[SOLVED] Can't get monsters to drop custom ammo correctly

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
User avatar
Ariasio
Posts: 40
Joined: Sat Apr 27, 2019 7:47 pm

[SOLVED] Can't get monsters to drop custom ammo correctly

Post by Ariasio »

I'm having a problem with making my monsters drop custom ammo correctly.

Here's the code of monster #1

Code: Select all

actor aresshocktrooper 30000
{
	health 80
	radius 20
	height 56
	mass 100
	speed 9
	painchance 96
	monster
	+floorclip
	attacksound "ashtfire"
	seesound "aretsight"
	painsound "aretpain"
	deathsound "aretdeath"
	obituary "%o was gunned down by an Ares Shock Trooper"
	dropitem "aresshell"
And here's the code of the custom ammo it's supposed to drop:

Code: Select all

actor aresshell : ammo 26002
{
	inventory.amount 4
	inventory.maxamount 40
	ammo.backpackamount 16
	ammo.backpackmaxamount 80
	inventory.pickupmessage "Picked up some Shotgun Shells (4)"
	inventory.pickupsound "aresapku"
The problem here is that the monster drops the specified ammo, but the amount you get when you pick it up is incorrect. You're supposed to get 4 shotgun shells, but instead you get 2.

Now, here's monster #2

Code: Select all

actor aresinfantry 30001
{
	health 40
	radius 20
	height 56
	mass 100
	speed 9
	painchance 120
	monster
	+floorclip
	attacksound "riflefire"
	seesound "aretsight"
	painsound "aretpain"
	deathsound "aretdeath"
	obituary "%o was gunned down by Ares Infantry"
	dropitem "aresrifleclip" 
And here's the code of the ammo drop:

Code: Select all

actor aresrifleclip : ammo 26000
{
	inventory.amount 10
	inventory.maxamount 60
	ammo.backpackamount 40
	ammo.backpackmaxamount 120
	inventory.pickupmessage "Picked up a rifle clip (10)"
	inventory.pickupsound "aresapku"
This monster I can't get to drop the ammo at all, no matter what I do.
EDIT: Now suddenly it started dropping ammo, but as with monster #1, only half the amount you're supposed to get is acquired when picked up. What the hell?

What seems to be the problem here? It's not the wrong class names. I spellchecked them, like, 10 times to be sure. The problem doesn't lie in the ammo itself either because when spawned separately, it works as intended. Thanks in advance for helping me out.

EDIT: The same problem occurs when the monster is supposed to drop a weapon. The pickup gives only half the amount of ammo it's supposed to. I've also tried specifying the amount after the classname (i.e. "aresshell" 4), but it results in the monster not dropping anything.
Last edited by Ariasio on Wed May 08, 2019 1:59 pm, edited 3 times in total.
User avatar
Void Weaver
Posts: 724
Joined: Thu Dec 18, 2014 7:15 am
Contact:

Re: Can't get monsters to drop custom ammo correctly

Post by Void Weaver »

All item-ammo amount dropped by monsters are halved by default.
Therefore you always get 4 shotgun shell in the Shotgun dropped by Shotgunguys, despite that 8 shells defined in the Shotgun actor.
At the same time, the placed one on map gives to player 8 shells instead.

So, you can set double drop amount of the same ammo-item OR just make inherited from original only for drop.
User avatar
Ariasio
Posts: 40
Joined: Sat Apr 27, 2019 7:47 pm

Re: Can't get monsters to drop custom ammo correctly

Post by Ariasio »

Void Weaver wrote:All item-ammo amount dropped by monsters are halved by default. Therefore you always get 4 shotgun shell in the Shotgun dropped by Shotgunguys, despite that 8 shells defined in the Shotgun actor. At the same time, the placed one on map gives to player 8 shells instead.
Huh, really? I never noticed that while playing the game. Now I feel stupid for making this thread. Do I lose streetcred in the community for that? :lol:
Void Weaver wrote:So, you can set double drop amount of the same ammo-item OR just make inherited from original only for drop.


Guess I'll go with the second option. Thanks a lot for explaining everything to me. I was losing my mind out there trying to figure out why it doesn't work the way I want it to.
User avatar
Void Weaver
Posts: 724
Joined: Thu Dec 18, 2014 7:15 am
Contact:

Re: [SOLVED] Can't get monsters to drop custom ammo correctl

Post by Void Weaver »

Yep, a such tiny "unnoticeable" detail. :) Also on 1st and 5th game difficulties ammo spawn\drop is doubled.
So if normally "Clip" gives 10 bullet from placed one on a map and 5 from drop, then the same "Clip" on ITYTD and NM will give 20\10 bullets from placement\drop correspondingly.

But as I said it's default behaviour, as global method you can always predefine ammo drop amount for each difficulty via corresponding parameters in MAPINFO/Skill definition.
User avatar
Ariasio
Posts: 40
Joined: Sat Apr 27, 2019 7:47 pm

Re: [SOLVED] Can't get monsters to drop custom ammo correctl

Post by Ariasio »

Void Weaver wrote:Also on 1st and 5th game difficulties ammo spawn\drop is doubled.
So if normally "Clip" gives 10 bullet from placed one on a map and 5 from drop, then the same "Clip" on ITYTD and NM will give 20\10 bullets from placement\drop correspondingly.

But as I said it's default behaviour, as global method you can always predefine ammo drop amount for each difficulty via corresponding parameters in MAPINFO/Skill definition.
I'll keep both of these things in mind. Thank you once again.
User avatar
R4L
Global Moderator
Posts: 404
Joined: Fri Mar 03, 2017 9:53 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11 Pro
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: [SOLVED] Can't get monsters to drop custom ammo correctl

Post by R4L »

You can also give your custom ammo the -DROPPED flag to make them drop a full amount or the amount you specify.
User avatar
Ariasio
Posts: 40
Joined: Sat Apr 27, 2019 7:47 pm

Re: [SOLVED] Can't get monsters to drop custom ammo correctl

Post by Ariasio »

R4L wrote:You can also give your custom ammo the -DROPPED flag to make them drop a full amount or the amount you specify.
Just tried this method out to see if it works. It doesn't.
User avatar
StroggVorbis
Posts: 866
Joined: Wed Nov 08, 2017 4:23 pm
Graphics Processor: nVidia with Vulkan support
Location: Germany

Re: [SOLVED] Can't get monsters to drop custom ammo correctl

Post by StroggVorbis »

Try adding "ammo.dropamount 4".
User avatar
Void Weaver
Posts: 724
Joined: Thu Dec 18, 2014 7:15 am
Contact:

Re: [SOLVED] Can't get monsters to drop custom ammo correctl

Post by Void Weaver »

DabbingSquidward, you absolutelly right! This is simpliest way ofc. ^_^
User avatar
Ariasio
Posts: 40
Joined: Sat Apr 27, 2019 7:47 pm

Re: [SOLVED] Can't get monsters to drop custom ammo correctl

Post by Ariasio »

DabbingSquidward wrote:Try adding "ammo.dropamount 4".
Holy shit! It works! Thank you so much!

Only works for ammo drops, though. What can I do when it comes to weapon drops? Aside from fiddling with skill definitions in MAPINFO, of course.
User avatar
Dan_The_Noob
Posts: 872
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: [SOLVED] Can't get monsters to drop custom ammo correctl

Post by Dan_The_Noob »

Ariasio wrote:
DabbingSquidward wrote:Try adding "ammo.dropamount 4".
Holy shit! It works! Thank you so much!

Only works for ammo drops, though. What can I do when it comes to weapon drops? Aside from fiddling with skill definitions in MAPINFO, of course.
just set the amount to double for dropped weapons?
User avatar
Ariasio
Posts: 40
Joined: Sat Apr 27, 2019 7:47 pm

Re: [SOLVED] Can't get monsters to drop custom ammo correctl

Post by Ariasio »

Dan_The_Noob wrote:just set the amount to double for dropped weapons?
Except there are no separate dropped weapons. I forgot to mention but in the meantime I tried out the method Void Weaver suggested, with the separate drops that inherit everything, apart from the ammo amount given, from the main weapon. It resulted in enemies dropping a clone of the main weapon that doesn't count as the main weapon when picked up.
User avatar
StroggVorbis
Posts: 866
Joined: Wed Nov 08, 2017 4:23 pm
Graphics Processor: nVidia with Vulkan support
Location: Germany

Re: Can't get monsters to drop custom ammo correctly

Post by StroggVorbis »

Make a new actor that inherits from WeaponGiver. Put the weapon you want the player to receive as DropItem and make the monster drop this actor. Use Weapon.AmmoGive to override the default amount.

Example:

Code: Select all

ShotgunGiver : WeaponGiver
{
Weapon.AmmoGive -1
Dropitem Shotgun
Inventory.PickupMessage "$GOTSHOTGUN"
States
{
Spawn:
SHOT A -1
}
}
User avatar
Ariasio
Posts: 40
Joined: Sat Apr 27, 2019 7:47 pm

Re: Can't get monsters to drop custom ammo correctly

Post by Ariasio »

DabbingSquidward wrote:Make a new actor that inherits from WeaponGiver. Put the weapon you want the player to receive as DropItem and make the monster drop this actor. Use Weapon.AmmoGive to override the default amount.

Example:

Code: Select all

ShotgunGiver : WeaponGiver
{
Weapon.AmmoGive -1
Dropitem Shotgun
Inventory.PickupMessage "$GOTSHOTGUN"
States
{
Spawn:
SHOT A -1
}
}
A pretty convoluted way to go about it, but at least it finally works. Thanks once again. You've been of great help to me.
User avatar
StroggVorbis
Posts: 866
Joined: Wed Nov 08, 2017 4:23 pm
Graphics Processor: nVidia with Vulkan support
Location: Germany

Re: [SOLVED] Can't get monsters to drop custom ammo correctl

Post by StroggVorbis »

Don't mention it, glad I could help :D
Post Reply

Return to “Scripting”