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:
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()
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!
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.)
本贴来自国际rpgmaker官方论坛作者:JohnDoeGames处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/in-game-advent-calendar-tutorial.173793/