Skip to content

Commit

Permalink
Add keyvalue to disable item dropping
Browse files Browse the repository at this point in the history
  • Loading branch information
hammermaps committed Apr 26, 2023
1 parent c33a834 commit c3ba605
Show file tree
Hide file tree
Showing 3 changed files with 5,406 additions and 5 deletions.
10 changes: 7 additions & 3 deletions dlls/basemonster.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class CBaseMonster : public CBaseToggle
float m_flWaitFinished;// if we're told to wait, this is the time that the wait will be over.
float m_flMoveWaitFinished;
float m_flLastYawTime;
bool m_AllowItemDropping = true;

Activity m_Activity;// what the monster is doing (animation)
Activity m_IdealActivity;// monster should switch to this activity
Expand Down Expand Up @@ -339,11 +340,14 @@ class CBaseMonster : public CBaseToggle
BOOL ExitScriptedSequence( );
BOOL CineCleanup( );

CBaseEntity* DropItem ( const char *pszItemName, const Vector &vecPos, const Vector &vecAng );// drop an item.
/**
* @brief Drop an item.
* Will return @c nullptr if item dropping is disabled for this NPC.
*/
CBaseEntity* DropItem(const char* pszItemName, const Vector& vecPos, const Vector& vecAng);

void StartPatrol( CBaseEntity *path );

CBaseEntity* DropItem ( char *pszItemName, const Vector &vecPos, const Vector &vecAng );// drop an item.

//LRC
float CalcRatio( CBaseEntity *pLocus )
{
Expand Down
13 changes: 11 additions & 2 deletions dlls/monsters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3016,6 +3016,10 @@ void CBaseMonster :: KeyValue( KeyValueData *pkvd )
m_iPlayerReact = atoi( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "allow_item_dropping"))
{
m_AllowItemDropping = atoi(pkvd->szValue) != 0;
}
else
{
CBaseToggle::KeyValue( pkvd );
Expand Down Expand Up @@ -3478,9 +3482,14 @@ CBaseEntity* CBaseMonster :: DropItem ( const char *pszItemName, const Vector &v
if ( !pszItemName )
{
ALERT ( at_console, "DropItem() - No item name!\n" );
return NULL;
return nullptr;
}


if (!m_AllowItemDropping)
{
return nullptr;
}

CBaseEntity *pItem = CBaseEntity::Create( pszItemName, vecPos, vecAng, edict() );

if ( pItem )
Expand Down
Loading

0 comments on commit c3ba605

Please sign in to comment.