Page 1 of 1

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

Posted: Sun May 15, 2022 9:45 pm
by yonvolt
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.

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

Posted: Mon May 16, 2022 12:12 am
by RKD
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.

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

Posted: Mon May 16, 2022 1:58 pm
by yonvolt
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.

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

Posted: Tue May 17, 2022 4:16 pm
by Blue Shadow
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.

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

Posted: Tue May 17, 2022 10:25 pm
by yonvolt
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...