@@ -3,14 +3,14 @@ dofile("Base.rte/Constants.lua")
3
3
function OneManArmy :StartActivity ()
4
4
5
5
self .BuyMenuEnabled = false ;
6
- -- Brain strength multiplier
7
- self .multiplier = math.ceil (11 - (self .Difficulty * 0.1 )); -- Med = 6, Max = 11, Min = 1
6
+ -- Brain strength multiplier
7
+ self .multiplier = math.ceil (11 - (self .Difficulty * 0.1 )); -- Med = 6, Max = 11, Min = 1
8
8
9
9
local primaryGroup = " Weapons - Heavy" ;
10
10
local secondaryGroup = " Weapons - Light" ;
11
- -- Tertiary weapon is always a grenade
11
+ -- Tertiary weapon is always a grenade
12
12
local actorGroup = " Actors - Heavy" ;
13
- -- Default actors if no tech is chosen
13
+ -- Default actors if no tech is chosen
14
14
local defaultActor = (" Soldier Heavy" );
15
15
local defaultPrimary = (" Coalition/Assault Rifle" );
16
16
local defaultSecondary = (" Coalition/Auto Pistol" );
@@ -55,30 +55,30 @@ function OneManArmy:StartActivity()
55
55
secondaryGroup = " Weapons - Secondary" ;
56
56
actorGroup = " Actors - Light" ;
57
57
end
58
- -- Destroy all doors for this Activity
58
+ -- Destroy all doors for this Activity - the enemy is not equipped to deal with them
59
59
MovableMan :OpenAllDoors (true , - 1 );
60
60
for actor in MovableMan .AddedActors do
61
61
if actor .ClassName == " ADoor" then
62
62
actor .ToSettle = true ;
63
63
actor :GibThis ();
64
64
end
65
65
end
66
- -- Check if we already have a brain assigned
66
+ -- Check if we already have a brain assigned
67
67
for player = Activity .PLAYER_1 , Activity .MAXPLAYERCOUNT - 1 do
68
68
if self :PlayerActive (player ) and self :PlayerHuman (player ) then
69
69
if not self :GetPlayerBrain (player ) then
70
70
local team = self :GetTeamOfPlayer (player );
71
71
local foundBrain = MovableMan :GetUnassignedBrain (team );
72
- -- If we can't find an unassigned brain in the scene to give the player, create one
72
+ -- If we can't find an unassigned brain in the scene to give the player, create one
73
73
if not foundBrain then
74
74
local tech = PresetMan :GetModuleID (self :GetTeamTech (team ));
75
75
foundBrain = CreateAHuman (defaultActor );
76
- -- If a faction was chosen, pick the first item from faction listing
76
+ -- If a faction was chosen, pick the first item from faction listing
77
77
if tech ~= - 1 then
78
78
local module = PresetMan :GetDataModule (tech );
79
79
local primaryWeapon , secondaryWeapon , throwable , actor ;
80
80
for entity in module .Presets do
81
- local picked ; -- Prevent duplicates
81
+ local picked ; -- Prevent duplicates
82
82
if not primaryWeapon and entity .ClassName == " HDFirearm" then
83
83
if ToMOSRotating (entity ):HasObjectInGroup (primaryGroup ) then
84
84
primaryWeapon = CreateHDFirearm (entity :GetModuleAndPresetName ());
@@ -115,7 +115,7 @@ function OneManArmy:StartActivity()
115
115
foundBrain :AddInventoryItem (weapons [i ]);
116
116
end
117
117
end
118
- else -- If no tech selected, use default items
118
+ else -- If no tech selected, use default items
119
119
local weapons = {defaultPrimary , defaultSecondary };
120
120
for i = 1 , # weapons do
121
121
local item = CreateHDFirearm (weapons [i ]);
@@ -130,13 +130,13 @@ function OneManArmy:StartActivity()
130
130
foundBrain :AddInventoryItem (item );
131
131
end
132
132
end
133
- -- Reinforce the brain actor
133
+ -- Reinforce the brain actor
134
134
local parts = {foundBrain , foundBrain .Head , foundBrain .FGArm , foundBrain .BGArm , foundBrain .FGLeg , foundBrain .BGLeg };
135
135
for i = 1 , # parts do
136
136
local part = parts [i ];
137
137
if part then
138
138
part .GibWoundLimit = math.ceil (part .GibWoundLimit * self .multiplier );
139
- part .DamageMultiplier = part .DamageMultiplier / self .multiplier ;
139
+ part .DamageMultiplier = part .DamageMultiplier / self .multiplier ;
140
140
if IsAttachable (part ) then
141
141
ToAttachable (part ).JointStrength = ToAttachable (part ).JointStrength * self .multiplier ;
142
142
else
@@ -153,61 +153,61 @@ function OneManArmy:StartActivity()
153
153
if medikit then
154
154
foundBrain :AddInventoryItem (medikit );
155
155
end
156
- -- Reinforce FGArm so that we don't lose it
157
- -- No FGArm = no weapons = no gameplay
156
+ -- Reinforce FGArm so that we don't lose it
157
+ -- No FGArm = no weapons = no gameplay
158
158
foundBrain .FGArm .GibWoundLimit = 999999 ;
159
159
foundBrain .FGArm .JointStrength = 999999 ;
160
160
161
161
foundBrain .Pos = SceneMan :MovePointToGround (Vector (math.random (0 , SceneMan .SceneWidth ), 0 ), 0 , 0 ) + Vector (0 , - foundBrain .Radius );
162
- foundBrain .Team = self :GetTeamOfPlayer (player )
163
- MovableMan :AddActor (foundBrain )
164
- -- Set the found brain to be the selected actor at start
165
- self :SetPlayerBrain (foundBrain , player )
166
- self :SwitchToActor (foundBrain , player , self :GetTeamOfPlayer (player ))
167
- self :SetLandingZone (self :GetPlayerBrain (player ).Pos , player )
168
- -- Set the observation target to the brain, so that if/when it dies, the view flies to it in observation mode
169
- self :SetObservationTarget (self :GetPlayerBrain (player ).Pos , player )
162
+ foundBrain .Team = self :GetTeamOfPlayer (player );
163
+ MovableMan :AddActor (foundBrain );
164
+ -- Set the found brain to be the selected actor at start
165
+ self :SetPlayerBrain (foundBrain , player );
166
+ self :SwitchToActor (foundBrain , player , self :GetTeamOfPlayer (player ));
167
+ self :SetLandingZone (self :GetPlayerBrain (player ).Pos , player );
168
+ -- Set the observation target to the brain, so that if/when it dies, the view flies to it in observation mode
169
+ self :SetObservationTarget (self :GetPlayerBrain (player ).Pos , player );
170
170
else
171
- -- Set the found brain to be the selected actor at start
172
- self :SetPlayerBrain (foundBrain , player )
173
- self :SwitchToActor (foundBrain , player , self :GetTeamOfPlayer (player ))
174
- self :SetLandingZone (self :GetPlayerBrain (player ).Pos , player )
175
- -- Set the observation target to the brain, so that if/when it dies, the view flies to it in observation mode
176
- self :SetObservationTarget (self :GetPlayerBrain (player ).Pos , player )
171
+ -- Set the found brain to be the selected actor at start
172
+ self :SetPlayerBrain (foundBrain , player );
173
+ self :SwitchToActor (foundBrain , player , self :GetTeamOfPlayer (player ));
174
+ self :SetLandingZone (self :GetPlayerBrain (player ).Pos , player );
175
+ -- Set the observation target to the brain, so that if/when it dies, the view flies to it in observation mode
176
+ self :SetObservationTarget (self :GetPlayerBrain (player ).Pos , player );
177
177
end
178
178
end
179
179
end
180
180
end
181
181
182
- -- Select a tech for the CPU player
182
+ -- Select a tech for the CPU player
183
183
self .CPUTechName = self :GetTeamTech (self .CPUTeam );
184
184
self .ESpawnTimer = Timer ();
185
- self .LZ = SceneMan .Scene :GetArea (" LZ Team 1" )
186
- self .EnemyLZ = SceneMan .Scene :GetArea (" LZ All" )
187
- self .SurvivalTimer = Timer ()
185
+ self .LZ = SceneMan .Scene :GetArea (" LZ Team 1" );
186
+ self .EnemyLZ = SceneMan .Scene :GetArea (" LZ All" );
187
+ self .SurvivalTimer = Timer ();
188
188
189
- self .StartTimer = Timer ()
190
- ActivityMan :GetActivity ():SetTeamFunds (0 ,Activity .TEAM_1 )
191
- ActivityMan :GetActivity ():SetTeamFunds (0 ,Activity .TEAM_2 )
192
- ActivityMan :GetActivity ():SetTeamFunds (0 ,Activity .TEAM_3 )
193
- ActivityMan :GetActivity ():SetTeamFunds (0 ,Activity .TEAM_4 )
189
+ self .StartTimer = Timer ();
190
+ ActivityMan :GetActivity ():SetTeamFunds (0 , Activity .TEAM_1 );
191
+ ActivityMan :GetActivity ():SetTeamFunds (0 , Activity .TEAM_2 );
192
+ ActivityMan :GetActivity ():SetTeamFunds (0 , Activity .TEAM_3 );
193
+ ActivityMan :GetActivity ():SetTeamFunds (0 , Activity .TEAM_4 );
194
194
195
- -- CPU Funds are unlimited
195
+ -- CPU Funds are " unlimited"
196
196
self :SetTeamFunds (1000000 , self .CPUTeam );
197
197
198
- self .TimeLeft = 500
198
+ self .TimeLeft = 500 ;
199
199
end
200
200
201
201
202
202
function OneManArmy :EndActivity ()
203
- -- Play sad music if no humans are left
203
+ -- Play sad music if no humans are left
204
204
if self :HumanBrainCount () == 0 then
205
205
AudioMan :ClearMusicQueue ();
206
206
AudioMan :PlayMusic (" Base.rte/Music/dBSoundworks/udiedfinal.ogg" , 2 , - 1.0 );
207
207
AudioMan :QueueSilence (10 );
208
208
AudioMan :QueueMusicStream (" Base.rte/Music/dBSoundworks/ccambient4.ogg" );
209
209
else
210
- -- But if humans are left, then play happy music!
210
+ -- But if humans are left, play happy music!
211
211
AudioMan :ClearMusicQueue ();
212
212
AudioMan :PlayMusic (" Base.rte/Music/dBSoundworks/uwinfinal.ogg" , 2 , - 1.0 );
213
213
AudioMan :QueueSilence (10 );
@@ -218,62 +218,59 @@ end
218
218
219
219
function OneManArmy :UpdateActivity ()
220
220
if self .ActivityState ~= Activity .OVER then
221
- ActivityMan :GetActivity ():SetTeamFunds (0 ,0 )
221
+ ActivityMan :GetActivity ():SetTeamFunds (0 , 0 )
222
222
for player = Activity .PLAYER_1 , Activity .MAXPLAYERCOUNT - 1 do
223
223
if self :PlayerActive (player ) and self :PlayerHuman (player ) then
224
- -- Display messages.
224
+ -- Display messages
225
225
if self .StartTimer :IsPastSimMS (3000 ) then
226
- FrameMan :SetScreenText (math.floor (self .SurvivalTimer :LeftTillSimMS (self .TimeLimit ) / 1000 ) .. " seconds left" , player , 0 , 1000 , false )
226
+ FrameMan :SetScreenText (math.floor (self .SurvivalTimer :LeftTillSimMS (self .TimeLimit ) * 0.001 ) .. " seconds left" , player , 0 , 1000 , false )
227
227
else
228
228
FrameMan :SetScreenText (" Survive for " .. self .timeDisplay .. " !" , player , 333 , 5000 , true )
229
229
end
230
-
231
- -- The current player's team
232
- local team = self :GetTeamOfPlayer (player )
233
- -- Check if any player's brain is dead
230
+
231
+ local team = self :GetTeamOfPlayer (player );
232
+ -- Check if any player's brain is dead
234
233
if not MovableMan :IsActor (self :GetPlayerBrain (player )) then
235
- self :SetPlayerBrain (nil , player )
236
- self :ResetMessageTimer (player )
237
- FrameMan :ClearScreenText (player )
238
- FrameMan :SetScreenText (" Your brain has been destroyed!" , player , 333 , - 1 , false )
239
- -- Now see if all brains of self player's team are dead, and if so, end the game
234
+ self :SetPlayerBrain (nil , player );
235
+ self :ResetMessageTimer (player );
236
+ FrameMan :ClearScreenText (player );
237
+ FrameMan :SetScreenText (" Your brain has been destroyed!" , player , 333 , - 1 , false );
238
+ -- Now see if all brains of self player's team are dead, and if so, end the game
240
239
if not MovableMan :GetFirstBrainActor (team ) then
241
- self .WinnerTeam = self :OtherTeam (team )
242
- ActivityMan :EndActivity ()
240
+ self .WinnerTeam = self :OtherTeam (team );
241
+ ActivityMan :EndActivity ();
243
242
end
244
- else
245
- self .HuntPlayer = player
246
243
end
247
244
248
- -- Check if the player has won.
245
+ -- Check if the player has won
249
246
if self .SurvivalTimer :IsPastSimMS (self .TimeLimit ) then
250
- self :ResetMessageTimer (player )
251
- FrameMan :ClearScreenText (player )
252
- FrameMan :SetScreenText (" You survived!" , player , 333 , - 1 , false )
247
+ self :ResetMessageTimer (player );
248
+ FrameMan :ClearScreenText (player );
249
+ FrameMan :SetScreenText (" You survived!" , player , 333 , - 1 , false );
253
250
254
- self .WinnerTeam = player
251
+ self .WinnerTeam = player ;
255
252
256
- -- Kill all enemies.
253
+ -- Kill all enemies
257
254
for actor in MovableMan .Actors do
258
255
if actor .Team ~= self .WinnerTeam then
259
- actor .Health = 0
256
+ actor .Health = 0 ;
260
257
end
261
258
end
262
259
263
- ActivityMan :EndActivity ()
260
+ ActivityMan :EndActivity ();
264
261
end
265
262
end
266
263
end
267
-
268
- -- Spawn the AI.
269
- if self .CPUTeam ~= Activity .NOTEAM and self .ESpawnTimer :LeftTillSimMS (self .TimeLeft ) <= 0 and MovableMan : GetTeamMOIDCount ( self . CPUTeam ) <= rte .AIMOIDMax * 3 / self : GetActiveCPUTeamCount () then
270
- local ship , actorsInCargo
264
+ local enemyMOIDCount = MovableMan : GetTeamMOIDCount ( self . CPUTeam );
265
+ -- Spawn the AI
266
+ if self .CPUTeam ~= Activity .NOTEAM and self .ESpawnTimer :LeftTillSimMS (self .TimeLeft ) <= 0 and enemyMOIDCount < rte .AIMOIDMax then
267
+ local ship , actorsInCargo ;
271
268
272
269
if math.random () < 0.5 then
273
- -- Set up the ship to deliver this stuff
270
+ -- Set up the ship to deliver this stuff
274
271
ship = RandomACDropShip (" Any" , self .CPUTechName );
275
- -- If we can't afford this dropship, then try a rocket instead
276
- if ship :GetTotalValue (0 ,3 ) > self :GetTeamFunds (self .CPUTeam ) then
272
+ -- If we can't afford this dropship, then try a rocket instead
273
+ if ship :GetTotalValue (0 , 3 ) > self :GetTeamFunds (self .CPUTeam ) then
277
274
DeleteEntity (ship );
278
275
ship = RandomACRocket (" Any" , self .CPUTechName );
279
276
end
@@ -285,44 +282,44 @@ function OneManArmy:UpdateActivity()
285
282
286
283
ship .Team = self .CPUTeam ;
287
284
288
- -- The max allowed weight of this craft plus cargo
289
- local craftMaxMass = ship .MaxMass
285
+ -- The max allowed weight of this craft plus cargo
286
+ local craftMaxMass = ship .MaxMass ;
290
287
if craftMaxMass < 0 then
291
- craftMaxMass = math.huge
288
+ craftMaxMass = math.huge ;
292
289
elseif craftMaxMass < 1 then
293
- craftMaxMass = ship .Mass + 400 -- MaxMass not defined
290
+ craftMaxMass = ship .Mass + 400 ; -- MaxMass not defined
294
291
end
295
292
296
- -- Set the ship up with a cargo of a few armed and equipped actors
293
+ -- Set the ship up with a cargo of a few armed and equipped actors
297
294
for i = 1 , actorsInCargo do
298
- -- Get any Actor from the CPU's native tech
295
+ -- Get any Actor from the CPU's native tech
299
296
local passenger = nil ;
300
297
if math.random () >= self :GetCrabToHumanSpawnRatio (PresetMan :GetModuleID (self .CPUTechName )) then
301
298
passenger = RandomAHuman (" Any" , self .CPUTechName );
302
299
else
303
300
passenger = RandomACrab (" Any" , self .CPUTechName );
304
301
end
305
- -- Equip it with tools and guns if it's a humanoid
302
+ -- Equip it with tools and guns if it's a humanoid
306
303
if IsAHuman (passenger ) then
307
304
passenger :AddInventoryItem (RandomHDFirearm (" Weapons - Light" , self .CPUTechName ));
308
305
passenger :AddInventoryItem (RandomHDFirearm (" Weapons - Secondary" , self .CPUTechName ));
309
306
if math.random () < 0.5 then
310
307
passenger :AddInventoryItem (RandomHDFirearm (" Tools - Diggers" , self .CPUTechName ));
311
308
end
312
309
end
313
- -- Set AI mode and team so it knows who and what to fight for!
310
+ -- Set AI mode and team so it knows who and what to fight for!
314
311
passenger .AIMode = Actor .AIMODE_BRAINHUNT ;
315
312
passenger .Team = self .CPUTeam ;
316
313
317
- -- Check that we can afford to buy and to carry the weight of this passenger
318
- if (ship :GetTotalValue (0 ,3 ) + passenger :GetTotalValue (0 ,3 )) <= self :GetTeamFunds (self .CPUTeam ) and (ship .Mass + passenger .Mass ) <= craftMaxMass then
319
- -- Yes we can; so add it to the cargo hold
314
+ -- Check that we can afford to buy and to carry the weight of this passenger
315
+ if (ship :GetTotalValue (0 , 3 ) + passenger :GetTotalValue (0 , 3 )) <= self :GetTeamFunds (self .CPUTeam ) and (ship .Mass + passenger .Mass ) <= craftMaxMass then
316
+ -- Yes we can; so add it to the cargo hold
320
317
ship :AddInventoryItem (passenger );
321
318
passenger = nil ;
322
319
else
323
- -- Nope; just delete the nixed passenger and stop adding new ones
324
- -- This doesn't need to be explicitly deleted here, teh garbage collection would do it eventually..
325
- -- but since we're so sure we don't need it, might as well go ahead and do it here right away
320
+ -- Nope; just delete the nixed passenger and stop adding new ones
321
+ -- This doesn't need to be explicitly deleted here, the garbage collection would do it eventually,
322
+ -- but since we're so sure we don't need it, might as well go ahead and do it right away
326
323
DeleteEntity (passenger );
327
324
passenger = nil ;
328
325
@@ -336,47 +333,45 @@ function OneManArmy:UpdateActivity()
336
333
end
337
334
338
335
if ship then
339
- -- Set the spawn point of the ship from orbit
336
+ -- Set the spawn point of the ship from orbit
340
337
if self .playertally == 1 then
341
338
for i = 1 , # self .playerlist do
342
339
if self .playerlist [i ] == true then
343
- local sceneChunk = SceneMan .SceneWidth / 3 ;
344
- local checkPos = self :GetPlayerBrain (i - 1 ).Pos .X + (SceneMan .SceneWidth / 2 ) + ( (sceneChunk / 2 ) - (math.random ()* sceneChunk ) );
340
+ local sceneChunk = SceneMan .SceneWidth * 0. 3 ;
341
+ local checkPos = self :GetPlayerBrain (i - 1 ).Pos .X + (SceneMan .SceneWidth * 0.5 ) + ((sceneChunk * 0.5 ) - (math.random () * sceneChunk ));
345
342
if checkPos > SceneMan .SceneWidth then
346
343
checkPos = checkPos - SceneMan .SceneWidth ;
347
344
elseif checkPos < 0 then
348
345
checkPos = SceneMan .SceneWidth + checkPos ;
349
346
end
350
- ship .Pos = Vector (checkPos ,- 50 );
347
+ ship .Pos = Vector (checkPos , - 50 );
351
348
break ;
352
349
end
353
350
end
354
351
else
355
352
if SceneMan .SceneWrapsX then
356
353
ship .Pos = Vector (math.random () * SceneMan .SceneWidth , - 50 );
357
354
else
358
- ship .Pos = Vector (RangeRand (100 , SceneMan .SceneWidth - 100 ), - 50 );
355
+ ship .Pos = Vector (RangeRand (100 , SceneMan .SceneWidth - 100 ), - 50 );
359
356
end
360
357
end
361
358
362
- -- Double-check if the computer can afford this ship and cargo, then subtract the total value from the team's funds
363
- local shipValue = ship :GetTotalValue (0 ,3 );
359
+ -- Double-check if the computer can afford this ship and cargo, then subtract the total value from the team's funds
360
+ local shipValue = ship :GetTotalValue (0 , 3 );
364
361
if shipValue <= self :GetTeamFunds (self .CPUTeam ) then
365
- -- Subtract the total value of the ship+cargo from the CPU team's funds
362
+ -- Subtract the total value of the ship+cargo from the CPU team's funds
366
363
self :ChangeTeamFunds (- shipValue , self .CPUTeam );
367
- -- Spawn the ship onto the scene
364
+ -- Spawn the ship onto the scene
368
365
MovableMan :AddActor (ship );
369
366
else
370
- -- The ship and its contents is deleted if it can't be afforded
371
- -- This doesn't need to be explicitly deleted here, teh garbage collection would do it eventually..
372
- -- but since we're so sure we don't need it, might as well go ahead and do it here right away
367
+ -- The ship and its contents is deleted if it can't be afforded
373
368
DeleteEntity (ship );
374
369
ship = nil ;
375
370
end
376
371
end
377
372
378
373
self .ESpawnTimer :Reset ();
379
- self .TimeLeft = (self .BaseSpawnTime + math.random (self .BaseSpawnTime ) * rte .SpawnIntervalScale ) ;
374
+ self .TimeLeft = (self .BaseSpawnTime * ( 1 + enemyMOIDCount * 0.1 ) + math.random (self .BaseSpawnTime )) * rte .SpawnIntervalScale ;
380
375
end
381
376
end
382
377
end
0 commit comments