That nasty SP bar - Mel - 05-03-2016
Hey,
I'm using this HP/SP bar script for enemies and have one problem.
When refilling the SP with a potion or SP heal state, the bar doesn't update correctly.
The HP bar works perfectly fine but the SP bar not. It only updates after using another skill.
Does anyone have an idea what to do?
I think the easiest way is to code the SP bar exactly like the HP bar but I'm too bad to accomplish that..
Here is the script. It's only copy and paste.
Code: #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Enemy/Actor HP & SP Bars +
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# By: El Conducter +
# Updated: January/08/08 +
# Version: 4.0 +
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#
# Update History:
# Version 1.0 - Displays enemy & actor HP & SP bars in battle.
#
# Version 2.0 - Made the enemy HP bars more centered aligned with the
# enemy. Actor bars now also show in menu screen.
#
# Version 3.0 - Module added to change bar lengths easier.
#
# Version 4.0 - System Rebuilt, new look for bars, new scrolling ability,
# more customizable features, bars on menu screen is lost,
# SDK compatible
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# What it Does:
# See enemy and actor HP/SP bars during battle.
#
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# How it Works:
#
# This version of the script works similar to the previous versions,
# however it runs a lot differently. Rather than the invisible window
# to display the bars as in previous versions, sub-sprites are used
# instead. The same effects can be achieved this way with more efficeincy
# and less code. New fetures can be taken advantage of through this new
# system like the ability for visual filling and depletion of bars.
# Though not built directly for the SDK, this script will work with or
# without it.
#
# Lengths and settings for the bars are stored in module Bar_Config.
#
# New and altered scripts are:
#
# - module Bar_Length
# - Sprite_HP_Bar
# - Sprite_SP_Bar
# - Sprite_Battler
# - Game_Battler
# - Scene_Battle
#
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# How to Use This Script:
# Just copy it and paste it above Main. If using the SDK, paste below SDK
# and above Main.
#
# To change the bar lengths and other settings go to module Bar_Config
# and change the values there.
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# Comments:
# I hope my script is easy for you to use and modify. Study this script
# to learn the ways of RGSS and join the ranks of those known as 'Scripters'.
#----------------------------------------------------------------------------
#==============================================================================
# ** Module Bar_Config
#------------------------------------------------------------------------------
# Contains various configurations for bars. The lengths, colors, and speeds
# are assigned to constants that will be referenced later in the script.
#==============================================================================
module Bar_Config
# CONSTANTS
# Bar Size
LENGTH = 100
WIDTH = 5
# Bar Colors
# Full bar color
GREEN = Color.new(145, 255, 80, 255)
# Bar low color
RED = Color.new(200, 50, 50, 255)
VIOLET = Color.new(120, 50, 180, 255)
# Colors for HP Bar
YELLOW = Color.new(145, 255, 80, 255)
ORANGE = Color.new(255, 255, 50, 255)
# Colors for SP Bar
INDIGO = Color.new(50, 162, 232, 255)
BLUE = Color.new(50, 111, 157, 255)
# Color for bar border
BLACK = Color.new(0, 0, 0, 255)
# Bar fill & decrease speed
FASTEST = 10
FAST = Graphics.frame_rate / 2
MEDUIM = Graphics.frame_rate
SLOW = Graphics.frame_rate * 2
SLOWEST = 100
# Set this to the above desired speed
CURRENT_SPEED = FAST
# Visibility for bars. Set which bars you want visible for battle.
ACTOR_HP_USED = true
ACTOR_SP_USED = true
ENEMY_HP_USED = true
ENEMY_SP_USED = true
end
#==============================================================================
# ** Sprite_HP_Bar
#------------------------------------------------------------------------------
# This sprite is used to display the HP_Bar for the battler. It inherits form
# RPG::Sprite.
#==============================================================================
class Sprite_HP_Bar < RPG::Sprite
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :battler
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(viewport, battler)
super(viewport)
# Assign battler and variables used in drawing bar
@battler = battler
@battler_hp = 0
@accu_damages = 0
@counter = 0
# Only call setup method if @battler is not equal to nothing
if @battler != nil
setup
end
end
#--------------------------------------------------------------------------
# * Setup: this prepares the bitmap
#--------------------------------------------------------------------------
def setup
@battler_hp = @battler.hp
self.bitmap = Bitmap.new(Bar_Config::LENGTH + 2, Bar_Config::WIDTH)
# Determine if bar is visible for Actor or Enemy
if @battler.is_a?(Game_Enemy)
self.visible = Bar_Config::ENEMY_HP_USED
elsif @battler.is_a?(Game_Actor)
self.visible = Bar_Config::ACTOR_HP_USED
end
# Set bar placement
self.x = @battler.screen_x
self.y = @battler.screen_y + self.bitmap.height
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height
# Call method to draw bars
draw_bars
update
end
#--------------------------------------------------------------------------
# * Method that draws the bars
#--------------------------------------------------------------------------
def draw_bars
# Clear previous bars if any
self.bitmap.clear
# Use formula to get length ratio to health
length = Bar_Config::LENGTH * @battler_hp / @battler.maxhp
# Specify bar & border
bar_border = Rect.new(0, 0, Bar_Config::LENGTH + 2, Bar_Config::WIDTH)
bar = Rect.new(1, 1, length, Bar_Config::WIDTH - 2)
# Draw the bar with border
self.bitmap.fill_rect(bar_border, Bar_Config::BLACK)
self.bitmap.fill_rect(bar, get_color)
end
#--------------------------------------------------------------------------
# * Determine the appropriate color based on battler's health
#--------------------------------------------------------------------------
def get_color
# Variables
full = @battler.maxhp
half = @battler.maxhp / 1.4
quarter = @battler.maxhp / 4
# Change bar color depending on amount HP
case @battler.hp
when full
color = Bar_Config::GREEN # Green when full
when half...full
color = Bar_Config::YELLOW # Yellow when above half
when quarter...half
color = Bar_Config::ORANGE # Orange when below half
when 0...quarter
color = Bar_Config::RED # Red when below quarter
end
# Return the appropriate color
return color
end
#--------------------------------------------------------------------------
# * Process when battler receives damage
#--------------------------------------------------------------------------
def damage_dealing(damages)
# Don't do process if damage is a String "Miss"
unless damages.is_a?(String)
# Add new damage to accumulitive damages
@accu_damages += damages
# Counter will be how many times the bars will be refreshed
# for the 'fill' effect.
@counter = Bar_Config::CURRENT_SPEED
# Rate is how many points will be altered for every refresh
@rate = @accu_damages / @counter
end
end
#--------------------------------------------------------------------------
# * Refresh Method
#--------------------------------------------------------------------------
def refresh
# Do only while @battler is not equal to nothing
unless @battler == nil
# Do only if @counter isn't equal to 0
unless @counter == 0
# Minus variables by rate amount of rate
@accu_damages -= @rate
@battler_hp -= @rate
# Check for healing over the bar amount. If so, fix amount
if @battler_hp > @battler.maxhp
@battler_hp = @battler.maxhp
end
end
# Call method to draw bars
draw_bars
end
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
unless self.bitmap == nil
self.bitmap.dispose
end
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# Clear if Battler is nil
if @battler.nil?
self.bitmap.clear unless self.bitmap.nil?
return
end
# If @counter is greater than zero, decrement @counter and refresh bars
if @counter > 0
# If counter is on last iteration
if @counter == 1
# Adjust variables in case of floating point number in-accuracy
@battler_hp = @battler.hp
@accu_damages = 0
end
@counter -= 1
refresh
end
end
end
#==============================================================================
# ** Sprite_SP_Bar
#------------------------------------------------------------------------------
# This sprite is used to display the SP Bar for the battler. It inherits form
# RPG::Sprite.
#==============================================================================
class Sprite_SP_Bar < RPG::Sprite
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :battler
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(viewport, battler)
super(viewport)
# Assign battler and variables used in drawing bar
@battler = battler
@battler_sp = 0
@accu_magic = 0
@counter = 0
# Only call setup method if @battler is not equal to nothing
if @battler != nil
setup
end
end
#--------------------------------------------------------------------------
# * Setup: this prepares the bitmap
#--------------------------------------------------------------------------
def setup
@battler_sp = @battler.sp
self.bitmap = Bitmap.new(Bar_Config::LENGTH + 2, 9)
# Determine if bar is visible for Actor or Enemy
if @battler.is_a?(Game_Enemy)
self.visible = Bar_Config::ENEMY_SP_USED
elsif @battler.is_a?(Game_Actor)
self.visible = Bar_Config::ACTOR_SP_USED
end
# Set bar placement
self.x = @battler.screen_x
self.y = @battler.screen_y + self.bitmap.height + 5
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height
# Call method to draw bars
draw_bars
update
end
#--------------------------------------------------------------------------
# * Method that draws the bars
#--------------------------------------------------------------------------
def draw_bars
if @battler_sp > 0
# Clear previous bars if any
self.bitmap.clear
# Use formula to get length ratio to SP
length = Bar_Config::LENGTH * @battler_sp / @battler.maxsp
# Specify bar & border
bar_border = Rect.new(0, 0, Bar_Config::LENGTH + 2, Bar_Config::WIDTH)
bar = Rect.new(1, 1, length, Bar_Config::WIDTH - 2)
# Draw the bar with border
self.bitmap.fill_rect(bar_border, Bar_Config::BLACK)
self.bitmap.fill_rect(bar, get_color)
end
end
#--------------------------------------------------------------------------
# * Determine the appropriate color based on battler's SP
#--------------------------------------------------------------------------
def get_color
# Variables
full = @battler.maxsp
half = @battler.maxsp / 2
quarter = @battler.maxsp / 4
# Change bar color depending on amount SP
case @battler.sp
when full
color = Bar_Config::INDIGO # Green when full
when half...full
color = Bar_Config::INDIGO # Indigo when above half
when quarter...half
color = Bar_Config::BLUE # Violet when below half
when 0...quarter
color = Bar_Config::VIOLET # Red when below quarter
end
# Return the appropriate color
return color
end
#--------------------------------------------------------------------------
# * Process when battler uses skills
#--------------------------------------------------------------------------
def skill_use(magic_used)
# Add new magic_used to accumulitive magic_used
@accu_magic += magic_used
# Counter will be how many times the bars will be refreshed
# for the 'fill' effect.
@counter = Bar_Config::CURRENT_SPEED
# Rate is how many points will be altered for every refresh
@rate = @accu_magic / @counter
end
#--------------------------------------------------------------------------
# * Refresh Method
#--------------------------------------------------------------------------
def refresh
# Do only while @battler is not equal to nothing
unless @battler == nil
# Do only if @counter isn't equal to 0
unless @counter == 0
# Minus variables by rate amount of rate
@accu_magic -= @rate
@battler_sp -= @rate
# Check for recovering SP over the bar amount. If so, fix amount
if @battler_sp > @battler.maxsp
@battler_sp = @battler.maxsp
end
end
# Call method to draw bars
draw_bars
end
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
unless self.bitmap == nil
self.bitmap.dispose
end
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# Clear if Battler is nil
if @battler.nil?
self.bitmap.clear unless self.bitmap.nil?
return
end
# If @counter is greater than zero, decrement @counter and refresh bars
if @counter > 0
# If counter is on last iteration
if @counter == 1
# Adjust variables in case of floating point number in-accuracy
@battler_sp = @battler.sp
@accu_magic = 0
end
@counter -= 1
refresh
end
end
end
#==============================================================================
# ** Sprite_Battler
#==============================================================================
class Sprite_Battler
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias_method :bar_initialize_init, :initialize
alias_method :bar_dispose_dispose, :dispose
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(viewport, battler = nil)
# Original Initialization
bar_initialize_init(viewport, battler)
# Create bar sprites
@hp_bar = Sprite_HP_Bar.new(viewport, @battler)
@sp_bar = Sprite_SP_Bar.new(viewport, @battler)
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
# Original Method
bar_dispose_dispose
# Dispose Battler Bars
@hp_bar.dispose
@sp_bar.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# If the HP bar sprite doesn't have a battler, assign one to it
if @battler != nil && @hp_bar.battler == nil
@hp_bar.battler = @battler
@hp_bar.setup
end
# If the SP bar sprite doesn't have a battler, assign one to it
if @battler != nil && @sp_bar.battler == nil
@sp_bar.battler = @battler
@sp_bar.setup
end
# If battler is changed, notify the bar sprites
if @battler != @hp_bar.battler
@hp_bar.battler = @battler
@sp_bar.battler = @battler
@hp_bar.setup
@sp_bar.setup
end
@hp_bar.update
@sp_bar.update
# If battler is nil
if @battler == nil
self.bitmap = nil
loop_animation(nil)
return
end
# If file name or hue are different than current ones
if @battler.battler_name != @battler_name or
@battler.battler_hue != @battler_hue
# Get and set bitmap
@battler_name = @battler.battler_name
@battler_hue = @battler.battler_hue
self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @width / 2
self.oy = @height
# Change opacity level to 0 when dead or hidden
if @battler.dead? or @battler.hidden
self.opacity = 0
end
end
# If animation ID is different than current one
if @battler.damage == nil and
@battler.state_animation_id != @state_animation_id
@state_animation_id = @battler.state_animation_id
loop_animation($data_animations[@state_animation_id])
end
# If actor which should be displayed
if @battler.is_a?(Game_Actor) and @battler_visible
# Bring opacity level down a bit when not in main phase
if $game_temp.battle_main_phase
self.opacity += 3 if self.opacity < 255
else
self.opacity -= 3 if self.opacity > 207
end
end
# Blink
if @battler.blink
blink_on
else
blink_off
end
# If invisible
unless @battler_visible
# Appear
if not @battler.hidden and not @battler.dead? and
(@battler.damage == nil or @battler.damage_pop)
appear
@hp_bar.appear
@battler_visible = true
end
end
# If visible
if @battler_visible
# Escape
if @battler.hidden
$game_system.se_play($data_system.escape_se)
escape
@battler_visible = false
end
# White flash
if @battler.white_flash
whiten
@battler.white_flash = false
end
# Animation
if @battler.animation_id != 0
animation = $data_animations[@battler.animation_id]
#@hp_bar.duration = animation.frame_max
animation(animation, @battler.animation_hit)
@battler.animation_id = 0
end
# Damage
if @battler.damage_pop
damage(@battler.damage, @battler.critical)
@hp_bar.damage_dealing(@battler.damage)
@battler.damage = nil
@battler.critical = false
@battler.damage_pop = false
end
# Using Skill
if @battler.magic_casting
@sp_bar.skill_use(@battler.sp_used)
@battler.sp_used = nil
@battler.magic_casting = false
end
# Collapse
if @battler.damage == nil and @battler.dead?
if @battler.is_a?(Game_Enemy)
$game_system.se_play($data_system.enemy_collapse_se)
else
$game_system.se_play($data_system.actor_collapse_se)
end
collapse
@hp_bar.battler = nil
@hp_bar.collapse
@sp_bar.collapse
@battler_visible = false
end
end
# Set sprite coordinates
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
end
end
#==============================================================================
# ** Game_Battler
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :magic_casting # sp bar update flag
attr_accessor :sp_used # skill points used
#--------------------------------------------------------------------------
# * Alias
#--------------------------------------------------------------------------
alias bar_initialize_init initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Added variables
@magic_casting = false
@sp_used = nil
# Original method execution
bar_initialize_init
end
end
#==============================================================================
# ** Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Make Skill Action Results
#--------------------------------------------------------------------------
def make_skill_action_result
# Get skill
@skill = $data_skills[@active_battler.current_action.skill_id]
# If not a forcing action
unless @active_battler.current_action.forcing
# If unable to use due to SP running out
unless @active_battler.skill_can_use?(@skill.id)
# Clear battler being forced into action
$game_temp.forcing_battler = nil
# Shift to step 1
@phase4_step = 1
return
end
end
# Use up SP
@active_battler.sp -= @skill.sp_cost
# Set amount used for use with sp bar
@active_battler.sp_used = @skill.sp_cost
# Refresh status window
@status_window.refresh
# Show skill name on help window
@help_window.set_text(@skill.name, 1)
# Set animation ID
@animation1_id = @skill.animation1_id
@animation2_id = @skill.animation2_id
# Set command event ID
@common_event_id = @skill.common_event_id
# Set target battlers
set_target_battlers(@skill.scope)
# Apply skill effect
for target in @target_battlers
target.skill_effect(@active_battler, @skill)
end
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 3 : animation for action performer)
#--------------------------------------------------------------------------
def update_phase4_step3
# Animation for action performer (if ID is 0, then white flash)
if @animation1_id == 0
@active_battler.white_flash = true
else
@active_battler.animation_id = @animation1_id
@active_battler.animation_hit = true
end
# Set flag to update sp bar sprite
if @active_battler.sp_used != nil
@active_battler.magic_casting = true
end
# Shift to step 4
@phase4_step = 4
end
end
RE: That nasty SP bar - DerVVulfman - 05-11-2016
Dang, I hate nasty formatting of this nasty SP bar code. Nasty!!!!
Oh, and there's a line he commented out (line 542) that he just didn't need anyway (nasty and sloppy!!!).
BUT... here's a fix. Paste it below the script!
Code: #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# DerVV's Enemy/Actor HP / SP Bars Fix
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# By: DerVVulfman (a fix for El Conducter's script v 4.0)
# Written May 10, 2016
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Put below his script and it should allow SP healing and damage now!!!
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Frame Update (main phase step 2 : start action)
#--------------------------------------------------------------------------
alias elconducter_set_sp_fix set_target_battlers
#--------------------------------------------------------------------------
# * Set Targeted Battler for Skill or Item
# scope : effect scope for skill or item
#--------------------------------------------------------------------------
def set_target_battlers(scope)
# The original call to get the scopes
scopers = elconducter_set_sp_fix(scope)
# Now creat an empty area to store SP values
@battler_sp_dmg = []
# And cycle through all the determined battlers to get 'em
for target in @target_battlers
@battler_sp_dmg.push(target.sp)
end
return scopers
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 5 : damage display)
#--------------------------------------------------------------------------
def update_phase4_step5
# Hide help window
@help_window.visible = false
# Refresh status window
@status_window.refresh
# Display damage
for target in @target_battlers
if target.damage != nil
target.damage_pop = true
end
end
counter = 0
# Display damage
for target in @target_battlers
old_sp = @battler_sp_dmg[counter]
if old_sp != target.sp
target.sp_used = old_sp - target.sp
target.magic_casting = true
end
counter += 1
end
# Shift to step 6
@phase4_step = 6
end
end
RE: That nasty SP bar - Mel - 05-11-2016
Thank you alot! :)
I just get this nasty error now:
Oh, and I think it was me who commented out that line, because it caused another error.^^
RE: That nasty SP bar - DerVVulfman - 05-12-2016
That line is old_sp = @battler_sp_dmg[counter]
Now, the value of 'counter' is defaulted immediately to the value of '0', so it's not that. So it would have to be the @battler_sp_dmg array, which was defined and repeatedly reset in the set_target_battlers method just before it goes through all your targets to get their SP values.
That makes me curious if you have something that is preventing the @battler_sp_dmg array from getting the target(s) SP values.
A little bit more info may be needed... What happened in battle... what battlesystem if any... what is the air speed velocity of a pair of canaries carrying a coconut between them...?
RE: That nasty SP bar - Mel - 05-12-2016
The error also appears in a clean project without any other custom scripts.
I'm just starting a normal battle against the ghosts and try to attack them. With the normal attack command. Not using a skill.
Then the game crashes.
Edit: I just found out that the error won't appear if any actor or enemy has used a skill once. It only crashes if nobody use a skill/consume SP in the battle.
RE: That nasty SP bar - DerVVulfman - 05-12-2016
SERIOUSLY!!!! REALLY!!!! WHAT THE **********Sigh**********!
Just had to add one line right before that sucker just to see if the array was nil... and thus version 1.1 is borne.
Code: #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# DerVV's Enemy/Actor HP / SP Bars Fix v 1.1
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# By: DerVVulfman (a fix for El Conducter's script v 4.0)
# Written May 11, 2016
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Put below his script and it should allow SP healing and damage now!!!
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Frame Update (main phase step 2 : start action)
#--------------------------------------------------------------------------
alias elconducter_set_sp_fix set_target_battlers
#--------------------------------------------------------------------------
# * Set Targeted Battler for Skill or Item
# scope : effect scope for skill or item
#--------------------------------------------------------------------------
def set_target_battlers(scope)
# The original call to get the scopes
scopers = elconducter_set_sp_fix(scope)
# Now creat an empty area to store SP values
@battler_sp_dmg = []
# And cycle through all the determined battlers to get 'em
for target in @target_battlers
@battler_sp_dmg.push(target.sp)
end
return scopers
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 5 : damage display)
#--------------------------------------------------------------------------
def update_phase4_step5
# Hide help window
@help_window.visible = false
# Refresh status window
@status_window.refresh
# Display damage
for target in @target_battlers
if target.damage != nil
target.damage_pop = true
end
end
counter = 0
# Display damage
for target in @target_battlers
next if @battler_sp_dmg.nil?
old_sp = @battler_sp_dmg[counter]
if old_sp != target.sp
target.sp_used = old_sp - target.sp
target.magic_casting = true
end
counter += 1
end
# Shift to step 6
@phase4_step = 6
end
end
RE: That nasty SP bar - Mel - 05-12-2016
Okay it works. :)
But now that nasty bar is doing some weird stuff when an actor takes damage. It's moving forward or backward while losing HP and then it jumps back to the right position.^^
RE: That nasty SP bar - DerVVulfman - 05-12-2016
Aaaaand, another stupid value to be added......
Basically the target.magic_casting had to be turned off before each check .
Code: #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# DerVV's Enemy/Actor HP / SP Bars Fix v 1.2
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# By: DerVVulfman (a fix for El Conducter's script v 4.0)
# Written May 11, 2016
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Put below his script and it should allow SP healing and damage now!!!
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Frame Update (main phase step 2 : start action)
#--------------------------------------------------------------------------
alias elconducter_set_sp_fix set_target_battlers
#--------------------------------------------------------------------------
# * Set Targeted Battler for Skill or Item
# scope : effect scope for skill or item
#--------------------------------------------------------------------------
def set_target_battlers(scope)
# The original call to get the scopes
scopers = elconducter_set_sp_fix(scope)
# Now creat an empty area to store SP values
@battler_sp_dmg = []
# And cycle through all the determined battlers to get 'em
for target in @target_battlers
@battler_sp_dmg.push(target.sp)
end
return scopers
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 5 : damage display)
#--------------------------------------------------------------------------
def update_phase4_step5
# Hide help window
@help_window.visible = false
# Refresh status window
@status_window.refresh
# Display damage
for target in @target_battlers
if target.damage != nil
target.damage_pop = true
end
end
counter = 0
# Display damage
for target in @target_battlers
target.magic_casting = false
next if @battler_sp_dmg.nil?
old_sp = @battler_sp_dmg[counter]
if old_sp != target.sp
target.sp_used = old_sp - target.sp
target.magic_casting = true
end
counter += 1
end
# Shift to step 6
@phase4_step = 6
end
end
RE: That nasty SP bar - Mel - 05-12-2016
The fight is not over.^^
It still happens when someone has used a skill.
RE: That nasty SP bar - DerVVulfman - 05-12-2016
*sigh* More specifically, it happens when a target who used a skill is attacked by a melee attack. My system that grabs the SP points for comparison is done within the scopes method.... unfortunately a method used only by items and skills. It didn't erase the values when the player is stuck by a melee attack, and I had to force a calculation re-do.
Code: #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# DerVV's Enemy/Actor HP / SP Bars Fix v 1.3
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# By: DerVVulfman (a fix for El Conducter's script v 4.0)
# Written May 11, 2016
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Put below his script and it should allow SP healing and damage now!!!
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Frame Update (main phase step 2 : start action)
#--------------------------------------------------------------------------
alias elconducter_set_sp_fix1 set_target_battlers
alias elconducter_set_sp_fix2 update_phase4_step3
#--------------------------------------------------------------------------
# * Set Targeted Battler for Skill or Item
# scope : effect scope for skill or item
#--------------------------------------------------------------------------
def set_target_battlers(scope)
# The original call to get the scopes
scopers = elconducter_set_sp_fix1(scope)
# Now creat an empty area to store SP values
@battler_sp_dmg = []
# And cycle through all the determined battlers to get 'em
for target in @target_battlers
@battler_sp_dmg.push(target.sp)
end
return scopers
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 3 : animation for action performer)
#--------------------------------------------------------------------------
def update_phase4_step3
@battler_sp_dmg = []
for target in @target_battlers
@battler_sp_dmg.push(target.sp)
target.magic_casting = false
end
elconducter_set_sp_fix2
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 5 : damage display)
#--------------------------------------------------------------------------
def update_phase4_step5
# Hide help window
@help_window.visible = false
# Refresh status window
@status_window.refresh
# Display damage
for target in @target_battlers
if target.damage != nil
target.damage_pop = true
end
end
counter = 0
# Display damage
for target in @target_battlers
target.magic_casting = false
next if @battler_sp_dmg.nil?
old_sp = @battler_sp_dmg[counter]
if old_sp != target.sp
target.sp_used = old_sp - target.sp
target.magic_casting = true
end
counter += 1
end
# Shift to step 6
@phase4_step = 6
end
end
|