Page 1 of 5 123 ... LastLast
Results 1 to 10 of 47

Thread: Building / tile collapse logic

  1. #1
    Beloved Leader Chris's Avatar
    Join Date
    Oct 2011
    Location
    London, UK
    Posts
    6,364

    Building / tile collapse logic

    OK, so one of the things that will be in Xenonauts is collapsing buildings. It's more realistic, of course - no more floating upper levels of buildings after you've shot out the ground level! We want to implement it in the next month or two ideally.

    The problem is, I'm struggling a little to find a method of doing this in formula terms. I need to find a formula that marks ground tiles as 'collapsed' and destroys them if they have insufficient support from the level below, but this is harder than it looks.

    In game terms, floor tiles fill a full square and wall tiles fill the lines between different tiles. Generally a floor is strong enough to survive the wall directly below it being destroyed, provided it still has walls around it to support it. My basic assumption was that it a floor tile on the edge of a building had any wall tile in an adjacent tile on the level below, then it would remain standing.

    The only problem with this is how to account for all the tiles in the centre of the room. Obviously the walls only run around the outside of the building in many cases, and we don't want a situation where a couple of outer wall sections are shot out and the entire floor collapses - but niether do we want a situation where shooting out 4-5 wall sections next to one another only causes a collapse of the tiles immediately next to them. Ideally it'd form a sort of V-shaped tapering wedge of collapse going into the centre of the floor.

    But yeah, I'm a bit short of ideas here. If anyone's got some ideas for basic logic underpinning the tile / building collapsing, then post them here!
    Chris England - Xenonauts Project Lead
    chris@xenonauts.com
    @GoldhawkInt

  2. #2
    <Witty Custom Title> Nuttss's Avatar
    Join Date
    Nov 2011
    Location
    Atlanta, GA, USA
    Posts
    56
    Can you use a variartion of the logic used for civilians fleeing from us and the aliens?

    I don't imagine it would be physics perfect, but floor tile distance from a wall calculation done only after an individual tile no longer has all of it's sides with an existing floor tile or wall.

    So, if a floor tile is connected to an existing wall, 0% chance of failure. If it is in the center of the room with floor tiles all around it, 0% chance of failure. However, if a tile used to be next to a wall, wall is destroyed, it is no a loooong ways from the next wall and it colapses, then the next one. Or is that type or approach, one by one too sequential?

  3. #3
    Commander Sathra's Avatar
    Join Date
    Oct 2011
    Location
    Australia
    Posts
    3,091
    It sounds reasonable. If the formula screws up though, the entire interior of the building will collapse. Might not be too bad a thing to see sometimes...

    And, no. I have no ideas as to how to do a formula.
    Common wisdom proposes that at minimum 60% of the field of engagement should be rubble and/or on fire. As such the munitions budget has been increased 50%. Operations debriefs have shown that 15% is insufficient for current combat requirements.
    Ein jeder Engel ist schrecklich.

  4. #4
    Beloved Leader Chris's Avatar
    Join Date
    Oct 2011
    Location
    London, UK
    Posts
    6,364
    Where's Gazz when you need him?
    Chris England - Xenonauts Project Lead
    chris@xenonauts.com
    @GoldhawkInt

  5. #5
    Squaddie Aelius's Avatar
    Join Date
    Oct 2011
    Location
    Lisbon, Portugal
    Posts
    52
    A simple solution is to transform some of the walls into pillars.

    like this:



    Uploaded with ImageShack.us

    Make them X times more HPs than normal walls. Once one of these collapses it will bring down upper sections down with it and imediatly destroying any normal walls/tiles in its vicinity.



    Uploaded with ImageShack.us
    Add a new solid cube tile to represent them.
    Any unit caught below or on top of the "cave in" would take damage according with the amount of debris that has fallen on top of the unit + the hight it has fallen (someone at the roof would take falling damage instead of crushing damage, someone in the 2nd floor of a 5 story high building would take both)

    To avoid the building looking as it has been cut clean as a cake, after X tiles further from the destroyed pillar the tiles would have "diminishing returns" on destruction, stronger as closer to the next good pillar, and that math would be done bottom up ALWAYS. The level where the pillar was destroyed would be calculated 1st, and only "surviving" tiles on that level would allow the math to continue on upper levels counterparts. ASA you have a good tile being calculated, ALL the next ones from there to the next good pillar will have 100% chance of being ok (at the same lv ofc)

    If a tile is destroyed by the math on the level "where the pillar collapsed" theres a 100% chance that any tile on top of that is destroyed also.
    If a tile on the level where the pillar was destroyed survives allows for the diminishing returns math to apply on the tile above it, and so on.


    Lets see if i can represent what i mean:
    I = Good pillar
    *= Destroyed pillar
    H = good wall
    _ = Destroyed wall


    IH______________* 5th floor
    IHHH____________* 4th floor
    IHHH____________* 3rd floor
    IHHHH___________* 2nd floor
    IHHHH___________* 1st floor
    IHHHHH__________* (level where the pillar was destroyed)





    That will create the "V" shape u are looking for i think.
    Last edited by Aelius; 11-11-2011 at 13:33.

  6. #6
    Alien Commander Lobster Man Commander's Avatar
    Join Date
    Nov 2011
    Location
    T'Leth
    Posts
    29
    Can you classify the floor-tilesections inside rooms as wall tiles without them being walls? I had to draw this to find the logic.
    But its just like you said. The V shape comes up as the most logical tile collapse mechanic.

    Seems the easiest way to logically make this to work is to say that each tile that is not next to a tile connected to a wall section should collapse. But the only problem is, there is a bunch of them in the middle of the room witch has no connecting wall next to them.

    Rough sketch using symbols where X represents destroyed wall, and O a collapsed floor tile on a two story building seen from the sky:

    ._ XXXXX _ _
    |##OOO###|
    |###O####|
    |########|


    Hope my useless, uneducated attempt was any help
    Last edited by Lobster Man Commander; 11-11-2011 at 13:29.
    Scientist: [an autopsy on Zoidberg is taking place] "Heart."
    Dr. Zoidberg: "Take, I've got four of them!"
    Scientist: "Stomach contents: One deviled egg."
    Dr. Zoidberg: "Deviled egg?"
    [eats it from the tray]
    Scientist: [pause] "The same deviled egg..."

  7. #7
    Beloved Leader Chris's Avatar
    Join Date
    Oct 2011
    Location
    London, UK
    Posts
    6,364
    I mostly want to avoid designating things as pillars if it can be avoided, as it's more work when each building is constructed and the resulting behaviour isn't always fully predictable. It'd be much better to have a formulae that can automatically calculate whether a floor tile should be destroyed based on whatever wall tiles below it have been destroyed.

    I kinda know what behaviours I want, but I can't seem to put them into a working formula...
    Chris England - Xenonauts Project Lead
    chris@xenonauts.com
    @GoldhawkInt

  8. #8
    Squaddie Aelius's Avatar
    Join Date
    Oct 2011
    Location
    Lisbon, Portugal
    Posts
    52
    Quote Originally Posted by Chris View Post
    I mostly want to avoid designating things as pillars if it can be avoided, as it's more work when each building is constructed and the resulting behaviour isn't always fully predictable. It'd be much better to have a formulae that can automatically calculate whether a floor tile should be destroyed based on whatever wall tiles below it have been destroyed.

    I kinda know what behaviours I want, but I can't seem to put them into a working formula...
    In that case you can add a pounds per square formula. Each wall is able to withstand X amounts of pounds. So just give a value in pounds to each tile.

    When a wall is destroyed any tile pounds above it will be transfered to adjacent walls, up to the breaking point where everything above comes crumbling down until walls that are left are able to sustain the weight again.

    oh and btw Chris, predictability is not always a good thing. When a building collapses is almost impossible to predict what will fall and what will remain standing. In a game unpredictability more often adds to gameplay than the other way around
    Last edited by Aelius; 11-11-2011 at 14:34.

  9. #9
    Elected Chryssalid Hugger anotherdevil's Avatar
    Join Date
    Oct 2011
    Location
    New Zealand
    Posts
    1,522
    But losing half your prise squad to randomly collapsing buildings isn't fun...

    Chris, the only way I can see it working is in 2 stages.

    Firstly all floor tiles are connected to their adjacent floor tiles. They will then fail when the adjacent one (or ones) in any direction have taken enough damage.
    However this HAS to work in conjunction with the wall tiles, and that is the second part. So the floor tiles that come into contact with wall tiles take cues from the wall as well as adjacent floor tiles.

    This allows walls to be shot, and when enough of that has happened, adjacent floor tiles will do the same. However just because one floor tile has failed does not mean they all will, as the other floor tiles surrounding the failed one all have more adjacent tiles etc. to hold them up.Now you just need to work out what the breaking point is for floor tiles, and how much damage carries over to adjacent floor tiles when the first fails...
    "What are you gonna do, talk the alien to death?"
    - James Cameron, on Sigourney Weaver's concern about the use of guns in Aliens

  10. #10
    Do you want to have a chance to collapse the walls on the ground floor as well? I wasn't sure from your post.

    A suggestion off the top of my head: I would have a recursive function calculating a chance for a floor tile to fall where at least 1 'support' is missing (support meaning either wall or other floor tile).

    Pseudo code (Java):
    Code:
    floorCollapse(Tile t) {
      int collapseChance = Random value (%, so from 0-100);
      int collapsedSupports = number of collapsed supports;
    
      if(collapseChance <= (collapsedSupports*4)) {
        collapse tile;
        for each adjacent tile {
          floorCollapse(Adjacent tile);
        }
      }
    }
    Hope that makes sense, it is not a final solution obviously, in its current form it has the potential to create a huge hole with a single wall destroyed (and one might have to fiddle with some details if you want a greater chance of creating a wedge rather than a hole that spreads evenly in all directions). Also, it isn't currently taking into account your basic assumption of "a floor tile on the edge of a building with any wall tile in an adjacent tile on the level below, would remain standing".

    Of course, it might end up checking some tiles several times, but on the other hand if you only check a tile once and more tiles around it collapses, it needs to be checked again.


    I also like Aelius' suggestion of having a weight that is distributed to the walls.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •