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

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
User avatar
PandaDoomer
Posts: 108
Joined: Sun Apr 12, 2015 9:05 pm
Location: USA

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

Post 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;
			...
		}
Last edited by PandaDoomer on Fri Oct 08, 2021 8:16 am, edited 1 time in total.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: ZScript HUD: Finding player's armor MaxAbsorb

Post 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?
User avatar
PandaDoomer
Posts: 108
Joined: Sun Apr 12, 2015 9:05 pm
Location: USA

Re: ZScript HUD: Finding player's armor MaxAbsorb

Post 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.
Blue Shadow
Posts: 5043
Joined: Sun Nov 14, 2010 12:59 am

Re: ZScript HUD: Finding player's armor MaxAbsorb

Post 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"));
User avatar
PandaDoomer
Posts: 108
Joined: Sun Apr 12, 2015 9:05 pm
Location: USA

Re: ZScript HUD: Finding player's armor MaxAbsorb

Post 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.
Post Reply

Return to “Scripting”