# Combat system, part 1 (with D2TM simplifications)

## Recommended Posts

[pre]

COMBAT SYSTEM FOR A REAL-TIME STRATEGY

{if you have troubles with viewing this in the browser, use Notepad. I still

can't make use of the tag.}

Preface

Don't faint away at once! I am rather sure you'll find too complicated. But

many significant simplifications are POSSIBLE and they will be added. But in

order to understand how it works you should read this anyway.

This part deals with firing at vehicles from guns (non-bullet), other types of

fire will be modelled by means of MINOR changes.

I. Needed values.

1. What characteristics a unit should have.

a) The velocity vector.

b)C1, C2, C3, C4, S - constants.

<will be later>

2. Derivation of some needed values.

a) The target position relative to the firer. We'll store it as a radius

vector of the target:

Rft^ = {Tx - Fx, Ty - Fy}, Where Fx, Fy, Tx and Ty are the coordinates of the

firer and the target.

b) Tangential target size. It is the 'visible' target size.

Lt = (Tl*cos(R^, V^) + Tw*sin(R^, V^)), where

Tl and Tw are the length and width of the target; (R^, V^) is the angle

between vectors R^ and V^.

cos(R^, V^) = (R^ * V^)/(|R^| * |V^|)

sin(R^, V^) = sqrt(1 - (cos(R^, V^))^2)

c) Angular size of the target.

alfa = Lt/|R^|, where |R^| is the absolute value of vector R^. Actually, alfa

= sin(Lt/|R^|), but for low angles we can use this approximation.

d) Target's velocity relative to the firer.

Vtf^ = Vt^ - Vf^, where Vt^ and Vf^ are the target's and the firer's

velocities.

e) Target's tangential velocity, scalar value.

Vtf_tau = Proj(Vtf^, tau^), tau^: (tau^ * Rft^) = 0, (A^ * B^) = Ax*Bx +Ay*By

- scalar product.

Derivation of tau^.

1) if Rftx <> 0 then

##### Share on other sites

Sounds pretty good, if this is implanted, will the game have a combat system equivalent to Total Annihilation?

##### Share on other sites

I have not played this game.

With the current D2TM this system simply won't use its capacities at full: the AI must be able to manuever; the damage system must be more realistic...

##### Share on other sites

And now let's go down from the sky onto the earth.

With the current D2TM engine many features of my system would be totally or almost useless. So, here is a simplified version.

1. Dispersion is a function of only omega and Vtf_tau.

2. Vtf^=Vt^. (Units shoot when motionless)

3. Instead of storing Tl and Tw separately and calculating alfa depending on its orientation and Rft^, it may be assumed that Lt is always constant for the given unit.

Thus:

0. Calculate alfa using a preset Lt. (simplification #3)

1. Canculate Vft_tau^ as described above, letting Vf^ = 0.

2. Calculate omega.

3. Calculate dispersion, D = S + C1*omega) + C3*Vtf_tau.

4. Calculate phi: phi = sqrt(D).

5. By formula (4) find the hit probability.

6. Perform constant fit as described above.

BUT: the requirement to fix the diagonal movement bug remains.

##### Share on other sites

* After reading this, MrFlibble feels stupid and illiterate *

* MrFlibble's very cross... *

:D

##### Share on other sites

Even i can't barely understand this. I need to hear it in 'normal language'. ie, i understood it when you said "shooting when motionless". Heh. Sorry.  :-[

##### Share on other sites

Ok. Write an example of what you can't understand in order for me to get an idea.

##### Share on other sites

Stefan, I advise drawing diagrams to help visualise it first. Ant, if you explain what you're doing more (i.e. not just sentences where half the nouns are variables), it might help.

e.g. "II Approximation of the Gauss distribution.

We will approximate it by a triangle:"

An intro paragraph of what this does and why might help.

##### Share on other sites

Oh... I thought that was due to my terrible English, while it is due to my style. I'll try to explain it, not only to give the algorithm.

Do the terms 'tangential speed', 'angular size', e.t.c. need an explanation too?

##### Share on other sites

An intro paragraph of what this does and why might help...

...follows:

[pre]If we take a variable which is affected by some random disturbance and measure

it many times, we'll find out that among the measured values there are some

met often and some met rarely. If we build a graph on which along the X axis

are marked the measured values and along the Y axis - the number of

measurements yielded this particular value, the points on it will tend to

describe a "bell" shape: high inaccuracies are met more rarely than low. The

center of the "bell" will have the X coordinate equal to the mean of all the

performed measurements.

For this set of values the probability of each value is in direct proportion

to the number of measurements which have given this result. So, downscaling

the graph along the Y axis by the total number of measurements will result in

a similar-looking graph, where for each value on the X axis is set the

probability (on the Y axis) to get this value in a (any) measure of the

variable in question. Now, if you need to know the probability of the fact

that the variable lies between say A and B, you just need to sum the Y values

for all the points on the X axis lying between A and B.

N.B.: The probability for the variable to be within its maximum and minimum

is, of course, equal to 1 (one). Therefore, the sum of the Y values for all

the points on the graph will necessarily yield 1. It can be simply proved. On

the unscaled graph the same sum would be equal to the total number of

measurements, since we have built the graph in this way. After scaling (=

dividing by the total measurements number) we'll get 1.

If the number of measurements tends to infinity, the points form an exact

"bell" shape. This is the Gauss distribution of the variable. The Y-values are

called probability density. But of course, now the probability to get every

certain value as the result of a measurement is negligibly low (after we have

switched to a limit). It is as negligible as a point of a line segment.

The use of this new graph is slightly more difficult. Imagine, you want to

know the probability of the variable's being between values A and B:

(x>=A)&&(x<=B). To accomplish this, you'll need to calculate the define

integral (=summator for infinitesimal values) of the function with A and B as

the lower and the higher limits.

This distribution naturally emerges in many processes. Particularly, in

shooting, where the distance between hit points and the target center obeys

the Gauss distribution.

Implementing something resembling this distribution (rather than fully empiric

formulas) will reduce the game's abstractness and, I hope, brighten the game

feeling.

[/pre]

##### Share on other sites

[pre]EXPLANATIONS (CONTINUED)

GAUSS DISTRIBUTION APPROXIMATION

As mentioned above, the probability calculation requires integration. the

exact Gauss distribution (exp(x^2)) is really CPU-expensive to integrate.

Since I am not a specialist in this field, I see only two ways to solve this

problem.

1. Tabulation.

We can store the function as a table with two columns:

X and F(X). Or we can store the integral in the same way: X, Int(-X, X).

Fortunately, the lower and the higher limits are of the same absolute

value.

Before finding the integral by this method, we will have to rescale the

found [alfa] to maintain the ration alfa/sigma.

2. Approximation by a simpler function.

Replace Gauss distribution with a function whose integral can be calculated

automatically. For example, we may divide the "bell" into several vertical

zones (X1, ..., XN) and build a function which in every zone [XN...X(N+1)]

will be a line segment. Triangle is the simplest possible approximation of

this kind.

This method yields an explicit formula for the integral (see formula 4).

FACTORS OF HIT CHANCE

It is evident that the hit probability should depend on some firer's

properties and some target's properties.

I Firer's properties.

1. Standard dispersion.

When testing a gun, it is clutched in a heavy construction and fired

several times in a row (no too often - the barrel may overheat and decrease

the accuracy). If the target is quite far from the gun, it'll be seen that

the projectiles haven't all hit the same point - there were a dispersion,

which is the gun's property. This dispersion caused by the weapon

properties I called S - standard dispersion.

...

II Target's properties.

1. Angular size.

In 2d the line from the firer to the hit point may be defined via the angle

this line forms with the one from the firer to the center of the target.

Give the distance, angular deviation may be easily converted into linear.

So, we assume that at every given moment the distance from the firer to all

points of the target is constant (in reality it is almost constant). This

allows to state that angular deviation obeys Gauss distribution. Now, to

calculate the hit probability, we need to know the target's angular size

and the distribution of angular deviation, the integral being calculated

with -alfa/2 and +alfa/2 as the lower and the higher limits, where alfa is

angular size.

2. Angular velocity

Shooting at moving targets is harder than at motionless. This and the two

following factors are to take it into account. Actually I don't know how it

effects accuracy, I just assume that it causes an additional dispersion

proportional to the Angular velocity: F1(omega) = C1*omega (see (6))

3. Linear tangential velocity.

When firing at a distant moving target lead have to be determined. Angular

lead is proportional to the distance to the target and to the target's

omega. And the inaccuracy in the lead calculation is proportional to the

dispersion proportional to the product omega*|Rft^| which is equal to

|Vtf_tau|: F3(Vtf_tau) = C3*|Vtf_tau|. It was a mistake that I hadn't

placed Vtf_tau in |...| above.

4. The intensity of the target's maneuvers.

Obviously, a maneuvering target is harder to hit. To take it into account I

invented (?) the Maneuvering Degree (MD). Its derivation have been

described above. Unlike the other listed factors, MD depends not only on

the target properties, but also on the Aiming time of the firer. Notes on

the latter value will be added soon. And I assumed that additional

dispersion is in direct proportion to MD: F2(MD) = C2*MD. I am not sure

this is true. I'll try to find corresponding info.[/pre]

##### Share on other sites

[pre]III AIMING TIME

It is the time which passes since the firer begins aiming till it takes a

shot.

Aiming time has three parts:

The time needed to reload the weapon (if it hasn't been done yet)

2. Rough aiming.

I'd characterize this stage by its main factor: the speed at which the

weapon can chance its direction. For example, the angular speed of a tank's

turret. For infantry it'll be very fast, especially for light weapons.

3. Fine-tuning.

Once, the first two stages have been accomplished, the firer needs to

precisely point its weapon at the target. Major factors: weapon size/mass,

aiming skill, some of the target's properties: it should take more time to

aim at a maneuvering trike than at a huge motionless harvester.

The first constituent is constant for the given unit. The second constituent

is calculated, assuming a constant angular speed for the given unit. Angular

distance between the current weapon direction and the direction to the target

should be divided by the angular speed of weapon rotation.

The third constituent is the hardest to calculate. It should be a function of

the target's angular size, tangential speed, angular speed and, maybe, MD.

And, of course, it should be a function of angular weapon speed (see rough

aiming) of the given unit. A linear combination of these won't be ok. I'll

think on the formula.

Thus, difficult targets will be fired at at a lower ROF.

[/pre]

##### Share on other sites

What does MD stand for?

##### Share on other sites

MD stands for Maneuverability Degree. It is needed to take into accont the target's maneuvers performed to avoid hits. Its calculation is described in section

##### Share on other sites

[pre]Hello everybody.

Two major bugs found! I really don't know how I couldn't have noticed them

before.

The first bug is connected with the aiming time. Rough Aiming time (RAT) can

not be calculated in the way indicated above. It should emerge mechanically in

one of two possible ways:

1.

##### Share on other sites

• 1 month later...

Are you talking small tweaks with this stuff or radical changes?

Also could you use examples of what a unit does with the current combat system, and then what it would do with the ideas you're posting.

Ie. Currently a rocket launcher will fire two fairly accurate rockets at a vehicle. With this formula and that anomaly the rockets will land somewhere slightly different each time.

Examples like this would help me understand what you're talking about.

##### Share on other sites

First of all, I'd like to say that these ideas have a low chance to be implemented in D2TM. This game has a real-time global mode and simultaneous battles are possible in it (two battles in two different regions). Thus, tactical level has become not as important as it was in Dune-2. The developers want to keep the tactical mode quite simple in order for the player to be able to control the whole empire in real-time. But my ideas were intended to make the tactical mode more interesting and diverse, assuming that the player is not distracted by another parallel (simultaneous) battle or the need to do something in the global mode.

If global mode sessions and tactical battles were not parallel, e.g you play a tactical battle, then give some orders in the global mode, then play another battle (like in Xcom), then my system could work as well. But in D2TM the player will simply have no time to enjoy the interesting and comlex tactical gameplay which my system offers.

Are you talking [about - ?] small tweaks with this stuff or radical changes?

Of course, I mean radical changes.

Also could you use examples of what a unit does with the current combat system, and then what it would do with the ideas you're posting.

I posted several such examples in the thread

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible. ×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.