mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-12 07:35:00 +00:00
Implemented usage of GameData::Item
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user