[7668] Cleanup In CreatureAI function descriptions and AttackStart/AttackedBy use.

* Use AI::AttackStart calls only in case explicit request creature attack from core or AI code "attack it if can".
  Like taunt, pet handler attack command.
* Use AI::AttackedBy for reaction at hostile action "do something at hostile action"
  Like non-dot damage, swing, negative spell landing, or fade fear/etc.
  And provided by default call AttackStart if no current target.

This fix some problems, like:
* Civilian will react propertly at attack by another creature (not pet or player).
* Will not cases (at least triggred by core) when attack target start run to attacker before any real hostile action apply.
This commit is contained in:
VladimirMangos 2009-04-14 07:21:04 +04:00
parent 69fb9736cc
commit d85e95295d
11 changed files with 72 additions and 82 deletions

View file

@ -78,29 +78,15 @@ struct Script
#define VISIBLE_RANGE (50.0f)
// Read function descriptions in CreatureAI
struct MANGOS_DLL_DECL ScriptedAI : public CreatureAI
{
explicit ScriptedAI(Creature* creature) : CreatureAI(creature) {}
~ScriptedAI() {}
// Called if IsVisible(Unit *who) is true at each *who move
void MoveInLineOfSight(Unit *) {}
// Called at each attack of m_creature by any victim
void AttackStart(Unit *) {}
// Called at stopping attack by any attacker
void EnterEvadeMode();
// Called at any heal cast/item used (call non implemented)
void HealBy(Unit* /*healer*/, uint32 /*amount_healed*/) {}
// Called at any Damage to any victim (before damage apply)
void DamageDeal(Unit* /*done_to*/, uint32& /*damage*/) {}
// Called at any Damage from any attacker (before damage apply)
void DamageTaken(Unit* /*done_by*/, uint32& /*damage*/) {}
// Is unit visible for MoveInLineOfSight
bool IsVisible(Unit* who) const
{
@ -110,18 +96,6 @@ struct MANGOS_DLL_DECL ScriptedAI : public CreatureAI
// Called at World update tick
void UpdateAI(const uint32);
// Called when the creature is killed
void JustDied(Unit *){}
// Called when the creature kills a unit
void KilledUnit(Unit *){}
// Called when hit by a spell
void SpellHit(Unit *, const SpellEntry*){}
// Called when spell hits creature's target
void SpellHitTarget(Unit*, const SpellEntry*) {}
//= Some useful helpers =========================
// Start attack of victim and go to him