PDA

View Full Version : Building / tile collapse logic



Chris
11-11-2011, 10:51
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!

Nuttss
11-11-2011, 11:37
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?

Sathra
11-11-2011, 12:24
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.

Chris
11-11-2011, 12:59
Where's Gazz when you need him?

Aelius
11-11-2011, 13:38
A simple solution is to transform some of the walls into pillars.

like this:

http://img337.imageshack.us/img337/47/xenopilars.th.jpg (http://imageshack.us/photo/my-images/337/xenopilars.jpg/)

Uploaded with ImageShack.us (http://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.

http://img9.imageshack.us/img9/326/xenopilarsdestroyed.th.jpg (http://imageshack.us/photo/my-images/9/xenopilarsdestroyed.jpg/)

Uploaded with ImageShack.us (http://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.

Lobster Man Commander
11-11-2011, 14:25
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 :)

Chris
11-11-2011, 15:18
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...

Aelius
11-11-2011, 15:27
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

anotherdevil
11-11-2011, 18:46
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...

GrumpySage
11-11-2011, 19:18
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):


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.

iamkyon
11-11-2011, 19:27
A somewhat pointless question: Will building collapses leave heaps of rubble scattered about in their wake? Or will the Stuff That Edifices Are Made Of simply be annihilated and the tiles affected by the fallout be switched to their damaged or destroyed variants?

Hoywolf
11-11-2011, 19:39
But losing half your prise squad to randomly collapsing buildings isn't fun...

This makes the game a bit more interesting IMO, now you can collape a building with aliens in it hoping to kill them. but this can spell death if the aliens to the same to your squad.

overall I love the idea!

Quartermaster
11-11-2011, 20:31
The simplest algorithm which may create the behavior you want is to have it have each tile calculate a resiliency value. If that value is below a certain point then the tile will collapse. Let the resiliency value be the count of adjacent tiles plus the number of walls which have a corner touching the tile times a certain value (let's say 2). If this sum is less than a certain value (lets say 6) then the tile would "collapse". You could play around with the relative values until you found something you liked. The nice thing about this approach would be that if the tiles and walls are object oriented than this could be a property of each tile which is updated as nearby tiles are damaged. If the tile has already been "damaged" by being shot up this could easily have some effect on the property which could lead to further collapsing. The same thing could be said for fire damage.

A similar mechanism could be used on the Z axis for walls that are stacked upon one another.

Gazz
11-11-2011, 22:12
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!
What should work:

Pass 1:
Check all wall tiles starting with ground floor +1.
If a wall tile has any undestroyed wall tile within 1-2 tiles on the floor below, it remains standing.
Whether 1 or 2 tiles work best there depends on how fragile you want your buildings.

If you somehow figure merely damaged wall tiles into this then you will have to deal with cases where wall tiles above an undestroyed but damaged section crumbles.



Pass 2:
Check each floor tile of a level.
If 4+ adjacent tiles are destroyed (either wall or floor), the tile crumbles.
Destroyed wall tiles count 2x for that.
Damaged (not destroyed) floor tiles count for 0,5.
Repeat Pass2 until no more floor tiles crumble.



That avoids long sticking out "bridges" of floor tiles remaining standing but leaves those intact that have a clean horizontal or diagonal connection.

Punching a few holes into an intact floor doesn't bring it down.

That the wall tiles count double in pass 2 forces some erosion of floor tiles close to walls.
To totally collapse a floor you need to work harder.

That damaged floor tiles count for 1/2 means that if you damage a large area of floor, the center tiles (surrounded by 8 damaged tiles) will fall down.
Slightly increase the 0,5 (to 0,6 or 0,7 tops) if you want to see that effect more often.


Yes, it is pretty simplistic but it's easy for every player to figure out why it happened.
Walls crumble in a pyramid shape,
floors crumble if they cannot "span" in a straight line between two intact walls.

It's a completely generic and predictable system, which doesn't require any fancy material properties.



Randomisation:
Below, some have posted their idea of introducing randomness.
I don't really like any of them because they are either complex, requiring wholly new material properties, or lead to hard to control sequences of destruction, which could all too easily turn runaway and destroy an entire floor for no visible reason.

My approach:
On creation of the level, flag a few wall + floor tiles (maybe 5 % ?) as "invisibly destroyed" - only for purposes of collapsing.
With an otherwise healthy building, this will not cause any damage all by itself.
Once a building takes damage, those "weak spots" will nudge the domino effect along but there is no chance that a few missing tiles will topple an entire floor.

I'm not convinced that this is entirely necessary but if you want randomness, this is a controllable way to to it. If there's something you absolutely don't want then this is entire buildings crashing down from the first hit due to some freak hit points / structural stability combination.



Visualisation:
You could even show the collapse.
The proposed system leads to a domino effect where the tile destruction / collapse can be animated in the exact order it is calculated in.
Walls come down, floor tiles break off and fall down, starting from the "weak spots", until only the stable tiles remain standing.
The best features are usually 90% show and 10% code. =P





Where's Gazz when you need him?
Actually, yesterday I was busy sweet-talking another developer into implementing a cool feature, close deadline or no. =P

behroozwolf
11-12-2011, 19:20
You could even show the collapse.
The proposed system leads to a domino effect where the tile destruction / collapse can be animated in the exact order it is calculated in.
Walls come down, floor tiles break off and fall down, starting from the "weak spots", until only the stable tiles remain standing.


^^ Epic. Two thumbs up for that idea. ^^


I like where Gazz is going, although I want more possibilities for unpredictable behavior-- collapsing buildings are totally chaotic and with the right framework we can make it more intuitive and even more fun. So, some quick thoughts:

Remaining HP affects support strength:



It feels intuitive that causing additional damage should make structures more likely to collapse, even if no tiles are immediately destroyed.

Weight the floor-supporting value (Gazz's Pass 2) contributed by damaged tiles based on the % of tile HP remaining. Damaged tiles at full HP counting as 0.75 supporting tiles, linear reduction down to 0 support at 0 HP.




Randomize Collapse Patterns:



Obvious artificial patterns are distracting, the results will look a lot better if we add some noise.

Assign a random strength modifier for collapse purposes to each tile at map start that directly raises/lowers that tile's support requirements. +/- 20% is probably a good place to start tweaking.




Delayed collapses for unstable areas:




Randomized tile modifiers can also give a framework for delayed collapses in an intuitive way-- once the dust has settled, it's probably safe.

At the end of each turn, re-roll the random modifiers for all tiles that are within 2 tiles of dense smoke/dust or fire, apply fire damage, then run a collapse cycle. Boom! Delayed collapses!


Weight and Instability:




Heavy objects put more stress on damaged floors.

Tiles with objects sitting on them should receive a negative modifier for collapse purposes. Quick and dirty option: weighted modifier based on the cover value of the object.


People and vehicles:




People are heavy too.

Each time a unit steps onto a tile, run a check with an additional weight modifier to see if the floor is likely to collapse. Critical fail above a certain threshold = instant collapse cycle, normal fail plays a creaking noise, interrupts Player's movement, and pops a dust/smoke burst-- sets timer to collapse that tile and run a collapse cycle after triggering unit has moved X more tiles? Likely to be especially useful when large/heavy aliens are implemented.

Akavit
11-12-2011, 23:55
Here is a variation of the pounds per tile idea merged with the above poster's reduced strength for reduced HP method.

First of all each wall and floor would be assigned a weight (might vary for different tilesets). Load capacity would be equal to HP. If a soldier or a tank (hovertanks are excluded) is on top of the tileset it will add to the weight of the floor.

Collapsing would occur when the combined load limit of the adjacent tiles and adjacent lower walls can no longer support the weight of the object.

For the sake of illustration I'll start tossing out numbers.

Walls: 200HP and 250 weight
Floors: 100HP and 200 weight

If a tile is damaged or destroyed the game will check the walls and floors the 8 adjacent tiles to see if they have enough HP worth of supporting objects nearby to prevent collapse.

Gauddlike
11-13-2011, 00:53
Similar to the system Gazz suggested you could give each tile a percentage chance of falling depending on how many missing sections it has around it.
Walls below the tiles level could still count double to represent their importance.
That should make every collapse look more individual and a little less predictable.

Wall sections (level 1) that are destroyed could have around a 75% chance of the section directly above (level 2) coming down and if that one does then a 50% chance of the ones either side (level 2) also dropping.
Floor tiles that are adjacent to a destroyed wall would have a 50% chance of falling.

Missing floor tiles could give a 25% fall chance to any tile north, south east or west and around a 15% chance to ne, nw, se and sw tiles.
This would stack depending on how many were missing, more missing support, higher chance of falling.
That is enough to make sure a tile always falls when the four immediately supporting tiles are missing but may sometimes survive otherwise.

Tying a weight system in would just be a matter of adding percentages when something passed over.
No idea how much that would slow down the engine though if it needs to check that often.

All of those numbers are rough off the top of my head and could be changed either way.

Gauddlike
11-13-2011, 01:37
Just a quick piccy to show what I was thinking about and the way it could propagate.
http://www.goldhawkinteractive.com/forums/attachment.php?attachmentid=144&d=1321179542
This fall check can be done whenever a model moves onto a tile with anything above a 0% fall chance.
Heavier armour or larger aliens/vehicles can add their own fall chance to the check.

Not sure these sorts of ideas were what Chris was looking for as it doesn't actually provide him with a formula.

anotherdevil
11-13-2011, 02:21
This makes the game a bit more interesting IMO, now you can collape a building with aliens in it hoping to kill them. but this can spell death if the aliens to the same to your squad.

overall I love the idea!
I like the idea of it, I dislike the idea of it being too random. Knowing that an explosion might bring down the room one man is in, that's fine. But that same explosion RANDOMLY bringing down the entire structure, including two other guys on the opposite side of the building, not cool.

All this talk about how buildings collapse being random. Why do people think this? I am sure there is a very good explanation for this with physics, and that it's not random at all...

Oh and I like Gazz' idea. Didn't actually read it through and through, but I've read enough of his in the past to know it'll be solid =]

iamkyon
11-13-2011, 02:32
Gauddlike, I'm afraid your link is broken.

I'm of the same opinion as the last four-ish posters: introducing an element of randomness, however slight, to the formula could give rise to all manner of excitement and hilarity.

Gazz
11-13-2011, 07:03
I'm not convinced that having a great deal of randomness in the process is such a good idea.
I feel that some of the proposed ideas would be very hard to control.
Didn't do the math, though. If you suggest an intricate feature, you do that and provide examples for the likely good/bad cases!

I added my own approach to my post above.
A way to include some randomness without the danger of it "going rogue" and entire buildings collapsing for no discernable reason.

Gauddlike
11-13-2011, 10:23
Actually shooting out a supporting wall is a pretty good reason for things to collapse.
Ok so small arms fire shouldn't bring down a farmhouse.
The problem is that if you start taking out walls with anything then sooner or later it is going to cause things to fall off.
The numbers I gave were probably a little high but as I said, just random rounded figures off the top of my head.
With that model there is definitely a small chance of a random shot taking a chunk out of the structure.
There is also a good chance of a rocket barely making a dent beyond the initially destroyed tiles.
Adding constraints to how much CAN collapse may well make sense.
The numbers should be tweaked but it is hard to do without actually seeing how the effect works in game.

*edit* Fixed the link in my previous post as well, cheers.

Phishfood
12-14-2011, 11:39
I like the idea of it, I dislike the idea of it being too random. Knowing that an explosion might bring down the room one man is in, that's fine. But that same explosion RANDOMLY bringing down the entire structure, including two other guys on the opposite side of the building, not cool.

All this talk about how buildings collapse being random. Why do people think this? I am sure there is a very good explanation for this with physics, and that it's not random at all...

Oh and I like Gazz' idea. Didn't actually read it through and through, but I've read enough of his in the past to know it'll be solid =]

Well, what you need is controlled randomness. Sure, one rocket won't bring down a whole warehouse, but it could just bust the walls it hits, or it could chain to 10 squares of wall and a few of floor or it could take out the entire room.

I guess the mathematical formula you want is basically including several rules.

1) A floor tile with no supports falls. I think for aesthetics, diagonals shouldn't count as support. It would be odd to have a square of floor hanging by a corner.
2) a floor tile with an intact wall does not fall.
3) a floor tile supported on 2 sides (not counting diagonals) does not fall.

Then you need some sort of probability map. The closer a floor tile is to a removed wall the higher the % chance of falling.

So, on level initialisation all floors have a 0% chance of falling.
Then, as soon as a wall is removed the chance of falling is set. That way you can set up a big building that has huge floors and no pillars, but if any wall is removed it instantly becomes fragile. Seems a bit unrealistic though, since you'd get a warehouse collapsing as soon as one wall tile was removed.

So... we need to calculate on a wall stretch e.g. the North Wall.
a) % of wall stretch removed - removing 2 wall segments does nothing, removing 50% does a lot
b) "quality" of the damage. Removing 10 tiles in one chunk does more than shooting out 10 tiles spaced evenly.
That then scales - destroying 3 chunks of a large building does nothing, but taking out the wall of a garden shed causes instant total collapse.

so
P(fall) = % of walls destroyed / (distance from destroyed segment * k) + (% supporting floors already fallen - 25%) + damage + load modifier + Rand(-20 to +20)


So, floor can fall if
1) Directly damaged
2) all four surrounding pieces destroyed
3) Nearby walls are destroyed - "nearby" defined by k, scale for buildings? k <1 causes greater chaining, k>1
4) Random 20% chance either way.

General gist is an undamaged tile will never fall, a damaged tile may fall especially if loaded and a nearby wall is taken out.

<edit 2>

Actually, better and simpler is

P(fall) = % of walls destroyed * straight line distance from intact wall* k * adjoing floors already fallen * damage * load * random(0.8-1.2)

Balance the variables right and you should get cool stuff like
WXX#
W###
WWXXX

(W = Wall, # = floor, X = collapse)
stays standing until a person tries to step on it, then it falls but absurd strucures like
WXXXXXXX#
WXXXXXXX#
WXXXXXXX#
W#######
WXXXXXXXX
never happen
Lots of multiplys, which can be costly in performance especially when we are looking at a large multifloor building.

You then need a second formula for upper wall segments I guess, simply:
P(wall fall) = 33% * # of below walls fallen. ie.

Side view:
####A####
###BBB####

Take out all 3 Bs and A will fall. Take out 1 and it might fall. Perhaps weight it some, so middle B gives 50% fall chance and edge B only 25%

<edit 3>

Theres also some possibilities on how this is applied. Obviously if every tile is checked every turn, its going to be slow and also one rocket will eventually take out every building piece by piece. So either it needs to be a one off check on a rocket explosion or perhaps after each explosion a building is unstable for 3 turns and after that will not collapse any more.

PotatoMcWhiskey
01-04-2012, 01:10
So I spent a few hours working this out. My idea was to keep this as simple as possible while retaining the behaviour needed. That is simple rules that produce fairly realistic structural integrity.

So, the basics of the idea are that Walls are on the edges of tiles and provide support and that floor tiles require support to remain in position.

Heres the rules that i've come up with the produce the behaviour pretty well.

A wall has a Strength value of 1 and a range value of 2.
A floor tile requires 2 strength provided by walls to remain supported.
If a floor tile is surrounded by floor tiles with a combined strength value of 4 or more that tile is considered supported.
A floor tile can transfer excess strength up to one tile away. In essence a floor tile with a strength 4 and a nearby tile of strength 0 it will transfer that 2 strength to that tile. Strength can only be transfered once and the remaining strength cannot be less than 2. Transferred strength can "push" strength onto another tile in a linear direction no further than 3 tiles in any direction.

Imagine a Line of tiles named A, B, C, D, E with the strength value of 4,3,1,0,0 in a line.
A=4 B=3 C=1 D=0 E=0

Tile A Pushes 2 Str into B which pushes 2 Str into C which pushes 1 Str into D.
A=2 B=3 C=2 D=1 E=0
Since we're assuming D and E have no surrouding tiles providing support they have insuficient support to remain supported and collapse.
The Strength that was pushed through C returns to C.
We're left with. A=2 B=3 C=3 D=Collapsed E=Collapsed

I'll try to illustrate my concept in stages. It interacts kinda weird but produces the results I think you're looking for and is easily tweaked and adjusted. This is the rough concept that I will be refining when I can.

http://i.imgur.com/cKmzJ.png

This image depicts a three by three grid of floor tiles on Z level 1(floor 1), surrounded by walls on Z level 0(ground).
This explains the idea of range. Each wall can provide direct support for a tile floor above it extending two tiles.

Each wall connecting to a piece of floor adds 1 strength. Here is the best illustration of this using the previous example I could manage.

http://i.imgur.com/ESUxf.png

The red lines depict the range of each of the walls. The black squares and numbers depict the strength value of each floor tile.

Hopefully as I show you more examples it will become more clear.

http://i.imgur.com/rOt9M.png

Here is a 5x5 grid surrounded by walls. Since everything is supported or has a total surrounding value around it higher than 4, everything is considered stable and supported.

What happens when we remove an entire wall?

http://i.imgur.com/OVUxW.png

As you can see, the entire south wall has been removed. Thus the four tiles with exclamation points are in danger of falling as their strength is lower than 2 AND there is not a total value of 4 strength surrounding them. The logic detects this and attempts to even out the values if it can underneath the rules above.

The logic prefers the closest possible tile to take strength from. Strength cannot be transfered over a distance larger than 3 tiles. This helps prevent tile strength coming from extreme distances. And helps explain why strength is not taken from more distant parts of the building.

We end up with something like this. A tile has collapsed.

http://i.imgur.com/wrEEL.png

If we remove another wall the effect becomes even more pronounced. I'll do a series of images of pieces being removed.

http://i.imgur.com/LPnzL.png
More strength is moved around sadly the algorithm can't find a way to support the two bottom tiles, so they are destroyed.

http://i.imgur.com/u7H4f.png

What if the piece of wall two tiles up from the tile we just hit gets destroyed? Lets find out!

http://i.imgur.com/Zcauz.png

Nothing collapses, but the building is weakened. What if we pop the wall just above that?

http://i.imgur.com/slz9z.png

Uh oh, we got three tiles that can't get the support they need. They fall out.

http://i.imgur.com/l3wo7.png

Double Uh oh! Now that wall that was holding everything together has no way to get its support to the other tiles. A chain reaction occurs.

http://i.imgur.com/HPB3N.png

Hopefully that illustrates the basic idea. Complex behavior is emerging from relatively simple rules. I know I might have made a mistake here or there but this is a fairly rough draft and Its 1 A.M. and I've been working on this idea for about six hours. Making this post took about 2 trying to explain the basics and I know I left some out. Its semi untested on larger more complex less square buildings or buildings with inner walls. I can imagine it limits the size of buildings somewhat but the numbers and ranges can be adjusted. So far the idea works for what you need even in the very infantile state. It seems simple and straightforward to me.

Gorlom
01-04-2012, 04:28
Imagine a Line of tiles named A, B, C, D, E with the strength value of 4,3,1,0,0 in a line.
A=4 B=3 C=1 D=0 E=0

Tile A Pushes 2 Str into B which pushes 2 Str into C which pushes 1 Str into D.
A=2 B=3 C=2 D=1 E=0
Since we're assuming D and E have no surrouding tiles providing support they have insuficient support to remain supported and collapse.
The Strength that was pushed through C returns to C.
We're left with. A=2 B=3 C=3 D=Collapsed E=Collapsed

If A loses 1 point of strenght does that one fall down then or retract it's strenght to keep itself supported? Will it then steal from C or from B?

Edit: also in your example you have forgotten to strenghten the second topmost middle tile that is very savable. the tile under that might ven be saved with a bit of strenght shunting around while its still only the bottom wall thats been damaged. that rearrangeing will unfortunately cause trouble when you remove the wall at the bottom left.

Edit: I realie i may have ignored the "adjacent tiles combined 4 strenght" rule. but still what is preventing the tiles at the top from shifting around integrity strenght and causing problems when they realigne due to new circumstances? If the algorith is going to be as intelligent as you want it to be, wouldnt it have to try to equalize the tiles strenght preemptivly?

Gauddlike
01-04-2012, 09:43
In answer to anotherdevil the reason for some randomness is because a completely predictable effect is not as interesting.
Sure in RL the collapse of a building can be predicted with fair certainty by demolitions experts with precisely placed explosives but that isn't what we are talking about here. Even then they sometimes fall in the wrong direction, fail to fall at all, or the collapse is bigger than expected.
I think being able to hit a building that you have troops inside with a rocket launcher, safe in the knowledge that they are stood 2 squares outside any possible harm, is less interesting than having to take the risk of not killing your target or accidentally taking out your own troops as well.
The last couple of ideas don't sound much different to mine except rather than a simple fall/stand mine had a chance of collapse that got higher depending on damage to the area. Would be nice to be able to alter the chance based on material types etc.

anotherdevil
01-04-2012, 10:08
Reflecting more on it, I agree that there should be some degree of randomness, but just a degree of it. Maybe a few extra tiles get destroyed, but not the difference between a half demolished and a fully demolished building

Sathra
01-04-2012, 13:12
Unless its a small building. Completely flattening a small building (house) with a single rock or charge should be possible, if rare. Because its fun.

Gauddlike
01-04-2012, 13:40
Especially if it is one built by a local council, you can do significant damage to them by putting up a picture in the wrong place.

PotatoMcWhiskey
01-04-2012, 19:01
If A loses 1 point of strenght does that one fall down then or retract it's strenght to keep itself supported? Will it then steal from C or from B?

Edit: also in your example you have forgotten to strenghten the second topmost middle tile that is very savable. the tile under that might ven be saved with a bit of strenght shunting around while its still only the bottom wall thats been damaged. that rearrangeing will unfortunately cause trouble when you remove the wall at the bottom left.

Edit: I realie i may have ignored the "adjacent tiles combined 4 strenght" rule. but still what is preventing the tiles at the top from shifting around integrity strenght and causing problems when they realigne due to new circumstances? If the algorith is going to be as intelligent as you want it to be, wouldnt it have to try to equalize the tiles strenght preemptivly?

Everytime a change occurs in the structure the stats are recalculated.

So let us say A=4 B=3 C=1 D=0 E=0 again.

In the previous example A shifts 2 strength to B so that we are left with.
A=2 B=5 C=1 D=0 E=0

Then the strength is pushed through B into C etc leaving us with. A=2 B=3 C=2 D=1 E=0

D and E collapse and the structure returns to stand by. When a piece of the building is damaged again, lets say only A is reduced by 1.

A=3 B=3 C=1

D and E are already gone. A can only push 1 strength through B into C but it is enough to save it all. Leaving us with A =2 B=3 C=2.

Then the logic checks all these as "Stable" and wait until a tile in its group is changed or damaged.

I will admit, its still very rough and it doesn't account for everything I want it to yet, but I can easily see how to expand it and allow for larger more complex buildings while retaining a believable structural integrity without it being too fragile or strong.

The logic only decides to try and move strength around if a tile is considered unsupported. Then it tries to find the closest available strength to support it. If no strength is found under the rules then the tile collapse and the algorithm is run again until the building is stable. If everything is considered stable then the logic awaits damage to the structure to determine when to check if things are unsupported. Pre-emptively moving the strength around doesn't really make sense because theres no where for it to go. It only goes where it is needed. And it goes to the closest place it is needed.

I'm a budding programmer, so I'm really enjoying thought crafting this idea before I try and see if I can actually build it.

I have the idea almost fully structured in my head, communicating that idea is another thing altogether.

anotherdevil
01-04-2012, 19:49
Unless its a small building. Completely flattening a small building (house) with a single rock or charge should be possible, if rare. Because its fun.

Especially if it is one built by a local council, you can do significant damage to them by putting up a picture in the wrong place.
This I agree with. But if the randomness is the difference between half a building (what would seem reasonable from the rocket blast) and the whole building, that's a no no

Parax
01-05-2012, 17:20
Why not just have a topple down effect if there is no building floor or building wall in the 9 squares below then the floor/wall above collapses.. yes you could remove all the walls and leave the floor and the building would stay up, but any explosion would damage the floor and cause a collapse.

You would have to identify internal floors (load bearing) from external floors, and where you need a bridge effect you'd have to use special load bearing external floors.

(sorry if this has been said, I skipped a few posts)

P.

Gorlom
01-05-2012, 17:27
Why not just have a topple down effect if there is no building floor or building wall in the 9 squares below then the floor/wall above collapses.. yes you could remove all the walls and leave the floor and the building would stay up, but any explosion would damage the floor and cause a collapse.

You would have to identify internal floors (load bearing) from external floors, and where you need a bridge effect you'd have to use special load bearing external floors.

(sorry if this has been said, I skipped a few posts)

P.

Would that mean if you shot at the floor in a 3x3 area with a lazer or plasma weapon that the tiles above start falling down? Without a single wall or or roof being shot out? (Assuming the room is larger then 9 squares)

And wouldnt you as a player want to avoid
you could remove all the walls and leave the floor and the building would stay up,
I bet a lot of players would be annoyed with that and think Chris was just beeing sloppy.

Parax
01-05-2012, 17:36
Yes and No...

Yes, the one centre tile would fall.. but after nine damaging blasts why not have some instability nearby! (with 3x3 only one tile falls from above, the second floor above that still has 8/9 supports)

No, I wouldn't mind that... it's no worse than the original.

I think it's been decided that any collapse method is better than none at all. In my opinion there's nothing wrong with quirky physics! it pays homage to the original floating buildings after all, its just a small improvement.. maybe try simple see and how it goes this is alpha testing afterall.

P.

IceVamp
01-09-2012, 14:17
Visualisation:
You could even show the collapse.
The proposed system leads to a domino effect where the tile destruction / collapse can be animated in the exact order it is calculated in.
Walls come down, floor tiles break off and fall down, starting from the "weak spots", until only the stable tiles remain standing.
The best features are usually 90% show and 10% code. =P




^^ Epic. Two thumbs up for that idea. ^^


What he said. They said.

anotherdevil
01-09-2012, 23:27
I agree, though it would have to be done quickly so that the payer wasn't constantly waiting if they used explosives, turning them off those weapons because everything took too long to actually break up

IceVamp
01-10-2012, 21:21
Yeah, I'm envisioning about three rows of tiles per second. Making it go pretty fast, but still noticeable. Or maybe a random .2 to .5 second delay every second row so it doesn't look too mechanical.
Bam, bam, delay, bam bam, delay, bam.

I really hope this can be implemented. The holding of ones breath and widening eyes as one sees an explosive head for the building your men are using for cover. *gleee*

Bibidibop
01-11-2012, 06:29
I wish I knew enough facts and math for this, so I hope I can help anyway.

In older buildings, the facade is load bearing, but past a certain point, large buildings no longer use load bearing facades. For the most part, or to the degree of older buildings.

Assuming load bearing exterior walls, the facade, just as a complete guess, will carry around 50% of the load, or more. You could treat every exterior, non- window or door frame surfaces, as a load bearing column section by dividing all of that by the amount of total wall load. You should end up with each wall section carrying less weight than the sparse existing columns. For instance, a building with a load of 100,000 kg, 50 load bearing facade sections, taking 50% load, and 8 columns, taking 50% load would put 1,000 kg on each working wall section, and 6,250 kg on each column. Then you stack those layers of 100,000 kg. Can that be turned into collapse data?

In a modern construction, the wall doesn't support the structure at all. You'll have more, or stronger, columns, and wall destruction won't do anything. Some structures may be like a hollow, columnless box, except for columns right at the walls. For sake of ease, you could make all structures work modern, even ones which look old.

Gorlom
01-11-2012, 06:50
By modern how modern are we talking about? 20th century? 1950? 1970? 1990? 2010?

Bibidibop
01-11-2012, 07:25
Unfortunately I can't say definitely, but 60's to modern times would see a lot of curtain walls, non load bearing walls, except for the World Trade Center which was unique for reintroducing load bearing walls. One thing to watch out for though are steel frame buildings where all the columns are in the outer wall. That's still a curtain wall design, at least I think it is because the wall is secured to the beams, rather than the floors to the walls. Also, lumber houses, using 2X4 construction don't have load bearing walls, but the frame of the house is in the wall and it amounts to a similar effect.

The theme is, if the walls aren't load bearing, you can blast them off, as long as the frame is intact. Blast the frame enough and the building should come down. For me it comes back to just treating the walls like a bunch of columns, and using a variable for how much the outer walls support.

Bibidibop
01-14-2012, 03:10
I just thought of something. We can destroy walls, and free standing objects, and floors will collapse. Does this mean we can attack wall/ceiling sections directly to make holes so we can shoot down and up to other levels?

Sathra
01-14-2012, 16:28
Hmm, you can currently directly target walls, but not sure about ceilings. I don't think that's in yet.

Gazz
01-16-2012, 16:30
not sure about ceilings
Wouldn't that be the same as targeting the ground on the next higher floor...?

Gauddlike
01-16-2012, 17:52
Yes but I think the query is more about if you can target the floor tile from the room below it, or if that would technically be out of view.
For example if the targeting system drew line of sight to the top of the tile rather than any part of it.

ufoFan
02-19-2012, 10:00
Is property damage calculated in with how pleased the country is with the mission, say like civilians dead?

Sunshard
02-19-2012, 14:01
That could become a bit of a nightmare with aliens casually walking through structures.

irongamer
02-20-2012, 21:57
Is property damage calculated in with how pleased the country is with the mission, say like civilians dead?

This is an interesting idea. It can often take fewer turns to just blast everything to little bits than to advance troops in a safe manner to building, setup guys for entry, enter building, and clear each room. I like the idea of property damage as it gives an incentive to be less destructive and play with more finesse. Aside from civilians possibly being in the building there is really no down side to just leveling the building in question. I think property damage should be calculated, within reason.

I would expect only your teams fire or explosions trigger by your team would be calculated. Or just make adjustments to the formula to account for some collateral damage or damage done by the aliens themselves.

[Edit]
Oh, this could also have achievements and/or badge: Demolition Man.