List = GetArmyBrain(army):GetListOfUnits(categories.ALLUNITS, false, true)
for k, unit in List do
if (unit:GetUnitId() == 'alphaa1') then
self:AddBuildRestriction( categories.sbrot1expd )
Statistics: Posted by DDDX — 24 Oct 2018, 18:24
Statistics: Posted by Franck83 — 24 Oct 2018, 16:16
Statistics: Posted by DDDX — 24 Oct 2018, 13:27
local num_Turrets = 0
local OldXEB2306 = XEB2306
XEB2306 = Class(OldXEB2306) {
OldOnStopBeingBuilt = OldXEB2306.OnStopBeingBuilt,
OnStopBeingBuilt = function(self, builder, layer)
num_Turrets = num_Turrets + 1
if num_Turrets > 5 then
-- Your building restriction code
end
end,
OldDestroyUnit = OldXEB2306.DestroyUnit,
DestroyUnit = function(self, overkillRatio)
num_Turrets = num_Turrets - 1
if num_Turrets <= 5 then
-- Your building unlocking code
end
end,
}
TypeClass = XEB2306
Statistics: Posted by Franck83 — 20 Oct 2018, 12:40
OnStopBuild = function(self, sbrot1expd, order)
AAirUnit.OnStopBuild(self, sbrot1expd)
--restrict the total number of things we can build
local army = self:GetArmy()
List = GetArmyBrain(army):GetListOfUnits(categories.ALLUNITS, false, true)
for k, unit in List do
if (unit:GetUnitId() == 'sbrot1expd') then --my turret that I only need 2 of at any given time
table.insert(num_Mizura, unit); -- add unit to special unit list
if (table.getn(num_Mizura) >= 2) then
self:AddBuildRestriction( categories.sbrot1expd ) -- works like a charm
end
end
end
end,
OnStartReclaim = function(self, target) -- the unit is gonna do a ton of reclaiming, that's why
AAirUnit.OnStartReclaim(self, target)
local army = self:GetArmy()
List = GetArmyBrain(army):GetListOfUnits(categories.sbrot1expd, false, true)
for k, unit in List do
if (table.getn(num_Mizura) <= 1) then
self:RemoveBuildRestriction( categories.sbrot1expd )
table.remove(num_Mizura, unit)
end
end
end,
OnKilled = function(self, instigator, damagetype, overkillRatio)
TStructureUnit.OnKilled(self, instigator, damagetype, overkillRatio)
local army = self:GetArmy()
List = GetArmyBrain(army):GetListOfUnits(categories.sbrot1expd, false, true)
for k, unit in List do
-- if (unit:GetUnitId() == 'sbrot1expd') then
table.remove(num_Mizura, 1); -- was table.remove(num_Mizura, unit), that's why I got the whole GetArmyBrain etc... but that gave me an error, asked for numerical value...what does the num value do here?
end
self:CreatTheEffectsDeath()
end,
Statistics: Posted by DDDX — 20 Oct 2018, 01:21