Merge branch 'dev' into ui-redesign

This commit is contained in:
Maruno17
2024-09-20 21:30:46 +01:00
15 changed files with 168 additions and 39 deletions

View File

@@ -60,8 +60,15 @@ end
# class Numeric
#===============================================================================
class Numeric
# Turns a number into a string formatted like 12,345,678.
# Turns a number into a string formatted like 12,345,678. Some languages use
# different characters as the thousands separator.
def to_s_formatted
case System.user_language[0..1]
when "fr", "es"
return self.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\1 ').reverse
when "it", "de"
return self.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\1.').reverse
end
return self.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\1,').reverse
end
@@ -72,9 +79,38 @@ class Numeric
_INTL("twelve"), _INTL("thirteen"), _INTL("fourteen"), _INTL("fifteen"),
_INTL("sixteen"), _INTL("seventeen"), _INTL("eighteen"), _INTL("nineteen"),
_INTL("twenty")]
return ret[self] if self.is_a?(Integer) && self >= 0 && self <= ret.length
return ret[self] if self.is_a?(Integer) && self >= 0 && self <= ret.length - 1
return self.to_s
end
def to_ordinal
ret = [_INTL("zeroth"), _INTL("first"), _INTL("second"), _INTL("third"),
_INTL("fourth"), _INTL("fifth"), _INTL("sixth"), _INTL("seventh"),
_INTL("eighth"), _INTL("ninth"), _INTL("tenth"), _INTL("eleventh"),
_INTL("twelfth"), _INTL("thirteenth"), _INTL("fourteenth"), _INTL("fifteenth"),
_INTL("sixteenth"), _INTL("seventeenth"), _INTL("eighteenth"), _INTL("nineteenth"),
_INTL("twentieth")]
return ret[self] if self.is_a?(Integer) && self >= 0 && self <= ret.length - 1
return self.to_ord
end
# Returns "1st", "2nd", "3rd", etc.
def to_ord
return self.to_s if !self.is_a?(Integer)
ret = self.to_s
if ((self % 100) / 10) == 1 # 10-19
ret += "th"
elsif (self % 10) == 1
ret += "st"
elsif (self % 10) == 2
ret += "nd"
elsif (self % 10) == 3
ret += "rd"
else
ret += "th"
end
return ret
end
end
#===============================================================================

View File

@@ -556,8 +556,18 @@ module PluginManager
return true if $full_compile
return true if !FileTest.exist?("Data/PluginScripts.rxdata")
Input.update
# Force compiling if holding Shift or Ctrl
return true if Input.press?(Input::SHIFT) || Input.press?(Input::CTRL)
# analyze whether or not to push recompile
# Should compile if the number of plugins has changed
scripts = load_data("Data/PluginScripts.rxdata")
return true if scripts.length != plugins.length
# Should compile if any plugins have changed version or been replaced
found_plugins = []
plugins.each_pair { |name, meta| found_plugins.push([meta[:name], meta[:version]]) }
existing_plugins = []
scripts.each { |plugin| existing_plugins.push([plugin[1][:name], plugin[1][:version]]) }
return true if found_plugins != existing_plugins
# Should compile if any plugin files have been recently modified
mtime = File.mtime("Data/PluginScripts.rxdata")
order.each do |o|
# go through all the registered plugin scripts

View File

@@ -72,11 +72,13 @@ end
#===============================================================================
SaveData.register_conversion(:v22_add_primal_reversion_stat) do
SaveData.register_conversion(:v22_add_new_stats) do
essentials_version 22
display_title "Adding a primal reversion stat"
display_title "Adding some more stats"
to_value :stats do |stats|
stats.instance_eval do
@wild_battles_fled = 0 if !@wild_battles_fled
@pokemon_release_count = 0 if !@pokemon_release_count
@primal_reversion_count = 0 if !@primal_reversion_count
end
end

View File

@@ -400,8 +400,22 @@ class Interpreter
result = ($game_switches[@parameters[1]] == (@parameters[2] == 0))
end
when 1 # variable
value1 = $game_variables[@parameters[1]]
value2 = (@parameters[2] == 0) ? @parameters[3] : $game_variables[@parameters[3]]
variable1_name = $data_system.variables[@parameters[1]]
if variable1_name && variable1_name[/^s\:/]
value1 = eval($~.post_match)
else
value1 = $game_variables[@parameters[1]]
end
if @parameters[2] == 0
value2 = @parameters[3]
else
variable2_name = $data_system.variables[@parameters[3]]
if variable2_name && variable2_name[/^s\:/]
value2 = eval($~.post_match)
else
value2 = $game_variables[@parameters[3]]
end
end
case @parameters[4]
when 0 then result = (value1 == value2)
when 1 then result = (value1 >= value2)

View File

@@ -79,13 +79,19 @@ class Game_Event < Game_Character
end
def switchIsOn?(id)
switchname = $data_system.switches[id]
return false if !switchname
if switchname[/^s\:/]
switch_name = $data_system.switches[id]
if switch_name && switch_name[/^s\:/]
return eval($~.post_match)
else
return $game_switches[id]
end
return $game_switches[id]
end
def variableIsLessThan?(id, value)
variable_name = $data_system.variables[id]
if variable_name && variable_name[/^s\:/]
return eval($~.post_match) < value
end
return $game_variables[id] < value
end
def variable
@@ -208,7 +214,7 @@ class Game_Event < Game_Character
c = page.condition
next if c.switch1_valid && !switchIsOn?(c.switch1_id)
next if c.switch2_valid && !switchIsOn?(c.switch2_id)
next if c.variable_valid && $game_variables[c.variable_id] < c.variable_value
next if c.variable_valid && variableIsLessThan?(c.variable_id, c.variable_value)
if c.self_switch_valid
key = [@map_id, @event.id, c.self_switch_ch]
next if $game_self_switches[key] != true

View File

@@ -28,12 +28,13 @@ class GameStats
attr_accessor :eggs_hatched
attr_accessor :evolution_count, :evolutions_cancelled
attr_accessor :trade_count
attr_accessor :pokemon_release_count
attr_accessor :moves_taught_by_item, :moves_taught_by_tutor, :moves_taught_by_reminder
attr_accessor :day_care_deposits, :day_care_levels_gained
attr_accessor :pokerus_infections
attr_accessor :shadow_pokemon_purified
# Battles
attr_accessor :wild_battles_won, :wild_battles_lost # Lost includes fled from
attr_accessor :wild_battles_won, :wild_battles_lost, :wild_battles_fled # Fled counts both player and wild Pokémon fleeing
attr_accessor :trainer_battles_won, :trainer_battles_lost
attr_accessor :total_exp_gained
attr_accessor :battle_money_gained, :battle_money_lost
@@ -101,6 +102,7 @@ class GameStats
@evolution_count = 0
@evolutions_cancelled = 0
@trade_count = 0
@pokemon_release_count = 0
@moves_taught_by_item = 0
@moves_taught_by_tutor = 0
@moves_taught_by_reminder = 0
@@ -111,6 +113,7 @@ class GameStats
# Battles
@wild_battles_won = 0
@wild_battles_lost = 0
@wild_battles_fled = 0
@trainer_battles_won = 0
@trainer_battles_lost = 0
@total_exp_gained = 0

View File

@@ -897,16 +897,12 @@ class Battle::Move::DisableTargetHealingMoves < Battle::Move
end
#===============================================================================
# Target cannot use sound-based moves for 2 more rounds. (Throat Chop)
# Target cannot use sound-based moves for 2 rounds. (Throat Chop)
#===============================================================================
class Battle::Move::DisableTargetSoundMoves < Battle::Move
def pbAdditionalEffect(user, target)
return if target.fainted? || target.damageState.substitute
if target.effects[PBEffects::ThroatChop] == 0
@battle.pbDisplay(_INTL("The effects of {1} prevent {2} from using certain moves!",
@name, target.pbThis(true)))
end
target.effects[PBEffects::ThroatChop] = 3
target.effects[PBEffects::ThroatChop] = 2 if target.effects[PBEffects::ThroatChop] == 0
end
end

View File

@@ -194,13 +194,23 @@ class Battle::AI
# Returns whether the move will definitely fail against the target (assuming
# no battle conditions change between now and using the move).
def pbPredictMoveFailureAgainstTarget
calc_type = @move.rough_type
typeMod = @move.move.pbCalcTypeMod(calc_type, @user.battler, @target.battler)
# Move effect-specific checks
return true if Battle::AI::Handlers.move_will_fail_against_target?(@move.function_code, @move, @user, @target, self, @battle)
# Immunity to priority moves because of Psychic Terrain
return true if @battle.field.terrain == :Psychic && @target.battler.affectedByTerrain? &&
@target.opposes?(@user) && @move.rough_priority(@user) > 0
# Immunity because of ability
return true if @move.move.pbImmunityByAbility(@user.battler, @target.battler, false)
if @target.has_active_ability?(:WONDERGUARD) && !@target.being_mold_broken?
# NOTE: The Battle::AbilityEffects::MoveImmunity for Wonder Guard makes
# use of target.damageState.typeMod, which isn't set by the AI, so
# its triggering needs to be checked here instead of via
# pbImmunityByAbility.
return true if move.damagingMove? && calc_type && !Effectiveness.super_effective?(typeMod)
else
return true if @move.move.pbImmunityByAbility(@user.battler, @target.battler, false)
end
# Immunity because of Dazzling/Queenly Majesty
if @move.rough_priority(@user) > 0 && @target.opposes?(@user)
each_same_side_battler(@target.side) do |b, i|
@@ -208,8 +218,6 @@ class Battle::AI
end
end
# Type immunity
calc_type = @move.rough_type
typeMod = @move.move.pbCalcTypeMod(calc_type, @user.battler, @target.battler)
return true if @move.move.pbDamagingMove? && Effectiveness.ineffective?(typeMod)
# Dark-type immunity to moves made faster by Prankster
return true if Settings::MECHANICS_GENERATION >= 7 && @move.statusMove? &&

View File

@@ -842,7 +842,8 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("DisableTargetHealingMove
#===============================================================================
Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("DisableTargetSoundMoves",
proc { |score, move, user, target, ai, battle|
next score if target.effects[PBEffects::ThroatChop] > 1
next score if target.effects[PBEffects::ThroatChop] >= 1
next score if target.effects[PBEffects::Substitute] > 0
next score if !target.check_for_move { |m| m.soundMove? }
# Check additional effect chance
add_effect = move.get_score_change_for_additional_effect(user, target)

View File

@@ -334,9 +334,12 @@ module BattleCreationHelperMethods
when Battle::Outcome::WIN, Battle::Outcome::CATCH
$stats.wild_battles_won += 1 if !trainer_battle
$stats.trainer_battles_won += 1 if trainer_battle
when Battle::Outcome::LOSE, Battle::Outcome::FLEE, Battle::Outcome::DRAW
when Battle::Outcome::LOSE, Battle::Outcome::DRAW
$stats.wild_battles_lost += 1 if !trainer_battle
$stats.trainer_battles_lost += 1 if trainer_battle
when Battle::Outcome::FLEE
$stats.wild_battles_fled += 1 if !trainer_battle
$stats.trainer_battles_lost += 1 if trainer_battle
end
pbSet(outcome_variable, outcome)
end

View File

@@ -1865,6 +1865,7 @@ class PokemonStorageScreen
end
command = pbShowCommands(_INTL("Release this Pokémon?"), [_INTL("No"), _INTL("Yes")])
if command == 1
$bag.add(pokemon.item_id) if pokemon.hasItem?
pkmnname = pokemon.name
@scene.pbRelease(selected, heldpoke)
if heldpoke
@@ -1875,6 +1876,7 @@ class PokemonStorageScreen
@scene.pbRefresh
pbDisplay(_INTL("{1} was released.", pkmnname))
pbDisplay(_INTL("Bye-bye, {1}!", pkmnname))
$stats.pokemon_release_count += 1
@scene.pbRefresh
end
return

View File

@@ -118,7 +118,30 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand
end
else
name = $data_system.variables[index + 1]
status = $game_variables[index + 1].to_s
codeswitch = (name[/^s\:/])
if codeswitch
code = $~.post_match
code_parts = code.split(/[(\[=<>. ]/)
code_parts[0].strip!
code_parts[0].gsub!(/^\s*!/, "")
status = nil
if code_parts[0][0][/[a-z]/i]
if code_parts[0][0].upcase == code_parts[0][0] &&
(Kernel.const_defined?(code_parts[0]) rescue false)
status = (eval(code) rescue nil) # Code starts with a class/method name
elsif code_parts[0][0].downcase == code_parts[0][0] &&
!(Interpreter.method_defined?(code_parts[0].to_sym) rescue false) &&
!(Game_Event.method_defined?(code_parts[0].to_sym) rescue false)
status = (eval(code) rescue nil) # Code starts with a method name (that isn't in Interpreter/Game_Event)
end
else
# Code doesn't start with a letter, probably $, just evaluate it
status = (eval(code) rescue nil)
end
else
status = $game_variables[index + 1]
end
status = status.to_s
status = "\"__\"" if nil_or_empty?(status)
end
name ||= ""
@@ -186,6 +209,8 @@ def pbDebugVariables(mode)
current_id = right_window.index + 1
case mode
when 0 # Switches
name = $data_system.switches[current_id]
next if name && name[/^s\:/]
if Input.trigger?(Input::USE)
pbPlayDecisionSE
$game_switches[current_id] = !$game_switches[current_id]
@@ -193,6 +218,8 @@ def pbDebugVariables(mode)
$game_map.need_refresh = true
end
when 1 # Variables
name = $data_system.variables[current_id]
next if name && name[/^s\:/]
if Input.repeat?(Input::LEFT)
pbDebugSetVariable(current_id, -1)
right_window.refresh
@@ -715,7 +742,7 @@ def pbDebugFixInvalidTiles
else
echoln ""
Console.echo_h2(_INTL("Done. {1} errors found and fixed.", total_errors), text: :green)
Console.echo_warn(_INTL("RMXP data was altered. Close RMXP now to ensure changes are applied."))
Console.echo_warn(_INTL("RMXP data was altered. Close RMXP now without saving to ensure changes are applied."))
echoln ""
pbMessage(_INTL("{1} error(s) were found across {2} map(s) and fixed.", total_errors, num_error_maps))
pbMessage(_INTL("Close RPG Maker XP to ensure the changes are applied properly."))

View File

@@ -81,7 +81,7 @@ module FilenameUpdater
# Warn if any map data has been changed
if !change_record.empty?
change_record.each { |msg| Console.echo_warn(msg) }
Console.echo_warn(_INTL("RMXP data was altered. Close RMXP now to ensure changes are applied."))
Console.echo_warn(_INTL("RMXP data was altered. Close RMXP now without saving to ensure changes are applied."))
end
echoln ""
Console.echo_h2(_INTL("Finished updating file names and locations"), text: :green)

View File

@@ -14,7 +14,8 @@ module Compiler
rescue SystemCallError
end
end
compile_pbs_files
text_files = get_all_pbs_files_to_compile
compile_pbs_files(text_files)
}
}
@@ -97,8 +98,7 @@ module Compiler
return (latest_text_edit_time >= latest_data_write_time)
end
def compile_pbs_files
text_files = get_all_pbs_files_to_compile
def compile_pbs_files(text_files)
modify_pbs_file_contents_before_compiling
compile_town_map(*text_files[:TownMap][1])
compile_connections(*text_files[:Connection][1])

View File

@@ -40,11 +40,17 @@ module Compiler
["calcStats", "calc_stats"]
]
@@categories[:import_new_maps] = {
:should_compile => proc { |compiling| next !new_maps_to_import.nil? },
:header_text => proc { next _INTL("Importing new maps") },
:skipped_text => proc { next _INTL("None found") },
:compile => proc { import_new_maps }
}
@@categories[:map_data] = {
:should_compile => proc { |compiling| next import_new_maps },
:header_text => proc { next _INTL("Modifying map data") },
:skipped_text => proc { next _INTL("Not modified") },
:compile => proc { compile_trainer_events }
:header_text => proc { next _INTL("Modifying map data") },
:skipped_text => proc { next _INTL("Not modified") },
:compile => proc { compile_trainer_events }
}
@@categories[:messages] = {
@@ -67,8 +73,9 @@ module Compiler
#-----------------------------------------------------------------------------
# Add new map files to the map tree.
#-----------------------------------------------------------------------------
def import_new_maps
return false if !$DEBUG
def new_maps_to_import
return nil if !$DEBUG
mapfiles = {}
# Get IDs of all maps in the Data folder
Dir.chdir("Data") do
@@ -85,6 +92,19 @@ module Compiler
mapfiles.delete(id) if mapfiles[id]
maxOrder = [maxOrder, mapinfos[id].order].max
end
return (mapfiles.empty?) ? nil : mapfiles
end
def import_new_maps
mapfiles = new_maps_to_import
return false if !mapfiles
# Get maxOrder to add new maps at
maxOrder = 0
mapinfos = pbLoadMapInfos
mapinfos.each_key do |id|
next if !mapinfos[id]
maxOrder = [maxOrder, mapinfos[id].order].max
end
# Import maps not found in mapinfos
maxOrder += 1
imported = false
@@ -102,7 +122,8 @@ module Compiler
if imported
save_data(mapinfos, "Data/MapInfos.rxdata")
$game_temp.map_infos = nil
pbMessage(_INTL("{1} new map(s) copied to the Data folder were successfully imported.", count))
Console.echoln_li_done(_INTL("{1} map(s) imported", count))
Console.echo_warn(_INTL("RMXP data was altered. Close RMXP now without saving to ensure changes are applied."))
end
return imported
end
@@ -1769,7 +1790,7 @@ module Compiler
save_data(commonEvents, "Data/CommonEvents.rxdata") if changed
Console.echo_done(true)
if change_record.length > 0 || changed
Console.echo_warn(_INTL("RMXP data was altered. Close RMXP now to ensure changes are applied."))
Console.echo_warn(_INTL("RMXP data was altered. Close RMXP now without saving to ensure changes are applied."))
end
end
end