[DECORATE] Infinite CustomInventory pickups

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!)
User avatar
Dr_Cosmobyte
Posts: 2833
Joined: Thu Jun 04, 2015 9:07 pm
Preferred Pronouns: He/Him
Location: Killing spiders.

[DECORATE] Infinite CustomInventory pickups

Post by Dr_Cosmobyte »

Small question which is been haunting me for a little while.

I use a CustomInventory item in Aracnocide to give each player class a different weapon based on the class the player chose. There are state jumps if the player has a ceratin item and the such. HOWEVER, my real struggle is: even if full on ammo, the player can pickup those weapons infinitely, thus discarding the pickups.

Here's some example code:

Code: Select all

//==============================================================================
// Light Pistol
//==============================================================================
ACTOR ARWPSPC : CustomInventory replaces Pistol
{
	+LOOKALLAROUND
	Inventory.Icon "TNT1A0"
	Inventory.PickupSound ""
	Inventory.PickupMessage "Obtained Weapon [Light Pistol]"
	States
	{
	Spawn:
		TNT1 A 1 A_Look
		Loop
	See:
		TNT1 A 0 A_JumpIfInTargetInventory("TrooperDummy",1,"SpawnTrooper")
		TNT1 A 0 A_JumpIfInTargetInventory("RangerDummy",1,"SpawnRanger")
		TNT1 A 0 A_JumpIfInTargetInventory("ReconDummy",1,"SpawnRecon")
		TNT1 A 0 A_JumpIfInTargetInventory("ScientistDummy",1,"SpawnScientist")
		Stop
	SpawnTrooper:
		TNT1 A 0 A_SetScale(0.20)
		WACP A -1
		Stop
	SpawnRanger:
		TNT1 A 0 A_SetScale(0.55)
		WBCP A -1
		Stop
	SpawnRecon:
		TNT1 A 0 A_SetScale(0.30)
		WCCP A -1
		Stop
	SpawnScientist:
		TNT1 A 0 A_SetScale(0.60)
		WDCP A -1
		Stop
	Pickup:
		NULL A 0 A_JumpIfInventory("TrooperDummy", 	 1,	"Blake")
		NULL A 0 A_JumpIfInventory("RangerDummy", 	 1,	"Derrick")
		NULL A 0 A_JumpIfInventory("ReconDummy", 	 1,	"Marion")
		NULL A 0 A_JumpIfInventory("ScientistDummy", 1, "Stella")
	Blake:
		NULL A 0 A_JumpIfInventory("ARTR1AC",1,"CL1PK")
		NULL A 0 A_JumpIfInventory("ARTRWPC",1,"CL1PK")
		NULL A 0 A_Print("= Beretta 92F =",5)
		NULL A 0 A_PlaySound("ARPK/WPN/PK1")
		NULL A 0 A_GiveInventory("ARCL1",15)
		NULL A 0 A_GiveInventory("ARTRWPC",1)
		Stop
	Derrick:
		NULL A 0 A_JumpIfInventory("ARRG1BC",1,"CL1PK")
		NULL A 0 A_JumpIfInventory("ARRGWPC",1,"CL1PK")
		NULL A 0 A_Print("= Browning Hi-Power =",5)
		NULL A 0 A_PlaySound("ARPK/WPN/PK1")
		NULL A 0 A_GiveInventory("ARCL1",15)
		NULL A 0 A_GiveInventory("ARRGWPC",1)
		Stop
	Marion:
		NULL A 0 A_JumpIfInventory("ARRC1CC",1,"CL1PK")
		NULL A 0 A_JumpIfInventory("ARRCWPC",1,"CL1PK")
		NULL A 0 A_Print("= Bottini BF-002 =",5)
		NULL A 0 A_PlaySound("ARPK/WPN/PK1")
		NULL A 0 A_GiveInventory("ARCL1",15)
		NULL A 0 A_GiveInventory("ARRCWPC",1)
		Stop
	Stella:
		NULL A 0 A_JumpIfInventory("ARSCWPC",1,"CL1PK")
		NULL A 0 A_Print("= A&E SMART Pistol =",5)
		NULL A 0 A_PlaySound("ARPK/WPN/PK1")
		NULL A 0 A_GiveInventory("ARCL1",15)
		NULL A 0 A_GiveInventory("ARSCWPC",1)
		Stop
	CL1PK:
		NULL A 0 A_Print("= +15 Light Pistol Ammo =",5)
		NULL A 0 A_PlaySound("ARPK/CL1/PK1")
		NULL A 0 A_GiveInventory("ARCL1",15)
		Stop
	}
}
the +LOOKALLAROUND flag and A_Look are used to display a different sprite depending on the player class.

Thank you in advance for the attention!
Boondorl
Posts: 157
Joined: Wed Jul 11, 2018 10:57 pm

Re: [DECORATE] Infinite CustomInventory pickups

Post by Boondorl »

I'm guessing ARCL1 is the defined ammo type for the weapons. Try moving its A_GiveInventory function to the very top of the Pickup state, that way it does an ammo check before the player can pick it up.
User avatar
Dr_Cosmobyte
Posts: 2833
Joined: Thu Jun 04, 2015 9:07 pm
Preferred Pronouns: He/Him
Location: Killing spiders.

Re: [DECORATE] Infinite CustomInventory pickups

Post by Dr_Cosmobyte »

I will try this at home later and see if works. Thanks.

Return to “Scripting”