//----------------------------------------------------------------------------- // Purpose: Sets up the entity's initial state //----------------------------------------------------------------------------- void CTDPHeadcrab::Spawn( void ) { Precache(); // precache resources SetModel( ENTITY_MODEL ); // set the display model BaseClass::Spawn(); // init CAI_BaseNPC's member vars m_iHealth = 100.0; // set health of your crab; you'll want to make this a convar SetHullType(HULL_TINY); SetHullSizeNormal(); SetSolid( SOLID_BBOX ); // we don't want to allow others to stand on this critter AddSolidFlags( FSOLID_NOT_STANDABLE ); SetMoveType( MOVETYPE_STEP ); // have to look into this, the original crab has it's own collision SetCollisionGroup( COLLISION_GROUP_NPC ); // model defined in hl2 specific code SetViewOffset( Vector(6, 0, 11) ) ; // Position of the eyes relative to NPC's origin. SetBloodColor( BLOOD_COLOR_GREEN ); // guess ;-) m_flFieldOfView = 0.5; m_NPCState = NPC_STATE_NONE; CapabilitiesClear(); // crab can move around and start melee attack CapabilitiesAdd( bits_CAP_MOVE_GROUND | bits_CAP_INNATE_MELEE_ATTACK1 ); NPCInit(); // initialize our NPC // Crab hates player, set to D_FR to see it run away from player AddClassRelationship( CLASS_PLAYER, D_HT, 0 ); AddClassRelationship( CLASS_COMBINE, D_HT, 0 ); }
//----------------------------------------------------------------------------- // Purpose: // Input : // Output : //----------------------------------------------------------------------------- int CNPC_Stalker::OnTakeDamage_Alive( const CTakeDamageInfo &inputInfo ) { CTakeDamageInfo info = inputInfo; // -------------------------------------------- // Don't take a lot of damage from Vortigaunt // -------------------------------------------- if (info.GetAttacker()->Classify() == CLASS_VORTIGAUNT) { info.ScaleDamage( 0.25 ); } int ret = BaseClass::OnTakeDamage_Alive( info ); // If player shot me make sure I'm mad at him even if I wasn't earlier if ( (info.GetAttacker()->GetFlags() & FL_CLIENT) ) { AddClassRelationship( CLASS_PLAYER, D_HT, 0 ); } return ret; }
//--------------------------------------------------------- //--------------------------------------------------------- void CNPC_MissileDefense::Spawn( void ) { Precache(); SetModel( "models/missile_defense.mdl" ); UTIL_SetSize( this, Vector( -36, -36 , 0 ), Vector( 36, 36, 64 ) ); SetSolid( SOLID_BBOX ); SetMoveType( MOVETYPE_NONE ); m_takedamage = DAMAGE_YES; SetBloodColor( DONT_BLEED ); m_iHealth = 10; m_flFieldOfView = 0.1; m_NPCState = NPC_STATE_NONE; CapabilitiesClear(); CapabilitiesAdd ( bits_CAP_INNATE_RANGE_ATTACK1 ); // Hate missiles AddClassRelationship( CLASS_MISSILE, D_HT, 5 ); m_spawnflags |= SF_NPC_LONG_RANGE; m_flReloadedTime = gpGlobals->curtime; InitBoneControllers(); NPCInit(); SetBoneController( MD_BC_YAW, 10 ); SetBoneController( MD_BC_PITCH, 0 ); SetBodygroup( 1, 1 ); SetBodygroup( 2, 1 ); SetBodygroup( 3, 1 ); SetBodygroup( 4, 1 ); m_NPCState = NPC_STATE_IDLE; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CNPC_Crow::Spawn( void ) { BaseClass::Spawn(); #ifdef _XBOX // Always fade the corpse AddSpawnFlags( SF_NPC_FADE_CORPSE ); #endif // _XBOX char *szModel = (char *)STRING( GetModelName() ); if (!szModel || !*szModel) { szModel = "models/crow.mdl"; SetModelName( AllocPooledString(szModel) ); } Precache(); SetModel( szModel ); m_iHealth = sk_crow_health.GetFloat(); SetHullType(HULL_TINY); SetHullSizeNormal(); SetSolid( SOLID_BBOX ); SetMoveType( MOVETYPE_STEP ); m_flFieldOfView = VIEW_FIELD_FULL; SetViewOffset( Vector(6, 0, 11) ); // Position of the eyes relative to NPC's origin. m_flGroundIdleMoveTime = gpGlobals->curtime + random->RandomFloat( 0.0f, 5.0f ); SetBloodColor( BLOOD_COLOR_RED ); m_NPCState = NPC_STATE_NONE; m_nMorale = random->RandomInt( 0, 12 ); SetCollisionGroup( HL2COLLISION_GROUP_CROW ); CapabilitiesClear(); bool bFlying = ( ( m_spawnflags & SF_CROW_FLYING ) != 0 ); SetFlyingState( bFlying ? FlyState_Flying : FlyState_Walking ); // We don't mind zombies so much. They smell good! AddClassRelationship( CLASS_ZOMBIE, D_NU, 0 ); m_bSoar = false; m_bOnJeep = false; m_flSoarTime = gpGlobals->curtime; NPCInit(); m_iBirdType = BIRDTYPE_CROW; m_vLastStoredOrigin = vec3_origin; m_flLastStuckCheck = gpGlobals->curtime; m_flDangerSoundTime = gpGlobals->curtime; SetGoalEnt( NULL ); }