Created
April 16, 2021 00:53
-
-
Save elleonard/48cc4d4c1228e42f8823047e972a7afa to your computer and use it in GitHub Desktop.
RPGツクールMZ向け、敵の復活を禁止する行動プラグインサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
'use strict'; | |
const _Game_Enemy_initMembers = Game_Enemy.prototype.initMembers; | |
Game_Enemy.prototype.initMembers = function () { | |
_Game_Enemy_initMembers.call(this); | |
this._cannotRevive = false; | |
}; | |
Game_Battler.prototype.cannotRevive = function () { | |
return false; | |
}; | |
Game_Enemy.prototype.cannotRevive = function () { | |
return this._cannotRevive; | |
}; | |
Game_Enemy.prototype.setCannotRevive = function (cannotRevive) { | |
this._cannotRevive = cannotRevive; | |
}; | |
const _Game_Enemy_recoverAll = Game_Enemy.prototype.recoverAll; | |
Game_Enemy.prototype.recoverAll = function () { | |
if (this.cannotRevive()) { | |
return; | |
} | |
_Game_Enemy_recoverAll.call(this); | |
}; | |
const _Game_Enemy_revive = Game_Enemy.prototype.revive; | |
Game_Enemy.prototype.revive = function () { | |
if (this.cannotRevive()) { | |
return; | |
} | |
_Game_Enemy_revive.call(this); | |
}; | |
const _Game_Action_testItemEffect = Game_Action.prototype.testItemEffect; | |
Game_Action.prototype.testItemEffect = function(target, effect) { | |
const result = _Game_Action_testItemEffect.call(this, target, effect); | |
if (effect.code === Game_Action.EFFECT_REMOVE_STATE && effect.dataId === Game_BattlerBase.prototype.deathStateId()) { | |
return result && !target.cannotRevive(); | |
} | |
return result; | |
}; | |
const _Game_Action_apply = Game_Action.prototype.apply; | |
Game_Action.prototype.apply = function(target) { | |
_Game_Action_apply.call(this, target); | |
if (target.result().isHit() && | |
this.item().damage.type > 0 && | |
target.isEnemy() && | |
target.isDead() && | |
this.isSealingRevive()) { | |
target.setCannotRevive(true); | |
} | |
}; | |
Game_Action.prototype.isSealingRevive = function () { | |
return !!this.item().meta.sealRevive; | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment