aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/AggressorAI.cpp1
-rw-r--r--src/game/Creature.cpp2
-rw-r--r--src/game/Creature.h5
-rw-r--r--src/game/CreatureAI.cpp1
-rw-r--r--src/game/Player.cpp3
-rw-r--r--src/game/ReactorAI.cpp1
-rw-r--r--src/game/Unit.cpp23
7 files changed, 32 insertions, 4 deletions
diff --git a/src/game/AggressorAI.cpp b/src/game/AggressorAI.cpp
index a001ea5af22..d44cab9fd22 100644
--- a/src/game/AggressorAI.cpp
+++ b/src/game/AggressorAI.cpp
@@ -93,6 +93,7 @@ void AggressorAI::EnterEvadeMode()
i_victimGuid = 0;
i_creature.CombatStop();
i_creature.SetLootRecipient(NULL);
+ i_creature.ResetDamageByPlayers();
}
void
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 5d18140f200..fc79caf7260 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -159,6 +159,7 @@ m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),m_creatureInfo(NULL), m_DBTabl
m_GlobalCooldown = 0;
m_unit_movement_flags = MOVEMENTFLAG_WALK_MODE;
DisableReputationGain = false;
+ ResetDamageByPlayers();
}
Creature::~Creature()
@@ -1653,6 +1654,7 @@ void Creature::setDeathState(DeathState s)
// setActive(true);
SetHealth(GetMaxHealth());
SetLootRecipient(NULL);
+ ResetDamageByPlayers();
Unit::setDeathState(ALIVE);
CreatureInfo const *cinfo = GetCreatureInfo();
RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
diff --git a/src/game/Creature.h b/src/game/Creature.h
index 5a8fd48f97d..b25893b5ba9 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -637,6 +637,10 @@ class TRINITY_DLL_SPEC Creature : public Unit
void SetDisableReputationGain(bool disable) { DisableReputationGain = disable; }
bool IsReputationGainDisabled() { return DisableReputationGain; }
+ bool IsDamageEnoughForLootingAndReward() { return m_unDamageByPlayers >= (uint32)(GetMaxHealth() / 2); }
+ void AddDamageByPlayers(uint32 unDamage) { m_unDamageByPlayers += unDamage; }
+ void ResetDamageByPlayers() { m_unDamageByPlayers = 0; }
+
protected:
bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL);
bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL);
@@ -651,6 +655,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
uint32 m_lootMoney;
uint64 m_lootRecipient;
+ uint32 m_unDamageByPlayers;
/// Timers
uint32 m_deathTimer; // (msecs)timer for death or corpse disappearance
diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp
index d21fe43fcaa..3a7cb896e88 100644
--- a/src/game/CreatureAI.cpp
+++ b/src/game/CreatureAI.cpp
@@ -100,6 +100,7 @@ void CreatureAI::EnterEvadeMode()
me->CombatStop();
me->LoadCreaturesAddon();
me->SetLootRecipient(NULL);
+ me->ResetDamageByPlayers();
if(me->isAlive())
me->GetMotionMaster()->MoveTargetedHome();
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index fcdeb30a42d..e91728ab9be 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -14379,6 +14379,9 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
bool Player::isAllowedToLoot(Creature* creature)
{
+ if(creature->isDead() && !creature->IsDamageEnoughForLootingAndReward())
+ return false;
+
if(Player* recipient = creature->GetLootRecipient())
{
if (recipient == this)
diff --git a/src/game/ReactorAI.cpp b/src/game/ReactorAI.cpp
index d15c71b28ef..f9fe0abfdc2 100644
--- a/src/game/ReactorAI.cpp
+++ b/src/game/ReactorAI.cpp
@@ -104,6 +104,7 @@ ReactorAI::EnterEvadeMode()
i_victimGuid = 0;
i_creature.CombatStop();
i_creature.SetLootRecipient(NULL);
+ i_creature.ResetDamageByPlayers();
if(!i_creature.GetCharmerOrOwner())
{
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);