Check for Monster Armor

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.

Check for Monster Armor

Postby Grey-Wolf » Sun Mar 10, 2019 2:24 pm

Hello!

I have some free time today, so I'm I'm back at scripting.
Currently, I'm trying to make monsters more diverse by giving them armor based on their features.
I'm using a pre-made script that was included in Brutal Doom to show monster's health when you hover the crosshair over them.
This is the one:
Spoiler:


Now, I want to also show their armor, but as you surely know, GetArmorInfo only works on players. I did some other tests, but nothing worked. Do any of you have some ideas to share?
User avatar
Grey-Wolf
 
Joined: 15 Jul 2018
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia (Modern GZDoom)

Re: Check for Monster Armor

Postby TDRR » Thu Mar 14, 2019 11:19 am

Um, i'm pretty sure enemies can't carry armor.
User avatar
TDRR
putting jelly on this hot dog
 
Joined: 11 Mar 2018
Location: Venezuela

Re: Check for Monster Armor

Postby Grey-Wolf » Thu Mar 14, 2019 12:14 pm

They can. I gave it to them with a_giveinventory in their spawn state, and it works as intended.
User avatar
Grey-Wolf
 
Joined: 15 Jul 2018
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia (Modern GZDoom)

Re: Check for Monster Armor

Postby Blue Shadow » Thu Mar 14, 2019 12:28 pm

Grey-Wolf wrote:Do any of you have some ideas to share?

Yeah, ZScript. Create a function that would allow you to get the information you need about the armor. After you do that, you can use ScriptCall to use that function in ACS (if you need to use it in ACS that is).


Edit: If all you want to know is how much armor points the actor has, then you don't need ZScript. You can just use ACS's CheckInventory() while passing "BasicArmor" as the item to check for.
User avatar
Blue Shadow
 
 
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Check for Monster Armor

Postby Grey-Wolf » Sun Mar 17, 2019 7:44 am

Code: Select allExpand view
//GET ACTOR INFO
         enemyname = GetActorProperty(new_tid, APROP_NameTag);         //name
         enemyhealthmax = GetActorProperty(new_tid, APROP_SpawnHealth);   //max hp
         enemyhealth = GetActorProperty(new_tid, APROP_HEALTH);          //current hp
         enemyarmor = Checkinventory("BasicArmor");
         

         //ACTOR HEALTH DISPLAY
      if(GetActorProperty(new_tid, APROP_Speed) > 0)
      {
         if (enemyhealth >= 1)
         {
            //ACTOR NAME DISPLAY
            HudMessage(   s:"",
                  s:enemyname;
                  HUDMSG_FADEOUT, 112223, CR_DARKRED, 0.5, 0.02, 0.6, 0.2);
          HudMessage(   s:"\n \n",
                  s:enemyarmor;
                  HUDMSG_FADEOUT, 112226, CR_DARKGREY, 0.5, 0.02, 0.6, 0.2);



This doesn't seem to work... instead, it shows me a totally different string, "bars raised." Pretty unsure what could be causing this.
User avatar
Grey-Wolf
 
Joined: 15 Jul 2018
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia (Modern GZDoom)

Re: Check for Monster Armor

Postby Blue Shadow » Sun Mar 17, 2019 11:13 am

Change s:enemyarmor to d:enemyarmor in the HudMessage call.
User avatar
Blue Shadow
 
 
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Check for Monster Armor

Postby Grey-Wolf » Sun Mar 17, 2019 11:38 am

Blue Shadow wrote:Change s:enemyarmor to d:enemyarmor in the HudMessage call.


Of course, I'm such an idiot -_-"
But still, something's not right. When I spawn an enemy wearing armor and aim at them, I just see a "0" under their health. Then, after some seconds, the zero turns into a "200", no matter the kind of armor they're wearing.

To make things clearer:
This is the updated code for the hud script:
Spoiler:


This is the Custom armor I'm using for the monster:
Spoiler:


And this is the spawn state of said monster:
Spoiler:


Note that I get the same results with other monster and other armor types, so I think the problem is elsewhere.
User avatar
Grey-Wolf
 
Joined: 15 Jul 2018
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia (Modern GZDoom)

Re: Check for Monster Armor

Postby Blue Shadow » Sun Mar 17, 2019 12:42 pm

Okay, switch to using CheckActorInventory. It allows you to pass a TID:

Code: Select allExpand view
enemyarmor = CheckActorInventory(new_tid, "BasicArmor"); 
User avatar
Blue Shadow
 
 
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: ATI/AMD (Modern GZDoom)


Return to Scripting

Who is online

Users browsing this forum: No registered users and 2 guests