扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 97|回复: 0

[转载发布] 【插件】地图上显示伤害

[复制链接]
累计送礼:
0 个
累计收礼:
0 个
  • TA的每日心情
    开心
    2025-2-4 02:05
  • 签到天数: 110 天

    连续签到: 2 天

    [LV.6]常住居民II

    2327

    主题

    395

    回帖

    1万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    6
    卡币
    10465
    OK点
    16
    推广点
    0
    同能卷
    0
    积分
    13215

    灌水之王

    发表于 2024-11-22 05:35:17 | 显示全部楼层 |阅读模式
    不知道有没有人已经发过了,我找了半天一直没有找到于是就自己实现了一个。实现地并不算优美,但是起码能用。显示效果不好是RMMV自己的缘故,因为我创建的就是Sprite_Damage。

    JAVASCRIPT 代码下载
    1. /*:
    2. -------------------------------------------------------------------------------
    3. @title mapDamagePopup
    4. @author gonglinyuan
    5. @version 0.1.0
    6. @date 2016-04-19
    7. @filename Util_MapDamagePopup.js
    8. -------------------------------------------------------------------------------
    9. @plugindesc pop up damage on map characters
    10. @help
    11. You can invoke the mapDamagePopup with the following pluginCommand:
    12. mapDamagePopup    [isCritical?]
    13. : Number of character on a map to show the damage. A positive number indicates an event number. 0 indicates the current event. -1 indicates the player. -2,-3,-4,... indicates followers.
    14. : Number of rows in "System/Damage.png". Numbered form 0 to 4. Row 4 indicates "Miss".
    15. : Value of damage. It is supposed to be above 0. (If it is negative, it might make the row to increase 1 according to the implementation of "createDigits" method.)
    16. [isCritical?]: Whether it is critical damage or not. "true" indicates it is critical, otherwise not.
    17. */
    18. (function(){
    19.         var _Sprite_Character_initMembers = Sprite_Character.prototype.initMembers;
    20.         Sprite_Character.prototype.initMembers = function(){
    21.                 _Sprite_Character_initMembers.call(this);
    22.                 this._damages = [];
    23.         };
    24.         Sprite_Character.prototype.updateDamagePopup = Sprite_Battler.prototype.updateDamagePopup;
    25.         Sprite_Character.prototype.setupDamagePopup = function(){
    26.                 if(this._character._spriteDamage){
    27.                         this._character._spriteDamage.x = this.x;
    28.                         this._character._spriteDamage.y = this.y;
    29.                         this._character._spriteDamage.z = this.z + 1;
    30.                         this._damages.push(this._character._spriteDamage);
    31.                         this.parent.addChild(this._character._spriteDamage);
    32.                         this._character._spriteDamage = null;
    33.                 }
    34.         };
    35.         var _Sprite_Character_update = Sprite_Character.prototype.update;
    36.         Sprite_Character.prototype.update = function(){
    37.                 _Sprite_Character_update.call(this);
    38.                 this.updateDamagePopup();
    39.         };
    40.         var _Game_Character_initMembers = Game_Character.prototype.initMembers;
    41.         Game_Character.prototype.initMembers = function(){
    42.                 _Game_Character_initMembers.call(this);
    43.                 this._spriteDamage = null;
    44.         };
    45.         var getTarget = function(target){
    46.                 if(target < -1){
    47.                         return $gamePlayer.followers().follower(-target - 2);
    48.                 }elseif(target == -1){
    49.                         return $gamePlayer;
    50.                 }elseif(target == 0){
    51.                         return $gameMap.event(this.eventId());
    52.                 }elseif(target > 0){
    53.                         return $gameMap.event(target);
    54.                 }
    55.         }
    56.         var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    57.         Game_Interpreter.prototype.pluginCommand = function(command, args){
    58.                 _Game_Interpreter_pluginCommand.call(this, command, args);
    59.                 if(command == "mapDamagePopup"){
    60.                         var target = getTarget.call(this, Number(args[0]));
    61.                         var row = Number(args[1]);
    62.                         var value = Number(args[2]);
    63.                         var sprite = new Sprite_Damage();
    64.                         if(row < 4){
    65.                                 sprite.createDigits(row, value);
    66.                         }else{
    67.                                 sprite.createMiss();
    68.                         }
    69.                         if(args[3] === "true"){
    70.                                 sprite.setupCriticalEffect();
    71.                         }
    72.                         console.log(target, row, value, sprite);
    73.                         target._spriteDamage = sprite;
    74.                 }
    75.         };
    76. })();
    复制代码


    使用方法见注释。

    例子:给角色回复50点生命值——(插件指令)mapDamagePopup -1 1 50
    其中mapDamagePopup是命令的名称
    -1指的是主角。这个和fuki的定义是一样的。0指本事件。1以上指事件编号。-2以下指跟随角色。
    1指的是img/system/Damage.png中的第2行(行从0开始标号)。
    50指的是回血的数值,注意这里不用写成-50
                本帖来自P1论坛作者gonglinyuan,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=391736  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

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

    本版积分规则

    关闭

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2025-3-10 12:05 , Processed in 0.131659 second(s), 53 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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