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

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

Postby PandaDoomer » Thu Oct 07, 2021 12:34 pm

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 allExpand view
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.
User avatar
PandaDoomer
I suck at making DOOM mods.
 
Joined: 12 Apr 2015
Location: USA
Discord: PedroThePanda64#1661
Operating System: Windows 10/8.1/8/201x 64-bit

Re: ZScript HUD: Finding player's armor MaxAbsorb

Postby Jarewill » Thu Oct 07, 2021 12:40 pm

BasicArmor has the following properties:
Code: Select allExpand view
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?
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: ZScript HUD: Finding player's armor MaxAbsorb

Postby PandaDoomer » Thu Oct 07, 2021 1:00 pm

Jarewill wrote:BasicArmor has the following properties:
Code: Select allExpand view
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.
User avatar
PandaDoomer
I suck at making DOOM mods.
 
Joined: 12 Apr 2015
Location: USA
Discord: PedroThePanda64#1661
Operating System: Windows 10/8.1/8/201x 64-bit

Re: ZScript HUD: Finding player's armor MaxAbsorb

Postby Blue Shadow » Thu Oct 07, 2021 9:54 pm

You need to cast the result of FindInventory to BasicArmor, since what you normally get from the function is Inventory.

Code: Select allExpand view
let armor = BasicArmor(cplayer.mo.FindInventory("BasicArmor"));
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: ZScript HUD: Finding player's armor MaxAbsorb

Postby PandaDoomer » Fri Oct 08, 2021 1:05 am

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 allExpand view
let armor = BasicArmor(cplayer.mo.FindInventory("BasicArmor")); 

Thanks! I had a feeling it was something obvious.
User avatar
PandaDoomer
I suck at making DOOM mods.
 
Joined: 12 Apr 2015
Location: USA
Discord: PedroThePanda64#1661
Operating System: Windows 10/8.1/8/201x 64-bit


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest