Same variable is different with each event?

I know how to do this, but I was wondering if there was a way to simplify this.


I have a pool of 64 NPC's who are generated randomly at the beginning of the game. Well, what I wanted was a variable to be attached to one NPC, and each time you talked to them the variable increased by one. When the variable reaches 9, for the sake of this example, the NPC gets mad and tells you to stop bugging them.


I was wondering if there was a way to use just one variable for all 64 NPC's, so I'm not overloading my database with all these variables (I already have 64 switches for each respective NPC). The problem is, that if I reset that one variable, the NPC will go back to being friendly, and if I don't, all NPC's will be annoyed at the player. 


To simplify my question, I was hoping there was a way that a variable could be stored to one specific event, and be reset at a completely different event.
Listen, you can do this for every event separately, using Self Switches from A to D. That means player would be bugging them (NPCs) 4 times. Self switches are local booleans switches on a specific event.


Thus you can do that, but just for 3 times bugging them.


Another alternative would be using some kind of script plugin commands but it becomes more complex that way
I think setting 64 different variables might actually be a little bit easier than that, because said conversation page has a lot of conditional branches and directions for the conversation to go, so I would have to put one self switch control on every end to each branch of conversation. That would be very time consuming. But if it was really simple that would work. 
Search for a Self Data plugin script.  That will allow you to have self variables, similar to self switches.
Search for a Self Data plugin.  That will allow you to have self variables, similar to self switches.



Talking about Ace unfortunately. 🙁


Is there a script for that?
Sure is. PK8 wrote one a l-o-n-g time ago.  I should have said script, not plugin.   I did know it was for Ace.
Sure is. PK8 wrote one a l-o-n-g time ago.  I should have said script, not plugin.   I did know it was for Ace.



Found it!





Hey, @KerriganSaila make sure you download the VXA version. Good luck on your game making.
I looked at the script, it seemed like a lot of work having to add every script call, compared to just eventing each variable. so I just made all 64 variables, instead. And it's probably better that each NPC has their own variable, anyways, in case I need to store something else in them. Thanks, though!! I'lll probably use that script in the future.
Whatever fits your solution.


BTW I actually read the documentation and my jaw has dropped.


If only I knew about that some time ago... whatever 😛
What is the "every script call" you have to add?  You've got a call to set the variable, and a call to check its value.  That's the same number as a Control Variables and a Conditional Branch to check its value.
For every end of every conditional branch of each NPC I would have to add the script call to add the self variable. With events I can copy and paste with minimal modification (just selecting the variable), and with script calls I will have to edit the script call for each new NPC and event.


I actually wound up needing a variable for each NPC, anyways, because I wanted to reset their variable to 0 at the beginning of each new day.

Original thread: https://forums.rpgmakerweb.com/threads/same-variable-is-different-with-each-event.71593/