a little fixes

This commit is contained in:
Dmitry 2015-06-10 23:30:48 +03:00
commit 02fe78ceee
4 changed files with 36 additions and 74 deletions

View file

@ -100,6 +100,8 @@ typedef struct
int iHitgroup; // 0 == generic, non zero is specific body part
} TraceResult;
typedef edict_t *entity_t;
typedef uint32 CRC32_t;
// Engine hands this to DLLs for functionality callbacks

View file

@ -2896,11 +2896,11 @@ void Bot::ChooseAimDirection (void)
GetValidWaypoint ();
// check if last enemy vector valid
if (m_lastEnemyOrigin != nullvec)
if (m_seeEnemyTime + 7.0 < GetWorldTime () && m_lastEnemyOrigin != nullvec)
{
TraceLine (EyePosition (), m_lastEnemyOrigin, false, true, GetEntity (), &tr);
if ((pev->origin - m_lastEnemyOrigin).GetLength () >= 1600 && IsEntityNull (m_enemy) && !UsesSniper () || (tr.flFraction <= 0.2 && tr.pHit == g_hostEntity) && m_seeEnemyTime + 7.0 < GetWorldTime ())
if ((pev->origin - m_lastEnemyOrigin).GetLength () >= 1600 && IsEntityNull (m_enemy) && !UsesSniper () || (tr.flFraction <= 0.2 && tr.pHit == g_hostEntity))
{
if ((m_aimFlags & (AIM_LAST_ENEMY | AIM_PREDICT_PATH)) && m_wantsToFire)
m_wantsToFire = false;
@ -2909,12 +2909,13 @@ void Bot::ChooseAimDirection (void)
m_aimFlags &= ~(AIM_LAST_ENEMY | AIM_PREDICT_PATH);
flags &= ~(AIM_LAST_ENEMY | AIM_PREDICT_PATH);
flags = m_aimFlags;
}
}
else
{
m_aimFlags &= ~(AIM_LAST_ENEMY | AIM_PREDICT_PATH);
flags &= ~(AIM_LAST_ENEMY | AIM_PREDICT_PATH);
flags = m_aimFlags;
}
// don't allow bot to look at danger positions under certain circumstances
@ -4853,32 +4854,34 @@ void Bot::BotAI (void)
SetConditions ();
// some stuff required by by chatter engine
if ((m_states & STATE_SEEING_ENEMY) && !IsEntityNull (m_enemy))
if (yb_communication_type.GetInt () == 2)
{
if (Random.Long (0, 100) < 45 && GetNearbyFriendsNearPosition (pev->origin, 512) == 0 && (m_enemy->v.weapons & (1 << WEAPON_C4)))
ChatterMessage (Chatter_SpotTheBomber);
if ((m_states & STATE_SEEING_ENEMY) && !IsEntityNull (m_enemy))
{
if (Random.Long (0, 100) < 45 && GetNearbyFriendsNearPosition (pev->origin, 512) == 0 && (m_enemy->v.weapons & (1 << WEAPON_C4)))
ChatterMessage (Chatter_SpotTheBomber);
if (Random.Long (0, 100) < 45 && m_team == TEAM_TF && GetNearbyFriendsNearPosition (pev->origin, 512) == 0 && *g_engfuncs.pfnInfoKeyValue (g_engfuncs.pfnGetInfoKeyBuffer (m_enemy), "model") == 'v')
ChatterMessage (Chatter_VIPSpotted);
if (Random.Long (0, 100) < 45 && m_team == TEAM_TF && GetNearbyFriendsNearPosition (pev->origin, 512) == 0 && *g_engfuncs.pfnInfoKeyValue (g_engfuncs.pfnGetInfoKeyBuffer (m_enemy), "model") == 'v')
ChatterMessage (Chatter_VIPSpotted);
if (Random.Long (0, 100) < 50 && GetNearbyFriendsNearPosition (pev->origin, 450) == 0 && GetTeam (m_enemy) != m_team && IsGroupOfEnemies (m_enemy->v.origin, 2, 384))
ChatterMessage (Chatter_ScaredEmotion);
if (Random.Long (0, 100) < 50 && GetNearbyFriendsNearPosition (pev->origin, 450) == 0 && GetTeam (m_enemy) != m_team && IsGroupOfEnemies (m_enemy->v.origin, 2, 384))
ChatterMessage (Chatter_ScaredEmotion);
if (Random.Long (0, 100) < 40 && GetNearbyFriendsNearPosition (pev->origin, 1024) == 0 && ((m_enemy->v.weapons & (1 << WEAPON_AWP)) || (m_enemy->v.weapons & (1 << WEAPON_SCOUT)) || (m_enemy->v.weapons & (1 << WEAPON_G3SG1)) || (m_enemy->v.weapons & (1 << WEAPON_SG550))))
ChatterMessage (Chatter_SniperWarning);
if (Random.Long (0, 100) < 40 && GetNearbyFriendsNearPosition (pev->origin, 1024) == 0 && ((m_enemy->v.weapons & (1 << WEAPON_AWP)) || (m_enemy->v.weapons & (1 << WEAPON_SCOUT)) || (m_enemy->v.weapons & (1 << WEAPON_G3SG1)) || (m_enemy->v.weapons & (1 << WEAPON_SG550))))
ChatterMessage (Chatter_SniperWarning);
}
// if bot is trapped under shield yell for help !
if (GetTaskId () == TASK_CAMP && HasShield () && IsShieldDrawn () && GetNearbyEnemiesNearPosition (pev->origin, 650) >= 2 && IsEnemyViewable (m_enemy))
InstantChatterMessage (Chatter_Pinned_Down);
// if bomb planted warn teammates !
if (g_canSayBombPlanted && g_bombPlanted && GetTeam (GetEntity ()) == TEAM_CF)
{
g_canSayBombPlanted = false;
ChatterMessage (Chatter_GottaFindTheBomb);
}
}
// if bot is trapped under shield yell for help !
if (GetTaskId () == TASK_CAMP && HasShield() && IsShieldDrawn () && GetNearbyEnemiesNearPosition (pev->origin, 650) >= 2 && IsEnemyViewable(m_enemy))
InstantChatterMessage(Chatter_Pinned_Down);
// if bomb planted warn teammates !
if (g_canSayBombPlanted && g_bombPlanted && GetTeam (GetEntity()) == TEAM_CF)
{
g_canSayBombPlanted = false;
ChatterMessage (Chatter_GottaFindTheBomb);
}
Vector src, destination;
m_checkTerrain = true;
@ -5781,7 +5784,7 @@ byte Bot::ThrottledMsec (void)
if (newMsec < 10)
{
msecVal = msecVal - static_cast <float> (newMsec) + m_msecValRest;
msecVal -= static_cast <float> (newMsec) + m_msecValRest;
msecRest = static_cast <int> (msecVal);
m_msecValRest = msecVal - static_cast <float> (msecRest);

View file

@ -191,7 +191,7 @@ bool Bot::LookupEnemy (void)
if (friendBot != NULL)
{
if (friendBot->m_seeEnemyTime + 2.0 < GetWorldTime () || IsEntityNull (friendBot->m_lastEnemy))
if (friendBot->m_seeEnemyTime + 2.0f < GetWorldTime () || IsEntityNull (friendBot->m_lastEnemy))
{
if (IsVisible (pev->origin, ENT (friendBot->pev)))
{
@ -213,7 +213,7 @@ bool Bot::LookupEnemy (void)
if (!IsAlive (newEnemy))
{
m_enemy = NULL;
// shoot at dying players if no new enemy to give some more human-like illusion
if (m_seeEnemyTime + 0.1 > GetWorldTime ())
{
@ -648,49 +648,6 @@ void Bot::FireWeapon (void)
selectId = WEAPON_KNIFE; // no available ammo, use knife!
}
// ignore enemies protected by shields
if (IsEnemyProtectedByShield (m_enemy) && !(m_currentWeapon == WEAPON_KNIFE) && IsEnemyViewable (m_enemy))
{
if (!g_bombPlanted && Random.Float (0, 100) < 50)
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (5, 10), true);
}
// check if bot has shield
if (HasShield () && m_shieldCheckTime < GetWorldTime () && GetTaskId () != TASK_CAMP && IsEnemyViewable (m_enemy))
{
if (IsGroupOfEnemies (pev->origin, 3, 750) && !IsShieldDrawn () && !g_bombPlanted)
StartTask (TASK_SEEKCOVER, TASKPRI_SEEKCOVER, -1, GetWorldTime () + Random.Float (10, 20), true);
if (distance >= 750 || ((m_enemy->v.button & IN_ATTACK) && !IsShieldDrawn()))
{
pev->button |= IN_ATTACK2; // draw the shield
pev->button &= ~IN_DUCK;
if (IsGroupOfEnemies (pev->origin, 3, 550) || (GetNearbyEnemiesNearPosition (pev->origin, 550) >= 3 && IsShieldDrawn ()))
{
ChooseAimDirection();
FacePosition ();
}
else if(!g_bombPlanted)
StartTask (TASK_CAMP, TASKPRI_PAUSE, -1, GetWorldTime () + Random.Float (10, 20), true);
if (IsEnemyProtectedByShield (m_lastEnemy) && !(m_currentWeapon == WEAPON_KNIFE) && IsEnemyViewable (m_lastEnemy))
{
pev->button &= ~IN_ATTACK;
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (10, 20), true);
}
}
else if (IsShieldDrawn () || (!IsEntityNull (m_enemy) && (m_enemy->v.button & IN_RELOAD) || !IsEnemyViewable (m_enemy)))
{
pev->button |= (IN_ATTACK2 | IN_DUCK); // draw out the shield
if (!g_bombPlanted)
StartTask (TASK_SEEKCOVER, TASKPRI_SEEKCOVER, -1, GetWorldTime () + Random.Float (10, 25), true);
}
m_shieldCheckTime = GetWorldTime () + 0.5;
}
WeaponSelectEnd:
// we want to fire weapon, don't reload now
if (!m_isReloading)

View file

@ -997,12 +997,12 @@ void Touch (edict_t *pentTouched, edict_t *pentOther)
// the two entities both have velocities, for example two players colliding, this function
// is called twice, once for each entity moving.
if (!IsEntityNull (pentTouched) && (pentTouched->v.flags & FL_FAKECLIENT))
if (!IsEntityNull (pentOther) && (pentOther->v.flags & FL_FAKECLIENT))
{
Bot *touched = g_botManager->GetBot (pentTouched);
Bot *bot = g_botManager->GetBot (pentOther);
if (touched != NULL)
touched->VerifyBreakable (pentOther);
if (bot != NULL)
bot->VerifyBreakable (pentTouched);
}
if (g_isMetamod)
RETURN_META (MRES_IGNORED);