Minor new additions for v20 (#147)

* Moved TMs/ TRs and HMs into their own handlers
* Improved Plugin Error Message
* Added sound effect when picking berries
* Allow player to always see quantity when buying items
* Trainers now require a Mega Ring item in their items (in trainers.txt) to Mega Evolve
This commit is contained in:
Golisopod-User
2021-12-30 00:06:26 +05:30
committed by GitHub
parent fb29f19a28
commit 13cc9790ce
11 changed files with 81 additions and 46 deletions

View File

@@ -638,23 +638,7 @@ end
def pbUseItem(bag, item, bagscene = nil)
itm = GameData::Item.get(item)
useType = itm.field_use
if itm.is_machine? # TM or TR or HM
if $player.pokemon_count == 0
pbMessage(_INTL("There is no Pokémon."))
return 0
end
machine = itm.move
return 0 if !machine
movename = GameData::Move.get(machine).name
pbMessage(_INTL("\\se[PC access]You booted up {1}.\1", itm.name))
if !pbConfirmMessage(_INTL("Do you want to teach {1} to a Pokémon?", movename))
return 0
elsif pbMoveTutorChoose(machine, nil, true, itm.is_TR?)
bag.remove(item) if itm.consumed_after_use?
return 1
end
return 0
elsif useType == 1 # Item is usable on a Pokémon
if useType == 1 # Item is usable on a Pokémon
if $player.pokemon_count == 0
pbMessage(_INTL("There is no Pokémon."))
return 0
@@ -705,7 +689,7 @@ def pbUseItem(bag, item, bagscene = nil)
bagscene&.pbRefresh
}
return (ret) ? 1 : 0
elsif useType == 2 # Item is usable from Bag
elsif useType == 2 || itm.is_machine? # Item is usable from Bag or teaches a move
intret = ItemHandlers.triggerUseFromBag(item)
if intret >= 0
bag.remove(item) if intret == 1 && itm.consumed_after_use?

View File

@@ -13,7 +13,7 @@ ItemHandlers::UseText.copy(:BICYCLE, :MACHBIKE, :ACROBIKE)
# 1 = used
# 2 = close the Bag to use
# If there is no UseFromBag handler for an item being used from the Bag (not on
# a Pokémon and not a TM/HM), calls the UseInField handler for it instead.
# a Pokémon), calls the UseInField handler for it instead.
#===============================================================================
ItemHandlers::UseFromBag.add(:HONEY, proc { |item|
@@ -64,6 +64,23 @@ ItemHandlers::UseFromBag.add(:TOWNMAP, proc { |item|
next ($game_temp.fly_destination) ? 2 : 0
})
ItemHandlers::UseFromBag.addIf(proc { |item| GameData::Item.get(item).is_machine? },
proc { |item|
if $player.pokemon_count == 0
pbMessage(_INTL("There is no Pokémon."))
next 0
end
item_data = GameData::Item.get(item)
move = item_data.move
next 0 if !move
pbMessage(_INTL("\\se[PC access]You booted up {1}.\1", item_data.name))
next 0 if !pbConfirmMessage(_INTL("Do you want to teach {1} to a Pokémon?",
GameData::Move.get(move).name))
next 1 if pbMoveTutorChoose(move, nil, true, item_data.is_TR?)
next 0
}
)
#===============================================================================
# ConfirmUseInField handlers
# Return values: true/false