Hi,
I wish to have fallout spawns on the tile where an uranium powered unit has been destroyed.
Putmalk has provided me with the following code but nothing happens and we don't find what's wrong :
The file with the code has been loaded with an InGameUIAddin line, it's VFS is set to true and there is no runtime error in the lua console.
Maybe on of you will have an idea ?
I wish to have fallout spawns on the tile where an uranium powered unit has been destroyed.
Putmalk has provided me with the following code but nothing happens and we don't find what's wrong :
Code:
print("---- Fallout mod ----");
Events.EndCombatSim.Add(function ( iAttackingPlayer, iAttackingUnit, iAttackingUnitDamage, iAttackingUnitFinalDamage,
iAttackingUnitMaxHitPoints, iDefendingPlayer, iDefendingUnit, iDefendingUnitDamage,
iDefendingUnitFinalDamage, iDefendingUnitMaxHitPoints )
-- Case: Both die
if(iAttackingUnitFinalDamage <= 0 and iDefendingUnitFinalDamage <= 0) then
CreateFalloutOnUnitPlot(iAttackingUnit);
CreateFalloutOnUnitPlot(iDefendingUnit);
-- Case: Attacker dies
elseif(iAttackingUnitFinalDamage <= 0) then
CreateFalloutOnUnitPlot(iAttackingUnit);
-- Case: Defender dies
elseif(iDefendingUnitFinalDamage <= 0) then
CreateFalloutOnUnitPlot(iDefendingUnit);
end
end);
function CreateFalloutOnUnitPlot(unitType)
iNumResourceNeeded = Game.GetNumResourceForUnit(unitType, GameInfo.Resources["RESOURCE_URANIUM"].ID);
-- This unit requires uranium, let's get his plot.
if(iNumResourceNeeded > 0) then
local plotX = unitType:GetX();
local plotY = unitType:GetY();
-- Unit doesn't require uranium.
else
return;
end
-- Get the fallout ID
featureFallout = FeatureTypes.FEATURE_FALLOUT;
-- Create fallout on Unit's X, Y
local plot = Map.GetPlot(plotX, plotY);
pPlot:SetFeatureType(featureFallout);
end
The file with the code has been loaded with an InGameUIAddin line, it's VFS is set to true and there is no runtime error in the lua console.
Maybe on of you will have an idea ?