* avoid loot/exp when the mobs are killed by npc. Authore: KAPATEJIb @ getmangos.org
--HG-- branch : trunk
This commit is contained in:
@@ -93,6 +93,7 @@ void AggressorAI::EnterEvadeMode()
|
||||
i_victimGuid = 0;
|
||||
i_creature.CombatStop();
|
||||
i_creature.SetLootRecipient(NULL);
|
||||
i_creature.ResetDamageByPlayers();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -100,6 +100,7 @@ void CreatureAI::EnterEvadeMode()
|
||||
me->CombatStop();
|
||||
me->LoadCreaturesAddon();
|
||||
me->SetLootRecipient(NULL);
|
||||
me->ResetDamageByPlayers();
|
||||
|
||||
if(me->isAlive())
|
||||
me->GetMotionMaster()->MoveTargetedHome();
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -104,6 +104,7 @@ ReactorAI::EnterEvadeMode()
|
||||
i_victimGuid = 0;
|
||||
i_creature.CombatStop();
|
||||
i_creature.SetLootRecipient(NULL);
|
||||
i_creature.ResetDamageByPlayers();
|
||||
|
||||
if(!i_creature.GetCharmerOrOwner())
|
||||
{
|
||||
|
||||
+18
-3
@@ -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())
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user