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:
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
Damage Direction Overlay
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.
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.
-
- Posts: 2
- Joined: Sun Aug 13, 2017 3:24 pm
Damage Direction Overlay
Last edited by Gerodium on Mon Aug 14, 2017 12:11 pm, edited 1 time in total.
-
- Posts: 147
- Joined: Sat Mar 31, 2012 4:27 am
- Preferred Pronouns: He/Him
- Location: Japan
Re: Damage Direction Overlay
Very nice mod, with many customization options!
I liked it.
I liked it.
-
- Posts: 661
- Joined: Thu Aug 08, 2013 1:30 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Spain
Re: Damage Direction Overlay
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...
Interesting, I'll have to take a look at it...
-
- Posts: 2
- Joined: Sun Aug 13, 2017 3:24 pm
Re: Damage Direction Overlay
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!
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!
-
-
- Posts: 17462
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: Damage Direction Overlay
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)
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:
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);
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]);
}
}
-
-
- Posts: 26560
- Joined: Tue Jul 15, 2003 4:58 pm
- Location: Scotland
Re: Damage Direction Overlay
I've been playing Doom for... a little while now but this has put something into perspective for me.
It's no wonder that, sometimes, a shot from a cyberdemon on a healthy player means "game over man".
It's no wonder that, sometimes, a shot from a cyberdemon on a healthy player means "game over man".
-
- Posts: 1555
- Joined: Thu Aug 15, 2013 5:34 pm
- Location: Plains of Pride
Re: Damage Direction Overlay
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
-
-
- Posts: 17462
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: Damage Direction Overlay
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
- Currently this does not respect player pitch and roll.
- Suggestion: rotating damage overlay from my previous post