From 36b865abdeeb88ba90980b38537af2c7b60fd913 Mon Sep 17 00:00:00 2001 From: jeefo Date: Sat, 15 Aug 2015 18:09:15 +0300 Subject: [PATCH] do not compare traceresult fraction directly 1.0 some cosmetic changes bots will spray more logos reduced "cheating" in jumping a little bit optimized checking 3d vector for zero --- include/core.h | 42 ++- include/corelib.h | 20 +- project/Performance1.psess | 65 ---- project/makefile | 2 +- source/basecode.cpp | 706 ++++++++++++++++++------------------- source/chatlib.cpp | 12 +- source/combat.cpp | 129 ++++--- source/globals.cpp | 60 ++-- source/interface.cpp | 2 +- source/manager.cpp | 92 ++--- source/navigate.cpp | 525 +++++++++++++-------------- source/netmsg.cpp | 2 +- source/support.cpp | 79 +++-- source/waypoint.cpp | 282 +++++++-------- 14 files changed, 958 insertions(+), 1060 deletions(-) delete mode 100644 project/Performance1.psess diff --git a/include/core.h b/include/core.h index dc3be06..8fc0b20 100644 --- a/include/core.h +++ b/include/core.h @@ -567,42 +567,40 @@ const int FV_EXPERIENCE = 3; const int FV_VISTABLE = 1; // some hardcoded desire defines used to override calculated ones -const float TASKPRI_NORMAL = 35.0; -const float TASKPRI_PAUSE = 36.0; -const float TASKPRI_CAMP = 37.0; -const float TASKPRI_SPRAYLOGO = 38.0; -const float TASKPRI_FOLLOWUSER = 39.0; -const float TASKPRI_MOVETOPOSITION = 50.0; -const float TASKPRI_DEFUSEBOMB = 89.0; -const float TASKPRI_PLANTBOMB = 89.0; -const float TASKPRI_ATTACK = 90.0; -const float TASKPRI_SEEKCOVER = 91.0; -const float TASKPRI_HIDE = 92.0; -const float TASKPRI_THROWGRENADE = 99.0; -const float TASKPRI_DOUBLEJUMP = 99.0; -const float TASKPRI_BLINDED = 100.0; -const float TASKPRI_SHOOTBREAKABLE = 100.0; -const float TASKPRI_ESCAPEFROMBOMB = 100.0; +const float TASKPRI_NORMAL = 35.0f; +const float TASKPRI_PAUSE = 36.0f; +const float TASKPRI_CAMP = 37.0f; +const float TASKPRI_SPRAYLOGO = 38.0f; +const float TASKPRI_FOLLOWUSER = 39.0f; +const float TASKPRI_MOVETOPOSITION = 50.0f; +const float TASKPRI_DEFUSEBOMB = 89.0f; +const float TASKPRI_PLANTBOMB = 89.0f; +const float TASKPRI_ATTACK = 90.0f; +const float TASKPRI_SEEKCOVER = 91.0f; +const float TASKPRI_HIDE = 92.0f; +const float TASKPRI_THROWGRENADE = 99.0f; +const float TASKPRI_DOUBLEJUMP = 99.0f; +const float TASKPRI_BLINDED = 100.0f; +const float TASKPRI_SHOOTBREAKABLE = 100.0f; +const float TASKPRI_ESCAPEFROMBOMB = 100.0f; const float MAX_GRENADE_TIMER = 2.34f; +const float TRACE_FRACTION_EQ = 0.999999f; const int MAX_HOSTAGES = 8; const int MAX_PATH_INDEX = 8; const int MAX_DAMAGE_VALUE = 2040; const int MAX_GOAL_VALUE = 2040; const int MAX_KILL_HISTORY = 16; -const int MAX_REG_MESSAGES = 256; const int MAX_WAYPOINTS = 1024; const int MAX_WEAPONS = 32; const int NUM_WEAPONS = 26; +const int MAX_COLLIDE_MOVES = 3; // weapon masks const int WEAPON_PRIMARY = ((1 << WEAPON_XM1014) | (1 < &radiusHolder, float radius, const Vector &origin, int maxCount = -1); - void Add (int flags, const Vector &waypointOrigin = nullvec); + void Add (int flags, const Vector &waypointOrigin = Vector::GetZero ()); void Delete (void); void ToggleFlags (int toggleFlag); void SetRadius (int radius); diff --git a/include/corelib.h b/include/corelib.h index 913ed50..0626d82 100644 --- a/include/corelib.h +++ b/include/corelib.h @@ -592,14 +592,14 @@ public: } // - // Function: IsNull + // Function: IsZero // // Checks whether vector is null. // // Returns: // True if this vector is (0.0f, 0.0f, 0.0f) within tolerance, false otherwise. // - inline bool IsNull (void) const + inline bool IsZero (void) const { return Math::FltZero (x) && Math::FltZero (y) && Math::FltZero (z); } @@ -612,10 +612,17 @@ public: // Returns: // Nulled vector. // - inline static const Vector &GetNull (void) + inline static const Vector &GetZero (void) { - static const Vector &s_null = Vector (0.0, 0.0, 0.0f); - return s_null; + static const Vector &s_zero = Vector (0.0f, 0.0f, 0.0f); + return s_zero; + } + + inline void Zero (void) + { + x = 0.0f; + y = 0.0f; + z = 0.0f; } // @@ -729,9 +736,6 @@ public: } }; -static const Vector &nullvec = Vector::GetNull (); - - // // Class: List // Simple linked list container. diff --git a/project/Performance1.psess b/project/Performance1.psess deleted file mode 100644 index 11c8ffc..0000000 --- a/project/Performance1.psess +++ /dev/null @@ -1,65 +0,0 @@ - - - - yapb.sln - Sampling - None - true - true - Timestamp - Cycles - 10000000 - 10 - 10 - - false - - - - false - 500 - - \Memory\Pages/sec - \PhysicalDisk(_Total)\Avg. Disk Queue Length - \Processor(_Total)\% Processor Time - - - - true - false - - false - - - false - - - - Report150602.vspx - - - Report150602(1).vspx - - - Report150602(2).vspx - - - Report150602(3).vspx - - - Report150602(4).vspx - - - Report150602(5).vspx - - - Report150602(6).vspx - - - Report150603.vspx - - - Report150603(1).vspx - - - \ No newline at end of file diff --git a/project/makefile b/project/makefile index 556510d..728549a 100644 --- a/project/makefile +++ b/project/makefile @@ -22,7 +22,7 @@ OBJECTS = $(SRC_DIR)/basecode.cpp \ $(SRC_DIR)/support.cpp \ $(SRC_DIR)/waypoint.cpp \ -C_OPT_FLAGS = -O3 -DNDEBUG=1 -ffast-math -fno-exceptions -fno-rtti -funroll-loops -fomit-frame-pointer -pipe +C_OPT_FLAGS = -O3 -DNDEBUG=1 -fno-exceptions -fno-rtti -funroll-loops -fomit-frame-pointer -pipe C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 C_GCC4_FLAGS = -fvisibility=hidden CPP_GCC4_FLAGS = -fvisibility-inlines-hidden diff --git a/source/basecode.cpp b/source/basecode.cpp index 6f8f55c..8ef2a63 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -104,13 +104,13 @@ bool Bot::ItemIsVisible (const Vector &destination, char *itemName) TraceLine (EyePosition (), destination, true, GetEntity (), &tr); // check if line of sight to object is not blocked (i.e. visible) - if (tr.flFraction != 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) { // check for standard items if (strcmp (STRING (tr.pHit->v.classname), itemName) == 0) return true; - if (tr.flFraction > 0.98 && (yb_csdm_mode.GetBool () && strncmp (STRING (tr.pHit->v.classname), "csdmw_", 6) == 0)) + if (tr.flFraction > 0.98f && (yb_csdm_mode.GetBool () && strncmp (STRING (tr.pHit->v.classname), "csdmw_", 6) == 0)) return true; return false; @@ -123,10 +123,10 @@ bool Bot::EntityIsVisible (const Vector &dest, bool fromBody) TraceResult tr; // trace a line from bot's eyes to destination... - TraceLine (fromBody ? pev->origin - Vector (0, 0, 1) : EyePosition (), dest, true, true, GetEntity (), &tr); + TraceLine (fromBody ? pev->origin - Vector (0.0f, 0.0f, 1.0f) : EyePosition (), dest, true, true, GetEntity (), &tr); // check if line of sight to object is not blocked (i.e. visible) - return tr.flFraction >= 1.0; + return tr.flFraction > TRACE_FRACTION_EQ; } void Bot::CheckGrenadeThrow (void) @@ -147,7 +147,7 @@ void Bot::CheckGrenadeThrow (void) // if we don't have grenades no need to check it this round again if (grenadeToThrow == -1) { - m_grenadeCheckTime = GetWorldTime () + 15.0; // changed since, conzero can drop grens from dead players + m_grenadeCheckTime = GetWorldTime () + 15.0f; // changed since, conzero can drop grens from dead players m_states &= ~(STATE_THROW_HE | STATE_THROW_FB | STATE_THROW_SG); return; @@ -175,17 +175,17 @@ void Bot::CheckGrenadeThrow (void) if (allowThrowing && m_seeEnemyTime + 2.0 < GetWorldTime ()) { - const Vector &enemyPredict = ((m_lastEnemy->v.velocity * 0.5).Get2D () + m_lastEnemy->v.origin); + const Vector &enemyPredict = ((m_lastEnemy->v.velocity * 0.5f).Get2D () + m_lastEnemy->v.origin); float searchRadius = m_lastEnemy->v.velocity.GetLength2D (); // check the search radius - if (searchRadius < 128.0) - searchRadius = 128.0; + if (searchRadius < 128.0f) + searchRadius = 128.0f; Array predictedPoints; // search waypoints - waypoints.FindInRadius (predictedPoints, searchRadius, enemyPredict, 4); + waypoints.FindInRadius (predictedPoints, searchRadius, enemyPredict, 5); FOR_EACH_AE (predictedPoints, it) { @@ -195,10 +195,10 @@ void Bot::CheckGrenadeThrow (void) m_throw = waypoints.GetPath (predictedPoints[it])->origin; Vector src = CheckThrow (EyePosition (), m_throw); - if (src.GetLengthSquared () < 100.0) + if (src.GetLengthSquared () < 100.0f) src = CheckToss (EyePosition (), m_throw); - if (src == nullvec) + if (src.IsZero ()) allowThrowing = false; else break; @@ -214,19 +214,19 @@ void Bot::CheckGrenadeThrow (void) else if (grenadeToThrow == WEAPON_SMOKE) { // start smoke grenade throwing? - if ((m_states & STATE_SEEING_ENEMY) && GetShootingConeDeviation (m_enemy, &pev->origin) >= 0.70 && m_seeEnemyTime + 2.0 < GetWorldTime ()) + if ((m_states & STATE_SEEING_ENEMY) && GetShootingConeDeviation (m_enemy, &pev->origin) >= 0.70f && m_seeEnemyTime + 2.0f < GetWorldTime ()) m_states &= ~STATE_THROW_SG; else m_states |= STATE_THROW_SG; } } } - else if (IsAlive (m_lastEnemy) && grenadeToThrow == WEAPON_FLASHBANG && (m_lastEnemy->v.origin - pev->origin).GetLength () < 800 && !(m_aimFlags & AIM_ENEMY) && Random.Long (0, 100) < 50) + else if (IsAlive (m_lastEnemy) && grenadeToThrow == WEAPON_FLASHBANG && (m_lastEnemy->v.origin - pev->origin).GetLength () < 800.0f && !(m_aimFlags & AIM_ENEMY) && Random.Long (0, 100) < 50) { bool allowThrowing = true; Array inRadius; - waypoints.FindInRadius (inRadius, 256, m_lastEnemy->v.origin + (m_lastEnemy->v.velocity * 0.5).Get2D ()); + waypoints.FindInRadius (inRadius, 256.0f, m_lastEnemy->v.origin + (m_lastEnemy->v.velocity * 0.5f).Get2D ()); FOR_EACH_AE (inRadius, i) { @@ -240,10 +240,10 @@ void Bot::CheckGrenadeThrow (void) m_throw = path->origin; Vector src = CheckThrow (EyePosition (), m_throw); - if (src.GetLengthSquared () < 100) + if (src.GetLengthSquared () < 100.0f) src = CheckToss (EyePosition (), m_throw); - if (src == nullvec) + if (src.IsZero ()) continue; allowThrowing = true; @@ -251,18 +251,18 @@ void Bot::CheckGrenadeThrow (void) } // start concussion grenade throwing? - if (allowThrowing && m_seeEnemyTime + 2.0 < GetWorldTime ()) + if (allowThrowing && m_seeEnemyTime + 2.0f < GetWorldTime ()) m_states |= STATE_THROW_FB; else m_states &= ~STATE_THROW_FB; } if (m_states & STATE_THROW_HE) - PushTask (TASK_THROWHEGRENADE, TASKPRI_THROWGRENADE, -1, GetWorldTime () + 3.0, false); + PushTask (TASK_THROWHEGRENADE, TASKPRI_THROWGRENADE, -1, GetWorldTime () + 3.0f, false); else if (m_states & STATE_THROW_FB) - PushTask (TASK_THROWFLASHBANG, TASKPRI_THROWGRENADE, -1, GetWorldTime () + 3.0, false); + PushTask (TASK_THROWFLASHBANG, TASKPRI_THROWGRENADE, -1, GetWorldTime () + 3.0f, false); else if (m_states & STATE_THROW_SG) - PushTask (TASK_THROWSMOKE, TASKPRI_THROWGRENADE, -1, GetWorldTime () + 3.0, false); + PushTask (TASK_THROWSMOKE, TASKPRI_THROWGRENADE, -1, GetWorldTime () + 3.0f, false); // delay next grenade throw if (m_states & (STATE_THROW_HE | STATE_THROW_FB | STATE_THROW_SG)) @@ -298,7 +298,7 @@ void Bot::AvoidGrenades (void) continue; // check if visible to the bot - if (!EntityIsVisible (ent->v.origin) && InFieldOfView (ent->v.origin - EyePosition ()) > pev->fov * 0.5) + if (!EntityIsVisible (ent->v.origin) && InFieldOfView (ent->v.origin - EyePosition ()) > pev->fov * 0.5f) continue; if (m_turnAwayFromFlashbang < GetWorldTime () && m_personality == PERSONALITY_RUSHER && m_difficulty == 4 && strcmp (STRING (ent->v.model) + 9, "flashbang.mdl") == 0) @@ -325,14 +325,14 @@ void Bot::AvoidGrenades (void) float distance = (ent->v.origin - pev->origin).GetLength (); float distanceMoved = ((ent->v.origin + ent->v.velocity * m_frameInterval) - pev->origin).GetLength (); - if (distanceMoved < distance && distance < 500) + if (distanceMoved < distance && distance < 500.0f) { MakeVectors (pev->v_angle); const Vector &dirToPoint = (pev->origin - ent->v.origin).Normalize2D (); const Vector &rightSide = g_pGlobals->v_right.Normalize2D (); - if ((dirToPoint | rightSide) > 0) + if ((dirToPoint | rightSide) > 0.0f) m_needAvoidGrenade = -1; else m_needAvoidGrenade = 1; @@ -365,7 +365,7 @@ bool Bot::IsBehindSmokeClouds (edict_t *ent) continue; // check if visible to the bot - if (!EntityIsVisible (ent->v.origin) && InFieldOfView (ent->v.origin - EyePosition ()) > pev->fov / 3) + if (!EntityIsVisible (ent->v.origin) && InFieldOfView (ent->v.origin - EyePosition ()) > pev->fov / 3.0f) continue; const Vector &entityOrigin = GetEntityOrigin (grenade); @@ -470,7 +470,7 @@ void Bot::VerifyBreakable (edict_t *touch) m_campButtons = pev->button & IN_DUCK; - PushTask (TASK_SHOOTBREAKABLE, TASKPRI_SHOOTBREAKABLE, -1, 0.0, false); + PushTask (TASK_SHOOTBREAKABLE, TASKPRI_SHOOTBREAKABLE, -1, 0.0f, false); } edict_t *Bot::FindBreakable (void) @@ -478,9 +478,9 @@ edict_t *Bot::FindBreakable (void) // this function checks if bot is blocked by a shoot able breakable in his moving direction TraceResult tr; - TraceLine (pev->origin, pev->origin + (m_destOrigin - pev->origin).Normalize () * 64, false, false, GetEntity (), &tr); + TraceLine (pev->origin, pev->origin + (m_destOrigin - pev->origin).Normalize () * 64.0f, false, false, GetEntity (), &tr); - if (tr.flFraction != 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) { edict_t *ent = tr.pHit; @@ -491,9 +491,9 @@ edict_t *Bot::FindBreakable (void) return ent; } } - TraceLine (EyePosition (), EyePosition () + (m_destOrigin - EyePosition ()).Normalize () * 64, false, false, GetEntity (), &tr); + TraceLine (EyePosition (), EyePosition () + (m_destOrigin - EyePosition ()).Normalize () * 64.0f, false, false, GetEntity (), &tr); - if (tr.flFraction != 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) { edict_t *ent = tr.pHit; @@ -504,7 +504,7 @@ edict_t *Bot::FindBreakable (void) } } m_breakableEntity = NULL; - m_breakable = nullvec; + m_breakable.Zero (); return NULL; } @@ -564,7 +564,7 @@ void Bot::FindItem (void) edict_t *ent = NULL, *pickupItem = NULL; Bot *bot = NULL; - float distance, minDistance = 341.0; + float distance, minDistance = 341.0f; const float searchRadius = 340.0f; @@ -601,8 +601,8 @@ void Bot::FindItem (void) PickupType pickupType = PICKUP_NONE; - Vector pickupOrigin = nullvec; - Vector entityOrigin = nullvec; + Vector pickupOrigin; + Vector entityOrigin; m_pickupItem = NULL; m_pickupType = PICKUP_NONE; @@ -680,9 +680,9 @@ void Bot::FindItem (void) } else if (m_isVIP || !RateGroundWeapon (ent)) allowPickup = false; - else if (strcmp (STRING (ent->v.model) + 9, "medkit.mdl") == 0 && pev->health >= 100) + else if (strcmp (STRING (ent->v.model) + 9, "medkit.mdl") == 0 && pev->health >= 100.0f) allowPickup = false; - else if ((strcmp (STRING (ent->v.model) + 9, "kevlar.mdl") == 0 || strcmp (STRING (ent->v.model) + 9, "battery.mdl") == 0) && pev->armorvalue >= 100) // armor vest + else if ((strcmp (STRING (ent->v.model) + 9, "kevlar.mdl") == 0 || strcmp (STRING (ent->v.model) + 9, "battery.mdl") == 0) && pev->armorvalue >= 100.0f) // armor vest allowPickup = false; else if (strcmp (STRING (ent->v.model) + 9, "flashbang.mdl") == 0 && (pev->weapons & (1 << WEAPON_FLASHBANG))) // concussion grenade allowPickup = false; @@ -715,8 +715,8 @@ void Bot::FindItem (void) { int index = FindDefendWaypoint (entityOrigin); - PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (30.0, 60.0), true); // push camp task on to stack - PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + Random.Float (3.0, 6.0), true); // push move command + PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (30.0f, 60.0f), true); // push camp task on to stack + PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + Random.Float (3.0f, 6.0f), true); // push move command if (waypoints.GetPath (index)->vis.crouch <= waypoints.GetPath (index)->vis.stand) m_campButtons |= IN_DUCK; @@ -741,7 +741,7 @@ void Bot::FindItem (void) Path *path = waypoints.GetPath (index); float bombTimer = mp_c4timer.GetFloat (); - float timeMidBlowup = g_timeBombPlanted + (bombTimer * 0.5 + bombTimer * 0.25) - waypoints.GetTravelTime (pev->maxspeed, pev->origin, path->origin); + float timeMidBlowup = g_timeBombPlanted + (bombTimer * 0.5f + bombTimer * 0.25f) - waypoints.GetTravelTime (pev->maxspeed, pev->origin, path->origin); if (timeMidBlowup > GetWorldTime ()) { @@ -767,7 +767,7 @@ void Bot::FindItem (void) { if (pickupType == PICKUP_HOSTAGE) { - if (IsEntityNull (ent) || (ent->v.health <= 0)) + if (IsEntityNull (ent) || ent->v.health <= 0) allowPickup = false; // never pickup dead hostage else for (int i = 0; i < GetMaxClients (); i++) { @@ -830,8 +830,8 @@ void Bot::FindItem (void) { int index = FindDefendWaypoint (entityOrigin); - PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (30.0, 70.0), true); // push camp task on to stack - PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + Random.Float (10.0, 30.0), true); // push move command + PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (30.0f, 70.0f), true); // push camp task on to stack + PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + Random.Float (10.0f, 30.0f), true); // push move command if (waypoints.GetPath (index)->vis.crouch <= waypoints.GetPath (index)->vis.stand) m_campButtons |= IN_DUCK; @@ -897,11 +897,11 @@ void Bot::GetCampDirection (Vector *dest) TraceLine (src, *dest, true, GetEntity (), &tr); // check if the trace hit something... - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) { float length = (tr.vecEndPos - src).GetLengthSquared (); - if (length > 10000) + if (length > 10000.0f) return; float minDistance = 99999.0f; @@ -991,7 +991,7 @@ void Bot::InstantChatterMessage (int type) if (reportTime >= GetWorldTime ()) return; - reportTime = GetWorldTime () + Random.Float (30.0, 80.0); + reportTime = GetWorldTime () + Random.Float (30.0f, 80.0f); } String defaultSound = g_chatterFactory[type].GetRandomElement ().name; @@ -1044,10 +1044,10 @@ void Bot::ChatterMessage (int message) bool shouldExecute = false; - if (m_voiceTimers[message] < GetWorldTime () || m_voiceTimers[message] == 99999.0f) + if (m_chatterTimes[message] < GetWorldTime () || m_chatterTimes[message] == 99999.0f) { - if (m_voiceTimers[message] != 99999.0f) - m_voiceTimers[message] = GetWorldTime () + g_chatterFactory[message][0].repeatTime; + if (m_chatterTimes[message] != 99999.0f) + m_chatterTimes[message] = GetWorldTime () + g_chatterFactory[message][0].repeatTime; shouldExecute = true; } @@ -1142,12 +1142,12 @@ void Bot::CheckMessageQueue (void) case GSM_RADIO: // general radio message issued // if last bot radio command (global) happened just a second ago, delay response - if (g_lastRadioTime[m_team] + 1.0 < GetWorldTime ()) + if (g_lastRadioTime[m_team] + 1.0f < GetWorldTime ()) { // if same message like previous just do a yes/no if (m_radioSelect != Radio_Affirmative && m_radioSelect != Radio_Negative) { - if (m_radioSelect == g_lastRadio[m_team] && g_lastRadioTime[m_team] + 1.5 > GetWorldTime ()) + if (m_radioSelect == g_lastRadio[m_team] && g_lastRadioTime[m_team] + 1.5f > GetWorldTime ()) m_radioSelect = -1; else { @@ -1386,7 +1386,7 @@ int Bot::PickBestFromRandom (int *random, int count) if (buyFactor < 1.0f) buyFactor = 1.0f; - return random[static_cast (static_cast (count - 1) * log10f (Random.Float (1, powf (10, buyFactor))) / buyFactor + 0.5f)]; + return random[static_cast (static_cast (count - 1) * log10f (Random.Float (1, powf (10.0f, buyFactor))) / buyFactor + 0.5f)]; } void Bot::PurchaseWeapons (void) @@ -1874,13 +1874,13 @@ void Bot::SetConditions (void) { if (!IsAlive (m_lastEnemy) && m_shootAtDeadTime < GetWorldTime ()) { - m_lastEnemyOrigin = nullvec; + m_lastEnemyOrigin.Zero (); m_lastEnemy = NULL; } } else { - m_lastEnemyOrigin = nullvec; + m_lastEnemyOrigin.Zero (); m_lastEnemy = NULL; } @@ -1893,7 +1893,7 @@ void Bot::SetConditions (void) else if (m_heardSoundTime < GetWorldTime ()) m_states &= ~STATE_HEARING_ENEMY; - if (IsEntityNull (m_enemy) && !IsEntityNull (m_lastEnemy) && m_lastEnemyOrigin != nullvec) + if (IsEntityNull (m_enemy) && !IsEntityNull (m_lastEnemy) && !m_lastEnemyOrigin.IsZero ()) { m_aimFlags |= AIM_PREDICT_PATH; @@ -1922,17 +1922,17 @@ void Bot::ApplyTaskFilters (void) // decrease fear if teammates near int friendlyNum = 0; - if (m_lastEnemyOrigin != nullvec) - friendlyNum = GetNearbyFriendsNearPosition (pev->origin, 500) - GetNearbyEnemiesNearPosition (m_lastEnemyOrigin, 500); + if (!m_lastEnemyOrigin.IsZero ()) + friendlyNum = GetNearbyFriendsNearPosition (pev->origin, 500.0f) - GetNearbyEnemiesNearPosition (m_lastEnemyOrigin, 500.0f); if (friendlyNum > 0) - tempFear = tempFear * 0.5; + tempFear = tempFear * 0.5f; // increase/decrease fear/aggression if bot uses a sniping weapon to be more careful if (UsesSniper ()) { - tempFear = tempFear * 1.5; - tempAgression = tempAgression * 0.5; + tempFear = tempFear * 1.5f; + tempAgression = tempAgression * 0.5f; } // bot found some item to use? @@ -1941,13 +1941,13 @@ void Bot::ApplyTaskFilters (void) m_states |= STATE_PICKUP_ITEM; if (m_pickupType == PICKUP_BUTTON) - g_taskFilters[TASK_PICKUPITEM].desire = 50; // always pickup button + g_taskFilters[TASK_PICKUPITEM].desire = 50.0f; // always pickup button else { - float distance = (500.0 - (GetEntityOrigin (m_pickupItem) - pev->origin).GetLength ()) * 0.2; + float distance = (500.0f - (GetEntityOrigin (m_pickupItem) - pev->origin).GetLength ()) * 0.2f; - if (distance > 50) - distance = 50; + if (distance > 50.0f) + distance = 50.0f; g_taskFilters[TASK_PICKUPITEM].desire = distance; } @@ -1955,73 +1955,73 @@ void Bot::ApplyTaskFilters (void) else { m_states &= ~STATE_PICKUP_ITEM; - g_taskFilters[TASK_PICKUPITEM].desire = 0.0; + g_taskFilters[TASK_PICKUPITEM].desire = 0.0f; } // calculate desire to attack if ((m_states & STATE_SEEING_ENEMY) && ReactOnEnemy ()) g_taskFilters[TASK_ATTACK].desire = TASKPRI_ATTACK; else - g_taskFilters[TASK_ATTACK].desire = 0; + g_taskFilters[TASK_ATTACK].desire = 0.0f; // calculate desires to seek cover or hunt - if (IsValidPlayer (m_lastEnemy) && m_lastEnemyOrigin != nullvec) + if (IsValidPlayer (m_lastEnemy) && !m_lastEnemyOrigin.IsZero ()) { float distance = (m_lastEnemyOrigin - pev->origin).GetLength (); // retreat level depends on bot health - float retreatLevel = (100.0 - (pev->health > 100.0 ? 100.0 : pev->health)) * tempFear; + float retreatLevel = (100.0f - (pev->health > 100.0f ? 100.0f : pev->health)) * tempFear; float timeSeen = m_seeEnemyTime - GetWorldTime (); float timeHeard = m_heardSoundTime - GetWorldTime (); - float ratio = 0.0; + float ratio = 0.0f; if (timeSeen > timeHeard) { - timeSeen += 10.0; - ratio = timeSeen * 0.1; + timeSeen += 10.0f; + ratio = timeSeen * 0.1f; } else { - timeHeard += 10.0; - ratio = timeHeard * 0.1; + timeHeard += 10.0f; + ratio = timeHeard * 0.1f; } if (g_bombPlanted || m_isStuck) - ratio /= 3; // reduce the seek cover desire if bomb is planted + ratio /= 3.0f; // reduce the seek cover desire if bomb is planted else if (m_isVIP || m_isReloading) - ratio *= 3; // triple the seek cover desire if bot is VIP or reloading + ratio *= 3.0f; // triple the seek cover desire if bot is VIP or reloading - if (distance > 500.0) + if (distance > 500.0f) g_taskFilters[TASK_SEEKCOVER].desire = retreatLevel * ratio; // if half of the round is over, allow hunting // FIXME: it probably should be also team/map dependant if (GetTaskId () != TASK_ESCAPEFROMBOMB && IsEntityNull (m_enemy) && g_timeRoundMid < GetWorldTime () && !m_isUsingGrenade && m_currentWaypointIndex != waypoints.FindNearest (m_lastEnemyOrigin) && m_personality != PERSONALITY_CAREFUL) { - float desireLevel = 4096.0 - ((1.0 - tempAgression) * distance); + float desireLevel = 4096.0f - ((1.0f - tempAgression) * distance); - desireLevel = (100 * desireLevel) / 4096.0; + desireLevel = (100.0f * desireLevel) / 4096.0; desireLevel -= retreatLevel; - if (desireLevel > 89) - desireLevel = 89; + if (desireLevel > 89.0f) + desireLevel = 89.0f; g_taskFilters[TASK_HUNTENEMY].desire = desireLevel; } else - g_taskFilters[TASK_HUNTENEMY].desire = 0; + g_taskFilters[TASK_HUNTENEMY].desire = 0.0f; } else { - g_taskFilters[TASK_SEEKCOVER].desire = 0; - g_taskFilters[TASK_HUNTENEMY].desire = 0; + g_taskFilters[TASK_SEEKCOVER].desire = 0.0f; + g_taskFilters[TASK_HUNTENEMY].desire = 0.0f; } // blinded behavior if (m_blindTime > GetWorldTime ()) g_taskFilters[TASK_BLINDED].desire = TASKPRI_BLINDED; else - g_taskFilters[TASK_BLINDED].desire = 0.0; + g_taskFilters[TASK_BLINDED].desire = 0.0f; // now we've initialized all the desires go through the hard work // of filtering all actions against each other to pick the most @@ -2035,17 +2035,17 @@ void Bot::ApplyTaskFilters (void) // utility i wrote so there could still be some weird behaviors, it's // hard to check them all out. - m_oldCombatDesire = HysteresisDesire (g_taskFilters[TASK_ATTACK].desire, 40.0, 90.0, m_oldCombatDesire); + m_oldCombatDesire = HysteresisDesire (g_taskFilters[TASK_ATTACK].desire, 40.0f, 90.0f, m_oldCombatDesire); g_taskFilters[TASK_ATTACK].desire = m_oldCombatDesire; TaskItem *taskOffensive = &g_taskFilters[TASK_ATTACK]; TaskItem *taskPickup = &g_taskFilters[TASK_PICKUPITEM]; // calc survive (cover/hide) - TaskItem *taskSurvive = ThresholdDesire (&g_taskFilters[TASK_SEEKCOVER], 40.0, 0.0); + TaskItem *taskSurvive = ThresholdDesire (&g_taskFilters[TASK_SEEKCOVER], 40.0f, 0.0f); taskSurvive = SubsumeDesire (&g_taskFilters[TASK_HIDE], taskSurvive); - TaskItem *def = ThresholdDesire (&g_taskFilters[TASK_HUNTENEMY], 41.0, 0.0); // don't allow hunting if desires 60< + TaskItem *def = ThresholdDesire (&g_taskFilters[TASK_HUNTENEMY], 41.0f, 0.0f); // don't allow hunting if desires 60< taskOffensive = SubsumeDesire (taskOffensive, taskPickup); // if offensive task, don't allow picking up stuff TaskItem *taskSub = MaxDesire (taskOffensive, def); // default normal & careful tasks against offensive actions @@ -2140,7 +2140,7 @@ TaskItem *Bot::GetTask (void) task.id = TASK_NORMAL; task.desire = TASKPRI_NORMAL; task.data = -1; - task.time = 0.0; + task.time = 0.0f; task.resume = true; m_tasks.Push (task); @@ -2220,12 +2220,12 @@ bool Bot::ReactOnEnemy (void) float lineDist = (m_enemy->v.origin - pev->origin).GetLength (); float pathDist = waypoints.GetPathDistance (i, enemyIndex); - if (pathDist - lineDist > 112.0) + if (pathDist - lineDist > 112.0f) m_isEnemyReachable = false; else m_isEnemyReachable = true; - m_enemyReachableTimer = GetWorldTime () + 1.0; + m_enemyReachableTimer = GetWorldTime () + 1.0f; } if (m_isEnemyReachable) @@ -2239,10 +2239,10 @@ bool Bot::ReactOnEnemy (void) bool Bot::LastEnemyShootable (void) { // don't allow shooting through walls - if (!(m_aimFlags & AIM_LAST_ENEMY) || m_lastEnemyOrigin == nullvec || IsEntityNull (m_lastEnemy)) + if (!(m_aimFlags & AIM_LAST_ENEMY) || !m_lastEnemyOrigin.IsZero () || IsEntityNull (m_lastEnemy)) return false; - return GetShootingConeDeviation (GetEntity (), &m_lastEnemyOrigin) >= 0.90 && IsShootableThruObstacle (m_lastEnemyOrigin); + return GetShootingConeDeviation (GetEntity (), &m_lastEnemyOrigin) >= 0.90f && IsShootableThruObstacle (m_lastEnemyOrigin); } void Bot::CheckRadioCommands (void) @@ -2303,11 +2303,11 @@ void Bot::CheckRadioCommands (void) if (taskID == TASK_PAUSE || taskID == TASK_CAMP) GetTask ()->time = GetWorldTime (); - PushTask (TASK_FOLLOWUSER, TASKPRI_FOLLOWUSER, -1, 0.0, true); + PushTask (TASK_FOLLOWUSER, TASKPRI_FOLLOWUSER, -1, 0.0f, true); } else if (numFollowers > allowedFollowers) { - for (int i = 0; (i < GetMaxClients () && numFollowers > allowedFollowers) ; i++) + for (int i = 0; (i < GetMaxClients () && numFollowers > allowedFollowers); i++) { Bot *bot = bots.GetBot (i); @@ -2342,7 +2342,7 @@ void Bot::CheckRadioCommands (void) m_campButtons = 0; - PushTask (TASK_PAUSE, TASKPRI_PAUSE, -1, GetWorldTime () + Random.Float (30.0, 60.0), false); + PushTask (TASK_PAUSE, TASKPRI_PAUSE, -1, GetWorldTime () + Random.Float (30.0f, 60.0f), false); } } break; @@ -2354,13 +2354,13 @@ void Bot::CheckRadioCommands (void) case Radio_TakingFire: if (IsEntityNull (m_targetEntity)) { - if (IsEntityNull (m_enemy) && m_seeEnemyTime + 4.0 < GetWorldTime ()) + if (IsEntityNull (m_enemy) && m_seeEnemyTime + 4.0f < GetWorldTime ()) { // decrease fear levels to lower probability of bot seeking cover again - m_fearLevel -= 0.2; + m_fearLevel -= 0.2f; - if (m_fearLevel < 0.0) - m_fearLevel = 0.0; + if (m_fearLevel < 0.0f) + m_fearLevel = 0.0f; if (Random.Long (0, 100) < 45 && yb_communication_type.GetInt () == 2) ChatterMessage (Chatter_OnMyWay); @@ -2383,12 +2383,12 @@ void Bot::CheckRadioCommands (void) case Radio_NeedBackup: case Chatter_ScaredEmotion: case Chatter_Pinned_Down: - if (((IsEntityNull (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 2048 || !m_moveToC4) && Random.Long (0, 100) > 50 && m_seeEnemyTime + 4.0 < GetWorldTime ()) + if (((IsEntityNull (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 2048.0f || !m_moveToC4) && Random.Long (0, 100) > 50 && m_seeEnemyTime + 4.0f < GetWorldTime ()) { - m_fearLevel -= 0.1; + m_fearLevel -= 0.1f; - if (m_fearLevel < 0.0) - m_fearLevel = 0.0; + if (m_fearLevel < 0.0f) + m_fearLevel = 0.0f; if (Random.Long (0, 100) < 45 && yb_communication_type.GetInt () == 2) ChatterMessage (Chatter_OnMyWay); @@ -2410,10 +2410,10 @@ void Bot::CheckRadioCommands (void) RadioMessage (Radio_Affirmative); m_targetEntity = NULL; - m_fearLevel -= 0.2; + m_fearLevel -= 0.2f; - if (m_fearLevel < 0.0) - m_fearLevel = 0.0; + if (m_fearLevel < 0.0f) + m_fearLevel = 0.0f; } else if ((IsEntityNull (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 2048) { @@ -2421,10 +2421,10 @@ void Bot::CheckRadioCommands (void) if (taskID == TASK_PAUSE || taskID == TASK_CAMP) { - m_fearLevel -= 0.2; + m_fearLevel -= 0.2f; - if (m_fearLevel < 0.0) - m_fearLevel = 0.0; + if (m_fearLevel < 0.0f) + m_fearLevel = 0.0f; RadioMessage (Radio_Affirmative); // don't pause/camp anymore @@ -2433,10 +2433,10 @@ void Bot::CheckRadioCommands (void) m_targetEntity = NULL; MakeVectors (m_radioEntity->v.v_angle); - m_position = m_radioEntity->v.origin + g_pGlobals->v_forward * Random.Long (1024, 2048); + m_position = m_radioEntity->v.origin + g_pGlobals->v_forward * Random.Float (1024.0f, 2048.0f); DeleteSearchNodes (); - PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, -1, 0.0, true); + PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, -1, 0.0f, true); } } else if (!IsEntityNull (m_doubleJumpEntity)) @@ -2450,7 +2450,7 @@ void Bot::CheckRadioCommands (void) break; case Radio_ShesGonnaBlow: - if (IsEntityNull (m_enemy) && distance < 2048 && g_bombPlanted && m_team == TEAM_TF) + if (IsEntityNull (m_enemy) && distance < 2048.0f && g_bombPlanted && m_team == TEAM_TF) { RadioMessage (Radio_Affirmative); @@ -2458,7 +2458,7 @@ void Bot::CheckRadioCommands (void) RemoveCertainTask (TASK_CAMP); m_targetEntity = NULL; - PushTask (TASK_ESCAPEFROMBOMB, TASKPRI_ESCAPEFROMBOMB, -1, 0.0, true); + PushTask (TASK_ESCAPEFROMBOMB, TASKPRI_ESCAPEFROMBOMB, -1, 0.0f, true); } else RadioMessage (Radio_Negative); @@ -2479,7 +2479,7 @@ void Bot::CheckRadioCommands (void) break; case Radio_StormTheFront: - if (((IsEntityNull (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 1024) && Random.Long (0, 100) > 50) + if (((IsEntityNull (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 1024.0f) && Random.Long (0, 100) > 50) { RadioMessage (Radio_Affirmative); @@ -2492,38 +2492,38 @@ void Bot::CheckRadioCommands (void) m_targetEntity = NULL; MakeVectors (m_radioEntity->v.v_angle); - m_position = m_radioEntity->v.origin + g_pGlobals->v_forward * Random.Long (1024, 2048); + m_position = m_radioEntity->v.origin + g_pGlobals->v_forward * Random.Float (1024.0f, 2048.0f); DeleteSearchNodes (); - PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, -1, 0.0, true); + PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, -1, 0.0f, true); - m_fearLevel -= 0.3; + m_fearLevel -= 0.3f; - if (m_fearLevel < 0.0) - m_fearLevel = 0.0; + if (m_fearLevel < 0.0f) + m_fearLevel = 0.0f; - m_agressionLevel += 0.3; + m_agressionLevel += 0.3f; - if (m_agressionLevel > 1.0) - m_agressionLevel = 1.0; + if (m_agressionLevel > 1.0f) + m_agressionLevel = 1.0f; } break; case Radio_Fallback: - if ((IsEntityNull (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 1024) + if ((IsEntityNull (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 1024.0f) { - m_fearLevel += 0.5; + m_fearLevel += 0.5f; - if (m_fearLevel > 1.0) - m_fearLevel = 1.0; + if (m_fearLevel > 1.0f) + m_fearLevel = 1.0f; - m_agressionLevel -= 0.5; + m_agressionLevel -= 0.5f; - if (m_agressionLevel < 0.0) - m_agressionLevel = 0.0; + if (m_agressionLevel < 0.0f) + m_agressionLevel = 0.0f; if (GetTaskId () == TASK_CAMP) - GetTask ()->time += Random.Float (10.0, 15.0); + GetTask ()->time += Random.Float (10.0f, 15.0f); else { // don't pause/camp anymore @@ -2536,7 +2536,7 @@ void Bot::CheckRadioCommands (void) m_seeEnemyTime = GetWorldTime (); // if bot has no enemy - if (m_lastEnemyOrigin == nullvec) + if (m_lastEnemyOrigin.IsZero ()) { float nearestDistance = 99999.0f; @@ -2564,7 +2564,7 @@ void Bot::CheckRadioCommands (void) case Radio_ReportTeam: if (Random.Long (0, 100) < 30) - RadioMessage ((GetNearbyEnemiesNearPosition (pev->origin, 400) == 0 && yb_communication_type.GetInt () != 2) ? Radio_SectorClear : Radio_ReportingIn); + RadioMessage ((GetNearbyEnemiesNearPosition (pev->origin, 400.0f) == 0 && yb_communication_type.GetInt () != 2) ? Radio_SectorClear : Radio_ReportingIn); break; case Radio_SectorClear: @@ -2608,19 +2608,19 @@ void Bot::CheckRadioCommands (void) } waypoints.SetGoalVisited (bombPoint); } - g_timeNextBombUpdate = GetWorldTime () + 0.5; + g_timeNextBombUpdate = GetWorldTime () + 0.5f; } } } break; case Radio_GetInPosition: - if ((IsEntityNull (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 1024) + if ((IsEntityNull (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 1024.0f) { RadioMessage (Radio_Affirmative); if (GetTaskId () == TASK_CAMP) - GetTask ()->time = GetWorldTime () + Random.Float (30.0, 60.0); + GetTask ()->time = GetWorldTime () + Random.Float (30.0f, 60.0f); else { // don't pause anymore @@ -2633,7 +2633,7 @@ void Bot::CheckRadioCommands (void) m_seeEnemyTime = GetWorldTime (); // if bot has no enemy - if (m_lastEnemyOrigin == nullvec) + if (m_lastEnemyOrigin.IsZero ()) { float nearestDistance = 99999.0f; @@ -2659,9 +2659,9 @@ void Bot::CheckRadioCommands (void) int index = FindDefendWaypoint (m_radioEntity->v.origin); // push camp task on to stack - PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (30.0, 60.0), true); + PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (30.0f, 60.0f), true); // push move command - PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + Random.Float (30.0, 60.0), true); + PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + Random.Float (30.0f, 60.0f), true); if (waypoints.GetPath (index)->vis.crouch <= waypoints.GetPath (index)->vis.stand) m_campButtons |= IN_DUCK; @@ -2690,7 +2690,7 @@ void Bot::TryHeadTowardRadioEntity (void) m_position = m_radioEntity->v.origin; DeleteSearchNodes (); - PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, -1, 0.0, true); + PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, -1, 0.0f, true); } } @@ -2804,7 +2804,7 @@ void Bot::ChooseAimDirection (void) if (flags & AIM_OVERRIDE) m_lookAt = m_camp; else if (flags & AIM_GRENADE) - m_lookAt = m_throw + Vector (0, 0, 1.0 * m_grenade.z); + m_lookAt = m_throw + Vector (0.0f, 0.0f, 1.0f * m_grenade.z); else if (flags & AIM_ENEMY) FocusEnemy (); else if (flags & AIM_ENTITY) @@ -2865,7 +2865,7 @@ void Bot::ChooseAimDirection (void) } } - if (m_lookAt == nullvec) + if (m_lookAt.IsZero ()) m_lookAt = m_destOrigin; } @@ -2888,9 +2888,9 @@ void Bot::ThinkDelayed (void) pev->button = 0; pev->flags |= FL_FAKECLIENT; // restore fake client bit, if it were removed by some evil action =) - m_moveSpeed = 0.0; - m_strafeSpeed = 0.0; - m_moveAngles = nullvec; + m_moveSpeed = 0.0f; + m_strafeSpeed = 0.0f; + m_moveAngles.Zero (); m_canChooseAimDirection = true; m_notKilled = IsAlive (GetEntity ()); @@ -2928,7 +2928,7 @@ void Bot::ThinkDelayed (void) } extern ConVar yb_chat; - if (yb_chat.GetBool () && !RepliesToPlayer () && m_lastChatTime + 10.0 < GetWorldTime () && g_lastChatTime + 5.0 < GetWorldTime ()) // bot chatting turned on? + if (yb_chat.GetBool () && !RepliesToPlayer () && m_lastChatTime + 10.0 < GetWorldTime () && g_lastChatTime + 5.0f < GetWorldTime ()) // bot chatting turned on? { // say a text every now and then if (Random.Long (1, 1500) < 2) @@ -2961,7 +2961,7 @@ void Bot::ThinkDelayed (void) } } } - else if (m_notKilled && m_buyingFinished && !(pev->maxspeed < 10 && GetTaskId () != TASK_PLANTBOMB && GetTaskId () != TASK_DEFUSEBOMB) && !yb_freeze_bots.GetBool ()) + else if (m_notKilled && m_buyingFinished && !(pev->maxspeed < 10.0f && GetTaskId () != TASK_PLANTBOMB && GetTaskId () != TASK_DEFUSEBOMB) && !yb_freeze_bots.GetBool ()) botMovement = true; CheckMessageQueue (); // check for pending messages @@ -2992,10 +2992,10 @@ void Bot::PeriodicThink (void) CheckSpawnTimeConditions (); // clear enemy far away - if (m_lastEnemyOrigin != nullvec && !IsEntityNull (m_lastEnemy) && (pev->origin - m_lastEnemyOrigin).GetLength () >= 1600.0) + if (!m_lastEnemyOrigin.IsZero () && !IsEntityNull (m_lastEnemy) && (pev->origin - m_lastEnemyOrigin).GetLength () >= 1600.0f) { m_lastEnemy = NULL; - m_lastEnemyOrigin = nullvec; + m_lastEnemyOrigin.Zero (); } m_timePeriodicUpdate = GetWorldTime () + 0.5f; } @@ -3032,7 +3032,7 @@ void Bot::RunTask_Normal (void) GetTask ()->data = -1; } - if (!g_bombPlanted && m_currentWaypointIndex != -1 && (m_currentPath->flags & FLAG_GOAL) && Random.Long (0, 100) < 80 && GetNearbyEnemiesNearPosition (pev->origin, 650) == 0) + if (!g_bombPlanted && m_currentWaypointIndex != -1 && (m_currentPath->flags & FLAG_GOAL) && Random.Long (0, 100) < 80 && GetNearbyEnemiesNearPosition (pev->origin, 650.0f) == 0) RadioMessage (Radio_SectorClear); // reached the destination (goal) waypoint? @@ -3043,13 +3043,13 @@ void Bot::RunTask_Normal (void) // spray logo sometimes if allowed to do so if (m_timeLogoSpray < GetWorldTime () && yb_spraypaints.GetBool () && Random.Long (1, 100) < 60 && m_moveSpeed > GetWalkSpeed () && IsEntityNull (m_pickupItem)) - PushTask (TASK_SPRAY, TASKPRI_SPRAYLOGO, -1, GetWorldTime () + 1.0, false); + PushTask (TASK_SPRAY, TASKPRI_SPRAYLOGO, -1, GetWorldTime () + 1.0f, false); // reached waypoint is a camp waypoint if ((m_currentPath->flags & FLAG_CAMP) && !yb_csdm_mode.GetBool ()) { // check if bot has got a primary weapon and hasn't camped before - if (HasPrimaryWeapon () && m_timeCamping + 10.0 < GetWorldTime () && !HasHostage ()) + if (HasPrimaryWeapon () && m_timeCamping + 10.0f < GetWorldTime () && !HasHostage ()) { bool campingAllowed = true; @@ -3125,8 +3125,8 @@ void Bot::RunTask_Normal (void) { int index = FindDefendWaypoint (m_currentPath->origin); - PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (60.0, 120.0), true); // push camp task on to stack - PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + Random.Float (5.0, 10.0), true); // push move command + PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (60.0f, 120.0f), true); // push camp task on to stack + PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + Random.Float (5.0f, 10.0f), true); // push move command if (waypoints.GetPath (index)->vis.crouch <= waypoints.GetPath (index)->vis.stand) m_campButtons |= IN_DUCK; @@ -3141,16 +3141,16 @@ void Bot::RunTask_Normal (void) // is it a terrorist carrying the bomb? if (m_hasC4) { - if ((m_states & STATE_SEEING_ENEMY) && GetNearbyFriendsNearPosition (pev->origin, 768) == 0) + if ((m_states & STATE_SEEING_ENEMY) && GetNearbyFriendsNearPosition (pev->origin, 768.0f) == 0) { // request an help also RadioMessage (Radio_NeedBackup); InstantChatterMessage (Chatter_ScaredEmotion); - PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (4.0, 8.0), true); + PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (4.0f, 8.0f), true); } else - PushTask (TASK_PLANTBOMB, TASKPRI_PLANTBOMB, -1, 0.0, false); + PushTask (TASK_PLANTBOMB, TASKPRI_PLANTBOMB, -1, 0.0f, false); } else if (m_team == TEAM_CF) { @@ -3202,11 +3202,11 @@ void Bot::RunTask_Normal (void) m_moveSpeed = m_minSpeed; } - if ((yb_walking_allowed.GetBool () && mp_footsteps.GetBool ()) && m_difficulty >= 2 && !(m_aimFlags & AIM_ENEMY) && (m_heardSoundTime + 13.0 >= GetWorldTime () || (m_states & (STATE_HEARING_ENEMY | STATE_SUSPECT_ENEMY))) && GetNearbyEnemiesNearPosition (pev->origin, 1024) >= 1 && !yb_jasonmode.GetBool () && !g_bombPlanted) + if ((yb_walking_allowed.GetBool () && mp_footsteps.GetBool ()) && m_difficulty >= 2 && !(m_aimFlags & AIM_ENEMY) && (m_heardSoundTime + 13.0f >= GetWorldTime () || (m_states & (STATE_HEARING_ENEMY | STATE_SUSPECT_ENEMY))) && GetNearbyEnemiesNearPosition (pev->origin, 1024.0f) >= 1 && !yb_jasonmode.GetBool () && !g_bombPlanted) m_moveSpeed = GetWalkSpeed (); // bot hasn't seen anything in a long time and is asking his teammates to report in - if (m_seeEnemyTime + Random.Float (45.0f, 80.0f) < GetWorldTime () && Random.Long (0, 100) < 30 && g_timeRoundStart + 20.0 < GetWorldTime () && m_askCheckTime + Random.Float (20.0, 30.0) < GetWorldTime ()) + if (m_seeEnemyTime + Random.Float (45.0f, 80.0f) < GetWorldTime () && Random.Long (0, 100) < 30 && g_timeRoundStart + 20.0f < GetWorldTime () && m_askCheckTime + Random.Float (20.0f, 30.0f) < GetWorldTime ()) { m_askCheckTime = GetWorldTime (); RadioMessage (Radio_ReportTeam); @@ -3227,7 +3227,7 @@ void Bot::RunTask_Spray (void) TraceLine (EyePosition (), sprayOrigin, true, GetEntity (), &tr); // no wall in front? - if (tr.flFraction >= 1.0) + if (tr.flFraction > TRACE_FRACTION_EQ) sprayOrigin.z -= 128.0; m_entity = sprayOrigin; @@ -3235,12 +3235,12 @@ void Bot::RunTask_Spray (void) if (GetTask ()->time - 0.5f < GetWorldTime ()) { // emit spraycan sound - EMIT_SOUND_DYN2 (GetEntity (), CHAN_VOICE, "player/sprayer.wav", 1.0, ATTN_NORM, 0, 100); - TraceLine (EyePosition (), EyePosition () + g_pGlobals->v_forward * 128, true, GetEntity (), &tr); + EMIT_SOUND_DYN2 (GetEntity (), CHAN_VOICE, "player/sprayer.wav", 1.0, ATTN_NORM, 0, 100.0f); + TraceLine (EyePosition (), EyePosition () + g_pGlobals->v_forward * 128.0f, true, GetEntity (), &tr); // paint the actual logo decal DecalTrace (pev, &tr, m_logotypeIndex); - m_timeLogoSpray = GetWorldTime () + Random.Float (30.0, 45.0); + m_timeLogoSpray = GetWorldTime () + Random.Float (30.0f, 45.0f); } } else @@ -3269,7 +3269,7 @@ void Bot::RunTask_HuntEnemy (void) m_prevGoalIndex = -1; m_lastEnemy = NULL; - m_lastEnemyOrigin = nullvec; + m_lastEnemyOrigin.Zero (); } else if (GetTeam (m_lastEnemy) == m_team) { @@ -3284,7 +3284,7 @@ void Bot::RunTask_HuntEnemy (void) m_prevGoalIndex = -1; m_lastEnemy = NULL; - m_lastEnemyOrigin = nullvec; + m_lastEnemyOrigin.Zero (); } else if (!GoalIsValid ()) // do we need to calculate a new path? { @@ -3314,11 +3314,11 @@ void Bot::RunTask_HuntEnemy (void) { if (m_currentWaypointIndex != -1) { - if (m_currentPath->radius < 32 && !IsOnLadder () && !IsInWater () && m_seeEnemyTime + 4.0 > GetWorldTime () && m_difficulty == 0) + if (m_currentPath->radius < 32 && !IsOnLadder () && !IsInWater () && m_seeEnemyTime + 4.0f > GetWorldTime () && m_difficulty < 2) pev->button |= IN_DUCK; } - if ((m_lastEnemyOrigin - pev->origin).GetLength () < 512.0) + if ((m_lastEnemyOrigin - pev->origin).GetLength () < 512.0f) m_moveSpeed = GetWalkSpeed (); } } @@ -3342,7 +3342,7 @@ void Bot::RunTask_SeekCover (void) m_pathType = 0; // start hide task - PushTask (TASK_HIDE, TASKPRI_HIDE, -1, GetWorldTime () + Random.Float (5.0, 15.0), false); + PushTask (TASK_HIDE, TASKPRI_HIDE, -1, GetWorldTime () + Random.Float (5.0f, 15.0f), false); Vector dest = m_lastEnemyOrigin; // get a valid look direction @@ -3377,7 +3377,7 @@ void Bot::RunTask_SeekCover (void) m_currentPath->campEndY = dest.y; } - if ((m_reloadState == RELOAD_NONE) && (GetAmmoInClip () < 8) && (GetAmmo () != 0)) + if (m_reloadState == RELOAD_NONE && GetAmmoInClip () < 8 && GetAmmo () != 0) m_reloadState = RELOAD_PRIMARY; m_moveSpeed = 0.0f; @@ -3441,22 +3441,22 @@ void Bot::RunTask_Pause (void) m_checkTerrain = false; m_navTimeset = GetWorldTime (); - m_moveSpeed = 0.0; - m_strafeSpeed = 0.0; + m_moveSpeed = 0.0f; + m_strafeSpeed = 0.0f; m_aimFlags |= AIM_NAVPOINT; // is bot blinded and above average difficulty? - if (m_viewDistance < 500.0 && m_difficulty >= 2) + if (m_viewDistance < 500.0f && m_difficulty >= 2) { // go mad! - m_moveSpeed = -fabsf ((m_viewDistance - 500.0) * 0.5f); + m_moveSpeed = -fabsf ((m_viewDistance - 500.0f) * 0.5f); if (m_moveSpeed < -pev->maxspeed) m_moveSpeed = -pev->maxspeed; MakeVectors (pev->v_angle); - m_camp = EyePosition () + (g_pGlobals->v_forward * 500); + m_camp = EyePosition () + g_pGlobals->v_forward * 500.0f; m_aimFlags |= AIM_OVERRIDE; m_wantsToFire = true; @@ -3476,7 +3476,7 @@ void Bot::RunTask_Blinded (void) m_navTimeset = GetWorldTime (); // if bot remembers last enemy position - if (m_difficulty >= 2 && m_lastEnemyOrigin != nullvec && IsValidPlayer (m_lastEnemy) && !UsesSniper ()) + if (m_difficulty >= 2 && !m_lastEnemyOrigin.IsZero () && IsValidPlayer (m_lastEnemy) && !UsesSniper ()) { m_lookAt = m_lastEnemyOrigin; // face last enemy m_wantsToFire = true; // and shoot it @@ -3509,14 +3509,14 @@ void Bot::RunTask_Camp (void) m_navTimeset = GetWorldTime (); m_timeCamping = GetWorldTime (); - m_moveSpeed = 0; - m_strafeSpeed = 0.0; + m_moveSpeed = 0.0f; + m_strafeSpeed = 0.0f; GetValidWaypoint (); if (m_nextCampDirTime < GetWorldTime ()) { - m_nextCampDirTime = GetWorldTime () + Random.Float (2.0, 5.0); + m_nextCampDirTime = GetWorldTime () + Random.Float (2.0f, 5.0f); if (m_currentPath->flags & FLAG_CAMP) { @@ -3593,7 +3593,7 @@ void Bot::RunTask_Camp (void) pev->button |= m_campButtons; // stop camping if time over or gets hurt by something else than bullets - if ((GetTask ()->time < GetWorldTime ()) || (m_lastDamageType > 0)) + if (GetTask ()->time < GetWorldTime () || m_lastDamageType > 0) TaskComplete (); } @@ -3608,8 +3608,8 @@ void Bot::RunTask_Hide (void) m_idealReactionTime *= 0.5f; m_navTimeset = GetWorldTime (); - m_moveSpeed = 0; - m_strafeSpeed = 0.0; + m_moveSpeed = 0.0f; + m_strafeSpeed = 0.0f; GetValidWaypoint (); @@ -3637,7 +3637,7 @@ void Bot::RunTask_Hide (void) return; } } - else if (m_lastEnemyOrigin == nullvec) // If we don't have an enemy we're also free to leave + else if (m_lastEnemyOrigin.IsZero ()) // If we don't have an enemy we're also free to leave { TaskComplete (); @@ -3670,7 +3670,7 @@ void Bot::RunTask_MoveToPos (void) TaskComplete (); // we're done m_prevGoalIndex = -1; - m_position = nullvec; + m_position.Zero (); } else if (!GoalIsValid ()) // didn't choose goal waypoint yet? { @@ -3734,9 +3734,9 @@ void Bot::RunTask_PlantBomb (void) float bombTimer = mp_c4timer.GetFloat (); // push camp task on to stack - PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + (bombTimer * 0.5 + bombTimer * 0.25), true); + PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + (bombTimer * 0.5f + bombTimer * 0.25f), true); // push move command - PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + (bombTimer * 0.5 + bombTimer * 0.25), true); + PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, index, GetWorldTime () + (bombTimer * 0.5f + bombTimer * 0.25f), true); if (waypoints.GetPath (index)->vis.crouch <= waypoints.GetPath (index)->vis.stand) m_campButtons |= IN_DUCK; @@ -3747,7 +3747,7 @@ void Bot::RunTask_PlantBomb (void) void Bot::RunTask_DefuseBomb (void) { - float fullDefuseTime = m_hasDefuser ? 6.0 : 11.0; + float fullDefuseTime = m_hasDefuser ? 6.0f : 11.0f; float timeToBlowUp = GetBombTimeleft (); float defuseRemainingTime = fullDefuseTime; @@ -3757,7 +3757,7 @@ void Bot::RunTask_DefuseBomb (void) bool defuseError = false; // exception: bomb has been defused - if (waypoints.GetBombPosition () == nullvec) + if (waypoints.GetBombPosition ().IsZero ()) { defuseError = true; g_bombPlanted = false; @@ -3779,7 +3779,7 @@ void Bot::RunTask_DefuseBomb (void) defuseError = true; else if (m_states & STATE_SEEING_ENEMY) // exception: saw/seeing enemy { - if (GetNearbyFriendsNearPosition (pev->origin, 128) == 0) + if (GetNearbyFriendsNearPosition (pev->origin, 128.0f) == 0) { if (defuseRemainingTime > 0.75f) { @@ -3789,14 +3789,14 @@ void Bot::RunTask_DefuseBomb (void) defuseError = true; } } - else if (timeToBlowUp > fullDefuseTime + 3.0 && defuseRemainingTime > 1.0) + else if (timeToBlowUp > fullDefuseTime + 3.0f && defuseRemainingTime > 1.0f) defuseError = true; } else if (m_states & STATE_SUSPECT_ENEMY) // exception: suspect enemy { - if (GetNearbyFriendsNearPosition (pev->origin, 128) == 0) + if (GetNearbyFriendsNearPosition (pev->origin, 128.0f) == 0) { - if (timeToBlowUp > fullDefuseTime + 10.0) + if (timeToBlowUp > fullDefuseTime + 10.0f) { if (GetNearbyFriendsNearPosition (pev->origin, 512.0f) > 0) RadioMessage (Radio_NeedBackup); @@ -3812,8 +3812,8 @@ void Bot::RunTask_DefuseBomb (void) m_checkTerrain = true; m_moveToGoal = true; - m_destOrigin = nullvec; - m_entity = nullvec; + m_destOrigin.Zero (); + m_entity.Zero (); m_pickupItem = NULL; m_pickupType = PICKUP_NONE; @@ -3827,12 +3827,12 @@ void Bot::RunTask_DefuseBomb (void) m_checkTerrain = true; m_moveSpeed = pev->maxspeed; - m_strafeSpeed = 0.0; + m_strafeSpeed = 0.0f; // bot is reloading and we close enough to start defusing - if (m_isReloading && (waypoints.GetBombPosition () - pev->origin).GetLength2D () < 80.0) + if (m_isReloading && (waypoints.GetBombPosition () - pev->origin).GetLength2D () < 80.0f) { - if (m_numEnemiesLeft == 0 || timeToBlowUp < fullDefuseTime + 7.0 || ((GetAmmoInClip () > 8 && m_reloadState == RELOAD_PRIMARY) || (GetAmmoInClip () > 5 && m_reloadState == RELOAD_SECONDARY))) + if (m_numEnemiesLeft == 0 || timeToBlowUp < fullDefuseTime + 7.0f || ((GetAmmoInClip () > 8 && m_reloadState == RELOAD_PRIMARY) || (GetAmmoInClip () > 5 && m_reloadState == RELOAD_SECONDARY))) { int weaponIndex = GetHighestWeapon (); @@ -3849,8 +3849,8 @@ void Bot::RunTask_DefuseBomb (void) m_moveToGoal = false; m_checkTerrain = false; - m_moveSpeed = 0.0; - m_strafeSpeed = 0.0; + m_moveSpeed = 0.0f; + m_strafeSpeed = 0.0f; } } @@ -3873,25 +3873,25 @@ void Bot::RunTask_DefuseBomb (void) if (pev->button & IN_DUCK) { botDuckOrigin = pev->origin; - botStandOrigin = pev->origin + Vector (0, 0, 18); + botStandOrigin = pev->origin + Vector (0.0f, 0.0f, 18.0f); } else { - botDuckOrigin = pev->origin - Vector (0, 0, 18); + botDuckOrigin = pev->origin - Vector (0.0f, 0.0f, 18.0f); botStandOrigin = pev->origin; } float duckLength = (m_entity - botDuckOrigin).GetLengthSquared (); float standLength = (m_entity - botStandOrigin).GetLengthSquared (); - if (duckLength > 5625 || standLength > 5625) + if (duckLength > 5625.0f || standLength > 5625.0f) { if (standLength < duckLength) m_duckDefuse = false; // stand else m_duckDefuse = true; // duck } - m_duckDefuseCheckTime = GetWorldTime () + 1.5; + m_duckDefuseCheckTime = GetWorldTime () + 1.5f; } // press duck button @@ -3912,8 +3912,8 @@ void Bot::RunTask_DefuseBomb (void) m_moveToGoal = false; m_checkTerrain = false; - m_moveSpeed = 0.0; - m_strafeSpeed = 0.0; + m_moveSpeed = 0.0f; + m_strafeSpeed = 0.0f; // notify team if (m_numFriendsLeft != 0) @@ -3941,7 +3941,7 @@ void Bot::RunTask_FollowUser (void) MakeVectors (m_targetEntity->v.v_angle); TraceResult tr; - TraceLine (m_targetEntity->v.origin + m_targetEntity->v.view_ofs, g_pGlobals->v_forward * 500, true, true, GetEntity (), &tr); + TraceLine (m_targetEntity->v.origin + m_targetEntity->v.view_ofs, g_pGlobals->v_forward * 500.0f, true, true, GetEntity (), &tr); if (!IsEntityNull (tr.pHit) && IsValidPlayer (tr.pHit) && GetTeam (tr.pHit) != m_team) { @@ -3961,16 +3961,16 @@ void Bot::RunTask_FollowUser (void) m_reloadState = RELOAD_PRIMARY; if ((m_targetEntity->v.origin - pev->origin).GetLength () > 130) - m_followWaitTime = 0.0; + m_followWaitTime = 0.0f; else { - m_moveSpeed = 0.0; + m_moveSpeed = 0.0f; - if (m_followWaitTime == 0.0) + if (m_followWaitTime == 0.0f) m_followWaitTime = GetWorldTime (); else { - if (m_followWaitTime + 3.0 < GetWorldTime ()) + if (m_followWaitTime + 3.0f < GetWorldTime ()) { // stop following if we have been waiting too long m_targetEntity = NULL; @@ -4000,14 +4000,14 @@ void Bot::RunTask_FollowUser (void) int destIndex = waypoints.FindNearest (m_targetEntity->v.origin); Array points; - waypoints.FindInRadius (points, 200, m_targetEntity->v.origin); + waypoints.FindInRadius (points, 200.0f, m_targetEntity->v.origin); while (!points.IsEmpty ()) { int newIndex = points.Pop (); // if waypoint not yet used, assign it as dest - if (!IsPointOccupied (newIndex) && (newIndex != m_currentWaypointIndex)) + if (!IsPointOccupied (newIndex) && newIndex != m_currentWaypointIndex) destIndex = newIndex; } @@ -4039,7 +4039,7 @@ void Bot::RunTask_Throw_HE (void) m_moveToGoal = false; } else if (!(m_states & STATE_SUSPECT_ENEMY) && !IsEntityNull (m_enemy)) - dest = m_enemy->v.origin + (m_enemy->v.velocity.Get2D () * 0.5); + dest = m_enemy->v.origin + m_enemy->v.velocity.Get2D () * 0.5f; m_isUsingGrenade = true; m_checkTerrain = false; @@ -4058,10 +4058,10 @@ void Bot::RunTask_Throw_HE (void) } m_grenade = CheckThrow (EyePosition (), dest); - if (m_grenade.GetLengthSquared () < 100) + if (m_grenade.GetLengthSquared () < 100.0f) m_grenade = CheckToss (EyePosition (), dest); - if (m_grenade.GetLengthSquared () <= 100) + if (m_grenade.GetLengthSquared () <= 100.0f) { m_grenadeCheckTime = GetWorldTime () + MAX_GRENADE_TIMER; m_grenade = m_lookAt; @@ -4078,7 +4078,7 @@ void Bot::RunTask_Throw_HE (void) if (ent->v.owner == GetEntity () && strcmp (STRING (ent->v.model) + 9, "hegrenade.mdl") == 0) { // set the correct velocity for the grenade - if (m_grenade.GetLengthSquared () > 100) + if (m_grenade.GetLengthSquared () > 100.0f) ent->v.velocity = m_grenade; m_grenadeCheckTime = GetWorldTime () + MAX_GRENADE_TIMER; @@ -4115,7 +4115,7 @@ void Bot::RunTask_Throw_FL (void) m_moveSpeed = 0.0f; } else if (!(m_states & STATE_SUSPECT_ENEMY) && !IsEntityNull (m_enemy)) - dest = m_enemy->v.origin + (m_enemy->v.velocity.Get2D () * 0.5); + dest = m_enemy->v.origin + m_enemy->v.velocity.Get2D () * 0.5; m_isUsingGrenade = true; m_checkTerrain = false; @@ -4124,10 +4124,10 @@ void Bot::RunTask_Throw_FL (void) m_grenade = CheckThrow (EyePosition (), dest); - if (m_grenade.GetLengthSquared () < 100) + if (m_grenade.GetLengthSquared () < 100.0f) m_grenade = CheckToss (pev->origin, dest); - if (m_grenade.GetLengthSquared () <= 100) + if (m_grenade.GetLengthSquared () <= 100.0f) { m_grenadeCheckTime = GetWorldTime () + MAX_GRENADE_TIMER; m_grenade = m_lookAt; @@ -4143,7 +4143,7 @@ void Bot::RunTask_Throw_FL (void) if (ent->v.owner == GetEntity () && strcmp (STRING (ent->v.model) + 9, "flashbang.mdl") == 0) { // set the correct velocity for the grenade - if (m_grenade.GetLengthSquared () > 100) + if (m_grenade.GetLengthSquared () > 100.0f) ent->v.velocity = m_grenade; m_grenadeCheckTime = GetWorldTime () + MAX_GRENADE_TIMER; @@ -4187,11 +4187,11 @@ void Bot::RunTask_Throw_SG (void) // predict where the enemy is in 0.5 secs if (!IsEntityNull (m_enemy)) - src = src + m_enemy->v.velocity * 0.5; + src = src + m_enemy->v.velocity * 0.5f; m_grenade = (src - EyePosition ()).Normalize (); - if (GetTask ()->time < GetWorldTime () + 0.5) + if (GetTask ()->time < GetWorldTime () + 0.5f) { m_aimFlags &= ~AIM_GRENADE; m_states &= ~STATE_THROW_SG; @@ -4208,7 +4208,7 @@ void Bot::RunTask_Throw_SG (void) GetTask ()->time = GetWorldTime () + MAX_GRENADE_TIMER; } else - GetTask ()->time = GetWorldTime () + 0.1; + GetTask ()->time = GetWorldTime () + 0.1f; } else if (!(pev->oldbuttons & IN_ATTACK)) pev->button |= IN_ATTACK; @@ -4229,25 +4229,25 @@ void Bot::RunTask_DoubleJump (void) m_checkTerrain = false; m_navTimeset = GetWorldTime (); - m_moveSpeed = 0.0; - m_strafeSpeed = 0.0; + m_moveSpeed = 0.0f; + m_strafeSpeed = 0.0f; if (m_duckForJump < GetWorldTime ()) pev->button |= IN_DUCK; - MakeVectors (nullvec); + MakeVectors (Vector::GetZero ()); - Vector dest = EyePosition () + g_pGlobals->v_forward * 500; - dest.z = 180.0; + Vector dest = EyePosition () + g_pGlobals->v_forward * 500.0f; + dest.z = 180.0f; TraceResult tr; TraceLine (EyePosition (), dest, false, true, GetEntity (), &tr); - if ((tr.flFraction < 1.0) && (tr.pHit == m_doubleJumpEntity)) + if (tr.flFraction <= TRACE_FRACTION_EQ && tr.pHit == m_doubleJumpEntity) { if (m_doubleJumpEntity->v.button & IN_JUMP) { - m_duckForJump = GetWorldTime () + Random.Float (3.0, 5.0); + m_duckForJump = GetWorldTime () + Random.Float (3.0f, 5.0f); GetTask ()->time = GetWorldTime (); } } @@ -4304,11 +4304,11 @@ void Bot::RunTask_EscapeFromBomb (void) TaskComplete (); // we're done // press duck button if we still have some enemies - if (GetNearbyEnemiesNearPosition (pev->origin, 2048)) + if (GetNearbyEnemiesNearPosition (pev->origin, 2048.0f)) m_campButtons = IN_DUCK; // we're reached destination point so just sit down and camp - PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + 10.0, true); + PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + 10.0f, true); } else if (!GoalIsValid ()) // didn't choose goal waypoint yet? { @@ -4361,10 +4361,10 @@ void Bot::RunTask_ShootBreakable (void) m_camp = src; // is bot facing the breakable? - if (GetShootingConeDeviation (GetEntity (), &src) >= 0.90) + if (GetShootingConeDeviation (GetEntity (), &src) >= 0.90f) { - m_moveSpeed = 0.0; - m_strafeSpeed = 0.0; + m_moveSpeed = 0.0f; + m_strafeSpeed = 0.0f; if (m_currentWeapon == WEAPON_KNIFE) SelectBestWeapon (); @@ -4403,7 +4403,7 @@ void Bot::RunTask_PickupItem () m_aimFlags |= AIM_NAVPOINT; // near to weapon? - if (itemDistance < 50) + if (itemDistance < 50.0f) { for (id = 0; id < 7; id++) { @@ -4456,7 +4456,7 @@ void Bot::RunTask_PickupItem () m_pickupItem = NULL; break; } - else if (itemDistance < 50) // near to shield? + else if (itemDistance < 50.0f) // near to shield? { // get current best weapon to check if it's a primary in need to be dropped int weaponID = GetHighestWeapon (); @@ -4486,7 +4486,7 @@ void Bot::RunTask_PickupItem () m_moveSpeed = 0; m_strafeSpeed = 0; - PushTask (TASK_DEFUSEBOMB, TASKPRI_DEFUSEBOMB, -1, 0.0, false); + PushTask (TASK_DEFUSEBOMB, TASKPRI_DEFUSEBOMB, -1, 0.0f, false); } break; @@ -4502,11 +4502,11 @@ void Bot::RunTask_PickupItem () break; } - if (itemDistance < 50) + if (itemDistance < 50.0f) { float angleToEntity = InFieldOfView (dest - EyePosition ()); - if (angleToEntity <= 10) // bot faces hostage? + if (angleToEntity <= 10.0f) // bot faces hostage? { // use game dll function to make sure the hostage is correctly 'used' MDLL_Use (m_pickupItem, GetEntity ()); @@ -4553,20 +4553,20 @@ void Bot::RunTask_PickupItem () // find angles from bot origin to entity... float angleToEntity = InFieldOfView (dest - EyePosition ()); - if (itemDistance < 90) // near to the button? + if (itemDistance < 90.0f) // near to the button? { - m_moveSpeed = 0.0; - m_strafeSpeed = 0.0; + m_moveSpeed = 0.0f; + m_strafeSpeed = 0.0f; m_moveToGoal = false; m_checkTerrain = false; - if (angleToEntity <= 10) // facing it directly? + if (angleToEntity <= 10.0f) // facing it directly? { MDLL_Use (m_pickupItem, GetEntity ()); m_pickupItem = NULL; m_pickupType = PICKUP_NONE; - m_buttonPushTime = GetWorldTime () + 3.0; + m_buttonPushTime = GetWorldTime () + 3.0f; TaskComplete (); } @@ -4690,10 +4690,10 @@ void Bot::CheckSpawnTimeConditions (void) // this function is called instead of BotAI when buying finished, but freezetime is not yet left. // switch to knife if time to do this - if (m_checkKnifeSwitch && !m_checkWeaponSwitch && m_buyingFinished && m_spawnTime + Random.Float (4.0, 6.5) < GetWorldTime ()) + if (m_checkKnifeSwitch && !m_checkWeaponSwitch && m_buyingFinished && m_spawnTime + Random.Float (4.0f, 6.5f) < GetWorldTime ()) { if (Random.Long (1, 100) < 2 && yb_spraypaints.GetBool ()) - PushTask (TASK_SPRAY, TASKPRI_SPRAYLOGO, -1, GetWorldTime () + 1.0, false); + PushTask (TASK_SPRAY, TASKPRI_SPRAYLOGO, -1, GetWorldTime () + 1.0f, false); if (m_difficulty >= 2 && Random.Long (0, 100) < (m_personality == PERSONALITY_RUSHER ? 99 : 50) && !m_isReloading && (g_mapType & (MAP_CS | MAP_DE | MAP_ES | MAP_AS))) { @@ -4712,7 +4712,7 @@ void Bot::CheckSpawnTimeConditions (void) } // check if we already switched weapon mode - if (m_checkWeaponSwitch && m_buyingFinished && m_spawnTime + Random.Float (2.0, 3.5) < GetWorldTime ()) + if (m_checkWeaponSwitch && m_buyingFinished && m_spawnTime + Random.Float (2.0f, 3.5f) < GetWorldTime ()) { if (HasShield () && IsShieldDrawn ()) pev->button |= IN_ATTACK2; @@ -4747,19 +4747,19 @@ void Bot::BotAI (void) TraceResult tr; // increase reaction time - m_actualReactionTime += 0.3; + m_actualReactionTime += 0.3f; if (m_actualReactionTime > m_idealReactionTime) m_actualReactionTime = m_idealReactionTime; // bot could be blinded by flashbang or smoke, recover from it - m_viewDistance += 3.0; + m_viewDistance += 3.0f; if (m_viewDistance > m_maxViewDistance) m_viewDistance = m_maxViewDistance; if (m_blindTime > GetWorldTime ()) - m_maxViewDistance = 4096.0; + m_maxViewDistance = 4096.0f; m_moveSpeed = pev->maxspeed; @@ -4770,10 +4770,10 @@ void Bot::BotAI (void) // save current position as previous m_prevOrigin = pev->origin; - m_prevTime = GetWorldTime () + 0.2; + m_prevTime = GetWorldTime () + 0.2f; } else - movedDistance = 2.0; + movedDistance = 2.0f; // if there's some radio message to respond, check it if (m_radioOrder != 0) @@ -4795,7 +4795,7 @@ void Bot::BotAI (void) else if (!hasFriendNearby && Random.Long (0, 100) < 45 && m_team == TEAM_TF && IsPlayerVIP (m_enemy)) ChatterMessage (Chatter_VIPSpotted); - else if (!hasFriendNearby && Random.Long (0, 100) < 50 && GetTeam (m_enemy) != m_team && IsGroupOfEnemies (m_enemy->v.origin, 2, 384)) + else if (!hasFriendNearby && Random.Long (0, 100) < 50 && GetTeam (m_enemy) != m_team && IsGroupOfEnemies (m_enemy->v.origin, 2, 384.0f)) ChatterMessage (Chatter_ScaredEmotion); else if (!hasFriendNearby && Random.Long (0, 100) < 40 && ((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)))) @@ -4844,7 +4844,7 @@ void Bot::BotAI (void) m_moveAngles = dirOld.ToAngles (); m_moveAngles.ClampAngles (); - m_moveAngles.x *= -1.0; // invert for engine + m_moveAngles.x *= -1.0f; // invert for engine if (m_difficulty > 3 && ((m_aimFlags & AIM_ENEMY) || (m_states & (STATE_SEEING_ENEMY | STATE_SUSPECT_ENEMY)) || (GetTaskId () == TASK_SEEKCOVER && (m_isReloading || m_isVIP))) && !yb_jasonmode.GetBool () && GetTaskId () != TASK_CAMP && !IsOnLadder ()) { @@ -4861,7 +4861,7 @@ void Bot::BotAI (void) TaskComplete (); // complete current task // then start escape from bomb immidiate - PushTask (TASK_ESCAPEFROMBOMB, TASKPRI_ESCAPEFROMBOMB, -1, 0.0, true); + PushTask (TASK_ESCAPEFROMBOMB, TASKPRI_ESCAPEFROMBOMB, -1, 0.0f, true); } // allowed to move to a destination position? @@ -4878,14 +4878,14 @@ void Bot::BotAI (void) if (IsInWater ()) // special movement for swimming here { // check if we need to go forward or back press the correct buttons - if (InFieldOfView (m_destOrigin - EyePosition ()) > 90) + if (InFieldOfView (m_destOrigin - EyePosition ()) > 90.0f) pev->button |= IN_BACK; else pev->button |= IN_FORWARD; - if (m_moveAngles.x > 60.0) + if (m_moveAngles.x > 60.0f) pev->button |= IN_DUCK; - else if (m_moveAngles.x < -60.0) + else if (m_moveAngles.x < -60.0f) pev->button |= IN_JUMP; } } @@ -4914,7 +4914,7 @@ void Bot::BotAI (void) m_pickupItem = NULL; m_breakableEntity = NULL; - m_itemCheckTime = GetWorldTime () + 5.0; + m_itemCheckTime = GetWorldTime () + 5.0f; m_pickupType = PICKUP_NONE; } @@ -4924,7 +4924,7 @@ void Bot::BotAI (void) if (pev->button & IN_JUMP) m_jumpTime = GetWorldTime (); - if (m_jumpTime + 0.85 > GetWorldTime ()) + if (m_jumpTime + 0.85f > GetWorldTime ()) { if (!IsOnFloor () && !IsInWater ()) pev->button |= IN_DUCK; @@ -4932,17 +4932,17 @@ void Bot::BotAI (void) if (!(pev->button & (IN_FORWARD | IN_BACK))) { - if (m_moveSpeed > 0) + if (m_moveSpeed > 0.0f) pev->button |= IN_FORWARD; - else if (m_moveSpeed < 0) + else if (m_moveSpeed < 0.0f) pev->button |= IN_BACK; } if (!(pev->button & (IN_MOVELEFT | IN_MOVERIGHT))) { - if (m_strafeSpeed > 0) + if (m_strafeSpeed > 0.0f) pev->button |= IN_MOVERIGHT; - else if (m_strafeSpeed < 0) + else if (m_strafeSpeed < 0.0f) pev->button |= IN_MOVELEFT; } @@ -4952,7 +4952,7 @@ void Bot::BotAI (void) if (specIndex == IndexOfEntity (GetEntity ())) { - static float timeDebugUpdate = 0.0; + static float timeDebugUpdate = 0.0f; static int index, goal, taskID; if (!m_tasks.IsEmpty ()) @@ -5162,10 +5162,10 @@ void Bot::BotAI (void) DrawArrow (g_hostEntity, EyePosition (), m_destOrigin, 10, 0, 0, 255, 0, 250, 5, 1); MakeVectors (m_idealAngles); - DrawArrow (g_hostEntity, EyePosition (), EyePosition () + (g_pGlobals->v_forward * 300), 10, 0, 0, 0, 255, 250, 5, 1); + DrawArrow (g_hostEntity, EyePosition (), EyePosition () + g_pGlobals->v_forward * 300.0f, 10, 0, 0, 0, 255, 250, 5, 1); MakeVectors (pev->v_angle); - DrawArrow (g_hostEntity, EyePosition (), EyePosition () + (g_pGlobals->v_forward * 300), 10, 0, 255, 0, 0, 250, 5, 1); + DrawArrow (g_hostEntity, EyePosition (), EyePosition () + g_pGlobals->v_forward * 300.0f, 10, 0, 255, 0, 0, 250, 5, 1); // now draw line from source to destination PathNode *node = &m_navNode[0]; @@ -5200,7 +5200,7 @@ bool Bot::HasHostage (void) if (!IsEntityNull (m_hostages[i])) { // don't care about dead hostages - if (m_hostages[i]->v.health <= 0 || (pev->origin - m_hostages[i]->v.origin).GetLength () > 600) + if (m_hostages[i]->v.health <= 0.0f || (pev->origin - m_hostages[i]->v.origin).GetLength () > 600.0f) { m_hostages[i] = NULL; continue; @@ -5247,19 +5247,19 @@ void Bot::TakeDamage (edict_t *inflictor, int damage, int armor, int bits) else { // attacked by an enemy - if (pev->health > 60) + if (pev->health > 60.0f) { - m_agressionLevel += 0.1; + m_agressionLevel += 0.1f; - if (m_agressionLevel > 1.0) - m_agressionLevel += 1.0; + if (m_agressionLevel > 1.0f) + m_agressionLevel += 1.0f; } else { - m_fearLevel += 0.03; + m_fearLevel += 0.03f; - if (m_fearLevel > 1.0) - m_fearLevel += 1.0; + if (m_fearLevel > 1.0f) + m_fearLevel += 1.0f; } RemoveCertainTask (TASK_CAMP); @@ -5293,24 +5293,24 @@ void Bot::TakeBlinded (const Vector &fade, int alpha) // it's used to make bot blind froumd the grenade. - if (fade.x != 255 || fade.y != 255 || fade.z != 255 || alpha <= 170) + if (fade.x != 255.0f || fade.y != 255.0f || fade.z != 255.0f || alpha <= 170.0f) return; m_enemy = NULL; - m_maxViewDistance = Random.Float (10, 20); - m_blindTime = GetWorldTime () + static_cast (alpha - 200) / 16; + m_maxViewDistance = Random.Float (10.0f, 20.0f); + m_blindTime = GetWorldTime () + static_cast (alpha - 200.0f) / 16.0f; if (m_difficulty <= 2) { - m_blindMoveSpeed = 0.0; - m_blindSidemoveSpeed = 0.0; + m_blindMoveSpeed = 0.0f; + m_blindSidemoveSpeed = 0.0f; m_blindButton = IN_DUCK; } else if (m_difficulty > 2) { m_blindMoveSpeed = -pev->maxspeed; - m_blindSidemoveSpeed = 0.0; + m_blindSidemoveSpeed = 0.0f; float walkSpeed = GetWalkSpeed (); @@ -5319,11 +5319,11 @@ void Bot::TakeBlinded (const Vector &fade, int alpha) else m_blindSidemoveSpeed = -walkSpeed; - if (pev->health < 85) + if (pev->health < 85.0f) m_blindMoveSpeed = -walkSpeed; else if (m_personality == PERSONALITY_CAREFUL) { - m_blindMoveSpeed = 0.0; + m_blindMoveSpeed = 0.0f; m_blindButton = IN_DUCK; } else @@ -5397,7 +5397,7 @@ void Bot::CollectExperienceData (edict_t *attacker, int damage) int attackerIndex = waypoints.FindNearest (attacker->v.origin); int victimIndex = waypoints.FindNearest (pev->origin); - if (pev->health > 20) + if (pev->health > 20.0f) { if (victimTeam == TEAM_TF) (g_experienceData + (victimIndex * g_numWaypoints) + victimIndex)->team0Damage++; @@ -5411,7 +5411,7 @@ void Bot::CollectExperienceData (edict_t *attacker, int damage) (g_experienceData + (victimIndex * g_numWaypoints) + victimIndex)->team1Damage = MAX_DAMAGE_VALUE; } - float updateDamage = IsValidBot (attacker) ? 10.0 : 7.0; + float updateDamage = IsValidBot (attacker) ? 10.0f : 7.0f; // store away the damage done if (victimTeam == TEAM_TF) @@ -5493,7 +5493,7 @@ void Bot::DiscardWeaponForUser (edict_t *user, bool discardC4) // this function, asks bot to discard his current primary weapon (or c4) to the user that requsted it with /drop* // command, very useful, when i'm don't have money to buy anything... ) - if (IsAlive (user) && m_moneyAmount >= 2000 && HasPrimaryWeapon () && (user->v.origin - pev->origin).GetLength () <= 240) + if (IsAlive (user) && m_moneyAmount >= 2000 && HasPrimaryWeapon () && (user->v.origin - pev->origin).GetLength () <= 240.0f) { m_aimFlags |= AIM_ENTITY; m_lookAt = user->v.origin; @@ -5511,7 +5511,7 @@ void Bot::DiscardWeaponForUser (edict_t *user, bool discardC4) m_pickupItem = NULL; m_pickupType = PICKUP_NONE; - m_itemCheckTime = GetWorldTime () + 5.0; + m_itemCheckTime = GetWorldTime () + 5.0f; if (m_inBuyZone) { @@ -5529,8 +5529,8 @@ void Bot::ResetDoubleJumpState (void) TaskComplete (); m_doubleJumpEntity = NULL; - m_duckForJump = 0.0; - m_doubleJumpOrigin = nullvec; + m_duckForJump = 0.0f; + m_doubleJumpOrigin.Zero (); m_travelStartIndex = -1; m_jumpReady = false; } @@ -5564,31 +5564,31 @@ Vector Bot::CheckToss(const Vector &start, const Vector &stop) // returns null vector if toss is not feasible. TraceResult tr; - float gravity = sv_gravity.GetFloat () * 0.55; + float gravity = sv_gravity.GetFloat () * 0.55f; Vector end = stop - pev->velocity; - end.z -= 15.0; + end.z -= 15.0f; - if (fabsf (end.z - start.z) > 500.0) - return nullvec; + if (fabsf (end.z - start.z) > 500.0f) + return Vector::GetZero (); - Vector midPoint = start + (end - start) * 0.5; - TraceHull (midPoint, midPoint + Vector (0, 0, 500), true, head_hull, ENT (pev), &tr); + Vector midPoint = start + (end - start) * 0.5f; + TraceHull (midPoint, midPoint + Vector (0.0f, 0.0f, 500.0f), true, head_hull, ENT (pev), &tr); - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) { midPoint = tr.vecEndPos; - midPoint.z = tr.pHit->v.absmin.z - 1.0; + midPoint.z = tr.pHit->v.absmin.z - 1.0f; } if ((midPoint.z < start.z) || (midPoint.z < end.z)) - return nullvec; + return Vector::GetZero (); - float timeOne = sqrtf ((midPoint.z - start.z) / (0.5 * gravity)); - float timeTwo = sqrtf ((midPoint.z - end.z) / (0.5 * gravity)); + float timeOne = sqrtf ((midPoint.z - start.z) / (0.5f * gravity)); + float timeTwo = sqrtf ((midPoint.z - end.z) / (0.5f * gravity)); - if (timeOne < 0.1) - return nullvec; + if (timeOne < 0.1f) + return Vector::GetZero (); Vector nadeVelocity = (end - start) / (timeOne + timeTwo); nadeVelocity.z = gravity * timeOne; @@ -5598,19 +5598,19 @@ Vector Bot::CheckToss(const Vector &start, const Vector &stop) TraceHull (start, apex, false, head_hull, ENT (pev), &tr); - if (tr.flFraction < 1.0 || tr.fAllSolid) - return nullvec; + if (tr.flFraction <= TRACE_FRACTION_EQ || tr.fAllSolid) + return Vector::GetZero (); TraceHull (end, apex, true, head_hull, ENT (pev), &tr); - if (tr.flFraction != 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) { float dot = -(tr.vecPlaneNormal | (apex - end).Normalize ()); - if (dot > 0.7 || tr.flFraction < 0.8) // 60 degrees - return nullvec; + if (dot > 0.7f || tr.flFraction < 0.8f) // 60 degrees + return Vector::GetZero (); } - return nadeVelocity * 0.777; + return nadeVelocity * 0.777f; } Vector Bot::CheckThrow(const Vector &start, const Vector &stop) @@ -5621,35 +5621,35 @@ Vector Bot::CheckThrow(const Vector &start, const Vector &stop) Vector nadeVelocity = (stop - start); TraceResult tr; - float gravity = sv_gravity.GetFloat () * 0.55; - float time = nadeVelocity.GetLength () / 195.0; + float gravity = sv_gravity.GetFloat () * 0.55f; + float time = nadeVelocity.GetLength () / 195.0f; - if (time < 0.01) - return nullvec; - else if (time > 2.0) - time = 1.2; + if (time < 0.01f) + return Vector::GetZero (); + else if (time > 2.0f) + time = 1.2f; - nadeVelocity = nadeVelocity * (1.0 / time); - nadeVelocity.z += gravity * time * 0.5; + nadeVelocity = nadeVelocity * (1.0f / time); + nadeVelocity.z += gravity * time * 0.5f; - Vector apex = start + (stop - start) * 0.5; - apex.z += 0.5 * gravity * (time * 0.5) * (time * 0.5); + Vector apex = start + (stop - start) * 0.5f; + apex.z += 0.5f * gravity * (time * 0.5f) * (time * 0.5f); TraceHull (start, apex, false, head_hull, GetEntity (), &tr); - if (tr.flFraction != 1.0) - return nullvec; + if (tr.flFraction <= TRACE_FRACTION_EQ) + return Vector::GetZero (); TraceHull (stop, apex, true, head_hull, GetEntity (), &tr); - if (tr.flFraction != 1.0 || tr.fAllSolid) + if (tr.flFraction <= TRACE_FRACTION_EQ || tr.fAllSolid) { float dot = -(tr.vecPlaneNormal | (apex - stop).Normalize ()); - if (dot > 0.7 || tr.flFraction < 0.8) - return nullvec; + if (dot > 0.7f || tr.flFraction < 0.8f) + return Vector::GetZero (); } - return nadeVelocity * 0.7793; + return nadeVelocity * 0.7793f; } Vector Bot::CheckBombAudible (void) @@ -5657,36 +5657,36 @@ Vector Bot::CheckBombAudible (void) // this function checks if bomb is can be heard by the bot, calculations done by manual testing. if (!g_bombPlanted || (GetTaskId () == TASK_ESCAPEFROMBOMB)) - return nullvec; // reliability check + return Vector::GetZero (); // reliability check if (m_difficulty >= 3) return waypoints.GetBombPosition(); const Vector &bombOrigin = waypoints.GetBombPosition (); - float timeElapsed = ((GetWorldTime () - g_timeBombPlanted) / mp_c4timer.GetFloat ()) * 100; - float desiredRadius = 768.0; + float timeElapsed = ((GetWorldTime () - g_timeBombPlanted) / mp_c4timer.GetFloat ()) * 100.0f; + float desiredRadius = 768.0f; // start the manual calculations - if (timeElapsed > 85.0) - desiredRadius = 4096.0; - else if (timeElapsed > 68.0) - desiredRadius = 2048.0; - else if (timeElapsed > 52.0) - desiredRadius = 1280.0; - else if (timeElapsed > 28.0) - desiredRadius = 1024.0; + if (timeElapsed > 85.0f) + desiredRadius = 4096.0f; + else if (timeElapsed > 68.0f) + desiredRadius = 2048.0f; + else if (timeElapsed > 52.0f) + desiredRadius = 1280.0f; + else if (timeElapsed > 28.0f) + desiredRadius = 1024.0f; // we hear bomb if length greater than radius if (desiredRadius < (pev->origin - bombOrigin).GetLength2D ()) return bombOrigin; - return nullvec; + return Vector::GetZero (); } void Bot::MoveToVector (const Vector &to) { - if (to == nullvec) + if (to.IsZero ()) return; FindPath (m_currentWaypointIndex, waypoints.FindNearest (to), 0); @@ -5736,15 +5736,15 @@ void Bot::CheckBurstMode (float distance) return; // no checking when shiled is active // if current weapon is glock, disable burstmode on long distances, enable it else - if (m_currentWeapon == WEAPON_GLOCK && distance < 300.0 && m_weaponBurstMode == BM_OFF) + if (m_currentWeapon == WEAPON_GLOCK && distance < 300.0f && m_weaponBurstMode == BM_OFF) pev->button |= IN_ATTACK2; - else if (m_currentWeapon == WEAPON_GLOCK && distance >= 300 && m_weaponBurstMode == BM_ON) + else if (m_currentWeapon == WEAPON_GLOCK && distance >= 300.0f && m_weaponBurstMode == BM_ON) pev->button |= IN_ATTACK2; // if current weapon is famas, disable burstmode on short distances, enable it else - if (m_currentWeapon == WEAPON_FAMAS && distance > 400.0 && m_weaponBurstMode == BM_OFF) + if (m_currentWeapon == WEAPON_FAMAS && distance > 400.0f && m_weaponBurstMode == BM_OFF) pev->button |= IN_ATTACK2; - else if (m_currentWeapon == WEAPON_FAMAS && distance <= 400 && m_weaponBurstMode == BM_ON) + else if (m_currentWeapon == WEAPON_FAMAS && distance <= 400.0f && m_weaponBurstMode == BM_ON) pev->button |= IN_ATTACK2; } @@ -5771,12 +5771,12 @@ void Bot::CheckSilencer (void) float Bot::GetBombTimeleft (void) { if (!g_bombPlanted) - return 0.0; + return 0.0f; float timeLeft = ((g_timeBombPlanted + mp_c4timer.GetFloat ()) - GetWorldTime ()); - if (timeLeft < 0.0) - return 0.0; + if (timeLeft < 0.0f) + return 0.0f; return timeLeft; } @@ -5824,13 +5824,13 @@ bool Bot::OutOfBombTimer (void) float timeLeft = GetBombTimeleft (); // if time left greater than 13, no need to do other checks - if (timeLeft > 16) + if (timeLeft > 16.0f) return false; const Vector &bombOrigin = waypoints.GetBombPosition (); // for terrorist, if timer is lower than eleven seconds, return true - if (static_cast (timeLeft) < 16 && m_team == TEAM_TF && (bombOrigin - pev->origin).GetLength () < 1000) + if (static_cast (timeLeft) < 16 && m_team == TEAM_TF && (bombOrigin - pev->origin).GetLength () < 1000.0f) return true; bool hasTeammatesWithDefuserKit = false; @@ -5841,7 +5841,7 @@ bool Bot::OutOfBombTimer (void) Bot *bot = NULL; // temporaly pointer to bot // search players with defuse kit - if ((bot = bots.GetBot (i)) != NULL && GetTeam (bot->GetEntity ()) == TEAM_CF && bot->m_hasDefuser && (bombOrigin - bot->pev->origin).GetLength () < 500) + if ((bot = bots.GetBot (i)) != NULL && GetTeam (bot->GetEntity ()) == TEAM_CF && bot->m_hasDefuser && (bombOrigin - bot->pev->origin).GetLength () < 500.0f) { hasTeammatesWithDefuserKit = true; break; @@ -5852,10 +5852,10 @@ bool Bot::OutOfBombTimer (void) float reachTime = waypoints.GetTravelTime (pev->maxspeed, m_currentPath->origin, bombOrigin); // for counter-terrorist check alos is we have time to reach position plus average defuse time - if ((timeLeft < reachTime + 6 && !m_hasDefuser && !hasTeammatesWithDefuserKit) || (timeLeft < reachTime + 2 && m_hasDefuser)) + if ((timeLeft < reachTime + 6.0f && !m_hasDefuser && !hasTeammatesWithDefuserKit) || (timeLeft < reachTime + 2.0f && m_hasDefuser)) return true; - if (m_hasProgressBar && IsOnFloor () && ((m_hasDefuser ? 10.0 : 15.0) > GetBombTimeleft ())) + if (m_hasProgressBar && IsOnFloor () && ((m_hasDefuser ? 10.0f : 15.0f) > GetBombTimeleft ())) return true; return false; // return false otherwise @@ -5909,14 +5909,14 @@ void Bot::ReactOnSound (void) if (m_shootTime < GetWorldTime () - 5.0f && IsOnFloor () && m_currentWeapon != WEAPON_C4 && m_currentWeapon != WEAPON_EXPLOSIVE && m_currentWeapon != WEAPON_SMOKE && m_currentWeapon != WEAPON_FLASHBANG && !yb_jasonmode.GetBool ()) SelectBestWeapon (); - m_heardSoundTime = GetWorldTime () + 5.0; + m_heardSoundTime = GetWorldTime () + 5.0f; m_states |= STATE_HEARING_ENEMY; - if ((Random.Long (0, 100) < 15) && IsEntityNull (m_enemy) && IsEntityNull (m_lastEnemy) && m_seeEnemyTime + 7.0 < GetWorldTime ()) + if ((Random.Long (0, 100) < 15) && IsEntityNull (m_enemy) && IsEntityNull (m_lastEnemy) && m_seeEnemyTime + 7.0f < GetWorldTime ()) ChatterMessage (Chatter_HeardEnemy); // didn't bot already have an enemy ? take this one... - if (m_lastEnemyOrigin == nullvec || m_lastEnemy == NULL) + if (m_lastEnemyOrigin.IsZero () || m_lastEnemy == NULL) { m_lastEnemy = player; m_lastEnemyOrigin = player->v.origin; @@ -5936,7 +5936,7 @@ void Bot::ReactOnSound (void) // if bot had an enemy but the heard one is nearer, take it instead float distance = (m_lastEnemyOrigin - pev->origin).GetLengthSquared (); - if (distance > (player->v.origin - pev->origin).GetLengthSquared () && m_seeEnemyTime + 2.0 < GetWorldTime ()) + if (distance > (player->v.origin - pev->origin).GetLengthSquared () && m_seeEnemyTime + 2.0f < GetWorldTime ()) { m_lastEnemy = player; m_lastEnemyOrigin = player->v.origin; @@ -5957,7 +5957,7 @@ void Bot::ReactOnSound (void) m_states |= STATE_SEEING_ENEMY; m_seeEnemyTime = GetWorldTime (); } - else if (m_lastEnemyOrigin != nullvec && m_lastEnemy == player && m_seeEnemyTime + 3.0f > GetWorldTime () && yb_shoots_thru_walls.GetBool () && IsShootableThruObstacle (m_lastEnemyOrigin)) + else if (!m_lastEnemyOrigin.IsZero () && m_lastEnemy == player && m_seeEnemyTime + 3.0f > GetWorldTime () && yb_shoots_thru_walls.GetBool () && IsShootableThruObstacle (m_lastEnemyOrigin)) { m_states |= STATE_SEEING_ENEMY; m_seeEnemyTime = GetWorldTime (); @@ -5970,7 +5970,7 @@ bool Bot::IsShootableBreakable (edict_t *ent) // this function is checking that pointed by ent pointer obstacle, can be destroyed. if (FClassnameIs (ent, "func_breakable") || (FClassnameIs (ent, "func_pushable") && (ent->v.spawnflags & SF_PUSH_BREAKABLE))) - return (ent->v.takedamage != DAMAGE_NO) && ent->v.impulse <= 0 && !(ent->v.flags & FL_WORLDBRUSH) && !(ent->v.spawnflags & SF_BREAK_TRIGGER_ONLY) && ent->v.health < 500; + return (ent->v.takedamage != DAMAGE_NO) && ent->v.impulse <= 0 && !(ent->v.flags & FL_WORLDBRUSH) && !(ent->v.spawnflags & SF_BREAK_TRIGGER_ONLY) && ent->v.health < 500.0f; return false; } @@ -5985,7 +5985,7 @@ void Bot::EquipInBuyzone (int buyCount) checkBuyTime = (g_timeRoundStart + Random.Float (10.0f, 20.0f) + mp_buytime.GetFloat () < GetWorldTime ()); // if bot is in buy zone, try to buy ammo for this weapon... - if (m_lastEquipTime + 15.0 < GetWorldTime () && m_inBuyZone && checkBuyTime && !g_bombPlanted && m_moneyAmount > g_botBuyEconomyTable[0]) + if (m_lastEquipTime + 15.0f < GetWorldTime () && m_inBuyZone && checkBuyTime && !g_bombPlanted && m_moneyAmount > g_botBuyEconomyTable[0]) { m_buyingFinished = false; m_buyState = buyCount; diff --git a/source/chatlib.cpp b/source/chatlib.cpp index f35a189..9720c12 100644 --- a/source/chatlib.cpp +++ b/source/chatlib.cpp @@ -32,7 +32,7 @@ void StripTags (char *buffer) fieldStop = strstr (buffer, tagClose[index]) - buffer; // look for a tag stop // have we found a tag stop? - if ((fieldStop > fieldStart) && (fieldStop < 32)) + if (fieldStop > fieldStart && fieldStop < 32) { int tagLength = strlen (tagClose[index]); @@ -224,7 +224,7 @@ void Bot::PrepareChatMessage (char *text) for (i = 0; i < GetMaxClients (); i++) { - if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || (g_clients[i].team != m_team) || (g_clients[i].ent == GetEntity ())) + if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || g_clients[i].team != m_team || g_clients[i].ent == GetEntity ()) continue; break; @@ -232,7 +232,7 @@ void Bot::PrepareChatMessage (char *text) if (i < GetMaxClients ()) { - if (!IsEntityNull (pev->dmg_inflictor) && (m_team == GetTeam (pev->dmg_inflictor))) + if (!IsEntityNull (pev->dmg_inflictor) && m_team == GetTeam (pev->dmg_inflictor)) talkEntity = pev->dmg_inflictor; else talkEntity = g_clients[i].ent; @@ -243,7 +243,7 @@ void Bot::PrepareChatMessage (char *text) { for (i = 0; i < GetMaxClients (); i++) { - if (!(g_clients[i].flags & CF_USED) || (g_clients[i].team != m_team) || (g_clients[i].ent == GetEntity ())) + if (!(g_clients[i].flags & CF_USED) || g_clients[i].team != m_team || g_clients[i].ent == GetEntity ()) continue; break; @@ -263,7 +263,7 @@ void Bot::PrepareChatMessage (char *text) for (i = 0; i < GetMaxClients (); i++) { - if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || (g_clients[i].team == m_team) || (g_clients[i].ent == GetEntity ())) + if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || g_clients[i].team == m_team || g_clients[i].ent == GetEntity ()) continue; break; } @@ -277,7 +277,7 @@ void Bot::PrepareChatMessage (char *text) { for (i = 0; i < GetMaxClients (); i++) { - if (!(g_clients[i].flags & CF_USED) || (g_clients[i].team == m_team) || (g_clients[i].ent == GetEntity ())) + if (!(g_clients[i].flags & CF_USED) || g_clients[i].team == m_team || g_clients[i].ent == GetEntity ()) continue; break; } diff --git a/source/combat.cpp b/source/combat.cpp index b89b776..ee3f790 100644 --- a/source/combat.cpp +++ b/source/combat.cpp @@ -96,7 +96,7 @@ bool Bot::CheckVisibility (edict_t *target, Vector *origin, byte *bodyPart) if (IsEnemyHiddenByRendering (target)) { *bodyPart = 0; - *origin = nullvec; + origin->Zero(); return false; } @@ -109,7 +109,7 @@ bool Bot::CheckVisibility (edict_t *target, Vector *origin, byte *bodyPart) // check for the body TraceLine (botHead, target->v.origin, true, true, GetEntity (), &tr); - if (tr.flFraction >= 1.0f) + if (tr.flFraction > TRACE_FRACTION_EQ) { *bodyPart |= VISIBLE_BODY; *origin = target->v.origin; @@ -121,7 +121,7 @@ bool Bot::CheckVisibility (edict_t *target, Vector *origin, byte *bodyPart) // check for the head TraceLine (botHead, target->v.origin + target->v.view_ofs, true, true, GetEntity (), &tr); - if (tr.flFraction >= 1.0f) + if (tr.flFraction > TRACE_FRACTION_EQ) { *bodyPart |= VISIBLE_HEAD; *origin = target->v.origin + target->v.view_ofs; @@ -184,7 +184,7 @@ bool Bot::CheckVisibility (edict_t *target, Vector *origin, byte *bodyPart) TraceLine (botHead, pos, true, true, GetEntity (), &tr); // check if we hit something - if (tr.flFraction >= 1.0f) + if (tr.flFraction > TRACE_FRACTION_EQ) { *origin = tr.vecEndPos; *bodyPart |= VISIBLE_OTHER; @@ -276,14 +276,14 @@ bool Bot::LookupEnemy (void) // do some blind by smoke grenade if (m_blindRecognizeTime < GetWorldTime () && IsBehindSmokeClouds (player)) { - m_blindRecognizeTime = GetWorldTime () + Random.Float (1.0, 2.0); + m_blindRecognizeTime = GetWorldTime () + Random.Float (1.0f, 2.0f); if (Random.Long (0, 100) < 50) ChatterMessage (Chatter_BehindSmoke); } if (player->v.button & (IN_ATTACK | IN_ATTACK2)) - m_blindRecognizeTime = GetWorldTime () - 0.1; + m_blindRecognizeTime = GetWorldTime () - 0.1f; // see if bot can see the player... if (m_blindRecognizeTime < GetWorldTime () && IsEnemyViewable (player)) @@ -324,7 +324,7 @@ bool Bot::LookupEnemy (void) m_seeEnemyTime = GetWorldTime (); // zero out reaction time - m_actualReactionTime = 0.0; + m_actualReactionTime = 0.0f; m_lastEnemy = newEnemy; m_lastEnemyOrigin = newEnemy->v.origin; @@ -343,11 +343,11 @@ bool Bot::LookupEnemy (void) m_enemySurpriseTime = GetWorldTime () + m_actualReactionTime; // zero out reaction time - m_actualReactionTime = 0.0; + m_actualReactionTime = 0.0f; m_enemy = newEnemy; m_lastEnemy = newEnemy; m_lastEnemyOrigin = newEnemy->v.origin; - m_enemyReachableTimer = 0.0; + m_enemyReachableTimer = 0.0f; // keep track of when we last saw an enemy m_seeEnemyTime = GetWorldTime (); @@ -400,7 +400,7 @@ bool Bot::LookupEnemy (void) } else if (m_shootAtDeadTime > GetWorldTime ()) { - m_actualReactionTime = 0.0; + m_actualReactionTime = 0.0f; m_states |= STATE_SUSPECT_ENEMY; return true; @@ -425,19 +425,19 @@ bool Bot::LookupEnemy (void) } // check if bots should reload... - if ((m_aimFlags <= AIM_PREDICT_PATH && m_seeEnemyTime + 3.0 < GetWorldTime () && !(m_states & (STATE_SEEING_ENEMY | STATE_HEARING_ENEMY)) && IsEntityNull (m_lastEnemy) && IsEntityNull (m_enemy) && GetTaskId () != TASK_SHOOTBREAKABLE && GetTaskId () != TASK_PLANTBOMB && GetTaskId () != TASK_DEFUSEBOMB) || g_roundEnded) + if ((m_aimFlags <= AIM_PREDICT_PATH && m_seeEnemyTime + 3.0f < GetWorldTime () && !(m_states & (STATE_SEEING_ENEMY | STATE_HEARING_ENEMY)) && IsEntityNull (m_lastEnemy) && IsEntityNull (m_enemy) && GetTaskId () != TASK_SHOOTBREAKABLE && GetTaskId () != TASK_PLANTBOMB && GetTaskId () != TASK_DEFUSEBOMB) || g_roundEnded) { if (!m_reloadState) m_reloadState = RELOAD_PRIMARY; } // is the bot using a sniper rifle or a zoomable rifle? - if ((UsesSniper () || UsesZoomableRifle ()) && m_zoomCheckTime + 1.0 < GetWorldTime ()) + if ((UsesSniper () || UsesZoomableRifle ()) && m_zoomCheckTime + 1.0f < GetWorldTime ()) { - if (pev->fov < 90) // let the bot zoom out + if (pev->fov < 90.0f) // let the bot zoom out pev->button |= IN_ATTACK2; else - m_zoomCheckTime = 0.0; + m_zoomCheckTime = 0.0f; } return false; } @@ -451,7 +451,7 @@ const Vector &Bot::GetAimPosition (void) // get enemy position initially Vector targetOrigin = m_enemy->v.origin; - Vector randomize = nullvec; + Vector randomize; const Vector &adjust = Vector (Random.Float (m_enemy->v.mins.x * 0.5f, m_enemy->v.maxs.x * 0.5f), Random.Float (m_enemy->v.mins.y * 0.5f, m_enemy->v.maxs.y * 0.5f), Random.Float (m_enemy->v.mins.z * 0.5f, m_enemy->v.maxs.z * 0.5f)); @@ -490,9 +490,9 @@ const Vector &Bot::GetAimPosition (void) } m_lastEnemyOrigin = targetOrigin; } - const Vector &velocity = UsesSniper () ? nullvec : 1.0f * m_frameInterval * (m_enemy->v.velocity - pev->velocity); + const Vector &velocity = UsesSniper () ? Vector::GetZero () : 1.0f * m_frameInterval * (m_enemy->v.velocity - pev->velocity); - if (m_difficulty < 3 && randomize != nullvec) + if (m_difficulty < 3 && !randomize.IsZero ()) { float divOffs = (m_enemyOrigin - pev->origin).GetLength (); @@ -597,7 +597,7 @@ bool Bot::IsFriendInLineOfFire (float distance) edict_t *ent = g_clients[i].ent; float friendDistance = (ent->v.origin - pev->origin).GetLength (); - float squareDistance = sqrtf (1089.0 + (friendDistance * friendDistance)); + float squareDistance = sqrtf (1089.0f + (friendDistance * friendDistance)); if (GetShootingConeDeviation (GetEntity (), &ent->v.origin) > (friendDistance * friendDistance) / (squareDistance * squareDistance) && friendDistance <= distance) return true; @@ -631,7 +631,7 @@ bool Bot::IsShootableThruObstacle (const Vector &dest) const Vector &source = tr.vecEndPos; TraceLine (dest, source, true, GetEntity (), &tr); - if (tr.flFraction != 1.0f) + if (tr.flFraction <= TRACE_FRACTION_EQ) { if ((tr.vecEndPos - dest).GetLengthSquared () > GET_SQUARE (800.0f)) return false; @@ -669,7 +669,7 @@ bool Bot::IsShootableThruObstacleEx (const Vector &dest) Vector source = EyePosition (); Vector direction = (dest - source).Normalize (); // 1 unit long - Vector point = nullvec; + Vector point; int thikness = 0; int numHits = 0; @@ -677,7 +677,7 @@ bool Bot::IsShootableThruObstacleEx (const Vector &dest) TraceResult tr; TraceLine (source, dest, true, true, GetEntity (), &tr); - while (tr.flFraction != 1.0 && numHits < 3) + while (tr.flFraction <= TRACE_FRACTION_EQ && numHits < 3) { numHits++; thikness++; @@ -713,7 +713,7 @@ bool Bot::DoFirePause (float distance) if (m_firePause > GetWorldTime ()) return true; - if ((m_aimFlags & AIM_ENEMY) && m_enemyOrigin != nullvec) + if ((m_aimFlags & AIM_ENEMY) && !m_enemyOrigin.IsZero ()) { if (IsEnemyProtectedByShield (m_enemy) && GetShootingConeDeviation (GetEntity (), &m_enemyOrigin) > 0.92f) return true; @@ -725,9 +725,9 @@ bool Bot::DoFirePause (float distance) if (distance < BurstDistance) return false; else if (distance < 2 * BurstDistance) - offset = 10.0; + offset = 10.0f; else - offset = 5.0; + offset = 5.0f; const float xPunch = DegreeToRadian (pev->punchangle.x); const float yPunch = DegreeToRadian (pev->punchangle.y); @@ -751,7 +751,7 @@ void Bot::FireWeapon (void) // if using grenade stop this if (m_isUsingGrenade) { - m_shootTime = GetWorldTime () + 0.1; + m_shootTime = GetWorldTime () + 0.1f; return; } @@ -778,7 +778,7 @@ void Bot::FireWeapon (void) goto WeaponSelectEnd; // use knife if near and good difficulty (l33t dude!) - if (m_difficulty >= 3 && pev->health > 80 && !IsEntityNull (enemy) && pev->health >= enemy->v.health && distance < 100.0f && !IsOnLadder () && !IsGroupOfEnemies (pev->origin)) + if (m_difficulty >= 3 && pev->health > 80.0f && !IsEntityNull (enemy) && pev->health >= enemy->v.health && distance < 100.0f && !IsOnLadder () && !IsGroupOfEnemies (pev->origin)) goto WeaponSelectEnd; // loop through all the weapons until terminator is found... @@ -833,7 +833,7 @@ WeaponSelectEnd: if (!m_isReloading) { m_reloadState = RELOAD_NONE; - m_reloadCheckTime = GetWorldTime () + 3.0; + m_reloadCheckTime = GetWorldTime () + 3.0f; } // select this weapon if it isn't already selected @@ -842,8 +842,8 @@ WeaponSelectEnd: SelectWeaponByName (g_weaponDefs[selectId].className); // reset burst fire variables - m_firePause = 0.0; - m_timeLastFired = 0.0; + m_firePause = 0.0f; + m_timeLastFired = 0.0f; return; } @@ -867,40 +867,40 @@ WeaponSelectEnd: if (HasShield () && m_shieldCheckTime < GetWorldTime () && GetTaskId () != TASK_CAMP) // better shield gun usage { - if (distance >= 750 && !IsShieldDrawn ()) + if (distance >= 750.0f && !IsShieldDrawn ()) pev->button |= IN_ATTACK2; // draw the shield else if (IsShieldDrawn () || (!IsEntityNull (m_enemy) && (m_enemy->v.button & IN_RELOAD) || !IsEnemyViewable(m_enemy))) pev->button |= IN_ATTACK2; // draw out the shield - m_shieldCheckTime = GetWorldTime () + 1.0; + m_shieldCheckTime = GetWorldTime () + 1.0f; } if (UsesSniper () && m_zoomCheckTime < GetWorldTime ()) // is the bot holding a sniper rifle? { - if (distance > 1500 && pev->fov >= 40) // should the bot switch to the long-range zoom? + if (distance > 1500.0f && pev->fov >= 40.0f) // should the bot switch to the long-range zoom? pev->button |= IN_ATTACK2; - else if (distance > 150 && pev->fov >= 90) // else should the bot switch to the close-range zoom ? + else if (distance > 150.0f && pev->fov >= 90.0f) // else should the bot switch to the close-range zoom ? pev->button |= IN_ATTACK2; - else if (distance <= 150 && pev->fov < 90) // else should the bot restore the normal view ? + else if (distance <= 150.0f && pev->fov < 90.0f) // else should the bot restore the normal view ? pev->button |= IN_ATTACK2; m_zoomCheckTime = GetWorldTime (); - if (!IsEntityNull (m_enemy) && (pev->velocity.x != 0 || pev->velocity.y != 0 || pev->velocity.z != 0) && (pev->basevelocity.x != 0 || pev->basevelocity.y != 0 || pev->basevelocity.z != 0)) + if (!IsEntityNull (m_enemy) && (pev->velocity.x != 0.0f || pev->velocity.y != 0.0f || pev->velocity.z != 0.0f) && (pev->basevelocity.x != 0.0f || pev->basevelocity.y != 0.0f || pev->basevelocity.z != 0.0f)) { - m_moveSpeed = 0.0; - m_strafeSpeed = 0.0; + m_moveSpeed = 0.0f; + m_strafeSpeed = 0.0f; m_navTimeset = GetWorldTime (); } } else if (m_difficulty < 4 && UsesZoomableRifle () && m_zoomCheckTime < GetWorldTime ()) // else is the bot holding a zoomable rifle? { - if (distance > 800 && pev->fov >= 90) // should the bot switch to zoomed mode? + if (distance > 800.0f && pev->fov >= 90.0f) // should the bot switch to zoomed mode? pev->button |= IN_ATTACK2; - else if (distance <= 800 && pev->fov < 90) // else should the bot restore the normal view? + else if (distance <= 800.0f && pev->fov < 90.0f) // else should the bot restore the normal view? pev->button |= IN_ATTACK2; m_zoomCheckTime = GetWorldTime (); @@ -918,7 +918,7 @@ WeaponSelectEnd: } // need to care for burst fire? - if (distance < 256.0 || m_blindTime > GetWorldTime ()) + if (distance < 256.0f || m_blindTime > GetWorldTime ()) { if (selectId == WEAPON_KNIFE) { @@ -1084,7 +1084,7 @@ void Bot::CombatFight (void) if (UsesPistol() && !((m_enemy->v.weapons & WEAPON_SECONDARY) || (m_enemy->v.weapons & (1 << WEAPON_SG550))) && !g_bombPlanted) { - m_fearLevel += 0.5; + m_fearLevel += 0.5f; CheckGrenades(); CheckThrow (EyePosition(), m_throw); @@ -1102,14 +1102,14 @@ void Bot::CombatFight (void) task->id = TASK_SEEKCOVER; task->resume = true; - task->desire = TASKPRI_ATTACK + 1.0; + task->desire = TASKPRI_ATTACK + 1.0f; } else if (approach < 50) - m_moveSpeed = 0.0; + m_moveSpeed = 0.0f; else m_moveSpeed = pev->maxspeed; - if (distance < 96 && m_currentWeapon != WEAPON_KNIFE) + if (distance < 96.0f && m_currentWeapon != WEAPON_KNIFE) m_moveSpeed = -pev->maxspeed; if (UsesSniper ()) @@ -1123,9 +1123,9 @@ void Bot::CombatFight (void) { int rand = Random.Long (1, 100); - if (distance < 450) + if (distance < 450.0f) m_fightStyle = 0; - else if (distance < 1024) + else if (distance < 1024.0f) { if (rand < (UsesSubmachineGun () ? 50 : 30)) m_fightStyle = 0; @@ -1144,7 +1144,7 @@ void Bot::CombatFight (void) } else { - if (m_lastFightStyleCheck + 3.0 < GetWorldTime ()) + if (m_lastFightStyleCheck + 3.0f < GetWorldTime ()) { if (Random.Long (0, 100) < 50) m_fightStyle = 1; @@ -1173,7 +1173,7 @@ void Bot::CombatFight (void) if (Random.Long (1, 100) < 30) m_combatStrafeDir ^= 1; - m_strafeSetTime = GetWorldTime () + Random.Float (0.5, 3.0); + m_strafeSetTime = GetWorldTime () + Random.Float (0.5f, 3.0f); } if (m_combatStrafeDir == 0) @@ -1183,7 +1183,7 @@ void Bot::CombatFight (void) else { m_combatStrafeDir ^= 1; - m_strafeSetTime = GetWorldTime () + 1.0; + m_strafeSetTime = GetWorldTime () + 1.0f; } } else @@ -1193,15 +1193,15 @@ void Bot::CombatFight (void) else { m_combatStrafeDir ^= 1; - m_strafeSetTime = GetWorldTime () + 1.0; + m_strafeSetTime = GetWorldTime () + 1.0f; } } - if (m_difficulty >= 3 && (m_jumpTime + 5.0 < GetWorldTime () && IsOnFloor () && Random.Long (0, 1000) < (m_isReloading ? 8 : 2) && pev->velocity.GetLength2D () > 150.0) && !UsesSniper ()) + if (m_difficulty >= 3 && (m_jumpTime + 5.0f < GetWorldTime () && IsOnFloor () && Random.Long (0, 1000) < (m_isReloading ? 8 : 2) && pev->velocity.GetLength2D () > 150.0f) && !UsesSniper ()) pev->button |= IN_JUMP; - if (m_moveSpeed > 0.0 && distance > 100.0 && m_currentWeapon != WEAPON_KNIFE) - m_moveSpeed = 0.0; + if (m_moveSpeed > 0.0f && distance > 100.0f && m_currentWeapon != WEAPON_KNIFE) + m_moveSpeed = 0.0f; if (m_currentWeapon == WEAPON_KNIFE) m_strafeSpeed = 0.0f; @@ -1211,25 +1211,25 @@ void Bot::CombatFight (void) bool shouldDuck = true; // should duck // check the enemy height - float enemyHalfHeight = ((m_enemy->v.flags & FL_DUCKING) == FL_DUCKING ? 36.0 : 72.0) / 2; + float enemyHalfHeight = ((m_enemy->v.flags & FL_DUCKING) == FL_DUCKING ? 36.0f : 72.0f) * 0.5f; // check center/feet - if (!IsVisible (m_enemy->v.origin, GetEntity ()) && !IsVisible (m_enemy->v.origin + Vector (0, 0, -enemyHalfHeight), GetEntity ())) + if (!IsVisible (m_enemy->v.origin, GetEntity ()) && !IsVisible (m_enemy->v.origin + Vector (0.0f, 0.0f, -enemyHalfHeight), GetEntity ())) shouldDuck = false; if (shouldDuck && GetTaskId () != TASK_SEEKCOVER && GetTaskId () != TASK_HUNTENEMY && (m_visibility & VISIBLE_BODY) && !(m_visibility & VISIBLE_OTHER) && waypoints.IsDuckVisible (m_currentWaypointIndex, waypoints.FindNearest (m_enemy->v.origin))) m_duckTime = GetWorldTime () + 0.5f; - m_moveSpeed = 0.0; - m_strafeSpeed = 0.0; + m_moveSpeed = 0.0f; + m_strafeSpeed = 0.0f; m_navTimeset = GetWorldTime (); } } if (m_duckTime > GetWorldTime ()) { - m_moveSpeed = 0.0; - m_strafeSpeed = 0.0; + m_moveSpeed = 0.0f; + m_strafeSpeed = 0.0f; } if (m_moveSpeed > 0.0f && m_currentWeapon != WEAPON_KNIFE) @@ -1245,7 +1245,7 @@ void Bot::CombatFight (void) { MakeVectors (pev->v_angle); - if (IsDeadlyDrop (pev->origin + (g_pGlobals->v_forward * m_moveSpeed * 0.2) + (g_pGlobals->v_right * m_strafeSpeed * 0.2) + (pev->velocity * m_frameInterval))) + if (IsDeadlyDrop (pev->origin + (g_pGlobals->v_forward * m_moveSpeed * 0.2f) + (g_pGlobals->v_right * m_strafeSpeed * 0.2f) + (pev->velocity * m_frameInterval))) { m_strafeSpeed = -m_strafeSpeed; m_moveSpeed = -m_moveSpeed; @@ -1443,7 +1443,6 @@ void Bot::SelectBestWeapon (void) m_reloadState = RELOAD_NONE; } - void Bot::SelectPistol (void) { int oldWeapons = pev->weapons; @@ -1506,7 +1505,7 @@ void Bot::AttachToUser (void) m_targetEntity = foundUsers.GetRandomElement (); ChatterMessage (Chatter_LeadOnSir); - PushTask (TASK_FOLLOWUSER, TASKPRI_FOLLOWUSER, -1, 0.0, true); + PushTask (TASK_FOLLOWUSER, TASKPRI_FOLLOWUSER, -1, 0.0f, true); } void Bot::CommandTeam (void) @@ -1545,7 +1544,7 @@ void Bot::CommandTeam (void) else if (memberExists && yb_communication_type.GetInt () == 2) ChatterMessage(Chatter_ScaredEmotion); - m_timeTeamOrder = GetWorldTime () + Random.Float (5.0, 30.0); + m_timeTeamOrder = GetWorldTime () + Random.Float (5.0f, 30.0f); } bool Bot::IsGroupOfEnemies (const Vector &location, int numEnemies, int radius) @@ -1581,7 +1580,7 @@ void Bot::CheckReload (void) } m_isReloading = false; // update reloading status - m_reloadCheckTime = GetWorldTime () + 3.0; + m_reloadCheckTime = GetWorldTime () + 3.0f; if (m_reloadState != RELOAD_NONE) { @@ -1673,7 +1672,7 @@ void Bot::CheckReload (void) break; } - if (m_ammoInClip[weaponIndex] < maxClip * 0.8 && g_weaponDefs[weaponIndex].ammo1 != -1 && g_weaponDefs[weaponIndex].ammo1 < 32 && m_ammo[g_weaponDefs[weaponIndex].ammo1] > 0) + if (m_ammoInClip[weaponIndex] < maxClip * 0.8f && g_weaponDefs[weaponIndex].ammo1 != -1 && g_weaponDefs[weaponIndex].ammo1 < 32 && m_ammo[g_weaponDefs[weaponIndex].ammo1] > 0) { if (m_currentWeapon != weaponIndex) SelectWeaponByName (g_weaponDefs[weaponIndex].className); diff --git a/source/globals.cpp b/source/globals.cpp index ab134ce..2c136b4 100644 --- a/source/globals.cpp +++ b/source/globals.cpp @@ -26,15 +26,15 @@ bool g_autoWaypoint = false; bool g_bLearnJumpWaypoint = false; bool g_leaderChoosen[2] = {false, false}; -float g_lastChatTime = 0.0; -float g_timeRoundStart = 0.0; -float g_timeRoundEnd = 0.0; -float g_timeRoundMid = 0.0; -float g_timeNextBombUpdate = 0.0; -float g_timeBombPlanted = 0.0; -float g_timePerSecondUpdate = 0.0; -float g_lastRadioTime[2] = {0.0, 0.0}; -float g_autoPathDistance = 250.0; +float g_lastChatTime = 0.0f; +float g_timeRoundStart = 0.0f; +float g_timeRoundEnd = 0.0f; +float g_timeRoundMid = 0.0f; +float g_timeNextBombUpdate = 0.0f; +float g_timeBombPlanted = 0.0f; +float g_timePerSecondUpdate = 0.0f; +float g_lastRadioTime[2] = {0.0f, 0.0f}; +float g_autoPathDistance = 250.0f; int g_lastRadio[2]; int g_storeAddbotVars[4]; @@ -131,27 +131,27 @@ plugin_info_t Plugin_info = // table with all available actions for the bots (filtered in & out in Bot::SetConditions) some of them have subactions included TaskItem g_taskFilters[] = { - {TASK_NORMAL, 0, -1, 0.0, true}, - {TASK_PAUSE, 0, -1, 0.0, false}, - {TASK_MOVETOPOSITION, 0, -1, 0.0, true}, - {TASK_FOLLOWUSER, 0, -1,0.0, true}, - {TASK_WAITFORGO, 0, -1, 0.0, true}, - {TASK_PICKUPITEM, 0, -1, 0.0, true}, - {TASK_CAMP, 0, -1, 0.0, true}, - {TASK_PLANTBOMB, 0, -1, 0.0, false}, - {TASK_DEFUSEBOMB, 0, -1, 0.0, false}, - {TASK_ATTACK, 0, -1, 0.0, false}, - {TASK_HUNTENEMY, 0, -1, 0.0, false}, - {TASK_SEEKCOVER, 0, -1, 0.0, false}, - {TASK_THROWHEGRENADE, 0, -1, 0.0, false}, - {TASK_THROWFLASHBANG, 0, -1, 0.0, false}, - {TASK_THROWSMOKE, 0, -1, 0.0, false}, - {TASK_DOUBLEJUMP, 0, -1, 0.0, false}, - {TASK_ESCAPEFROMBOMB, 0, -1, 0.0, false}, - {TASK_SHOOTBREAKABLE, 0, -1, 0.0, false}, - {TASK_HIDE, 0, -1, 0.0, false}, - {TASK_BLINDED, 0, -1, 0.0, false}, - {TASK_SPRAY, 0, -1, 0.0, false} + {TASK_NORMAL, 0, -1, 0.0f, true}, + {TASK_PAUSE, 0, -1, 0.0f, false}, + {TASK_MOVETOPOSITION, 0, -1, 0.0f, true}, + {TASK_FOLLOWUSER, 0, -1, 0.0f, true}, + {TASK_WAITFORGO, 0, -1, 0.0f, true}, + {TASK_PICKUPITEM, 0, -1, 0.0f, true}, + {TASK_CAMP, 0, -1, 0.0f, true}, + {TASK_PLANTBOMB, 0, -1, 0.0f, false}, + {TASK_DEFUSEBOMB, 0, -1, 0.0f, false}, + {TASK_ATTACK, 0, -1, 0.0f, false}, + {TASK_HUNTENEMY, 0, -1, 0.0f, false}, + {TASK_SEEKCOVER, 0, -1, 0.0f, false}, + {TASK_THROWHEGRENADE, 0, -1, 0.0f, false}, + {TASK_THROWFLASHBANG, 0, -1, 0.0f, false}, + {TASK_THROWSMOKE, 0, -1, 0.0f, false}, + {TASK_DOUBLEJUMP, 0, -1, 0.0f, false}, + {TASK_ESCAPEFROMBOMB, 0, -1, 0.0f, false}, + {TASK_SHOOTBREAKABLE, 0, -1, 0.0f, false}, + {TASK_HIDE, 0, -1, 0.0f, false}, + {TASK_BLINDED, 0, -1, 0.0f, false}, + {TASK_SPRAY, 0, -1, 0.0f, false} }; // weapons and their specifications diff --git a/source/interface.cpp b/source/interface.cpp index fd3645b..e764b7c 100644 --- a/source/interface.cpp +++ b/source/interface.cpp @@ -452,7 +452,7 @@ void ParseVoiceEvent (const String &base, int type, float timeToRepeat) { temp[i].Trim ().TrimQuotes (); - if (GetWaveLength (temp[i]) == 0.0) + if (GetWaveLength (temp[i]) == 0.0f) continue; chatterItem.name = temp[i]; diff --git a/source/manager.cpp b/source/manager.cpp index a5579dc..d9a5221 100644 --- a/source/manager.cpp +++ b/source/manager.cpp @@ -819,10 +819,10 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c m_startAction = GSM_IDLE; m_moneyAmount = 0; - m_logotypeIndex = Random.Long (0, 5); + m_logotypeIndex = Random.Long (0, 9); // assign how talkative this bot will be - m_sayTextBuffer.chatDelay = Random.Float (3.8, 10.0); + m_sayTextBuffer.chatDelay = Random.Float (3.8f, 10.0f); m_sayTextBuffer.chatProbability = Random.Long (1, 100); m_notKilled = false; @@ -843,20 +843,20 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c { case 1: m_personality = PERSONALITY_RUSHER; - m_baseAgressionLevel = Random.Float (0.7, 1.0); - m_baseFearLevel = Random.Float (0.0, 0.4); + m_baseAgressionLevel = Random.Float (0.7f, 1.0f); + m_baseFearLevel = Random.Float (0.0f, 0.4f); break; case 2: m_personality = PERSONALITY_CAREFUL; - m_baseAgressionLevel = Random.Float (0.2, 0.5); - m_baseFearLevel = Random.Float (0.7, 1.0); + m_baseAgressionLevel = Random.Float (0.2f, 0.5f); + m_baseFearLevel = Random.Float (0.7f, 1.0f); break; default: m_personality = PERSONALITY_NORMAL; - m_baseAgressionLevel = Random.Float (0.4, 0.7); - m_baseFearLevel = Random.Float (0.4, 0.7); + m_baseAgressionLevel = Random.Float (0.4f, 0.7f); + m_baseFearLevel = Random.Float (0.4f, 0.7f); break; } @@ -869,7 +869,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c // copy them over to the temp level variables m_agressionLevel = m_baseAgressionLevel; m_fearLevel = m_baseFearLevel; - m_nextEmotionUpdate = GetWorldTime () + 0.5; + m_nextEmotionUpdate = GetWorldTime () + 0.5f; // just to be sure m_actMessageIndex = 0; @@ -962,20 +962,20 @@ void Bot::NewRound (void) // delete all allocated path nodes DeleteSearchNodes (); - m_waypointOrigin = nullvec; - m_destOrigin = nullvec; + m_waypointOrigin.Zero (); + m_destOrigin.Zero (); m_currentWaypointIndex = -1; m_currentPath = NULL; m_currentTravelFlags = 0; m_goalFailed = 0; - m_desiredVelocity = nullvec; + m_desiredVelocity.Zero (); m_prevGoalIndex = -1; m_chosenGoalIndex = -1; m_loosedBombWptIndex = -1; m_moveToC4 = false; m_duckDefuse = false; - m_duckDefuseCheckTime = 0.0; + m_duckDefuseCheckTime = 0.0f; m_numFriendsLeft = 0; m_numEnemiesLeft = 0; @@ -1011,26 +1011,26 @@ void Bot::NewRound (void) m_canChooseAimDirection = true; m_turnAwayFromFlashbang = 0.0f; - m_timeTeamOrder = 0.0; - m_askCheckTime = 0.0; - m_minSpeed = 260.0; - m_prevSpeed = 0.0; - m_prevOrigin = Vector (9999.0, 9999.0, 9999.0); + m_timeTeamOrder = 0.0f; + m_askCheckTime = 0.0f; + m_minSpeed = 260.0f; + m_prevSpeed = 0.0f; + m_prevOrigin = Vector (9999.0f, 9999.0f, 9999.0f); m_prevTime = GetWorldTime (); m_blindRecognizeTime = GetWorldTime (); m_lookUpdateTime = GetWorldTime (); - m_viewDistance = 4096.0; - m_maxViewDistance = 4096.0; + m_viewDistance = 4096.0f; + m_maxViewDistance = 4096.0f; m_liftEntity = NULL; m_pickupItem = NULL; m_itemIgnore = NULL; - m_itemCheckTime = 0.0; + m_itemCheckTime = 0.0f; m_breakableEntity = NULL; - m_breakable = nullvec; - m_timeDoorOpen = 0.0; + m_breakable.Zero (); + m_timeDoorOpen = 0.0f; ResetCollideState (); ResetDoubleJumpState (); @@ -1038,16 +1038,16 @@ void Bot::NewRound (void) m_enemy = NULL; m_lastVictim = NULL; m_lastEnemy = NULL; - m_lastEnemyOrigin = nullvec; + m_lastEnemyOrigin.Zero (); m_trackingEdict = NULL; - m_timeNextTracking = 0.0; + m_timeNextTracking = 0.0f; - m_buttonPushTime = 0.0; - m_enemyUpdateTime = 0.0; - m_seeEnemyTime = 0.0; - m_shootAtDeadTime = 0.0; - m_oldCombatDesire = 0.0; - m_liftUsageTime = 0.0; + m_buttonPushTime = 0.0f; + m_enemyUpdateTime = 0.0f; + m_seeEnemyTime = 0.0f; + m_shootAtDeadTime = 0.0f; + m_oldCombatDesire = 0.0f; + m_liftUsageTime = 0.0f; m_avoidGrenade = NULL; m_needAvoidGrenade = 0; @@ -1060,31 +1060,31 @@ void Bot::NewRound (void) m_aimFlags = 0; m_liftState = 0; - m_position = nullvec; - m_liftTravelPos = nullvec; + m_position.Zero (); + m_liftTravelPos.Zero (); SetIdealReactionTimes (true); m_targetEntity = NULL; m_tasks = NULL; - m_followWaitTime = 0.0; + m_followWaitTime = 0.0f; for (i = 0; i < MAX_HOSTAGES; i++) m_hostages[i] = NULL; for (i = 0; i < Chatter_Total; i++) - m_voiceTimers[i] = -1.0; + m_chatterTimes[i] = -1.0f; m_isReloading = false; m_reloadState = RELOAD_NONE; - m_reloadCheckTime = 0.0; + m_reloadCheckTime = 0.0f; m_shootTime = GetWorldTime (); m_playerTargetTime = GetWorldTime (); - m_firePause = 0.0; - m_timeLastFired = 0.0; + m_firePause = 0.0f; + m_timeLastFired = 0.0f; - m_grenadeCheckTime = 0.0; + m_grenadeCheckTime = 0.0f; m_isUsingGrenade = false; m_blindButton = 0; @@ -1116,12 +1116,12 @@ void Bot::NewRound (void) m_inBombZone = false; m_hasC4 = false; - m_shieldCheckTime = 0.0; - m_zoomCheckTime = 0.0; - m_strafeSetTime = 0.0; + m_shieldCheckTime = 0.0f; + m_zoomCheckTime = 0.0f; + m_strafeSetTime = 0.0f; m_combatStrafeDir = 0; m_fightStyle = 0; - m_lastFightStyleCheck = 0.0; + m_lastFightStyleCheck = 0.0f; m_checkWeaponSwitch = true; m_checkKnifeSwitch = true; @@ -1133,7 +1133,7 @@ void Bot::NewRound (void) m_defendHostage = false; m_headedTime = 0.0f; - m_timeLogoSpray = GetWorldTime () + Random.Float (0.5, 2.0); + m_timeLogoSpray = GetWorldTime () + Random.Float (0.5f, 2.0f); m_spawnTime = GetWorldTime (); m_lastChatTime = GetWorldTime (); @@ -1142,7 +1142,7 @@ void Bot::NewRound (void) m_nextCampDirTime = 0; m_campButtons = 0; - m_soundUpdateTime = 0.0; + m_soundUpdateTime = 0.0f; m_heardSoundTime = GetWorldTime (); // clear its message queue @@ -1154,7 +1154,7 @@ void Bot::NewRound (void) // and put buying into its message queue PushMessageQueue (GSM_BUY_STUFF); - PushTask (TASK_NORMAL, TASKPRI_NORMAL, -1, 0.0, true); + PushTask (TASK_NORMAL, TASKPRI_NORMAL, -1, 0.0f, true); if (Random.Long (0, 100) < 50) ChatterMessage (Chatter_NewRound); diff --git a/source/navigate.cpp b/source/navigate.cpp index b901ab4..5cb5288 100644 --- a/source/navigate.cpp +++ b/source/navigate.cpp @@ -73,8 +73,8 @@ int Bot::FindGoal (void) goto TacticChoosen; } - offensive = m_agressionLevel * 100; - defensive = m_fearLevel * 100; + offensive = m_agressionLevel * 100.0f; + defensive = m_fearLevel * 100.0f; if (g_mapType & (MAP_AS | MAP_CS)) { @@ -100,7 +100,7 @@ int Bot::FindGoal (void) } else if ((g_mapType & MAP_DE) && m_team == TEAM_CF) { - if (g_bombPlanted && GetTaskId () != TASK_ESCAPEFROMBOMB && waypoints.GetBombPosition () != nullvec) + if (g_bombPlanted && GetTaskId () != TASK_ESCAPEFROMBOMB && !waypoints.GetBombPosition ().IsZero ()) { if (g_bombSayString) { @@ -286,8 +286,8 @@ bool Bot::GoalIsValid (void) void Bot::ResetCollideState (void) { - m_collideTime = 0.0; - m_probeTime = 0.0; + m_collideTime = 0.0f; + m_probeTime = 0.0f; m_collisionProbeBits = 0; m_collisionState = COLLISION_NOTDECICED; @@ -346,7 +346,7 @@ void Bot::CheckCloseAvoidance (const Vector &dirNormal) float nextFrameDistance = ((nearest->v.origin + nearest->v.velocity * m_frameInterval) - pev->origin).GetLength2D (); // is player that near now or in future that we need to steer away? - if ((nearest->v.origin - moved).GetLength2D () <= 48.0 || (nearestDistance <= 56.0 && nextFrameDistance < nearestDistance)) + if ((nearest->v.origin - moved).GetLength2D () <= 48.0f || (nearestDistance <= 56.0f && nextFrameDistance < nearestDistance)) { // to start strafing, we have to first figure out if the target is on the left side or right side const Vector &dirToPoint = (pev->origin - nearest->v.origin).Get2D (); @@ -356,7 +356,7 @@ void Bot::CheckCloseAvoidance (const Vector &dirNormal) else SetStrafeSpeed (dirNormal, -pev->maxspeed); - if (nearestDistance < 56.0 && (dirToPoint | g_pGlobals->v_forward.Get2D ()) < 0.0f) + if (nearestDistance < 56.0f && (dirToPoint | g_pGlobals->v_forward.Get2D ()) < 0.0f) m_moveSpeed = -pev->maxspeed; } } @@ -365,17 +365,13 @@ void Bot::CheckCloseAvoidance (const Vector &dirNormal) void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal) { m_isStuck = false; - - Vector src = nullvec; - Vector dst = nullvec; - TraceResult tr; CheckCloseAvoidance (dirNormal); // Standing still, no need to check? // FIXME: doesn't care for ladder movement (handled separately) should be included in some way - if ((m_moveSpeed >= 10 || m_strafeSpeed >= 10) && m_lastCollTime < GetWorldTime () && m_seeEnemyTime + 0.8f < GetWorldTime () && GetTaskId () != TASK_ATTACK) + if ((m_moveSpeed >= 10.0f || m_strafeSpeed >= 10.0f) && m_lastCollTime < GetWorldTime () && m_seeEnemyTime + 0.8f < GetWorldTime () && GetTaskId () != TASK_ATTACK) { bool cantMoveForward = false; @@ -393,14 +389,14 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal) // test if there's something ahead blocking the way if ((cantMoveForward = CantMoveForward (dirNormal, &tr)) && !IsOnLadder ()) { - if (m_firstCollideTime == 0.0) + if (m_firstCollideTime == 0.0f) m_firstCollideTime = GetWorldTime () + 0.2f; else if (m_firstCollideTime <= GetWorldTime ()) m_isStuck = true; } else - m_firstCollideTime = 0.0; + m_firstCollideTime = 0.0f; } if (!m_isStuck) // not stuck? @@ -416,6 +412,9 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal) return; } // bot is stuck! + + Vector src; + Vector dst; // not yet decided what to do? if (m_collisionState == COLLISION_NOTDECICED) @@ -457,7 +456,7 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal) bool blockedLeft = false; bool blockedRight = false; - if ((dirToPoint | rightSide) > 0) + if ((dirToPoint | rightSide) > 0.0f) dirRight = true; else dirLeft = true; @@ -465,20 +464,20 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal) const Vector &testDir = m_moveSpeed > 0.0f ? g_pGlobals->v_forward : -g_pGlobals->v_forward; // now check which side is blocked - src = pev->origin + (g_pGlobals->v_right * 32); - dst = src + testDir * 32; + src = pev->origin + g_pGlobals->v_right * 32.0f; + dst = src + testDir * 32.0f; TraceHull (src, dst, true, head_hull, GetEntity (), &tr); - if (tr.flFraction != 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) blockedRight = true; - src = pev->origin - (g_pGlobals->v_right * 32); - dst = src + testDir * 32; + src = pev->origin - g_pGlobals->v_right * 32.0f; + dst = src + testDir * 32.0f; TraceHull (src, dst, true, head_hull, GetEntity (), &tr); - if (tr.flFraction != 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) blockedLeft = true; if (dirLeft) @@ -508,7 +507,7 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal) if (CanJumpUp (dirNormal)) state[i] += 10; - if (m_destOrigin.z >= pev->origin.z + 18.0) + if (m_destOrigin.z >= pev->origin.z + 18.0f) state[i] += 5; if (EntityIsVisible (m_destOrigin)) @@ -516,30 +515,30 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal) MakeVectors (m_moveAngles); src = EyePosition (); - src = src + g_pGlobals->v_right * 15; + src = src + g_pGlobals->v_right * 15.0f; TraceLine (src, m_destOrigin, true, true, GetEntity (), &tr); - if (tr.flFraction >= 1.0) + if (tr.flFraction > TRACE_FRACTION_EQ) { src = EyePosition (); - src = src - g_pGlobals->v_right * 15; + src = src - g_pGlobals->v_right * 15.0f; TraceLine (src, m_destOrigin, true, true, GetEntity (), &tr); - if (tr.flFraction >= 1.0) + if (tr.flFraction > TRACE_FRACTION_EQ) state[i] += 5; } } if (pev->flags & FL_DUCKING) src = pev->origin; else - src = pev->origin + Vector (0, 0, -17); + src = pev->origin + Vector (0.0f, 0.0f, -17.0f); - dst = src + dirNormal * 30; + dst = src + dirNormal * 30.0f; TraceLine (src, dst, true, true, GetEntity (), &tr); - if (tr.flFraction != 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) state[i] += 10; } else @@ -553,7 +552,7 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal) if (CanDuckUnder (dirNormal)) state[i] += 10; - if ((m_destOrigin.z + 36.0 <= pev->origin.z) && EntityIsVisible (m_destOrigin)) + if ((m_destOrigin.z + 36.0f <= pev->origin.z) && EntityIsVisible (m_destOrigin)) state[i] += 5; } else @@ -589,7 +588,7 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal) m_collideMoves[i] = state[i]; m_collideTime = GetWorldTime (); - m_probeTime = GetWorldTime () + 0.5; + m_probeTime = GetWorldTime () + 0.5f; m_collisionProbeBits = bits; m_collisionState = COLLISION_PROBING; m_collStateIndex = 0; @@ -601,11 +600,11 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal) if (m_probeTime < GetWorldTime ()) { m_collStateIndex++; - m_probeTime = GetWorldTime () + 0.5; + m_probeTime = GetWorldTime () + 0.5f; if (m_collStateIndex > MAX_COLLIDE_MOVES) { - m_navTimeset = GetWorldTime () - 5.0; + m_navTimeset = GetWorldTime () - 5.0f; ResetCollideState (); } } @@ -657,7 +656,7 @@ bool Bot::DoWaypointNav (void) // if wayzone radios non zero vary origin a bit depending on the body angles if (m_currentPath->radius > 0) { - MakeVectors (Vector (pev->angles.x, AngleNormalize (pev->angles.y + Random.Float (-90, 90)), 0.0)); + MakeVectors (Vector (pev->angles.x, AngleNormalize (pev->angles.y + Random.Float (-90.0f, 90.0f)), 0.0f)); m_waypointOrigin = m_waypointOrigin + g_pGlobals->v_forward * Random.Float (0, m_currentPath->radius); } m_navTimeset = GetWorldTime (); @@ -681,13 +680,13 @@ bool Bot::DoWaypointNav (void) if (IsOnFloor () || IsOnLadder ()) { if (m_desiredVelocity.x != 0.0f && m_desiredVelocity.y != 0.0f) - pev->velocity = m_desiredVelocity + m_desiredVelocity * 0.076f; + pev->velocity = m_desiredVelocity + m_desiredVelocity * 0.046f; pev->button |= IN_JUMP; m_jumpFinished = true; m_checkTerrain = false; - m_desiredVelocity = nullvec; + m_desiredVelocity.Zero (); } } else if (!yb_jasonmode.GetBool () && m_currentWeapon == WEAPON_KNIFE && IsOnFloor ()) @@ -696,14 +695,14 @@ bool Bot::DoWaypointNav (void) if (m_currentPath->flags & FLAG_LADDER) { - if (m_waypointOrigin.z >= (pev->origin.z + 16.0)) - m_waypointOrigin = m_currentPath->origin + Vector (0, 0, 16); - else if (m_waypointOrigin.z < pev->origin.z + 16.0 && !IsOnLadder () && IsOnFloor () && !(pev->flags & FL_DUCKING)) + if (m_waypointOrigin.z >= (pev->origin.z + 16.0f)) + m_waypointOrigin = m_currentPath->origin + Vector (0.0f, 0.0f, 16.0f); + else if (m_waypointOrigin.z < pev->origin.z + 16.0f && !IsOnLadder () && IsOnFloor () && !(pev->flags & FL_DUCKING)) { m_moveSpeed = waypointDistance; - if (m_moveSpeed < 150.0) - m_moveSpeed = 150.0; + if (m_moveSpeed < 150.0f) + m_moveSpeed = 150.0f; else if (m_moveSpeed > pev->maxspeed) m_moveSpeed = pev->maxspeed; } @@ -712,7 +711,6 @@ bool Bot::DoWaypointNav (void) // special lift handling (code merged from podbotmm) if (m_currentPath->flags & FLAG_LIFT) { - bool liftClosedDoorExists = false; // update waypoint time set @@ -721,7 +719,7 @@ bool Bot::DoWaypointNav (void) // trace line to door TraceLine (pev->origin, m_currentPath->origin, true, true, GetEntity (), &tr2); - if (tr2.flFraction < 1.0 && strcmp (STRING (tr2.pHit->v.classname), "func_door") == 0 && (m_liftState == LIFT_NO_NEARBY || m_liftState == LIFT_WAITING_FOR || m_liftState == LIFT_LOOKING_BUTTON_OUTSIDE) && pev->groundentity != tr2.pHit) + if (tr2.flFraction <= TRACE_FRACTION_EQ && strcmp (STRING (tr2.pHit->v.classname), "func_door") == 0 && (m_liftState == LIFT_NO_NEARBY || m_liftState == LIFT_WAITING_FOR || m_liftState == LIFT_LOOKING_BUTTON_OUTSIDE) && pev->groundentity != tr2.pHit) { if (m_liftState == LIFT_NO_NEARBY) { @@ -732,25 +730,25 @@ bool Bot::DoWaypointNav (void) } // trace line down - TraceLine (m_currentPath->origin, m_currentPath->origin + Vector (0, 0, -50), true, true, GetEntity (), &tr); + TraceLine (m_currentPath->origin, m_currentPath->origin + Vector (0.0f, 0.0f, -50.0f), true, true, GetEntity (), &tr); // if trace result shows us that it is a lift if (!IsEntityNull (tr.pHit) && m_navNode != NULL && (strcmp (STRING (tr.pHit->v.classname), "func_door") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_plat") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_train") == 0) && !liftClosedDoorExists) { - if ((m_liftState == LIFT_NO_NEARBY || m_liftState == LIFT_WAITING_FOR || m_liftState == LIFT_LOOKING_BUTTON_OUTSIDE) && tr.pHit->v.velocity.z == 0) + if ((m_liftState == LIFT_NO_NEARBY || m_liftState == LIFT_WAITING_FOR || m_liftState == LIFT_LOOKING_BUTTON_OUTSIDE) && tr.pHit->v.velocity.z == 0.0f) { - if (fabsf (pev->origin.z - tr.vecEndPos.z) < 70.0) + if (fabsf (pev->origin.z - tr.vecEndPos.z) < 70.0f) { m_liftEntity = tr.pHit; m_liftState = LIFT_ENTERING_IN; m_liftTravelPos = m_currentPath->origin; - m_liftUsageTime = GetWorldTime () + 5.0; + m_liftUsageTime = GetWorldTime () + 5.0f; } } else if (m_liftState == LIFT_TRAVELING_BY) { m_liftState = LIFT_LEAVING; - m_liftUsageTime = GetWorldTime () + 7.0; + m_liftUsageTime = GetWorldTime () + 7.0f; } } else if (m_navNode != NULL) // no lift found at waypoint @@ -765,7 +763,7 @@ bool Bot::DoWaypointNav (void) m_liftEntity = tr.pHit; } m_liftState = LIFT_LOOKING_BUTTON_OUTSIDE; - m_liftUsageTime = GetWorldTime () + 15.0; + m_liftUsageTime = GetWorldTime () + 15.0f; } } @@ -812,12 +810,12 @@ bool Bot::DoWaypointNav (void) if (needWaitForTeammate) { m_liftState = LIFT_WAIT_FOR_TEAMMATES; - m_liftUsageTime = GetWorldTime () + 8.0; + m_liftUsageTime = GetWorldTime () + 8.0f; } else { m_liftState = LIFT_LOOKING_BUTTON_INSIDE; - m_liftUsageTime = GetWorldTime () + 10.0; + m_liftUsageTime = GetWorldTime () + 10.0f; } } } @@ -850,7 +848,7 @@ bool Bot::DoWaypointNav (void) { m_destOrigin = m_liftTravelPos; - if ((pev->origin - m_destOrigin).GetLengthSquared () < 225) + if ((pev->origin - m_destOrigin).GetLengthSquared () < 225.0f) { m_moveSpeed = 0.0f; m_strafeSpeed = 0.0f; @@ -863,7 +861,7 @@ bool Bot::DoWaypointNav (void) } // else we need to look for button - if (!needWaitForTeammate || (m_liftUsageTime < GetWorldTime ())) + if (!needWaitForTeammate || m_liftUsageTime < GetWorldTime ()) { m_liftState = LIFT_LOOKING_BUTTON_INSIDE; m_liftUsageTime = GetWorldTime () + 10.0; @@ -876,7 +874,7 @@ bool Bot::DoWaypointNav (void) edict_t *button = FindNearestButton (STRING (m_liftEntity->v.targetname)); // got a valid button entity ? - if (!IsEntityNull (button) && pev->groundentity == m_liftEntity && m_buttonPushTime + 1.0 < GetWorldTime () && m_liftEntity->v.velocity.z == 0.0 && IsOnFloor ()) + if (!IsEntityNull (button) && pev->groundentity == m_liftEntity && m_buttonPushTime + 1.0f < GetWorldTime () && m_liftEntity->v.velocity.z == 0.0f && IsOnFloor ()) { m_pickupItem = button; m_pickupType = PICKUP_BUTTON; @@ -888,12 +886,12 @@ bool Bot::DoWaypointNav (void) // is lift activated and bot is standing on it and lift is moving ? if (m_liftState == LIFT_LOOKING_BUTTON_INSIDE || m_liftState == LIFT_ENTERING_IN || m_liftState == LIFT_WAIT_FOR_TEAMMATES || m_liftState == LIFT_WAITING_FOR) { - if (pev->groundentity == m_liftEntity && m_liftEntity->v.velocity.z != 0 && IsOnFloor () && ((waypoints.GetPath (m_prevWptIndex[0])->flags & FLAG_LIFT) || !IsEntityNull (m_targetEntity))) + if (pev->groundentity == m_liftEntity && m_liftEntity->v.velocity.z != 0.0f && IsOnFloor () && ((waypoints.GetPath (m_prevWptIndex[0])->flags & FLAG_LIFT) || !IsEntityNull (m_targetEntity))) { m_liftState = LIFT_TRAVELING_BY; - m_liftUsageTime = GetWorldTime () + 14.0; + m_liftUsageTime = GetWorldTime () + 14.0f; - if ((pev->origin - m_destOrigin).GetLengthSquared () < 225) + if ((pev->origin - m_destOrigin).GetLengthSquared () < 225.0f) { m_moveSpeed = 0.0f; m_strafeSpeed = 0.0f; @@ -911,7 +909,7 @@ bool Bot::DoWaypointNav (void) { m_destOrigin = Vector (m_liftTravelPos.x, m_liftTravelPos.y, pev->origin.z); - if ((pev->origin - m_destOrigin).GetLengthSquared () < 225) + if ((pev->origin - m_destOrigin).GetLengthSquared () < 225.0f) { m_moveSpeed = 0.0f; m_strafeSpeed = 0.0f; @@ -928,14 +926,14 @@ bool Bot::DoWaypointNav (void) { // button has been pressed, lift should come - if (m_buttonPushTime + 8.0 >= GetWorldTime ()) + if (m_buttonPushTime + 8.0f >= GetWorldTime ()) { - if ((m_prevWptIndex[0] >= 0) && (m_prevWptIndex[0] < g_numWaypoints)) + if (m_prevWptIndex[0] >= 0 && m_prevWptIndex[0] < g_numWaypoints) m_destOrigin = waypoints.GetPath (m_prevWptIndex[0])->origin; else m_destOrigin = pev->origin; - if ((pev->origin - m_destOrigin).GetLengthSquared () < 225) + if ((pev->origin - m_destOrigin).GetLengthSquared () < 225.0f) { m_moveSpeed = 0.0f; m_strafeSpeed = 0.0f; @@ -977,10 +975,10 @@ bool Bot::DoWaypointNav (void) else m_destOrigin = button->v.origin; - if ((pev->origin - m_destOrigin).GetLengthSquared () < 225) + if ((pev->origin - m_destOrigin).GetLengthSquared () < 225.0f) { - m_moveSpeed = 0.0; - m_strafeSpeed = 0.0; + m_moveSpeed = 0.0f; + m_strafeSpeed = 0.0f; } } else @@ -990,13 +988,13 @@ bool Bot::DoWaypointNav (void) m_liftState = LIFT_WAITING_FOR; m_navTimeset = GetWorldTime (); - m_liftUsageTime = GetWorldTime () + 20.0; + m_liftUsageTime = GetWorldTime () + 20.0f; } } else { m_liftState = LIFT_WAITING_FOR; - m_liftUsageTime = GetWorldTime () + 15.0; + m_liftUsageTime = GetWorldTime () + 15.0f; } } } @@ -1004,15 +1002,15 @@ bool Bot::DoWaypointNav (void) // bot is waiting for lift if (m_liftState == LIFT_WAITING_FOR) { - if ((m_prevWptIndex[0] >= 0) && (m_prevWptIndex[0] < g_numWaypoints)) + if (m_prevWptIndex[0] >= 0 && m_prevWptIndex[0] < g_numWaypoints) { if (!(waypoints.GetPath (m_prevWptIndex[0])->flags & FLAG_LIFT)) m_destOrigin = waypoints.GetPath (m_prevWptIndex[0])->origin; - else if ((m_prevWptIndex[1] >= 0) && (m_prevWptIndex[0] < g_numWaypoints)) + else if (m_prevWptIndex[1] >= 0 && m_prevWptIndex[1] < g_numWaypoints) m_destOrigin = waypoints.GetPath (m_prevWptIndex[1])->origin; } - if ((pev->origin - m_destOrigin).GetLengthSquared () < 100) + if ((pev->origin - m_destOrigin).GetLengthSquared () < 100.0f) { m_moveSpeed = 0.0f; m_strafeSpeed = 0.0f; @@ -1030,11 +1028,11 @@ bool Bot::DoWaypointNav (void) // bot fall down somewhere inside the lift's groove :) if (pev->groundentity != m_liftEntity && m_prevWptIndex[0] >= 0 && m_prevWptIndex[0] < g_numWaypoints) { - if ((waypoints.GetPath (m_prevWptIndex[0])->flags & FLAG_LIFT) && (m_currentPath->origin.z - pev->origin.z) > 50.0 && (waypoints.GetPath (m_prevWptIndex[0])->origin.z - pev->origin.z) > 50.0) + if ((waypoints.GetPath (m_prevWptIndex[0])->flags & FLAG_LIFT) && (m_currentPath->origin.z - pev->origin.z) > 50.0f && (waypoints.GetPath (m_prevWptIndex[0])->origin.z - pev->origin.z) > 50.0f) { m_liftState = LIFT_NO_NEARBY; m_liftEntity = NULL; - m_liftUsageTime = 0.0; + m_liftUsageTime = 0.0f; DeleteSearchNodes (); FindWaypoint (); @@ -1053,22 +1051,22 @@ bool Bot::DoWaypointNav (void) if (m_liftState == LIFT_TRAVELING_BY) { m_liftState = LIFT_LEAVING; - m_liftUsageTime = GetWorldTime () + 10.0; + m_liftUsageTime = GetWorldTime () + 10.0f; } if (m_liftState == LIFT_LEAVING && m_liftUsageTime < GetWorldTime () && pev->groundentity != m_liftEntity) { m_liftState = LIFT_NO_NEARBY; - m_liftUsageTime = 0.0; + m_liftUsageTime = 0.0f; m_liftEntity = NULL; } } - if (m_liftUsageTime < GetWorldTime () && m_liftUsageTime != 0.0) + if (m_liftUsageTime < GetWorldTime () && m_liftUsageTime != 0.0f) { m_liftEntity = NULL; m_liftState = LIFT_NO_NEARBY; - m_liftUsageTime = 0.0; + m_liftUsageTime = 0.0f; DeleteSearchNodes (); @@ -1091,7 +1089,7 @@ bool Bot::DoWaypointNav (void) if (!IsEntityNull (tr.pHit) && IsEntityNull (m_liftEntity) && strncmp (STRING (tr.pHit->v.classname), "func_door", 9) == 0) { // if the door is near enough... - if ((GetEntityOrigin (tr.pHit) - pev->origin).GetLengthSquared () < 2500) + if ((GetEntityOrigin (tr.pHit) - pev->origin).GetLengthSquared () < 2500.0f) { IgnoreCollisionShortly (); // don't consider being stuck @@ -1119,7 +1117,7 @@ bool Bot::DoWaypointNav (void) PushTask (TASK_PAUSE, TASKPRI_PAUSE, -1, GetWorldTime () + 1, false); m_doorOpenAttempt++; - m_timeDoorOpen = GetWorldTime () + 1.0; // retry in 1 sec until door is open + m_timeDoorOpen = GetWorldTime () + 1.0f; // retry in 1 sec until door is open edict_t *ent = NULL; @@ -1148,17 +1146,17 @@ bool Bot::DoWaypointNav (void) } } - float desiredDistance = 0.0; + float desiredDistance = 0.0f; // initialize the radius for a special waypoint type, where the wpt is considered to be reached if (m_currentPath->flags & FLAG_LIFT) - desiredDistance = 50; + desiredDistance = 50.0f; else if ((pev->flags & FL_DUCKING) || (m_currentPath->flags & FLAG_GOAL)) - desiredDistance = 25; + desiredDistance = 25.0f; else if (m_currentPath->flags & FLAG_LADDER) - desiredDistance = 15; + desiredDistance = 15.0f; else if (m_currentTravelFlags & PATHFLAG_JUMP) - desiredDistance = 0.0; + desiredDistance = 0.0f; else desiredDistance = m_currentPath->radius; @@ -1173,8 +1171,8 @@ bool Bot::DoWaypointNav (void) } // needs precise placement - check if we get past the point - if (desiredDistance < 16.0 && waypointDistance < 30 && (pev->origin + (pev->velocity * m_frameInterval) - m_waypointOrigin).GetLength () > waypointDistance) - desiredDistance = waypointDistance + 1.0; + if (desiredDistance < 16.0f && waypointDistance < 30.0f && (pev->origin + (pev->velocity * m_frameInterval) - m_waypointOrigin).GetLength () > waypointDistance) + desiredDistance = waypointDistance + 1.0f; if (waypointDistance < desiredDistance) { @@ -1191,8 +1189,8 @@ bool Bot::DoWaypointNav (void) if (m_team == TEAM_TF) { waypointValue = (g_experienceData + (startIndex * g_numWaypoints) + goalIndex)->team0Value; - waypointValue += static_cast (pev->health * 0.5); - waypointValue += static_cast (m_goalValue * 0.5); + waypointValue += static_cast (pev->health * 0.5f); + waypointValue += static_cast (m_goalValue * 0.5f); if (waypointValue < -MAX_GOAL_VALUE) waypointValue = -MAX_GOAL_VALUE; @@ -1204,8 +1202,8 @@ bool Bot::DoWaypointNav (void) else { waypointValue = (g_experienceData + (startIndex * g_numWaypoints) + goalIndex)->team1Value; - waypointValue += static_cast (pev->health * 0.5); - waypointValue += static_cast (m_goalValue * 0.5); + waypointValue += static_cast (pev->health * 0.5f); + waypointValue += static_cast (m_goalValue * 0.5f); if (waypointValue < -MAX_GOAL_VALUE) waypointValue = -MAX_GOAL_VALUE; @@ -1225,7 +1223,7 @@ bool Bot::DoWaypointNav (void) Vector bombOrigin = CheckBombAudible (); // bot within 'hearable' bomb tick noises? - if (bombOrigin != nullvec) + if (!bombOrigin.IsZero ()) { float distance = (bombOrigin - waypoints.GetPath (GetTask ()->data)->origin).GetLength (); @@ -1248,7 +1246,7 @@ void Bot::FindShortestPath (int srcIndex, int destIndex) DeleteSearchNodes (); m_chosenGoalIndex = srcIndex; - m_goalValue = 0.0; + m_goalValue = 0.0f; PathNode *node = new PathNode; @@ -1303,7 +1301,7 @@ public: return m_size == 0; } - inline PriorityQueue (int initialSize = MAX_WAYPOINTS * 0.5) + inline PriorityQueue (int initialSize = MAX_WAYPOINTS * 0.5f) { m_size = 0; m_heapSize = initialSize; @@ -1348,7 +1346,7 @@ public: while (child) { - int parent = (child - 1) * 0.5; + int parent = (child - 1) * 0.5f; if (m_heap[parent].pri <= m_heap[child].pri) break; @@ -1401,7 +1399,7 @@ float gfunctionKillsDistT (int currentIndex, int parentIndex) // least kills and number of nodes to goal for a team if (parentIndex == -1) - return 0; + return 0.0f; float cost = (g_experienceData + (currentIndex * g_numWaypoints) + currentIndex)->team0Damage + g_highestDamageT; @@ -1416,7 +1414,7 @@ float gfunctionKillsDistT (int currentIndex, int parentIndex) } if (current->flags & FLAG_CROUCH) - cost *= 1.5; + cost *= 1.5f; return waypoints.GetPathDistance (parentIndex, currentIndex) + cost; } @@ -1427,7 +1425,7 @@ float gfunctionKillsDistCT (int currentIndex, int parentIndex) // least kills and number of nodes to goal for a team if (parentIndex == -1) - return 0; + return 0.0f; float cost = (g_experienceData + (currentIndex * g_numWaypoints) + currentIndex)->team1Damage + g_highestDamageCT; @@ -1442,7 +1440,7 @@ float gfunctionKillsDistCT (int currentIndex, int parentIndex) } if (current->flags & FLAG_CROUCH) - cost *= 1.5; + cost *= 1.5f; return waypoints.GetPathDistance (parentIndex, currentIndex) + cost; } @@ -1454,10 +1452,10 @@ float gfunctionKillsDistCTWithHostage (int currentIndex, int parentIndex) Path *current = waypoints.GetPath (currentIndex); if (current->flags & FLAG_NOHOSTAGE) - return 65355; + return 65355.0f; else if (current->flags & (FLAG_CROUCH | FLAG_LADDER)) - return gfunctionKillsDistCT (currentIndex, parentIndex) * 500; + return gfunctionKillsDistCT (currentIndex, parentIndex) * 500.0f; return gfunctionKillsDistCT (currentIndex, parentIndex); } @@ -1489,7 +1487,7 @@ float gfunctionKillsCT (int currentIndex, int parentIndex) // least kills to goal for a team if (parentIndex == -1) - return 0; + return 0.0f; float cost = (g_experienceData + (currentIndex * g_numWaypoints) + currentIndex)->team1Damage; @@ -1504,7 +1502,7 @@ float gfunctionKillsCT (int currentIndex, int parentIndex) } if (current->flags & FLAG_CROUCH) - cost *= 1.5; + cost *= 1.5f; return cost + 0.5f; } @@ -1514,15 +1512,15 @@ float gfunctionKillsCTWithHostage (int currentIndex, int parentIndex) // least kills to goal for a team if (parentIndex == -1) - return 0; + return 0.0f; Path *current = waypoints.GetPath (currentIndex); if (current->flags & FLAG_NOHOSTAGE) - return 65355; + return 65355.0f; else if (current->flags & (FLAG_CROUCH | FLAG_LADDER)) - return gfunctionKillsDistCT (currentIndex, parentIndex) * 500; + return gfunctionKillsDistCT (currentIndex, parentIndex) * 500.0f; return gfunctionKillsCT (currentIndex, parentIndex); } @@ -1530,7 +1528,7 @@ float gfunctionKillsCTWithHostage (int currentIndex, int parentIndex) float gfunctionPathDist (int currentIndex, int parentIndex) { if (parentIndex == -1) - return 0; + return 0.0f; Path *parent = waypoints.GetPath (parentIndex); Path *current = waypoints.GetPath (currentIndex); @@ -1541,12 +1539,12 @@ float gfunctionPathDist (int currentIndex, int parentIndex) { // we don't like ladder or crouch point if (current->flags & (FLAG_CROUCH | FLAG_LADDER)) - return parent->distances[i] * 1.5; + return parent->distances[i] * 1.5f; return parent->distances[i]; } } - return 65355; + return 65355.0f; } float gfunctionPathDistWithHostage (int currentIndex, int parentIndex) @@ -1554,10 +1552,10 @@ float gfunctionPathDistWithHostage (int currentIndex, int parentIndex) Path *current = waypoints.GetPath (currentIndex); if (current->flags & FLAG_NOHOSTAGE) - return 65355; + return 65355.0f; else if (current->flags & (FLAG_CROUCH | FLAG_LADDER)) - return gfunctionPathDist (currentIndex, parentIndex) * 500; + return gfunctionPathDist (currentIndex, parentIndex) * 500.0f; return gfunctionPathDist (currentIndex, parentIndex); } @@ -1569,13 +1567,6 @@ float hfunctionSquareDist (int index, int, int goalIndex) Path *start = waypoints.GetPath (index); Path *goal = waypoints.GetPath (goalIndex); -#if 0 - float deltaX = fabsf (start->origin.x - goal->origin.x); - float deltaY = fabsf (start->origin.y - goal->origin.y); - float deltaZ = fabsf (start->origin.z - goal->origin.z); - - return static_cast (deltaX + deltaY + deltaZ); -#else float xDist = fabsf (start->origin.x - goal->origin.x); float yDist = fabsf (start->origin.y - goal->origin.y); float zDist = fabsf (start->origin.z - goal->origin.z); @@ -1584,7 +1575,6 @@ float hfunctionSquareDist (int index, int, int goalIndex) return 1.4f * yDist + (xDist - yDist) + zDist; return 1.4f * xDist + (yDist - xDist) + zDist; -#endif } float hfunctionSquareDistWithHostage (int index, int startIndex, int goalIndex) @@ -1592,19 +1582,19 @@ float hfunctionSquareDistWithHostage (int index, int startIndex, int goalIndex) // square distance heuristic with hostages if (waypoints.GetPath (startIndex)->flags & FLAG_NOHOSTAGE) - return 65355; + return 65355.0f; return hfunctionSquareDist (index, startIndex, goalIndex); } float hfunctionNone (int index, int startIndex, int goalIndex) { - return hfunctionSquareDist (index, startIndex, goalIndex) / (128 * 10); + return hfunctionSquareDist (index, startIndex, goalIndex) / (128.0f * 10.0f); } float hfunctionNumberNodes (int index, int startIndex, int goalIndex) { - return hfunctionSquareDist (index, startIndex, goalIndex) / 128 * g_highestKills; + return hfunctionSquareDist (index, startIndex, goalIndex) / 128.0f * g_highestKills; } void Bot::FindPath (int srcIndex, int destIndex, unsigned char pathType) @@ -1625,7 +1615,7 @@ void Bot::FindPath (int srcIndex, int destIndex, unsigned char pathType) DeleteSearchNodes (); m_chosenGoalIndex = srcIndex; - m_goalValue = 0.0; + m_goalValue = 0.0f; // A* Stuff enum AStarState {OPEN, CLOSED, NEW}; @@ -1642,8 +1632,8 @@ void Bot::FindPath (int srcIndex, int destIndex, unsigned char pathType) for (int i = 0; i < MAX_WAYPOINTS; i++) { - astar[i].g = 0; - astar[i].f = 0; + astar[i].g = 0.0f; + astar[i].f = 0.0f; astar[i].parentIndex = -1; astar[i].state = NEW; } @@ -1704,7 +1694,6 @@ void Bot::FindPath (int srcIndex, int destIndex, unsigned char pathType) break; } - // put start node into open list astar[srcIndex].g = gcalc (srcIndex, -1); astar[srcIndex].f = astar[srcIndex].g + hcalc (srcIndex, srcIndex, destIndex); @@ -1830,18 +1819,14 @@ bool Bot::FindWaypoint (void) for (i = 0; i < 3; i++) { waypointIndeces[i] = -1; - reachDistances[i] = 9999.0; + reachDistances[i] = 9999.0f; } // do main search loop for (i = 0; i < g_numWaypoints; i++) { // ignore current waypoint and previous recent waypoints... -#if 0 - if (i == m_currentWaypointIndex || i == m_prevWptIndex[0] || i == m_prevWptIndex[1] || i == m_prevWptIndex[2] || i == m_prevWptIndex[3] || i == m_prevWptIndex[4]) -#else if (i == m_currentWaypointIndex || i == m_prevWptIndex[0] || i == m_prevWptIndex[1] || i == m_prevWptIndex[2]) -#endif continue; if ((g_mapType & MAP_CS) && HasHostage () && (waypoints.GetPath (i)->flags & FLAG_NOHOSTAGE)) @@ -2050,7 +2035,7 @@ int Bot::ChooseBombWaypoint (void) Vector bombOrigin = CheckBombAudible (); // if bomb returns no valid vector, return the current bot pos - if (bombOrigin == nullvec) + if (bombOrigin.IsZero ()) bombOrigin = pev->origin; int goal = 0, count = 0; @@ -2111,14 +2096,14 @@ int Bot::FindDefendWaypoint (const Vector &origin) // use the 'real' pathfinding distances int distances = waypoints.GetPathDistance (srcIndex, i); - // skip wayponts with distance more than 1024 units - if (distances > 1248.0f) + // skip wayponts with distance more than 1536 units + if (distances > 1536.0f) continue; TraceLine (waypoints.GetPath (i)->origin, waypoints.GetPath (posIndex)->origin, true, true, GetEntity (), &tr); // check if line not hit anything - if (tr.flFraction != 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) continue; for (int j = 0; j < MAX_PATH_INDEX; j++) @@ -2199,7 +2184,7 @@ int Bot::FindDefendWaypoint (const Vector &origin) if (waypointIndex[index] == -1) break; } - return waypointIndex[Random.Long (0, (index - 1) * 0.5)]; + return waypointIndex[Random.Long (0, (index - 1) * 0.5f)]; } int Bot::FindCoverWaypoint (float maxDistance) @@ -2210,8 +2195,8 @@ int Bot::FindCoverWaypoint (float maxDistance) if (maxDistance > (m_lastEnemyOrigin - pev->origin).GetLength ()) maxDistance = (m_lastEnemyOrigin - pev->origin).GetLength (); - if (maxDistance < 300.0) - maxDistance = 300.0; + if (maxDistance < 300.0f) + maxDistance = 300.0f; int srcIndex = m_currentWaypointIndex; int enemyIndex = waypoints.FindNearest (m_lastEnemyOrigin); @@ -2327,9 +2312,9 @@ int Bot::FindCoverWaypoint (float maxDistance) { if (waypointIndex[i] != -1) { - TraceLine (m_lastEnemyOrigin + Vector (0, 0, 36), waypoints.GetPath (waypointIndex[i])->origin, true, true, GetEntity (), &tr); + TraceLine (m_lastEnemyOrigin + Vector (0.0f, 0.0f, 36.0f), waypoints.GetPath (waypointIndex[i])->origin, true, true, GetEntity (), &tr); - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) return waypointIndex[i]; } } @@ -2424,7 +2409,7 @@ bool Bot::HeadTowardWaypoint (void) if (m_baseAgressionLevel < kills && HasPrimaryWeapon ()) { - PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (m_difficulty * 0.5, m_difficulty) * 5, true); + PushTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (m_difficulty * 0.5f, m_difficulty) * 5.0f, true); PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, FindDefendWaypoint (waypoints.GetPath (nextIndex)->origin), GetWorldTime () + Random.Float (3.0f, 10.0f), true); } } @@ -2459,10 +2444,10 @@ bool Bot::HeadTowardWaypoint (void) // check if bot is going to jump bool willJump = false; - float jumpDistance = 0.0; + float jumpDistance = 0.0f; - Vector src = nullvec; - Vector destination = nullvec; + Vector src; + Vector dst; // try to find out about future connection flags if (m_navNode->next != NULL) @@ -2475,7 +2460,7 @@ bool Bot::HeadTowardWaypoint (void) if (path->index[i] == m_navNode->next->index && (path->connectionFlags[i] & PATHFLAG_JUMP)) { src = path->origin; - destination = next->origin; + dst = next->origin; jumpDistance = (path->origin - next->origin).GetLength (); willJump = true; @@ -2486,7 +2471,7 @@ bool Bot::HeadTowardWaypoint (void) } // is there a jump waypoint right ahead and do we need to draw out the light weapon ? - if (willJump && m_currentWeapon != WEAPON_KNIFE && m_currentWeapon != WEAPON_SCOUT && !m_isReloading && !UsesPistol () && (jumpDistance > 210 || (destination.z + 32.0f > src.z && jumpDistance > 150.0f) || ((destination - src).GetLength2D () < 60 && jumpDistance > 60)) && IsEntityNull (m_enemy)) + if (willJump && m_currentWeapon != WEAPON_KNIFE && m_currentWeapon != WEAPON_SCOUT && !m_isReloading && !UsesPistol () && (jumpDistance > 210.0f || (dst.z + 32.0f > src.z && jumpDistance > 150.0f) || ((dst - src).GetLength2D () < 60.0f && jumpDistance > 60.0f)) && IsEntityNull (m_enemy)) SelectWeaponByName ("weapon_knife"); // draw out the knife if we needed // bot not already on ladder but will be soon? @@ -2500,7 +2485,7 @@ bool Bot::HeadTowardWaypoint (void) // if another bot uses this ladder, wait 3 secs if (otherBot != NULL && otherBot != this && IsAlive (otherBot->GetEntity ()) && otherBot->m_currentWaypointIndex == m_navNode->index) { - PushTask (TASK_PAUSE, TASKPRI_PAUSE, -1, GetWorldTime () + 3.0, false); + PushTask (TASK_PAUSE, TASKPRI_PAUSE, -1, GetWorldTime () + 3.0f, false); return true; } } @@ -2514,16 +2499,16 @@ bool Bot::HeadTowardWaypoint (void) // if wayzone radius non zero vary origin a bit depending on the body angles if (m_currentPath->radius > 0.0f) { - MakeVectors (Vector (pev->angles.x, AngleNormalize (pev->angles.y + Random.Float (-90, 90)), 0.0)); - m_waypointOrigin = m_waypointOrigin + g_pGlobals->v_forward * Random.Float (0, m_currentPath->radius); + MakeVectors (Vector (pev->angles.x, AngleNormalize (pev->angles.y + Random.Float (-90.0f, 90.0f)), 0.0f)); + m_waypointOrigin = m_waypointOrigin + g_pGlobals->v_forward * Random.Float (0.0f, m_currentPath->radius); } if (IsOnLadder ()) { TraceLine (Vector (pev->origin.x, pev->origin.y, pev->absmin.z), m_waypointOrigin, true, true, GetEntity (), &tr); - if (tr.flFraction < 1.0) - m_waypointOrigin = m_waypointOrigin + (pev->origin - m_waypointOrigin) * 0.5 + Vector (0, 0, 32); + if (tr.flFraction <= TRACE_FRACTION_EQ) + m_waypointOrigin = m_waypointOrigin + (pev->origin - m_waypointOrigin) * 0.5f + Vector (0.0f, 0.0f, 32.0f); } m_navTimeset = GetWorldTime (); @@ -2538,15 +2523,15 @@ bool Bot::CantMoveForward (const Vector &normal, TraceResult *tr) // first do a trace from the bot's eyes forward... Vector src = EyePosition (); - Vector forward = src + normal * 24; + Vector forward = src + normal * 24.0f; - MakeVectors (Vector (0, pev->angles.y, 0)); + MakeVectors (Vector (0.0f, pev->angles.y, 0.0f)); // trace from the bot's eyes straight forward... TraceLine (src, forward, true, GetEntity (), tr); // check if the trace hit something... - if (tr->flFraction < 1.0) + if (tr->flFraction <= TRACE_FRACTION_EQ) { if (strncmp ("func_door", STRING (tr->pHit->v.classname), 9) == 0) return false; @@ -2556,68 +2541,68 @@ bool Bot::CantMoveForward (const Vector &normal, TraceResult *tr) // bot's head is clear, check at shoulder level... // trace from the bot's shoulder left diagonal forward to the right shoulder... - src = EyePosition () + Vector (0, 0, -16) - g_pGlobals->v_right * -16; - forward = EyePosition () + Vector (0, 0, -16) + g_pGlobals->v_right * 16 + normal * 24; + src = EyePosition () + Vector (0.0f, 0.0f, -16.0f) - g_pGlobals->v_right * -16.0f; + forward = EyePosition () + Vector (0.0f, 0.0f, -16.0f) + g_pGlobals->v_right * 16.0f + normal * 24.0f; TraceLine (src, forward, true, GetEntity (), tr); // check if the trace hit something... - if (tr->flFraction < 1.0 && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0) + if (tr->flFraction <= TRACE_FRACTION_EQ && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0) return true; // bot's body will hit something // bot's head is clear, check at shoulder level... // trace from the bot's shoulder right diagonal forward to the left shoulder... - src = EyePosition () + Vector (0, 0, -16) + g_pGlobals->v_right * 16; - forward = EyePosition () + Vector (0, 0, -16) - g_pGlobals->v_right * -16 + normal * 24; + src = EyePosition () + Vector (0.0f, 0.0f, -16.0f) + g_pGlobals->v_right * 16.0f; + forward = EyePosition () + Vector (0.0f, 0.0f, -16.0f) - g_pGlobals->v_right * -16.0f + normal * 24.0f; TraceLine (src, forward, true, GetEntity (), tr); // check if the trace hit something... - if (tr->flFraction < 1.0 && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0) + if (tr->flFraction <= TRACE_FRACTION_EQ && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0) return true; // bot's body will hit something // now check below waist if (pev->flags & FL_DUCKING) { - src = pev->origin + Vector (0, 0, -19 + 19); - forward = src + Vector (0, 0, 10) + normal * 24; + src = pev->origin + Vector (0.0f, 0.0f, -19.0f + 19.0f); + forward = src + Vector (0.0f, 0.0f, 10.0f) + normal * 24.0f; TraceLine (src, forward, true, GetEntity (), tr); // check if the trace hit something... - if (tr->flFraction < 1.0 && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0) + if (tr->flFraction <= TRACE_FRACTION_EQ && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0) return true; // bot's body will hit something src = pev->origin; - forward = src + normal * 24; + forward = src + normal * 24.0f; TraceLine (src, forward, true, GetEntity (), tr); // check if the trace hit something... - if (tr->flFraction < 1.0 && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0) + if (tr->flFraction <= TRACE_FRACTION_EQ && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0) return true; // bot's body will hit something } else { // trace from the left waist to the right forward waist pos - src = pev->origin + Vector (0, 0, -17) - g_pGlobals->v_right * -16; - forward = pev->origin + Vector (0, 0, -17) + g_pGlobals->v_right * 16 + normal * 24; + src = pev->origin + Vector (0.0f, 0.0f, -17.0f) - g_pGlobals->v_right * -16.0f; + forward = pev->origin + Vector (0.0f, 0.0f, -17.0f) + g_pGlobals->v_right * 16.0f + normal * 24.0f; // trace from the bot's waist straight forward... TraceLine (src, forward, true, GetEntity (), tr); // check if the trace hit something... - if (tr->flFraction < 1.0 && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0) + if (tr->flFraction <= TRACE_FRACTION_EQ && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0) return true; // bot's body will hit something // trace from the left waist to the right forward waist pos - src = pev->origin + Vector (0, 0, -17) + g_pGlobals->v_right * 16; - forward = pev->origin + Vector (0, 0, -17) - g_pGlobals->v_right * -16 + normal * 24; + src = pev->origin + Vector (0.0f, 0.0f, -17.0f) + g_pGlobals->v_right * 16.0f; + forward = pev->origin + Vector (0.0f, 0.0f, -17.0f) - g_pGlobals->v_right * -16.0f + normal * 24.0f; TraceLine (src, forward, true, GetEntity (), tr); // check if the trace hit something... - if (tr->flFraction < 1.0 && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0) + if (tr->flFraction <= TRACE_FRACTION_EQ && strncmp ("func_door", STRING (tr->pHit->v.classname), 9) != 0) return true; // bot's body will hit something } return false; // bot can move forward, return false @@ -2631,23 +2616,23 @@ bool Bot::CanStrafeLeft (TraceResult *tr) MakeVectors (pev->v_angle); Vector src = pev->origin; - Vector left = src - g_pGlobals->v_right * -40; + Vector left = src - g_pGlobals->v_right * -40.0f; // trace from the bot's waist straight left... TraceLine (src, left, true, GetEntity (), tr); // check if the trace hit something... - if (tr->flFraction < 1.0) + if (tr->flFraction <= TRACE_FRACTION_EQ) return false; // bot's body will hit something src = left; - left = left + g_pGlobals->v_forward * 40; + left = left + g_pGlobals->v_forward * 40.0f; // trace from the strafe pos straight forward... TraceLine (src, left, true, GetEntity (), tr); // check if the trace hit something... - if (tr->flFraction < 1.0) + if (tr->flFraction <= TRACE_FRACTION_EQ) return false; // bot's body will hit something return true; @@ -2660,23 +2645,23 @@ bool Bot::CanStrafeRight (TraceResult * tr) MakeVectors (pev->v_angle); Vector src = pev->origin; - Vector right = src + g_pGlobals->v_right * 40; + Vector right = src + g_pGlobals->v_right * 40.0f; // trace from the bot's waist straight right... TraceLine (src, right, true, GetEntity (), tr); // check if the trace hit something... - if (tr->flFraction < 1.0) + if (tr->flFraction <= TRACE_FRACTION_EQ) return false; // bot's body will hit something src = right; - right = right + g_pGlobals->v_forward * 40; + right = right + g_pGlobals->v_forward * 40.0f; // trace from the strafe pos straight forward... TraceLine (src, right, true, GetEntity (), tr); // check if the trace hit something... - if (tr->flFraction < 1.0) + if (tr->flFraction <= TRACE_FRACTION_EQ) return false; // bot's body will hit something return true; @@ -2695,139 +2680,135 @@ bool Bot::CanJumpUp (const Vector &normal) return false; // convert current view angle to vectors for traceline math... - Vector jump = pev->angles; - jump.x = 0; // reset pitch to 0 (level horizontally) - jump.z = 0; // reset roll to 0 (straight up and down) - - MakeVectors (jump); + MakeVectors (Vector (0.0f, pev->angles.y, 0.0f)); // check for normal jump height first... - Vector src = pev->origin + Vector (0, 0, -36 + 45); - Vector dest = src + normal * 32; + Vector src = pev->origin + Vector (0.0f, 0.0f, -36.0f + 45.0f); + Vector dest = src + normal * 32.0f; // trace a line forward at maximum jump height... TraceLine (src, dest, true, GetEntity (), &tr); - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) goto CheckDuckJump; else { // now trace from jump height upward to check for obstructions... src = dest; - dest.z = dest.z + 37; + dest.z = dest.z + 37.0f; TraceLine (src, dest, true, GetEntity (), &tr); - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) return false; } // now check same height to one side of the bot... - src = pev->origin + g_pGlobals->v_right * 16 + Vector (0, 0, -36 + 45); - dest = src + normal * 32; + src = pev->origin + g_pGlobals->v_right * 16.0f + Vector (0.0f, 0.0f, -36.0f + 45.0f); + dest = src + normal * 32.0f; // trace a line forward at maximum jump height... TraceLine (src, dest, true, GetEntity (), &tr); // if trace hit something, return false - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) goto CheckDuckJump; // now trace from jump height upward to check for obstructions... src = dest; - dest.z = dest.z + 37; + dest.z = dest.z + 37.0f; TraceLine (src, dest, true, GetEntity (), &tr); // if trace hit something, return false - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) return false; // now check same height on the other side of the bot... - src = pev->origin + (-g_pGlobals->v_right * 16) + Vector (0, 0, -36 + 45); - dest = src + normal * 32; + src = pev->origin + (-g_pGlobals->v_right * 16.0f) + Vector (0.0f, 0.0f, -36.0f + 45.0f); + dest = src + normal * 32.0f; // trace a line forward at maximum jump height... TraceLine (src, dest, true, GetEntity (), &tr); // if trace hit something, return false - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) goto CheckDuckJump; // now trace from jump height upward to check for obstructions... src = dest; - dest.z = dest.z + 37; + dest.z = dest.z + 37.0f; TraceLine (src, dest, true, GetEntity (), &tr); // if trace hit something, return false - return tr.flFraction > 1.0; + return tr.flFraction > TRACE_FRACTION_EQ; // here we check if a duck jump would work... CheckDuckJump: // use center of the body first... maximum duck jump height is 62, so check one unit above that (63) - src = pev->origin + Vector (0, 0, -36 + 63); - dest = src + normal * 32; + src = pev->origin + Vector (0.0f, 0.0f, -36.0f + 63.0f); + dest = src + normal * 32.0f; // trace a line forward at maximum jump height... TraceLine (src, dest, true, GetEntity (), &tr); - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) return false; else { // now trace from jump height upward to check for obstructions... src = dest; - dest.z = dest.z + 37; + dest.z = dest.z + 37.0f; TraceLine (src, dest, true, GetEntity (), &tr); // if trace hit something, check duckjump - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) return false; } // now check same height to one side of the bot... - src = pev->origin + g_pGlobals->v_right * 16 + Vector (0, 0, -36 + 63); - dest = src + normal * 32; + src = pev->origin + g_pGlobals->v_right * 16.0f + Vector (0.0f, 0.0f, -36.0f + 63.0f); + dest = src + normal * 32.0f; // trace a line forward at maximum jump height... TraceLine (src, dest, true, GetEntity (), &tr); // if trace hit something, return false - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) return false; // now trace from jump height upward to check for obstructions... src = dest; - dest.z = dest.z + 37; + dest.z = dest.z + 37.0f; TraceLine (src, dest, true, GetEntity (), &tr); // if trace hit something, return false - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) return false; // now check same height on the other side of the bot... - src = pev->origin + (-g_pGlobals->v_right * 16) + Vector (0, 0, -36 + 63); - dest = src + normal * 32; + src = pev->origin + (-g_pGlobals->v_right * 16.0f) + Vector (0.0f, 0.0f, -36.0f + 63.0f); + dest = src + normal * 32.0f; // trace a line forward at maximum jump height... TraceLine (src, dest, true, GetEntity (), &tr); // if trace hit something, return false - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) return false; // now trace from jump height upward to check for obstructions... src = dest; - dest.z = dest.z + 37; + dest.z = dest.z + 37.0f; TraceLine (src, dest, true, GetEntity (), &tr); // if trace hit something, return false - return tr.flFraction > 1.0; + return tr.flFraction > TRACE_FRACTION_EQ; } bool Bot::CanDuckUnder (const Vector &normal) @@ -2838,48 +2819,44 @@ bool Bot::CanDuckUnder (const Vector &normal) Vector baseHeight; // convert current view angle to vectors for TraceLine math... - Vector duck = pev->angles; - duck.x = 0; // reset pitch to 0 (level horizontally) - duck.z = 0; // reset roll to 0 (straight up and down) - - MakeVectors (duck); + MakeVectors (Vector (0.0f, pev->angles.y, 0.0f)); // use center of the body first... if (pev->flags & FL_DUCKING) - baseHeight = pev->origin + Vector (0, 0, -17); + baseHeight = pev->origin + Vector (0.0f, 0.0f, -17.0f); else baseHeight = pev->origin; Vector src = baseHeight; - Vector dest = src + normal * 32; + Vector dest = src + normal * 32.0f; // trace a line forward at duck height... TraceLine (src, dest, true, GetEntity (), &tr); // if trace hit something, return false - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) return false; // now check same height to one side of the bot... - src = baseHeight + g_pGlobals->v_right * 16; - dest = src + normal * 32; + src = baseHeight + g_pGlobals->v_right * 16.0f; + dest = src + normal * 32.0f; // trace a line forward at duck height... TraceLine (src, dest, true, GetEntity (), &tr); // if trace hit something, return false - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) return false; // now check same height on the other side of the bot... - src = baseHeight + (-g_pGlobals->v_right * 16); - dest = src + normal * 32; + src = baseHeight + (-g_pGlobals->v_right * 16.0f); + dest = src + normal * 32.0f; // trace a line forward at duck height... TraceLine (src, dest, true, GetEntity (), &tr); // if trace hit something, return false - return tr.flFraction > 1.0; + return tr.flFraction > TRACE_FRACTION_EQ; } #ifdef DEAD_CODE @@ -2889,16 +2866,16 @@ bool Bot::IsBlockedLeft (void) TraceResult tr; int direction = 48; - if (m_moveSpeed < 0) + if (m_moveSpeed < 0.0f) direction = -48; MakeVectors (pev->angles); // do a trace to the left... - TraceLine (pev->origin, g_pGlobals->v_forward * direction - g_pGlobals->v_right * 48, true, GetEntity (), &tr); + TraceLine (pev->origin, g_pGlobals->v_forward * direction - g_pGlobals->v_right * 48.0f, true, GetEntity (), &tr); // check if the trace hit something... - if (tr.flFraction < 1.0 && strncmp ("func_door", STRING (tr.pHit->v.classname), 9) != 0) + if (tr.flFraction <= TRACE_FRACTION_EQ && strncmp ("func_door", STRING (tr.pHit->v.classname), 9) != 0) return true; // bot's body will hit something return false; @@ -2915,10 +2892,10 @@ bool Bot::IsBlockedRight (void) MakeVectors (pev->angles); // do a trace to the right... - TraceLine (pev->origin, pev->origin + g_pGlobals->v_forward * direction + g_pGlobals->v_right * 48, true, GetEntity (), &tr); + TraceLine (pev->origin, pev->origin + g_pGlobals->v_forward * direction + g_pGlobals->v_right * 48.0f, true, GetEntity (), &tr); // check if the trace hit something... - if ((tr.flFraction < 1.0) && (strncmp ("func_door", STRING (tr.pHit->v.classname), 9) != 0)) + if (tr.flFraction <= TRACE_FRACTION_EQ && (strncmp ("func_door", STRING (tr.pHit->v.classname), 9) != 0)) return true; // bot's body will hit something return false; @@ -2931,10 +2908,10 @@ bool Bot::CheckWallOnLeft (void) TraceResult tr; MakeVectors (pev->angles); - TraceLine (pev->origin, pev->origin - g_pGlobals->v_right * 40, true, GetEntity (), &tr); + TraceLine (pev->origin, pev->origin - g_pGlobals->v_right * 40.0f, true, GetEntity (), &tr); // check if the trace hit something... - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) return true; return false; @@ -2946,10 +2923,10 @@ bool Bot::CheckWallOnRight (void) MakeVectors (pev->angles); // do a trace to the right... - TraceLine (pev->origin, pev->origin + g_pGlobals->v_right * 40, true, GetEntity (), &tr); + TraceLine (pev->origin, pev->origin + g_pGlobals->v_right * 40.0f, true, GetEntity (), &tr); // check if the trace hit something... - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) return true; return false; @@ -2962,39 +2939,39 @@ bool Bot::IsDeadlyDrop (const Vector &to) Vector botPos = pev->origin; TraceResult tr; - Vector move ((to - botPos).ToYaw (), 0, 0); + Vector move ((to - botPos).ToYaw (), 0.0f, 0.0f); MakeVectors (move); Vector direction = (to - botPos).Normalize (); // 1 unit long Vector check = botPos; Vector down = botPos; - down.z = down.z - 1000.0; // straight down 1000 units + down.z = down.z - 1000.0f; // straight down 1000 units TraceHull (check, down, true, head_hull, GetEntity (), &tr); - if (tr.flFraction > 0.036) // We're not on ground anymore? - tr.flFraction = 0.036; + if (tr.flFraction > 0.036f) // We're not on ground anymore? + tr.flFraction = 0.036f; - float lastHeight = tr.flFraction * 1000.0; // height from ground + float lastHeight = tr.flFraction * 1000.0f; // height from ground float distance = (to - check).GetLength (); // distance from goal - while (distance > 16.0) + while (distance > 16.0f) { - check = check + direction * 16.0; // move 10 units closer to the goal... + check = check + direction * 16.0f; // move 10 units closer to the goal... down = check; - down.z = down.z - 1000.0; // straight down 1000 units + down.z = down.z - 1000.0f; // straight down 1000 units TraceHull (check, down, true, head_hull, GetEntity (), &tr); if (tr.fStartSolid) // Wall blocking? return false; - float height = tr.flFraction * 1000.0; // height from ground + float height = tr.flFraction * 1000.0f; // height from ground - if (lastHeight < height - 100) // Drops more than 100 Units? + if (lastHeight < height - 100.0f) // Drops more than 100 Units? return true; lastHeight = height; @@ -3010,16 +2987,6 @@ void Bot::ChangePitch (float speed) // this function turns a bot towards its ideal_pitch float idealPitch = AngleNormalize (pev->idealpitch); - - if (yb_aim_method.GetInt () == 1) - { - // turn to the ideal angle immediately - pev->v_angle.x = idealPitch; - pev->angles.x = -idealPitch / 3; - - return; - } - float curent = AngleNormalize (pev->v_angle.x); // turn from the current v_angle pitch to the idealpitch by selecting @@ -3028,7 +2995,7 @@ void Bot::ChangePitch (float speed) // find the difference in the curent and ideal angle float normalizePitch = AngleNormalize (idealPitch - curent); - if (normalizePitch > 0) + if (normalizePitch > 0.0f) { if (normalizePitch > speed) normalizePitch = speed; @@ -3041,11 +3008,11 @@ void Bot::ChangePitch (float speed) pev->v_angle.x = AngleNormalize (curent + normalizePitch); - if (pev->v_angle.x > 89.9) - pev->v_angle.x = 89.9; + if (pev->v_angle.x > 89.9f) + pev->v_angle.x = 89.9f; - if (pev->v_angle.x < -89.9) - pev->v_angle.x = -89.9; + if (pev->v_angle.x < -89.9f) + pev->v_angle.x = -89.9f; pev->angles.x = -pev->v_angle.x / 3; } @@ -3055,14 +3022,6 @@ void Bot::ChangeYaw (float speed) // this function turns a bot towards its ideal_yaw float idealPitch = AngleNormalize (pev->ideal_yaw); - - if (yb_aim_method.GetInt () == 1) - { - // turn to the ideal angle immediately - pev->angles.y = (pev->v_angle.y = idealPitch); - return; - } - float curent = AngleNormalize (pev->v_angle.y); // turn from the current v_angle yaw to the ideal_yaw by selecting @@ -3071,7 +3030,7 @@ void Bot::ChangeYaw (float speed) // find the difference in the curent and ideal angle float normalizePitch = AngleNormalize (idealPitch - curent); - if (normalizePitch > 0) + if (normalizePitch > 0.0f) { if (normalizePitch > speed) normalizePitch = speed; @@ -3240,8 +3199,8 @@ void Bot::UpdateLookAnglesLowSkill (const Vector &direction, const float delta) const float noTargetRatio = 0.3f; const float offsetDelay = 1.2f; - Vector stiffness = nullvec; - Vector randomize = nullvec; + Vector stiffness; + Vector randomize; m_idealAngles = direction.Get2D (); m_idealAngles.ClampAngles (); @@ -3251,21 +3210,21 @@ void Bot::UpdateLookAnglesLowSkill (const Vector &direction, const float delta) m_playerTargetTime = GetWorldTime (); m_randomizedIdealAngles = m_idealAngles; - stiffness = spring * (0.2 + (m_difficulty * 25) / 125.0); + stiffness = spring * (0.2f + (m_difficulty * 25) / 125.0f); } else { // is it time for bot to randomize the aim direction again (more often where moving) ? - if (m_randomizeAnglesTime < GetWorldTime () && ((pev->velocity.GetLength () > 1.0 && m_angularDeviation.GetLength () < 5.0) || m_angularDeviation.GetLength () < 1.0)) + if (m_randomizeAnglesTime < GetWorldTime () && ((pev->velocity.GetLength () > 1.0f && m_angularDeviation.GetLength () < 5.0f) || m_angularDeviation.GetLength () < 1.0f)) { // is the bot standing still ? - if (pev->velocity.GetLength () < 1.0) - randomize = randomization * 0.2; // randomize less + if (pev->velocity.GetLength () < 1.0f) + randomize = randomization * 0.2f; // randomize less else randomize = randomization; // randomize targeted location a bit (slightly towards the ground) - m_randomizedIdealAngles = m_idealAngles + Vector (Random.Float (-randomize.x * 0.5, randomize.x * 1.5), Random.Float (-randomize.y, randomize.y), 0); + m_randomizedIdealAngles = m_idealAngles + Vector (Random.Float (-randomize.x * 0.5f, randomize.x * 1.5f), Random.Float (-randomize.y, randomize.y), 0.0f); // set next time to do this m_randomizeAnglesTime = GetWorldTime () + Random.Float (0.4f, offsetDelay); @@ -3273,21 +3232,21 @@ void Bot::UpdateLookAnglesLowSkill (const Vector &direction, const float delta) float stiffnessMultiplier = noTargetRatio; // take in account whether the bot was targeting someone in the last N seconds - if (GetWorldTime () - (m_playerTargetTime + offsetDelay) < noTargetRatio * 10.0) + if (GetWorldTime () - (m_playerTargetTime + offsetDelay) < noTargetRatio * 10.0f) { - stiffnessMultiplier = 1.0 - (GetWorldTime () - m_timeLastFired) * 0.1; + stiffnessMultiplier = 1.0f - (GetWorldTime () - m_timeLastFired) * 0.1f; // don't allow that stiffness multiplier less than zero - if (stiffnessMultiplier < 0.0) - stiffnessMultiplier = 0.5; + if (stiffnessMultiplier < 0.0f) + stiffnessMultiplier = 0.5f; } // also take in account the remaining deviation (slow down the aiming in the last 10°) - stiffnessMultiplier *= m_angularDeviation.GetLength () * 0.1 * 0.5; + stiffnessMultiplier *= m_angularDeviation.GetLength () * 0.1f * 0.5f; // but don't allow getting below a certain value - if (stiffnessMultiplier < 0.35) - stiffnessMultiplier = 0.35; + if (stiffnessMultiplier < 0.35f) + stiffnessMultiplier = 0.35f; stiffness = spring * stiffnessMultiplier; // increasingly slow aim } @@ -3316,7 +3275,7 @@ void Bot::SetStrafeSpeed (const Vector &moveDir, float strafeSpeed) const Vector &los = (moveDir - pev->origin).Normalize2D (); float dot = los | g_pGlobals->v_forward.Get2D (); - if (dot > 0 && !CheckWallOnRight ()) + if (dot > 0.0f && !CheckWallOnRight ()) m_strafeSpeed = strafeSpeed; else if (!CheckWallOnLeft ()) m_strafeSpeed = -strafeSpeed; diff --git a/source/netmsg.cpp b/source/netmsg.cpp index d06f200..5605827 100644 --- a/source/netmsg.cpp +++ b/source/netmsg.cpp @@ -291,7 +291,7 @@ void NetworkMsg::Execute (void *p) if (bot != NULL && IsAlive (bot->GetEntity ()) && GetTeam (bot->GetEntity ()) == GetTeam (victim) && IsVisible (killer->v.origin, bot->GetEntity ()) && IsEntityNull (bot->m_enemy) && GetTeam (killer) != GetTeam (victim)) { - bot->m_actualReactionTime = 0.0; + bot->m_actualReactionTime = 0.0f; bot->m_seeEnemyTime = GetWorldTime (); bot->m_enemy = killer; bot->m_lastEnemy = killer; diff --git a/source/support.cpp b/source/support.cpp index 4a2c2ab..fbdbea1 100644 --- a/source/support.cpp +++ b/source/support.cpp @@ -130,10 +130,10 @@ bool IsVisible (const Vector &origin, edict_t *ent) TraceResult tr; TraceLine (ent->v.origin + ent->v.view_ofs, origin, true, true, ent, &tr); - if (tr.flFraction != 1.0) - return false; // line of sight is not established + if (tr.flFraction > TRACE_FRACTION_EQ) + return true; - return true; // line of sight is valid. + return false; } Vector GetEntityOrigin (edict_t *ent) @@ -142,10 +142,10 @@ Vector GetEntityOrigin (edict_t *ent) // entity that has a bounding box has its center at the center of the bounding box itself. if (IsEntityNull (ent)) - return nullvec; + return Vector::GetZero (); - if (ent->v.origin == nullvec) - return ent->v.absmin + ent->v.size * 0.5; + if (ent->v.origin.IsZero ()) + return ent->v.absmin + ent->v.size * 0.5f; return ent->v.origin; } @@ -224,7 +224,7 @@ void DecalTrace (entvars_t *pev, TraceResult *trace, int logotypeIndex) if (decalIndex < 0) decalIndex = (*g_engfuncs.pfnDecalIndex) ("{lambda06"); - if (trace->flFraction == 1.0) + if (trace->flFraction > TRACE_FRACTION_EQ) return; if (!IsEntityNull (trace->pHit)) @@ -745,14 +745,14 @@ void RoundInit (void) waypoints.ClearGoalScore (); g_bombSayString = false; - g_timeBombPlanted = 0.0; - g_timeNextBombUpdate = 0.0; + g_timeBombPlanted = 0.0f; + g_timeNextBombUpdate = 0.0f; g_leaderChoosen[TEAM_CF] = false; g_leaderChoosen[TEAM_TF] = false; - g_lastRadioTime[0] = 0.0; - g_lastRadioTime[1] = 0.0; + g_lastRadioTime[0] = 0.0f; + g_lastRadioTime[1] = 0.0f; g_botsCanPause = false; for (int i = 0; i < TASK_MAX; i++) @@ -762,8 +762,8 @@ void RoundInit (void) // calculate the round mid/end in world time g_timeRoundStart = GetWorldTime () + mp_freezetime.GetFloat (); - g_timeRoundMid = g_timeRoundStart + mp_roundtime.GetFloat () * 60 * 0.5f; - g_timeRoundEnd = g_timeRoundStart + mp_roundtime.GetFloat () * 60; + g_timeRoundMid = g_timeRoundStart + mp_roundtime.GetFloat () * 60.0f * 0.5f; + g_timeRoundEnd = g_timeRoundStart + mp_roundtime.GetFloat () * 60.0f; } int GetWeaponPenetrationPower (int id) @@ -877,7 +877,6 @@ void ChartPrint (const char *format, ...) WRITE_BYTE (HUD_PRINTTALK); WRITE_STRING (string); MESSAGE_END (); - } void ClientPrint (edict_t *ent, int dest, const char *format, ...) @@ -978,7 +977,7 @@ void CheckWelcomeMessage (void) // the purpose of this function, is to send quick welcome message, to the listenserver entity. static bool alreadyReceived = !yb_listenserver_welcome.GetBool (); - static float receiveTime = 0.0; + static float receiveTime = 0.0f; if (alreadyReceived) return; @@ -1004,9 +1003,9 @@ void CheckWelcomeMessage (void) sentences.Push ("warning, medical attention required"); if (IsAlive (g_hostEntity) && !alreadyReceived && receiveTime < 1.0 && (g_numWaypoints > 0 ? g_isCommencing : true)) - receiveTime = GetWorldTime () + 4.0; // receive welcome message in four seconds after game has commencing + receiveTime = GetWorldTime () + 4.0f; // receive welcome message in four seconds after game has commencing - if (receiveTime > 0.0 && receiveTime < GetWorldTime () && !alreadyReceived && (g_numWaypoints > 0 ? g_isCommencing : true)) + if (receiveTime > 0.0f && receiveTime < GetWorldTime () && !alreadyReceived && (g_numWaypoints > 0 ? g_isCommencing : true)) { ServerCommand ("speak \"%s\"", const_cast (sentences.GetRandomElement ().GetBuffer ())); @@ -1026,10 +1025,10 @@ void CheckWelcomeMessage (void) WRITE_BYTE (Random.Long (230, 255)); WRITE_BYTE (Random.Long (230, 255)); WRITE_BYTE (200); - WRITE_SHORT (FixedUnsigned16 (0.0078125, 1 << 8)); - WRITE_SHORT (FixedUnsigned16 (2, 1 << 8)); - WRITE_SHORT (FixedUnsigned16 (6, 1 << 8)); - WRITE_SHORT (FixedUnsigned16 (0.1, 1 << 8)); + WRITE_SHORT (FixedUnsigned16 (0.0078125f, 1 << 8)); + WRITE_SHORT (FixedUnsigned16 (2.0f, 1 << 8)); + WRITE_SHORT (FixedUnsigned16 (6.0f, 1 << 8)); + WRITE_SHORT (FixedUnsigned16 (0.1f, 1 << 8)); WRITE_STRING (FormatBuffer ("\nServer is running YaPB v%s (Build: %u)\nDeveloped by %s\n\n%s", PRODUCT_VERSION, GenerateBuildNumber (), PRODUCT_AUTHOR, waypoints.GetInfo ())); MESSAGE_END (); @@ -1059,7 +1058,7 @@ void DetectCSVersion (void) void PlaySound (edict_t *ent, const char *name) { // TODO: make this obsolete - EMIT_SOUND_DYN2 (ent, CHAN_WEAPON, name, 1.0, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN2 (ent, CHAN_WEAPON, name, 1.0f, ATTN_NORM, 0, 100.0f); return; } @@ -1163,12 +1162,16 @@ void AddLogEntry (bool outputToConsole, int logLevel, const char *format, ...) if (logLevel == LL_FATAL) { + bots.RemoveAll (); + FreeLibraryMemory (); + #if defined (PLATFORM_WIN32) + DestroyWindow (GetForegroundWindow ()); MessageBoxA (GetActiveWindow (), buffer, "YaPB Error", MB_ICONSTOP); #else printf ("%s", buffer); #endif - FreeLibraryMemory (); + #if defined (PLATFORM_WIN32) _exit (1); @@ -1228,7 +1231,7 @@ bool FindNearestPlayer (void **pvHolder, edict_t *to, float searchDistance, bool // be filled with bot pointer, else with edict pointer(!). edict_t *survive = NULL; // pointer to temporaly & survive entity - float nearestPlayer = 4096.0; // nearest player + float nearestPlayer = 4096.0f; // nearest player int toTeam = GetTeam (to); @@ -1299,50 +1302,50 @@ void SoundAttachToClients (edict_t *ent, const char *sample, float volume) if (strncmp ("player/bhit_flesh", sample, 17) == 0 || strncmp ("player/headshot", sample, 15) == 0) { // hit/fall sound? - client->hearingDistance = 768.0 * volume; - client->timeSoundLasting = GetWorldTime () + 0.5; + client->hearingDistance = 768.0f * volume; + client->timeSoundLasting = GetWorldTime () + 0.5f; client->soundPosition = origin; } else if (strncmp ("items/gunpickup", sample, 15) == 0) { // weapon pickup? - client->hearingDistance = 768.0 * volume; - client->timeSoundLasting = GetWorldTime () + 0.5; + client->hearingDistance = 768.0f * volume; + client->timeSoundLasting = GetWorldTime () + 0.5f; client->soundPosition = origin; } else if (strncmp ("weapons/zoom", sample, 12) == 0) { // sniper zooming? - client->hearingDistance = 512.0 * volume; - client->timeSoundLasting = GetWorldTime () + 0.1; + client->hearingDistance = 512.0f * volume; + client->timeSoundLasting = GetWorldTime () + 0.1f; client->soundPosition = origin; } else if (strncmp ("items/9mmclip", sample, 13) == 0) { // ammo pickup? - client->hearingDistance = 512.0 * volume; - client->timeSoundLasting = GetWorldTime () + 0.1; + client->hearingDistance = 512.0f * volume; + client->timeSoundLasting = GetWorldTime () + 0.1f; client->soundPosition = origin; } else if (strncmp ("hostage/hos", sample, 11) == 0) { // CT used hostage? - client->hearingDistance = 1024.0 * volume; - client->timeSoundLasting = GetWorldTime () + 5.0; + client->hearingDistance = 1024.0f * volume; + client->timeSoundLasting = GetWorldTime () + 5.0f; client->soundPosition = origin; } else if (strncmp ("debris/bustmetal", sample, 16) == 0 || strncmp ("debris/bustglass", sample, 16) == 0) { // broke something? - client->hearingDistance = 1024.0 * volume; - client->timeSoundLasting = GetWorldTime () + 2.0; + client->hearingDistance = 1024.0f * volume; + client->timeSoundLasting = GetWorldTime () + 2.0f; client->soundPosition = origin; } else if (strncmp ("doors/doormove", sample, 14) == 0) { // someone opened a door - client->hearingDistance = 1024.0 * volume; - client->timeSoundLasting = GetWorldTime () + 3.0; + client->hearingDistance = 1024.0f * volume; + client->timeSoundLasting = GetWorldTime () + 3.0f; client->soundPosition = origin; } } diff --git a/source/waypoint.cpp b/source/waypoint.cpp index 76d3f5a..9009ac5 100644 --- a/source/waypoint.cpp +++ b/source/waypoint.cpp @@ -18,9 +18,9 @@ void Waypoint::Init (void) { // this function initialize the waypoint structures.. - m_learnVelocity = nullvec; - m_learnPosition = nullvec; - m_lastWaypoint = nullvec; + m_learnVelocity.Zero (); + m_learnPosition.Zero (); + m_lastWaypoint.Zero (); // have any waypoint path nodes been allocated yet? if (m_waypointPaths) @@ -32,7 +32,6 @@ void Waypoint::Init (void) } } g_numWaypoints = 0; - m_lastWaypoint = nullvec; } void Waypoint::AddPath (short int addIndex, short int pathIndex, float distance) @@ -149,13 +148,13 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin) int index = -1, i; float distance; - Vector forward = nullvec; + Vector forward; Path *path = NULL; bool placeNew = true; Vector newOrigin = waypointOrigin; - if (waypointOrigin == nullvec) + if (waypointOrigin.IsZero ()) newOrigin = g_hostEntity->v.origin; if (bots.GetBotsNum () > 0) @@ -166,7 +165,7 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin) switch (flags) { case 6: - index = FindNearest (g_hostEntity->v.origin, 50.0); + index = FindNearest (g_hostEntity->v.origin, 50.0f); if (index != -1) { @@ -179,7 +178,7 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin) } MakeVectors (g_hostEntity->v.v_angle); - forward = g_hostEntity->v.origin + g_hostEntity->v.view_ofs + g_pGlobals->v_forward * 640; + forward = g_hostEntity->v.origin + g_hostEntity->v.view_ofs + g_pGlobals->v_forward * 640.0f; path->campEndX = forward.x; path->campEndY = forward.y; @@ -190,19 +189,19 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin) return; case 9: - index = FindNearest (g_hostEntity->v.origin, 50.0); + index = FindNearest (g_hostEntity->v.origin, 50.0f); if (index != -1) { distance = (m_paths[index]->origin - g_hostEntity->v.origin).GetLength (); - if (distance < 50) + if (distance < 50.0f) { placeNew = false; path = m_paths[index]; if (flags == 9) - path->origin = (path->origin + m_learnPosition) / 2; + path->origin = (path->origin + m_learnPosition) * 0.5f; } } else @@ -210,13 +209,13 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin) break; case 10: - index = FindNearest (g_hostEntity->v.origin, 50.0); + index = FindNearest (g_hostEntity->v.origin, 50.0f); if (index != -1 && m_paths[index] != NULL) { distance = (m_paths[index]->origin - g_hostEntity->v.origin).GetLength (); - if (distance < 50) + if (distance < 50.0f) { placeNew = false; path = m_paths[index]; @@ -227,7 +226,7 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin) flags += path->connectionFlags[i]; if (flags == 0) - path->origin = (path->origin + g_hostEntity->v.origin) * 0.5; + path->origin = (path->origin + g_hostEntity->v.origin) * 0.5f; } } break; @@ -255,10 +254,10 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin) // store the origin (location) of this waypoint path->origin = newOrigin; - path->campEndX = 0; - path->campEndY = 0; - path->campStartX = 0; - path->campStartY = 0; + path->campEndX = 0.0f; + path->campEndY = 0.0f; + path->campStartX = 0.0f; + path->campStartY = 0.0f; for (i = 0; i < MAX_PATH_INDEX; i++) { @@ -266,7 +265,7 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin) path->distances[i] = 0; path->connectionFlags[i] = 0; - path->connectionVelocity[i] = nullvec; + path->connectionVelocity[i].Zero (); } // store the last used waypoint for the auto waypoint code... @@ -306,7 +305,7 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin) path->flags |= FLAG_LADDER; MakeVectors (g_hostEntity->v.v_angle); - forward = g_hostEntity->v.origin + g_hostEntity->v.view_ofs + g_pGlobals->v_forward * 640; + forward = g_hostEntity->v.origin + g_hostEntity->v.view_ofs + g_pGlobals->v_forward * 640.0f; path->campStartY = forward.y; } else if (m_isOnLadder) @@ -337,7 +336,7 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin) path->flags |= FLAG_CAMP; MakeVectors (g_hostEntity->v.v_angle); - forward = g_hostEntity->v.origin + g_hostEntity->v.view_ofs + g_pGlobals->v_forward * 640; + forward = g_hostEntity->v.origin + g_hostEntity->v.view_ofs + g_pGlobals->v_forward * 640.0f; path->campStartX = forward.x; path->campStartY = forward.y; @@ -351,7 +350,7 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin) // Ladder waypoints need careful connections if (path->flags & FLAG_LADDER) { - float minDistance = 9999.0; + float minDistance = 9999.0f; int destIndex = -1; TraceResult tr; @@ -368,7 +367,7 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin) // check if the waypoint is reachable from the new one TraceLine (newOrigin, m_paths[i]->origin, true, g_hostEntity, &tr); - if (tr.flFraction == 1.0 && fabs (newOrigin.x - m_paths[i]->origin.x) < 64 && fabs (newOrigin.y - m_paths[i]->origin.y) < 64 && fabs (newOrigin.z - m_paths[i]->origin.z) < g_autoPathDistance) + if (tr.flFraction > TRACE_FRACTION_EQ && fabs (newOrigin.x - m_paths[i]->origin.x) < 64.0f && fabs (newOrigin.y - m_paths[i]->origin.y) < 64.0f && fabs (newOrigin.z - m_paths[i]->origin.z) < g_autoPathDistance) { distance = (m_paths[i]->origin - newOrigin).GetLength (); @@ -446,7 +445,7 @@ void Waypoint::Delete (void) if (bots.GetBotsNum () > 0) bots.RemoveAll (); - int index = FindNearest (g_hostEntity->v.origin, 50.0); + int index = FindNearest (g_hostEntity->v.origin, 50.0f); if (index == -1) return; @@ -467,7 +466,7 @@ void Waypoint::Delete (void) path->index[j] = -1; // unassign this path path->connectionFlags[j] = 0; path->distances[j] = 0; - path->connectionVelocity[j] = nullvec; + path->connectionVelocity[j].Zero (); } } } @@ -504,7 +503,7 @@ void Waypoint::ToggleFlags (int toggleFlag) { // this function allow manually changing flags - int index = FindNearest (g_hostEntity->v.origin, 50.0); + int index = FindNearest (g_hostEntity->v.origin, 50.0f); if (index != -1) { @@ -530,7 +529,7 @@ void Waypoint::SetRadius (int radius) { // this function allow manually setting the zone radius - int index = FindNearest (g_hostEntity->v.origin, 50.0); + int index = FindNearest (g_hostEntity->v.origin, 50.0f); if (index != -1) { @@ -558,27 +557,27 @@ int Waypoint::GetFacingIndex (void) // this function finds waypoint the user is pointing at. int pointedIndex = -1; - float viewCone[3] = {0.0, 0.0, 0.0}; + float viewCone[3] = {0.0f, 0.0f, 0.0f}; // find the waypoint the user is pointing at for (int i = 0; i < g_numWaypoints; i++) { - if ((m_paths[i]->origin - g_hostEntity->v.origin).GetLengthSquared () > 250000) + if ((m_paths[i]->origin - g_hostEntity->v.origin).GetLengthSquared () > 250000.0f) continue; // get the current view cone viewCone[0] = GetShootingConeDeviation (g_hostEntity, &m_paths[i]->origin); - Vector bound = m_paths[i]->origin - Vector (0, 0, (m_paths[i]->flags & FLAG_CROUCH) ? 8 : 15); + Vector bound = m_paths[i]->origin - Vector (0.0f, 0.0f, (m_paths[i]->flags & FLAG_CROUCH) ? 8.0f : 15.0f); // get the current view cone viewCone[1] = GetShootingConeDeviation (g_hostEntity, &bound); - bound = m_paths[i]->origin + Vector (0, 0, (m_paths[i]->flags & FLAG_CROUCH) ? 8 : 15); + bound = m_paths[i]->origin + Vector (0.0f, 0.0f, (m_paths[i]->flags & FLAG_CROUCH) ? 8.0f : 15.0f); // get the current view cone viewCone[2] = GetShootingConeDeviation (g_hostEntity, &bound); // check if we can see it - if (viewCone[0] < 0.998 && viewCone[1] < 0.997 && viewCone[2] < 0.997) + if (viewCone[0] < 0.998f && viewCone[1] < 0.997f && viewCone[2] < 0.997f) continue; pointedIndex = i; @@ -590,7 +589,7 @@ void Waypoint::CreatePath (char dir) { // this function allow player to manually create a path from one waypoint to another - int nodeFrom = FindNearest (g_hostEntity->v.origin, 50.0); + int nodeFrom = FindNearest (g_hostEntity->v.origin, 50.0f); if (nodeFrom == -1) { @@ -637,7 +636,7 @@ void Waypoint::DeletePath (void) { // this function allow player to manually remove a path from one waypoint to another - int nodeFrom = FindNearest (g_hostEntity->v.origin, 50.0); + int nodeFrom = FindNearest (g_hostEntity->v.origin, 50.0f); int index = 0; if (nodeFrom == -1) @@ -664,10 +663,10 @@ void Waypoint::DeletePath (void) { g_waypointsChanged = true; - m_paths[nodeFrom]->index[index] = -1; // unassign this path - m_paths[nodeFrom]->connectionFlags[index] = 0; - m_paths[nodeFrom]->connectionVelocity[index] = nullvec; + m_paths[nodeFrom]->index[index] = -1; // unassigns this path m_paths[nodeFrom]->distances[index] = 0; + m_paths[nodeFrom]->connectionFlags[index] = 0; + m_paths[nodeFrom]->connectionVelocity[index].Zero (); PlaySound (g_hostEntity, "weapons/mine_activate.wav"); return; @@ -686,10 +685,11 @@ void Waypoint::DeletePath (void) g_waypointsChanged = true; m_paths[nodeFrom]->index[index] = -1; // unassign this path - m_paths[nodeFrom]->connectionFlags[index] = 0; - m_paths[nodeFrom]->connectionVelocity[index] = nullvec; m_paths[nodeFrom]->distances[index] = 0; + m_paths[nodeFrom]->connectionFlags[index] = 0; + m_paths[nodeFrom]->connectionVelocity[index].Zero (); + PlaySound (g_hostEntity, "weapons/mine_activate.wav"); return; } @@ -699,7 +699,7 @@ void Waypoint::DeletePath (void) void Waypoint::CacheWaypoint (void) { - int node = FindNearest (g_hostEntity->v.origin, 50.0); + int node = FindNearest (g_hostEntity->v.origin, 50.0f); if (node == -1) { @@ -724,7 +724,7 @@ void Waypoint::CalculateWayzone (int index) if ((path->flags & (FLAG_LADDER | FLAG_GOAL | FLAG_CAMP | FLAG_RESCUE | FLAG_CROUCH)) || m_learnJumpWaypoint) { - path->radius = 0; + path->radius = 0.0f; return; } @@ -732,7 +732,7 @@ void Waypoint::CalculateWayzone (int index) { if (path->index[i] != -1 && (m_paths[path->index[i]]->flags & FLAG_LADDER)) { - path->radius = 0; + path->radius = 0.0f; return; } } @@ -740,14 +740,14 @@ void Waypoint::CalculateWayzone (int index) for (int scanDistance = 16; scanDistance < 128; scanDistance += 16) { start = path->origin; - MakeVectors (nullvec); + MakeVectors (Vector::GetZero ()); direction = g_pGlobals->v_forward * scanDistance; direction = direction.ToAngles (); path->radius = scanDistance; - for (float circleRadius = 0.0; circleRadius < 180.0; circleRadius += 5) + for (float circleRadius = 0.0f; circleRadius < 180.0f; circleRadius += 5.0f) { MakeVectors (direction); @@ -756,55 +756,55 @@ void Waypoint::CalculateWayzone (int index) TraceHull (radiusStart, radiusEnd, true, head_hull, NULL, &tr); - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) { TraceLine (radiusStart, radiusEnd, true, NULL, &tr); if (FClassnameIs (tr.pHit, "func_door") || FClassnameIs (tr.pHit, "func_door_rotating")) { - path->radius = 0; + path->radius = 0.0f; wayBlocked = true; break; } wayBlocked = true; - path->radius -= 16; + path->radius -= 16.0f; break; } - Vector dropStart = start + (g_pGlobals->v_forward * scanDistance); - Vector dropEnd = dropStart - Vector (0, 0, scanDistance + 60); + Vector dropStart = start + g_pGlobals->v_forward * scanDistance; + Vector dropEnd = dropStart - Vector (0.0f, 0.0f, scanDistance + 60.0f); TraceHull (dropStart, dropEnd, true, head_hull, NULL, &tr); - if (tr.flFraction >= 1.0) + if (tr.flFraction > TRACE_FRACTION_EQ) { wayBlocked = true; - path->radius -= 16; + path->radius -= 16.0f; break; } - dropStart = start - (g_pGlobals->v_forward * scanDistance); - dropEnd = dropStart - Vector (0, 0, scanDistance + 60); + dropStart = start - g_pGlobals->v_forward * scanDistance; + dropEnd = dropStart - Vector (0.0f, 0.0f, scanDistance + 60.0f); TraceHull (dropStart, dropEnd, true, head_hull, NULL, &tr); - if (tr.flFraction >= 1.0) + if (tr.flFraction > TRACE_FRACTION_EQ) { wayBlocked = true; - path->radius -= 16; + path->radius -= 16.0f; break; } - radiusEnd.z += 34; + radiusEnd.z += 34.0f; TraceHull (radiusStart, radiusEnd, true, head_hull, NULL, &tr); - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) { wayBlocked = true; - path->radius -= 16; + path->radius -= 16.0f; break; } @@ -813,10 +813,10 @@ void Waypoint::CalculateWayzone (int index) if (wayBlocked) break; } - path->radius -= 16; + path->radius -= 16.0f; - if (path->radius < 0) - path->radius = 0; + if (path->radius < 0.0f) + path->radius = 0.0f; } void Waypoint::SaveExperienceTab (void) @@ -1188,8 +1188,8 @@ bool Waypoint::Load (void) g_waypointsChanged = false; g_highestKills = 1; - m_pathDisplayTime = 0.0; - m_arrowDisplayTime = 0.0; + m_pathDisplayTime = 0.0f; + m_arrowDisplayTime = 0.0f; InitVisibilityTab (); InitExperienceTab (); @@ -1278,7 +1278,7 @@ bool Waypoint::Reachable (Bot *bot, int index) TraceLine (src, dest, true, bot->GetEntity (), &tr); // if waypoint is visible from current position (even behind head)... - if (tr.flFraction >= 1.0) + if (tr.flFraction > TRACE_FRACTION_EQ) { if (bot->pev->waterlevel == 2 || bot->pev->waterlevel == 3) return true; @@ -1286,7 +1286,7 @@ bool Waypoint::Reachable (Bot *bot, int index) float distance2D = (dest - src).GetLength2D (); // is destination waypoint higher that source (62 is max jump height), or destination waypoint higher that source - if (((dest.z > src.z + 62.0 || dest.z < src.z - 100.0f) && (!(m_paths[index]->flags & FLAG_LADDER))) || distance2D >= 120.0f) + if (((dest.z > src.z + 62.0f || dest.z < src.z - 100.0f) && (!(m_paths[index]->flags & FLAG_LADDER))) || distance2D >= 120.0f) return false; // unable to reach this one return true; @@ -1314,14 +1314,14 @@ bool Waypoint::IsNodeReachable (const Vector &src, const Vector &destination) TraceLine (src, destination, ignore_monsters, g_hostEntity, &tr); // if waypoint is visible from current position (even behind head)... - if (tr.flFraction >= 1.0 || strncmp ("func_door", STRING (tr.pHit->v.classname), 9) == 0) + if (tr.flFraction > TRACE_FRACTION_EQ || strncmp ("func_door", STRING (tr.pHit->v.classname), 9) == 0) { // if it's a door check if nothing blocks behind if (strncmp ("func_door", STRING (tr.pHit->v.classname), 9) == 0) { TraceLine (tr.vecEndPos, destination, ignore_monsters, tr.pHit, &tr); - if (tr.flFraction < 1.0) + if (tr.flFraction <= TRACE_FRACTION_EQ) return false; } @@ -1330,16 +1330,16 @@ bool Waypoint::IsNodeReachable (const Vector &src, const Vector &destination) return true; // then they're reachable each other // is dest waypoint higher than src? (45 is max jump height) - if (destination.z > src.z + 45.0) + if (destination.z > src.z + 45.0f) { Vector sourceNew = destination; Vector destinationNew = destination; - destinationNew.z = destinationNew.z - 50; // straight down 50 units + destinationNew.z = destinationNew.z - 50.0f; // straight down 50 units TraceLine (sourceNew, destinationNew, ignore_monsters, g_hostEntity, &tr); // check if we didn't hit anything, if not then it's in mid-air - if (tr.flFraction >= 1.0) + if (tr.flFraction > TRACE_FRACTION_EQ) return false; // can't reach this one } @@ -1347,27 +1347,27 @@ bool Waypoint::IsNodeReachable (const Vector &src, const Vector &destination) Vector direction = (destination - src).Normalize(); // 1 unit long Vector check = src, down = src; - down.z = down.z - 1000.0; // straight down 1000 units + down.z = down.z - 1000.0f; // straight down 1000 units TraceLine (check, down, ignore_monsters, g_hostEntity, &tr); - float lastHeight = tr.flFraction * 1000.0; // height from ground + float lastHeight = tr.flFraction * 1000.0f; // height from ground distance = (destination - check).GetLength (); // distance from goal - while (distance > 10.0) + while (distance > 10.0f) { // move 10 units closer to the goal... - check = check + (direction * 10.0); + check = check + (direction * 10.0f); down = check; - down.z = down.z - 1000.0; // straight down 1000 units + down.z = down.z - 1000.0f; // straight down 1000 units TraceLine (check, down, ignore_monsters, g_hostEntity, &tr); - float height = tr.flFraction * 1000.0; // height from ground + float height = tr.flFraction * 1000.0f; // height from ground // is the current height greater than the step height? - if (height < lastHeight - 18.0) + if (height < lastHeight - 18.0f) return false; // can't get there without jumping... lastHeight = height; @@ -1393,13 +1393,13 @@ void Waypoint::InitializeVisibility (void) if (m_paths[m_visibilityIndex]->flags & FLAG_CROUCH) { - sourceDuck.z += 12.0; - sourceStand.z += 18.0 + 28.0; + sourceDuck.z += 12.0f; + sourceStand.z += 18.0f + 28.0f; } else { - sourceDuck.z += -18.0 + 12.0; - sourceStand.z += 28.0; + sourceDuck.z += -18.0f + 12.0f; + sourceStand.z += 28.0f; } uint16 standCount = 0, crouchCount = 0; @@ -1411,7 +1411,7 @@ void Waypoint::InitializeVisibility (void) TraceLine (sourceDuck, dest, true, NULL, &tr); // check if line of sight to object is not blocked (i.e. visible) - if ((tr.flFraction != 1.0) || tr.fStartSolid) + if (tr.flFraction <= TRACE_FRACTION_EQ || tr.fStartSolid) res = 1; else res = 0; @@ -1421,7 +1421,7 @@ void Waypoint::InitializeVisibility (void) TraceLine (sourceStand, dest, true, NULL, &tr); // check if line of sight to object is not blocked (i.e. visible) - if ((tr.flFraction != 1.0) || tr.fStartSolid) + if (tr.flFraction <= TRACE_FRACTION_EQ || tr.fStartSolid) res |= 1; shift = (i % 4) << 1; @@ -1534,7 +1534,7 @@ void Waypoint::Think (void) // find the distance from the last used waypoint float distance = (m_lastWaypoint - g_hostEntity->v.origin).GetLengthSquared (); - if (distance > 16384) + if (distance > 16384.0f) { // check that no other reachable waypoints are nearby... for (int i = 0; i < g_numWaypoints; i++) @@ -1549,7 +1549,7 @@ void Waypoint::Think (void) } // make sure nearest waypoint is far enough away... - if (nearestDistance >= 16384) + if (nearestDistance >= 16384.0f) Add (0); // place a waypoint here } } @@ -1564,7 +1564,7 @@ void Waypoint::Think (void) float distance = (m_paths[i]->origin - g_hostEntity->v.origin).GetLengthSquared (); // check if waypoint is whitin a distance, and is visible - if (distance < 500 * 500 && ((::IsVisible (m_paths[i]->origin, g_hostEntity) && IsInViewCone (m_paths[i]->origin, g_hostEntity)) || !IsAlive (g_hostEntity) || distance < 2500)) + if (distance < GET_SQUARE (500.0f) && ((::IsVisible (m_paths[i]->origin, g_hostEntity) && IsInViewCone (m_paths[i]->origin, g_hostEntity)) || !IsAlive (g_hostEntity) || distance < 2500.0f)) { // check the distance if (distance < nearestDistance) @@ -1573,20 +1573,20 @@ void Waypoint::Think (void) nearestDistance = distance; } - if (m_waypointDisplayTime[i] + 1.0 < GetWorldTime ()) + if (m_waypointDisplayTime[i] + 1.0f < GetWorldTime ()) { - float nodeHeight = 0.0; + float nodeHeight = 0.0f; // check the node height if (m_paths[i]->flags & FLAG_CROUCH) - nodeHeight = 36.0; + nodeHeight = 36.0f; else - nodeHeight = 72.0; + nodeHeight = 72.0f; - float nodeHalfHeight = nodeHeight * 0.5; + float nodeHalfHeight = nodeHeight * 0.5f; // all waypoints are by default are green - Vector nodeColor = nullvec; + Vector nodeColor; // colorize all other waypoints if (m_paths[i]->flags & FLAG_CAMP) @@ -1633,7 +1633,7 @@ void Waypoint::Think (void) if ((m_findWPIndex != -1 && m_findWPIndex < g_numWaypoints) || (m_cacheWaypointIndex != -1 && m_cacheWaypointIndex < g_numWaypoints) || (m_facingAtIndex != -1 && m_facingAtIndex < g_numWaypoints)) { // check for drawing code - if (m_arrowDisplayTime + 0.5 < GetWorldTime ()) + if (m_arrowDisplayTime + 0.5f < GetWorldTime ()) { // finding waypoint - pink arrow if (m_findWPIndex != -1) @@ -1655,18 +1655,18 @@ void Waypoint::Think (void) Path *path = m_paths[nearestIndex]; // draw a paths, camplines and danger directions for nearest waypoint - if (nearestDistance < 4096 && m_pathDisplayTime <= GetWorldTime ()) + if (nearestDistance < 4096.0f && m_pathDisplayTime <= GetWorldTime ()) { - m_pathDisplayTime = GetWorldTime () + 1.0; + m_pathDisplayTime = GetWorldTime () + 1.0f; // draw the camplines if (path->flags & FLAG_CAMP) { - Vector campSourceOrigin = path->origin + Vector (0, 0, 36); + Vector campSourceOrigin = path->origin + Vector (0.0f, 0.0f, 36.0f); // check if it's a source if (path->flags & FLAG_CROUCH) - campSourceOrigin = path->origin + Vector (0, 0, 18); + campSourceOrigin = path->origin + Vector (0.0f, 0.0f, 18.0f); Vector campStartOrigin = Vector (path->campStartX, path->campStartY, campSourceOrigin.z); // camp start Vector campEndOrigin = Vector (path->campEndX, path->campEndY, campSourceOrigin.z); // camp end @@ -1699,31 +1699,31 @@ void Waypoint::Think (void) } // draw the radius circle - Vector origin = (path->flags & FLAG_CROUCH) ? path->origin : path->origin - Vector (0, 0, 18); + Vector origin = (path->flags & FLAG_CROUCH) ? path->origin : path->origin - Vector (0.0f, 0.0f, 18.0f); // if radius is nonzero, draw a full circle - if (path->radius > 0.0) + if (path->radius > 0.0f) { - float squareRoot = sqrtf ((path->radius * path->radius) * 0.5); + float squareRoot = sqrtf (path->radius * path->radius * 0.5f); - DrawLine (g_hostEntity, origin + Vector (path->radius, 0, 0), origin + Vector (squareRoot, -squareRoot, 0), 5, 0, 0, 0, 255, 200, 0, 10); - DrawLine (g_hostEntity, origin + Vector (squareRoot, -squareRoot, 0), origin + Vector (0, -path->radius, 0), 5, 0, 0, 0, 255, 200, 0, 10); + DrawLine (g_hostEntity, origin + Vector (path->radius, 0.0f, 0.0f), origin + Vector (squareRoot, -squareRoot, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10); + DrawLine (g_hostEntity, origin + Vector (squareRoot, -squareRoot, 0.0f), origin + Vector (0.0f, -path->radius, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10); - DrawLine (g_hostEntity, origin + Vector (0, -path->radius, 0), origin + Vector (-squareRoot, -squareRoot, 0), 5, 0, 0, 0, 255, 200, 0, 10); - DrawLine (g_hostEntity, origin + Vector (-squareRoot, -squareRoot, 0), origin + Vector (-path->radius, 0, 0), 5, 0, 0, 0, 255, 200, 0, 10); + DrawLine (g_hostEntity, origin + Vector (0.0f, -path->radius, 0.0f), origin + Vector (-squareRoot, -squareRoot, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10); + DrawLine (g_hostEntity, origin + Vector (-squareRoot, -squareRoot, 0.0f), origin + Vector (-path->radius, 0.0f, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10); - DrawLine (g_hostEntity, origin + Vector (-path->radius, 0, 0), origin + Vector (-squareRoot, squareRoot, 0), 5, 0, 0, 0, 255, 200, 0, 10); - DrawLine (g_hostEntity, origin + Vector (-squareRoot, squareRoot, 0), origin + Vector (0, path->radius, 0), 5, 0, 0, 0, 255, 200, 0, 10); + DrawLine (g_hostEntity, origin + Vector (-path->radius, 0.0f, 0.0f), origin + Vector (-squareRoot, squareRoot, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10); + DrawLine (g_hostEntity, origin + Vector (-squareRoot, squareRoot, 0.0f), origin + Vector (0.0f, path->radius, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10); - DrawLine (g_hostEntity, origin + Vector (0, path->radius, 0), origin + Vector (squareRoot, squareRoot, 0), 5, 0, 0, 0, 255, 200, 0, 10); - DrawLine (g_hostEntity, origin + Vector (squareRoot, squareRoot, 0), origin + Vector (path->radius, 0, 0), 5, 0, 0, 0, 255, 200, 0, 10); + DrawLine (g_hostEntity, origin + Vector (0.0f, path->radius, 0.0f), origin + Vector (squareRoot, squareRoot, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10); + DrawLine (g_hostEntity, origin + Vector (squareRoot, squareRoot, 0.0f), origin + Vector (path->radius, 0.0f, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10); } else { - float squareRoot = sqrtf (32.0); + float squareRoot = sqrtf (32.0f); - DrawLine (g_hostEntity, origin + Vector (squareRoot, -squareRoot, 0), origin + Vector (-squareRoot, squareRoot, 0), 5, 0, 255, 0, 0, 200, 0, 10); - DrawLine (g_hostEntity, origin + Vector (-squareRoot, -squareRoot, 0), origin + Vector (squareRoot, squareRoot, 0), 5, 0, 255, 0, 0, 200, 0, 10); + DrawLine (g_hostEntity, origin + Vector (squareRoot, -squareRoot, 0.0f), origin + Vector (-squareRoot, squareRoot, 0.0f), 5, 0, 255, 0, 0, 200, 0, 10); + DrawLine (g_hostEntity, origin + Vector (-squareRoot, -squareRoot, 0.0f), origin + Vector (squareRoot, squareRoot, 0.0f), 5, 0, 255, 0, 0, 200, 0, 10); } // draw the danger directions @@ -2187,7 +2187,7 @@ void Waypoint::SetGoalVisited (int index) int bombPoint = FindNearest (GetBombPosition ()); Array markAsVisited; - FindInRadius (markAsVisited, 356.0, GetPath (index)->origin); + FindInRadius (markAsVisited, 356.0f, GetPath (index)->origin); IterateArray (markAsVisited, i) { @@ -2228,7 +2228,7 @@ void Waypoint::CreateBasic (void) TraceResult tr; Vector up, down, front, back; - Vector diff = ((ladderLeft - ladderRight) ^ Vector (0, 0, 0)).Normalize () * 15.0; + Vector diff = ((ladderLeft - ladderRight) ^ Vector (0.0f, 0.0f, 0.0f)).Normalize () * 15.0f; front = back = GetEntityOrigin (ent); front = front + diff; // front @@ -2239,29 +2239,29 @@ void Waypoint::CreateBasic (void) TraceHull (down, up, true, point_hull, NULL, &tr); - if (POINT_CONTENTS (up) == CONTENTS_SOLID || tr.flFraction != 1.0) + if (POINT_CONTENTS (up) == CONTENTS_SOLID || tr.flFraction <= TRACE_FRACTION_EQ) { up = down = back; down.z = ent->v.absmax.z; } - TraceHull (down, up - Vector (0, 0, 1000), true, point_hull, NULL, &tr); + TraceHull (down, up - Vector (0.0f, 0.0f, 1000.0f), true, point_hull, NULL, &tr); up = tr.vecEndPos; - Vector pointOrigin = up + Vector (0, 0, 39); + Vector pointOrigin = up + Vector (0.0f, 0.0f, 39.0f); m_isOnLadder = true; do { - if (FindNearest (pointOrigin, 50.0) == -1) + if (FindNearest (pointOrigin, 50.0f) == -1) Add (3, pointOrigin); pointOrigin.z += 160; - } while (pointOrigin.z < down.z - 40); + } while (pointOrigin.z < down.z - 40.0f); - pointOrigin = down + Vector (0, 0, 38); + pointOrigin = down + Vector (0.0f, 0.0f, 38.0f); - if (FindNearest (pointOrigin, 50.0) == -1) + if (FindNearest (pointOrigin, 50.0f) == -1) Add (3, pointOrigin); m_isOnLadder = false; @@ -2272,7 +2272,7 @@ void Waypoint::CreateBasic (void) { Vector origin = GetEntityOrigin (ent); - if (FindNearest (origin, 50) == -1) + if (FindNearest (origin, 50.0f) == -1) Add (0, origin); } @@ -2281,7 +2281,7 @@ void Waypoint::CreateBasic (void) { Vector origin = GetEntityOrigin (ent); - if (FindNearest (origin, 50) == -1) + if (FindNearest (origin, 50.0f) == -1) Add (0, origin); } @@ -2290,7 +2290,7 @@ void Waypoint::CreateBasic (void) { Vector origin = GetEntityOrigin (ent); - if (FindNearest (origin, 50) == -1) + if (FindNearest (origin, 50.0f) == -1) Add (0, origin); } @@ -2299,7 +2299,7 @@ void Waypoint::CreateBasic (void) { Vector origin = GetEntityOrigin (ent); - if (FindNearest (origin, 50) == -1) + if (FindNearest (origin, 50.0f) == -1) Add (4, origin); } @@ -2308,7 +2308,7 @@ void Waypoint::CreateBasic (void) { Vector origin = GetEntityOrigin (ent); - if (FindNearest (origin, 50) == -1) + if (FindNearest (origin, 50.0f) == -1) Add (4, origin); } @@ -2317,7 +2317,7 @@ void Waypoint::CreateBasic (void) { Vector origin = GetEntityOrigin (ent); - if (FindNearest (origin, 50) == -1) + if (FindNearest (origin, 50.0f) == -1) Add (100, origin); } @@ -2326,7 +2326,7 @@ void Waypoint::CreateBasic (void) { Vector origin = GetEntityOrigin (ent); - if (FindNearest (origin, 50) == -1) + if (FindNearest (origin, 50.0f) == -1) Add (100, origin); } @@ -2334,7 +2334,7 @@ void Waypoint::CreateBasic (void) while (!IsEntityNull (ent = FIND_ENTITY_BY_CLASSNAME (ent, "hostage_entity"))) { // if already saved || moving skip it - if ((ent->v.effects & EF_NODRAW) && (ent->v.speed > 0)) + if ((ent->v.effects & EF_NODRAW) && ent->v.speed > 0.0f) continue; Vector origin = GetEntityOrigin (ent); @@ -2348,7 +2348,7 @@ void Waypoint::CreateBasic (void) { Vector origin = GetEntityOrigin (ent); - if (FindNearest (origin, 50) == -1) + if (FindNearest (origin, 50.0f) == -1) Add (100, origin); } @@ -2357,7 +2357,7 @@ void Waypoint::CreateBasic (void) { Vector origin = GetEntityOrigin (ent); - if (FindNearest (origin, 50) == -1) + if (FindNearest (origin, 50.0f) == -1) Add (100, origin); } @@ -2366,7 +2366,7 @@ void Waypoint::CreateBasic (void) { Vector origin = GetEntityOrigin (ent); - if (FindNearest (origin, 50) == -1) + if (FindNearest (origin, 50.0f) == -1) Add (0, origin); } } @@ -2413,7 +2413,7 @@ void Waypoint::SetBombPosition (bool shouldReset) if (shouldReset) { - m_foundBombOrigin = nullvec; + m_foundBombOrigin.Zero (); g_bombPlanted = false; return; @@ -2450,12 +2450,12 @@ int Waypoint::AddGoalScore (int index, int other[4]) { Array left; - if (m_goalsScore[index] < 1024.0) + if (m_goalsScore[index] < 1024.0f) left.Push (index); for (int i = 0; i < 3; i++) { - if (m_goalsScore[other[i]] < 1024.0) + if (m_goalsScore[other[i]] < 1024.0f) left.Push (other[i]); } @@ -2465,11 +2465,11 @@ int Waypoint::AddGoalScore (int index, int other[4]) index = left.GetRandomElement (); if (m_paths[index]->flags & FLAG_GOAL) - m_goalsScore[index] += 384.0; + m_goalsScore[index] += 384.0f; else if (m_paths[index]->flags & (FLAG_CF_ONLY | FLAG_TF_ONLY)) - m_goalsScore[index] += 768.0; + m_goalsScore[index] += 768.0f; else if (m_paths[index]->flags & FLAG_CAMP) - m_goalsScore[index] += 1024.0; + m_goalsScore[index] += 1024.0f; return index; } @@ -2478,7 +2478,7 @@ void Waypoint::ClearGoalScore (void) { // iterate though all waypoints for (int i = 0; i < MAX_WAYPOINTS; i++) - m_goalsScore[i] = 0.0; + m_goalsScore[i] = 0.0f; } Waypoint::Waypoint (void) @@ -2487,7 +2487,7 @@ Waypoint::Waypoint (void) m_endJumpPoint = false; m_redoneVisibility = false; m_learnJumpWaypoint = false; - m_timeJumpStarted = 0.0; + m_timeJumpStarted = 0.0f; m_lastJumpWaypoint = -1; m_cacheWaypointIndex = -1; @@ -2497,8 +2497,8 @@ Waypoint::Waypoint (void) m_isOnLadder = false; - m_pathDisplayTime = 0.0; - m_arrowDisplayTime = 0.0; + m_pathDisplayTime = 0.0f; + m_arrowDisplayTime = 0.0f; m_terrorPoints.RemoveAll (); m_ctPoints.RemoveAll ();