OnItemDrop output for NPCs

This commit is contained in:
Blixibon 2021-09-24 13:18:04 -05:00
parent 256cdfb7af
commit 5998158ac2
3 changed files with 14 additions and 1 deletions

View File

@ -11576,6 +11576,10 @@ CBaseEntity *CAI_BaseNPC::DropItem ( const char *pszItemName, Vector vecPos, QAn
pItem->ApplyLocalAngularVelocityImpulse( AngularImpulse( 0, random->RandomFloat( 0, 100 ), 0 ) );
}
#ifdef MAPBASE
m_OnItemDrop.Set( pItem, pItem, this );
#endif
return pItem;
}
else
@ -11943,6 +11947,7 @@ BEGIN_DATADESC( CAI_BaseNPC )
DEFINE_OUTPUT( m_OnForcedInteractionFinished, "OnForcedInteractionFinished" ),
#ifdef MAPBASE
DEFINE_OUTPUT( m_OnItemPickup, "OnItemPickup" ),
DEFINE_OUTPUT( m_OnItemDrop, "OnItemDrop" ),
#endif
// Inputs

View File

@ -2119,6 +2119,7 @@ public:
COutputEHANDLE m_OnUnholsterWeapon;
COutputEHANDLE m_OnItemPickup;
COutputEHANDLE m_OnItemDrop;
COutputInt m_OnStateChange;
#endif

View File

@ -1788,7 +1788,14 @@ void CBaseCombatCharacter::Event_Killed( const CTakeDamageInfo &info )
// if flagged to drop a health kit
if (HasSpawnFlags(SF_NPC_DROP_HEALTHKIT))
{
CBaseEntity::Create( "item_healthvial", GetAbsOrigin(), GetAbsAngles() );
CBaseEntity *pItem = CBaseEntity::Create( "item_healthvial", GetAbsOrigin(), GetAbsAngles() );
if (pItem)
{
#ifdef MAPBASE
if (MyNPCPointer())
MyNPCPointer()->m_OnItemDrop.Set( pItem, pItem, this );
#endif
}
}
// clear the deceased's sound channels.(may have been firing or reloading when killed)
EmitSound( "BaseCombatCharacter.StopWeaponSounds" );