ACS check actor property for death?

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.

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
TurboBabyShakes5000
Posts: 26
Joined: Sun Jul 18, 2021 3:22 pm
Graphics Processor: Intel (Modern GZDoom)
Location: The South :(

ACS check actor property for death?

Post by TurboBabyShakes5000 »

Im very new and Ive got 10 ten tabs open and can't find an answer. Is there an acs function that checks if a thing is dead or alive? I'm trying to run a script that checks if monsters defined in an array are alive or dead. Not in the ThingCount way of checking against the monsters in the map itself but basically if an actor (the 18 monsters) defined in the array dies. But I don't see a CheckActorProperty that covers that. Don't know whether that means that I cant do that or that I cant do it THAT WAY. Any help in this regard is greatly appreciated.
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: ACS check actor property for death?

Post by Jarewill »

Wouldn't checking if the monster's health is below 1 be enough?
Using CheckActorProperty(APROP_Health)<1 should be enough.
Just remember to check if it's either below 1, or lower/equal to 0, because monsters can get below 0 health.
User avatar
TurboBabyShakes5000
Posts: 26
Joined: Sun Jul 18, 2021 3:22 pm
Graphics Processor: Intel (Modern GZDoom)
Location: The South :(

Re: ACS check actor property for death?

Post by TurboBabyShakes5000 »

Thank you so much for your reply. I'm running into a snag with the syntax, as I've said Im very new. I tried various things but this is the closest I've gotten.

Code: Select all


script 3 (int tid)
{
	if (CheckActorProperty(monstnum[1], APROP_Species, "ZombieMan"))

	{
		(CheckActorProperty(monstnum[1], APROP_Health, < 1 ))

		print (s:"Former Human Neutralized.");
	}

}
The first argument clears, so it's not the array. It's proven to work in the past for spawners.
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: ACS check actor property for death?

Post by Jarewill »

Okay, this is my bad completely.
I confused CheckActorProperty with GetActorProperty.
Not sure how it would look with Check, but with Get you can use something like this:

Code: Select all

If(GetActorProperty(monstnum[1], APROP_Health) <1)
{
    //Stuff
}
Also remember that those functions take a monster TID, so make sure that's what's in your array.
Also you forgot the If before the health check.
User avatar
TurboBabyShakes5000
Posts: 26
Joined: Sun Jul 18, 2021 3:22 pm
Graphics Processor: Intel (Modern GZDoom)
Location: The South :(

Re: ACS check actor property for death?

Post by TurboBabyShakes5000 »

Thanks again. Well, now it compiles without errors, but does not execute the print when the conditions are met.

Code: Select all

script 3 (int tid)
{
	if (GetActorProperty(monstNum[1], APROP_Health) < 1)
	{
		print (s:"Former Human Neutralized.");
	}
}
As I said previously the array is functional and has been used successfully in a map that uses it to spawn various monsters itemized 1-18 because I needed to learn arrays and the default monster TID scheme was difficult to remember.

Code: Select all

Int monstNum[18] = { 4, 	        //Former Human		1 UAC, 5 XP
				 1,		//Former Seargent 	2 UAC, 10 XP
				 5,		//Imp				3 UAC, 50 XP
				 110,	//Lost Soul			5 UAC, 60 XP
				 8,		//Demon				8 UAC, 65 XP
				 9,		//Spectre			8 UAC, 70 XP
				 116,	//Wolf SS			10 UAC, 70 XP
				 2,		//Former Commando	15 UAC, 80 XP
				 19,	        //Cacodemon			20 UAC, 100 XP
				 113,	//Hell Knight		25 UAC, 110 XP
				 20,	        //Revenant			50 UAC, 125 XP
			         3,		//Baron				30 UAC, 150 XP
				 6,		//Arachnotron		40 UAC, 200 XP
				 112,	//Mancubus			60 UAC, 250 XP
				 115,	//Pain Elemental	75 UAC, 300 XP
				 111,	//Archvile			100 UAC, 350 XP
				 7,		//Spider"Mastermind" 200 UAC, 500 XP
				114};	//Cyberdemon		 250 UAC, 550 XP
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: ACS check actor property for death?

Post by Jarewill »

Looks like an issue with the activator to me.
First you should replace Print with PrintBold and see if it prints, if it does then it's the activator issue.
I assume your script is being called when a monster dies? If that's the case then the monster is the activator.
You would need to use SetActivator with either AAPTR_TARGET or AAPTR_PLAYER1 pointers.

Also if you want to retrieve the first variable from an array you should use [0], as [1] will retrieve the second one.
User avatar
TurboBabyShakes5000
Posts: 26
Joined: Sun Jul 18, 2021 3:22 pm
Graphics Processor: Intel (Modern GZDoom)
Location: The South :(

Re: ACS check actor property for death?

Post by TurboBabyShakes5000 »

Well, some progress was made, but the goal hasn't been reached. I'm trying my best to solve the problem on my own. I do not want to test anybodies' patience here but my reference level is really low. Any resources one could suggest as a bridge from the wiki and boiler plate example scripts to formulating and executing your own basic ones would be greatly appreciated. Even just knowing how to get into the black box of compiled ".o" ACS in Slade would be super helpful because all the stuff I'm trying to reverse engineer has stuff pointing to things I can't read.
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: ACS check actor property for death?

Post by Jarewill »

The wiki has a lot of information on ACS that you can check out.
In my attempt to make such a script I only used GetActorProperty and SetActivator while making it a KILL script.
There's a fancy MAPINFO keyword called ForceKillScripts that makes all enemies trigger KILL scripts as long as they don't have a specific flag.
If you are interested in my implementation, this is how I did it:
Spoiler:
User avatar
TurboBabyShakes5000
Posts: 26
Joined: Sun Jul 18, 2021 3:22 pm
Graphics Processor: Intel (Modern GZDoom)
Location: The South :(

Re: ACS check actor property for death?

Post by TurboBabyShakes5000 »

You're a lifesaver. I'm familiar with the wiki. It's a valuable resource but a bit murky for those without more coding experience, like myself. This is not intended as a criticism of the wiki but my level of understanding. Is that library in front of the include header a reference to an external document or denoting it AS the library? If no maps are made for this mod as I intend, will having a MAPINFO entry mess with the maps it's loaded with in some way I should be aware of? Does the mapinfo entry need to appear in a specific place in the archives' structure?
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: ACS check actor property for death?

Post by Jarewill »

The library defines the script as a library, that helps avoid problems with maps that use scripting.
If a gameplay mod defines a script without a library, then the mod's script will get jumbled up with the map's script and both won't work, that's why it's important to specify libraries for gameplay mods.

The GameInfo definition in MAPINFO won't mess with any maps, in fact pretty much all mods use MAPINFO to define new player classes, event handlers and such.
You can put it in the root of your structure, alongside all other lumps such as DECORATE or SNDINFO.
Post Reply

Return to “Scripting”