MCPcopy Create free account
hub / github.com/EasyRPG/Player / CommandEasyRpgWaitForSingleMovement

Method CommandEasyRpgWaitForSingleMovement

src/game_interpreter_map.cpp:975–1026  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

973}
974
975bool Game_Interpreter_Map::CommandEasyRpgWaitForSingleMovement(lcf::rpg::EventCommand const& com) {
976 if (!Player::HasEasyRpgExtensions()) {
977 return true;
978 }
979
980 _state.easyrpg_parameters.resize(3);
981
982 auto& event_id = _state.easyrpg_parameters[0];
983 auto& failure_limit = _state.easyrpg_parameters[1];
984 auto& output_var = _state.easyrpg_parameters[2];
985
986 if (!_state.easyrpg_active) {
987 event_id = ValueOrVariable(com.parameters[0], com.parameters[1]);
988 failure_limit = ValueOrVariable(com.parameters[2], com.parameters[3]);
989 output_var = ValueOrVariable(com.parameters[4], com.parameters[5]);
990 }
991
992 _state.easyrpg_active = false;
993
994 Game_Character* chara = GetCharacter(event_id, "EasyRpgWaitForSingleMovement");
995 if (chara == nullptr) {
996 return true;
997 }
998
999 bool exists = chara->IsMoveRouteOverwritten();
1000 bool finished = chara->IsMoveRouteFinished();
1001
1002 if (!exists || (exists && finished)) {
1003 if (output_var > 0) {
1004 // Move route inexistant or ended: Report success (1)
1005 Main_Data::game_variables->Set(output_var, 1);
1006 Game_Map::SetNeedRefresh(true);
1007 }
1008 return true;
1009 }
1010
1011 // !finished
1012 if (failure_limit == 0 || chara->GetMoveFailureCount() < failure_limit) {
1013 // Below threshold: Yield
1014 _state.easyrpg_active = true;
1015 return false;
1016 }
1017
1018 // Cancel move route and report abort (0)
1019 chara->CancelMoveRoute();
1020 if (output_var > 0) {
1021 Main_Data::game_variables->Set(output_var, 0);
1022 Game_Map::SetNeedRefresh(true);
1023 }
1024
1025 return true;
1026}

Callers

nothing calls this directly

Calls 5

IsMoveRouteFinishedMethod · 0.80
GetMoveFailureCountMethod · 0.80
CancelMoveRouteMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected