fix Handle related stuff

This commit is contained in:
BenCat07 2022-12-27 22:00:47 +01:00 committed by LightCat
parent ae2c42c242
commit a68f198508
21 changed files with 492 additions and 432 deletions

View File

@ -196,6 +196,7 @@ public:
offset_t m_angRotation;
offset_t m_hOwnerEntity;
offset_t m_hOriginalLauncher;
offset_t m_nStreaks_Player;
offset_t m_nStreaks_Resource;

View File

@ -136,7 +136,7 @@ bool AmbassadorCanHeadshot();
void ValidateUserCmd(CUserCmd *cmd, int sequence_nr);
// Convert a TF2 handle into an IDX -> ENTITY(IDX)
int HandleToIDX(int handle);
#define HandleToIDX(handle) (handle & 0xFFFF)
inline const char *teamname(int team)
{

View File

@ -64,9 +64,9 @@ void logging::Info(const char *fmt, ...)
va_list list;
va_start(list, fmt);
// Allocate buffer
char result[512];
char result[1024];
// Fill buffer
int size = vsnprintf(result, 512, fmt, list);
int size = vsnprintf(result, 1024, fmt, list);
va_end(list);
if (size < 0)
return;

View File

@ -52,7 +52,7 @@ void NetVars::Init()
// "m_flObservedCritChance");
this->iItemDefinitionIndex = gNetvars.get_offset("DT_EconEntity", "m_AttributeManager", "m_Item", "m_iItemDefinitionIndex");
this->AttributeList = gNetvars.get_offset("DT_EconEntity", "m_AttributeManager", "m_Item",
"m_AttributeList"); // hmmm
"m_AttributeList"); // hmmm
this->flChargeBeginTime = gNetvars.get_offset("DT_WeaponPipebombLauncher", "PipebombLauncherLocalData", "m_flChargeBeginTime");
this->flDetonateTime = gNetvars.get_offset("DT_WeaponGrenadeLauncher", "m_flDetonateTime");
this->flLastFireTime = gNetvars.get_offset("DT_TFWeaponBase", "LocalActiveTFWeaponData", "m_flLastFireTime");
@ -79,18 +79,19 @@ void NetVars::Init()
this->res_iScore = gNetvars.get_offset("DT_TFPlayerResource", "baseclass", "m_iScore");
IF_GAME(IsTF())
{
this->m_hOwnerEntity = gNetvars.get_offset("DT_BaseEntity", "m_hOwnerEntity");
this->res_iMaxHealth = gNetvars.get_offset("DT_TFPlayerResource", "m_iMaxHealth");
this->res_iPlayerClass = gNetvars.get_offset("DT_TFPlayerResource", "m_iPlayerClass");
this->m_bReadyToBackstab = gNetvars.get_offset("DT_TFWeaponKnife", "m_bReadyToBackstab");
this->m_bDucked = gNetvars.get_offset("DT_TFPlayer", "localdata", "m_Local", "m_bDucked");
this->m_flDuckTimer = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_flDuckTimer");
this->iCond = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_nPlayerCond");
this->iCond1 = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_nPlayerCondEx");
this->iCond2 = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_nPlayerCondEx2");
this->iCond3 = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_nPlayerCondEx3");
this->iClass = gNetvars.get_offset("DT_TFPlayer", "m_PlayerClass", "m_iClass");
this->flChargedDamage = gNetvars.get_offset("DT_TFSniperRifle", "SniperRifleLocalData", "m_flChargedDamage");
this->m_hOwnerEntity = gNetvars.get_offset("DT_BaseEntity", "m_hOwnerEntity");
this->m_hOriginalLauncher = gNetvars.get_offset("DT_BaseProjectile", "m_hOriginalLauncher");
this->res_iMaxHealth = gNetvars.get_offset("DT_TFPlayerResource", "m_iMaxHealth");
this->res_iPlayerClass = gNetvars.get_offset("DT_TFPlayerResource", "m_iPlayerClass");
this->m_bReadyToBackstab = gNetvars.get_offset("DT_TFWeaponKnife", "m_bReadyToBackstab");
this->m_bDucked = gNetvars.get_offset("DT_TFPlayer", "localdata", "m_Local", "m_bDucked");
this->m_flDuckTimer = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_flDuckTimer");
this->iCond = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_nPlayerCond");
this->iCond1 = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_nPlayerCondEx");
this->iCond2 = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_nPlayerCondEx2");
this->iCond3 = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_nPlayerCondEx3");
this->iClass = gNetvars.get_offset("DT_TFPlayer", "m_PlayerClass", "m_iClass");
this->flChargedDamage = gNetvars.get_offset("DT_TFSniperRifle", "SniperRifleLocalData", "m_flChargedDamage");
// sentry
this->m_iAmmoShells = gNetvars.get_offset("DT_ObjectSentrygun", "m_iAmmoShells");

View File

@ -73,7 +73,7 @@ CachedEntity *ClosestSpy()
{
if (CE_INT(ent, netvar.iClass) != tf_class::tf_pyro && CE_INT(ent, netvar.iClass) != tf_class::tf_heavy)
continue;
int idx = CE_INT(ent, netvar.hActiveWeapon) & 0xFFF;
int idx = HandleToIDX(CE_INT(ent, netvar.hActiveWeapon));
if (IDX_BAD(idx))
continue;
CachedEntity *pyro_weapon = ENTITY(idx);

View File

@ -26,7 +26,7 @@ bool IsFlare(CachedEntity *ent)
return false;
// Check if we're the owner of the flare
if ((CE_INT(ent, 0x894) & 0xFFF) != LOCAL_W->m_IDX)
if (HandleToIDX((CE_INT(ent, netvar.m_hOwnerEntity))) != LOCAL_W->m_IDX)
return false;
// Check passed, return true

View File

@ -34,7 +34,7 @@ bool IsBomb(CachedEntity *ent)
return false;
// Check if the stickybomb is the players own
if ((CE_INT(ent, netvar.hThrower) & 0xFFF) != g_pLocalPlayer->entity->m_IDX)
if (HandleToIDX(CE_INT(ent, netvar.hThrower)) != g_pLocalPlayer->entity->m_IDX)
return false;
// Check passed, return true

View File

@ -1464,7 +1464,7 @@ void _FASTCALL ProcessEntity(CachedEntity *ent)
for (int i = 0; weapon_list[i]; i++)
{
int handle = weapon_list[i];
int eid = handle & 0xFFF;
int eid = HandleToIDX(handle);
if (eid > MAX_PLAYERS && eid <= HIGHEST_ENTITY)
{
CachedEntity *weapon = ENTITY(eid);
@ -1542,7 +1542,7 @@ void _FASTCALL ProcessEntity(CachedEntity *ent)
// We want revving, zoomed and slowed to be mutually exclusive. Otherwise slowed and zoomed/revving will show at the same time.
// Revving
auto weapon_idx = CE_INT(ent, netvar.hActiveWeapon) & 0xFFF;
auto weapon_idx = HandleToIDX(CE_INT(ent, netvar.hActiveWeapon));
CachedEntity *weapon = IDX_GOOD(weapon_idx) ? ENTITY(weapon_idx) : nullptr;
if (CE_GOOD(weapon) && weapon->m_iClassID() == CL_CLASS(CTFMinigun) && CE_INT(weapon, netvar.iWeaponState) != 0)
AddEntityString(ent, revving_str, colors::FromRGBA8(220.0f, 220.0f, 220.0f, 255.0f));
@ -1571,7 +1571,7 @@ void _FASTCALL ProcessEntity(CachedEntity *ent)
// Active weapon esp
if (show_weapon)
{
int widx = CE_INT(ent, netvar.hActiveWeapon) & 0xFFF;
int widx = HandleToIDX(CE_INT(ent, netvar.hActiveWeapon));
if (IDX_GOOD(widx))
{
CachedEntity *weapon = ENTITY(widx);

View File

@ -677,7 +677,7 @@ static void cm()
last_slot_check = g_GlobalVars->curtime;
// Get the follow targets active weapon
int owner_weapon_eid = (CE_INT(ENTITY(follow_target), netvar.hActiveWeapon) & 0xFFF);
int owner_weapon_eid = HandleToIDX(CE_INT(ENTITY(follow_target), netvar.hActiveWeapon));
IClientEntity *owner_weapon = g_IEntityList->GetClientEntity(owner_weapon_eid);
// If both the follow targets and the local players weapons are

View File

@ -421,7 +421,7 @@ void Draw()
// Assign the for loops tick number to an ent
CachedEntity *ent = ENTITY(i);
player_info_s info;
if (!CE_BAD(ent) && ent != LOCAL_E && ent->m_Type() == ENTITY_PLAYER && (CE_INT(ent, netvar.hObserverTarget) & 0xFFF) == LOCAL_E->m_IDX && CE_INT(ent, netvar.iObserverMode) >= 4 && GetPlayerInfo(i, &info))
if (!CE_BAD(ent) && ent != LOCAL_E && ent->m_Type() == ENTITY_PLAYER && HandleToIDX(CE_INT(ent, netvar.hObserverTarget)) == LOCAL_E->m_IDX && CE_INT(ent, netvar.iObserverMode) >= 4 && GetPlayerInfo(i, &info))
{
auto observermode = "N/A";
rgba_t color = colors::green;
@ -1061,6 +1061,8 @@ inline void force_wait_func(bool after)
patch_wait.Shutdown();
}
static CatCommand debug_xd("debug_sig_pls", "debug", []() { gSignatures.GetClientSignature("55 89 E5 57 56 53 83 EC 6C C7 45 ? 00 00 00 00 A1 ? ? ? ? C7 45 ? 00 00 00 00 8B 5D ? 85 C0 0F 84 ? ? ? ? 8D 55 ? 89 04 24 31 F6 89 54 24 ? C7 44 24 ? ? ? ? ? C7 44 24 ? ? ? ? ? C7 44 24 ? ? ? ? ? C7 44 24 ? ? ? ? ? C7 44 24 ? 6B 00 00 00 C7 44 24 ? ? ? ? ? C7 44 24 ? 00 00 00 00 C7 44 24 ? 00 00 00 00 C7 44 24 ? 00 00 00 00 C7 44 24 ? 00 00 00 00 FF 50 ? A1 ? ? ? ? 8B 3D ? ? ? ? 8B 55 ? 89 45 ? 8B 45 ? 85 FF 89 55 ? 89 45 ? 0F 85 ? ? ? ? 85 DB 0F 84 ? ? ? ? 8B 7B ? 85 FF 0F 84 ? ? ? ? C7 04 24 ? ? ? ? E8 ? ? ? ? 89 45 ? 8B 07 89 3C 24 FF 10 8B 7D ? 8B 10 C7 44 24 ? 00 00 00 00 89 5C 24 ? C7 44 24 ? 00 00 80 3F 89 7C 24 ? 89 04 24 FF 52 ? D9 5D ? F3 0F 10 45 ? F3 0F 11 04 24 E8 ? ? ? ? D9 5D"); });
void callback_force_wait(settings::VariableBase<bool> &, bool after)
{
force_wait_func(after);

View File

@ -100,7 +100,7 @@ bool shouldSearchAmmo()
for (int i = 0; weapon_list[i]; i++)
{
int handle = weapon_list[i];
int eid = handle & 0xFFF;
int eid = HandleToIDX(handle);
if (eid > MAX_PLAYERS && eid <= HIGHEST_ENTITY)
{
IClientEntity *weapon = g_IEntityList->GetClientEntity(eid);

View File

@ -23,7 +23,7 @@ static settings::Boolean debug{ "skinchanger.debug", "false" };
const char *sig_GetAttributeDefinition = "55 89 E5 57 56 53 83 EC 6C C7 45 9C 00 00 00 00";
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";
"DB 89 D8 74 0B 83 C4 1C 5B 5E 5F 5D C3";
ItemSystem_t ItemSystem{ nullptr };
GetAttributeDefinition_t GetAttributeDefinitionFn{ nullptr };
@ -35,7 +35,7 @@ ItemSchemaPtr_t GetItemSchema(void)
{
ItemSystem = (ItemSystem_t) gSignatures.GetClientSignature((char *) sig_GetItemSchema);
}
return (void *) ((uint32_t)(ItemSystem()) + 4);
return (void *) ((uint32_t) (ItemSystem()) + 4);
}
CAttribute::CAttribute(uint16_t iAttributeDefinitionIndex, float flValue)
@ -98,143 +98,163 @@ void CAttributeList::SetAttribute(int index, float value)
static std::array<int, 46> australium_table{ 4, 7, 13, 14, 15, 16, 18, 19, 20, 21, 29, 36, 38, 45, 61, 132, 141, 194, 197, 200, 201, 202, 203, 205, 206, 207, 208, 211, 228, 424, 654, 658, 659, 662, 663, 664, 665, 669, 1000, 1004, 1006, 1007, 1078, 1082, 1085, 1149 };
static std::array<std::pair<int, int>, 12> redirects{ std::pair{ 264, 1071 }, std::pair{ 18, 205 }, std::pair{ 13, 200 }, std::pair{ 21, 208 }, std::pair{ 19, 206 }, std::pair{ 20, 207 }, std::pair{ 15, 202 }, std::pair{ 7, 197 }, std::pair{ 29, 211 }, std::pair{ 14, 201 }, std::pair{ 16, 203 }, std::pair{ 4, 194 } };
static CatCommand australize("australize", "Make everything australium", []() {
enable = true;
for (auto i : redirects)
GetModifier(i.first).defidx_redirect = i.second;
for (auto i : australium_table)
{
GetModifier(i).Set(2027, 1);
GetModifier(i).Set(2022, 1);
GetModifier(i).Set(542, 1);
}
InvalidateCookie();
});
static CatCommand set_attr("skinchanger_set", "Set Attribute", [](const CCommand &args) {
if (args.ArgC() < 2)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please Provide an Argument\n");
return;
}
enable = true;
try
{
if (CE_BAD(LOCAL_W))
return;
unsigned attrid = std::strtoul(args.Arg(1), nullptr, 10);
float attrv = std::strtof(args.Arg(2), nullptr);
GetModifier(CE_INT(LOCAL_W, netvar.iItemDefinitionIndex)).Set(attrid, attrv);
InvalidateCookie();
}
catch (const std::invalid_argument &)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please pass a valid int\n");
}
});
static CatCommand remove_attr("skinchanger_remove", "Remove attribute", [](const CCommand &args) {
if (args.ArgC() < 2)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please Provide an Argument\n");
return;
}
try
{
if (CE_BAD(LOCAL_W))
return;
enable = true;
unsigned attrid = std::strtoul(args.Arg(1), nullptr, 10);
GetModifier(CE_INT(LOCAL_W, netvar.iItemDefinitionIndex)).Remove(attrid);
InvalidateCookie();
}
catch (const std::invalid_argument &)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please pass a valid int\n");
}
});
static CatCommand set_redirect("skinchanger_redirect", "Set Redirect", [](const CCommand &args) {
if (args.ArgC() < 2)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please Provide an Argument\n");
return;
}
try
{
if (CE_BAD(LOCAL_W))
return;
enable = true;
unsigned redirect = std::strtoul(args.Arg(1), nullptr, 10);
GetModifier(CE_INT(LOCAL_W, netvar.iItemDefinitionIndex)).defidx_redirect = redirect;
InvalidateCookie();
}
catch (const std::invalid_argument &)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please pass a valid int\n");
}
});
static CatCommand dump_attrs("skinchanger_debug_attrs", "Dump attributes", []() {
CAttributeList *list = (CAttributeList *) ((uintptr_t)(RAW_ENT(LOCAL_W)) + netvar.AttributeList);
logging::Info("ATTRIBUTE LIST: %i", list->m_Attributes.Size());
for (int i = 0; i < list->m_Attributes.Size(); i++)
{
logging::Info("%i %.2f", list->m_Attributes[i].defidx, list->m_Attributes[i].value);
}
});
static CatCommand australize("australize", "Make everything australium",
[]()
{
enable = true;
for (auto i : redirects)
GetModifier(i.first).defidx_redirect = i.second;
for (auto i : australium_table)
{
GetModifier(i).Set(2027, 1);
GetModifier(i).Set(2022, 1);
GetModifier(i).Set(542, 1);
}
InvalidateCookie();
});
static CatCommand set_attr("skinchanger_set", "Set Attribute",
[](const CCommand &args)
{
if (args.ArgC() < 2)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please Provide an Argument\n");
return;
}
enable = true;
try
{
if (CE_BAD(LOCAL_W))
return;
unsigned attrid = std::strtoul(args.Arg(1), nullptr, 10);
float attrv = std::strtof(args.Arg(2), nullptr);
GetModifier(CE_INT(LOCAL_W, netvar.iItemDefinitionIndex)).Set(attrid, attrv);
InvalidateCookie();
}
catch (const std::invalid_argument &)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please pass a valid int\n");
}
});
static CatCommand remove_attr("skinchanger_remove", "Remove attribute",
[](const CCommand &args)
{
if (args.ArgC() < 2)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please Provide an Argument\n");
return;
}
try
{
if (CE_BAD(LOCAL_W))
return;
enable = true;
unsigned attrid = std::strtoul(args.Arg(1), nullptr, 10);
GetModifier(CE_INT(LOCAL_W, netvar.iItemDefinitionIndex)).Remove(attrid);
InvalidateCookie();
}
catch (const std::invalid_argument &)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please pass a valid int\n");
}
});
static CatCommand set_redirect("skinchanger_redirect", "Set Redirect",
[](const CCommand &args)
{
if (args.ArgC() < 2)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please Provide an Argument\n");
return;
}
try
{
if (CE_BAD(LOCAL_W))
return;
enable = true;
unsigned redirect = std::strtoul(args.Arg(1), nullptr, 10);
GetModifier(CE_INT(LOCAL_W, netvar.iItemDefinitionIndex)).defidx_redirect = redirect;
InvalidateCookie();
}
catch (const std::invalid_argument &)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please pass a valid int\n");
}
});
static CatCommand dump_attrs("skinchanger_debug_attrs", "Dump attributes",
[]()
{
CAttributeList *list = (CAttributeList *) ((uintptr_t) (RAW_ENT(LOCAL_W)) + netvar.AttributeList);
logging::Info("ATTRIBUTE LIST: %i", list->m_Attributes.Size());
for (int i = 0; i < list->m_Attributes.Size(); i++)
{
logging::Info("%i %.2f", list->m_Attributes[i].defidx, list->m_Attributes[i].value);
}
});
static CatCommand list_redirects("skinchanger_redirect_list", "Dump redirects", []() {
for (const auto &mod : modifier_map)
{
if (mod.second.defidx_redirect)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "%d -> %d\n", mod.first, mod.second.defidx_redirect);
}
}
});
static CatCommand save("skinchanger_save", "Save", [](const CCommand &args) {
std::string filename = "skinchanger";
if (args.ArgC() > 1)
{
filename = args.Arg(1);
}
Save(filename);
});
static CatCommand load("skinchanger_load", "Load", [](const CCommand &args) {
enable = true;
std::string filename = "skinchanger";
if (args.ArgC() > 1)
{
filename = args.Arg(1);
}
Load(filename);
});
static CatCommand load_merge("skinchanger_load_merge", "Load with merge", [](const CCommand &args) {
enable = true;
std::string filename = "skinchanger";
if (args.ArgC() > 1)
{
filename = args.Arg(1);
}
Load(filename, true);
});
static CatCommand remove_redirect("skinchanger_remove_redirect", "Remove redirect", [](const CCommand &args) {
if (args.ArgC() < 2)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please Provide an argument\n");
}
try
{
if (CE_BAD(LOCAL_W))
return;
enable = true;
unsigned redirectid = std::strtoul(args.Arg(1), nullptr, 10);
GetModifier(redirectid).defidx_redirect = 0;
logging::Info("Redirect removed");
InvalidateCookie();
}
catch (const std::invalid_argument &)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please supply a valid int\n");
}
});
static CatCommand list_redirects("skinchanger_redirect_list", "Dump redirects",
[]()
{
for (const auto &mod : modifier_map)
{
if (mod.second.defidx_redirect)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "%d -> %d\n", mod.first, mod.second.defidx_redirect);
}
}
});
static CatCommand save("skinchanger_save", "Save",
[](const CCommand &args)
{
std::string filename = "skinchanger";
if (args.ArgC() > 1)
{
filename = args.Arg(1);
}
Save(filename);
});
static CatCommand load("skinchanger_load", "Load",
[](const CCommand &args)
{
enable = true;
std::string filename = "skinchanger";
if (args.ArgC() > 1)
{
filename = args.Arg(1);
}
Load(filename);
});
static CatCommand load_merge("skinchanger_load_merge", "Load with merge",
[](const CCommand &args)
{
enable = true;
std::string filename = "skinchanger";
if (args.ArgC() > 1)
{
filename = args.Arg(1);
}
Load(filename, true);
});
static CatCommand remove_redirect("skinchanger_remove_redirect", "Remove redirect",
[](const CCommand &args)
{
if (args.ArgC() < 2)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please Provide an argument\n");
}
try
{
if (CE_BAD(LOCAL_W))
return;
enable = true;
unsigned redirectid = std::strtoul(args.Arg(1), nullptr, 10);
GetModifier(redirectid).defidx_redirect = 0;
logging::Info("Redirect removed");
InvalidateCookie();
}
catch (const std::invalid_argument &)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please supply a valid int\n");
}
});
static CatCommand reset("skinchanger_reset", "Reset", []() { modifier_map.clear(); });
static CatCommand invalidate_cookies("skinchanger_bite_cookie", "Bite Cookie", InvalidateCookie);
@ -254,18 +274,18 @@ void FrameStageNotify(int stage)
if (!SetRuntimeAttributeValueFn)
{
SetRuntimeAttributeValueFn = (SetRuntimeAttributeValue_t)(gSignatures.GetClientSignature((char *) sig_SetRuntimeAttributeValue));
SetRuntimeAttributeValueFn = (SetRuntimeAttributeValue_t) (gSignatures.GetClientSignature((char *) sig_SetRuntimeAttributeValue));
logging::Info("SetRuntimeAttributeValue: 0x%08x", SetRuntimeAttributeValueFn);
}
if (!GetAttributeDefinitionFn)
{
GetAttributeDefinitionFn = (GetAttributeDefinition_t)(gSignatures.GetClientSignature((char *) sig_GetAttributeDefinition));
GetAttributeDefinitionFn = (GetAttributeDefinition_t) (gSignatures.GetClientSignature((char *) sig_GetAttributeDefinition));
logging::Info("GetAttributeDefinition: 0x%08x", GetAttributeDefinitionFn);
}
weapon_list = (int *) ((unsigned) (RAW_ENT(LOCAL_E)) + netvar.hMyWeapons);
my_weapon = CE_INT(g_pLocalPlayer->entity, netvar.hActiveWeapon);
my_weapon_ptr = g_IEntityList->GetClientEntity(my_weapon & 0xFFF);
my_weapon_ptr = g_IEntityList->GetClientEntity(HandleToIDX(my_weapon));
if (!my_weapon_ptr)
return;
if (!re::C_BaseCombatWeapon::IsBaseCombatWeapon(my_weapon_ptr))
@ -273,7 +293,7 @@ void FrameStageNotify(int stage)
for (int i = 0; i < 4; i++)
{
handle = weapon_list[i];
eid = handle & 0xFFF;
eid = HandleToIDX(handle);
if (eid <= MAX_PLAYERS || eid > HIGHEST_ENTITY)
continue;
// logging::Info("eid, %i", eid);
@ -290,7 +310,7 @@ void FrameStageNotify(int stage)
}
}
if ((my_weapon_ptr != last_weapon_out) || !cookie.Check())
cookie.Update(my_weapon & 0xFFF);
cookie.Update(HandleToIDX(my_weapon));
last_weapon_out = my_weapon_ptr;
}
@ -305,7 +325,7 @@ void DrawText()
if (CE_GOOD(LOCAL_W))
{
AddSideString(format("dIDX: ", CE_INT(LOCAL_W, netvar.iItemDefinitionIndex)));
list = (CAttributeList *) ((uintptr_t)(RAW_ENT(LOCAL_W)) + netvar.AttributeList);
list = (CAttributeList *) ((uintptr_t) (RAW_ENT(LOCAL_W)) + netvar.AttributeList);
for (int i = 0; i < list->m_Attributes.Size(); i++)
{
AddSideString(format('[', i, "] ", list->m_Attributes[i].defidx, ": ", list->m_Attributes[i].value));

View File

@ -242,7 +242,7 @@ bool HasLowAmmo()
for (int i = 0; weapon_list[i]; i++)
{
int handle = weapon_list[i];
int eid = handle & 0xFFF;
int eid = HandleToIDX(handle);
if (eid > MAX_PLAYERS && eid <= HIGHEST_ENTITY)
{
IClientEntity *weapon = g_IEntityList->GetClientEntity(eid);
@ -410,24 +410,28 @@ bool Load(std::string filename)
return false;
}
static CatCommand save("wb_save", "Save", [](const CCommand &args) {
logging::Info("Saving");
std::string filename = "default";
if (args.ArgC() > 1)
{
filename = args.Arg(1);
}
Save(filename);
});
static CatCommand load("wb_load", "Load", [](const CCommand &args) {
logging::Info("Loading");
std::string filename = "default";
if (args.ArgC() > 1)
{
filename = args.Arg(1);
}
Load(filename);
});
static CatCommand save("wb_save", "Save",
[](const CCommand &args)
{
logging::Info("Saving");
std::string filename = "default";
if (args.ArgC() > 1)
{
filename = args.Arg(1);
}
Save(filename);
});
static CatCommand load("wb_load", "Load",
[](const CCommand &args)
{
logging::Info("Loading");
std::string filename = "default";
if (args.ArgC() > 1)
{
filename = args.Arg(1);
}
Load(filename);
});
index_t CreateNode(const Vector &xyz)
{
@ -442,138 +446,158 @@ index_t CreateNode(const Vector &xyz)
CatCommand c_start_recording("wb_record", "Start recording", []() { state::state = WB_RECORDING; });
CatCommand c_start_editing("wb_edit", "Start editing", []() { state::state = WB_EDITING; });
CatCommand c_start_replaying("wb_replay", "Start replaying", []() {
state::last_node = state::active_node;
state::active_node = state::closest_node;
state::state = WB_REPLAYING;
});
CatCommand c_start_replaying("wb_replay", "Start replaying",
[]()
{
state::last_node = state::active_node;
state::active_node = state::closest_node;
state::state = WB_REPLAYING;
});
CatCommand c_exit("wb_exit", "Exit", []() { state::state = WB_DISABLED; });
// Selects closest node, clears selection if node is selected
CatCommand c_select_node("wb_select", "Select node", []() {
if (state::active_node == state::closest_node)
{
state::active_node = BAD_NODE;
}
else
{
state::active_node = state::closest_node;
}
});
CatCommand c_select_node("wb_select", "Select node",
[]()
{
if (state::active_node == state::closest_node)
{
state::active_node = BAD_NODE;
}
else
{
state::active_node = state::closest_node;
}
});
// Makes a new node in the middle of connection between 2 nodes
CatCommand c_split_connection("wb_split", "Split connection", []() {
if (not(state::node_good(state::active_node) and state::node_good(state::closest_node)))
return;
CatCommand c_split_connection("wb_split", "Split connection",
[]()
{
if (not(state::node_good(state::active_node) and state::node_good(state::closest_node)))
return;
if (state::active_node == state::closest_node)
return;
if (state::active_node == state::closest_node)
return;
auto &a = state::nodes[state::active_node];
auto &b = state::nodes[state::closest_node];
auto &a = state::nodes[state::active_node];
auto &b = state::nodes[state::closest_node];
a.unlink(state::closest_node);
b.unlink(state::active_node);
a.unlink(state::closest_node);
b.unlink(state::active_node);
index_t node = CreateNode((a.xyz() + b.xyz()) / 2);
auto &n = state::nodes[node];
a.link(node);
n.link(state::active_node);
b.link(node);
n.link(state::closest_node);
});
index_t node = CreateNode((a.xyz() + b.xyz()) / 2);
auto &n = state::nodes[node];
a.link(node);
n.link(state::active_node);
b.link(node);
n.link(state::closest_node);
});
// Deletes closest node and its connections
CatCommand c_delete_node("wb_delete", "Delete node", []() { DeleteNode(state::closest_node); });
// Creates a new node under your feet and connects it to closest node to your
// crosshair
CatCommand c_create_node("wb_create", "Create node", []() {
index_t node = CreateNode(g_pLocalPlayer->v_Origin);
auto &n = state::nodes[node];
if (current_user_cmd->buttons & IN_DUCK)
n.flags |= NF_DUCK;
if (state::node_good(state::closest_node))
{
auto &c = state::nodes[state::closest_node];
n.link(state::closest_node);
c.link(node);
logging::Info("[wb] Node %u linked to node %u at (%.2f %.2f %.2f)", node, state::closest_node, c.x, c.y, c.z);
}
});
CatCommand c_create_node("wb_create", "Create node",
[]()
{
index_t node = CreateNode(g_pLocalPlayer->v_Origin);
auto &n = state::nodes[node];
if (current_user_cmd->buttons & IN_DUCK)
n.flags |= NF_DUCK;
if (state::node_good(state::closest_node))
{
auto &c = state::nodes[state::closest_node];
n.link(state::closest_node);
c.link(node);
logging::Info("[wb] Node %u linked to node %u at (%.2f %.2f %.2f)", node, state::closest_node, c.x, c.y, c.z);
}
});
// Connects selected node to closest one
CatCommand c_connect_node("wb_connect", "Connect nodes", []() {
if (not(state::node_good(state::active_node) and state::node_good(state::closest_node)))
return;
// Don't link a node to itself, idiot
if (state::active_node == state::closest_node)
return;
CatCommand c_connect_node("wb_connect", "Connect nodes",
[]()
{
if (not(state::node_good(state::active_node) and state::node_good(state::closest_node)))
return;
// Don't link a node to itself, idiot
if (state::active_node == state::closest_node)
return;
auto &a = state::nodes[state::active_node];
auto &b = state::nodes[state::closest_node];
auto &a = state::nodes[state::active_node];
auto &b = state::nodes[state::closest_node];
a.link(state::closest_node);
b.link(state::active_node);
});
a.link(state::closest_node);
b.link(state::active_node);
});
// Makes a one-way connection
CatCommand c_connect_single_node("wb_connect_single", "Connect nodes (one-way)", []() {
if (not(state::node_good(state::active_node) and state::node_good(state::closest_node)))
return;
// Don't link a node to itself, idiot
if (state::active_node == state::closest_node)
return;
CatCommand c_connect_single_node("wb_connect_single", "Connect nodes (one-way)",
[]()
{
if (not(state::node_good(state::active_node) and state::node_good(state::closest_node)))
return;
// Don't link a node to itself, idiot
if (state::active_node == state::closest_node)
return;
auto &a = state::nodes[state::active_node];
auto &a = state::nodes[state::active_node];
a.link(state::closest_node);
});
a.link(state::closest_node);
});
// Connects selected node to closest one
CatCommand c_disconnect_node("wb_disconnect", "Disconnect nodes", []() {
if (not(state::node_good(state::active_node) and state::node_good(state::closest_node)))
return;
// Don't link a node to itself, idiot
if (state::active_node == state::closest_node)
return;
CatCommand c_disconnect_node("wb_disconnect", "Disconnect nodes",
[]()
{
if (not(state::node_good(state::active_node) and state::node_good(state::closest_node)))
return;
// Don't link a node to itself, idiot
if (state::active_node == state::closest_node)
return;
auto &a = state::nodes[state::active_node];
auto &b = state::nodes[state::closest_node];
auto &a = state::nodes[state::active_node];
auto &b = state::nodes[state::closest_node];
a.unlink(state::closest_node);
b.unlink(state::active_node);
});
a.unlink(state::closest_node);
b.unlink(state::active_node);
});
// Makes a one-way connection
CatCommand c_disconnect_single_node("wb_disconnect_single", "Connect nodes (one-way)", []() {
if (not(state::node_good(state::active_node) and state::node_good(state::closest_node)))
return;
// Don't link a node to itself, idiot
if (state::active_node == state::closest_node)
return;
CatCommand c_disconnect_single_node("wb_disconnect_single", "Connect nodes (one-way)",
[]()
{
if (not(state::node_good(state::active_node) and state::node_good(state::closest_node)))
return;
// Don't link a node to itself, idiot
if (state::active_node == state::closest_node)
return;
auto &a = state::nodes[state::active_node];
auto &a = state::nodes[state::active_node];
a.unlink(state::closest_node);
});
a.unlink(state::closest_node);
});
// Toggles jump flag on closest node
CatCommand c_update_duck("wb_duck", "Toggle duck flag", []() {
if (not state::node_good(state::closest_node))
return;
CatCommand c_update_duck("wb_duck", "Toggle duck flag",
[]()
{
if (not state::node_good(state::closest_node))
return;
auto &n = state::nodes[state::closest_node];
auto &n = state::nodes[state::closest_node];
if (n.flags & NF_DUCK)
n.flags &= ~NF_DUCK;
else
n.flags |= NF_DUCK;
});
if (n.flags & NF_DUCK)
n.flags &= ~NF_DUCK;
else
n.flags |= NF_DUCK;
});
// Toggles jump flag on closest node
CatCommand c_update_jump("wb_jump", "Toggle jump flag", []() {
if (not state::node_good(state::closest_node))
return;
CatCommand c_update_jump("wb_jump", "Toggle jump flag",
[]()
{
if (not state::node_good(state::closest_node))
return;
auto &n = state::nodes[state::closest_node];
auto &n = state::nodes[state::closest_node];
if (n.flags & NF_JUMP)
n.flags &= ~NF_JUMP;
else
n.flags |= NF_JUMP;
});
if (n.flags & NF_JUMP)
n.flags &= ~NF_JUMP;
else
n.flags |= NF_JUMP;
});
// Assuming node is good and conn is in range [0; MAX_CONNECTIONS)
std::string DescribeConnection(index_t node, connection conn)
{
@ -608,117 +632,127 @@ std::string DescribeConnection(index_t node, connection conn)
std::string result = format(node, ' ', (broken ? "-x>" : (oneway ? "-->" : "<->")), ' ', c.node, ' ', extra);
return result;
}
CatCommand c_toggle_cf_ammo("wb_conn_ammo", "Toggle 'ammo' flag on connection from ACTIVE to CLOSEST node", []() {
auto a = state::active();
auto b = state::closest();
if (not(a and b))
return;
for (connection i = 0; i < MAX_CONNECTIONS; i++)
{
auto &c = a->connections[i];
if (c.free())
continue;
if (c.node != state::closest_node)
continue;
// Actually flip the flag
if (c.flags & CF_LOW_AMMO)
c.flags &= ~CF_LOW_AMMO;
else
c.flags |= CF_LOW_AMMO;
}
});
CatCommand c_toggle_cf_health("wb_conn_health", "Toggle 'health' flag on connection from ACTIVE to CLOSEST node", []() {
auto a = state::active();
auto b = state::closest();
if (not(a and b))
return;
for (connection i = 0; i < MAX_CONNECTIONS; i++)
{
auto &c = a->connections[i];
if (c.free())
continue;
if (c.node != state::closest_node)
continue;
// Actually flip the flag
if (c.flags & CF_LOW_HEALTH)
c.flags &= ~CF_LOW_HEALTH;
else
c.flags |= CF_LOW_HEALTH;
}
});
CatCommand c_toggle_cf_sticky("wb_conn_sticky", "Toggle 'Sticky' flag on connection from ACTIVE to CLOSEST node", []() {
auto a = state::active();
auto b = state::closest();
if (not(a and b))
return;
for (connection i = 0; i < MAX_CONNECTIONS; i++)
{
auto &c = a->connections[i];
if (c.free())
continue;
if (c.node != state::closest_node)
continue;
// Actually flip the flag
if (c.flags & CF_STICKYBOMB)
c.flags &= ~CF_STICKYBOMB;
else
c.flags |= CF_STICKYBOMB;
}
});
CatCommand c_toggle_cf_ammo("wb_conn_ammo", "Toggle 'ammo' flag on connection from ACTIVE to CLOSEST node",
[]()
{
auto a = state::active();
auto b = state::closest();
if (not(a and b))
return;
for (connection i = 0; i < MAX_CONNECTIONS; i++)
{
auto &c = a->connections[i];
if (c.free())
continue;
if (c.node != state::closest_node)
continue;
// Actually flip the flag
if (c.flags & CF_LOW_AMMO)
c.flags &= ~CF_LOW_AMMO;
else
c.flags |= CF_LOW_AMMO;
}
});
CatCommand c_toggle_cf_health("wb_conn_health", "Toggle 'health' flag on connection from ACTIVE to CLOSEST node",
[]()
{
auto a = state::active();
auto b = state::closest();
if (not(a and b))
return;
for (connection i = 0; i < MAX_CONNECTIONS; i++)
{
auto &c = a->connections[i];
if (c.free())
continue;
if (c.node != state::closest_node)
continue;
// Actually flip the flag
if (c.flags & CF_LOW_HEALTH)
c.flags &= ~CF_LOW_HEALTH;
else
c.flags |= CF_LOW_HEALTH;
}
});
CatCommand c_toggle_cf_sticky("wb_conn_sticky", "Toggle 'Sticky' flag on connection from ACTIVE to CLOSEST node",
[]()
{
auto a = state::active();
auto b = state::closest();
if (not(a and b))
return;
for (connection i = 0; i < MAX_CONNECTIONS; i++)
{
auto &c = a->connections[i];
if (c.free())
continue;
if (c.node != state::closest_node)
continue;
// Actually flip the flag
if (c.flags & CF_STICKYBOMB)
c.flags &= ~CF_STICKYBOMB;
else
c.flags |= CF_STICKYBOMB;
}
});
// Displays all info about closest node and its connections
CatCommand c_info("wb_dump", "Show info", []() {
index_t node = state::closest_node;
if (not node_good(node))
return;
CatCommand c_info("wb_dump", "Show info",
[]()
{
index_t node = state::closest_node;
if (not node_good(node))
return;
auto &n = nodes[node];
auto &n = nodes[node];
logging::Info("[wb] Info about node %u", node);
logging::Info("[wb] Flags: Duck=%d, Jump=%d, Raw=%u", n.flags & NF_DUCK, n.flags & NF_JUMP, n.flags);
logging::Info("[wb] X: %.2f | Y: %.2f | Z: %.2f", n.x, n.y, n.z);
logging::Info("[wb] Connections:");
for (size_t i = 0; i < MAX_CONNECTIONS; i++)
{
if (n.connections[i].free())
continue;
logging::Info("[wb] %s", DescribeConnection(node, i).c_str());
}
});
logging::Info("[wb] Info about node %u", node);
logging::Info("[wb] Flags: Duck=%d, Jump=%d, Raw=%u", n.flags & NF_DUCK, n.flags & NF_JUMP, n.flags);
logging::Info("[wb] X: %.2f | Y: %.2f | Z: %.2f", n.x, n.y, n.z);
logging::Info("[wb] Connections:");
for (size_t i = 0; i < MAX_CONNECTIONS; i++)
{
if (n.connections[i].free())
continue;
logging::Info("[wb] %s", DescribeConnection(node, i).c_str());
}
});
// Deletes a whole region of nodes
// Deletes a single closest node if no node is selected
CatCommand c_delete_region("wb_delete_region", "Delete region of nodes", []() {
logging::Info("< DISABLED >");
/*index_t a = state::active_node;
index_t b = state::closest_node;
CatCommand c_delete_region("wb_delete_region", "Delete region of nodes",
[]()
{
logging::Info("< DISABLED >");
/*index_t a = state::active_node;
index_t b = state::closest_node;
if (not (state::node_good(a) and state::node_good(b)))
return;
if (not (state::node_good(a) and state::node_good(b)))
return;
index_t current = state::closest_node;
index_t next = INVALID_NODE;
index_t current = state::closest_node;
index_t next = INVALID_NODE;
do {
auto& n = state::nodes[current];
do {
auto& n = state::nodes[current];
if (n.connection_count > 2) {
logging::Info("[wb] More than 2 connections on a node! Quitting.");
return;
}
bool found_next = false;
for (size_t i = 0; i < 2; i++) {
if (n.connections[i] != current) {
next = n.connections[i];
found_next = true;
}
}
DeleteNode(current);
current = next;
if (not found_next) {
logging::Info("[wb] Dead end? Can't find next node after %u",
current); break;
}
} while (state::node_good(current) and (current != a));*/
});
if (n.connection_count > 2) {
logging::Info("[wb] More than 2 connections on a node! Quitting.");
return;
}
bool found_next = false;
for (size_t i = 0; i < 2; i++) {
if (n.connections[i] != current) {
next = n.connections[i];
found_next = true;
}
}
DeleteNode(current);
current = next;
if (not found_next) {
logging::Info("[wb] Dead end? Can't find next node after %u",
current); break;
}
} while (state::node_good(current) and (current != a));*/
});
// Clears the state
CatCommand c_clear("wb_clear", "Removes all nodes", []() { state::nodes.clear(); });
@ -1218,12 +1252,14 @@ static void cm()
}
}
static InitRoutine init([]() {
EC::Register(EC::CreateMove_NoEnginePred, cm, "cm_walkbot", EC::average);
EC::Register(EC::LevelInit, OnLevelInit, "init_walkbot", EC::average);
static InitRoutine init(
[]()
{
EC::Register(EC::CreateMove_NoEnginePred, cm, "cm_walkbot", EC::average);
EC::Register(EC::LevelInit, OnLevelInit, "init_walkbot", EC::average);
#if ENABLE_VISUALS
EC::Register(EC::Draw, Draw, "draw_walkbot", EC::average);
EC::Register(EC::Draw, Draw, "draw_walkbot", EC::average);
#endif
});
});
} // namespace hacks::shared::walkbot

View File

@ -56,7 +56,7 @@ void Update(CachedEntity *player)
{
auto &angles = angles::data(player);
float deviation = angles.deviation(2);
int widx = CE_INT(player, netvar.hActiveWeapon) & 0xFFF;
int widx = HandleToIDX(CE_INT(player, netvar.hActiveWeapon));
CachedEntity *wep = ENTITY(widx);
if (!CE_GOOD(wep))
return;
@ -76,7 +76,7 @@ void Update(CachedEntity *player)
{
const char *wp_name = "[unknown]";
int widx = CE_INT(player, netvar.hActiveWeapon) & 0xFFF;
int widx = HandleToIDX(CE_INT(player, netvar.hActiveWeapon));
if (IDX_GOOD(widx))
{
CachedEntity *weapon = ENTITY(widx);

View File

@ -1137,11 +1137,6 @@ bool IsBuildingVisible(CachedEntity *ent)
return IsEntityVectorVisible(ent, GetBuildingPosition(ent));
}
int HandleToIDX(int handle)
{
return handle & 0xFFF;
}
void fClampAngle(Vector &qaAng)
{
while (qaAng[0] > 89)
@ -1180,7 +1175,7 @@ CachedEntity *weapon_get(CachedEntity *entity)
if (CE_BAD(entity))
return 0;
handle = CE_INT(entity, netvar.hActiveWeapon);
eid = handle & 0xFFF;
eid = HandleToIDX(handle);
if (IDX_BAD(eid))
return 0;
return ENTITY(eid);
@ -1188,18 +1183,20 @@ CachedEntity *weapon_get(CachedEntity *entity)
weaponmode GetWeaponMode(CachedEntity *ent)
{
int weapon_handle, slot;
int weapon_handle, weapon_idx, slot;
CachedEntity *weapon;
if (CE_BAD(ent) || CE_BAD(weapon_get(ent)))
return weapon_invalid;
weapon_handle = CE_INT(ent, netvar.hActiveWeapon);
if (IDX_BAD((weapon_handle & 0xFFF)))
weapon_idx = HandleToIDX(weapon_handle);
if (IDX_BAD(weapon_idx))
{
// logging::Info("IDX_BAD: %i", weapon_handle & 0xFFF);
// logging::Info("IDX_BAD: %i", weapon_idx);
return weaponmode::weapon_invalid;
}
weapon = (ENTITY(weapon_handle & 0xFFF));
weapon = (ENTITY(weapon_idx));
if (CE_BAD(weapon))
return weaponmode::weapon_invalid;
int classid = weapon->m_iClassID();

View File

@ -296,7 +296,7 @@ bool ShouldRenderChams(IClientEntity *entity)
if (pipes)
{
if (pipes_local && chamsself)
if ((CE_INT(ent, netvar.hThrower) & 0xFFF) == g_pLocalPlayer->entity->m_IDX) // Check if the sticky is the players own
if (HandleToIDX(CE_INT(ent, netvar.hThrower)) == g_pLocalPlayer->entity->m_IDX) // Check if the sticky is the players own
return true;
if (ent->m_bEnemy())
return true;
@ -305,7 +305,7 @@ bool ShouldRenderChams(IClientEntity *entity)
return false;
}
if (stickies_local && chamsself)
if ((CE_INT(ent, netvar.hThrower) & 0xFFF) == g_pLocalPlayer->entity->m_IDX) // Check if the sticky is the players own
if (HandleToIDX(CE_INT(ent, netvar.hThrower)) == g_pLocalPlayer->entity->m_IDX) // Check if the sticky is the players own
return true;
if (ent->m_bEnemy())
return true;
@ -471,13 +471,13 @@ void RenderChamsRecursive(IClientEntity *entity, CMaterialReference &mat, IVMode
IClientEntity *attach;
int passes = 0;
attach = g_IEntityList->GetClientEntity(*(int *) ((uintptr_t) entity + netvar.m_Collision - 24) & 0xFFF);
attach = g_IEntityList->GetClientEntity(HandleToIDX(*(int *) ((uintptr_t) entity + netvar.m_Collision - 24)));
while (attach && passes++ < 32)
{
chams_attachment_drawing = true;
RenderAttachment(entity, attach, mat);
chams_attachment_drawing = false;
attach = g_IEntityList->GetClientEntity(*(int *) ((uintptr_t) attach + netvar.m_Collision - 20) & 0xFFF);
attach = g_IEntityList->GetClientEntity(HandleToIDX(*(int *) ((uintptr_t) attach + netvar.m_Collision - 20)));
}
#endif
}

View File

@ -15,7 +15,7 @@ bool HasSandvichOut(CachedEntity *entity)
int weapon_idx;
CachedEntity *weapon;
weapon_idx = CE_INT(entity, netvar.hActiveWeapon) & 0xFFF;
weapon_idx = HandleToIDX(CE_INT(entity, netvar.hActiveWeapon));
if (!(weapon_idx > 0 && weapon_idx <= HIGHEST_ENTITY))
return false;
weapon = ENTITY(weapon_idx);

View File

@ -8,24 +8,27 @@
#include "common.hpp"
#include "AntiAim.hpp"
CatCommand printfov("fov_print", "Dump achievements to file (development)", []() {
if (CE_GOOD(LOCAL_E))
logging::Info("%d", CE_INT(LOCAL_E, netvar.iFOV));
});
CatCommand printfov("fov_print", "Dump achievements to file (development)",
[]()
{
if (CE_GOOD(LOCAL_E))
logging::Info("%d", CE_INT(LOCAL_E, netvar.iFOV));
});
weaponmode GetWeaponModeloc()
{
int weapon_handle, slot;
int weapon_handle, weapon_idx, slot;
CachedEntity *weapon;
if (CE_BAD(LOCAL_E) | CE_BAD(LOCAL_W))
return weapon_invalid;
weapon_handle = CE_INT(LOCAL_E, netvar.hActiveWeapon);
if (IDX_BAD((weapon_handle & 0xFFF)))
weapon_idx = HandleToIDX(weapon_handle);
if (IDX_BAD(weapon_idx))
{
// logging::Info("IDX_BAD: %i", weapon_handle & 0xFFF);
// logging::Info("IDX_BAD: %i", weapon_idx);
return weaponmode::weapon_invalid;
}
weapon = (ENTITY(weapon_handle & 0xFFF));
weapon = (ENTITY(weapon_idx));
if (CE_BAD(weapon))
return weaponmode::weapon_invalid;
int classid = weapon->m_iClassID();
@ -153,7 +156,7 @@ void LocalPlayer::Update()
{
// Assign the for loops tick number to an ent
CachedEntity *ent = ENTITY(i);
if (!CE_BAD(ent) && (CE_INT(ent, netvar.hObserverTarget) & 0xFFF) == LOCAL_E->m_IDX)
if (!CE_BAD(ent) && (HandleToIDX(CE_INT(ent, netvar.hObserverTarget))) == LOCAL_E->m_IDX)
{
auto mode = CE_INT(ent, netvar.iObserverMode);
if (mode == 4)
@ -190,7 +193,7 @@ CachedEntity *LocalPlayer::weapon()
if (CE_BAD(entity))
return 0;
handle = CE_INT(entity, netvar.hActiveWeapon);
eid = handle & 0xFFF;
eid = HandleToIDX(handle);
if (IDX_BAD(eid))
return 0;
return ENTITY(eid);

View File

@ -17,8 +17,8 @@ void Update()
for (auto &ent : entity_cache::valid_ents)
{
const model_t *model = RAW_ENT(ent)->GetModel();
bool issandwich = false;
const model_t *model = RAW_ENT(ent)->GetModel();
bool issandwich = false;
const uint16_t curr_idx = ent->m_IDX;
if (model && tickcount % 33 == 0)
{
@ -34,7 +34,7 @@ void Update()
}
if (ent->m_Type() == ENTITY_PROJECTILE || issandwich)
{
/*int owner = CE_INT(ent, 0x894) & 0xFFF;
/*int owner = HandleToIDX(CE_INT(ent, 0x894));
if (owner != LOCAL_W->m_IDX)
continue;*/
if (tickcount % 20 == 0)
@ -42,8 +42,8 @@ void Update()
Vector abs_orig = RAW_ENT(ent)->GetAbsOrigin();
float movement = prevloc[curr_idx].DistTo(abs_orig);
logging::Info("movement: %f", movement);
prevloc[curr_idx] = abs_orig;
const Vector &v = ent->m_vecVelocity;
prevloc[curr_idx] = abs_orig;
const Vector &v = ent->m_vecVelocity;
Vector eav;
velocity::EstimateAbsVelocity(RAW_ENT(ent), eav);
// logging::Info("%d [%s]: CatVelocity: %.2f %.2f

View File

@ -58,7 +58,7 @@ bool trace::FilterDefault::ShouldHitEntity(IHandleEntity *handle, int mask)
if (CE_GOOD(ent) && ent->m_bAlivePlayer())
{
// Get held weapon
auto weapon_idx = CE_INT(ent, netvar.hActiveWeapon) & 0xFFF;
auto weapon_idx = HandleToIDX(CE_INT(ent, netvar.hActiveWeapon));
// Check if weapon is valid
if (IDX_GOOD(weapon_idx))
{

View File

@ -417,7 +417,7 @@ void EffectGlow::DrawEntity(IClientEntity *entity)
passes = 0;
entity->DrawModel(1);
attach = g_IEntityList->GetClientEntity(*(int *) ((uintptr_t) entity + netvar.m_Collision - 24) & 0xFFF);
attach = g_IEntityList->GetClientEntity(HandleToIDX(*(int *) ((uintptr_t) entity + netvar.m_Collision - 24)));
while (attach && passes++ < 32)
{
if (attach->ShouldDraw())
@ -435,7 +435,7 @@ void EffectGlow::DrawEntity(IClientEntity *entity)
attach->DrawModel(1);
}
}
attach = g_IEntityList->GetClientEntity(*(int *) ((uintptr_t) attach + netvar.m_Collision - 20) & 0xFFF);
attach = g_IEntityList->GetClientEntity(HandleToIDX(*(int *) ((uintptr_t) attach + netvar.m_Collision - 20)));
}
#endif
}