enhance "player_weaponstrip" entity (#634)

* enhance "player_weaponstrip" entity
* update fgd
This commit is contained in:
Vaqtincha 2021-06-06 17:17:07 +05:00 committed by GitHub
parent 548cca5e5f
commit ab846f86f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 124 additions and 2 deletions

View File

@ -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);
}
}
}

View File

@ -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

View File

@ -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"