Refactoring ammo stuff

This commit is contained in:
s1lentq 2017-10-15 21:48:22 +04:00 committed by Dmitry Novikov
parent 8f913b1623
commit af9ef1aa4d
9 changed files with 165 additions and 260 deletions

View File

@ -1,5 +1,92 @@
#include "precompiled.h"
void CBasePlayerAmmo::Spawn()
{
pev->movetype = MOVETYPE_TOSS;
pev->solid = SOLID_TRIGGER;
UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16));
UTIL_SetOrigin(pev, pev->origin);
SetTouch(&CBasePlayerAmmo::DefaultTouch);
if (g_pGameRules->IsMultiplayer())
{
SetThink(&CBaseEntity::SUB_Remove);
pev->nextthink = gpGlobals->time + 2.0f;
}
}
BOOL CBasePlayerAmmo::AddAmmo(CBaseEntity *pOther)
{
auto ammoInfo = GetAmmoInfo(pev->classname);
if (pOther->GiveAmmo(ammoInfo->buyClipSize, ammoInfo->ammoName2) == -1)
{
return FALSE;
}
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM);
return TRUE;
}
CBaseEntity *CBasePlayerAmmo::Respawn()
{
pev->effects |= EF_NODRAW;
SetTouch(nullptr);
// move to wherever I'm supposed to repawn.
UTIL_SetOrigin(pev, g_pGameRules->VecAmmoRespawnSpot(this));
SetThink(&CBasePlayerAmmo::Materialize);
pev->nextthink = g_pGameRules->FlAmmoRespawnTime(this);
return this;
}
void CBasePlayerAmmo::Materialize()
{
if (pev->effects & EF_NODRAW)
{
// changing from invisible state to visible.
if (g_pGameRules->IsMultiplayer())
{
EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, "items/suitchargeok1.wav", VOL_NORM, ATTN_NORM, 0, 150);
}
pev->effects &= ~EF_NODRAW;
pev->effects |= EF_MUZZLEFLASH;
}
SetTouch(&CBasePlayerAmmo::DefaultTouch);
}
void CBasePlayerAmmo::DefaultTouch(CBaseEntity *pOther)
{
if (!pOther->IsPlayer())
return;
if (AddAmmo(pOther))
{
if (g_pGameRules->AmmoShouldRespawn(this) == GR_AMMO_RESPAWN_YES)
{
Respawn();
}
else
{
SetTouch(nullptr);
SetThink(&CBaseEntity::SUB_Remove);
pev->nextthink = gpGlobals->time + 0.1f;
}
}
else if (gEvilImpulse101)
{
// evil impulse 101 hack, kill always
SetTouch(nullptr);
SetThink(&CBaseEntity::SUB_Remove);
pev->nextthink = gpGlobals->time + 0.1f;
}
}
void C9MMAmmo::Spawn()
{
Precache();
@ -13,17 +100,6 @@ void C9MMAmmo::Precache()
PRECACHE_SOUND("items/9mmclip1.wav");
}
BOOL C9MMAmmo::AddAmmo(CBaseEntity *pOther)
{
if (pOther->GiveAmmo(AMMO_9MM_BUY, "9mm") == -1)
{
return FALSE;
}
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM);
return TRUE;
}
LINK_ENTITY_TO_CLASS(ammo_9mm, C9MMAmmo, CCS9MMAmmo)
void CBuckShotAmmo::Spawn()
@ -39,17 +115,6 @@ void CBuckShotAmmo::Precache()
PRECACHE_SOUND("items/9mmclip1.wav");
}
BOOL CBuckShotAmmo::AddAmmo(CBaseEntity *pOther)
{
if (pOther->GiveAmmo(AMMO_BUCKSHOT_BUY, "buckshot") == -1)
{
return FALSE;
}
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM);
return TRUE;
}
LINK_ENTITY_TO_CLASS(ammo_buckshot, CBuckShotAmmo, CCSBuckShotAmmo)
void C556NatoAmmo::Spawn()
@ -65,17 +130,6 @@ void C556NatoAmmo::Precache()
PRECACHE_SOUND("items/9mmclip1.wav");
}
BOOL C556NatoAmmo::AddAmmo(CBaseEntity *pOther)
{
if (pOther->GiveAmmo(AMMO_556NATO_BUY, "556Nato") == -1)
{
return FALSE;
}
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM);
return TRUE;
}
LINK_ENTITY_TO_CLASS(ammo_556nato, C556NatoAmmo, CCS556NatoAmmo)
void C556NatoBoxAmmo::Spawn()
@ -91,17 +145,6 @@ void C556NatoBoxAmmo::Precache()
PRECACHE_SOUND("items/9mmclip1.wav");
}
BOOL C556NatoBoxAmmo::AddAmmo(CBaseEntity *pOther)
{
if (pOther->GiveAmmo(AMMO_556NATOBOX_BUY, "556NatoBox") == -1)
{
return FALSE;
}
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM);
return TRUE;
}
LINK_ENTITY_TO_CLASS(ammo_556natobox, C556NatoBoxAmmo, CCS556NatoBoxAmmo)
void C762NatoAmmo::Spawn()
@ -117,17 +160,6 @@ void C762NatoAmmo::Precache()
PRECACHE_SOUND("items/9mmclip1.wav");
}
BOOL C762NatoAmmo::AddAmmo(CBaseEntity *pOther)
{
if (pOther->GiveAmmo(AMMO_762NATO_BUY, "762Nato") == -1)
{
return FALSE;
}
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM);
return TRUE;
}
LINK_ENTITY_TO_CLASS(ammo_762nato, C762NatoAmmo, CCS762NatoAmmo)
void C45ACPAmmo::Spawn()
@ -143,17 +175,6 @@ void C45ACPAmmo::Precache()
PRECACHE_SOUND("items/9mmclip1.wav");
}
BOOL C45ACPAmmo::AddAmmo(CBaseEntity *pOther)
{
if (pOther->GiveAmmo(AMMO_45ACP_BUY, "45acp") == -1)
{
return FALSE;
}
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM);
return TRUE;
}
LINK_ENTITY_TO_CLASS(ammo_45acp, C45ACPAmmo, CCS45ACPAmmo)
void C50AEAmmo::Spawn()
@ -169,17 +190,6 @@ void C50AEAmmo::Precache()
PRECACHE_SOUND("items/9mmclip1.wav");
}
BOOL C50AEAmmo::AddAmmo(CBaseEntity *pOther)
{
if (pOther->GiveAmmo(AMMO_50AE_BUY, "50AE") == -1)
{
return FALSE;
}
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM);
return TRUE;
}
LINK_ENTITY_TO_CLASS(ammo_50ae, C50AEAmmo, CCS50AEAmmo)
void C338MagnumAmmo::Spawn()
@ -195,17 +205,6 @@ void C338MagnumAmmo::Precache()
PRECACHE_SOUND("items/9mmclip1.wav");
}
BOOL C338MagnumAmmo::AddAmmo(CBaseEntity *pOther)
{
if (pOther->GiveAmmo(AMMO_338MAG_BUY, "338Magnum") == -1)
{
return FALSE;
}
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM);
return TRUE;
}
LINK_ENTITY_TO_CLASS(ammo_338magnum, C338MagnumAmmo, CCS338MagnumAmmo)
void C57MMAmmo::Spawn()
@ -221,17 +220,6 @@ void C57MMAmmo::Precache()
PRECACHE_SOUND("items/9mmclip1.wav");
}
BOOL C57MMAmmo::AddAmmo(CBaseEntity *pOther)
{
if (pOther->GiveAmmo(AMMO_57MM_BUY, "57mm") == -1)
{
return FALSE;
}
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM);
return TRUE;
}
LINK_ENTITY_TO_CLASS(ammo_57mm, C57MMAmmo, CCS57MMAmmo)
void C357SIGAmmo::Spawn()
@ -247,15 +235,4 @@ void C357SIGAmmo::Precache()
PRECACHE_SOUND("items/9mmclip1.wav");
}
BOOL C357SIGAmmo::AddAmmo(CBaseEntity *pOther)
{
if (pOther->GiveAmmo(AMMO_357SIG_BUY, "357SIG") == -1)
{
return FALSE;
}
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM);
return TRUE;
}
LINK_ENTITY_TO_CLASS(ammo_357sig, C357SIGAmmo, CCS357SIGAmmo)

View File

@ -28,12 +28,23 @@
#pragma once
class CBasePlayerAmmo: public CBaseEntity
{
public:
virtual void Spawn();
virtual BOOL AddAmmo(CBaseEntity *pOther);
virtual CBaseEntity *Respawn();
public:
void EXPORT DefaultTouch(CBaseEntity *pOther);
void EXPORT Materialize();
};
class C9MMAmmo: public CBasePlayerAmmo
{
public:
virtual void Spawn();
virtual void Precache();
virtual BOOL AddAmmo(CBaseEntity *pOther);
};
class CBuckShotAmmo: public CBasePlayerAmmo
@ -41,7 +52,6 @@ class CBuckShotAmmo: public CBasePlayerAmmo
public:
virtual void Spawn();
virtual void Precache();
virtual BOOL AddAmmo(CBaseEntity *pOther);
};
class C556NatoAmmo: public CBasePlayerAmmo
@ -49,7 +59,6 @@ class C556NatoAmmo: public CBasePlayerAmmo
public:
virtual void Spawn();
virtual void Precache();
virtual BOOL AddAmmo(CBaseEntity *pOther);
};
class C556NatoBoxAmmo: public CBasePlayerAmmo
@ -57,7 +66,6 @@ class C556NatoBoxAmmo: public CBasePlayerAmmo
public:
virtual void Spawn();
virtual void Precache();
virtual BOOL AddAmmo(CBaseEntity *pOther);
};
class C762NatoAmmo: public CBasePlayerAmmo
@ -65,7 +73,6 @@ class C762NatoAmmo: public CBasePlayerAmmo
public:
virtual void Spawn();
virtual void Precache();
virtual BOOL AddAmmo(CBaseEntity *pOther);
};
class C45ACPAmmo: public CBasePlayerAmmo
@ -73,7 +80,6 @@ class C45ACPAmmo: public CBasePlayerAmmo
public:
virtual void Spawn();
virtual void Precache();
virtual BOOL AddAmmo(CBaseEntity *pOther);
};
class C50AEAmmo: public CBasePlayerAmmo
@ -81,7 +87,6 @@ class C50AEAmmo: public CBasePlayerAmmo
public:
virtual void Spawn();
virtual void Precache();
virtual BOOL AddAmmo(CBaseEntity *pOther);
};
class C338MagnumAmmo: public CBasePlayerAmmo
@ -89,7 +94,6 @@ class C338MagnumAmmo: public CBasePlayerAmmo
public:
virtual void Spawn();
virtual void Precache();
virtual BOOL AddAmmo(CBaseEntity *pOther);
};
class C57MMAmmo: public CBasePlayerAmmo
@ -97,7 +101,6 @@ class C57MMAmmo: public CBasePlayerAmmo
public:
virtual void Spawn();
virtual void Precache();
virtual BOOL AddAmmo(CBaseEntity *pOther);
};
class C357SIGAmmo: public CBasePlayerAmmo
@ -105,5 +108,4 @@ class C357SIGAmmo: public CBasePlayerAmmo
public:
virtual void Spawn();
virtual void Precache();
virtual BOOL AddAmmo(CBaseEntity *pOther);
};

View File

@ -2199,7 +2199,7 @@ bool EXT_FUNC __API_HOOK(BuyGunAmmo)(CBasePlayer *player, CBasePlayerItem *weapo
// Purchase the ammo if the player has enough money
if (player->m_iAccount >= info->clipCost)
{
player->GiveNamedItem(info->ammoName);
player->GiveNamedItem(info->ammoName1);
player->AddAccount(-info->clipCost, RT_PLAYER_BOUGHT_SOMETHING);
return true;
}

View File

@ -1400,7 +1400,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(GiveDefaultItems)()
GiveNamedItem(pszWeaponName);
const WeaponInfoStruct *info = GetWeaponInfo(pszWeaponName);
if (info) {
GiveAmmo(refill_bpammo_weapons.value != 0.0f ? info->maxRounds : ammo, info->ammoName + 5/*ammo_*/);
GiveAmmo(refill_bpammo_weapons.value != 0.0f ? info->maxRounds : ammo, info->ammoName2);
}
};

View File

@ -65,15 +65,15 @@ MULTIDAMAGE gMultiDamage;
// player can carry.
int MaxAmmoCarry(const char *szName)
{
for (int i = 0; i < MAX_WEAPONS; ++i)
for (int i = 0; i < MAX_WEAPONS; i++)
{
ItemInfo *info = &IMPL_CLASS(CBasePlayerItem, ItemInfoArray)[ i ];
if (info->pszAmmo1 && !Q_strcmp(szName, info->pszAmmo1))
ItemInfo *info = &IMPL_CLASS(CBasePlayerItem, ItemInfoArray)[i];
if (info->pszAmmo1 && !Q_stricmp(szName, info->pszAmmo1))
{
return info->iMaxAmmo1;
}
if (info->pszAmmo2 && !Q_strcmp(szName, info->pszAmmo2))
if (info->pszAmmo2 && !Q_stricmp(szName, info->pszAmmo2))
{
return info->iMaxAmmo2;
}
@ -85,7 +85,7 @@ int MaxAmmoCarry(const char *szName)
int MaxAmmoCarry(WeaponIdType weaponId)
{
return IMPL_CLASS(CBasePlayerItem, ItemInfoArray)[ weaponId ].iMaxAmmo1;
return IMPL_CLASS(CBasePlayerItem, ItemInfoArray)[weaponId].iMaxAmmo1;
}
// ClearMultiDamage - resets the global multi damage accumulator
@ -1424,81 +1424,6 @@ void CBasePlayerWeapon::Holster(int skiplocal)
m_pPlayer->pev->weaponmodel = 0;
}
void CBasePlayerAmmo::Spawn()
{
pev->movetype = MOVETYPE_TOSS;
pev->solid = SOLID_TRIGGER;
UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16));
UTIL_SetOrigin(pev, pev->origin);
SetTouch(&CBasePlayerAmmo::DefaultTouch);
if (g_pGameRules->IsMultiplayer())
{
SetThink(&CBaseEntity::SUB_Remove);
pev->nextthink = gpGlobals->time + 2.0f;
}
}
CBaseEntity *CBasePlayerAmmo::Respawn()
{
pev->effects |= EF_NODRAW;
SetTouch(NULL);
// move to wherever I'm supposed to repawn.
UTIL_SetOrigin(pev, g_pGameRules->VecAmmoRespawnSpot(this));
SetThink(&CBasePlayerAmmo::Materialize);
pev->nextthink = g_pGameRules->FlAmmoRespawnTime(this);
return this;
}
void CBasePlayerAmmo::Materialize()
{
if (pev->effects & EF_NODRAW)
{
// changing from invisible state to visible.
if (g_pGameRules->IsMultiplayer())
{
EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, "items/suitchargeok1.wav", VOL_NORM, ATTN_NORM, 0, 150);
}
pev->effects &= ~EF_NODRAW;
pev->effects |= EF_MUZZLEFLASH;
}
SetTouch(&CBasePlayerAmmo::DefaultTouch);
}
void CBasePlayerAmmo::DefaultTouch(CBaseEntity *pOther)
{
if (!pOther->IsPlayer())
return;
if (AddAmmo(pOther))
{
if (g_pGameRules->AmmoShouldRespawn(this) == GR_AMMO_RESPAWN_YES)
{
Respawn();
}
else
{
SetTouch(NULL);
SetThink(&CBaseEntity::SUB_Remove);
pev->nextthink = gpGlobals->time + 0.1f;
}
}
else if (gEvilImpulse101)
{
// evil impulse 101 hack, kill always
SetTouch(NULL);
SetThink(&CBaseEntity::SUB_Remove);
pev->nextthink = gpGlobals->time + 0.1f;
}
}
// called by the new item with the existing item as parameter
//
// if we call ExtractAmmo(), it's because the player is picking up this type of weapon for

View File

@ -405,18 +405,6 @@ public:
float m_flLastFireTime;
};
class CBasePlayerAmmo: public CBaseEntity
{
public:
virtual void Spawn();
virtual BOOL AddAmmo(CBaseEntity *pOther) { return TRUE; }
virtual CBaseEntity *Respawn();
public:
void EXPORT DefaultTouch(CBaseEntity *pOther);
void EXPORT Materialize();
};
class CWeaponBox: public CBaseEntity
{
public:

View File

@ -227,50 +227,50 @@ WeaponClassAliasInfo weaponClassAliasInfo[] =
WeaponInfoStruct weaponInfo[31];
WeaponInfoStruct weaponInfo_default[] =
{
{ WEAPON_P228, P228_PRICE, AMMO_357SIG_PRICE, AMMO_357SIG_BUY, P228_MAX_CLIP, MAX_AMMO_357SIG, AMMO_357SIG, "weapon_p228", "ammo_357sig" },
{ WEAPON_P228, P228_PRICE, AMMO_357SIG_PRICE, AMMO_357SIG_BUY, P228_MAX_CLIP, MAX_AMMO_357SIG, AMMO_357SIG, "weapon_p228", "ammo_357sig", "357SIG" },
// fix collision with glock18
#ifdef REGAMEDLL_FIXES
{ WEAPON_GLOCK, GLOCK18_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, GLOCK18_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_glock", "ammo_9mm" },
{ WEAPON_GLOCK, GLOCK18_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, GLOCK18_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_glock", "ammo_9mm", "9mm" },
#else
{ WEAPON_GLOCK, GLOCK18_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, GLOCK18_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_glock18", "ammo_9mm" },
{ WEAPON_GLOCK, GLOCK18_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, GLOCK18_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_glock18", "ammo_9mm", "9mm" },
#endif
{ 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_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_GLOCK18, GLOCK18_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, GLOCK18_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_glock18", "ammo_9mm", "9mm" },
{ WEAPON_SCOUT, SCOUT_PRICE, AMMO_762MM_PRICE, AMMO_762NATO_BUY, SCOUT_MAX_CLIP, MAX_AMMO_762NATO, AMMO_762NATO, "weapon_scout", "ammo_762nato", "762Nato" },
{ WEAPON_XM1014, XM1014_PRICE, AMMO_BUCKSHOT_PRICE, AMMO_BUCKSHOT_BUY, XM1014_MAX_CLIP, MAX_AMMO_BUCKSHOT, AMMO_BUCKSHOT, "weapon_xm1014", "ammo_buckshot", "buckshot" },
{ WEAPON_MAC10, MAC10_PRICE, AMMO_45ACP_PRICE, AMMO_45ACP_BUY, MAC10_MAX_CLIP, MAX_AMMO_45ACP, AMMO_45ACP, "weapon_mac10", "ammo_45acp", "45acp" },
{ WEAPON_AUG, AUG_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, AUG_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_aug", "ammo_556nato", "556Nato" },
{ WEAPON_ELITE, ELITE_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, ELITE_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_elite", "ammo_9mm", "9mm" },
{ WEAPON_FIVESEVEN, FIVESEVEN_PRICE, AMMO_57MM_PRICE, AMMO_57MM_BUY, FIVESEVEN_MAX_CLIP, MAX_AMMO_57MM, AMMO_57MM, "weapon_fiveseven", "ammo_57mm", "57mm" },
{ WEAPON_UMP45, UMP45_PRICE, AMMO_45ACP_PRICE, AMMO_45ACP_BUY, UMP45_MAX_CLIP, MAX_AMMO_45ACP, AMMO_45ACP, "weapon_ump45", "ammo_45acp", "45acp" },
{ WEAPON_SG550, SG550_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, SG550_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_sg550", "ammo_556nato", "556Nato" },
{ WEAPON_GALIL, GALIL_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, GALIL_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_galil", "ammo_556nato", "556Nato" },
{ WEAPON_FAMAS, FAMAS_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, FAMAS_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_famas", "ammo_556nato", "556Nato" },
{ WEAPON_USP, USP_PRICE, AMMO_45ACP_PRICE, AMMO_45ACP_BUY, USP_MAX_CLIP, MAX_AMMO_45ACP, AMMO_45ACP, "weapon_usp", "ammo_45acp", "45acp" },
{ WEAPON_AWP, AWP_PRICE, AMMO_338MAG_PRICE, AMMO_338MAG_BUY, AWP_MAX_CLIP, MAX_AMMO_338MAGNUM, AMMO_338MAGNUM, "weapon_awp", "ammo_338magnum", "338Magnum" },
{ WEAPON_MP5N, MP5NAVY_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, MP5N_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_mp5navy", "ammo_9mm", "9mm" },
{ WEAPON_M249, M249_PRICE, AMMO_556MM_PRICE, AMMO_556NATOBOX_BUY, M249_MAX_CLIP, MAX_AMMO_556NATOBOX, AMMO_556NATOBOX, "weapon_m249", "ammo_556natobox", "556NatoBox" },
{ WEAPON_M3, M3_PRICE, AMMO_BUCKSHOT_PRICE, AMMO_BUCKSHOT_BUY, M3_MAX_CLIP, MAX_AMMO_BUCKSHOT, AMMO_BUCKSHOT, "weapon_m3", "ammo_buckshot", "buckshot" },
{ WEAPON_M4A1, M4A1_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, M4A1_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_m4a1", "ammo_556nato", "556Nato" },
{ WEAPON_TMP, TMP_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, TMP_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_tmp", "ammo_9mm", "9mm" },
{ WEAPON_G3SG1, G3SG1_PRICE, AMMO_762MM_PRICE, AMMO_762NATO_BUY, G3SG1_MAX_CLIP, MAX_AMMO_762NATO, AMMO_762NATO, "weapon_g3sg1", "ammo_762nato", "762Nato" },
{ WEAPON_DEAGLE, DEAGLE_PRICE, AMMO_50AE_PRICE, AMMO_50AE_BUY, DEAGLE_MAX_CLIP, MAX_AMMO_50AE, AMMO_50AE, "weapon_deagle", "ammo_50ae", "50AE" },
{ WEAPON_SG552, SG552_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, SG552_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_sg552", "ammo_556nato", "556Nato" },
{ WEAPON_AK47, AK47_PRICE, AMMO_762MM_PRICE, AMMO_762NATO_BUY, AK47_MAX_CLIP, MAX_AMMO_762NATO, AMMO_762NATO, "weapon_ak47", "ammo_762nato", "762Nato" },
{ WEAPON_P90, P90_PRICE, AMMO_57MM_PRICE, AMMO_57MM_BUY, P90_MAX_CLIP, MAX_AMMO_57MM, AMMO_57MM, "weapon_p90", "ammo_57mm", "57mm" },
#ifdef REGAMEDLL_FIXES
{ WEAPON_C4, 0, 0, 0, 0, 0, AMMO_C4, "weapon_c4", nullptr },
{ WEAPON_KNIFE, 0, 0, 0, 0, 0, AMMO_NONE, "weapon_knife", nullptr },
{ WEAPON_HEGRENADE, (WeaponCostType)HEGRENADE_PRICE, 0, 0, 0, MAX_AMMO_HEGRENADE, AMMO_HEGRENADE, "weapon_hegrenade", nullptr },
{ WEAPON_SMOKEGRENADE, (WeaponCostType)SMOKEGRENADE_PRICE, 0, 0, 0, MAX_AMMO_SMOKEGRENADE, AMMO_SMOKEGRENADE, "weapon_smokegrenade", nullptr },
{ WEAPON_FLASHBANG, (WeaponCostType)FLASHBANG_PRICE, 0, 0, 0, MAX_AMMO_FLASHBANG, AMMO_FLASHBANG, "weapon_flashbang", nullptr },
{ WEAPON_C4, 0, 0, 0, 0, 0, AMMO_C4, "weapon_c4", nullptr, "C4" },
{ WEAPON_KNIFE, 0, 0, 0, 0, 0, AMMO_NONE, "weapon_knife", nullptr, nullptr },
{ WEAPON_HEGRENADE, (WeaponCostType)HEGRENADE_PRICE, 0, 0, 0, MAX_AMMO_HEGRENADE, AMMO_HEGRENADE, "weapon_hegrenade", nullptr, "HEGrenade" },
{ WEAPON_SMOKEGRENADE, (WeaponCostType)SMOKEGRENADE_PRICE, 0, 0, 0, MAX_AMMO_SMOKEGRENADE, AMMO_SMOKEGRENADE, "weapon_smokegrenade", nullptr, "SmokeGrenade" },
{ WEAPON_FLASHBANG, (WeaponCostType)FLASHBANG_PRICE, 0, 0, 0, MAX_AMMO_FLASHBANG, AMMO_FLASHBANG, "weapon_flashbang", nullptr, "Flashbang" },
#endif
{ WEAPON_SHIELDGUN, SHIELDGUN_PRICE, 0, 0, 0, 0, AMMO_NONE, "weapon_shield", nullptr },
{ WEAPON_SHIELDGUN, SHIELDGUN_PRICE, 0, 0, 0, 0, AMMO_NONE, "weapon_shield", nullptr, nullptr },
#ifndef REGAMEDLL_FIXES
{ 0, 0, 0, 0, 0, 0, AMMO_NONE, nullptr, nullptr },
{ 0, 0, 0, 0, 0, 0, AMMO_NONE, nullptr, nullptr, nullptr },
#endif
};
@ -425,7 +425,7 @@ bool IsSecondaryWeapon(int id)
return false;
}
WeaponInfoStruct* GetWeaponInfo(int weaponID)
WeaponInfoStruct *GetWeaponInfo(int weaponID)
{
for (auto& info : weaponInfo) {
if (info.id == weaponID) {
@ -436,7 +436,7 @@ WeaponInfoStruct* GetWeaponInfo(int weaponID)
return nullptr;
}
WeaponInfoStruct* GetWeaponInfo(const char* weaponName)
WeaponInfoStruct *GetWeaponInfo(const char *weaponName)
{
for (auto& info : weaponInfo) {
if (!Q_stricmp(info.entityName, weaponName)) {
@ -447,6 +447,17 @@ WeaponInfoStruct* GetWeaponInfo(const char* weaponName)
return nullptr;
}
WeaponInfoStruct *GetAmmoInfo(const char *ammoName)
{
for (auto& info : weaponInfo) {
if (!Q_stricmp(info.ammoName1, ammoName)) {
return &info;
}
}
return nullptr;
}
void WeaponInfoReset()
{
#ifndef HOOK_GAMEDLL

View File

@ -409,7 +409,8 @@ struct WeaponInfoStruct
char *entityName;
// custom
const char *ammoName;
const char *ammoName1;
const char *ammoName2;
};
struct WeaponSlotInfo
@ -435,6 +436,7 @@ void WeaponInfoReset();
WeaponInfoStruct *GetWeaponInfo(int weaponID);
WeaponInfoStruct *GetWeaponInfo(const char *weaponName);
WeaponInfoStruct *GetAmmoInfo(const char *ammoName);
WeaponSlotInfo *GetWeaponSlot(WeaponIdType weaponID);
WeaponSlotInfo *GetWeaponSlot(const char *weaponName);

View File

@ -2939,61 +2939,61 @@ FunctionHook g_FunctionHooks[] =
//C9MMAmmo
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59550, "_ZN8C9MMAmmo5SpawnEv", C9MMAmmo::Spawn),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59580, "_ZN8C9MMAmmo8PrecacheEv", C9MMAmmo::Precache),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D595A0, "_ZN8C9MMAmmo7AddAmmoEP11CBaseEntity", C9MMAmmo::AddAmmo),
//HOOK_SYMBOL_VIRTUAL_DEF(0x01D595A0, "_ZN8C9MMAmmo7AddAmmoEP11CBaseEntity", C9MMAmmo::AddAmmo),
// non-virtual func
HOOK_DEF(0x01D59500, ammo_9mm),
//CBuckShotAmmo
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59640, "_ZN13CBuckShotAmmo5SpawnEv", CBuckShotAmmo::Spawn),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59670, "_ZN13CBuckShotAmmo8PrecacheEv", CBuckShotAmmo::Precache),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59690, "_ZN13CBuckShotAmmo7AddAmmoEP11CBaseEntity", CBuckShotAmmo::AddAmmo),
//HOOK_SYMBOL_VIRTUAL_DEF(0x01D59690, "_ZN13CBuckShotAmmo7AddAmmoEP11CBaseEntity", CBuckShotAmmo::AddAmmo),
// non-virtual func
HOOK_DEF(0x01D595F0, ammo_buckshot),
//C556NatoAmmo
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59730, "_ZN12C556NatoAmmo5SpawnEv", C556NatoAmmo::Spawn),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59760, "_ZN12C556NatoAmmo8PrecacheEv", C556NatoAmmo::Precache),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59780, "_ZN12C556NatoAmmo7AddAmmoEP11CBaseEntity", C556NatoAmmo::AddAmmo),
//HOOK_SYMBOL_VIRTUAL_DEF(0x01D59780, "_ZN12C556NatoAmmo7AddAmmoEP11CBaseEntity", C556NatoAmmo::AddAmmo),
// non-virtual func
HOOK_DEF(0x01D596E0, ammo_556nato),
//C556NatoBoxAmmo
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59820, "_ZN15C556NatoBoxAmmo5SpawnEv", C556NatoBoxAmmo::Spawn),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59850, "_ZN15C556NatoBoxAmmo8PrecacheEv", C556NatoBoxAmmo::Precache),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59870, "_ZN15C556NatoBoxAmmo7AddAmmoEP11CBaseEntity", C556NatoBoxAmmo::AddAmmo),
//HOOK_SYMBOL_VIRTUAL_DEF(0x01D59870, "_ZN15C556NatoBoxAmmo7AddAmmoEP11CBaseEntity", C556NatoBoxAmmo::AddAmmo),
// non-virtual func
HOOK_DEF(0x01D597D0, ammo_556natobox),
//C762NatoAmmo
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59920, "_ZN12C762NatoAmmo5SpawnEv", C762NatoAmmo::Spawn),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59950, "_ZN12C762NatoAmmo8PrecacheEv", C762NatoAmmo::Precache),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59970, "_ZN12C762NatoAmmo7AddAmmoEP11CBaseEntity", C762NatoAmmo::AddAmmo),
//HOOK_SYMBOL_VIRTUAL_DEF(0x01D59970, "_ZN12C762NatoAmmo7AddAmmoEP11CBaseEntity", C762NatoAmmo::AddAmmo),
// non-virtual func
HOOK_DEF(0x01D598D0, ammo_762nato),
//C45ACPAmmo
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59A10, "_ZN10C45ACPAmmo5SpawnEv", C45ACPAmmo::Spawn),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59A40, "_ZN10C45ACPAmmo8PrecacheEv", C45ACPAmmo::Precache),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59A60, "_ZN10C45ACPAmmo7AddAmmoEP11CBaseEntity", C45ACPAmmo::AddAmmo),
//HOOK_SYMBOL_VIRTUAL_DEF(0x01D59A60, "_ZN10C45ACPAmmo7AddAmmoEP11CBaseEntity", C45ACPAmmo::AddAmmo),
// non-virtual func
HOOK_DEF(0x01D599C0, ammo_45acp),
//C50AEAmmo
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59B00, "_ZN9C50AEAmmo5SpawnEv", C50AEAmmo::Spawn),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59B30, "_ZN9C50AEAmmo8PrecacheEv", C50AEAmmo::Precache),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59B50, "_ZN9C50AEAmmo7AddAmmoEP11CBaseEntity", C50AEAmmo::AddAmmo),
//HOOK_SYMBOL_VIRTUAL_DEF(0x01D59B50, "_ZN9C50AEAmmo7AddAmmoEP11CBaseEntity", C50AEAmmo::AddAmmo),
// non-virtual func
HOOK_DEF(0x01D59AB0, ammo_50ae),
//C338MagnumAmmo
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59BF0, "_ZN14C338MagnumAmmo5SpawnEv", C338MagnumAmmo::Spawn),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59C20, "_ZN14C338MagnumAmmo8PrecacheEv", C338MagnumAmmo::Precache),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59C40, "_ZN14C338MagnumAmmo7AddAmmoEP11CBaseEntity", C338MagnumAmmo::AddAmmo),
//HOOK_SYMBOL_VIRTUAL_DEF(0x01D59C40, "_ZN14C338MagnumAmmo7AddAmmoEP11CBaseEntity", C338MagnumAmmo::AddAmmo),
// non-virtual func
HOOK_DEF(0x01D59BA0, ammo_338magnum),
//C57MMAmmo
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59CE0, "_ZN9C57MMAmmo5SpawnEv", C57MMAmmo::Spawn),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59D10, "_ZN9C57MMAmmo8PrecacheEv", C57MMAmmo::Precache),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59D30, "_ZN9C57MMAmmo7AddAmmoEP11CBaseEntity", C57MMAmmo::AddAmmo),
//HOOK_SYMBOL_VIRTUAL_DEF(0x01D59D30, "_ZN9C57MMAmmo7AddAmmoEP11CBaseEntity", C57MMAmmo::AddAmmo),
// non-virtual func
HOOK_DEF(0x01D59C90, ammo_57mm),
//C357SIGAmmo
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59DD0, "_ZN11C357SIGAmmo5SpawnEv", C357SIGAmmo::Spawn),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59E00, "_ZN11C357SIGAmmo8PrecacheEv", C357SIGAmmo::Precache),
HOOK_SYMBOL_VIRTUAL_DEF(0x01D59E20, "_ZN11C357SIGAmmo7AddAmmoEP11CBaseEntity", C357SIGAmmo::AddAmmo),
//HOOK_SYMBOL_VIRTUAL_DEF(0x01D59E20, "_ZN11C357SIGAmmo7AddAmmoEP11CBaseEntity", C357SIGAmmo::AddAmmo),
// non-virtual func
HOOK_DEF(0x01D59D80, ammo_357sig),
//CWeaponBox