Advertisement
Maliki79

MalMZ_EnemyDeathStateMarkers

Jul 20th, 2024
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Maliki's Enemy Death State Markers
  3. // MalMZ_EnemyDeathStateMarkers.js
  4. // version 1.0 MZ
  5. //=============================================================================
  6. /*:
  7.  * @target MZ
  8.  *  
  9.  * @plugindesc ver1.0 Allows devs to give enemies states when taking Hp or MP damage.  Also makes battlers die if they have 0 mp while having MMP over 0.
  10.  * @author Maliki79
  11.  *
  12.  * @param HPDamageState
  13.  * @desc Place an interger of the state from the database that will be added whenever an enemy takes HP Damage. 0 will not add a state.
  14.  * Default: 0
  15.  * @default 0
  16.  *
  17.  * @param MPDamageState
  18.  * @desc Place an interger of the state from the database that will be added whenever an enemy takes MP Damage. 0 will not add a state.
  19.  * Default: 0
  20.  * @default 0
  21. */
  22.  
  23. var MalSpec = MalSpec || {};
  24.  
  25. MalSpec.Parameters = PluginManager.parameters('MalMZ_EnemyDeathStateMarkers');
  26. MalSpec.Param = MalSpec.Param || {};
  27.  
  28. MalSpec.hpState = parseInt(MalSpec.Parameters['HPDamageState']) || 0;
  29. MalSpec.mpState = parseInt(MalSpec.Parameters['MPDamageState']) || 0;
  30.  
  31. Game_Battler.prototype.refresh = function() {
  32.     Game_BattlerBase.prototype.refresh.call(this);
  33.     if (this.hp === 0 || (this.mp === 0 && this.mmp != 0)) {
  34.         this.addState(this.deathStateId());
  35.     } else {
  36.         this.removeState(this.deathStateId());
  37.     }
  38. };
  39.  
  40. Game_BattlerBase.prototype.die = function() {
  41.     this._hp = 0;
  42.     if (this.isActor()) {
  43.         this.clearStates();
  44.         this.clearBuffs();
  45.     };
  46. };
  47.  
  48. var malGainHp = Game_Battler.prototype.gainHp;
  49. Game_Battler.prototype.gainHp = function(value) {
  50.     malGainHp.call(this, value);   
  51.     if( this.isEnemy() && MalSpec.hpState != 0){
  52.         if(value < 0) {
  53.             this.addState(MalSpec.hpState);
  54.             } else {
  55.             this.removeState(MalSpec.hpState);
  56.         };
  57.     };
  58. };
  59.  
  60. var malGainMp = Game_Battler.prototype.gainMp;
  61. Game_Battler.prototype.gainMp = function(value) {
  62.     malGainMp.call(this, value);
  63.     if( this.isEnemy() && MalSpec.mpState != 0){   
  64.         if(value < 0) {
  65.             this.addState(MalSpec.mpState);
  66.             } else {
  67.             this.removeState(MalSpec.mpState);
  68.             };
  69.     };
  70. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement