Not logged inOpenClonk Forum
Up Topic Development / Scenario & Object Development / Explosions inside containers
- - By Maikel Date 2015-01-13 16:45
There something wrong with explosions from objects inside containers causing double the damage to the container itself. Now this begs the questions, how should these explosions behave.

First of all containers can be contained in containers, so we can have a stack of containers. I will put some notions which should be true in general.

* If the exploding object is inside a container with ContainBlast (or any container in the stack is ContainBlast) the explosion should not affect the landscape or objects outside the stack of containers.
* If there is no ContainBlast in the stack of containers, it should affect the landscape and outside objects.
* At all times the explosion should affect the objects inside the container and the container itself.
* An explosion cause damage to parent containers and their contents until a container which contains the blast is reached.

Example 1: Flint in lorry in wagon in submarine: flint damages lorry and its contents, then damages wagon and its contents then damages submarine and its contents, no damaging of landscape and objects outside cause submarine is ContainBlast.
Example 2: Flint in Submarine in wagon: flint damage submarine and contents and nothing more since the blast is contained.

Would this be the preferred and expected behaviour? Feedback needed!
Parent - By Marky [de] Date 2015-01-13 18:42
You described the ideal behaviour, in my opinion.
Parent - By Clonkonaut [de] Date 2015-01-13 22:30
yes
Reply
- - By Maikel Date 2015-01-13 23:13
It gets more technical, what happens when a container inside a container explodes? Where do the objects go? inside the parent container? And then do they get blasted twice?

Or is it maybe better to first blast the outmost container and work the way to the core?
Parent - By Maikel Date 2015-01-13 23:54
I think I have got the solution, maybe more tomorrow.
Parent - - By Sven2 [de] Date 2015-01-14 00:38
Aren't contents removed anyway when an object explodes?
Parent - - By Maikel Date 2015-01-14 08:56
Not for all objects, I want for example to make the lorry scatter its contents when it explodes.
Parent - - By Zapper [de] Date 2015-01-14 09:26
How could the lorry itself ever explode?
Parent - - By Maikel Date 2015-01-14 10:07 Edited 2015-01-14 10:11
Cause I wanted to try that, in my opinion that should not be an indestructible vehicles somehow.

Edit but this is not really a lorry specific problem, but will also affect content developers.
Parent - - By Zapper [de] Date 2015-01-14 17:02
Ah okay. But wouldn't the lorry (and any other container) simply do the destruction thing in its Damage-Callback and care for flinging around its contents itself?
Where do you need engine support?

PS: and the lorry wouldn't Explode but just burst into fragments and remove itself, right? It's not made of gunpowder or steam-tanks after all
Parent - By Sven2 Date 2015-01-14 17:37
You don't need engine support either way because Explode is defined in script. You can also just overload Explode in the lorry script.
Parent - - By Maikel Date 2015-01-14 18:01
A destruction callback can be triggered in many ways (blast, burned, out of landscape, script), not all of them should toss objects around, but the explosion initiated one should.
Parent - - By Zapper [de] Date 2015-01-14 18:19
Mh.

That could be solved by making the explosion deal damage to the container first. IFF the container is destroyed through that damage, it would simply Exit it's contents. And since the explosion had not worked through all the free objects yet, it would just treat the former contents like usual free objects and fling them around.

PS: also the Damage callback could get (or gets?) the source of the damage as a parameter like Fx*Damage and then just check for FX_Call_DmgBlast
Parent - By Maikel Date 2015-01-14 18:31
I know that, I am working on it.
Parent - - By Sven2 Date 2015-01-14 14:33
Yeah, that's a good change. Maybe Explode can generally be changed to eject contents in all directions according to explosion strength.

(Unless the object is contained, in which case stuff can just go to the parent container)
Parent - By Maikel Date 2015-01-14 14:46
Let me first try to fix the explode bug and fix the remove object behaviour when contents are not deleted.

And then implement this behaviour for the lorry only (is already done, that is how I found the bug), and then we can see how we like it, it makes settlement a bit more dangerous :D
Parent - - By Clonkonaut [de] Date 2015-01-14 13:35
Strange behaviour though. Your contents don't simply vanish when you explode!
Reply
Parent - By Pyrit Date 2015-01-14 15:20
They're vaporized! :D
Parent - - By Clonkonaut [de] Date 2015-01-14 13:34

> Where do the objects go? inside the parent container?


Of course inside the parent container. Everything else would make no sense.

> And then do they get blasted twice?


Why? Do objects get blasted twice when their container (not contained) explodes?
Reply
Parent - By Maikel Date 2015-01-14 14:13
Currently, I haven't tested, but I have found a way to prevent that.

Indeed they should go into the parent container, but currently they don't do that I suppose. RemoveObject has a parameter which is off default to eject contents on object removal.

But script solutions could do something else obviously...

Let me outline a new approach which also involves changes to RemoveObject at some later point, when it is more evolved.
- By Maikel Date 2015-01-14 23:38
The last four commits here contain the current status, I will do some more testing to see whether all corner cases are covered and then push it.

Of course some additional eyes on the code are appreciated.
- - By Maikel Date 2015-01-15 18:35
Current changes pushed:
* ContainBlast is now a property, either false or true.
* RemoveObject(true) first tries to enter its contents into the parent container instead of exiting them altogether.
* Test scenario for explosions in containers.
* Changed explosion behaviour:
  * explode container first and then move up the list of parent containers until a BlastContain one or the last one is found.
  * BlastContain prevents damage to landscape and outside objects / parent containers.
  * exploding in a container means, deal damage to container first, then to contents.
  * if container is destructed, move contents outside (or they are removed), they will be blasted later.
  * explosions propagated to a parent container do not damage the child container (it has already been damaged).
* The lorry now ejects its contents on destruction and also tosses around a few burning fragments.

Only remaining issue:
A BlastContain container which is destroyed, will contain the blast when inside other containers, but not when it is the last one.

What is the expected behaviour there?
Parent - - By Clonkonaut Date 2017-10-27 14:46

> * RemoveObject(true) first tries to enter its contents into the parent container instead of exiting them altogether.


I suspect you made the last changes on RemoveObject. If yes, then I wanted to bring this to your attention: http://bugs.openclonk.org/view.php?id=1950
Reply
Parent - By Maikel Date 2017-11-10 10:46
This can be fixed easily, it would be good if someone looks at the bug report to see if potential problems may arise.
Up Topic Development / Scenario & Object Development / Explosions inside containers

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill