*Creature::_IsTargetAcceptable rewrite, should hopefully fix the bugs ogeraisi reported.
*Creature health regen patch, written and tested by Gyullo. --HG-- branch : trunk
This commit is contained in:
+49
-31
@@ -533,30 +533,41 @@ void Creature::Update(uint32 diff)
|
|||||||
if(!isAlive())
|
if(!isAlive())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if(m_regenTimer > 0)
|
||||||
|
{
|
||||||
|
if(diff >= m_regenTimer)
|
||||||
|
m_regenTimer = 0;
|
||||||
|
else
|
||||||
|
m_regenTimer -= diff;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_regenTimer != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
bool bIsPolymorphed = IsPolymorphed();
|
bool bIsPolymorphed = IsPolymorphed();
|
||||||
bool bInCombat = isInCombat() && (!getVictim() || // if isInCombat() is true and this has no victim
|
bool bInCombat = isInCombat() && (!getVictim() || // if isInCombat() is true and this has no victim
|
||||||
!getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself() || // or the victim/owner/charmer is not a player
|
!getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself() || // or the victim/owner/charmer is not a player
|
||||||
!getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself()->isGameMaster()); // or the victim/owner/charmer is not a GameMaster
|
!getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself()->isGameMaster()); // or the victim/owner/charmer is not a GameMaster
|
||||||
|
|
||||||
if(m_regenTimer > diff && !bIsPolymorphed) // if polymorphed, skip the timer
|
/*if(m_regenTimer <= diff)
|
||||||
m_regenTimer -= diff;
|
{*/
|
||||||
else
|
if(!bInCombat || bIsPolymorphed) // regenerate health if not in combat or if polymorphed
|
||||||
|
RegenerateHealth();
|
||||||
|
|
||||||
|
if(getPowerType() == POWER_ENERGY)
|
||||||
{
|
{
|
||||||
if(!bInCombat || bIsPolymorphed) // regenerate health if not in combat or if polymorphed
|
if(!IsVehicle() || GetVehicleKit()->GetVehicleInfo()->m_powerType != POWER_PYRITE)
|
||||||
RegenerateHealth();
|
Regenerate(POWER_ENERGY);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
RegenerateMana();
|
||||||
|
|
||||||
if(getPowerType() == POWER_ENERGY)
|
/*if(!bIsPolymorphed) // only increase the timer if not polymorphed
|
||||||
{
|
|
||||||
if(!IsVehicle() || GetVehicleKit()->GetVehicleInfo()->m_powerType != POWER_PYRITE)
|
|
||||||
Regenerate(POWER_ENERGY);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
RegenerateMana();
|
|
||||||
|
|
||||||
if(!bIsPolymorphed) // only increase the timer if not polymorphed
|
|
||||||
m_regenTimer += 2000 - diff;
|
m_regenTimer += 2000 - diff;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
if(!bIsPolymorphed) // if polymorphed, skip the timer
|
||||||
|
m_regenTimer -= diff;*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DEAD_FALLING:
|
case DEAD_FALLING:
|
||||||
@@ -2173,31 +2184,38 @@ bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /
|
|||||||
|
|
||||||
// use this function to avoid having hostile creatures attack
|
// use this function to avoid having hostile creatures attack
|
||||||
// friendlies and other mobs they shouldn't attack
|
// friendlies and other mobs they shouldn't attack
|
||||||
bool Creature::_IsTargetAcceptable(const Unit* target) const
|
bool Creature::_IsTargetAcceptable(const Unit *target) const
|
||||||
{
|
{
|
||||||
if(IsFriendlyTo(target)) // friends shouldn't fight friends
|
const Unit *myVictim = getAttackerForHelper();
|
||||||
return false;
|
|
||||||
|
|
||||||
const Unit* targetVictim = target->getAttackerForHelper();
|
// if I'm already fighting target, the target is acceptable
|
||||||
|
if (myVictim == target)
|
||||||
if(!targetVictim) // if target does not have a victim, the target is acceptable
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const Player* targetVictimPlayer = targetVictim->GetCharmerOrOwnerPlayerOrPlayerItself();
|
// if I'm not aggressive, the target is not acceptable
|
||||||
|
if (GetReactState() != REACT_AGGRESSIVE)
|
||||||
if(!targetVictimPlayer) // if the victim is not a player, the target is acceptable
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// if the victim is a non-friendly player, the target is not acceptable
|
|
||||||
if(!IsFriendlyTo(targetVictim))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// if I'm hostile towards the target, the target is acceptable
|
||||||
|
if (IsHostileTo(target))
|
||||||
|
return true;
|
||||||
|
|
||||||
// if the target is passive, the target is not acceptable
|
// if the target is passive, the target is not acceptable
|
||||||
if(((Creature*)target)->GetReactState() == REACT_PASSIVE)
|
if (((Creature*)target)->GetReactState() == REACT_PASSIVE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// otherwise, the target is acceptable
|
const Unit *targetVictim = target->getAttackerForHelper();
|
||||||
return true;
|
|
||||||
|
// if the target does not have a victim, the target is not acceptable
|
||||||
|
if (!targetVictim)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// if the target's victim is friendly, and the target is neutral, the target is acceptable
|
||||||
|
if (IsFriendlyTo(targetVictim) && !IsFriendlyTo(target))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// if the target's victim is not friendly, or the target is friendly, the target is not acceptable
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::SaveRespawnTime()
|
void Creature::SaveRespawnTime()
|
||||||
|
|||||||
@@ -488,7 +488,7 @@ inline void CreatureAI::SetGazeOn(Unit *target)
|
|||||||
if(me->canAttack(target))
|
if(me->canAttack(target))
|
||||||
{
|
{
|
||||||
AttackStart(target);
|
AttackStart(target);
|
||||||
me->SetReactState(REACT_AGGRESSIVE);
|
me->SetReactState(REACT_PASSIVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -524,7 +524,6 @@ inline bool CreatureAI::UpdateCombatState()
|
|||||||
else if(me->getThreatManager().isThreatListEmpty())
|
else if(me->getThreatManager().isThreatListEmpty())
|
||||||
{
|
{
|
||||||
EnterEvadeMode();
|
EnterEvadeMode();
|
||||||
me->SetReactState(REACT_PASSIVE);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,7 +544,6 @@ inline bool CreatureAI::UpdateVictim()
|
|||||||
else if(me->getThreatManager().isThreatListEmpty())
|
else if(me->getThreatManager().isThreatListEmpty())
|
||||||
{
|
{
|
||||||
EnterEvadeMode();
|
EnterEvadeMode();
|
||||||
me->SetReactState(REACT_PASSIVE);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,18 +567,16 @@ inline bool CreatureAI::_EnterEvadeMode()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// sometimes bosses stuck in combat?
|
// sometimes bosses stuck in combat?
|
||||||
|
me->RemoveAllAuras();
|
||||||
me->DeleteThreatList();
|
me->DeleteThreatList();
|
||||||
me->CombatStop(true);
|
me->CombatStop(true);
|
||||||
|
me->LoadCreaturesAddon();
|
||||||
|
me->SetLootRecipient(NULL);
|
||||||
me->ResetPlayerDamageReq();
|
me->ResetPlayerDamageReq();
|
||||||
|
|
||||||
if(me->IsInEvadeMode())
|
if(me->IsInEvadeMode())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
me->RemoveAllAuras();
|
|
||||||
me->LoadCreaturesAddon();
|
|
||||||
me->SetLootRecipient(NULL);
|
|
||||||
me->SetReactState(REACT_AGGRESSIVE);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user