Skip to content

Commit

Permalink
Actually fixed area healers. It was a Blame Damgam moment all along
Browse files Browse the repository at this point in the history
  • Loading branch information
Damgam committed May 18, 2024
1 parent 41ff037 commit ee9c334
Showing 1 changed file with 27 additions and 30 deletions.
57 changes: 27 additions & 30 deletions luarules/gadgets/pve_areahealers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,31 @@ end
local aliveHealers = {}
local healersTable = {}
if Spring.Utilities.Gametype.IsRaptors() then
local healersTableRaptors = {
[UnitDefNames["raptor_land_swarmer_heal_t1_v1"].id] = {
healingpower = UnitDefNames["raptor_land_swarmer_heal_t1_v1"].repairSpeed,
healingrange = UnitDefNames["raptor_land_swarmer_heal_t1_v1"].buildDistance*2,
canbehealed = false,
},
[UnitDefNames["raptor_land_swarmer_heal_t2_v1"].id] = {
healingpower = UnitDefNames["raptor_land_swarmer_heal_t2_v1"].repairSpeed,
healingrange = UnitDefNames["raptor_land_swarmer_heal_t2_v1"].buildDistance*2,
canbehealed = false,
},
[UnitDefNames["raptor_land_swarmer_heal_t3_v1"].id] = {
healingpower = UnitDefNames["raptor_land_swarmer_heal_t3_v1"].repairSpeed,
healingrange = UnitDefNames["raptor_land_swarmer_heal_t3_v1"].buildDistance*2,
canbehealed = false,
},
[UnitDefNames["raptor_land_swarmer_heal_t4_v1"].id] = {
healingpower = UnitDefNames["raptor_land_swarmer_heal_t4_v1"].repairSpeed,
healingrange = UnitDefNames["raptor_land_swarmer_heal_t4_v1"].buildDistance*2,
canbehealed = false,
},
[UnitDefNames["raptor_matriarch_healer"].id] = {
healingpower = UnitDefNames["raptor_matriarch_healer"].repairSpeed,
healingrange = UnitDefNames["raptor_matriarch_healer"].buildDistance*2,
canbehealed = false,
},
healersTable[UnitDefNames["raptor_land_swarmer_heal_t1_v1"].id] = {
healingpower = UnitDefNames["raptor_land_swarmer_heal_t1_v1"].repairSpeed,
healingrange = UnitDefNames["raptor_land_swarmer_heal_t1_v1"].buildDistance*2,
canbehealed = false,
}
healersTable[UnitDefNames["raptor_land_swarmer_heal_t2_v1"].id] = {
healingpower = UnitDefNames["raptor_land_swarmer_heal_t2_v1"].repairSpeed,
healingrange = UnitDefNames["raptor_land_swarmer_heal_t2_v1"].buildDistance*2,
canbehealed = false,
}
healersTable[UnitDefNames["raptor_land_swarmer_heal_t3_v1"].id] = {
healingpower = UnitDefNames["raptor_land_swarmer_heal_t3_v1"].repairSpeed,
healingrange = UnitDefNames["raptor_land_swarmer_heal_t3_v1"].buildDistance*2,
canbehealed = false,
}
healersTable[UnitDefNames["raptor_land_swarmer_heal_t4_v1"].id] = {
healingpower = UnitDefNames["raptor_land_swarmer_heal_t4_v1"].repairSpeed,
healingrange = UnitDefNames["raptor_land_swarmer_heal_t4_v1"].buildDistance*2,
canbehealed = false,
}
healersTable[UnitDefNames["raptor_matriarch_healer"].id] = {
healingpower = UnitDefNames["raptor_matriarch_healer"].repairSpeed,
healingrange = UnitDefNames["raptor_matriarch_healer"].buildDistance*2,
canbehealed = false,
}
table.append(healersTable, healersTableRaptors)
end

for unitDefID, unitDef in pairs(UnitDefs) do
Expand All @@ -69,26 +66,26 @@ end

function gadget:UnitCreated(unitID, unitDefID, unitTeam)
if healersTable[unitDefID] then
Spring.Echo("Created Area Healer", unitID, UnitDefs[unitDefID].name)
--Spring.Echo("Created Area Healer", unitID, UnitDefs[unitDefID].name)
aliveHealers[unitID] = {
healingpower = healersTable[unitDefID].healingpower,
healingrange = healersTable[unitDefID].healingrange,
canbehealed = healersTable[unitDefID].canbehealed,
}
else
aliveHealers[unitID] = nil
end
end

function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID)
if aliveHealers[unitID] then
--Spring.Echo("Removed Area Healer", unitID, UnitDefs[unitDefID].name)
aliveHealers[unitID] = nil
end
end

function gadget:GameFrame(frame)
for unitID, statsTable in pairs(aliveHealers) do
if unitID%30 == frame%30 then
--Spring.Echo("Alive Healer ID", unitID, UnitDefs[Spring.GetUnitDefID(unitID)].name)
local x,y,z = Spring.GetUnitPosition(unitID)
local surroundingUnits = Spring.GetUnitsInSphere(x, y, z, statsTable.healingrange)
for i = 1,#surroundingUnits do
Expand Down

0 comments on commit ee9c334

Please sign in to comment.