From 97a66020ca5b3c51ec4d385d276d59b3a435db83 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Thu, 18 Jan 2024 22:40:58 +0000 Subject: [PATCH] Fixed being able to jump over a ledge the wrong way if it's on the edge of a connected map --- Data/Scripts/004_Game classes/004_Game_Map.rb | 12 ++++++------ .../004_Game classes/005_Game_MapFactory.rb | 8 ++++---- .../Scripts/004_Game classes/006_Game_Character.rb | 14 +++++++------- Data/Scripts/004_Game classes/008_Game_Player.rb | 8 ++++---- .../021_Compiler/004_Compiler_MapsAndEvents.rb | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Data/Scripts/004_Game classes/004_Game_Map.rb b/Data/Scripts/004_Game classes/004_Game_Map.rb index 3fda78303..552da9363 100644 --- a/Data/Scripts/004_Game classes/004_Game_Map.rb +++ b/Data/Scripts/004_Game classes/004_Game_Map.rb @@ -139,9 +139,9 @@ class Game_Map return x >= -10 && x <= width + 10 && y >= -10 && y <= height + 10 end - def passable?(x, y, d, self_event = nil) + def passable?(x, y, dir, self_event = nil) return false if !valid?(x, y) - bit = (1 << ((d / 2) - 1)) & 0x0f + bit = (1 << ((dir / 2) - 1)) & 0x0f events.each_value do |event| next if event.tile_id <= 0 next if event == self_event @@ -153,11 +153,11 @@ class Game_Map return false if passage & 0x0f == 0x0f return true if @priorities[event.tile_id] == 0 end - return playerPassable?(x, y, d, self_event) if self_event == $game_player + return playerPassable?(x, y, dir, self_event) if self_event == $game_player # All other events newx = x newy = y - case d + case dir when 1 newx -= 1 newy += 1 @@ -219,8 +219,8 @@ class Game_Map return true end - def playerPassable?(x, y, d, self_event = nil) - bit = (1 << ((d / 2) - 1)) & 0x0f + def playerPassable?(x, y, dir, self_event = nil) + bit = (1 << ((dir / 2) - 1)) & 0x0f [2, 1, 0].each do |i| tile_id = data[x, y, i] next if tile_id == 0 diff --git a/Data/Scripts/004_Game classes/005_Game_MapFactory.rb b/Data/Scripts/004_Game classes/005_Game_MapFactory.rb index 8e0b4bbf5..b2a414d01 100644 --- a/Data/Scripts/004_Game classes/005_Game_MapFactory.rb +++ b/Data/Scripts/004_Game classes/005_Game_MapFactory.rb @@ -154,14 +154,14 @@ class PokemonMapFactory end # Similar to Game_Player#passable?, but supports map connections - def isPassableFromEdge?(x, y) + def isPassableFromEdge?(x, y, dir = 0) return true if $game_map.valid?(x, y) newmap = getNewMap(x, y, $game_map.map_id) return false if !newmap - return isPassable?(newmap[0].map_id, newmap[1], newmap[2]) + return isPassable?(newmap[0].map_id, newmap[1], newmap[2], dir) end - def isPassable?(mapID, x, y, thisEvent = nil) + def isPassable?(mapID, x, y, dir = 0, thisEvent = nil) thisEvent = $game_player if !thisEvent map = getMapNoAdd(mapID) return false if !map @@ -169,7 +169,7 @@ class PokemonMapFactory return true if thisEvent.through # Check passability of tile return true if $DEBUG && Input.press?(Input::CTRL) && thisEvent.is_a?(Game_Player) - return false if !map.passable?(x, y, 0, thisEvent) + return false if !map.passable?(x, y, dir, thisEvent) # Check passability of event(s) in that spot map.events.each_value do |event| next if event == thisEvent || !event.at_coordinate?(x, y) diff --git a/Data/Scripts/004_Game classes/006_Game_Character.rb b/Data/Scripts/004_Game classes/006_Game_Character.rb index 9de49c288..475f43a37 100644 --- a/Data/Scripts/004_Game classes/006_Game_Character.rb +++ b/Data/Scripts/004_Game classes/006_Game_Character.rb @@ -234,17 +234,17 @@ class Game_Character #============================================================================= # Passability #============================================================================= - def passable?(x, y, d, strict = false) - new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0) - new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0) + def passable?(x, y, dir, strict = false) + new_x = x + (dir == 6 ? 1 : dir == 4 ? -1 : 0) + new_y = y + (dir == 2 ? 1 : dir == 8 ? -1 : 0) return false unless self.map.valid?(new_x, new_y) return true if @through if strict - return false unless self.map.passableStrict?(x, y, d, self) - return false unless self.map.passableStrict?(new_x, new_y, 10 - d, self) + return false unless self.map.passableStrict?(x, y, dir, self) + return false unless self.map.passableStrict?(new_x, new_y, 10 - dir, self) else - return false unless self.map.passable?(x, y, d, self) - return false unless self.map.passable?(new_x, new_y, 10 - d, self) + return false unless self.map.passable?(x, y, dir, self) + return false unless self.map.passable?(new_x, new_y, 10 - dir, self) end self.map.events.each_value do |event| next if self == event || !event.at_coordinate?(new_x, new_y) || event.through diff --git a/Data/Scripts/004_Game classes/008_Game_Player.rb b/Data/Scripts/004_Game classes/008_Game_Player.rb index 8f49870b9..e285ce7a1 100644 --- a/Data/Scripts/004_Game classes/008_Game_Player.rb +++ b/Data/Scripts/004_Game classes/008_Game_Player.rb @@ -235,15 +235,15 @@ class Game_Player < Game_Character # y : y-coordinate # d : direction (0, 2, 4, 6, 8) # * 0 = Determines if all directions are impassable (for jumping) - def passable?(x, y, d, strict = false) + def passable?(x, y, dir, strict = false) # Get new coordinates - new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0) - new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0) + new_x = x + (dir == 6 ? 1 : dir == 4 ? -1 : 0) + new_y = y + (dir == 2 ? 1 : dir == 8 ? -1 : 0) # If coordinates are outside of map return false if !$game_map.validLax?(new_x, new_y) if !$game_map.valid?(new_x, new_y) return false if !$map_factory - return $map_factory.isPassableFromEdge?(new_x, new_y) + return $map_factory.isPassableFromEdge?(new_x, new_y, 10 - dir) end # If debug mode is ON and Ctrl key was pressed return true if $DEBUG && Input.press?(Input::CTRL) diff --git a/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb b/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb index cb302adb0..26ba87d25 100644 --- a/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb +++ b/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb @@ -922,7 +922,7 @@ module Compiler if thisEvent.pages[0].graphic.character_name == "" && thisEvent.pages[0].list.length <= 12 && thisEvent.pages[0].list.any? { |cmd| cmd.code == 201 } && # Transfer Player -# mapData.isPassable?(mapID,thisEvent.x,thisEvent.y+1) && +# mapData.isPassable?(mapID, thisEvent.x, thisEvent.y + 1) && mapData.isPassable?(mapID, thisEvent.x, thisEvent.y) && !mapData.isPassable?(mapID, thisEvent.x - 1, thisEvent.y) && !mapData.isPassable?(mapID, thisEvent.x + 1, thisEvent.y) &&