mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Added more stats, added script variables, fixed AI thinking Wonder Guard provides total immunity, releasing a Pokémon puts its held item in the Bag, tweaked new map Compiler
This commit is contained in:
@@ -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
|
||||
|
||||
#===============================================================================
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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? &&
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -717,7 +744,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."))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user