本文整理汇总了C++中Player::AddArenaPoints方法的典型用法代码示例。如果您正苦于以下问题:C++ Player::AddArenaPoints方法的具体用法?C++ Player::AddArenaPoints怎么用?C++ Player::AddArenaPoints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player::AddArenaPoints方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EventUpdateResources
void ArathiBasin::EventUpdateResources(uint32 Team)
{
static uint32 resource_fields[2] = { WORLDSTATE_AB_ALLIANCE_RESOURCES, WORLDSTATE_AB_HORDE_RESOURCES };
uint32 current_resources = m_resources[Team];
uint32 current_bases = m_capturedBases[Team];
if(current_bases>5)
current_bases=5;
// figure out how much resources we have to add to that team based on the number of captured bases.
current_resources += (PointBonusPerUpdate[current_bases]);
// did it change?
if(current_resources == m_resources[Team])
return;
m_mainLock.Acquire();
// check for overflow
if(current_resources > RESOURCES_WINVAL)
current_resources = RESOURCES_WINVAL;
m_resources[Team] = current_resources;
if((current_resources - m_lastHonorGainResources[Team]) >= m_resToGainBH)
{
m_lastHonorGainResources[Team] += m_resToGainBH;
for(set< Player* >::iterator itr = m_players[Team].begin(); itr != m_players[Team].end(); itr++)
{
(*itr)->m_bgScore.BonusHonor += m_bonusHonor;
HonorHandler::AddHonorPointsToPlayer((*itr), m_bonusHonor);
}
}
// update the world states
m_mapMgr->GetStateManager().UpdateWorldState(resource_fields[Team], current_resources);
if(current_resources >= RESOURCES_WARNING_THRESHOLD && !m_nearingVictory[Team])
{
m_nearingVictory[Team] = true;
SendChatMessage(Team ? CHAT_MSG_BG_SYSTEM_HORDE : CHAT_MSG_BG_SYSTEM_ALLIANCE, (uint64)0, "The %s has gathered %u resources and is nearing victory!", Team ? "Horde" : "Alliance", current_resources);
uint32 sound = SOUND_ALLIANCE_BGALMOSTEND - Team;
PlaySoundToAll(sound);
}
// check for winning condition
if(current_resources == RESOURCES_WINVAL)
{
m_ended = true;
m_losingteam = (Team) ? 0 : 1;
m_nextPvPUpdateTime = 0;
sEventMgr.RemoveEvents(this);
sEventMgr.AddEvent(TO_CBATTLEGROUND(this), &CBattleground::Close, EVENT_BATTLEGROUND_CLOSE, 120000, 1,0);
SendChatMessage( CHAT_MSG_BG_SYSTEM_NEUTRAL, 0, "|cffffff00This battleground will close in 2 minutes.");
for(uint32 i = 0; i < 2; i++)
{
for(set<Player* >::iterator itr = m_players[i].begin(); itr != m_players[i].end(); itr++)
{
(*itr)->Root();
if( (*itr)->HasFlag(PLAYER_FLAGS, PLAYER_FLAG_AFK) )
continue;
if(i == m_losingteam)
{
(*itr)->m_bgScore.BonusHonor += m_bonusHonor;
HonorHandler::AddHonorPointsToPlayer((*itr), m_bonusHonor);
if((*itr)->fromrandombg)
{
(*itr)->m_honorToday += (*itr)->GenerateRBGReward((*itr)->getLevel(),5);
HonorHandler::RecalculateHonorFields((*itr));
(*itr)->fromrandombg = false;
}
}
else
{
(*itr)->m_bgScore.BonusHonor += 2*m_bonusHonor;
HonorHandler::AddHonorPointsToPlayer((*itr), 2*m_bonusHonor);
uint32 diff = abs((int32)(m_resources[i] - m_resources[i ? 0 : 1]));
(*itr)->GetAchievementInterface()->HandleAchievementCriteriaWinBattleground( m_mapMgr->GetMapId(), diff, ((uint32)UNIXTIME - m_startTime) / 1000, TO_CBATTLEGROUND(this));
if((*itr)->fromrandombg)
{
Player * p = (*itr);
p->AddArenaPoints(p->randombgwinner == false ? p->GenerateRBGReward(p->getLevel(),25) : p->GenerateRBGReward(p->getLevel(),0));
p->m_honorToday += p->randombgwinner == false ? p->GenerateRBGReward(p->getLevel(),30) : p->GenerateRBGReward(p->getLevel(),15);
HonorHandler::RecalculateHonorFields(p);
p->randombgwinner = true;
p->fromrandombg = false;
}
}
}
}
}
UpdatePvPData();
m_mainLock.Release();
}
示例2: GivePoints
bool EyeOfTheStorm::GivePoints(uint32 team, uint32 points)
{
if(m_ended || !m_started)
return false;
//printf("EOTS: Give team %u %u points.\n", team, points);
m_points[team] += points;
if( m_points[team] >= m_resourceRewards[team] )
{
m_resourceRewards[team] += m_resToGainBH;
for(set<Player* >::iterator itx = m_players[team].begin(); itx != m_players[team].end(); itx++)
{
Player* plr = (*itx);
if(!plr) continue;
(*itx)->m_bgScore.BonusHonor += m_bonusHonor;
HonorHandler::AddHonorPointsToPlayer( plr, m_bonusHonor );
}
}
if( m_points[team] >= 1600 )
{
m_points[team] = 1600;
m_mapMgr->GetStateManager().UpdateWorldState( WORLDSTATE_EOTS_ALLIANCE_VICTORYPOINTS + team, m_points[team] );
m_ended = true;
m_losingteam = (team) ? 0 : 1;
m_nextPvPUpdateTime = 0;
sEventMgr.RemoveEvents(this);
sEventMgr.AddEvent(TO_CBATTLEGROUND(this), &CBattleground::Close, EVENT_BATTLEGROUND_CLOSE, 120000, 1,0);
SendChatMessage( CHAT_MSG_BG_SYSTEM_NEUTRAL, 0, "|cffffff00This battleground will close in 2 minutes.");
/* add the marks of honor to all players */
m_mainLock.Acquire();
for(uint32 i = 0; i < 2; i++)
{
for(set<Player* >::iterator itr = m_players[i].begin(); itr != m_players[i].end(); itr++)
{
(*itr)->Root();
if( (*itr)->HasFlag(PLAYER_FLAGS, PLAYER_FLAG_AFK) )
continue;
// create eye of the storm mark of honor
uint32 item_count = (i == m_losingteam) ? 1 : 3;
if( i != m_losingteam )
{
(*itr)->m_bgScore.BonusHonor += 2*m_bonusHonor;
HonorHandler::AddHonorPointsToPlayer( (*itr), 2*m_bonusHonor );
if((*itr)->fromrandombg)
{
(*itr)->m_honorToday += (*itr)->GenerateRBGReward((*itr)->getLevel(),5);
HonorHandler::RecalculateHonorFields((*itr));
(*itr)->fromrandombg = false;
}
}
else
{
(*itr)->m_bgScore.BonusHonor += m_bonusHonor;
HonorHandler::AddHonorPointsToPlayer( (*itr), m_bonusHonor );
uint32 diff = abs((int32)(m_points[i] - m_points[i ? 0 : 1]));
(*itr)->GetAchievementInterface()->HandleAchievementCriteriaWinBattleground( m_mapMgr->GetMapId(), diff, ((uint32)UNIXTIME - m_startTime) / 1000, TO_CBATTLEGROUND(this));
if((*itr)->fromrandombg)
{
Player * p = (*itr);
p->AddArenaPoints(p->randombgwinner == false ? p->GenerateRBGReward(p->getLevel(),25) : p->GenerateRBGReward(p->getLevel(),0));
p->m_honorToday += p->randombgwinner == false ? p->GenerateRBGReward(p->getLevel(),30) : p->GenerateRBGReward(p->getLevel(),15);
HonorHandler::RecalculateHonorFields(p);
p->randombgwinner = true;
p->fromrandombg = false;
}
}
Item* pReward;
SlotResult res;
if( ( pReward = (*itr)->GetItemInterface()->FindItemLessMax(EOTS_MARK_ID, item_count, false) ) == NULL )
{
res = (*itr)->GetItemInterface()->FindFreeInventorySlot( ItemPrototypeStorage.LookupEntry(EOTS_MARK_ID) );
if( !res.Result )
{
(*itr)->BroadcastMessage("Could not add EOTS mark. Make sure you have room in your inventory.");
continue;
}
pReward = objmgr.CreateItem(EOTS_MARK_ID, (*itr));
pReward->SetUInt32Value(ITEM_FIELD_STACK_COUNT, item_count);
pReward->m_isDirty = true;
if( !(*itr)->GetItemInterface()->SafeAddItem(pReward, res.ContainerSlot, res.Slot) )
{
if( !(*itr)->GetItemInterface()->AddItemToFreeSlot(pReward) )
{
pReward->DeleteMe();
pReward = NULLGOB;
}
}
//.........这里部分代码省略.........
示例3: update_arena
void DayWatcherThread::update_arena()
{
LogNotice("DayWatcherThread : Running Weekly Arena Point Maintenance...");
QueryResult* result = CharacterDatabase.Query("SELECT guid, arenaPoints FROM characters"); // this one is a little more intensive
Player* plr;
uint32 guid, arenapoints, orig_arenapoints;
ArenaTeam* team;
uint32 arenapointsPerTeam[3] = { 0 };
double X, Y;
if (result)
{
do
{
Field* f = result->Fetch();
guid = f[0].GetUInt32();
arenapoints = f[1].GetUInt32();
orig_arenapoints = arenapoints;
for (uint8 i = 0; i < 3; ++i)
arenapointsPerTeam[i] = 0;
// are we in any arena teams?
for (uint8 i = 0; i < 3; ++i) // 3 arena team types
{
team = objmgr.GetArenaTeamByGuid(guid, i);
if (team)
{
ArenaTeamMember* member = team->GetMemberByGuid(guid);
if (member == NULL || team->m_stat_gamesplayedweek < 10 || ((member->Played_ThisWeek * 100) / team->m_stat_gamesplayedweek < 30))
continue;
// we're in an arena team of this type!
// Source: http://www.wowwiki.com/Arena_point
X = (double)team->m_stat_rating;
if (X <= 510.0) // "if X<=510"
continue; // no change
else if (X > 510.0 && X <= 1500.0) // "if 510 < X <= 1500"
{
Y = (0.22 * X) + 14.0;
}
else // "if X > 1500"
{
// http://eu.wowarmory.com/arena-calculator.xml
// 1511.26
// ---------------------------
// -0.00412*X
// 1+1639.28*2.71828
double power = ((-0.00412) * X);
//if (power < 1.0)
// power = 1.0;
double divisor = pow(((double)(2.71828)), power);
divisor *= 1639.28;
divisor += 1.0;
//if (divisor < 1.0)
// divisor = 1.0;
Y = 1511.26 / divisor;
}
// 2v2 teams only earn 70% (Was 60% until 13th March 07) of the arena points, 3v3 teams get 80%, while 5v5 teams get 100% of the arena points.
// 2v2 - 76%, 3v3 - 88% as of patch 2.2
if (team->m_type == ARENA_TEAM_TYPE_2V2)
{
Y *= 0.76;
Y *= worldConfig.getFloatRate(RATE_ARENAPOINTMULTIPLIER2X);
}
else if (team->m_type == ARENA_TEAM_TYPE_3V3)
{
Y *= 0.88;
Y *= worldConfig.getFloatRate(RATE_ARENAPOINTMULTIPLIER3X);
}
else
{
Y *= worldConfig.getFloatRate(RATE_ARENAPOINTMULTIPLIER5X);
}
if (Y > 1.0)
arenapointsPerTeam[i] += long2int32(double(ceil(Y)));
}
}
arenapointsPerTeam[0] = (uint32)std::max(arenapointsPerTeam[0], arenapointsPerTeam[1]);
arenapoints += (uint32)std::max(arenapointsPerTeam[0], arenapointsPerTeam[2]);
if (arenapoints > 5000) arenapoints = 5000;
if (orig_arenapoints != arenapoints)
{
plr = objmgr.GetPlayer(guid);
if (plr)
{
plr->AddArenaPoints(arenapoints, false);
// update visible fields (must be done through an event because of no uint lock
sEventMgr.AddEvent(plr, &Player::UpdateArenaPoints, EVENT_PLAYER_UPDATE, 100, 1, 0);
sChatHandler.SystemMessage(plr->GetSession(), "Your arena points have been updated! Check your PvP tab!");
}
//.........这里部分代码省略.........