Kain Nobel
Member
States : Slip Damage +
Version: 3.5
By: Kain Nobel
Introduction
This script handles and stacks multiple 'slip damage' effects, which can either act like a "Poison" or "Regen"-esque state. You have the options of setting a Direct, Percent and Variance modifier to the damage/recovery done with HP and SP. This script is way better fine-tuned than any other script I've ever come across of the same nature, and knows how to stack multiple-effects properly.
Features
Script
Instructions
Place above 'main' and below the 'SDK'
Compatibility
This script is likely to be incompatible with scripts which modify the following methods, since they're overwritten...
Due to the nature of the script, these overwrites were necessary and couldn't be aliased. Place this script ABOVE anything that overwrites the methods above^^
Not guaranteed to work with scripts that modify and display a fancy damage displays, but if it does it'll probably display damage like the default system. If you have any issues with this script VS a damage display script, I'll definately look into it and see how both work together.
This script does not work with "States : Regen" script from Kain Nobel Test Bed (v1.5). Please either use the Regen script, or replace it with this one since you can't use both!
FAQ
Special Thanks
Although this script was written from scratch, I'd like to thank the following for releasing their own versions of a script like this because I've learned from them, and their versions are the ones I tested.
Author's Notes
I will most likely post a 'non-SDK' version when I find time, and if VX doesn't already have a special 'slip damage' feature like this then I might make a VX version for the families
Comments, questions, suggestions and bug-reports encouraged! Also, if you have any compatability issues with this script and another one, please make a topic in Script Support and link me to the topic here or via PM. I will try to resolve compatability issues right away!
Terms and Conditions
Free for 'commercial' and 'non-commercial' use, credit is an absolute requirement!!! Please do not re-distribute outside of the community without my written consent first!
Version: 3.5
By: Kain Nobel
Introduction
This script handles and stacks multiple 'slip damage' effects, which can either act like a "Poison" or "Regen"-esque state. You have the options of setting a Direct, Percent and Variance modifier to the damage/recovery done with HP and SP. This script is way better fine-tuned than any other script I've ever come across of the same nature, and knows how to stack multiple-effects properly.
Features
- The following applies to HP & SP (Map & Battle)
- A Direct modifier can be set to slip state values
- A Percent modifer can be set to slip state values
- A Variance modifer can be set to slip state values
- Multiple "Poison"-esque states can be made with this
- Multiple "Regen"-esque states can be made with this
- HP values are stacked accordingly
- SP values are stacked accordingly
- Damage pop will let you know if poison is affecting HP, SP or both
Script
Code:
#===============================================================================
# ** States : Slip Damage +
#===============================================================================
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
SDK.log('States.SlipDamage+', 'Kain Nobel ©', 3.5, '2009.06.17')
SDK.log_overwrite(:Game_Battler, :slip_damage_effect_base_damage)
SDK.log_overwrite(:Game_Battler, :slip_damage_effect_dispersion)
SDK.log_overwrite(:Game_Battler, :slip_damage_effect_damage)
SDK.log_overwrite(:Game_Party, :check_map_slip_damage)
#-------------------------------------------------------------------------------
# * SDK Enabled Test :
#-------------------------------------------------------------------------------
if SDK.enabled?('States.SlipDamage+')
#===============================================================================
# ** RPG::State::Slip_Damage
#===============================================================================
class RPG::State::Slip_Damage
#-----------------------------------------------------------------------------
# * Test (This will print slip damage values, if you're testing...)
#-----------------------------------------------------------------------------
Test = true
#-----------------------------------------------------------------------------
# * Map : HP Direct
#-----------------------------------------------------------------------------
Map_HP_Direct = Hash.new
#-----------------------------------------------------------------------------
# * Map : HP Percent
#-----------------------------------------------------------------------------
Map_HP_Percent = Hash.new
#-----------------------------------------------------------------------------
# * Map : HP Variance
#-----------------------------------------------------------------------------
Map_HP_Variance = Hash.new
#-----------------------------------------------------------------------------
# * Map : SP Direct
#-----------------------------------------------------------------------------
Map_SP_Direct = Hash.new
#-----------------------------------------------------------------------------
# * Map : SP Percent
#-----------------------------------------------------------------------------
Map_SP_Percent = Hash.new
#-----------------------------------------------------------------------------
# * Map : SP Variance
#-----------------------------------------------------------------------------
Map_SP_Variance = Hash.new
#-----------------------------------------------------------------------------
# * Battle : HP Direct
#-----------------------------------------------------------------------------
Battle_HP_Direct = Hash.new
#-----------------------------------------------------------------------------
# * Battle : HP Percent
#-----------------------------------------------------------------------------
Battle_HP_Percent = Hash.new
#-----------------------------------------------------------------------------
# * Battle : HP Variance
#-----------------------------------------------------------------------------
Battle_HP_Variance = Hash.new
#-----------------------------------------------------------------------------
# * Battle : SP Direct
#-----------------------------------------------------------------------------
Battle_SP_Direct = Hash.new
#-----------------------------------------------------------------------------
# * Battle : SP Percent
#-----------------------------------------------------------------------------
Battle_SP_Percent = Hash.new
#-----------------------------------------------------------------------------
# * Battle : SP Variance
#-----------------------------------------------------------------------------
Battle_SP_Variance = Hash.new
#-----------------------------------------------------------------------------
# * Constant Defaults (Do Not Touch : Will Affect ALL States)
#-----------------------------------------------------------------------------
Map_HP_Direct.default = Battle_HP_Direct.default = 0
Map_HP_Percent.default = Battle_HP_Percent.default = 0
Map_HP_Variance.default = Battle_HP_Variance.default = 0
Map_SP_Direct.default = Battle_SP_Direct.default = 0
Map_SP_Percent.default = Battle_SP_Percent.default = 0
Map_SP_Variance.default = Battle_SP_Variance.default = 0
#-----------------------------------------------------------------------------
# * Public Instance Variables
#-----------------------------------------------------------------------------
attr_accessor :map_hp_direct, :map_hp_percent, :map_hp_variance
attr_accessor :map_sp_direct, :map_sp_percent, :map_sp_variance
attr_accessor :battle_hp_direct,:battle_hp_percent, :battle_hp_variance
attr_accessor :battle_sp_direct,:battle_sp_percent, :battle_sp_variance
#-----------------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------------
def initialize(id)
@map_hp_direct = Map_HP_Direct[id]
@map_hp_percent = Map_HP_Percent[id]
@map_hp_variance = Map_HP_Variance[id]
@map_sp_direct = Map_SP_Direct[id]
@map_sp_percent = Map_SP_Percent[id]
@map_sp_variance = Map_SP_Variance[id]
@battle_hp_direct = Battle_HP_Direct[id]
@battle_hp_percent = Battle_HP_Percent[id]
@battle_hp_variance = Battle_HP_Variance[id]
@battle_sp_direct = Battle_SP_Direct[id]
@battle_sp_percent = Battle_SP_Percent[id]
@battle_sp_variance = Battle_SP_Variance[id]
end
end
#===============================================================================
# ** RPG::State
#===============================================================================
class RPG::State
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :advslipdmg_rpgstate_slipdamage, :slip_damage
#-----------------------------------------------------------------------------
# * Slip
#-----------------------------------------------------------------------------
def slip
@@slip ||= RPG::State::Slip_Damage.new(id)
return @@slip
end
#-----------------------------------------------------------------------------
# * Slip Damage
#-----------------------------------------------------------------------------
def slip_damage
result = advslipdmg_rpgstate_slipdamage
result |= !slip_hp_direct.zero?
result |= !slip_hp_percent.zero?
result |= !slip_sp_direct.zero?
result |= !slip_sp_percent.zero?
return result
end
#-----------------------------------------------------------------------------
# * Slip HP Direct
#-----------------------------------------------------------------------------
def slip_hp_direct
($scene.is_a?(Scene_Map) ? slip.map_hp_direct : slip.battle_hp_direct)
end
#-----------------------------------------------------------------------------
# * Slip HP Percent
#-----------------------------------------------------------------------------
def slip_hp_percent
($scene.is_a?(Scene_Map) ? slip.map_hp_percent : slip.battle_hp_percent)
end
#-----------------------------------------------------------------------------
# * Slip HP Variance
#-----------------------------------------------------------------------------
def slip_hp_variance
($scene.is_a?(Scene_Map) ? slip.map_hp_variance : slip.battle_hp_variance)
end
#-----------------------------------------------------------------------------
# * Slip SP Direct
#-----------------------------------------------------------------------------
def slip_sp_direct
($scene.is_a?(Scene_Map) ? slip.map_sp_direct : slip.battle_sp_direct)
end
#-----------------------------------------------------------------------------
# * Slip SP Percent
#-----------------------------------------------------------------------------
def slip_sp_percent
($scene.is_a?(Scene_Map) ? slip.map_sp_percent : slip.battle_sp_percent)
end
#-----------------------------------------------------------------------------
# * Slip SP Variance
#-----------------------------------------------------------------------------
def slip_sp_variance
($scene.is_a?(Scene_Map) ? slip.map_sp_variance : slip.battle_sp_variance)
end
end
#===============================================================================
# ** Game_Battler
#===============================================================================
class Game_Battler
#-----------------------------------------------------------------------------
# * Slip Damage Effects : Base Damage
#-----------------------------------------------------------------------------
def slip_damage_effect_base_damage
@slip_hp = @slip_sp = 0
self.states.each do |state_id|
if $data_states[state_id].nil? || !$data_states[state_id].slip_damage
next
end
state = $data_states[state_id]
@slip_hp += self.maxhp * (state.slip_hp_percent / 100.0)
@slip_sp += self.maxsp * (state.slip_sp_percent / 100.0)
@slip_hp += state.slip_hp_direct
@slip_sp += state.slip_sp_direct
@slip_hp += 1 if state.slip_hp_direct > 0
@slip_sp += 1 if state.slip_sp_direct > 0
@slip_hp += 1 if state.slip_hp_percent > 0
@slip_sp += 1 if state.slip_sp_percent > 0
end
@slip_test = [self.name, "Base Damage", @slip_hp, @slip_sp]
end
#-----------------------------------------------------------------------------
# * Slip Damage Effects : Dispersion
#-----------------------------------------------------------------------------
def slip_damage_effect_dispersion
hp_var = sp_var = hp_avg = sp_avg = 0
self.states.each do |state_id|
s = $data_states[state_id]
next if s.nil? || !s.slip_damage
unless s.slip_hp_direct.zero? && s.slip_hp_percent.zero?
hp_var += s.slip_hp_variance
hp_avg += 1
end
unless s.slip_sp_direct.zero? && s.slip_sp_percent.zero?
sp_var += s.slip_sp_variance
sp_avg += 1
end
end
unless hp_avg.zero?
hp_var /= hp_avg
hp_var = (rand(2) > 1 ? rand(hp_var) : -rand(hp_var))
end
unless sp_avg.zero?
sp_var /= sp_avg
sp_var = (rand(2) > 1 ? rand(sp_var) : -rand(sp_var))
end
if @slip_hp.abs > 0
@slip_hp += hp_var
end
if @slip_sp.abs > 0
@slip_sp += sp_var
end
@slip_test += ["Dispersion", @slip_hp, @slip_sp]
end
#-----------------------------------------------------------------------------
# * Slip Damage Effects : Damage
#-----------------------------------------------------------------------------
def slip_damage_effect_damage
damage_hp = Integer(@slip_hp)
damage_sp = Integer(@slip_sp)
self.damage = Array.new
self.damage << "Slip Damage"
self.hp -= damage_hp
self.damage << damage_hp
self.sp -= damage_sp
self.damage << damage_sp
@slip_test += [self.damage]
p *@slip_test if RPG::State::Slip_Damage::Test
end
end
#===============================================================================
# ** Game_Party
#===============================================================================
class Game_Party
#-----------------------------------------------------------------------------
# * Check Map Slip Damage
#-----------------------------------------------------------------------------
def check_map_slip_damage
@actors.each do |actor|
next if actor.dead? || !actor.slip_damage?
old_hp = actor.hp
actor.slip_damage_effect
if actor.dead?
$game_system.se_play($data_system.actor_collapse_se)
end
unless actor.hp == old_hp
flash_color = (actor.hp < old_hp ? [255, 0, 0, 128] : [0, 255, 0, 128])
$game_screen.start_flash(Color.new(*flash_color), 4)
end
$game_temp.gameover = $game_party.all_dead?
end
end
end
#===============================================================================
# ** RPG::Sprite
#===============================================================================
class RPG::Sprite
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :advslipdmg_rpgsprite_damage, :damage
#-----------------------------------------------------------------------------
# * Damage
#-----------------------------------------------------------------------------
def damage(value, critical)
unless value.is_a?(Array) && value[0] == "Slip Damage"
advslipdmg_rpgsprite_damage(value, critical)
return
end
dispose_damage
hp_damage = value[1]
sp_damage = value[2]
hp_damage_s = "HP #{(hp_damage > 0 ? hp_damage : -hp_damage)}"
sp_damage_s = "SP #{(sp_damage > 0 ? sp_damage : -sp_damage)}"
bitmap = Bitmap.new(160, 96)
bitmap.font.name = "Arial Black"
bitmap.font.size = 32
bitmap.font.color.set(0, 0, 0)
y = 12
unless hp_damage.zero?
bitmap.draw_text(-1, y-1, 160, 36, hp_damage_s, 1)
bitmap.draw_text(+1, y-1, 160, 36, hp_damage_s, 1)
bitmap.draw_text(-1, y+1, 160, 36, hp_damage_s, 1)
bitmap.draw_text(+1, y+1, 160, 36, hp_damage_s, 1)
if hp_damage.is_a?(Numeric) and hp_damage < 0
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(255, 255, 255)
end
bitmap.draw_text(0, y, 160, 36, hp_damage_s, 1)
end
unless sp_damage.zero?
y += 32 unless hp_damage.zero?
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, y-1, 160, 36, sp_damage_s, 1)
bitmap.draw_text(+1, y-1, 160, 36, sp_damage_s, 1)
bitmap.draw_text(-1, y+1, 160, 36, sp_damage_s, 1)
bitmap.draw_text(+1, y+1, 160, 36, sp_damage_s, 1)
if sp_damage.is_a?(Numeric) and sp_damage < 0
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(255, 255, 255)
end
bitmap.draw_text(0, y, 160, 36, sp_damage_s, 1)
end
@_damage_sprite = ::Sprite.new(self.viewport)
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 80
@_damage_sprite.oy = 20
@_damage_sprite.x = self.x
@_damage_sprite.y = self.y - self.oy / 2
@_damage_sprite.z = 3000
@_damage_duration = 40
end
end
#-------------------------------------------------------------------------------
# * SDK Enabled Test : End
#-------------------------------------------------------------------------------
end
Instructions
Place above 'main' and below the 'SDK'
Compatibility
This script is likely to be incompatible with scripts which modify the following methods, since they're overwritten...
Game_Battler.slip_damage_effect_base_damage (SDK)
Game_Battler.slip_damage_effect_dispersion (SDK)
Game_Battler.slip_damage_effect_damage (SDK)
Game_Party.check_map_slip_damage
Game_Battler.slip_damage_effect_dispersion (SDK)
Game_Battler.slip_damage_effect_damage (SDK)
Game_Party.check_map_slip_damage
Due to the nature of the script, these overwrites were necessary and couldn't be aliased. Place this script ABOVE anything that overwrites the methods above^^
Not guaranteed to work with scripts that modify and display a fancy damage displays, but if it does it'll probably display damage like the default system. If you have any issues with this script VS a damage display script, I'll definately look into it and see how both work together.
This script does not work with "States : Regen" script from Kain Nobel Test Bed (v1.5). Please either use the Regen script, or replace it with this one since you can't use both!
FAQ
All settings are handled within a Hash, and you have to check which setting you're applying. All settings either refer to the Map, or Battle; also, all settings refer to HP or SP, so yes you can make states that are "Poison" or "Regen" type for SP as well as HP.
Now, to ensure your settings look correct, they must look like one of the following examples...
Example A
Example B
Syntax
state_id : The ID of the state (in database) with the setting.
value : The value of damage/recovery done by state.
Now, to ensure your settings look correct, they must look like one of the following examples...
Example A
Code:
 #-----------------------------------------------------------------------------
 # * Map : HP Direct
 #-----------------------------------------------------------------------------
 Map_HP_Direct    = {state_id => value, ...}
Example B
Code:
 #-----------------------------------------------------------------------------
 # * Map : HP Direct
 #-----------------------------------------------------------------------------
 Map_HP_Direct    = Hash.new
 Map_HP_Direct[state_id] = value
 #...etc, etc, etc...
Syntax
state_id : The ID of the state (in database) with the setting.
value : The value of damage/recovery done by state.
Basically, a "Direct" setting will call a direct ammount of HP/SP damage (or healing) to a battler inflicted with that particular state.
For instance, if you have a state with a "Direct" HP modifier of 30, that means the state will do 30 damage (or heal you by 30 points, if -30).
A Direct value is calculated after percent, but before variance, but basically damage won't be 'exactly 30' if there is a variance or percent setting.
For instance, if you have a state with a "Direct" HP modifier of 30, that means the state will do 30 damage (or heal you by 30 points, if -30).
A Direct value is calculated after percent, but before variance, but basically damage won't be 'exactly 30' if there is a variance or percent setting.
Basically, a "Percent" setting will call [value] percent of Max HP (or SP) to be damaged/recovered each time the state cycles.
For instance, if you have a "Percent" HP modifier of 50, that means the damage/recovery done by the state will be based off of [target.maxhp] at 50%.
A Percent value is calculated before direct and variance, but basically damage/recovery won't be 'exactly 50% of Max HP' if one of the other settings are modified.
For instance, if you have a "Percent" HP modifier of 50, that means the damage/recovery done by the state will be based off of [target.maxhp] at 50%.
A Percent value is calculated before direct and variance, but basically damage/recovery won't be 'exactly 50% of Max HP' if one of the other settings are modified.
Basically, a "Variance" setting will randomize the value of damage/recovery done by the state each cycle.
So, if you have a state with 0 variance, it'll just calculate Percent/Direct, however, if you have a variance of 15 then that means the state's damage/recovery value will be added or subtracted up to 15 points.
A Variance value is calculated after direct and percent.
So, if you have a state with 0 variance, it'll just calculate Percent/Direct, however, if you have a variance of 15 then that means the state's damage/recovery value will be added or subtracted up to 15 points.
A Variance value is calculated after direct and percent.
In order to make a state to regenerate HP and/or SP, then you must ensure that the "Direct" and "Percent" settings of each state are negative (less than 0), this will trigger recovery. If you do one negative, and the other positive, then it might be likely to still be a 'damage' state rather than a 'regenerate' state.
Simply because slip states require values now. For instance, if you plug it in right now with the settings as-is and don't modify anything, then the default "Venom" state probably won't do anything in battle. Please refer and set the constants in the top of the script to set states with slip damage.
Please note, slip state values for Map and Battle are seperate, so a defined Battle slip state will do something but the map slip state likely will not.
Please note, slip state values for Map and Battle are seperate, so a defined Battle slip state will do something but the map slip state likely will not.
Again, I'm aware of that issue but read the spoiler above this one; it tells you why.
I'll probably edit the script later when I have time, so if a state isn't defined within the script's settings, yet this checkbox is marked in the database it'll deduct maxhp at 10% like a standard slip state.
I'll probably edit the script later when I have time, so if a state isn't defined within the script's settings, yet this checkbox is marked in the database it'll deduct maxhp at 10% like a standard slip state.
Special Thanks
Although this script was written from scratch, I'd like to thank the following for releasing their own versions of a script like this because I've learned from them, and their versions are the ones I tested.
- SephirothSpawn
- Trickster
- Yeyinde
Author's Notes
I will most likely post a 'non-SDK' version when I find time, and if VX doesn't already have a special 'slip damage' feature like this then I might make a VX version for the families
Comments, questions, suggestions and bug-reports encouraged! Also, if you have any compatability issues with this script and another one, please make a topic in Script Support and link me to the topic here or via PM. I will try to resolve compatability issues right away!
Terms and Conditions
Free for 'commercial' and 'non-commercial' use, credit is an absolute requirement!!! Please do not re-distribute outside of the community without my written consent first!