I am trying to make a entity that move in front of player with Z-cord always on the ground.
This is I got so far. But there are few problem:
- I could use drop_to_floor but idk if calling it every 0.1s is too much for the server to handle.
- If player aim to the group, the entity might just fall into the void
- If put specific Z first (like +100.0 up) then drop to the ground, it might stuck into a wall or object.
PHP Code:
public Item_think(ent)
{
static owner;owner = pev(ent, pev_owner)
static Float:StartPos[3];
get_position(id, 100.0, 0.0, 0.0, StartPos); //100.0 just for testing, might be smaller
set_pev(ent, pev_nextthink, get_gametime()+0.1)
}
stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
{
static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
pev(id, pev_origin, vOrigin)
pev(id, pev_view_ofs, vUp) //for player
xs_vec_add(vOrigin, vUp, vOrigin)
pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
angle_vector(vAngle,ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
angle_vector(vAngle,ANGLEVECTOR_RIGHT, vRight)
angle_vector(vAngle,ANGLEVECTOR_UP, vUp)
vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
}
__________________