KSkillMsg - kyonides - 09-18-2023
KSkillMsg
VX + ACE
by Kyonides
Introduction
Do you want to replace the default message for the Escape skill?
Or any other skill?
Now you can do it by using special note tags!
Please read the instructions already embedded in the script before asking questions here.
VX Script
Code: # * KSkillMsg VX * #
# Scripter : Kyonides Arkanthes
# 2023-09-19
# * How to Use * #
# Option 1: Place 1 or more notetags in a given Skill's Note Box.
# Option 2: Set a custom "string" to the ESCAPE_START Constant below.
# - Example of a Note Tag for Actors - Skill can be cast individually - #
#<message: actor 1 leaves at once.>
# - Example of a Note Tag for Enemies - #
#<message: enemy 1 chickens out.>
# - ESCAPE_START Constant's Default Value - #
# Below you will find the expression %s included in the string.
# It is used as a placeholder for the party's name.
# ESCAPE_START = "%s runs away from danger."
module KSkillMsg
ESCAPE_START = "%s runs away from danger."
REGEX_ACTOR = /<message: (actor) (\d+) ([^>]+)>/i
REGEX_ENEMY = /<message: (enemy) (\d+) ([^>]+)>/i
def self.process_msg(subject, item, default_line)
regex = subject.is_a?(Game_Enemy)? REGEX_ENEMY : REGEX_ACTOR
item.note[regex]
($1.nil? or subject.id != $2.to_i)? default_line : " " + $3
end
end
class Game_Enemy
def id
@enemy_id
end
end
class Scene_Battle
def process_escape
@info_viewport.visible = false
@message_window.visible = true
text = rand(100) < 50 ? Vocab::EscapeStart : KSkillMsg::ESCAPE_START
text = sprintf(text, $game_party.name)
$game_message.texts.push(text)
if $game_troop.preemptive
success = true
else
success = (rand(100) < @escape_ratio)
end
Sound.play_escape
if success
wait_for_message
battle_end(1)
else
@escape_ratio += 10
$game_message.texts.push('\.' + Vocab::EscapeFailure)
wait_for_message
$game_party.clear_actions
start_main
end
end
def alternate_display_use_item(skill)
line = KSkillMsg.process_msg(@active_battler, skill, skill.message1)
@message_window.add_instant_text(@active_battler.name + line)
return if skill.message2.empty?
wait(10)
@message_window.add_instant_text(skill.message2)
end
def execute_action_skill
skill = @active_battler.action.skill
alternate_display_use_item(skill)
targets = @active_battler.action.make_targets
display_animation(targets, skill.animation_id)
@active_battler.mp -= @active_battler.calc_mp_cost(skill)
$game_temp.common_event_id = skill.common_event_id
for target in targets
target.skill_effect(@active_battler, skill)
display_action_effects(target, skill)
end
end
end
VX ACE Script
Code: # * KSkillMsg ACE * #
# Scripter : Kyonides Arkanthes
# 2023-09-19
# * How to Use * #
# Option 1: Place 1 or more notetags in a given Skill's Note Box.
# Option 2: Set a custom "string" to the ESCAPE_START Constant below.
# - Example of a Note Tag for Actors - Skill can be cast individually - #
#<message: actor 1 leaves at once.>
# - Example of a Note Tag for Enemies - #
#<message: enemy 1 chickens out.>
# - ESCAPE_START Constant's Default Value - #
# Below you will find the expression %s included in the string.
# It is used as a placeholder for the party's name.
# ESCAPE_START = "%s runs away from danger."
module KSkillMsg
ESCAPE_START = "%s runs away from danger."
REGEX_ACTOR = /<message: (actor) (\d+) ([^>]+)>/i
REGEX_ENEMY = /<message: (enemy) (\d+) ([^>]+)>/i
def self.process_msg(subject, item, default_line)
regex = subject.is_a?(Game_Enemy)? REGEX_ENEMY : REGEX_ACTOR
item.note[regex]
($1.nil? or subject.id != $2.to_i)? default_line : " " + $3
end
end
module BattleManager
def self.process_escape
text = rand(100) < 50 ? Vocab::EscapeStart : KSkillMsg::ESCAPE_START
text = sprintf(text, $game_party.name)
$game_message.add(text)
success = @preemptive ? true : (rand < @escape_ratio)
Sound.play_escape
if success
process_abort
else
@escape_ratio += 0.1
$game_message.add('\.' + Vocab::EscapeFailure)
$game_party.clear_actions
end
wait_for_message
return success
end
end
class Game_Enemy
def id
@enemy_id
end
end
class Window_BattleLog
alias :kyon_escape_msg_win_btl_log_disp_use_itm :display_use_item
def display_use_item(subject, item)
return alternate_display_use_item(subject, item) if item.is_a?(RPG::Skill)
kyon_escape_msg_win_btl_log_disp_use_itm(subject, item)
end
def alternate_display_use_item(subject, item)
line = KSkillMsg.process_msg(subject, item, item.message1)
add_text(subject.name + line)
return if item.message2.empty?
wait
add_text(item.message2)
end
end
Terms & Conditions
Free for use in ANY game.
Due credit is mandatory.
The script is distributed AS IS.
That's it!
RE: KSkillMsg - kyonides - 09-20-2023
A Not Really Unexpected Update But Definitely an Useful One!
From now on, RMVX has been become the second port of this family of scripts!
Both versions allow you to change ANY SKILL's first message based on a very special note tag you can type right into your note box.
For Actors:
Code: <message: actor 1 leaves at once.>
For Enemies:
Code: <message: enemy 1 chickens out.>
Have a Nice String Replacement Day!
|