void AvHGamerules::AwardExperience(AvHPlayer* inPlayer, int inTargetLevel, bool inAwardFriendliesInRange) { PlayerListType thePlayerList; thePlayerList.push_back(inPlayer); if(inAwardFriendliesInRange) { // Award experience to player, and any other players nearby int theExperienceRadius = BALANCE_IVAR(kCombatFriendlyNearbyRange); // Make list of players to split it between. If a player is at full experience, extra is wasted. CBaseEntity* theEntity = NULL; while ((theEntity = UTIL_FindEntityInSphere(theEntity, inPlayer->pev->origin, theExperienceRadius)) != NULL) { const char* theClassName = STRING(theEntity->pev->classname); if(!AvHSUGetIsExternalClassName(theClassName)) { AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theEntity); if(thePlayer && (thePlayer != inPlayer) && (thePlayer->pev->team == inPlayer->pev->team) && thePlayer->GetIsRelevant() && !thePlayer->GetIsBeingDigested()) { thePlayerList.push_back(thePlayer); } } } } ASSERT(thePlayerList.size() > 0); float theExperienceFactor = GetGameRules()->GetIsIronMan() ? BALANCE_FVAR(kCombatIronManExperienceScalar) : 1.0f; int theExperienceToAward = BALANCE_IVAR(kCombatExperienceBaseAward) + inTargetLevel*BALANCE_IVAR(kCombatExperienceLevelAward); float theExperienceForEach = (theExperienceToAward/(float)thePlayerList.size() + BALANCE_IVAR(kCombatExperienceCrowdAward))*theExperienceFactor; for(PlayerListType::iterator thePlayerIter = thePlayerList.begin(); thePlayerIter != thePlayerList.end(); thePlayerIter++) { AvHPlayer* theCurrentPlayer = (*thePlayerIter); theCurrentPlayer->SetExperience(theCurrentPlayer->GetExperience() + theExperienceForEach); } }