Koudelka like Status-System

When deeper playtesting it now i got the following error:


error1xoj3u.jpg



This did happen when i was in the equip menu and wanted to equip some armor with the following notetags:


<Add to Variable: 1, 50, 1>


<Add to Variable: 2, 50, 1>


<Add to Variable: 3, 50, 1>


<Add to Variable: 4, 50, 1>


<Add to Variable: 5, 50, 1>


<Add to Variable: 6, 50, 1>


<Add to Variable: 7, 50, 1>


<Add to Variable: 8, 50, 1>


This does happen on character 1 and on character 2. And it does happen also if the actorid is 0 instead of 1.


When i did the quick playtest yesterday i created a weapon with the same notetag like above and that did and still does work wonderful and no matter if actorid is 0 or 1.


What i also did notice recently was that my main character in the database only got a weapon as starting equipment. The armor slot is definitly set on none.When starting the game all that is done is that some variables from attributes are changed and the mhp and mmp are set with the formulas from above. Then a weapon and some item will be added to the inventory. After that a fight gets startet. And when the fight starts the character is already equipped with armor 2 from the database. This has nothing to do with your plugin as it occurs independant from that being activated or not. Still i dont have any idea how such a thing can happen ?
I think I fixed it: https://drive.google.com/open?id=0Bzg5Egy_d-RoeU5kWUpEeGpMTXc


Let me know if that version works - if it does, I'll start implementing the functionality for starting equipment and clean up the code.


For your actor suddenly being equipped with armor, I can only think of two possible reasons: Either you have another plugin somewhere that messes with the equipment, or an event somewhere contains the command Change Equipment (instead of Change Weapons/Armors, which only adds the item to the inventory without equipping it).
Thanks a lot :  )


I will try that out tomorrow and give you some feedback.


For the suddenly being equipped problem. I could solve that by making some other armor a starting equip...starting the game...and after closing the game making "none" the starting armour again. So it seems like a caching problem or something from rmmv.
It is working as intended and i couldnt find any unknown errors :  )
Great, I'll try to upload a new version of the plugin tomorrow 🙂
Thanks again for all of your efforts !


While doing that plugin, do you think it could be possible to modify the plugin by myself so that everytime when something gets equipped or deequipped the formula for mhp and mmp gets calculated again to just get realtime changes ?
I'm not sure if it will work, but you could add the lines from the script calls that you now have in your Common Event to the plugin file and see if it works. I will mark the point where you would add those lines in the plugin.
That sounds great :  )
Finished!


https://drive.google.com/open?id=0Bzg5Egy_d-RoeU5kWUpEeGpMTXc


I'll also post the plugin with a bit more documentation here in the forum. Once the topic is up, I'm going to post the link to it here as well.


I commented the code a bit; you should put your script call lines at line 144 of the plugin, directly below the comment.
I just did take a quick look and noticed, that negative numbers are still not supportet. Is that something you cant technical solve or is it a question of time ?


I will try to get the script calls done tomorrow and report back.


Thanks for the work :  )
More a question of "need to look up how to do more stuff with regular expressions". It shouldn't be difficult to solve once I find out how to properly make it recognize the minus sign at the start of a number. Actually, it looks like it can be done by just changing line 65 from


var regexp = /<Add to Variable: (\d+), (\d+), (\d+)>/i;


to


var regexp = /<Add to Variable: (\d+), (-?\d+), (\d+)>/i;


If you want, try it and see if it works - I'm too lazy to edit the plugin right now 😉
Ok first the good news: Negative Values are working after that little addition :  )


If i input my script call in the designated place it is working very well first. But when deequipping some weapon i did notice that the variables arent calculated again. The stay add the reduced/increased value that did happen after equipping.


Just a side not that isnt that important: I was wondering if there is a way to make some variable unable to get lower then 1. Is there some way do that ?
Huh, I'll have to look into that tomorrow. That's definitely a bug that needs to be fixed.


Yes, just check if the variable is lower than 1 after you have done your calculations and set it to 1 if it is. Like this:

Code:
if ($gameVariables.value(20) < 1) {
  $gameVariables.setValue(20, 1);
}
Wow that was a fast response. Thanks for the hint :  )
And I just fixed the bug. It was just a pair of brackets that was missing. While I was at it, I officially added support for negative values.


Download link is the same as before: https://drive.google.com/open?id=0Bzg5Egy_d-RoeU5kWUpEeGpMTXc


Add your code below line 151 now.
All is working perfectly: negativ values and real time updates when eqp changes :  ) 


Thank you so much for your work !


I think the last thing attribut wise i need to solve will be to redo the magic skills that allow temporary changes of attributes in battle. After the battle all is reset.


That sounds quite easy in theory as well. When the battle starts write all 24 variables (3 characters with 8 attributes each) into 24 new variables. During battle the skills now can increase the original attributes variables. When the battle ends the original variables just got overwritten with the data from the 24 new variables. 
Storing the variables and resetting at the end of battle is a good idea. If the variables are in consecutive order, you can quite easily cycle through them with a for-loop so you don't need 24 Change Variable commands:


// place these two assignments at the beginning of each storing/resetting script call,
// or just use the numbers directly in the loops below
var firstOriginalID = 20; // change to the ID of the first "original" variable
var firstCopyID = 120; // change to the ID of the first "storage" variable

// storing
for(i = 0; i < 24; i++) {
$gameVariables.setValue(i + firstCopyID, $gameVariables.value(i + firstOriginalID));
}

// resetting
for(i = 0; i < 24; i++) {
$gameVariables.setValue(i + firstOriginalID, $gameVariables.value(i + firstCopyID));
}


The only thing that might be a bit difficult is to reset the variables at the end of battle. If you use Himeworks' End Phase Triggers, you could make a troop event that runs at the end of each turn, checks if all the enemies are dead (Conditional Branch -> Script -> $gameTroop.isAllDead() ) and if they are, executes a script call with the code for resetting. Since you will need the troop events for all your troops, Yanfly's Base Troop Events will save you a lot of work.
Ok that really sounds like a lot of scripting work (because there are also enemy skills that can lower the players attributes). I will come back to that later in the development when i got the head for it.


Thanks as always for your help :  )
By the way, the plugin I wrote now has its own topic here:




If you find any more bugs, you can report them there.
I will do that if i encounter some problems or got questions about using ist :  )

Original thread: https://forums.rpgmakerweb.com/threads/koudelka-like-status-system.72881/