void CProjectile::Setup(DVector *vDir, DBYTE nType, DFLOAT fDamage, DFLOAT fVelocity, int nRadius, HOBJECT hFiredFrom) { CServerDE* pServerDE = BaseClass::GetServerDE(); if (!pServerDE) return; VEC_COPY(m_vDir, *vDir); m_fDamage = fDamage; m_fVelocity = fVelocity; m_nRadius = nRadius; m_hFiredFrom = hFiredFrom; pServerDE->CreateInterObjectLink( m_hObject, m_hFiredFrom ); m_nWeaponType = nType; DVector vVel; VEC_MULSCALAR(vVel, m_vDir, m_fVelocity); // Set the rotation of the projectile... DRotation rRot; pServerDE->AlignRotation(&rRot, &m_vDir, DNULL); pServerDE->SetObjectRotation(m_hObject, &rRot); // And away we go... pServerDE->SetVelocity(m_hObject, &vVel); pServerDE->SetObjectFlags(m_hObject, m_dwFlags); // Add smoke trail if (m_bSmokeTrail) AddSmokeTrail(vVel); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- int CPropAPC::OnTakeDamage( const CTakeDamageInfo &info ) { if ( m_iHealth == 0 ) return 0; m_OnDamaged.FireOutput( info.GetAttacker(), this ); if ( info.GetAttacker() && info.GetAttacker()->IsPlayer() ) { m_OnDamagedByPlayer.FireOutput( info.GetAttacker(), this ); } CTakeDamageInfo dmgInfo = info; if ( dmgInfo.GetDamageType() & (DMG_BLAST | DMG_AIRBOAT) ) { int nPrevHealth = GetHealth(); m_iHealth -= dmgInfo.GetDamage(); if ( m_iHealth <= 0 ) { m_iHealth = 0; Event_Killed( dmgInfo ); return 0; } // Chain // BaseClass::OnTakeDamage( dmgInfo ); // Spawn damage effects if ( nPrevHealth != GetHealth() ) { if ( ShouldTriggerDamageEffect( nPrevHealth, MAX_SMOKE_TRAILS ) ) { AddSmokeTrail( dmgInfo.GetDamagePosition() ); } if ( ShouldTriggerDamageEffect( nPrevHealth, MAX_EXPLOSIONS ) ) { ExplodeAndThrowChunk( dmgInfo.GetDamagePosition() ); } } } return 1; }