GetDistance(tid)

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: GetDistance(tid)

by Macil » Fri Mar 11, 2005 5:58 pm

Oh, I see. I never looked at it closely enough.

by Graf Zahl » Fri Mar 11, 2005 5:32 pm

Look at my code. One is the activator, the other the specified tid.

Re: GetDistance(tid)

by Macil » Fri Mar 11, 2005 5:26 pm

cutmanmike wrote:Since you can do this in ACS anyway (with a bit more hassle) why not have this? A little low priority but there you go
What would it do? And don't you need two things to be able to tell the distance between them?

by Graf Zahl » Fri Mar 11, 2005 8:14 am

Code: Select all


function int abs(int x)
{
  if (x>=0) return x;
  return -x;
}

function int min(int x, int y)
{
    if (x<y) return x;
    else return y;
}

function int AproxDistance(int dx, int dy)
{
	int dx = abs(dx);
	int dy = abs(dy);
	return dx+dy-(min(dx,dy)>>1);
}

function void GetDistance(int tid)
{
    int x=abs(GetActorX(tid)-GetActorX(activatortid()));
    int y=abs(GetActorY(tid)-GetActorY(activatortid()));
    int z=abs(GetActorZ(tid)-GetActorZ(activatortid()));

    return AproxDistance(AproxDistance(x,y), z);
}

It used the same precision Doom is using internally for distance calculations as a fixed point value.

GetDistance(tid)

by Cutmanmike » Fri Mar 11, 2005 7:00 am

Since you can do this in ACS anyway (with a bit more hassle) why not have this? A little low priority but there you go

Top