Page 1 of 1

Item pickup and scripting help

Posted: Mon Oct 15, 2012 12:24 am
by nightshade94
I'm working on a Slenderman-type WAD and I'm trying to do something similar to the paper that changes the music when you pick it up, despite what order you pick them up up.
I use an item that I place in say, 8 different spots on the map. What I want to happen is when you pick any of them up, no matter what order, it switches to a preferred music track. Then when you pick up the 2nd item, no matter the order, it will switch to another preferred music track. If anyone is experienced with this type of thing or when I can find it, I'd appreciate it.

RE: Item pickup and scripting help

Posted: Mon Oct 15, 2012 2:50 am
by BloodyAcid
I think this works. For DECORATE, put:

Code: Select all

Actor slendernote : Inventory
{
	Inventory.maxamount (number of notes max here)
	INVENTORY.AUTOACTIVATE
	States
	{
	Use:
		TNT1 A 0 ACS_Execute(script #, map #);
	}
}
For ACS, put:

Code: Select all

#include "zcommon.acs"

script 1 (void)
{
	int notes = CheckInventory("slendernote");
	
	if (notes == 1);
	{
	SetMusic("lump name");
	}

	 if (notes == 2);
	{
	SetMusic("lump name");
	}

	  if (notes == 3);
	{
	SetMusic("lump name");
	}

	  if (notes == 4);
	{
	SetMusic("lump name");
	}

	  if (notes == 5);
	{
	SetMusic("lump name");
	}

	  if (notes == 6);
	{
	SetMusic("lump name");
	}

	  if (notes == 7);
	{
	SetMusic("lump name");
	}

	 if (notes == 8);
	{
	SetMusic("lump name");
	}

        ...
        ...
        if (notes == 99999);
	{
	SetMusic("lump name");
	}
}
Replace variables with your desired script numbers and music lump names as needed.

RE: Item pickup and scripting help

Posted: Mon Oct 15, 2012 3:23 am
by Llewellyn
BloodyAcid wrote: I think this works. For DECORATE, put:
STUFF
I'm just going to come in here and...

Decorate: Uses NOTE A-E, replace with TNT1 A if you don't want sprites

Code: Select all

Actor slenderNote: CustomInventory
{
	Inventory.maxamount 1 //Put 1 for only allow music to change once, put 999999 for every time you get a note if you plan to reuse notes for later levels
	States
	{
	PickUp:
		TNT1 A 0 ACS_ExecuteAlways(100, 0, 0)
                stop
	Spawn:
		TNT1 A -1
		stop
	}
}

actor SlenderNote1 : SlenderNote 12001 //Use 12001 in a map editor
{
	States
	{
	PickUp:
		TNT1 A 0 ACS_ExecuteAlways(100, 0, 1)
		stop
	Spawn:
		NOTE A -1
		stop
	}
}

actor SlenderNote2 : SlenderNote 12002 //Use 12002 in a map editor
{
	States
	{
	PickUp:
		TNT1 A 0 ACS_ExecuteAlways(100, 0, 2)
		stop
	Spawn:
		NOTE B -1
		stop
	}
}

actor SlenderNote3 : SlenderNote 12003 //Use 12003 in a map editor
{
	States
	{
	PickUp:
		TNT1 A 0 ACS_ExecuteAlways(100, 0, 3)
		stop
	Spawn:
		NOTE C -1
		stop
	}
}

actor SlenderNote4 : SlenderNote 12004 //Use 12004 in a map editor
{
	States
	{
	PickUp:
		TNT1 A 0 ACS_ExecuteAlways(100, 0, 4)
		stop
	Spawn:
		NOTE D -1
		stop
	}
}

actor SlenderNote5 : SlenderNote 12005 //Use 12005 in a map editor
{
	States
	{
	PickUp:
		TNT1 A 0 ACS_ExecuteAlways(100, 0, 5)
		stop
	Spawn:
		NOTE E -1
		stop
	}
}

ACS:

Code: Select all

#include "zcommon.acs"
#define S_NOTE 100 //Change to your will

script S_NOTE (int whichNote)
{
	switch (whichNote)
	{
	Case 0:
        	SetMusic("lump name0");
		break;
	Case 1:
		SetMusic("lump name1");
		break;
	Case 2:
		SetMusic("lump name2");
		break;
	Case 3:
		SetMusic("lump name3");
		break;
	Case 4:
		SetMusic("lump name4");
		break;
	Case 5:
		SetMusic("lump name5");
		break;
	}
}

RE: Item pickup and scripting help

Posted: Mon Oct 15, 2012 4:16 am
by nightshade94
Llewellyn, I;ve attempted to try it your way, and I get this message when I run the game.

"Script error, "tempmap.wad:DECORATE" line 31:
Sprite names must be exactly 4 characters"

That would be this line : "TNT1 A 0 ACS_ExecuteAlways(100, 0, 0);", which is the DECORATE for the custom inventory note. I've tried changing it to "NOTE A 0", since the sprite I'm using has a lumpname of "NOTEA0", but the message still shows.

RE: Item pickup and scripting help

Posted: Mon Oct 15, 2012 4:45 am
by Llewellyn
nightshade94 wrote: Llewellyn, I;ve attempted to try it your way, and I get this message when I run the game.

"Script error, "tempmap.wad:DECORATE" line 31:
Sprite names must be exactly 4 characters"

That would be this line : "TNT1 A 0 ACS_ExecuteAlways(100, 0, 0);", which is the DECORATE for the custom inventory note. I've tried changing it to "NOTE A 0", since the sprite I'm using has a lumpname of "NOTEA0", but the message still shows.
Sorry, the random semi-colons need to go rofl
Bad habit I have from ACS is to put semi colons after an ACS_Execute function

RE: Item pickup and scripting help

Posted: Mon Oct 15, 2012 2:50 pm
by nightshade94
Ah, thank you! It works now! The only problem is that they can't be picked up in any order or the music will play out of order, but I can have it so that a script spawns a new note each time you pick another one. Thanks!

RE: Item pickup and scripting help

Posted: Mon Oct 15, 2012 3:56 pm
by Llewellyn
nightshade94 wrote: Ah, thank you! It works now! The only problem is that they can't be picked up in any order or the music will play out of order, but I can have it so that a script spawns a new note each time you pick another one. Thanks!
Yea basically what I did is make it so you place done the note of the song that you want them to play, so they pick it up and the corresponding song plays, just make sure they're picked up in the order you want the music to play I guess.

RE: Item pickup and scripting help

Posted: Mon Oct 15, 2012 7:28 pm
by Ijon Tichy
Llewellyn wrote:
BloodyAcid wrote: I think this works. For DECORATE, put:
STUFF
I'm just going to come in here and...

Decorate: Uses NOTE A-E, replace with TNT1 A if you don't want sprites

Code: Select all

Actor slenderNote: CustomInventory
{
	Inventory.maxamount 1 //Put 1 for only allow music to change once, put 999999 for every time you get a note if you plan to reuse notes for later levels
	States
	{
	PickUp:
		TNT1 A 0 ACS_ExecuteAlways(100, 0, 0)
                stop
	Spawn:
		TNT1 A -1
		stop
	}
}

actor SlenderNote1 : SlenderNote 12001 //Use 12001 in a map editor
{
	States
	{
	PickUp:
		TNT1 A 0 ACS_ExecuteAlways(100, 0, 1)
		stop
	Spawn:
		NOTE A -1
		stop
	}
}

actor SlenderNote2 : SlenderNote 12002 //Use 12002 in a map editor
{
	States
	{
	PickUp:
		TNT1 A 0 ACS_ExecuteAlways(100, 0, 2)
		stop
	Spawn:
		NOTE B -1
		stop
	}
}

actor SlenderNote3 : SlenderNote 12003 //Use 12003 in a map editor
{
	States
	{
	PickUp:
		TNT1 A 0 ACS_ExecuteAlways(100, 0, 3)
		stop
	Spawn:
		NOTE C -1
		stop
	}
}

actor SlenderNote4 : SlenderNote 12004 //Use 12004 in a map editor
{
	States
	{
	PickUp:
		TNT1 A 0 ACS_ExecuteAlways(100, 0, 4)
		stop
	Spawn:
		NOTE D -1
		stop
	}
}

actor SlenderNote5 : SlenderNote 12005 //Use 12005 in a map editor
{
	States
	{
	PickUp:
		TNT1 A 0 ACS_ExecuteAlways(100, 0, 5)
		stop
	Spawn:
		NOTE E -1
		stop
	}
}

ACS:

Code: Select all

#include "zcommon.acs"
#define S_NOTE 100 //Change to your will

script S_NOTE (int whichNote)
{
	switch (whichNote)
	{
	Case 0:
        	SetMusic("lump name0");
		break;
	Case 1:
		SetMusic("lump name1");
		break;
	Case 2:
		SetMusic("lump name2");
		break;
	Case 3:
		SetMusic("lump name3");
		break;
	Case 4:
		SetMusic("lump name4");
		break;
	Case 5:
		SetMusic("lump name5");
		break;
	}
}
yo strparam :(

Code: Select all

#define S_NOTE 42
int NoteNameBase = "dicks";

script S_NOTE (int noteNum)
{
    int noteName = StrParam(s:NoteNameBase, d:noteNum);
    SetMusic(noteName);
}

RE: Item pickup and scripting help

Posted: Mon Oct 15, 2012 8:34 pm
by Llewellyn
Ijon Tichy wrote: yo strparam :(
I don't think that he wants to rename his music lumps just for your script to work, mkay?

RE: Item pickup and scripting help

Posted: Mon Oct 15, 2012 8:44 pm
by Synert
it's much less work though

RE: Item pickup and scripting help

Posted: Mon Oct 15, 2012 11:08 pm
by Llewellyn
Synert wrote: it's much less work though
> Much less work
Doing more work by renaming all the music lumps and all then making sure you have renamed them in your MAPINFO and then making sure that all of your scripts have them renamed...
More work.
Plus StrParam is harder to understand for someone like the OP who may or may not be fluent in ACS and might want to know what is going on.

RE: Item pickup and scripting help

Posted: Mon Oct 15, 2012 11:45 pm
by nightshade94
For now, I'm sticking with Llewellyn's code. That way, I can make notes spawn in different parts of the map each time so that players wont exactly know where the note is the next time they play the map.