function WrestlingDefense:SceneTest() --[[ THIS TEST IS DONE AUTOMATICALLY BY THE GAME NOW; IT SCANS THE SCRIPT FOR ANY MENTIONS OF "GetArea" AND TESTS THE SCENES FOR HAVING THOSE USED AREAS DEFINED! -- See if the required areas are present in the test scene if not (TestScene:HasArea("LZ Team 1") and TestScene:HasArea("LZ Team 2")) then -- If the test scene failed the compatibility test, invalidate it TestScene = nil; end --]] end function WrestlingDefense:StartActivity() print("START! -- WrestlingDefense:StartActivity()!"); self.playertally = 0; self.playerlist = {}; for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do if self:PlayerActive(player) and self:PlayerHuman(player) then self.playerlist[player + 1] = true; self.playertally = self.playertally + 1; -- Check if we already have a brain assigned if not self:GetPlayerBrain(player) then local foundBrain = MovableMan:GetUnassignedBrain(self:GetTeamOfPlayer(player)); -- If we can't find an unassigned brain in the scene to give each player, then force to go into editing mode to place one if not foundBrain then self.ActivityState = Activity.EDITING; AudioMan:ClearMusicQueue(); AudioMan:PlayMusic("Base.rte/Music/dBSoundworks/ccambient4.ogg", -1, -1); else -- Set the found brain to be the selected actor at start self:SetPlayerBrain(foundBrain, player); self:SwitchToActor(foundBrain, player, self:GetTeamOfPlayer(player)); self:SetLandingZone(self:GetPlayerBrain(player).Pos, player); -- Set the observation target to the brain, so that if/when it dies, the view flies to it in observation mode self:SetObservationTarget(self:GetPlayerBrain(player).Pos, player); end end end end self.WList = { "Grenade Launcher", "Blaster", "Nailgun", "Pistol", "Sniper Rifle", "Heavy Sniper Rifle", "Gatling Gun", "Flamer", "Napalm Flamer", "Spike Launcher", "Flak Cannon", "Auto Pistol", "Shotgun", "Auto Shotgun", "Mauler Shotgun", "Bazooka", "AK-47", "YAK4700", "TommyGun", "Uzi", "M16", "Shortgun", "Spas12", "Spaz1200", "Rifle Long", "Desert Eagle", "Glock", "Luger", "Peacemaker" } self.AList = { "Mia", "Dafred", "Dimitri", "Gordon", "Brutus", "Sandra", "Soldier Light", "Soldier Heavy", "Browncoat Light", "Browncoat Heavy" }; self.ESpawnTimer = Timer(); self.LZ = SceneMan.Scene:GetArea("LZ Team 1"); self.EnemyLZ = SceneMan.Scene:GetArea("LZ Team 2"); if self.Difficulty <= GameActivity.CAKEDIFFICULTY then self:SetTeamFunds(10000, Activity.TEAM_1); self:SetTeamFunds(10000, Activity.TEAM_2); self:SetTeamFunds(10000, Activity.TEAM_3); self:SetTeamFunds(10000, Activity.TEAM_4); self.BaseSpawnTime = 12000; self.RandomSpawnTime = 8000; elseif self.Difficulty <= GameActivity.EASYDIFFICULTY then self:SetTeamFunds(8000, Activity.TEAM_1); self:SetTeamFunds(8000, Activity.TEAM_2); self:SetTeamFunds(8000, Activity.TEAM_3); self:SetTeamFunds(8000, Activity.TEAM_4); self.BaseSpawnTime = 11000; self.RandomSpawnTime = 7000; elseif self.Difficulty <= GameActivity.MEDIUMDIFFICULTY then self:SetTeamFunds(6000, Activity.TEAM_1); self:SetTeamFunds(6000, Activity.TEAM_2); self:SetTeamFunds(6000, Activity.TEAM_3); self:SetTeamFunds(6000, Activity.TEAM_4); self.BaseSpawnTime = 10000; self.RandomSpawnTime = 6000; elseif self.Difficulty <= GameActivity.HARDDIFFICULTY then self:SetTeamFunds(4000, Activity.TEAM_1); self:SetTeamFunds(4000, Activity.TEAM_2); self:SetTeamFunds(4000, Activity.TEAM_3); self:SetTeamFunds(4000, Activity.TEAM_4); self.BaseSpawnTime = 9000; self.RandomSpawnTime = 5000; elseif self.Difficulty <= GameActivity.NUTSDIFFICULTY then self:SetTeamFunds(2000, Activity.TEAM_1); self:SetTeamFunds(2000, Activity.TEAM_2); self:SetTeamFunds(2000, Activity.TEAM_3); self:SetTeamFunds(2000, Activity.TEAM_4); self.BaseSpawnTime = 8000; self.RandomSpawnTime = 4500; elseif self.Difficulty <= GameActivity.MAXDIFFICULTY then self:SetTeamFunds(1000, Activity.TEAM_1); self:SetTeamFunds(1000, Activity.TEAM_2); self:SetTeamFunds(1000, Activity.TEAM_3); self:SetTeamFunds(1000, Activity.TEAM_4); self.BaseSpawnTime = 7000; self.RandomSpawnTime = 4000; end self.StartTimer = Timer(); self.TimeLeft = self.BaseSpawnTime + math.random(self.RandomSpawnTime); end function WrestlingDefense:PauseActivity(pause) print("PAUSE! -- WrestlingDefense:PauseActivity()!"); end function WrestlingDefense:EndActivity() print("END! -- WrestlingDefense:EndActivity()!"); end function WrestlingDefense:UpdateActivity() if self.ActivityState ~= Activity.OVER and self.ActivityState ~= Activity.EDITING then MovableMan:OpenAllDoors(false,Activity.NOTEAM) -- Clear all objective markers, they get re-added each frame self:ClearObjectivePoints(); for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do if self:PlayerActive(player) and self:PlayerHuman(player) then if not self.StartTimer:IsPastSimMS(3000) then FrameMan:SetScreenText("Destroy the enemy brain(s)!", player, 333, 5000, true); end -- The current player's team local team = self:GetTeamOfPlayer(player); -- Check if any player's brain is dead if not MovableMan:IsActor(self:GetPlayerBrain(player)) then self:SetPlayerBrain(nil, player); self:ResetMessageTimer(player); FrameMan:ClearScreenText(player); FrameMan:SetScreenText("Your brain has been destroyed!", player, 333, -1, false); if self.playerlist[player + 1] == true then self.playerlist[player + 1] = false; self.playertally = self.playertally - 1; end else --Add objective points self:AddObjectivePoint("Protect!", self:GetPlayerBrain(player).AboveHUDPos, team, GameActivity.ARROWDOWN); for player2 = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do if player2 ~= player and self:PlayerActive(player2) and self:PlayerHuman(player2) and MovableMan:IsActor(self:GetPlayerBrain(player2)) then local team2 = self:GetTeamOfPlayer(player2); self:AddObjectivePoint("Destroy!", self:GetPlayerBrain(player2).AboveHUDPos, team, GameActivity.ARROWDOWN); end end end end end --Spawn the AI. if self.CPUTeam == nil then self.CPUTeam = Activity.NOTEAM; for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do if self:PlayerActive(player) and not(self:PlayerHuman(player)) then local team = self:GetTeamOfPlayer(player); self.CPUTeam = team; end end end if self.CPUTeam ~= Activity.NOTEAM and self.ESpawnTimer:LeftTillSimMS(self.TimeLeft) <= 0 and MovableMan:GetMOIDCount() <= 210 then local actor = {}; for x = 0, math.ceil(math.random(3)) do local y = math.random(); if y > 0.05 then actor[x] = CreateAHuman(self.AList[math.random(#self.AList)]); actor[x].Team = self.CPUTeam; actor[x].AIMode = Actor.AIMODE_BRAINHUNT; --actor[x]:AddInventoryItem(CreateHDFirearm(self.WList[math.random(#self.WList)])); --actor[x]:AddInventoryItem(CreateHDFirearm("Medium Digger")); else actor[x] = CreateACrab("Dreadnought"); actor[x].Team = self.CPUTeam; actor[x].AIMode = Actor.AIMODE_BRAINHUNT; end end local ship = nil; local z = math.random(); if z > 0.90 then ship = CreateACRocket("Drop Crate","Dummy.rte"); elseif z > 0.80 then ship = CreateACRocket("Rocklet","Dummy.rte"); elseif z > 0.60 then ship = CreateACDropShip("Drop Ship","Dummy.rte"); elseif z > 0.40 then ship = CreateACDropShip("Drop Ship MK1","Coalition.rte"); elseif z > 0.20 then ship = CreateACRocket("Rocket MK2","Coalition.rte"); else ship = CreateACRocket("Rocket MK1","Coalition.rte"); end for n = 0, #actor do ship:AddInventoryItem(actor[n]); end ship.Team = self.CPUTeam; local w = math.random(); if w > 0.5 then ship.Pos = Vector(self.EnemyLZ:GetRandomPoint().X,-50); else ship.Pos = Vector(self.LZ:GetRandomPoint().X,-50); end MovableMan:AddActor(ship); self.ESpawnTimer:Reset(); self.TimeLeft = self.BaseSpawnTime + math.random(self.RandomSpawnTime); end --Win/Lose Conditions if self.CPUTeam == Activity.NOTEAM then if self.playertally == 1 then for i = 1, #self.playerlist do if self.playerlist[i] == true then self.WinnerTeam = i - 1; ActivityMan:EndActivity(); end end end else if self.playertally == 0 then self.WinnerTeam = self.CPUTeam; ActivityMan:EndActivity(); end end else MovableMan:OpenAllDoors(true,Activity.NOTEAM) self.StartTimer:Reset(); end end