-
Notifications
You must be signed in to change notification settings - Fork 160
Unit
HungryForFood edited this page Aug 15, 2021
·
10 revisions
Return | Method (arguments) | Description |
---|---|---|
void | AddMessage(string sMessage, opt PlayerID iNotifyPlayer) | If no player ID is specified, defaults to the owner of the unit. |
Return | Method (arguments) | Description |
---|---|---|
int | BarbarianCombatBonus() | Returns this unit's combat bonus against barbarians. |
Return | Method (arguments) | Description |
---|---|---|
int | CanChangePort(Plot pPlot) | Can this unit teleport to another coastal city if the specified plot is a coastal city? Note that in Community Patch, units other than the Great Admiral can be given this ability. |
bool | CanCreateGreatWork(Plot pPlot) | Can this unit create a Great Work at the specified plot? |
bool | CanCrossIce() | |
bool | CanCrossMountains() | |
bool | CanCrossOceans() | |
bool | CanPlunderTradeRoute(Plot pPlot) | Can this unit plunder a trade route while at the specified plot? |
bool | CanUpgradeTo(UnitType iUpgradeUnitType, opt bool bTestVisible = false) | If bTestVisible is set to true, then it only checks if the upgrade can show up in the UI. |
bool | CanUpgradeInTerritory(opt bool bTestVisible) | Can this unit upgrade to anything right now? If bTestVisible is set to true, then it only checks if the upgrade can show up in the UI. |
void | ChangeExperienceTimes100(int iChange, opt int iMax = -1, opt bool bFromCombat = false, opt bool bInBorders = false, opt bool bUpdateGlobal) | Changes the total amount of experience multiplied by 100 this unit has. Reduces rounding error compared to ChangeExperience. iMax is to prevent from exceeding a certain value; bFromCombat affects game speed scaling, triggering post combat promotions, experience gain modifiers, etc; bInBorders affect certain policies which increase experience gained in borders; bUpdateGlobal affects great general and great admiral generation. |
void | ChangeMaxHitPointsBase(int iValue) | Changes the maximum hit points of this unit, before any other modifiers such as promotions. |
bool | CreateGreatWork() |
Return | Method (arguments) | Description |
---|---|---|
void | EndTrader() | The unit ends its trade route. |
bool | ExtraFeatureDamage() | Does this unit take extra damage from features? Usually due to promotions. |
bool | ExtraTerrainDamage() | Does this unit take extra damage from terrain? Usually due to promotions. |
Return | Method (arguments) | Description |
---|---|---|
table | GetActivePath() | Returns a Lua table with information on the unit's current movement path. Columns are 'X', 'Y', 'RemainingMovement', 'Turn', 'Flags', 'Invisible', AdjVisible'. |
string | GetAIOperationInfo() | Returns a string describing the AI's operation with this unit. |
int | GetAllianceCSStrength() | Returns this unit's combat bonus due to the owner's traits which grant a bonus based on city state alliances, or if the unit owner is a city state, checks if the ally has such a trait, then grants a combat bonus. |
int | GetAuraEffect() | How much combat bonus do other units within range of this unit get? Sum of the normal Great General bonus with this unit's extra bonus. |
int | GetAuraRange() | How far from this unit do other units still get combat bonuses? Sum of the default Great General range with this unit's extra range. |
ImprovementType | GetCombatBonusImprovement() | What is the improvement type which gives this unit a combat bonus? |
int | GetCombatVersusOtherReligionOwnLands(Unit pOtherUnit) | Returns the combat bonus against the other unit in this unit's lands due to religious difference. Method will use the other unit's plot, and check if the other unit's owner is actually of a different religion. |
int | GetCombatVersusOtherReligionTheirLands(Unit pOtherUnit) | Returns the combat bonus against the other unit in foreign lands due to religious difference. Method will use the other unit's plot, and check if the other unit's owner is actually of a different religion. |
ContractType | GetContractUnit() | Method for JFDLC. Returns the contract this unit is part of. |
int | GetDanger() | How much danger does the AI think this unit is in? |
int | GetExperienceTimes100() | Returns the total amount of experience this unit has, multiplied by 100. Reduces rounding error compared to GetExperience. |
int | GetExtraReconRange() | What is the extra range we can see invisible units? Usually due to promotions. |
int | GetGiveCombatModToUnit() | Returns the combat bonus due to other units around this unit. |
int | GetMaxHitPointsBase() | Returns the maximum hit points of this unit as defined in the Units table, before any other modifiers such as promotions. |
string | GetMissionInfo() | Returns a string describing the AI's mission for this unit. |
int | GetMonopolyAttackBonus() | What is the attack bonus due to the player having resource monopolies? |
int | GetMonopolyDefenseBonus() | What is the defence bonus due to the player having resource monopolies? |
string | GetMovementRules(Unit pOtherUnit) | Method for JFDLC, related to the plague mechanic. |
int | GetMultiAttackBonus(Unit pOtherUnit) | Checks the number of times the other unit has been attacked this turn, then returns this unit's combat bonus against it due to having certain promotions and player traits. |
int | GetMultiAttackBonusCity(City pCity) | Checks the number of times the city has been attacked this turn, then returns this unit's combat bonus against it due to having certain promotions and player traits. |
int | GetNearbyCityBonusCombatMod() | Returns this unit's combat bonus due to being near to cities. |
int | GetNearbyImprovementBonusRange() | What is the maximum distance from the improvement where the unit still has a combat bonus? |
int | GetNearbyImprovementCombatBonus() | How much combat bonus does this unit get when near a certain improvement? |
UnitCombatType | GetUnitPromotionType() | Which combat class's promotion tree does this unit use? This can be different than the unit's actual combat class in the Community Patch. |
int | GetNearbyUnitClassModifierFromUnitClass() | Does this unit get a combat bonus from being near to units which have a certain unit class? |
int | GetNumResourceTotalNeededToUpgrade(ResourceType iResource , opt UnitType iUnitType) | What is the gross number of resources required before the unit can be upgraded to the specified unit type? If no unit type is specified, the method will determine based on the default upgrade unit type. Related to the database table Unit_ResourceQuantityTotals. |
int | GetPromotionDuration(PromotionType iPromotion) | How many turns after being gained before the specified promotion on this unit expires? This duration is related to the 'PromotionDuration' column in the 'UnitPromotions' database table. |
int | GetResistancePower(Unit pOtherUnit) | Returns the combat bonus towards the other unit due to the other unit's owner's warmongering. |
int | GetSapperAreaEffectBonus(City pCity) | What is this unit's sapper bonus due to being near a city? |
int | GetTradeRouteIndex() | Fetches the trade route index performed by this unit. Returns -1 if no valid value can be found. |
int | GetTurnPromotionGained(PromotionType iPromotion) | At what turn did this unit gain the specified promotion? Returns 0 if not a valid promotion. |
bool | greatperson() | Expends the unit if it is a great person. Returns true if successful. Note the full lower case and non-descriptive method name. To be deprecated in the future for a better name. |
string | GetZOCStatus() | Returns a tooltip if this unit ignores zones of control. |
Return | Method (arguments) | Description |
---|---|---|
bool | HasPromotion(PromotionType iPromotionType) |
Return | Method (arguments) | Description |
---|---|---|
bool | IgnoreFeatureDamage() | |
bool | IgnoreTerrainDamage() | |
bool | IsAdjacentToFeature(FeatureType iFeatureType) | |
bool | IsAdjacentToImprovement(ImprovementType iImprovementType) | |
bool | IsAdjacentToPlotType(PlotType iPlotType) | |
bool | IsAdjacentToResource(ResourceType iResourceType) | |
bool | IsAdjacentToTerrain(TerrainType iTerrainType) | |
bool | IsAdjacentToUnit(UnitType iUnitType, bool bFriendly, bool bEnemy) | |
bool | IsAdjacentToUnitClass(UnitClassType iUnitClass, bool bFriendly, bool bEnemy) | |
bool | IsAdjacentToUnitCombatType(UnitCombatType iUnitCombat, bool bFriendly, bool bEnemy) | |
bool | IsAdjacentToUnitPromotion(PromotionType iPromotion, bool bFriendly, bool bEnemy) | |
bool | IsCivilization(CivilizationType iCivilizationType) | Is this unit's owner the specified civilization type? |
bool | IsCoastalUpgradePrereq() | Checks if the unit has a coastal prerequisite defined in Unit_UpgradePrereqs. |
bool | IsContractUnit() | Method for JFDLC. Is this unit part of any contract? |
bool | IsHalfNearSapper(City pCity) | Is this unit close enough to the specified city to apply a partial sapper bonus, but not close enough for the full bonus to take effect? |
bool | IsGGFromBarbarians() | Can this unit generate Great General points from fighting barbarians? Either due to the player's traits, or from promotions. |
bool | IsHigherPopThan(Unit pOtherUnit) | Checks if this unit's owner has more population than the other unit's owner. |
bool | IsHillsUpgradePrereq() | Checks if the unit has a hills prerequisite defined in Unit_UpgradePrereqs. |
bool | IsHigherTechThan(Unit pOtherUnit) | Checks if this unit's prerequisite technology has a higher science cost than the other unit. |
bool | IsLargerCivThan(Unit pOtherUnit) | Checks if this unit's owner has more cities than the other unit's owner. |
bool | IsRangedSupportFire() | When attacking, does this unit perform a ranged attack before a melee attack? |
bool | IsStrongerDamaged() | Does this unit have a promotion that allows it to gain combat bonus when damaged? This method does not check for the player having the stronger damaged trait. |
bool | IsWithinDistanceOfResource(ResourceType iResourceType, int iDistance) | |
bool | IsFeatureHalfMove(FeatureType iFeatureType) | |
bool | IsFoundAbroad() | Can this unit start a city on a continent other than one with capital? |
bool | IsHoveringUnit() | |
bool | IsMounted() | Is the 'IsMounted' column in the Units database table set to 1? Not related to UNITCOMBAT_MOUNTED. |
bool | IsOnFeature(FeatureType iFeatureType) | |
bool | IsOnImprovement(ImprovementType iImprovementType) | |
bool | IsOnPlotType(PlotType iPlotType) | |
bool | IsOnResource(ResourceType iResourceType) | |
bool | IsOnTerrain(TerrainType iTerrainType) | |
bool | IsRecalledTrader() | |
bool | IsSpecificContractUnit(ContractType iContract) | Method for JFDLC. Is this unit part of the specific contract? |
bool | IsTerrainHalfMove(TerrainType iTerrainType) | |
bool | IsUnit(UnitType iUnitType) | |
bool | IsUnitClass(UnitClassType iUnitClassType) | |
bool | IsWithinDistanceOfCity(int iDistance, bool bIsFriendly, bool bIsEnemy) | Boolean arguments tells method whether to include friendly and enemy cities. |
bool | IsWithinDistanceOfFeature(FeatureType iFeatureType, int iDistance) | |
bool | IsWithinDistanceOfImprovement(ImprovementType iImprovementType, int iDistance) | |
bool | IsWithinDistanceOfPlotType(PlotType iPlotType, int iDistance) | |
bool | IsWithinDistanceOfTerrain(TerrainType iTerrainType, int iDistance) | |
bool | IsWithinDistanceOfUnit(UnitType iUnitType, int iDistance, bool bFriendly, bool bEnemy) | |
bool | IsWithinDistanceOfUnitClass(UnitClassType iUnitClass, int iDistance, bool bFriendly, bool bEnemy) | |
bool | IsWithinDistanceOfUnitCombatType(UnitCombatType iUnitCombat, int iDistance, bool bFriendly, bool bEnemy) | |
bool | IsWithinDistanceOfUnitPromotion(PromotionType iPromotion, int iDistance, bool bFriendly, bool bEnemy) |
Return | Method (arguments) | Description |
---|---|---|
int | PerAdjacentUnitCombatAttackMod() | What is the unit's attack bonus due to having adjacent unit combats? Related to UnitPromotions_CombatModPerAdjacentUnitCombat. |
int | PerAdjacentUnitCombatDefenseMod() | What is the unit's defense bonus due to having adjacent unit combats? Related to UnitPromotions_CombatModPerAdjacentUnitCombat. |
int | PerAdjacentUnitCombatModifier() | What is the unit's combat modifier bonus due to having adjacent unit combats? Related to UnitPromotions_CombatModPerAdjacentUnitCombat. |
Return | Method (arguments) | Description |
---|---|---|
void | RebaseAt(int iPlotX, int iPlotY) | Rebases the unit if it is an air unit, and it is valid to rebase to the plot at the specified coordinates. |
void | RecallTrader(bool bImmediate) | Stops this unit's trade route. |
Return | Method (arguments) | Description |
---|---|---|
bool | PlunderTradeRoute() | This unit attempts to plunders all trade routes at its current plot. Returns true if at least one trade route has been plundered. |
Return | Method (arguments) | Description |
---|---|---|
void | SetActivityType(ActivityType iActivityType) | Sets the current activity of this unit. |
void | SetBaseRangedCombatStrength(int iValue) | Sets this unit's base ranged combat strength, before any other modifiers such as promotions. |
void | SetConversionStrength(int iStrength) | Set this unit's religious conversion strength. |
void | SetExperienceTimes100(int iValue, opt int iMax = -1) | Sets the total amount of experience multiplied by 100 this unit has. Use the optional argument to prevent from exceeding the specified value. Reduces rounding error compared to SetExperience. |
void | SetMaxHitPointsBase(int iValue) | Sets the maximum hit points of this unit, before any other modifiers such as promotions. |
void | SetReligion(ReligionType iReligion) | Set this unit's religion. |
void | SetSpreadsLeft(int iSpreads) | Set the number of times this unit can spread religion. |
Return | Method (arguments) | Description |
---|---|---|
Unit | Upgrade(opt bool bIsFree = false) | Upgrades the unit to the normal upgrade unit type. Does not check if this unit actually has a valid unit type to upgrade to, and also does not check if the player has enough gold. If bFree is false, it will attempt to deduct gold even if the player does not have enough. Returns the upgrade unit instance. |
Unit | UpgradeTo(UnitType iUpgradeUnitType, opt bool bIsFree = false) | Same as Upgrade, except the upgrade unit type can be specified. |