Merge pull request #10 from jonisavo/additional-refactoring

Additional #isSpecies? and #hasItem? refactoring
This commit is contained in:
Maruno17
2020-09-06 19:21:17 +01:00
committed by GitHub
8 changed files with 13 additions and 17 deletions

View File

@@ -164,7 +164,7 @@ class PokeBattle_Move
return return
end end
# Disguise will take the damage # Disguise will take the damage
if !@battle.moldBreaker && isConst?(target.species,PBSpecies,:MIMIKYU) && if !@battle.moldBreaker && target.isSpecies?(:MIMIKYU) &&
target.form==0 && isConst?(target.ability,PBAbilities,:DISGUISE) target.form==0 && isConst?(target.ability,PBAbilities,:DISGUISE)
target.damageState.disguise = true target.damageState.disguise = true
return return

View File

@@ -852,7 +852,7 @@ BattleHandlers::DamageCalcTargetItem.add(:COLBURBERRY,
BattleHandlers::DamageCalcTargetItem.add(:DEEPSEASCALE, BattleHandlers::DamageCalcTargetItem.add(:DEEPSEASCALE,
proc { |item,user,target,move,mults,baseDmg,type| proc { |item,user,target,move,mults,baseDmg,type|
if isConst?(target.species,PBSpecies,:CLAMPERL) && move.specialMove? if target.isSpecies?(:CLAMPERL) && move.specialMove?
mults[DEF_MULT] *= 2 mults[DEF_MULT] *= 2
end end
} }
@@ -889,8 +889,7 @@ BattleHandlers::DamageCalcTargetItem.add(:KEBIABERRY,
BattleHandlers::DamageCalcTargetItem.add(:METALPOWDER, BattleHandlers::DamageCalcTargetItem.add(:METALPOWDER,
proc { |item,user,target,move,mults,baseDmg,type| proc { |item,user,target,move,mults,baseDmg,type|
if isConst?(target.species,PBSpecies,:DITTO) && if target.isSpecies?(:DITTO) && !target.effects[PBEffects::Transform]
!target.effects[PBEffects::Transform]
mults[DEF_MULT] = (mults[DEF_MULT]*1.5).round mults[DEF_MULT] = (mults[DEF_MULT]*1.5).round
end end
} }
@@ -935,8 +934,7 @@ BattleHandlers::DamageCalcTargetItem.add(:SHUCABERRY,
BattleHandlers::DamageCalcTargetItem.add(:SOULDEW, BattleHandlers::DamageCalcTargetItem.add(:SOULDEW,
proc { |item,user,target,move,mults,baseDmg,type| proc { |item,user,target,move,mults,baseDmg,type|
next if NEWEST_BATTLE_MECHANICS next if NEWEST_BATTLE_MECHANICS
next if !isConst?(target.species,PBSpecies,:LATIAS) && next if !target.isSpecies?(:LATIAS) && !target.isSpecies?(:LATIOS)
!isConst?(target.species,PBSpecies,:LATIOS)
if move.specialMove? && !user.battle.rules["souldewclause"] if move.specialMove? && !user.battle.rules["souldewclause"]
mults[DEF_MULT] = (mults[DEF_MULT]*1.5).round mults[DEF_MULT] = (mults[DEF_MULT]*1.5).round
end end

View File

@@ -338,9 +338,9 @@ class PokemonEncounters
end end
firstPkmn = $Trainer.firstPokemon firstPkmn = $Trainer.firstPokemon
if firstPkmn if firstPkmn
if isConst?(firstPkmn.item,PBItems,:CLEANSETAG) if firstPkmn.hasItem?(:CLEANSETAG)
encount = encount*2/3 encount = encount*2/3
elsif isConst?(firstPkmn.item,PBItems,:PUREINCENSE) elsif firstPkmn.hasItem?(:PUREINCENSE)
encount = encount*2/3 encount = encount*2/3
else # Ignore ability effects if an item effect applies else # Ignore ability effects if an item effect applies
if isConst?(firstPkmn.ability,PBAbilities,:STENCH) if isConst?(firstPkmn.ability,PBAbilities,:STENCH)

View File

@@ -220,7 +220,7 @@ def pbDayCareGenerateEgg
isConst?(babyspecies,PBSpecies,:ROCKRUFF) || isConst?(babyspecies,PBSpecies,:ROCKRUFF) ||
isConst?(babyspecies,PBSpecies,:MINIOR) isConst?(babyspecies,PBSpecies,:MINIOR)
newForm = mother.form newForm = mother.form
newForm = 0 if isConst?(mother.species,PBSpecies,:MOTHIM) newForm = 0 if mother.isSpecies?(:MOTHIM)
egg.form = newForm egg.form = newForm
end end
# Inheriting Alolan form # Inheriting Alolan form
@@ -280,13 +280,11 @@ def pbDayCareGenerateEgg
end end
# Volt Tackle # Volt Tackle
lightball = false lightball = false
if (isConst?(father.species,PBSpecies,:PIKACHU) || if (father.isSpecies?(:PIKACHU) || father.isSpecies?(:RAICHU)) &&
isConst?(father.species,PBSpecies,:RAICHU)) &&
father.hasItem?(:LIGHTBALL) father.hasItem?(:LIGHTBALL)
lightball = true lightball = true
end end
if (isConst?(mother.species,PBSpecies,:PIKACHU) || if (mother.isSpecies?(:PIKACHU) || mother.isSpecies?(:RAICHU)) &&
isConst?(mother.species,PBSpecies,:RAICHU)) &&
mother.hasItem?(:LIGHTBALL) mother.hasItem?(:LIGHTBALL)
lightball = true lightball = true
end end

View File

@@ -796,7 +796,7 @@ class PokeBattle_Pokemon
if gain>0 if gain>0
gain += 1 if @obtainMap==$game_map.map_id gain += 1 if @obtainMap==$game_map.map_id
gain += 1 if self.ballused==pbGetBallType(:LUXURYBALL) gain += 1 if self.ballused==pbGetBallType(:LUXURYBALL)
gain = (gain*1.5).floor if isConst?(self.item,PBItems,:SOOTHEBELL) gain = (gain*1.5).floor if self.hasItem?(:SOOTHEBELL)
end end
@happiness += gain @happiness += gain
@happiness = [[255,@happiness].min,0].max @happiness = [[255,@happiness].min,0].max

View File

@@ -1715,7 +1715,7 @@ class PokemonStorageScreen
if heldpoke || selected[0]==-1 if heldpoke || selected[0]==-1
p = (heldpoke) ? heldpoke : @storage[-1,index] p = (heldpoke) ? heldpoke : @storage[-1,index]
p.formTime = nil if p.respond_to?("formTime") p.formTime = nil if p.respond_to?("formTime")
p.form = 0 if isConst?(p.species,PBSpecies,:SHAYMIN) p.form = 0 if p.isSpecies?(:SHAYMIN)
p.heal p.heal
end end
@scene.pbStore(selected,heldpoke,destbox,firstfree) @scene.pbStore(selected,heldpoke,destbox,firstfree)

View File

@@ -587,7 +587,7 @@ class PokemonEvolutionScene
# Modify Pokémon to make it evolved # Modify Pokémon to make it evolved
@pokemon.species = @newspecies @pokemon.species = @newspecies
@pokemon.name = newspeciesname if @pokemon.name==oldspeciesname @pokemon.name = newspeciesname if @pokemon.name==oldspeciesname
@pokemon.form = 0 if isConst?(@pokemon.species,PBSpecies,:MOTHIM) @pokemon.form = 0 if @pokemon.isSpecies?(:MOTHIM)
@pokemon.calcStats @pokemon.calcStats
# See and own evolved species # See and own evolved species
$Trainer.seen[@newspecies] = true $Trainer.seen[@newspecies] = true

View File

@@ -182,7 +182,7 @@ class PurifyChamber # German: der Kryptorbis
return false if !shadow return false if !shadow
return false if shadow.heartgauge!=0 return false if shadow.heartgauge!=0
# Define an exception for Lugia # Define an exception for Lugia
if isConst?(shadow.species,PBSpecies,:LUGIA) if shadow.isSpecies?(:LUGIA)
maxtempo=PurifyChamber.maximumTempo() maxtempo=PurifyChamber.maximumTempo()
for i in 0...NUMSETS for i in 0...NUMSETS
return false if @sets[i].tempo!=maxtempo return false if @sets[i].tempo!=maxtempo