Page 1 of 1

- SOLVED - ZScript HUD: Finding player's armor MaxAbsorb

Posted: Thu Oct 07, 2021 12:34 pm
by PandaDoomer
How can I get my HUD to find the player's armor's MaxAbsorb value? just putting MaxAbsorb instead of amount isn't working. I bet I'm missing something obvious here.

Here's a snippet of the code that I need it for:

Code: Select all

let armor = cplayer.mo.FindInventory("BasicArmor");
		if(armor != null)
		{
			...
			string fontcolor =
				!armor.amount ?			BigFontWhite :
				armor.amount <= 150 ?	BigFontGreen : // These 2 lines would find maxabsorb instead and use different values than these
				armor.amount <= 200 ?	BigFontBlue :
										BigFontRed;
			...
		}

Re: ZScript HUD: Finding player's armor MaxAbsorb

Posted: Thu Oct 07, 2021 12:40 pm
by Jarewill
BasicArmor has the following properties:

Code: Select all

int AbsorbCount;
double SavePercent;
int MaxAbsorb;
int MaxFullAbsorb;
int BonusCount;
Name ArmorType;
int ActualSaveAmount; 
Alongside the standard Amount and MaxAmount of Inventory items.
I don't know if that's exactly what you are looking for, but maybe try checking for one of those?

Re: ZScript HUD: Finding player's armor MaxAbsorb

Posted: Thu Oct 07, 2021 1:00 pm
by PandaDoomer
Jarewill wrote:BasicArmor has the following properties:

Code: Select all

int AbsorbCount;
double SavePercent;
int MaxAbsorb;
int MaxFullAbsorb;
int BonusCount;
Name ArmorType;
int ActualSaveAmount;
Alongside the standard Amount and MaxAmount of Inventory items.
I don't know if that's exactly what you are looking for, but maybe try checking for one of those?
I already tried armor.maxabsorb, but it didn't work.

Re: ZScript HUD: Finding player's armor MaxAbsorb

Posted: Thu Oct 07, 2021 9:54 pm
by Blue Shadow
You need to cast the result of FindInventory to BasicArmor, since what you normally get from the function is Inventory.

Code: Select all

let armor = BasicArmor(cplayer.mo.FindInventory("BasicArmor"));

Re: ZScript HUD: Finding player's armor MaxAbsorb

Posted: Fri Oct 08, 2021 1:05 am
by PandaDoomer
Blue Shadow wrote:You need to cast the result of FindInventory to BasicArmor, since what you normally get from the function is Inventory.

Code: Select all

let armor = BasicArmor(cplayer.mo.FindInventory("BasicArmor")); 
Thanks! I had a feeling it was something obvious.