CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.31k stars 4.13k forks source link

Flat roof on Buildings / chain link fence and locked wire gate #76376

Open ZweiFedern opened 2 weeks ago

ZweiFedern commented 2 weeks ago

Is your feature request related to a problem? Please describe.

if i go on roof tops of buildings, that have a water heater, water purifier, standing tank, a chain link fence and a locked wire gate, and i smahed the fence an the gate, for parts all droped down. because there is no flat roof under the fence.

Bildschirmfoto vom 2024-09-12 10-46-55

Solution you would like.

Is it possible to get a "ground" under the fence and gate? like concrete if the rest of the roof top is all make of concrete.

Describe alternatives you have considered.

No response

Additional context

No response

PatrikLundell commented 2 weeks ago

The problem is that a chain link fence is "terrain", and the underlying system doesn't support "terrain" on top of a base "terrain". It's the same issue with trees (which are also "terrain"). A smashed chain link fence results in the terrain turning into chain fence posts, and smashing those turns the terrain into "t_null", which I would guess means it turns into whatever the base terrain of that overmap tile is (open air above ground, such as on a roof, soil at the ground level, and rock below ground, basically). For this to work properly, the system would have to support more than one layer of "terrain". I've suggested a split between a "terrain" layer and a "construction/vegetation" layer. It would not be trivial to implement, however (and a lot of work to convert things to work with it).

ZweiFedern commented 2 weeks ago

ok look here, i just found this. building - grocery store roof, with chain link fence. i smash the first "chain link fence" and get pips and no hole in the celling. ("flat roof" was under the fence). Bildschirmfoto vom 2024-09-13 16-26-11 i smash the second "chain link fence" and the pips drop down in a hole. ("open air") Bildschirmfoto vom 2024-09-13 16-52-28

under one fence is flat roof - now i have the question: why does it work there and not with the other tiles? Bildschirmfoto vom 2024-09-13 17-05-19

i see on cdda-guide.nornagon.net - chain link fence there are 2x maybe is there the "wrong" build in?

PatrikLundell commented 2 weeks ago

First you smash chain link fence into chain link posts, and then you smash chain link posts into open air. There is only one version in the JSON files, although it also has two additional alias names.

The above is what happened when I tried it. If you're using an old version you may be subjected to roof autmagic repair, although that should only happen on a save/load cycle.

Syler1984 commented 6 days ago

As a workaround in /data/json/furniture_and_terrain in:

{
    "type": "terrain",
    "id": "t_chainfence_posts",
    ...
   "bash": {
      "ter_set": "t_null",
    }
},

Value of bash -> ter_set can be changed to something like:

"ter_set": "t_thconc_floor"

Syler1984 commented 6 days ago

ok look here, i just found this. building - grocery store roof, with chain link fence. i smash the first "chain link fence" and get pips and no hole in the celling.

I can confirm that on fresh experimental. Gunstore roof (data/json/mapgen/store/s_gunstore.json):

Screenshot_3

Screenshot_2

As you can see, smashing fence and gate north and south of the character did result in proper roof tiles generating. In this case it happens because there is a wall under these two tiles, which generates roof above them.

Syler1984 commented 6 days ago

As a workaround in /data/json/furniture_and_terrain in: ... Value of bash -> ter_set can be changed to something like:

"ter_set": "t_thconc_floor"

To follow up on that: Similar changes needed to be made for t_chaingate_l, t_chaingate_c and t_chaingate_o (lokced, unlocked and open chain link gates).

Also, all related terrain leaves t_dirt when hacksawed or torched instead of t_null: Screenshot_4

Some other terrain like railings seem to function in similar way, leaving some sort of solid floor instead of nothing when bashed.

Night-Pryanik commented 6 days ago

Value of bash -> ter_set can be changed to something like: "ter_set": "t_thconc_floor"

This will lead to concrete floor generating even if fence is located somewhere in open field.

Syler1984 commented 6 days ago

Value of bash -> ter_set can be changed to something like: "ter_set": "t_thconc_floor"

This will lead to concrete floor generating even if fence is located somewhere in open field.

Like i said "workaround". It probably less exploity to have concrete floor in the field than hole in the roof of a gunstore. But it could be anything else but t_null. Wooden floor, dirt, anything.

Syler1984 commented 6 days ago

This is actually interesting:

ok look here, i just found this. building - grocery store roof, with chain link fence. i smash the first "chain link fence" and get pips and no hole in the celling.

I can confirm that on fresh experimental. Gunstore roof (data/json/mapgen/store/s_gunstore.json):

As you can see, smashing fence and gate north and south of the character did result in proper roof tiles generating. In this case it happens because there is a wall under these two tiles, which generates roof above them.

As far as I can tell, whenever terrain is destroyed, the game checks terrain one level below for presence of a "WALL" flag. If the flag is present, it generates terrain from "roof" property. Which, in case of a regular wall is set to "roof": "t_flat_roof". So regular roof tile is generated.

It might be possible to extend this logic to some new tag, like "GENERATE_ROOF" or something. And then check, if destroyed terrain already equal to "roof", then just ignore that logic to avoid indestructible roofs. This should fix this issue and many similar ones by generating proper terrain instead of open air.

I'll look for a place in the code which handles that logic.

Syler1984 commented 6 days ago

And then check, if destroyed terrain already equal to "roof", then just ignore that logic to avoid indestructible roofs.

This logic exists in the game code already. I don't see any other effect of "WALL" tag other than generating roof tile above it (unless it is already the "roof"). It does not influence pathfinding, it does not make terrain impassible.

Basically, just adding "WALL" flag to every floor in the game already fixes the issue (despite being a misnomer). It does add extra "layer" to bashing normal floors down if floor does not match "roof" terrain of a floor below it.

I still haven't looked at the code though.

PatrikLundell commented 6 days ago

The WALL flag affects support, and thus collapse effects. If you'd add it to a floor it would allow a roof to levitate over it. It may also affect visuals and similar things that tries to join up walls with each others.