Advertisement
Guest User

Untitled

a guest
Feb 13th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.08 KB | None | 0 0
  1. #include "SDK.h"
  2. #include "Global.h"
  3. #include "Configs.h"
  4. #include "SkinChanger.h"
  5.  
  6. #define SEQUENCE_DEFAULT_DRAW 0
  7. #define SEQUENCE_DEFAULT_IDLE1 1
  8. #define SEQUENCE_DEFAULT_IDLE2 2
  9. #define SEQUENCE_DEFAULT_LIGHT_MISS1 3
  10. #define SEQUENCE_DEFAULT_LIGHT_MISS2 4
  11. #define SEQUENCE_DEFAULT_HEAVY_MISS1 9
  12. #define SEQUENCE_DEFAULT_HEAVY_HIT1 10
  13. #define SEQUENCE_DEFAULT_HEAVY_BACKSTAB 11
  14. #define SEQUENCE_DEFAULT_LOOKAT01 12
  15.  
  16. #define SEQUENCE_BUTTERFLY_DRAW 0
  17. #define SEQUENCE_BUTTERFLY_DRAW2 1
  18. #define SEQUENCE_BUTTERFLY_LOOKAT01 13
  19. #define SEQUENCE_BUTTERFLY_LOOKAT03 15
  20.  
  21. #define SEQUENCE_FALCHION_IDLE1 1
  22. #define SEQUENCE_FALCHION_HEAVY_MISS1 8
  23. #define SEQUENCE_FALCHION_HEAVY_MISS1_NOFLIP 9
  24. #define SEQUENCE_FALCHION_LOOKAT01 12
  25. #define SEQUENCE_FALCHION_LOOKAT02 13
  26.  
  27. #define SEQUENCE_DAGGERS_IDLE1 1
  28. #define SEQUENCE_DAGGERS_LIGHT_MISS1 2
  29. #define SEQUENCE_DAGGERS_LIGHT_MISS5 6
  30. #define SEQUENCE_DAGGERS_HEAVY_MISS2 11
  31. #define SEQUENCE_DAGGERS_HEAVY_MISS1 12
  32.  
  33. #define SEQUENCE_BOWIE_IDLE1 1
  34.  
  35. // Store the original proxy functions.
  36. RecvVarProxyFn oSequenceProxyFn = NULL;
  37.  
  38. bool requestFullUpdate = false;
  39.  
  40. class SkinChangerInfo
  41. {
  42. public:
  43. char model[128];
  44. int fallbackPaintKit;
  45. int itemDefinitionIndex;
  46.  
  47. SkinChangerInfo(char *model_, int fallbackPaintKit_, int itemDefinitionIndex_)
  48. {
  49. strcp(model, model_);
  50. fallbackPaintKit = fallbackPaintKit_;
  51. itemDefinitionIndex = itemDefinitionIndex_;
  52. }
  53. };
  54.  
  55. //RecvVarProxyFn oRecvnModelIndex = NULL;
  56.  
  57. void SkinChanger(ClientFrameStage_t Stage)
  58. {
  59. CBaseEntity *pLocal = G::pLocal;
  60.  
  61. static std::vector<SkinChangerInfo> knifeModelReplace;
  62.  
  63. if (knifeModelReplace.size() == 0)
  64. {
  65. knifeModelReplace.push_back(SkinChangerInfo(xorstr("models/weapons/v_knife_karam.mdl"), 38, WEAPON_KNIFE_KARAMBIT));
  66. knifeModelReplace.push_back(SkinChangerInfo(xorstr("models/weapons/v_knife_m9_bay.mdl"), 421, WEAPON_KNIFE_M9_BAYONET));
  67. knifeModelReplace.push_back(SkinChangerInfo(xorstr("models/weapons/v_knife_butterfly.mdl"), 12, WEAPON_KNIFE_BUTTERFLY));
  68. }
  69.  
  70. if (Stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START)
  71. {
  72. if (!requestFullUpdate && cfg.SkinChanger.knife != 0)
  73. {
  74. UINT* hWeapons = pLocal->GetWeapons();
  75.  
  76. if (hWeapons)
  77. {
  78. int nLocalPlayerID = I::pEngineClient->GetLocalPlayer();
  79.  
  80. player_info_t LocalPlayerInfo;
  81. I::pEngineClient->GetPlayerInfo(nLocalPlayerID, &LocalPlayerInfo);
  82.  
  83. static int default_t = I::pModelInfo->GetModelIndex(xorstr("models/weapons/v_knife_default_t.mdl"));
  84. static int default_ct = I::pModelInfo->GetModelIndex(xorstr("models/weapons/v_knife_default_ct.mdl"));
  85.  
  86. int replace = I::pModelInfo->GetModelIndex(knifeModelReplace[cfg.SkinChanger.knife - 1].model);
  87.  
  88. // Loop through weapons and run our skin function on them.
  89. for (int nIndex = 0; hWeapons[nIndex]; nIndex++)
  90. {
  91. CBaseAttributableItem* pWeapon = (CBaseAttributableItem*)I::pClientEntityList->GetClientEntityFromHandle(hWeapons[nIndex]);
  92.  
  93. if (!pWeapon)
  94. continue;
  95.  
  96. // Compare original owner XUIDs.
  97. if (LocalPlayerInfo.m_nXuidLow != *pWeapon->GetOriginalOwnerXuidLow())
  98. continue;
  99.  
  100. if (LocalPlayerInfo.m_nXuidHigh != *pWeapon->GetOriginalOwnerXuidHigh())
  101. continue;
  102.  
  103. if (pWeapon->GetClientClass()->m_ClassID == 93) // knives
  104. {
  105. *pWeapon->GetFallbackPaintKit() = knifeModelReplace[cfg.SkinChanger.knife - 1].fallbackPaintKit;
  106. *pWeapon->GetItemDefinitionIndex() = knifeModelReplace[cfg.SkinChanger.knife - 1].itemDefinitionIndex;
  107.  
  108. *pWeapon->GetItemIDHigh() = -1;
  109. *pWeapon->GetFallbackWear() = 0.0001f;
  110. *pWeapon->GetEntityQuality() = 3;
  111. /**pWeapon->GetViewModelIndex() = replace;
  112. *pWeapon->GetWorldModelIndex() = replace + 1;*/
  113.  
  114. pWeapon->SetModelIndex(replace);
  115.  
  116. // Fix up the account ID so StatTrak will display correctly.
  117. *pWeapon->GetAccountID() = LocalPlayerInfo.m_nXuidLow;
  118.  
  119. CBaseViewModel *pViewModel = (CBaseViewModel*)I::pClientEntityList->GetClientEntityFromHandle(pLocal->GetViewModel());
  120. CBaseAttributableItem *pViewModelWeapon = (CBaseAttributableItem*)I::pClientEntityList->GetClientEntityFromHandle(pViewModel->GetWeapon());
  121. CBaseAttributableItem *pWorldModel = (CBaseAttributableItem*)I::pClientEntityList->GetClientEntityFromHandle(pWeapon->GetWorldModel());
  122.  
  123. if (pWorldModel)
  124. {
  125. pWorldModel->SetModelIndex(replace + 1);
  126. }
  127.  
  128. if (pLocal->GetViewModel() != -1)
  129. {
  130. if (pViewModelWeapon == pWeapon)
  131. {
  132. pViewModel->SetModelIndex(replace);
  133. }
  134. }
  135. }
  136. else
  137. {
  138. if (*pWeapon->GetItemDefinitionIndex() == WEAPON_SCAR20)
  139. {
  140. *pWeapon->GetFallbackPaintKit() = 597;
  141. }
  142. else if (*pWeapon->GetItemDefinitionIndex() == WEAPON_G3SG1)
  143. {
  144. *pWeapon->GetFallbackPaintKit() = 465;
  145. }
  146. else if (*pWeapon->GetItemDefinitionIndex() == WEAPON_AK47)
  147. {
  148. *pWeapon->GetFallbackPaintKit() = 639;
  149. }
  150. else if (*pWeapon->GetItemDefinitionIndex() == WEAPON_AWP)
  151. {
  152. *pWeapon->GetFallbackPaintKit() = 344;
  153. }
  154. /*else if (*pWeapon->GetItemDefinitionIndex() == WEAPON_DEAGLE)
  155. {
  156. *pWeapon->GetFallbackPaintKit() = 232;
  157. }*/
  158. else if (*pWeapon->GetItemDefinitionIndex() == WEAPON_REVOLVER)
  159. {
  160. *pWeapon->GetFallbackPaintKit() = 595;
  161. }
  162.  
  163. *pWeapon->GetItemIDHigh() = -1;
  164. *pWeapon->GetFallbackWear() = 0.0001f;
  165. *pWeapon->GetEntityQuality() = 3;
  166. *pWeapon->GetAccountID() = LocalPlayerInfo.m_nXuidLow;
  167. }
  168. }
  169. }
  170. }
  171.  
  172. if (requestFullUpdate)
  173. {
  174. static ConCommand * cl_fullupdate = NULL;
  175.  
  176. if (!cl_fullupdate)
  177. cl_fullupdate = I::pCVar->FindCommand(xorstr("cl_fullupdate"));
  178.  
  179. if (cl_fullupdate)
  180. {
  181. //cl_fullupdate->m_nFlags &= ~FCVAR_CHEAT;
  182. //I::pEngineClient->ClientCmd_Unrestricted(xorstr("cl_fullupdate"));
  183. //cl_fullupdate->m_nFlags |= FCVAR_CHEAT;
  184. cl_fullupdate->m_fnCommandCallbackV1();
  185. }
  186.  
  187. requestFullUpdate = false;
  188. }
  189. }
  190. }
  191.  
  192. /*
  193. void RecvProxy_ModelIndex(CRecvProxyData *pData, void *pStruct, void *pOut)
  194. {
  195. if (G::exit)
  196. {
  197. oRecvnModelIndex(pData, pStruct, pOut);
  198. return;
  199. }
  200.  
  201. static int default_t = I::pModelInfo->GetModelIndex("models/weapons/v_knife_default_t.mdl");
  202. static int default_ct = I::pModelInfo->GetModelIndex("models/weapons/v_knife_default_ct.mdl");
  203.  
  204. static int iKarambit = I::pModelInfo->GetModelIndex("models/weapons/v_knife_karam.mdl");
  205.  
  206. CBaseEntity *pLocal = G::pLocal;
  207.  
  208. if (pLocal)
  209. {
  210. if (pLocal->GetLifeState() == LIFE_ALIVE && (pData->m_Value.m_Int == default_t || pData->m_Value.m_Int == default_ct))
  211. {
  212. pData->m_Value.m_Int = iKarambit;
  213. }
  214. }
  215.  
  216. oRecvnModelIndex(pData, pStruct, pOut);
  217. }
  218. */
  219.  
  220. // Function to fix sequences for certain models.
  221. void RecvProxy_SetViewModelSequence(const CRecvProxyData *pDataConst, void *pStruct, void *pOut)
  222. {
  223. // Make the incoming data editable.
  224. CRecvProxyData* pData = const_cast<CRecvProxyData*>(pDataConst);
  225.  
  226. // Confirm that we are replacing our view model and not someone elses.
  227. CBaseViewModel* pViewModel = (CBaseViewModel*)pStruct;
  228.  
  229. if (pViewModel) {
  230. CBaseEntity* pOwner = I::pClientEntityList->GetClientEntityFromHandle(pViewModel->GetOwner());
  231.  
  232. // Compare the owner entity of this view model to the local player entity.
  233. if (pOwner && pOwner == G::pLocal) {
  234. // Get the filename of the current view model.
  235. const model_t* pModel = I::pModelInfo->GetModel(pViewModel->GetModelIndex());
  236. const char* szModel = I::pModelInfo->GetModelName(pModel);
  237.  
  238. // Store the current sequence.
  239. int m_nSequence = pData->m_Value.m_Int;
  240.  
  241. if (!strcmp(szModel, xorstr("models/weapons/v_knife_butterfly.mdl"))) {
  242. // Fix animations for the Butterfly Knife.
  243. switch (m_nSequence) {
  244. case SEQUENCE_DEFAULT_DRAW:
  245. m_nSequence = Math::Random(SEQUENCE_BUTTERFLY_DRAW, SEQUENCE_BUTTERFLY_DRAW2); break;
  246. case SEQUENCE_DEFAULT_LOOKAT01:
  247. m_nSequence = Math::Random(SEQUENCE_BUTTERFLY_LOOKAT01, SEQUENCE_BUTTERFLY_LOOKAT03); break;
  248. default:
  249. m_nSequence++;
  250. }
  251. }
  252. else if (!strcmp(szModel, xorstr("models/weapons/v_knife_falchion_advanced.mdl"))) {
  253. // Fix animations for the Falchion Knife.
  254. switch (m_nSequence) {
  255. case SEQUENCE_DEFAULT_IDLE2:
  256. m_nSequence = SEQUENCE_FALCHION_IDLE1; break;
  257. case SEQUENCE_DEFAULT_HEAVY_MISS1:
  258. m_nSequence = Math::Random(SEQUENCE_FALCHION_HEAVY_MISS1, SEQUENCE_FALCHION_HEAVY_MISS1_NOFLIP); break;
  259. case SEQUENCE_DEFAULT_LOOKAT01:
  260. m_nSequence = Math::Random(SEQUENCE_FALCHION_LOOKAT01, SEQUENCE_FALCHION_LOOKAT02); break;
  261. case SEQUENCE_DEFAULT_DRAW:
  262. case SEQUENCE_DEFAULT_IDLE1:
  263. break;
  264. default:
  265. m_nSequence--;
  266. }
  267. }
  268. else if (!strcmp(szModel, xorstr("models/weapons/v_knife_push.mdl"))) {
  269. // Fix animations for the Shadow Daggers.
  270. switch (m_nSequence) {
  271. case SEQUENCE_DEFAULT_IDLE2:
  272. m_nSequence = SEQUENCE_DAGGERS_IDLE1; break;
  273. case SEQUENCE_DEFAULT_LIGHT_MISS1:
  274. case SEQUENCE_DEFAULT_LIGHT_MISS2:
  275. m_nSequence = Math::Random(SEQUENCE_DAGGERS_LIGHT_MISS1, SEQUENCE_DAGGERS_LIGHT_MISS5); break;
  276. case SEQUENCE_DEFAULT_HEAVY_MISS1:
  277. m_nSequence = Math::Random(SEQUENCE_DAGGERS_HEAVY_MISS2, SEQUENCE_DAGGERS_HEAVY_MISS1); break;
  278. case SEQUENCE_DEFAULT_HEAVY_HIT1:
  279. case SEQUENCE_DEFAULT_HEAVY_BACKSTAB:
  280. case SEQUENCE_DEFAULT_LOOKAT01:
  281. m_nSequence += 3; break;
  282. case SEQUENCE_DEFAULT_DRAW:
  283. case SEQUENCE_DEFAULT_IDLE1:
  284. break;
  285. default:
  286. m_nSequence += 2;
  287. }
  288. }
  289. else if (!strcmp(szModel, xorstr("models/weapons/v_knife_survival_bowie.mdl"))) {
  290. // Fix animations for the Bowie Knife.
  291. switch (m_nSequence) {
  292. case SEQUENCE_DEFAULT_DRAW:
  293. case SEQUENCE_DEFAULT_IDLE1:
  294. break;
  295. case SEQUENCE_DEFAULT_IDLE2:
  296. m_nSequence = SEQUENCE_BOWIE_IDLE1; break;
  297. default:
  298. m_nSequence--;
  299. }
  300. }
  301.  
  302. // Set the fixed sequence.
  303. pData->m_Value.m_Int = m_nSequence;
  304. }
  305. }
  306.  
  307. // Call original function with the modified data.
  308. oSequenceProxyFn(pData, pStruct, pOut);
  309. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement