Consolidated code for the player interacting in the overworld, fixed bad splash screen animations, added ShowQuantity property to items.txt, fixed Quick Draw and Aroma Veil, fixed text alignment in long list of regional Dexes in Pokédex, added better error message in load screen if player's charset is missing

This commit is contained in:
Maruno17
2023-06-12 22:32:41 +01:00
parent 20affb4345
commit 9c2a9130a5
20 changed files with 106 additions and 66 deletions

View File

@@ -125,7 +125,7 @@ class Scene_Map
updateMaps
$game_system.update
$game_screen.update
break unless $game_temp.player_transferring
break if !$game_temp.player_transferring
transfer_player(false)
break if $game_temp.transition_processing
end
@@ -169,7 +169,7 @@ class Scene_Map
updateMaps
$game_system.update
$game_screen.update
break unless $game_temp.player_transferring
break if !$game_temp.player_transferring
transfer_player(false)
break if $game_temp.transition_processing
end
@@ -192,7 +192,7 @@ class Scene_Map
if Input.trigger?(Input::USE)
$game_temp.interact_calling = true
elsif Input.trigger?(Input::ACTION)
unless $game_system.menu_disabled || $game_player.moving?
if !$game_system.menu_disabled && !$game_player.moving?
$game_temp.menu_calling = true
$game_temp.menu_beep = true
end
@@ -202,7 +202,7 @@ class Scene_Map
$game_temp.debug_calling = true if $DEBUG
end
end
unless $game_player.moving?
if !$game_player.moving?
if $game_temp.menu_calling
call_menu
elsif $game_temp.debug_calling
@@ -213,8 +213,18 @@ class Scene_Map
pbUseKeyItem
elsif $game_temp.interact_calling
$game_temp.interact_calling = false
$game_player.straighten
EventHandlers.trigger(:on_player_interact)
triggered = false
# Try to trigger an event the player is standing on, and one in front of
# the player
if !$game_temp.in_mini_update
triggered ||= $game_player.check_event_trigger_here([0])
triggered ||= $game_player.check_event_trigger_there([0, 2]) if !triggered
end
# Try to trigger an interaction with a tile
if !triggered
$game_player.straighten
EventHandlers.trigger(:on_player_interact)
end
end
end
end

View File

@@ -84,7 +84,6 @@ class Interpreter
def update
@loop_count = 0
loop do
# TODO: Possibly not needed?
@loop_count += 1
if @loop_count > 100 # Call Graphics.update for freeze prevention
Graphics.update

View File

@@ -549,12 +549,6 @@ class Game_Player < Game_Character
# No events triggered, try other event triggers upon finishing a step
pbOnStepTaken(result)
end
# Try to manually interact with events
if Input.trigger?(Input::USE) && !$game_temp.in_mini_update
# Same position and front event determinant
check_event_trigger_here([0])
check_event_trigger_there([0, 2])
end
end
end

View File

@@ -199,6 +199,7 @@ class PictureEx
def clearProcesses
@processes = []
@timer_start = nil
end
def adjustPosition(xOffset, yOffset)
@@ -458,6 +459,7 @@ class PictureEx
end
# Clear out empty spaces in @processes array caused by finished processes
@processes.compact! if procEnded
@timer_start = nil if @processes.empty? && @rotate_speed == 0
# Add the constant rotation speed
if @rotate_speed != 0
@frameUpdates.push(Processes::ANGLE) if !@frameUpdates.include?(Processes::ANGLE)

View File

@@ -13,6 +13,7 @@ module GameData
attr_reader :battle_use
attr_reader :flags
attr_reader :consumable
attr_reader :show_quantity
attr_reader :move
attr_reader :real_description
attr_reader :pbs_file_suffix
@@ -37,6 +38,7 @@ module GameData
"OnBattler" => 3, "OnFoe" => 4, "Direct" => 5}],
"Flags" => [:flags, "*s"],
"Consumable" => [:consumable, "b"],
"ShowQuantity" => [:show_quantity, "b"],
"Move" => [:move, "e", :Move],
"Description" => [:real_description, "q"]
}
@@ -63,6 +65,7 @@ module GameData
["BattleUse", EnumProperty.new(battle_use_array), _INTL("How this item can be used within a battle.")],
["Flags", StringListProperty, _INTL("Words/phrases that can be used to group certain kinds of items.")],
["Consumable", BooleanProperty, _INTL("Whether this item is consumed after use.")],
["ShowQuantity", BooleanProperty, _INTL("Whether the Bag shows how many of this item are in there.")],
["Move", MoveProperty, _INTL("Move taught by this HM, TM or TR.")],
["Description", StringProperty, _INTL("Description of this item.")]
]
@@ -128,6 +131,7 @@ module GameData
@flags = hash[:flags] || []
@consumable = hash[:consumable]
@consumable = !is_important? if @consumable.nil?
@show_quantity = hash[:show_quantity]
@move = hash[:move]
@real_description = hash[:real_description] || "???"
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
@@ -193,6 +197,10 @@ module GameData
return !is_important? && @consumable
end
def show_quantity?
return @show_quantity || !is_important?
end
def unlosable?(species, ability)
return false if species == :ARCEUS && ability != :MULTITYPE
return false if species == :SILVALLY && ability != :RKSSYSTEM

View File

@@ -199,12 +199,19 @@ class Battle
entry[5] = pri
choice[4] = pri
end
# Recalculate sub-priority change caused by ability (but not by item)
if entry[0].abilityActive?
subPri = Battle::AbilityEffects.triggerPriorityBracketChange(entry[0].ability, entry[0], self)
needRearranging = true if subPri != entry[2]
entry[2] = subPri
end
# NOTE: If the battler's ability at the start of this round was one with
# a PriorityBracketChange handler (i.e. Quick Draw), but it Mega
# Evolved and now doesn't have that ability, that old ability's
# priority bracket modifier will still apply. Similarly, if its
# old ability did not have a PriorityBracketChange handler but it
# Mega Evolved and now does have it, it will not apply this round.
# This is because the message saying that it had an effect appears
# before Mega Evolution happens, and recalculating it now would
# make that message inaccurate because Quick Draw only has a
# chance of triggering. However, since Quick Draw is exclusive to
# a species that doesn't Mega Evolve, these circumstances should
# never arise and no one will notice that the priority bracket
# change isn't recalculated when technically it should be.
end
end
# Calculate each battler's overall sub-priority, and whether its ability or

View File

@@ -532,15 +532,15 @@ class Battle::Battler
allAllies.each do |b|
next if !b.hasActiveAbility?(:AROMAVEIL)
if showMessages
@battle.pbShowAbilitySplash(self)
@battle.pbShowAbilitySplash(b)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis))
else
@battle.pbDisplay(_INTL("{1}'s {2} prevents romance!", b.pbThis, b.abilityName))
end
@battle.pbHideAbilitySplash(self)
@battle.pbHideAbilitySplash(b)
end
return true
return false
end
end
end

View File

@@ -143,14 +143,14 @@ class Battle::Move
target.allAllies.each do |b|
next if !b.hasActiveAbility?(:AROMAVEIL)
if showMessage
@battle.pbShowAbilitySplash(target)
@battle.pbShowAbilitySplash(b)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis))
else
@battle.pbDisplay(_INTL("{1} is unaffected because of {2}'s {3}!",
target.pbThis, b.pbThis(true), b.abilityName))
end
@battle.pbHideAbilitySplash(target)
@battle.pbHideAbilitySplash(b)
end
return true
end

View File

@@ -639,7 +639,6 @@ class Battle::Move::AttractTarget < Battle::Move
def pbFailsAgainstTarget?(user, target, show_message)
return false if damagingMove?
return true if !target.pbCanAttract?(user, show_message)
return true if pbMoveFailedAromaVeil?(user, target, show_message)
return false
end

View File

@@ -289,10 +289,10 @@ class Battle::Move::StartNegateHeldItems < Battle::Move
end
#===============================================================================
# The user consumes its held berry and gains its effect. Also, increases the
# user's Defense by 2 stages. The berry can be consumed even if Unnerve/Magic
# Room apply. Fails if the user is not holding a berry. This move cannot be
# chosen to be used if the user is not holding a berry. (Stuff Cheeks)
# The user consumes its held berry increases its Defense by 2 stages. It also
# gains the berry's effect if it has one. The berry can be consumed even if
# Unnerve/Magic Room apply. Fails if the user is not holding a berry. This move
# cannot be chosen to be used if the user is not holding a berry. (Stuff Cheeks)
#===============================================================================
class Battle::Move::UserConsumeBerryRaiseDefense2 < Battle::Move::StatUpMove
def initialize(battle, move)
@@ -319,7 +319,6 @@ class Battle::Move::UserConsumeBerryRaiseDefense2 < Battle::Move::StatUpMove
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
# TODO: Should this return super? It can consume the berry at this point.
return super
end

View File

@@ -275,7 +275,6 @@ HiddenMoveHandlers::UseMove.add(:DIG, proc { |move, pokemon|
# Dive
#===============================================================================
def pbDive
return false if $game_player.pbFacingEvent
map_metadata = $game_map.metadata
return false if !map_metadata || !map_metadata.dive_map_id
move = :DIVE
@@ -308,7 +307,6 @@ end
def pbSurfacing
return if !$PokemonGlobal.diving
return false if $game_player.pbFacingEvent
surface_map_id = nil
GameData::MapMetadata.each do |map_data|
next if !map_data.dive_map_id || map_data.dive_map_id != $game_map.map_id
@@ -683,7 +681,6 @@ HiddenMoveHandlers::UseMove.add(:STRENGTH, proc { |move, pokemon|
# Surf
#===============================================================================
def pbSurf
return false if $game_player.pbFacingEvent
return false if !$game_player.can_ride_vehicle_with_follower?
move = :SURF
movefinder = $player.get_pokemon_with_move(move)

View File

@@ -425,7 +425,8 @@ module RandomDungeon
#===========================================================================
def generate
@rng_seed = @parameters.rng_seed || Random.new_seed
@rng_seed = @parameters.rng_seed || $PokemonGlobal.dungeon_rng_seed || Random.new_seed
$PokemonGlobal.dungeon_rng_seed = nil
Random.srand(@rng_seed)
maxWidth = @usable_width - (@buffer_x * 2)
maxHeight = @usable_height - (@buffer_y * 2)
@@ -1025,7 +1026,8 @@ end
# dungeon.
#===============================================================================
class PokemonGlobalMetadata
attr_writer :dungeon_area, :dungeon_version
attr_writer :dungeon_area, :dungeon_version
attr_accessor :dungeon_rng_seed
def dungeon_area
return @dungeon_area || :none
@@ -1070,21 +1072,3 @@ EventHandlers.add(:on_game_map_setup, :random_dungeon,
end
}
)
#===============================================================================
# TODO: Temporary debug function for testing random dungeon generation.
#===============================================================================
MenuHandlers.add(:debug_menu, :test_random_dungeon, {
"name" => _INTL("Test Random Dungeon Generation"),
"parent" => :main,
"description" => _INTL("Generates a random dungeon and echoes it to the console."),
"effect" => proc {
tileset = :cave # :forest # :cave
tileset_data = GameData::DungeonTileset.try_get((tileset == :forest) ? 23 : 7)
params = GameData::DungeonParameters.try_get(tileset)
dungeon = RandomDungeon::Dungeon.new(params.cell_count_x, params.cell_count_y, tileset_data, params)
dungeon.generate
echoln dungeon.rng_seed
echoln dungeon.write
}
})

View File

@@ -7,6 +7,14 @@ ItemHandlers::UseText.add(:BICYCLE, proc { |item|
ItemHandlers::UseText.copy(:BICYCLE, :MACHBIKE, :ACROBIKE)
ItemHandlers::UseText.add(:EXPALLOFF, proc { |item|
next _INTL("Turn on")
})
ItemHandlers::UseText.add(:EXPALL, proc { |item|
next _INTL("Turn off")
})
#===============================================================================
# UseFromBag handlers
# Return values: 0 = not used

View File

@@ -17,10 +17,10 @@ class Window_DexesList < Window_CommandPokemon
def drawItem(index, count, rect)
super(index, count, rect)
if index >= 0 && index < @commands2.length
pbDrawShadowText(self.contents, rect.x + 254, rect.y, 64, rect.height,
@commands2[index][0].to_s, self.baseColor, self.shadowColor, 1)
pbDrawShadowText(self.contents, rect.x + 350, rect.y, 64, rect.height,
@commands2[index][1].to_s, self.baseColor, self.shadowColor, 1)
pbDrawShadowText(self.contents, rect.x + 254, rect.y + (self.contents.text_offset_y || 0),
64, rect.height, @commands2[index][0].to_s, self.baseColor, self.shadowColor, 1)
pbDrawShadowText(self.contents, rect.x + 350, rect.y + (self.contents.text_offset_y || 0),
64, rect.height, @commands2[index][1].to_s, self.baseColor, self.shadowColor, 1)
allseen = (@commands2[index][0] >= @commands2[index][2])
allown = (@commands2[index][1] >= @commands2[index][2])
pbDrawImagePositions(

View File

@@ -78,19 +78,24 @@ class Window_PokemonBag < Window_DrawableCommand
textpos.push(
[@adapter.getDisplayName(item), rect.x, rect.y + 2, :left, baseColor, shadowColor]
)
if GameData::Item.get(item).is_important?
item_data = GameData::Item.get(item)
showing_register_icon = false
if item_data.is_important?
if @bag.registered?(item)
pbDrawImagePositions(
self.contents,
[["Graphics/UI/Bag/icon_register", rect.x + rect.width - 72, rect.y + 8, 0, 0, -1, 24]]
)
showing_register_icon = true
elsif pbCanRegisterItem?(item)
pbDrawImagePositions(
self.contents,
[["Graphics/UI/Bag/icon_register", rect.x + rect.width - 72, rect.y + 8, 0, 24, -1, 24]]
)
showing_register_icon = true
end
else
end
if item_data.show_quantity? && !showing_register_icon
qty = (@filterlist) ? thispocket[@filterlist[@pocket][index]][1] : thispocket[index][1]
qtytext = _ISPRINTF("x{1: 3d}", qty)
xQty = rect.x + rect.width - self.contents.text_size(qtytext).width - 16

View File

@@ -168,11 +168,14 @@ class PokemonLoad_Scene
if meta
filename = pbGetPlayerCharset(meta.walk_charset, trainer, true)
@sprites["player"] = TrainerWalkingCharSprite.new(filename, @viewport)
if !@sprites["player"].bitmap
raise _INTL("Player character {1}'s walking charset was not found (filename: \"{2}\").", trainer.character_ID, filename)
end
charwidth = @sprites["player"].bitmap.width
charheight = @sprites["player"].bitmap.height
@sprites["player"].x = 112 - (charwidth / 8)
@sprites["player"].y = 112 - (charheight / 8)
@sprites["player"].src_rect = Rect.new(0, 0, charwidth / 4, charheight / 4)
@sprites["player"].x = 112 - (charwidth / 8)
@sprites["player"].y = 112 - (charheight / 8)
@sprites["player"].z = 99999
end
trainer.party.each_with_index do |pkmn, i|
@sprites["party#{i}"] = PokemonIconSprite.new(pkmn, @viewport)

View File

@@ -38,7 +38,7 @@ class Window_PokemonItemStorage < Window_DrawableCommand
itemname = @adapter.getDisplayName(item)
baseColor = (index == @sortIndex) ? Color.new(248, 24, 24) : self.baseColor
textpos.push([itemname, rect.x, rect.y, :left, self.baseColor, self.shadowColor])
if !GameData::Item.get(item).is_important? # Not a Key item/HM/TM
if GameData::Item.get(item).show_quantity?
qty = _ISPRINTF("x{1: 2d}", @bag[index][1])
sizeQty = self.contents.text_size(qty).width
xQty = rect.x + rect.width - sizeQty - 2

View File

@@ -488,8 +488,7 @@ class BattlePointShopScreen
end
if added == quantity
$stats.battle_points_spent += price
# TODO: Add bpshop_items_bought to $stats?
# $stats.bpshop_items_bought += quantity
$stats.mart_items_bought += quantity
@adapter.setBP(@adapter.getBP - price)
@stock.delete_if { |itm| GameData::Item.get(itm).is_important? && $bag.has?(itm) }
pbDisplayPaused(_INTL("Here you are! Thank you!")) { pbSEPlay("Mart buy item") }

View File

@@ -345,7 +345,10 @@ MenuHandlers.add(:debug_menu, :test_wild_battle_advanced, {
params.setCancelValue(0)
level = pbMessageChooseNumber(_INTL("Set the wild {1}'s level.",
GameData::Species.get(species).name), params)
pkmn.push(pbGenerateWildPokemon(species, level)) if level > 0
if level > 0
pkmn.push(pbGenerateWildPokemon(species, level))
size0 = pkmn.length
end
end
else # Edit a Pokémon
if pbConfirmMessage(_INTL("Change this Pokémon?"))
@@ -354,6 +357,7 @@ MenuHandlers.add(:debug_menu, :test_wild_battle_advanced, {
scr.pbEndScreen
elsif pbConfirmMessage(_INTL("Delete this Pokémon?"))
pkmn.delete_at(pkmnCmd)
size0 = [pkmn.length, 1].max
end
end
end
@@ -450,6 +454,8 @@ MenuHandlers.add(:debug_menu, :test_trainer_battle_advanced, {
tr = pbLoadTrainer(trainerdata[0], trainerdata[1], trainerdata[2])
EventHandlers.trigger(:on_trainer_load, tr)
trainers.push([0, tr])
size0 = trainers.length
size1 = trainers.length
end
else # Edit a trainer
if pbConfirmMessage(_INTL("Change this trainer?"))
@@ -462,6 +468,8 @@ MenuHandlers.add(:debug_menu, :test_trainer_battle_advanced, {
end
elsif pbConfirmMessage(_INTL("Delete this trainer?"))
trainers.delete_at(trainerCmd)
size0 = [trainers.length, 1].max
size1 = [trainers.length, 1].max
end
end
end

View File

@@ -0,0 +1,18 @@
#===============================================================================
#
#===============================================================================
MenuHandlers.add(:debug_menu, :test_random_dungeon, {
"name" => "Test Random Dungeon Generation",
"parent" => :main,
"description" => "Generates a random dungeon and echoes it to the console.",
"effect" => proc {
# $PokemonGlobal.dungeon_rng_seed = 12345
tileset = :cave # :forest # :cave
tileset_data = GameData::DungeonTileset.try_get((tileset == :forest) ? 23 : 7)
params = GameData::DungeonParameters.try_get(tileset)
dungeon = RandomDungeon::Dungeon.new(params.cell_count_x, params.cell_count_y, tileset_data, params)
dungeon.generate
echoln dungeon.rng_seed
echoln dungeon.write
}
})