I need some help. I have an actor (an NPC not a monster). It has infinite health with no health defined in the zscript. I need to make it so that if player is scummy enough to shoot a bullet at this actor, the player is instantly obliterated, killed and gibbed into a million pieces. How can I implement this? The player pawn isn't really suitable because that just acts as a duplicate with equal health and takes multiple shots to kill. I need this to be INSTANT death by GIBBING if they even fire a SINGLE SHOT at this NPC.
Any advice please? Thanks.
Instant death to player when shooting a certain actor
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!)
- AshHouswares
- Posts: 145
- Joined: Fri Jun 03, 2022 11:31 am
- Graphics Processor: Not Listed
Re: Instant death to player when shooting a certain actor
With ZScript you can override the actor's DamageMobj virtual to instead deal damage to whoever damaged it:
I just hope you know what you are doing with this, because a thing like this can get very frustrating to the player if misused. 
Code: Select all
Override int DamageMobj(Actor inflictor, Actor source, int damage, Name mod, int flags, double angle){
If(source.player){source.DamageMobj(self,self,999,"Extreme",DMG_THRUSTLESS);} //If a player damaged it, kill them
Return 0; //Deal no damage to the actor itself
}

- AshHouswares
- Posts: 145
- Joined: Fri Jun 03, 2022 11:31 am
- Graphics Processor: Not Listed
Re: Instant death to player when shooting a certain actor
It's being used only for one single NPC. A little animal in an area with no enemies or any reason to fire a gun. Anyone that decides they want to shoot an animal for no reason deserves all they get. I suppose I could (if it is possible) lock the players ability to use weapons in their sector as an alternative. But I think if they wish to shoot in the first place. They deserve to be gibbed.
So will this method work even if the NPC has no health at all? Ie; is invincible? Currently they have no health or pain states in their code. Complete invulernable. Also where would I put this is and how to implement it? I assume in the maps script box but I'm a little at loss with this one sorry.
So will this method work even if the NPC has no health at all? Ie; is invincible? Currently they have no health or pain states in their code. Complete invulernable. Also where would I put this is and how to implement it? I assume in the maps script box but I'm a little at loss with this one sorry.
Re: Instant death to player when shooting a certain actor
The only thing this needs to work is for the actor to have the +SHOOTABLE flag set.
Then you just drop off the code I provided anywhere in your actor's code outside any other blocks. (Outside Default and States)
So it would look something like this:
I will note that even if you don't define health in the Default block, it will default to 1000 health, as that's specified in the base Actor class.
However the function I provided will make sure the NPC won't take any damage at all, because of the Return 0;.
Then you just drop off the code I provided anywhere in your actor's code outside any other blocks. (Outside Default and States)
So it would look something like this:
Code: Select all
Class Thing : Actor{
Default{
}
States{
}
//Code I provided goes here
}
However the function I provided will make sure the NPC won't take any damage at all, because of the Return 0;.
- AshHouswares
- Posts: 145
- Joined: Fri Jun 03, 2022 11:31 am
- Graphics Processor: Not Listed
Re: Instant death to player when shooting a certain actor
Ahhhh I get ya now. Thank you once again, so much. All the help you offered me you deserve a credit in the game by this point.