Can ACS detect which monster killed the player?
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: 25
- Joined: Wed Oct 06, 2021 5:58 pm
Can ACS detect which monster killed the player?
Is there a way we can detect which monster killed the player and execute Scripts accordingly?
-
- Posts: 4903
- Joined: Sun Nov 14, 2010 12:59 am
- OS Test Version: No (Using Stable Public Version)
- Graphics Processor: ATI/AMD (Modern GZDoom)
Re: Can ACS detect which monster killed the player?
In a roundabout way, yes.
Code: Select all
script "CheckKiller" (int check)
{
bool res = false;
// Change the script activator from the player to the killer,
// which is stored in the player's 'target' field on death.
if (SetActivatorToTarget(0))
{
// Compare the killer's class name with the class name that's
// being passed. If there's a match, return 'true'.
res = CheckActorClass(0, check);
}
SetResultValue(res);
}
script "Test" Death
{
// Is the killer an imp?
if (ACS_NamedExecuteWithResult("CheckKiller", "DoomImp"))
{
// Yes, print a message.
Print(s:"Killer is an imp.");
}
}
-
- Posts: 25
- Joined: Wed Oct 06, 2021 5:58 pm
Re: Can ACS detect which monster killed the player?
Thanks! This works most of the time, the reason i came up with my question is that in zdaemon some of the custom monsters replaces a decorations like "HangTNoBrain" and that actor doesn't have the string "Obituary", so when a player dies you get "Player Died" instead of "Player is killed by HangTNoBrain".
Maybe an OPEN script that checks the player HP in a loop and when it reaches <1 the print script execute instead of the DEATH script beacuse some times it gets the actor class wrong in a crowded area full of monsters.
Maybe an OPEN script that checks the player HP in a loop and when it reaches <1 the print script execute instead of the DEATH script beacuse some times it gets the actor class wrong in a crowded area full of monsters.