Jump to content

Combat System (Simplified and Truncated)


Recommended Posts

Hi all!

What about  a simple  engine improvement (or a worsening...)

that's relatively easy to implement. In terms of the program

design, that would require giving the units some new parame-

ters and  one new  function to calculate the hit probability

before shooting.  Depending on  the calculated  probability,

the firer can hit or miss with the current shot.

I don't know whether D2TM needs it. FurtherMore - I very far

from being sure if this will improve the gameplay! See your-

self ;)

Here it is:


This method implies no change in the code except for:

1.  For each shot hit probability is calculated and, using a

    random number,  it's checked  whether the  target  enemy

    unit is hit or not.

2.  You'll have  to gather some additional parameters needed

    for the calculation.

So, no code should be rewritten, only added.

As soon  as the firer has faced the target and it's time for

a shot  (according to  the  firers  rate  of  fire  (=reload

time)), is called an additional procedure that takes firer's

and target's  parameters on  input and returns hit probabil-



All vectors are 2d and are defined by their X and Y.

Distance -  vector from  firer to  target. If  everything in

D2TM is  on a cell basis then the coordinates of all vectors

will be  measured in  units corresponding to the length of a

cell side (But fractional (float) numbers possible!)

By the  way, since  in D2TM  diagonal speed is sqrt(2) times

faster than  that when moving vertically or horizontally the

value   of    the   distance   should   be   calculated   as

max(Distance.X,Distance.Y). For  the time  being,  I'll  use

normal Euclidean measure.

Speed can  be measured  in cells/second or in whatever units

it's measured in the current version of D2TM.

Target's size -     a real number, each unit is given a size


Special factor -    (Fact), a  real  number,  less  than  or

                    equal to  1, a unit parameter, just like

                    the Size.

L0 -                a unit  parameter, determines the degree

                    of dispersion of the unit's weapon, when

                    firing at a motionless target - weapon's

                    own dispersion.

AVS -               a unit  parameter. Determines  how  much

                    accuracy of the firer is affected by the

                    target's movements.

Fact -              a unit  parameter,  for  most  cases  it

                    equals 1.

Other variables  mentioned are local, used only for calcula-

tions within the function.

To refer  to various parameters of different units I'll use:


    //Used SubRoutines:


    Proj(A,B):=(A.X*B.X+A.Y*B.Y)/Length(B);//Projection of A

    onto B.


    //Main probability function:






    if Ang_Size<=L then

    Prob=(2/L+1/sqr(L)*Ang_Size)*Ang_Size; else


    return Prob; //Probability calculated!

Tuning the values.

First, one should attach a value of size to each unit.

Then, for each unit, L0 is chosen this way:

For example,  we want a tank to hit a trike with a 80% accu-

racy at a distance of 5 cells. Thus,






In the  last formula,  all values  are know  except for  L0.

Therefore, we can calculate L0 as follows:


It was  a quadratic  equation with  two roots, but the other

root doesn't do because it yields L0<Ang_Size.

Thus we  know what  L0 the unit should have to hit a motion-

less trike from a 5-cell distance...

Targets bigger  than trike  will be  hit with a higher (than

80%) accuracy  and those  smaller than  trike - with a lower


Then, say,  we wanna  kill the same trike from the same dis-

tance with 45%, when this trike is moving 1.5 cells/sec per-

pendicular to the firer's line of sight (=Distance vector).


    Ang_Size is the same.





That's it.


This system's  very bad.  It's empirical  throughout. But it

should work!

What will this function give?

1.  Smaller targets are harder to hit

2.  The higher  the distance  to the target the harder it is

    to hit.

3.  The faster the target moves, the harder to hit it is.

4.  The system is not internally conflicting.

5.  L0 and  AVS parameters  for each  unit are determined by

    means of a single "test case".

6.  By varying  the Factor  property we  can emulate various

    additional effects on accuracy:

    Infantry standing/Lying

    Bad visibility



1.  Instead of  AVS - sensitivity to target's angular speed,

    we better  use MD - manoeuvrability degree introduced in

    my former posts.

2.  If units could fire on the move I would implement effect

    of firer's speed on accuracy.

3.  Damage differs  according to  which side  has been  hit:

    front, side,  stern (in  descending order of armouring).

    How to  determine which side was hit was explained in my

    earlier posts. Of course, I can re-explain anything.

Also endow infantry with additional capabilities:

1.  Hard to spot when lying (light inf.)

2.  Can destroy  tanks at  very close combat (1 cell) (light


3.  Takes less damage if on rocks (not sand) (light inf.)

4.  Tracked vehicles  can hardly  crush light  inf.  because

    it's hard  to see at very close range from tanks and can

    avoid caterpillars.

5.  Heavy inf. - good against light inf. at high distance in

    open field.

6.  Heavy inf.  - more  or less  can resist wheeled vehicles

    (which are hard to hit with RPG (small and fast) but ar-

    moured not strong enough to effectively resist LasGuns)

7.  Good against  tanks at  medium and  high range  (which a

    quite big and slow to be hit by anti-tank RPG)

8.  But tanks can crush Heavy inf, which also can't lie down

    (due to  its mechanical  suits -  according to  GFX from




Updated one formula, the one for L. (Firer.AVS*Ang_Vel) should

not be squared.

Link to comment
Share on other sites

A little note while I have a break:

To make the process of fitting these L0 and AVS values for each unit as easy as possible, I think a little program should be written that would take test cases (see above post) as input and return values of L0 and AVS into a .cfg file that'll then be read by the game. Thus we'll avoid all manual calculations.

Also, the .cfg file should keep the Size value of each unit.

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.