diff --git a/cl_dll/hl/hl_baseentity.cpp b/cl_dll/hl/hl_baseentity.cpp index 83bd279f..ae91a4d2 100644 --- a/cl_dll/hl/hl_baseentity.cpp +++ b/cl_dll/hl/hl_baseentity.cpp @@ -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; } @@ -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, diff --git a/dlls/CBaseEntity.cpp b/dlls/CBaseEntity.cpp index cf756315..1cab1b4a 100644 --- a/dlls/CBaseEntity.cpp +++ b/dlls/CBaseEntity.cpp @@ -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; } \ No newline at end of file diff --git a/dlls/CBasePlayer.cpp b/dlls/CBasePlayer.cpp index 2a5235c8..bcbd894e 100644 --- a/dlls/CBasePlayer.cpp +++ b/dlls/CBasePlayer.cpp @@ -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() ); @@ -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); diff --git a/dlls/cbase.h b/dlls/cbase.h index 52a82f83..0aa30d28 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -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; diff --git a/dlls/env/CBeam.h b/dlls/env/CBeam.h index f35ce514..aef9c6f1 100644 --- a/dlls/env/CBeam.h +++ b/dlls/env/CBeam.h @@ -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); diff --git a/dlls/item/CItem.cpp b/dlls/item/CItem.cpp index 249847ff..b54e8817 100644 --- a/dlls/item/CItem.cpp +++ b/dlls/item/CItem.cpp @@ -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); @@ -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; + } +} \ No newline at end of file diff --git a/dlls/item/CItem.h b/dlls/item/CItem.h index 3d3edc2f..c607ce3a 100644 --- a/dlls/item/CItem.h +++ b/dlls/item/CItem.h @@ -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; diff --git a/dlls/monster/CApache.cpp b/dlls/monster/CApache.cpp index ba3685ac..402960c2 100644 --- a/dlls/monster/CApache.cpp +++ b/dlls/monster/CApache.cpp @@ -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 ) { diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 669bf8c9..d439310e 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -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 diff --git a/dlls/weapon/CBasePlayerAmmo.cpp b/dlls/weapon/CBasePlayerAmmo.cpp index 3b029e67..9f2656fe 100644 --- a/dlls/weapon/CBasePlayerAmmo.cpp +++ b/dlls/weapon/CBasePlayerAmmo.cpp @@ -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; + } } \ No newline at end of file diff --git a/dlls/weapon/CBasePlayerAmmo.h b/dlls/weapon/CBasePlayerAmmo.h index a9a1c89f..1cd5de92 100644 --- a/dlls/weapon/CBasePlayerAmmo.h +++ b/dlls/weapon/CBasePlayerAmmo.h @@ -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 ); diff --git a/dlls/weapon/CBasePlayerItem.cpp b/dlls/weapon/CBasePlayerItem.cpp index df43fc8b..a5f51091 100644 --- a/dlls/weapon/CBasePlayerItem.cpp +++ b/dlls/weapon/CBasePlayerItem.cpp @@ -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 } @@ -291,16 +291,8 @@ 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); @@ -308,7 +300,7 @@ void CBasePlayerItem::DefaultUse(CBaseEntity* pActivator, CBaseEntity* pCaller, } int CBasePlayerItem::ObjectCaps() { - if (pev->movetype == MOVETYPE_FOLLOW) { + if (pev->effects == MOVETYPE_FOLLOW || (pev->effects & EF_NODRAW)) { return CBaseEntity::ObjectCaps(); } else { diff --git a/dlls/weapon/CWeaponBox.cpp b/dlls/weapon/CWeaponBox.cpp index fcec4785..08ba1be2 100644 --- a/dlls/weapon/CWeaponBox.cpp +++ b/dlls/weapon/CWeaponBox.cpp @@ -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); } }