@@ -821,6 +821,10 @@ bool Game_Interpreter::ExecuteCommand(lcf::rpg::EventCommand const& com) {
821821 return CommandManiacSetGameOption (com);
822822 case Cmd::Maniac_CallCommand:
823823 return CommandManiacCallCommand (com);
824+ case static_cast <Game_Interpreter::Cmd>(2050 ): // Cmd::EasyRpg_CallMovement
825+ return CommandCallMovement (com);
826+ case static_cast <Game_Interpreter::Cmd>(2051 ): // Cmd::EasyRpg_WaitForMovement
827+ return CommandWaitForMovement (com);
824828 default :
825829 return true ;
826830 }
@@ -4643,6 +4647,87 @@ bool Game_Interpreter::CommandManiacCallCommand(lcf::rpg::EventCommand const&) {
46434647 return true ;
46444648}
46454649
4650+ bool Game_Interpreter::CommandCallMovement (lcf::rpg::EventCommand const & com) {
4651+ // CommandSetMovement("moveCommand",[useVarID, ID, useVarOutput, output])
4652+
4653+ int eventID = ValueOrVariable (com.parameters [0 ], com.parameters [1 ]);
4654+ int outputParam = ValueOrVariable (com.parameters [2 ], com.parameters [3 ]);
4655+
4656+ Game_Character* event = GetCharacter (eventID);
4657+ Game_Character* target;
4658+
4659+ std::string moveCommand = ToString (com.string );
4660+ std::string outputString = event->GetSpriteName ();
4661+
4662+ std::size_t pos = moveCommand.find (' /' );
4663+
4664+ if (pos != std::string::npos) {
4665+ outputString = moveCommand.substr (pos + 1 );
4666+ moveCommand = moveCommand.substr (0 , pos);
4667+ }
4668+
4669+ if (moveCommand == " SetMoveSpeed" )event->SetMoveSpeed (outputParam);
4670+ if (moveCommand == " SetMoveFrequency" )event->SetMoveFrequency (outputParam);
4671+ if (moveCommand == " SetTransparency" )event->SetTransparency (outputParam);
4672+
4673+ if (moveCommand == " Event2Event" ) {
4674+ target = GetCharacter (outputParam);
4675+ event->SetFacing (target->GetFacing ());
4676+ event->SetDirection (target->GetDirection ());
4677+ event->SetX (target->GetX ());
4678+ event->SetY (target->GetY ());
4679+ }
4680+
4681+ if (moveCommand == " SetFacingLocked" )event->SetFacingLocked (outputParam);
4682+ if (moveCommand == " SetLayer" )event->SetLayer (outputParam);
4683+ if (moveCommand == " SetFlying" )event->SetFlying (outputParam); // FIXME: I wish any event could imitate an airship, lacks more work.
4684+ if (moveCommand == " ChangeCharset" )event->SetSpriteGraphic (outputString,outputParam); // syntax ChangeCharset/actor1
4685+
4686+ if (moveCommand == " StopMovement" )event->CancelMoveRoute ();
4687+
4688+ return true ;
4689+ }
4690+
4691+ bool Game_Interpreter::CommandWaitForMovement (lcf::rpg::EventCommand const & com) {
4692+ // CommandWaitForMovement(useVarID, ID)
4693+
4694+ // Needed for ShowChoice
4695+ auto * frame = GetFramePtr ();
4696+ const auto & list = frame->commands ;
4697+ auto & index = frame->current_command ;
4698+
4699+ // Retrieve event ID
4700+ int eventID = ValueOrVariable (com.parameters [0 ], com.parameters [1 ]);
4701+ if (eventID == 0 )
4702+ eventID = GetCurrentEventId ();
4703+
4704+ // Get the character associated with the event ID
4705+ Game_Character* ev = GetCharacter (eventID);
4706+
4707+ // Check if movement exists and if it's currently running
4708+ bool movementExists = !ev->GetMoveRoute ().move_commands .empty ();
4709+ bool movementIsRunning = movementExists && (ev->IsMoveRouteOverwritten () && !ev->IsMoveRouteFinished ());
4710+
4711+ int i = frame->current_command + 1 ;
4712+
4713+ // Check the next command for a specific condition
4714+ const auto & cmd = list[i];
4715+ const int32_t failBranch = static_cast <int >(Cmd::ShowChoiceOption);
4716+
4717+ // If the next command is "Fails to move x times" and the character is stuck, cancel movement
4718+ if (cmd.code == failBranch && cmd.string == " Fails to move x times" )
4719+ if (ev->isStuck (cmd.parameters [0 ])) {
4720+ ev->failsMove = 0 ;
4721+ ev->CancelMoveRoute ();
4722+ frame->current_command = i + 1 ;
4723+ return true ;
4724+ }
4725+
4726+ // Return false if movement is still in progress
4727+ if (!movementIsRunning) ev->failsMove = 0 ;
4728+ return !movementIsRunning;
4729+ }
4730+
46464731Game_Interpreter& Game_Interpreter::GetForegroundInterpreter () {
46474732 return Game_Battle::IsBattleRunning ()
46484733 ? Game_Battle::GetInterpreter ()
0 commit comments