I'm trying to have an enemy skill mention the name of the character being targeted in the using message. Is there a built in way to do that or do I have to use a plugin?
VXAce Skills: How to make use message specify a target
RPG Maker VXAce SupportI tried something, but have a small problem. In the damage formula window of a skill, I put this
v[277]=b.name ; 10
Then in the message window I put: weakens \v[277]'s defences!
Now when the enemy uses the skill, it first says "XXX weakens 0's defences!" then the damage info comes up and the message changes to "XXX weakens Paul's defences!" when the target was Paul. So it sort of works, but first it takes the variable before it has been assigned and displays the message with the zero. Does anyone know if something can be done about it?
(@Biodrum , are you using a battle script? I have Yami's Battle Symphony, so maybe that is interfering with my message. Maybe try what I tried in your project to see if it does the same.)
v[277]=b.name ; 10
Then in the message window I put: weakens \v[277]'s defences!
Now when the enemy uses the skill, it first says "XXX weakens 0's defences!" then the damage info comes up and the message changes to "XXX weakens Paul's defences!" when the target was Paul. So it sort of works, but first it takes the variable before it has been assigned and displays the message with the zero. Does anyone know if something can be done about it?
(@Biodrum , are you using a battle script? I have Yami's Battle Symphony, so maybe that is interfering with my message. Maybe try what I tried in your project to see if it does the same.)
While this is working for me, Im not really that competent at coding so someone else should probably look this over.
Code:
class Scene_Battle < Scene_Base
alias_method :custom_use_item, :use_item
def use_item
@log_window.set_targets(@subject.current_action.make_targets.compact)
custom_use_item
end
end
class Window_BattleLog < Window_Selectable
def set_targets(targets)
@custom_targets = targets
end
alias_method :custom_display_use_item, :display_use_item
def display_use_item(subject, item)
targets = @custom_targets || []
if targets.any?
targets.each do |target|
if item.id == 1 && item.is_a?(RPG::Skill)
add_text("#{subject.name} attacks #{target.name}!")
else
add_text("#{subject.name} uses #{item.name} on #{target.name}!")
end
end
else
add_text("#{subject.name} uses #{item.name}!")
end
# Optional: comment out to remove default message
# custom_display_use_item(subject, item)
@custom_targets = nil
end
end
Original thread: https://forums.rpgmakerweb.com/threads/skills-how-to-make-use-message-specify-a-target.180044/