# point_dis for p3dc.dll

2 replies to this topic

### #1 topmarine

topmarine

GMC Member

• New Member
• 122 posts
• Version:GM8.1

Posted 10 November 2011 - 01:49 AM

point_dis script. Hope this helps all those other p3dc.dll users out there.

var vx,vy,vz,dis,zp,zdir;
zdir = argument1
dis = p3dc_ray(level_colid,x,y,z,vx,vy,vz)
zp = z+vz*dis

return dis
• 0

### #2 Zesterer

Zesterer

Professor of Articul

• GMC Member
• 1019 posts
• Version:GM8

Posted 06 February 2012 - 10:37 PM

I think I can guess, but could you explain for others exactly what it does? It is very unclear...
• 0

### #3 Gamer3D

Gamer3D

Human* me = this;

• GMC Member
• 1590 posts
• Version:GM8.1

Posted 08 February 2012 - 05:50 AM

var vx,vy,vz,dis,zp,zdir;
zdir = argument1
dis = p3dc_ray(level_colid,x,y,z,vx,vy,vz)
zp = z+vz*dis

return dis

I think I can guess, but could you explain for others exactly what it does? It is very unclear...

Well, analyzing it results in:
Calculate a unit-vector from spherical coordinates, in degrees. Use P3DC raycasting to find distance from position <x, y, VARIABLE_UNDEFINED> one unit in that direction, with collisions calculated against VARIABLE_UNDEFINED. It then assigns a value to the useless local variable "zp" and returns whatever p3dc_ray would return.

If you make your game like he does (z for position and level_colid for the P3DC collision model), then it will return the same as
a raycast of distance one in a direction specified by polar coordinates.

Simplifying and replacing his assumptions of variables with arguments, we get:
```var vx, vy, vz, zc;
zc = cos(argument5 * 0.00872664625997164788461845384244);
vx = cos(argument4 * 0.00872664625997164788461845384244) * zc;
vy = -sin(argument4 * 0.00872664625997164788461845384244) * zc;
vz = sin(argument5 * 0.00872664625997164788461845384244);
return p3dc_ray(argument0, argument1, argument2, argument3, vx, vy, vz);
```

The changes: Removed assumed variables "z" and "level_colid" and replaced with arguments. Replaced x and y with arguments to make it more useful. Moved polar coordinate arguments to end of argument array.

P.S. I should have checked the original post date. Not sure why Zesterer revived this topic.
• 0

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users