Skip to content

Commit

Permalink
Maniac: Support Variable Indirect, Switch (Maps to 0/1) and Switch In…
Browse files Browse the repository at this point in the history
…direct for ValueOrVariable function

Maniac Patch itself does not support this for all commands but supporting it for all is simpler and makes most sense.
  • Loading branch information
Ghabry committed Aug 28, 2021
1 parent 4688cab commit 3506e96
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/game_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1642,14 +1642,25 @@ bool Game_Interpreter::CommandChangeLevel(lcf::rpg::EventCommand const& com) { /
}

int Game_Interpreter::ValueOrVariable(int mode, int val) {
switch (mode) {
case 0:
return val;
case 1:
return Main_Data::game_variables->Get(val);
default:
return -1;
}
if (mode == 0) {
return val;
} else if (mode == 1) {
return Main_Data::game_variables->Get(val);
} else if (Player::IsPatchManiac()) {
// Maniac Patch does not implement all modes for all commands
// For simplicity it is enabled for all here
if (mode == 2) {
// Variable indirect
return Main_Data::game_variables->Get(Main_Data::game_variables->Get(val));
} else if (mode == 3) {
// Switch (F = 0, T = 1)
return Main_Data::game_switches->Get(val) ? 1 : 0;
} else if (mode == 4) {
// Switch through Variable indirect
return Main_Data::game_switches->Get(Main_Data::game_variables->Get(val)) ? 1 : 0;
}
}
return -1;
}

bool Game_Interpreter::CommandChangeParameters(lcf::rpg::EventCommand const& com) { // Code 10430
Expand Down

0 comments on commit 3506e96

Please sign in to comment.