Skip to content

Commit

Permalink
TriggerEventAt: Add flag to configure "Face Player" behaviour
Browse files Browse the repository at this point in the history
The "Triggered By Decision Key" state is now forwarded from the source event.

Suggested by @florianessl
  • Loading branch information
Ghabry committed Jan 20, 2025
1 parent a557aa6 commit 9913714
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
10 changes: 9 additions & 1 deletion src/game_interpreter_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,15 @@ bool Game_Interpreter_Map::CommandEasyRpgTriggerEventAt(lcf::rpg::EventCommand c
int x = ValueOrVariable(com.parameters[0], com.parameters[1]);
int y = ValueOrVariable(com.parameters[2], com.parameters[3]);

Main_Data::game_player->TriggerEventAt(x, y);
// backwards compatible with old (shorter) command
bool face_player = true;

if (com.parameters.size() > 4) {
int flags = com.parameters[4];
face_player = (flags & 1) > 0;
}

Main_Data::game_player->TriggerEventAt(x, y, GetFrame().triggered_by_decision_key, face_player);

return true;
}
Expand Down
12 changes: 6 additions & 6 deletions src/game_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ bool Game_Player::CheckActionEvent() {
return result || got_action;
}

bool Game_Player::CheckEventTriggerHere(TriggerSet triggers, bool triggered_by_decision_key) {
bool Game_Player::CheckEventTriggerHere(TriggerSet triggers, bool triggered_by_decision_key, bool face_player) {
if (InAirship()) {
return false;
}
Expand All @@ -444,13 +444,13 @@ bool Game_Player::CheckEventTriggerHere(TriggerSet triggers, bool triggered_by_d
&& trigger >= 0
&& triggers[trigger]) {
SetEncounterCalling(false);
result |= ev.ScheduleForegroundExecution(triggered_by_decision_key, true);
result |= ev.ScheduleForegroundExecution(triggered_by_decision_key, face_player);
}
}
return result;
}

bool Game_Player::CheckEventTriggerThere(TriggerSet triggers, int x, int y, bool triggered_by_decision_key) {
bool Game_Player::CheckEventTriggerThere(TriggerSet triggers, int x, int y, bool triggered_by_decision_key, bool face_player) {
if (InAirship()) {
return false;
}
Expand All @@ -465,7 +465,7 @@ bool Game_Player::CheckEventTriggerThere(TriggerSet triggers, int x, int y, bool
&& trigger >= 0
&& triggers[trigger]) {
SetEncounterCalling(false);
result |= ev.ScheduleForegroundExecution(triggered_by_decision_key, true);
result |= ev.ScheduleForegroundExecution(triggered_by_decision_key, face_player);
}
}
return result;
Expand Down Expand Up @@ -927,6 +927,6 @@ void Game_Player::UpdatePan() {
data()->pan_current_y -= dy;
}

bool Game_Player::TriggerEventAt(int x, int y) {
return CheckEventTriggerThere({ lcf::rpg::EventPage::Trigger_action }, x, y, true);
bool Game_Player::TriggerEventAt(int x, int y, bool triggered_by_decision_key, bool face_player) {
return CheckEventTriggerThere({ lcf::rpg::EventPage::Trigger_action }, x, y, triggered_by_decision_key, face_player);
}
6 changes: 3 additions & 3 deletions src/game_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Game_Player : public Game_PlayerBase {
TeleportTarget GetTeleportTarget() const;
void ResetTeleportTarget(TeleportTarget tt = {});

bool TriggerEventAt(int x, int y);
bool TriggerEventAt(int x, int y, bool triggered_by_decision_key, bool face_player);

/**
* Sets the map, position and direction that the game player must have after the teleport is over
Expand Down Expand Up @@ -163,8 +163,8 @@ class Game_Player : public Game_PlayerBase {
void UpdatePan();
void UpdateEncounterSteps();
bool CheckActionEvent();
bool CheckEventTriggerHere(TriggerSet triggers, bool triggered_by_decision_key);
bool CheckEventTriggerThere(TriggerSet triggers, int x, int y, bool triggered_by_decision_key);
bool CheckEventTriggerHere(TriggerSet triggers, bool triggered_by_decision_key, bool face_player = true);
bool CheckEventTriggerThere(TriggerSet triggers, int x, int y, bool triggered_by_decision_key, bool face_player = true);
bool GetOnVehicle();
bool GetOffVehicle();
bool UpdateAirship();
Expand Down

0 comments on commit 9913714

Please sign in to comment.