Skip to content

Commit

Permalink
enhance "player_weaponstrip" entity
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaqtincha committed May 28, 2021
1 parent d80d873 commit 0a6a857
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 1 deletion.
80 changes: 79 additions & 1 deletion regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions regamedll/dlls/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0a6a857

Please sign in to comment.