we wuz killstreaks n shit

This commit is contained in:
nullifiedcat 2017-11-13 21:22:24 +03:00
parent 2e6aae7819
commit a539bd4b73
38 changed files with 194 additions and 8 deletions

BIN
data/sound/combowhore.wav Normal file

Binary file not shown.

BIN
data/sound/dominating.wav Normal file

Binary file not shown.

BIN
data/sound/doublekill.wav Normal file

Binary file not shown.

BIN
data/sound/firstblood.wav Normal file

Binary file not shown.

BIN
data/sound/godlike.wav Normal file

Binary file not shown.

BIN
data/sound/hattrick.wav Normal file

Binary file not shown.

BIN
data/sound/headhunter.wav Normal file

Binary file not shown.

BIN
data/sound/headshot.wav Normal file

Binary file not shown.

BIN
data/sound/holyshit.wav Normal file

Binary file not shown.

BIN
data/sound/humiliation.wav Normal file

Binary file not shown.

BIN
data/sound/impressive.wav Normal file

Binary file not shown.

BIN
data/sound/killingspree.wav Normal file

Binary file not shown.

Binary file not shown.

BIN
data/sound/megakill.wav Normal file

Binary file not shown.

BIN
data/sound/monsterkill.wav Normal file

Binary file not shown.

BIN
data/sound/multikill.wav Normal file

Binary file not shown.

BIN
data/sound/perfect.wav Normal file

Binary file not shown.

BIN
data/sound/play.wav Normal file

Binary file not shown.

BIN
data/sound/prepare.wav Normal file

Binary file not shown.

BIN
data/sound/rampage.wav Normal file

Binary file not shown.

BIN
data/sound/teamkiller.wav Normal file

Binary file not shown.

BIN
data/sound/triplekill.wav Normal file

Binary file not shown.

BIN
data/sound/ultrakill.wav Normal file

Binary file not shown.

BIN
data/sound/unstoppable.wav Normal file

Binary file not shown.

BIN
data/sound/wickedsick.wav Normal file

Binary file not shown.

View File

@ -0,0 +1,20 @@
/*
* Killstreak.hpp
*
* Created on: Nov 13, 2017
* Author: nullifiedcat
*/
#pragma once
#include "common.hpp"
namespace hacks { namespace tf2 { namespace killstreak {
int current_streak();
void init();
void shutdown();
void fire_event(IGameEvent *event);
void apply_killstreaks();
}}}

View File

@ -41,5 +41,6 @@
#include "Noisemaker.hpp"
#include "FollowBot.hpp"
#include "Announcer.hpp"
#include "Killstreak.hpp"
#endif /* HACKS_HACKLIST_HPP_ */

View File

@ -139,6 +139,8 @@ public:
offset_t m_angEyeAnglesLocal;
offset_t m_nSequence;
offset_t m_flSimulationTime;
offset_t m_nStreaks_Player;
offset_t m_nStreaks_Resource;
};
extern NetVars netvar;

View File

@ -60,6 +60,8 @@ struct offsets {
static constexpr uint32_t LevelShutdown() { return PlatformOffset(24, -1, -1); }
static constexpr uint32_t BeginFrame() { return PlatformOffset(5, -1, -1); }
static constexpr uint32_t FireGameEvent() { return PlatformOffset(2, -1, -1); }
static constexpr uint32_t FireEvent() { return PlatformOffset(8, 0, 0); }
static constexpr uint32_t FireEventClientSide() { return PlatformOffset(9, 0, 0); }
static constexpr uint32_t lastoutgoingcommand() { return PlatformOffset(19228, -1, -1); }
static constexpr uint32_t m_nOutSequenceNr() { return PlatformOffset(8, -1, -1); }

View File

@ -88,7 +88,7 @@ bool draw::EntityCenterToScreen(CachedEntity* entity, Vector& out) {
Vector world, min, max;
bool succ;
if (!entity) return false;
if (!entity || !RAW_ENT(entity)) return false;
RAW_ENT(entity)->GetRenderBounds(min, max);
world = RAW_ENT(entity)->GetAbsOrigin();
world.z += (min.z + max.z) / 2;

View File

@ -99,8 +99,9 @@ matrix3x4_t* EntityHitboxCache::GetBones() {
bones_setup_time = CE_FLOAT(parent_ref, netvar.m_flSimulationTime);
}
if (!bones_setup) {
std::lock_guard<std::mutex> lock(setupbones_mutex);
bones_setup = RAW_ENT(parent_ref)->SetupBones(bones, MAXSTUDIOBONES, 0x100, bones_setup_time);
//std::lock_guard<std::mutex> lock(setupbones_mutex);
if (g_Settings.is_create_move)
bones_setup = RAW_ENT(parent_ref)->SetupBones(bones, MAXSTUDIOBONES, 0x100, bones_setup_time);
}
return bones;
}

View File

@ -277,6 +277,7 @@ void hack::Initialize() {
// FIXME [MP]
hacks::shared::killsay::Init();
hacks::shared::announcer::init();
hacks::tf2::killstreak::init();
logging::Info("Hooked!");
velocity::Init();
playerlist::Load();

View File

@ -63,7 +63,12 @@ const announcer_entry_s *find_entry(const std::vector<announcer_entry_s>& vector
void playsound(const std::string& sound)
{
g_ISurface->PlaySound(std::string("announcer/" + sound).c_str());
// yes
char command[128];
snprintf(command, 128, "aplay %s/sound/%s &", DATA_PATH, sound.c_str());
logging::Info("system(%s)", command);
system(command);
// g_ISurface->PlaySound(std::string("announcer/" + sound).c_str());
}
void reset()
@ -136,11 +141,25 @@ void on_kill(IGameEvent *event)
}
}
void on_spawn(IGameEvent *event)
{
int userid = g_IEngine->GetPlayerForUserID(event->GetInt("userid"));
if (userid == g_IEngine->GetLocalPlayer())
{
reset();
}
}
class AnnouncerEventListener : public IGameEventListener2 {
virtual void FireGameEvent(IGameEvent *event)
{
if (enabled)
if (!enabled)
return;
if (0 == strcmp(event->GetName(), "player_death"))
on_kill(event);
else if (0 == strcmp(event->GetName(), "player_spawn"))
on_spawn(event);
}
};
@ -153,6 +172,7 @@ AnnouncerEventListener& listener()
void init()
{
g_IEventManager2->AddListener(&listener(), "player_death", false);
g_IEventManager2->AddListener(&listener(), "player_spawn", false);
}
void shutdown()

132
src/hacks/Killstreak.cpp Normal file
View File

@ -0,0 +1,132 @@
/*
* Killstreak.cpp
*
* Created on: Nov 13, 2017
* Author: nullifiedcat
*/
#include "common.hpp"
#include "hooks.hpp"
namespace hacks { namespace tf2 { namespace killstreak {
CatVar enabled(CV_SWITCH, "killstreak", "0", "Enable killstreaks on all weapons");
int killstreak { 0 };
void reset()
{
killstreak = 0;
}
int current_streak()
{
return killstreak;
}
void apply_killstreaks()
{
if (!enabled)
return;
IClientEntity *ent = g_IEntityList->GetClientEntity(g_IEngine->GetLocalPlayer());
IClientEntity *resource = g_IEntityList->GetClientEntity(g_pPlayerResource->entity);
if (!ent || ent->GetClientClass()->m_ClassID != RCC_PLAYERRESOURCE) return;
if (!(ent && resource))
{
logging::Info("1");
}
int *streaks_resource = (int*)((unsigned)resource + netvar.m_nStreaks_Resource + 4 * g_IEngine->GetLocalPlayer());
if (*streaks_resource != current_streak())
{
logging::Info("Adjusting %d -> %d", *streaks_resource, current_streak());
*streaks_resource = current_streak();
}
int *streaks_player = (int *)ent + netvar.m_nStreaks_Player;
//logging::Info("P0: %d", streaks_player[0]);
streaks_player[0] = current_streak();
streaks_player[1] = current_streak();
streaks_player[2] = current_streak();
streaks_player[3] = current_streak();
}
void on_kill(IGameEvent *event)
{
int killer_id = g_IEngine->GetPlayerForUserID(event->GetInt("attacker"));
int victim_id = g_IEngine->GetPlayerForUserID(event->GetInt("userid"));
if (victim_id == g_IEngine->GetLocalPlayer())
{
reset();
return;
}
if (killer_id != g_IEngine->GetLocalPlayer())
return;
if (killer_id == victim_id)
return;
killstreak++;
// if (event->GetInt("kill_streak_total") == 0)
{
logging::Info("Manipulating KS %d", killstreak);
event->SetInt("kill_streak_total", current_streak());
event->SetInt("kill_streak_wep", current_streak());
}
apply_killstreaks();
}
void on_spawn(IGameEvent *event)
{
int userid = g_IEngine->GetPlayerForUserID(event->GetInt("userid"));
if (userid == g_IEngine->GetLocalPlayer())
{
reset();
}
apply_killstreaks();
}
void fire_event(IGameEvent *event)
{
if (enabled)
{
if (0 == strcmp(event->GetName(), "player_death"))
on_kill(event);
else if (0 == strcmp(event->GetName(), "player_spawn"))
on_spawn(event);
}
}
hooks::VMTHook hook;
typedef bool(*FireEvent_t)(IGameEventManager2 *, IGameEvent *, bool);
bool FireEvent_hook(IGameEventManager2 *manager, IGameEvent *event, bool bDontBroadcast)
{
static FireEvent_t original = hook.GetMethod(offsets::FireEvent());
fire_event(event);
return original(manager, event, bDontBroadcast);
}
typedef bool(*FireEventClientSide_t)(IGameEventManager2 *, IGameEvent *);
bool FireEventClientSide(IGameEventManager2 *manager, IGameEvent *event)
{
static FireEventClientSide_t original = hook.GetMethod(offsets::FireEventClientSide());
fire_event(event);
return original(manager, event);
}
void init()
{
hook.Set(g_IEventManager2, 0);
// hook.HookMethod(FireEvent_hook, offsets::FireEvent());
hook.HookMethod(FireEventClientSide, offsets::FireEventClientSide());
hook.Apply();
}
}}}

View File

@ -13,8 +13,8 @@
namespace hacks { namespace tf2 { namespace skinchanger {
// Because fuck you, that's why.
const char* sig_GetAttributeDefinition = "55 89 E5 57 56 53 83 EC 6C C7 45 9C 00 00 00 00 8B 75 08 C7 45 A4 00 00 00 00 8B 45 0C C6 45 A8 00 C6 45 A9 00 C6 45 AA 00 8B BE B0 01 00 00 C6 45 AB 00 C6 45 B4 00 C7 45 B8 00 00 00 00 C7 45 BC 02 00 00 00 83 FF FF C7 45 C0 00 00 00 00 C7 45 C4 00 00 00 00 C7 45 C8 00 00 00 00 C7 45 CC 00 00 00 00 C7 45 D0 00 00 00 00 C6 45 D4 00 C6 45 D5 00 C7 45 D8 FF FF FF FF C7 45 DC 00 00 00 00 89 45 98 0F 84 86 01 00 00 8B 86 A4 01 00 00 EB 21";
const char* sig_SetRuntimeAttributeValue = "55 89 E5 57 56 53 83 EC 3C 8B 5D 08 8B 4B 10 85 C9 7E 33 8B 75 0C 8B 43 04 0F B7 7E 04 66 3B 78 04 0F 84 CA 00 00 00 83 C0 10 31 D2 EB 11 66 90 89 C6 83 C0 10 66 39 78 F4 0F 84 B9 00 00 00";
const char* sig_GetAttributeDefinition = "55 89 E5 57 56 53 83 EC 6C C7 45 9C 00 00 00 00 8B 75 08 C7 45 A4 00 00 00 00 8B 45 0C C6 45 A8 00 C6 45 A9 00 C6";
const char* sig_SetRuntimeAttributeValue = "55 89 E5 57 56 53 83 EC 3C 8B 5D 08 8B 4B 10 85 C9 7E 33";
const char* sig_GetItemSchema = "55 89 E5 57 56 53 83 EC 1C 8B 1D ? ? ? ? 85 DB 89 D8 74 0B 83 C4 1C 5B 5E 5F 5D C3";
ItemSystem_t ItemSystem { nullptr };

View File

@ -332,6 +332,8 @@ bool IsEntityVisible(CachedEntity* entity, int hb) {
}
CatVar tcm(CV_SWITCH, "debug_tcm", "1", "TCM");
std::mutex trace_lock;
bool IsEntityVectorVisible(CachedEntity* entity, Vector endpos) {
trace_t trace_object;
@ -346,7 +348,8 @@ bool IsEntityVectorVisible(CachedEntity* entity, Vector endpos) {
{
PROF_SECTION(IEVV_TraceRay);
std::lock_guard<std::mutex> lock(trace_lock);
g_ITrace->TraceRay(ray, MASK_SHOT_HULL, &trace::filter_default, &trace_object);
if (!tcm || g_Settings.is_create_move)
g_ITrace->TraceRay(ray, MASK_SHOT_HULL, &trace::filter_default, &trace_object);
}
return (trace_object.fraction >= 0.99f || (((IClientEntity*)trace_object.m_pEnt)) == RAW_ENT(entity));
}

View File

@ -435,6 +435,7 @@ void FireGameEvent_hook(void* _this, IGameEvent* event) {
return;
}
}
// hacks::tf2::killstreak::fire_event(event);
}
original(_this, event);
}
@ -445,6 +446,7 @@ void FrameStageNotify_hook(void* _this, int stage) {
static IClientEntity *ent;
PROF_SECTION(FrameStageNotify_TOTAL);
hacks::tf2::killstreak::apply_killstreaks();
static const FrameStageNotify_t original = (FrameStageNotify_t)hooks::client.GetMethod(offsets::FrameStageNotify());
SEGV_BEGIN;

View File

@ -76,6 +76,8 @@ void NetVars::Init() {
this->iWeaponState = gNetvars.get_offset("DT_WeaponMinigun", "m_iWeaponState");
this->flChargeLevel = gNetvars.get_offset("DT_WeaponMedigun", "NonLocalTFWeaponMedigunData", "m_flChargeLevel");
this->bChargeRelease = gNetvars.get_offset("DT_WeaponMedigun", "m_bChargeRelease");
this->m_nStreaks_Player = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_nStreaks");
this->m_nStreaks_Resource = gNetvars.get_offset("DT_TFPlayerResource", "m_iStreaks");
}
IF_GAME (IsTF2C()) {
this->iCritMult = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_iCritMult");