mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-01-14 23:58:06 +03:00
Improvement function CCSPlayer::RemovePlayerItem (with considering item_*/weapon_shield/weapon_c4)
Fix: using CCSPlayer::RemovePlayerItem removal of the primary slot later was impossible to pick up armoury_entity. Fix: Do was not pack all bpammo of the item with flag ITEM_FLAG_EXHAUSTIBLE (always only 0 or 1)
This commit is contained in:
parent
83a01dbb48
commit
82d49fdcb6
@ -337,7 +337,7 @@ void CFuncTank::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller,
|
|||||||
}
|
}
|
||||||
else if (!m_pController && useType != USE_OFF)
|
else if (!m_pController && useType != USE_OFF)
|
||||||
{
|
{
|
||||||
((CBasePlayer*)pActivator)->m_pTank = this;
|
((CBasePlayer *)pActivator)->m_pTank = this;
|
||||||
StartControl((CBasePlayer*)pActivator);
|
StartControl((CBasePlayer*)pActivator);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -34,7 +34,7 @@ enum ItemRestType
|
|||||||
{
|
{
|
||||||
ITEM_TYPE_BUYING, // when a player buying items
|
ITEM_TYPE_BUYING, // when a player buying items
|
||||||
ITEM_TYPE_TOUCHED, // when the player touches with a weaponbox or armoury_entity
|
ITEM_TYPE_TOUCHED, // when the player touches with a weaponbox or armoury_entity
|
||||||
ITEM_TYPE_EQUIPPED // when a entity game_player_equip to player gives item
|
ITEM_TYPE_EQUIPPED // when a entity game_player_equip gives item to player or default item's on player spawn
|
||||||
};
|
};
|
||||||
|
|
||||||
// constant items
|
// constant items
|
||||||
|
@ -425,7 +425,7 @@ void CHalfLifeMultiplay::ReadMultiplayCvars()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// auto-disable ff
|
// auto-disable ff
|
||||||
if (friendlyfire.value)
|
if (freeforall.value)
|
||||||
{
|
{
|
||||||
CVAR_SET_FLOAT("mp_friendlyfire", 0);
|
CVAR_SET_FLOAT("mp_friendlyfire", 0);
|
||||||
}
|
}
|
||||||
|
@ -1575,6 +1575,35 @@ void EXT_ALIGN CBasePlayer::__API_HOOK(GiveDefaultItems)()
|
|||||||
RemoveAllItems(FALSE);
|
RemoveAllItems(FALSE);
|
||||||
m_bHasPrimary = false;
|
m_bHasPrimary = false;
|
||||||
|
|
||||||
|
#ifdef REGAMEDLL_ADD
|
||||||
|
switch (m_iTeam)
|
||||||
|
{
|
||||||
|
case CT:
|
||||||
|
{
|
||||||
|
if (!HasRestrictItem(ITEM_KNIFE, ITEM_TYPE_EQUIPPED)) {
|
||||||
|
GiveNamedItem("weapon_knife");
|
||||||
|
}
|
||||||
|
if (!HasRestrictItem(ITEM_USP, ITEM_TYPE_EQUIPPED)) {
|
||||||
|
GiveNamedItem("weapon_usp");
|
||||||
|
GiveAmmo(m_bIsVIP ? 12 : 24, "45acp", MAX_AMMO_45ACP);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TERRORIST:
|
||||||
|
{
|
||||||
|
if (!HasRestrictItem(ITEM_KNIFE, ITEM_TYPE_EQUIPPED)) {
|
||||||
|
GiveNamedItem("weapon_knife");
|
||||||
|
}
|
||||||
|
if (!HasRestrictItem(ITEM_GLOCK18, ITEM_TYPE_EQUIPPED)) {
|
||||||
|
GiveNamedItem("weapon_glock18");
|
||||||
|
GiveAmmo(40, "9mm", MAX_AMMO_9MM);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
switch (m_iTeam)
|
switch (m_iTeam)
|
||||||
{
|
{
|
||||||
case CT:
|
case CT:
|
||||||
@ -1588,6 +1617,7 @@ void EXT_ALIGN CBasePlayer::__API_HOOK(GiveDefaultItems)()
|
|||||||
GiveAmmo(40, "9mm", MAX_AMMO_9MM);
|
GiveAmmo(40, "9mm", MAX_AMMO_9MM);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBasePlayer::RemoveAllItems(BOOL removeSuit)
|
void CBasePlayer::RemoveAllItems(BOOL removeSuit)
|
||||||
@ -7363,7 +7393,7 @@ void CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName)
|
|||||||
if (pWeapon->iItemSlot() == PRIMARY_WEAPON_SLOT)
|
if (pWeapon->iItemSlot() == PRIMARY_WEAPON_SLOT)
|
||||||
m_bHasPrimary = false;
|
m_bHasPrimary = false;
|
||||||
|
|
||||||
if (!Q_strcmp(STRING(pWeapon->pev->classname), "weapon_c4"))
|
if (FClassnameIs(pWeapon->pev, "weapon_c4"))
|
||||||
{
|
{
|
||||||
m_bHasC4 = false;
|
m_bHasC4 = false;
|
||||||
pev->body = 0;
|
pev->body = 0;
|
||||||
@ -7412,7 +7442,7 @@ void CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName)
|
|||||||
pWeaponBox->PackWeapon(pWeapon);
|
pWeaponBox->PackWeapon(pWeapon);
|
||||||
pWeaponBox->pev->velocity = gpGlobals->v_forward * 300 + gpGlobals->v_forward * 100;
|
pWeaponBox->pev->velocity = gpGlobals->v_forward * 300 + gpGlobals->v_forward * 100;
|
||||||
|
|
||||||
if (!Q_strcmp(STRING(pWeapon->pev->classname), "weapon_c4"))
|
if (FClassnameIs(pWeapon->pev, "weapon_c4"))
|
||||||
{
|
{
|
||||||
pWeaponBox->m_bIsBomb = true;
|
pWeaponBox->m_bIsBomb = true;
|
||||||
pWeaponBox->SetThink(&CWeaponBox::BombThink);
|
pWeaponBox->SetThink(&CWeaponBox::BombThink);
|
||||||
@ -7431,7 +7461,12 @@ void CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName)
|
|||||||
int iAmmoIndex = GetAmmoIndex(pWeapon->pszAmmo1());
|
int iAmmoIndex = GetAmmoIndex(pWeapon->pszAmmo1());
|
||||||
if (iAmmoIndex != -1)
|
if (iAmmoIndex != -1)
|
||||||
{
|
{
|
||||||
|
#ifdef REGAMEDLL_FIXES
|
||||||
|
// why not pack the ammo more than one?
|
||||||
|
pWeaponBox->PackAmmo(MAKE_STRING(pWeapon->pszAmmo1()), m_rgAmmo[iAmmoIndex]);
|
||||||
|
#else
|
||||||
pWeaponBox->PackAmmo(MAKE_STRING(pWeapon->pszAmmo1()), m_rgAmmo[iAmmoIndex] > 0);
|
pWeaponBox->PackAmmo(MAKE_STRING(pWeapon->pszAmmo1()), m_rgAmmo[iAmmoIndex] > 0);
|
||||||
|
#endif
|
||||||
m_rgAmmo[iAmmoIndex] = 0;
|
m_rgAmmo[iAmmoIndex] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ enum ItemRestType
|
|||||||
{
|
{
|
||||||
ITEM_TYPE_BUYING, // when a player buying items
|
ITEM_TYPE_BUYING, // when a player buying items
|
||||||
ITEM_TYPE_TOUCHED, // when the player touches with a weaponbox or armoury_entity
|
ITEM_TYPE_TOUCHED, // when the player touches with a weaponbox or armoury_entity
|
||||||
ITEM_TYPE_EQUIPPED // when a entity game_player_equip to player gives item
|
ITEM_TYPE_EQUIPPED // when a entity game_player_equip gives item to player or default item's on player spawn
|
||||||
};
|
};
|
||||||
|
|
||||||
// constant items
|
// constant items
|
||||||
|
@ -133,18 +133,133 @@ bool CCSPlayer::JoinTeam(TeamName team)
|
|||||||
|
|
||||||
bool CCSPlayer::RemovePlayerItem(const char* pszItemName)
|
bool CCSPlayer::RemovePlayerItem(const char* pszItemName)
|
||||||
{
|
{
|
||||||
|
if (!pszItemName)
|
||||||
|
return false;
|
||||||
|
|
||||||
CBasePlayer *pPlayer = BasePlayer();
|
CBasePlayer *pPlayer = BasePlayer();
|
||||||
|
|
||||||
|
// if it item_ ?
|
||||||
|
if (pszItemName[0] == 'i') {
|
||||||
|
pszItemName += sizeof("item_") - 1;
|
||||||
|
|
||||||
|
// item_thighpack
|
||||||
|
if (FStrEq(pszItemName, "thighpack"))
|
||||||
|
{
|
||||||
|
// if we don't have it?
|
||||||
|
if (!pPlayer->m_bHasDefuser)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
pPlayer->m_bHasDefuser = false;
|
||||||
|
pPlayer->pev->body = 0;
|
||||||
|
|
||||||
|
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pPlayer->pev);
|
||||||
|
WRITE_BYTE(STATUSICON_HIDE);
|
||||||
|
WRITE_STRING("defuser");
|
||||||
|
MESSAGE_END();
|
||||||
|
|
||||||
|
pPlayer->SendItemStatus();
|
||||||
|
}
|
||||||
|
// item_longjump
|
||||||
|
else if (FStrEq(pszItemName, "longjump"))
|
||||||
|
{
|
||||||
|
// if we don't have it?
|
||||||
|
if (!pPlayer->m_fLongJump)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
pPlayer->m_fLongJump = FALSE;
|
||||||
|
SET_PHYSICS_KEY_VALUE(pPlayer->edict(), "slj", "0");
|
||||||
|
}
|
||||||
|
// item_assaultsuit
|
||||||
|
else if (FStrEq(pszItemName, "assaultsuit"))
|
||||||
|
{
|
||||||
|
// if we don't have it?
|
||||||
|
if (pPlayer->m_iKevlar != ARMOR_VESTHELM)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
pPlayer->m_iKevlar = ARMOR_NONE;
|
||||||
|
pPlayer->pev->armorvalue = 0;
|
||||||
|
|
||||||
|
MESSAGE_BEGIN(MSG_ONE, gmsgArmorType, NULL, pPlayer->pev);
|
||||||
|
WRITE_BYTE(0);
|
||||||
|
MESSAGE_END();
|
||||||
|
}
|
||||||
|
// item_kevlar
|
||||||
|
else if (FStrEq(pszItemName, "kevlar"))
|
||||||
|
{
|
||||||
|
// if we don't have it?
|
||||||
|
if (pPlayer->m_iKevlar != ARMOR_KEVLAR)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
pPlayer->m_iKevlar = ARMOR_NONE;
|
||||||
|
pPlayer->pev->armorvalue = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (FStrEq(pszItemName, "weapon_shield")) {
|
||||||
|
if (!pPlayer->HasShield())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool bIsProtectedShield = pPlayer->IsProtectedByShield();
|
||||||
|
pPlayer->RemoveShield();
|
||||||
|
|
||||||
|
CBasePlayerWeapon *pWeapon = static_cast<CBasePlayerWeapon *>(pPlayer->m_pActiveItem);
|
||||||
|
|
||||||
|
if (pWeapon)
|
||||||
|
{
|
||||||
|
if (!pWeapon->CanHolster())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (pWeapon->m_iId == WEAPON_HEGRENADE || pWeapon->m_iId == WEAPON_FLASHBANG || pWeapon->m_iId == WEAPON_SMOKEGRENADE)
|
||||||
|
{
|
||||||
|
if (pPlayer->m_rgAmmo[ pWeapon->m_iPrimaryAmmoType ] <= 0)
|
||||||
|
g_pGameRules->GetNextBestWeapon(pPlayer, pWeapon);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pWeapon->m_flStartThrow != 0.0f)
|
||||||
|
pWeapon->Holster();
|
||||||
|
|
||||||
|
if (pPlayer->IsReloading())
|
||||||
|
{
|
||||||
|
pWeapon->m_fInReload = FALSE;
|
||||||
|
pPlayer->m_flNextAttack = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bIsProtectedShield)
|
||||||
|
pWeapon->SecondaryAttack();
|
||||||
|
|
||||||
|
pWeapon->Deploy();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
for (auto pItem : pPlayer->m_rgpPlayerItems) {
|
for (auto pItem : pPlayer->m_rgpPlayerItems) {
|
||||||
while (pItem != nullptr)
|
while (pItem != nullptr)
|
||||||
{
|
{
|
||||||
if (FClassnameIs(pItem->pev, pszItemName))
|
if (FClassnameIs(pItem->pev, pszItemName))
|
||||||
{
|
{
|
||||||
CBasePlayerWeapon *pWeapon = static_cast<CBasePlayerWeapon *>(pItem);
|
CBasePlayerWeapon *pWeapon = static_cast<CBasePlayerWeapon *>(pItem);
|
||||||
if (pWeapon->IsWeapon()) {
|
if (pWeapon->IsWeapon())
|
||||||
|
{
|
||||||
|
if (FClassnameIs(pWeapon->pev, "weapon_c4"))
|
||||||
|
{
|
||||||
|
pPlayer->m_bHasC4 = false;
|
||||||
|
pPlayer->pev->body = 0;
|
||||||
|
pPlayer->SetBombIcon(FALSE);
|
||||||
|
pPlayer->SetProgressBarTime(0);
|
||||||
|
}
|
||||||
|
|
||||||
pWeapon->RetireWeapon();
|
pWeapon->RetireWeapon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pWeapon->iItemSlot() == PRIMARY_WEAPON_SLOT) {
|
||||||
|
pPlayer->m_bHasPrimary = false;
|
||||||
|
}
|
||||||
|
|
||||||
pPlayer->pev->weapons &= ~(1 << pItem->m_iId);
|
pPlayer->pev->weapons &= ~(1 << pItem->m_iId);
|
||||||
pPlayer->RemovePlayerItem(pItem);
|
pPlayer->RemovePlayerItem(pItem);
|
||||||
pItem->Kill();
|
pItem->Kill();
|
||||||
@ -158,11 +273,30 @@ bool CCSPlayer::RemovePlayerItem(const char* pszItemName)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCSPlayer::GiveNamedItemEx(const char *pszName)
|
||||||
|
{
|
||||||
|
CBasePlayer *pPlayer = BasePlayer();
|
||||||
|
|
||||||
|
if (FStrEq(pszName, "weapon_c4")) {
|
||||||
|
pPlayer->m_bHasC4 = true;
|
||||||
|
pPlayer->SetBombIcon();
|
||||||
|
|
||||||
|
if (pPlayer->m_iTeam == TERRORIST) {
|
||||||
|
pPlayer->pev->body = 1;
|
||||||
|
}
|
||||||
|
} else if (FStrEq(pszName, "weapon_shield")) {
|
||||||
|
DropPrimary(pPlayer);
|
||||||
|
pPlayer->GiveShield();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pPlayer->GiveNamedItemEx(pszName);
|
||||||
|
}
|
||||||
|
|
||||||
bool CCSPlayer::IsConnected() const { return m_pContainingEntity->has_disconnected == false; }
|
bool CCSPlayer::IsConnected() const { return m_pContainingEntity->has_disconnected == false; }
|
||||||
void CCSPlayer::SetAnimation(PLAYER_ANIM playerAnim) { BasePlayer()->SetAnimation(playerAnim); }
|
void CCSPlayer::SetAnimation(PLAYER_ANIM playerAnim) { BasePlayer()->SetAnimation(playerAnim); }
|
||||||
void CCSPlayer::AddAccount(int amount, RewardType type, bool bTrackChange) { BasePlayer()->AddAccount(amount, type, bTrackChange); }
|
void CCSPlayer::AddAccount(int amount, RewardType type, bool bTrackChange) { BasePlayer()->AddAccount(amount, type, bTrackChange); }
|
||||||
void CCSPlayer::GiveNamedItem(const char *pszName) { BasePlayer()->GiveNamedItem(pszName); }
|
void CCSPlayer::GiveNamedItem(const char *pszName) { BasePlayer()->GiveNamedItem(pszName); }
|
||||||
void CCSPlayer::GiveNamedItemEx(const char *pszName) { BasePlayer()->GiveNamedItemEx(pszName); }
|
|
||||||
void CCSPlayer::GiveDefaultItems() { BasePlayer()->GiveDefaultItems(); }
|
void CCSPlayer::GiveDefaultItems() { BasePlayer()->GiveDefaultItems(); }
|
||||||
void CCSPlayer::GiveShield(bool bDeploy) { BasePlayer()->GiveShield(bDeploy); }
|
void CCSPlayer::GiveShield(bool bDeploy) { BasePlayer()->GiveShield(bDeploy); }
|
||||||
void CCSPlayer::DropShield(bool bDeploy) { BasePlayer()->DropShield(bDeploy); }
|
void CCSPlayer::DropShield(bool bDeploy) { BasePlayer()->DropShield(bDeploy); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user