Skip to content

Commit

Permalink
Merge pull request #3337 from Ghabry/trigger-event-at
Browse files Browse the repository at this point in the history
TriggerEventAt: Add flag to configure "Face Player" behaviour
  • Loading branch information
fdelapena authored Jan 22, 2025
2 parents e374637 + a43df20 commit 8296199
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 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
2 changes: 1 addition & 1 deletion src/tilemap_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ void TilemapLayer::RecalculateAutotile(int x, int y, int tile_id) {
return neighbors;
};

auto processBlock = [&](int blockType, int blockStride, int blockBase, auto isSameAutotileFn) {
auto processBlock = [&](int /*blockType*/, int blockStride, int blockBase, auto isSameAutotileFn) {
uint8_t neighbors = calculateNeighbors(isSameAutotileFn);
int block = (tile_id - blockBase) / blockStride;
int variant = AUTOTILE_D_VARIANTS_MAP.at(neighbors);
Expand Down

0 comments on commit 8296199

Please sign in to comment.