Implemented GameData::Move

This commit is contained in:
Maruno17
2020-11-19 21:00:29 +00:00
parent 52ffae9e8a
commit 3cd8d59918
71 changed files with 1443 additions and 1584 deletions
@@ -217,8 +217,5 @@ end
class MoveHandlerHash < HandlerHash class MoveHandlerHash < HandlerHash2
def initialize
super(:PBMoves)
end
end end
+1 -1
View File
@@ -179,7 +179,7 @@ end
def pbLoadSpeciesTMData def pbLoadSpeciesTMData
$PokemonTemp = PokemonTemp.new if !$PokemonTemp $PokemonTemp = PokemonTemp.new if !$PokemonTemp
if !$PokemonTemp.speciesTMData if !$PokemonTemp.speciesTMData
$PokemonTemp.speciesTMData = load_data("Data/tm.dat") || [] $PokemonTemp.speciesTMData = load_data("Data/tm.dat") || {}
end end
return $PokemonTemp.speciesTMData return $PokemonTemp.speciesTMData
end end
@@ -0,0 +1,89 @@
module GameData
class Move
attr_reader :id
attr_reader :id_number
attr_reader :real_name
attr_reader :function_code
attr_reader :base_damage
attr_reader :type
attr_reader :category
attr_reader :accuracy
attr_reader :total_pp
attr_reader :effect_chance
attr_reader :target
attr_reader :priority
attr_reader :flags
attr_reader :real_description
DATA = {}
DATA_FILENAME = "moves.dat"
extend ClassMethods
include InstanceMethods
def initialize(hash)
validate hash => Hash, hash[:id] => Symbol
@id = hash[:id]
@id_number = hash[:id_number] || -1
@real_name = hash[:name] || "Unnamed"
@function_code = hash[:function_code]
@base_damage = hash[:base_damage]
@type = hash[:type]
@category = hash[:category]
@accuracy = hash[:accuracy]
@total_pp = hash[:total_pp]
@effect_chance = hash[:effect_chance]
@target = hash[:target]
@priority = hash[:priority]
@flags = hash[:flags]
@real_description = hash[:description] || "???"
end
# @return [String] the translated name of this move
def name
return pbGetMessage(MessageTypes::Moves, @id_number)
end
# @return [String] the translated description of this move
def description
return pbGetMessage(MessageTypes::MoveDescriptions, @id_number)
end
def hidden_move?
GameData::Item.each do |i|
return true if i.is_HM? && i.move == @id
end
return false
end
end
end
#===============================================================================
# Deprecated methods
#===============================================================================
module MoveData
ID = 0
INTERNAL_NAME = 1
NAME = 2
FUNCTION_CODE = 3
BASE_DAMAGE = 4
TYPE = 5
CATEGORY = 6
ACCURACY = 7
TOTAL_PP = 8
EFFECT_CHANCE = 9
TARGET = 10
PRIORITY = 11
FLAGS = 12
DESCRIPTION = 13
end
def pbGetMoveData(move_id, move_data_type = -1)
Deprecation.warn_method('pbGetMoveData', 'v20', 'GameData::Move.get(move_id)')
return GameData::Move.get(move_id)
end
def pbIsHiddenMove?(move)
Deprecation.warn_method('pbIsHiddenMove?', 'v20', 'GameData::Move.get(move).hidden_move?')
return GameData::Move.get(move).hidden_move?
end
+3 -3
View File
@@ -84,7 +84,7 @@ module SpeciesData
"Weight" => [WEIGHT, "f"], "Weight" => [WEIGHT, "f"],
"Color" => [COLOR, "e", :PBColors], "Color" => [COLOR, "e", :PBColors],
"Shape" => [SHAPE, "u"], "Shape" => [SHAPE, "u"],
"Moves" => [0, "*ue", nil, :PBMoves], "Moves" => [0, "*ue", nil, :Move],
"Kind" => [0, "s"], "Kind" => [0, "s"],
"Pokedex" => [0, "q"] "Pokedex" => [0, "q"]
} }
@@ -114,14 +114,14 @@ module SpeciesData
"BattlerAltitude" => [METRIC_ALTITUDE, "i"], "BattlerAltitude" => [METRIC_ALTITUDE, "i"],
"BattlerShadowX" => [METRIC_SHADOW_X, "i"], "BattlerShadowX" => [METRIC_SHADOW_X, "i"],
"BattlerShadowSize" => [METRIC_SHADOW_SIZE, "u"], "BattlerShadowSize" => [METRIC_SHADOW_SIZE, "u"],
"EggMoves" => [0, "*e", :PBMoves], "EggMoves" => [0, "*e", :Move],
"FormName" => [0, "q"], "FormName" => [0, "q"],
"Evolutions" => [0, "*ses", nil, :PBEvolution, nil] "Evolutions" => [0, "*ses", nil, :PBEvolution, nil]
} }
if compilingForms if compilingForms
ret["PokedexForm"] = [POKEDEX_FORM, "u"] ret["PokedexForm"] = [POKEDEX_FORM, "u"]
ret["MegaStone"] = [MEGA_STONE, "e", :Item] ret["MegaStone"] = [MEGA_STONE, "e", :Item]
ret["MegaMove"] = [MEGA_MOVE, "e", :PBMoves] ret["MegaMove"] = [MEGA_MOVE, "e", :Move]
ret["UnmegaForm"] = [UNMEGA_FORM, "u"] ret["UnmegaForm"] = [UNMEGA_FORM, "u"]
ret["MegaMessage"] = [MEGA_MESSAGE, "u"] ret["MegaMessage"] = [MEGA_MESSAGE, "u"]
else else
+22 -90
View File
@@ -1,111 +1,43 @@
module MoveData
ID = 0
INTERNAL_NAME = 1
NAME = 2
FUNCTION_CODE = 3
BASE_DAMAGE = 4
TYPE = 5
CATEGORY = 6
ACCURACY = 7
TOTAL_PP = 8
EFFECT_CHANCE = 9
TARGET = 10
PRIORITY = 11
FLAGS = 12
DESCRIPTION = 13
end
class PokemonTemp
attr_accessor :movesData
end
def pbLoadMovesData
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
if !$PokemonTemp.movesData
if pbRgssExists?("Data/moves.dat")
$PokemonTemp.movesData = load_data("Data/moves.dat")
else
$PokemonTemp.movesData = []
end
end
return $PokemonTemp.movesData
end
def pbGetMoveData(move_id, move_data_type = -1)
meta = pbLoadMovesData
if move_data_type < 0
return meta[move_id] || []
end
return meta[move_id][move_data_type] if meta[move_id]
return nil
end
alias __moveData__pbClearData pbClearData
def pbClearData
$PokemonTemp.movesData = nil if $PokemonTemp
__moveData__pbClearData
end
#=============================================================================== #===============================================================================
# Move objects known by Pokémon. # Move objects known by Pokémon.
#=============================================================================== #===============================================================================
class PBMove class PBMove
attr_reader(:id) # This move's ID attr_reader :id # This move's ID
attr_accessor(:pp) # The amount of PP remaining for this move attr_accessor :pp # The amount of PP remaining for this move
attr_accessor(:ppup) # The number of PP Ups used for this move attr_accessor :ppup # The number of PP Ups used on this move
# Initializes this object to the specified move ID. # Initializes this object to the specified move ID.
def initialize(move_id) def initialize(move_id)
@id = move_id @id = GameData::Move.get(move_id).id
@pp = pbGetMoveData(move_id, MoveData::TOTAL_PP) || 0
@ppup = 0 @ppup = 0
@pp = total_pp
end end
# Changes this move's ID, and caps the PP amount if it is now greater than the # Changes this move's ID, and caps the PP amount if it is now greater than the
# new move's total PP. # new move's total PP.
def id=(value) def id=(value)
old_id = @id old_id = @id
@id = value @id = GameData::Move.get(value).id
@pp = [@pp, totalpp].min if old_id > 0 @pp = [@pp, total_pp].min
end
# Gets this move's type.
def type
return pbGetMoveData(@id, MoveData::TYPE) || 0
end end
# Gets the maximum PP for this move. # Gets the maximum PP for this move.
def totalpp def total_pp
max_pp = pbGetMoveData(@id, MoveData::TOTAL_PP) || 0 max_pp = GameData::Move.get(@id).total_pp
return max_pp + max_pp * @ppup / 5 return max_pp + max_pp * @ppup / 5
end end
end alias totalpp total_pp
#=============================================================================== def function_code; return GameData::Move.get(@id).function_code; end
# Object containing move data. Not used for much. def base_damage; return GameData::Move.get(@id).base_damage; end
#=============================================================================== def type; return GameData::Move.get(@id).type; end
class PBMoveData def category; return GameData::Move.get(@id).category; end
attr_reader :function, :basedamage, :type, :accuracy, :category def accuracy; return GameData::Move.get(@id).accuracy; end
attr_reader :totalpp, :addlEffect, :target, :priority, :flags def effect_chance; return GameData::Move.get(@id).effect_chance; end
def target; return GameData::Move.get(@id).target; end
def initialize(move_id) def priority; return GameData::Move.get(@id).priority; end
move_data = pbGetMoveData(move_id) def flags; return GameData::Move.get(@id).flags; end
@function = move_data[MoveData::FUNCTION_CODE] def name; return GameData::Move.get(@id).name; end
@basedamage = move_data[MoveData::BASE_DAMAGE] def description; return GameData::Move.get(@id).description; end
@type = move_data[MoveData::TYPE] def hidden_move?; return GameData::Move.get(@id).hidden_move?; end
@category = move_data[MoveData::CATEGORY]
@accuracy = move_data[MoveData::ACCURACY]
@totalpp = move_data[MoveData::TOTAL_PP]
@addlEffect = move_data[MoveData::EFFECT_CHANCE]
@target = move_data[MoveData::TARGET]
@priority = move_data[MoveData::PRIORITY]
@flags = move_data[MoveData::FLAGS]
end
end
def pbIsHiddenMove?(move)
GameData::Item.each do |i|
return true if i.is_HM? && move == i.move
end
return false
end end
@@ -429,16 +429,15 @@ class PokeBattle_Battler
end end
def eachMove def eachMove
@moves.each { |m| yield m if m && m.id != 0 } @moves.each { |m| yield m }
end end
def eachMoveWithIndex def eachMoveWithIndex
@moves.each_with_index { |m, i| yield m, i if m && m.id != 0 } @moves.each_with_index { |m, i| yield m, i }
end end
def pbHasMove?(move_id) def pbHasMove?(move_id)
move_id = getID(PBMoves, move_id) return false if !move_id
return false if !move_id || move_id <= 0
eachMove { |m| return true if m.id == move_id } eachMove { |m| return true if m.id == move_id }
return false return false
end end
@@ -574,7 +573,7 @@ class PokeBattle_Battler
end end
def usingMultiTurnAttack? def usingMultiTurnAttack?
return true if @effects[PBEffects::TwoTurnAttack]>0 return true if @effects[PBEffects::TwoTurnAttack]
return true if @effects[PBEffects::HyperBeam]>0 return true if @effects[PBEffects::HyperBeam]>0
return true if @effects[PBEffects::Rollout]>0 return true if @effects[PBEffects::Rollout]>0
return true if @effects[PBEffects::Outrage]>0 return true if @effects[PBEffects::Outrage]>0
@@ -584,8 +583,8 @@ class PokeBattle_Battler
end end
def inTwoTurnAttack?(*arg) def inTwoTurnAttack?(*arg)
return false if @effects[PBEffects::TwoTurnAttack]==0 return false if !@effects[PBEffects::TwoTurnAttack]
ttaFunction = pbGetMoveData(@effects[PBEffects::TwoTurnAttack],MoveData::FUNCTION_CODE) ttaFunction = GameData::Move.get(@effects[PBEffects::TwoTurnAttack]).function_code
arg.each { |a| return true if a==ttaFunction } arg.each { |a| return true if a==ttaFunction }
return false return false
end end
@@ -595,7 +594,7 @@ class PokeBattle_Battler
end end
def pbEncoredMoveIndex def pbEncoredMoveIndex
return -1 if @effects[PBEffects::Encore]==0 || @effects[PBEffects::EncoreMove]==0 return -1 if @effects[PBEffects::Encore]==0 || !@effects[PBEffects::EncoreMove]
ret = -1 ret = -1
eachMoveWithIndex do |m,i| eachMoveWithIndex do |m,i|
next if m.id!=@effects[PBEffects::EncoreMove] next if m.id!=@effects[PBEffects::EncoreMove]
@@ -147,9 +147,9 @@ class PokeBattle_Battler
@lastHPLostFromFoe = 0 @lastHPLostFromFoe = 0
@tookDamage = false @tookDamage = false
@tookPhysicalHit = false @tookPhysicalHit = false
@lastMoveUsed = -1 @lastMoveUsed = nil
@lastMoveUsedType = -1 @lastMoveUsedType = -1
@lastRegularMoveUsed = -1 @lastRegularMoveUsed = nil
@lastRegularMoveTarget = -1 @lastRegularMoveTarget = -1
@lastRoundMoved = -1 @lastRoundMoved = -1
@lastMoveFailed = false @lastMoveFailed = false
@@ -167,7 +167,7 @@ class PokeBattle_Battler
@effects[PBEffects::BideTarget] = -1 @effects[PBEffects::BideTarget] = -1
@effects[PBEffects::BurnUp] = false @effects[PBEffects::BurnUp] = false
@effects[PBEffects::Charge] = 0 @effects[PBEffects::Charge] = 0
@effects[PBEffects::ChoiceBand] = -1 @effects[PBEffects::ChoiceBand] = nil
@effects[PBEffects::Counter] = -1 @effects[PBEffects::Counter] = -1
@effects[PBEffects::CounterTarget] = -1 @effects[PBEffects::CounterTarget] = -1
@effects[PBEffects::Dancer] = false @effects[PBEffects::Dancer] = false
@@ -176,10 +176,10 @@ class PokeBattle_Battler
@effects[PBEffects::DestinyBondPrevious] = false @effects[PBEffects::DestinyBondPrevious] = false
@effects[PBEffects::DestinyBondTarget] = -1 @effects[PBEffects::DestinyBondTarget] = -1
@effects[PBEffects::Disable] = 0 @effects[PBEffects::Disable] = 0
@effects[PBEffects::DisableMove] = 0 @effects[PBEffects::DisableMove] = nil
@effects[PBEffects::Electrify] = false @effects[PBEffects::Electrify] = false
@effects[PBEffects::Encore] = 0 @effects[PBEffects::Encore] = 0
@effects[PBEffects::EncoreMove] = 0 @effects[PBEffects::EncoreMove] = nil
@effects[PBEffects::Endure] = false @effects[PBEffects::Endure] = false
@effects[PBEffects::FirstPledge] = 0 @effects[PBEffects::FirstPledge] = 0
@effects[PBEffects::FlashFire] = false @effects[PBEffects::FlashFire] = false
@@ -240,7 +240,6 @@ class PokeBattle_Battler
@effects[PBEffects::Quash] = 0 @effects[PBEffects::Quash] = 0
@effects[PBEffects::Rage] = false @effects[PBEffects::Rage] = false
@effects[PBEffects::RagePowder] = false @effects[PBEffects::RagePowder] = false
@effects[PBEffects::Revenge] = 0
@effects[PBEffects::Rollout] = 0 @effects[PBEffects::Rollout] = 0
@effects[PBEffects::Roost] = false @effects[PBEffects::Roost] = false
@effects[PBEffects::SkyDrop] = -1 @effects[PBEffects::SkyDrop] = -1
@@ -262,7 +261,7 @@ class PokeBattle_Battler
@effects[PBEffects::Transform] = false @effects[PBEffects::Transform] = false
@effects[PBEffects::TransformSpecies] = 0 @effects[PBEffects::TransformSpecies] = 0
@effects[PBEffects::Trapping] = 0 @effects[PBEffects::Trapping] = 0
@effects[PBEffects::TrappingMove] = 0 @effects[PBEffects::TrappingMove] = nil
@effects[PBEffects::TrappingUser] = -1 @effects[PBEffects::TrappingUser] = -1
@battle.eachBattler do |b| # Other battlers no longer trapped by self @battle.eachBattler do |b| # Other battlers no longer trapped by self
next if b.effects[PBEffects::TrappingUser]!=@index next if b.effects[PBEffects::TrappingUser]!=@index
@@ -270,7 +269,7 @@ class PokeBattle_Battler
b.effects[PBEffects::TrappingUser] = -1 b.effects[PBEffects::TrappingUser] = -1
end end
@effects[PBEffects::Truant] = false @effects[PBEffects::Truant] = false
@effects[PBEffects::TwoTurnAttack] = 0 @effects[PBEffects::TwoTurnAttack] = nil
@effects[PBEffects::Type3] = -1 @effects[PBEffects::Type3] = -1
@effects[PBEffects::Unburden] = false @effects[PBEffects::Unburden] = false
@effects[PBEffects::Uproar] = 0 @effects[PBEffects::Uproar] = 0
@@ -95,7 +95,7 @@ class PokeBattle_Battler
def pbReducePP(move) def pbReducePP(move)
return true if usingMultiTurnAttack? return true if usingMultiTurnAttack?
return true if move.pp<0 # Don't reduce PP for special calls of moves return true if move.pp<0 # Don't reduce PP for special calls of moves
return true if move.totalpp<=0 # Infinite PP, can always be used return true if move.total_pp<=0 # Infinite PP, can always be used
return false if move.pp==0 # Ran out of PP, couldn't reduce return false if move.pp==0 # Ran out of PP, couldn't reduce
pbSetPP(move,move.pp-1) if move.pp>0 pbSetPP(move,move.pp-1) if move.pp>0
return true return true
@@ -285,10 +285,10 @@ class PokeBattle_Battler
target.moves.each_with_index do |m,i| target.moves.each_with_index do |m,i|
@moves[i] = PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(m.id)) @moves[i] = PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(m.id))
@moves[i].pp = 5 @moves[i].pp = 5
@moves[i].totalpp = 5 @moves[i].total_pp = 5
end end
@effects[PBEffects::Disable] = 0 @effects[PBEffects::Disable] = 0
@effects[PBEffects::DisableMove] = 0 @effects[PBEffects::DisableMove] = nil
@effects[PBEffects::WeightChange] = target.effects[PBEffects::WeightChange] @effects[PBEffects::WeightChange] = target.effects[PBEffects::WeightChange]
@battle.scene.pbRefreshOne(@index) @battle.scene.pbRefreshOne(@index)
@battle.pbDisplay(_INTL("{1} transformed into {2}!",pbThis,target.pbThis(true))) @battle.pbDisplay(_INTL("{1} transformed into {2}!",pbThis,target.pbThis(true)))
@@ -261,7 +261,7 @@ class PokeBattle_Battler
# disabled/anything else). This behaviour was tested in Gen 5. # disabled/anything else). This behaviour was tested in Gen 5.
if @status==PBStatuses::SLEEP && @effects[PBEffects::Outrage]>0 if @status==PBStatuses::SLEEP && @effects[PBEffects::Outrage]>0
@effects[PBEffects::Outrage] = 0 @effects[PBEffects::Outrage] = 0
@currentMove = 0 @currentMove = nil
end end
end end
@@ -136,7 +136,7 @@ class PokeBattle_Battler
# permanent is whether the item is lost even after battle. Is false for Knock # permanent is whether the item is lost even after battle. Is false for Knock
# Off. # Off.
def pbRemoveItem(permanent = true) def pbRemoveItem(permanent = true)
@effects[PBEffects::ChoiceBand] = -1 @effects[PBEffects::ChoiceBand] = nil
@effects[PBEffects::Unburden] = true if self.item @effects[PBEffects::Unburden] = true if self.item
setInitialItem(nil) if permanent && self.item == self.initialItem setInitialItem(nil) if permanent && self.item == self.initialItem
self.item = nil self.item = nil
@@ -80,7 +80,7 @@ class PokeBattle_Battler
# Encore's effect ends if the encored move is no longer available # Encore's effect ends if the encored move is no longer available
if @effects[PBEffects::Encore]>0 && pbEncoredMoveIndex<0 if @effects[PBEffects::Encore]>0 && pbEncoredMoveIndex<0
@effects[PBEffects::Encore] = 0 @effects[PBEffects::Encore] = 0
@effects[PBEffects::EncoreMove] = 0 @effects[PBEffects::EncoreMove] = nil
end end
end end
@@ -96,23 +96,23 @@ class PokeBattle_Battler
pbConfuse(_INTL("{1} became confused due to fatigue!",pbThis)) pbConfuse(_INTL("{1} became confused due to fatigue!",pbThis))
end end
# Cancel usage of most multi-turn moves # Cancel usage of most multi-turn moves
@effects[PBEffects::TwoTurnAttack] = 0 @effects[PBEffects::TwoTurnAttack] = nil
@effects[PBEffects::Rollout] = 0 @effects[PBEffects::Rollout] = 0
@effects[PBEffects::Outrage] = 0 @effects[PBEffects::Outrage] = 0
@effects[PBEffects::Uproar] = 0 @effects[PBEffects::Uproar] = 0
@effects[PBEffects::Bide] = 0 @effects[PBEffects::Bide] = 0
@currentMove = 0 @currentMove = nil
# Reset counters for moves which increase them when used in succession # Reset counters for moves which increase them when used in succession
@effects[PBEffects::FuryCutter] = 0 @effects[PBEffects::FuryCutter] = 0
end end
def pbEndTurn(_choice) def pbEndTurn(_choice)
@lastRoundMoved = @battle.turnCount # Done something this round @lastRoundMoved = @battle.turnCount # Done something this round
if @effects[PBEffects::ChoiceBand]<0 && if !@effects[PBEffects::ChoiceBand] &&
hasActiveItem?([:CHOICEBAND,:CHOICESPECS,:CHOICESCARF]) hasActiveItem?([:CHOICEBAND,:CHOICESPECS,:CHOICESCARF])
if @lastMoveUsed>=0 && pbHasMove?(@lastMoveUsed) if @lastMoveUsed && pbHasMove?(@lastMoveUsed)
@effects[PBEffects::ChoiceBand] = @lastMoveUsed @effects[PBEffects::ChoiceBand] = @lastMoveUsed
elsif @lastRegularMoveUsed>=0 && pbHasMove?(@lastRegularMoveUsed) elsif @lastRegularMoveUsed && pbHasMove?(@lastRegularMoveUsed)
@effects[PBEffects::ChoiceBand] = @lastRegularMoveUsed @effects[PBEffects::ChoiceBand] = @lastRegularMoveUsed
end end
end end
@@ -184,14 +184,14 @@ class PokeBattle_Battler
end end
# Labels the move being used as "move" # Labels the move being used as "move"
move = choice[2] move = choice[2]
return if !move || move.id==0 # if move was not chosen somehow return if !move # if move was not chosen somehow
# Try to use the move (inc. disobedience) # Try to use the move (inc. disobedience)
@lastMoveFailed = false @lastMoveFailed = false
if !pbTryUseMove(choice,move,specialUsage,skipAccuracyCheck) if !pbTryUseMove(choice,move,specialUsage,skipAccuracyCheck)
@lastMoveUsed = -1 @lastMoveUsed = nil
@lastMoveUsedType = -1 @lastMoveUsedType = -1
if !specialUsage if !specialUsage
@lastRegularMoveUsed = -1 @lastRegularMoveUsed = nil
@lastRegularMoveTarget = -1 @lastRegularMoveTarget = -1
end end
@battle.pbGainExp # In case self is KO'd due to confusion @battle.pbGainExp # In case self is KO'd due to confusion
@@ -200,15 +200,15 @@ class PokeBattle_Battler
return return
end end
move = choice[2] # In case disobedience changed the move to be used move = choice[2] # In case disobedience changed the move to be used
return if !move || move.id==0 # if move was not chosen somehow return if !move # if move was not chosen somehow
# Subtract PP # Subtract PP
if !specialUsage if !specialUsage
if !pbReducePP(move) if !pbReducePP(move)
@battle.pbDisplay(_INTL("{1} used {2}!",pbThis,move.name)) @battle.pbDisplay(_INTL("{1} used {2}!",pbThis,move.name))
@battle.pbDisplay(_INTL("But there was no PP left for the move!")) @battle.pbDisplay(_INTL("But there was no PP left for the move!"))
@lastMoveUsed = -1 @lastMoveUsed = nil
@lastMoveUsedType = -1 @lastMoveUsedType = -1
@lastRegularMoveUsed = -1 @lastRegularMoveUsed = nil
@lastRegularMoveTarget = -1 @lastRegularMoveTarget = -1
@lastMoveFailed = true @lastMoveFailed = true
pbCancelMoves pbCancelMoves
@@ -220,7 +220,7 @@ class PokeBattle_Battler
if isSpecies?(:AEGISLASH) && self.ability == :STANCECHANGE if isSpecies?(:AEGISLASH) && self.ability == :STANCECHANGE
if move.damagingMove? if move.damagingMove?
pbChangeForm(1,_INTL("{1} changed to Blade Forme!",pbThis)) pbChangeForm(1,_INTL("{1} changed to Blade Forme!",pbThis))
elsif isConst?(move.id,PBMoves,:KINGSSHIELD) elsif move.id == :KINGSSHIELD
pbChangeForm(0,_INTL("{1} changed to Shield Forme!",pbThis)) pbChangeForm(0,_INTL("{1} changed to Shield Forme!",pbThis))
end end
end end
@@ -234,13 +234,13 @@ class PokeBattle_Battler
@effects[PBEffects::TwoTurnAttack] = move.id @effects[PBEffects::TwoTurnAttack] = move.id
@currentMove = move.id @currentMove = move.id
else else
@effects[PBEffects::TwoTurnAttack] = 0 # Cancel use of two-turn attack @effects[PBEffects::TwoTurnAttack] = nil # Cancel use of two-turn attack
end end
# Add to counters for moves which increase them when used in succession # Add to counters for moves which increase them when used in succession
move.pbChangeUsageCounters(self,specialUsage) move.pbChangeUsageCounters(self,specialUsage)
# Charge up Metronome item # Charge up Metronome item
if hasActiveItem?(:METRONOME) && !move.callsAnotherMove? if hasActiveItem?(:METRONOME) && !move.callsAnotherMove?
if @lastMoveUsed==move.id && !@lastMoveFailed if @lastMoveUsed && @lastMoveUsed==move.id && !@lastMoveFailed
@effects[PBEffects::Metronome] += 1 @effects[PBEffects::Metronome] += 1
else else
@effects[PBEffects::Metronome] = 0 @effects[PBEffects::Metronome] = 0
@@ -516,7 +516,7 @@ class PokeBattle_Battler
pbEndTurn(choice) pbEndTurn(choice)
# Instruct # Instruct
@battle.eachBattler do |b| @battle.eachBattler do |b|
next if !b.effects[PBEffects::Instruct] next if !b.effects[PBEffects::Instruct] || !b.lastMoveUsed
b.effects[PBEffects::Instruct] = false b.effects[PBEffects::Instruct] = false
idxMove = -1 idxMove = -1
b.eachMoveWithIndex { |m,i| idxMove = i if m.id==b.lastMoveUsed } b.eachMoveWithIndex { |m,i| idxMove = i if m.id==b.lastMoveUsed }
@@ -41,19 +41,19 @@ class PokeBattle_Battler
return false return false
end end
# Choice Band # Choice Band
if @effects[PBEffects::ChoiceBand]>=0 if @effects[PBEffects::ChoiceBand]
if hasActiveItem?([:CHOICEBAND,:CHOICESPECS,:CHOICESCARF]) && if hasActiveItem?([:CHOICEBAND,:CHOICESPECS,:CHOICESCARF]) &&
pbHasMove?(@effects[PBEffects::ChoiceBand]) pbHasMove?(@effects[PBEffects::ChoiceBand])
if move.id!=@effects[PBEffects::ChoiceBand] if move.id!=@effects[PBEffects::ChoiceBand]
if showMessages if showMessages
msg = _INTL("{1} allows the use of only {2}!",itemName, msg = _INTL("{1} allows the use of only {2}!",itemName,
PBMoves.getName(@effects[PBEffects::ChoiceBand])) GameData::Move.get(@effects[PBEffects::ChoiceBand]).name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg) (commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end end
return false return false
end end
else else
@effects[PBEffects::ChoiceBand] = -1 @effects[PBEffects::ChoiceBand] = nil
end end
end end
# Taunt # Taunt
@@ -66,7 +66,7 @@ class PokeBattle_Battler
end end
# Torment # Torment
if @effects[PBEffects::Torment] && !@effects[PBEffects::Instructed] && if @effects[PBEffects::Torment] && !@effects[PBEffects::Instructed] &&
move.id==@lastMoveUsed && move.id!=@battle.struggle.id @lastMoveUsed && move.id==@lastMoveUsed && move.id!=@battle.struggle.id
if showMessages if showMessages
msg = _INTL("{1} can't use the same move twice in a row due to the torment!",pbThis) msg = _INTL("{1} can't use the same move twice in a row due to the torment!",pbThis)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg) (commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
@@ -138,7 +138,7 @@ class PokeBattle_Battler
otherMoves = [] otherMoves = []
eachMoveWithIndex do |_m,i| eachMoveWithIndex do |_m,i|
next if i==choice[1] next if i==choice[1]
otherMoves[otherMoves.length] = i if @battle.pbCanChooseMove?(@index,i,false) otherMoves.push(i) if @battle.pbCanChooseMove?(@index,i,false)
end end
return false if otherMoves.length==0 # No other move to use; do nothing return false if otherMoves.length==0 # No other move to use; do nothing
newChoice = otherMoves[@battle.pbRandom(otherMoves.length)] newChoice = otherMoves[@battle.pbRandom(otherMoves.length)]
@@ -291,7 +291,7 @@ class PokeBattle_Battler
typeMod = move.pbCalcTypeMod(move.calcType,user,target) typeMod = move.pbCalcTypeMod(move.calcType,user,target)
target.damageState.typeMod = typeMod target.damageState.typeMod = typeMod
# Two-turn attacks can't fail here in the charging turn # Two-turn attacks can't fail here in the charging turn
return true if user.effects[PBEffects::TwoTurnAttack]>0 return true if user.effects[PBEffects::TwoTurnAttack]
# Move-specific failures # Move-specific failures
return false if move.pbFailsAgainstTarget?(user,target) return false if move.pbFailsAgainstTarget?(user,target)
# Immunity to priority moves because of Psychic Terrain # Immunity to priority moves because of Psychic Terrain
@@ -479,7 +479,7 @@ class PokeBattle_Battler
#============================================================================= #=============================================================================
def pbSuccessCheckPerHit(move,user,target,skipAccuracyCheck) def pbSuccessCheckPerHit(move,user,target,skipAccuracyCheck)
# Two-turn attacks can't fail here in the charging turn # Two-turn attacks can't fail here in the charging turn
return true if user.effects[PBEffects::TwoTurnAttack]>0 return true if user.effects[PBEffects::TwoTurnAttack]
# Lock-On # Lock-On
return true if user.effects[PBEffects::LockOn]>0 && return true if user.effects[PBEffects::LockOn]>0 &&
user.effects[PBEffects::LockOnPos]==target.index user.effects[PBEffects::LockOnPos]==target.index
@@ -495,7 +495,7 @@ class PokeBattle_Battler
hitsInvul = true if move.function=="09C" hitsInvul = true if move.function=="09C"
if !hitsInvul if !hitsInvul
# Semi-invulnerable moves # Semi-invulnerable moves
if target.effects[PBEffects::TwoTurnAttack]>0 if target.effects[PBEffects::TwoTurnAttack]
if target.inTwoTurnAttack?("0C9","0CC","0CE") # Fly, Bounce, Sky Drop if target.inTwoTurnAttack?("0C9","0CC","0CE") # Fly, Bounce, Sky Drop
miss = true if !move.hitsFlyingTargets? miss = true if !move.hitsFlyingTargets?
elsif target.inTwoTurnAttack?("0CA") # Dig elsif target.inTwoTurnAttack?("0CA") # Dig
@@ -529,7 +529,7 @@ class PokeBattle_Battler
tar = move.pbTarget(user) tar = move.pbTarget(user)
if PBTargets.multipleTargets?(tar) if PBTargets.multipleTargets?(tar)
@battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis)) @battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis))
elsif target.effects[PBEffects::TwoTurnAttack]>0 elsif target.effects[PBEffects::TwoTurnAttack]
@battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis)) @battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis))
elsif !move.pbMissMessage(user,target) elsif !move.pbMissMessage(user,target)
@battle.pbDisplay(_INTL("{1}'s attack missed!",user.pbThis)) @battle.pbDisplay(_INTL("{1}'s attack missed!",user.pbThis))
@@ -9,7 +9,7 @@ class PokeBattle_Move
attr_reader :category attr_reader :category
attr_reader :accuracy attr_reader :accuracy
attr_accessor :pp attr_accessor :pp
attr_writer :totalpp attr_writer :total_pp
attr_reader :addlEffect attr_reader :addlEffect
attr_reader :target attr_reader :target
attr_reader :priority attr_reader :priority
@@ -23,23 +23,22 @@ class PokeBattle_Move
#============================================================================= #=============================================================================
# Creating a move # Creating a move
#============================================================================= #=============================================================================
def initialize(battle,move) def initialize(battle, move)
@battle = battle @battle = battle
@realMove = move @realMove = move
@id = move.id @id = move.id
@name = PBMoves.getName(@id) # Get the move's name @name = move.name # Get the move's name
# Get data on the move # Get data on the move
moveData = pbGetMoveData(@id) @function = move.function_code
@function = moveData[MoveData::FUNCTION_CODE] @baseDamage = move.base_damage
@baseDamage = moveData[MoveData::BASE_DAMAGE] @type = move.type
@type = moveData[MoveData::TYPE] @category = move.category
@category = moveData[MoveData::CATEGORY] @accuracy = move.accuracy
@accuracy = moveData[MoveData::ACCURACY]
@pp = move.pp # Can be changed with Mimic/Transform @pp = move.pp # Can be changed with Mimic/Transform
@addlEffect = moveData[MoveData::EFFECT_CHANCE] @addlEffect = move.effect_chance
@target = moveData[MoveData::TARGET] @target = move.target
@priority = moveData[MoveData::PRIORITY] @priority = move.priority
@flags = moveData[MoveData::FLAGS] @flags = move.flags
@calcType = -1 @calcType = -1
@powerBoost = false # For Aerilate, Pixilate, Refrigerate, Galvanize @powerBoost = false # For Aerilate, Pixilate, Refrigerate, Galvanize
@snatched = false @snatched = false
@@ -48,14 +47,14 @@ class PokeBattle_Move
# This is the code actually used to generate a PokeBattle_Move object. The # This is the code actually used to generate a PokeBattle_Move object. The
# object generated is a subclass of this one which depends on the move's # object generated is a subclass of this one which depends on the move's
# function code (found in the script section PokeBattle_MoveEffect). # function code (found in the script section PokeBattle_MoveEffect).
def PokeBattle_Move.pbFromPBMove(battle,move) def PokeBattle_Move.pbFromPBMove(battle, move)
move = PBMove.new(0) if !move validate move => PBMove
moveFunction = pbGetMoveData(move.id,MoveData::FUNCTION_CODE) || "000" moveFunction = move.function_code || "000"
className = sprintf("PokeBattle_Move_%s",moveFunction) className = sprintf("PokeBattle_Move_%s", moveFunction)
if Object.const_defined?(className) if Object.const_defined?(className)
return Object.const_get(className).new(battle,move) return Object.const_get(className).new(battle, move)
end end
return PokeBattle_UnimplementedMove.new(battle,move) return PokeBattle_UnimplementedMove.new(battle, move)
end end
#============================================================================= #=============================================================================
@@ -63,9 +62,9 @@ class PokeBattle_Move
#============================================================================= #=============================================================================
def pbTarget(_user); return @target; end def pbTarget(_user); return @target; end
def totalpp def total_pp
return @totalpp if @totalpp && @totalpp>0 # Usually undefined return @total_pp if @total_pp && @total_pp>0 # Usually undefined
return @realMove.totalpp if @realMove return @realMove.total_pp if @realMove
return 0 return 0
end end
@@ -29,7 +29,7 @@ class PokeBattle_Move
# Is false if Power Herb or another effect lets a two turn move charge and # Is false if Power Herb or another effect lets a two turn move charge and
# attack in the same turn. # attack in the same turn.
# user.effects[PBEffects::TwoTurnAttack] is set to the move's ID during the # user.effects[PBEffects::TwoTurnAttack] is set to the move's ID during the
# charging turn, and is 0 during the attack turn. # charging turn, and is nil during the attack turn.
def pbIsChargingTurn?(user); return false; end def pbIsChargingTurn?(user); return false; end
def pbDamagingMove?; return damagingMove?; end def pbDamagingMove?; return damagingMove?; end
@@ -54,8 +54,8 @@ class PokeBattle_Struggle < PokeBattle_Move
def initialize(battle,move) def initialize(battle,move)
@battle = battle @battle = battle
@realMove = nil # Not associated with a move @realMove = nil # Not associated with a move
@id = (move) ? move.id : -1 # Doesn't work if 0 @id = (move) ? move.id : :STRUGGLE
@name = (move) ? PBMoves.getName(@id) : _INTL("Struggle") @name = (move) ? move.name : _INTL("Struggle")
@function = "002" @function = "002"
@baseDamage = 50 @baseDamage = 50
@type = -1 @type = -1
@@ -410,14 +410,14 @@ class PokeBattle_TwoTurnMove < PokeBattle_Move
def chargingTurnMove?; return true; end def chargingTurnMove?; return true; end
# user.effects[PBEffects::TwoTurnAttack] is set to the move's ID if this # user.effects[PBEffects::TwoTurnAttack] is set to the move's ID if this
# method returns true, or 0 if false. # method returns true, or nil if false.
# Non-zero means the charging turn. 0 means the attacking turn. # Non-nil means the charging turn. nil means the attacking turn.
def pbIsChargingTurn?(user) def pbIsChargingTurn?(user)
@powerHerb = false @powerHerb = false
@chargingTurn = false # Assume damaging turn by default @chargingTurn = false # Assume damaging turn by default
@damagingTurn = true @damagingTurn = true
# 0 at start of charging turn, move's ID at start of damaging turn # 0 at start of charging turn, move's ID at start of damaging turn
if user.effects[PBEffects::TwoTurnAttack]==0 if !user.effects[PBEffects::TwoTurnAttack]
@powerHerb = user.hasActiveItem?(:POWERHERB) @powerHerb = user.hasActiveItem?(:POWERHERB)
@chargingTurn = true @chargingTurn = true
@damagingTurn = @powerHerb @damagingTurn = @powerHerb
@@ -643,7 +643,7 @@ class PokeBattle_PledgeMove < PokeBattle_Move
user.eachAlly do |b| user.eachAlly do |b|
next if @battle.choices[b.index][0]!=:UseMove || b.movedThisRound? next if @battle.choices[b.index][0]!=:UseMove || b.movedThisRound?
move = @battle.choices[b.index][2] move = @battle.choices[b.index][2]
next if !move || move.id<=0 next if !move
@combos.each do |i| @combos.each do |i|
next if i[0]!=move.function next if i[0]!=move.function
@pledgeSetup = true @pledgeSetup = true
@@ -708,7 +708,7 @@ class PokeBattle_PledgeMove < PokeBattle_Move
def pbShowAnimation(id,user,targets,hitNum=0,showAnimation=true) def pbShowAnimation(id,user,targets,hitNum=0,showAnimation=true)
return if @pledgeSetup # No animation for setting up return if @pledgeSetup # No animation for setting up
id = @overrideAnim if @overrideAnim!=nil id = @overrideAnim if @overrideAnim
return super return super
end end
end end
@@ -32,7 +32,7 @@ end
#=============================================================================== #===============================================================================
class PokeBattle_Move_003 < PokeBattle_SleepMove class PokeBattle_Move_003 < PokeBattle_SleepMove
def pbMoveFailed?(user,targets) def pbMoveFailed?(user,targets)
if NEWEST_BATTLE_MECHANICS && isConst?(@id,PBMoves,:DARKVOID) if NEWEST_BATTLE_MECHANICS && @id == :DARKVOID
if !user.isSpecies?(:DARKRAI) && if !user.isSpecies?(:DARKRAI) &&
!isConst?(user.effects[PBEffects::TransformSpecies],PBSpecies,:DARKRAI) !isConst?(user.effects[PBEffects::TransformSpecies],PBSpecies,:DARKRAI)
@battle.pbDisplay(_INTL("But {1} can't use the move!",user.pbThis)) @battle.pbDisplay(_INTL("But {1} can't use the move!",user.pbThis))
@@ -45,7 +45,7 @@ class PokeBattle_Move_003 < PokeBattle_SleepMove
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers) def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers)
return if numHits==0 return if numHits==0
return if user.fainted? || user.effects[PBEffects::Transform] return if user.fainted? || user.effects[PBEffects::Transform]
return if !isConst?(@id,PBMoves,:RELICSONG) return if @id != :RELICSONG
return if !user.isSpecies?(:MELOETTA) return if !user.isSpecies?(:MELOETTA)
return if user.hasActiveAbility?(:SHEERFORCE) && @addlEffect>0 return if user.hasActiveAbility?(:SHEERFORCE) && @addlEffect>0
newForm = (oldForm+1)%2 newForm = (oldForm+1)%2
@@ -108,12 +108,12 @@ end
class PokeBattle_Move_007 < PokeBattle_ParalysisMove class PokeBattle_Move_007 < PokeBattle_ParalysisMove
def tramplesMinimize?(param=1) def tramplesMinimize?(param=1)
# Perfect accuracy and double damage (for Body Slam only) # Perfect accuracy and double damage (for Body Slam only)
return NEWEST_BATTLE_MECHANICS if isConst?(@id,PBMoves,:BODYSLAM) return NEWEST_BATTLE_MECHANICS if @id == :BODYSLAM
return super return super
end end
def pbFailsAgainstTarget?(user,target) def pbFailsAgainstTarget?(user,target)
if isConst?(@id,PBMoves,:THUNDERWAVE) && PBTypes.ineffective?(target.damageState.typeMod) if @id == :THUNDERWAVE && PBTypes.ineffective?(target.damageState.typeMod)
@battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true))) @battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true)))
return true return true
end end
@@ -242,7 +242,7 @@ end
#=============================================================================== #===============================================================================
class PokeBattle_Move_010 < PokeBattle_FlinchMove class PokeBattle_Move_010 < PokeBattle_FlinchMove
def tramplesMinimize?(param=1) def tramplesMinimize?(param=1)
return super if isConst?(@id,PBMoves,:DRAGONRUSH) && !NEWEST_BATTLE_MECHANICS return super if @id == :DRAGONRUSH && !NEWEST_BATTLE_MECHANICS
return true if param==1 && NEWEST_BATTLE_MECHANICS # Perfect accuracy return true if param==1 && NEWEST_BATTLE_MECHANICS # Perfect accuracy
return true if param==2 # Double damage return true if param==2 # Double damage
return super return super
@@ -492,9 +492,9 @@ class PokeBattle_Move_019 < PokeBattle_Move
def pbShowAnimation(id,user,targets,hitNum=0,showAnimation=true) def pbShowAnimation(id,user,targets,hitNum=0,showAnimation=true)
super super
if isConst?(@id,PBMoves,:AROMATHERAPY) if @id == :AROMATHERAPY
@battle.pbDisplay(_INTL("A soothing aroma wafted through the area!")) @battle.pbDisplay(_INTL("A soothing aroma wafted through the area!"))
elsif isConst?(@id,PBMoves,:HEALBELL) elsif @id == :HEALBELL
@battle.pbDisplay(_INTL("A bell chimed!")) @battle.pbDisplay(_INTL("A bell chimed!"))
end end
end end
@@ -1217,7 +1217,7 @@ class PokeBattle_Move_044 < PokeBattle_TargetStatDownMove
end end
def pbBaseDamage(baseDmg,user,target) def pbBaseDamage(baseDmg,user,target)
if isConst?(@id,PBMoves,:BULLDOZE) && @battle.field.terrain==PBBattleTerrains::Grassy if @id == :BULLDOZE && @battle.field.terrain==PBBattleTerrains::Grassy
baseDmg = (baseDmg/2.0).round baseDmg = (baseDmg/2.0).round
end end
return baseDmg return baseDmg
@@ -1406,7 +1406,7 @@ class PokeBattle_Move_04D < PokeBattle_TargetStatDownMove
def initialize(battle,move) def initialize(battle,move)
super super
inc = 2 inc = 2
inc = 1 if isConst?(@id,PBMoves,:STRINGSHOT) && !NEWEST_BATTLE_MECHANICS inc = 1 if @id == :STRINGSHOT && !NEWEST_BATTLE_MECHANICS
@statDown = [PBStats::SPEED,inc] @statDown = [PBStats::SPEED,inc]
end end
end end
@@ -1705,11 +1705,11 @@ class PokeBattle_Move_05C < PokeBattle_Move
end end
def pbFailsAgainstTarget?(user,target) def pbFailsAgainstTarget?(user,target)
lastMoveData = pbGetMoveData(target.lastRegularMoveUsed) lastMoveData = GameData::Move.try_get(target.lastRegularMoveUsed)
if target.lastRegularMoveUsed<=0 || if !lastMoveData ||
user.pbHasMove?(target.lastRegularMoveUsed) || user.pbHasMove?(target.lastRegularMoveUsed) ||
@moveBlacklist.include?(lastMoveData[MoveData::FUNCTION_CODE]) || @moveBlacklist.include?(lastMoveData.function_code) ||
isConst?(lastMoveData[MoveData::TYPE],PBTypes,:SHADOW) isConst?(lastMoveData.type, PBTypes,:SHADOW)
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -1721,8 +1721,7 @@ class PokeBattle_Move_05C < PokeBattle_Move
next if m.id!=@id next if m.id!=@id
newMove = PBMove.new(target.lastRegularMoveUsed) newMove = PBMove.new(target.lastRegularMoveUsed)
user.moves[i] = PokeBattle_Move.pbFromPBMove(@battle,newMove) user.moves[i] = PokeBattle_Move.pbFromPBMove(@battle,newMove)
@battle.pbDisplay(_INTL("{1} learned {2}!",user.pbThis, @battle.pbDisplay(_INTL("{1} learned {2}!",user.pbThis,newMove.name))
PBMoves.getName(target.lastRegularMoveUsed)))
user.pbCheckFormOnMovesetChange user.pbCheckFormOnMovesetChange
break break
end end
@@ -1756,11 +1755,11 @@ class PokeBattle_Move_05D < PokeBattle_Move
end end
def pbFailsAgainstTarget?(user,target) def pbFailsAgainstTarget?(user,target)
lastMoveData = pbGetMoveData(target.lastRegularMoveUsed) lastMoveData = GameData::Move.try_get(target.lastRegularMoveUsed)
if target.lastRegularMoveUsed<=0 || if !lastMoveData ||
user.pbHasMove?(target.lastRegularMoveUsed) || user.pbHasMove?(target.lastRegularMoveUsed) ||
@moveBlacklist.include?(lastMoveData[MoveData::FUNCTION_CODE]) || @moveBlacklist.include?(lastMoveData.function_code) ||
isConst?(lastMoveData[MoveData::TYPE],PBTypes,:SHADOW) isConst?(lastMoveData.type, PBTypes,:SHADOW)
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -1773,8 +1772,7 @@ class PokeBattle_Move_05D < PokeBattle_Move
newMove = PBMove.new(target.lastRegularMoveUsed) newMove = PBMove.new(target.lastRegularMoveUsed)
user.pokemon.moves[i] = newMove user.pokemon.moves[i] = newMove
user.moves[i] = PokeBattle_Move.pbFromPBMove(@battle,newMove) user.moves[i] = PokeBattle_Move.pbFromPBMove(@battle,newMove)
@battle.pbDisplay(_INTL("{1} learned {2}!",user.pbThis, @battle.pbDisplay(_INTL("{1} learned {2}!",user.pbThis,newMove.name))
PBMoves.getName(target.lastRegularMoveUsed)))
user.pbCheckFormOnMovesetChange user.pbCheckFormOnMovesetChange
break break
end end
@@ -1835,9 +1833,8 @@ class PokeBattle_Move_05F < PokeBattle_Move
end end
def pbFailsAgainstTarget?(user,target) def pbFailsAgainstTarget?(user,target)
if target.lastMoveUsed<=0 || if !target.lastMoveUsed || target.lastMoveUsedType < 0 ||
target.lastMoveUsedType<0 || PBTypes.isPseudoType?(GameData::Move.get(target.lastMoveUsed).type)
PBTypes.isPseudoType?(pbGetMoveData(target.lastMoveUsed,MoveData::TYPE))
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -2347,7 +2344,7 @@ end
# OHKO. Accuracy increases by difference between levels of user and target. # OHKO. Accuracy increases by difference between levels of user and target.
#=============================================================================== #===============================================================================
class PokeBattle_Move_070 < PokeBattle_FixedDamageMove class PokeBattle_Move_070 < PokeBattle_FixedDamageMove
def hitsDiggingTargets?; return isConst?(@id,PBMoves,:FISSURE); end def hitsDiggingTargets?; return @id == :FISSURE; end
def pbFailsAgainstTarget?(user,target) def pbFailsAgainstTarget?(user,target)
if target.level>user.level if target.level>user.level
@@ -2375,8 +2372,7 @@ class PokeBattle_Move_070 < PokeBattle_FixedDamageMove
def pbAccuracyCheck(user,target) def pbAccuracyCheck(user,target)
acc = @accuracy+user.level-target.level acc = @accuracy+user.level-target.level
acc -= 10 if NEWEST_BATTLE_MECHANICS && isConst?(@id,PBMoves,:SHEERCOLD) && acc -= 10 if NEWEST_BATTLE_MECHANICS && @id == :SHEERCOLD && !user.pbHasType?(:ICE)
!user.pbHasType?(:ICE)
return @battle.pbRandom(100)<acc return @battle.pbRandom(100)<acc
end end
@@ -714,7 +714,7 @@ end
class PokeBattle_Move_09F < PokeBattle_Move class PokeBattle_Move_09F < PokeBattle_Move
def initialize(battle,move) def initialize(battle,move)
super super
if isConst?(@id,PBMoves,:JUDGMENT) if @id == :JUDGMENT
@itemTypes = { @itemTypes = {
:FISTPLATE => :FIGHTING, :FISTPLATE => :FIGHTING,
:SKYPLATE => :FLYING, :SKYPLATE => :FLYING,
@@ -734,14 +734,14 @@ class PokeBattle_Move_09F < PokeBattle_Move
:DREADPLATE => :DARK, :DREADPLATE => :DARK,
:PIXIEPLATE => :FAIRY :PIXIEPLATE => :FAIRY
} }
elsif isConst?(@id,PBMoves,:TECHNOBLAST) elsif @id == :TECHNOBLAST
@itemTypes = { @itemTypes = {
:SHOCKDRIVE => :ELECTRIC, :SHOCKDRIVE => :ELECTRIC,
:BURNDRIVE => :FIRE, :BURNDRIVE => :FIRE,
:CHILLDRIVE => :ICE, :CHILLDRIVE => :ICE,
:DOUSEDRIVE => :WATER :DOUSEDRIVE => :WATER
} }
elsif isConst?(@id,PBMoves,:MULTIATTACK) elsif @id == :MULTIATTACK
@itemTypes = { @itemTypes = {
:FIGHTINGMEMORY => :FIGHTING, :FIGHTINGMEMORY => :FIGHTING,
:FLYINGMEMORY => :FLYING, :FLYINGMEMORY => :FLYING,
@@ -778,7 +778,7 @@ class PokeBattle_Move_09F < PokeBattle_Move
end end
def pbShowAnimation(id,user,targets,hitNum=0,showAnimation=true) def pbShowAnimation(id,user,targets,hitNum=0,showAnimation=true)
if isConst?(@id,PBMoves,:TECHNOBLAST) # Type-specific anim if @id == :TECHNOBLAST # Type-specific anim
t = pbBaseType(user) t = pbBaseType(user)
hitNum = 0 hitNum = 0
hitNum = 1 if isConst?(t,PBTypes,:ELECTRIC) hitNum = 1 if isConst?(t,PBTypes,:ELECTRIC)
@@ -956,22 +956,22 @@ class PokeBattle_Move_0A4 < PokeBattle_Move
end end
def pbShowAnimation(id,user,targets,hitNum=0,showAnimation=true) def pbShowAnimation(id,user,targets,hitNum=0,showAnimation=true)
id = getConst(PBMoves,:BODYSLAM) # Environment-specific anim id = :BODYSLAM # Environment-specific anim
case @secretPower case @secretPower
when 1; id = getConst(PBMoves,:THUNDERSHOCK) || id when 1; id = :THUNDERSHOCK if GameData::Move.exists?(:THUNDERSHOCK)
when 2; id = getConst(PBMoves,:VINEWHIP) || id when 2; id = :VINEWHIP if GameData::Move.exists?(:VINEWHIP)
when 3; id = getConst(PBMoves,:FAIRYWIND) || id when 3; id = :FAIRYWIND if GameData::Move.exists?(:FAIRYWIND)
when 4; id = getConst(PBMoves,:CONFUSION) || id when 4; id = :CONFUSIO if GameData::Move.exists?(:CONFUSION)
when 5; id = getConst(PBMoves,:WATERPULSE) || id when 5; id = :WATERPULSE if GameData::Move.exists?(:WATERPULSE)
when 6; id = getConst(PBMoves,:MUDSHOT) || id when 6; id = :MUDSHOT if GameData::Move.exists?(:MUDSHOT)
when 7; id = getConst(PBMoves,:ROCKTHROW) || id when 7; id = :ROCKTHROW if GameData::Move.exists?(:ROCKTHROW)
when 8; id = getConst(PBMoves,:MUDSLAP) || id when 8; id = :MUDSLAP if GameData::Move.exists?(:MUDSLAP)
when 9; id = getConst(PBMoves,:ICESHARD) || id when 9; id = :ICESHARD if GameData::Move.exists?(:ICESHARD)
when 10; id = getConst(PBMoves,:INCINERATE) || id when 10; id = :INCINERATE if GameData::Move.exists?(:INCINERATE)
when 11; id = getConst(PBMoves,:SHADOWSNEAK) || id when 11; id = :SHADOWSNEAK if GameData::Move.exists?(:SHADOWSNEAK)
when 12; id = getConst(PBMoves,:GUST) || id when 12; id = :GUST if GameData::Move.exists?(:GUST)
when 13; id = getConst(PBMoves,:SWIFT) || id when 13; id = :SWIFT if GameData::Move.exists?(:SWIFT)
when 14; id = getConst(PBMoves,:PSYWAVE) || id when 14; id = :PSYWAVE if GameData::Move.exists?(:PSYWAVE)
end end
super super
end end
@@ -1116,8 +1116,8 @@ class PokeBattle_Move_0AE < PokeBattle_Move
def callsAnotherMove?; return true; end def callsAnotherMove?; return true; end
def pbFailsAgainstTarget?(user,target) def pbFailsAgainstTarget?(user,target)
if target.lastRegularMoveUsed<=0 || if !target.lastRegularMoveUsed ||
!pbGetMoveData(target.lastRegularMoveUsed,MoveData::FLAGS)[/e/] # Not copyable by Mirror Move !GameData::Move.get(target.lastRegularMoveUsed).flags[/e/] # Not copyable by Mirror Move
@battle.pbDisplay(_INTL("The mirror move failed!")) @battle.pbDisplay(_INTL("The mirror move failed!"))
return true return true
end end
@@ -1207,8 +1207,8 @@ class PokeBattle_Move_0AF < PokeBattle_Move
end end
def pbMoveFailed?(user,targets) def pbMoveFailed?(user,targets)
if @battle.lastMoveUsed<=0 || if !@battle.lastMoveUsed ||
@moveBlacklist.include?(pbGetMoveData(@battle.lastMoveUsed,MoveData::FUNCTION_CODE)) @moveBlacklist.include?(GameData::Move.get(@battle.lastMoveUsed).function_code)
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -1252,8 +1252,7 @@ class PokeBattle_Move_0B0 < PokeBattle_Move
def pbFailsAgainstTarget?(user,target) def pbFailsAgainstTarget?(user,target)
return true if pbMoveFailedTargetAlreadyMoved?(target) return true if pbMoveFailedTargetAlreadyMoved?(target)
oppMove = @battle.choices[target.index][2] oppMove = @battle.choices[target.index][2]
if !oppMove || oppMove.id<=0 || if !oppMove || oppMove.statusMove? || @moveBlacklist.include?(oppMove.function)
oppMove.statusMove? || @moveBlacklist.include?(oppMove.function)
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -1311,71 +1310,71 @@ class PokeBattle_Move_0B3 < PokeBattle_Move
# NOTE: It's possible in theory to not have the move Nature Power wants to # NOTE: It's possible in theory to not have the move Nature Power wants to
# turn into, but what self-respecting game wouldn't at least have Tri # turn into, but what self-respecting game wouldn't at least have Tri
# Attack in it? # Attack in it?
@npMove = getID(PBMoves,:TRIATTACK) @npMove = :TRIATTACK
case @battle.field.terrain case @battle.field.terrain
when PBBattleTerrains::Electric when PBBattleTerrains::Electric
@npMove = getConst(PBMoves,:THUNDERBOLT) || @npMove @npMove = :THUNDERBOLT if GameData::Move.exists?(:THUNDERBOLT)
when PBBattleTerrains::Grassy when PBBattleTerrains::Grassy
@npMove = getConst(PBMoves,:ENERGYBALL) || @npMove @npMove = :ENERGYBALL if GameData::Move.exists?(:ENERGYBALL)
when PBBattleTerrains::Misty when PBBattleTerrains::Misty
@npMove = getConst(PBMoves,:MOONBLAST) || @npMove @npMove = :MOONBLAST if GameData::Move.exists?(:MOONBLAST)
when PBBattleTerrains::Psychic when PBBattleTerrains::Psychic
@npMove = getConst(PBMoves,:PSYCHIC) || @npMove @npMove = :PSYCHIC if GameData::Move.exists?(:PSYCHIC)
else else
case @battle.environment case @battle.environment
when PBEnvironment::Grass, PBEnvironment::TallGrass, when PBEnvironment::Grass, PBEnvironment::TallGrass,
PBEnvironment::Forest, PBEnvironment::ForestGrass PBEnvironment::Forest, PBEnvironment::ForestGrass
if NEWEST_BATTLE_MECHANICS if NEWEST_BATTLE_MECHANICS
@npMove = getConst(PBMoves,:ENERGYBALL) || @npMove @npMove = :ENERGYBALL if GameData::Move.exists?(:ENERGYBALL)
else else
@npMove = getConst(PBMoves,:SEEDBOMB) || @npMove @npMove = :SEEDBOMB if GameData::Move.exists?(:SEEDBOMB)
end end
when PBEnvironment::MovingWater, PBEnvironment::StillWater, PBEnvironment::Underwater when PBEnvironment::MovingWater, PBEnvironment::StillWater, PBEnvironment::Underwater
@npMove = getConst(PBMoves,:HYDROPUMP) || @npMove @npMove = :HYDROPUMP if GameData::Move.exists?(:HYDROPUMP)
when PBEnvironment::Puddle when PBEnvironment::Puddle
@npMove = getConst(PBMoves,:MUDBOMB) || @npMove @npMove = :MUDBOMB if GameData::Move.exists?(:MUDBOMB)
when PBEnvironment::Cave when PBEnvironment::Cave
if NEWEST_BATTLE_MECHANICS if NEWEST_BATTLE_MECHANICS
@npMove = getConst(PBMoves,:POWERGEM) || @npMove @npMove = :POWERGEM if GameData::Move.exists?(:POWERGEM)
else else
@npMove = getConst(PBMoves,:ROCKSLIDE) || @npMove @npMove = :ROCKSLIDE if GameData::Move.exists?(:ROCKSLIDE)
end end
when PBEnvironment::Rock when PBEnvironment::Rock
if NEWEST_BATTLE_MECHANICS if NEWEST_BATTLE_MECHANICS
@npMove = getConst(PBMoves,:EARTHPOWER) || @npMove @npMove = :EARTHPOWER if GameData::Move.exists?(:EARTHPOWER)
else else
@npMove = getConst(PBMoves,:ROCKSLIDE) || @npMove @npMove = :ROCKSLIDE if GameData::Move.exists?(:ROCKSLIDE)
end end
when PBEnvironment::Sand when PBEnvironment::Sand
if NEWEST_BATTLE_MECHANICS if NEWEST_BATTLE_MECHANICS
@npMove = getConst(PBMoves,:EARTHPOWER) || @npMove @npMove = :EARTHPOWER if GameData::Move.exists?(:EARTHPOWER)
else else
@npMove = getConst(PBMoves,:EARTHQUAKE) || @npMove @npMove = :EARTHQUAKE if GameData::Move.exists?(:EARTHQUAKE)
end end
# Ice tiles in Gen 6 should be Ice Beam # Ice tiles in Gen 6 should be Ice Beam
when PBEnvironment::Snow, PBEnvironment::Ice when PBEnvironment::Snow, PBEnvironment::Ice
if NEWEST_BATTLE_MECHANICS if NEWEST_BATTLE_MECHANICS
@npMove = getConst(PBMoves,:FROSTBREATH) || @npMove @npMove = :FROSTBREATH if GameData::Move.exists?(:FROSTBREATH)
else else
@npMove = getConst(PBMoves,:ICEBEAM) || @npMove @npMove = :ICEBEAM if GameData::Move.exists?(:ICEBEAM)
end end
when PBEnvironment::Volcano when PBEnvironment::Volcano
@npMove = getConst(PBMoves,:LAVAPLUME) || @npMove @npMove = :LAVAPLUME if GameData::Move.exists?(:LAVAPLUME)
when PBEnvironment::Graveyard when PBEnvironment::Graveyard
@npMove = getConst(PBMoves,:SHADOWBALL) || @npMove @npMove = :SHADOWBALL if GameData::Move.exists?(:SHADOWBALL)
when PBEnvironment::Sky when PBEnvironment::Sky
@npMove = getConst(PBMoves,:AIRSLASH) || @npMove @npMove = :AIRSLASH if GameData::Move.exists?(:AIRSLASH)
when PBEnvironment::Space when PBEnvironment::Space
@npMove = getConst(PBMoves,:DRACOMETEOR) || @npMove @npMove = :DRACOMETEOR if GameData::Move.exists?(:DRACOMETEOR)
when PBEnvironment::UltraSpace when PBEnvironment::UltraSpace
@npMove = getConst(PBMoves,:PSYSHOCK) || @npMove @npMove = :PSYSHOCK if GameData::Move.exists?(:PSYSHOCK)
end end
end end
end end
def pbEffectAgainstTarget(user,target) def pbEffectAgainstTarget(user,target)
@battle.pbDisplay(_INTL("{1} turned into {2}!",@name,PBMoves.getName(@npMove))) @battle.pbDisplay(_INTL("{1} turned into {2}!", @name, GameData::Move.get(@npMove).name))
user.pbUseMoveSimple(@npMove,target.index) user.pbUseMoveSimple(@npMove, target.index)
end end
end end
@@ -1551,8 +1550,7 @@ class PokeBattle_Move_0B5 < PokeBattle_Move
next if !pkmn || i==user.pokemonIndex next if !pkmn || i==user.pokemonIndex
next if NEWEST_BATTLE_MECHANICS && pkmn.egg? next if NEWEST_BATTLE_MECHANICS && pkmn.egg?
pkmn.moves.each do |move| pkmn.moves.each do |move|
next if !move || move.id<=0 next if @moveBlacklist.include?(move.function_code)
next if @moveBlacklist.include?(pbGetMoveData(move.id,MoveData::FUNCTION_CODE))
next if isConst?(move.type,PBTypes,:SHADOW) next if isConst?(move.type,PBTypes,:SHADOW)
@assistMoves.push(move.id) @assistMoves.push(move.id)
end end
@@ -1663,25 +1661,20 @@ class PokeBattle_Move_0B6 < PokeBattle_Move
end end
def pbMoveFailed?(user,targets) def pbMoveFailed?(user,targets)
movesData = pbLoadMovesData @metronomeMove = nil
@metronomeMove = 0 move_keys = GameData::Move::DATA.keys.sort
# NOTE: You could be really unlucky and roll blacklisted moves 1000 times in # NOTE: You could be really unlucky and roll blacklisted moves 1000 times in
# a row. This is too unlikely to care about, though. # a row. This is too unlikely to care about, though.
1000.times do 1000.times do
move = @battle.pbRandom(PBMoves.maxValue)+1 # Random move move_id = move_keys[@battle.pbRandom(move_keys.length)]
next if !movesData[move] move_data = GameData::Move.get(move_id)
next if @moveBlacklist.include?(movesData[move][MoveData::FUNCTION_CODE]) next if @moveBlacklist.include?(move_data.function_code)
blMove = false next if @moveBlacklistSignatures.include?(move_data.id)
@moveBlacklistSignatures.each do |m| next if isConst?(move_data.type, PBTypes, :SHADOW)
next if !isConst?(move,PBMoves,m) @metronomeMove = move_data.id
blMove = true; break
end
next if blMove
next if isConst?(movesData[move][MoveData::TYPE],PBTypes,:SHADOW)
@metronomeMove = move
break break
end end
if @metronomeMove<=0 if !@metronomeMove
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -1746,7 +1739,7 @@ class PokeBattle_Move_0B9 < PokeBattle_Move
def ignoresSubstitute?(user); return true; end def ignoresSubstitute?(user); return true; end
def pbFailsAgainstTarget?(user,target) def pbFailsAgainstTarget?(user,target)
if target.effects[PBEffects::Disable]>0 if target.effects[PBEffects::Disable]>0 || !target.lastRegularMoveUsed
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -1754,7 +1747,7 @@ class PokeBattle_Move_0B9 < PokeBattle_Move
canDisable = false canDisable = false
target.eachMove do |m| target.eachMove do |m|
next if m.id!=target.lastRegularMoveUsed next if m.id!=target.lastRegularMoveUsed
next if m.pp==0 && m.totalpp>0 next if m.pp==0 && m.total_pp>0
canDisable = true canDisable = true
break break
end end
@@ -1769,7 +1762,7 @@ class PokeBattle_Move_0B9 < PokeBattle_Move
target.effects[PBEffects::Disable] = 5 target.effects[PBEffects::Disable] = 5
target.effects[PBEffects::DisableMove] = target.lastRegularMoveUsed target.effects[PBEffects::DisableMove] = target.lastRegularMoveUsed
@battle.pbDisplay(_INTL("{1}'s {2} was disabled!",target.pbThis, @battle.pbDisplay(_INTL("{1}'s {2} was disabled!",target.pbThis,
PBMoves.getName(target.lastRegularMoveUsed))) GameData::Move.get(target.lastRegularMoveUsed).name))
target.pbItemStatusCureCheck target.pbItemStatusCureCheck
end end
end end
@@ -1872,8 +1865,8 @@ class PokeBattle_Move_0BC < PokeBattle_Move
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
if target.lastRegularMoveUsed<=0 || if !target.lastRegularMoveUsed ||
@moveBlacklist.include?(pbGetMoveData(target.lastRegularMoveUsed,MoveData::FUNCTION_CODE)) @moveBlacklist.include?(GameData::Move.get(target.lastRegularMoveUsed).function_code)
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -1885,7 +1878,7 @@ class PokeBattle_Move_0BC < PokeBattle_Move
canEncore = false canEncore = false
target.eachMove do |m| target.eachMove do |m|
next if m.id!=target.lastRegularMoveUsed next if m.id!=target.lastRegularMoveUsed
next if m.pp==0 && m.totalpp>0 next if m.pp==0 && m.total_pp>0
canEncore = true canEncore = true
break break
end end
@@ -1958,8 +1951,7 @@ class PokeBattle_Move_0C0 < PokeBattle_Move
def multiHitMove?; return true; end def multiHitMove?; return true; end
def pbNumHits(user,targets) def pbNumHits(user,targets)
if isConst?(@id,PBMoves,:WATERSHURIKEN) && if @id == :WATERSHURIKEN && user.isSpecies?(:GRENINJA) && user.form == 2
user.isSpecies?(:GRENINJA) && user.form==2
return 3 return 3
end end
hitChances = [2,2,3,3,4,5] hitChances = [2,2,3,3,4,5]
@@ -1969,8 +1961,7 @@ class PokeBattle_Move_0C0 < PokeBattle_Move
end end
def pbBaseDamage(baseDmg,user,target) def pbBaseDamage(baseDmg,user,target)
if isConst?(@id,PBMoves,:WATERSHURIKEN) && if @id == :WATERSHURIKEN && user.isSpecies?(:GRENINJA) && user.form == 2
user.isSpecies?(:GRENINJA) && user.form==2
return 20 return 20
end end
return super return super
@@ -2044,7 +2035,7 @@ end
class PokeBattle_Move_0C4 < PokeBattle_TwoTurnMove class PokeBattle_Move_0C4 < PokeBattle_TwoTurnMove
def pbIsChargingTurn?(user) def pbIsChargingTurn?(user)
ret = super ret = super
if user.effects[PBEffects::TwoTurnAttack]==0 if !user.effects[PBEffects::TwoTurnAttack]
w = @battle.pbWeather w = @battle.pbWeather
if w==PBWeather::Sun || w==PBWeather::HarshSun if w==PBWeather::Sun || w==PBWeather::HarshSun
@powerHerb = false @powerHerb = false
@@ -2234,8 +2225,8 @@ class PokeBattle_Move_0CE < PokeBattle_TwoTurnMove
# NOTE: Sky Drop doesn't benefit from Power Herb, probably because it works # NOTE: Sky Drop doesn't benefit from Power Herb, probably because it works
# differently (i.e. immobilises the target during use too). # differently (i.e. immobilises the target during use too).
@powerHerb = false @powerHerb = false
@chargingTurn = (user.effects[PBEffects::TwoTurnAttack]==0) @chargingTurn = (user.effects[PBEffects::TwoTurnAttack].nil?)
@damagingTurn = (user.effects[PBEffects::TwoTurnAttack]!=0) @damagingTurn = (!user.effects[PBEffects::TwoTurnAttack].nil?)
return !@damagingTurn return !@damagingTurn
end end
@@ -2306,21 +2297,22 @@ class PokeBattle_Move_0CF < PokeBattle_Move
target.effects[PBEffects::TrappingUser] = user.index target.effects[PBEffects::TrappingUser] = user.index
# Message # Message
msg = _INTL("{1} was trapped in the vortex!",target.pbThis) msg = _INTL("{1} was trapped in the vortex!",target.pbThis)
if isConst?(@id,PBMoves,:BIND) case @id
when :BIND
msg = _INTL("{1} was squeezed by {2}!",target.pbThis,user.pbThis(true)) msg = _INTL("{1} was squeezed by {2}!",target.pbThis,user.pbThis(true))
elsif isConst?(@id,PBMoves,:CLAMP) when :CLAMP
msg = _INTL("{1} clamped {2}!",user.pbThis,target.pbThis(true)) msg = _INTL("{1} clamped {2}!",user.pbThis,target.pbThis(true))
elsif isConst?(@id,PBMoves,:FIRESPIN) when :FIRESPIN
msg = _INTL("{1} was trapped in the fiery vortex!",target.pbThis) msg = _INTL("{1} was trapped in the fiery vortex!",target.pbThis)
elsif isConst?(@id,PBMoves,:INFESTATION) when :INFESTATION
msg = _INTL("{1} has been afflicted with an infestation by {2}!",target.pbThis,user.pbThis(true)) msg = _INTL("{1} has been afflicted with an infestation by {2}!",target.pbThis,user.pbThis(true))
elsif isConst?(@id,PBMoves,:MAGMASTORM) when :MAGMASTORM
msg = _INTL("{1} became trapped by Magma Storm!",target.pbThis) msg = _INTL("{1} became trapped by Magma Storm!",target.pbThis)
elsif isConst?(@id,PBMoves,:SANDTOMB) when :SANDTOMB
msg = _INTL("{1} became trapped by Sand Tomb!",target.pbThis) msg = _INTL("{1} became trapped by Sand Tomb!",target.pbThis)
elsif isConst?(@id,PBMoves,:WHIRLPOOL) when :WHIRLPOOL
msg = _INTL("{1} became trapped in the vortex!",target.pbThis) msg = _INTL("{1} became trapped in the vortex!",target.pbThis)
elsif isConst?(@id,PBMoves,:WRAP) when :WRAP
msg = _INTL("{1} was wrapped by {2}!",target.pbThis,user.pbThis(true)) msg = _INTL("{1} was wrapped by {2}!",target.pbThis,user.pbThis(true))
end end
@battle.pbDisplay(msg) @battle.pbDisplay(msg)
@@ -3282,10 +3274,10 @@ class PokeBattle_Move_0F2 < PokeBattle_Move
oldUserItem = user.item; oldUserItemName = user.itemName oldUserItem = user.item; oldUserItemName = user.itemName
oldTargetItem = target.item; oldTargetItemName = target.itemName oldTargetItem = target.item; oldTargetItemName = target.itemName
user.item = oldTargetItem user.item = oldTargetItem
user.effects[PBEffects::ChoiceBand] = -1 user.effects[PBEffects::ChoiceBand] = nil
user.effects[PBEffects::Unburden] = (!user.item && oldUserItem) user.effects[PBEffects::Unburden] = (!user.item && oldUserItem)
target.item = oldUserItem target.item = oldUserItem
target.effects[PBEffects::ChoiceBand] = -1 target.effects[PBEffects::ChoiceBand] = nil
target.effects[PBEffects::Unburden] = (!target.item && oldTargetItem) target.effects[PBEffects::Unburden] = (!target.item && oldTargetItem)
# Permanently steal the item from wild Pokémon # Permanently steal the item from wild Pokémon
if @battle.wildBattle? && target.opposes? && if @battle.wildBattle? && target.opposes? &&
@@ -107,8 +107,8 @@ class PokeBattle_Move_106 < PokeBattle_PledgeMove
def initialize(battle,move) def initialize(battle,move)
super super
# [Function code to combo with, effect, override type, override animation] # [Function code to combo with, effect, override type, override animation]
@combos = [["107",:SeaOfFire,getConst(PBTypes,:FIRE),getConst(PBMoves,:FIREPLEDGE)], @combos = [["107", :SeaOfFire, getConst(PBTypes, :FIRE), :FIREPLEDGE],
["108",:Swamp,nil,nil]] ["108", :Swamp, nil, nil]]
end end
end end
@@ -123,8 +123,8 @@ class PokeBattle_Move_107 < PokeBattle_PledgeMove
def initialize(battle,move) def initialize(battle,move)
super super
# [Function code to combo with, effect, override type, override animation] # [Function code to combo with, effect, override type, override animation]
@combos = [["108",:Rainbow,getConst(PBTypes,:WATER),getConst(PBMoves,:WATERPLEDGE)], @combos = [["108", :Rainbow, getConst(PBTypes, :WATER), :WATERPLEDGE],
["106",:SeaOfFire,nil,nil]] ["106", :SeaOfFire, nil, nil]]
end end
end end
@@ -139,8 +139,8 @@ class PokeBattle_Move_108 < PokeBattle_PledgeMove
def initialize(battle,move) def initialize(battle,move)
super super
# [Function code to combo with, effect, override type, override animation] # [Function code to combo with, effect, override type, override animation]
@combos = [["106",:Swamp,getConst(PBTypes,:GRASS),getConst(PBMoves,:GRASSPLEDGE)], @combos = [["106", :Swamp, getConst(PBTypes, :GRASS), :GRASSPLEDGE],
["107",:Rainbow,nil,nil]] ["107", :Rainbow, nil, nil]]
end end
end end
@@ -243,7 +243,7 @@ class PokeBattle_Move_10C < PokeBattle_Move
def pbEffectGeneral(user) def pbEffectGeneral(user)
user.effects[PBEffects::Trapping] = 0 user.effects[PBEffects::Trapping] = 0
user.effects[PBEffects::TrappingMove] = 0 user.effects[PBEffects::TrappingMove] = nil
user.effects[PBEffects::Substitute] = @subLife user.effects[PBEffects::Substitute] = @subLife
@battle.pbDisplay(_INTL("{1} put in a substitute!",user.pbThis)) @battle.pbDisplay(_INTL("{1} put in a substitute!",user.pbThis))
end end
@@ -326,10 +326,12 @@ class PokeBattle_Move_10E < PokeBattle_Move
def pbFailsAgainstTarget?(user,target) def pbFailsAgainstTarget?(user,target)
failed = true failed = true
if target.lastRegularMoveUsed
target.eachMove do |m| target.eachMove do |m|
next if m.id!=target.lastRegularMoveUsed || m.pp==0 || m.totalpp<=0 next if m.id!=target.lastRegularMoveUsed || m.pp==0 || m.total_pp<=0
failed = false; break failed = false; break
end end
end
if failed if failed
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
@@ -379,11 +381,11 @@ class PokeBattle_Move_110 < PokeBattle_Move
def pbEffectAfterAllHits(user,target) def pbEffectAfterAllHits(user,target)
return if user.fainted? || target.damageState.unaffected return if user.fainted? || target.damageState.unaffected
if user.effects[PBEffects::Trapping]>0 if user.effects[PBEffects::Trapping]>0
trapMove = PBMoves.getName(user.effects[PBEffects::TrappingMove]) trapMove = GameData::Move.get(user.effects[PBEffects::TrappingMove]).name
trapUser = @battle.battlers[user.effects[PBEffects::TrappingUser]] trapUser = @battle.battlers[user.effects[PBEffects::TrappingUser]]
@battle.pbDisplay(_INTL("{1} got free of {2}'s {3}!",user.pbThis,trapUser.pbThis(true),trapMove)) @battle.pbDisplay(_INTL("{1} got free of {2}'s {3}!",user.pbThis,trapUser.pbThis(true),trapMove))
user.effects[PBEffects::Trapping] = 0 user.effects[PBEffects::Trapping] = 0
user.effects[PBEffects::TrappingMove] = 0 user.effects[PBEffects::TrappingMove] = nil
user.effects[PBEffects::TrappingUser] = -1 user.effects[PBEffects::TrappingUser] = -1
end end
if user.effects[PBEffects::LeechSeed]>=0 if user.effects[PBEffects::LeechSeed]>=0
@@ -447,7 +449,7 @@ class PokeBattle_Move_111 < PokeBattle_Move
effects[PBEffects::FutureSightMove] = @id effects[PBEffects::FutureSightMove] = @id
effects[PBEffects::FutureSightUserIndex] = user.index effects[PBEffects::FutureSightUserIndex] = user.index
effects[PBEffects::FutureSightUserPartyIndex] = user.pokemonIndex effects[PBEffects::FutureSightUserPartyIndex] = user.pokemonIndex
if isConst?(@id,PBMoves,:DOOMDESIRE) if @id == :DOOMDESIRE
@battle.pbDisplay(_INTL("{1} chose Doom Desire as its destiny!",user.pbThis)) @battle.pbDisplay(_INTL("{1} chose Doom Desire as its destiny!",user.pbThis))
else else
@battle.pbDisplay(_INTL("{1} foresaw an attack!",user.pbThis)) @battle.pbDisplay(_INTL("{1} foresaw an attack!",user.pbThis))
@@ -624,7 +626,7 @@ class PokeBattle_Move_116 < PokeBattle_Move
return true return true
end end
oppMove = @battle.choices[target.index][2] oppMove = @battle.choices[target.index][2]
if !oppMove || oppMove.id<=0 || if !oppMove ||
(oppMove.function!="0B0" && # Me First (oppMove.function!="0B0" && # Me First
(target.movedThisRound? || oppMove.statusMove?)) (target.movedThisRound? || oppMove.statusMove?))
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
@@ -647,7 +649,7 @@ class PokeBattle_Move_117 < PokeBattle_Move
next if b.effects[PBEffects::FollowMe]<user.effects[PBEffects::FollowMe] next if b.effects[PBEffects::FollowMe]<user.effects[PBEffects::FollowMe]
user.effects[PBEffects::FollowMe] = b.effects[PBEffects::FollowMe]+1 user.effects[PBEffects::FollowMe] = b.effects[PBEffects::FollowMe]+1
end end
user.effects[PBEffects::RagePowder] = true if isConst?(@id,PBMoves,:RAGEPOWDER) user.effects[PBEffects::RagePowder] = true if @id == :RAGEPOWDER
@battle.pbDisplay(_INTL("{1} became the center of attention!",user.pbThis)) @battle.pbDisplay(_INTL("{1} became the center of attention!",user.pbThis))
end end
end end
@@ -673,7 +675,7 @@ class PokeBattle_Move_118 < PokeBattle_Move
@battle.eachBattler do |b| @battle.eachBattler do |b|
showMessage = false showMessage = false
if b.inTwoTurnAttack?("0C9","0CC","0CE") # Fly/Bounce/Sky Drop if b.inTwoTurnAttack?("0C9","0CC","0CE") # Fly/Bounce/Sky Drop
b.effects[PBEffects::TwoTurnAttack] = 0 b.effects[PBEffects::TwoTurnAttack] = nil
@battle.pbClearChoice(b.index) if !b.movedThisRound? @battle.pbClearChoice(b.index) if !b.movedThisRound?
showMessage = true showMessage = true
end end
@@ -778,7 +780,7 @@ class PokeBattle_Move_11C < PokeBattle_Move
return if !target.airborne? && !target.inTwoTurnAttack?("0C9","0CC") # Fly/Bounce return if !target.airborne? && !target.inTwoTurnAttack?("0C9","0CC") # Fly/Bounce
target.effects[PBEffects::SmackDown] = true target.effects[PBEffects::SmackDown] = true
if target.inTwoTurnAttack?("0C9","0CC") # Fly/Bounce. NOTE: Not Sky Drop. if target.inTwoTurnAttack?("0C9","0CC") # Fly/Bounce. NOTE: Not Sky Drop.
target.effects[PBEffects::TwoTurnAttack] = 0 target.effects[PBEffects::TwoTurnAttack] = nil
@battle.pbClearChoice(target.index) if !target.movedThisRound? @battle.pbClearChoice(target.index) if !target.movedThisRound?
end end
target.effects[PBEffects::MagnetRise] = 0 target.effects[PBEffects::MagnetRise] = 0
@@ -805,7 +807,7 @@ class PokeBattle_Move_11D < PokeBattle_Move
end end
# Target didn't choose to use a move this round # Target didn't choose to use a move this round
oppMove = @battle.choices[target.index][2] oppMove = @battle.choices[target.index][2]
if !oppMove || oppMove.id<=0 if !oppMove
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -829,7 +831,7 @@ class PokeBattle_Move_11E < PokeBattle_Move
return true if pbMoveFailedTargetAlreadyMoved?(target) return true if pbMoveFailedTargetAlreadyMoved?(target)
# Target isn't going to use a move # Target isn't going to use a move
oppMove = @battle.choices[target.index][2] oppMove = @battle.choices[target.index][2]
if !oppMove || oppMove.id<=0 if !oppMove
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -1636,7 +1638,7 @@ end
#=============================================================================== #===============================================================================
class PokeBattle_Move_14E < PokeBattle_TwoTurnMove class PokeBattle_Move_14E < PokeBattle_TwoTurnMove
def pbMoveFailed?(user,targets) def pbMoveFailed?(user,targets)
return false if user.effects[PBEffects::TwoTurnAttack]>0 # Charging turn return false if user.effects[PBEffects::TwoTurnAttack] # Charging turn
if !user.pbCanRaiseStatStage?(PBStats::SPATK,user,self) && if !user.pbCanRaiseStatStage?(PBStats::SPATK,user,self) &&
!user.pbCanRaiseStatStage?(PBStats::SPDEF,user,self) && !user.pbCanRaiseStatStage?(PBStats::SPDEF,user,self) &&
!user.pbCanRaiseStatStage?(PBStats::SPEED,user,self) !user.pbCanRaiseStatStage?(PBStats::SPEED,user,self)
@@ -2327,7 +2329,7 @@ class PokeBattle_Move_16B < PokeBattle_Move
end end
def pbFailsAgainstTarget?(user,target) def pbFailsAgainstTarget?(user,target)
if target.lastRegularMoveUsed<0 || !target.pbHasMove?(target.lastRegularMoveUsed) if !target.lastRegularMoveUsed || !target.pbHasMove?(target.lastRegularMoveUsed)
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -2342,7 +2344,7 @@ class PokeBattle_Move_16B < PokeBattle_Move
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
if @moveBlacklist.include?(pbGetMoveData(target.lastRegularMoveUsed,MoveData::FUNCTION_CODE)) if @moveBlacklist.include?(GameData::Move.get(target.lastRegularMoveUsed).function_code)
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -2350,7 +2352,7 @@ class PokeBattle_Move_16B < PokeBattle_Move
target.eachMoveWithIndex do |m,i| target.eachMoveWithIndex do |m,i|
idxMove = i if m.id==target.lastRegularMoveUsed idxMove = i if m.id==target.lastRegularMoveUsed
end end
if target.moves[idxMove].pp==0 && target.moves[idxMove].totalpp>0 if target.moves[idxMove].pp==0 && target.moves[idxMove].total_pp>0
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -152,7 +152,7 @@ class PokeBattle_Battle
@battleBond = [Array.new(@party1.length, false), Array.new(@party2.length, false)] @battleBond = [Array.new(@party1.length, false), Array.new(@party2.length, false)]
@usedInBattle = [Array.new(@party1.length, false), Array.new(@party2.length, false)] @usedInBattle = [Array.new(@party1.length, false), Array.new(@party2.length, false)]
@successStates = [] @successStates = []
@lastMoveUsed = -1 @lastMoveUsed = nil
@lastMoveUser = -1 @lastMoveUser = -1
@switching = false @switching = false
@futureSight = false @futureSight = false
@@ -160,8 +160,8 @@ class PokeBattle_Battle
@moldBreaker = false @moldBreaker = false
@runCommand = 0 @runCommand = 0
@nextPickupUse = 0 @nextPickupUse = 0
if hasConst?(PBMoves,:STRUGGLE) if GameData::Move.exists?(:STRUGGLE)
@struggle = PokeBattle_Move.pbFromPBMove(self,PBMove.new(getConst(PBMoves,:STRUGGLE))) @struggle = PokeBattle_Move.pbFromPBMove(self,PBMove.new(:STRUGGLE))
else else
@struggle = PokeBattle_Struggle.new(self,nil) @struggle = PokeBattle_Struggle.new(self,nil)
end end
@@ -222,11 +222,11 @@ class PokeBattle_Battle
return if !pkmn return if !pkmn
pkmnName = pkmn.name pkmnName = pkmn.name
battler = pbFindBattler(idxParty) battler = pbFindBattler(idxParty)
moveName = PBMoves.getName(newMove) moveName = GameData::Move.get(newMove).name
# Find a space for the new move in pkmn's moveset and learn it # Find a space for the new move in pkmn's moveset and learn it
pkmn.moves.each_with_index do |m,i| for i in 0...Pokemon::MAX_MOVES
return if m.id==newMove # Already knows the new move m = pkmn.moves[i]
next if m.id!=0 # Not a blank move slot return if m && m.id==newMove # Already knows the new move
pkmn.moves[i] = PBMove.new(newMove) pkmn.moves[i] = PBMove.new(newMove)
battler.moves[i] = PokeBattle_Move.pbFromPBMove(self,pkmn.moves[i]) if battler battler.moves[i] = PokeBattle_Move.pbFromPBMove(self,pkmn.moves[i]) if battler
pbDisplay(_INTL("{1} learned {2}!",pkmnName,moveName)) { pbSEPlay("Pkmn move learnt") } pbDisplay(_INTL("{1} learned {2}!",pkmnName,moveName)) { pbSEPlay("Pkmn move learnt") }
@@ -240,7 +240,7 @@ class PokeBattle_Battle
pbDisplayPaused(_INTL("Which move should be forgotten?")) pbDisplayPaused(_INTL("Which move should be forgotten?"))
forgetMove = @scene.pbForgetMove(pkmn,newMove) forgetMove = @scene.pbForgetMove(pkmn,newMove)
if forgetMove>=0 if forgetMove>=0
oldMoveName = PBMoves.getName(pkmn.moves[forgetMove].id) oldMoveName = pkmn.moves[forgetMove].name
pkmn.moves[forgetMove] = PBMove.new(newMove) # Replaces current/total PP pkmn.moves[forgetMove] = PBMove.new(newMove) # Replaces current/total PP
battler.moves[forgetMove] = PokeBattle_Move.pbFromPBMove(self,pkmn.moves[forgetMove]) if battler battler.moves[forgetMove] = PokeBattle_Move.pbFromPBMove(self,pkmn.moves[forgetMove]) if battler
pbDisplayPaused(_INTL("1, 2, and... ... ... Ta-da!")) pbDisplayPaused(_INTL("1, 2, and... ... ... Ta-da!"))
@@ -5,8 +5,8 @@ class PokeBattle_Battle
def pbCanChooseMove?(idxBattler,idxMove,showMessages,sleepTalk=false) def pbCanChooseMove?(idxBattler,idxMove,showMessages,sleepTalk=false)
battler = @battlers[idxBattler] battler = @battlers[idxBattler]
move = battler.moves[idxMove] move = battler.moves[idxMove]
return false unless move && move.id>0 return false unless move
if move.pp==0 && move.totalpp>0 && !sleepTalk if move.pp==0 && move.total_pp>0 && !sleepTalk
pbDisplayPaused(_INTL("There's no PP left for this move!")) if showMessages pbDisplayPaused(_INTL("There's no PP left for this move!")) if showMessages
return false return false
end end
@@ -20,7 +20,7 @@ class PokeBattle_Battle
def pbCanChooseAnyMove?(idxBattler,sleepTalk=false) def pbCanChooseAnyMove?(idxBattler,sleepTalk=false)
battler = @battlers[idxBattler] battler = @battlers[idxBattler]
battler.eachMoveWithIndex do |m,i| battler.eachMoveWithIndex do |m,i|
next if m.pp==0 && m.totalpp>0 && !sleepTalk next if m.pp==0 && m.total_pp>0 && !sleepTalk
if battler.effects[PBEffects::Encore]>0 if battler.effects[PBEffects::Encore]>0
idxEncoredMove = battler.pbEncoredMoveIndex idxEncoredMove = battler.pbEncoredMoveIndex
next if idxEncoredMove>=0 && i!=idxEncoredMove next if idxEncoredMove>=0 && i!=idxEncoredMove
@@ -80,10 +80,8 @@ class PokeBattle_Battle
def pbChoseMove?(idxBattler,moveID) def pbChoseMove?(idxBattler,moveID)
return false if !@battlers[idxBattler] || @battlers[idxBattler].fainted? return false if !@battlers[idxBattler] || @battlers[idxBattler].fainted?
idxMove = @choices[idxBattler][1] if @choices[idxBattler][0]==:UseMove && @choices[idxBattler][1]
if @choices[idxBattler][0]==:UseMove && idxMove>=0 return @choices[idxBattler][2].id == moveID
chosenMoveID = @battlers[idxBattler].moves[idxMove].id
return isConst?(chosenMoveID,PBMoves,moveID)
end end
return false return false
end end
@@ -91,8 +89,8 @@ class PokeBattle_Battle
def pbChoseMoveFunctionCode?(idxBattler,code) def pbChoseMoveFunctionCode?(idxBattler,code)
return false if @battlers[idxBattler].fainted? return false if @battlers[idxBattler].fainted?
idxMove = @choices[idxBattler][1] idxMove = @choices[idxBattler][1]
if @choices[idxBattler][0]==:UseMove && idxMove>=0 if @choices[idxBattler][0]==:UseMove && @choices[idxBattler][1]
return @battlers[idxBattler].moves[idxMove].function==code return @choices[idxBattler][2].function == code
end end
return false return false
end end
@@ -342,7 +342,7 @@ class PokeBattle_Battle
pbDisplay(_INTL("{1} became cloaked in mystical moonlight!",battler.pbThis)) pbDisplay(_INTL("{1} became cloaked in mystical moonlight!",battler.pbThis))
battler.pbRecoverHP(battler.totalhp) battler.pbRecoverHP(battler.totalhp)
battler.pbCureStatus(false) battler.pbCureStatus(false)
battler.eachMove { |m| m.pp = m.totalpp } battler.eachMove { |m| m.pp = m.total_pp }
@positions[battler.index].effects[PBEffects::LunarDance] = false @positions[battler.index].effects[PBEffects::LunarDance] = false
end end
# Entry hazards # Entry hazards
@@ -76,7 +76,7 @@ class PokeBattle_Battle
ret = true ret = true
else # Chose a move to use else # Chose a move to use
next false if cmd<0 || !@battlers[idxBattler].moves[cmd] || next false if cmd<0 || !@battlers[idxBattler].moves[cmd] ||
@battlers[idxBattler].moves[cmd].id<=0 !@battlers[idxBattler].moves[cmd].id
next false if !pbRegisterMove(idxBattler,cmd) next false if !pbRegisterMove(idxBattler,cmd)
next false if !singleBattle? && next false if !singleBattle? &&
!pbChooseTarget(@battlers[idxBattler],@battlers[idxBattler].moves[cmd]) !pbChooseTarget(@battlers[idxBattler],@battlers[idxBattler].moves[cmd])
@@ -234,7 +234,8 @@ class PokeBattle_Battle
end end
next if !moveUser # User is fainted next if !moveUser # User is fainted
move = pos.effects[PBEffects::FutureSightMove] move = pos.effects[PBEffects::FutureSightMove]
pbDisplay(_INTL("{1} took the {2} attack!",@battlers[idxPos].pbThis,PBMoves.getName(move))) pbDisplay(_INTL("{1} took the {2} attack!",@battlers[idxPos].pbThis,
GameData::Move.get(move).name))
# NOTE: Future Sight failing against the target here doesn't count towards # NOTE: Future Sight failing against the target here doesn't count towards
# Stomping Tantrum. # Stomping Tantrum.
userLastMoveFailed = moveUser.lastMoveFailed userLastMoveFailed = moveUser.lastMoveFailed
@@ -244,7 +245,7 @@ class PokeBattle_Battle
moveUser.lastMoveFailed = userLastMoveFailed moveUser.lastMoveFailed = userLastMoveFailed
@battlers[idxPos].pbFaint if @battlers[idxPos].fainted? @battlers[idxPos].pbFaint if @battlers[idxPos].fainted?
pos.effects[PBEffects::FutureSightCounter] = 0 pos.effects[PBEffects::FutureSightCounter] = 0
pos.effects[PBEffects::FutureSightMove] = 0 pos.effects[PBEffects::FutureSightMove] = nil
pos.effects[PBEffects::FutureSightUserIndex] = -1 pos.effects[PBEffects::FutureSightUserIndex] = -1
pos.effects[PBEffects::FutureSightUserPartyIndex] = -1 pos.effects[PBEffects::FutureSightUserPartyIndex] = -1
end end
@@ -401,19 +402,19 @@ class PokeBattle_Battle
priority.each do |b| priority.each do |b|
next if b.fainted? || b.effects[PBEffects::Trapping]==0 next if b.fainted? || b.effects[PBEffects::Trapping]==0
b.effects[PBEffects::Trapping] -= 1 b.effects[PBEffects::Trapping] -= 1
moveName = PBMoves.getName(b.effects[PBEffects::TrappingMove]) moveName = GameData::Move.get(b.effects[PBEffects::TrappingMove]).name
if b.effects[PBEffects::Trapping]==0 if b.effects[PBEffects::Trapping]==0
pbDisplay(_INTL("{1} was freed from {2}!",b.pbThis,moveName)) pbDisplay(_INTL("{1} was freed from {2}!",b.pbThis,moveName))
else else
trappingMove = b.effects[PBEffects::TrappingMove] case b.effects[PBEffects::TrappingMove]
if isConst?(trappingMove,PBMoves,:BIND); pbCommonAnimation("Bind",b) when :BIND then pbCommonAnimation("Bind", b)
elsif isConst?(trappingMove,PBMoves,:CLAMP); pbCommonAnimation("Clamp",b) when :CLAMP then pbCommonAnimation("Clamp", b)
elsif isConst?(trappingMove,PBMoves,:FIRESPIN); pbCommonAnimation("FireSpin",b) when :FIRESPIN then pbCommonAnimation("FireSpin", b)
elsif isConst?(trappingMove,PBMoves,:MAGMASTORM); pbCommonAnimation("MagmaStorm",b) when :MAGMASTORM then pbCommonAnimation("MagmaStorm", b)
elsif isConst?(trappingMove,PBMoves,:SANDTOMB); pbCommonAnimation("SandTomb",b) when :SANDTOMB then pbCommonAnimation("SandTomb", b)
elsif isConst?(trappingMove,PBMoves,:WRAP); pbCommonAnimation("Wrap",b) when :WRAP then pbCommonAnimation("Wrap", b)
elsif isConst?(trappingMove,PBMoves,:INFESTATION); pbCommonAnimation("Infestation",b) when :INFESTATION then pbCommonAnimation("Infestation", b)
else; pbCommonAnimation("Wrap",b) else pbCommonAnimation("Wrap", b)
end end
if b.takesIndirectDamage? if b.takesIndirectDamage?
hpLoss = (NEWEST_BATTLE_MECHANICS) ? b.totalhp/8 : b.totalhp/16 hpLoss = (NEWEST_BATTLE_MECHANICS) ? b.totalhp/8 : b.totalhp/16
@@ -446,12 +447,12 @@ class PokeBattle_Battle
else else
PBDebug.log("[End of effect] #{b.pbThis}'s encore ended (encored move no longer known)") PBDebug.log("[End of effect] #{b.pbThis}'s encore ended (encored move no longer known)")
b.effects[PBEffects::Encore] = 0 b.effects[PBEffects::Encore] = 0
b.effects[PBEffects::EncoreMove] = 0 b.effects[PBEffects::EncoreMove] = nil
end end
end end
# Disable/Cursed Body # Disable/Cursed Body
pbEORCountDownBattlerEffect(priority,PBEffects::Disable) { |battler| pbEORCountDownBattlerEffect(priority,PBEffects::Disable) { |battler|
battler.effects[PBEffects::DisableMove] = 0 battler.effects[PBEffects::DisableMove] = nil
pbDisplay(_INTL("{1} is no longer disabled!",battler.pbThis)) pbDisplay(_INTL("{1} is no longer disabled!",battler.pbThis))
} }
# Magnet Rise # Magnet Rise
@@ -17,14 +17,14 @@ class PokeBattle_AI
# super-effective and powerful # super-effective and powerful
if !shouldSwitch && battler.turnCount>0 && skill>=PBTrainerAI.highSkill if !shouldSwitch && battler.turnCount>0 && skill>=PBTrainerAI.highSkill
target = battler.pbDirectOpposing(true) target = battler.pbDirectOpposing(true)
if !target.fainted? && target.lastMoveUsed>0 && if !target.fainted? && target.lastMoveUsed &&
(target.level-battler.level).abs<=6 (target.level-battler.level).abs<=6
moveData = pbGetMoveData(target.lastMoveUsed) moveData = GameData::Move.get(target.lastMoveUsed)
moveType = moveData[MoveData::TYPE] moveType = moveData.type
typeMod = pbCalcTypeMod(moveType,target,battler) typeMod = pbCalcTypeMod(moveType,target,battler)
if PBTypes.superEffective?(typeMod) && moveData[MoveData::BASE_DAMAGE]>50 if PBTypes.superEffective?(typeMod) && moveData.base_damage > 50
switchChance = (moveData[MoveData::BASE_DAMAGE]>70) ? 30 : 20 switchChance = (moveData.base_damage > 70) ? 30 : 20
shouldSwitch = (pbAIRandom(100)<switchChance) shouldSwitch = (pbAIRandom(100) < switchChance)
end end
end end
end end
@@ -158,18 +158,14 @@ class PokeBattle_AI
return -1 if !enemies || enemies.length==0 return -1 if !enemies || enemies.length==0
best = -1 best = -1
bestSum = 0 bestSum = 0
movesData = pbLoadMovesData
enemies.each do |i| enemies.each do |i|
pkmn = party[i] pkmn = party[i]
sum = 0 sum = 0
pkmn.moves.each do |m| pkmn.moves.each do |m|
next if m.id==0 next if m.base_damage == 0
moveData = movesData[m.id]
next if moveData[MoveData::BASE_DAMAGE]==0
@battle.battlers[idxBattler].eachOpposing do |b| @battle.battlers[idxBattler].eachOpposing do |b|
bTypes = b.pbTypes(true) bTypes = b.pbTypes(true)
sum += PBTypes.getCombinedEffectiveness(moveData[MoveData::TYPE], sum += PBTypes.getCombinedEffectiveness(m.type, bTypes[0], bTypes[1], bTypes[2])
bTypes[0],bTypes[1],bTypes[2])
end end
end end
if best==-1 || sum>bestSum if best==-1 || sum>bestSum
@@ -105,7 +105,7 @@ class PokeBattle_AI
end end
# Log the result # Log the result
if @battle.choices[idxBattler][2] if @battle.choices[idxBattler][2]
PBDebug.log("[AI] #{user.pbThis} (#{user.index}) will use #{@battle.choices[user.index][2].name}") PBDebug.log("[AI] #{user.pbThis} (#{user.index}) will use #{@battle.choices[idxBattler][2].name}")
end end
end end
@@ -70,7 +70,7 @@ class PokeBattle_AI
when "007", "008", "009", "0C5" when "007", "008", "009", "0C5"
if target.pbCanParalyze?(user,false) && if target.pbCanParalyze?(user,false) &&
!(skill>=PBTrainerAI.mediumSkill && !(skill>=PBTrainerAI.mediumSkill &&
isConst?(move.id,PBMoves,:THUNDERWAVE) && move.id == :THUNDERWAVE &&
PBTypes.ineffective?(pbCalcTypeMod(move.type,user,target))) PBTypes.ineffective?(pbCalcTypeMod(move.type,user,target)))
score += 30 score += 30
if skill>=PBTrainerAI.mediumSkill if skill>=PBTrainerAI.mediumSkill
@@ -1275,18 +1275,20 @@ class PokeBattle_AI
"05D", # Sketch "05D", # Sketch
"0B6" # Metronome "0B6" # Metronome
] ]
lastMoveData = pbGetMoveData(target.lastRegularMoveUsed) if user.effects[PBEffects::Transform] || !target.lastRegularMoveUsed
if user.effects[PBEffects::Transform] || score -= 90
target.lastRegularMoveUsed<=0 || else
moveBlacklist.include?(lastMoveData[MoveData::FUNCTION_CODE]) || lastMoveData = GameData::Move.get(target.lastRegularMoveUsed)
isConst?(lastMoveData[MoveData::TYPE],PBTypes,:SHADOW) if moveBlacklist.include?(lastMoveData.function_code) ||
isConst?(lastMoveData.type, PBTypes,:SHADOW)
score -= 90 score -= 90
end end
user.eachMove do |m| user.eachMove do |m|
next if m.id!=target.lastRegularMoveUsed next if m != target.lastRegularMoveUsed
score -= 90 score -= 90
break break
end end
end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "05D" when "05D"
moveBlacklist = [ moveBlacklist = [
@@ -1294,18 +1296,20 @@ class PokeBattle_AI
"014", # Chatter "014", # Chatter
"05D" # Sketch "05D" # Sketch
] ]
lastMoveData = pbGetMoveData(target.lastRegularMoveUsed) if user.effects[PBEffects::Transform] || !target.lastRegularMoveUsed
if user.effects[PBEffects::Transform] || score -= 90
target.lastRegularMoveUsed<=0 || else
moveBlacklist.include?(lastMoveData[MoveData::FUNCTION_CODE]) || lastMoveData = GameData::Move.get(target.lastRegularMoveUsed)
isConst?(lastMoveData[MoveData::TYPE],PBTypes,:SHADOW) if moveBlacklist.include?(lastMoveData.function_code) ||
isConst?(lastMoveData.type, PBTypes,:SHADOW)
score -= 90 score -= 90
end end
user.eachMove do |m| user.eachMove do |m|
next if m.id!=target.lastRegularMoveUsed next if m != target.lastRegularMoveUsed
score -= 90 # User already knows the move that will be Sketched score -= 90 # User already knows the move that will be Sketched
break break
end end
end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "05E" when "05E"
if user.ability == :MULTITYPE || user.ability == :RKSSYSTEM if user.ability == :MULTITYPE || user.ability == :RKSSYSTEM
@@ -1324,8 +1328,8 @@ class PokeBattle_AI
when "05F" when "05F"
if user.ability == :MULTITYPE || user.ability == :RKSSYSTEM if user.ability == :MULTITYPE || user.ability == :RKSSYSTEM
score -= 90 score -= 90
elsif target.lastMoveUsed<=0 || elsif !target.lastMoveUsed ||
PBTypes.isPseudoType?(pbGetMoveData(target.lastMoveUsed,MoveData::TYPE)) PBTypes.isPseudoType?(GameData::Move.get(target.lastMoveUsed).type)
score -= 90 score -= 90
else else
aType = -1 aType = -1
@@ -1507,11 +1511,11 @@ class PokeBattle_AI
spatk = pbRoughStat(user,PBStats::SPATK,skill) spatk = pbRoughStat(user,PBStats::SPATK,skill)
if attack*1.5<spatk if attack*1.5<spatk
score -= 60 score -= 60
elsif skill>=PBTrainerAI.mediumSkill && target.lastMoveUsed>0 elsif skill>=PBTrainerAI.mediumSkill && target.lastMoveUsed
moveData = pbGetMoveData(target.lastMoveUsed) moveData = GameData::Move.get(target.lastMoveUsed)
if moveData[MoveData::BASE_DAMAGE]>0 && if moveData.base_damage > 0 &&
(MOVE_CATEGORY_PER_MOVE && moveData[MoveData::CATEGORY]==0) || (MOVE_CATEGORY_PER_MOVE && moveData.category == 0) ||
(!MOVE_CATEGORY_PER_MOVE && PBTypes.isPhysicalType?(moveData[MoveData::TYPE])) (!MOVE_CATEGORY_PER_MOVE && PBTypes.isPhysicalType?(moveData.type))
score -= 60 score -= 60
end end
end end
@@ -1525,11 +1529,11 @@ class PokeBattle_AI
spatk = pbRoughStat(user,PBStats::SPATK,skill) spatk = pbRoughStat(user,PBStats::SPATK,skill)
if attack>spatk*1.5 if attack>spatk*1.5
score -= 60 score -= 60
elsif skill>=PBTrainerAI.mediumSkill && target.lastMoveUsed>0 elsif skill>=PBTrainerAI.mediumSkill && target.lastMoveUsed
moveData = pbGetMoveData(target.lastMoveUsed) moveData = GameData::Move.get(target.lastMoveUsed)
if moveData[MoveData::BASE_DAMAGE]>0 && if moveData.base_damage > 0 &&
(MOVE_CATEGORY_PER_MOVE && moveData[MoveData::CATEGORY]==1) || (MOVE_CATEGORY_PER_MOVE && moveData.caegory == 1) ||
(!MOVE_CATEGORY_PER_MOVE && !PBTypes.isSpecialType?(moveData[MoveData::TYPE])) (!MOVE_CATEGORY_PER_MOVE && !PBTypes.isSpecialType?(moveData.type))
score -= 60 score -= 60
end end
end end
@@ -1709,7 +1713,7 @@ class PokeBattle_AI
score -= user.effects[PBEffects::ProtectRate]*40 score -= user.effects[PBEffects::ProtectRate]*40
end end
score += 50 if user.turnCount==0 score += 50 if user.turnCount==0
score += 30 if target.effects[PBEffects::TwoTurnAttack]>0 score += 30 if target.effects[PBEffects::TwoTurnAttack]
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "0AB" when "0AB"
@@ -1721,8 +1725,8 @@ class PokeBattle_AI
when "0AE" when "0AE"
score -= 40 score -= 40
if skill>=PBTrainerAI.highSkill if skill>=PBTrainerAI.highSkill
score -= 100 if target.lastRegularMoveUsed<=0 || score -= 100 if !target.lastRegularMoveUsed ||
!pbGetMoveData(target.lastRegularMoveUsed,MoveData::FLAGS)[/e/] # Not copyable by Mirror Move !GameData::Move.get(target.lastRegularMoveUsed).flags[/e/] # Not copyable by Mirror Move
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "0AF" when "0AF"
@@ -1767,17 +1771,16 @@ class PokeBattle_AI
if target.effects[PBEffects::Encore]>0 if target.effects[PBEffects::Encore]>0
score -= 90 score -= 90
elsif aspeed>ospeed elsif aspeed>ospeed
if target.lastMoveUsed<=0 if !target.lastRegularMoveUsed
score -= 90 score -= 90
else else
moveData = pbGetMoveData(target.lastRegularMoveUsed) moveData = GameData::Move.get(target.lastRegularMoveUsed)
if moveData[MoveData::CATEGORY]==2 && # Status move if moveData.category == 2 && # Status move
(moveData[MoveData::TARGET]==PBTargets::User || [PBTargets::User, PBTargets::BothSides].include?(moveData.target)
moveData[MoveData::TARGET]==PBTargets::BothSides)
score += 60 score += 60
elsif moveData[MoveData::CATEGORY]!=2 && # Damaging move elsif moveData.category != 2 && # Damaging move
moveData[MoveData::TARGET]==PBTargets::NearOther && moveData.target == PBTargets::NearOther &&
PBTypes.ineffective?(pbCalcTypeMod(moveData[MoveData::TYPE],target,user)) PBTypes.ineffective?(pbCalcTypeMod(moveData.type, target, user))
score += 60 score += 60
end end
end end
@@ -2054,7 +2057,8 @@ class PokeBattle_AI
:CHOICEBAND,:CHOICESCARF,:CHOICESPECS]) :CHOICEBAND,:CHOICESCARF,:CHOICESPECS])
score += 50 score += 50
elsif !user.item && target.item elsif !user.item && target.item
score -= 30 if pbGetMoveData(user.lastMoveUsed,MoveData::FUNCTION_CODE)=="0F2" # Trick/Switcheroo score -= 30 if user.lastMoveUsed &&
GameData::Move.get(user.lastMoveUsed).function_code == "0F2" # Trick/Switcheroo
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "0F3" when "0F3"
@@ -2712,7 +2716,7 @@ class PokeBattle_AI
score -= user.effects[PBEffects::ProtectRate]*40 score -= user.effects[PBEffects::ProtectRate]*40
end end
score += 50 if user.turnCount==0 score += 50 if user.turnCount==0
score += 30 if target.effects[PBEffects::TwoTurnAttack]>0 score += 30 if target.effects[PBEffects::TwoTurnAttack]
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "14D" when "14D"
@@ -2924,7 +2928,7 @@ class PokeBattle_AI
score -= user.effects[PBEffects::ProtectRate]*40 score -= user.effects[PBEffects::ProtectRate]*40
end end
score += 50 if user.turnCount==0 score += 50 if user.turnCount==0
score += 30 if target.effects[PBEffects::TwoTurnAttack]>0 score += 30 if target.effects[PBEffects::TwoTurnAttack]
score += 20 # Because of possible poisoning score += 20 # Because of possible poisoning
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@@ -2940,7 +2944,7 @@ class PokeBattle_AI
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "16B" when "16B"
if skill>=PBTrainerAI.mediumSkill if skill>=PBTrainerAI.mediumSkill
if target.lastRegularMoveUsed<0 || if !target.lastRegularMoveUsed ||
!target.pbHasMove?(target.lastRegularMoveUsed) || !target.pbHasMove?(target.lastRegularMoveUsed) ||
target.usingMultiTurnAttack? target.usingMultiTurnAttack?
score -= 90 score -= 90
@@ -287,7 +287,7 @@ class PokeBattle_AI
abilityBlacklist = [:ANALYTIC,:SNIPER,:TINTEDLENS,:AERILATE,:PIXILATE,:REFRIGERATE] abilityBlacklist = [:ANALYTIC,:SNIPER,:TINTEDLENS,:AERILATE,:PIXILATE,:REFRIGERATE]
canCheck = true canCheck = true
abilityBlacklist.each do |m| abilityBlacklist.each do |m|
next if !isConst?(move.id,PBMoves,m) next if move.id != m
canCheck = false canCheck = false
break break
end end
@@ -309,7 +309,7 @@ class PokeBattle_AI
abilityBlacklist = [:FILTER,:SOLIDROCK] abilityBlacklist = [:FILTER,:SOLIDROCK]
canCheck = true canCheck = true
abilityBlacklist.each do |m| abilityBlacklist.each do |m|
next if !isConst?(move.id,PBMoves,m) next if move.id != m
canCheck = false canCheck = false
break break
end end
@@ -179,7 +179,7 @@ class CommandMenuDisplay < BattleMenuBase
def refreshButtons def refreshButtons
return if !USE_GRAPHICS return if !USE_GRAPHICS
for i in 0...4 for i in 0...@buttons.length
button = @buttons[i] button = @buttons[i]
button.src_rect.x = (i==@index) ? @buttonBitmap.width/2 : 0 button.src_rect.x = (i==@index) ? @buttonBitmap.width/2 : 0
button.src_rect.y = MODES[@mode][i]*BUTTON_HEIGHT button.src_rect.y = MODES[@mode][i]*BUTTON_HEIGHT
@@ -218,7 +218,6 @@ class FightMenuDisplay < BattleMenuBase
Color.new(248,192,0),Color.new(144,104,0), # Yellow, 1/2 of total PP or less Color.new(248,192,0),Color.new(144,104,0), # Yellow, 1/2 of total PP or less
TEXT_BASE_COLOR,TEXT_SHADOW_COLOR # Black, more than 1/2 of total PP TEXT_BASE_COLOR,TEXT_SHADOW_COLOR # Black, more than 1/2 of total PP
] ]
MAX_MOVES = 4 # Number of moves to display at once
def initialize(viewport,z) def initialize(viewport,z)
super(viewport) super(viewport)
@@ -239,7 +238,7 @@ class FightMenuDisplay < BattleMenuBase
background.setBitmap("Graphics/Pictures/Battle/overlay_fight") background.setBitmap("Graphics/Pictures/Battle/overlay_fight")
addSprite("background",background) addSprite("background",background)
# Create move buttons # Create move buttons
@buttons = Array.new(MAX_MOVES) do |i| @buttons = Array.new(Pokemon::MAX_MOVES) do |i|
button = SpriteWrapper.new(viewport) button = SpriteWrapper.new(viewport)
button.bitmap = @buttonBitmap.bitmap button.bitmap = @buttonBitmap.bitmap
button.x = self.x+4 button.x = self.x+4
@@ -337,20 +336,21 @@ class FightMenuDisplay < BattleMenuBase
if !USE_GRAPHICS if !USE_GRAPHICS
# Fill in command window # Fill in command window
commands = [] commands = []
moves.each { |m| commands.push((m && m.id>0) ? m.name : "-") } for i in 0...[4, moves.length].max
commands.push((moves[i]) ? moves[i].name : "-")
end
@cmdWindow.commands = commands @cmdWindow.commands = commands
return return
end end
# Draw move names onto overlay # Draw move names onto overlay
@overlay.bitmap.clear @overlay.bitmap.clear
textPos = [] textPos = []
moves.each_with_index do |m,i| @buttons.each_with_index do |button,i|
button = @buttons[i]
next if !@visibility["button_#{i}"] next if !@visibility["button_#{i}"]
x = button.x-self.x+button.src_rect.width/2 x = button.x-self.x+button.src_rect.width/2
y = button.y-self.y+8 y = button.y-self.y+8
moveNameBase = TEXT_BASE_COLOR moveNameBase = TEXT_BASE_COLOR
if m.type>=0 if moves[i].type>=0
# NOTE: This takes a colour from a particular pixel in the button # NOTE: This takes a colour from a particular pixel in the button
# graphic and makes the move name's base colour that same colour. # graphic and makes the move name's base colour that same colour.
# The pixel is at coordinates 10,34 in the button box. If you # The pixel is at coordinates 10,34 in the button box. If you
@@ -358,7 +358,7 @@ class FightMenuDisplay < BattleMenuBase
# of code to ensure the font is an appropriate colour. # of code to ensure the font is an appropriate colour.
moveNameBase = button.bitmap.get_pixel(10,button.src_rect.y+34) moveNameBase = button.bitmap.get_pixel(10,button.src_rect.y+34)
end end
textPos.push([m.name,x,y,2,moveNameBase,TEXT_SHADOW_COLOR]) textPos.push([moves[i].name,x,y,2,moveNameBase,TEXT_SHADOW_COLOR])
end end
pbDrawTextPositions(@overlay.bitmap,textPos) pbDrawTextPositions(@overlay.bitmap,textPos)
end end
@@ -368,7 +368,7 @@ class FightMenuDisplay < BattleMenuBase
if USE_GRAPHICS if USE_GRAPHICS
# Choose appropriate button graphics and z positions # Choose appropriate button graphics and z positions
@buttons.each_with_index do |button,i| @buttons.each_with_index do |button,i|
if !moves[i] || moves[i].id==0 if !moves[i]
@visibility["button_#{i}"] = false @visibility["button_#{i}"] = false
next next
end end
@@ -385,16 +385,16 @@ class FightMenuDisplay < BattleMenuBase
# Write PP and type of the selected move # Write PP and type of the selected move
if !USE_GRAPHICS if !USE_GRAPHICS
moveType = PBTypes.getName(move.type) moveType = PBTypes.getName(move.type)
if move.totalpp<=0 if move.total_pp<=0
@msgBox.text = _INTL("PP: ---<br>TYPE/{1}",moveType) @msgBox.text = _INTL("PP: ---<br>TYPE/{1}",moveType)
else else
@msgBox.text = _ISPRINTF("PP: {1: 2d}/{2: 2d}<br>TYPE/{3:s}", @msgBox.text = _ISPRINTF("PP: {1: 2d}/{2: 2d}<br>TYPE/{3:s}",
move.pp,move.totalpp,moveType) move.pp,move.total_pp,moveType)
end end
return return
end end
@infoOverlay.bitmap.clear @infoOverlay.bitmap.clear
if !move || move.id==0 if !move
@visibility["typeIcon"] = false @visibility["typeIcon"] = false
return return
end end
@@ -402,10 +402,10 @@ class FightMenuDisplay < BattleMenuBase
# Type icon # Type icon
@typeIcon.src_rect.y = move.type*TYPE_ICON_HEIGHT @typeIcon.src_rect.y = move.type*TYPE_ICON_HEIGHT
# PP text # PP text
if move.totalpp>0 if move.total_pp>0
ppFraction = [(4.0*move.pp/move.totalpp).ceil,3].min ppFraction = [(4.0*move.pp/move.total_pp).ceil,3].min
textPos = [] textPos = []
textPos.push([_INTL("PP: {1}/{2}",move.pp,move.totalpp), textPos.push([_INTL("PP: {1}/{2}",move.pp,move.total_pp),
448,50,2,PP_COLORS[ppFraction*2],PP_COLORS[ppFraction*2+1]]) 448,50,2,PP_COLORS[ppFraction*2],PP_COLORS[ppFraction*2+1]])
pbDrawTextPositions(@infoOverlay.bitmap,textPos) pbDrawTextPositions(@infoOverlay.bitmap,textPos)
end end
@@ -70,7 +70,7 @@ class PokeBattle_Scene
cw = @sprites["fightWindow"] cw = @sprites["fightWindow"]
cw.battler = battler cw.battler = battler
moveIndex = 0 moveIndex = 0
if battler.moves[@lastMove[idxBattler]] && battler.moves[@lastMove[idxBattler]].id>0 if battler.moves[@lastMove[idxBattler]] && battler.moves[@lastMove[idxBattler]].id
moveIndex = @lastMove[idxBattler] moveIndex = @lastMove[idxBattler]
end end
cw.shiftMode = (@battle.pbCanShift?(idxBattler)) ? 1 : 0 cw.shiftMode = (@battle.pbCanShift?(idxBattler)) ? 1 : 0
@@ -98,13 +98,13 @@ class PokeBattle_Scene
if Input.trigger?(Input::LEFT) if Input.trigger?(Input::LEFT)
cw.index -= 1 if (cw.index&1)==1 cw.index -= 1 if (cw.index&1)==1
elsif Input.trigger?(Input::RIGHT) elsif Input.trigger?(Input::RIGHT)
if battler.moves[cw.index+1] && battler.moves[cw.index+1].id>0 if battler.moves[cw.index+1] && battler.moves[cw.index+1].id
cw.index += 1 if (cw.index&1)==0 cw.index += 1 if (cw.index&1)==0
end end
elsif Input.trigger?(Input::UP) elsif Input.trigger?(Input::UP)
cw.index -= 2 if (cw.index&2)==2 cw.index -= 2 if (cw.index&2)==2
elsif Input.trigger?(Input::DOWN) elsif Input.trigger?(Input::DOWN)
if battler.moves[cw.index+2] && battler.moves[cw.index+2].id>0 if battler.moves[cw.index+2] && battler.moves[cw.index+2].id
cw.index += 2 if (cw.index&2)==0 cw.index += 2 if (cw.index&2)==0
end end
end end
@@ -383,13 +383,14 @@ class PokeBattle_Scene
# Returns the animation ID to use for a given move/user. Returns nil if that # Returns the animation ID to use for a given move/user. Returns nil if that
# move has no animations defined for it. # move has no animations defined for it.
def pbFindMoveAnimDetails(move2anim,moveID,idxUser,hitNum=0) def pbFindMoveAnimDetails(move2anim,moveID,idxUser,hitNum=0)
id_number = GameData::Move.get(moveID).id_number
noFlip = false noFlip = false
if (idxUser&1)==0 # On player's side if (idxUser&1)==0 # On player's side
anim = move2anim[0][moveID] anim = move2anim[0][id_number]
else # On opposing side else # On opposing side
anim = move2anim[1][moveID] anim = move2anim[1][id_number]
noFlip = true if anim noFlip = true if anim
anim = move2anim[0][moveID] if !anim anim = move2anim[0][id_number] if !anim
end end
return [anim+hitNum,noFlip] if anim return [anim+hitNum,noFlip] if anim
return nil return nil
@@ -399,62 +400,62 @@ class PokeBattle_Scene
# animations, tries to use a default move animation depending on the move's # animations, tries to use a default move animation depending on the move's
# type. If that default move animation doesn't exist, trues to use Tackle's # type. If that default move animation doesn't exist, trues to use Tackle's
# move animation. Returns nil if it can't find any of these animations to use. # move animation. Returns nil if it can't find any of these animations to use.
def pbFindMoveAnimation(moveID,idxUser,hitNum) def pbFindMoveAnimation(moveID, idxUser, hitNum)
begin begin
move2anim = pbLoadMoveToAnim move2anim = pbLoadMoveToAnim
# Find actual animation requested (an opponent using the animation first # Find actual animation requested (an opponent using the animation first
# looks for an OppMove version then a Move version) # looks for an OppMove version then a Move version)
anim = pbFindMoveAnimDetails(move2anim,moveID,idxUser,hitNum) anim = pbFindMoveAnimDetails(move2anim, moveID, idxUser, hitNum)
return anim if anim return anim if anim
# Actual animation not found, get the default animation for the move's type # Actual animation not found, get the default animation for the move's type
moveData = pbGetMoveData(moveID) moveData = GameData::Move.get(moveID)
moveType = moveData[MoveData::TYPE] moveType = moveData.type
moveKind = moveData[MoveData::CATEGORY] moveKind = moveData.category
moveKind += 3 if PBTargets.multipleTargets?(moveData[MoveData::TARGET]) || moveKind += 3 if PBTargets.multipleTargets?(moveData.target) ||
PBTargets.targetsFoeSide?(moveData[MoveData::TARGET]) PBTargets.targetsFoeSide?(moveData.target)
moveKind += 3 if moveKind==2 && moveData[MoveData::TARGET]!=PBTargets::User && moveKind += 3 if moveKind == 2 && moveData.target != PBTargets::User &&
moveData[MoveData::TARGET]!=PBTargets::UserSide moveData.target != PBTargets::UserSide
# [one target physical, one target special, user status, # [one target physical, one target special, user status,
# multiple targets physical, multiple targets special, non-user status] # multiple targets physical, multiple targets special, non-user status]
typeDefaultAnim = { typeDefaultAnim = {
:NORMAL => [:TACKLE,:SONICBOOM,:DEFENSECURL,:EXPLOSION,:SWIFT,:TAILWHIP], :NORMAL => [:TACKLE, :SONICBOOM, :DEFENSECURL, :EXPLOSION, :SWIFT, :TAILWHIP],
:FIGHTING => [:MACHPUNCH,:AURASPHERE,:DETECT,nil,nil,nil], :FIGHTING => [:MACHPUNCH, :AURASPHERE, :DETECT, nil, nil, nil],
:FLYING => [:WINGATTACK,:GUST,:ROOST,nil,:AIRCUTTER,:FEATHERDANCE], :FLYING => [:WINGATTACK, :GUST, :ROOST, nil, :AIRCUTTER, :FEATHERDANCE],
:POISON => [:POISONSTING,:SLUDGE,:ACIDARMOR,nil,:ACID,:POISONPOWDER], :POISON => [:POISONSTING, :SLUDGE, :ACIDARMOR, nil, :ACID, :POISONPOWDER],
:GROUND => [:SANDTOMB,:MUDSLAP,nil,:EARTHQUAKE,:EARTHPOWER,:MUDSPORT], :GROUND => [:SANDTOMB, :MUDSLAP, nil, :EARTHQUAKE, :EARTHPOWER, :MUDSPORT],
:ROCK => [:ROCKTHROW,:POWERGEM,:ROCKPOLISH,:ROCKSLIDE,nil,:SANDSTORM], :ROCK => [:ROCKTHROW, :POWERGEM, :ROCKPOLISH, :ROCKSLIDE, nil, :SANDSTORM],
:BUG => [:TWINEEDLE,:BUGBUZZ,:QUIVERDANCE,nil,:STRUGGLEBUG,:STRINGSHOT], :BUG => [:TWINEEDLE, :BUGBUZZ, :QUIVERDANCE, nil, :STRUGGLEBUG, :STRINGSHOT],
:GHOST => [:LICK,:SHADOWBALL,:GRUDGE,nil,nil,:CONFUSERAY], :GHOST => [:LICK, :SHADOWBALL, :GRUDGE, nil, nil, :CONFUSERAY],
:STEEL => [:IRONHEAD,:MIRRORSHOT,:IRONDEFENSE,nil,nil,:METALSOUND], :STEEL => [:IRONHEAD, :MIRRORSHOT, :IRONDEFENSE, nil, nil, :METALSOUND],
:FIRE => [:FIREPUNCH,:EMBER,:SUNNYDAY,nil,:INCINERATE,:WILLOWISP], :FIRE => [:FIREPUNCH, :EMBER, :SUNNYDAY, nil, :INCINERATE, :WILLOWISP],
:WATER => [:CRABHAMMER,:WATERGUN,:AQUARING,nil,:SURF,:WATERSPORT], :WATER => [:CRABHAMMER, :WATERGUN, :AQUARING, nil, :SURF, :WATERSPORT],
:GRASS => [:VINEWHIP,:MEGADRAIN,:COTTONGUARD,:RAZORLEAF,nil,:SPORE], :GRASS => [:VINEWHIP, :MEGADRAIN, :COTTONGUARD, :RAZORLEAF, nil, :SPORE],
:ELECTRIC => [:THUNDERPUNCH,:THUNDERSHOCK,:CHARGE,nil,:DISCHARGE,:THUNDERWAVE], :ELECTRIC => [:THUNDERPUNCH, :THUNDERSHOCK, :CHARGE, nil, :DISCHARGE, :THUNDERWAVE],
:PSYCHIC => [:ZENHEADBUTT,:CONFUSION,:CALMMIND,nil,:SYNCHRONOISE,:MIRACLEEYE], :PSYCHIC => [:ZENHEADBUTT, :CONFUSION, :CALMMIND, nil, :SYNCHRONOISE, :MIRACLEEYE],
:ICE => [:ICEPUNCH,:ICEBEAM,:MIST,nil,:POWDERSNOW,:HAIL], :ICE => [:ICEPUNCH, :ICEBEAM, :MIST, nil, :POWDERSNOW, :HAIL],
:DRAGON => [:DRAGONCLAW,:DRAGONRAGE,:DRAGONDANCE,nil,:TWISTER,nil], :DRAGON => [:DRAGONCLAW, :DRAGONRAGE, :DRAGONDANCE, nil, :TWISTER, nil],
:DARK => [:PURSUIT,:DARKPULSE,:HONECLAWS,nil,:SNARL,:EMBARGO], :DARK => [:PURSUIT, :DARKPULSE, :HONECLAWS, nil, :SNARL, :EMBARGO],
:FAIRY => [:TACKLE,:FAIRYWIND,:MOONLIGHT,nil,:SWIFT,:SWEETKISS] :FAIRY => [:TACKLE, :FAIRYWIND, :MOONLIGHT, nil, :SWIFT, :SWEETKISS]
} }
typeDefaultAnim.each do |type, anims| typeDefaultAnim.each do |type, anims|
next if !isConst?(moveType,PBTypes,type) next if !isConst?(moveType, PBTypes, type)
if anims[moveKind] && hasConst?(PBMoves,anims[moveKind]) if GameData::Move.exists?(anims[moveKind])
anim = pbFindMoveAnimDetails(move2anim,getConst(PBMoves,anims[moveKind]),idxUser) anim = pbFindMoveAnimDetails(move2anim, anims[moveKind], idxUser)
end end
break if anim break if anim
if moveKind>=3 && anims[moveKind-3] && hasConst?(PBMoves,anims[moveKind-3]) if moveKind >= 3 && GameData::Move.exists?(anims[moveKind - 3])
anim = pbFindMoveAnimDetails(move2anim,getConst(PBMoves,anims[moveKind-3]),idxUser) anim = pbFindMoveAnimDetails(move2anim, anims[moveKind - 3], idxUser)
end end
break if anim break if anim
if anims[2] && hasConst?(PBMoves,anims[2]) if GameData::Move.exists?(anims[2])
anim = pbFindMoveAnimDetails(move2anim,getConst(PBMoves,anims[2]),idxUser) anim = pbFindMoveAnimDetails(move2anim, anims[2], idxUser)
end end
break break
end end
return anim if anim return anim if anim
# Default animation for the move's type not found, use Tackle's animation # Default animation for the move's type not found, use Tackle's animation
if hasConst?(PBMoves,:TACKLE) if GameData::Move.exists?(:TACKLE)
return pbFindMoveAnimDetails(move2anim,getConst(PBMoves,:TACKLE),idxUser) return pbFindMoveAnimDetails(move2anim, :TACKLE, idxUser)
end end
rescue rescue
end end
+31 -32
View File
@@ -85,38 +85,37 @@ begin
Quash = 79 Quash = 79
Rage = 80 Rage = 80
RagePowder = 81 # Used along with FollowMe RagePowder = 81 # Used along with FollowMe
Revenge = 82 Rollout = 82
Rollout = 83 Roost = 83
Roost = 84 ShellTrap = 84
ShellTrap = 85 SkyDrop = 85
SkyDrop = 86 SlowStart = 86
SlowStart = 87 SmackDown = 87
SmackDown = 88 Snatch = 88
Snatch = 89 SpikyShield = 89
SpikyShield = 90 Spotlight = 90
Spotlight = 91 Stockpile = 91
Stockpile = 92 StockpileDef = 92
StockpileDef = 93 StockpileSpDef = 93
StockpileSpDef = 94 Substitute = 94
Substitute = 95 Taunt = 95
Taunt = 96 Telekinesis = 96
Telekinesis = 97 ThroatChop = 97
ThroatChop = 98 Torment = 98
Torment = 99 Toxic = 99
Toxic = 100 Transform = 100
Transform = 101 TransformSpecies = 101
TransformSpecies = 102 Trapping = 102 # Trapping move
Trapping = 103 # Trapping move TrappingMove = 103
TrappingMove = 104 TrappingUser = 104
TrappingUser = 105 Truant = 105
Truant = 106 TwoTurnAttack = 106
TwoTurnAttack = 107 Type3 = 107
Type3 = 108 Unburden = 108
Unburden = 109 Uproar = 109
Uproar = 110 WaterSport = 110
WaterSport = 111 WeightChange = 111
WeightChange = 112 Yawn = 112
Yawn = 113
#=========================================================================== #===========================================================================
# These effects apply to a battler position # These effects apply to a battler position
@@ -78,15 +78,15 @@ class PokeBattle_BattlePalace < PokeBattle_Battle
def pbCanChooseMovePartial?(idxPokemon,idxMove) def pbCanChooseMovePartial?(idxPokemon,idxMove)
thispkmn = @battlers[idxPokemon] thispkmn = @battlers[idxPokemon]
thismove = thispkmn.moves[idxMove] thismove = thispkmn.moves[idxMove]
return false if !thismove || thismove.id==0 return false if !thismove
return false if thismove.pp<=0 return false if thismove.pp<=0
if thispkmn.effects[PBEffects::ChoiceBand]>=0 && if thispkmn.effects[PBEffects::ChoiceBand] &&
thismove.id!=thispkmn.effects[PBEffects::ChoiceBand] && thismove.id!=thispkmn.effects[PBEffects::ChoiceBand] &&
thispkmn.hasActiveItem?(:CHOICEBAND) thispkmn.hasActiveItem?(:CHOICEBAND)
return false return false
end end
# though incorrect, just for convenience (actually checks Torment later) # though incorrect, just for convenience (actually checks Torment later)
if thispkmn.effects[PBEffects::Torment] if thispkmn.effects[PBEffects::Torment] && thispkmn.lastMoveUsed
return false if thismove.id==thispkmn.lastMoveUsed return false if thismove.id==thispkmn.lastMoveUsed
end end
return true return true
@@ -135,28 +135,28 @@ class PokeBattle_BattlePalace < PokeBattle_Battle
end end
def pbRegisterMove(idxBattler,idxMove,_showMessages=true) def pbRegisterMove(idxBattler,idxMove,_showMessages=true)
thispkmn = @battlers[idxBattler] this_battler = @battlers[idxBattler]
if idxMove==-2 if idxMove==-2
@choices[idxPokemon][0] = :UseMove # Move @choices[idxBattler][0] = :UseMove # Move
@choices[idxPokemon][1] = -2 # "Incapable of using its power..." @choices[idxBattler][1] = -2 # "Incapable of using its power..."
@choices[idxPokemon][2] = @struggle @choices[idxBattler][2] = @struggle
@choices[idxPokemon][3] = -1 @choices[idxBattler][3] = -1
else else
@choices[idxPokemon][0] = :UseMove # Move @choices[idxBattler][0] = :UseMove # Move
@choices[idxPokemon][1] = idxMove # Index of move @choices[idxBattler][1] = idxMove # Index of move
@choices[idxPokemon][2] = thispkmn.moves[idxMove] # Move object @choices[idxBattler][2] = this_battler.moves[idxMove] # Move object
@choices[idxPokemon][3] = -1 # No target chosen @choices[idxBattler][3] = -1 # No target chosen
end end
end end
def pbAutoFightMenu(idxBattler) def pbAutoFightMenu(idxBattler)
thispkmn = @battlers[idxBattler] this_battler = @battlers[idxBattler]
nature = thispkmn.nature nature = this_battler.nature
randnum = @battleAI.pbAIRandom(100) randnum = @battleAI.pbAIRandom(100)
category = 0 category = 0
atkpercent = 0 atkpercent = 0
defpercent = 0 defpercent = 0
if thispkmn.effects[PBEffects::Pinch] if this_battler.effects[PBEffects::Pinch]
atkpercent = @@BattlePalacePinchTable[nature*3] atkpercent = @@BattlePalacePinchTable[nature*3]
defpercent = atkpercent+@@BattlePalacePinchTable[nature*3+1] defpercent = atkpercent+@@BattlePalacePinchTable[nature*3+1]
else else
@@ -171,9 +171,9 @@ class PokeBattle_BattlePalace < PokeBattle_Battle
category = 2 category = 2
end end
moves = [] moves = []
for i in 0...thispkmn.moves.length for i in 0...this_battler.moves.length
next if !pbCanChooseMovePartial?(idxBattler,i) next if !pbCanChooseMovePartial?(idxBattler,i)
next if pbMoveCategory(thispkmn.moves[i])!=category next if pbMoveCategory(this_battler.moves[i])!=category
moves[moves.length] = i moves[moves.length] = i
end end
if moves.length==0 if moves.length==0
@@ -1080,7 +1080,8 @@ BattleHandlers::DamageCalcUserAbility.add(:SWARM,
BattleHandlers::DamageCalcUserAbility.add(:TECHNICIAN, BattleHandlers::DamageCalcUserAbility.add(:TECHNICIAN,
proc { |ability,user,target,move,mults,baseDmg,type| proc { |ability,user,target,move,mults,baseDmg,type|
if user.index!=target.index && move.id>0 && baseDmg*mults[BASE_DMG_MULT]<=60 if user.index!=target.index && move && move.id != :STRUGGLE &&
baseDmg*mults[BASE_DMG_MULT]<=60
mults[BASE_DMG_MULT] *= 1.5 mults[BASE_DMG_MULT] *= 1.5
end end
} }
@@ -1358,7 +1359,7 @@ BattleHandlers::TargetAbilityOnHit.add(:CURSEDBODY,
regularMove = m regularMove = m
break break
end end
next if !regularMove || (regularMove.pp==0 && regularMove.totalpp>0) next if !regularMove || (regularMove.pp==0 && regularMove.total_pp>0)
next if battle.pbRandom(100)>=30 next if battle.pbRandom(100)>=30
battle.pbShowAbilitySplash(target) battle.pbShowAbilitySplash(target)
if !move.pbMoveFailedAromaVeil?(target,user,PokeBattle_SceneConstants::USE_ABILITY_SPLASH) if !move.pbMoveFailedAromaVeil?(target,user,PokeBattle_SceneConstants::USE_ABILITY_SPLASH)
@@ -2098,17 +2099,16 @@ BattleHandlers::AbilityOnSwitchIn.add(:ANTICIPATION,
battle.eachOtherSideBattler(battler.index) do |b| battle.eachOtherSideBattler(battler.index) do |b|
b.eachMove do |m| b.eachMove do |m|
next if m.statusMove? next if m.statusMove?
moveData = pbGetMoveData(m.id)
if type1 if type1
moveType = moveData[MoveData::TYPE] moveType = m.type
if NEWEST_BATTLE_MECHANICS && isConst?(m.id,PBMoves,:HIDDENPOWER) if NEWEST_BATTLE_MECHANICS && m.function == "090" # Hidden Power
moveType = pbHiddenPower(b.pokemon)[0] moveType = pbHiddenPower(b.pokemon)[0]
end end
eff = PBTypes.getCombinedEffectiveness(moveType,type1,type2,type3) eff = PBTypes.getCombinedEffectiveness(moveType,type1,type2,type3)
next if PBTypes.ineffective?(eff) next if PBTypes.ineffective?(eff)
next if !PBTypes.superEffective?(eff) && moveData[MoveData::FUNCTION_CODE]!="070" # OHKO next if !PBTypes.superEffective?(eff) && m.function != "070" # OHKO
else else
next if moveData[MoveData::FUNCTION_CODE]!="070" # OHKO next if m.function != "070" # OHKO
end end
found = true found = true
break break
@@ -2207,33 +2207,32 @@ BattleHandlers::AbilityOnSwitchIn.add(:FOREWARN,
forewarnMoves = [] forewarnMoves = []
battle.eachOtherSideBattler(battler.index) do |b| battle.eachOtherSideBattler(battler.index) do |b|
b.eachMove do |m| b.eachMove do |m|
moveData = pbGetMoveData(m.id) power = m.baseDamage
power = moveData[MoveData::BASE_DAMAGE] power = 160 if ["070"].include?(m.function) # OHKO
power = 160 if ["070"].include?(moveData[MoveData::FUNCTION_CODE]) # OHKO power = 150 if ["08B"].include?(m.function) # Eruption
power = 150 if ["08B"].include?(moveData[MoveData::FUNCTION_CODE]) # Eruption
# Counter, Mirror Coat, Metal Burst # Counter, Mirror Coat, Metal Burst
power = 120 if ["071","072","073"].include?(moveData[MoveData::FUNCTION_CODE]) power = 120 if ["071","072","073"].include?(m.function)
# Sonic Boom, Dragon Rage, Night Shade, Endeavor, Psywave, # Sonic Boom, Dragon Rage, Night Shade, Endeavor, Psywave,
# Return, Frustration, Crush Grip, Gyro Ball, Hidden Power, # Return, Frustration, Crush Grip, Gyro Ball, Hidden Power,
# Natural Gift, Trump Card, Flail, Grass Knot # Natural Gift, Trump Card, Flail, Grass Knot
power = 80 if ["06A","06B","06D","06E","06F", power = 80 if ["06A","06B","06D","06E","06F",
"089","08A","08C","08D","090", "089","08A","08C","08D","090",
"096","097","098","09A"].include?(moveData[MoveData::FUNCTION_CODE]) "096","097","098","09A"].include?(m.function)
next if power<highestPower next if power<highestPower
forewarnMoves = [] if power>highestPower forewarnMoves = [] if power>highestPower
forewarnMoves.push(m.id) forewarnMoves.push(m.name)
highestPower = power highestPower = power
end end
end end
if forewarnMoves.length>0 if forewarnMoves.length>0
battle.pbShowAbilitySplash(battler) battle.pbShowAbilitySplash(battler)
forewarnMoveID = forewarnMoves[battle.pbRandom(forewarnMoves.length)] forewarnMoveName = forewarnMoves[battle.pbRandom(forewarnMoves.length)]
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
battle.pbDisplay(_INTL("{1} was alerted to {2}!", battle.pbDisplay(_INTL("{1} was alerted to {2}!",
battler.pbThis,PBMoves.getName(forewarnMoveID))) battler.pbThis, forewarnMoveName))
else else
battle.pbDisplay(_INTL("{1}'s Forewarn alerted it to {2}!", battle.pbDisplay(_INTL("{1}'s Forewarn alerted it to {2}!",
battler.pbThis,PBMoves.getName(forewarnMoveID))) battler.pbThis, forewarnMoveName))
end end
battle.pbHideAbilitySplash(battler) battle.pbHideAbilitySplash(battler)
end end
@@ -2285,7 +2284,7 @@ BattleHandlers::AbilityOnSwitchIn.add(:IMPOSTER,
choice.semiInvulnerable? choice.semiInvulnerable?
battle.pbShowAbilitySplash(battler,true) battle.pbShowAbilitySplash(battler,true)
battle.pbHideAbilitySplash(battler) battle.pbHideAbilitySplash(battler)
battle.pbAnimation(getConst(PBMoves,:TRANSFORM),battler,choice) battle.pbAnimation(:TRANSFORM,battler,choice)
battle.scene.pbChangePokemon(battler,choice.pokemon) battle.scene.pbChangePokemon(battler,choice.pokemon)
battler.pbTransform(choice) battler.pbTransform(choice)
} }
@@ -309,7 +309,7 @@ BattleHandlers::StatusCureItem.add(:MENTALHERB,
battler.effects[PBEffects::Taunt] = 0 battler.effects[PBEffects::Taunt] = 0
battle.pbDisplay(_INTL("{1}'s encore ended!",battler.pbThis)) if battler.effects[PBEffects::Encore]>0 battle.pbDisplay(_INTL("{1}'s encore ended!",battler.pbThis)) if battler.effects[PBEffects::Encore]>0
battler.effects[PBEffects::Encore] = 0 battler.effects[PBEffects::Encore] = 0
battler.effects[PBEffects::EncoreMove] = 0 battler.effects[PBEffects::EncoreMove] = nil
battle.pbDisplay(_INTL("{1}'s torment wore off!",battler.pbThis)) if battler.effects[PBEffects::Torment] battle.pbDisplay(_INTL("{1}'s torment wore off!",battler.pbThis)) if battler.effects[PBEffects::Torment]
battler.effects[PBEffects::Torment] = false battler.effects[PBEffects::Torment] = false
battle.pbDisplay(_INTL("{1} is no longer disabled!",battler.pbThis)) if battler.effects[PBEffects::Disable]>0 battle.pbDisplay(_INTL("{1} is no longer disabled!",battler.pbThis)) if battler.effects[PBEffects::Disable]>0
@@ -1288,8 +1288,7 @@ BattleHandlers::EndOfMoveItem.add(:LEPPABERRY,
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index) next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
found = [] found = []
battler.pokemon.moves.each_with_index do |m,i| battler.pokemon.moves.each_with_index do |m,i|
next if !m || m.id==0 next if m.total_pp<=0 || m.pp==m.total_pp
next if m.totalpp<=0 || m.pp==m.totalpp
next if !forced && m.pp>0 next if !forced && m.pp>0
found.push(i) found.push(i)
end end
@@ -1300,9 +1299,9 @@ BattleHandlers::EndOfMoveItem.add(:LEPPABERRY,
choice = found[battle.pbRandom(found.length)] choice = found[battle.pbRandom(found.length)]
pkmnMove = battler.pokemon.moves[choice] pkmnMove = battler.pokemon.moves[choice]
pkmnMove.pp += 10 pkmnMove.pp += 10
pkmnMove.pp = pkmnMove.totalpp if pkmnMove.pp>pkmnMove.totalpp pkmnMove.pp = pkmnMove.total_pp if pkmnMove.pp>pkmnMove.total_pp
battler.moves[choice].pp = pkmnMove.pp battler.moves[choice].pp = pkmnMove.pp
moveName = PBMoves.getName(pkmnMove.id) moveName = pkmnMove.name
if forced if forced
battle.pbDisplay(_INTL("{1} restored its {2}'s PP.",battler.pbThis,moveName)) battle.pbDisplay(_INTL("{1} restored its {2}'s PP.",battler.pbThis,moveName))
else else
@@ -72,7 +72,7 @@ begin
def initialize def initialize
@effects = [] @effects = []
@effects[PBEffects::FutureSightCounter] = 0 @effects[PBEffects::FutureSightCounter] = 0
@effects[PBEffects::FutureSightMove] = 0 @effects[PBEffects::FutureSightMove] = nil
@effects[PBEffects::FutureSightUserIndex] = -1 @effects[PBEffects::FutureSightUserIndex] = -1
@effects[PBEffects::FutureSightUserPartyIndex] = -1 @effects[PBEffects::FutureSightUserPartyIndex] = -1
@effects[PBEffects::HealingWish] = false @effects[PBEffects::HealingWish] = false
@@ -1334,7 +1334,7 @@ def pbItemBall(item,quantity=1)
if item == :LEFTOVERS if item == :LEFTOVERS
pbMessage(_INTL("\\me[{1}]You found some \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname)) pbMessage(_INTL("\\me[{1}]You found some \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
elsif item.is_machine? # TM or HM elsif item.is_machine? # TM or HM
pbMessage(_INTL("\\me[{1}]You found \\c[1]{2} {3}\\c[0]!\\wtnp[30]",meName,itemname,PBMoves.getName(move))) pbMessage(_INTL("\\me[{1}]You found \\c[1]{2} {3}\\c[0]!\\wtnp[30]",meName,itemname,GameData::Move.get(move).name))
elsif quantity>1 elsif quantity>1
pbMessage(_INTL("\\me[{1}]You found {2} \\c[1]{3}\\c[0]!\\wtnp[30]",meName,quantity,itemname)) pbMessage(_INTL("\\me[{1}]You found {2} \\c[1]{3}\\c[0]!\\wtnp[30]",meName,quantity,itemname))
elsif itemname.starts_with_vowel? elsif itemname.starts_with_vowel?
@@ -1350,7 +1350,7 @@ def pbItemBall(item,quantity=1)
if item == :LEFTOVERS if item == :LEFTOVERS
pbMessage(_INTL("You found some \\c[1]{1}\\c[0]!\\wtnp[30]",itemname)) pbMessage(_INTL("You found some \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
elsif item.is_machine? # TM or HM elsif item.is_machine? # TM or HM
pbMessage(_INTL("You found \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,PBMoves.getName(move))) pbMessage(_INTL("You found \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,GameData::Move.get(move).name))
elsif quantity>1 elsif quantity>1
pbMessage(_INTL("You found {1} \\c[1]{2}\\c[0]!\\wtnp[30]",quantity,itemname)) pbMessage(_INTL("You found {1} \\c[1]{2}\\c[0]!\\wtnp[30]",quantity,itemname))
elsif itemname.starts_with_vowel? elsif itemname.starts_with_vowel?
@@ -1377,7 +1377,7 @@ def pbReceiveItem(item,quantity=1)
if item == :LEFTOVERS if item == :LEFTOVERS
pbMessage(_INTL("\\me[{1}]You obtained some \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname)) pbMessage(_INTL("\\me[{1}]You obtained some \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
elsif item.is_machine? # TM or HM elsif item.is_machine? # TM or HM
pbMessage(_INTL("\\me[{1}]You obtained \\c[1]{2} {3}\\c[0]!\\wtnp[30]",meName,itemname,PBMoves.getName(move))) pbMessage(_INTL("\\me[{1}]You obtained \\c[1]{2} {3}\\c[0]!\\wtnp[30]",meName,itemname,GameData::Move.get(move).name))
elsif quantity>1 elsif quantity>1
pbMessage(_INTL("\\me[{1}]You obtained {2} \\c[1]{3}\\c[0]!\\wtnp[30]",meName,quantity,itemname)) pbMessage(_INTL("\\me[{1}]You obtained {2} \\c[1]{3}\\c[0]!\\wtnp[30]",meName,quantity,itemname))
elsif itemname.starts_with_vowel? elsif itemname.starts_with_vowel?
@@ -1,14 +1,6 @@
#=============================================================================== #===============================================================================
# Hidden move handlers # Hidden move handlers
#=============================================================================== #===============================================================================
class MoveHandlerHash < HandlerHash
def initialize
super(:PBMoves)
end
end
module HiddenMoveHandlers module HiddenMoveHandlers
CanUseMove = MoveHandlerHash.new CanUseMove = MoveHandlerHash.new
ConfirmUseMove = MoveHandlerHash.new ConfirmUseMove = MoveHandlerHash.new
@@ -194,7 +186,7 @@ end
# Cut # Cut
#=============================================================================== #===============================================================================
def pbCut def pbCut
move = getID(PBMoves,:CUT) move = :CUT
movefinder = pbCheckMove(move) movefinder = pbCheckMove(move)
if !pbCheckHiddenMoveBadge(BADGE_FOR_CUT,false) || (!$DEBUG && !movefinder) if !pbCheckHiddenMoveBadge(BADGE_FOR_CUT,false) || (!$DEBUG && !movefinder)
pbMessage(_INTL("This tree looks like it can be cut down.")) pbMessage(_INTL("This tree looks like it can be cut down."))
@@ -203,7 +195,7 @@ def pbCut
pbMessage(_INTL("This tree looks like it can be cut down!\1")) pbMessage(_INTL("This tree looks like it can be cut down!\1"))
if pbConfirmMessage(_INTL("Would you like to cut it?")) if pbConfirmMessage(_INTL("Would you like to cut it?"))
speciesname = (movefinder) ? movefinder.name : $Trainer.name speciesname = (movefinder) ? movefinder.name : $Trainer.name
pbMessage(_INTL("{1} used {2}!",speciesname,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",speciesname,GameData::Move.get(move).name))
pbHiddenMoveAnimation(movefinder) pbHiddenMoveAnimation(movefinder)
return true return true
end end
@@ -222,7 +214,7 @@ HiddenMoveHandlers::CanUseMove.add(:CUT,proc { |move,pkmn,showmsg|
HiddenMoveHandlers::UseMove.add(:CUT,proc { |move,pokemon| HiddenMoveHandlers::UseMove.add(:CUT,proc { |move,pokemon|
if !pbHiddenMoveAnimation(pokemon) if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name))
end end
facingEvent = $game_player.pbFacingEvent facingEvent = $game_player.pbFacingEvent
if facingEvent if facingEvent
@@ -279,7 +271,7 @@ HiddenMoveHandlers::UseMove.add(:DIG,proc { |move,pokemon|
escape = ($PokemonGlobal.escapePoint rescue nil) escape = ($PokemonGlobal.escapePoint rescue nil)
if escape if escape
if !pbHiddenMoveAnimation(pokemon) if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name))
end end
pbFadeOutIn { pbFadeOutIn {
$game_temp.player_new_map_id = escape[0] $game_temp.player_new_map_id = escape[0]
@@ -304,7 +296,7 @@ HiddenMoveHandlers::UseMove.add(:DIG,proc { |move,pokemon|
def pbDive def pbDive
divemap = GameData::MapMetadata.get($game_map.map_id).dive_map_id divemap = GameData::MapMetadata.get($game_map.map_id).dive_map_id
return false if !divemap return false if !divemap
move = getID(PBMoves,:DIVE) move = :DIVE
movefinder = pbCheckMove(move) movefinder = pbCheckMove(move)
if !pbCheckHiddenMoveBadge(BADGE_FOR_DIVE,false) || (!$DEBUG && !movefinder) if !pbCheckHiddenMoveBadge(BADGE_FOR_DIVE,false) || (!$DEBUG && !movefinder)
pbMessage(_INTL("The sea is deep here. A Pokémon may be able to go underwater.")) pbMessage(_INTL("The sea is deep here. A Pokémon may be able to go underwater."))
@@ -312,7 +304,7 @@ def pbDive
end end
if pbConfirmMessage(_INTL("The sea is deep here. Would you like to use Dive?")) if pbConfirmMessage(_INTL("The sea is deep here. Would you like to use Dive?"))
speciesname = (movefinder) ? movefinder.name : $Trainer.name speciesname = (movefinder) ? movefinder.name : $Trainer.name
pbMessage(_INTL("{1} used {2}!",speciesname,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",speciesname,GameData::Move.get(move).name))
pbHiddenMoveAnimation(movefinder) pbHiddenMoveAnimation(movefinder)
pbFadeOutIn { pbFadeOutIn {
$game_temp.player_new_map_id = divemap $game_temp.player_new_map_id = divemap
@@ -340,7 +332,7 @@ def pbSurfacing
break break
end end
return if !surface_map_id return if !surface_map_id
move = getID(PBMoves,:DIVE) move = :DIVE
movefinder = pbCheckMove(move) movefinder = pbCheckMove(move)
if !pbCheckHiddenMoveBadge(BADGE_FOR_DIVE,false) || (!$DEBUG && !movefinder) if !pbCheckHiddenMoveBadge(BADGE_FOR_DIVE,false) || (!$DEBUG && !movefinder)
pbMessage(_INTL("Light is filtering down from above. A Pokémon may be able to surface here.")) pbMessage(_INTL("Light is filtering down from above. A Pokémon may be able to surface here."))
@@ -348,7 +340,7 @@ def pbSurfacing
end end
if pbConfirmMessage(_INTL("Light is filtering down from above. Would you like to use Dive?")) if pbConfirmMessage(_INTL("Light is filtering down from above. Would you like to use Dive?"))
speciesname = (movefinder) ? movefinder.name : $Trainer.name speciesname = (movefinder) ? movefinder.name : $Trainer.name
pbMessage(_INTL("{1} used {2}!",speciesname,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",speciesname,GameData::Move.get(move).name))
pbHiddenMoveAnimation(movefinder) pbHiddenMoveAnimation(movefinder)
pbFadeOutIn { pbFadeOutIn {
$game_temp.player_new_map_id = surface_map_id $game_temp.player_new_map_id = surface_map_id
@@ -443,7 +435,7 @@ HiddenMoveHandlers::UseMove.add(:DIVE,proc { |move,pokemon|
end end
next false if !dive_map_id next false if !dive_map_id
if !pbHiddenMoveAnimation(pokemon) if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name))
end end
pbFadeOutIn { pbFadeOutIn {
$game_temp.player_new_map_id = dive_map_id $game_temp.player_new_map_id = dive_map_id
@@ -482,7 +474,7 @@ HiddenMoveHandlers::UseMove.add(:FLASH,proc { |move,pokemon|
darkness = $PokemonTemp.darknessSprite darkness = $PokemonTemp.darknessSprite
next false if !darkness || darkness.disposed? next false if !darkness || darkness.disposed?
if !pbHiddenMoveAnimation(pokemon) if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name))
end end
$PokemonGlobal.flashUsed = true $PokemonGlobal.flashUsed = true
radiusDiff = 8*20/Graphics.frame_rate radiusDiff = 8*20/Graphics.frame_rate
@@ -520,7 +512,7 @@ HiddenMoveHandlers::UseMove.add(:FLY,proc { |move,pokemon|
next false next false
end end
if !pbHiddenMoveAnimation(pokemon) if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name))
end end
pbFadeOutIn { pbFadeOutIn {
$game_temp.player_new_map_id = $PokemonTemp.flydata[0] $game_temp.player_new_map_id = $PokemonTemp.flydata[0]
@@ -562,7 +554,7 @@ def pbHeadbuttEffect(event=nil)
end end
def pbHeadbutt(event=nil) def pbHeadbutt(event=nil)
move = getID(PBMoves,:HEADBUTT) move = :HEADBUTT
movefinder = pbCheckMove(move) movefinder = pbCheckMove(move)
if !$DEBUG && !movefinder if !$DEBUG && !movefinder
pbMessage(_INTL("A Pokémon could be in this tree. Maybe a Pokémon could shake it.")) pbMessage(_INTL("A Pokémon could be in this tree. Maybe a Pokémon could shake it."))
@@ -570,7 +562,7 @@ def pbHeadbutt(event=nil)
end end
if pbConfirmMessage(_INTL("A Pokémon could be in this tree. Would you like to use Headbutt?")) if pbConfirmMessage(_INTL("A Pokémon could be in this tree. Would you like to use Headbutt?"))
speciesname = (movefinder) ? movefinder.name : $Trainer.name speciesname = (movefinder) ? movefinder.name : $Trainer.name
pbMessage(_INTL("{1} used {2}!",speciesname,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",speciesname,GameData::Move.get(move).name))
pbHiddenMoveAnimation(movefinder) pbHiddenMoveAnimation(movefinder)
pbHeadbuttEffect(event) pbHeadbuttEffect(event)
return true return true
@@ -589,7 +581,7 @@ HiddenMoveHandlers::CanUseMove.add(:HEADBUTT,proc { |move,pkmn,showmsg|
HiddenMoveHandlers::UseMove.add(:HEADBUTT,proc { |move,pokemon| HiddenMoveHandlers::UseMove.add(:HEADBUTT,proc { |move,pokemon|
if !pbHiddenMoveAnimation(pokemon) if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name))
end end
facingEvent = $game_player.pbFacingEvent facingEvent = $game_player.pbFacingEvent
pbHeadbuttEffect(facingEvent) pbHeadbuttEffect(facingEvent)
@@ -607,7 +599,7 @@ def pbRockSmashRandomEncounter
end end
def pbRockSmash def pbRockSmash
move = getID(PBMoves,:ROCKSMASH) move = :ROCKSMASH
movefinder = pbCheckMove(move) movefinder = pbCheckMove(move)
if !pbCheckHiddenMoveBadge(BADGE_FOR_ROCKSMASH,false) || (!$DEBUG && !movefinder) if !pbCheckHiddenMoveBadge(BADGE_FOR_ROCKSMASH,false) || (!$DEBUG && !movefinder)
pbMessage(_INTL("It's a rugged rock, but a Pokémon may be able to smash it.")) pbMessage(_INTL("It's a rugged rock, but a Pokémon may be able to smash it."))
@@ -615,7 +607,7 @@ def pbRockSmash
end end
if pbConfirmMessage(_INTL("This rock appears to be breakable. Would you like to use Rock Smash?")) if pbConfirmMessage(_INTL("This rock appears to be breakable. Would you like to use Rock Smash?"))
speciesname = (movefinder) ? movefinder.name : $Trainer.name speciesname = (movefinder) ? movefinder.name : $Trainer.name
pbMessage(_INTL("{1} used {2}!",speciesname,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",speciesname,GameData::Move.get(move).name))
pbHiddenMoveAnimation(movefinder) pbHiddenMoveAnimation(movefinder)
return true return true
end end
@@ -634,7 +626,7 @@ HiddenMoveHandlers::CanUseMove.add(:ROCKSMASH,proc { |move,pkmn,showmsg|
HiddenMoveHandlers::UseMove.add(:ROCKSMASH,proc { |move,pokemon| HiddenMoveHandlers::UseMove.add(:ROCKSMASH,proc { |move,pokemon|
if !pbHiddenMoveAnimation(pokemon) if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name))
end end
facingEvent = $game_player.pbFacingEvent facingEvent = $game_player.pbFacingEvent
if facingEvent if facingEvent
@@ -654,7 +646,7 @@ def pbStrength
pbMessage(_INTL("Strength made it possible to move boulders around.")) pbMessage(_INTL("Strength made it possible to move boulders around."))
return false return false
end end
move = getID(PBMoves,:STRENGTH) move = :STRENGTH
movefinder = pbCheckMove(move) movefinder = pbCheckMove(move)
if !pbCheckHiddenMoveBadge(BADGE_FOR_STRENGTH,false) || (!$DEBUG && !movefinder) if !pbCheckHiddenMoveBadge(BADGE_FOR_STRENGTH,false) || (!$DEBUG && !movefinder)
pbMessage(_INTL("It's a big boulder, but a Pokémon may be able to push it aside.")) pbMessage(_INTL("It's a big boulder, but a Pokémon may be able to push it aside."))
@@ -663,7 +655,7 @@ def pbStrength
pbMessage(_INTL("It's a big boulder, but a Pokémon may be able to push it aside.\1")) pbMessage(_INTL("It's a big boulder, but a Pokémon may be able to push it aside.\1"))
if pbConfirmMessage(_INTL("Would you like to use Strength?")) if pbConfirmMessage(_INTL("Would you like to use Strength?"))
speciesname = (movefinder) ? movefinder.name : $Trainer.name speciesname = (movefinder) ? movefinder.name : $Trainer.name
pbMessage(_INTL("{1} used {2}!",speciesname,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",speciesname,GameData::Move.get(move).name))
pbHiddenMoveAnimation(movefinder) pbHiddenMoveAnimation(movefinder)
pbMessage(_INTL("{1}'s Strength made it possible to move boulders around!",speciesname)) pbMessage(_INTL("{1}'s Strength made it possible to move boulders around!",speciesname))
$PokemonMap.strengthUsed = true $PokemonMap.strengthUsed = true
@@ -688,7 +680,7 @@ HiddenMoveHandlers::CanUseMove.add(:STRENGTH,proc { |move,pkmn,showmsg|
HiddenMoveHandlers::UseMove.add(:STRENGTH,proc { |move,pokemon| HiddenMoveHandlers::UseMove.add(:STRENGTH,proc { |move,pokemon|
if !pbHiddenMoveAnimation(pokemon) if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!\1",pokemon.name,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!\1",pokemon.name,GameData::Move.get(move).name))
end end
pbMessage(_INTL("{1}'s Strength made it possible to move boulders around!",pokemon.name)) pbMessage(_INTL("{1}'s Strength made it possible to move boulders around!",pokemon.name))
$PokemonMap.strengthUsed = true $PokemonMap.strengthUsed = true
@@ -703,14 +695,14 @@ HiddenMoveHandlers::UseMove.add(:STRENGTH,proc { |move,pokemon|
def pbSurf def pbSurf
return false if $game_player.pbFacingEvent return false if $game_player.pbFacingEvent
return false if $game_player.pbHasDependentEvents? return false if $game_player.pbHasDependentEvents?
move = getID(PBMoves,:SURF) move = :SURF
movefinder = pbCheckMove(move) movefinder = pbCheckMove(move)
if !pbCheckHiddenMoveBadge(BADGE_FOR_SURF,false) || (!$DEBUG && !movefinder) if !pbCheckHiddenMoveBadge(BADGE_FOR_SURF,false) || (!$DEBUG && !movefinder)
return false return false
end end
if pbConfirmMessage(_INTL("The water is a deep blue...\nWould you like to surf on it?")) if pbConfirmMessage(_INTL("The water is a deep blue...\nWould you like to surf on it?"))
speciesname = (movefinder) ? movefinder.name : $Trainer.name speciesname = (movefinder) ? movefinder.name : $Trainer.name
pbMessage(_INTL("{1} used {2}!",speciesname,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",speciesname,GameData::Move.get(move).name))
pbCancelVehicles pbCancelVehicles
pbHiddenMoveAnimation(movefinder) pbHiddenMoveAnimation(movefinder)
surfbgm = GameData::Metadata.get.surf_BGM surfbgm = GameData::Metadata.get.surf_BGM
@@ -798,7 +790,7 @@ HiddenMoveHandlers::UseMove.add(:SURF,proc { |move,pokemon|
$game_temp.in_menu = false $game_temp.in_menu = false
pbCancelVehicles pbCancelVehicles
if !pbHiddenMoveAnimation(pokemon) if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name))
end end
surfbgm = GameData::Metadata.get.surf_BGM surfbgm = GameData::Metadata.get.surf_BGM
pbCueBGM(surfbgm,0.5) if surfbgm pbCueBGM(surfbgm,0.5) if surfbgm
@@ -851,7 +843,7 @@ HiddenMoveHandlers::CanUseMove.add(:SWEETSCENT,proc { |move,pkmn,showmsg|
HiddenMoveHandlers::UseMove.add(:SWEETSCENT,proc { |move,pokemon| HiddenMoveHandlers::UseMove.add(:SWEETSCENT,proc { |move,pokemon|
if !pbHiddenMoveAnimation(pokemon) if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name))
end end
pbSweetScent pbSweetScent
next true next true
@@ -893,7 +885,7 @@ HiddenMoveHandlers::UseMove.add(:TELEPORT,proc { |move,pokemon|
healing = GameData::Metadata.get.home if !healing # Home healing = GameData::Metadata.get.home if !healing # Home
next false if !healing next false if !healing
if !pbHiddenMoveAnimation(pokemon) if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name))
end end
pbFadeOutIn { pbFadeOutIn {
$game_temp.player_new_map_id = healing[0] $game_temp.player_new_map_id = healing[0]
@@ -952,7 +944,7 @@ def pbDescendWaterfall(event=nil)
end end
def pbWaterfall def pbWaterfall
move = getID(PBMoves,:WATERFALL) move = :WATERFALL
movefinder = pbCheckMove(move) movefinder = pbCheckMove(move)
if !pbCheckHiddenMoveBadge(BADGE_FOR_WATERFALL,false) || (!$DEBUG && !movefinder) if !pbCheckHiddenMoveBadge(BADGE_FOR_WATERFALL,false) || (!$DEBUG && !movefinder)
pbMessage(_INTL("A wall of water is crashing down with a mighty roar.")) pbMessage(_INTL("A wall of water is crashing down with a mighty roar."))
@@ -960,7 +952,7 @@ def pbWaterfall
end end
if pbConfirmMessage(_INTL("It's a large waterfall. Would you like to use Waterfall?")) if pbConfirmMessage(_INTL("It's a large waterfall. Would you like to use Waterfall?"))
speciesname = (movefinder) ? movefinder.name : $Trainer.name speciesname = (movefinder) ? movefinder.name : $Trainer.name
pbMessage(_INTL("{1} used {2}!",speciesname,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",speciesname,GameData::Move.get(move).name))
pbHiddenMoveAnimation(movefinder) pbHiddenMoveAnimation(movefinder)
pbAscendWaterfall pbAscendWaterfall
return true return true
@@ -988,7 +980,7 @@ HiddenMoveHandlers::CanUseMove.add(:WATERFALL,proc { |move,pkmn,showmsg|
HiddenMoveHandlers::UseMove.add(:WATERFALL,proc { |move,pokemon| HiddenMoveHandlers::UseMove.add(:WATERFALL,proc { |move,pokemon|
if !pbHiddenMoveAnimation(pokemon) if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move))) pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name))
end end
pbAscendWaterfall pbAscendWaterfall
next true next true
@@ -286,20 +286,18 @@ def pbDayCareGenerateEgg
mother.hasItem?(:LIGHTBALL) mother.hasItem?(:LIGHTBALL)
lightball = true lightball = true
end end
if lightball && isConst?(babyspecies,PBSpecies,:PICHU) && if lightball && isConst?(babyspecies,PBSpecies,:PICHU) && GameData::Move.exists?(:VOLTTACKLE)
hasConst?(PBMoves,:VOLTTACKLE) moves.push(:VOLTTACKLE)
moves.push(getConst(PBMoves,:VOLTTACKLE))
end end
moves = moves.reverse moves = moves.reverse
moves |= [] # remove duplicates moves |= [] # remove duplicates
moves = moves.reverse moves = moves.reverse
# Assembling move list # Assembling move list
first_move_index = moves.length - Pokemon::MAX_MOVES
first_move_index = 0 if first_move_index < 0
finalmoves = [] finalmoves = []
listend = moves.length-4 for i in first_move_index...moves.length
listend = 0 if listend<0 finalmoves.push(PBMove.new(moves[i]))
for i in listend...listend+4
moveid = (i>=moves.length) ? 0 : moves[i]
finalmoves[finalmoves.length] = PBMove.new(moveid)
end end
# Inheriting Individual Values # Inheriting Individual Values
ivs = [] ivs = []
@@ -386,10 +384,7 @@ def pbDayCareGenerateEgg
egg.iv[3] = ivs[3] egg.iv[3] = ivs[3]
egg.iv[4] = ivs[4] egg.iv[4] = ivs[4]
egg.iv[5] = ivs[5] egg.iv[5] = ivs[5]
egg.moves[0] = finalmoves[0] egg.moves = finalmoves
egg.moves[1] = finalmoves[1]
egg.moves[2] = finalmoves[2]
egg.moves[3] = finalmoves[3]
egg.calcStats egg.calcStats
egg.obtainText = _INTL("Day-Care Couple") egg.obtainText = _INTL("Day-Care Couple")
egg.name = _INTL("Egg") egg.name = _INTL("Egg")
@@ -24,7 +24,7 @@ module TrainerData
:Item, :Item, :Item, :Item], :Item, :Item, :Item, :Item],
"Pokemon" => [SPECIES, "ev", :PBSpecies, nil], # Species, level "Pokemon" => [SPECIES, "ev", :PBSpecies, nil], # Species, level
"Item" => [ITEM, "e", :Item], "Item" => [ITEM, "e", :Item],
"Moves" => [MOVES, "eEEE", :PBMoves, :PBMoves, :PBMoves, :PBMoves], "Moves" => [MOVES, "eEEE", :Move, :Move, :Move, :Move],
"Ability" => [ABILITY, "u"], "Ability" => [ABILITY, "u"],
"Gender" => [GENDER, "e", { "M" => 0, "m" => 0, "Male" => 0, "male" => 0, "0" => 0, "Gender" => [GENDER, "e", { "M" => 0, "m" => 0, "Male" => 0, "male" => 0, "0" => 0,
"F" => 1, "f" => 1, "Female" => 1, "female" => 1, "1" => 1 }], "F" => 1, "f" => 1, "Female" => 1, "female" => 1, "1" => 1 }],
+10 -9
View File
@@ -246,11 +246,11 @@ end
# Restore PP # Restore PP
#=============================================================================== #===============================================================================
def pbRestorePP(pkmn,idxMove,pp) def pbRestorePP(pkmn,idxMove,pp)
return 0 if !pkmn.moves[idxMove] || pkmn.moves[idxMove].id==0 return 0 if !pkmn.moves[idxMove] || !pkmn.moves[idxMove].id
return 0 if pkmn.moves[idxMove].totalpp<=0 return 0 if pkmn.moves[idxMove].total_pp<=0
oldpp = pkmn.moves[idxMove].pp oldpp = pkmn.moves[idxMove].pp
newpp = pkmn.moves[idxMove].pp+pp newpp = pkmn.moves[idxMove].pp+pp
newpp = pkmn.moves[idxMove].totalpp if newpp>pkmn.moves[idxMove].totalpp newpp = pkmn.moves[idxMove].total_pp if newpp>pkmn.moves[idxMove].total_pp
pkmn.moves[idxMove].pp = newpp pkmn.moves[idxMove].pp = newpp
return newpp-oldpp return newpp-oldpp
end end
@@ -407,7 +407,7 @@ end
#=============================================================================== #===============================================================================
def pbLearnMove(pkmn,move,ignoreifknown=false,bymachine=false,&block) def pbLearnMove(pkmn,move,ignoreifknown=false,bymachine=false,&block)
return false if !pkmn return false if !pkmn
movename = PBMoves.getName(move) move = GameData::Move.get(move).id
if pkmn.egg? && !$DEBUG if pkmn.egg? && !$DEBUG
pbMessage(_INTL("Eggs can't be taught any moves."),&block) pbMessage(_INTL("Eggs can't be taught any moves."),&block)
return false return false
@@ -417,11 +417,12 @@ def pbLearnMove(pkmn,move,ignoreifknown=false,bymachine=false,&block)
return false return false
end end
pkmnname = pkmn.name pkmnname = pkmn.name
movename = GameData::Move.get(move).name
if pkmn.hasMove?(move) if pkmn.hasMove?(move)
pbMessage(_INTL("{1} already knows {2}.",pkmnname,movename),&block) if !ignoreifknown pbMessage(_INTL("{1} already knows {2}.",pkmnname,movename),&block) if !ignoreifknown
return false return false
end end
if pkmn.numMoves<4 if pkmn.numMoves<Pokemon::MAX_MOVES
pkmn.pbLearnMove(move) pkmn.pbLearnMove(move)
pbMessage(_INTL("\\se[]{1} learned {2}!\\se[Pkmn move learnt]",pkmnname,movename),&block) pbMessage(_INTL("\\se[]{1} learned {2}!\\se[Pkmn move learnt]",pkmnname,movename),&block)
return true return true
@@ -431,11 +432,11 @@ def pbLearnMove(pkmn,move,ignoreifknown=false,bymachine=false,&block)
pbMessage(_INTL("Please choose a move that will be replaced with {1}.",movename),&block) pbMessage(_INTL("Please choose a move that will be replaced with {1}.",movename),&block)
forgetmove = pbForgetMove(pkmn,move) forgetmove = pbForgetMove(pkmn,move)
if forgetmove>=0 if forgetmove>=0
oldmovename = PBMoves.getName(pkmn.moves[forgetmove].id) oldmovename = pkmn.moves[forgetmove].name
oldmovepp = pkmn.moves[forgetmove].pp oldmovepp = pkmn.moves[forgetmove].pp
pkmn.moves[forgetmove] = PBMove.new(move) # Replaces current/total PP pkmn.moves[forgetmove] = PBMove.new(move) # Replaces current/total PP
if bymachine && !NEWEST_BATTLE_MECHANICS if bymachine && !NEWEST_BATTLE_MECHANICS
pkmn.moves[forgetmove].pp = [oldmovepp,pkmn.moves[forgetmove].totalpp].min pkmn.moves[forgetmove].pp = [oldmovepp,pkmn.moves[forgetmove].total_pp].min
end end
pbMessage(_INTL("1,\\wt[16] 2, and\\wt[16]...\\wt[16] ...\\wt[16] ... Ta-da!\\se[Battle ball drop]\1"),&block) pbMessage(_INTL("1,\\wt[16] 2, and\\wt[16]...\\wt[16] ...\\wt[16] ... Ta-da!\\se[Battle ball drop]\1"),&block)
pbMessage(_INTL("{1} forgot how to use {2}.\\nAnd...\1",pkmnname,oldmovename),&block) pbMessage(_INTL("{1} forgot how to use {2}.\\nAnd...\1",pkmnname,oldmovename),&block)
@@ -480,7 +481,7 @@ def pbUseItem(bag,item,bagscene=nil)
end end
machine = itm.move machine = itm.move
return 0 if !machine return 0 if !machine
movename = PBMoves.getName(machine) movename = GameData::Move.get(machine).name
pbMessage(_INTL("\\se[PC access]You booted up {1}.\1",itm.name)) pbMessage(_INTL("\\se[PC access]You booted up {1}.\1",itm.name))
if !pbConfirmMessage(_INTL("Do you want to teach {1} to a Pokémon?",movename)) if !pbConfirmMessage(_INTL("Do you want to teach {1} to a Pokémon?",movename))
return 0 return 0
@@ -554,7 +555,7 @@ def pbUseItemOnPokemon(item,pkmn,scene)
if itm.is_machine? if itm.is_machine?
machine = itm.move machine = itm.move
return false if !machine return false if !machine
movename = PBMoves.getName(machine) movename = GameData::Move.get(machine).name
if pkmn.shadowPokemon? if pkmn.shadowPokemon?
pbMessage(_INTL("Shadow Pokémon can't be taught any moves.")) { scene.pbUpdate } pbMessage(_INTL("Shadow Pokémon can't be taught any moves.")) { scene.pbUpdate }
elsif !pkmn.compatibleWithMove?(machine) elsif !pkmn.compatibleWithMove?(machine)
@@ -590,7 +590,7 @@ ItemHandlers::UseOnPokemon.copy(:ETHER,:LEPPABERRY)
ItemHandlers::UseOnPokemon.add(:MAXETHER,proc { |item,pkmn,scene| ItemHandlers::UseOnPokemon.add(:MAXETHER,proc { |item,pkmn,scene|
move = scene.pbChooseMove(pkmn,_INTL("Restore which move?")) move = scene.pbChooseMove(pkmn,_INTL("Restore which move?"))
next false if move<0 next false if move<0
if pbRestorePP(pkmn,move,pkmn.moves[move].totalpp-pkmn.moves[move].pp)==0 if pbRestorePP(pkmn,move,pkmn.moves[move].total_pp-pkmn.moves[move].pp)==0
scene.pbDisplay(_INTL("It won't have any effect.")) scene.pbDisplay(_INTL("It won't have any effect."))
next false next false
end end
@@ -614,7 +614,7 @@ ItemHandlers::UseOnPokemon.add(:ELIXIR,proc { |item,pkmn,scene|
ItemHandlers::UseOnPokemon.add(:MAXELIXIR,proc { |item,pkmn,scene| ItemHandlers::UseOnPokemon.add(:MAXELIXIR,proc { |item,pkmn,scene|
pprestored = 0 pprestored = 0
for i in 0...pkmn.moves.length for i in 0...pkmn.moves.length
pprestored += pbRestorePP(pkmn,i,pkmn.moves[i].totalpp-pkmn.moves[i].pp) pprestored += pbRestorePP(pkmn,i,pkmn.moves[i].total_pp-pkmn.moves[i].pp)
end end
if pprestored==0 if pprestored==0
scene.pbDisplay(_INTL("It won't have any effect.")) scene.pbDisplay(_INTL("It won't have any effect."))
@@ -627,12 +627,12 @@ ItemHandlers::UseOnPokemon.add(:MAXELIXIR,proc { |item,pkmn,scene|
ItemHandlers::UseOnPokemon.add(:PPUP,proc { |item,pkmn,scene| ItemHandlers::UseOnPokemon.add(:PPUP,proc { |item,pkmn,scene|
move = scene.pbChooseMove(pkmn,_INTL("Boost PP of which move?")) move = scene.pbChooseMove(pkmn,_INTL("Boost PP of which move?"))
if move>=0 if move>=0
if pkmn.moves[move].totalpp<=1 || pkmn.moves[move].ppup>=3 if pkmn.moves[move].total_pp<=1 || pkmn.moves[move].ppup>=3
scene.pbDisplay(_INTL("It won't have any effect.")) scene.pbDisplay(_INTL("It won't have any effect."))
next false next false
end end
pkmn.moves[move].ppup += 1 pkmn.moves[move].ppup += 1
movename = PBMoves.getName(pkmn.moves[move].id) movename = pkmn.moves[move].name
scene.pbDisplay(_INTL("{1}'s PP increased.",movename)) scene.pbDisplay(_INTL("{1}'s PP increased.",movename))
next true next true
end end
@@ -642,12 +642,12 @@ ItemHandlers::UseOnPokemon.add(:PPUP,proc { |item,pkmn,scene|
ItemHandlers::UseOnPokemon.add(:PPMAX,proc { |item,pkmn,scene| ItemHandlers::UseOnPokemon.add(:PPMAX,proc { |item,pkmn,scene|
move = scene.pbChooseMove(pkmn,_INTL("Boost PP of which move?")) move = scene.pbChooseMove(pkmn,_INTL("Boost PP of which move?"))
if move>=0 if move>=0
if pkmn.moves[move].totalpp<=1 || pkmn.moves[move].ppup>=3 if pkmn.moves[move].total_pp<=1 || pkmn.moves[move].ppup>=3
scene.pbDisplay(_INTL("It won't have any effect.")) scene.pbDisplay(_INTL("It won't have any effect."))
next false next false
end end
pkmn.moves[move].ppup = 3 pkmn.moves[move].ppup = 3
movename = PBMoves.getName(pkmn.moves[move].id) movename = pkmn.moves[move].name
scene.pbDisplay(_INTL("{1}'s PP increased.",movename)) scene.pbDisplay(_INTL("{1}'s PP increased.",movename))
next true next true
end end
@@ -143,8 +143,8 @@ ItemHandlers::CanUseInBattle.copy(:REVIVE,:MAXREVIVE,:REVIVALHERB)
ItemHandlers::CanUseInBattle.add(:ETHER,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| ItemHandlers::CanUseInBattle.add(:ETHER,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages|
if !pokemon.able? || move<0 || if !pokemon.able? || move<0 ||
pokemon.moves[move].totalpp<=0 || pokemon.moves[move].total_pp<=0 ||
pokemon.moves[move].pp==pokemon.moves[move].totalpp pokemon.moves[move].pp==pokemon.moves[move].total_pp
scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages
next false next false
end end
@@ -161,7 +161,7 @@ ItemHandlers::CanUseInBattle.add(:ELIXIR,proc { |item,pokemon,battler,move,first
canRestore = false canRestore = false
for m in pokemon.moves for m in pokemon.moves
next if m.id==0 next if m.id==0
next if m.totalpp<=0 || m.pp==m.totalpp next if m.total_pp<=0 || m.pp==m.total_pp
canRestore = true canRestore = true
break break
end end
@@ -487,7 +487,7 @@ ItemHandlers::BattleUseOnPokemon.copy(:ETHER,:LEPPABERRY)
ItemHandlers::BattleUseOnPokemon.add(:MAXETHER,proc { |item,pokemon,battler,choices,scene| ItemHandlers::BattleUseOnPokemon.add(:MAXETHER,proc { |item,pokemon,battler,choices,scene|
idxMove = choices[3] idxMove = choices[3]
pbBattleRestorePP(pokemon,battler,idxMove,pokemon.moves[idxMove].totalpp) pbBattleRestorePP(pokemon,battler,idxMove,pokemon.moves[idxMove].total_pp)
scene.pbDisplay(_INTL("PP was restored.")) scene.pbDisplay(_INTL("PP was restored."))
}) })
@@ -500,7 +500,7 @@ ItemHandlers::BattleUseOnPokemon.add(:ELIXIR,proc { |item,pokemon,battler,choice
ItemHandlers::BattleUseOnPokemon.add(:MAXELIXIR,proc { |item,pokemon,battler,choices,scene| ItemHandlers::BattleUseOnPokemon.add(:MAXELIXIR,proc { |item,pokemon,battler,choices,scene|
for i in 0...pokemon.moves.length for i in 0...pokemon.moves.length
pbBattleRestorePP(pokemon,battler,i,pokemon.moves[i].totalpp) pbBattleRestorePP(pokemon,battler,i,pokemon.moves[i].total_pp)
end end
scene.pbDisplay(_INTL("PP was restored.")) scene.pbDisplay(_INTL("PP was restored."))
}) })
+56 -85
View File
@@ -103,6 +103,8 @@ class Pokemon
EV_STAT_LIMIT = 252 EV_STAT_LIMIT = 252
# Maximum length a Pokémon's nickname can be # Maximum length a Pokémon's nickname can be
MAX_NAME_SIZE = 10 MAX_NAME_SIZE = 10
# Maximum number of moves a Pokémon can know at once
MAX_MOVES = 4
#============================================================================= #=============================================================================
# Ownership, obtained information # Ownership, obtained information
@@ -495,18 +497,15 @@ class Pokemon
# @return [Integer] the number of moves known by the Pokémon # @return [Integer] the number of moves known by the Pokémon
def numMoves def numMoves
ret = 0 return @moves.length
@moves.each { |m| ret += 1 if m && m.id != 0 }
return ret
end end
# @param move [Integer, Symbol, String] ID of the move to check # @param move [Integer, Symbol, String] ID of the move to check
# @return [Boolean] whether the Pokémon knows the given move # @return [Boolean] whether the Pokémon knows the given move
def hasMove?(move) def hasMove?(move_id)
move = getID(PBMoves, move) move_data = GameData::Move.try_get(move_id)
return false if !move || move <= 0 return false if !move_data
@moves.each { |m| return true if m && m.id == move } return @moves.any? { |m| m.id == move_data.id }
return false
end end
alias knowsMove? hasMove? alias knowsMove? hasMove?
@@ -518,101 +517,79 @@ class Pokemon
# Sets this Pokémon's movelist to the default movelist it originally had. # Sets this Pokémon's movelist to the default movelist it originally had.
def resetMoves def resetMoves
lvl = self.level this_level = self.level
fullMoveList = self.getMoveList # Find all level-up moves that self could have learned
moveList = [] moveset = self.getMoveList
fullMoveList.each { |m| moveList.push(m[1]) if m[0] <= lvl } knowable_moves = []
moveList = moveList.reverse moveset.each { |m| knowable_moves.push(m[1]) if m[0] <= this_level }
moveList |= [] # Remove duplicates # Remove duplicates (retaining the latest copy of each move)
moveList = moveList.reverse knowable_moves = knowable_moves.reverse
listend = moveList.length - 4 knowable_moves |= []
listend = 0 if listend < 0 knowable_moves = knowable_moves.reverse
j = 0 # Add all moves
for i in listend...listend+4 @moves.clear
moveid = (i >= moveList.length) ? 0 : moveList[i] first_move_index = knowable_moves.length - MAX_MOVES
@moves[j] = PBMove.new(moveid) first_move_index = 0 if first_move_index < 0
j += 1 for i in first_move_index...knowable_moves.length
@moves.push(PBMove.new(knowable_moves[i]))
end end
end end
# Silently learns the given move. Will erase the first known move if it has to. # Silently learns the given move. Will erase the first known move if it has to.
# @param move [Integer, Symbol, String] ID of the move to learn # @param move_id [Integer, Symbol, String] ID of the move to learn
def pbLearnMove(move) def pbLearnMove(move_id)
move = getID(PBMoves, move) move_data = GameData::Move.try_get(move_id)
return if move <= 0 return if !move_data
for i in 0...4 # Already knows move, relocate it to the end of the list # Check if self already knows the move; if so, move it to the end of the array
next if @moves[i].id != move @moves.each_with_index do |m, i|
j = i + 1 next if m.id != move_data.id
while j < 4 @moves.push(m)
break if @moves[j].id == 0 @moves.delete_at(i)
tmp = @moves[j]
@moves[j] = @moves[j - 1]
@moves[j - 1] = tmp
j += 1
end
return return
end end
for i in 0...4 # Has empty move slot, put move in there # Move is not already known; learn it
next if @moves[i].id != 0 @moves.push(PBMove.new(move_data.id))
@moves[i] = PBMove.new(move) # Delete the first known move if self now knows more moves than it should
return @moves.shift if numMoves > MAX_MOVES
end
# Already knows 4 moves, forget the first move and learn the new move
@moves[0] = @moves[1]
@moves[1] = @moves[2]
@moves[2] = @moves[3]
@moves[3] = PBMove.new(move)
end end
# Deletes the given move from the Pokémon. # Deletes the given move from the Pokémon.
# @param move [Integer, Symbol, String] ID of the move to delete # @param move_id [Integer, Symbol, String] ID of the move to delete
def pbDeleteMove(move) def pbDeleteMove(move_id)
move = getID(PBMoves,move) move_data = GameData::Move.try_get(move_id)
return if !move || move <= 0 return if !move_data
newMoves = [] @moves.delete_if { |m| m.id == move_data.id }
@moves.each { |m| newMoves.push(m) if m && m.id != move }
newMoves.push(PBMove.new(0))
for i in 0...4
@moves[i] = newMoves[i]
end
end end
# Deletes the move at the given index from the Pokémon. # Deletes the move at the given index from the Pokémon.
# @param index [Integer] index of the move to be deleted # @param index [Integer] index of the move to be deleted
def pbDeleteMoveAtIndex(index) def pbDeleteMoveAtIndex(index)
newMoves = [] @moves.delete_at(index)
@moves.each_with_index { |m, i| newMoves.push(m) if m && i != index }
newMoves.push(PBMove.new(0))
for i in 0...4
@moves[i] = newMoves[i]
end
end end
# Deletes all moves from the Pokémon. # Deletes all moves from the Pokémon.
def pbDeleteAllMoves def pbDeleteAllMoves
for i in 0...4 @moves = []
@moves[i] = PBMove.new(0)
end
end end
# Copies currently known moves into a separate array, for Move Relearner. # Copies currently known moves into a separate array, for Move Relearner.
def pbRecordFirstMoves def pbRecordFirstMoves
@firstmoves = [] @firstmoves = []
@moves.each { |m| @firstmoves.push(m.id) if m && m.id > 0 } @moves.each { |m| @firstmoves.push(m.id) }
end end
# Adds a move to this Pokémon's first moves. # Adds a move to this Pokémon's first moves.
# @param move [Integer, Symbol, String] ID of the move to add # @param move_id [Integer, Symbol, String] ID of the move to add
def pbAddFirstMove(move) def pbAddFirstMove(move_id)
move = getID(PBMoves, move) move_data = GameData::Move.try_get(move_id)
@firstmoves.push(move) if move > 0 && !@firstmoves.include?(move) @firstmoves.push(move_data.id) if move_data && !@firstmoves.include?(move_data.id)
end end
# Removes a move from this Pokémon's first moves. # Removes a move from this Pokémon's first moves.
# @param move [Integer, Symbol, String] ID of the move to remove # @param move_id [Integer, Symbol, String] ID of the move to remove
def pbRemoveFirstMove(move) def pbRemoveFirstMove(move_id)
move = getID(PBMoves, move) move_data = GameData::Move.try_get(move_id)
@firstmoves.delete(move) if move > 0 @firstmoves.delete(move_data.id) if move_data
end end
# Clears this Pokémon's first moves. # Clears this Pokémon's first moves.
@@ -622,8 +599,8 @@ class Pokemon
# @param move [Integer, Symbol, String] ID of the move to check # @param move [Integer, Symbol, String] ID of the move to check
# @return [Boolean] whether the Pokémon is compatible with the given move # @return [Boolean] whether the Pokémon is compatible with the given move
def compatibleWithMove?(move) def compatibleWithMove?(move_id)
return pbSpeciesCompatible?(self.fSpecies, move) return pbSpeciesCompatible?(self.fSpecies, move_id)
end end
#============================================================================= #=============================================================================
@@ -830,9 +807,9 @@ class Pokemon
def healPP(move_index = -1) def healPP(move_index = -1)
return if egg? return if egg?
if move_index >= 0 if move_index >= 0
@moves[move_index].pp = @moves[move_index].totalpp @moves[move_index].pp = @moves[move_index].total_pp
else else
@moves.each { |m| m.pp = m.totalpp } @moves.each { |m| m.pp = m.total_pp }
end end
end end
@@ -1107,12 +1084,6 @@ class Pokemon
calcStats calcStats
@hp = @totalhp @hp = @totalhp
@happiness = pbGetSpeciesData(@species, formSimple, SpeciesData::HAPPINESS) @happiness = pbGetSpeciesData(@species, formSimple, SpeciesData::HAPPINESS)
if withMoves self.resetMoves if withMoves
self.resetMoves
else
for i in 0...4
@moves[i] = PBMove.new(0)
end
end
end end
end end
+55 -72
View File
@@ -270,48 +270,48 @@ MultipleForms.register(:CHERRIM,{
}) })
MultipleForms.register(:ROTOM,{ MultipleForms.register(:ROTOM,{
"onSetForm" => proc { |pkmn,form,oldForm| "onSetForm" => proc { |pkmn, form, oldForm|
formMoves = [ form_moves = [
:OVERHEAT, # Heat, Microwave :OVERHEAT, # Heat, Microwave
:HYDROPUMP, # Wash, Washing Machine :HYDROPUMP, # Wash, Washing Machine
:BLIZZARD, # Frost, Refrigerator :BLIZZARD, # Frost, Refrigerator
:AIRSLASH, # Fan :AIRSLASH, # Fan
:LEAFSTORM # Mow, Lawnmower :LEAFSTORM # Mow, Lawnmower
] ]
idxMoveToReplace = -1 move_index = -1
pkmn.moves.each_with_index do |move,i| pkmn.moves.each_with_index do |move, i|
next if !move next if !form_moves.any? { |m| move == m }
formMoves.each do |newMove| move_index = i
next if !isConst?(move.id,PBMoves,newMove)
idxMoveToReplace = i
break break
end end
break if idxMoveToReplace>=0 if form == 0
end # Turned back into the base form; forget form-specific moves
if form==0 if move_index >= 0
if idxMoveToReplace>=0 move_name = pkmn.moves[move_index].name
moveName = PBMoves.getName(pkmn.moves[idxMoveToReplace].id) pkmn.pbDeleteMoveAtIndex(move_index)
pkmn.pbDeleteMoveAtIndex(idxMoveToReplace) pbMessage(_INTL("{1} forgot {2}...", pkmn.name, move_name))
pbMessage(_INTL("{1} forgot {2}...",pkmn.name,moveName)) pkmn.pbLearnMove(:THUNDERSHOCK) if pkmn.numMoves == 0
pkmn.pbLearnMove(:THUNDERSHOCK) if pkmn.numMoves==0
end end
else else
newMove = getConst(PBMoves,formMoves[form-1]) # Turned into an alternate form; try learning that form's unique move
if idxMoveToReplace>=0 new_move_id = form_moves[form - 1]
oldMoveName = PBMoves.getName(pkmn.moves[idxMoveToReplace].id) if move_index >= 0
if newMove && newMove>0 # Knows another form's unique move; replace it
newMoveName = PBMoves.getName(newMove) old_move_name = pkmn.moves[move_index].name
pkmn.moves[idxMoveToReplace].id = newMove if GameData::Move.exists?(new_move_id)
pkmn.moves[move_index].id = new_move_id
new_move_name = pkmn.moves[move_index].name
pbMessage(_INTL("1,\\wt[16] 2, and\\wt[16]...\\wt[16] ...\\wt[16] ... Ta-da!\\se[Battle ball drop]\1")) pbMessage(_INTL("1,\\wt[16] 2, and\\wt[16]...\\wt[16] ...\\wt[16] ... Ta-da!\\se[Battle ball drop]\1"))
pbMessage(_INTL("{1} forgot how to use {2}.\\nAnd...\1",pkmn.name,oldMoveName)) pbMessage(_INTL("{1} forgot how to use {2}.\\nAnd...\1", pkmn.name, old_move_name))
pbMessage(_INTL("\\se[]{1} learned {2}!\\se[Pkmn move learnt]",pkmn.name,newMoveName)) pbMessage(_INTL("\\se[]{1} learned {2}!\\se[Pkmn move learnt]", pkmn.name, new_move_name))
else else
pkmn.pbDeleteMoveAtIndex(idxMoveToReplace) pkmn.pbDeleteMoveAtIndex(move_index)
pbMessage(_INTL("{1} forgot {2}...",pkmn.name,oldMoveName)) pbMessage(_INTL("{1} forgot {2}...", pkmn.name, old_move_name))
pkmn.pbLearnMove(:THUNDERSHOCK) if pkmn.numMoves==0 pkmn.pbLearnMove(:THUNDERSHOCK) if pkmn.numMoves == 0
end end
elsif newMove && newMove>0 else
pbLearnMove(pkmn,newMove,true) # Just try to learn this form's unique move
pbLearnMove(pkmn, new_move_id, true)
end end
end end
} }
@@ -396,39 +396,26 @@ MultipleForms.register(:KYUREM,{
"getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle| "getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle|
next pkmn.form-2 if pkmn.form>=3 # Fused forms stop glowing next pkmn.form-2 if pkmn.form>=3 # Fused forms stop glowing
}, },
"onSetForm" => proc { |pkmn,form,oldForm| "onSetForm" => proc { |pkmn, form, oldForm|
case form case form
when 0 # Normal when 0 # Normal
pkmn.moves.each do |move| pkmn.moves.each do |move|
next if !move if [:ICEBURN, :FREEZESHOCK].include?(move.id)
if (isConst?(move.id,PBMoves,:ICEBURN) || move.id = :GLACIATE if GameData::Move.exists?(:GLACIATE)
isConst?(move.id,PBMoves,:FREEZESHOCK)) && hasConst?(PBMoves,:GLACIATE)
move.id = getConst(PBMoves,:GLACIATE)
end end
if (isConst?(move.id,PBMoves,:FUSIONFLARE) || if [:FUSIONFLARE, :FUSIONBOLT].include?(move.id)
isConst?(move.id,PBMoves,:FUSIONBOLT)) && hasConst?(PBMoves,:SCARYFACE) move.id = :SCARYFACE if GameData::Move.exists?(:SCARYFACE)
move.id = getConst(PBMoves,:SCARYFACE)
end end
end end
when 1 # White when 1 # White
pkmn.moves.each do |move| pkmn.moves.each do |move|
next if !move move.id = :ICEBURN if move == :GLACIATE && GameData::Move.exists?(:ICEBURN)
if isConst?(move.id,PBMoves,:GLACIATE) && hasConst?(PBMoves,:ICEBURN) move.id = :FUSIONFLARE if move == :SCARYFACE && GameData::Move.exists?(:FUSIONFLARE)
move.id = getConst(PBMoves,:ICEBURN)
end
if isConst?(move.id,PBMoves,:SCARYFACE) && hasConst?(PBMoves,:FUSIONFLARE)
move.id = getConst(PBMoves,:FUSIONFLARE)
end
end end
when 2 # Black when 2 # Black
pkmn.moves.each do |move| pkmn.moves.each do |move|
next if !move move.id = :FREEZESHOCK if move == :GLACIATE && GameData::Move.exists?(:FREEZESHOCK)
if isConst?(move.id,PBMoves,:GLACIATE) && hasConst?(PBMoves,:FREEZESHOCK) move.id = :FUSIONBOLT if move == :SCARYFACE && GameData::Move.exists?(:FUSIONBOLT)
move.id = getConst(PBMoves,:FREEZESHOCK)
end
if isConst?(move.id,PBMoves,:SCARYFACE) && hasConst?(PBMoves,:FUSIONBOLT)
move.id = getConst(PBMoves,:FUSIONBOLT)
end
end end
end end
} }
@@ -629,34 +616,30 @@ MultipleForms.register(:NECROZMA,{
# Fused forms are 1 and 2, Ultra form is 3 or 4 depending on which fusion # Fused forms are 1 and 2, Ultra form is 3 or 4 depending on which fusion
next pkmn.form-2 if pkmn.form>=3 && (pkmn.fainted? || endBattle) next pkmn.form-2 if pkmn.form>=3 && (pkmn.fainted? || endBattle)
}, },
"onSetForm" => proc { |pkmn,form,oldForm| "onSetForm" => proc { |pkmn, form, oldForm|
next if form>2 || oldForm>2 # Ultra form changes don't affect moveset next if form > 2 || oldForm > 2 # Ultra form changes don't affect moveset
formMoves = [ form_moves = [
:SUNSTEELSTRIKE, # Dusk Mane (with Solgaleo) (form 1) :SUNSTEELSTRIKE, # Dusk Mane (with Solgaleo) (form 1)
:MOONGEISTBEAM # Dawn Wings (with Lunala) (form 2) :MOONGEISTBEAM # Dawn Wings (with Lunala) (form 2)
] ]
if form==0 if form == 0
idxMoveToReplace = -1 # Turned back into the base form; forget form-specific moves
pkmn.moves.each_with_index do |move,i| move_index = -1
next if !move pkmn.moves.each_with_index do |move, i|
formMoves.each do |newMove| next if !form_moves.any? { |m| move == m }
next if !isConst?(move.id,PBMoves,newMove) move_index = i
idxMoveToReplace = i
break break
end end
break if idxMoveToReplace>=0 if move_index >= 0
end move_name = pkmn.moves[move_index].name
if idxMoveToReplace>=0 pkmn.pbDeleteMoveAtIndex(move_index)
moveName = PBMoves.getName(pkmn.moves[idxMoveToReplace].id) pbMessage(_INTL("{1} forgot {2}...", pkmn.name, move_name))
pkmn.pbDeleteMoveAtIndex(idxMoveToReplace) pkmn.pbLearnMove(:CONFUSION) if pkmn.numMoves == 0
pbMessage(_INTL("{1} forgot {2}...",pkmn.name,moveName))
pkmn.pbLearnMove(:CONFUSION) if pkmn.numMoves==0
end end
else else
newMove = getConst(PBMoves,formMoves[form-1]) # Turned into an alternate form; try learning that form's unique move
if newMove && newMove>0 new_move_id = form_moves[form - 1]
pbLearnMove(pkmn,newMove,true) pbLearnMove(pkmn, new_move_id, true)
end
end end
} }
}) })
@@ -16,8 +16,8 @@ class Pokemon
ret = i; break ret = i; break
end end
if !checkItemOnly if !checkItemOnly
megaMove = speciesData[fSpec][SpeciesData::MEGA_MOVE] || 0 megaMove = speciesData[fSpec][SpeciesData::MEGA_MOVE]
if megaMove>0 && self.hasMove?(megaMove) if self.hasMove?(megaMove)
ret = i; break ret = i; break
end end
end end
@@ -22,13 +22,12 @@ def pbPurify(pokemon,scene)
pokemon.shadow = false pokemon.shadow = false
pokemon.giveRibbon(PBRibbons::NATIONAL) pokemon.giveRibbon(PBRibbons::NATIONAL)
scene.pbDisplay(_INTL("{1} opened the door to its heart!",pokemon.name)) scene.pbDisplay(_INTL("{1} opened the door to its heart!",pokemon.name))
oldmoves = [] old_moves = []
for i in 0...4; oldmoves.push(pokemon.moves[i].id); end pokemon.moves.each { |m| old_moves.push(m.id) }
pokemon.pbUpdateShadowMoves pokemon.pbUpdateShadowMoves
for i in 0...4 pokemon.moves.each_with_index do |m, i|
next if pokemon.moves[i].id<=0 || pokemon.moves[i].id==oldmoves[i] next if m == old_moves[i]
scene.pbDisplay(_INTL("{1} regained the move \n{2}!", scene.pbDisplay(_INTL("{1} regained the move {2}!", pokemon.name, m.name))
pokemon.name,PBMoves.getName(pokemon.moves[i].id)))
end end
pokemon.pbRecordFirstMoves pokemon.pbRecordFirstMoves
if pokemon.savedev if pokemon.savedev
@@ -75,31 +74,23 @@ def pbApplyEVGain(pokemon,ev,evgain)
end end
end end
def pbReplaceMoves(pokemon,move1,move2=0,move3=0,move4=0) def pbReplaceMoves(pkmn, new_moves)
return if !pokemon return if !pkmn
[move1,move2,move3,move4].each { |move| new_moves.each do |move|
moveIndex = -1 next if !move || pkmn.hasMove?(move)
if move!=0 # Find a move slot to put move into
# Look for given move for i in 0...Pokemon::MAX_MOVES
for i in 0...4 if i >= pkmn.numMoves
moveIndex = i if pokemon.moves[i].id==move # Empty slot; add the new move there
end pkmn.pbLearnMove(move)
end break
if moveIndex==-1 elsif !new_moves.include?(pkmn.moves[i].id)
# Look for slot to replace move # Known move that isn't a move to be relearned; replace it
for i in 0...4 pkmn.moves[i].id = move
if (pokemon.moves[i].id==0 && move!=0) || (
pokemon.moves[i].id!=move1 &&
pokemon.moves[i].id!=move2 &&
pokemon.moves[i].id!=move3 &&
pokemon.moves[i].id!=move4)
# Replace move
pokemon.moves[i] = PBMove.new(move)
break break
end end
end end
end end
}
end end
@@ -288,47 +279,57 @@ class Pokemon
self.heartgauge = HEARTGAUGESIZE self.heartgauge = HEARTGAUGESIZE
self.savedexp = 0 self.savedexp = 0
self.savedev = [0,0,0,0,0,0] self.savedev = [0,0,0,0,0,0]
self.shadowmoves = [0,0,0,0,0,0,0,0] self.shadowmoves = []
# Retrieve shadow moves # Retrieve Shadow moveset for this Pokémon
moves = pbLoadShadowMovesets shadow_moveset = pbLoadShadowMovesets[self.fSpecies]
if moves[self.species] && moves[self.species].length>0 shadow_moveset = pbLoadShadowMovesets[self.species] if !shadow_moveset || shadow_moveset.length == 0
for i in 0...[4,moves[self.species].length].min # Record this Pokémon's Shadow moves
self.shadowmoves[i] = moves[self.species][i] if shadow_moveset && shadow_moveset.length > 0
for i in 0...[shadow_moveset.length, MAX_MOVES].min
self.shadowmoves[i] = shadow_moveset[i]
end end
self.shadowmovenum = moves[self.species].length self.shadowmovenum = shadow_moveset.length
else else
# No special shadow moves # No Shadow moveset defined; just use Shadow Rush
self.shadowmoves[0] = getConst(PBMoves,:SHADOWRUSH) || 0 self.shadowmoves[0] = :SHADOWRUSH if GameData::Move.exists?(:SHADOWRUSH)
self.shadowmovenum = 1 self.shadowmovenum = 1
end end
for i in 0...4 # Save old moves # Record this Pokémon's original moves
self.shadowmoves[4+i] = self.moves[i].id @moves.each_with_index { |m, i| self.shadowmoves[MAX_MOVES + i] = m.id }
end # Update moves
pbUpdateShadowMoves pbUpdateShadowMoves
end end
def pbUpdateShadowMoves(allmoves=false) def pbUpdateShadowMoves(relearn_all_moves = false)
return if !@shadowmoves return if !@shadowmoves
m = @shadowmoves # Not a Shadow Pokémon (any more); relearn all its original moves
if !@shadow if !@shadow
# No shadow moves if @shadowmoves.length > MAX_MOVES
pbReplaceMoves(self,m[4],m[5],m[6],m[7]) new_moves = []
@shadowmoves.each_with_index { |m, i| new_moves.push(m) if m && i >= MAX_MOVES }
pbReplaceMoves(self, new_moves)
end
@shadowmoves = nil @shadowmoves = nil
else return
moves = [] end
relearning = (allmoves) ? 3 : [3,3,2,1,1,0][self.heartStage] # Is a Shadow Pokémon; ensure it knows the appropriate moves depending on its heart stage
relearned = 0 m = @shadowmoves
# Add all Shadow moves # Start with all Shadow moves
for i in 0...4; moves.push(m[i]) if m[i]!=0; end new_moves = []
# Add X regular moves @shadowmoves.each_with_index { |m, i| new_moves.push(m) if m && i < MAX_MOVES }
for i in 0...4 # Add some original moves (skipping ones in the same slot as a Shadow Move)
next if i<@shadowmovenum num_original_moves = (relearn_all_moves) ? 3 : [3, 3, 2, 1, 1, 0][self.heartStage]
if m[i+4]!=0 && relearned<relearning if num_original_moves > 0
moves.push(m[i+4]); relearned += 1 relearned_count = 0
@shadowmoves.each_with_index do |m, i|
next if !m || i < MAX_MOVES + @shadowmovenum
new_moves.push(m)
relearned_count += 1
break if relearned_count >= num_original_moves
end end
end end
pbReplaceMoves(self,moves[0] || 0,moves[1] || 0,moves[2] || 0,moves[3] || 0) # Relearn Shadow moves plus some original moves (may not change anything)
end pbReplaceMoves(self, new_moves)
end end
alias :__shadow_clone :clone alias :__shadow_clone :clone
@@ -493,7 +493,7 @@ PBEvolution.register(:HappinessNight, {
PBEvolution.register(:HappinessMove, { PBEvolution.register(:HappinessMove, {
"minimumLevel" => 1, # Needs any level up "minimumLevel" => 1, # Needs any level up
"parameterType" => :PBMoves, "parameterType" => :Move,
"levelUpCheck" => proc { |pkmn, parameter| "levelUpCheck" => proc { |pkmn, parameter|
if pkmn.happiness >= 220 if pkmn.happiness >= 220
next pkmn.moves.any? { |m| m && m.id == parameter } next pkmn.moves.any? { |m| m && m.id == parameter }
@@ -619,7 +619,7 @@ PBEvolution.register(:HoldItemHappiness, {
PBEvolution.register(:HasMove, { PBEvolution.register(:HasMove, {
"minimumLevel" => 1, # Needs any level up "minimumLevel" => 1, # Needs any level up
"parameterType" => :PBMoves, "parameterType" => :Move,
"levelUpCheck" => proc { |pkmn, parameter| "levelUpCheck" => proc { |pkmn, parameter|
next pkmn.moves.any? { |m| m && m.id == parameter } next pkmn.moves.any? { |m| m && m.id == parameter }
} }
@@ -4,75 +4,75 @@
#=============================================================================== #===============================================================================
# @deprecated Use {Pokemon} instead. PokeBattle_Pokemon has been turned into an alias # @deprecated Use {Pokemon} instead. PokeBattle_Pokemon has been turned into an alias
# and is slated to be removed in vXX. # and is slated to be removed in v20.
class PokeBattle_Pokemon; end class PokeBattle_Pokemon; end
PokeBattle_Pokemon = Pokemon PokeBattle_Pokemon = Pokemon
class Pokemon class Pokemon
# @deprecated Use {MAX_NAME_SIZE} instead. This alias is slated to be removed in vXX. # @deprecated Use {MAX_NAME_SIZE} instead. This alias is slated to be removed in v20.
MAX_POKEMON_NAME_SIZE = MAX_NAME_SIZE MAX_POKEMON_NAME_SIZE = MAX_NAME_SIZE
# @deprecated Use {Owner#public_id} instead. This alias is slated to be removed in vXX. # @deprecated Use {Owner#public_id} instead. This alias is slated to be removed in v20.
def publicID def publicID
Deprecation.warn_method('Pokemon#publicID', 'vXX', 'Pokemon::Owner#public_id') Deprecation.warn_method('Pokemon#publicID', 'v20', 'Pokemon::Owner#public_id')
return @owner.public_id return @owner.public_id
end end
# @deprecated Use {Owner#id} instead. This alias is slated to be removed in vXX. # @deprecated Use {Owner#id} instead. This alias is slated to be removed in v20.
def trainerID def trainerID
Deprecation.warn_method('Pokemon#trainerID', 'vXX', 'Pokemon::Owner#id') Deprecation.warn_method('Pokemon#trainerID', 'v20', 'Pokemon::Owner#id')
return @owner.id return @owner.id
end end
# @deprecated Use {Owner#id=} instead. This alias is slated to be removed in vXX. # @deprecated Use {Owner#id=} instead. This alias is slated to be removed in v20.
def trainerID=(value) def trainerID=(value)
Deprecation.warn_method('Pokemon#trainerID=', 'vXX', 'Pokemon::Owner#id=') Deprecation.warn_method('Pokemon#trainerID=', 'v20', 'Pokemon::Owner#id=')
@owner.id = value @owner.id = value
end end
# @deprecated Use {Owner#name} instead. This alias is slated to be removed in vXX. # @deprecated Use {Owner#name} instead. This alias is slated to be removed in v20.
def ot def ot
Deprecation.warn_method('Pokemon#ot', 'vXX', 'Pokemon::Owner#name') Deprecation.warn_method('Pokemon#ot', 'v20', 'Pokemon::Owner#name')
return @owner.name return @owner.name
end end
# @deprecated Use {Owner#name=} instead. This alias is slated to be removed in vXX. # @deprecated Use {Owner#name=} instead. This alias is slated to be removed in v20.
def ot=(value) def ot=(value)
Deprecation.warn_method('Pokemon#ot=', 'vXX', 'Pokemon::Owner#name=') Deprecation.warn_method('Pokemon#ot=', 'v20', 'Pokemon::Owner#name=')
@owner.name = value @owner.name = value
end end
# @deprecated Use {Owner#gender} instead. This alias is slated to be removed in vXX. # @deprecated Use {Owner#gender} instead. This alias is slated to be removed in v20.
def otgender def otgender
Deprecation.warn_method('Pokemon#otgender', 'vXX', 'Pokemon::Owner#gender') Deprecation.warn_method('Pokemon#otgender', 'v20', 'Pokemon::Owner#gender')
return @owner.gender return @owner.gender
end end
# @deprecated Use {Owner#gender=} instead. This alias is slated to be removed in vXX. # @deprecated Use {Owner#gender=} instead. This alias is slated to be removed in v20.
def otgender=(value) def otgender=(value)
Deprecation.warn_method('Pokemon#otgender=', 'vXX', 'Pokemon::Owner#gender=') Deprecation.warn_method('Pokemon#otgender=', 'v20', 'Pokemon::Owner#gender=')
@owner.gender = value @owner.gender = value
end end
# @deprecated Use {Owner#language} instead. This alias is slated to be removed in vXX. # @deprecated Use {Owner#language} instead. This alias is slated to be removed in v20.
def language def language
Deprecation.warn_method('Pokemon#language', 'vXX', 'Pokemon::Owner#language') Deprecation.warn_method('Pokemon#language', 'v20', 'Pokemon::Owner#language')
return @owner.language return @owner.language
end end
# @deprecated Use {Owner#language=} instead. This alias is slated to be removed in vXX. # @deprecated Use {Owner#language=} instead. This alias is slated to be removed in v20.
def language=(value) def language=(value)
Deprecation.warn_method('Pokemon#language=', 'vXX', 'Pokemon::Owner#language=') Deprecation.warn_method('Pokemon#language=', 'v20', 'Pokemon::Owner#language=')
@owner.language = value @owner.language = value
end end
end end
# (see Pokemon#initialize) # (see Pokemon#initialize)
# @deprecated Use +Pokemon.new+ instead. This method and its aliases are # @deprecated Use +Pokemon.new+ instead. This method and its aliases are
# slated to be removed in vXX. # slated to be removed in v20.
def pbNewPkmn(species, level, owner = $Trainer, withMoves = true) def pbNewPkmn(species, level, owner = $Trainer, withMoves = true)
Deprecation.warn_method('pbNewPkmn', 'vXX', 'Pokemon.new') Deprecation.warn_method('pbNewPkmn', 'v20', 'Pokemon.new')
return Pokemon.new(species, level, owner, withMoves) return Pokemon.new(species, level, owner, withMoves)
end end
alias pbGenPkmn pbNewPkmn alias pbGenPkmn pbNewPkmn
+15 -19
View File
@@ -941,10 +941,10 @@ class PokemonPartyScreen
movenames = [] movenames = []
for i in pokemon.moves for i in pokemon.moves
break if i.id==0 break if i.id==0
if i.totalpp<=0 if i.total_pp<=0
movenames.push(_INTL("{1} (PP: ---)",PBMoves.getName(i.id))) movenames.push(_INTL("{1} (PP: ---)",i.name))
else else
movenames.push(_INTL("{1} (PP: {2}/{3})",PBMoves.getName(i.id),i.pp,i.totalpp)) movenames.push(_INTL("{1} (PP: {2}/{3})",i.name,i.pp,i.total_pp))
end end
end end
return @scene.pbShowCommands(helptext,movenames,index) return @scene.pbShowCommands(helptext,movenames,index)
@@ -1129,20 +1129,20 @@ class PokemonPartyScreen
commands = [] commands = []
cmdSummary = -1 cmdSummary = -1
cmdDebug = -1 cmdDebug = -1
cmdMoves = [-1,-1,-1,-1] cmdMoves = [-1] * pkmn.numMoves
cmdSwitch = -1 cmdSwitch = -1
cmdMail = -1 cmdMail = -1
cmdItem = -1 cmdItem = -1
# Build the commands # Build the commands
commands[cmdSummary = commands.length] = _INTL("Summary") commands[cmdSummary = commands.length] = _INTL("Summary")
commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG
for i in 0...pkmn.moves.length if !pkmn.egg?
move = pkmn.moves[i]
# Check for hidden moves and add any that were found # Check for hidden moves and add any that were found
if !pkmn.egg? && (isConst?(move.id,PBMoves,:MILKDRINK) || pkmn.moves.each_with_index do |m, i|
isConst?(move.id,PBMoves,:SOFTBOILED) || if [:MILKDRINK, :SOFTBOILED].include?(m.id) ||
HiddenMoveHandlers.hasHandler(move.id)) HiddenMoveHandlers.hasHandler(m.id)
commands[cmdMoves[i] = commands.length] = [PBMoves.getName(move.id),1] commands[cmdMoves[i] = commands.length] = [m.name, 1]
end
end end
end end
commands[cmdSwitch = commands.length] = _INTL("Switch") if @party.length>1 commands[cmdSwitch = commands.length] = _INTL("Switch") if @party.length>1
@@ -1156,11 +1156,10 @@ class PokemonPartyScreen
commands[commands.length] = _INTL("Cancel") commands[commands.length] = _INTL("Cancel")
command = @scene.pbShowCommands(_INTL("Do what with {1}?",pkmn.name),commands) command = @scene.pbShowCommands(_INTL("Do what with {1}?",pkmn.name),commands)
havecommand = false havecommand = false
for i in 0...4 cmdMoves.each_with_index do |cmd, i|
if cmdMoves[i]>=0 && command==cmdMoves[i] next if cmd < 0 || cmd != command
havecommand = true havecommand = true
if isConst?(pkmn.moves[i].id,PBMoves,:SOFTBOILED) || if [:MILKDRINK, :SOFTBOILED].include?(pkmn.moves[i].id)
isConst?(pkmn.moves[i].id,PBMoves,:MILKDRINK)
amt = [(pkmn.totalhp/5).floor,1].max amt = [(pkmn.totalhp/5).floor,1].max
if pkmn.hp<=amt if pkmn.hp<=amt
pbDisplay(_INTL("Not enough HP...")) pbDisplay(_INTL("Not enough HP..."))
@@ -1173,7 +1172,7 @@ class PokemonPartyScreen
pkmnid = @scene.pbChoosePokemon(true,pkmnid) pkmnid = @scene.pbChoosePokemon(true,pkmnid)
break if pkmnid<0 break if pkmnid<0
newpkmn = @party[pkmnid] newpkmn = @party[pkmnid]
movename = PBMoves.getName(pkmn.moves[i].id) movename = pkmn.moves[i].name
if pkmnid==oldpkmnid if pkmnid==oldpkmnid
pbDisplay(_INTL("{1} can't use {2} on itself!",pkmn.name,movename)) pbDisplay(_INTL("{1} can't use {2} on itself!",pkmn.name,movename))
elsif newpkmn.egg? elsif newpkmn.egg?
@@ -1194,7 +1193,7 @@ class PokemonPartyScreen
elsif pbCanUseHiddenMove?(pkmn,pkmn.moves[i].id) elsif pbCanUseHiddenMove?(pkmn,pkmn.moves[i].id)
if pbConfirmUseHiddenMove(pkmn,pkmn.moves[i].id) if pbConfirmUseHiddenMove(pkmn,pkmn.moves[i].id)
@scene.pbEndScene @scene.pbEndScene
if isConst?(pkmn.moves[i].id,PBMoves,:FLY) if pkmn.moves[i].id == :FLY
scene = PokemonRegionMap_Scene.new(-1,false) scene = PokemonRegionMap_Scene.new(-1,false)
screen = PokemonRegionMapScreen.new(scene) screen = PokemonRegionMapScreen.new(scene)
ret = screen.pbStartFlyScreen ret = screen.pbStartFlyScreen
@@ -1208,9 +1207,6 @@ class PokemonPartyScreen
end end
return [pkmn,pkmn.moves[i].id] return [pkmn,pkmn.moves[i].id]
end end
else
break
end
end end
end end
next if havecommand next if havecommand
+88 -100
View File
@@ -34,7 +34,7 @@ class MoveSelectionSprite < SpriteWrapper
self.x = 240 self.x = 240
self.y = 92+(self.index*64) self.y = 92+(self.index*64)
self.y -= 76 if @fifthmove self.y -= 76 if @fifthmove
self.y += 20 if @fifthmove && self.index==4 self.y += 20 if @fifthmove && self.index==Pokemon::MAX_MOVES # Add a gap
self.bitmap = @movesel.bitmap self.bitmap = @movesel.bitmap
if self.preselected if self.preselected
self.src_rect.set(0,h,w,h) self.src_rect.set(0,h,w,h)
@@ -166,7 +166,7 @@ class PokemonSummary_Scene
pbFadeInAndShow(@sprites) { pbUpdate } pbFadeInAndShow(@sprites) { pbUpdate }
end end
def pbStartForgetScene(party,partyindex,moveToLearn) def pbStartForgetScene(party,partyindex,move_to_learn)
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height) @viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z = 99999 @viewport.z = 99999
@party = party @party = party
@@ -182,11 +182,12 @@ class PokemonSummary_Scene
@sprites["pokeicon"].setOffset(PictureOrigin::Center) @sprites["pokeicon"].setOffset(PictureOrigin::Center)
@sprites["pokeicon"].x = 46 @sprites["pokeicon"].x = 46
@sprites["pokeicon"].y = 92 @sprites["pokeicon"].y = 92
@sprites["movesel"] = MoveSelectionSprite.new(@viewport,moveToLearn>0) @sprites["movesel"] = MoveSelectionSprite.new(@viewport,!move_to_learn.nil?)
@sprites["movesel"].visible = false @sprites["movesel"].visible = false
@sprites["movesel"].visible = true @sprites["movesel"].visible = true
@sprites["movesel"].index = 0 @sprites["movesel"].index = 0
drawSelectedMove(moveToLearn,@pokemon.moves[0].id) new_move = (move_to_learn) ? PBMove.new(move_to_learn) : nil
drawSelectedMove(new_move,@pokemon.moves[0])
pbFadeInAndShow(@sprites) pbFadeInAndShow(@sprites)
end end
@@ -678,19 +679,19 @@ class PokemonSummary_Scene
imagepos = [] imagepos = []
# Write move names, types and PP amounts for each known move # Write move names, types and PP amounts for each known move
yPos = 98 yPos = 98
for i in 0...@pokemon.moves.length for i in 0...Pokemon::MAX_MOVES
move=@pokemon.moves[i] move=@pokemon.moves[i]
if move.id>0 if move
imagepos.push(["Graphics/Pictures/types",248,yPos+2,0,move.type*28,64,28]) imagepos.push(["Graphics/Pictures/types",248,yPos+2,0,move.type*28,64,28])
textpos.push([PBMoves.getName(move.id),316,yPos,0,moveBase,moveShadow]) textpos.push([move.name,316,yPos,0,moveBase,moveShadow])
if move.totalpp>0 if move.total_pp>0
textpos.push([_INTL("PP"),342,yPos+32,0,moveBase,moveShadow]) textpos.push([_INTL("PP"),342,yPos+32,0,moveBase,moveShadow])
ppfraction = 0 ppfraction = 0
if move.pp==0; ppfraction = 3 if move.pp==0; ppfraction = 3
elsif move.pp*4<=move.totalpp; ppfraction = 2 elsif move.pp*4<=move.total_pp; ppfraction = 2
elsif move.pp*2<=move.totalpp; ppfraction = 1 elsif move.pp*2<=move.total_pp; ppfraction = 1
end end
textpos.push([sprintf("%d/%d",move.pp,move.totalpp),460,yPos+32,1,ppBase[ppfraction],ppShadow[ppfraction]]) textpos.push([sprintf("%d/%d",move.pp,move.total_pp),460,yPos+32,1,ppBase[ppfraction],ppShadow[ppfraction]])
end end
else else
textpos.push(["-",316,yPos,0,moveBase,moveShadow]) textpos.push(["-",316,yPos,0,moveBase,moveShadow])
@@ -703,47 +704,7 @@ class PokemonSummary_Scene
pbDrawImagePositions(overlay,imagepos) pbDrawImagePositions(overlay,imagepos)
end end
def drawSelectedMove(moveToLearn,moveid) def drawPageFourSelecting(move_to_learn)
# Draw all of page four, except selected move's details
drawMoveSelection(moveToLearn)
# Set various values
overlay = @sprites["overlay"].bitmap
base = Color.new(64,64,64)
shadow = Color.new(176,176,176)
@sprites["pokemon"].visible = false if @sprites["pokemon"]
@sprites["pokeicon"].pokemon = @pokemon
@sprites["pokeicon"].visible = true
@sprites["itemicon"].visible = false if @sprites["itemicon"]
# Get data for selected move
moveData = pbGetMoveData(moveid)
basedamage = moveData[MoveData::BASE_DAMAGE]
category = moveData[MoveData::CATEGORY]
accuracy = moveData[MoveData::ACCURACY]
textpos = []
# Write power and accuracy values for selected move
if basedamage==0 # Status move
textpos.push(["---",216,154,1,base,shadow])
elsif basedamage==1 # Variable power move
textpos.push(["???",216,154,1,base,shadow])
else
textpos.push([sprintf("%d",basedamage),216,154,1,base,shadow])
end
if accuracy==0
textpos.push(["---",216,186,1,base,shadow])
else
textpos.push([sprintf("%d%",accuracy),216+overlay.text_size("%").width,186,1,base,shadow])
end
# Draw all text
pbDrawTextPositions(overlay,textpos)
# Draw selected move's damage category icon
imagepos = [["Graphics/Pictures/category",166,124,0,category*28,64,28]]
pbDrawImagePositions(overlay,imagepos)
# Draw selected move's description
drawTextEx(overlay,4,218,230,5,
pbGetMessage(MessageTypes::MoveDescriptions,moveid),base,shadow)
end
def drawMoveSelection(moveToLearn)
overlay = @sprites["overlay"].bitmap overlay = @sprites["overlay"].bitmap
overlay.clear overlay.clear
base = Color.new(248,248,248) base = Color.new(248,248,248)
@@ -759,7 +720,7 @@ class PokemonSummary_Scene
Color.new(144,72,24), # 1/4 of total PP or less Color.new(144,72,24), # 1/4 of total PP or less
Color.new(136,48,48)] # Zero PP Color.new(136,48,48)] # Zero PP
# Set background image # Set background image
if moveToLearn!=0 if move_to_learn
@sprites["background"].setBitmap("Graphics/Pictures/Summary/bg_learnmove") @sprites["background"].setBitmap("Graphics/Pictures/Summary/bg_learnmove")
else else
@sprites["background"].setBitmap("Graphics/Pictures/Summary/bg_movedetail") @sprites["background"].setBitmap("Graphics/Pictures/Summary/bg_movedetail")
@@ -774,24 +735,25 @@ class PokemonSummary_Scene
imagepos = [] imagepos = []
# Write move names, types and PP amounts for each known move # Write move names, types and PP amounts for each known move
yPos = 98 yPos = 98
yPos -= 76 if moveToLearn!=0 yPos -= 76 if move_to_learn
for i in 0...5 limit = (move_to_learn) ? Pokemon::MAX_MOVES + 1 : Pokemon::MAX_MOVES
for i in 0...limit
move = @pokemon.moves[i] move = @pokemon.moves[i]
if i==4 if i==Pokemon::MAX_MOVES
move = PBMove.new(moveToLearn) if moveToLearn!=0 move = move_to_learn
yPos += 20 yPos += 20
end end
if move && move.id>0 if move
imagepos.push(["Graphics/Pictures/types",248,yPos+2,0,move.type*28,64,28]) imagepos.push(["Graphics/Pictures/types",248,yPos+2,0,move.type*28,64,28])
textpos.push([PBMoves.getName(move.id),316,yPos,0,moveBase,moveShadow]) textpos.push([move.name,316,yPos,0,moveBase,moveShadow])
if move.totalpp>0 if move.total_pp>0
textpos.push([_INTL("PP"),342,yPos+32,0,moveBase,moveShadow]) textpos.push([_INTL("PP"),342,yPos+32,0,moveBase,moveShadow])
ppfraction = 0 ppfraction = 0
if move.pp==0; ppfraction = 3 if move.pp==0; ppfraction = 3
elsif move.pp*4<=move.totalpp; ppfraction = 2 elsif move.pp*4<=move.total_pp; ppfraction = 2
elsif move.pp*2<=move.totalpp; ppfraction = 1 elsif move.pp*2<=move.total_pp; ppfraction = 1
end end
textpos.push([sprintf("%d/%d",move.pp,move.totalpp),460,yPos+32,1,ppBase[ppfraction],ppShadow[ppfraction]]) textpos.push([sprintf("%d/%d",move.pp,move.total_pp),460,yPos+32,1,ppBase[ppfraction],ppShadow[ppfraction]])
end end
else else
textpos.push(["-",316,yPos,0,moveBase,moveShadow]) textpos.push(["-",316,yPos,0,moveBase,moveShadow])
@@ -813,6 +775,38 @@ class PokemonSummary_Scene
end end
end end
def drawSelectedMove(move_to_learn, selected_move)
# Draw all of page four, except selected move's details
drawPageFourSelecting(move_to_learn)
# Set various values
overlay = @sprites["overlay"].bitmap
base = Color.new(64, 64, 64)
shadow = Color.new(176, 176, 176)
@sprites["pokemon"].visible = false if @sprites["pokemon"]
@sprites["pokeicon"].pokemon = @pokemon
@sprites["pokeicon"].visible = true
@sprites["itemicon"].visible = false if @sprites["itemicon"]
textpos = []
# Write power and accuracy values for selected move
case selected_move.base_damage
when 0 then textpos.push(["---", 216, 154, 1, base, shadow]) # Status move
when 1 then textpos.push(["???", 216, 154, 1, base, shadow]) # Variable power move
else textpos.push([selected_move.base_damage.to_s, 216, 154, 1, base, shadow])
end
if selected_move.accuracy == 0
textpos.push(["---", 216, 186, 1, base, shadow])
else
textpos.push([sprintf("%d%", selected_move.accuracy), 216 + overlay.text_size("%").width, 186, 1, base, shadow])
end
# Draw all text
pbDrawTextPositions(overlay, textpos)
# Draw selected move's damage category icon
imagepos = [["Graphics/Pictures/category", 166, 124, 0, selected_move.category * 28, 64, 28]]
pbDrawImagePositions(overlay, imagepos)
# Draw selected move's description
drawTextEx(overlay, 4, 218, 230, 5, selected_move.description, base, shadow)
end
def drawPageFive def drawPageFive
overlay = @sprites["overlay"].bitmap overlay = @sprites["overlay"].bitmap
@sprites["uparrow"].visible = false @sprites["uparrow"].visible = false
@@ -903,7 +897,7 @@ class PokemonSummary_Scene
selmove = 0 selmove = 0
oldselmove = 0 oldselmove = 0
switching = false switching = false
drawSelectedMove(0,@pokemon.moves[selmove].id) drawSelectedMove(nil,@pokemon.moves[selmove])
loop do loop do
Graphics.update Graphics.update
Input.update Input.update
@@ -920,7 +914,7 @@ class PokemonSummary_Scene
switching = false switching = false
elsif Input.trigger?(Input::C) elsif Input.trigger?(Input::C)
pbPlayDecisionSE pbPlayDecisionSE
if selmove==4 if selmove==Pokemon::MAX_MOVES
break if !switching break if !switching
@sprites["movepresel"].visible = false @sprites["movepresel"].visible = false
switching = false switching = false
@@ -937,30 +931,28 @@ class PokemonSummary_Scene
@pokemon.moves[selmove] = tmpmove @pokemon.moves[selmove] = tmpmove
@sprites["movepresel"].visible = false @sprites["movepresel"].visible = false
switching = false switching = false
drawSelectedMove(0,@pokemon.moves[selmove].id) drawSelectedMove(nil,@pokemon.moves[selmove])
end end
end end
end end
elsif Input.trigger?(Input::UP) elsif Input.trigger?(Input::UP)
selmove -= 1 selmove -= 1
if selmove<4 && selmove>=@pokemon.numMoves if selmove<Pokemon::MAX_MOVES && selmove>=@pokemon.numMoves
selmove = @pokemon.numMoves-1 selmove = @pokemon.numMoves-1
end end
selmove = 0 if selmove>=4 selmove = 0 if selmove>=Pokemon::MAX_MOVES
selmove = @pokemon.numMoves-1 if selmove<0 selmove = @pokemon.numMoves-1 if selmove<0
@sprites["movesel"].index = selmove @sprites["movesel"].index = selmove
newmove = @pokemon.moves[selmove].id
pbPlayCursorSE pbPlayCursorSE
drawSelectedMove(0,newmove) drawSelectedMove(nil,@pokemon.moves[selmove])
elsif Input.trigger?(Input::DOWN) elsif Input.trigger?(Input::DOWN)
selmove += 1 selmove += 1
selmove = 0 if selmove<4 && selmove>=@pokemon.numMoves selmove = 0 if selmove<Pokemon::MAX_MOVES && selmove>=@pokemon.numMoves
selmove = 0 if selmove>=4 selmove = 0 if selmove>=Pokemon::MAX_MOVES
selmove = 4 if selmove<0 selmove = Pokemon::MAX_MOVES if selmove<0
@sprites["movesel"].index = selmove @sprites["movesel"].index = selmove
newmove = @pokemon.moves[selmove].id
pbPlayCursorSE pbPlayCursorSE
drawSelectedMove(0,newmove) drawSelectedMove(nil,@pokemon.moves[selmove])
end end
end end
@sprites["movesel"].visible=false @sprites["movesel"].visible=false
@@ -1194,16 +1186,17 @@ class PokemonSummary_Scene
return dorefresh return dorefresh
end end
def pbChooseMoveToForget(moveToLearn) def pbChooseMoveToForget(move_to_learn)
new_move = (move_to_learn) ? PBMove.new(move_to_learn) : nil
selmove = 0 selmove = 0
maxmove = (moveToLearn>0) ? 4 : 3 maxmove = (new_move) ? Pokemon::MAX_MOVES : Pokemon::MAX_MOVES - 1
loop do loop do
Graphics.update Graphics.update
Input.update Input.update
pbUpdate pbUpdate
if Input.trigger?(Input::B) if Input.trigger?(Input::B)
selmove = 4 selmove = Pokemon::MAX_MOVES
pbPlayCloseMenuSE if moveToLearn>0 pbPlayCloseMenuSE if new_move
break break
elsif Input.trigger?(Input::C) elsif Input.trigger?(Input::C)
pbPlayDecisionSE pbPlayDecisionSE
@@ -1211,24 +1204,24 @@ class PokemonSummary_Scene
elsif Input.trigger?(Input::UP) elsif Input.trigger?(Input::UP)
selmove -= 1 selmove -= 1
selmove = maxmove if selmove<0 selmove = maxmove if selmove<0
if selmove<4 && selmove>=@pokemon.numMoves if selmove<Pokemon::MAX_MOVES && selmove>=@pokemon.numMoves
selmove = @pokemon.numMoves-1 selmove = @pokemon.numMoves-1
end end
@sprites["movesel"].index = selmove @sprites["movesel"].index = selmove
newmove = (selmove==4) ? moveToLearn : @pokemon.moves[selmove].id selected_move = (selmove==Pokemon::MAX_MOVES) ? new_move : @pokemon.moves[selmove]
drawSelectedMove(moveToLearn,newmove) drawSelectedMove(new_move,selected_move)
elsif Input.trigger?(Input::DOWN) elsif Input.trigger?(Input::DOWN)
selmove += 1 selmove += 1
selmove = 0 if selmove>maxmove selmove = 0 if selmove>maxmove
if selmove<4 && selmove>=@pokemon.numMoves if selmove<Pokemon::MAX_MOVES && selmove>=@pokemon.numMoves
selmove = (moveToLearn>0) ? maxmove : 0 selmove = (new_move) ? maxmove : 0
end end
@sprites["movesel"].index = selmove @sprites["movesel"].index = selmove
newmove = (selmove==4) ? moveToLearn : @pokemon.moves[selmove].id selected_move = (selmove==Pokemon::MAX_MOVES) ? new_move : @pokemon.moves[selmove]
drawSelectedMove(moveToLearn,newmove) drawSelectedMove(new_move,selected_move)
end end
end end
return (selmove==4) ? -1 : selmove return (selmove==Pokemon::MAX_MOVES) ? -1 : selmove
end end
def pbScene def pbScene
@@ -1317,16 +1310,14 @@ class PokemonSummaryScreen
return ret return ret
end end
def pbStartForgetScreen(party,partyindex,moveToLearn) def pbStartForgetScreen(party,partyindex,move_to_learn)
ret = -1 ret = -1
@scene.pbStartForgetScene(party,partyindex,moveToLearn) @scene.pbStartForgetScene(party,partyindex,move_to_learn)
loop do loop do
ret = @scene.pbChooseMoveToForget(moveToLearn) ret = @scene.pbChooseMoveToForget(move_to_learn)
if ret>=0 && moveToLearn!=0 && pbIsHiddenMove?(party[partyindex].moves[ret].id) && !$DEBUG break if ret < 0 || !move_to_learn
break if $DEBUG || !party[partyindex].moves[ret].hidden_move?
pbMessage(_INTL("HM moves can't be forgotten now.")) { @scene.pbUpdate } pbMessage(_INTL("HM moves can't be forgotten now.")) { @scene.pbUpdate }
else
break
end
end end
@scene.pbEndScene @scene.pbEndScene
return ret return ret
@@ -1334,15 +1325,12 @@ class PokemonSummaryScreen
def pbStartChooseMoveScreen(party,partyindex,message) def pbStartChooseMoveScreen(party,partyindex,message)
ret = -1 ret = -1
@scene.pbStartForgetScene(party,partyindex,0) @scene.pbStartForgetScene(party,partyindex,nil)
pbMessage(message) { @scene.pbUpdate } pbMessage(message) { @scene.pbUpdate }
loop do loop do
ret = @scene.pbChooseMoveToForget(0) ret = @scene.pbChooseMoveToForget(nil)
if ret<0 break if ret >= 0
pbMessage(_INTL("You must choose a move!")) { @scene.pbUpdate } pbMessage(_INTL("You must choose a move!")) { @scene.pbUpdate }
else
break
end
end end
@scene.pbEndScene @scene.pbEndScene
return ret return ret
+11 -15
View File
@@ -236,7 +236,7 @@ class PokemonReadyMenu
def pbStartReadyMenu(moves,items) def pbStartReadyMenu(moves,items)
commands = [[],[]] # Moves, items commands = [[],[]] # Moves, items
for i in moves for i in moves
commands[0].push([i[0], PBMoves.getName(i[0]), true, i[1]]) commands[0].push([i[0], GameData::Move.get(i[0]).name, true, i[1]])
end end
commands[0].sort! { |a,b| a[1]<=>b[1] } commands[0].sort! { |a,b| a[1]<=>b[1] }
for i in items for i in items
@@ -250,7 +250,7 @@ class PokemonReadyMenu
if command[0]==0 # Use a move if command[0]==0 # Use a move
move = commands[0][command[1]][0] move = commands[0][command[1]][0]
user = $Trainer.party[commands[0][command[1]][3]] user = $Trainer.party[commands[0][command[1]][3]]
if isConst?(move,PBMoves,:FLY) if move == :FLY
ret = nil ret = nil
pbFadeOutInWithUpdate(99999,@scene.sprites) { pbFadeOutInWithUpdate(99999,@scene.sprites) {
pbHideMenu pbHideMenu
@@ -299,30 +299,26 @@ def pbUseKeyItem
moves = [:CUT, :DEFOG, :DIG, :DIVE, :FLASH, :FLY, :HEADBUTT, :ROCKCLIMB, moves = [:CUT, :DEFOG, :DIG, :DIVE, :FLASH, :FLY, :HEADBUTT, :ROCKCLIMB,
:ROCKSMASH, :SECRETPOWER, :STRENGTH, :SURF, :SWEETSCENT, :TELEPORT, :ROCKSMASH, :SECRETPOWER, :STRENGTH, :SURF, :SWEETSCENT, :TELEPORT,
:WATERFALL, :WHIRLPOOL] :WATERFALL, :WHIRLPOOL]
realmoves = [] real_moves = []
for i in moves moves.each do |move|
move = getID(PBMoves,i) $Trainer.pokemonParty.each_with_index do |pkmn, i|
next if move==0 next if !pkmn.hasMove?(move)
for j in 0...$Trainer.party.length real_moves.push([move, i]) if pbCanUseHiddenMove?(pkmn, move, false)
next if $Trainer.party[j].egg?
next if !$Trainer.party[j].hasMove?(move)
realmoves.push([move,j]) if pbCanUseHiddenMove?($Trainer.party[j],move,false)
break
end end
end end
realitems = [] real_items = []
for i in $PokemonBag.registeredItems for i in $PokemonBag.registeredItems
itm = GameData::Item.get(i).id itm = GameData::Item.get(i).id
realitems.push(itm) if $PokemonBag.pbHasItem?(itm) real_items.push(itm) if $PokemonBag.pbHasItem?(itm)
end end
if realitems.length==0 && realmoves.length==0 if real_items.length == 0 && real_moves.length == 0
pbMessage(_INTL("An item in the Bag can be registered to this key for instant use.")) pbMessage(_INTL("An item in the Bag can be registered to this key for instant use."))
else else
$game_temp.in_menu = true $game_temp.in_menu = true
$game_map.update $game_map.update
sscene = PokemonReadyMenu_Scene.new sscene = PokemonReadyMenu_Scene.new
sscreen = PokemonReadyMenu.new(sscene) sscreen = PokemonReadyMenu.new(sscene)
sscreen.pbStartReadyMenu(realmoves,realitems) sscreen.pbStartReadyMenu(real_moves, real_items)
$game_temp.in_menu = false $game_temp.in_menu = false
end end
end end
@@ -1839,11 +1839,10 @@ class PokemonStorageScreen
def pbChooseMove(pkmn,helptext,index=0) def pbChooseMove(pkmn,helptext,index=0)
movenames = [] movenames = []
for i in pkmn.moves for i in pkmn.moves
break if i.id==0 if i.total_pp<=0
if i.totalpp<=0 movenames.push(_INTL("{1} (PP: ---)",i.name))
movenames.push(_INTL("{1} (PP: ---)",PBMoves.getName(i.id)))
else else
movenames.push(_INTL("{1} (PP: {2}/{3})",PBMoves.getName(i.id),i.pp,i.totalpp)) movenames.push(_INTL("{1} (PP: {2}/{3})",i.name,i.pp,i.total_pp))
end end
end end
return @scene.pbShowCommands(helptext,movenames,index) return @scene.pbShowCommands(helptext,movenames,index)
@@ -51,7 +51,7 @@ class MoveRelearner_Scene
@pokemon=pokemon @pokemon=pokemon
@moves=moves @moves=moves
moveCommands=[] moveCommands=[]
moves.each { |m| moveCommands.push(PBMoves.getName(m)) } moves.each { |m| moveCommands.push(GameData::Move.get(m).name) }
# Create sprite hash # Create sprite hash
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height) @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999 @viewport.z=99999
@@ -81,7 +81,6 @@ class MoveRelearner_Scene
end end
def pbDrawMoveList def pbDrawMoveList
movesData = pbLoadMovesData
overlay=@sprites["overlay"].bitmap overlay=@sprites["overlay"].bitmap
overlay.clear overlay.clear
type1rect=Rect.new(0,@pokemon.type1*28,64,28) type1rect=Rect.new(0,@pokemon.type1*28,64,28)
@@ -100,19 +99,13 @@ class MoveRelearner_Scene
for i in 0...VISIBLEMOVES for i in 0...VISIBLEMOVES
moveobject=@moves[@sprites["commands"].top_item+i] moveobject=@moves[@sprites["commands"].top_item+i]
if moveobject if moveobject
moveData=movesData[moveobject] moveData=GameData::Move.get(moveobject)
if moveData imagepos.push(["Graphics/Pictures/types",12,yPos+2,0,moveData.type*28,64,28])
imagepos.push(["Graphics/Pictures/types",12,yPos+2,0, textpos.push([moveData.name,80,yPos,0,Color.new(248,248,248),Color.new(0,0,0)])
moveData[MoveData::TYPE]*28,64,28]) if moveData.total_pp>0
textpos.push([PBMoves.getName(moveobject),80,yPos,0, textpos.push([_INTL("PP"),112,yPos+32,0,Color.new(64,64,64),Color.new(176,176,176)])
Color.new(248,248,248),Color.new(0,0,0)]) textpos.push([_INTL("{1}/{1}",moveData.total_pp),230,yPos+32,1,
if moveData[MoveData::TOTAL_PP]>0
textpos.push([_INTL("PP"),112,yPos+32,0,
Color.new(64,64,64),Color.new(176,176,176)]) Color.new(64,64,64),Color.new(176,176,176)])
textpos.push([_INTL("{1}/{2}",
moveData[MoveData::TOTAL_PP],moveData[MoveData::TOTAL_PP]),230,yPos+32,1,
Color.new(64,64,64),Color.new(176,176,176)])
end
else else
textpos.push(["-",80,yPos,0,Color.new(64,64,64),Color.new(176,176,176)]) textpos.push(["-",80,yPos,0,Color.new(64,64,64),Color.new(176,176,176)])
textpos.push(["--",228,yPos+32,1,Color.new(64,64,64),Color.new(176,176,176)]) textpos.push(["--",228,yPos+32,1,Color.new(64,64,64),Color.new(176,176,176)])
@@ -123,10 +116,10 @@ class MoveRelearner_Scene
imagepos.push(["Graphics/Pictures/reminderSel", imagepos.push(["Graphics/Pictures/reminderSel",
0,78+(@sprites["commands"].index-@sprites["commands"].top_item)*64, 0,78+(@sprites["commands"].index-@sprites["commands"].top_item)*64,
0,0,258,72]) 0,0,258,72])
selMoveData=movesData[@moves[@sprites["commands"].index]] selMoveData=GameData::Move.get(@moves[@sprites["commands"].index])
basedamage=selMoveData[MoveData::BASE_DAMAGE] basedamage=selMoveData.base_damage
category=selMoveData[MoveData::CATEGORY] category=selMoveData.category
accuracy=selMoveData[MoveData::ACCURACY] accuracy=selMoveData.accuracy
textpos.push([_INTL("CATEGORY"),272,114,0,Color.new(248,248,248),Color.new(0,0,0)]) textpos.push([_INTL("CATEGORY"),272,114,0,Color.new(248,248,248),Color.new(0,0,0)])
textpos.push([_INTL("POWER"),272,146,0,Color.new(248,248,248),Color.new(0,0,0)]) textpos.push([_INTL("POWER"),272,146,0,Color.new(248,248,248),Color.new(0,0,0)])
textpos.push([basedamage<=1 ? basedamage==1 ? "???" : "---" : sprintf("%d",basedamage), textpos.push([basedamage<=1 ? basedamage==1 ? "???" : "---" : sprintf("%d",basedamage),
@@ -143,8 +136,7 @@ class MoveRelearner_Scene
imagepos.push(["Graphics/Pictures/reminderButtons",134,350,76,0,76,32]) imagepos.push(["Graphics/Pictures/reminderButtons",134,350,76,0,76,32])
end end
pbDrawImagePositions(overlay,imagepos) pbDrawImagePositions(overlay,imagepos)
drawTextEx(overlay,272,210,230,5, drawTextEx(overlay,272,210,230,5,selMoveData.description,
pbGetMessage(MessageTypes::MoveDescriptions,@moves[@sprites["commands"].index]),
Color.new(64,64,64),Color.new(176,176,176)) Color.new(64,64,64),Color.new(176,176,176))
end end
@@ -193,19 +185,16 @@ class MoveRelearnerScreen
@scene.pbStartScene(pokemon,moves) @scene.pbStartScene(pokemon,moves)
loop do loop do
move=@scene.pbChooseMove move=@scene.pbChooseMove
if move<=0 if move
if @scene.pbConfirm( if @scene.pbConfirm(_INTL("Teach {1}?",GameData::Move.get(move).name))
_INTL("Give up trying to teach a new move to {1}?",pokemon.name))
@scene.pbEndScene
return false
end
else
if @scene.pbConfirm(_INTL("Teach {1}?",PBMoves.getName(move)))
if pbLearnMove(pokemon,move) if pbLearnMove(pokemon,move)
@scene.pbEndScene @scene.pbEndScene
return true return true
end end
end end
elsif @scene.pbConfirm(_INTL("Give up trying to teach a new move to {1}?",pokemon.name))
@scene.pbEndScene
return false
end end
end end
end end
+1 -1
View File
@@ -26,7 +26,7 @@ class PokemonMartAdapter
item_name = getName(item) item_name = getName(item)
if GameData::Item.get(item).is_machine? if GameData::Item.get(item).is_machine?
machine = GameData::Item.get(item).move machine = GameData::Item.get(item).move
item_name = _INTL("{1} {2}", item_name, PBMoves.getName(machine)) item_name = _INTL("{1} {2}", item_name, GameData::Move.get(machine).name)
end end
return item_name return item_name
end end
@@ -412,7 +412,8 @@ def pbReceiveMysteryGift(id)
if item == :LEFTOVERS if item == :LEFTOVERS
pbMessage(_INTL("\\me[Item get]You obtained some \\c[1]{1}\\c[0]!\\wtnp[30]",itemname)) pbMessage(_INTL("\\me[Item get]You obtained some \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
elsif itm.is_machine? # TM or HM elsif itm.is_machine? # TM or HM
pbMessage(_INTL("\\me[Item get]You obtained \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,PBMoves.getName(itm.move))) pbMessage(_INTL("\\me[Item get]You obtained \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,
GameData::Move.get(itm.move).name))
elsif qty>1 elsif qty>1
pbMessage(_INTL("\\me[Item get]You obtained {1} \\c[1]{2}\\c[0]!\\wtnp[30]",qty,itemname)) pbMessage(_INTL("\\me[Item get]You obtained {1} \\c[1]{2}\\c[0]!\\wtnp[30]",qty,itemname))
elsif itemname.starts_with_vowel? elsif itemname.starts_with_vowel?
@@ -53,13 +53,11 @@ class PBPokemon
moves=pieces[4].split(/\s*,\s*/) moves=pieces[4].split(/\s*,\s*/)
moveid=[] moveid=[]
for i in 0...4 for i in 0...4
if (PBMoves.const_defined?(moves[i]) rescue false) move_data = GameData::Move.try_get(moves[i])
moveid.push(PBMoves.const_get(moves[i])) moveid.push(move_data.id) if move_data
end end
end moveid=[GameData::Move.get(1)] if moveid.length==0
moveid=[1] if moveid.length==0 return self.new(species, item, nature, moveid[0], moveid[1], moveid[2], moveid[3], evvalue)
return self.new(species,item,nature,
moveid[0],(moveid[1]||0),(moveid[2]||0),(moveid[3]||0),evvalue)
end end
def self.fromPokemon(pokemon) def self.fromPokemon(pokemon)
@@ -70,9 +68,12 @@ class PBPokemon
evvalue|=0x08 if pokemon.ev[3]>60 evvalue|=0x08 if pokemon.ev[3]>60
evvalue|=0x10 if pokemon.ev[4]>60 evvalue|=0x10 if pokemon.ev[4]>60
evvalue|=0x20 if pokemon.ev[5]>60 evvalue|=0x20 if pokemon.ev[5]>60
mov1 = (pokemon.moves[0]) ? pokemon.moves[0].id : nil
mov2 = (pokemon.moves[1]) ? pokemon.moves[1].id : nil
mov3 = (pokemon.moves[2]) ? pokemon.moves[2].id : nil
mov4 = (pokemon.moves[3]) ? pokemon.moves[3].id : nil
return self.new(pokemon.species,pokemon.item_id,pokemon.nature, return self.new(pokemon.species,pokemon.item_id,pokemon.nature,
pokemon.moves[0].id,pokemon.moves[1].id,pokemon.moves[2].id, mov1,mov2,mov3,mov4,evvalue)
pokemon.moves[3].id,evvalue)
end end
def self.constFromStr(mod,str) def self.constFromStr(mod,str)
@@ -97,10 +98,10 @@ class PBPokemon
species=self.constFromStr(PBSpecies,s[1]) species=self.constFromStr(PBSpecies,s[1])
item=s[2].to_sym item=s[2].to_sym
nature=self.constFromStr(PBNatures,s[3]) nature=self.constFromStr(PBNatures,s[3])
move1=self.constFromStr(PBMoves,s[4]) move1=GameData::Move.get(s[4]).id
move2=(s.length>=12) ? self.constFromStr(PBMoves,s[5]) : 0 move2=(s.length>=12) ? GameData::Move.get(s[5]).id : nil
move3=(s.length>=13) ? self.constFromStr(PBMoves,s[6]) : 0 move3=(s.length>=13) ? GameData::Move.get(s[6]).id : nil
move4=(s.length>=14) ? self.constFromStr(PBMoves,s[7]) : 0 move4=(s.length>=14) ? GameData::Move.get(s[7]).id : nil
ev=0 ev=0
slen=s.length-6 slen=s.length-6
ev|=0x01 if s[slen].to_i>0 ev|=0x01 if s[slen].to_i>0
@@ -129,7 +130,7 @@ class PBPokemon
def inspect def inspect
c1=getConstantName(PBSpecies,@species) c1=getConstantName(PBSpecies,@species)
c2=(@item) ? GameData::Item.get(@item).name : "" c2=(@item) ? GameData::Item.get(@item).id_to_s : ""
c3=getConstantName(PBNatures,@nature) c3=getConstantName(PBNatures,@nature)
evlist="" evlist=""
for i in 0...@ev for i in 0...@ev
@@ -138,10 +139,10 @@ class PBPokemon
evlist+=["HP","ATK","DEF","SPD","SA","SD"][i] evlist+=["HP","ATK","DEF","SPD","SA","SD"][i]
end end
end end
c4=(@move1==0) ? "" : getConstantName(PBMoves,@move1) c4=(@move1) ? GameData::Move.get(@move1).id_to_s : ""
c5=(@move2==0) ? "" : getConstantName(PBMoves,@move2) c5=(@move2) ? GameData::Move.get(@move2).id_to_s : ""
c6=(@move3==0) ? "" : getConstantName(PBMoves,@move3) c6=(@move3) ? GameData::Move.get(@move3).id_to_s : ""
c7=(@move4==0) ? "" : getConstantName(PBMoves,@move4) c7=(@move4) ? GameData::Move.get(@move4).id_to_s : ""
return "#{c1};#{c2};#{c3};#{evlist};#{c4},#{c5},#{c6},#{c7}" return "#{c1};#{c2};#{c3};#{evlist};#{c4},#{c5},#{c6},#{c7}"
end end
@@ -150,9 +151,7 @@ class PBPokemon
end end
def convertMove(move) def convertMove(move)
if isConst?(move,PBMoves,:RETURN) && hasConst?(PBMoves,:FRUSTRATION) move = :FRUSTRATION if move == :RETURN && GameData::Move.exists?(:FRUSTRATION)
move=getConst(PBMoves,:FRUSTRATION)
end
return move return move
end end
@@ -1,63 +1,47 @@
def pbRandomMove def pbRandomMove
keys = GameData::Move::DATA.keys.sort
loop do loop do
move=rand(PBMoves.maxValue)+1 move_id = keys[rand(keys.length)]
next if move>384 || isConst?(move,PBMoves,:SKETCH) || isConst?(move,PBMoves,:STRUGGLE) move = GameData::Move.get(move_id)
return move if PBMoves.getName(move)!="" next if move.id_number > 384 || move.id == :SKETCH || move.id == :STRUGGLE
return move.id
end end
end end
def addMove(moves,move,base) def addMove(moves,move,base)
data=moveData(move) data=GameData::Move.get(move)
count=base+1 count=base+1
if data.function=="000" && data.basedamage<=40 if data.function_code=="000" && data.base_damage<=40
count=base count=base
end end
if isConst?(move,PBMoves,:BUBBLE) || if [:BUBBLE, :BUBBLEBEAM].include?(data.id)
isConst?(move,PBMoves,:BUBBLEBEAM)
count=0 count=0
return return
end end
if data.basedamage<=30 || if data.base_damage<=30 || [:GROWL, :TAILWHIP, :LEER].include?(data.id)
isConst?(move,PBMoves,:GROWL) ||
isConst?(move,PBMoves,:TAILWHIP) ||
isConst?(move,PBMoves,:LEER)
count=base count=base
end end
if data.basedamage>=60 || if data.base_damage>=60 ||
isConst?(move,PBMoves,:REFLECT) || [:REFLECT, :LIGHTSCREEN, :SAFEGUARD, :SUBSTITUTE, :FAKEOUT].include?(data.id)
isConst?(move,PBMoves,:LIGHTSCREEN) ||
isConst?(move,PBMoves,:SAFEGUARD) ||
isConst?(move,PBMoves,:SUBSTITUTE) ||
isConst?(move,PBMoves,:FAKEOUT)
count=base+2 count=base+2
end end
if data.basedamage>=80 && isConst?(data.type,PBTypes,:NORMAL) if data.base_damage>=80 && isConst?(data.type,PBTypes,:NORMAL)
count=base+5 count=base+5
end end
if data.basedamage>=80 && isConst?(data.type,PBTypes,:NORMAL) if data.base_damage>=80 && isConst?(data.type,PBTypes,:NORMAL)
count=base+3 count=base+3
end end
if isConst?(move,PBMoves,:PROTECT) || if [:PROTECT, :DETECT, :TOXIC, :AERIALACE, :WILLOWISP, :SPORE, :THUNDERWAVE,
isConst?(move,PBMoves,:DETECT) || :HYPNOSIS, :CONFUSERAY, :ENDURE, :SWORDSDANCE].include?(data.id)
isConst?(move,PBMoves,:TOXIC) ||
isConst?(move,PBMoves,:AERIALACE) ||
isConst?(move,PBMoves,:WILLOWISP) ||
isConst?(move,PBMoves,:SPORE) ||
isConst?(move,PBMoves,:THUNDERWAVE) ||
isConst?(move,PBMoves,:HYPNOSIS) ||
isConst?(move,PBMoves,:CONFUSERAY) ||
isConst?(move,PBMoves,:ENDURE) ||
isConst?(move,PBMoves,:SWORDSDANCE)
count=base+3 count=base+3
end end
if !moves.include?(move) if !moves.include?(move.id)
count.times{moves.push(move)} count.times { moves.push(move.id) }
end end
end end
$legalMoves = [] $legalMoves = []
$legalMovesLevel = 0 $legalMovesLevel = 0
$moveData = []
$baseStatTotal = [] $baseStatTotal = []
$minimumLevel = [] $minimumLevel = []
$babySpecies = [] $babySpecies = []
@@ -84,7 +68,7 @@ def pbGetLegalMoves2(species,maxlevel)
babyEggMoves.each { |m| addMove(moves,m,2) } babyEggMoves.each { |m| addMove(moves,m,2) }
movedatas=[] movedatas=[]
for move in moves for move in moves
movedatas.push([move,moveData(move)]) movedatas.push([move,GameData::Move.get(move)])
end end
# Delete less powerful moves # Delete less powerful moves
deleteAll=proc { |a,item| deleteAll=proc { |a,item|
@@ -93,22 +77,22 @@ def pbGetLegalMoves2(species,maxlevel)
end end
} }
for move in moves for move in moves
md=moveData(move) md=GameData::Move.get(move)
for move2 in movedatas for move2 in movedatas
if md.function=="0A5" && move2[1].function=="000" && md.type==move2[1].type && if md.function_code=="0A5" && move2[1].function_code=="000" &&
md.basedamage>=move2[1].basedamage md.type==move2[1].type && md.base_damage>=move2[1].base_damage
deleteAll.call(moves,move2[0]) deleteAll.call(moves,move2[0])
elsif md.function==move2[1].function && md.basedamage==0 && elsif md.function_code==move2[1].function_code && md.base_damage==0 &&
md.accuracy>move2[1].accuracy md.accuracy>move2[1].accuracy
# Supersonic vs. Confuse Ray, etc. # Supersonic vs. Confuse Ray, etc.
deleteAll.call(moves,move2[0]) deleteAll.call(moves,move2[0])
elsif md.function=="006" && move2[1].function=="005" elsif md.function_code=="006" && move2[1].function_code=="005"
deleteAll.call(moves,move2[0]) deleteAll.call(moves,move2[0])
elsif md.function==move2[1].function && md.basedamage!=0 && elsif md.function_code==move2[1].function_code && md.base_damage!=0 &&
md.type==move2[1].type && md.type==move2[1].type &&
(md.totalpp==15 || md.totalpp==10 || md.totalpp==move2[1].totalpp) && (md.total_pp==15 || md.total_pp==10 || md.total_pp==move2[1].total_pp) &&
(md.basedamage>move2[1].basedamage || (md.base_damage>move2[1].base_damage ||
(md.basedamage==move2[1].basedamage && md.accuracy>move2[1].accuracy)) (md.base_damage==move2[1].base_damage && md.accuracy>move2[1].accuracy))
# Surf, Flamethrower, Thunderbolt, etc. # Surf, Flamethrower, Thunderbolt, etc.
deleteAll.call(moves,move2[0]) deleteAll.call(moves,move2[0])
end end
@@ -145,13 +129,6 @@ def evolutions(move)
return $evolutions[move] return $evolutions[move]
end end
def moveData(move)
if !$moveData[move]
$moveData[move]=PBMoveData.new(move)
end
return $moveData[move]
end
=begin =begin
[3/10] [3/10]
0-266 - 0-500 0-266 - 0-500
@@ -265,12 +242,12 @@ def pbArrangeByTier(pokemonlist,rule)
end end
def hasMorePowerfulMove(moves,thismove) def hasMorePowerfulMove(moves,thismove)
thisdata=moveData(thismove) thisdata=GameData::Move.get(thismove)
return false if thisdata.basedamage==0 return false if thisdata.base_damage==0
for move in moves for move in moves
next if move==0 next if !move
if moveData(move).type==thisdata.type && moveData = GameData::Move.get(move)
moveData(move).basedamage>thisdata.basedamage if moveData.type==thisdata.type && moveData.base_damage>thisdata.base_damage
return true return true
end end
end end
@@ -399,31 +376,30 @@ def pbRandomPokemonFromRule(rule,trainer)
end end
moves=$legalMoves[species] moves=$legalMoves[species]
sketch=false sketch=false
if isConst?(moves[0],PBMoves,:SKETCH) if moves[0] == :SKETCH
sketch=true sketch=true
moves[0]=pbRandomMove for i in 0...Pokemon::MAX_MOVES
moves[1]=pbRandomMove moves[i]=pbRandomMove
moves[2]=pbRandomMove end
moves[3]=pbRandomMove
end end
next if moves.length==0 next if moves.length==0
if (moves|[]).length<4 if (moves|[]).length<Pokemon::MAX_MOVES
moves=[getID(PBMoves,:TACKLE)] if moves.length==0 moves=[:TACKLE] if moves.length==0
moves|=[] moves|=[]
else else
newmoves=[] newmoves=[]
rest=(getConst(PBMoves,:REST) || -1) rest=GameData::Move.exists?(:REST) ? :REST : nil
spitup=(getConst(PBMoves,:SPITUP) || -1) spitup=GameData::Move.exists?(:SPITUP) ? :SPITUP : nil
swallow=(getConst(PBMoves,:SWALLOW) || -1) swallow=GameData::Move.exists?(:SWALLOW) ? :SWALLOW : nil
stockpile=(getConst(PBMoves,:STOCKPILE) || -1) stockpile=GameData::Move.exists?(:STOCKPILE) ? :STOCKPILE : nil
snore=(getConst(PBMoves,:SNORE) || -1) snore=GameData::Move.exists?(:SNORE) ? :SNORE : nil
sleeptalk=(getConst(PBMoves,:SLEEPTALK) || -1) sleeptalk=GameData::Move.exists?(:SLEEPTALK) ? :SLEEPTALK : nil
loop do loop do
newmoves.clear newmoves.clear
while newmoves.length<4 while newmoves.length<[moves.length,Pokemon::MAX_MOVES].min
m=moves[rand(moves.length)] m=moves[rand(moves.length)]
next if rand(2)==0 && hasMorePowerfulMove(moves,m) next if rand(2)==0 && hasMorePowerfulMove(moves,m)
newmoves.push(m) if !newmoves.include?(m) && m!=0 newmoves.push(m) if m && !newmoves.include?(m)
end end
if (newmoves.include?(spitup) || if (newmoves.include?(spitup) ||
newmoves.include?(swallow)) && !newmoves.include?(stockpile) newmoves.include?(swallow)) && !newmoves.include?(stockpile)
@@ -444,9 +420,9 @@ def pbRandomPokemonFromRule(rule,trainer)
hasSpecial=false hasSpecial=false
hasNormal=false hasNormal=false
for move in newmoves for move in newmoves
d=moveData(move) d=GameData::Move.get(move)
totalbasedamage+=d.basedamage totalbasedamage+=d.base_damage
if d.basedamage>=1 if d.base_damage>=1
hasNormal=true if isConst?(d.type,PBTypes,:NORMAL) hasNormal=true if isConst?(d.type,PBTypes,:NORMAL)
hasPhysical=true if d.category==0 hasPhysical=true if d.category==0
hasSpecial=true if d.category==1 hasSpecial=true if d.category==1
@@ -479,12 +455,7 @@ def pbRandomPokemonFromRule(rule,trainer)
break break
end end
end end
for i in 0...4 if item == :LIGHTCLAY && !moves.any? { |m| m == :LIGHTSCREEN || m = :REFLECT }
moves[i]=0 if !moves[i]
end
if item == :LIGHTCLAY &&
!moves.include?((getConst(PBMoves,:LIGHTSCREEN) || -1)) &&
!moves.include?((getConst(PBMoves,:REFLECT) || -1))
item = :LEFTOVERS item = :LEFTOVERS
end end
if item == :BLACKSLUDGE if item == :BLACKSLUDGE
@@ -494,13 +465,13 @@ def pbRandomPokemonFromRule(rule,trainer)
item = :LEFTOVERS item = :LEFTOVERS
end end
end end
if item == :HEATROCK && !moves.include?((getConst(PBMoves,:SUNNYDAY) || -1)) if item == :HEATROCK && !moves.any? { |m| m == :SUNNYDAY }
item = :LEFTOVERS item = :LEFTOVERS
end end
if item == :DAMPROCK && !moves.include?((getConst(PBMoves,:RAINDANCE) || -1)) if item == :DAMPROCK && !moves.any? { |m| m == :RAINDANCE }
item = :LEFTOVERS item = :LEFTOVERS
end end
if moves.include?((getConst(PBMoves,:REST) || -1)) if moves.any? { |m| m == :REST }
item = :LUMBERRY if rand(3)==0 item = :LUMBERRY if rand(3)==0
item = :CHESTOBERRY if rand(4)==0 item = :CHESTOBERRY if rand(4)==0
end end
@@ -819,8 +790,8 @@ end
def pbDecideWinnerEffectiveness(move,otype1,otype2,ability,scores) def pbDecideWinnerEffectiveness(move,otype1,otype2,ability,scores)
data=moveData(move) data=GameData::Move.get(move)
return 0 if data.basedamage==0 return 0 if data.base_damage==0
atype=data.type atype=data.type
typemod=PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE*PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE typemod=PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE*PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE
if ability != :LEVITATE || !isConst?(data.type,PBTypes,:GROUND) if ability != :LEVITATE || !isConst?(data.type,PBTypes,:GROUND)
@@ -853,7 +824,7 @@ def pbDecideWinnerScore(party0,party1,rating)
end end
for i in 0...party0.length for i in 0...party0.length
for move in party0[i].moves for move in party0[i].moves
next if move.id==0 next if !move
for j in 0...party1.length for j in 0...party1.length
score+=pbDecideWinnerEffectiveness(move.id, score+=pbDecideWinnerEffectiveness(move.id,
types1[j],types2[j],abilities[j],[-16,-8,0,4,12,20]) types1[j],types2[j],abilities[j],[-16,-8,0,4,12,20])
@@ -1138,18 +1109,15 @@ def isBattlePokemonDuplicate(pk,pk2)
if pk.species==pk2.species if pk.species==pk2.species
moves1=[] moves1=[]
moves2=[] moves2=[]
4.times{ for i in 0...Pokemon::MAX_MOVES
moves1.push(pk.moves[0].id) moves1.push((pk.moves[i]) ? pk.moves[i].id : nil)
moves2.push(pk.moves[1].id) moves2.push((pk2.moves[i]) ? pk2.moves[i].id : nil)
} end
moves1.sort! moves1.sort!
moves2.sort! moves2.sort!
if moves1[0]==moves2[0] && if moves1 == moves2
moves1[1]==moves2[1] &&
moves1[2]==moves2[2] &&
moves1[3]==moves2[3]
# Accept as same if moves are same and there are four moves each # Accept as same if moves are same and there are four moves each
return true if moves1[3]!=0 return true if moves1[Pokemon::MAX_MOVES - 1]
end end
return true if pk.item==pk2.item && return true if pk.item==pk2.item &&
pk.nature==pk2.nature && pk.nature==pk2.nature &&
@@ -79,6 +79,7 @@ def pbSetUpSystem
consts = [] if !consts consts = [] if !consts
GameData::Ability.load GameData::Ability.load
GameData::Item.load GameData::Item.load
GameData::Move.load
GameData::BerryPlant.load GameData::BerryPlant.load
GameData::Metadata.load GameData::Metadata.load
GameData::MapMetadata.load GameData::MapMetadata.load
@@ -270,7 +270,7 @@ def pbItemIconFile(item)
bitmapFileName = sprintf("Graphics/Icons/item%03d",itm.id_number) bitmapFileName = sprintf("Graphics/Icons/item%03d",itm.id_number)
if !pbResolveBitmap(bitmapFileName) && itm.is_machine? if !pbResolveBitmap(bitmapFileName) && itm.is_machine?
move = itm.move move = itm.move
type = pbGetMoveData(move,MoveData::TYPE) type = GameData::Move.get(move).type
bitmapFileName = sprintf("Graphics/Icons/itemMachine%s",getConstantName(PBTypes,type)) rescue nil bitmapFileName = sprintf("Graphics/Icons/itemMachine%s",getConstantName(PBTypes,type)) rescue nil
if !pbResolveBitmap(bitmapFileName) if !pbResolveBitmap(bitmapFileName)
bitmapFileName = sprintf("Graphics/Icons/itemMachine%03d",type) bitmapFileName = sprintf("Graphics/Icons/itemMachine%03d",type)
@@ -368,12 +368,8 @@ end
# Checks whether any Pokémon in the party knows the given move, and returns # Checks whether any Pokémon in the party knows the given move, and returns
# the first Pokémon it finds with that move, or nil if no Pokémon has that move. # the first Pokémon it finds with that move, or nil if no Pokémon has that move.
def pbCheckMove(move) def pbCheckMove(move)
move = getID(PBMoves,move) $Trainer.pokemonParty.each do |pkmn|
return nil if !move || move<=0 return pkmn if pkmn.hasMove?(move)
for i in $Trainer.pokemonParty
for j in i.moves
return i if j.id==move
end
end end
return nil return nil
end end
@@ -982,43 +982,39 @@ def pbTextEntry(helptext,minlength,maxlength,variableNumber)
$game_map.need_refresh = true if $game_map $game_map.need_refresh = true if $game_map
end end
def pbMoveTutorAnnotations(move,movelist=nil) def pbMoveTutorAnnotations(move, movelist = nil)
ret = [] ret = []
for i in 0...6 $Trainer.party.each_with_index do |pkmn, i|
ret[i] = nil if pkmn.egg?
next if i>=$Trainer.party.length ret[i] = _INTL("NOT ABLE")
found = false elsif pkmn.hasMove?(move)
for j in 0...4
if !$Trainer.party[i].egg? && $Trainer.party[i].moves[j].id==move
ret[i] = _INTL("LEARNED") ret[i] = _INTL("LEARNED")
found = true else
end species = pkmn.species
end if movelist && movelist.any? { |j| j == species }
next if found # Checked data from movelist given in parameter
species = $Trainer.party[i].species
if !$Trainer.party[i].egg? && movelist && movelist.any? { |j| j==species }
# Checked data from movelist
ret[i] = _INTL("ABLE") ret[i] = _INTL("ABLE")
elsif !$Trainer.party[i].egg? && $Trainer.party[i].compatibleWithMove?(move) elsif pkmn.compatibleWithMove?(move)
# Checked data from PBS/tm.txt # Checked data from PBS/tm.txt
ret[i] = _INTL("ABLE") ret[i] = _INTL("ABLE")
else else
ret[i] = _INTL("NOT ABLE") ret[i] = _INTL("NOT ABLE")
end end
end end
end
return ret return ret
end end
def pbMoveTutorChoose(move,movelist=nil,bymachine=false) def pbMoveTutorChoose(move,movelist=nil,bymachine=false)
ret = false ret = false
move = getID(PBMoves,move) move = GameData::Move.get(move).id
if movelist!=nil && movelist.is_a?(Array) if movelist!=nil && movelist.is_a?(Array)
for i in 0...movelist.length for i in 0...movelist.length
movelist[i] = getID(PBSpecies,movelist[i]) movelist[i] = GameData::Move.get(movelist[i]).id
end end
end end
pbFadeOutIn { pbFadeOutIn {
movename = PBMoves.getName(move) movename = GameData::Move.get(move).name
annot = pbMoveTutorAnnotations(move,movelist) annot = pbMoveTutorAnnotations(move,movelist)
scene = PokemonParty_Scene.new scene = PokemonParty_Scene.new
screen = PokemonPartyScreen.new(scene,$Trainer.party) screen = PokemonPartyScreen.new(scene,$Trainer.party)
@@ -1053,11 +1049,11 @@ def pbChooseMove(pokemon,variableNumber,nameVarNumber)
pbFadeOutIn { pbFadeOutIn {
scene = PokemonSummary_Scene.new scene = PokemonSummary_Scene.new
screen = PokemonSummaryScreen.new(scene) screen = PokemonSummaryScreen.new(scene)
ret = screen.pbStartForgetScreen([pokemon],0,0) ret = screen.pbStartForgetScreen([pokemon],0,nil)
} }
$game_variables[variableNumber] = ret $game_variables[variableNumber] = ret
if ret>=0 if ret>=0
$game_variables[nameVarNumber] = PBMoves.getName(pokemon.moves[ret].id) $game_variables[nameVarNumber] = pokemon.moves[ret].name
else else
$game_variables[nameVarNumber] = "" $game_variables[nameVarNumber] = ""
end end
+3 -4
View File
@@ -980,11 +980,10 @@ class PokemonDebugPartyScreen
def pbChooseMove(pkmn,text,index=0) def pbChooseMove(pkmn,text,index=0)
moveNames = [] moveNames = []
for i in pkmn.moves for i in pkmn.moves
break if i.id==0 if i.total_pp<=0
if i.totalpp<=0 moveNames.push(_INTL("{1} (PP: ---)",i.name))
moveNames.push(_INTL("{1} (PP: ---)",PBMoves.getName(i.id)))
else else
moveNames.push(_INTL("{1} (PP: {2}/{3})",PBMoves.getName(i.id),i.pp,i.totalpp)) moveNames.push(_INTL("{1} (PP: {2}/{3})",i.name,i.pp,i.total_pp))
end end
end end
return pbShowCommands(text,moveNames,index) return pbShowCommands(text,moveNames,index)
+13 -13
View File
@@ -347,7 +347,7 @@ module PokemonDebugMixin
#=========================================================================== #===========================================================================
when "teachmove" when "teachmove"
move = pbChooseMoveList move = pbChooseMoveList
if move!=0 if move
pbLearnMove(pkmn,move) pbLearnMove(pkmn,move)
pbRefreshSingle(pkmnid) pbRefreshSingle(pkmnid)
end end
@@ -355,7 +355,7 @@ module PokemonDebugMixin
when "forgetmove" when "forgetmove"
moveindex = pbChooseMove(pkmn,_INTL("Choose move to forget.")) moveindex = pbChooseMove(pkmn,_INTL("Choose move to forget."))
if moveindex>=0 if moveindex>=0
movename = PBMoves.getName(pkmn.moves[moveindex].id) movename = pkmn.moves[moveindex].name
pkmn.pbDeleteMoveAtIndex(moveindex) pkmn.pbDeleteMoveAtIndex(moveindex)
pbDisplay(_INTL("{1} forgot {2}.",pkmn.name,movename)) pbDisplay(_INTL("{1} forgot {2}.",pkmn.name,movename))
pbRefreshSingle(pkmnid) pbRefreshSingle(pkmnid)
@@ -371,11 +371,11 @@ module PokemonDebugMixin
loop do loop do
commands = [] commands = []
for i in pkmn.moves for i in pkmn.moves
break if i.id==0 break if !i.id
if i.totalpp<=0 if i.total_pp<=0
commands.push(_INTL("{1} (PP: ---)",PBMoves.getName(i.id))) commands.push(_INTL("{1} (PP: ---)",i.name))
else else
commands.push(_INTL("{1} (PP: {2}/{3})",PBMoves.getName(i.id),i.pp,i.totalpp)) commands.push(_INTL("{1} (PP: {2}/{3})",i.name,i.pp,i.total_pp))
end end
end end
commands.push(_INTL("Restore all PP")) commands.push(_INTL("Restore all PP"))
@@ -383,13 +383,13 @@ module PokemonDebugMixin
break if cmd<0 break if cmd<0
if cmd>=0 && cmd<commands.length-1 # Move if cmd>=0 && cmd<commands.length-1 # Move
move = pkmn.moves[cmd] move = pkmn.moves[cmd]
movename = PBMoves.getName(move.id) movename = move.name
if move.totalpp<=0 if move.total_pp<=0
pbDisplay(_INTL("{1} has infinite PP.",movename)) pbDisplay(_INTL("{1} has infinite PP.",movename))
else else
cmd2 = 0 cmd2 = 0
loop do loop do
msg = _INTL("{1}: PP {2}/{3} (PP Up {4}/3)",movename,move.pp,move.totalpp,move.ppup) msg = _INTL("{1}: PP {2}/{3} (PP Up {4}/3)",movename,move.pp,move.total_pp,move.ppup)
cmd2 = pbShowCommands(msg,[ cmd2 = pbShowCommands(msg,[
_INTL("Set PP"), _INTL("Set PP"),
_INTL("Full PP"), _INTL("Full PP"),
@@ -398,13 +398,13 @@ module PokemonDebugMixin
case cmd2 case cmd2
when 0 # Change PP when 0 # Change PP
params = ChooseNumberParams.new params = ChooseNumberParams.new
params.setRange(0,move.totalpp) params.setRange(0,move.total_pp)
params.setDefaultValue(move.pp) params.setDefaultValue(move.pp)
h = pbMessageChooseNumber( h = pbMessageChooseNumber(
_INTL("Set PP of {1} (max. {2}).",movename,move.totalpp),params) { pbUpdate } _INTL("Set PP of {1} (max. {2}).",movename,move.total_pp),params) { pbUpdate }
move.pp = h move.pp = h
when 1 # Full PP when 1 # Full PP
move.pp = move.totalpp move.pp = move.total_pp
when 2 # Change PP Up when 2 # Change PP Up
params = ChooseNumberParams.new params = ChooseNumberParams.new
params.setRange(0,3) params.setRange(0,3)
@@ -412,7 +412,7 @@ module PokemonDebugMixin
h = pbMessageChooseNumber( h = pbMessageChooseNumber(
_INTL("Set PP Up of {1} (max. 3).",movename),params) { pbUpdate } _INTL("Set PP Up of {1} (max. 3).",movename),params) { pbUpdate }
move.ppup = h move.ppup = h
move.pp = move.totalpp if move.pp>move.totalpp move.pp = move.total_pp if move.pp>move.total_pp
end end
end end
end end
+5 -5
View File
@@ -694,7 +694,7 @@ def pbItemEditor
itm.field_use, itm.field_use,
itm.battle_use, itm.battle_use,
itm.type, itm.type,
itm.move || 0 itm.move
] ]
if pbPropertyList(itm.id.to_s, data, items, true) if pbPropertyList(itm.id.to_s, data, items, true)
# Construct item hash # Construct item hash
@@ -709,7 +709,7 @@ def pbItemEditor
:field_use => data[6], :field_use => data[6],
:battle_use => data[7], :battle_use => data[7],
:type => data[8], :type => data[8],
:move => (data[9] > 0) ? data[9] : nil :move => data[9]
} }
# Add item's data to records # Add item's data to records
GameData::Item::DATA[itm.id_number] = GameData::Item::DATA[itm.id] = GameData::Item.new(item_hash) GameData::Item::DATA[itm.id_number] = GameData::Item::DATA[itm.id] = GameData::Item.new(item_hash)
@@ -938,7 +938,7 @@ def pbPokemonEditor
movelist.sort! { |a,b| (a[0]==b[0]) ? a[2]<=>b[2] : a[0]<=>b[0] } movelist.sort! { |a,b| (a[0]==b[0]) ? a[2]<=>b[2] : a[0]<=>b[0] }
originalEggMoves = pbGetSpeciesEggMoves(selection) originalEggMoves = pbGetSpeciesEggMoves(selection)
eggmovelist = [] eggmovelist = []
originalEggMoves.each { |m| eggmovelist.push(m) if m!=0 } originalEggMoves.each { |m| eggmovelist.push(m) }
regionallist = [] regionallist = []
for i in 0...regionalDexes.length for i in 0...regionalDexes.length
regionallist.push(regionalDexes[i][selection]) regionallist.push(regionalDexes[i][selection])
@@ -1162,12 +1162,12 @@ def pbRegionalDexEditor(dex)
refreshlist = false refreshlist = false
cmd = pbCommands3(cmdwin,commands,-1,cmd[1],true) cmd = pbCommands3(cmdwin,commands,-1,cmd[1],true)
case cmd[0] case cmd[0]
when 1 # Swap move up when 1 # Swap entry up
if cmd[1]<tdex.length-1 if cmd[1]<tdex.length-1
tdex[cmd[1]+1],tdex[cmd[1]] = tdex[cmd[1]],tdex[cmd[1]+1] tdex[cmd[1]+1],tdex[cmd[1]] = tdex[cmd[1]],tdex[cmd[1]+1]
refreshlist = true refreshlist = true
end end
when 2 # Swap move down when 2 # Swap entry down
if cmd[1]>0 if cmd[1]>0
tdex[cmd[1]-1],tdex[cmd[1]] = tdex[cmd[1]],tdex[cmd[1]-1] tdex[cmd[1]-1],tdex[cmd[1]] = tdex[cmd[1]],tdex[cmd[1]-1]
refreshlist = true refreshlist = true
+48 -57
View File
@@ -48,7 +48,7 @@ end
# Save ability data to PBS file # Save ability data to PBS file
#=============================================================================== #===============================================================================
def pbSaveAbilities def pbSaveAbilities
File.open("PBS/abilities.txt","wb") { |f| File.open("PBS/abilities.txt", "wb") { |f|
f.write(0xEF.chr) f.write(0xEF.chr)
f.write(0xBB.chr) f.write(0xBB.chr)
f.write(0xBF.chr) f.write(0xBF.chr)
@@ -72,39 +72,34 @@ end
# Save move data to PBS file # Save move data to PBS file
#=============================================================================== #===============================================================================
def pbSaveMoveData def pbSaveMoveData
movesData = pbLoadMovesData File.open("PBS/moves.txt", "wb") { |f|
return if !movesData
File.open("PBS/moves.txt","wb") { |f|
f.write(0xEF.chr) f.write(0xEF.chr)
f.write(0xBB.chr) f.write(0xBB.chr)
f.write(0xBF.chr) f.write(0xBF.chr)
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file.")) f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
f.write("\r\n") f.write("\r\n")
currentType = -1 current_type = -1
for i in 1..(PBMoves.maxValue rescue PBMoves.getCount-1 rescue pbGetMessageCount(MessageTypes::Moves)-1) GameData::Move.each do |m|
moveData = movesData[i] if current_type != m.type
next if !moveData # No move with that ID defined current_type = m.type
if currentType!=moveData[MoveData::TYPE]
currentType = moveData[MoveData::TYPE]
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
end end
f.write(sprintf("%d,%s,%s,%s,%d,%s,%s,%d,%d,%d,%s,%d,%s,%s", f.write(sprintf("%d,%s,%s,%s,%d,%s,%s,%d,%d,%d,%s,%d,%s,%s\r\n",
moveData[MoveData::ID], m.id_number,
moveData[MoveData::INTERNAL_NAME], csvQuote(m.id.to_s),
csvQuote(moveData[MoveData::NAME]), csvQuote(m.real_name),
csvQuote(moveData[MoveData::FUNCTION_CODE]), csvQuote(m.function_code),
moveData[MoveData::BASE_DAMAGE], m.base_damage,
(getConstantName(PBTypes,moveData[MoveData::TYPE]) rescue pbGetTypeConst(moveData[MoveData::TYPE]) rescue ""), (getConstantName(PBTypes, m.type) rescue pbGetTypeConst(m.type) rescue ""),
["Physical","Special","Status"][moveData[MoveData::CATEGORY]], ["Physical", "Special", "Status"][m.category],
moveData[MoveData::ACCURACY], m.accuracy,
moveData[MoveData::TOTAL_PP], m.total_pp,
moveData[MoveData::EFFECT_CHANCE], m.effect_chance,
(getConstantName(PBTargets,moveData[MoveData::TARGET]) rescue sprintf("%02X",moveData[MoveData::TARGET])), (getConstantName(PBTargets, m.target) rescue sprintf("%02X", m.target)),
moveData[MoveData::PRIORITY], m.priority,
csvQuote(moveData[MoveData::FLAGS]), csvQuote(m.flags),
csvQuoteAlways(moveData[MoveData::DESCRIPTION]) csvQuoteAlways(m.real_description)
)) ))
f.write("\r\n")
end end
} }
end end
@@ -185,7 +180,7 @@ end
# Save metadata data to PBS file # Save metadata data to PBS file
#=============================================================================== #===============================================================================
def pbSaveMetadata def pbSaveMetadata
File.open("PBS/metadata.txt","wb") { |f| File.open("PBS/metadata.txt", "wb") { |f|
f.write(0xEF.chr) f.write(0xEF.chr)
f.write(0xBB.chr) f.write(0xBB.chr)
f.write(0xBF.chr) f.write(0xBF.chr)
@@ -231,7 +226,7 @@ end
# Save item data to PBS file # Save item data to PBS file
#=============================================================================== #===============================================================================
def pbSaveItems def pbSaveItems
File.open("PBS/items.txt","wb") { |f| File.open("PBS/items.txt", "wb") { |f|
f.write(0xEF.chr) f.write(0xEF.chr)
f.write(0xBB.chr) f.write(0xBB.chr)
f.write(0xBF.chr) f.write(0xBF.chr)
@@ -243,11 +238,10 @@ def pbSaveItems
current_pocket = i.pocket current_pocket = i.pocket
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
end end
move_name = "" move_name = (i.move) ? GameData::Move.get(i.move).id.to_s : ""
if i.move sprintf_text = "%d,%s,%s,%s,%d,%d,%s,%d,%d,%d\r\n"
move_name = getConstantName(PBMoves, i.move) rescue pbGetMoveConst(i.move) rescue "" sprintf_text = "%d,%s,%s,%s,%d,%d,%s,%d,%d,%d,%s\r\n" if move_name != ""
end f.write(sprintf(sprintf_text,
f.write(sprintf("%d,%s,%s,%s,%d,%d,%s,%d,%d,%d,%s\r\n",
i.id_number, i.id_number,
csvQuote(i.id.to_s), csvQuote(i.id.to_s),
csvQuote(i.real_name), csvQuote(i.real_name),
@@ -270,7 +264,7 @@ end
# Save berry plant data to PBS file # Save berry plant data to PBS file
#=============================================================================== #===============================================================================
def pbSaveBerryPlants def pbSaveBerryPlants
File.open("PBS/berryplants.txt","wb") { |f| File.open("PBS/berryplants.txt", "wb") { |f|
f.write(0xEF.chr) f.write(0xEF.chr)
f.write(0xBB.chr) f.write(0xBB.chr)
f.write(0xBF.chr) f.write(0xBF.chr)
@@ -329,17 +323,18 @@ def pbSaveMachines
f.write(0xBF.chr) f.write(0xBF.chr)
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file.")) f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
f.write("\r\n") f.write("\r\n")
for i in 1...machines.length keys = machines.keys.sort { |a, b| GameData::Move.get(a).id_number <=> GameData::Move.get(b).id_number }
for i in 0...keys.length
Graphics.update if i%50==0 Graphics.update if i%50==0
Win32API.SetWindowText(_INTL("Writing move {1}/{2}",i,machines.length)) if i%20==0 Win32API.SetWindowText(_INTL("Writing move {1}/{2}",i,keys.length)) if i%20==0
next if !machines[i] next if !machines[keys[i]]
movename = getConstantName(PBMoves,i) rescue pbGetMoveConst(i) rescue nil movename = GameData::Move.get(keys[i]).id.to_s
next if !movename || movename=="" next if !movename || movename==""
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
f.write(sprintf("[%s]\r\n",movename)) f.write(sprintf("[%s]\r\n",movename))
x = [] x = []
for j in 0...machines[i].length machines[keys[i]].each do |species|
speciesname = getConstantName(PBSpecies,machines[i][j]) rescue pbGetSpeciesConst(machines[i][j]) rescue nil speciesname = getConstantName(PBSpecies,species) rescue pbGetSpeciesConst(species) rescue nil
next if !speciesname || speciesname=="" next if !speciesname || speciesname==""
x.push(speciesname) x.push(speciesname)
end end
@@ -487,7 +482,7 @@ def pbSaveTrainerBattles
if poke[TrainerData::MOVES] && poke[TrainerData::MOVES].length>0 if poke[TrainerData::MOVES] && poke[TrainerData::MOVES].length>0
movestring = "" movestring = ""
for i in 0...poke[TrainerData::MOVES].length for i in 0...poke[TrainerData::MOVES].length
movename = getConstantName(PBMoves,poke[TrainerData::MOVES][i]) rescue pbGetMoveConst(poke[TrainerData::MOVES][i]) rescue nil movename = GameData::Move.get(poke[TrainerData::MOVES][i]).id.to_s
next if !movename next if !movename
movestring.concat(",") if i>0 movestring.concat(",") if i>0
movestring.concat(movename) movestring.concat(movename)
@@ -747,7 +742,7 @@ def pbSavePokemonData
level = m[0] level = m[0]
move = m[1] move = m[1]
pokedata.write(",") if !first pokedata.write(",") if !first
cmove = getConstantName(PBMoves,move) rescue pbGetMoveConst(move) cmove = GameData::Move.get(move).id.to_s
pokedata.write(sprintf("%d,%s",level,cmove)) pokedata.write(sprintf("%d,%s",level,cmove))
first = false first = false
end end
@@ -759,7 +754,7 @@ def pbSavePokemonData
eggMoves[i].each do |m| eggMoves[i].each do |m|
next if !m || m==0 next if !m || m==0
pokedata.write(",") if !first pokedata.write(",") if !first
cmove = getConstantName(PBMoves,m) rescue pbGetMoveConst(m) cmove = GameData::Move.get(m).id.to_s
pokedata.write("#{cmove}") pokedata.write("#{cmove}")
first = false first = false
end end
@@ -1053,7 +1048,7 @@ def pbSavePokemonFormsData
incense = nil if incense==origdata["incense"] incense = nil if incense==origdata["incense"]
pokedexform = speciesData[i][SpeciesData::POKEDEX_FORM] || 0 # No nil check pokedexform = speciesData[i][SpeciesData::POKEDEX_FORM] || 0 # No nil check
megastone = speciesData[i][SpeciesData::MEGA_STONE] # No nil check megastone = speciesData[i][SpeciesData::MEGA_STONE] # No nil check
megamove = speciesData[i][SpeciesData::MEGA_MOVE] || 0 # No nil check megamove = speciesData[i][SpeciesData::MEGA_MOVE] # No nil check
unmega = speciesData[i][SpeciesData::UNMEGA_FORM] || 0 # No nil check unmega = speciesData[i][SpeciesData::UNMEGA_FORM] || 0 # No nil check
megamessage = speciesData[i][SpeciesData::MEGA_MESSAGE] || 0 # No nil check megamessage = speciesData[i][SpeciesData::MEGA_MESSAGE] || 0 # No nil check
pokedata.write("\#-------------------------------\r\n") pokedata.write("\#-------------------------------\r\n")
@@ -1064,8 +1059,8 @@ def pbSavePokemonFormsData
citem = GameData::Item.get(megastone).id.to_s citem = GameData::Item.get(megastone).id.to_s
pokedata.write("MegaStone = #{citem}\r\n") pokedata.write("MegaStone = #{citem}\r\n")
end end
if megamove>0 if megamove
cmove = getConstantName(PBMoves,megamove) rescue pbGetMoveConst(megamove) cmove = GameData::Move.get(megamove).id.to_s
pokedata.write("MegaMove = #{cmove}\r\n") pokedata.write("MegaMove = #{cmove}\r\n")
end end
pokedata.write("UnmegaForm = #{unmega}\r\n") if unmega>0 pokedata.write("UnmegaForm = #{unmega}\r\n") if unmega>0
@@ -1163,7 +1158,7 @@ def pbSavePokemonFormsData
level = m[0] level = m[0]
move = m[1] move = m[1]
pokedata.write(",") if !first pokedata.write(",") if !first
cmove = getConstantName(PBMoves,move) rescue pbGetMoveConst(move) cmove = GameData::Move.get(move).id.to_s
pokedata.write(sprintf("%d,%s",level,cmove)) pokedata.write(sprintf("%d,%s",level,cmove))
first = false first = false
end end
@@ -1189,7 +1184,7 @@ def pbSavePokemonFormsData
eggList.each do |m| eggList.each do |m|
next if !m || m==0 next if !m || m==0
pokedata.write(",") if !first pokedata.write(",") if !first
cmove = getConstantName(PBMoves,m) rescue pbGetMoveConst(m) cmove = GameData::Move.get(m).id.to_s
pokedata.write("#{cmove}") pokedata.write("#{cmove}")
first = false first = false
end end
@@ -1351,7 +1346,7 @@ def pbSaveShadowMoves
f.write(sprintf("%s = ",constname)) f.write(sprintf("%s = ",constname))
movenames = [] movenames = []
for m in move for m in move
movenames.push((getConstantName(PBMoves,m) rescue pbGetMoveConst(m) rescue nil)) movenames.push(GameData::Move.get(m).id.to_s)
end end
f.write(sprintf("%s\r\n",movenames.compact.join(","))) f.write(sprintf("%s\r\n",movenames.compact.join(",")))
end end
@@ -1443,14 +1438,10 @@ def pbFastInspect(pkmn,moves,species,items,natures)
evlist += evs[i] evlist += evs[i]
end end
end end
c4 = (moves[pkmn.move1]) ? moves[pkmn.move1] : c4 = (moves[pkmn.move1]) ? moves[pkmn.move1] : (moves[pkmn.move1] = GameData::Move.get(pkmn.move1).id_to_s)
(moves[pkmn.move1] = (getConstantName(PBMoves,pkmn.move1) rescue pbGetMoveConst(pkmn.move1))) c5 = (moves[pkmn.move2]) ? moves[pkmn.move2] : (moves[pkmn.move2] = GameData::Move.get(pkmn.move2).id_to_s)
c5 = (moves[pkmn.move2]) ? moves[pkmn.move2] : c6 = (moves[pkmn.move3]) ? moves[pkmn.move3] : (moves[pkmn.move3] = GameData::Move.get(pkmn.move3).id_to_s)
(moves[pkmn.move2] = (getConstantName(PBMoves,pkmn.move2) rescue pbGetMoveConst(pkmn.move2))) c7 = (moves[pkmn.move4]) ? moves[pkmn.move4] : (moves[pkmn.move4] = GameData::Move.get(pkmn.move4).id_to_s)
c6 = (moves[pkmn.move3]) ? moves[pkmn.move3] :
(moves[pkmn.move3] = (getConstantName(PBMoves,pkmn.move3) rescue pbGetMoveConst(pkmn.move3)))
c7 = (moves[pkmn.move4]) ? moves[pkmn.move4] :
(moves[pkmn.move4] = (getConstantName(PBMoves,pkmn.move4) rescue pbGetMoveConst(pkmn.move4)))
return "#{c1};#{c2};#{c3};#{evlist};#{c4},#{c5},#{c6},#{c7}" return "#{c1};#{c2};#{c3};#{evlist};#{c4},#{c5},#{c6},#{c7}"
end end
+163 -165
View File
@@ -296,17 +296,17 @@ end
module MoveProperty module MoveProperty
def self.set(_settingname,oldsetting) def self.set(_settingname, oldsetting)
ret = pbChooseMoveList((oldsetting) ? oldsetting : 1) ret = pbChooseMoveList(oldsetting || nil)
return (ret<=0) ? (oldsetting) ? oldsetting : 0 : ret return ret || oldsetting
end end
def self.defaultValue def self.defaultValue
return 0 return nil
end end
def self.format(value) def self.format(value)
return (value) ? PBMoves.getName(value) : "-" return (value && GameData::Move.exists?(value)) ? GameData::Move.get(value).real_name : "-"
end end
end end
@@ -317,9 +317,9 @@ class MoveProperty2
@pokemondata = pokemondata @pokemondata = pokemondata
end end
def set(_settingname,oldsetting) def set(_settingname, oldsetting)
ret = pbChooseMoveListForSpecies(@pokemondata[0],(oldsetting) ? oldsetting : 1) ret = pbChooseMoveListForSpecies(@pokemondata[TrainerData::SPECIES], oldsetting || nil)
return (ret>0) ? ret : (oldsetting) ? oldsetting : nil return ret || oldsetting
end end
def defaultValue def defaultValue
@@ -327,7 +327,7 @@ class MoveProperty2
end end
def format(value) def format(value)
return (value) ? PBMoves.getName(value) : "-" return (value && GameData::Move.exists?(value)) ? GameData::Move.get(value).real_name : "-"
end end
end end
@@ -399,14 +399,13 @@ class IVsProperty
for i in 0...6 for i in 0...6
oldsetting[i] = oldsetting[0] if !oldsetting[i] oldsetting[i] = oldsetting[0] if !oldsetting[i]
end end
properties = [ properties = []
[_INTL("HP"),LimitProperty2.new(@limit),_INTL("Individual values for the Pokémon's HP stat (0-{1}).",@limit)], properties[PBStats::HP] = [_INTL("HP"), LimitProperty2.new(@limit), _INTL("Individual values for the Pokémon's HP stat (0-{1}).", @limit)]
[_INTL("Attack"),LimitProperty2.new(@limit),_INTL("Individual values for the Pokémon's Attack stat (0-{1}).",@limit)], properties[PBStats::ATTACK] = [_INTL("Attack"), LimitProperty2.new(@limit), _INTL("Individual values for the Pokémon's Attack stat (0-{1}).", @limit)]
[_INTL("Defense"),LimitProperty2.new(@limit),_INTL("Individual values for the Pokémon's Defense stat (0-{1}).",@limit)], properties[PBStats::DEFENSE] = [_INTL("Defense"), LimitProperty2.new(@limit), _INTL("Individual values for the Pokémon's Defense stat (0-{1}).", @limit)]
[_INTL("Speed"),LimitProperty2.new(@limit),_INTL("Individual values for the Pokémon's Speed stat (0-{1}).",@limit)], properties[PBStats::SPATK] = [_INTL("Sp. Atk"), LimitProperty2.new(@limit), _INTL("Individual values for the Pokémon's Sp. Atk stat (0-{1}).", @limit)]
[_INTL("Sp. Atk"),LimitProperty2.new(@limit),_INTL("Individual values for the Pokémon's Sp. Atk stat (0-{1}).",@limit)], properties[PBStats::SPDEF] = [_INTL("Sp. Def"), LimitProperty2.new(@limit), _INTL("Individual values for the Pokémon's Sp. Def stat (0-{1}).", @limit)]
[_INTL("Sp. Def"),LimitProperty2.new(@limit),_INTL("Individual values for the Pokémon's Sp. Def stat (0-{1}).",@limit)] properties[PBStats::SPEED] = [_INTL("Speed"), LimitProperty2.new(@limit), _INTL("Individual values for the Pokémon's Speed stat (0-{1}).", @limit)]
]
pbPropertyList(settingname,oldsetting,properties,false) pbPropertyList(settingname,oldsetting,properties,false)
hasNonNil = false hasNonNil = false
hasAltVal = false hasAltVal = false
@@ -452,14 +451,13 @@ class EVsProperty
for i in 0...6 for i in 0...6
oldsetting[i] = oldsetting[0] if !oldsetting[i] oldsetting[i] = oldsetting[0] if !oldsetting[i]
end end
properties = [ properties = []
[_INTL("HP"),LimitProperty2.new(@limit),_INTL("Effort values for the Pokémon's HP stat (0-{1}).",@limit)], properties[PBStats::HP] = [_INTL("HP"), LimitProperty2.new(@limit), _INTL("Effort values for the Pokémon's HP stat (0-{1}).", @limit)]
[_INTL("Attack"),LimitProperty2.new(@limit),_INTL("Effort values for the Pokémon's Attack stat (0-{1}).",@limit)], properties[PBStats::ATTACK] = [_INTL("Attack"), LimitProperty2.new(@limit), _INTL("Effort values for the Pokémon's Attack stat (0-{1}).", @limit)]
[_INTL("Defense"),LimitProperty2.new(@limit),_INTL("Effort values for the Pokémon's Defense stat (0-{1}).",@limit)], properties[PBStats::DEFENSE] = [_INTL("Defense"), LimitProperty2.new(@limit), _INTL("Effort values for the Pokémon's Defense stat (0-{1}).", @limit)]
[_INTL("Speed"),LimitProperty2.new(@limit),_INTL("Effort values for the Pokémon's Speed stat (0-{1}).",@limit)], properties[PBStats::SPATK] = [_INTL("Sp. Atk"), LimitProperty2.new(@limit), _INTL("Effort values for the Pokémon's Sp. Atk stat (0-{1}).", @limit)]
[_INTL("Sp. Atk"),LimitProperty2.new(@limit),_INTL("Effort values for the Pokémon's Sp. Atk stat (0-{1}).",@limit)], properties[PBStats::SPDEF] = [_INTL("Sp. Def"), LimitProperty2.new(@limit), _INTL("Effort values for the Pokémon's Sp. Def stat (0-{1}).", @limit)]
[_INTL("Sp. Def"),LimitProperty2.new(@limit),_INTL("Effort values for the Pokémon's Sp. Def stat (0-{1}).",@limit)] properties[PBStats::SPEED] = [_INTL("Speed"), LimitProperty2.new(@limit), _INTL("Effort values for the Pokémon's Speed stat (0-{1}).", @limit)]
]
loop do loop do
pbPropertyList(settingname,oldsetting,properties,false) pbPropertyList(settingname,oldsetting,properties,false)
evtotal = 0 evtotal = 0
@@ -467,8 +465,7 @@ class EVsProperty
evtotal += oldsetting[i] if oldsetting[i] evtotal += oldsetting[i] if oldsetting[i]
end end
if evtotal>Pokemon::EV_LIMIT if evtotal>Pokemon::EV_LIMIT
pbMessage(_INTL("Total EVs ({1}) are greater than allowed ({2}). Please reduce them.", pbMessage(_INTL("Total EVs ({1}) are greater than allowed ({2}). Please reduce them.", evtotal, Pokemon::EV_LIMIT))
evtotal, Pokemon::EV_LIMIT))
else else
break break
end end
@@ -545,14 +542,14 @@ module PlayerProperty
def self.set(settingname,oldsetting) def self.set(settingname,oldsetting)
oldsetting = [0,"xxx","xxx","xxx","xxx","xxx","xxx","xxx"] if !oldsetting oldsetting = [0,"xxx","xxx","xxx","xxx","xxx","xxx","xxx"] if !oldsetting
properties = [ properties = [
[_INTL("Trainer Type"),TrainerTypeProperty,_INTL("Trainer type of this player.")], [_INTL("Trainer Type"), TrainerTypeProperty, _INTL("Trainer type of this player.")],
[_INTL("Sprite"),CharacterProperty,_INTL("Walking character sprite.")], [_INTL("Sprite"), CharacterProperty, _INTL("Walking character sprite.")],
[_INTL("Cycling"),CharacterProperty,_INTL("Cycling character sprite.")], [_INTL("Cycling"), CharacterProperty, _INTL("Cycling character sprite.")],
[_INTL("Surfing"),CharacterProperty,_INTL("Surfing character sprite.")], [_INTL("Surfing"), CharacterProperty, _INTL("Surfing character sprite.")],
[_INTL("Running"),CharacterProperty,_INTL("Running character sprite.")], [_INTL("Running"), CharacterProperty, _INTL("Running character sprite.")],
[_INTL("Diving"),CharacterProperty,_INTL("Diving character sprite.")], [_INTL("Diving"), CharacterProperty, _INTL("Diving character sprite.")],
[_INTL("Fishing"),CharacterProperty,_INTL("Fishing character sprite.")], [_INTL("Fishing"), CharacterProperty, _INTL("Fishing character sprite.")],
[_INTL("Field Move"),CharacterProperty,_INTL("Using a field move character sprite.")] [_INTL("Field Move"), CharacterProperty, _INTL("Using a field move character sprite.")]
] ]
pbPropertyList(settingname,oldsetting,properties,false) pbPropertyList(settingname,oldsetting,properties,false)
return oldsetting return oldsetting
@@ -717,7 +714,7 @@ end
module ItemNameProperty module ItemNameProperty
def self.set(settingname,oldsetting) def self.set(settingname, oldsetting)
return pbMessageFreeText(_INTL("Set the value for {1}.",settingname), return pbMessageFreeText(_INTL("Set the value for {1}.",settingname),
(oldsetting) ? oldsetting : "",false,30) (oldsetting) ? oldsetting : "",false,30)
end end
@@ -735,14 +732,14 @@ end
module PocketProperty module PocketProperty
def self.pocketnames def self.pocketnames
return [_INTL("Items"),_INTL("Medicine"),_INTL("Poké Balls"), return [_INTL("Items"), _INTL("Medicine"), _INTL("Poké Balls"),
_INTL("TMs & HMs"),_INTL("Berries"),_INTL("Mail"), _INTL("TMs & HMs"), _INTL("Berries"), _INTL("Mail"),
_INTL("Battle Items"),_INTL("Key Items")] _INTL("Battle Items"), _INTL("Key Items")]
end end
def self.set(_settingname,oldsetting) def self.set(_settingname, oldsetting)
cmd = pbMessage(_INTL("Choose a pocket for this item."),pocketnames(),-1) cmd = pbMessage(_INTL("Choose a pocket for this item."), pocketnames(), -1)
return (cmd>=0) ? cmd+1 : oldsetting return (cmd >= 0) ? cmd + 1 : oldsetting
end end
def self.defaultValue def self.defaultValue
@@ -750,8 +747,8 @@ module PocketProperty
end end
def self.format(value) def self.format(value)
return _INTL("No Pocket") if value==0 return _INTL("No Pocket") if value == 0
return (value) ? pocketnames[value-1] : value.inspect return (value) ? pocketnames[value - 1] : value.inspect
end end
end end
@@ -761,12 +758,12 @@ module BaseStatsProperty
def self.set(settingname,oldsetting) def self.set(settingname,oldsetting)
return oldsetting if !oldsetting return oldsetting if !oldsetting
properties = [] properties = []
properties[PBStats::HP] = _INTL("Base HP"),NonzeroLimitProperty.new(255),_INTL("Base HP stat of the Pokémon.") properties[PBStats::HP] = _INTL("Base HP"), NonzeroLimitProperty.new(255), _INTL("Base HP stat of the Pokémon.")
properties[PBStats::ATTACK] = _INTL("Base Attack"),NonzeroLimitProperty.new(255),_INTL("Base Attack stat of the Pokémon.") properties[PBStats::ATTACK] = _INTL("Base Attack"), NonzeroLimitProperty.new(255), _INTL("Base Attack stat of the Pokémon.")
properties[PBStats::DEFENSE] = _INTL("Base Defense"),NonzeroLimitProperty.new(255),_INTL("Base Defense stat of the Pokémon.") properties[PBStats::DEFENSE] = _INTL("Base Defense"), NonzeroLimitProperty.new(255), _INTL("Base Defense stat of the Pokémon.")
properties[PBStats::SPATK] = _INTL("Base Sp. Attack"),NonzeroLimitProperty.new(255),_INTL("Base Special Attack stat of the Pokémon.") properties[PBStats::SPATK] = _INTL("Base Sp. Attack"), NonzeroLimitProperty.new(255), _INTL("Base Special Attack stat of the Pokémon.")
properties[PBStats::SPDEF] = _INTL("Base Sp. Defense"),NonzeroLimitProperty.new(255),_INTL("Base Special Defense stat of the Pokémon.") properties[PBStats::SPDEF] = _INTL("Base Sp. Defense"), NonzeroLimitProperty.new(255), _INTL("Base Special Defense stat of the Pokémon.")
properties[PBStats::SPEED] = _INTL("Base Speed"),NonzeroLimitProperty.new(255),_INTL("Base Speed stat of the Pokémon.") properties[PBStats::SPEED] = _INTL("Base Speed"), NonzeroLimitProperty.new(255), _INTL("Base Speed stat of the Pokémon.")
if !pbPropertyList(settingname,oldsetting,properties,true) if !pbPropertyList(settingname,oldsetting,properties,true)
oldsetting = nil oldsetting = nil
else else
@@ -790,12 +787,12 @@ module EffortValuesProperty
def self.set(settingname,oldsetting) def self.set(settingname,oldsetting)
return oldsetting if !oldsetting return oldsetting if !oldsetting
properties = [] properties = []
properties[PBStats::HP] = _INTL("HP EVs"),LimitProperty.new(255),_INTL("Number of HP Effort Value points gained from the Pokémon.") properties[PBStats::HP] = [_INTL("HP EVs"), LimitProperty.new(255), _INTL("Number of HP Effort Value points gained from the Pokémon.")]
properties[PBStats::ATTACK] = _INTL("Attack EVs"),LimitProperty.new(255),_INTL("Number of Attack Effort Value points gained from the Pokémon.") properties[PBStats::ATTACK] = [_INTL("Attack EVs"), LimitProperty.new(255), _INTL("Number of Attack Effort Value points gained from the Pokémon.")]
properties[PBStats::DEFENSE] = _INTL("Defense EVs"),LimitProperty.new(255),_INTL("Number of Defense Effort Value points gained from the Pokémon.") properties[PBStats::DEFENSE] = [_INTL("Defense EVs"), LimitProperty.new(255), _INTL("Number of Defense Effort Value points gained from the Pokémon.")]
properties[PBStats::SPATK] = _INTL("Sp. Attack EVs"),LimitProperty.new(255),_INTL("Number of Special Attack Effort Value points gained from the Pokémon.") properties[PBStats::SPATK] = [_INTL("Sp. Attack EVs"), LimitProperty.new(255), _INTL("Number of Special Attack Effort Value points gained from the Pokémon.")]
properties[PBStats::SPDEF] = _INTL("Sp. Defense EVs"),LimitProperty.new(255),_INTL("Number of Special Defense Effort Value points gained from the Pokémon.") properties[PBStats::SPDEF] = [_INTL("Sp. Defense EVs"), LimitProperty.new(255), _INTL("Number of Special Defense Effort Value points gained from the Pokémon.")]
properties[PBStats::SPEED] = _INTL("Speed EVs"),LimitProperty.new(255),_INTL("Number of Speed Effort Value points gained from the Pokémon.") properties[PBStats::SPEED] = [_INTL("Speed EVs"), LimitProperty.new(255), _INTL("Number of Speed Effort Value points gained from the Pokémon.")]
if !pbPropertyList(settingname,oldsetting,properties,true) if !pbPropertyList(settingname,oldsetting,properties,true)
oldsetting = nil oldsetting = nil
else else
@@ -833,127 +830,133 @@ end
module MovePoolProperty module MovePoolProperty
def self.set(_settingname,oldsetting) def self.set(_settingname, oldsetting)
ret = oldsetting # Get all moves in move pool
cmdwin = pbListWindow([],200)
commands = []
realcmds = [] realcmds = []
realcmds.push([-1,0,-1]) realcmds.push([-1, nil, -1, "-"]) # Level, move ID, index in this list, name
for i in 0...oldsetting.length for i in 0...oldsetting.length
realcmds.push([oldsetting[i][0],oldsetting[i][1],i]) realcmds.push([oldsetting[i][0], oldsetting[i][1], i, GameData::Move.get(oldsetting[i][1]).real_name])
end end
refreshlist = true; oldsel = -1 # Edit move pool
cmd = [0,0] cmdwin = pbListWindow([], 200)
oldsel = -1
ret = oldsetting
cmd = [0, 0]
commands = []
refreshlist = true
loop do loop do
if refreshlist if refreshlist
realcmds.sort! { |a,b| (a[0]==b[0]) ? a[2]<=>b[2] : a[0]<=>b[0] } realcmds.sort! { |a, b| (a[0] == b[0]) ? a[2] <=> b[2] : a[0] <=> b[0] }
commands = [] commands = []
for i in 0...realcmds.length realcmds.each_with_index do |entry, i|
if realcmds[i][0]==-1 if entry[0] == -1
commands.push(_INTL("[ADD MOVE]")) commands.push(_INTL("[ADD MOVE]"))
else else
commands.push(_INTL("{1}: {2}",realcmds[i][0],PBMoves.getName(realcmds[i][1]))) commands.push(_INTL("{1}: {2}", entry[0], entry[3]))
end end
cmd[1] = i if oldsel>=0 && realcmds[i][2]==oldsel cmd[1] = i if oldsel >= 0 && entry[2] == oldsel
end end
end end
refreshlist = false; oldsel = -1 refreshlist = false
cmd = pbCommands3(cmdwin,commands,-1,cmd[1],true) oldsel = -1
if cmd[0]==1 # Swap move up cmd = pbCommands3(cmdwin, commands, -1, cmd[1], true)
if cmd[1]<realcmds.length-1 && realcmds[cmd[1]][0]==realcmds[cmd[1]+1][0] case cmd[0]
realcmds[cmd[1]+1][2],realcmds[cmd[1]][2] = realcmds[cmd[1]][2],realcmds[cmd[1]+1][2] when 1 # Swap move up (if both moves have the same level)
if cmd[1] < realcmds.length - 1 && realcmds[cmd[1]][0] == realcmds[cmd[1] + 1][0]
realcmds[cmd[1] + 1][2], realcmds[cmd[1]][2] = realcmds[cmd[1]][2], realcmds[cmd[1] + 1][2]
refreshlist = true refreshlist = true
end end
elsif cmd[0]==2 # Swap move down when 2 # Swap move down (if both moves have the same level)
if cmd[1]>0 && realcmds[cmd[1]][0]==realcmds[cmd[1]-1][0] if cmd[1] > 0 && realcmds[cmd[1]][0] == realcmds[cmd[1] - 1][0]
realcmds[cmd[1]-1][2],realcmds[cmd[1]][2] = realcmds[cmd[1]][2],realcmds[cmd[1]-1][2] realcmds[cmd[1] - 1][2], realcmds[cmd[1]][2] = realcmds[cmd[1]][2], realcmds[cmd[1] - 1][2]
refreshlist = true refreshlist = true
end end
elsif cmd[0]==0 when 0
if cmd[1]>=0 if cmd[1] >= 0 # Chose an entry
entry = realcmds[cmd[1]] entry = realcmds[cmd[1]]
if entry[0]==-1 # Add new move if entry[0] == -1 # Add new move
params = ChooseNumberParams.new params = ChooseNumberParams.new
params.setRange(0,PBExperience.maxLevel) params.setRange(0, PBExperience.maxLevel)
params.setDefaultValue(1) params.setDefaultValue(1)
params.setCancelValue(-1) params.setCancelValue(-1)
newlevel = pbMessageChooseNumber(_INTL("Choose a level."),params) newlevel = pbMessageChooseNumber(_INTL("Choose a level."),params)
if newlevel>=0 if newlevel >= 0
newmove = pbChooseMoveList newmove = pbChooseMoveList
if newmove>0 if newmove
havemove = -1 havemove = -1
for i in 0...realcmds.length realcmds.each do |e|
havemove = realcmds[i][2] if realcmds[i][0]==newlevel && realcmds[i][1]==newmove havemove = e[2] if e[0] == newlevel && e[1] == newmove
end end
if havemove>=0 if havemove >= 0
oldsel = havemove oldsel = havemove
else else
maxid = -1 maxid = -1
for i in realcmds; maxid = [maxid,i[2]].max; end realcmds.each { |e| maxid = [maxid, e[2]].max }
realcmds.push([newlevel,newmove,maxid+1]) realcmds.push([newlevel, newmove, maxid + 1, GameData::Move.get(newmove).real_name])
end end
refreshlist = true refreshlist = true
end end
end end
else # Edit move else # Edit existing move
cmd2 = pbMessage(_INTL("\\ts[]Do what with this move?"), case pbMessage(_INTL("\\ts[]Do what with this move?"),
[_INTL("Change level"),_INTL("Change move"),_INTL("Delete"),_INTL("Cancel")],4) [_INTL("Change level"), _INTL("Change move"), _INTL("Delete"), _INTL("Cancel")], 4)
if cmd2==0 when 0 # Change level
params = ChooseNumberParams.new params = ChooseNumberParams.new
params.setRange(0,PBExperience.maxLevel) params.setRange(0, PBExperience.maxLevel)
params.setDefaultValue(entry[0]) params.setDefaultValue(entry[0])
newlevel = pbMessageChooseNumber(_INTL("Choose a new level."),params) newlevel = pbMessageChooseNumber(_INTL("Choose a new level."), params)
if newlevel>=0 && newlevel!=entry[0] if newlevel >= 0 && newlevel != entry[0]
havemove = -1 havemove = -1
for i in 0...realcmds.length realcmds.each do |e|
havemove = realcmds[i][2] if realcmds[i][0]==newlevel && realcmds[i][1]==entry[1] havemove = e[2] if e[0] == newlevel && e[1] == entry[1]
end end
if havemove>=0 if havemove >= 0 # Move already known at new level; delete this move
realcmds[cmd[1]] = nil realcmds[cmd[1]] = nil
realcmds.compact! realcmds.compact!
oldsel = havemove oldsel = havemove
else else # Apply the new level
entry[0] = newlevel entry[0] = newlevel
oldsel = entry[2] oldsel = entry[2]
end end
refreshlist = true refreshlist = true
end end
elsif cmd2==1 when 1 # Change move
newmove = pbChooseMoveList(entry[1]) newmove = pbChooseMoveList(entry[1])
if newmove>0 if newmove
havemove = -1 havemove = -1
for i in 0...realcmds.length realcmds.each do |e|
havemove = realcmds[i][2] if realcmds[i][0]==entry[0] && realcmds[i][1]==newmove havemove = e[2] if e[0] == entry[0] && e[1] == newmove
end end
if havemove>=0 if havemove >= 0 # New move already known at level; delete this move
realcmds[cmd[1]] = nil realcmds[cmd[1]] = nil
realcmds.compact! realcmds.compact!
oldsel = havemove oldsel = havemove
else else # Apply the new move
entry[1] = newmove entry[1] = newmove
entry[3] = GameData::Move.get(newmove).real_name
oldsel = entry[2] oldsel = entry[2]
end end
refreshlist = true refreshlist = true
end end
elsif cmd2==2 when 2 # Delete
realcmds[cmd[1]] = nil realcmds[cmd[1]] = nil
realcmds.compact! realcmds.compact!
cmd[1] = [cmd[1],realcmds.length-1].min cmd[1] = [cmd[1], realcmds.length - 1].min
refreshlist = true refreshlist = true
end end
end end
else else # Cancel/quit
cmd2 = pbMessage(_INTL("Save changes?"), case pbMessage(_INTL("Save changes?"),
[_INTL("Yes"),_INTL("No"),_INTL("Cancel")],3) [_INTL("Yes"), _INTL("No"), _INTL("Cancel")], 3)
if cmd2==0 || cmd2==1 when 0
if cmd2==0
for i in 0...realcmds.length for i in 0...realcmds.length
realcmds[i].pop realcmds[i].pop # Remove name
realcmds[i] = nil if realcmds[i][0]==0 realcmds[i].pop # Remove index in this list
end end
realcmds.compact! realcmds.compact!
ret = realcmds ret = realcmds
end break
when 1
break break
end end
end end
@@ -970,8 +973,8 @@ module MovePoolProperty
def self.format(value) def self.format(value)
ret = "" ret = ""
for i in 0...value.length for i in 0...value.length
ret << "," if i>0 ret << "," if i > 0
ret << sprintf("#{value[i][0]},#{PBMoves.getName(value[i][1])}") ret << sprintf("%s,%s", value[i][0], GameData::Move.get(value[i][1]).real_name)
end end
return ret return ret
end end
@@ -980,83 +983,78 @@ end
module EggMovesProperty module EggMovesProperty
def self.set(_settingname,oldsetting) def self.set(_settingname, oldsetting)
ret = oldsetting # Get all egg moves
cmdwin = pbListWindow([],200)
commands = []
realcmds = [] realcmds = []
realcmds.push([0,_INTL("[ADD MOVE]"),-1]) realcmds.push([nil, _INTL("[ADD MOVE]"), -1])
for i in 0...oldsetting.length for i in 0...oldsetting.length
realcmds.push([oldsetting[i],PBMoves.getName(oldsetting[i]),0]) realcmds.push([oldsetting[i], GameData::Move.get(oldsetting[i]).real_name, 0])
end end
refreshlist = true; oldsel = -1 # Edit egg moves list
cmdwin = pbListWindow([], 200)
oldsel = nil
ret = oldsetting
cmd = 0 cmd = 0
commands = []
refreshlist = true
loop do loop do
if refreshlist if refreshlist
realcmds.sort! { |a,b| (a[2]==b[2]) ? a[1]<=>b[1] : a[2]<=>b[2] } realcmds.sort! { |a, b| (a[2] == b[2]) ? a[1] <=> b[1] : a[2] <=> b[2] }
commands = [] commands = []
for i in 0...realcmds.length realcmds.each_with_index do |entry, i|
commands.push(realcmds[i][1]) commands.push(entry[1])
cmd = i if oldsel>=0 && realcmds[i][0]==oldsel cmd = i if oldsel && entry[0] == oldsel
end end
end end
refreshlist = false; oldsel = -1 refreshlist = false
cmd = pbCommands2(cmdwin,commands,-1,cmd,true) oldsel = nil
if cmd>=0 cmd = pbCommands2(cmdwin, commands, -1, cmd, true)
if cmd >= 0 # Chose an entry
entry = realcmds[cmd] entry = realcmds[cmd]
if entry[0]==0 # Add new move if entry[2] == -1 # Add new move
newmove = pbChooseMoveList newmove = pbChooseMoveList
if newmove>0 if newmove
havemove = false if realcmds.any? { |e| e[0] == newmove }
for i in 0...realcmds.length oldsel = newmove # Already have move; just move cursor to it
havemove = true if realcmds[i][0]==newmove
end
if havemove
oldsel = newmove
else else
realcmds.push([newmove,PBMoves.getName(newmove),0]) realcmds.push([newmove, GameData::Move.get(newmove).name, 0])
end end
refreshlist = true refreshlist = true
end end
else # Edit move else # Edit move
cmd2 = pbMessage(_INTL("\\ts[]Do what with this move?"), case pbMessage(_INTL("\\ts[]Do what with this move?"),
[_INTL("Change move"),_INTL("Delete"),_INTL("Cancel")],3) [_INTL("Change move"), _INTL("Delete"), _INTL("Cancel")], 3)
if cmd2==0 when 0 # Change move
newmove = pbChooseMoveList(entry[0]) newmove = pbChooseMoveList(entry[0])
if newmove>0 if newmove
havemove = false if realcmds.any? { |e| e[0] == newmove } # Already have move; delete this one
for i in 0...realcmds.length
havemove = true if realcmds[i][0]==newmove
end
if havemove
realcmds[cmd] = nil realcmds[cmd] = nil
realcmds.compact! realcmds.compact!
cmd = [cmd,realcmds.length-1].min cmd = [cmd, realcmds.length - 1].min
else else # Change move
realcmds[cmd] = [newmove,PBMoves.getName(newmove),0] realcmds[cmd] = [newmove, GameData::Move.get(newmove).name, 0]
end end
oldsel = newmove oldsel = newmove
refreshlist = true refreshlist = true
end end
elsif cmd2==1 when 1 # Delete
realcmds[cmd] = nil realcmds[cmd] = nil
realcmds.compact! realcmds.compact!
cmd = [cmd,realcmds.length-1].min cmd = [cmd, realcmds.length - 1].min
refreshlist = true refreshlist = true
end end
end end
else else # Cancel/quit
cmd2 = pbMessage(_INTL("Save changes?"), case pbMessage(_INTL("Save changes?"),
[_INTL("Yes"),_INTL("No"),_INTL("Cancel")],3) [_INTL("Yes"), _INTL("No"), _INTL("Cancel")], 3)
if cmd2==0 || cmd2==1 when 0
if cmd2==0
for i in 0...realcmds.length for i in 0...realcmds.length
realcmds[i] = realcmds[i][0] realcmds[i] = realcmds[i][0]
realcmds[i] = nil if realcmds[i]==0
end end
realcmds.compact! realcmds.compact!
ret = realcmds ret = realcmds
end break
when 1
break break
end end
end end
@@ -1072,8 +1070,8 @@ module EggMovesProperty
def self.format(value) def self.format(value)
ret = "" ret = ""
for i in 0...value.length for i in 0...value.length
ret << "," if i>0 ret << "," if i > 0
ret << sprintf("#{PBMoves.getName(value[i])}") ret << GameData::Move.get(value[i]).real_name
end end
return ret return ret
end end
@@ -1254,7 +1252,7 @@ class EvolutionsProperty
case param_type case param_type
when :Item when :Item
newparam = pbChooseItemList newparam = pbChooseItemList
when :PBMoves when :Move
newparam = pbChooseMoveList newparam = pbChooseMoveList
when :PBSpecies when :PBSpecies
newparam = pbChooseSpeciesList newparam = pbChooseSpeciesList
@@ -1343,7 +1341,7 @@ class EvolutionsProperty
case param_type case param_type
when :Item when :Item
newparam = pbChooseItemList(entry[1]) newparam = pbChooseItemList(entry[1])
when :PBMoves when :Move
newparam = pbChooseMoveList(entry[1]) newparam = pbChooseMoveList(entry[1])
when :PBSpecies when :PBSpecies
newparam = pbChooseSpeciesList(entry[1]) newparam = pbChooseSpeciesList(entry[1])
+33 -36
View File
@@ -17,8 +17,7 @@ def pbGetLegalMoves(species)
tmdat = pbLoadSpeciesTMData tmdat = pbLoadSpeciesTMData
GameData::Item.each do |i| GameData::Item.each do |i|
next if !i.move next if !i.move
atk = getConst(PBMoves, i.move) moves.push(i.move) if tmdat[i.move] && tmdat[i.move].include?(species)
moves.push(atk) if tmdat[atk] && tmdat[atk].include?(species)
end end
babyspecies = pbGetBabySpecies(species) babyspecies = pbGetBabySpecies(species)
eggMoves = pbGetSpeciesEggMoves(babyspecies) eggMoves = pbGetSpeciesEggMoves(babyspecies)
@@ -228,7 +227,7 @@ def pbGetGenderConst(i)
end end
def pbGetHabitatConst(i) def pbGetHabitatConst(i)
ret = MakeshiftConsts.get(53,i,PBHabitats) ret = MakeshiftConsts.get(54,i,PBHabitats)
if !ret if !ret
ret = ["","Grassland","Forest","WatersEdge","Sea","Cave","Mountain", ret = ["","Grassland","Forest","WatersEdge","Sea","Cave","Mountain",
"RoughTerrain","Urban","Rare"] "RoughTerrain","Urban","Rare"]
@@ -243,9 +242,10 @@ end
# return MakeshiftConsts.get(MessageTypes::Abilities,i,PBAbilities) # return MakeshiftConsts.get(MessageTypes::Abilities,i,PBAbilities)
#end #end
def pbGetMoveConst(i) # Unused
return MakeshiftConsts.get(MessageTypes::Moves,i,PBMoves) #def pbGetMoveConst(i)
end # return MakeshiftConsts.get(MessageTypes::Moves,i,PBMoves)
#end
# Unused # Unused
#def pbGetItemConst(i) #def pbGetItemConst(i)
@@ -283,47 +283,44 @@ end
# is the ID of the move to initially select. # is the ID of the move to initially select.
def pbChooseMoveList(default=0) def pbChooseMoveList(default=0)
commands = [] commands = []
for i in 1..PBMoves.maxValue GameData::Move.each { |i| commands.push([i.id_number, i.name, i.id]) }
cname = getConstantName(PBMoves,i) rescue nil return pbChooseList(commands, default, nil, -1)
commands.push([i,PBMoves.getName(i)]) if cname
end
return pbChooseList(commands,default,0)
end end
def pbChooseMoveListForSpecies(species,defaultMoveID=0) def pbChooseMoveListForSpecies(species, defaultMoveID = nil)
cmdwin = pbListWindow([],200) cmdwin = pbListWindow([], 200)
commands = [] commands = []
moveDefault = 0 # Get all legal moves
legalMoves = pbGetLegalMoves(species) legalMoves = pbGetLegalMoves(species)
for move in legalMoves legalMoves.each do |move|
commands.push([move,PBMoves.getName(move)]) move_data = GameData::Move.get(move)
commands.push([move_data.id_number, move_data.name, move_data.id])
end end
commands.sort! { |a,b| a[1]<=>b[1] } commands.sort! { |a, b| a[1] <=> b[1] }
if defaultMoveID>0 moveDefault = 0
commands.each_with_index do |_item,i| if defaultMoveID
moveDefault = i if moveDefault==0 && i[0]==defaultMoveID commands.each_with_index do |_item, i|
moveDefault = i if moveDefault == 0 && i[2] == defaultMoveID
end end
end end
# Get all moves
commands2 = [] commands2 = []
for i in 1..PBMoves.maxValue GameData::Move.each do |move_data|
if PBMoves.getName(i)!=nil && PBMoves.getName(i)!="" commands2.push([move_data.id_number, move_data.name, move_data.id])
commands2.push([i,PBMoves.getName(i)]) end
end commands2.sort! { |a, b| a[0] <=> b[0] }
end if defaultMoveID
commands2.sort! { |a,b| a[1]<=>b[1] } commands2.each_with_index do |_item, i|
if defaultMoveID>0 moveDefault = i if moveDefault == 0 && i[2] == defaultMoveID
commands2.each_with_index do |_item,i|
moveDefault = i if moveDefault==0 && i[0]==defaultMoveID
end end
end end
# Choose from all moves
commands.concat(commands2) commands.concat(commands2)
realcommands = [] realcommands = []
for command in commands commands.each { |cmd| realcommands.push(cmd[1]) }
realcommands.push("#{command[1]}") ret = pbCommands2(cmdwin, realcommands, -1, moveDefault, true)
end
ret = pbCommands2(cmdwin,realcommands,-1,moveDefault,true)
cmdwin.dispose cmdwin.dispose
return (ret>=0) ? commands[ret][0] : 0 return (ret >= 0) ? commands[ret][2] : nil
end end
# Displays an alphabetically sorted list of all types, and returns the ID of the # Displays an alphabetically sorted list of all types, and returns the ID of the
@@ -352,7 +349,7 @@ end
# (or -1 if the selection was canceled). "default", if specified, is the ID of # (or -1 if the selection was canceled). "default", if specified, is the ID of
# the ability to initially select. Pressing Input::A will toggle the list # the ability to initially select. Pressing Input::A will toggle the list
# sorting between numerical and alphabetical. # sorting between numerical and alphabetical.
def pbChooseAbilityList(default = 0) def pbChooseAbilityList(default = nil)
commands = [] commands = []
GameData::Ability.each { |a| commands.push([a.id_number, a.name, a.id]) } GameData::Ability.each { |a| commands.push([a.id_number, a.name, a.id]) }
return pbChooseList(commands, default, nil, -1) return pbChooseList(commands, default, nil, -1)
@@ -364,7 +361,7 @@ def pbChooseBallList(defaultMoveID = -1)
moveDefault = 0 moveDefault = 0
for key in $BallTypes.keys for key in $BallTypes.keys
item = GameData::Item.try_get($BallTypes[key]) item = GameData::Item.try_get($BallTypes[key])
balls.push([key.to_i, item.name]) if item commands.push([key.to_i, item.name]) if item
end end
commands.sort! { |a, b| a[1] <=> b[1] } commands.sort! { |a, b| a[1] <=> b[1] }
if defaultMoveID >= 0 if defaultMoveID >= 0
@@ -133,7 +133,7 @@ class ByteArray
end end
end end
# Used for tm.txt data # Unused
class WordArray class WordArray
include Enumerable include Enumerable
+19 -14
View File
@@ -311,7 +311,7 @@ module Compiler
end end
return enumer.const_get(ret.to_sym) return enumer.const_get(ret.to_sym)
elsif enumer.is_a?(Symbol) || enumer.is_a?(String) elsif enumer.is_a?(Symbol) || enumer.is_a?(String)
if [:Ability, :Item].include?(enumer) if [:Ability, :Item, :Move].include?(enumer)
enumer = GameData.const_get(enumer.to_sym) enumer = GameData.const_get(enumer.to_sym)
begin begin
if ret == "" || !enumer.exists?(ret.to_sym) if ret == "" || !enumer.exists?(ret.to_sym)
@@ -353,7 +353,7 @@ module Compiler
return nil if ret=="" || !(enumer.const_defined?(ret) rescue false) return nil if ret=="" || !(enumer.const_defined?(ret) rescue false)
return enumer.const_get(ret.to_sym) return enumer.const_get(ret.to_sym)
elsif enumer.is_a?(Symbol) || enumer.is_a?(String) elsif enumer.is_a?(Symbol) || enumer.is_a?(String)
if [:Ability, :Item].include?(enumer) if [:Ability, :Item, :Move].include?(enumer)
enumer = GameData.const_get(enumer.to_sym) enumer = GameData.const_get(enumer.to_sym)
return nil if ret == "" || !enumer.exists?(ret.to_sym) return nil if ret == "" || !enumer.exists?(ret.to_sym)
return ret.to_sym return ret.to_sym
@@ -568,7 +568,7 @@ module Compiler
clonitem.sub!(/\s*$/,"") clonitem.sub!(/\s*$/,"")
itm = GameData::Item.try_get(clonitem) itm = GameData::Item.try_get(clonitem)
if !itm if !itm
raise _INTL("Undefined item constant name: %s\r\nName must consist only of letters, numbers and\r\nunderscores, and can't begin with a number.\r\nMake sure the item is defined in\r\nPBS/items.txt.\r\n{1}",FileLineData.linereport) raise _INTL("Undefined item constant name: %s\r\nName must consist only of letters, numbers and\r\nunderscores, and can't begin with a number.\r\nMake sure the item is defined in\r\nPBS/items.txt.\r\n{1}", item, FileLineData.linereport)
end end
return itm.id.to_s return itm.id.to_s
end end
@@ -582,11 +582,16 @@ module Compiler
return pbGetConst(PBSpecies,clonitem,_INTL("Undefined species constant name: [%s]\r\nName must consist only of letters, numbers, and\r\nunderscores and can't begin with a number.\r\nMake sure the name is defined in\r\nPBS/pokemon.txt.\r\n{1}",FileLineData.linereport)) return pbGetConst(PBSpecies,clonitem,_INTL("Undefined species constant name: [%s]\r\nName must consist only of letters, numbers, and\r\nunderscores and can't begin with a number.\r\nMake sure the name is defined in\r\nPBS/pokemon.txt.\r\n{1}",FileLineData.linereport))
end end
def parseMove(item) def parseMove(move, skip_unknown = false)
clonitem = item.upcase clonmove = move.upcase
clonitem.sub!(/^\s*/,"") clonmove.sub!(/^\s*/, "")
clonitem.sub!(/\s*$/,"") clonmove.sub!(/\s*$/, "")
return pbGetConst(PBMoves,clonitem,_INTL("Undefined move constant name: %s\r\nName must consist only of letters, numbers, and\r\nunderscores and can't begin with a number.\r\nMake sure the name is defined in\r\nPBS/moves.txt.\r\n{1}",FileLineData.linereport)) mov = GameData::Move.try_get(clonmove)
if !mov
return nil if skip_unknown
raise _INTL("Undefined move constant name: %s\r\nName must consist only of letters, numbers and\r\nunderscores, and can't begin with a number.\r\nMake sure the move is defined in\r\nPBS/moves.txt.\r\n{1}", move, FileLineData.linereport)
end
return mov.id.to_s
end end
# Unused # Unused
@@ -625,19 +630,19 @@ module Compiler
yield(_INTL("Compiling move data")) yield(_INTL("Compiling move data"))
compile_moves # Depends on PBTypes compile_moves # Depends on PBTypes
yield(_INTL("Compiling item data")) yield(_INTL("Compiling item data"))
compile_items # Depends on PBMoves compile_items # Depends on Move
yield(_INTL("Compiling berry plant data")) yield(_INTL("Compiling berry plant data"))
compile_berry_plants # Depends on Item compile_berry_plants # Depends on Item
yield(_INTL("Compiling Pokémon data")) yield(_INTL("Compiling Pokémon data"))
compile_pokemon # Depends on PBMoves, Item, PBTypes, Ability compile_pokemon # Depends on Move, Item, PBTypes, Ability
yield(_INTL("Compiling Pokémon forms data")) yield(_INTL("Compiling Pokémon forms data"))
compile_pokemon_forms # Depends on PBSpecies, PBMoves, Item, PBTypes, Ability compile_pokemon_forms # Depends on PBSpecies, Move, Item, PBTypes, Ability
yield(_INTL("Compiling machine data")) yield(_INTL("Compiling machine data"))
compile_move_compatibilities # Depends on PBSpecies, PBMoves compile_move_compatibilities # Depends on PBSpecies, Move
yield(_INTL("Compiling Trainer type data")) yield(_INTL("Compiling Trainer type data"))
compile_trainer_types # No dependencies compile_trainer_types # No dependencies
yield(_INTL("Compiling Trainer data")) yield(_INTL("Compiling Trainer data"))
compile_trainers # Depends on PBSpecies, Item, PBMoves compile_trainers # Depends on PBSpecies, Item, Move
yield(_INTL("Compiling phone data")) yield(_INTL("Compiling phone data"))
compile_phone # Depends on PBTrainers compile_phone # Depends on PBTrainers
yield(_INTL("Compiling metadata")) yield(_INTL("Compiling metadata"))
@@ -647,7 +652,7 @@ module Compiler
yield(_INTL("Compiling encounter data")) yield(_INTL("Compiling encounter data"))
compile_encounters # Depends on PBSpecies compile_encounters # Depends on PBSpecies
yield(_INTL("Compiling shadow moveset data")) yield(_INTL("Compiling shadow moveset data"))
compile_shadow_movesets # Depends on PBSpecies, PBMoves compile_shadow_movesets # Depends on PBSpecies, Move
yield(_INTL("Compiling animations")) yield(_INTL("Compiling animations"))
compile_animations compile_animations
yield(_INTL("Converting events")) yield(_INTL("Converting events"))
+58 -63
View File
@@ -505,62 +505,56 @@ module Compiler
# Compile move data # Compile move data
#============================================================================= #=============================================================================
def compile_moves def compile_moves
records = [] GameData::Move::DATA.clear
moveNames = [] move_names = []
moveDescs = [] move_descriptions = []
maxValue = 0 # Read each line of moves.txt at a time and compile it into an move
count = 0 pbCompilerEachPreppedLine("PBS/moves.txt") { |line, line_no|
pbCompilerEachPreppedLine("PBS/moves.txt") { |line,lineno| line = pbGetCsvRecord(line, line_no, [0, "vnssueeuuuyiss",
record = [] nil, nil, nil, nil, nil, PBTypes, ["Physical", "Special", "Status"],
lineRecord = pbGetCsvRecord(line,lineno,[0,"vnssueeuuuyiss", nil, nil, nil, PBTargets, nil, nil, nil
nil,nil,nil,nil,nil,PBTypes,["Physical","Special","Status"],
nil,nil,nil,PBTargets,nil,nil,nil
]) ])
if records[lineRecord[0]] move_number = line[0]
raise _INTL("Move ID number '{1}' is used twice.\r\n{2}",lineRecord[0],FileLineData.linereport) move_symbol = line[1].to_sym
if GameData::Move::DATA[move_number]
raise _INTL("Move ID number '{1}' is used twice.\r\n{2}", move_number, FileLineData.linereport)
elsif GameData::Move::DATA[move_symbol]
raise _INTL("Move ID '{1}' is used twice.\r\n{2}", move_symbol, FileLineData.linereport)
end end
if lineRecord[6]==2 && lineRecord[4]!=0 # Sanitise data
raise _INTL("Status moves must have a base damage of 0, use either Physical or Special.\r\n{1}",FileLineData.linereport) if line[6] == 2 && line[4] != 0
raise _INTL("Move {1} is defined as a Status move with a non-zero base damage.\r\n{2}", line[2], FileLineData.linereport)
elsif line[6] != 2 && line[4] == 0
print _INTL("Warning: Move {1} was defined as Physical or Special but had a base damage of 0. Changing it to a Status move.\r\n{2}", line[2], FileLineData.linereport)
line[6] = 2
end end
if lineRecord[6]!=2 && lineRecord[4]==0 # Construct move hash
print _INTL("Warning: Physical and special moves can't have a base damage of 0, changing to a Status move.\r\n{1}",FileLineData.linereport) move_hash = {
lineRecord[6] = 2 :id_number => move_number,
end :id => move_symbol,
record[MoveData::ID] = lineRecord[0] :name => line[2],
record[MoveData::INTERNAL_NAME] = lineRecord[1] :function_code => line[3],
record[MoveData::NAME] = lineRecord[2] :base_damage => line[4],
record[MoveData::FUNCTION_CODE] = lineRecord[3] :type => line[5],
record[MoveData::BASE_DAMAGE] = lineRecord[4] :category => line[6],
record[MoveData::TYPE] = lineRecord[5] :accuracy => line[7],
record[MoveData::CATEGORY] = lineRecord[6] :total_pp => line[8],
record[MoveData::ACCURACY] = lineRecord[7] :effect_chance => line[9],
record[MoveData::TOTAL_PP] = lineRecord[8] :target => line[10],
record[MoveData::EFFECT_CHANCE] = lineRecord[9] :priority => line[11],
record[MoveData::TARGET] = lineRecord[10] :flags => line[12],
record[MoveData::PRIORITY] = lineRecord[11] :description => line[13]
record[MoveData::FLAGS] = lineRecord[12]
record[MoveData::DESCRIPTION] = lineRecord[13]
maxValue = [maxValue,lineRecord[0]].max
count += 1
moveNames[lineRecord[0]] = lineRecord[2] # Name
moveDescs[lineRecord[0]] = lineRecord[13] # Description
records[lineRecord[0]] = record
} }
save_data(records,"Data/moves.dat") # Add move's data to records
MessageTypes.setMessages(MessageTypes::Moves,moveNames) GameData::Move::DATA[move_number] = GameData::Move::DATA[move_symbol] = GameData::Move.new(move_hash)
MessageTypes.setMessages(MessageTypes::MoveDescriptions,moveDescs) move_names[move_number] = move_hash[:name]
code = "class PBMoves\r\n" move_descriptions[move_number] = move_hash[:description]
for rec in records }
code += "#{rec[MoveData::INTERNAL_NAME]}=#{rec[MoveData::ID]}\r\n" if rec # Save all data
end GameData::Move.save
code += "def self.getName(id)\r\n" MessageTypes.setMessages(MessageTypes::Moves, move_names)
code += "id=getID(PBMoves,id)\r\n" MessageTypes.setMessages(MessageTypes::MoveDescriptions, move_descriptions)
code += "return pbGetMessage(MessageTypes::Moves,id); end\r\n" Graphics.update
code += "def self.getCount; return #{count}; end\r\n"
code += "def self.maxValue; return #{maxValue}; end\r\n"
code += "end\r\n"
eval(code, TOPLEVEL_BINDING)
pbAddScript(code,"PBMoves")
end end
#============================================================================= #=============================================================================
@@ -598,13 +592,13 @@ module Compiler
for i in 0...pbanims.length for i in 0...pbanims.length
next if !pbanims[i] next if !pbanims[i]
if pbanims[i].name[/^OppMove\:\s*(.*)$/] if pbanims[i].name[/^OppMove\:\s*(.*)$/]
if hasConst?(PBMoves,$~[1]) if GameData::Move.exists?($~[1])
moveid = PBMoves.const_get($~[1]) moveid = GameData::Move.get($~[1]).id_number
move2anim[1][moveid] = i move2anim[1][moveid] = i
end end
elsif pbanims[i].name[/^Move\:\s*(.*)$/] elsif pbanims[i].name[/^Move\:\s*(.*)$/]
if hasConst?(PBMoves,$~[1]) if GameData::Move.exists?($~[1])
moveid = PBMoves.const_get($~[1]) moveid = GameData::Move.get($~[1]).id_number
move2anim[0][moveid] = i move2anim[0][moveid] = i
end end
end end
@@ -1055,7 +1049,7 @@ module Compiler
lineno = 1 lineno = 1
havesection = false havesection = false
sectionname = nil sectionname = nil
sections = [] sections = {}
if safeExists?("PBS/tm.txt") if safeExists?("PBS/tm.txt")
f = File.open("PBS/tm.txt","rb") f = File.open("PBS/tm.txt","rb")
FileLineData.file = "PBS/tm.txt" FileLineData.file = "PBS/tm.txt"
@@ -1070,7 +1064,7 @@ module Compiler
if sections[sectionname] if sections[sectionname]
raise _INTL("TM section [{1}] is defined twice.\r\n{2}",sectionname,FileLineData.linereport) raise _INTL("TM section [{1}] is defined twice.\r\n{2}",sectionname,FileLineData.linereport)
end end
sections[sectionname] = WordArray.new sections[sectionname] = []
havesection = true havesection = true
else else
if sectionname==nil if sectionname==nil
@@ -1107,8 +1101,9 @@ module Compiler
value = value.split(",") value = value.split(",")
species = parseSpecies(key) species = parseSpecies(key)
moves = [] moves = []
for i in 0...[4,value.length].min for i in 0...[Pokemon::MAX_MOVES,value.length].min
moves.push((parseMove(value[i]) rescue nil)) move = parseMove(value[i], true)
moves.push(move) if move
end end
moves.compact! moves.compact!
sections[species] = moves if moves.length>0 sections[species] = moves if moves.length>0
@@ -1316,7 +1311,7 @@ module Compiler
raise _INTL("Bad level: {1} (must be 1-{2}).\r\n{3}",record[1],mLevel,FileLineData.linereport) raise _INTL("Bad level: {1} (must be 1-{2}).\r\n{3}",record[1],mLevel,FileLineData.linereport)
end end
when "Moves" when "Moves"
record = [record] if record.is_a?(Integer) record = [record] if record.is_a?(Symbol)
record.compact! record.compact!
when "Ability" when "Ability"
if record>5 if record>5
@@ -1407,8 +1402,8 @@ module Compiler
pokemonindex += 1 pokemonindex += 1
trainers[trainerindex][3][pokemonindex] = [] trainers[trainerindex][3][pokemonindex] = []
record = pbGetCsvRecord(line,lineno, record = pbGetCsvRecord(line,lineno,
[0,"evEEEEEUEUBEUUSBU",PBSpecies,nil,Item,PBMoves,PBMoves,PBMoves, [0,"evEEEEEUEUBEUUSBU",PBSpecies,nil,:Item,:Move,:Move,:Move,:Move,
PBMoves,nil,{"M"=>0,"m"=>0,"Male"=>0,"male"=>0, nil,{"M"=>0,"m"=>0,"Male"=>0,"male"=>0,
"0"=>0,"F"=>1,"f"=>1,"Female"=>1,"female"=>1, "0"=>0,"F"=>1,"f"=>1,"Female"=>1,"female"=>1,
"1"=>1},nil,nil,PBNatures,nil,nil,nil,nil,nil]) "1"=>1},nil,nil,PBNatures,nil,nil,nil,nil,nil])
# Error checking (the +3 is for properties after the four moves) # Error checking (the +3 is for properties after the four moves)