From 9761affc8dcc9cc54ba13bad4e1522d3b3ffda42 Mon Sep 17 00:00:00 2001 From: Discover- Date: Wed, 4 Sep 2013 09:35:21 +0200 Subject: Core/SAI: Make SMART_TARGET_OWNER_OR_SUMMONER also work for creatures summoned by spells --- src/server/game/AI/SmartScripts/SmartScript.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/server/game/AI/SmartScripts') diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index f94a3e79066..e6fab906736 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -2509,8 +2509,15 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /* case SMART_TARGET_OWNER_OR_SUMMONER: { if (me) - if (Unit* owner = ObjectAccessor::GetUnit(*me, me->GetCharmerOrOwnerGUID())) + { + uint64 charmerOrOwnerGuid = me->GetCharmerOrOwnerGUID(); + + if (!charmerOrOwnerGuid) + charmerOrOwnerGuid = me->GetCreatorGUID(); + + if (Unit* owner = ObjectAccessor::GetUnit(*me, charmerOrOwnerGuid)) l->push_back(owner); + } break; } case SMART_TARGET_THREAT_LIST: -- cgit v1.2.3 From 926edaf49dd91c8d550919f8a37b90c59011b2e0 Mon Sep 17 00:00:00 2001 From: Discover- Date: Wed, 4 Sep 2013 14:07:27 +0200 Subject: Tabs to spaces... --- src/server/game/AI/SmartScripts/SmartScript.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/server/game/AI/SmartScripts') diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index e6fab906736..111ac53e670 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -2509,15 +2509,15 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /* case SMART_TARGET_OWNER_OR_SUMMONER: { if (me) - { - uint64 charmerOrOwnerGuid = me->GetCharmerOrOwnerGUID(); + { + uint64 charmerOrOwnerGuid = me->GetCharmerOrOwnerGUID(); - if (!charmerOrOwnerGuid) - charmerOrOwnerGuid = me->GetCreatorGUID(); + if (!charmerOrOwnerGuid) + charmerOrOwnerGuid = me->GetCreatorGUID(); if (Unit* owner = ObjectAccessor::GetUnit(*me, charmerOrOwnerGuid)) l->push_back(owner); - } + } break; } case SMART_TARGET_THREAT_LIST: -- cgit v1.2.3 From 458f5b9502da9f861ba729142dd63c3a98191ece Mon Sep 17 00:00:00 2001 From: Vincent-Michael Date: Thu, 5 Sep 2013 16:16:23 +0200 Subject: Core/SAI: Added SMART_ACTION_SUMMON_CREA / SMART_ACTION_SUMMON_GO log for has already summon spell --- src/server/game/AI/SmartScripts/SmartScriptMgr.cpp | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/server/game/AI/SmartScripts') diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index 01f9080fba1..c93ffe90add 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -771,6 +771,26 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) case SMART_ACTION_SUMMON_CREATURE: if (!IsCreatureValid(e, e.action.summonCreature.creature)) return false; + + for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i) + { + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i); + if (!spellInfo) + continue; + + for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j) + { + if (spellInfo->Effects[j].Effect == SPELL_EFFECT_SUMMON) + { + uint32 creatureSummonEntry = spellInfo->Effects[j].MiscValue; + + if (e.action.killedMonster.creature == creatureSummonEntry) + TC_LOG_ERROR(LOG_FILTER_SQL, "SmartAIMgr: Entry %d SourceType %u Event %u Action %u creature summon: %u has already summon spell (SpellId: %u effect: %u)", + e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.killedMonster.creature, spellInfo->Id, j); + } + } + } + if (e.action.summonCreature.type < TEMPSUMMON_TIMED_OR_DEAD_DESPAWN || e.action.summonCreature.type > TEMPSUMMON_MANUAL_DESPAWN) { TC_LOG_ERROR(LOG_FILTER_SQL, "SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses incorrect TempSummonType %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.summonCreature.type); @@ -828,6 +848,25 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) case SMART_ACTION_SUMMON_GO: if (!IsGameObjectValid(e, e.action.summonGO.entry)) return false; + + for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i) + { + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i); + if (!spellInfo) + continue; + + for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j) + { + if (spellInfo->Effects[j].Effect == SPELL_EFFECT_SUMMON_OBJECT_WILD) + { + uint32 goSummonEntry = spellInfo->Effects[j].MiscValue; + + if (e.action.summonGO.entry == goSummonEntry) + TC_LOG_ERROR(LOG_FILTER_SQL, "SmartAIMgr: Entry %d SourceType %u Event %u Action %u gameobject summon: %u has already summon spell (SpellId: %u effect: %u)", + e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.summonGO.entry, spellInfo->Id, j); + } + } + } break; case SMART_ACTION_ADD_ITEM: case SMART_ACTION_REMOVE_ITEM: -- cgit v1.2.3 From bc1a079b6ca2516d80f3eed5b911971b77cabce4 Mon Sep 17 00:00:00 2001 From: Vincent-Michael Date: Fri, 6 Sep 2013 21:40:04 +0200 Subject: Core/SAI: Fix typo (i blame germans laziness) --- src/server/game/AI/SmartScripts/SmartScriptMgr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/server/game/AI/SmartScripts') diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index c93ffe90add..361cf025647 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -784,9 +784,9 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) { uint32 creatureSummonEntry = spellInfo->Effects[j].MiscValue; - if (e.action.killedMonster.creature == creatureSummonEntry) + if (e.action.summonCreature.creature == creatureSummonEntry) TC_LOG_ERROR(LOG_FILTER_SQL, "SmartAIMgr: Entry %d SourceType %u Event %u Action %u creature summon: %u has already summon spell (SpellId: %u effect: %u)", - e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.killedMonster.creature, spellInfo->Id, j); + e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.summonCreature.creature, spellInfo->Id, j); } } } -- cgit v1.2.3 From fcf9552934aa671840e76293764cbfe60e7732a7 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 8 Sep 2013 12:15:13 +0200 Subject: Core/SmartScripts: Fixed heap corruption in SMART_ACTION_EQUIP Closes #10739 --- src/server/game/AI/SmartScripts/SmartScript.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/server/game/AI/SmartScripts') diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 111ac53e670..3a14e8946eb 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1447,7 +1447,6 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!einfo) { TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript: SMART_ACTION_EQUIP uses non-existent equipment info id %u for creature %u", equipId, npc->GetEntry()); - delete targets; break; } @@ -1991,13 +1990,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u e.GetTargetType() == SMART_TARGET_OWNER_OR_SUMMONER || e.GetTargetType() == SMART_TARGET_ACTION_INVOKER || e.GetTargetType() == SMART_TARGET_CLOSEST_ENEMY || e.GetTargetType() == SMART_TARGET_CLOSEST_FRIENDLY) { - if (ObjectList* targets = GetTargets(e, unit)) - { - if (WorldObject* target = targets->front()) - (*itr)->ToCreature()->SetHomePosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation()); - - delete targets; - } + (*itr)->ToCreature()->SetHomePosition((*itr)->GetPositionX(), (*itr)->GetPositionY(), (*itr)->GetPositionZ(), (*itr)->GetOrientation()); } else TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript: Action target for SMART_ACTION_SET_HOME_POS is invalid, skipping"); -- cgit v1.2.3 From be5cf42ec392e8526d3180e51ffaacb84e883fae Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 9 Sep 2013 17:44:07 +0200 Subject: Core/SmartAI: Fixed creatures using SAI not attacking its charmer after it breaks Closes #7601 --- src/server/game/AI/SmartScripts/SmartAI.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/server/game/AI/SmartScripts') diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index a1862c07d14..a56d0f94f2d 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -699,6 +699,10 @@ void SmartAI::InitializeAI() void SmartAI::OnCharmed(bool apply) { GetScript()->ProcessEventsFor(SMART_EVENT_CHARMED, NULL, 0, 0, apply); + + if (!apply && !me->IsInEvadeMode() && me->GetUInt64Value(UNIT_FIELD_CHARMEDBY)) + if (Unit* charmer = ObjectAccessor::GetUnit(*me, me->GetUInt64Value(UNIT_FIELD_CHARMEDBY))) + AttackStart(charmer); } void SmartAI::DoAction(int32 param) -- cgit v1.2.3 From 69b0a009c4c99b858296d4cbc5f86a87258f6699 Mon Sep 17 00:00:00 2001 From: Discover- Date: Sat, 21 Sep 2013 11:21:29 +0200 Subject: Core/SAI: Make SMART_ACTION_RANDOM_MOVE also work with SMART_TARGET_NONE and non-creature targets (if a non-creature target_type is specified and no creature target was found, the action is fired at the source) Ref. #7431 --- src/server/game/AI/SmartScripts/SmartScript.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/server/game/AI/SmartScripts') diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 3a14e8946eb..aed212a392a 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1770,10 +1770,14 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!targets) break; + bool foundTarget = false; + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { if (IsCreature((*itr))) { + foundTarget = true; + if (e.action.moveRandom.distance) (*itr)->ToCreature()->GetMotionMaster()->MoveRandom((float)e.action.moveRandom.distance); else @@ -1781,6 +1785,14 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u } } + if (!foundTarget && me && IsCreature(me)) + { + if (e.action.moveRandom.distance) + me->GetMotionMaster()->MoveRandom((float)e.action.moveRandom.distance); + else + me->GetMotionMaster()->MoveIdle(); + } + delete targets; break; } @@ -2287,8 +2299,9 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /* l->push_back(baseObject); break; case SMART_TARGET_VICTIM: - if (me && me->GetVictim()) - l->push_back(me->GetVictim()); + if (me) + if (Unit* victim = me->GetVictim()) + l->push_back(victim); break; case SMART_TARGET_HOSTILE_SECOND_AGGRO: if (me) -- cgit v1.2.3