How to write a C Program Doom ACS distance in C Programming Language ?
Solution:
- function int abs(int input)
- {
- if (input < 0) { return -input; }
- return input;
- }
- function int fdistance(int tid1, int tid2)
- {
- int len;
- int y = getactory(tid1) - getactory(tid2);
- int x = getactorx(tid1) - getactorx(tid2);
- int z = getactorz(tid1) - getactorz(tid2);
- int ang = vectorangle(x,y);
- if (((ang+0.125)%0.5) > 0.25) len = fixeddiv(y, sin(ang));
- else len = fixeddiv(x, cos(ang));
- ang = vectorangle(len, z);
- if (((ang+0.125)%0.5) > 0.25) len = fixeddiv(z, sin(ang));
- else len = fixeddiv(len, cos(ang));
- return len;
- }
- // distance between player and monster tid.
- int owner_dist = fdistance(0, mtid) >> 16;