MZ [SOLVED] Alistair - [MZ] AP – Stat Distribution - Can AP be stored as a variable?

Hello! I'm hoping that I have a bit of a simple request here.
I'm trying to make use of Alistair's stat distribution (free!) plugin to handle a form of manual level ups in my game. https://alistairengine.wordpress.com/2020/11/21/mz-ap-stat-distribution/

The issue is that I need to be able to make the ability points = a variable that I have set up. I was hoping to have a similar function to a souls game where instead of getting a game over, the player will temporarily lose their upgrade points and have to retrieve them or risk losing them permanently. Now I have all of that evented out just fine (in theory) but there are no plugin commands to CHECK a characters current AP. And if I can't check AP I can't store it in a variable that is required for the death AP to function. So while I can set AP to 0 or increase it based on a variable, I can't first store AP as a variable to then give it back to them later. At least not with the built in commands as far as I can understand them.

Obviously AP has to be stored somewhere since the game remembers how many points you have if you exit the menu, but I'm not sure where I'd find that in the actual javascript document nor how I would run a script that can call that information upon defat to then be stored in a variable. Any help would be much appreciated! I've had a lot of trouble finding many MZ stat distribution plugins as well so if there's one I missed that has this kind of functionality feel free to point me toward that as well. Thanks for your time!

EDIT/SOLUTION:

I will provide all of the finalized code here should anyone like to have a similar system in their own game. Alistairs AP Stat Distribution is a great base for a souls style leveling system. If you want a system where the player can die, lose all of their souls and then later retrieve them, you can do just that, but you'll have to use some scripting and a couple of variables to do so.

To start you should ignore most of the actual plugin commands as you won't be using many of them. Instead make 2 variables. For examples Souls and Death Souls. Souls will track your current Souls. So kill an enemy, they add to the variable. When you die simply make Death Souls = Souls, and set Souls to 0. Then when you retrieve your Death Souls you add Death Souls to Souls and set Death Souls to 0.

Where does the AP come in? At your bonfire you need to run a few events. First use a plugin command to subtract your AP by the maximum value you set in the plugin parameters. This will ensure that your AP to spend will always equal your current Souls. Then run this script to add your Souls value to your AP

$gameActors.actor(ID).addDistributionPoints($gameVariables.value(x));

Your event should then call the stat distribution scene, allowing the players to level up their stats by spending their points. However once this is done we need to do the inverse code and change Souls to reflect our remaining AP. Just add this script under the distribution scene call.

$gameVariables.setValue(x, $gameActors.actor(ID)._distributionPoints);

And that's all it takes really. Now you can have less game overs will still giving your player plenty of reason to avoid losing in battle!
Seems like it's just actor._abilityPoints, so like $gameActors.actor(1)._abilityPoints
Assuming you want the points they currently have, I didn't think through everything you wrote.
Seems like it's just actor._abilityPoints, so like $gameActors.actor(1)._abilityPoints
Assuming you want the points they currently have, I didn't think through everything you wrote.
Thanks for the response! I threw in a test event to try it out but unfortunately it's reporting 0 instead of 10. I probably did something wrong with the code though I don't have a clue what I'd alter.
Screen Shot 2025-08-07 at 3.33.20 PM.png
Aha, I guess it was the _distributionPoints instead. At least that gives the value of the initial points you give the actor. But I didn't really check how the plugin works.
Aha, I guess it was the _distributionPoints instead. At least that gives the value of the initial points you give the actor. But I didn't really check how the plugin works.
Yep that was it, now it's displaying properly. Thanks so much! I've run into another issue that I'm not sure can be fixed though. I thought I'd be able to just call the variables value when distributing points back to the player but it's just causing things to break and return a value of "NaN" instead. I'm not sure if I wrote the wrong code for the amount of points or if that simply won't work with this plug in though.

If it CAN'T work like that, would it be possible to do an inverse of the previous code? So instead of
$gameVariables.setValue(246, $gameActors.actor(4)._distributionPoints);
Something that would set the distribution points to a variables value?
$gameActors.actor(4)._distributionPoints.setValue($gameVariables.value(246));
I tried writing that out myself but it's just giving me 0 as the value instead of 10 again. Not that I expected I would be able to make that work myself haha. I appreciate you taking the time to help!

Screen Shot 2025-08-07 at 5.16.24 PM.png
script:

const actor = $gameActors.actor(X);
const points = $gameVariables.value(Y);
actor.addDistributionPoints(points);
script:

const actor = $gameActors.actor(X);
const points = $gameVariables.value(Y);
actor.addDistributionPoints(points);
I couldn't get this script to work but I am FOREVER in your debt because seeing this somehow made java click for me haha. I DID find a way to make everything work as I wanted so I will update the original post and provide all the code should anyone want to run a similar system.

Thank you again so much though for all your help! I super appreciate it!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/solved-alistair-mz-ap-stat-distribution-can-ap-be-stored-as-a-variable.179428/