mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 22:24:58 +00:00
Implemented usage of GameData::Item
This commit is contained in:
@@ -9,6 +9,7 @@ class PokeBattle_Battler
|
||||
attr_accessor :type1
|
||||
attr_accessor :type2
|
||||
attr_accessor :ability_id
|
||||
attr_accessor :item_id
|
||||
attr_accessor :moves
|
||||
attr_accessor :gender
|
||||
attr_accessor :iv
|
||||
@@ -60,19 +61,22 @@ class PokeBattle_Battler
|
||||
end
|
||||
|
||||
def ability
|
||||
return PokemonData::Ability.try_get(@ability_id)
|
||||
return GameData::Ability.try_get(@ability_id)
|
||||
end
|
||||
|
||||
def ability=(value)
|
||||
abil = PokemonData::Ability.try_get(value)
|
||||
@ability_id = (abil) ? abil.id : nil
|
||||
new_ability = GameData::Ability.try_get(value)
|
||||
@ability_id = (new_ability) ? new_ability.id : nil
|
||||
end
|
||||
|
||||
attr_reader :item
|
||||
def item
|
||||
return GameData::Item.try_get(@item_id)
|
||||
end
|
||||
|
||||
def item=(value)
|
||||
@item = value
|
||||
@pokemon.setItem(value) if @pokemon
|
||||
new_item = GameData::Item.try_get(value)
|
||||
@item_id = (new_item) ? new_item.id : nil
|
||||
@pokemon.setItem(@item_id) if @pokemon
|
||||
end
|
||||
|
||||
def defense
|
||||
@@ -195,7 +199,10 @@ class PokeBattle_Battler
|
||||
return (abil) ? abil.name : ""
|
||||
end
|
||||
|
||||
def itemName; return PBItems.getName(@item); end
|
||||
def itemName
|
||||
itm = self.item
|
||||
return (itm) ? itm.name : ""
|
||||
end
|
||||
|
||||
def pbThis(lowerCase=false)
|
||||
if opposes?
|
||||
@@ -240,7 +247,7 @@ class PokeBattle_Battler
|
||||
end
|
||||
# Item effects that alter calculated Speed
|
||||
if itemActive?
|
||||
speedMult = BattleHandlers.triggerSpeedCalcItem(@item,self,speedMult)
|
||||
speedMult = BattleHandlers.triggerSpeedCalcItem(self.item,self,speedMult)
|
||||
end
|
||||
# Other effects
|
||||
speedMult *= 2 if pbOwnSide.effects[PBEffects::Tailwind]>0
|
||||
@@ -266,7 +273,7 @@ class PokeBattle_Battler
|
||||
ret = BattleHandlers.triggerWeightCalcAbility(self.ability,self,ret)
|
||||
end
|
||||
if itemActive?
|
||||
ret = BattleHandlers.triggerWeightCalcItem(@item,self,ret)
|
||||
ret = BattleHandlers.triggerWeightCalcItem(self.item,self,ret)
|
||||
end
|
||||
return [ret,1].max
|
||||
end
|
||||
@@ -331,14 +338,14 @@ class PokeBattle_Battler
|
||||
# active, and the code for the two combined would cause an infinite loop
|
||||
# (regardless of whether any Pokémon actualy has either the ability or
|
||||
# the item - the code existing is enough to cause the loop).
|
||||
def abilityActive?(ignoreFainted=false)
|
||||
return false if fainted? && !ignoreFainted
|
||||
def abilityActive?(ignore_fainted = false)
|
||||
return false if fainted? && !ignore_fainted
|
||||
return false if @effects[PBEffects::GastroAcid]
|
||||
return true
|
||||
end
|
||||
|
||||
def hasActiveAbility?(check_ability, ignoreFainted = false)
|
||||
return false if !abilityActive?(ignoreFainted)
|
||||
def hasActiveAbility?(check_ability, ignore_fainted = false)
|
||||
return false if !abilityActive?(ignore_fainted)
|
||||
return check_ability.include?(@ability_id) if check_ability.is_a?(Array)
|
||||
return check_ability == self.ability
|
||||
end
|
||||
@@ -348,7 +355,7 @@ class PokeBattle_Battler
|
||||
# having self's ability be negated.
|
||||
def unstoppableAbility?(abil = nil)
|
||||
abil = @ability_id if !abil
|
||||
abil = PokemonData::Ability.try_get(abil)
|
||||
abil = GameData::Ability.try_get(abil)
|
||||
return false if !abil
|
||||
ability_blacklist = [
|
||||
# Form-changing abilities
|
||||
@@ -372,7 +379,7 @@ class PokeBattle_Battler
|
||||
# Applies to gaining the ability.
|
||||
def ungainableAbility?(abil = nil)
|
||||
abil = @ability_id if !abil
|
||||
abil = PokemonData::Ability.try_get(abil)
|
||||
abil = GameData::Ability.try_get(abil)
|
||||
return false if !abil
|
||||
ability_blacklist = [
|
||||
# Form-changing abilities
|
||||
@@ -404,28 +411,21 @@ class PokeBattle_Battler
|
||||
return true
|
||||
end
|
||||
|
||||
def hasActiveItem?(item,ignoreFainted=false)
|
||||
return false if !itemActive?(ignoreFainted)
|
||||
if item.is_a?(Array)
|
||||
item.each do |i|
|
||||
i = getID(PBItems,i)
|
||||
return true if i!=0 && i==@item
|
||||
end
|
||||
return false
|
||||
end
|
||||
item = getID(PBItems,item)
|
||||
return item!=0 && item==@item
|
||||
def hasActiveItem?(check_item, ignore_fainted = false)
|
||||
return false if !itemActive?(ignore_fainted)
|
||||
return check_item.include?(@item_id) if check_item.is_a?(Array)
|
||||
return check_item == self.item
|
||||
end
|
||||
alias hasWorkingItem hasActiveItem?
|
||||
|
||||
# Returns whether the specified item will be unlosable for this Pokémon.
|
||||
def unlosableItem?(check_item)
|
||||
return false if check_item <= 0
|
||||
return true if pbIsMail?(check_item)
|
||||
return false if !check_item
|
||||
return true if GameData::Item.get(check_item).is_mail?
|
||||
return false if @effects[PBEffects::Transform]
|
||||
# Items that change a Pokémon's form
|
||||
return true if @pokemon && @pokemon.getMegaForm(true) > 0 # Mega Stone
|
||||
return pbIsUnlosableItem?(check_item, @species, self.ability)
|
||||
return GameData::Item.get(check_item).unlosable?(@species, self.ability)
|
||||
end
|
||||
|
||||
def eachMove
|
||||
|
||||
@@ -22,7 +22,7 @@ class PokeBattle_Battler
|
||||
@hp = @totalhp = 0
|
||||
@type1 = @type2 = 0
|
||||
@ability_id = nil
|
||||
@item = 0
|
||||
@item_id = nil
|
||||
@gender = 0
|
||||
@attack = @defense = @spatk = @spdef = @speed = 0
|
||||
@status = PBStatuses::NONE
|
||||
@@ -79,7 +79,7 @@ class PokeBattle_Battler
|
||||
@type1 = pkmn.type1
|
||||
@type2 = pkmn.type2
|
||||
@ability_id = pkmn.ability_id
|
||||
@item = pkmn.item
|
||||
@item_id = pkmn.item_id
|
||||
@gender = pkmn.gender
|
||||
@attack = pkmn.attack
|
||||
@defense = pkmn.defense
|
||||
@@ -188,7 +188,7 @@ class PokeBattle_Battler
|
||||
@effects[PBEffects::FollowMe] = 0
|
||||
@effects[PBEffects::Foresight] = false
|
||||
@effects[PBEffects::FuryCutter] = 0
|
||||
@effects[PBEffects::GemConsumed] = 0
|
||||
@effects[PBEffects::GemConsumed] = nil
|
||||
@effects[PBEffects::Grudge] = false
|
||||
@effects[PBEffects::HelpingHand] = false
|
||||
@effects[PBEffects::HyperBeam] = 0
|
||||
@@ -227,7 +227,7 @@ class PokeBattle_Battler
|
||||
@effects[PBEffects::Nightmare] = false
|
||||
@effects[PBEffects::Outrage] = 0
|
||||
@effects[PBEffects::ParentalBond] = 0
|
||||
@effects[PBEffects::PickupItem] = 0
|
||||
@effects[PBEffects::PickupItem] = nil
|
||||
@effects[PBEffects::PickupUse] = 0
|
||||
@effects[PBEffects::Pinch] = false
|
||||
@effects[PBEffects::Powder] = false
|
||||
|
||||
@@ -17,7 +17,7 @@ class PokeBattle_Battler
|
||||
@battle.pbEndPrimordialWeather
|
||||
# Items that trigger upon switching in (Air Balloon message)
|
||||
if switchIn && itemActive?
|
||||
BattleHandlers.triggerItemOnSwitchIn(@item,self,@battle)
|
||||
BattleHandlers.triggerItemOnSwitchIn(self.item,self,@battle)
|
||||
end
|
||||
# Berry check, status-curing ability check
|
||||
pbHeldItemTriggerCheck if switchIn
|
||||
@@ -75,7 +75,7 @@ class PokeBattle_Battler
|
||||
choices = []
|
||||
@battle.eachOtherSideBattler(@index) do |b|
|
||||
next if b.ungainableAbility? ||
|
||||
[:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(b.ability)
|
||||
[:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(b.ability_id)
|
||||
choices.push(b)
|
||||
end
|
||||
if choices.length>0
|
||||
@@ -109,7 +109,7 @@ class PokeBattle_Battler
|
||||
@effects[PBEffects::Illusion] = nil
|
||||
if !@effects[PBEffects::Transform]
|
||||
@battle.scene.pbChangePokemon(self, @pokemon)
|
||||
@battle.pbDisplay(_INTL("{1}'s {2} wore off!", pbThis, PokemonData::Ability.get(oldAbil).name))
|
||||
@battle.pbDisplay(_INTL("{1}'s {2} wore off!", pbThis, GameData::Ability.get(oldAbil).name))
|
||||
@battle.pbSetSeen(self)
|
||||
end
|
||||
end
|
||||
@@ -135,32 +135,32 @@ class PokeBattle_Battler
|
||||
|
||||
# permanent is whether the item is lost even after battle. Is false for Knock
|
||||
# Off.
|
||||
def pbRemoveItem(permanent=true)
|
||||
def pbRemoveItem(permanent = true)
|
||||
@effects[PBEffects::ChoiceBand] = -1
|
||||
@effects[PBEffects::Unburden] = true if @item>0
|
||||
setInitialItem(0) if self.initialItem==@item && permanent
|
||||
self.item = 0
|
||||
@effects[PBEffects::Unburden] = true if self.item
|
||||
setInitialItem(nil) if permanent && self.item == self.initialItem
|
||||
self.item = nil
|
||||
end
|
||||
|
||||
def pbConsumeItem(recoverable=true,symbiosis=true,belch=true)
|
||||
PBDebug.log("[Item consumed] #{pbThis} consumed its held #{PBItems.getName(@item)}")
|
||||
PBDebug.log("[Item consumed] #{pbThis} consumed its held #{itemName}")
|
||||
if recoverable
|
||||
setRecycleItem(@item)
|
||||
@effects[PBEffects::PickupItem] = @item
|
||||
setRecycleItem(@item_id)
|
||||
@effects[PBEffects::PickupItem] = @item_id
|
||||
@effects[PBEffects::PickupUse] = @battle.nextPickupUse
|
||||
end
|
||||
setBelched if belch && pbIsBerry?(@item)
|
||||
setBelched if belch && self.item.is_berry?
|
||||
pbRemoveItem
|
||||
pbSymbiosis if symbiosis
|
||||
end
|
||||
|
||||
def pbSymbiosis
|
||||
return if fainted?
|
||||
return if @item!=0
|
||||
return if !self.item
|
||||
@battle.pbPriority(true).each do |b|
|
||||
next if b.opposes?
|
||||
next if !b.hasActiveAbility?(:SYMBIOSIS)
|
||||
next if b.item==0 || b.unlosableItem?(b.item)
|
||||
next if !b.item || b.unlosableItem?(b.item)
|
||||
next if unlosableItem?(b.item)
|
||||
@battle.pbShowAbilitySplash(b)
|
||||
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
|
||||
@@ -171,7 +171,7 @@ class PokeBattle_Battler
|
||||
b.pbThis,b.abilityName,b.itemName,pbThis(true)))
|
||||
end
|
||||
self.item = b.item
|
||||
b.item = 0
|
||||
b.item = nil
|
||||
b.effects[PBEffects::Unburden] = true
|
||||
@battle.pbHideAbilitySplash(b)
|
||||
pbHeldItemTriggerCheck
|
||||
@@ -179,20 +179,22 @@ class PokeBattle_Battler
|
||||
end
|
||||
end
|
||||
|
||||
def pbHeldItemTriggered(thisItem,forcedItem=0,fling=false)
|
||||
# item_to_use is an item ID or GameData::Item object. own_item is whether the
|
||||
# item is held by self. fling is for Fling only.
|
||||
def pbHeldItemTriggered(item_to_use, own_item = true, fling = false)
|
||||
# Cheek Pouch
|
||||
if hasActiveAbility?(:CHEEKPOUCH) && pbIsBerry?(thisItem) && canHeal?
|
||||
if hasActiveAbility?(:CHEEKPOUCH) && GameData::Item.get(item_to_use).is_berry? && canHeal?
|
||||
@battle.pbShowAbilitySplash(self)
|
||||
pbRecoverHP(@totalhp/3)
|
||||
pbRecoverHP(@totalhp / 3)
|
||||
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
|
||||
@battle.pbDisplay(_INTL("{1}'s HP was restored.",pbThis))
|
||||
@battle.pbDisplay(_INTL("{1}'s HP was restored.", pbThis))
|
||||
else
|
||||
@battle.pbDisplay(_INTL("{1}'s {2} restored its HP.",pbThis,abilityName))
|
||||
@battle.pbDisplay(_INTL("{1}'s {2} restored its HP.", pbThis, abilityName))
|
||||
end
|
||||
@battle.pbHideAbilitySplash(self)
|
||||
end
|
||||
pbConsumeItem if forcedItem<=0
|
||||
pbSymbiosis if forcedItem>0 && !fling # Bug Bite/Pluck users trigger Symbiosis
|
||||
pbConsumeItem if own_item
|
||||
pbSymbiosis if !own_item && !fling # Bug Bite/Pluck users trigger Symbiosis
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -201,96 +203,91 @@ class PokeBattle_Battler
|
||||
# NOTE: A Pokémon using Bug Bite/Pluck, and a Pokémon having an item thrown at
|
||||
# it via Fling, will gain the effect of the item even if the Pokémon is
|
||||
# affected by item-negating effects.
|
||||
# If forcedItem is -1, the Pokémon's held item is forced to be consumed. If it
|
||||
# is greater than 0, a different item (of that ID) is forced to be consumed
|
||||
# (not the Pokémon's held one).
|
||||
def pbHeldItemTriggerCheck(forcedItem=0,fling=false)
|
||||
# item_to_use is an item ID for Bug Bite/Pluck and Fling, and nil otherwise.
|
||||
# fling is for Fling only.
|
||||
def pbHeldItemTriggerCheck(item_to_use = nil, fling = false)
|
||||
return if fainted?
|
||||
return if forcedItem==0 && !itemActive?
|
||||
pbItemHPHealCheck(forcedItem,fling)
|
||||
pbItemStatusCureCheck(forcedItem,fling)
|
||||
pbItemEndOfMoveCheck(forcedItem,fling)
|
||||
return if !item_to_use && !itemActive?
|
||||
pbItemHPHealCheck(item_to_use, fling)
|
||||
pbItemStatusCureCheck(item_to_use, fling)
|
||||
pbItemEndOfMoveCheck(item_to_use, fling)
|
||||
# For Enigma Berry, Kee Berry and Maranga Berry, which have their effects
|
||||
# when forcibly consumed by Pluck/Fling.
|
||||
if forcedItem!=0
|
||||
thisItem = (forcedItem>0) ? forcedItem : @item
|
||||
if BattleHandlers.triggerTargetItemOnHitPositiveBerry(thisItem,self,@battle,true)
|
||||
pbHeldItemTriggered(thisItem,forcedItem,fling)
|
||||
if item_to_use
|
||||
itm = item_to_use || self.item
|
||||
if BattleHandlers.triggerTargetItemOnHitPositiveBerry(itm, self, @battle, true)
|
||||
pbHeldItemTriggered(itm, false, fling)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# forcedItem is an item ID for Bug Bite/Pluck/Fling, and 0 otherwise.
|
||||
# item_to_use is an item ID for Bug Bite/Pluck and Fling, and nil otherwise.
|
||||
# fling is for Fling only.
|
||||
def pbItemHPHealCheck(forcedItem=0,fling=false)
|
||||
return if forcedItem==0 && !itemActive?
|
||||
thisItem = (forcedItem>0) ? forcedItem : @item
|
||||
if BattleHandlers.triggerHPHealItem(thisItem,self,@battle,(forcedItem!=0))
|
||||
pbHeldItemTriggered(thisItem,forcedItem,fling)
|
||||
elsif forcedItem==0
|
||||
def pbItemHPHealCheck(item_to_use = nil, fling = false)
|
||||
return if !item_to_use && !itemActive?
|
||||
itm = item_to_use || self.item
|
||||
if BattleHandlers.triggerHPHealItem(itm, self, @battle, !item_to_use.nil?)
|
||||
pbHeldItemTriggered(itm, item_to_use.nil?, fling)
|
||||
elsif !item_to_use
|
||||
pbItemTerrainStatBoostCheck
|
||||
end
|
||||
end
|
||||
|
||||
# Cures status conditions, confusion, infatuation and the other effects cured
|
||||
# by Mental Herb.
|
||||
# forcedItem is an item ID for Pluck/Fling, and 0 otherwise. fling is for
|
||||
# Fling only.
|
||||
def pbItemStatusCureCheck(forcedItem=0,fling=false)
|
||||
# item_to_use is an item ID for Bug Bite/Pluck and Fling, and nil otherwise.
|
||||
# fling is for Fling only.
|
||||
def pbItemStatusCureCheck(item_to_use = nil, fling = false)
|
||||
return if fainted?
|
||||
return if forcedItem==0 && !itemActive?
|
||||
thisItem = (forcedItem>0) ? forcedItem : @item
|
||||
if BattleHandlers.triggerStatusCureItem(thisItem,self,@battle,(forcedItem!=0))
|
||||
pbHeldItemTriggered(thisItem,forcedItem,fling)
|
||||
return if !item_to_use && !itemActive?
|
||||
itm = item_to_use || self.item
|
||||
if BattleHandlers.triggerStatusCureItem(itm, self, @battle, !item_to_use.nil?)
|
||||
pbHeldItemTriggered(itm, item_to_use.nil?, fling)
|
||||
end
|
||||
end
|
||||
|
||||
# Called at the end of using a move.
|
||||
# forcedItem is an item ID for Pluck/Fling, and 0 otherwise. fling is for
|
||||
# Fling only.
|
||||
def pbItemEndOfMoveCheck(forcedItem=0,fling=false)
|
||||
# item_to_use is an item ID for Bug Bite/Pluck and Fling, and nil otherwise.
|
||||
# fling is for Fling only.
|
||||
def pbItemEndOfMoveCheck(item_to_use = nil, fling = false)
|
||||
return if fainted?
|
||||
return if forcedItem==0 && !itemActive?
|
||||
thisItem = (forcedItem>0) ? forcedItem : @item
|
||||
if BattleHandlers.triggerEndOfMoveItem(thisItem,self,@battle,(forcedItem!=0))
|
||||
pbHeldItemTriggered(thisItem,forcedItem,fling)
|
||||
elsif BattleHandlers.triggerEndOfMoveStatRestoreItem(thisItem,self,@battle,(forcedItem!=0))
|
||||
pbHeldItemTriggered(thisItem,forcedItem,fling)
|
||||
return if !item_to_use && !itemActive?
|
||||
itm = item_to_use || self.item
|
||||
if BattleHandlers.triggerEndOfMoveItem(itm, self, @battle, !item_to_use.nil?)
|
||||
pbHeldItemTriggered(itm, item_to_use.nil?, fling)
|
||||
elsif BattleHandlers.triggerEndOfMoveStatRestoreItem(itm, self, @battle, !item_to_use.nil?)
|
||||
pbHeldItemTriggered(itm, item_to_use.nil?, fling)
|
||||
end
|
||||
end
|
||||
|
||||
# Used for White Herb (restore lowered stats). Only called by Moody and Sticky
|
||||
# Web, as all other stat reduction happens because of/during move usage and
|
||||
# this handler is also called at the end of each move's usage.
|
||||
# forcedItem is an item ID for Pluck/Fling, and 0 otherwise. fling is for
|
||||
# Fling only.
|
||||
def pbItemStatRestoreCheck(forcedItem=0,fling=false)
|
||||
# item_to_use is an item ID for Bug Bite/Pluck and Fling, and nil otherwise.
|
||||
# fling is for Fling only.
|
||||
def pbItemStatRestoreCheck(item_to_use = nil, fling = false)
|
||||
return if fainted?
|
||||
return if forcedItem==0 && !itemActive?
|
||||
thisItem = (forcedItem>0) ? forcedItem : @item
|
||||
if BattleHandlers.triggerEndOfMoveStatRestoreItem(thisItem,self,@battle,(forcedItem!=0))
|
||||
pbHeldItemTriggered(thisItem,forcedItem,fling)
|
||||
return if !item_to_use && !itemActive?
|
||||
itm = item_to_use || self.item
|
||||
if BattleHandlers.triggerEndOfMoveStatRestoreItem(itm, self, @battle, !item_to_use.nil?)
|
||||
pbHeldItemTriggered(itm, item_to_use.nil?, fling)
|
||||
end
|
||||
end
|
||||
|
||||
# Called when the battle terrain changes and when a Pokémon loses HP.
|
||||
# forcedItem is an item ID for Pluck/Fling, and 0 otherwise. fling is for
|
||||
# Fling only.
|
||||
def pbItemTerrainStatBoostCheck
|
||||
return if !itemActive?
|
||||
if BattleHandlers.triggerTerrainStatBoostItem(@item,self,@battle)
|
||||
pbHeldItemTriggered(@item)
|
||||
if BattleHandlers.triggerTerrainStatBoostItem(self.item, self, @battle)
|
||||
pbHeldItemTriggered(self.item)
|
||||
end
|
||||
end
|
||||
|
||||
# Used for Adrenaline Orb. Called when Intimidate is triggered (even if
|
||||
# Intimidate has no effect on the Pokémon).
|
||||
# forcedItem is an item ID for Pluck/Fling, and 0 otherwise. fling is for
|
||||
# Fling only.
|
||||
def pbItemOnIntimidatedCheck
|
||||
return if !itemActive?
|
||||
if BattleHandlers.triggerItemOnIntimidated(@item,self,@battle)
|
||||
pbHeldItemTriggered(@item)
|
||||
if BattleHandlers.triggerItemOnIntimidated(self.item, self, @battle)
|
||||
pbHeldItemTriggered(self.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -116,7 +116,7 @@ class PokeBattle_Battler
|
||||
end
|
||||
end
|
||||
@effects[PBEffects::Charge] = 0 if @effects[PBEffects::Charge]==1
|
||||
@effects[PBEffects::GemConsumed] = 0
|
||||
@effects[PBEffects::GemConsumed] = nil
|
||||
@battle.eachBattler { |b| b.pbContinualAbilityChecks } # Trace, end primordial weathers
|
||||
end
|
||||
|
||||
@@ -624,12 +624,12 @@ class PokeBattle_Battler
|
||||
# Show move animation (for this hit)
|
||||
move.pbShowAnimation(move.id,user,targets,hitNum)
|
||||
# Type-boosting Gem consume animation/message
|
||||
if user.effects[PBEffects::GemConsumed]>0 && hitNum==0
|
||||
if user.effects[PBEffects::GemConsumed] && hitNum==0
|
||||
# NOTE: The consume animation and message for Gems are shown now, but the
|
||||
# actual removal of the item happens in def pbEffectsAfterMove.
|
||||
@battle.pbCommonAnimation("UseItem",user)
|
||||
@battle.pbDisplay(_INTL("The {1} strengthened {2}'s power!",
|
||||
PBItems.getName(user.effects[PBEffects::GemConsumed]),move.name))
|
||||
GameData::Item.get(user.effects[PBEffects::GemConsumed]).name,move.name))
|
||||
end
|
||||
# Messages about missed target(s) (relevant for multi-target moves only)
|
||||
targets.each do |b|
|
||||
|
||||
@@ -111,7 +111,7 @@ class PokeBattle_Battler
|
||||
end
|
||||
end
|
||||
# Consume user's Gem
|
||||
if user.effects[PBEffects::GemConsumed]>0
|
||||
if user.effects[PBEffects::GemConsumed]
|
||||
# NOTE: The consume animation and message for Gems are shown immediately
|
||||
# after the move's animation, but the item is only consumed now.
|
||||
user.pbConsumeItem
|
||||
|
||||
@@ -1997,7 +1997,7 @@ end
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_063 < PokeBattle_Move
|
||||
def pbMoveFailed?(user,targets)
|
||||
if !PokemonData::Ability.exists?(:SIMPLE)
|
||||
if !GameData::Ability.exists?(:SIMPLE)
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -2030,7 +2030,7 @@ end
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_064 < PokeBattle_Move
|
||||
def pbMoveFailed?(user,targets)
|
||||
if !PokemonData::Ability.exists?(:INSOMNIA)
|
||||
if !GameData::Ability.exists?(:INSOMNIA)
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -93,7 +93,7 @@ end
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_086 < PokeBattle_Move
|
||||
def pbBaseDamageMultiplier(damageMult,user,target)
|
||||
damageMult *= 2 if user.item==0
|
||||
damageMult *= 2 if !user.item
|
||||
return damageMult
|
||||
end
|
||||
end
|
||||
@@ -473,13 +473,13 @@ class PokeBattle_Move_096 < PokeBattle_Move
|
||||
:ENIGMABERRY, :MICLEBERRY, :CUSTAPBERRY, :JABOCABERRY, :ROWAPBERRY,
|
||||
:KEEBERRY, :MARANGABERRY]
|
||||
}
|
||||
@berry = 0
|
||||
@berry = nil
|
||||
end
|
||||
|
||||
def pbMoveFailed?(user,targets)
|
||||
# NOTE: Unnerve does not stop a Pokémon using this move.
|
||||
@berry = user.item
|
||||
if !pbIsBerry?(@berry) || !user.itemActive?
|
||||
if !@berry || !@berry.is_berry? || !user.itemActive?
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -492,14 +492,10 @@ class PokeBattle_Move_096 < PokeBattle_Move
|
||||
# complex item movement is unlikely, perhaps this is good enough.
|
||||
def pbBaseType(user)
|
||||
ret = getID(PBTypes,:NORMAL)
|
||||
found = false
|
||||
@typeArray.each do |type, items|
|
||||
items.each do |i|
|
||||
next if !isConst?(@berry,PBItems,i)
|
||||
ret = getConst(PBTypes,type) || ret
|
||||
found = true; break
|
||||
end
|
||||
break if found
|
||||
next if !items.include?(@berry.id)
|
||||
ret = getConst(PBTypes,type) || ret
|
||||
break
|
||||
end
|
||||
return ret
|
||||
end
|
||||
@@ -507,21 +503,17 @@ class PokeBattle_Move_096 < PokeBattle_Move
|
||||
# This is a separate method so that the AI can use it as well
|
||||
def pbNaturalGiftBaseDamage(heldItem)
|
||||
ret = 1
|
||||
found = false
|
||||
@damageArray.each do |dmg, items|
|
||||
items.each do |i|
|
||||
next if !isConst?(heldItem,PBItems,i)
|
||||
ret = dmg
|
||||
ret += 20 if NEWEST_BATTLE_MECHANICS
|
||||
found = true; break
|
||||
end
|
||||
break if found
|
||||
next if !items.include?(heldItem)
|
||||
ret = dmg
|
||||
ret += 20 if NEWEST_BATTLE_MECHANICS
|
||||
break
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbBaseDamage(baseDmg,user,target)
|
||||
return pbNaturalGiftBaseDamage(@berry)
|
||||
return pbNaturalGiftBaseDamage(@berry.id)
|
||||
end
|
||||
|
||||
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers)
|
||||
@@ -529,8 +521,8 @@ class PokeBattle_Move_096 < PokeBattle_Move
|
||||
# missed. The item is not consumed if the target was switched out by
|
||||
# an effect like a target's Red Card.
|
||||
# NOTE: There is no item consumption animation.
|
||||
user.pbConsumeItem(true,true,false) if user.item>0
|
||||
@berry = 0
|
||||
user.pbConsumeItem(true,true,false) if user.item
|
||||
@berry = nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -776,7 +768,7 @@ class PokeBattle_Move_09F < PokeBattle_Move
|
||||
ret = getID(PBTypes,:NORMAL)
|
||||
if user.itemActive?
|
||||
@itemTypes.each do |item, itemType|
|
||||
next if !isConst?(user.item,PBItems,item)
|
||||
next if user.item != item
|
||||
t = getConst(PBTypes,itemType)
|
||||
ret = t || ret
|
||||
break
|
||||
@@ -3195,7 +3187,7 @@ end
|
||||
class PokeBattle_Move_0F0 < PokeBattle_Move
|
||||
def pbBaseDamage(baseDmg,user,target)
|
||||
if NEWEST_BATTLE_MECHANICS &&
|
||||
target.item!=0 && !target.unlosableItem?(target.item)
|
||||
target.item && !target.unlosableItem?(target.item)
|
||||
# NOTE: Damage is still boosted even if target has Sticky Hold or a
|
||||
# substitute.
|
||||
baseDmg = (baseDmg*1.5).round
|
||||
@@ -3207,7 +3199,7 @@ class PokeBattle_Move_0F0 < PokeBattle_Move
|
||||
return if @battle.wildBattle? && user.opposes? # Wild Pokémon can't knock off
|
||||
return if user.fainted?
|
||||
return if target.damageState.unaffected || target.damageState.substitute
|
||||
return if target.item==0 || target.unlosableItem?(target.item)
|
||||
return if !target.item || target.unlosableItem?(target.item)
|
||||
return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker
|
||||
itemName = target.itemName
|
||||
target.pbRemoveItem(false)
|
||||
@@ -3226,7 +3218,7 @@ class PokeBattle_Move_0F1 < PokeBattle_Move
|
||||
return if @battle.wildBattle? && user.opposes? # Wild Pokémon can't thieve
|
||||
return if user.fainted?
|
||||
return if target.damageState.unaffected || target.damageState.substitute
|
||||
return if target.item==0 || user.item!=0
|
||||
return if !target.item || user.item
|
||||
return if target.unlosableItem?(target.item)
|
||||
return if user.unlosableItem?(target.item)
|
||||
return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker
|
||||
@@ -3234,7 +3226,7 @@ class PokeBattle_Move_0F1 < PokeBattle_Move
|
||||
user.item = target.item
|
||||
# Permanently steal the item from wild Pokémon
|
||||
if @battle.wildBattle? && target.opposes? &&
|
||||
target.initialItem==target.item && user.initialItem==0
|
||||
target.initialItem==target.item && !user.initialItem
|
||||
user.setInitialItem(target.item)
|
||||
target.pbRemoveItem
|
||||
else
|
||||
@@ -3261,7 +3253,7 @@ class PokeBattle_Move_0F2 < PokeBattle_Move
|
||||
end
|
||||
|
||||
def pbFailsAgainstTarget?(user,target)
|
||||
if user.item==0 && target.item==0
|
||||
if !user.item && !target.item
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -3291,22 +3283,22 @@ class PokeBattle_Move_0F2 < PokeBattle_Move
|
||||
oldTargetItem = target.item; oldTargetItemName = target.itemName
|
||||
user.item = oldTargetItem
|
||||
user.effects[PBEffects::ChoiceBand] = -1
|
||||
user.effects[PBEffects::Unburden] = (user.item==0 && oldUserItem>0)
|
||||
user.effects[PBEffects::Unburden] = (!user.item && oldUserItem)
|
||||
target.item = oldUserItem
|
||||
target.effects[PBEffects::ChoiceBand] = -1
|
||||
target.effects[PBEffects::Unburden] = (target.item==0 && oldTargetItem>0)
|
||||
target.effects[PBEffects::Unburden] = (!target.item && oldTargetItem)
|
||||
# Permanently steal the item from wild Pokémon
|
||||
if @battle.wildBattle? && target.opposes? &&
|
||||
target.initialItem==oldTargetItem && user.initialItem==0
|
||||
target.initialItem==oldTargetItem && !user.initialItem
|
||||
user.setInitialItem(oldTargetItem)
|
||||
end
|
||||
@battle.pbDisplay(_INTL("{1} switched items with its opponent!",user.pbThis))
|
||||
if oldUserItem>0 && oldTargetItem>0
|
||||
if oldUserItem && oldTargetItem
|
||||
@battle.pbDisplay(_INTL("{1} obtained {2}.",user.pbThis,oldTargetItemName))
|
||||
elsif oldTargetItem>0
|
||||
elsif oldTargetItem
|
||||
@battle.pbDisplay(_INTL("{1} obtained {2}.",user.pbThis,oldTargetItemName))
|
||||
end
|
||||
@battle.pbDisplay(_INTL("{1} obtained {2}.",target.pbThis,oldUserItemName)) if oldUserItem>0
|
||||
@battle.pbDisplay(_INTL("{1} obtained {2}.",target.pbThis,oldUserItemName)) if oldUserItem
|
||||
user.pbHeldItemTriggerCheck
|
||||
target.pbHeldItemTriggerCheck
|
||||
end
|
||||
@@ -3325,7 +3317,7 @@ class PokeBattle_Move_0F3 < PokeBattle_Move
|
||||
end
|
||||
|
||||
def pbMoveFailed?(user,targets)
|
||||
if user.item==0 || user.unlosableItem?(user.item)
|
||||
if !user.item || user.unlosableItem?(user.item)
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -3333,7 +3325,7 @@ class PokeBattle_Move_0F3 < PokeBattle_Move
|
||||
end
|
||||
|
||||
def pbFailsAgainstTarget?(user,target)
|
||||
if target.item!=0 || target.unlosableItem?(user.item)
|
||||
if target.item || target.unlosableItem?(user.item)
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -3345,7 +3337,7 @@ class PokeBattle_Move_0F3 < PokeBattle_Move
|
||||
target.item = user.item
|
||||
# Permanently steal the item from wild Pokémon
|
||||
if @battle.wildBattle? && user.opposes? &&
|
||||
user.initialItem==user.item && target.initialItem==0
|
||||
user.initialItem==user.item && !target.initialItem
|
||||
target.setInitialItem(user.item)
|
||||
user.pbRemoveItem
|
||||
else
|
||||
@@ -3365,7 +3357,7 @@ class PokeBattle_Move_0F4 < PokeBattle_Move
|
||||
def pbEffectAfterAllHits(user,target)
|
||||
return if user.fainted? || target.fainted?
|
||||
return if target.damageState.unaffected || target.damageState.substitute
|
||||
return if target.item==0 || !pbIsBerry?(target.item)
|
||||
return if !target.item || !target.item.is_berry?
|
||||
return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker
|
||||
item = target.item
|
||||
itemName = target.itemName
|
||||
@@ -3383,8 +3375,8 @@ end
|
||||
class PokeBattle_Move_0F5 < PokeBattle_Move
|
||||
def pbEffectWhenDealingDamage(user,target)
|
||||
return if target.damageState.substitute || target.damageState.berryWeakened
|
||||
return if !pbIsBerry?(target.item) &&
|
||||
!(NEWEST_BATTLE_MECHANICS && pbIsGem?(target.item))
|
||||
return if !target.item || (!target.item.is_berry? &&
|
||||
!(NEWEST_BATTLE_MECHANICS && target.item.is_gem?))
|
||||
target.pbRemoveItem
|
||||
@battle.pbDisplay(_INTL("{1}'s {2} was incinerated!",target.pbThis,target.itemName))
|
||||
end
|
||||
@@ -3397,7 +3389,7 @@ end
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_0F6 < PokeBattle_Move
|
||||
def pbMoveFailed?(user,targets)
|
||||
if user.recycleItem==0
|
||||
if !user.recycleItem
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -3407,11 +3399,11 @@ class PokeBattle_Move_0F6 < PokeBattle_Move
|
||||
def pbEffectGeneral(user)
|
||||
item = user.recycleItem
|
||||
user.item = item
|
||||
user.setInitialItem(item) if @battle.wildBattle? && user.initialItem==0
|
||||
user.setRecycleItem(0)
|
||||
user.effects[PBEffects::PickupItem] = 0
|
||||
user.setInitialItem(item) if @battle.wildBattle? && !user.initialItem
|
||||
user.setRecycleItem(nil)
|
||||
user.effects[PBEffects::PickupItem] = nil
|
||||
user.effects[PBEffects::PickupUse] = 0
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if itemName.starts_with_vowel?
|
||||
@battle.pbDisplay(_INTL("{1} found an {2}!",user.pbThis,itemName))
|
||||
else
|
||||
@@ -3545,20 +3537,18 @@ class PokeBattle_Move_0F7 < PokeBattle_Move
|
||||
|
||||
def pbCheckFlingSuccess(user)
|
||||
@willFail = false
|
||||
@willFail = true if user.item==0 || !user.itemActive? || user.unlosableItem?(user.item)
|
||||
if pbIsBerry?(user.item)
|
||||
@willFail = true if @battle.pbCheckOpposingAbility(:UNNERVE,user.index)
|
||||
return
|
||||
@willFail = true if !user.item || !user.itemActive? || user.unlosableItem?(user.item)
|
||||
return if @willFail
|
||||
if user.item.is_berry? && @battle.pbCheckOpposingAbility(:UNNERVE,user.index)
|
||||
@willFail = true
|
||||
end
|
||||
return if pbIsMegaStone?(user.item)
|
||||
return if @willFail
|
||||
return if user.item.is_mega_stone?
|
||||
flingableItem = false
|
||||
@flingPowers.each do |_power,items|
|
||||
items.each do |i|
|
||||
next if !isConst?(user.item,PBItems,i)
|
||||
flingableItem = true
|
||||
break
|
||||
end
|
||||
break if flingableItem
|
||||
@flingPowers.each do |_power, items|
|
||||
next if !items.include?(user.item_id)
|
||||
flingableItem = true
|
||||
break
|
||||
end
|
||||
@willFail = true if !flingableItem
|
||||
end
|
||||
@@ -3582,10 +3572,10 @@ class PokeBattle_Move_0F7 < PokeBattle_Move
|
||||
def pbNumHits(user,targets); return 1; end
|
||||
|
||||
def pbBaseDamage(baseDmg,user,target)
|
||||
return 10 if pbIsBerry?(user.item)
|
||||
return 80 if pbIsMegaStone?(user.item)
|
||||
return 10 if user.item && user.item.is_berry?
|
||||
return 80 if user.item && user.item.is_mega_stone?
|
||||
@flingPowers.each do |power,items|
|
||||
items.each { |i| return power if isConst?(user.item,PBItems,i) }
|
||||
return power if items.include?(user.item_id)
|
||||
end
|
||||
return 10
|
||||
end
|
||||
@@ -3593,16 +3583,16 @@ class PokeBattle_Move_0F7 < PokeBattle_Move
|
||||
def pbEffectAgainstTarget(user,target)
|
||||
return if target.damageState.substitute
|
||||
return if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker
|
||||
if isConst?(user.item,PBItems,:POISONBARB)
|
||||
case user.item_id
|
||||
when :POISONBARB
|
||||
target.pbPoison(user) if target.pbCanPoison?(user,false,self)
|
||||
elsif isConst?(user.item,PBItems,:TOXICORB)
|
||||
when :TOXICORB
|
||||
target.pbPoison(user,nil,true) if target.pbCanPoison?(user,false,self)
|
||||
elsif isConst?(user.item,PBItems,:FLAMEORB)
|
||||
when :FLAMEORB
|
||||
target.pbBurn(user) if target.pbCanBurn?(user,false,self)
|
||||
elsif isConst?(user.item,PBItems,:LIGHTBALL)
|
||||
when :LIGHTBALL
|
||||
target.pbParalyze(user) if target.pbCanParalyze?(user,false,self)
|
||||
elsif isConst?(user.item,PBItems,:KINGSROCK) ||
|
||||
isConst?(user.item,PBItems,:RAZORFANG)
|
||||
when :KINGSROCK, :RAZORFANG
|
||||
target.pbFlinch(user)
|
||||
else
|
||||
target.pbHeldItemTriggerCheck(user.item,true)
|
||||
@@ -3614,7 +3604,7 @@ class PokeBattle_Move_0F7 < PokeBattle_Move
|
||||
# missed. The item is not consumed if the target was switched out by
|
||||
# an effect like a target's Red Card.
|
||||
# NOTE: There is no item consumption animation.
|
||||
user.pbConsumeItem(true,true,false) if user.item>0
|
||||
user.pbConsumeItem(true,true,false) if user.item
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ module PokeBattle_BattleCommon
|
||||
storedBox = @peer.pbStorePokemon(pbPlayer,pkmn)
|
||||
if storedBox<0
|
||||
pbDisplayPaused(_INTL("{1} has been added to your party.",pkmn.name))
|
||||
@initialItems[0][pbPlayer.party.length-1] = pkmn.item if @initialItems
|
||||
@initialItems[0][pbPlayer.party.length-1] = pkmn.item_id if @initialItems
|
||||
return
|
||||
end
|
||||
# Messages saying the Pokémon was stored in a PC box
|
||||
@@ -80,7 +80,7 @@ module PokeBattle_BattleCommon
|
||||
end
|
||||
end
|
||||
# Messages
|
||||
itemName = PBItems.getName(ball)
|
||||
itemName = GameData::Item.get(ball).name
|
||||
if battler.fainted?
|
||||
if itemName.starts_with_vowel?
|
||||
pbDisplay(_INTL("{1} threw an {2}!",pbPlayer.name,itemName))
|
||||
@@ -97,7 +97,7 @@ module PokeBattle_BattleCommon
|
||||
end
|
||||
# Animation of opposing trainer blocking Poké Balls (unless it's a Snag Ball
|
||||
# at a Shadow Pokémon)
|
||||
if trainerBattle? && !(pbIsSnagBall?(ball) && battler.shadowPokemon?)
|
||||
if trainerBattle? && !(GameData::Item.get(ball).is_snag_ball? && battler.shadowPokemon?)
|
||||
@scene.pbThrowAndDeflect(ball,1)
|
||||
pbDisplay(_INTL("The Trainer blocked your Poké Ball! Don't be a thief!"))
|
||||
return
|
||||
@@ -140,7 +140,7 @@ module PokeBattle_BattleCommon
|
||||
@decision = 4 if pbAllFainted?(battler.index) # Battle ended by capture
|
||||
end
|
||||
# Modify the Pokémon's properties because of the capture
|
||||
if pbIsSnagBall?(ball)
|
||||
if GameData::Item.get(ball).is_snag_ball?
|
||||
pkmn.owner = Pokemon::Owner.new_from_trainer(pbPlayer)
|
||||
end
|
||||
BallHandlers.onCatch(ball,self,pkmn)
|
||||
@@ -180,7 +180,7 @@ module PokeBattle_BattleCommon
|
||||
battler.isSpecies?(:NAGANADEL) ||
|
||||
battler.isSpecies?(:STAKATAKA) ||
|
||||
battler.isSpecies?(:BLACEPHALON))
|
||||
if !ultraBeast || isConst?(ball,PBItems,:BEASTBALL)
|
||||
if !ultraBeast || ball == :BEASTBALL
|
||||
rareness = BallHandlers.modifyCatchRate(ball,rareness,self,battler,ultraBeast)
|
||||
else
|
||||
rareness /= 10
|
||||
|
||||
@@ -144,13 +144,13 @@ class PokeBattle_Battle
|
||||
[-1] * (@opponent ? @opponent.length : 1)
|
||||
]
|
||||
@initialItems = [
|
||||
Array.new(@party1.length) { |i| (@party1[i]) ? @party1[i].item : 0 },
|
||||
Array.new(@party2.length) { |i| (@party2[i]) ? @party2[i].item : 0 }
|
||||
Array.new(@party1.length) { |i| (@party1[i]) ? @party1[i].item_id : nil },
|
||||
Array.new(@party2.length) { |i| (@party2[i]) ? @party2[i].item_id : nil }
|
||||
]
|
||||
@recycleItems = [Array.new(@party1.length,0),Array.new(@party2.length,0)]
|
||||
@belch = [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)]
|
||||
@recycleItems = [Array.new(@party1.length, nil), Array.new(@party2.length, nil)]
|
||||
@belch = [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)]
|
||||
@successStates = []
|
||||
@lastMoveUsed = -1
|
||||
@lastMoveUser = -1
|
||||
|
||||
@@ -478,7 +478,7 @@ class PokeBattle_Battle
|
||||
pbParty(0).each_with_index do |pkmn,i|
|
||||
next if !pkmn
|
||||
@peer.pbOnLeavingBattle(self,pkmn,@usedInBattle[0][i],true) # Reset form
|
||||
pkmn.setItem(@initialItems[0][i] || 0)
|
||||
pkmn.setItem(@initialItems[0][i])
|
||||
end
|
||||
return @decision
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ class PokeBattle_Battle
|
||||
return if !@internalBattle || !@expGain
|
||||
# Go through each battler in turn to find the Pokémon that participated in
|
||||
# battle against it, and award those Pokémon Exp/EVs
|
||||
expAll = (hasConst?(PBItems,:EXPALL) && $PokemonBag.pbHasItem?(:EXPALL))
|
||||
expAll = (GameData::Item.exists?(:EXPALL) && $PokemonBag.pbHasItem?(:EXPALL))
|
||||
p1 = pbParty(0)
|
||||
@battlers.each do |b|
|
||||
next unless b && b.opposes? # Can only gain Exp from fainted foes
|
||||
@@ -25,8 +25,7 @@ class PokeBattle_Battle
|
||||
if !expAll
|
||||
eachInTeam(0,0) do |pkmn,i|
|
||||
next if !pkmn.able?
|
||||
next if !pkmn.hasItem?(:EXPSHARE) &&
|
||||
!isConst?(@initialItems[0][i],PBItems,:EXPSHARE)
|
||||
next if !pkmn.hasItem?(:EXPSHARE) && GameData::Item.try_get(@initialItems[0][i]) != :EXPSHARE
|
||||
expShare.push(i)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -323,8 +323,7 @@ class PokeBattle_Battle
|
||||
pbDisplay(_INTL("Oh!\nA Shadow Pokémon!"))
|
||||
end
|
||||
# Record money-doubling effect of Amulet Coin/Luck Incense
|
||||
if !battler.opposes? && (isConst?(battler.item,PBItems,:AMULETCOIN) ||
|
||||
isConst?(battler.item,PBItems,:LUCKINCENSE))
|
||||
if !battler.opposes? && [:AMULETCOIN, :LUCKINCENSE].include?(battler.item_id)
|
||||
@field.effects[PBEffects::AmuletCoin] = true
|
||||
end
|
||||
# Update battlers' participants (who will gain Exp/EVs when a battler faints)
|
||||
|
||||
@@ -20,7 +20,7 @@ class PokeBattle_Battle
|
||||
# below is one half of making this happen; the other half is in the
|
||||
# ItemHandlers::CanUseInBattle for Poké Balls.
|
||||
def pbItemUsesAllActions?(item)
|
||||
return true if pbIsPokeBall?(item)
|
||||
return true if GameData::Item.get(item).is_poke_ball?
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -40,9 +40,9 @@ class PokeBattle_Battle
|
||||
# Using an item
|
||||
#=============================================================================
|
||||
def pbConsumeItemInBag(item,idxBattler)
|
||||
return if item==0
|
||||
useType = pbGetItemData(item,ItemData::BATTLE_USE)
|
||||
return if !useType || useType==0 || (useType>=6 && useType<=10) # Not consumed upon use
|
||||
return if !item
|
||||
useType = GameData::Item.get(item).battle_use
|
||||
return if useType==0 || (useType>=6 && useType<=10) # Not consumed upon use
|
||||
if pbOwnedByPlayer?(idxBattler)
|
||||
if !$PokemonBag.pbDeleteItem(item)
|
||||
raise _INTL("Tried to consume item that wasn't in the Bag somehow.")
|
||||
@@ -59,9 +59,9 @@ class PokeBattle_Battle
|
||||
end
|
||||
|
||||
def pbReturnUnusedItemToBag(item,idxBattler)
|
||||
return if item==0
|
||||
useType = pbGetItemData(item,ItemData::BATTLE_USE)
|
||||
return if !useType || useType==0 || (useType>=6 && useType<=10) # Not consumed upon use
|
||||
return if item!
|
||||
useType = GameData::Item.get(item).battle_use
|
||||
return if useType==0 || (useType>=6 && useType<=10) # Not consumed upon use
|
||||
if pbOwnedByPlayer?(idxBattler)
|
||||
if $PokemonBag && $PokemonBag.pbCanStore?(item)
|
||||
$PokemonBag.pbStoreItem(item)
|
||||
@@ -75,7 +75,7 @@ class PokeBattle_Battle
|
||||
end
|
||||
|
||||
def pbUseItemMessage(item,trainerName)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if itemName.starts_with_vowel?
|
||||
pbDisplayBrief(_INTL("{1} used an {2}.",trainerName,itemName))
|
||||
else
|
||||
@@ -92,7 +92,7 @@ class PokeBattle_Battle
|
||||
ch = @choices[userBattler.index]
|
||||
if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false)
|
||||
ItemHandlers.triggerBattleUseOnPokemon(item,pkmn,battler,ch,@scene)
|
||||
ch[1] = 0 # Delete item from choice
|
||||
ch[1] = nil # Delete item from choice
|
||||
return
|
||||
end
|
||||
pbDisplay(_INTL("But it had no effect!"))
|
||||
@@ -109,7 +109,7 @@ class PokeBattle_Battle
|
||||
ch = @choices[userBattler.index]
|
||||
if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false)
|
||||
ItemHandlers.triggerBattleUseOnBattler(item,battler,@scene)
|
||||
ch[1] = 0 # Delete item from choice
|
||||
ch[1] = nil # Delete item from choice
|
||||
return
|
||||
end
|
||||
pbDisplay(_INTL("But it's not where this item can be used!"))
|
||||
@@ -122,7 +122,7 @@ class PokeBattle_Battle
|
||||
idxBattler = userBattler.index if idxBattler<0
|
||||
battler = @battlers[idxBattler]
|
||||
ItemHandlers.triggerUseInBattle(item,battler,self)
|
||||
@choices[userBattler.index][1] = 0 # Delete item from choice
|
||||
@choices[userBattler.index][1] = nil # Delete item from choice
|
||||
end
|
||||
|
||||
# Uses an item in battle directly.
|
||||
@@ -134,7 +134,7 @@ class PokeBattle_Battle
|
||||
ch = @choices[userBattler.index]
|
||||
if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false)
|
||||
ItemHandlers.triggerUseInBattle(item,battler,self)
|
||||
ch[1] = 0 # Delete item from choice
|
||||
ch[1] = nil # Delete item from choice
|
||||
return
|
||||
end
|
||||
pbDisplay(_INTL("But it had no effect!"))
|
||||
|
||||
@@ -62,17 +62,14 @@ class PokeBattle_Battle
|
||||
#=============================================================================
|
||||
def pbHasMegaRing?(idxBattler)
|
||||
return true if !pbOwnedByPlayer?(idxBattler) # Assume AI trainer have a ring
|
||||
MEGA_RINGS.each do |item|
|
||||
return true if hasConst?(PBItems,item) && $PokemonBag.pbHasItem?(item)
|
||||
end
|
||||
MEGA_RINGS.each { |item| return true if $PokemonBag.pbHasItem?(item) }
|
||||
return false
|
||||
end
|
||||
|
||||
def pbGetMegaRingName(idxBattler)
|
||||
if pbOwnedByPlayer?(idxBattler)
|
||||
MEGA_RINGS.each do |i|
|
||||
next if !hasConst?(PBItems,i)
|
||||
return PBItems.getName(getConst(PBItems,i)) if $PokemonBag.pbHasItem?(i)
|
||||
MEGA_RINGS.each do |item|
|
||||
return GameData::Item.get(item).name if $PokemonBag.pbHasItem?(item)
|
||||
end
|
||||
end
|
||||
# NOTE: Add your own Mega objects for particular NPC trainers here.
|
||||
|
||||
@@ -12,9 +12,9 @@ class PokeBattle_Battle
|
||||
|
||||
def pbCancelChoice(idxBattler)
|
||||
# If idxBattler's choice was to use an item, return that item to the Bag
|
||||
if @choices[idxBattler][0]==:UseItem
|
||||
if @choices[idxBattler][0] == :UseItem
|
||||
item = @choices[idxBattler][1]
|
||||
pbReturnUnusedItemToBag(item,idxBattler) if item && item>0
|
||||
pbReturnUnusedItemToBag(item, idxBattler) if item
|
||||
end
|
||||
# If idxBattler chose to Mega Evolve, cancel it
|
||||
pbUnregisterMegaEvolution(idxBattler)
|
||||
@@ -104,7 +104,7 @@ class PokeBattle_Battle
|
||||
end
|
||||
ret = false
|
||||
@scene.pbItemMenu(idxBattler,firstAction) { |item,useType,idxPkmn,idxMove,itemScene|
|
||||
next false if item<0
|
||||
next false if !item
|
||||
battler = pkmn = nil
|
||||
case useType
|
||||
when 1, 2, 6, 7 # Use on Pokémon/Pokémon's move
|
||||
|
||||
@@ -66,23 +66,23 @@ class PokeBattle_Battle
|
||||
|
||||
def pbAttackPhaseItems
|
||||
pbPriority.each do |b|
|
||||
next unless @choices[b.index][0]==:UseItem && !b.fainted?
|
||||
next unless @choices[b.index][0] == :UseItem && !b.fainted?
|
||||
b.lastMoveFailed = false # Counts as a successful move for Stomping Tantrum
|
||||
item = @choices[b.index][1]
|
||||
next if !item || item<=0
|
||||
useType = pbGetItemData(item,ItemData::BATTLE_USE)
|
||||
next if !useType
|
||||
case useType
|
||||
next if !item
|
||||
case GameData::Item.get(item).battle_use
|
||||
when 1, 2, 6, 7 # Use on Pokémon/Pokémon's move
|
||||
pbUseItemOnPokemon(item,@choices[b.index][2],b) if @choices[b.index][2]>=0
|
||||
pbUseItemOnPokemon(item, @choices[b.index][2], b) if @choices[b.index][2] >= 0
|
||||
when 3, 8 # Use on battler
|
||||
pbUseItemOnBattler(item,@choices[b.index][2],b)
|
||||
pbUseItemOnBattler(item, @choices[b.index][2], b)
|
||||
when 4, 9 # Use Poké Ball
|
||||
pbUsePokeBallInBattle(item,@choices[b.index][2],b)
|
||||
pbUsePokeBallInBattle(item, @choices[b.index][2], b)
|
||||
when 5, 10 # Use directly
|
||||
pbUseItemInBattle(item,@choices[b.index][2],b)
|
||||
pbUseItemInBattle(item, @choices[b.index][2], b)
|
||||
else
|
||||
next
|
||||
end
|
||||
return if @decision>0
|
||||
return if @decision > 0
|
||||
end
|
||||
# pbCalculatePriority if NEWEST_BATTLE_MECHANICS
|
||||
end
|
||||
|
||||
@@ -5,24 +5,24 @@ class PokeBattle_AI
|
||||
def pbEnemyShouldUseItem?(idxBattler)
|
||||
user = @battle.battlers[idxBattler]
|
||||
item, idxTarget = pbEnemyItemToUse(idxBattler)
|
||||
return false if item==0
|
||||
return false if !item
|
||||
# Determine target of item (always the Pokémon choosing the action)
|
||||
useType = pbGetItemData(item,ItemData::BATTLE_USE)
|
||||
if useType && (useType==1 || useType==6) # Use on Pokémon
|
||||
useType = GameData::Item.get(item).battle_use
|
||||
if useType==1 || useType==6 # Use on Pokémon
|
||||
idxTarget = @battle.battlers[idxTarget].pokemonIndex # Party Pokémon
|
||||
end
|
||||
# Register use of item
|
||||
@battle.pbRegisterItem(idxBattler,item,idxTarget)
|
||||
PBDebug.log("[AI] #{user.pbThis} (#{user.index}) will use item #{PBItems.getName(item)}")
|
||||
PBDebug.log("[AI] #{user.pbThis} (#{user.index}) will use item #{GameData::Item.get(item).name}")
|
||||
return true
|
||||
end
|
||||
|
||||
# NOTE: The AI will only consider using an item on the Pokémon it's currently
|
||||
# choosing an action for.
|
||||
def pbEnemyItemToUse(idxBattler)
|
||||
return 0 if !@battle.internalBattle
|
||||
return nil if !@battle.internalBattle
|
||||
items = @battle.pbGetOwnerItems(idxBattler)
|
||||
return 0 if !items || items.length==0
|
||||
return nil if !items || items.length==0
|
||||
# Determine target of item (always the Pokémon choosing the action)
|
||||
idxTarget = idxBattler # Battler using the item
|
||||
battler = @battle.battlers[idxTarget]
|
||||
@@ -49,106 +49,95 @@ class PokeBattle_AI
|
||||
:FULLRESTORE
|
||||
]
|
||||
oneStatusItems = [ # Preferred over items that heal all status problems
|
||||
:AWAKENING,:CHESTOBERRY,:BLUEFLUTE,
|
||||
:ANTIDOTE,:PECHABERRY,
|
||||
:BURNHEAL,:RAWSTBERRY,
|
||||
:PARALYZEHEAL,:PARLYZHEAL,:CHERIBERRY,
|
||||
:ICEHEAL,:ASPEARBERRY
|
||||
:AWAKENING, :CHESTOBERRY, :BLUEFLUTE,
|
||||
:ANTIDOTE, :PECHABERRY,
|
||||
:BURNHEAL, :RAWSTBERRY,
|
||||
:PARALYZEHEAL, :PARLYZHEAL, :CHERIBERRY,
|
||||
:ICEHEAL, :ASPEARBERRY
|
||||
]
|
||||
allStatusItems = [
|
||||
:FULLHEAL,:LAVACOOKIE,:OLDGATEAU,:CASTELIACONE,:LUMIOSEGALETTE,
|
||||
:SHALOURSABLE,:BIGMALASADA,:LUMBERRY,:HEALPOWDER
|
||||
:FULLHEAL, :LAVACOOKIE, :OLDGATEAU, :CASTELIACONE, :LUMIOSEGALETTE,
|
||||
:SHALOURSABLE, :BIGMALASADA, :LUMBERRY, :HEALPOWDER
|
||||
]
|
||||
allStatusItems.push(:RAGECANDYBAR) if NEWEST_BATTLE_MECHANICS
|
||||
xItems = {
|
||||
:XATTACK => [PBStats::ATTACK,(NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XATTACK2 => [PBStats::ATTACK,2],
|
||||
:XATTACK3 => [PBStats::ATTACK,3],
|
||||
:XATTACK6 => [PBStats::ATTACK,6],
|
||||
:XDEFENSE => [PBStats::DEFENSE,(NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XDEFENSE2 => [PBStats::DEFENSE,2],
|
||||
:XDEFENSE3 => [PBStats::DEFENSE,3],
|
||||
:XDEFENSE6 => [PBStats::DEFENSE,6],
|
||||
:XDEFEND => [PBStats::DEFENSE,(NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XDEFEND2 => [PBStats::DEFENSE,2],
|
||||
:XDEFEND3 => [PBStats::DEFENSE,3],
|
||||
:XDEFEND6 => [PBStats::DEFENSE,6],
|
||||
:XSPATK => [PBStats::SPATK,(NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XSPATK2 => [PBStats::SPATK,2],
|
||||
:XSPATK3 => [PBStats::SPATK,3],
|
||||
:XSPATK6 => [PBStats::SPATK,6],
|
||||
:XSPECIAL => [PBStats::SPATK,(NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XSPECIAL2 => [PBStats::SPATK,2],
|
||||
:XSPECIAL3 => [PBStats::SPATK,3],
|
||||
:XSPECIAL6 => [PBStats::SPATK,6],
|
||||
:XSPDEF => [PBStats::SPDEF,(NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XSPDEF2 => [PBStats::SPDEF,2],
|
||||
:XSPDEF3 => [PBStats::SPDEF,3],
|
||||
:XSPDEF6 => [PBStats::SPDEF,6],
|
||||
:XSPEED => [PBStats::SPEED,(NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XSPEED2 => [PBStats::SPEED,2],
|
||||
:XSPEED3 => [PBStats::SPEED,3],
|
||||
:XSPEED6 => [PBStats::SPEED,6],
|
||||
:XACCURACY => [PBStats::ACCURACY,(NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XACCURACY2 => [PBStats::ACCURACY,2],
|
||||
:XACCURACY3 => [PBStats::ACCURACY,3],
|
||||
:XACCURACY6 => [PBStats::ACCURACY,6]
|
||||
:XATTACK => [PBStats::ATTACK, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XATTACK2 => [PBStats::ATTACK, 2],
|
||||
:XATTACK3 => [PBStats::ATTACK, 3],
|
||||
:XATTACK6 => [PBStats::ATTACK, 6],
|
||||
:XDEFENSE => [PBStats::DEFENSE, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XDEFENSE2 => [PBStats::DEFENSE, 2],
|
||||
:XDEFENSE3 => [PBStats::DEFENSE, 3],
|
||||
:XDEFENSE6 => [PBStats::DEFENSE, 6],
|
||||
:XDEFEND => [PBStats::DEFENSE, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XDEFEND2 => [PBStats::DEFENSE, 2],
|
||||
:XDEFEND3 => [PBStats::DEFENSE, 3],
|
||||
:XDEFEND6 => [PBStats::DEFENSE, 6],
|
||||
:XSPATK => [PBStats::SPATK, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XSPATK2 => [PBStats::SPATK, 2],
|
||||
:XSPATK3 => [PBStats::SPATK, 3],
|
||||
:XSPATK6 => [PBStats::SPATK, 6],
|
||||
:XSPECIAL => [PBStats::SPATK, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XSPECIAL2 => [PBStats::SPATK, 2],
|
||||
:XSPECIAL3 => [PBStats::SPATK, 3],
|
||||
:XSPECIAL6 => [PBStats::SPATK, 6],
|
||||
:XSPDEF => [PBStats::SPDEF, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XSPDEF2 => [PBStats::SPDEF, 2],
|
||||
:XSPDEF3 => [PBStats::SPDEF, 3],
|
||||
:XSPDEF6 => [PBStats::SPDEF, 6],
|
||||
:XSPEED => [PBStats::SPEED, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XSPEED2 => [PBStats::SPEED, 2],
|
||||
:XSPEED3 => [PBStats::SPEED, 3],
|
||||
:XSPEED6 => [PBStats::SPEED, 6],
|
||||
:XACCURACY => [PBStats::ACCURACY, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XACCURACY2 => [PBStats::ACCURACY, 2],
|
||||
:XACCURACY3 => [PBStats::ACCURACY, 3],
|
||||
:XACCURACY6 => [PBStats::ACCURACY, 6]
|
||||
}
|
||||
losthp = battler.totalhp-battler.hp
|
||||
preferFullRestore = (battler.hp<=battler.totalhp*2/3 &&
|
||||
(battler.status!=PBStatuses::NONE || battler.effects[PBEffects::Confusion]>0))
|
||||
losthp = battler.totalhp - battler.hp
|
||||
preferFullRestore = (battler.hp <= battler.totalhp * 2 / 3 &&
|
||||
(battler.status != PBStatuses::NONE || battler.effects[PBEffects::Confusion] > 0))
|
||||
# Find all usable items
|
||||
usableHPItems = []
|
||||
usableStatusItems = []
|
||||
usableXItems = []
|
||||
items.each do |i|
|
||||
next if !i || i==0
|
||||
next if !i
|
||||
next if !@battle.pbCanUseItemOnPokemon?(i,pkmn,battler,@battle.scene,false)
|
||||
next if !ItemHandlers.triggerCanUseInBattle(i,pkmn,battler,nil,
|
||||
false,self,@battle.scene,false)
|
||||
checkedItem = false
|
||||
# Log HP healing items
|
||||
if losthp>0
|
||||
hpItems.each do |item, power|
|
||||
next if !isConst?(i,PBItems,item)
|
||||
checkedItem = true
|
||||
usableHPItems.push([i,5,power])
|
||||
if losthp > 0
|
||||
power = hpItems[i]
|
||||
if power
|
||||
usableHPItems.push([i, 5, power])
|
||||
next
|
||||
end
|
||||
next if checkedItem
|
||||
end
|
||||
# Log Full Restores (HP healer and status curer)
|
||||
if losthp>0 || battler.status!=PBStatuses::NONE
|
||||
fullRestoreItems.each do |item|
|
||||
next if !isConst?(i,PBItems,item)
|
||||
checkedItem = true
|
||||
usableHPItems.push([i,(preferFullRestore) ? 3 : 7,999])
|
||||
usableStatusItems.push([i,(preferFullRestore) ? 3 : 9])
|
||||
if losthp > 0 || battler.status != PBStatuses::NONE
|
||||
if fullRestoreItems.include?(i)
|
||||
usableHPItems.push([i, (preferFullRestore) ? 3 : 7, 999])
|
||||
usableStatusItems.push([i, (preferFullRestore) ? 3 : 9])
|
||||
next
|
||||
end
|
||||
next if checkedItem
|
||||
end
|
||||
# Log single status-curing items
|
||||
if battler.status!=PBStatuses::NONE
|
||||
oneStatusItems.each do |item|
|
||||
next if !isConst?(i,PBItems,item)
|
||||
checkedItem = true
|
||||
usableStatusItems.push([i,5])
|
||||
end
|
||||
next if checkedItem
|
||||
# Log Full Heal-type items
|
||||
allStatusItems.each do |item|
|
||||
next if !isConst?(i,PBItems,item)
|
||||
checkedItem = true
|
||||
usableStatusItems.push([i,7])
|
||||
end
|
||||
next if checkedItem
|
||||
if oneStatusItems.include?(i)
|
||||
usableStatusItems.push([i, 5])
|
||||
next
|
||||
end
|
||||
# Log Full Heal-type items
|
||||
if allStatusItems.include?(i)
|
||||
usableStatusItems.push([i, 7])
|
||||
next
|
||||
end
|
||||
# Log stat-raising items
|
||||
xItems.each do |item, data|
|
||||
next if !isConst?(i,PBItems,item)
|
||||
checkedItem = true
|
||||
usableXItems.push([i,battler.stages[data[0]],data[1]])
|
||||
if xItems[i]
|
||||
data = xItems[i]
|
||||
usableXItems.push([i, battler.stages[data[0]], data[1]])
|
||||
next
|
||||
end
|
||||
next if checkedItem
|
||||
end
|
||||
# Prioritise using a HP restoration item
|
||||
if usableHPItems.length>0 && (battler.hp<=battler.totalhp/4 ||
|
||||
@@ -156,15 +145,15 @@ class PokeBattle_AI
|
||||
usableHPItems.sort! { |a,b| (a[1]==b[1]) ? a[2]<=>b[2] : a[1]<=>b[1] }
|
||||
prevItem = nil
|
||||
usableHPItems.each do |i|
|
||||
return i[0],idxTarget if i[2]>=losthp
|
||||
return i[0], idxTarget if i[2]>=losthp
|
||||
prevItem = i
|
||||
end
|
||||
return prevItem[0],idxTarget
|
||||
return prevItem[0], idxTarget
|
||||
end
|
||||
# Next prioritise using a status-curing item
|
||||
if usableStatusItems.length>0 && pbAIRandom(100)<40
|
||||
usableStatusItems.sort! { |a,b| a[1]<=>b[1] }
|
||||
return usableStatusItems[0][0],idxTarget
|
||||
return usableStatusItems[0][0], idxTarget
|
||||
end
|
||||
# Next try using an X item
|
||||
if usableXItems.length>0 && pbAIRandom(100)<30
|
||||
@@ -172,11 +161,11 @@ class PokeBattle_AI
|
||||
prevItem = nil
|
||||
usableXItems.each do |i|
|
||||
break if prevItem && i[1]>prevItem[1]
|
||||
return i[0],idxTarget if i[1]+i[2]>=6
|
||||
return i[0], idxTarget if i[1]+i[2]>=6
|
||||
prevItem = i
|
||||
end
|
||||
return prevItem[0],idxTarget
|
||||
return prevItem[0], idxTarget
|
||||
end
|
||||
return 0
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1632,7 +1632,7 @@ class PokeBattle_AI
|
||||
when "095"
|
||||
#---------------------------------------------------------------------------
|
||||
when "096"
|
||||
score -= 90 if !pbIsBerry?(user.item) || !user.itemActive?
|
||||
score -= 90 if !user.item || !user.item.is_berry? || !user.itemActive?
|
||||
#---------------------------------------------------------------------------
|
||||
when "097"
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -2031,12 +2031,12 @@ class PokeBattle_AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "0F0"
|
||||
if skill>=PBTrainerAI.highSkill
|
||||
score += 20 if target.item!=0
|
||||
score += 20 if target.item
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "0F1"
|
||||
if skill>=PBTrainerAI.highSkill
|
||||
if user.item==0 && target.item!=0
|
||||
if !user.item && target.item
|
||||
score += 40
|
||||
else
|
||||
score -= 90
|
||||
@@ -2046,19 +2046,19 @@ class PokeBattle_AI
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "0F2"
|
||||
if user.item==0 && target.item==0
|
||||
if !user.item && !target.item
|
||||
score -= 90
|
||||
elsif skill>=PBTrainerAI.highSkill && target.hasActiveAbility?(:STICKYHOLD)
|
||||
score -= 90
|
||||
elsif user.hasActiveItem?([:FLAMEORB,:TOXICORB,:STICKYBARB,:IRONBALL,
|
||||
:CHOICEBAND,:CHOICESCARF,:CHOICESPECS])
|
||||
score += 50
|
||||
elsif user.item==0 && target.item!=0
|
||||
elsif !user.item && target.item
|
||||
score -= 30 if pbGetMoveData(user.lastMoveUsed,MoveData::FUNCTION_CODE)=="0F2" # Trick/Switcheroo
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "0F3"
|
||||
if user.item==0 || target.item!=0
|
||||
if !user.item || target.item
|
||||
score -= 90
|
||||
else
|
||||
if user.hasActiveItem?([:FLAMEORB,:TOXICORB,:STICKYBARB,:IRONBALL,
|
||||
@@ -2071,21 +2071,21 @@ class PokeBattle_AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "0F4", "0F5"
|
||||
if target.effects[PBEffects::Substitute]==0
|
||||
if skill>=PBTrainerAI.highSkill && pbIsBerry?(target.item)
|
||||
if skill>=PBTrainerAI.highSkill && target.item && target.item.is_berry?
|
||||
score += 30
|
||||
end
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "0F6"
|
||||
if user.recycleItem==0 || user.item!=0
|
||||
if !user.recycleItem || user.item
|
||||
score -= 80
|
||||
elsif user.recycleItem!=0
|
||||
elsif user.recycleItem
|
||||
score += 30
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "0F7"
|
||||
if user.item==0 || !user.itemActive? ||
|
||||
user.unlosableItem?(user.item) || pbIsPokeBall?(user.item)
|
||||
if !user.item || !user.itemActive? ||
|
||||
user.unlosableItem?(user.item) || user.item.is_poke_ball?
|
||||
score -= 90
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -2096,7 +2096,7 @@ class PokeBattle_AI
|
||||
if @battle.field.effects[PBEffects::MagicRoom]>0
|
||||
score -= 90
|
||||
else
|
||||
score += 30 if user.item==0 && target.item!=0
|
||||
score += 30 if !user.item && target.item
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "0FA"
|
||||
|
||||
@@ -186,7 +186,7 @@ class PokeBattle_AI
|
||||
"098", "099", "09A", "0F7", "113"
|
||||
baseDmg = move.pbBaseDamage(baseDmg,user,target)
|
||||
when "086" # Acrobatics
|
||||
baseDmg *= 2 if user.item==0 || user.hasActiveItem?(:FLYINGGEM)
|
||||
baseDmg *= 2 if !user.item || user.hasActiveItem?(:FLYINGGEM)
|
||||
when "08D" # Gyro Ball
|
||||
targetSpeed = pbRoughStat(target,PBStats::SPEED,skill)
|
||||
userSpeed = pbRoughStat(user,PBStats::SPEED,skill)
|
||||
@@ -197,7 +197,7 @@ class PokeBattle_AI
|
||||
baseDmg = 71
|
||||
baseDmg *= 2 if target.inTwoTurnAttack?("0CA") # Dig
|
||||
when "096" # Natural Gift
|
||||
baseDmg = move.pbNaturalGiftBaseDamage(user.item)
|
||||
baseDmg = move.pbNaturalGiftBaseDamage(user.item_id)
|
||||
when "09B" # Heavy Slam
|
||||
baseDmg = move.pbBaseDamage(baseDmg,user,target)
|
||||
baseDmg *= 2 if NEWEST_BATTLE_MECHANICS && skill>=PBTrainerAI.mediumSkill &&
|
||||
@@ -332,13 +332,7 @@ class PokeBattle_AI
|
||||
# NOTE: These items aren't suitable for checking at the start of the
|
||||
# round.
|
||||
itemBlacklist = [:EXPERTBELT,:LIFEORB]
|
||||
canCheck = true
|
||||
itemBlacklist.each do |i|
|
||||
next if !isConst?(user.item,PBItems,i)
|
||||
canCheck = false
|
||||
break
|
||||
end
|
||||
if canCheck
|
||||
if !itemBlacklist.include?(user.item_id)
|
||||
BattleHandlers.triggerDamageCalcUserItem(user.item,
|
||||
user,target,move,multipliers,baseDmg,type)
|
||||
end
|
||||
@@ -346,7 +340,7 @@ class PokeBattle_AI
|
||||
if skill>=PBTrainerAI.bestSkill && target.itemActive?
|
||||
# NOTE: Type-weakening berries aren't suitable for checking at the start
|
||||
# of the round.
|
||||
if !pbIsBerry?(target.item)
|
||||
if !target.item.is_berry?
|
||||
BattleHandlers.triggerDamageCalcTargetItem(target.item,
|
||||
user,target,move,multipliers,baseDmg,type)
|
||||
end
|
||||
|
||||
@@ -200,7 +200,7 @@ class PokeBattle_Scene
|
||||
# Start Bag screen
|
||||
itemScene = PokemonBag_Scene.new
|
||||
itemScene.pbStartScene($PokemonBag,true,Proc.new { |item|
|
||||
useType = pbGetItemData(item,ItemData::BATTLE_USE)
|
||||
useType = GameData::Item.get(item).battle_use
|
||||
next useType && useType>0
|
||||
},false)
|
||||
# Loop while in Bag screen
|
||||
@@ -208,10 +208,11 @@ class PokeBattle_Scene
|
||||
loop do
|
||||
# Select an item
|
||||
item = itemScene.pbChooseItem
|
||||
break if item==0
|
||||
break if !item
|
||||
# Choose a command for the selected item
|
||||
itemName = PBItems.getName(item)
|
||||
useType = pbGetItemData(item,ItemData::BATTLE_USE)
|
||||
item = GameData::Item.get(item)
|
||||
itemName = item.name
|
||||
useType = item.battle_use
|
||||
cmdUse = -1
|
||||
commands = []
|
||||
commands[cmdUse = commands.length] = _INTL("Use") if useType && useType!=0
|
||||
@@ -237,11 +238,11 @@ class PokeBattle_Scene
|
||||
case useType
|
||||
when 1, 6 # Use on Pokémon
|
||||
if @battle.pbTeamLengthFromBattlerIndex(idxBattler)==1
|
||||
break if yield item, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene
|
||||
break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene
|
||||
end
|
||||
when 3, 8 # Use on battler
|
||||
if @battle.pbPlayerBattlerCount==1
|
||||
break if yield item, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene
|
||||
break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene
|
||||
end
|
||||
end
|
||||
# Fade out and hide Bag screen
|
||||
@@ -276,7 +277,7 @@ class PokeBattle_Scene
|
||||
idxMove = pkmnScreen.pbChooseMove(pkmn,_INTL("Restore which move?"))
|
||||
next if idxMove<0
|
||||
end
|
||||
break if yield item, useType, idxPartyRet, idxMove, pkmnScene
|
||||
break if yield item.id, useType, idxPartyRet, idxMove, pkmnScene
|
||||
end
|
||||
pkmnScene.pbEndScene
|
||||
break if idxParty>=0
|
||||
@@ -286,7 +287,7 @@ class PokeBattle_Scene
|
||||
idxTarget = -1
|
||||
if @battle.pbOpposingBattlerCount(idxBattler)==1
|
||||
@battle.eachOtherSideBattler(idxBattler) { |b| idxTarget = b.index }
|
||||
break if yield item, useType, idxTarget, -1, itemScene
|
||||
break if yield item.id, useType, idxTarget, -1, itemScene
|
||||
else
|
||||
wasTargeting = true
|
||||
# Fade out and hide Bag screen
|
||||
@@ -297,7 +298,7 @@ class PokeBattle_Scene
|
||||
tempVisibleSprites["targetWindow"] = true
|
||||
idxTarget = pbChooseTarget(idxBattler,PBTargets::Foe,tempVisibleSprites)
|
||||
if idxTarget>=0
|
||||
break if yield item, useType, idxTarget, -1, self
|
||||
break if yield item.id, useType, idxTarget, -1, self
|
||||
end
|
||||
# Target invalid/cancelled choosing a target; show the Bag screen again
|
||||
wasTargeting = false
|
||||
@@ -305,7 +306,7 @@ class PokeBattle_Scene
|
||||
itemScene.pbFadeInScene
|
||||
end
|
||||
when 5, 10 # Use with no target
|
||||
break if yield item, useType, idxBattler, -1, itemScene
|
||||
break if yield item.id, useType, idxBattler, -1, itemScene
|
||||
end
|
||||
end
|
||||
@bagLastPocket = $PokemonBag.lastpocket
|
||||
|
||||
@@ -492,7 +492,7 @@ FINAL_DMG_MULT = 3
|
||||
def pbBattleConfusionBerry(battler,battle,item,forced,flavor,confuseMsg)
|
||||
return false if !forced && !battler.canHeal?
|
||||
return false if !forced && !battler.pbCanConsumeBerry?(item,false)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
amt = (NEWEST_BATTLE_MECHANICS) ? battler.pbRecoverHP(battler.totalhp/2) : battler.pbRecoverHP(battler.totalhp/8)
|
||||
if amt>0
|
||||
@@ -515,7 +515,7 @@ end
|
||||
def pbBattleStatIncreasingBerry(battler,battle,item,forced,stat,increment=1)
|
||||
return false if !forced && !battler.pbCanConsumeBerry?(item)
|
||||
return false if !battler.pbCanRaiseStatStage?(stat,battler)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if forced
|
||||
PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
|
||||
return battler.pbRaiseStatStage(stat,increment,battler)
|
||||
@@ -576,7 +576,7 @@ def pbBattleGem(user,type,move,mults,moveType)
|
||||
# Pledge moves never consume Gems
|
||||
return if move.is_a?(PokeBattle_PledgeMove)
|
||||
return if !isConst?(moveType,PBTypes,type)
|
||||
user.effects[PBEffects::GemConsumed] = user.item
|
||||
user.effects[PBEffects::GemConsumed] = user.item_id
|
||||
if NEWEST_BATTLE_MECHANICS
|
||||
mults[BASE_DMG_MULT] *= 1.3
|
||||
else
|
||||
|
||||
@@ -427,7 +427,7 @@ class PokeBattle_SafariZone
|
||||
pbDisplayPaused(_INTL("Wild {1} appeared!",wildpoke.name))
|
||||
@scene.pbSafariStart
|
||||
@scene.pbCommonAnimation(PBWeather.animationName(@weather))
|
||||
safariBall = getConst(PBItems,:SAFARIBALL)
|
||||
safariBall = GameData::Item.get(:SAFARIBALL).id
|
||||
rareness = pbGetSpeciesData(wildpoke.species,wildpoke.form,SpeciesData::RARENESS)
|
||||
catchFactor = (rareness*100)/1275
|
||||
catchFactor = [[catchFactor,3].max,20].min
|
||||
|
||||
@@ -36,7 +36,7 @@ class PokeBattle_BugContestBattle < PokeBattle_Battle
|
||||
|
||||
def initialize(*arg)
|
||||
@ballCount = 0
|
||||
@ballConst = getConst(PBItems,:SPORTBALL) || -1
|
||||
@ballConst = GameData::Item.get(:SPORTBALL).id
|
||||
super(*arg)
|
||||
end
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ BattleHandlers::SpeedCalcAbility.add(:SWIFTSWIM,
|
||||
|
||||
BattleHandlers::SpeedCalcAbility.add(:UNBURDEN,
|
||||
proc { |ability,battler,mult|
|
||||
next mult*2 if battler.effects[PBEffects::Unburden] && battler.item==0
|
||||
next mult*2 if battler.effects[PBEffects::Unburden] && !battler.item
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1673,11 +1673,11 @@ BattleHandlers::UserAbilityEndOfMove.add(:MAGICIAN,
|
||||
proc { |ability,user,targets,move,battle|
|
||||
next if !battle.futureSight
|
||||
next if !move.pbDamagingMove?
|
||||
next if user.item>0
|
||||
next if user.item
|
||||
next if battle.wildBattle? && user.opposes?
|
||||
targets.each do |b|
|
||||
next if b.damageState.unaffected || b.damageState.substitute
|
||||
next if b.item==0
|
||||
next if !b.item
|
||||
next if b.unlosableItem?(b.item) || user.unlosableItem?(b.item)
|
||||
battle.pbShowAbilitySplash(user)
|
||||
if b.hasActiveAbility?(:STICKYHOLD)
|
||||
@@ -1689,11 +1689,11 @@ BattleHandlers::UserAbilityEndOfMove.add(:MAGICIAN,
|
||||
next
|
||||
end
|
||||
user.item = b.item
|
||||
b.item = 0
|
||||
b.item = nil
|
||||
b.effects[PBEffects::Unburden] = true
|
||||
if battle.wildBattle? && user.initialItem==0 && b.initialItem==user.item
|
||||
if battle.wildBattle? && !user.initialItem && b.initialItem==user.item
|
||||
user.setInitialItem(user.item)
|
||||
b.setInitialItem(0)
|
||||
b.setInitialItem(nil)
|
||||
end
|
||||
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
|
||||
battle.pbDisplay(_INTL("{1} stole {2}'s {3}!",user.pbThis,
|
||||
@@ -1755,7 +1755,7 @@ BattleHandlers::TargetAbilityAfterMoveUse.add(:PICKPOCKET,
|
||||
next if !move.contactMove?
|
||||
next if switched.include?(user.index)
|
||||
next if user.effects[PBEffects::Substitute]>0 || target.damageState.substitute
|
||||
next if target.item>0 || user.item==0
|
||||
next if target.item || !user.item
|
||||
next if user.unlosableItem?(user.item) || target.unlosableItem?(user.item)
|
||||
battle.pbShowAbilitySplash(target)
|
||||
if user.hasActiveAbility?(:STICKYHOLD)
|
||||
@@ -1768,11 +1768,11 @@ BattleHandlers::TargetAbilityAfterMoveUse.add(:PICKPOCKET,
|
||||
next
|
||||
end
|
||||
target.item = user.item
|
||||
user.item = 0
|
||||
user.item = nil
|
||||
user.effects[PBEffects::Unburden] = true
|
||||
if battle.wildBattle? && target.initialItem==0 && user.initialItem==target.item
|
||||
if battle.wildBattle? && !target.initialItem && user.initialItem==target.item
|
||||
target.setInitialItem(target.item)
|
||||
user.setInitialItem(0)
|
||||
user.setInitialItem(nil)
|
||||
end
|
||||
battle.pbDisplay(_INTL("{1} pickpocketed {2}'s {3}!",target.pbThis,
|
||||
user.pbThis(true),target.itemName))
|
||||
@@ -1998,16 +1998,16 @@ BattleHandlers::EOREffectAbility.add(:SPEEDBOOST,
|
||||
|
||||
BattleHandlers::EORGainItemAbility.add(:HARVEST,
|
||||
proc { |ability,battler,battle|
|
||||
next if battler.item>0
|
||||
next if battler.recycleItem<=0 || !pbIsBerry?(battler.recycleItem)
|
||||
next if battler.item
|
||||
next if !battler.recycleItem || !GameData::Item.get(battler.recycleItem).is_berry?
|
||||
curWeather = battle.pbWeather
|
||||
if curWeather!=PBWeather::Sun && curWeather!=PBWeather::HarshSun
|
||||
next unless battle.pbRandom(100)<50
|
||||
end
|
||||
battle.pbShowAbilitySplash(battler)
|
||||
battler.item = battler.recycleItem
|
||||
battler.setRecycleItem(0)
|
||||
battler.setInitialItem(battler.item) if battler.initialItem==0
|
||||
battler.setRecycleItem(nil)
|
||||
battler.setInitialItem(battler.item) if !battler.initialItem
|
||||
battle.pbDisplay(_INTL("{1} harvested one {2}!",battler.pbThis,battler.itemName))
|
||||
battle.pbHideAbilitySplash(battler)
|
||||
battler.pbHeldItemTriggerCheck
|
||||
@@ -2016,8 +2016,8 @@ BattleHandlers::EORGainItemAbility.add(:HARVEST,
|
||||
|
||||
BattleHandlers::EORGainItemAbility.add(:PICKUP,
|
||||
proc { |ability,battler,battle|
|
||||
next if battler.item>0
|
||||
foundItem = 0; fromBattler = nil; use = 0
|
||||
next if battler.item
|
||||
foundItem = nil; fromBattler = nil; use = 0
|
||||
battle.eachBattler do |b|
|
||||
next if b.index==battler.index
|
||||
next if b.effects[PBEffects::PickupUse]<=use
|
||||
@@ -2025,15 +2025,15 @@ BattleHandlers::EORGainItemAbility.add(:PICKUP,
|
||||
fromBattler = b
|
||||
use = b.effects[PBEffects::PickupUse]
|
||||
end
|
||||
next if foundItem<=0
|
||||
next if !foundItem
|
||||
battle.pbShowAbilitySplash(battler)
|
||||
battler.item = foundItem
|
||||
fromBattler.effects[PBEffects::PickupItem] = 0
|
||||
fromBattler.effects[PBEffects::PickupItem] = nil
|
||||
fromBattler.effects[PBEffects::PickupUse] = 0
|
||||
fromBattler.setRecycleItem(0) if fromBattler.recycleItem==foundItem
|
||||
if battle.wildBattle? && battler.initialItem==0 && fromBattler.initialItem==foundItem
|
||||
fromBattler.setRecycleItem(nil) if fromBattler.recycleItem==foundItem
|
||||
if battle.wildBattle? && !battler.initialItem && fromBattler.initialItem==foundItem
|
||||
battler.setInitialItem(foundItem)
|
||||
fromBattler.setInitialItem(0)
|
||||
fromBattler.setInitialItem(nil)
|
||||
end
|
||||
battle.pbDisplay(_INTL("{1} found one {2}!",battler.pbThis,battler.itemName))
|
||||
battle.pbHideAbilitySplash(battler)
|
||||
@@ -2244,19 +2244,19 @@ BattleHandlers::AbilityOnSwitchIn.add(:FRISK,
|
||||
next if !battler.pbOwnedByPlayer?
|
||||
foes = []
|
||||
battle.eachOtherSideBattler(battler.index) do |b|
|
||||
foes.push(b) if b.item>0
|
||||
foes.push(b) if b.item
|
||||
end
|
||||
if foes.length>0
|
||||
battle.pbShowAbilitySplash(battler)
|
||||
if NEWEST_BATTLE_MECHANICS
|
||||
foes.each do |b|
|
||||
battle.pbDisplay(_INTL("{1} frisked {2} and found its {3}!",
|
||||
battler.pbThis,b.pbThis(true),PBItems.getName(b.item)))
|
||||
battler.pbThis,b.pbThis(true),b.itemName))
|
||||
end
|
||||
else
|
||||
foe = foes[battle.pbRandom(foes.length)]
|
||||
battle.pbDisplay(_INTL("{1} frisked the foe and found one {2}!",
|
||||
battler.pbThis,PBItems.getName(foe.item)))
|
||||
battler.pbThis,foe.itemName))
|
||||
end
|
||||
battle.pbHideAbilitySplash(battler)
|
||||
end
|
||||
|
||||
@@ -48,7 +48,7 @@ BattleHandlers::WeightCalcItem.add(:FLOATSTONE,
|
||||
BattleHandlers::HPHealItem.add(:AGUAVBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next pbBattleConfusionBerry(battler,battle,item,forced,4,
|
||||
_INTL("For {1}, the {2} was too bitter!",battler.pbThis(true),PBItems.getName(item)))
|
||||
_INTL("For {1}, the {2} was too bitter!",battler.pbThis(true),GameData::Item.get(item).name))
|
||||
}
|
||||
)
|
||||
|
||||
@@ -62,7 +62,7 @@ BattleHandlers::HPHealItem.add(:BERRYJUICE,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !battler.canHeal?
|
||||
next false if !forced && battler.hp>battler.totalhp/2
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] Forced consuming of #{itemName}") if forced
|
||||
battle.pbCommonAnimation("UseItem",battler) if !forced
|
||||
battler.pbRecoverHP(20)
|
||||
@@ -78,7 +78,7 @@ BattleHandlers::HPHealItem.add(:BERRYJUICE,
|
||||
BattleHandlers::HPHealItem.add(:FIGYBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next pbBattleConfusionBerry(battler,battle,item,forced,0,
|
||||
_INTL("For {1}, the {2} was too spicy!",battler.pbThis(true),PBItems.getName(item)))
|
||||
_INTL("For {1}, the {2} was too spicy!",battler.pbThis(true),GameData::Item.get(item).name))
|
||||
}
|
||||
)
|
||||
|
||||
@@ -91,7 +91,7 @@ BattleHandlers::HPHealItem.add(:GANLONBERRY,
|
||||
BattleHandlers::HPHealItem.add(:IAPAPABERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next pbBattleConfusionBerry(battler,battle,item,forced,1,
|
||||
_INTL("For {1}, the {2} was too sour!",battler.pbThis(true),PBItems.getName(item)))
|
||||
_INTL("For {1}, the {2} was too sour!",battler.pbThis(true),GameData::Item.get(item).name))
|
||||
}
|
||||
)
|
||||
|
||||
@@ -101,7 +101,7 @@ BattleHandlers::HPHealItem.add(:LANSATBERRY,
|
||||
next false if battler.effects[PBEffects::FocusEnergy]>=2
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.effects[PBEffects::FocusEnergy] = 2
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if forced
|
||||
battle.pbDisplay(_INTL("{1} got pumped from the {2}!",battler.pbThis,itemName))
|
||||
else
|
||||
@@ -120,7 +120,7 @@ BattleHandlers::HPHealItem.add(:LIECHIBERRY,
|
||||
BattleHandlers::HPHealItem.add(:MAGOBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next pbBattleConfusionBerry(battler,battle,item,forced,2,
|
||||
_INTL("For {1}, the {2} was too sweet!",battler.pbThis(true),PBItems.getName(item)))
|
||||
_INTL("For {1}, the {2} was too sweet!",battler.pbThis(true),GameData::Item.get(item).name))
|
||||
}
|
||||
)
|
||||
|
||||
@@ -130,7 +130,7 @@ BattleHandlers::HPHealItem.add(:MICLEBERRY,
|
||||
next false if !battler.effects[PBEffects::MicleBerry]
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.effects[PBEffects::MicleBerry] = true
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if forced
|
||||
PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
|
||||
battle.pbDisplay(_INTL("{1} boosted the accuracy of its next move!",battler.pbThis))
|
||||
@@ -149,7 +149,7 @@ BattleHandlers::HPHealItem.add(:ORANBERRY,
|
||||
next false if !forced && battler.hp>battler.totalhp/2
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbRecoverHP(10)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if forced
|
||||
PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
|
||||
battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
|
||||
@@ -179,7 +179,7 @@ BattleHandlers::HPHealItem.add(:SITRUSBERRY,
|
||||
next false if !forced && battler.hp>battler.totalhp/2
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbRecoverHP(battler.totalhp/4)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if forced
|
||||
PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
|
||||
battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
|
||||
@@ -203,7 +203,7 @@ BattleHandlers::HPHealItem.add(:STARFBERRY,
|
||||
BattleHandlers::HPHealItem.add(:WIKIBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next pbBattleConfusionBerry(battler,battle,item,forced,3,
|
||||
_INTL("For {1}, the {2} was too dry!",battler.pbThis(true),PBItems.getName(item)))
|
||||
_INTL("For {1}, the {2} was too dry!",battler.pbThis(true),GameData::Item.get(item).name))
|
||||
}
|
||||
)
|
||||
|
||||
@@ -215,7 +215,7 @@ BattleHandlers::StatusCureItem.add(:ASPEARBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if battler.status!=PBStatuses::FROZEN
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbCureStatus(forced)
|
||||
@@ -228,7 +228,7 @@ BattleHandlers::StatusCureItem.add(:CHERIBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if battler.status!=PBStatuses::PARALYSIS
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbCureStatus(forced)
|
||||
@@ -241,7 +241,7 @@ BattleHandlers::StatusCureItem.add(:CHESTOBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if battler.status!=PBStatuses::SLEEP
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbCureStatus(forced)
|
||||
@@ -255,7 +255,7 @@ BattleHandlers::StatusCureItem.add(:LUMBERRY,
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if battler.status==PBStatuses::NONE &&
|
||||
battler.effects[PBEffects::Confusion]==0
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
oldStatus = battler.status
|
||||
@@ -293,7 +293,7 @@ BattleHandlers::StatusCureItem.add(:MENTALHERB,
|
||||
!battler.effects[PBEffects::Torment] &&
|
||||
battler.effects[PBEffects::Disable]==0 &&
|
||||
battler.effects[PBEffects::HealBlock]==0
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}")
|
||||
battle.pbCommonAnimation("UseItem",battler) if !forced
|
||||
if battler.effects[PBEffects::Attract]>=0
|
||||
@@ -324,7 +324,7 @@ BattleHandlers::StatusCureItem.add(:PECHABERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if battler.status!=PBStatuses::POISON
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbCureStatus(forced)
|
||||
@@ -337,7 +337,7 @@ BattleHandlers::StatusCureItem.add(:PERSIMBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if battler.effects[PBEffects::Confusion]==0
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbCureConfusion
|
||||
@@ -355,7 +355,7 @@ BattleHandlers::StatusCureItem.add(:RAWSTBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if battler.status!=PBStatuses::BURN
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbCureStatus(forced)
|
||||
@@ -1124,14 +1124,14 @@ BattleHandlers::TargetItemOnHit.add(:SNOWBALL,
|
||||
BattleHandlers::TargetItemOnHit.add(:STICKYBARB,
|
||||
proc { |item,user,target,move,battle|
|
||||
next if !move.pbContactMove?(user) || !user.affectedByContactEffect?
|
||||
next if user.fainted? || user.item>0
|
||||
next if user.fainted? || user.item
|
||||
user.item = target.item
|
||||
target.item = 0
|
||||
target.item = nil
|
||||
target.effects[PBEffects::Unburden] = true
|
||||
if battle.wildBattle? && !user.opposes?
|
||||
if user.initialItem==0 && target.initialItem==user.item
|
||||
if !user.initialItem && target.initialItem==user.item
|
||||
user.setInitialItem(user.item)
|
||||
target.setInitialItem(0)
|
||||
target.setInitialItem(nil)
|
||||
end
|
||||
end
|
||||
battle.pbDisplay(_INTL("{1}'s {2} was transferred to {3}!",
|
||||
@@ -1168,7 +1168,7 @@ BattleHandlers::TargetItemOnHitPositiveBerry.add(:ENIGMABERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !battler.canHeal?
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbRecoverHP(battler.totalhp/4)
|
||||
@@ -1186,7 +1186,7 @@ BattleHandlers::TargetItemOnHitPositiveBerry.add(:KEEBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if !battler.pbCanRaiseStatStage?(PBStats::DEFENSE,battler)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if !forced
|
||||
battle.pbCommonAnimation("EatBerry",battler)
|
||||
next battler.pbRaiseStatStageByCause(PBStats::DEFENSE,1,battler,itemName)
|
||||
@@ -1200,7 +1200,7 @@ BattleHandlers::TargetItemOnHitPositiveBerry.add(:MARANGABERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if !battler.pbCanRaiseStatStage?(PBStats::SPDEF,battler)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if !forced
|
||||
battle.pbCommonAnimation("EatBerry",battler)
|
||||
next battler.pbRaiseStatStageByCause(PBStats::SPDEF,1,battler,itemName)
|
||||
@@ -1294,7 +1294,7 @@ BattleHandlers::EndOfMoveItem.add(:LEPPABERRY,
|
||||
found.push(i)
|
||||
end
|
||||
next false if found.length==0
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
choice = found[battle.pbRandom(found.length)]
|
||||
@@ -1325,7 +1325,7 @@ BattleHandlers::EndOfMoveStatRestoreItem.add(:WHITEHERB,
|
||||
reducedStats = true
|
||||
end
|
||||
next false if !reducedStats
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("UseItem",battler) if !forced
|
||||
if forced
|
||||
@@ -1440,7 +1440,7 @@ BattleHandlers::TerrainStatBoostItem.add(:ELECTRICSEED,
|
||||
proc { |item,battler,battle|
|
||||
next false if battle.field.terrain!=PBBattleTerrains::Electric
|
||||
next false if !battler.pbCanRaiseStatStage?(PBStats::DEFENSE,battler)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
battle.pbCommonAnimation("UseItem",battler)
|
||||
next battler.pbRaiseStatStageByCause(PBStats::DEFENSE,1,battler,itemName)
|
||||
}
|
||||
@@ -1450,7 +1450,7 @@ BattleHandlers::TerrainStatBoostItem.add(:GRASSYSEED,
|
||||
proc { |item,battler,battle|
|
||||
next false if battle.field.terrain!=PBBattleTerrains::Grassy
|
||||
next false if !battler.pbCanRaiseStatStage?(PBStats::DEFENSE,battler)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
battle.pbCommonAnimation("UseItem",battler)
|
||||
next battler.pbRaiseStatStageByCause(PBStats::DEFENSE,1,battler,itemName)
|
||||
}
|
||||
@@ -1460,7 +1460,7 @@ BattleHandlers::TerrainStatBoostItem.add(:MISTYSEED,
|
||||
proc { |item,battler,battle|
|
||||
next false if battle.field.terrain!=PBBattleTerrains::Misty
|
||||
next false if !battler.pbCanRaiseStatStage?(PBStats::SPDEF,battler)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
battle.pbCommonAnimation("UseItem",battler)
|
||||
next battler.pbRaiseStatStageByCause(PBStats::SPDEF,1,battler,itemName)
|
||||
}
|
||||
@@ -1470,7 +1470,7 @@ BattleHandlers::TerrainStatBoostItem.add(:PSYCHICSEED,
|
||||
proc { |item,battler,battle|
|
||||
next false if battle.field.terrain!=PBBattleTerrains::Psychic
|
||||
next false if !battler.pbCanRaiseStatStage?(PBStats::SPDEF,battler)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
battle.pbCommonAnimation("UseItem",battler)
|
||||
next battler.pbRaiseStatStageByCause(PBStats::SPDEF,1,battler,itemName)
|
||||
}
|
||||
@@ -1577,7 +1577,7 @@ BattleHandlers::ItemOnSwitchIn.add(:AIRBALLOON,
|
||||
BattleHandlers::ItemOnIntimidated.add(:ADRENALINEORB,
|
||||
proc { |item,battler,battle|
|
||||
next false if !battler.pbCanRaiseStatStage?(PBStats::SPEED,battler)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
battle.pbCommonAnimation("UseItem",battler)
|
||||
next battler.pbRaiseStatStageByCause(PBStats::SPEED,1,battler,itemName)
|
||||
}
|
||||
|
||||
@@ -27,22 +27,18 @@ $BallTypes = {
|
||||
25 => :BEASTBALL
|
||||
}
|
||||
|
||||
def pbBallTypeToItem(balltype)
|
||||
if $BallTypes[balltype]
|
||||
ret = getID(PBItems,$BallTypes[balltype])
|
||||
return ret if ret!=0
|
||||
end
|
||||
if $BallTypes[0]
|
||||
ret = getID(PBItems,$BallTypes[0])
|
||||
return ret if ret!=0
|
||||
end
|
||||
return getID(PBItems,:POKEBALL)
|
||||
def pbBallTypeToItem(ball_type)
|
||||
ret = GameData::Item.try_get($BallTypes[ball_type])
|
||||
return ret if ret
|
||||
ret = GameData::Item.try_get($BallTypes[0])
|
||||
return ret if ret
|
||||
return GameData::Item.get(:POKEBALL)
|
||||
end
|
||||
|
||||
def pbGetBallType(ball)
|
||||
ball = getID(PBItems,ball)
|
||||
ball = GameData::Item.try_get(ball)
|
||||
$BallTypes.keys.each do |key|
|
||||
return key if isConst?(ball,PBItems,$BallTypes[key])
|
||||
return key if ball == $BallTypes[key]
|
||||
end
|
||||
return 0
|
||||
end
|
||||
@@ -206,8 +202,8 @@ BallHandlers::ModifyCatchRate.add(:MOONBALL,proc { |ball,catchRate,battle,battle
|
||||
# NOTE: Moon Ball cares about whether any species in the target's evolutionary
|
||||
# family can evolve with the Moon Stone, not whether the target itself
|
||||
# can immediately evolve with the Moon Stone.
|
||||
if hasConst?(PBItems,:MOONSTONE) &&
|
||||
pbCheckEvolutionFamilyForItemMethodItem(battler.species,getConst(PBItems,:MOONSTONE))
|
||||
moon_stone = GameData::Item.try_get(:MOONSTONE)
|
||||
if moon_stone && pbCheckEvolutionFamilyForItemMethodItem(battler.species, moon_stone.id)
|
||||
catchRate *= 4
|
||||
end
|
||||
next [catchRate,255].min
|
||||
|
||||
Reference in New Issue
Block a user