diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bindings/scripts/ScriptMgr.cpp | 8 | ||||
-rw-r--r-- | src/bindings/scripts/include/sc_creature.cpp | 1 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/creature/mob_event_ai.cpp | 25 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/zone/azshara/azshara.cpp | 4 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp | 8 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/zone/scarlet_monastery/boss_headless_horseman.cpp | 1 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp | 3 | ||||
-rw-r--r-- | src/game/Creature.cpp | 10 | ||||
-rw-r--r-- | src/game/CreatureAI.cpp | 7 | ||||
-rw-r--r-- | src/game/GridNotifiers.h | 9 | ||||
-rw-r--r-- | src/game/GuardAI.cpp | 1 | ||||
-rw-r--r-- | src/game/IdleMovementGenerator.cpp | 5 | ||||
-rw-r--r-- | src/game/IdleMovementGenerator.h | 2 | ||||
-rw-r--r-- | src/game/ObjectMgr.cpp | 10 | ||||
-rw-r--r-- | src/game/PetAI.cpp | 1 | ||||
-rw-r--r-- | src/game/PetHandler.cpp | 1 | ||||
-rw-r--r-- | src/game/Player.cpp | 2 | ||||
-rw-r--r-- | src/game/SpellAuras.cpp | 1 | ||||
-rw-r--r-- | src/game/Unit.cpp | 28 | ||||
-rw-r--r-- | src/game/Unit.h | 3 |
20 files changed, 77 insertions, 53 deletions
diff --git a/src/bindings/scripts/ScriptMgr.cpp b/src/bindings/scripts/ScriptMgr.cpp index 39ddedecb9a..e7177fa9ec6 100644 --- a/src/bindings/scripts/ScriptMgr.cpp +++ b/src/bindings/scripts/ScriptMgr.cpp @@ -940,7 +940,7 @@ void LoadDatabase() //Creature does not exist in database if (!GetCreatureTemplateStore(temp.creature_id)) - error_db_log("TSCR: Event %u has script for non-existing creature.", i); + error_db_log("TSCR: Event %u has script for non-existing creature.", i); //Report any errors in event if (temp.event_type >= EVENT_T_END) @@ -1125,7 +1125,7 @@ void LoadDatabase() { const SpellEntry *spell = GetSpellStore()->LookupEntry(temp.action[j].param1); if (!spell) - error_db_log("TSCR: Event %u Action %u uses non-existant SpellID %u.", i, j+1, temp.action[j].param1); + error_db_log("SD2: Event %u Action %u uses non-existant SpellID %u.", i, j+1, temp.action[j].param1); else { if (spell->RecoveryTime > 0 && temp.event_flags & EFLAG_REPEATABLE) @@ -1183,7 +1183,7 @@ void LoadDatabase() error_db_log("TSCR: Event %u Action %u uses non-existant SpellID %u.", i, j+1, temp.action[j].param2); if (temp.action[j].param3 >= TARGET_T_END) - error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); + error_db_log("SD2: Event %u Action %u uses incorrect Target type", i, j+1); } break; case ACTION_T_CASTCREATUREGO_ALL: @@ -1249,7 +1249,7 @@ void LoadDatabase() case ACTION_T_INC_PHASE: if (!temp.action[j].param1) - error_db_log("TSCR: Event %u Action %u is incrementing phase by 0. Was this intended?", i, j+1); + error_db_log("SD2: Event %u Action %u is incrementing phase by 0. Was this intended?", i, j+1); break; case ACTION_T_SET_INST_DATA: diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp index 1f5dc77aa26..59019348043 100644 --- a/src/bindings/scripts/include/sc_creature.cpp +++ b/src/bindings/scripts/include/sc_creature.cpp @@ -166,7 +166,6 @@ void ScriptedAI::DoStartNoMovement(Unit* victim) return; m_creature->GetMotionMaster()->MoveIdle(); - m_creature->StopMoving(); } void ScriptedAI::DoStopAttack() diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp index 7102add172d..77c24b16173 100644 --- a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp +++ b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp @@ -687,7 +687,6 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI AttackDistance = 0; AttackAngle = 0; - m_creature->GetMotionMaster()->Clear(false); m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle); } } @@ -804,19 +803,12 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI //Allow movement (create new targeted movement gen only if idle) if (CombatMovementEnabled) { - if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == IDLE_MOTION_TYPE) - { - m_creature->GetMotionMaster()->Clear(false); - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle); - } + m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle); } else - if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) - { - m_creature->GetMotionMaster()->Clear(false); - m_creature->GetMotionMaster()->MoveIdle(); - m_creature->StopMoving(); - } + { + m_creature->GetMotionMaster()->MoveIdle(); + } } break; case ACTION_T_SET_PHASE: @@ -886,10 +878,6 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI if (CombatMovementEnabled) { - if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) - { - //Drop current movement gen - m_creature->GetMotionMaster()->Clear(false); m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle); } } @@ -1099,7 +1087,7 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI Reset(); } - + void EnterEvadeMode() { m_creature->InterruptNonMeleeSpells(true); @@ -1234,7 +1222,6 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI else { m_creature->GetMotionMaster()->MoveIdle(); - m_creature->StopMoving(); } } } @@ -1450,7 +1437,7 @@ void AddSC_mob_event() { Script *newscript; newscript = new Script; - newscript->Name="mob_eventai"; + newscript->Name = "mob_eventai"; newscript->GetAI = &GetAI_Mob_EventAI; newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/azshara/azshara.cpp b/src/bindings/scripts/scripts/zone/azshara/azshara.cpp index 4428f17ea21..b1fb11a8a09 100644 --- a/src/bindings/scripts/scripts/zone/azshara/azshara.cpp +++ b/src/bindings/scripts/scripts/zone/azshara/azshara.cpp @@ -350,9 +350,7 @@ struct TRINITY_DLL_DECL mob_rizzle_sprysprocketAI : public ScriptedAI DoScriptText(SAY_RIZZLE_FINAL, m_creature); m_creature->SetUInt32Value(UNIT_NPC_FLAGS, 1); m_creature->setFaction(35); - m_creature->StopMoving(); - m_creature->GetMotionMaster()->MovementExpired(); - m_creature->GetMotionMaster()->Clear(true); + m_creature->GetMotionMaster()->MoveIdle(); m_creature->RemoveAurasDueToSpell(SPELL_PERIODIC_DEPTH_CHARGE); Reached = true; } diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp index 6592e3783f4..78014b34bbb 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp @@ -1086,8 +1086,8 @@ struct TRINITY_DLL_DECL npc_akama_illidanAI : public ScriptedAI Illidan->RemoveAurasDueToSpell(SPELL_KNEEL); m_creature->SetInFront(Illidan); Illidan->SetInFront(m_creature); - m_creature->StopMoving(); - Illidan->StopMoving(); + m_creature->GetMotionMaster()->MoveIdle(); + Illidan->GetMotionMaster()->MoveIdle(); ((boss_illidan_stormrageAI*)Illidan->AI())->AkamaGUID = m_creature->GetGUID(); ((boss_illidan_stormrageAI*)Illidan->AI())->EnterPhase(PHASE_TALK_SEQUENCE); } @@ -1919,8 +1919,8 @@ void boss_illidan_stormrageAI::HandleTalkSequence() Maiev->CastSpell(Maiev, SPELL_TELEPORT_VISUAL, true); // onoz she looks like she teleported! Maiev->SetInFront(m_creature); // Have her face us m_creature->SetInFront(Maiev); // Face her, so it's not rude =P - Maiev->StopMoving(); - m_creature->StopMoving(); + Maiev->GetMotionMaster()->MoveIdle(); + m_creature->GetMotionMaster()->MoveIdle(); }break; case 14: if(GETCRE(Maiev, MaievGUID)) diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_headless_horseman.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_headless_horseman.cpp index 013bebb860d..1fec7ccd88e 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_headless_horseman.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_headless_horseman.cpp @@ -709,7 +709,6 @@ void mob_headAI::Disappear() m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); m_creature->GetMotionMaster()->MoveIdle(); - m_creature->StopMoving(); ((boss_headless_horsemanAI*)body->AI())->returned = true; } } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp index be733b5c819..1498dbfb7ca 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp @@ -228,7 +228,6 @@ struct TRINITY_DLL_DECL advisorbase_ai : public ScriptedAI m_creature->InterruptNonMeleeSpells(false); m_creature->SetHealth(0); - m_creature->StopMoving(); m_creature->ClearComboPointHolders(); m_creature->RemoveAllAurasOnDeath(); m_creature->ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, false); @@ -864,7 +863,6 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI DoScriptText(SAY_PHASE5_NUTS, m_creature); - m_creature->StopMoving(); m_creature->GetMotionMaster()->Clear(); m_creature->GetMotionMaster()->MoveIdle(); DoTeleportTo(GRAVITY_X, GRAVITY_Y, GRAVITY_Z); @@ -928,7 +926,6 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI switch(GravityLapse_Phase) { case 0: - m_creature->StopMoving(); m_creature->GetMotionMaster()->Clear(); m_creature->GetMotionMaster()->MoveIdle(); DoTeleportTo(GRAVITY_X, GRAVITY_Y, GRAVITY_Z); diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 115906e94a3..d31e6dec1a1 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -478,7 +478,12 @@ void Creature::Update(uint32 diff) break; // if creature is charmed, switch to charmed AI - UpdateCharmAI(); + if(NeedChangeAI) + { + UpdateCharmAI(); + NeedChangeAI = false; + IsAIEnabled = true; + } if(!IsInEvadeMode() && IsAIEnabled) { @@ -1613,9 +1618,6 @@ void Creature::setDeathState(DeathState s) if (canFly() && FallGround()) return; - - if(!IsStopped()) - StopMoving(); } Unit::setDeathState(s); diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index 0fa85a4d9e2..3295c1149c5 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -63,7 +63,12 @@ void UnitAI::DoMeleeAttackIfReady() 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;*/ + me->NeedChangeAI = true; + me->IsAIEnabled = false; +} void CreatureAI::MoveInLineOfSight(Unit *who) { diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 74e10be31a8..b2988a43090 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -656,10 +656,13 @@ namespace Trinity AnyUnfriendlyNoTotemUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) {} bool operator()(Unit* u) { - if(u->isAlive() && i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(u) && !((Creature*)u)->isTotem()) - return true; - else + if(!u->isAlive()) + return false; + + if(u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->isTotem()) return false; + + return i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(u); } private: WorldObject const* i_obj; diff --git a/src/game/GuardAI.cpp b/src/game/GuardAI.cpp index 8fc8e3e143f..1aabe1beeda 100644 --- a/src/game/GuardAI.cpp +++ b/src/game/GuardAI.cpp @@ -62,7 +62,6 @@ void GuardAI::EnterEvadeMode() if( !i_creature.isAlive() ) { DEBUG_LOG("Creature stopped attacking because he's dead [guid=%u]", i_creature.GetGUIDLow()); - i_creature.StopMoving(); i_creature.GetMotionMaster()->MoveIdle(); i_state = STATE_NORMAL; diff --git a/src/game/IdleMovementGenerator.cpp b/src/game/IdleMovementGenerator.cpp index 56b4e883338..67f89303e40 100644 --- a/src/game/IdleMovementGenerator.cpp +++ b/src/game/IdleMovementGenerator.cpp @@ -23,6 +23,11 @@ IdleMovementGenerator si_idleMovement; +void IdleMovementGenerator::Initialize(Unit &owner) +{ + owner.StopMoving(); +} + void IdleMovementGenerator::Reset(Unit& /*owner*/) { diff --git a/src/game/IdleMovementGenerator.h b/src/game/IdleMovementGenerator.h index 7f1f41f9166..7ada9f08f52 100644 --- a/src/game/IdleMovementGenerator.h +++ b/src/game/IdleMovementGenerator.h @@ -27,7 +27,7 @@ class TRINITY_DLL_SPEC IdleMovementGenerator : public MovementGenerator { public: - void Initialize(Unit &) { } + void Initialize(Unit &); void Finalize(Unit &) { } void Reset(Unit &); bool Update(Unit &, const uint32 &) { return true; } diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index ba6d78f637e..c2aebff8bc4 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -7631,6 +7631,16 @@ CreatureInfo const *GetCreatureInfo(uint32 id) return objmgr.GetCreatureTemplate(id); } +CreatureInfo const* GetCreatureTemplateStore(uint32 entry) +{ + return sCreatureStorage.LookupEntry<CreatureInfo>(entry); +} + +Quest const* GetQuestTemplateStore(uint32 entry) +{ + return objmgr.GetQuestTemplate(entry); +} + void ObjectMgr::LoadTransportEvents() { diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index 068548ac8d7..b85d675e6a4 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -63,7 +63,6 @@ void PetAI::_stopAttack() if( !i_pet.isAlive() ) { DEBUG_LOG("Creature stoped attacking cuz his dead [guid=%u]", i_pet.GetGUIDLow()); - i_pet.StopMoving(); i_pet.GetMotionMaster()->Clear(); i_pet.GetMotionMaster()->MoveIdle(); i_pet.CombatStop(); diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index f158f3a8fcc..11caeb74a55 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -84,7 +84,6 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) case COMMAND_STAY: //flat=1792 //STAY pet->AttackStop(); pet->InterruptNonMeleeSpells(false); - pet->StopMoving(); pet->GetMotionMaster()->MoveIdle(); charmInfo->SetCommandState( COMMAND_STAY ); break; diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 6f7985331c7..064e4db969e 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -20158,7 +20158,7 @@ void Player::StopCastingBindSight() if (WorldObject* target = GetFarsightTarget()) { if (target->isType(TYPEMASK_UNIT)) - ((Unit*)target)->RemoveSpellsCausingAura(SPELL_AURA_BIND_SIGHT); + ((Unit*)target)->RemoveAuraTypeByCaster(SPELL_AURA_BIND_SIGHT, GetGUID()); } } diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index d69762d49a5..efca1bdc600 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -4187,6 +4187,7 @@ void Aura::HandleAuraModResistance(bool apply, bool Real) m_target->ApplyResistanceBuffModsMod(SpellSchools(x),m_positive,m_modifier.m_amount, apply); } } + } void Aura::HandleAuraModBaseResistancePCT(bool apply, bool Real) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index a8275c73b9a..d91a6bf83e6 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -77,7 +77,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) +, m_IsInNotifyList(false), m_Notified(false), IsAIEnabled(false), NeedChangeAI(false) , i_AI(NULL), i_disabledAI(NULL) { m_objectType |= TYPEMASK_UNIT; @@ -479,6 +479,28 @@ void Unit::RemoveSpellsCausingAura(AuraType auraType) } } +void Unit::RemoveAuraTypeByCaster(AuraType auraType, uint64 casterGUID) +{ + if (auraType >= TOTAL_AURAS) return; + AuraList::iterator iter, next; + for(iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end(); ++iter) + { + next = iter; + ++next; + + if (*iter) + { + RemoveAurasByCasterSpell((*iter)->GetId(), casterGUID); + continue; + RemoveAurasDueToSpell((*iter)->GetId()); + if (!m_modAuras[auraType].empty()) + next = m_modAuras[auraType].begin(); + else + return; + } + } +} + void Unit::RemoveSpellsCausingAuraWithDispel(AuraType auraType, Spell * spell) { if (auraType >= TOTAL_AURAS) return; @@ -498,7 +520,7 @@ void Unit::RemoveSpellsCausingAuraWithDispel(AuraType auraType, Spell * spell) else return; } - } + } std::deque <Aura *> dispel_list; @@ -10321,7 +10343,6 @@ void Unit::setDeathState(DeathState s) ClearDiminishings(); GetMotionMaster()->Clear(false); GetMotionMaster()->MoveIdle(); - StopMoving(); //without this when removing IncreaseMaxHealth aura player may stuck with 1 hp //do not why since in IncreaseMaxHealth currenthealth is checked SetHealth(0); @@ -13088,7 +13109,6 @@ void Unit::SetCharmedOrPossessedBy(Unit* charmer, bool possess) if(GetTypeId() == TYPEID_UNIT) { ((Creature*)this)->AI()->OnCharmed(true); - StopMoving(); GetMotionMaster()->Clear(false); GetMotionMaster()->MoveIdle(); } diff --git a/src/game/Unit.h b/src/game/Unit.h index 6c3fb560788..85f8a60409e 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1244,6 +1244,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void RemoveSpellsCausingAura(AuraType auraType); void RemoveSpellsCausingAuraWithDispel(AuraType auraType, Spell * spell); + void RemoveAuraTypeByCaster(AuraType auraType, uint64 casterGUID); void RemoveRankAurasDueToSpell(uint32 spellId); bool RemoveNoStackAurasDueToAura(Aura *Aur); void RemoveAurasWithInterruptFlags(uint32 flags, uint32 except = 0); @@ -1549,7 +1550,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject uint32 GetReducedThreatPercent() { return m_reducedThreatPercent; } Unit *GetMisdirectionTarget() { return m_misdirectionTargetGUID ? GetUnit(*this, m_misdirectionTargetGUID) : NULL; } - bool IsAIEnabled; + bool IsAIEnabled, NeedChangeAI; protected: explicit Unit (); |