Merge branch 'master' into mkxp-z

This commit is contained in:
Maruno17
2020-11-09 19:26:44 +00:00
79 changed files with 3367 additions and 3235 deletions

View File

@@ -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
@@ -422,48 +432,34 @@ class Game_Character
end
end
def move_up(turn_enabled = true)
turn_up if turn_enabled
if passable?(@x, @y, 8)
turn_up
@y -= 1
def move_generic(dir, turn_enabled = true)
turn_generic(dir) if turn_enabled
x_offset = (dir == 4) ? -1 : (dir == 6) ? 1 : 0
y_offset = (dir == 8) ? -1 : (dir == 2) ? 1 : 0
if passable?(@x, @y, dir)
turn_generic(dir)
@x += x_offset
@y += y_offset
increase_steps
else
check_event_trigger_touch(@x, @y-1)
check_event_trigger_touch(@x + x_offset, @y + y_offset)
end
end
def move_down(turn_enabled = true)
turn_down if turn_enabled
if passable?(@x, @y, 2)
turn_down
@y += 1
increase_steps
else
check_event_trigger_touch(@x, @y+1)
end
move_generic(2, turn_enabled)
end
def move_left(turn_enabled = true)
turn_left if turn_enabled
if passable?(@x, @y, 4)
turn_left
@x -= 1
increase_steps
else
check_event_trigger_touch(@x-1, @y)
end
move_generic(4, turn_enabled)
end
def move_right(turn_enabled = true)
turn_right if turn_enabled
if passable?(@x, @y, 6)
turn_right
@x += 1
increase_steps
else
check_event_trigger_touch(@x+1, @y)
end
move_generic(6, turn_enabled)
end
def move_up(turn_enabled = true)
move_generic(8, turn_enabled)
end
def move_upper_left
@@ -648,12 +644,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
@@ -680,7 +682,7 @@ class Game_Character
end
end
def turnGeneric(dir)
def turn_generic(dir)
return if @direction_fix
oldDirection = @direction
@direction = dir
@@ -688,10 +690,10 @@ class Game_Character
pbCheckEventTriggerAfterTurning if dir != oldDirection
end
def turn_up; turnGeneric(8); end
def turn_down; turnGeneric(2); end
def turn_left; turnGeneric(4); end
def turn_right; turnGeneric(6); end
def turn_down; turn_generic(2); end
def turn_left; turn_generic(4); end
def turn_right; turn_generic(6); end
def turn_up; turn_generic(8); end
def turn_right_90
case @direction
@@ -764,10 +766,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 +800,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 +819,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 +839,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 +847,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 +855,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

View File

@@ -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
@@ -64,67 +64,36 @@ class Game_Player < Game_Character
@bump_se = Graphics.frame_rate/4
end
def move_down(turn_enabled = true)
turn_down if turn_enabled
if passable?(@x, @y, 2)
return if pbLedge(0,1)
return if pbEndSurf(0,1)
turn_down
@y += 1
$PokemonTemp.dependentEvents.pbMoveDependentEvents
increase_steps
else
if !check_event_trigger_touch(@x, @y+1)
bump_into_object
def move_generic(dir, turn_enabled = true)
turn_generic(dir, true) if turn_enabled
if !$PokemonTemp.encounterTriggered
x_offset = (dir == 4) ? -1 : (dir == 6) ? 1 : 0
y_offset = (dir == 8) ? -1 : (dir == 2) ? 1 : 0
if passable?(@x, @y, dir)
return if pbLedge(x_offset, y_offset)
return if pbEndSurf(x_offset, y_offset)
turn_generic(dir, true)
if !$PokemonTemp.encounterTriggered
@x += x_offset
@y += y_offset
$PokemonTemp.dependentEvents.pbMoveDependentEvents
increase_steps
end
else
if !check_event_trigger_touch(@x + x_offset, @y + y_offset)
bump_into_object
end
end
end
$PokemonTemp.encounterTriggered = false
end
def move_left(turn_enabled = true)
turn_left if turn_enabled
if passable?(@x, @y, 4)
return if pbLedge(-1,0)
return if pbEndSurf(-1,0)
turn_left
@x -= 1
$PokemonTemp.dependentEvents.pbMoveDependentEvents
increase_steps
else
if !check_event_trigger_touch(@x-1, @y)
bump_into_object
end
end
end
def move_right(turn_enabled = true)
turn_right if turn_enabled
if passable?(@x, @y, 6)
return if pbLedge(1,0)
return if pbEndSurf(1,0)
turn_right
@x += 1
$PokemonTemp.dependentEvents.pbMoveDependentEvents
increase_steps
else
if !check_event_trigger_touch(@x+1, @y)
bump_into_object
end
end
end
def move_up(turn_enabled = true)
turn_up if turn_enabled
if passable?(@x, @y, 8)
return if pbLedge(0,-1)
return if pbEndSurf(0,-1)
turn_up
@y -= 1
$PokemonTemp.dependentEvents.pbMoveDependentEvents
increase_steps
else
if !check_event_trigger_touch(@x, @y-1)
bump_into_object
end
def turn_generic(dir, keep_enc_indicator = false)
old_direction = @direction
super(dir)
if @direction != old_direction && !@move_route_forcing && !pbMapInterpreterRunning?
Events.onChangeDirection.trigger(self, self)
$PokemonTemp.encounterTriggered = false if !keep_enc_indicator
end
end
@@ -162,8 +131,7 @@ class Game_Player < Game_Character
return result
end
def pbCheckEventTriggerAfterTurning
end
def pbCheckEventTriggerAfterTurning; end
def pbCheckEventTriggerFromDistance(triggers)
ret = pbTriggeredTrainerEvents(triggers)
@@ -377,17 +345,18 @@ class Game_Player < Game_Character
def update_command_new
dir = Input.dir4
unless pbMapInterpreterRunning? or $game_temp.message_window_showing or
$PokemonTemp.miniupdate or $game_temp.in_menu
unless pbMapInterpreterRunning? || $game_temp.message_window_showing ||
$PokemonTemp.miniupdate || $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 > 0 && dir == @lastdir && Graphics.frame_count - @lastdirframe > Graphics.frame_rate / 20)
case dir
when 2; move_down
when 4; move_left
when 6; move_right
when 8; move_up
end
elsif dir!=@lastdir
elsif dir != @lastdir
case dir
when 2; turn_down
when 4; turn_left
@@ -397,7 +366,7 @@ class Game_Player < Game_Character
end
end
# Record last direction input
@lastdirframe = Graphics.frame_count if dir!=@lastdir
@lastdirframe = Graphics.frame_count if dir != @lastdir
@lastdir = dir
end

View File

@@ -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
elsif pbCanRun? || $PokemonGlobal.surfing || $PokemonGlobal.diving
self.move_speed = 5 # Running, surfing or diving
self.move_speed = 5 # Cycling
elsif pbCanRun? || $PokemonGlobal.surfing
self.move_speed = 4 # Running, surfing
else
self.move_speed = 4 # Walking
self.move_speed = 3 # Walking, diving
end
end
super

View File

@@ -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