mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Merge branch 'master' into refactor
This commit is contained in:
@@ -33,7 +33,7 @@ class Game_Character
|
||||
@y = 0
|
||||
@real_x = 0
|
||||
@real_y = 0
|
||||
@sprite_size = [Game_Map::TILE_WIDTH,Game_Map::TILE_HEIGHT]
|
||||
@sprite_size = [Game_Map::TILE_WIDTH, Game_Map::TILE_HEIGHT]
|
||||
@tile_id = 0
|
||||
@character_name = ""
|
||||
@character_hue = 0
|
||||
@@ -50,7 +50,7 @@ class Game_Character
|
||||
@original_direction = 2
|
||||
@original_pattern = 0
|
||||
@move_type = 0
|
||||
self.move_speed = 4
|
||||
self.move_speed = 3
|
||||
self.move_frequency = 6
|
||||
@move_route = nil
|
||||
@move_route_index = 0
|
||||
@@ -62,8 +62,10 @@ class Game_Character
|
||||
@always_on_top = false
|
||||
@anime_count = 0
|
||||
@stop_count = 0
|
||||
@jump_count = 0
|
||||
@jump_peak = 0
|
||||
@jump_peak = 0 # Max height while jumping
|
||||
@jump_distance = 0 # Total distance of jump
|
||||
@jump_distance_left = 0 # Distance left to travel
|
||||
@jump_count = 0 # Frames left in a stationary jump
|
||||
@bob_height = 0
|
||||
@wait_count = 0
|
||||
@moved_this_frame = false
|
||||
@@ -77,13 +79,13 @@ class Game_Character
|
||||
# @move_speed_real is the number of quarter-pixels to move each frame. There
|
||||
# are 128 quarter-pixels per tile. By default, it is calculated from
|
||||
# @move_speed and has these values (assuming 40 fps):
|
||||
# 1 => 1.6 # 80 frames per tile
|
||||
# 2 => 3.2 # 40 frames per tile
|
||||
# 3 => 6.4 # 20 frames per tile
|
||||
# 4 => 12.8 # 10 frames per tile - walking speed
|
||||
# 5 => 25.6 # 5 frames per tile - running speed (2x walking speed)
|
||||
# 6 => 32 # 4 frames per tile - cycling speed (1.25x running speed)
|
||||
self.move_speed_real = (val == 6) ? 32 : (1 << val) * 0.8
|
||||
# 1 => 3.2 # 40 frames per tile
|
||||
# 2 => 6.4 # 20 frames per tile
|
||||
# 3 => 12.8 # 10 frames per tile - walking speed
|
||||
# 4 => 25.6 # 5 frames per tile - running speed (2x walking speed)
|
||||
# 5 => 32 # 4 frames per tile - cycling speed (1.25x running speed)
|
||||
# 6 => 64 # 2 frames per tile
|
||||
self.move_speed_real = (val == 6) ? 64 : (val == 5) ? 32 : (2 ** (val + 1)) * 0.8
|
||||
end
|
||||
|
||||
def move_speed_real
|
||||
@@ -95,6 +97,10 @@ class Game_Character
|
||||
@move_speed_real = val * 40.0 / Graphics.frame_rate
|
||||
end
|
||||
|
||||
def jump_speed_real
|
||||
return (2 ** (3 + 1)) * 0.8 * 40.0 / Graphics.frame_rate # Walking speed
|
||||
end
|
||||
|
||||
def move_frequency=(val)
|
||||
return if val==@move_frequency
|
||||
@move_frequency = val
|
||||
@@ -160,7 +166,7 @@ class Game_Character
|
||||
end
|
||||
|
||||
def bush_depth
|
||||
return 0 if @tile_id > 0 or @always_on_top or @jump_count > 0
|
||||
return 0 if @tile_id > 0 || @always_on_top or jumping?
|
||||
xbehind = @x + (@direction==4 ? 1 : @direction==6 ? -1 : 0)
|
||||
ybehind = @y + (@direction==8 ? 1 : @direction==2 ? -1 : 0)
|
||||
return Game_Map::TILE_HEIGHT if self.map.deepBush?(@x, @y) and self.map.deepBush?(xbehind, ybehind)
|
||||
@@ -219,8 +225,12 @@ class Game_Character
|
||||
def screen_y
|
||||
ret = screen_y_ground
|
||||
if jumping?
|
||||
n = ((2 * @jump_count * 20 / Graphics.frame_rate) - @jump_peak).abs
|
||||
return ret - (@jump_peak * @jump_peak - n * n) / 2
|
||||
if @jump_count > 0
|
||||
jump_fraction = ((@jump_count * jump_speed_real / Game_Map::REAL_RES_X) - 0.5).abs # 0.5 to 0 to 0.5
|
||||
else
|
||||
jump_fraction = ((@jump_distance_left / @jump_distance) - 0.5).abs # 0.5 to 0 to 0.5
|
||||
end
|
||||
ret += @jump_peak * (4 * jump_fraction**2 - 1)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
@@ -248,7 +258,7 @@ class Game_Character
|
||||
end
|
||||
|
||||
def jumping?
|
||||
return @jump_count > 0
|
||||
return (@jump_distance_left || 0) > 0 || @jump_count > 0
|
||||
end
|
||||
|
||||
def straighten
|
||||
@@ -648,12 +658,18 @@ class Game_Character
|
||||
new_x = @x + x_plus
|
||||
new_y = @y + y_plus
|
||||
if (x_plus == 0 and y_plus == 0) || passable?(new_x, new_y, 0)
|
||||
straighten
|
||||
@x = new_x
|
||||
@y = new_y
|
||||
distance = [4, x_plus * x_plus + y_plus * y_plus].max
|
||||
@jump_peak = (6 + distance - move_speed).floor
|
||||
@jump_count = @jump_peak * Graphics.frame_rate / 20
|
||||
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
|
||||
@jump_count = 0
|
||||
else # Jumping on the spot
|
||||
@jump_count = Game_Map::REAL_RES_X / jump_speed_real # Number of frames to jump one tile
|
||||
end
|
||||
@stop_count = 0
|
||||
if self.is_a?(Game_Player)
|
||||
$PokemonTemp.dependentEvents.pbMoveDependentEvents
|
||||
@@ -764,10 +780,7 @@ class Game_Character
|
||||
# Update command
|
||||
update_command
|
||||
# Update movement
|
||||
if jumping?; update_jump
|
||||
elsif moving?; update_move
|
||||
else; update_stop
|
||||
end
|
||||
(moving? || jumping?) ? update_move : update_stop
|
||||
end
|
||||
# Update animation
|
||||
update_pattern
|
||||
@@ -801,18 +814,9 @@ class Game_Character
|
||||
end
|
||||
end
|
||||
|
||||
def update_jump
|
||||
@jump_count -= 1
|
||||
@real_x = (@real_x * @jump_count + @x * Game_Map::REAL_RES_X) / (@jump_count + 1)
|
||||
@real_y = (@real_y * @jump_count + @y * Game_Map::REAL_RES_Y) / (@jump_count + 1)
|
||||
@moved_this_frame = true
|
||||
# End of a jump, so perform events that happen at this time
|
||||
Events.onStepTakenFieldMovement.trigger(self,self) if !jumping? && !moving?
|
||||
end
|
||||
|
||||
def update_move
|
||||
# Move the character (the 0.1 catches rounding errors)
|
||||
distance = move_speed_real
|
||||
distance = (jumping?) ? jump_speed_real : move_speed_real
|
||||
dest_x = @x * Game_Map::REAL_RES_X
|
||||
dest_y = @y * Game_Map::REAL_RES_Y
|
||||
if @real_x < dest_x
|
||||
@@ -829,8 +833,13 @@ class Game_Character
|
||||
@real_y -= distance
|
||||
@real_y = dest_y if @real_y < dest_y + 0.1
|
||||
end
|
||||
# Refresh how far is left to travel in a jump
|
||||
if jumping?
|
||||
@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
|
||||
end
|
||||
# End of a step, so perform events that happen at this time
|
||||
Events.onStepTakenFieldMovement.trigger(self,self) if !jumping? && !moving?
|
||||
Events.onStepTakenFieldMovement.trigger(self, self) if !jumping? && !moving?
|
||||
# Increment animation counter
|
||||
@anime_count += 1 if @walk_anime || @step_anime
|
||||
@moved_this_frame = true
|
||||
@@ -844,6 +853,7 @@ class Game_Character
|
||||
|
||||
def update_pattern
|
||||
return if @lock_pattern
|
||||
# return if @jump_count > 0 # Don't animate if jumping on the spot
|
||||
# Character has stopped moving, return to original pattern
|
||||
if @moved_last_frame && !@moved_this_frame && !@step_anime
|
||||
@pattern = @original_pattern
|
||||
@@ -851,7 +861,7 @@ class Game_Character
|
||||
return
|
||||
end
|
||||
# Character has started to move, change pattern immediately
|
||||
if !@moved_last_frame && @moved_this_frame && !jumping? && !@step_anime
|
||||
if !@moved_last_frame && @moved_this_frame && !@step_anime
|
||||
@pattern = (@pattern + 1) % 4 if @walk_anime
|
||||
@anime_count = 0
|
||||
return
|
||||
@@ -859,7 +869,8 @@ class Game_Character
|
||||
# Calculate how many frames each pattern should display for, i.e. the time
|
||||
# it takes to move half a tile (or a whole tile if cycling). We assume the
|
||||
# game uses square tiles.
|
||||
frames_per_pattern = Game_Map::REAL_RES_X / (move_speed_real * 2.0)
|
||||
real_speed = (jumping?) ? jump_speed_real : move_speed_real
|
||||
frames_per_pattern = Game_Map::REAL_RES_X / (real_speed * 2.0)
|
||||
frames_per_pattern *= 2 if move_speed == 6 # Cycling/fastest speed
|
||||
return if @anime_count < frames_per_pattern
|
||||
# Advance to the next animation frame
|
||||
|
||||
@@ -23,7 +23,7 @@ class Game_Player < Game_Character
|
||||
end
|
||||
|
||||
def bush_depth
|
||||
return 0 if @tile_id > 0 or @always_on_top
|
||||
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
|
||||
@@ -47,7 +47,7 @@ class Game_Player < Game_Character
|
||||
behindmap = newbehind[0]; behindx = newbehind[1]; behindy = newbehind[2]
|
||||
end
|
||||
# Return bush depth
|
||||
if @jump_count <= 0
|
||||
if !jumping?
|
||||
return 32 if heremap.deepBush?(herex, herey) && behindmap.deepBush?(behindx, behindy)
|
||||
return 12 if heremap.bush?(herex, herey) && !moving?
|
||||
end
|
||||
@@ -128,6 +128,14 @@ class Game_Player < Game_Character
|
||||
end
|
||||
end
|
||||
|
||||
def turnGeneric(dir)
|
||||
old_direction = @direction
|
||||
super
|
||||
if @direction != old_direction && !@move_route_forcing && !pbMapInterpreterRunning?
|
||||
Events.onChangeDirection.trigger(self, self)
|
||||
end
|
||||
end
|
||||
|
||||
def pbTriggeredTrainerEvents(triggers,checkIfRunning=true)
|
||||
result = []
|
||||
# If event is running
|
||||
@@ -380,7 +388,7 @@ class Game_Player < Game_Character
|
||||
unless pbMapInterpreterRunning? or $game_temp.message_window_showing or
|
||||
$PokemonTemp.miniupdate or $game_temp.in_menu
|
||||
# Move player in the direction the directional button is being pressed
|
||||
if dir==@lastdir && Graphics.frame_count-@lastdirframe>Graphics.frame_rate/20
|
||||
if @moved_last_frame || (dir==@lastdir && Graphics.frame_count-@lastdirframe>Graphics.frame_rate/20)
|
||||
case dir
|
||||
when 2; move_down
|
||||
when 4; move_left
|
||||
|
||||
@@ -25,7 +25,7 @@ class Game_Player < Game_Character
|
||||
pbMapInterpreterRunning?
|
||||
terrain = pbGetTerrainTag
|
||||
input = ($PokemonSystem.runstyle==1) ? $PokemonGlobal.runtoggle : Input.press?(Input::A)
|
||||
return input && $PokemonGlobal.runningShoes &&
|
||||
return input && $PokemonGlobal.runningShoes && !jumping? &&
|
||||
!$PokemonGlobal.diving && !$PokemonGlobal.surfing &&
|
||||
!$PokemonGlobal.bicycle && !PBTerrain.onlyWalk?(terrain)
|
||||
end
|
||||
@@ -54,14 +54,14 @@ class Game_Player < Game_Character
|
||||
|
||||
def update_command
|
||||
if PBTerrain.isIce?(pbGetTerrainTag)
|
||||
self.move_speed = 5 # Sliding on ice
|
||||
self.move_speed = 4 # Sliding on ice
|
||||
elsif !moving? && !@move_route_forcing && $PokemonGlobal
|
||||
if $PokemonGlobal.bicycle
|
||||
self.move_speed = 6 # Cycling
|
||||
self.move_speed = 5 # Cycling
|
||||
elsif pbCanRun? || $PokemonGlobal.surfing
|
||||
self.move_speed = 5 # Running, surfing
|
||||
self.move_speed = 4 # Running, surfing
|
||||
else
|
||||
self.move_speed = 4 # Walking, diving
|
||||
self.move_speed = 3 # Walking, diving
|
||||
end
|
||||
end
|
||||
super
|
||||
|
||||
@@ -103,7 +103,7 @@ class Game_Map
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
# * Autoplays background music
|
||||
# Plays music called "[normal BGM]n" if it's night time and it exists
|
||||
# Plays music called "[normal BGM]_n" if it's night time and it exists
|
||||
#-----------------------------------------------------------------------------
|
||||
def autoplayAsCue
|
||||
if @map.autoplay_bgm
|
||||
@@ -119,12 +119,12 @@ class Game_Map
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
# * Plays background music
|
||||
# Plays music called "[normal BGM]n" if it's night time and it exists
|
||||
# Plays music called "[normal BGM]_n" if it's night time and it exists
|
||||
#-----------------------------------------------------------------------------
|
||||
def autoplay
|
||||
if @map.autoplay_bgm
|
||||
if PBDayNight.isNight? && FileTest.audio_exist?("Audio/BGM/"+ @map.bgm.name+ "n")
|
||||
pbBGMPlay(@map.bgm.name+"n",@map.bgm.volume,@map.bgm.pitch)
|
||||
if PBDayNight.isNight? && FileTest.audio_exist?("Audio/BGM/"+ @map.bgm.name+ "_n")
|
||||
pbBGMPlay(@map.bgm.name+"_n",@map.bgm.volume,@map.bgm.pitch)
|
||||
else
|
||||
pbBGMPlay(@map.bgm)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user