Code: Select all
[customParams]
{
reclaim_fx=yes;
reclaim_fx_type=tree_reclaim_fx;
}
Code: Select all
function gadget:GetInfo()
return {
name = "Reclaim FX",
desc = "Generates effect if certain objects are reclaimed.",
author = "Argh",
date = "December 18th, 2008",
license = "Public Domain, or the least-restrictive rights of your country of residence",
layer = 1,
enabled = true,
}
end
local GetUnitHealth = Spring.GetUnitHealth
local GetUnitPosition = Spring.GetUnitPosition
local SpawnCEG = Spring.SpawnCEG
local ReclaimFXList = {}
if (gadgetHandler:IsSyncedCode()) then
--/////////////////////////////////////////////////////////////////////////////////////////////////////////////
--/////////////////////////////////////////////////////////////////////////////////////////////////////////////
--/////////////////////////////////////////////////////////////////////////////////////////////////////////////
for ud,_ in pairs(UnitDefs) do
if UnitDefs[ud].customParams.reclaim_fx == 'yes' then
table.insert(ReclaimFXList,ud,1)
end
end
end
function gadget:AllowUnitBuildStep(builderID, builderTeam, unitID, unitDefID, part)
if part < 0 then
health = GetUnitHealth(unitID)
if health < 10 and ReclaimFXList[unitDefID] then
x,y,z = GetUnitPosition(unitID)
SpawnCEG(UnitDefs[unitDefID].customParams.reclaim_fx_type, x, y, z, 0, 1.0, 0,0,0)
end
end
return true
end
--/////////////////////////////////////////////////////////////////////////////////////////////////////////////
--/////////////////////////////////////////////////////////////////////////////////////////////////////////////
--/////////////////////////////////////////////////////////////////////////////////////////////////////////////
end
But just having a CEG beats the heck out've just seeing stuff disappear, though
