//========================================================= // Crea un NPC Grunt. //========================================================= CAI_BaseNPC *CSurvivalZombieSpawn::MakeGrunt() { // Desactivado if ( Disabled || !sv_spawn_zombies.GetBool() ) return NULL; CAI_BaseNPC *pGrunt = (CAI_BaseNPC *)CreateEntityByName("npc_grunt"); // Ocurrio algún problema. if ( !pGrunt ) { Warning("[SURVIVAL ZOMBIE MAKER] Ha ocurrido un problema al intentar crear un grunt. \r\n"); return NULL; } Vector origin; if ( !CanMakeNPC(pGrunt, &origin) ) return NULL; // Lugar de creación. pGrunt->SetAbsOrigin(origin); // Nombre del Grunt. // [¡NO CAMBIAR!] Es utilizado por otras entidades para referirse a los zombis creados por esta entidad. pGrunt->SetName(MAKE_STRING("survival_grunt")); QAngle angles = GetAbsAngles(); angles.x = 0.0; angles.z = 0.0; pGrunt->SetAbsAngles(angles); // Tiene que caer al suelo. pGrunt->AddSpawnFlags(SF_NPC_FALL_TO_GROUND); // Creamos al grunt, le decimos quien es su dios (creador) y lo activamos. DispatchSpawn(pGrunt); pGrunt->SetOwnerEntity(this); DispatchActivate(pGrunt); // Ahora creamos la música. pGruntMusic = (CEnvSound *)CreateEntityByName("env_sound"); pGruntMusic->SetSourceEntityName(MAKE_STRING("survival_grunt")); pGruntMusic->SetSoundName(MAKE_STRING("NPC_Grunt.BackgroundMusic")); pGruntMusic->SetRadius(8000.0); pGruntMusic->SetAbsOrigin(origin); DispatchSpawn(pGruntMusic); pGruntMusic->SetOwnerEntity(this); DispatchActivate(pGruntMusic); pGruntMusic->SetPitch(100); pGruntMusic->SetVolume(1); pGruntMusic->PlayManual(1, 100); return pGrunt; }
//------------------------------------------------------------------------------ // Purpose: Create an NPC of the given type //------------------------------------------------------------------------------ void CC_ASW_Ent_Create( const CCommand& args ) { MDLCACHE_CRITICAL_SECTION(); bool allowPrecache = CBaseEntity::IsPrecacheAllowed(); CBaseEntity::SetAllowPrecache( true ); // Try to create entity CBaseEntity *entity = dynamic_cast< CBaseEntity * >( CreateEntityByName(args[1]) ); if (entity) { entity->Precache(); // Now attempt to drop into the world CASW_Player* pPlayer = ToASW_Player( UTIL_GetCommandClient() ); if (!pPlayer) return; trace_t tr; UTIL_TraceLine( pPlayer->GetCrosshairTracePos() + Vector( 0, 0, 30 ), pPlayer->GetCrosshairTracePos(), MASK_SOLID, pPlayer, COLLISION_GROUP_NONE, &tr ); if ( tr.fraction != 0.0 ) { // Raise the end position a little up off the floor, place the npc and drop him down tr.endpos.z += 12; entity->Teleport( &tr.endpos, NULL, NULL ); // this was causing aliens to spawn under ground //UTIL_DropToFloor( entity, MASK_SOLID ); } DispatchSpawn(entity); } CBaseEntity::SetAllowPrecache( allowPrecache ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CAntlionGrub::CreateNugget( void ) { CGrubNugget *pNugget = (CGrubNugget *) CreateEntityByName( "item_grubnugget" ); if ( pNugget == NULL ) return; Vector vecOrigin; Vector vecForward; GetAttachment( LookupAttachment( "glow" ), vecOrigin, &vecForward ); // Find out what size to make this nugget! int nDenomination = GetNuggetDenomination(); pNugget->SetDenomination( nDenomination ); pNugget->SetAbsOrigin( vecOrigin ); pNugget->SetAbsAngles( RandomAngle( 0, 360 ) ); DispatchSpawn( pNugget ); IPhysicsObject *pPhys = pNugget->VPhysicsGetObject(); if ( pPhys ) { Vector vecForward; GetVectors( &vecForward, NULL, NULL ); Vector vecVelocity = RandomVector( -35.0f, 35.0f ) + ( vecForward * -RandomFloat( 50.0f, 75.0f ) ); AngularImpulse vecAngImpulse = RandomAngularImpulse( -100.0f, 100.0f ); pPhys->AddVelocity( &vecVelocity, &vecAngImpulse ); } }
CBaseEntity * CEntHost::GiveNamedItem( const char * szName, int iSubType, bool removeIfNotCarried ) { // If I already own this type don't create one if ( GetHost()->Weapon_OwnsThisType( szName, iSubType ) ) return NULL; CBaseEntity *pEntity = CreateEntityByName( szName ); if ( !pEntity ) { Msg( "NULL Ent in GiveNamedItem!\n" ); return NULL; } pEntity->SetLocalOrigin( GetLocalOrigin() ); pEntity->AddSpawnFlags( SF_NORESPAWN ); CBaseCombatWeapon *pWeapon = dynamic_cast<CBaseCombatWeapon *>(pEntity); DispatchSpawn( pEntity ); if ( pWeapon ) { pWeapon->SetSubType( iSubType ); GetHost()->Weapon_Equip( pWeapon ); } else { if ( pEntity && !(pEntity->IsMarkedForDeletion()) ) { pEntity->Touch( GetHost() ); } } return pEntity; }
void CEntHost::CreateViewModel( int index ) { Assert( IsPlayer() ); Assert( index >= 0 && index < MAX_VIEWMODELS ); if ( !IsPlayer() ) return; if ( GetPlayer()->GetViewModel( index ) ) return; CPredictedViewModel *vm = (CPredictedViewModel *)CreateEntityByName( "predicted_viewmodel" ); if ( vm ) { vm->SetAbsOrigin( GetAbsOrigin() ); vm->SetOwner( GetPlayer() ); vm->SetIndex( index ); DispatchSpawn( vm ); vm->FollowEntity( GetPlayer(), false ); vm->AddEffects( EF_NODRAW ); GetPlayer()->m_hViewModel.Set( index, vm ); } }
CBaseEntity *CreateServerStatueFromOBBs( const CUtlVector<outer_collision_obb_t> &vecSphereOrigins, CBaseAnimating *pAnimating ) { Assert( vecSphereOrigins.Count() > 0 ); if ( vecSphereOrigins.Count() <= 0 ) return NULL; CStatueProp *pStatue = static_cast<CStatueProp *>( CreateEntityByName( "physics_prop_statue" ) ); if ( pStatue ) { pStatue->m_pInitOBBs = &vecSphereOrigins; pStatue->m_hInitBaseAnimating = pAnimating; pStatue->SetModelName( pAnimating->GetModelName() ); pStatue->SetAbsOrigin( pAnimating->GetAbsOrigin() ); pStatue->SetAbsAngles( pAnimating->GetAbsAngles() ); DispatchSpawn( pStatue ); pStatue->Activate(); pStatue->AddEffects( EF_NODRAW ); pStatue->CollisionProp()->SetSurroundingBoundsType( USE_GAME_CODE ); pStatue->AddSolidFlags( ( pAnimating->GetSolidFlags() & FSOLID_CUSTOMBOXTEST ) | ( pAnimating->GetSolidFlags() & FSOLID_CUSTOMRAYTEST ) ); pAnimating->SetParent( pStatue ); // You'll need to keep track of the child for collision rules pStatue->SetThink( &CStatueProp::CollisionPartnerThink ); pStatue->SetNextThink( gpGlobals->curtime + 1.0f ); } return pStatue; }
//------------------------------------------------------------------------------ // Purpose : // Input : // Output : //------------------------------------------------------------------------------ CAI_Hint* CAI_HintManager::CreateHint( HintNodeData *pNodeData, const char *pMapData ) { // Reset last found hint if new node is added CAI_HintManager::ResetFoundHints(); CAI_Hint *pHint = (CAI_Hint*)CreateEntityByName("ai_hint"); if ( pHint ) { // First, parse the mapdata chunk we were passed if ( pMapData ) { CEntityMapData entData( (char*)pMapData ); pHint->ParseMapData( &entData ); // Restore the desired classname (parsing the mapdata stomps it) pHint->SetClassname( "ai_hint" ); } pHint->SetName( pNodeData->strEntityName ); pHint->SetAbsOrigin( pNodeData->vecPosition ); memcpy( &(pHint->m_NodeData), pNodeData, sizeof(HintNodeData) ); DispatchSpawn( pHint ); return pHint; } return NULL; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- CTFGrenadePipebombProjectile* CTFGrenadePipebombProjectile::Create( const Vector &position, const QAngle &angles, const Vector &velocity, const AngularImpulse &angVelocity, CBaseCombatCharacter *pOwner, const CTFWeaponInfo &weaponInfo, bool bRemoteDetonate ) { CTFGrenadePipebombProjectile *pGrenade = static_cast<CTFGrenadePipebombProjectile*>( CBaseEntity::CreateNoSpawn( bRemoteDetonate ? "tf_projectile_pipe_remote" : "tf_projectile_pipe", position, angles, pOwner ) ); if ( pGrenade ) { // Set the pipebomb mode before calling spawn, so the model & associated vphysics get setup properly pGrenade->SetPipebombMode( bRemoteDetonate ); DispatchSpawn( pGrenade ); pGrenade->InitGrenade( velocity, angVelocity, pOwner, weaponInfo ); #ifdef _X360 if ( pGrenade->m_iType != TF_GL_MODE_REMOTE_DETONATE ) { pGrenade->SetDamage( TF_WEAPON_GRENADE_XBOX_DAMAGE ); } #endif pGrenade->m_flFullDamage = pGrenade->GetDamage(); if ( pGrenade->m_iType != TF_GL_MODE_REMOTE_DETONATE ) { // Some hackery here. Reduce the damage by 25%, so that if we explode on timeout, // we'll do less damage. If we explode on contact, we'll restore this to full damage. pGrenade->SetDamage( pGrenade->GetDamage() * TF_WEAPON_PIPEBOMB_TIMER_DMG_REDUCTION ); } pGrenade->ApplyLocalAngularVelocityImpulse( angVelocity ); } return pGrenade; }
//----------------------------------------------------------------------------- // Purpose: Spawn //----------------------------------------------------------------------------- void CGrappleHook::Spawn(void) { Precache(); SetModel(HOOK_MODEL); SetMoveType(MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_CUSTOM); UTIL_SetSize(this, -Vector(1, 1, 1), Vector(1, 1, 1)); SetSolid(SOLID_BBOX); SetGravity(0.05f); // The rock is invisible, the crossbow bolt is the visual representation AddEffects(EF_NODRAW); // Make sure we're updated if we're underwater UpdateWaterState(); SetTouch(&CGrappleHook::HookTouch); SetThink(&CGrappleHook::FlyThink); SetNextThink(gpGlobals->curtime + 0.1f); //m_pSpring = NULL; m_fSpringLength = 0.0f; m_bPlayerWasStanding = false; // Create bolt model and parent it CBaseEntity *pBolt = CBaseEntity::CreateNoSpawn("prop_dynamic", GetAbsOrigin(), GetAbsAngles(), this); pBolt->SetModelName(MAKE_STRING(BOLT_MODEL)); pBolt->SetModel(BOLT_MODEL); DispatchSpawn(pBolt); pBolt->SetParent(this); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponStriderBuster::Spawn( void ) { SetModelName( AllocPooledString("models/magnusson_device.mdl") ); BaseClass::Spawn(); // Setup for being shot by the player m_takedamage = DAMAGE_EVENTS_ONLY; // Ignore touches until launched. SetTouch ( NULL ); AddFlag( FL_AIMTARGET|FL_OBJECT ); m_hParticleEffect = CreateEntityByName( "info_particle_system" ); if ( m_hParticleEffect ) { m_hParticleEffect->KeyValue( "start_active", "1" ); m_hParticleEffect->KeyValue( "effect_name", "striderbuster_smoke" ); DispatchSpawn( m_hParticleEffect ); if ( gpGlobals->curtime > 0.2f ) { m_hParticleEffect->Activate(); } m_hParticleEffect->SetAbsOrigin( GetAbsOrigin() ); m_hParticleEffect->SetParent( this ); } SetHealth( striderbuster_health.GetFloat() ); SetNextThink(gpGlobals->curtime + 0.01f); }
void CGstringInteraction::InputStartInteraction( inputdata_t &inputdata ) { if ( m_bInteractionActive ) { Warning( "Can't start interaction while there is one active!\n" ); return; } if ( m_hInteractiveObject.Get() == NULL ) { Warning( "Interaction entity has no interactive object assigned!\n" ); return; } if ( !inputdata.pActivator->IsPlayer() ) { Warning( "Interaction must be triggered by a player.\n" ); return; } CDynamicProp *pInteractiveObject = dynamic_cast< CDynamicProp* >( m_hInteractiveObject.Get() ); if ( pInteractiveObject != NULL ) { pInteractiveObject->SetInteractionEntity( this ); inputdata_t data; data.value.SetString( m_strObjectSequenceName ); pInteractiveObject->InputSetAnimation( data ); pInteractiveObject->SetNextThink( gpGlobals->curtime + 0.1f ); } else { Warning( "Interaction entity must be a prop_dynamic!\n" ); return; } CGstringInteractionBody *pFirstpersonBody = assert_cast< CGstringInteractionBody* >( CreateEntityByName( "gstring_interaction_body" ) ); Assert( pFirstpersonBody ); pFirstpersonBody->SetAbsOrigin( pInteractiveObject->GetAbsOrigin() ); pFirstpersonBody->SetAbsAngles( pInteractiveObject->GetAbsAngles() ); pFirstpersonBody->SetModel( FIRSTPERSON_BODY_MODEL ); DispatchSpawn( pFirstpersonBody ); const int iPlayerSequence = pFirstpersonBody->LookupSequence( m_strPlayerSequenceName.ToCStr() ); if ( iPlayerSequence >= 0 ) { pFirstpersonBody->ResetSequence( iPlayerSequence ); } CGstringPlayer *pPlayer = assert_cast< CGstringPlayer* >( inputdata.pActivator ); pPlayer->BeginInteraction( pFirstpersonBody ); m_hPlayer.Set( pPlayer ); pFirstpersonBody->SetInteractionEntity( this ); m_bInteractionActive = true; m_InteractionStartEvent.FireOutput( inputdata.pActivator, inputdata.pCaller ); }
//========================================================= // Crea un Jefe. //========================================================= CAI_BaseNPC *CDirectorSpawn::MakeBoss() { // Desactivado if ( Disabled ) return NULL; // Seleccionamos una clase de NPC para crear. const char *pClass = SelectRandomBoss(); CAI_BaseNPC *pNPC = VerifyClass(pClass); // Ocurrio algún problema. if ( !pNPC ) { Warning("[DIRECTOR SPAWN] Ha ocurrido un problema al intentar crear un Jefe. \r\n"); return NULL; } Vector origin; // Verificamos si podemos crear el Grunt en el radio. if ( !CanMakeNPC(pNPC, &origin) ) return NULL; // Lugar de creación. pNPC->SetAbsOrigin(origin); // Nombre del Jefe. pNPC->SetName(MAKE_STRING(BOSS_NAME)); QAngle angles = GetAbsAngles(); angles.x = 0.0; angles.z = 0.0; pNPC->SetAbsAngles(angles); // Tiene que caer al suelo. pNPC->AddSpawnFlags(SF_NPC_FALL_TO_GROUND); // Creamos al Jefe, le decimos quien es su dios (creador) y lo activamos. DispatchSpawn(pNPC); pNPC->SetOwnerEntity(this); DispatchActivate(pNPC); // Al parecer se atoro en una pared. if ( !PostSpawn(pNPC) ) return NULL; // Debe conocer la ubicación del jugador (Su enemigo) CIN_Player *pPlayer = UTIL_GetRandomInPlayer(); if ( pPlayer ) { // Ataca al jugador YA pNPC->SetEnemy(pPlayer); pNPC->UpdateEnemyMemory(pPlayer, pPlayer->GetAbsOrigin()); } return pNPC; }
void SpawnAllEntities( int nEntities, HierarchicalSpawn_t *pSpawnList, bool bActivateEntities ) { int nEntity; for (nEntity = 0; nEntity < nEntities; nEntity++) { VPROF( "MapEntity_ParseAllEntities_Spawn"); CBaseEntity *pEntity = pSpawnList[nEntity].m_pEntity; if ( pSpawnList[nEntity].m_pDeferredParent ) { // UNDONE: Promote this up to the root of this function? MDLCACHE_CRITICAL_SECTION(); CBaseEntity *pParent = pSpawnList[nEntity].m_pDeferredParent; int iAttachment = -1; CBaseAnimating *pAnim = pParent->GetBaseAnimating(); if ( pAnim ) { iAttachment = pAnim->LookupAttachment(pSpawnList[nEntity].m_pDeferredParentAttachment); } pEntity->SetParent( pParent, iAttachment ); } if ( pEntity ) { if (DispatchSpawn(pEntity) < 0) { for ( int i = nEntity+1; i < nEntities; i++ ) { // this is a child object that will be deleted now if ( pSpawnList[i].m_pEntity && pSpawnList[i].m_pEntity->IsMarkedForDeletion() ) { pSpawnList[i].m_pEntity = NULL; } } // Spawn failed. gEntList.CleanupDeleteList(); // Remove the entity from the spawn list pSpawnList[nEntity].m_pEntity = NULL; } } } if ( bActivateEntities ) { VPROF( "MapEntity_ParseAllEntities_Activate"); bool bAsyncAnims = mdlcache->SetAsyncLoad( MDLCACHE_ANIMBLOCK, false ); for (nEntity = 0; nEntity < nEntities; nEntity++) { CBaseEntity *pEntity = pSpawnList[nEntity].m_pEntity; if ( pEntity ) { MDLCACHE_CRITICAL_SECTION(); pEntity->Activate(); } } mdlcache->SetAsyncLoad( MDLCACHE_ANIMBLOCK, bAsyncAnims ); } }
virtual void FrameUpdatePostEntityThink( void ) { // Wait until we're all spawned in if ( gpGlobals->curtime < 5 ) return; if ( m_bIssuedNextMapCommand ) return; if ( !m_bParsedMapFile ) { m_bParsedMapFile = true; // See if we've got a camera file to import cameras from char szFullName[512]; Q_snprintf(szFullName,sizeof(szFullName), "maps/%s.txt", STRING( gpGlobals->mapname )); KeyValues *pkvMapCameras = new KeyValues( "MapCameras" ); if ( pkvMapCameras->LoadFromFile( filesystem, szFullName, "MOD" ) ) { Warning( "Devshots: Loading point_devshot_camera positions from %s. \n", szFullName ); // Get each camera, and add it to our list KeyValues *pkvCamera = pkvMapCameras->GetFirstSubKey(); while ( pkvCamera ) { // Get camera name const char *pCameraName = pkvCamera->GetName(); // Make a camera, and move it to the position specified CPointDevShotCamera *pCamera = (CPointDevShotCamera*)CreateEntityByName( "point_devshot_camera" ); Assert( pCamera ); pCamera->KeyValue( "cameraname", pCameraName ); pCamera->KeyValue( "origin", pkvCamera->GetString( "origin", "0 0 0" ) ); pCamera->KeyValue( "angles", pkvCamera->GetString( "angles", "0 0 0" ) ); pCamera->KeyValue( "FOV", pkvCamera->GetString( "FOV", "75" ) ); DispatchSpawn( pCamera ); pCamera->Activate(); // Move to next camera pkvCamera = pkvCamera->GetNextKey(); } } if ( !g_iDevShotCameraCount ) { Warning( "Devshots: No point_devshot_camera in %s. Moving to next map.\n", STRING( gpGlobals->mapname ) ); CBasePlayer *pPlayer = UTIL_GetLocalPlayerOrListenServerHost(); if ( pPlayer ) { engine->ClientCommand( pPlayer->edict(), "devshots_nextmap" ); m_bIssuedNextMapCommand = true; return; } } } }
//------------------------------------------------------------------------------ // Display the hull type of the specified NPC. //------------------------------------------------------------------------------ void CC_AI_Hull( const CCommand &args ) { if ( !g_pAINetworkManager ) return; bool bSpawned = false; CBaseEntity *pEnt = NULL; if ( !args[1] || !args[1][0] ) { // No arg means the entity under the crosshair. pEnt = FindPickerEntity( UTIL_GetCommandClient() ); if ( !pEnt ) { DevMsg( "No entity under the crosshair.\n" ); return; } } else { // Find the entity specified on the command line. pEnt = gEntList.FindEntityGeneric( NULL, args[1] ); if ( !pEnt ) { // Not found, try to create one. pEnt = (CAI_BaseNPC *)CreateEntityByName( args[1] ); if ( !pEnt ) { DevMsg( "Entity %s not found, and couldn't create!\n", args[1] ); return; } bSpawned = true; DispatchSpawn( pEnt ); } } CAI_BaseNPC *pNPC = dynamic_cast<CAI_BaseNPC *>( pEnt ); if ( !pNPC ) { DevMsg( "Entity %s is not an NPC.\n", pEnt->GetDebugName() ); return; } Hull_t eHull = pNPC->GetHullType(); if ( bSpawned ) { UTIL_Remove( pEnt ); } g_pAINetworkManager->GetEditOps()->DrawHull( eHull ); CBaseEntity::m_nDebugPlayer = UTIL_GetCommandClientIndex(); }
//----------------------------------------------------------------------------- // Purpose: Place NPC somewhere on the perimeter of my radius. //----------------------------------------------------------------------------- void CTemplateNPCMaker::MakeNPCInRadius( void ) { if ( !CanMakeNPC(true)) return; CAI_BaseNPC *pent = NULL; CBaseEntity *pEntity = NULL; MapEntity_ParseEntity( pEntity, STRING(m_iszTemplateData), NULL ); if ( pEntity != NULL ) { pent = (CAI_BaseNPC *)pEntity; } if ( !pent ) { Warning("NULL Ent in NPCMaker!\n" ); return; } if ( !PlaceNPCInRadius( pent ) ) { // Failed to place the NPC. Abort UTIL_RemoveImmediate( pent ); return; } m_OnSpawnNPC.Set( pEntity, pEntity, this ); pent->AddSpawnFlags( SF_NPC_FALL_TO_GROUND ); pent->RemoveSpawnFlags( SF_NPC_TEMPLATE ); ChildPreSpawn( pent ); DispatchSpawn( pent ); pent->SetOwnerEntity( this ); DispatchActivate( pent ); ChildPostSpawn( pent ); m_nLiveChildren++;// count this NPC if (!(m_spawnflags & SF_NPCMAKER_INF_CHILD)) { m_nMaxNumNPCs--; if ( IsDepleted() ) { m_OnAllSpawned.FireOutput( this, this ); // Disable this forever. Don't kill it because it still gets death notices SetThink( NULL ); SetUse( NULL ); } } }
void CreateWeaponManager( const char *pWeaponName, int iMaxPieces ) { CGameWeaponManager *pManager = (CGameWeaponManager *)CreateEntityByName( "game_weapon_manager"); if( pManager ) { pManager->m_iszWeaponName = MAKE_STRING( pWeaponName ); pManager->m_iMaxPieces = iMaxPieces; DispatchSpawn( pManager ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CNPC_CombineAce::SpawnArmorPieces(void) { pArmor = (CArmorPiece *)CBaseEntity::CreateNoSpawn("combine_armor_piece", GetAbsOrigin(), GetAbsAngles(), this); pArmor->SetModelName(MAKE_STRING("models/armor/shield.mdl")); pArmor->SetParent(this, LookupAttachment("shield_attach")); pArmor->SetLocalOrigin(vec3_origin); pArmor->SetLocalAngles(vec3_angle); DispatchSpawn(pArmor); pArmor->Activate(); m_bNoArmor = false; }
bool CDirector_Manager::AddBoss(const Vector &vecPosition) { // No se ha podido acceder al Director. if ( !Director() ) return false; // No es posible crear un jefe aquí. if ( !CanMake(vecPosition) ) return false; // Creamos un jefe de la lista. const char *pBossName = GetBossClass(); CAI_BaseNPC *pBoss = (CAI_BaseNPC *)CreateEntityByName(pBossName); QAngle angles = RandomAngle(0, 360); angles.x = 0.0; angles.z = 0.0; pBoss->SetAbsAngles(angles); // Establecemos la ubicación de creación. pBoss->SetAbsOrigin(vecPosition); // Debe caer al suelo y desaparecer. pBoss->AddSpawnFlags(SF_NPC_FALL_TO_GROUND); UTIL_DropToFloor(pBoss, MASK_SOLID); ConVarRef director_debug("director_debug"); // Marcamos al nodo afortunado. if ( director_debug.GetBool() ) NDebugOverlay::Box(vecPosition, -Vector(15, 15, 15), Vector(15, 15, 15), 223, 1, 1, 10, 3.0f); DispatchSpawn(pBoss); pBoss->SetOwnerEntity(Director()); DispatchActivate(pBoss); // ¡¡NO CAMBIAR!! pBoss->SetName(MAKE_STRING(BOSS_NAME)); // Al parecer se atoro en una pared. if ( !PostSpawn(pBoss) ) return false; DevMsg("[MANAGER] Se ha creado un JEFE. \r\n"); ++Director()->BossSpawned; Director()->BossPendient = false; Director()->ChildsKilled = 0; return true; }
void GhostEntity::CreateTrail(){ trail = CreateEntityByName("env_spritetrail"); trail->SetAbsOrigin(GetAbsOrigin()); trail->SetParent(this); trail->KeyValue("rendermode", "5"); trail->KeyValue("spritename", "materials/sprites/laser.vmt"); trail->KeyValue("lifetime", ghostData.trailLength); trail->SetRenderColor(ghostData.trailRed, ghostData.trailGreen, ghostData.trailBlue); //trail->KeyValue("rendercolor", spriteColor.GetString()); trail->KeyValue("renderamt", "75"); trail->KeyValue("startwidth", "9.5"); trail->KeyValue("endwidth", "1.05"); DispatchSpawn(trail); }
CBaseEntity* CASW_Spawn_Manager::SpawnAlienAt(const char* szAlienClass, const Vector& vecPos, const QAngle &angle) { CBaseEntity *pEntity = NULL; pEntity = CreateEntityByName( szAlienClass ); CAI_BaseNPC *pNPC = dynamic_cast<CAI_BaseNPC*>(pEntity); if ( pNPC ) { pNPC->AddSpawnFlags( SF_NPC_FALL_TO_GROUND ); } // Strip pitch and roll from the spawner's angles. Pass only yaw to the spawned NPC. QAngle angles = angle; angles.x = 0.0; angles.z = 0.0; pEntity->SetAbsOrigin( vecPos ); pEntity->SetAbsAngles( angles ); IASW_Spawnable_NPC* pSpawnable = dynamic_cast<IASW_Spawnable_NPC*>(pEntity); ASSERT(pSpawnable); if ( !pSpawnable ) { Warning("NULL Spawnable Ent in CASW_Spawn_Manager::SpawnAlienAt! AlienClass = %s\n", szAlienClass); UTIL_Remove(pEntity); return NULL; } // have drones unburrow by default, so we don't worry so much about them spawning onscreen if ( !Q_strcmp( szAlienClass, "asw_drone" ) ) { pSpawnable->StartBurrowed(); pSpawnable->SetUnburrowIdleActivity( NULL_STRING ); pSpawnable->SetUnburrowActivity( NULL_STRING ); } DispatchSpawn( pEntity ); pEntity->Activate(); // give our aliens the orders pSpawnable->SetAlienOrders(AOT_MoveToNearestMarine, vec3_origin, NULL); // reactivedrop: fixed horde aliens falling through floor and stuck in walls // by moving this function call to the bottom of SpawnAlienAt() // riflemod: temporary comment to test whether parasites fall throught floor //UTIL_DropToFloor(pEntity, MASK_SOLID); return pEntity; }
CTFDroppedWeapon *CTFDroppedWeapon::Create( const Vector &vecOrigin, const QAngle &vecAngles, CBaseEntity *pOwner, CTFWeaponBase *pWeapon ) { CTFDroppedWeapon *pDroppedWeapon = static_cast<CTFDroppedWeapon*>( CBaseAnimating::CreateNoSpawn( "tf_dropped_weapon", vecOrigin, vecAngles, pOwner ) ); if ( pDroppedWeapon ) { pDroppedWeapon->SetModelName( pWeapon->GetModelName() ); pDroppedWeapon->SetItem( pWeapon->GetItem() ); WEAPON_FILE_INFO_HANDLE hWpnInfo = LookupWeaponInfoSlot( pWeapon->GetClassname() ); pDroppedWeapon->m_pWeaponInfo = static_cast<CTFWeaponInfo*>( GetFileWeaponInfoFromHandle( hWpnInfo ) ); DispatchSpawn( pDroppedWeapon ); } return pDroppedWeapon; }
CBaseEntity *CreateServerStatue( CBaseAnimating *pAnimating, int collisionGroup ) { CStatueProp *pStatue = static_cast<CStatueProp *>( CreateEntityByName( "physics_prop_statue" ) ); if ( pStatue ) { pStatue->m_hInitBaseAnimating = pAnimating; pStatue->SetModelName( pAnimating->GetModelName() ); pStatue->SetAbsOrigin( pAnimating->GetAbsOrigin() ); pStatue->SetAbsAngles( pAnimating->GetAbsAngles() ); DispatchSpawn( pStatue ); pStatue->Activate(); } return pStatue; }
CAI_BaseNPC* CASW_Harvester::SpawnAlien() { if (asw_harverter_suppress_children.GetBool()) return NULL; CBaseEntity *pEntity = CreateEntityByName( "asw_parasite_defanged" ); CAI_BaseNPC *pNPC = dynamic_cast<CAI_BaseNPC*>(pEntity); if ( !pNPC ) { Warning("NULL Ent in CASW_Harvester!\n"); return NULL; } pNPC->AddSpawnFlags( SF_NPC_FALL_TO_GROUND ); pNPC->SetAbsOrigin( GetAbsOrigin() + Vector( 0, 0, asw_harvester_spawn_height.GetFloat() ) ); // Strip pitch and roll from the spawner's angles. Pass only yaw to the spawned NPC. QAngle angles = GetAbsAngles(); angles.x = 0.0; angles.z = 0.0; pNPC->SetAbsAngles( angles ); IASW_Spawnable_NPC* pSpawnable = dynamic_cast<IASW_Spawnable_NPC*>(pNPC); ASSERT(pSpawnable); if ( !pSpawnable ) { Warning("NULL Spawnable Ent in CASW_Harvester!\n"); UTIL_Remove(pNPC); return NULL; } DispatchSpawn( pNPC ); pNPC->SetOwnerEntity( this ); pNPC->Activate(); CASW_Parasite *pParasite = dynamic_cast<CASW_Parasite*>(pNPC); if (pParasite) { m_iCrittersAlive++; pParasite->SetMother(this); } return pNPC; }
//----------------------------------------------------------------------------- // Purpose: Creates the NPC. //----------------------------------------------------------------------------- void CHL1NPCMaker::MakeNPC( void ) { if (!CanMakeNPC()) { return; } CBaseEntity *pent = (CBaseEntity*)CreateEntityByName( STRING(m_iszNPCClassname) ); if ( !pent ) { Warning("NULL Ent in NPCMakerHL1!\n" ); return; } m_OnSpawnNPC.FireOutput( this, this ); pent->SetLocalOrigin( GetAbsOrigin() ); pent->SetLocalAngles( GetAbsAngles() ); pent->AddSpawnFlags( SF_NPC_FALL_TO_GROUND ); if ( m_spawnflags & SF_NPCMakerHL1_FADE ) { pent->AddSpawnFlags( SF_NPC_FADE_CORPSE ); } DispatchSpawn( pent ); pent->SetOwnerEntity( this ); m_cLiveChildren++;// count this NPC if (!(m_spawnflags & SF_NPCMakerHL1_INF_CHILD)) { m_iMaxNumNPCs--; if ( IsDepleted() ) { // Disable this forever. Don't kill it because it still gets death notices SetThink( NULL ); SetUse( NULL ); } } }
// NOTE: szName must be a pointer to constant memory, e.g. "monster_class" because the entity // will keep a pointer to it after this call. CBaseEntity *CBaseEntity::Create(char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner) { edict_t * pent; CBaseEntity *pEntity; pent = CREATE_NAMED_ENTITY(MAKE_STRING(szName)); if(FNullEnt(pent)) { ALERT(at_console, "NULL Ent in Create!\n"); return NULL; } pEntity = Instance(pent); pEntity->pev->owner = pentOwner; pEntity->pev->origin = vecOrigin; pEntity->pev->angles = vecAngles; DispatchSpawn(pEntity->edict()); return pEntity; }
void CHL2MP_Player::CreateViewModel( int index /*=0*/ ) { Assert( index >= 0 && index < MAX_VIEWMODELS ); if ( GetViewModel( index ) ) return; CPredictedViewModel *vm = ( CPredictedViewModel * )CreateEntityByName( "predicted_viewmodel" ); if ( vm ) { vm->SetAbsOrigin( GetAbsOrigin() ); vm->SetOwner( this ); vm->SetIndex( index ); DispatchSpawn( vm ); vm->FollowEntity( this, false ); m_hViewModel.Set( index, vm ); } }
//========================================================= // Un jugador ha muerto. //========================================================= void CInSurvivalGameRules::PlayerKilled(CBasePlayer *pVictim, const CTakeDamageInfo &info) { BaseClass::PlayerKilled(pVictim, info); CIN_Player *pInPlayer = GetInPlayer(pVictim); // @TODO: ¿En vez de soltar todas las cosas, permitir ver el inventario externo? pInPlayer->Inventory_DropAll(); // Creamos efecto de moscas. CEnvSound *pFlies = (CEnvSound *)CreateEntityByName("env_sound"); pFlies->SetSoundName(MAKE_STRING("Ambient.DeathFlies2")); pFlies->SetRadius(900); pFlies->SetName(MAKE_STRING("survivor_dead_flies")); pFlies->SetAbsOrigin(pVictim->GetAbsOrigin()); DispatchSpawn(pFlies); pFlies->Activate(); pFlies->PlayManual(1, 100); }
CTFBaseDMPowerup *CTFBaseDMPowerup::Create( const Vector &vecOrigin, const QAngle &vecAngles, CBaseEntity *pOwner, const char *pszClassname, float flDuration ) { CTFBaseDMPowerup *pPowerup = dynamic_cast<CTFBaseDMPowerup *>( CBaseEntity::CreateNoSpawn( pszClassname, vecOrigin, vecAngles, pOwner ) ); if ( pPowerup ) { pPowerup->SetEffectDuration( flDuration ); pPowerup->AddSpawnFlags( SF_NORESPAWN ); DispatchSpawn( pPowerup ); pPowerup->SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_CUSTOM ); pPowerup->SetThink( &CBaseEntity::SUB_Remove ); pPowerup->SetNextThink( gpGlobals->curtime + 30.0f ); } return pPowerup; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CGrenadeSpit::Spawn( void ) { Precache( ); SetSolid( SOLID_BBOX ); SetMoveType( MOVETYPE_FLYGRAVITY ); SetSolidFlags( FSOLID_NOT_STANDABLE ); SetModel( "models/spitball_large.mdl" ); UTIL_SetSize( this, vec3_origin, vec3_origin ); SetUse( &CBaseGrenade::DetonateUse ); SetTouch( &CGrenadeSpit::GrenadeSpitTouch ); SetNextThink( gpGlobals->curtime + 0.1f ); m_flDamage = sk_antlion_worker_spit_grenade_dmg.GetFloat(); m_DmgRadius = sk_antlion_worker_spit_grenade_radius.GetFloat(); m_takedamage = DAMAGE_NO; m_iHealth = 1; SetGravity( UTIL_ScaleForGravity( SPIT_GRAVITY ) ); SetFriction( 0.8f ); SetCollisionGroup( HL2COLLISION_GROUP_SPIT ); AddEFlags( EFL_FORCE_CHECK_TRANSMIT ); // We're self-illuminating, so we don't take or give shadows AddEffects( EF_NOSHADOW|EF_NORECEIVESHADOW ); // Create the dust effect in place m_hSpitEffect = (CParticleSystem *) CreateEntityByName( "info_particle_system" ); if ( m_hSpitEffect != NULL ) { // Setup our basic parameters m_hSpitEffect->KeyValue( "start_active", "1" ); m_hSpitEffect->KeyValue( "effect_name", "antlion_spit_trail" ); m_hSpitEffect->SetParent( this ); m_hSpitEffect->SetLocalOrigin( vec3_origin ); DispatchSpawn( m_hSpitEffect ); if ( gpGlobals->curtime > 0.5f ) m_hSpitEffect->Activate(); } }