Check for Monster Armor

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
Grey-Wolf
Posts: 179
Joined: Sun Jul 15, 2018 4:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Check for Monster Armor

Post by Grey-Wolf »

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
TDRR
Posts: 815
Joined: Sun Mar 11, 2018 4:15 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Debian 12/ Manjaro
Graphics Processor: nVidia with Vulkan support
Location: Venezuela

Re: Check for Monster Armor

Post by TDRR »

Um, i'm pretty sure enemies can't carry armor.
User avatar
Grey-Wolf
Posts: 179
Joined: Sun Jul 15, 2018 4:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Check for Monster Armor

Post by Grey-Wolf »

They can. I gave it to them with a_giveinventory in their spawn state, and it works as intended.
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Check for Monster Armor

Post by Blue Shadow »

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 [wiki]ScriptCall[/wiki] 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
Grey-Wolf
Posts: 179
Joined: Sun Jul 15, 2018 4:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Check for Monster Armor

Post by Grey-Wolf »

Code: Select all

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

Re: Check for Monster Armor

Post by Blue Shadow »

Change s:enemyarmor to d:enemyarmor in the HudMessage call.
User avatar
Grey-Wolf
Posts: 179
Joined: Sun Jul 15, 2018 4:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Check for Monster Armor

Post by Grey-Wolf »

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

Re: Check for Monster Armor

Post by Blue Shadow »

Okay, switch to using [wiki]CheckActorInventory[/wiki]. It allows you to pass a [wiki]TID[/wiki]:

Code: Select all

enemyarmor = CheckActorInventory(new_tid, "BasicArmor"); 
Post Reply

Return to “Scripting”