Page 1 of 1

[ZSCRIPT] Polyobject doors - unlocking and breaking

Posted: Wed Sep 13, 2023 10:53 am
by Sir Robin
Two things I want to do:
1. Create a lock pick object that when used on a polyobject all locks are removed
2. Make a polyobject destroyable by taking damage

For the first one, I thik what I need to do is create a inventory item that when used fires a linetrace. If the linetrace hits a wall, check to see if that wall is part of a poly object and if so get the poly object number. Then iterate all lines in the map looking for polyobject specials and if they point to that poly object number then remove the lock on that line.
I can create the inventory item and fire the ine trace, the rest I'm trying to figure out.

For the second one, I think I could be able to use the UDMF settings for Health and HealthGroup. I'm still tying to figure out exactly how to do that. Is it possible to destroy a polyobject like you can destory an actor? And where to put the code? An event handler? Or have a line that activates an invisible actor and put the code in that actor's activation function?
The thread on destructable geometry I'm trying to understand that but the example is done with ACS.

Re: [ZSCRIPT] Polyobject doors - unlocking and breaking

Posted: Wed Sep 13, 2023 4:54 pm
by 22alpha22
Polyobjects are not sectors but just lines (usually 1-sided) that get moved at runtime. They can not be destroyed, only moved. Sectors cannot be destroyed either, in fact as far as I'm aware, no map geometry can be destroyed. Effects like you are looking for will most likely need to be faked with 3D models.

Re: [ZSCRIPT] Polyobject doors - unlocking and breaking

Posted: Thu Sep 14, 2023 5:42 am
by Jarewill
22alpha22 wrote: Wed Sep 13, 2023 4:54 pm Sectors cannot be destroyed either, in fact as far as I'm aware, no map geometry can be destroyed.
Not exactly right, as GZDoom does have destructible map geometry and lines, floors and ceilings have health values.

I haven't looked too deep into it, but this thread might be of use.
I also don't know how well it will work with polyobjects.

Re: [ZSCRIPT] Polyobject doors - unlocking and breaking

Posted: Thu Sep 14, 2023 11:46 am
by Sir Robin
So here's how I understand it:
Level geometry (verticies, lines, sectors, etc) cannot be created or destroyed.
Verticies cannot be moved (x,y changed) therefore anything attached to them (lines, sectors) cannot be moved.
A "destructable" wall (or door or whatever) is really just a closed sector (ceiling @ floor) that when taking enough damage springs open to simulate having a hole blown through it. That's how for example the rocket-hole walls in Duke3d work.

Polyobjcts I'm not so sure about.
I understand how to create them in the mapper, and that the enigne uses the control sector and lines to create the polyobject at map load time. And that it uses the anchor and startspot to move it after map load.
What I'm asking is that once created like this in the engine, is it a dynamic object like an actor that can be destroyed to remove the poly object from the game?
If not, the object can be "removed" by just moving it to somewhere outside the map so it's not seen anymore.
I've been told that a PolyObject is just a collectoin of lines and has no sector. I've been told this even by the developers, but I keep finding that not to be true. A PolyObject may not be located in it's control sector after level load, but it is still programmatically attached to it. You can manipulate that sector and the poly object will be affected in realtime, just like any other line attached to a sector would.
Jarewill wrote: Thu Sep 14, 2023 5:42 am Not exactly right, as GZDoom does have destructible map geometry and lines, floors and ceilings have health values.

I haven't looked too deep into it, but this thread might be of use.
I also don't know how well it will work with polyobjects.
It's true that lines and sectors have health values and track damage, but it's just a convenience feature provided for mod developers to use. Nothing actually happens when a line or sector reaches 0 health unless a developer has written specific code to handle that event.
So that's what I'm writing, code that will monitor the health values of the door and "destroy" it when any of them reaches 0.
And thanks for the link, very helpful.

Re: [ZSCRIPT] Polyobject doors - unlocking and breaking

Posted: Thu Sep 14, 2023 11:51 am
by Sir Robin
Here's a sample of what I've got working so far
PolyObject_Door_Destroy.wad

The destruction needs some fanfare (a shattering noise and animation, debris actors spawned and flung, etc) but it's basically functional.
Also could have the lines removed from the automap (set to do not draw) and clear the activation specials. You get the point.