MOGHunter's Time System: Increasing a Variable Value by 1 and Only 1

Status
Not open for further replies.

Djajapena

Villager
Member
Joined
Oct 28, 2017
Messages
17
Reaction score
5
First Language
Indonesia
Primarily Uses
RMMV
As the title said, I have not figured a way to increase a variable value by 1 and only 1 in a specific in-game hour.

What I Want:
The concept is a farming game where the player can choose to not sleep and doing all-nighters as many as they want... until the debuff/passive state makes them a zombie farmer or some sort. While doing all-nighter the player will accumulate fatigue points. If they accumulate enough, at 6 AM in-game time morning a variable will be increased by one. A state then will be applied based on the value of that variable.

The Problem I Got:
The Variable's value increased too many, the player straight up become zombie farmer after one nighter.

What I Did:
I made three parallel Common Events:
1. Counting fatigue points if the player does an all-nighter.
2. Enabling a switch for 6 AM check at 5 AM.
3. Increase a variable and determine which state/passive will be applied to the player at 6 AM,
then disable the check switch. Screen capture included.

Adding and removing the plugin command still didn't give me the desired result. Moving switch-off below the "enable_time" didn't work too.

Plugins Used in This Project:
- Yanfly Core
- DKTools
- DKTools Localization
- Yanfly Auto Passive States
- Yanfly Passive Cases
- MOG Actor HUD
- MOG Time System
- MOG Time System HUD
- Ventiqu Single Actor
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,087
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
A few things~
  1. The script condition is incorrect: = is used to assign values, use == or === for comparison. Technical details can be found here: Comparison Operators (MDN). Try this script condition instead:
    JavaScript:
    !$gameActors.actor(1).isStateAffected($gameVariables.value(5) + 3)
    The ! is the NOT operator, it converts true to false and false to true. The statement itself means:
    Is actor 1 not affected by the state with ID equal to (3 plus the value of variable 5)?
    There's no need for a comparison, since isStateAffected already returns a true/false value. :kaopride:

  2. Parallel events will trigger repeatedly while active (generally once per frame). This means that while the event is active, hour = 6, and fatiguePointAccumulate > 299, then fatigueState gets +1 per frame. But at that stage, the event only turns off if that scripted branch condition is met! :kaoback:

  3. Since this event is Parallel, turning off its switch will immediately disable it, ending the event at the current command. This means that the actor refresh Script command and the enable_time Plugin Command immediately after it will never run. :kaoswt:
If the switch is getting turned on at hour 5 (why not hour 6?), maybe try rearranging your event to something like this:
Code:
◆If:hour = 6
  ◆If:fatiguePointAccumulate > 299
    ◆Plugin Command:disable_time
    ◆Control Variables:#0005 fatigueState += 1
    ◆If:Script:!$gameActors.actor(1).isStateAffected($gameVariables.value(5) + 3)
      ◆Script:$gameActors.actor(1).refresh();
      ◆Plugin Command:enable_time
      ◆
    :End
    ◆
  :End
  ◆Comment:Do once~
  ◆Control Switches:#0021 refreshActor = OFF
  ◆
:End
:kaophew:
 

Djajapena

Villager
Member
Joined
Oct 28, 2017
Messages
17
Reaction score
5
First Language
Indonesia
Primarily Uses
RMMV
Ah... so the problem is my flawed logic. The suggested event structure works just like what I want. Thanks!

I set one parallel common event to enable check switches an hour before the process common events (Fatigue Check, Crop's Water Level Reset, Foraging Items Respawn, etc).

Code:
◆If:hour = 5
  ◆Comment: Refresh Actor at 6
  ◆Control Switches : #0021 refreshActor = ON
  ◆
 :End
◆If:hour = 5
  ◆Comment: Reset crops' water level at 6
  ◆Control Switches : #0022 waterReset = ON
  ◆
 :End
◆If:hour = 3
  ◆Comment: Reset foraging items at 4
  ◆Control Switches : #0023 forageReset = ON
  ◆
 :End
I do this because I'm afraid the switches will always be "on" if I enable them at the same hour the process common events executed. Is my logic on this also flawed?
 

Annwfn

Veteran
Veteran
Joined
Nov 6, 2019
Messages
51
Reaction score
5
First Language
Romanian
Primarily Uses
RMMV
Hello, glad your problem was solved! Can you put a picture of how you put the "If: Hour = 5" in event command lines (a picture of the event itself with the time-checking conditional)? Been having trouble with this part for a long while. Thank you!
 

Djajapena

Villager
Member
Joined
Oct 28, 2017
Messages
17
Reaction score
5
First Language
Indonesia
Primarily Uses
RMMV
@Annwfn you mean like this?

I customized the MOG_TimeSystem's parameters to suit my project. I check the variable where the plugin store the "Hour Variable ID" (In my case, variable 1 that I labeled "hour").

 

Annwfn

Veteran
Veteran
Joined
Nov 6, 2019
Messages
51
Reaction score
5
First Language
Romanian
Primarily Uses
RMMV
Wait, you're using MOG's timer and you use variables to check on the timer? I used to do this, but variable incrementation didn't seem to match it (incrementation of the variables seems to be faster through Common Events, almost 50% faster than through Parallel Event). How exactly does one set this up?

<> I created a personal "timer" that functioned by incrementing a variable alongside Yanfly's timer system, in an attempt to match Yanfly's timer. The timer I created was based on Event Timer Countup script. put by increase by 1 second every 12 frames. My "timer" variables also incremented every 12 frames. My variables were always faster O.O
 

Djajapena

Villager
Member
Joined
Oct 28, 2017
Messages
17
Reaction score
5
First Language
Indonesia
Primarily Uses
RMMV
Well, MOG already set a variable parameter to store the game hour and there's no difference there.

For Yanfly's Timer, personally, rather than storing them as a variable I prefer to check "what is the current second now". For example, I have another project where I use Yanfly's Timer as an in-game clock. To change the screen tint in that project I made this parallel common event:


I set the variable 1 (timetint) to store the timer's second. I switched to MOGHunter Time System because I haven't managed to make the Yanfly's Timer run/count twice as fast.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,087
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
I set one parallel common event to enable check switches an hour before the process common events (Fatigue Check, Crop's Water Level Reset, Foraging Items Respawn, etc).
Oh I see, it's just a different Parallel event. I'm not familiar with Mog's plugin, I thought maybe it had a special auto-switch feature or something. :kaoslp:

Note that when it comes to events, RMMV is technically single-threaded: it processes each event interpreter in sequence. This means that in terms of CPU/RAM usage, one Parallel event is actually very slightly better than multiple Parallel events. :kaoswt:

As such, you might want to consider having one Parallel event to handle everything. You could still have the separate processes in their own events, though, e.g.
Code:
◆Comment:This common event has Trigger: Parallel.
:       :It calls other common events with Trigger: None.
:       :Just to keep things nice and organised!
◆Common Event:Update Fatigue
◆Common Event:Update Forage
◆Common Event:Update Weather/Tint
◆Comment:Run 60/12 = 5 times per second...
◆Wait:12 frames
Note I've also added a Wait command at the end here, since I'm assuming you don't need this to run every single frame~
 

Annwfn

Veteran
Veteran
Joined
Nov 6, 2019
Messages
51
Reaction score
5
First Language
Romanian
Primarily Uses
RMMV
I have seen the Variable for hour, thank you for reminding me of its existence. I was using the Scripts to check for time ($gameTime.minutes() and the one for seconds and hours, however, they seem to disregard the timer). I need to address the minutes issue, see how I can solve that. Once done, I have dealt with one of the main pain points of my game.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,838
Reaction score
5,222
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,986
Members
137,561
Latest member
visploo100
Top