Advertisement
Guest User

Common Event Self Switches

a guest
Feb 19th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var oldGameInterpreter_command111 = Game_Interpreter.prototype.command111;
  2. Game_Interpreter.prototype.command111 = function() {
  3.   var result = false;
  4.   if (this._params[0] == 2) {
  5.     if (this._commonEventId > 0) {
  6.       var key = ['common-event', this._commonEventId, this._params[1]];
  7.       result = ($gameSelfSwitches.value(key) === (this._params[2] === 0));
  8.  
  9.       this._branch[this._indent] = result;
  10.       if (this._branch[this._indent] === false) {
  11.           this.skipBranch();
  12.       }
  13.       return true;
  14.     }
  15.   }
  16.  
  17.   return oldGameInterpreter_command111.apply(this, arguments);
  18. };
  19.  
  20. var oldGameInterpreter_setupReservedCommonEvent = Game_Interpreter.prototype.setupReservedCommonEvent;
  21. Game_Interpreter.prototype.setupReservedCommonEvent = function() {
  22.     if ($gameTemp.isCommonEventReserved()) {
  23.         var event = $gameTemp.reservedCommonEvent();
  24.         this.setup(event.list);
  25.         this._commonEventId = event.id;
  26.         $gameTemp.clearCommonEvent();
  27.         return true;
  28.     } else {
  29.         return false;
  30.     }
  31. };
  32.  
  33. var oldGameInterpreter_clear = Game_Interpreter.prototype.clear;
  34. Game_Interpreter.prototype.clear = function() {
  35.     oldGameInterpreter_clear.apply(this, arguments);
  36.     this._commonEventId = 0;
  37. };
  38.  
  39. var oldGameInterpreter_command123 = Game_Interpreter.prototype.command123;
  40. Game_Interpreter.prototype.command123 = function() {
  41.     if (this._commonEventId > 0) {
  42.         var key = ['common-event', this._commonEventId, this._params[0]];
  43.         $gameSelfSwitches.setValue(key, this._params[1] === 0);
  44.         return true;
  45.     }
  46.    
  47.     return oldGameInterpreter_command123.apply(this, arguments);
  48. };
  49.  
  50. var oldGameInterpreter_setupChild = Game_Interpreter.prototype.setupChild;
  51. Game_Interpreter.prototype.setupChild = function(list, eventId) {
  52.     oldGameInterpreter_setupChild.apply(this, arguments);
  53.     this._childInterpreter._commonEventId = eventId;
  54. };
  55.  
  56.  
  57. var oldGameCommonEvent_refresh = Game_CommonEvent.prototype.refresh;
  58. Game_CommonEvent.prototype.refresh = function() {
  59.     oldGameCommonEvent_refresh.apply(this, arguments);
  60.     if (this._interpreter) {
  61.       this._interpreter._commonEventId = this._commonEventId;
  62.     }
  63. };
  64.  
  65. var oldGameCommonEvent_update = Game_CommonEvent.prototype.update;
  66. Game_CommonEvent.prototype.update = function() {
  67.     if (this._interpreter) {
  68.         if (!this._interpreter.isRunning()) {
  69.             this._interpreter.setup(this.list());
  70.             this._interpreter._commonEventId = this._commonEventId;
  71.         }
  72.         this._interpreter.update();
  73.     }
  74. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement