From 62c5720227f2863270ab7c3f8d72c90a802e7084 Mon Sep 17 00:00:00 2001 From: Muhaha Date: Wed, 13 May 2009 10:34:55 +0200 Subject: * avoid loot/exp when the mobs are killed by npc. Authore: KAPATEJIb @ getmangos.org --HG-- branch : trunk --- src/game/Unit.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/game/Unit.cpp') diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index d0b71d0f3a3..0890bcce364 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -788,8 +788,15 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa } } - if (pVictim->GetTypeId() == TYPEID_UNIT && !((Creature*)pVictim)->isPet() && !((Creature*)pVictim)->hasLootRecipient()) - ((Creature*)pVictim)->SetLootRecipient(this); + if (pVictim->GetTypeId() == TYPEID_UNIT && !((Creature*)pVictim)->isPet()) + { + if(!((Creature*)pVictim)->hasLootRecipient()) + ((Creature*)pVictim)->SetLootRecipient(this); + + if(GetCharmerOrOwnerPlayerOrPlayerItself()) + ((Creature*)pVictim)->AddDamageByPlayers(health < damage ? health : damage); + } + if (health <= damage) { DEBUG_LOG("DealDamage: victim just died"); @@ -12471,11 +12478,19 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss) // find player: owner of controlled `this` or `this` itself maybe Player *player = GetCharmerOrOwnerPlayerOrPlayerItself(); - if(pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->GetLootRecipient()) + bool bRewardIsAllowed = true; + if(pVictim->GetTypeId() == TYPEID_UNIT) + { + bRewardIsAllowed = ((Creature*)pVictim)->IsDamageEnoughForLootingAndReward(); + if(!bRewardIsAllowed) + ((Creature*)pVictim)->SetLootRecipient(NULL); + } + + if(bRewardIsAllowed && pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->GetLootRecipient()) player = ((Creature*)pVictim)->GetLootRecipient(); // Reward player, his pets, and group/raid members // call kill spell proc event (before real die and combat stop to triggering auras removed at death/combat stop) - if(player && player!=pVictim) + if(bRewardIsAllowed && player && player!=pVictim) { if(player->RewardPlayerAndGroupAtKill(pVictim)) player->ProcDamageAndSpell(pVictim, PROC_FLAG_KILL_AND_GET_XP, PROC_FLAG_KILLED, PROC_EX_NONE, 0); -- cgit v1.2.3