better skinchanger

This commit is contained in:
nullifiedcat 2017-05-05 23:59:45 +03:00
parent 348719ae46
commit 54b0f00610
2 changed files with 17 additions and 9 deletions

View File

@ -142,16 +142,24 @@ void FrameStageNotify(int stage) {
}
if (stage != FRAME_NET_UPDATE_POSTDATAUPDATE_START) return;
int handle = CE_INT(g_pLocalPlayer->entity, netvar.hActiveWeapon);
int eid = handle & 0xFFF;
IClientEntity* entity = g_IEntityList->GetClientEntity(eid);
if (!entity || entity->IsDormant()) return;
int* weapon_list = (int*)((unsigned)(RAW_ENT(LOCAL_E)) + netvar.hMyWeapons);
int my_weapon = CE_INT(g_pLocalPlayer->entity, netvar.hActiveWeapon);
IClientEntity* my_weapon_ptr = g_IEntityList->GetClientEntity(my_weapon & 0xFFF);
static IClientEntity* last_weapon_out = nullptr;
if ((last_weapon_out != entity) || !cookie.Check()) {
GetModifier(NET_INT(entity, netvar.iItemDefinitionIndex)).Apply(eid);
cookie.Update(eid);
for (int i = 0; i < 5; i++) {
int handle = weapon_list[i];
int eid = handle & 0xFFF;
if (eid < 32 || eid > HIGHEST_ENTITY) continue;
//logging::Info("eid, %i", eid);
IClientEntity* entity = g_IEntityList->GetClientEntity(eid);
if (!entity) continue;
if ((my_weapon_ptr != last_weapon_out) || !cookie.Check()) {
GetModifier(NET_INT(entity, netvar.iItemDefinitionIndex)).Apply(eid);
}
}
last_weapon_out = entity;
if ((my_weapon_ptr != last_weapon_out) || !cookie.Check())
cookie.Update(my_weapon & 0xFFF);
last_weapon_out = my_weapon_ptr;
}
static CatVar show_debug_info(CV_SWITCH, "skinchanger_debug", "1", "Debug Skinchanger");

View File

@ -17,6 +17,7 @@ void NetVars::Init() {
this->iTeamNum = gNetvars.get_offset("DT_BaseEntity", "m_iTeamNum");
this->vViewOffset = gNetvars.get_offset("DT_BasePlayer", "localdata", "m_vecViewOffset[0]");
this->hActiveWeapon = gNetvars.get_offset("DT_BaseCombatCharacter", "m_hActiveWeapon");
this->hMyWeapons = gNetvars.get_offset("DT_BaseCombatCharacter", "m_hMyWeapons");
this->iHitboxSet = gNetvars.get_offset("DT_BaseAnimating", "m_nHitboxSet");
this->vVelocity = gNetvars.get_offset("DT_BasePlayer", "localdata", "m_vecVelocity[0]");
this->movetype = gNetvars.get_offset("DT_BaseEntity", "movetype");
@ -77,7 +78,6 @@ void NetVars::Init() {
this->vecPunchAngle = gNetvars.get_offset("DT_BasePlayer", "localdata", "m_Local", "m_vecPunchAngle");
this->vecPunchAngleVel = gNetvars.get_offset("DT_BasePlayer", "localdata", "m_Local", "m_vecPunchAngleVel");
this->hThrower = gNetvars.get_offset("DT_BaseGrenade", "m_hThrower");
this->hMyWeapons = gNetvars.get_offset("DT_BaseCombatCharacter", "m_hMyWeapons");
this->iObserverMode = gNetvars.get_offset("DT_BasePlayer", "m_iObserverMode");
this->hObserverTarget = gNetvars.get_offset("DT_BasePlayer", "m_hObserverTarget");
this->deadflag = gNetvars.get_offset("DT_BasePlayer", "pl", "deadflag");