Simplification existing code associated with buy weapons and more

This commit is contained in:
s1lentq 2016-05-04 03:53:03 +06:00
parent bba210b6a1
commit 13e12cc0ae
18 changed files with 321 additions and 905 deletions

File diff suppressed because it is too large Load Diff

View File

@ -115,7 +115,7 @@ int CMD_ARGC_();
const char *CMD_ARGV_(int i);
void set_suicide_frame(entvars_t *pev);
void TeamChangeUpdate(CBasePlayer *player, int team_id);
void BlinkAccount(CBasePlayer *player, int numBlinks);
void BlinkAccount(CBasePlayer *player, int numBlinks = 2);
BOOL ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *szRejectReason);
void ClientDisconnect(edict_t *pEntity);
void respawn(entvars_t *pev, BOOL fCopyCorpse = FALSE);
@ -191,4 +191,19 @@ void CreateInstancedBaselines();
int InconsistentFile(const edict_t *player, const char *filename, char *disconnect_message);
int AllowLagCompensation();
inline const char *GetTeamName(int team)
{
switch (team)
{
case CT:
return "CT";
case TERRORIST:
return "TERRORIST";
case SPECTATOR:
return "SPECTATOR";
default:
return "UNASSIGNED";
}
}
#endif // CLIENT_H

View File

@ -3264,21 +3264,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl)
{
MESSAGE_BEGIN(MSG_ONE, gmsgTeamInfo, NULL, pl->edict());
WRITE_BYTE(plr->entindex());
switch (plr->m_iTeam)
{
case CT:
WRITE_STRING("CT");
break;
case TERRORIST:
WRITE_STRING("TERRORIST");
break;
case SPECTATOR:
WRITE_STRING("SPECTATOR");
break;
default:
WRITE_STRING("UNASSIGNED");
break;
}
WRITE_STRING(GetTeamName(plr->m_iTeam));
MESSAGE_END();
plr->SetScoreboardAttributes(pl);

View File

@ -3335,21 +3335,7 @@ void CBasePlayer::JoiningThink()
MESSAGE_BEGIN(MSG_ALL, gmsgTeamInfo);
WRITE_BYTE(entindex());
switch (m_iTeam)
{
case CT:
WRITE_STRING("CT");
break;
case TERRORIST:
WRITE_STRING("TERRORIST");
break;
case SPECTATOR:
WRITE_STRING("SPECTATOR");
break;
default:
WRITE_STRING("UNASSIGNED");
break;
}
WRITE_STRING(GetTeamName(m_iTeam));
MESSAGE_END();
MESSAGE_BEGIN(MSG_ALL, gmsgLocation);
@ -5340,21 +5326,7 @@ void CBasePlayer::__API_VHOOK(Spawn)()
MESSAGE_BEGIN(MSG_ALL, gmsgTeamInfo);
WRITE_BYTE(entindex());
switch (m_iTeam)
{
case CT:
WRITE_STRING("CT");
break;
case TERRORIST:
WRITE_STRING("TERRORIST");
break;
case SPECTATOR:
WRITE_STRING("SPECTATOR");
break;
default:
WRITE_STRING("UNASSIGNED");
break;
}
WRITE_STRING(GetTeamName(m_iTeam));
MESSAGE_END();
UpdateLocation(true);
@ -7482,21 +7454,7 @@ void CBasePlayer::SwitchTeam()
MESSAGE_BEGIN(MSG_ALL, gmsgTeamInfo);
WRITE_BYTE(entindex());
switch (m_iTeam)
{
case CT:
WRITE_STRING("CT");
break;
case TERRORIST:
WRITE_STRING("TERRORIST");
break;
case SPECTATOR:
WRITE_STRING("SPECTATOR");
break;
default:
WRITE_STRING("UNASSIGNED");
break;
}
WRITE_STRING(GetTeamName(m_iTeam));
MESSAGE_END();
if (TheBots != NULL)

View File

@ -421,7 +421,7 @@ CBaseEntity *EXT_FUNC UTIL_FindEntityByString(CBaseEntity *pStartEntity, const c
startEntityIndex = ENTINDEX(pentEntity);
//it best each entity list
// it best each entity list
if (*szKeyword == 'c')
{
int hash;

View File

@ -202,7 +202,7 @@ inline BOOL FNullEnt(EOFFSET eoffset) { return (eoffset == 0); }
inline BOOL FNullEnt(entvars_t *pev) { return (pev == NULL || FNullEnt(OFFSET(pev))); }
inline BOOL FNullEnt(const edict_t *pent) { return (pent == NULL || FNullEnt(OFFSET(pent))); }
inline BOOL FStringNull(int iString) { return (iString == iStringNull); }
inline BOOL FStrEq(const char *sz1, const char *sz2) { return (strcmp(sz1, sz2) == 0); }
inline BOOL FStrEq(const char *sz1, const char *sz2) { return (Q_strcmp(sz1, sz2) == 0); }
inline BOOL FClassnameIs(entvars_t *pev, const char *szClassname) { return FStrEq(STRING(pev->classname), szClassname); }
inline BOOL FClassnameIs(edict_t *pent, const char *szClassname) { return FStrEq(STRING(VARS(pent)->classname), szClassname); }
inline void UTIL_MakeVectorsPrivate(Vector vecAngles, float *p_vForward, float *p_vRight, float *p_vUp) { g_engfuncs.pfnAngleVectors(vecAngles, p_vForward, p_vRight, p_vUp); }

View File

@ -63,27 +63,32 @@ MULTIDAMAGE gMultiDamage;
// MaxAmmoCarry - pass in a name and this function will tell
// you the maximum amount of that type of ammunition that a
// player can carry.
int MaxAmmoCarry(int iszName)
int MaxAmmoCarry(const char *szName)
{
for (int i = 0; i < MAX_WEAPONS; ++i)
{
ItemInfo *info = &IMPL_CLASS(CBasePlayerItem, ItemInfoArray)[ i ];
if (info->pszAmmo1 && !Q_strcmp(STRING(iszName), info->pszAmmo1))
if (info->pszAmmo1 && !Q_strcmp(szName, info->pszAmmo1))
{
return info->iMaxAmmo1;
}
if (info->pszAmmo2 && !Q_strcmp(STRING(iszName), info->pszAmmo2))
if (info->pszAmmo2 && !Q_strcmp(szName, info->pszAmmo2))
{
return info->iMaxAmmo2;
}
}
ALERT(at_console, "MaxAmmoCarry() doesn't recognize '%s'!\n", STRING(iszName));
ALERT(at_console, "MaxAmmoCarry() doesn't recognize '%s'!\n", szName);
return -1;
}
int MaxAmmoCarry(int iszName)
{
return MaxAmmoCarry(STRING(iszName));
}
// ClearMultiDamage - resets the global multi damage accumulator
void ClearMultiDamage()
{
@ -309,7 +314,9 @@ void W_Precache()
{
Q_memset(IMPL_CLASS(CBasePlayerItem, ItemInfoArray), 0, sizeof(IMPL_CLASS(CBasePlayerItem, ItemInfoArray)));
Q_memset(IMPL_CLASS(CBasePlayerItem, AmmoInfoArray), 0, sizeof(IMPL_CLASS(CBasePlayerItem, AmmoInfoArray)));
giAmmoIndex = 0;
WeaponInfoReset();
// custom items...
@ -2002,6 +2009,29 @@ void CWeaponBox::__MAKE_VHOOK(SetObjectCollisionBox)()
pev->absmax = pev->origin + Vector(16, 16, 16);
}
char *armouryItemModels[] = {
"models/w_mp5.mdl",
"models/w_tmp.mdl",
"models/w_p90.mdl",
"models/w_mac10.mdl",
"models/w_ak47.mdl",
"models/w_sg552.mdl",
"models/w_m4a1.mdl",
"models/w_aug.mdl",
"models/w_scout.mdl",
"models/w_g3sg1.mdl",
"models/w_awp.mdl",
"models/w_m3.mdl",
"models/w_xm1014.mdl",
"models/w_m249.mdl",
"models/w_flashbang.mdl",
"models/w_hegrenade.mdl",
"models/w_kevlar.mdl",
"models/w_assault.mdl",
"models/w_smokegrenade.mdl",
"models/w_kevlar.mdl",
};
void CArmoury::__MAKE_VHOOK(Spawn)()
{
Precache();
@ -2010,31 +2040,9 @@ void CArmoury::__MAKE_VHOOK(Spawn)()
UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16));
UTIL_SetOrigin(pev, pev->origin);
SetTouch(&CArmoury::ArmouryTouch);
switch (m_iItem)
{
case ARMOURY_MP5NAVY: SET_MODEL(ENT(pev), "models/w_mp5.mdl"); break;
case ARMOURY_TMP: SET_MODEL(ENT(pev), "models/w_tmp.mdl"); break;
case ARMOURY_P90: SET_MODEL(ENT(pev), "models/w_p90.mdl"); break;
case ARMOURY_MAC10: SET_MODEL(ENT(pev), "models/w_mac10.mdl"); break;
case ARMOURY_AK47: SET_MODEL(ENT(pev), "models/w_ak47.mdl"); break;
case ARMOURY_SG552: SET_MODEL(ENT(pev), "models/w_sg552.mdl"); break;
case ARMOURY_M4A1: SET_MODEL(ENT(pev), "models/w_m4a1.mdl"); break;
case ARMOURY_AUG: SET_MODEL(ENT(pev), "models/w_aug.mdl"); break;
case ARMOURY_SCOUT: SET_MODEL(ENT(pev), "models/w_scout.mdl"); break;
case ARMOURY_G3SG1: SET_MODEL(ENT(pev), "models/w_g3sg1.mdl"); break;
case ARMOURY_AWP: SET_MODEL(ENT(pev), "models/w_awp.mdl"); break;
case ARMOURY_M3: SET_MODEL(ENT(pev), "models/w_m3.mdl"); break;
case ARMOURY_XM1014: SET_MODEL(ENT(pev), "models/w_xm1014.mdl"); break;
case ARMOURY_M249: SET_MODEL(ENT(pev), "models/w_m249.mdl"); break;
case ARMOURY_FLASHBANG: SET_MODEL(ENT(pev), "models/w_flashbang.mdl"); break;
case ARMOURY_HEGRENADE: SET_MODEL(ENT(pev), "models/w_hegrenade.mdl"); break;
case ARMOURY_KEVLAR: SET_MODEL(ENT(pev), "models/w_kevlar.mdl"); break;
case ARMOURY_ASSAULT: SET_MODEL(ENT(pev), "models/w_assault.mdl"); break;
case ARMOURY_SMOKEGRENADE: SET_MODEL(ENT(pev), "models/w_smokegrenade.mdl"); break;
default: SET_MODEL(ENT(pev), "models/w_kevlar.mdl"); break;
}
SetTouch(&CArmoury::ArmouryTouch);
SET_MODEL(ENT(pev), armouryItemModels[m_iItem]);
if (m_iCount <= 0)
{
@ -2100,31 +2108,32 @@ void CArmoury::__MAKE_VHOOK(Restart)()
void CArmoury::__MAKE_VHOOK(Precache)()
{
switch (m_iItem)
{
case ARMOURY_MP5NAVY: PRECACHE_MODEL("models/w_mp5.mdl"); break;
case ARMOURY_TMP: PRECACHE_MODEL("models/w_tmp.mdl"); break;
case ARMOURY_P90: PRECACHE_MODEL("models/w_p90.mdl"); break;
case ARMOURY_MAC10: PRECACHE_MODEL("models/w_mac10.mdl"); break;
case ARMOURY_AK47: PRECACHE_MODEL("models/w_ak47.mdl"); break;
case ARMOURY_SG552: PRECACHE_MODEL("models/w_sg552.mdl"); break;
case ARMOURY_M4A1: PRECACHE_MODEL("models/w_m4a1.mdl"); break;
case ARMOURY_AUG: PRECACHE_MODEL("models/w_aug.mdl"); break;
case ARMOURY_SCOUT: PRECACHE_MODEL("models/w_scout.mdl"); break;
case ARMOURY_G3SG1: PRECACHE_MODEL("models/w_g3sg1.mdl"); break;
case ARMOURY_AWP: PRECACHE_MODEL("models/w_awp.mdl"); break;
case ARMOURY_M3: PRECACHE_MODEL("models/w_m3.mdl"); break;
case ARMOURY_XM1014: PRECACHE_MODEL("models/w_xm1014.mdl"); break;
case ARMOURY_M249: PRECACHE_MODEL("models/w_m249.mdl"); break;
case ARMOURY_FLASHBANG: PRECACHE_MODEL("models/w_flashbang.mdl"); break;
case ARMOURY_HEGRENADE: PRECACHE_MODEL("models/w_hegrenade.mdl"); break;
case ARMOURY_KEVLAR: PRECACHE_MODEL("models/w_kevlar.mdl"); break;
case ARMOURY_ASSAULT: PRECACHE_MODEL("models/w_assault.mdl"); break;
case ARMOURY_SMOKEGRENADE: PRECACHE_MODEL("models/w_smokegrenade.mdl"); break;
default: PRECACHE_MODEL("models/w_kevlar.mdl"); break;
}
PRECACHE_MODEL(armouryItemModels[m_iItem]);
}
struct ArmouryItemStruct
{
const char *entityName;
char *ammoName;
int giveAmount;
MaxAmmoType maxRounds;
} armouryItemInfo[] = {
{ "weapon_mp5navy", "9mm", 60, MAX_AMMO_9MM }, // ARMOURY_MP5NAVY
{ "weapon_tmp", "9mm", 60, MAX_AMMO_9MM }, // ARMOURY_TMP
{ "weapon_p90", "57mm", 50, MAX_AMMO_57MM }, // ARMOURY_P90
{ "weapon_mac10", "45acp", 60, MAX_AMMO_45ACP }, // ARMOURY_MAC10
{ "weapon_ak47", "762Nato", 60, MAX_AMMO_762NATO }, // ARMOURY_AK47
{ "weapon_sg552", "556Nato", 60, MAX_AMMO_556NATO }, // ARMOURY_SG552
{ "weapon_m4a1", "556Nato", 60, MAX_AMMO_556NATO }, // ARMOURY_M4A1
{ "weapon_aug", "556Nato", 60, MAX_AMMO_556NATO }, // ARMOURY_AUG
{ "weapon_scout", "762Nato", 30, MAX_AMMO_762NATO }, // ARMOURY_SCOUT
{ "weapon_g3sg1", "762Nato", 30, MAX_AMMO_762NATO }, // ARMOURY_G3SG1
{ "weapon_awp", "338Magnum", 20, MAX_AMMO_338MAGNUM }, // ARMOURY_AWP
{ "weapon_m3", "buckshot", 24, MAX_AMMO_BUCKSHOT }, // ARMOURY_M3
{ "weapon_xm1014", "buckshot", 24, MAX_AMMO_BUCKSHOT }, // ARMOURY_XM1014
{ "weapon_m249", "556NatoBox", 60, MAX_AMMO_556NATOBOX }, // ARMOURY_M249
};
void CArmoury::ArmouryTouch(CBaseEntity *pOther)
{
if (!pOther->IsPlayer())
@ -2135,80 +2144,26 @@ void CArmoury::ArmouryTouch(CBaseEntity *pOther)
if (p->m_bIsVIP)
return;
// weapons
if (m_iCount > 0 && m_iItem <= ARMOURY_M249)
{
if (p->m_bHasPrimary)
return;
m_iCount--;
auto item = &armouryItemInfo[m_iItem];
switch (m_iItem)
{
case ARMOURY_MP5NAVY:
p->GiveNamedItem("weapon_mp5navy");
p->GiveAmmo(60, "9mm", MAX_AMMO_9MM);
break;
case ARMOURY_TMP:
p->GiveNamedItem("weapon_tmp");
p->GiveAmmo(60, "9mm", MAX_AMMO_9MM);
break;
case ARMOURY_P90:
p->GiveNamedItem("weapon_p90");
p->GiveAmmo(50, "57mm", MAX_AMMO_57MM);
break;
case ARMOURY_MAC10:
p->GiveNamedItem("weapon_mac10");
p->GiveAmmo(60, "45acp", MAX_AMMO_45ACP);
break;
case ARMOURY_AK47:
p->GiveNamedItem("weapon_ak47");
p->GiveAmmo(60, "762Nato", MAX_AMMO_762NATO);
break;
case ARMOURY_SG552:
p->GiveNamedItem("weapon_sg552");
p->GiveAmmo(60, "556Nato", MAX_AMMO_556NATO);
break;
case ARMOURY_M4A1:
p->GiveNamedItem("weapon_m4a1");
p->GiveAmmo(60, "556Nato", MAX_AMMO_556NATO);
break;
case ARMOURY_AUG:
p->GiveNamedItem("weapon_aug");
p->GiveAmmo(60, "556Nato", MAX_AMMO_556NATO);
break;
case ARMOURY_SCOUT:
p->GiveNamedItem("weapon_scout");
p->GiveAmmo(30, "762Nato", MAX_AMMO_762NATO);
break;
case ARMOURY_G3SG1:
p->GiveNamedItem("weapon_g3sg1");
p->GiveAmmo(30, "762Nato", MAX_AMMO_762NATO);
break;
case ARMOURY_AWP:
p->GiveNamedItem("weapon_awp");
p->GiveAmmo(20, "338Magnum", MAX_AMMO_338MAGNUM);
break;
case ARMOURY_M3:
p->GiveNamedItem("weapon_m3");
p->GiveAmmo(24, "buckshot", MAX_AMMO_BUCKSHOT);
break;
case ARMOURY_XM1014:
p->GiveNamedItem("weapon_xm1014");
p->GiveAmmo(24, "buckshot", MAX_AMMO_BUCKSHOT);
break;
case ARMOURY_M249:
p->GiveNamedItem("weapon_m249");
p->GiveAmmo(60, "556NatoBox", MAX_AMMO_556NATOBOX);
break;
}
p->GiveNamedItem(item->entityName);
p->GiveAmmo(item->giveAmount, item->ammoName, item->maxRounds);
}
// items & grenades
else if (m_iCount > 0 && m_iItem >= ARMOURY_FLASHBANG)
{
switch (m_iItem)
{
case ARMOURY_FLASHBANG:
{
if (p->AmmoInventory(p->GetAmmoIndex("Flashbang")) >= 2)
if (p->AmmoInventory(p->GetAmmoIndex("Flashbang")) >= MaxAmmoCarry("Flashbang"))
return;
p->GiveNamedItem("weapon_flashbang");
@ -2217,7 +2172,7 @@ void CArmoury::ArmouryTouch(CBaseEntity *pOther)
}
case ARMOURY_HEGRENADE:
{
if (p->AmmoInventory(p->GetAmmoIndex("HEGrenade")) >= 1)
if (p->AmmoInventory(p->GetAmmoIndex("HEGrenade")) >= MaxAmmoCarry("HEGrenade"))
return;
p->GiveNamedItem("weapon_hegrenade");
@ -2244,7 +2199,7 @@ void CArmoury::ArmouryTouch(CBaseEntity *pOther)
}
case ARMOURY_SMOKEGRENADE:
{
if (p->AmmoInventory(p->GetAmmoIndex("SmokeGrenade")) >= 1)
if (p->AmmoInventory(p->GetAmmoIndex("SmokeGrenade")) >= MaxAmmoCarry("SmokeGrenade"))
return;
p->GiveNamedItem("weapon_smokegrenade");

View File

@ -95,6 +95,7 @@ enum ArmouryItemPack
ARMOURY_KEVLAR,
ARMOURY_ASSAULT,
ARMOURY_SMOKEGRENADE,
ARMOURY_END
};
struct ItemInfo
@ -1840,6 +1841,8 @@ void FindHullIntersection(const Vector &vecSrc, TraceResult &tr, float *mins, fl
void AnnounceFlashInterval(float interval, float offset = 0);
int MaxAmmoCarry(int iszName);
int MaxAmmoCarry(const char *szName);
void ClearMultiDamage();
void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker);
void AddMultiDamage(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType);

View File

@ -224,35 +224,36 @@ WeaponClassAliasInfo weaponClassAliasInfo[] =
{ NULL, WEAPONCLASS_NONE }
};
WeaponInfoStruct weaponInfo[] =
WeaponInfoStruct weaponInfo[27];
WeaponInfoStruct weaponInfo_default[] =
{
{ WEAPON_P228, P228_PRICE, AMMO_357SIG_PRICE, AMMO_357SIG_BUY, P228_MAX_CLIP, MAX_AMMO_357SIG, AMMO_357SIG, "weapon_p228" },
{ WEAPON_GLOCK, GLOCK18_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, GLOCK18_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_glock18" },
{ WEAPON_GLOCK18, GLOCK18_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, GLOCK18_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_glock18" },
{ WEAPON_SCOUT, SCOUT_PRICE, AMMO_762MM_PRICE, AMMO_762NATO_BUY, SCOUT_MAX_CLIP, MAX_AMMO_762NATO, AMMO_762NATO, "weapon_scout" },
{ WEAPON_XM1014, XM1014_PRICE, AMMO_BUCKSHOT_PRICE, AMMO_BUCKSHOT_BUY, XM1014_MAX_CLIP, MAX_AMMO_BUCKSHOT, AMMO_BUCKSHOT, "weapon_xm1014" },
{ WEAPON_MAC10, MAC10_PRICE, AMMO_45ACP_PRICE, AMMO_45ACP_BUY, MAC10_MAX_CLIP, MAX_AMMO_45ACP, AMMO_45ACP, "weapon_mac10" },
{ WEAPON_AUG, AUG_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, AUG_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_aug" },
{ WEAPON_ELITE, ELITE_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, ELITE_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_elite" },
{ WEAPON_FIVESEVEN, FIVESEVEN_PRICE, AMMO_57MM_PRICE, AMMO_57MM_BUY, FIVESEVEN_MAX_CLIP, MAX_AMMO_57MM, AMMO_57MM, "weapon_fiveseven" },
{ WEAPON_UMP45, UMP45_PRICE, AMMO_45ACP_PRICE, AMMO_45ACP_BUY, UMP45_MAX_CLIP, MAX_AMMO_45ACP, AMMO_45ACP, "weapon_ump45" },
{ WEAPON_SG550, SG550_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, SG550_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_sg550" },
{ WEAPON_GALIL, GALIL_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, GALIL_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_galil" },
{ WEAPON_FAMAS, FAMAS_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, FAMAS_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_famas" },
{ WEAPON_USP, USP_PRICE, AMMO_45ACP_PRICE, AMMO_45ACP_BUY, USP_MAX_CLIP, MAX_AMMO_45ACP, AMMO_45ACP, "weapon_usp" },
{ WEAPON_AWP, AWP_PRICE, AMMO_338MAG_PRICE, AMMO_338MAG_BUY, AWP_MAX_CLIP, MAX_AMMO_338MAGNUM, AMMO_338MAGNUM, "weapon_awp" },
{ WEAPON_MP5N, MP5NAVY_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, MP5N_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_mp5navy" },
{ WEAPON_M249, M249_PRICE, AMMO_556MM_PRICE, AMMO_556NATOBOX_BUY, M249_MAX_CLIP, MAX_AMMO_556NATOBOX, AMMO_556NATOBOX, "weapon_m249" },
{ WEAPON_M3, M3_PRICE, AMMO_BUCKSHOT_PRICE, AMMO_BUCKSHOT_BUY, M3_MAX_CLIP, MAX_AMMO_BUCKSHOT, AMMO_BUCKSHOT, "weapon_m3" },
{ WEAPON_M4A1, M4A1_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, M4A1_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_m4a1" },
{ WEAPON_TMP, TMP_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, TMP_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_tmp" },
{ WEAPON_G3SG1, G3SG1_PRICE, AMMO_762MM_PRICE, AMMO_762NATO_BUY, G3SG1_MAX_CLIP, MAX_AMMO_762NATO, AMMO_762NATO, "weapon_g3sg1" },
{ WEAPON_DEAGLE, DEAGLE_PRICE, AMMO_50AE_PRICE, AMMO_50AE_BUY, DEAGLE_MAX_CLIP, MAX_AMMO_50AE, AMMO_50AE, "weapon_deagle" },
{ WEAPON_SG552, SG552_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, SG552_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_sg552" },
{ WEAPON_AK47, AK47_PRICE, AMMO_762MM_PRICE, AMMO_762NATO_BUY, AK47_MAX_CLIP, MAX_AMMO_762NATO, AMMO_762NATO, "weapon_ak47" },
{ WEAPON_P90, P90_PRICE, AMMO_57MM_PRICE, AMMO_57MM_BUY, P90_MAX_CLIP, MAX_AMMO_57MM, AMMO_57MM, "weapon_p90" },
{ WEAPON_SHIELDGUN, SHIELDGUN_PRICE, 0, 0, 0, 0, -1, NULL },
{ 0, 0, 0, 0, 0, 0, -1, NULL }
{ WEAPON_P228, P228_PRICE, AMMO_357SIG_PRICE, AMMO_357SIG_BUY, P228_MAX_CLIP, MAX_AMMO_357SIG, AMMO_357SIG, "weapon_p228", "ammo_357sig" },
{ WEAPON_GLOCK, GLOCK18_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, GLOCK18_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_glock18", "ammo_9mm" },
{ WEAPON_GLOCK18, GLOCK18_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, GLOCK18_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_glock18", "ammo_9mm" },
{ WEAPON_SCOUT, SCOUT_PRICE, AMMO_762MM_PRICE, AMMO_762NATO_BUY, SCOUT_MAX_CLIP, MAX_AMMO_762NATO, AMMO_762NATO, "weapon_scout", "ammo_762nato" },
{ WEAPON_XM1014, XM1014_PRICE, AMMO_BUCKSHOT_PRICE, AMMO_BUCKSHOT_BUY, XM1014_MAX_CLIP, MAX_AMMO_BUCKSHOT, AMMO_BUCKSHOT, "weapon_xm1014", "ammo_buckshot" },
{ WEAPON_MAC10, MAC10_PRICE, AMMO_45ACP_PRICE, AMMO_45ACP_BUY, MAC10_MAX_CLIP, MAX_AMMO_45ACP, AMMO_45ACP, "weapon_mac10", "ammo_45acp" },
{ WEAPON_AUG, AUG_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, AUG_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_aug", "ammo_556nato" },
{ WEAPON_ELITE, ELITE_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, ELITE_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_elite", "ammo_ammo_9mm" },
{ WEAPON_FIVESEVEN, FIVESEVEN_PRICE, AMMO_57MM_PRICE, AMMO_57MM_BUY, FIVESEVEN_MAX_CLIP, MAX_AMMO_57MM, AMMO_57MM, "weapon_fiveseven", "ammo_57mm" },
{ WEAPON_UMP45, UMP45_PRICE, AMMO_45ACP_PRICE, AMMO_45ACP_BUY, UMP45_MAX_CLIP, MAX_AMMO_45ACP, AMMO_45ACP, "weapon_ump45", "ammo_45acp" },
{ WEAPON_SG550, SG550_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, SG550_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_sg550", "ammo_556nato" },
{ WEAPON_GALIL, GALIL_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, GALIL_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_galil", "ammo_556nato" },
{ WEAPON_FAMAS, FAMAS_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, FAMAS_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_famas", "ammo_556nato" },
{ WEAPON_USP, USP_PRICE, AMMO_45ACP_PRICE, AMMO_45ACP_BUY, USP_MAX_CLIP, MAX_AMMO_45ACP, AMMO_45ACP, "weapon_usp", "ammo_45acp" },
{ WEAPON_AWP, AWP_PRICE, AMMO_338MAG_PRICE, AMMO_338MAG_BUY, AWP_MAX_CLIP, MAX_AMMO_338MAGNUM, AMMO_338MAGNUM, "weapon_awp", "ammo_338magnum" },
{ WEAPON_MP5N, MP5NAVY_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, MP5N_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_mp5navy", "ammo_9mm" },
{ WEAPON_M249, M249_PRICE, AMMO_556MM_PRICE, AMMO_556NATOBOX_BUY, M249_MAX_CLIP, MAX_AMMO_556NATOBOX, AMMO_556NATOBOX, "weapon_m249", "ammo_556natobox" },
{ WEAPON_M3, M3_PRICE, AMMO_BUCKSHOT_PRICE, AMMO_BUCKSHOT_BUY, M3_MAX_CLIP, MAX_AMMO_BUCKSHOT, AMMO_BUCKSHOT, "weapon_m3", "ammo_buckshot" },
{ WEAPON_M4A1, M4A1_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, M4A1_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_m4a1", "ammo_556nato" },
{ WEAPON_TMP, TMP_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, TMP_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_tmp", "ammo_9mm" },
{ WEAPON_G3SG1, G3SG1_PRICE, AMMO_762MM_PRICE, AMMO_762NATO_BUY, G3SG1_MAX_CLIP, MAX_AMMO_762NATO, AMMO_762NATO, "weapon_g3sg1", "ammo_762nato" },
{ WEAPON_DEAGLE, DEAGLE_PRICE, AMMO_50AE_PRICE, AMMO_50AE_BUY, DEAGLE_MAX_CLIP, MAX_AMMO_50AE, AMMO_50AE, "weapon_deagle", "ammo_50ae" },
{ WEAPON_SG552, SG552_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, SG552_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_sg552", "ammo_556nato" },
{ WEAPON_AK47, AK47_PRICE, AMMO_762MM_PRICE, AMMO_762NATO_BUY, AK47_MAX_CLIP, MAX_AMMO_762NATO, AMMO_762NATO, "weapon_ak47", "ammo_762nato" },
{ WEAPON_P90, P90_PRICE, AMMO_57MM_PRICE, AMMO_57MM_BUY, P90_MAX_CLIP, MAX_AMMO_57MM, AMMO_57MM, "weapon_p90", "ammo_57mm" },
{ WEAPON_SHIELDGUN, SHIELDGUN_PRICE, 0, 0, 0, 0, AMMO_NONE, nullptr, nullptr },
{ 0, 0, 0, 0, 0, 0, AMMO_NONE, nullptr, nullptr }
};
#endif // HOOK_GAMEDLL
@ -383,6 +384,13 @@ WeaponInfoStruct *EXT_FUNC GetWeaponInfo(int weaponID)
return NULL;
}
void WeaponInfoReset()
{
#ifndef HOOK_GAMEDLL
Q_memcpy(weaponInfo, weaponInfo_default, sizeof(weaponInfo));
#endif
}
bool CanBuyWeaponByMaptype(int playerTeam, WeaponIdType weaponID, bool useAssasinationRestrictions)
{
if (useAssasinationRestrictions)

View File

@ -256,6 +256,7 @@ enum MaxAmmoType
enum AmmoType
{
AMMO_NONE = -1,
AMMO_BUCKSHOT,
AMMO_9MM,
AMMO_556NATO,
@ -402,12 +403,17 @@ struct WeaponInfoStruct
int buyClipSize;
int gunClipSize;
int maxRounds;
int ammoType;
AmmoType ammoType;
char *entityName;
#ifndef HOOK_GAMEDLL
const char *ammoName;
#endif
};
extern AutoBuyInfoStruct g_autoBuyInfo[35];
extern WeaponStruct g_weaponStruct[MAX_WEAPONS];
extern WeaponInfoStruct weaponInfo[27];
// WeaponType
WeaponIdType AliasToWeaponID(const char *alias);
@ -419,5 +425,6 @@ bool IsPrimaryWeapon(int id);
bool IsSecondaryWeapon(int id);
WeaponInfoStruct *GetWeaponInfo(int weaponID);
bool CanBuyWeaponByMaptype(int playerTeam, WeaponIdType weaponID, bool useAssasinationRestrictions);
void WeaponInfoReset();
#endif // WEAPONTYPE_H

View File

@ -246,7 +246,6 @@ struct ReGameFuncs_t {
void (*EndRoundMessage)(const char *sentence, int event);
class CBaseEntity *(*UTIL_FindEntityByString)(class CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue);
struct WeaponInfoStruct *(*GetWeaponInfo)(int weaponID);
};
class IReGameApi {

View File

@ -90,6 +90,7 @@ enum ArmouryItemPack
ARMOURY_KEVLAR,
ARMOURY_ASSAULT,
ARMOURY_SMOKEGRENADE,
ARMOURY_END
};
struct ItemInfo

View File

@ -251,6 +251,7 @@ enum MaxAmmoType
enum AmmoType
{
AMMO_NONE = -1,
AMMO_BUCKSHOT,
AMMO_9MM,
AMMO_556NATO,
@ -399,4 +400,5 @@ struct WeaponInfoStruct
int maxRounds;
int ammoType;
char *entityName;
const char *ammoName;
};

View File

@ -246,7 +246,6 @@ struct ReGameFuncs_t {
void (*EndRoundMessage)(const char *sentence, int event);
class CBaseEntity *(*UTIL_FindEntityByString)(class CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue);
struct WeaponInfoStruct *(*GetWeaponInfo)(int weaponID);
};
class IReGameApi {

View File

@ -2077,4 +2077,5 @@ public:
virtual ~IReGameData() {}
virtual class CGameRules* GetGameRules() = 0;
virtual struct WeaponInfoStruct *GetWeaponInfo(int weaponID) = 0;
};

View File

@ -47,7 +47,6 @@ ReGameFuncs_t g_ReGameApiFuncs = {
&EndRoundMessage,
&UTIL_FindEntityByString,
&GetWeaponInfo,
};

View File

@ -138,3 +138,7 @@ ICSEntity *EXT_FUNC INDEX_TO_CSENTITY(int iEntityIndex)
CGameRules* EXT_FUNC CReGameData::GetGameRules() {
return g_pGameRules;
}
WeaponInfoStruct* EXT_FUNC CReGameData::GetWeaponInfo(int weaponID) {
return ::GetWeaponInfo(weaponID);
}

View File

@ -2523,6 +2523,7 @@ public:
class CReGameData: public IReGameData {
public:
virtual CGameRules* GetGameRules();
virtual WeaponInfoStruct *GetWeaponInfo(int weaponID);
};
template <class T>