From 875e01226a2cac6ec3d4b6d702281c0f13235725 Mon Sep 17 00:00:00 2001 From: Ghabry Date: Sun, 3 Nov 2024 21:42:12 +0100 Subject: [PATCH] Relocate CallMovementAction to the Map interpreter --- src/game_interpreter.cpp | 73 ----------------------------------- src/game_interpreter.h | 1 - src/game_interpreter_map.cpp | 74 ++++++++++++++++++++++++++++++++++++ src/game_interpreter_map.h | 1 + 4 files changed, 75 insertions(+), 74 deletions(-) diff --git a/src/game_interpreter.cpp b/src/game_interpreter.cpp index 476ad0bb59..afceaa5bf9 100644 --- a/src/game_interpreter.cpp +++ b/src/game_interpreter.cpp @@ -786,8 +786,6 @@ bool Game_Interpreter::ExecuteCommand(lcf::rpg::EventCommand const& com) { return CommandManiacControlStrings(com); case Cmd::Maniac_CallCommand: return CommandManiacCallCommand(com); - case Cmd::EasyRpg_CallMovementAction: - return CommandCallMovement(com); case Cmd::EasyRpg_SetInterpreterFlag: return CommandEasyRpgSetInterpreterFlag(com); case Cmd::EasyRpg_CloneMapEvent: @@ -5081,77 +5079,6 @@ bool Game_Interpreter::CommandEasyRpgDestroyMapEvent(lcf::rpg::EventCommand cons return true; } -bool Game_Interpreter::CommandCallMovement(lcf::rpg::EventCommand const& com) { - // CommandSetMovement("moveCommand",[useVarID, ID, useVarOutput, output]) - - int eventID = ValueOrVariable(com.parameters[0], com.parameters[1]); - int outputParam = ValueOrVariable(com.parameters[2], com.parameters[3]); - int outputParamB = ValueOrVariable(com.parameters[4], com.parameters[5]); - - Game_Character* event = GetCharacter(eventID); - Game_Character* target; - - std::string moveCommand = ToString(com.string); - std::string outputString = event->GetSpriteName(); - - std::size_t pos = moveCommand.find('/'); - - if (pos != std::string::npos) { - outputString = moveCommand.substr(pos + 1); - moveCommand = moveCommand.substr(0, pos); - } - - if (moveCommand == "SetMoveSpeed")event->SetMoveSpeed(outputParam); - if (moveCommand == "SetMoveFrequency")event->SetMoveFrequency(outputParam); - if (moveCommand == "SetTransparency")event->SetTransparency(outputParam); - if (moveCommand == "SetAnimationType")event->SetAnimationType(static_cast(outputParam)); - - - if (moveCommand == "Event2Event") { - target = GetCharacter(outputParam); - if (!target) { - return true; - } - event->SetFacing(target->GetFacing()); - event->SetDirection(target->GetDirection()); - event->SetX(target->GetX()); - event->SetY(target->GetY()); - } - - if (moveCommand == "FaceTowards"){ - if(!event->IsMoving()) { - target = GetCharacter(outputParam); - if (!target) { - return true; - } - event->TurnTowardCharacter(*target); - event->UpdateFacing(); - } - } - - if (moveCommand == "FaceAway"){ - if (!event->IsMoving()) { - target = GetCharacter(outputParam); - if (!target) { - return true; - } - event->TurnAwayFromCharacter(*target); - event->UpdateFacing(); - } - } - - if (moveCommand == "SetFacingLocked")event->SetFacingLocked(outputParam); - if (moveCommand == "SetLayer")event->SetLayer(outputParam); - if (moveCommand == "SetFlying")event->SetFlying(outputParam); //FIXME: I wish any event could imitate an airship, lacks more work. - if (moveCommand == "ChangeCharset")event->SetSpriteGraphic(outputString,outputParam); // syntax ChangeCharset/actor1 - - if (moveCommand == "JumpTo")event->Game_Character::Jump(outputParam, outputParamB); - - if (moveCommand == "StopMovement")event->CancelMoveRoute(); - - return true; -} - Game_Interpreter& Game_Interpreter::GetForegroundInterpreter() { return Game_Battle::IsBattleRunning() ? Game_Battle::GetInterpreter() diff --git a/src/game_interpreter.h b/src/game_interpreter.h index e382e8e0a5..2955dc3ff7 100644 --- a/src/game_interpreter.h +++ b/src/game_interpreter.h @@ -300,7 +300,6 @@ class Game_Interpreter : public Game_BaseInterpreterContext bool CommandEasyRpgSetInterpreterFlag(lcf::rpg::EventCommand const& com); bool CommandEasyRpgCloneMapEvent(lcf::rpg::EventCommand const& com); bool CommandEasyRpgDestroyMapEvent(lcf::rpg::EventCommand const& com); - bool CommandCallMovement(lcf::rpg::EventCommand const& com); int DecodeInt(lcf::DBArray::const_iterator& it); const std::string DecodeString(lcf::DBArray::const_iterator& it); diff --git a/src/game_interpreter_map.cpp b/src/game_interpreter_map.cpp index 37269f0b66..1df583c111 100644 --- a/src/game_interpreter_map.cpp +++ b/src/game_interpreter_map.cpp @@ -234,6 +234,8 @@ bool Game_Interpreter_Map::ExecuteCommand(lcf::rpg::EventCommand const& com) { return CommandToggleAtbMode(com); case Cmd::EasyRpg_TriggerEventAt: return CommandEasyRpgTriggerEventAt(com); + case Cmd::EasyRpg_CallMovementAction: + return CommandEasyRpgCallMovementAction(com); case Cmd::EasyRpg_WaitForSingleMovement: return CommandEasyRpgWaitForSingleMovement(com); default: @@ -832,6 +834,78 @@ bool Game_Interpreter_Map::CommandEasyRpgTriggerEventAt(lcf::rpg::EventCommand c return true; } + +bool Game_Interpreter_Map::CommandEasyRpgCallMovementAction(lcf::rpg::EventCommand const& com) { + // CommandSetMovement("moveCommand",[useVarID, ID, useVarOutput, output]) + + int eventID = ValueOrVariable(com.parameters[0], com.parameters[1]); + int outputParam = ValueOrVariable(com.parameters[2], com.parameters[3]); + int outputParamB = ValueOrVariable(com.parameters[4], com.parameters[5]); + + Game_Character* event = GetCharacter(eventID); + Game_Character* target; + + std::string moveCommand = ToString(com.string); + std::string outputString = event->GetSpriteName(); + + std::size_t pos = moveCommand.find('/'); + + if (pos != std::string::npos) { + outputString = moveCommand.substr(pos + 1); + moveCommand = moveCommand.substr(0, pos); + } + + if (moveCommand == "SetMoveSpeed")event->SetMoveSpeed(outputParam); + if (moveCommand == "SetMoveFrequency")event->SetMoveFrequency(outputParam); + if (moveCommand == "SetTransparency")event->SetTransparency(outputParam); + if (moveCommand == "SetAnimationType")event->SetAnimationType(static_cast(outputParam)); + + + if (moveCommand == "Event2Event") { + target = GetCharacter(outputParam); + if (!target) { + return true; + } + event->SetFacing(target->GetFacing()); + event->SetDirection(target->GetDirection()); + event->SetX(target->GetX()); + event->SetY(target->GetY()); + } + + if (moveCommand == "FaceTowards"){ + if(!event->IsMoving()) { + target = GetCharacter(outputParam); + if (!target) { + return true; + } + event->TurnTowardCharacter(*target); + event->UpdateFacing(); + } + } + + if (moveCommand == "FaceAway"){ + if (!event->IsMoving()) { + target = GetCharacter(outputParam); + if (!target) { + return true; + } + event->TurnAwayFromCharacter(*target); + event->UpdateFacing(); + } + } + + if (moveCommand == "SetFacingLocked")event->SetFacingLocked(outputParam); + if (moveCommand == "SetLayer")event->SetLayer(outputParam); + if (moveCommand == "SetFlying")event->SetFlying(outputParam); //FIXME: I wish any event could imitate an airship, lacks more work. + if (moveCommand == "ChangeCharset")event->SetSpriteGraphic(outputString,outputParam); // syntax ChangeCharset/actor1 + + if (moveCommand == "JumpTo")event->Game_Character::Jump(outputParam, outputParamB); + + if (moveCommand == "StopMovement")event->CancelMoveRoute(); + + return true; +} + bool Game_Interpreter_Map::CommandEasyRpgWaitForSingleMovement(lcf::rpg::EventCommand const& com) { if (!Player::HasEasyRpgExtensions()) { return true; diff --git a/src/game_interpreter_map.h b/src/game_interpreter_map.h index e94dd0dc96..60ea07fd3b 100644 --- a/src/game_interpreter_map.h +++ b/src/game_interpreter_map.h @@ -85,6 +85,7 @@ class Game_Interpreter_Map : public Game_Interpreter bool CommandToggleAtbMode(lcf::rpg::EventCommand const& com); bool CommandEasyRpgTriggerEventAt(lcf::rpg::EventCommand const& com); + bool CommandEasyRpgCallMovementAction(lcf::rpg::EventCommand const& com); bool CommandEasyRpgWaitForSingleMovement(lcf::rpg::EventCommand const& com); AsyncOp ContinuationShowInnStart(int indent, int choice_result, int price);