mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 14:14:59 +00:00
More revamping and rearranging
This commit is contained in:
@@ -155,6 +155,20 @@ MultipleForms.register(:CASTFORM,{
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:GROUDON,{
|
||||
"getPrimalForm" => proc { |pkmn|
|
||||
next 1 if pkmn.hasItem?(:REDORB)
|
||||
next
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:KYOGRE,{
|
||||
"getPrimalForm" => proc { |pkmn|
|
||||
next 1 if pkmn.hasItem?(:BLUEORB)
|
||||
next
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:BURMY,{
|
||||
"getFormOnCreation" => proc { |pkmn|
|
||||
case pbGetEnvironment
|
||||
@@ -217,9 +231,9 @@ MultipleForms.register(:ROTOM,{
|
||||
# Turned back into the base form; forget form-specific moves
|
||||
if move_index >= 0
|
||||
move_name = pkmn.moves[move_index].name
|
||||
pkmn.pbDeleteMoveAtIndex(move_index)
|
||||
pkmn.forget_move_at_index(move_index)
|
||||
pbMessage(_INTL("{1} forgot {2}...", pkmn.name, move_name))
|
||||
pkmn.pbLearnMove(:THUNDERSHOCK) if pkmn.numMoves == 0
|
||||
pkmn.learn_move(:THUNDERSHOCK) if pkmn.numMoves == 0
|
||||
end
|
||||
else
|
||||
# Turned into an alternate form; try learning that form's unique move
|
||||
@@ -234,9 +248,9 @@ MultipleForms.register(:ROTOM,{
|
||||
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, new_move_name))
|
||||
else
|
||||
pkmn.pbDeleteMoveAtIndex(move_index)
|
||||
pkmn.forget_move_at_index(move_index)
|
||||
pbMessage(_INTL("{1} forgot {2}...", pkmn.name, old_move_name))
|
||||
pkmn.pbLearnMove(:THUNDERSHOCK) if pkmn.numMoves == 0
|
||||
pkmn.learn_move(:THUNDERSHOCK) if pkmn.numMoves == 0
|
||||
end
|
||||
else
|
||||
# Just try to learn this form's unique move
|
||||
@@ -397,12 +411,13 @@ MultipleForms.copy(:FLABEBE,:FLOETTE,:FLORGES)
|
||||
|
||||
MultipleForms.register(:FURFROU,{
|
||||
"getForm" => proc { |pkmn|
|
||||
if !pkmn.formTime || pbGetTimeNow.to_i>pkmn.formTime.to_i+60*60*24*5 # 5 days
|
||||
if !pkmn.time_form_set ||
|
||||
pbGetTimeNow.to_i > pkmn.time_form_set.to_i + 60 * 60 * 24 * 5 # 5 days
|
||||
next 0
|
||||
end
|
||||
},
|
||||
"onSetForm" => proc { |pkmn,form,oldForm|
|
||||
pkmn.formTime = (form>0) ? pbGetTimeNow.to_i : nil
|
||||
pkmn.time_form_set = (form > 0) ? pbGetTimeNow.to_i : nil
|
||||
}
|
||||
})
|
||||
|
||||
@@ -450,12 +465,13 @@ MultipleForms.register(:ZYGARDE,{
|
||||
|
||||
MultipleForms.register(:HOOPA,{
|
||||
"getForm" => proc { |pkmn|
|
||||
if !pkmn.formTime || pbGetTimeNow.to_i>pkmn.formTime.to_i+60*60*24*3 # 3 days
|
||||
if !pkmn.time_form_set ||
|
||||
pbGetTimeNow.to_i > pkmn.time_form_set.to_i + 60 * 60 * 24 * 3 # 3 days
|
||||
next 0
|
||||
end
|
||||
},
|
||||
"onSetForm" => proc { |pkmn,form,oldForm|
|
||||
pkmn.formTime = (form>0) ? pbGetTimeNow.to_i : nil
|
||||
pkmn.time_form_set = (form>0) ? pbGetTimeNow.to_i : nil
|
||||
}
|
||||
})
|
||||
|
||||
@@ -467,7 +483,7 @@ MultipleForms.register(:ORICORIO,{
|
||||
|
||||
MultipleForms.register(:ROCKRUFF,{
|
||||
"getForm" => proc { |pkmn|
|
||||
next if pkmn.formSimple>=2 # Own Tempo Rockruff cannot become another form
|
||||
next if pkmn.form_simple >= 2 # Own Tempo Rockruff cannot become another form
|
||||
next 1 if PBDayNight.isNight?
|
||||
next 0
|
||||
}
|
||||
@@ -561,9 +577,9 @@ MultipleForms.register(:NECROZMA,{
|
||||
end
|
||||
if move_index >= 0
|
||||
move_name = pkmn.moves[move_index].name
|
||||
pkmn.pbDeleteMoveAtIndex(move_index)
|
||||
pkmn.forget_move_at_index(move_index)
|
||||
pbMessage(_INTL("{1} forgot {2}...", pkmn.name, move_name))
|
||||
pkmn.pbLearnMove(:CONFUSION) if pkmn.numMoves == 0
|
||||
pkmn.learn_move(:CONFUSION) if pkmn.numMoves == 0
|
||||
end
|
||||
else
|
||||
# Turned into an alternate form; try learning that form's unique move
|
||||
@@ -581,7 +597,7 @@ MultipleForms.register(:NECROZMA,{
|
||||
# evolve into different forms depending on the location where they evolved.
|
||||
MultipleForms.register(:PIKACHU, {
|
||||
"getForm" => proc { |pkmn|
|
||||
next if pkmn.formSimple >= 2
|
||||
next if pkmn.form_simple >= 2
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
next 1 if map_metadata && map_metadata.town_map_position &&
|
||||
map_metadata.town_map_position[0] == 1 # Tiall region
|
||||
@@ -16,80 +16,44 @@ critical hit.
|
||||
#===============================================================================
|
||||
# Purify a Shadow Pokémon.
|
||||
#===============================================================================
|
||||
def pbPurify(pokemon,scene)
|
||||
return if pokemon.heartgauge!=0 || !pokemon.shadow
|
||||
return if !pokemon.savedev && !pokemon.savedexp
|
||||
pokemon.shadow = false
|
||||
pokemon.giveRibbon(PBRibbons::NATIONAL)
|
||||
scene.pbDisplay(_INTL("{1} opened the door to its heart!",pokemon.name))
|
||||
def pbPurify(pkmn, scene)
|
||||
return if !pkmn.shadowPokemon? || pkmn.heart_gauge != 0
|
||||
pkmn.shadow = false
|
||||
pkmn.giveRibbon(PBRibbons::NATIONAL)
|
||||
scene.pbDisplay(_INTL("{1} opened the door to its heart!", pkmn.name))
|
||||
old_moves = []
|
||||
pokemon.moves.each { |m| old_moves.push(m.id) }
|
||||
pokemon.pbUpdateShadowMoves
|
||||
pokemon.moves.each_with_index do |m, i|
|
||||
next if m == old_moves[i]
|
||||
scene.pbDisplay(_INTL("{1} regained the move {2}!", pokemon.name, m.name))
|
||||
pkmn.moves.each { |m| old_moves.push(m.id) }
|
||||
pkmn.update_shadow_moves
|
||||
pkmn.moves.each_with_index do |m, i|
|
||||
next if m.id == old_moves[i]
|
||||
scene.pbDisplay(_INTL("{1} regained the move {2}!", pkmn.name, m.name))
|
||||
end
|
||||
pokemon.pbRecordFirstMoves
|
||||
if pokemon.savedev
|
||||
for i in 0...6
|
||||
pbApplyEVGain(pokemon,i,pokemon.savedev[i])
|
||||
pkmn.record_first_moves
|
||||
if pkmn.saved_ev
|
||||
pkmn.add_evs(pkmn.saved_ev)
|
||||
pkmn.saved_ev = nil
|
||||
end
|
||||
if pkmn.saved_exp
|
||||
newexp = PBExperience.pbAddExperience(pkmn.exp, pkmn.saved_exp || 0, pkmn.growth_rate)
|
||||
pkmn.saved_exp = nil
|
||||
newlevel = PBExperience.pbGetLevelFromExperience(newexp, pkmn.growth_rate)
|
||||
curlevel = pkmn.level
|
||||
if newexp != pkmn.exp
|
||||
scene.pbDisplay(_INTL("{1} regained {2} Exp. Points!", pkmn.name, newexp - pkmn.exp))
|
||||
end
|
||||
pokemon.savedev = nil
|
||||
end
|
||||
newexp = PBExperience.pbAddExperience(pokemon.exp,pokemon.savedexp||0,pokemon.growth_rate)
|
||||
pokemon.savedexp = nil
|
||||
newlevel = PBExperience.pbGetLevelFromExperience(newexp,pokemon.growth_rate)
|
||||
curlevel = pokemon.level
|
||||
if newexp!=pokemon.exp
|
||||
scene.pbDisplay(_INTL("{1} regained {2} Exp. Points!",pokemon.name,newexp-pokemon.exp))
|
||||
end
|
||||
if newlevel==curlevel
|
||||
pokemon.exp = newexp
|
||||
pokemon.calcStats
|
||||
else
|
||||
pbChangeLevel(pokemon,newlevel,scene) # for convenience
|
||||
pokemon.exp = newexp
|
||||
end
|
||||
if scene.pbConfirm(_INTL("Would you like to give a nickname to {1}?", pokemon.speciesName))
|
||||
newname = pbEnterPokemonName(_INTL("{1}'s nickname?", pokemon.speciesName),
|
||||
0, Pokemon::MAX_NAME_SIZE, "", pokemon)
|
||||
pokemon.name = newname
|
||||
end
|
||||
end
|
||||
|
||||
def pbApplyEVGain(pokemon,ev,evgain)
|
||||
totalev = 0
|
||||
for i in 0...6
|
||||
totalev += pokemon.ev[i]
|
||||
end
|
||||
if totalev+evgain>Pokemon::EV_LIMIT # Can't exceed overall limit
|
||||
evgain -= totalev+evgain-Pokemon::EV_LIMIT
|
||||
end
|
||||
if pokemon.ev[ev]+evgain>Pokemon::EV_STAT_LIMIT
|
||||
evgain -= totalev+evgain-Pokemon::EV_STAT_LIMIT
|
||||
end
|
||||
if evgain>0
|
||||
pokemon.ev[ev] += evgain
|
||||
end
|
||||
end
|
||||
|
||||
def pbReplaceMoves(pkmn, new_moves)
|
||||
return if !pkmn
|
||||
new_moves.each do |move|
|
||||
next if !move || pkmn.hasMove?(move)
|
||||
# Find a move slot to put move into
|
||||
for i in 0...Pokemon::MAX_MOVES
|
||||
if i >= pkmn.numMoves
|
||||
# Empty slot; add the new move there
|
||||
pkmn.pbLearnMove(move)
|
||||
break
|
||||
elsif !new_moves.include?(pkmn.moves[i].id)
|
||||
# Known move that isn't a move to be relearned; replace it
|
||||
pkmn.moves[i].id = move
|
||||
break
|
||||
end
|
||||
if newlevel == curlevel
|
||||
pkmn.exp = newexp
|
||||
pkmn.calcStats
|
||||
else
|
||||
pbChangeLevel(pkmn, newlevel, scene) # for convenience
|
||||
pkmn.exp = newexp
|
||||
end
|
||||
end
|
||||
if scene.pbConfirm(_INTL("Would you like to give a nickname to {1}?", pkmn.speciesName))
|
||||
newname = pbEnterPokemonName(_INTL("{1}'s nickname?", pkmn.speciesName),
|
||||
0, Pokemon::MAX_NAME_SIZE, "", pkmn)
|
||||
pkmn.name = newname
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -182,164 +146,21 @@ end
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbIsPurifiable?(pkmn)
|
||||
return false if !pkmn
|
||||
return false if pkmn.isSpecies?(:LUGIA)
|
||||
return false if !pkmn.shadowPokemon? || pkmn.heartgauge>0
|
||||
return true
|
||||
end
|
||||
|
||||
def pbHasPurifiableInParty?
|
||||
return $Trainer.party.any? { |pkmn| pbIsPurifiable?(pkmn) }
|
||||
end
|
||||
|
||||
def pbRelicStone
|
||||
if !pbHasPurifiableInParty?
|
||||
if !$Trainer.party.any? { |pkmn| pkmn.purifiable? }
|
||||
pbMessage(_INTL("You have no Pokémon that can be purified."))
|
||||
return
|
||||
end
|
||||
pbMessage(_INTL("There's a Pokémon that may open the door to its heart!"))
|
||||
# Choose a purifiable Pokemon
|
||||
pbChoosePokemon(1,2,proc { |pkmn|
|
||||
!pkmn.egg? && pkmn.hp>0 && pkmn.shadowPokemon? && pkmn.heartgauge==0
|
||||
pbChoosePokemon(1, 2,proc { |pkmn|
|
||||
pkmn.able? && pkmn.shadowPokemon? && pkmn.heart_gauge == 0
|
||||
})
|
||||
if $game_variables[1]>=0
|
||||
if $game_variables[1] >= 0
|
||||
pbRelicStoneScreen($Trainer.party[$game_variables[1]])
|
||||
end
|
||||
end
|
||||
|
||||
def pbReadyToPurify(pkmn)
|
||||
return unless pkmn && pkmn.shadowPokemon?
|
||||
pkmn.pbUpdateShadowMoves
|
||||
if pkmn.heartgauge==0
|
||||
pbMessage(_INTL("{1} can now be purified!",pkmn.name))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Pokémon class.
|
||||
#===============================================================================
|
||||
class Pokemon
|
||||
attr_writer :heartgauge
|
||||
attr_accessor :shadow
|
||||
attr_writer :hypermode
|
||||
attr_accessor :savedev
|
||||
attr_accessor :savedexp
|
||||
attr_accessor :shadowmoves
|
||||
attr_accessor :shadowmovenum
|
||||
HEARTGAUGESIZE = 3840
|
||||
|
||||
alias :__shadow_expeq :exp=
|
||||
def exp=(value)
|
||||
if shadowPokemon?
|
||||
@savedexp += value-self.exp
|
||||
else
|
||||
__shadow_expeq(value)
|
||||
end
|
||||
end
|
||||
|
||||
alias :__shadow_hpeq :hp=
|
||||
def hp=(value)
|
||||
__shadow_hpeq(value)
|
||||
@hypermode = false if value<=0
|
||||
end
|
||||
|
||||
def hypermode
|
||||
return (self.heartgauge==0 || self.hp==0) ? false : @hypermode
|
||||
end
|
||||
|
||||
def heartgauge
|
||||
return @heartgauge || 0
|
||||
end
|
||||
|
||||
def heartStage
|
||||
return 0 if !@shadow
|
||||
hg = HEARTGAUGESIZE/5.0
|
||||
return ([self.heartgauge,HEARTGAUGESIZE].min/hg).ceil
|
||||
end
|
||||
|
||||
def adjustHeart(value)
|
||||
return if !@shadow
|
||||
@heartgauge = 0 if !@heartgauge
|
||||
@heartgauge += value
|
||||
@heartgauge = HEARTGAUGESIZE if @heartgauge>HEARTGAUGESIZE
|
||||
@heartgauge = 0 if @heartgauge<0
|
||||
end
|
||||
|
||||
def shadowPokemon?
|
||||
return @shadow && @heartgauge && @heartgauge>=0
|
||||
end
|
||||
alias :isShadow? :shadowPokemon?
|
||||
|
||||
def makeShadow
|
||||
self.shadow = true
|
||||
self.heartgauge = HEARTGAUGESIZE
|
||||
self.savedexp = 0
|
||||
self.savedev = [0,0,0,0,0,0]
|
||||
self.shadowmoves = []
|
||||
# Retrieve Shadow moveset for this Pokémon
|
||||
shadow_moveset = pbLoadShadowMovesets[species_data.id]
|
||||
shadow_moveset = pbLoadShadowMovesets[@species] if !shadow_moveset || shadow_moveset.length == 0
|
||||
# Record this Pokémon's Shadow moves
|
||||
if shadow_moveset && shadow_moveset.length > 0
|
||||
for i in 0...[shadow_moveset.length, MAX_MOVES].min
|
||||
self.shadowmoves[i] = shadow_moveset[i]
|
||||
end
|
||||
self.shadowmovenum = shadow_moveset.length
|
||||
else
|
||||
# No Shadow moveset defined; just use Shadow Rush
|
||||
self.shadowmoves[0] = :SHADOWRUSH if GameData::Move.exists?(:SHADOWRUSH)
|
||||
self.shadowmovenum = 1
|
||||
end
|
||||
# Record this Pokémon's original moves
|
||||
@moves.each_with_index { |m, i| self.shadowmoves[MAX_MOVES + i] = m.id }
|
||||
# Update moves
|
||||
pbUpdateShadowMoves
|
||||
end
|
||||
|
||||
def pbUpdateShadowMoves(relearn_all_moves = false)
|
||||
return if !@shadowmoves
|
||||
# Not a Shadow Pokémon (any more); relearn all its original moves
|
||||
if !@shadow
|
||||
if @shadowmoves.length > MAX_MOVES
|
||||
new_moves = []
|
||||
@shadowmoves.each_with_index { |m, i| new_moves.push(m) if m && i >= MAX_MOVES }
|
||||
pbReplaceMoves(self, new_moves)
|
||||
end
|
||||
@shadowmoves = nil
|
||||
return
|
||||
end
|
||||
# Is a Shadow Pokémon; ensure it knows the appropriate moves depending on its heart stage
|
||||
m = @shadowmoves
|
||||
# Start with all Shadow moves
|
||||
new_moves = []
|
||||
@shadowmoves.each_with_index { |m, i| new_moves.push(m) if m && i < MAX_MOVES }
|
||||
# Add some original moves (skipping ones in the same slot as a Shadow Move)
|
||||
num_original_moves = (relearn_all_moves) ? 3 : [3, 3, 2, 1, 1, 0][self.heartStage]
|
||||
if num_original_moves > 0
|
||||
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
|
||||
# Relearn Shadow moves plus some original moves (may not change anything)
|
||||
pbReplaceMoves(self, new_moves)
|
||||
end
|
||||
|
||||
alias :__shadow_clone :clone
|
||||
def clone
|
||||
ret = __shadow_clone
|
||||
ret.savedev = self.savedev.clone if self.savedev
|
||||
ret.shadowmoves = self.shadowmoves.clone if self.shadowmoves
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
@@ -350,7 +171,7 @@ class PokeBattle_Battle
|
||||
|
||||
def pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages=true)
|
||||
ret = __shadow__pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages)
|
||||
if ret && pkmn.hypermode && ![:JOYSCENT, :EXCITESCENT, :VIVIDSCENT].include?(item)
|
||||
if ret && pkmn.hyper_mode && ![:JOYSCENT, :EXCITESCENT, :VIVIDSCENT].include?(item)
|
||||
scene.pbDisplay(_INTL("This item can't be used on that Pokémon."))
|
||||
return false
|
||||
end
|
||||
@@ -366,7 +187,7 @@ class PokeBattle_Battler
|
||||
def pbInitPokemon(*arg)
|
||||
if self.pokemonIndex>0 && inHyperMode?
|
||||
# Called out of Hyper Mode
|
||||
self.pokemon.hypermode = false
|
||||
self.pokemon.hyper_mode = false
|
||||
self.pokemon.adjustHeart(-50)
|
||||
end
|
||||
__shadow__pbInitPokemon(*arg)
|
||||
@@ -382,21 +203,21 @@ class PokeBattle_Battler
|
||||
|
||||
def shadowPokemon?
|
||||
p = self.pokemon
|
||||
return p && p.respond_to?("shadowPokemon?") && p.shadowPokemon?
|
||||
return p && p.shadowPokemon?
|
||||
end
|
||||
alias isShadow? shadowPokemon?
|
||||
|
||||
def inHyperMode?
|
||||
return false if fainted?
|
||||
p = self.pokemon
|
||||
return p && p.respond_to?("hypermode") && p.hypermode
|
||||
return p && p.hyper_mode
|
||||
end
|
||||
|
||||
def pbHyperMode
|
||||
return if fainted? || !shadowPokemon? || inHyperMode?
|
||||
p = self.pokemon
|
||||
if @battle.pbRandom(p.heartgauge)<=Pokemon::HEARTGAUGESIZE/4
|
||||
p.hypermode = true
|
||||
if @battle.pbRandom(p.heart_gauge) <= Pokemon::HEART_GAUGE_SIZE / 4
|
||||
p.hyper_mode = true
|
||||
@battle.pbDisplay(_INTL("{1}'s emotions rose to a fever pitch!\nIt entered Hyper Mode!",self.pbThis))
|
||||
end
|
||||
end
|
||||
@@ -413,30 +234,27 @@ end
|
||||
#===============================================================================
|
||||
# Shadow item effects.
|
||||
#===============================================================================
|
||||
def pbRaiseHappinessAndReduceHeart(pokemon,scene,amount)
|
||||
if !pokemon.shadowPokemon?
|
||||
def pbRaiseHappinessAndReduceHeart(pkmn, scene, heart_amount)
|
||||
if !pkmn.shadowPokemon? || (pkmn.happiness == 255 && pkmn.heart_gauge == 0)
|
||||
scene.pbDisplay(_INTL("It won't have any effect."))
|
||||
return false
|
||||
end
|
||||
if pokemon.happiness==255 && pokemon.heartgauge==0
|
||||
scene.pbDisplay(_INTL("It won't have any effect."))
|
||||
return false
|
||||
elsif pokemon.happiness==255
|
||||
pokemon.adjustHeart(-amount)
|
||||
scene.pbDisplay(_INTL("{1} adores you!\nThe door to its heart opened a little.",pokemon.name))
|
||||
pbReadyToPurify(pokemon)
|
||||
return true
|
||||
elsif pokemon.heartgauge==0
|
||||
pokemon.changeHappiness("vitamin")
|
||||
scene.pbDisplay(_INTL("{1} turned friendly.",pokemon.name))
|
||||
return true
|
||||
if pkmn.happiness == 255
|
||||
stage = pkmn.heart_gauge
|
||||
pkmn.adjustHeart(-heart_amount)
|
||||
scene.pbDisplay(_INTL("{1} adores you!\nThe door to its heart opened a little.", pkmn.name))
|
||||
pkmn.check_ready_to_purify if pkmn.heart_gauge != stage
|
||||
elsif pkmn.heart_gauge == 0
|
||||
pkmn.changeHappiness("vitamin")
|
||||
scene.pbDisplay(_INTL("{1} turned friendly.", pkmn.name))
|
||||
else
|
||||
pokemon.changeHappiness("vitamin")
|
||||
pokemon.adjustHeart(-amount)
|
||||
scene.pbDisplay(_INTL("{1} turned friendly.\nThe door to its heart opened a little.",pokemon.name))
|
||||
pbReadyToPurify(pokemon)
|
||||
return true
|
||||
stage = pkmn.heart_gauge
|
||||
pkmn.changeHappiness("vitamin")
|
||||
pkmn.adjustHeart(-heart_amount)
|
||||
scene.pbDisplay(_INTL("{1} turned friendly.\nThe door to its heart opened a little.", pkmn.name))
|
||||
pkmn.check_ready_to_purify if pkmn.heart_gauge != stage
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
ItemHandlers::UseOnPokemon.add(:JOYSCENT,proc { |item,pokemon,scene|
|
||||
@@ -452,12 +270,12 @@ ItemHandlers::UseOnPokemon.add(:VIVIDSCENT,proc { |item,pokemon,scene|
|
||||
})
|
||||
|
||||
ItemHandlers::UseOnPokemon.add(:TIMEFLUTE,proc { |item,pokemon,scene|
|
||||
if !pokemon.shadowPokemon?
|
||||
if !pokemon.shadowPokemon? || pokemon.heart_gauge == 0
|
||||
scene.pbDisplay(_INTL("It won't have any effect."))
|
||||
next false
|
||||
end
|
||||
pokemon.heartgauge = 0
|
||||
pbReadyToPurify(pokemon)
|
||||
pokemon.heart_gauge = 0
|
||||
pokemon.check_ready_to_purify
|
||||
next true
|
||||
})
|
||||
|
||||
@@ -472,22 +290,22 @@ ItemHandlers::CanUseInBattle.add(:JOYSCENT,proc { |item,pokemon,battler,move,fir
|
||||
ItemHandlers::CanUseInBattle.copy(:JOYSCENT,:EXCITESCENT,:VIVIDSCENT)
|
||||
|
||||
ItemHandlers::BattleUseOnBattler.add(:JOYSCENT,proc { |item,battler,scene|
|
||||
battler.pokemon.hypermode = false
|
||||
battler.pokemon.adjustHeart(-500)
|
||||
battler.pokemon.hyper_mode = false
|
||||
battler.pokemon.adjustHeart(-100)
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name))
|
||||
next true
|
||||
})
|
||||
|
||||
ItemHandlers::BattleUseOnBattler.add(:EXCITESCENT,proc { |item,battler,scene|
|
||||
battler.pokemon.hypermode = false
|
||||
battler.pokemon.adjustHeart(-1000)
|
||||
battler.pokemon.hyper_mode = false
|
||||
battler.pokemon.adjustHeart(-200)
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name))
|
||||
next true
|
||||
})
|
||||
|
||||
ItemHandlers::BattleUseOnBattler.add(:VIVIDSCENT,proc { |item,battler,scene|
|
||||
battler.pokemon.hypermode = false
|
||||
battler.pokemon.adjustHeart(-2000)
|
||||
battler.pokemon.hyper_mode = false
|
||||
battler.pokemon.adjustHeart(-300)
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name))
|
||||
next true
|
||||
})
|
||||
@@ -660,35 +478,39 @@ end
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonTemp
|
||||
attr_accessor :heartgauges
|
||||
attr_accessor :heart_gauges
|
||||
end
|
||||
|
||||
|
||||
|
||||
# Record current heart gauges of Pokémon in party, to see if they drop to zero
|
||||
# during battle and need to say they're ready to be purified afterwards
|
||||
Events.onStartBattle += proc { |_sender|
|
||||
# Record current heart gauges of Pokémon in party, to see if they drop to zero
|
||||
# during battle and need to say they're ready to be purified afterwards
|
||||
$PokemonTemp.heartgauges = []
|
||||
for i in 0...$Trainer.party.length
|
||||
$PokemonTemp.heartgauges[i] = $Trainer.party[i].heartgauge
|
||||
$PokemonTemp.heart_gauges = []
|
||||
$Trainer.party.each_with_index do |pkmn, i|
|
||||
$PokemonTemp.heart_gauges[i] = pkmn.heart_gauge
|
||||
end
|
||||
}
|
||||
|
||||
Events.onEndBattle += proc { |_sender,_e|
|
||||
for i in 0...$PokemonTemp.heartgauges.length
|
||||
pokemon = $Trainer.party[i]
|
||||
if pokemon && $PokemonTemp.heartgauges[i] &&
|
||||
$PokemonTemp.heartgauges[i]!=0 && pokemon.heartgauge==0
|
||||
pbReadyToPurify(pokemon)
|
||||
end
|
||||
$PokemonTemp.heart_gauges.each_with_index do |value, i|
|
||||
pkmn = $Trainer.party[i]
|
||||
next if !pkmn || !value || value == 0
|
||||
pkmn.check_ready_to_purify if pkmn.heart_gauge == 0
|
||||
end
|
||||
}
|
||||
|
||||
Events.onStepTaken += proc {
|
||||
for pkmn in $Trainer.ablePokemonParty
|
||||
if pkmn.heartgauge>0
|
||||
pkmn.adjustHeart(-1)
|
||||
pbReadyToPurify(pkmn) if pkmn.heartgauge==0
|
||||
next if pkmn.heart_gauge == 0
|
||||
stage = pkmn.heartStage
|
||||
pkmn.adjustHeart(-1)
|
||||
case pkmn.heartStage
|
||||
when 0
|
||||
pkmn.check_ready_to_purify
|
||||
when stage
|
||||
else
|
||||
pkmn.update_shadow_moves
|
||||
end
|
||||
end
|
||||
if ($PokemonGlobal.purifyChamber rescue nil)
|
||||
@@ -697,7 +519,8 @@ Events.onStepTaken += proc {
|
||||
for i in 0...2
|
||||
pkmn = $PokemonGlobal.daycare[i][0]
|
||||
next if !pkmn
|
||||
stage = pkmn.heartStage
|
||||
pkmn.adjustHeart(-1)
|
||||
pkmn.pbUpdateShadowMoves
|
||||
pkmn.update_shadow_moves if pkmn.heartStage != stage
|
||||
end
|
||||
}
|
||||
@@ -189,8 +189,8 @@ class PokemonStorage
|
||||
else # Copying into box
|
||||
pkmn = self[boxSrc,indexSrc]
|
||||
raise "Trying to copy nil to storage" if !pkmn
|
||||
pkmn.formTime = nil if pkmn.respond_to?("formTime")
|
||||
pkmn.form = 0 if pkmn.isSpecies?(:SHAYMIN)
|
||||
pkmn.time_form_set = nil
|
||||
pkmn.form = 0 if pkmn.isSpecies?(:SHAYMIN)
|
||||
pkmn.heal
|
||||
self[boxDst,indexDst] = pkmn
|
||||
end
|
||||
@@ -212,8 +212,8 @@ class PokemonStorage
|
||||
for i in 0...maxPokemon(box)
|
||||
if self[box,i]==nil
|
||||
if box>=0
|
||||
pkmn.formTime = nil if pkmn.respond_to?("formTime") && pkmn.formTime
|
||||
pkmn.form = 0 if pkmn.isSpecies?(:SHAYMIN)
|
||||
pkmn.time_form_set = nil if pkmn.time_form_set
|
||||
pkmn.form = 0 if pkmn.isSpecies?(:SHAYMIN)
|
||||
pkmn.heal
|
||||
end
|
||||
self[box,i] = pkmn
|
||||
@@ -225,8 +225,8 @@ class PokemonStorage
|
||||
|
||||
def pbStoreCaught(pkmn)
|
||||
if @currentBox>=0
|
||||
pkmn.formTime = nil if pkmn.respond_to?("formTime")
|
||||
pkmn.form = 0 if pkmn.isSpecies?(:SHAYMIN)
|
||||
pkmn.time_form_set = nil
|
||||
pkmn.form = 0 if pkmn.isSpecies?(:SHAYMIN)
|
||||
pkmn.heal
|
||||
end
|
||||
for i in 0...maxPokemon(@currentBox)
|
||||
@@ -8,14 +8,14 @@ class Pokemon
|
||||
# If defined, this Pokémon's form will be this value even if a MultipleForms
|
||||
# handler tries to say otherwise.
|
||||
# @return [Integer, nil] this Pokémon's form
|
||||
attr_accessor :forcedForm
|
||||
attr_accessor :forced_form
|
||||
# If defined, is the time (in Integer form) when this Pokémon's form was set.
|
||||
# @return [Integer, nil] the time this Pokémon's form was set
|
||||
attr_accessor :formTime
|
||||
attr_accessor :time_form_set
|
||||
# @return [Integer] the current experience points
|
||||
attr_reader :exp
|
||||
# @return [Integer] the number of steps until this Pokémon hatches, 0 if this Pokémon is not an egg
|
||||
attr_accessor :eggsteps
|
||||
attr_accessor :steps_to_hatch
|
||||
# @return [Integer] the current HP
|
||||
attr_reader :hp
|
||||
# @return [Integer] this Pokémon's current status (from PBStatuses)
|
||||
@@ -37,7 +37,7 @@ class Pokemon
|
||||
# @return [Array<Pokemon::Move>] the moves known by this Pokémon
|
||||
attr_accessor :moves
|
||||
# @return [Array<Integer>] the IDs of moves known by this Pokémon when it was obtained
|
||||
attr_accessor :firstmoves
|
||||
attr_accessor :first_moves
|
||||
# @return [Array<Integer>] an array of ribbons owned by this Pokémon
|
||||
attr_accessor :ribbons
|
||||
# @return [Integer] contest stats
|
||||
@@ -46,8 +46,8 @@ class Pokemon
|
||||
attr_accessor :pokerus
|
||||
# @return [Integer] this Pokémon's current happiness (an integer between 0 and 255)
|
||||
attr_accessor :happiness
|
||||
# @return [Integer] the type of ball used (refer to {$BallTypes} for valid types)
|
||||
attr_accessor :ballused
|
||||
# @return [Symbol] the item ID of the Poké Ball this Pokémon is in
|
||||
attr_accessor :poke_ball
|
||||
# @return [Integer] this Pokémon's markings, one bit per marking
|
||||
attr_accessor :markings
|
||||
# @return [Array<Integer>] an array of IV values for HP, Atk, Def, Speed, Sp. Atk and Sp. Def
|
||||
@@ -66,17 +66,17 @@ class Pokemon
|
||||
# 0 (met), 1 (as egg), 2 (traded), 4 (fateful encounter)
|
||||
attr_accessor :obtain_method
|
||||
# @return [Integer] the ID of the map this Pokémon was obtained in
|
||||
attr_accessor :obtainMap
|
||||
attr_accessor :obtain_map
|
||||
# Describes the manner this Pokémon was obtained. If left undefined,
|
||||
# the obtain map's name is used.
|
||||
# @return [String] the obtain text
|
||||
attr_accessor :obtainText
|
||||
attr_accessor :obtain_text
|
||||
# @return [Integer] the level of this Pokémon when it was obtained
|
||||
attr_accessor :obtainLevel
|
||||
attr_accessor :obtain_level
|
||||
# If this Pokémon hatched from an egg, returns the map ID where the hatching happened.
|
||||
# Otherwise returns 0.
|
||||
# @return [Integer] the map ID where egg was hatched (0 by default)
|
||||
attr_accessor :hatchedMap
|
||||
attr_accessor :hatched_map
|
||||
# Another Pokémon which has been fused with this Pokémon (or nil if there is none).
|
||||
# Currently only used by Kyurem, to record a fused Reshiram or Zekrom.
|
||||
# @return [Pokemon, nil] the Pokémon fused into this one (nil if there is none)
|
||||
@@ -96,7 +96,7 @@ class Pokemon
|
||||
MAX_MOVES = 4
|
||||
|
||||
def species_data
|
||||
return GameData::Species.get_species_form(@species, formSimple)
|
||||
return GameData::Species.get_species_form(@species, form_simple)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -108,11 +108,11 @@ class Pokemon
|
||||
def species=(species_id)
|
||||
new_species_data = GameData::Species.get(species_id)
|
||||
return if @species == new_species_data.species
|
||||
@species = new_species_data.species
|
||||
@form = new_species_data.form if new_species_data.form != 0
|
||||
@forcedForm = nil
|
||||
@level = nil # In case growth rate is different for the new species
|
||||
@ability = nil
|
||||
@species = new_species_data.species
|
||||
@form = new_species_data.form if new_species_data.form != 0
|
||||
@forced_form = nil
|
||||
@level = nil # In case growth rate is different for the new species
|
||||
@ability = nil
|
||||
calcStats
|
||||
end
|
||||
|
||||
@@ -124,15 +124,15 @@ class Pokemon
|
||||
end
|
||||
|
||||
def form
|
||||
return @forcedForm if !@forcedForm.nil?
|
||||
return @forced_form if !@forced_form.nil?
|
||||
return @form if $game_temp.in_battle
|
||||
calc_form = MultipleForms.call("getForm", self)
|
||||
self.form = calc_form if calc_form != nil && calc_form != @form
|
||||
return @form
|
||||
end
|
||||
|
||||
def formSimple
|
||||
return @forcedForm || @form
|
||||
def form_simple
|
||||
return @forced_form || @form
|
||||
end
|
||||
|
||||
def form=(value)
|
||||
@@ -149,7 +149,7 @@ class Pokemon
|
||||
self.form = value
|
||||
end
|
||||
|
||||
def formSimple=(value)
|
||||
def form_simple=(value)
|
||||
@form = value
|
||||
calcStats
|
||||
end
|
||||
@@ -184,7 +184,7 @@ class Pokemon
|
||||
|
||||
# @return [Boolean] whether this Pokémon is an egg
|
||||
def egg?
|
||||
return @eggsteps > 0
|
||||
return @steps_to_hatch > 0
|
||||
end
|
||||
alias isEgg? egg?
|
||||
|
||||
@@ -200,7 +200,7 @@ class Pokemon
|
||||
|
||||
# @return [Float] a number between 0 and 1 indicating how much of the current level's
|
||||
# Exp this Pokémon has
|
||||
def expFraction
|
||||
def exp_fraction
|
||||
lvl = self.level
|
||||
return 0.0 if lvl >= PBExperience.maxLevel
|
||||
g_rate = growth_rate
|
||||
@@ -217,7 +217,7 @@ class Pokemon
|
||||
# @param value [Integer] new HP value
|
||||
def hp=(value)
|
||||
@hp = value.clamp(0, @totalhp)
|
||||
healStatus if @hp == 0
|
||||
heal_status if @hp == 0
|
||||
end
|
||||
|
||||
# Sets this Pokémon's status. See {PBStatuses} for all possible status effects.
|
||||
@@ -243,13 +243,13 @@ class Pokemon
|
||||
alias isFainted? fainted?
|
||||
|
||||
# Heals all HP of this Pokémon.
|
||||
def healHP
|
||||
def heal_HP
|
||||
return if egg?
|
||||
@hp = @totalhp
|
||||
end
|
||||
|
||||
# Heals the status problem of this Pokémon.
|
||||
def healStatus
|
||||
def heal_status
|
||||
return if egg?
|
||||
@status = PBStatuses::NONE
|
||||
@statusCount = 0
|
||||
@@ -259,7 +259,7 @@ class Pokemon
|
||||
# of the move in that index.
|
||||
# @param move_index [Integer] index of the move to heal (-1 if all moves
|
||||
# should be healed)
|
||||
def healPP(move_index = -1)
|
||||
def heal_PP(move_index = -1)
|
||||
return if egg?
|
||||
if move_index >= 0
|
||||
@moves[move_index].pp = @moves[move_index].total_pp
|
||||
@@ -271,9 +271,9 @@ class Pokemon
|
||||
# Heals all HP, PP, and status problems of this Pokémon.
|
||||
def heal
|
||||
return if egg?
|
||||
healHP
|
||||
healStatus
|
||||
healPP
|
||||
heal_HP
|
||||
heal_status
|
||||
heal_PP
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -572,7 +572,7 @@ class Pokemon
|
||||
|
||||
# Silently learns the given move. Will erase the first known move if it has to.
|
||||
# @param move_id [Integer, Symbol, String] ID of the move to learn
|
||||
def pbLearnMove(move_id)
|
||||
def learn_move(move_id)
|
||||
move_data = GameData::Move.try_get(move_id)
|
||||
return if !move_data
|
||||
# Check if self already knows the move; if so, move it to the end of the array
|
||||
@@ -590,7 +590,7 @@ class Pokemon
|
||||
|
||||
# Deletes the given move from the Pokémon.
|
||||
# @param move_id [Integer, Symbol, String] ID of the move to delete
|
||||
def pbDeleteMove(move_id)
|
||||
def forget_move(move_id)
|
||||
move_data = GameData::Move.try_get(move_id)
|
||||
return if !move_data
|
||||
@moves.delete_if { |m| m.id == move_data.id }
|
||||
@@ -598,43 +598,43 @@ class Pokemon
|
||||
|
||||
# Deletes the move at the given index from the Pokémon.
|
||||
# @param index [Integer] index of the move to be deleted
|
||||
def pbDeleteMoveAtIndex(index)
|
||||
def forget_move_at_index(index)
|
||||
@moves.delete_at(index)
|
||||
end
|
||||
|
||||
# Deletes all moves from the Pokémon.
|
||||
def pbDeleteAllMoves
|
||||
def forget_all_moves
|
||||
@moves.clear
|
||||
end
|
||||
|
||||
# Copies currently known moves into a separate array, for Move Relearner.
|
||||
def pbRecordFirstMoves
|
||||
pbClearFirstMoves
|
||||
@moves.each { |m| @firstmoves.push(m.id) }
|
||||
def record_first_moves
|
||||
clear_first_moves
|
||||
@moves.each { |m| @first_moves.push(m.id) }
|
||||
end
|
||||
|
||||
# Adds a move to this Pokémon's first moves.
|
||||
# @param move_id [Integer, Symbol, String] ID of the move to add
|
||||
def pbAddFirstMove(move_id)
|
||||
def add_first_move(move_id)
|
||||
move_data = GameData::Move.try_get(move_id)
|
||||
@firstmoves.push(move_data.id) if move_data && !@firstmoves.include?(move_data.id)
|
||||
@first_moves.push(move_data.id) if move_data && !@first_moves.include?(move_data.id)
|
||||
end
|
||||
|
||||
# Removes a move from this Pokémon's first moves.
|
||||
# @param move_id [Integer, Symbol, String] ID of the move to remove
|
||||
def pbRemoveFirstMove(move_id)
|
||||
def remove_first_move(move_id)
|
||||
move_data = GameData::Move.try_get(move_id)
|
||||
@firstmoves.delete(move_data.id) if move_data
|
||||
@first_moves.delete(move_data.id) if move_data
|
||||
end
|
||||
|
||||
# Clears this Pokémon's first moves.
|
||||
def pbClearFirstMoves
|
||||
@firstmoves.clear
|
||||
def clear_first_moves
|
||||
@first_moves.clear
|
||||
end
|
||||
|
||||
# @param move_id [Integer, Symbol, String] ID of the move to check
|
||||
# @return [Boolean] whether the Pokémon is compatible with the given move
|
||||
def compatibleWithMove?(move_id)
|
||||
def compatible_with_move?(move_id)
|
||||
move_data = GameData::Move.try_get(move_id)
|
||||
return move_data && species_data.tutor_moves.include?(move_data.id)
|
||||
end
|
||||
@@ -644,7 +644,7 @@ class Pokemon
|
||||
#=============================================================================
|
||||
|
||||
# @return [Integer] the number of ribbons this Pokémon has
|
||||
def ribbonCount
|
||||
def numRibbons
|
||||
return @ribbons.length
|
||||
end
|
||||
|
||||
@@ -860,8 +860,8 @@ class Pokemon
|
||||
raise _INTL("Unknown happiness-changing method: {1}", method.to_s)
|
||||
end
|
||||
if gain > 0
|
||||
gain += 1 if @obtainMap == $game_map.map_id
|
||||
gain += 1 if @ballused == pbGetBallType(:LUXURYBALL)
|
||||
gain += 1 if @obtain_map == $game_map.map_id
|
||||
gain += 1 if @poke_ball == :LUXURYBALL
|
||||
gain = (gain * 1.5).floor if hasItem?(:SOOTHEBELL)
|
||||
end
|
||||
@happiness = (@happiness + gain).clamp(0, 255)
|
||||
@@ -928,14 +928,14 @@ class Pokemon
|
||||
# @return [Pokemon] a copy of this Pokémon
|
||||
def clone
|
||||
ret = super
|
||||
ret.iv = @iv.clone
|
||||
ret.ivMaxed = @ivMaxed.clone
|
||||
ret.ev = @ev.clone
|
||||
ret.moves = []
|
||||
ret.iv = @iv.clone
|
||||
ret.ivMaxed = @ivMaxed.clone
|
||||
ret.ev = @ev.clone
|
||||
ret.moves = []
|
||||
@moves.each_with_index { |m, i| ret.moves[i] = m.clone }
|
||||
ret.firstmoves = @firstmoves.cline
|
||||
ret.owner = @owner.clone
|
||||
ret.ribbons = @ribbons.clone
|
||||
ret.first_moves = @first_moves.clone
|
||||
ret.owner = @owner.clone
|
||||
ret.ribbons = @ribbons.clone
|
||||
return ret
|
||||
end
|
||||
|
||||
@@ -948,11 +948,11 @@ class Pokemon
|
||||
species_data = GameData::Species.get(species)
|
||||
@species = species_data.species
|
||||
@form = species_data.form
|
||||
@forcedForm = nil
|
||||
@formTime = nil
|
||||
@forced_form = nil
|
||||
@time_form_set = nil
|
||||
self.level = level
|
||||
@eggsteps = 0
|
||||
healStatus
|
||||
@steps_to_hatch = 0
|
||||
heal_status
|
||||
@gender = nil
|
||||
@shiny = nil
|
||||
@ability_index = nil
|
||||
@@ -963,7 +963,7 @@ class Pokemon
|
||||
@mail = nil
|
||||
@moves = []
|
||||
resetMoves if withMoves
|
||||
@firstmoves = []
|
||||
@first_moves = []
|
||||
@ribbons = []
|
||||
@cool = 0
|
||||
@beauty = 0
|
||||
@@ -974,7 +974,7 @@ class Pokemon
|
||||
@pokerus = 0
|
||||
@name = nil
|
||||
@happiness = species_data.happiness
|
||||
@ballused = 0
|
||||
@poke_ball = :POKEBALL
|
||||
@markings = 0
|
||||
@iv = []
|
||||
@ivMaxed = []
|
||||
@@ -992,10 +992,10 @@ class Pokemon
|
||||
end
|
||||
@obtain_method = 0 # Met
|
||||
@obtain_method = 4 if $game_switches && $game_switches[FATEFUL_ENCOUNTER_SWITCH]
|
||||
@obtainMap = ($game_map) ? $game_map.map_id : 0
|
||||
@obtainText = nil
|
||||
@obtainLevel = level
|
||||
@hatchedMap = 0
|
||||
@obtain_map = ($game_map) ? $game_map.map_id : 0
|
||||
@obtain_text = nil
|
||||
@obtain_level = level
|
||||
@hatched_map = 0
|
||||
@timeReceived = pbGetTimeNow.to_i
|
||||
@timeEggHatched = nil
|
||||
@fused = nil
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#===============================================================================
|
||||
# Mega Evolution
|
||||
# NOTE: These are treated as form changes in Essentials.
|
||||
#===============================================================================
|
||||
class Pokemon
|
||||
#=============================================================================
|
||||
# Mega Evolution
|
||||
# NOTE: These are treated as form changes in Essentials.
|
||||
#=============================================================================
|
||||
def getMegaForm(checkItemOnly = false)
|
||||
ret = 0
|
||||
GameData::Species.each do |data|
|
||||
@@ -24,12 +24,12 @@ class Pokemon
|
||||
|
||||
def hasMegaForm?
|
||||
megaForm = self.getMegaForm
|
||||
return megaForm > 0 && megaForm != self.formSimple
|
||||
return megaForm > 0 && megaForm != form_simple
|
||||
end
|
||||
|
||||
def mega?
|
||||
megaForm = self.getMegaForm
|
||||
return megaForm > 0 && megaForm == self.formSimple
|
||||
return megaForm > 0 && megaForm == form_simple
|
||||
end
|
||||
alias isMega? mega?
|
||||
|
||||
@@ -51,15 +51,11 @@ class Pokemon
|
||||
def megaMessage # 0=default message, 1=Rayquaza message
|
||||
return species_data.mega_message
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Primal Reversion
|
||||
# NOTE: These are treated as form changes in Essentials.
|
||||
#===============================================================================
|
||||
class Pokemon
|
||||
#=============================================================================
|
||||
# Primal Reversion
|
||||
# NOTE: These are treated as form changes in Essentials.
|
||||
#=============================================================================
|
||||
def hasPrimalForm?
|
||||
v = MultipleForms.call("getPrimalForm",self)
|
||||
return v!=nil
|
||||
@@ -83,19 +79,3 @@ class Pokemon
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
MultipleForms.register(:GROUDON,{
|
||||
"getPrimalForm" => proc { |pkmn|
|
||||
next 1 if pkmn.hasItem?(:REDORB)
|
||||
next
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:KYOGRE,{
|
||||
"getPrimalForm" => proc { |pkmn|
|
||||
next 1 if pkmn.hasItem?(:BLUEORB)
|
||||
next
|
||||
}
|
||||
})
|
||||
156
Data/Scripts/016_Pokemon/003_Pokemon_ShadowPokemon.rb
Normal file
156
Data/Scripts/016_Pokemon/003_Pokemon_ShadowPokemon.rb
Normal file
@@ -0,0 +1,156 @@
|
||||
#===============================================================================
|
||||
# Pokémon class.
|
||||
#===============================================================================
|
||||
class Pokemon
|
||||
attr_accessor :shadow
|
||||
attr_writer :heart_gauge
|
||||
attr_writer :hyper_mode
|
||||
attr_accessor :saved_exp
|
||||
attr_accessor :saved_ev
|
||||
attr_accessor :shadow_moves
|
||||
HEART_GAUGE_SIZE = 3840
|
||||
|
||||
alias :__shadow_expeq :exp=
|
||||
def exp=(value)
|
||||
if shadowPokemon?
|
||||
@saved_exp += value - @exp
|
||||
else
|
||||
__shadow_expeq(value)
|
||||
end
|
||||
end
|
||||
|
||||
alias :__shadow_hpeq :hp=
|
||||
def hp=(value)
|
||||
__shadow_hpeq(value)
|
||||
@hyper_mode = false if @hp <= 0
|
||||
end
|
||||
|
||||
def heart_gauge
|
||||
return @heart_gauge || 0
|
||||
end
|
||||
|
||||
def adjustHeart(value)
|
||||
return if !shadowPokemon?
|
||||
@heart_gauge = (self.heart_gauge + value).clamp(0, HEART_GAUGE_SIZE)
|
||||
end
|
||||
|
||||
def heartStage
|
||||
return 0 if !shadowPokemon?
|
||||
stage_size = HEART_GAUGE_SIZE / 5.0
|
||||
return ([self.heart_gauge, HEART_GAUGE_SIZE].min / stage_size).ceil
|
||||
end
|
||||
|
||||
def shadowPokemon?
|
||||
return @shadow && @heart_gauge && @heart_gauge >= 0
|
||||
end
|
||||
alias isShadow? shadowPokemon?
|
||||
|
||||
def hyper_mode
|
||||
return (self.heart_gauge == 0 || @hp == 0) ? false : @hyper_mode
|
||||
end
|
||||
|
||||
def makeShadow
|
||||
@shadow = true
|
||||
@heart_gauge = HEART_GAUGE_SIZE
|
||||
@hyper_mode = false
|
||||
@saved_exp = 0
|
||||
@saved_ev = [0, 0, 0, 0, 0, 0]
|
||||
@shadow_moves = []
|
||||
# Retrieve Shadow moveset for this Pokémon
|
||||
shadow_moveset = pbLoadShadowMovesets[species_data.id]
|
||||
shadow_moveset = pbLoadShadowMovesets[@species] if !shadow_moveset || shadow_moveset.length == 0
|
||||
# Record this Pokémon's Shadow moves
|
||||
if shadow_moveset && shadow_moveset.length > 0
|
||||
for i in 0...[shadow_moveset.length, MAX_MOVES].min
|
||||
@shadow_moves[i] = shadow_moveset[i]
|
||||
end
|
||||
elsif GameData::Move.exists?(:SHADOWRUSH)
|
||||
# No Shadow moveset defined; just use Shadow Rush
|
||||
@shadow_moves[0] = :SHADOWRUSH
|
||||
else
|
||||
raise _INTL("Expected Shadow moves or Shadow Rush to be defined, but they weren't.")
|
||||
end
|
||||
# Record this Pokémon's original moves
|
||||
@moves.each_with_index { |m, i| @shadow_moves[MAX_MOVES + i] = m.id }
|
||||
# Update moves
|
||||
update_shadow_moves
|
||||
end
|
||||
|
||||
def update_shadow_moves(relearn_all_moves = false)
|
||||
return if !@shadow_moves
|
||||
# Not a Shadow Pokémon (any more); relearn all its original moves
|
||||
if !shadowPokemon?
|
||||
if @shadow_moves.length > MAX_MOVES
|
||||
new_moves = []
|
||||
@shadow_moves.each_with_index { |m, i| new_moves.push(m) if m && i >= MAX_MOVES }
|
||||
replace_moves(new_moves)
|
||||
end
|
||||
@shadow_moves = nil
|
||||
return
|
||||
end
|
||||
# Is a Shadow Pokémon; ensure it knows the appropriate moves depending on its heart stage
|
||||
# Start with all Shadow moves
|
||||
new_moves = []
|
||||
@shadow_moves.each_with_index { |m, i| new_moves.push(m) if m && i < MAX_MOVES }
|
||||
num_shadow_moves = new_moves.length
|
||||
# Add some original moves (skipping ones in the same slot as a Shadow Move)
|
||||
num_original_moves = (relearn_all_moves) ? 3 : [3, 3, 2, 1, 1, 0][self.heartStage]
|
||||
if num_original_moves > 0
|
||||
relearned_count = 0
|
||||
@shadow_moves.each_with_index do |m, i|
|
||||
next if !m || i < MAX_MOVES + num_shadow_moves
|
||||
new_moves.push(m)
|
||||
relearned_count += 1
|
||||
break if relearned_count >= num_original_moves
|
||||
end
|
||||
end
|
||||
# Relearn Shadow moves plus some original moves (may not change anything)
|
||||
replace_moves(new_moves)
|
||||
end
|
||||
|
||||
def replace_moves(new_moves)
|
||||
new_moves.each do |move|
|
||||
next if !move || !GameData::Move.exists?(move) || hasMove?(move)
|
||||
if numMoves < Pokemon::MAX_MOVES # Has an empty slot; just learn move
|
||||
learn_move(move)
|
||||
next
|
||||
end
|
||||
@moves.each do |m|
|
||||
next if new_moves.include?(m.id)
|
||||
m.id = GameData::Move.get(move).id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def purifiable?
|
||||
return false if !shadowPokemon? || self.heart_gauge > 0
|
||||
return false if isSpecies?(:LUGIA)
|
||||
return true
|
||||
end
|
||||
|
||||
def check_ready_to_purify
|
||||
return if !shadowPokemon?
|
||||
update_shadow_moves
|
||||
pbMessage(_INTL("{1} can now be purified!", self.name)) if self.heart_gauge == 0
|
||||
end
|
||||
|
||||
def add_evs(added_evs)
|
||||
total = 0
|
||||
@ev.each { |e| total += e }
|
||||
PBStats.each do |s|
|
||||
addition = added_evs[s].clamp(0, Pokemon::EV_STAT_LIMIT - @ev[s])
|
||||
addition = addition.clamp(0, Pokemon::EV_LIMIT - total)
|
||||
next if addition == 0
|
||||
@ev[s] += addition
|
||||
total += addition
|
||||
end
|
||||
end
|
||||
|
||||
alias :__shadow_clone :clone
|
||||
def clone
|
||||
ret = __shadow_clone
|
||||
ret.saved_ev = @saved_ev.clone if @saved_ev
|
||||
ret.shadow_moves = @shadow_moves.clone if @shadow_moves
|
||||
return ret
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,7 @@
|
||||
#===============================================================================
|
||||
# Stores information about a Pokémon's owner.
|
||||
#===============================================================================
|
||||
class Pokemon
|
||||
# Stores information about a Pokémon's owner.
|
||||
class Owner
|
||||
# @return [Integer] the ID of the owner
|
||||
attr_reader :id
|
||||
|
||||
@@ -18,8 +18,7 @@ class PokeBattle_Pokemon
|
||||
attr_reader :timeReceived, :timeEggHatched
|
||||
attr_reader :cool, :beauty, :cute, :smart, :tough, :sheen
|
||||
attr_reader :trainerID, :ot, :otgender, :language
|
||||
attr_reader :shadow, :heartgauge, :savedexp, :savedev, :hypermode
|
||||
attr_reader :shadowmoves, :shadowmovenum
|
||||
attr_reader :shadow, :heartgauge, :savedexp, :savedev, :hypermode, :shadowmoves
|
||||
|
||||
def initialise
|
||||
raise "PokeBattle_Pokemon.new is deprecated. Use Pokemon.new instead."
|
||||
@@ -28,10 +27,10 @@ class PokeBattle_Pokemon
|
||||
def self.copy(pkmn)
|
||||
owner = Pokemon::Owner.new(pkmn.trainerID, pkmn.ot, pkmn.otgender, pkmn.language)
|
||||
ret = Pokemon.new(pkmn.species, pkmn.level, owner, false)
|
||||
ret.forcedForm = pkmn.forcedForm if pkmn.forcedForm
|
||||
ret.formTime = pkmn.formTime
|
||||
ret.forced_form = pkmn.forcedForm if pkmn.forcedForm
|
||||
ret.time_form_set = pkmn.formTime
|
||||
ret.exp = pkmn.exp
|
||||
ret.eggsteps = pkmn.eggsteps
|
||||
ret.steps_to_hatch = pkmn.eggsteps
|
||||
ret.status = pkmn.status
|
||||
ret.statusCount = pkmn.statusCount
|
||||
ret.gender = pkmn.genderflag
|
||||
@@ -42,7 +41,7 @@ class PokeBattle_Pokemon
|
||||
ret.item = pkmn.item
|
||||
ret.mail = PokemonMail.copy(pkmn.mail) if pkmn.mail
|
||||
pkmn.moves.each { |m| ret.moves.push(PBMove.copy(m)) if m && m.id > 0 }
|
||||
pkmn.firstmoves.each { |m| ret.pbAddFirstMove(m) }
|
||||
pkmn.firstmoves.each { |m| ret.add_first_move(m) }
|
||||
ret.ribbons = pkmn.ribbons.clone if pkmn.ribbons
|
||||
ret.cool = pkmn.cool if pkmn.cool
|
||||
ret.beauty = pkmn.beauty if pkmn.beauty
|
||||
@@ -53,16 +52,16 @@ class PokeBattle_Pokemon
|
||||
ret.pokerus = pkmn.pokerus if pkmn.pokerus
|
||||
ret.name = pkmn.name
|
||||
ret.happiness = pkmn.happiness
|
||||
ret.ballused = pkmn.ballused
|
||||
ret.poke_ball = pbBallTypeToItem(pkmn.ballused)
|
||||
ret.markings = pkmn.markings if pkmn.markings
|
||||
ret.iv = pkmn.iv.clone
|
||||
ret.ivMaxed = pkmn.ivMaxed.clone if pkmn.ivMaxed
|
||||
ret.ev = pkmn.ev.clone
|
||||
ret.obtain_method = pkmn.obtainMode
|
||||
ret.obtainMap = pkmn.obtainMap
|
||||
ret.obtainText = pkmn.obtainText
|
||||
ret.obtainLevel = pkmn.obtainLevel if pkmn.obtainLevel
|
||||
ret.hatchedMap = pkmn.hatchedMap
|
||||
ret.obtain_map = pkmn.obtainMap
|
||||
ret.obtain_text = pkmn.obtainText
|
||||
ret.obtain_level = pkmn.obtainLevel if pkmn.obtainLevel
|
||||
ret.hatched_map = pkmn.hatchedMap
|
||||
ret.timeReceived = pkmn.timeReceived
|
||||
ret.timeEggHatched = pkmn.timeEggHatched
|
||||
if pkmn.fused
|
||||
@@ -71,16 +70,19 @@ class PokeBattle_Pokemon
|
||||
end
|
||||
ret.personalID = pkmn.personalID
|
||||
ret.hp = pkmn.hp
|
||||
|
||||
ret.shadow = pkmn.shadow
|
||||
ret.heartgauge = pkmn.heartgauge
|
||||
ret.savedexp = pkmn.savedexp
|
||||
ret.savedev = pkmn.savedev.clone
|
||||
ret.hypermode = pkmn.hypermode
|
||||
ret.shadowmoves = pkmn.shadowmoves.clone
|
||||
ret.shadowmovenum = pkmn.shadowmovenum
|
||||
if pkmn.shadow
|
||||
ret.shadow = pkmn.shadow
|
||||
ret.heart_gauge = pkmn.heartgauge
|
||||
ret.hyper_mode = pkmn.hypermode
|
||||
ret.saved_exp = pkmn.savedexp
|
||||
ret.saved_ev = pkmn.savedev.clone
|
||||
ret.shadow_moves = []
|
||||
pkmn.shadowmoves.each_with_index do |move, i|
|
||||
ret.shadow_moves[i] = GameData::Move.get(move).id if move
|
||||
end
|
||||
end
|
||||
# NOTE: Intentionally set last, as it recalculates stats.
|
||||
ret.formSimple = pkmn.form || 0
|
||||
ret.form_simple = pkmn.form || 0
|
||||
return ret
|
||||
end
|
||||
end
|
||||
@@ -178,6 +180,16 @@ class Pokemon
|
||||
Deprecation.warn_method('Pokemon#setItem', 'v20', 'Pokemon#item=')
|
||||
self.item = value
|
||||
end
|
||||
|
||||
alias healStatus heal_status
|
||||
alias pbLearnMove learn_move
|
||||
alias pbDeleteMove forget_move
|
||||
alias pbDeleteMoveAtIndex forget_move_at_index
|
||||
alias pbRecordFirstMoves record_first_moves
|
||||
alias pbAddFirstMove add_first_move
|
||||
alias pbRemoveFirstMove remove_first_move
|
||||
alias pbClearFirstMoves clear_first_moves
|
||||
alias pbUpdateShadowMoves update_shadow_moves
|
||||
end
|
||||
|
||||
# (see Pokemon#initialize)
|
||||
|
||||
Reference in New Issue
Block a user