Vector CBaseTurret::EyePosition( void ) { Vector vecOrigin; QAngle vecAngles; GetAttachment( "eyes", vecOrigin, vecAngles ); return vecOrigin; }
void CNPC_RocketTurret::UpdateMuzzleMatrix() { if ( gpGlobals->tickcount != m_muzzleToWorldTick ) { m_muzzleToWorldTick = gpGlobals->tickcount; GetAttachment( m_iMuzzleAttachment, m_muzzleToWorld ); } }
void CNPC_Gargantua::FlameUpdate( void ) { int i; static float offset[2] = { 60, -60 }; trace_t trace; Vector vecStart; QAngle angleGun; BOOL streaks = FALSE; Vector vForward; for ( i = 0; i < 2; i++ ) { if ( m_pFlame[i] ) { QAngle vecAim = GetAbsAngles(); vecAim.x += -m_flameX; vecAim.y += m_flameY; AngleVectors( vecAim, &vForward ); GetAttachment( i + 2, vecStart, angleGun ); Vector vecEnd = vecStart + ( vForward * GARG_FLAME_LENGTH); // - offset[i] * gpGlobals->v_right; UTIL_TraceLine ( vecStart, vecEnd, MASK_SOLID, this, COLLISION_GROUP_NONE, &trace); m_pFlame[i]->SetStartPos( trace.endpos ); m_pFlame[i+2]->SetStartPos( (vecStart * 0.6) + (trace.endpos * 0.4) ); if ( trace.fraction != 1.0 && gpGlobals->curtime > m_streakTime ) { g_pEffects->Sparks( trace.endpos, 1, 1, &trace.plane.normal ); streaks = TRUE; UTIL_DecalTrace( &trace, "SmallScorch" ); } // RadiusDamage( trace.vecEndPos, pev, pev, gSkillData.gargantuaDmgFire, CLASS_ALIEN_MONSTER, DMG_BURN ); FlameDamage( vecStart, trace.endpos, this, this, sk_gargantua_dmg_fire.GetFloat(), CLASS_ALIEN_MONSTER, DMG_BURN ); CBroadcastRecipientFilter filter; GetAttachment(i + 2, vecStart, angleGun); te->DynamicLight( filter, 0.0, &vecStart, 255, 0, 0, 0, 48, 0.2, 150 ); } } if ( streaks ) m_streakTime = gpGlobals->curtime; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPropAPC::Activate() { BaseClass::Activate(); m_nRocketAttachment = LookupAttachment( "cannon_muzzle" ); m_nMachineGunMuzzleAttachment = LookupAttachment( "muzzle" ); m_nMachineGunBaseAttachment = LookupAttachment( "gun_base" ); // NOTE: gun_ref must have the same position as gun_base, but rotates with the gun int nMachineGunRefAttachment = LookupAttachment( "gun_def" ); Vector vecWorldBarrelPos; matrix3x4_t matRefToWorld; GetAttachment( m_nMachineGunMuzzleAttachment, vecWorldBarrelPos ); GetAttachment( nMachineGunRefAttachment, matRefToWorld ); VectorITransform( vecWorldBarrelPos, matRefToWorld, m_vecBarrelPos ); }
int CBaseTurret::MoveTurret(void) { bool bDidMove = false; int iPose; matrix3x4_t localToWorld; GetAttachment( LookupAttachment( "eyes" ), localToWorld ); Vector vecGoalDir; AngleVectors( m_vecGoalAngles, &vecGoalDir ); Vector vecGoalLocalDir; VectorIRotate( vecGoalDir, localToWorld, vecGoalLocalDir ); QAngle vecGoalLocalAngles; VectorAngles( vecGoalLocalDir, vecGoalLocalAngles ); float flDiff; QAngle vecNewAngles; // update pitch flDiff = AngleNormalize( UTIL_ApproachAngle( vecGoalLocalAngles.x, 0.0, 0.1 * m_iBaseTurnRate ) ); iPose = LookupPoseParameter( TURRET_BC_PITCH ); SetPoseParameter( iPose, GetPoseParameter( iPose ) + flDiff / 1.5 ); if (fabs(flDiff) > 0.1) { bDidMove = true; } // update yaw, with acceleration #if 0 float flDist = AngleNormalize( vecGoalLocalAngles.y ); float flNewDist; float flNewTurnRate; ChangeDistance( 0.1, flDist, 0.0, m_fTurnRate, m_iBaseTurnRate, m_iBaseTurnRate * 4, flNewDist, flNewTurnRate ); m_fTurnRate = flNewTurnRate; flDiff = flDist - flNewDist; #else flDiff = AngleNormalize( UTIL_ApproachAngle( vecGoalLocalAngles.y, 0.0, 0.1 * m_iBaseTurnRate ) ); #endif iPose = LookupPoseParameter( TURRET_BC_YAW ); SetPoseParameter( iPose, GetPoseParameter( iPose ) + flDiff / 1.5 ); if (fabs(flDiff) > 0.1) { bDidMove = true; } if (bDidMove) { // DevMsg( "(%.2f, %.2f)\n", AngleNormalize( vecGoalLocalAngles.x ), AngleNormalize( vecGoalLocalAngles.y ) ); } return bDidMove; }
//----------------------------------------------------------------------------- // Purpose: Create danger sounds in front of the vehicle. //----------------------------------------------------------------------------- void CASW_PropJeep::CreateDangerSounds( void ) { QAngle dummy; GetAttachment( "Muzzle", m_vecGunOrigin, dummy ); if ( m_flDangerSoundTime > gpGlobals->curtime ) return; QAngle vehicleAngles = GetLocalAngles(); Vector vecStart = GetAbsOrigin(); Vector vecDir, vecRight; GetVectors( &vecDir, &vecRight, NULL ); const float soundDuration = 0.25; float speed = m_VehiclePhysics.GetHLSpeed(); // Make danger sounds ahead of the jeep if ( fabs(speed) > 120 ) { Vector vecSpot; float steering = m_VehiclePhysics.GetSteering(); if ( steering != 0 ) { if ( speed > 0 ) { vecDir += vecRight * steering * 0.5; } else { vecDir -= vecRight * steering * 0.5; } VectorNormalize(vecDir); } const float radius = speed * 0.4; // 0.3 seconds ahead of the jeep vecSpot = vecStart + vecDir * (speed * 0.3f); CSoundEnt::InsertSound( SOUND_DANGER, vecSpot, radius, soundDuration, this, 0 ); CSoundEnt::InsertSound( SOUND_PHYSICS_DANGER, vecSpot, radius, soundDuration, this, 1 ); //NDebugOverlay::Box(vecSpot, Vector(-radius,-radius,-radius),Vector(radius,radius,radius), 255, 0, 255, 0, soundDuration); #if 0 trace_t tr; // put sounds a bit to left and right but slightly closer to Jeep to make a "cone" of sound // in front of it vecSpot = vecStart + vecDir * (speed * 0.5f) - vecRight * speed * 0.5; UTIL_TraceLine( vecStart, vecSpot, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr ); CSoundEnt::InsertSound( SOUND_DANGER, vecSpot, 400, soundDuration, this, 1 ); vecSpot = vecStart + vecDir * (speed * 0.5f) + vecRight * speed * 0.5; UTIL_TraceLine( vecStart, vecSpot, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr ); CSoundEnt::InsertSound( SOUND_DANGER, vecSpot, 400, soundDuration, this, 2); #endif } m_flDangerSoundTime = gpGlobals->curtime + 0.1; }
void DetachObject(SActivationInfo *pActInfo) { IAttachment *pAttachment = GetAttachment(pActInfo); if (pAttachment) { pAttachment->ClearBinding(); ActivateOutput(pActInfo, eOP_Detached, 0); } }
//----------------------------------------------------------------------------- // Purpose: Finds the true aiming position of the gun (looks at what player // is looking at and adjusts) // Input : &resultDir - direction to be calculated //----------------------------------------------------------------------------- void CASW_PropJeep::GetCannonAim( Vector *resultDir ) { Vector muzzleOrigin; QAngle muzzleAngles; GetAttachment( LookupAttachment("gun_ref"), muzzleOrigin, muzzleAngles ); AngleVectors( muzzleAngles, resultDir ); }
int CBaseTFVehicle::LocateEntryPoint( CBaseTFPlayer *pPlayer, float* fBest2dDistanceSqr ) { // Get the players origin and compare it to all the entry points on the // vehicle. Vector vecPlayerPos = pPlayer->GetAbsOrigin(); Vector vecEntryPos; QAngle vecEntryAngle; int iMinEntry = -1; float flMinDistance2 = INITIAL_MAX_DISTANCE; // Is the player the owner of the vehicle? bool bOwner = ( pPlayer == GetOwner() ); char szPassengerEyes[32]; for( int iEntryPoint = 0; iEntryPoint < m_nMaxPassengers; ++iEntryPoint ) { // If not the owner, check to see if the entry point is available. The // entry point is always available for the owner. bool bOccupied = ( GetPassenger( iEntryPoint ) != NULL ); // Also check for child vehicles... if ( bOccupied && !bOwner ) continue; // FIXME: Cache off the entry point Q_snprintf( szPassengerEyes, sizeof( szPassengerEyes ), "vehicle_feet_passenger%d", iEntryPoint ); int nAttachmentIndex = LookupAttachment( szPassengerEyes ); float flDistance2; if (nAttachmentIndex > 0) { GetAttachment( nAttachmentIndex, vecEntryPos, vecEntryAngle ); Vector vecDelta = vecEntryPos - vecPlayerPos; flDistance2 = vecDelta.AsVector2D().LengthSqr(); } else { // No attachment? Choose it if we must as a last resort flDistance2 = INITIAL_MAX_DISTANCE - 1; } if ( flDistance2 < flMinDistance2 ) { flMinDistance2 = flDistance2; iMinEntry = iEntryPoint; } } if( fBest2dDistanceSqr ) { *fBest2dDistanceSqr = flMinDistance2; } return iMinEntry; }
//------------------------------------------------------------------------------ // Purpose : Returns position of laser for any given position of the staler // Input : // Output : //------------------------------------------------------------------------------ Vector CNPC_Stalker::LaserStartPosition(Vector vStalkerPos) { // Get attachment position Vector vAttachPos; GetAttachment(STALKER_LASER_ATTACHMENT,vAttachPos); // Now convert to vStalkerPos vAttachPos = vAttachPos - GetAbsOrigin() + vStalkerPos; return vAttachPos; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- Vector CNPC_CombineCamera::HeadDirection2D() { Vector vecMuzzle, vecMuzzleDir; GetAttachment("eyes", vecMuzzle, &vecMuzzleDir ); vecMuzzleDir.z = 0; VectorNormalize(vecMuzzleDir); return vecMuzzleDir; }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- Vector CNPC_PoisonZombie::HeadTarget( const Vector &posSrc ) { int iCrabAttachment = LookupAttachment( "headcrab1" ); Assert( iCrabAttachment > 0 ); Vector vecPosition; GetAttachment( iCrabAttachment, vecPosition ); return vecPosition; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_PropJeep::OnEnteredVehicle( C_BasePlayer *pPlayer ) { int eyeAttachmentIndex = LookupAttachment( "vehicle_driver_eyes" ); Vector vehicleEyeOrigin; QAngle vehicleEyeAngles; GetAttachment( eyeAttachmentIndex, vehicleEyeOrigin, vehicleEyeAngles ); m_vecLastEyeTarget = vehicleEyeOrigin; m_vecLastEyePos = vehicleEyeOrigin; m_vecEyeSpeed = vec3_origin; }
Vector CPropVehicleManhack::BodyTarget( const Vector &posSrc, bool bNoisy ) { Vector shotPos; //matrix3x4_t matrix; int eyeAttachmentIndex = LookupAttachment("vehicle_driver_eyes"); GetAttachment( eyeAttachmentIndex, shotPos ); //shotPos = WorldSpaceCenter(); return shotPos; }
// Звук шага и пыль от поступи крематора, правый шаг. Vector CNPC_Cremator::RightFootHit( float eventtime ) { Vector footPosition; GetAttachment( "footright", footPosition ); CPASAttenuationFilter filter( this ); EmitSound( filter, entindex(), "NPC_Cremator.FootstepRight", &footPosition, eventtime ); FootstepEffect( footPosition ); return footPosition; }
bool C_BaseCombatWeapon::GetShootPosition( Vector &vOrigin, QAngle &vAngles ) { // Get the entity because the weapon doesn't have the right angles. C_BaseCombatCharacter *pEnt = ToBaseCombatCharacter( GetOwner() ); if ( pEnt ) { if ( pEnt == C_BasePlayer::GetLocalPlayer() ) { vAngles = pEnt->EyeAngles(); } else { vAngles = pEnt->GetRenderAngles(); } } else { vAngles.Init(); } C_BasePlayer *player = ToBasePlayer( pEnt ); bool bUseViewModel = false; if ( C_BasePlayer::IsLocalPlayer( pEnt ) ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( pEnt ); bUseViewModel = !player->ShouldDrawLocalPlayer(); } QAngle vDummy; if ( IsActiveByLocalPlayer() && bUseViewModel ) { C_BaseViewModel *vm = player ? player->GetViewModel( 0 ) : NULL; if ( vm ) { int iAttachment = vm->LookupAttachment( "muzzle" ); if ( vm->GetAttachment( iAttachment, vOrigin, vDummy ) ) { return true; } } } else { // Thirdperson int iAttachment = LookupAttachment( "muzzle" ); if ( GetAttachment( iAttachment, vOrigin, vDummy ) ) { return true; } } vOrigin = GetRenderOrigin(); return false; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- bool CASW_PropJeep::CheckWater( void ) { bool bInWater = false; // Check all four wheels. for ( int iWheel = 0; iWheel < ASW_JEEP_WHEEL_COUNT; ++iWheel ) { // Get the current wheel and get its contact point. IPhysicsObject *pWheel = m_VehiclePhysics.GetWheel( iWheel ); if ( !pWheel ) continue; // Check to see if we hit water. if ( pWheel->GetContactPoint( &m_WaterData.m_vecWheelContactPoints[iWheel], NULL ) ) { m_WaterData.m_bWheelInWater[iWheel] = ( UTIL_PointContents( m_WaterData.m_vecWheelContactPoints[iWheel], MASK_WATER ) & MASK_WATER ) ? true : false; if ( m_WaterData.m_bWheelInWater[iWheel] ) { bInWater = true; } } } // Check the body and the BONNET. int iEngine = LookupAttachment( "vehicle_engine" ); Vector vecEnginePoint; QAngle vecEngineAngles; GetAttachment( iEngine, vecEnginePoint, vecEngineAngles ); m_WaterData.m_bBodyInWater = ( UTIL_PointContents( vecEnginePoint, MASK_WATER ) & MASK_WATER ) ? true : false; if ( m_WaterData.m_bBodyInWater ) { if ( !m_VehiclePhysics.IsEngineDisabled() ) { m_VehiclePhysics.SetDisableEngine( true ); } } else { if ( m_VehiclePhysics.IsEngineDisabled() ) { m_VehiclePhysics.SetDisableEngine( false ); } } if ( bInWater ) { // Check the player's water level. CheckWaterLevel(); } return bInWater; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponSMG1::Operator_ForceNPCFire( CBaseCombatCharacter *pOperator, bool bSecondary ) { // Ensure we have enough rounds in the clip m_iClip1++; Vector vecShootOrigin, vecShootDir; QAngle angShootDir; GetAttachment( LookupAttachment( "muzzle" ), vecShootOrigin, angShootDir ); AngleVectors( angShootDir, &vecShootDir ); FireNPCPrimaryAttack( pOperator, vecShootOrigin, vecShootDir ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CObjectTower::FinishedBuilding( void ) { BaseClass::FinishedBuilding(); // Create the ladder. Vector vecOrigin; QAngle vecAngles; GetAttachment( "ladder", vecOrigin, vecAngles ); m_hLadder = CObjectTowerLadder::Create( vecOrigin, vecAngles, this ); m_hLadder->ChangeTeam( GetTeamNumber() ); }
void UpdateOffset(SActivationInfo *pActInfo) { IAttachment *pAttachment = GetAttachment(pActInfo); if (pAttachment) { const Vec3& rotationOffsetEuler = GetPortVec3(pActInfo, eIP_RotationOffset); QuatT offset = QuatT::CreateRotationXYZ(Ang3(DEG2RAD(rotationOffsetEuler))); offset.t = GetPortVec3(pActInfo, eIP_TranslationOffset); pAttachment->SetAttRelativeDefault(offset); } }
//========================================================= // RunAI //========================================================= void CNPC_Controller::RunAI( void ) { BaseClass::RunAI(); Vector vecStart; QAngle angleGun; //some kind of hack in hl1 ? // if ( HasMemory( bits_MEMORY_KILLED ) ) //use this instead if( !IsAlive() ) return; for (int i = 0; i < 2; i++) { if (m_pBall[i] == NULL) { m_pBall[i] = CSprite::SpriteCreate( "sprites/xspark4.vmt", GetAbsOrigin(), TRUE ); m_pBall[i]->SetTransparency( kRenderGlow, 255, 255, 255, 255, kRenderFxNoDissipation ); m_pBall[i]->SetAttachment( this, (i + 3) ); m_pBall[i]->SetScale( 1.0 ); } float t = m_iBallTime[i] - gpGlobals->curtime; if (t > 0.1) t = 0.1 / t; else t = 1.0; m_iBallCurrent[i] += (m_iBall[i] - m_iBallCurrent[i]) * t; m_pBall[i]->SetBrightness( m_iBallCurrent[i] ); GetAttachment( i + 2, vecStart, angleGun ); m_pBall[i]->SetAbsOrigin( vecStart ); CBroadcastRecipientFilter filter; GetAttachment( i + 3, vecStart, angleGun ); te->DynamicLight( filter, 0.0, &vecStart, 255, 192, 64, 0/*exponent*/, m_iBallCurrent[i] / 8 /*radius*/, 0.5, 0 ); } }
// Do part of our effect void ClientThink( void ) { // Update our effects if ( m_bActive && gpGlobals->frametime != 0.0f && ( random->RandomInt( 0, 5 ) == 0 ) ) { Vector vecOrigin; QAngle vecAngles; GetAttachment( 1, vecOrigin, vecAngles ); Vector vForward; AngleVectors( vecAngles, &vForward ); Vector vEnd = vecOrigin - vForward * 1.0f; // Inner beams BeamInfo_t beamInfo; beamInfo.m_vecStart = vEnd; Vector offset = RandomVector( -6, 2 ); offset += Vector(2,2,2); beamInfo.m_vecEnd = vecOrigin + offset; beamInfo.m_pStartEnt= cl_entitylist->GetEnt( BEAMENT_ENTITY( entindex() ) ); beamInfo.m_pEndEnt = cl_entitylist->GetEnt( BEAMENT_ENTITY( entindex() ) ); beamInfo.m_nStartAttachment = 1; beamInfo.m_nEndAttachment = 2; beamInfo.m_nType = TE_BEAMTESLA; beamInfo.m_pszModelName = "sprites/physbeam.vmt"; beamInfo.m_flHaloScale = 0.0f; beamInfo.m_flLife = 0.01f; beamInfo.m_flWidth = random->RandomFloat( 0.5f, 2.0f ); beamInfo.m_flEndWidth = 0; beamInfo.m_flFadeLength = 0.0f; beamInfo.m_flAmplitude = random->RandomFloat( 1, 2 ); beamInfo.m_flBrightness = 255.0; beamInfo.m_flSpeed = 0.0; beamInfo.m_nStartFrame = 0.0; beamInfo.m_flFrameRate = 1.0f; beamInfo.m_flRed = 255.0f;; beamInfo.m_flGreen = 255.0f; beamInfo.m_flBlue = 255.0f; beamInfo.m_nSegments = 8; beamInfo.m_bRenderable = true; beamInfo.m_nFlags = (FBEAM_ONLYNOISEONCE|FBEAM_SHADEOUT); beams->CreateBeamPoints( beamInfo ); } }
//----------------------------------------------------------------------------- // Purpose: Update the designator position //----------------------------------------------------------------------------- void CObjectBaseMannedGun::UpdateDesignator( void ) { // Make the beam, if we don't have one yet if ( !m_hBeam && GetDriverPlayer() ) { m_hBeam = BEAM_CREATE_PREDICTABLE_PERSIST( "sprites/laserbeam.vmt", 5, GetDriverPlayer() ); if ( m_hBeam.Get() ) { m_hBeam->PointEntInit( vec3_origin, this ); m_hBeam->SetEndAttachment( m_nBarrelAttachment ); m_hBeam->SetColor( 255, 32, 32 ); m_hBeam->SetBrightness( 255 ); m_hBeam->SetNoise( 0 ); m_hBeam->SetWidth( 0.5 ); m_hBeam->SetEndWidth( 0.5 ); } } // We have to flush the bone cache because it's possible that only the bone controllers // have changed since the bonecache was generated, and bone controllers aren't checked. InvalidateBoneCache(); QAngle vecAng; Vector vecSrc, vecAim; GetAttachment( m_nBarrelAttachment, vecSrc, vecAng ); AngleVectors( vecAng, &vecAim, 0, 0 ); // "Fire" the designator beam Vector vecEnd = vecSrc + vecAim * obj_manned_gun_designator_range.GetFloat(); trace_t tr; TFGameRules()->WeaponTraceLine(vecSrc, vecEnd, MASK_SHOT, this, DMG_PROBE, &tr); if ( m_hLaserDesignation.Get() ) { // Only update our designated target point if we hit something if ( tr.fraction != 1.0 ) { m_hLaserDesignation->SetActive( true ); m_hLaserDesignation->SetAbsOrigin( tr.endpos ); } else { m_hLaserDesignation->SetActive( false ); } } // Update beam visual if ( m_hBeam.Get() ) { m_hBeam->SetStartPos( tr.endpos ); m_hBeam->RelinkBeam(); } }
// ========================================================= // TORCH SUPPORT // ========================================================= void CGenericMonster :: Torch ( void ) { Vector vecGunPos; Vector vecGunAngles; Vector vecShootDir; GetAttachment( 4, vecGunPos, vecGunAngles ); pev->effects |= EF_MUZZLEFLASH; Vector angDir = UTIL_VecToAngles( vecShootDir ); SetBlending( 0, angDir.x ); }
void CMGargantua :: FlameUpdate( void ) { int i; static float offset[2] = { 60, -60 }; TraceResult trace; Vector vecStart, angleGun; BOOL streaks = FALSE; for ( i = 0; i < 2; i++ ) { if ( m_pFlame[i] ) { Vector vecAim = pev->angles; vecAim.x += m_flameX; vecAim.y += m_flameY; UTIL_MakeVectors( vecAim ); GetAttachment( i+1, vecStart, angleGun ); Vector vecEnd = vecStart + (gpGlobals->v_forward * GARG_FLAME_LENGTH); // - offset[i] * gpGlobals->v_right; UTIL_TraceLine( vecStart, vecEnd, dont_ignore_monsters, edict(), &trace ); m_pFlame[i]->SetStartPos( trace.vecEndPos ); m_pFlame[i+2]->SetStartPos( (vecStart * 0.6) + (trace.vecEndPos * 0.4) ); if ( trace.flFraction != 1.0 && gpGlobals->time > m_streakTime ) { StreakSplash( trace.vecEndPos, trace.vecPlaneNormal, 6, 20, 50, 400 ); streaks = TRUE; UTIL_DecalTrace( &trace, DECAL_SMALLSCORCH1 + RANDOM_LONG(0,2) ); } RadiusDamage( trace.vecEndPos, pev, pev, gSkillData.gargantuaDmgFire, CLASS_ALIEN_MONSTER, DMG_BURN ); FlameDamage( vecStart, trace.vecEndPos, pev, pev, gSkillData.gargantuaDmgFire, CLASS_ALIEN_MONSTER, DMG_BURN ); MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); WRITE_SHORT( entindex( ) + 0x1000 * (i + 2) ); // entity, attachment WRITE_COORD( vecStart.x ); // origin WRITE_COORD( vecStart.y ); WRITE_COORD( vecStart.z ); WRITE_COORD( RANDOM_FLOAT( 32, 48 ) ); // radius WRITE_BYTE( 255 ); // R WRITE_BYTE( 255 ); // G WRITE_BYTE( 255 ); // B WRITE_BYTE( 2 ); // life * 10 WRITE_COORD( 0 ); // decay MESSAGE_END(); } } if ( streaks ) m_streakTime = gpGlobals->time; }
Vector CPhysicsCannister::CalcLocalThrust( const Vector &offset ) { matrix3x4_t nozzleMatrix; Vector thrustDirection; GetAttachment( LookupAttachment("nozzle"), nozzleMatrix ); MatrixGetColumn( nozzleMatrix, 2, thrustDirection ); MatrixGetColumn( nozzleMatrix, 3, m_thrustOrigin ); thrustDirection = -5*thrustDirection + offset; VectorNormalize( thrustDirection ); return thrustDirection; }
//----------------------------------------------------------------------------- // Purpose: Creates, destroys, and updates the flashlight effect as needed. //----------------------------------------------------------------------------- void C_HL2MP_Player::UpdateFlashlight() { // The dim light is the flashlight. if ( IsEffectActive( EF_DIMLIGHT ) ) { if (!m_pHL2MPFlashLightEffect) { // Turned on the headlight; create it. m_pHL2MPFlashLightEffect = new CHL2MPFlashlightEffect(index); if (!m_pHL2MPFlashLightEffect) return; m_pHL2MPFlashLightEffect->TurnOn(); } Vector vecForward, vecRight, vecUp; Vector position = EyePosition(); if ( ::input->CAM_IsThirdPerson() ) { int iAttachment = LookupAttachment( "anim_attachment_RH" ); if ( iAttachment >= 0 ) { Vector vecOrigin; //Tony; EyeAngles will return proper whether it's local player or not. QAngle eyeAngles = EyeAngles(); GetAttachment( iAttachment, vecOrigin, eyeAngles ); Vector vForward; AngleVectors( eyeAngles, &vecForward, &vecRight, &vecUp ); position = vecOrigin; } else EyeVectors( &vecForward, &vecRight, &vecUp ); } else EyeVectors( &vecForward, &vecRight, &vecUp ); // Update the light with the new position and direction. m_pHL2MPFlashLightEffect->UpdateLight( position, vecForward, vecRight, vecUp, FLASHLIGHT_DISTANCE ); } else if (m_pHL2MPFlashLightEffect) { // Turned off the flashlight; delete it. delete m_pHL2MPFlashLightEffect; m_pHL2MPFlashLightEffect = NULL; } }
//========================================================= // CheckRangeAttack1 // // !!!LATER - we may want to load balance this. Several // tracelines are done, so we may not want to do this every // server frame. Definitely not while firing. //========================================================= int CNPC_AlienGrunt::RangeAttack1Conditions ( float flDot, float flDist ) { if ( gpGlobals->curtime < m_flNextHornetAttackCheck ) { if ( HasCondition( COND_SEE_ENEMY ) ) { if ( m_fCanHornetAttack == true ) { return COND_CAN_RANGE_ATTACK1; } else { return COND_NONE; } } else return COND_NONE; } if ( flDist < AGRUNT_MELEE_DIST ) return COND_NONE; if ( flDist > 1024 ) return COND_NONE; if ( flDot < 0.5 ) return COND_NONE; if ( HasCondition( COND_SEE_ENEMY ) ) { trace_t tr; Vector vecArmPos; QAngle angArmDir; // verify that a shot fired from the gun will hit the enemy before the world. // !!!LATER - we may wish to do something different for projectile weapons as opposed to instant-hit GetAttachment( "0", vecArmPos, angArmDir ); UTIL_TraceLine( vecArmPos, GetEnemy()->BodyTarget( vecArmPos ), MASK_SOLID, this, COLLISION_GROUP_NONE, &tr); if ( tr.fraction == 1.0 || tr.m_pEnt == GetEnemy() ) { m_flNextHornetAttackCheck = gpGlobals->curtime + random->RandomFloat( 2, 5 ); m_fCanHornetAttack = true; return COND_CAN_RANGE_ATTACK1; } } m_flNextHornetAttackCheck = gpGlobals->curtime + 0.2;// don't check for half second if this check wasn't successful m_fCanHornetAttack = false; return COND_NONE; }
//----------------------------------------------------------------------------- // Creates, destroys particles attached to an attachment //----------------------------------------------------------------------------- void C_EnvParticleScript::CreateParticle( const char *pAttachmentName, const char *pSpriteName ) { // Find the attachment int nAttachment = LookupAttachment( pAttachmentName ); if ( nAttachment <= 0 ) return; // Get the sprite materials PMaterialHandle hMat = m_ParticleEffect.FindOrAddMaterial( pSpriteName ); ParticleScriptParticle_t *pParticle = (ParticleScriptParticle_t*)m_ParticleEffect.AddParticle(sizeof(ParticleScriptParticle_t), hMat); if ( pParticle == NULL ) return; // Get the sprite size from the material's materialvars bool bFound = false; IMaterialVar *pMaterialVar = NULL; IMaterial *pMaterial = ParticleMgr()->PMaterialToIMaterial( hMat ); if ( pMaterial ) { pMaterialVar = pMaterial->FindVar( "$spritesize", &bFound, false ); } if ( bFound ) { pParticle->m_flSize = pMaterialVar->GetFloatValue(); } else { pParticle->m_flSize = 100.0f; } // Make sure the particle cull size reflects our particles if ( pParticle->m_flSize > m_flMaxParticleSize ) { m_flMaxParticleSize = pParticle->m_flSize; m_ParticleEffect.SetParticleCullRadius( m_flMaxParticleSize ); } // Place the particle on the attachment specified pParticle->m_nAttachment = nAttachment; QAngle vecAngles; GetAttachment( nAttachment, pParticle->m_Pos, vecAngles ); if ( m_flSequenceScale != 1.0f ) { pParticle->m_Pos -= GetAbsOrigin(); pParticle->m_Pos *= m_flSequenceScale; pParticle->m_Pos += GetAbsOrigin(); } }
Vector CWalkerMiniStrider::GetLargeGunShootOrigin() { Vector vRet; QAngle dummyAngle; if ( GetAttachment( LookupAttachment( "LargeGun" ), vRet, dummyAngle ) ) { return vRet; } else { return GetAbsOrigin(); } }