Get a number in Commands

● ARCHIVED · READ-ONLY
Started by Bloodmorphed 1 posts View original ↗
  1. Okay so I have this code here:

    Code:
      var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
      Game_Interpreter.prototype.pluginCommand = function(command, args) {
          _Game_Interpreter_pluginCommand.call(this, command, args);
          if (command === 'Setting'){
    
            switch (args[0]) {
              case 'ad':
                 return ad = Number(args[1]);
              break;
      }
     }

    I'm pretty sure I'm missing something obvious, but I'm not sure what

    Setting ad 5

    would make ad = 5 through the commands.

    Cheers!
    ~Bloodmorphed

    EDIT:
    Okay this IS working, but I do have a separate problem.

    Code:
    /*:
    BM_Difficulty.js
    Version: 1.0
    
    @plugindesc Adds difficulty through parameter manipulation.
    @author Bloodmorphed
    
    @help
    Plugin Commands:
    
    
    
    */
    
    (function() {
    
      function toNumber(str, def) {
          return isNaN(str) ? def : +(str || def);
      }
    
    
    
      var parameters = PluginManager.parameters('BM_Difficulty');
    
      // Param Multipliers
      var dhp = toNumber(parameters['Max HP Multiplier'], 1); // Max HP
      var dmp = toNumber(parameters['Max MP Multiplier'], 1); // Max MP
      var dap = toNumber(parameters['Attack Multiplier'], 1); // Attack
      var ddp = toNumber(parameters['Defense Multiplier'], 1); // Defense
      var dma = toNumber(parameters['Magic Attack Multiplier'], 1); // Magic Attack
      var dmd = toNumber(parameters['Magic Defense Multiplier'], 1); // Magic Defense
      var day = toNumber(parameters['Agility Multiplier'], 1); // Agility
      var dlk = toNumber(parameters['Luck Multiplier'], 1); // Luck
      var exp = toNumber(parameters['EXP Multiplier'], 1); // EXP
      var gold = toNumber(parameters['Gold Multiplier'], 1); // Gold
      var params = [dhp, dmp, dap, ddp, dma, dmd, day, dlk]; // Parameter Array
    
    // End 'noob friendly' Customization
      var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
      Game_Interpreter.prototype.pluginCommand = function(command, args) {
          _Game_Interpreter_pluginCommand.call(this, command, args);
          if (command === 'hp'){ return dhp = Number(args[0]) }
          if (command === 'exp'){ return exp = Number(args[0]) }
    
    
      }; // end pluginCommand
    
      // Gold calculations
      Game_Enemy.prototype.gold = function() {
        var esg = this.enemy().gold;
        var gdifficulty = Math.round(esg * gold);
        return gdifficulty;
      }; // End Gold
    
      // EXP Calculation
      Game_Enemy.prototype.exp = function() {
        var ene = this.enemy().exp;
        var edifficulty = Math.round(ene * exp);
        return edifficulty;
      }; // End exp
    
      // Param Calculation
      Game_Enemy.prototype.paramBase = function(paramId) {
        var enp = this.enemy().params[paramId];
        var pdifficulty = Math.floor(enp * params[paramId]);
        return pdifficulty;
        }; // End paramBase
    
    })();

    Right now I have a command in an event to where I can change the values when I want:

    The exp one works, flawlessly. However when I use hp *number* it doesn't work. I think it DOES change the variable number, but it does not change it inside of battle. Like the multiplication doesn't work. I know it works because if I start the game on say dhp = 20, it'll multiply the way it is intended. However if I change it in game - no go.

    I'm thinking I need to update it somehow when it changes?

    Okay so after logging it into the console - it DOES change the variable. The multiplication doesn't work... Now I have some weird stuff happening. Sometimes it works fine. Like my parameters setup after toNumber work, then every once in awhile they will break and im not sure why. (Nevermind my variables are not breaking, the multiplication just isnt happening!)

    However in my other plugin, where I have it using switches instead of commands, it works perfectly fine. Changing say diffSetting 0, 1 ,2 those corresponding to 3 different calculations... I don;t understand how that would work, and what I'm doing now is not, especially the variables, as they are the exact same thing.

    Upon further investigation, it seems the dhp is being updated, but the dhp inside my array is NOT being updated. It's like something is freezing it to the defaults.

    EDIT:
    So, good to know array variables don't update correctly when they are global? I just moved my array variable into the .paramBase function. And it seemed to fix it.

    Can anyone tell me WHY this works, but having it up tp like everything else, it did not update correctly? EDIT: After thinking about it for an hour or so, i know why it didn;t work, and im a dumb dumb. /rage