diff --git a/Data/Scripts/001_Technical/004_RPG__Sprite.rb b/Data/Scripts/001_Technical/004_RPG__Sprite.rb index e0909f533..db1035f7c 100644 --- a/Data/Scripts/001_Technical/004_RPG__Sprite.rb +++ b/Data/Scripts/001_Technical/004_RPG__Sprite.rb @@ -188,9 +188,9 @@ class SpriteAnimation end else sprite_x = self.x - self.ox + self.src_rect.width / 2 - sprite_y = self.y - self.oy + self.src_rect.height / 2 - sprite_y -= self.src_rect.height / 4 if position == 0 - sprite_y += self.src_rect.height / 4 if position == 2 + sprite_y = self.y - self.oy + sprite_y += self.src_rect.height / 2 if position == 1 + sprite_y += self.src_rect.height if position == 2 end for i in 0..15 sprite = sprites[i] diff --git a/Data/Scripts/002_Save data/003_BuiltinValues.rb b/Data/Scripts/002_Save data/003_BuiltinValues.rb index 62105ebe8..18d3ab07b 100644 --- a/Data/Scripts/002_Save data/003_BuiltinValues.rb +++ b/Data/Scripts/002_Save data/003_BuiltinValues.rb @@ -4,6 +4,11 @@ SaveData.register(:player) do ensure_class :Player save_value { $Trainer } load_value { |value| $Trainer = value } + new_game_value { + trainer_type = nil # Get the first defined trainer type as a placeholder + GameData::TrainerType.each { |t| trainer_type = t.id; break } + Player.new("Unnamed", trainer_type) + } from_old_format { |old_format| old_format[0] } end @@ -100,6 +105,7 @@ SaveData.register(:bag) do ensure_class :PokemonBag save_value { $PokemonBag } load_value { |value| $PokemonBag = value } + new_game_value { PokemonBag.new } from_old_format { |old_format| old_format[13] } end diff --git a/Data/Scripts/002_Save data/005_BuiltinConversions.rb b/Data/Scripts/002_Save data/005_BuiltinConversions.rb index 2c3cf4701..66e2d73bb 100644 --- a/Data/Scripts/002_Save data/005_BuiltinConversions.rb +++ b/Data/Scripts/002_Save data/005_BuiltinConversions.rb @@ -50,6 +50,8 @@ SaveData.register_conversion(:v19_move_global_data_to_player) do to_all do |save_data| global = save_data[:global_metadata] player = save_data[:player] + player.character_ID = global.playerID + global.playerID = nil global.pokedexUnlocked.each_with_index do |value, i| if value player.pokedex.unlock(i) @@ -57,17 +59,17 @@ SaveData.register_conversion(:v19_move_global_data_to_player) do player.pokedex.lock(i) end end - trainer.coins = global.coins + player.coins = global.coins global.coins = nil - trainer.soot = global.sootsack + player.soot = global.sootsack global.sootsack = nil - trainer.has_running_shoes = global.runningShoes + player.has_running_shoes = global.runningShoes global.runningShoes = nil - trainer.seen_storage_creator = global.seenStorageCreator + player.seen_storage_creator = global.seenStorageCreator global.seenStorageCreator = nil - trainer.has_snag_machine = global.snagMachine + player.has_snag_machine = global.snagMachine global.snagMachine = nil - trainer.seen_purify_chamber = global.seenPurifyChamber + player.seen_purify_chamber = global.seenPurifyChamber global.seenPurifyChamber = nil end end diff --git a/Data/Scripts/004_Game classes/009_Game_Player.rb b/Data/Scripts/004_Game classes/009_Game_Player.rb index 3343cd4ec..76190bc45 100644 --- a/Data/Scripts/004_Game classes/009_Game_Player.rb +++ b/Data/Scripts/004_Game classes/009_Game_Player.rb @@ -417,11 +417,11 @@ def pbGetPlayerCharset(meta,charset,trainer=nil,force=false) trainer = $Trainer if !trainer outfit = (trainer) ? trainer.outfit : 0 if $game_player && $game_player.charsetData && !force - return nil if $game_player.charsetData[0]==$PokemonGlobal.playerID && + return nil if $game_player.charsetData[0]==$Trainer.character_ID && $game_player.charsetData[1]==charset && $game_player.charsetData[2]==outfit end - $game_player.charsetData = [$PokemonGlobal.playerID,charset,outfit] if $game_player + $game_player.charsetData = [$Trainer.character_ID,charset,outfit] if $game_player ret = meta[charset] ret = meta[1] if !ret || ret=="" if pbResolveBitmap("Graphics/Characters/"+ret+"_"+outfit.to_s) @@ -431,7 +431,7 @@ def pbGetPlayerCharset(meta,charset,trainer=nil,force=false) end def pbUpdateVehicle - meta = GameData::Metadata.get_player($PokemonGlobal.playerID) + meta = GameData::Metadata.get_player($Trainer.character_ID) if meta charset = 1 # Regular graphic if $PokemonGlobal.diving; charset = 5 # Diving graphic diff --git a/Data/Scripts/004_Game classes/010_Game_PlayerVisuals.rb b/Data/Scripts/004_Game classes/010_Game_PlayerVisuals.rb index 9f819903a..8deb09001 100644 --- a/Data/Scripts/004_Game classes/010_Game_PlayerVisuals.rb +++ b/Data/Scripts/004_Game classes/010_Game_PlayerVisuals.rb @@ -36,8 +36,8 @@ class Game_Player < Game_Character def character_name @defaultCharacterName = "" if !@defaultCharacterName return @defaultCharacterName if @defaultCharacterName!="" - if !@move_route_forcing && $PokemonGlobal.playerID>=0 - meta = GameData::Metadata.get_player($PokemonGlobal.playerID) + 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]!="" diff --git a/Data/Scripts/007_Objects and windows/012_TextEntry.rb b/Data/Scripts/007_Objects and windows/012_TextEntry.rb index f91ba2a3b..4e287e8db 100644 --- a/Data/Scripts/007_Objects and windows/012_TextEntry.rb +++ b/Data/Scripts/007_Objects and windows/012_TextEntry.rb @@ -750,7 +750,7 @@ class PokemonEntryScene addBackgroundPlane(@sprites,"background","Naming/bg_2",@viewport) case subject when 1 # Player - meta=GameData::Metadata.get_player($PokemonGlobal.playerID) + meta=GameData::Metadata.get_player($Trainer.character_ID) if meta @sprites["shadow"]=IconSprite.new(0,0,@viewport) @sprites["shadow"].setBitmap("Graphics/Pictures/Naming/icon_shadow") @@ -1028,7 +1028,7 @@ class PokemonEntryScene2 @sprites["bg"].setBitmap("Graphics/Pictures/Naming/bg") case subject when 1 # Player - meta=GameData::Metadata.get_player($PokemonGlobal.playerID) + meta=GameData::Metadata.get_player($Trainer.character_ID) if meta @sprites["shadow"]=IconSprite.new(0,0,@viewport) @sprites["shadow"].setBitmap("Graphics/Pictures/Naming/icon_shadow") diff --git a/Data/Scripts/010_Scenes/001_Transitions.rb b/Data/Scripts/010_Scenes/001_Transitions.rb index a9f88dfd6..4222ab80d 100644 --- a/Data/Scripts/010_Scenes/001_Transitions.rb +++ b/Data/Scripts/010_Scenes/001_Transitions.rb @@ -780,7 +780,7 @@ module Transitions when 2 then k = @numtiles-1-(i*cx+(cx-1-j)) # Bottom left when 3 then k = @numtiles-1-k # Bottom right end - @frame[k] = ((0.6*j*width+0.8*i*height)*(@numframes/50)/l).floor + @frame[k] = ((0.6*j*width+0.8*i*height)*(@numframes/50.0)/l).floor end end @addzoom = 0.125*50/@numframes @@ -876,7 +876,7 @@ module Transitions @bubblesuby = @height*2/@numframes @splashsuby = @bubblesuby*2 @blacksuby = @height/(@numframes*0.1).floor - @angmult = 2/(@numframes/50) + @angmult = 2/(@numframes/50.0) end def disposed?; @disposed; end @@ -1384,7 +1384,7 @@ module Transitions @ballsprites[i].bitmap = @ballbitmap end @suby = (@height*3.5)/(@numframes*0.6) - @angmult = 4/(@numframes/50) + @angmult = 4/(@numframes/50.0) end def disposed?; @disposed; end @@ -1484,7 +1484,7 @@ module Transitions @blacksprite.oy = @blackbitmap.height/2 @blacksprite.visible = false @blacksprite.bitmap = @blackbitmap - @angmult = 4/(@numframes/50) + @angmult = 4/(@numframes/50.0) end def disposed?; @disposed; end diff --git a/Data/Scripts/012_Battle/002_Move/003_Move_Usage_Calculations.rb b/Data/Scripts/012_Battle/002_Move/003_Move_Usage_Calculations.rb index 8f5a7318a..f17b3bc78 100644 --- a/Data/Scripts/012_Battle/002_Move/003_Move_Usage_Calculations.rb +++ b/Data/Scripts/012_Battle/002_Move/003_Move_Usage_Calculations.rb @@ -65,8 +65,16 @@ class PokeBattle_Move tTypes = target.pbTypes(true) # Get effectivenesses typeMods = [Effectiveness::NORMAL_EFFECTIVE_ONE] * 3 # 3 types max - tTypes.each_with_index do |type,i| - typeMods[i] = pbCalcTypeModSingle(moveType,type,user,target) + if moveType == :SHADOW + if target.shadowPokemon? + typeMods[0] = Effectiveness::NOT_VERY_EFFECTIVE_ONE + else + typeMods[0] = Effectiveness::SUPER_EFFECTIVE_ONE + end + else + tTypes.each_with_index do |type,i| + typeMods[i] = pbCalcTypeModSingle(moveType,type,user,target) + end end # Multiply all effectivenesses together ret = 1 diff --git a/Data/Scripts/012_Battle/002_Move/007_Move_Effects_100-17F.rb b/Data/Scripts/012_Battle/002_Move/007_Move_Effects_100-17F.rb index 7a2560e3c..24e77fda7 100644 --- a/Data/Scripts/012_Battle/002_Move/007_Move_Effects_100-17F.rb +++ b/Data/Scripts/012_Battle/002_Move/007_Move_Effects_100-17F.rb @@ -1649,7 +1649,8 @@ class PokeBattle_Move_14E < PokeBattle_TwoTurnMove @battle.pbDisplay(_INTL("{1} is absorbing power!",user.pbThis)) end - def pbAttackingTurnEffect(user,target) + def pbEffectGeneral(user) + return if !@damagingTurn showAnim = true [:SPECIAL_ATTACK,:SPECIAL_DEFENSE,:SPEED].each do |s| next if !user.pbCanRaiseStatStage?(s,user,self) diff --git a/Data/Scripts/012_Battle/003_Battle/001_PokeBattle_BattleCommon.rb b/Data/Scripts/012_Battle/003_Battle/001_PokeBattle_BattleCommon.rb index 1138d5634..d8b4b9aa9 100644 --- a/Data/Scripts/012_Battle/003_Battle/001_PokeBattle_BattleCommon.rb +++ b/Data/Scripts/012_Battle/003_Battle/001_PokeBattle_BattleCommon.rb @@ -131,10 +131,8 @@ module PokeBattle_BattleCommon battler.captured = false end battler.pbReset - if trainerBattle? - @decision = 1 if pbAllFainted?(battler.index) - else - @decision = 4 if pbAllFainted?(battler.index) # Battle ended by capture + if pbAllFainted?(battler.index) + @decision = (trainerBattle?) ? 1 : 4 # Battle ended by win/capture end # Modify the Pokémon's properties because of the capture if GameData::Item.get(ball).is_snag_ball? diff --git a/Data/Scripts/012_Battle/004_AI/006_AI_Move_Utilities.rb b/Data/Scripts/012_Battle/004_AI/006_AI_Move_Utilities.rb index 4a06e899b..76dfa71fa 100644 --- a/Data/Scripts/012_Battle/004_AI/006_AI_Move_Utilities.rb +++ b/Data/Scripts/012_Battle/004_AI/006_AI_Move_Utilities.rb @@ -60,8 +60,16 @@ class PokeBattle_AI tTypes = target.pbTypes(true) # Get effectivenesses typeMods = [Effectiveness::NORMAL_EFFECTIVE_ONE] * 3 # 3 types max - tTypes.each_with_index do |type,i| - typeMods[i] = pbCalcTypeModSingle(moveType,type,user,target) + if moveType == :SHADOW + if target.shadowPokemon? + typeMods[0] = Effectiveness::NOT_VERY_EFFECTIVE_ONE + else + typeMods[0] = Effectiveness::SUPER_EFFECTIVE_ONE + end + else + tTypes.each_with_index do |type,i| + typeMods[i] = pbCalcTypeModSingle(moveType,type,user,target) + end end # Multiply all effectivenesses together ret = 1 diff --git a/Data/Scripts/012_Battle/005_Battle scene/009_Scene_Animations.rb b/Data/Scripts/012_Battle/005_Battle scene/009_Scene_Animations.rb index 454f29437..57c81a28b 100644 --- a/Data/Scripts/012_Battle/005_Battle scene/009_Scene_Animations.rb +++ b/Data/Scripts/012_Battle/005_Battle scene/009_Scene_Animations.rb @@ -409,7 +409,7 @@ class PokeBattle_Scene return anim if anim # Actual animation not found, get the default animation for the move's type moveData = GameData::Move.get(moveID) - target_data = moveData.pbTarget(@battle.battlers[idxUser]) + target_data = GameData::Target.get(moveData.target) moveType = moveData.type moveKind = moveData.category moveKind += 3 if target_data.num_targets > 1 || target_data.affects_foe_side diff --git a/Data/Scripts/013_Overworld/002_Overworld_Metadata.rb b/Data/Scripts/013_Overworld/002_Overworld_Metadata.rb index 8c3866681..9cec49832 100644 --- a/Data/Scripts/013_Overworld/002_Overworld_Metadata.rb +++ b/Data/Scripts/013_Overworld/002_Overworld_Metadata.rb @@ -12,7 +12,6 @@ class PokemonGlobalMetadata # Player data attr_accessor :startTime attr_accessor :stepcount - attr_accessor :playerID attr_accessor :pcItemStorage attr_accessor :mailbox attr_accessor :phoneNumbers @@ -66,7 +65,6 @@ class PokemonGlobalMetadata # Player data @startTime = Time.now @stepcount = 0 - @playerID = -1 @pcItemStorage = nil @mailbox = nil @phoneNumbers = [] @@ -114,6 +112,22 @@ class PokemonGlobalMetadata @safesave = false end + # @deprecated Use {Player#character_ID} instead. This alias is slated to be removed in v20. + def playerID + Deprecation.warn_method('PokemonGlobalMetadata#playerID', 'v20', '$Trainer.character_ID') + return @playerID || $Trainer.character_ID + end + + # @deprecated Use {Player#character_ID=} instead. This alias is slated to be removed in v20. + def playerID=(value) + Deprecation.warn_method('PokemonGlobalMetadata#playerID=', 'v20', '$Trainer.character_ID=') + if value.nil? + @playerID = value # For setting to nil by a save data conversion + else + $Trainer.character_ID = value + end + end + # @deprecated Use {Player#coins} instead. This alias is slated to be removed in v20. def coins Deprecation.warn_method('PokemonGlobalMetadata#coins', 'v20', '$Trainer.coins') diff --git a/Data/Scripts/013_Overworld/005_Overworld_Fishing.rb b/Data/Scripts/013_Overworld/005_Overworld_Fishing.rb index 4dde6e11d..4e6bc245c 100644 --- a/Data/Scripts/013_Overworld/005_Overworld_Fishing.rb +++ b/Data/Scripts/013_Overworld/005_Overworld_Fishing.rb @@ -5,7 +5,7 @@ def pbFishingBegin $PokemonGlobal.fishing = true if !pbCommonEvent(Settings::FISHING_BEGIN_COMMON_EVENT) patternb = 2*$game_player.direction - 1 - meta = GameData::Metadata.get_player($PokemonGlobal.playerID) + meta = GameData::Metadata.get_player($Trainer.character_ID) num = ($PokemonGlobal.surfing) ? 7 : 6 if meta && meta[num] && meta[num]!="" charset = pbGetPlayerCharset(meta,num) @@ -24,7 +24,7 @@ end def pbFishingEnd if !pbCommonEvent(Settings::FISHING_END_COMMON_EVENT) patternb = 2*($game_player.direction - 2) - meta = GameData::Metadata.get_player($PokemonGlobal.playerID) + meta = GameData::Metadata.get_player($Trainer.character_ID) num = ($PokemonGlobal.surfing) ? 7 : 6 if meta && meta[num] && meta[num]!="" charset = pbGetPlayerCharset(meta,num) diff --git a/Data/Scripts/014_Trainers/001_Trainer.rb b/Data/Scripts/014_Trainers/001_Trainer.rb index d3ac81c0c..aef1650fe 100644 --- a/Data/Scripts/014_Trainers/001_Trainer.rb +++ b/Data/Scripts/014_Trainers/001_Trainer.rb @@ -40,8 +40,6 @@ class Trainer def gender; return GameData::TrainerType.get(@trainer_type).gender; end def male?; return GameData::TrainerType.get(@trainer_type).male?; end def female?; return GameData::TrainerType.get(@trainer_type).female?; end - alias isMale? male? - alias isFemale? female? def skill_level; return GameData::TrainerType.get(@trainer_type).skill_level; end def skill_code; return GameData::TrainerType.get(@trainer_type).skill_code; end diff --git a/Data/Scripts/014_Trainers/004_Player.rb b/Data/Scripts/014_Trainers/004_Player.rb index b632b973d..842f94895 100644 --- a/Data/Scripts/014_Trainers/004_Player.rb +++ b/Data/Scripts/014_Trainers/004_Player.rb @@ -2,8 +2,8 @@ # Trainer class for the player #=============================================================================== class Player < Trainer - # @param value [Integer] new character ID - attr_writer :character_ID + # @return [Integer] the character ID of the player + attr_accessor :character_ID # @return [Integer] the player's outfit attr_accessor :outfit # @return [Array] the player's Gym Badges (true if owned) @@ -38,12 +38,6 @@ class Player < Trainer return str end - # @return [Integer] the character ID of the player - def character_ID - @character_ID = $PokemonGlobal.playerID || 0 if !@character_ID - return @character_ID - end - # Sets the player's money. It can not exceed {Settings::MAX_MONEY}. # @param value [Integer] new money value def money=(value) @@ -96,7 +90,7 @@ class Player < Trainer def initialize(name, trainer_type) super - @character_ID = nil + @character_ID = -1 @outfit = 0 @badges = [false] * 8 @money = Settings::INITIAL_MONEY diff --git a/Data/Scripts/014_Trainers/005_Player_Pokedex.rb b/Data/Scripts/014_Trainers/005_Player_Pokedex.rb index e24ba17cb..c9b86047f 100644 --- a/Data/Scripts/014_Trainers/005_Player_Pokedex.rb +++ b/Data/Scripts/014_Trainers/005_Player_Pokedex.rb @@ -34,11 +34,12 @@ class Player < Trainer # Sets the given species as seen in the Pokédex. # @param species [Symbol, GameData::Species] species to set as seen - def set_seen(species) + # @param should_refresh_dexes [Boolean] whether Dex accessibility should be recalculated + def set_seen(species, should_refresh_dexes = true) species_id = GameData::Species.try_get(species)&.species return if species_id.nil? @seen[species_id] = true - self.refresh_accessible_dexes + self.refresh_accessible_dexes if should_refresh_dexes end # @param species [Symbol, GameData::Species] species to check @@ -116,11 +117,12 @@ class Player < Trainer # Sets the given species as owned in the Pokédex. # @param species [Symbol, GameData::Species] species to set as owned - def set_owned(species) + # @param should_refresh_dexes [Boolean] whether Dex accessibility should be recalculated + def set_owned(species, should_refresh_dexes = true) species_id = GameData::Species.try_get(species)&.species return if species_id.nil? @owned[species_id] = true - self.refresh_accessible_dexes + self.refresh_accessible_dexes if should_refresh_dexes end # Sets the given species as owned in the Pokédex. @@ -162,7 +164,7 @@ class Player < Trainer # @param pkmn [Pokemon, Symbol, GameData::Species] Pokemon to register as seen # @param gender [Integer] gender to register (0=male, 1=female, 2=genderless) # @param form [Integer] form to register - def register(species, gender = 0, form = 0) + def register(species, gender = 0, form = 0, should_refresh_dexes = true) if species.is_a?(Pokemon) species_data = species.species_data gender = species.gender @@ -183,7 +185,7 @@ class Player < Trainer @seen_forms[species][gender][form] = true @last_seen_forms[species] ||= [] @last_seen_forms[species] = [gender, form] if @last_seen_forms[species] == [] - self.refresh_accessible_dexes + self.refresh_accessible_dexes if should_refresh_dexes end # @param pkmn [Pokemon] Pokemon to register as most recently seen diff --git a/Data/Scripts/014_Trainers/006_Player_Deprecated.rb b/Data/Scripts/014_Trainers/006_Player_Deprecated.rb index c8b330007..6239ad8b2 100644 --- a/Data/Scripts/014_Trainers/006_Player_Deprecated.rb +++ b/Data/Scripts/014_Trainers/006_Player_Deprecated.rb @@ -7,6 +7,8 @@ class Trainer deprecated_method_alias :secretID, :secret_ID, removal_in: 'v20' deprecated_method_alias :getForeignID, :make_foreign_ID, removal_in: 'v20' deprecated_method_alias :trainerTypeName, :trainer_type_name, removal_in: 'v20' + deprecated_method_alias :isMale?, :male?, removal_in: 'v20' + deprecated_method_alias :isFemale?, :female?, removal_in: 'v20' deprecated_method_alias :moneyEarned, :base_money, removal_in: 'v20' deprecated_method_alias :skill, :skill_level, removal_in: 'v20' deprecated_method_alias :skillCode, :skill_code, removal_in: 'v20' @@ -75,6 +77,7 @@ class Player < Trainer end end +# @deprecated Use {Player} instead. PokeBattle_Trainer is slated to be removed in v20. class PokeBattle_Trainer attr_reader :trainertype, :name, :id, :metaID, :outfit, :language attr_reader :party, :badges, :money diff --git a/Data/Scripts/016_Pokemon/001_Pokemon.rb b/Data/Scripts/016_Pokemon/001_Pokemon.rb index 11afbbd36..65e67949c 100644 --- a/Data/Scripts/016_Pokemon/001_Pokemon.rb +++ b/Data/Scripts/016_Pokemon/001_Pokemon.rb @@ -142,10 +142,6 @@ class Pokemon $Trainer.pokedex.register(self) end - def setForm(value) - self.form = value - end - def form_simple=(value) @form = value calc_stats @@ -183,7 +179,6 @@ class Pokemon def egg? return @steps_to_hatch > 0 end - alias isEgg? egg? # @return [GameData::GrowthRate] this Pokémon's growth rate def growth_rate @@ -232,13 +227,11 @@ class Pokemon def able? return !egg? && @hp > 0 end - alias isAble? able? # @return [Boolean] whether the Pokémon is fainted def fainted? return !egg? && @hp <= 0 end - alias isFainted? fainted? # Heals all HP of this Pokémon. def heal_HP @@ -339,15 +332,12 @@ class Pokemon # @return [Boolean] whether this Pokémon is male def male?; return self.gender == 0; end - alias isMale? male? # @return [Boolean] whether this Pokémon is female def female?; return self.gender == 1; end - alias isFemale? female? # @return [Boolean] whether this Pokémon is genderless def genderless?; return self.gender == 2; end - alias isGenderless? genderless? # @return [Boolean] whether this Pokémon species is restricted to only ever being one # gender (or genderless) @@ -355,7 +345,6 @@ class Pokemon gender_ratio = species_data.gender_ratio return [:AlwaysMale, :AlwaysFemale, :Genderless].include?(gender_ratio) end - alias isSingleGendered? singleGendered? #============================================================================= # Shininess @@ -372,7 +361,6 @@ class Pokemon end return @shiny end - alias isShiny? shiny? #============================================================================= # Ability @@ -516,7 +504,8 @@ class Pokemon # an item at all def hasItem?(check_item = nil) return !@item.nil? if check_item.nil? - return self.item == check_item + held_item = self.item + return held_item && held_item == check_item end # @return [Array] the items this species can be found holding in the wild @@ -557,7 +546,6 @@ class Pokemon return false if !move_data return @moves.any? { |m| m.id == move_data.id } end - alias knowsMove? hasMove? # Returns the list of moves this Pokémon can learn by levelling up. # @return [Array>] this Pokémon's move list, where every element is [level, move ID] @@ -786,7 +774,6 @@ class Pokemon def foreign?(trainer) return @owner.id != trainer.id || @owner.name != trainer.name end - alias isForeign? foreign? # @return [Time] the time when this Pokémon was obtained def timeReceived diff --git a/Data/Scripts/016_Pokemon/004_Pokemon_Move.rb b/Data/Scripts/016_Pokemon/004_Pokemon_Move.rb index 941cab755..b175d16b8 100644 --- a/Data/Scripts/016_Pokemon/004_Pokemon_Move.rb +++ b/Data/Scripts/016_Pokemon/004_Pokemon_Move.rb @@ -63,12 +63,13 @@ class Pokemon end #=============================================================================== -# Move objects known by Pokémon. +# Legacy move object known by Pokémon. #=============================================================================== +# @deprecated Use {Pokemon#Move} instead. PBMove is slated to be removed in v20. class PBMove attr_reader :id, :pp, :ppup - def self.copy(move) + def self.convert(move) ret = Pokemon::Move.new(move.id) ret.ppup = move.ppup ret.pp = move.pp diff --git a/Data/Scripts/016_Pokemon/010_Pokemon_Deprecated.rb b/Data/Scripts/016_Pokemon/010_Pokemon_Deprecated.rb index c4b31b8a9..057b708b9 100644 --- a/Data/Scripts/016_Pokemon/010_Pokemon_Deprecated.rb +++ b/Data/Scripts/016_Pokemon/010_Pokemon_Deprecated.rb @@ -3,8 +3,7 @@ # These will be removed in a future Essentials version. #=============================================================================== -# @deprecated Use {Pokemon} instead. PokeBattle_Pokemon is slated to be removed -# in v20. +# @deprecated Use {Pokemon} instead. PokeBattle_Pokemon is slated to be removed in v20. class PokeBattle_Pokemon attr_reader :name, :species, :form, :formTime, :forcedForm, :fused attr_reader :personalID, :exp, :hp, :status, :statusCount @@ -42,7 +41,7 @@ class PokeBattle_Pokemon ret.nature_for_stats = pkmn.natureOverride ret.item = pkmn.item ret.mail = PokemonMail.convert(pkmn.mail) if pkmn.mail - pkmn.moves.each { |m| ret.moves.push(PBMove.copy(m)) if m && m.id > 0 } + pkmn.moves.each { |m| ret.moves.push(PBMove.convert(m)) if m && m.id > 0 } if pkmn.firstmoves pkmn.firstmoves.each { |m| ret.add_first_move(m) } end @@ -168,12 +167,21 @@ class Pokemon self.shiny = false end + deprecated_method_alias :isEgg?, :egg?, removal_in: 'v20' + deprecated_method_alias :isAble?, :able?, removal_in: 'v20' + deprecated_method_alias :isFainted?, :fainted?, removal_in: 'v20' + deprecated_method_alias :isShiny?, :shiny?, removal_in: 'v20' + deprecated_method_alias :setForm, :form=, removal_in: 'v20' deprecated_method_alias :setGender, :gender=, removal_in: 'v20' + deprecated_method_alias :isMale?, :male?, removal_in: 'v20' + deprecated_method_alias :isFemale?, :female?, removal_in: 'v20' + deprecated_method_alias :isGenderless?, :genderless?, removal_in: 'v20' + deprecated_method_alias :isSingleGendered?, :singleGendered?, removal_in: 'v20' deprecated_method_alias :setAbility, :ability_index=, removal_in: 'v20' deprecated_method_alias :setNature, :nature=, removal_in: 'v20' deprecated_method_alias :setItem, :item=, removal_in: 'v20' - deprecated_method_alias :healStatus, :heal_status, removal_in: 'v20' + deprecated_method_alias :knowsMove?, :hasMove?, removal_in: 'v20' deprecated_method_alias :resetMoves, :reset_moves, removal_in: 'v20' deprecated_method_alias :pbLearnMove, :learn_move, removal_in: 'v20' deprecated_method_alias :pbDeleteMove, :forget_move, removal_in: 'v20' @@ -183,6 +191,7 @@ class Pokemon deprecated_method_alias :pbRemoveFirstMove, :remove_first_move, removal_in: 'v20' deprecated_method_alias :pbClearFirstMoves, :clear_first_moves, removal_in: 'v20' deprecated_method_alias :pbUpdateShadowMoves, :update_shadow_moves, removal_in: 'v20' + deprecated_method_alias :isForeign?, :foreign?, removal_in: 'v20' deprecated_method_alias :calcStats, :calc_stats, removal_in: 'v20' end diff --git a/Data/Scripts/020_System and utilities/005_PSystem_Utilities.rb b/Data/Scripts/020_System and utilities/005_PSystem_Utilities.rb index 04e9ed1a9..ecef851af 100644 --- a/Data/Scripts/020_System and utilities/005_PSystem_Utilities.rb +++ b/Data/Scripts/020_System and utilities/005_PSystem_Utilities.rb @@ -206,8 +206,9 @@ end #=============================================================================== # Player-related utilities, random name generator #=============================================================================== +# Unused def pbGetPlayerGraphic - id = $PokemonGlobal.playerID + id = $Trainer.character_ID return "" if id < 0 || id >= 8 meta = GameData::Metadata.get_player(id) return "" if !meta @@ -222,28 +223,24 @@ def pbChangePlayer(id) return false if id < 0 || id >= 8 meta = GameData::Metadata.get_player(id) return false if !meta - $Trainer.trainer_type = meta[0] if $Trainer + $Trainer.character_ID = id + $Trainer.trainer_type = meta[0] $game_player.character_name = meta[1] - $PokemonGlobal.playerID = id - $Trainer.character_ID = id if $Trainer end def pbTrainerName(name = nil, outfit = 0) - pbChangePlayer(0) if $PokemonGlobal.playerID < 0 - player_metadata = GameData::Metadata.get_player($PokemonGlobal.playerID) - trainer_type = (player_metadata) ? player_metadata[0] : nil - $Trainer = Player.new(name, trainer_type) - $Trainer.outfit = outfit - $Trainer.character_ID = $PokemonGlobal.playerID + pbChangePlayer(0) if $Trainer.character_ID < 0 if name.nil? name = pbEnterPlayerName(_INTL("Your name?"), 0, Settings::MAX_PLAYER_NAME_SIZE) if name.nil? || name.empty? + player_metadata = GameData::Metadata.get_player($Trainer.character_ID) + trainer_type = (player_metadata) ? player_metadata[0] : nil gender = pbGetTrainerTypeGender(trainer_type) name = pbSuggestTrainerName(gender) end end - $Trainer.name = name - $PokemonBag = PokemonBag.new + $Trainer.name = name + $Trainer.outfit = outfit $PokemonTemp.begunNewGame = true end diff --git a/Data/Scripts/021_Debug/001_Debug menus/002_Debug_MenuCommands.rb b/Data/Scripts/021_Debug/001_Debug menus/002_Debug_MenuCommands.rb index bb45aaafd..909e87d1c 100644 --- a/Data/Scripts/021_Debug/001_Debug menus/002_Debug_MenuCommands.rb +++ b/Data/Scripts/021_Debug/001_Debug menus/002_Debug_MenuCommands.rb @@ -610,17 +610,17 @@ DebugMenuCommands.register("fillboxes", { if f == 0 if [:AlwaysMale, :AlwaysFemale, :Genderless].include?(species_data.gender_ratio) g = (species_data.gender_ratio == :AlwaysFemale) ? 1 : 0 - $Trainer.pokedex.register(sp, g, f) + $Trainer.pokedex.register(sp, g, f, false) else # Both male and female - $Trainer.pokedex.register(sp, 0, f) - $Trainer.pokedex.register(sp, 1, f) + $Trainer.pokedex.register(sp, 0, f, false) + $Trainer.pokedex.register(sp, 1, f, false) end - $Trainer.pokedex.set_owned(sp) + $Trainer.pokedex.set_owned(sp, false) elsif species_data.real_form_name && !species_data.real_form_name.empty? g = (species_data.gender_ratio == :AlwaysFemale) ? 1 : 0 - $Trainer.pokedex.register(sp, g, f) + $Trainer.pokedex.register(sp, g, f, false) end - # Add Pokémon (if form 0) + # Add Pokémon (if form 0, i.e. one of each species) next if f != 0 if added >= Settings::NUM_STORAGE_BOXES * box_qty completed = false @@ -629,6 +629,7 @@ DebugMenuCommands.register("fillboxes", { added += 1 $PokemonStorage[(added - 1) / box_qty, (added - 1) % box_qty] = Pokemon.new(sp, 50) end + $Trainer.pokedex.refresh_accessible_dexes pbMessage(_INTL("Storage boxes were filled with one Pokémon of each species.")) if !completed pbMessage(_INTL("Note: The number of storage spaces ({1} boxes of {2}) is less than the number of species.", @@ -808,9 +809,9 @@ DebugMenuCommands.register("setplayer", { else params = ChooseNumberParams.new params.setRange(0, limit - 1) - params.setDefaultValue($PokemonGlobal.playerID) + params.setDefaultValue($Trainer.character_ID) newid = pbMessageChooseNumber(_INTL("Choose the new player character."), params) - if newid != $PokemonGlobal.playerID + if newid != $Trainer.character_ID pbChangePlayer(newid) pbMessage(_INTL("The player character was changed.")) end diff --git a/Data/Scripts/021_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb b/Data/Scripts/021_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb index de2ff2033..619db638f 100644 --- a/Data/Scripts/021_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb +++ b/Data/Scripts/021_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb @@ -308,8 +308,8 @@ def pbDefinePath(canvas) for j in 0...4 curve[j].mouseover end - mouse = Mouse::getMousePos(true) - newtext = (mouse) ? sprintf("(%d,%d)",mouse[0],mouse[1]) : "(??,??)" + mousepos = Mouse::getMousePos(true) + newtext = (mousepos) ? sprintf("(%d,%d)",mousepos[0],mousepos[1]) : "(??,??)" if window.text!=newtext window.text=newtext end @@ -382,7 +382,7 @@ def pbDefinePath(canvas) end while !canceled mousepos=Mouse::getMousePos(true) - if mouse && !pointpath.isEndPoint?(mousepos[0],mousepos[1]) + if mousepos && !pointpath.isEndPoint?(mousepos[0],mousepos[1]) pointpath.addPoint(mousepos[0],mousepos[1]) points.push(PointSprite.new(mousepos[0],mousepos[1],canvas.viewport)) end diff --git a/Data/Scripts/022_Compiler/002_Compiler_CompilePBS.rb b/Data/Scripts/022_Compiler/002_Compiler_CompilePBS.rb index 3064e7b96..3cd204e18 100644 --- a/Data/Scripts/022_Compiler/002_Compiler_CompilePBS.rb +++ b/Data/Scripts/022_Compiler/002_Compiler_CompilePBS.rb @@ -247,7 +247,7 @@ module Compiler move_descriptions = [] # Read each line of moves.txt at a time and compile it into an move pbCompilerEachPreppedLine("PBS/moves.txt") { |line, line_no| - line = pbGetCsvRecord(line, line_no, [0, "vnssueeuuuyiss", + line = pbGetCsvRecord(line, line_no, [0, "vnssueeuuueiss", nil, nil, nil, nil, nil, :Type, ["Physical", "Special", "Status"], nil, nil, nil, :Target, nil, nil, nil ])