// if the player has his mouse over another marine, highlight it, cos he's the one we can give health to void CASW_Weapon_Medical_Satchel::MouseOverEntity(C_BaseEntity *pEnt, Vector vecWorldCursor) { C_ASW_Marine* pOtherMarine = C_ASW_Marine::AsMarine( pEnt ); CASW_Player *pOwner = GetCommander(); CASW_Marine *pMarine = GetMarine(); if (!pOwner || !pMarine) return; float fOtherHealth = 1.0f; if (pOtherMarine && pOtherMarine->GetMarineResource()) fOtherHealth = pOtherMarine->GetMarineResource()->GetHealthPercent(); if (!pOtherMarine) { C_ASW_Game_Resource *pGameResource = ASWGameResource(); if (pGameResource) { // find marine closest to world cursor const float fMustBeThisClose = 70; const C_ASW_Game_Resource::CMarineToCrosshairInfo::tuple_t &info = pGameResource->GetMarineCrosshairCache()->GetClosestMarine(); if ( info.m_fDistToCursor <= fMustBeThisClose ) { pOtherMarine = info.m_hMarine.Get(); } } } // if the marine our cursor is over is near enough, highlight him if (pOtherMarine) { float dist = (pMarine->GetAbsOrigin() - pOtherMarine->GetAbsOrigin()).Length2D(); if (dist < MAX_HEAL_DISTANCE) { bool bCanGiveHealth = ( fOtherHealth < 1.0f && m_iClip1 > 0 ); ASWInput()->SetHighlightEntity( pOtherMarine, bCanGiveHealth ); if ( bCanGiveHealth ) // if he needs healing, show the give health cursor { CASWHudCrosshair *pCrosshair = GET_HUDELEMENT( CASWHudCrosshair ); if ( pCrosshair ) { pCrosshair->SetShowGiveHealth(true); } } } } }
void CASWInput::UpdateHighlightEntity() { // if we're currently brightening any entity, stop SetHighlightEntity( NULL, false ); // clear any additional cursor icons CASWHudCrosshair *pCrosshair = GET_HUDELEMENT( CASWHudCrosshair ); if ( pCrosshair ) { pCrosshair->SetShowGiveAmmo(false, -1); pCrosshair->SetShowGiveHealth( false ); } C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer(); if ( !pPlayer ) return; C_ASW_Marine* pMarine = pPlayer->GetMarine(); if ( !pMarine ) return; // see if the marine and his weapons want to highlight the current entity, or something near the cursor pMarine->MouseOverEntity( GetMouseOverEntity(), GetCrosshairAimingPos() ); }