*Disable charmed/possessed creature AI.
*Use general react states to replace charminfo react states. --HG-- branch : trunk
This commit is contained in:
@@ -905,7 +905,7 @@ struct TRINITY_DLL_DECL npc_steam_tonkAI : public ScriptedAI
|
||||
if (apply)
|
||||
{
|
||||
// Initialize the action bar without the melee attack command
|
||||
m_creature->InitCharmInfo(m_creature);
|
||||
m_creature->InitCharmInfo();
|
||||
m_creature->GetCharmInfo()->InitEmptyActionBar(false);
|
||||
|
||||
m_creature->SetReactState(REACT_PASSIVE);
|
||||
|
||||
+4
-36
@@ -132,7 +132,7 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
{
|
||||
assistant->SetNoCallAssistance(true);
|
||||
assistant->CombatStart(victim);
|
||||
if(assistant->AI())
|
||||
if(assistant->IsAIEnabled)
|
||||
assistant->AI()->AttackStart(victim);
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
}
|
||||
|
||||
Creature::Creature() :
|
||||
Unit(), i_AI(NULL), i_AI_possessed(NULL),
|
||||
Unit(), i_AI(NULL),
|
||||
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),
|
||||
@@ -169,12 +169,6 @@ Creature::~Creature()
|
||||
|
||||
delete i_AI;
|
||||
i_AI = NULL;
|
||||
|
||||
if (i_AI_possessed)
|
||||
{
|
||||
delete i_AI_possessed;
|
||||
i_AI_possessed = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::AddToWorld()
|
||||
@@ -490,7 +484,7 @@ void Creature::Update(uint32 diff)
|
||||
if(!isAlive())
|
||||
break;
|
||||
|
||||
if(!IsInEvadeMode() && m_AI_enabled)
|
||||
if(!IsInEvadeMode() && IsAIEnabled)
|
||||
{
|
||||
// do not allow the AI to be changed during update
|
||||
m_AI_locked = true;
|
||||
@@ -607,36 +601,10 @@ bool Creature::AIM_Initialize(CreatureAI* ai)
|
||||
i_AI = ai ? ai : FactorySelector::selectAI(this);
|
||||
if (oldAI)
|
||||
delete oldAI;
|
||||
m_AI_enabled = true;
|
||||
IsAIEnabled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Creature::InitPossessedAI()
|
||||
{
|
||||
if (!isPossessed()) return;
|
||||
|
||||
if (!i_AI_possessed)
|
||||
i_AI_possessed = new PossessedAI(this);
|
||||
|
||||
// Signal the old AI that it's been disabled
|
||||
i_AI->OnPossess(true);
|
||||
|
||||
if(!(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CHARM_AI))
|
||||
m_AI_enabled = false;
|
||||
}
|
||||
|
||||
void Creature::DisablePossessedAI()
|
||||
{
|
||||
if (!i_AI_possessed) return;
|
||||
|
||||
delete i_AI_possessed;
|
||||
|
||||
// Signal the old AI that it's been re-enabled
|
||||
i_AI->OnPossess(false);
|
||||
|
||||
m_AI_enabled = true;
|
||||
}
|
||||
|
||||
bool Creature::Create (uint32 guidlow, Map *map, uint32 Entry, uint32 team, const CreatureData *data)
|
||||
{
|
||||
SetMapId(map->GetId());
|
||||
|
||||
+2
-5
@@ -132,7 +132,7 @@ enum CreatureFlagsExtra
|
||||
CREATURE_FLAG_EXTRA_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP
|
||||
CREATURE_FLAG_EXTRA_TRIGGER = 0x00000080, // trigger creature
|
||||
CREATURE_FLAG_EXTRA_WORLDEVENT = 0x00004000, // custom flag for world event creatures (left room for merging)
|
||||
CREATURE_FLAG_EXTRA_CHARM_AI = 0x00008000, // use ai when charmed
|
||||
//CREATURE_FLAG_EXTRA_CHARM_AI = 0x00008000, // use ai when charmed
|
||||
CREATURE_FLAG_EXTRA_NO_TAUNT = 0x00010000, // cannot be taunted
|
||||
};
|
||||
|
||||
@@ -402,7 +402,6 @@ typedef std::map<uint32,time_t> CreatureSpellCooldowns;
|
||||
class TRINITY_DLL_SPEC Creature : public Unit
|
||||
{
|
||||
CreatureAI *i_AI;
|
||||
CreatureAI *i_AI_possessed;
|
||||
|
||||
public:
|
||||
|
||||
@@ -467,11 +466,9 @@ class TRINITY_DLL_SPEC Creature : public Unit
|
||||
bool IsInEvadeMode() const;
|
||||
|
||||
bool AIM_Initialize(CreatureAI* ai = NULL);
|
||||
void InitPossessedAI();
|
||||
void DisablePossessedAI();
|
||||
|
||||
void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type);
|
||||
CreatureAI* AI() { return isPossessed() && i_AI_possessed ? i_AI_possessed : i_AI; }
|
||||
CreatureAI* AI() { return i_AI; }
|
||||
|
||||
uint32 GetShieldBlockValue() const //dunno mob block value
|
||||
{
|
||||
|
||||
@@ -36,6 +36,12 @@ void UnitAI::AttackStart(Unit *victim)
|
||||
}
|
||||
}
|
||||
|
||||
//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::MoveInLineOfSight(Unit *who)
|
||||
{
|
||||
if(!me->getVictim() && me->canStartAttack(who))
|
||||
|
||||
@@ -78,6 +78,9 @@ class TRINITY_DLL_SPEC UnitAI
|
||||
UnitAI(Unit *u) : me(u) {}
|
||||
virtual void AttackStart(Unit *);
|
||||
virtual void UpdateAI(const uint32 diff) = 0;
|
||||
|
||||
// Called when unit is charmed
|
||||
virtual void OnCharmed(bool apply) = 0;
|
||||
};
|
||||
|
||||
class TRINITY_DLL_SPEC PlayerAI : public UnitAI
|
||||
@@ -86,6 +89,8 @@ class TRINITY_DLL_SPEC PlayerAI : public UnitAI
|
||||
Player *me;
|
||||
public:
|
||||
PlayerAI(Player *p) : UnitAI((Unit*)p), me(p) {}
|
||||
|
||||
void OnCharmed(bool apply);
|
||||
};
|
||||
|
||||
class TRINITY_DLL_SPEC SimpleCharmedAI : public PlayerAI
|
||||
@@ -140,8 +145,7 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI
|
||||
// Called at waypoint reached or point movement finished
|
||||
virtual void MovementInform(uint32 /*MovementType*/, uint32 /*Data*/) {}
|
||||
|
||||
// Called when AI is temporarily replaced or put back when possess is applied or removed
|
||||
virtual void OnPossess(bool apply) {}
|
||||
void OnCharmed(bool apply);
|
||||
};
|
||||
|
||||
struct SelectableAI : public FactoryHolder<CreatureAI>, public Permissible<Creature>
|
||||
|
||||
@@ -74,7 +74,7 @@ inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c)
|
||||
// Creature AI reaction
|
||||
if(c->HasReactState(REACT_AGGRESSIVE) && !c->hasUnitState(UNIT_STAT_SIGHTLESS))
|
||||
{
|
||||
if( c->AI() && c->IsWithinSightDist(pl) && !c->IsInEvadeMode() )
|
||||
if( c->IsAIEnabled && c->IsWithinSightDist(pl) && !c->IsInEvadeMode() )
|
||||
c->AI()->MoveInLineOfSight(pl);
|
||||
}
|
||||
}
|
||||
@@ -83,13 +83,13 @@ inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2)
|
||||
{
|
||||
if(c1->HasReactState(REACT_AGGRESSIVE) && !c1->hasUnitState(UNIT_STAT_SIGHTLESS))
|
||||
{
|
||||
if( c1->AI() && c1->IsWithinSightDist(c2) && !c1->IsInEvadeMode() )
|
||||
if( c1->IsAIEnabled && c1->IsWithinSightDist(c2) && !c1->IsInEvadeMode() )
|
||||
c1->AI()->MoveInLineOfSight(c2);
|
||||
}
|
||||
|
||||
if(c2->HasReactState(REACT_AGGRESSIVE) && !c2->hasUnitState(UNIT_STAT_SIGHTLESS))
|
||||
{
|
||||
if( c2->AI() && c1->IsWithinSightDist(c2) && !c2->IsInEvadeMode() )
|
||||
if( c2->IsAIEnabled && c1->IsWithinSightDist(c2) && !c2->IsInEvadeMode() )
|
||||
c2->AI()->MoveInLineOfSight(c1);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1601,7 +1601,7 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
|
||||
pCreature->SetHomePosition(x, y, z, ang);
|
||||
pCreature->Summon(spwtype, despwtime);
|
||||
|
||||
if(GetTypeId()==TYPEID_UNIT && ((Creature*)this)->AI())
|
||||
if(GetTypeId()==TYPEID_UNIT && ((Creature*)this)->IsAIEnabled)
|
||||
((Creature*)this)->AI()->JustSummoned(pCreature);
|
||||
|
||||
if(pCreature->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER && pCreature->m_spells[0])
|
||||
|
||||
@@ -56,7 +56,7 @@ void OutdoorPvPObjective::HandlePlayerActivityChanged(Player * plr)
|
||||
{
|
||||
if(m_CapturePointCreature)
|
||||
if(Creature * c = HashMapHolder<Creature>::Find(m_CapturePointCreature))
|
||||
if(c->AI())
|
||||
if(c->IsAIEnabled)
|
||||
c->AI()->MoveInLineOfSight(plr);
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -83,12 +83,12 @@ Pet::Pet(PetType type) : Creature()
|
||||
m_auraUpdateMask = 0;
|
||||
|
||||
// pets always have a charminfo, even if they are not actually charmed
|
||||
CharmInfo* charmInfo = InitCharmInfo(this);
|
||||
CharmInfo* charmInfo = InitCharmInfo();
|
||||
|
||||
if(type == MINI_PET || type == POSSESSED_PET) // always passive
|
||||
charmInfo->SetReactState(REACT_PASSIVE);
|
||||
SetReactState(REACT_PASSIVE);
|
||||
else if(type == GUARDIAN_PET) // always aggressive
|
||||
charmInfo->SetReactState(REACT_AGGRESSIVE);
|
||||
SetReactState(REACT_AGGRESSIVE);
|
||||
|
||||
m_spells.clear();
|
||||
m_Auras.clear();
|
||||
@@ -253,7 +253,7 @@ bool Pet::LoadPetFromDB( Unit* owner, uint32 petentry, uint32 petnumber, bool cu
|
||||
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, fields[5].GetUInt32());
|
||||
SetUInt64Value(UNIT_FIELD_CREATEDBY, owner->GetGUID());
|
||||
|
||||
m_charmInfo->SetReactState( ReactStates( fields[6].GetUInt8() ));
|
||||
SetReactState( ReactStates( fields[6].GetUInt8() ));
|
||||
m_loyaltyPoints = fields[7].GetInt32();
|
||||
|
||||
uint32 savedhealth = fields[13].GetUInt32();
|
||||
@@ -445,7 +445,7 @@ void Pet::SavePetToDB(PetSaveMode mode)
|
||||
<< GetNativeDisplayId() << ", "
|
||||
<< getLevel() << ", "
|
||||
<< GetUInt32Value(UNIT_FIELD_PETEXPERIENCE) << ", "
|
||||
<< uint32(m_charmInfo->GetReactState()) << ", "
|
||||
<< uint32(GetReactState()) << ", "
|
||||
<< m_loyaltyPoints << ", "
|
||||
<< GetLoyaltyLevel() << ", "
|
||||
<< m_TrainingPoints << ", "
|
||||
|
||||
+1
-2
@@ -47,7 +47,6 @@ PetAI::PetAI(Creature *c) : CreatureAI(c), i_pet(*c), i_tracker(TIME_INTERVAL_LO
|
||||
void PetAI::MoveInLineOfSight(Unit *u)
|
||||
{
|
||||
if( !i_pet.getVictim() && i_pet.GetCharmInfo() &&
|
||||
i_pet.GetCharmInfo()->HasReactState(REACT_AGGRESSIVE) &&
|
||||
i_pet.IsHostileTo( u ) && i_pet.canAttack(u) &&
|
||||
u->isInAccessiblePlaceFor(&i_pet))
|
||||
{
|
||||
@@ -181,7 +180,7 @@ void PetAI::UpdateAI(const uint32 diff)
|
||||
}
|
||||
else if(owner && i_pet.GetCharmInfo())
|
||||
{
|
||||
if(owner->isInCombat() && !(i_pet.GetCharmInfo()->HasReactState(REACT_PASSIVE) || i_pet.GetCharmInfo()->HasCommandState(COMMAND_STAY)))
|
||||
if(owner->isInCombat() && !(i_pet.HasReactState(REACT_PASSIVE) || i_pet.GetCharmInfo()->HasCommandState(COMMAND_STAY)))
|
||||
{
|
||||
AttackStart(owner->getAttackerForHelper());
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
|
||||
|
||||
if(pet->GetTypeId() != TYPEID_PLAYER)
|
||||
{
|
||||
if (((Creature*)pet)->AI())
|
||||
if (((Creature*)pet)->IsAIEnabled)
|
||||
((Creature*)pet)->AI()->AttackStart(TargetUnit);
|
||||
|
||||
//10% chance to play special pet attack talk, else growl
|
||||
@@ -165,7 +165,8 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
|
||||
case REACT_PASSIVE: //passive
|
||||
case REACT_DEFENSIVE: //recovery
|
||||
case REACT_AGGRESSIVE: //activete
|
||||
charmInfo->SetReactState( ReactStates(spellid) );
|
||||
if(pet->GetTypeId() == TYPEID_UNIT)
|
||||
((Creature*)pet)->SetReactState( ReactStates(spellid) );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -241,7 +242,7 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
|
||||
if(pet->getVictim())
|
||||
pet->AttackStop();
|
||||
pet->GetMotionMaster()->Clear();
|
||||
if (((Creature*)pet)->AI())
|
||||
if (((Creature*)pet)->IsAIEnabled)
|
||||
((Creature*)pet)->AI()->AttackStart(unit_target);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -16365,7 +16365,7 @@ void Player::PetSpellInitialize()
|
||||
CharmInfo *charmInfo = pet->GetCharmInfo();
|
||||
|
||||
//16
|
||||
data << (uint64)pet->GetGUID() << uint32(0x00000000) << uint8(charmInfo->GetReactState()) << uint8(charmInfo->GetCommandState()) << uint16(0);
|
||||
data << (uint64)pet->GetGUID() << uint32(0x00000000) << uint8(pet->GetReactState()) << uint8(charmInfo->GetCommandState()) << uint16(0);
|
||||
|
||||
for(uint32 i = 0; i < 10; i++) //40
|
||||
{
|
||||
@@ -16474,7 +16474,7 @@ void Player::CharmSpellInitialize()
|
||||
data << (uint64)charm->GetGUID() << uint32(0x00000000);
|
||||
|
||||
if(charm->GetTypeId() != TYPEID_PLAYER)
|
||||
data << uint8(charmInfo->GetReactState()) << uint8(charmInfo->GetCommandState());
|
||||
data << uint8(((Creature*)charm)->GetReactState()) << uint8(charmInfo->GetCommandState());
|
||||
else
|
||||
data << uint8(0) << uint8(0);
|
||||
|
||||
|
||||
+2
-2
@@ -1212,10 +1212,10 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask)
|
||||
}
|
||||
}
|
||||
|
||||
if(unit->GetTypeId() == TYPEID_UNIT && ((Creature*)unit)->AI())
|
||||
if(unit->GetTypeId() == TYPEID_UNIT && ((Creature*)unit)->IsAIEnabled)
|
||||
((Creature*)unit)->AI()->SpellHit(m_caster, m_spellInfo);
|
||||
|
||||
if(m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->AI())
|
||||
if(m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->IsAIEnabled)
|
||||
((Creature*)m_caster)->AI()->SpellHitTarget(unit, m_spellInfo);
|
||||
|
||||
for(ChanceTriggerSpells::const_iterator i = m_ChanceTriggerSpells.begin(); i != m_ChanceTriggerSpells.end(); ++i)
|
||||
|
||||
@@ -1146,7 +1146,7 @@ void Spell::EffectDummy(uint32 i)
|
||||
|
||||
pCreature->SetHealth(health);
|
||||
|
||||
if(pCreature->AI())
|
||||
if(pCreature->IsAIEnabled)
|
||||
pCreature->AI()->AttackStart(m_caster);
|
||||
|
||||
return;
|
||||
@@ -1178,7 +1178,7 @@ void Spell::EffectDummy(uint32 i)
|
||||
pCreature->SetHealth(health);
|
||||
((Player*)m_caster)->KilledMonster(16992,pCreature->GetGUID());
|
||||
|
||||
if (pCreature->AI())
|
||||
if (pCreature->IsAIEnabled)
|
||||
pCreature->AI()->AttackStart(m_caster);
|
||||
|
||||
return;
|
||||
@@ -3244,7 +3244,7 @@ void Spell::EffectSummon(uint32 i)
|
||||
name.append(petTypeSuffix[spawnCreature->getPetType()]);
|
||||
spawnCreature->SetName( name );
|
||||
|
||||
spawnCreature->GetCharmInfo()->SetReactState( REACT_DEFENSIVE );
|
||||
spawnCreature->SetReactState( REACT_DEFENSIVE );
|
||||
}
|
||||
|
||||
void Spell::EffectLearnSpell(uint32 i)
|
||||
@@ -3471,7 +3471,7 @@ void Spell::EffectPickPocket(uint32 /*i*/)
|
||||
{
|
||||
// Reveal action + get attack
|
||||
m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TALK);
|
||||
if (((Creature*)unitTarget)->AI())
|
||||
if (((Creature*)unitTarget)->IsAIEnabled)
|
||||
((Creature*)unitTarget)->AI()->AttackStart(m_caster);
|
||||
}
|
||||
}
|
||||
@@ -4022,9 +4022,9 @@ void Spell::EffectSummonPet(uint32 i)
|
||||
if(m_caster->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
if ( ((Creature*)m_caster)->isTotem() )
|
||||
pet->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE);
|
||||
pet->SetReactState(REACT_AGGRESSIVE);
|
||||
else
|
||||
pet->GetCharmInfo()->SetReactState(REACT_DEFENSIVE);
|
||||
pet->SetReactState(REACT_DEFENSIVE);
|
||||
}
|
||||
|
||||
pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
|
||||
|
||||
@@ -176,7 +176,7 @@ void TemporarySummon::UnSummon()
|
||||
AddObjectToRemoveList();
|
||||
|
||||
Unit* sum = m_summoner ? ObjectAccessor::GetUnit(*this, m_summoner) : NULL;
|
||||
if (sum && sum->GetTypeId() == TYPEID_UNIT && ((Creature*)sum)->AI())
|
||||
if (sum && sum->GetTypeId() == TYPEID_UNIT && ((Creature*)sum)->IsAIEnabled)
|
||||
{
|
||||
((Creature*)sum)->AI()->SummonedCreatureDespawn(this);
|
||||
}
|
||||
|
||||
+46
-20
@@ -149,7 +149,7 @@ bool IsPassiveStackableSpell( uint32 spellId )
|
||||
|
||||
Unit::Unit()
|
||||
: WorldObject(), i_motionMaster(this), m_ThreatManager(this), m_HostilRefManager(this)
|
||||
, m_IsInNotifyList(false), m_Notified(false), m_AI_enabled(false)
|
||||
, m_IsInNotifyList(false), m_Notified(false), IsAIEnabled(false)
|
||||
{
|
||||
m_objectType |= TYPEMASK_UNIT;
|
||||
m_objectTypeId = TYPEID_UNIT;
|
||||
@@ -627,7 +627,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
|
||||
}
|
||||
|
||||
//Script Event damage taken
|
||||
if( pVictim->GetTypeId()== TYPEID_UNIT && ((Creature *)pVictim)->AI() )
|
||||
if( pVictim->GetTypeId()== TYPEID_UNIT && ((Creature *)pVictim)->IsAIEnabled )
|
||||
{
|
||||
((Creature *)pVictim)->AI()->DamageTaken(this, damage);
|
||||
|
||||
@@ -778,7 +778,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
|
||||
if(!getVictim())
|
||||
/*{
|
||||
// if have target and damage pVictim just call AI reaction
|
||||
if(pVictim != getVictim() && pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->AI())
|
||||
if(pVictim != getVictim() && pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->IsAIEnabled)
|
||||
((Creature*)pVictim)->AI()->AttackedBy(this);
|
||||
}
|
||||
else*/
|
||||
@@ -8283,7 +8283,7 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
|
||||
m_attacking = victim;
|
||||
m_attacking->_addAttacker(this);
|
||||
|
||||
//if(m_attacking->GetTypeId()==TYPEID_UNIT && ((Creature*)m_attacking)->AI())
|
||||
//if(m_attacking->GetTypeId()==TYPEID_UNIT && ((Creature*)m_attacking)->IsAIEnabled)
|
||||
// ((Creature*)m_attacking)->AI()->AttackedBy(this);
|
||||
|
||||
if(GetTypeId()==TYPEID_UNIT)
|
||||
@@ -9831,7 +9831,7 @@ void Unit::CombatStart(Unit* target)
|
||||
target->SetStandState(PLAYER_STATE_NONE);
|
||||
|
||||
if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER
|
||||
&& !((Creature*)target)->HasReactState(REACT_PASSIVE) && ((Creature*)target)->AI())
|
||||
&& !((Creature*)target)->HasReactState(REACT_PASSIVE) && ((Creature*)target)->IsAIEnabled)
|
||||
((Creature*)target)->AI()->AttackStart(this);
|
||||
|
||||
SetInCombatWith(target);
|
||||
@@ -10454,7 +10454,7 @@ void Unit::TauntApply(Unit* taunter)
|
||||
return;
|
||||
|
||||
SetInFront(taunter);
|
||||
if (((Creature*)this)->AI())
|
||||
if (((Creature*)this)->IsAIEnabled)
|
||||
((Creature*)this)->AI()->AttackStart(taunter);
|
||||
|
||||
m_ThreatManager.tauntApply(taunter);
|
||||
@@ -10478,7 +10478,7 @@ void Unit::TauntFadeOut(Unit *taunter)
|
||||
|
||||
if(m_ThreatManager.isThreatListEmpty())
|
||||
{
|
||||
if(((Creature*)this)->AI())
|
||||
if(((Creature*)this)->IsAIEnabled)
|
||||
((Creature*)this)->AI()->EnterEvadeMode();
|
||||
return;
|
||||
}
|
||||
@@ -10489,7 +10489,7 @@ void Unit::TauntFadeOut(Unit *taunter)
|
||||
if (target && target != taunter)
|
||||
{
|
||||
SetInFront(target);
|
||||
if (((Creature*)this)->AI())
|
||||
if (((Creature*)this)->IsAIEnabled)
|
||||
((Creature*)this)->AI()->AttackStart(target);
|
||||
}
|
||||
}
|
||||
@@ -11225,21 +11225,43 @@ void Unit::CleanupsBeforeDelete()
|
||||
RemoveFromWorld();
|
||||
}
|
||||
|
||||
CharmInfo* Unit::InitCharmInfo(Unit *charm)
|
||||
CharmInfo* Unit::InitCharmInfo()
|
||||
{
|
||||
if(!m_charmInfo)
|
||||
m_charmInfo = new CharmInfo(charm);
|
||||
m_charmInfo = new CharmInfo(this);
|
||||
return m_charmInfo;
|
||||
}
|
||||
|
||||
void Unit::DeleteCharmInfo()
|
||||
{
|
||||
if(!m_charmInfo)
|
||||
return;
|
||||
|
||||
delete m_charmInfo;
|
||||
m_charmInfo = NULL;
|
||||
}
|
||||
|
||||
CharmInfo::CharmInfo(Unit* unit)
|
||||
: m_unit(unit), m_CommandState(COMMAND_FOLLOW), m_reactState(REACT_PASSIVE), m_petnumber(0), m_barInit(false)
|
||||
: m_unit(unit), m_CommandState(COMMAND_FOLLOW), m_petnumber(0), m_barInit(false)
|
||||
{
|
||||
for(int i =0; i<4; ++i)
|
||||
{
|
||||
m_charmspells[i].spellId = 0;
|
||||
m_charmspells[i].active = ACT_DISABLED;
|
||||
}
|
||||
if(m_unit->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
m_oldReactState = ((Creature*)m_unit)->GetReactState();
|
||||
((Creature*)m_unit)->SetReactState(REACT_PASSIVE);
|
||||
}
|
||||
}
|
||||
|
||||
CharmInfo::~CharmInfo()
|
||||
{
|
||||
if(m_unit->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
((Creature*)m_unit)->SetReactState(m_oldReactState);
|
||||
}
|
||||
}
|
||||
|
||||
void CharmInfo::InitPetActionBar()
|
||||
@@ -12084,7 +12106,7 @@ void Unit::SetFeared(bool apply, uint64 casterGUID, uint32 spellID)
|
||||
|
||||
// attack caster if can
|
||||
Unit* caster = ObjectAccessor::GetObjectInWorld(casterGUID, (Unit*)NULL);
|
||||
if(caster && caster != getVictim() && ((Creature*)this)->AI())
|
||||
if(caster && caster != getVictim() && ((Creature*)this)->IsAIEnabled)
|
||||
((Creature*)this)->AI()->AttackStart(caster);
|
||||
}
|
||||
}
|
||||
@@ -12768,7 +12790,7 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss)
|
||||
((Player*)pVictim)->GetSession()->SendPacket(&data);
|
||||
}
|
||||
// Call KilledUnit for creatures
|
||||
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI())
|
||||
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsAIEnabled)
|
||||
((Creature*)this)->AI()->KilledUnit(pVictim);
|
||||
|
||||
// last damage from non duel opponent or opponent controlled creature
|
||||
@@ -12791,11 +12813,11 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss)
|
||||
}
|
||||
|
||||
// Call KilledUnit for creatures, this needs to be called after the lootable flag is set
|
||||
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI())
|
||||
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsAIEnabled)
|
||||
((Creature*)this)->AI()->KilledUnit(pVictim);
|
||||
|
||||
// Call creature just died function
|
||||
if (cVictim->AI())
|
||||
if (cVictim->IsAIEnabled)
|
||||
cVictim->AI()->JustDied(this);
|
||||
|
||||
// Dungeon specific stuff, only applies to players killing creatures
|
||||
@@ -13059,7 +13081,7 @@ void Unit::SetCharmedOrPossessedBy(Unit* charmer, bool possess)
|
||||
|
||||
if(GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
((Creature*)this)->InitPossessedAI();
|
||||
((Creature*)this)->AI()->OnCharmed(true);
|
||||
StopMoving();
|
||||
GetMotionMaster()->Clear(false);
|
||||
GetMotionMaster()->MoveIdle();
|
||||
@@ -13074,8 +13096,7 @@ void Unit::SetCharmedOrPossessedBy(Unit* charmer, bool possess)
|
||||
// Pets already have a properly initialized CharmInfo, don't overwrite it.
|
||||
if(GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT && !((Creature*)this)->isPet())
|
||||
{
|
||||
CharmInfo *charmInfo = InitCharmInfo(this);
|
||||
charmInfo->SetReactState(REACT_DEFENSIVE);
|
||||
CharmInfo *charmInfo = InitCharmInfo();
|
||||
if(possess)
|
||||
charmInfo->InitPossessCreateSpells();
|
||||
else
|
||||
@@ -13145,8 +13166,8 @@ void Unit::RemoveCharmedOrPossessedBy(Unit *charmer)
|
||||
if(!((Creature*)this)->isPet())
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
|
||||
|
||||
((Creature*)this)->DisablePossessedAI();
|
||||
if(isAlive() && ((Creature*)this)->AI())
|
||||
((Creature*)this)->AI()->OnCharmed(false);
|
||||
if(isAlive() && ((Creature*)this)->IsAIEnabled)
|
||||
{
|
||||
if(charmer && !IsFriendlyTo(charmer))
|
||||
{
|
||||
@@ -13192,6 +13213,11 @@ void Unit::RemoveCharmedOrPossessedBy(Unit *charmer)
|
||||
}
|
||||
}
|
||||
|
||||
if(GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT && !((Creature*)this)->isPet())
|
||||
{
|
||||
DeleteCharmInfo();
|
||||
}
|
||||
|
||||
if(possess || charmer->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
// Remove pet spell action bar
|
||||
|
||||
+12
-6
@@ -709,15 +709,16 @@ struct TRINITY_DLL_SPEC CharmInfo
|
||||
{
|
||||
public:
|
||||
explicit CharmInfo(Unit* unit);
|
||||
~CharmInfo();
|
||||
uint32 GetPetNumber() const { return m_petnumber; }
|
||||
void SetPetNumber(uint32 petnumber, bool statwindow);
|
||||
|
||||
void SetCommandState(CommandStates st) { m_CommandState = st; }
|
||||
CommandStates GetCommandState() { return m_CommandState; }
|
||||
bool HasCommandState(CommandStates state) { return (m_CommandState == state); }
|
||||
void SetReactState(ReactStates st) { m_reactState = st; }
|
||||
ReactStates GetReactState() { return m_reactState; }
|
||||
bool HasReactState(ReactStates state) { return (m_reactState == state); }
|
||||
//void SetReactState(ReactStates st) { m_reactState = st; }
|
||||
//ReactStates GetReactState() { return m_reactState; }
|
||||
//bool HasReactState(ReactStates state) { return (m_reactState == state); }
|
||||
|
||||
void InitPossessCreateSpells();
|
||||
void InitCharmCreateSpells();
|
||||
@@ -734,9 +735,12 @@ struct TRINITY_DLL_SPEC CharmInfo
|
||||
UnitActionBarEntry PetActionBar[10];
|
||||
CharmSpellEntry m_charmspells[4];
|
||||
CommandStates m_CommandState;
|
||||
ReactStates m_reactState;
|
||||
//ReactStates m_reactState;
|
||||
uint32 m_petnumber;
|
||||
bool m_barInit;
|
||||
|
||||
//for restoration after charmed
|
||||
ReactStates m_oldReactState;
|
||||
};
|
||||
|
||||
// for clearing special attacks
|
||||
@@ -1103,7 +1107,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
||||
bool isPossessing(Unit* u) const { return u->isPossessed() && GetCharmGUID() == u->GetGUID(); }
|
||||
|
||||
CharmInfo* GetCharmInfo() { return m_charmInfo; }
|
||||
CharmInfo* InitCharmInfo(Unit* charm);
|
||||
CharmInfo* InitCharmInfo();
|
||||
void DeleteCharmInfo();
|
||||
SharedVisionList const& GetSharedVisionList() { return m_sharedVision; }
|
||||
void AddPlayerToVision(Player* plr);
|
||||
void RemovePlayerFromVision(Player* plr);
|
||||
@@ -1414,6 +1419,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
||||
}
|
||||
uint32 GetReducedThreatPercent() { return m_reducedThreatPercent; }
|
||||
Unit *GetMisdirectionTarget() { return m_misdirectionTargetGUID ? GetUnit(*this, m_misdirectionTargetGUID) : NULL; }
|
||||
|
||||
bool IsAIEnabled;
|
||||
protected:
|
||||
explicit Unit ();
|
||||
|
||||
@@ -1466,7 +1473,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
||||
|
||||
ThreatManager m_ThreatManager;
|
||||
|
||||
bool m_AI_enabled;
|
||||
private:
|
||||
void SendAttackStop(Unit* victim); // only from AttackStop(Unit*)
|
||||
//void SendAttackStart(Unit* pVictim); // only from Unit::AttackStart(Unit*)
|
||||
|
||||
Reference in New Issue
Block a user