cromcrom
Cernu
Crédits:
Gedemon
LeeS
Infixo
TheRealHellBlazer
Isau
Gleb Bazov
And all the fine people sharing their knowledge and being helpful or supportive.
I don't want to clutter the main LUA thread with my noob questions and bits of codes, so I am opening this thread.
Ultimately, I want to create a mod that will damage units moving or standing into various terrains (especially jungles...)
First bit of code:
This works. However, when a unit reaches 0 or less damage through this ChangeDamage function, it is not destroyed.
Gedemon
LeeS
Infixo
TheRealHellBlazer
Isau
Gleb Bazov
And all the fine people sharing their knowledge and being helpful or supportive.
I don't want to clutter the main LUA thread with my noob questions and bits of codes, so I am opening this thread.
Ultimately, I want to create a mod that will damage units moving or standing into various terrains (especially jungles...)
First bit of code:
Code:
function printBlah()
local localPlayer = Players[Game.GetLocalPlayer()];
-- local pPlayer = Players[pPlayerID];
local pUnits = localPlayer:GetUnits()
for k,v in pUnits:Members() do
local unitPlot = v:GetLocation()
local featureType = Map.GetPlot(unitPlot)
local plotName = Plot.GetTerrainType(featureType)
print(unitPlot)
print(plotName)
print(v:GetName())
--[[ local killUnit = math.random(1,5)
if killUnit <= 1 then
pUnits:Destroy(v)
end ]]
local unitDamage = math.random(30,60)
v:ChangeDamage(unitDamage)
print("inflicted "..unitDamage.." to unit")
end
print("bloh blah")
end
Events.TurnEnd.Add(printBlah)
This works. However, when a unit reaches 0 or less damage through this ChangeDamage function, it is not destroyed.
Last edited: