## Formula to Calculate Rate of Fire?

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.
XenonArchitect7
Posts: 58
Joined: Fri, 5. Jul 19, 07:19

### Formula to Calculate Rate of Fire?

Hello,

I am trying to develop an external script for me to use on the TLaser.txt and TBullets.txt files so I can more easily tweak the weapon balance, although I can't understand how the value for "rate of fire" translates to the rds/min value in the game.

For example, a value of 60000 for this entry in TLaser.txt corresponds to a rate of fire of 1 rds/min in the game.
Similarly, a value of 21429 translates to 2.8 rds/min and 997 translates to 60.2 rds/min. These calculations seem to be independent of other variables, since they remain the same across different lasers.

So does anyone know the formula? I can't seem to derive it from this information alone.

BlackArchon
Posts: 1004
Joined: Wed, 4. Feb 04, 18:37

### Re: Formula to Calculate Rate of Fire?

A delay of 60000 equals 1 round per minute, as you already figured out.
A delay of 21429 means one shot every 21429/60000=0.35 minutes, which results in 1/0.35=2.8 rounds per minute.
A delay of 997 means one shot every 997/60000=0.017 minutes, which results in 1/0.017=60.2 rounds per minute.

SirNukes
Posts: 407
Joined: Sat, 31. Mar 07, 23:44

### Re: Formula to Calculate Rate of Fire?

The game stores refire delays, not rates, since that's what is needed at runtime. I assume 60k is from egosoft aiming for 1000 time units per frame at 60 fps.

There is an existing tool for tweaking this stuff if you want to use or borrow from it:
X3 Customizer

This file has most of my code specifically for adjusting fire rates (skip past the comments at the top):
https://github.com/bvbohnen/X3_Customiz ... re_Rate.py

XenonArchitect7
Posts: 58
Joined: Fri, 5. Jul 19, 07:19

### Re: Formula to Calculate Rate of Fire?

Thanks for the info guys!

JSDD
Posts: 949
Joined: Fri, 21. Mar 14, 21:51

### Re: Formula to Calculate Rate of Fire?

(hull damage / minute) = (hull damage / round) * (rounds / minute)

example: HEPT, 283rnd/min, 332 hull damage / round

(hull damage / minute) = 332 * 283 = 93956

(hull damage / second) = 332 * 283 / 60 = 1565 ... thats the ingame value in the encyclopedia

exceptions:
plasma burst generator and phased shockwave generator have special formulas for damage calculation

----------------------------------------------------

firing delay:

time between bullets = 1 / (bullets / time) ... correct ?!

time between bullets = 1 / (rounds / min) = 1 / (rounds / 60s) = 60 / (rounds/s)

example: HEPT, 283rnd/min

time between bullets = 60 / 283 = 0.212 s/round

you want it in milliseconds ? multiply with 1000ms/s ... (the game cant handle numbers smaller than 1 [or floating-point])

time between bullets = 60.000 / 283 = 212 ms/round

----------------------------------------------------

by the way ... that has nothing to do with FPS or so

the firing delay for a usual turret script should NOT be < 0.2s/round, otherwise the turret will not fire as much bullets as mentioned by TLaser

exception:
MARS uses 2 scripts per turret to circumvent that "obstacle" ...
To err is human. To really foul things up you need a computer.
Irren ist menschlich. Aber wenn man richtig Fehler machen will, braucht man einen Computer.

Mission Director Beispiele

Deniskos
Posts: 37
Joined: Wed, 11. Jun 08, 21:40

### Re: Formula to Calculate Rate of Fire?

In the game, I do it like this:

Code: Select all

``````\$rate.of.fire = get laser reload time of type: laser type=\$laser
\$rate.of.fire = (60000 / \$rate.of.fire) * 1000
\$rate.of.fire = \$rate.of.fire / 60

\$shield.dmg = get shield damage of laser \$laser
\$shield.dmg = (\$shield.dmg * \$rate.of.fire) / 1000

\$hull.dmg = get hull damage of laser \$laser
\$hull.dmg = (\$hull.dmg * \$rate.of.fire) / 1000``````