Help with a timer/calendar mechanic

So, I’m working on a game idea that’s been on my mind for a while. Just having some trouble getting certain mechanics working the way I want. I’m using MZ and Yanfly Plugins, if that helps.

Basically, the game takes place over 30 days, if the objectives haven’t been completed by the end, then the player gets a game over/bad ending. A day moves forward when either enough time passes (I’m think about 15 minutes at this point), when a certain number of party members have been knocked out, or the player can manually end the day through the menu.

I have a common event that moves a counter forward/heals/transports the player back to base (along with other things). That's working perfectly (for now), the only problems I have at the moment are about triggering the event.

I'm not too sure how to work the MZ timer, it just starts up a countdown and not much else, doesn't seem to even wait for it to stop before proceeding through the event. Is there anyway I could implement a timer, so that after a timer is triggered and runs down, it will trigger the event, regardless of where the player is?

I’ve almost got the second method down, where each time something is knocked out, it increases a counter, and if the counter is at its limit runs an event to abort the battle, then an event on the map ends the day. Of course, I need to edit to trigger so it only counts party members, so the day doesn’t end after the first few random battles.

Screenshot 2023-09-30 163950.png
Screenshot 2023-09-30 164056.png


Also, as I have a mechanic that lets you temporarily remove party members to perform certain tasks, I’ll guess I’ll need something for party wipes. Are there any plugins/codes that run the event instead of giving a game over when wiping out?

Not exactly sure how to make the menu option work, is there any way to add a menu option and make it run a common event? I've had a look in Yanfly's Main Menu Core, but a lot of that went right over my head.

If anyone can please help out or point me in the right direction that be great.
your first problem is that your screenshots of the events are incomplete.
you only give us the content of the events, completely missing the equally important event properties - and it's often the properties (triggers, conditions, page numbers) that determine how an event really works.

And then you're missing several basics.

Time systems are usually evented and do NOT use the default timer. instead you have parallels that are counting waits to determine the base time progress.

please give complete screenshots and we can help you try to implement that mechanic.
Thanks for the reply. Sorry, I was a bit vague with my post. The screenshots are the notes in the death state and a common event that ran as a counter, so they have no triggers and there's nothing else below the cutoff of the common event. They're running fine as is, what I was asking for was there any line of code I can add to the note box/event so that it only counts when a party member is inflicted with the death state.

Like I said, I'm not too sure about how to go about with timer, so I don't really have anything to post. I've gave the wait option a test, but its max setting is about 15 seconds (though I guess I could loop them and use a counter). But I was looking more for a universal timer, one that started when the player entered certain areas and kept counting down in other maps (though not in battles/cutscenes).

I've got around the menu problem by creating a menu-only skill that ends the day. It does feel a bit clunky and I would want it in the menu and not buried in a skillset, but it does what I want for now so I'll cross that bridge when I get to it.
I've gave the wait option a test, but its max setting is about 15 seconds (though I guess I could loop them and use a counter). But I was looking more for a universal timer,
you didn't think this through, because the wait is how you do that exactly.

first, you use a common event parallel to have the time work everywhere.
then you need to count small waits - wait 5 frames or so - becvause a map transfer resets the common events and will loose any waitframes during that time.

third, you count up and not down - you store the current counter in an additional variable and add how much time you want to wait, then compare current count to that stored+ count until you reach the number you want.
Visustella main menu core has an example addition to menu commands where it runs a common event when you select it.

Visustella battle core you can run code at party defeat and also a common event when you return to map after defeat. If you add 1 hp to your actors with that code at party defeat, it doesn't go to game over.
For example: $gameActors.actor(1).gainHp(1);

For the timer you can count the time with a parallel event variable that adds 1 and then waits some time. And then just check the variable value.
Thanks. I did fumble around with the main menu core for a while but I couldn't figure it out. The menu was more for playtesting (when I get to that stage) so what I've done will work for now. I can always come back and fix it up.

Cool, will have to look into the Battle Core a bit more then, I'll see what I can do.

Yeah I might go with the wait timer/variable idea. I guess if I have a trigger on each map it would work, it'll probably solve the fact that I don't want it to tick down in battles/cutscenes too.

Only thing left to fix is making the death counter to only count party members.
t'll probably solve the fact that I don't want it to tick down in battles/cutscenes too.
no need for battles - all scenes (including battlesscene) automaticaly stop all parallels.

and no need for handling the switch on every map either, switches don't change unless commanded - so you only need to tunr off the switch at cutscenes and on after them
The main menu core options are in the command window list plugin settings. There's a ready made option for a common event menu option. In the settings change JS: Show and JS: Enable to: return true; And then change JS: Ext to return (your common event id);

If you're fine with your KO counter, I think you can use a script "battler.isActor()" to check if the one who's being affected by the state is an actor. So you'd add a conditional with a script: target.isActor()
and then put your variable increase inside that conditional.
no need for battles - all scenes (including battlesscene) automaticaly stop all parallels.

and no need for handling the switch on every map either, switches don't change unless commanded - so you only need to tunr off the switch at cutscenes and on after them
you didn't think this through, because the wait is how you do that exactly.

first, you use a common event parallel to have the time work everywhere.
then you need to count small waits - wait 5 frames or so - becvause a map transfer resets the common events and will loose any waitframes during that time.

third, you count up and not down - you store the current counter in an additional variable and add how much time you want to wait, then compare current count to that stored+ count until you reach the number you want.

Okay, I see what you mean now. That's 100 times simpler than what I was trying to do. So when want the timer to start just turn on the switch and when I want it to stop just turn it off. I do feel like a second is a short enough period, or should I shorten it even more?

Day Timer.png

If you're fine with your KO counter, I think you can use a script "battler.isActor()" to check if the one who's being affected by the state is an actor. So you'd add a conditional with a script: target.isActor()
and then put your variable increase inside that conditional.

So this is what I've done for the defeat event, it's in each characters' notetag. It kicks the party out of the battle when defeated, heals the party to avoid a game over and increases the variable to trigger the end of day event.

Defeat Event.png


Well I think that fixes all the problems I have for now, if anyone sees any problems with anything please let me know. Thanks for all the help guys 🙂
I do feel like a second is a short enough period, or should I shorten it even more?
depends on what you do with your timer and how often the player needs to change maps.
60 frames means that the player can hold the countdown by stepping between maps every 50 frames, because the map transfer resets to zero before the sixty frames are past.
If you have any mechanic where that would become critical, then you should indeed go down to a much smaller base wait like the 5 frames I mentioned.

that said, remove the loop from the parallel - parallels automatically loop and having one loop inside another can mess up the timing as well - not in this specific case, but it would introduce problems for more complex parallels

Original thread: https://forums.rpgmakerweb.com/threads/help-with-a-timer-calendar-mechanic.161610/