void CGauss::SecondaryAttack() { // don't fire underwater if ( m_pPlayer->pev->waterlevel == 3 ) { if ( m_fInAttack != 0 ) { EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG(0,0x3f)); SendWeaponAnim( GAUSS_IDLE ); m_fInAttack = 0; } else { PlayEmptySound( ); } m_flNextSecondaryAttack = m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; return; } if ( m_fInAttack == 0 ) { if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) { EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM); m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; return; } m_fPrimaryFire = FALSE; m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;// take one ammo just to start the spin m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase(); // spin up m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME; SendWeaponAnim( GAUSS_SPINUP ); m_fInAttack = 1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; m_pPlayer->m_flStartCharge = gpGlobals->time; m_pPlayer->m_flAmmoStartCharge = UTIL_WeaponTimeBase() + GetFullChargeTime(); PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 110, 0, 0, 0 ); m_iSoundState = SND_CHANGE_PITCH; } else if (m_fInAttack == 1) { if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase()) { SendWeaponAnim( GAUSS_SPIN ); m_fInAttack = 2; } } else { // during the charging process, eat one bit of ammo every once in a while if ( UTIL_WeaponTimeBase() >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000 ) { #ifdef CLIENT_DLL if ( bIsMultiplayer() ) #else if ( g_pGameRules->IsMultiplayer() ) #endif { m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.1; } else { m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.3; } } if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) { // out of ammo! force the gun to fire StartFire(); m_fInAttack = 0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; return; } if ( UTIL_WeaponTimeBase() >= m_pPlayer->m_flAmmoStartCharge ) { // don't eat any more ammo after gun is fully charged. m_pPlayer->m_flNextAmmoBurn = 1000; } int pitch = ( gpGlobals->time - m_pPlayer->m_flStartCharge ) * ( 150 / GetFullChargeTime() ) + 100; if ( pitch > 250 ) pitch = 250; // ALERT( at_console, "%d %d %d\n", m_fInAttack, m_iSoundState, pitch ); if ( m_iSoundState == 0 ) ALERT( at_console, "sound state %d\n", m_iSoundState ); PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, pitch, 0, ( m_iSoundState == SND_CHANGE_PITCH ) ? 1 : 0, 0 ); m_iSoundState = SND_CHANGE_PITCH; // hack for going through level transitions m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME; // m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1; if ( m_pPlayer->m_flStartCharge < gpGlobals->time - 10 ) { // Player charged up too long. Zap him. EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG(0,0x3f)); EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/electro6.wav", 1.0, ATTN_NORM, 0, 75 + RANDOM_LONG(0,0x3f)); m_fInAttack = 0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; #ifndef CLIENT_DLL m_pPlayer->TakeDamage( VARS(eoNullEntity), VARS(eoNullEntity), 50, DMG_SHOCK ); UTIL_ScreenFade( m_pPlayer, Vector(255,128,0), 2, 0.5, 128, FFADE_IN ); #endif SendWeaponAnim( GAUSS_IDLE ); // Player may have been killed and this weapon dropped, don't execute any more code after this! return; } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponAR2::DelayedAttack( void ) { m_bShotDelayed = false; CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( pOwner == NULL ) return; // Deplete the clip completely SendWeaponAnim( ACT_VM_SECONDARYATTACK ); m_flNextSecondaryAttack = pOwner->m_flNextAttack = gpGlobals->curtime + SequenceDuration(); #ifndef CLIENT_DLL // Register a muzzleflash for the AI pOwner->DoMuzzleFlash(); pOwner->SetMuzzleFlashTime( gpGlobals->curtime + 0.5 ); #endif WeaponSound( WPN_DOUBLE ); // Fire the bullets Vector vecSrc = pOwner->Weapon_ShootPosition( ); Vector vecAiming = pOwner->GetAutoaimVector( AUTOAIM_2DEGREES ); Vector impactPoint = vecSrc + ( vecAiming * MAX_TRACE_LENGTH ); // Fire the bullets Vector vecVelocity = vecAiming * 1000.0f; #ifndef CLIENT_DLL // Fire the combine ball CreateCombineBall( vecSrc, vecVelocity, sk_weapon_ar2_alt_fire_radius.GetFloat(), sk_weapon_ar2_alt_fire_mass.GetFloat(), sk_weapon_ar2_alt_fire_duration.GetFloat(), pOwner ); // View effects color32 white = {255, 255, 255, 64}; UTIL_ScreenFade( pOwner, white, 0.1, 0, FFADE_IN ); #endif //Disorient the player QAngle angles = pOwner->GetLocalAngles(); angles.x += random->RandomInt( -4, 4 ); angles.y += random->RandomInt( -4, 4 ); angles.z = 0; // pOwner->SnapEyeAngles( angles ); pOwner->ViewPunch( QAngle( SharedRandomInt( "ar2pax", -8, -12 ), SharedRandomInt( "ar2pay", 1, 2 ), 0 ) ); // Decrease ammo pOwner->RemoveAmmo( 1, m_iSecondaryAmmoType ); // Can shoot again immediately m_flNextPrimaryAttack = gpGlobals->curtime + 0.5f; // Can blow up after a short delay (so have time to release mouse button) m_flNextSecondaryAttack = gpGlobals->curtime + 1.0f; }
/* <11c2c7> ../cstrike/dlls/observer.cpp:82 */ void UpdateClientEffects(CBasePlayer *pObserver, int oldMode) { bool clearProgress = false; bool clearBlindness = false; bool blindnessOk = (fadetoblack.value == 0); bool clearNightvision = false; if (pObserver->IsObserver() == OBS_IN_EYE) { clearProgress = true; clearBlindness = true; clearNightvision = true; if (pObserver->m_hObserverTarget->IsPlayer()) { CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(pObserver->m_hObserverTarget->entindex())); if (pPlayer) { if (pPlayer->m_progressStart && pPlayer->m_progressEnd > pPlayer->m_progressStart) { if (pPlayer->m_progressEnd > gpGlobals->time) { float percentRemaining = gpGlobals->time - pPlayer->m_progressStart; pObserver->SetProgressBarTime2((int)(pPlayer->m_progressEnd - pPlayer->m_progressStart), percentRemaining); clearProgress = false; } } if (blindnessOk && pPlayer->m_blindStartTime && pPlayer->m_blindFadeTime) { float fadeTime, holdTime, alpha, ratio; float endTime = pPlayer->m_blindFadeTime + pPlayer->m_blindHoldTime + pPlayer->m_blindStartTime; if (endTime > gpGlobals->time) { clearBlindness = false; fadeTime = pPlayer->m_blindFadeTime; alpha = (float)pPlayer->m_blindAlpha; holdTime = pPlayer->m_blindHoldTime + pPlayer->m_blindStartTime - gpGlobals->time; if (holdTime <= 0) { holdTime = 0; ratio = (endTime - gpGlobals->time) / fadeTime; alpha = pPlayer->m_blindAlpha * ratio; fadeTime = ratio * fadeTime; } UTIL_ScreenFade(pObserver, Vector(255, 255, 255), fadeTime, holdTime, alpha); } } clearNightvision = false; if (pPlayer->m_bNightVisionOn != pObserver->m_bNightVisionOn) { MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); WRITE_BYTE(pPlayer->m_bNightVisionOn ? STATUS_NIGHTVISION_ON : STATUS_NIGHTVISION_OFF); MESSAGE_END(); pObserver->m_bNightVisionOn = pPlayer->m_bNightVisionOn; } } } } else if (oldMode == OBS_IN_EYE) { clearProgress = true; clearBlindness = true; clearNightvision = true; } if (clearProgress) pObserver->SetProgressBarTime(0); if (blindnessOk && clearBlindness) UTIL_ScreenFade(pObserver, Vector(0, 0, 0), 0.001); if (clearNightvision) { MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); WRITE_BYTE(STATUS_NIGHTVISION_OFF); MESSAGE_END(); pObserver->m_bNightVisionOn = false; } }
void CWeaponStunStick::Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCharacter *pOperator ) { switch( pEvent->event ) { case EVENT_WEAPON_MELEE_HIT: { // Trace up or down based on where the enemy is... // But only if we're basically facing that direction Vector vecDirection; AngleVectors( GetAbsAngles(), &vecDirection ); CBaseEntity *pEnemy = pOperator->MyNPCPointer() ? pOperator->MyNPCPointer()->GetEnemy() : NULL; if ( pEnemy ) { Vector vecDelta; VectorSubtract( pEnemy->WorldSpaceCenter(), pOperator->Weapon_ShootPosition(), vecDelta ); VectorNormalize( vecDelta ); Vector2D vecDelta2D = vecDelta.AsVector2D(); Vector2DNormalize( vecDelta2D ); if ( DotProduct2D( vecDelta2D, vecDirection.AsVector2D() ) > 0.8f ) { vecDirection = vecDelta; } } Vector vecEnd; VectorMA( pOperator->Weapon_ShootPosition(), 32, vecDirection, vecEnd ); // Stretch the swing box down to catch low level physics objects CBaseEntity *pHurt = pOperator->CheckTraceHullAttack( pOperator->Weapon_ShootPosition(), vecEnd, Vector(-16,-16,-40), Vector(16,16,16), GetDamageForActivity( GetActivity() ), DMG_CLUB, 0.5f, false ); // did I hit someone? if ( pHurt ) { // play sound WeaponSound( MELEE_HIT ); CBasePlayer *pPlayer = ToBasePlayer( pHurt ); #ifdef SecobMod__Enable_Fixed_Multiplayer_AI CNPC_MetroPolice *pCop = dynamic_cast<CNPC_MetroPolice *>(pOperator); #endif //SecobMod__Enable_Fixed_Multiplayer_AI bool bFlashed = false; #ifdef SecobMod__Enable_Fixed_Multiplayer_AI if ( pCop != NULL && pPlayer != NULL ) { // See if we need to knock out this target if ( pCop->ShouldKnockOutTarget( pHurt ) ) { float yawKick = random->RandomFloat( -48, -24 ); //Kick the player angles pPlayer->ViewPunch( QAngle( -16, yawKick, 2 ) ); color32 white = {255,255,255,255}; UTIL_ScreenFade( pPlayer, white, 0.2f, 1.0f, FFADE_OUT|FFADE_PURGE|FFADE_STAYOUT ); bFlashed = true; pCop->KnockOutTarget( pHurt ); break; } else { // Notify that we've stunned a target pCop->StunnedTarget( pHurt ); } } #endif //SecobMod__Enable_Fixed_Multiplayer_AI // Punch angles if ( pPlayer != NULL && !(pPlayer->GetFlags() & FL_GODMODE) ) { float yawKick = random->RandomFloat( -48, -24 ); //Kick the player angles pPlayer->ViewPunch( QAngle( -16, yawKick, 2 ) ); Vector dir = pHurt->GetAbsOrigin() - GetAbsOrigin(); // If the player's on my head, don't knock him up if ( pPlayer->GetGroundEntity() == pOperator ) { dir = vecDirection; dir.z = 0; } VectorNormalize(dir); dir *= 500.0f; //If not on ground, then don't make them fly! if ( !(pPlayer->GetFlags() & FL_ONGROUND ) ) dir.z = 0.0f; //Push the target back pHurt->ApplyAbsVelocityImpulse( dir ); if ( !bFlashed ) { color32 red = {128,0,0,128}; UTIL_ScreenFade( pPlayer, red, 0.5f, 0.1f, FFADE_IN ); } // Force the player to drop anyting they were holding pPlayer->ForceDropOfCarriedPhysObjects(); } // do effect? } else { WeaponSound( MELEE_MISS ); } } break; default: BaseClass::Operator_HandleAnimEvent( pEvent, pOperator ); break; } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CNPC_Ichthyosaur::Bite( void ) { //Don't allow another bite too soon if ( m_flNextBiteTime > gpGlobals->curtime ) return; CBaseEntity *pHurt; //FIXME: E3 HACK - Always damage bullseyes if we're scripted to hit them if ( ( GetEnemy() != NULL ) && ( GetEnemy()->Classify() == CLASS_BULLSEYE ) ) { pHurt = GetEnemy(); } else { pHurt = CheckTraceHullAttack( 108, Vector(-32,-32,-32), Vector(32,32,32), 0, DMG_CLUB ); } //Hit something if ( pHurt != NULL ) { CTakeDamageInfo info( this, this, sk_ichthyosaur_melee_dmg.GetInt(), DMG_CLUB ); if ( pHurt->IsPlayer() ) { CBasePlayer *pPlayer = ToBasePlayer( pHurt ); if ( pPlayer ) { if ( ( ( m_flHoldTime < gpGlobals->curtime ) && ( pPlayer->m_iHealth < (pPlayer->m_iMaxHealth*0.5f)) ) || ( pPlayer->GetWaterLevel() < 1 ) ) { //EnsnareVictim( pHurt ); } else { info.SetDamage( sk_ichthyosaur_melee_dmg.GetInt() * 3 ); } CalculateMeleeDamageForce( &info, GetAbsVelocity(), pHurt->GetAbsOrigin() ); pHurt->TakeDamage( info ); color32 red = {64, 0, 0, 255}; UTIL_ScreenFade( pPlayer, red, 0.5, 0, FFADE_IN ); //Disorient the player QAngle angles = pPlayer->GetLocalAngles(); angles.x += random->RandomInt( 60, 25 ); angles.y += random->RandomInt( 60, 25 ); angles.z = 0.0f; pPlayer->SetLocalAngles( angles ); pPlayer->SnapEyeAngles( angles ); } } else { CalculateMeleeDamageForce( &info, GetAbsVelocity(), pHurt->GetAbsOrigin() ); pHurt->TakeDamage( info ); } m_flNextBiteTime = gpGlobals->curtime + random->RandomFloat( 2.0f, 4.0f ); //Bubbles! UTIL_Bubbles( pHurt->GetAbsOrigin()+Vector(-32.0f,-32.0f,-32.0f), pHurt->GetAbsOrigin()+Vector(32.0f,32.0f,0.0f), random->RandomInt( 16, 32 ) ); // Play a random attack hit sound EmitSound( "NPC_Ichthyosaur.Bite" ); if ( GetActivity() == ACT_MELEE_ATTACK1 ) { SetActivity( (Activity) ACT_ICH_BITE_HIT ); } return; } //Play the miss animation and sound if ( GetActivity() == ACT_MELEE_ATTACK1 ) { SetActivity( (Activity) ACT_ICH_BITE_MISS ); } //Miss sound EmitSound( "NPC_Ichthyosaur.BiteMiss" ); }
//----------------------------------------------------------------------------- // Purpose: Manhack is still dangerous when dead // Input : // Output : //----------------------------------------------------------------------------- void CPlayer_Missile::FlyThink() { SetNextThink( gpGlobals->curtime ); // ------------------- // Get the player // ------------------- CBasePlayer* pPlayer = UTIL_PlayerByIndex( 1 ); if (!pPlayer) return; // --------------------------------------------------- // Calulate amount of xturn from player mouse movement // --------------------------------------------------- QAngle vecViewAngles = pPlayer->EyeAngles(); float xLev; if (vecViewAngles.x < 180) { xLev = vecViewAngles.x/180; } else { xLev = (vecViewAngles.x-360)/180; } // --------------------------------------------------- // Calulate amount of xturn from player mouse movement // --------------------------------------------------- float yLev; // Keep yaw in bounds (don't let loop) if (vecViewAngles.y > 90) { if (vecViewAngles.y < 180) { pPlayer->SetLocalAngles( QAngle( vecViewAngles.x - 360, 90, 0 ) ); QAngle newViewAngles = vecViewAngles; newViewAngles.y = 90; pPlayer->SnapEyeAngles( newViewAngles ); } else if (vecViewAngles.y < 270) { pPlayer->SetLocalAngles( QAngle( vecViewAngles.x, 270, 0 ) ); QAngle newViewAngles = vecViewAngles; newViewAngles.y = 270; pPlayer->SnapEyeAngles( newViewAngles ); } } if (vecViewAngles.y < 180) { yLev = vecViewAngles.y/180; } else { yLev = (vecViewAngles.y-360)/180; } //<<TEMP.>> this is a temp HUD until we create a real one on the client NDebugOverlay::ScreenText( 0.5, 0.5+0.2*xLev, "|", 255, 0, 0, 255, 0.0); NDebugOverlay::ScreenText( 0.5-(0.1*yLev), 0.5, "=", 255, 0, 0, 255, 0.0); NDebugOverlay::ScreenText( 0.5-(0.1*yLev), 0.5+0.2*xLev, "*", 255, 0, 0, 255, 0.0); NDebugOverlay::ScreenText( 0.45, 0.5, "-----------------------", 0, 255, 0, 255, 0.0); NDebugOverlay::ScreenText( 0.5, 0.425, "|", 0, 255, 0, 255, 0.0); NDebugOverlay::ScreenText( 0.5, 0.45, "|", 0, 255, 0, 255, 0.0); NDebugOverlay::ScreenText( 0.5, 0.475, "|", 0, 255, 0, 255, 0.0); NDebugOverlay::ScreenText( 0.5, 0.5, "|", 0, 255, 0, 255, 0.0); NDebugOverlay::ScreenText( 0.5, 0.525, "|", 0, 255, 0, 255, 0.0); NDebugOverlay::ScreenText( 0.5, 0.55, "|", 0, 255, 0, 255, 0.0); NDebugOverlay::ScreenText( 0.5, 0.575, "|", 0, 255, 0, 255, 0.0); // Add in turn Vector vRight,vUp; AngleVectors( GetLocalAngles(), 0, &vRight,&vUp); QAngle angles = GetLocalAngles(); angles.x += PMISSILE_TURN_RATE*xLev*gpGlobals->frametime; angles.y += PMISSILE_TURN_RATE*yLev*gpGlobals->frametime; if (m_bShake) { angles.x += random->RandomFloat(-3.0,3.0); angles.y += random->RandomFloat(-3.0,3.0); m_bShake = false; } SetLocalAngles( angles ); // Reset velocity Vector vVelocity; AngleVectors( GetLocalAngles(), &vVelocity); SetAbsVelocity( vVelocity*PMISSILE_SPEED ); // Add some screen noise float flClipDist = PlayerControlClipDistance(); if (flClipDist < PMISSILE_LOSE_CONTROL_DIST) { LoseMissileControl(); } // Average static over time float flStatic = 255*(1-flClipDist/PCONTROL_CLIP_DIST); m_flStatic = 0.9*m_flStatic + 0.1*flStatic; color32 white = {255,255,255,m_flStatic}; UTIL_ScreenFade( pPlayer, white, 0.01, 0.1, FFADE_MODULATE ); // Insert danger sound so NPCs run away from me if (gpGlobals->curtime > m_flNextDangerTime) { CSoundEnt::InsertSound ( SOUND_DANGER, GetAbsOrigin(), 2000, PMISSILE_DANGER_SOUND_DURATION ); m_flNextDangerTime = gpGlobals->curtime + PMISSILE_DANGER_SOUND_DURATION; } }
bool CObjectTunnelTrigger::KeepTunneling( TunnelPlayer *tunnel ) { if ( !tunnel || ( tunnel->player == NULL ) ) { return false; } float remaining = tunnel->teleporttime - gpGlobals->curtime + 0.5f; remaining = max( 0.0f, remaining ); tunnel->iremaining = (int)( remaining ); if ( !tunnel->exitstarted ) { if ( gpGlobals->curtime > tunnel->fadeintime ) { tunnel->exitstarted = true; // Fade user screen to black color32 black = {0,0,0,255}; UTIL_ScreenFade( tunnel->player, black, tunnel->fadetime, 0.0, FFADE_IN | FFADE_PURGE ); // Move to tunnel exit spot now that we're half-way through teleport if ( m_hTunnelExit != NULL ) { tunnel->player->EnableControl( true ); tunnel->player->RemoveEffects( EF_NODRAW ); // Change the player to non-solid before the teleport, so the physics system doesn't think he // actually moved this distance: int OriginalSolidFlags = tunnel->player->GetSolidFlags(); tunnel->player->AddSolidFlags( FSOLID_NOT_SOLID); // Do a placement test to prevent the player from teleporting inside another player, the ground, or just to help // prevent badly placed tunnels from causing stuck situations. Vector vTarget = m_hTunnelExit->GetAbsOrigin(); Vector vOriginal = vTarget; if ( !EntityPlacementTest( tunnel->player, vOriginal, vTarget, true ) ) { Warning("Couldn't place entity after tunnel teleport.\n"); } tunnel->player->Teleport( &vTarget /*m_hTunnelExit->GetAbsOrigin()*/, &m_hTunnelExit->GetAbsAngles(), NULL ); tunnel->player->SnapEyeAngles( m_hTunnelExit->GetAbsAngles() ); tunnel->player->SetAbsVelocity( vec3_origin ); // Restore the player's solid flags. tunnel->player->SetSolidFlags(OriginalSolidFlags); } } // Can't quite do this because the player's weapons are still visible flying across the map even if // he is hidden #if 0 else if ( gpGlobals->curtime > tunnel->tunnelstarted + tunnel->fadetime ) { float travel_time = tunnel->duration - 2 * tunnel->fadetime; if ( travel_time > 0.0f ) { float f = ( gpGlobals->curtime - tunnel->tunnelstarted - tunnel->fadetime ) / travel_time; f = clamp( f, 0.0f, 1.0f ); if ( m_hTunnelExit != NULL ) { Vector delta = m_hTunnelExit->GetAbsOrigin() - tunnel->startpos; Vector currentPos; VectorMA( tunnel->startpos, f, delta, currentPos ); tunnel->player->Teleport( ¤tPos, NULL, NULL ); } } } #endif } if ( tunnel->ilastremaining != tunnel->iremaining && tunnel->needremainigcounter && tunnel->iremaining >= 1 && tunnel->player != NULL ) { // Counter ClientPrint( tunnel->player, HUD_PRINTCENTER, UTIL_VarArgs("\nExiting tunnel in %d %s\n", tunnel->iremaining, tunnel->iremaining > 1 ? "seconds" : "second" ) ); } tunnel->ilastremaining = tunnel->iremaining; // TODO: Play footstep or some other teleport sounds occasionaly to this player? bool done = ( gpGlobals->curtime > tunnel->teleporttime ) ? true : false; if ( done ) { color32 black = {0,0,0,255}; UTIL_ScreenFade( tunnel->player, black, 0.0f, 0.0f, FFADE_IN | FFADE_PURGE ); tunnel->player->SetMoveType( MOVETYPE_WALK ); tunnel->player->EnableControl( true ); tunnel->player->RemoveEffects( EF_NODRAW ); tunnel->player->RemoveSolidFlags( FSOLID_NOT_SOLID ); // TODO: Play an exit sound?? OnTunnelTriggerEnd.FireOutput( tunnel->player, this ); } return !done; }
void CSDKPlayer::PostThink() { BaseClass::PostThink(); // Keep the model upright; pose params will handle pitch aiming. QAngle angles = GetLocalAngles(); angles[PITCH] = 0; SetLocalAngles(angles); if ( m_flNextMouseoverUpdate < gpGlobals->curtime ) { m_flNextMouseoverUpdate = gpGlobals->curtime + 0.2f; if ( m_bShowHints ) { #ifdef PLAYER_MOUSEOVER_HINTS UpdateMouseoverHints(); #endif } } #ifdef PLAYER_HEALTH_REGEN // Regenerate heath after 3 seconds if ( IsAlive() && GetHealth() < GetMaxHealth() ) { // Color to overlay on the screen while the player is taking damage color32 hurtScreenOverlay = {64,0,0,64}; if ( gpGlobals->curtime > m_fTimeLastHurt + sv_regeneration_wait_time.GetFloat() ) { TakeHealth( 1, DMG_GENERIC ); m_bIsRegenerating = true; if ( GetHealth() >= GetMaxHealth() ) { m_bIsRegenerating = false; } } else { m_bIsRegenerating = false; UTIL_ScreenFade( this, hurtScreenOverlay, 1.0f, 0.1f, FFADE_IN|FFADE_PURGE ); } } #else // HACK!: Make it so that when we fall, we show red! if ( IsAlive() && GetHealth() < GetMaxHealth() ) { // Color to overlay on the screen while the player is taking damage color32 hurtScreenOverlay = {64,0,0,64}; if ( gpGlobals->curtime > m_fTimeLastHurt + sv_regeneration_wait_time.GetFloat() ) { if ( GetHealth() >= GetMaxHealth() ) { // Nothing at all??? } } else { UTIL_ScreenFade( this, hurtScreenOverlay, 1.0f, 0.1f, FFADE_IN|FFADE_PURGE ); } } #endif }
//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- void CObjectTeleporter::TeleporterThink( void ) { SetContextThink( &CObjectTeleporter::TeleporterThink, gpGlobals->curtime + BUILD_TELEPORTER_NEXT_THINK, TELEPORTER_THINK_CONTEXT ); // At any point, if our match is not ready, revert to IDLE if ( IsDisabled() || IsMatchingTeleporterReady() == false ) { if ( GetState() != TELEPORTER_STATE_IDLE ) { SetState( TELEPORTER_STATE_IDLE ); ShowDirectionArrow( false ); } return; } if ( m_flMyNextThink && m_flMyNextThink > gpGlobals->curtime ) return; // pMatch is not NULL and is not building CObjectTeleporter *pMatch = GetMatchingTeleporter(); Assert( pMatch ); Assert( pMatch->m_iState != TELEPORTER_STATE_BUILDING ); switch ( m_iState ) { // Teleporter is not yet active, do nothing case TELEPORTER_STATE_BUILDING: break; default: case TELEPORTER_STATE_IDLE: // Do we have a match that is active? if ( IsMatchingTeleporterReady() ) { SetState( TELEPORTER_STATE_READY ); EmitSound( "Building_Teleporter.Ready" ); if ( GetType() == OBJ_TELEPORTER_ENTRANCE ) { ShowDirectionArrow( true ); } } break; case TELEPORTER_STATE_READY: break; case TELEPORTER_STATE_SENDING: { pMatch->TeleporterReceive( m_hTeleportingPlayer, 1.0 ); m_flRechargeTime = gpGlobals->curtime + ( BUILD_TELEPORTER_FADEOUT_TIME + BUILD_TELEPORTER_FADEIN_TIME + TELEPORTER_RECHARGE_TIME ); // change state to recharging... SetState( TELEPORTER_STATE_RECHARGING ); } break; case TELEPORTER_STATE_RECEIVING: { // get the position we'll move the player to Vector newPosition = GetAbsOrigin(); newPosition.z += TELEPORTER_MAXS.z + 1; // Telefrag anyone in the way CBaseEntity *pEnts[256]; Vector mins, maxs; Vector expand( 4, 4, 4 ); mins = newPosition + VEC_HULL_MIN - expand; maxs = newPosition + VEC_HULL_MAX + expand; CTFPlayer *pTeleportingPlayer = m_hTeleportingPlayer.Get(); // move the player if ( pTeleportingPlayer ) { CUtlVector<CBaseEntity*> hPlayersToKill; bool bClear = true; // Telefrag any players in the way int numEnts = UTIL_EntitiesInBox( pEnts, 256, mins, maxs, 0 ); if ( numEnts ) { //Iterate through the list and check the results for ( int i = 0; i < numEnts && bClear; i++ ) { if ( pEnts[i] == NULL ) continue; if ( pEnts[i] == this ) continue; // kill players and NPCs if ( pEnts[i]->IsPlayer() || pEnts[i]->IsNPC() ) { if ( !pTeleportingPlayer->InSameTeam(pEnts[i]) ) { hPlayersToKill.AddToTail( pEnts[i] ); } continue; } if ( pEnts[i]->IsBaseObject() ) continue; // Solid entities will prevent a teleport if ( pEnts[i]->IsSolid() && pEnts[i]->ShouldCollide( pTeleportingPlayer->GetCollisionGroup(), MASK_ALL ) && g_pGameRules->ShouldCollide( pTeleportingPlayer->GetCollisionGroup(), pEnts[i]->GetCollisionGroup() ) ) { // We're going to teleport into something solid. Abort & destroy this exit. bClear = false; } } } if ( bClear ) { // Telefrag all enemy players we've found for ( int player = 0; player < hPlayersToKill.Count(); player++ ) { hPlayersToKill[player]->TakeDamage( CTakeDamageInfo( pTeleportingPlayer, this, 1000, DMG_CRUSH ) ); } pTeleportingPlayer->Teleport( &newPosition, &(GetAbsAngles()), &vec3_origin ); // Unzoom if we are a sniper zoomed! if ( ( pTeleportingPlayer->GetPlayerClass()->GetClassIndex() == TF_CLASS_SNIPER ) && pTeleportingPlayer->m_Shared.InCond( TF_COND_AIMING ) ) { CTFWeaponBase *pWpn = pTeleportingPlayer->GetActiveTFWeapon(); if ( pWpn && pWpn->GetWeaponID() == TF_WEAPON_SNIPERRIFLE ) { CTFSniperRifle *pRifle = static_cast<CTFSniperRifle*>( pWpn ); pRifle->ToggleZoom(); } } pTeleportingPlayer->SetFOV( pTeleportingPlayer, 0, tf_teleporter_fov_time.GetFloat(), tf_teleporter_fov_start.GetInt() ); color32 fadeColor = {255,255,255,100}; UTIL_ScreenFade( pTeleportingPlayer, fadeColor, 0.25, 0.4, FFADE_IN ); } else { DetonateObject(); } } SetState( TELEPORTER_STATE_RECEIVING_RELEASE ); m_flMyNextThink = gpGlobals->curtime + ( BUILD_TELEPORTER_FADEIN_TIME ); } break; case TELEPORTER_STATE_RECEIVING_RELEASE: { CTFPlayer *pTeleportingPlayer = m_hTeleportingPlayer.Get(); if ( pTeleportingPlayer ) { pTeleportingPlayer->TeleportEffect(); pTeleportingPlayer->m_Shared.RemoveCond( TF_COND_SELECTED_TO_TELEPORT ); CTF_GameStats.Event_PlayerUsedTeleport( GetBuilder(), pTeleportingPlayer ); pTeleportingPlayer->SpeakConceptIfAllowed( MP_CONCEPT_TELEPORTED ); } // reset the pointers to the player now that we're done teleporting SetTeleportingPlayer( NULL ); pMatch->SetTeleportingPlayer( NULL ); SetState( TELEPORTER_STATE_RECHARGING ); m_flMyNextThink = gpGlobals->curtime + ( TELEPORTER_RECHARGE_TIME ); } break; case TELEPORTER_STATE_RECHARGING: // If we are finished recharging, go active if ( gpGlobals->curtime > m_flRechargeTime ) { SetState( TELEPORTER_STATE_READY ); EmitSound( "Building_Teleporter.Ready" ); } break; } }