DBP: Check Within Distance

The DBP version of my C# snippet of the same name. This will check if an object is within a certain distance.

function CheckIfDist(Object1, object2, distance)
check = 0
NPCx = Object position x(Object1)
NPCy = Object position y(Object1)
NPCz = object position z(Object1)
PlayerX = Object position x(Object2)
PlayerY = object position y(Object2)
PlayerZ = object position z(Object2)
Posx = NPCx - PlayerX
Posy = NPCy - PlayerY
Posz = NPCz - PlayerZ

dis = distance
if posx < dis and posx > -dis and posy < dis and posy > -dis and posz < dis and posz > -dis then check = 1

endfunction check
Object1 = First object to compare
Object2 = Second Object to compare
Distance = Maximum distance for it to return true

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s