Unit (Civ5 Type)

From Civilization Modding Wiki
Jump to navigationJump to search

This page is a part of the Lua and UI Reference (Civ5).


Instance Methods

Methods are functions that belong to an object. Instance methods are invoked through a colon, as in caller:SomeMethod(<args>), where caller is an instance of Unit.
A colon implictly passes the caller object as the first argument. That is, the former call is equivalent to this one: caller.SomeMethod(caller, <args>)

A

Base game Gods & Kings ___________________________
int AirSweepCombatMod()
bool At(int x, int y)
int AtPlot(Plot plot)
int AttackFortifiedModifier()
int AttackWoundedModifier()
int AttackXPValue()

C

Base game Gods & Kings ___________________________
bool CanAcquirePromotion(PromotionType promotion)
bool CanAcquirePromotionAny()
bool CanAirAttack()
bool CanAirDefend(Plot plot)
bool CanAirlift(Plot plot)
bool CanAirliftAt(Plot plot, int x, int y)
bool CanAirPatrol(Plot plot)
bool CanAutomate(AutomateType automate)
bool CanBuild(Plot plot, BuildActionType build, bool testVisible = false, bool testGold = true)
bool CanBuildRoute()
bool CanBuildSpaceship(Plot plot, bool visible)
bool CanCargoAllMove()
bool CanCoexistWithEnemyUnit(TeamID team)
bool CanConstruct(Plot plot, BuildingType building)
bool CanDiscover(Plot plot)
bool CanDisembark(Plot plot)
bool CanDisembarkOnto(Plot plot)
bool CanDistanceGift(TaskType toPlayer)
bool CanDoCommand(CommandType command, int data1, int data2, bool testVisible = false, bool testBusy = true)
bool CanEmbark(Plot plot)
bool CanEmbarkOnto(Plot plot, Plot targetPlot)
bool CanEnterTerritory(TeamID team, bool ignoreRightOfPassage = false, bool isCity = false)
bool CanFortify(Plot plot)
bool CanFound(Plot plot, bool testVisible = false)
bool CanGift(bool testVisible = false, bool testTransport = false)
bool CanGiveExperience(Plot plot)
bool CanGoldenAge(Plot plot, bool testVisible)
int CanHeal(Plot plot)
bool CanHold(Plot plot)
bool CanJoin(Plot plot, SpecialistType specialist)
bool CanLead(Plot plot, int unitId)
bool CanLoad(Plot plot)
bool CanLoadUnit(Unit unit, Plot plot)
bool CanMove()
bool CanMoveAllTerrain()
bool CanMoveImpassable()
bool CanMoveOrAttackInto(Plot plot, bool declareWar = false, bool destination = false)
bool CanMoveThrough(Plot plot)
int CanNuke(Plot plot)
bool CanNukeAt(Plot plot, int x, int y)
bool CanParadrop(Plot plot, bool arg1)
bool CanParadropAt(Plot plot, int x, int y)
bool CanPillage(Plot plot)
bool CanPromote(PromotionType promotion, int leaderUnitId)
int CanRangeStrike()
int CanRangeStrikeAt(int x, int y, bool arg2 = nil, bool noncombatAllowed = nil)
bool CanRebaseAt(Plot sourcePlot, int targetX, int targetY)
CanRepairFleet
bool CanScrap()
bool CanSentry(Plot plot)
bool CanSetUpForRangedAttack()
bool CanSiege(TeamID team)
bool CanSleep(Plot plot)
bool CanStartMission(int mission, int data1, int data2, Plot plot = nil, bool testVisible = false)
bool CanTrade(Plot plot, bool testVisible)
bool CanUnload()
bool CanUnloadAll()
int CanUpgradeRightNow()
int CapitalDefenseFalloff()
int CapitalDefenseModifier()
int CargoSpace()
int CargoSpaceAvailable(SpecialUnitType specialCargo, DomainType domainCargo)
int ChanceFirstStrikes()
ChangeCargoSpace(int change)
ChangeDamage(int change, PlayerID player)
ChangeExperience(int change, int max = -1, bool fromCombat = false, bool inBorders = false, bool updateGlobal = false)
ChangeLevel(int change)
ChangeMoves(int change)
int CityAttackModifier()
int CityDefenseModifier()
Convert(Unit unit)
int CurrInterceptionProbability()

D

Base game Gods & Kings ___________________________
int DefenseXPValue()
DoCommand(CommandType command, int data1, int data2)
DomainType DomainCargo()
int DomainModifier(DomainType domain)

E

Base game Gods & Kings ___________________________
Embark(Plot plot)
int EvasionProbability()
ExecuteSpecialExploreMove(Plot targetPlot)
int ExperienceNeeded()

F

Base game Gods & Kings ___________________________
int FeatureAttackModifier(FeatureType feature)
int FeatureDefenseModifier(FeatureType feature)
FinishMoves
int FirstStrikes()
int FlankAttackModifier()
bool FlatMovementCost()
int FlavorValue(FlavorType flavor)
int FortifyModifier()

G

Base game Gods & Kings ___________________________
bool GeneratePath(Plot toPlot, int flags = 0, bool reuse = false, unknown piPathTurns = nil)
ActivityType GetActivityType()
int GetAdjacentModifier()
int GetAdjacentTileHeal()
int GetAirCombatDamage(Unit defender)
int GetAmphibCount()
Area GetArea()
int GetAttackModifier()
int GetBaseCombatStrength()
int GetBaseRangedCombatStrength()
unknown GetBestInterceptor(Plot plot)
unknown GetBestSeaPillageInterceptor(Plot plot)
int GetBlitzCount()
BuildActionType GetBuildType()
UnitType GetCaptureUnitType(CivilizationType civilization)
int GetCargo()
CivilizationType GetCivilizationType()
int GetCombatDamage(int strength, int opponentStrength, int currentDamage, bool includeRand = true, bool attackerIsCity = false, bool defenderIsCity = false)
int GetCombatLimit()
int GetCombatOwner(TeamID forTeam)
unknown GetConversionStrength()
int GetCurrHitPoints()
int GetDamage()
TeamID GetDeclareWarRangeStrike(Plot plot)
int GetDefenseModifier()
DomainType GetDomainType()
int GetDropRange()
int GetEmbarkedUnitDefense()
int GetExperience()
int GetExperiencePercent()
int GetExtraAttackFortifiedMod()
int GetExtraAttackWoundedMod()
int GetExtraChanceFirstStrikes()
int GetExtraCityAttackPercent()
int GetExtraCityDefensePercent()
int GetExtraCombatPercent()
int GetExtraDomainModifier(DomainType index)
int GetExtraEnemyHeal()
int GetExtraEvasion()
int GetExtraFeatureAttackPercent(FeatureType index)
int GetExtraFeatureDefensePercent(FeatureType index)
int GetExtraFirstStrikes()
int GetExtraFriendlyHeal()
int GetExtraHillsAttackPercent()
int GetExtraHillsDefensePercent()
int GetExtraIntercept()
int GetExtraMoveDiscount()
int GetExtraMoves()
int GetExtraNeutralHeal()
int GetExtraOpenAttackPercent()
int GetExtraOpenDefensePercent()
int GetExtraOpenRangedAttackMod()
int GetExtraRange()
int GetExtraRoughAttackPercent()
int GetExtraRoughRangedAttackMod()
int GetExtraTerrainAttackPercent(TerrainType index)
int GetExtraTerrainDefensePercent(TerrainType index)
int GetExtraUnitCombatModifier(UnitCombatType index)
int GetExtraVisibilityRange()
int GetExtraWithdrawal()
int GetFacingDirection()
Unit GetFireSupportUnit(PlayerID defender, int x, int y)
int GetFortifyTurns()
int GetFriendlyLandsAttackModifier()
int GetFriendlyLandsModifier()
int GetGameTurnCreated()
int GetGarrisonedCity()
int GetGoldenAgeTurns()
int GetGreatGeneralCombatModifier()
HandicapType GetHandicapType()
int GetHotKeyNumber()
UnitID GetID()
InvisibilityScopeType GetInvisibleType()
int GetKamikazePercent()
int GetLastMoveTurn()
unknown GetLeaderUnitType()
int GetLevel()
ReligionType GetMajorityReligionAfterSpread()
int GetMaxAttackStrength(Plot fromPlot, Plot toPlot, Unit defender)
int GetMaxDefenseStrength(Plot inPlot, Unit attacker, bool arg2 = nil)
int GetMaxHitPoints()
int GetMaxRangedCombatStrength(Unit other, int attacking, bool arg2, bool arg3)
int GetMoves()
string GetName()
string GetNameKey()
unknown GetNameNoDesc()
int GetNearbyImprovementModifier()
int GetNumEnemyUnitsAdjacent(Unit otherUnit)
int GetNumFollowersAfterSpread()
int GetNumResourceNeededToUpgrade(ResourceType resourceLoop)
int GetOriginalOwner()
int GetOutsideFriendlyLandsModifier()
PlayerID GetOwner()
unknown GetPathEndTurnPlot()
int GetPillageChange()
Plot GetPlot()
int GetRangeCombatDamage(Unit defender, City city, bool includeRand)
int GetRangedAttackModifier()
int GetRangedCombatLimit()
unknown GetReconPlot()
ReligionType GetReligion()
int GetReverseGreatGeneralModifier()
int GetRiverCrossingNoPenaltyCount()
int GetSameTileHeal()
GetScenarioData
bool GetScrapGold()
string GetScriptData()
InvisibilityScopeType GetSeeInvisibleType()
SpecialUnitType GetSpecialUnitType()
int GetSpreadsLeft()
int GetStrategicResourceCombatPenalty()
TeamID GetTeam()
int GetTradeGold(Plot plot)
unknown GetTransportUnit()
int GetUnitAICargo(UnitAIType unitAI)
UnitAIType GetUnitAIType()
int GetUnitClassModifier(UnitClassType index)
UnitClassType GetUnitClassType()
UnitCombatType GetUnitCombatType()
unknown GetUnitFlagIconOffset()
unknown GetUnitPortraitOffset()
UnitType GetUnitType()
int GetUpgradeDiscount()
Unit GetUpgradeUnitFromPlot(Plot adjacentPlot)
UnitType GetUpgradeUnitType()
int GetVisualOwner()
int GetX()
int GetY()
bool GiveExperience()

H

Base game Gods & Kings ___________________________
bool HasCargo()
bool HasMoved()
bool HasName()
int HillsAttackModifier()
int HillsDefenseModifier()

I

Base game Gods & Kings ___________________________
bool IgnoreBuildingDefense()
bool IgnoreTerrainCost()
bool ImmuneToFirstStrikes()
bool IsActionRecommended(ActionType action)
bool IsAlwaysHeal()
bool IsAmphib()
bool IsAttacking()
bool IsAutomated()
bool IsBarbarian()
bool IsBetterDefenderThan(Unit defender, Unit attacker)
bool IsBlitz()
bool IsBusy()
int IsCanAttack()
bool IsCanAttackRanged()
bool IsCanAttackWithMove()
bool IsCanAttackWithMoveNow()
bool IsCanDefend(Plot plot)
int IsCargo()
bool IsCityAttackOnly()
int IsCombatUnit()
int IsDead()
bool IsDefending()
int IsDelayedDeath()
int IsEmbarked()
int IsEnemyCityAdjacent()
bool IsEnemyInMovementRange(bool arg0, bool arg1)
bool IsEnemyRoute()
bool IsEverFortifyable()
bool IsFeatureDoubleMove(FeatureType index)
bool IsFighting()
bool IsFortifyable()
int IsFound()
bool IsFriendlyUnitAdjacent(bool combatUnit)
bool IsFull()
int IsGarrisoned()
bool IsGoldenAge()
IsGreatPerson
bool IsHasPromotion(PromotionType promotion)
bool IsHealOutsideFriendly()
int IsHigherTechThan(UnitType arg0)
bool IsHillsDoubleMove()
bool IsHuman()
int IsHurt()
bool IsImmobile()
bool IsInCombat()
bool IsInvisible(TeamID team, bool debug, bool checkCargo = false)
int IsLargerCivThan(Unit myUnit)
int IsMustSetUpToRangedAttack()
bool IsNearGreatGeneral()
bool IsNeverInvisible()
bool IsNoBadGoodies()
bool IsNoCapture()
bool IsNone()
bool IsNukeImmune()
bool IsNukeVictim(Plot plot, TeamID team)
bool IsOnlyDefensive()
bool IsOutOfAttacks()
bool isOutOfInterceptions()
bool IsPromotionReady()
bool IsPromotionValid(PromotionType promotion)
bool IsRangeAttackIgnoreLOS(Plot plot)
int IsRangeAttackOnlyInDomain()
int IsRanged()
int IsReadyToMove()
bool IsRivalTerritory()
bool IsRiverCrossingNoPenalty()
int IsSelected(unknown void)
bool IsSetUpForRangedAttack()
int IsStackedGreatGeneral()
bool IsTerrainDoubleMove(TerrainType index)
bool IsWaiting()
bool IsWork()

J

Base game Gods & Kings ___________________________
JumpToNearestValidPlot()

K

Base game Gods & Kings ___________________________
Kill(bool delay, PlayerID player = NO_PLAYER)

L

Base game Gods & Kings ___________________________
LastMissionPlot
bool Lead(int unitId)

M

Base game Gods & Kings ___________________________
int MaxFirstStrikes()
int MaxInterceptionProbability()
int MaxMoves()
int MaxXPValue()
int MovesLeft()

N

Base game Gods & Kings ___________________________
bool NoDefensiveBonus()
int NukeDamageLevel()

O

Base game Gods & Kings ___________________________
int OpenAttackModifier()
int OpenDefenseModifier()
int OpenRangedAttackModifier()

P

Base game Gods & Kings ___________________________
PopMission
Promote(PromotionType promotion, int leaderUnitId)
PushMission(MissionType mission, int data1 = -1, int data2 = -1, int flags = 0, bool append = false, bool manual = fa;se, MissionType missionAI = NO_MISSIONAI, Plot missionAIPlot = nil, Unit missionAIUnit = nil)

R

Base game Gods & Kings ___________________________
int Range()
RangeStrike(int x, int y)
RotateFacingDirectionClockwise
RotateFacingDirectionCounterClockwise
int RoughAttackModifier()
int RoughDefenseModifier()
int RoughRangedAttackModifier()

S

Base game Gods & Kings ___________________________
SetBaseCombatStrength(int combat)
SetDamage(int newValue, PlayerID player, bool notifyEntity = true)
SetDeployFromOperationTurn(int arg0)
SetEmbarked(bool newValue)
SetExperience(int newValue, int max = -1)
SetHasPromotion(PromotionType index, bool newValue)
SetHotKeyNumber(int newValue)
SetLeaderUnitType(UnitType leaderUnitType)
SetLevel(int newLevel)
SetMadeAttack(bool newValue)
SetMadeInterception(bool newValue)
SetMoves(int newValue)
SetName(string newValue)
SetOriginalOwner(PlayerID oldOwner)
SetPromotionReady(bool newValue)
SetReconPlot(Plot newValue)
SetScenarioData
SetScriptData(string newValue)
SetXY(int x, int y, bool group = false, bool update = true, bool show = false, bool checkPlotVisible = false)
SpecialCargo

T

Base game Gods & Kings ___________________________
int TerrainAttackModifier(TerrainType terrain)
int TerrainDefenseModifier(TerrainType terrain)

U

Base game Gods & Kings ___________________________
int UnitClassAttackModifier(UnitClassType unitClass)
int UnitClassDefenseModifier(UnitClassType unitClass)
int UnitCombatModifier(UnitCombatType unitCombat)
int UpgradePrice(UnitType unit)

V

Base game Gods & Kings ___________________________
int VisibilityRange()

W

Base game Gods & Kings ___________________________
int WithdrawalProbability()
int WorkRate(bool max, BuildActionType build = nil)


Used by

City:AddProductionExperience(Unit unit, bool conscript = false)
Unit City:GetGarrisonedUnit()
int City:RangeCombatDamage(Unit theirUnit, unknown arg1)
int City:RangeCombatUnitDefense(Unit theirUnit)
CombatPredictionType Game.GetCombatPrediction(Unit myUnit, Unit theirUnit)
bool Player:CanReceiveGoody(Plot plot, GoodyType goody, Unit unit)
Player:CreateGreatGeneral(Unit eGreatPersonUnit, bool incrementThreshold, bool incrementExperience, int x, int y)
Player:DoGoody(Plot plot, Unit unit)
Unit Player:GetFirstReadyUnit()
Unit Player:GetUnitByID(UnitID unit)
Unit Player:InitUnit(UnitType unit, ResourceType x, ResourceType y, UnitAIType unitAI = NO_UNITAI, DirectionType facingDirection = NO_DIRECTION)
Player:ReceiveGoody(Plot plot, GoodyType goody, Unit unit)
iterator(Unit) Player:Units()
unknown Plot:GetBestDefender(PlayerID owner, PlayerID attackingPlayer, Unit attacker, bool testAtWar, bool testPotentialEnemy, bool testCanMove)
int Plot:GetNumFriendlyUnitsOfType(Unit unit)
int Plot:GetNumVisibleEnemyDefenders(Unit unit)
int Plot:GetNumVisiblePotentialEnemyDefenders(Unit unit)
Unit Plot:GetUnit(UnitID id)
int Plot:IsEnemyCity(Unit unit)
bool Plot:IsFriendlyCity(Unit unit, bool checkImprovement)
bool Plot:IsValidDomainForAction(Unit unit)
bool Plot:IsValidDomainForLocation(Unit unit)
int Plot:IsVisibleEnemyDefender(Unit unit)
int Plot:MovementCost(Unit unit, Plot fromPlot)
Plot:NukeExplosion(int range, Unit nukeUnit)
Unit UI.GetHeadSelectedUnit()
UI.HighlightCanPlacePlots(Unit unit, Plot arg1)
UI.SelectUnit(Unit v)
UI.SetPlaceUnit(Unit unit)
bool Unit:CanLoadUnit(Unit unit, Plot plot)
Unit:Convert(Unit unit)
int Unit:GetAirCombatDamage(Unit defender)
Unit Unit:GetFireSupportUnit(PlayerID defender, int x, int y)
int Unit:GetMaxAttackStrength(Plot fromPlot, Plot toPlot, Unit defender)
int Unit:GetMaxDefenseStrength(Plot inPlot, Unit attacker, bool arg2 = nil)
int Unit:GetMaxRangedCombatStrength(Unit other, int attacking, bool arg2, bool arg3)
int Unit:GetNumEnemyUnitsAdjacent(Unit otherUnit)
int Unit:GetRangeCombatDamage(Unit defender, City city, bool includeRand)
Unit Unit:GetUpgradeUnitFromPlot(Plot adjacentPlot)
bool Unit:IsBetterDefenderThan(Unit defender, Unit attacker)
int Unit:IsLargerCivThan(Unit myUnit)
Unit:PushMission(MissionType mission, int data1 = -1, int data2 = -1, int flags = 0, bool append = false, bool manual = fa;se, MissionType missionAI = NO_MISSIONAI, Plot missionAIPlot = nil, Unit missionAIUnit = nil)



The initial version of this page was created by the Civ5 API Bot, see the Civ5 API Reference FAQ. Some of the texts come from the 2kgames' wiki and most of code samples are copyrighted to Firaxis.
Functions' signatures were either copied from the 2kgames' wiki, or infered from the Lua source files and the binaries. Errors are possible.
Contributors may find help in the Contributors guide to the Civ5 API.