Hi, can someone help me with events? I can't understand how to get an actor's state when it dies. I need it. I know you can use an WorldEventDied, but I can't find how to use it to get states.
(Sorry if it seems a bit vague.)
Any way to check an actor's state from ZScript?
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!)
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!)
-
- Posts: 422
- Joined: Fri Dec 22, 2017 1:53 am
- Graphics Processor: ATI/AMD (Modern GZDoom)
- Contact:
-
- Posts: 5043
- Joined: Sun Nov 14, 2010 12:59 am
Re: Any way to check an actor's state from ZScript?
By using [wiki]InStateSequence[/wiki]. Example:
If something died while shooting (during the Missile state sequence), it logs "<class name of the thing> died while shooting!".
Note that at the time the event is called, the actor is yet to enter its death state. So checking whether the actor is in Death, XDeath, etc., won't work.
Code: Select all
class ThingDiedTest : EventHandler
{
override void WorldThingDied (WorldEvent e)
{
if (e.Thing && e.Thing.InStateSequence(e.Thing.CurState, e.Thing.ResolveState("Missile")))
{
Console.Printf("%s died while shooting!", e.Thing.GetClassName());
}
}
}
Note that at the time the event is called, the actor is yet to enter its death state. So checking whether the actor is in Death, XDeath, etc., won't work.
-
- Posts: 422
- Joined: Fri Dec 22, 2017 1:53 am
- Graphics Processor: ATI/AMD (Modern GZDoom)
- Contact:
Re: Any way to check an actor's state from ZScript?
I think I will need to find other ways to check if the actor is in a Death state. Because it seems like it isn't going to work at all.
- Matt
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
- Contact:
Re: Any way to check an actor's state from ZScript?
Is it realy necessary that you do this script while it's in its death state? If you're testing whether it's being gibbed you can check if the thing has an xdeath state and whether its health is equal to or below negative gibhealth.
-
- Posts: 422
- Joined: Fri Dec 22, 2017 1:53 am
- Graphics Processor: ATI/AMD (Modern GZDoom)
- Contact:
Re: Any way to check an actor's state from ZScript?
How do I do that?Matt wrote:Is it realy necessary that you do this script while it's in its death state? If you're testing whether it's being gibbed you can check if the thing has an xdeath state and whether its health is equal to or below negative gibhealth.
- Matt
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
- Contact:
Re: Any way to check an actor's state from ZScript?
if(
youractorpointer.findstate("xdeath")
&& youractorpointer.health <= -youractorpointer.gibhealth
)
youractorpointer.findstate("xdeath")
&& youractorpointer.health <= -youractorpointer.gibhealth
)
-
- Posts: 422
- Joined: Fri Dec 22, 2017 1:53 am
- Graphics Processor: ATI/AMD (Modern GZDoom)
- Contact:
Re: Any way to check an actor's state from ZScript?
Thanks, but it isn't going to work with mods that change monster behaviour to only gib if hit with a specific weapon.Matt wrote:if(
youractorpointer.findstate("xdeath")
&& youractorpointer.health <= -youractorpointer.gibhealth
)
Also, I need to find a way to calculate damage taken by monster and add points to the player.