累计送礼: 0 个 累计收礼: 1 个 TA的每日心情 开心 2026-7-12 04:10
签到天数: 209 天
连续签到: 2 天
[LV.7]常住居民III
管理员
VIP
7
卡币
29925
OK点
16
推广点
0
同能卷
50
积分 38778
KMessageTarget MV
2 Versions
by Kyonides Arkanthes
Introduction
By default the Battle Log doesn't expect you to add a target's name to a skill action message. This plugin changes that to make sure you can certainly read who's the hero's current target.
Simple Version
JavaScript:
//=========================================== // * KMessageTargetMV.js - Simple Version //=========================================== /*: * @plugindesc This plugin will let you add the enemy's name to a skill's * action message by using a tag or wildcard. * @author Kyonides Arkanthes * @help Date: 2023-01-30 * # * Free as in beer. * # * The regular expression or regex is %e by default. */ function KMessageTarget() { throw new Error('This is a static class'); } KMessageTarget.regex = /%e/i; Window_BattleLog.prototype.displaySkillTargets = function(subject, item, targets) { let target = 0; let msg = ""; for (var i = 0; i < targets.length; i++) { target = targets[i]; if (item.message1) { msg = subject.name() + item.message1.format(item.name); msg = msg.replace(KMessageTarget.regex, target.name()); this.push('addText', msg); } if (item.message2) { this.push('addText', item.message2.format(item.name)); } } } const KMessageTarget_win_btl_log_displayAction = Window_BattleLog.prototype.displayAction; Window_BattleLog.prototype.displayAction = function(subject, item, targets) { if (DataManager.isSkill(item)) { this.displaySkillTargets(subject, item, targets); } else { KMessageTarget_win_btl_log_displayAction.call(subject, item); } }; Window_BattleLog.prototype.startAction = function(subject, action, targets) { let item = action.item(); this.push('performActionStart', subject, action); this.push('waitForMovement'); this.push('performAction', subject, action); this.push('showAnimation', subject, targets.clone(), item.animationId); this.displayAction(subject, item, targets); }; 复制代码
Full Version
JavaScript:
//=========================================== // * KMessageTargetMV.js - Full Version //=========================================== /*: * @plugindesc This plugin will let you add the enemy's name to a skill's * action message by using a tag or wildcard. * @author Kyonides Arkanthes * @help Date: 2023-01-30 * # * Free as in beer. * # * * The regular expressions or regex are * %a for an Actor or Ally * %e for an Enemy * * Note Tag: _party item_ * It allows your hero uses an item on all of his or her allies while preventing * the Battle Log from repeating itself over and over again. * * You can customize the KMessageTarget.party_as_target string if necessary. */ function KMessageTarget() { throw new Error('This is a static class'); } KMessageTarget.item_list = [1, 6]; KMessageTarget.actor_regex = /%a/i; KMessageTarget.enemy_regex = /%e/i; KMessageTarget.no_target_item = / on %a/i; KMessageTarget.party_item = /_party item_/i; KMessageTarget.party_as_target = "the party"; Window_BattleLog.prototype.displaySkillTargets = function(s_name, item, targets) { let target = 0; let msg = ""; for (var i = 0; i < targets.length; i++) { target = targets[i]; if (item.message1) { msg = s_name + item.message1.format(item.name); msg = msg.replace(KMessageTarget.actor_regex, target.name()); msg = msg.replace(KMessageTarget.enemy_regex, target.name()); this.push('addText', msg); } if (item.message2) { this.push('addText', item.message2.format(item.name)); } } } Window_BattleLog.prototype.processNames = function(s_name, item, t_name) { let msg = TextManager.useItem.format(s_name, item.name); if (!KMessageTarget.item_list.includes(item.id)) { msg = msg.replace(KMessageTarget.no_target_item, ""); } msg = msg.replace(KMessageTarget.actor_regex, t_name); this.push('addText', msg); } Window_BattleLog.prototype.displayItemTargets = function(s_name, item, targets) { if ( KMessageTarget.party_item.exec(item.note) ) { this.processNames(s_name, item, KMessageTarget.party_as_target); return; } let target = 0; for (var i = 0; i < targets.length; i++) { target = targets[i]; this.processNames(s_name, item, target.name()); } } Window_BattleLog.prototype.displayAction = function(subject, item, targets) { let numMethods = this._methods.length; if (DataManager.isSkill(item)) { this.displaySkillTargets(subject.name(), item, targets); } else { this.displayItemTargets(subject.name(), item, targets); } if (this._methods.length === numMethods) { this.push('wait'); } }; Window_BattleLog.prototype.startAction = function(subject, action, targets) { let item = action.item(); this.push('performActionStart', subject, action); this.push('waitForMovement'); this.push('performAction', subject, action); this.push('showAnimation', subject, targets.clone(), item.animationId); this.displayAction(subject, item, targets); }; 复制代码
Side Note: There should be another regex that I could have used there, yet, I preferred to use a very specific one that people could quickly interpret as an enemy's name if they ever find it in the message box. We could say it's a very friendly reminder of what it actually stands for.
Terms & Conditions
Free as in beer.
Include my nickname in your game credits.
Read the instructions.
Do not repost it.
本贴来自国际rpgmaker官方论坛作者:kyonides处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/kmessagetarget-mv.154542/