diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/BattleGround.cpp | 75 | ||||
-rw-r--r-- | src/game/BattleGround.h | 4 |
2 files changed, 50 insertions, 29 deletions
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index d179ec33691..7a6b96070a1 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -726,12 +726,10 @@ void BattleGround::EndBattleGround(uint32 winner) if (team == winner) { RewardMark(plr,ITEM_WINNER_COUNT); - RewardQuest(plr); + RewardQuestComplete(plr); } - else if(winner !=0) - { + else if(winner) RewardMark(plr,ITEM_LOSER_COUNT); - } plr->CombatStopWithPets(true); @@ -785,13 +783,6 @@ uint32 BattleGround::GetBattlemasterEntry() const 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; - - if(!plr || !count) - return; - BattleGroundMarks mark; switch(GetTypeID()) { @@ -811,21 +802,53 @@ void BattleGround::RewardMark(Player *plr,uint32 count) return; } - if ( objmgr.GetItemPrototype( mark ) ) + //if (IsSpell) + // RewardSpellCast(plr,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) { - ItemPosCountVec dest; - uint32 no_space_count = 0; - uint8 msg = plr->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, mark, count, &no_space_count ); - if( msg != EQUIP_ERR_OK ) // convert to possible store amount - count -= no_space_count; + sLog.outError("Battleground reward casting spell %u not exist.",spell_id); + return; + } - if(!dest.empty()) // can add some - if(Item* item = plr->StoreNewItem( dest, mark, true, 0)) - plr->SendNewItem(item,count,false,true); + 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; - if (no_space_count > 0) - SendRewardMarkByMail(plr,mark,no_space_count); + ItemPosCountVec dest; + uint32 no_space_count = 0; + 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 + count -= no_space_count; + + if( count != 0 && !dest.empty()) // can add some + if (Item* item = plr->StoreNewItem( dest, item_id, true, 0)) + plr->SendNewItem(item,count,false,true); + + if (no_space_count > 0) + SendRewardMarkByMail(plr,item_id,no_space_count); } void BattleGround::SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count) @@ -865,12 +888,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; switch(GetTypeID()) { @@ -890,7 +909,7 @@ void BattleGround::RewardQuest(Player *plr) return; } - plr->CastSpell(plr, quest, true); + RewardSpellCast(plr, quest); } void BattleGround::BlockMovement(Player *plr) diff --git a/src/game/BattleGround.h b/src/game/BattleGround.h index 9788f264502..509ba6eb972 100644 --- a/src/game/BattleGround.h +++ b/src/game/BattleGround.h @@ -421,7 +421,9 @@ class BattleGround void RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID); void RewardMark(Player *plr,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 UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player *Source); void EndBattleGround(uint32 winner); |