----------------------------------------------------------------------------------------- -- Start Activity ----------------------------------------------------------------------------------------- function Towers:StartActivity() print("START! -- Towers:StartActivity()!"); self.braindead = {}; self.AssignedBrains = {}; self.PlayerLZ = SceneMan.Scene:GetArea("LZ Team 1"); self.EnemyLZ = SceneMan.Scene:GetArea("LZ Team 2"); self.EnemyLZb = SceneMan.Scene:GetArea("LZ Team 2b"); self.TopBase = SceneMan.Scene:GetArea("Top Base"); self.MidBase = SceneMan.Scene:GetArea("Mid Base"); self.Outside = SceneMan.Scene:GetArea("Outside"); self.GeneratorArea = SceneMan.Scene:GetArea("Generator Area"); self.NearIntelArea = SceneMan.Scene:GetArea("Near Intel"); self.IntelArea = SceneMan.Scene:GetArea("Intel Area"); self.WECBase = SceneMan.Scene:GetArea("WEC Base"); self.PatrolZones = {}; self.PatrolWaypoints = {}; self.PatrolZones[1] = SceneMan.Scene:GetArea("PatrolZone1"); self.PatrolZones[2] = SceneMan.Scene:GetArea("PatrolZone2"); self.PatrolZones[3] = SceneMan.Scene:GetArea("PatrolZone3"); self.PatrolZones[4] = SceneMan.Scene:GetArea("PatrolZone4"); self.PatrolZones[5] = SceneMan.Scene:GetArea("PatrolZone5"); self.PatrolWaypoints[1] = {SceneMan.Scene:GetArea("PatrolPoint1L"):GetCenterPoint(), SceneMan.Scene:GetArea("PatrolPoint1R"):GetCenterPoint()}; self.PatrolWaypoints[2] = {SceneMan.Scene:GetArea("PatrolPoint2L"):GetCenterPoint(), SceneMan.Scene:GetArea("PatrolPoint2R"):GetCenterPoint()}; self.PatrolWaypoints[3] = {SceneMan.Scene:GetArea("PatrolPoint3L"):GetCenterPoint(), SceneMan.Scene:GetArea("PatrolPoint3R"):GetCenterPoint()}; self.PatrolWaypoints[4] = {SceneMan.Scene:GetArea("PatrolPoint4L"):GetCenterPoint(), SceneMan.Scene:GetArea("PatrolPoint4R"):GetCenterPoint()}; self.PatrolWaypoints[5] = {SceneMan.Scene:GetArea("PatrolPoint5L"):GetCenterPoint(), SceneMan.Scene:GetArea("PatrolPoint5R"):GetCenterPoint()}; self.PlayerGold = 0; self.CPUTeam = Activity.TEAM_2; self.PlayerTeam = Activity.TEAM_1; self.RogueTeam = -1; --Ronin Troops and Weapons self.LWepList = {"Peacemaker" , "Glock" , "Desert Eagle" , "Uzi"}; self.WepList = {"M16" , "AK-47" , "M1 Garand" , "Pumpgun"}; self.HWepList = {"Spas 12" , "Kar98" , "M60"}; self.EnemyList = {"Mia" , "Dimitri" , "Sandra" , "Gordon"}; --WEC Troops and Weapons self.WepListWEC = {"WEC GL-303" , "WEC PL-1" , "WEC PA-31" , "WEC AC-88"}; self.EnemyListWEC = {"Reeves" , "Cardova" , "Quentin" , "Vittek"}; --Intel and Generator Items self.IntelDisk = CreateHeldDevice("Enemy Intel" , "Unitec.rte"); self.IntelDisk.Pos = Vector(3500 , 900); self.Generator = CreateMOSRotating("Passive Generator", "Base.rte"); self.Generator.Pos = Vector(3768 , 965); MovableMan:AddParticle(self.Generator); self.TextCount = 0; self.EnemyHWep = 0.5; self.Stage = 0; self.EvacHatch = 0; self.WECCount = 0; self.GeneratorTimeLeft = 10; self.GeneratorTimer = Timer(); self.GeneratorTimer:Reset(); self.IntelTimeLeft = 30; self.IntelTimer = Timer(); self.IntelTimer:Reset(); self.InWECBase = false; self.WECPissed = false; self.InLZ = false; self.InTopBase = false; self.InMidBase = false; self.InGeneratorArea = false; self.InIntelArea = false; self.NearIntel = false; self.GeneratorOverloaded = false; self.TurretsDead = false; self.HeavyWeaponHere = false; self.HaveIntel = false; self.HeroShipIn = false; self.EvacShipIn = false; self.WECPissedTimer = Timer(); self.WECPissedInterval = 1000; self.WECPissedTimer:Reset(); self.WECSpawnTimer = Timer(); self.WECSpawnInterval = 60000; self.WECSpawnTimer:Reset(); self.AddWECShip1 = false; self.AddWECShip2 = false; self.ShipTimer = Timer(); self.ShipInterval = 25000; self.ShipTimer:Reset(); self.CrateTimer = Timer(); self.CrateInterval = 17500; self.CrateTimer:Reset(); self.EvacHealTimer = Timer(); self.EvacHealInterval = 100; self.EvacHealTimer:Reset(); self.TextTimer = Timer(); self.TextInterval = 5000; self.TextTimer:Reset(); if self.Difficulty <= GameActivity.CAKEDIFFICULTY then self.ShipInterval = 35000; self.CrateInterval = 30000; self.WECSpawnInterval = 90000; self.MOIDLimit = 125; elseif self.Difficulty <= GameActivity.EASYDIFFICULTY then self.ShipInterval = 30000; self.CrateInterval = 22500; self.WECSpawnInterval = 75000; self.MOIDLimit = 150; elseif self.Difficulty <= GameActivity.MEDIUMDIFFICULTY then self.ShipInterval = 25000; self.CrateInterval = 17500; self.WECSpawnInterval = 60000; self.MOIDLimit = 175; elseif self.Difficulty <= GameActivity.HARDDIFFICULTY then self.ShipInterval = 20000; self.CrateInterval = 15000; self.WECSpawnInterval = 50000; self.MOIDLimit = 200; elseif self.Difficulty <= GameActivity.NUTSDIFFICULTY then self.ShipInterval = 17500; self.CrateInterval = 12500; self.WECSpawnInterval = 40000; self.MOIDLimit = 225; elseif self.Difficulty <= GameActivity.MAXDIFFICULTY then self.ShipInterval = 15000; self.CrateInterval = 10000; self.WECSpawnInterval = 30000; self.MOIDLimit = 255; end --Music Stuff self.MusicEnabled = false; if PresetMan:GetModuleID("Unitec Mission Music.rte") ~= -1 then self.MusicEnabled = true; end if self.MusicEnabled == true then AudioMan:ClearMusicQueue(); AudioMan:PlayMusic("Missions - City.rte/Music/Silence.ogg", 0, -1); AudioMan:QueueSilence(8); AudioMan:QueueMusicStream("Unitec Mission Music.rte/Just Do It.ogg"); AudioMan:QueueMusicStream("Unitec Mission Music.rte/Just Do It v2.ogg "); AudioMan:QueueMusicStream("Unitec Mission Music.rte/Just Do It.ogg"); AudioMan:QueueMusicStream("Unitec Mission Music.rte/Just Do It v2.ogg"); AudioMan:QueueMusicStream("Unitec Mission Music.rte/Just Do It.ogg"); end --Spawn Our Heroes self.Scarlett = CreateAHuman("Brain Scarlett" , "Unitec.rte"); self.Scarlett.Team = self.PlayerTeam; self.Scarlett:AddInventoryItem(CreateHDFirearm("Pancor Jackhammer" , "Unitec.rte")); self.Scarlett.AIMode = Actor.AIMODE_SENTRY; self.Tanya = CreateAHuman("Brain Tanya" , "Unitec.rte"); self.Tanya.Team = self.PlayerTeam; self.Tanya:AddInventoryItem(CreateHDFirearm("AI AWM" , "Unitec.rte")); self.Tanya.AIMode = Actor.AIMODE_SENTRY; self.Gus = CreateAHuman("Brain Gus" , "Unitec.rte"); self.Gus.Team = self.PlayerTeam; self.Gus:AddInventoryItem(CreateHDFirearm("Colt M16" , "Unitec.rte")); self.Gus.AIMode = Actor.AIMODE_SENTRY; --Define Scarlett's Ride self.HeroPod = CreateACRocket("Drop Crate"); self.HeroPod.Team = self.PlayerTeam; self.HeroPod:AddInventoryItem(self.Scarlett); self.HeroPod.Pos = Vector(3140, 0); self.HeroPod:SetControllerMode(Controller.CIM_AI, -1); --Define Gus and Tanya's Ride self.HeroShip = CreateACDropShip("UniTec Drop Ship" , "Unitec.rte"); self.HeroShip.Team = self.PlayerTeam; self.HeroShip:AddInventoryItem(self.Tanya); self.HeroShip:AddInventoryItem(self.Gus); self.HeroShip.Pos = Vector(3110, 0); self.HeroShip:SetControllerMode(Controller.CIM_AI, -1); self.HeroShip.AIMode = 9; --Define the evac ship now so it doesn't give errors later self.EvacShip = nil; --Define the Heavy Weapon and its Crate self.HeavyWeapon = CreateHDFirearm("M202" , "Unitec.rte"); self.HeavyWeaponCrate = CreateACRocket("Drop Crate"); self.HeavyWeaponCrate.Pos = Vector(2900 , 0); self.HeavyWeaponCrate:SetControllerMode(Controller.CIM_AI, -1); self.HeavyWeaponCrate:AddInventoryItem(self.HeavyWeapon); --Spawn Ronin Sentries ronin = {}; for i = 1 , 6 do ronin[i] = CreateAHuman(self.EnemyList[math.random(#self.EnemyList)] , "Ronin.rte"); ronin[i].Team = self.CPUTeam; ronin[i].AIMode = Actor.AIMODE_SENTRY; if math.random() < self.EnemyHWep then ronin[i]:AddInventoryItem(CreateHDFirearm(self.HWepList[math.random(#self.HWepList)] , "Ronin.rte")); else ronin[i]:AddInventoryItem(CreateHDFirearm(self.WepList[math.random(#self.WepList)] , "Ronin.rte")); end ronin[i]:AddInventoryItem(CreateHDFirearm(self.LWepList[math.random(#self.LWepList)] , "Ronin.rte")); if math.random() < 0.25 then ronin[i]:AddInventoryItem(CreateHeldDevice("Riot Shield" , "Base.rte")); end MovableMan:AddActor(ronin[i]); end ronin[1].Pos = Vector(2995 , 585); ronin[2].Pos = Vector(4300 , 395); ronin[3].Pos = Vector(4300 , 970); ronin[4].Pos = Vector(4300 , 1155); --Ronins 7 and 8 mark barricade positions ronin[5].Pos = Vector(3265 , 1308); ronin[6].Pos = Vector(3455 , 1308); --Ronin on rooftop, sole purpose in life is to be squished ronin = CreateAHuman(self.EnemyList[math.random(#self.EnemyList)] , "Ronin.rte"); ronin.Team = self.CPUTeam; ronin.AIMode = Actor.AIMODE_SENTRY; ronin:AddInventoryItem(CreateHDFirearm("RPG-7" , "Ronin.rte")); MovableMan:AddActor(ronin); ronin.Pos = Vector(3150 , 240); --Spawn Ronin Patrollers self.Patrollers = {}; for i = 1 , 5 do self.Patrollers[i] = CreateAHuman(self.EnemyList[math.random(#self.EnemyList)] , "Ronin.rte"); self.Patrollers[i].Team = self.CPUTeam; self.Patrollers[i].AIMode = Actor.AIMODE_SENTRY; if math.random() < self.EnemyHWep then self.Patrollers[i]:AddInventoryItem(CreateHDFirearm(self.HWepList[math.random(#self.HWepList)] , "Ronin.rte")); else self.Patrollers[i]:AddInventoryItem(CreateHDFirearm(self.WepList[math.random(#self.WepList)] , "Ronin.rte")); end self.Patrollers[i]:AddInventoryItem(CreateHDFirearm(self.LWepList[math.random(#self.LWepList)] , "Ronin.rte")); if math.random() < 0.25 then self.Patrollers[i]:AddInventoryItem(CreateHeldDevice("Riot Shield" , "Base.rte")); end MovableMan:AddActor(self.Patrollers[i]); end self.Patrollers[1].Pos = Vector(self.PatrolZones[1]:GetRandomPoint().X , 820); -- Goes to Vector(3600 , 820); self.Patrollers[2].Pos = Vector(self.PatrolZones[2]:GetRandomPoint().X , 820); -- Goes to Vector(4030 , 820); self.Patrollers[3].Pos = Vector(self.PatrolZones[3]:GetRandomPoint().X , 390); -- Goes to Vector(4080 , 390); self.Patrollers[4].Pos = Vector(self.PatrolZones[4]:GetRandomPoint().X , 1305); -- Goes to Vector(4035 , 1305); self.Patrollers[5].Pos = Vector(self.PatrolZones[5]:GetRandomPoint().X , 1165); -- Goes to Vector(4030 , 1165); -- Spawn Ronin Turrets self.Banshee = CreateACrab("Sentry Gun Banshee" , "Unitec.rte"); self.Banshee.Pos = Vector(3170 , 1250); self.Banshee.Team = self.CPUTeam; self.Banshee.AIMode = Actor.AIMODE_SENTRY; MovableMan:AddActor(self.Banshee); self.Turrets = {}; self.Turrets[1] = CreateACrab("Sentry Gun LAS-R-G" , "Unitec.rte"); self.Turrets[2] = CreateACrab("Sentry Gun Mini-G" , "Unitec.rte"); self.Turrets[3] = CreateACrab("Sentry Gun A13-C" , "Unitec.rte"); self.Turrets[4] = CreateACrab("Sentry Gun Mini-C" , "Unitec.rte"); -- Turret for intel room for i = 1 , 4 do self.Turrets[i].Team = self.CPUTeam; self.Turrets[i].AIMode = Actor.AIMODE_SENTRY; MovableMan:AddActor(self.Turrets[i]); end self.Turrets[1].Pos = Vector(3170 , 1308); self.Turrets[2].Pos = Vector(3550 , 1308); self.Turrets[3].Pos = Vector(3510 , 1236); self.Turrets[4].Pos = Vector(3600 , 900); --Spawn WEC self.WEC = {}; for i = 1 , 3 do self.WEC[i] = CreateAHuman(self.EnemyListWEC[math.random(#self.EnemyListWEC)] , "Unitec.rte"); self.WEC[i].Team = self.CPUTeam; self.WEC[i].AIMode = Actor.AIMODE_SENTRY; if math.random() < 0.1 then self.WEC[i]:AddInventoryItem(CreateHDFirearm("WEC UV-9" , "Unitec.rte")); else self.WEC[i]:AddInventoryItem(CreateHDFirearm(self.WepListWEC[math.random(#self.WepListWEC)] , "Unitec.rte")); end self.WEC[i]:AddInventoryItem(CreateHeldDevice("Force Shield" , "Unitec.rte")); MovableMan:AddActor(self.WEC[i]); end self.WEC[1].Pos = Vector(1870 , 830); self.WEC[2].Pos = Vector(2075 , 250); self.WEC[3].Pos = Vector(1805 , 1305); end ----------------------------------------------------------------------------------------- -- Pause Activity ----------------------------------------------------------------------------------------- -- This function is called when mission is paused function Towers:PauseActivity(pause) print("PAUSE! -- Towers:PauseActivity()!"); end ----------------------------------------------------------------------------------------- -- End Activity ----------------------------------------------------------------------------------------- -- This function is called after mission has ended function Towers:EndActivity() print("END! -- Towers:EndActivity()!"); end ----------------------------------------------------------------------------------------- -- Update Activity ----------------------------------------------------------------------------------------- function Towers:UpdateActivity() if self.ActivityState ~= Activity.OVER then self:SetTeamFunds(self.PlayerGold , self.PlayerTeam); if self.TextCount == 0 then for player = 0, self.PlayerCount - 1 do if MovableMan:IsActor(self.HeroPod) then if self.HeroPod.Pos.Y <= 5 then self:SwitchToActor(self.HeroPod, player, self.PlayerTeam); end end end end self:ClearObjectivePoints(); self:PatrolControl(); --Some more checks to try to deal with the fact that no matter how many times I make sure everyone exists CC can still reference non-existing actors and crash. Argh, infuriating! if self.HeroShipIn == true and not MovableMan:IsActor(self.HeroShip) and not MovableMan:IsActor(self.HeroPod) then if self.EvacShipIn == false then if not MovableMan:IsActor(self.Scarlett) then self.Scarlett = nil; end if not MovableMan:IsActor(self.Tanya) then self.Tanya = nil; end if not MovableMan:IsActor(self.Gus) then self.Gus = nil; end elseif self.EvacShipIn == true then if not MovableMan:IsActor(self.Scarlett) and not self.EvacShip:HasObject("Brain Scarlett") then self.Scarlett = nil; end if not MovableMan:IsActor(self.Tanya) and not self.EvacShip:HasObject("Brain Tanya") then self.Tanya = nil; end if not MovableMan:IsActor(self.Gus) and not self.EvacShip:HasObject("Brain Gus") then self.Gus = nil; end end end --Call the function to do all the WEC stuff self:WECActions(); if MovableMan:IsActor(self.Scarlett) and MovableMan:IsActor(self.Tanya) and MovableMan:IsActor(self.Gus) then --Set up Stage Actions if self.Stage == 1 then self:RetrieveIntel(); end end if self.Stage == 2 then self:Evacuate(); end --Add the two hero craft if self.TextCount == 0 then if self.TextTimer:IsPastSimMS(self.TextInterval - 500) then if not MovableMan:IsActor(self.HeroPod) then MovableMan:AddActor(self.HeroPod); end end end if self.HeroShipIn == false then if MovableMan:IsActor(self.Scarlett) then if not MovableMan:IsActor(self.HeroShip) then MovableMan:AddActor(self.HeroShip); self.HeroShipIn = true; end end end --Set the ships as observation targets when they show up if MovableMan:IsActor(self.HeroPod) then self.HeroPod.Health = 100; for player = 0, self.PlayerCount - 1 do self:SetObservationTarget(self.HeroPod.Pos, player); end self.HeroPod:SetControllerMode(Controller.CIM_AI, -1); end if MovableMan:IsActor(self.HeroShip) then for player = 0, self.PlayerCount - 1 do self:SetObservationTarget(self.HeroShip.Pos, player); end self.HeroShip:SetControllerMode(Controller.CIM_AI, -1); end self:DoText(); end self:DoBrainSelection(); self:Winner(); self:YSortObjectivePoints(); end ----------------------------------------------------------------------------------------- -- Set up Text ----------------------------------------------------------------------------------------- function Towers:DoText() if self.TextTimer:IsPastSimMS(self.TextInterval) then if self.TextCount ~= 3 then if self.TextCount ~= 7 then if self.TextCount ~= 9 then if self.TextCount ~= 11 then if self.TextCount ~= 13 then if self.TextCount ~= 15 then if self.TextCount ~= 17 then self.TextCount = self.TextCount + 1; end end end end end end end self.TextTimer:Reset(); end for player = 0, self.PlayerCount - 1 do if self.TextCount == 0 then FrameMan:ClearScreenText(player); FrameMan:SetScreenText("We've got an enemy on the roof, looks like they're expecting us. \n We'll drop a drop pod on him, see if he expects that." , player, 25000, -1, true); elseif self.TextCount == 1 then FrameMan:ClearScreenText(player); FrameMan:SetScreenText("Right, he's down. Head down through the tower and get that intel disk. \n The evac zone is the same as the LZ, move fast and stay alive." , player, 25000, -1, true); self.Stage = 1; elseif self.TextCount == 2 then FrameMan:ClearScreenText(player); FrameMan:SetScreenText("Oh, and don't stray to the other tower, there are WEC troops there and we don't want to mess with them. \n As long as we stay out of their way, they'll stay out of ours." , player, 25000, -1, true); elseif self.TextCount == 3 then FrameMan:ClearScreenText(player); self.TextTimer:Reset(); elseif self.TextCount == 4 then FrameMan:ClearScreenText(player); FrameMan:SetScreenText("Wow, they've really got the lower level defended. \n God knows how they were able to afford a Banshee - those things are spaceship class weapons and they're not cheap." , player, 25000, -1, true); elseif self.TextCount == 5 then FrameMan:ClearScreenText(player); FrameMan:SetScreenText("It seems luck is on our side though, the turrets all seem to be jury rigged to one power generator. \n We'll need all of you to head over there to deal with it." , player, 25000, -1, true); elseif self.TextCount == 6 then FrameMan:ClearScreenText(player); self.TextTimer:Reset(); elseif self.TextCount == 7 then FrameMan:ClearScreenText(player); FrameMan:SetScreenText(string.format("The generator will be overloaded in %d more seconds." , self.GeneratorTimeLeft) , player, 333, -1, false); self.TextTimer:Reset(); elseif self.TextCount == 8 then FrameMan:ClearScreenText(player); if self.GeneratorOverloaded == true then FrameMan:SetScreenText("It seems the ronin wiring was worse than we thought, overloading the generator completely destroyed the turrets. \n Anyway, the way is clear, get that intel." , player, 25000, -1, true); elseif self.TurretsDead == true then FrameMan:SetScreenText("Wow, that's pretty unbelievable, taking out a banshee, not to mention all the other defenses there, with relatively small arms. \n \n \n *Developer's note: You're either cheating, exploiting the sniper or the ultimate cortex command badass. \n Whichever it is, congratulations on doing this the ridiculously hard way.*" , player, 25000, -1, true); end elseif self.TextCount == 9 then FrameMan:ClearScreenText(player); self.TextTimer:Reset(); elseif self.TextCount == 10 then FrameMan:ClearScreenText(player); FrameMan:SetScreenText("Looks like one of the turrets is still damaged but still working, that'll be tough to take out with the weapons you've got. \n We'll send you in something heavy to take care of it, don't try to assault it until you've got the heavy weapon." , player, 25000, -1, true); elseif self.TextCount == 11 then FrameMan:ClearScreenText(player); self.TextTimer:Reset(); elseif self.TextCount == 12 then FrameMan:ClearScreenText(player); FrameMan:SetScreenText("Great, you've made it. We're hacking the console, it'll take about half a minute. \n Stay in the area until it's done, the connection from your gear is needed to hack it." , player, 25000, -1, true); elseif self.TextCount == 13 then FrameMan:ClearScreenText(player); FrameMan:SetScreenText(string.format("The hacking will be completed in %d more seconds. Keep someone near the console until it's finished." , self.IntelTimeLeft) , player, 333, -1, false); self.TextTimer:Reset(); elseif self.TextCount == 14 then FrameMan:ClearScreenText(player); FrameMan:SetScreenText("Alright, we've got everything we need. It's too big to send over the wireless so we've put it on a disk for you. \n Head to the evac zone and move fast, ronin are incoming. And whatever you do, don't let the disk get destroyed." , player, 25000, -1, true); elseif self.TextCount == 15 then FrameMan:ClearScreenText(player); self.TextTimer:Reset(); elseif self.TextCount == 16 then FrameMan:ClearScreenText(player); FrameMan:SetScreenText("Your ship's here, get in and head out. Make sure not to try to unload anyone you've already loaded since the ship's ai isn't too smart. \n Good work by the way, with this we're a lot closer to finding Jack." , player, 25000, -1, true); elseif self.TextCount == 17 then FrameMan:ClearScreenText(player); self.TextTimer:Reset(); end --WEC Text if self.TextCount == 7 or self.TextCount == 13 then if self.InWECBase == true and self.WECPissed == false and self.WECCount > 0 and self.WECCount < 5 then FrameMan:SetScreenText("Soldiers of S.H.I.E.L.D. we hold no grudge against you but know that choosing to remain within our property will be your end." , player, 25000, -1, true); elseif self.WECPissed == true and self.WECCount > 5 and self.WECCount < 11 then FrameMan:SetScreenText("Very well, you have made your choice. You will be terminated with extreme predujice as long as you are within our property. \n Should you choose to leave we will not pursue you." , player, 25000, -1, true); end else if self.InWECBase == true and self.WECPissed == false and self.WECCount > 0 and self.WECCount < 5 then FrameMan:SetScreenText("Soldiers of S.H.I.E.L.D. we hold no grudge against you but know that choosing to remain within our property will be your end." , player, 25000, -1, false); elseif self.WECPissed == true and self.WECCount > 5 and self.WECCount < 11 then FrameMan:SetScreenText("Very well, you have made your choice. You will be terminated with extreme predujice as long as you are within our property. \n Should you choose to leave we will not pursue you." , player, 25000, -1, false); end end end end ----------------------------------------------------------------------------------------- -- Patrol Control - Thanks to weegee for the awesome script ----------------------------------------------------------------------------------------- function Towers:PatrolControl() for actor in MovableMan.Actors do if actor.Team == self.CPUTeam and actor.AIMode ~= Actor.AIMODE_GOTO and actor.AIMode ~= Actor.AIMODE_BRAINHUNT and actor.ClassName == "AHuman" then for i = 1 , #self.PatrolZones do if self.PatrolZones[i]:IsInside(actor.Pos) then local dist1 = math.sqrt((actor.Pos.X - self.PatrolWaypoints[i][1].X) ^ 2 + (actor.Pos.Y - self.PatrolWaypoints[i][1].Y) ^ 2); local dist2 = math.sqrt((actor.Pos.X - self.PatrolWaypoints[i][2].X) ^ 2 + (actor.Pos.Y - self.PatrolWaypoints[i][2].Y) ^ 2); actor.AIMode = Actor.AIMODE_GOTO; actor:ClearAIWaypoints(); --actor:FlashWhite(50); --actor:DrawWaypoints(true); if dist1 < dist2 then actor:AddAISceneWaypoint(self.PatrolWaypoints[i][2]); else actor:AddAISceneWaypoint(self.PatrolWaypoints[i][1]); end break; end end end end end ----------------------------------------------------------------------------------------- -- Do everything involving WEC ----------------------------------------------------------------------------------------- function Towers:SpawnWEC() local ship1 = CreateACDropShip("UniTec Drop Ship" , "Unitec.rte"); local ship2 = CreateACDropShip("UniTec Drop Ship" , "Unitec.rte"); self.WECR = {} for i = 1 , 5 do self.WECR[i] = CreateAHuman(self.EnemyListWEC[math.random(#self.EnemyListWEC)] , "Unitec.rte"); self.WECR[i].Team = self.CPUTeam; self.WECR[i].AIMode = Actor.AIMODE_GOTO; if math.random() < 0.1 then self.WECR[i]:AddInventoryItem(CreateHDFirearm("WEC UV-9" , "Unitec.rte")); else self.WECR[i]:AddInventoryItem(CreateHDFirearm(self.WepListWEC[math.random(#self.WepListWEC)] , "Unitec.rte")); end self.WECR[i]:AddInventoryItem(CreateHeldDevice("Force Shield" , "Unitec.rte")); end self.WECR[1]:AddAISceneWaypoint(Vector(1870 , 830)); self.WECR[2]:AddAISceneWaypoint(Vector(2075 , 250)); self.WECR[3]:AddAISceneWaypoint(Vector(1090 , 830)); self.WECR[4]:AddAISceneWaypoint(Vector(1805 , 1305)); self.WECR[5]:AddAISceneWaypoint(Vector(1430 , 1165)); if not MovableMan:IsActor(self.WEC[1]) and not MovableMan:IsActor(self.WECR[1]) then ship1:AddInventoryItem(self.WECR[1]); self.AddWECShip1 = true; end if not MovableMan:IsActor(self.WEC[2]) and not MovableMan:IsActor(self.WECR[2]) then ship1:AddInventoryItem(self.WECR[2]); self.AddWECShip1 = true; end if not MovableMan:IsActor(self.WEC[3]) and not MovableMan:IsActor(self.WECR[3]) then ship1:AddInventoryItem(self.WECR[3]); self.AddWECShip1 = true; end if not MovableMan:IsActor(self.WEC[4]) and not MovableMan:IsActor(self.WECR[4]) then ship2:AddInventoryItem(self.WECR[4]); self.AddWECShip2 = true; end if not MovableMan:IsActor(self.WEC[5]) and not MovableMan:IsActor(self.WECR[5]) then ship2:AddInventoryItem(self.WECR[5]); self.AddWECShip2 = true; end ship1.Pos = Vector(1700, 0); ship1.Team = self.CPUTeam; ship1:SetControllerMode(Controller.CIM_AI, -1); if self.AddWECShip1 == true then MovableMan:AddActor(ship1); self.AddWECShip1 = false; end ship2.Pos = Vector(2000, 0); ship2.Team = self.CPUTeam; ship2:SetControllerMode(Controller.CIM_AI, -1); if self.AddWECShip2 == true then MovableMan:AddActor(ship2); self.AddWECShip2 = false; end end function Towers:WECActions() --Check if your actors are inside. if MovableMan:IsActor(self.Scarlett) and MovableMan:IsActor(self.Tanya) and MovableMan:IsActor(self.Gus) then if self.WECBase:IsInside(self.Scarlett.Pos) or self.WECBase:IsInside(self.Tanya.Pos) or self.WECBase:IsInside(self.Gus.Pos) then self.InWECBase = true; elseif not self.WECBase:IsInside(self.Scarlett.Pos) and not self.WECBase:IsInside(self.Tanya.Pos) and not self.WECBase:IsInside(self.Gus.Pos) then self.InWECBase = false; end --Also determine who to add objective markers to if self.WECBase:IsInside(self.Scarlett.Pos) then if self.WECCount < 6 then self:AddObjectivePoint(string.format("Leave the WEC base within %d seconds to keep them from attacking you." , 5 - self.WECCount) , self.Scarlett.AboveHUDPos , self.PlayerTeam, GameActivity.ARROWDOWN) end elseif self.WECBase:IsInside(self.Tanya.Pos) then if self.WECCount < 6 then self:AddObjectivePoint(string.format("Leave the WEC base within %d seconds to keep them from attacking you." , 5 - self.WECCount) , self.Tanya.AboveHUDPos , self.PlayerTeam, GameActivity.ARROWDOWN) end elseif self.WECBase:IsInside(self.Gus.Pos) then if self.WECCount < 6 then self:AddObjectivePoint(string.format("Leave the WEC base within %d seconds to keep them from attacking you." , 5 - self.WECCount) , self.Gus.AboveHUDPos , self.PlayerTeam, GameActivity.ARROWDOWN) end end end if self.InWECBase == true then if self.WECPissedTimer:IsPastSimMS(self.WECPissedInterval) then self.WECCount = self.WECCount + 1; self.WECPissedTimer:Reset(); end if self.WECCount >= 5 then self.WECPissed = true; end else if self.WECPissed == false then self.WECPissedTimer:Reset(); end end if self.WECPissed == true then if self.WECCount < 13 then if self.WECPissedTimer:IsPastSimMS(self.WECPissedInterval) then self.WECCount = self.WECCount + 1; self.WECPissedTimer:Reset(); end end if MovableMan:GetMOIDCount() < self.MOIDLimit then if self.WECSpawnTimer:IsPastSimMS(self.WECSpawnInterval) then self:SpawnWEC(); self.WECSpawnTimer:Reset(); end end end --This shouldn't actually be here but I want to do as few for actor in MovableMan.Actors as possible cause they're slow for actor in MovableMan.Actors do if MovableMan:GetMOIDCount() >= self.MOIDLimit - 25 and MovableMan:GetMOIDCount() <= self.MOIDLimit - 5 then if self.stage == 2 then if actor.Team == self.CPUTeam and actor.AIMode == Actor.AIMODE_GOTO then if self.TopBase:IsInside(actor.Pos) or self.MidBase:IsInside(actor.Pos) then actor.AIMode = Actor.AIMODE_SENTRY; end end end end --This should be here though if actor.Team == self.CPUTeam and self.WECBase:IsInside(actor.Pos) and actor.ClassName == "AHuman" then if actor.Health < 90 or self.WECPissed == true then actor:SetControllerMode(Controller.CIM_AI, -1); else actor:SetControllerMode(Controller.CIM_DISABLED, -1); end end end end ----------------------------------------------------------------------------------------- -- Create the Ronins and Ship ----------------------------------------------------------------------------------------- function Towers:SpawnRoninShipTop() local ship = CreateACDropShip("Drop Ship MK1" , "Base.rte"); local actor = nil; --Create the actors for i = 0 , 2 do actor = CreateAHuman(self.EnemyList[math.random(#self.EnemyList)] , "Ronin.rte"); actor.Team = self.CPUTeam; actor.AIMode = Actor.AIMODE_GOTO; actor:AddAISceneWaypoint(Vector(self.TopBase:GetRandomPoint().X, self.TopBase:GetRandomPoint().Y)); if math.random() < self.EnemyHWep then actor:AddInventoryItem(CreateHDFirearm(self.HWepList[math.random(#self.HWepList)] , "Ronin.rte")); else actor:AddInventoryItem(CreateHDFirearm(self.WepList[math.random(#self.WepList)] , "Ronin.rte")); end actor:AddInventoryItem(CreateHDFirearm(self.LWepList[math.random(#self.LWepList)] , "Ronin.rte")); if math.random() < 0.25 then actor:AddInventoryItem(CreateHeldDevice("Riot Shield" , "Base.rte")); end ship:AddInventoryItem(actor); end ship.Pos = Vector(self.EnemyLZ:GetRandomPoint().X, 0); ship.Team = self.CPUTeam; ship:SetControllerMode(Controller.CIM_AI, -1); MovableMan:AddActor(ship); end function Towers:SpawnRoninShipMid() local ship = CreateACDropShip("Drop Ship MK1" , "Base.rte"); local actor = nil; --Create the actors for i = 0 , 2 do actor = CreateAHuman(self.EnemyList[math.random(#self.EnemyList)] , "Ronin.rte"); actor.Team = self.CPUTeam; actor.AIMode = Actor.AIMODE_GOTO; actor:AddAISceneWaypoint(Vector(self.MidBase:GetRandomPoint().X, self.TopBase:GetRandomPoint().Y)); if math.random() < self.EnemyHWep then actor:AddInventoryItem(CreateHDFirearm(self.HWepList[math.random(#self.HWepList)] , "Ronin.rte")); else actor:AddInventoryItem(CreateHDFirearm(self.WepList[math.random(#self.WepList)] , "Ronin.rte")); end actor:AddInventoryItem(CreateHDFirearm(self.LWepList[math.random(#self.LWepList)] , "Ronin.rte")); if math.random() < 0.25 then actor:AddInventoryItem(CreateHeldDevice("Riot Shield" , "Base.rte")); end ship:AddInventoryItem(actor); end ship.Pos = Vector(self.EnemyLZb:GetRandomPoint().X, 0); ship.Team = self.CPUTeam; ship:SetControllerMode(Controller.CIM_AI, -1); MovableMan:AddActor(ship); end ----------------------------------------------------------------------------------------- -- Create the Ronins and Crate ----------------------------------------------------------------------------------------- function Towers:SpawnRoninCrateTop() local crate = CreateACRocket("Drop Crate", "Dummy.rte"); local actor = nil; --Create the actors actor = CreateAHuman(self.EnemyList[math.random(#self.EnemyList)] , "Ronin.rte"); actor.Team = self.CPUTeam; actor.AIMode = Actor.AIMODE_GOTO; actor:AddAISceneWaypoint(Vector(self.TopBase:GetRandomPoint().X, self.TopBase:GetRandomPoint().Y)); if math.random() < self.EnemyHWep then actor:AddInventoryItem(CreateHDFirearm(self.HWepList[math.random(#self.HWepList)] , "Ronin.rte")); else actor:AddInventoryItem(CreateHDFirearm(self.WepList[math.random(#self.WepList)] , "Ronin.rte")); end actor:AddInventoryItem(CreateHDFirearm(self.LWepList[math.random(#self.LWepList)] , "Ronin.rte")); if math.random() < 0.25 then actor:AddInventoryItem(CreateHeldDevice("Riot Shield" , "Base.rte")); end --Add the actor crate:AddInventoryItem(actor); crate.Pos = Vector(self.EnemyLZ:GetRandomPoint().X, 0); crate.Team = self.CPUTeam; crate:SetControllerMode(Controller.CIM_AI, -1); MovableMan:AddActor(crate); end function Towers:SpawnRoninCrateMid() local crate = CreateACRocket("Drop Crate", "Dummy.rte"); local actor = nil; --Create the actors actor = CreateAHuman(self.EnemyList[math.random(#self.EnemyList)] , "Ronin.rte"); actor.Team = self.CPUTeam; actor.AIMode = Actor.AIMODE_GOTO; actor:AddAISceneWaypoint(Vector(self.MidBase:GetRandomPoint().X, self.MidBase:GetRandomPoint().Y)); if math.random() < self.EnemyHWep then actor:AddInventoryItem(CreateHDFirearm(self.HWepList[math.random(#self.HWepList)] , "Ronin.rte")); else actor:AddInventoryItem(CreateHDFirearm(self.WepList[math.random(#self.WepList)] , "Ronin.rte")); end actor:AddInventoryItem(CreateHDFirearm(self.LWepList[math.random(#self.LWepList)] , "Ronin.rte")); if math.random() < 0.25 then actor:AddInventoryItem(CreateHeldDevice("Riot Shield" , "Base.rte")); end --Add the actor crate:AddInventoryItem(actor); crate.Pos = Vector(self.EnemyLZb:GetRandomPoint().X, 0); crate.Team = self.CPUTeam; crate:SetControllerMode(Controller.CIM_AI, -1); MovableMan:AddActor(crate); end ----------------------------------------------------------------------------------------- -- Destroy Turrets and generator when generator is overloaded ----------------------------------------------------------------------------------------- function Towers:Boom() if MovableMan:IsActor(self.Banshee) then bombb = CreateTDExplosive("Timebomb" , "Unitec.rte"); bombb.Pos = self.Banshee.Pos bombb:GibThis(); self.Banshee:GibThis(); count = 0; end bomb = {} for i = 1, 3 do if MovableMan:IsActor(self.Turrets[i]) then bomb[i] = CreateTDExplosive("Timebomb" , "Unitec.rte"); bomb[i].Pos = self.Turrets[i].Pos bomb[i]:GibThis(); self.Turrets[i]:GibThis(); else self.Turrets[i] = nil; end end if MovableMan:IsActor(self.Turrets[4]) and count == 0 then bombt = CreateTDExplosive("Molotov Cocktail" , "Ronin.rte"); bombt.Pos = self.Turrets[4].Pos bombt:GibThis(); count = count + 1; end end ----------------------------------------------------------------------------------------- -- Get the Intel ----------------------------------------------------------------------------------------- function Towers:RetrieveIntel() -- Set up an objective point to the console. Does not show up when you have to overload the generator so it doesn't confuse people. if self.InMidBase == false then if self.InGeneratorArea == false and self.GeneratorOverloaded == false and self.TurretsDead == false and self.InIntelArea == false and self.HaveIntel == false then self:AddObjectivePoint("Hack the console to obtain valuable intel.", Vector(3500 , 900) , self.PlayerTeam, GameActivity.ARROWDOWN) end end --Generator Stuff if self.MidBase:IsInside(self.Scarlett.Pos) or self.MidBase:IsInside(self.Tanya.Pos) or self.MidBase:IsInside(self.Gus.Pos) then self.InMidBase = true; end if self.InMidBase == true then if self.InGeneratorArea == false and self.GeneratorOverloaded == false then if self.TextCount == 3 then self.TextCount = self.TextCount + 1; end self:AddObjectivePoint("Get everyone to the generator to overload it.", Vector(3768 , 965) , self.PlayerTeam, GameActivity.ARROWDOWN); end end if self.GeneratorOverloaded == false then if self.GeneratorArea:IsInside(self.Scarlett.Pos) or self.GeneratorArea:IsInside(self.Tanya.Pos) or self.GeneratorArea:IsInside(self.Gus.Pos) then self.InGeneratorArea = true; else self.GeneratorTimer:Reset(); end end if self.InGeneratorArea == true then if self.TextCount == 6 then self.TextCount = self.TextCount + 1; end self.InMidBase = false; if self.GeneratorOverloaded == false then if self.GeneratorArea:IsInside(self.Scarlett.Pos) and self.GeneratorArea:IsInside(self.Tanya.Pos) and self.GeneratorArea:IsInside(self.Gus.Pos) then self:AddObjectivePoint("Keep everyone near the generator.", Vector(3768 , 965) , self.PlayerTeam, GameActivity.ARROWDOWN); if self.GeneratorTimer:IsPastSimMS(1000) then self.GeneratorTimeLeft = self.GeneratorTimeLeft - 1 self.GeneratorTimer:Reset(); end else self:AddObjectivePoint("Get everyone near to the generator.", Vector(3768 , 965) , self.PlayerTeam, GameActivity.ARROWDOWN); end end end if self.GeneratorTimeLeft == 0 then self.GeneratorOverloaded = true; if MovableMan:IsParticle(self.Generator) then self.Generator:GibThis(); end end for i = 1, 3 do if not MovableMan:IsActor(self.Turrets[i]) and not MovableMan:IsActor(self.Banshee) then self.Turrets[i] = nil; self.Banshee = nil; self.TurretsDead = true; end end if self.GeneratorOverloaded == true or self.TurretsDead == true then self:Boom(); if self.InIntelArea == false then if self.NearIntel == false then self:AddObjectivePoint("Hack the console to obtain valuable intel.", Vector(3500 , 900) , self.PlayerTeam, GameActivity.ARROWDOWN) end end if self.TextCount == 7 then self.TextCount = self.TextCount + 1 end end --Do Intel stuff if self.NearIntelArea:IsInside(self.Scarlett.Pos) or self.NearIntelArea:IsInside(self.Tanya.Pos) or self.NearIntelArea:IsInside(self.Gus.Pos) then if self.InIntelArea == false and self.HaveIntel == false then self.NearIntel = true; end end if self.NearIntel == true then if self.InIntelArea == false and self.HaveIntel == false then if self.TextCount == 9 then self.TextCount = self.TextCount + 1; end if self.TextCount == 10 then if self.TextTimer:IsPastSimMS(self.TextInterval - 1) then if not MovableMan:IsActor(self.HeavyWeaponCrate) then if not MovableMan:IsDevice(self.HeavyWeapon) then MovableMan:AddActor(self.HeavyWeaponCrate); end end end if MovableMan:IsActor(self.Turrets[4]) then if self.Turrets[4].Health >= 39 then self.Turrets[4].Health = 39; end end end if self.TextCount == 11 then if MovableMan:IsActor(self.Turrets[4]) then if MovableMan:IsActor(self.HeavyWeaponCrate) then self:AddObjectivePoint("Incoming Heavy Weapon.", self.HeavyWeaponCrate.AboveHUDPos , self.PlayerTeam, GameActivity.ARROWDOWN) self:AddObjectivePoint("Collect the heavy weapon and destroy the turret.", Vector(3600 , 900) , self.PlayerTeam, GameActivity.ARROWDOWN) end if MovableMan:IsDevice(self.HeavyWeapon) then if MovableMan:IsActor(self.HeavyWeaponCrate) then self.HeavyWeaponCrate:GibThis(); end if not self.HeavyWeapon:IsAttached() then self:AddObjectivePoint("Heavy Weapon Deployed.", self.HeavyWeapon.AboveHUDPos , self.PlayerTeam, GameActivity.ARROWDOWN) end self:AddObjectivePoint("Collect the heavy weapon and destroy the turret.", Vector(3600 , 900) , self.PlayerTeam, GameActivity.ARROWDOWN) end if self.HeavyWeapon:IsAttached() then self:AddObjectivePoint("Use the heavy weapon to destroy the turret.", Vector(3600 , 900) , self.PlayerTeam, GameActivity.ARROWDOWN) end end end end end if not MovableMan:IsActor(self.Turrets[4]) then self.Turrets[4] = nil; if self.HaveIntel == false then if self.IntelArea:IsInside(self.Scarlett.Pos) or self.IntelArea:IsInside(self.Tanya.Pos) or self.IntelArea:IsInside(self.Gus.Pos) then self.InIntelArea = true; else self.IntelTimer:Reset(); if self.IntelTimeLeft == 30 and self.HaveIntel == false then self:AddObjectivePoint("Hack the console to obtain valuable intel.", Vector(3500 , 900) , self.PlayerTeam, GameActivity.ARROWDOWN) end end end end if self.InIntelArea == true then if self.TextCount == 11 then self.TextCount = self.TextCount + 1; end if self.HaveIntel == false and self.IntelTimeLeft > 0 and self.TextCount == 13 then if self.IntelArea:IsInside(self.Scarlett.Pos) or self.IntelArea:IsInside(self.Tanya.Pos) or self.IntelArea:IsInside(self.Gus.Pos) then self:AddObjectivePoint("Stay near the console.", Vector(3500 , 900) , self.PlayerTeam, GameActivity.ARROWDOWN) if self.IntelTimer:IsPastSimMS(1000) then self.IntelTimeLeft = self.IntelTimeLeft - 1 self.IntelTimer:Reset(); end else self:AddObjectivePoint("Get back to the console.", Vector(3500 , 900) , self.PlayerTeam, GameActivity.ARROWDOWN) end end end if self.IntelTimeLeft < 30 then if self.ShipTimer:IsPastSimMS(self.ShipInterval) and MovableMan:GetMOIDCount() <= self.MOIDLimit then if math.random() < 0.5 then self:SpawnRoninShipTop(); else self:SpawnRoninShipMid(); end self.ShipTimer:Reset(); end if self.CrateTimer:IsPastSimMS(self.CrateInterval) and MovableMan:GetMOIDCount() <= self.MOIDLimit then if math.random() < 0.5 then self:SpawnRoninCrateTop(); else self:SpawnRoninCrateMid(); end self.CrateTimer:Reset(); end elseif self.IntelTimeLeft == 30 then self.ShipTimer:Reset(); self.CrateTimer:Reset(); end for actor in MovableMan.Actors do if self.IntelTimeLeft == 29 then if actor.Team == self.CPUTeam and actor.Pos.Y > 380 and actor.ClassName ~= "ADoor" then actor.AIMode = Actor.AIMODE_GOLDDIG; end elseif self.IntelTimeLeft < 29 then if actor.Team == self.CPUTeam and actor.Pos.Y > 380 and actor.AIMode == Actor.AIMODE_GOLDDIG and actor.ClassName ~= "ADoor" then actor.AIMode = Actor.AIMODE_GOTO; actor:AddAISceneWaypoint(Vector(self.MidBase:GetRandomPoint().X , 1275)); break; end end end if self.IntelTimeLeft == 0 then self.InIntelArea = false; if self.TextCount == 13 then self.TextCount = self.TextCount + 1; end if self.Scarlett:HasObject("Enemy Intel") or self.Tanya:HasObject("Enemy Intel") or self.Gus:HasObject("Enemy Intel") then self.HaveIntel = true; else if self.HaveIntel == false then if not MovableMan:IsDevice(self.IntelDisk) then MovableMan:AddParticle(self.IntelDisk); elseif MovableMan:IsDevice(self.IntelDisk) then self:AddObjectivePoint("Pick up the intel disk.", self.IntelDisk.AboveHUDPos , self.PlayerTeam, GameActivity.ARROWDOWN) end end end end if self.HaveIntel == true then if self.TextCount == 14 or self.TextCount == 15 then self.ShipInterval = 25000; self.CrateInterval = 1250; self.Stage = 2; end end end ----------------------------------------------------------------------------------------- -- Spawn the Evac Ship ----------------------------------------------------------------------------------------- function Towers:SpawnEvacShip() self.EvacShip = CreateACDropShip("UniTec Drop Ship" , "Unitec.rte"); self.EvacShip.Team = self.PlayerTeam; self.EvacShip.Pos = Vector(3110, 0); self.EvacShip:SetControllerMode(Controller.CIM_AI, -1); MovableMan:AddActor(self.EvacShip); end ----------------------------------------------------------------------------------------- -- Evacuate ----------------------------------------------------------------------------------------- function Towers:Evacuate() --Enemy spawns if self.ShipTimer:IsPastSimMS(self.ShipInterval) and MovableMan:GetMOIDCount() <= self.MOIDLimit then if math.random() < 0.8 then self:SpawnRoninShipTop(); else self:SpawnRoninShipMid(); end self.ShipTimer:Reset(); end if self.CrateTimer:IsPastSimMS(self.CrateInterval) and MovableMan:GetMOIDCount() <= self.MOIDLimit then if math.random() < 0.8 then self:SpawnRoninCrateTop(); else self:SpawnRoninCrateMid(); end self.CrateTimer:Reset(); end if MovableMan:IsActor(self.Scarlett) and MovableMan:IsActor(self.Tanya) and MovableMan:IsActor(self.Gus) then --Spawn the evacuation ship when they're in the top area or the outside area and let the player know with text if self.TopBase:IsInside(self.Scarlett.Pos) or self.TopBase:IsInside(self.Tanya.Pos) or self.TopBase:IsInside(self.Gus.Pos) or self.Outside:IsInside(self.Scarlett.Pos) or self.Outside:IsInside(self.Tanya.Pos) or self.Outside:IsInside(self.Gus.Pos) then self.InTopBase = true; end if self.InTopBase == true then if self.TextCount == 14 or self.TextCount == 15 then self.TextCount = self.TextCount + 1; end if not MovableMan:IsActor(self.EvacShip) then if self.EvacShipIn == false then self:SpawnEvacShip(); self.EvacShipIn = true; end end end --Make the ship close its doors if the disk is dropped. if self.PlayerLZ:IsInside(self.Scarlett.Pos) or self.PlayerLZ:IsInside(self.Tanya.Pos) or self.PlayerLZ:IsInside(self.Gus.Pos) then self.InLZ = true; end if self.Scarlett:HasObject("Enemy Intel") or self.Tanya:HasObject("Enemy Intel") or self.Gus:HasObject("Enemy Intel") or self.EvacShip:HasObject("Enemy Intel") then if self.InLZ == true then if self.EvacHatch ~= 2 then self.EvacHatch = 1; end end else self.EvacHatch = 0; end end --A bunch of things happen here: if MovableMan:IsActor(self.EvacShip) and self.EvacShipIn == true and self.ActivityState ~= Activity.OVER then --Make the evacship's hatch open if you have the intel, if not, it stays closed. TODO: Make it possible to get intel again if it's destroyed, either that or make you fail if the intel gets destroyed. if self.EvacHatch == 0 then self.EvacShip:CloseHatch(); elseif self.EvacHatch == 1 then self.EvacShip:GetController():SetState(Controller.PRESS_FACEBUTTON, true); self.EvacHatch = self.EvacHatch + 1; end --Make sure the ship's X position isn't too far off. if self.EvacShip.Pos.X < 3080 then self.EvacShip:GetController():SetState(Controller.MOVE_RIGHT, true); if self.EvacShip.Vel.X < - 2 then self.EvacShip.Vel.X = self.EvacShip.Vel.X + 1; end elseif self.EvacShip.Pos.X > 3140 then self.EvacShip:GetController():SetState(Controller.MOVE_LEFT, true); if self.EvacShip.Vel.X > 2 then self.EvacShip.Vel.X = self.EvacShip.Vel.X - 1; end end --Make sure the ship doesn't try to leave without you. if not self.EvacShip:HasObject("Enemy Intel") or not self.EvacShip:HasObject("Brain Scarlett") or not self.EvacShip:HasObject("Brain Tanya") or not self.EvacShip:HasObject("Brain Gus") then if self.EvacShip.Pos.Y <= 45 then self.EvacShip:GetController():SetState(Controller.MOVE_DOWN, true); if self.EvacShip.Pos.Y <= 15 then self.EvacShip.Pos.Y = self.EvacShip.Pos.Y + 5; end end end --Heal the ship by 1hp every 0.1 seconds, 5hp if it's less than 25 health, Make sure it doesn't drop below 5hp if self.EvacHealTimer:IsPastSimMS(self.EvacHealInterval) then if self.EvacShip.Health < 25 then self.EvacShip.Health = self.EvacShip.Health + 5; elseif self.EvacShip.Health > 25 and self.EvacShip.Health < 100 then self.EvacShip.Health = self.EvacShip.Health + 1; elseif self.EvacShip.Health < 6 then self.EvacShip.Health = 5; end self.EvacHealTimer:Reset(); end --Add an objective point if they're not in the ship. For some reason adding the objective onto the ship itself makes it disappear as soon as someone goes in. if MovableMan:IsActor(self.Scarlett) and not self.EvacShip:HasObject("Brain Scarlett") then self:AddObjectivePoint("Get Scarlett to the evac zone and into the evac ship.", Vector(3110 , 210) , self.PlayerTeam, GameActivity.ARROWUP) end if MovableMan:IsActor(self.Tanya) and not self.EvacShip:HasObject("Brain Tanya") then self:AddObjectivePoint("Get Tanya to the evac zone and into the evac ship.", Vector(3110 , 170) , self.PlayerTeam, GameActivity.ARROWUP) end if MovableMan:IsActor(self.Gus) and not self.EvacShip:HasObject("Brain Gus") then self:AddObjectivePoint("Get Gus to the evac zone and into the evac ship.", Vector(3110 , 130) , self.PlayerTeam, GameActivity.ARROWUP) end end end ----------------------------------------------------------------------------------------- -- Brain selection ----------------------------------------------------------------------------------------- function Towers:DoBrainSelection() for player = 0, self.PlayerCount - 1 do local team = self:GetTeamOfPlayer(player); local brain = self:GetPlayerBrain(player); if not brain or not MovableMan:IsActor(brain) then self:SetPlayerBrain(nil, player); local newBrain = MovableMan:GetUnassignedBrain(team); if newBrain and self.braindead[player] == false then self:SetPlayerBrain(newBrain, player); self.AssignedBrains[player] = newBrain; self:SwitchToActor(newBrain, player, team); end else self:SetObservationTarget(brain.Pos, player) end end end ----------------------------------------------------------------------------------------- -- Check winning and losing conditions ----------------------------------------------------------------------------------------- function Towers:Winner() if MovableMan:IsActor(self.EvacShip) then if self.EvacShip:HasObject("Brain Scarlett") and self.EvacShip:HasObject("Brain Tanya") and self.EvacShip:HasObject("Brain Gus") and self.EvacShip:HasObject("Enemy Intel") then self.EvacShip.AIMode = Actor.AIMODE_RETURN; if (self.EvacShip.Pos.Y < -60 and self.EvacShip.Vel.Y < 0) or self.WinnerTeam == self.PlayerTeam then if self.ActivityState ~= Activity.OVER then self.Scarlett = nil; self.Tanya = nil; self.Gus = nil; self.WinnerTeam = self.PlayerTeam; ActivityMan:EndActivity(); AudioMan:StopAll(); for player = 0, self.PlayerCount - 1 do self.braindead[player] = true; end end for player = 0, self.PlayerCount - 1 do FrameMan:ClearScreenText(player); FrameMan:SetScreenText("You made it, those ronin put up quite a fight but this data will definitely lead us to Jack. \n And when we find him the ronin will come to deeply regret making trouble for us.", player, -1, 15000, true); end self.EvacShip.Pos = Vector(0,0); end end end if not MovableMan:IsActor(self.HeroPod) and not MovableMan:IsActor(self.HeroShip) then if self.TextCount >= 1 and self.TextCount <= 15 then if not MovableMan:IsActor(self.Scarlett) or not MovableMan:IsActor(self.Tanya) or not MovableMan:IsActor(self.Gus) then if self.ActivityState ~= Activity.OVER then self.Scarlett = nil; self.Tanya = nil; self.Gus = nil; self.WinnerTeam = self.CPUTeam; ActivityMan:EndActivity(); AudioMan:StopAll(); for player = 0, self.PlayerCount - 1 do self.braindead[player] = true; end end for player = 0, self.PlayerCount - 1 do FrameMan:ClearScreenText(player); FrameMan:SetScreenText("We can't afford to lose such important S.H.I.E.L.D. members, not to mention the data on Jack.", player, -1, 15000, true); end end end end if self.TextCount > 15 then if MovableMan:IsActor(self.EvacShip) then if not MovableMan:IsActor(self.Scarlett) and not self.EvacShip:HasObject("Brain Scarlett") or not MovableMan:IsActor(self.Tanya) and not self.EvacShip:HasObject("Brain Tanya") or not MovableMan:IsActor(self.Gus) and not self.EvacShip:HasObject("Brain Gus") then if self.ActivityState ~= Activity.OVER then self.Scarlett = nil; self.Tanya = nil; self.Gus = nil; self.EvacShip = nil; self.WinnerTeam = self.CPUTeam; ActivityMan:EndActivity(); AudioMan:StopAll(); for player = 0, self.PlayerCount - 1 do self.braindead[player] = true; end end for player = 0, self.PlayerCount - 1 do FrameMan:ClearScreenText(player); FrameMan:SetScreenText("We can't afford to lose such important S.H.I.E.L.D. members, not to mention the data on Jack.", player, -1, 15000, true); end end elseif not MovableMan:IsActor(self.EvacShip) then if self.ActivityState ~= Activity.OVER then self.Scarlett = nil; self.Tanya = nil; self.Gus = nil; self.EvacShip = nil; self.WinnerTeam = self.CPUTeam; ActivityMan:EndActivity(); AudioMan:StopAll(); for player = 0, self.PlayerCount - 1 do self.braindead[player] = true; end end for player = 0, self.PlayerCount - 1 do FrameMan:ClearScreenText(player); FrameMan:SetScreenText("We can't afford to lose such important S.H.I.E.L.D. members, not to mention the data on Jack.", player, -1, 15000, true); end end end end ----------------------------------------------------------------------------------------- -- That's all folks! -----------------------------------------------------------------------------------------