CurtSibling
ENEMY ACE™
- Joined
- Aug 31, 2001
- Messages
- 29,449
Tested out the barb (and my own unit) with the terrain/unit immunity code, and it doesn't seem to be kicking in...
Although, there is a very likely chance I am doing something wrong...I post the code here as it is for inspection.
Although, there is a very likely chance I am doing something wrong...I post the code here as it is for inspection.
Code:
local onTurn = {}
local desertTerrain = 0
local glacierTerrain = 7
local jungleTerrain = 9
local object = require("object")
local desertImmune = {}
desertImmune[object.uTribalRaiders.id] = true
desertImmune[object.uArabRaiders.id] = true
desertImmune[object.uTribalCavalry.id] = true
desertImmune[object.uBerberCavalry.id] = true
desertImmune[object.uMuslimCavalry.id] = true
desertImmune[object.uWarParty.id] = true
function onTurn.onTurn(turn)
for unit in civ.iterateUnits() do
if unit.location.terrainType % 16 == desertTerrain then
local newDamage = math.floor(unit.hitpoints/4)
if not desertImmune[unit.type.id] then
unit.damage = math.min(unit.type.hitpoints-1,unit.damage+newDamage)
end
end
if unit.location.terrainType % 16 == jungleTerrain then
local newDamage = math.floor(unit.hitpoints/3)
unit.damage = math.min(unit.type.hitpoints-1,unit.damage+newDamage)
end
if unit.location.terrainType % 16 == glacierTerrain then
local newDamage = math.floor(unit.hitpoints/2)
unit.damage = math.min(unit.type.hitpoints-1,unit.damage+newDamage)
end
end
end
return onTurn