Ticker = 0 Units_Table = {} Paths_Table ={} SecTechTop = {TMPL1, TMPL2} SecTechBot = {MISS1, MISS2} Factorys = {"e1factory","e2factory" ,"e3factory" ,"e4factory" ,"e5factory" ,"e22factory", "rmbofactory" ,"carfactory1", "carfactory2", "carfactory3", "carfactory4", "carfactory5", "carfactory6", "carfactory7" ,"carfactory8", "airfact1" ,"airfact2", "secretfactory1", "secretfactory2", "secretfactory3", "secretfactory4" } QueueUnits = {"e1new", "e2new","e3new","e4new","e5new","e22new","rmbonew", "jeepnew","mtnknew","msamnew","htnknew", "artynew", "ftnknew","mlrsnew","bikenew","orcanew","helinew","tmplangel","fatwr","guntank","moico"} Proxy1 = function() Trigger.OnEnteredProximityTrigger(Map.CenterOfCell(CPos.New(16,49)), WDist.FromCells(3), function(a, id) local mine = TMPL1.Owner local yours = a.Owner if yours ~= Player.GetPlayer("Neutral") and yours ~= Player.GetPlayer("Creeps") and Actor.CruiseAltitude(a.Type) == 0 then if yours == TeamLeft[1] or yours == TeamLeft[2] or yours == TeamLeft[3] then for i = 1,3 do if TeamLeft[i] ~= nil then SecTechTop[i].Owner = TeamLeft[i] end end elseif yours == TeamRight[1] or yours == TeamRight[2] or yours == TeamRight[3] then for i = 1,3 do if TeamRight[i] ~= nil then SecTechTop[i].Owner = TeamRight[i] end end end end end) Trigger.OnEnteredProximityTrigger(Map.CenterOfCell(CPos.New(48,15)), WDist.FromCells(3), function(a, id) local mine = MISS1.Owner local yours = a.Owner if yours ~= Player.GetPlayer("Neutral") and yours ~= Player.GetPlayer("Creeps") and Actor.CruiseAltitude(a.Type) == 0 then if yours == TeamLeft[1] or yours == TeamLeft[2] or yours == TeamLeft[3] then for i = 1,3 do if TeamLeft[i] ~= nil then SecTechBot[i].Owner = TeamLeft[i] end end elseif yours == TeamRight[1] or yours == TeamRight[2] or yours == TeamRight[3] then for i = 1,3 do if TeamRight[i] ~= nil then SecTechBot[i].Owner = TeamRight[i] end end end end end) end --(64,180), function Set (list) local set = {} for _, l in ipairs(list) do set[l] = true end return set end BuildTrigger = function(Unit) local Facts = Set {"e1factory","e2factory" ,"e3factory" ,"e4factory" ,"e5factory" ,"e22factory", "rmbofactory" ,"carfactory1", "carfactory2", "carfactory3", "carfactory4", "carfactory5", "carfactory6", "carfactory7" ,"carfactory8", "airfact2" ,"airfact1", "secretfactory1", "secretfactory2", "secretfactory3", "secretfactory4" } if Facts[Unit.Type] then Media.Debug("worked: " .. Unit.Type) StartBuilding(Unit) end end StartBuilding = function(Bldng) for a,b in ipairs(Factorys) do local Producer = Bldng local Queue = QueueUnits[a] if Bldng.Type == b and not Producer.IsDead then Producer.Build({Queue},function(u) for x,y in ipairs(u) do MovementTrigger(y) end end) Trigger.OnIdle(Producer,function(a) TriggerBuildagain(a,Queue) end) break end end end TriggerBuildagain = function(Producer,Queue) if not Producer.IsDead then Producer.Build({Queue},function(u) for x,y in ipairs(u) do MovementTrigger(y) end end) end end WorldLoaded = function() Trigger.OnEnteredProximityTrigger(Map.CenterOfCell(CPos.New(64,64)),WDist.FromCells(128), function(a, id) BuildTrigger(a) end) Trigger.AfterDelay(DateTime.Seconds(0), function() local MBFs = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(a) return a.Type == "mcv" end) for k,v in ipairs(MBFs) do v.Deploy() end end) Trigger.AfterDelay(DateTime.Seconds(5), function() BaseTL = Map.ActorsInCircle(Map.CenterOfCell(CPos.New(20,9)),WDist.FromCells(3),function(a) return a.Type == "fact2" end) BaseTR = Map.ActorsInCircle(Map.CenterOfCell(CPos.New(9,20)),WDist.FromCells(3),function(a) return a.Type == "fact2" end) BaseBL = Map.ActorsInCircle(Map.CenterOfCell(CPos.New(57,45)),WDist.FromCells(3),function(a) return a.Type == "fact2" end) BaseBR = Map.ActorsInCircle(Map.CenterOfCell(CPos.New(45,57)),WDist.FromCells(3),function(a) return a.Type == "fact2" end) if BaseTL[1] ~= nil then BaseTL = BaseTL[1] Trigger.OnKilled(BaseTL, function() Units = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(a) return a.Owner == BaseTL.Owner end) --Player.GetPlayer("Neutral" for e,f in ipairs(Units) do if f.Type == "tmplnew" or f.Type == "missnew" or f.Type == "fixtech" then f.Owner = Player.GetPlayer("Neutral") elseif not f.IsDead then f.Kill() end end if BaseTR ~= nil and not BaseTR.IsDead and BaseTR.Type == "fact2" then local loc = BaseTR.Location + CVec.New(1,2) Actor.Create("extracash",true,{Owner = BaseTR.Owner,Location = loc, Facing = 0}) end end) end if BaseTR[1] ~= nil then BaseTR = BaseTR[1] Trigger.OnKilled(BaseTR, function() Units = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(a) return a.Owner == BaseTR.Owner end) for e,f in ipairs(Units) do if f.Type == "tmplnew" or f.Type == "missnew" or f.Type == "fixtech" then f.Owner = Player.GetPlayer("Neutral") elseif not f.IsDead then f.Kill() end end if BaseTL ~= nil and not BaseTL.IsDead and BaseTL.Type == "fact2" then local loc = BaseTL.Location + CVec.New(1,2) Actor.Create("extracash",true,{Owner = BaseTL.Owner,Location = loc, Facing = 0}) end end) end if BaseBL[1] ~= nil then BaseBL = BaseBL[1] Trigger.OnKilled(BaseBL, function() Units = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(a) return a.Owner == BaseBL.Owner end) for e,f in ipairs(Units) do if f.Type == "tmplnew" or f.Type == "missnew" or f.Type == "fixtech" then f.Owner = Player.GetPlayer("Neutral") elseif not f.IsDead then f.Kill() end end if BaseBR ~= nil and not BaseBR.IsDead and BaseBR.Type == "fact2" then local loc = BaseBR.Location + CVec.New(2,2) Actor.Create("extracash",true,{Owner = BaseBR.Owner,Location = loc, Facing = 0}) end end) end if BaseBR[1] ~= nil then BaseBR = BaseBR[1] Trigger.OnKilled(BaseBR, function() Units = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(a) return a.Owner == BaseBR.Owner end) for e,f in ipairs(Units) do if f.Type == "tmplnew" or f.Type == "missnew" or f.Type == "fixtech" then f.Owner = Player.GetPlayer("Neutral") elseif not f.IsDead then f.Kill() end end if BaseBL ~= nil and not BaseBL.IsDead and BaseBL.Type == "fact2" then local loc = BaseBL.Location + CVec.New(2,2) Actor.Create("extracash",true,{Owner = BaseBL.Owner,Location = loc, Facing = 0}) end end) end count = true Proxy1() TeamLeft = {BaseTL.Owner, BaseTR.Owner} TeamRight = {BaseBL.Owner, BaseBR.Owner} end) end Tick = function() end IdleContinue = function(Unit) for k,v in pairs(Units_Table) do if v == Unit and not Unit.IsDead and Paths_Table[k][1] ~= nil then local X = Paths_Table[k][1].X local Y = Paths_Table[k][1].Y if (Unit.Location.X < X+2 and Unit.Location.X > X-2 ) and (Unit.Location.Y < Y+2 and Unit.Location.Y > Y-2 ) then table.remove(Paths_Table[k],1) end if Paths_Table[k][1] ~= nil then --if not Actor.CruiseAltitude(Unit.Type) == 0 then local RandIntA = Utils.RandomInteger(-1,2) local RandIntB = Utils.RandomInteger(-1,2) Paths_Table[k][1] = Paths_Table[k][1] + CVec.New(RandIntA,RandIntB) --end Unit.AttackMove(Paths_Table[k][1],3) end elseif v == Unit and not Unit.IsDead and Paths_Table[k][1] == nil then Unit.Destroy() end end end KilledUnit = function(Unit) for k,v in ipairs(Units_Table) do if v == Unit then table.remove(Paths_Table,k) table.remove(Units_Table,k) end end end MovementTrigger = function(Unit) local RandIntA = Utils.RandomInteger(-1,2) local RandIntB = Utils.RandomInteger(-1,2) local PathTopLeft1={CPos.New(48,15)+ CVec.New(RandIntA,RandIntB),CPos.New(59,26),CPos.New(57,57),CPos.New(45,57)} local PathMidTop1={CPos.New(34,30)+ CVec.New(RandIntA,RandIntB),CPos.New(46,42),CPos.New(57,45),CPos.New(45,57)} local PathMidTop2={CPos.New(29,34)+ CVec.New(RandIntA,RandIntB),CPos.New(41,46),CPos.New(45,57),CPos.New(57,45)} local PathTopRight1={CPos.New(16,49)+ CVec.New(RandIntA,RandIntB),CPos.New(27,60),CPos.New(57,57),CPos.New(57,45)} local PathBottomLeft1={CPos.New(48,15)+ CVec.New(RandIntA,RandIntB),CPos.New(38,5),CPos.New(9,9),CPos.New(9,20)} local PathMidBot1={CPos.New(34,30)+ CVec.New(RandIntA,RandIntB),CPos.New(23,19),CPos.New(20,9),CPos.New(9,20)} local PathMidBot2={CPos.New(29,34)+ CVec.New(RandIntA,RandIntB),CPos.New(18,23),CPos.New(9,20),CPos.New(20,9)} local PathBottomRight1={CPos.New(16,49)+ CVec.New(RandIntA,RandIntB),CPos.New(5,38),CPos.New(9,9),CPos.New(20,9)} -- Movement Top Flank Left if((Unit.Location.Y < 4 and Unit.Location.X > 11) or (Unit.Location.Y < 6 and Unit.Location.X > 13) or (Unit.Location.Y < 8 and Unit.Location.X > 15) or (Unit.Location.Y < 10 and Unit.Location.X > 17) or (Unit.Location.Y < 12 and Unit.Location.X > 19)or (Unit.Location.Y < 18 and Unit.Location.X > 33) )and not Unit.IsDead then table.insert(Paths_Table,1,PathTopLeft1) table.insert(Units_Table,1,Unit) Unit.AttackMove(PathTopLeft1[1],3) elseif((Unit.Location.Y > 11 and Unit.Location.X < 4) or (Unit.Location.Y > 13 and Unit.Location.X < 6) or (Unit.Location.Y > 15 and Unit.Location.X < 8) or (Unit.Location.Y > 17 and Unit.Location.X < 10) or (Unit.Location.Y > 19 and Unit.Location.X < 12) or (Unit.Location.Y > 33 and Unit.Location.X < 18))and not Unit.IsDead then table.insert(Paths_Table,1,PathTopRight1) table.insert(Units_Table,1,Unit) Unit.AttackMove(PathTopRight1[1],3) elseif (Unit.Owner == BaseTR.Owner or Unit.Owner == BaseTL.Owner) and not Unit.IsDead then local roll = Utils.RandomInteger(1,3) if roll == 1 then Unit.AttackMove(PathMidTop1[1],3) table.insert(Paths_Table,1,PathMidTop1) table.insert(Units_Table,1,Unit) else Unit.AttackMove(PathMidTop2[1],3) table.insert(Paths_Table,1,PathMidTop2) table.insert(Units_Table,1,Unit) end elseif((Unit.Location.Y < 54 and Unit.Location.X > 62) or (Unit.Location.Y < 52 and Unit.Location.X > 60) or (Unit.Location.Y < 50 and Unit.Location.X > 58) or (Unit.Location.Y < 48 and Unit.Location.X > 56) or (Unit.Location.Y < 46 and Unit.Location.X > 54)or (Unit.Location.Y < 33 and Unit.Location.X > 48) )and not Unit.IsDead then table.insert(Paths_Table,1,PathBottomLeft1) table.insert(Units_Table,1,Unit) Unit.AttackMove(PathBottomLeft1[1],3) elseif((Unit.Location.Y > 54 and Unit.Location.X < 46) or (Unit.Location.Y > 56 and Unit.Location.X < 48) or (Unit.Location.Y > 58 and Unit.Location.X < 50) or (Unit.Location.Y > 60 and Unit.Location.X < 52) or (Unit.Location.Y > 62 and Unit.Location.X < 54) or (Unit.Location.Y > 48 and Unit.Location.X < 33) )and not Unit.IsDead then table.insert(Paths_Table,1,PathBottomRight1) table.insert(Units_Table,1,Unit) Unit.AttackMove(PathBottomRight1[1],3) elseif (Unit.Owner == BaseBR.Owner or Unit.Owner == BaseBL.Owner) and not Unit.IsDead then local roll = Utils.RandomInteger(1,3) if roll == 1 then Unit.AttackMove(PathMidBot1[1],3) table.insert(Paths_Table,1,PathMidBot1) table.insert(Units_Table,1,Unit) else Unit.AttackMove(PathMidBot2[1],3) table.insert(Paths_Table,1,PathMidBot2) table.insert(Units_Table,1,Unit) end end Trigger.OnIdle(Unit,function() IdleContinue(Unit) end) Trigger.OnKilled(Unit, function() KilledUnit(Unit) end) end