Introducing new data.

Hi everyone. I'm only just starting out with both JS and programming in general, and as you might expect, I have run into some difficulties. Namely, I want to create a feature whereby:

1, An ability deals damage, as well as drains a portion of that damage. I have that down, as it is easy to create such an ability with the Damage Type -> Hp Drain feature in the editor. My problem is how to point to that data? Where is the number that is the amount of damage dealt or the amount drained?

2, The damage/amount drained persists in a variable which is subsequently added to via

bloodPool += subsequent draining attacks;. I.e. we're talking about a 'blood pool' if you will, which the player fills by using draining attacks. My problem, indeed shortcoming, is that I understand how to modify a feature through

var _Eat_Sirlion_Steak = Eating.prototype.eatOnlyCelery = function() {};but that's modifying something - I want to introduce the a new variable which will correspond to the amount of blood the 'blood pool' has. I suppose I could tack a var or this. statement onto something pretty much unrelated, but that seems to me, even with my barely rudimentary understanding of js or programming, to be a butchery of the code and most inelegant and very confusing in the long run. So I was wondering if there is a clean and elegant way of introducing new code and thereby variables through plugins?

3, Finally, and I guess this is a very tall order, I want to commit that variable to persistent storage. I was hoping of storing it in Actors.JSON via assigning to

$gameActors(1).bloodPool;but to no avail. Am I just out of luck on this last one?

I realise that I'm asking a lot of questions, I'm sorry for the wall of text and thanks in advance!
Maybe I am not understanding this very well, but can't you accomplish all of the above by creating a variable called BloodPool and using that in your damage formula? I don't see why you need to have a plugin for any of this.


You might want to explore what is possible with the damage formula (there is a pinned thread in MV Support that you can look through or post in), before resorting to plugins.
Thank you for the information. After exploring the option you suggested, I must admit it is by far more straightforward, but then it is not, necessarily, the purpose of this process to make things easy for me. I want to be able to do with scripting what I set out to do, for educational purposes, and I also want to create a robust system where the BloodPool is a secondary resource

which is used to fuel and interact with other abilities. I don't know if a damage formula can create such a persistent value, but I'll give it a shot. Hell, before you told me, I didn't even know that the damage formula feature could handle more complex statements. I genuinely thought that the variables listed on mouseover are the only ones you could use. Thanks for that, too. 👍 👍
I don't know if this will be of value to anyone, as the problem was a beginner issue anyway, but I managed to solve it, in part, by creating a variable through a plugin and in part by using the damage formula to interact with the variable, as Shaz had suggested.

Original thread: https://forums.rpgmakerweb.com/threads/introducing-new-data.48993/