//========================================================= // GibMonster - make gun fly through the air. //========================================================= //sys: esto es rarisimo, porque son raros los casos de gibbeo...Vamos a ponerlo //igual de todas formas: void CFriend :: GibMonster ( void ) { Vector vecGunPos; Vector vecGunAngles; // Si tiene arma ... y si NO tiene el flag de "no tirar arma" if ( GetBodygroup( 2 ) != 2 && !(pev->spawnflags & SF_MONSTER_NO_WPN_DROP)) {// throw a gun if the grunt has one GetAttachment( 0, vecGunPos, vecGunAngles ); CBaseEntity *pGun; // if (FBitSet( pev->weapons, HGRUNT_SHOTGUN )) if (pev->frags) { pGun = DropItem( "weapon_spas12", vecGunPos, vecGunAngles ); pGun->pev->spawnflags |= SF_NORESPAWN; } else //sino tiene 9mmAR { pGun = DropItem( "weapon_m16", vecGunPos, vecGunAngles ); pGun->pev->spawnflags |= SF_NORESPAWN; } if ( pGun ) { pGun->pev->velocity = Vector (RANDOM_FLOAT(-100,100), RANDOM_FLOAT(-100,100), RANDOM_FLOAT(200,300)); pGun->pev->avelocity = Vector ( 0, RANDOM_FLOAT( 200, 400 ), 0 ); } /* if (FBitSet( pev->weapons, HGRUNT_GRENADELAUNCHER )) { pGun = DropItem( "ammo_ARgrenades", vecGunPos, vecGunAngles ); if ( pGun ) { pGun->pev->velocity = Vector (RANDOM_FLOAT(-100,100), RANDOM_FLOAT(-100,100), RANDOM_FLOAT(200,300)); pGun->pev->avelocity = Vector ( 0, RANDOM_FLOAT( 200, 400 ), 0 ); } } */ } CBaseMonster :: GibMonster(); }
void COtis::Killed( entvars_t *pevAttacker, int iGib ) { if ( GetBodygroup( OT_GUN_GROUP ) != OT_GUN_HOLSTER ) {// drop the gun! Vector vecGunPos; Vector vecGunAngles; SetBodygroup( OT_GUN_GROUP , OT_GUN_HOLSTER ); GetAttachment( 0, vecGunPos, vecGunAngles ); CBaseEntity *pGun = DropItem( "weapon_357", vecGunPos, vecGunAngles ); } SetUse( NULL ); // make sure friends talk about it if player hurts talkmonsters... if( !m_fHostile ) CTalkMonster::Killed( pevAttacker, iGib ); else CBaseMonster::Killed( pevAttacker, iGib ); }
//----------------------------------------------------------------------------- // Purpose: The nest is dead! Evacuate the nest! // Input : bExplosion - We were evicted by an explosion so we should go a-flying. // flDamage - The damage that was done to cause the evacuation. //----------------------------------------------------------------------------- void CNPC_PoisonZombie::EvacuateNest( bool bExplosion, float flDamage, CBaseEntity *pAttacker ) { // HACK: if we were in mid-throw, drop the throwing crab also. if ( GetBodygroup( ZOMBIE_BODYGROUP_THROW ) ) { SetBodygroup( ZOMBIE_BODYGROUP_THROW, 0 ); m_nCrabCount++; } for( int i = 0; i < MAX_CRABS ; i++ ) { if( m_bCrabs[i] ) { Vector vecPosition; QAngle vecAngles; char szAttachment[64]; switch( i ) { case 0: strcpy( szAttachment, "headcrab2" ); break; case 1: strcpy( szAttachment, "headcrab3" ); break; case 2: strcpy( szAttachment, "headcrab4" ); break; } GetAttachment( szAttachment, vecPosition, vecAngles ); // Now slam the angles because the attachment point will have pitch and roll, which we can't use. vecAngles = QAngle( 0, random->RandomFloat( 0, 360 ), 0 ); CBlackHeadcrab *pCrab = (CBlackHeadcrab *)CreateNoSpawn( GetHeadcrabClassname(), vecPosition, vecAngles, this ); pCrab->Spawn(); if( !HeadcrabFits(pCrab) ) { UTIL_Remove(pCrab); continue; } float flVelocityScale = 2.0f; if ( bExplosion && ( flDamage > 10 ) ) { flVelocityScale = 0.1 * flDamage; } if (IsOnFire()) { pCrab->Ignite( 100.0 ); } pCrab->Eject( vecAngles, flVelocityScale, pAttacker ); EnableCrab( i, false ); } } }
void CFriend::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { // check for helmet shot if (ptr->iHitgroup == HITGROUP_HEAD) // si el daño es en la cabeza { if (GetBodygroup( 1 ) == HEAD_MASK && (bitsDamageType & (DMG_BULLET | DMG_SLASH | DMG_BLAST | DMG_CLUB))) { // absorb damage flDamage -= 20; if (flDamage <= 0) { UTIL_Ricochet( ptr->vecEndPos, 1.0 ); UTIL_Sparks( ptr->vecEndPos ); // Sonidos (precache en world.cpp) switch (RANDOM_LONG(0,2)) { case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/damage/helmet1.wav", 0.9, ATTN_NORM); break; case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/damage/helmet2.wav", 0.9, ATTN_NORM); break; case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/damage/helmet3.wav", 0.9, ATTN_NORM); break; } flDamage = 0.01; } } else if (GetBodygroup( 1 ) == HEAD_GRUNT && (bitsDamageType & (DMG_BULLET | DMG_SLASH | DMG_BLAST | DMG_CLUB))) { // absorb damage flDamage -= 20; if (flDamage <= 0) { UTIL_Ricochet( ptr->vecEndPos, 1.0 ); UTIL_Sparks( ptr->vecEndPos ); // Sonidos (precache en world.cpp) switch (RANDOM_LONG(0,2)) { case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/damage/helmet1.wav", 0.9, ATTN_NORM); break; case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/damage/helmet2.wav", 0.9, ATTN_NORM); break; case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/damage/helmet3.wav", 0.9, ATTN_NORM); break; } flDamage = 0.01; } } else { ALERT( at_console, "Human Grunt Headshot!\n" ); UTIL_BloodStream( ptr->vecEndPos, gpGlobals->v_forward * 10 + // -5 gpGlobals->v_up * 2, (unsigned short)73, 100 ); //-35 switch (RANDOM_LONG(0,2)) //ejecuta los siguientes sonidos al azar { case 0: EMIT_SOUND (ENT(pev), CHAN_BODY, "fvox/m_headshot1.wav", 1, ATTN_NORM ); break; case 1: EMIT_SOUND (ENT(pev), CHAN_BODY, "fvox/m_headshot2.wav", 1, ATTN_NORM ); break; case 2: EMIT_SOUND (ENT(pev), CHAN_BODY, "fvox/m_headshot3.wav", 1, ATTN_NORM ); break; } } } else { switch (RANDOM_LONG(0,2)) //ejecuta los siguientes sonidos al azar { case 0: EMIT_SOUND (ENT(pev), CHAN_BODY, "fvox/m_hit1.wav", 1, ATTN_NORM ); break; case 1: EMIT_SOUND (ENT(pev), CHAN_BODY, "fvox/m_hit2.wav", 1, ATTN_NORM ); break; case 2: EMIT_SOUND (ENT(pev), CHAN_BODY, "fvox/m_hit3.wav", 1, ATTN_NORM ); break; } } CTalkMonster::TraceAttack( pevAttacker, flDamage, vecDir, ptr, bitsDamageType ); }
//========================================================= // Spawn //========================================================= void CFriend :: Spawn() { Precache( ); if (pev->model) SET_MODEL( ENT(pev), STRING(pev->model) ); else if ( CVAR_GET_FLOAT("cl_ragdoll" ) != 0 ) SET_MODEL( ENT(pev),"physics/models/hgrunt_ally.mdl"); else SET_MODEL( ENT(pev),"models/hgrunt_ally.mdl"); UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_STEP; m_bloodColor = BLOOD_COLOR_RED; if (pev->health == 0) //LRC pev->health = gSkillData.barneyHealth; pev->view_ofs = Vector ( 0, 0, 50 );// position of the eyes relative to monster's origin. m_flFieldOfView = VIEW_FIELD_WIDE; // NOTE: we need a wide field of view so npc will notice player and say hello m_MonsterState = MONSTERSTATE_NONE; m_fGunDrawn = TRUE; m_afCapability = bits_CAP_HEAR | bits_CAP_TURN_HEAD | bits_CAP_DOORS_GROUP; if (pev->frags == -1) //si no esta seteado la deagle { if (RANDOM_LONG( 0, 99 ) < 60) // { pev->frags = 0; // ALERT (at_console, "mp5\n"); } else { pev->frags = 1; // ALERT (at_console, "shotgun\n"); } } if (pev->frags)//shotgun { SetBodygroup( GUN_GROUP, GUN_SHOTGUN ); m_cClipSize = 8; } else { SetBodygroup( GUN_GROUP, GUN_MP5 ); m_cClipSize = 30; } m_cAmmoLoaded = m_cClipSize; //random heads switch (RANDOM_LONG(0,3)) { case 0: SetBodygroup( HEAD_GROUP, HEAD_GRUNT ); break; case 1: SetBodygroup( HEAD_GROUP, HEAD_COMMANDER ); break; case 2: SetBodygroup( HEAD_GROUP, HEAD_SHOTGUN ); break; case 3: SetBodygroup( HEAD_GROUP, HEAD_M203 ); break; } //set random skins if (RANDOM_LONG( 0, 99 ) < 80) pev->skin = 0; // light skin else pev->skin = 1; // dark skin //oh dear! commander is not a black guy! if ( GetBodygroup( HEAD_GROUP ) == HEAD_COMMANDER ) pev->skin = 0; // always light skin //right, the black guy must have dark arms if ( GetBodygroup( HEAD_GROUP ) == HEAD_M203 ) pev->skin = 1; // always dark skin MonsterInit(); SetUse(&CFriend :: FollowerUse ); }