Item pickup and scripting help
-
nightshade94
- Posts: 29
- Joined: Sun Oct 14, 2012 9:10 pm
- Location: Canada
Item pickup and scripting help
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.
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.
-
BloodyAcid
- Forum Regular
- Posts: 294
- Joined: Sat Jun 16, 2012 7:42 pm
RE: Item pickup and scripting help
I think this works. For DECORATE, put:
For ACS, put:
Replace variables with your desired script numbers and music lump names as needed.
Code: Select all
Actor slendernote : Inventory
{
Inventory.maxamount (number of notes max here)
INVENTORY.AUTOACTIVATE
States
{
Use:
TNT1 A 0 ACS_Execute(script #, map #);
}
}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");
}
}
Last edited by BloodyAcid on Mon Oct 15, 2012 2:51 am, edited 1 time in total.
RE: Item pickup and scripting help
I'm just going to come in here and...BloodyAcid wrote: I think this works. For DECORATE, put:
STUFF
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
}
}
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;
}
}
Last edited by Llewellyn on Mon Oct 15, 2012 4:46 am, edited 1 time in total.
-
nightshade94
- Posts: 29
- Joined: Sun Oct 14, 2012 9:10 pm
- Location: Canada
RE: Item pickup and scripting help
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.
"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
Sorry, the random semi-colons need to go roflnightshade94 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.
Bad habit I have from ACS is to put semi colons after an ACS_Execute function
Last edited by Llewellyn on Mon Oct 15, 2012 5:01 am, edited 1 time in total.
-
nightshade94
- Posts: 29
- Joined: Sun Oct 14, 2012 9:10 pm
- Location: Canada
RE: Item pickup and scripting help
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
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.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!
-
Ijon Tichy
- Frequent Poster Miles card holder
- Posts: 901
- Joined: Mon Jun 04, 2012 5:07 am
RE: Item pickup and scripting help
yo strparam :(Llewellyn wrote:I'm just going to come in here and...BloodyAcid wrote: I think this works. For DECORATE, put:
STUFF
Decorate: Uses NOTE A-E, replace with TNT1 A if you don't want spritesACS: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 } }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; } }
Code: Select all
#define S_NOTE 42
int NoteNameBase = "dicks";
script S_NOTE (int noteNum)
{
int noteName = StrParam(s:NoteNameBase, d:noteNum);
SetMusic(noteName);
}
Last edited by Ijon Tichy on Mon Oct 15, 2012 7:28 pm, edited 1 time in total.
RE: Item pickup and scripting help
I don't think that he wants to rename his music lumps just for your script to work, mkay?Ijon Tichy wrote: yo strparam :(
Last edited by Llewellyn on Mon Oct 15, 2012 8:34 pm, edited 1 time in total.
RE: Item pickup and scripting help
> Much less workSynert wrote: it's much less work though
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.
-
nightshade94
- Posts: 29
- Joined: Sun Oct 14, 2012 9:10 pm
- Location: Canada
RE: Item pickup and scripting help
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.