Fixed code assuming map metadata exists, fixed misplaced species data methods, rewrote class PokeBattle_Pokemon

This commit is contained in:
Maruno17
2021-01-20 20:22:31 +00:00
parent 7f254c6434
commit 736bb9ed10
24 changed files with 283 additions and 198 deletions

View File

@@ -59,7 +59,7 @@ class Pokemon
attr_reader :status
# @return [Integer] sleep count / toxic flag / 0:
# sleep (number of rounds before waking up), toxic (0 = regular poison, 1 = toxic)
attr_reader :statusCount
attr_accessor :statusCount
# Another Pokémon which has been fused with this Pokémon (or nil if there is none).
# Currently only used by Kyurem, to record a fused Reshiram or Zekrom.
# @return [Pokemon, nil] the Pokémon fused into this one (nil if there is none)
@@ -751,12 +751,6 @@ class Pokemon
@status = new_status
end
# Sets a new status count. See {#statusCount} for more information.
# @param new_status_count [Integer] new sleep count / toxic flag
def statusCount=(new_status_count)
@statusCount = new_status_count
end
# @return [Boolean] whether the Pokémon is not fainted and not an egg
def able?
return !egg? && @hp > 0
@@ -824,7 +818,8 @@ class Pokemon
# @param check_species [Integer, Symbol, String] id of the species to check for
# @return [Boolean] whether this Pokémon is of the specified species
def isSpecies?(check_species)
return @species == check_species || @species == GameData::Species.get(check_species).species
return @species == check_species || (GameData::Species.exists?(check_species) &&
@species == GameData::Species.get(check_species).species)
end
def form

View File

@@ -582,8 +582,9 @@ MultipleForms.register(:NECROZMA,{
MultipleForms.register(:PIKACHU, {
"getForm" => proc { |pkmn|
next if pkmn.formSimple >= 2
mapPos = GameData::MapMetadata.get($game_map.map_id).town_map_position
next 1 if mapPos && mapPos[0] == 1 # Tiall region
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
next 1 if map_metadata && map_metadata.town_map_position &&
map_metadata.town_map_position[0] == 1 # Tiall region
next 0
}
})

View File

@@ -0,0 +1,43 @@
#===============================================================================
# Move objects known by Pokémon.
#===============================================================================
class PBMove
attr_reader :id # This move's ID
attr_accessor :pp # The amount of PP remaining for this move
attr_accessor :ppup # The number of PP Ups used on this move
# Initializes this object to the specified move ID.
def initialize(move_id)
@id = GameData::Move.get(move_id).id
@ppup = 0
@pp = total_pp
end
# Changes this move's ID, and caps the PP amount if it is now greater than the
# new move's total PP.
def id=(value)
old_id = @id
@id = GameData::Move.get(value).id
@pp = [@pp, total_pp].min
end
# Gets the maximum PP for this move.
def total_pp
max_pp = GameData::Move.get(@id).total_pp
return max_pp + max_pp * @ppup / 5
end
alias totalpp total_pp
def function_code; return GameData::Move.get(@id).function_code; end
def base_damage; return GameData::Move.get(@id).base_damage; end
def type; return GameData::Move.get(@id).type; end
def category; return GameData::Move.get(@id).category; end
def accuracy; return GameData::Move.get(@id).accuracy; end
def effect_chance; return GameData::Move.get(@id).effect_chance; end
def target; return GameData::Move.get(@id).target; end
def priority; return GameData::Move.get(@id).priority; end
def flags; return GameData::Move.get(@id).flags; end
def name; return GameData::Move.get(@id).name; end
def description; return GameData::Move.get(@id).description; end
def hidden_move?; return GameData::Move.get(@id).hidden_move?; end
end

View File

@@ -401,7 +401,8 @@ PBEvolution.register(:LevelDiving, {
PBEvolution.register(:LevelDarkness, {
"levelUpCheck" => proc { |pkmn, parameter|
next pkmn.level >= parameter && GameData::MapMetadata.get($game_map.map_id).dark_map
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
next pkmn.level >= parameter && map_metadata && map_metadata.dark_map
}
})
@@ -660,8 +661,9 @@ PBEvolution.register(:Location, {
PBEvolution.register(:Region, {
"minimumLevel" => 1, # Needs any level up
"levelUpCheck" => proc { |pkmn, parameter|
mapPos = GameData::MapMetadata.get($game_map.map_id).town_map_position
next mapPos && mapPos[0] == parameter
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
next map_metadata && map_metadata.town_map_position &&
map_metadata.town_map_position[0] == parameter
}
})

View File

@@ -3,11 +3,85 @@
# These will be removed in a future Essentials version.
#===============================================================================
# @deprecated Use {Pokemon} instead. PokeBattle_Pokemon has been turned into an alias
# and is slated to be removed in v20.
class PokeBattle_Pokemon; end
# @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
attr_reader :abilityflag, :genderflag, :natureflag, :natureOverride, :shinyflag
attr_reader :moves, :firstmoves
attr_reader :item, :mail
attr_reader :iv, :ivMaxed, :ev
attr_reader :happiness, :eggsteps, :pokerus
attr_reader :ballused, :markings, :ribbons
attr_reader :obtainMode, :obtainMap, :obtainText, :obtainLevel, :hatchedMap
attr_reader :timeReceived, :timeEggHatched
attr_reader :cool, :beauty, :cute, :smart, :tough, :sheen
attr_reader :trainerID, :ot, :otgender, :language
attr_reader :shadow, :heartgauge, :savedexp, :savedev, :hypermode
attr_reader :shadowmoves, :shadowmovenum
PokeBattle_Pokemon = Pokemon
def initialise
raise "PokeBattle_Pokemon.new is deprecated. Use Pokemon.new instead."
end
def self.copy(pkmn)
owner = Pokemon::Owner.new(pkmn.trainerID, pkmn.ot, pkmn.otgender, pkmn.language)
ret = Pokemon.new(pkmn.species, pkmn.level, owner, false)
ret.name = pkmn.name
ret.exp = pkmn.exp
ret.formTime = pkmn.formTime
ret.forcedForm = pkmn.forcedForm
ret.hp = pkmn.hp
ret.abilityflag = pkmn.abilityflag
ret.genderflag = pkmn.genderflag
ret.natureflag = pkmn.natureflag
ret.natureOverride = pkmn.natureOverride
ret.shinyflag = pkmn.shinyflag
ret.item_id = pkmn.item
ret.mail = pkmn.mail
ret.moves = pkmn.moves
ret.firstmoves = pkmn.firstmoves.clone
ret.status = pkmn.status
ret.statusCount = pkmn.statusCount
ret.iv = pkmn.iv.clone
ret.ev = pkmn.ev.clone
ret.ivMaxed = pkmn.ivMaxed if pkmn.ivMaxed
ret.happiness = pkmn.happiness
ret.ballused = pkmn.ballused
ret.eggsteps = pkmn.eggsteps
ret.markings = pkmn.markings if pkmn.markings
ret.ribbons = pkmn.ribbons.clone
ret.pokerus = pkmn.pokerus
ret.personalID = pkmn.personalID
ret.obtainMode = pkmn.obtainMode
ret.obtainMap = pkmn.obtainMap
ret.obtainText = pkmn.obtainText
ret.obtainLevel = pkmn.obtainLevel if pkmn.obtainLevel
ret.hatchedMap = pkmn.hatchedMap
ret.timeReceived = pkmn.timeReceived
ret.timeEggHatched = pkmn.timeEggHatched
ret.cool = pkmn.cool if pkmn.cool
ret.beauty = pkmn.beauty if pkmn.beauty
ret.cute = pkmn.cute if pkmn.cute
ret.smart = pkmn.smart if pkmn.smart
ret.tough = pkmn.tough if pkmn.tough
ret.sheen = pkmn.sheen if pkmn.sheen
if pkmn.fused
ret.fused = PokeBattle_Pokemon.copy(pkmn.fused) if pkmn.fused.is_a?(PokeBattle_Pokemon)
ret.fused = pkmn.fused if pkmn.fused.is_a?(Pokemon)
end
ret.shadow = pkmn.shadow
ret.heartgauge = pkmn.heartgauge
ret.savedexp = pkmn.savedexp
ret.savedev = pkmn.savedev.clone
ret.hypermode = pkmn.hypermode
ret.shadowmoves = pkmn.shadowmoves.clone
ret.shadowmovenum = pkmn.shadowmovenum
# NOTE: Intentionally set last, as it recalculates stats.
ret.formSimple = pkmn.form
end
end
class Pokemon
# @deprecated Use {MAX_NAME_SIZE} instead. This alias is slated to be removed in v20.