Custom Item Pickup Defs issues

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Custom Item Pickup Defs issues

Postby Gunslaher_Pi » Mon Oct 11, 2021 7:42 am

Hiya slayers.

Gun here with yet another frustrating scripting issue.
Usually I'm pretty on the ball with scripting unless I've
Hit a barrier that's unresolvable.

In this case; it's a PDA sprite actor.

What I want it for;

When picked up, plays a defined sound file.

What it's supposed to play;

Initial pickup sound of my choice, followed by another
Doom3 radio sound dubbed "radio1" and "radio2". Randomised of course. *Future radio sounds to be added later on*.

Using a separate Sndinfo file with the sound files inside the .wad

What message I want the print to say;

"Picked up a PDA" (Inventory.Pickupmessage currently errors out with a "Not a defined actor property".

Conclusion/Bottom-line:

When the PDA is picked up, it should register a custom pick-up sound, play the random sound as if it's a radio recording on the PDA and display "Picked up a PDA" at the top of the screen like standardised items do during normal play.

Maybe I'm missing a bunch of stuff, but after looking at all the examples from other people, I can't help but thinking I'm overlooking something.

Help greatly appreciated.

TIA
User avatar
Gunslaher_Pi
 
Joined: 17 Jan 2021
Location: Aussieland
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: Intel (Modern GZDoom)

Re: Custom Item Pickup Defs issues

Postby Blue Shadow » Mon Oct 11, 2021 8:48 pm

Here you go (this is in ZScript, not DECORATE):

Code: Select allExpand view
class PDA : Inventory
{
    Default
    
{
        Inventory.PickupMessage "Picked up a PDA.";
        Inventory.PickupSound "misc/p_pkup";
    }

    override bool TryPickup (in out Actor toucher)
    {
        toucher.A_StartSound("brain/sight", CHAN_5);
        GoAwayAndDie();
        return true;
    }

    States
    
{
    Spawn:
        STIM A -1;
        Stop;
    }
}

Obviously, the sprite and sounds are placeholders, so change them to whatever you need.
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Custom Item Pickup Defs issues

Postby Gunslaher_Pi » Mon Oct 11, 2021 10:57 pm

Great! I'll try it tonight. Thanks buddy!
User avatar
Gunslaher_Pi
 
Joined: 17 Jan 2021
Location: Aussieland
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: Intel (Modern GZDoom)

Re: Custom Item Pickup Defs issues

Postby Gunslaher_Pi » Tue Oct 12, 2021 5:48 am

The code is perfect. However I don't know how to utilize it. Sorry, but I'm new to this engine (GzDoom Builder).
I'm used to injection of data bit objects onto map grid matrices. However, since Zscript is completely foreign
to me, I'm uncertain of how to place the PDA down onto the grid for the player to pickup.

My apologies for being a "noob" at this.
User avatar
Gunslaher_Pi
 
Joined: 17 Jan 2021
Location: Aussieland
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: Intel (Modern GZDoom)

Re: Custom Item Pickup Defs issues

Postby Blue Shadow » Tue Oct 12, 2021 8:12 am

By using MAPINFO, you can assign the PDA thing an editor number so you can place it in your map when editing.
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Custom Item Pickup Defs issues

Postby Blue Shadow » Fri Oct 15, 2021 11:16 pm

Did you ask how to have a delay before playing the audio file or was I imagining it?
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Custom Item Pickup Defs issues

Postby Gunslaher_Pi » Sat Oct 16, 2021 4:47 am

Ohhh, actually I didn't ask. Please tell and uhm....Noob question again. I have my MAPINFO File with the majority of the properties assigned to their
assigned resources. How exactly do I assign an "Editor" number? Is it dissimilar to an ACTOR number?
User avatar
Gunslaher_Pi
 
Joined: 17 Jan 2021
Location: Aussieland
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: Intel (Modern GZDoom)

Re: Custom Item Pickup Defs issues

Postby Blue Shadow » Sat Oct 16, 2021 8:17 am

You didn't? Weird. Anyway, here's a demo:

https://www.dropbox.com/s/4n9q3lfbqam05 ... s.pk3?dl=1

In addition to implementing the delay thing, it shows how you assign an editor number through MAPINFO.
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Custom Item Pickup Defs issues

Postby Gunslaher_Pi » Sat Oct 16, 2021 9:24 am

Alright, I'll give that a burn tomorrow. I simply don't understand how we can't program a new sound on a new item when picked up.
It's perplexing. When I was doing maps for 3D Realms, it was a Hi-Tag and Lo-Tag. Hopefully the developer of GzDoom Builder will
be able to script in a feature to allow "Activate sound when" then a definition of "When player uses, walks over" to the sector and
ACTOR definitions.

That will make a LOT of difference for newcomers and veteran map makers.

Thanks again Shadow.
User avatar
Gunslaher_Pi
 
Joined: 17 Jan 2021
Location: Aussieland
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: Intel (Modern GZDoom)

Re: Custom Item Pickup Defs issues

Postby Blue Shadow » Sat Oct 16, 2021 11:06 pm

I revised the demo a little (link), so that there's only one PDA item. You place instances of it in your maps, and each instance can be given its own audio log sound to play upon pickup. This is done from the map editor by creating a custom field/key which is called user_audiofile, setting it to the name of the sound.

Image

Note the screenshot above is from SLADE's map editor, not GZDoom Builder or Ultimate Doom Builder. The Doom Builder editors do support creating custom fields. It's just I don't know the steps to do it, since I don't have any of them installed on my computer currently, and it's been a very long time since I used any of them. You'll have to figure it out yourself or ask around on the forums.



Edit: this guide on setting/using custom fields might a useful read, specifically this section.
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests