Intial CS:Go changes and slight changes for CS:S WeaponID related function.
This commit is contained in:
parent
0e7a3b0173
commit
453e9da7c5
@ -36,6 +36,7 @@
|
||||
#include "iplayerinfo.h"
|
||||
#include "ISDKTools.h"
|
||||
#include "forwards.h"
|
||||
#include "util_cstrike.h"
|
||||
|
||||
/**
|
||||
* @file extension.cpp
|
||||
@ -126,6 +127,10 @@ void CStrike::SDK_OnUnload()
|
||||
forwards->ReleaseForward(g_pPriceForward);
|
||||
forwards->ReleaseForward(g_pTerminateRoundForward);
|
||||
forwards->ReleaseForward(g_pCSWeaponDropForward);
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO
|
||||
ClearHashMaps();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CStrike::SDK_OnAllLoaded()
|
||||
@ -146,6 +151,10 @@ void CStrike::SDK_OnAllLoaded()
|
||||
hooked_everything = true;
|
||||
|
||||
SM_GET_LATE_IFACE(BINTOOLS, g_pBinTools);
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO
|
||||
CreateHashMaps();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CStrike::QueryRunning(char *error, size_t maxlength)
|
||||
|
95
extensions/cstrike/itemdef-hash.h
Normal file
95
extensions/cstrike/itemdef-hash.h
Normal file
@ -0,0 +1,95 @@
|
||||
#ifndef _INCLUDE_CSTRIKE_HASH_H_
|
||||
#define _INCLUDE_CSTRIKE_HASH_H_
|
||||
|
||||
#include <amtl/am-string.h>
|
||||
#include <amtl/am-hashmap.h>
|
||||
#include <amtl/am-hashtable.h>
|
||||
|
||||
#define MAX_WEAPON_NAME_LENGTH 80
|
||||
class CEconItemDefinition;
|
||||
|
||||
struct HashItemDef_Node
|
||||
{
|
||||
int key;
|
||||
CEconItemDefinition *pDef;
|
||||
int iunknown;
|
||||
};
|
||||
|
||||
class CHashItemDef
|
||||
{
|
||||
public:
|
||||
unsigned char padding[36];
|
||||
HashItemDef_Node *pMem;
|
||||
int nAllocatedCount;
|
||||
int nGrowSize;
|
||||
int iunknown;
|
||||
int currentElements;
|
||||
int maxElements;
|
||||
};
|
||||
|
||||
struct ItemDefHashValue
|
||||
{
|
||||
ItemDefHashValue(int iLoadoutSlot, unsigned int iPrice, SMCSWeapon iWeaponID, unsigned int iDefIdx, const char *szClassname)
|
||||
{
|
||||
m_iLoadoutSlot = iLoadoutSlot;
|
||||
m_iPrice = iPrice;
|
||||
m_iDefIdx = iDefIdx;
|
||||
m_iWeaponID = iWeaponID;
|
||||
|
||||
Q_strncpy(m_szClassname, szClassname, sizeof(m_szClassname));
|
||||
|
||||
//Create the item name
|
||||
Q_strncpy(m_szItemName, GetWeaponNameFromClassname(szClassname), sizeof(m_szItemName));
|
||||
}
|
||||
int m_iLoadoutSlot;
|
||||
SMCSWeapon m_iWeaponID;
|
||||
unsigned int m_iPrice;
|
||||
unsigned int m_iDefIdx;
|
||||
char m_szClassname[MAX_WEAPON_NAME_LENGTH];
|
||||
char m_szItemName[MAX_WEAPON_NAME_LENGTH];
|
||||
};
|
||||
|
||||
struct StringPolicy
|
||||
{
|
||||
static inline uint32_t hash(const char *key)
|
||||
{
|
||||
return ke::FastHashCharSequence(key, strlen(key));
|
||||
}
|
||||
static inline bool matches(const char *find, const ke::AString &key)
|
||||
{
|
||||
return key.compare(find) == 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct IntegerPolicy
|
||||
{
|
||||
static inline uint32_t hash(const int key)
|
||||
{
|
||||
return ke::HashInt32(key);
|
||||
}
|
||||
static inline bool matches(const int find, const int &key)
|
||||
{
|
||||
return (key == find);
|
||||
}
|
||||
};
|
||||
|
||||
struct WeaponIDPolicy
|
||||
{
|
||||
static inline uint32_t hash(const SMCSWeapon key)
|
||||
{
|
||||
return ke::HashInt32((int)key);
|
||||
}
|
||||
static inline bool matches(const SMCSWeapon find, const SMCSWeapon &key)
|
||||
{
|
||||
return (key == find);
|
||||
}
|
||||
};
|
||||
|
||||
typedef ke::HashMap<ke::AString, ItemDefHashValue, StringPolicy> ClassnameMap;
|
||||
typedef ke::HashMap<int, ItemDefHashValue, IntegerPolicy> ItemIndexMap;
|
||||
typedef ke::HashMap<SMCSWeapon, ItemDefHashValue, WeaponIDPolicy> WeaponIDMap;
|
||||
|
||||
extern ClassnameMap g_mapClassToDefIdx;
|
||||
extern ItemIndexMap g_mapDefIdxToClass;
|
||||
extern WeaponIDMap g_mapWeaponIDToDefIdx;
|
||||
#endif //_INCLUDE_CSTRIKE_HASH_H_
|
@ -35,13 +35,17 @@
|
||||
#include "util_cstrike.h"
|
||||
#include <server_class.h>
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO
|
||||
#include "itemdef-hash.h"
|
||||
#endif
|
||||
|
||||
int g_iPriceOffset = -1;
|
||||
|
||||
#define REGISTER_NATIVE_ADDR(name, code) \
|
||||
void *addr; \
|
||||
if (!g_pGameConf->GetMemSig(name, &addr) || !addr) \
|
||||
{ \
|
||||
return pContext->ThrowNativeError("Failed to locate function"); \
|
||||
return pContext->ThrowNativeError("Failed to lookup %s signature.", name); \
|
||||
} \
|
||||
code; \
|
||||
g_RegNatives.Register(pWrapper);
|
||||
@ -49,7 +53,7 @@ int g_iPriceOffset = -1;
|
||||
#define GET_MEMSIG(name) \
|
||||
if (!g_pGameConf->GetMemSig(name, &addr) || !addr) \
|
||||
{ \
|
||||
return pContext->ThrowNativeError("Failed to locate function"); \
|
||||
return pContext->ThrowNativeError("Failed to lookup %s signature.", name); \
|
||||
}
|
||||
|
||||
inline CBaseEntity *GetCBaseEntity(int num, bool isplayer)
|
||||
@ -366,6 +370,10 @@ static cell_t CS_TerminateRound(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
static cell_t CS_WeaponIDToAlias(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
#if SOURCE_ENGINE == SE_CSGO
|
||||
if(g_mapClassToDefIdx.elements() == 0)
|
||||
return pContext->ThrowNativeError("Failed to create weapon hashmap");
|
||||
#endif
|
||||
if (!IsValidWeaponID(params[1]))
|
||||
return pContext->ThrowNativeError("Invalid WeaponID passed for this game");
|
||||
|
||||
@ -409,7 +417,7 @@ static cell_t CS_GetWeaponPrice(IPluginContext *pContext, const cell_t *params)
|
||||
if (!IsValidWeaponID(params[2]))
|
||||
return pContext->ThrowNativeError("Invalid WeaponID passed for this game");
|
||||
|
||||
int id = GetRealWeaponID(params[2]);
|
||||
int id = params[2];
|
||||
|
||||
//Hard code return values for weapons that dont call GetWeaponPrice and always use default value.
|
||||
if (id == WEAPON_C4 || id == WEAPON_KNIFE || id == WEAPON_SHIELD)
|
||||
@ -449,55 +457,26 @@ static cell_t CS_GetWeaponPrice(IPluginContext *pContext, const cell_t *params)
|
||||
#else
|
||||
static cell_t CS_GetWeaponPrice(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
if (g_mapClassToDefIdx.elements() == 0)
|
||||
return pContext->ThrowNativeError("Failed to create weapon hashmap");
|
||||
|
||||
CBaseEntity *pEntity;
|
||||
if (!(pEntity = GetCBaseEntity(params[1], true)))
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
|
||||
}
|
||||
|
||||
static const char *pPriceKey = NULL;
|
||||
|
||||
if (!pPriceKey)
|
||||
{
|
||||
pPriceKey = g_pGameConf->GetKeyValue("PriceKey");
|
||||
if (!pPriceKey)
|
||||
{
|
||||
return pContext->ThrowNativeError("Failed to get PriceKey KeyValue.");
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsValidWeaponID(params[2]))
|
||||
return pContext->ThrowNativeError("Invalid WeaponID passed for this game");
|
||||
|
||||
int id = GetRealWeaponID(params[2]);
|
||||
WeaponIDMap::Result res = g_mapWeaponIDToDefIdx.find((SMCSWeapon)params[2]);
|
||||
|
||||
char classname[128];
|
||||
|
||||
if (id < CSGOWeapon_KEVLAR)
|
||||
Q_snprintf(classname, sizeof(classname), "weapon_%s", WeaponIDToAlias(params[2]));
|
||||
else
|
||||
Q_snprintf(classname, sizeof(classname), "item_%s", WeaponIDToAlias(params[2]));
|
||||
|
||||
CEconItemDefinition *pDef = GetItemDefintionByName(classname);
|
||||
|
||||
if (!pDef)
|
||||
{
|
||||
return pContext->ThrowNativeError("Failed to get CEconItemDefinition for %s", classname);
|
||||
}
|
||||
|
||||
KeyValues *pAttributes = pDef->m_pKv->FindKey("attributes", false);
|
||||
|
||||
if (!pAttributes)
|
||||
{
|
||||
return pContext->ThrowNativeError("Failed to get item attributes keyvalue for %s", classname);
|
||||
}
|
||||
|
||||
int price = pAttributes->GetInt(pPriceKey, 0);
|
||||
int price = res->value.m_iPrice;
|
||||
|
||||
if (params[3] || weaponNameOffset == -1)
|
||||
return price;
|
||||
|
||||
return CallPriceForward(params[1], WeaponIDToAlias(params[2]), price);
|
||||
return CallPriceForward(params[1], res->value.m_szClassname, price);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -577,30 +556,15 @@ static cell_t CS_SetClientClanTag(IPluginContext *pContext, const cell_t *params
|
||||
|
||||
static cell_t CS_AliasToWeaponID(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
#if SOURCE_ENGINE == SE_CSGO
|
||||
if (g_mapClassToDefIdx.elements() == 0)
|
||||
return pContext->ThrowNativeError("Failed to create weapon hashmap");
|
||||
#endif
|
||||
char *weapon;
|
||||
|
||||
pContext->LocalToString(params[1], &weapon);
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO
|
||||
if (strstr(weapon, "usp_silencer") != NULL)
|
||||
{
|
||||
return SMCSWeapon_HKP2000;
|
||||
}
|
||||
else if(strstr(weapon, "cz75a") != NULL)
|
||||
{
|
||||
return SMCSWeapon_P250;
|
||||
}
|
||||
else if (strstr(weapon, "m4a1_silencer") != NULL)
|
||||
{
|
||||
return SMCSWeapon_M4A1;
|
||||
}
|
||||
else if (strstr(weapon, "revolver") != NULL)
|
||||
{
|
||||
return SMCSWeapon_DEAGLE;
|
||||
}
|
||||
#endif
|
||||
|
||||
int id = GetFakeWeaponID(AliasToWeaponID(weapon));
|
||||
int id = AliasToWeaponID(weapon);
|
||||
|
||||
if (!IsValidWeaponID(id))
|
||||
return SMCSWeapon_NONE;
|
||||
|
@ -29,11 +29,17 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include "util_cstrike.h"
|
||||
|
||||
#include "extension.h"
|
||||
#include "util_cstrike.h"
|
||||
#include "RegNatives.h"
|
||||
#include <iplayerinfo.h>
|
||||
#if SOURCE_ENGINE == SE_CSGO
|
||||
#include "itemdef-hash.h"
|
||||
|
||||
ClassnameMap g_mapClassToDefIdx;
|
||||
ItemIndexMap g_mapDefIdxToClass;
|
||||
WeaponIDMap g_mapWeaponIDToDefIdx;
|
||||
#endif
|
||||
|
||||
#define REGISTER_ADDR(name, defaultret, code) \
|
||||
void *addr; \
|
||||
@ -240,6 +246,145 @@ CEconItemDefinition *GetItemDefintionByName(const char *classname)
|
||||
|
||||
return pItemDef;
|
||||
}
|
||||
|
||||
void CreateHashMaps()
|
||||
{
|
||||
CEconItemSchema *pSchema = GetItemSchema();
|
||||
|
||||
if (!pSchema)
|
||||
return;
|
||||
|
||||
static const char *pPriceKey = NULL;
|
||||
|
||||
if (!pPriceKey)
|
||||
{
|
||||
pPriceKey = g_pGameConf->GetKeyValue("PriceKey");
|
||||
if (!pPriceKey)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static int iHashMapOffset = -1;
|
||||
|
||||
if (iHashMapOffset == -1)
|
||||
{
|
||||
if (!g_pGameConf->GetOffset("ItemDefHashOffset", &iHashMapOffset) || iHashMapOffset == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
g_mapClassToDefIdx.init();
|
||||
g_mapDefIdxToClass.init();
|
||||
g_mapWeaponIDToDefIdx.init();
|
||||
|
||||
CHashItemDef *map = (CHashItemDef *)((intptr_t)pSchema + iHashMapOffset);
|
||||
|
||||
for (int i = 0; i < map->currentElements; i++)
|
||||
{
|
||||
HashItemDef_Node node = map->pMem[i];
|
||||
|
||||
if (!node.pDef || !node.pDef->m_pKv)
|
||||
continue;
|
||||
|
||||
KeyValues *pClassname = node.pDef->m_pKv->FindKey("name", false);
|
||||
KeyValues *pAttributes = node.pDef->m_pKv->FindKey("attributes", false);
|
||||
|
||||
if (pClassname && pAttributes)
|
||||
{
|
||||
KeyValues *pPrice = pAttributes->FindKey(pPriceKey, false);
|
||||
|
||||
if (pPrice)
|
||||
{
|
||||
const char *classname = pClassname->GetString();
|
||||
|
||||
unsigned int price = pPrice->GetInt();
|
||||
uint16_t iItemDefIdx = node.pDef->m_iDefinitionIndex;
|
||||
SMCSWeapon iWeaponID = GetWeaponIdFromDefIdx(iItemDefIdx);
|
||||
int iLoadoutslot = node.pDef->GetDefaultLoadoutSlot();
|
||||
|
||||
ClassnameMap::Insert i = g_mapClassToDefIdx.findForAdd(classname);
|
||||
g_mapClassToDefIdx.add(i, ke::AString(classname), ItemDefHashValue(iLoadoutslot, price, iWeaponID, iItemDefIdx, classname));
|
||||
|
||||
ItemIndexMap::Insert x = g_mapDefIdxToClass.findForAdd(iItemDefIdx);
|
||||
g_mapDefIdxToClass.add(x, iItemDefIdx, ItemDefHashValue(iLoadoutslot, price, iWeaponID, iItemDefIdx, classname));
|
||||
|
||||
WeaponIDMap::Insert t = g_mapWeaponIDToDefIdx.findForAdd(iWeaponID);
|
||||
g_mapWeaponIDToDefIdx.add(t, iWeaponID, ItemDefHashValue(iLoadoutslot, price, iWeaponID, iItemDefIdx, classname));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ClearHashMaps()
|
||||
{
|
||||
g_mapClassToDefIdx.clear();
|
||||
g_mapDefIdxToClass.clear();
|
||||
g_mapWeaponIDToDefIdx.clear();
|
||||
}
|
||||
|
||||
SMCSWeapon GetWeaponIdFromDefIdx(uint16_t iDefIdx)
|
||||
{
|
||||
//DEAR GOD THIS IS HIDEOUS
|
||||
//None in the middle are weapons that dont exist.
|
||||
//If they are added and use the same idx they should be changed to their respective ones
|
||||
static SMCSWeapon weaponIDMap[SMCSWeapon_MAXWEAPONIDS] =
|
||||
{
|
||||
SMCSWeapon_NONE, SMCSWeapon_DEAGLE, SMCSWeapon_ELITE, SMCSWeapon_FIVESEVEN,
|
||||
SMCSWeapon_GLOCK, SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_AK47,
|
||||
SMCSWeapon_AUG, SMCSWeapon_AWP, SMCSWeapon_FAMAS, SMCSWeapon_G3SG1,
|
||||
SMCSWeapon_NONE, SMCSWeapon_GALILAR, SMCSWeapon_M249, SMCSWeapon_NONE,
|
||||
SMCSWeapon_M4A1, SMCSWeapon_MAC10, SMCSWeapon_NONE, SMCSWeapon_P90,
|
||||
SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_NONE,
|
||||
SMCSWeapon_UMP45, SMCSWeapon_XM1014, SMCSWeapon_BIZON, SMCSWeapon_MAG7,
|
||||
SMCSWeapon_NEGEV, SMCSWeapon_SAWEDOFF, SMCSWeapon_TEC9, SMCSWeapon_TASER,
|
||||
SMCSWeapon_HKP2000, SMCSWeapon_MP7, SMCSWeapon_MP9, SMCSWeapon_NOVA,
|
||||
SMCSWeapon_P250, SMCSWeapon_NONE, SMCSWeapon_SCAR20, SMCSWeapon_SG556,
|
||||
SMCSWeapon_SSG08, SMCSWeapon_KNIFE_GG, SMCSWeapon_KNIFE, SMCSWeapon_FLASHBANG,
|
||||
SMCSWeapon_HEGRENADE, SMCSWeapon_SMOKEGRENADE, SMCSWeapon_MOLOTOV, SMCSWeapon_DECOY,
|
||||
SMCSWeapon_INCGRENADE, SMCSWeapon_C4, SMCSWeapon_KEVLAR, SMCSWeapon_ASSAULTSUIT,
|
||||
SMCSWeapon_HEAVYASSAULTSUIT, SMCSWeapon_NONE, SMCSWeapon_NIGHTVISION, SMCSWeapon_DEFUSER
|
||||
};
|
||||
|
||||
if (iDefIdx >= SMCSWeapon_MAXWEAPONIDS)
|
||||
return (SMCSWeapon)iDefIdx;
|
||||
else
|
||||
return weaponIDMap[iDefIdx];
|
||||
}
|
||||
|
||||
ItemDefHashValue *GetHashValueFromWeapon(const char *szWeapon)
|
||||
{
|
||||
char tempWeapon[MAX_WEAPON_NAME_LENGTH];
|
||||
|
||||
Q_strncpy(tempWeapon, szWeapon, sizeof(tempWeapon));
|
||||
Q_strlower(tempWeapon);
|
||||
|
||||
if (strstr(tempWeapon, "weapon_") == NULL && strstr(tempWeapon, "item_") == NULL)
|
||||
{
|
||||
static const char *szClassPrefixs[] = { "weapon_", "item_" };
|
||||
|
||||
for (unsigned int i = 0; i < SM_ARRAYSIZE(szClassPrefixs); i++)
|
||||
{
|
||||
char classname[MAX_WEAPON_NAME_LENGTH];
|
||||
Q_snprintf(classname, sizeof(classname), "%s%s", szClassPrefixs[i], tempWeapon);
|
||||
|
||||
ClassnameMap::Result res = g_mapClassToDefIdx.find(classname);
|
||||
|
||||
if (res.found())
|
||||
return &res->value;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ClassnameMap::Result res = g_mapClassToDefIdx.find(tempWeapon);
|
||||
|
||||
if (res.found())
|
||||
return &res->value;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SOURCE_ENGINE != SE_CSGO
|
||||
@ -273,6 +418,20 @@ void *GetWeaponInfo(int weaponID)
|
||||
}
|
||||
#endif
|
||||
|
||||
const char *GetWeaponNameFromClassname(const char *weapon)
|
||||
{
|
||||
char *szTemp = strstr((char *)weapon, "_");
|
||||
|
||||
if (!szTemp)
|
||||
{
|
||||
return weapon;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (const char *)((intptr_t)szTemp + 1);
|
||||
}
|
||||
}
|
||||
|
||||
const char *GetTranslatedWeaponAlias(const char *weapon)
|
||||
{
|
||||
#if SOURCE_ENGINE != SE_CSGO
|
||||
@ -297,12 +456,11 @@ const char *GetTranslatedWeaponAlias(const char *weapon)
|
||||
unsigned char vstk[sizeof(const char *)];
|
||||
unsigned char *vptr = vstk;
|
||||
|
||||
*(const char **)vptr = weapon;
|
||||
*(const char **)vptr = GetWeaponNameFromClassname(weapon);
|
||||
|
||||
pWrapper->Execute(vstk, &alias);
|
||||
return alias;
|
||||
#else //this should work for both games maybe replace both?
|
||||
|
||||
static const char *szAliases[] =
|
||||
{
|
||||
"cv47", "ak47",
|
||||
@ -321,13 +479,13 @@ const char *GetTranslatedWeaponAlias(const char *weapon)
|
||||
"nvgs", "nightvision"
|
||||
};
|
||||
|
||||
for (int i = 0; i < SM_ARRAYSIZE(szAliases)/2; i++)
|
||||
for (int i = 0; i < SM_ARRAYSIZE(szAliases) / 2; i++)
|
||||
{
|
||||
if (stricmp(weapon, szAliases[i * 2]) == 0)
|
||||
if (Q_stristr(GetWeaponNameFromClassname(weapon), szAliases[i * 2]) != 0)
|
||||
return szAliases[i * 2 + 1];
|
||||
}
|
||||
|
||||
return weapon;
|
||||
return GetWeaponNameFromClassname(weapon);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -355,17 +513,17 @@ int AliasToWeaponID(const char *weapon)
|
||||
unsigned char vstk[sizeof(const char *)];
|
||||
unsigned char *vptr = vstk;
|
||||
|
||||
*(const char **)vptr = weapon;
|
||||
*(const char **)vptr = GetWeaponNameFromClassname(weapon);
|
||||
|
||||
pWrapper->Execute(vstk, &weaponID);
|
||||
|
||||
return weaponID;
|
||||
#else //this is horribly broken hackfix for now.
|
||||
for (unsigned int i = 0; i < SM_ARRAYSIZE(szWeaponInfo); i++)
|
||||
{
|
||||
if (stricmp(weapon, szWeaponInfo[i]) == 0)
|
||||
return i;
|
||||
}
|
||||
#else
|
||||
ItemDefHashValue *pHashValue = GetHashValueFromWeapon(weapon);
|
||||
|
||||
if (pHashValue)
|
||||
return pHashValue->m_iWeaponID;
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
@ -394,278 +552,28 @@ const char *WeaponIDToAlias(int weaponID)
|
||||
unsigned char vstk[sizeof(int)];
|
||||
unsigned char *vptr = vstk;
|
||||
|
||||
*(int *)vptr = GetRealWeaponID(weaponID);
|
||||
*(int *)vptr = weaponID;
|
||||
|
||||
pWrapper->Execute(vstk, &alias);
|
||||
|
||||
return alias;
|
||||
#else
|
||||
int realID = GetRealWeaponID(weaponID);
|
||||
WeaponIDMap::Result res = g_mapWeaponIDToDefIdx.find((SMCSWeapon)weaponID);
|
||||
|
||||
if (realID < SM_ARRAYSIZE(szWeaponInfo) && realID > 0)
|
||||
return szWeaponInfo[realID];
|
||||
if (res.found())
|
||||
return res->value.m_szItemName;
|
||||
|
||||
return NULL;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
int GetRealWeaponID(int weaponId)
|
||||
{
|
||||
#if SOURCE_ENGINE == SE_CSGO
|
||||
switch((SMCSWeapon)weaponId)
|
||||
{
|
||||
case SMCSWeapon_NONE:
|
||||
return (int)CSGOWeapon_NONE;
|
||||
case SMCSWeapon_DEAGLE:
|
||||
return (int)CSGOWeapon_DEAGLE;
|
||||
case SMCSWeapon_ELITE:
|
||||
return (int)CSGOWeapon_ELITE;
|
||||
case SMCSWeapon_FIVESEVEN:
|
||||
return (int)CSGOWeapon_FIVESEVEN;
|
||||
case SMCSWeapon_GLOCK:
|
||||
return (int)CSGOWeapon_GLOCK;
|
||||
case SMCSWeapon_P228:
|
||||
return (int)CSGOWeapon_P228;
|
||||
case SMCSWeapon_USP:
|
||||
return (int)CSGOWeapon_USP;
|
||||
case SMCSWeapon_AK47:
|
||||
return (int)CSGOWeapon_AK47;
|
||||
case SMCSWeapon_AUG:
|
||||
return (int)CSGOWeapon_AUG;
|
||||
case SMCSWeapon_AWP:
|
||||
return (int)CSGOWeapon_AWP;
|
||||
case SMCSWeapon_FAMAS:
|
||||
return (int)CSGOWeapon_FAMAS;
|
||||
case SMCSWeapon_G3SG1:
|
||||
return (int)CSGOWeapon_G3SG1;
|
||||
case SMCSWeapon_GALIL:
|
||||
return (int)CSGOWeapon_GALIL;
|
||||
case SMCSWeapon_GALILAR:
|
||||
return (int)CSGOWeapon_GALILAR;
|
||||
case SMCSWeapon_M249:
|
||||
return (int)CSGOWeapon_M249;
|
||||
case SMCSWeapon_M3:
|
||||
return (int)CSGOWeapon_M3;
|
||||
case SMCSWeapon_M4A1:
|
||||
return (int)CSGOWeapon_M4A1;
|
||||
case SMCSWeapon_MAC10:
|
||||
return (int)CSGOWeapon_MAC10;
|
||||
case SMCSWeapon_MP5NAVY:
|
||||
return (int)CSGOWeapon_MP5NAVY;
|
||||
case SMCSWeapon_P90:
|
||||
return (int)CSGOWeapon_P90;
|
||||
case SMCSWeapon_SCOUT:
|
||||
return (int)CSGOWeapon_SCOUT;
|
||||
case SMCSWeapon_SG550:
|
||||
return (int)CSGOWeapon_SG550;
|
||||
case SMCSWeapon_SG552:
|
||||
return (int)CSGOWeapon_SG552;
|
||||
case SMCSWeapon_TMP:
|
||||
return (int)CSGOWeapon_TMP;
|
||||
case SMCSWeapon_UMP45:
|
||||
return (int)CSGOWeapon_UMP45;
|
||||
case SMCSWeapon_XM1014:
|
||||
return (int)CSGOWeapon_XM1014;
|
||||
case SMCSWeapon_BIZON:
|
||||
return (int)CSGOWeapon_BIZON;
|
||||
case SMCSWeapon_MAG7:
|
||||
return (int)CSGOWeapon_MAG7;
|
||||
case SMCSWeapon_NEGEV:
|
||||
return (int)CSGOWeapon_NEGEV;
|
||||
case SMCSWeapon_SAWEDOFF:
|
||||
return (int)CSGOWeapon_SAWEDOFF;
|
||||
case SMCSWeapon_TEC9:
|
||||
return (int)CSGOWeapon_TEC9;
|
||||
case SMCSWeapon_TASER:
|
||||
return (int)CSGOWeapon_TASER;
|
||||
case SMCSWeapon_HKP2000:
|
||||
return (int)CSGOWeapon_HKP2000;
|
||||
case SMCSWeapon_MP7:
|
||||
return (int)CSGOWeapon_MP7;
|
||||
case SMCSWeapon_MP9:
|
||||
return (int)CSGOWeapon_MP9;
|
||||
case SMCSWeapon_NOVA:
|
||||
return (int)CSGOWeapon_NOVA;
|
||||
case SMCSWeapon_P250:
|
||||
return (int)CSGOWeapon_P250;
|
||||
case SMCSWeapon_SCAR17:
|
||||
return (int)CSGOWeapon_SCAR17;
|
||||
case SMCSWeapon_SCAR20:
|
||||
return (int)CSGOWeapon_SCAR20;
|
||||
case SMCSWeapon_SG556:
|
||||
return (int)CSGOWeapon_SG556;
|
||||
case SMCSWeapon_SSG08:
|
||||
return (int)CSGOWeapon_SSG08;
|
||||
case SMCSWeapon_KNIFE_GG:
|
||||
return (int)CSGOWeapon_KNIFE_GG;
|
||||
case SMCSWeapon_KNIFE:
|
||||
return (int)CSGOWeapon_KNIFE;
|
||||
case SMCSWeapon_FLASHBANG:
|
||||
return (int)CSGOWeapon_FLASHBANG;
|
||||
case SMCSWeapon_HEGRENADE:
|
||||
return (int)CSGOWeapon_HEGRENADE;
|
||||
case SMCSWeapon_SMOKEGRENADE:
|
||||
return (int)CSGOWeapon_SMOKEGRENADE;
|
||||
case SMCSWeapon_MOLOTOV:
|
||||
return (int)CSGOWeapon_MOLOTOV;
|
||||
case SMCSWeapon_DECOY:
|
||||
return (int)CSGOWeapon_DECOY;
|
||||
case SMCSWeapon_INCGRENADE:
|
||||
return (int)CSGOWeapon_INCGRENADE;
|
||||
case SMCSWeapon_C4:
|
||||
return (int)CSGOWeapon_C4;
|
||||
case SMCSWeapon_KEVLAR:
|
||||
return (int)CSGOWeapon_KEVLAR;
|
||||
case SMCSWeapon_ASSAULTSUIT:
|
||||
return (int)CSGOWeapon_ASSAULTSUIT;
|
||||
case SMCSWeapon_NIGHTVISION:
|
||||
return (int)CSGOWeapon_NVG;
|
||||
case SMCSWeapon_DEFUSER:
|
||||
return (int)CSGOWeapon_DEFUSER;
|
||||
default:
|
||||
return (int)CSGOWeapon_NONE;
|
||||
}
|
||||
#else
|
||||
if (weaponId > (int)SMCSWeapon_NIGHTVISION || weaponId < (int)SMCSWeapon_NONE)
|
||||
return (int)SMCSWeapon_NONE;
|
||||
else
|
||||
return weaponId;
|
||||
#endif
|
||||
}
|
||||
|
||||
int GetFakeWeaponID(int weaponId)
|
||||
{
|
||||
#if SOURCE_ENGINE == SE_CSGO
|
||||
switch((CSGOWeapon)weaponId)
|
||||
{
|
||||
case CSGOWeapon_NONE:
|
||||
return (int)SMCSWeapon_NONE;
|
||||
case CSGOWeapon_DEAGLE:
|
||||
return (int)SMCSWeapon_DEAGLE;
|
||||
case CSGOWeapon_ELITE:
|
||||
return (int)SMCSWeapon_ELITE;
|
||||
case CSGOWeapon_FIVESEVEN:
|
||||
return (int)SMCSWeapon_FIVESEVEN;
|
||||
case CSGOWeapon_GLOCK:
|
||||
return (int)SMCSWeapon_GLOCK;
|
||||
case CSGOWeapon_P228:
|
||||
return (int)SMCSWeapon_P228;
|
||||
case CSGOWeapon_USP:
|
||||
return (int)SMCSWeapon_USP;
|
||||
case CSGOWeapon_AK47:
|
||||
return (int)SMCSWeapon_AK47;
|
||||
case CSGOWeapon_AUG:
|
||||
return (int)SMCSWeapon_AUG;
|
||||
case CSGOWeapon_AWP:
|
||||
return (int)SMCSWeapon_AWP;
|
||||
case CSGOWeapon_FAMAS:
|
||||
return (int)SMCSWeapon_FAMAS;
|
||||
case CSGOWeapon_G3SG1:
|
||||
return (int)SMCSWeapon_G3SG1;
|
||||
case CSGOWeapon_GALIL:
|
||||
return (int)SMCSWeapon_GALIL;
|
||||
case CSGOWeapon_GALILAR:
|
||||
return (int)SMCSWeapon_GALILAR;
|
||||
case CSGOWeapon_M249:
|
||||
return (int)SMCSWeapon_M249;
|
||||
case CSGOWeapon_M3:
|
||||
return (int)SMCSWeapon_M3;
|
||||
case CSGOWeapon_M4A1:
|
||||
return (int)SMCSWeapon_M4A1;
|
||||
case CSGOWeapon_MAC10:
|
||||
return (int)SMCSWeapon_MAC10;
|
||||
case CSGOWeapon_MP5NAVY:
|
||||
return (int)SMCSWeapon_MP5NAVY;
|
||||
case CSGOWeapon_P90:
|
||||
return (int)SMCSWeapon_P90;
|
||||
case CSGOWeapon_SCOUT:
|
||||
return (int)SMCSWeapon_SCOUT;
|
||||
case CSGOWeapon_SG550:
|
||||
return (int)SMCSWeapon_SG550;
|
||||
case CSGOWeapon_SG552:
|
||||
return (int)SMCSWeapon_SG552;
|
||||
case CSGOWeapon_TMP:
|
||||
return (int)SMCSWeapon_TMP;
|
||||
case CSGOWeapon_UMP45:
|
||||
return (int)SMCSWeapon_UMP45;
|
||||
case CSGOWeapon_XM1014:
|
||||
return (int)SMCSWeapon_XM1014;
|
||||
case CSGOWeapon_BIZON:
|
||||
return (int)SMCSWeapon_BIZON;
|
||||
case CSGOWeapon_MAG7:
|
||||
return (int)SMCSWeapon_MAG7;
|
||||
case CSGOWeapon_NEGEV:
|
||||
return (int)SMCSWeapon_NEGEV;
|
||||
case CSGOWeapon_SAWEDOFF:
|
||||
return (int)SMCSWeapon_SAWEDOFF;
|
||||
case CSGOWeapon_TEC9:
|
||||
return (int)SMCSWeapon_TEC9;
|
||||
case CSGOWeapon_TASER:
|
||||
return (int)SMCSWeapon_TASER;
|
||||
case CSGOWeapon_HKP2000:
|
||||
return (int)SMCSWeapon_HKP2000;
|
||||
case CSGOWeapon_MP7:
|
||||
return (int)SMCSWeapon_MP7;
|
||||
case CSGOWeapon_MP9:
|
||||
return (int)SMCSWeapon_MP9;
|
||||
case CSGOWeapon_NOVA:
|
||||
return (int)SMCSWeapon_NOVA;
|
||||
case CSGOWeapon_P250:
|
||||
return (int)SMCSWeapon_P250;
|
||||
case CSGOWeapon_SCAR17:
|
||||
return (int)SMCSWeapon_SCAR17;
|
||||
case CSGOWeapon_SCAR20:
|
||||
return (int)SMCSWeapon_SCAR20;
|
||||
case CSGOWeapon_SG556:
|
||||
return (int)SMCSWeapon_SG556;
|
||||
case CSGOWeapon_SSG08:
|
||||
return (int)SMCSWeapon_SSG08;
|
||||
case CSGOWeapon_KNIFE_GG:
|
||||
return (int)SMCSWeapon_KNIFE_GG;
|
||||
case CSGOWeapon_KNIFE:
|
||||
return (int)SMCSWeapon_KNIFE;
|
||||
case CSGOWeapon_FLASHBANG:
|
||||
return (int)SMCSWeapon_FLASHBANG;
|
||||
case CSGOWeapon_HEGRENADE:
|
||||
return (int)SMCSWeapon_HEGRENADE;
|
||||
case CSGOWeapon_SMOKEGRENADE:
|
||||
return (int)SMCSWeapon_SMOKEGRENADE;
|
||||
case CSGOWeapon_MOLOTOV:
|
||||
return (int)SMCSWeapon_MOLOTOV;
|
||||
case CSGOWeapon_DECOY:
|
||||
return (int)SMCSWeapon_DECOY;
|
||||
case CSGOWeapon_INCGRENADE:
|
||||
return (int)SMCSWeapon_INCGRENADE;
|
||||
case CSGOWeapon_C4:
|
||||
return (int)SMCSWeapon_C4;
|
||||
case CSGOWeapon_KEVLAR:
|
||||
return (int)SMCSWeapon_KEVLAR;
|
||||
case CSGOWeapon_ASSAULTSUIT:
|
||||
return (int)SMCSWeapon_ASSAULTSUIT;
|
||||
case CSGOWeapon_NVG:
|
||||
return (int)SMCSWeapon_NIGHTVISION;
|
||||
case CSGOWeapon_DEFUSER:
|
||||
return (int)SMCSWeapon_DEFUSER;
|
||||
default:
|
||||
return (int)SMCSWeapon_NONE;
|
||||
}
|
||||
#else
|
||||
if (weaponId > (int)SMCSWeapon_NIGHTVISION || weaponId < (int)SMCSWeapon_NONE)
|
||||
return (int)SMCSWeapon_NONE;
|
||||
else
|
||||
return weaponId;
|
||||
#endif
|
||||
}
|
||||
bool IsValidWeaponID(int id)
|
||||
{
|
||||
if (id <= (int)SMCSWeapon_NONE)
|
||||
return false;
|
||||
//Why are these even HERE!?! They dont exist in CS:GO but have valid ID's still
|
||||
#if SOURCE_ENGINE == SE_CSGO
|
||||
else if (id > (int)SMCSWeapon_DEFUSER || id == (int)SMCSWeapon_P228 || id == (int)SMCSWeapon_SCOUT || id == (int)SMCSWeapon_SG550 || id == (int)SMCSWeapon_GALIL ||
|
||||
id == (int)SMCSWeapon_SCAR17 || id == (int)SMCSWeapon_USP || id == (int)SMCSWeapon_M3 || id == (int)SMCSWeapon_MP5NAVY || id == (int)SMCSWeapon_TMP || id == (int)SMCSWeapon_SG552)
|
||||
WeaponIDMap::Result res = g_mapWeaponIDToDefIdx.find((SMCSWeapon)id);
|
||||
if (!res.found())
|
||||
return false;
|
||||
#else
|
||||
else if (id > (int)SMCSWeapon_NIGHTVISION)
|
||||
|
@ -31,158 +31,9 @@
|
||||
|
||||
#ifndef _INCLUDE_CSTRIKE_UTIL_H_
|
||||
#define _INCLUDE_CSTRIKE_UTIL_H_
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO
|
||||
#include "extension.h"
|
||||
|
||||
class CEconItemView;
|
||||
class CCSWeaponData;
|
||||
class CEconItemSchema;
|
||||
|
||||
class CEconItemDefinition
|
||||
{
|
||||
public:
|
||||
void **m_pVtable;
|
||||
KeyValues *m_pKv;
|
||||
uint16_t m_iDefinitionIndex;
|
||||
int GetDefaultLoadoutSlot()
|
||||
{
|
||||
static int iLoadoutSlotOffset = -1;
|
||||
|
||||
if (iLoadoutSlotOffset == -1)
|
||||
{
|
||||
if (!g_pGameConf->GetOffset("LoadoutSlotOffset", &iLoadoutSlotOffset) || iLoadoutSlotOffset == -1)
|
||||
{
|
||||
iLoadoutSlotOffset = -1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return *(int *)((intptr_t)this + iLoadoutSlotOffset);
|
||||
}
|
||||
};
|
||||
|
||||
CEconItemView *GetEconItemView(CBaseEntity *pEntity, int iSlot);
|
||||
CCSWeaponData *GetCCSWeaponData(CEconItemView *view);
|
||||
CEconItemSchema *GetItemSchema();
|
||||
CEconItemDefinition *GetItemDefintionByName(const char *classname);
|
||||
|
||||
static const char *szWeaponInfo[] =
|
||||
{
|
||||
"none",
|
||||
"deagle",
|
||||
"elite",
|
||||
"fiveseven",
|
||||
"glock",
|
||||
"p228",
|
||||
"usp",
|
||||
"ak47",
|
||||
"aug",
|
||||
"awp",
|
||||
"famas",
|
||||
"g3sg1",
|
||||
"galil",
|
||||
"galilar",
|
||||
"m249",
|
||||
"m3",
|
||||
"m4a1",
|
||||
"mac10",
|
||||
"mp5",
|
||||
"p90",
|
||||
"scout",
|
||||
"sg550",
|
||||
"sg552",
|
||||
"tmp",
|
||||
"ump45",
|
||||
"xm1014",
|
||||
"bizon",
|
||||
"mag7",
|
||||
"negev",
|
||||
"sawedoff",
|
||||
"tec9",
|
||||
"taser",
|
||||
"hkp2000",
|
||||
"mp7",
|
||||
"mp9",
|
||||
"nova",
|
||||
"p250",
|
||||
"scar17",
|
||||
"scar20",
|
||||
"sg556",
|
||||
"ssg08",
|
||||
"knifegg",
|
||||
"knife",
|
||||
"flashbang",
|
||||
"hegrenade",
|
||||
"smokegrenade",
|
||||
"molotov",
|
||||
"decoy",
|
||||
"incgrenade",
|
||||
"c4",
|
||||
"kevlar",
|
||||
"assaultsuit",
|
||||
"nvg",
|
||||
"defuser"
|
||||
};
|
||||
|
||||
enum CSGOWeapon
|
||||
{
|
||||
CSGOWeapon_NONE,
|
||||
CSGOWeapon_DEAGLE,
|
||||
CSGOWeapon_ELITE,
|
||||
CSGOWeapon_FIVESEVEN,
|
||||
CSGOWeapon_GLOCK,
|
||||
CSGOWeapon_P228,
|
||||
CSGOWeapon_USP,
|
||||
CSGOWeapon_AK47,
|
||||
CSGOWeapon_AUG,
|
||||
CSGOWeapon_AWP,
|
||||
CSGOWeapon_FAMAS,
|
||||
CSGOWeapon_G3SG1,
|
||||
CSGOWeapon_GALIL,
|
||||
CSGOWeapon_GALILAR,
|
||||
CSGOWeapon_M249,
|
||||
CSGOWeapon_M3,
|
||||
CSGOWeapon_M4A1,
|
||||
CSGOWeapon_MAC10,
|
||||
CSGOWeapon_MP5NAVY,
|
||||
CSGOWeapon_P90,
|
||||
CSGOWeapon_SCOUT,
|
||||
CSGOWeapon_SG550,
|
||||
CSGOWeapon_SG552,
|
||||
CSGOWeapon_TMP,
|
||||
CSGOWeapon_UMP45,
|
||||
CSGOWeapon_XM1014,
|
||||
CSGOWeapon_BIZON,
|
||||
CSGOWeapon_MAG7,
|
||||
CSGOWeapon_NEGEV,
|
||||
CSGOWeapon_SAWEDOFF,
|
||||
CSGOWeapon_TEC9,
|
||||
CSGOWeapon_TASER,
|
||||
CSGOWeapon_HKP2000,
|
||||
CSGOWeapon_MP7,
|
||||
CSGOWeapon_MP9,
|
||||
CSGOWeapon_NOVA,
|
||||
CSGOWeapon_P250,
|
||||
CSGOWeapon_SCAR17,
|
||||
CSGOWeapon_SCAR20,
|
||||
CSGOWeapon_SG556,
|
||||
CSGOWeapon_SSG08,
|
||||
CSGOWeapon_KNIFE_GG,
|
||||
CSGOWeapon_KNIFE,
|
||||
CSGOWeapon_FLASHBANG,
|
||||
CSGOWeapon_HEGRENADE,
|
||||
CSGOWeapon_SMOKEGRENADE,
|
||||
CSGOWeapon_MOLOTOV,
|
||||
CSGOWeapon_DECOY,
|
||||
CSGOWeapon_INCGRENADE,
|
||||
CSGOWeapon_C4, //49
|
||||
CSGOWeapon_KEVLAR = 50,
|
||||
CSGOWeapon_ASSAULTSUIT,
|
||||
CSGOWeapon_NVG,
|
||||
CSGOWeapon_DEFUSER
|
||||
};
|
||||
#endif
|
||||
//THIS IS THE INCLUDE ENUM DO NOT CHANGE ONLY UPDATE THE INCLUDE
|
||||
//This is used to match to old weaponid's to their correct enum value
|
||||
//Anything after defuser will pass the itemdef as they will be the id set in include
|
||||
enum SMCSWeapon
|
||||
{
|
||||
SMCSWeapon_NONE = 0,
|
||||
@ -239,22 +90,117 @@ enum SMCSWeapon
|
||||
SMCSWeapon_MOLOTOV,
|
||||
SMCSWeapon_DECOY,
|
||||
SMCSWeapon_INCGRENADE,
|
||||
SMCSWeapon_DEFUSER
|
||||
SMCSWeapon_DEFUSER,
|
||||
SMCSWeapon_HEAVYASSAULTSUIT,
|
||||
SMCSWeapon_MAXWEAPONIDS, //This only exists here... the include has more. This is for easy array construction
|
||||
};
|
||||
|
||||
#if SOURCE_ENGINE != SE_CSGO
|
||||
#if SOURCE_ENGINE == SE_CSGO
|
||||
//These are the ItemDefintion indexs they are used as a reference to create GetWeaponIdFromDefIdx
|
||||
/*
|
||||
enum CSGOItemDefs
|
||||
{
|
||||
CSGOItemDef_NONE = 0,
|
||||
CSGOItemDef_DEAGLE,
|
||||
CSGOItemDef_ELITE,
|
||||
CSGOItemDef_FIVESEVEN,
|
||||
CSGOItemDef_GLOCK,
|
||||
CSGOItemDef_P228,
|
||||
CSGOItemDef_USP,
|
||||
CSGOItemDef_AK47,
|
||||
CSGOItemDef_AUG,
|
||||
CSGOItemDef_AWP,
|
||||
CSGOItemDef_FAMAS,
|
||||
CSGOItemDef_G3SG1,
|
||||
CSGOItemDef_GALIL,
|
||||
CSGOItemDef_GALILAR,
|
||||
CSGOItemDef_M249,
|
||||
CSGOItemDef_M3,
|
||||
CSGOItemDef_M4A1,
|
||||
CSGOItemDef_MAC10,
|
||||
CSGOItemDef_MP5NAVY,
|
||||
CSGOItemDef_P90,
|
||||
CSGOItemDef_SCOUT,
|
||||
CSGOItemDef_SG550,
|
||||
CSGOItemDef_SG552,
|
||||
CSGOItemDef_TMP,
|
||||
CSGOItemDef_UMP45,
|
||||
CSGOItemDef_XM1014,
|
||||
CSGOItemDef_BIZON,
|
||||
CSGOItemDef_MAG7,
|
||||
CSGOItemDef_NEGEV,
|
||||
CSGOItemDef_SAWEDOFF,
|
||||
CSGOItemDef_TEC9,
|
||||
CSGOItemDef_TASER,
|
||||
CSGOItemDef_HKP2000,
|
||||
CSGOItemDef_MP7,
|
||||
CSGOItemDef_MP9,
|
||||
CSGOItemDef_NOVA,
|
||||
CSGOItemDef_P250,
|
||||
CSGOItemDef_SCAR17,
|
||||
CSGOItemDef_SCAR20,
|
||||
CSGOItemDef_SG556,
|
||||
CSGOItemDef_SSG08,
|
||||
CSGOItemDef_KNIFE_GG,
|
||||
CSGOItemDef_KNIFE,
|
||||
CSGOItemDef_FLASHBANG,
|
||||
CSGOItemDef_HEGRENADE,
|
||||
CSGOItemDef_SMOKEGRENADE,
|
||||
CSGOItemDef_MOLOTOV,
|
||||
CSGOItemDef_DECOY,
|
||||
CSGOItemDef_INCGRENADE,
|
||||
CSGOItemDef_C4,
|
||||
CSGOItemDef_KEVLAR,
|
||||
CSGOItemDef_ASSAULTSUIT,
|
||||
CSGOItemDef_HEAVYASSAULTSUIT,
|
||||
CSGOItemDef_UNUSED,
|
||||
CSGOItemDef_NVG,
|
||||
CSGOItemDef_DEFUSER,
|
||||
CSGOItemDef_MAXDEFS,
|
||||
};
|
||||
*/
|
||||
struct ItemDefHashValue;
|
||||
class CEconItemView;
|
||||
class CCSWeaponData;
|
||||
class CEconItemSchema;
|
||||
class CEconItemDefinition
|
||||
{
|
||||
public:
|
||||
void **m_pVtable;
|
||||
KeyValues *m_pKv;
|
||||
uint16_t m_iDefinitionIndex;
|
||||
int GetDefaultLoadoutSlot()
|
||||
{
|
||||
static int iLoadoutSlotOffset = -1;
|
||||
|
||||
if (iLoadoutSlotOffset == -1)
|
||||
{
|
||||
if (!g_pGameConf->GetOffset("LoadoutSlotOffset", &iLoadoutSlotOffset) || iLoadoutSlotOffset == -1)
|
||||
{
|
||||
iLoadoutSlotOffset = -1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return *(int *)((intptr_t)this + iLoadoutSlotOffset);
|
||||
}
|
||||
};
|
||||
|
||||
CEconItemView *GetEconItemView(CBaseEntity *pEntity, int iSlot);
|
||||
CCSWeaponData *GetCCSWeaponData(CEconItemView *view);
|
||||
CEconItemSchema *GetItemSchema();
|
||||
CEconItemDefinition *GetItemDefintionByName(const char *classname);
|
||||
void CreateHashMaps();
|
||||
void ClearHashMaps();
|
||||
SMCSWeapon GetWeaponIdFromDefIdx(uint16_t iDefIdx);
|
||||
ItemDefHashValue *GetHashValueFromWeapon(const char *szWeapon);
|
||||
#else //CS:S ONLY STUFF
|
||||
void *GetWeaponInfo(int weaponID);
|
||||
#endif
|
||||
|
||||
const char *GetWeaponNameFromClassname(const char *weapon);
|
||||
const char *GetTranslatedWeaponAlias(const char *weapon);
|
||||
|
||||
int AliasToWeaponID(const char *weapon);
|
||||
|
||||
const char *WeaponIDToAlias(int weaponID);
|
||||
|
||||
int GetRealWeaponID(int weaponId);
|
||||
|
||||
int GetFakeWeaponID(int weaponId);
|
||||
|
||||
bool IsValidWeaponID(int weaponId);
|
||||
#endif
|
||||
|
@ -82,6 +82,14 @@
|
||||
"linux" "588"
|
||||
"mac" "588"
|
||||
}
|
||||
// Offset into CEconItemSchema * to a hashmap of all itemdefs
|
||||
// Offset can be found in... GetItemDefinitionMutable (easy to get offset on windows should be the same)
|
||||
"ItemDefHashOffset"
|
||||
{
|
||||
"windows" "172"
|
||||
"linux" "172"
|
||||
"mac" "172"
|
||||
}
|
||||
}
|
||||
"Signatures"
|
||||
{
|
||||
|
@ -109,7 +109,7 @@ enum CSWeaponID
|
||||
CSWeapon_SHIELD,
|
||||
CSWeapon_KEVLAR,
|
||||
CSWeapon_ASSAULTSUIT,
|
||||
CSWeapon_NIGHTVISION,
|
||||
CSWeapon_NIGHTVISION, //Anything below is CS:GO ONLY
|
||||
CSWeapon_GALILAR,
|
||||
CSWeapon_BIZON,
|
||||
CSWeapon_MAG7,
|
||||
@ -130,7 +130,27 @@ enum CSWeaponID
|
||||
CSWeapon_MOLOTOV,
|
||||
CSWeapon_DECOY,
|
||||
CSWeapon_INCGRENADE,
|
||||
CSWeapon_DEFUSER
|
||||
CSWeapon_DEFUSER,
|
||||
CSWeapon_HEAVYASSAULTSUIT,
|
||||
//The rest are actual item definition indexes for CS:GO
|
||||
CSWeapon_CUTTERS = 56,
|
||||
CSWeapon_HEALTHSHOT = 57,
|
||||
CSWeapon_KNIFE_T = 59,
|
||||
CSWeapon_M4A1_SILENCER = 60.
|
||||
CSWeapon_USP_SILENCER = 61,
|
||||
CSWeapon_CZ75A = 63,
|
||||
CSWeapon_REVOLVER = 64,
|
||||
CSWeapon_TAGGRENADE = 68.
|
||||
CSWeapon_BAYONET = 500,
|
||||
CSWeapon_KNIFE_FLIP = 505,
|
||||
CSWeapon_KNIFE_GUT = 506,
|
||||
CSWeapon_KNIFE_KARAMBIT = 507,
|
||||
CSWeapon_KNIFE_M9_BAYONET = 508,
|
||||
CSWeapon_KNIFE_TATICAL = 509,
|
||||
CSWeapon_KNIFE_FALCHION = 512,
|
||||
CSWeapon_KNIFE_SURVIVAL_BOWIE = 514,
|
||||
CSWeapon_KNIFE_BUTTERFLY = 515,
|
||||
CSWeapon_KNIFE_PUSH = 516,
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user