Having trouble creating a parameter and then modifying the value with a notetag

kuoushi

Villager
Member
Joined
Oct 28, 2015
Messages
14
Reaction score
15
First Language
English
So I might just be missing something but here's the problem I've been having. I have added some stats to Game_BatterBase to keep track of some values for me. Normal enough.

Object.defineProperties(Game_BattlerBase.prototype, { hpgr: { writable: true, value: Compat.Param.HPGrowthRate }, hpgmin: { writable: true, value: Compat.Param.HPGrowthMax }, hpgmax: { writable: true, value: Compat.Param.HPGrowthMin } });The Compat.Param.* guys are just the defaults as defined in the plugin's parameters in RPG Maker MV setup by the user.

Now, that all seems to work fine and when I call something like actorObject.hpgr it'll return the variables I want. So far so good. The problem comes in when I try to modify those values through notetags.

I've decided to just make my plugin require the Yanfly Core since I'm not sure I want to release my spaghetti into the world, so I piggy-backed on his code when it gets all of the notetags and added in my own grab after his like this:

Compat.BE.DataManager_processCORENotetages3 = DataManager.processCORENotetags3;DataManager.processCORENotetags3 = function(group) { Compat.BE.DataManager_processCORENotetages3(group); for (var n = 1; n < group.length; n++) { var obj = group[n]; var notedata = obj.note.split(/[\r\n]+/); obj.hpgr = Compat.Param.HPGrowthRate; for (var i = 0; i < notedata.length; i++) { var line = notedata; if (line.match(/<(?:HPGR):[ ](\d+.?\d+?)>/i)) { obj.hpgr = parseFloat(RegExp.$1); if (obj.hpgr < 0) obj.hpgr = 0; } } }};Pretty wonky but right now I'm just trying to get the HPGR value alone and once I can get that one working I'll make it work a little bit more elegantly for grabbing a large amount of extra statistics. Anyway, this code actually works fine. The problem is, obj doesn't appear to be a Game_Actor (as I found out when I sent the obj to console_log(obj)).

Not sure what to do as everything appears to be functioning correctly, but it just refuses to save the newly created parameter's value from the notetag during processCORENotetags3.

I hope I've provided enough information to get help here. I know the code is pretty copy/pasta, which is also why this is so confusing. I had originally tried to write the notetag getter on my own but it didn't work so I tried doing what other people had done and still nothing. Any help would be appreciated. Thanks!
 

Jeremy Cannady

Coldfire
Veteran
Joined
Oct 25, 2015
Messages
449
Reaction score
268
First Language
English
Game_BattlerBase.prototype.defineProperties = function() { hpgr: { writable: true, value: Compat.Param.HPGrowthRate }; hpgmin: { writable: true, value: Compat.Param.HPGrowthMax }; hpgmax: { writable: true, value: Compat.Param.HPGrowthMin }; });I think for the first peice of code I would use this. I don't have access to my code and console debug to help as I can't remember the syntax correctly.
 

kuoushi

Villager
Member
Joined
Oct 28, 2015
Messages
14
Reaction score
15
First Language
English
I'm not overriding the defineProperties function in Game_BattlerBase, I'm adding properties to it that I want to use so that doesn't seem to fix it.

What I have done, however, is start using the MVC for one. And for another I've kind of cheated by having a global (in the scope of my plugin) variable that can contain all of the meta data which I can then access later in my getter/setter functions. So far so good I'll report back with code for if anyone else runs into a similar problem once I've cleaned it all up.

Okay, so here's the code snippets to kind of replace what I was doing up there.

var extractMetadata = DataManager.extractMetadata; DataManager.extractMetadata = function(data) { extractMetadata.apply(this, arguments); if(data.classId) { // we only want actor notetags, only actors have a classId //set up our growth parameters with the actor's id in a global plugin variable // and give them default values from our user's parameters Compat.gParam[data.id] = Compat.gParam[data.id] || {}; Compat.gParam[data.id]["hpgr"] = Compat.Param.HPGrowthRate / 100; Compat.gParam[data.id]["hpgmax"] = Compat.Param.HPGrowthMax; Compat.gParam[data.id]["hpgmin"] = Compat.Param.HPGrowthMin; for(var a in data.meta) { // for every notetag on this actor, overwrite default values. var b = parseInt(data.meta[a]); if(a.toUpperCase() == "HPGR") { b /= 100; } Compat.gParam[data.id][a] = b; } } }; //Add the growth rates and min/max stats to BattlerBase: MVC.reader(Game_BattlerBase.prototype,'hpgr', function(){ return this._hpGrowthRate(); }); MVC.reader(Game_BattlerBase.prototype,'hpgmin', function(){ return Compat.gParam[this._actorId]["hpgmin"]; }); MVC.reader(Game_BattlerBase.prototype,'hpgmax', function(){ return Compat.gParam[this._actorId]["hpgmax"]; }); Game_BattlerBase.prototype._hpGrowthRate = function() { return Compat.gParam[this._actorId]["hpgr"]; }This still needs a lot of cleaning up, but it does allow me to say actor.hpgr and get the correct values that I want.

Just took some extra figuring out on my part. Thanks for reading if you did and thanks for trying to help Jeremy.
 
Last edited by a moderator:

Latest Threads

Latest Profile Posts

Who wants to see my review of the worst star wars movie? This movie has all the excitement of being on Jury Duty of the most boring case ever about trade negotiations.
A lot to learn to make a game. Can I handle it?
I've been working on status effects since last thursday, and today I finished the core mechanic of Zombie, Teleport, Curse and Recall. Zombie and Curse are lacking a few things to make them complete atm. Teleport though is the "HAHA" spell for some of my mobs, but can "NOPE" at them with Recall.
I'm weird as there are a few game franchises I'll watch and read about, but have no interest in playing.
Humans have such a capacity to assign personalities and love to objects. We do this because we love them. It's interesting then that our fears over AI are that they won't love us back and will instead hate us.

Forum statistics

Threads
115,158
Messages
1,087,723
Members
149,702
Latest member
Hidemitsu
Top