Simplified and cleaned up honor calculation.

--HG--
branch : trunk
This commit is contained in:
Xanadu
2010-06-25 15:58:27 +02:00
parent 66535c3700
commit fec8ca58b5
6 changed files with 57 additions and 59 deletions
@@ -1891,8 +1891,8 @@ void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, const uint6
uint32 win_arena = plr->GetRandomWinner() ? BG_REWARD_WINNER_ARENA_LAST : BG_REWARD_WINNER_ARENA_FIRST;
uint32 loos_kills = plr->GetRandomWinner() ? BG_REWARD_LOOSER_HONOR_LAST : BG_REWARD_LOOSER_HONOR_FIRST;
win_kills = (uint32)Trinity::Honor::hk_honor_at_level(plr->getLevel(), win_kills);
loos_kills = (uint32)Trinity::Honor::hk_honor_at_level(plr->getLevel(), loos_kills);
win_kills = Trinity::Honor::hk_honor_at_level(plr->getLevel(), win_kills);
loos_kills = Trinity::Honor::hk_honor_at_level(plr->getLevel(), loos_kills);
data->Initialize(SMSG_BATTLEFIELD_LIST);
*data << uint64(guid); // battlemaster guid
@@ -522,7 +522,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const *pQuest, uint64 npcGUID,
}
// rewarded honor points. Multiply with 10 to satisfy client
data << uint32(10*Trinity::Honor::hk_honor_at_level(pSession->GetPlayer()->getLevel(), pQuest->GetRewHonorableKills()));
data << 10 * Trinity::Honor::hk_honor_at_level(pSession->GetPlayer()->getLevel(), pQuest->GetRewHonorableKills());
data << float(0); // new 3.3.0, honor multiplier?
data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast == 0)
data << int32(pQuest->GetRewSpellCast()); // casted spell
@@ -616,7 +616,7 @@ void PlayerMenu::SendQuestQueryResponse(Quest const *pQuest)
data << int32(pQuest->GetRewSpellCast()); // casted spell
// rewarded honor points
data << uint32(Trinity::Honor::hk_honor_at_level(pSession->GetPlayer()->getLevel(), pQuest->GetRewHonorableKills()));
data << Trinity::Honor::hk_honor_at_level(pSession->GetPlayer()->getLevel(), pQuest->GetRewHonorableKills());
data << float(0); // new reward honor (multipled by ~62 at client side)
data << uint32(pQuest->GetSrcItemId()); // source item id
data << uint32(pQuest->GetFlags() & 0xFFFF); // quest flags
@@ -775,7 +775,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* pQuest, uint64 npcGUID,
data << uint32(pQuest->XPValue(pSession->GetPlayer())*sWorld.getRate(RATE_XP_QUEST));
// rewarded honor points. Multiply with 10 to satisfy client
data << uint32(10*Trinity::Honor::hk_honor_at_level(pSession->GetPlayer()->getLevel(), pQuest->GetRewHonorableKills()));
data << 10 * Trinity::Honor::hk_honor_at_level(pSession->GetPlayer()->getLevel(), pQuest->GetRewHonorableKills());
data << float(0); // unk, honor multiplier?
data << uint32(0x08); // unused by client?
data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast == 0)
+25 -32
View File
@@ -6600,7 +6600,7 @@ void Player::UpdateHonorFields()
///Calculate the amount of honor gained based on the victim
///and the size of the group for which the honor is divided
///An exact honor value can also be given (overriding the calcs)
bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor, bool pvptoken)
bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, int32 honor, bool pvptoken)
{
// do not reward honor in arenas, but enable onkill spellproc
if (InArena())
@@ -6620,8 +6620,6 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor, bool pvpt
uint64 victim_guid = 0;
uint32 victim_rank = 0;
//uint32 rank_diff = 0;
//time_t now = time(NULL);
// need call before fields update to have chance move yesterday data to appropriate fields before today data change.
UpdateHonorFields();
@@ -6630,7 +6628,10 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor, bool pvpt
if (InBattleGround() && GetBattleGround() && GetBattleGround()->isArena())
return true;
if (honor <= 0)
// Promote to float for calculations
float honor_f = honor;
if (honor_f <= 0)
{
if (!uVictim || uVictim == this || uVictim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT))
return false;
@@ -6644,12 +6645,13 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor, bool pvpt
if (GetTeam() == pVictim->GetTeam() && !sWorld.IsFFAPvPRealm())
return false;
float f = 1; //need for total kills (?? need more info)
uint32 k_grey = 0;
uint32 k_level = getLevel();
uint32 v_level = pVictim->getLevel();
uint8 k_level = getLevel();
uint8 k_grey = Trinity::XP::GetGrayLevel(k_level);
uint8 v_level = pVictim->getLevel();
if (v_level <= k_grey)
return false;
{
// PLAYER_CHOSEN_TITLE VALUES DESCRIPTION
// [0] Just name
// [1..14] Alliance honor titles and player name
@@ -6670,19 +6672,8 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor, bool pvpt
victim_rank = victim_title - 14 + 4;
else
victim_guid = 0; // Don't show HK: <rank> message, only log.
}
k_grey = Trinity::XP::GetGrayLevel(k_level);
if (v_level <= k_grey)
return false;
float diff_level = (k_level == k_grey) ? 1 : ((float(v_level) - float(k_grey)) / (float(k_level) - float(k_grey)));
int32 v_rank =1; //need more info
honor = ((f * diff_level * (190 + v_rank*10))/6);
honor *= ((float)k_level) / 21.50537f; //factor of dependence on levels of the killer
honor_f = ceil(Trinity::Honor::hk_honor_at_level_f(k_level) * (v_level - k_grey) / (k_level - k_grey));
// count the number of playerkills in one day
ApplyModUInt32Value(PLAYER_FIELD_KILLS, 1, true);
@@ -6697,7 +6688,7 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor, bool pvpt
if (!uVictim->ToCreature()->isRacialLeader())
return false;
honor = 100; // ??? need more info
honor_f = 100.0f; // ??? need more info
victim_rank = 19; // HK: Leader
}
}
@@ -6705,35 +6696,37 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor, bool pvpt
if (uVictim != NULL)
{
if (groupsize > 1)
honor /= groupsize;
honor_f /= groupsize;
// apply honor multiplier from aura (not stacking-get highest)
honor = int32(float(honor) * (float(GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HONOR_GAIN_PCT))+100.0f)/100.0f);
honor_f *= (GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HONOR_GAIN_PCT) + 100) / 100.0f;
}
honor *= sWorld.getRate(RATE_HONOR);
honor_f *= sWorld.getRate(RATE_HONOR);
// Back to int now
honor = honor_f;
// honor - for show honor points in log
// victim_guid - for show victim name in log
// victim_rank [1..4] HK: <dishonored rank>
// victim_rank [5..19] HK: <alliance\horde rank>
// victim_rank [0,20+] HK: <>
WorldPacket data(SMSG_PVP_CREDIT,4+8+4);
data << (uint32) honor;
data << (uint64) victim_guid;
data << (uint32) victim_rank;
data << honor;
data << victim_guid;
data << victim_rank;
GetSession()->SendPacket(&data);
// add honor points
ModifyHonorPoints(int32(honor));
ModifyHonorPoints(honor);
ApplyModUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, uint32(honor), true);
ApplyModUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, honor, true);
if (InBattleGround() && honor > 0)
{
if (BattleGround *bg = GetBattleGround())
{
bg->UpdatePlayerScore(this, SCORE_BONUS_HONOR, uint32(honor), false);//false: prevent looping
bg->UpdatePlayerScore(this, SCORE_BONUS_HONOR, honor, false); //false: prevent looping
}
}
@@ -15524,7 +15517,7 @@ void Player::SendQuestReward(Quest const *pQuest, uint32 XP, Object * questGiver
data << uint32(pQuest->GetRewOrReqMoney() + int32(pQuest->GetRewMoneyMaxLevel() * sWorld.getRate(RATE_DROP_MONEY)));
}
data << uint32(10*Trinity::Honor::hk_honor_at_level(getLevel(), pQuest->GetRewHonorableKills()));
data << 10 * Trinity::Honor::hk_honor_at_level(getLevel(), pQuest->GetRewHonorableKills());
data << uint32(pQuest->GetBonusTalents()); // bonus talents
data << uint32(pQuest->GetRewArenaPoints());
GetSession()->SendPacket(&data);
+1 -1
View File
@@ -1918,7 +1918,7 @@ class Player : public Unit, public GridObject<Player>
/*** PVP SYSTEM ***/
/*********************************************************/
void UpdateHonorFields();
bool RewardHonor(Unit *pVictim, uint32 groupsize, float honor = -1, bool pvptoken = false);
bool RewardHonor(Unit *pVictim, uint32 groupsize, int32 honor = -1, bool pvptoken = false);
uint32 GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); }
uint32 GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY); }
void ModifyHonorPoints(int32 value);
+6 -1
View File
@@ -27,9 +27,14 @@ namespace Trinity
{
namespace Honor
{
inline float hk_honor_at_level_f(uint8 level, uint32 count = 1)
{
return count * level * 1.55f;
}
inline uint32 hk_honor_at_level(uint8 level, uint32 count = 1)
{
return uint32(ceil(count * (33.333f * ((float)level) / 21.50537f)));
return ceil(hk_honor_at_level_f(level, count));
}
}
namespace XP