[Added] Destructible geometry

Moderator: Developers

Destructible geometry

Postby ZZYZX » Tue Oct 30, 2018 6:38 pm

Hello.

So basically this is a horizontally borrowed feature from another 199x game called Radix (just because I occasionally poked at the map format of Radix and realized we can have it here as well).
In the original engine, the point is that wall has some hitpoints, you can shoot at the wall and once hitpoints reach 0 some scriptable trigger is executed.

Intended usages:
Automated glass breaking by explosive effects (without having scripted actors)
DN3D-like forcefield effects (since this actually returns information in the form of "wall X was damaged at X/Y/Z")
Script effects based on any shooting at specific parts of sector linedefs or even sector floor, with numbers (i.e. count of damage, damage type...)
Ideally, once ZScript part is implemented, it should be straightforward to script it in a way that the user only needs to put a specific texture (e.g. lamp or glass) that will do some actions once destroyed (spawn effects, change textures, flags) — with everything else managed from events.

Video!
https://streamable.com/4qmal

Changes to UDMF entities:
  • sector
    • healthfloor
    • healthceiling
    • health3d
    • healthfloorgroup
    • healthceilinggroup
    • health3dgroup
  • linedef
    • health
    • healthgroup
    • damagespecial (flag)
    • deathspecial (flag)

Added specials:
  • 150:Line_SetHealth
  • 151:Sector_SetHealth

Added ACS functions:
  • GetLineHealth — returns health for either first line by id, or health group's health if it's set
  • GetSectorHealth — returns health for either first sector by tag+part(floor/ceiling), or health group's health if it's set

Here's how it visually works in the geometry:
Image
The "health3d" field in the sector is expected to be used in 3D floor control sectors for convenience (along with SECPART_3D and separate trigger things for this).

About health groups:
"Health group" is an object that synchronizes health for all participating geometry (lines and sectors).
This is so that you can have a single visual object composed of multiple sectors/linedefs that will receive damage synchronously.
Any damage-related specials (either by line activation or sector actions) will be called for each of the participating objects.

About logic of receiving damage:
With ACS and line/thing actions, it's simple: hitscans and projectiles inflict damage directly, radius damage inflicts radius damage based on closest part of sector (or closest part of damage group) that's not blocked.
Specials will be executed either on each damage or when health of object is zero (i.e. it dies), depending on which trigger is used (there are two kinds of line activation flags and sector triggers).
With ZScript, I'm planning to make an event that should provide all the detailed information on who hit which object and how, and provide a way to modify received damage in the event callback.

Current issues:
  • ZScript interface planned but not implemented
  • Portals are not supported for radius damage (p_map.cpp:P_GeometryRadiusAttack) because the logic is complex enough even without portals
  • Radius damage is kinda weird with slopes
  • ACS_ExecuteWithResult combined with health groups is going to return weird values for GetHealth resolved
  • Behavior of shooting at portals/skyboxes/other weird line/sector types is undefined (suggestions?)
  • 3D floors not yet implemented — planned as sector triggers in the control sector (with health also taken from the control sector) resolved

Overall this is still somewhat in dev and testing, code review/opinions/whatever highly welcome.

Build for testing if anyone is interested: https://www.mediafire.com/file/zblzrcfc ... y.zip/file
PR for GZDoom: https://github.com/coelckers/gzdoom/pull/611
PR for ACC: https://github.com/rheit/acc/pull/74

Example wad (only works with destructiblegeometry branch or build above):
http://www.mediafire.com/file/nahkay69e ... t.wad/file
Last edited by ZZYZX on Mon Nov 05, 2018 1:26 am, edited 1 time in total.
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine

Re: Destructible geometry

Postby Graf Zahl » Wed Oct 31, 2018 1:11 am

Can you please reorganize this that it isn't scattered throughout the code? This is such a complex and extensive features that all related code should be in its own file so that they are easier to find later. Also, after doing that, please squash the commits into one.

This looks like something that will most likely be extended later, and nobody wants to hunt for all the code involved.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Destructible geometry

Postby ZZYZX » Wed Oct 31, 2018 6:19 am

Squashed.

Moved most complex logic to p_destructible, with the exception of handling projectile death (because it's too closely related to the collision code).
Overall most of the scattering is due to existing structure — UDMF fields are declared in one file, action specials in another, ACS functions elsewhere... But yes, tried to have most special logic in the separate file.
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine

Re: Destructible geometry

Postby Graf Zahl » Wed Oct 31, 2018 6:24 am

ZZYZX wrote:Overall most of the scattering is due to existing structure


I know. At some point I'd really like to clean up the code. But this has grown over 24 years by now - 4 of those even before ZDoom came to be.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Destructible geometry

Postby ZZYZX » Wed Oct 31, 2018 8:11 am

btw, a random bug that I've found while implementing this, is that P_XYMovement doesn't trigger "actor hits ceiling" actions (can be resolved by this condition)

Easiest test case is making a slope like this and running into it:
Image

I think just logging it here for now to avoid merge hell later if I report/fix it separately.
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine

Re: Destructible geometry

Postby Graf Zahl » Wed Oct 31, 2018 12:18 pm

Added.

Now you can add the fix for the last mentioned issue. ;)
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Destructible geometry

Postby ZZYZX » Wed Oct 31, 2018 3:00 pm

https://github.com/coelckers/gzdoom/pull/614 :)

Actually I didn't expect this to be added so soon, so it's a bit unfinished ;)
One thing that I can remember right now is that savegames are not handled at all, so I'm going to soon make a new PR to serialize list of FHealthGroups as well as Health values for various entities, so that it at least starts being usable.

Everything else from the issues (ZScript, 3D floors...) maybe later as a single different PR.
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine

Re: Destructible geometry

Postby Graf Zahl » Wed Oct 31, 2018 3:36 pm

Actually, if you have unfinished features it's not time for a PR. It's better to just start a discussion thread here then. I actually missed the serialization issue completely when looking through it.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Destructible geometry

Postby ZZYZX » Wed Oct 31, 2018 3:44 pm

Well on serializing, here it is: https://github.com/coelckers/gzdoom/pull/615
With 615 in, the unfinished features are more like "there's still something to add" rather than "it doesn't work".

But on the actual feature addition — hence the "maybe later" — after a discussion and some planning that is. Since while existing parts are very unlikely to change, I'm still not sure how some new things are going to work.

Either way sorry for submitting an incomplete PR, actually expected some review and responses ranging from "[No]" to "X is broken, redo before adding please" :) Won't do it again.
Going to make the second part more complete. Other than that, I actually missed the serialization as well. Only realized after merging.
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine

Re: Destructible geometry

Postby Rachael » Wed Oct 31, 2018 4:03 pm

In GitHub, where you first create a PR (before actually submitting it), you will get a compare link in your location bar.

If you want to trigger a discussion and a review for your code, share this link, before actually submitting the PR.

Here is an example of such a link: https://github.com/coelckers/gzdoom/compare/master...jewalky:destructible-saveg?expand=1
User avatar
Rachael
QZDoom + Webmaster
 
Joined: 13 Jan 2004

Re: Destructible geometry

Postby Gez » Wed Oct 31, 2018 4:32 pm

Or perhaps you can name it accordingly, e.g. this is currently entitled "[DON'T MERGE YET] Shadows".
Gez
 
 
 
Joined: 06 Jul 2007

Re: Destructible geometry

Postby dpJudas » Wed Oct 31, 2018 4:57 pm

Having an open PR that is being worked on isn't so good because it produces emails each time someone commits to it.
dpJudas
 
 
 
Joined: 28 May 2016


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 2 guests