//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CAI_RappelBehavior::CreateZipline() { #if 1 if( !m_hLine ) { int attachment = GetOuter()->LookupAttachment( "zipline" ); if( attachment != -1 ) { CBeam *pBeam; pBeam = CBeam::BeamCreate( "cable/cable.vmt", 1 ); pBeam->SetColor( 150, 150, 150 ); pBeam->SetWidth( 0.3 ); pBeam->SetEndWidth( 0.3 ); CAI_BaseNPC *pNPC = GetOuter(); pBeam->PointEntInit( pNPC->GetAbsOrigin() + Vector( 0, 0, 80 ), pNPC ); pBeam->SetEndAttachment( attachment ); m_hLine.Set( pBeam ); } } #endif }
void CWeaponMomentumGun::DrawBeam(const Vector &startPos, const Vector &endPos, float width) { //Tracer down the middle UTIL_Tracer(startPos, endPos, 0, TRACER_DONT_USE_ATTACHMENT, 6500, false, "GaussTracer"); //Draw the main beam shaft CBeam *pBeam = CBeam::BeamCreate("sprites/orangelight1.vmt", 15.5); // It starts at startPos pBeam->SetStartPos(startPos); // This sets up some things that the beam uses to figure out where // it should start and end pBeam->PointEntInit(endPos, this); // This makes it so that the laser appears to come from the muzzle of the pistol pBeam->SetEndAttachment(LookupAttachment("Muzzle")); pBeam->SetWidth(width); // pBeam->SetEndWidth( 0.05f ); // Higher brightness means less transparent pBeam->SetBrightness(255); pBeam->SetColor(255, 185 + random->RandomInt(-16, 16), 40); pBeam->RelinkBeam(); // The beam should only exist for a very short time pBeam->LiveForTime(0.1f); }
//----------------------------------------------------------------------------- // Purpose: // Input : &startPos - // &endPos - // width - // useMuzzle - //----------------------------------------------------------------------------- void CASW_PropJeep::DrawBeam( const Vector &startPos, const Vector &endPos, float width ) { //Tracer down the middle UTIL_Tracer( startPos, endPos, 0, TRACER_DONT_USE_ATTACHMENT, 6500, false, "GaussTracer" ); //Draw the main beam shaft CBeam *pBeam = CBeam::BeamCreate( GAUSS_BEAM_SPRITE, 0.5 ); pBeam->SetStartPos( startPos ); pBeam->PointEntInit( endPos, this ); pBeam->SetEndAttachment( LookupAttachment("Muzzle") ); pBeam->SetWidth( width ); pBeam->SetEndWidth( 0.05f ); pBeam->SetBrightness( 255 ); pBeam->SetColor( 255, 185+random->RandomInt( -16, 16 ), 40 ); pBeam->RelinkBeam(); pBeam->LiveForTime( 0.1f ); //Draw electric bolts along shaft pBeam = CBeam::BeamCreate( GAUSS_BEAM_SPRITE, 3.0f ); pBeam->SetStartPos( startPos ); pBeam->PointEntInit( endPos, this ); pBeam->SetEndAttachment( LookupAttachment("Muzzle") ); pBeam->SetBrightness( random->RandomInt( 64, 255 ) ); pBeam->SetColor( 255, 255, 150+random->RandomInt( 0, 64 ) ); pBeam->RelinkBeam(); pBeam->LiveForTime( 0.1f ); pBeam->SetNoise( 1.6f ); pBeam->SetEndWidth( 0.1f ); }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CNPC_GroundTurret::ProjectBeam( const Vector &vecStart, const Vector &vecDir, int width, int brightness, float duration ) { CBeam *pBeam; pBeam = CBeam::BeamCreate( GROUNDTURRET_BEAM_SPRITE, width ); if ( !pBeam ) return; trace_t tr; AI_TraceLine( vecStart, vecStart + vecDir * m_flSensingDist, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr ); pBeam->SetStartPos( tr.endpos ); pBeam->SetEndPos( tr.startpos ); pBeam->SetWidth( width ); pBeam->SetEndWidth( 0.1 ); pBeam->SetFadeLength( 16 ); pBeam->SetBrightness( brightness ); pBeam->SetColor( 0, 145+random->RandomInt( -16, 16 ), 255 ); pBeam->RelinkBeam(); pBeam->LiveForTime( duration ); }
//--------------------------------------------------------- //--------------------------------------------------------- void CNPC_GroundTurret::MakeTracer( const Vector &vecTracerSrc, const trace_t &tr, int iTracerType ) { #if 1 //BaseClass::MakeTracer( vecTracerSrc, tr, iTracerType ); UTIL_Tracer( vecTracerSrc, tr.endpos, 0, TRACER_DONT_USE_ATTACHMENT, 5000, true, "AR2Tracer" ); #else CBeam *pBeam; int width = 2; pBeam = CBeam::BeamCreate( GROUNDTURRET_BEAM_SPRITE, width ); if ( !pBeam ) return; pBeam->SetStartPos( vecTracerSrc ); pBeam->SetEndPos( tr.endpos ); pBeam->SetWidth( width ); pBeam->SetEndWidth( width / 4.0f ); pBeam->SetBrightness( 100 ); pBeam->SetColor( 0, 145+random->RandomInt( -16, 16 ), 255 ); pBeam->RelinkBeam(); pBeam->LiveForTime( random->RandomFloat( 0.2f, 0.5f ) ); #endif }
void CEgon::UpdateEffect( const Vector &startPoint, const Vector &endPoint, float timeBlend ) { if ( !m_pBeam ) { CreateEffect(); } m_pBeam->SetStartPos( endPoint ); m_pBeam->SetBrightness( 255 - (timeBlend*180) ); m_pBeam->SetWidth( 40 - (timeBlend*20) ); if ( m_fireMode == FIRE_WIDE ) m_pBeam->SetColor( 30 + (25*timeBlend), 30 + (30*timeBlend), 64 + 80*fabs(sin(gpGlobals->time*10)) ); else m_pBeam->SetColor( 60 + (25*timeBlend), 120 + (30*timeBlend), 64 + 80*fabs(sin(gpGlobals->time*10)) ); UTIL_SetOrigin( m_pSprite->pev, endPoint ); m_pSprite->pev->frame += 8 * gpGlobals->frametime; if ( m_pSprite->pev->frame > m_pSprite->Frames() ) m_pSprite->pev->frame = 0; m_pNoise->SetStartPos( endPoint ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponGaussGun::DrawBeam( const Vector &startPos, const Vector &endPos, float width, bool useMuzzle ) { CBasePlayer *pOwner = ToBasePlayer(GetOwner()); if (!pOwner) return; //Check to store off our view model index if (m_hViewModel == NULL) { CBaseViewModel *vm = pOwner->GetViewModel(); if (vm) m_hViewModel.Set(vm); } //Draw the main beam shaft CBeam *pBeam = CBeam::BeamCreate( GAUSS_BEAM_SPRITE, width ); if ( useMuzzle ) { pBeam->PointEntInit( endPos, m_hViewModel ); pBeam->SetEndAttachment( 1 ); pBeam->SetWidth( width / 4.0f ); pBeam->SetEndWidth( width ); } else { pBeam->SetStartPos( startPos ); pBeam->SetEndPos( endPos ); pBeam->SetWidth( width ); pBeam->SetEndWidth( width / 4.0f ); } pBeam->SetBrightness( 255 ); pBeam->SetColor( 255, 145+random->RandomInt( -16, 16 ), 0 ); pBeam->RelinkBeam(); pBeam->LiveForTime( 0.1f ); //Draw electric bolts along shaft for ( int i = 0; i < 3; i++ ) { pBeam = CBeam::BeamCreate( GAUSS_BEAM_SPRITE, (width/2.0f) + i ); if ( useMuzzle ) { pBeam->PointEntInit( endPos, m_hViewModel ); pBeam->SetEndAttachment( 1 ); } else { pBeam->SetStartPos( startPos ); pBeam->SetEndPos( endPos ); } pBeam->SetBrightness( random->RandomInt( 64, 255 ) ); pBeam->SetColor( 255, 255, 150+random->RandomInt( 0, 64 ) ); pBeam->RelinkBeam(); pBeam->LiveForTime( 0.1f ); pBeam->SetNoise( 1.6f * i ); pBeam->SetEndWidth( 0.1f ); } }
void CTestEffect::TestThink( void ) { int i; float t = (gpGlobals->time - m_flStartTime); if (m_iBeam < 24) { CBeam *pbeam = CBeam::BeamCreate( "sprites/lgtning.spr", 100 ); TraceResult tr; Vector vecSrc = pev->origin; Vector vecDir = Vector( RANDOM_FLOAT( -1.0, 1.0 ), RANDOM_FLOAT( -1.0, 1.0 ),RANDOM_FLOAT( -1.0, 1.0 ) ); vecDir = vecDir.Normalize(); UTIL_TraceLine( vecSrc, vecSrc + vecDir * 128, ignore_monsters, ENT(pev), &tr); pbeam->PointsInit( vecSrc, tr.vecEndPos ); // pbeam->SetColor( 80, 100, 255 ); pbeam->SetColor( 255, 180, 100 ); pbeam->SetWidth( 100 ); pbeam->SetScrollRate( 12 ); m_flBeamTime[m_iBeam] = gpGlobals->time; m_pBeam[m_iBeam] = pbeam; m_iBeam++; #if 0 Vector vecMid = (vecSrc + tr.vecEndPos) * 0.5; MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE(TE_DLIGHT); WRITE_COORD(vecMid.x); // X WRITE_COORD(vecMid.y); // Y WRITE_COORD(vecMid.z); // Z WRITE_BYTE( 20 ); // radius * 0.1 WRITE_BYTE( 255 ); // r WRITE_BYTE( 180 ); // g WRITE_BYTE( 100 ); // b WRITE_BYTE( 20 ); // time * 10 WRITE_BYTE( 0 ); // decay * 0.1 MESSAGE_END( ); #endif } if (t < 3.0) { for (i = 0; i < m_iBeam; i++) { t = (gpGlobals->time - m_flBeamTime[i]) / ( 3 + m_flStartTime - m_flBeamTime[i]); m_pBeam[i]->SetBrightness( 255 * t ); // m_pBeam[i]->SetScrollRate( 20 * t ); } pev->nextthink = gpGlobals->time + 0.1; } else { for (i = 0; i < m_iBeam; i++) { UTIL_Remove( m_pBeam[i] ); } m_flStartTime = gpGlobals->time; m_iBeam = 0; // pev->nextthink = gpGlobals->time; SetThink( NULL ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFGrenadeEmpProjectile::Detonate() { if ( ShouldNotDetonate() ) { RemoveGrenade(); return; } // Explosion effect on client // SendDispatchEffect(); float flRadius = 180; float flDamage = 1; if ( tf_grenade_show_radius.GetBool() ) { DrawRadius( flRadius ); } // Apply some amount of EMP damage to every entity in the radius. They will calculate // their own damage based on how much ammo they have or some other wacky calculation. CTakeDamageInfo info( this, GetThrower(), vec3_origin, GetAbsOrigin(), flDamage, /* DMG_EMP |*/ DMG_PREVENT_PHYSICS_FORCE ); CBaseEntity *pEntityList[100]; int nEntityCount = UTIL_EntitiesInSphere( pEntityList, 100, GetAbsOrigin(), flRadius, 0 ); int iEntity; for ( iEntity = 0; iEntity < nEntityCount; ++iEntity ) { CBaseEntity *pEntity = pEntityList[iEntity]; if ( pEntity == this ) continue; if ( pEntity && pEntity->IsPlayer() ) continue; if ( pEntity && ( pEntity->m_takedamage == DAMAGE_YES || pEntity->m_takedamage == DAMAGE_EVENTS_ONLY ) ) { pEntity->TakeDamage( info ); //if ( pEntity->IsPlayer() /* || is ammo box || is enemy object */ ) { CBeam *pBeam = CBeam::BeamCreate( "sprites/physcannon_bluelight1b.vmt", 3.0 ); if ( !pBeam ) return; pBeam->PointsInit( GetAbsOrigin(), pEntity->WorldSpaceCenter() ); pBeam->SetColor( 255, 255, 255 ); pBeam->SetBrightness( 128 ); pBeam->SetNoise( 12.0f ); pBeam->SetEndWidth( 3.0f ); pBeam->SetWidth( 3.0f ); pBeam->LiveForTime( 0.5f ); // Fail-safe pBeam->SetFrameRate( 25.0f ); pBeam->SetFrame( random->RandomInt( 0, 2 ) ); } } } DispatchParticleEffect( "emp_shockwave", GetAbsOrigin(), vec3_angle ); UTIL_Remove( this ); #if 0 // Tell the bots an HE grenade has exploded CTFPlayer *pPlayer = ToTFPlayer( GetThrower() ); if ( pPlayer ) { KeyValues *pEvent = new KeyValues( "tf_weapon_grenade_detonate" ); pEvent->SetInt( "userid", pPlayer->GetUserID() ); gameeventmanager->FireEventServerOnly( pEvent ); } #endif }
void CNPC_Dog::ThrowObject( const char *pAttachmentName ) { if ( m_hPhysicsEnt ) { m_bHasObject = false; IPhysicsObject *pPhysObj = m_hPhysicsEnt->VPhysicsGetObject(); if ( pPhysObj ) { Vector vGunPos; QAngle angGunAngles; AngularImpulse angVelocity = RandomAngularImpulse( -250 , -250 ) / pPhysObj->GetMass(); InvalidateBoneCache(); int iAttachment = LookupAttachment( pAttachmentName ); if ( iAttachment == 0 ) iAttachment = m_iPhysGunAttachment; GetAttachment( iAttachment, vGunPos, angGunAngles ); pPhysObj->Wake(); if ( pPhysObj->GetShadowController() ) { m_hPhysicsEnt->SetParent( NULL ); m_hPhysicsEnt->SetMoveType( (MoveType_t)m_iContainerMoveType ); m_hPhysicsEnt->SetOwnerEntity( this ); pPhysObj->RemoveShadowController(); pPhysObj->SetPosition( m_hPhysicsEnt->GetLocalOrigin(), m_hPhysicsEnt->GetLocalAngles(), true ); pPhysObj->RecheckCollisionFilter(); pPhysObj->RecheckContactPoints(); } if ( m_hThrowTarget == NULL ) #ifdef SecobMod__Enable_Fixed_Multiplayer_AI m_hThrowTarget = UTIL_GetNearestVisiblePlayer(this); #else m_hThrowTarget = AI_GetSinglePlayer(); #endif //SecobMod__Enable_Fixed_Multiplayer_AI Vector vThrowDirection; if ( m_hThrowTarget ) { Vector vThrowOrigin = m_hThrowTarget->GetAbsOrigin(); if ( m_hThrowTarget->IsPlayer() ) vThrowOrigin = vThrowOrigin + Vector( random->RandomFloat( -128, 128 ), random->RandomFloat( -128, 128 ), 0 ); Vector vecToss = VecCheckToss( this, vGunPos, vThrowOrigin, m_flThrowArcModifier, 1.0f, true ); if( vecToss == vec3_origin ) { // Fix up an impossible throw so dog will at least toss the box in the target's general direction instead of dropping it. // Also toss it up in the air so it will fall down and break. (Just throw the box up at a 45 degree angle) Vector forward, up; GetVectors( &forward, NULL, &up ); vecToss = forward + up; VectorNormalize( vecToss ); vecToss *= pPhysObj->GetMass() * 30.0f; } vThrowDirection = vecToss + ( m_hThrowTarget->GetSmoothedVelocity() / 2 ); Vector vLinearDrag; Vector unitVel = vThrowDirection; VectorNormalize( unitVel ); float flTest = 1000 / vThrowDirection.Length(); float flDrag = pPhysObj->CalculateLinearDrag( vThrowDirection ); vThrowDirection = vThrowDirection + ( unitVel * ( flDrag * flDrag ) ) / flTest; pPhysObj->SetVelocity( &vThrowDirection, &angVelocity ); m_flTimeToCatch = gpGlobals->curtime + dog_max_wait_time.GetFloat(); //Don't start pulling until the object is away from me. //We base the time on the throw velocity. m_flTimeToPull = gpGlobals->curtime + ( 1000 / vThrowDirection.Length() ); } //Fire Output! m_OnThrow.FireOutput( this, this ); ClearBeams(); if ( m_bBeamEffects == true ) { EmitSound( "Weapon_PhysCannon.Launch" ); CBeam *pBeam = CBeam::BeamCreate( "sprites/orangelight1.vmt", 1.8 ); if ( pBeam != NULL ) { pBeam->PointEntInit( m_hPhysicsEnt->WorldSpaceCenter(), this ); pBeam->SetEndAttachment( m_iPhysGunAttachment ); pBeam->SetWidth( 6.4 ); pBeam->SetEndWidth( 12.8 ); pBeam->SetBrightness( 255 ); pBeam->SetColor( 255, 255, 255 ); pBeam->LiveForTime( 0.2f ); pBeam->RelinkBeam(); pBeam->SetNoise( 2 ); } Vector shotDir = ( m_hPhysicsEnt->WorldSpaceCenter() - vGunPos ); VectorNormalize( shotDir ); CPVSFilter filter( m_hPhysicsEnt->WorldSpaceCenter() ); te->GaussExplosion( filter, 0.0f, m_hPhysicsEnt->WorldSpaceCenter() - ( shotDir * 4.0f ), RandomVector(-1.0f, 1.0f), 0 ); } } } }