diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 138 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.h | 7 |
2 files changed, 93 insertions, 52 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 6c526dd7c75..3b54df584a8 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -133,6 +133,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { case SMART_ACTION_TALK: { + if (!me) + return; + ObjectList* targets = GetTargets(e, unit); talker = me; if (targets) @@ -165,9 +168,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsCreature((*itr))) + if (IsCreature(*itr)) sCreatureTextMgr->SendChat((*itr)->ToCreature(), uint8(e.action.talk.textGroupID), IsPlayer(GetLastInvoker())? GetLastInvoker()->GetGUID() : 0); - else if (IsPlayer((*itr))) + else if (IsPlayer(*itr) && me) { Unit* templastInvoker = GetLastInvoker(); sCreatureTextMgr->SendChat(me, uint8(e.action.talk.textGroupID), IsPlayer(templastInvoker) ? templastInvoker->GetGUID() : 0, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, (*itr)->ToPlayer()); @@ -186,14 +189,16 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (targets) { for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) - if (IsUnit((*itr))) + { + if (IsUnit(*itr)) { (*itr)->ToUnit()->HandleEmoteCommand(e.action.emote.emote); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_PLAY_EMOTE: target: %s (GuidLow: %u), emote: %u", (*itr)->GetName(), (*itr)->GetGUIDLow(), e.action.emote.emote); } + } - delete targets; + delete targets; } break; } @@ -204,7 +209,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsCreature((*itr))) + if (IsCreature(*itr)) { sCreatureTextMgr->SendSound((*itr)->ToCreature(), e.action.sound.sound, CHAT_MSG_MONSTER_SAY, 0, TextRange(e.action.sound.range), Team(0), false); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SOUND: source: %s (GuidLow: %u), sound: %u, range: %u", @@ -223,7 +228,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsCreature((*itr))) + if (IsCreature(*itr)) { if (e.action.faction.factionID) { @@ -255,9 +260,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u ObjectList* targets = GetTargets(e, unit); if (!targets) return; + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (!IsCreature((*itr))) + if (!IsCreature(*itr)) continue; if (e.action.morphOrMount.creature || e.action.morphOrMount.model) @@ -297,9 +303,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u ObjectList* targets = GetTargets(e, unit); if (!targets) return; + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsPlayer((*itr))) + if (IsPlayer(*itr)) { (*itr)->ToPlayer()->FailQuest(e.action.quest.quest); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_FAIL_QUEST: Player guidLow %u fails quest %u", @@ -315,15 +322,18 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u ObjectList* targets = GetTargets(e, unit); if (!targets) return; + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsPlayer((*itr))) - if (const Quest* q = sObjectMgr->GetQuestTemplate(e.action.quest.quest)) + if (IsPlayer(*itr)) + { + if (Quest const* q = sObjectMgr->GetQuestTemplate(e.action.quest.quest)) { (*itr)->ToPlayer()->AddQuest(q, NULL); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_ADD_QUEST: Player guidLow %u add quest %u", (*itr)->GetGUIDLow(), e.action.quest.quest); } + } } delete targets; @@ -344,6 +354,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u ObjectList* targets = GetTargets(e, unit); if (!targets) return; + uint32 emotes[SMART_ACTION_PARAM_COUNT]; emotes[0] = e.action.randomEmote.emote1; emotes[1] = e.action.randomEmote.emote2; @@ -358,13 +369,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (emotes[i]) { temp[count] = emotes[i]; - count++; + ++count; } } for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsUnit((*itr))) + if (IsUnit(*itr)) { uint32 emote = temp[urand(0, count)]; (*itr)->ToUnit()->HandleEmoteCommand(emote); @@ -384,11 +395,11 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u std::list<HostileReference*> const& threatList = me->getThreatManager().getThreatList(); for (std::list<HostileReference*>::const_iterator i = threatList.begin(); i != threatList.end(); ++i) { - if (Unit* Temp = Unit::GetUnit(*me, (*i)->getUnitGuid())) + if (Unit* target = Unit::GetUnit(*me, (*i)->getUnitGuid())) { - me->getThreatManager().modifyThreatPercent(Temp, e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC); + me->getThreatManager().modifyThreatPercent(target, e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_THREAT_ALL_PCT: Creature guidLow %u modify threat for unit %u, value %i", - me->GetGUIDLow(), Temp->GetGUIDLow(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC); + me->GetGUIDLow(), target->GetGUIDLow(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC); } } break; @@ -404,7 +415,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsUnit((*itr))) + if (IsUnit(*itr)) { me->getThreatManager().modifyThreatPercent((*itr)->ToUnit(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_THREAT_SINGLE_PCT: Creature guidLow %u modify threat for unit %u, value %i", @@ -423,7 +434,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsPlayer((*itr))) + if (IsPlayer(*itr)) { (*itr)->ToPlayer()->AreaExploredOrEventHappens(e.action.quest.quest); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS: Player guidLow %u credited quest %u", @@ -445,7 +456,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsPlayer((*itr))) + if (IsPlayer(*itr)) { (*itr)->ToPlayer()->CastedCreatureOrGO(e.action.castedCreatureOrGO.creature, GetBaseObject()->GetGUID(), e.action.castedCreatureOrGO.spell); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SEND_CASTCREATUREORGO: Player guidLow %u.org Creature: %u, BaseObject GUID: "UI64FMTD" , Spell: %u", @@ -467,7 +478,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsUnit((*itr))) + if (IsUnit(*itr)) { if (e.action.cast.flags & SMARTCAST_INTERRUPT_PREVIOUS) me->InterruptNonMeleeSpells(false); @@ -493,7 +504,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsUnit((*itr))) + if (IsUnit(*itr)) { if (e.action.cast.flags & SMARTCAST_INTERRUPT_PREVIOUS) tempLastInvoker->InterruptNonMeleeSpells(false); @@ -515,7 +526,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsUnit((*itr))) + if (IsUnit(*itr)) { (*itr)->ToUnit()->AddAura(e.action.cast.spell, (*itr)->ToUnit()); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_ADD_AURA: Adding aura %u to unit %u", @@ -534,7 +545,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsGameObject((*itr))) + if (IsGameObject(*itr)) { // Activate (*itr)->ToGameObject()->SetLootState(GO_READY); @@ -552,9 +563,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u ObjectList* targets = GetTargets(e, unit); if (!targets) return; + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsGameObject((*itr))) + if (IsGameObject(*itr)) { (*itr)->ToGameObject()->ResetDoorOrButton(); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_RESET_GOBJECT. Gameobject %u (entry: %u) reset", @@ -573,7 +585,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsUnit((*itr))) + if (IsUnit(*itr)) { (*itr)->ToUnit()->SetUInt32Value(UNIT_NPC_EMOTESTATE, e.action.emote.emote); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SET_EMOTE_STATE. Unit %u set emotestate to %u", @@ -589,9 +601,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u ObjectList* targets = GetTargets(e, unit); if (!targets) return; + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsUnit((*itr))) + if (IsUnit(*itr)) { (*itr)->ToUnit()->SetFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit %u added flag %u to UNIT_FIELD_FLAGS", @@ -610,7 +623,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsUnit((*itr))) + if (IsUnit(*itr)) { (*itr)->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit %u removed flag %u to UNIT_FIELD_FLAGS", @@ -644,17 +657,23 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u } case SMART_ACTION_SET_EVENT_PHASE: { + if (!GetBaseObject()) + return; + SetPhase(e.action.setEventPhase.phase); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SET_EVENT_PHASE: Creature %u set event phase %u", - me->GetGUIDLow(), e.action.setEventPhase.phase); + GetBaseObject()->GetGUIDLow(), e.action.setEventPhase.phase); break; } case SMART_ACTION_INC_EVENT_PHASE: { + if (!GetBaseObject()) + return; + IncPhase(e.action.incEventPhase.inc); DecPhase(e.action.incEventPhase.dec); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_INC_EVENT_PHASE: Creature %u inc event phase by %u, " - "decrease by %u", me->GetGUIDLow(), e.action.incEventPhase.inc, e.action.incEventPhase.dec); + "decrease by %u", GetBaseObject()->GetGUIDLow(), e.action.incEventPhase.inc, e.action.incEventPhase.dec); break; } case SMART_ACTION_EVADE: @@ -751,6 +770,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u } case SMART_ACTION_RANDOM_PHASE: { + if (!GetBaseObject()) + return; + uint32 phases[SMART_ACTION_PARAM_COUNT]; phases[0] = e.action.randomPhase.phase1; phases[1] = e.action.randomPhase.phase2; @@ -765,33 +787,35 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (phases[i] > 0) { temp[count] = phases[i]; - count++; + ++count; } } uint32 phase = temp[urand(0, count)]; SetPhase(phase); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE: Creature %u sets event phase to %u", - me->GetGUIDLow(), phase); + GetBaseObject()->GetGUIDLow(), phase); break; } case SMART_ACTION_RANDOM_PHASE_RANGE: { + if (!GetBaseObject()) + return; + uint32 phase = urand(e.action.randomPhaseRange.phaseMin, e.action.randomPhaseRange.phaseMax); SetPhase(phase); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE_RANGE: Creature %u sets event phase to %u", - me->GetGUIDLow(), phase); + GetBaseObject()->GetGUIDLow(), phase); break; } case SMART_ACTION_CALL_KILLEDMONSTER: { - Player* pPlayer = NULL; + Player* player = NULL; if (me) - pPlayer = me->GetLootRecipient(); - - if (me && pPlayer) - pPlayer->RewardPlayerAndGroupAtEvent(e.action.killedMonster.creature, pPlayer); + player = me->GetLootRecipient(); + if (me && player) + player->RewardPlayerAndGroupAtEvent(e.action.killedMonster.creature, player); else if (GetBaseObject()) { ObjectList* targets = GetTargets(e, unit); @@ -800,7 +824,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (!IsPlayer((*itr))) + if (!IsPlayer(*itr)) continue; (*itr)->ToPlayer()->RewardPlayerAndGroupAtEvent(e.action.killedMonster.creature, (*itr)->ToPlayer()); @@ -827,14 +851,14 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!obj) return; - InstanceScript* pInst = (InstanceScript*)obj->GetInstanceScript(); - if (!pInst) + InstanceScript* instance = obj->GetInstanceScript(); + if (!instance) { sLog->outErrorDb("SmartScript: Event %u attempt to set instance data without instance script. EntryOrGuid %d", e.GetEventType(), e.entryOrGuid); return; } - pInst->SetData(e.action.setInstanceData.field, e.action.setInstanceData.data); + instance->SetData(e.action.setInstanceData.field, e.action.setInstanceData.data); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA: Field: %u, data: %u", e.action.setInstanceData.field, e.action.setInstanceData.data); break; @@ -848,8 +872,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!obj) return; - InstanceScript* pInst = (InstanceScript*)obj->GetInstanceScript(); - if (!pInst) + InstanceScript* instance = obj->GetInstanceScript(); + if (!instance) { sLog->outErrorDb("SmartScript: Event %u attempt to set instance data without instance script. EntryOrGuid %d", e.GetEventType(), e.entryOrGuid); return; @@ -859,7 +883,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!targets) return; - pInst->SetData64(e.action.setInstanceData64.field, targets->front()->GetGUID()); + instance->SetData64(e.action.setInstanceData64.field, targets->front()->GetGUID()); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA64: Field: %u, data: "UI64FMTD, e.action.setInstanceData64.field, targets->front()->GetGUID()); @@ -917,6 +941,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (!IsSmart()) return; + CAST_AI(SmartAI, me->AI())->SetDespawnTime(e.action.forceDespawn.delay + 1);//next tick CAST_AI(SmartAI, me->AI())->StartDespawn(); break; @@ -932,10 +957,12 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u ObjectList* targets = GetTargets(e, unit); if (!targets) return; + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (!IsUnit((*itr))) + if (!IsUnit(*itr)) continue; + if (e.action.morphOrMount.creature || e.action.morphOrMount.model) { if (e.action.morphOrMount.creature > 0) @@ -958,8 +985,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u } case SMART_ACTION_SET_INVINCIBILITY_HP_LEVEL: { - if (!GetBaseObject()) + if (!me) return; + if (e.action.invincHP.percent) mInvinceabilityHpLevel = me->CountPctFromMaxHealth(e.action.invincHP.percent); else @@ -987,6 +1015,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (!me) return; + float x, y, z; me->GetClosePoint(x, y, z, me->GetObjectSize() / 3, (float)e.action.moveRandom.distance); me->GetMotionMaster()->MovePoint(SMART_RANDOM_POINT, x, y, z); @@ -1021,6 +1050,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u break; } } + delete targets; break; } @@ -1084,6 +1114,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u ObjectList* targets = GetTargets(e, unit); if (!targets) return; + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { if (!IsUnit(*itr)) @@ -1168,6 +1199,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (!IsSmart()) return; + CAST_AI(SmartAI, me->AI())->SetFly(e.action.setFly.fly ? true : false); break; } @@ -1175,6 +1207,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (!IsSmart()) return; + CAST_AI(SmartAI, me->AI())->SetRun(e.action.setRun.run ? true : false); break; } @@ -1182,6 +1215,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (!IsSmart()) return; + CAST_AI(SmartAI, me->AI())->SetSwimm(e.action.setSwimm.swimm ? true : false); break; } @@ -1189,6 +1223,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (!IsSmart()) return; + bool run = e.action.wpStart.run ? true : false; uint32 entry = e.action.wpStart.pathID; bool repeat = e.action.wpStart.repeat ? true : false; @@ -1207,6 +1242,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (!IsSmart()) return; + uint32 delay = e.action.wpPause.delay; CAST_AI(SmartAI, me->AI())->PausePath(delay, e.GetEventType() == SMART_EVENT_WAYPOINT_REACHED ? false : true); break; @@ -1215,6 +1251,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (!IsSmart()) return; + uint32 DespawnTime = e.action.wpStop.despawnTime; uint32 quest = e.action.wpStop.quest; bool fail = e.action.wpStop.fail ? true : false; @@ -1225,6 +1262,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (!IsSmart()) return; + CAST_AI(SmartAI, me->AI())->ResumePath(); break; } @@ -1265,6 +1303,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (!IsSmart()) return; + bool run = e.action.setRun.run ? true : false; CAST_AI(SmartAI, me->AI())->SetRun(run); me->GetMotionMaster()->MovePoint(0, e.target.x, e.target.y , e.target.z); @@ -1369,7 +1408,6 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u ev.action = ac; InitTimer(ev); mStoredEvents.push_back(ev); - break; } case SMART_ACTION_TRIGGER_TIMED_EVENT: @@ -1603,7 +1641,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (IsSmart(target)) CAST_AI(SmartAI, target->AI())->SetScript9(e, id, GetLastInvoker()); - } else if (GameObject* target = (*itr)->ToGameObject()) + } + else if (GameObject* target = (*itr)->ToGameObject()) { if (IsSmartGO(target)) CAST_AI(SmartGameObjectAI, target->AI())->SetScript9(e, id, GetLastInvoker()); @@ -1664,6 +1703,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u ObjectList* targets = GetTargets(e, unit); if (!targets) return; + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) if (IsUnit(*itr)) (*itr)->ToUnit()->RemoveByteFlag(UNIT_FIELD_BYTES_1, 0, e.action.delunitByte.byte1); @@ -2862,7 +2902,7 @@ void SmartScript::DoFindFriendlyCC(std::list<Creature*>& _list, float range) cell.Visit(p, grid_creature_searcher, *me->GetMap()); } -void SmartScript::DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float range, uint32 spellid) +void SmartScript::DoFindFriendlyMissingBuff(std::list<Creature*>& list, float range, uint32 spellid) { if (!me) return; CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); @@ -2871,7 +2911,7 @@ void SmartScript::DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float r cell.SetNoCreate(); Trinity::FriendlyMissingBuffInRange u_check(me, range, spellid); - Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange> searcher(me, _list, u_check); + Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange> searcher(me, list, u_check); TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange>, GridTypeMapContainer > grid_creature_searcher(searcher); diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h index 4fc70ed33ea..1e3601dca3d 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.h +++ b/src/server/game/AI/SmartScripts/SmartScript.h @@ -101,7 +101,7 @@ class SmartScript Unit* DoSelectLowestHpFriendly(float range, uint32 MinHPDiff); void DoFindFriendlyCC(std::list<Creature*>& _list, float range); - void DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float range, uint32 spellid); + void DoFindFriendlyMissingBuff(std::list<Creature*>& list, float range, uint32 spellid); void StoreTargetList(ObjectList* targets, uint32 id) { @@ -124,7 +124,8 @@ class SmartScript smart = false; if (!smart) - sLog->outErrorDb("SmartScript: Action target Creature(entry: %u) is not using SmartAI, action skipped to prevent crash.", c?c->GetEntry():(me?me->GetEntry():0)); + sLog->outErrorDb("SmartScript: Action target Creature(entry: %u) is not using SmartAI, action skipped to prevent crash.", c ? c->GetEntry() : (me ? me->GetEntry() : 0)); + return smart; } @@ -137,8 +138,8 @@ class SmartScript if (!go || go->GetAIName() != "SmartGameObjectAI") smart = false; if (!smart) + sLog->outErrorDb("SmartScript: Action target GameObject(entry: %u) is not using SmartGameObjectAI, action skipped to prevent crash.", g ? g->GetEntry() : (go ? go->GetEntry() : 0)); - sLog->outErrorDb("SmartScript: Action target GameObject(entry: %u) is not using SmartGameObjectAI, action skipped to prevent crash.", g?g->GetEntry():(go?go->GetEntry():0)); return smart; } |