Xenomorph
King
- Joined
- Oct 7, 2007
- Messages
- 972
I'm trying to add a new unique unit that can always be purchased with faith, regardless of whether or not Holy Warriors was chosen for the religion. Initially I set RequiresFaithPurchaseEnabled to false, but this allow any civilization to get the unit. I have since repurposed an existing LUA script to limit who can build it by civilization, but now I need to limit the unit to a specific era or better yet, the existence of a specific tech. Here's my current code.
I haven't tested this yet, since I need to restrict it by tech and era first, i.e. not available until Steel and not available after the Renaissance era. I'm not familiar with all the lua script tags available, so I don't really know where to start.
Code:
print("This is the 'Unique Unit - War Captain Guard' mod script.")
local iBuildWarGuard = GameInfo.Units["UNIT_UU_WAR_CAPTAIN_GUARD"].ID
local iCivMayan = GameInfo.Civilizations["CIVILIZATION_MAYA"].ID
GameEvents.CityCanConstruct.Add(function(iPlayerId, iCityId, iUnitType)
if (iUnitType == iBuildWarGuard) then
local pPlayer = Players[iPlayerId]
if (pPlayer:GetCivilizationType() == iCivMayan) then
return true
else
return false
end
end
return true
end)