Squad beta
Class of @v12-engine/engine/ai
export declare class SquadA squad of the brain (ai.squads.make, named, all): a handle over its data, with the task methods. A squad's units are as of the think's picture: the dead and those its owner no longer holds are dropped as the squads module looks at it
Members
constructor
constructor(
squads: Squads,
data: SquadData);Constructs a new instance of the Squad class
add
add(units: Iterable<EntityState | number>, why?: string): this;Adds units: what its owner may have (see Squads.make), taken out of any other squad
alive
get alive(): boolean;Whether it is still one of the brain's squads: not once disbanded
attack
attack(target: Vec2 | EntityState | number, options?: {
avoid?: 'army' | false;
via?: Vec2;
then?: TaskOrder;
}): this;Goes to fight at a place or a target (an entity, or its id): attack-moves there, fighting what it meets, regroups on the way, retreats on the odds. Done cleared once there with nothing left to fight, lost when the target is gone. avoid: 'army' goes round where their strength is on the way (the threat map and their army as last seen), when there is a way round. via: a place to go by on the way (a way of its own: Random Paths). then: the task after it
attackMove
attackMove(at: Vec2, options?: {
then?: TaskOrder;
}): this;Attack-moves to a place, as a group of units would on a click: the squad's attack without its regroup
capture
capture(id: string): this;Sends its units to take a capture point of the game's (capturePack), by its id: they fight their way in and stand in it until it is theirs (captured), or it is gone (lost)
centre
centre(): Vec2 | undefined;Its middle: none with no unit left
changed
changed(why: string): void;Writes down the last change of its units or task, for the report
creep
creep(camp: Vec2): this;Takes a camp of creeps: fights there until the camp is cleared. Done cleared
current
get current(): TaskState | undefined;What it is doing: none for a squad told nothing yet
data
readonly data: SquadData;What it is, as plain data: what a save keeps
defend
defend(at: Vec2, radius?: number): this;Holds a place against what comes within radius of it (16 when left out): fights what comes, goes back once it is gone. Never over by itself: its owner says when
disband
disband(why?: string): void;Disbands it: its units go back to its owner (a goal's), or to the pool (a squad of its own)
done
get done(): TaskDone | undefined;How its task ended: none while it goes on, or while it has none
drop
drop(at: Vec2, transports: readonly number[], options?: {
then?: TaskOrder;
}): this;Carried by transports to a place it cannot walk to, let out on the land nearest it (the drop task): done landed, then what then says (an attack where it landed)
escort
escort(target: EntityState | number): this;Goes with a unit of the player's or an ally's, fighting what comes near it. Done lost when it is gone
fight
fight(at: Vec2, units?: readonly number[], target?: number, queue?: boolean): void;Sends its units, all or some, to fight at a place, or a target there: an attack-move, or an attack
finish
finish(done: TaskDone): void;Ends its task, saying how: what a task's think calls once it is over
gather
gather(at: Vec2, options?: {
minForces?: number;
seconds?: number;
then?: TaskOrder;
}): this;Gathers at a rally point before going on (then): until minForces of it (a share, 1 when left out) is there, or seconds have gone by. Done arrived, and on to then
harass
harass(at: Vec2, options?: {
avoid?: 'army' | false;
then?: TaskOrder;
}): this;Goes for the workers at a place, round where their army is (avoid: 'army' unless told otherwise), the workers first once there. Done cleared
hold
hold(at?: Vec2): this;Goes to a place (where it stands when left out) and holds it: stands, fighting only what comes within reach
idle
get idle(): boolean;Whether it has nothing to do: no task, or its task is over
idleUnits
idleUnits(): EntityState[];Its units that stand with nothing to do: what lost its order, or never had one
length
get length(): number;How many units it has
mayResend
mayResend(): boolean;Whether its last order was sent long enough ago to send one again (RESEND seconds): what keeps a stuck unit from being told every think
move
move(at: Vec2, options?: {
then?: TaskOrder;
}): this;Walks to a place, fighting nothing on the way. Done arrived
name
get name(): string;Its name: unique among the brain's squads
options
get options(): SquadOptions;How it behaves: its own options over the brain's
order
order(order: OrderInit, units?: readonly number[], queue?: boolean): void;Sends its units an order (move, hold, the game's), all or some of them: counted as the task's last
owner
get owner(): string;Who it belongs to: the goal, rule or module that made it
patrol
patrol(points: readonly Vec2[]): this;Walks a round of places, one after the other and back to the first, fighting what it meets on the way (an attack-move to each): a mission's guards on the road, a watch round the walls. Never over by itself: its owner says when
remove
remove(units: Iterable<EntityState | number>, why?: string): this;Takes units out: they go back to the pool (its owner lets go of them)
retreat
retreat(to?: Vec2, why?: string): this;Falls back to a place (home when left out), fighting nothing on the way. Done retreated
scout
scout(points: readonly Vec2[]): this;Goes to look at places, one after the other: each is looked at once in sight, or reached as near as the ground lets. Done arrived
setStance
setStance(id: string, units?: readonly number[]): void;Puts its units, all or some, in a stance, where the game has stances (stancesPack): those not in it already. A squad that holds is defensive, one sent to fight aggressive
spread
spread(): number;How far from its middle a unit may be before it counts as strayed (SquadOptions.spread): grows with the squad when not given
squads
readonly squads: Squads;The squads it is one of
strength
strength(): number;How strong it is together (UnitSet.strength)
task
task<D extends object, M extends object>(def: TaskDef<D, M>, data: D & TaskCommon): this;Gives it a task: one of the kit's by its word (attack), or of the game's (defineTask, by its def or its id). What it was doing is over. Its first orders go at once; the squads module watches it from then on
task
task(kind: string, data?: TaskData): this;Gives the squad a task of a game's own, by its definition and data; what it was doing is over and the squad is returned
units
units(): UnitSet;Its units, as of the think's picture: those alive and the player's