BOOM Headshots. In DECORATE. Nothing (even remotely) fancy.

Handy guides on how to do things, written by users for users.

Moderators: GZDoom Developers, Raze Developers

Forum rules
Please don't start threads here asking for help. This forum is not for requesting guides, only for posting them. If you need help, the Editing forum is for you.
SlabOfCheese69
Posts: 6
Joined: Tue Aug 25, 2015 7:22 am

Re: BOOM Headshots. In DECORATE. Nothing (even remotely) fan

Post by SlabOfCheese69 »

thanks! i will be as using this now! thanks for making :)
User avatar
|ndußtrial
Posts: 398
Joined: Sat Aug 17, 2013 11:39 am
Graphics Processor: Intel (Modern GZDoom)
Location: Ivy Mercy Lyons

Re: BOOM Headshots. In DECORATE. Nothing (even remotely) fan

Post by |ndußtrial »

going to have to remember this
User avatar
Carbine Dioxide
Posts: 1927
Joined: Thu Jun 12, 2014 3:16 pm
Location: Anywhere.

Re: BOOM Headshots. In DECORATE. Nothing (even remotely) fan

Post by Carbine Dioxide »

If I can use projectiles instead of bullet puffs, then I will like this very much.
User avatar
EddieMann
Posts: 524
Joined: Sun May 18, 2014 7:25 pm
Location: Arizona

Re: BOOM Headshots. In DECORATE. Nothing (even remotely) fan

Post by EddieMann »

What if I wanted to do head armor and implement the "hurt" sounds (bullet striking metal)?
User avatar
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: BOOM Headshots. In DECORATE. Nothing (even remotely) fan

Post by Matt »

Bump to add a ZScript version. Unfortunately I can't find a way to bypass the head without redefining the missile. :( If anyone knows how to do it (CanCollideWith is not even called, it seems) please add it!
Spoiler:
User avatar
Mikk-
Posts: 2274
Joined: Tue Jun 30, 2009 1:31 pm
Location: Somewhere off Kanagawa

Re: BOOM Headshots. In DECORATE. Nothing (even remotely) fan

Post by Mikk- »

Funny you mention ZScript because I too, have been making a ZScript version that can work for any game using eventhandlers. can be customised easily enough, modifying the CriticalFactor changes the amount of damage dealt to the master. Doesn't apply for floating monsters or bosses mostly because it's too OP but I'm sure it can be modified to suit other's needs.

Code: Select all

class HeadShotHandler : StaticEventHandler
{
    override void WorldThingSpawned(WorldEvent e)
    {
        if (e.Thing.bIsMonster && !e.Thing.bFLOAT)
        {
            Actor.Spawn("Z_HeadshotHitbox").master = e.Thing;
        }
    }
    
    override void WorldThingRevived(WorldEvent e)
    {
        if (e.Thing.bIsMonster && !e.Thing.bFLOAT)
        {
            Actor.Spawn("Z_HeadshotHitbox").master = e.Thing;
        }
    }    
}

const CriticalFactor = 2;

Class Z_HeadshotHitbox : Actor
    {
    
    Default
        {
        Health     0x7FFFFFFF;
        Mass     0x7FFFFFFF;
        BloodColor "red";
        radius 32;
        height 32;
        +SHOOTABLE; +NODAMAGETHRUST; +NOGRAVITY;
        }
    
    int lastHealth;
    
    override void BeginPlay() 
        {

        self.lastHealth = self.health;
        super.BeginPlay();
        }    
    
    action void blod(int amount)
        {
        while(amount > 0) 
            {
            if(master.bNOBLOOD)
                { return; } 
            A_SpawnItemEx("Blood",xvel: frandom(1.0,2.0),zvel: frandom(4.0,8.0),angle: random(0,359));
            amount--;
            }
        }
    
    override void Tick()
        {
        if (master)
            {
            self.bNOBLOOD = master.bNOBLOOD;
            if(radius != master.radius || height != master.height)
                { A_SetSize(master.radius+2, master.height/3); } 
            
            if(!master.bSOLID || master.bBOSS)
                { Destroy(); } 
            }
        
        if(self.health < self.lastHealth)
            { 
            blod(15);
            A_DamageMaster((self.lastHealth - self.Health)*CriticalFactor,"default"); self.lasthealth = self.health;
            }
            
        setorigin(master.pos+(0,0,master.height - (self.height * 0.5)),true);
        Super.Tick();
        }
    
    States
        {
        Spawn:
            TNT1 A 1;
            loop;
        Death:
            TNT1 A 1;
            stop;
        }
    }
        
todo: make the hitbox and blod function respect the master's blood color
User avatar
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: BOOM Headshots. In DECORATE. Nothing (even remotely) fan

Post by Matt »

Actor.Spawn("Z_HeadshotHitbox").master = e.Thing;
I had no idea you could squish a master definition in there like that! :shock:

Might want to set the master's height as well.

(In the meantime I've been messing around with CanCollideWith() to see if it could ignore any collisions that are above the "neck height" but still outside the narrower "head radius" of a full-height monster... seems like it could work, but there may be some projectiles that won't work for it, for the same reason why I had to replace the doomimpball.)
ZzZombo
Posts: 315
Joined: Mon Jul 16, 2012 2:02 am

Re: BOOM Headshots. In DECORATE. Nothing (even remotely) fan

Post by ZzZombo »

You don't really have to forcefully remove actors, just have them to end up in a non-negative duration state w/ the stop flow control keyword, for example "TNT1 A 0". So you can simply remove the label after the A_CheckFlag() call, and put here "TNT1 A 0<newline>stop", it will have the same effect as calling the remove function, but cheaper.
User avatar
Leon_Portier
Posts: 62
Joined: Sun Feb 12, 2017 3:30 pm
Location: Dark side of Bavaria

Re: BOOM Headshots. In DECORATE. Nothing (even remotely) fan

Post by Leon_Portier »

Very good tutorial, the code can be expanded to create helmets, which fly off when shot.

Looks like this:
https://www.youtube.com/watch?v=CJ4w6GKfqwg

I could not figure out how to pass a var to a child actor, so I used a fake inventory actor.

Code(commented):
Spoiler:
User avatar
DoomKrakken
Posts: 3482
Joined: Sun Oct 19, 2014 6:45 pm
Location: Plahnit Urff
Contact:

Re: BOOM Headshots. In DECORATE. Nothing (even remotely) fan

Post by DoomKrakken »

Bump, but it's very relevant.

I've been trying to make a mod for Doom based off of DOOM, and as such, it would need headshots. Wanting to have as much universal compatibility as possible (as I want to be able to play my mod with mapsets such as Ultimate Torment 'N Torture and ZPack, which have custom monsters), I recently succeeded in making a system that worked with EVERY monster. I didn't want to reveal this until I had released my mod, but once I discovered this thread, I figured it should be shared. After all, I'm seeing a hell of a lot of stuff here that already may help me along with my mod in other ways (never knew about functions such as "A_SetSize" or "WorldThingSpawned" until now).

Anyway, what my function does is check to see if the top 1/6 of an actor's height was struck by a specially coded projectile. If so, it will deal 25% damage to the hit actor (and then proceed to deal the actual damage of the projectile).
Spoiler:
What do you think? :D
User avatar
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: BOOM Headshots. In DECORATE. Nothing (even remotely) fan

Post by Matt »

Can we possibly rename this thread? I forgot about this thread and got momentarily excited at the thought of a BOOM-compatible headshot mod, or some obscure such function that already exists and is now ported to Decorate, and I'm all disappointed now.
User avatar
Nash
 
 
Posts: 17433
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: BOOM Headshots. In DECORATE. Nothing (even remotely) fan

Post by Nash »

What's even funnier is, 2 years prior to this thread, I offered a more universal - and tl;dr - solution* but yet this thread is still advocating the convoluted, outdated and spaghetti-like spawning-a-hitbox method...




* need to ZScriptify that but I'm sure many others here have already done it in their ZScript projects
User avatar
phantombeta
Posts: 2084
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: BOOM Headshots. In DECORATE. Nothing (even remotely) fan

Post by phantombeta »

Nash wrote:but I'm sure many others here have already done it in their ZScript projects
Indeed. There's even an universal ZScript version in the Scripts Library forum.
Here's the forum thread it's in.
User avatar
DoomKrakken
Posts: 3482
Joined: Sun Oct 19, 2014 6:45 pm
Location: Plahnit Urff
Contact:

Re: BOOM Headshots. In DECORATE. Nothing (even remotely) fan

Post by DoomKrakken »

Liking what I'm seeing... :D
Post Reply

Return to “Tutorials”