diff --git a/Data/Scripts/004_Game classes/009_Game_Player.rb b/Data/Scripts/004_Game classes/009_Game_Player.rb index 6a7bbe120..83592371a 100644 --- a/Data/Scripts/004_Game classes/009_Game_Player.rb +++ b/Data/Scripts/004_Game classes/009_Game_Player.rb @@ -77,6 +77,23 @@ class Game_Player < Game_Character @character_name = new_charset if new_charset end + # Called when the player's character or outfit changes. Assumes the player + # isn't moving. + def refresh_charset + meta = GameData::PlayerMetadata.get($player&.character_ID || 1) + new_charset = nil + if $PokemonGlobal&.diving + new_charset = pbGetPlayerCharset(meta.dive_charset) + elsif $PokemonGlobal&.surfing + new_charset = pbGetPlayerCharset(meta.surf_charset) + elsif $PokemonGlobal&.bicycle + new_charset = pbGetPlayerCharset(meta.cycle_charset) + else + new_charset = pbGetPlayerCharset(meta.walk_charset) + end + @character_name = new_charset if new_charset + end + def bump_into_object return if @bump_se && @bump_se>0 pbSEPlay("Player bump") @@ -498,7 +515,7 @@ def pbGetPlayerCharset(charset, trainer = nil, force = false) $game_player.charsetData[1] == charset && $game_player.charsetData[2] == outfit end - $game_player.charsetData = [trainer.character_ID, charset,outfit] if $game_player + $game_player.charsetData = [trainer.character_ID, charset, outfit] if $game_player ret = charset if pbResolveBitmap("Graphics/Characters/"+ret+"_"+outfit.to_s) ret = ret+"_"+outfit.to_s diff --git a/Data/Scripts/015_Trainers and player/004_Player.rb b/Data/Scripts/015_Trainers and player/004_Player.rb index 716783a0c..0590ffaa3 100644 --- a/Data/Scripts/015_Trainers and player/004_Player.rb +++ b/Data/Scripts/015_Trainers and player/004_Player.rb @@ -3,9 +3,9 @@ #=============================================================================== class Player < Trainer # @return [Integer] the character ID of the player - attr_accessor :character_ID + attr_reader :character_ID # @return [Integer] the player's outfit - attr_accessor :outfit + attr_reader :outfit # @return [Array] the player's Gym Badges (true if owned) attr_accessor :badges # @return [Integer] the player's money @@ -31,11 +31,20 @@ class Player < Trainer # @return [Array] downloaded Mystery Gift data attr_accessor :mystery_gifts + def character_ID=(value) + return if @character_ID == value + @character_ID = value + $game_player.refresh_charset if $game_player + end + + def outfit=(value) + return if @outfit == value + @outfit = value + $game_player.refresh_charset if $game_player + end + def trainer_type - if @trainer_type.is_a?(Integer) - @trainer_type = GameData::PlayerMetadata.get(@character_ID || 1).trainer_type - end - return @trainer_type + return GameData::PlayerMetadata.get(@character_ID || 1).trainer_type end # Sets the player's money. It can not exceed {Settings::MAX_MONEY}. diff --git a/Data/Scripts/019_Utilities/001_Utilities.rb b/Data/Scripts/019_Utilities/001_Utilities.rb index 9abf29874..f07272a55 100644 --- a/Data/Scripts/019_Utilities/001_Utilities.rb +++ b/Data/Scripts/019_Utilities/001_Utilities.rb @@ -224,8 +224,6 @@ def pbChangePlayer(id) meta = GameData::PlayerMetadata.get(id) return false if !meta $player.character_ID = id - $player.trainer_type = meta.trainer_type - $game_player.character_name = meta.walk_charset end def pbTrainerName(name = nil, outfit = 0)