Optimization Check

● ARCHIVED · READ-ONLY
Started by Jeremiah Eastman 8 posts View original ↗
  1. Hey there gang, I've been looking at a parallel process that I have running in every map of my game and thinking it needs some work optimizing it. I am not sure how much of a negative affect some of the aspects may be having, like with the sound changing. This event controls tinting, due to time of day, and the changing of BGM from day to night and back. Some of them have switches which turn the zone lights on and off at certain times and a few random other things.

    I was really hoping someone could take a look at my basic parallel and see if you see any problems, especially frame drop related as I want the parallel to be as non intrusive as possible, while still basically doing what it does now. Also a big thanks to anyone that takes a look it's much appreciated. As you can see in the pic there's more you can scroll down to, all that is down there is a Wait 120. It's fairly straight forward, one branch checking if its night or day, then things inside that condition.

    Thanks for taking a look.:smile:

    1.jpg
  2. A parallel event is going to continue to run that code EVERY single frame. I would suggest throwing a "wait x frames" at the bottom of that.
  3. Yeah I have a wait 120 at the bottom that didn't get shown in the pic, but I wasn't sure if the fact that it was redoing mainly the audio steps would cause an issue. Thanks for taking the time to have a look there bud, I appreciate it.
  4. How long (in frames) is each "hour"?

    I would suggest to change the wait time so that the event is running exactly at every hour. The reason is that you don't care if it's 15:30, but you do care if it's 16:00 which is when the lights come on.

    The next suggestion is to change the >= and <= to just = and reformat where necessary. At 16:00 it needs to turn the lights on and play the Night BGS, but at 17:00, 18:00, 19:00, etc. you don't need to play the Night BGS because it's already playing. Basically the mantra of any parallel process is to only use it when it's needed.
  5. Each hour is 60 frames, 1 per second. With running exactly on the hour what happens if I zone into the map then at say 9:30 pm, would it still set everything even though it is set to run at 9:00 and 10:00? I was of the understanding it wouldn't fire the command then until 10:00.

    I can see changing the greater than or equal to if the above is correct but the less than 1 or equal to was just for protection against something locking it up if it somehow gets changed to a negative at some point. Thanks for the info I really hope you are right about the not needing the in between hours, that would help clean things up a good bit.
  6. Oh so the game-day is only 24 real-seconds long?

    Then your wait command could only be 60 frames at the maximum, 120 is too long. For example your existing condition of Hours == 15 won't trigger because the event (in the first post) is only executing every other hour (0, 2, 4, 6 etc.)

    The answer still depends on your setup:
    Does the lighting only change on some maps and not others?
    Does the clock only advance on some maps and not others?
    What controls the clock - another parallel map event, a parallel common event, or a plugin?
    Syncing these things across multiple sources is tricky.

    In an ideal world I would set it up like this with all Common Events (of course you might have additional restrictions that doesn't allow you to do it this way).
    Now, the clock is implicitly synced with the lighting and audio.
    • Common Event 1 (Master controller)
      • Parallel trigger
      • Every frame, calls the Clock controller
      • Every 60 frames, calls the Lighting controller if the current map is eligible for Lighting (maybe caves are not affected by outside light)
      • Every 60 frames, calls the Audio Controller if appropriate
    • Common Event 2 (Clock Controller)
      • No trigger
      • Called by Master controller every frame
      • Every frame, increases the Minutes variable by 1
      • Every 60 frames increases the Hours variable by 1 and sets the Minutes variable to 0
    • Common Event 3 (Lighting controller)
      • No trigger
      • Called by Master controller every 60 frames
      • Checks the current hour (using equals comparison) and tints the screen
    • Common Event 4 (audio controller)
      • No trigger
      • Called by Master controller every 60 frames
      • Checks the current hour (using equals comparison) and plays the appropriate audio
    Last thing is for any transfer events into the lighting eligible maps to call the Lighting controller and Audio controller common events (as a one-time call) so if they transfer in at 21:30 then they'll get the lighting/audio of 21:00 for the next half-second until it changes to 22:00
  7. No that's my bad an hour is 1 minute in the game. The time is controlled by a common event parallel process and every map has tinting affected by the time, the clock is active everywhere and the light switch is only on some maps, that's for like torches and fire pits.

    So for your examples I already have common event 1 and 2 but they are combined in 1 common event and the tinting controller is in the map events. The other 2 common events you have are whats contained in a single event in each map currently. Think I got it all I'll try it out thanks much for diagramming it, much appreciated.:smile: Sorry again about the misunderstanding with the length of my hour.
  8. 1 Minute per 60 frames sounds much more reasonable haha. Otherwise as a player, if I sneezed I might miss the opening hours for a shop!

    Sounds like you got a good handle on it now. Remember the strategy for optimization is "do whatcha gotta do when you gotta do it, but not more often" (it's a very fancy sounding strategy, I know). I often diagram out this stuff on paper using boxes/arrows/etc. to keep myself organized.