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