Advertisement
ludovicodes

LudoSkillCount.js

Dec 17th, 2017
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. //LudoSkillCount.js
  3. //=============================================================================
  4.  
  5. /*:
  6.  * @plugindesc Counts the amount of times a skill has been used in a single battle, and over the course of the game.
  7.  * @author Alessio De Santis
  8.  *
  9.  *
  10.  * @help
  11.  * Access the values by using script commands.
  12.  * $skillCount[skillId].battle for the amounts of times used in a battle (value is saved until next battle)
  13.  * $skillCount[skillId].total for the total amounts of times used in all battles.
  14.  */  
  15.  
  16.  
  17.  //-----------------------------------------------------------------------------
  18.  
  19.  $skillCount = [];
  20.  
  21.  
  22.  Scene_Battle.prototype.start = function() {
  23.     Scene_Base.prototype.start.call(this);
  24.     this.startFadeIn(this.fadeSpeed(), false);
  25.     BattleManager.playBattleBgm();
  26.     BattleManager.startBattle();
  27.  };
  28.  
  29.  
  30.  
  31. BattleManager.startBattle = function() {
  32.     this._phase = 'start';
  33.    
  34.  
  35.     $gameSystem.onBattleStart();
  36.     $gameParty.onBattleStart();
  37.     $gameTroop.onBattleStart();
  38.     this.displayStartMessages();
  39. };
  40.  
  41. BattleManager.startAction = function() {
  42.     var subject = this._subject;
  43.     var action = subject.currentAction();
  44.     var targets = action.makeTargets();
  45.     this._phase = 'action';
  46.     this._action = action;
  47.     this._targets = targets;
  48.     subject.useItem(action.item());
  49.    
  50.     this.increment(action.item().id);
  51.  
  52.     this._action.applyGlobal();
  53.     this.refreshStatus();
  54.     this._logWindow.startAction(subject, action, targets);
  55. };
  56.  
  57. Scene_Title.prototype.create = function() {
  58.     Scene_Base.prototype.create.call(this);
  59.     this.createBackground();
  60.     this.createForeground();
  61.     this.createWindowLayer();
  62.     this.createCommandWindow();
  63.  
  64.     this.initSC();
  65. };
  66.  
  67. BattleManager.increment = function(id) {
  68.     if(id != 0){
  69.         $skillCount[id-1].battle++;
  70.         $skillCount[id-1].total++;
  71.     }
  72. }
  73.  
  74. BattleManager.resetSC = function() {
  75.     for(i of $skillCount){
  76.         i.battle = 0;
  77.     }
  78. }
  79.  
  80. Scene_Title.prototype.initSC = function(){
  81.     var temp = $dataSkills;
  82.     for(i of temp){
  83.         for(j in i){
  84.             if (j == "name") {
  85.                 for(k of $skillCount) {
  86.                     if(k.name == i[j]){
  87.                         return console.log($skillCount);
  88.                     }
  89.                 }
  90.                 $skillCount.push({
  91.                     name : i[j],
  92.                     battle : 0,
  93.                     total : 0,
  94.                 });
  95.             }
  96.         }
  97.        
  98.     }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement