【插件】地图上显示伤害
不知道有没有人已经发过了,我找了半天一直没有找到于是就自己实现了一个。实现地并不算优美,但是起码能用。显示效果不好是RMMV自己的缘故,因为我创建的就是Sprite_Damage。JAVASCRIPT 代码下载
/*:
-------------------------------------------------------------------------------
@title mapDamagePopup
@author gonglinyuan
@version 0.1.0
@date 2016-04-19
@filename Util_MapDamagePopup.js
-------------------------------------------------------------------------------
@plugindesc pop up damage on map characters
@help
You can invoke the mapDamagePopup with the following pluginCommand:
mapDamagePopup
: 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.
: Number of rows in "System/Damage.png". Numbered form 0 to 4. Row 4 indicates "Miss".
: 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.)
: Whether it is critical damage or not. "true" indicates it is critical, otherwise not.
*/
(function(){
var _Sprite_Character_initMembers = Sprite_Character.prototype.initMembers;
Sprite_Character.prototype.initMembers = function(){
_Sprite_Character_initMembers.call(this);
this._damages = [];
};
Sprite_Character.prototype.updateDamagePopup = Sprite_Battler.prototype.updateDamagePopup;
Sprite_Character.prototype.setupDamagePopup = function(){
if(this._character._spriteDamage){
this._character._spriteDamage.x = this.x;
this._character._spriteDamage.y = this.y;
this._character._spriteDamage.z = this.z + 1;
this._damages.push(this._character._spriteDamage);
this.parent.addChild(this._character._spriteDamage);
this._character._spriteDamage = null;
}
};
var _Sprite_Character_update = Sprite_Character.prototype.update;
Sprite_Character.prototype.update = function(){
_Sprite_Character_update.call(this);
this.updateDamagePopup();
};
var _Game_Character_initMembers = Game_Character.prototype.initMembers;
Game_Character.prototype.initMembers = function(){
_Game_Character_initMembers.call(this);
this._spriteDamage = null;
};
var getTarget = function(target){
if(target < -1){
return $gamePlayer.followers().follower(-target - 2);
}elseif(target == -1){
return $gamePlayer;
}elseif(target == 0){
return $gameMap.event(this.eventId());
}elseif(target > 0){
return $gameMap.event(target);
}
}
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args){
_Game_Interpreter_pluginCommand.call(this, command, args);
if(command == "mapDamagePopup"){
var target = getTarget.call(this, Number(args));
var row = Number(args);
var value = Number(args);
var sprite = new Sprite_Damage();
if(row < 4){
sprite.createDigits(row, value);
}else{
sprite.createMiss();
}
if(args === "true"){
sprite.setupCriticalEffect();
}
console.log(target, row, value, sprite);
target._spriteDamage = sprite;
}
};
})();
使用方法见注释。
例子:给角色回复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在线咨询功能删除,谢谢。
页:
[1]