Skip to content

Commit a0d0538

Browse files
authored
Merge pull request #99 from MageKing17/bugfix/more-player-assumptions
Activities: Fix more player 1 assumptions, make broken code to avoid deploying on a player work.
2 parents 655b2d3 + e94bfb8 commit a0d0538

File tree

10 files changed

+64
-39
lines changed

10 files changed

+64
-39
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2626

2727
- `LERP` Lua binding has been deprecated, and renamed to `Lerp`.
2828

29+
- Six activities (Harvester, Keepie-Uppie, Massacre, One-Man Army, One-Man Army (Diggers Only), and Survival) now avoid AI deployments on top of the player.
30+
2931
</details>
3032

3133
<details><summary><b>Fixed</b></summary>
@@ -54,6 +56,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5456

5557
- Fixed `MovableObject` INI and Lua property `IgnoreTerrain` not having any appreciable effect.
5658

59+
- Fixed Signal Hunt speedrun mode not working properly if you used a player other than 1.
60+
61+
- Fixed Decision Day camera potentially getting stuck at the start if player 1 wasn't present.
62+
5763
</details>
5864

5965
<details><summary><b>Removed</b></summary>

Data/Base.rte/Activities/Harvester.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function Harvester:UpdateActivity()
209209
end
210210

211211
if self.addFogOfWar then
212-
SceneMan:MakeAllUnseen(Vector(20, 20), self:GetTeamOfPlayer(Activity.PLAYER_1));
212+
SceneMan:MakeAllUnseen(Vector(20, 20), Activity.TEAM_1);
213213
self.addFogOfWar = false;
214214
end
215215

@@ -294,11 +294,11 @@ function Harvester:UpdateActivity()
294294

295295
if ship then
296296
-- Set the spawn point of the ship from orbit
297-
if self.playertally == 1 then
298-
for i = 1, #self.playerlist do
299-
if self.playerlist[i] == true then
297+
if self.HumanCount == 1 then
298+
for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
299+
if self:PlayerActive(player) and self:PlayerHuman(player) then
300300
local sceneChunk = SceneMan.SceneWidth / 3;
301-
local checkPos = self:GetPlayerBrain(i - 1).Pos.X + (SceneMan.SceneWidth/2) + ( (sceneChunk/2) - (math.random()*sceneChunk) );
301+
local checkPos = self:GetPlayerBrain(player).Pos.X + (SceneMan.SceneWidth/2) + ( (sceneChunk/2) - (math.random()*sceneChunk) );
302302
if checkPos > SceneMan.SceneWidth then
303303
checkPos = checkPos - SceneMan.SceneWidth;
304304
elseif checkPos < 0 then

Data/Base.rte/Activities/KeepieUppie.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,11 @@ function KeepieUppie:UpdateActivity()
226226
end
227227

228228
-- Set the spawn point of the ship from orbit
229-
if self.playertally == 1 then
230-
for i = 1, #self.playerlist do
231-
if self.playerlist[i] == true then
229+
if self.HumanCount == 1 then
230+
for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
231+
if self:PlayerActive(player) and self:PlayerHuman(player) then
232232
local sceneChunk = SceneMan.SceneWidth / 3;
233-
local checkPos = self:GetPlayerBrain(i - 1).Pos.X + (SceneMan.SceneWidth/2) + ( (sceneChunk/2) - (math.random()*sceneChunk) );
233+
local checkPos = self:GetPlayerBrain(player).Pos.X + (SceneMan.SceneWidth/2) + ( (sceneChunk/2) - (math.random()*sceneChunk) );
234234
if checkPos > SceneMan.SceneWidth then
235235
checkPos = checkPos - SceneMan.SceneWidth;
236236
elseif checkPos < 0 then

Data/Base.rte/Activities/Massacre.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ function Massacre:UpdateActivity()
297297

298298
if ship then
299299
-- Set the spawn point of the ship from orbit
300-
if self.playertally == 1 then
301-
for i = 1, #self.playerlist do
302-
if self.playerlist[i] == true then
300+
if self.HumanCount == 1 then
301+
for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
302+
if self:PlayerActive(player) and self:PlayerHuman(player) then
303303
local sceneChunk = SceneMan.SceneWidth / 3;
304304
local checkPos = self:GetPlayerBrain(i - 1).Pos.X + (SceneMan.SceneWidth/2) + ( (sceneChunk/2) - (math.random()*sceneChunk) );
305305
if checkPos > SceneMan.SceneWidth then

Data/Base.rte/Activities/OneManArmy.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,9 @@ function OneManArmy:UpdateActivity()
378378

379379
if ship then
380380
--Set the spawn point of the ship from orbit
381-
if self.playertally == 1 then
382-
for i = 1, #self.playerlist do
383-
if self.playerlist[i] == true then
381+
if self.HumanCount == 1 then
382+
for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
383+
if self:PlayerActive(player) and self:PlayerHuman(player) then
384384
local sceneChunk = SceneMan.SceneWidth * 0.3;
385385
local checkPos = self:GetPlayerBrain(i - 1).Pos.X + (SceneMan.SceneWidth * 0.5) + ((sceneChunk * 0.5) - (math.random() * sceneChunk));
386386
if checkPos > SceneMan.SceneWidth then

Data/Base.rte/Activities/OneManArmyDiggers.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,9 @@ function OneManArmy:UpdateActivity()
321321

322322
if ship then
323323
-- Set the spawn point of the ship from orbit
324-
if self.playertally == 1 then
325-
for i = 1, #self.playerlist do
326-
if self.playerlist[i] == true then
324+
if self.HumanCount == 1 then
325+
for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
326+
if self:PlayerActive(player) and self:PlayerHuman(player) then
327327
local sceneChunk = SceneMan.SceneWidth / 3;
328328
local checkPos = self:GetPlayerBrain(i - 1).Pos.X + (SceneMan.SceneWidth/2) + ( (sceneChunk/2) - (math.random()*sceneChunk) );
329329
if checkPos > SceneMan.SceneWidth then

Data/Base.rte/Activities/Survival.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,9 @@ function Survival:UpdateActivity()
275275

276276
if ship then
277277
-- Set the spawn point of the ship from orbit
278-
if self.playertally == 1 then
279-
for i = 1, #self.playerlist do
280-
if self.playerlist[i] == true then
278+
if self.HumanCount == 1 then
279+
for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
280+
if self:PlayerActive(player) and self:PlayerHuman(player) then
281281
local sceneChunk = SceneMan.SceneWidth / 3;
282282
local checkPos = self:GetPlayerBrain(i - 1).Pos.X + (SceneMan.SceneWidth/2) + ( (sceneChunk/2) - (math.random()*sceneChunk) );
283283
if checkPos > SceneMan.SceneWidth then

Data/Missions.rte/Activities/DecisionDay.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,10 +1006,7 @@ function DecisionDay:UpdateCamera()
10061006
local scrollTargetAndSpeed;
10071007
if self.currentStage <= self.stages.showInitialText then
10081008
if self.currentStage == self.stages.showInitialText and self.messageTimer.SimTimeLimitProgress > 0.75 then
1009-
local brain = self:GetPlayerBrain(0);
1010-
if brain then
1011-
scrollTargetAndSpeed = {brain.Pos, fastScroll};
1012-
end
1009+
scrollTargetAndSpeed = {nil, fastScroll};
10131010
else
10141011
local dropShipToFollow = #self.initialDropShipsAndVelocities > 0 and self.initialDropShipsAndVelocities[1].dropShip or nil;
10151012
if dropShipToFollow then
@@ -1101,7 +1098,14 @@ function DecisionDay:UpdateCamera()
11011098

11021099
if scrollTargetAndSpeed then
11031100
for _, player in pairs(self.humanPlayers) do
1104-
CameraMan:SetScrollTarget(scrollTargetAndSpeed[1], scrollTargetAndSpeed[2], player);
1101+
if not scrollTargetAndSpeed[1] then
1102+
brain = self:GetPlayerBrain(player)
1103+
if brain then
1104+
CameraMan:SetScrollTarget(brain.pos, scrollTargetAndSpeed[2], player)
1105+
end
1106+
else
1107+
CameraMan:SetScrollTarget(scrollTargetAndSpeed[1], scrollTargetAndSpeed[2], player);
1108+
end
11051109
end
11061110
end
11071111
self.cameraIsPanning = scrollTargetAndSpeed ~= nil;

Data/Missions.rte/Activities/SignalHunt.lua

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -329,17 +329,23 @@ function SignalHunt:DoSpeedrunMode()
329329

330330
AudioMan:PlayMusic("Base.rte/Music/dBSoundworks/bossfight.ogg", -1, -1);
331331

332-
local rocket = self:GetPlayerBrain(0);
333-
rocket.PlayerControllable = true;
334-
rocket.HUDVisible = true;
335-
for item in rocket.Inventory do
336-
rocket:RemoveInventoryItem(item.ModuleName, item.PresetName);
337-
end
338-
local brain = CreateAHuman("Brain Robot", "Base.rte");
339-
brain:AddInventoryItem(CreateHDFirearm("Old Stock Pistol", "Base.rte"));
340-
brain.Team = self.humanTeam;
341-
rocket:AddInventoryItem(brain);
342-
self:SwitchToActor(rocket, 0, self.humanTeam);
332+
for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
333+
if self:PlayerActive(player) and self:PlayerHuman(player) then
334+
local rocket = self:GetPlayerBrain(player);
335+
rocket.PlayerControllable = true;
336+
rocket.HUDVisible = true;
337+
for item in rocket.Inventory do
338+
rocket:RemoveInventoryItem(item.ModuleName, item.PresetName);
339+
end
340+
local brain = CreateAHuman("Brain Robot", "Base.rte");
341+
brain:AddInventoryItem(CreateHDFirearm("Old Stock Pistol", "Base.rte"));
342+
brain.Team = self.humanTeam;
343+
rocket:AddInventoryItem(brain);
344+
self:SwitchToActor(rocket, player, self.humanTeam);
345+
-- Speedrun mode only works with a single human player, but if that ever changes, this break can be removed.
346+
break
347+
end
348+
end
343349

344350
local currentZombieSpawnDifficultyMultiplier = self.zombieSpawnDifficultyMultiplier;
345351
self:SetupDifficultySettings();
@@ -409,6 +415,7 @@ function SignalHunt:DoSecret(playersWhoCompletedCode)
409415
MovableMan:ChangeActorTeam(playerBrain, self.zombieTeam);
410416
self:SetTeamOfPlayer(player, self.zombieTeam);
411417
self:SetPlayerBrain(playerBrain, player);
418+
self:SwitchToActor(playerBrain, player, self.zombieTeam)
412419
end
413420

414421
local otherHumanPlayersExist = self.HumanCount > #playersWhoCompletedCode;
@@ -418,7 +425,7 @@ function SignalHunt:DoSecret(playersWhoCompletedCode)
418425

419426
local zombieWaypoint = SceneMan:MovePointToGround(self.humanLZ:GetCenterPoint(), 10, 10);
420427
for actor in MovableMan.Actors do
421-
if actor.Team == self.zombieTeam then
428+
if actor.Team == self.zombieTeam and not actor:IsPlayerControlled() then
422429
actor:ClearAIWaypoints();
423430
if otherHumanPlayersExist then
424431
actor.AIMode = Actor.AIMODE_BRAINHUNT;
@@ -578,7 +585,14 @@ function SignalHunt:UpdateActivity()
578585
self:DoGameOverCheck();
579586

580587
if self.speedrunData and not ActivitySpeedrunHelper.SpeedrunActive(self.speedrunData) then
581-
if IsAHuman(self:GetPlayerBrain(Activity.PLAYER_1)) then
588+
brainbot_spawned = false
589+
for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
590+
if self:PlayerActive(player) and self:PlayerHuman(player) and IsAHuman(self:GetPlayerBrain(player)) then
591+
brainbot_spawned = true
592+
break
593+
end
594+
end
595+
if brainbot_spawned then
582596
self.speedrunData = nil;
583597
else
584598
ActivitySpeedrunHelper.CheckForSpeedrun(self.speedrunData);

Resources/Credits.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ R I K U " 4 Z K " K
2727
S T E W I E
2828
T H O M A S " C A U S E L E S S " M A R C H
2929
T O P K E K
30+
W I L L I A M " M A G E K I N G 1 7 " H O W A R D
3031
Z A L O
3132
3233
Art and Content Production

0 commit comments

Comments
 (0)