Renamed variables and methods relating to the Bag, renamed $PokemonBag to $Bag, $bag.has? can now check for a minimum quantity

This commit is contained in:
Maruno17
2021-10-17 23:02:58 +01:00
parent 72c50db6c0
commit 36ff7c4ba3
30 changed files with 502 additions and 426 deletions

View File

@@ -207,7 +207,7 @@ module PokeBattle_BattleCommon
elsif numOwned>30
dex_modifier = 1
end
dex_modifier *= 2 if $PokemonBag.pbHasItem?(:CATCHINGCHARM)
dex_modifier *= 2 if $bag.has?(:CATCHINGCHARM)
c = x * dex_modifier / 12
# Calculate the number of shakes
if c>0 && pbRandom(256)<c

View File

@@ -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 = (GameData::Item.exists?(:EXPALL) && $PokemonBag.pbHasItem?(:EXPALL))
expAll = $bag.has?(:EXPALL)
p1 = pbParty(0)
@battlers.each do |b|
next unless b && b.opposes? # Can only gain Exp from fainted foes
@@ -145,7 +145,7 @@ class PokeBattle_Battle
end
end
# Exp. Charm increases Exp gained
exp = exp * 3 / 2 if GameData::Item.exists?(:EXPCHARM) && $PokemonBag.pbHasItem?(:EXPCHARM)
exp = exp * 3 / 2 if $bag.has?(:EXPCHARM)
# Modify Exp gain based on pkmn's held item
i = BattleHandlers.triggerExpGainModifierItem(pkmn.item,pkmn,exp)
if i<0

View File

@@ -43,7 +43,7 @@ class PokeBattle_Battle
return if !item
return if !GameData::Item.get(item).consumed_after_use?
if pbOwnedByPlayer?(idxBattler)
if !$PokemonBag.pbDeleteItem(item)
if !$bag.remove(item)
raise _INTL("Tried to consume item that wasn't in the Bag somehow.")
end
else
@@ -56,8 +56,8 @@ class PokeBattle_Battle
return if !item
return if !GameData::Item.get(item).consumed_after_use?
if pbOwnedByPlayer?(idxBattler)
if $PokemonBag && $PokemonBag.pbCanStore?(item)
$PokemonBag.pbStoreItem(item)
if $bag && $bag.can_add?(item)
$bag.add(item)
else
raise _INTL("Couldn't return unused item to Bag somehow.")
end

View File

@@ -63,14 +63,14 @@ class PokeBattle_Battle
#=============================================================================
def pbHasMegaRing?(idxBattler)
return true if !pbOwnedByPlayer?(idxBattler) # Assume AI trainer have a ring
Settings::MEGA_RINGS.each { |item| return true if $PokemonBag.pbHasItem?(item) }
Settings::MEGA_RINGS.each { |item| return true if $bag.has?(item) }
return false
end
def pbGetMegaRingName(idxBattler)
if pbOwnedByPlayer?(idxBattler)
Settings::MEGA_RINGS.each do |item|
return GameData::Item.get(item).name if $PokemonBag.pbHasItem?(item)
return GameData::Item.get(item).name if $bag.has?(item)
end
end
# NOTE: Add your own Mega objects for particular NPC trainers here.

View File

@@ -193,13 +193,13 @@ class PokeBattle_Scene
# Fade out and hide all sprites
visibleSprites = pbFadeOutAndHide(@sprites)
# Set Bag starting positions
oldLastPocket = $PokemonBag.lastpocket
oldChoices = $PokemonBag.getAllChoices
$PokemonBag.lastpocket = @bagLastPocket if @bagLastPocket!=nil
$PokemonBag.setAllChoices(@bagChoices) if @bagChoices!=nil
oldLastPocket = $bag.last_viewed_pocket
oldChoices = $bag.last_pocket_selections.clone
$bag.last_viewed_pocket = @bagLastPocket if @bagLastPocket != nil
$bag.last_pocket_selections = @bagChoices if @bagChoices != nil
# Start Bag screen
itemScene = PokemonBag_Scene.new
itemScene.pbStartScene($PokemonBag,true,Proc.new { |item|
itemScene.pbStartScene($bag, true, Proc.new { |item|
useType = GameData::Item.get(item).battle_use
next useType && useType>0
},false)
@@ -304,10 +304,10 @@ class PokeBattle_Scene
break if yield item.id, useType, idxBattler, -1, itemScene
end
end
@bagLastPocket = $PokemonBag.lastpocket
@bagChoices = $PokemonBag.getAllChoices
$PokemonBag.lastpocket = oldLastPocket
$PokemonBag.setAllChoices(oldChoices)
@bagLastPocket = $bag.last_viewed_pocket
@bagChoices = $bag.last_pocket_selections.clone
$bag.last_viewed_pocket = oldLastPocket
$bag.last_pocket_selections = oldChoices
# Close Bag screen
itemScene.pbEndScene
# Fade back into battle screen (if not already showing it)