Skip to content

Commit

Permalink
Fix for events with stop_count and collision trigger
Browse files Browse the repository at this point in the history
When an event has layer=same and trigger=collision and fails
to step onto the player's position, stop_count gets reset to 0.
  • Loading branch information
fmatthew5876 committed Apr 3, 2019
1 parent b7106b7 commit 031fcd3
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/game_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,9 @@ void Game_Event::OnMoveFailed(int x, int y) {

if (Main_Data::game_player->IsInPosition(x, y)) {
SetAsWaitingForegroundExecution(false, false);
// Events with trigger collision and layer same always reset their
// stop_count when they fail movement to a tile that the player inhabits.
SetStopCount(0);
return;
}
}
Expand Down Expand Up @@ -442,16 +445,6 @@ void Game_Event::MoveTypeCycle(int default_dir) {
Move(move_dir, MoveOption::IgnoreIfCantMove);

if (move_failed) {
if (trigger == RPG::EventPage::Trigger_collision) {
int new_x = Game_Map::XwithDirection(GetX(), move_dir);
int new_y = Game_Map::YwithDirection(GetY(), move_dir);

if (Main_Data::game_player->IsInPosition(new_x, new_y)) {
SetStopCount(0);
return;
}
}

if (GetStopCount() >= GetMaxStopCount() + 20) {
if (GetStopCount() >= GetMaxStopCount() + 60) {
Move(ReverseDir(move_dir));
Expand Down

0 comments on commit 031fcd3

Please sign in to comment.