mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Bush depths for events/the player are now only recalculated wheh they move, rather than every time they're queried (anti-lag)
This commit is contained in:
@@ -193,12 +193,25 @@ class Game_Character
|
|||||||
end
|
end
|
||||||
|
|
||||||
def bush_depth
|
def bush_depth
|
||||||
return 0 if @tile_id > 0 || @always_on_top || jumping?
|
return @bush_depth || 0
|
||||||
xbehind = @x + (@direction==4 ? 1 : @direction==6 ? -1 : 0)
|
end
|
||||||
ybehind = @y + (@direction==8 ? 1 : @direction==2 ? -1 : 0)
|
|
||||||
return Game_Map::TILE_HEIGHT if self.map.deepBush?(@x, @y) && self.map.deepBush?(xbehind, ybehind)
|
def calculate_bush_depth
|
||||||
return 12 if !moving? && self.map.bush?(@x, @y)
|
if @tile_id > 0 || @always_on_top || jumping?
|
||||||
return 0
|
@bush_depth = 0
|
||||||
|
else
|
||||||
|
deep_bush = regular_bush = false
|
||||||
|
xbehind = @x + (@direction == 4 ? 1 : @direction == 6 ? -1 : 0)
|
||||||
|
ybehind = @y + (@direction == 8 ? 1 : @direction == 2 ? -1 : 0)
|
||||||
|
this_map = (self.map.valid?(@x, @y)) ? [self.map, @x, @y] : $MapFactory.getNewMap(@x, @y)
|
||||||
|
if this_map[0].deepBush?(this_map[1], this_map[2]) && self.map.deepBush?(xbehind, ybehind)
|
||||||
|
@bush_depth = Game_Map::TILE_HEIGHT
|
||||||
|
elsif !moving? && this_map[0].bush?(this_map[1], this_map[2])
|
||||||
|
@bush_depth = 12
|
||||||
|
else
|
||||||
|
@bush_depth = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
@@ -818,6 +831,7 @@ class Game_Character
|
|||||||
#=============================================================================
|
#=============================================================================
|
||||||
def update
|
def update
|
||||||
@moved_last_frame = @moved_this_frame
|
@moved_last_frame = @moved_this_frame
|
||||||
|
@stopped_last_frame = @stopped_this_frame
|
||||||
if !$game_temp.in_menu
|
if !$game_temp.in_menu
|
||||||
# Update command
|
# Update command
|
||||||
update_command
|
update_command
|
||||||
@@ -881,7 +895,14 @@ class Game_Character
|
|||||||
@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
|
||||||
Events.onStepTakenFieldMovement.trigger(self, self) if !jumping? && !moving?
|
if !jumping? && !moving?
|
||||||
|
Events.onStepTakenFieldMovement.trigger(self, self)
|
||||||
|
calculate_bush_depth
|
||||||
|
@stopped_this_frame = true
|
||||||
|
elsif !@moved_last_frame || @stopped_last_frame # Started a new step
|
||||||
|
calculate_bush_depth
|
||||||
|
@stopped_this_frame = false
|
||||||
|
end
|
||||||
# Increment animation counter
|
# Increment animation counter
|
||||||
@anime_count += 1 if @walk_anime || @step_anime
|
@anime_count += 1 if @walk_anime || @step_anime
|
||||||
@moved_this_frame = true
|
@moved_this_frame = true
|
||||||
@@ -891,6 +912,7 @@ class Game_Character
|
|||||||
@anime_count += 1 if @step_anime
|
@anime_count += 1 if @step_anime
|
||||||
@stop_count += 1 if !@starting && !lock?
|
@stop_count += 1 if !@starting && !lock?
|
||||||
@moved_this_frame = false
|
@moved_this_frame = false
|
||||||
|
@stopped_this_frame = false
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_pattern
|
def update_pattern
|
||||||
|
|||||||
@@ -25,38 +25,6 @@ class Game_Player < Game_Character
|
|||||||
return $game_map
|
return $game_map
|
||||||
end
|
end
|
||||||
|
|
||||||
def bush_depth
|
|
||||||
return 0 if @tile_id > 0 || @always_on_top
|
|
||||||
xbehind = (@direction==4) ? @x+1 : (@direction==6) ? @x-1 : @x
|
|
||||||
ybehind = (@direction==8) ? @y+1 : (@direction==2) ? @y-1 : @y
|
|
||||||
# Both current tile and previous tile are on the same map; just return super
|
|
||||||
return super if $game_map.valid?(@x,@y) && $game_map.valid?(xbehind,ybehind)
|
|
||||||
# The current or the previous tile is on a different map; consult MapFactory
|
|
||||||
return 0 if !$MapFactory
|
|
||||||
# Get map and coordinates of the current tile
|
|
||||||
if $game_map.valid?(@x,@y)
|
|
||||||
heremap = self.map; herex = @x; herey = @y
|
|
||||||
else
|
|
||||||
newhere = $MapFactory.getNewMap(@x,@y)
|
|
||||||
return 0 unless newhere && newhere[0] # Map not found
|
|
||||||
heremap = newhere[0]; herex = newhere[1]; herey = newhere[2]
|
|
||||||
end
|
|
||||||
# Get map and coordinates of the previous tile
|
|
||||||
newbehind = $MapFactory.getNewMap(xbehind,ybehind)
|
|
||||||
if $game_map.valid?(xbehind,ybehind)
|
|
||||||
behindmap = self.map; behindx = xbehind; behindy = ybehind
|
|
||||||
else
|
|
||||||
return 0 unless newbehind && newbehind[0] # Map not found
|
|
||||||
behindmap = newbehind[0]; behindx = newbehind[1]; behindy = newbehind[2]
|
|
||||||
end
|
|
||||||
# Return bush depth
|
|
||||||
if !jumping?
|
|
||||||
return 32 if heremap.deepBush?(herex, herey) && behindmap.deepBush?(behindx, behindy)
|
|
||||||
return 12 if heremap.bush?(herex, herey) && !moving?
|
|
||||||
end
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbHasDependentEvents?
|
def pbHasDependentEvents?
|
||||||
return $PokemonGlobal.dependentEvents.length>0
|
return $PokemonGlobal.dependentEvents.length>0
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user