diff options
author | n0n4m3 <none@none> | 2009-12-17 10:35:35 +0100 |
---|---|---|
committer | n0n4m3 <none@none> | 2009-12-17 10:35:35 +0100 |
commit | 2edfea7bb905413db649d1a75d1495657adc4219 (patch) | |
tree | bac720de3165296f3396bdb796d9ef1ff9ea0add | |
parent | 64e03d6f3f5037f2217194e8d998c6a92ae2ba36 (diff) |
Update Arena and Achievement for 322a
--HG--
branch : trunk
-rw-r--r-- | src/game/AchievementMgr.cpp | 31 | ||||
-rw-r--r-- | src/game/AchievementMgr.h | 4 | ||||
-rw-r--r-- | src/game/ArenaTeam.cpp | 99 | ||||
-rw-r--r-- | src/game/ArenaTeamHandler.cpp | 40 |
4 files changed, 75 insertions, 99 deletions
diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp index d03bb5f4211..8326029703d 100644 --- a/src/game/AchievementMgr.cpp +++ b/src/game/AchievementMgr.cpp @@ -196,10 +196,10 @@ bool AchievementCriteriaData::IsValid(AchievementCriteriaEntry const* criteria) } return true; case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY: - if (difficalty.difficalty >= TOTAL_DIFFICULTIES) + if (difficulty.difficulty >= MAX_DIFFICULTY) { sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY (%u) have wrong difficulty in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,dataType,difficalty.difficalty); + criteria->ID, criteria->requiredType,dataType,difficulty.difficulty); return false; } return true; @@ -294,7 +294,7 @@ bool AchievementCriteriaData::Meets(Player const* source, Unit const* target, ui case ACHIEVEMENT_CRITERIA_DATA_TYPE_DISABLED: return false; // always fail case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY: - return source->GetMap()->GetSpawnMode()==difficalty.difficalty; + return source->GetMap()->GetSpawnMode()==difficulty.difficulty; case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_PLAYER_COUNT: return source->GetMap()->GetPlayersCountExceptGMs() <= map_players.maxcount; case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM: @@ -902,7 +902,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if(!achievIdForDangeon[j][2]) break; // for } - else if(GetPlayer()->GetDifficulty()==DIFFICULTY_NORMAL) + else if(GetPlayer()->GetDungeonDifficulty()==DUNGEON_DIFFICULTY_NORMAL) { // dungeon in normal mode accepted if(!achievIdForDangeon[j][1]) @@ -1708,6 +1708,16 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement) { Item* item = reward->itemId ? Item::CreateItem(reward->itemId,1,GetPlayer ()) : NULL; + MailItemsInfo mi; + if(item) + { + // save new item before send + item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted + + // item + mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item); + } + int loc_idx = GetPlayer()->GetSession()->GetSessionDbLocaleIndex(); // subject and text @@ -1726,18 +1736,7 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement) uint32 itemTextId = objmgr.CreateItemText( text ); - MailDraft draft(subject, itemTextId); - - if(item) - { - // save new item before send - item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted - - // item - draft.AddItem(item); - } - - draft.SendMailTo(GetPlayer(), MailSender(MAIL_CREATURE, reward->sender)); + WorldSession::SendMailTo(GetPlayer(), MAIL_CREATURE, MAIL_STATIONERY_NORMAL, reward->sender, GetPlayer()->GetGUIDLow(), subject, itemTextId , &mi, 0, 0, MAIL_CHECK_MASK_NONE); } } diff --git a/src/game/AchievementMgr.h b/src/game/AchievementMgr.h index d031672f2a5..ceaa4bde65b 100644 --- a/src/game/AchievementMgr.h +++ b/src/game/AchievementMgr.h @@ -125,8 +125,8 @@ struct AchievementCriteriaData // ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY = 12 struct { - uint32 difficalty; - } difficalty; + uint32 difficulty; + } difficulty; // ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_PLAYER_COUNT = 13 struct { 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 -*/ - diff --git a/src/game/ArenaTeamHandler.cpp b/src/game/ArenaTeamHandler.cpp index c7ecf5b1d80..edcfeed0f99 100644 --- a/src/game/ArenaTeamHandler.cpp +++ b/src/game/ArenaTeamHandler.cpp @@ -57,12 +57,11 @@ void WorldSession::HandleArenaTeamQueryOpcode(WorldPacket & recv_data) uint32 ArenaTeamId; recv_data >> ArenaTeamId; - ArenaTeam *arenateam = objmgr.GetArenaTeamById(ArenaTeamId); - if(!arenateam) // arena team not found - return; - - arenateam->Query(this); - arenateam->Stats(this); + if(ArenaTeam *arenateam = objmgr.GetArenaTeamById(ArenaTeamId)) + { + arenateam->Query(this); + arenateam->Stats(this); + } } void WorldSession::HandleArenaTeamRosterOpcode(WorldPacket & recv_data) @@ -72,11 +71,8 @@ void WorldSession::HandleArenaTeamRosterOpcode(WorldPacket & recv_data) uint32 ArenaTeamId; // arena team id recv_data >> ArenaTeamId; - ArenaTeam *arenateam = objmgr.GetArenaTeamById(ArenaTeamId); - if(!arenateam) - return; - - arenateam->Roster(this); + if(ArenaTeam *arenateam = objmgr.GetArenaTeamById(ArenaTeamId)) + arenateam->Roster(this); } void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recv_data) @@ -206,12 +202,14 @@ void WorldSession::HandleArenaTeamLeaveOpcode(WorldPacket & recv_data) ArenaTeam *at = objmgr.GetArenaTeamById(ArenaTeamId); if(!at) return; + if(_player->GetGUID() == at->GetCaptain() && at->GetMembersSize() > 1) { // check for correctness SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, "", "", ERR_ARENA_TEAM_LEADER_LEAVE_S); return; } + // arena team has only one member (=captain) if(_player->GetGUID() == at->GetCaptain()) { @@ -238,18 +236,17 @@ void WorldSession::HandleArenaTeamDisbandOpcode(WorldPacket & recv_data) uint32 ArenaTeamId; // arena team id recv_data >> ArenaTeamId; - ArenaTeam *at = objmgr.GetArenaTeamById(ArenaTeamId); - if(!at) - return; - - if(at->GetCaptain() != _player->GetGUID()) - return; + if(ArenaTeam *at = objmgr.GetArenaTeamById(ArenaTeamId)) + { + if(at->GetCaptain() != _player->GetGUID()) + return; - if (at->IsFighting()) - return; + if(at->IsFighting()) + return; - at->Disband(this); - delete at; + at->Disband(this); + delete at; + } } void WorldSession::HandleArenaTeamRemoveOpcode(WorldPacket & recv_data) @@ -422,4 +419,3 @@ ERR_ARENA_TEAM_TOO_MANY_MEMBERS_S "%s is full" ERR_ARENA_TEAM_LEVEL_TOO_LOW_I "You must be level %d to form an arena team" */ - |