mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[7805] Refactoring batleground rewards code for cleanup and useful state for custom reward reuse.
Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
7204f83a55
commit
00820846e9
3 changed files with 51 additions and 29 deletions
|
|
@ -705,12 +705,10 @@ void BattleGround::EndBattleGround(uint32 winner)
|
||||||
if (team == winner)
|
if (team == winner)
|
||||||
{
|
{
|
||||||
RewardMark(plr,ITEM_WINNER_COUNT);
|
RewardMark(plr,ITEM_WINNER_COUNT);
|
||||||
RewardQuest(plr);
|
RewardQuestComplete(plr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
RewardMark(plr,ITEM_LOSER_COUNT);
|
RewardMark(plr,ITEM_LOSER_COUNT);
|
||||||
}
|
|
||||||
|
|
||||||
plr->CombatStopWithPets(true);
|
plr->CombatStopWithPets(true);
|
||||||
|
|
||||||
|
|
@ -764,10 +762,6 @@ uint32 BattleGround::GetBattlemasterEntry() const
|
||||||
|
|
||||||
void BattleGround::RewardMark(Player *plr,uint32 count)
|
void BattleGround::RewardMark(Player *plr,uint32 count)
|
||||||
{
|
{
|
||||||
// 'Inactive' this aura prevents the player from gaining honor points and battleground tokens
|
|
||||||
if (plr->GetDummyAura(SPELL_AURA_PLAYER_INACTIVE))
|
|
||||||
return;
|
|
||||||
|
|
||||||
BattleGroundMarks mark;
|
BattleGroundMarks mark;
|
||||||
bool IsSpell;
|
bool IsSpell;
|
||||||
switch(GetTypeID())
|
switch(GetTypeID())
|
||||||
|
|
@ -802,22 +796,52 @@ void BattleGround::RewardMark(Player *plr,uint32 count)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsSpell)
|
if (IsSpell)
|
||||||
plr->CastSpell(plr, mark, true);
|
RewardSpellCast(plr,mark);
|
||||||
else if (objmgr.GetItemPrototype( mark ) )
|
else
|
||||||
|
RewardItem(plr,mark,count);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BattleGround::RewardSpellCast(Player *plr, uint32 spell_id)
|
||||||
{
|
{
|
||||||
|
// 'Inactive' this aura prevents the player from gaining honor points and battleground tokens
|
||||||
|
if (plr->GetDummyAura(SPELL_AURA_PLAYER_INACTIVE))
|
||||||
|
return;
|
||||||
|
|
||||||
|
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id);
|
||||||
|
if(!spellInfo)
|
||||||
|
{
|
||||||
|
sLog.outError("Battleground reward casting spell %u not exist.",spell_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
plr->CastSpell(plr, spellInfo, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BattleGround::RewardItem(Player *plr, uint32 item_id, uint32 count)
|
||||||
|
{
|
||||||
|
// 'Inactive' this aura prevents the player from gaining honor points and battleground tokens
|
||||||
|
if (plr->GetDummyAura(SPELL_AURA_PLAYER_INACTIVE))
|
||||||
|
return;
|
||||||
|
|
||||||
ItemPosCountVec dest;
|
ItemPosCountVec dest;
|
||||||
uint32 no_space_count = 0;
|
uint32 no_space_count = 0;
|
||||||
uint8 msg = plr->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, mark, count, &no_space_count );
|
uint8 msg = plr->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, item_id, count, &no_space_count );
|
||||||
|
|
||||||
|
if( msg == EQUIP_ERR_ITEM_NOT_FOUND)
|
||||||
|
{
|
||||||
|
sLog.outErrorDb("Battleground reward item (Entry %u) not exist in `item_template`.",item_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if( msg != EQUIP_ERR_OK ) // convert to possible store amount
|
if( msg != EQUIP_ERR_OK ) // convert to possible store amount
|
||||||
count -= no_space_count;
|
count -= no_space_count;
|
||||||
|
|
||||||
if( count != 0 && !dest.empty()) // can add some
|
if( count != 0 && !dest.empty()) // can add some
|
||||||
if (Item* item = plr->StoreNewItem( dest, mark, true, 0))
|
if (Item* item = plr->StoreNewItem( dest, item_id, true, 0))
|
||||||
plr->SendNewItem(item,count,false,true);
|
plr->SendNewItem(item,count,false,true);
|
||||||
|
|
||||||
if (no_space_count > 0)
|
if (no_space_count > 0)
|
||||||
SendRewardMarkByMail(plr,mark,no_space_count);
|
SendRewardMarkByMail(plr,item_id,no_space_count);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleGround::SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count)
|
void BattleGround::SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count)
|
||||||
|
|
@ -857,12 +881,8 @@ void BattleGround::SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleGround::RewardQuest(Player *plr)
|
void BattleGround::RewardQuestComplete(Player *plr)
|
||||||
{
|
{
|
||||||
// 'Inactive' this aura prevents the player from gaining honor points and battleground tokens
|
|
||||||
if (plr->GetDummyAura(SPELL_AURA_PLAYER_INACTIVE))
|
|
||||||
return;
|
|
||||||
|
|
||||||
uint32 quest;
|
uint32 quest;
|
||||||
switch(GetTypeID())
|
switch(GetTypeID())
|
||||||
{
|
{
|
||||||
|
|
@ -882,7 +902,7 @@ void BattleGround::RewardQuest(Player *plr)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plr->CastSpell(plr, quest, true);
|
RewardSpellCast(plr, quest);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleGround::BlockMovement(Player *plr)
|
void BattleGround::BlockMovement(Player *plr)
|
||||||
|
|
|
||||||
|
|
@ -411,7 +411,9 @@ class BattleGround
|
||||||
void RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID);
|
void RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID);
|
||||||
void RewardMark(Player *plr,uint32 count);
|
void RewardMark(Player *plr,uint32 count);
|
||||||
void SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count);
|
void SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count);
|
||||||
void RewardQuest(Player *plr);
|
void RewardItem(Player *plr, uint32 item_id, uint32 count);
|
||||||
|
void RewardQuestComplete(Player *plr);
|
||||||
|
void RewardSpellCast(Player *plr, uint32 spell_id);
|
||||||
void UpdateWorldState(uint32 Field, uint32 Value);
|
void UpdateWorldState(uint32 Field, uint32 Value);
|
||||||
void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player *Source);
|
void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player *Source);
|
||||||
void EndBattleGround(uint32 winner);
|
void EndBattleGround(uint32 winner);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "7804"
|
#define REVISION_NR "7805"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue