void CASW_Weapon_Welder::UpdateDoorWeldingEffects( void ) { if ( !m_bIsFiring || !GetMarine() || !GetMarine()->GetMarineResource() ) { RemoveWeldingEffects(); StopWelderSound(); return; } C_ASW_Door* pDoor = GetMarine()->GetMarineResource()->m_hWeldingDoor.Get(); if ( !pDoor || pDoor->IsOpen() ) { RemoveWeldingEffects(); StopWelderSound(); return; } StartWelderSound(); if ( !m_hWeldEffects || m_bWeldSealLast != m_bWeldSeal ) { CreateWeldingEffects( pDoor ); } if ( m_hWeldEffects ) { m_hWeldEffects->SetControlPoint( 0, pDoor->GetWeldFacingPoint( GetMarine() ) ); m_hWeldEffects->SetControlPointForwardVector( 0, pDoor->GetSparkNormal( GetMarine() ) ); } m_bWeldSealLast = m_bWeldSeal; }
int CASW_Weapon_Assault_Shotgun::GetNumPellets() { if (GetMarine()) return MarineSkills()->GetSkillBasedValueByMarine(GetMarine(), ASW_MARINE_SKILL_VINDICATOR, ASW_MARINE_SUBSKILL_VINDICATOR_PELLETS); return GetWeaponInfo()->m_iNumPellets; }
bool CASW_Weapon_Medkit::OffhandActivate() { if (!GetMarine() || GetMarine()->GetFlags() & FL_FROZEN) // don't allow this if the marine is frozen return false; SelfHeal(); return true; }
bool CASW_Weapon_Buff_Grenade::OffhandActivate() { if (!GetMarine() || GetMarine()->GetFlags() & FL_FROZEN) // don't allow this if the marine is frozen return false; PrimaryAttack(); return true; }
bool CASW_Weapon_Shotgun::ShouldUseFastReloadAnim() { if (GetMarine()) { return (MarineSkills()->GetSkillBasedValueByMarine(GetMarine(), ASW_MARINE_SKILL_RELOADING) < 1.06f); } return true; }
bool CASW_Weapon_Stim::OffhandActivate() { if (!GetMarine() || GetMarine()->GetFlags() & FL_FROZEN) // don't allow this if the marine is frozen return false; if (m_flNextPrimaryAttack < gpGlobals->curtime) PrimaryAttack(); return true; }
float CASW_Weapon_Sniper_Rifle::GetWeaponDamage() { float flDamage = GetWeaponInfo()->m_flBaseDamage; if ( GetMarine() ) { flDamage += MarineSkills()->GetSkillBasedValueByMarine(GetMarine(), ASW_MARINE_SKILL_ACCURACY, ASW_MARINE_SUBSKILL_ACCURACY_SNIPER_RIFLE_DMG); } return flDamage; }
float CASW_Weapon_Autogun::GetWeaponDamage() { float flDamage = GetWeaponInfo()->m_flBaseDamage; if ( GetMarine() ) { flDamage += MarineSkills()->GetSkillBasedValueByMarine(GetMarine(), ASW_MARINE_SKILL_AUTOGUN, ASW_MARINE_SUBSKILL_AUTOGUN_DMG); } return flDamage; }
float CASW_Weapon_Shotgun::GetWeaponDamage() { float flDamage = GetWeaponInfo()->m_flBaseDamage; if ( GetMarine() ) { flDamage += MarineSkills()->GetSkillBasedValueByMarine(GetMarine(), ASW_MARINE_SKILL_ACCURACY, ASW_MARINE_SUBSKILL_ACCURACY_SHOTGUN_DMG); } //CALL_ATTRIB_HOOK_FLOAT( flDamage, mod_damage_done ); return flDamage; }
float CASW_Weapon_Minigun::GetWeaponDamage() { //float flDamage = 7.0f; float flDamage = GetWeaponInfo()->m_flBaseDamage; if ( GetMarine() ) { flDamage += MarineSkills()->GetSkillBasedValueByMarine(GetMarine(), ASW_MARINE_SKILL_AUTOGUN, ASW_MARINE_SUBSKILL_AUTOGUN_DMG); } //CALL_ATTRIB_HOOK_FLOAT( flDamage, mod_damage_done ); return flDamage; }
float CASW_Weapon_Assault_Shotgun::GetWeaponDamage() { //float flDamage = 7.0f; float flDamage = GetWeaponInfo()->m_flBaseDamage; if ( GetMarine() ) { flDamage += MarineSkills()->GetSkillBasedValueByMarine(GetMarine(), ASW_MARINE_SKILL_VINDICATOR, ASW_MARINE_SUBSKILL_VINDICATOR_DAMAGE); } //CALL_ATTRIB_HOOK_FLOAT( flDamage, mod_damage_done ); return flDamage; }
const QAngle& CASW_Weapon_Smart_Bomb::GetRocketAngle() { static QAngle angRocket = vec3_angle; CASW_Player *pPlayer = GetCommander(); CASW_Marine *pMarine = GetMarine(); if ( !pPlayer || !pMarine || pMarine->GetHealth() <= 0 ) { return angRocket; } //Vector vecDir = pPlayer->GetAutoaimVectorForMarine(pMarine, GetAutoAimAmount(), GetVerticalAdjustOnlyAutoAimAmount()); // 45 degrees = 0.707106781187 //VectorAngles( vecDir, angRocket ); //angRocket[ YAW ] += random->RandomFloat( -35, 35 ); angRocket[ PITCH ] = -60.0f; // aim up to help avoid FF if ( GetRocketsToFire() % 2 ) { angRocket[ YAW ] = m_iRocketsToFire * 15.0f; // 15 degrees between each rocket } else { angRocket[ YAW ] = RandomFloat( 0.0f, 360.0f ); } angRocket[ ROLL ] = 0; return angRocket; }
float CASW_Weapon_Pistol::GetFireRate( void ) { CASW_Marine *pMarine = GetMarine(); float flRate = GetWeaponInfo()->m_flFireRate; // player firing rate if (!pMarine || pMarine->IsInhabited()) { return flRate; } #ifdef CLIENT_DLL return flRate; #else float randomness = 0.1f * random->RandomFloat() - 0.05f; // AI firing rate: depends on distance to enemy if (!pMarine->GetEnemy()) return 0.3f + randomness; float dist = pMarine->GetAbsOrigin().DistTo(pMarine->GetEnemy()->GetAbsOrigin()); if (dist > 500) return 0.3f + randomness; if (dist < 100) return 0.14f + randomness; float factor = (dist - 100) / 400.0f; return 0.14f + factor * 0.16f + randomness; #endif }
void CASW_Weapon_Hornet_Barrage::FireRocket() { CASW_Player *pPlayer = GetCommander(); CASW_Marine *pMarine = GetMarine(); if ( !pPlayer || !pMarine || pMarine->GetHealth() <= 0 ) { m_iRocketsToFire = 0; return; } WeaponSound(SINGLE); // tell the marine to tell its weapon to draw the muzzle flash pMarine->DoMuzzleFlash(); pMarine->DoAnimationEvent( PLAYERANIMEVENT_FIRE_GUN_PRIMARY ); Vector vecSrc = GetRocketFiringPosition(); m_iRocketsToFire = m_iRocketsToFire.Get() - 1; m_flNextLaunchTime = gpGlobals->curtime + m_flFireInterval.Get(); #ifndef CLIENT_DLL float fGrenadeDamage = MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_GRENADES, ASW_MARINE_SUBSKILL_GRENADE_HORNET_DMG ); CASW_Rocket::Create( fGrenadeDamage, vecSrc, GetRocketAngle(), pMarine, this ); if ( ASWGameRules() ) { ASWGameRules()->m_fLastFireTime = gpGlobals->curtime; } pMarine->OnWeaponFired( this, 1 ); #endif }
const char *CASW_Weapon::GetASWShootSound( int iIndex, int &iPitch ) { if ( iIndex == SINGLE || iIndex == SINGLE_NPC ) { iIndex = IsCarriedByLocalPlayer() ? SINGLE : SINGLE_NPC; } if ( iIndex == WPN_DOUBLE || iIndex == DOUBLE_NPC ) { iIndex = IsCarriedByLocalPlayer() ? WPN_DOUBLE : DOUBLE_NPC; } if ( iIndex == RELOAD || iIndex == RELOAD_NPC ) { iIndex = IsCarriedByLocalPlayer() ? RELOAD : RELOAD_NPC; // play the weapon sound according to marine skill int iSkill = MarineSkills()->GetSkillBasedValueByMarine(GetMarine(), ASW_MARINE_SKILL_RELOADING, ASW_MARINE_SUBSKILL_RELOADING_SOUND); switch (iSkill) { case 5: return GetWpnData().aShootSounds[ FAST_RELOAD ]; break; case 4: iPitch = 120; return GetWpnData().aShootSounds[ iIndex ]; break; case 3: iPitch = 115; return GetWpnData().aShootSounds[ iIndex ]; break; case 2: iPitch = 110; return GetWpnData().aShootSounds[ iIndex ]; break; case 1: iPitch = 105; return GetWpnData().aShootSounds[ iIndex ]; break; default: return GetWpnData().aShootSounds[ iIndex ]; break; }; } return GetShootSound( iIndex ); }
void CASW_Weapon_Sniper_Rifle::ItemPostFrame( void ) { BaseClass::ItemPostFrame(); CASW_Marine *pMarine = GetMarine(); if ( !pMarine ) return; // AIs switch out of zoom mode if ( !pMarine->IsInhabited() && IsZoomed() ) { m_bZoomed = false; } bool bAttack1, bAttack2, bReload, bOldReload, bOldAttack1; GetButtons( bAttack1, bAttack2, bReload, bOldReload, bOldAttack1 ); bool bOldAttack2 = false; if ( pMarine->IsInhabited() && pMarine->GetCommander() ) { bOldAttack2 = !!(pMarine->m_nOldButtons & IN_ATTACK2); } if ( bAttack2 && !bOldAttack2 ) { m_bZoomed = !IsZoomed(); } }
void CASW_Weapon_Blink::DoBlink() { CASW_Marine *pMarine = GetMarine(); if ( !pMarine ) return; pMarine->m_iJumpJetting = JJ_BLINK; pMarine->m_vecJumpJetStart = pMarine->GetAbsOrigin(); pMarine->m_vecJumpJetEnd = m_vecAbilityDestination; pMarine->m_flJumpJetStartTime = gpGlobals->curtime; pMarine->m_flJumpJetEndTime = gpGlobals->curtime + asw_blink_time.GetFloat(); ASWMeleeSystem()->StartMeleeAttack( ASWMeleeSystem()->GetMeleeAttackByName( "Blink" ), pMarine, ASWGameMovement()->GetMoveData() ); // TODO: /* #ifdef GAME_DLL // create a small stun volume at the start CASW_Weapon_EffectVolume *pEffect = (CASW_Weapon_EffectVolume*) CreateEntityByName("asw_weapon_effect_volume"); if ( pEffect ) { pEffect->SetAbsOrigin( pMarine->GetAbsOrigin() ); pEffect->SetOwnerEntity( pMarine ); pEffect->SetOwnerWeapon( NULL ); pEffect->SetEffectFlag( ASW_WEV_ELECTRIC_BIG ); pEffect->SetDuration( pSkill->GetValue( CASW_Skill_Details::Duration, GetSkillPoints() ) ); pEffect->Spawn(); } #endif */ m_flPower = 0.0f; // TODO: Check for charges being zero }
void CASW_Weapon_Chainsaw::CreateEffect( void ) { #ifndef CLIENT_DLL CASW_Marine *pMarine = GetMarine(); if ( !pMarine ) { return; } DestroyEffect(); m_hBeam = CBeam::BeamCreate( ASW_CHAINSAW_BEAM_SPRITE, 1.75 ); m_hBeam->PointEntInit( GetAbsOrigin(), this ); m_hBeam->SetBeamFlags( FBEAM_SINENOISE ); m_hBeam->SetEndAttachment( 1 ); m_hBeam->AddSpawnFlags( SF_BEAM_TEMPORARY ); // Flag these to be destroyed on save/restore or level transition m_hBeam->SetOwnerEntity( pMarine ); m_hBeam->SetScrollRate( 10 ); m_hBeam->SetBrightness( 200 ); m_hBeam->SetColor( 255, 255, 255 ); m_hBeam->SetNoise( 0.025 ); m_hNoise = CBeam::BeamCreate( ASW_CHAINSAW_BEAM_SPRITE, 2.5 ); m_hNoise->PointEntInit( GetAbsOrigin(), this ); m_hNoise->SetEndAttachment( 1 ); m_hNoise->AddSpawnFlags( SF_BEAM_TEMPORARY ); m_hNoise->SetOwnerEntity( pMarine ); m_hNoise->SetScrollRate( 25 ); m_hNoise->SetBrightness( 200 ); m_hNoise->SetColor( 255, 255, 255 ); m_hNoise->SetNoise( 0.8 ); #endif }
bool CASW_Weapon::DestroyIfEmpty( bool bDestroyWhenActive, bool bCheckSecondaryAmmo ) { CASW_Marine *pMarine = GetMarine(); if ( !pMarine ) return false; bool bActive = (pMarine->GetActiveASWWeapon() == this); if ( bActive && !bDestroyWhenActive ) return false; if ( bCheckSecondaryAmmo && (m_iClip2 || pMarine->GetAmmoCount(m_iSecondaryAmmoType) > 0) ) return false; if ( !m_iClip1 && pMarine->GetAmmoCount(m_iPrimaryAmmoType) <= 0) { #ifndef CLIENT_DLL if (pMarine) { pMarine->Weapon_Detach(this); if (bActive) pMarine->SwitchToNextBestWeapon(NULL); } Kill(); return true; #endif } return false; }
float CASW_Weapon_Hornet_Barrage::GetRocketFireInterval() { CASW_Marine *pMarine = GetMarine(); if ( !pMarine ) return 0.5f; return MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_GRENADES, ASW_MARINE_SUBSKILL_GRENADE_HORNET_INTERVAL ); }
void CASW_Weapon_Smart_Bomb::SetRocketsToFire() { CASW_Marine *pMarine = GetMarine(); if ( !pMarine ) return; m_iRocketsToFire = MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_GRENADES, ASW_MARINE_SUBSKILL_GRENADE_SMART_BOMB_COUNT ); }
float CASW_Weapon_Smart_Bomb::GetRocketFireInterval() { CASW_Marine *pMarine = GetMarine(); if ( !pMarine ) return 0.5f; return MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_GRENADES, ASW_MARINE_SUBSKILL_GRENADE_SMART_BOMB_INTERVAL ); }
void CASW_Weapon_Hornet_Barrage::SetRocketsToFire() { CASW_Marine *pMarine = GetMarine(); if ( !pMarine ) return; m_iRocketsToFire = MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_GRENADES, ASW_MARINE_SUBSKILL_GRENADE_HORNET_COUNT ); }
void CASW_Weapon_Freeze_Grenades::DelayedAttack( void ) { m_bShotDelayed = false; CASW_Player *pPlayer = GetCommander(); if ( !pPlayer ) return; CASW_Marine *pMarine = GetMarine(); if ( !pMarine || pMarine->GetWaterLevel() == 3 ) return; #ifndef CLIENT_DLL Vector vecSrc = pMarine->GetOffhandThrowSource(); Vector vecDest = pPlayer->GetCrosshairTracePos(); Vector newVel = UTIL_LaunchVector( vecSrc, vecDest, GetThrowGravity() ) * 28.0f; float fGrenadeRadius = GetBoomRadius( pMarine ); if (asw_debug_marine_damage.GetBool()) { Msg( "Freeze grenade radius = %f \n", fGrenadeRadius ); } pMarine->GetMarineSpeech()->Chatter( CHATTER_GRENADE ); // freeze aliens completely, plus the freeze duration float flFreezeAmount = 1.0f + MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_GRENADES, ASW_MARINE_SUBSKILL_GRENADE_FREEZE_DURATION); if (ASWGameRules()) ASWGameRules()->m_fLastFireTime = gpGlobals->curtime; CASW_Grenade_Freeze *pGrenade = CASW_Grenade_Freeze::Freeze_Grenade_Create( 1.0f, flFreezeAmount, fGrenadeRadius, 0, vecSrc, pMarine->EyeAngles(), newVel, AngularImpulse(0,0,0), pMarine, this ); if ( pGrenade ) { pGrenade->SetGravity( GetThrowGravity() ); pGrenade->SetExplodeOnWorldContact( true ); } #endif // decrement ammo m_iClip1 -= 1; #ifndef CLIENT_DLL DestroyIfEmpty( true ); #endif m_flSoonestPrimaryAttack = gpGlobals->curtime + ASW_FLARES_FASTEST_REFIRE_TIME; if (m_iClip1 > 0) // only force the fire wait time if we have ammo for another shot m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate(); else m_flNextPrimaryAttack = gpGlobals->curtime; }
void CASW_Weapon_Electrified_Armor::PrimaryAttack( void ) { if ( !ASWGameRules() ) return; CASW_Marine *pMarine = GetMarine(); if ( !pMarine || pMarine->IsElectrifiedArmorActive() ) return; #ifndef CLIENT_DLL bool bThisActive = (pMarine->GetActiveASWWeapon() == this); #endif // sets the animation on the marine holding this weapon //pMarine->SetAnimation( PLAYER_ATTACK1 ); #ifndef CLIENT_DLL float flDuration = asw_electrified_armor_duration.GetFloat(); pMarine->AddElectrifiedArmor( flDuration ); // stun aliens within the radius ASWGameRules()->ShockNearbyAliens( pMarine, this ); // CTakeDamageInfo info( this, GetOwnerEntity(), 5, DMG_SHOCK ); // info.SetDamageCustom( DAMAGE_FLAG_NO_FALLOFF ); // RadiusDamage( info, GetAbsOrigin(), flRadius, CLASS_ASW_MARINE, NULL ); DispatchParticleEffect( "electrified_armor_burst", pMarine->GetAbsOrigin(), QAngle( 0, 0, 0 ) ); // count as a shot fired if ( pMarine->GetMarineResource() ) { pMarine->GetMarineResource()->UsedWeapon( this , 1 ); pMarine->OnWeaponFired( this, 1 ); } #endif // decrement ammo m_iClip1 -= 1; m_flNextPrimaryAttack = gpGlobals->curtime + 4.0f; if (!m_iClip1 && pMarine->GetAmmoCount(m_iPrimaryAmmoType) <= 0) { // weapon is lost when all stims are gone #ifndef CLIENT_DLL if (pMarine) { pMarine->Weapon_Detach(this); if (bThisActive) pMarine->SwitchToNextBestWeapon(NULL); } Kill(); #endif } }
const Vector& CASW_Weapon_Hornet_Barrage::GetRocketFiringPosition() { CASW_Marine *pMarine = GetMarine(); if ( !pMarine ) return vec3_origin; static Vector vecSrc; vecSrc = pMarine->Weapon_ShootPosition(); return vecSrc; }
void CASW_Weapon_Welder::CreateWeldingEffects( C_ASW_Door* pDoor ) { if ( !m_bIsFiring || !GetOwner() || !pDoor ) return; if ( m_hWeldEffects ) { RemoveWeldingEffects(); } if ( !m_hWeldEffects ) { if ( m_bWeldSeal ) m_hWeldEffects = ParticleProp()->Create( "welding_door_seal", PATTACH_CUSTOMORIGIN ); else m_hWeldEffects = ParticleProp()->Create( "welding_door_cut", PATTACH_CUSTOMORIGIN ); if ( m_hWeldEffects ) { m_hWeldEffects->SetControlPoint( 0, pDoor->GetSparkNormal( GetMarine() ) ); m_hWeldEffects->SetControlPointForwardVector( 0, pDoor->GetWeldFacingPoint( GetMarine() ) ); } /* m_pLaserPointerEffect->SetControlPoint( 1, vecOrigin ); m_pLaserPointerEffect->SetControlPoint( 2, tr.endpos ); m_pLaserPointerEffect->SetControlPointForwardVector ( 1, vecDirShooting ); Vector vecImpactY, vecImpactZ; VectorVectors( tr.plane.normal, vecImpactY, vecImpactZ ); vecImpactY *= -1.0f; m_pLaserPointerEffect->SetControlPointOrientation( 2, vecImpactY, vecImpactZ, tr.plane.normal ); m_pLaserPointerEffect->SetControlPoint( 3, Vector( alpha, 0, 0 ) ); if ( m_hWeldEffects ) { ParticleProp()->AddControlPoint( m_pLaserPointerEffect, 1, this, PATTACH_CUSTOMORIGIN ); ParticleProp()->AddControlPoint( m_pLaserPointerEffect, 2, this, PATTACH_CUSTOMORIGIN ); } */ } }
float CASW_Weapon::GetReloadTime() { // can adjust for marine's weapon skill here float fReloadTime = GetWeaponInfo()->flReloadTime; if (GetMarine()) { float fSpeedScale = MarineSkills()->GetSkillBasedValueByMarine(GetMarine(), ASW_MARINE_SKILL_RELOADING, ASW_MARINE_SUBSKILL_RELOADING_SPEED_SCALE); fReloadTime *= fSpeedScale; // riflemod: bots reload very fast because they are stupid to die // during long reloads if ( !GetMarine()->IsInhabited() ) { fReloadTime = 1.0f; } } //CALL_ATTRIB_HOOK_FLOAT( fReloadTime, mod_reload_time ); return fReloadTime; }
float CASW_Weapon_Medical_Satchel::GetInfestationCureAmount() { CASW_Marine *pMarine = GetMarine(); if (!pMarine) return 0.0f; float flCureAmount = MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_XENOWOUNDS) / 100.0f; //CALL_ATTRIB_HOOK_FLOAT( flCureAmount, mod_xenowound_bonus ); return flCureAmount; }
float CASW_Weapon_Minigun::GetMuzzleFlashScale( void ) { // if we haven't calculated the muzzle scale based on the carrying marine's skill yet, then do so if (m_fMuzzleFlashScale == -1) { C_ASW_Marine *pMarine = GetMarine(); if (pMarine) m_fMuzzleFlashScale = 2.0f * MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_AUTOGUN, ASW_MARINE_SUBSKILL_AUTOGUN_MUZZLE); else return 2.0f; } return m_fMuzzleFlashScale; }