void setNewPos()
{
if(theEntityPointer != NULL)
{
theEntityPointer.newPosSet = ON;
theEntityPointer.newPosX = mouse_pos.x;
theEntityPointer.newPosY = mouse_pos.y;
}
}
#define newPosSet skill1
#define newPosX skill2
#define newPosY skill3
void theEnt()
{
var myMoveSpeed = 3;
while(enet_ent_globpointer(my) == -1)wait(1);
if(enet_ent_clientid() == enet_ent_creator(enet_ent_globpointer(my))) //this is executed on the client who enet_ent_created the entits
{
while(my != NULL)
{
if(my.newPosSet == ON)
{
newPosSet = OFF;
enet_send_skills(enet_ent_globpointer(my),1,2,-1); //sending skills skill2 and skill3 (skills in anet start with 0, not with 1)
}
vec_diff(temp,vector(my.newPosX,my.newPosY,0),my.x);
vec_normalize(temp,minv(vec_dist(vector(my.newPosX,my.newPosY,0),my.x),myMoveSpeed*time_step));
c_move(my,nullvector,temp,IGNORE_PASSABLE);
wait(1);
}
}
else //and this on all other clients
{
while(my != NULL)
{
vec_diff(temp,vector(my.newPosX,my.newPosY,0),my.x);
vec_normalize(temp,minv(vec_dist(vector(my.newPosX,my.newPosY,0),my.x),myMoveSpeed*time_step));
c_move(my,nullvector,temp,IGNORE_PASSABLE);
wait(1);
}
}
}
in main:
mouse_mode = 4;
on_mouse_left = setNewPos;
...set up connection
theEntityPointer = enet_ent_create("entity.mdl",nullvector,_str("theEnt"));