diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 14f1a4ec..0b049e6d 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -8310,6 +8310,50 @@ void CDeadHEV::KeyValue(KeyValueData *pkvd) LINK_ENTITY_TO_CLASS(player_weaponstrip, CStripWeapons, CCSStripWeapons) +void CStripWeapons::KeyValue(KeyValueData *pkvd) +{ +#ifdef REGAMEDLL_ADD + 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 +#endif + { + CPointEntity::KeyValue(pkvd); + } +} + void CStripWeapons::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { CBasePlayer *pPlayer = nullptr; @@ -8324,7 +8368,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 8f146c66..3108ba53 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); + virtual void KeyValue(KeyValueData *pkvd); + +#ifdef REGAMEDLL_ADD +public: + int m_bitsIgnoreSlots; + int m_iszSpecialItem; +#endif }; // Dead HEV suit prop diff --git a/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd b/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd index 3b59afd9..fbdd8a90 100644 --- a/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd +++ b/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd @@ -2039,7 +2039,40 @@ speed(integer) : "New Train Speed" : 0 ] -@PointClass base(Targetname) size(-16 -16 -16, 16 16 16) iconsprite("sprites/CS/player_weaponstrip.spr") = player_weaponstrip : "Strips player's weapons" [] +@PointClass base(Targetname) size(-16 -16 -16, 16 16 16) iconsprite("sprites/CS/player_weaponstrip.spr") = player_weaponstrip : "Strips player's weapons" +[ + primary(choices) : "Ignore primary weapons" : 0 = + [ + 0 : "No" + 1 : "Yes" + ] + secondary(choices) : "Ignore pistols" : 0 = + [ + 0 : "No" + 1 : "Yes" + ] + knife(choices) : "Ignore knife" : 0 = + [ + 0 : "No" + 1 : "Yes" + ] + grenade(choices) : "Ignore grenades" : 0 = + [ + 0 : "No" + 1 : "Yes" + ] + bomb(choices) : "Ignore bomb" : 0 = + [ + 0 : "No" + 1 : "Yes" + ] + items(choices) : "Ignore other items (shield, defuser, kevlar etc)" : 0 = + [ + 0 : "No" + 1 : "Yes" + ] + special(string) : "Special item to strip" +] // Monsters @PointClass iconsprite("sprites/CS/hostage_entity.spr") base(PlayerClass, RenderFields) size(-16 -16 0, 16 16 72) = monster_scientist : "Scientist Hostage"