void FireGameEvent_Internal( IGameEvent *event ) { if ( 0 == Q_strcmp( event->GetName(), "flare_ignite_npc" ) ) { CBaseEntity *pEntityIgnited = UTIL_EntityByIndex( event->GetInt( "entindex" ) ); // was it a zombie that got set on fire? if ( pEntityIgnited && ( ( pEntityIgnited->ClassMatches( "npc_zombie" ) ) || ( pEntityIgnited->ClassMatches( "npc_zombine" ) ) || ( pEntityIgnited->ClassMatches( "npc_fastzombie" ) ) || ( pEntityIgnited->ClassMatches( "npc_poisonzombie" ) ) ) ) { IncrementCount(); } } }
//----------------------------------------------------------------------------- // Purpose: // Output : Returns true on success, false on failure. // Notes : This behavior runs when I have an enemy that I fear, but who // does NOT hate or fear me (meaning they aren't going to fight me) //----------------------------------------------------------------------------- bool CAI_FearBehavior::CanSelectSchedule() { if( !GetOuter()->IsInterruptable() ) return false; if( m_flDeferUntil > gpGlobals->curtime ) return false; CBaseEntity *pEnemy = GetEnemy(); if( pEnemy == NULL ) return false; //if( !HasCondition(COND_SEE_PLAYER) ) // return false; if( !ai_enable_fear_behavior.GetBool() ) return false; if( GetOuter()->IRelationType(pEnemy) != D_FR ) return false; if( !pEnemy->ClassMatches("npc_hunter") ) return false; return true; }
virtual bool ShouldHitEntity( IHandleEntity *pServerEntity, int contentsMask ) { static const char *ppszIgnoredClasses[] = { "weapon_*", "item_*", "prop_ragdoll", "prop_dynamic", "prop_static", "prop_physics", "npc_bullseye", // Tracker 15335 }; CBaseEntity *pEntity = EntityFromEntityHandle( pServerEntity ); // Tracker 15335: Never impact decals against entities which are not rendering, either. if ( pEntity->IsEffectActive( EF_NODRAW ) ) return false; for ( int i = 0; i < ARRAYSIZE(ppszIgnoredClasses); i++ ) { if ( pEntity->ClassMatches( ppszIgnoredClasses[i] ) ) return false; } if ( modelinfo->GetModelType( pEntity->GetModel() ) != mod_brush ) return false; return CTraceFilterSimple::ShouldHitEntity( pServerEntity, contentsMask ); }
void FireGameEvent_Internal( IGameEvent *event ) { if ( 0 == Q_strcmp( event->GetName(), "physgun_pickup" ) ) { // was the object picked up a frag grenade? CBaseEntity *pEntityPickedUp = UTIL_EntityByIndex( event->GetInt( "entindex" ) ); if ( pEntityPickedUp && pEntityPickedUp->ClassMatches( "npc_grenade_frag" ) ) { // get the grenade object CBaseGrenade *pGrenade = dynamic_cast<CBaseGrenade *>( pEntityPickedUp ); if ( pGrenade ) { // was the original thrower a zombine? CBaseEntity *pOriginalThrower = pGrenade->GetOriginalThrower(); if ( pOriginalThrower && pOriginalThrower->ClassMatches( "npc_zombine" ) ) { IncrementCount(); } } } } }
//----------------------------------------------------------------------------- // Purpose: Iterates the entities with a given classname. // Input : pStartEntity - Last entity found, NULL to start a new iteration. // szName - Classname to search for. //----------------------------------------------------------------------------- CBaseEntity *CGlobalEntityList::FindEntityByClassname( CBaseEntity *pStartEntity, const char *szName ) { const CEntInfo *pInfo = pStartEntity ? GetEntInfoPtr( pStartEntity->GetRefEHandle() )->m_pNext : FirstEntInfo(); for ( ;pInfo; pInfo = pInfo->m_pNext ) { CBaseEntity *pEntity = (CBaseEntity *)pInfo->m_pEntity; if ( !pEntity ) { DevWarning( "NULL entity in global entity list!\n" ); continue; } if ( pEntity->ClassMatches(szName) ) return pEntity; } return NULL; }
//----------------------------------------------------------------------------- bool CTraceFilterNav::ShouldHitEntity( IHandleEntity *pHandleEntity, int contentsMask ) { IServerEntity *pServerEntity = (IServerEntity*)pHandleEntity; CBaseEntity *pEntity = (CBaseEntity *)pServerEntity; if ( m_pProber == pEntity ) return false; if ( m_pProber->GetMoveProbe()->ShouldBrushBeIgnored( pEntity ) == true ) return false; #ifdef HL1_DLL if ( ( contentsMask & CONTENTS_MOVEABLE ) == 0 ) { if ( pEntity->ClassMatches( "func_pushable" ) ) return false; } #endif if ( m_bIgnoreTransientEntities && (pEntity->IsPlayer() || pEntity->IsNPC() ) ) return false; //Adrian - If I'm flagged as using the new collision method, then ignore the player when trying //to check if I can get somewhere. if ( m_pProber->ShouldPlayerAvoid() && pEntity->IsPlayer() ) return false; if ( pEntity->IsNavIgnored() ) return false; if ( m_bCheckCollisionTable ) { if ( g_EntityCollisionHash->IsObjectPairInHash( m_pProber, pEntity ) ) return false; } if ( m_pProber->ShouldProbeCollideAgainstEntity( pEntity ) == false ) return false; return CTraceFilterSimple::ShouldHitEntity( pHandleEntity, contentsMask ); }
//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- void DynamicResupply_InitFromAlternateMaster( CBaseEntity *pTargetEnt, string_t iszMaster ) { if ( iszMaster== NULL_STRING ) { return; } CItem_DynamicResupply *pTargetResupply = assert_cast<CItem_DynamicResupply *>( pTargetEnt ); CBaseEntity *pMasterEnt = gEntList.FindEntityByName( NULL, iszMaster ); if ( !pMasterEnt || !pMasterEnt->ClassMatches( pTargetResupply->GetClassname() ) ) { DevWarning( "Invalid item_dynamic_resupply name %s\n", STRING( iszMaster ) ); return; } CItem_DynamicResupply *pMasterResupply = assert_cast<CItem_DynamicResupply *>( pMasterEnt ); pTargetResupply->RemoveSpawnFlags( SF_DYNAMICRESUPPLY_USE_MASTER ); memcpy( pTargetResupply->m_flDesiredHealth, pMasterResupply->m_flDesiredHealth, sizeof( pMasterResupply->m_flDesiredHealth ) ); memcpy( pTargetResupply->m_flDesiredAmmo, pMasterResupply->m_flDesiredAmmo, sizeof( pMasterResupply->m_flDesiredAmmo ) ); }
static void saveZonFile(const char* szMapName) { KeyValues* zoneKV = new KeyValues(szMapName); CBaseEntity* pEnt = gEntList.FindEntityByClassname(NULL, "trigger_momentum_*"); while (pEnt) { KeyValues* subKey = NULL; if (pEnt->ClassMatches("trigger_momentum_timer_start")) { CTriggerTimerStart* pTrigger = dynamic_cast<CTriggerTimerStart*>(pEnt); subKey = new KeyValues("start"); if (pTrigger) { subKey->SetFloat("leavespeed", pTrigger->GetMaxLeaveSpeed()); subKey->SetBool("limitingspeed", pTrigger->IsLimitingSpeed()); } } else if (pEnt->ClassMatches("trigger_momentum_timer_stop")) { subKey = new KeyValues("end"); } else if (pEnt->ClassMatches("trigger_momentum_timer_checkpoint")) { CTriggerCheckpoint* pTrigger = dynamic_cast<CTriggerCheckpoint*>(pEnt); if (pTrigger) { subKey = new KeyValues("checkpoint"); subKey->SetInt("number", pTrigger->GetCheckpointNumber()); } } else if (pEnt->ClassMatches("trigger_momentum_onehop")) { CTriggerOnehop* pTrigger = dynamic_cast<CTriggerOnehop*>(pEnt); if (pTrigger) { subKey = new KeyValues("onehop"); //subKey->SetInt("destination", pTrigger->GetDestinationIndex()); subKey->SetBool("stop", pTrigger->ShouldStopPlayer()); subKey->SetBool("resetang", pTrigger->ShouldResetAngles()); subKey->SetFloat("hold", pTrigger->GetHoldTeleportTime()); subKey->SetString("destinationname", pTrigger->m_target.ToCStr()); } } else if (pEnt->ClassMatches("trigger_momentum_resetonehop")) { subKey = new KeyValues("resetonehop"); } else if (pEnt->ClassMatches("trigger_momentum_teleport_checkpoint")) { CTriggerTeleportCheckpoint* pTrigger = dynamic_cast<CTriggerTeleportCheckpoint*>(pEnt); if (pTrigger) { subKey = new KeyValues("checkpoint_teleport"); //subKey->SetInt("destination", pTrigger->GetDestinationCheckpointNumber()); subKey->SetBool("stop", pTrigger->ShouldStopPlayer()); subKey->SetBool("resetang", pTrigger->ShouldResetAngles()); subKey->SetString("destinationname", pTrigger->m_target.ToCStr()); } } else if (pEnt->ClassMatches("trigger_momentum_multihop")) { CTriggerMultihop* pTrigger = dynamic_cast<CTriggerMultihop*>(pEnt); if (pTrigger) { subKey = new KeyValues("multihop"); //subKey->SetInt("destination", pTrigger->GetDestinationIndex()); subKey->SetBool("stop", pTrigger->ShouldStopPlayer()); subKey->SetFloat("hold", pTrigger->GetHoldTeleportTime()); subKey->SetBool("resetang", pTrigger->ShouldResetAngles()); subKey->SetString("destinationname", pTrigger->m_target.ToCStr()); } } else if (pEnt->ClassMatches("trigger_momentum_timer_stage")) { CTriggerStage *pTrigger = dynamic_cast<CTriggerStage*>(pEnt); if (pTrigger) { subKey = new KeyValues("stage"); subKey->SetInt("number", pTrigger->GetStageNumber()); } } if (subKey) { subKey->SetFloat("xPos", pEnt->GetAbsOrigin().x); subKey->SetFloat("yPos", pEnt->GetAbsOrigin().y); subKey->SetFloat("zPos", pEnt->GetAbsOrigin().z); subKey->SetFloat("xRot", pEnt->GetAbsAngles().x); subKey->SetFloat("yRot", pEnt->GetAbsAngles().y); subKey->SetFloat("zRot", pEnt->GetAbsAngles().z); subKey->SetFloat("xScaleMins", pEnt->WorldAlignMins().x); subKey->SetFloat("yScaleMins", pEnt->WorldAlignMins().y); subKey->SetFloat("zScaleMins", pEnt->WorldAlignMins().z); subKey->SetFloat("xScaleMaxs", pEnt->WorldAlignMaxs().x); subKey->SetFloat("yScaleMaxs", pEnt->WorldAlignMaxs().y); subKey->SetFloat("zScaleMaxs", pEnt->WorldAlignMaxs().z); zoneKV->AddSubKey(subKey); } pEnt = gEntList.FindEntityByClassname(pEnt, "trigger_momentum_*"); } if (zoneKV->GetFirstSubKey())//not empty { char zoneFilePath[MAX_PATH]; Q_strcpy(zoneFilePath, "maps/"); Q_strcat(zoneFilePath, szMapName, MAX_PATH); Q_strncat(zoneFilePath, ".zon", MAX_PATH); zoneKV->SaveToFile(filesystem, zoneFilePath, "MOD"); zoneKV->deleteThis(); } }