converted all tabs to 4 spaces

This commit is contained in:
Yehonal
2016-06-26 19:23:57 +02:00
parent 52f305111c
commit f6eefedcd5
717 changed files with 132388 additions and 132388 deletions

View File

@@ -274,8 +274,8 @@ void VehicleAI::UpdateAI(uint32 diff)
m_DoDismiss = false;
me->DespawnOrUnsummon();
}
else
m_DismissTimer -= diff;
else
m_DismissTimer -= diff;
}
}

View File

@@ -61,7 +61,7 @@ class GameObjectAI
virtual void OnGameEvent(bool /*start*/, uint16 /*eventId*/) {}
virtual void OnStateChanged(uint32 /*state*/, Unit* /*unit*/) {}
virtual void EventInform(uint32 /*eventId*/) {}
virtual void SpellHit(Unit* unit, const SpellInfo* spellInfo) {}
virtual void SpellHit(Unit* unit, const SpellInfo* spellInfo) {}
};
class NullGameObjectAI : public GameObjectAI

View File

@@ -37,8 +37,8 @@ GuardAI::GuardAI(Creature* creature) : ScriptedAI(creature)
void GuardAI::Reset()
{
ScriptedAI::Reset();
me->CastSpell(me, 18950 /*SPELL_INVISIBILITY_AND_STEALTH_DETECTION*/, true);
ScriptedAI::Reset();
me->CastSpell(me, 18950 /*SPELL_INVISIBILITY_AND_STEALTH_DETECTION*/, true);
}
void GuardAI::EnterEvadeMode()

View File

@@ -30,7 +30,7 @@ class GuardAI : public ScriptedAI
static int Permissible(Creature const* creature);
void Reset();
void Reset();
void EnterEvadeMode();
void JustDied(Unit* killer);
};

View File

@@ -64,7 +64,7 @@ void CritterAI::DamageTaken(Unit*, uint32&, DamageEffectType, SpellSchoolMask)
if (!me->HasUnitState(UNIT_STATE_FLEEING))
me->SetControlled(true, UNIT_STATE_FLEEING);
_combatTimer = 1;
_combatTimer = 1;
}
void CritterAI::EnterEvadeMode()
@@ -72,21 +72,21 @@ void CritterAI::EnterEvadeMode()
if (me->HasUnitState(UNIT_STATE_FLEEING))
me->SetControlled(false, UNIT_STATE_FLEEING);
CreatureAI::EnterEvadeMode();
_combatTimer = 0;
_combatTimer = 0;
}
void CritterAI::UpdateAI(uint32 diff)
{
if (me->IsInCombat())
{
_combatTimer += diff;
if (_combatTimer >= 5000)
EnterEvadeMode();
}
if (me->IsInCombat())
{
_combatTimer += diff;
if (_combatTimer >= 5000)
EnterEvadeMode();
}
}
void TriggerAI::IsSummonedBy(Unit* summoner)
{
if (me->m_spells[0])
me->CastSpell(me, me->m_spells[0], false, 0, 0, summoner ? summoner->GetGUID() : 0);
me->CastSpell(me, me->m_spells[0], false, 0, 0, summoner ? summoner->GetGUID() : 0);
}

View File

@@ -71,11 +71,11 @@ class CritterAI : public PassiveAI
void DamageTaken(Unit* /*done_by*/, uint32& /*damage*/, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask);
void EnterEvadeMode();
void UpdateAI(uint32);
void UpdateAI(uint32);
// Xinef: Added
private:
uint32 _combatTimer;
// Xinef: Added
private:
uint32 _combatTimer;
};
class TriggerAI : public NullCreatureAI

View File

@@ -51,22 +51,22 @@ bool PetAI::_needToStop()
if (me->IsCharmed() && me->GetVictim() == me->GetCharmer())
return true;
// xinef: dont allow to follow targets out of visibility range
if (me->GetExactDist(me->GetVictim()) > me->GetVisibilityRange()-5.0f)
return true;
// xinef: dont allow to follow targets out of visibility range
if (me->GetExactDist(me->GetVictim()) > me->GetVisibilityRange()-5.0f)
return true;
// dont allow pets to follow targets far away from owner
if (Unit* owner = me->GetCharmerOrOwner())
if (owner->GetExactDist(me) >= (owner->GetVisibilityRange()-10.0f))
return true;
// dont allow pets to follow targets far away from owner
if (Unit* owner = me->GetCharmerOrOwner())
if (owner->GetExactDist(me) >= (owner->GetVisibilityRange()-10.0f))
return true;
if (!me->_CanDetectFeignDeathOf(me->GetVictim()))
return true;
if (!me->_CanDetectFeignDeathOf(me->GetVictim()))
return true;
if (me->isTargetNotAcceptableByMMaps(me->GetVictim()->GetGUID(), sWorld->GetGameTime(), me->GetVictim()))
return true;
if (me->isTargetNotAcceptableByMMaps(me->GetVictim()->GetGUID(), sWorld->GetGameTime(), me->GetVictim()))
return true;
return !me->CanCreatureAttack(me->GetVictim());
return !me->CanCreatureAttack(me->GetVictim());
}
void PetAI::_stopAttack()
@@ -90,18 +90,18 @@ void PetAI::_stopAttack()
void PetAI::_doMeleeAttack()
{
// Xinef: Imps cannot attack with melee
if (!_canMeleeAttack())
return;
// Xinef: Imps cannot attack with melee
if (!_canMeleeAttack())
return;
DoMeleeAttackIfReady();
DoMeleeAttackIfReady();
}
bool PetAI::_canMeleeAttack() const
{
return me->GetEntry() != 416 /*ENTRY_IMP*/ &&
me->GetEntry() != 510 /*ENTRY_WATER_ELEMENTAL*/ &&
me->GetEntry() != 37994 /*ENTRY_WATER_ELEMENTAL_PERM*/;
return me->GetEntry() != 416 /*ENTRY_IMP*/ &&
me->GetEntry() != 510 /*ENTRY_WATER_ELEMENTAL*/ &&
me->GetEntry() != 37994 /*ENTRY_WATER_ELEMENTAL_PERM*/;
}
void PetAI::UpdateAI(uint32 diff)
@@ -162,34 +162,34 @@ void PetAI::UpdateAI(uint32 diff)
HandleReturnMovement();
}
// xinef: charm info must be always available
if (!me->GetCharmInfo())
return;
// xinef: charm info must be always available
if (!me->GetCharmInfo())
return;
// Autocast (casted only in combat or persistent spells in any state)
if (!me->HasUnitState(UNIT_STATE_CASTING))
{
if (owner && owner->GetTypeId() == TYPEID_PLAYER && me->GetCharmInfo()->GetForcedSpell() && me->GetCharmInfo()->GetForcedTarget())
{
owner->ToPlayer()->GetSession()->HandlePetActionHelper(me, me->GetGUID(), abs(me->GetCharmInfo()->GetForcedSpell()), ACT_ENABLED, me->GetCharmInfo()->GetForcedTarget());
if (owner && owner->GetTypeId() == TYPEID_PLAYER && me->GetCharmInfo()->GetForcedSpell() && me->GetCharmInfo()->GetForcedTarget())
{
owner->ToPlayer()->GetSession()->HandlePetActionHelper(me, me->GetGUID(), abs(me->GetCharmInfo()->GetForcedSpell()), ACT_ENABLED, me->GetCharmInfo()->GetForcedTarget());
// xinef: if spell was casted properly and we are in passive mode, handle return
if (!me->GetCharmInfo()->GetForcedSpell() && me->HasReactState(REACT_PASSIVE))
{
if (me->HasUnitState(UNIT_STATE_CASTING))
{
me->GetMotionMaster()->Clear(false);
me->StopMoving();
}
else
_stopAttack();
}
return;
}
// xinef: if spell was casted properly and we are in passive mode, handle return
if (!me->GetCharmInfo()->GetForcedSpell() && me->HasReactState(REACT_PASSIVE))
{
if (me->HasUnitState(UNIT_STATE_CASTING))
{
me->GetMotionMaster()->Clear(false);
me->StopMoving();
}
else
_stopAttack();
}
return;
}
// xinef: dont allow ghouls to cast spells below 75 energy
if (me->IsPet() && me->ToPet()->IsPetGhoul() && me->GetPower(POWER_ENERGY) < 75)
return;
// xinef: dont allow ghouls to cast spells below 75 energy
if (me->IsPet() && me->ToPet()->IsPetGhoul() && me->GetPower(POWER_ENERGY) < 75)
return;
typedef std::vector<std::pair<Unit*, Spell*> > TargetSpellList;
TargetSpellList targetSpellStore;
@@ -221,7 +221,7 @@ void PetAI::UpdateAI(uint32 diff)
}
Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0);
spell->LoadScripts(); // xinef: load for CanAutoCast (calling CheckPetCast)
spell->LoadScripts(); // xinef: load for CanAutoCast (calling CheckPetCast)
bool spellUsed = false;
// Some spells can target enemy or friendly (DK Ghoul's Leap)
@@ -333,7 +333,7 @@ void PetAI::UpdateAllies()
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* Target = itr->GetSource();
if (!Target || !Target->IsInMap(owner) || !group->SameSubGroup(owner->ToPlayer(), Target))
if (!Target || !Target->IsInMap(owner) || !group->SameSubGroup(owner->ToPlayer(), Target))
continue;
if (Target->GetGUID() == owner->GetGUID())
@@ -353,9 +353,9 @@ void PetAI::KilledUnit(Unit* victim)
if (me->GetVictim() && me->GetVictim() != victim)
return;
// Xinef: if pet is channeling a spell and owner killed something different, dont interrupt it
if (me->HasUnitState(UNIT_STATE_CASTING) && me->GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT) && me->GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT) != victim->GetGUID())
return;
// Xinef: if pet is channeling a spell and owner killed something different, dont interrupt it
if (me->HasUnitState(UNIT_STATE_CASTING) && me->GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT) && me->GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT) != victim->GetGUID())
return;
// Clear target just in case. May help problem where health / focus / mana
// regen gets stuck. Also resets attack command.
@@ -437,35 +437,35 @@ Unit* PetAI::SelectNextTarget(bool allowAutoSelect) const
// Check pet attackers first so we don't drag a bunch of targets to the owner
if (Unit* myAttacker = me->getAttackerForHelper())
if (!myAttacker->HasBreakableByDamageCrowdControlAura() && me->_CanDetectFeignDeathOf(myAttacker) && me->CanCreatureAttack(myAttacker) && !me->isTargetNotAcceptableByMMaps(myAttacker->GetGUID(), sWorld->GetGameTime(), myAttacker))
if (!myAttacker->HasBreakableByDamageCrowdControlAura() && me->_CanDetectFeignDeathOf(myAttacker) && me->CanCreatureAttack(myAttacker) && !me->isTargetNotAcceptableByMMaps(myAttacker->GetGUID(), sWorld->GetGameTime(), myAttacker))
return myAttacker;
// Check pet's attackers first to prevent dragging mobs back to owner
if (me->HasAuraType(SPELL_AURA_MOD_TAUNT))
{
const Unit::AuraEffectList& tauntAuras = me->GetAuraEffectsByType(SPELL_AURA_MOD_TAUNT);
if (!tauntAuras.empty())
for (Unit::AuraEffectList::const_reverse_iterator itr = tauntAuras.rbegin(); itr != tauntAuras.rend(); ++itr)
if (Unit* caster = (*itr)->GetCaster())
if (me->_CanDetectFeignDeathOf(caster) && me->CanCreatureAttack(caster) && !caster->HasAuraTypeWithCaster(SPELL_AURA_IGNORED, me->GetGUID()))
return caster;
}
if (me->HasAuraType(SPELL_AURA_MOD_TAUNT))
{
const Unit::AuraEffectList& tauntAuras = me->GetAuraEffectsByType(SPELL_AURA_MOD_TAUNT);
if (!tauntAuras.empty())
for (Unit::AuraEffectList::const_reverse_iterator itr = tauntAuras.rbegin(); itr != tauntAuras.rend(); ++itr)
if (Unit* caster = (*itr)->GetCaster())
if (me->_CanDetectFeignDeathOf(caster) && me->CanCreatureAttack(caster) && !caster->HasAuraTypeWithCaster(SPELL_AURA_IGNORED, me->GetGUID()))
return caster;
}
// Not sure why we wouldn't have an owner but just in case...
Unit* owner = me->GetCharmerOrOwner();
Unit* owner = me->GetCharmerOrOwner();
if (!owner)
return NULL;
// Check owner attackers
if (Unit* ownerAttacker = owner->getAttackerForHelper())
if (!ownerAttacker->HasBreakableByDamageCrowdControlAura() && me->_CanDetectFeignDeathOf(ownerAttacker) && me->CanCreatureAttack(ownerAttacker) && !me->isTargetNotAcceptableByMMaps(ownerAttacker->GetGUID(), sWorld->GetGameTime(), ownerAttacker))
if (!ownerAttacker->HasBreakableByDamageCrowdControlAura() && me->_CanDetectFeignDeathOf(ownerAttacker) && me->CanCreatureAttack(ownerAttacker) && !me->isTargetNotAcceptableByMMaps(ownerAttacker->GetGUID(), sWorld->GetGameTime(), ownerAttacker))
return ownerAttacker;
// Check owner victim
// 3.0.2 - Pets now start attacking their owners victim in defensive mode as soon as the hunter does
if (Unit* ownerVictim = owner->GetVictim())
if (me->_CanDetectFeignDeathOf(ownerVictim) && me->CanCreatureAttack(ownerVictim) && !me->isTargetNotAcceptableByMMaps(ownerVictim->GetGUID(), sWorld->GetGameTime(), ownerVictim))
return ownerVictim;
if (me->_CanDetectFeignDeathOf(ownerVictim) && me->CanCreatureAttack(ownerVictim) && !me->isTargetNotAcceptableByMMaps(ownerVictim->GetGUID(), sWorld->GetGameTime(), ownerVictim))
return ownerVictim;
// Neither pet or owner had a target and aggressive pets can pick any target
// To prevent aggressive pets from chain selecting targets and running off, we
@@ -509,7 +509,7 @@ void PetAI::HandleReturnMovement()
{
if (!me->GetCharmInfo()->IsFollowing() && !me->GetCharmInfo()->IsReturning())
{
if (me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_CONTROLLED) == NULL_MOTION_TYPE)
if (me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_CONTROLLED) == NULL_MOTION_TYPE)
{
ClearCharmInfoFlags();
me->GetCharmInfo()->SetIsReturning(true);
@@ -519,23 +519,23 @@ void PetAI::HandleReturnMovement()
}
}
me->GetCharmInfo()->SetForcedSpell(0);
me->GetCharmInfo()->SetForcedTargetGUID(0);
me->GetCharmInfo()->SetForcedSpell(0);
me->GetCharmInfo()->SetForcedTargetGUID(0);
// xinef: remember that npcs summoned by npcs can also be pets
me->DeleteThreatList();
me->ClearInPetCombat();
// xinef: remember that npcs summoned by npcs can also be pets
me->DeleteThreatList();
me->ClearInPetCombat();
}
void PetAI::SpellHit(Unit* caster, const SpellInfo* spellInfo)
{
// Xinef: taunt behavior code
if (spellInfo->HasAura(SPELL_AURA_MOD_TAUNT) && !me->HasReactState(REACT_PASSIVE))
{
me->GetCharmInfo()->SetForcedSpell(0);
me->GetCharmInfo()->SetForcedTargetGUID(0);
AttackStart(caster);
}
// Xinef: taunt behavior code
if (spellInfo->HasAura(SPELL_AURA_MOD_TAUNT) && !me->HasReactState(REACT_PASSIVE))
{
me->GetCharmInfo()->SetForcedSpell(0);
me->GetCharmInfo()->SetForcedTargetGUID(0);
AttackStart(caster);
}
}
void PetAI::DoAttack(Unit* target, bool chase)
@@ -545,11 +545,11 @@ void PetAI::DoAttack(Unit* target, bool chase)
if (me->Attack(target, true))
{
// xinef: properly fix fake combat after pet is sent to attack
if (Unit* owner = me->GetOwner())
owner->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
// xinef: properly fix fake combat after pet is sent to attack
if (Unit* owner = me->GetOwner())
owner->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
// Play sound to let the player know the pet is attacking something it picked on its own
if (me->HasReactState(REACT_AGGRESSIVE) && !me->GetCharmInfo()->IsCommandAttack())
@@ -565,12 +565,12 @@ void PetAI::DoAttack(Unit* target, bool chase)
if (chase)
{
me->GetMotionMaster()->MoveChase(target, !_canMeleeAttack() ? 20.0f: 0.0f, me->GetAngle(target));
me->GetMotionMaster()->MoveChase(target, !_canMeleeAttack() ? 20.0f: 0.0f, me->GetAngle(target));
}
else // (Stay && ((Aggressive || Defensive) && In Melee Range)))
{
me->GetCharmInfo()->SetIsAtStay(true);
me->GetMotionMaster()->MovementExpiredOnSlot(MOTION_SLOT_ACTIVE, false);
me->GetMotionMaster()->MovementExpiredOnSlot(MOTION_SLOT_ACTIVE, false);
me->GetMotionMaster()->MoveIdle();
}
}
@@ -621,34 +621,34 @@ bool PetAI::CanAttack(Unit* target, const SpellInfo* spellInfo)
if (!target->IsAlive())
{
// xinef: if target is invalid, pet should evade automaticly
// xinef: if target is invalid, pet should evade automaticly
// Clear target to prevent getting stuck on dead targets
//me->AttackStop();
//me->InterruptNonMeleeSpells(false);
return false;
}
// xinef: check unit states of pet
if (me->HasUnitState(UNIT_STATE_LOST_CONTROL))
return false;
// xinef: check unit states of pet
if (me->HasUnitState(UNIT_STATE_LOST_CONTROL))
return false;
// xinef: pets of mounted players have stunned flag only, check this also
if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED))
return false;
// xinef: pets of mounted players have stunned flag only, check this also
if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED))
return false;
// pussywizard: ZOMG! TEMP!
if (!me->GetCharmInfo())
{
sLog->outMisc("PetAI::CanAttack (A1) - %u, %u", me->GetEntry(), GUID_LOPART(me->GetOwnerGUID()));
return false;
}
// pussywizard: ZOMG! TEMP!
if (!me->GetCharmInfo())
{
sLog->outMisc("PetAI::CanAttack (A1) - %u, %u", me->GetEntry(), GUID_LOPART(me->GetOwnerGUID()));
return false;
}
// Passive - passive pets can attack if told to
if (me->HasReactState(REACT_PASSIVE))
return me->GetCharmInfo()->IsCommandAttack();
// CC - mobs under crowd control can be attacked if owner commanded
if (target->HasBreakableByDamageCrowdControlAura() && (!spellInfo || !spellInfo->HasAttribute(SPELL_ATTR4_DAMAGE_DOESNT_BREAK_AURAS)))
if (target->HasBreakableByDamageCrowdControlAura() && (!spellInfo || !spellInfo->HasAttribute(SPELL_ATTR4_DAMAGE_DOESNT_BREAK_AURAS)))
return me->GetCharmInfo()->IsCommandAttack();
// Returning - pets ignore attacks only if owner clicked follow
@@ -658,7 +658,7 @@ bool PetAI::CanAttack(Unit* target, const SpellInfo* spellInfo)
// Stay - can attack if target is within range or commanded to
if (me->GetCharmInfo()->HasCommandState(COMMAND_STAY))
return (me->IsWithinMeleeRange(target) || me->GetCharmInfo()->IsCommandAttack());
// Pets attacking something (or chasing) should only switch targets if owner tells them to
if (me->GetVictim() && me->GetVictim() != target)
{
@@ -668,7 +668,7 @@ bool PetAI::CanAttack(Unit* target, const SpellInfo* spellInfo)
ownerTarget = owner->GetSelectedUnit();
else
ownerTarget = me->GetCharmerOrOwner()->GetVictim();
if (ownerTarget && me->GetCharmInfo()->IsCommandAttack())
return (target->GetGUID() == ownerTarget->GetGUID());
}

View File

@@ -48,14 +48,14 @@ class PetAI : public CreatureAI
void MoveInLineOfSight(Unit* /*who*/) {} // CreatureAI interferes with returning pets
void MoveInLineOfSight_Safe(Unit* /*who*/) {} // CreatureAI interferes with returning pets
void EnterEvadeMode() {} // For fleeing, pets don't use this type of Evade mechanic
void SpellHit(Unit* caster, const SpellInfo* spellInfo);
void SpellHit(Unit* caster, const SpellInfo* spellInfo);
private:
bool _isVisible(Unit*) const;
bool _needToStop(void);
void _stopAttack(void);
void _doMeleeAttack();
bool _canMeleeAttack() const;
void _doMeleeAttack();
bool _canMeleeAttack() const;
void UpdateAllies();

View File

@@ -46,16 +46,16 @@ class TotemAI : public CreatureAI
class KillMagnetEvent : public BasicEvent
{
public:
KillMagnetEvent(Unit& self) : _self(self) { }
bool Execute(uint64 e_time, uint32 p_time)
{
_self.setDeathState(JUST_DIED);
return true;
}
public:
KillMagnetEvent(Unit& self) : _self(self) { }
bool Execute(uint64 e_time, uint32 p_time)
{
_self.setDeathState(JUST_DIED);
return true;
}
protected:
Unit& _self;
protected:
Unit& _self;
};
#endif

View File

@@ -53,10 +53,10 @@ void UnitAI::DoMeleeAttackIfReady()
//Make sure our attack is ready and we aren't currently casting before checking distance
if (me->isAttackReady())
{
// xinef: prevent base and off attack in same time, delay attack at 0.2 sec
if (me->haveOffhandWeapon())
if (me->getAttackTimer(OFF_ATTACK) < ATTACK_DISPLAY_DELAY)
me->setAttackTimer(OFF_ATTACK, ATTACK_DISPLAY_DELAY);
// xinef: prevent base and off attack in same time, delay attack at 0.2 sec
if (me->haveOffhandWeapon())
if (me->getAttackTimer(OFF_ATTACK) < ATTACK_DISPLAY_DELAY)
me->setAttackTimer(OFF_ATTACK, ATTACK_DISPLAY_DELAY);
me->AttackerStateUpdate(victim);
me->resetAttackTimer();
@@ -64,8 +64,8 @@ void UnitAI::DoMeleeAttackIfReady()
if (me->haveOffhandWeapon() && me->isAttackReady(OFF_ATTACK))
{
// xinef: delay main hand attack if both will hit at the same time (players code)
if (me->getAttackTimer(BASE_ATTACK) < ATTACK_DISPLAY_DELAY)
// xinef: delay main hand attack if both will hit at the same time (players code)
if (me->getAttackTimer(BASE_ATTACK) < ATTACK_DISPLAY_DELAY)
me->setAttackTimer(BASE_ATTACK, ATTACK_DISPLAY_DELAY);
me->AttackerStateUpdate(victim, OFF_ATTACK);

View File

@@ -121,7 +121,7 @@ struct PowerUsersSelector : public std::unary_function<Unit*, bool>
Unit const* _me;
float const _dist;
bool const _playerOnly;
Powers const _power;
Powers const _power;
PowerUsersSelector(Unit const* unit, Powers power, float dist, bool playerOnly) : _me(unit), _power(power), _dist(dist), _playerOnly(playerOnly) { }
@@ -131,8 +131,8 @@ struct PowerUsersSelector : public std::unary_function<Unit*, bool>
if (!_me || !target)
return false;
if (target->getPowerType() != _power)
return false;
if (target->getPowerType() != _power)
return false;
if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER)
return false;
@@ -162,8 +162,8 @@ struct FarthestTargetSelector : public std::unary_function<Unit*, bool>
if (_dist > 0.0f && !_me->IsWithinCombatRange(target, _dist))
return false;
if (_inLos && !_me->IsWithinLOSInMap(target))
return false;
if (_inLos && !_me->IsWithinLOSInMap(target))
return false;
return true;
}
@@ -172,7 +172,7 @@ private:
const Unit* _me;
float _dist;
bool _playerOnly;
bool _inLos;
bool _inLos;
};
class UnitAI

View File

@@ -58,8 +58,8 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= NULL*/, float maxRangeToN
return;
}
// Xinef: Skip creatures in evade mode
if (!creature->HasReactState(REACT_PASSIVE) && !creature->GetVictim() && !creature->IsInEvadeMode())
// Xinef: Skip creatures in evade mode
if (!creature->HasReactState(REACT_PASSIVE) && !creature->GetVictim() && !creature->IsInEvadeMode())
{
if (Unit* nearTarget = creature->SelectNearestTarget(maxRangeToNearestTarget))
creature->AI()->AttackStart(nearTarget);
@@ -128,12 +128,12 @@ void CreatureAI::MoveInLineOfSight(Unit* who)
if (me->GetVictim())
return;
// pussywizard: civilian, non-combat pet or any other NOT HOSTILE TO ANYONE (!)
if (me->IsMoveInLineOfSightDisabled())
if (me->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET || // nothing more to do, return
!who->IsInCombat() || // if not in combat, nothing more to do
!me->IsWithinDist(who, ATTACK_DISTANCE)) // if in combat and in dist - neutral to all can actually assist other creatures
return;
// pussywizard: civilian, non-combat pet or any other NOT HOSTILE TO ANYONE (!)
if (me->IsMoveInLineOfSightDisabled())
if (me->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET || // nothing more to do, return
!who->IsInCombat() || // if not in combat, nothing more to do
!me->IsWithinDist(who, ATTACK_DISTANCE)) // if in combat and in dist - neutral to all can actually assist other creatures
return;
if (me->CanStartAttack(who))
AttackStart(who);
@@ -212,9 +212,9 @@ bool CreatureAI::UpdateVictim()
AttackStart(victim);
return me->GetVictim();
}
// xinef: if we have any victim, just return true
else if (me->GetVictim() && me->GetExactDist(me->GetVictim()) < 30.0f)
return true;
// xinef: if we have any victim, just return true
else if (me->GetVictim() && me->GetExactDist(me->GetVictim()) < 30.0f)
return true;
else if (me->getThreatManager().isThreatListEmpty())
{
EnterEvadeMode();

View File

@@ -165,11 +165,11 @@ class CreatureAI : public UnitAI
/// == Fields =======================================
virtual void PassengerBoarded(Unit* /*passenger*/, int8 /*seatId*/, bool /*apply*/) {}
virtual void OnSpellClick(Unit* /*clicker*/, bool& /*result*/) { }
virtual void OnSpellClick(Unit* /*clicker*/, bool& /*result*/) { }
virtual bool CanSeeAlways(WorldObject const* /*obj*/) { return false; }
virtual bool CanBeSeen(Player const* /*seer*/) { return true; }
virtual bool CanBeSeen(Player const* /*seer*/) { return true; }
protected:
virtual void MoveInLineOfSight(Unit* /*who*/);

View File

@@ -33,8 +33,8 @@ namespace FactorySelector
const CreatureAICreator* ai_factory = NULL;
CreatureAIRegistry& ai_registry(*CreatureAIRepository::instance());
// xinef: if we have controlable guardian, define petai for players as they can steer him, otherwise db / normal ai
// xinef: dont remember why i changed this qq commented out as may break some quests
// xinef: if we have controlable guardian, define petai for players as they can steer him, otherwise db / normal ai
// xinef: dont remember why i changed this qq commented out as may break some quests
if (creature->IsPet()/* || (creature->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN) && ((Guardian*)creature)->GetOwner()->GetTypeId() == TYPEID_PLAYER)*/)
ai_factory = ai_registry.GetRegistryItem("PetAI");
@@ -95,7 +95,7 @@ namespace FactorySelector
}
// select NullCreatureAI if not another cases
// xinef: unused
// xinef: unused
// ainame = (ai_factory == NULL) ? "NullCreatureAI" : ai_factory->key();
;//sLog->outDebug(LOG_FILTER_TSCR, "Creature %u used AI is %s.", creature->GetGUIDLow(), ainame.c_str());
@@ -143,7 +143,7 @@ namespace FactorySelector
//future goAI types go here
// xinef: unused
// xinef: unused
//std::string ainame = (ai_factory == NULL || go->GetScriptId()) ? "NullGameObjectAI" : ai_factory->key();
;//sLog->outDebug(LOG_FILTER_TSCR, "GameObject %u used AI is %s.", go->GetGUIDLow(), ainame.c_str());

View File

@@ -90,7 +90,7 @@ bool SummonList::HasEntry(uint32 entry) const
uint32 SummonList::GetEntryCount(uint32 entry) const
{
uint32 count = 0;
uint32 count = 0;
for (StorageType::const_iterator i = storage_.begin(); i != storage_.end(); ++i)
{
Creature* summon = ObjectAccessor::GetCreature(*me, *i);
@@ -106,10 +106,10 @@ void SummonList::Respawn()
for (StorageType::iterator i = storage_.begin(); i != storage_.end();)
{
if (Creature* summon = ObjectAccessor::GetCreature(*me, *i))
{
summon->Respawn(true);
{
summon->Respawn(true);
++i;
}
}
else
i = storage_.erase(i);
}
@@ -120,8 +120,8 @@ Creature* SummonList::GetCreatureWithEntry(uint32 entry) const
for (StorageType::const_iterator i = storage_.begin(); i != storage_.end(); ++i)
{
if (Creature* summon = ObjectAccessor::GetCreature(*me, *i))
if (summon->GetEntry() == entry)
return summon;
if (summon->GetEntry() == entry)
return summon;
}
return NULL;
@@ -296,7 +296,7 @@ void ScriptedAI::DoResetThreat()
return;
}
me->getThreatManager().resetAllAggro();
me->getThreatManager().resetAllAggro();
}
float ScriptedAI::DoGetThreat(Unit* unit)
@@ -410,20 +410,20 @@ enum eNPCs
NPC_BROODLORD = 12017,
NPC_JAN_ALAI = 23578,
NPC_SARTHARION = 28860,
NPC_FREYA = 32906,
NPC_FREYA = 32906,
};
bool ScriptedAI::EnterEvadeIfOutOfCombatArea()
{
if (me->IsInEvadeMode() || !me->IsInCombat())
if (me->IsInEvadeMode() || !me->IsInCombat())
return false;
if (_evadeCheckCooldown == time(NULL))
return false;
_evadeCheckCooldown = time(NULL);
if (_evadeCheckCooldown == time(NULL))
return false;
_evadeCheckCooldown = time(NULL);
if (!CheckEvadeIfOutOfCombatArea())
return false;
if (!CheckEvadeIfOutOfCombatArea())
return false;
EnterEvadeMode();
return true;
@@ -431,22 +431,22 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea()
Player* ScriptedAI::SelectTargetFromPlayerList(float maxdist, uint32 excludeAura, bool mustBeInLOS) const
{
Map::PlayerList const& pList = me->GetMap()->GetPlayers();
std::vector<Player*> tList;
for(Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
{
if (me->GetDistance(itr->GetSource()) > maxdist || !itr->GetSource()->IsAlive() || itr->GetSource()->IsGameMaster())
continue;
if (excludeAura && itr->GetSource()->HasAura(excludeAura))
continue;
if (mustBeInLOS && !me->IsWithinLOSInMap(itr->GetSource()))
continue;
tList.push_back(itr->GetSource());
}
if (!tList.empty())
return tList[urand(0,tList.size()-1)];
else
return NULL;
Map::PlayerList const& pList = me->GetMap()->GetPlayers();
std::vector<Player*> tList;
for(Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
{
if (me->GetDistance(itr->GetSource()) > maxdist || !itr->GetSource()->IsAlive() || itr->GetSource()->IsGameMaster())
continue;
if (excludeAura && itr->GetSource()->HasAura(excludeAura))
continue;
if (mustBeInLOS && !me->IsWithinLOSInMap(itr->GetSource()))
continue;
tList.push_back(itr->GetSource());
}
if (!tList.empty())
return tList[urand(0,tList.size()-1)];
else
return NULL;
}
// BossAI - for instanced bosses

View File

@@ -79,10 +79,10 @@ public:
return storage_.size();
}
void clear()
{
storage_.clear();
}
void clear()
{
storage_.clear();
}
void Summon(Creature const* summon) { storage_.push_back(summon->GetGUID()); }
void Despawn(Creature const* summon) { storage_.remove(summon->GetGUID()); }
@@ -100,7 +100,7 @@ public:
if (max)
RemoveNotExisting(); // pussywizard: when max is set, non existing can be chosen and nothing will happen
StorageType listCopy = storage_;
StorageType listCopy = storage_;
for (StorageType::const_iterator i = listCopy.begin(); i != listCopy.end(); ++i)
{
if (Creature* summon = ObjectAccessor::GetCreature(*me, *i))
@@ -135,8 +135,8 @@ public:
void RemoveNotExisting();
bool HasEntry(uint32 entry) const;
uint32 GetEntryCount(uint32 entry) const;
void Respawn();
Creature* GetCreatureWithEntry(uint32 entry) const;
void Respawn();
Creature* GetCreatureWithEntry(uint32 entry) const;
private:
Creature* me;
@@ -159,7 +159,7 @@ class PlayerOrPetCheck
bool operator() (WorldObject* unit) const
{
if (unit->GetTypeId() != TYPEID_PLAYER)
if (!IS_PLAYER_GUID(unit->ToUnit()->GetOwnerGUID()))
if (!IS_PLAYER_GUID(unit->ToUnit()->GetOwnerGUID()))
return true;
return false;
@@ -291,7 +291,7 @@ struct ScriptedAI : public CreatureAI
bool IsCombatMovementAllowed() const { return _isCombatMovementAllowed; }
bool EnterEvadeIfOutOfCombatArea();
virtual bool CheckEvadeIfOutOfCombatArea() const { return false; }
virtual bool CheckEvadeIfOutOfCombatArea() const { return false; }
// return true for heroic mode. i.e.
// - for dungeon in mode 10-heroic,
@@ -358,7 +358,7 @@ struct ScriptedAI : public CreatureAI
return heroic25;
}
Player* SelectTargetFromPlayerList(float maxdist, uint32 excludeAura = 0, bool mustBeInLOS = false) const;
Player* SelectTargetFromPlayerList(float maxdist, uint32 excludeAura = 0, bool mustBeInLOS = false) const;
private:
Difficulty _difficulty;

View File

@@ -87,8 +87,8 @@ bool npc_escortAI::AssistPlayerInCombat(Unit* who)
void npc_escortAI::MoveInLineOfSight(Unit* who)
{
if (me->GetVictim())
return;
if (me->GetVictim())
return;
if (!me->HasUnitState(UNIT_STATE_STUNNED) && who->isTargetableForAttack(true, me) && who->isInAccessiblePlaceFor(me))
if (HasEscortState(STATE_ESCORT_ESCORTING) && AssistPlayerInCombat(who))
@@ -122,7 +122,7 @@ void npc_escortAI::JustDied(Unit* /*killer*/)
void npc_escortAI::JustRespawned()
{
RemoveEscortState(STATE_ESCORT_ESCORTING|STATE_ESCORT_RETURNING|STATE_ESCORT_PAUSED);
RemoveEscortState(STATE_ESCORT_ESCORTING|STATE_ESCORT_RETURNING|STATE_ESCORT_PAUSED);
if (!IsCombatMovementAllowed())
SetCombatMovement(true);
@@ -139,7 +139,7 @@ void npc_escortAI::JustRespawned()
void npc_escortAI::ReturnToLastPoint()
{
float x, y, z, o;
me->SetWalk(false);
me->SetWalk(false);
me->GetHomePosition(x, y, z, o);
me->GetMotionMaster()->MovePoint(POINT_LAST_POINT, x, y, z);
}
@@ -213,8 +213,8 @@ void npc_escortAI::UpdateAI(uint32 diff)
me->DespawnOrUnsummon();
}
// xinef: remove escort state, escort was finished (lack of this line resulted in skipping UpdateEscortAI calls after finished escort)
RemoveEscortState(STATE_ESCORT_ESCORTING);
// xinef: remove escort state, escort was finished (lack of this line resulted in skipping UpdateEscortAI calls after finished escort)
RemoveEscortState(STATE_ESCORT_ESCORTING);
return;
}
@@ -239,7 +239,7 @@ void npc_escortAI::UpdateAI(uint32 diff)
//Check if player or any member of his group is within range
if (HasEscortState(STATE_ESCORT_ESCORTING) && m_uiPlayerGUID && !me->GetVictim() && !HasEscortState(STATE_ESCORT_RETURNING))
{
m_uiPlayerCheckTimer += diff;
m_uiPlayerCheckTimer += diff;
if (m_uiPlayerCheckTimer > 1000)
{
if (DespawnAtFar && !IsPlayerOrGroupInRange())
@@ -303,7 +303,7 @@ void npc_escortAI::MovementInform(uint32 moveType, uint32 pointId)
{
//Call WP function
me->SetPosition(CurrentWP->x, CurrentWP->y, CurrentWP->z, me->GetOrientation());
me->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
me->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
WaypointReached(CurrentWP->id);
m_uiWPWaitTimer = CurrentWP->WaitTimeMs + 1;
@@ -495,9 +495,9 @@ bool npc_escortAI::SetNextWaypoint(uint32 pointId, bool setPosition)
size_t const size = WaypointList.size();
Escort_Waypoint waypoint(0, 0, 0, 0, 0);
for (CurrentWP = WaypointList.begin(); CurrentWP != WaypointList.end(); ++CurrentWP)
for (CurrentWP = WaypointList.begin(); CurrentWP != WaypointList.end(); ++CurrentWP)
{
if (CurrentWP->id == pointId)
if (CurrentWP->id == pointId)
{
if (setPosition)
me->UpdatePosition(CurrentWP->x, CurrentWP->y, CurrentWP->z, me->GetOrientation());
@@ -540,7 +540,7 @@ void npc_escortAI::GenerateWaypointArray(Movement::PointsArray* points)
{
// xinef: first point in vector is unit real position
points->clear();
points->push_back(G3D::Vector3(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()));
points->push_back(G3D::Vector3(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()));
for (std::list<Escort_Waypoint>::const_iterator itr = CurrentWP; itr != WaypointList.end(); ++itr)
points->push_back(G3D::Vector3(itr->x, itr->y, itr->z));
}

View File

@@ -35,7 +35,7 @@ void FollowerAI::AttackStart(Unit* who)
if (me->Attack(who, true))
{
// This is done in Unit::Attack function which wont bug npcs by not adding threat upon combat start...
// This is done in Unit::Attack function which wont bug npcs by not adding threat upon combat start...
//me->AddThreat(who, 0.0f);
//me->SetInCombatWith(who);
//who->SetInCombatWith(me);
@@ -80,14 +80,14 @@ bool FollowerAI::AssistPlayerInCombat(Unit* who)
void FollowerAI::MoveInLineOfSight(Unit* who)
{
if (me->GetVictim())
return;
if (me->GetVictim())
return;
if (!me->HasUnitState(UNIT_STATE_STUNNED) && who->isTargetableForAttack(true, me) && who->isInAccessiblePlaceFor(me))
if (HasFollowState(STATE_FOLLOW_INPROGRESS) && AssistPlayerInCombat(who))
return;
if (me->CanStartAttack(who))
if (me->CanStartAttack(who))
AttackStart(who);
}

View File

@@ -39,15 +39,15 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c)
mEscortState = SMART_ESCORT_NONE;
mCurrentWPID = 0;//first wp id is 1 !!
mWPReached = false;
mOOCReached = false;
mOOCReached = false;
mWPPauseTimer = 0;
mLastWP = NULL;
mEscortNPCFlags = 0;
mEscortNPCFlags = 0;
mCanRepeatPath = false;
// spawn in run mode
// Xinef: spawn in run mode and set mRun to run... this overrides SetWalk EVERYWHERE, RETARDS
// Xinef: spawn in run mode and set mRun to run... this overrides SetWalk EVERYWHERE, RETARDS
mRun = true;
mCanAutoAttack = true;
@@ -73,10 +73,10 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c)
mJustReset = false;
// Xinef: Vehicle conditions
m_ConditionsTimer = 0;
if (me->GetVehicleKit())
conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, me->GetEntry());
// Xinef: Vehicle conditions
m_ConditionsTimer = 0;
if (me->GetVehicleKit())
conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, me->GetEntry());
}
void SmartAI::UpdateDespawn(const uint32 diff)
@@ -95,8 +95,8 @@ void SmartAI::UpdateDespawn(const uint32 diff)
else
me->DespawnOrUnsummon();
}
else
mDespawnTime -= diff;
else
mDespawnTime -= diff;
}
WayPoint* SmartAI::GetNextWayPoint()
@@ -192,10 +192,10 @@ void SmartAI::StartPath(bool run, uint32 path, bool repeat, Unit* invoker)
StopPath();
if (path)
{
{
if (!LoadPath(path))
return;
}
}
if (!mWayPoints || mWayPoints->empty())
return;
@@ -206,11 +206,11 @@ void SmartAI::StartPath(bool run, uint32 path, bool repeat, Unit* invoker)
mCanRepeatPath = repeat;
SetRun(run);
if (invoker && invoker->GetTypeId() == TYPEID_PLAYER)
{
mEscortNPCFlags = me->GetUInt32Value(UNIT_NPC_FLAGS);
me->SetUInt32Value(UNIT_NPC_FLAGS, 0);
}
if (invoker && invoker->GetTypeId() == TYPEID_PLAYER)
{
mEscortNPCFlags = me->GetUInt32Value(UNIT_NPC_FLAGS);
me->SetUInt32Value(UNIT_NPC_FLAGS, 0);
}
Movement::PointsArray pathPoints;
GenerateWayPointArray(&pathPoints);
@@ -251,7 +251,7 @@ void SmartAI::PausePath(uint32 delay, bool forced)
mWPPauseTimer = delay;
if (forced && !mWPReached)
{
mForcedPaused = forced;
mForcedPaused = forced;
SetRun(mRun);
if (me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_ACTIVE) == ESCORT_MOTION_TYPE)
me->GetMotionMaster()->MovementExpired();
@@ -288,11 +288,11 @@ void SmartAI::EndPath(bool fail)
mLastWP = NULL;
mWPPauseTimer = 0;
if (mEscortNPCFlags)
{
me->SetUInt32Value(UNIT_NPC_FLAGS, mEscortNPCFlags);
mEscortNPCFlags = 0;
}
if (mEscortNPCFlags)
{
me->SetUInt32Value(UNIT_NPC_FLAGS, mEscortNPCFlags);
mEscortNPCFlags = 0;
}
ObjectList* targets = GetScript()->GetTargetList(SMART_ESCORT_TARGETS);
if (targets && mEscortQuestID)
@@ -305,8 +305,8 @@ void SmartAI::EndPath(bool fail)
for (GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->next())
{
Player* groupGuy = groupRef->GetSource();
if (!groupGuy || !player->IsInMap(groupGuy))
continue;
if (!groupGuy || !player->IsInMap(groupGuy))
continue;
if (!fail && groupGuy->IsAtGroupRewardDistance(me) && !groupGuy->GetCorpse())
groupGuy->AreaExploredOrEventHappens(mEscortQuestID);
@@ -314,15 +314,15 @@ void SmartAI::EndPath(bool fail)
groupGuy->FailQuest(mEscortQuestID);
}
}
else
{
if (!fail && player->IsAtGroupRewardDistance(me) && !player->GetCorpse())
player->GroupEventHappens(mEscortQuestID, me);
else if (fail && player->GetQuestStatus(mEscortQuestID) == QUEST_STATUS_INCOMPLETE)
player->FailQuest(mEscortQuestID);
}
else
{
if (!fail && player->IsAtGroupRewardDistance(me) && !player->GetCorpse())
player->GroupEventHappens(mEscortQuestID, me);
else if (fail && player->GetQuestStatus(mEscortQuestID) == QUEST_STATUS_INCOMPLETE)
player->FailQuest(mEscortQuestID);
}
}
else
else
{
for (ObjectList::iterator iter = targets->begin(); iter != targets->end(); ++iter)
{
@@ -338,16 +338,16 @@ void SmartAI::EndPath(bool fail)
}
}
// Xinef: if the escort failed - DO NOT PROCESS ANYTHING, ITS RETARDED
// Xinef: End Path events should be only processed if it was SUCCESSFUL stop or stop called by SMART_ACTION_WAYPOINT_STOP
if (fail)
{
mCurrentWPID = 0;
return;
}
// Xinef: if the escort failed - DO NOT PROCESS ANYTHING, ITS RETARDED
// Xinef: End Path events should be only processed if it was SUCCESSFUL stop or stop called by SMART_ACTION_WAYPOINT_STOP
if (fail)
{
mCurrentWPID = 0;
return;
}
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_ENDED, NULL, mCurrentWPID, GetScript()->GetPathId());
mCurrentWPID = 0;
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_ENDED, NULL, mCurrentWPID, GetScript()->GetPathId());
mCurrentWPID = 0;
if (mCanRepeatPath)
StartPath(mRun, GetScript()->GetPathId(), mCanRepeatPath);
@@ -373,8 +373,8 @@ void SmartAI::ResumePath()
void SmartAI::ReturnToLastOOCPos()
{
me->SetWalk(false);
float x, y, z, o;
me->SetWalk(false);
float x, y, z, o;
me->GetHomePosition(x, y, z, o);
me->GetMotionMaster()->MovePoint(SMART_ESCORT_LAST_OOC_POINT, x, y, z);
}
@@ -386,21 +386,21 @@ void SmartAI::UpdatePath(const uint32 diff)
if (mEscortInvokerCheckTimer < diff)
{
// Xinef: Escort failed - no players in range
// Xinef: Despawn immediately
// Xinef: Escort failed - no players in range
// Xinef: Despawn immediately
if (!IsEscortInvokerInRange())
{
StopPath(0, mEscortQuestID, true);
// Xinef: allow to properly hook out of range despawn action, which in most cases should perform the same operation as dying
GetScript()->ProcessEventsFor(SMART_EVENT_DEATH, me);
me->DespawnOrUnsummon(1);
return;
// Xinef: allow to properly hook out of range despawn action, which in most cases should perform the same operation as dying
GetScript()->ProcessEventsFor(SMART_EVENT_DEATH, me);
me->DespawnOrUnsummon(1);
return;
}
mEscortInvokerCheckTimer = 1000;
}
else
mEscortInvokerCheckTimer -= diff;
else
mEscortInvokerCheckTimer -= diff;
// handle pause
if (HasEscortState(SMART_ESCORT_PAUSED))
@@ -415,13 +415,13 @@ void SmartAI::UpdatePath(const uint32 diff)
{
mWPReached = false;
mForcedPaused = false;
ResumePath();
ResumePath();
}
mWPPauseTimer = 0;
mWPPauseTimer = 0;
}
}
else
else
mWPPauseTimer -= diff;
}
@@ -429,7 +429,7 @@ void SmartAI::UpdatePath(const uint32 diff)
{
if (mOOCReached)//reached OOC WP
{
mOOCReached = false;
mOOCReached = false;
RemoveEscortState(SMART_ESCORT_RETURNING);
if (!HasEscortState(SMART_ESCORT_PAUSED))
ResumePath();
@@ -440,13 +440,13 @@ void SmartAI::UpdatePath(const uint32 diff)
return;
// handle next wp
if (!me->HasUnitState(UNIT_STATE_NOT_MOVE) && me->movespline->Finalized())//reached WP
if (!me->HasUnitState(UNIT_STATE_NOT_MOVE) && me->movespline->Finalized())//reached WP
{
if (!mWPReached)
{
ResumePath();
return;
}
if (!mWPReached)
{
ResumePath();
return;
}
mWPReached = false;
if (mCurrentWPID == GetWPCount())
@@ -464,16 +464,16 @@ void SmartAI::UpdatePath(const uint32 diff)
void SmartAI::CheckConditions(const uint32 diff)
{
Vehicle* vehicle = me->GetVehicleKit();
if (!vehicle)
return;
Vehicle* vehicle = me->GetVehicleKit();
if (!vehicle)
return;
if (m_ConditionsTimer < diff)
{
if (!conditions.empty())
{
for (SeatMap::iterator itr = vehicle->Seats.begin(); itr != vehicle->Seats.end(); ++itr)
if (Unit* passenger = ObjectAccessor::GetUnit(*me, itr->second.Passenger.Guid))
if (Unit* passenger = ObjectAccessor::GetUnit(*me, itr->second.Passenger.Guid))
{
if (Player* player = passenger->ToPlayer())
{
@@ -487,13 +487,13 @@ void SmartAI::CheckConditions(const uint32 diff)
}
m_ConditionsTimer = 1000;
}
else
m_ConditionsTimer -= diff;
else
m_ConditionsTimer -= diff;
}
void SmartAI::UpdateAI(uint32 diff)
{
CheckConditions(diff);
CheckConditions(diff);
GetScript()->OnUpdate(diff);
UpdatePath(diff);
UpdateDespawn(diff);
@@ -527,12 +527,12 @@ bool SmartAI::IsEscortInvokerInRange()
ObjectList* targets = GetScript()->GetTargetList(SMART_ESCORT_TARGETS);
if (targets)
{
float checkDist = me->GetInstanceScript() ? SMART_ESCORT_MAX_PLAYER_DIST*2 : SMART_ESCORT_MAX_PLAYER_DIST;
float checkDist = me->GetInstanceScript() ? SMART_ESCORT_MAX_PLAYER_DIST*2 : SMART_ESCORT_MAX_PLAYER_DIST;
if (targets->size() == 1 && GetScript()->IsPlayer((*targets->begin())))
{
Player* player = (*targets->begin())->ToPlayer();
if (me->GetDistance(player) <= checkDist)
return true;
return true;
if (Group* group = player->GetGroup())
{
@@ -540,12 +540,12 @@ bool SmartAI::IsEscortInvokerInRange()
{
Player* groupGuy = groupRef->GetSource();
if (groupGuy && me->IsInMap(groupGuy) && me->GetDistance(groupGuy) <= checkDist)
if (groupGuy && me->IsInMap(groupGuy) && me->GetDistance(groupGuy) <= checkDist)
return true;
}
}
}
else
else
{
for (ObjectList::iterator iter = targets->begin(); iter != targets->end(); ++iter)
{
@@ -557,10 +557,10 @@ bool SmartAI::IsEscortInvokerInRange()
}
}
// Xinef: no valid target found
return false;
// Xinef: no valid target found
return false;
}
// Xinef: no player invoker was stored, just ignore range check
// Xinef: no player invoker was stored, just ignore range check
return true;
}
@@ -571,19 +571,19 @@ void SmartAI::MovepointReached(uint32 id)
// xinef: both point movement and escort generator can enter this function
if (id == SMART_ESCORT_LAST_OOC_POINT)
{
mOOCReached = true;
{
mOOCReached = true;
return;
}
}
mWPReached = true;
mWPReached = true;
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_REACHED, NULL, mCurrentWPID);
if (mLastWP)
{
{
me->SetPosition(mLastWP->x, mLastWP->y, mLastWP->z, me->GetOrientation());
me->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
}
me->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
}
if (HasEscortState(SMART_ESCORT_PAUSED))
{
@@ -593,20 +593,20 @@ void SmartAI::MovepointReached(uint32 id)
me->StopMovingOnCurrentPos();
me->GetMotionMaster()->MoveIdle();
}
// Xinef: Can be unset in ProcessEvents
else if (HasEscortState(SMART_ESCORT_ESCORTING) && me->GetMotionMaster()->GetCurrentMovementGeneratorType() == ESCORT_MOTION_TYPE)
{
mWPReached = false;
if (mCurrentWPID == GetWPCount())
EndPath();
else if (GetNextWayPoint())
{
SetRun(mRun);
// xinef: if we have reached waypoint, and there is no working spline movement it means our splitted array has ended, make new one
if (me->movespline->Finalized())
ResumePath();
}
}
// Xinef: Can be unset in ProcessEvents
else if (HasEscortState(SMART_ESCORT_ESCORTING) && me->GetMotionMaster()->GetCurrentMovementGeneratorType() == ESCORT_MOTION_TYPE)
{
mWPReached = false;
if (mCurrentWPID == GetWPCount())
EndPath();
else if (GetNextWayPoint())
{
SetRun(mRun);
// xinef: if we have reached waypoint, and there is no working spline movement it means our splitted array has ended, make new one
if (me->movespline->Finalized())
ResumePath();
}
}
}
void SmartAI::MovementInform(uint32 MovementType, uint32 Data)
@@ -624,15 +624,15 @@ void SmartAI::MovementInform(uint32 MovementType, uint32 Data)
void SmartAI::EnterEvadeMode()
{
// xinef: fixes strange jumps when charming SmartAI npc
// xinef: fixes strange jumps when charming SmartAI npc
if (!me->IsAlive() || me->IsInEvadeMode())
return;
if (IS_PLAYER_GUID(me->GetCharmerGUID()) || me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
{
me->AttackStop();
return;
}
if (IS_PLAYER_GUID(me->GetCharmerGUID()) || me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
{
me->AttackStop();
return;
}
me->RemoveEvadeAuras();
@@ -656,19 +656,19 @@ void SmartAI::EnterEvadeMode()
{
if (Unit* target = ObjectAccessor::GetUnit(*me, mFollowGuid))
me->GetMotionMaster()->MoveFollow(target, mFollowDist, mFollowAngle);
me->ClearUnitState(UNIT_STATE_EVADE);
me->ClearUnitState(UNIT_STATE_EVADE);
// xinef: do not forget to reset scripts as we wont call reached home
GetScript()->OnReset();
// xinef: do not forget to reset scripts as we wont call reached home
GetScript()->OnReset();
}
else
{
{
me->GetMotionMaster()->MoveTargetedHome();
// xinef: do not forget to reset scripts as we wont call reached home
if (!me->HasUnitState(UNIT_STATE_EVADE))
GetScript()->OnReset();
}
// xinef: do not forget to reset scripts as we wont call reached home
if (!me->HasUnitState(UNIT_STATE_EVADE))
GetScript()->OnReset();
}
}
void SmartAI::MoveInLineOfSight(Unit* who)
@@ -678,8 +678,8 @@ void SmartAI::MoveInLineOfSight(Unit* who)
GetScript()->OnMoveInLineOfSight(who);
if (me->GetVictim())
return;
if (me->GetVictim())
return;
if (me->HasReactState(REACT_PASSIVE) || AssistPlayerInCombat(who))
return;
@@ -697,7 +697,7 @@ bool SmartAI::CanAIAttack(const Unit* /*who*/) const
bool SmartAI::AssistPlayerInCombat(Unit* who)
{
// Xinef: if unit has no victim, or victim is player controlled thing
// Xinef: if unit has no victim, or victim is player controlled thing
if (!who->GetVictim() || IS_PLAYER_GUID(who->GetCharmerOrOwnerOrOwnGUID()))
return false;
@@ -741,7 +741,7 @@ void SmartAI::JustRespawned()
mFollowArrivedTimer = 1000;
mFollowArrivedEntry = 0;
mFollowCreditType = 0;
mFollowArrivedAlive = true;
mFollowArrivedAlive = true;
}
int SmartAI::Permissible(const Creature* creature)
@@ -768,8 +768,8 @@ void SmartAI::JustReachedHome()
void SmartAI::EnterCombat(Unit* enemy)
{
// Xinef: Interrupt channeled spells
me->InterruptSpell(CURRENT_CHANNELED_SPELL, true, true);
// Xinef: Interrupt channeled spells
me->InterruptSpell(CURRENT_CHANNELED_SPELL, true, true);
GetScript()->ProcessEventsFor(SMART_EVENT_AGGRO, enemy);
}
@@ -792,27 +792,27 @@ void SmartAI::JustSummoned(Creature* creature)
void SmartAI::AttackStart(Unit* who)
{
// xinef: dont allow charmed npcs to act on their own
if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
{
if (who && mCanAutoAttack)
me->Attack(who, true);
return;
}
// xinef: dont allow charmed npcs to act on their own
if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
{
if (who && mCanAutoAttack)
me->Attack(who, true);
return;
}
if (who && me->Attack(who, me->IsWithinMeleeRange(who)))
{
if (mCanCombatMove || GetScript()->GetMaxCombatDist())
{
SetRun(mRun);
MovementGeneratorType type = me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_ACTIVE);
if (type == ESCORT_MOTION_TYPE || type == POINT_MOTION_TYPE)
{
me->GetMotionMaster()->MovementExpired();
me->StopMoving();
}
{
SetRun(mRun);
MovementGeneratorType type = me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_ACTIVE);
if (type == ESCORT_MOTION_TYPE || type == POINT_MOTION_TYPE)
{
me->GetMotionMaster()->MovementExpired();
me->StopMoving();
}
me->GetMotionMaster()->MoveChase(who, GetScript()->GetCasterActualDist() ? GetScript()->GetCasterActualDist() : GetScript()->GetActualCombatDist());
}
}
}
}
@@ -831,7 +831,7 @@ void SmartAI::DamageTaken(Unit* doneBy, uint32& damage, DamageEffectType damaget
if (doneBy)
GetScript()->ProcessEventsFor(SMART_EVENT_DAMAGED, doneBy, damage);
// Xinef: skip nodamage type (eg. instakill effect)
// Xinef: skip nodamage type (eg. instakill effect)
if (damagetype != NODAMAGE && mInvincibilityHpLevel && (damage >= me->GetHealth() - mInvincibilityHpLevel))
damage = me->GetHealth() - mInvincibilityHpLevel; // damage should not be nullified, because of player damage req.
}
@@ -869,9 +869,9 @@ void SmartAI::CorpseRemoved(uint32& respawnDelay)
{
GetScript()->ProcessEventsFor(SMART_EVENT_CORPSE_REMOVED, NULL, respawnDelay);
// xinef: end escort upon corpse remove, safe check in case of immediate despawn
if (IsEscorted())
EndPath(true);
// xinef: end escort upon corpse remove, safe check in case of immediate despawn
if (IsEscorted())
EndPath(true);
}
void SmartAI::PassengerBoarded(Unit* who, int8 seatId, bool apply)
@@ -883,11 +883,11 @@ void SmartAI::InitializeAI()
{
GetScript()->OnInitialize(me);
if (!me->isDead())
{
mJustReset = true;
JustReachedHome();
GetScript()->ProcessEventsFor(SMART_EVENT_RESPAWN);
}
{
mJustReset = true;
JustReachedHome();
GetScript()->ProcessEventsFor(SMART_EVENT_RESPAWN);
}
}
void SmartAI::OnCharmed(bool apply)
@@ -963,18 +963,18 @@ void SmartAI::sQuestReward(Player* player, Quest const* quest, uint32 opt)
void SmartAI::SetForcedCombatMove(float dist)
{
if (!me->GetVictim())
return;
if (!me->GetVictim())
return;
SetRun(mRun);
SetRun(mRun);
me->GetMotionMaster()->MoveChase(me->GetVictim(), dist);
}
void SmartAI::SetCombatMove(bool on)
{
// Xinef: Fix Combat Movement
if (GetScript()->GetMaxCombatDist()/* || GetScript()->GetCasterMaxDist()*/) // Xinef: we only need this hack for old caster movement system
return;
// Xinef: Fix Combat Movement
if (GetScript()->GetMaxCombatDist()/* || GetScript()->GetCasterMaxDist()*/) // Xinef: we only need this hack for old caster movement system
return;
if (mCanCombatMove == on)
return;
@@ -1016,7 +1016,7 @@ void SmartAI::SetFollow(Unit* target, float dist, float angle, uint32 credit, ui
mFollowArrivedTimer = 1000;
mFollowCredit = credit;
mFollowArrivedEntry = end;
mFollowArrivedAlive = !aliveState; // negate - 0 is alive
mFollowArrivedAlive = !aliveState; // negate - 0 is alive
me->GetMotionMaster()->MoveFollow(target, mFollowDist, mFollowAngle);
mFollowCreditType = creditType;
@@ -1036,10 +1036,10 @@ void SmartAI::StopFollow(bool complete)
me->StopMoving();
me->GetMotionMaster()->MoveIdle();
if (!complete)
return;
if (!complete)
return;
if (Player* player = ObjectAccessor::GetPlayer(*me, mFollowGuid))
if (Player* player = ObjectAccessor::GetPlayer(*me, mFollowGuid))
{
if (!mFollowCreditType)
player->RewardPlayerAndGroupAtEvent(mFollowCredit, me);
@@ -1047,10 +1047,10 @@ void SmartAI::StopFollow(bool complete)
player->GroupEventHappens(mFollowCredit, me);
}
SetDespawnTime(5000);
SetDespawnTime(5000);
StartDespawn();
GetScript()->ProcessEventsFor(SMART_EVENT_FOLLOW_COMPLETED);
GetScript()->ProcessEventsFor(SMART_EVENT_FOLLOW_COMPLETED);
}
void SmartAI::SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker)
@@ -1067,7 +1067,7 @@ void SmartAI::sOnGameEvent(bool start, uint16 eventId)
void SmartAI::OnSpellClick(Unit* clicker, bool& result)
{
// Xinef: i dont think this is necessery (can be made as event parameter)
// Xinef: i dont think this is necessery (can be made as event parameter)
//if (!result)
// return;
@@ -1090,16 +1090,16 @@ void SmartGameObjectAI::InitializeAI()
{
GetScript()->OnInitialize(go);
// Xinef: do not call respawn event if go is not spawned
if (go->isSpawned())
GetScript()->ProcessEventsFor(SMART_EVENT_RESPAWN);
// Xinef: do not call respawn event if go is not spawned
if (go->isSpawned())
GetScript()->ProcessEventsFor(SMART_EVENT_RESPAWN);
//Reset();
}
void SmartGameObjectAI::Reset()
{
// Xinef: call respawn event on reset
GetScript()->ProcessEventsFor(SMART_EVENT_RESPAWN);
// Xinef: call respawn event on reset
GetScript()->ProcessEventsFor(SMART_EVENT_RESPAWN);
GetScript()->OnReset();
}

View File

@@ -39,7 +39,7 @@ enum SmartEscortState
enum SmartEscortVars
{
SMART_ESCORT_MAX_PLAYER_DIST = 60,
SMART_MAX_AID_DIST = SMART_ESCORT_MAX_PLAYER_DIST / 2,
SMART_MAX_AID_DIST = SMART_ESCORT_MAX_PLAYER_DIST / 2,
};
class SmartAI : public CreatureAI
@@ -59,11 +59,11 @@ class SmartAI : public CreatureAI
void GenerateWayPointArray(Movement::PointsArray* points);
bool HasEscortState(uint32 uiEscortState) { return (mEscortState & uiEscortState); }
void AddEscortState(uint32 uiEscortState) { mEscortState |= uiEscortState; }
virtual bool IsEscorted() { return (mEscortState & SMART_ESCORT_ESCORTING); }
virtual bool IsEscorted() { return (mEscortState & SMART_ESCORT_ESCORTING); }
void RemoveEscortState(uint32 uiEscortState) { mEscortState &= ~uiEscortState; }
void SetAutoAttack(bool on) { mCanAutoAttack = on; }
void SetCombatMove(bool on);
bool CanCombatMove() { return mCanCombatMove; }
bool CanCombatMove() { return mCanCombatMove; }
void SetFollow(Unit* target, float dist = 0.0f, float angle = 0.0f, uint32 credit = 0, uint32 end = 0, uint32 creditType = 0, bool aliveState = true);
void StopFollow(bool complete);
@@ -196,16 +196,16 @@ class SmartAI : public CreatureAI
void OnSpellClick(Unit* clicker, bool& result);
// Xinef
void SetWPPauseTimer(uint32 time) { mWPPauseTimer = time; }
void SetForcedCombatMove(float dist);
// Xinef
void SetWPPauseTimer(uint32 time) { mWPPauseTimer = time; }
void SetForcedCombatMove(float dist);
private:
uint32 mFollowCreditType;
uint32 mFollowArrivedTimer;
uint32 mFollowCredit;
uint32 mFollowArrivedEntry;
bool mFollowArrivedAlive;
bool mFollowArrivedAlive;
uint64 mFollowGuid;
float mFollowDist;
float mFollowAngle;
@@ -217,7 +217,7 @@ class SmartAI : public CreatureAI
uint32 mEscortState;
uint32 mCurrentWPID;
bool mWPReached;
bool mOOCReached;
bool mOOCReached;
uint32 mWPPauseTimer;
WayPoint* mLastWP;
uint32 mEscortNPCFlags;
@@ -237,7 +237,7 @@ class SmartAI : public CreatureAI
uint32 mEscortInvokerCheckTimer;
bool mJustReset;
// Xinef: Vehicle conditions
// Xinef: Vehicle conditions
void CheckConditions(const uint32 diff);
ConditionList conditions;
uint32 m_ConditionsTimer;
@@ -266,7 +266,7 @@ class SmartGameObjectAI : public GameObjectAI
void OnGameEvent(bool start, uint16 eventId);
void OnStateChanged(uint32 state, Unit* unit);
void EventInform(uint32 eventId);
void SpellHit(Unit* unit, const SpellInfo* spellInfo);
void SpellHit(Unit* unit, const SpellInfo* spellInfo);
protected:
SmartScript mScript;

File diff suppressed because it is too large Load Diff

View File

@@ -152,11 +152,11 @@ class SmartScript
{
if (reset == 0)
itr->second += value;
else
itr->second = value;
else
itr->second = value;
}
else
mCounterList.insert(std::make_pair(id, value));
else
mCounterList.insert(std::make_pair(id, value));
ProcessEventsFor(SMART_EVENT_COUNTER_SET, NULL, id);
}
@@ -232,42 +232,42 @@ class SmartScript
typedef UNORDERED_MAP<uint32, uint32> CounterMap;
CounterMap mCounterList;
// Xinef: Fix Combat Movement
void SetActualCombatDist(uint32 dist) { mActualCombatDist = dist; }
void RestoreMaxCombatDist() { mActualCombatDist = mMaxCombatDist; }
uint32 GetActualCombatDist() const { return mActualCombatDist; }
uint32 GetMaxCombatDist() const { return mMaxCombatDist; }
// Xinef: Fix Combat Movement
void SetActualCombatDist(uint32 dist) { mActualCombatDist = dist; }
void RestoreMaxCombatDist() { mActualCombatDist = mMaxCombatDist; }
uint32 GetActualCombatDist() const { return mActualCombatDist; }
uint32 GetMaxCombatDist() const { return mMaxCombatDist; }
// Xinef: SmartCasterAI, replace above
void SetCasterActualDist(float dist) { smartCasterActualDist = dist; }
void RestoreCasterMaxDist() { smartCasterActualDist = smartCasterMaxDist; }
Powers GetCasterPowerType() const { return smartCasterPowerType; }
float GetCasterActualDist() const { return smartCasterActualDist; }
float GetCasterMaxDist() const { return smartCasterMaxDist; }
// Xinef: SmartCasterAI, replace above
void SetCasterActualDist(float dist) { smartCasterActualDist = dist; }
void RestoreCasterMaxDist() { smartCasterActualDist = smartCasterMaxDist; }
Powers GetCasterPowerType() const { return smartCasterPowerType; }
float GetCasterActualDist() const { return smartCasterActualDist; }
float GetCasterMaxDist() const { return smartCasterMaxDist; }
bool AllowPhaseReset() const { return _allowPhaseReset; }
void SetPhaseReset(bool allow) { _allowPhaseReset = allow; }
bool AllowPhaseReset() const { return _allowPhaseReset; }
void SetPhaseReset(bool allow) { _allowPhaseReset = allow; }
private:
void IncPhase(uint32 p)
{
// Xinef: protect phase from overflowing
mEventPhase = std::min<uint32>(SMART_EVENT_PHASE_12, mEventPhase + p);
}
{
// Xinef: protect phase from overflowing
mEventPhase = std::min<uint32>(SMART_EVENT_PHASE_12, mEventPhase + p);
}
void DecPhase(uint32 p)
{
if (p >= mEventPhase)
mEventPhase = 0;
else
mEventPhase -= p;
}
{
if (p >= mEventPhase)
mEventPhase = 0;
else
mEventPhase -= p;
}
bool IsInPhase(uint32 p) const
{
if (mEventPhase == 0)
return false;
return (1 << (mEventPhase - 1)) & p;
}
{
if (mEventPhase == 0)
return false;
return (1 << (mEventPhase - 1)) & p;
}
void SetPhase(uint32 p = 0) { mEventPhase = p; }
SmartAIEventList mEvents;
@@ -292,17 +292,17 @@ class SmartScript
uint32 mTalkerEntry;
bool mUseTextTimer;
// Xinef: Fix Combat Movement
uint32 mActualCombatDist;
uint32 mMaxCombatDist;
// Xinef: Fix Combat Movement
uint32 mActualCombatDist;
uint32 mMaxCombatDist;
// Xinef: SmartCasterAI, replace above in future
uint32 smartCasterActualDist;
uint32 smartCasterMaxDist;
Powers smartCasterPowerType;
// Xinef: SmartCasterAI, replace above in future
uint32 smartCasterActualDist;
uint32 smartCasterMaxDist;
Powers smartCasterPowerType;
// Xinef: misc
bool _allowPhaseReset;
// Xinef: misc
bool _allowPhaseReset;
SMARTAI_TEMPLATE mTemplate;
void InstallEvents();

View File

@@ -241,19 +241,19 @@ void SmartAIMgr::LoadSmartAIFromDB()
break;
case SMART_EVENT_VICTIM_CASTING:
case SMART_EVENT_IS_BEHIND_TARGET:
if (temp.event.minMaxRepeat.min == 0 && temp.event.minMaxRepeat.max == 0)
if (temp.event.minMaxRepeat.min == 0 && temp.event.minMaxRepeat.max == 0)
temp.event.event_flags |= SMART_EVENT_FLAG_NOT_REPEATABLE;
break;
case SMART_EVENT_FRIENDLY_IS_CC:
if (temp.event.friendlyCC.repeatMin == 0 && temp.event.friendlyCC.repeatMax == 0)
if (temp.event.friendlyCC.repeatMin == 0 && temp.event.friendlyCC.repeatMax == 0)
temp.event.event_flags |= SMART_EVENT_FLAG_NOT_REPEATABLE;
break;
}
// xinef: rozpierdol tc, niedojeby ze szok
if (temp.action.type == SMART_ACTION_MOVE_TO_POS)
if (temp.target.type == SMART_TARGET_SELF && (fabs(temp.target.x) > 200.0f || fabs(temp.target.y) > 200.0f || fabs(temp.target.z) > 200.0f))
temp.target.type = SMART_TARGET_POSITION;
// xinef: rozpierdol tc, niedojeby ze szok
if (temp.action.type == SMART_ACTION_MOVE_TO_POS)
if (temp.target.type == SMART_TARGET_SELF && (fabs(temp.target.x) > 200.0f || fabs(temp.target.y) > 200.0f || fabs(temp.target.z) > 200.0f))
temp.target.type = SMART_TARGET_POSITION;
// creature entry / guid not found in storage, create empty event list for it and increase counters
if (mEventMap[source_type].find(temp.entryOrGuid) == mEventMap[source_type].end())
@@ -338,7 +338,7 @@ bool SmartAIMgr::IsTargetValid(SmartScriptHolder const& e)
case SMART_TARGET_CLOSEST_ENEMY:
case SMART_TARGET_CLOSEST_FRIENDLY:
case SMART_TARGET_STORED:
case SMART_TARGET_FARTHEST:
case SMART_TARGET_FARTHEST:
break;
default:
sLog->outErrorDb("SmartAIMgr: Not handled target_type(%u), Entry %d SourceType %u Event %u Action %u, skipped.", e.GetTargetType(), e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
@@ -671,7 +671,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
}
break;
case SMART_EVENT_GO_STATE_CHANGED:
case SMART_EVENT_GO_EVENT_INFORM:
case SMART_EVENT_GO_EVENT_INFORM:
case SMART_EVENT_TIMED_EVENT_TRIGGERED:
case SMART_EVENT_INSTANCE_PLAYER_ENTER:
case SMART_EVENT_TRANSPORT_RELOCATE:
@@ -702,7 +702,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
case SMART_EVENT_GOSSIP_HELLO:
case SMART_EVENT_JUST_CREATED:
case SMART_EVENT_FOLLOW_COMPLETED:
case SMART_EVENT_ON_SPELLCLICK:
case SMART_EVENT_ON_SPELLCLICK:
break;
default:
sLog->outErrorDb("SmartAIMgr: Not handled event_type(%u), Entry %d SourceType %u Event %u Action %u, skipped.", e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
@@ -847,7 +847,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u attempts to set invalid phase, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
return false;
}
if (e.action.randomPhase.phase1 == 0 &&
if (e.action.randomPhase.phase1 == 0 &&
e.action.randomPhase.phase2 == 0 &&
e.action.randomPhase.phase3 == 0 &&
e.action.randomPhase.phase4 == 0 &&
@@ -970,13 +970,13 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
case SMART_ACTION_REMOVE_POWER:
if (e.action.power.powerType > MAX_POWERS)
{
sLog->outError("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Power %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.power.powerType);
sLog->outError("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Power %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.power.powerType);
return false;
}
break;
case SMART_ACTION_GAME_EVENT_STOP:
{
return false;
return false;
uint32 eventId = e.action.gameEventStop.id;
GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
@@ -996,7 +996,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
}
case SMART_ACTION_GAME_EVENT_START:
{
return false;
return false;
uint32 eventId = e.action.gameEventStart.id;
GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
@@ -1033,15 +1033,15 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
}
break;
}
case SMART_ACTION_LOAD_GRID:
{
if (!Trinity::IsValidMapCoord(e.target.x, e.target.y))
{
sLog->outError("SmartScript: SMART_ACTION_LOAD_GRID uses invalid map coords: %u, skipped.", e.entryOrGuid);
return false;
}
break;
}
case SMART_ACTION_LOAD_GRID:
{
if (!Trinity::IsValidMapCoord(e.target.x, e.target.y))
{
sLog->outError("SmartScript: SMART_ACTION_LOAD_GRID uses invalid map coords: %u, skipped.", e.entryOrGuid);
return false;
}
break;
}
case SMART_ACTION_START_CLOSEST_WAYPOINT:
case SMART_ACTION_FOLLOW:
case SMART_ACTION_SET_ORIENTATION:
@@ -1105,35 +1105,35 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
case SMART_ACTION_SEND_GOSSIP_MENU:
case SMART_ACTION_GO_SET_LOOT_STATE:
case SMART_ACTION_SEND_TARGET_TO_TARGET:
case SMART_ACTION_SET_HOME_POS:
case SMART_ACTION_SET_HOME_POS:
case SMART_ACTION_SET_HEALTH_REGEN:
case SMART_ACTION_SET_ROOT:
case SMART_ACTION_SET_GO_FLAG:
case SMART_ACTION_ADD_GO_FLAG:
case SMART_ACTION_REMOVE_GO_FLAG:
case SMART_ACTION_SUMMON_CREATURE_GROUP:
case SMART_ACTION_RISE_UP:
case SMART_ACTION_RISE_UP:
case SMART_ACTION_MOVE_TO_POS_TARGET:
case SMART_ACTION_SET_GO_STATE:
case SMART_ACTION_EXIT_VEHICLE:
case SMART_ACTION_SET_UNIT_MOVEMENT_FLAGS:
case SMART_ACTION_SET_COMBAT_DISTANCE:
case SMART_ACTION_SET_CASTER_COMBAT_DIST:
case SMART_ACTION_SET_SIGHT_DIST:
case SMART_ACTION_FLEE:
case SMART_ACTION_ADD_THREAT:
case SMART_ACTION_LOAD_EQUIPMENT:
case SMART_ACTION_TRIGGER_RANDOM_TIMED_EVENT:
case SMART_ACTION_SET_HOVER:
case SMART_ACTION_ADD_IMMUNITY:
case SMART_ACTION_REMOVE_IMMUNITY:
case SMART_ACTION_SET_COUNTER:
case SMART_ACTION_FALL:
case SMART_ACTION_SET_EVENT_FLAG_RESET:
case SMART_ACTION_REMOVE_ALL_GAMEOBJECTS:
case SMART_ACTION_STOP_MOTION:
case SMART_ACTION_NO_ENVIRONMENT_UPDATE:
case SMART_ACTION_ZONE_UNDER_ATTACK:
case SMART_ACTION_SET_GO_STATE:
case SMART_ACTION_EXIT_VEHICLE:
case SMART_ACTION_SET_UNIT_MOVEMENT_FLAGS:
case SMART_ACTION_SET_COMBAT_DISTANCE:
case SMART_ACTION_SET_CASTER_COMBAT_DIST:
case SMART_ACTION_SET_SIGHT_DIST:
case SMART_ACTION_FLEE:
case SMART_ACTION_ADD_THREAT:
case SMART_ACTION_LOAD_EQUIPMENT:
case SMART_ACTION_TRIGGER_RANDOM_TIMED_EVENT:
case SMART_ACTION_SET_HOVER:
case SMART_ACTION_ADD_IMMUNITY:
case SMART_ACTION_REMOVE_IMMUNITY:
case SMART_ACTION_SET_COUNTER:
case SMART_ACTION_FALL:
case SMART_ACTION_SET_EVENT_FLAG_RESET:
case SMART_ACTION_REMOVE_ALL_GAMEOBJECTS:
case SMART_ACTION_STOP_MOTION:
case SMART_ACTION_NO_ENVIRONMENT_UPDATE:
case SMART_ACTION_ZONE_UNDER_ATTACK:
break;
default:
sLog->outErrorDb("SmartAIMgr: Not handled action_type(%u), event_type(%u), Entry %d SourceType %u Event %u, skipped.", e.GetActionType(), e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id);

View File

@@ -57,7 +57,7 @@ enum SMART_EVENT_PHASE
SMART_EVENT_PHASE_9 = 9,
SMART_EVENT_PHASE_10 = 10,
SMART_EVENT_PHASE_11 = 11,
SMART_EVENT_PHASE_12 = 12,
SMART_EVENT_PHASE_12 = 12,
SMART_EVENT_PHASE_MAX = 13,
SMART_EVENT_PHASE_COUNT = 12
@@ -390,7 +390,7 @@ struct SmartEvent
uint32 eventId;
} eventInform;
struct
struct
{
uint32 eventId;
} doAction;
@@ -554,43 +554,43 @@ enum SMART_ACTION
SMART_ACTION_GAME_EVENT_START = 112, // GameEventId
SMART_ACTION_START_CLOSEST_WAYPOINT = 113, // wp1, wp2, wp3, wp4, wp5, wp6, wp7
SMART_ACTION_RISE_UP = 114, // distance
// RESERVED = 115,
// RESERVED = 116,
// RESERVED = 117,
// RESERVED = 118,
// RESERVED = 119,
// RESERVED = 120,
// RESERVED = 121,
// RESERVED = 122,
// RESERVED = 123,
// RESERVED = 124,
// RESERVED = 125,
// RESERVED = 126,
// RESERVED = 127,
// RESERVED = 128,
// RESERVED = 129,
// 113!
SMART_ACTION_MOVE_TO_POS_TARGET = 130, // pointId
SMART_ACTION_SET_GO_STATE = 131, // state
SMART_ACTION_EXIT_VEHICLE = 132, // none
SMART_ACTION_SET_UNIT_MOVEMENT_FLAGS = 133, // flags
SMART_ACTION_SET_COMBAT_DISTANCE = 134, // combatDistance
SMART_ACTION_SET_CASTER_COMBAT_DIST = 135, // followDistance, resetToMax
SMART_ACTION_SET_SIGHT_DIST = 136, // sightDistance
SMART_ACTION_FLEE = 137, // fleeTime
SMART_ACTION_ADD_THREAT = 138, // +threat, -threat
SMART_ACTION_LOAD_EQUIPMENT = 139, // id
SMART_ACTION_TRIGGER_RANDOM_TIMED_EVENT = 140, // id min range, id max range
SMART_ACTION_SET_HOVER = 141, // 0/1
SMART_ACTION_ADD_IMMUNITY = 142, // type, id, value
SMART_ACTION_REMOVE_IMMUNITY = 143, // type, id, value
SMART_ACTION_FALL = 144, //
SMART_ACTION_SET_EVENT_FLAG_RESET = 145, // 0/1
SMART_ACTION_REMOVE_ALL_GAMEOBJECTS = 146,
SMART_ACTION_STOP_MOTION = 147, // stopMoving, movementExpired
SMART_ACTION_NO_ENVIRONMENT_UPDATE = 148,
SMART_ACTION_ZONE_UNDER_ATTACK = 149,
SMART_ACTION_LOAD_GRID = 150,
// RESERVED = 115,
// RESERVED = 116,
// RESERVED = 117,
// RESERVED = 118,
// RESERVED = 119,
// RESERVED = 120,
// RESERVED = 121,
// RESERVED = 122,
// RESERVED = 123,
// RESERVED = 124,
// RESERVED = 125,
// RESERVED = 126,
// RESERVED = 127,
// RESERVED = 128,
// RESERVED = 129,
// 113!
SMART_ACTION_MOVE_TO_POS_TARGET = 130, // pointId
SMART_ACTION_SET_GO_STATE = 131, // state
SMART_ACTION_EXIT_VEHICLE = 132, // none
SMART_ACTION_SET_UNIT_MOVEMENT_FLAGS = 133, // flags
SMART_ACTION_SET_COMBAT_DISTANCE = 134, // combatDistance
SMART_ACTION_SET_CASTER_COMBAT_DIST = 135, // followDistance, resetToMax
SMART_ACTION_SET_SIGHT_DIST = 136, // sightDistance
SMART_ACTION_FLEE = 137, // fleeTime
SMART_ACTION_ADD_THREAT = 138, // +threat, -threat
SMART_ACTION_LOAD_EQUIPMENT = 139, // id
SMART_ACTION_TRIGGER_RANDOM_TIMED_EVENT = 140, // id min range, id max range
SMART_ACTION_SET_HOVER = 141, // 0/1
SMART_ACTION_ADD_IMMUNITY = 142, // type, id, value
SMART_ACTION_REMOVE_IMMUNITY = 143, // type, id, value
SMART_ACTION_FALL = 144, //
SMART_ACTION_SET_EVENT_FLAG_RESET = 145, // 0/1
SMART_ACTION_REMOVE_ALL_GAMEOBJECTS = 146,
SMART_ACTION_STOP_MOTION = 147, // stopMoving, movementExpired
SMART_ACTION_NO_ENVIRONMENT_UPDATE = 148,
SMART_ACTION_ZONE_UNDER_ATTACK = 149,
SMART_ACTION_LOAD_GRID = 150,
SMART_ACTION_END = 151, // ZOMG!, zmienic w sql
};
@@ -605,7 +605,7 @@ struct SmartAction
{
uint32 textGroupID;
uint32 duration;
uint32 useTalkTarget;
uint32 useTalkTarget;
} talk;
struct
@@ -668,10 +668,10 @@ struct SmartAction
uint32 targetParam3;
} crossCast;
struct
{
uint32 alternative;
} activateObject;
struct
{
uint32 alternative;
} activateObject;
struct
{
@@ -679,7 +679,7 @@ struct SmartAction
uint32 type;
uint32 duration;
uint32 attackInvoker;
uint32 attackScriptOwner;
uint32 attackScriptOwner;
} summonCreature;
struct
@@ -742,7 +742,7 @@ struct SmartAction
uint32 entry;
uint32 credit;
uint32 creditType;
uint32 aliveState;
uint32 aliveState;
} follow;
struct
@@ -781,7 +781,7 @@ struct SmartAction
{
uint32 creature;
uint32 team;
uint32 doNotChangeLevel;
uint32 doNotChangeLevel;
} updateTemplate;
struct
@@ -836,7 +836,7 @@ struct SmartAction
{
uint32 entry;
uint32 despawnTime;
uint32 targetsummon;
uint32 targetsummon;
} summonGO;
struct
@@ -890,8 +890,8 @@ struct SmartAction
struct
{
uint32 fly;
uint32 speed;
uint32 disableGravity;
uint32 speed;
uint32 disableGravity;
} setFly;
struct
@@ -995,13 +995,13 @@ struct SmartAction
{
uint32 speedxy;
uint32 speedz;
uint32 selfJump;
uint32 selfJump;
} jump;
struct
{
uint32 flag;
} movementFlag;
struct
{
uint32 flag;
} movementFlag;
struct
{
@@ -1017,7 +1017,7 @@ struct SmartAction
{
uint32 pointId;
uint32 transport;
uint32 controlled;
uint32 controlled;
} MoveToPos;
struct
@@ -1057,16 +1057,16 @@ struct SmartAction
uint32 flag;
} goFlag;
struct
{
uint32 state;
} goState;
struct
{
uint32 state;
} goState;
struct
{
uint32 group;
uint32 attackInvoker;
uint32 attackScriptOwner;
uint32 attackScriptOwner;
} creatureGroup;
struct
@@ -1095,61 +1095,61 @@ struct SmartAction
uint32 wp6;
} closestWaypointFromList;
struct
{
uint32 dist;
} combatDistance;
struct
{
uint32 dist;
} combatDistance;
struct
{
uint32 dist;
} sightDistance;
struct
{
uint32 dist;
} sightDistance;
struct
{
uint32 dist;
uint32 reset;
} casterDistance;
struct
{
uint32 dist;
uint32 reset;
} casterDistance;
struct
{
uint32 spawnPos;
} setHomePos;
struct
{
uint32 spawnPos;
} setHomePos;
struct
{
uint32 id;
uint32 force;
} loadEquipment;
struct
{
uint32 id;
uint32 force;
} loadEquipment;
struct
{
uint32 minId;
uint32 maxId;
} randomTimedEvent;
struct
{
uint32 minId;
uint32 maxId;
} randomTimedEvent;
struct
{
uint32 state;
} setHover;
struct
{
uint32 state;
} setHover;
struct
{
uint32 type;
uint32 id;
uint32 value;
} immunity;
struct
{
uint32 type;
uint32 id;
uint32 value;
} immunity;
struct
{
uint32 quickChange;
} orientation;
struct
{
uint32 quickChange;
} orientation;
struct
{
uint32 stopMovement;
uint32 movementExpired;
} stopMotion;
struct
{
uint32 stopMovement;
uint32 movementExpired;
} stopMotion;
//! Note for any new future actions
//! All parameters must have type uint32
@@ -1206,20 +1206,20 @@ enum SMARTAI_TARGETS
SMART_TARGET_THREAT_LIST = 24, // All units on creature's threat list, maxdist, playerOnly
SMART_TARGET_CLOSEST_ENEMY = 25, // maxDist, playerOnly
SMART_TARGET_CLOSEST_FRIENDLY = 26, // maxDist, playerOnly
// RESERVED = 27,
// RESERVED = 28,
// RESERVED = 29,
// RESERVED = 30,
// RESERVED = 31,
// RESERVED = 32,
// RESERVED = 33,
// RESERVED = 34,
// RESERVED = 35,
// RESERVED = 36,
// RESERVED = 37,
// RESERVED = 38,
// RESERVED = 39,
SMART_TARGET_FARTHEST = 40,
// RESERVED = 27,
// RESERVED = 28,
// RESERVED = 29,
// RESERVED = 30,
// RESERVED = 31,
// RESERVED = 32,
// RESERVED = 33,
// RESERVED = 34,
// RESERVED = 35,
// RESERVED = 36,
// RESERVED = 37,
// RESERVED = 38,
// RESERVED = 39,
SMART_TARGET_FARTHEST = 40,
SMART_TARGET_END = 41
};
@@ -1232,7 +1232,7 @@ struct SmartTarget
raw.param1 = p1;
raw.param2 = p2;
raw.param3 = p3;
raw.param4 = p4;
raw.param4 = p4;
x = 0.0f;
y = 0.0f;
z = 0.0f;
@@ -1242,19 +1242,19 @@ struct SmartTarget
float x, y, z, o;
union
{
// Xinef: allow random selectors to limit distance
struct
// Xinef: allow random selectors to limit distance
struct
{
uint32 maxDist;
uint32 playerOnly;
uint32 powerType;
uint32 playerOnly;
uint32 powerType;
} hostilRandom;
struct
struct
{
uint32 maxDist;
uint32 playerOnly;
uint32 isInLos;
uint32 playerOnly;
uint32 isInLos;
} farthest;
struct
@@ -1262,21 +1262,21 @@ struct SmartTarget
uint32 creature;
uint32 minDist;
uint32 maxDist;
uint32 livingState;
uint32 livingState;
} unitRange;
struct
{
uint32 dbGuid;
uint32 entry;
uint32 getFromHashMap; // Does not work in instances
uint32 getFromHashMap; // Does not work in instances
} unitGUID;
struct
{
uint32 creature;
uint32 dist;
uint32 livingState;
uint32 livingState;
} unitDistance;
struct
@@ -1307,7 +1307,7 @@ struct SmartTarget
{
uint32 dbGuid;
uint32 entry;
uint32 getFromHashMap; // Does not work in instances
uint32 getFromHashMap; // Does not work in instances
} goGUID;
struct
@@ -1321,10 +1321,10 @@ struct SmartTarget
uint32 map;
} position;
struct
{
uint32 useCharmerOrOwner;
} owner;
struct
{
uint32 useCharmerOrOwner;
} owner;
struct
{
@@ -1350,7 +1350,7 @@ struct SmartTarget
uint32 param1;
uint32 param2;
uint32 param3;
uint32 param4;
uint32 param4;
} raw;
};
};
@@ -1476,7 +1476,7 @@ const uint32 SmartAIEventMask[SMART_EVENT_END][2] =
{SMART_EVENT_JUST_CREATED, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
{SMART_EVENT_GOSSIP_HELLO, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
{SMART_EVENT_FOLLOW_COMPLETED, SMART_SCRIPT_TYPE_MASK_CREATURE },
{SMART_EVENT_UNUSED_66, 0},
{SMART_EVENT_UNUSED_66, 0},
{SMART_EVENT_IS_BEHIND_TARGET, SMART_SCRIPT_TYPE_MASK_CREATURE },
{SMART_EVENT_GAME_EVENT_START, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
{SMART_EVENT_GAME_EVENT_END, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },