mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-08 13:44:59 +00:00
Fixed screen positioning bug when jumping over ledges near the top or left of a map
This commit is contained in:
@@ -763,26 +763,33 @@ class Game_Character
|
|||||||
@jump_speed_real = nil # Reset jump speed
|
@jump_speed_real = nil # Reset jump speed
|
||||||
@jump_count = Game_Map::REAL_RES_X / jump_speed_real # Number of frames to jump one tile
|
@jump_count = Game_Map::REAL_RES_X / jump_speed_real # Number of frames to jump one tile
|
||||||
end
|
end
|
||||||
@stop_count = 0
|
increase_steps
|
||||||
triggerLeaveTile
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def jumpForward
|
def jumpForward(distance = 1)
|
||||||
|
return false if distance == 0
|
||||||
|
old_x = @x
|
||||||
|
old_y = @y
|
||||||
case self.direction
|
case self.direction
|
||||||
when 2 then jump(0, 1) # down
|
when 2 then jump(0, distance) # down
|
||||||
when 4 then jump(-1, 0) # left
|
when 4 then jump(-distance, 0) # left
|
||||||
when 6 then jump(1, 0) # right
|
when 6 then jump(distance, 0) # right
|
||||||
when 8 then jump(0, -1) # up
|
when 8 then jump(0, -distance) # up
|
||||||
end
|
end
|
||||||
|
return @x != old_x || @y != old_y
|
||||||
end
|
end
|
||||||
|
|
||||||
def jumpBackward
|
def jumpBackward(distance = 1)
|
||||||
|
return false if distance == 0
|
||||||
|
old_x = @x
|
||||||
|
old_y = @y
|
||||||
case self.direction
|
case self.direction
|
||||||
when 2 then jump(0, -1) # down
|
when 2 then jump(0, -distance) # down
|
||||||
when 4 then jump(1, 0) # left
|
when 4 then jump(distance, 0) # left
|
||||||
when 6 then jump(-1, 0) # right
|
when 6 then jump(-distance, 0) # right
|
||||||
when 8 then jump(0, 1) # up
|
when 8 then jump(0, distance) # up
|
||||||
end
|
end
|
||||||
|
return @x != old_x || @y != old_y
|
||||||
end
|
end
|
||||||
|
|
||||||
def turn_generic(dir)
|
def turn_generic(dir)
|
||||||
@@ -926,12 +933,16 @@ class Game_Character
|
|||||||
@real_y = dest_y if @real_y < dest_y + 0.1
|
@real_y = dest_y if @real_y < dest_y + 0.1
|
||||||
end
|
end
|
||||||
# Refresh how far is left to travel in a jump
|
# Refresh how far is left to travel in a jump
|
||||||
if jumping?
|
was_jumping = jumping?
|
||||||
|
if was_jumping
|
||||||
@jump_count -= 1 if @jump_count > 0 # For stationary jumps only
|
@jump_count -= 1 if @jump_count > 0 # For stationary jumps only
|
||||||
@jump_distance_left = [(dest_x - @real_x).abs, (dest_y - @real_y).abs].max
|
@jump_distance_left = [(dest_x - @real_x).abs, (dest_y - @real_y).abs].max
|
||||||
end
|
end
|
||||||
# End of a step, so perform events that happen at this time
|
# End of a step, so perform events that happen at this time
|
||||||
if !jumping? && !moving?
|
if !jumping? && !moving?
|
||||||
|
if was_jumping && !(self.is_a?(Game_Player) && $PokemonGlobal.surfing && !$game_temp.ending_surf)
|
||||||
|
$scene.spriteset.addUserAnimation(Settings::DUST_ANIMATION_ID, @x, @y, true, 1)
|
||||||
|
end
|
||||||
EventHandlers.trigger(:on_step_taken, self)
|
EventHandlers.trigger(:on_step_taken, self)
|
||||||
calculate_bush_depth
|
calculate_bush_depth
|
||||||
@stopped_this_frame = true
|
@stopped_this_frame = true
|
||||||
|
|||||||
@@ -116,26 +116,39 @@ class Game_Player < Game_Character
|
|||||||
@bump_se = Graphics.frame_rate / 4
|
@bump_se = Graphics.frame_rate / 4
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_move_distance_to_stats(distance = 1)
|
||||||
|
if $PokemonGlobal&.diving || $PokemonGlobal&.surfing
|
||||||
|
$stats.distance_surfed += distance
|
||||||
|
elsif $PokemonGlobal&.bicycle
|
||||||
|
$stats.distance_cycled += distance
|
||||||
|
else
|
||||||
|
$stats.distance_walked += distance
|
||||||
|
end
|
||||||
|
$stats.distance_slid_on_ice += distance if $PokemonGlobal.ice_sliding
|
||||||
|
end
|
||||||
|
|
||||||
def move_generic(dir, turn_enabled = true)
|
def move_generic(dir, turn_enabled = true)
|
||||||
turn_generic(dir, true) if turn_enabled
|
turn_generic(dir, true) if turn_enabled
|
||||||
if !$game_temp.encounter_triggered
|
if !$game_temp.encounter_triggered
|
||||||
if can_move_in_direction?(dir)
|
if can_move_in_direction?(dir)
|
||||||
x_offset = (dir == 4) ? -1 : (dir == 6) ? 1 : 0
|
x_offset = (dir == 4) ? -1 : (dir == 6) ? 1 : 0
|
||||||
y_offset = (dir == 8) ? -1 : (dir == 2) ? 1 : 0
|
y_offset = (dir == 8) ? -1 : (dir == 2) ? 1 : 0
|
||||||
return if pbLedge(x_offset, y_offset)
|
# Jump over ledges
|
||||||
|
if pbFacingTerrainTag.ledge
|
||||||
|
if jumpForward(2)
|
||||||
|
pbSEPlay("Player jump")
|
||||||
|
increase_steps
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
# Jumping out of surfing back onto land
|
||||||
return if pbEndSurf(x_offset, y_offset)
|
return if pbEndSurf(x_offset, y_offset)
|
||||||
|
# General movement
|
||||||
turn_generic(dir, true)
|
turn_generic(dir, true)
|
||||||
if !$game_temp.encounter_triggered
|
if !$game_temp.encounter_triggered
|
||||||
@x += x_offset
|
@x += x_offset
|
||||||
@y += y_offset
|
@y += y_offset
|
||||||
if $PokemonGlobal&.diving || $PokemonGlobal&.surfing
|
add_move_distance_to_stats(x_offset.abs + y_offset.abs)
|
||||||
$stats.distance_surfed += 1
|
|
||||||
elsif $PokemonGlobal&.bicycle
|
|
||||||
$stats.distance_cycled += 1
|
|
||||||
else
|
|
||||||
$stats.distance_walked += 1
|
|
||||||
end
|
|
||||||
$stats.distance_slid_on_ice += 1 if $PokemonGlobal.ice_sliding
|
|
||||||
increase_steps
|
increase_steps
|
||||||
end
|
end
|
||||||
elsif !check_event_trigger_touch(dir)
|
elsif !check_event_trigger_touch(dir)
|
||||||
@@ -155,36 +168,10 @@ class Game_Player < Game_Character
|
|||||||
end
|
end
|
||||||
|
|
||||||
def jump(x_plus, y_plus)
|
def jump(x_plus, y_plus)
|
||||||
if x_plus != 0 || y_plus != 0
|
old_x = @x
|
||||||
if x_plus.abs > y_plus.abs
|
old_y = @y
|
||||||
(x_plus < 0) ? turn_left : turn_right
|
super
|
||||||
else
|
add_move_distance_to_stats(x_plus.abs + y_plus.abs) if @x != old_x || @y != old_y
|
||||||
(y_plus < 0) ? turn_up : turn_down
|
|
||||||
end
|
|
||||||
each_occupied_tile { |i, j| return if !passable?(i + x_plus, j + y_plus, 0) }
|
|
||||||
end
|
|
||||||
@x = @x + x_plus
|
|
||||||
@y = @y + y_plus
|
|
||||||
real_distance = Math.sqrt((x_plus * x_plus) + (y_plus * y_plus))
|
|
||||||
distance = [1, real_distance].max
|
|
||||||
@jump_peak = distance * Game_Map::TILE_HEIGHT * 3 / 8 # 3/4 of tile for ledge jumping
|
|
||||||
@jump_distance = [x_plus.abs * Game_Map::REAL_RES_X, y_plus.abs * Game_Map::REAL_RES_Y].max
|
|
||||||
@jump_distance_left = 1 # Just needs to be non-zero
|
|
||||||
if real_distance > 0 # Jumping to somewhere else
|
|
||||||
if $PokemonGlobal&.diving || $PokemonGlobal&.surfing
|
|
||||||
$stats.distance_surfed += x_plus.abs + y_plus.abs
|
|
||||||
elsif $PokemonGlobal&.bicycle
|
|
||||||
$stats.distance_cycled += x_plus.abs + y_plus.abs
|
|
||||||
else
|
|
||||||
$stats.distance_walked += x_plus.abs + y_plus.abs
|
|
||||||
end
|
|
||||||
@jump_count = 0
|
|
||||||
else # Jumping on the spot
|
|
||||||
@jump_speed_real = nil # Reset jump speed
|
|
||||||
@jump_count = Game_Map::REAL_RES_X / jump_speed_real # Number of frames to jump one tile
|
|
||||||
end
|
|
||||||
@stop_count = 0
|
|
||||||
triggerLeaveTile
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbTriggeredTrainerEvents(triggers, checkIfRunning = true, trainer_only = false)
|
def pbTriggeredTrainerEvents(triggers, checkIfRunning = true, trainer_only = false)
|
||||||
@@ -414,12 +401,6 @@ class Game_Player < Game_Character
|
|||||||
$game_temp.followers.update
|
$game_temp.followers.update
|
||||||
# Count down the time between allowed bump sounds
|
# Count down the time between allowed bump sounds
|
||||||
@bump_se -= 1 if @bump_se && @bump_se > 0
|
@bump_se -= 1 if @bump_se && @bump_se > 0
|
||||||
# Finish up dismounting from surfing
|
|
||||||
if $game_temp.ending_surf && !moving?
|
|
||||||
pbCancelVehicles
|
|
||||||
$game_temp.surf_base_coords = nil
|
|
||||||
$game_temp.ending_surf = false
|
|
||||||
end
|
|
||||||
update_event_triggering
|
update_event_triggering
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -514,18 +495,18 @@ class Game_Player < Game_Character
|
|||||||
# Track the player on-screen as they move.
|
# Track the player on-screen as they move.
|
||||||
def update_screen_position(last_real_x, last_real_y)
|
def update_screen_position(last_real_x, last_real_y)
|
||||||
return if self.map.scrolling? || !(@moved_last_frame || @moved_this_frame)
|
return if self.map.scrolling? || !(@moved_last_frame || @moved_this_frame)
|
||||||
if (@real_x < last_real_x && @real_x - $game_map.display_x < SCREEN_CENTER_X) ||
|
if (@real_x < last_real_x && @real_x < $game_map.display_x + SCREEN_CENTER_X) ||
|
||||||
(@real_x > last_real_x && @real_x - $game_map.display_x > SCREEN_CENTER_X)
|
(@real_x > last_real_x && @real_x > $game_map.display_x + SCREEN_CENTER_X)
|
||||||
self.map.display_x += @real_x - last_real_x
|
self.map.display_x += @real_x - last_real_x
|
||||||
end
|
end
|
||||||
if (@real_y < last_real_y && @real_y - $game_map.display_y < SCREEN_CENTER_Y) ||
|
if (@real_y < last_real_y && @real_y < $game_map.display_y + SCREEN_CENTER_Y) ||
|
||||||
(@real_y > last_real_y && @real_y - $game_map.display_y > SCREEN_CENTER_Y)
|
(@real_y > last_real_y && @real_y > $game_map.display_y + SCREEN_CENTER_Y)
|
||||||
self.map.display_y += @real_y - last_real_y
|
self.map.display_y += @real_y - last_real_y
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_event_triggering
|
def update_event_triggering
|
||||||
return if moving? || $PokemonGlobal.ice_sliding
|
return if moving? || jumping? || $PokemonGlobal.ice_sliding
|
||||||
# Try triggering events upon walking into them/in front of them
|
# Try triggering events upon walking into them/in front of them
|
||||||
if @moved_this_frame
|
if @moved_this_frame
|
||||||
$game_temp.followers.turn_followers
|
$game_temp.followers.turn_followers
|
||||||
|
|||||||
@@ -544,18 +544,6 @@ end
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Player/event movement in the field
|
# Player/event movement in the field
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
def pbLedge(_xOffset, _yOffset)
|
|
||||||
if $game_player.pbFacingTerrainTag.ledge
|
|
||||||
if pbJumpToward(2, true)
|
|
||||||
$scene.spriteset.addUserAnimation(Settings::DUST_ANIMATION_ID, $game_player.x, $game_player.y, true, 1)
|
|
||||||
$game_player.increase_steps
|
|
||||||
$game_player.check_event_trigger_here([1, 2])
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbSlideOnIce
|
def pbSlideOnIce
|
||||||
if $game_player.pbTerrainTag.ice && $game_player.can_move_in_direction?($game_player.direction)
|
if $game_player.pbTerrainTag.ice && $game_player.can_move_in_direction?($game_player.direction)
|
||||||
$PokemonGlobal.ice_sliding = true
|
$PokemonGlobal.ice_sliding = true
|
||||||
@@ -605,29 +593,6 @@ def pbMoveTowardPlayer(event)
|
|||||||
$PokemonMap&.addMovedEvent(event.id)
|
$PokemonMap&.addMovedEvent(event.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbJumpToward(dist = 1, playSound = false, cancelSurf = false)
|
|
||||||
x = $game_player.x
|
|
||||||
y = $game_player.y
|
|
||||||
case $game_player.direction
|
|
||||||
when 2 then $game_player.jump(0, dist) # down
|
|
||||||
when 4 then $game_player.jump(-dist, 0) # left
|
|
||||||
when 6 then $game_player.jump(dist, 0) # right
|
|
||||||
when 8 then $game_player.jump(0, -dist) # up
|
|
||||||
end
|
|
||||||
if $game_player.x != x || $game_player.y != y
|
|
||||||
pbSEPlay("Player jump") if playSound
|
|
||||||
$PokemonEncounters.reset_step_count if cancelSurf
|
|
||||||
$game_temp.ending_surf = true if cancelSurf
|
|
||||||
while $game_player.jumping?
|
|
||||||
Graphics.update
|
|
||||||
Input.update
|
|
||||||
pbUpdateSceneMap
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Bridges, cave escape points, and setting the heal point
|
# Bridges, cave escape points, and setting the heal point
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|||||||
@@ -745,24 +745,16 @@ def pbStartSurfing
|
|||||||
$stats.surf_count += 1
|
$stats.surf_count += 1
|
||||||
pbUpdateVehicle
|
pbUpdateVehicle
|
||||||
$game_temp.surf_base_coords = $map_factory.getFacingCoords($game_player.x, $game_player.y, $game_player.direction)
|
$game_temp.surf_base_coords = $map_factory.getFacingCoords($game_player.x, $game_player.y, $game_player.direction)
|
||||||
pbJumpToward
|
$game_player.jumpForward
|
||||||
$game_temp.surf_base_coords = nil
|
|
||||||
$game_player.check_event_trigger_here([1, 2])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbEndSurf(_xOffset, _yOffset)
|
def pbEndSurf(_xOffset, _yOffset)
|
||||||
return false if !$PokemonGlobal.surfing
|
return false if !$PokemonGlobal.surfing
|
||||||
x = $game_player.x
|
return false if $game_player.pbFacingTerrainTag.can_surf
|
||||||
y = $game_player.y
|
base_coords = [$game_player.x, $game_player.y]
|
||||||
if $game_map.terrain_tag(x, y).can_surf && !$game_player.pbFacingTerrainTag.can_surf
|
if $game_player.jumpForward
|
||||||
$game_temp.surf_base_coords = [x, y]
|
$game_temp.surf_base_coords = base_coords
|
||||||
if pbJumpToward(1, false, true)
|
$game_temp.ending_surf = true
|
||||||
$game_map.autoplayAsCue
|
|
||||||
$game_player.increase_steps
|
|
||||||
result = $game_player.check_event_trigger_here([1, 2])
|
|
||||||
pbOnStepTaken(result)
|
|
||||||
end
|
|
||||||
$game_temp.surf_base_coords = nil
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@@ -792,6 +784,23 @@ EventHandlers.add(:on_player_interact, :start_surfing,
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Do things after a jump to start/end surfing.
|
||||||
|
EventHandlers.add(:on_step_taken, :surf_jump,
|
||||||
|
proc { |event|
|
||||||
|
next if !$scene.is_a?(Scene_Map) || !event.is_a?(Game_Player)
|
||||||
|
next if !$game_temp.surf_base_coords
|
||||||
|
# Hide the temporary surf base graphic after jumping onto/off it
|
||||||
|
$game_temp.surf_base_coords = nil
|
||||||
|
# Finish up dismounting from surfing
|
||||||
|
if $game_temp.ending_surf
|
||||||
|
pbCancelVehicles
|
||||||
|
$PokemonEncounters.reset_step_count
|
||||||
|
$game_map.autoplayAsCue # Play regular map BGM
|
||||||
|
$game_temp.ending_surf = false
|
||||||
|
end
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
HiddenMoveHandlers::CanUseMove.add(:SURF, proc { |move, pkmn, showmsg|
|
HiddenMoveHandlers::CanUseMove.add(:SURF, proc { |move, pkmn, showmsg|
|
||||||
next false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_SURF, showmsg)
|
next false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_SURF, showmsg)
|
||||||
if $PokemonGlobal.surfing
|
if $PokemonGlobal.surfing
|
||||||
|
|||||||
Reference in New Issue
Block a user