In-Game advent calendar (Tutorial)

INTRO:

Inspired by the amazing advent calendars on the forum, I want to show you how you can easily make an in-game advent calendar, where your players can collect a new reward once a day, in december.

I made a way more complicated system for an advent calendar in my card game, but I will keep it short and simple. We will use some javascript in this tutorial, but it will be just a tiny bit and you can just copy-paste the script call from my example. You can still follow this tutorial if you know absolutely nothing about javascript.

In theory this should work for MZ as well.

REQUIREMENTS:

For this tutorial we need the following:
  • 1 variable
  • 1 event or common event the player can reach and trigger easily
  • 31 rewards
Spoiler: About triggering the (common) event
In MV, I use a plugin by Yanfly to trigger a common event every time the game is loaded, but if you don't have a plugin like that, you can give the player an item, lets say an advent calendar, which will trigger the common event on use. Or you can make an object on the world map, lets say an advent calendar, which will trigger the common event when you interact with it. You know what? I will show you how to make a fully functional advent calendar and I will leave the trigger to your imagination.

What is MMDD:

MMDD is a timestamp of 3 or 4 digits. The last 2 digits are the current date, and the other 1 or 2 digits are the current month.

We're going to use this a lot in the mini tutorial below.

Example:
0512 = May 12th
1205 = December 5th


512 = also May 12th
125 = NOT also December 5th...
125 = January 25th instead.

STEP BY STEP:

1733776599546.png


With the first condition, we check if it is even December or not.

If it is not December, you can either show them a message (if the players trigger the calendar themselves) or do nothing (if you script the trigger for the event).

In the second condition, we check if the MMDD in \v[140] is equal to the current MMDD. If so, the reward was already claimed, but if not, we claim the reward for today.

Where we claim the reward, we also put the current MMDD timestamp in \v[140]. If you would run the event again, it will have the current MMDD already saved in the variable, so the second condition will prevent todays reward to be claimed again.

For the first condition:
JavaScript:
new Date().getMonth() == 11
This simply checks if it is December right now.

For the second condition:
JavaScript:
(new Date().getMonth() + 1) * 100 + new Date().getDate() == $gameVariables.value(140)
I use variable 140, but you can change that to the id of any variable you use for this.
This checks if todays MMDD timestamp is the same as the one in the variable.

For the Control Variables command:
JavaScript:
(new Date().getMonth() + 1) * 100 + new Date().getDate()

1733776805574.png


I have removed the text messages. The mechanics are untouched.

I did add a few conditions. If MMDD = 1201, give the first reward. If MMDD = 1202, give the second reward. Etc etc. You can add a message here, show some pictures, sing them a song. Whatever you want to do to dress up your calendar.

We place this in the condition where it is indeed December, and the current timestamp is NOT equal to the old timestamp.

Do this AFTER updating the DDMM in variable 140. This is important, otherwise the first day you get nothing, and every other day you get yesterdays reward.

This is all. If you want, you can start dressing your advent calendar up. What it will look like, is all up to you. I just told you how it works.

But if you think this is to simple, or you're just too lazy to give all the rewards manually, keep reading step 3!

1733778023848.png


If your rewards are items, which have upgoing ID's, you can use this script call to automatically give the right item to your player.

In my example, the reward for december 1 is item 21, and dec 2 is item 22, dec 3 is item 23. etc etc. Change my 21 to the item id of your december 1st reward.

And just like before, change the 140 to whatever variable you choose to use to store MMDD.

Script call:
JavaScript:
var itemId = 21 ; //replace this with this id of the reward for 1 december.
var mmddId = 140 ; //replace this with the id of the variable you stored MMDD in.
$gameParty.gainItem($dataItems[$gameVariables.value(mmddId)-1201+itemId], 1);

Well, that was it! No need for 31 conditions, or 31 commands to give a reward. Now you can dress it up with an animation, theatrical music or you shouting: "MERRY CHRISTMAS!". Do whatever you feel is needed to make this the coolest advent calendar ever!

THANKS FOR READING!

I know it is a little late for this years advent and Christmas games, but it can also be used in regular games, just to have a little extra in your game during the december month.

Happy holidays everyone!

(Last comment... I wrote this after a day of work, and I'm tired. But I've tested everything and everything works just fine for me. But if I somehow forgot to explain something, or rushed over a detail as if it was something obvious, let me know.)
what a clever idea... i really enjoy the meta-level of this Advent Calendar contribution!
what a clever idea... i really enjoy the meta-level of this Advent Calendar contribution!
I think that is the passion. I love writing directly to people on a personal level, with some silliness here and there.

To be honest, I don't use tutorials that much, or at all, so I have no clue what they are supposed to look like.

I'm glad you enjoyed it.
I do see 2 issues, 1 more.

when using the mini javascript, it gives items 21 always?
what if you have an array instead of 7 possible items you can get at random?

what if they miss a day? (by reward on day 1, 2, 3 (you miss a day), you start at day 1).
there are ways to make it nicely, but I do love this advent part, specially if you only
have fixed days.

I can make this kind very easy with my base, as my variables do it, so the checks
are slightly easier, but still, without plugins, this is really cool idea 🙂

without plugins, common event can be triggered on a location (like a calendar) on the wall.
so it's fully evented that way 🙂

Nice and clear tutorial.
I do see 2 issues, 1 more.

when using the mini javascript, it gives items 21 always?
No, it gives item 1 on day one, item 2 on day 2. So in December, you get 31 different rewards, if you play every day.

what if you have an array instead of 7 possible items you can get at random?
Oh yeah, you can make plenty variations to randomize the rewards or something. But is that needed for an advent calendar. After all, they can get each reward only once a year. So it's not like they keep getting different loot every time.

what if they miss a day? (by reward on day 1, 2, 3 (you miss a day), you start at day 1).
there are ways to make it nicely, but I do love this advent part, specially if you only
have fixed days.
With my system, if they miss a day, they miss that reward. They don't go back to reward 1. The reason for this is simple: rewards are bound to the date. The Christmas reward should be given dwc 24th or 25th, and the new years reward on December 31st.

I can make this kind very easy with my base, as my variables do it, so the checks
are slightly easier, but still, without plugins, this is really cool idea 🙂

without plugins, common event can be triggered on a location (like a calendar) on the wall.
so it's fully evented that way 🙂

Nice and clear tutorial.
Thanks mate
looking closer, it subtract 1201 first, than add up 21, I kind of miscalculate
this part, as it would be 1 + 21 after (whatever the item start it.)

it's at least very user friendly, to the point.

but separately, or duplicate with slightly different setting, you can do day of
5, 24,25,31 (31 between time 23:xx and 23:59 for quests) or treasure hunt
for that day only, otherwise, come back later 😛

so a few more idea's for the readers 😀
Yeah, you can use the MMDD for many things, like seasonal events.

This is also a large part of my clock and calendar system. (That uses the MMDD method as well.)

Edit: Oh wait, I see what you mean now. You want to add a second variable to the system with a HHMM value. And use that on certain days.

Yeah, that would be the next step, right? 😛 Because that is exactly what my plugin does. Only now we use it with the actual time, not an artificial in-game clock.

The system is local, btw!! So someone in America will see midnight new-years eve in-game when it is new-years eve in their region, while someone in Europe will see it hours earlier... And someone in Asia will see it even earlier.
If anyone turns out to make an advent calendar with this tutorial, I invite you to record a bit of gameplay, showing of your version of the advent calendar. How did you dress it up? With pictures? Or animations? Or audio effects? Or all of them? And how does it trigger? Do you give your player an item they can use, or do you trigger it with a parallel event once a day? Or do you use a plugin to trigger the advent event?

If you would, for no reason at all, record that and put it on youtube, I would love to see what you made. And, with your permission, add it to the post as a fun example of what can be done with it.

The thing is... The post... It isn't very festive. It could use some "HO HO HO!" and "Merry Christmas" and... and... "Jingle Bells". You know... Festive stuff.

Like... I can do it myself... I have the assets, bought some like 2 years ago, including all the Christmas tunes, and I always remember halfway december that I have that stuff... But I am lazy... And if you are going to make that advent calendar anyway... It's a win-win! For me. (I get to see what you made, and I don't have to do the dirty work myself). See, I like to build things, but I don't enjoy dressing things up. Other people like to dress what I have build up, and that might be you.

Anyhow... Long story short... I like to see a recording of your advent calendar, and with your permission I will post it under the main post.
I'm testing it with 1 of my main function to game boot, when game it loaded,
it shows the time and date (with my getTime function.

so I can go many ways, so time - 2 (to get a new reward in 22 hours).
if 24 hours passed, you miss the reward 😀.

it's just a simple show text, but I might have a way to dress it up and might use
it in my actual game if a certain date is reached 🙂

Original thread: https://forums.rpgmakerweb.com/threads/in-game-advent-calendar-tutorial.173793/