Status
Not open for further replies.

Mercedes90

Veteran
Veteran
Joined
May 7, 2021
Messages
105
Reaction score
27
First Language
English
Primarily Uses
RMMV
I've been trying to make a parallel event that randomly plays BGM.​
But the problem is that they play only for a minute and then fade out even though the song is longer than that.​
Secondly, I've tried to do Switches so that the BGM event will deactivate when interacting with certain events (common events) and re-activate again when the Player stops interacting with certain events, but no luck.​
I also want the random BGM event to work on one map only.​
Much appreciated for the help.​

1.png
EDIT:​
This is for MV, not MZ.​
I've chosen the wrong thread path.​
 

Mercedes90

Veteran
Veteran
Joined
May 7, 2021
Messages
105
Reaction score
27
First Language
English
Primarily Uses
RMMV
Yes, I'd also like to have randomly timed pauses in between the random BGM's. And the BGM Parallel must be Switched Off after the Player interacts with a few certain events whether the music is being played or not. And the Parallel should activate again when the Player is done with certain events (which are in the "common events").

Click on the "Report" button for the post.

Done.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
965
Reaction score
470
First Language
PT-BR
Primarily Uses
RM2k3
As to whether the BGM has come to an end then it's not really the difficulty.
Try using Loop, I can't test it now, but see if it works:
Code:
<>Op. Variable #0010 BGM, radom 1..5
<>Fadeout BGM: 2 Seconds
<>If: Variable BGM = 1
    <>Play BGM: Song 1
      <>
:end if
<>If: Variable BGM = 2
    <>Play BGM: Song 2
      <>
   :end if
<>If: Variable BGM = 3
    <>Play BGM: Song 3
      <>
:end if
<>If: Variable BGM = 4
    <>Play BGM: Song 4
      <>
:end if
<>If: Variable BGM = 5
    <>Play BGM: Song 5
      <>
:end if
<>Comment: ============ Wait Player ===========
<>Loop
    <>If: Switch: OFF
        <>Break
        <>
    :end if
    <>Wait: 200 fps
    <>
:end Loop
<>Comment: ============= End Song =============
<>Play BGM: Stop

If you want to end this event you have to use a Switch to start it too, if not, when you finish, you will draw the variable again.
 
Last edited:

Mercedes90

Veteran
Veteran
Joined
May 7, 2021
Messages
105
Reaction score
27
First Language
English
Primarily Uses
RMMV
When you said "Cycle", did you mean the "Loop" command?
I followed the instructions, but it didn't work any better.
Also, the game became laggy, low fps, and it crashed twice.
It seems like having Loop commands as a parallel is not a good idea.

12.png
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
965
Reaction score
470
First Language
PT-BR
Primarily Uses
RM2k3
When you said "Cycle", did you mean the "Loop" command?
:LZSwink: :thumbsup-left:

Also, the game became laggy, low fps, and it crashed twice.
Sorry, I forgot that Loop causes RMMV lag, put a wait of 200 frames inside each loop.

Tip: Fadeout must be after the variable draw, it is not necessary for each IF.

I edited my previous answer
 
Last edited:

Mercedes90

Veteran
Veteran
Joined
May 7, 2021
Messages
105
Reaction score
27
First Language
English
Primarily Uses
RMMV
Alas, no BGM plays as well as intense lag occurs again:
◆If: Stop BGM is OFF
◆Break Loop

If I switch it to "ON" the Music plays accordingly but doesn't Switch OFF when interacting with the Event that leads to various Common Events shown in the screenshots below, so you'd spot the flaws.


[SCREENSHOTS DELETED]
 
Last edited:

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
965
Reaction score
470
First Language
PT-BR
Primarily Uses
RM2k3
You need to consider that a map event in parallel process will always be looping.
2.png
 

Syberduh

Veteran
Veteran
Joined
Jul 26, 2021
Messages
31
Reaction score
18
First Language
English
Primarily Uses
RMMZ
I don't think this architecture is going to work. You have to be pretty careful with loops inside of loops. As I understand it, the event handler doesn't "stay" inside the loop waiting for 200 frames. It runs the parallel event again as soon as it can so you will very quickly have 1000s of loops waiting for the background music to stop. Loops shouldn't really be used for timing purposes, they're to process stuff that iterates.

That said, I think if you put another wait200 at the very end of your parallel event it will alleviate the immediate lag. Though I think it will probably still build up over time, it may be slow enough that the scene is playable.

I think a more robust solution is

(Page 1)
(Parallel event)
<var RandomBGM = random number>
<if RandomBGM ===1>
<Play BGM that corresponds to RandomBGM1
<Set self switch A ON>

<if RandomBGM ===2>
<Play BGM that corresponds to RandomBGM2
<Set self switch B ON>
etc.
<Wait200>

(Page 2)
(Parallel event)
(Active when Self switch A is ON)
Set timer (length of time of BGM 1)
(IF timer <= 0
Fade out BGM
Set self switch A OFF)
<Wait200>

(Page 3)
(Parallel event)
(Active when Self switch B is ON)
Set timer (length of time of BGM 2)
(IF timer <= 0
Fade out BGM
Set self switch B OFF)
<Wait200>

etc. as needed.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
965
Reaction score
470
First Language
PT-BR
Primarily Uses
RM2k3
I don't understand so much about events in RMMV, I would like to know why using this command on common events if turning off the Switch would have the same effect, or am I mistaken?
5.png

I did a simulation, see the video:

I crafted it in a visually cleaner way, see the attachments.
 

Attachments

  • 01.png
    01.png
    34.6 KB · Views: 4
  • 02.png
    02.png
    36 KB · Views: 4
  • 03.png
    03.png
    21.7 KB · Views: 4

Mercedes90

Veteran
Veteran
Joined
May 7, 2021
Messages
105
Reaction score
27
First Language
English
Primarily Uses
RMMV
@Syberduh - I've followed the code you've made, but that did only cause distortion/glitches with the timer and the wait commands. The whole process was acting weirdly. Also, the timer on the upper right corner is not something I wanna have. But thank you anyway. @Dev_With_Coffee 's new code worked smoothly, though.​
@Dev_With_Coffee - The random BGM is now working smoothly after your new code, thanks a lot!
What made it work how I wanted it was by placing "Control Switches: #0017 *BGM MUTE* = ON" commands at the beginning of the various/specific events, and then the same switch command *BGM MUTE* but rather switched to OFF at the exit processing of those same events, and the BGM started playing automatically again.​
Thanks a bunch!​
One last question;​
How do I make sure, or what is the most effective way to keep this BGM parallel event run in only 1 map? Should I use the same Control Switch commands as I did with the specific events but placing them on door-events? Or is there a better way?​
I don't understand so much about events in RMMV, I would like to know why using this command on common events if turning off the Switch would have the same effect, or am I mistaken?
Frankly, I had no clue what I was doing when turning on the "Trigger: Parallel" & "Switch: ###" in the Common Event(s). I was trying out various solutions at some points, and I forgot to turn those off. Even though the code is now working like a charm, I've still yet to learn how exactly Switches work in this engine.​
 
Last edited:

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
965
Reaction score
470
First Language
PT-BR
Primarily Uses
RM2k3
Thanks a bunch!One last question;How do I make sure, or what is the most effective way to keep this BGM parallel event run in only 1 map? Should I use the same Control Switch commands as I did with the specific events but placing them on door-events? Or is there a better way?
The event that triggers the BGM only starts once through the map event, this event does not exist in other maps, just define a different BGM in the properties of each map.

Another way would be, put the command "Play BGM..." to change a different song after the command "Transfer player..." in the output event of this map:
Code:
◆Transfer Player:Script Tester (11,9)
◆Play BGM:Field1 (90, 100, 0)

Frankly, I had no clue what I was doing when turning on the "Trigger: Parallel" & "Switch: ###" in the Common Event(s). I was trying out various solutions at some points, and I forgot to turn those off. Even though the code is now working like a charm, I've still yet to learn how exactly Switches work in this engine.
Try not to enter commands from puzzles or mini-quests with the system you created with Common Events. You can get lost with Switches and Variables.
At most, just allow them to turn off the Common Events for as long as they work and ensure that when they're done, they turn it back on.
 
Last edited:

Syberduh

Veteran
Veteran
Joined
Jul 26, 2021
Messages
31
Reaction score
18
First Language
English
Primarily Uses
RMMZ
Oops yeah the events will need some tweaking to work. Glad you found another way to make it work but this is how I would do it with event pages.

I also forgot there's no built-in way to hide the timer (which blows my mind because it seems like having a hidden timer would be a very common request). You would need a plugin or would have to edit your sprites.js manually (as I have done in the video).

Here's the final version of what I came up with (extra variable dontPlayTwice keeps a track from playing twice in a row). Each timer is set to the length of the given track:
1633297608127.png
1633297646361.png

Pages 2-5 look like this (dontPlayTwice goes up by 1 on each subsequent page and the self switch is also changed to the appropriate self switch) if you have more than 4 potential tracks you'll have to use regular switches instead of self switches:

1633297717765.png

The top page is active when your "mute music" switch is on:

1633297825052.png

The pages of the event that turns music on/off look like this. Variable BGMResumeTimer stores timer value and adds back the appropriate amount of time for the track to play when it's turned off/on:

1633297861545.png


1633297884439.png


 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,149
Reaction score
15,537
First Language
English
Primarily Uses
RMMV

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.

Latest Threads

Latest Profile Posts

Mod name: "[Game name] Gameplay Overhaul"
What they actually mean: "Here is a mod that makes the game harder."
I decided to reinstall one of my most favourite game of all times, Gothic 2. Time to get back to Khorinis!
So much game make... I needs to rest. The foods call.
-Casino with bunnysuit green check.png
1638563168795.png
Monday December 6th 2021 at 7PM Hawkzombie will stream A Thief's Voyage on his Twitch.

Hawkzombie Twitch

Check it out.​

Forum statistics

Threads
117,162
Messages
1,105,058
Members
153,249
Latest member
Jon_Doe
Top