swiftlys2/docs/api/ai/
API Reference Services

IGameService

Interface
Namespace: SwiftlyS2.Shared.Services · Assembly: SwiftlyS2.CS2.dll
public interface IGameService
View source

Properties

MatchData

Gets a read-only reference to the current match data.

ref readonly CCSMatch MatchData { get; }
Property Value

Methods

AddCTBonusPoints(int)

Adds bonus points to the Counter-Terrorist team.

void AddCTBonusPoints(int points)
Parameters
  • pointsintBonus points to add.

AddCTScore(int)

Adds score to the Counter-Terrorist team.

void AddCTScore(int score)
Parameters
  • scoreintScore to add.

AddCTWins(int)

Adds wins to the Counter-Terrorist team.

void AddCTWins(int numWins)
Parameters
  • numWinsintNumber of wins to add.

AddTerroristBonusPoints(int)

Adds bonus points to the Terrorist team.

void AddTerroristBonusPoints(int points)
Parameters
  • pointsintBonus points to add.

AddTerroristScore(int)

Adds score to the Terrorist team.

void AddTerroristScore(int score)
Parameters
  • scoreintScore to add.

AddTerroristWins(int)

Adds wins to the Terrorist team.

void AddTerroristWins(int numWins)
Parameters
  • numWinsintNumber of wins to add.

EmitDecoy(Vector, QAngle, Vector, CBasePlayerPawn?)

Creates a decoy grenade projectile. Thread unsafe, use async variant instead for non-main thread context.

[ThreadUnsafe]
CDecoyProjectile EmitDecoy(Vector pos, QAngle angle, Vector velocity, CBasePlayerPawn? owner)
Parameters
  • posVectorThe position where the decoy grenade projectile will be created.
  • angleQAngleThe angle at which the decoy grenade projectile will be created.
  • velocityVectorThe velocity of the decoy grenade projectile.
  • ownerCBasePlayerPawn?The owner of the decoy grenade projectile.
Returns
The created decoy grenade projectile.

EmitDecoyAsync(Vector, QAngle, Vector, CBasePlayerPawn?)

Creates a decoy grenade projectile asynchronously.

Task<CDecoyProjectile> EmitDecoyAsync(Vector pos, QAngle angle, Vector velocity, CBasePlayerPawn? owner)
Parameters
  • posVectorThe position where the decoy grenade projectile will be created.
  • angleQAngleThe angle at which the decoy grenade projectile will be created.
  • velocityVectorThe velocity of the decoy grenade projectile.
  • ownerCBasePlayerPawn?The owner of the decoy grenade projectile.
Returns
The created decoy grenade projectile.

EmitFlashbang(Vector, QAngle, Vector, CBasePlayerPawn?)

Creates a flashbang grenade projectile. Thread unsafe, use async variant instead for non-main thread context.

[ThreadUnsafe]
CFlashbangProjectile EmitFlashbang(Vector pos, QAngle angle, Vector velocity, CBasePlayerPawn? owner)
Parameters
  • posVectorThe position where the flashbang grenade projectile will be created.
  • angleQAngleThe angle at which the flashbang grenade projectile will be created.
  • velocityVectorThe velocity of the flashbang grenade projectile.
  • ownerCBasePlayerPawn?The owner of the flashbang grenade projectile.
Returns
The created flashbang grenade projectile.

EmitFlashbangAsync(Vector, QAngle, Vector, CBasePlayerPawn?)

Creates a flashbang grenade projectile asynchronously.

Task<CFlashbangProjectile> EmitFlashbangAsync(Vector pos, QAngle angle, Vector velocity, CBasePlayerPawn? owner)
Parameters
  • posVectorThe position where the flashbang grenade projectile will be created.
  • angleQAngleThe angle at which the flashbang grenade projectile will be created.
  • velocityVectorThe velocity of the flashbang grenade projectile.
  • ownerCBasePlayerPawn?The owner of the flashbang grenade projectile.
Returns
The created flashbang grenade projectile.

EmitHEGrenade(Vector, QAngle, Vector, CBasePlayerPawn?)

Creates a HE grenade projectile. Thread unsafe, use async variant instead for non-main thread context.

[ThreadUnsafe]
CHEGrenadeProjectile EmitHEGrenade(Vector pos, QAngle angle, Vector velocity, CBasePlayerPawn? owner)
Parameters
  • posVectorThe position where the HE grenade projectile will be created.
  • angleQAngleThe angle at which the HE grenade projectile will be created.
  • velocityVectorThe velocity of the HE grenade projectile.
  • ownerCBasePlayerPawn?The owner of the HE grenade projectile.
Returns
The created HE grenade projectile.

EmitHEGrenadeAsync(Vector, QAngle, Vector, CBasePlayerPawn?)

Creates a HE grenade projectile asynchronously.

Task<CHEGrenadeProjectile> EmitHEGrenadeAsync(Vector pos, QAngle angle, Vector velocity, CBasePlayerPawn? owner)
Parameters
  • posVectorThe position where the HE grenade projectile will be created.
  • angleQAngleThe angle at which the HE grenade projectile will be created.
  • velocityVectorThe velocity of the HE grenade projectile.
  • ownerCBasePlayerPawn?The owner of the HE grenade projectile.
Returns
The created HE grenade projectile.

EmitMolotov(Vector, QAngle, Vector, Team, CBasePlayerPawn?)

Creates a molotov grenade projectile. Thread unsafe, use async variant instead for non-main thread context.

[ThreadUnsafe]
CMolotovProjectile EmitMolotov(Vector pos, QAngle angle, Vector velocity, Team team, CBasePlayerPawn? owner)
Parameters
  • posVectorThe position where the molotov grenade projectile will be created.
  • angleQAngleThe angle at which the molotov grenade projectile will be created.
  • velocityVectorThe velocity of the molotov grenade projectile.
  • teamTeamThe team of the molotov grenade projectile.
  • ownerCBasePlayerPawn?The owner of the molotov grenade projectile.
Returns
The created molotov grenade projectile.

EmitMolotovAsync(Vector, QAngle, Vector, Team, CBasePlayerPawn?)

Creates a molotov grenade projectile asynchronously.

Task<CMolotovProjectile> EmitMolotovAsync(Vector pos, QAngle angle, Vector velocity, Team team, CBasePlayerPawn? owner)
Parameters
  • posVectorThe position where the molotov grenade projectile will be created.
  • angleQAngleThe angle at which the molotov grenade projectile will be created.
  • velocityVectorThe velocity of the molotov grenade projectile.
  • teamTeamThe team of the molotov grenade projectile.
  • ownerCBasePlayerPawn?The owner of the molotov grenade projectile.
Returns
The created molotov grenade projectile.

EmitSmokeGrenade(Vector, QAngle, Vector, Team, CBasePlayerPawn?)

Creates a smoke grenade projectile. Thread unsafe, use async variant instead for non-main thread context.

[ThreadUnsafe]
CSmokeGrenadeProjectile EmitSmokeGrenade(Vector pos, QAngle angle, Vector velocity, Team team, CBasePlayerPawn? owner)
Parameters
  • posVectorThe position where the smoke grenade projectile will be created.
  • angleQAngleThe angle at which the smoke grenade projectile will be created.
  • velocityVectorThe velocity of the smoke grenade projectile.
  • teamTeamThe team associated with the smoke grenade projectile.
  • ownerCBasePlayerPawn?The owner of the smoke grenade projectile.
Returns
The created smoke grenade projectile.

EmitSmokeGrenadeAsync(Vector, QAngle, Vector, Team, CBasePlayerPawn?)

Creates a smoke grenade projectile asynchronously.

Task<CSmokeGrenadeProjectile> EmitSmokeGrenadeAsync(Vector pos, QAngle angle, Vector velocity, Team team, CBasePlayerPawn? owner)
Parameters
  • posVectorThe position where the smoke grenade projectile will be created.
  • angleQAngleThe angle at which the smoke grenade projectile will be created.
  • velocityVectorThe velocity of the smoke grenade projectile.
  • teamTeamThe team associated with the smoke grenade projectile.
  • ownerCBasePlayerPawn?The owner of the smoke grenade projectile.
Returns
The created smoke grenade projectile.

GetWinningTeam()

Gets the winning team ID.

int GetWinningTeam()
Returns
Team ID of the winner, or 0 if tie.

GoToIntermission(bool)

Go to the intermission phase of the game.

void GoToIntermission(bool abortedMatch = false)
Parameters
  • abortedMatchbooloptionalIndicates whether the match was aborted

GoToOvertime(int)

Enters overtime mode.

void GoToOvertime(int numOvertimesToAdd = 1)
Parameters
  • numOvertimesToAddintoptionalNumber of overtime periods to add.

IncrementRound(int)

Increments the round count.

void IncrementRound(int numRounds = 1)
Parameters
  • numRoundsintoptionalNumber of rounds to increment.

Reset()

Resets all match data to initial state.

void Reset()

SetPhase(GamePhase)

Sets the current game phase.

void SetPhase(GamePhase phase)
Parameters

SwapTeamScores()

Swaps the team scores between Terrorist and Counter-Terrorist.

void SwapTeamScores()

TerminateRound(RoundEndReason, float)

Ends the current round with the specified reason after an optional delay

void TerminateRound(RoundEndReason reason, float delay)
Parameters