further attempt at avoiding bot falling off edges

This commit is contained in:
christian 2021-04-29 11:55:38 +02:00
parent a3a0b640d0
commit fb6e8d9166

View File

@ -306,7 +306,7 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
TR_GetEndPosition(ground_pos);
ground_distance = GetVectorDistance(feet_origin, ground_pos);
float forward_distance = GetVectorDistance(feet_origin, ground_pos);
if (forward_distance > 250)
if (forward_distance > 280)
{
float ClientPos[3];
float Result[3];
@ -316,6 +316,10 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
GetVectorAngles(Result, Result);
TeleportEntity(client, NULL_VECTOR, Result, NULL_VECTOR);
bot_avoid_edge[client] = 0;
ApplyBoost(client, 500.0, Result);
buttons_old[client] = buttons;
flags_old[client] = flags;
return;
}
}
}
@ -327,6 +331,14 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
}
}
void ApplyBoost(int client, float amount, float vel[3]){
float direction[3];
NormalizeVector(vel, direction);
ScaleVector(direction, amount);
AddVectors(vel, direction, vel);
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vel);
}
public bool is_bot_player(int client)
{
char auth[50];
@ -354,7 +366,7 @@ public Action recursive_pressing(Handle timer, any data)
ChangeClientTeam(client, 2);
continue;
}
if (bot_avoid_edge[client] >= 4)
if (bot_avoid_edge[client] >= 3)
bot_avoid_edge[client] = -1;
if (bot_avoid_edge[client] > -1)
{