remove randomness
more optimizations
This commit is contained in:
parent
66c33472ff
commit
515bc85207
3 changed files with 102 additions and 66 deletions
|
|
@ -130,15 +130,52 @@ bool Bot::CheckVisibility (edict_t *target, Vector *origin, byte *bodyPart)
|
|||
if (*bodyPart != 0)
|
||||
return true;
|
||||
|
||||
// worst case, choose random position in enemy body
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
Vector pos = target->v.origin; // get the player origin
|
||||
// thanks for this code goes to kwo
|
||||
MakeVectors (target->v.angles);
|
||||
|
||||
// find the vector beetwen mins and maxs of the player body
|
||||
pos.x += Random.Float (target->v.mins.x * 0.5f, target->v.maxs.x * 0.5f);
|
||||
pos.y += Random.Float (target->v.mins.y * 0.5f, target->v.maxs.y * 0.5f);
|
||||
pos.z += Random.Float (target->v.mins.z * 0.5f, target->v.maxs.z * 0.5f);
|
||||
// worst case, choose random position in enemy body
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
Vector pos = target->v.origin;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0: // left arm
|
||||
pos.x -= 10.0f * g_pGlobals->v_right.x;
|
||||
pos.y -= 10.0f * g_pGlobals->v_right.y;
|
||||
pos.z += 8.0f;
|
||||
break;
|
||||
|
||||
case 1: // right arm
|
||||
pos.x += 10.0f * g_pGlobals->v_right.x;
|
||||
pos.y += 10.0f * g_pGlobals->v_right.y;
|
||||
pos.z += 8.0f;
|
||||
break;
|
||||
|
||||
case 2: // left leg
|
||||
pos.x -= 10.0f * g_pGlobals->v_right.x;
|
||||
pos.y -= 10.0f * g_pGlobals->v_right.y;
|
||||
pos.z -= 12.0f;
|
||||
break;
|
||||
|
||||
case 3: // right leg
|
||||
pos.x += 10.0f * g_pGlobals->v_right.x;
|
||||
pos.y += 10.0f * g_pGlobals->v_right.y;
|
||||
pos.z -= 12.0f;
|
||||
break;
|
||||
|
||||
case 4: // left foot
|
||||
pos.x -= 10.0f * g_pGlobals->v_right.x;
|
||||
pos.y -= 10.0f * g_pGlobals->v_right.y;
|
||||
pos.z -= 24.0f;
|
||||
break;
|
||||
|
||||
case 5: // right foot
|
||||
pos.x += 10.0f * g_pGlobals->v_right.x;
|
||||
pos.y += 10.0f * g_pGlobals->v_right.y;
|
||||
pos.z -= 24.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
// check direct line to random part of the player body
|
||||
TraceLine (botHead, pos, true, true, GetEntity (), &tr);
|
||||
|
|
@ -2882,6 +2919,8 @@ void Bot::ChooseAimDirection (void)
|
|||
if (!(m_currentWaypointIndex >= 0 && m_currentWaypointIndex < g_numWaypoints))
|
||||
GetValidWaypoint ();
|
||||
|
||||
bool tracelineIssued = false;
|
||||
|
||||
// check if last enemy vector valid
|
||||
if (m_seeEnemyTime + 7.0 < GetWorldTime () && m_lastEnemyOrigin != nullvec && (pev->origin - m_lastEnemyOrigin).GetLength () >= 1600.0f && IsEntityNull (m_enemy) && !UsesSniper ())
|
||||
{
|
||||
|
|
@ -2895,6 +2934,7 @@ void Bot::ChooseAimDirection (void)
|
|||
m_lastEnemyOrigin = nullvec;
|
||||
m_aimFlags &= ~(AIM_LAST_ENEMY | AIM_PREDICT_PATH);
|
||||
}
|
||||
tracelineIssued = true;
|
||||
}
|
||||
else if (m_lastEnemyOrigin == nullvec)
|
||||
m_aimFlags &= ~(AIM_LAST_ENEMY | AIM_PREDICT_PATH);
|
||||
|
|
@ -2940,7 +2980,7 @@ void Bot::ChooseAimDirection (void)
|
|||
}
|
||||
else if (flags & AIM_PREDICT_PATH)
|
||||
{
|
||||
if (((pev->origin - m_lastEnemyOrigin).GetLength () < 1600 || UsesSniper ()) && (tr.flFraction >= 0.2 || tr.pHit != g_worldEdict))
|
||||
if (((pev->origin - m_lastEnemyOrigin).GetLength () < 1600 || UsesSniper ()) && (((tr.flFraction >= 0.2 || tr.pHit != g_worldEdict) && tracelineIssued) || !tracelineIssued))
|
||||
{
|
||||
bool recalcPath = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ ConVar yb_version ("yb_version", PRODUCT_VERSION, VT_READONLY);
|
|||
|
||||
ConVar mp_startmoney ("mp_startmoney", NULL, VT_NOREGISTER);
|
||||
|
||||
int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5)
|
||||
int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5, const char *self)
|
||||
{
|
||||
// adding one bot with random parameters to random team
|
||||
if (stricmp (arg0, "addbot") == 0 || stricmp (arg0, "add") == 0)
|
||||
g_botManager->AddBot (arg4, arg1, arg2, arg3, arg5);
|
||||
|
||||
// adding one bot with high difficuluty parameters to random team
|
||||
// adding one bot with high difficulty parameters to random team
|
||||
if (stricmp (arg0, "addbot_hs") == 0 || stricmp (arg0, "addhs") == 0)
|
||||
g_botManager->AddBot (arg4, "4", "1", arg3, arg5);
|
||||
|
||||
|
|
@ -118,53 +118,52 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
|
|||
else if (stricmp (arg0, "?") == 0 || stricmp (arg0, "help") == 0)
|
||||
{
|
||||
ClientPrint (ent, print_console, "Bot Commands:");
|
||||
ClientPrint (ent, print_console, "yapb version - display version information.");
|
||||
ClientPrint (ent, print_console, "yapb about - show bot about information.");
|
||||
ClientPrint (ent, print_console, "yapb add - create a bot in current game.");
|
||||
ClientPrint (ent, print_console, "yapb fill - fill the server with random bots.");
|
||||
ClientPrint (ent, print_console, "yapb kickall - disconnects all bots from current game.");
|
||||
ClientPrint (ent, print_console, "yapb killbots - kills all bots in current game.");
|
||||
ClientPrint (ent, print_console, "yapb kick - disconnect one random bot from game.");
|
||||
ClientPrint (ent, print_console, "yapb weaponmode - select bot weapon mode.");
|
||||
ClientPrint (ent, print_console, "yapb votemap - allows dead bots to vote for specific map.");
|
||||
ClientPrint (ent, print_console, "yapb cmenu - displaying bots command menu.");
|
||||
ClientPrint (ent, print_console, "%s version\t - display version information.", self);
|
||||
ClientPrint (ent, print_console, "%s add\t - create a bot in current game.", self);
|
||||
ClientPrint (ent, print_console, "%s fill\t - fill the server with random bots.", self);
|
||||
ClientPrint (ent, print_console, "%s kickall\t - disconnects all bots from current game.", self);
|
||||
ClientPrint (ent, print_console, "%s killbots\t - kills all bots in current game.", self);
|
||||
ClientPrint (ent, print_console, "%s kick\t - disconnect one random bot from game.", self);
|
||||
ClientPrint (ent, print_console, "%s weaponmode\t - select bot weapon mode.", self);
|
||||
ClientPrint (ent, print_console, "%s votemap\t - allows dead bots to vote for specific map.", self);
|
||||
ClientPrint (ent, print_console, "%s cmenu\t - displaying bots command menu.", self);
|
||||
|
||||
if (stricmp (arg1, "full") == 0 || stricmp (arg1, "f") == 0 || stricmp (arg1, "?") == 0)
|
||||
{
|
||||
ClientPrint (ent, print_console, "yapb add_t - creates one random bot to terrorist team.");
|
||||
ClientPrint (ent, print_console, "yapb add_ct - creates one random bot to ct team.");
|
||||
ClientPrint (ent, print_console, "yapb kick_t - disconnect one random bot from terrorist team.");
|
||||
ClientPrint (ent, print_console, "yapb kick_ct - disconnect one random bot from ct team.");
|
||||
ClientPrint (ent, print_console, "yapb kill_t - kills all bots on terrorist team.");
|
||||
ClientPrint (ent, print_console, "yapb kill_ct - kills all bots on ct team.");
|
||||
ClientPrint (ent, print_console, "yapb list - display list of bots currently playing.");
|
||||
ClientPrint (ent, print_console, "yapb order - execute specific command on specified bot.");
|
||||
ClientPrint (ent, print_console, "yapb time - displays current time on server.");
|
||||
ClientPrint (ent, print_console, "yapb deletewp - erase waypoint file from hard disk (permanently).");
|
||||
ClientPrint (ent, print_console, "%s add_t\t - creates one random bot to terrorist team.", self);
|
||||
ClientPrint (ent, print_console, "%s add_ct\t - creates one random bot to ct team.", self);
|
||||
ClientPrint (ent, print_console, "%s kick_t\t - disconnect one random bot from terrorist team.", self);
|
||||
ClientPrint (ent, print_console, "%s kick_ct\t - disconnect one random bot from ct team.", self);
|
||||
ClientPrint (ent, print_console, "%s kill_t\t - kills all bots on terrorist team.", self);
|
||||
ClientPrint (ent, print_console, "%s kill_ct\t - kills all bots on ct team.", self);
|
||||
ClientPrint (ent, print_console, "%s list\t - display list of bots currently playing.", self);
|
||||
ClientPrint (ent, print_console, "%s order\t - execute specific command on specified bot.", self);
|
||||
ClientPrint (ent, print_console, "%s time\t - displays current time on server.", self);
|
||||
ClientPrint (ent, print_console, "%s deletewp\t - erase waypoint file from hard disk (permanently).", self);
|
||||
|
||||
if (!IsDedicatedServer ())
|
||||
{
|
||||
ServerPrint ("yapb autowp - toggle autowaypointing.");
|
||||
ServerPrint ("yapb wp - toggle waypoint showing.");
|
||||
ServerPrint ("yapb wp on noclip - enable noclip cheat");
|
||||
ServerPrint ("yapb wp save nocheck - save waypoints without checking.");
|
||||
ServerPrint ("yapb wp add - open menu for waypoint creation.");
|
||||
ServerPrint ("yapb wp menu - open main waypoint menu.");
|
||||
ServerPrint ("yapb wp addbasic - creates basic waypoints on map.");
|
||||
ServerPrint ("yapb wp find - show direction to specified waypoint.");
|
||||
ServerPrint ("yapb wp load - load the waypoint file from hard disk.");
|
||||
ServerPrint ("yapb wp check - checks if all waypoints connections are valid.");
|
||||
ServerPrint ("yapb wp cache - cache nearest waypoint.");
|
||||
ServerPrint ("yapb wp teleport - teleport hostile to specified waypoint.");
|
||||
ServerPrint ("yapb wp setradius - manually sets the wayzone radius for this waypoint.");
|
||||
ServerPrint ("yapb path autodistance - opens menu for setting autopath maximum distance.");
|
||||
ServerPrint ("yapb path cache - remember the nearest to player waypoint.");
|
||||
ServerPrint ("yapb path create - opens menu for path creation.");
|
||||
ServerPrint ("yapb path delete - delete path from cached to nearest waypoint.");
|
||||
ServerPrint ("yapb path create_in - creating incoming path connection.");
|
||||
ServerPrint ("yapb path create_out - creating outgoing path connection.");
|
||||
ServerPrint ("yapb path create_both - creating both-ways path connection.");
|
||||
ServerPrint ("yapb exp save - save the experience data.");
|
||||
ServerPrint ("%s autowp\t - toggle autowaypointing.", self);
|
||||
ServerPrint ("%s wp\t - toggle waypoint showing.", self);
|
||||
ServerPrint ("%s wp on noclip\t - enable noclip cheat", self);
|
||||
ServerPrint ("%s wp save nocheck\t - save waypoints without checking.", self);
|
||||
ServerPrint ("%s wp add\t - open menu for waypoint creation.", self);
|
||||
ServerPrint ("%s wp menu\t - open main waypoint menu.", self);
|
||||
ServerPrint ("%s wp addbasic\t - creates basic waypoints on map.", self);
|
||||
ServerPrint ("%s wp find\t - show direction to specified waypoint.", self);
|
||||
ServerPrint ("%s wp load\t - load the waypoint file from hard disk.", self);
|
||||
ServerPrint ("%s wp check\t - checks if all waypoints connections are valid.", self);
|
||||
ServerPrint ("%s wp cache\t - cache nearest waypoint.", self);
|
||||
ServerPrint ("%s wp teleport\t - teleport hostile to specified waypoint.", self);
|
||||
ServerPrint ("%s wp setradius\t - manually sets the wayzone radius for this waypoint.", self);
|
||||
ServerPrint ("%s path autodistance - opens menu for setting autopath maximum distance.", self);
|
||||
ServerPrint ("%s path cache\t - remember the nearest to player waypoint.", self);
|
||||
ServerPrint ("%s path create\t - opens menu for path creation.", self);
|
||||
ServerPrint ("%s path delete\t - delete path from cached to nearest waypoint.", self);
|
||||
ServerPrint ("%s path create_in\t - creating incoming path connection.", self);
|
||||
ServerPrint ("%s path create_out\t - creating outgoing path connection.", self);
|
||||
ServerPrint ("%s path create_both\t - creating both-ways path connection.", self);
|
||||
ServerPrint ("%s exp save\t - save the experience data.", self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -452,7 +451,7 @@ void CommandHandler (void)
|
|||
// the stdio command-line parsing in C when you write "long main (long argc, char **argv)".
|
||||
|
||||
// check status for dedicated server command
|
||||
if (BotCommandHandler (g_hostEntity, IsNullString (CMD_ARGV (1)) ? "help" : CMD_ARGV (1), CMD_ARGV (2), CMD_ARGV (3), CMD_ARGV (4), CMD_ARGV (5), CMD_ARGV (6)) == 0)
|
||||
if (BotCommandHandler (g_hostEntity, IsNullString (CMD_ARGV (1)) ? "help" : CMD_ARGV (1), CMD_ARGV (2), CMD_ARGV (3), CMD_ARGV (4), CMD_ARGV (5), CMD_ARGV (6), CMD_ARGV (0)) == 0)
|
||||
ServerPrint ("Unknown command: %s", CMD_ARGV (1));
|
||||
}
|
||||
|
||||
|
|
@ -1191,7 +1190,7 @@ void ClientCommand (edict_t *ent)
|
|||
{
|
||||
if (stricmp (command, "yapb") == 0 || stricmp (command, "yb") == 0)
|
||||
{
|
||||
int state = BotCommandHandler (ent, IsNullString (CMD_ARGV (1)) ? "help" : CMD_ARGV (1), CMD_ARGV (2), CMD_ARGV (3), CMD_ARGV (4), CMD_ARGV (5), CMD_ARGV (6));
|
||||
int state = BotCommandHandler (ent, IsNullString (CMD_ARGV (1)) ? "help" : CMD_ARGV (1), CMD_ARGV (2), CMD_ARGV (3), CMD_ARGV (4), CMD_ARGV (5), CMD_ARGV (6), CMD_ARGV (0));
|
||||
|
||||
switch (state)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -428,20 +428,17 @@ void NetworkMsg::Execute (void *p)
|
|||
g_bombPlanted = g_bombSayString = true;
|
||||
g_timeBombPlanted = GetWorldTime ();
|
||||
|
||||
if (yb_communication_type.GetInt () == 2)
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
{
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
Bot *bot = g_botManager->GetBot (i);
|
||||
|
||||
if (bot != NULL && IsAlive (bot->GetEntity ()))
|
||||
{
|
||||
Bot *bot = g_botManager->GetBot (i);
|
||||
bot->DeleteSearchNodes ();
|
||||
bot->ResetTasks ();
|
||||
|
||||
if (bot != NULL && IsAlive (bot->GetEntity ()))
|
||||
{
|
||||
bot->DeleteSearchNodes ();
|
||||
bot->ResetTasks ();
|
||||
|
||||
if (Random.Long (0, 100) < 75 && GetTeam (bot->GetEntity ()) == TEAM_CF)
|
||||
bot->ChatterMessage (Chatter_WhereIsTheBomb);
|
||||
}
|
||||
if (yb_communication_type.GetInt () == 2 && Random.Long (0, 100) < 75 && GetTeam (bot->GetEntity ()) == TEAM_CF)
|
||||
bot->ChatterMessage (Chatter_WhereIsTheBomb);
|
||||
}
|
||||
}
|
||||
g_waypoint->SetBombPosition ();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue