From c5d7d1447b78d7ca695410d9ce666aeabfa462a7 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Thu, 18 Jan 2024 22:20:46 +0000 Subject: [PATCH] Added Setting for item sell prices, added stat for primal reversions, fixed weird movement when jumping across a map connection --- Data/Scripts/001_Settings.rb | 3 +++ .../002_Save data/005_Game_SaveConversions.rb | 12 ++++++++++++ Data/Scripts/003_Game processing/003_Interpreter.rb | 4 ++-- Data/Scripts/004_Game classes/005_Game_MapFactory.rb | 2 +- Data/Scripts/004_Game classes/012_Game_Stats.rb | 3 ++- Data/Scripts/010_Data/002_PBS data/006_Item.rb | 6 +++--- .../011_Battle/001_Battle/008_Battle_ActionOther.rb | 1 + .../001_Non-interactive UI/003_UI_EggHatching.rb | 1 + 8 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Data/Scripts/001_Settings.rb b/Data/Scripts/001_Settings.rb index 8f2aacb86..7b570b9a1 100644 --- a/Data/Scripts/001_Settings.rb +++ b/Data/Scripts/001_Settings.rb @@ -255,6 +255,9 @@ module Settings # from a Mart at once (true), or 1 Premier Ball for buying 10+ regular Poké # Balls (false). MORE_BONUS_PREMIER_BALLS = (MECHANICS_GENERATION >= 8) + # The default sell price of an item to a Poké Mart is its buy price divided by + # this number. + ITEM_SELL_PRICE_DIVISOR = (MECHANICS_GENERATION >= 9) ? 4 : 2 #----------------------------------------------------------------------------- # Bag diff --git a/Data/Scripts/002_Save data/005_Game_SaveConversions.rb b/Data/Scripts/002_Save data/005_Game_SaveConversions.rb index 63e10203b..00c2ee627 100644 --- a/Data/Scripts/002_Save data/005_Game_SaveConversions.rb +++ b/Data/Scripts/002_Save data/005_Game_SaveConversions.rb @@ -418,3 +418,15 @@ SaveData.register_conversion(:v21_add_bump_stat) do end end end + +#=============================================================================== + +SaveData.register_conversion(:v22_add_primal_reversion_stat) do + essentials_version 22 + display_title "Adding a primal reversion stat" + to_value :stats do |stats| + stats.instance_eval do + @primal_reversion_count = 0 if !@primal_reversion_count + end + end +end diff --git a/Data/Scripts/003_Game processing/003_Interpreter.rb b/Data/Scripts/003_Game processing/003_Interpreter.rb index 21666002e..73e71ebf3 100644 --- a/Data/Scripts/003_Game processing/003_Interpreter.rb +++ b/Data/Scripts/003_Game processing/003_Interpreter.rb @@ -442,9 +442,9 @@ class Interpreter $game_temp.mart_prices[item] = [-1, -1] if !$game_temp.mart_prices[item] $game_temp.mart_prices[item][0] = buy_price if buy_price > 0 if sell_price >= 0 # 0=can't sell - $game_temp.mart_prices[item][1] = sell_price * 2 + $game_temp.mart_prices[item][1] = sell_price elsif buy_price > 0 - $game_temp.mart_prices[item][1] = buy_price + $game_temp.mart_prices[item][1] = buy_price / Settings::ITEM_SELL_PRICE_DIVISOR end end diff --git a/Data/Scripts/004_Game classes/005_Game_MapFactory.rb b/Data/Scripts/004_Game classes/005_Game_MapFactory.rb index 0657b0f2d..8e0b4bbf5 100644 --- a/Data/Scripts/004_Game classes/005_Game_MapFactory.rb +++ b/Data/Scripts/004_Game classes/005_Game_MapFactory.rb @@ -93,7 +93,7 @@ class PokemonMapFactory # Detects whether the player has moved onto a connected map, and if so, causes # their transfer to that map. def setCurrentMap - return if $game_player.moving? + return if $game_player.moving? || $game_player.jumping? return if $game_map.valid?($game_player.x, $game_player.y) newmap = getNewMap($game_player.x, $game_player.y) return if !newmap diff --git a/Data/Scripts/004_Game classes/012_Game_Stats.rb b/Data/Scripts/004_Game classes/012_Game_Stats.rb index d380a3101..59c4b7d7b 100644 --- a/Data/Scripts/004_Game classes/012_Game_Stats.rb +++ b/Data/Scripts/004_Game classes/012_Game_Stats.rb @@ -38,7 +38,7 @@ class GameStats attr_accessor :total_exp_gained attr_accessor :battle_money_gained, :battle_money_lost attr_accessor :blacked_out_count - attr_accessor :mega_evolution_count + attr_accessor :mega_evolution_count, :primal_reversion_count attr_accessor :failed_poke_ball_count # Currency attr_accessor :money_spent_at_marts @@ -118,6 +118,7 @@ class GameStats @battle_money_lost = 0 @blacked_out_count = 0 @mega_evolution_count = 0 + @primal_reversion_count = 0 @failed_poke_ball_count = 0 # Currency @money_spent_at_marts = 0 diff --git a/Data/Scripts/010_Data/002_PBS data/006_Item.rb b/Data/Scripts/010_Data/002_PBS data/006_Item.rb index 94ac69921..6320a58c0 100644 --- a/Data/Scripts/010_Data/002_PBS data/006_Item.rb +++ b/Data/Scripts/010_Data/002_PBS data/006_Item.rb @@ -59,7 +59,7 @@ module GameData ["PortionNamePlural", ItemNameProperty, _INTL("Name of 2 or more portions of this item as displayed by the game.")], ["Pocket", PocketProperty, _INTL("Pocket in the Bag where this item is stored.")], ["Price", LimitProperty.new(Settings::MAX_MONEY), _INTL("Purchase price of this item.")], - ["SellPrice", LimitProperty2.new(Settings::MAX_MONEY), _INTL("Sell price of this item. If blank, is half the purchase price.")], + ["SellPrice", LimitProperty2.new(Settings::MAX_MONEY), _INTL("Sell price of this item. If blank, is usually half the purchase price.")], ["BPPrice", LimitProperty.new(Settings::MAX_BATTLE_POINTS), _INTL("Purchase price of this item in Battle Points (BP).")], ["FieldUse", EnumProperty.new(field_use_array), _INTL("How this item can be used outside of battle.")], ["BattleUse", EnumProperty.new(battle_use_array), _INTL("How this item can be used within a battle.")], @@ -124,7 +124,7 @@ module GameData @real_portion_name_plural = hash[:real_portion_name_plural] @pocket = hash[:pocket] || 1 @price = hash[:price] || 0 - @sell_price = hash[:sell_price] || (@price / 2) + @sell_price = hash[:sell_price] || (@price / Settings::ITEM_SELL_PRICE_DIVISOR) @bp_price = hash[:bp_price] || 1 @field_use = hash[:field_use] || 0 @battle_use = hash[:battle_use] || 0 @@ -255,7 +255,7 @@ module GameData ret = __orig__get_property_for_PBS(key) case key when "SellPrice" - ret = nil if ret == @price / 2 + ret = nil if ret == @price / Settings::ITEM_SELL_PRICE_DIVISOR when "BPPrice" ret = nil if ret == 1 when "FieldUse", "BattleUse" diff --git a/Data/Scripts/011_Battle/001_Battle/008_Battle_ActionOther.rb b/Data/Scripts/011_Battle/001_Battle/008_Battle_ActionOther.rb index f1bb5c0fd..99772ccd3 100644 --- a/Data/Scripts/011_Battle/001_Battle/008_Battle_ActionOther.rb +++ b/Data/Scripts/011_Battle/001_Battle/008_Battle_ActionOther.rb @@ -181,6 +181,7 @@ class Battle battler = @battlers[idxBattler] return if !battler || !battler.pokemon || battler.fainted? return if !battler.hasPrimal? || battler.primal? + $stats.primal_reversion_count += 1 if battler.pbOwnedByPlayer? if battler.isSpecies?(:KYOGRE) pbCommonAnimation("PrimalKyogre", battler) elsif battler.isSpecies?(:GROUDON) diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb b/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb index 788f2eb59..70c5a5de8 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb @@ -215,6 +215,7 @@ def pbHatch(pokemon) pokemon.name = nil pokemon.owner = Pokemon::Owner.new_from_trainer($player) pokemon.happiness = 120 + pokemon.steps_to_hatch = 0 pokemon.timeEggHatched = Time.now.to_i pokemon.obtain_method = 1 # hatched from egg pokemon.hatched_map = $game_map.map_id