aboutsummaryrefslogtreecommitdiff
path: root/src/game/ArenaTeam.cpp
diff options
context:
space:
mode:
authorn0n4m3 <none@none>2009-12-17 10:35:35 +0100
committern0n4m3 <none@none>2009-12-17 10:35:35 +0100
commit2edfea7bb905413db649d1a75d1495657adc4219 (patch)
treebac720de3165296f3396bdb796d9ef1ff9ea0add /src/game/ArenaTeam.cpp
parent64e03d6f3f5037f2217194e8d998c6a92ae2ba36 (diff)
Update Arena and Achievement for 322a
--HG-- branch : trunk
Diffstat (limited to 'src/game/ArenaTeam.cpp')
-rw-r--r--src/game/ArenaTeam.cpp99
1 files changed, 40 insertions, 59 deletions
diff --git a/src/game/ArenaTeam.cpp b/src/game/ArenaTeam.cpp
index feeae849bae..1d9669007fc 100644
--- a/src/game/ArenaTeam.cpp
+++ b/src/game/ArenaTeam.cpp
@@ -24,11 +24,12 @@
void ArenaTeamMember::ModifyPersonalRating(Player* plr, int32 mod, uint32 slot)
{
- int32 memberRating = int32(personal_rating) + mod;
- personal_rating = memberRating > 0 ? memberRating : 0;
- if(plr)
- plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot*6) + 5, personal_rating);
- //sLog.outArena("Modify personal rating for player %s: personal rating %u, mod %d, rating %d", plr->GetName(), personal_rating, mod, rating);
+ if (int32(personal_rating) + mod < 0)
+ personal_rating = 0;
+ else
+ personal_rating += mod;
+ if(plr)
+ plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING, personal_rating);
}
ArenaTeam::ArenaTeam()
@@ -109,7 +110,7 @@ bool ArenaTeam::AddMember(const uint64& PlayerGuid)
return false;
}
- plClass = (uint8)pl->getClass();
+ plClass = pl->getClass();
plName = pl->GetName();
}
else
@@ -146,7 +147,7 @@ bool ArenaTeam::AddMember(const uint64& PlayerGuid)
if (sWorld.getConfig(CONFIG_ARENA_SEASON_ID) >= 6)
{
if (m_stats.rating < 1000)
- newmember.personal_rating = m_stats.rating;
+ newmember.personal_rating = 0;
else
newmember.personal_rating = 1000;
}
@@ -160,13 +161,13 @@ bool ArenaTeam::AddMember(const uint64& PlayerGuid)
if(pl)
{
- pl->SetInArenaTeam(m_TeamId, GetSlot());
+ pl->SetInArenaTeam(m_TeamId, GetSlot(), GetType());
pl->SetArenaTeamIdInvited(0);
- pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot()*6) + 5, newmember.personal_rating );
+ pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING, newmember.personal_rating );
// hide promote/remove buttons
if(m_CaptainGuid != PlayerGuid)
- pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * 6) + 1, 1);
+ pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_MEMBER, 1);
sLog.outArena("Player: %s [GUID: %u] joined arena team type: %u [Id: %u].", pl->GetName(), pl->GetGUIDLow(), GetType(), GetId());
}
return true;
@@ -263,7 +264,7 @@ void ArenaTeam::SetCaptain(const uint64& guid)
// disable remove/promote buttons
Player *oldcaptain = objmgr.GetPlayer(GetCaptain());
if(oldcaptain)
- oldcaptain->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 + (GetSlot() * 6), 1);
+ oldcaptain->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_MEMBER, 1);
// set new captain
m_CaptainGuid = guid;
@@ -275,7 +276,7 @@ void ArenaTeam::SetCaptain(const uint64& guid)
Player *newcaptain = objmgr.GetPlayer(guid);
if(newcaptain)
{
- newcaptain->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 + (GetSlot() * 6), 0);
+ newcaptain->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_MEMBER, 0);
sLog.outArena("Player: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team [Id: %u] [Type: %u].", oldcaptain->GetName(), oldcaptain->GetGUIDLow(), newcaptain->GetName(), newcaptain->GetGUIDLow(), GetId(), GetType());
}
}
@@ -291,17 +292,12 @@ void ArenaTeam::DelMember(uint64 guid)
}
}
- Player *player = objmgr.GetPlayer(guid);
-
- if(player)
+ if(Player *player = objmgr.GetPlayer(guid))
{
- player->SetInArenaTeam(0, GetSlot());
player->GetSession()->SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, GetName(), "", 0);
// delete all info regarding this team
- for (uint8 i = 0; i < 6; ++i)
- {
- player->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * 6) + i, 0);
- }
+ for(uint32 i = 0; i < ARENA_TEAM_END; ++i)
+ player->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + i, 0);
sLog.outArena("Player: %s [GUID: %u] left arena team type: %u [Id: %u].", player->GetName(), player->GetGUIDLow(), GetType(), GetId());
}
CharacterDatabase.PExecute("DELETE FROM arena_team_member WHERE arenateamid = '%u' AND guid = '%u'", GetId(), GUID_LOPART(guid));
@@ -513,8 +509,7 @@ uint32 ArenaTeam::GetPoints(uint32 MemberRating)
uint32 rating = MemberRating + 150 < m_stats.rating ? MemberRating : m_stats.rating;
if(rating<=1500)
- // points = (float)1500 * 0.22f + 14.0f;
- points = 344.0f; // 3.1 change - teams with rating below 1500 get arena points for 1500 rating
+ points = (float)rating * 0.22f + 14.0f;
else
points = 1511.26f / (1.0f + 1639.28f * exp(-0.00412f * (float)rating));
@@ -533,8 +528,8 @@ float ArenaTeam::GetChanceAgainst(uint32 own_rating, uint32 enemy_rating)
// ELO system
if (sWorld.getConfig(CONFIG_ARENA_SEASON_ID) >= 6)
- if (enemy_rating < 1300)
- enemy_rating = 1300;
+ if (enemy_rating < 1000)
+ enemy_rating = 1000;
return 1.0f/(1.0f+exp(log(10.0f)*(float)((float)enemy_rating - (float)own_rating)/400.0f));
}
@@ -560,10 +555,12 @@ void ArenaTeam::FinishGame(int32 mod)
int32 ArenaTeam::WonAgainst(uint32 againstRating)
{
// called when the team has won
- //'chance' calculation - to beat the opponent
+ // 'chance' calculation - to beat the opponent
float chance = GetChanceAgainst(m_stats.rating, againstRating);
- // calculate the rating modification (ELO system with k=32)
- int32 mod = (int32)floor(32.0f * (1.0f - chance));
+ float K = (m_stats.rating < 1000) ? 48.0f : 32.0f;
+ // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000)
+ int32 mod = (int32)floor(K* (1.0f - chance));
+
// modify the team stats accordingly
FinishGame(mod);
m_stats.wins_week += 1;
@@ -578,8 +575,9 @@ int32 ArenaTeam::LostAgainst(uint32 againstRating)
// called when the team has lost
//'chance' calculation - to loose to the opponent
float chance = GetChanceAgainst(m_stats.rating, againstRating);
- // calculate the rating modification (ELO system with k=32)
- int32 mod = (int32)ceil(32.0f * (0.0f - chance));
+ float K = (m_stats.rating < 1000) ? 48.0f : 32.0f;
+ // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000)
+ int32 mod = (int32)ceil(K * (0.0f - chance));
// modify the team stats accordingly
FinishGame(mod);
@@ -596,14 +594,16 @@ void ArenaTeam::MemberLost(Player * plr, uint32 againstRating)
{
// update personal rating
float chance = GetChanceAgainst(itr->personal_rating, againstRating);
- int32 mod = (int32)ceil(32.0f * (0.0f - chance));
+ float K = (itr->personal_rating < 1000) ? 48.0f : 32.0f;
+ // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000)
+ int32 mod = (int32)ceil(K * (0.0f - chance));
itr->ModifyPersonalRating(plr, mod, GetSlot());
// update personal played stats
itr->games_week +=1;
itr->games_season +=1;
// update the unit fields
- plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 2, itr->games_week);
- plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 3, itr->games_season);
+ plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_GAMES_WEEK, itr->games_week);
+ plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_GAMES_SEASON, itr->games_season);
return;
}
}
@@ -618,7 +618,9 @@ void ArenaTeam::OfflineMemberLost(uint64 guid, uint32 againstRating)
{
// update personal rating
float chance = GetChanceAgainst(itr->personal_rating, againstRating);
- int32 mod = (int32)ceil(32.0f * (0.0f - chance));
+ float K = (itr->personal_rating < 1000) ? 48.0f : 32.0f;
+ // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000)
+ int32 mod = (int32)ceil(K * (0.0f - chance));
if (int32(itr->personal_rating) + mod < 0)
itr->personal_rating = 0;
else
@@ -640,7 +642,9 @@ void ArenaTeam::MemberWon(Player * plr, uint32 againstRating)
{
// update personal rating
float chance = GetChanceAgainst(itr->personal_rating, againstRating);
- int32 mod = (int32)floor(32.0f * (1.0f - chance));
+ float K = (itr->personal_rating < 1000) ? 48.0f : 32.0f;
+ // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000)
+ int32 mod = (int32)floor(K* (1.0f - chance));
itr->ModifyPersonalRating(plr, mod, GetSlot());
// update personal stats
itr->games_week +=1;
@@ -648,8 +652,8 @@ void ArenaTeam::MemberWon(Player * plr, uint32 againstRating)
itr->wins_season += 1;
itr->wins_week += 1;
// update unit fields
- plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 2, itr->games_week);
- plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 3, itr->games_season);
+ plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_GAMES_WEEK, itr->games_week);
+ plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_GAMES_SEASON, itr->games_season);
return;
}
}
@@ -720,26 +724,3 @@ bool ArenaTeam::IsFighting() const
}
return false;
}
-
-/*
-arenateam fields (id from 2.3.3 client):
-1414 - arena team id 2v2
-1415 - 0=captain, 1=member
-1416 - played this week
-1417 - played this season
-1418 - unk - rank?
-1419 - personal arena rating
-1420 - arena team id 3v3
-1421 - 0=captain, 1=member
-1422 - played this week
-1423 - played this season
-1424 - unk - rank?
-1425 - personal arena rating
-1426 - arena team id 5v5
-1427 - 0=captain, 1=member
-1428 - played this week
-1429 - played this season
-1430 - unk - rank?
-1431 - personal arena rating
-*/
-