Is there a way to display "(actor) uses skill on (enemy)" in the skill menu?
How do I make the enemy name appear when using a skill?
RPG Maker VXAce SupportI was working on a script a while back to greatly enhance the behavior of the battle message log, but I don't intend to finish it anytime soon. So here's the incomplete script. I don't remember which parts work and which don't, but you can definitely do something like create a message "breathes fire on {target}" as a Skill use text and {target} will be replaced with the target's name.
Code:
module LogNames
# These settings prevent enemy suffixes from being displayed in the enemy's
# name in Battle Log actions. For example, if these settings are set to
# TRUE, "Slime A" will simply appear as "Slime" in the battle log.
No_suffix_in_user_string = false
No_suffix_in_target_string = true
# By default, VX Ace starts every action in the Battle Log with the name of
# the user. If you don't want it to, you can turn it off by setting this
# option to FALSE.
Skill_display_user_name = true
# Enter the default string that will be displayed when an actor uses an item
# on a single friend (including herself) or a single foe. Any other scope
# will use the string specified for item use in the Vocab module instead.
# The standard {user}, {target}, and {item} keywords may be used here.
# If you have entered a custom string for a database item in its notetag,
# it will take precedence over this default.
Item_string_one_friend = "{user} aids {target} with {item}!"
Item_string_one_foe = "{user} uses {item} on {target}!"
Item_string_self = "{user} uses {item}!"
# If someone self-targets with a skill or item, this script will automatically
# use the reflexive pronoun you've set for that actor/enemy (so, for example,
# "Eric uses Potion on himself" instead of "Eric uses Potion on Eric").
# If for some reason you DON'T want this behavior, set this option to FALSE.
Convert_self_to_reflexive = true
end
class Window_BattleLog < Window_Selectable
#--------------------------------------------------------------------------
# * Display Skill/Item Use - OVERWRITE METHOD!
#--------------------------------------------------------------------------
def display_use_item(subject, target, item)
if item.is_a?(RPG::Skill)
string1 = subject.name + item.message1
mod_string1 = parse_names(string1, subject, target, item)
add_text(mod_string1)
unless item.message2.empty?
wait
string2 = item.message2
mod_string2 = parse_names(string2, subject, target, item)
add_text(mod_string2)
end
else
if target == nil
Audio.se_play('Audio/SE/Applause1')
string1 = sprintf(Vocab::UseItem, subject.name, item.name)
else
if target.actor?
string1 = LogNames::Item_string_one_friend
else
string1 = LogNames::Item_string_one_foe
end
end
mod_string1 = parse_names(string1, subject, target, item)
add_text(mod_string1)
end
end
#--------------------------------------------------------------------------
# * Parse Subject/Target Names
#--------------------------------------------------------------------------
def parse_names(string, subject, target, item_obj)
# Get names of objects
subj = subject.name
ssp = subject.subject_pronoun
sop = subject.object_pronoun
spp = subject.possessive_pronoun
srp = subject.reflexive_pronoun
if target == nil
targ = "the target"
tsp = "it"
top = "it"
tpp = "its"
trp = "itself"
else
targ = target.name
tsp = target.subject_pronoun
top = subject.object_pronoun
tpp = target.possessive_pronoun
trp = target.reflexive_pronoun
# If the subject IS the target, replace target name with reflexive pronoun
# (unless option has been turned off in the module)
if LogNames::Convert_self_to_reflexive == true
if subject == target
targ = srp
end
end
end
item = item_obj.name
# Perform name substitutions
string.gsub!(/{u}/, subj)
string.gsub!(/{user}/, subj)
string.gsub!(/{username}/, subj)
string.gsub!(/{usp}/, ssp)
string.gsub!(/{user_sp}/, ssp)
string.gsub!(/{user_subject}/, ssp)
string.gsub!(/{user_pronoun}/, ssp)
string.gsub!(/{uop}/, sop)
string.gsub!(/{user_op}/, sop)
string.gsub!(/{user_object}/, sop)
string.gsub!(/{upp}/, spp)
string.gsub!(/{user_pp}/, spp)
string.gsub!(/{user_possessive}/, spp)
string.gsub!(/{urp}/, srp)
string.gsub!(/{user_rp}/, srp)
string.gsub!(/{user_reflexive}/, srp)
string.gsub!(/{n}/, targ)
string.gsub!(/{name}/, targ)
string.gsub!(/{t}/, targ)
string.gsub!(/{target}/, targ)
string.gsub!(/{tsp}/, tsp)
string.gsub!(/{target_sp}/, tsp)
string.gsub!(/{target_subject}/, tsp)
string.gsub!(/{target_pronoun}/, tsp)
string.gsub!(/{top}/, top)
string.gsub!(/{target_op}/, top)
string.gsub!(/{target_object}/, top)
string.gsub!(/{tpp}/, tpp)
string.gsub!(/{target_pp}/, tpp)
string.gsub!(/{target_possessive}/, tpp)
string.gsub!(/{trp}/, trp)
string.gsub!(/{target_rp}/, trp)
string.gsub!(/{target_reflexive}/, trp)
string.gsub!(/{i}/, item)
string.gsub!(/{item}/, item)
string.gsub!(/{itemname}/, item)
string.gsub!(/{s}/, item)
string.gsub!(/{skill}/, item)
string.gsub!(/{skillname}/, item)
# Return the modified string
return string
end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Use Skill/Item - OVERWRITE METHOD! Changes order & evaluates Targets size
#--------------------------------------------------------------------------
def use_item
item = @subject.current_action.item
targets = @subject.current_action.make_targets.compact # moved from 5th line
#~ if targets.size == 1
#~ cur_targ = targets[0]
#~ else
#~ cur_targ = nil
#~ end
# If it's a single target, we'll need info about the target for the log
sco = item.scope
if ((sco % 2 == 1) and (sco != 5)) # 1, 3, 7, 9, or 11 = one target
cur_targ = targets[0]
else
cur_targ = nil
end
@log_window.display_use_item(@subject, cur_targ, item)
@subject.use_item(item)
refresh_status
show_animation(targets, item.animation_id)
targets.each {|target| item.repeats.times { invoke_item(target, item) } }
end
end
# FOR NOTETAGS
module DataManager
class << self
#--------------------------------------------------------------------------
# * Load Normal Database
#--------------------------------------------------------------------------
alias :load_normals_with_enhanced_log_info :load_normal_database
def load_normal_database
load_normals_with_enhanced_log_info
for actor in $data_actors
actor.init_log_info if actor != nil
end
for enemy in $data_enemies
enemy.init_log_info if enemy != nil
end
end
#--------------------------------------------------------------------------
# * Load Battle Test Database
#--------------------------------------------------------------------------
alias :load_btest_with_enhanced_log_info :load_battle_test_database
def load_battle_test_database
load_btest_with_enhanced_log_info
for actor in $data_actors
actor.init_log_info if actor != nil
end
for enemy in $data_enemies
enemy.init_log_info if enemy != nil
end
end
end
end
class Game_Actor < Game_Battler
attr_accessor :subject_pronoun
attr_accessor :object_pronoun
attr_accessor :possessive_pronoun
attr_accessor :reflexive_pronoun
#--------------------------------------------------------------------------
# * Setup
#--------------------------------------------------------------------------
alias :setup_with_pronouns :setup
def setup(actor_id)
setup_with_pronouns(actor_id)
@subject_pronoun = actor.subject_pronoun
@object_pronoun = actor.object_pronoun
@possessive_pronoun = actor.possessive_pronoun
@reflexive_pronoun = actor.reflexive_pronoun
end
end
class Game_Enemy < Game_Battler
attr_accessor :subject_pronoun
attr_accessor :object_pronoun
attr_accessor :possessive_pronoun
attr_accessor :reflexive_pronoun
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias :init_with_pronouns :initialize
def initialize(index, enemy_id)
init_with_pronouns(index, enemy_id)
@subject_pronoun = enemy.subject_pronoun
@object_pronoun = enemy.object_pronoun
@possessive_pronoun = enemy.possessive_pronoun
@reflexive_pronoun = enemy.reflexive_pronoun
end
end
module RPG
# Get Battle Effects for Actors from their notetags.
# Format is as follows:
# <BE>
# Type: (Perform or Receive)
# Condition: (Condition)
# Condition: (Condition)
# ...
# Effect: (Effect)
# Effect: (Effect)
# ...
# <BE END>
class RPG::BaseItem
#--------------------------------------------------------------------------
# * Add extra Parameters to RPG::State items
#--------------------------------------------------------------------------
def init_log_info
@subject_pronoun = "it"
@object_pronoun = "it"
@possessive_pronoun = "its"
@reflexive_pronoun = "itself"
# Set the Battle Effects from the item's notetag
self.get_pronouns(@note)
end
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :subject_pronoun # Subject Pronoun, e.g. "he"
attr_accessor :object_pronoun # Object Pronoun, e.g. "him"
attr_accessor :possessive_pronoun # Possessive Pronoun, e.g. "his"
attr_accessor :reflexive_pronoun # Reflexive Pronoun, e.g. "himself"
#--------------------------------------------------------------------------
# * Set the Battle Effects array from the item's notetag
#--------------------------------------------------------------------------
def get_pronouns(note)
# First, search for Common Pronouns (It, He, She, You) and set all four
# pronouns appropriately if one is found.
if @note =~ /<pn (.*)>/
common_pronoun = $1
else
common_pronoun = ""
end
if @note =~ /<pronoun (.*)>/
common_pronoun = $1
end
if common_pronoun == "it"
@subject_pronoun = "it"
@object_pronoun = "it"
@possessive_pronoun = "its"
@reflexive_pronoun = "itself"
end
if common_pronoun == "he"
@subject_pronoun = "he"
@object_pronoun = "him"
@possessive_pronoun = "his"
@reflexive_pronoun = "himself"
end
if common_pronoun == "him"
@subject_pronoun = "he"
@object_pronoun = "him"
@possessive_pronoun = "his"
@reflexive_pronoun = "himself"
end
if common_pronoun == "she"
@subject_pronoun = "she"
@object_pronoun = "she"
@possessive_pronoun = "her"
@reflexive_pronoun = "herself"
end
if common_pronoun == "her"
@subject_pronoun = "she"
@object_pronoun = "she"
@possessive_pronoun = "her"
@reflexive_pronoun = "herself"
end
if common_pronoun == "you"
@subject_pronoun = "you"
@object_pronoun = "you"
@possessive_pronoun = "your"
@reflexive_pronoun = "yourself"
end
# Then, search for Individual Pronouns and set it appropriately if found.
if @note =~ /<spn (.*)>/
subject_pronoun = $1
end
if @note =~ /<sub_pn (.*)>/
subject_pronoun = $1
end
if @note =~ /<subject_pronoun (.*)>/
subject_pronoun = $1
end
if @note =~ /<opn (.*)>/
object_pronoun = $1
end
if @note =~ /<ob_pn (.*)>/
object_pronoun = $1
end
if @note =~ /<obj_pn (.*)>/
object_pronoun = $1
end
if @note =~ /<subject_pronoun (.*)>/
object_pronoun = $1
end
if @note =~ /<ppn (.*)>/
possessive_pronoun = $1
end
if @note =~ /<pos_pn (.*)>/
possessive_pronoun = $1
end
if @note =~ /<poss_pn (.*)>/
possessive_pronoun = $1
end
if @note =~ /<possessive_pronoun (.*)>/
possessive_pronoun = $1
end
if @note =~ /<rpn (.*)>/
reflexive_pronoun = $1
end
if @note =~ /<ref_pn (.*)>/
reflexive_pronoun = $1
end
if @note =~ /<reflexive_pronoun (.*)>/
reflexive_pronoun = $1
end
end
end
end
Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-make-the-enemy-name-appear-when-using-a-skill.56674/