some combat behaviour improvements

This commit is contained in:
Dmitry 2015-06-08 22:55:57 +03:00
commit f0dcda5747
3 changed files with 28 additions and 32 deletions

View file

@ -2872,16 +2872,11 @@ void Bot::SelectLeaderEachTeam (int team)
void Bot::ChooseAimDirection (void) void Bot::ChooseAimDirection (void)
{ {
if (!m_canChooseAimDirection)
return;
TraceResult tr; TraceResult tr;
memset (&tr, 0, sizeof (TraceResult)); memset (&tr, 0, sizeof (TraceResult));
unsigned int flags = m_aimFlags; unsigned int flags = m_aimFlags;
bool canChooseAimDirection = false;
if (!(m_currentWaypointIndex >= 0 && m_currentWaypointIndex < g_numWaypoints)) if (!(m_currentWaypointIndex >= 0 && m_currentWaypointIndex < g_numWaypoints))
GetValidWaypoint (); GetValidWaypoint ();
@ -2913,7 +2908,7 @@ void Bot::ChooseAimDirection (void)
if (IsOnLadder () || IsInWater () || (m_waypointFlags & FLAG_LADDER) || (m_currentTravelFlags & PATHFLAG_JUMP)) if (IsOnLadder () || IsInWater () || (m_waypointFlags & FLAG_LADDER) || (m_currentTravelFlags & PATHFLAG_JUMP))
{ {
flags &= ~(AIM_LAST_ENEMY | AIM_PREDICT_PATH); flags &= ~(AIM_LAST_ENEMY | AIM_PREDICT_PATH);
canChooseAimDirection = false; m_canChooseAimDirection = false;
} }
} }
@ -2982,7 +2977,7 @@ void Bot::ChooseAimDirection (void)
{ {
m_lookAt = m_destOrigin; m_lookAt = m_destOrigin;
if (canChooseAimDirection && m_currentWaypointIndex != -1 && !(m_currentPath->flags & FLAG_LADDER)) if (m_canChooseAimDirection && m_currentWaypointIndex != -1 && !(m_currentPath->flags & FLAG_LADDER))
{ {
int index = m_currentWaypointIndex; int index = m_currentWaypointIndex;
@ -3010,7 +3005,7 @@ void Bot::ChooseAimDirection (void)
} }
} }
if (canChooseAimDirection && m_prevWptIndex[0] >= 0 && m_prevWptIndex[0] < g_numWaypoints) if (m_canChooseAimDirection && m_prevWptIndex[0] >= 0 && m_prevWptIndex[0] < g_numWaypoints)
{ {
Path *path = g_waypoint->GetPath (m_prevWptIndex[0]); Path *path = g_waypoint->GetPath (m_prevWptIndex[0]);

View file

@ -1047,7 +1047,7 @@ void Bot::CombatFight (void)
{ {
if (m_lastFightStyleCheck + 3.0 < GetWorldTime ()) if (m_lastFightStyleCheck + 3.0 < GetWorldTime ())
{ {
if ( g_randGen.Long (0, 100) < 50) if (g_randGen.Long (0, 100) < 50)
m_fightStyle = 1; m_fightStyle = 1;
else else
m_fightStyle = 0; m_fightStyle = 0;
@ -1056,7 +1056,11 @@ void Bot::CombatFight (void)
} }
} }
if ((m_difficulty >= 1 && m_fightStyle == 0) || ((pev->button & IN_RELOAD) || m_isReloading) || (UsesPistol () && distance < 500.0)) // if there is a friend between us and enemy, do a strafe movement
if (m_lastFightStyleCheck + 2.5f < GetWorldTime () && IsFriendInLineOfFire (distance))
m_fightStyle = 0;
if ((m_difficulty >= 1 && m_fightStyle == 0) || ((pev->button & IN_RELOAD) || m_isReloading) || (UsesPistol () && distance < 400.0f))
{ {
if (m_strafeSetTime < GetWorldTime ()) if (m_strafeSetTime < GetWorldTime ())
{ {

View file

@ -1847,7 +1847,6 @@ bool Bot::FindWaypoint (void)
reachDistances[j] = distance; reachDistances[j] = distance;
} }
} }
DebugMsg ("got some waypoints...");
} }
// now pick random one from choosen // now pick random one from choosen
@ -1872,8 +1871,6 @@ bool Bot::FindWaypoint (void)
Array <int> found; Array <int> found;
g_waypoint->FindInRadius (found, 256.0f, pev->origin); g_waypoint->FindInRadius (found, 256.0f, pev->origin);
DebugMsg ("doing worst case");
if (!found.IsEmpty ()) if (!found.IsEmpty ())
{ {
bool gotId = false; bool gotId = false;
@ -2339,6 +2336,7 @@ bool Bot::HeadTowardWaypoint (void)
m_navNode = m_navNode->next; // advance in list m_navNode = m_navNode->next; // advance in list
m_currentTravelFlags = 0; // reset travel flags (jumping etc) m_currentTravelFlags = 0; // reset travel flags (jumping etc)
// we're not at the end of the list?
// we're not at the end of the list? // we're not at the end of the list?
if (m_navNode != NULL) if (m_navNode != NULL)
{ {
@ -2346,12 +2344,10 @@ bool Bot::HeadTowardWaypoint (void)
if (m_navNode != m_navNodeStart && m_navNode->next != NULL) if (m_navNode != m_navNodeStart && m_navNode->next != NULL)
{ {
GetBestNextWaypoint (); GetBestNextWaypoint ();
int taskID = GetTaskId ();
m_minSpeed = pev->maxspeed; m_minSpeed = pev->maxspeed;
// only if we in normal task and bomb is not planted // only if we in normal task and bomb is not planted
if (taskID == TASK_NORMAL && !g_bombPlanted && !m_inBombZone && !m_inBuyZone && m_personality != PERSONALITY_RUSHER && !m_hasC4 && !m_isVIP && (m_loosedBombWptIndex == -1) && !HasHostage () && m_fearLevel * 2 > m_agressionLevel) if (m_currentPath->flags & (FLAG_GOAL | FLAG_SNIPER | FLAG_CAMP) && GetTaskId () == TASK_NORMAL && !g_bombPlanted && m_personality != PERSONALITY_RUSHER && !m_hasC4 && !m_isVIP && m_loosedBombWptIndex == -1 && !HasHostage ())
{ {
m_campButtons = 0; m_campButtons = 0;
@ -2363,35 +2359,36 @@ bool Bot::HeadTowardWaypoint (void)
else else
kills = (g_experienceData + (waypoint * g_numWaypoints) + waypoint)->team1Damage / g_highestDamageCT; kills = (g_experienceData + (waypoint * g_numWaypoints) + waypoint)->team1Damage / g_highestDamageCT;
switch (m_personality)
{
case PERSONALITY_NORMAL:
kills *= 0.33f;
break;
default:
kills *= 0.5f;
break;
}
// if damage done higher than one // if damage done higher than one
if (kills > 0.15f && g_timeRoundMid + 30.0f > GetWorldTime () && m_timeCamping + 10.0 < GetWorldTime()) if (kills > 0.15f && g_timeRoundMid > GetWorldTime ())
{ {
switch (m_personality)
{
case PERSONALITY_NORMAL:
kills *= 0.33f;
break;
default:
kills *= 0.5f;
break;
}
if (m_baseAgressionLevel < kills && GetTaskId () != TASK_MOVETOPOSITION && HasPrimaryWeapon ()) if (m_baseAgressionLevel < kills && GetTaskId () != TASK_MOVETOPOSITION && HasPrimaryWeapon ())
{ {
DebugMsg ("pushing camp on to stack");
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + (m_fearLevel * (g_timeRoundMid - GetWorldTime ()) * 0.5), true); // push camp task on to stack StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + (m_fearLevel * (g_timeRoundMid - GetWorldTime ()) * 0.5), true); // push camp task on to stack
StartTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, FindDefendWaypoint (g_waypoint->GetPath (waypoint)->origin), 0.0, true); StartTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, FindDefendWaypoint (g_waypoint->GetPath (waypoint)->origin), 0.0, true);
if (m_difficulty >= 2) if (m_difficulty >= 3)
pev->button |= IN_DUCK; pev->button |= IN_DUCK;
} }
} }
else if (g_botsCanPause && !IsOnLadder () && !IsInWater () && !m_currentTravelFlags && IsOnFloor ())
if (g_botsCanPause && !IsOnLadder () && !IsInWater () && !m_currentTravelFlags && IsOnFloor ())
{ {
if (static_cast <float> (kills) == m_baseAgressionLevel) if (static_cast <float> (kills) == m_baseAgressionLevel)
m_campButtons |= IN_DUCK; m_campButtons |= IN_DUCK;
else if (g_randGen.Long (1, 100) < m_difficulty * 25) else if (g_randGen.Long (1, 100) > (m_difficulty * 25 + g_randGen.Long (1, 20)))
m_minSpeed = GetWalkSpeed (); m_minSpeed = GetWalkSpeed ();
} }
} }