Hi all,
So with the release of MV I'm trying to get into Javascript (much like other people). I've written the below to add a new AP property to Actors and change the Level Up to add AP points. It works and logs the AP increase to the console when an actor levels up and I can call the AP value through script call. I'm just wondering if I have done this the correct way or if there is a better/best practice way to achieve the same thing. This is my first plugin so apologies if it's amateurish.
Thanks in advance
So with the release of MV I'm trying to get into Javascript (much like other people). I've written the below to add a new AP property to Actors and change the Level Up to add AP points. It works and logs the AP increase to the console when an actor levels up and I can call the AP value through script call. I'm just wondering if I have done this the correct way or if there is a better/best practice way to achieve the same thing. This is my first plugin so apologies if it's amateurish.
//=============================================================================// Baba Points On Level// by Beenbaba// Date: 10/30/2015 //============================================================================= /*: * @plugindesc Points On Level Up * @author beenbaba * * @param Points * @desc Amount of Points to add to actor on level up * @default 1 */ //============================================================================= // Declare function//============================================================================= (function() { var parameters = PluginManager.parameters('BabaPointsOnLevel'); var PointsLV = (parameters['Points']); var PointsLVNum = +PointsLV //==============================================================================// SYSTEM - Add AP as property to Game_Actor Prototype//============================================================================== Object.defineProperties(Game_Actor.prototype, { _ap: { writable: true, value: 0, configurable: true, enumerable: true } }); //===============================================================================// LEVEL UP - Add Points param to current AP on Level Up//=============================================================================== var _Game_Actor_levelUp = Game_Actor.prototype.levelUp; Game_Actor.prototype.levelUp = function() { _Game_Actor_levelUp.call(this); this._level++; this.currentClass().learnings.forEach(function(learning) { if (learning.level === this._level) { this.learnSkill(learning.skillId); } }, this); this._ap += PointsLVNum; console.log($gameActors.actor(this._actorId)._ap) }; })(); // dont touch this.