I'm using RTAB and Animated battlers with a display script from a demo I DLed from here.
Messing around I'm getting it to show enemy ATB/CT/HP gauges as well....
However, I can only get the final enemy's to show once the battle starts. At the beginning of the battle, when the 'initialize' of my script is run, i get all 3 gauges, but once the refresh starts, only the last enemy in the troop's bar/gauge will be displayed/updated/refreshed.
Sorry about the messiness... I'm still new to coding. There are also other glaring errors with other parts of the script, but I know how to fix those once I can get all enemies' info to be displayed instead of just one.
Thanks a bundle!
-K
Messing around I'm getting it to show enemy ATB/CT/HP gauges as well....
However, I can only get the final enemy's to show once the battle starts. At the beginning of the battle, when the 'initialize' of my script is run, i get all 3 gauges, but once the refresh starts, only the last enemy in the troop's bar/gauge will be displayed/updated/refreshed.
Code:
class Window_BattleStatus < Window_Base
#--------------------------------------------------------------------------
# â— Initialize
#--------------------------------------------------------------------------
def initialize
super(0, 320, 480, 162)
self.opacity = 0
@ewindows = []
@windows = []
@faces = []
@bullets = []
@ubullets = []
@combohits = []
@coin = []
@boosting = []
@boostcounter = []
@troopsize = []
viewport = Viewport.new(3, 320, 640, 162)
boostview = Viewport.new (490, 291, 150, 27)
viewport.z = 101
boostview.z = 105
@troopsize = $game_troop.enemies.size #used for disposing EnemyStatus Windows
for i in 0...$game_party.actors.size
y = i * 54 + 1 # (4 - $game_party.actors.size) #- 15 #* 60
@windows[i] = Window_ActorStatus.new(i, i * 54 + 318)
@faces[i] = Sprite.new(viewport)
@faces[i].bitmap = RPG::Cache.picture("Face" + $game_party.actors[i].id.to_s + ".png")
@faces[i].y = y
@faces[i].opacity = 250
end
for i in 0...$game_troop.enemies.size
@enemy = $game_troop.enemies[i]
@ewindows[i] = Window_EnemyStatus.new(@enemy, id, 0, 0)
print @enemy.index
viewportz = Viewport.new(0, 0, 600, 600)
viewportz.z = @enemy.screen_z
y = @enemy.screen_y - 26
x = @enemy.screen_x - 60
z = @enemy.screen_z - 100
#@enemyhp[i] = Sprite.new(viewportz)
@combohits[i] = Sprite.new(viewportz)
@coin[i] = Sprite.new(viewportz)
end
@boosting = Sprite.new(boostview)
@boostcounter = Sprite.new(boostview)
@boostcounter.x = 131
@boostcounter.y = 6
@level_up_flags = [false, false, false, false]
refresh
end
#--------------------------------------------------------------------------
# â— Update
#--------------------------------------------------------------------------
def update
super
for window in @windows
window.update
end
for window in @ewindows
window.update
end
end
#--------------------------------------------------------------------------
# â— Dispose
#--------------------------------------------------------------------------
def dispose
#super
for i in 0...$game_party.actors.size
@windows[i].dispose
@faces[i].dispose
end
@boosting.dispose
@boostcounter.dispose
for i in 0...@troopsize
@ewindows[i].dispose
end
super
end
#--------------------------------------------------------------------------
# â— Refresh
#--------------------------------------------------------------------------
def refresh(number = 0)
@boosting.bitmap = RPG::Cache.picture("boost" + $game_variables[103].to_s + ".png")
if $game_variables[104] < 10
@boostcounter.bitmap = RPG::Cache.picture("boostcount" + $game_variables[104].to_s + ".png")
end
for i in 0...$game_troop.enemies.size
@enemy = $game_troop.enemies[i]
y = @enemy.screen_y - 26
x = @enemy.screen_x - 60
z = @enemy.screen_z - 100
if @enemy.exist?
#enemy = @enemy
#draw_enemy_atg(enemy, 0, 0, 100)
if @enemy.coin < 10
@coin[i].bitmap = RPG::Cache.picture("coin" + @enemy.coin.to_s + ".png")
@coin[i].x = x + 45
@coin[i].y = y + 10
@coin[i].z = z
@coin[i].opacity = 255
end
if @enemy.combo < 10
@combohits[i].bitmap = RPG::Cache.picture("combohit" + @enemy.combo.to_s + ".png")
@combohits[i].x = x
@combohits[i].y = y
@combohits[i].z = z
@combohits[i].opacity = 255
end
else
@combohits[i].dispose
@coin[i].dispose
end
end
if number == 0
for window in @ewindows
window.refresh(enemy, id, x, y)
end
count = 0
for window in @windows
window.refresh(@level_up_flags[count])
count += 1
end
else
@windows[number - 1].refresh(@level_up_flags[number - 1])
end
#if number == 0
# count = 0
# for window in @ewindows
# window.refresh(@enemy, id, x, y)
# count += 1
# end
#else
# @ewindows[number + 1].refresh(@enemy[number - 1], id, x, y)
#end
end
#--------------------------------------------------------------------------
# â— AT Refresh
#--------------------------------------------------------------------------
def at_refresh(number = 0)
if number == 0
for window in @windows
window.at_refresh
end
else
@windows[number - 1].at_refresh
end
if number == 0
for window in @ewindows
window.refresh(@enemy, id, x, y) #(enemy, id, x, y)
end
else
@ewindows[number - 1].at_refresh
end
if number == 0
for window in @ewindows
window.at_refresh
end
else
@ewindows[number - 1].at_refresh
end
end
end
#==============================================================================
# â– Window_ActorStatus
#==============================================================================
class Window_ActorStatus < Window_Base
#--------------------------------------------------------------------------
# â— Initialize
#--------------------------------------------------------------------------
#def initialize(id, x)
# @id = id
# super(x, 320, 160, 160)
# self.contents = Bitmap.new(width - 32, height - 32)
# self.back_opacity = 255
# actor = $game_party.actors[@id]
# @name = actor.name
# @maxhp = actor.maxhp
# @maxsp = actor.maxsp
# @hp = actor.hp
# @sp = actor.sp
# @state = make_battler_state_text(actor, 120, true)
# @windows = []
# for i in 0...5
# @windows.push(Window_DetailsStatus.new(actor, i, x))
# end
# refresh(false)
#end
def initialize(id, y)
@id = id
super(0, y, 480, 54)
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 255
actor = $game_party.actors[@id]
@name = actor.name
@maxhp = actor.maxhp
@maxsp = actor.maxsp
@hp = actor.hp
@sp = actor.sp
@state = make_battler_state_text(actor, 120, true)
@windows = []
for i in 0...5
@windows.push(Window_DetailsStatus.new(actor, i, x, y))
end
refresh(false)
end
#--------------------------------------------------------------------------
# â— Update
#--------------------------------------------------------------------------
def update
for window in @windows
window.update
end
end
#--------------------------------------------------------------------------
# â— Dispose
#--------------------------------------------------------------------------
def dispose
for window in @windows
window.dispose
end
super
end
#--------------------------------------------------------------------------
# â— Refresh
#--------------------------------------------------------------------------
def refresh(level_up_flags)
self.contents.clear
actor = $game_party.actors[@id]
#enemy = $game_troop.enemies[@id]
@windows[0].refresh(actor) if @name != actor.name
@windows[1].refresh(actor) if @maxhp != actor.maxhp or @hp != actor.hp
@windows[2].refresh(actor) if @maxsp != actor.maxsp or @sp != actor.sp
@windows[3].refresh(actor, level_up_flags) if
(@state != make_battler_state_text(actor, 120, true) or level_up_flags)
@name = actor.name
@maxhp = actor.maxhp
@maxsp = actor.maxsp
@hp = actor.hp
@sp = actor.sp
actor.bounty = actor.bounty
@state = make_battler_state_text(actor, 120, true)
end
#--------------------------------------------------------------------------
# â— AT Refresh
#--------------------------------------------------------------------------
def at_refresh
@windows[4].refresh($game_party.actors[@id])
end
end
#==============================================================================
# â– Window_DetailsStatus
#==============================================================================
class Window_DetailsStatus < Window_Base
#--------------------------------------------------------------------------
# â— Initialize
#--------------------------------------------------------------------------
#def initialize(actor, id, x)
# @status_id = id
# super(x, 320 + id * 26, 160, 64)
# self.contents = Bitmap.new(width - 32, height - 32)
# #self.contents.font.name = $fontface
# #self.contents.font.size = $fontsize
# self.opacity = 0
# self.back_opacity = 0
# refresh(actor, false)
#end
def initialize(actor, id, x, y)
@status_id = id
super(x - 20, y - 17, 500, 90) #individual window viewport/bitmap (dunno the real name)
self.contents = Bitmap.new(width - 32, height - 32)
#self.contents.font.name = $fontface
#self.contents.font.size = $fontsize
self.opacity = 0
self.back_opacity = 0
refresh(actor, false)
end
#--------------------------------------------------------------------------
# â— Refresh
#--------------------------------------------------------------------------
def refresh(actor, level_up_flags = false)
self.contents.clear
#enemy = []
#for i in 0...$game_troop.enemies.size
# enemy = $game_troop.enemies[i]
#x = enemy.screen_x
#y = enemy.screen_y
#print enemy.name.to_s
# end
#y = @enemy.screen_y - 26
#x = @enemy.screen_x - 60
#for i in 0...$data_actors[3].parameters[1,1]
# @ubullets[i].dispose
#end
#for i in 0...$game_actors[3].sp
# @bullets[i].dispose
#end
case @status_id
when 0
draw_actor_name(actor, 9, -1)
when 1
self.contents.font.size = 34
#self.contents.font.bold = true
draw_actor_hp(actor, 180, 5, 100)
when 2
if actor.id == 1
draw_actor_sp(actor, 320, 19, 145)
end
if actor.id == 2
armorz = $data_actors[actor.id].armor3_id
self.contents.font.color = normal_color
self.contents.font.size = 21
self.contents.draw_text(320, 20, 220, 18, $data_armors[armorz].name)
end
if actor.id == 3
@ubullets = []
@bullets = []
viewport = Viewport.new(3, 302, 640, 180)
viewport.z = 101
if $game_actors[3].exist?
for i in 0...$data_actors[3].parameters[1,1]
y = actor.index * 54 + 29
@ubullets[i] = Sprite.new(viewport)
@ubullets[i].bitmap = RPG::Cache.picture("ubullet.png")
@ubullets[i].x = i * 20 + 300
@ubullets[i].y = y
@ubullets[i].z = 9999
@ubullets[i].opacity = 255
end
for i in 0...$game_actors[3].sp
@bullets[i] = Sprite.new(viewport)
@bullets[i].bitmap = RPG::Cache.picture("sbullet.png")
@bullets[i].x = i * 20 + 300
@bullets[i].y = y
@bullets[i].z = 10000
@bullets[i].opacity = 255
end
else
@ubullets[i].dispose
@bullets[i].dispose
end
end
if actor.id == 4
#$game_actors[4].bounty = 100000
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 21
self.contents.draw_text(309, 3, 220, 20, "$$:" + $game_actors[4].bounty.to_s)
self.contents.font.size = 24
self.contents.draw_text(309, 23, 220, 20, "Coin:")
@coins = []
viewport = Viewport.new(3, 302, 640, 180)
viewport.z = 101
for i in 0...$game_actors[4].sp
y = actor.index * 54 + 29
@coins[i] = Sprite.new(viewport)
@coins[i].bitmap = RPG::Cache.picture("coin.png")
@coins[i].x = i * 10 + 370
@coins[i].y = y + 12
@coins[i].z = 9999
@coins[i].opacity = 255
end
end
when 3
if level_up_flags
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120, 32, "LEVEL UP!")
else
#draw_actor_state(actor, 4, 0)
end
when 4
draw_actor_atg(actor, 170, 24, 120)
#for i in 0...$game_troop.enemies.size
# enemy = $game_troop.enemies[i]
# draw_enemy_atg(enemy, 0, -14 + i * 11, 100)
#end
#enemy = $game_troop.enemies[1]
#draw_enemy_atg(enemy, 0, 0, 100)
#enemy = []
#for i in 0...$game_troop.enemies.size
# enemy = $game_troop.enemies[i]
# draw_enemy_atg(enemy, 0, 0, 100)
#end
=begin
@enemyhp = []
for i in 0...$game_troop.enemies.size
@enemy = $game_troop.enemies[i]
viewportz = Viewport.new(0, 0, 600, 600)
viewportz.z = @enemy.screen_z
y = @enemy.screen_y - 26
x = @enemy.screen_x - 60
z = @enemy.screen_z - 100
@enemyhp[i] = Sprite.new(viewportz)
if @enemy.exist?
@enemyhp[i].bitmap = Bitmap.new(100, 100)
@enemyhp[i].x = x
@enemyhp[i].y = y
@enemyhp[i].z = z
@enemyhp[i].opacity = 255
@enemyhp[i].bitmap.draw_text(0, 0, 220, 18, @enemy.at.to_s)
end
end
=end
end
end
end
#==============================================================================
# â– Window_Base
#==============================================================================
class Window_Base
#--------------------------------------------------------------------------
# â— Draw Actor HP Meter
#--------------------------------------------------------------------------
#alias cbs_draw_actor_hp draw_actor_hp
#def draw_actor_hp(actor, x, y, width = 146, height = 5)
# bg = Color.new( 0, 0, 0, 160)
# c1 = Color.new(175, 0, 0, 160)
# c2 = Color.new(255, 0, 0, 255)
# self.contents.fill_rect(x, y, width, height, bg)
# width2 = width * actor.hp / actor.maxhp
# gradient(x + 1, y + 1, width2 - 2, height - 2, c1, c2)
# cbs_draw_actor_hp(actor, x, y, width)
#end
#--------------------------------------------------------------------------
# â— Draw Actor SP Meter
#--------------------------------------------------------------------------
alias cbs_draw_actor_sp draw_actor_sp
def draw_actor_sp(actor, x, y, width = 146, height = 15)
bg = Color.new( 0, 0, 0, 160)
c1 = Color.new( 0, 174, 225, 255)
c2 = Color.new( 255, 255, 255, 255)
self.contents.fill_rect(x, y, width, height, bg)
width2 = width * actor.sp / actor.maxsp
gradient(x + 1, y + 1, width2 - 2, height - 2, c1, c2)
cbs_draw_actor_sp(actor, x, y, width)
end
#--------------------------------------------------------------------------
# â— Draw Gradient
#--------------------------------------------------------------------------
def gradient(x, y, width, height, c1, c2)
for i in 1..width
x2 = x + i - 1
r = c1.red * (width - i) / width + c2.red * i / width
g = c1.green * (width - i) / width + c2.green * i / width
b = c1.blue * (width - i) / width + c2.blue * i / width
a = c1.alpha * (width - i) / width + c2.alpha * i / width
self.contents.fill_rect(x2, y, 1, height, Color.new(r, g, b, a))
end
end
#--------------------------------------------------------------------------
# â— Make State Text
#--------------------------------------------------------------------------
def make_battler_state_text(battler, width, need_normal)
brackets_width = self.contents.text_size("Status: ").width
text = ""
for i in battler.states
if $data_states[i].rating >= 1
if text == ""
text = $data_states[i].name
else
new_text = text + "/" + $data_states[i].name
text_width = self.contents.text_size(new_text).width
if text_width > width - brackets_width
break
end
text = new_text
end
end
end
if text == ""
if need_normal
text = "Status: Normal"
end
else
#text = "Status: " + text + $game_variables[26 + battler.index].to_s
#text = "Combo: " + battler.sp.to_s
text = " [" + text + "]"
end
return text
end
end
Code:
class Window_Base < Window
#--------------------------------------------------------------------------
# * Draw enemy ATG
# enemy : enemy
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : draw spot width
#--------------------------------------------------------------------------
#attr_accessor :enemy
#attr_reader :enemy
def draw_enemy_atg(enemy, x, y, width = 100)
if @at_gauge == nil
# plus_x: revised x-coordinate
# rate_x: revised X-coordinate as (%)
# plus_y: revised y-coordinate
# plus_width: revised width
# rate_width: revised width as (%)
# height: Vertical width
# align1: Type 1 ( 0: left justify 1: center justify 2: right justify )
# align2: Type 2 ( 0: Upper stuffing 1: Central arranging 2:Lower stuffing )
# align3: Gauge type 0:Left justify 1: Right justify
@plus_x = 0
@rate_x = 0
@plus_y = 16
@plus_width = 0
@rate_width = 100
@width = @plus_width + width * @rate_width / 100
@height = 8
@align1 = 0
@align2 = 1
@align3 = 0
# Gradation settings: grade1: Empty gauge grade2:Actual gauge
# (0:On side gradation 1:Vertically gradation 2: Slantedly gradation)
grade1 = 1
grade2 = 0
# Color setting. color1: Outermost framework, color2: Medium framework
# color3: Empty framework dark color, color4: Empty framework light/write color
color1 = Color.new(20, 74, 134)
color2 = Color.new(20, 74, 134)
color3 = Color.new(0, 0, 0, 255)
color4 = Color.new(0, 0, 0, 255)
#color4 = Color.new(0, 0, 64, 192)
# Color setting of gauge
# Usually color setting of the time
color5 = Color.new(196, 223, 155)
color6 = Color.new(255, 255, 255)
# When gauge is MAX, color setting
color7 = Color.new(255, 0, 0)
color8 = Color.new(255, 0, 0)
# Color setting at time of cooperation skill use
color9 = Color.new(80, 64, 32)
color10 = Color.new(240, 192, 96)
# Color setting at time of skill permanent residence
color11 = Color.new(80, 0, 64)
color12 = Color.new(240, 0, 192)
# Drawing of gauge
gauge_rect_at(@width, @height, @align3, color1, color2,
color3, color4, color5, color6, color7, color8,
color9, color10, color11, color12, grade1, grade2)
end
# Variable at substituting the width of the gauge which is drawn
#if enemy.at == 0
at = (width + @plus_width) * enemy.atp * @rate_width / 10000
#else
# at = (width + @plus_width) * enemy.rt * @rate_width / enemy.rtp / 100
#end
if at > width
at = width
end
# Revision such as the left stuffing central posture of gauge
case @align1
when 1
x += (@rect_width - width) / 2
when 2
x += @rect_width - width
end
case @align2
when 1
y -= @height / 2
when 2
y -= @height
end
self.contents.blt(x + @plus_x + width * @rate_x / 100, y + @plus_y,
@at_gauge, Rect.new(0, 0, @width, @height))
if @align3 == 0
rect_x = 0
else
x += @width - at - 1
rect_x = @width - at - 1
end
# Color setting of gauge
if at == width
# Gauge drawing at the time of MAX
self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
@at_gauge, Rect.new(rect_x, @height * 2, at, @height))
else
if enemy.rtp == 0
# Usually gauge drawing of the time
self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
@at_gauge, Rect.new(rect_x, @height, at, @height))
else
if enemy.spell == true
#Gauge drawing at time of cooperation skill use
self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
@at_gauge, Rect.new(rect_x, @height * 3, at, @height))
else
# Gauge drawing at time of skill permanent residence
self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
@at_gauge, Rect.new(rect_x, @height * 4, at, @height))
end
end
end
end
end
class Window_EnemyStatus < Window_Base
#--------------------------------------------------------------------------
# â— Initialize
#--------------------------------------------------------------------------
def initialize(enemy, id, x, y)
#id = id
@ewindows = []
super(0, 0, 640, 480) #individual window viewport/bitmap (dunno the real name)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
self.back_opacity = 0
self.contents.font.color = normal_color
self.contents.font.size = 21
self.contents.draw_text(enemy.screen_x - 45, enemy.screen_y, 220, 18, enemy.name)
draw_enemy_atg(enemy, enemy.screen_x, enemy.screen_y, 100)
#print "initialize 1:" + enemy.index.to_s
refresh(enemy, id, x, y)
#print "initialize 2:" + enemy.index.to_s
end
#--------------------------------------------------------------------------
# â— Refresh
#--------------------------------------------------------------------------
def refresh(enemy, id, x, y)
#print "refresh 1:" + enemy.index.to_s
self.contents.clear
#print "refresh 2:" + enemy.index.to_s
#case @status_id
#when 0
draw_enemy_atg(enemy, enemy.screen_x, enemy.screen_y, 100)
#print "refresh 3:" + enemy.index.to_s
#end
end
def at_refresh(number = 0)
if number == 0
for window in @ewindows
window.at_refresh
end
else
@ewindows[number - 1].at_refresh
print "whoa"
end
end
end
Sorry about the messiness... I'm still new to coding. There are also other glaring errors with other parts of the script, but I know how to fix those once I can get all enemies' info to be displayed instead of just one.
Thanks a bundle!
-K