Advertisement
Astfgl

ITSW

Apr 17th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // SBOEO
  3. // by Astfgl
  4. // Date: 15/04/2017
  5. // Latest: 21/04/2017
  6. // TOU:
  7. // Free to use both commercially and non commercially
  8. // Edits allowed under the condition that the edits must share the same
  9. // license and be clearly labelled as such. Redistribution allowed.
  10. // Credits required: Any of Astfgl/Pierre MATEO/Pierre MATEO (Astfgl)
  11. // You cannot remove or alter this header under any condition.
  12. //=============================================================================
  13.  
  14.  
  15. /*:
  16.  * @plugindesc In turn selection window
  17.  * @author Astfgl
  18.  * @help
  19.  * Call the selection window with:
  20.  * $gameSystem.startSelection(subject,skillId)
  21.  * The subject must be the actor ir enemy object, not its ID.
  22.  * The given skill ID doesn't have to be the skill that will be cast,
  23.  * it's just a dummy skill used for targetting purposes, it will not be cast.
  24.  * Then get the results IN ANOTHER SCRIPT CALL with:
  25.  * $gameSystem.getSelectionResult();
  26.  * This will return the actor or enemy object targeted for single target skills.
  27.  * For multiple target skills, you don't really need this plugin. Yanfly
  28.  * is inconsistent with his notation and it will only return the index of
  29.  * who was selected, disregarding if it's a party or troop members.
  30.  *
  31.  * If the selection is cancelled the result will be "cancelled"
  32.  * You should wrap your event in a conditional script:
  33.  * $gameSystem.getSelectionResult() !== "cancelled"
  34.  * in the else field you can then do what you want if the selection was cancelled.
  35.  */
  36.  
  37. (function(){
  38.     var var1;
  39.     var var2;
  40.     var var3;
  41.    
  42. var _Astfgl_aliasSBOEO = Scene_Battle.prototype.onEnemyOk
  43. Scene_Battle.prototype.onEnemyOk = function() {
  44.         if (BattleManager._phase === "turn" || BattleManager._phase === "actionList") {
  45.             var1 = this._enemyWindow.enemyIndex();
  46.             this._enemyWindow.hide();
  47.             this._enemyWindow.deselect();
  48.             this._enemyWindow.deactivate();
  49.         } else {
  50.             _Astfgl_aliasSBOEO.call(this);
  51.         }
  52. };
  53.  
  54. var _Astgfl_aliasSBOEC = Scene_Battle.prototype.onEnemyCancel
  55. Scene_Battle.prototype.onEnemyCancel = function() {
  56.     if (BattleManager._phase === "turn" || BattleManager._phase === "actionList") {
  57.             var1 = "cancelled";
  58.             this._enemyWindow.hide();
  59.             this._enemyWindow.deselect();
  60.             this._enemyWindow.deactivate();
  61.         } else {
  62.             _Astgfl_aliasSBOEC.call(this);
  63.         }
  64. };
  65.    
  66. var _Astgl_aliasGIUWM = Game_Interpreter.prototype.updateWaitMode
  67. Game_Interpreter.prototype.updateWaitMode = function() {
  68.         var bool = false
  69.         if (SceneManager._scene._enemyWindow) {
  70.             bool = SceneManager._scene._enemyWindow.active
  71.         }
  72.         return _Astgl_aliasGIUWM.call(this) || bool
  73. }
  74.      
  75. Window_BattleEnemy.prototype.action = function() {
  76.     if (BattleManager._phase === "actionList") {
  77.         var action = new Game_Action(var2,false)
  78.         action.setSkill(var3);
  79.         return action
  80.     }
  81.     return BattleManager.inputtingAction();
  82. };
  83.  
  84. Game_System.prototype.startSelection = function(subject,skillId) {
  85.     if ($gameParty.inBattle()) {
  86.         SceneManager._scene._enemyWindow.activate();
  87.         SceneManager._scene._enemyWindow.select(0);
  88.         var2 = subject;
  89.         var3 = skillId;
  90.         SceneManager._scene._enemyWindow.refresh();
  91.     }
  92. }
  93.  
  94. Game_System.prototype.getSelectionResult = function() {
  95.     var txt = var1
  96.     if (typeof txt === "Number") {
  97.         return var1
  98.     } else if (var1 !== "cancelled"){
  99.         var reg = /\d+/
  100.         var num = Number(txt.match(reg)[0])
  101.         if (txt.match("ACTOR")) {
  102.             return $gameParty.battleMembers()[num]
  103.         } else {
  104.             return $gameTroop.members()[num]
  105.         }
  106.     } else {
  107.         return var1
  108.     }
  109. }
  110.      
  111.  })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement