From 4b82035006eef10efa5794da305488b838f16cd3 Mon Sep 17 00:00:00 2001 From: QAston Date: Thu, 12 Mar 2009 23:40:55 +0100 Subject: [PATCH 01/12] *Fix traps. Thanks to megamage for help. --HG-- branch : trunk --- src/game/GridNotifiers.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 8e427366f1a..ba487dec55f 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -600,8 +600,12 @@ 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()) + if(u->isAlive() && i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(u)) + { + if (u->GetTypeId()==TYPEID_UNIT && !((Creature*)u)->isTotem()) + return false; return true; + } else return false; } From 17e0c43d20a644aa65df9364762952679ee1f7c6 Mon Sep 17 00:00:00 2001 From: megamage Date: Thu, 12 Mar 2009 17:10:23 -0600 Subject: [PATCH 02/12] *Fix a typo of that last rev. --HG-- branch : trunk --- src/game/GridNotifiers.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index ba487dec55f..daa8296674a 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -600,14 +600,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)) - { - if (u->GetTypeId()==TYPEID_UNIT && !((Creature*)u)->isTotem()) - return false; - 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; From 5e4986ad3a2f4f70e1754b94d5ca631a4f193774 Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 13 Mar 2009 14:21:15 -0600 Subject: [PATCH 03/12] *Update event ai. By nofantasy. --HG-- branch : trunk --- .../scripts/scripts/creature/mob_event_ai.cpp | 86 ++++++++++++++++--- .../scripts/scripts/creature/mob_event_ai.h | 79 ++++++++--------- 2 files changed, 115 insertions(+), 50 deletions(-) diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp index 89151cd494b..d6396dfae99 100644 --- a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp +++ b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp @@ -23,6 +23,7 @@ EndScriptData */ #include "precompiled.h" #include "mob_event_ai.h" +#include "ObjectMgr.h" #define EVENT_UPDATE_TIME 500 #define SPELL_RUN_AWAY 8225 @@ -454,6 +455,10 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI } } break; + case EVENT_T_REACHED_HOME: + { + } + break; default: if (EAI_ErrorLevel > 0) error_db_log("SD2: Creature %u using Event %u has invalid Event Type(%u), missing from ProcessEvent() Switch.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); @@ -577,6 +582,43 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI } } break; + case ACTION_T_SET_FACTION: + { + if (param1) + m_creature->setFaction(param1); + else + { + if (CreatureInfo const* ci = GetCreatureTemplateStore(m_creature->GetEntry())) + { + //if no id provided, assume reset and then use default + if (m_creature->getFaction() != ci->faction_A) + m_creature->setFaction(ci->faction_A); + } + } + } + break; + case ACTION_T_MORPH_TO_ENTRY_OR_MODEL: + { + if (param1 || param2) + { + //set model based on entry from creature_template + if (param1) + { + if (CreatureInfo const* ci = GetCreatureTemplateStore(param1)) + { + //use default display + if (ci->DisplayID_A) + m_creature->SetDisplayId(ci->DisplayID_A); + } + } + //if no param1, then use value from param2 (modelId) + else + m_creature->SetDisplayId(param2); + } + else + m_creature->DeMorph(); + } + break; case ACTION_T_SOUND: DoPlaySoundToSet(m_creature, param1); break; @@ -720,6 +762,9 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI { Unit* target = GetTargetByType(param3, pActionInvoker); + if (param1 < OBJECT_END || param1 >= UNIT_END) + return; + if (target) target->SetUInt32Value(param1, param2); } @@ -1004,7 +1049,7 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI EventUpdateTime = EVENT_UPDATE_TIME; EventDiff = 0; - //Handle Evade events and reset all events to enabled + //Reset all events to enabled for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) { switch ((*i).Event.event_type) @@ -1033,6 +1078,20 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI } } + //when creature reach home after EnterEvadeMode + void JustReachedHome() + { + m_creature->LoadCreaturesAddon(); + + for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) + { + if ((*i).Event.event_type == EVENT_T_REACHED_HOME) + ProcessEvent(*i); + } + + Reset(); + } + void EnterEvadeMode() { ScriptedAI::EnterEvadeMode(); @@ -1042,13 +1101,8 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI //Handle Evade events for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) { - switch ((*i).Event.event_type) - { - //Evade - case EVENT_T_EVADE: - ProcessEvent(*i); - break; - } + if ((*i).Event.event_type == EVENT_T_EVADE) + ProcessEvent(*i); } } @@ -1290,9 +1344,9 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI else (*i).Time = 0; } + //Events that are updated every EVENT_UPDATE_TIME switch ((*i).Event.event_type) { - //Events that are updated every EVENT_UPDATE_TIME case EVENT_T_TIMER_OOC: ProcessEvent(*i); break; @@ -1302,9 +1356,19 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI case EVENT_T_TARGET_HP: case EVENT_T_TARGET_CASTING: case EVENT_T_FRIENDLY_HP: - if( Combat ) + if (Combat) ProcessEvent(*i); break; + case EVENT_T_RANGE: + if (Combat) + { + if (m_creature->IsWithinDistInMap(m_creature->getVictim(),(float)(*i).Event.event_param2)) + { + if (m_creature->GetDistance(m_creature->getVictim()) >= (float)(*i).Event.event_param1) + ProcessEvent(*i); + } + } + break; } } @@ -1391,7 +1455,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/creature/mob_event_ai.h b/src/bindings/scripts/scripts/creature/mob_event_ai.h index fafd21b3543..39bf050cd70 100644 --- a/src/bindings/scripts/scripts/creature/mob_event_ai.h +++ b/src/bindings/scripts/scripts/creature/mob_event_ai.h @@ -30,51 +30,52 @@ enum Event_Types EVENT_T_TARGET_MANA = 18, //ManaMax%, ManaMin%, RepeatMin, RepeatMax EVENT_T_QUEST_ACCEPT = 19, //QuestID EVENT_T_QUEST_COMPLETE = 20, // + EVENT_T_REACHED_HOME = 21, //NONE EVENT_T_END, }; enum Action_Types { - ACTION_T_NONE = 0, //No action - ACTION_T_TEXT = 1, //-TextId1, optionally -TextId2, optionally -TextId3(if -TextId2 exist). If more than just -TextId1 is defined, randomize. Negative values. - ACTION_T_YELL = 2, //UNUSED - ACTION_T_TEXTEMOTE = 3, //UNUSED - ACTION_T_SOUND = 4, //SoundId - ACTION_T_EMOTE = 5, //EmoteId - ACTION_T_RANDOM_SAY = 6, //UNUSED - ACTION_T_RANDOM_YELL = 7, //UNUSED - ACTION_T_RANDOM_TEXTEMOTE = 8, //UNUSED - ACTION_T_RANDOM_SOUND = 9, //SoundId1, SoundId2, SoundId3 (-1 in any field means no output if randomed that field) - ACTION_T_RANDOM_EMOTE = 10, //EmoteId1, EmoteId2, EmoteId3 (-1 in any field means no output if randomed that field) - ACTION_T_CAST = 11, //SpellId, Target, CastFlags - ACTION_T_SUMMON = 12, //CreatureID, Target, Duration in ms - ACTION_T_THREAT_SINGLE_PCT = 13, //Threat%, Target - ACTION_T_THREAT_ALL_PCT = 14, //Threat% - ACTION_T_QUEST_EVENT = 15, //QuestID, Target - ACTION_T_CASTCREATUREGO = 16, //QuestID, SpellId, Target - ACTION_T_SET_UNIT_FIELD = 17, //Field_Number, Value, Target - ACTION_T_SET_UNIT_FLAG = 18, //Flags (may be more than one field OR'd together), Target - ACTION_T_REMOVE_UNIT_FLAG = 19, //Flags (may be more than one field OR'd together), Target - ACTION_T_AUTO_ATTACK = 20, //AllowAttackState (0 = stop attack, anything else means continue attacking) - ACTION_T_COMBAT_MOVEMENT = 21, //AllowCombatMovement (0 = stop combat based movement, anything else continue attacking) - ACTION_T_SET_PHASE = 22, //Phase - ACTION_T_INC_PHASE = 23, //Value (may be negative to decrement phase, should not be 0) - ACTION_T_EVADE = 24, //No Params - ACTION_T_FLEE = 25, //No Params - ACTION_T_QUEST_EVENT_ALL = 26, //QuestID - ACTION_T_CASTCREATUREGO_ALL = 27, //QuestId, SpellId - ACTION_T_REMOVEAURASFROMSPELL = 28, //Target, Spellid - ACTION_T_RANGED_MOVEMENT = 29, //Distance, Angle - ACTION_T_RANDOM_PHASE = 30, //PhaseId1, PhaseId2, PhaseId3 - ACTION_T_RANDOM_PHASE_RANGE = 31, //PhaseMin, PhaseMax - ACTION_T_SUMMON_ID = 32, //CreatureId, Target, SpawnId - ACTION_T_KILLED_MONSTER = 33, //CreatureId, Target - ACTION_T_SET_INST_DATA = 34, //Field, Data - ACTION_T_SET_INST_DATA64 = 35, //Field, Target - ACTION_T_UPDATE_TEMPLATE = 36, //Entry, Team - ACTION_T_DIE = 37, //No Params - ACTION_T_ZONE_COMBAT_PULSE = 38, //No Params + ACTION_T_NONE = 0, //No action + ACTION_T_TEXT = 1, //-TextId1, optionally -TextId2, optionally -TextId3(if -TextId2 exist). If more than just -TextId1 is defined, randomize. Negative values. + ACTION_T_SET_FACTION = 2, //FactionId (or 0 for default) + ACTION_T_MORPH_TO_ENTRY_OR_MODEL = 3, //Creature_template entry(param1) OR ModelId (param2) (or 0 for both to demorph) + ACTION_T_SOUND = 4, //SoundId + ACTION_T_EMOTE = 5, //EmoteId + ACTION_T_RANDOM_SAY = 6, //UNUSED + ACTION_T_RANDOM_YELL = 7, //UNUSED + ACTION_T_RANDOM_TEXTEMOTE = 8, //UNUSED + ACTION_T_RANDOM_SOUND = 9, //SoundId1, SoundId2, SoundId3 (-1 in any field means no output if randomed that field) + ACTION_T_RANDOM_EMOTE = 10, //EmoteId1, EmoteId2, EmoteId3 (-1 in any field means no output if randomed that field) + ACTION_T_CAST = 11, //SpellId, Target, CastFlags + ACTION_T_SUMMON = 12, //CreatureID, Target, Duration in ms + ACTION_T_THREAT_SINGLE_PCT = 13, //Threat%, Target + ACTION_T_THREAT_ALL_PCT = 14, //Threat% + ACTION_T_QUEST_EVENT = 15, //QuestID, Target + ACTION_T_CASTCREATUREGO = 16, //QuestID, SpellId, Target + ACTION_T_SET_UNIT_FIELD = 17, //Field_Number, Value, Target + ACTION_T_SET_UNIT_FLAG = 18, //Flags (may be more than one field OR'd together), Target + ACTION_T_REMOVE_UNIT_FLAG = 19, //Flags (may be more than one field OR'd together), Target + ACTION_T_AUTO_ATTACK = 20, //AllowAttackState (0 = stop attack, anything else means continue attacking) + ACTION_T_COMBAT_MOVEMENT = 21, //AllowCombatMovement (0 = stop combat based movement, anything else continue attacking) + ACTION_T_SET_PHASE = 22, //Phase + ACTION_T_INC_PHASE = 23, //Value (may be negative to decrement phase, should not be 0) + ACTION_T_EVADE = 24, //No Params + ACTION_T_FLEE = 25, //No Params + ACTION_T_QUEST_EVENT_ALL = 26, //QuestID + ACTION_T_CASTCREATUREGO_ALL = 27, //QuestId, SpellId + ACTION_T_REMOVEAURASFROMSPELL = 28, //Target, Spellid + ACTION_T_RANGED_MOVEMENT = 29, //Distance, Angle + ACTION_T_RANDOM_PHASE = 30, //PhaseId1, PhaseId2, PhaseId3 + ACTION_T_RANDOM_PHASE_RANGE = 31, //PhaseMin, PhaseMax + ACTION_T_SUMMON_ID = 32, //CreatureId, Target, SpawnId + ACTION_T_KILLED_MONSTER = 33, //CreatureId, Target + ACTION_T_SET_INST_DATA = 34, //Field, Data + ACTION_T_SET_INST_DATA64 = 35, //Field, Target + ACTION_T_UPDATE_TEMPLATE = 36, //Entry, Team + ACTION_T_DIE = 37, //No Params + ACTION_T_ZONE_COMBAT_PULSE = 38, //No Params ACTION_T_SET_ACTIVE = 101, //Apply ACTION_T_SET_AGGRESSIVE = 102, //Apply From be90383b1337a630eb1417a4555890df6b7c92e5 Mon Sep 17 00:00:00 2001 From: QAston Date: Fri, 13 Mar 2009 21:24:02 +0100 Subject: [PATCH 04/12] *Fix Glowing Blood. --HG-- branch : trunk --- src/game/SpellAuras.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 99adb488eb1..4b868812b16 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -4013,9 +4013,10 @@ void Aura::HandleAuraModResistance(bool apply, bool Real) } // Faerie Fire (druid versions) - if( m_spellProto->SpellIconID == 109 && + if( (m_spellProto->SpellIconID == 109 && m_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && - m_spellProto->SpellFamilyFlags & 0x0000000000000400LL ) + m_spellProto->SpellFamilyFlags & 0x0000000000000400LL) + || m_spellProto->Id == 35325) { m_target->ModifyAuraState(AURA_STATE_FAERIE_FIRE,apply); } From bb7391f129e831cd5daac17d54245738571c5d32 Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 13 Mar 2009 14:28:28 -0600 Subject: [PATCH 05/12] *Update event ai. Do not clear motionmaster. --HG-- branch : trunk --- .../scripts/scripts/creature/mob_event_ai.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp index d6396dfae99..54b29e07651 100644 --- a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp +++ b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp @@ -684,7 +684,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); } @@ -799,19 +798,13 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI //Allow movement (create new targeted movement gen if none exist already) if (CombatMovementEnabled) { - if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_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(); + m_creature->StopMoving(); + } } break; case ACTION_T_SET_PHASE: @@ -881,8 +874,6 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI if (CombatMovementEnabled) { - //Drop current movement gen - m_creature->GetMotionMaster()->Clear(false); m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle); } } From 146b2560aa8a7d0fc8a90ec3af70d1a8e01e514d Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 13 Mar 2009 14:42:57 -0600 Subject: [PATCH 06/12] *Call stopmoving in moveidle. --HG-- branch : trunk --- src/bindings/scripts/include/sc_creature.cpp | 1 - src/bindings/scripts/scripts/creature/mob_event_ai.cpp | 2 -- src/bindings/scripts/scripts/zone/azshara/azshara.cpp | 4 +--- .../scripts/scripts/zone/black_temple/boss_illidan.cpp | 8 ++++---- .../scripts/scripts/zone/karazhan/bosses_opera.cpp | 1 - .../zone/scarlet_monastery/boss_headless_horseman.cpp | 1 - .../scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp | 3 --- src/game/Creature.cpp | 3 --- src/game/GuardAI.cpp | 1 - src/game/IdleMovementGenerator.cpp | 5 +++++ src/game/IdleMovementGenerator.h | 2 +- src/game/PetAI.cpp | 1 - src/game/PetHandler.cpp | 1 - src/game/Unit.cpp | 2 -- 14 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp index be37c66c740..f30ae9408c5 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 54b29e07651..41a509cefa8 100644 --- a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp +++ b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp @@ -803,7 +803,6 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI else { m_creature->GetMotionMaster()->MoveIdle(); - m_creature->StopMoving(); } } break; @@ -1209,7 +1208,6 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI else { m_creature->GetMotionMaster()->MoveIdle(); - m_creature->StopMoving(); } } } diff --git a/src/bindings/scripts/scripts/zone/azshara/azshara.cpp b/src/bindings/scripts/scripts/zone/azshara/azshara.cpp index 4ed71f89c55..d71101d4898 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 dba57924e56..1c2856fdd14 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp @@ -1079,8 +1079,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); } @@ -1912,8 +1912,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/karazhan/bosses_opera.cpp b/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp index 8478bdca284..2d4a644bf67 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp @@ -895,7 +895,6 @@ void PretendToDie(Creature* _Creature) { _Creature->InterruptNonMeleeSpells(false); _Creature->SetHealth(0); - _Creature->StopMoving(); _Creature->ClearComboPointHolders(); _Creature->RemoveAllAurasOnDeath(); _Creature->ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, false); 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 7bbbd4d4bc9..0bcfd6ba49b 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 7d22b76ac70..2cb92f07600 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 ed2f3f2ee54..df56a3ac27f 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1620,9 +1620,6 @@ void Creature::setDeathState(DeathState s) if (canFly() && FallGround()) return; - - if(!IsStopped()) - StopMoving(); } Unit::setDeathState(s); diff --git a/src/game/GuardAI.cpp b/src/game/GuardAI.cpp index 0a892961f4d..07a5bd9f819 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 ff21643c2b0..c6598409b44 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 3719f7bc7d7..ac5a4da529c 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/PetAI.cpp b/src/game/PetAI.cpp index 72c8c1e760b..ad11a49c07d 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 49a3bb95cb7..456d68ed54d 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -87,7 +87,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/Unit.cpp b/src/game/Unit.cpp index e3e11c2e840..d8c4d3bb16a 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -10394,7 +10394,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); @@ -13138,7 +13137,6 @@ void Unit::SetCharmedOrPossessedBy(Unit* charmer, bool possess) if(GetTypeId() == TYPEID_UNIT) { ((Creature*)this)->AI()->OnCharmed(true); - StopMoving(); GetMotionMaster()->Clear(false); GetMotionMaster()->MoveIdle(); } From 5ea92ebb129fd868bcb5049616266b4d4db6f1f4 Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 13 Mar 2009 14:57:42 -0600 Subject: [PATCH 07/12] *Fix a bug of checking bags which can store items. Backported from TC2. Thanks to Iskander for pointing out the bug. --HG-- branch : trunk --- src/game/Player.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 6345a8d2d1f..3ed59445d88 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -9657,6 +9657,12 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t ); if( pBag ) { + pBagProto = pBag->GetProto(); + + // special bag already checked + if( pBagProto && (pBagProto->Class != ITEM_CLASS_CONTAINER || pBagProto->SubClass != ITEM_SUBCLASS_CONTAINER)) + continue; + for(uint32 j = 0; j < pBag->GetBagSize(); j++) { if( inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0 ) From 7c33373289e236520d5150476cbe30ef42045153 Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 13 Mar 2009 17:14:02 -0600 Subject: [PATCH 08/12] *Merge more contents from SD2. By nofantasy. Also backport some content from TC2. --HG-- branch : trunk --- src/bindings/scripts/ScriptMgr.cpp | 136 +++++++++++++++--- .../scripts/scripts/creature/mob_event_ai.cpp | 4 +- src/game/ObjectMgr.cpp | 10 ++ src/game/ObjectMgr.h | 2 + 4 files changed, 134 insertions(+), 18 deletions(-) diff --git a/src/bindings/scripts/ScriptMgr.cpp b/src/bindings/scripts/ScriptMgr.cpp index eb7e6dafa7b..311d8fe60bf 100644 --- a/src/bindings/scripts/ScriptMgr.cpp +++ b/src/bindings/scripts/ScriptMgr.cpp @@ -928,6 +928,10 @@ void LoadDatabase() temp.event_param3 = fields[8].GetUInt32(); temp.event_param4 = fields[9].GetUInt32(); + //Creature does not exist in database + if (!GetCreatureTemplateStore(temp.creature_id)) + 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) error_db_log("TSCR: Event %u has incorrect event type. Maybe DB requires updated version of SD2.", i); @@ -1023,6 +1027,7 @@ void LoadDatabase() case EVENT_T_DEATH: case EVENT_T_EVADE: case EVENT_T_SPAWNED: + case EVENT_T_REACHED_HOME: { if (temp.event_flags & EFLAG_REPEATABLE) { @@ -1068,7 +1073,29 @@ void LoadDatabase() } } break; + case ACTION_T_SET_FACTION: + if (temp.action[j].param1 !=0 && !GetFactionStore()->LookupEntry(temp.action[j].param1)) + { + error_db_log("SD2: Event %u Action %u uses non-existant FactionId %u.", i, j+1, temp.action[j].param1); + temp.action[j].param1 = 0; + } + break; + case ACTION_T_MORPH_TO_ENTRY_OR_MODEL: + if (temp.action[j].param1 !=0 || temp.action[j].param2 !=0) + { + if (temp.action[j].param1 && !GetCreatureTemplateStore(temp.action[j].param1)) + { + error_db_log("TSCR: Event %u Action %u uses non-existant Creature entry %u.", i, j+1, temp.action[j].param1); + temp.action[j].param1 = 0; + } + if (temp.action[j].param2 && !GetCreatureDisplayStore()->LookupEntry(temp.action[j].param2)) + { + error_db_log("TSCR: Event %u Action %u uses non-existant ModelId %u.", i, j+1, temp.action[j].param2); + temp.action[j].param2 = 0; + } + } + break; case ACTION_T_SOUND: if (!GetSoundEntriesStore()->LookupEntry(temp.action[j].param1)) error_db_log("TSCR: Event %u Action %u uses non-existant SoundID %u.", i, j+1, temp.action[j].param1); @@ -1087,8 +1114,18 @@ void LoadDatabase() case ACTION_T_CAST: { - if (!GetSpellStore()->LookupEntry(temp.action[j].param1)) - error_db_log("TSCR: Event %u Action %u uses non-existant SpellID %u.", i, j+1, temp.action[j].param1); + const SpellEntry *spell = GetSpellStore()->LookupEntry(temp.action[j].param1); + if (!spell) + 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) + { + //output as debug for now, also because there's no general rule all spells have RecoveryTime + if (temp.event_param3 < spell->RecoveryTime) + debug_log("SD2: Event %u Action %u uses SpellID %u but cooldown is longer(%u) than minumum defined in event param3(%u).", i, j+1,temp.action[j].param1, spell->RecoveryTime, temp.event_param3); + } + } if (temp.action[j].param2 >= TARGET_T_END) error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); @@ -1104,20 +1141,59 @@ void LoadDatabase() error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); } break; + case ACTION_T_QUEST_EVENT: + { + if (Quest const* qid = GetQuestTemplateStore(temp.action[j].param1)) + { + if (!qid->HasFlag(QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT)) + error_db_log("SD2: Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j+1, temp.action[j].param1); + } + else + error_db_log("SD2: Event %u Action %u uses non-existant Quest entry %u.", i, j+1, temp.action[j].param1); + if (temp.action[j].param2 >= TARGET_T_END) + error_db_log("SD2: Event %u Action %u uses incorrect Target type", i, j+1); + } + break; + case ACTION_T_QUEST_EVENT_ALL: + { + if (Quest const* qid = GetQuestTemplateStore(temp.action[j].param1)) + { + if (!qid->HasFlag(QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT)) + error_db_log("SD2: Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j+1, temp.action[j].param1); + } + else + error_db_log("SD2: Event %u Action %u uses non-existant Quest entry %u.", i, j+1, temp.action[j].param1); + } + break; case ACTION_T_CASTCREATUREGO: { + if (!GetCreatureTemplateStore(temp.action[j].param1)) + error_db_log("SD2: Event %u Action %u uses non-existant creature entry %u.", i, j+1, temp.action[j].param1); + if (!GetSpellStore()->LookupEntry(temp.action[j].param2)) 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: + { + if (!GetQuestTemplateStore(temp.action[j].param1)) + error_db_log("SD2: Event %u Action %u uses non-existant Quest entry %u.", i, j+1, temp.action[j].param1); + + if (!GetSpellStore()->LookupEntry(temp.action[j].param2)) + error_db_log("SD2: Event %u Action %u uses non-existant SpellID %u.", i, j+1, temp.action[j].param2); } break; //2nd param target case ACTION_T_SUMMON_ID: { + if (!GetCreatureTemplateStore(temp.action[j].param1)) + error_db_log("SD2: Event %u Action %u uses non-existant creature entry %u.", i, j+1, temp.action[j].param1); + if (EventAI_Summon_Map.find(temp.action[j].param3) == EventAI_Summon_Map.end()) error_db_log("TSCR: Event %u Action %u summons missing EventAI_Summon %u", i, j+1, temp.action[j].param3); @@ -1125,19 +1201,35 @@ void LoadDatabase() error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); } break; + case ACTION_T_KILLED_MONSTER: + { + if (!GetCreatureTemplateStore(temp.action[j].param1)) + error_db_log("SD2: Event %u Action %u uses non-existant creature entry %u.", i, j+1, temp.action[j].param1); + if (temp.action[j].param2 >= TARGET_T_END) + error_db_log("SD2: Event %u Action %u uses incorrect Target type", i, j+1); + } + break; case ACTION_T_SUMMON: + { + if (!GetCreatureTemplateStore(temp.action[j].param1)) + error_db_log("SD2: Event %u Action %u uses non-existant creature entry %u.", i, j+1, temp.action[j].param1); + + if (temp.action[j].param2 >= TARGET_T_END) + error_db_log("SD2: Event %u Action %u uses incorrect Target type", i, j+1); + } + break; case ACTION_T_THREAT_SINGLE_PCT: - case ACTION_T_QUEST_EVENT: case ACTION_T_SET_UNIT_FLAG: case ACTION_T_REMOVE_UNIT_FLAG: - case ACTION_T_SET_INST_DATA64: if (temp.action[j].param2 >= TARGET_T_END) error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); break; //3rd param target case ACTION_T_SET_UNIT_FIELD: + if (temp.action[j].param1 < OBJECT_END || temp.action[j].param1 >= UNIT_END) + error_db_log("SD2: Event %u Action %u param1 (UNIT_FIELD*). Index out of range for intended use.", i, j+1); if (temp.action[j].param3 >= TARGET_T_END) error_db_log("TSCR: Event %u Action %u uses incorrect Target type", i, j+1); break; @@ -1149,21 +1241,33 @@ 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); - break; - - case ACTION_T_KILLED_MONSTER: - if (temp.event_type != EVENT_T_DEATH) - outstring_log("SD2 WARNING: Event %u Action %u calling ACTION_T_KILLED_MONSTER outside of EVENT_T_DEATH", 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: - if (temp.action[j].param2 > SPECIAL) - error_db_log("TSCR2: Event %u Action %u attempts to set instance data above encounter state 4. Custom case?", i, j+1); - break; + { + if (!(temp.event_flags & EFLAG_NORMAL) && !(temp.event_flags & EFLAG_HEROIC)) + error_db_log("SD2: Event %u Action %u. Cannot set instance data without event flags (normal/heroic).", i, j+1); - case ACTION_T_YELL: - case ACTION_T_TEXTEMOTE: + if (temp.action[j].param2 > SPECIAL) + error_db_log("SD2: Event %u Action %u attempts to set instance data above encounter state 4. Custom case?", i, j+1); + } + break; + case ACTION_T_SET_INST_DATA64: + { + if (!(temp.event_flags & EFLAG_NORMAL) && !(temp.event_flags & EFLAG_HEROIC)) + error_db_log("SD2: Event %u Action %u. Cannot set instance data without event flags (normal/heroic).", i, j+1); + + if (temp.action[j].param2 >= TARGET_T_END) + error_db_log("SD2: Event %u Action %u uses incorrect Target type", i, j+1); + } + break; + case ACTION_T_UPDATE_TEMPLATE: + { + if (!GetCreatureTemplateStore(temp.action[j].param1)) + error_db_log("SD2: Event %u Action %u uses non-existant creature entry %u.", i, j+1, temp.action[j].param1); + } + break; case ACTION_T_RANDOM_SAY: case ACTION_T_RANDOM_YELL: case ACTION_T_RANDOM_TEXTEMOTE: diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp index 41a509cefa8..726bd1fb419 100644 --- a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp +++ b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp @@ -607,8 +607,8 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI if (CreatureInfo const* ci = GetCreatureTemplateStore(param1)) { //use default display - if (ci->DisplayID_A) - m_creature->SetDisplayId(ci->DisplayID_A); + if (ci->Modelid1) + m_creature->SetDisplayId(ci->Modelid1); } } //if no param1, then use value from param2 (modelId) diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 7da8e89b26b..fbe22bea64b 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -7257,6 +7257,16 @@ CreatureInfo const *GetCreatureInfo(uint32 id) return objmgr.GetCreatureTemplate(id); } +CreatureInfo const* GetCreatureTemplateStore(uint32 entry) +{ + return sCreatureStorage.LookupEntry(entry); +} + +Quest const* GetQuestTemplateStore(uint32 entry) +{ + return objmgr.GetQuestTemplate(entry); +} + void ObjectMgr::LoadTransportEvents() { diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 5489bf7e42f..bb2866d55c7 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -907,6 +907,8 @@ TRINITY_DLL_SPEC uint32 GetScriptId(const char *name); TRINITY_DLL_SPEC ObjectMgr::ScriptNameMap& GetScriptNames(); TRINITY_DLL_SPEC GameObjectInfo const *GetGameObjectInfo(uint32 id); TRINITY_DLL_SPEC CreatureInfo const *GetCreatureInfo(uint32 id); +TRINITY_DLL_SPEC CreatureInfo const* GetCreatureTemplateStore(uint32 entry); +TRINITY_DLL_SPEC Quest const* GetQuestTemplateStore(uint32 entry); #endif From 7dd699c076b5ff212b819c7b9dcf5707958f9be5 Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 13 Mar 2009 17:25:46 -0600 Subject: [PATCH 09/12] *Remove aura type by caster in some cases. New function RemoveAuraTypeByCaster. --HG-- branch : trunk --- src/game/Player.cpp | 4 +-- src/game/Player.h | 3 +-- src/game/Spell.cpp | 4 +-- src/game/SpellEffects.cpp | 4 +-- src/game/Unit.cpp | 57 ++++++++++++++++++++++++++------------- src/game/Unit.h | 3 ++- 6 files changed, 47 insertions(+), 28 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 3ed59445d88..78ac6dc3958 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -19129,8 +19129,8 @@ void Player::StopCastingBindSight() { if (WorldObject* fTarget = GetFarsightTarget()) { - if (fTarget->isType(TYPEMASK_PLAYER | TYPEMASK_UNIT)) - ((Unit*)fTarget)->RemoveSpellsCausingAura(SPELL_AURA_BIND_SIGHT); + if (fTarget->isType(TYPEMASK_UNIT)) + ((Unit*)fTarget)->RemoveAuraTypeByCaster(SPELL_AURA_BIND_SIGHT, GetGUID()); } } diff --git a/src/game/Player.h b/src/game/Player.h index 53dcf84d5b5..0003c6d85bc 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -914,10 +914,9 @@ class TRINITY_DLL_SPEC Player : public Unit void SetViewport(uint64 guid, bool movable); void StopCastingCharm() { Uncharm(); } - void StopBindSight(); + void StopCastingBindSight(); WorldObject* GetFarsightTarget() const; void ClearFarsight(); - void StopCastingBindSight(); void SetFarsightTarget(WorldObject* target); // Controls if vision is currently on farsight object, updated in FAR_SIGHT opcode void SetFarsightVision(bool apply) { m_farsightVision = apply; } diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 9f5ed2a4e02..04310f2c6c8 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2141,11 +2141,11 @@ void Spell::cancel() { Unit* unit = m_caster->GetGUID()==(*ihit).targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); if( unit && unit->isAlive() ) - unit->RemoveAurasDueToCasterSpell(m_spellInfo->Id, m_caster->GetGUID()); + unit->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetGUID()); } } - m_caster->RemoveAurasDueToCasterSpell(m_spellInfo->Id, m_caster->GetGUID()); + m_caster->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetGUID()); SendChannelUpdate(0); SendInterrupted(0); SendCastResult(SPELL_FAILED_INTERRUPTED); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 32aeb1a7968..d7e236b4be6 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -418,7 +418,7 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx) if( (*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && ((*i)->GetSpellProto()->SpellFamilyFlags & 4) && (*i)->GetCasterGUID()==m_caster->GetGUID() ) { - unitTarget->RemoveAurasDueToCasterSpell((*i)->GetId(), m_caster->GetGUID()); + unitTarget->RemoveAurasByCasterSpell((*i)->GetId(), m_caster->GetGUID()); break; } } @@ -2437,7 +2437,7 @@ void Spell::SpellDamageHeal(uint32 /*i*/) } } addhealth += tickheal * tickcount; - unitTarget->RemoveAurasDueToCasterSpell(targetAura->GetId(), targetAura->GetCasterGUID()); + unitTarget->RemoveAurasByCasterSpell(targetAura->GetId(), targetAura->GetCasterGUID()); //addhealth += tickheal * tickcount; //addhealth = caster->SpellHealingBonus(m_spellInfo, addhealth,HEAL, unitTarget); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index d8c4d3bb16a..886020459b1 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -535,6 +535,26 @@ 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); + if (!m_modAuras[auraType].empty()) + next = m_modAuras[auraType].begin(); + else + return; + } + } +} + void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except) { if(!(m_interruptMask & flag)) @@ -4454,6 +4474,24 @@ void Unit::RemoveAura(uint32 spellId, uint32 effindex, Aura* except) } } +void Unit::RemoveAurasByCasterSpell(uint32 spellId, uint64 casterGUID) +{ + for(int k = 0; k < 3; ++k) + { + spellEffectPair spair = spellEffectPair(spellId, k); + for (AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair);) + { + if (iter->second->GetCasterGUID() == casterGUID) + { + RemoveAura(iter); + iter = m_Auras.upper_bound(spair); // overwrite by more appropriate + } + else + ++iter; + } + } +} + void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit *dispeler) { for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) @@ -4596,25 +4634,6 @@ void Unit::RemoveAurasDueToSpell(uint32 spellId, Aura* except) RemoveAura(spellId,i,except); } -void Unit::RemoveAurasDueToCasterSpell(uint32 spellId, uint64 guid) -{ - for (int k=0; k < 3; ++k) - { - spellEffectPair spair = spellEffectPair(spellId, k); - for (AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair);) - { - if (iter->second->GetCasterGUID() == guid) - { - RemoveAura(iter); - break; - //iter = m_Auras.upper_bound(spair); // overwrite by more appropriate - } - else - ++iter; - } - } -} - void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId) { for (int k=0; k < 3; ++k) diff --git a/src/game/Unit.h b/src/game/Unit.h index f73a5386aef..d3455d83baa 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1127,7 +1127,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void RemoveSingleAuraFromStack(uint32 spellId, uint32 effindex); void RemoveAurasDueToSpell(uint32 spellId, Aura* except = NULL); void RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId); - void RemoveAurasDueToCasterSpell(uint32 spellId, uint64 guid); + void RemoveAurasByCasterSpell(uint32 spellId, uint64 casterGUID); void RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit *dispeler); void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer); void RemoveAurasDueToSpellByCancel(uint32 spellId); @@ -1135,6 +1135,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void RemoveNotOwnSingleTargetAuras(); void RemoveSpellsCausingAura(AuraType auraType); + void RemoveAuraTypeByCaster(AuraType auraType, uint64 casterGUID); void RemoveRankAurasDueToSpell(uint32 spellId); bool RemoveNoStackAurasDueToAura(Aura *Aur); void RemoveAurasWithInterruptFlags(uint32 flags, uint32 except = 0); From 5f2edfc7e899d7c6997e679f1b9737fb5e7e8d4d Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 13 Mar 2009 17:34:23 -0600 Subject: [PATCH 10/12] *Fix build. --HG-- branch : trunk --- src/bindings/scripts/ScriptMgr.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bindings/scripts/ScriptMgr.cpp b/src/bindings/scripts/ScriptMgr.cpp index 311d8fe60bf..728bc435d81 100644 --- a/src/bindings/scripts/ScriptMgr.cpp +++ b/src/bindings/scripts/ScriptMgr.cpp @@ -1074,11 +1074,11 @@ void LoadDatabase() } break; case ACTION_T_SET_FACTION: - if (temp.action[j].param1 !=0 && !GetFactionStore()->LookupEntry(temp.action[j].param1)) + /*if (temp.action[j].param1 !=0 && !GetFactionStore()->LookupEntry(temp.action[j].param1)) { error_db_log("SD2: Event %u Action %u uses non-existant FactionId %u.", i, j+1, temp.action[j].param1); temp.action[j].param1 = 0; - } + }*/ break; case ACTION_T_MORPH_TO_ENTRY_OR_MODEL: if (temp.action[j].param1 !=0 || temp.action[j].param2 !=0) @@ -1089,11 +1089,11 @@ void LoadDatabase() temp.action[j].param1 = 0; } - if (temp.action[j].param2 && !GetCreatureDisplayStore()->LookupEntry(temp.action[j].param2)) + /*if (temp.action[j].param2 && !GetCreatureDisplayStore()->LookupEntry(temp.action[j].param2)) { error_db_log("TSCR: Event %u Action %u uses non-existant ModelId %u.", i, j+1, temp.action[j].param2); temp.action[j].param2 = 0; - } + }*/ } break; case ACTION_T_SOUND: From ce4c9cb2aeca0000e6ec7cccf5ae0951ad1e1266 Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 13 Mar 2009 17:48:57 -0600 Subject: [PATCH 11/12] *Allow not to switch to charmed AI for some scripts. --HG-- branch : trunk --- src/game/Creature.cpp | 7 ++++++- src/game/CreatureAI.cpp | 7 ++++++- src/game/Unit.cpp | 2 +- src/game/Unit.h | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index df56a3ac27f..8a5e6e52018 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -484,7 +484,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) { diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index 2d7eeeb18ff..9d9a3fc3a63 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/Unit.cpp b/src/game/Unit.cpp index 886020459b1..76a2cb264d4 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -151,7 +151,7 @@ bool IsPassiveStackableSpell( uint32 spellId ) 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; diff --git a/src/game/Unit.h b/src/game/Unit.h index d3455d83baa..f980692ef7b 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1422,7 +1422,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 (); From 62cdd39279e573f99bc49db45a043bd057372afc Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 13 Mar 2009 17:59:58 -0600 Subject: [PATCH 12/12] *Add some description of linked spells. --HG-- branch : trunk --- sql/world_spell_full.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sql/world_spell_full.sql b/sql/world_spell_full.sql index cfaa310a166..c33b05c168c 100644 --- a/sql/world_spell_full.sql +++ b/sql/world_spell_full.sql @@ -4,6 +4,16 @@ -- LINKED -- -------- +# spell1 / spell2 / type +# + + 0 caster casts 2 when casts 1 +# + - 0 caster removes aura 2 when casts 1 +# + + 1 target casts 2 on self (originalCaster = caster) when 1 casted by caster hits target +# + - 1 target removes aura 2 when hit by 1 +# + + 2 when aura 1 is applied, aura 2 is also applied; when 1 is removed, 2 is also removed +# + - 2 when aura 1 is applied, target is immune to spell 2, until 1 is removed +# - + 0 target casts 2 on self (originalCaster = caster) when aura 1 casted by caster is removed +# - - 0 aura 2 is removed when aura 1 is removed + DROP TABLE IF EXISTS `spell_linked_spell`; CREATE TABLE `spell_linked_spell` ( `spell_trigger` mediumint(8) NOT NULL,