Skip to main content

Bots

Adds and controls bot heroes: fake clients with a hero and a CCitadelPlayerBotNPCBrain.

public static class Bots

Namespace: DeadworksManaged.Api
Source: Bots.cs#L7

Notes​

A fake client from Server.CreateFakeClient also gets a brain, but no hero.

Properties​

Bots.AiEnabled​

Whether bot heroes play on their own. Off by default on servers without a matchmaking lobby. Same as citadel_solo_bot_match.

Signature

public static bool AiEnabled { get; }

Source: Bots.cs#L95

Bots.Brains​

Every bot brain on the map.

Signature

public static IEnumerable<CCitadelPlayerBotNPCBrain> Brains { get; }

Source: Bots.cs#L112

Methods​

Bots.Add()​

Adds a bot hero, like citadel_create_unit. Returns its pawn, or null if bots can't play the hero, the server is full or no map is loaded.

Signature

public static CCitadelPlayerPawn? Add(Heroes? hero, int team, Vector3 position, BotDifficulty? difficulty = null, bool assignLane = true)

Parameters

  • hero: Hero. Null picks a random one.
  • team: 2 Amber, 3 Sapphire.
  • position: Spawn position, on the navmesh.
  • difficulty: Null uses citadel_default_bot_difficulty.
  • assignLane: Let the game pick a lane.

Notes The bot joins as a fake client named BotN. Its hero finishes loading shortly after. Wait before reading its abilities. Remove it with Server.Kick. It only plays while AiEnabled is on.

Source: Bots.cs#L22

Bots.SetMoveInput()​

Fills in a usercmd that moves a bot hero towards a point. Call from IDeadworksPlugin.OnProcessUsercmds while AiEnabled is off.

Signature

public static void SetMoveInput(CCitadelUserCmdPB usercmd, CCitadelPlayerPawn pawn, Vector3 moveTo, Vector3? lookAt = null, bool jump = false)

Parameters

  • usercmd: The bot's usercmd.
  • pawn: The bot hero.
  • moveTo: Point to move towards. Height is ignored.
  • lookAt: Point to aim at while moving. Null faces the direction of travel.
  • jump: Press jump.

Source: Bots.cs#L53

Bots.SetAiEnabled()​

Turns the bot AI on or off for every bot. Returns false if no map is loaded.

Signature

public static bool SetAiEnabled(bool enabled)

Source: Bots.cs#L103