void CGrenadeSpit::Spawn( void ) { Precache( ); SetSolid( SOLID_BBOX ); SetMoveType( MOVETYPE_FLYGRAVITY ); // FIXME, if these is a sprite, then we need a base class derived from CSprite rather than // CBaseAnimating. pev->scale becomes m_flSpriteScale in that case. SetModel( "models/spitball_large.mdl" ); UTIL_SetSize(this, Vector(0, 0, 0), Vector(0, 0, 0)); m_nRenderMode = kRenderTransAdd; SetRenderColor( 255, 255, 255, 255 ); m_nRenderFX = kRenderFxNone; SetThink( SpitThink ); SetUse( DetonateUse ); SetTouch( GrenadeSpitTouch ); SetNextThink( gpGlobals->curtime + 0.1f ); m_flDamage = sk_dmg_spit_grenade.GetFloat(); m_DmgRadius = sk_spit_grenade_radius.GetFloat(); m_takedamage = DAMAGE_YES; m_iHealth = 1; SetGravity( UTIL_ScaleForGravity( SPIT_GRAVITY ) ); SetFriction( 0.8 ); SetSequence( 1 ); SetCollisionGroup( HL2COLLISION_GROUP_SPIT ); }
void CBaseHelicopter::Event_Killed( const CTakeDamageInfo &info ) { m_lifeState = LIFE_DYING; SetMoveType( MOVETYPE_FLYGRAVITY ); SetGravity( UTIL_ScaleForGravity( 240 ) ); // use a lower gravity StopLoopingSounds(); UTIL_SetSize( this, Vector( -32, -32, -64), Vector( 32, 32, 0) ); SetThink( &CBaseHelicopter::CallDyingThink ); SetTouch( &CBaseHelicopter::CrashTouch ); SetNextThink( gpGlobals->curtime + 0.1f ); m_iHealth = 0; m_takedamage = DAMAGE_NO; /* if (m_spawnflags & SF_NOWRECKAGE) { m_flNextRocket = gpGlobals->curtime + 4.0; } else { m_flNextRocket = gpGlobals->curtime + 15.0; } */ StopRotorWash(); m_OnDeath.FireOutput( info.GetAttacker(), this ); }
void CSatchelCharge::Spawn( void ) { Precache( ); SetModel( "models/Weapons/w_slam.mdl" ); VPhysicsInitNormal( SOLID_BBOX, GetSolidFlags() | FSOLID_TRIGGER, false ); SetMoveType( MOVETYPE_VPHYSICS ); SetCollisionGroup( COLLISION_GROUP_WEAPON ); UTIL_SetSize(this, Vector( -6, -6, -2), Vector(6, 6, 2)); SetThink( &CSatchelCharge::SatchelThink ); SetNextThink( gpGlobals->curtime + 0.1f ); m_flDamage = sk_plr_dmg_satchel.GetFloat(); m_DmgRadius = sk_satchel_radius.GetFloat(); m_takedamage = DAMAGE_YES; m_iHealth = 1; SetGravity( UTIL_ScaleForGravity( 560 ) ); // slightly lower gravity SetFriction( 1.0 ); SetSequence( 1 ); SetDamage( 150 ); m_bIsAttached = false; m_bInAir = true; m_flNextBounceSoundTime = 0; m_vLastPosition = vec3_origin; m_hGlowSprite = NULL; CreateEffects(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CGETKnife::Spawn( void ) { Precache(); BaseClass::Spawn(); SetModel( "models/weapons/knife/w_tknife.mdl" ); SetSize( -Vector(8,8,8), Vector(8,8,8) ); // Init our physics definition VPhysicsInitNormal( SOLID_VPHYSICS, GetSolidFlags() | FSOLID_TRIGGER, false ); SetMoveType( MOVETYPE_VPHYSICS ); SetCollisionGroup( COLLISION_GROUP_GRENADE ); // No Air-Drag, lower gravity VPhysicsGetObject()->EnableDrag( false ); SetGravity( UTIL_ScaleForGravity( 540.0f ) ); m_bInAir = true; m_takedamage = DAMAGE_NO; AddSolidFlags( FSOLID_NOT_STANDABLE ); m_flStopFlyingTime = gpGlobals->curtime + 4.5f; // const CBaseEntity *host = te->GetSuppressHost(); // te->SetSuppressHost( NULL ); // DispatchParticleEffect( "tracer_tknife", PATTACH_POINT_FOLLOW, this, "tip" ); // te->SetSuppressHost( (CBaseEntity*)host ); SetTouch( &CGETKnife::DamageTouch ); SetThink( &CGETKnife::SoundThink ); SetNextThink( gpGlobals->curtime ); }
void CBaseGrenadeContact::Spawn( void ) { // point sized, solid, bouncing SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE ); SetSolid( SOLID_BBOX ); SetCollisionGroup( COLLISION_GROUP_PROJECTILE ); SetModel( "models/weapons/w_grenade.mdl" ); // BUG: wrong model UTIL_SetSize(this, vec3_origin, vec3_origin); // contact grenades arc lower SetGravity( UTIL_ScaleForGravity( 400 ) ); // use a lower gravity for grenades to make them easier to see QAngle angles; VectorAngles(GetAbsVelocity(), angles); SetLocalAngles( angles ); // make NPCs afaid of it while in the air SetThink( &CBaseGrenadeContact::DangerSoundThink ); SetNextThink( gpGlobals->curtime ); // Tumble in air QAngle vecAngVelocity( random->RandomFloat ( -100, -500 ), 0, 0 ); SetLocalAngularVelocity( vecAngVelocity ); // Explode on contact SetTouch( &CBaseGrenadeContact::ExplodeTouch ); m_flDamage = 100; // BOXBOX was sk_plr_dmg_grenade.GetFloat(); // Allow player to blow this puppy up in the air m_takedamage = DAMAGE_YES; m_iszBounceSound = NULL_STRING; }
void CShower::Spawn( void ) { Vector vecForward; AngleVectors( GetLocalAngles(), &vecForward ); Vector vecNewVelocity; vecNewVelocity = random->RandomFloat( 200, 300 ) * vecForward; vecNewVelocity.x += random->RandomFloat(-100.f,100.f); vecNewVelocity.y += random->RandomFloat(-100.f,100.f); if ( vecNewVelocity.z >= 0 ) vecNewVelocity.z += 200; else vecNewVelocity.z -= 200; SetAbsVelocity( vecNewVelocity ); SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE ); SetGravity( UTIL_ScaleForGravity( 400 ) ); // fall a bit more slowly than normal SetNextThink( gpGlobals->curtime + 0.1f ); SetSolid( SOLID_NONE ); UTIL_SetSize(this, vec3_origin, vec3_origin ); AddEffects( EF_NODRAW ); m_flSpeed = random->RandomFloat( 0.5, 1.5 ); SetLocalAngles( vec3_angle ); }
void CGrenadeMP5::Spawn( void ) { Precache( ); SetSolid( SOLID_BBOX ); SetMoveType( MOVETYPE_FLY ); AddFlag( FL_GRENADE ); SetModel( "models/grenade.mdl" ); //UTIL_SetSize(this, Vector(-3, -3, -3), Vector(3, 3, 3)); UTIL_SetSize(this, Vector(0, 0, 0), Vector(0, 0, 0)); SetUse( &CBaseGrenade::DetonateUse ); SetTouch( &CGrenadeMP5::GrenadeMP5Touch ); SetNextThink( gpGlobals->curtime + 0.1f ); m_flDamage = sk_plr_dmg_mp5_grenade.GetFloat(); m_DmgRadius = sk_mp5_grenade_radius.GetFloat(); m_takedamage = DAMAGE_YES; m_bIsLive = true; m_iHealth = 1; SetGravity( UTIL_ScaleForGravity( 400 ) ); // use a lower gravity for grenades to make them easier to see SetFriction( 0.8 ); SetSequence( 0 ); m_fSpawnTime = gpGlobals->curtime; }
void CSatchelCharge::Spawn( void ) { Precache( ); // motor SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE ); SetSolid( SOLID_BBOX ); SetCollisionGroup( COLLISION_GROUP_PROJECTILE ); SetModel( "models/Weapons/w_slam.mdl" ); UTIL_SetSize(this, Vector( -6, -6, -2), Vector(6, 6, 2)); SetTouch( SatchelTouch ); SetUse( SatchelUse ); SetThink( SatchelThink ); SetNextThink( gpGlobals->curtime + 0.1f ); m_flDamage = sk_plr_dmg_satchel.GetFloat(); m_DmgRadius = sk_satchel_radius.GetFloat(); m_takedamage = DAMAGE_YES; m_iHealth = 1; SetGravity( UTIL_ScaleForGravity( 560 ) ); // slightly lower gravity SetFriction( 1.0 ); SetSequence( 1 ); m_bIsAttached = false; m_bInAir = true; m_flSlideVolume = -1.0; m_flNextBounceSoundTime = 0; m_vLastPosition = vec3_origin; InitSlideSound(); }
//------------------------------------------------------------------------------ // Spawn //------------------------------------------------------------------------------ void CQUAGrenadeHelicopter::Spawn( void ) { Precache(); // point sized, solid, bouncing SetCollisionGroup( COLLISION_GROUP_PROJECTILE ); SetModel( "models/combine_helicopter/helicopter_bomb01.mdl" ); SetSolid( SOLID_BBOX ); SetCollisionBounds( Vector( -12.5, -12.5, -12.5 ), Vector( 12.5, 12.5, 12.5 ) ); VPhysicsInitShadow( false, false ); SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_CUSTOM ); SetElasticity( 0.5f ); AddEffects( EF_NOSHADOW ); // We're always being dropped beneath the helicopter; need to not // be affected by the rotor wash AddEFlags( EFL_NO_ROTORWASH_PUSH ); // contact grenades arc lower SetGravity( UTIL_ScaleForGravity( 400 ) ); // use a lower gravity for grenades to make them easier to see QAngle angles; VectorAngles(GetAbsVelocity(), angles ); SetLocalAngles( angles ); SetThink( NULL ); // Tumble in air QAngle vecAngVel( random->RandomFloat ( -100, -500 ), 0, 0 ); SetLocalAngularVelocity( vecAngVel ); // Explode on contact SetTouch( &CQUAGrenadeHelicopter::ExplodeConcussion ); m_bActivated = false; m_pWarnSound = NULL; m_flDamage = 75.0; // Allow player to blow this puppy up in the air m_takedamage = DAMAGE_YES; g_pNotify->AddEntity( this, this ); }
//----------------------------------------------------------------------------- // Purpose: Setup basic values for Thrown grens //----------------------------------------------------------------------------- void CThrownGrenade::Spawn( void ) { // point sized, solid, bouncing SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE ); SetSolid( SOLID_BBOX ); UTIL_SetSize(this, vec3_origin, vec3_origin); // Movement SetGravity( UTIL_ScaleForGravity( 648 ) ); SetFriction(0.6); QAngle angles; VectorAngles( GetAbsVelocity(), angles ); SetLocalAngles( angles ); QAngle vecAngVel( random->RandomFloat ( -100, -500 ), 0, 0 ); SetLocalAngularVelocity( vecAngVel ); SetTouch( &CThrownGrenade::BounceTouch ); }
//----------------------------------------------------------------------------- // 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(); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CFlare::Spawn( void ) { Precache(); SetModel( "models/weapons/flare.mdl" ); UTIL_SetSize( this, Vector( -2, -2, -2 ), Vector( 2, 2, 2 ) ); SetSolid( SOLID_BBOX ); AddSolidFlags( FSOLID_NOT_SOLID ); SetMoveType( MOVETYPE_NONE ); SetFriction( 0.6f ); SetGravity( UTIL_ScaleForGravity( 400 ) ); m_flTimeBurnOut = gpGlobals->curtime + 30; AddEffects( EF_NOSHADOW|EF_NORECEIVESHADOW ); if ( m_spawnflags & SF_FLARE_NO_DLIGHT ) { m_bLight = false; } if ( m_spawnflags & SF_FLARE_NO_SMOKE ) { m_bSmoke = false; } if ( m_spawnflags & SF_FLARE_INFINITE ) { m_flTimeBurnOut = -1.0f; } if ( m_spawnflags & SF_FLARE_START_OFF ) { AddEffects( EF_NODRAW ); } AddFlag( FL_OBJECT ); }
void CGrenadeAR2::Spawn( void ) { Precache( ); SetSolid( SOLID_BBOX ); SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE ); // Hits everything but debris SetCollisionGroup( COLLISION_GROUP_PROJECTILE ); SetModel( "models/Weapons/ar2_grenade.mdl"); UTIL_SetSize(this, Vector(-3, -3, -3), Vector(3, 3, 3)); // UTIL_SetSize(this, Vector(0, 0, 0), Vector(0, 0, 0)); SetUse( &CGrenadeAR2::DetonateUse ); SetTouch( &CGrenadeAR2::GrenadeAR2Touch ); SetThink( &CGrenadeAR2::GrenadeAR2Think ); SetNextThink( gpGlobals->curtime + 0.1f ); if( GetOwnerEntity() && GetOwnerEntity()->IsPlayer() ) { m_flDamage = sk_plr_dmg_smg1_grenade.GetFloat(); } else { m_flDamage = sk_npc_dmg_smg1_grenade.GetFloat(); } m_DmgRadius = sk_smg1_grenade_radius.GetFloat(); m_takedamage = DAMAGE_YES; m_bIsLive = true; m_iHealth = 1; SetGravity( UTIL_ScaleForGravity( 400 ) ); // use a lower gravity for grenades to make them easier to see SetFriction( 0.8 ); SetSequence( 0 ); m_fDangerRadius = 100; m_fSpawnTime = gpGlobals->curtime; // ------------- // Smoke trail. // ------------- if( g_CV_SmokeTrail.GetInt() && !IsXbox() ) { m_hSmokeTrail = SmokeTrail::CreateSmokeTrail(); if( m_hSmokeTrail ) { m_hSmokeTrail->m_SpawnRate = 48; m_hSmokeTrail->m_ParticleLifetime = 1; m_hSmokeTrail->m_StartColor.Init(0.1f, 0.1f, 0.1f); m_hSmokeTrail->m_EndColor.Init(0,0,0); m_hSmokeTrail->m_StartSize = 12; m_hSmokeTrail->m_EndSize = m_hSmokeTrail->m_StartSize * 4; m_hSmokeTrail->m_SpawnRadius = 4; m_hSmokeTrail->m_MinSpeed = 4; m_hSmokeTrail->m_MaxSpeed = 24; m_hSmokeTrail->m_Opacity = 0.2f; m_hSmokeTrail->SetLifetime(10.0f); m_hSmokeTrail->FollowEntity(this); } } }
void CASW_Bait::BaitTouch( CBaseEntity *pOther ) { Assert( pOther ); if ( !pOther->IsSolid() ) return; if ( pOther && pOther->m_takedamage ) { Vector vecNewVelocity = GetAbsVelocity(); vecNewVelocity *= 0.1f; SetAbsVelocity( vecNewVelocity ); SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE ); SetGravity(1.0f); return; } else { // hit the world, check the material type here, see if the flare should stick. trace_t tr; tr = CBaseEntity::GetTouchTrace(); //Only do this on the first bounce if ( m_nBounces == 0 ) { surfacedata_t *pdata = physprops->GetSurfaceData( tr.surface.surfaceProps ); if ( pdata != NULL ) { //Only embed into concrete and wood (jdw: too obscure for players?) //if ( ( pdata->gameMaterial == 'C' ) || ( pdata->gameMaterial == 'W' ) ) { Vector impactDir = ( tr.endpos - tr.startpos ); VectorNormalize( impactDir ); float surfDot = tr.plane.normal.Dot( impactDir ); //Do not stick to ceilings or on shallow impacts if ( ( tr.plane.normal.z > -0.5f ) && ( surfDot < -0.9f ) ) { RemoveSolidFlags( FSOLID_NOT_SOLID ); AddSolidFlags( FSOLID_TRIGGER ); LayFlat(); UTIL_SetOrigin( this, tr.endpos + ( tr.plane.normal * 2.0f ) ); SetAbsVelocity( vec3_origin ); SetMoveType( MOVETYPE_NONE ); SetTouch( NULL ); return; } } } } // Change our flight characteristics SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE ); SetGravity( UTIL_ScaleForGravity( 640 ) ); m_nBounces++; //After the first bounce, smacking into whoever fired the flare is fair game SetOwnerEntity( NULL ); // Slow down Vector vecNewVelocity = GetAbsVelocity(); vecNewVelocity.x *= 0.8f; vecNewVelocity.y *= 0.8f; SetAbsVelocity( vecNewVelocity ); //Stopped? if ( GetAbsVelocity().Length() < 64.0f ) { LayFlat(); SetAbsVelocity( vec3_origin ); SetMoveType( MOVETYPE_NONE ); RemoveSolidFlags( FSOLID_NOT_SOLID ); AddSolidFlags( FSOLID_TRIGGER ); SetTouch( NULL ); } } }
//----------------------------------------------------------------------------- // Purpose: // Input : *pOther - //----------------------------------------------------------------------------- void CFlare::FlareTouch( CBaseEntity *pOther ) { Assert( pOther ); if ( !pOther->IsSolid() ) return; if ( ( m_nBounces < 10 ) && ( GetWaterLevel() < 1 ) ) { // Throw some real chunks here g_pEffects->Sparks( GetAbsOrigin() ); } //If the flare hit a person or NPC, do damage here. if ( pOther && pOther->m_takedamage ) { /* The Flare is the iRifle round right now. No damage, just ignite. (sjb) //Damage is a function of how fast the flare is flying. int iDamage = GetAbsVelocity().Length() / 50.0f; if ( iDamage < 5 ) { //Clamp minimum damage iDamage = 5; } //Use m_pOwner, not GetOwnerEntity() pOther->TakeDamage( CTakeDamageInfo( this, m_pOwner, iDamage, (DMG_BULLET|DMG_BURN) ) ); m_flNextDamage = gpGlobals->curtime + 1.0f; */ CBaseAnimating *pAnim; pAnim = dynamic_cast<CBaseAnimating*>(pOther); if( pAnim ) { pAnim->Ignite( 30.0f ); } Vector vecNewVelocity = GetAbsVelocity(); vecNewVelocity *= 0.1f; SetAbsVelocity( vecNewVelocity ); SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE ); SetGravity(1.0f); Die( 0.5 ); return; } else { // hit the world, check the material type here, see if the flare should stick. trace_t tr; tr = CBaseEntity::GetTouchTrace(); //Only do this on the first bounce if ( m_nBounces == 0 ) { const surfacedata_t *pdata = physprops->GetSurfaceData( tr.surface.surfaceProps ); if ( pdata != NULL ) { //Only embed into concrete and wood (jdw: too obscure for players?) //if ( ( pdata->gameMaterial == 'C' ) || ( pdata->gameMaterial == 'W' ) ) { Vector impactDir = ( tr.endpos - tr.startpos ); VectorNormalize( impactDir ); float surfDot = tr.plane.normal.Dot( impactDir ); //Do not stick to ceilings or on shallow impacts if ( ( tr.plane.normal.z > -0.5f ) && ( surfDot < -0.9f ) ) { RemoveSolidFlags( FSOLID_NOT_SOLID ); AddSolidFlags( FSOLID_TRIGGER ); UTIL_SetOrigin( this, tr.endpos + ( tr.plane.normal * 2.0f ) ); SetAbsVelocity( vec3_origin ); SetMoveType( MOVETYPE_NONE ); SetTouch( &CFlare::FlareBurnTouch ); int index = decalsystem->GetDecalIndexForName( "SmallScorch" ); if ( index >= 0 ) { CBroadcastRecipientFilter filter; te->Decal( filter, 0.0, &tr.endpos, &tr.startpos, ENTINDEX( tr.m_pEnt ), tr.hitbox, index ); } CPASAttenuationFilter filter2( this, "Flare.Touch" ); EmitSound( filter2, entindex(), "Flare.Touch" ); return; } } } } //Scorch decal if ( GetAbsVelocity().LengthSqr() > (250*250) ) { int index = decalsystem->GetDecalIndexForName( "FadingScorch" ); if ( index >= 0 ) { CBroadcastRecipientFilter filter; te->Decal( filter, 0.0, &tr.endpos, &tr.startpos, ENTINDEX( tr.m_pEnt ), tr.hitbox, index ); } } // Change our flight characteristics SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE ); SetGravity( UTIL_ScaleForGravity( 640 ) ); m_nBounces++; //After the first bounce, smacking into whoever fired the flare is fair game SetOwnerEntity( this ); // Slow down Vector vecNewVelocity = GetAbsVelocity(); vecNewVelocity.x *= 0.8f; vecNewVelocity.y *= 0.8f; SetAbsVelocity( vecNewVelocity ); //Stopped? if ( GetAbsVelocity().Length() < 64.0f ) { SetAbsVelocity( vec3_origin ); SetMoveType( MOVETYPE_NONE ); RemoveSolidFlags( FSOLID_NOT_SOLID ); AddSolidFlags( FSOLID_TRIGGER ); SetTouch( &CFlare::FlareBurnTouch ); } } }