Can't give multiple Hexen Armors at once w/ A_GiveInventory?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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
eharper256
Posts: 1118
Joined: Sun Feb 25, 2018 2:30 am
Location: UK
Contact:

Can't give multiple Hexen Armors at once w/ A_GiveInventory?

Post by eharper256 »

So, I'm trying to add in a custom inventory item to give the player two sets of the four Hexen Armours simultaneously in Walpurgis. Thought this would be a fairly simple job as I've already got items that analyse the players class and give appropriate items; but it seems like that it malfunctions for Hexen Armours.

The below setup should always give +25 to armour/+5 AC, because each of armours should add up to that amount for that class. These armours work normally and give the correct AC if picked up from their component items, or given by the console "give X" command. But a custom inventory giving them doesn't seem to work; and no matter what I set for the items (they should give different bonuses by class), they actually each give +5 to armour (which would be +1 AC) as if they are not reading the correct stats from the playerclass for some reason.

Code: Select all

ACTOR ArmourLesserWalp : CustomInventory 
{
  +INVENTORY.QUIET
  +INVENTORY.PICKUPFLASH
  +INVENTORY.AUTOACTIVATE
  Inventory.MaxAmount 0
  States
  {
	Spawn:
		TNT1 A 0 Nodelay A_JumpIf(CheckClass("CrusaderPlayer",AAPTR_PLAYER1),"SpawnCrus")
		TNT1 A 0 A_JumpIf(CheckClass("MyrmidonPlayer",AAPTR_PLAYER1),"SpawnMyrm")
		TNT1 A 0 A_JumpIf(CheckClass("MagisterPlayer",AAPTR_PLAYER1),"SpawnMagi")
		TNT1 A 0 A_JumpIf(CheckClass("DruidPlayer",AAPTR_PLAYER1),"SpawnDrui")
		Stop
	SpawnMyrm:
		ARMM M -1
		Stop
	SpawnCrus:
		ARMC M -1
		Stop
	SpawnMagi:
		ARMG M -1
		Stop
	SpawnDrui:
		ARMD M -1
		Stop
	Pickup:
		TNT1 A 0 A_JumpIf(CheckClass("CrusaderPlayer",AAPTR_PLAYER1),"IsCrus")
		TNT1 A 0 A_JumpIf(CheckClass("MyrmidonPlayer",AAPTR_PLAYER1),"IsMyrm")
		TNT1 A 0 A_JumpIf(CheckClass("MagisterPlayer",AAPTR_PLAYER1),"IsMagi")
		TNT1 A 0 A_JumpIf(CheckClass("DruidPlayer",AAPTR_PLAYER1),"IsDrui")
		Stop
	IsMyrm:
		TNT1 A 0
		TNT1 A 1 A_GiveInventory("AmuletOfWardingW", 1,AAPTR_PLAYER1)
		TNT1 A 1 A_GiveInventory("DrakeBoots", 1,AAPTR_PLAYER1)
		TNT1 A 0 A_Log("\c[white]A fresh set of \c[red]Gauntlets\c[white] and \c[brown]Boots\c[white]! They should help protect me.")
		TNT1 A 0 A_Playsound("Pickup/ArmourMed",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	IsCrus:
		TNT1 A 0
		TNT1 A 1 A_GiveInventory("AmuletOfWardingW", 1,AAPTR_PLAYER1)
		TNT1 A 1 A_GiveInventory("DrakeBoots", 1,AAPTR_PLAYER1)
		TNT1 A 0 A_Log("\c[white]Excellent, a new \c[red]Shield\c[white] and \c[gold]Rosary\c[white]! They should help protect me.")
		TNT1 A 0 A_Playsound("Pickup/ArmourMed",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	IsMagi:
		TNT1 A 0
		TNT1 A 1 A_GiveInventory("MeshArmourW", 1,AAPTR_PLAYER1)
		TNT1 A 1 A_GiveInventory("PlatinumHelmW", 1,AAPTR_PLAYER1)
		TNT1 A 0 A_Log("\c[white]A pristine \c[red]Tunic\c[white] and \c[sapphire]Focusing Stone\c[white]! They should help protect me.")
		TNT1 A 0 A_Playsound("Pickup/ArmourClothing",CHAN_ITEM,1,false,ATTN_NONE)
		Stop 
	IsDrui:
		TNT1 A 0
		TNT1 A 1 A_GiveInventory("MeshArmourW", 1,AAPTR_PLAYER1)
		TNT1 A 1 A_GiveInventory("PlatinumHelmW", 1,AAPTR_PLAYER1)
		TNT1 A 0 A_Log("\c[white]A pristine \c[green]Tunic\c[white] and \c[red]Wolf Fetish\c[white]! They should help protect me.")
		TNT1 A 0 A_Playsound("Pickup/ArmourClothing",CHAN_ITEM,1,false,ATTN_NONE)
		Stop 
  }
}
Whilst there are some ways to cheese it (give 2 of one item, and 3 of another); or use (A_SpawnItemEx for both of them to instantly be picked up), it seems a bit odd to have to use a weird workaround for this specifically, so I was wondering if anyone had any insight on the matter?
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: Can't give multiple Hexen Armors at once w/ A_GiveInvent

Post by Arctangent »

It's because HexenArmor with a non-0 amount acts as Dragonskin Bracers. All normal HexenArmor pickups give 0 of themselves to avoid this.

Also, it goes without saying that your solution to this makes it so that already having those particular pieces of armor means you don't get +5 AC, but a lesser amount, if that's an issue. Though there's also the issue that Dragonskin Bracer-style boosts have a hard-coded cap of +4 of the class's normal max AC, so ...

Really, if you're trying to do stuff with the HexenArmor system that Hexen didn't already do, your best bet is to break out ZScript and write your own. ZDoom's armor system in general is a bit ... unintuitive, but HexenArmor is especially rife with oddities because ... well, Hexen.
Post Reply

Return to “Scripting”