[svn] * Fixed xp calculation for low level characters when grouped with a higher level player. Patch provided by Reiner030.

* Fixed positive spells being not resistable when cast on hostile units. Patch provided by QAston.
* Fixed compile warnings in gcc. Patch provided by WarHead.

--HG--
branch : trunk
This commit is contained in:
w12x
2008-10-26 11:50:07 -05:00
parent 55c25d894e
commit 6f2e0ee48a
10 changed files with 31 additions and 18 deletions

View File

@@ -720,7 +720,7 @@ void ArenaTeam::UpdateArenaPointsHelper()
if(stats.games < 10)
return;
// to get points, a player has to participate in at least 30% of the matches
uint32 min_plays = ceil(stats.games * 0.3);
uint32 min_plays = (uint32)ceil(stats.games * 0.3);
for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
{
// the player participated in enough games, update his points

View File

@@ -29,7 +29,7 @@ namespace Trinity
{
inline uint32 hk_honor_at_level(uint32 level, uint32 count=1)
{
return ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f )));
return (uint32) ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f )));
}
}
namespace XP

View File

@@ -1527,8 +1527,8 @@ void GameEvent::SendWorldStateUpdate(Player * plr, uint16 event_id)
for(itr = mGameEvent[event_id].conditions.begin(); itr !=mGameEvent[event_id].conditions.end(); ++itr)
{
if(itr->second.done_world_state)
plr->SendUpdateWorldState(itr->second.done_world_state, itr->second.done);
plr->SendUpdateWorldState(itr->second.done_world_state, (uint32)(itr->second.done));
if(itr->second.max_world_state)
plr->SendUpdateWorldState(itr->second.max_world_state, itr->second.reqNum);
plr->SendUpdateWorldState(itr->second.max_world_state, (uint32)(itr->second.reqNum));
}
}

View File

@@ -26,6 +26,7 @@
#include "World.h"
#include "ObjectMgr.h"
#include "Group.h"
#include "Formulas.h"
#include "ObjectAccessor.h"
#include "BattleGround.h"
#include "MapManager.h"
@@ -785,7 +786,7 @@ void Group::SetTargetIcon(uint8 id, uint64 guid)
BroadcastPacket(&data);
}
void Group::GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_level, Player* & member_with_max_level)
void Group::GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_level, Player* & member_with_max_level, Player* & not_gray_member_with_max_level)
{
for(GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next())
{
@@ -798,8 +799,16 @@ void Group::GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_lev
++count;
sum_level += member->getLevel();
// store maximum member level
if(!member_with_max_level || member_with_max_level->getLevel() < member->getLevel())
member_with_max_level = member;
uint32 gray_level = Trinity::XP::GetGrayLevel(member->getLevel());
// if the victim is higher level than the gray level of the currently examined group member,
// then set not_gray_member_with_max_level if needed.
if( victim->getLevel() > gray_level && (!not_gray_member_with_max_level
|| not_gray_member_with_max_level->getLevel() < member->getLevel()))
not_gray_member_with_max_level = member;
}
}

View File

@@ -217,7 +217,7 @@ class TRINITY_DLL_SPEC Group
MemberSlotList const& GetMemberSlots() const { return m_memberSlots; }
GroupReference* GetFirstMember() { return m_memberMgr.getFirst(); }
uint32 GetMembersCount() const { return m_memberSlots.size(); }
void GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_level, Player* & member_with_max_level);
void GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_level, Player* & member_with_max_level, Player* & not_gray_member_with_max_level);
uint8 GetMemberGroup(uint64 guid) const
{
member_citerator mslot = _getMemberCSlot(guid);

View File

@@ -121,7 +121,7 @@ bool OutdoorPvPHP::Update(uint32 diff)
else if(m_HordeTowersControlled == 3)
BuffTeam(HORDE);
else
BuffTeam(NULL);
BuffTeam(0);
SendUpdateWorldState(HP_UI_TOWER_COUNT_A, m_AllianceTowersControlled);
SendUpdateWorldState(HP_UI_TOWER_COUNT_H, m_HordeTowersControlled);
}

View File

@@ -588,7 +588,7 @@ bool Player::Create( uint32 guidlow, std::string name, uint8 race, uint8 class_,
else
SetUInt32Value( UNIT_FIELD_LEVEL, sWorld.getConfig(CONFIG_START_PLAYER_LEVEL) );
// set starting gold
SetUInt32Value( PLAYER_FIELD_COINAGE, sWorld.getConfig(CONFIG_PLAYER_START_GOLD)*10000 );
SetUInt32Value( PLAYER_FIELD_COINAGE, sWorld.getConfig(CONFIG_PLAYER_START_GOLD) );
// set starting honor
SetUInt32Value( PLAYER_FIELD_HONOR_CURRENCY, sWorld.getConfig(CONFIG_PLAYER_START_HONOR) );
@@ -18187,12 +18187,16 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim)
uint32 count = 0;
uint32 sum_level = 0;
Player* member_with_max_level = NULL;
Player* not_gray_member_with_max_level = NULL;
pGroup->GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level);
// gets the max member level of the group, and the max member level that still gets XP
pGroup->GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level,not_gray_member_with_max_level);
if(member_with_max_level)
{
xp = PvP ? 0 : Trinity::XP::Gain(member_with_max_level, pVictim);
// PvP kills doesn't yield experience
// also no XP gained if there is no member below gray level
xp = (PvP || !not_gray_member_with_max_level) ? 0 : Trinity::XP::Gain(not_gray_member_with_max_level, pVictim);
// skip in check PvP case (for speed, not used)
bool is_raid = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsRaid() && pGroup->isRaidGroup();
@@ -18222,9 +18226,10 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim)
pGroupGuy->RewardReputation(pVictim,is_dungeon ? 1.0f : rate);
// XP updated only for alive group member
if(pGroupGuy->isAlive())
if(pGroupGuy->isAlive() && not_gray_member_with_max_level &&
pGroupGuy->getLevel() <= not_gray_member_with_max_level->getLevel())
{
uint32 itr_xp = uint32(xp*rate);
uint32 itr_xp = (member_with_max_level == not_gray_member_with_max_level) ? uint32(xp*rate) : uint32((xp*rate/2)+1);
pGroupGuy->GiveXP(itr_xp, pVictim);
if(Pet* pet = pGroupGuy->GetPet())

View File

@@ -176,4 +176,4 @@ bool Totem::IsImmunedToSpell(SpellEntry const* spellInfo, bool useCharges)
}
}
return Creature::IsImmunedToSpell(spellInfo, useCharges);
}
}

View File

@@ -2827,7 +2827,8 @@ SpellMissInfo Unit::SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool
// All positive spells can`t miss
// TODO: client not show miss log for this spells - so need find info for this in dbc and use it!
if (IsPositiveSpell(spell->Id))
if (IsPositiveSpell(spell->Id)
&&(!IsHostileTo(pVictim))) //prevent from affecting enemy by "positive" spell
return SPELL_MISS_NONE;
// Check for immune (use charges)

View File

@@ -766,7 +766,7 @@ void World::LoadConfigSettings(bool reload)
m_configs[CONFIG_THREAT_RADIUS] = sConfig.GetIntDefault("ThreatRadius", 100);
// always use declined names in the russian client
// always use declined names in the Russian client
m_configs[CONFIG_DECLINED_NAMES_USED] =
(m_configs[CONFIG_REALM_ZONE] == REALM_ZONE_RUSSIAN) ? true : sConfig.GetBoolDefault("DeclinedNames", false);
@@ -774,9 +774,7 @@ void World::LoadConfigSettings(bool reload)
m_configs[CONFIG_LISTEN_RANGE_TEXTEMOTE] = sConfig.GetIntDefault("ListenRange.TextEmote", 25);
m_configs[CONFIG_LISTEN_RANGE_YELL] = sConfig.GetIntDefault("ListenRange.Yell", 300);
m_configs[CONFIG_PLAYER_START_GOLD] = sConfig.GetFloatDefault("PlayerStart.Gold", 0);
if(m_configs[CONFIG_PLAYER_START_GOLD] < 0)
m_configs[CONFIG_PLAYER_START_GOLD] = 0;
m_configs[CONFIG_PLAYER_START_GOLD] = (uint32)(sConfig.GetFloatDefault("PlayerStart.Gold", 0.0f) * 10000.0f);
if(m_configs[CONFIG_PLAYER_START_GOLD] > MAX_MONEY_AMOUNT)
m_configs[CONFIG_PLAYER_START_GOLD] = MAX_MONEY_AMOUNT;