Giving custom inventory like weapon upgrades via backpack.

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
doomguy214
Posts: 192
Joined: Tue Feb 17, 2015 11:33 pm

Giving custom inventory like weapon upgrades via backpack.

Post by doomguy214 »

Is it possible to give custom inventory via backpack with code below :-

Code: Select all

ACTOR AmmoSuply : BackpackItem Replaces Backpack
{
	Game Doom
	Height 26
	+COUNTITEM
	+DONTGIB
	+INVENTORY.ALWAYSPICKUP
	inventory.pickupsound "BACKPK2"
	Inventory.PickupMessage "$GOTBACKPACK"
	States
	{
	Spawn:
		CMPK ABCDEFG 1 
		Loop
    Pickup:
        TNT1 A 0 A_GiveInventory("ShellBox", 1)
        TNT1 A 0 A_GiveInventory("ClipBox", 1)
        TNT1 A 0 A_GiveInventory("CellPack", 1)
        TNT1 A 0 A_GiveInventory("RocketBox", 1)
        Stop
	}
}
Inventory code as below.
ACTOR Doom2016ShotgunUpgradeSpawner : CustomInventory //Weapon Spawn
{
	-COUNTITEM
	-INVENTORY.ALWAYSPICKUP
	Inventory.Amount 0
	Inventory.MaxAmount 1
	Inventory.PickupMessage ""
	States
	{
	Spawn:
        TNT1 A 0
		TNT1 A 0 A_JumpIf(CallACS("GameplayPreset_IB")==1, "SpawnNothing")//Arsenal
		TNT1 A 0 A_JumpIf(CallACS("GameplayPreset_IB")==2, "Spawn4Reel")//Doom 2016
		TNT1 A 0 A_JumpIf((CallACS("GameplayPreset_IB")==3)||(CallACS("GameplayPreset_IB")==7), "SpawnNothing")//Conjoined (:P)
		TNT1 A 0 A_JumpIf(CallACS("GameplayPreset_IB")==4, "Spawn4Reel")//JRMYXD Arsenal
		TNT1 A 0 A_JumpIf(CallACS("GameplayPreset_IB")==5, "SpawnNothing")//JRMYXD Classic
		TNT1 A 0 A_JumpIf(CallACS("GameplayPreset_IB")==6, "SpawnNothing")//JRMYXD Insanity
		
		TNT1 A 0 A_JumpIf(CallACS("UpgradePresets_IB")==1, "SpawnNothing")//Default
		TNT1 A 0 A_JumpIf(CallACS("UpgradePresets_IB")==2, "Spawn4Reel")//Doom 2016
		TNT1 A 0 A_JumpIf(CallACS("UpgradePresets_IB")==3, "SpawnNothing")//Extra Arsenal
		TNT1 A 0 A_JumpIf(CallACS("UpgradePresets_IB")==4, "Spawn4Reel")//JRMYXD Arsenal
		TNT1 A 0 A_JumpIf(CallACS("UpgradePresets_IB")==5, "SpawnNothing")//JRMYXD Classic
		TNT1 A 0 A_JumpIf(CallACS("UpgradePresets_IB")==6, "SpawnNothing")//JRMYXD Insanity
	Spawn4Reel:
		TNT1 A 0
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("DisableUpgrade")==1,"SpawnNothing")
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("NoDoom2016ShotgunUpgrade")==1,"SpawnNothing")
		TNT1 A 0 A_JumpIF(ACS_NamedExecuteWithResult("IBArsenalUpgradeToggle")==1,"SpawnNothing")
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("Doom2016UpgradeToggle")==1,"SpawnNothing")
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("JRMYXDARsenalUpgradeToggle")==1,"SpawnNothing")
		Goto Spawn2
		
	SpawnNothing:
	TNT1 A 0 A_SpawnItem("ShellBoxSpawnIBNew")
	Goto Derp
	
	Spawn2:
	TNT1 A 0 A_SpawnItem("Doom2016GrenadeShotgun")
	Goto Derp
    
	Derp:
	TNT1 A 0
	//TNT1 A -1
	Stop
	}
}
Last edited by wildweasel on Thu Jul 11, 2019 10:39 pm, edited 1 time in total.
Reason: Added [code] tags.
User avatar
Void Weaver
Posts: 724
Joined: Thu Dec 18, 2014 7:15 am
Contact:

Re: Giving custom inventory like weapon upgrades via backpac

Post by Void Weaver »

doomguy214 wrote:Pickup:
TNT1 A 0 A_GiveInventory("ShellBox", 1)
The 'Pickup:' state should be used only for CustomInventory NOT for Inventory or BackpackItem.

Anyway you should either make ZScript custom Backpack OR make CustomInventory with ammo cap increasing via ACS smth like as:
'SetAmmoCapacity("<your_ammo_type>",GetAmmoCapacity("<your_ammo_type>")+<additional_cap_value_of_your_ammo_type>);' and with yours weapon upgrades, both into Pickup state.
Post Reply

Return to “Scripting”