mdesc1="CAPTURE & DEFEND THE FLAGS!" mdesc2="HOLD 11/20 FLAGS FOR 1 MIN & WIN THE GAME!" mdesc3="SPAM UNITS & DEFENSE STRUCTURES, THEY ONLY COST BUILDTIME!" mdesc4="USE RALLYPOINTS!" mdesc5="HI5!" CTFFLagtypes = {"ctrlzone","ctrlzonem","ctrlzonet","ctrlzonea","ctrlzoneh","ctrlzoneh2","ctrlzoneh3","ctrlzones","ctrlzoneb","ctrlzoned"} CTbs = {"handnew","labnew","centnew","padnew","infpad","hinfpad","tinfpad","fixnew","fixnew2","fixnew3","dashq", "artpad", "defgun", "defsam", "defgtwr"} aiTicker = DateTime.Seconds(4) -- 0:4 num = 0 function GetNearFlag (flag) -- function for flag trigger and capture --Media.DisplayMessage("Set Up Flag!","") local flagactors = Map.ActorsInCircle(flag.CenterPosition , WDist.FromCells(10), function(bld) return bld.Type == CTbs[1] or bld.Type == CTbs[2] or bld.Type == CTbs[3] or bld.Type == CTbs[4] or bld.Type == CTbs[5] or bld.Type == CTbs[6] or bld.Type == CTbs[7] or bld.Type == CTbs[8] or bld.Type == CTbs[9] or bld.Type == CTbs[10] or bld.Type == CTbs[11]or bld.Type == CTbs[12] or bld.Type == CTbs[13] or bld.Type == CTbs[14] end) Trigger.OnEnteredProximityTrigger(flag.CenterPosition, WDist.FromCells(2), function(a, id) local mine = flag.Owner local yours = a.Owner if mine ~= yours and mine.IsAlliedWith(yours) ~= true and yours ~= Player.GetPlayer("Neutral") and yours ~= Player.GetPlayer("Creeps") and Actor.CruiseAltitude(a.Type) == 0 then flag.Owner = yours if flagactors ~= nil and flag.Type ~= "ctrlzones" and flag.Type ~= "ctrlzoneb" then for i,v in ipairs(flagactors) do if v ~= nil then v.Owner = yours -- Desync solved? end end end end end) end function joinMyTables(t1, t2) -- simple join tables for k,v in ipairs(t2) do table.insert(t1, v) num = num + 1 end return t1 end WorldLoaded = function() CTFlags = {} Trigger.AfterDelay(DateTime.Seconds(1), function() -- set up Flags local neut = Player.GetPlayer("Neutral") for i=1,#CTFFLagtypes do local T1 = neut.GetActorsByType(CTFFLagtypes[i]) if T1 ~= nil then joinMyTables(CTFlags, T1) end end end) Trigger.AfterDelay(DateTime.Seconds(2), function() -- fuse flags for k,v in ipairs(CTFlags) do GetNearFlag(v) end return CTFlags end) Trigger.AfterDelay(DateTime.Seconds(3), function() -- player announcements timerStarted = true Media.DisplayMessage(mdesc1,"") end) Trigger.AfterDelay(DateTime.Seconds(8), function() Media.DisplayMessage(mdesc2,"") end) Trigger.AfterDelay(DateTime.Seconds(15), function() Media.DisplayMessage(mdesc3,"") end) Trigger.AfterDelay(DateTime.Seconds(22), function() Media.DisplayMessage(mdesc4,"") end) Trigger.AfterDelay(DateTime.Seconds(29), function() Media.DisplayMessage(mdesc5,"") end) Trigger.AfterDelay(DateTime.Seconds(3), function() --AI Enter Closed area Trigger local aiflaggers = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(bld) return bld.Type == CTFFLagtypes[1] or bld.Type == CTFFLagtypes[2] or bld.Type == CTFFLagtypes[3] or bld.Type == CTFFLagtypes[4] or bld.Type == CTFFLagtypes[5] or bld.Type == CTFFLagtypes[6] end) for i = 1, #aiflaggers do if aiflaggers[i] ~= nil then Trigger.OnEnteredProximityTrigger(aiflaggers[i].CenterPosition, WDist.FromCells(8), function(a, id) local mine = aiflaggers[i].Owner local yours = a.Owner if mine ~= yours and mine.IsAlliedWith(yours) == false and yours.IsBot and a.HasProperty("AttackMove") and Actor.CruiseAltitude(a.Type) == 0 and a.IsDead == false then a.Stop() a.AttackMove(aiflaggers[i].Location) end end) Trigger.OnExitedProximityTrigger(aiflaggers[i].CenterPosition, WDist.FromCells(5), function(a, id) local mine = aiflaggers[i].Owner local yours = a.Owner if mine ~= yours and mine.IsAlliedWith(yours) == false and yours.IsBot and a.HasProperty("AttackMove") and Actor.CruiseAltitude(a.Type) == 0 and a.IsDead == false then a.Stop() a.AttackMove(aiflaggers[i].Location) end end) end end end) end