Sound Cache improvements
This commit is contained in:
parent
e1b517935a
commit
e296e67d3e
@ -8,6 +8,7 @@
|
||||
#include "common.hpp"
|
||||
#include <PlayerTools.hpp>
|
||||
#include <settings/Bool.hpp>
|
||||
#include "soundcache.hpp"
|
||||
|
||||
namespace hacks::tf::autosticky
|
||||
{
|
||||
@ -16,8 +17,8 @@ static settings::Boolean buildings{ "autosticky.buildings", "true" };
|
||||
static settings::Boolean legit{ "autosticky.legit", "false" };
|
||||
|
||||
// A storage array for ents
|
||||
std::vector<CachedEntity *> bombs;
|
||||
std::vector<CachedEntity *> targets;
|
||||
static std::vector<CachedEntity *> bombs;
|
||||
static std::vector<CachedEntity *> targets;
|
||||
|
||||
// Function to tell when an ent is the local players own bomb
|
||||
bool IsBomb(CachedEntity *ent)
|
||||
@ -86,6 +87,7 @@ bool IsTarget(CachedEntity *ent)
|
||||
// Target isnt a good type
|
||||
return false;
|
||||
}
|
||||
|
||||
// Function called by game for movement
|
||||
void CreateMove()
|
||||
{
|
||||
@ -108,12 +110,12 @@ void CreateMove()
|
||||
targets.clear();
|
||||
|
||||
// Cycle through the ents and search for valid ents
|
||||
for (int i = 0; i < HIGHEST_ENTITY; i++)
|
||||
for (int i = 0; i <= HIGHEST_ENTITY; i++)
|
||||
{
|
||||
// Assign the for loops tick number to an ent
|
||||
CachedEntity *ent = ENTITY(i);
|
||||
// Check for dormancy and if valid
|
||||
if (CE_BAD(ent))
|
||||
if (CE_INVALID(ent))
|
||||
continue;
|
||||
// Check if ent is a bomb or suitable target and push to respective
|
||||
// arrays
|
||||
@ -134,10 +136,22 @@ void CreateMove()
|
||||
for (auto target : targets)
|
||||
{
|
||||
// Check distance to the target to see if the sticky will hit
|
||||
if (bomb->m_vecOrigin().DistToSqr(target->m_vecOrigin()) < 16900)
|
||||
Vector position = target->m_vecOrigin();
|
||||
if (RAW_ENT(target)->IsDormant())
|
||||
{
|
||||
if (!sound_cache[target->m_IDX].last_update.check(10000) && sound_cache[target->m_IDX].sound.m_pOrigin != Vector(0.0f))
|
||||
position = sound_cache[target->m_IDX].sound.m_pOrigin;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
auto collideable = RAW_ENT(target)->GetCollideable();
|
||||
|
||||
position = position + (collideable->OBBMins() + collideable->OBBMaxs()) / 2;
|
||||
|
||||
if (bomb->m_vecOrigin().DistToSqr(position) < 16900)
|
||||
{
|
||||
// Vis check the target from the bomb
|
||||
if (VisCheckEntFromEnt(bomb, target))
|
||||
if (IsVectorVisible(bomb->m_vecOrigin(), target->m_vecDormantOrigin(), true))
|
||||
{
|
||||
// Check user settings if legit mode is off, if legit mode
|
||||
// is off then detonate
|
||||
|
@ -40,13 +40,16 @@ public:
|
||||
if (g_IEngine->GetPlayerForUserID(event->GetInt("attacker")) == g_IEngine->GetLocalPlayer())
|
||||
{
|
||||
bool nearby = false;
|
||||
for (int i = 1; i < HIGHEST_ENTITY; i++)
|
||||
for (int i = 1; i <= HIGHEST_ENTITY; i++)
|
||||
{
|
||||
auto ent = ENTITY(i);
|
||||
if (CE_GOOD(ent) && (ent->m_Type() == ENTITY_PLAYER || ent->m_iClassID() == CL_CLASS(CObjectSentrygun)) && ent->m_bEnemy() && ent->m_bAlivePlayer() && ent->m_flDistance() < *safety)
|
||||
if (CE_VALID(ent) && (ent->m_Type() == ENTITY_PLAYER || ent->m_iClassID() == CL_CLASS(CObjectSentrygun)) && ent->m_bEnemy() && ent->m_bAlivePlayer())
|
||||
{
|
||||
nearby = true;
|
||||
break;
|
||||
if (ent->m_vecDormantOrigin() != Vector(0.0f) && ent->m_vecDormantOrigin().DistTo(LOCAL_E->m_vecOrigin()) < *safety)
|
||||
{
|
||||
nearby = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!nearby && RandomFloat(0, 100) <= float(chance))
|
||||
|
@ -431,7 +431,7 @@ int count_bots{ 0 };
|
||||
|
||||
bool should_ignore_player(CachedEntity *player)
|
||||
{
|
||||
if (CE_BAD(player))
|
||||
if (CE_INVALID(player))
|
||||
return false;
|
||||
|
||||
return is_a_catbot(player->player_info.friendsID);
|
||||
|
@ -439,7 +439,7 @@ void EffectGlow::Render(int x, int y, int w, int h)
|
||||
CMatRenderContextPtr ptr(GET_RENDER_CONTEXT);
|
||||
orig = ptr->GetRenderTarget();
|
||||
BeginRenderGlow();
|
||||
for (int i = 1; i < HIGHEST_ENTITY; i++)
|
||||
for (int i = 1; i <= HIGHEST_ENTITY; i++)
|
||||
{
|
||||
ent = g_IEntityList->GetClientEntity(i);
|
||||
if (ent && !ent->IsDormant() && ShouldRenderGlow(ent))
|
||||
@ -452,7 +452,7 @@ void EffectGlow::Render(int x, int y, int w, int h)
|
||||
{
|
||||
ptr->ClearStencilBufferRectangle(x, y, w, h, 0);
|
||||
StartStenciling();
|
||||
for (int i = 1; i < HIGHEST_ENTITY; i++)
|
||||
for (int i = 1; i <= HIGHEST_ENTITY; i++)
|
||||
{
|
||||
ent = g_IEntityList->GetClientEntity(i);
|
||||
if (ent && !ent->IsDormant() && ShouldRenderGlow(ent))
|
||||
|
Reference in New Issue
Block a user