aliens

Author Topic: Formula of the Perfect explosion.  (Read 6304 times)

Offline redv

  • Colonel
  • ****
  • Posts: 335
    • View Profile
Formula of the Perfect explosion.
« on: February 18, 2013, 03:24:43 pm »
The basic data.
In vanilla Xcom explosions was flat. Xcom is not designed for 3D explosions.
Basic formula for calculate the average power of explosion:
Code: [Select]
Power = PowerMax – 10 * L
where: L – range from epicenter in tiles.
https://www.ufopaedia.org/index.php?title=Explosions
In OpenXcom explosions is 3D.
Game field is limited in height by 4 tiles.

The problem.
Tiles is not cubic, but rectangular 16x16x24 voxels. 3D explosion stretched in height.
For the correct convert between real angles and in-game angles need use processor expensive formulas (for example: tg(real fi) = tg(in-game fi) * 16 / 24).

The suggestion.
Easy to use formula for calculate the average power of 3D explosion must be:
Code: [Select]
Power = PowerMax – 10 * L – 10 * H
where: L – range from epicenter in tiles. Same as L in previous formula (no projection on axis X, Y).
            H – height in tiles; projection on axis Z.
Formula is the compromise between vanilla Xcom and OpenXcom.
Result of the explosion would be more realistic.

Sample of calculations is attached.

Volutar

  • Guest
Re: Formula of the Perfect explosion.
« Reply #1 on: February 18, 2013, 07:23:41 pm »
options.cfg, explosionHeight
0=flat (original)
1=-30 damage units per level (additinal to -10 per tile)
2=-10 damage units per level
3=-5 damage units per level

Commit incoming.

Offline redv

  • Colonel
  • ****
  • Posts: 335
    • View Profile
Re: Formula of the Perfect explosion.
« Reply #2 on: February 18, 2013, 08:32:21 pm »
OK
Thank you.

Offline luke83

  • Commander
  • *****
  • Posts: 1558
    • View Profile
    • openxcommods
Re: Formula of the Perfect explosion.
« Reply #3 on: February 18, 2013, 08:40:40 pm »
Nice work Volutar :)

Offline redv

  • Colonel
  • ****
  • Posts: 335
    • View Profile
Re: Formula of the Perfect explosion.
« Reply #4 on: February 23, 2013, 01:48:37 pm »
Volutar, small mistake in formula.

Code: [Select]
if (origin->getPosition().z != tileZ) power_ -= vertdec; https://3d explosion factorhttps://github.com/SupSuper/OpenXcom/blob/master/src/Battlescape/TileEngine.cpp#L875
if (origin->getPosition().z != tileZ) then "vertdec" will be subtracted every step by "l", even if tileZ not change.

Correct code is:
Code: [Select]
power_ -= abs((int)(vertdec * sin_fi)); https://3d explosion factor

Volutar

  • Guest
Re: Formula of the Perfect explosion.
« Reply #5 on: February 23, 2013, 02:49:39 pm »
redv, no mistakes. it traces step by step, and "origin" changes every time. and z is changed only with vertical switch.

Offline redv

  • Colonel
  • ****
  • Posts: 335
    • View Profile
Re: Formula of the Perfect explosion.
« Reply #6 on: February 23, 2013, 03:26:17 pm »
Yes, you're right.

Volutar

  • Guest
Re: Formula of the Perfect explosion.
« Reply #7 on: May 17, 2013, 07:56:36 am »
Recently Daiky discovered inproper explosion values.


So I must shed some light on these things arised.
1. So called "Double destruction" commented in this commit is not what code needed.

2. Power/2 here only confuses thus better to be processed inside of "detonate", because it's tile ARMOR which is multiplied, than explosion strength which is weaken.

3. Damaging process is iterative, it decreases current DAMAGE value by armor, unless it become less than value affecting on tile damage (which is armor*2). Commented with "double damage" is just emulation of that process. If damage was for instance 200, and tile armor*2 is 80, it should be destroyed. But then damage value of 120 should applied to this tile (which become death_tile at this point), and ot should be destroyed too!.. So final damage value will be 40, and damage process applied to tile TWICE.

4. Smoke density value depends on LOFT height (it determined by checking loft values != 0).
Formula is: smoke_density = random(LoftHeight/2+2) + LoftHeight/2+1;

5. Tiles inflamation is also somewhat screwed. Ignition process should happen when damage value is greater than than "fire proof"*2 tile value (similar to armor for destruction). Fire lifetime is taken from MCD info. Fire density is calculated as 15-fire_proof/10, and must be capped to range 1..12.
« Last Edit: May 17, 2013, 09:35:03 am by Volutar »

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: Formula of the Perfect explosion.
« Reply #8 on: May 17, 2013, 11:55:58 am »
Regarding to point 3: I don't get it why you want to multiply the armor of the original tile by two?

Example:
desert floortile armor: 5
damaged desert floortile armor: 20
grenade maximum damage power at center: 25

you did 5*2. 10 damage would destroy both the desert floortile and damaged desert floortile?
while in the original game you need more than 5+20 to destroy both the desert floortile and damaged desert floortile.

I don't know why you changed this... I thought the purpose was to get close to how the original works?


ok, I get it, the power/2 is confusing, I guess I'll fix that bit then. Commit incoming.
« Last Edit: May 17, 2013, 12:01:47 pm by Daiky »