Guest User

Untitled

a guest
Apr 4th, 2011
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.96 KB | None | 0 0
  1. function OneManArmy:SceneTest()
  2. --[[ 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!
  3. -- See if the required areas are present in the test scene
  4. if not (TestScene:HasArea("LZ Team 1") and TestScene:HasArea("LZ Team 2")) then
  5. -- If the test scene failed the compatibility test, invalidate it
  6. TestScene = nil;
  7. end
  8. --]]
  9. end
  10.  
  11. function OneManArmy:StartActivity()
  12. print("START! -- OneManArmy:StartActivity()!");
  13. -- Check if we already have a brain assigned
  14. if not self:GetPlayerBrain(Activity.PLAYER_1) then
  15. local foundBrain = MovableMan:GetUnassignedBrain(self:GetTeamOfPlayer(Activity.PLAYER_1));
  16. -- 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
  17. if not foundBrain then
  18. foundBrain = CreateAHuman("Sanaora Scout");
  19. foundBrain:AddInventoryItem(CreateHDFirearm("Starcommand/Particle Disintegrator"));
  20. foundBrain:AddInventoryItem(CreateHDFirearm("Starcommand/Particle Cannon"));
  21. foundBrain.Pos = SceneMan:MovePointToGround(Vector(math.random(0, SceneMan.SceneWidth), 0), 0, 0) + Vector(0, -50);
  22. foundBrain.Team = self:GetTeamOfPlayer(Activity.PLAYER_1);
  23. MovableMan:AddActor(foundBrain);
  24. -- Set the found brain to be the selected actor at start
  25. self:SetPlayerBrain(foundBrain, Activity.PLAYER_1);
  26. self:SwitchToActor(foundBrain, Activity.PLAYER_1, self:GetTeamOfPlayer(Activity.PLAYER_1));
  27. self:SetLandingZone(self:GetPlayerBrain(Activity.PLAYER_1).Pos, Activity.PLAYER_1);
  28. -- Set the observation target to the brain, so that if/when it dies, the view flies to it in observation mode
  29. self:SetObservationTarget(self:GetPlayerBrain(Activity.PLAYER_1).Pos, Activity.PLAYER_1);
  30. else
  31. -- Set the found brain to be the selected actor at start
  32. self:SetPlayerBrain(foundBrain, Activity.PLAYER_1);
  33. self:SwitchToActor(foundBrain, Activity.PLAYER_1, self:GetTeamOfPlayer(Activity.PLAYER_1));
  34. self:SetLandingZone(self:GetPlayerBrain(Activity.PLAYER_1).Pos, Activity.PLAYER_1);
  35. -- Set the observation target to the brain, so that if/when it dies, the view flies to it in observation mode
  36. self:SetObservationTarget(self:GetPlayerBrain(Activity.PLAYER_1).Pos, Activity.PLAYER_1);
  37. end
  38. end
  39.  
  40.  
  41. if not self:GetPlayerBrain(Activity.PLAYER_2) then
  42. local foundBrain = MovableMan:GetUnassignedBrain(self:GetTeamOfPlayer(Activity.PLAYER_2));
  43. -- 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
  44. if not foundBrain then
  45. foundBrain = CreateAHuman("Ghost");
  46. foundBrain:AddInventoryItem(CreateHDFirearm("The Void/RPG"));
  47. foundBrain:AddInventoryItem(CreateHDFirearm("The Void/Burst Flamer"));
  48. foundBrain.Pos = SceneMan:MovePointToGround(Vector(math.random(0, SceneMan.SceneWidth), 0), 0, 0) + Vector(0, -50);
  49. foundBrain.Team = self:GetTeamOfPlayer(Activity.PLAYER_2);
  50. MovableMan:AddActor(foundBrain);
  51. -- Set the found brain to be the selected actor at start
  52. self:SetPlayerBrain(foundBrain, Activity.PLAYER_2);
  53. self:SwitchToActor(foundBrain, Activity.PLAYER_2, self:GetTeamOfPlayer(Activity.PLAYER_2));
  54. self:SetLandingZone(self:GetPlayerBrain(Activity.PLAYER_2).Pos, Activity.PLAYER_2);
  55. -- Set the observation target to the brain, so that if/when it dies, the view flies to it in observation mode
  56. self:SetObservationTarget(self:GetPlayerBrain(Activity.PLAYER_2).Pos, Activity.PLAYER_2);
  57. else
  58. -- Set the found brain to be the selected actor at start
  59. self:SetPlayerBrain(foundBrain, Activity.PLAYER_2);
  60. self:SwitchToActor(foundBrain, Activity.PLAYER_2, self:GetTeamOfPlayer(Activity.PLAYER_2));
  61. self:SetLandingZone(self:GetPlayerBrain(Activity.PLAYER_2).Pos, Activity.PLAYER_2);
  62. -- Set the observation target to the brain, so that if/when it dies, the view flies to it in observation mode
  63. self:SetObservationTarget(self:GetPlayerBrain(Activity.PLAYER_2).Pos, Activity.PLAYER_2);
  64. end
  65. end
  66.  
  67. 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" };
  68. self.AList = { "Mia", "Dafred", "Dimitri", "Gordon", "Brutus", "Sandra", "Soldier Light", "Soldier Heavy", "Browncoat Light", "Browncoat Heavy" };
  69. self.ESpawnTimer = Timer();
  70. self.LZ = SceneMan.Scene:GetArea("LZ Team 1");
  71. self.EnemyLZ = SceneMan.Scene:GetArea("LZ All");
  72. self.SurvivalTimer = Timer();
  73.  
  74. if self.Difficulty <= GameActivity.CAKEDIFFICULTY then
  75. self.TimeLimit = 65000;
  76. self.timeDisplay = "one minute";
  77. self.BaseSpawnTime = 6000;
  78. self.RandomSpawnTime = 8000;
  79. elseif self.Difficulty <= GameActivity.EASYDIFFICULTY then
  80. self.TimeLimit = 95000;
  81. self.timeDisplay = "one minute and thirty seconds";
  82. self.BaseSpawnTime = 5500;
  83. self.RandomSpawnTime = 7000;
  84. elseif self.Difficulty <= GameActivity.MEDIUMDIFFICULTY then
  85. self.TimeLimit = 125000;
  86. self.timeDisplay = "two minutes";
  87. self.BaseSpawnTime = 5000;
  88. self.RandomSpawnTime = 6000;
  89. elseif self.Difficulty <= GameActivity.HARDDIFFICULTY then
  90. self.TimeLimit = 185000;
  91. self.timeDisplay = "three minutes";
  92. self.BaseSpawnTime = 4500;
  93. self.RandomSpawnTime = 5000;
  94. elseif self.Difficulty <= GameActivity.NUTSDIFFICULTY then
  95. self.TimeLimit = 305000;
  96. self.timeDisplay = "five minutes";
  97. self.BaseSpawnTime = 4000;
  98. self.RandomSpawnTime = 4500;
  99. elseif self.Difficulty <= GameActivity.MAXDIFFICULTY then
  100. self.TimeLimit = 105000;
  101. self.timeDisplay = "ten minutes";
  102. self.BaseSpawnTime = 3500;
  103. self.RandomSpawnTime = 4000;
  104. end
  105.  
  106. self.StartTimer = Timer();
  107. ActivityMan:GetActivity():SetTeamFunds(0,0);
  108.  
  109. self.TimeLeft = self.BaseSpawnTime + math.random(self.RandomSpawnTime);
  110. end
  111.  
  112. function OneManArmy:PauseActivity(pause)
  113. print("PAUSE! -- OneManArmy:PauseActivity()!");
  114. end
  115.  
  116. function OneManArmy:EndActivity()
  117. print("END! -- OneManArmy:EndActivity()!");
  118.  
  119. end
  120.  
  121. function OneManArmy:UpdateActivity()
  122. if self.ActivityState ~= Activity.OVER then
  123. ActivityMan:GetActivity():SetTeamFunds(0,0);
  124. for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
  125. if self:PlayerActive(player) and self:PlayerHuman(player) then
  126. --Display messages.
  127. if self.StartTimer:IsPastSimMS(3000) then
  128. FrameMan:SetScreenText(math.floor(self.SurvivalTimer:LeftTillSimMS(self.TimeLimit) / 1000) .. " seconds left", player, 0, 1000, false);
  129. else
  130. FrameMan:SetScreenText("Survive for " .. self.timeDisplay .. "!", Activity.PLAYER_1, 333, 5000, true);
  131. end
  132.  
  133. -- The current player's team
  134. local team = self:GetTeamOfPlayer(player);
  135. -- Check if any player's brain is dead
  136. if not MovableMan:IsActor(self:GetPlayerBrain(player)) then
  137. self:SetPlayerBrain(nil, player);
  138. self:ResetMessageTimer(player);
  139. FrameMan:ClearScreenText(player);
  140. FrameMan:SetScreenText("Your brain has been destroyed!", player, 333, -1, false);
  141. -- Now see if all brains of self player's team are dead, and if so, end the game
  142. if not MovableMan:GetClosestBrainActor(team) then
  143. self.WinnerTeam = self:OtherTeam(team);
  144. ActivityMan:EndActivity();
  145. end
  146. end
  147.  
  148. --Check if the player has won.
  149. if self.SurvivalTimer:IsPastSimMS(self.TimeLimit) then
  150. self:ResetMessageTimer(player);
  151. FrameMan:ClearScreenText(player);
  152. FrameMan:SetScreenText("You survived!", player, 333, -1, false);
  153.  
  154. self.WinnerTeam = Activity.TEAM_1;
  155.  
  156. --Kill all enemies.
  157. for actor in MovableMan.Actors do
  158. if actor.Team ~= self.WinnerTeam then
  159. actor.Health = 0;
  160. end
  161. end
  162.  
  163. ActivityMan:EndActivity();
  164. end
  165. end
  166. end
  167.  
  168. --Spawn the AI.
  169. if self.ESpawnTimer:LeftTillSimMS(self.TimeLeft) <= 0 and MovableMan:GetMOIDCount() <= 210 then
  170. local actor = {};
  171. for x = 0, math.ceil(math.random(3)) do
  172. local y = math.random();
  173. if y > 0.05 then
  174. actor[x] = CreateAHuman(self.AList[math.random(#self.AList)]);
  175. actor[x].Team = 1;
  176. actor[x].AIMode = Actor.AIMODE_BRAINHUNT;
  177. actor[x]:AddInventoryItem(CreateHDFirearm(self.WList[math.random(#self.WList)]));
  178. actor[x]:AddInventoryItem(CreateHDFirearm("Medium Digger"));
  179. else
  180. actor[x] = CreateACrab("Dreadnought");
  181. actor[x].Team = 1;
  182. actor[x].AIMode = Actor.AIMODE_BRAINHUNT;
  183. end
  184. end
  185. local ship = nil;
  186. local z = math.random();
  187. if z > 0.90 then
  188. ship = CreateACRocket("Drop Crate","Dummy.rte");
  189. elseif z > 0.80 then
  190. ship = CreateACRocket("Rocklet","Dummy.rte");
  191. elseif z > 0.60 then
  192. ship = CreateACDropShip("Drop Ship","Dummy.rte");
  193. elseif z > 0.40 then
  194. ship = CreateACDropShip("Drop Ship MK1","Coalition.rte");
  195. elseif z > 0.20 then
  196. ship = CreateACRocket("Rocket MK2","Coalition.rte");
  197. else
  198. ship = CreateACRocket("Rocket MK1","Coalition.rte");
  199. end
  200. for n = 0, #actor do
  201. ship:AddInventoryItem(actor[n]);
  202. end
  203. ship.Team = 1;
  204. local w = math.random();
  205. if w > 0.5 then
  206. ship.Pos = Vector(self.EnemyLZ:GetRandomPoint().X,-50);
  207. else
  208. ship.Pos = Vector(self.LZ:GetRandomPoint().X,-50);
  209. end
  210. MovableMan:AddActor(ship);
  211. self.ESpawnTimer:Reset();
  212. self.TimeLeft = self.BaseSpawnTime + math.random(self.RandomSpawnTime);
  213. end
  214. end
  215. end
Advertisement
Add Comment
Please, Sign In to add comment