Damage Direction Overlay

Projects that alter game functions but do not include new maps belong here.
Forum rules
The Projects forums are ONLY for YOUR 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.

Damage Direction Overlay

Postby Gerodium » Sun Aug 13, 2017 4:59 pm

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 1:11 pm, edited 1 time in total.
Gerodium
 
Joined: 13 Aug 2017

Re: Damage Direction Overlay

Postby namsan » Sun Aug 13, 2017 6:42 pm

Very nice mod, with many customization options!
I liked it.
User avatar
namsan
Loves English but hates Revenants
 
Joined: 31 Mar 2012
Location: Japan
Discord: Namsan#8146

Re: Damage Direction Overlay

Postby Hexereticdoom » Thu Aug 17, 2017 9:53 pm

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:
User avatar
Hexereticdoom
Don't make me angry or I'll bite you! Heheheee...
 
Joined: 08 Aug 2013
Location: Spain

Re: Damage Direction Overlay

Postby Gerodium » Fri Aug 18, 2017 1:05 pm

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!
Gerodium
 
Joined: 13 Aug 2017

Re: Damage Direction Overlay

Postby Nash » Thu Oct 25, 2018 8:10 am

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 allExpand view

                    
//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.*= scaling;
                    size.*= scaling;
                    // scale coordinates
                    // (some compensation for the Y coordinate to center the graphic properly)
                    Vector2 dpos = (xpos, ypos + ((size./ 2) / scaling));
                    dpos.*= scaling;
                    dpos.*= scaling;
                    // calculate angle of texture rotation
                    Vector2 center = (Screen.GetWidth() / 2, Screen.GetHeight() / 2);
                    double ang = atan2(center.- dpos.Y, center.- 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 allExpand view

    
// 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].= oldpos.* cos(angle) - oldpos.* sin(angle) + pos.X;
            points[i].= oldpos.* sin(angle) + oldpos.* cos(angle) + pos.Y;
            shape.PushVertex(points[i]);
        }
    }
 
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: Damage Direction Overlay

Postby Enjay » Thu Oct 25, 2018 8:22 am

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
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: Damage Direction Overlay

Postby Silentdarkness12 » Fri Dec 21, 2018 9:39 am

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 allExpand view
Called from DmgDirOveH.WorldThingSpawned at DmgDirOv.pk3:dmgdirov-zs/handler.txt, line 138
User avatar
Silentdarkness12
Level 7: ZScript Victim
 
Joined: 15 Aug 2013
Location: Plains of Pride

Re: Damage Direction Overlay

Postby Nash » Fri May 24, 2019 8:01 am

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
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes


Return to Gameplay Mods

Who is online

Users browsing this forum: EndHack, mrtaterz, Timakrov_Gunn and 14 guests