mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[7723] New AI call EnterCombat called at enter creature to combat (and re-enter if leave by some reason).
This commit is contained in:
parent
f2f817883a
commit
73db1cbe01
10 changed files with 30 additions and 25 deletions
|
|
@ -8678,7 +8678,7 @@ void Unit::SetInCombatWith(Unit* enemy)
|
|||
Unit* eOwner = enemy->GetCharmerOrOwnerOrSelf();
|
||||
if(eOwner->IsPvP())
|
||||
{
|
||||
SetInCombatState(true);
|
||||
SetInCombatState(true,enemy);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -8688,14 +8688,14 @@ void Unit::SetInCombatWith(Unit* enemy)
|
|||
Unit const* myOwner = GetCharmerOrOwnerOrSelf();
|
||||
if(((Player const*)eOwner)->duel->opponent == myOwner)
|
||||
{
|
||||
SetInCombatState(true);
|
||||
SetInCombatState(true,enemy);
|
||||
return;
|
||||
}
|
||||
}
|
||||
SetInCombatState(false);
|
||||
SetInCombatState(false,enemy);
|
||||
}
|
||||
|
||||
void Unit::SetInCombatState(bool PvP)
|
||||
void Unit::SetInCombatState(bool PvP, Unit* enemy)
|
||||
{
|
||||
// only alive units can be in combat
|
||||
if(!isAlive())
|
||||
|
|
@ -8703,10 +8703,16 @@ void Unit::SetInCombatState(bool PvP)
|
|||
|
||||
if(PvP)
|
||||
m_CombatTimer = 5000;
|
||||
|
||||
bool creatureNotInCombat = GetTypeId()==TYPEID_UNIT && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
|
||||
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
|
||||
|
||||
if(isCharmed() || (GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->isPet()))
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
|
||||
|
||||
if(creatureNotInCombat && ((Creature*)this)->AI())
|
||||
((Creature*)this)->AI()->EnterCombat(enemy);
|
||||
}
|
||||
|
||||
void Unit::ClearInCombat()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue