=begin
"Blood Mage" Script for RMXP, v 1.80
by WcW
Introduction:
This script was made by request for Akkein (aka Akkrin) at
http://forum.chaos-project.com/. Make sure to credit him and
all others listed in the "Credits/Thanks" section below if you
use this script. For detailed instructions on how to use this script,
please see the section "Directions" below. For small mods that can
be done, see the "Tips/Modifying this Script" section below.
Features:
* Allows for the consumption of HP rather than SP for skills
* Can be configured to set "Blood Mage" state based on class,
actor, state, or by default on some skills
* Can set behavior for when an actor has too little HP for a
skill, and can set a minimum percentage of HP an actor must
have to use skills
* As of 1.8, no bug-free (hopefully! ;))
* Compatible with SP-cost add-ons and RTAB
* Small code; less than 100 lines if you cut out all commeting
and white space
Version History:
1.0: Release
1.02: Undocumented bug fixes
1.12: Bug fix (checked for SP in addition to HP)
1.22: "Bloodkill" added, allowing for you to disable "suicide" moves
1.32: Blizzard gave me some optimized code
1.33: Undocumented bug fix
1.43: Modified some code, added new features
1.44: Fixed status window refresh
1.45: Fixed bug where Blood Skills were unaffected by SP cost modifications
1.46: Fixed bug where no HP was consumed if the actor had 0 SP
1.56: Added the option to disable bloodmage for some skills
1.57: More RTAB compatibility (a la Blizzard)
1.58: Fixed bugs (once again, a la Blizzard)
1.59: Fixed $game_system.bloodmage_not error
1.70: New testing version; direct predecessor and base of 1.8x series;
better coding, new options, improved compatibility
1.71: Undocumented bug fix
1.72: Fixed RTAB error
1.73: Improved comments, optimized skill_can_use?(id), added overcharging
option, fixed an as-yet undiscovered bug (actors with too little HP
could use a blood skill anyway)
1.73b: Fixed a careless mistake
1.80: All bugs fixed, bloodstates added, all commenting redone, flagged
as stable, $WCW_BLOOD_MAGE added ;)
Roadmap:
1.85: BlizzABS compatibility, enemies as blood mages, and "dryusers" (users
who will never use blood skills)
Directions:
You should place this script below all of the default RMXP scripts (these
should end in Scene_Debug) and above any of Blizzard's scripts.
All of the instructions below are either referring to the code directly
after this comment-block, or the code inside Game_System within this script.
- If you want to use RTAB with this script, change
"WCW_BLOODMAGE_RTAB = false" to "WCW_BLOODMAGE_RTAB = true". This enables
a small workaround for a quirk in RTAB (make_skill_action_result takes
an argument, whereas it does not in the DBS)
- To set an actor to be a bloodmage by default, add his ID between the
brackets next to "@wcw_bloodusers =" below, and separate all IDs with
commas. To remove a user from the group, simply delete their ID. To add
a Blood-User in-game, use a Call Script event command with the code
"$game_system.wcw_bloodusers.push <id>", replacing <id> with the
actor's ID. To remove them, use "$game_system.wcw_bloodusers.delete <id>",
likewise replacing <id> with the actor's ID.
- To set a class to Blood Mage, add the ID between the brackets beside
"@wcw_bloodmages =" below, once again separating them with commas.
To remove a class, simply remove the ID. To add in-game, use Call Script
with "$game_system.wcw_bloodmages.push <id>", replacing <id> with the ID.
To remove a class, use "$game_system.wcw_bloodmages.delete <id>".
- To add a Blood State, add the ID of the state between the brackets next
to "@wcw_bloodstates =" below, separating each ID with a comma. To
remove a state, simply remove the ID. To do the same in-game, use
"$game_system.wcw_bloodstates.push <id>" and
"$game_system.wcw_bloodstates.delete <id>".
- To add a skill which always consumes HP rather than MP, add its ID
between the brackets next to "@wcw_bloodskills = " below, separating
each ID with commas. To remove the skill, remove the ID. To do the
same in-game, use "$game_system.wcw_bloodskills.push <id>" and
"$game_system.wcw_bloodskills.delete <id>".
- To add a skill that will consume SP even when used by a Bloodmage,
add its ID between the brackets next to "@wcw_dryskills =" below,
separating each with a comma. To remove the skill, remove the ID.
To do the same in-game, use "$game_system.wcw_dryskills.push <id>" and
"$game_system.wcw_dryskills.delete <id>".
- To allow a Blood Mage to die when they use a skill the require more
HP than they have, replace "false" with "true" next to "@wcw_blood_die = "
below. To reverse this, replace "true" with "false". TO do the same
in-game, use "$game_system.wcw_blood_die = true" and
"$game_system.wcw_blood_die = false".
- To have a Bloodmage be left with 1 HP after they overcharge, replace
"false" with "true" on the line with "@wcw_blood_overcharge". To do the
same in-game, use "$game_system.wcw_blood_overcharge = true" or
"$game_system.wcw_blood_overcharge = false". For this to work, the
option above must be set to "false".
- To set the minimum % HP a Blood Mage must have to use a Blood Skill,
set the number between 0 and 1 next to "@wcw_blood_limit = " below. To do
the same in-game, use "$game_system.wcw_blood_limit = <% in decimal>".
Tips/Modifying this Script:
* To change how much a Blood Mage is left with after overcharging,
replace the "battler.hp = 1" in make_skill_action_effect in Scene_Battle
with "battler.hp = <expression>", and the "return @hp > 1" in
skil_can_use? in Game_Battler with "return @hp > <expression>".
* To make $game_system.wcw_blood_limit be a static amount rather than
percentage, replace "(self.hp * $game_system.wcw_blood_limit).to_i"
in skill_can_use? in Game_battler with "$game_system.wcw_blood_limit".
* To check for Blood Mage, use "if $WCW_BLOOD_MAGE". To check the version,
use "if $WCW_BLOOD_MAGE > <your_version>".
Compatibility:
Tested with SP Cost Mod from Blizzard's Tons of Add-Ons and the
Default Battle System. If you find any issues, please report them
at http://forum.chaos-project.com/, in the Blood Mage thread, which
will most likely be in the "RMXP Script Database" forum.
Credits:
Blizzard, for helping me learn to script, pointing out a bug, and
optimizing code
Fantasist, for getting me to come back to RMXP
Akkrin, for giving me the Blood Mage idea
Myself, for scripting it
Cid, for reporting two errors ;)
omegapirate2000, for confirming Cid's error (more the merrier :P)
game_guy, for giving me an idea (overcharging)
Enjoy |:]
=end
$WCW_BLOOD_MAGE = 1.8
#----------------------------------------------------------------------------
# * CONFIG (redefinition of Game_System class)
# Configuration section :)
#----------------------------------------------------------------------------
# To use with RTAB, change false in the line below to true.
WCW_BLOODMAGE_RTAB = false
class Game_System
# Defines getter's and setter's for configuration variables
attr_accessor :wcw_bloodusers, :wcw_bloodmages, :wcw_bloodstates,
:wcw_bloodskills, :wcw_dryskills, :wcw_blood_die,
:wcw_blood_overcharge, :wcw_blood_limit
# Backs up the old initialize method
alias init_wcw_bloodmage_later initialize
#------------------------------------------------------------------------
# - initialize
# First method called :P
#------------------------------------------------------------------------
def initialize
# This variable stores the ID's of all classes which should consume
# HP over MP.
@wcw_bloodusers = [1]
# This variable stores the ID's of all actors that act as
# bloodmages, even though their class is not a bloodmage.
@wcw_bloodmages = []
# This variable stores the IDs of all states which cause an actor to
# consumer HP rather than MP.
@wcw_bloodstates = []
# This variable stores the ID's of all skills which will act as
# bloodmage skills, even if the actor using it isn't a bloodmage
@wcw_bloodskills = []
# This variable stores the ID's of all skills which will not cause
# a bloodmage to lose HP if they use them.
@wcw_dryskills = [57]
# If this variable is set to "true," bloodmages will be able to kill
# themselves if they use to much HP (it will use more HP than the
# actor has, even if it is not enough for the skill.) If it is
# set to false, they will only be able to use the skills until it
# would put them below $game_system.wcw_blood_limit.
@wcw_blood_die = false
# If this variable is set to "true," (and the one above is false),
# then when an actor uses a blood skill that costs more HP than he
# currently has, it will simply reduce his HP to one. (STILL IN
# TESTING).
@wcw_blood_overcharge = false
# This number must be set from 0 to 1. It signifies the minimum
# percent of HP an actor must have to use a skill if
# $game_system.wcw_blood_die is set to "false. 0 is default,
# and means the actor can use skills until his HP is 1.
@wcw_blood_limit = 0
# Do everything else that is normally done :P
return init_wcw_bloodmage_later
end
end
#----------------------------------------------------------------------------
# * Bulk of the code (redefinition of some Game_Battler code)
#----------------------------------------------------------------------------
class Game_Battler
# Backs up skill_can_use?(skill_id)
alias skill_can_use_wcw_bloodmage_later skill_can_use? #lol, long name :P
#------------------------------------------------------------------------
# - wcw_is_bloodmage?()
# Checks to see if actor is a bloodmage.
#------------------------------------------------------------------------
def wcw_is_bloodmage?
return self.is_a?(Game_Actor) && (
$game_system.wcw_bloodusers.include?(self.class_id) ||
$game_system.wcw_bloodmages.include?(self.id) ||
@states.any? {|s| $game_system.wcw_bloodstates.include?(s)})
end
#------------------------------------------------------------------------
# - wcw_bloodmages_applies?(skill_id)
# Checks to see whether a given skill is a bloodskill when used by
# the actor.
#------------------------------------------------------------------------
def wcw_bloodmage_applies?(skill_id)
return (wcw_is_bloodmage? && (!
$game_system.wcw_dryskills.include?(skill_id))) ||
$game_system.wcw_bloodskills.include?(skill_id)
end
#------------------------------------------------------------------------
# - skill_can_use?(skill_id)
# Checks to see if a skill can be used
#------------------------------------------------------------------------
def skill_can_use?(skill_id)
# Go ahead and pass it on if the actor isn't a bloodmage or the
# skill isn't a bloodskill
unless wcw_bloodmage_applies?(skill_id)
return skill_can_use_wcw_bloodmage_later(skill_id)
end
# Get HP Cost, check other factors
mysp = @sp
@sp = $data_skills[skill_id].sp_cost
return false unless skill_can_use_wcw_bloodmage_later(skill_id)
@sp = mysp
# Check HP
if $game_system.wcw_blood_die
return true
elsif $game_system.wcw_blood_overcharge
return @hp > 1
else
cost = (($tons_version >= 6.54) && $game_system.SP_COST_MOD) ?
BlizzCFG.get_cost_mod(@states, $data_skills[skill_id].sp_cost) :
$data_skills[skill_id].sp_cost
print cost
return (self.hp - cost) >((self.maxhp*$game_system.wcw_blood_limit).to_i)
end
end
end
#----------------------------------------------------------------------------
# * Code to make sure bloodmages consume HP instead of MP
#----------------------------------------------------------------------------
class Scene_Battle
# Backs up make_skill_action_result
alias make_skl_act_res_wcw_bldmg_later make_skill_action_result
#----------------------------------------------------------------------------
# - make_skill_action_result(battler=nil)
# Execute skill
#----------------------------------------------------------------------------
def make_skill_action_result(battler = @active_battler)
mysp = battler.sp
# RTAB Compatibility Workaround
if WCW_BLOODMAGE_RTAB
make_skl_act_res_wcw_bldmg_later battler
else
make_skl_act_res_wcw_bldmg_later
end
# Reduce HP, and put the SP back where it should be :P
if battler.wcw_bloodmage_applies?(@skill.id)
cost = ($tons_version && $game_system.SP_COST_MOD) ?
BlizzCFG.get_cost_mod(battler.states, $data_skills[@skill.id].sp_cost) :
$data_skill[@skill.id].sp_cost
# Set HP to 1 if overcharging; else, subtract cost
if (battler.hp < cost) && $game_system.wcw_blood_overcharge
battler.hp = 1
else
battler.hp -= cost
end
battler.sp = mysp
end
# Refresh Status Window
@status_window.refresh
end
end