Class: GarrisonHolder

GarrisonHolder()

new GarrisonHolder()

Source:

Members

HEAL_TIMEOUT

Time between heals.
Source:

Methods

AllowGarrisoning(allow)

Set this entity to allow or disallow garrisoning in the entity. Every component calling this function should do it with its own ID, and as long as one component doesn't allow this entity to garrison, it can't be garrisoned When this entity already contains garrisoned soldiers, these will not be able to ungarrison until the flag is set to true again. This more useful for modern-day features. For example you can't garrison or ungarrison a driving vehicle or plane.
Parameters:
Name Type Description
allow boolean Whether the entity should be garrisonable.
Source:

Eject(entity, forced) → {boolean}

Parameters:
Name Type Description
entity number The entity ID of the entity to eject.
forced boolean Whether eject is forced (e.g. if building is destroyed).
Source:
Returns:
Whether the entity was ejected.
Type
boolean

EjectOrKill()

Eject or kill a garrisoned unit which can no more be garrisoned (garrisonholder's health too small or ownership changed).
Source:

Garrison(entity) → {boolean}

Parameters:
Name Type Description
entity number The entityID to garrison.
Source:
Returns:
- Whether the entity was garrisoned.
Type
boolean

GetAllowedClasses() → {Array}

Source:
Returns:
unit classes which can be garrisoned inside this particular entity. Obtained from the entity's template.
Type
Array

HealTimeout()

Source:

Init()

Initialize GarrisonHolder Component Garrisoning when loading a map is set in the script of the map, by setting initGarrison which should contain the array of garrisoned entities.
Source:

IsEjectable(entity) → {boolean}

Whether an entity is ejectable.
Parameters:
Name Type Description
entity number The entity-ID to be tested.
Source:
Returns:
- Whether the entity is ejectable.
Type
boolean

IsGarrisoned(entity) → {boolean}

Parameters:
Name Type Description
entity number The entity to verify.
Source:
Returns:
- Whether the given entity is garrisoned in this GarrisonHolder.
Type
boolean

IsGarrisoningAllowed() → {boolean}

Source:
Returns:
- Whether (un)garrisoning is allowed.
Type
boolean

LoadingRange() → {Object}

Source:
Returns:
max and min range at which entities can garrison the holder.
Type
Object

OnDestroy()

Cancel timer when destroyed.
Source:

OnDiplomacyChanged()

Eject all foreign garrisoned entities which are no more allied.
Source:

OnGlobalInitGame()

Initialise the garrisoned units.
Source:

OnGlobalOwnershipChanged()

If a garrisoned entity is captured, or about to be killed (so its owner changes to '-1'), remove it from the building so we only ever contain valid entities.
Source:

OnGlobalSkirmishReplacerReplaced()

Update list of garrisoned entities when a game inits.
Source:

OnHealthChanged()

Used to check if the garrisoning entity's health has fallen below a certain limit after which all garrisoned units are unloaded.
Source:

SetInitGarrison(entities)

Sets the intitGarrison to the specified entities. Used by the mapreader.
Parameters:
Name Type Description
entities Array.<number> The entity IDs to garrison on init.
Source:

Unload(entity) → {boolean}

Tell unit to unload from this entity.
Parameters:
Name Type Description
entity number The entity to unload.
Source:
Returns:
Whether the command was successful.
Type
boolean

UnloadAll() → {boolean}

Unload all units from the entity and order them to move to the rally point.
Source:
Returns:
Whether the unloading was successful.
Type
boolean

UnloadAllByOwner(owner) → {boolean}

Unload all units, that belong to certain player and order all own units to move to the rally point.
Parameters:
Name Type Description
owner number Id of the player whose units should be ejected.
Source:
Returns:
Whether the unloading was successful.
Type
boolean

UnloadEntities(entities) → {boolean}

Tell units to unload from this entity.
Parameters:
Name Type Description
entities Array.<number> The entities to unload.
Source:
Returns:
- Whether all unloads were successful.
Type
boolean

UnloadTemplate(template, owner, all) → {boolean}

Unload one or all units that match a template and owner from us.
Parameters:
Name Type Description
template string Type of units that should be ejected.
owner number Id of the player whose units should be ejected.
all boolean Whether all units should be ejected.
Source:
Returns:
Whether the unloading was successful.
Type
boolean

UpdateGarrisonFlag()

Updates the garrison flag depending whether something is garrisoned in the entity.
Source: