mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-01-14 23:58:06 +03:00
game_player_equip fixes/enhancement (#618)
* game_player_equip: Check UseOnly flag * New flag SF_PLAYEREQUIP_REMOVEWEAPONS
This commit is contained in:
parent
8d1f4fb673
commit
d80d87366a
@ -565,14 +565,11 @@ void CGamePlayerEquip::KeyValue(KeyValueData *pkvd)
|
|||||||
|
|
||||||
void CGamePlayerEquip::Touch(CBaseEntity *pOther)
|
void CGamePlayerEquip::Touch(CBaseEntity *pOther)
|
||||||
{
|
{
|
||||||
if (!CanFireForActivator(pOther))
|
if (CanEquipOverTouch(pOther))
|
||||||
return;
|
{
|
||||||
|
|
||||||
if (UseOnly())
|
|
||||||
return;
|
|
||||||
|
|
||||||
EquipPlayer(pOther);
|
EquipPlayer(pOther);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CGamePlayerEquip::EquipPlayer(CBaseEntity *pEntity)
|
void CGamePlayerEquip::EquipPlayer(CBaseEntity *pEntity)
|
||||||
{
|
{
|
||||||
@ -580,6 +577,12 @@ void CGamePlayerEquip::EquipPlayer(CBaseEntity *pEntity)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
|
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
|
||||||
|
|
||||||
|
if (RemoveWeapons())
|
||||||
|
{
|
||||||
|
pPlayer->RemoveAllItems(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < MAX_EQUIP; i++)
|
for (int i = 0; i < MAX_EQUIP; i++)
|
||||||
{
|
{
|
||||||
if (FStringNull(m_weaponNames[i]))
|
if (FStringNull(m_weaponNames[i]))
|
||||||
|
@ -245,6 +245,7 @@ public:
|
|||||||
#define MAX_EQUIP 32
|
#define MAX_EQUIP 32
|
||||||
#define SF_PLAYEREQUIP_USEONLY BIT(0) // If set, the game_player_equip entity will not equip respawning players,
|
#define SF_PLAYEREQUIP_USEONLY BIT(0) // If set, the game_player_equip entity will not equip respawning players,
|
||||||
// but only react to direct triggering, equipping its activator. This makes its master obsolete.
|
// but only react to direct triggering, equipping its activator. This makes its master obsolete.
|
||||||
|
#define SF_PLAYEREQUIP_REMOVEWEAPONS BIT(1) // Remove all weapons before give.
|
||||||
|
|
||||||
// Sets the default player equipment
|
// Sets the default player equipment
|
||||||
class CGamePlayerEquip: public CRulePointEntity
|
class CGamePlayerEquip: public CRulePointEntity
|
||||||
@ -256,6 +257,18 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
bool UseOnly() const { return (pev->spawnflags & SF_PLAYEREQUIP_USEONLY) == SF_PLAYEREQUIP_USEONLY; }
|
bool UseOnly() const { return (pev->spawnflags & SF_PLAYEREQUIP_USEONLY) == SF_PLAYEREQUIP_USEONLY; }
|
||||||
|
bool RemoveWeapons() const { return (pev->spawnflags & SF_PLAYEREQUIP_REMOVEWEAPONS) == SF_PLAYEREQUIP_REMOVEWEAPONS; }
|
||||||
|
|
||||||
|
bool CanEquipOverTouch(CBaseEntity *pOther)
|
||||||
|
{
|
||||||
|
if (!CanFireForActivator(pOther))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (UseOnly())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void EquipPlayer(CBaseEntity *pPlayer);
|
void EquipPlayer(CBaseEntity *pPlayer);
|
||||||
|
@ -9889,13 +9889,20 @@ void EXT_FUNC CBasePlayer::__API_HOOK(OnSpawnEquip)(bool addDefault, bool equipG
|
|||||||
{
|
{
|
||||||
if (equipGame)
|
if (equipGame)
|
||||||
{
|
{
|
||||||
CBaseEntity *pWeaponEntity = nullptr;
|
CGamePlayerEquip *pWeaponEntity = nullptr;
|
||||||
while ((pWeaponEntity = UTIL_FindEntityByClassname(pWeaponEntity, "game_player_equip")))
|
while ((pWeaponEntity = UTIL_FindEntityByClassname(pWeaponEntity, "game_player_equip")))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef REGAMEDLL_FIXES
|
||||||
|
if (pWeaponEntity->CanEquipOverTouch(this))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
pWeaponEntity->Touch(this);
|
pWeaponEntity->Touch(this);
|
||||||
|
|
||||||
addDefault = false;
|
addDefault = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_bNotKilled)
|
if (m_bNotKilled)
|
||||||
addDefault = false;
|
addDefault = false;
|
||||||
|
@ -1407,6 +1407,7 @@
|
|||||||
spawnflags(flags) =
|
spawnflags(flags) =
|
||||||
[
|
[
|
||||||
1: "Use Only" : 0
|
1: "Use Only" : 0
|
||||||
|
2: "Remove Weapons" : 0
|
||||||
]
|
]
|
||||||
weapon_knife (choices) : "Give Knife" : 0 =
|
weapon_knife (choices) : "Give Knife" : 0 =
|
||||||
[
|
[
|
||||||
|
Loading…
x
Reference in New Issue
Block a user