Page 1 of 1

Distance between mob and player?

Posted: Wed Oct 11, 2017 3:54 am
by Roboethicist
I'm trying to find a way to get the distance between my my character and a targeted mob so that I can plan my profile maxtargetdistance accordingly. ROM API unitdistance function appears to no longer work and I was hoping someone would have a workaround. Thanks.

Re: Distance between mob and player?

Posted: Mon Oct 16, 2017 2:52 pm
by ThulsaDoom
You can use function: player:distanceToTarget()
It will return distance between you and target, then you can compare with skill range.

This is the original function:

Code: Select all


function CPawn:distanceToTarget()
	self:updateTargetPtr()
	if( self.TargetPtr == 0 ) then return 0; end;

	local target = CPawn.new(self.TargetPtr);
	target:updateXYZ()
	self:updateXYZ()
	local tx,ty,tz = target.X, target.Y, target.Z;
	local px,py,pz = self.X, self.Y, self.Z;

	return math.sqrt( (tx-px)*(tx-px) + (ty-py)*(ty-py) + (tz-pz)*(tz-pz) );
end