UnitType (Civ5 Type)

From Civilization Modding Wiki
Revision as of 14:58, 19 September 2012 by DonQuich (talk | contribs) (Bot update)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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


ID.png The UnitType pseudo-type is actually a regular integer. Pseudo-types do not exist in Lua, they only serve a documentation purpose on the wiki!
  • DB.png Integers labeled as UnitType corresponds to the ID column of the Units XML table.


XML: the Units table

Here are the ID and Type columns found in this table.

ID Type
0 UNIT_SETTLER
0 UNIT_PROPHET
1 UNIT_WORKER
1 UNIT_CELT_PICTISH_WARRIOR
2 UNIT_WORKBOAT
2 UNIT_MAYAN_ATLATLIST
3 UNIT_ARTIST
3 UNIT_BYZANTINE_DROMON
4 UNIT_SCIENTIST
4 UNIT_BYZANTINE_CATAPHRACT
5 UNIT_MERCHANT
5 UNIT_CARTHAGINIAN_FOREST_ELEPHANT
6 UNIT_ENGINEER
6 UNIT_CARTHAGINIAN_QUINQUEREME
7 UNIT_GREAT_GENERAL
7 UNIT_HUN_HORSE_ARCHER
8 UNIT_SS_STASIS_CHAMBER
8 UNIT_AUSTRIAN_HUSSAR
9 UNIT_SS_ENGINE
9 UNIT_ETHIOPIAN_MEHAL_SEFARI
10 UNIT_SS_COCKPIT
10 UNIT_MISSIONARY
11 UNIT_SS_BOOSTER
11 UNIT_COMPOSITE_BOWMAN
12 UNIT_MISSILE_CRUISER
12 UNIT_GALLEASS
13 UNIT_NUCLEAR_SUBMARINE
13 UNIT_GREAT_WAR_INFANTRY
14 UNIT_CARRIER
14 UNIT_MARINE
15 UNIT_BATTLESHIP
15 UNIT_TRIPLANE
16 UNIT_SUBMARINE
16 UNIT_WWI_BOMBER
17 UNIT_DESTROYER
17 UNIT_WWI_TANK
18 UNIT_IRONCLAD
18 UNIT_MACHINE_GUN
19 UNIT_FRIGATE
19 UNIT_SWEDISH_CAROLEAN
20 UNIT_ENGLISH_SHIPOFTHELINE
20 UNIT_SWEDISH_HAKKAPELIITTA
21 UNIT_CARAVEL
21 UNIT_HUN_BATTERING_RAM
22 UNIT_TRIREME
22 UNIT_PRIVATEER
23 UNIT_MECH
23 UNIT_DUTCH_SEA_BEGGAR
24 UNIT_NUCLEAR_MISSILE
24 UNIT_INQUISITOR
25 UNIT_STEALTH_BOMBER
25 UNIT_GREAT_ADMIRAL
26 UNIT_JET_FIGHTER
26 UNIT_GATLINGGUN
27 UNIT_GUIDED_MISSILE
28 UNIT_MODERN_ARMOR
29 UNIT_HELICOPTER_GUNSHIP
30 UNIT_MOBILE_SAM
31 UNIT_ROCKET_ARTILLERY
32 UNIT_MECHANIZED_INFANTRY
33 UNIT_ATOMIC_BOMB
34 UNIT_BOMBER
35 UNIT_AMERICAN_B17
36 UNIT_FIGHTER
37 UNIT_JAPANESE_ZERO
38 UNIT_PARATROOPER
39 UNIT_TANK
40 UNIT_GERMAN_PANZER
41 UNIT_ARTILLERY
42 UNIT_ANTI_AIRCRAFT_GUN
43 UNIT_ANTI_TANK_GUN
44 UNIT_INFANTRY
45 UNIT_FRENCH_FOREIGNLEGION
46 UNIT_CAVALRY
47 UNIT_RUSSIAN_COSSACK
48 UNIT_RIFLEMAN
49 UNIT_LANCER
50 UNIT_OTTOMAN_SIPAHI
51 UNIT_CANNON
52 UNIT_MUSKETMAN
53 UNIT_AMERICAN_MINUTEMAN
54 UNIT_FRENCH_MUSKETEER
55 UNIT_OTTOMAN_JANISSARY
56 UNIT_LONGSWORDSMAN
57 UNIT_JAPANESE_SAMURAI
58 UNIT_TREBUCHET
59 UNIT_KNIGHT
60 UNIT_ARABIAN_CAMELARCHER
61 UNIT_SIAMESE_WARELEPHANT
62 UNIT_SONGHAI_MUSLIMCAVALRY
63 UNIT_CROSSBOWMAN
64 UNIT_CHINESE_CHUKONU
65 UNIT_ENGLISH_LONGBOWMAN
66 UNIT_PIKEMAN
67 UNIT_GERMAN_LANDSKNECHT
68 UNIT_CATAPULT
69 UNIT_ROMAN_BALLISTA
70 UNIT_HORSEMAN
71 UNIT_GREEK_COMPANIONCAVALRY
72 UNIT_SWORDSMAN
73 UNIT_IROQUOIAN_MOHAWKWARRIOR
74 UNIT_ROMAN_LEGION
75 UNIT_CHARIOT_ARCHER
76 UNIT_EGYPTIAN_WARCHARIOT
77 UNIT_INDIAN_WARELEPHANT
78 UNIT_SPEARMAN
79 UNIT_GREEK_HOPLITE
80 UNIT_PERSIAN_IMMORTAL
81 UNIT_ARCHER
82 UNIT_SCOUT
83 UNIT_WARRIOR
84 UNIT_AZTEC_JAGUAR
85 UNIT_BARBARIAN_WARRIOR
86 UNIT_GALLEY
87 UNIT_BARBARIAN_ARCHER
88 UNIT_BARBARIAN_SPEARMAN
89 UNIT_BARBARIAN_SWORDSMAN


Examples

Here are different ways to query the database to retrieve the ID from the type. Those examples will return and assign the integer value 0. See also GameInfo.

local id = GameInfo.Units.UNIT_PROPHET.ID
local id = GameInfo["Units"].["UNIT_PROPHET"].ID
local id = GameInfo.Units{Type="UNIT_PROPHET"}().ID

Alternatively you could use the ID or the type to retrieve the value of the Description column. Those examples will return and assign the value TXT_KEY_UNIT_GREAT_PROPHET.

local description = GameInfo.Units[0].Description
local description = GameInfo["Units"][0]["Description"]
local description = GameInfo.Units{ID=0}().Description


Used by

string GetHelpTextForUnit(UnitType unit, bool includeRequirementsInfo)
UnitType City:AllUpgradesAvailable(UnitType unit, int upgradeCount = 0)
bool City:CanTrain(UnitType unit, int continue, int testVisible, bool ignoreCost, bool ignoreUpgrades)
int City:CanTrainTooltip(UnitType id)
City:ChangeGreatPeopleUnitProgress(UnitType index, int change)
City:ChangeUnitProduction(UnitType index, int change)
City:ChooseProduction(UnitType trainUnit, BuildingType constructBuilding, ProjectType createProject, bool finish, bool front)
City:CreateGreatGeneral(UnitType greatPersonUnit)
UnitType City:GetConscriptUnit()
int City:GetFaithPurchaseUnitTooltip(UnitType id)
int City:GetFirstUnitOrder(UnitType unit)
int City:GetGreatPeopleUnitProgress(UnitType index)
int City:GetGreatPeopleUnitRate(UnitType index)
int City:GetProductionExperience(UnitType unit)
UnitType City:GetProductionUnit()
int City:GetPurchaseUnitTooltip(UnitType id)
int City:GetUnitFaithPurchaseCost(UnitType unit, bool arg1)
int City:GetUnitProductionModifier(UnitType unit)
int City:GetUnitProductionTurnsLeft(UnitType unit, int num)
int City:GetUnitPurchaseCost(UnitType unit)
bool City:IsCanPurchase(UnitType unitType, int buildingType, int projectType, int projectID, int projectID = nil, YieldType yield = nil)
bool City:IsUnitFoodProduction(UnitType unit)
City:SetGreatPeopleUnitProgress(UnitType index, int newValue)
Game.CityPurchaseBuilding(City city, UnitType unitType, int buildingType, ProjectType projectTypes)
Game.CityPurchaseProject(City city, UnitType unitType, int buildingType, ProjectType projectTypes)
Game.CityPurchaseUnit(City city, UnitType unitType, int buildingType, ProjectType projectTypes)
Game.CityPushOrder(City city, OrderType order, UnitType data, bool alt, bool shift, bool ctrl)
UnitType Game.GetBestLandUnit()
UnitType Game.GetBestLandUnitCombat()
int Game.GetFaithCost(UnitType unit)
int Game.GetNumResourceRequiredForUnit(UnitType unit, ResourceType resource)
int Game.GetUnitCreatedCount(UnitType index)
UnitType Game.GetUnitUpgradesTo(UnitType unit)
bool Game.IsUnitEverActive(UnitType unit)
Player:AddFreeUnit(UnitType arg0, UnitAIType UNITAI_DEFENSE)
int Player:CanTrain(UnitType unit, bool continue, bool testVisible, bool arg3, bool arg4)
Player:DoGreatPersonChoice(int cityID, bool spawnUnit, UnitType unit)
int Player:GetAdvancedStartUnitCost(UnitType unit, bool add, Plot plot)
UnitType Player:GetMinorCivUniqueUnit()
int Player:GetUnitBaktun(UnitType arg0)
int Player:GetUnitProductionNeeded(UnitType index)
Unit Player:InitUnit(UnitType unit, ResourceType x, ResourceType y, UnitAIType unitAI = NO_UNITAI, DirectionType facingDirection = NO_DIRECTION)
int Player:IsCanPurchaseAnyCity(bool arg0, bool arg1, UnitType arg2, BuildingType arg3, YieldType arg4)
TextButton:RegisterCallback(MouseType OnSearchTextEnter, (void func(PolicyBranchType policyBranchIndex, UnitType y, Button button)) OnClose = nil)
UnitType UI.GetInterfaceModeDebugItemID2()
table(UnitType => Civilizations.row) UI.GetMapPlayers(string mapScriptPath)
UI.MoveScenarioPlayerToSlot(UnitType playerIndex, int arg1)
UnitType Unit:GetCaptureUnitType(CivilizationType civilization)
UnitType Unit:GetUnitType()
UnitType Unit:GetUpgradeUnitType()
int Unit:IsHigherTechThan(UnitType arg0)
Unit:SetLeaderUnitType(UnitType leaderUnitType)
int Unit:UpgradePrice(UnitType unit)



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.