#===============================================================================

# Nova's Utility Belt v. 1.0

#===============================================================================
=begin

What does this do?

- Changes the maximum battle members.
- Continues playing map BGM during battle unless specified by a switch.
- Disables the shutdown menu on the Main Menu if specified.
- Turns on a switch during playtesting only.
- Allows Actors to keep their experience points upon changing classes.
- Adjust the limits of how many items you can carry.
- Modify critical damage formula.
- Add/remove states from the target target upon inflicting a critical.
- Can change the settings for dashing.
- Can change the actor's descriptions using a script call.


===============================================================================
INSTRUCTIONS:

Plug in below Materials, but above Main. Remember to save. For best
results, place this script BELOW all other custom scripts.
===============================================================================

===============================================================================
COMPATIBILITY:

This was made to simply bring forth default systems in Ace. It makes very few
changes to the systems themselves. As such, it SHOULD be compatable with most
scripts you can find.
===============================================================================

===============================================================================
ACTOR DESCRIPTIONS

If you want to change the description of your actors throughout the game,
place this script call in an event:

$game_actors[x]description = "Your description here."

where x is the index of whatever actor you want to add in the description.
===============================================================================

=end


module NOVA
module UTILITY

#===============================================================================
# Adjust this to change the maximum party members you can have in battle.
#===============================================================================

MAX_BATTLE_MEMBERS = 4

#===============================================================================
# Switch must be OFF to hide boss music. Set to 0 to disable
# When ON: battle music will play.
# When OFF: the map BGM will continue playing during battle.
#===============================================================================

PLAY_BATTLE_MUSIC = 40

#===============================================================================
# Set this to true to disable the shutdown option in the title screen menu
#===============================================================================

NO_SHUTDOWN = false

#===============================================================================
# Turns a game switch on only when in playtest mode. Useful for adding
# self commentary nodes. Set to 0 to disable
#===============================================================================

PLAYTEST_SWITCH = 0

#===============================================================================
# When an actor changes classes, set this to true to keep all the
# experience gained.
#===============================================================================

KEEP_EXP = false # default false

#===============================================================================
# MAX_ITEMS
#===============================================================================

MAX_ITEMS = 99 # DEFAULT: 99

#===============================================================================
# Save Settings:
# 0 = Always show
# 1 = only during playtesting
# 2 = Never show
#===============================================================================

SAVE_OPTION_SETTING = 0


#===============================================================================
# Formation Settings:
# 0 = Always show
# 1 = only during playtesting
# 2 = Never show
#===============================================================================

FORMATION_OPTION_SETTING = 0

#===============================================================================
# This changes the damage formula for critical hits as well as
# adding/removing states for battlers upon scoring a critical hit.
#===============================================================================
CRIT_DMG = 3 # <-- The base damage is multiplies by this. Default 3
CRIT_TARGET_STATE_ADD = 0
CRIT_TARGET_STATE_REM = 0

#==============================================================================
# Dash Settings:
# 0 = Speed up
# 1 = Slow down
# 2 = Disable Dashing
#===============================================================================

DASH_SETTING = 0

end
end

#=================================================================================

# End Module
# DO NOT MODIFY BELOW IF YOU DON'T KNOW WHAT YOU ARE DOING!!!!

#=================================================================================



class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# * overwrite method: command_new_game
#--------------------------------------------------------------------------
def command_new_game
DataManager.setup_new_game
close_command_window
if $TEST
$game_switches[NOVA::UTILITY::PLAYTEST_SWITCH] = true
else
$game_switches[NOVA::UTILITY::PLAYTEST_SWITCH] = false
end
fadeout_all
$game_map.autoplay
SceneManager.goto(Scene_Map)
end
end #Scene_Title



class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# * overwrite method: on_load_success
#--------------------------------------------------------------------------
def on_load_success
Sound.play_load
if $TEST
$game_switches[NOVA::UTILITY::PLAYTEST_SWITCH] = true
else
$game_switches[NOVA::UTILITY::PLAYTEST_SWITCH] = false
end
fadeout_all
$game_system.on_after_load
SceneManager.goto(Scene_Map)
end
end #Scene_Load



class Game_CharacterBase
#--------------------------------------------------------------------------
# * overwrite method: Get Move Speed
#--------------------------------------------------------------------------
def real_move_speed
case NOVA::UTILITY::DASH_SETTING
when 0; @move_speed + (dash? ? 1 : 0)
when 1; @move_speed - (dash? ? 1 : 0)
when 2; @move_speed
end
end
end



module BattleManager

#--------------------------------------------------------------------------
# * Play Battle BGM
#--------------------------------------------------------------------------
def self.play_battle_bgm
if $game_switches[NOVA::UTILITY::PLAY_BATTLE_MUSIC] || NOVA::UTILITY::PLAY_BATTLE_MUSIC == 0
$game_system.battle_bgm.play
end
RPG::BGS.stop
end

end #Module BattleManager


class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# overwrite method: max_item_number
#--------------------------------------------------------------------------
def max_item_number(item)
return NOVA::UTILITY::MAX_ITEMS
end


#--------------------------------------------------------------------------
# * overwrite method: max_battle_members
#--------------------------------------------------------------------------
def max_battle_members
return NOVA::UTILITY::MAX_BATTLE_MEMBERS
end
end #Game_Party



class Window_TitleCommand < Window_Command
#--------------------------------------------------------------------------
# * overwrite method: make_command_list
#--------------------------------------------------------------------------
def make_command_list
add_command(Vocab::new_game, :new_game)
add_command(Vocab::continue, :continue, continue_enabled)
add_command(Vocab::shutdown, :shutdown) if !NOVA::UTILITY::NO_SHUTDOWN
end
end #Window_TitleCommand


class Window_MenuCommand < Window_Command

#--------------------------------------------------------------------------
# alias: add_formation_command
#--------------------------------------------------------------------------
alias nova_form_command add_formation_command
def add_formation_command
case NOVA::UTILITY::FORMATION_OPTION_SETTING
when 0; nova_form_command
when 1; nova_form_command if $TEST
when 2; return
end
end
#--------------------------------------------------------------------------
# alias: add_save_command
#--------------------------------------------------------------------------
alias nova_save_command add_save_command
def add_save_command
case NOVA::UTILITY::SAVE_OPTION_SETTING
when 0; nova_save_command
when 1; nova_save_command if $TEST
when 2; return
end
end

#--------------------------------------------------------------------------
# * overwrite method: add_main_commands
#--------------------------------------------------------------------------
def add_main_commands
add_command(Vocab::item, :item, main_commands_enabled)
add_command(Vocab::skill, :skill, main_commands_enabled)
add_command(Vocab::equip, :equip, main_commands_enabled)
add_command(Vocab::status, :status, main_commands_enabled)
end
end #Window_MenuCommand


class Game_Battler
#--------------------------------------------------------------------------
# * overwrite method: make_damage_value
#--------------------------------------------------------------------------
def make_damage_value(user, item)
value = item.damage.eval(user, self, $game_variables)
value *= item_element_rate(user, item)
value *= pdr if item.physical?
value *= mdr if item.magical?
value *= rec if item.damage.recover?
value = apply_critical(user, value) if @result.critical
value = apply_variance(value, item.damage.variance)
value = apply_guard(value)
@result.make_damage(value.to_i, item)
end

#--------------------------------------------------------------------------
# * overwrite method: apply_critical
#--------------------------------------------------------------------------
def apply_critical(user, damage)
add_state(NOVA::UTILITY::CRIT_TARGET_STATE_ADD)
remove_state(NOVA::UTILITY::CRIT_TARGET_STATE_REM)
damage * NOVA::UTILITY::CRIT_DMG
end

#--------------------------------------------------------------------------
# * alias method: on_action_end
#--------------------------------------------------------------------------
alias nova_utility_actionend on_action_end
def on_action_end
#user.add_state(NOVA::UTILITY::CRIT_USER_STATE_ADD) unless !@result.critical
#user.remove_state(NOVA::UTILITY::CRIT_USER_STATE_REM) unless !@result.critical
nova_utility_actionend
end
end #Game_Battler



class Game_Actor < Game_Battler

#--------------------------------------------------------------------------
# * Change Class
# keep_exp: Keep EXP
#--------------------------------------------------------------------------
def change_class(class_id, keep_exp = NOVA::UTILITY::KEEP_EXP)
@exp[class_id] = exp if keep_exp
@class_id = class_id
change_exp(@exp[@class_id] || 0, false)
refresh
end


#--------------------------------------------------------------------------
# new method: description=
#--------------------------------------------------------------------------
def description=(text)
@description = text
end

#--------------------------------------------------------------------------
# overwrite method: description
#--------------------------------------------------------------------------
def description
return @description unless @description.nil?
return actor.description
end
end #Game_Actor