This is what I use...
Code:
sentry_turntotarget(ent, Float:sentryOrigin[3], target, Float:closestOrigin[3]) {
if(target) {
new name[32]
get_user_name(target, name, 31)
new Float:newAngle[3]
entity_get_vector(ent, EV_VEC_angles, newAngle)
new Float:x = closestOrigin[0] - sentryOrigin[0]
new Float:z = closestOrigin[1] - sentryOrigin[1]
new Float:radians = floatatan(z/x, radian)
newAngle[1] = radians * (180.0 / 3.141592654)
newAngle[1] += 180
if (closestOrigin[0] < sentryOrigin[0])
newAngle[1] -= 180.0
entity_set_float(ent, SENTRY_FL_ANGLE, newAngle[1])
new Float:h = closestOrigin[2] - sentryOrigin[2]
new Float:b = vector_distance(sentryOrigin, closestOrigin)
radians = floatatan(h/b, radian)
new Float:degs = radians * (180.0 / 3.141592654)
new Float:degreeByte = 830.0/256.0;
new Float:tilt = 127.0 - degreeByte * degs;
entity_set_byte(ent, SENTRY_TILT_TURRET, floatround(tilt))
entity_set_vector(ent, EV_VEC_angles, newAngle)
}
}
It is from the SentryGuns plugin, and had to revise a lot of it to make it cleaner. But it forces and Entity to turn to a target.
Go look in the Sentry Guns plugin and see how he does it, it should be very similiar.
Some lines aren't truelly necassary for calculating the angles, they are just fuser, iuser, etc to hold values specific to that entity.
Sorry I can't be much of help, hope that gives you somewhere to start looking though!
__________________