Skip to content

Commit

Permalink
WaitForSingleMovement: Similiar to other waiting commands preserve th…
Browse files Browse the repository at this point in the history
…e state.

Is required to prevent that the variable changes across waits and causes issues.
  • Loading branch information
Ghabry committed Jul 31, 2024
1 parent 0263687 commit 42903a9
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/game_interpreter_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,21 +785,29 @@ bool Game_Interpreter_Map::CommandEasyRpgTriggerEventAt(lcf::rpg::EventCommand c
}

bool Game_Interpreter_Map::CommandEasyRpgWaitForSingleMovement(lcf::rpg::EventCommand const& com) {
int event_id = ValueOrVariable(com.parameters[0], com.parameters[1]);
_state.easyrpg_parameters.resize(3);

Game_Character* chara = GetCharacter(event_id);
if (chara == nullptr) {
return true;
}
int& event_id = _state.easyrpg_parameters[0];
int& failure_limit = _state.easyrpg_parameters[1];
int& output_var = _state.easyrpg_parameters[2];

if (!_state.easyrpg_active) {
event_id = ValueOrVariable(com.parameters[0], com.parameters[1]);

if (com.parameters.size() >= 4) {
failure_limit = ValueOrVariable(com.parameters[2], com.parameters[3]);
}

int failure_limit = 0;
if (com.parameters.size() >= 4) {
failure_limit = ValueOrVariable(com.parameters[2], com.parameters[3]);
if (com.parameters.size() >= 6) {
output_var = ValueOrVariable(com.parameters[4], com.parameters[5]);
}
}

int output_var = 0;
if (com.parameters.size() >= 6) {
failure_limit = ValueOrVariable(com.parameters[4], com.parameters[5]);
_state.easyrpg_active = false;

Game_Character* chara = GetCharacter(event_id);
if (chara == nullptr) {
return true;
}

bool exists = chara->IsMoveRouteOverwritten();
Expand All @@ -817,6 +825,7 @@ bool Game_Interpreter_Map::CommandEasyRpgWaitForSingleMovement(lcf::rpg::EventCo
// !finished
if (failure_limit == 0 || chara->GetMoveFailureCount() < failure_limit) {
// Below threshold: Yield
_state.easyrpg_active = true;
return false;
}

Expand Down

0 comments on commit 42903a9

Please sign in to comment.