From e56b7a1789a91edb0db6420705607e7813323aab Mon Sep 17 00:00:00 2001 From: Mauro Junior <45118493+jetrotal@users.noreply.github.com> Date: Tue, 17 Dec 2024 23:39:40 -0300 Subject: [PATCH 1/2] Erase Event - Erase Event By ID + Recreate Event Option (Maniacs Feature) Another smaller update: Events can be disabled and enabled again through maniacs patch. It also allows targeting event by ID instead of only erasing the caller itself. ```js //TPC SYNTAX @ev[2].erase @wait .input v[1] = 2 @ev[ v[1] ].return ``` --- src/game_interpreter.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/game_interpreter.cpp b/src/game_interpreter.cpp index 879a296e4d..6383a8ef33 100644 --- a/src/game_interpreter.cpp +++ b/src/game_interpreter.cpp @@ -3850,11 +3850,21 @@ bool Game_Interpreter::CommandEndLoop(lcf::rpg::EventCommand const& com) { // co return true; } -bool Game_Interpreter::CommandEraseEvent(lcf::rpg::EventCommand const& /* com */) { // code 12320 +bool Game_Interpreter::CommandEraseEvent(lcf::rpg::EventCommand const& com) { // code 12320 + int event_id = 0; // default rm values + bool is_active = 0; // In Vanilla RM event is always itself and it always becomes inactive + + if (Player::IsPatchManiac()) { + event_id = ValueOrVariableBitfield(com.parameters[0], 1, com.parameters[2]); + is_active = com.parameters[1]; + } + auto& frame = GetFrame(); auto& index = frame.current_command; - auto event_id = GetThisEventId(); + if (event_id == 0) { + event_id = GetThisEventId(); + } // When a common event and not RPG2k3E engine ignore the call, otherwise // operate on last map_event @@ -3863,7 +3873,7 @@ bool Game_Interpreter::CommandEraseEvent(lcf::rpg::EventCommand const& /* com */ Game_Event* evnt = Game_Map::GetEvent(event_id); if (evnt) { - evnt->SetActive(false); + evnt->SetActive(is_active); // Parallel map events shall stop immediately if (!main_flag) { From a2e0cf26dc22635080b60c2dbb8a276d1a54f900 Mon Sep 17 00:00:00 2001 From: Mauro Junior <45118493+jetrotal@users.noreply.github.com> Date: Thu, 19 Dec 2024 04:44:49 -0300 Subject: [PATCH 2/2] Erase Event - propper conditions to avoid running useless code --- src/game_interpreter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game_interpreter.cpp b/src/game_interpreter.cpp index 6383a8ef33..a75472dd49 100644 --- a/src/game_interpreter.cpp +++ b/src/game_interpreter.cpp @@ -3854,7 +3854,7 @@ bool Game_Interpreter::CommandEraseEvent(lcf::rpg::EventCommand const& com) { // int event_id = 0; // default rm values bool is_active = 0; // In Vanilla RM event is always itself and it always becomes inactive - if (Player::IsPatchManiac()) { + if (Player::IsPatchManiac() && com.parameters.size() >= 3) { event_id = ValueOrVariableBitfield(com.parameters[0], 1, com.parameters[2]); is_active = com.parameters[1]; }