Skip to content

Commit

Permalink
Maniac Patch: Support Common Event call extensions
Browse files Browse the repository at this point in the history
Fix #2949
  • Loading branch information
Ghabry committed Apr 12, 2023
1 parent 07328a0 commit 043ce89
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/game_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3805,8 +3805,19 @@ bool Game_Interpreter::CommandCallEvent(lcf::rpg::EventCommand const& com) { //
int event_page;

switch (com.parameters[0]) {
case 0: { // Common Event
evt_id = com.parameters[1];
case 0:
case 3:
case 4: { // Common Event
if (com.parameters[0] == 0) {
evt_id = com.parameters[1];
} else if (com.parameters[0] == 3 && Player::IsPatchManiac()) {
evt_id = Main_Data::game_variables->Get(com.parameters[1]);
} else if (com.parameters[0] == 4 && Player::IsPatchManiac()) {
evt_id = Main_Data::game_variables->GetIndirect(com.parameters[1]);
} else {
return true;
}

Game_CommonEvent* common_event = lcf::ReaderUtil::GetElement(Game_Map::GetCommonEvents(), evt_id);
if (!common_event) {
Output::Warning("CallEvent: Can't call invalid common event {}", evt_id);
Expand All @@ -3826,19 +3837,19 @@ bool Game_Interpreter::CommandCallEvent(lcf::rpg::EventCommand const& com) { //
event_page = Main_Data::game_variables->Get(com.parameters[2]);
break;
default:
return false;
return true;
}

Game_Event* event = static_cast<Game_Event*>(GetCharacter(evt_id));
if (!event) {
Output::Warning("CallEvent: Can't call non-existant event {}", evt_id);
return false;
Output::Warning("CallEvent: Can't call non-existent event {}", evt_id);
return true;
}

const lcf::rpg::EventPage* page = event->GetPage(event_page);
if (!page) {
Output::Warning("CallEvent: Can't call non-existant page {} of event {}", event_page, evt_id);
return false;
Output::Warning("CallEvent: Can't call non-existent page {} of event {}", event_page, evt_id);
return true;
}

Push(page->event_commands, event->GetId(), false);
Expand Down

0 comments on commit 043ce89

Please sign in to comment.