Unit/Object
Written by: Alian713, Kramb
1. xsCreateUnit¶
Returning Type: int
Prototype: int xsCreateUnit(int objectId, int playerId, vector location, bool foundation, bool playCreatedSound, bool checkCollision)
Parameters:
int objectId: The ID of the object to createint playerId: The player to create the unit forvector location: The location to create the unit at- (Optional)
bool foundation: If true, create a foundation (ignored for non buildings) - (Optional)
bool playCreatedSound: If false, don't play the unit creation sound - (Optional)
bool checkCollision: If false, don't check for collision before creating the unit
Creates a unit on the map and returns its ID, or -1 if creation failed
2. xsRemoveUnit¶
Returning Type: bool
Prototype: bool xsRemoveUnit(int unitId)
Parameters:
int unitId: The unit to remove
Removes the given unit from the map
3. xsGetObjectAttribute¶
Returning Type: float
Prototype: float xsGetObjectAttribute(int playerId, int objectId, int attribute, int damageClass)
Parameters:
int playerId: The player whose object to get the attribute forint objectId: The object to get the attribute forint attribute: The attribute to getint damageClass: For use with armor/attack attributes - specifies which armor/attack class to get
Returns the attribute value for an object. Note that values for certain attributes such as sound events must be converted using bitCastToInt after being returned.
4. xsGetUnitAttribute¶
Returning Type: float
Prototype: float xsGetUnitAttribute(int unitId, int attribute, int damageClass)
Parameters:
int unitId: The unit to get the attribute for.int attribute: The attribute to getint damageClass: For use with armor/attack attributes - specifies which armor/attack class to get
Returns the attribute value for a specific unit on the map. Note that values for certain attributes such as sound events must be converted using bitCastToInt after being returned.
5. xsDoesUnitExist¶
Returning Type: bool
Prototype: bool xsDoesUnitExist(int unitId)
Parameters:
int unitId: The unit ID to check
Returns true if a unit with the given ID exists on the map.
6. xsGetUnitOwner¶
Returning Type: int
Prototype: int xsGetUnitOwner(int unitId)
Parameters:
int unitId: The unit to get the owner ID for
Returns the lobby index of the player owning this unit.
7. xsGetUnitPosition¶
Returning Type: vector
Prototype: vector xsGetUnitPosition(int unitId)
Parameters:
int unitId: The unit to get the position for
Returns the current position of a unit.
8. xsSetUnitPosition¶
Returning Type: bool
Prototype: bool xsSetUnitPosition(int unitId, vector position, bool checkCollision)
Parameters:
int unitId: The unit to set the position forvector position: The position to set- (Optional)
bool checkCollision: If false, don't check for collision before moving the unit
Sets the given unit's position.
9. xsGetUnitName¶
Returning Type: string
Prototype: string xsGetUnitName(int unitId, bool internalName)
Parameters:
int unitId: The unit ID to check- (Optional)
bool internalName: Returns the internal name of the unit if set.!#xs falseby default.
Returns the current name of a given unit
10. xsGetObjectName¶
Returning Type: string
Prototype: string xsGetObjectName(int objectId, int playerId, bool internalName)
Parameters:
int objectId: The object to get the name forint playerId: The player to get the object's name for- (Optional)
bool internalName: Returns the internal name of the object if set.!#xs falseby default.
Returns the current name of the given object for the specified player.
11. xsGetUnitTargetUnitId¶
Returning Type: int
Prototype: int xsGetUnitTargetUnitId(int unitId)
Parameters:
int unitId: The unit to get the target for
Returns the ID of the currently targeted unit for this unit
12. xsGetUnitMoveTarget¶
Returning Type: vector
Prototype: vector xsGetUnitMoveTarget(int unitId)
Parameters:
int unitId: The unit to get the movement target for
Returns the location this unit is currently moving to
13. xsGetUnitGroupId¶
Returning Type: int
Prototype: int xsGetUnitGroupId(int unitId)
Parameters:
int unitId: The unit to get the group ID (formation) for
Returns the ID of the group (formation) for this unit
14. xsGetGroupMoveTarget¶
Returning Type: vector
Prototype: vector xsGetGroupMoveTarget(int groupId)
Parameters:
int groupId: The group (formation) to get the movement target for
Returns the location this group (formation) is currently moving to
15. xsIsObjectAvailable¶
Returning Type: bool
Prototype: bool xsIsObjectAvailable(int objectId, int playerId)
Parameters:
int objectId: The object to check the availability forint playerId: The player to get the object's availability for
Returns true if this object can currently be trained or built.
16. xsGetUnitHitpoints¶
Returning Type: float
Prototype: float xsGetUnitHitpoints(int unitId)
Parameters:
int unitId: The unit to get the HP for
Returns the given unit's HP
17. xsSetUnitHitpoints¶
Returning Type: bool
Prototype: bool xsSetUnitHitpoints(int unitId, float value)
Parameters:
int unitId: The unit to set the HP forfloat value: The value to set the HP to
Sets the given unit's HP
18. xsGetUnitBuildPoints¶
Returning Type: float
Prototype: float xsGetUnitBuildPoints(int unitId)
Parameters:
int unitId: The unit to get the Build Points for
Returns the given unit's Built Points
19. xsSetUnitBuildPoints¶
Returning Type: bool
Prototype: bool xsSetUnitBuildPoints(int unitId, float value)
Parameters:
int unitId: The unit to set the build points forfloat value: The value to set the build points to
Sets the given unit's Build Points
20. xsGetUnitObjectId¶
Returning Type: int
Prototype: int xsGetUnitObjectId(int unitId)
Parameters:
int unitId: The unit to get the object ID for
Returns the given unit's ID in data
21. xsGetUnitCopyId¶
Returning Type: int
Prototype: int xsGetUnitCopyId(int unitId)
Parameters:
int unitId: The unit to get the copy ID for
Returns the given unit's copy ID in data
22. xsGetObjectCopyId¶
Returning Type: int
Prototype: int xsGetObjectCopyId(int playerId, int objectId)
Parameters:
int playerId: The player to get the object's copy ID forint objectId: The object to get the copy ID for
Returns the given object's copy ID in data for the specified player
23. xsGetUnitClass¶
Returning Type: int
Prototype: int xsGetUnitClass(int unitId)
Parameters:
int unitId: The unit to get the class for
Returns the given unit's class See cClass constants
24. xsGetObjectClass¶
Returning Type: int
Prototype: int xsGetObjectClass(int playerId, int objectId)
Parameters:
int playerId: The player to get the object's class forint objectId: The object to get the class for
Returns the given object's class for the specified player. See cClass constants
25. xsGetUnitType¶
Returning Type: int
Prototype: int xsGetUnitType(int unitId)
Parameters:
int unitId: The unit to get the type for
Returns the given unit's type. See cObjectType constants
26. xsGetObjectType¶
Returning Type: int
Prototype: int xsGetObjectType(int playerId, int objectId)
Parameters:
int playerId: The player to get the object's type forint objectId: The object to get the type for
Returns the given object's type for the specified player. See cObjectType constants
27. xsGetUnitAttributeTypesHeld¶
Returning Type: int
Prototype: int xsGetUnitAttributeTypesHeld(int unitId)
Parameters:
int unitId: The unit to get the held resource types for
Returns the given unit's type of resources held as an array of ints. The only unit that this currently returns multiple values for is the trade cart/cog.
28. xsGetUnitAttributeHeld¶
Returning Type: float
Prototype: float xsGetUnitAttributeHeld(int unitId, int attributeId)
Parameters:
int unitId: The unit to get the resource held for- (Optional)
int attributeId: The ID of the resource to get. If unspecified, return the first resource which the unit holds
Returns the given unit's amount of the specified resource held.
29. xsSetUnitAttributeHeld¶
Returning Type: bool
Prototype: bool xsSetUnitAttributeHeld(int unitId, float value, int attributeId)
Parameters:
int unitId: The unit to set the resource held forfloat value: The amount to set the held resource to- (Optional)
int attributeId: The ID of the resource to set. If unspecified, sets the first resource which the unit holds
Sets the given unit's amount of the specified resource. The only unit this can currently add extra resources to is the trade cart/cog.
30. xsGetUnitCharge¶
Returning Type: float
Prototype: float xsGetUnitCharge(int unitId)
Parameters:
int unitId: The unit to get the charge for
Returns the given unit's charge
31. xsSetUnitCharge¶
Returning Type: bool
Prototype: bool xsSetUnitCharge(int unitId, float value)
Parameters:
int unitId: The unit to set the charge forfloat value: The value to set the charge to
Sets the given unit's charge
32. xsGetGarrisonedInUnitId¶
Returning Type: int
Prototype: int xsGetGarrisonedInUnitId(int unitId)
Parameters:
int unitId: The unit to get the garrisoned in
Returns the ID of the unit in which this unit is garrisoned in
33. xsGetGarrisonedUnitIds¶
Returning Type: int
Prototype: int xsGetGarrisonedUnitIds(int unitId)
Parameters:
int unitId: The unit to get the garrisoned objects for
Returns an int array which contains the IDs of all the units garrisoned inside this unit
34. xsGetObjectCount¶
Returning Type: int
Prototype: int xsGetObjectCount(int playerId, int objectOrClassId)
Parameters:
int playerId: The player to get the object count forint objectOrClassId: The ID of the object or class to get the count for
Returns the number of currently alive objects with the given ID of the specified player
35. xsGetObjectCountTotal¶
Returning Type: int
Prototype: int xsGetObjectCountTotal(int playerId, int objectOrClassId)
Parameters:
int playerId: The player to get the object count forint objectOrClassId: The ID of the object or class to get the count for
Returns the number of currently alive/standing + queued/foundation objects with the given ID of the specified player
36. xsObjectHasAction¶
Returning Type: bool
Prototype: bool xsObjectHasAction(int playerId, int objectOrClassId, int actionId, int targetPlayerId, int targetType, int targetUnitLevel)
Parameters:
int playerId: The player to check unit actions forint objectOrClassId: The ID of the object or class to check actions forint actionId: The type of action to check for- (Optional)
int targetPlayerId: Check if the action is being performed on a unit (eg. attacking) of this player. Can use -1 to ignore this filter. - (Optional)
int targetType: Check if the action is being performed on a unit of this type. Values 9xx refer to classes. Can use -1 to ignore this filter. - (Optional)
int targetUnitLevel: Check if the action is being performed on a unit with thisInterface Kind(look in the A.G.E.), eg: 3 - villagers, 4 - most military units. Can be used as an alternative totargetType. If both are used, will pick units that match either. Can use -1 to ignore this filter.
Checks and returns if any unit matching the set filters of the given player has the specified action.