void CNPC_HL1Barney::SUB_LVFadeOut( void ) { if( VPhysicsGetObject() ) { if( VPhysicsGetObject()->GetGameFlags() & FVPHYSICS_PLAYER_HELD || GetEFlags() & EFL_IS_BEING_LIFTED_BY_BARNACLE ) { // Try again in a few seconds. SetNextThink( gpGlobals->curtime + 5 ); SetRenderColorA( 255 ); return; } } float dt = gpGlobals->frametime; if ( dt > 0.1f ) { dt = 0.1f; } m_nRenderMode = kRenderTransTexture; int speed = max(3,256*dt); // fade out over 3 seconds SetRenderColorA( UTIL_Approach( 0, m_clrRender->a, speed ) ); NetworkStateChanged(); if ( m_clrRender->a == 0 ) { UTIL_Remove(this); } else { SetNextThink( gpGlobals->curtime ); } }
void CWateryDeathLeech::LeechThink( void ) { if ( IsMarkedForDeletion() ) return; StudioFrameAdvance(); SetNextThink( gpGlobals->curtime + 0.1 ); if ( m_iFadeState != 0 ) { float dt = gpGlobals->frametime; if ( dt > 0.1f ) { dt = 0.1f; } m_nRenderMode = kRenderTransTexture; int speed = max(1,256*dt); // fade out over 1 second if ( m_iFadeState == -1 ) SetRenderColorA( UTIL_Approach( 0, m_clrRender->a, speed ) ); else SetRenderColorA( UTIL_Approach( 255, m_clrRender->a, speed ) ); if ( m_clrRender->a == 0 ) { UTIL_Remove(this); } else if ( m_clrRender->a == 255 ) { m_iFadeState = 0; } else { SetNextThink( gpGlobals->curtime ); } } if ( GetOwnerEntity() ) { if ( GetOwnerEntity()->GetWaterLevel() < 3 ) { AddEffects( EF_NODRAW ); } else { RemoveEffects( EF_NODRAW ); } SetAbsOrigin( GetOwnerEntity()->GetAbsOrigin() + GetOwnerEntity()->GetViewOffset() ); } }
// // Throw a chunk // void CGib::Spawn( const char *szGibModel ) { SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE ); SetFriction(0.55); // deading the bounce a bit // sometimes an entity inherits the edict from a former piece of glass, // and will spawn using the same render FX or m_nRenderMode! bad! SetRenderColorA( 255 ); m_nRenderMode = kRenderNormal; m_nRenderFX = kRenderFxNone; // hopefully this will fix the VELOCITY TOO LOW crap m_takedamage = DAMAGE_EVENTS_ONLY; SetSolid( SOLID_BBOX ); AddSolidFlags( FSOLID_NOT_STANDABLE ); SetCollisionGroup( COLLISION_GROUP_DEBRIS ); SetModel( szGibModel ); #ifdef HL1_DLL SetElasticity( 1.0 ); UTIL_SetSize( this, vec3_origin, vec3_origin ); #endif//HL1_DLL SetNextThink( gpGlobals->curtime + 4 ); m_lifeTime = 25; SetTouch ( &CGib::BounceGibTouch ); m_bForceRemove = false; m_material = matNone; m_cBloodDecals = 5;// how many blood decals this gib can place (1 per bounce until none remain). }
void CRagdollProp::FadeOutThink(void) { float dt = gpGlobals->curtime - m_flFadeOutStartTime; if ( dt < 0 ) { SetContextThink( &CRagdollProp::FadeOutThink, gpGlobals->curtime + 0.1, s_pFadeOutContext ); } else if ( dt < m_flFadeTime ) { float alpha = 1.0f - dt / m_flFadeTime; int nFade = (int)(alpha * 255.0f); m_nRenderMode = kRenderTransTexture; SetRenderColorA( nFade ); NetworkStateChanged(); SetContextThink( &CRagdollProp::FadeOutThink, gpGlobals->curtime + TICK_INTERVAL, s_pFadeOutContext ); } else { // Necessary to cause it to do the appropriate death cleanup // Yeah, the player may have nothing to do with it, but // passing NULL to TakeDamage causes bad things to happen CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); CTakeDamageInfo info( pPlayer, pPlayer, 10000.0, DMG_GENERIC ); TakeDamage( info ); UTIL_Remove( this ); } }
void CWateryDeathLeech::Spawn( void ) { Precache(); BaseClass::Spawn(); SetSolid ( SOLID_NONE ); SetMoveType( MOVETYPE_NONE ); AddEffects( EF_NOSHADOW ); SetModel( "models/leech.mdl" ); SetThink( &CWateryDeathLeech::LeechThink ); SetNextThink( gpGlobals->curtime + 0.1 ); m_flPlaybackRate = random->RandomFloat( 0.5, 1.5 ); SetCycle( random->RandomFloat( 0.0f, 0.9f ) ); QAngle vAngle; vAngle[YAW] = random->RandomFloat( 0, 360 ); SetAbsAngles( vAngle ); m_iFadeState = 1; SetRenderColorA( 1 ); }
//========================================================= // WaitTillLand - in order to emit their meaty scent from // the proper location, gibs should wait until they stop // bouncing to emit their scent. That's what this function // does. //========================================================= void CGib::WaitTillLand ( void ) { if (!IsInWorld()) { UTIL_Remove( this ); return; } if ( GetAbsVelocity() == vec3_origin ) { SetRenderColorA( 255 ); m_nRenderMode = kRenderTransTexture; if ( GetMoveType() != MOVETYPE_VPHYSICS ) { AddSolidFlags( FSOLID_NOT_SOLID ); } SetLocalAngularVelocity( vec3_angle ); SetNextThink( gpGlobals->curtime + m_lifeTime ); SetThink ( &CGib::SUB_FadeOut ); if ( GetSprite() ) { CSprite *pSprite = dynamic_cast<CSprite*>( GetSprite() ); if ( pSprite ) { //Adrian - Why am I doing this? Check InitPointGib for the answer! if ( m_lifeTime == 0 ) m_lifeTime = random->RandomFloat( 1, 3 ); pSprite->FadeAndDie( m_lifeTime ); } } if ( GetFlame() ) { CEntityFlame *pFlame = dynamic_cast< CEntityFlame*>( GetFlame() ); if ( pFlame ) { pFlame->SetLifetime( 1.0f ); } } // If you bleed, you stink! if ( m_bloodColor != DONT_BLEED ) { // ok, start stinkin! // FIXME: It's too easy to fill up the sound queue with all these meat sounds // CSoundEnt::InsertSound ( SOUND_MEAT, GetAbsOrigin(), 384, 25 ); } } else { // wait and check again in another half second. SetNextThink( gpGlobals->curtime + 0.5f ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CSprite::ExpandThink( void ) { float frametime = gpGlobals->curtime - m_flLastTime; SetSpriteScale( m_flSpriteScale + m_flSpeed * frametime ); int sub = (int)(m_iHealth * frametime); if ( sub > m_clrRender->a ) { SetRenderColorA( 0 ); Remove( ); } else { SetRenderColorA( m_clrRender->a - sub ); SetNextThink( gpGlobals->curtime ); m_flLastTime = gpGlobals->curtime; } }
void C_CFRagdoll::ClientThink() { float flFadeTime = 3.0f; float dt = gpGlobals->curtime - m_flFadeStartTime - 3; if ( dt > 0 && dt < flFadeTime ) { SetRenderMode(kRenderTransTexture); SetRenderColorA( (1.0f - dt / flFadeTime) * 255.0f ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFBaseDMPowerup::Materialize( void ) { BaseClass::Materialize(); if ( !IsDisabled() ) { EmitSound( "Item.Materialize" ); AddEffects( EF_ITEM_BLINK ); SetRenderColorA( 255 ); } }
//----------------------------------------------------------------------------- // Purpose: Override to get rid of EF_NODRAW //----------------------------------------------------------------------------- CBaseEntity* CTFBaseDMPowerup::Respawn( void ) { CBaseEntity *pRet = BaseClass::Respawn(); RemoveEffects( EF_NODRAW ); RemoveEffects( EF_ITEM_BLINK ); SetRenderColorA( 80 ); m_flRespawnAtTime = GetNextThink(); return pRet; }
//========================================================= // RunAI //========================================================= void CNPC_HAssassin::RunAI( void ) { BaseClass::RunAI(); // always visible if moving // always visible is not on hard if (g_iSkillLevel != SKILL_HARD || GetEnemy() == NULL || m_lifeState == LIFE_DEAD || GetActivity() == ACT_RUN || GetActivity() == ACT_WALK || !(GetFlags() & FL_ONGROUND)) m_iTargetRanderamt = 255; else m_iTargetRanderamt = 20; CPASAttenuationFilter filter( this ); if ( GetRenderColor().a > m_iTargetRanderamt) { if ( GetRenderColor().a == 255) { EmitSound( filter, entindex(), "HAssassin.Beamsound" ); } SetRenderColorA( max( GetRenderColor().a - 50, m_iTargetRanderamt ) ); m_nRenderMode = kRenderTransTexture; } else if ( GetRenderColor().a < m_iTargetRanderamt) { SetRenderColorA ( min( GetRenderColor().a + 50, m_iTargetRanderamt ) ); if (GetRenderColor().a == 255) m_nRenderMode = kRenderNormal; } if ( GetActivity() == ACT_RUN || GetActivity() == ACT_WALK) { static int iStep = 0; iStep = ! iStep; if (iStep) { EmitSound( filter, entindex(), "HAssassin.Footstep" ); } } }
//----------------------------------------------------------------------------- // Purpose: Burn targets around us //----------------------------------------------------------------------------- void CEntityDissolve::DissolveThink( void ) { CBaseAnimating *pTarget = ( GetMoveParent() ) ? GetMoveParent()->GetBaseAnimating() : NULL; if ( GetModelName() == NULL_STRING && pTarget == NULL ) return; if ( pTarget == NULL ) { UTIL_Remove( this ); return; } // Turn them into debris pTarget->SetCollisionGroup( COLLISION_GROUP_DISSOLVING ); if ( pTarget && pTarget->GetFlags() & FL_TRANSRAGDOLL ) { SetRenderColorA( 0 ); } float dt = gpGlobals->curtime - m_flStartTime; if ( dt < m_flFadeInStart ) { SetNextThink( m_flStartTime + m_flFadeInStart ); return; } // If we're done fading, then kill our target entity and us if ( dt >= m_flFadeOutStart + m_flFadeOutLength ) { // Necessary to cause it to do the appropriate death cleanup // Yeah, the player may have nothing to do with it, but // passing NULL to TakeDamage causes bad things to happen CBasePlayer *pPlayer = UTIL_PlayerByIndex( 1 ); int iNoPhysicsDamage = g_pGameRules->Damage_GetNoPhysicsForce(); CTakeDamageInfo info( pPlayer, pPlayer, 10000.0, DMG_GENERIC | DMG_REMOVENORAGDOLL | iNoPhysicsDamage ); pTarget->TakeDamage( info ); if ( pTarget != pPlayer ) { UTIL_Remove( pTarget ); } UTIL_Remove( this ); return; } SetNextThink( gpGlobals->curtime + TICK_INTERVAL ); }
void CNPC_HL1Barney::SUB_StartLVFadeOut( float delay, bool notSolid ) { SetThink( &CNPC_HL1Barney::SUB_LVFadeOut ); SetNextThink( gpGlobals->curtime + delay ); SetRenderColorA( 255 ); m_nRenderMode = kRenderNormal; if ( notSolid ) { AddSolidFlags( FSOLID_NOT_SOLID ); SetLocalAngularVelocity( vec3_angle ); } }
//------------------------------------------------------------------------------ // Purpose : // Input : // Output : //------------------------------------------------------------------------------ void CGrenadeEnergy::Animate( void ) { float flLifeLeft = 1-(gpGlobals->curtime - m_flLaunchTime)/ENERGY_GRENADE_LIFETIME; if (flLifeLeft < 0) { SetRenderColorA( 0 ); SetThink(NULL); UTIL_Remove(this); } SetNextThink( gpGlobals->curtime + 0.01f ); QAngle angles; VectorAngles( GetAbsVelocity(), angles ); SetLocalAngles( angles ); SetNextThink( gpGlobals->curtime + 0.1f ); StudioFrameAdvance( ); SetRenderColorA( (byte)flLifeLeft ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CEnergyWave::Spawn( void ) { Precache(); // Make it translucent m_nRenderFX = kRenderTransAlpha; SetRenderColorA( 255 ); SetSolid( SOLID_BBOX ); SetMoveType( MOVETYPE_NONE ); UTIL_SetSize( this, vec3_origin, vec3_origin ); // Think function SetNextThink( gpGlobals->curtime + 0.1f ); }
//----------------------------------------------------------------------------- void C_CHostage::ClientThink() { C_BaseCombatCharacter::ClientThink(); int speed = 2; int a = m_clrRender->a; a = max( 0, a - speed ); SetRenderColorA( a ); if ( m_clrRender->a > 0 ) { SetNextClientThink( gpGlobals->curtime + 0.001 ); } }
//----------------------------------------------------------------------------- // Purpose: Sets up the entity's initial state //----------------------------------------------------------------------------- void GhostEntity::Spawn( void ) { Precache(); if (GhostEngine::getEngine()->shouldDrawTrails()) { if (ghostData.trailLength > 0) { CreateTrail(); } } RemoveEffects(EF_NODRAW); SetModel(MODEL); SetSolid( SOLID_NONE ); SetRenderMode(kRenderTransColor); SetRenderColor(ghostData.ghostRed, ghostData.ghostGreen, ghostData.ghostBlue); SetRenderColorA(75); SetMoveType( MOVETYPE_NOCLIP ); isActive = true; }
//----------------------------------------------------------------------------- void C_LowViolenceHostageDeathModel::ClientThink( void ) { if ( m_flFadeOutStart > gpGlobals->curtime ) { return; } int iAlpha = GetRenderColor().a; iAlpha = max( iAlpha - ( g_ragdoll_fadespeed.GetInt() * gpGlobals->frametime ), 0 ); SetRenderMode( kRenderTransAlpha ); SetRenderColorA( iAlpha ); if ( iAlpha == 0 ) { Release(); } }
void CSquidSpit:: Spawn( void ) { Precache(); SetMoveType ( MOVETYPE_FLY ); SetClassname( "squidspit" ); SetSolid( SOLID_BBOX ); m_nRenderMode = kRenderTransAlpha; SetRenderColorA( 255 ); SetModel( "" ); SetSprite( CSprite::SpriteCreate( "sprites/bigspit.vmt", GetAbsOrigin(), true ) ); UTIL_SetSize( this, Vector( 0, 0, 0), Vector(0, 0, 0) ); SetCollisionGroup( HL2COLLISION_GROUP_SPIT ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_PhysPropClientside::ClientThink( void ) { if ( m_fDeathTime < 0 ) { SetNextClientThink( CLIENT_THINK_NEVER ); return; } if ( m_fDeathTime <= gpGlobals->curtime ) { Release(); // Die return; } // fade out float alpha = (m_fDeathTime - gpGlobals->curtime)/FADEOUT_TIME; SetRenderMode( kRenderTransTexture ); SetRenderColorA( alpha * 256 ); SetNextClientThink( CLIENT_THINK_ALWAYS ); }
//----------------------------------------------------------------------------- // Purpose: Burn targets around us //----------------------------------------------------------------------------- void CEntityFlame::FlameThink( void ) { // Assure that this function will be ticked again even if we early-out in the if below. SetNextThink( gpGlobals->curtime + FLAME_DAMAGE_INTERVAL ); if ( m_hEntAttached ) { if ( m_hEntAttached->GetFlags() & FL_TRANSRAGDOLL ) { SetRenderColorA( 0 ); return; } CAI_BaseNPC *pNPC = m_hEntAttached->MyNPCPointer(); if ( pNPC && !pNPC->IsAlive() ) { UTIL_Remove( this ); // Notify the NPC that it's no longer burning! pNPC->Extinguish(); return; } if( m_hEntAttached->GetWaterLevel() > 0 ) { Vector mins, maxs; mins = m_hEntAttached->WorldSpaceCenter(); maxs = mins; maxs.z = m_hEntAttached->WorldSpaceCenter().z; maxs.x += 32; maxs.y += 32; mins.z -= 32; mins.x -= 32; mins.y -= 32; UTIL_Bubbles( mins, maxs, 12 ); } } else { UTIL_Remove( this ); return; } // See if we're done burning, or our attached ent has vanished if ( m_flLifetime < gpGlobals->curtime || m_hEntAttached == NULL ) { EmitSound( "General.StopBurning" ); m_bPlayingSound = false; SetThink( &CEntityFlame::SUB_Remove ); SetNextThink( gpGlobals->curtime + 0.5f ); // Notify anything we're attached to if ( m_hEntAttached ) { CBaseCombatCharacter *pAttachedCC = m_hEntAttached->MyCombatCharacterPointer(); if( pAttachedCC ) { // Notify the NPC that it's no longer burning! pAttachedCC->Extinguish(); } } return; } if ( m_hEntAttached ) { // Do radius damage ignoring the entity I'm attached to. This will harm things around me. RadiusDamage( CTakeDamageInfo( this, this, 4.0f, DMG_BURN ), GetAbsOrigin(), m_flSize/2, CLASS_NONE, m_hEntAttached ); // Directly harm the entity I'm attached to. This is so we can precisely control how much damage the entity // that is on fire takes without worrying about the flame's position relative to the bodytarget (which is the // distance that the radius damage code uses to determine how much damage to inflict) m_hEntAttached->TakeDamage( CTakeDamageInfo( this, this, FLAME_DIRECT_DAMAGE, DMG_BURN | DMG_DIRECT ) ); if( !m_hEntAttached->IsNPC() && hl2_episodic.GetBool() ) { const int ENTITYFLAME_MOVE_AWAY_DIST = 24; // Make a sound near my origin, and up a little higher (in case I'm on the ground, so NPC's still hear it) CSoundEnt::InsertSound( SOUND_MOVE_AWAY, GetAbsOrigin(), ENTITYFLAME_MOVE_AWAY_DIST, 0.1f, this, SOUNDENT_CHANNEL_REPEATED_DANGER ); CSoundEnt::InsertSound( SOUND_MOVE_AWAY, GetAbsOrigin() + Vector( 0, 0, 48.0f ), ENTITYFLAME_MOVE_AWAY_DIST, 0.1f, this, SOUNDENT_CHANNEL_REPEATING ); } } else { RadiusDamage( CTakeDamageInfo( this, this, FLAME_RADIUS_DAMAGE, DMG_BURN ), GetAbsOrigin(), m_flSize/2, CLASS_NONE, NULL ); } FireSystem_AddHeatInRadius( GetAbsOrigin(), m_flSize/2, 2.0f ); }
void C_SDKRagdoll::ClientThink( void ) { SetNextClientThink( CLIENT_THINK_ALWAYS ); if ( m_bFadingOut == true ) { int iAlpha = GetRenderColor().a; int iFadeSpeed = 600.0f; iAlpha = max( iAlpha - ( iFadeSpeed * gpGlobals->frametime ), 0 ); SetRenderMode( kRenderTransAlpha ); SetRenderColorA( iAlpha ); if ( iAlpha == 0 ) { Release(); } return; } for( int iClient = 1; iClient <= gpGlobals->maxClients; ++iClient ) { C_SDKPlayer *pEnt = static_cast< C_SDKPlayer *> ( UTIL_PlayerByIndex( iClient ) ); if(!pEnt || !pEnt->IsPlayer()) continue; if ( m_hPlayer == NULL ) continue; if ( pEnt->entindex() == m_hPlayer->entindex() ) continue; if ( pEnt->GetHealth() <= 0 ) continue; #if defined ( SDK_USE_PRONE ) if ( pEnt->m_Shared.IsProne() == false ) continue; #endif Vector vTargetOrigin = pEnt->GetAbsOrigin(); Vector vMyOrigin = GetAbsOrigin(); Vector vDir = vTargetOrigin - vMyOrigin; if ( vDir.Length() > cl_ragdoll_pronecheck_distance.GetInt() ) continue; SetNextClientThink( CLIENT_THINK_ALWAYS ); m_bFadingOut = true; return; } //Tony; this is kind of silly, because.. whats the point of fading out? // if the player is looking at us, delay the fade if ( IsRagdollVisible() ) { StartFadeOut( 5.0 ); return; } if ( m_fDeathTime > gpGlobals->curtime ) return; Release(); // Die }
void CSDKPlayer::UpdateThirdCamera(const Vector& vecEye, const QAngle& angEye) { if (!IsInThirdPerson()) return; CWeaponSDKBase * pWeapon = NULL; if (GetActiveWeapon() != NULL){ pWeapon = GetActiveSDKWeapon(); } Assert(pWeapon); #ifdef CLIENT_DLL if (m_vecThirdCamera.DistTo(vecEye) < da_cam_fade_distance.GetFloat()){ m_flCurrentAlphaVal = Approach(da_cam_fade_alpha_val.GetFloat(), m_flCurrentAlphaVal, 500.0f * gpGlobals->frametime); if (GetRenderMode() != kRenderTransTexture){ SetRenderMode(kRenderTransTexture); } SetRenderColorA(m_flCurrentAlphaVal); if (pWeapon){ if (pWeapon->GetRenderMode() != kRenderTransTexture){ pWeapon->SetRenderMode(kRenderTransTexture); } pWeapon->SetRenderColorA(m_flCurrentAlphaVal); } }else{ m_flCurrentAlphaVal = Approach(255.0f, m_flCurrentAlphaVal, 500.0f * gpGlobals->frametime); if (GetRenderMode() != kRenderNormal){ SetRenderMode(kRenderNormal); } SetRenderColorA(m_flCurrentAlphaVal); if (pWeapon){ if (pWeapon->GetRenderMode() != kRenderNormal){ pWeapon->SetRenderMode(kRenderNormal); } pWeapon->SetRenderColorA(m_flCurrentAlphaVal); } } #endif m_vecThirdCamera = CalculateThirdPersonCameraPosition(vecEye, angEye); Vector vecShoot; AngleVectors(angEye, &vecShoot); // Trace to see where the camera is pointing trace_t tr; UTIL_TraceLine( m_vecThirdCamera, m_vecThirdCamera + vecShoot * 99999, MASK_VISIBLE|CONTENTS_DEBRIS|CONTENTS_HITBOX, this, COLLISION_GROUP_NONE, &tr ); m_vecThirdTarget = tr.endpos; }