[RMVX ACE] PUT ICON IN ENEMY NAME? (SOLVED)
Posts
Pages:
1
Hello! ^_^
I wanted to be able to put icons in enemy names in order to show what type of enemy it is, like a ghost icon before specter enemies and an armor icon before heavy armor enemies. I can use...
in message boxes and skill descriptions, but it doesn't work in enemy names.
Is this doable with code?
Thanks a lot! :D
I wanted to be able to put icons in enemy names in order to show what type of enemy it is, like a ghost icon before specter enemies and an armor icon before heavy armor enemies. I can use...
\i[1]
in message boxes and skill descriptions, but it doesn't work in enemy names.
Is this doable with code?
Thanks a lot! :D
Red_Nova
Sir Redd of Novus: He who made Prayer of the Faithless that one time, and that was pretty dang rad! :D
9192
Try this:
=begin Show icons next to battler names ================================================================================ INSTRUCTIONS ================================================================================ - Add [x] in front of each enemy's name. Replace x with the index of the icon you want to use. For example: [1]enemy - !!!!IMPORTANT!!! Don't leave a space after the closing bracket. =end class Game_Enemy < Game_Battler attr_accessor :icon #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(index, enemy_id) super() @index = index @enemy_id = enemy_id enemy = $data_enemies[@enemy_id] @original_name = enemy.name @letter = "" @plural = false @screen_x = 0 @screen_y = 0 @battler_name = enemy.battler_name @battler_hue = enemy.battler_hue @hp = mhp @mp = mmp @icon = @original_name.slice!(0,3) #removes the first 3 characters of the enemies. @icon = sprintf("%d", @icon.slice(1)) end end class Window_BattleEnemy < Window_Selectable #-------------------------------------------------------------------------- # * overwrite method: Draw Item #-------------------------------------------------------------------------- def draw_item(index) change_color(normal_color) name = $game_troop.alive_members[index].name draw_icon($game_troop.alive_members[index].icon.to_i, item_rect(index).x, item_rect(index).y, true) draw_text(item_rect(index).x + 24, item_rect(index).y, width, line_height, name) end end
It shows the enemies names but no icon. I'm using Yanfly's Battle System and the Luna engine. Does that change anything?
Thanks for your help!
Thanks for your help!
Shot in the dark - I'm not using Luna (and I'm not at home so I can't test myself) but does Yanfly's Ace Message System work for enemy names? It'll format text everywhere I've tried so far, but I haven't tried enemy names. If it does work, you can just use (where X is the icon number).
EDIT: oh wow I... spaced out and forgot that part of the first post.
\i[x]
EDIT: oh wow I... spaced out and forgot that part of the first post.
Red_Nova
Sir Redd of Novus: He who made Prayer of the Faithless that one time, and that was pretty dang rad! :D
9192
That's... weird. It works just fine on my version. Is this underneath the Target Window Config script?
EDIT: Double check your icon index. If you set your target to 0, then (with the RTP iconset anyway) that particular index is blank. Try different numbers.
EDIT: Double check your icon index. If you set your target to 0, then (with the RTP iconset anyway) that particular index is blank. Try different numbers.
draw_text won't parse escaped characters (the \i, for example).
Use draw_text_ex instead.
Edit> I missed the draw_icon line...
Edit2> Red, that code won't work for icon indices with more than one digit in them. That might be the issue.
Use draw_text_ex instead.
Edit> I missed the draw_icon line...
Edit2> Red, that code won't work for icon indices with more than one digit in them. That might be the issue.
author=slash
Shot in the dark - I'm not using Luna (and I'm not at home so I can't test myself) but does Yanfly's Ace Message System work for enemy names? It'll format text everywhere I've tried so far, but I haven't tried enemy names. If it does work, you can just use(where X is the icon number).\i[x]
Haha, that's actually the first thing I tried. Unfortunately, it didn't work ^^;;
author=Red_Nova
That's... weird. It works just fine on my version. Is this underneath the Target Window Config script?
EDIT: Double check your icon index. If you set your target to 0, then (with the RTP iconset anyway) that particular index is blank. Try different numbers.
I used icon 1. To make sure it's an icon that works, I used the message system to show this with
\i[1]
And it showed the icon.
In battle, however...
Here's what the enemy looks like, in case I've messed that up.
And also, if I encounter a battle after the first, I get this error:
Sorry for all the trouble. ^^;; I could copy the project and delete scripts to try to find the conflicting one, or send the project to you.
Red_Nova
Sir Redd of Novus: He who made Prayer of the Faithless that one time, and that was pretty dang rad! :D
9192
author=karins_soulkeeper
draw_text won't parse escaped characters (the \i, for example).
Use draw_text_ex instead.
Edit> I missed the draw_icon line...
Edit2> Red, that code won't work for icon indices with more than one digit in them. That might be the issue.
draw_text_ex works for me. unity, cut that entire script I posted and use this instead:
class Window_BattleEnemy < Window_Selectable #-------------------------------------------------------------------------- # * overwrite method: Draw Item #-------------------------------------------------------------------------- def draw_item(index) change_color(normal_color) name = $game_troop.alive_members[index].name draw_text_ex(item_rect(index).x, item_rect(index).y, name) end end
Then add the
\i[x]
Red_Nova
Sir Redd of Novus: He who made Prayer of the Faithless that one time, and that was pretty dang rad! :D
9192
Holy mother of balls I can't read my own typing.
Don't use
use
Don't use
\n[x]
\i[x]
Red_Nova
Sir Redd of Novus: He who made Prayer of the Faithless that one time, and that was pretty dang rad! :D
9192
Whaaaaaa...?
Can you PM me a copy of your project? Everything's working just fine on my end, so there might be another script interfering with the solution.
Can you PM me a copy of your project? Everything's working just fine on my end, so there might be another script interfering with the solution.
Red_Nova
Sir Redd of Novus: He who made Prayer of the Faithless that one time, and that was pretty dang rad! :D
9192
Glad we got it working! In case someone wanted to do the same thing, here's my solution:
Just paste this underneath all Luna Engine scripts for it to work. Make sure that you're using BattleHelp window to show enemy names instead of BattleEnemy.
class Window_BattleHelp < Window_Help #-------------------------------------------------------------------------- # refresh_battler_name #-------------------------------------------------------------------------- def refresh_battler_name(battler) contents.clear reset_font_settings change_color(normal_color) @text = battler_name(battler) icons = battler.state_icons + battler.buff_icons dy = icons.size <= 0 ? line_height / 2 : 0 draw_text_ex((width / 2) - 60, dy, @text) dx = (contents.width - (icons.size * 24)) / 2 draw_actor_icons(battler, dx, line_height, contents.width) end end
Just paste this underneath all Luna Engine scripts for it to work. Make sure that you're using BattleHelp window to show enemy names instead of BattleEnemy.
I hate to nitpick, but I've found a small thing that still bothers me a little ^^;;
It looks like the enemy's name is no longer centered with this script. For enemies with small names, it looks fine:
But when an enemy has a long name, it looks quite a bit off:
Any way to fix this? ^^;; Thanks
It looks like the enemy's name is no longer centered with this script. For enemies with small names, it looks fine:
But when an enemy has a long name, it looks quite a bit off:
Any way to fix this? ^^;; Thanks
Red_Nova
Sir Redd of Novus: He who made Prayer of the Faithless that one time, and that was pretty dang rad! :D
9192
Unfortunately, draw_text_ex doesn't have a way of selecting alignment. You can try to ape a center alignment by replacing this
with this
in the refresh_battler_name method in that script posted above.
Is that fine?
draw_text_ex((width / 2) - 60, dy, @text)
draw_text_ex((width / 2) - (@text.size*6), dy, @text)
in the refresh_battler_name method in that script posted above.
Is that fine?
Pages:
1
















