Breakable objects: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Tels (talk | contribs)
first stub
 
Tels (talk | contribs)
fix name of spawnargs
 
(12 intermediate revisions by the same user not shown)
Line 5: Line 5:
== Introduction ==
== Introduction ==


This article deals with details in regarding of breakable objects in the physics simulation.
This article deals with details in regarding of breaking single objects apart in the physics simulation.


=== Destroying Objects ===
For breaking the connection between bound objects, please see the article about [[breakable bonds]].


When the force acting on one entity becomes very strong, it should be destroyed. This can happen while the entity is still bound to another entity, or after they have become unbound. These cases are already working for some objects, like wine bottles.
== How to Destroy Objects ==


Currently, this is done by setting the following [[:Category:spawnargs]] on one entity:
When the force acting on one entity becomes very strong, it should be destroyed. This can happen while the entity is still bound to another entity, or after they have become unbound.
 
Currently, there are two ways to denote that an entity should be destroyed/broken upon ''death'':
 
=== Setting [[health]] ===
 
By setting the following [[:Category:spawnargs|spawnargs]] on one entity:


        "broken"                        "models/darkmod/junk/wbottle01_broken.lwo"
         "health"                        "20"
         "health"                        "20"


The [[Spawnarg:health]] sets the amount of damage that needs to be done to the object until it breaks, and the
the entity will be destroyed when the health drops to 0.
[[Spawnarg:broken]] sets the model that will replace the default model after the destruction.
 
The [[health]] sets the amount of damage that needs to be done to the object until it breaks.


Drawbacks of this method are that health can drop by small forces acting on the entity. After the health has dropped considerable, a small force can then suddenly break the object. For instance, damaging a wine bottle by 9 points 2 times would leave the bottle with only 2 points health, and thus suddenly a damage of 2 points can destroy the bottle.
Drawbacks of this method are that health can drop by small forces acting on the entity. After the health has dropped considerable, a small force can then suddenly break the object. For instance, damaging a wine bottle by 9 points 2 times would leave the bottle with only 2 points health, and thus suddenly a damage of 2 points can destroy the bottle.


Another drawback is that forces do not translate into damage except in some specially coded exceptions, like hits from weapons.
Another drawback is that forces do not translate into damage except in some specially coded exceptions, like hits from weapons or movers that ''damage'' entities.  
 
=== Setting [[max_stress]] or [[max_torque]] ===


{{important|headline=TODO|text=
When the forces acting on a moveable entity exceed these values, the entity breaks:
* Except wine bottles, no object breaks when a sufficient force acts on it.
 
* Strong forces do not nec. damage entities. For instance dropping a crate on a bottle does not break the bottle.}}
        "max_stress"                        "50 50 200"
        "max_torque"                        "10 10 100"
 
== What happens when an entity dies? ==
 
Depending on which spawnarg is set, different things happen when an entity is broken:
 
=== [[broken]] ===
 
Setting:
 
        "broken"                        "models/darkmod/junk/wbottle01_broken.lwo"
 
The [[broken]] sets the model that will replace the default model after the destruction. The entity itself will stay around, but it cannot be damaged any further.
 
=== def_flinder, flinder_offset, flinder_probability and flinder_count ===


=== Unbinding ===
Setting:


[[Image:Bind entities.png|right]]
        "def_flinder"              "models/darkmod/junk/wbottle01_broken.lwo"
        "flinder_offset"            "0 0 -5"
        "def_flinder1"              "models/darkmod/junk/glass_shard.lwo"
        "flinder_count1"            "6"


It is possible to bind entities together via the [[spawnarg]] ''bind''.
will result in the bottle spawn one broken lower half bottle, and 6 glass shards. The original entity will be removed from the world automatically.


The bound entity is called "slave" (or bindslave), while the entity it is bound to is usually called "master (or "bindmaster").
''flinder_offset'', ''flinder_probability'' and ''flinder_count'' are optional.


Binding means that the relative position of the slave to the master will stay the same. Forces that act on either the slave or the master are relayed to the other entity, making them act as if they were one unit.
== Todo ==


When the force acting on one of the bind-members becomes to strong, the bind should break up.
{{important|headline=TODO|text=
* Except wine bottles, no object breaks when a sufficient force acts on it.
* Strong forces do not nec. damage entities. For instance dropping a crate on a bottle does not break the bottle.
* Damage needs to be calculated from the impulse, not from a fixed set of "damage" values.}}


{{important|headline=TODO|text=This is currently never the case.}}
== See also ==


==== Forces acting on bound entities ====
* [[Breakable bonds]]
* http://en.wikipedia.org/wiki/Lever
* http://en.wikipedia.org/wiki/moment_%28physics%29


{{physics}}
{{physics}}

Latest revision as of 19:32, 11 February 2008

Things to remember:

This article represents work-in-progress and does not necessarily reflect the current working state of the code!

Introduction

This article deals with details in regarding of breaking single objects apart in the physics simulation.

For breaking the connection between bound objects, please see the article about breakable bonds.

How to Destroy Objects

When the force acting on one entity becomes very strong, it should be destroyed. This can happen while the entity is still bound to another entity, or after they have become unbound.

Currently, there are two ways to denote that an entity should be destroyed/broken upon death:

Setting health

By setting the following spawnargs on one entity:

       "health"                        "20"

the entity will be destroyed when the health drops to 0.

The health sets the amount of damage that needs to be done to the object until it breaks.

Drawbacks of this method are that health can drop by small forces acting on the entity. After the health has dropped considerable, a small force can then suddenly break the object. For instance, damaging a wine bottle by 9 points 2 times would leave the bottle with only 2 points health, and thus suddenly a damage of 2 points can destroy the bottle.

Another drawback is that forces do not translate into damage except in some specially coded exceptions, like hits from weapons or movers that damage entities.

Setting max_stress or max_torque

When the forces acting on a moveable entity exceed these values, the entity breaks:

       "max_stress"                        "50 50 200"
       "max_torque"                        "10 10 100"

What happens when an entity dies?

Depending on which spawnarg is set, different things happen when an entity is broken:

broken

Setting:

       "broken"                        "models/darkmod/junk/wbottle01_broken.lwo"

The broken sets the model that will replace the default model after the destruction. The entity itself will stay around, but it cannot be damaged any further.

def_flinder, flinder_offset, flinder_probability and flinder_count

Setting:

       "def_flinder"               "models/darkmod/junk/wbottle01_broken.lwo"
       "flinder_offset"            "0 0 -5"
       "def_flinder1"              "models/darkmod/junk/glass_shard.lwo"
       "flinder_count1"            "6"

will result in the bottle spawn one broken lower half bottle, and 6 glass shards. The original entity will be removed from the world automatically.

flinder_offset, flinder_probability and flinder_count are optional.

Todo

TODO

  • Except wine bottles, no object breaks when a sufficient force acts on it.
  • Strong forces do not nec. damage entities. For instance dropping a crate on a bottle does not break the bottle.
  • Damage needs to be calculated from the impulse, not from a fixed set of "damage" values.

See also