RadiusDebug - Actor radius (hitbox) tool (18/05/21 update!)

Post your example zscripts/ACS scripts/etc 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.
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

RadiusDebug - Actor radius (hitbox) tool (18/05/21 update!)

Post by Nash »




RadiusDebug is a simple utility I use to see a visual representation of an Actor's radius - AKA hitbox - in the world. This works on any Actor - not just monsters. Basically, if a thing could hold inventory, it will work.

There are two ways to utilize this tool:

Method A

Image

Go to the options menu to enable it for the entire level. There are several options to choose from.

Method B

Actors can have the radius (hitbox) models enabled individually, in either DECORATE or ZScript! Here are examples for both of them.

DECORATE:

Code: Select all

// Just give RadiusDebugMe to enable RadiusDebug on an Actor.
// Take RadiusDebugMe away from it to disable it.
// Simple!

Actor TestZombieman : Zombieman replaces Zombieman
{
    States
    {
        Spawn:
            TNT1 A 0 NoDelay A_GiveInventory("RadiusDebugMe")
            Goto Super::Spawn
    }
}
ZScript:

Code: Select all

class TestZombieman : Zombieman replaces Zombieman
{
    override void BeginPlay(void)
    {
        // This enables the radius debugger...
        RadiusDebug.Enable(self);

        // ... and this would disable it.
        // RadiusDebug.Disable(self);

        Super.BeginPlay();
    }
}
Spoiler: Updates
Known Issues:

- Hardware renderer only. Unfortunately, some time after this mod was released GZDoom lost its ability to render models in software mode...
- When "actors are infinitely tall" is enabled, the bottom of the collision model doesn't touch the floor anymore. This is due to texture degradation from the extremely tall scaling.
- RadiusDebug is meant as a development aid and is therefore not really optimized for performance. Goes without saying; don't ship your mods with RadiusDebug. :P

Feel free to use this any way you like. No need to ask for my permission. Credits would be cool. Have fun!

Wanna chat about my mods? Join my studio's Discord server, Mischief Donut!
Image

I spend an uncountable amount of hours making mods. Consider supporting me on Patreon for cool benefits!
Image
Attachments
RadiusDebug.pk3
18th May 2021 Update
(9.82 KiB) Downloaded 578 times
Last edited by Nash on Thu Sep 01, 2022 6:05 am, edited 14 times in total.
User avatar
Enjay
 
 
Posts: 26517
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: RadiusDebug - Visual Actor radius utility [ZScript/DECOR

Post by Enjay »

I just tried it with map20 in Doom2. It provides interesting and potentially useful information.

Image
User avatar
Kinsie
Posts: 7399
Joined: Fri Oct 22, 2004 9:22 am
Graphics Processor: nVidia with Vulkan support
Location: MAP33
Contact:

Re: RadiusDebug - Visual Actor radius utility [ZScript/DECOR

Post by Kinsie »

I've wished for this to be an engine feature for yeeeears now.
dodopod
Posts: 66
Joined: Wed Oct 04, 2017 2:00 pm
Contact:

Re: RadiusDebug - Visual Actor radius utility [ZScript/DECOR

Post by dodopod »

I would suggest one small change. As you can see in the screenshots, monsters' heads tend to poke out the top of the radius box. According to the Doom Wiki:
However, height and width units do not quite agree. The 1-meter interpretation would imply that the Doomguy is one meter wide, or at least cannot pass through an opening narrower than one meter, which would be to exaggerate his muscularity. The discrepancy is likely related to the fact that pixels in Doom's original video modes were rectangular: because pixels were taller than they were wide, and each map unit was proportional in size to a pixel of an in-game texture, flat, or sprite, height units were larger than width units. A more realistic interpretation (if there is any such thing) is perhaps that one "width unit" (w) corresponds to 5/6 of a "height unit" (h).
So, it would be more accurate if you change the line

Code: Select all

Scale.Y = double(Height);
to

Code: Select all

Scale.Y = double(6 * Height) / 5;
Here's a comparison:

User avatar
camper
Posts: 103
Joined: Sun Feb 25, 2018 10:53 am
Location: Tatarstan

Re: RadiusDebug - Visual Actor radius utility [ZScript/DECOR

Post by camper »

It looks like 3d blocks, only without textures.
Gez
 
 
Posts: 17833
Joined: Fri Jul 06, 2007 3:22 pm

Re: RadiusDebug - Visual Actor radius utility [ZScript/DECOR

Post by Gez »

Now make a gun whose projectile uses A_RadiusGive to give RadiusDebugMe items, and you can call it RadiusRadiusDebug.
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: RadiusDebug - Visual Actor radius utility [ZScript/DECOR

Post by Nash »

dodopod wrote:I would suggest one small change. As you can see in the screenshots, monsters' heads tend to poke out the top of the radius box. According to the Doom Wiki:
However, height and width units do not quite agree. The 1-meter interpretation would imply that the Doomguy is one meter wide, or at least cannot pass through an opening narrower than one meter, which would be to exaggerate his muscularity. The discrepancy is likely related to the fact that pixels in Doom's original video modes were rectangular: because pixels were taller than they were wide, and each map unit was proportional in size to a pixel of an in-game texture, flat, or sprite, height units were larger than width units. A more realistic interpretation (if there is any such thing) is perhaps that one "width unit" (w) corresponds to 5/6 of a "height unit" (h).
So, it would be more accurate if you change the line

Code: Select all

Scale.Y = double(Height);
to

Code: Select all

Scale.Y = double(6 * Height) / 5;
Here's a comparison:

This only works correctly if the project's PixelRatio is at "Doom" settings (1.2). For projects with PixelRatio 1.0, your fix looks wrong on them.

level.pixelstretch can be used to retrieve said setting. Can you figure out how to fix this into the calculation? I suck at maths.
dodopod
Posts: 66
Joined: Wed Oct 04, 2017 2:00 pm
Contact:

Re: RadiusDebug - Visual Actor radius utility [ZScript/DECOR

Post by dodopod »

Nash wrote:This only works correctly if the project's PixelRatio is at "Doom" settings (1.2). For projects with PixelRatio 1.0, your fix looks wrong on them.

level.pixelstretch can be used to retrieve said setting. Can you figure out how to fix this into the calculation? I suck at maths.
In that case the line should be:

Code: Select all

Scale.Y = double(Height) * level.pixelStretch;
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: RadiusDebug - Visual Actor radius utility [ZScript/DECOR

Post by Nash »

20th December 2018 Update:

- Proper height scale calculation
- Update size every tic so that Actor death height, and any other real-time changes will be reflected. This might be a little expensive, but because RadiusDebug is a development aid, I am not going to bother to optimize it

Download link in first post
gramps
Posts: 300
Joined: Thu Oct 18, 2018 2:16 pm

Re: RadiusDebug - Visual Actor radius utility [ZScript/DECOR

Post by gramps »

Hey, that's pretty neat!

I'm just gonna throw an idea out there; not really related but this brings it to mind. I'd love to see an add-on with a toggle button that freezes time, and then draws a box like that around anything you point at, and also pops up all the stuff from the "info" console command in a nice little overlay thing. I've found myself using "freeze" and "info" a lot during some experimentation and something like that would speed things up quite a bit.
User avatar
TDRR
Posts: 815
Joined: Sun Mar 11, 2018 4:15 pm
Operating System Version (Optional): Manjaro/Win 8.1
Graphics Processor: Intel (Modern GZDoom)
Location: Venezuela

Re: RadiusDebug - Visual Actor radius utility [ZScript/DECOR

Post by TDRR »

Can you also add A_RadiusGive radius viewing? Even if it's just for RGF_CUBE.
dodopod
Posts: 66
Joined: Wed Oct 04, 2017 2:00 pm
Contact:

Re: RadiusDebug - Visual Actor radius utility [ZScript/DECOR

Post by dodopod »

I made a custom event handler, which displays actor radii depending on a CVar. Just like with TestRadiusDebugHandler.pk3, load RadiusDebugCVar.pk3 after RadiusDebug.pk3 to make it work.

RadiusDebug can be set to either:
  • None
  • Monsters
  • Pickups
  • Solids
  • Shootables
  • All
Oh, by the way, calling RadiusDebug.Disable() doesn't work for me.
Attachments
RadiusDebugCVar.pk3
(1.63 KiB) Downloaded 181 times
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: RadiusDebug - Visual Actor radius utility [ZScript/DECOR

Post by Nash »

I have a few cool ideas to make this mod even more useful and actually universally auto-load ready (meaning you can just leave it in your autoload, and turn it on or off with a button toggle/option menu), and I can also add useful text info about what you are pointing at - but I'm going to way for GZDoom to add "extends Actor" functionality first (which will be technically possible, last I understood it).
User avatar
Kizoky
Posts: 291
Joined: Mon Nov 14, 2011 9:59 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: Around weirdos, I'm the biggest weirdo among them
Contact:

Re: RadiusDebug - Visual Actor radius utility [ZScript/DECOR

Post by Kizoky »

I edited dodopod's code, so now you'll get a menu + and when you change the setting in the menu the box will be attached to the actors in real time
No need to reload the level
Spoiler:
Attachments
RadiusDebug_Menu.pk3
(7.73 KiB) Downloaded 193 times
Kzer-Za
Posts: 509
Joined: Sat Aug 19, 2017 11:52 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: RadiusDebug - Visual Actor radius utility [ZScript/DECOR

Post by Kzer-Za »

It appears there is a bug that crashes the game when you create a class inherited from ammo and inherit specific ammo types from this class. I have:

Code: Select all

Class SchismAmmo : Ammo
{
	Default
	{}
}

//---------------------------------------------------
Class SchismGoldWandAmmo : SchismAmmo replaces GoldWandAmmo
{
	Default
	{
		Inventory.PickupMessage "$TXT_AMMOGOLDWAND1";
		Inventory.Amount 10;
		Inventory.MaxAmount 100;
		Ammo.BackpackAmount 10;
		Ammo.BackpackMaxAmount 200;
		Inventory.Icon "INAMGLD";
	}
	States
	{
	Spawn:
		TNT1 A 0 NoDelay {RadiusDebug.Enable(self);}
	Exist:
		AMG1 A 1 Bright;
		Loop;
	}
}
As you can see, I removed everything from SchismAmmo, so it seems it is not any property or flag that is responsible, but the very fact of inheriting. If I inherit SchismGoldWandAmmo form just "Ammo", everything works. But if I inherit it from SchismAmmo, then regardless of what SchismAmmo has defined in it or it being just empty, the game crashes with:

Code: Select all

VM execution aborted: tried to read from address zero.
Called from RadiusDebugMe.Tick at RadiusDebug.pk3:zscript/radiusdebug/radiusdebug.zc, line 82
Post Reply

Return to “Script Library”