diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index e3cac4fcd..976fbc0e8 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -8310,6 +8310,48 @@ void CDeadHEV::KeyValue(KeyValueData *pkvd) LINK_ENTITY_TO_CLASS(player_weaponstrip, CStripWeapons, CCSStripWeapons) +void CStripWeapons::KeyValue(KeyValueData *pkvd) +{ + if (FStrEq(pkvd->szKeyName, "primary") && Q_atoi(pkvd->szValue) > 0) + { + m_bitsIgnoreSlots |= (1 << PRIMARY_WEAPON_SLOT); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "secondary") && Q_atoi(pkvd->szValue) > 0) + { + m_bitsIgnoreSlots |= (1 << PISTOL_SLOT); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "knife") && Q_atoi(pkvd->szValue) > 0) + { + m_bitsIgnoreSlots |= (1 << KNIFE_SLOT); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "grenade") && Q_atoi(pkvd->szValue) > 0) + { + m_bitsIgnoreSlots |= (1 << GRENADE_SLOT); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "bomb") && Q_atoi(pkvd->szValue) > 0) + { + m_bitsIgnoreSlots |= (1 << C4_SLOT); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "items") && Q_atoi(pkvd->szValue) > 0) + { + m_bitsIgnoreSlots |= (1 << ALL_OTHER_ITEMS); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "special")) + { + m_iszSpecialItem = ALLOC_STRING(pkvd->szValue); + } + else + { + CPointEntity::KeyValue(pkvd); + } +} + void CStripWeapons::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { CBasePlayer *pPlayer = nullptr; @@ -8324,7 +8366,43 @@ void CStripWeapons::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE if (pPlayer) { - pPlayer->RemoveAllItems(FALSE); +#ifdef REGAMEDLL_ADD + if (m_bitsIgnoreSlots != 0 || m_iszSpecialItem) + { + if (m_iszSpecialItem) + { + pPlayer->CSPlayer()->RemovePlayerItem(STRING(m_iszSpecialItem)); + } + + for (int slot = PRIMARY_WEAPON_SLOT; slot <= ALL_OTHER_ITEMS; slot++) + { + if (m_bitsIgnoreSlots & (1 << slot)) + continue; + + if (slot == ALL_OTHER_ITEMS) + { + pPlayer->CSPlayer()->RemovePlayerItem("item_thighpack"); + pPlayer->CSPlayer()->RemovePlayerItem("item_longjump"); + pPlayer->CSPlayer()->RemovePlayerItem("item_assaultsuit"); + pPlayer->CSPlayer()->RemovePlayerItem("item_kevlar"); + pPlayer->CSPlayer()->RemovePlayerItem("item_thighpack"); + pPlayer->CSPlayer()->RemovePlayerItem("weapon_shield"); + } + else + { + pPlayer->ForEachItem(slot, [pPlayer](CBasePlayerItem *pItem) + { + pPlayer->CSPlayer()->RemovePlayerItem(STRING(pItem->pev->classname)); + return false; + }); + } + } + } + else +#endif + { + pPlayer->RemoveAllItems(FALSE); + } } } diff --git a/regamedll/dlls/player.h b/regamedll/dlls/player.h index 8f146c665..fbf34b146 100644 --- a/regamedll/dlls/player.h +++ b/regamedll/dlls/player.h @@ -298,9 +298,18 @@ enum MusicState { SILENT, CALM, INTENSE }; class CCSPlayer; +#define ALL_OTHER_ITEMS 6 + class CStripWeapons: public CPointEntity { public: virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); +#ifdef REGAMEDLL_ADD + virtual void KeyValue(KeyValueData *pkvd); + +public: + int m_bitsIgnoreSlots; + int m_iszSpecialItem; +#endif }; // Dead HEV suit prop