Add a minimum distance option
This commit is contained in:
parent
465c5ba694
commit
5332ef0502
@ -28,6 +28,7 @@
|
||||
<Box padding="12 6 6 6" width="content" height="content" name="Rapidfire" x="210">
|
||||
<List width="185">
|
||||
<AutoVariable width="fill" target="warp.rapidfire" label="Enable Rapidfire" tooltip="Allows you to shoot multiple shots at once or reduce time between shots."/>
|
||||
<AutoVariable width="fill" target="warp.rapidfire.distance" label="Minimum distance" tooltip="How close an enemy has to be to be able to rapidfire. 0 is off."/>
|
||||
<AutoVariable width="fill" target="warp.rapidfire.zoom" label="Enable Rapid zoom" tooltip="Allows you to instantly zoom in."/>
|
||||
<AutoVariable width="fill" target="warp.rapidfire.no-movement" label="Prevent movement in rapidfire" tooltip="Attempt to not move when Rapidfiring."/>
|
||||
<AutoVariable width="fill" target="warp.rapidfire.key" label="Rapidfire key" tooltip="Optional. If set you can use this key to control when to rapidfire."/>
|
||||
|
@ -121,6 +121,7 @@ Vector getShootPos(Vector angle);
|
||||
Vector GetForwardVector(Vector origin, Vector viewangles, float distance, CachedEntity *punch_entity = nullptr);
|
||||
Vector GetForwardVector(float distance, CachedEntity *punch_entity = nullptr);
|
||||
CachedEntity *getClosestEntity(Vector vec);
|
||||
CachedEntity *getClosestNonlocalEntity(Vector vec);
|
||||
bool IsSentryBuster(CachedEntity *ent);
|
||||
std::unique_ptr<char[]> strfmt(const char *fmt, ...);
|
||||
// TODO move that to weaponid.h
|
||||
@ -218,7 +219,7 @@ template <typename T, typename... Targs> void format_internal(std::stringstream
|
||||
stream << value;
|
||||
format_internal(stream, args...);
|
||||
}
|
||||
template <typename... Args> std::string format(const Args &... args)
|
||||
template <typename... Args> std::string format(const Args &...args)
|
||||
{
|
||||
std::stringstream stream;
|
||||
format_internal(stream, args...);
|
||||
|
@ -21,6 +21,7 @@ namespace hacks::tf2::warp
|
||||
static settings::Boolean enabled{ "warp.enabled", "false" };
|
||||
static settings::Boolean no_movement{ "warp.rapidfire.no-movement", "true" };
|
||||
static settings::Boolean rapidfire{ "warp.rapidfire", "false" };
|
||||
static settings::Int distance{ "warp.rapidfire.distance", "0" };
|
||||
static settings::Boolean rapidfire_zoom{ "warp.rapidfire.zoom", "true" };
|
||||
static settings::Boolean wait_full{ "warp.rapidfire.wait-full", "true" };
|
||||
static settings::Button rapidfire_key{ "warp.rapidfire.key", "<null>" };
|
||||
@ -206,6 +207,14 @@ bool shouldRapidfire()
|
||||
if (LOCAL_W->m_iClassID() == CL_CLASS(CTFMinigun) && CE_INT(LOCAL_W, netvar.iWeaponState) != 3 && CE_INT(LOCAL_W, netvar.iWeaponState) != 2)
|
||||
return false;
|
||||
|
||||
// Check if enemies are close enough
|
||||
if (distance)
|
||||
{
|
||||
auto closest = getClosestNonlocalEntity(LOCAL_E->m_vecOrigin());
|
||||
if (!closest || closest->m_flDistance() > *distance)
|
||||
return false;
|
||||
}
|
||||
|
||||
// We do not have the amount of ticks needed, don't try it
|
||||
if (warp_amount < TIME_TO_TICKS(getFireDelay()) && (TIME_TO_TICKS(getFireDelay()) < *maxusrcmdprocessticks - 1 || (wait_full && warp_amount != GetMaxWarpTicks())))
|
||||
return false;
|
||||
|
@ -705,6 +705,22 @@ CachedEntity *getClosestEntity(Vector vec)
|
||||
return best_ent;
|
||||
}
|
||||
|
||||
CachedEntity *getClosestNonlocalEntity(Vector vec)
|
||||
{
|
||||
float distance = FLT_MAX;
|
||||
CachedEntity *best_ent = nullptr;
|
||||
for (int i = 1; i <= g_IEngine->GetMaxClients(); i++)
|
||||
{
|
||||
CachedEntity *ent = ENTITY(i);
|
||||
if (CE_VALID(ent) && ent->m_IDX != g_pLocalPlayer->entity_idx && ent->m_vecDormantOrigin() && ent->m_bAlivePlayer() && ent->m_bEnemy() && vec.DistTo(ent->m_vecOrigin()) < distance)
|
||||
{
|
||||
distance = vec.DistTo(*ent->m_vecDormantOrigin());
|
||||
best_ent = ent;
|
||||
}
|
||||
}
|
||||
return best_ent;
|
||||
}
|
||||
|
||||
void VectorTransform(const float *in1, const matrix3x4_t &in2, float *out)
|
||||
{
|
||||
out[0] = (in1[0] * in2[0][0] + in1[1] * in2[0][1] + in1[2] * in2[0][2]) + in2[0][3];
|
||||
|
Reference in New Issue
Block a user