void NDebugOverlay::BoxAngles(const Vector &origin, const Vector &mins, const Vector &maxs, const QAngle &angles, int r, int g, int b, int a, float duration) { // -------------------------------------------------------------- // Have to do clip the boxes before sending so we // don't overflow the client message buffer // -------------------------------------------------------------- CBasePlayer *player = UTIL_PlayerByIndex(1); if ( !player ) return; // ------------------------------------ // Clip boxes that are far away // ------------------------------------ if ((player->GetAbsOrigin() - origin).LengthSqr() > MAX_OVERLAY_DIST_SQR) return; // ------------------------------------ // Clip boxes that are behind the client // ------------------------------------ Vector clientForward; player->EyeVectors( &clientForward ); // Build a rotation matrix from orientation matrix3x4_t fRotateMatrix; AngleMatrix(angles, fRotateMatrix); // Transform the mins and maxs Vector tmins, tmaxs; VectorRotate( mins, fRotateMatrix, tmins); VectorAdd(tmins,origin,tmins); VectorRotate( maxs, fRotateMatrix, tmaxs); VectorAdd(tmaxs,origin,tmaxs); Vector toMins = tmins - player->GetAbsOrigin(); Vector toMaxs = tmaxs - player->GetAbsOrigin(); float dotMins = DotProduct(clientForward,toMins); float dotMaxs = DotProduct(clientForward,toMaxs); if (dotMins < 0 && dotMaxs < 0) return; CSingleUserRecipientFilter user( player ); MessageBegin( user, SVC_DEBUG_BOX_OVERLAY ); WRITE_VEC3COORD(origin); WRITE_VEC3COORD(mins); WRITE_VEC3COORD(maxs); WRITE_ANGLES(angles); WRITE_SHORT(r); WRITE_SHORT(g); WRITE_SHORT(b); WRITE_SHORT(a); WRITE_FLOAT(duration); MessageEnd(); }
//----------------------------------------------------------------------------- // Purpose: Send debug overlay line to the client // Input : // Output : //----------------------------------------------------------------------------- void NDebugOverlay::Triangle( const Vector &p1, const Vector &p2, const Vector &p3, int r, int g, int b, int a, bool noDepthTest, float duration ) { // -------------------------------------------------------------- // Have to do clip the boxes before sending so we // don't overflow the client message buffer // -------------------------------------------------------------- CBasePlayer *player = UTIL_PlayerByIndex(1); if ( !player ) return; Vector to1 = p1 - player->GetAbsOrigin(); Vector to2 = p2 - player->GetAbsOrigin(); Vector to3 = p3 - player->GetAbsOrigin(); // ------------------------------------ // Clip triangles that are far away // ------------------------------------ if ((to1.LengthSqr() > MAX_OVERLAY_DIST_SQR) && (to2.LengthSqr() > MAX_OVERLAY_DIST_SQR) && (to3.LengthSqr() > MAX_OVERLAY_DIST_SQR)) { return; } // ------------------------------------ // Clip triangles that are behind the client // ------------------------------------ Vector clientForward; player->EyeVectors( &clientForward ); float dot1 = DotProduct(clientForward, to1); float dot2 = DotProduct(clientForward, to2); float dot3 = DotProduct(clientForward, to3); if (dot1 < 0 && dot2 < 0 && dot3 < 0) { return; } CSingleUserRecipientFilter user( player ); MessageBegin( user, SVC_DEBUG_TRIANGLE_OVERLAY ); WRITE_VEC3COORD(p1); WRITE_VEC3COORD(p2); WRITE_VEC3COORD(p3); WRITE_SHORT(r); WRITE_SHORT(g); WRITE_SHORT(b); WRITE_SHORT(a); WRITE_SHORT(noDepthTest); WRITE_FLOAT(duration); MessageEnd(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPropAPC2::FireMachineGun( void ) { if ( m_flMachineGunTime > gpGlobals->curtime ) return; // If we're still firing the salvo, fire quickly m_iMachineGunBurstLeft--; if ( m_iMachineGunBurstLeft > 0 ) { m_flMachineGunTime = gpGlobals->curtime + MACHINE_GUN_BURST_TIME; } else { // Reload the salvo m_iMachineGunBurstLeft = MACHINE_GUN_BURST_SIZE; m_flMachineGunTime = gpGlobals->curtime + MACHINE_GUN_BURST_PAUSE_TIME; } Vector vecMachineGunShootPos; QAngle vecMachineGunAngles; GetAttachment( m_nMachineGunMuzzleAttachment, vecMachineGunShootPos, vecMachineGunAngles ); Vector vecMachineGunDir; AngleVectors( vecMachineGunAngles, &vecMachineGunDir ); // Fire the round int bulletType = GetAmmoDef()->Index("StriderMiniGun"); FireBulletsInfo_t info; info.m_iShots = 1; info.m_vecSrc = vecMachineGunShootPos; info.m_vecDirShooting = vecMachineGunDir; info.m_vecSpread = VECTOR_CONE_8DEGREES; info.m_pAttacker = (CBaseEntity *) m_hPlayer; info.m_flDistance = MAX_TRACE_LENGTH; info.m_iAmmoType = bulletType; info.m_flDamage = 30; info.m_iPlayerDamage= 30; info.m_iTracerFreq = 1; FireBullets( info ); EntityMessageBegin( this, true ); WRITE_BYTE( APC_MSG_MACHINEGUN ); WRITE_VEC3COORD(vecMachineGunShootPos); WRITE_VEC3COORD(vecMachineGunDir); WRITE_VEC3COORD(VECTOR_CONE_8DEGREES); WRITE_BYTE( bulletType ); MessageEnd(); DoMuzzleFlash(); m_iAmmoCount--; EmitSound( "Weapon_AR2.Single" ); }
//----------------------------------------------------------------------------- // Purpose: Send grid overlay text to the client // Input : // Output : //----------------------------------------------------------------------------- void NDebugOverlay::Grid( const Vector &vPosition ) { CBroadcastRecipientFilter filter; MessageBegin( filter, SVC_DEBUG_GRID_OVERLAY); WRITE_VEC3COORD(vPosition); MessageEnd(); }
//----------------------------------------------------------------------------- // Purpose: Send debug overlay line to the client // Input : // Output : //----------------------------------------------------------------------------- void NDebugOverlay::Line( const Vector &origin, const Vector &target, int r, int g, int b, bool noDepthTest, float duration ) { // -------------------------------------------------------------- // Clip the line before sending so we // don't overflow the client message buffer // -------------------------------------------------------------- CBasePlayer *player = UTIL_PlayerByIndex(1); if ( !player ) return; // ------------------------------------ // Clip line that is far away // ------------------------------------ if (((player->GetAbsOrigin() - origin).LengthSqr() > MAX_OVERLAY_DIST_SQR) && ((player->GetAbsOrigin() - target).LengthSqr() > MAX_OVERLAY_DIST_SQR) ) return; // ------------------------------------ // Clip line that is behind the client // ------------------------------------ Vector clientForward; player->EyeVectors( &clientForward ); Vector toOrigin = origin - player->GetAbsOrigin(); Vector toTarget = target - player->GetAbsOrigin(); float dotOrigin = DotProduct(clientForward,toOrigin); float dotTarget = DotProduct(clientForward,toTarget); if (dotOrigin < 0 && dotTarget < 0) { return; } CSingleUserRecipientFilter user( player ); MessageBegin( user, SVC_DEBUG_LINE_OVERLAY ); WRITE_VEC3COORD(origin); WRITE_VEC3COORD(target); WRITE_SHORT(r); WRITE_SHORT(g); WRITE_SHORT(b); WRITE_SHORT(noDepthTest); WRITE_FLOAT(duration); MessageEnd(); }
void QUA_helicopter::Dispara(void) { if (m_flWaitAttack<=gpGlobals->curtime) { Vector vecMachineGunShootPos; QAngle vecMachineGunAngles; GetAttachment( m_nMachineGunMuzzleAttachment, vecMachineGunShootPos, vecMachineGunAngles ); Vector vecMachineGunDir = DondeApuntaPlayer() - vecMachineGunShootPos; VectorNormalize(vecMachineGunDir); //AngleVectors( vecMachineGunAngles, &vecMachineGunDir ); // Fire the round FireBulletsInfo_t info; info.m_iShots = 1; info.m_vecSrc = vecMachineGunShootPos; info.m_vecDirShooting = vecMachineGunDir; info.m_vecSpread = VECTOR_CONE_PRECALCULATED; info.m_pAttacker = (CBaseEntity *) m_hPlayer; info.m_flDistance = MAX_TRACE_LENGTH; info.m_iAmmoType = m_iAmmoType; info.m_flDamage = 60; info.m_iPlayerDamage= 60; info.m_iTracerFreq = 1; FireBullets( info ); EntityMessageBegin( this, true ); WRITE_BYTE( HELICOPTER_MSG_MACHINEGUN ); WRITE_VEC3COORD(vecMachineGunShootPos); WRITE_VEC3COORD(vecMachineGunDir); WRITE_VEC3COORD(VECTOR_CONE_PRECALCULATED); WRITE_BYTE( m_iAmmoType ); MessageEnd(); DoMuzzleFlash(); m_iAmmoCount--; // Descontamos ametralladora. EmitSound( "Weapon_AR2.Single" ); } }
//----------------------------------------------------------------------------- // Purpose: Send debug overlay text to the client // Input : // Output : //----------------------------------------------------------------------------- void NDebugOverlay::Text( const Vector &origin, const char *text, bool bViewCheck, float duration ) { CBasePlayer *player = UTIL_PlayerByIndex(1); if ( !player ) return; // ------------------------------------ // Clip text that is far away // ------------------------------------ if ((player->GetAbsOrigin() - origin).LengthSqr() > 4000000) return; // ------------------------------------ // Clip text that is behind the client // ------------------------------------ Vector clientForward; player->EyeVectors( &clientForward ); Vector toText = origin - player->GetAbsOrigin(); float dotPr = DotProduct(clientForward,toText); if (dotPr < 0) { return; } if (bViewCheck) { trace_t tr; UTIL_TraceLine(player->GetAbsOrigin(), origin, MASK_OPAQUE, NULL, COLLISION_GROUP_NONE, &tr); if ((tr.endpos - origin).Length() > 10) { return; } } CSingleUserRecipientFilter user( player ); MessageBegin( user, SVC_DEBUG_TEXT_OVERLAY ); WRITE_VEC3COORD(origin); WRITE_FLOAT(duration); WRITE_STRING(text); MessageEnd(); }
int CSDKPlayer::OnTakeDamage( const CTakeDamageInfo &inputInfo ) { CTakeDamageInfo info = inputInfo; CBaseEntity *pInflictor = info.GetInflictor(); if ( !pInflictor ) return 0; if ( GetMoveType() == MOVETYPE_NOCLIP || GetMoveType() == MOVETYPE_OBSERVER ) return 0; float flArmorBonus = 0.5f; float flArmorRatio = 0.5f; float flDamage = info.GetDamage(); bool bCheckFriendlyFire = false; bool bFriendlyFire = friendlyfire.GetBool(); //Tony; only check teams in teamplay if ( gpGlobals->teamplay ) bCheckFriendlyFire = true; if ( bFriendlyFire || ( bCheckFriendlyFire && pInflictor->GetTeamNumber() != GetTeamNumber() ) || pInflictor == this || info.GetAttacker() == this ) { if ( bFriendlyFire && (info.GetDamageType() & DMG_BLAST) == 0 ) { if ( pInflictor->GetTeamNumber() == GetTeamNumber() && bCheckFriendlyFire) { flDamage *= 0.35; // bullets hurt teammates less } } // keep track of amount of damage last sustained m_lastDamageAmount = flDamage; // Deal with Armour if ( ArmorValue() && !( info.GetDamageType() & (DMG_FALL | DMG_DROWN)) ) { float flNew = flDamage * flArmorRatio; float flArmor = (flDamage - flNew) * flArmorBonus; // Does this use more armor than we have? if (flArmor > ArmorValue() ) { //armorHit = (int)(flArmor); flArmor = ArmorValue(); flArmor *= (1/flArmorBonus); flNew = flDamage - flArmor; SetArmorValue( 0 ); } else { int oldValue = (int)(ArmorValue()); if ( flArmor < 0 ) flArmor = 1; SetArmorValue( oldValue - flArmor ); //armorHit = oldValue - (int)(pev->armorvalue); } flDamage = flNew; info.SetDamage( flDamage ); } // round damage to integer info.SetDamage( (int)flDamage ); if ( info.GetDamage() <= 0 ) return 0; CSingleUserRecipientFilter user( this ); user.MakeReliable(); UserMessageBegin( user, "Damage" ); WRITE_BYTE( (int)info.GetDamage() ); WRITE_VEC3COORD( info.GetInflictor()->WorldSpaceCenter() ); MessageEnd(); // Do special explosion damage effect if ( info.GetDamageType() & DMG_BLAST ) { OnDamagedByExplosion( info ); } gamestats->Event_PlayerDamage( this, info ); return CBaseCombatCharacter::OnTakeDamage( info ); } else { return 0; } }