*Merge.
--HG-- branch : trunk
This commit is contained in:
@@ -1128,9 +1128,7 @@ void BattleGround::AddPlayer(Player *plr)
|
||||
|
||||
if(GetStatus() == STATUS_WAIT_JOIN) // not started yet
|
||||
{
|
||||
if(GetStatus() == STATUS_IN_PROGRESS)
|
||||
plr->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION);
|
||||
else plr->CastSpell(plr, SPELL_ARENA_PREPARATION, true);
|
||||
plr->CastSpell(plr, SPELL_ARENA_PREPARATION, true);
|
||||
|
||||
plr->SetHealth(plr->GetMaxHealth());
|
||||
plr->SetPower(POWER_MANA, plr->GetMaxPower(POWER_MANA));
|
||||
|
||||
@@ -71,7 +71,7 @@ enum BattleGroundSpells
|
||||
SPELL_SPIRIT_HEAL_CHANNEL = 22011, // Spirit Heal Channel
|
||||
SPELL_SPIRIT_HEAL = 22012, // Spirit Heal
|
||||
SPELL_RESURRECTION_VISUAL = 24171, // Resurrection Impact Visual
|
||||
SPELL_ARENA_PREPARATION = 32728, // use this one, 32727 has an invisibility aura which is wrong
|
||||
SPELL_ARENA_PREPARATION = 32727, // use this one, 32728 not correct
|
||||
SPELL_ALLIANCE_GOLD_FLAG = 32724,
|
||||
SPELL_ALLIANCE_GREEN_FLAG = 32725,
|
||||
SPELL_HORDE_GOLD_FLAG = 35774,
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#include "CellImpl.h"
|
||||
#include "OutdoorPvPMgr.h"
|
||||
#include "GameEventMgr.h"
|
||||
#include "PossessedAI.h"
|
||||
#include "CreatureGroups.h"
|
||||
// apply implementation of the singletons
|
||||
#include "Policies/SingletonImp.h"
|
||||
@@ -133,7 +132,7 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
}
|
||||
|
||||
Creature::Creature() :
|
||||
Unit(), i_AI(NULL),
|
||||
Unit(),
|
||||
lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0),
|
||||
m_lootMoney(0), m_lootRecipient(0),
|
||||
m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f),
|
||||
@@ -414,7 +413,7 @@ void Creature::Update(uint32 diff)
|
||||
setDeathState( JUST_ALIVED );
|
||||
|
||||
//Call AI respawn virtual function
|
||||
i_AI->JustRespawned();
|
||||
AI()->JustRespawned();
|
||||
|
||||
uint16 poolid = poolhandler.IsPartOfAPool(GetGUIDLow(), GetTypeId());
|
||||
if (poolid)
|
||||
@@ -478,6 +477,9 @@ void Creature::Update(uint32 diff)
|
||||
if(!isAlive())
|
||||
break;
|
||||
|
||||
// if creature is charmed, switch to charmed AI
|
||||
UpdateCharmAI();
|
||||
|
||||
if(!IsInEvadeMode() && IsAIEnabled)
|
||||
{
|
||||
// do not allow the AI to be changed during update
|
||||
@@ -590,11 +592,9 @@ bool Creature::AIM_Initialize(CreatureAI* ai)
|
||||
return false;
|
||||
}
|
||||
|
||||
CreatureAI * oldAI = i_AI;
|
||||
i_motionMaster.Initialize();
|
||||
if(i_AI) delete i_AI;
|
||||
i_AI = ai ? ai : FactorySelector::selectAI(this);
|
||||
if (oldAI)
|
||||
delete oldAI;
|
||||
i_motionMaster.Initialize();
|
||||
IsAIEnabled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-3
@@ -416,8 +416,6 @@ typedef std::map<uint32,time_t> CreatureSpellCooldowns;
|
||||
|
||||
class TRINITY_DLL_SPEC Creature : public Unit
|
||||
{
|
||||
CreatureAI *i_AI;
|
||||
|
||||
public:
|
||||
|
||||
explicit Creature();
|
||||
@@ -484,7 +482,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
|
||||
bool AIM_Initialize(CreatureAI* ai = NULL);
|
||||
|
||||
void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type);
|
||||
CreatureAI* AI() { return i_AI; }
|
||||
CreatureAI* AI() { return (CreatureAI*)i_AI; }
|
||||
|
||||
uint32 GetShieldBlockValue() const //dunno mob block value
|
||||
{
|
||||
|
||||
+24
-1
@@ -36,11 +36,34 @@ void UnitAI::AttackStart(Unit *victim)
|
||||
}
|
||||
}
|
||||
|
||||
void UnitAI::DoMeleeAttackIfReady()
|
||||
{
|
||||
//Make sure our attack is ready and we aren't currently casting before checking distance
|
||||
if (me->isAttackReady() && !me->hasUnitState(UNIT_STAT_CASTING))
|
||||
{
|
||||
//If we are within range melee the target
|
||||
if (me->IsWithinMeleeRange(me->getVictim()))
|
||||
{
|
||||
me->AttackerStateUpdate(me->getVictim());
|
||||
me->resetAttackTimer();
|
||||
}
|
||||
}
|
||||
if (me->haveOffhandWeapon() && me->isAttackReady(OFF_ATTACK) && !me->hasUnitState(UNIT_STAT_CASTING))
|
||||
{
|
||||
//If we are within range melee the target
|
||||
if (me->IsWithinMeleeRange(me->getVictim()))
|
||||
{
|
||||
me->AttackerStateUpdate(me->getVictim(), OFF_ATTACK);
|
||||
me->resetAttackTimer(OFF_ATTACK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Enable PlayerAI when charmed
|
||||
void PlayerAI::OnCharmed(bool apply) { me->IsAIEnabled = apply; }
|
||||
|
||||
//Disable CreatureAI when charmed
|
||||
void CreatureAI::OnCharmed(bool apply) { me->IsAIEnabled = !apply; }
|
||||
void CreatureAI::OnCharmed(bool apply) { /*me->IsAIEnabled = !apply;*/ }
|
||||
|
||||
void CreatureAI::MoveInLineOfSight(Unit *who)
|
||||
{
|
||||
|
||||
@@ -81,6 +81,9 @@ class TRINITY_DLL_SPEC UnitAI
|
||||
|
||||
// Called when unit is charmed
|
||||
virtual void OnCharmed(bool apply) = 0;
|
||||
|
||||
//Do melee swing of current victim if in rnage and ready and not casting
|
||||
void DoMeleeAttackIfReady();
|
||||
};
|
||||
|
||||
class TRINITY_DLL_SPEC PlayerAI : public UnitAI
|
||||
|
||||
@@ -175,7 +175,18 @@ inline void Trinity::DynamicObjectUpdater::VisitHelper(Unit* target)
|
||||
if( target->GetTypeId()==TYPEID_PLAYER && target != i_check && (((Player*)target)->isGameMaster() || ((Player*)target)->GetVisibility()==VISIBILITY_OFF) )
|
||||
return;
|
||||
|
||||
if (i_check->GetTypeId()==TYPEID_PLAYER )
|
||||
if (i_dynobject.IsAffecting(target))
|
||||
return;
|
||||
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(i_dynobject.GetSpellId());
|
||||
uint32 eff_index = i_dynobject.GetEffIndex();
|
||||
if(spellInfo->EffectImplicitTargetB[eff_index] == TARGET_UNIT_AREA_ALLY_CHANNEL
|
||||
|| spellInfo->EffectImplicitTargetB[eff_index] == TARGET_UNIT_AREA_ALLY_GROUND)
|
||||
{
|
||||
if(!i_check->IsFriendlyTo(target))
|
||||
return;
|
||||
}
|
||||
else if( i_check->GetTypeId()==TYPEID_PLAYER )
|
||||
{
|
||||
if (i_check->IsFriendlyTo( target ))
|
||||
return;
|
||||
@@ -186,11 +197,6 @@ inline void Trinity::DynamicObjectUpdater::VisitHelper(Unit* target)
|
||||
return;
|
||||
}
|
||||
|
||||
if (i_dynobject.IsAffecting(target))
|
||||
return;
|
||||
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(i_dynobject.GetSpellId());
|
||||
uint32 eff_index = i_dynobject.GetEffIndex();
|
||||
// Check target immune to spell or aura
|
||||
if (target->IsImmunedToSpell(spellInfo) || target->IsImmunedToSpellEffect(spellInfo, eff_index))
|
||||
return;
|
||||
|
||||
+27
-22
@@ -696,6 +696,33 @@ void Map::Update(const uint32 &t_diff)
|
||||
if(!obj->IsInWorld())
|
||||
continue;
|
||||
|
||||
// Update bindsight players
|
||||
/*if(obj->isType(TYPEMASK_UNIT))
|
||||
{
|
||||
if(!((Unit*)obj)->GetSharedVisionList().empty())
|
||||
for(SharedVisionList::const_iterator itr = ((Unit*)obj)->GetSharedVisionList().begin(); itr != ((Unit*)obj)->GetSharedVisionList().end(); ++itr)
|
||||
{
|
||||
if(!*itr)
|
||||
{
|
||||
sLog.outError("unit %u has invalid shared vision player, list size %u", obj->GetEntry(), ((Unit*)obj)->GetSharedVisionList().size());
|
||||
continue;
|
||||
}
|
||||
Trinity::PlayerVisibilityNotifier notifier(**itr);
|
||||
VisitAll(obj->GetPositionX(), obj->GetPositionY(), World::GetMaxVisibleDistance(), notifier);
|
||||
notifier.Notify();
|
||||
}
|
||||
}
|
||||
else */if(obj->GetTypeId() == TYPEID_DYNAMICOBJECT)
|
||||
{
|
||||
if(Unit *caster = ((DynamicObject*)obj)->GetCaster())
|
||||
if(caster->GetTypeId() == TYPEID_PLAYER && caster->GetUInt64Value(PLAYER_FARSIGHT) == obj->GetGUID())
|
||||
{
|
||||
Trinity::PlayerVisibilityNotifier notifier(*((Player*)caster));
|
||||
VisitAll(obj->GetPositionX(), obj->GetPositionY(), World::GetMaxVisibleDistance(), notifier);
|
||||
notifier.Notify();
|
||||
}
|
||||
}
|
||||
|
||||
CellPair standing_cell(Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()));
|
||||
|
||||
// Check for correctness of standing_cell, it also avoids problems with update_cell
|
||||
@@ -728,28 +755,6 @@ void Map::Update(const uint32 &t_diff)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update bindsight players
|
||||
if(obj->isType(TYPEMASK_UNIT))
|
||||
{
|
||||
if(!((Unit*)obj)->GetSharedVisionList().empty())
|
||||
for(SharedVisionList::const_iterator itr = ((Unit*)obj)->GetSharedVisionList().begin(); itr != ((Unit*)obj)->GetSharedVisionList().end(); ++itr)
|
||||
{
|
||||
Trinity::PlayerVisibilityNotifier notifier(**itr);
|
||||
VisitAll(obj->GetPositionX(), obj->GetPositionY(), World::GetMaxVisibleDistance(), notifier);
|
||||
notifier.Notify();
|
||||
}
|
||||
}
|
||||
else if(obj->GetTypeId() == TYPEID_DYNAMICOBJECT)
|
||||
{
|
||||
if(Unit *caster = ((DynamicObject*)obj)->GetCaster())
|
||||
if(caster->GetTypeId() == TYPEID_PLAYER && caster->GetUInt64Value(PLAYER_FARSIGHT) == obj->GetGUID())
|
||||
{
|
||||
Trinity::PlayerVisibilityNotifier notifier(*((Player*)caster));
|
||||
VisitAll(obj->GetPositionX(), obj->GetPositionY(), World::GetMaxVisibleDistance(), notifier);
|
||||
notifier.Notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,30 @@ void PassiveAI::UpdateAI(const uint32)
|
||||
EnterEvadeMode();
|
||||
}
|
||||
|
||||
void PossessedAI::UpdateAI(const uint32 diff)
|
||||
{
|
||||
if(me->getVictim())
|
||||
{
|
||||
if(!me->canAttack(me->getVictim()))
|
||||
me->AttackStop();
|
||||
else
|
||||
DoMeleeAttackIfReady();
|
||||
}
|
||||
}
|
||||
|
||||
void PossessedAI::JustDied(Unit *u)
|
||||
{
|
||||
// We died while possessed, disable our loot
|
||||
me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
|
||||
}
|
||||
|
||||
void PossessedAI::KilledUnit(Unit* victim)
|
||||
{
|
||||
// We killed a creature, disable victim's loot
|
||||
if (victim->GetTypeId() == TYPEID_UNIT)
|
||||
victim->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
|
||||
}
|
||||
|
||||
void CritterAI::DamageTaken(Unit *done_by, uint32 &)
|
||||
{
|
||||
if(!me->hasUnitState(UNIT_STAT_FLEEING))
|
||||
@@ -39,4 +63,3 @@ void CritterAI::EnterEvadeMode()
|
||||
me->SetControlled(false, UNIT_STAT_FLEEING);
|
||||
CreatureAI::EnterEvadeMode();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,18 @@ class TRINITY_DLL_DECL PassiveAI : public CreatureAI
|
||||
static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; }
|
||||
};
|
||||
|
||||
class TRINITY_DLL_DECL PossessedAI : public PassiveAI
|
||||
{
|
||||
public:
|
||||
PossessedAI(Creature *c) : PassiveAI(c) {}
|
||||
|
||||
void UpdateAI(const uint32);
|
||||
void EnterEvadeMode() {}
|
||||
|
||||
void JustDied(Unit*);
|
||||
void KilledUnit(Unit* victim);
|
||||
};
|
||||
|
||||
class TRINITY_DLL_DECL NullCreatureAI : public PassiveAI
|
||||
{
|
||||
public:
|
||||
|
||||
+9
-86
@@ -44,44 +44,6 @@ PetAI::PetAI(Creature *c) : CreatureAI(c), i_pet(*c), i_tracker(TIME_INTERVAL_LO
|
||||
UpdateAllies();
|
||||
}
|
||||
|
||||
void PetAI::MoveInLineOfSight(Unit *u)
|
||||
{
|
||||
if( !i_pet.getVictim() && i_pet.GetCharmInfo() &&
|
||||
i_pet.IsHostileTo( u ) && i_pet.canAttack(u) &&
|
||||
u->isInAccessiblePlaceFor(&i_pet))
|
||||
{
|
||||
float attackRadius = i_pet.GetAttackDistance(u);
|
||||
if(i_pet.IsWithinDistInMap(u, attackRadius) && i_pet.GetDistanceZ(u) <= CREATURE_Z_ATTACK_RANGE)
|
||||
{
|
||||
if(i_pet.IsWithinLOSInMap(u))
|
||||
{
|
||||
AttackStart(u);
|
||||
//u->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PetAI::AttackStart(Unit *u)
|
||||
{
|
||||
if( !u || (i_pet.isPet() && ((Pet&)i_pet).getPetType() == MINI_PET) )
|
||||
return;
|
||||
|
||||
if (inCombat && i_pet.getVictim() && u != i_pet.getVictim())
|
||||
i_pet.AttackStop();
|
||||
|
||||
if(i_pet.Attack(u,true))
|
||||
{
|
||||
i_pet.clearUnitState(UNIT_STAT_FOLLOW);
|
||||
// TMGs call CreatureRelocation which via MoveInLineOfSight can call this function
|
||||
// thus with the following clear the original TMG gets invalidated and crash, doh
|
||||
// hope it doesn't start to leak memory without this :-/
|
||||
//i_pet->Clear();
|
||||
i_pet.GetMotionMaster()->MoveChase(u);
|
||||
inCombat = true;
|
||||
}
|
||||
}
|
||||
|
||||
void PetAI::EnterEvadeMode()
|
||||
{
|
||||
}
|
||||
@@ -138,9 +100,6 @@ void PetAI::UpdateAI(const uint32 diff)
|
||||
else
|
||||
m_updateAlliesTimer -= diff;
|
||||
|
||||
if (inCombat && !i_pet.getVictim())
|
||||
_stopAttack();
|
||||
|
||||
// i_pet.getVictim() can't be used for check in case stop fighting, i_pet.getVictim() clear at Unit death etc.
|
||||
if( i_pet.getVictim() )
|
||||
{
|
||||
@@ -150,50 +109,23 @@ void PetAI::UpdateAI(const uint32 diff)
|
||||
_stopAttack();
|
||||
return;
|
||||
}
|
||||
else if( i_pet.IsStopped() || i_pet.IsWithinMeleeRange(i_pet.getVictim()))
|
||||
{
|
||||
// required to be stopped cases
|
||||
if ( i_pet.IsStopped() && i_pet.IsNonMeleeSpellCasted(false) )
|
||||
{
|
||||
if( i_pet.hasUnitState(UNIT_STAT_FOLLOW) )
|
||||
i_pet.InterruptNonMeleeSpells(false);
|
||||
else
|
||||
return;
|
||||
}
|
||||
// not required to be stopped case
|
||||
else if( i_pet.isAttackReady() && i_pet.IsWithinMeleeRange(i_pet.getVictim()) )
|
||||
{
|
||||
i_pet.AttackerStateUpdate(i_pet.getVictim());
|
||||
|
||||
i_pet.resetAttackTimer();
|
||||
|
||||
if ( !i_pet.getVictim() )
|
||||
return;
|
||||
|
||||
//if pet misses its target, it will also be the first in threat list
|
||||
i_pet.getVictim()->AddThreat(&i_pet,0.0f);
|
||||
|
||||
if( _needToStop() )
|
||||
_stopAttack();
|
||||
}
|
||||
}
|
||||
DoMeleeAttackIfReady();
|
||||
}
|
||||
else if(owner && i_pet.GetCharmInfo())
|
||||
else
|
||||
{
|
||||
if(owner->isInCombat() && !(i_pet.HasReactState(REACT_PASSIVE) || i_pet.GetCharmInfo()->HasCommandState(COMMAND_STAY)))
|
||||
if(me->isInCombat())
|
||||
_stopAttack();
|
||||
else if(owner && i_pet.GetCharmInfo()) //no victim
|
||||
{
|
||||
AttackStart(owner->getAttackerForHelper());
|
||||
}
|
||||
else if(i_pet.GetCharmInfo()->HasCommandState(COMMAND_FOLLOW))
|
||||
{
|
||||
if (!i_pet.hasUnitState(UNIT_STAT_FOLLOW) )
|
||||
{
|
||||
if(owner->isInCombat() && !(i_pet.HasReactState(REACT_PASSIVE) || i_pet.GetCharmInfo()->HasCommandState(COMMAND_STAY)))
|
||||
AttackStart(owner->getAttackerForHelper());
|
||||
else if(i_pet.GetCharmInfo()->HasCommandState(COMMAND_FOLLOW) && !i_pet.hasUnitState(UNIT_STAT_FOLLOW))
|
||||
i_pet.GetMotionMaster()->MoveFollow(owner,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i_pet.GetGlobalCooldown() == 0 && !i_pet.IsNonMeleeSpellCasted(false))
|
||||
if (i_pet.GetGlobalCooldown() == 0 && !i_pet.hasUnitState(UNIT_STAT_CASTING))
|
||||
{
|
||||
//Autocast
|
||||
for (uint8 i = 0; i < i_pet.GetPetAutoSpellSize(); i++)
|
||||
@@ -323,12 +255,3 @@ void PetAI::UpdateAllies()
|
||||
else //remove group
|
||||
m_AllySet.insert(owner->GetGUID());
|
||||
}
|
||||
|
||||
/*void PetAI::AttackedBy(Unit *attacker)
|
||||
{
|
||||
//when attacked, fight back in case 1)no victim already AND 2)not set to passive AND 3)not set to stay, unless can it can reach attacker with melee attack anyway
|
||||
if(!i_pet.getVictim() && i_pet.GetCharmInfo() && !i_pet.GetCharmInfo()->HasReactState(REACT_PASSIVE) &&
|
||||
(!i_pet.GetCharmInfo()->HasCommandState(COMMAND_STAY) || i_pet.IsWithinMeleeRange(attacker)))
|
||||
AttackStart(attacker);
|
||||
}*/
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@ class TRINITY_DLL_DECL PetAI : public CreatureAI
|
||||
|
||||
PetAI(Creature *c);
|
||||
|
||||
void MoveInLineOfSight(Unit *);
|
||||
void AttackStart(Unit *);
|
||||
void EnterEvadeMode();
|
||||
void JustDied(Unit* who) { _stopAttack(); }
|
||||
|
||||
|
||||
@@ -82,13 +82,15 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
|
||||
switch(spellid)
|
||||
{
|
||||
case COMMAND_STAY: //flat=1792 //STAY
|
||||
pet->AttackStop();
|
||||
pet->InterruptNonMeleeSpells(false);
|
||||
pet->StopMoving();
|
||||
pet->GetMotionMaster()->Clear();
|
||||
pet->GetMotionMaster()->MoveIdle();
|
||||
charmInfo->SetCommandState( COMMAND_STAY );
|
||||
break;
|
||||
case COMMAND_FOLLOW: //spellid=1792 //FOLLOW
|
||||
pet->AttackStop();
|
||||
pet->InterruptNonMeleeSpells(false);
|
||||
pet->GetMotionMaster()->MoveFollow(_player,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE);
|
||||
charmInfo->SetCommandState( COMMAND_FOLLOW );
|
||||
break;
|
||||
|
||||
@@ -18,105 +18,3 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "PossessedAI.h"
|
||||
#include "Creature.h"
|
||||
#include "World.h"
|
||||
|
||||
void PossessedAI::AttackStart(Unit *u)
|
||||
{
|
||||
if( !u || i_pet.GetCharmer()->HasAuraType(SPELL_AURA_MOD_PACIFY))
|
||||
return;
|
||||
|
||||
if (i_pet.getVictim() && u != i_pet.getVictim())
|
||||
i_pet.AttackStop();
|
||||
|
||||
if(i_pet.Attack(u, true))
|
||||
i_victimGuid = u->GetGUID();
|
||||
|
||||
// Do not autochase our target, and also make sure our current movement generator
|
||||
// is removed since the motion master is reset before this function is called
|
||||
i_pet.GetMotionMaster()->Clear(false);
|
||||
i_pet.GetMotionMaster()->MoveIdle();
|
||||
}
|
||||
|
||||
bool PossessedAI::_needToStop() const
|
||||
{
|
||||
if(!i_pet.getVictim() || !i_pet.isAlive())
|
||||
return true;
|
||||
|
||||
// This is needed for charmed creatures, as once their target was reset other effects can trigger threat
|
||||
if(i_pet.getVictim() == i_pet.GetCharmer())
|
||||
return true;
|
||||
|
||||
return !i_pet.canAttack(i_pet.getVictim());
|
||||
}
|
||||
|
||||
void PossessedAI::_stopAttack()
|
||||
{
|
||||
if( !i_victimGuid )
|
||||
return;
|
||||
|
||||
Unit* victim = Unit::GetUnit(i_pet, i_victimGuid );
|
||||
|
||||
if ( !victim )
|
||||
return;
|
||||
|
||||
assert(!i_pet.getVictim() || i_pet.getVictim() == victim);
|
||||
|
||||
if( !i_pet.isAlive() )
|
||||
{
|
||||
i_pet.StopMoving();
|
||||
i_pet.GetMotionMaster()->Clear(false);
|
||||
i_pet.GetMotionMaster()->MoveIdle();
|
||||
i_victimGuid = 0;
|
||||
i_pet.CombatStop();
|
||||
i_pet.getHostilRefManager().deleteReferences();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
i_pet.GetMotionMaster()->Clear(false);
|
||||
i_pet.GetMotionMaster()->MoveIdle();
|
||||
i_victimGuid = 0;
|
||||
i_pet.AttackStop();
|
||||
}
|
||||
|
||||
void PossessedAI::UpdateAI(const uint32 diff)
|
||||
{
|
||||
// update i_victimGuid if i_pet.getVictim() !=0 and changed
|
||||
if(i_pet.getVictim())
|
||||
i_victimGuid = i_pet.getVictim()->GetGUID();
|
||||
|
||||
// i_pet.getVictim() can't be used for check in case stop fighting, i_pet.getVictim() clear at Unit death etc.
|
||||
if( i_victimGuid )
|
||||
{
|
||||
if( _needToStop() )
|
||||
{
|
||||
_stopAttack(); // i_victimGuid == 0 && i_pet.getVictim() == NULL now
|
||||
return;
|
||||
}
|
||||
else if(i_pet.IsWithinMeleeRange(i_pet.getVictim()) && i_pet.isAttackReady() && !i_pet.GetCharmer()->HasAuraType(SPELL_AURA_MOD_PACIFY))
|
||||
{
|
||||
i_pet.AttackerStateUpdate(i_pet.getVictim());
|
||||
|
||||
i_pet.resetAttackTimer();
|
||||
|
||||
if( _needToStop() )
|
||||
_stopAttack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PossessedAI::JustDied(Unit *u)
|
||||
{
|
||||
// We died while possessed, disable our loot
|
||||
i_pet.RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
|
||||
}
|
||||
|
||||
void PossessedAI::KilledUnit(Unit* victim)
|
||||
{
|
||||
// We killed a creature, disable victim's loot
|
||||
if (victim->GetTypeId() == TYPEID_UNIT)
|
||||
victim->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,33 +21,5 @@
|
||||
#ifndef MANGOS_POSSESSEDAI_H
|
||||
#define MANGOS_POSSESSEDAI_H
|
||||
|
||||
#include "CreatureAI.h"
|
||||
|
||||
class Creature;
|
||||
|
||||
class TRINITY_DLL_DECL PossessedAI : public CreatureAI
|
||||
{
|
||||
public:
|
||||
PossessedAI(Creature *c) : CreatureAI(c), i_pet(*c), i_victimGuid(0) {}
|
||||
|
||||
// Possessed creatures shouldn't aggro by themselves
|
||||
void MoveInLineOfSight(Unit *) {}
|
||||
void AttackStart(Unit *);
|
||||
void EnterEvadeMode() {}
|
||||
void JustDied(Unit*);
|
||||
void KilledUnit(Unit* victim);
|
||||
|
||||
void UpdateAI(const uint32);
|
||||
// Never permit this to be used, it must always be initialized with Creature::InitPossessedAI()
|
||||
static int Permissible(const Creature *) { return PERMIT_BASE_NO; }
|
||||
|
||||
private:
|
||||
bool _isVisible(Unit *) const;
|
||||
bool _needToStop(void) const;
|
||||
void _stopAttack(void);
|
||||
|
||||
Creature &i_pet;
|
||||
uint64 i_victimGuid;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -893,7 +893,7 @@ enum Targets
|
||||
TARGET_UNIT_CLASS_TARGET = 61,
|
||||
TARGET_TEST = 62, // for a test spell
|
||||
TARGET_DUELVSPLAYER_COORDINATES = 63,
|
||||
TARGET_DEST_TARGET_FRIEND = 63,
|
||||
TARGET_DEST_TARGET_ANY = 63,
|
||||
TARGET_DEST_TARGET_FRONT = 64,
|
||||
TARGET_DEST_TARGET_BACK = 65, // uses in teleport behind spells
|
||||
TARGET_DEST_TARGET_RIGHT = 66,
|
||||
|
||||
+1
-6
@@ -1892,16 +1892,11 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
|
||||
break;
|
||||
}
|
||||
|
||||
if(cur == TARGET_DEST_TARGET_ENEMY)
|
||||
if(cur == TARGET_DEST_TARGET_ENEMY || cur == TARGET_DEST_TARGET_ANY)
|
||||
{
|
||||
m_targets.setDestination(target, true);
|
||||
break;
|
||||
}
|
||||
else if(cur == TARGET_DEST_TARGET_FRIEND) // no ground?
|
||||
{
|
||||
m_targets.setDestination(target, false);
|
||||
break;
|
||||
}
|
||||
|
||||
float x, y, z, angle, dist;
|
||||
|
||||
|
||||
@@ -2818,9 +2818,10 @@ void Spell::EffectPersistentAA(uint32 i)
|
||||
if(Player* modOwner = m_originalCaster->GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius);
|
||||
|
||||
Unit *caster = m_caster->GetEntry() == WORLD_TRIGGER ? m_originalCaster : m_caster;
|
||||
int32 duration = GetSpellDuration(m_spellInfo);
|
||||
DynamicObject* dynObj = new DynamicObject;
|
||||
if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_originalCaster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius))
|
||||
if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius))
|
||||
{
|
||||
delete dynObj;
|
||||
return;
|
||||
@@ -2828,8 +2829,8 @@ void Spell::EffectPersistentAA(uint32 i)
|
||||
dynObj->SetUInt32Value(OBJECT_FIELD_TYPE, 65);
|
||||
dynObj->SetUInt32Value(GAMEOBJECT_DISPLAYID, 368003);
|
||||
dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x01eeeeee);
|
||||
m_originalCaster->AddDynObject(dynObj);
|
||||
MapManager::Instance().GetMap(dynObj->GetMapId(), dynObj)->Add(dynObj);
|
||||
caster->AddDynObject(dynObj);
|
||||
dynObj->GetMap()->Add(dynObj);
|
||||
}
|
||||
|
||||
void Spell::EffectEnergize(uint32 i)
|
||||
|
||||
@@ -129,7 +129,7 @@ SpellMgr::SpellMgr()
|
||||
SpellTargetType[i] = TARGET_TYPE_AREA_DEST;
|
||||
break;
|
||||
case TARGET_DEST_TARGET_ENEMY:
|
||||
case TARGET_DEST_TARGET_FRIEND:
|
||||
case TARGET_DEST_TARGET_ANY:
|
||||
case TARGET_DEST_TARGET_FRONT:
|
||||
case TARGET_DEST_TARGET_BACK:
|
||||
case TARGET_DEST_TARGET_RIGHT:
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
#include "CellImpl.h"
|
||||
#include "Path.h"
|
||||
#include "CreatureGroups.h"
|
||||
#include "PetAI.h"
|
||||
#include "NullCreatureAI.h"
|
||||
#include "Traveller.h"
|
||||
|
||||
#include <math.h>
|
||||
@@ -76,6 +78,7 @@ static bool procPrepared = InitTriggerAuraData();
|
||||
Unit::Unit()
|
||||
: WorldObject(), i_motionMaster(this), m_ThreatManager(this), m_HostilRefManager(this)
|
||||
, m_IsInNotifyList(false), m_Notified(false), IsAIEnabled(false)
|
||||
, i_AI(NULL), i_disabledAI(NULL)
|
||||
{
|
||||
m_objectType |= TYPEMASK_UNIT;
|
||||
m_objectTypeId = TYPEID_UNIT;
|
||||
@@ -11284,10 +11287,38 @@ void Unit::CleanupsBeforeDelete()
|
||||
RemoveFromWorld();
|
||||
}
|
||||
|
||||
void Unit::UpdateCharmAI()
|
||||
{
|
||||
if(GetTypeId() == TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
if(i_disabledAI) // disabled AI must be primary AI
|
||||
{
|
||||
if(!isCharmed())
|
||||
{
|
||||
if(i_AI) delete i_AI;
|
||||
i_AI = i_disabledAI;
|
||||
i_disabledAI = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isCharmed())
|
||||
{
|
||||
i_disabledAI = i_AI;
|
||||
if(isPossessed())
|
||||
i_AI = new PossessedAI((Creature*)this);
|
||||
else
|
||||
i_AI = new PetAI((Creature*)this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CharmInfo* Unit::InitCharmInfo()
|
||||
{
|
||||
if(!m_charmInfo)
|
||||
m_charmInfo = new CharmInfo(this);
|
||||
|
||||
return m_charmInfo;
|
||||
}
|
||||
|
||||
|
||||
@@ -1214,6 +1214,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
||||
CharmInfo* GetCharmInfo() { return m_charmInfo; }
|
||||
CharmInfo* InitCharmInfo();
|
||||
void DeleteCharmInfo();
|
||||
void UpdateCharmAI();
|
||||
SharedVisionList const& GetSharedVisionList() { return m_sharedVision; }
|
||||
void AddPlayerToVision(Player* plr);
|
||||
void RemovePlayerFromVision(Player* plr);
|
||||
@@ -1549,6 +1550,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
||||
protected:
|
||||
explicit Unit ();
|
||||
|
||||
UnitAI *i_AI, *i_disabledAI;
|
||||
|
||||
void _UpdateSpells(uint32 time);
|
||||
|
||||
void _UpdateAutoRepeatSpell();
|
||||
|
||||
Reference in New Issue
Block a user