diff --git a/include/core.h b/include/core.h index ba4578e..94252f8 100644 --- a/include/core.h +++ b/include/core.h @@ -1152,6 +1152,7 @@ public: bool m_hasProgressBar; // has progress bar on a HUD bool m_jumpReady; // is double jump ready bool m_canChooseAimDirection; // can choose aiming direction + float m_turnAwayFromFlashbang; // bot turned away from flashbang float m_breakableCheckTime; float m_blindTime; // time when bot is blinded @@ -1471,7 +1472,7 @@ public: int FindFarest (const Vector &origin, float maxDistance = 32.0); int FindNearest (const Vector &origin, float minDistance = 9999.0, int flags = -1); void FindInRadius (const Vector &origin, float radius, int *holdTab, int *count); - void FindInRadius (Array &queueID, float radius, const Vector &origin); + void FindInRadius (Array &radiusHolder, float radius, const Vector &origin); void Add (int flags, const Vector &waypointOrigin = nullvec); void Delete (void); @@ -1646,7 +1647,6 @@ extern int GetWeaponReturn (bool isString, const char *weaponAlias, int weaponIn extern float GetShootingConeDeviation (edict_t *ent, Vector *position); extern float GetWaveLength (const char *fileName); -extern bool TryFileOpen (const char *fileName); extern bool IsDedicatedServer (void); extern bool IsVisible (const Vector &origin, edict_t *ent); extern bool IsAlive (edict_t *ent); diff --git a/include/corelib.h b/include/corelib.h index 8d0e82d..487c4fe 100644 --- a/include/corelib.h +++ b/include/corelib.h @@ -3905,6 +3905,19 @@ public: { return m_handle != NULL; } + +public: + static inline bool Accessible (const String &filename) + { + File fp; + + if (fp.Open (filename, "rb")) + { + fp.Close (); + return true; + } + return false; + } }; // diff --git a/project/yapb.vcxproj b/project/yapb.vcxproj index 120e302..5cb734b 100644 --- a/project/yapb.vcxproj +++ b/project/yapb.vcxproj @@ -187,10 +187,10 @@ ..\mmgr;..\include\engine;..\include;%(AdditionalIncludeDirectories) NDEBUG;WIN32;%(PreprocessorDefinitions) true - Async + false MultiThreaded - Default - true + 16Bytes + false false StreamingSIMDExtensions2 false @@ -211,6 +211,10 @@ false Fast Full + AVXI + AVXI + false + false NDEBUG;%(PreprocessorDefinitions) diff --git a/source/basecode.cpp b/source/basecode.cpp index 8cc4719..1f9f4a5 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -426,16 +426,15 @@ void Bot::AvoidGrenades (void) if (!EntityIsVisible (ent->v.origin) && InFieldOfView (ent->v.origin - EyePosition ()) > pev->fov * 0.5) continue; - // TODO: should be done once for grenade, instead of checking several times - if (m_personality == PERSONALITY_RUSHER && m_difficulty == 4 && strcmp (STRING (ent->v.model) + 9, "flashbang.mdl") == 0) + if (m_turnAwayFromFlashbang < GetWorldTime () && m_personality == PERSONALITY_RUSHER && m_difficulty == 4 && strcmp (STRING (ent->v.model) + 9, "flashbang.mdl") == 0) { - const Vector &position = (GetEntityOrigin (ent) - EyePosition ()).ToAngles (); - // don't look at flash bang if (!(m_states & STATE_SEEING_ENEMY)) { - pev->v_angle.y = AngleNormalize (position.y + 180.0f); + pev->v_angle.y = AngleNormalize ((GetEntityOrigin (ent) - EyePosition ()).ToAngles ().y + 180.0f); + m_canChooseAimDirection = false; + m_turnAwayFromFlashbang = GetWorldTime () + Random.Float (1.0f, 2.0f); } } else if (strcmp (STRING (ent->v.model) + 9, "hegrenade.mdl") == 0) @@ -1223,7 +1222,7 @@ void Bot::CheckMessageQueue (void) } m_buyPending = false; - m_nextBuyTime = GetWorldTime () + Random.Float (0.3, 0.8); + m_nextBuyTime = GetWorldTime () + Random.Float (0.5f, 1.3f); // if bot buying is off then no need to buy if (!yb_botbuy.GetBool ()) @@ -1416,7 +1415,7 @@ bool Bot::IsRestricted (int weaponIndex) // this function checks for weapon restrictions. if (IsNullString (yb_restricted_weapons.GetString ())) - return false; // no banned weapons + return IsRestrictedAMX (weaponIndex); // no banned weapons Array bannedWeapons = String (yb_restricted_weapons.GetString ()).Split (';'); @@ -1522,7 +1521,7 @@ void Bot::PurchaseWeapons (void) // this function does all the work in selecting correct buy menus for most weapons/items WeaponSelect *selectedWeapon = NULL; - m_nextBuyTime = GetWorldTime (); + m_nextBuyTime = GetWorldTime () + Random.Float (0.3f, 0.5f); int count = 0, foundWeapons = 0; int choices[NUM_WEAPONS]; diff --git a/source/chatlib.cpp b/source/chatlib.cpp index 478fe4a..f35a189 100644 --- a/source/chatlib.cpp +++ b/source/chatlib.cpp @@ -49,10 +49,10 @@ void StripTags (char *buffer) { strtrim (buffer); // if so, string is just a tag - int tagLength = 0; + int tagLength = 0; // strip just the tag part... - for (index = 0; index < ARRAYSIZE_HLSDK(tagOpen); index++) + for (index = 0; index < ARRAYSIZE_HLSDK (tagOpen); index++) { fieldStart = strstr (buffer, tagOpen[index]) - buffer; // look for a tag start @@ -75,7 +75,7 @@ void StripTags (char *buffer) for (i = fieldStart; i < length - tagLength; i++) buffer[i] = buffer[i + tagLength]; // overwrite the buffer with the stripped string - + buffer[i] = 0; // terminate the string } } diff --git a/source/combat.cpp b/source/combat.cpp index 46645c9..5ea900e 100644 --- a/source/combat.cpp +++ b/source/combat.cpp @@ -585,6 +585,12 @@ bool Bot::DoFirePause (float distance, FireDelay *fireDelay) return false; } + if (UsesPistol () && distance > 450.0f) + { + m_shootTime = GetWorldTime () + Random.Float (0.15f, 0.4f); + return false; + } + if (m_firePause > GetWorldTime ()) return true; @@ -613,6 +619,8 @@ bool Bot::DoFirePause (float distance, FireDelay *fireDelay) if (m_firePause < GetWorldTime () - 0.4f) m_firePause = GetWorldTime () + Random.Float (0.4f, 0.4f + 0.3f * ((100 - (m_difficulty * 25)) / 100.f)); + m_burstShotsFired = 0; + return true; } @@ -866,7 +874,7 @@ WeaponSelectEnd: pev->button |= IN_ATTACK; m_shootTime = GetWorldTime () + baseDelay + Random.Float (minDelay, maxDelay); - m_zoomCheckTime = GetWorldTime (); + m_zoomCheckTime = GetWorldTime () - 0.09f; } } } diff --git a/source/interface.cpp b/source/interface.cpp index 07c9cfd..ac912d0 100644 --- a/source/interface.cpp +++ b/source/interface.cpp @@ -2054,7 +2054,7 @@ void ServerActivate (edict_t *pentEdictList, int edictCount, int clientMax) // execute main config ServerCommand ("exec addons/yapb/conf/yapb.cfg"); - if (TryFileOpen (FormatBuffer ("%s/maps/%s_yapb.cfg", GetModName (), GetMapName ()))) + if (File::Accessible (FormatBuffer ("%s/maps/%s_yapb.cfg", GetModName (), GetMapName ()))) { ServerCommand ("exec maps/%s_yapb.cfg", GetMapName ()); ServerPrint ("Executing Map-Specific config file"); @@ -3078,7 +3078,7 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t { ModSupport *mod = &s_supportedMods[i]; - if (strcmp (mod->name, GetModName ()) == 0 && TryFileOpen (FormatBuffer ("%s/dlls/%s", mod->name, + if (strcmp (mod->name, GetModName ()) == 0 && File::Accessible (FormatBuffer ("%s/dlls/%s", mod->name, #if defined (PLATFORM_WIN32) mod->winLib #elif defined (PLATFORM_LINUX) diff --git a/source/manager.cpp b/source/manager.cpp index 4df3a36..560b17f 100644 --- a/source/manager.cpp +++ b/source/manager.cpp @@ -818,7 +818,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c memset (&m_ammo, 0, sizeof (m_ammo)); m_currentWeapon = 0; // current weapon is not assigned at start - m_voicePitch = Random.Long (166, 250) * 0.5; // assign voice pitch + m_voicePitch = Random.Long (80, 115); // assign voice pitch // copy them over to the temp level variables m_agressionLevel = m_baseAgressionLevel; @@ -960,6 +960,7 @@ void Bot::NewRound (void) m_isLeader = false; m_hasProgressBar = false; m_canChooseAimDirection = true; + m_turnAwayFromFlashbang = 0.0f; m_timeTeamOrder = 0.0; m_askCheckTime = 0.0; @@ -1059,8 +1060,8 @@ void Bot::NewRound (void) m_currentWeapon = 0; } - m_knifeAttackTime = GetWorldTime () + Random.Float (1.3, 2.6); - m_nextBuyTime = GetWorldTime () + Random.Float (0.6, 1.2); + m_knifeAttackTime = GetWorldTime () + Random.Float (1.3f, 2.6f); + m_nextBuyTime = GetWorldTime () + Random.Float (0.6f, 2.0f); m_buyPending = false; m_inBombZone = false; diff --git a/source/navigate.cpp b/source/navigate.cpp index ce9782b..d1062ae 100644 --- a/source/navigate.cpp +++ b/source/navigate.cpp @@ -659,6 +659,15 @@ bool Bot::DoWaypointNav (void) TraceResult tr, tr2; + // check if we fallen from something + if (IsOnFloor () && m_jumpFinished && m_currentWaypointIndex > 0) + { + const Vector &wptOrg = m_currentPath->origin; + + if ((pev->origin - wptOrg).GetLength2D () <= 100.0f && (wptOrg.z > pev->origin.z + 20.0f)) + m_currentWaypointIndex = -1; + } + // check if we need to find a waypoint... if (m_currentWaypointIndex == -1) { diff --git a/source/support.cpp b/source/support.cpp index a76c0ed..55c29bf 100644 --- a/source/support.cpp +++ b/source/support.cpp @@ -830,21 +830,6 @@ bool IsDedicatedServer (void) return (IS_DEDICATED_SERVER () > 0); // ask engine for this } -bool TryFileOpen (const char *fileName) -{ - // this function tests if a file exists by attempting to open it - - File fp; - - // check if got valid handle - if (fp.Open (fileName, "rb")) - { - fp.Close (); - return true; - } - return false; -} - void ServerPrint (const char *format, ...) { va_list ap; @@ -961,7 +946,7 @@ extern bool OpenConfig(const char *fileName, const char *errorIfNotExists, File const char *languageDependantConfigFile = FormatBuffer ("%s/addons/yapb/conf/lang/%s_%s", GetModName (), yb_language.GetString (), fileName); // check is file is exists for this language - if (TryFileOpen (languageDependantConfigFile)) + if (File::Accessible (languageDependantConfigFile)) outFile->Open (languageDependantConfigFile, "rt"); else outFile->Open (FormatBuffer ("%s/addons/yapb/conf/lang/en_%s", GetModName (), fileName), "rt"); diff --git a/source/waypoint.cpp b/source/waypoint.cpp index ec47286..7b9b7f9 100644 --- a/source/waypoint.cpp +++ b/source/waypoint.cpp @@ -149,12 +149,12 @@ void Waypoint::FindInRadius (const Vector &origin, float radius, int *holdTab, i *count -= 1; } -void Waypoint::FindInRadius (Array &queueID, float radius, const Vector &origin) +void Waypoint::FindInRadius (Array &radiusHolder, float radius, const Vector &origin) { for (int i = 0; i < g_numWaypoints; i++) { if ((m_paths[i]->origin - origin).GetLength () <= radius) - queueID.Push (i); + radiusHolder.Push (i); } } @@ -1262,7 +1262,7 @@ String Waypoint::CheckSubfolderFile (void) returnFile = FormatBuffer ("%s%s%s.pwf", GetWaypointDir (), returnFile.GetBuffer (), GetMapName ()); - if (TryFileOpen (returnFile)) + if (File::Accessible (returnFile)) return returnFile; return FormatBuffer ("%s%s.pwf", GetWaypointDir (), GetMapName ()); @@ -2412,7 +2412,7 @@ void Waypoint::EraseFromHardDisk (void) for (int i = 0; i < 4; i++) { - if (TryFileOpen (const_cast (deleteList[i].GetBuffer ()))) + if (File::Accessible (const_cast (deleteList[i].GetBuffer ()))) { unlink (deleteList[i].GetBuffer ()); AddLogEntry (true, LL_DEFAULT, "File %s, has been deleted from the hard disk", deleteList[i].GetBuffer ());