Skip to content

Commit

Permalink
Merge pull request #2702 from TheSilverHornet/infestorupdate
Browse files Browse the repository at this point in the history
Infestor update final form
  • Loading branch information
Zecrus2 authored Mar 7, 2024
2 parents 448a0bd + 6db2b40 commit 7e07038
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions luarules/gadgets/unit_infestor_spawn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,22 @@ if not gadgetHandler:IsSyncedCode() then
end



local isBuilding = {}
local isInfestor = {}
for udid, ud in pairs(UnitDefs) do
if string.find(ud.name, 'leginfestor') then
isInfestor[udid] = true
Spring.Echo(udid)
end
if ud.isBuilding then
isBuilding[udid] = true
end
if UnitDefNames.leginfestor then
local infestor = {}
infestor[UnitDefNames.leginfestor.id] = true

if (UnitDefNames.leginfestor_scav) then
infestor[UnitDefNames.leginfestor_scav.id] = true
end


function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID)
if (builderID) then
if infestor[unitDefID] and infestor[Spring.GetUnitDefID(builderID)] then
Spring.GiveOrderToUnit(unitID, CMD.GUARD, { builderID }, { "shift" })
end
end
end
else
gadgetHandler:RemoveGadget(self)
end


function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID)
if builderID and isInfestor[unitDefID] and isInfestor[Spring.GetUnitDefID(builderID)] then
local OrderUnit = Spring.GiveOrderToUnit
OrderUnit(unitID, CMD.GUARD, { builderID }, { "shift" })
end
end

0 comments on commit 7e07038

Please sign in to comment.