Changing the player's character or outfit immediately updates the player's graphic again

This commit is contained in:
Maruno17
2021-10-26 22:54:31 +01:00
parent 6c38f769c7
commit 6066797517
3 changed files with 33 additions and 9 deletions

View File

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

View File

@@ -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<Boolean>] 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<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}.

View File

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