Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
- items being usable through walls
- kill feed icon/name changes
- some weapons still usable before respawning
- client build errors
  • Loading branch information
wootguy committed Oct 6, 2024
1 parent 76adfd4 commit 09adb6b
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 40 deletions.
4 changes: 4 additions & 0 deletions cl_dll/hl/hl_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ void CBasePlayerItem::Kill( void ) { }
void CBasePlayerItem::Holster( int skiplocal ) { }
void CBasePlayerItem::AttachToPlayer ( CBasePlayer *pPlayer ) { }
void CBasePlayerItem::KeyValue(KeyValueData* pkvd) {}
int CBasePlayerItem::ObjectCaps(void) { return 0; }
int CBasePlayerAmmo::ObjectCaps(void) { return 0; }
int CBasePlayerWeapon::AddDuplicate( CBasePlayerItem *pOriginal ) { return 0; }
int CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer ) { return FALSE; }
int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) { return 0; }
Expand All @@ -368,6 +370,8 @@ CBaseEntity* CBasePlayerWeapon::Respawn() { return NULL; }
const char* CBasePlayerWeapon::GetModelV() { return 0; }
const char* CBasePlayerWeapon::GetModelP() { return 0; }
const char* CBasePlayerWeapon::GetModelW() { return 0; }
void CBasePlayerWeapon::SetWeaponModelW() { }
void CGrenade::SetGrenadeModel() { }
void CSoundEnt::InsertSound ( int iType, const Vector &vecOrigin, int iVolume, float flDuration ) {}
void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType ){}
void StartSound(edict_t* entity, int channel, const char* sample, float volume, float attenuation,
Expand Down
10 changes: 10 additions & 0 deletions dlls/CBaseEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -976,4 +976,14 @@ bool CBaseEntity::ShouldBlockFriendlyFire(entvars_t* attacker) {
}

return false;
}

bool CBaseEntity::CanReach(CBaseEntity* toucher) {
TraceResult tr;
TRACE_LINE(toucher->pev->origin + toucher->pev->view_ofs, pev->origin, dont_ignore_monsters, toucher->edict(), &tr);

bool hitItemSurface = tr.pHit && tr.pHit == edict();
bool enteredItemBox = boxesIntersect(pev->absmin, pev->absmax, tr.vecEndPos, tr.vecEndPos);

return hitItemSurface || enteredItemBox;
}
5 changes: 3 additions & 2 deletions dlls/CBasePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2004,6 +2004,8 @@ void CBasePlayer::UpdateStatusBar()
{
CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );

bool ignoreMonster = FClassnameIs(pEntity->pev, "monster_furniture");

if (pEntity->Classify() == CLASS_PLAYER )
{
newSBarState[ SBAR_ID_TARGETNAME ] = ENTINDEX( pEntity->edict() );
Expand All @@ -2015,8 +2017,7 @@ void CBasePlayer::UpdateStatusBar()

m_flStatusBarDisappearDelay = gpGlobals->time + 1.0;
}
else if (pEntity->IsMonster() && pEntity->IsAlive()) {

else if (pEntity->IsMonster() && pEntity->IsAlive() && !ignoreMonster) {
name = replaceString(pEntity->DisplayName(), "\n", " ");
int hp = roundf(pEntity->pev->health);

Expand Down
4 changes: 4 additions & 0 deletions dlls/cbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ class EXPORT CBaseEntity
static int IRelationship(int attackerClass, int victimClass);
bool ShouldBlockFriendlyFire(entvars_t* attacker);

// can the player using this entity physically touch the ent with their hand?
// or is there something in the way? (player use code assumes arms have noclip)
bool CanReach(CBaseEntity* toucher);

//We use this variables to store each ammo count.
int ammo_9mm;
int ammo_357;
Expand Down
1 change: 1 addition & 0 deletions dlls/env/CBeam.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class CBeam : public CBaseEntity
flags = FCAP_DONT_SAVE;
return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags;
}
virtual const char* DisplayName() { return "Laser"; }

void EXPORT TriggerTouch(CBaseEntity* pOther);

Expand Down
21 changes: 11 additions & 10 deletions dlls/item/CItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,8 @@ void CItem::ItemUse(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useT
{
if (pCaller && pCaller->IsPlayer()) {

if (!(pev->spawnflags & SF_ITEM_USE_WITHOUT_LOS)) {
TraceResult tr;
TRACE_LINE(pCaller->pev->origin + pCaller->pev->view_ofs, pev->origin, dont_ignore_monsters, pCaller->edict(), &tr);

bool hitItemSurface = tr.pHit && tr.pHit != edict();
bool enteredItemBox = boxesIntersect(pev->absmin, pev->absmax, tr.vecEndPos, tr.vecEndPos);
if (!hitItemSurface && !enteredItemBox) {
ALERT(at_console, "Can't use item not in LOS\n");
return;
}
if (!(pev->spawnflags & SF_ITEM_USE_WITHOUT_LOS) && !CanReach(pCaller)) {
return;
}

ItemTouch(pCaller);
Expand Down Expand Up @@ -195,3 +187,12 @@ const char* CItem::GetModel() {

return mp_mergemodels.value && MergedModelBody() != -1 ? MERGED_ITEMS_MODEL : m_defaultModel;
}

int CItem::ObjectCaps(void) {
if (pev->effects & EF_NODRAW) {
return CBaseEntity::ObjectCaps();
}
else {
return FCAP_ACROSS_TRANSITION | FCAP_IMPULSE_USE;
}
}
2 changes: 1 addition & 1 deletion dlls/item/CItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class EXPORT CItem : public CBaseAnimating
void SetSize(Vector defaultMins, Vector defaultMaxs);
void SetItemModel();
virtual int MergedModelBody() { return -1; }
virtual int ObjectCaps(void) { return FCAP_ACROSS_TRANSITION | FCAP_IMPULSE_USE; }
virtual int ObjectCaps(void);

const char* m_defaultModel;
string_t m_sequence_name;
Expand Down
4 changes: 3 additions & 1 deletion dlls/monster/CApache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class CApache : public CBaseMonster
int BloodColor( void ) { return DONT_BLEED; }
void Killed( entvars_t *pevAttacker, int iGib );
void GibMonster( void );
const char* GetDeathNoticeWeapon() { return "weapon_9mmAR"; }

// when crashing, show an explosion kill icon
const char* GetDeathNoticeWeapon() { return IsAlive() ? "weapon_9mmAR" : "grenade"; }

void SetObjectCollisionBox( void )
{
Expand Down
4 changes: 2 additions & 2 deletions dlls/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,8 @@ void CHalfLifeMultiplay::DeathNotice( CBaseMonster *pVictim, entvars_t *pKiller,
killerName = "Mortar";
}
else if (pVictim->m_lastDamageType & DMG_BLAST) {
if (pVictim->IsBreakable()) {
killerName = "Explosion";
if (Killer->IsBreakable()) {
killerName = "Explosives";
}
//killerName = "Explosion";
// entity name should be better
Expand Down
21 changes: 11 additions & 10 deletions dlls/weapon/CBasePlayerAmmo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,19 @@ void CBasePlayerAmmo::DefaultUse(CBaseEntity* pActivator, CBaseEntity* pCaller,
{
if (pCaller && pCaller->IsPlayer()) {

if (!(pev->spawnflags & SF_ITEM_USE_WITHOUT_LOS)) {
TraceResult tr;
TRACE_LINE(pCaller->pev->origin + pCaller->pev->view_ofs, pev->origin, dont_ignore_monsters, pCaller->edict(), &tr);

bool hitItemSurface = tr.pHit && tr.pHit != edict();
bool enteredItemBox = boxesIntersect(pev->absmin, pev->absmax, tr.vecEndPos, tr.vecEndPos);
if (!hitItemSurface && !enteredItemBox) {
ALERT(at_console, "Can't use item not in LOS\n");
return;
}
if (!(pev->spawnflags & SF_ITEM_USE_WITHOUT_LOS) && !CanReach(pCaller)) {
return;
}

DefaultTouch(pCaller);
}
}

int CBasePlayerAmmo::ObjectCaps(void) {
if (pev->effects & EF_NODRAW) {
return CBaseEntity::ObjectCaps();
}
else {
return FCAP_ACROSS_TRANSITION | FCAP_IMPULSE_USE;
}
}
2 changes: 1 addition & 1 deletion dlls/weapon/CBasePlayerAmmo.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class EXPORT CBasePlayerAmmo : public CBaseEntity
void DefaultTouch( CBaseEntity *pOther ); // default weapon touch
void DefaultUse(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useType, float value);
virtual BOOL AddAmmo( CBaseEntity *pOther ) { return TRUE; };
virtual int ObjectCaps(void) { return FCAP_ACROSS_TRANSITION | FCAP_IMPULSE_USE; }
virtual int ObjectCaps(void);

CBaseEntity* Respawn( void );
void Materialize( void );
Expand Down
16 changes: 4 additions & 12 deletions dlls/weapon/CBasePlayerItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void CBasePlayerItem::DefaultTouch(CBaseEntity* pOther)
if (!pOther->IsPlayer())
return;

if (pev->movetype == MOVETYPE_FOLLOW || m_hPlayer) {
if (pev->movetype == MOVETYPE_FOLLOW || m_hPlayer || (pev->effects & EF_NODRAW)) {
return; // attached to a player
}

Expand Down Expand Up @@ -291,24 +291,16 @@ void CBasePlayerItem::DefaultUse(CBaseEntity* pActivator, CBaseEntity* pCaller,
{
if (pCaller && pCaller->IsPlayer()) {

if (!(pev->spawnflags & SF_ITEM_USE_WITHOUT_LOS)) {
TraceResult tr;
TRACE_LINE(pCaller->pev->origin + pCaller->pev->view_ofs, pev->origin, dont_ignore_monsters, pCaller->edict(), &tr);

bool hitItemSurface = tr.pHit && tr.pHit != edict();
bool enteredItemBox = boxesIntersect(pev->absmin, pev->absmax, tr.vecEndPos, tr.vecEndPos);
if (!hitItemSurface && !enteredItemBox) {
ALERT(at_console, "Can't use item not in LOS\n");
return;
}
if (!(pev->spawnflags & SF_ITEM_USE_WITHOUT_LOS) && !CanReach(pCaller)) {
return;
}

DefaultTouch(pCaller);
}
}

int CBasePlayerItem::ObjectCaps() {
if (pev->movetype == MOVETYPE_FOLLOW) {
if (pev->effects == MOVETYPE_FOLLOW || (pev->effects & EF_NODRAW)) {
return CBaseEntity::ObjectCaps();
}
else {
Expand Down
2 changes: 1 addition & 1 deletion dlls/weapon/CWeaponBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void CWeaponBox::Touch(CBaseEntity* pOther)

void CWeaponBox::Use(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useType, float value)
{
if (pCaller && pCaller->IsPlayer()) {
if (pCaller && pCaller->IsPlayer() && CanReach(pCaller)) {
Touch(pCaller);
}
}
Expand Down

0 comments on commit 09adb6b

Please sign in to comment.