Skip to content

Commit e15c693

Browse files
authored
Merge pull request #111 from MageKing17/bugfix/metafight-instant-fail
Fix MetaFight immediately failing if a defending brain is present.
2 parents 1da3f81 + 7cc3b39 commit e15c693

File tree

4 files changed

+56
-48
lines changed

4 files changed

+56
-48
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [Unreleased]
8+
9+
<details><summary><b>Fixed</b></summary>
10+
11+
- Fixed regression introduced in 6.1 causing Conquest activities to immediately fail if a defending brain was present (and probably breaking other activities as well).
12+
13+
- Fixed the Conquest start game menu not letting you immediately start a game until you tweak some settings.
14+
15+
</details>
16+
717
## [Release v6.2.1] - 2024/02/21
818

919
<details><summary><b>Fixed</b></summary>

Data/Base.rte/Activities/MetaFight.lua

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ function MetaFight:BrainCheck()
55
-- Clear all objective markers, they get re-added each frame
66
self:ClearObjectivePoints();
77
-- Keep track of which teams we have set objective points for already, since multiple players can be on the same team
8-
local setTeam = { [Activity.TEAM_1] = false, [Activity.TEAM_2] = false, [Activity.TEAM_3] = false, [Activity.TEAM_4] = false };
8+
local setTeam = {};
9+
for team = Activity.TEAM_1, Activity.MAXTEAMCOUNT - 1 do
10+
setTeam[team] = false;
11+
end
912

1013
-----------------------------------------------------------------
1114
-- Brain integrity check logic for every player, Human or AI
@@ -166,36 +169,33 @@ function MetaFight:StartActivity()
166169
-- self.CurrentScanStage = { [Activity.TEAM_1] = self.ScanStage.PRESCAN, [Activity.TEAM_2] = self.ScanStage.PRESCAN, [Activity.TEAM_3] = self.ScanStage.PRESCAN, [Activity.TEAM_4] = self.ScanStage.PRESCAN };
167170
-- Start by assming no teams have scanning scheduled
168171
self.CurrentScanStage = self.ScanStage.DONESCAN;
169-
self.ScanPosX = { [Activity.TEAM_1] = -1, [Activity.TEAM_2] = -1, [Activity.TEAM_3] = -1, [Activity.TEAM_4] = -1 };
170-
self.ScanTimer = { [Activity.TEAM_1] = Timer(), [Activity.TEAM_2] = Timer(), [Activity.TEAM_3] = Timer(), [Activity.TEAM_4] = Timer() };
171-
self.StartFunds = { [Activity.TEAM_1] = 0, [Activity.TEAM_2] = 0, [Activity.TEAM_3] = 0, [Activity.TEAM_4] = 0 };
172+
self.ScanPosX = {};
173+
self.ScanTimer = {};
174+
self.StartFunds = {};
172175
self.ScanEndPos = Vector();
173176

174-
-- Reset scan timers and check that there's any teams with a scheduled scan at all
175-
for team = Activity.TEAM_1, Activity.MAXTEAMCOUNT - 1 do
176-
if self:TeamActive(team) then
177-
self.ScanTimer[team]:Reset();
178-
-- Yes there is at least one active team that has scanning scheduled
179-
if SceneMan.Scene:IsScanScheduled(team) then
180-
self.CurrentScanStage = self.ScanStage.PRESCAN;
181-
end
182-
end
183-
end
184-
185177
-- Which are the invading teams
186-
self.InvadingTeam = { [Activity.TEAM_1] = false, [Activity.TEAM_2] = false, [Activity.TEAM_3] = false, [Activity.TEAM_4] = false };
178+
self.InvadingTeam = {};
187179
-- Which Teams are managed tactically by the AI? Only teams with NO human players on them
188-
self.TeamAIActive = { [Activity.TEAM_1] = false, [Activity.TEAM_2] = false, [Activity.TEAM_3] = false, [Activity.TEAM_4] = false };
180+
self.TeamAIActive = {};
189181
-- Team has given up and is evacuating their brain
190-
self.TeamEvacuating = { [Activity.TEAM_1] = false, [Activity.TEAM_2] = false, [Activity.TEAM_3] = false, [Activity.TEAM_4] = false };
182+
self.TeamEvacuating = {};
191183

192184
-- A list of AI controlled team numbers
193185
local CPUTeams = {};
194186
-- Timers for controlling the AI modes of team members
195187
self.AIModeTimer = {};
196188

197189
for team = Activity.TEAM_1, Activity.MAXTEAMCOUNT - 1 do
190+
self.ScanPosX[team] = -1;
191+
self.ScanTimer[team] = Timer();
192+
self.StartFunds[team] = 0;
193+
198194
if self:TeamActive(team) then
195+
if SceneMan.Scene:IsScanScheduled(team) then
196+
-- Yes there is at least one active team that has scanning scheduled
197+
self.CurrentScanStage = self.ScanStage.PRESCAN;
198+
end
199199
-- Start out assuming all teams are all AI invaders, then disprove it
200200
self.InvadingTeam[team] = true;
201201
self.TeamAIActive[team] = true;
@@ -220,34 +220,32 @@ function MetaFight:StartActivity()
220220
self.AIModeTimer[team] = Timer();
221221
table.insert(CPUTeams, team);
222222
end
223+
else
224+
self.InvadingTeam[team] = false;
225+
self.TeamAIActive[team] = false;
226+
self.TeamEvacuating[team] = false;
223227
end
224228
end
225229

226230
-- MetaFight-specific player parameters
227-
self.InvadingPlayer = { [Activity.PLAYER_1] = false, [Activity.PLAYER_2] = false, [Activity.PLAYER_3] = false, [Activity.PLAYER_4] = false };
228-
self.Ready = { [Activity.PLAYER_1] = false, [Activity.PLAYER_2] = false, [Activity.PLAYER_3] = false, [Activity.PLAYER_4] = false };
231+
self.InvadingPlayer = {};
232+
self.Ready = {};
229233
self.InvadingPlayerCount = 0;
230234
-- At what funds level the AI starts thinking about going into brain evacuation mode
231-
self.EvacThreshold = { [Activity.PLAYER_1] = 100, [Activity.PLAYER_2] = 100, [Activity.PLAYER_3] = 100, [Activity.PLAYER_4] = 100 };
235+
self.EvacThreshold = {};
232236
-- The last known position of all players' active brains
233-
self.LastBrainPos = { [Activity.PLAYER_1] = Vector(), [Activity.PLAYER_2] = Vector(), [Activity.PLAYER_3] = Vector(), [Activity.PLAYER_4] = Vector() };
237+
self.LastBrainPos = {};
234238
-- The position of the last brain that died
235239
self.LastBrainDeathPos = Vector();
236240

237-
-- Count how many invading players there are
238-
for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
239-
if self:PlayerActive(player) then -- and self:PlayerHuman(player) then
240-
if not SceneMan.Scene:GetResidentBrain(player) then
241-
self.InvadingPlayerCount = self.InvadingPlayerCount + 1;
242-
end
243-
end
244-
end
245-
246241
local defenderTeam;
247242
local defenderTeamNativeCostMultiplier = 1.0;
248243

249244
-- Now init all players
250245
for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
246+
self.Ready[player] = false;
247+
self.EvacThreshold[player] = 100;
248+
self.LastBrainPos[player] = Vector();
251249
if self:PlayerActive(player) then
252250
-- Reset the timer that will measure the delay between ordering of reinforcements
253251
-- Determine whether this player is invading or already has a brain to defend here
@@ -273,10 +271,7 @@ function MetaFight:StartActivity()
273271
-- Invading player
274272
if not residentBrain then
275273
self.InvadingPlayer[player] = true;
276-
-- Sanity check
277-
if self.InvadingPlayerCount < 1 then
278-
self.InvadingPlayerCount = 1;
279-
end
274+
self.InvadingPlayerCount = self.InvadingPlayerCount + 1;
280275

281276
-- Human player; init as appropriate for invaders
282277
if self:PlayerHuman(player) then
@@ -324,7 +319,7 @@ function MetaFight:StartActivity()
324319
if residentBrain.Pos.X == -1 and residentBrain.Pos.Y == -1 then
325320
-- Find some random spot to put our brain
326321
local pos;
327-
local sucess = false;
322+
local success = false;
328323
-- Make few attempts to find a suitable spot
329324
for i = 1, 10 do
330325
local rangeWidth;
@@ -351,16 +346,16 @@ function MetaFight:StartActivity()
351346

352347
pos = Vector(math.random(rangeStart, rangeEnd), 0);
353348

354-
sucess = true;
349+
success = true;
355350

356351
-- Measure heights 5 times and verify that we can put brain there
357352
for j = -2, 2 do
358353
if SceneMan:FindAltitude(pos + Vector(j * 10, 0), 0, 19) < 25 then
359-
sucess = false;
354+
success = false;
360355
end
361356
end
362357

363-
if sucess then
358+
if success then
364359
break;
365360
end
366361
end
@@ -417,7 +412,7 @@ function MetaFight:StartActivity()
417412
if residentBrain.Pos.X == -1 and residentBrain.Pos.Y == -1 then
418413
-- Find some random spot to put our brain
419414
local pos;
420-
local sucess = false;
415+
local success = false;
421416
-- Make few attempts to find a suitable spot
422417
for i = 1, 20 do
423418
local rangeWidth;
@@ -444,16 +439,16 @@ function MetaFight:StartActivity()
444439

445440
pos = Vector(math.random(rangeStart, rangeEnd), 0);
446441

447-
sucess = true;
442+
success = true;
448443

449444
-- Measure heights 5 times and verify that we can put brain there
450445
for j = -2, 2 do
451446
if SceneMan:FindAltitude(pos + Vector(j * 10, 0), 0, 19) < 25 then
452-
sucess = false;
447+
success = false;
453448
end
454449
end
455450

456-
if sucess then
451+
if success then
457452
break;
458453
end
459454
end
@@ -1435,13 +1430,13 @@ function MetaFight:OrderHeavyLoadout(player, team)
14351430
if actorsInCargo >= passengerLimit or totalMass > craftMaxMass then
14361431
break;
14371432
end
1438-
1439-
return true;
14401433
end
14411434

14421435
if diggers < 1 then
14431436
self:AddOverridePurchase(CreateHDFirearm("Light Digger", "Base.rte"), player);
14441437
end
1438+
1439+
return true;
14451440
end
14461441
end
14471442

Source/Managers/MovableMan.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ bool MovableMan::AddMO(MovableObject* movableObjectToAdd) {
666666
}
667667

668668
void MovableMan::AddActor(Actor* actorToAdd) {
669-
if (actorToAdd && g_ActivityMan.ActivityRunning()) {
669+
if (actorToAdd && g_ActivityMan.GetActivity()) {
670670
actorToAdd->SetAsAddedToMovableMan();
671671
actorToAdd->CorrectAttachableAndWoundPositionsAndRotations();
672672

@@ -696,7 +696,7 @@ void MovableMan::AddActor(Actor* actorToAdd) {
696696
}
697697

698698
void MovableMan::AddItem(HeldDevice* itemToAdd) {
699-
if (itemToAdd && g_ActivityMan.ActivityRunning()) {
699+
if (itemToAdd && g_ActivityMan.GetActivity()) {
700700
g_ActivityMan.GetActivity()->ForceSetTeamAsActive(itemToAdd->GetTeam());
701701

702702
itemToAdd->SetAsAddedToMovableMan();
@@ -720,7 +720,7 @@ void MovableMan::AddItem(HeldDevice* itemToAdd) {
720720
}
721721

722722
void MovableMan::AddParticle(MovableObject* particleToAdd) {
723-
if (particleToAdd && g_ActivityMan.ActivityRunning()) {
723+
if (particleToAdd && g_ActivityMan.GetActivity()) {
724724
g_ActivityMan.GetActivity()->ForceSetTeamAsActive(particleToAdd->GetTeam());
725725

726726
particleToAdd->SetAsAddedToMovableMan();

Source/Menus/MetagameGUI.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,9 @@ void MetagameGUI::SetEnabled(bool enable) {
757757
}
758758
}
759759

760+
if (enable) {
761+
UpdatePlayerSetup(); // Ensure everything's ready to jump right in to the game, if the player wants.
762+
}
760763
m_ScreenChange = true;
761764
}
762765

0 commit comments

Comments
 (0)