ant222 Posted January 3, 2007 Share Posted January 3, 2007 Hi all!What about a simple engine improvement (or a worsening...)that's relatively easy to implement. In terms of the programdesign, that would require giving the units some new parame-ters and one new function to calculate the hit probabilitybefore 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 farfrom being sure if this will improve the gameplay! See your-self ;)Here it is:METHOD 3. MATH ONLY, NO SIMULATION.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 fora shot (according to the firers rate of fire (=reloadtime)), is called an additional procedure that takes firer'sand target's parameters on input and returns hit probabil-ity.PARAMETERS:All vectors are 2d and are defined by their X and Y.Distance - vector from firer to target. If everything inD2TM is on a cell basis then the coordinates of all vectorswill be measured in units corresponding to the length of acell side (But fractional (float) numbers possible!)By the way, since in D2TM diagonal speed is sqrt(2) timesfaster than that when moving vertically or horizontally thevalue of the distance should be calculated asmax(Distance.X,Distance.Y). For the time being, I'll usenormal Euclidean measure.Speed can be measured in cells/second or in whatever unitsit's measured in the current version of D2TM.Target's size - a real number, each unit is given a size value.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:Unit.Parameter. //Used SubRoutines: Length(A):=sqrt(sqr(A.X)+sqr(A.Y)); Proj(A,B):=(A.X*B.X+A.Y*B.Y)/Length(B);//Projection of A onto B. //Main probability function: Ang_Size:=Target.Size/length(Distance)*Target.Fact; Tang_Vel:=Sqrt(Sqr(Length(Target.Speed))- Sqr(Proj(Target.Speed,Distance))); Ang_Vel:=Tang_Vel/Length(Distance); L:=sqrt(sqr(Firer.L0)+Firer.AVS*Ang_Vel); if Ang_Size<=L then Prob=(2/L+1/sqr(L)*Ang_Size)*Ang_Size; else Prob=1; 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, Ang_Size=Trike.Size/5; Ang_Vel=0; L=L0; Prob=80%=(2/L0+1/sqr(L0)*Ang_Size)*Ang_Size; In the last formula, all values are know except for L0.Therefore, we can calculate L0 as follows: L0=1/0.8*(Ang_Size*(1-sqrt(1-0.8)));It was a quadratic equation with two roots, but the otherroot 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 (than80%) accuracy and those smaller than trike - with a lowerone.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).Ok. Ang_Size is the same. Tang_Vel:=1.5; Ang_Vel:=1.5/5; L=1/0.45*(Ang_Size*(1-sqrt(1-0.45))); AVS:=sqrt((L*L-L0*L0)/sqr(Ang_Vel));That's it.RESUME:This system's very bad. It's empirical throughout. But itshould work!What will this function give?1. Smaller targets are harder to hit2. 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 ...TODO: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 inf.)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 Dune-2). ...EDIT:Updated one formula, the one for L. (Firer.AVS*Ang_Vel) shouldnot be squared. Quote Link to comment Share on other sites More sharing options...

ant222 Posted January 4, 2007 Author Share Posted January 4, 2007 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. Quote Link to comment Share on other sites More sharing options...

## Recommended Posts

## 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.