Skip to content

Commit 27bf8b9

Browse files
committed
mother brain barrier clear logic for custom objectives
1 parent 549d76a commit 27bf8b9

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

rust/maprando-game/src/lib.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ pub enum Requirement {
200200
Item(ItemId),
201201
Flag(FlagId),
202202
NotFlag(FlagId),
203-
Objective(usize),
203+
MotherBrainBarrierClear(usize),
204204
Walljump,
205205
ShineCharge {
206206
used_tiles: Float,
@@ -1999,14 +1999,14 @@ impl GameData {
19991999
green: true,
20002000
heated: true,
20012001
});
2002-
} else if value == "i_Objective1Complete" {
2003-
return Ok(Requirement::Objective(0));
2004-
} else if value == "i_Objective2Complete" {
2005-
return Ok(Requirement::Objective(1));
2006-
} else if value == "i_Objective3Complete" {
2007-
return Ok(Requirement::Objective(2));
2008-
} else if value == "i_Objective4Complete" {
2009-
return Ok(Requirement::Objective(3));
2002+
} else if value == "i_MotherBrainBarrier1Clear" {
2003+
return Ok(Requirement::MotherBrainBarrierClear(0));
2004+
} else if value == "i_MotherBrainBarrier2Clear" {
2005+
return Ok(Requirement::MotherBrainBarrierClear(1));
2006+
} else if value == "i_MotherBrainBarrier3Clear" {
2007+
return Ok(Requirement::MotherBrainBarrierClear(2));
2008+
} else if value == "i_MotherBrainBarrier4Clear" {
2009+
return Ok(Requirement::MotherBrainBarrierClear(3));
20102010
} else if value == "i_LowerNorfairElevatorDownwardFrames" {
20112011
return Ok(Requirement::LowerNorfairElevatorDownFrames);
20122012
} else if value == "i_LowerNorfairElevatorUpwardFrames" {
@@ -2763,10 +2763,10 @@ impl GameData {
27632763
if x["id"] == 38
27642764
|| (x["link"][0].as_i32().unwrap() == 2 && x["link"][1].as_i32().unwrap() != 2)
27652765
{
2766-
x["requires"].push("i_Objective1Complete").unwrap();
2767-
x["requires"].push("i_Objective2Complete").unwrap();
2768-
x["requires"].push("i_Objective3Complete").unwrap();
2769-
x["requires"].push("i_Objective4Complete").unwrap();
2766+
x["requires"].push("i_MotherBrainBarrier1Clear").unwrap();
2767+
x["requires"].push("i_MotherBrainBarrier2Clear").unwrap();
2768+
x["requires"].push("i_MotherBrainBarrier3Clear").unwrap();
2769+
x["requires"].push("i_MotherBrainBarrier4Clear").unwrap();
27702770
}
27712771
}
27722772

@@ -2787,10 +2787,10 @@ impl GameData {
27872787
x["exitCondition"]["leaveWithRunway"]["openEnd"] = JsonValue::Number(0.into());
27882788

27892789
let obj_conditions = [
2790-
"i_Objective1Complete",
2791-
"i_Objective2Complete",
2792-
"i_Objective3Complete",
2793-
"i_Objective4Complete",
2790+
"i_MotherBrainBarrier1Clear",
2791+
"i_MotherBrainBarrier2Clear",
2792+
"i_MotherBrainBarrier3Clear",
2793+
"i_MotherBrainBarrier4Clear",
27942794
];
27952795
for num_objectives_complete in 1..=4 {
27962796
let mut strat = x.clone();
@@ -2805,12 +2805,12 @@ impl GameData {
28052805
strat["id"] = JsonValue::Number((10000 + num_objectives_complete).into());
28062806
if num_objectives_complete == 1 {
28072807
strat["name"] = JsonValue::String(format!(
2808-
"{}, 1 Objective Complete",
2808+
"{}, 1 Barrier Cleared",
28092809
x["name"].as_str().unwrap()
28102810
));
28112811
} else {
28122812
strat["name"] = JsonValue::String(format!(
2813-
"{}, {} Objectives Complete",
2813+
"{}, {} Barriers Cleared",
28142814
x["name"].as_str().unwrap(),
28152815
num_objectives_complete
28162816
));

rust/maprando/src/traverse.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,23 @@ fn apply_gate_glitch_leniency(
218218
}
219219
}
220220

221-
fn is_objective_complete(
221+
fn is_mother_brain_barrier_clear(
222222
global: &GlobalState,
223223
_difficulty: &DifficultyConfig,
224224
objectives: &[Objective],
225225
game_data: &GameData,
226226
obj_id: usize,
227227
) -> bool {
228-
// TODO: What to do when obj_id is out of bounds?
229-
if let Some(obj) = objectives.get(obj_id) {
228+
if objectives.len() > 4 {
229+
for obj in objectives {
230+
let flag_name = obj.get_flag_name();
231+
let flag_idx = game_data.flag_isv.index_by_key[flag_name];
232+
if !global.flags[flag_idx] {
233+
return false;
234+
}
235+
}
236+
true
237+
} else if let Some(obj) = objectives.get(obj_id) {
230238
let flag_name = obj.get_flag_name();
231239
let flag_idx = game_data.flag_isv.index_by_key[flag_name];
232240
global.flags[flag_idx]
@@ -1025,8 +1033,8 @@ pub fn apply_requirement(
10251033
// guarded by "canRiskPermanentLossOfAccess" if there is not an alternative strat with the flag set.
10261034
Some(local)
10271035
}
1028-
Requirement::Objective(obj_id) => {
1029-
if is_objective_complete(global, difficulty, objectives, game_data, *obj_id) {
1036+
Requirement::MotherBrainBarrierClear(obj_id) => {
1037+
if is_mother_brain_barrier_clear(global, difficulty, objectives, game_data, *obj_id) {
10301038
Some(local)
10311039
} else {
10321040
None

todo.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
v118:
2+
- include "objectives" details on seed page.
23
- finish adding shinecharge and temp blue strats
34
- add `easyHeatFrames` logical requirement
45
- look into Kraid Eye Door grapple teleport strats: why [2, 19] is option from one door but not the other?

0 commit comments

Comments
 (0)