From 096f13f45101346b6fedfc48a7bba507434335e6 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Wed, 22 Sep 2021 22:57:06 +0100 Subject: [PATCH] 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. --- .../004_Game classes/007_Game_Character.rb | 10 ++ .../004_Game classes/009_Game_Player.rb | 126 ++++++++++++++++-- ...CommonEvent.rb => 010_Game_CommonEvent.rb} | 0 .../010_Game_Player_Visuals.rb | 80 ----------- ...tEvents.rb => 011_Game_DependentEvents.rb} | 0 .../012_Overworld/005_Overworld_Fishing.rb | 71 +++++----- .../Scripts/020_Debug/002_Editor_DataTypes.rb | 4 +- 7 files changed, 157 insertions(+), 134 deletions(-) rename Data/Scripts/004_Game classes/{011_Game_CommonEvent.rb => 010_Game_CommonEvent.rb} (100%) delete mode 100644 Data/Scripts/004_Game classes/010_Game_Player_Visuals.rb rename Data/Scripts/004_Game classes/{012_Game_DependentEvents.rb => 011_Game_DependentEvents.rb} (100%) diff --git a/Data/Scripts/004_Game classes/007_Game_Character.rb b/Data/Scripts/004_Game classes/007_Game_Character.rb index 099ffc917..c655db210 100644 --- a/Data/Scripts/004_Game classes/007_Game_Character.rb +++ b/Data/Scripts/004_Game classes/007_Game_Character.rb @@ -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 #============================================================================= diff --git a/Data/Scripts/004_Game classes/009_Game_Player.rb b/Data/Scripts/004_Game classes/009_Game_Player.rb index 607f62fb0..4e5da12d7 100644 --- a/Data/Scripts/004_Game classes/009_Game_Player.rb +++ b/Data/Scripts/004_Game classes/009_Game_Player.rb @@ -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 diff --git a/Data/Scripts/004_Game classes/011_Game_CommonEvent.rb b/Data/Scripts/004_Game classes/010_Game_CommonEvent.rb similarity index 100% rename from Data/Scripts/004_Game classes/011_Game_CommonEvent.rb rename to Data/Scripts/004_Game classes/010_Game_CommonEvent.rb diff --git a/Data/Scripts/004_Game classes/010_Game_Player_Visuals.rb b/Data/Scripts/004_Game classes/010_Game_Player_Visuals.rb deleted file mode 100644 index cd7e42fda..000000000 --- a/Data/Scripts/004_Game classes/010_Game_Player_Visuals.rb +++ /dev/null @@ -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 diff --git a/Data/Scripts/004_Game classes/012_Game_DependentEvents.rb b/Data/Scripts/004_Game classes/011_Game_DependentEvents.rb similarity index 100% rename from Data/Scripts/004_Game classes/012_Game_DependentEvents.rb rename to Data/Scripts/004_Game classes/011_Game_DependentEvents.rb diff --git a/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb b/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb index 4e6bc245c..641c93f21 100644 --- a/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb +++ b/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb @@ -4,40 +4,36 @@ 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) - 4.times do |pattern| - $game_player.setDefaultCharName(charset,patternb-pattern,true) - (Graphics.frame_rate/20).times do - Graphics.update - Input.update - pbUpdateSceneMap - end + $game_player.set_movement_type(($PokemonGlobal.surfing) ? :surf_fishing : :fishing) + $game_player.lock_pattern = true + 4.times do |pattern| + $game_player.pattern = 3 - pattern + (Graphics.frame_rate / 20).times do + Graphics.update + Input.update + pbUpdateSceneMap 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) - 4.times do |pattern| - $game_player.setDefaultCharName(charset,patternb+pattern,true) - (Graphics.frame_rate/20).times do - Graphics.update - Input.update - pbUpdateSceneMap - end + $game_player.lock_pattern = true + 4.times do |pattern| + $game_player.pattern = pattern + (Graphics.frame_rate / 20).times do + Graphics.update + Input.update + pbUpdateSceneMap 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) - pbMessageDisplay(msgWindow,_INTL("Not even a nibble...")) + pbFishingEnd { + pbMessageDisplay(msgWindow,_INTL("Not even a nibble...")) + } break end if hasEncounter && rand(100)