设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 66|回复: 0

[转载发布] KMessageTarget MV

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    7959

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    29925
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    38778

    灌水之王

    发表于 前天 08:33 | 显示全部楼层 |阅读模式
    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:       
    1. //===========================================
    2. // * KMessageTargetMV.js - Simple Version
    3. //===========================================
    4. /*:
    5. * @plugindesc This plugin will let you add the enemy's name to a skill's
    6. * action message by using a tag or wildcard.
    7. * @author Kyonides Arkanthes
    8. * @help Date: 2023-01-30
    9. * # * Free as in beer. * #
    10. * The regular expression or regex is %e by default.
    11. */
    12. function KMessageTarget() {
    13.   throw new Error('This is a static class');
    14. }
    15. KMessageTarget.regex = /%e/i;
    16. Window_BattleLog.prototype.displaySkillTargets = function(subject, item, targets) {
    17.   let target = 0;
    18.   let msg = "";
    19.   for (var i = 0; i < targets.length; i++) {
    20.     target = targets[i];
    21.     if (item.message1) {
    22.       msg = subject.name() + item.message1.format(item.name);
    23.       msg = msg.replace(KMessageTarget.regex, target.name());
    24.       this.push('addText', msg);
    25.     }
    26.     if (item.message2) {
    27.       this.push('addText', item.message2.format(item.name));
    28.     }
    29.   }
    30. }
    31. const KMessageTarget_win_btl_log_displayAction = Window_BattleLog.prototype.displayAction;
    32. Window_BattleLog.prototype.displayAction = function(subject, item, targets) {
    33.   if (DataManager.isSkill(item)) {
    34.     this.displaySkillTargets(subject, item, targets);
    35.   } else {
    36.     KMessageTarget_win_btl_log_displayAction.call(subject, item);
    37.   }
    38. };
    39. Window_BattleLog.prototype.startAction = function(subject, action, targets) {
    40.   let item = action.item();
    41.   this.push('performActionStart', subject, action);
    42.   this.push('waitForMovement');
    43.   this.push('performAction', subject, action);
    44.   this.push('showAnimation', subject, targets.clone(), item.animationId);
    45.   this.displayAction(subject, item, targets);
    46. };
    复制代码


    Full Version

                    JavaScript:       
    1. //===========================================
    2. // * KMessageTargetMV.js - Full Version
    3. //===========================================
    4. /*:
    5. * @plugindesc This plugin will let you add the enemy's name to a skill's
    6. * action message by using a tag or wildcard.
    7. * @author Kyonides Arkanthes
    8. * @help Date: 2023-01-30
    9. * # * Free as in beer. * #
    10. *
    11. * The regular expressions or regex are
    12. *   %a for an Actor or Ally
    13. *   %e for an Enemy
    14. *
    15. * Note Tag: _party item_
    16. * It allows your hero uses an item on all of his or her allies while preventing
    17. * the Battle Log from repeating itself over and over again.
    18. *
    19. * You can customize the KMessageTarget.party_as_target string if necessary.
    20. */
    21. function KMessageTarget() {
    22.   throw new Error('This is a static class');
    23. }
    24. KMessageTarget.item_list = [1, 6];
    25. KMessageTarget.actor_regex = /%a/i;
    26. KMessageTarget.enemy_regex = /%e/i;
    27. KMessageTarget.no_target_item = / on %a/i;
    28. KMessageTarget.party_item = /_party item_/i;
    29. KMessageTarget.party_as_target = "the party";
    30. Window_BattleLog.prototype.displaySkillTargets = function(s_name, item, targets) {
    31.   let target = 0;
    32.   let msg = "";
    33.   for (var i = 0; i < targets.length; i++) {
    34.     target = targets[i];
    35.     if (item.message1) {
    36.       msg = s_name + item.message1.format(item.name);
    37.       msg = msg.replace(KMessageTarget.actor_regex, target.name());
    38.       msg = msg.replace(KMessageTarget.enemy_regex, target.name());
    39.       this.push('addText', msg);
    40.     }
    41.     if (item.message2) {
    42.       this.push('addText', item.message2.format(item.name));
    43.     }
    44.   }
    45. }
    46. Window_BattleLog.prototype.processNames = function(s_name, item, t_name) {
    47.   let msg = TextManager.useItem.format(s_name, item.name);
    48.   if (!KMessageTarget.item_list.includes(item.id)) {
    49.     msg = msg.replace(KMessageTarget.no_target_item, "");
    50.   }
    51.   msg = msg.replace(KMessageTarget.actor_regex, t_name);
    52.   this.push('addText', msg);
    53. }
    54. Window_BattleLog.prototype.displayItemTargets = function(s_name, item, targets) {
    55.   if ( KMessageTarget.party_item.exec(item.note) ) {
    56.     this.processNames(s_name, item, KMessageTarget.party_as_target);
    57.     return;
    58.   }
    59.   let target = 0;
    60.   for (var i = 0; i < targets.length; i++) {
    61.     target = targets[i];
    62.     this.processNames(s_name, item, target.name());
    63.   }
    64. }
    65. Window_BattleLog.prototype.displayAction = function(subject, item, targets) {
    66.   let numMethods = this._methods.length;
    67.   if (DataManager.isSkill(item)) {
    68.     this.displaySkillTargets(subject.name(), item, targets);
    69.   } else {
    70.     this.displayItemTargets(subject.name(), item, targets);
    71.   }
    72.   if (this._methods.length === numMethods) {
    73.     this.push('wait');
    74.   }
    75. };
    76. Window_BattleLog.prototype.startAction = function(subject, action, targets) {
    77.   let item = action.item();
    78.   this.push('performActionStart', subject, action);
    79.   this.push('waitForMovement');
    80.   this.push('performAction', subject, action);
    81.   this.push('showAnimation', subject, targets.clone(), item.animationId);
    82.   this.displayAction(subject, item, targets);
    83. };
    复制代码


    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/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-1 00:28 , Processed in 0.143771 second(s), 56 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表