//============================================================
// Z O M B I E   T O R R E N T   2   -   J J   J A M
// Coded by Zedek the Plague Doctor, slot machine example
//============================================================

#library "jellyfish"
#import "slotcards.acs"
#include "zcommon.acs"

// Add the actual card
script 895 OPEN
{
	// Let the original cards load
	delay(1);
	// Add a test card
	AddSlotCard("Jellyfish Jam",0,"SLOTJELY",896,2,"How can you have fun with a jellyfish?","slot/win");
	// Show an effect on the screen
	AddEffect("EFFJELLY","PowerJellyfish");
}

// SCRIPT 81: PICK A NEW SONG

// What happens when this slot is rolled (MAKE SURE THIS SCRIPT IS NET)
script 896 (int caseID) NET
{
	
	// We can use a switch to have multiple slots in one script
	switch (caseID)
	{
		// Give the player a card and junk
		case 0:
		{
			// FOR ALL PLAYERS
			for (int l=0; l<PlayerCount(); l++)
			{
				SetActivator(1000+l);
				GiveInventory("PowerJellyfish",1);
				ACS_ExecuteAlways(897,0,0,0,0);
				ACS_ExecuteAlways(896,0,1,0,0);
			}
			
			break;
		}
		
		// serverside, music
		case 1:
		{
			SetMusic("");
			AmbientSound("jellyfish/jam",127);
			
			// Do this once a second
			for (int m=0; m<35; m++)
			{
				Delay(35);
				SpawnSpotForced("Jellyfish",201,878,0);
				SpawnSpotForced("Jellyfish",202,878,0);
				SpawnSpotForced("Jellyfish",203,878,0);
				SpawnSpotForced("Jellyfish",204,878,0);
				SpawnSpotForced("Jellyfish",205,878,0);
				SpawnSpotForced("Jellyfish",206,878,0);
				SpawnSpotForced("Jellyfish",207,878,0);
				SpawnSpotForced("Jellyfish",208,878,0);
				SpawnSpotForced("Jellyfish",209,878,0);
			}
			
			// FOR ALL PLAYERS
			for (int n=0; n<PlayerCount(); n++)
			{
				SetActivator(1000+n);
				TakeInventory("PowerJellyfish",1);
				ACS_Terminate(897,0);
			}
			
			ACS_ExecuteAlways(81,0,0,0,0);
			Thing_Destroy(878);
			
			break;
		}
	}
}

// Some rave shit
script 897 (void)
{
	int R;
	int G;
	int B;
	int canFade;
	
	while (!canFade && CheckInventory("PowerJellyfish"))
	{
		LocalSetMusic("");
		canFade = 1;
		R = Random(0,255);
		G = Random(0,255);
		B = Random(0,255);
		FadeTo(R,G,B,0.5,0.5);
		Delay(8);
		LocalSetMusic("");
		FadeTo(0,0,0,0.0,0.5);
		Delay(8);
		canFade = 0;
		delay(1);
	}
}