More or less standardised separator comments in the code

This commit is contained in:
Maruno17
2024-06-27 21:21:26 +01:00
parent 225549bfce
commit 509a414f37
198 changed files with 1907 additions and 1263 deletions

View File

@@ -1,5 +1,5 @@
#===============================================================================
# ItemHandlers
# ItemHandlers.
#===============================================================================
module ItemHandlers
UseText = ItemHandlerHash.new
@@ -13,42 +13,44 @@ module ItemHandlers
BattleUseOnBattler = ItemHandlerHash.new
BattleUseOnPokemon = ItemHandlerHash.new
def self.hasUseText(item)
module_function
def hasUseText(item)
return !UseText[item].nil?
end
# Shows "Use" option in Bag.
def self.hasOutHandler(item)
def hasOutHandler(item)
return !UseFromBag[item].nil? || !UseInField[item].nil? || !UseOnPokemon[item].nil?
end
# Shows "Register" option in Bag.
def self.hasUseInFieldHandler(item)
def hasUseInFieldHandler(item)
return !UseInField[item].nil?
end
def self.hasUseOnPokemon(item)
def hasUseOnPokemon(item)
return !UseOnPokemon[item].nil?
end
def self.hasUseOnPokemonMaximum(item)
def hasUseOnPokemonMaximum(item)
return !UseOnPokemonMaximum[item].nil?
end
def self.hasUseInBattle(item)
def hasUseInBattle(item)
return !UseInBattle[item].nil?
end
def self.hasBattleUseOnBattler(item)
def hasBattleUseOnBattler(item)
return !BattleUseOnBattler[item].nil?
end
def self.hasBattleUseOnPokemon(item)
def hasBattleUseOnPokemon(item)
return !BattleUseOnPokemon[item].nil?
end
# Returns text to display instead of "Use"
def self.getUseText(item)
# Returns text to display instead of "Use".
def getUseText(item)
return UseText.trigger(item)
end
@@ -56,7 +58,7 @@ module ItemHandlers
# 0 - Item not used
# 1 - Item used, don't end screen
# 2 - Item used, end screen
def self.triggerUseFromBag(item)
def triggerUseFromBag(item)
return UseFromBag.trigger(item) if UseFromBag[item]
# No UseFromBag handler exists; check the UseInField handler if present
if UseInField[item]
@@ -65,8 +67,8 @@ module ItemHandlers
return 0
end
# Returns whether item can be used
def self.triggerConfirmUseInField(item)
# Returns whether item can be used.
def triggerConfirmUseInField(item)
return true if !ConfirmUseInField[item]
return ConfirmUseInField.trigger(item)
end
@@ -75,41 +77,41 @@ module ItemHandlers
# -1 - Item effect not found
# 0 - Item not used
# 1 - Item used
def self.triggerUseInField(item)
def triggerUseInField(item)
return -1 if !UseInField[item]
return (UseInField.trigger(item)) ? 1 : 0
end
# Returns whether item was used
def self.triggerUseOnPokemon(item, qty, pkmn, scene)
# Returns whether item was used.
def triggerUseOnPokemon(item, qty, pkmn, scene)
return false if !UseOnPokemon[item]
return UseOnPokemon.trigger(item, qty, pkmn, scene)
end
# Returns the maximum number of the item that can be used on the Pokémon at once.
def self.triggerUseOnPokemonMaximum(item, pkmn)
def triggerUseOnPokemonMaximum(item, pkmn)
return 1 if !UseOnPokemonMaximum[item]
return 1 if !Settings::USE_MULTIPLE_STAT_ITEMS_AT_ONCE
return [UseOnPokemonMaximum.trigger(item, pkmn), 1].max
end
def self.triggerCanUseInBattle(item, pkmn, battler, move, firstAction, battle, scene, showMessages = true)
def triggerCanUseInBattle(item, pkmn, battler, move, firstAction, battle, scene, showMessages = true)
return true if !CanUseInBattle[item] # Can use the item by default
return CanUseInBattle.trigger(item, pkmn, battler, move, firstAction, battle, scene, showMessages)
end
def self.triggerUseInBattle(item, battler, battle)
def triggerUseInBattle(item, battler, battle)
UseInBattle.trigger(item, battler, battle)
end
# Returns whether item was used
def self.triggerBattleUseOnBattler(item, battler, scene)
# Returns whether item was used.
def triggerBattleUseOnBattler(item, battler, scene)
return false if !BattleUseOnBattler[item]
return BattleUseOnBattler.trigger(item, battler, scene)
end
# Returns whether item was used
def self.triggerBattleUseOnPokemon(item, pkmn, battler, choices, scene)
# Returns whether item was used.
def triggerBattleUseOnPokemon(item, pkmn, battler, choices, scene)
return false if !BattleUseOnPokemon[item]
return BattleUseOnPokemon.trigger(item, pkmn, battler, choices, scene)
end
@@ -127,7 +129,7 @@ def pbCanUseOnPokemon?(item)
end
#===============================================================================
# Change a Pokémon's level
# Change a Pokémon's level.
#===============================================================================
def pbChangeLevel(pkmn, new_level, scene)
new_level = new_level.clamp(1, GameData::GrowthRate.max_level)
@@ -328,7 +330,7 @@ def pbGainExpFromExpCandy(pkmn, base_amt, qty, scene)
end
#===============================================================================
# Restore HP
# Restore HP.
#===============================================================================
def pbItemRestoreHP(pkmn, restoreHP)
newHP = pkmn.hp + restoreHP
@@ -362,7 +364,7 @@ def pbBattleHPItem(pkmn, battler, restoreHP, scene)
end
#===============================================================================
# Restore PP
# Restore PP.
#===============================================================================
def pbRestorePP(pkmn, idxMove, pp)
return 0 if !pkmn.moves[idxMove] || !pkmn.moves[idxMove].id
@@ -383,7 +385,7 @@ def pbBattleRestorePP(pkmn, battler, idxMove, pp)
end
#===============================================================================
# Change EVs
# Change EVs.
#===============================================================================
def pbJustRaiseEffortValues(pkmn, stat, evGain)
stat = GameData::Stat.get(stat).id
@@ -484,7 +486,7 @@ def pbRaiseHappinessAndLowerEV(pkmn, scene, stat, qty, messages)
end
#===============================================================================
# Change nature
# Change nature.
#===============================================================================
def pbNatureChangingMint(new_nature, item, pkmn, scene)
if pkmn.nature_for_stats == new_nature
@@ -503,7 +505,7 @@ def pbNatureChangingMint(new_nature, item, pkmn, scene)
end
#===============================================================================
# Battle items
# Battle items.
#===============================================================================
def pbBattleItemCanCureStatus?(status, pkmn, scene, showMessages)
if !pkmn.able? || pkmn.status != status
@@ -522,7 +524,7 @@ def pbBattleItemCanRaiseStat?(stat, battler, scene, showMessages)
end
#===============================================================================
# Decide whether the player is able to ride/dismount their Bicycle
# Decide whether the player is able to ride/dismount their Bicycle.
#===============================================================================
def pbBikeCheck
if $PokemonGlobal.surfing || $PokemonGlobal.diving ||
@@ -551,7 +553,7 @@ def pbBikeCheck
end
#===============================================================================
# Find the closest hidden item (for Itemfinder)
# Find the closest hidden item (for Itemfinder).
#===============================================================================
def pbClosestHiddenItem
result = []
@@ -577,7 +579,7 @@ def pbClosestHiddenItem
end
#===============================================================================
# Teach and forget a move
# Teach and forget a move.
#===============================================================================
def pbLearnMove(pkmn, move, ignore_if_known = false, by_machine = false, &block)
return false if !pkmn
@@ -638,7 +640,7 @@ def pbForgetMove(pkmn, moveToLearn)
end
#===============================================================================
# Use an item from the Bag and/or on a Pokémon
# Use an item from the Bag and/or on a Pokémon.
#===============================================================================
# @return [Integer] 0 = item wasn't used; 1 = item used; 2 = close Bag to use in field
def pbUseItem(bag, item, bagscene = nil)
@@ -706,7 +708,7 @@ def pbUseItem(bag, item, bagscene = nil)
end
# Only called when in the party screen and having chosen an item to be used on
# the selected Pokémon
# the selected Pokémon.
def pbUseItemOnPokemon(item, pkmn, scene)
itm = GameData::Item.get(item)
# TM or HM
@@ -776,7 +778,7 @@ def pbCheckUseOnPokemon(item, pkmn, _screen)
end
#===============================================================================
# Give an item to a Pokémon to hold, and take a held item from a Pokémon
# Give an item to a Pokémon to hold, and take a held item from a Pokémon.
#===============================================================================
def pbGiveItemToPokemon(item, pkmn, scene, pkmnid = 0)
newitemname = GameData::Item.get(item).portion_name
@@ -854,7 +856,7 @@ def pbTakeItemFromPokemon(pkmn, scene)
end
#===============================================================================
# Choose an item from the Bag
# Choose an item from the Bag.
#===============================================================================
def pbChooseItem(var = 0, *args)
ret = nil

View File

@@ -1,6 +1,7 @@
#===============================================================================
# UseText handlers
# UseText handlers.
#===============================================================================
ItemHandlers::UseText.add(:BICYCLE, proc { |item|
next ($PokemonGlobal.bicycle) ? _INTL("Walk") : _INTL("Use")
})
@@ -16,7 +17,7 @@ ItemHandlers::UseText.add(:EXPALL, proc { |item|
})
#===============================================================================
# UseFromBag handlers
# UseFromBag handlers.
# Return values: 0 = not used
# 1 = used
# 2 = close the Bag to use
@@ -91,7 +92,7 @@ ItemHandlers::UseFromBag.addIf(:move_machines,
)
#===============================================================================
# ConfirmUseInField handlers
# ConfirmUseInField handlers.
# Return values: true/false
# Called when an item is used from the Ready Menu.
# If an item does not have this handler, it is treated as returning true.
@@ -112,7 +113,7 @@ ItemHandlers::ConfirmUseInField.add(:ESCAPEROPE, proc { |item|
})
#===============================================================================
# UseInField handlers
# UseInField handlers.
# 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
@@ -378,7 +379,7 @@ ItemHandlers::UseInField.add(:EXPALLOFF, proc { |item|
})
#===============================================================================
# UseOnPokemon handlers
# UseOnPokemon handlers.
#===============================================================================
# Applies to all items defined as an evolution stone.

View File

@@ -1,6 +1,7 @@
#===============================================================================
# CanUseInBattle handlers
# CanUseInBattle handlers.
#===============================================================================
ItemHandlers::CanUseInBattle.add(:GUARDSPEC, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages|
if !battler || battler.pbOwnSide.effects[PBEffects::Mist] > 0
scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages
@@ -292,9 +293,10 @@ ItemHandlers::CanUseInBattle.add(:POKEFLUTE, proc { |item, pokemon, battler, mov
})
#===============================================================================
# UseInBattle handlers
# For items used directly or on an opposing battler
# UseInBattle handlers.
# For items used directly or on an opposing battler.
#===============================================================================
ItemHandlers::UseInBattle.add(:GUARDSPEC, proc { |item, battler, battle|
battler.pbOwnSide.effects[PBEffects::Mist] = 5
battle.pbDisplay(_INTL("{1} became shrouded in mist!", battler.pbTeam))
@@ -323,9 +325,10 @@ ItemHandlers::UseInBattle.addIf(:poke_balls,
)
#===============================================================================
# BattleUseOnPokemon handlers
# For items used on Pokémon or on a Pokémon's move
# BattleUseOnPokemon handlers.
# For items used on Pokémon or on a Pokémon's move.
#===============================================================================
ItemHandlers::BattleUseOnPokemon.add(:POTION, proc { |item, pokemon, battler, choices, scene|
pbBattleHPItem(pokemon, battler, 20, scene)
})
@@ -527,8 +530,8 @@ ItemHandlers::BattleUseOnPokemon.add(:MAXELIXIR, proc { |item, pokemon, battler,
})
#===============================================================================
# BattleUseOnBattler handlers
# For items used on a Pokémon in battle
# BattleUseOnBattler handlers.
# For items used on a Pokémon in battle.
#===============================================================================
ItemHandlers::BattleUseOnBattler.add(:REDFLUTE, proc { |item, battler, scene|

View File

@@ -112,7 +112,7 @@ class Phone
@contacts = new_contacts
end
#=============================================================================
#-----------------------------------------------------------------------------
# Checks once every second.
def refresh_ready_trainers
@@ -143,7 +143,7 @@ class Phone
contact.time_to_ready = 0
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.rematch_variant
return $PokemonGlobal.phone.rematch_variant
@@ -366,7 +366,7 @@ class Phone
return valid_contacts.sample
end
#===========================================================================
#-----------------------------------------------------------------------------
def make_incoming
return if !can_make?
@@ -442,7 +442,7 @@ class Phone
pbMessage(_INTL("Click!") + "\\wt[10]\n......\\wt[5] ......\1")
end
#===========================================================================
#-----------------------------------------------------------------------------
def generate_trainer_dialogue(contact)
validate contact => Phone::Contact

View File

@@ -13,7 +13,7 @@ class Game_Temp
end
#===============================================================================
# Using the Poke Radar
# Using the Poke Radar.
#===============================================================================
def pbCanUsePokeRadar?
# Can't use Radar if not in tall grass
@@ -156,8 +156,9 @@ def pbPokeRadarGetEncounter(rarity = 0)
end
#===============================================================================
# Event handlers
# Event handlers.
#===============================================================================
EventHandlers.add(:on_wild_species_chosen, :poke_radar_chain,
proc { |encounter|
if GameData::EncounterType.get($game_temp.encounter_type).type != :land ||
@@ -256,8 +257,9 @@ EventHandlers.add(:on_enter_map, :cancel_poke_radar,
)
#===============================================================================
# Item handlers
# Item handlers.
#===============================================================================
ItemHandlers::UseInField.add(:POKERADAR, proc { |item|
next pbUsePokeRadar
})

View File

@@ -1,5 +1,5 @@
#===============================================================================
# Data structure representing mail that the Pokémon can hold
# Data structure representing mail that the Pokémon can hold.
#===============================================================================
class Mail
attr_accessor :item, :message, :sender, :poke1, :poke2, :poke3

View File

@@ -1,5 +1,5 @@
#===============================================================================
# Item icon
# Item icon.
#===============================================================================
class ItemIconSprite < Sprite
attr_reader :item
@@ -111,7 +111,7 @@ class ItemIconSprite < Sprite
end
#===============================================================================
# Item held icon (used in the party screen)
# Item held icon (used in the party screen).
#===============================================================================
class HeldItemIconSprite < Sprite
def initialize(x, y, pokemon, viewport = nil)

View File

@@ -165,7 +165,7 @@ class PokemonBag
end
#===============================================================================
# The PC item storage object, which actually contains all the items
# The PC item storage object, which actually contains all the items.
#===============================================================================
class PCItemStorage
attr_reader :items
@@ -230,19 +230,21 @@ class PCItemStorage
end
#===============================================================================
# Implements methods that act on arrays of items. Each element in an item
# array is itself an array of [itemID, itemCount].
# Implements methods that act on arrays of items. Each element in an item array
# is itself an array of [itemID, itemCount].
# Used by the Bag, PC item storage, and Triple Triad.
#===============================================================================
module ItemStorageHelper
# Returns the quantity of item in items
def self.quantity(items, item)
module_function
# Returns the quantity of item in items.
def quantity(items, item)
ret = 0
items.each { |i| ret += i[1] if i && i[0] == item }
return ret
end
def self.can_add?(items, max_slots, max_per_slot, item, qty)
def can_add?(items, max_slots, max_per_slot, item, qty)
raise "Invalid value for qty: #{qty}" if qty < 0
return true if qty == 0
max_slots.times do |i|
@@ -260,7 +262,7 @@ module ItemStorageHelper
return false
end
def self.add(items, max_slots, max_per_slot, item, qty)
def add(items, max_slots, max_per_slot, item, qty)
raise "Invalid value for qty: #{qty}" if qty < 0
return true if qty == 0
max_slots.times do |i|
@@ -280,8 +282,8 @@ module ItemStorageHelper
return false
end
# Deletes an item (items array, max. size per slot, item, no. of items to delete)
def self.remove(items, item, qty)
# Deletes an item (items array, max. size per slot, item, no. of items to delete).
def remove(items, item, qty)
raise "Invalid value for qty: #{qty}" if qty < 0
return true if qty == 0
ret = false