*added code tags*
Look at the refresh method inside the Window_EnemyHP class. Anyone with half a brain should know what
draw_actor_hp does. But what about the values in it?
@enemy refers to the enemy object you would like to extract the HP from
0 is the x-coordinate to start the drawing, which should be on the far left of the window
i*45 + 50 is the y-coordinate to start the drawing, assuming a value of 0 would be at the very top of the window. The use of i allows you to space out the different enemies' HP values, as you could probably see in-game.
You can learn the origin of this method by looking at the Window_Base class in the default RMXP scripts:
#--------------------------------------------------------------------------
# * Draw HP
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : draw spot width
#--------------------------------------------------------------------------
def draw_actor_hp(actor, x, y, width = 144)
# Draw "HP" text string
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
# Calculate if there is draw space for MaxHP
if width - 32 >= 108
hp_x = x + width - 108
flag = true
elsif width - 32 >= 48
hp_x = x + width - 48
flag = false
end
# Draw HP
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
# Draw MaxHP
if flag
self.contents.font.color = normal_color
self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
end
end
Scroll down more and you will come across two more methods: draw_actor_sp and draw_actor_parameter. These are the things you want to use. All you have to do is just add these method calls directly below your draw_actor_hp in your script.
def refresh
self.contents.clear
for i in 0...$game_troop.enemies.size
@enemy = $game_troop.enemies[i]
@old_hp[i] = @enemy.hp
unless @enemy.hp == 0
self.contents.font.size = 15
self.contents.font.bold = true
self.contents.font.color = Color.new(0,0,0)
self.contents.font.color = normal_color
self.contents.draw_text(0, i * 45 + 37, 100, 32, @enemy.name)
draw_actor_hp(@enemy, 0, i*45 + 50)
# ADD THEM HERE #####################
draw_actor_sp(@enemy, 80, i*45 + 50)
draw_actor_parameter(@enemy, 160, i*45 + 50, 0) # Draws enemy ATK stat
draw_actor_parameter(@enemy, 240, i*45 + 50, 1) # Draws enemy PDEF stat
# and so on and so forth...
end
end
end
The only thing that remains for you to do is adjust the x-/y-coordinates of where to draw the stats that is most meaningful to you (since this is just to debug/test your eventing).
Also, if you want the changes to update as soon as any stat changes (because right now, it's set to only update if the enemy's HP changes)
class Window_EnemyHP < Window_Base
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
@old_enemy = []
refresh
end
def refresh
self.contents.clear
for i in 0...$game_troop.enemies.size
@enemy = $game_troop.enemies[i]
@old_enemy[i] = @enemy.clone
unless @enemy.hp == 0
self.contents.font.size = 15
self.contents.font.bold = true
self.contents.font.color = Color.new(0,0,0)
self.contents.font.color = normal_color
self.contents.draw_text(0, i * 45 + 37, 100, 32, @enemy.name)
draw_actor_hp(@enemy, 0, i*45 + 50)
# ADD THEM HERE #####################
draw_actor_sp(@enemy, 80, i*45 + 50)
draw_actor_parameter(@enemy, 160, i*45 + 50, 0) # Draws enemy ATK stat
draw_actor_parameter(@enemy, 240, i*45 + 50, 1) # Draws enemy PDEF stat
# and so on and so forth...
end
end
end
def update
for i in 0...$game_troop.enemies.size
enemy = $game_troop.enemies[i]
if enemy.hp != @old_enemy[i].hp || enemy.sp != @old_enemy[i].sp || enemy.atk != @old_enemy[i].atk || enemy.pdef != @old_enemy[i].pdef ||
enemy.mdef != @old_enemy[i].mdef || enemy.str != @old_enemy[i].str || enemy.dex != @old_enemy[i].dex || enemy.int != @old_enemy[i].int || enemy.agi != @old_enemy[i].agi
refresh
end
end
end
end