Guest User

Untitled

a guest
Jun 17th, 2020
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*:
  2. *
  3. * @plugindesc Yanfly Gab Windows State Status Alert Ext
  4. *
  5. * @author Ritter
  6. *
  7. * @help
  8. *
  9. * Add state notetags to display a gab window for add/remove states!
  10. * Works with evented 'Change State' command and step removal.
  11. * This script requires you to own Yanfly Gab Windows Plugin.
  12. *
  13. * Just add both note tags for each state you want to display a gab
  14. * window for.
  15. *
  16. * note tags:
  17. *
  18. * <addGab:text>
  19. * <removeGab:text>
  20. *
  21. * Example usage:
  22. *
  23. * <addGab:Suffering from Poison>
  24. * <removeGab:No longer suffering from Poison>
  25. *
  26. * You can also use the word actor to display actors name.
  27. *
  28. * <addGab:actor is suffering from Poison>
  29. * <removeGab:actor is no longer suffering from Poison>
  30. *
  31. * This would make it say Harold is suffering from Poison
  32. * Harold is no longer suffering from Poison
  33. *
  34. *-----------------------------------------------------------------
  35. *
  36. * Terms of use:
  37. *
  38. * Free to use for commercial and non-commercial games provided you
  39. * own Yanfly Gab Windows plugin.
  40. * You are free to edit, chop, delete, copy, paste, destroy, burn, take
  41. * code from, or toss this plugin in the river as much as you please.
  42. * (Plugin not tested for buoyancy)
  43. * Feel free to credit me if you wish, this is optional but appreciated.
  44. *
  45. *
  46. */
  47.  
  48.  
  49. (function() {
  50.  
  51. // Aliased functions to display gabs when needed.
  52.  
  53. // Change State
  54. var alias_Game_Interpreter_command313 = Game_Interpreter.prototype.command313;
  55. Game_Interpreter.prototype.command313 = function() {
  56.     this.iterateActorEx(this._params[0], this._params[1], function(actor) {
  57.         var alreadyDead = actor.isDead();
  58.         if (this._params[2] === 0) {
  59.             if ($dataStates[this._params[3]].meta.addGab) {
  60.                 this.addStateGab(this._params[3], actor);
  61.                 this.showGab();
  62.             }
  63.         } else {
  64.             if ($dataStates[this._params[3]].meta.removeGab) {
  65.                 this.removeStateGab(this._params[3], actor);
  66.                 this.showGab();
  67.             }
  68.         }
  69.     }.bind(this));
  70.     return alias_Game_Interpreter_command313.call(this);
  71. };
  72.  
  73. // show added states on steps, not sure how this works but added it anyway?
  74. var alias_Game_Actor_showAddedStates = Game_Actor.prototype.showAddedStates;
  75. Game_Actor.prototype.showAddedStates = function() {
  76.     this.result().addedStateObjects().forEach(function(state) {
  77.        if ($dataStates[state.id].meta.addGab) {
  78.             Game_Interpreter.prototype.addStateGab(state.id, this);
  79.             Game_Interpreter.prototype.showGab();
  80.         } else {
  81.             alias_Game_Actor_showAddedStates.call(this);
  82.         }
  83.     }, this);
  84. };
  85.  
  86. // show removed states on steps
  87. var alias_Game_actor_showRemovedStates = Game_Actor.prototype.showRemovedStates;
  88. Game_Actor.prototype.showRemovedStates = function() {
  89.     this.result().removedStateObjects().forEach(function(state) {
  90.         if ($dataStates[state.id].meta.removeGab) {
  91.             Game_Interpreter.prototype.removeStateGab(state.id, this);
  92.             Game_Interpreter.prototype.showGab();
  93.         } else {
  94.             alias_Game_Actor_showRemovedStates.call(this);
  95.         }
  96.     }, this);
  97. };
  98.  
  99. // Functions for handling gabs.
  100.  
  101. // create gab text for added state
  102. Game_Interpreter.prototype.addStateGab = function(state, actor) {
  103.     text = this.gabMeta(state, 1);
  104.     if (text.contains("actor")) text = text.replace("actor", actor._name);
  105.     this._gabText = text;
  106. };
  107.  
  108. // create gab text for removed state
  109. Game_Interpreter.prototype.removeStateGab = function(state, actor) {
  110.     text = this.gabMeta(state, 0);
  111.     if (text.contains("actor")) text = text.replace("actor", actor._name);
  112.     this._gabText = text;
  113. };
  114.  
  115. // get state meta data
  116. Game_Interpreter.prototype.gabMeta = function(state, value) {
  117.     if (value == 1) return $dataStates[state].meta.addGab;
  118.     if (value == 0) return $dataStates[state].meta.removeGab;
  119. };
  120.  
  121. })();
Add Comment
Please, Sign In to add comment