Dynamic Music 2.0

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
ImpieTwo
Posts: 912
Joined: Sun Aug 16, 2015 11:52 pm

Dynamic Music 2.0

Post by ImpieTwo »

I posted about this a year or two ago and never came to a proper solution, but recently Eradrop shared a cool new project, Hide and Seek, which actually uses a form of dynamic music.

The way his works: the script triggers several events in order, starting with switching the music from "Relax" to "Fight" using SetMusic, then after a delay of 3000 tics the music changes back to the standard theme on its own. This is almost like how it's done in IM Meen for DOS, where the battle theme is triggered and plays for a limited time before changing back.

The thing I have in mind is tougher: once the script activates, it keeps checking until the tagged ambush monsters are dead. If they are, it changes the music back, else it keeps looping. I'm not experienced with ACS scripting apart from a few things I learned with conversation trees here on the forum, so I don't know how to translate the idea into a script. If someone can walk me through that, I'm more than capable of tweaking and testing 'til I get something that works well enough for others in the community to use at their leisure.

I'm also wondering if there's a way to have it check to see if the script is already executed, so if the battle music is already playing, it ignores any additional activation attempts.
ImpieTwo
Posts: 912
Joined: Sun Aug 16, 2015 11:52 pm

Re: Dynamic Music 2.0

Post by ImpieTwo »

This is why I'm always asking for help. I dunno why this script doesn't work. It keeps highlighting the "else" case but doesn't tell me why.

Code: Select all

Script 1 Enter // => Starting Script.
{
    SetMusic("SniperC", 0, 0);
}

Script 2 (void) // => First sniper fight.
{
	Thing_Activate(100);
	SetMusic("SniperF", 0, 0);
	
	While(ThingCount(0, 100) > 0)
	{
		Delay(1);
	}
	else
	{
		SetMusic("SniperC", 0, 0)
		terminate;
	}
	
}
User avatar
Rachael
Posts: 13571
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Dynamic Music 2.0

Post by Rachael »

There is no "if" for the "else". Simply take the SetMusic() out of the else {} and don't even bother with the terminate - you don't need it.
ImpieTwo
Posts: 912
Joined: Sun Aug 16, 2015 11:52 pm

Re: Dynamic Music 2.0

Post by ImpieTwo »

Rachael wrote:There is no "if" for the "else". Simply take the SetMusic() out of the else {} and don't even bother with the terminate - you don't need it.
Ahh, okay so it basically keeps checking on its own, and continues once the "while" parameter is met.

Except now it's flagging the stuff at the beginning o the script, before the "while" state. Didn't i type all that correctly?
User avatar
Rachael
Posts: 13571
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Dynamic Music 2.0

Post by Rachael »

Code: Select all

Script 1 Enter // => Starting Script.
{
    SetMusic("SniperC", 0, 0);
}

Script 2 (void) // => First sniper fight.
{
   Thing_Activate(100);
   SetMusic("SniperF", 0, 0);
   
   while(ThingCount(0, 100) > 0)
   {
      Delay(1);
   }
   SetMusic("SniperC", 0, 0)
   
}
Something like this, I think. ("while" may be case sensitive, I can't remember if that's the case for ACS)
ImpieTwo
Posts: 912
Joined: Sun Aug 16, 2015 11:52 pm

Re: Dynamic Music 2.0

Post by ImpieTwo »

Rachael wrote:Something like this, I think. ("while" may be case sensitive, I can't remember if that's the case for ACS)
You might be right, cos else and if are always lower-cased. Weird. I'll give that a try.

EDIT: Nope, it's still pissed at the stuff before the while case.
Last edited by ImpieTwo on Sun Aug 06, 2017 9:32 pm, edited 1 time in total.
User avatar
Rachael
Posts: 13571
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Dynamic Music 2.0

Post by Rachael »

I don't know, then. >_<
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: Dynamic Music 2.0

Post by Ed the Bat »

It is recommended that you not give SetMusic a third parameter. In fact, since your second paramter is 0, that's redundant to begin with.
ImpieTwo
Posts: 912
Joined: Sun Aug 16, 2015 11:52 pm

Re: Dynamic Music 2.0

Post by ImpieTwo »

Figured it out finally. I forgot the damn "include" for common acs commands. Now it's working.
Nevander
Posts: 2254
Joined: Mon Jan 06, 2014 11:32 pm

Re: Dynamic Music 2.0

Post by Nevander »

Also this

Code: Select all

while(ThingCount(0, 100) > 0)
{
   Delay(1);
}
can be reduced to

Code: Select all

while(ThingCount(0, 100) > 0) Delay(1);
Just a cosmetic thing but it helps me with visualization of a script. Note you can only do this with single actions inside a block. Two or more actions require the block.
Locked

Return to “Editing (Archive)”