void CASW_Weapon_Medkit::SelfHeal() { CASW_Marine *pMarine = GetMarine(); if (pMarine) // firing from a marine { if (pMarine->GetHealth() >= pMarine->GetMaxHealth()) // already on full health return; if (pMarine->GetHealth() <= 0) // aleady dead! return; if (pMarine->m_bSlowHeal) // already healing return; if (pMarine->GetFlags() & FL_FROZEN) // don't allow this if the marine is frozen return; // MUST call sound before removing a round from the clip of a CMachineGun WeaponSound(SINGLE); // sets the animation on the weapon model iteself SendWeaponAnim( GetPrimaryAttackActivity() ); // sets the animation on the marine holding this weapon //pMarine->SetAnimation( PLAYER_ATTACK1 ); #ifndef CLIENT_DLL bool bMedic = (pMarine->GetMarineProfile() && pMarine->GetMarineProfile()->CanUseFirstAid()); // put a slow heal onto the marine, play a particle effect if (!pMarine->m_bSlowHeal && pMarine->GetHealth() < pMarine->GetMaxHealth()) { pMarine->AddSlowHeal( GetHealAmount(), 1, pMarine, this ); // Fire event IGameEvent * event = gameeventmanager->CreateEvent( "player_heal" ); if ( event ) { CASW_Player *pPlayer = GetCommander(); event->SetInt( "userid", ( pPlayer ? pPlayer->GetUserID() : 0 ) ); event->SetInt( "entindex", pMarine->entindex() ); gameeventmanager->FireEvent( event ); } if ( ASWGameRules()->GetInfoHeal() ) { ASWGameRules()->GetInfoHeal()->OnMarineHealed( pMarine, pMarine, this ); } pMarine->OnWeaponFired( this, 1 ); } if (pMarine->IsInfested() && bMedic) { float fCure = GetInfestationCureAmount(); // cure infestation if (fCure < 100) pMarine->CureInfestation(pMarine, fCure); } #endif // decrement ammo m_iClip1 -= 1; #ifndef CLIENT_DLL DestroyIfEmpty( false ); #endif } }
void CASW_Weapon_Medical_Satchel::GiveHealthTo( CASW_Marine *pTarget ) { if ( !pTarget || m_iClip1 <= 0 ) return; if ( pTarget->GetHealth() >= pTarget->GetMaxHealth() ) // already on full health return; if ( pTarget->GetHealth() <= 0 ) // target is dead! return; if ( pTarget->m_bSlowHeal ) // already healing return; CASW_Marine *pMarine = GetMarine(); if ( !pMarine ) return; if ( pMarine->GetFlags() & FL_FROZEN ) // don't allow this if the marine is frozen return; // check if we're close enough Vector diff = pMarine->GetAbsOrigin() - pTarget->GetAbsOrigin(); if ( diff.Length() > MAX_HEAL_DISTANCE_SERVER ) // add a bit of leeway to account for lag return; bool bMedic = pMarine && pMarine->GetMarineProfile() && pMarine->GetMarineProfile()->CanUseFirstAid(); //pMarine->DoAnimationEvent(PLAYERANIMEVENT_HEAL); WeaponSound(SINGLE); int iHealAmount = GetHealAmount(); pTarget->AddSlowHeal(iHealAmount, 1, pMarine, this ); // Fire event IGameEvent * event = gameeventmanager->CreateEvent( "player_heal" ); if ( event ) { CASW_Player *pPlayer = GetCommander(); event->SetInt( "userid", ( pPlayer ? pPlayer->GetUserID() : 0 ) ); event->SetInt( "entindex", pTarget->entindex() ); gameeventmanager->FireEvent( event ); } ASWFailAdvice()->OnMarineHealed(); if ( ASWGameRules()->GetInfoHeal() ) { ASWGameRules()->GetInfoHeal()->OnMarineHealed( GetMarine(), pTarget, this ); } m_iClip1 -= 1; if ( bMedic ) { if (pTarget->IsInfested()) { float fCurePercent = GetInfestationCureAmount(); // cure infestation if ( fCurePercent > 0 && fCurePercent < 100 ) { pTarget->CureInfestation(pMarine, fCurePercent); } } bool bSkipChatter = pTarget->IsInfested(); int iTotalMeds = GetTotalMeds(); if ( m_iClip1 <= 0 ) { if ( iTotalMeds <= 0 ) { ASWFailAdvice()->OnMedSatchelEmpty(); pMarine->GetMarineSpeech()->Chatter( CHATTER_MEDS_NONE ); bSkipChatter = true; } DestroyIfEmpty( false, true ); // out of medical charges, remove this item } else if ( iTotalMeds <= 1 ) { if ( pMarine->GetMarineSpeech()->Chatter( CHATTER_MEDS_LOW ) ) { bSkipChatter = true; } } if ( !bSkipChatter ) { // try and do a special chatter? bool bSkipChatter = false; if (pMarine->GetMarineSpeech()->AllowCalmConversations(CONV_HEALING_CRASH)) { if (!pTarget->m_bDoneWoundedRebuke && pTarget->GetMarineResource() && pTarget->GetMarineResource()->m_bTakenWoundDamage) { // marine has been wounded and this is our first heal after the fact - good chance of the medic saying something if (random->RandomFloat() < asw_marine_special_heal_chatter_chance.GetFloat() * 3) { if (CASW_MarineSpeech::StartConversation(CONV_SERIOUS_INJURY, pMarine, pTarget)) { bSkipChatter = true; pTarget->m_bDoneWoundedRebuke = true; } } } // if we didn't complaint about a serious injury, check for doing a different kind of conv float fRand = random->RandomFloat(); if (!bSkipChatter && fRand < asw_marine_special_heal_chatter_chance.GetFloat()) { if (pTarget->GetMarineProfile() && pTarget->GetMarineProfile()->m_VoiceType == ASW_VOICE_CRASH && pMarine->GetMarineProfile() && pMarine->GetMarineProfile()->m_VoiceType == ASW_VOICE_BASTILLE) // bastille healing crash { if (random->RandomFloat() < 0.5f) { if (CASW_MarineSpeech::StartConversation(CONV_HEALING_CRASH, pMarine, pTarget)) bSkipChatter = true; } else { if (CASW_MarineSpeech::StartConversation(CONV_MEDIC_COMPLAIN, pMarine, pTarget)) bSkipChatter = true; } } else { if (CASW_MarineSpeech::StartConversation(CONV_MEDIC_COMPLAIN, pMarine, pTarget)) bSkipChatter = true; } } } if (!bSkipChatter) pMarine->GetMarineSpeech()->Chatter(CHATTER_HEALING); } } }