Thanks a lot, connorr
I was able to get the formula from that plugin. I converted it to use floats instead of integers so it's more accurate.
Here it is if anyone else wants it:
PHP Code:
static Float:origin[3], Float:aimVec[3], Float:entOrigin[3], Float:direction[3], Float:length;
static Float:moveTo[3], Float:Mins[3], Float:Maxs[3], distance;
pev(id, pev_origin, origin);
pev(isMovingEnt[id], pev_origin, entOrigin);
fm_get_aim_origin(id, aimVec);
direction[0] = aimVec[0] - origin[0];
direction[1] = aimVec[1] - origin[1];
direction[2] = aimVec[2] - origin[2];
length = get_distance_f(aimVec, origin);
// Avoid division by 0
if(length == 0.0)
length = 1.0;
distance = 200; // Set how close you want the ent to be to you
moveTo[0] = origin[0] + direction[0] * distance / length;
moveTo[1] = origin[1] + direction[1] * distance / length;
moveTo[2] = origin[2] + direction[2] * distance / length;
pev(isMovingEnt[id], pev_mins, Mins);
pev(isMovingEnt[id], pev_maxs, Maxs);
moveTo[0] -= (Mins[0] + Maxs[0]) * 0.5;
moveTo[1] -= (Mins[1] + Maxs[1]) * 0.5;
moveTo[2] -= (Mins[2] + Maxs[2]) * 0.5;
engfunc(EngFunc_SetOrigin, isMovingEnt[id], moveTo);