Added "Consumable" property to items.txt, light effects now properly centre themselves on the event regardless of graphic size, Disguise/Double Iron Bash Gen 8 changes

This commit is contained in:
Maruno17
2021-07-21 22:46:49 +01:00
parent 03a7ff39ad
commit 551f64e8a1
20 changed files with 184 additions and 162 deletions

View File

@@ -49,12 +49,12 @@ module ItemHandlers
# 0 - Item not used
# 1 - Item used, don't end screen
# 2 - Item used, end screen
# 3 - Item used, don't end screen, consume item
# 4 - Item used, end screen, consume item
def self.triggerUseFromBag(item)
return UseFromBag.trigger(item) if UseFromBag[item]
# No UseFromBag handler exists; check the UseInField handler if present
return UseInField.trigger(item) if UseInField[item]
if UseInField[item]
return (UseInField.trigger(item)) ? 1 : 0
end
return 0
end
@@ -68,10 +68,9 @@ module ItemHandlers
# -1 - Item effect not found
# 0 - Item not used
# 1 - Item used
# 3 - Item used, consume item
def self.triggerUseInField(item)
return -1 if !UseInField[item]
return UseInField.trigger(item)
return (UseInField.trigger(item)) ? 1 : 0
end
# Returns whether item was used
@@ -561,11 +560,11 @@ def pbUseItem(bag,item,bagscene=nil)
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.pbDeleteItem(item) if itm.is_TR?
bag.pbDeleteItem(item) if itm.consumed_after_use?
return 1
end
return 0
elsif useType==1 || useType==5 # Item is usable on a Pokémon
elsif useType==1 # Item is usable on a Pokémon
if $Trainer.pokemon_count == 0
pbMessage(_INTL("There is no Pokémon."))
return 0
@@ -593,7 +592,7 @@ def pbUseItem(bag,item,bagscene=nil)
pkmn = $Trainer.party[chosen]
if pbCheckUseOnPokemon(item,pkmn,screen)
ret = ItemHandlers.triggerUseOnPokemon(item,pkmn,screen)
if ret && useType==1 # Usable on Pokémon, consumed
if ret && itm.consumed_after_use?
bag.pbDeleteItem(item)
if !bag.pbHasItem?(item)
pbMessage(_INTL("You used your last {1}.",itm.name)) { screen.pbUpdate }
@@ -608,16 +607,9 @@ def pbUseItem(bag,item,bagscene=nil)
return (ret) ? 1 : 0
elsif useType==2 # Item is usable from Bag
intret = ItemHandlers.triggerUseFromBag(item)
case intret
when 0 then return 0
when 1 then return 1 # Item used
when 2 then return 2 # Item used, end screen
when 3 # Item used, consume item
bag.pbDeleteItem(item)
return 1
when 4 # Item used, end screen and consume item
bag.pbDeleteItem(item)
return 2
if intret >= 0
bag.pbDeleteItem(item) if intret == 1 && itm.consumed_after_use?
return intret
end
pbMessage(_INTL("Can't use that here."))
return 0
@@ -643,7 +635,7 @@ def pbUseItemOnPokemon(item,pkmn,scene)
pbMessage(_INTL("\\se[PC access]You booted up {1}.\1",itm.name)) { scene.pbUpdate }
if pbConfirmMessage(_INTL("Do you want to teach {1} to {2}?",movename,pkmn.name)) { scene.pbUpdate }
if pbLearnMove(pkmn,machine,false,true) { scene.pbUpdate }
$PokemonBag.pbDeleteItem(item) if itm.is_TR?
$PokemonBag.pbDeleteItem(item) if itm.consumed_after_use?
return true
end
end
@@ -654,8 +646,7 @@ def pbUseItemOnPokemon(item,pkmn,scene)
ret = ItemHandlers.triggerUseOnPokemon(item,pkmn,scene)
scene.pbClearAnnotations
scene.pbHardRefresh
useType = itm.field_use
if ret && useType==1 # Usable on Pokémon, consumed
if ret && itm.consumed_after_use?
$PokemonBag.pbDeleteItem(item)
if !$PokemonBag.pbHasItem?(item)
pbMessage(_INTL("You used your last {1}.",itm.name)) { scene.pbUpdate }
@@ -668,10 +659,10 @@ def pbUseKeyItemInField(item)
ret = ItemHandlers.triggerUseInField(item)
if ret==-1 # Item effect not found
pbMessage(_INTL("Can't use that here."))
elsif ret==3 # Item was used and consumed
elsif ret > 0 && GameData::Item.get(item).consumed_after_use?
$PokemonBag.pbDeleteItem(item)
end
return ret!=-1 && ret!=0
return ret > 0
end
def pbUseItemMessage(item)

View File

@@ -10,16 +10,14 @@ ItemHandlers::UseText.copy(:BICYCLE,:MACHBIKE,:ACROBIKE)
#===============================================================================
# UseFromBag handlers
# Return values: 0 = not used
# 1 = used, item not consumed
# 2 = close the Bag to use, item not consumed
# 3 = used, item consumed
# 4 = close the Bag to use, item consumed
# 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.
#===============================================================================
ItemHandlers::UseFromBag.add(:HONEY,proc { |item|
next 4
next 2
})
ItemHandlers::UseFromBag.add(:ESCAPEROPE,proc { |item|
@@ -28,7 +26,7 @@ ItemHandlers::UseFromBag.add(:ESCAPEROPE,proc { |item|
next 0
end
if ($PokemonGlobal.escapePoint rescue false) && $PokemonGlobal.escapePoint.length>0
next (GameData::Item.get(item).is_key_item?) ? 2 : 4 # End screen and use item
next 2 # End screen and use item
end
pbMessage(_INTL("Can't use that here."))
next 0
@@ -78,9 +76,8 @@ ItemHandlers::ConfirmUseInField.add(:ESCAPEROPE,proc { |item|
#===============================================================================
# UseInField handlers
# Return values: 0 = not used
# 1 = used, item not consumed
# 3 = used, item consumed
# Return values: false = not used
# true = used
# Called if an item is used from the Bag (not on a Pokémon and not a TM/HM) and
# there is no UseFromBag handler above.
# If an item has this handler, it can be registered to the Ready Menu.
@@ -89,11 +86,11 @@ ItemHandlers::ConfirmUseInField.add(:ESCAPEROPE,proc { |item|
def pbRepel(item,steps)
if $PokemonGlobal.repel>0
pbMessage(_INTL("But a repellent's effect still lingers from earlier."))
return 0
return false
end
pbUseItemMessage(item)
$PokemonGlobal.repel = steps
return 3
return true
end
ItemHandlers::UseInField.add(:REPEL,proc { |item|
@@ -138,7 +135,7 @@ ItemHandlers::UseInField.add(:BLACKFLUTE,proc { |item|
pbMessage(_INTL("Wild Pokémon will be repelled."))
$PokemonMap.blackFluteUsed = true
$PokemonMap.whiteFluteUsed = false
next 1
next true
})
ItemHandlers::UseInField.add(:WHITEFLUTE,proc { |item|
@@ -146,24 +143,24 @@ ItemHandlers::UseInField.add(:WHITEFLUTE,proc { |item|
pbMessage(_INTL("Wild Pokémon will be lured."))
$PokemonMap.blackFluteUsed = false
$PokemonMap.whiteFluteUsed = true
next 1
next true
})
ItemHandlers::UseInField.add(:HONEY,proc { |item|
pbUseItemMessage(item)
pbSweetScent
next 3
next true
})
ItemHandlers::UseInField.add(:ESCAPEROPE,proc { |item|
escape = ($PokemonGlobal.escapePoint rescue nil)
if !escape || escape==[]
pbMessage(_INTL("Can't use that here."))
next 0
next false
end
if $game_player.pbHasDependentEvents?
pbMessage(_INTL("It can't be used when you have someone with you."))
next 0
next false
end
pbUseItemMessage(item)
pbFadeOutIn {
@@ -177,13 +174,13 @@ ItemHandlers::UseInField.add(:ESCAPEROPE,proc { |item|
$game_map.refresh
}
pbEraseEscapePoint
next (GameData::Item.get(item).is_key_item?) ? 1 : 3
next true
})
ItemHandlers::UseInField.add(:SACREDASH,proc { |item|
if $Trainer.pokemon_count == 0
pbMessage(_INTL("There is no Pokémon."))
next 0
next false
end
canrevive = false
for i in $Trainer.pokemon_party
@@ -192,7 +189,7 @@ ItemHandlers::UseInField.add(:SACREDASH,proc { |item|
end
if !canrevive
pbMessage(_INTL("It won't have any effect."))
next 0
next false
end
revived = 0
pbFadeOutIn {
@@ -212,7 +209,7 @@ ItemHandlers::UseInField.add(:SACREDASH,proc { |item|
end
screen.pbEndScene
}
next (revived==0) ? 0 : 3
next (revived > 0)
})
ItemHandlers::UseInField.add(:BICYCLE,proc { |item|
@@ -222,9 +219,9 @@ ItemHandlers::UseInField.add(:BICYCLE,proc { |item|
else
pbMountBike
end
next 1
next true
end
next 0
next false
})
ItemHandlers::UseInField.copy(:BICYCLE,:MACHBIKE,:ACROBIKE)
@@ -233,39 +230,39 @@ ItemHandlers::UseInField.add(:OLDROD,proc { |item|
notCliff = $game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
if !$game_player.pbFacingTerrainTag.can_fish || (!$PokemonGlobal.surfing && !notCliff)
pbMessage(_INTL("Can't use that here."))
next 0
next false
end
encounter = $PokemonEncounters.has_encounter_type?(:OldRod)
if pbFishing(encounter,1)
pbEncounter(:OldRod)
end
next 1
next true
})
ItemHandlers::UseInField.add(:GOODROD,proc { |item|
notCliff = $game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
if !$game_player.pbFacingTerrainTag.can_fish || (!$PokemonGlobal.surfing && !notCliff)
pbMessage(_INTL("Can't use that here."))
next 0
next false
end
encounter = $PokemonEncounters.has_encounter_type?(:GoodRod)
if pbFishing(encounter,2)
pbEncounter(:GoodRod)
end
next 1
next true
})
ItemHandlers::UseInField.add(:SUPERROD,proc { |item|
notCliff = $game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
if !$game_player.pbFacingTerrainTag.can_fish || (!$PokemonGlobal.surfing && !notCliff)
pbMessage(_INTL("Can't use that here."))
next 0
next false
end
encounter = $PokemonEncounters.has_encounter_type?(:SuperRod)
if pbFishing(encounter,3)
pbEncounter(:SuperRod)
end
next 1
next true
})
ItemHandlers::UseInField.add(:ITEMFINDER,proc { |item|
@@ -300,31 +297,31 @@ ItemHandlers::UseInField.add(:ITEMFINDER,proc { |item|
pbMessage(_INTL("There's an item buried around here!"))
end
end
next 1
next true
})
ItemHandlers::UseInField.copy(:ITEMFINDER,:DOWSINGMCHN,:DOWSINGMACHINE)
ItemHandlers::UseInField.add(:TOWNMAP,proc { |item|
pbShowMap(-1,false)
next 1
next true
})
ItemHandlers::UseInField.add(:COINCASE,proc { |item|
pbMessage(_INTL("Coins: {1}", $Trainer.coins.to_s_formatted))
next 1
next true
})
ItemHandlers::UseInField.add(:EXPALL,proc { |item|
$PokemonBag.pbChangeItem(:EXPALL,:EXPALLOFF)
pbMessage(_INTL("The Exp Share was turned off."))
next 1
next true
})
ItemHandlers::UseInField.add(:EXPALLOFF,proc { |item|
$PokemonBag.pbChangeItem(:EXPALLOFF,:EXPALL)
pbMessage(_INTL("The Exp Share was turned on."))
next 1
next true
})
#===============================================================================

View File

@@ -238,7 +238,7 @@ Events.onMapChange += proc { |_sender,_e|
# Item handlers
################################################################################
ItemHandlers::UseInField.add(:POKERADAR,proc { |item|
next (pbUsePokeRadar) ? 1 : 0
next pbUsePokeRadar
})
ItemHandlers::UseFromBag.add(:POKERADAR,proc { |item|