When the map starts, the player is given a tId of 1000
Code: Select all
script 999 enter //Attributes tId of 1000 to the player
{
Thing_ChangeTID(0, 1000);
}Code: Select all
script 994 (void)
{
SetActivatorToTarget(0);
print(d:distance(1000,ActivatorTid()));
}Code: Select all
function int sqrt (int x)
{
int r;
x = x + 1 >> 1;
while (x > r)
x -= r++;
return r;
}
function int distance (int tid1, int tid2)
{
int x, y, z, d;
x = GetActorX(tid1) - GetActorX(tid2) >> 16; // Convert fixed point to integer
y = GetActorY(tid1) - GetActorY(tid2) >> 16;
z = GetActorZ(tid1) - GetActorZ(tid2) >> 16;
d = sqrt( x*x + y*y + z*z );
return d;
}But when aiming at an Imp..
nothing happens. Nothing is printed. I suppose the script dies somewhere along the line, but for the life of me I can't make heads or tails of it.
Any help would be greatly appreciated.