Damage Direction Overlay

Projects that alter game functions but do not include new maps belong here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
Gerodium
Posts: 2
Joined: Sun Aug 13, 2017 3:24 pm

Damage Direction Overlay

Post by Gerodium »

Configurable overlay for GZDoom to display from which direction the player is receiving damage.

Screenshot - got hit by the 2 shotguys in the front plus the two on the sides:
Image

There are several customization options for appearance and gameplay.
If your main options menu is overridden, type "openmenu dmgdirovopt" in the console.

The mod is universal, but the self-damage direction will only be accurate for vanilla Doom/Heretic/Hexen. (see the readme in the archive for details)

Tested on GZDoom 3.1.0 (requires v2.4+)

Download v1.01.
EDIT - v1.01: fixed a minor display bug upon changing the display mode
Last edited by Gerodium on Mon Aug 14, 2017 12:11 pm, edited 1 time in total.
User avatar
namsan
Posts: 145
Joined: Sat Mar 31, 2012 4:27 am
Location: Japan

Re: Damage Direction Overlay

Post by namsan »

Very nice mod, with many customization options!
I liked it.
User avatar
Hexereticdoom
Posts: 613
Joined: Thu Aug 08, 2013 1:30 pm
Graphics Processor: nVidia with Vulkan support
Location: Spain

Re: Damage Direction Overlay

Post by Hexereticdoom »

So then, this is almost like the existing Damnums addon but just for the main player?

Interesting, I'll have to take a look at it... :yup:
Gerodium
Posts: 2
Joined: Sun Aug 13, 2017 3:24 pm

Re: Damage Direction Overlay

Post by Gerodium »

You're right, but to be more accurate:
DamNums show the damage you does to the enemies in the 3d world coords.

DmgDirOverlay mainly indicate the direction from where the player take damage on a 2d hud plane, which is always visible (if you don't use any angle restriction option).
The default behavior shows the actual damage taken, but you can hide it if you want and just display a "X" character, or the animated menu selection icon.
At first, I wanted to put an arrow or something pointing to the direction instead of that icon, but apparently we cannot rotate a texture nor transform the canvas (or I missed something).

If you use both mods, make sure to use different fonts or it may be confusing.

@namsan Thanks, glad you like it!
User avatar
Nash
 
 
Posts: 17322
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: Damage Direction Overlay

Post by Nash »

Hey Gerodium,

I messed around with this and added texture rotation (but only for the circular mode), it uses Screen.DrawShape and some helper functions that Marisa Kirisame wrote in this thread, feel free to merge it into your mod (and credit her for the helper functions). I probably did a half-ass job on it and you know your code better than I do. :)

The replacement for the circular Screen.DrawTexture call (the commented out was from your original code)

Code: Select all

                    //Screen.DrawTexture(texSelIcon, true, xpos, ypos,
                    //    DTA_Alpha, (dataList[i].lifespan < 35) ? float(dataList[i].lifespan) / 35 : 1.0f,
                    //    DTA_VirtualWidth, virtualW, DTA_VirtualHeight, virtualH, DTA_KeepRatio, true);
                    
                    // make 2D shape
                    let shape = MakeSquare();
                    // get texture size and scale it
                    Vector2 size = TexMan.GetScaledSize(texSelIcon);
                    size.X *= scaling;
                    size.Y *= scaling;
                    // scale coordinates
                    // (some compensation for the Y coordinate to center the graphic properly)
                    Vector2 dpos = (xpos, ypos + ((size.Y / 2) / scaling));
                    dpos.X *= scaling;
                    dpos.Y *= scaling;
                    // calculate angle of texture rotation
                    Vector2 center = (Screen.GetWidth() / 2, Screen.GetHeight() / 2);
                    double ang = atan2(center.Y - dpos.Y, center.X - dpos.X) - 90;
                    // draw rotated texture
                    MoveSquare(shape, size, dpos, ang);
                    Screen.DrawShape(texSelIcon, true, shape,
                        DTA_Alpha, (dataList[i].lifespan < 35) ? float(dataList[i].lifespan) / 35 : 1.0f,
                        DTA_VirtualWidth, virtualW, DTA_VirtualHeight, virtualH, DTA_KeepRatio, true);
You're going to need MakeSquare() and MoveSquare(), feel free to stick it in wherever you feel is appropriate. The following code is MK's helper functions, just with cleaned up formatting and 1 tiny error fix:

Code: Select all

    // create a square shape (not usable until calling MoveSquare)
    static clearscope Shape2D MakeSquare()
    {
        // the shape that will be drawn
        Shape2D square = new("Shape2D");
        // texture coordinates of each corner
        square.PushCoord((0, 0));
        square.PushCoord((1, 0));
        square.PushCoord((0, 1));
        square.PushCoord((1, 1));
        // two triangles make up the square
        // the points have to be in counter-clockwise order
        square.PushTriangle(0, 3, 1);
        square.PushTriangle(0, 2, 3);
        return square;
    }

    // set the positions of an existing square shape's vertices
    static clearscope void MoveSquare(Shape2D shape, Vector2 size, Vector2 pos, double angle)
    {
        // clear any vertices already set
        shape.Clear(Shape2D.C_Verts);
        // corners of a square centered on 0,0
        Vector2 points[4];
        points[0] = (-0.5 * size.X, -0.5 * size.Y);
        points[1] = (0.5 * size.X, -0.5 * size.Y);
        points[2] = (-0.5 * size.X, 0.5 * size.Y);
        points[3] = (0.5 * size.X, 0.5 * size.Y);
        // apply a 2D rotation matrix:
        //
        // ┌               ┐   ┌   ┐
        // │ cos θ  -sin θ │   │ X │
        // │               │ * │   │
        // │ sin θ   cos θ │   │ Y │
        // └               ┘   └   ┘
        //
        // then move the points by the set offset
        for (int i = 0; i < 4; i++)
        {
            Vector2 oldpos = points[i];
            points[i].X = oldpos.X * cos(angle) - oldpos.Y * sin(angle) + pos.X;
            points[i].Y = oldpos.X * sin(angle) + oldpos.Y * cos(angle) + pos.Y;
            shape.PushVertex(points[i]);
        }
    }
 
User avatar
Enjay
 
 
Posts: 26430
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Damage Direction Overlay

Post by Enjay »

I've been playing Doom for... a little while now but this has put something into perspective for me.

Image

It's no wonder that, sometimes, a shot from a cyberdemon on a healthy player means "game over man".
User avatar
Silentdarkness12
Posts: 1555
Joined: Thu Aug 15, 2013 5:34 pm
Location: Plains of Pride

Re: Damage Direction Overlay

Post by Silentdarkness12 »

I get 2 read from Address Zero crashes with this mod. One was with a homemade titlemap addon. The other was a crash when I try to load game after dying. I'm loading this with Hideous Destructor, admittedly, but here they are. Same line causes the same crash.

Code: Select all

Called from DmgDirOveH.WorldThingSpawned at DmgDirOv.pk3:dmgdirov-zs/handler.txt, line 138
User avatar
Nash
 
 
Posts: 17322
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: Damage Direction Overlay

Post by Nash »

I know the OP hasn't logged in a very long time, but I am posting this here anyway in case they return in future, or if someone else would like to continue the work done here.

- Currently this does not respect player pitch and roll.
- Suggestion: rotating damage overlay from my previous post

Return to “Gameplay Mods”