Major Item ESP update

This commit is contained in:
nullifiedcat 2017-02-10 20:21:53 +03:00
parent 5b2b83f588
commit c118af6549
19 changed files with 454 additions and 611 deletions

0
cathook/src/ItemManager Normal file
View File

View File

@ -30,6 +30,7 @@
#include "hooks.h"
#include "prediction.h"
#include "conditions.h"
#include "itemtypes.h"
#include "ipc/ipcctl.h"
#include "chatstack.h"
#include "textfile.h"

View File

@ -133,44 +133,30 @@ void colors::Init() {
green = Create(0, 255, 0, 255);
}
int colors::EntityB(CachedEntity* ent) {
using namespace colors;
int result = Transparent(black);
if (ent->m_Type == ENTITY_PLAYER || ent->m_Type == ENTITY_BUILDING) {
if (ent->m_iTeam == TEAM_BLU) result = blu_b;
else if (ent->m_iTeam == TEAM_RED) result = red_b;
if (ent->m_Type == ENTITY_PLAYER) {
if (GetRelation(ent) == relation::DEVELOPER) result = Transparent(black, 0.6f);
}
if (!ent->IsVisible()) result = Transparent(result, 0.833f);
}
return result;
}
int colors::EntityF(CachedEntity* ent) {
using namespace colors;
int result = white;
if (ent->m_iClassID == g_pClassID->CBaseAnimating) {
item_type type = GetItemType(ent);
if (type != item_null) {
if (type >= item_medkit_small && type <= item_medkit_large) {
result = green;
} else if (type >= item_ammo_small && type <= item_ammo_large) {
// White.
} else if (type >= item_mp_strength && type <= item_mp_crit) {
int skin = RAW_ENT(ent)->GetSkin();
if (skin == 1) {
result = red;
} else if (skin == 2) {
result = blu;
} else {
result = yellow;
}
k_EItemType type = ent->m_ItemType;
if (type) {
if (type >= ITEM_HEALTH_SMALL && type <= ITEM_HEALTH_LARGE || type == ITEM_TF2C_PILL) result = green;
else if (type >= ITEM_POWERUP_FIRST && type <= ITEM_POWERUP_LAST) {
int skin = RAW_ENT(ent)->GetSkin();
if (skin == 1) result = red;
else if (skin == 2) result = blu;
else result = yellow;
}
else if (type >= ITEM_TF2C_W_FIRST && type <= ITEM_TF2C_W_LAST) {
if (CE_BYTE(ent, netvar.bRespawning)) {
result = red;
} else {
result = yellow;
}
}
else if (type == ITEM_HL_BATTERY) {
result = yellow;
}
}
if (ent->m_iClassID == g_pClassID->CCurrencyPack) {
if (CE_BYTE(ent, netvar.bDistributed))
result = red;
@ -208,8 +194,10 @@ int colors::EntityF(CachedEntity* ent) {
result = RainbowCurrent(); break;
}
}
if (g_phESP->v_bVisCheck->GetBool())
if (!ent->IsVisible()) result = Transparent(result);
}
if (g_phESP->v_bVisCheck->GetBool()) {
if (!ent->IsVisible()) result = Transparent(result);
}
return result;
@ -394,7 +382,7 @@ void draw::WString(unsigned long font, int x, int y, int color, int shadow, cons
if (shadow > 0) {
draw::WString(font, x + 1, y + 1, black_t, false, text);
}
if (shadow > 1) {
if (shadow > 1 && !g_Settings.bFastOutline->GetBool()) {
draw::WString(font, x - 1, y + 1, black_t, false, text);
draw::WString(font, x - 1, y - 1, black_t, false, text);
draw::WString(font, x + 1, y - 1, black_t, false, text);

View File

@ -62,7 +62,6 @@ int FromHSL(float h, float s, float l);
int RainbowCurrent();
int Health(int health, int max);
int EntityF(CachedEntity* ent);
int EntityB(CachedEntity* ent);
}

View File

@ -74,6 +74,8 @@ void CachedEntity::Update(int idx) {
}*/
m_vecOrigin = origin;
m_ItemType = ITEM_NONE;
m_bGrenadeProjectile = false;
m_bBonesSetup = false;
@ -110,6 +112,7 @@ void CachedEntity::Update(int idx) {
m_iClassID == g_pClassID->CTFProjectile_Flare) {
m_Type = EntityType::ENTITY_PROJECTILE;
} else {
m_ItemType = g_ItemManager.GetItemType(this);
m_Type = EntityType::ENTITY_GENERIC;
}

View File

@ -9,6 +9,7 @@
#define ENTITYCACHE_H_
#include "enums.h"
#include "itemtypes.h"
#include "fixsdk.h"
#include <mathlib/vector.h>
@ -127,6 +128,7 @@ public:
Vector m_vecOrigin;
k_EItemType m_ItemType;
int m_iTeam;
bool m_bAlivePlayer;
bool m_bEnemy;
@ -152,7 +154,6 @@ public:
IClientEntity* m_pEntity;
ESPStringCompound* m_Strings;
int m_ESPColorFG;
int m_ESPColorBG;
int m_nESPStrings;
Vector m_ESPOrigin;
Vector m_vecVOrigin;

View File

@ -15,86 +15,6 @@ enum EntityType {
ENTITY_PROJECTILE
};
/*enum cond {
slowed = (1 << 0),
zoomed = (1 << 1),
disguised = (1 << 3),
cloaked = (1 << 4),
uber = (1 << 5),
taunting = (1 << 7),
uber_expiration = (1 << 8),
kritzkrieg = (1 << 11),
dead_ringer = (1 << 13),
bonk = (1 << 14),
stunned = (1 << 15),
buff_banner = (1 << 16),
mini_crit = (1 << 19),
on_fire = (1 << 22),
jarate = (1 << 24),
backup = (1 << 26),
milk = (1 << 27),
quickfix_uber = (1 << 28),
concheror = (1 << 29),
marked = (1 << 30)
};
enum cond_ex {
halloween_crit = (1 << 1),
canteen_crit = (1 << 2),
hype = (1 << 4),
first_blood_crit = (1 << 5),
winning_crit = (1 << 6),
intelligence_crit = (1 << 7),
on_kill_crit = (1 << 8),
phlog_crit = (1 << 12),
phlog_uber = (1 << 13),
gru_marked = (1 << 16),
hidden_uber = (1 << 19),
canteen_uber = (1 << 20),
misc_crit = (1 << 24),
misc_uber = (1 << 25),
vacc_bullet = (1 << 26),
vacc_blast = (1 << 27),
vacc_fire = (1 << 28),
vacc_pbullet = (1 << 29),
vacc_pblast = (1 << 30),
vacc_pfire = (1 << 31)
};
enum cond_ex2 {
cloak_spell = (1 << 0),
cloak_spell_fading = (1 << 2),
immunity_bullet = (1 << 3),
immunity_blast = (1 << 4),
immunity_fire = (1 << 5),
buddha = (1 << 6),
minify_spell = (1 << 8),
healing_spell = (1 << 9),
minify_spell_size = (1 << 11),
base_jumping = (1 << 16),
rocket_jumping = (1 << 17),
powerup_generic = (1 << 25),
powerup_strength = (1 << 26),
powerup_haste = (1 << 27),
powerup_regen = (1 << 28),
powerup_resistance = (1 << 29),
powerup_vampire = (1 << 30),
powerup_reflect = (1 << 31)
};
enum cond_ex3 {
powerup_precision = (1 << 0),
powerup_agility = (1 << 1),
grappling = (1 << 2),
powerup_knockout = (1 << 7),
powerup_revenge = (1 << 8),
powerup_crit = (1 << 9),
powerup_king = (1 << 13),
powerup_plague = (1 << 14),
powerup_supernova = (1 << 15),
airblasted = (1 << 19)
};*/
enum powerup_type {
not_powerup = -1,
strength,
@ -119,398 +39,6 @@ enum powerup_owner {
blue = 2
};
enum item_type {
item_null = -1,
item_medkit_small,
item_medkit_medium,
item_medkit_large,
item_ammo_small,
item_ammo_medium,
item_ammo_large,
item_mp_strength,
item_mp_resistance,
item_mp_vampire,
item_mp_reflect,
item_mp_haste,
item_mp_regeneration,
item_mp_precision,
item_mp_agility,
item_mp_knockout,
item_mp_king,
item_mp_plague,
item_mp_supernova,
item_mp_crit,
item_mp_uber, /* this exists for some reason */
item_mp_warlock, /* never seen that powerup, but the model exists */
item_mp_thorns /* and this one */
};
enum pack_type {
not_pack = -1,
small,
medium,
large,
PACK_COUNT
};
/*enum ClassID {
CTFWearableLevelableItem = 326,
CTFWearableDemoShield = 324,
CTFBaseRocket = 184,
CTFWeaponBaseMerasmusGrenade = 313,
CTFWeaponBaseMelee = 312,
CTFWeaponBaseGun = 311,
CTFWeaponBaseGrenadeProj = 310,
CTFWeaponBase = 309,
CTFWearableRobotArm = 327,
CTFRobotArm = 277,
CTFWrench = 329,
CTFProjectile_ThrowableBreadMonster = 269,
CTFProjectile_ThrowableBrick = 270,
CTFProjectile_ThrowableRepel = 271,
CTFProjectile_Throwable = 268,
CTFThrowable = 307,
CTFSyringeGun = 303,
CTFKatana = 219,
CTFSword = 302,
CSniperDot = 117,
CTFSniperRifleClassic = 296,
CTFSniperRifleDecap = 297,
CTFSniperRifle = 295,
CTFChargedSMG = 194,
CTFSMG = 294,
CTFShovel = 293,
CTFShotgunBuildingRescue = 292,
CTFPEPBrawlerBlaster = 235,
CTFSodaPopper = 298,
CTFShotgun_Revenge = 290,
CTFScatterGun = 286,
CTFShotgun_Pyro = 289,
CTFShotgun_HWG = 288,
CTFShotgun_Soldier = 291,
CTFShotgun = 287,
CTFCrossbow = 198,
CTFRocketLauncher_Mortar = 285,
CTFRocketLauncher_AirStrike = 283,
CTFRocketLauncher_DirectHit = 284,
CTFRocketLauncher = 282,
CTFRevolver = 276,
CTFDRGPomson = 199,
CTFRaygun = 274,
CTFPistol_ScoutSecondary = 240,
CTFPistol_ScoutPrimary = 239,
CTFPistol_Scout = 238,
CTFPistol = 237,
CTFPipebombLauncher = 236,
CTFWeaponPDA_Spy = 319,
CTFWeaponPDA_Engineer_Destroy = 318,
CTFWeaponPDA_Engineer_Build = 317,
CTFWeaponPDAExpansion_Teleporter = 321,
CTFWeaponPDAExpansion_Dispenser = 320,
CTFWeaponPDA = 316,
CTFParticleCannon = 233,
CTFParachute_Secondary = 232,
CTFParachute_Primary = 231,
CTFParachute = 230,
CTFMinigun = 228,
CTFMedigunShield = 225,
CWeaponMedigun = 337,
CTFMechanicalArm = 224,
CTFLunchBox_Drink = 223,
CTFLunchBox = 222,
CLaserDot = 78,
CTFLaserPointer = 221,
CTFKnife = 220,
CTFProjectile_Cleaver = 246,
CTFProjectile_JarMilk = 253,
CTFProjectile_Jar = 252,
CTFCleaver = 195,
CTFJarMilk = 218,
CTFJar = 217,
CTFWeaponInvis = 315,
CTFCannon = 193,
CTFGrenadeLauncher = 211,
CTFGrenadePipebombProjectile = 212,
CTFGrapplingHook = 210,
CTFFlareGun_Revenge = 206,
CTFFlareGun = 205,
CTFFlameRocket = 203,
CTFFlameThrower = 204,
CTFFists = 202,
CTFFireAxe = 201,
CTFCompoundBow = 197,
CTFClub = 196,
CTFBuffItem = 192,
CTFStickBomb = 300,
CTFBottle = 191,
CTFBonesaw = 189,
CTFBall_Ornament = 181,
CTFStunBall = 301,
CTFBat_Giftwrap = 187,
CTFBat_Wood = 188,
CTFBat_Fish = 186,
CTFBat = 185,
CTFProjectile_EnergyRing = 248,
CTFDroppedWeapon = 200,
CTFWeaponSapper = 322,
CTFWeaponBuilder = 314,
C_TFWeaponBuilder = 0,
CTFProjectile_Rocket = 254,
CTFProjectile_Flare = 249,
CTFProjectile_EnergyBall = 247,
CTFProjectile_GrapplingHook = 250,
CTFProjectile_HealingBolt = 251,
CTFProjectile_Arrow = 245,
CMannVsMachineStats = 80,
CTFTankBoss = 304,
CTFBaseBoss = 182,
CBossAlpha = 0,
NextBotCombatCharacter = 342,
CTFProjectile_SpellKartBats = 258,
CTFProjectile_SpellKartOrb = 259,
CTFHellZap = 215,
CTFProjectile_SpellLightningOrb = 260,
CTFProjectile_SpellTransposeTeleport = 267,
CTFProjectile_SpellMeteorShower = 261,
CTFProjectile_SpellSpawnBoss = 264,
CTFProjectile_SpellMirv = 262,
CTFProjectile_SpellPumpkin = 263,
CTFProjectile_SpellSpawnHorde = 265,
CTFProjectile_SpellSpawnZombie = 266,
CTFProjectile_SpellBats = 256,
CTFProjectile_SpellFireball = 257,
CTFSpellBook = 299,
CHightower_TeleportVortex = 74,
CTeleportVortex = 159,
CZombie = 339,
CMerasmusDancer = 83,
CMerasmus = 82,
CHeadlessHatman = 73,
CEyeballBoss = 48,
CTFBotHintEngineerNest = 190,
CBotNPCMinion = 0,
CBotNPC = 0,
CPasstimeGun = 94,
CTFViewModel = 308,
CRobotDispenser = 111,
CTFRobotDestruction_Robot = 278,
CTFReviveMarker = 275,
CTFPumpkinBomb = 272,
CTFBaseProjectile = 183,
CBaseObjectUpgrade = 11,
CTFRobotDestructionLogic = 281,
CTFRobotDestruction_RobotGroup = 279,
CTFRobotDestruction_RobotSpawn = 280,
CTFPlayerDestructionLogic = 242,
CPlayerDestructionDispenser = 101,
CTFMinigameLogic = 227,
CTFHalloweenMinigame_FallingPlatforms = 214,
CTFHalloweenMinigame = 213,
CTFMiniGame = 226,
CTFPowerupBottle = 244,
CTFItem = 216,
CHalloweenSoulPack = 71,
CTFGenericBomb = 208,
CBonusRoundLogic = 23,
CTFGameRulesProxy = 207,
CTETFParticleEffect = 178,
CTETFExplosion = 177,
CTETFBlood = 176,
CHalloweenGiftPickup = 69,
CBonusDuckPickup = 21,
CHalloweenPickup = 70,
CCaptureFlagReturnIcon = 27,
CCaptureFlag = 26,
CBonusPack = 22,
CTFTeam = 306,
CTFTauntProp = 305,
CTFPlayerResource = 243,
CTFPlayer = 241,
CTFRagdoll = 273,
CTEPlayerAnimEvent = 164,
CTFPasstimeLogic = 234,
CPasstimeBall = 93,
CTFObjectiveResource = 229,
CTFGlow = 209,
CTEFireBullets = 151,
CTFBuffBanner = 0,
CTFAmmoPack = 180,
CObjectTeleporter = 89,
CObjectSentrygun = 88,
CTFProjectile_SentryRocket = 255,
CObjectSapper = 87,
CObjectCartDispenser = 85,
CObjectDispenser = 86,
CMonsterResource = 84,
CFuncRespawnRoomVisualizer = 64,
CFuncRespawnRoom = 63,
CFuncPasstimeGoal = 61,
CFuncForceField = 57,
CCaptureZone = 28,
CCurrencyPack = 31,
CBaseObject = 10,
CTestTraceline = 175,
CTEWorldDecal = 179,
CTESpriteSpray = 173,
CTESprite = 172,
CTESparks = 171,
CTESmoke = 170,
CTEShowLine = 168,
CTEProjectedDecal = 166,
CTEPlayerDecal = 165,
CTEPhysicsProp = 163,
CTEParticleSystem = 162,
CTEMuzzleFlash = 161,
CTELargeFunnel = 158,
CTEKillPlayerAttachments = 157,
CTEImpact = 156,
CTEGlowSprite = 155,
CTEShatterSurface = 167,
CTEFootprintDecal = 153,
CTEFizz = 152,
CTEExplosion = 150,
CTEEnergySplash = 149,
CTEEffectDispatch = 148,
CTEDynamicLight = 147,
CTEDecal = 145,
CTEClientProjectile = 144,
CTEBubbleTrail = 143,
CTEBubbles = 142,
CTEBSPDecal = 141,
CTEBreakModel = 140,
CTEBloodStream = 139,
CTEBloodSprite = 138,
CTEBeamSpline = 137,
CTEBeamRingPoint = 136,
CTEBeamRing = 135,
CTEBeamPoints = 134,
CTEBeamLaser = 133,
CTEBeamFollow = 132,
CTEBeamEnts = 131,
CTEBeamEntPoint = 130,
CTEBaseBeam = 129,
CTEArmorRicochet = 128,
CTEMetalSparks = 160,
CSteamJet = 122,
CSmokeStack = 116,
DustTrail = 340,
CFireTrail = 50,
SporeTrail = 347,
SporeExplosion = 346,
RocketTrail = 344,
SmokeTrail = 345,
CPropVehicleDriveable = 107,
ParticleSmokeGrenade = 343,
CParticleFire = 90,
MovieExplosion = 341,
CTEGaussExplosion = 154,
CEnvQuadraticBeam = 43,
CEmbers = 36,
CEnvWind = 47,
CPrecipitation = 106,
CBaseTempEntity = 17,
CWeaponIFMSteadyCam = 336,
CWeaponIFMBaseCamera = 335,
CWeaponIFMBase = 334,
CTFWearableVM = 328,
CTFWearable = 323,
CTFWearableItem = 325,
CEconWearable = 35,
CBaseAttributableItem = 3,
CEconEntity = 34,
CHandleTest = 72,
CTeamplayRoundBasedRulesProxy = 125,
CTeamRoundTimer = 126,
CSpriteTrail = 121,
CSpriteOriented = 120,
CSprite = 119,
CRagdollPropAttached = 110,
CRagdollProp = 109,
CPoseController = 105,
CGameRulesProxy = 68,
CInfoLadderDismount = 75,
CFuncLadder = 58,
CEnvDetailController = 40,
CWorld = 338,
CWaterLODControl = 333,
CWaterBullet = 332,
CVoteController = 331,
CVGuiScreen = 330,
CPropJeep = 0,
CPropVehicleChoreoGeneric = 0,
CTest_ProxyToggle_Networkable = 174,
CTesla = 169,
CTeamTrainWatcher = 127,
CBaseTeamObjectiveResource = 16,
CTeam = 124,
CSun = 123,
CParticlePerformanceMonitor = 91,
CSpotlightEnd = 118,
CSlideshowDisplay = 115,
CShadowControl = 114,
CSceneEntity = 113,
CRopeKeyframe = 112,
CRagdollManager = 108,
CPhysicsPropMultiplayer = 98,
CPhysBoxMultiplayer = 96,
CBasePropDoor = 15,
CDynamicProp = 33,
CPointCommentaryNode = 104,
CPointCamera = 103,
CPlayerResource = 102,
CPlasma = 100,
CPhysMagnet = 99,
CPhysicsProp = 97,
CPhysBox = 95,
CParticleSystem = 92,
CMaterialModifyControl = 81,
CLightGlow = 79,
CInfoOverlayAccessor = 77,
CFuncTrackTrain = 67,
CFuncSmokeVolume = 66,
CFuncRotating = 65,
CFuncReflectiveGlass = 62,
CFuncOccluder = 60,
CFuncMonitor = 59,
CFunc_LOD = 54,
CTEDust = 146,
CFunc_Dust = 53,
CFuncConveyor = 56,
CBreakableSurface = 25,
CFuncAreaPortalWindow = 55,
CFish = 51,
CEntityFlame = 38,
CFireSmoke = 49,
CEnvTonemapController = 46,
CEnvScreenEffect = 44,
CEnvScreenOverlay = 45,
CEnvProjectedTexture = 42,
CEnvParticleScript = 41,
CFogController = 52,
CEntityParticleTrail = 39,
CEntityDissolve = 37,
CDynamicLight = 32,
CColorCorrectionVolume = 30,
CColorCorrection = 29,
CBreakableProp = 24,
CBasePlayer = 13,
CBaseFlex = 8,
CBaseEntity = 7,
CBaseDoor = 6,
CBaseCombatCharacter = 4,
CBaseAnimatingOverlay = 2,
CBoneFollower = 20,
CBaseAnimating = 1,
CInfoLightingRelative = 76,
CAI_BaseNPC = 0,
CBeam = 19,
CBaseViewModel = 18,
CBaseProjectile = 14,
CBaseParticleEntity = 12,
CBaseGrenade = 9,
CBaseCombatWeapon = 5
};*/
enum tf_team {
TEAM_UNK = 0,
TEAM_SPEC,

View File

@ -42,6 +42,7 @@ void GlobalSettings::Init() {
this->bCleanScreenshots = new CatVar(CV_SWITCH, "clean_screenshot", "1", "Clean screenshots", NULL, "Clean screenshots");
this->bDebugLog = new CatVar(CV_SWITCH, "log", "1", "Debug Log", NULL, "Disable this if you don't need cathook messages in your console");
this->bThirdperson->m_pConVar->InstallChangeCallback(ThirdpersonCallback);
this->bFastOutline = new CatVar(CV_SWITCH, "fastoutline", "0", "Low quality outline", NULL, "Might increase performance when there is a lot of ESP text to draw");
bInvalid = true;
}

View File

@ -40,6 +40,7 @@ public:
CatVar* bCleanScreenshots;
CatVar* bDebugLog;
Vector last_angles;
CatVar* bFastOutline;
bool bInvalid;
};

View File

@ -75,6 +75,8 @@ void CMenuWindow::AddElements() {
ADDCVAR(g_phESP->v_bItemESP);
ADDCVAR(g_phESP->v_bShowMoney);
ADDCVAR(g_phESP->v_bShowHealthPacks);
if (TF2C) ADDCVAR(g_phESP->v_bShowWeaponSpawners);
if (TF2C) ADDCVAR(g_phESP->v_bShowAdrenaline);
if (TF) ADDCVAR(g_phESP->v_bShowAmmoPacks);
ADDCVAR(g_phESP->v_bShowDroppedWeapons);
if (TF) ADDCVAR(g_phESP->v_bShowPowerups);
@ -151,6 +153,7 @@ void CMenuWindow::AddElements() {
//ADDCVAR(g_phMisc->v_bDebugInfo);
if (HL2DM) ADDCVAR(g_phMisc->v_bFlashlightSpam);
ADDCVAR(g_phMisc->v_iFakeLag);
ADDCVAR(g_Settings.bFastOutline);
if (TF) {
ADDLABEL("Spy Alert");
ADDCVAR(g_phSpyAlert->v_bEnabled);

View File

@ -65,6 +65,10 @@ ESP::ESP() {
v_bShowClass = new CatVar(CV_SWITCH, "esp_class", "1", "Class ESP", NULL, "Show class");
v_bShowConditions = new CatVar(CV_SWITCH, "esp_conds", "1", "Conditions ESP", NULL, "Show conditions");
this->v_bBuildingESP = new CatVar(CV_SWITCH, "esp_buildings", "1", "Building ESP", NULL, "Show buildings");
this->v_bShowWeaponSpawners = new CatVar(CV_SWITCH, "esp_weapon_spawners", "1", "Show weapon spawners", NULL, "TF2C deathmatch weapon spawners");
v_bShowAdrenaline = new CatVar(CV_SWITCH, "esp_item_adrenaline", "0", "Show Adrenaline", NULL, "TF2C adrenaline pills");
v_bModelName = new CatVar(CV_SWITCH, "esp_model_name", "0", "Model name ESP", NULL, "Model name esp (DEBUG ONLY)");
}
#define ESP_HEIGHT 14
@ -154,14 +158,18 @@ void ESP::ProcessEntity(CachedEntity* ent) {
if (CE_BAD(ent)) return;
ent->m_ESPColorFG = colors::EntityF(ent);
ent->m_ESPColorBG = colors::EntityB(ent);
//if (ent->IsVisible()) ent->AddESPString("VISIBLE");
if (v_bEntityESP->GetBool()) {
ent->AddESPString("%s [%i]", RAW_ENT(ent)->GetClientClass()->m_pNetworkName, ent->m_iClassID);
if (v_bShowEntityID->GetBool()) {
ent->AddESPString("%i", ent->m_IDX);
}
ent->AddESPString("Type: %i", ent->m_Type);
//ent->AddESPString("Type: %i", ent->m_Type);
if (v_bModelName->GetBool()) {
const model_t* model = RAW_ENT(ent)->GetModel();
if (model) ent->AddESPString("%s", interfaces::model->GetModelName(model));
}
}
if (ent->m_Type == ENTITY_PROJECTILE && v_bProjectileESP->GetBool() && (ent->m_bEnemy || (v_bTeammates->GetBool() && !v_bOnlyEnemyProjectiles->GetBool()))) {
@ -234,11 +242,6 @@ void ESP::ProcessEntity(CachedEntity* ent) {
if (this->v_bShowDistance->GetBool()) {
ent->AddESPString("%im", (int)(ent->m_flDistance / 64 * 1.22f));
}
} else if (ent->m_iClassID == g_pClassID->CTFAmmoPack && this->v_bItemESP->GetBool() && this->v_bShowAmmoPacks->GetBool()) {
ent->AddESPString("++ AMMO");
if (this->v_bShowDistance->GetBool()) {
ent->AddESPString("%im", (int)(ent->m_flDistance / 64 * 1.22f));
}
} else if (ent->m_iClassID == g_pClassID->CCurrencyPack && v_bShowMoney->GetBool()) {
if (CE_BYTE(ent, netvar.bDistributed)) {
if (this->v_bShowRedMoney->GetBool()) {
@ -249,24 +252,27 @@ void ESP::ProcessEntity(CachedEntity* ent) {
ent->AddESPString("$$$");
ent->AddESPString("%im", (int)(ent->m_flDistance / 64 * 1.22f));
}
} else if (ent->m_iClassID == g_pClassID->CBaseAnimating && this->v_bItemESP->GetBool()) {
item_type type = GetItemType(ent);
if (type != item_type::item_null) {
bool shown = false;
if (type >= item_medkit_small && type <= item_medkit_large && this->v_bShowHealthPacks->GetBool()) {
ent->AddESPString("%s HEALTH", packs[type - item_medkit_small]);
//CE_INT(ent, netvar.bGlowEnabled) = 1;
shown = true;
} else if (type >= item_ammo_small && type <= item_ammo_large && this->v_bShowAmmoPacks->GetBool()) {
ent->AddESPString("%s AMMO", packs[type - item_ammo_small]);
shown = true;
} else if (type >= item_mp_strength && type <= item_mp_crit && this->v_bShowPowerups->GetBool()) {
ent->AddESPString("%s PICKUP", powerups[type - item_mp_strength]);
shown = true;
}
if (this->v_bShowDistance->GetBool() && shown) {
ent->AddESPString("%im", (int)(ent->m_flDistance / 64 * 1.22f));
}
} else if (ent->m_ItemType != ITEM_NONE && this->v_bItemESP->GetBool()) {
bool shown = false;
if (this->v_bShowHealthPacks->GetBool() && (ent->m_ItemType >= ITEM_HEALTH_SMALL && ent->m_ItemType <= ITEM_HEALTH_LARGE || ent->m_ItemType == ITEM_HL_BATTERY)) {
if (ent->m_ItemType == ITEM_HEALTH_SMALL) ent->AddESPString("[+]");
if (ent->m_ItemType == ITEM_HEALTH_MEDIUM) ent->AddESPString("[++]");
if (ent->m_ItemType == ITEM_HEALTH_LARGE) ent->AddESPString("[+++]");
if (ent->m_ItemType == ITEM_HL_BATTERY) ent->AddESPString("[Z]");
} else if (this->v_bShowAdrenaline->GetBool() && ent->m_ItemType == ITEM_TF2C_PILL) {
ent->AddESPString("[a]");
} else if (this->v_bShowAmmoPacks->GetBool() && ent->m_ItemType >= ITEM_AMMO_SMALL && ent->m_ItemType <= ITEM_AMMO_LARGE) {
if (ent->m_ItemType == ITEM_AMMO_SMALL) ent->AddESPString("{i}");
if (ent->m_ItemType == ITEM_AMMO_MEDIUM) ent->AddESPString("{ii}");
if (ent->m_ItemType == ITEM_AMMO_LARGE) ent->AddESPString("{iii}");
} else if (this->v_bShowPowerups->GetBool() && ent->m_ItemType >= ITEM_POWERUP_FIRST && ent->m_ItemType <= ITEM_POWERUP_LAST) {
ent->AddESPString("%s PICKUP", powerups[ent->m_ItemType - ITEM_POWERUP_FIRST]);
} else if (this->v_bShowWeaponSpawners->GetBool() && ent->m_ItemType >= ITEM_TF2C_W_FIRST && ent->m_ItemType <= ITEM_TF2C_W_LAST) {
ent->AddESPString("%s SPAWNER", tf2c_weapon_names[ent->m_ItemType - ITEM_TF2C_W_FIRST].c_str());
if (CE_BYTE(ent, netvar.bRespawning)) ent->AddESPString("-- RESPAWNING --");
}
if (this->v_bShowDistance->GetBool() && shown) {
ent->AddESPString("%im", (int)(ent->m_flDistance / 64 * 1.22f));
}
} else if (ent->m_Type == ENTITY_BUILDING && v_bBuildingESP->GetBool()) {
if (!ent->m_bEnemy && !v_bTeammates->GetBool()) return;

View File

@ -55,6 +55,9 @@ public:
CatVar* v_iShowStickies;
CatVar* v_bOnlyEnemyProjectiles;
CatVar* v_bProjectileESP;
CatVar* v_bModelName;
CatVar* v_bShowWeaponSpawners;
CatVar* v_bShowAdrenaline;
//ConVar* v_bModelInfo;
};

View File

@ -91,12 +91,6 @@ ConCommand* CreateConCommand(const char* name, FnCommandCallback_t callback, con
return ret;
}
const char* GetModelPath(CachedEntity* entity) {
if (!entity) return "NULL";
const model_t* model = RAW_ENT(entity)->GetModel();
return interfaces::model->GetModelName(model);
}
const char* GetBuildingName(CachedEntity* ent) {
if (!ent) return "[NULL]";
if (ent->m_iClassID == g_pClassID->CObjectSentrygun) return "Sentry";
@ -140,62 +134,6 @@ std::string WordWrap(std::string& in, int max) {
return result.str();
}
/* Takes CBaseAnimating entity as input */
item_type GetItemType(CachedEntity* entity) {
if (entity == 0) return item_type::item_null;
const char* path = GetModelPath(entity); /* SDK function */
size_t length = strlen(path);
/* Default/Festive medkits */
if (length >= 29 && path[16] == 'k') {
if (path[20] == 's') return item_type::item_medkit_small;
if (path[20] == 'm') return item_type::item_medkit_medium;
if (path[20] == 'l') return item_type::item_medkit_large;
}
/* Sandwich/Steak */
if (length >= 22 && path[13] == 'p' && path[14] == 'l') {
return item_type::item_medkit_medium;
}
/* Medieval meat */
if (length == 39 && path[31] == 'm' && path[29] == 'l') {
return item_type::item_medkit_medium;
}
/* Halloween medkits */
if (length >= 49 && path[33] == 'm' && path[36] == 'k') {
if (path[20] == 's') return item_type::item_medkit_small;
if (path[40] == 'm') return item_type::item_medkit_medium;
if (path[40] == 'l') return item_type::item_medkit_large;
}
/* Ammo packs */
if (length >= 31 && path[14] == 'm' && path[15] == 'm') {
if (path[22] == 's') return item_type::item_ammo_small;
if (path[22] == 'm') return item_type::item_ammo_medium;
if (path[22] == 'l') return item_type::item_ammo_large;
}
/* Powerups */
if (length >= 38 && path[20] == 'p' && path[24] == 'w') {
if (path[30] == 'h') return item_type::item_mp_haste;
if (path[30] == 'v') return item_type::item_mp_vampire;
if (path[30] == 'u') return item_type::item_mp_uber;
if (path[32] == 'e') return item_type::item_mp_precision;
if (path[30] == 'w') return item_type::item_mp_warlock;
if (path[32] == 'r') return item_type::item_mp_strength;
if (path[32] == 'g') return item_type::item_mp_regeneration;
if (path[37] == 'v') return item_type::item_mp_supernova;
/* looks like resistance.mdl is unused and replaced with defense.mdl? idk */
if (path[37] == 'n') return item_type::item_mp_resistance;
if (path[34] == 'k') return item_type::item_mp_knockout;
/* actually this one is 'defense' but it's used for resistance powerup */
if (path[35] == 's') return item_type::item_mp_resistance;
if (path[30] == 'c') return item_type::item_mp_crit;
if (path[30] == 'a') return item_type::item_mp_agility;
if (path[31] == 'i') return item_type::item_mp_king;
if (path[33] == 'g') return item_type::item_mp_plague;
if (path[36] == 't') return item_type::item_mp_reflect;
if (path[30] == 't') return item_type::item_mp_thorns;
}
return item_type::item_null;
}
powerup_type GetPowerupOnPlayer(CachedEntity* player) {
if (!CE_BAD(player)) return powerup_type::not_powerup;
if (HasCondition(player, TFCond_RuneStrength)) return powerup_type::strength;
@ -378,9 +316,8 @@ bool IsEntityVectorVisible(CachedEntity* entity, Vector endpos) {
trace::g_pFilterDefault->SetSelf(RAW_ENT(g_pLocalPlayer->entity));
ray.Init(g_pLocalPlayer->v_Eye, endpos);
interfaces::trace->TraceRay(ray, MASK_SHOT_HULL, trace::g_pFilterDefault, &trace_object);
if (trace_object.m_pEnt) {
return (((IClientEntity*)trace_object.m_pEnt)) == RAW_ENT(entity);
} else return false;
//logging::Info("%.2f expected %s got %s", trace_object.fraction, RAW_ENT(entity)->GetClientClass()->GetName(), trace_object.m_pEnt ? ((IClientEntity*)trace_object.m_pEnt)->GetClientClass()->GetName() : "NULL");
return (trace_object.fraction >= 0.99f || (((IClientEntity*)trace_object.m_pEnt)) == RAW_ENT(entity));
}
Vector GetBuildingPosition(CachedEntity* ent) {
@ -904,9 +841,3 @@ const char* tfclasses[] = {
"Spy",
"Engineer"
};
const char* packs[] = {
"+",
"++",
"+++"
};

View File

@ -52,9 +52,6 @@ ConVar* CreateConVar(std::string name, std::string value, std::string help);
ConCommand* CreateConCommand(const char* name, FnCommandCallback_t callback, const char* help);
powerup_type GetPowerupOnPlayer(CachedEntity* player);
item_type GetItemType(CachedEntity* entity);
const char* GetModelPath(IClientEntity* entity);
// GetHitbox() is being called really frequently.
// It's better if it won't create a new object each time it gets called.
// So it returns a success state, and the values are stored in out reference.
@ -117,7 +114,6 @@ float GetFov(Vector ang, Vector src, Vector dst);
extern const char* tfclasses[10];
extern const char* powerups[POWERUP_COUNT];
extern const char* packs[PACK_COUNT];
extern uint32 friends[256];
extern int n_friends;
extern int n_rage;

View File

@ -139,7 +139,8 @@ void PaintTraverse_hook(void* p, unsigned int vp, bool fr, bool ar) {
draw::String(fonts::ESP, ce->m_ESPOrigin.x, ce->m_ESPOrigin.y, color, 2, str.m_String);
ce->m_ESPOrigin.y += 12;
} else {
draw::String(fonts::ESP, screen.x, screen.y, color, 2, str.m_String);
auto l = draw::GetStringLength(fonts::ESP, std::string(str.m_String));
draw::String(fonts::ESP, screen.x - l.first / 2, screen.y, color, 2, str.m_String);
screen.y += 11;
}
}

200
cathook/src/itemtypes.cpp Normal file
View File

@ -0,0 +1,200 @@
/*
* itemtypes.cpp
*
* Created on: Feb 10, 2017
* Author: nullifiedcat
*/
#include "itemtypes.h"
#include "common.h"
#include "sdk.h"
ItemManager::ItemManager() : mapper() {
// == MEDKITS
// Normal
RegisterModelMapping("models/items/medkit_small.mdl", ITEM_HEALTH_SMALL);
RegisterModelMapping("models/items/medkit_medium.mdl", ITEM_HEALTH_MEDIUM);
RegisterModelMapping("models/items/medkit_large.mdl", ITEM_HEALTH_LARGE);
// Halloween
RegisterModelMapping("models/props_halloween/halloween_medkit_small.mdl", ITEM_HEALTH_SMALL);
RegisterModelMapping("models/props_halloween/halloween_medkit_medium.mdl", ITEM_HEALTH_MEDIUM);
RegisterModelMapping("models/props_halloween/halloween_medkit_large.mdl", ITEM_HEALTH_LARGE);
// Holiday
RegisterModelMapping("models/items/medkit_small_bday.mdl", ITEM_HEALTH_SMALL);
RegisterModelMapping("models/items/medkit_medium_bday.mdl", ITEM_HEALTH_MEDIUM);
RegisterModelMapping("models/items/medkit_large_bday.mdl", ITEM_HEALTH_LARGE);
// Medieval
RegisterModelMapping("models/props_medieval/medieval_meat.mdl", ITEM_HEALTH_MEDIUM);
// == AMMOPACKS
// Normal
RegisterModelMapping("models/items/ammopack_small.mdl", ITEM_AMMO_SMALL);
RegisterModelMapping("models/items/ammopack_medium.mdl", ITEM_AMMO_MEDIUM);
RegisterModelMapping("models/items/ammopack_large.mdl", ITEM_AMMO_LARGE);
// Holiday
RegisterModelMapping("models/items/ammopack_small_bday.mdl", ITEM_AMMO_SMALL);
RegisterModelMapping("models/items/ammopack_medium_bday.mdl", ITEM_AMMO_MEDIUM);
RegisterModelMapping("models/items/ammopack_large_bday.mdl", ITEM_AMMO_LARGE);
// == POWERUPS
RegisterModelMapping("models/pickups/pickup_powerup_haste.mdl", ITEM_POWERUP_HASTE);
RegisterModelMapping("models/pickups/pickup_powerup_vampire.mdl", ITEM_POWERUP_VAMPIRE);
RegisterModelMapping("models/pickups/pickup_powerup_precision.mdl", ITEM_POWERUP_PRECISION);
//RegisterModelMapping("models/pickups/pickup_powerup_strength_arm.mdl", ITEM_POWERUP_AGILITY);
RegisterModelMapping("models/pickups/pickup_powerup_regen.mdl", ITEM_POWERUP_REGENERATION);
RegisterModelMapping("models/pickups/pickup_powerup_supernova.mdl", ITEM_POWERUP_SUPERNOVA);
RegisterModelMapping("models/pickups/pickup_powerup_strength.mdl", ITEM_POWERUP_STRENGTH);
//RegisterModelMapping("models/pickups/pickup_powerup_resistance.mdl", ITEM_POWERUP_RESISTANCE);
RegisterModelMapping("models/pickups/pickup_powerup_knockout.mdl", ITEM_POWERUP_KNOCKOUT);
//RegisterModelMapping("models/pickups/pickup_powerup_uber.mdl", ITEM_POWERUP_AGILITY);
RegisterModelMapping("models/pickups/pickup_powerup_defense.mdl", ITEM_POWERUP_RESISTANCE);
RegisterModelMapping("models/pickups/pickup_powerup_crit.mdl", ITEM_POWERUP_CRITS);
RegisterModelMapping("models/pickups/pickup_powerup_agility.mdl", ITEM_POWERUP_AGILITY);
RegisterModelMapping("models/pickups/pickup_powerup_king.mdl", ITEM_POWERUP_KING);
//RegisterModelMapping("models/pickups/pickup_powerup_warlock.mdl", ITEM_POWERUP_REFLECT);
RegisterModelMapping("models/pickups/pickup_powerup_plague.mdl", ITEM_POWERUP_PLAGUE);
RegisterModelMapping("models/pickups/pickup_powerup_reflect.mdl", ITEM_POWERUP_REFLECT);
//RegisterModelMapping("models/pickups/pickup_powerup_thorns.mdl", ITEM_POWERUP_AGILITY);
RegisterModelMapping("models/items/battery.mdl", ITEM_HL_BATTERY);
RegisterModelMapping("models/items/healthkit.mdl", ITEM_HEALTH_MEDIUM);
//RegisterModelMapping("models/pickups/pickup_powerup_reflect.mdl", ITEM_POWERUP_REFLECT);
RegisterSpecialMapping([](CachedEntity* ent) -> bool {
return ent->m_iClassID == g_pClassID->CTFAmmoPack;
}, ITEM_AMMO_MEDIUM);
RegisterModelMapping("models/items/medkit_overheal.mdl", ITEM_TF2C_PILL);
// TF2C spawners
specials.push_back([](CachedEntity* entity) -> k_EItemType {
static ItemModelMapper tf2c_weapon_mapper = []() -> ItemModelMapper {
ItemModelMapper result;
result.RegisterItem("models/weapons/w_models/w_bottle.mdl", ITEM_TF2C_W_BOTTLE);
result.RegisterItem("models/weapons/w_models/w_grenade_napalm.mdl", ITEM_TF2C_W_GRENADE_NAPALM);
result.RegisterItem("models/weapons/w_models/w_supershotgun_mercenary.mdl", ITEM_TF2C_W_SUPERSHOTGUN_MERCENARY);
result.RegisterItem("models/weapons/w_models/w_rocketbeta.mdl", ITEM_TF2C_W_ROCKETBETA);
result.RegisterItem("models/weapons/w_models/w_grenade_grenadelauncher.mdl", ITEM_TF2C_W_GRENADE_GRENADELAUNCHER);
result.RegisterItem("models/weapons/w_models/w_grenadelauncher.mdl", ITEM_TF2C_W_GRENADELAUNCHER);
result.RegisterItem("models/weapons/w_models/w_grenade_pipebomb.mdl", ITEM_TF2C_W_GRENADE_PIPEBOMB);
result.RegisterItem("models/weapons/w_models/w_cigarette_case.mdl", ITEM_TF2C_W_CIGARETTE_CASE);
result.RegisterItem("models/weapons/w_models/w_brandingiron.mdl", ITEM_TF2C_W_BRANDINGIRON);
result.RegisterItem("models/weapons/w_models/w_banhammer.mdl", ITEM_TF2C_W_BANHAMMER);
result.RegisterItem("models/weapons/w_models/w_sniperrifle.mdl", ITEM_TF2C_W_SNIPERRIFLE);
result.RegisterItem("models/weapons/w_models/w_grenade_heal.mdl", ITEM_TF2C_W_GRENADE_HEAL);
result.RegisterItem("models/weapons/w_models/w_hammerfists.mdl", ITEM_TF2C_W_HAMMERFISTS);
result.RegisterItem("models/weapons/w_models/w_grenade_nail.mdl", ITEM_TF2C_W_GRENADE_NAIL);
result.RegisterItem("models/weapons/w_models/w_dart.mdl", ITEM_TF2C_W_DART);
result.RegisterItem("models/weapons/w_models/w_rpg.mdl", ITEM_TF2C_W_RPG);
result.RegisterItem("models/weapons/w_models/w_umbrella_civilian.mdl", ITEM_TF2C_W_UMBRELLA_CIVILIAN);
result.RegisterItem("models/weapons/w_models/w_grenade_frag.mdl", ITEM_TF2C_W_GRENADE_FRAG);
result.RegisterItem("models/weapons/w_models/w_grenade_mirv.mdl", ITEM_TF2C_W_GRENADE_MIRV);
result.RegisterItem("models/weapons/w_models/w_medigun.mdl", ITEM_TF2C_W_MEDIGUN);
result.RegisterItem("models/weapons/w_models/w_grenade_mirv_demo.mdl", ITEM_TF2C_W_GRENADE_MIRV_DEMO);
result.RegisterItem("models/weapons/w_models/w_pickaxe.mdl", ITEM_TF2C_W_PICKAXE);
result.RegisterItem("models/weapons/w_models/w_syringegun.mdl", ITEM_TF2C_W_SYRINGEGUN);
result.RegisterItem("models/weapons/w_models/w_scattergun.mdl", ITEM_TF2C_W_SCATTERGUN);
result.RegisterItem("models/weapons/w_models/w_stengun.mdl", ITEM_TF2C_W_STENGUN);
result.RegisterItem("models/weapons/w_models/w_snubnose.mdl", ITEM_TF2C_W_SNUBNOSE);
result.RegisterItem("models/weapons/w_models/w_minigun.mdl", ITEM_TF2C_W_MINIGUN);
result.RegisterItem("models/weapons/w_models/w_wrench.mdl", ITEM_TF2C_W_WRENCH);
result.RegisterItem("models/weapons/w_models/w_bat.mdl", ITEM_TF2C_W_BAT);
result.RegisterItem("models/weapons/w_models/w_sapper.mdl", ITEM_TF2C_W_SAPPER);
result.RegisterItem("models/weapons/w_models/w_rocket.mdl", ITEM_TF2C_W_ROCKET);
result.RegisterItem("models/weapons/w_models/w_hammer.mdl", ITEM_TF2C_W_HAMMER);
result.RegisterItem("models/weapons/w_models/w_fishwhacker.mdl", ITEM_TF2C_W_FISHWHACKER);
result.RegisterItem("models/weapons/w_models/w_kritzkrieg.mdl", ITEM_TF2C_W_KRITZKRIEG);
result.RegisterItem("models/weapons/w_models/w_flaregun.mdl", ITEM_TF2C_W_FLAREGUN);
result.RegisterItem("models/weapons/w_models/w_shovel.mdl", ITEM_TF2C_W_SHOVEL);
result.RegisterItem("models/weapons/w_models/w_pistol.mdl", ITEM_TF2C_W_PISTOL);
result.RegisterItem("models/weapons/w_models/w_smg.mdl", ITEM_TF2C_W_SMG);
result.RegisterItem("models/weapons/w_models/w_leadpipe.mdl", ITEM_TF2C_W_LEADPIPE);
result.RegisterItem("models/weapons/w_models/w_flaregun_shell.mdl", ITEM_TF2C_W_FLAREGUN_SHELL);
result.RegisterItem("models/weapons/w_models/w_grenade_emp.mdl", ITEM_TF2C_W_GRENADE_EMP);
result.RegisterItem("models/weapons/w_models/w_cyclops.mdl", ITEM_TF2C_W_CYCLOPS);
result.RegisterItem("models/weapons/w_models/w_machete.mdl", ITEM_TF2C_W_MACHETE);
result.RegisterItem("models/weapons/w_models/w_shotgun.mdl", ITEM_TF2C_W_SHOTGUN);
result.RegisterItem("models/weapons/w_models/w_revolver.mdl", ITEM_TF2C_W_REVOLVER);
result.RegisterItem("models/weapons/w_models/w_grenade_gas.mdl", ITEM_TF2C_W_GRENADE_GAS);
result.RegisterItem("models/weapons/w_models/w_grenade_beartrap.mdl", ITEM_TF2C_W_GRENADE_BEARTRAP);
result.RegisterItem("models/weapons/w_models/w_fireaxe.mdl", ITEM_TF2C_W_FIREAXE);
result.RegisterItem("models/weapons/w_models/w_grenade_conc.mdl", ITEM_TF2C_W_GRENADE_CONC);
result.RegisterItem("models/weapons/w_models/w_nailgun.mdl", ITEM_TF2C_W_NAILGUN);
result.RegisterItem("models/weapons/w_models/w_bonesaw.mdl", ITEM_TF2C_W_BONESAW);
result.RegisterItem("models/weapons/w_models/w_stickybomb_launcher.mdl", ITEM_TF2C_W_STICKYBOMB_LAUNCHER);
result.RegisterItem("models/weapons/w_models/w_grenade_bomblet.mdl", ITEM_TF2C_W_GRENADE_BOMBLET);
result.RegisterItem("models/weapons/w_models/w_tranq.mdl", ITEM_TF2C_W_TRANQ);
result.RegisterItem("models/weapons/w_models/w_dynamite.mdl", ITEM_TF2C_W_DYNAMITE);
result.RegisterItem("models/weapons/w_models/w_club.mdl", ITEM_TF2C_W_CLUB);
result.RegisterItem("models/weapons/w_models/w_tommygun.mdl", ITEM_TF2C_W_TOMMYGUN);
result.RegisterItem("models/weapons/w_models/w_coffepot.mdl", ITEM_TF2C_W_COFFEPOT);
result.RegisterItem("models/weapons/w_models/w_stickybomb.mdl", ITEM_TF2C_W_STICKYBOMB);
result.RegisterItem("models/weapons/w_models/w_rocketlauncher.mdl", ITEM_TF2C_W_ROCKETLAUNCHER);
result.RegisterItem("models/weapons/w_models/w_flamethrower.mdl", ITEM_TF2C_W_FLAMETHROWER);
result.RegisterItem("models/weapons/w_models/w_crowbar.mdl", ITEM_TF2C_W_CROWBAR);
result.RegisterItem("models/weapons/w_models/w_builder.mdl", ITEM_TF2C_W_BUILDER);
result.RegisterItem("models/weapons/w_models/w_heavy_artillery.mdl", ITEM_TF2C_W_HEAVY_ARTILLERY);
result.RegisterItem("models/weapons/w_models/w_knife.mdl", ITEM_TF2C_W_KNIFE);
result.RegisterItem("models/weapons/w_models/w_pda_engineer.mdl", ITEM_TF2C_W_PDA_ENGINEER);
result.RegisterItem("models/weapons/w_models/w_bottle_broken.mdl", ITEM_TF2C_W_BOTTLE_BROKEN);
result.RegisterItem("models/weapons/w_models/w_toolbox.mdl", ITEM_TF2C_W_TOOLBOX);
result.RegisterItem("models/weapons/w_models/w_syringe_proj.mdl", ITEM_TF2C_W_SYRINGE_PROJ);
result.RegisterItem("models/weapons/w_models/w_nail.mdl", ITEM_TF2C_W_NAIL);
result.RegisterItem("models/weapons/w_models/w_syringe.mdl", ITEM_TF2C_W_SYRINGE);
result.RegisterItem("models/weapons/w_models/w_overhealer.mdl", ITEM_TF2C_W_OVERHEALER);
return result;
}();
if (entity->m_iClassID == g_pClassID->CWeaponSpawner) {
return tf2c_weapon_mapper.GetItemType(entity);
}
return ITEM_NONE;
});
}
void ItemManager::RegisterModelMapping(std::string path, k_EItemType type) {
mapper.RegisterItem(path, type);
}
void ItemManager::RegisterSpecialMapping(ItemCheckerFn fn, k_EItemType type) {
special_map.emplace(fn, type);
}
k_EItemType ItemManager::GetItemType(CachedEntity* ent) {
for (const auto& it : specials) {
const auto type = it(ent);
if (type != ITEM_NONE) return type;
}
for (const auto& it : special_map) {
if (it.first(ent)) return it.second;
}
return mapper.GetItemType(ent);
}
void ItemModelMapper::RegisterItem(std::string modelpath, k_EItemType type) {
models.emplace(modelpath, type);
}
k_EItemType ItemModelMapper::GetItemType(CachedEntity* entity) {
const uintptr_t model = (uintptr_t)RAW_ENT(entity)->GetModel();
for (const auto& it : map) {
if (it.first == model) return it.second;
}
std::string path(interfaces::model->GetModelName((const model_t*)model));
bool set = false;
for (const auto& it : models) {
//logging::Info("comparing [%s] to [%s]", path.c_str(), it.first.c_str());
if (it.first == path) {
//logging::Info("Found %s!", path.c_str());
map.emplace(model, it.second);
set = true;
break;
}
}
if (!set) map.emplace(model, k_EItemType::ITEM_NONE);
return k_EItemType::ITEM_NONE;
}
ItemManager g_ItemManager;

178
cathook/src/itemtypes.h Normal file
View File

@ -0,0 +1,178 @@
/*
* itemtypes.h
*
* Created on: Feb 10, 2017
* Author: nullifiedcat
*/
#ifndef ITEMTYPES_H_
#define ITEMTYPES_H_
#include "beforecheaders.h"
#include <map>
#include <string>
#include <vector>
#include "aftercheaders.h"
const std::string tf2c_weapon_names[] = {
"BOTTLE",
"GRENADE_NAPALM", "SUPERSHOTGUN_MERCENARY", "ROCKETBETA", "GRENADE_GRENADELAUNCHER",
"GRENADELAUNCHER", "GRENADE_PIPEBOMB", "CIGARETTE_CASE", "BRANDINGIRON",
"BANHAMMER", "SNIPERRIFLE", "GRENADE_HEAL", "HAMMERFISTS",
"GRENADE_NAIL", "DART", "RPG", "UMBRELLA_CIVILIAN",
"GRENADE_FRAG", "GRENADE_MIRV", "MEDIGUN", "GRENADE_MIRV_DEMO",
"PICKAXE", "SYRINGEGUN", "SCATTERGUN", "STENGUN",
"SNUBNOSE", "MINIGUN", "WRENCH", "BAT",
"SAPPER", "ROCKET", "HAMMER", "FISHWHACKER",
"KRITZKRIEG", "FLAREGUN", "SHOVEL", "PISTOL",
"SMG", "LEADPIPE", "FLAREGUN_SHELL", "GRENADE_EMP",
"CYCLOPS", "MACHETE", "SHOTGUN", "REVOLVER",
"GRENADE_GAS", "GRENADE_BEARTRAP", "FIREAXE", "GRENADE_CONC",
"NAILGUN", "BONESAW", "STICKYBOMB_LAUNCHER", "GRENADE_BOMBLET",
"TRANQ", "DYNAMITE", "CLUB", "TOMMYGUN",
"COFFEPOT", "STICKYBOMB", "ROCKETLAUNCHER", "FLAMETHROWER",
"CROWBAR", "BUILDER", "HEAVY_ARTILLERY", "KNIFE",
"PDA_ENGINEER", "BOTTLE_BROKEN", "TOOLBOX", "SYRINGE_PROJ",
"NAIL", "SYRINGE", "OVERHEALER" };
enum k_EItemType {
ITEM_NONE = 0,
ITEM_HEALTH_SMALL,
ITEM_HEALTH_MEDIUM,
ITEM_HEALTH_LARGE,
ITEM_AMMO_SMALL,
ITEM_AMMO_MEDIUM,
ITEM_AMMO_LARGE,
ITEM_POWERUP_STRENGTH,
ITEM_POWERUP_RESISTANCE,
ITEM_POWERUP_VAMPIRE,
ITEM_POWERUP_REFLECT,
ITEM_POWERUP_HASTE,
ITEM_POWERUP_REGENERATION,
ITEM_POWERUP_PRECISION,
ITEM_POWERUP_AGILITY,
ITEM_POWERUP_KNOCKOUT,
ITEM_POWERUP_KING,
ITEM_POWERUP_PLAGUE,
ITEM_POWERUP_SUPERNOVA,
ITEM_POWERUP_CRITS,
ITEM_POWERUP_FIRST = ITEM_POWERUP_STRENGTH,
ITEM_POWERUP_LAST = ITEM_POWERUP_CRITS,
ITEM_TF2C_PILL,
ITEM_TF2C_CRITS,
ITEM_TF2C_W_BOTTLE,
ITEM_TF2C_W_GRENADE_NAPALM,
ITEM_TF2C_W_SUPERSHOTGUN_MERCENARY,
ITEM_TF2C_W_ROCKETBETA,
ITEM_TF2C_W_GRENADE_GRENADELAUNCHER,
ITEM_TF2C_W_GRENADELAUNCHER,
ITEM_TF2C_W_GRENADE_PIPEBOMB,
ITEM_TF2C_W_CIGARETTE_CASE,
ITEM_TF2C_W_BRANDINGIRON,
ITEM_TF2C_W_BANHAMMER,
ITEM_TF2C_W_SNIPERRIFLE,
ITEM_TF2C_W_GRENADE_HEAL,
ITEM_TF2C_W_HAMMERFISTS,
ITEM_TF2C_W_GRENADE_NAIL,
ITEM_TF2C_W_DART,
ITEM_TF2C_W_RPG,
ITEM_TF2C_W_UMBRELLA_CIVILIAN,
ITEM_TF2C_W_GRENADE_FRAG,
ITEM_TF2C_W_GRENADE_MIRV,
ITEM_TF2C_W_MEDIGUN,
ITEM_TF2C_W_GRENADE_MIRV_DEMO,
ITEM_TF2C_W_PICKAXE,
ITEM_TF2C_W_SYRINGEGUN,
ITEM_TF2C_W_SCATTERGUN,
ITEM_TF2C_W_STENGUN,
ITEM_TF2C_W_SNUBNOSE,
ITEM_TF2C_W_MINIGUN,
ITEM_TF2C_W_WRENCH,
ITEM_TF2C_W_BAT,
ITEM_TF2C_W_SAPPER,
ITEM_TF2C_W_ROCKET,
ITEM_TF2C_W_HAMMER,
ITEM_TF2C_W_FISHWHACKER,
ITEM_TF2C_W_KRITZKRIEG,
ITEM_TF2C_W_FLAREGUN,
ITEM_TF2C_W_SHOVEL,
ITEM_TF2C_W_PISTOL,
ITEM_TF2C_W_SMG,
ITEM_TF2C_W_LEADPIPE,
ITEM_TF2C_W_FLAREGUN_SHELL,
ITEM_TF2C_W_GRENADE_EMP,
ITEM_TF2C_W_CYCLOPS,
ITEM_TF2C_W_MACHETE,
ITEM_TF2C_W_SHOTGUN,
ITEM_TF2C_W_REVOLVER,
ITEM_TF2C_W_GRENADE_GAS,
ITEM_TF2C_W_GRENADE_BEARTRAP,
ITEM_TF2C_W_FIREAXE,
ITEM_TF2C_W_GRENADE_CONC,
ITEM_TF2C_W_NAILGUN,
ITEM_TF2C_W_BONESAW,
ITEM_TF2C_W_STICKYBOMB_LAUNCHER,
ITEM_TF2C_W_GRENADE_BOMBLET,
ITEM_TF2C_W_TRANQ,
ITEM_TF2C_W_DYNAMITE,
ITEM_TF2C_W_CLUB,
ITEM_TF2C_W_TOMMYGUN,
ITEM_TF2C_W_COFFEPOT,
ITEM_TF2C_W_STICKYBOMB,
ITEM_TF2C_W_ROCKETLAUNCHER,
ITEM_TF2C_W_FLAMETHROWER,
ITEM_TF2C_W_CROWBAR,
ITEM_TF2C_W_BUILDER,
ITEM_TF2C_W_HEAVY_ARTILLERY,
ITEM_TF2C_W_KNIFE,
ITEM_TF2C_W_PDA_ENGINEER,
ITEM_TF2C_W_BOTTLE_BROKEN,
ITEM_TF2C_W_TOOLBOX,
ITEM_TF2C_W_SYRINGE_PROJ,
ITEM_TF2C_W_NAIL,
ITEM_TF2C_W_SYRINGE,
ITEM_TF2C_W_OVERHEALER,
ITEM_TF2C_W_FIRST = ITEM_TF2C_W_BOTTLE,
ITEM_TF2C_W_LAST = ITEM_TF2C_W_OVERHEALER,
ITEM_HL_BATTERY,
ITEM_COUNT
};
class CachedEntity;
typedef bool(*ItemCheckerFn)(CachedEntity*);
typedef k_EItemType(*ItemSpecialMapperFn)(CachedEntity*);
class ItemModelMapper {
public:
void RegisterItem(std::string modelpath, k_EItemType type);
k_EItemType GetItemType(CachedEntity* entity);
std::map<std::string, k_EItemType> models;
std::map<uintptr_t, k_EItemType> map;
};
class ItemManager {
public:
ItemManager();
void RegisterModelMapping(std::string path, k_EItemType type);
void RegisterSpecialMapping(ItemCheckerFn fn, k_EItemType type);
k_EItemType GetItemType(CachedEntity* ent);
std::map<ItemCheckerFn, k_EItemType> special_map;
std::vector<ItemSpecialMapperFn> specials;
ItemModelMapper mapper_special;
ItemModelMapper mapper;
};
extern ItemManager g_ItemManager;
#endif /* ITEMTYPES_H_ */

View File

@ -56,6 +56,9 @@ void NetVars::Init() {
this->iWeaponState = gNetvars.get_offset("DT_WeaponMinigun", "m_iWeaponState");
}
if (TF2C) this->iCritMult = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_iCritMult");
if (TF2C) {
this->bRespawning = gNetvars.get_offset("DT_WeaponSpawner", "m_bRespawning");
}
this->flNextAttack = gNetvars.get_offset("DT_BaseCombatCharacter", "bcc_localdata", "m_flNextAttack");
this->flNextPrimaryAttack = gNetvars.get_offset("DT_BaseCombatWeapon", "LocalActiveWeaponData", "m_flNextPrimaryAttack");
this->iNextThinkTick = gNetvars.get_offset("DT_BaseCombatWeapon", "LocalActiveWeaponData", "m_nNextThinkTick");

View File

@ -79,7 +79,7 @@ public:
offset_t nTickBase;
//offset_t iDecapitations;
offset_t iMaxBuffedHealth;
offset_t bRespawning;
offset_t iItemDefinitionIndex;
offset_t AttributeList;