The player's charset now only changes itself at the start of a step or the start of not moving. Added potential for running/jumping/stationary speeds/charsets for surfing/diving/cycling. Tweaked fishing animation.

This commit is contained in:
Maruno17
2021-09-22 22:57:06 +01:00
parent 694e567f3d
commit 096f13f451
7 changed files with 157 additions and 134 deletions

View File

@@ -214,6 +214,16 @@ class Game_Character
end
end
def fullPattern
case self.direction
when 2 then return self.pattern
when 4 then return self.pattern + 4
when 6 then return self.pattern + 8
when 8 then return self.pattern + 12
end
return 0
end
#=============================================================================
# Passability
#=============================================================================

View File

@@ -13,6 +13,8 @@ class Game_Player < Game_Character
SCREEN_CENTER_X = (Settings::SCREEN_WIDTH / 2 - Game_Map::TILE_WIDTH / 2) * Game_Map::X_SUBPIXELS
SCREEN_CENTER_Y = (Settings::SCREEN_HEIGHT / 2 - Game_Map::TILE_HEIGHT / 2) * Game_Map::Y_SUBPIXELS
@@bobFrameSpeed = 1.0 / 15
def initialize(*arg)
super(*arg)
@lastdir=0
@@ -29,6 +31,47 @@ class Game_Player < Game_Character
return $PokemonGlobal.dependentEvents.length>0
end
def can_run?
return false if $game_temp.in_menu || $game_temp.in_battle ||
@move_route_forcing || $game_temp.message_window_showing ||
pbMapInterpreterRunning?
return false if !$Trainer.has_running_shoes && !$PokemonGlobal.diving &&
!$PokemonGlobal.surfing && !$PokemonGlobal.bicycle
return false if jumping?
return false if pbTerrainTag.must_walk
return ($PokemonSystem.runstyle == 1) ^ Input.press?(Input::BACK)
end
def set_movement_type(type)
meta = GameData::Metadata.get_player($Trainer&.character_ID || 0)
new_charset = nil
case type
when :fishing
new_charset = pbGetPlayerCharset(meta, 6)
when :surf_fishing
new_charset = pbGetPlayerCharset(meta, 7)
when :diving, :diving_fast, :diving_jumping, :diving_stopped
self.move_speed = 3
new_charset = pbGetPlayerCharset(meta, 5)
when :surfing, :surfing_fast, :surfing_jumping, :surfing_stopped
self.move_speed = (type == :surfing_jumping) ? 3 : 4
new_charset = pbGetPlayerCharset(meta, 3)
when :cycling, :cycling_fast, :cycling_jumping, :cycling_stopped
self.move_speed = (type == :cycling_jumping) ? 3 : 5
new_charset = pbGetPlayerCharset(meta, 2)
when :running
self.move_speed = 4
new_charset = pbGetPlayerCharset(meta, 4)
when :ice_sliding
self.move_speed = 4
new_charset = pbGetPlayerCharset(meta, 1)
else # :walking, :jumping, :walking_stopped
self.move_speed = 3
new_charset = pbGetPlayerCharset(meta, 1)
end
@character_name = new_charset if new_charset
end
def bump_into_object
return if @bump_se && @bump_se>0
pbSEPlay("Player bump")
@@ -185,9 +228,7 @@ class Game_Player < Game_Character
#-----------------------------------------------------------------------------
def moveto(x, y)
super
# Centering
center(x, y)
# Make encounter count
make_encounter_count
end
@@ -351,6 +392,64 @@ class Game_Player < Game_Character
@lastdir = dir
end
def update_move
if !@moved_last_frame || @stopped_last_frame # Started a new step
if pbTerrainTag.ice
set_movement_type(:ice_sliding)
elsif !@move_route_forcing
faster = can_run?
if $PokemonGlobal&.diving
set_movement_type((faster) ? :diving_fast : :diving)
elsif $PokemonGlobal&.surfing
set_movement_type((faster) ? :surfing_fast : :surfing)
elsif $PokemonGlobal&.bicycle
set_movement_type((faster) ? :cycling_fast : :cycling)
else
set_movement_type((faster) ? :running : :walking)
end
end
if jumping?
if $PokemonGlobal&.diving
set_movement_type(:diving_jumping)
elsif $PokemonGlobal&.surfing
set_movement_type(:surfing_jumping)
elsif $PokemonGlobal&.bicycle
set_movement_type(:cycling_jumping)
else
set_movement_type(:jumping) # Walking speed/charset while jumping
end
end
end
super
end
def update_stop
if @stopped_last_frame
if $PokemonGlobal&.diving
set_movement_type(:diving_stopped)
elsif $PokemonGlobal&.surfing
set_movement_type(:surfing_stopped)
elsif $PokemonGlobal&.bicycle
set_movement_type(:cycling_stopped)
else
set_movement_type(:walking_stopped)
end
end
super
end
def update_pattern
if $PokemonGlobal&.surfing || $PokemonGlobal&.diving
p = ((Graphics.frame_count % 60) * @@bobFrameSpeed).floor
@pattern = p if !@lock_pattern
@pattern_surf = p
@bob_height = (p >= 2) ? 2 : 0
else
@bob_height = 0
super
end
end
# Center player on-screen
def update_screen_position(last_real_x, last_real_y)
return if self.map.scrolling? || !(@moved_last_frame || @moved_this_frame)
@@ -380,6 +479,9 @@ end
#===============================================================================
#
#===============================================================================
def pbGetPlayerCharset(meta,charset,trainer=nil,force=false)
trainer = $Trainer if !trainer
outfit = (trainer) ? trainer.outfit : 0
@@ -398,18 +500,14 @@ def pbGetPlayerCharset(meta,charset,trainer=nil,force=false)
end
def pbUpdateVehicle
meta = GameData::Metadata.get_player($Trainer.character_ID)
if meta
charset = 1 # Regular graphic
if $PokemonGlobal.diving
charset = 5 # Diving graphic
elsif $PokemonGlobal.surfing
charset = 3 # Surfing graphic
elsif $PokemonGlobal.bicycle
charset = 2 # Bicycle graphic
end
newCharName = pbGetPlayerCharset(meta,charset)
$game_player.character_name = newCharName if newCharName
if $PokemonGlobal&.diving
$game_player.set_movement_type(:diving)
elsif $PokemonGlobal&.surfing
$game_player.set_movement_type(:surfing)
elsif $PokemonGlobal&.bicycle
$game_player.set_movement_type(:cycling)
else
$game_player.set_movement_type(:walking)
end
end

View File

@@ -1,80 +0,0 @@
class Game_Player < Game_Character
@@bobFrameSpeed = 1.0/15
def fullPattern
case self.direction
when 2 then return self.pattern
when 4 then return self.pattern + 4
when 6 then return self.pattern + 8
when 8 then return self.pattern + 12
end
return 0
end
def setDefaultCharName(chname,pattern,lockpattern=false)
return if pattern<0 || pattern>=16
@defaultCharacterName = chname
@direction = [2,4,6,8][pattern/4]
@pattern = pattern%4
@lock_pattern = lockpattern
end
def pbCanRun?
return false if $game_temp.in_menu || $game_temp.in_battle ||
@move_route_forcing || $game_temp.message_window_showing ||
pbMapInterpreterRunning?
input = ($PokemonSystem.runstyle == 1) ^ Input.press?(Input::BACK)
return input && $Trainer.has_running_shoes && !jumping? &&
!$PokemonGlobal.diving && !$PokemonGlobal.surfing &&
!$PokemonGlobal.bicycle && !$game_player.pbTerrainTag.must_walk
end
def pbIsRunning?
return moving? && !@move_route_forcing && pbCanRun?
end
def character_name
@defaultCharacterName = "" if !@defaultCharacterName
return @defaultCharacterName if @defaultCharacterName!=""
if !@move_route_forcing && $Trainer.character_ID>=0
meta = GameData::Metadata.get_player($Trainer.character_ID)
if meta && !$PokemonGlobal.bicycle && !$PokemonGlobal.diving && !$PokemonGlobal.surfing
charset = 1 # Display normal character sprite
if pbCanRun? && (moving? || @wasmoving) && Input.dir4!=0 && meta[4] && meta[4]!=""
charset = 4 # Display running character sprite
end
newCharName = pbGetPlayerCharset(meta,charset)
@character_name = newCharName if newCharName
@wasmoving = moving?
end
end
return @character_name
end
def update_command
if $game_player.pbTerrainTag.ice
self.move_speed = 4 # Sliding on ice
elsif !moving? && !@move_route_forcing && $PokemonGlobal
if $PokemonGlobal.bicycle
self.move_speed = 5 # Cycling
elsif pbCanRun? || $PokemonGlobal.surfing
self.move_speed = 4 # Running, surfing
else
self.move_speed = 3 # Walking, diving
end
end
super
end
def update_pattern
if $PokemonGlobal.surfing || $PokemonGlobal.diving
p = ((Graphics.frame_count%60)*@@bobFrameSpeed).floor
@pattern = p if !@lock_pattern
@pattern_surf = p
@bob_height = (p>=2) ? 2 : 0
else
@bob_height = 0
super
end
end
end

View File

@@ -4,32 +4,25 @@
def pbFishingBegin
$PokemonGlobal.fishing = true
if !pbCommonEvent(Settings::FISHING_BEGIN_COMMON_EVENT)
patternb = 2*$game_player.direction - 1
meta = GameData::Metadata.get_player($Trainer.character_ID)
num = ($PokemonGlobal.surfing) ? 7 : 6
if meta && meta[num] && meta[num]!=""
charset = pbGetPlayerCharset(meta,num)
$game_player.set_movement_type(($PokemonGlobal.surfing) ? :surf_fishing : :fishing)
$game_player.lock_pattern = true
4.times do |pattern|
$game_player.setDefaultCharName(charset,patternb-pattern,true)
$game_player.pattern = 3 - pattern
(Graphics.frame_rate / 20).times do
Graphics.update
Input.update
pbUpdateSceneMap
end
end
end
$game_player.lock_pattern = false
end
end
def pbFishingEnd
if !pbCommonEvent(Settings::FISHING_END_COMMON_EVENT)
patternb = 2*($game_player.direction - 2)
meta = GameData::Metadata.get_player($Trainer.character_ID)
num = ($PokemonGlobal.surfing) ? 7 : 6
if meta && meta[num] && meta[num]!=""
charset = pbGetPlayerCharset(meta,num)
$game_player.lock_pattern = true
4.times do |pattern|
$game_player.setDefaultCharName(charset,patternb+pattern,true)
$game_player.pattern = pattern
(Graphics.frame_rate / 20).times do
Graphics.update
Input.update
@@ -37,7 +30,10 @@ def pbFishingEnd
end
end
end
end
yield if block_given?
$game_player.set_movement_type(($PokemonGlobal.surfing) ? :surfing : :walking)
$game_player.lock_pattern = false
$game_player.straighten
$PokemonGlobal.fishing = false
end
@@ -46,7 +42,6 @@ def pbFishing(hasEncounter,rodType=1)
biteChance = 20+(25*rodType) # 45, 70, 95
biteChance *= 1.5 if speedup # 67.5, 100, 100
hookChance = 100
oldpattern = $game_player.fullPattern
pbFishingBegin
msgWindow = pbCreateMessageWindow
ret = false
@@ -56,33 +51,33 @@ def pbFishing(hasEncounter,rodType=1)
message = ""
time.times { message += ". " }
if pbWaitMessage(msgWindow,time)
pbFishingEnd
$game_player.setDefaultCharName(nil,oldpattern)
pbFishingEnd {
pbMessageDisplay(msgWindow,_INTL("Not even a nibble..."))
}
break
end
if hasEncounter && rand(100)<biteChance
$scene.spriteset.addUserAnimation(Settings::EXCLAMATION_ANIMATION_ID,$game_player.x,$game_player.y,true,3)
frames = Graphics.frame_rate - rand(Graphics.frame_rate/2) # 0.5-1 second
if !pbWaitForInput(msgWindow,message+_INTL("\r\nOh! A bite!"),frames)
pbFishingEnd
$game_player.setDefaultCharName(nil,oldpattern)
pbFishingEnd {
pbMessageDisplay(msgWindow,_INTL("The Pokémon got away..."))
}
break
end
if Settings::FISHING_AUTO_HOOK || rand(100) < hookChance
pbFishingEnd
pbFishingEnd {
pbMessageDisplay(msgWindow,_INTL("Landed a Pokémon!")) if !Settings::FISHING_AUTO_HOOK
$game_player.setDefaultCharName(nil,oldpattern)
}
ret = true
break
end
# biteChance += 15
# hookChance += 15
else
pbFishingEnd
$game_player.setDefaultCharName(nil,oldpattern)
pbFishingEnd {
pbMessageDisplay(msgWindow,_INTL("Not even a nibble..."))
}
break
end
end
@@ -114,7 +109,7 @@ def pbWaitForInput(msgWindow,message,frames)
pbMessageDisplay(msgWindow,message,false)
numFrame = 0
twitchFrame = 0
twitchFrameTime = Graphics.frame_rate/10 # 0.1 seconds, 4 frames
twitchFrameTime = Graphics.frame_rate * 2 / 10 # 0.2 seconds, 8 frames
loop do
Graphics.update
Input.update

View File

@@ -668,13 +668,13 @@ module PlayerProperty
oldsetting = [nil,"xxx","xxx","xxx","xxx","xxx","xxx","xxx"] if !oldsetting
properties = [
[_INTL("Trainer Type"), TrainerTypeProperty, _INTL("Trainer type of this player.")],
[_INTL("Sprite"), CharacterProperty, _INTL("Walking character sprite.")],
[_INTL("Walking"), CharacterProperty, _INTL("Walking character sprite.")],
[_INTL("Cycling"), CharacterProperty, _INTL("Cycling character sprite.")],
[_INTL("Surfing"), CharacterProperty, _INTL("Surfing character sprite.")],
[_INTL("Running"), CharacterProperty, _INTL("Running character sprite.")],
[_INTL("Diving"), CharacterProperty, _INTL("Diving character sprite.")],
[_INTL("Fishing"), CharacterProperty, _INTL("Fishing character sprite.")],
[_INTL("Field Move"), CharacterProperty, _INTL("Using a field move character sprite.")]
[_INTL("Surf-Fishing"), CharacterProperty, _INTL("Fishing while surfing character sprite.")]
]
pbPropertyList(settingname,oldsetting,properties,false)
return oldsetting