AiControl = function() 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 aiflaggers[i] ~= nil and 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 aiflaggers[i] ~= nil and 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 Tick = function() if aiTicker > 0 and aiTicker then aiTicker = aiTicker - 1 elseif aiTicker == 0 then Trigger.AfterDelay(DateTime.Seconds(1), function() aiTicker = DateTime.Minutes(0) + DateTime.Seconds(5) -- 0:5 end) end --new AI scripz if aiTicker == 1 then for i=1,8 do local ai = Player.GetPlayer("Multi" .. tostring(i-1)) if ai ~= nil and ai.IsBot then local aiunits = ai.GetGroundAttackers() -- get Atack units local attackpoint = nil local randomn = Utils.RandomInteger(1,100) -- random Roll local lowtarget = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(bld) -- getting sight flags return (bld.Type == CTFFLagtypes[6]) and bld.Owner ~= ai and ai.IsAlliedWith(bld.Owner) == false end) local medtarget = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(bld) -- getting Infantry flags return (bld.Type == CTFFLagtypes[1] or bld.Type == CTFFLagtypes[2]) and bld.Owner ~= ai and ai.IsAlliedWith(bld.Owner) == false end) local Hightarget = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(bld) -- getting Tang flags return (bld.Type == CTFFLagtypes[3] or bld.Type == CTFFLagtypes[4] or bld.Type == CTFFLagtypes[8]) and bld.Owner ~= ai and ai.IsAlliedWith(bld.Owner) == false end) local Mosttarget = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(bld) -- getting Heavy flags return (bld.Type == CTFFLagtypes[5] or bld.Type == CTFFLagtypes[7]) and bld.Owner ~= ai and ai.IsAlliedWith(bld.Owner) == false end) --Media.DisplayMessage("Ai decides to Attack now and Rolled: " .. tostring(randomn),"") -- Delete aafterwards if randomn > 73 and #Mosttarget ~= 0 then -- decide on priority and random roll attackpoint = Mosttarget[Utils.RandomInteger(1,#Mosttarget)] elseif( randomn > 35 and randomn < 74 ) or (#Mosttarget == 0 and #Hightarget ~= 0)then attackpoint = Hightarget[Utils.RandomInteger(1,#Hightarget)] elseif (randomn > 13 and randomn < 36) or (#Hightarget == 0 and #medtarget ~= 0) then attackpoint = medtarget[Utils.RandomInteger(1,#medtarget)] else attackpoint = lowtarget[Utils.RandomInteger(1,#lowtarget)] end if attackpoint ~= nil then -- check and force to attack choosen point --Media.DisplayMessage("Ai decides to Attack: " .. attackpoint.Type,"") -- Delete aafterwards local whos = attackpoint.Owner if whos ~= ai and whos.IsAlliedWith(ai) == false then for v=1, 40 do local unit = aiunits[v] if unit ~= nil and unit.IsIdle then unit.AttackMove(attackpoint.Location) end end end end end end end end