Drops based on player's weapons? Ammo capacity upgrades?

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!)

Drops based on player's weapons? Ammo capacity upgrades?

Postby yonvolt » Sun May 15, 2022 9:45 pm

In my mod, the player starts with a bottomless main pea-shooter, and later acquires a rocket launcher and a plasma rifle with limited ammo. I want dying enemies to randomly pick from a drop table--health, rockets, cells, or nothing--but not drop ammo that the player doesn't have the weapon for. I'm not sure whether this would be best to do in DECORATE or in ACS, or which scripting it would even be possible in for that matter.

Ideally this would manifest as, if the player has only a rocket launcher, a 1/3 chance to drop health, rockets, or nothing; rather than a 1/4 chance to drop everything in the table, and then if it tries to drop cells it just gets replaced. But, if the second way is how it has to be, then I can gladly work with that.

Additionally, I want to start the player with a maximum ammo count of 5 rockets, and allow them to pick up items which increase their capacity by 5 each time. A standard backpack doesn't work for this, so how could it be managed? I saw the SetAmmoCapacity actor function but it's limited to dev builds right now, and I'm not sure how I would incorporate the ACS version into an item the player picks up.
User avatar
yonvolt
 
Joined: 08 May 2022
Discord: vae#9652

Re: Drops based on player's weapons? Ammo capacity upgrades?

Postby RKD » Mon May 16, 2022 12:12 am

yonvolt wrote:I want dying enemies to randomly pick from a drop table--health, rockets, cells, or nothing--but not drop ammo that the player doesn't have the weapon for.


Haven't coded anything but maybe CheckActorInventory could be what you're looking for? You'll need to assign a Thing ID to the player first, from what I understand, since the player doesn't have one by default. Probably there are other ways to do this, but I'm gonna go with making your monsters (either all or some of them) drop an invisible actor that inherits from RandomSpawner and this actor is the one tasked with dropping the ammo you set in its DECORATE. With CheckActorInventory, you specify this spawner to check if the actor with the TID of the player has certain weapons in his/her possession and change the probability accordingly for each possible drop.

I'm sure someone will have a better alternative but that would be my take on it.
User avatar
RKD
 
Joined: 19 Mar 2022
Location: Argentina
Operating System: Windows 10/8.1/8/201x 64-bit

Re: Drops based on player's weapons? Ammo capacity upgrades?

Postby yonvolt » Mon May 16, 2022 1:58 pm

RKD wrote:Haven't coded anything but maybe CheckActorInventory could be what you're looking for?

Likely; I still will have to figure out the cleanest way to determine the valid drops in the table but that can be an exercise for myself rather than the rest of the forum.
I should also set up my scripts as an imported library since basically everything I'm writing applies to every map I plan to make.

Which just leaves stacking ammo capacity upgrades, then.
User avatar
yonvolt
 
Joined: 08 May 2022
Discord: vae#9652

Re: Drops based on player's weapons? Ammo capacity upgrades?

Postby Blue Shadow » Tue May 17, 2022 4:16 pm

yonvolt wrote:I saw the SetAmmoCapacity actor function but it's limited to dev builds right now, and I'm not sure how I would incorporate the ACS version into an item the player picks up.

The item needs to be a custom inventory. From its Pickup state, you call an ACS script by using ACS_NamedExecuteWithResult.
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: Drops based on player's weapons? Ammo capacity upgrades?

Postby yonvolt » Tue May 17, 2022 10:25 pm

Blue Shadow wrote:The item needs to be a custom inventory. From its Pickup state, you call an ACS script by using ACS_NamedExecuteWithResult.

I see, thank you! I'm surprised I didn't put two and two together when I was using ACS_NamedExecuteAlways for actors to call the drop table script, and realize I could use ACS_[x] to call a script with SetAmmoCapacity...
User avatar
yonvolt
 
Joined: 08 May 2022
Discord: vae#9652


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest