[Solved] How do I make an enemy drop a Blue Key

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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
Spaceshiporion
Posts: 58
Joined: Sun Dec 03, 2023 6:58 pm

[Solved] How do I make an enemy drop a Blue Key

Post by Spaceshiporion »

Hello, I am very very new to coding...

I'm making my first map, and I want a single enemy on the map to drop a blue keycard.
I keep finding different answers for the same question, some of them from 2003.

This is the closest I got.

Code: Select all

#include "zcommon.acs"

script 2 (void)

{
	DropItem (T_IMP, T_BLUEKEYCARD, 1, 256);
}
I then added "action 80" or "Script execute" in the monsters file.
The script does execute at death, because I also added a print function.

Can someone tell me what I'm doing wrong?
Some sources told me to use numbers from a list instead of the item names.
Last edited by Spaceshiporion on Mon Dec 11, 2023 2:23 pm, edited 1 time in total.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: How do I make an enemy drop a Blue Key

Post by Jarewill »

For DropItem, the first argument has to be the TID of the monster, so if your monster's ID is 5, you put 5 there, and the second argument is a class name, so it should be "BlueCard" with quotation marks.
Spaceshiporion
Posts: 58
Joined: Sun Dec 03, 2023 6:58 pm

Re: How do I make an enemy drop a Blue Key

Post by Spaceshiporion »

Jarewill wrote: Mon Dec 04, 2023 3:06 am For DropItem, the first argument has to be the TID of the monster, so if your monster's ID is 5, you put 5 there, and the second argument is a class name, so it should be "BlueCard" with quotation marks.
Thanks for the quick response! I found a list with spawn numbers, which I figured I'd bookmark.
https://zdoom.org/wiki/Doom_spawn_numbers

code looks like this now, but the imp doesn't drop a bluecard, unfortunately...

Code: Select all

#include "zcommon.acs"

script 2 (void)

{
	DropItem (5, "BlueCard", 1, 256);
}
I've also seen this item listed as "BlueCardKey", not sure if that matters....
Could you possibly show me how you would write this code? It would help a ton.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: How do I make an enemy drop a Blue Key

Post by Jarewill »

Here you go:
DropItem.wad
(1.73 KiB) Downloaded 48 times
The imp was given an ID of 1 and made to execute the script when it dies.
The script then calls DropItem(1,"BlueCard"), which drops a blue keycard at the imp with tag of 1.
Spaceshiporion
Posts: 58
Joined: Sun Dec 03, 2023 6:58 pm

Re: How do I make an enemy drop a Blue Key

Post by Spaceshiporion »

I managed to get the Blue Key to drop!! Thank you so much for demonstrating Jarewill!

Another note that I realize affected the code was that I used a "clearinventory" code,
which I think prevented the keys from existing.

Placing this code beneath the drop item code got the game running exactly how I wanted it!
Post Reply

Return to “Scripting”