Help with the code for the event

Hello, dear community!

I have an idea to make an item that applies an effect of “Delayed death” on NPCs. I’m planning to include some missions where the main character should kill different bad (burglars, murderers and etc.) NPCs especially in “Side quests”. For example, the hero comes to the village to kill the burglar, enters the NPC’s house, and leaves an item there in a pointed place. In several days, the job will be done and the quest will be completed.

Or it can be a special love poison to make someone to fall in love with someone. Why not?

So… In any case, I know that it should be a Common event, BUT there will be plenty of NPCs. Is it possible to write a script, which will include the necessary effect in one line of code for ALL NPCs? And if it’s possible, will somebody help me to do it, because my level in JavaScript is the lowest.:LZSsad:

I will appreciate all your help, advices or solutions of my problem.

Thank you.
I don't know how many "plenty" is...but I would do this with common events before I did it with JavaScript.

Just make the event where you plant the poison turn a switch on, then you have a parallel event that goes through all of the switches once in a while and kills any NPC that's has their switch on.

Or assign them each a variable and make the parallel event tick it down every minute or whatever, and when it hits 0 again it kills them.

If there are really a lot of NPCs it might be more efficient to make an array of values instead of using one game variable for each...but you should be able to make that system work for one or two of them, then get help converting it to use an array.
you don't even need common events for this.

from the context I assume that this "killing" NPCs is simply changing the event pretending to be the NPC to an event page without sprite, making it invisible.

So you need only one event on the placement position that checks for the possible placement (for example with select item), then checks the time and if the time is up turns a switch to remove the NPC.

How to do that depends on how you define your time, which is something you didn't describe.
but no matter what you define as time, it will be a value inside a variable and that can be checked.
ATT_Turan, Andar, thank you for your ideas!!! I think I'll try to make it work with the Common Event. Nevertheless, I'll experiment with time as well.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-the-code-for-the-event.167433/