Table of Contents
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Pathfinding and Terrain
Mission scripts use PathType, LandTypes, and IRecalcPathParams with GamePlay.gpFindPath() for pathfinding. RecalcPathState indicates the result. ActorName provides helpers for parsing and building actor names (mission number + short name).
RecalcPathState
Kind: enum
Result of a pathfinding request.
| Value | Description |
|---|---|
FAILED |
Path finding failed. |
SUCCESS |
Path found. |
WAIT |
Still computing. |
Check IRecalcPathParams.State after calling gpFindPath.
PathType
Kind: enum
Type of path to compute.
| Value | Description |
|---|---|
GROUND |
Ground path. |
RAIL |
Rail path. |
WATER |
Water path. |
AVIA |
Air path. |
Pass to GamePlay.gpFindPath(Point2d a, double ra, Point2d b, double rb, PathType type, int army).
LandTypes
Kind: enum (Flags)
Terrain type at a point (from GamePlay.gpLandType(double x, double y)).
| Value | Description |
|---|---|
NONE |
0 |
CITY |
0x10 |
ROAD |
0x20 |
RAIL |
0x40 |
HIGHWAY |
0x80 |
WATER |
0x1C |
OBJECTS_MASK |
0x03 |
ROAD_MASK |
0xE0 |
IRecalcPathParams
Kind: interface
Returned by GamePlay.gpFindPath(). Contains the result state, path waypoints, bridges, and length.
| Property | Type | Description |
|---|---|---|
State |
RecalcPathState | FAILED, SUCCESS, or WAIT. |
Bridges |
AiBridge[] | Bridges on the path. |
Path |
AiWayPoint[] | Waypoints of the path. |
Length |
double | Path length. |
Usage
var prms = GamePlay.gpFindPath(start, rStart, end, rEnd, PathType.GROUND, army);
if (prms.State == RecalcPathState.SUCCESS)
{
foreach (var wp in prms.Path)
// use wp.P, wp.Speed
}
ActorName
Kind: static class
Utility for actor names: full names are "missionNumber:shortName" (e.g. "0:PlayerSpawn").
| Method | Return | Description |
|---|---|---|
bool IsShort(string actorName) |
bool | True if the name has no ':' (short name only). |
string Full(int missionNumber, string shortActorName) |
string | Build full name: "missionNumber:shortName". |
void Parce(string fullActorName, out int missionNumber, out string shortName) |
— | Parse full name into mission number and short name. (Note: method name is "Parce", not "Parse".) |
string Short(string fullActorName) |
string | Get short name part (after ':'). |
int MissionNumber(string fullActorName) |
int | Get mission number part (before ':'). |
Use when building names for GamePlay.gpActorByName() or when parsing actor names from events (e.g. in OnActorCreated the actor’s Name() is the full name).