Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
SmartAI.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "Cell.h"
7#include "CellImpl.h"
8#include "DatabaseEnv.h"
9#include "GridDefines.h"
10#include "GridNotifiers.h"
11#include "GridNotifiersImpl.h"
12#include "Group.h"
13#include "InstanceScript.h"
14#include "ObjectDefines.h"
15#include "ObjectMgr.h"
16#include "ScriptedCreature.h"
17#include "ScriptMgr.h"
18#include "SmartAI.h"
19#include "SpellMgr.h"
20
30
32{
34 return;
35
36 if (mDespawnTime < diff)
37 {
38 if (mDespawnState == 2)
39 {
40 me->SetVisible(false);
41 mDespawnTime = 5000;
43 }
44 else
45 me->DespawnOrUnsummon();
46 }
47 else mDespawnTime -= diff;
48}
49
51{
52 if (!HasEscortState(SMART_ESCORT_ESCORTING))//dont mess up escort movement after combat
53 SetRun(mRun);
54 GetScript()->OnReset();
55}
56
58{
59 if (!mWayPoints || mWayPoints->empty())
60 return NULL;
61
63 WPPath::const_iterator itr = mWayPoints->find(mCurrentWPID);
64 if (itr != mWayPoints->end())
65 {
66 mLastWP = (*itr).second;
67 if (mLastWP->id != mCurrentWPID)
68 {
69 SF_LOG_ERROR("misc", "SmartAI::GetNextWayPoint: Got not expected waypoint id %u, expected %u", mLastWP->id, mCurrentWPID);
70 }
71 return (*itr).second;
72 }
73 return NULL;
74}
75
76void SmartAI::StartPath(bool run, uint32 path, bool repeat, Unit* /*invoker*/)
77{
78 if (me->IsInCombat())// no wp movement in combat
79 {
80 SF_LOG_ERROR("misc", "SmartAI::StartPath: Creature entry %u wanted to start waypoint movement while in combat, ignoring.", me->GetEntry());
81 return;
82 }
84 StopPath();
85 if (path)
86 if (!LoadPath(path))
87 return;
88 if (!mWayPoints || mWayPoints->empty())
89 return;
90
92 mCanRepeatPath = repeat;
93
94 SetRun(run);
95
96 if (WayPoint* wp = GetNextWayPoint())
97 {
98 me->GetPosition(&mLastOOCPos);
99 me->GetMotionMaster()->MovePoint(wp->id, wp->x, wp->y, wp->z);
100 GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_START, NULL, wp->id, GetScript()->GetPathId());
101 }
102}
103
105{
107 return false;
108 mWayPoints = sSmartWaypointMgr->GetPath(entry);
109 if (!mWayPoints)
110 {
111 GetScript()->SetPathId(0);
112 return false;
113 }
114 GetScript()->SetPathId(entry);
115 return true;
116}
117
118void SmartAI::PausePath(uint32 delay, bool forced)
119{
121 return;
123 {
124 SF_LOG_ERROR("misc", "SmartAI::StartPath: Creature entry %u wanted to pause waypoint movement while already paused, ignoring.", me->GetEntry());
125 return;
126 }
127 mForcedPaused = forced;
128 me->GetPosition(&mLastOOCPos);
130 mWPPauseTimer = delay;
131 if (forced)
132 {
133 SetRun(mRun);
134 me->StopMoving();//force stop
135 me->GetMotionMaster()->MoveIdle();//force stop
136 }
138}
139
140void SmartAI::StopPath(uint32 DespawnTime, uint32 quest, bool fail)
141{
143 return;
144
145 if (quest)
146 mEscortQuestID = quest;
147 SetDespawnTime(DespawnTime);
148 //mDespawnTime = DespawnTime;
149
150 me->GetPosition(&mLastOOCPos);
151 me->StopMoving();//force stop
152 me->GetMotionMaster()->MoveIdle();
154 EndPath(fail);
155}
156
157void SmartAI::EndPath(bool fail)
158{
160
162 mWayPoints = NULL;
163 mCurrentWPID = 0;
164 mWPPauseTimer = 0;
165 mLastWP = NULL;
166
167 if (mCanRepeatPath)
168 StartPath(mRun, GetScript()->GetPathId(), true);
169 else
170 GetScript()->SetPathId(0);
171
173 if (targets && mEscortQuestID)
174 {
175 if (targets->size() == 1 && GetScript()->IsPlayer((*targets->begin())))
176 {
177 Player* player = (*targets->begin())->ToPlayer();
178 if (!fail && player->IsAtGroupRewardDistance(me) && !player->GetCorpse())
180
182 player->FailQuest(mEscortQuestID);
183
184 if (Group* group = player->GetGroup())
185 {
186 for (GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->next())
187 {
188 Player* groupGuy = groupRef->GetSource();
189
190 if (!fail && groupGuy->IsAtGroupRewardDistance(me) && !groupGuy->GetCorpse())
192 if (fail && groupGuy->GetQuestStatus(mEscortQuestID) == QUEST_STATUS_INCOMPLETE)
193 groupGuy->FailQuest(mEscortQuestID);
194 }
195 }
196 }
197 else
198 {
199 for (ObjectList::iterator iter = targets->begin(); iter != targets->end(); ++iter)
200 {
201 if (GetScript()->IsPlayer((*iter)))
202 {
203 Player* player = (*iter)->ToPlayer();
204 if (!fail && player->IsAtGroupRewardDistance(me) && !player->GetCorpse())
207 player->FailQuest(mEscortQuestID);
208 }
209 }
210 }
211 }
212 if (mDespawnState == 1)
213 StartDespawn();
214}
215
217{
218 //mWPReached = false;
219 SetRun(mRun);
220 if (mLastWP)
221 me->GetMotionMaster()->MovePoint(mLastWP->id, mLastWP->x, mLastWP->y, mLastWP->z);
222}
223
225{
226 SetRun(mRun);
227 me->GetMotionMaster()->MovePoint(SMART_ESCORT_LAST_OOC_POINT, mLastOOCPos);
228}
229
231{
233 return;
234 if (mEscortInvokerCheckTimer < diff)
235 {
237 {
239 }
241 }
242 else mEscortInvokerCheckTimer -= diff;
243 // handle pause
245 {
246 if (mWPPauseTimer < diff)
247 {
249 {
252 if (mForcedPaused)// if paused between 2 wps resend movement
253 {
254 ResumePath();
255 mWPReached = false;
256 mForcedPaused = false;
257 }
259 mWPReached = true;
260 }
261 mWPPauseTimer = 0;
262 }
263 else
264 {
265 mWPPauseTimer -= diff;
266 }
267 }
269 {
270 if (mWPReached)//reached OOC WP
271 {
274 ResumePath();
275 mWPReached = false;
276 }
277 }
278 if ((!me->HasReactState(REACT_PASSIVE) && me->IsInCombat()) || HasEscortState(SMART_ESCORT_PAUSED | SMART_ESCORT_RETURNING))
279 return;
280 // handle next wp
281 if (mWPReached)//reached WP
282 {
283 mWPReached = false;
284 if (mCurrentWPID == GetWPCount())
285 {
286 EndPath();
287 }
288 else if (WayPoint* wp = GetNextWayPoint())
289 {
290 SetRun(mRun);
291 me->GetMotionMaster()->MovePoint(wp->id, wp->x, wp->y, wp->z);
292 }
293 }
294}
295
297{
298 GetScript()->OnUpdate(diff);
299 UpdatePath(diff);
300 UpdateDespawn(diff);
301
303 if (mFollowGuid)
304 {
305 if (mFollowArrivedTimer < diff)
306 {
307 if (me->FindNearestCreature(mFollowArrivedEntry, INTERACTION_DISTANCE, true))
308 {
310 {
312 player->RewardPlayerAndGroupAtEvent(mFollowCredit, me);
313 else
314 player->GroupEventHappens(mFollowCredit, me);
315 }
316 mFollowGuid = 0;
317 mFollowDist = 0;
318 mFollowAngle = 0;
319 mFollowCredit = 0;
320 mFollowArrivedTimer = 1000;
323 SetDespawnTime(5000);
324 me->StopMoving();
325 me->GetMotionMaster()->MoveIdle();
326 StartDespawn();
328 return;
329 }
330 mFollowArrivedTimer = 1000;
331 }
332 else
333 mFollowArrivedTimer -= diff;
334 }
335
336 if (!UpdateVictim())
337 return;
338
339 if (mCanAutoAttack)
341}
342
344{
346 if (targets)
347 {
348 if (targets->size() == 1 && GetScript()->IsPlayer((*targets->begin())))
349 {
350 Player* player = (*targets->begin())->ToPlayer();
351 if (me->GetDistance(player) <= float(SMART_ESCORT_MAX_PLAYER_DIST))
352 return true;
353
354 if (Group* group = player->GetGroup())
355 {
356 for (GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->next())
357 {
358 Player* groupGuy = groupRef->GetSource();
359
360 if (me->GetDistance(groupGuy) <= float(SMART_ESCORT_MAX_PLAYER_DIST))
361 return true;
362 }
363 }
364 }
365 else
366 {
367 for (ObjectList::iterator iter = targets->begin(); iter != targets->end(); ++iter)
368 {
369 if (GetScript()->IsPlayer((*iter)))
370 {
371 if (me->GetDistance((*iter)->ToPlayer()) <= float(SMART_ESCORT_MAX_PLAYER_DIST))
372 return true;
373 }
374 }
375 }
376 }
377 return true;//escort targets were not set, ignore range check
378}
379
388
390{
391 if ((MovementType == POINT_MOTION_TYPE && Data == SMART_ESCORT_LAST_OOC_POINT) || MovementType == FOLLOW_MOTION_TYPE)
392 me->ClearUnitState(UNIT_STATE_EVADE);
393
396 return;
398}
399
401{
403 Unit::AuraApplicationMap& appliedAuras = me->GetAppliedAuras();
404 for (Unit::AuraApplicationMap::iterator iter = appliedAuras.begin(); iter != appliedAuras.end();)
405 {
406 Aura const* aura = iter->second->GetBase();
407 if (!aura->IsPassive() && !aura->HasEffectType(SPELL_AURA_CONTROL_VEHICLE) && !aura->HasEffectType(SPELL_AURA_CLONE_CASTER) && aura->GetCasterGUID() != me->GetGUID())
408 me->RemoveAura(iter);
409 else
410 ++iter;
411 }
412}
413
415{
416 if (!me->IsAlive() || me->IsInEvadeMode())
417 return;
418
419 RemoveAuras();
420
421 me->AddUnitState(UNIT_STATE_EVADE);
422 me->DeleteThreatList();
423 me->CombatStop(true);
424 me->LoadCreaturesAddon(true);
425 me->SetLootRecipient(NULL);
426 me->ResetPlayerDamageReq();
427
428 GetScript()->ProcessEventsFor(SMART_EVENT_EVADE);//must be after aura clear so we can cast spells from db
429
430 SetRun(mRun);
432 {
435 }
436 else if (mFollowGuid)
437 {
438 if (Unit* target = me->GetUnit(*me, mFollowGuid))
439 me->GetMotionMaster()->MoveFollow(target, mFollowDist, mFollowAngle);
440 }
441 else
442 me->GetMotionMaster()->MoveTargetedHome();
443
444 Reset();
445}
446
448{
449 if (!who)
450 return;
451
453
454 if (me->HasReactState(REACT_PASSIVE) || AssistPlayerInCombat(who))
455 return;
456
457 if (!CanAIAttack(who))
458 return;
459
460 if (!me->CanStartAttack(who, false))
461 return;
462
463 if (me->IsHostileTo(who))
464 {
465 float fAttackRadius = me->GetAttackDistance(who);
466 if (me->IsWithinDistInMap(who, fAttackRadius) && me->IsWithinLOSInMap(who))
467 {
468 if (!me->GetVictim())
469 {
471 AttackStart(who);
472 }
473 else/* if (me->GetMap()->IsDungeon())*/
474 {
475 who->SetInCombatWith(me);
476 me->AddThreat(who, 0.0f);
477 }
478 }
479 }
480}
481
482bool SmartAI::CanAIAttack(const Unit* /*who*/) const
483{
484 if (me->GetReactState() == REACT_PASSIVE)
485 return false;
486 return true;
487}
488
490{
491 if (!who || !who->GetVictim())
492 return false;
493
494 //experimental (unknown) flag not present
495 if (!(me->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_AID_PLAYERS))
496 return false;
497
498 //not a player
500 return false;
501
502 //never attack friendly
503 if (me->IsFriendlyTo(who))
504 return false;
505
506 //too far away and no free sight?
507 if (me->IsWithinDistInMap(who, SMART_MAX_AID_DIST) && me->IsWithinLOSInMap(who))
508 {
509 //already fighting someone?
510 if (!me->GetVictim())
511 {
512 AttackStart(who);
513 return true;
514 }
515 else
516 {
517 who->SetInCombatWith(me);
518 me->AddThreat(who, 0.0f);
519 return true;
520 }
521 }
522
523 return false;
524}
525
527{
528 mDespawnTime = 0;
529 mDespawnState = 0;
531 me->SetVisible(true);
532 if (me->getFaction() != me->GetCreatureTemplate()->faction_A)
533 me->RestoreFaction();
535 Reset();
536 mFollowGuid = 0;//do not reset follower on Reset(), we need it after combat evade
537 mFollowDist = 0;
538 mFollowAngle = 0;
539 mFollowCredit = 0;
540 mFollowArrivedTimer = 1000;
543}
544
545int SmartAI::Permissible(const Creature* creature)
546{
547 if (creature->GetAIName() == "SmartAI")
548 return PERMIT_BASE_SPECIAL;
549 return PERMIT_BASE_NO;
550}
551
556
558{
559 me->InterruptNonMeleeSpells(false); // must be before ProcessEvents
561 me->GetPosition(&mLastOOCPos);
562}
563
570
572{
574}
575
580
582{
583 if (who && me->Attack(who, true))
584 {
586
587 SetRun(mRun);
588 if (me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_ACTIVE) == POINT_MOTION_TYPE)
589 me->GetMotionMaster()->MovementExpired();
590
591 if (me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_IDLE) == RANDOM_MOTION_TYPE)
592 me->GetMotionMaster()->MoveIdle();
593
594 if (mCanCombatMove)
595 me->GetMotionMaster()->MoveChase(who);
596
597 me->GetPosition(&mLastOOCPos);
598 }
599}
600
601void SmartAI::SpellHit(Unit* unit, const SpellInfo* spellInfo)
602{
603 GetScript()->ProcessEventsFor(SMART_EVENT_SPELLHIT, unit, 0, 0, false, spellInfo);
604}
605
606void SmartAI::SpellHitTarget(Unit* target, const SpellInfo* spellInfo)
607{
608 GetScript()->ProcessEventsFor(SMART_EVENT_SPELLHIT_TARGET, target, 0, 0, false, spellInfo);
609}
610
611void SmartAI::DamageTaken(Unit* doneBy, uint32& damage)
612{
614 if (mInvincibilityHpLevel && (damage >= me->GetHealth() - mInvincibilityHpLevel))
615 {
616 damage = 0;
617 me->SetHealth(mInvincibilityHpLevel);
618 }
619}
620
621void SmartAI::HealReceived(Unit* doneBy, uint32& addhealth)
622{
624}
625
626void SmartAI::ReceiveEmote(Player* player, uint32 textEmote)
627{
629}
630
635
636void SmartAI::DamageDealt(Unit* doneTo, uint32& damage, DamageEffectType /*damagetype*/)
637{
639}
640
645
646void SmartAI::UpdateAIWhileCharmed(const uint32 /*diff*/) { }
647
649{
651}
652
653void SmartAI::PassengerBoarded(Unit* who, int8 seatId, bool apply)
654{
656}
657
659{
661 if (!me->isDead())
662 Reset();
664}
665
666void SmartAI::OnCharmed(bool apply)
667{
668 GetScript()->ProcessEventsFor(SMART_EVENT_CHARMED, NULL, 0, 0, apply);
669
670 if (!apply && !me->IsInEvadeMode() && me->GetUInt64Value(UNIT_FIELD_CHARMED_BY))
671 if (Unit* charmer = ObjectAccessor::GetUnit(*me, me->GetUInt64Value(UNIT_FIELD_CHARMED_BY)))
672 AttackStart(charmer);
673}
674
679
681{
682 return 0;
683}
684
686{
688}
689
690void SmartAI::SetGUID(uint64 /*guid*/, int32 /*id*/) { }
691
693{
694 return 0;
695}
696
697void SmartAI::SetRun(bool run)
698{
699 me->SetWalk(!run);
700 mRun = run;
701}
702
703void SmartAI::SetFly(bool fly)
704{
705 me->SetDisableGravity(fly);
706}
707
708void SmartAI::SetSwim(bool swim)
709{
710 me->SetSwim(swim);
711}
712
717
719{
720 _gossipReturn = false;
721 sGossipHello(player);
722 return _gossipReturn;
723}
724
725void SmartAI::sGossipSelect(Player* player, uint32 sender, uint32 action)
726{
727 GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_SELECT, player, sender, action);
728}
729
730void SmartAI::sGossipSelectCode(Player* /*player*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { }
731
732void SmartAI::sQuestAccept(Player* player, Quest const* quest)
733{
735}
736
737void SmartAI::sQuestReward(Player* player, Quest const* quest, uint32 opt)
738{
740}
741
742bool SmartAI::sOnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex)
743{
744 GetScript()->ProcessEventsFor(SMART_EVENT_DUMMY_EFFECT, caster, spellId, (uint32)effIndex);
745 return true;
746}
747
749{
750 if (mCanCombatMove == on)
751 return;
752 mCanCombatMove = on;
754 {
755 if (on && me->GetVictim())
756 {
757 if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == IDLE_MOTION_TYPE)
758 {
759 SetRun(mRun);
760 me->GetMotionMaster()->MoveChase(me->GetVictim());
761 me->CastStop();
762 }
763 }
764 else
765 {
766 me->StopMoving();
767 me->GetMotionMaster()->MoveIdle();
768 }
769 }
770}
771
772void SmartAI::SetFollow(Unit* target, float dist, float angle, uint32 credit, uint32 end, uint32 creditType)
773{
774 if (!target)
775 return;
776 SetRun(mRun);
777 mFollowGuid = target->GetGUID();
778 mFollowDist = dist >= 0.0f ? dist : PET_FOLLOW_DIST;
779 mFollowAngle = angle >= 0.0f ? angle : me->GetFollowAngle();
780 mFollowArrivedTimer = 1000;
781 mFollowCredit = credit;
783 me->GetMotionMaster()->MoveFollow(target, mFollowDist, mFollowAngle);
784 mFollowCreditType = creditType;
785}
786
788{
789 if (invoker)
790 GetScript()->mLastInvoker = invoker->GetGUID();
791 GetScript()->SetScript9(e, entry);
792}
793
794void SmartAI::sOnGameEvent(bool start, uint16 eventId)
795{
797}
798
799void SmartAI::OnSpellClick(Unit* clicker, bool& result)
800{
801 if (!result)
802 return;
803
805}
806
808{
809 if (g->GetAIName() == "SmartGameObjectAI")
810 return PERMIT_BASE_SPECIAL;
811 return PERMIT_BASE_NO;
812}
813
815{
816 GetScript()->OnUpdate(diff);
817}
818
825
827{
828 GetScript()->OnReset();
829}
830
831// Called when a player opens a gossip dialog with the gameobject.
833{
834 SF_LOG_DEBUG("scripts.ai", "SmartGameObjectAI::GossipHello");
835 _gossipReturn = false;
836 GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_HELLO, player, 0, 0, false, NULL, go);
837 return _gossipReturn;
838}
839
840// Called when a player selects a gossip item in the gameobject's gossip menu.
842{
843 GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_SELECT, player, sender, action, false, NULL, go);
844 return false;
845}
846
847// Called when a player selects a gossip with a code in the gameobject's gossip menu.
848bool SmartGameObjectAI::GossipSelectCode(Player* /*player*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/)
849{
850 return false;
851}
852
853// Called when a player accepts a quest from the gameobject.
854bool SmartGameObjectAI::QuestAccept(Player* player, Quest const* quest)
855{
856 GetScript()->ProcessEventsFor(SMART_EVENT_ACCEPTED_QUEST, player, quest->GetQuestId(), 0, false, NULL, go);
857 return false;
858}
859
860// Called when a player selects a quest reward.
861bool SmartGameObjectAI::QuestReward(Player* player, Quest const* quest, uint32 opt)
862{
863 GetScript()->ProcessEventsFor(SMART_EVENT_REWARD_QUEST, player, quest->GetQuestId(), opt, false, NULL, go);
864 return false;
865}
866
867// Called when the dialog status between a player and the gameobject is requested.
869
870// Called when the gameobject is destroyed (destructible buildings only).
872{
873 GetScript()->ProcessEventsFor(SMART_EVENT_DEATH, player, eventId, 0, false, NULL, go);
874}
875
877{
879}
880
882{
883 if (invoker)
884 GetScript()->mLastInvoker = invoker->GetGUID();
885 GetScript()->SetScript9(e, entry);
886}
887
892
897
902
904{
905public:
906 SmartTrigger() : AreaTriggerScript("SmartTrigger") { }
907
908 bool OnTrigger(Player* player, AreaTriggerEntry const* trigger)
909 {
910 if (!player->IsAlive())
911 return false;
912
913 SF_LOG_DEBUG("scripts.ai", "AreaTrigger %u is using SmartTrigger script", trigger->id);
914 SmartScript script;
915 script.OnInitialize(NULL, trigger);
916 script.ProcessEventsFor(SMART_EVENT_AREATRIGGER_ONTRIGGER, player, trigger->id);
917 return true;
918 }
919};
920
922{
923 new SmartTrigger();
924}
@ PERMIT_BASE_SPECIAL
Definition CreatureAI.h:185
@ PERMIT_BASE_NO
Definition CreatureAI.h:180
std::int32_t int32
Definition Define.h:73
std::uint32_t uint32
Definition Define.h:77
std::int8_t int8
Definition Define.h:75
std::uint64_t uint64
Definition Define.h:76
std::uint16_t uint16
Definition Define.h:78
#define SF_LOG_DEBUG(filterType__,...)
Definition Log.h:134
#define SF_LOG_ERROR(filterType__,...)
Definition Log.h:143
@ MOTION_SLOT_ACTIVE
@ MOTION_SLOT_IDLE
@ IDLE_MOTION_TYPE
@ POINT_MOTION_TYPE
@ FOLLOW_MOTION_TYPE
@ RANDOM_MOTION_TYPE
#define INTERACTION_DISTANCE
Definition Object.h:21
#define PET_FOLLOW_DIST
Definition PetDefines.h:57
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:89
SpellEffIndex
@ CREATURE_TYPEFLAGS_AID_PLAYERS
void AddSC_SmartSCripts()
Definition SmartAI.cpp:921
@ SMART_ESCORT_ESCORTING
Definition SmartAI.h:21
@ SMART_ESCORT_PAUSED
Definition SmartAI.h:23
@ SMART_ESCORT_RETURNING
Definition SmartAI.h:22
@ SMART_ESCORT_NONE
Definition SmartAI.h:20
@ SMART_ESCORT_MAX_PLAYER_DIST
Definition SmartAI.h:28
@ SMART_MAX_AID_DIST
Definition SmartAI.h:29
#define sSmartWaypointMgr
@ SMART_EVENT_EVADE
@ SMART_EVENT_ACTION_DONE
@ SMART_EVENT_SUMMON_DESPAWNED
@ SMART_EVENT_SPELLHIT
@ SMART_EVENT_RECEIVE_EMOTE
@ SMART_EVENT_DATA_SET
@ SMART_EVENT_RECEIVE_HEAL
@ SMART_EVENT_DUMMY_EFFECT
@ SMART_EVENT_AREATRIGGER_ONTRIGGER
@ SMART_EVENT_ON_SPELLCLICK
@ SMART_EVENT_MOVEMENTINFORM
@ SMART_EVENT_PASSENGER_REMOVED
@ SMART_EVENT_WAYPOINT_PAUSED
@ SMART_EVENT_REACHED_HOME
@ SMART_EVENT_REWARD_QUEST
@ SMART_EVENT_GO_EVENT_INFORM
@ SMART_EVENT_JUST_SUMMONED
@ SMART_EVENT_CHARMED
@ SMART_EVENT_WAYPOINT_START
@ SMART_EVENT_SPELLHIT_TARGET
@ SMART_EVENT_GAME_EVENT_START
@ SMART_EVENT_KILL
@ SMART_EVENT_GOSSIP_HELLO
@ SMART_EVENT_GOSSIP_SELECT
@ SMART_EVENT_CORPSE_REMOVED
@ SMART_EVENT_PASSENGER_BOARDED
@ SMART_EVENT_WAYPOINT_ENDED
@ SMART_EVENT_ACCEPTED_QUEST
@ SMART_EVENT_WAYPOINT_RESUMED
@ SMART_EVENT_WAYPOINT_REACHED
@ SMART_EVENT_RESPAWN
@ SMART_EVENT_DEATH
@ SMART_EVENT_GAME_EVENT_END
@ SMART_EVENT_DAMAGED
@ SMART_EVENT_FOLLOW_COMPLETED
@ SMART_EVENT_WAYPOINT_STOPPED
@ SMART_EVENT_GO_STATE_CHANGED
@ SMART_EVENT_AGGRO
@ SMART_EVENT_DAMAGED_TARGET
@ SMART_EVENT_SUMMONED_UNIT
@ SMART_ESCORT_LAST_OOC_POINT
@ SMART_ESCORT_TARGETS
std::list< WorldObject * > ObjectList
@ SPELL_AURA_CLONE_CASTER
@ SPELL_AURA_CONTROL_VEHICLE
@ SPELL_AURA_MOD_STEALTH
@ UNIT_STATE_EVADE
Definition Unit.h:533
@ UNIT_STATE_ROAMING_MOVE
Definition Unit.h:534
@ UNIT_STATE_ROAMING
Definition Unit.h:516
@ REACT_PASSIVE
Definition Unit.h:1156
DamageEffectType
Definition Unit.h:613
@ UNIT_FIELD_CHARMED_BY
AreaTriggerScript(const char *name)
uint64 GetCasterGUID() const
Definition SpellAuras.h:91
bool HasEffectType(AuraType type) const
bool IsPassive() const
CreatureAI(Creature *creature)
Definition CreatureAI.h:69
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:56
std::string GetAIName() const
std::string GetAIName() const
Definition Group.h:147
GroupReference * next()
static Player * GetPlayer(WorldObject const &, uint64 guid)
static Unit * GetUnit(WorldObject const &, uint64 guid)
uint64 GetGUID() const
Definition Object.h:119
Player * ToPlayer()
Definition Object.h:204
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
bool IsAtGroupRewardDistance(WorldObject const *pRewardSource) const
Definition Player.cpp:19789
Corpse * GetCorpse() const
Definition Player.cpp:5385
Group * GetGroup()
Definition Player.h:2972
void AreaExploredOrEventHappens(uint32 questId)
QuestStatus GetQuestStatus(uint32 quest_id) const
void FailQuest(uint32 quest_id)
uint32 GetQuestId() const
Definition QuestDef.h:270
uint32 mDespawnTime
Definition SmartAI.h:221
uint32 mEscortState
Definition SmartAI.h:205
WayPoint * mLastWP
Definition SmartAI.h:210
bool OnGossipHello(Player *player) OVERRIDE
Definition SmartAI.cpp:718
WPPath * mWayPoints
Definition SmartAI.h:204
uint32 mEscortInvokerCheckTimer
Definition SmartAI.h:224
void OnSpellClick(Unit *clicker, bool &result) OVERRIDE
Definition SmartAI.cpp:799
void RemoveEscortState(uint32 uiEscortState)
Definition SmartAI.h:48
uint32 mDespawnState
Definition SmartAI.h:222
uint32 mWPPauseTimer
Definition SmartAI.h:209
void UpdatePath(const uint32 diff)
Definition SmartAI.cpp:230
void JustReachedHome() OVERRIDE
Definition SmartAI.cpp:552
void IsSummonedBy(Unit *summoner) OVERRIDE
Definition SmartAI.cpp:631
void StartPath(bool run=false, uint32 path=0, bool repeat=false, Unit *invoker=NULL)
Definition SmartAI.cpp:76
uint32 mCurrentWPID
Definition SmartAI.h:206
void PausePath(uint32 delay, bool forced=false)
Definition SmartAI.cpp:118
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
Definition SmartAI.cpp:296
void MoveInLineOfSight(Unit *who) OVERRIDE
Definition SmartAI.cpp:447
void sGossipSelect(Player *player, uint32 sender, uint32 action) OVERRIDE
Definition SmartAI.cpp:725
void RemoveAuras()
Definition SmartAI.cpp:400
void SetSwim(bool swim=true)
Definition SmartAI.cpp:708
void AttackStart(Unit *who) OVERRIDE
Definition SmartAI.cpp:581
bool mWPReached
Definition SmartAI.h:208
uint32 mLastWPIDReached
Definition SmartAI.h:207
uint32 mFollowArrivedTimer
Definition SmartAI.h:194
void StopPath(uint32 DespawnTime=0, uint32 quest=0, bool fail=false)
Definition SmartAI.cpp:140
void PassengerBoarded(Unit *who, int8 seatId, bool apply) OVERRIDE
== Fields =======================================
Definition SmartAI.cpp:653
static int Permissible(const Creature *)
Definition SmartAI.cpp:545
void UpdateAIWhileCharmed(const uint32 diff)
Definition SmartAI.cpp:646
void InitializeAI() OVERRIDE
Definition SmartAI.cpp:658
void SetDespawnTime(uint32 t)
Definition SmartAI.h:179
void StartDespawn()
Definition SmartAI.h:184
bool AssistPlayerInCombat(Unit *who)
Definition SmartAI.cpp:489
void EndPath(bool fail=false)
Definition SmartAI.cpp:157
void SetFollow(Unit *target, float dist=0.0f, float angle=0.0f, uint32 credit=0, uint32 end=0, uint32 creditType=0)
Definition SmartAI.cpp:772
SmartAI(Creature *c)
Definition SmartAI.cpp:21
void sQuestAccept(Player *player, Quest const *quest) OVERRIDE
Definition SmartAI.cpp:732
void sGossipHello(Player *player) OVERRIDE
Definition SmartAI.cpp:713
float mFollowAngle
Definition SmartAI.h:199
bool LoadPath(uint32 entry)
Definition SmartAI.cpp:104
void DamageDealt(Unit *doneTo, uint32 &damage, DamageEffectType) OVERRIDE
Definition SmartAI.cpp:636
WayPoint * GetNextWayPoint()
Definition SmartAI.cpp:57
uint32 mEscortQuestID
Definition SmartAI.h:177
void MovepointReached(uint32 id)
Definition SmartAI.cpp:380
void JustRespawned() OVERRIDE
Definition SmartAI.cpp:526
void MovementInform(uint32 MovementType, uint32 Data) OVERRIDE
Definition SmartAI.cpp:389
bool CanAIAttack(const Unit *who) const OVERRIDE
Definition SmartAI.cpp:482
void CorpseRemoved(uint32 &respawnDelay) OVERRIDE
== State checks =================================
Definition SmartAI.cpp:648
void SetGUID(uint64 guid, int32 id=0) OVERRIDE
Definition SmartAI.cpp:690
bool _gossipReturn
Definition SmartAI.h:225
bool mRun
Definition SmartAI.h:214
void SpellHitTarget(Unit *target, const SpellInfo *spellInfo) OVERRIDE
Definition SmartAI.cpp:606
uint32 mFollowCreditType
Definition SmartAI.h:193
uint32 GetData(uint32 id=0) const OVERRIDE
Definition SmartAI.cpp:680
void OnCharmed(bool apply) OVERRIDE
Definition SmartAI.cpp:666
void sQuestReward(Player *player, Quest const *quest, uint32 opt) OVERRIDE
Definition SmartAI.cpp:737
void KilledUnit(Unit *victim) OVERRIDE
Definition SmartAI.cpp:571
void Reset() OVERRIDE
Definition SmartAI.cpp:50
uint32 mInvincibilityHpLevel
Definition SmartAI.h:218
bool mCanAutoAttack
Definition SmartAI.h:215
void DamageTaken(Unit *doneBy, uint32 &damage) OVERRIDE
Definition SmartAI.cpp:611
void sGossipSelectCode(Player *player, uint32 sender, uint32 action, const char *code) OVERRIDE
Definition SmartAI.cpp:730
uint64 GetGUID(int32 id=0) const OVERRIDE
Definition SmartAI.cpp:692
bool mCanRepeatPath
Definition SmartAI.h:213
bool sOnDummyEffect(Unit *caster, uint32 spellId, SpellEffIndex effIndex) OVERRIDE
Definition SmartAI.cpp:742
void SetFly(bool fly=true)
Definition SmartAI.cpp:703
bool mCanCombatMove
Definition SmartAI.h:216
void ReturnToLastOOCPos()
Definition SmartAI.cpp:224
void EnterEvadeMode() OVERRIDE
Definition SmartAI.cpp:414
void JustSummoned(Creature *creature) OVERRIDE
Definition SmartAI.cpp:576
void EnterCombat(Unit *enemy) OVERRIDE
Definition SmartAI.cpp:557
bool mForcedPaused
Definition SmartAI.h:217
bool HasEscortState(uint32 uiEscortState) const
Definition SmartAI.h:46
void AddEscortState(uint32 uiEscortState)
Definition SmartAI.h:47
uint32 mFollowCredit
Definition SmartAI.h:195
uint32 mFollowArrivedEntry
Definition SmartAI.h:196
float mFollowDist
Definition SmartAI.h:198
void SummonedCreatureDespawn(Creature *unit) OVERRIDE
Definition SmartAI.cpp:641
uint64 mFollowGuid
Definition SmartAI.h:197
void DoAction(int32 param=0) OVERRIDE
Definition SmartAI.cpp:675
void SpellHit(Unit *unit, const SpellInfo *spellInfo) OVERRIDE
Definition SmartAI.cpp:601
void SetCombatMove(bool on)
Definition SmartAI.cpp:748
void SetScript9(SmartScriptHolder &e, uint32 entry, Unit *invoker)
Definition SmartAI.cpp:787
SmartScript * GetScript()
Definition SmartAI.h:55
void ReceiveEmote(Player *player, uint32 textEmote) OVERRIDE
Definition SmartAI.cpp:626
uint32 GetWPCount()
Definition SmartAI.h:212
void SetRun(bool run=true)
Definition SmartAI.cpp:697
void UpdateDespawn(const uint32 diff)
Definition SmartAI.cpp:31
Position mLastOOCPos
Definition SmartAI.h:211
void JustDied(Unit *killer) OVERRIDE
Definition SmartAI.cpp:564
void ResumePath()
Definition SmartAI.cpp:216
void HealReceived(Unit *doneBy, uint32 &addhealth) OVERRIDE
Definition SmartAI.cpp:621
bool IsEscortInvokerInRange()
Definition SmartAI.cpp:343
void sOnGameEvent(bool start, uint16 eventId) OVERRIDE
Definition SmartAI.cpp:794
void SetData(uint32 id, uint32 value) OVERRIDE
Definition SmartAI.cpp:685
void SetData(uint32 id, uint32 value) OVERRIDE
Definition SmartAI.cpp:876
bool GossipHello(Player *player) OVERRIDE
Definition SmartAI.cpp:832
bool GossipSelect(Player *player, uint32 sender, uint32 action) OVERRIDE
Definition SmartAI.cpp:841
GameObject *const go
Definition SmartAI.h:255
bool QuestAccept(Player *player, Quest const *quest) OVERRIDE
Definition SmartAI.cpp:854
void SetScript9(SmartScriptHolder &e, uint32 entry, Unit *invoker)
Definition SmartAI.cpp:881
void OnStateChanged(uint32 state, Unit *unit) OVERRIDE
Definition SmartAI.cpp:893
void EventInform(uint32 eventId) OVERRIDE
Definition SmartAI.cpp:898
void Reset() OVERRIDE
Definition SmartAI.cpp:826
SmartScript * GetScript()
Definition SmartAI.h:237
void UpdateAI(uint32 diff) OVERRIDE
Definition SmartAI.cpp:814
uint32 GetDialogStatus(Player *) OVERRIDE
Definition SmartAI.cpp:868
static int Permissible(const GameObject *g)
Definition SmartAI.cpp:807
void OnGameEvent(bool start, uint16 eventId) OVERRIDE
Definition SmartAI.cpp:888
void InitializeAI() OVERRIDE
Definition SmartAI.cpp:819
void Destroyed(Player *player, uint32 eventId) OVERRIDE
Definition SmartAI.cpp:871
bool GossipSelectCode(Player *, uint32, uint32, const char *) OVERRIDE
Definition SmartAI.cpp:848
bool QuestReward(Player *player, Quest const *quest, uint32 opt) OVERRIDE
Definition SmartAI.cpp:861
void OnUpdate(const uint32 diff)
void SetScript9(SmartScriptHolder &e, uint32 entry)
void ProcessEventsFor(SMART_EVENT e, Unit *unit=NULL, uint32 var0=0, uint32 var1=0, bool bvar=false, const SpellInfo *spell=NULL, GameObject *gob=NULL)
void OnInitialize(WorldObject *obj, AreaTriggerEntry const *at=NULL)
uint64 mLastInvoker
void OnMoveInLineOfSight(Unit *who)
ObjectList * GetTargetList(uint32 id)
void SetPathId(uint32 id)
Definition SmartScript.h:41
bool OnTrigger(Player *player, AreaTriggerEntry const *trigger)
Definition SmartAI.cpp:908
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:28
Definition Unit.h:1367
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition Unit.h:1376
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition Unit.cpp:2355
bool IsAlive() const
Definition Unit.h:2032
void RemoveAurasByType(AuraType auraType, uint64 casterGUID=0, Aura *except=NULL, bool negative=true, bool positive=true)
Unit * GetVictim() const
Definition Unit.h:1468
void SetInCombatWith(Unit *enemy)
Data
Definition molten_core.h:55
uint32 id