Simulating The Body
Version history
Date |
Version |
Author |
Nick |
Changes |
| 2001-03-19 | 0.1 |
Hans Häggström | zzorn | Started. |
| 2001-03-22 | 0.2 |
Hans Häggström | zzorn | Added chapter headings & basic layout |
| 2001-04-21 | 0.3 |
Hans Häggström | zzorn | A new organization. The design is starting to take shape, all the parts fit into the whole. |
| 2001-04-24 | 0.4 |
Hans Häggström | zzorn | Completed the overview of the sub modules. Made an initial beta release. |
| 2001-04-26 | 0.5 |
Hans Häggström | zzorn | Wrote the section on substance effect triggers. |
| 2001-04-28 | 0.6 |
Hans Häggström | zzorn | Wrote section about effect results. |
Abstract
Glossary
Term |
Definition |
|---|---|
| Body Module / |
The name of the body module described in this paper. |
| Body Attribute | |
| Attribute | See Body Attribute |
| Biochemistry Sub module | |
| Organs Sub module | |
| Wounds Sub module | |
| Attributes Sub module | |
| Body parts Sub module | |
| Wound | |
| Organ | |
| Body part | |
| Substance | |
| Effect | |
| Substance Effect | See Effect |
| Organ Effect | See Effect |
| Trigger Condition | Condition that determines when an effect is active. |
| Active Effect | An effect which trigger condition is true. |
Introduction
Goals & motivation
The body module simulates the bodies of the characters and animals in the game. A body contains the basic stats of the character (strength, intelligence, etc) plus others like health and energy. The behavior of the body is controlled by the mind, which can be a player or an AI script. The body module takes care of the automatic processes that go on inside a body. It does not handle the mind, the skills, or the behavior. It does keep track of primitive mental attributes, such as the current emotional state, and consciousness.
The body module offers an API for the other modules that lets them query the various attributes, consume energy, mana and similar attributes, inflict wounds on the body, block the airflow, feed things to the body, and apply drugs, poisons and other stuff on the skin, to the lungs, or in wounds. It allows the mind to affect the emotions and other attributes (meditating could be used to calm down the body, and a battle cry could be used to work up the adrenaline level). The body can also affect the behavior directly in some cases, such as sneezing, yawning, falling asleep, going into shock, twitching, or turning blue. The body module is also the one that determines when a character dies.
Overview
The body module consists of five different parts that form sub modules of the body module. The five parts are body attributes, the biochemistry, organs, wounds, and body parts. The tasks and datastructures of each sub module are described briefly in the following list, and more detailedly below.
- Attributes
- The attributes sub module stores four types of data about
the character body:
- Stats describing the performance and abilities of the character body, such as the basic RPG stats strength, intelligence, and so on. It does not store skills or other non-body related stats however.
- Behavior affecting attributes. These contain things like sneeze or sleep levels, when the level goes above a border value the character sneezes, falls asleep, pukes, spasms, etc. When the action has happened, the attribute value is usually reduced again (so it will be a while before the character falls asleep or sneezes again).
- Appearance affecting attributes. These include things like hair, eye, and skin color, amount of hair, and disease symptoms like red dots all over the body, etc.
- Perceptions. There are also attributes that describe the perceptions of surrounding world and the internal state of the body, gathered by the senses. These include temperature, light level, whether the character is submerged in water/liquid, time of the day, fatigue, pain, hunger, etc. They are subjective perceptions and not absolute facts, so they do not necessarily reflect reality. They can be affected by the body state. For example some drugs could alter the perception of time.
The attributes can be more or less permanent, or vary a lot over time. They can be affected by internal events in the body, and sometimes by external events.
- Biochemistry
- This module simulates the body chemistry and its various internal signal and control systems. The bloodstream can contain a lot of different substances, such as sugar, proteins, fat, oxygen, carbon dioxide, hormones & other signal substances, white blood cells, bacteria, viruses, poisons, drugs, potions, and so on.
- The substances can have temporary or permanent effects on the amount of other substances, and on the value of different attributes.
- The biochemistry sub module keeps track of the amounts of different substances and simulates the effects of the substances.
- Organs
- This sub module handles internal organs. Note that the skin, the skeleton, and the muscular system are also considered organs. The organs can perform functions that affect the biochemistry or attributes of a body. They can also be wounded, and can operate at reduced effectiveness or not at all a a result of this. The match to actual organs is not always 100%, sometimes a whole biological organ system that performs one function can be modeled with one body module organ (such as the digestive system). Organs can also store some substances locally, and release or pick them up from the bloodstream (the body fat layer does this, for example).
- Wounds
- The wounds sub module keeps track of wounds and their healing. One wound can penetrate many different organs. Wounds are also different depending on the type of the damage. Wounds can be infected, and the healing can be affected by various substances in the body or in the wound. For this reason wounds can have local concentrations of substances that can differ from the body wide concentrations.
- Body parts
- Finally, the body part sub module holds information about each body part. It is also used to inflict damage on some part of the body. Each body part contains one or more organs (and the same organ can reach to many body parts, for example the skin).
- The organs are ordered in a layered manner from the front to the back of the body part for the torso this order could be skin, fat, muscles, ribcage, lungs, heart, ribcage, spine, muscles, fat, skin. So a simple one dimensional spatial representation of the organization of the body part is given. When a body part is damaged, the damage has to penetrate the outer layers to reach an inner layer. Clothes and armor are also kept in this list, allowing for a simple consistent way to calculate damage effects and protection against it. The interface to this system is kept general enough that it is possible to replace with a true 3D layout or some other system later.
Sub modules
Attributes
Biochemistry
Substances
- properties
- amount in body
Effects
Both substances and organs can have one or more effects. Each effect has a trigger condition and results. The trigger condition determines when the changes are executed.
Trigger condition
The trigger condition consist of one or more conditions combined with logical operations. Parenthesis or similar can be used to specify the order of the boolean operators, in practice, they can be stored as a tree with logical operations at the nodes and conditions at the leafs. Currently there is only one kind of condition, the range check. A range check specifies a range for an attribute, or for the amount of a substance. If the value is outside the range the condition is false, if it is inside, the condition is true. Ranges have a upper and lower bound, both of which can be infinity (negative infinity for lower bound). More complicated ranges can be specified using many ranges for the same attribute/substance combined with boolean operators.
An effect is said to be active when its trigger condition is true. It is activated when the trigger condition changes from false to true.
An effect can be set to execute only when it is activated, or constantly as long as it is active. In the latter case the max execution frequency will specify the intervals at which a check is done.
A substance has a max execution frequency parameter. This value specifies how often the trigger condition can be checked at most. This is used to avoid very frequent events if some value gets in an oscilating change around a trigger boundary, or when the effect is set to execute constantly when active. Each substance has to have this property, because some might be necessary to check often (a snake poison that is very quick), while others can be run for long times and don't need frequent checks. The simulation code can prioritize (organ effects over substance effects), or lower the max frequency of all effects by some factor if it is necessary to cut down on the processor power devoted to simulating effects.
Results
Executing an effect can have various results:
- An attribute or the amount of some substance is changed temporary or permanently.
- A new trigger condition for this effect is set.
- The max execution frequency for this effect is changed.
Changing an attribute or substance amount
[ToDo: Call attribute or substance amount being changed a 'target', to avoid having to write 'attribute/substance amount' all the time, and to allow easy expansion later to other targets.]
A change in an attribute or substance amount is specified as a mathematical formula depending on the time. We have to be able to computate intersection points between different formulas in constant time, so the formula is limited to a second degree polynom:
valueDelta = at2 + bt + c,
where a, b and c are parameters specified for the formula and t is the time is given in seconds after the execution time.
[Note: I would like to include an exponential term there too, deft, but I'm not sure if that can be calculated in constant time. An alternative would be to use a formula of the shape valueDelta = aekt + b, where e is a natural constant and t is time. This is similar to what is used in physics and biology to describe exponential growth or decline.]
A temporary change of an attribute or substance means that it is possible to reverse later by the effect that made it. Temporary changes to an attribute by different effects are stored separately. A permanent change is added directly to the attribute / substance amount value.
A temporary change can be either cumulative or non-cumulative. A cumulative change means that it is added to the other changes that this effect has on the attribute or substance value. A non-cumulative change means that the previous change on the attribute / substance value by this effect is replaced with the newly calculated change.
Setting a new trigger condition
Changing the max execution frequency
Different types of substances
Nutrition
Hormones
Drugs
Viruses
Bacteria
Parasites
Poisons
Magic potions
Nanotechnology
Biotechnology
How substances enter the body
Digestive system
Skin
Lungs
Injection
Wounds
Sex
- Diseases can spread by somebody breathing near an infected person who just sneezed, etc.
Organs
Intro
Different organs
Storing substances
Organ functionality
Damage
Wounds
Damage types
strangle damage also... ? The time it is applied is important here..
...
Pain
Shock
Bleeding
Infection risk
Poisons, etc
Healing
Stopping the blood flow
Blood coagulation speed
Bandaging
Protecting exposed areas
Preventing / healing infections
Healing speed
Body parts
Properties
Clothing
Wounds
Layout system
- Wound location?
Tie in to physics simulation
- Joint strength
- Muscle strength (max force)
- Stiffness, elasticity
- Max forces that can be applied to joints, body parts before damage (crushing, tearing, or twitching (used in locks))
Creating a body
Selecting stats
Selecting other body parameters
Age
Body construction
Healing speed, needed sleep, etc, etc
Calculating attributes
Cost in circe points?
Generating bodies on the fly for animals & NPC:s
Implementation
Interfaces
External for body
Internal for sub modules
Sub module internal for classes / interfaces
Implementation
Data structures / Class diagram
Optimizations
Enabling only needed parts of the functionality for specific games
Performance
Implementation plan
Summary
----------------------
To do
Movement handling, how tightly integrated should it be?
- Limping
- Strength of muscles in different body parts?
- Damages to muscles or bones in a body part
- Energy usage of different movements, force that the body can provide for the movements
- Coordination & precision
- Reaction speed
- Wounds getting worse because of stress placed on them
- Wounds resulting from stress, tearing of body, forces acting on nodes / different body parts, 3D presentation of body/ body skeleton?
3D model skeleton
- Possible ways to bend different body joints
- Strength of muscles powering different body joints
- Currently max available power from muscles?
- Body parts associated with each model bone
- Limitations in use of different body parts, limping, broken bones, amputations, etc.
- Read by the physics module (if realistic skeletal animation used, or the animation renderer.
- Should movement actions be passed to the body module, allowing it to calculate the energy cost and energy available to the action, or should bodypart/bone movement be given to the body module, and it returns the energy available for use, or should the body module just be asked for x amounts of energy for a certain joint, body part, or generally, and it responds with how much of it was used/available?
Energy consumption
- Resulting from moving the body / doing manual work (movements).
- Thinking (the brain uses more energy when much activity takes place)
- Keeping the temperature
- Processing food
- Healing wounds
- Usage by different organs
=> Energy does not have to be possible to manipulate from outside the module, instead different actions can be done with the organs, or action levels given for them. Many organs work completely internally, for example the digestive system is only fed, and the temperature system depends on clothing and external temperature. Muscle movements and brain activity have yet to be possible to specify somehow. Magic might use internal energy too.. how could this be plugged in? Organ? Substance (mana, created from available energy at some level)?
Internal perceptions
- Characters can perceive some aspects of their internal state, these could be another attribute category.
- Energy, pain, hunger, thirst, cold/warmth, tiredness, mana, sickness, etc.
- This can be used by the mind module to plan actions, or to present / visualize to the player.
- External perception can be used to gain information about wounds, some is also given internally (pain at a location, type of pain).
Substance containers
- Can contain substances
- Can simulate the effects of the substances on each other, on local attributes, and on body global attributes
- Used for the global body substances, for organs that need them, and for wounds
- Substances can be transferred between substance containers. This process can be filtered in some way.
- Containers also have a relative size. That way substances can be transferred so that two connected containers have the same concentration of it.
Substances in wounds
- Poison
- Infection (= lots of bacteria)
- Immune defense, white blood cells
- alcohol (from cleaning a wound)
- Herbs, potions, salves (for speeding the coagulation & healing, etc.
Shock
- Can result from many different things
- The body shuts down to preserve vital functions
- Brain power down, digestive system out of function, etc
- Keep warm, elevate the feet.
Amputation of body parts to avoid infections
- Anesthetics important
- Infection risk of amputation wound
- Alcohol decreases blood coagulation.
- Also cut of body parts as a result of damage
- Home
- -
- About
- -
- Introduction
- -
- FAQ
- -
- Team
- -
- Newbie Guide
- -
- Getting Started
- Editing Guide
- -
- Edit
- -
- Manage
- -
- New Page
- -
- Changes
- -
- Map
- -
- Password
- -
- Deprecation