Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function OneManArmy: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 OneManArmy:StartActivity()
- print("START! -- OneManArmy:StartActivity()!");
- -- Check if we already have a brain assigned
- if not self:GetPlayerBrain(Activity.PLAYER_1) then
- local foundBrain = MovableMan:GetUnassignedBrain(self:GetTeamOfPlayer(Activity.PLAYER_1));
- -- If we can't find an unassigned brain in the scene to give the player, then force to go into editing mode to place one
- if not foundBrain then
- foundBrain = CreateAHuman("Sanaora Scout");
- foundBrain:AddInventoryItem(CreateHDFirearm("Starcommand/Particle Disintegrator"));
- foundBrain:AddInventoryItem(CreateHDFirearm("Starcommand/Particle Cannon"));
- foundBrain.Pos = SceneMan:MovePointToGround(Vector(math.random(0, SceneMan.SceneWidth), 0), 0, 0) + Vector(0, -50);
- foundBrain.Team = self:GetTeamOfPlayer(Activity.PLAYER_1);
- MovableMan:AddActor(foundBrain);
- -- Set the found brain to be the selected actor at start
- self:SetPlayerBrain(foundBrain, Activity.PLAYER_1);
- self:SwitchToActor(foundBrain, Activity.PLAYER_1, self:GetTeamOfPlayer(Activity.PLAYER_1));
- self:SetLandingZone(self:GetPlayerBrain(Activity.PLAYER_1).Pos, Activity.PLAYER_1);
- -- 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(Activity.PLAYER_1).Pos, Activity.PLAYER_1);
- else
- -- Set the found brain to be the selected actor at start
- self:SetPlayerBrain(foundBrain, Activity.PLAYER_1);
- self:SwitchToActor(foundBrain, Activity.PLAYER_1, self:GetTeamOfPlayer(Activity.PLAYER_1));
- self:SetLandingZone(self:GetPlayerBrain(Activity.PLAYER_1).Pos, Activity.PLAYER_1);
- -- 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(Activity.PLAYER_1).Pos, Activity.PLAYER_1);
- end
- end
- if not self:GetPlayerBrain(Activity.PLAYER_2) then
- local foundBrain = MovableMan:GetUnassignedBrain(self:GetTeamOfPlayer(Activity.PLAYER_2));
- -- If we can't find an unassigned brain in the scene to give the player, then force to go into editing mode to place one
- if not foundBrain then
- foundBrain = CreateAHuman("Ghost");
- foundBrain:AddInventoryItem(CreateHDFirearm("The Void/RPG"));
- foundBrain:AddInventoryItem(CreateHDFirearm("The Void/Burst Flamer"));
- foundBrain.Pos = SceneMan:MovePointToGround(Vector(math.random(0, SceneMan.SceneWidth), 0), 0, 0) + Vector(0, -50);
- foundBrain.Team = self:GetTeamOfPlayer(Activity.PLAYER_2);
- MovableMan:AddActor(foundBrain);
- -- Set the found brain to be the selected actor at start
- self:SetPlayerBrain(foundBrain, Activity.PLAYER_2);
- self:SwitchToActor(foundBrain, Activity.PLAYER_2, self:GetTeamOfPlayer(Activity.PLAYER_2));
- self:SetLandingZone(self:GetPlayerBrain(Activity.PLAYER_2).Pos, Activity.PLAYER_2);
- -- 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(Activity.PLAYER_2).Pos, Activity.PLAYER_2);
- else
- -- Set the found brain to be the selected actor at start
- self:SetPlayerBrain(foundBrain, Activity.PLAYER_2);
- self:SwitchToActor(foundBrain, Activity.PLAYER_2, self:GetTeamOfPlayer(Activity.PLAYER_2));
- self:SetLandingZone(self:GetPlayerBrain(Activity.PLAYER_2).Pos, Activity.PLAYER_2);
- -- 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(Activity.PLAYER_2).Pos, Activity.PLAYER_2);
- 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", "YAK47", "YAK4700", "TommyGun", "Uzi", "M16", "Shortgun", "Spaz12", "Spaz1200", "Rifle Long", "Desert Eagle", "Glock", "HAK 20", "Luger", "Peacemaker", "Lady Pistol" };
- 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 All");
- self.SurvivalTimer = Timer();
- if self.Difficulty <= GameActivity.CAKEDIFFICULTY then
- self.TimeLimit = 65000;
- self.timeDisplay = "one minute";
- self.BaseSpawnTime = 6000;
- self.RandomSpawnTime = 8000;
- elseif self.Difficulty <= GameActivity.EASYDIFFICULTY then
- self.TimeLimit = 95000;
- self.timeDisplay = "one minute and thirty seconds";
- self.BaseSpawnTime = 5500;
- self.RandomSpawnTime = 7000;
- elseif self.Difficulty <= GameActivity.MEDIUMDIFFICULTY then
- self.TimeLimit = 125000;
- self.timeDisplay = "two minutes";
- self.BaseSpawnTime = 5000;
- self.RandomSpawnTime = 6000;
- elseif self.Difficulty <= GameActivity.HARDDIFFICULTY then
- self.TimeLimit = 185000;
- self.timeDisplay = "three minutes";
- self.BaseSpawnTime = 4500;
- self.RandomSpawnTime = 5000;
- elseif self.Difficulty <= GameActivity.NUTSDIFFICULTY then
- self.TimeLimit = 305000;
- self.timeDisplay = "five minutes";
- self.BaseSpawnTime = 4000;
- self.RandomSpawnTime = 4500;
- elseif self.Difficulty <= GameActivity.MAXDIFFICULTY then
- self.TimeLimit = 105000;
- self.timeDisplay = "ten minutes";
- self.BaseSpawnTime = 3500;
- self.RandomSpawnTime = 4000;
- end
- self.StartTimer = Timer();
- ActivityMan:GetActivity():SetTeamFunds(0,0);
- self.TimeLeft = self.BaseSpawnTime + math.random(self.RandomSpawnTime);
- end
- function OneManArmy:PauseActivity(pause)
- print("PAUSE! -- OneManArmy:PauseActivity()!");
- end
- function OneManArmy:EndActivity()
- print("END! -- OneManArmy:EndActivity()!");
- end
- function OneManArmy:UpdateActivity()
- if self.ActivityState ~= Activity.OVER then
- ActivityMan:GetActivity():SetTeamFunds(0,0);
- for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
- if self:PlayerActive(player) and self:PlayerHuman(player) then
- --Display messages.
- if self.StartTimer:IsPastSimMS(3000) then
- FrameMan:SetScreenText(math.floor(self.SurvivalTimer:LeftTillSimMS(self.TimeLimit) / 1000) .. " seconds left", player, 0, 1000, false);
- else
- FrameMan:SetScreenText("Survive for " .. self.timeDisplay .. "!", Activity.PLAYER_1, 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);
- -- Now see if all brains of self player's team are dead, and if so, end the game
- if not MovableMan:GetClosestBrainActor(team) then
- self.WinnerTeam = self:OtherTeam(team);
- ActivityMan:EndActivity();
- end
- end
- --Check if the player has won.
- if self.SurvivalTimer:IsPastSimMS(self.TimeLimit) then
- self:ResetMessageTimer(player);
- FrameMan:ClearScreenText(player);
- FrameMan:SetScreenText("You survived!", player, 333, -1, false);
- self.WinnerTeam = Activity.TEAM_1;
- --Kill all enemies.
- for actor in MovableMan.Actors do
- if actor.Team ~= self.WinnerTeam then
- actor.Health = 0;
- end
- end
- ActivityMan:EndActivity();
- end
- end
- end
- --Spawn the AI.
- if 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 = 1;
- 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 = 1;
- 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 = 1;
- 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
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment