mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-01-14 15:48:01 +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)
|
||||
{
|
||||
((CBasePlayer*)pActivator)->m_pTank = this;
|
||||
((CBasePlayer *)pActivator)->m_pTank = this;
|
||||
StartControl((CBasePlayer*)pActivator);
|
||||
}
|
||||
else
|
||||
|
@ -34,7 +34,7 @@ enum ItemRestType
|
||||
{
|
||||
ITEM_TYPE_BUYING, // when a player buying items
|
||||
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
|
||||
|
@ -425,7 +425,7 @@ void CHalfLifeMultiplay::ReadMultiplayCvars()
|
||||
}
|
||||
|
||||
// auto-disable ff
|
||||
if (friendlyfire.value)
|
||||
if (freeforall.value)
|
||||
{
|
||||
CVAR_SET_FLOAT("mp_friendlyfire", 0);
|
||||
}
|
||||
|
@ -1575,6 +1575,35 @@ void EXT_ALIGN CBasePlayer::__API_HOOK(GiveDefaultItems)()
|
||||
RemoveAllItems(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)
|
||||
{
|
||||
case CT:
|
||||
@ -1588,6 +1617,7 @@ void EXT_ALIGN CBasePlayer::__API_HOOK(GiveDefaultItems)()
|
||||
GiveAmmo(40, "9mm", MAX_AMMO_9MM);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CBasePlayer::RemoveAllItems(BOOL removeSuit)
|
||||
@ -7363,7 +7393,7 @@ void CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName)
|
||||
if (pWeapon->iItemSlot() == PRIMARY_WEAPON_SLOT)
|
||||
m_bHasPrimary = false;
|
||||
|
||||
if (!Q_strcmp(STRING(pWeapon->pev->classname), "weapon_c4"))
|
||||
if (FClassnameIs(pWeapon->pev, "weapon_c4"))
|
||||
{
|
||||
m_bHasC4 = false;
|
||||
pev->body = 0;
|
||||
@ -7412,7 +7442,7 @@ void CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName)
|
||||
pWeaponBox->PackWeapon(pWeapon);
|
||||
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->SetThink(&CWeaponBox::BombThink);
|
||||
@ -7431,7 +7461,12 @@ void CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName)
|
||||
int iAmmoIndex = GetAmmoIndex(pWeapon->pszAmmo1());
|
||||
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);
|
||||
#endif
|
||||
m_rgAmmo[iAmmoIndex] = 0;
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ enum ItemRestType
|
||||
{
|
||||
ITEM_TYPE_BUYING, // when a player buying items
|
||||
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
|
||||
|
@ -133,18 +133,133 @@ bool CCSPlayer::JoinTeam(TeamName team)
|
||||
|
||||
bool CCSPlayer::RemovePlayerItem(const char* pszItemName)
|
||||
{
|
||||
if (!pszItemName)
|
||||
return false;
|
||||
|
||||
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) {
|
||||
while (pItem != nullptr)
|
||||
{
|
||||
if (FClassnameIs(pItem->pev, pszItemName))
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
if (pWeapon->iItemSlot() == PRIMARY_WEAPON_SLOT) {
|
||||
pPlayer->m_bHasPrimary = false;
|
||||
}
|
||||
|
||||
pPlayer->pev->weapons &= ~(1 << pItem->m_iId);
|
||||
pPlayer->RemovePlayerItem(pItem);
|
||||
pItem->Kill();
|
||||
@ -158,11 +273,30 @@ bool CCSPlayer::RemovePlayerItem(const char* pszItemName)
|
||||
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; }
|
||||
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::GiveNamedItem(const char *pszName) { BasePlayer()->GiveNamedItem(pszName); }
|
||||
void CCSPlayer::GiveNamedItemEx(const char *pszName) { BasePlayer()->GiveNamedItemEx(pszName); }
|
||||
void CCSPlayer::GiveDefaultItems() { BasePlayer()->GiveDefaultItems(); }
|
||||
void CCSPlayer::GiveShield(bool bDeploy) { BasePlayer()->GiveShield(bDeploy); }
|
||||
void CCSPlayer::DropShield(bool bDeploy) { BasePlayer()->DropShield(bDeploy); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user