#===============================================================================
# ** 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 Effect
#-----------------------------------------------------------------------------
def slip_damage_effect
@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]
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]
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
return true
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