OregonCore  revision fb2a440-git
Your Favourite TBC server
SmartAI.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of the OregonCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #include "DatabaseEnv.h"
19 #include "ObjectMgr.h"
20 #include "GridDefines.h"
21 #include "GridNotifiers.h"
22 #include "SpellMgr.h"
23 #include "Cell.h"
24 #include "Group.h"
25 #include "SmartAI.h"
26 #include "ScriptMgr.h"
27 
29 {
30  // copy script to local (protection for table reload)
31 
32  mWayPoints = NULL;
34  mCurrentWPID = 0;//first wp id is 1 !!
35  mWPReached = false;
36  mWPPauseTimer = 0;
37  mLastWP = NULL;
38 
39  mCanRepeatPath = false;
40 
41  // spawn in run mode
42  me->SetWalk(false);
43  mRun = false;
44 
46 
47  mCanAutoAttack = true;
48  mCanCombatMove = true;
49 
50  mForcedPaused = false;
51  mLastWPIDReached = 0;
52 
53  mEscortQuestID = 0;
54 
55  mDespawnTime = 0;
56  mDespawnState = 0;
57 
60  mFollowDist = 0;
61  mFollowAngle = 0;
62  mFollowCredit = 0;
67 
68  mJustReset = false;
69 }
70 
72 {
73  if (mDespawnState <= 1 || mDespawnState > 3)
74  return;
75 
76  if (mDespawnTime < diff)
77  {
78  if (mDespawnState == 2)
79  {
80  me->SetVisible(false);
81  mDespawnTime = 5000;
82  mDespawnState++;
83  }
84  else
86  } else mDespawnTime -= diff;
87 }
88 
90 {
91  if (!mWayPoints || mWayPoints->empty())
92  return NULL;
93 
94  mCurrentWPID++;
95  WPPath::const_iterator itr = mWayPoints->find(mCurrentWPID);
96  if (itr != mWayPoints->end())
97  {
98  mLastWP = (*itr).second;
99  if (mLastWP->id != mCurrentWPID)
100  {
101  sLog.outError("SmartAI::GetNextWayPoint: Got not expected waypoint id %u, expected %u", mLastWP->id, mCurrentWPID);
102  }
103  return (*itr).second;
104  }
105  return NULL;
106 }
107 
108 void SmartAI::StartPath(bool run, uint32 path, bool repeat, Unit* /*invoker*/)
109 {
110  if (me->IsInCombat())// no wp movement in combat
111  {
112  sLog.outError("SmartAI::StartPath: Creature entry %u wanted to start waypoint movement while in combat, ignoring.", me->GetEntry());
113  return;
114  }
116  StopPath();
117  if (path)
118  if (!LoadPath(path))
119  return;
120  if (!mWayPoints || mWayPoints->empty())
121  return;
122 
124  mCanRepeatPath = repeat;
125 
126  SetRun(run);
127 
128  if (WayPoint* wp = GetNextWayPoint())
129  {
131  me->GetMotionMaster()->MovePoint(wp->id, wp->x, wp->y, wp->z);
132  GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_START, NULL, wp->id, GetScript()->GetPathId());
133  }
134 }
135 
137 {
139  return false;
140  mWayPoints = sSmartWaypointMgr->GetPath(entry);
141  if (!mWayPoints)
142  {
143  GetScript()->SetPathId(0);
144  return false;
145  }
146  GetScript()->SetPathId(entry);
147  return true;
148 }
149 
150 void SmartAI::PausePath(uint32 delay, bool forced)
151 {
153  {
154  sLog.outError("SmartAI::StartPath: Creature entry %u wanted to pause waypoint movement while already paused, ignoring.", me->GetEntry());
155  return;
156  }
157  mForcedPaused = forced;
160  mWPPauseTimer = delay;
161  if (forced)
162  {
163  SetRun(mRun);
164  me->StopMoving();//force stop
165  me->GetMotionMaster()->MoveIdle();//force stop
166  }
168 }
169 
170 void SmartAI::StopPath(uint32 DespawnTime, uint32 quest, bool fail)
171 {
172  if (quest)
173  mEscortQuestID = quest;
174  SetDespawnTime(DespawnTime);
175  //mDespawnTime = DespawnTime;
176 
178  me->StopMoving();//force stop
181  EndPath(fail);
182 }
183 
184 void SmartAI::EndPath(bool fail)
185 {
187 
189  mWayPoints = NULL;
190  mCurrentWPID = 0;
191  mWPPauseTimer = 0;
192  mLastWP = NULL;
193 
194  if (mCanRepeatPath)
195  StartPath(mRun, GetScript()->GetPathId(), true);
196  else
197  GetScript()->SetPathId(0);
198 
200  if (targets && mEscortQuestID)
201  {
202  if (targets->size() == 1 && GetScript()->IsPlayer((*targets->begin())))
203  {
204  Player* player = (*targets->begin())->ToPlayer();
205  if (!fail && player->IsAtGroupRewardDistance(me) && !player->GetCorpse())
207 
208  if (fail && player->GetQuestStatus(mEscortQuestID) == QUEST_STATUS_INCOMPLETE)
209  player->FailQuest(mEscortQuestID);
210 
211  if (Group* group = player->GetGroup())
212  {
213  for (GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->next())
214  {
215  Player* groupGuy = groupRef->GetSource();
216  if (!groupGuy->IsInMap(player))
217  continue;
218 
219  if (!fail && groupGuy->IsAtGroupRewardDistance(me) && !groupGuy->GetCorpse())
221  if (fail && groupGuy->GetQuestStatus(mEscortQuestID) == QUEST_STATUS_INCOMPLETE)
222  groupGuy->FailQuest(mEscortQuestID);
223  }
224  }
225  }else
226  {
227  for (ObjectList::iterator iter = targets->begin(); iter != targets->end(); ++iter)
228  {
229  if (GetScript()->IsPlayer((*iter)))
230  {
231  Player* player = (*iter)->ToPlayer();
232  if (!fail && player->IsAtGroupRewardDistance(me) && !player->GetCorpse())
234  if (fail && player->GetQuestStatus(mEscortQuestID) == QUEST_STATUS_INCOMPLETE)
235  player->FailQuest(mEscortQuestID);
236  }
237  }
238  }
239  }
240  if (mDespawnState == 1)
241  StartDespawn();
242 }
243 
245 {
246  //mWPReached = false;
247  SetRun(mRun);
248  if (mLastWP)
250 }
251 
253 {
254  SetRun(mRun);
256 }
257 
258 void SmartAI::UpdatePath(const uint32 diff)
259 {
260  if (mEscortInvokerCheckTimer < diff)
261  {
262  if (!IsEscortInvokerInRange())
263  {
265  }
267  } else mEscortInvokerCheckTimer -= diff;
268  // handle pause
270  {
271  if (mWPPauseTimer < diff)
272  {
274  {
277  if (mForcedPaused)// if paused between 2 wps resend movement
278  {
279  ResumePath();
280  mWPReached = false;
281  mForcedPaused = false;
282  }
284  mWPReached = true;
285  }
286  mWPPauseTimer = 0;
287  } else {
288  mWPPauseTimer -= diff;
289  }
290  }
292  {
293  if (mWPReached)//reached OOC WP
294  {
297  ResumePath();
298  mWPReached = false;
299  }
300  }
302  return;
303  // handle next wp
304  if (mWPReached)//reached WP
305  {
306  mWPReached = false;
307  if (mCurrentWPID == GetWPCount())
308  {
309  EndPath();
310  }
311  else if (WayPoint* wp = GetNextWayPoint())
312  {
313  SetRun(mRun);
314  me->GetMotionMaster()->MovePoint(wp->id, wp->x, wp->y, wp->z);
315  }
316  }
317 }
318 
320 {
321  GetScript()->OnUpdate(diff);
322  UpdatePath(diff);
323  UpdateDespawn(diff);
324 
326  if (mFollowGuid)
327  {
328  if (mFollowArrivedTimer < diff)
329  {
331  {
332  StopFollow();
333  return;
334  }
335 
336  mFollowArrivedTimer = 1000;
337  }
338  else
339  mFollowArrivedTimer -= diff;
340  }
341 
342  if (!UpdateVictim())
343  return;
344 
345  if (mCanAutoAttack)
347 }
348 
350 {
352  if (targets)
353  {
354  if (targets->size() == 1 && GetScript()->IsPlayer((*targets->begin())))
355  {
356  Player* player = (*targets->begin())->ToPlayer();
358  return true;
359 
360  if (Group* group = player->GetGroup())
361  {
362  for (GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->next())
363  {
364  Player* groupGuy = groupRef->GetSource();
365 
366  if (groupGuy->IsInMap(player) && me->GetDistance(groupGuy) <= SMART_ESCORT_MAX_PLAYER_DIST)
367  return true;
368  }
369  }
370  }else
371  {
372  for (ObjectList::iterator iter = targets->begin(); iter != targets->end(); ++iter)
373  {
374  if (GetScript()->IsPlayer((*iter)))
375  {
376  if (me->GetDistance((*iter)->ToPlayer()) <= SMART_ESCORT_MAX_PLAYER_DIST)
377  return true;
378  }
379  }
380  }
381  }
382  return true;//escort targets were not set, ignore range check
383 }
384 
386 {
389 
390  mLastWPIDReached = id;
391  mWPReached = true;
392 }
393 
394 void SmartAI::MovementInform(uint32 MovementType, uint32 Data)
395 {
396  if ((MovementType == POINT_MOTION_TYPE && Data == SMART_ESCORT_LAST_OOC_POINT) || MovementType == FOLLOW_MOTION_TYPE)
398 
399  GetScript()->ProcessEventsFor(SMART_EVENT_MOVEMENTINFORM, NULL, MovementType, Data);
401  return;
402  MovepointReached(Data);
403 }
404 
406 {
407  if (!me->IsAlive() || me->IsInEvadeMode())
408  return;
409 
410  me->RemoveAllAuras();
411 
413  me->DeleteThreatList();
414  me->CombatStop(true);
416  me->SetLootRecipient(NULL);
417  me->SetPlayerDamaged(false);
419 
420  GetScript()->ProcessEventsFor(SMART_EVENT_EVADE);//must be after aura clear so we can cast spells from db
421 
422  SetRun(mRun);
424  {
427  }
428  else if (mFollowGuid)
429  {
430  if (Unit* target = ObjectAccessor::GetUnit(*me, mFollowGuid))
432 
433  // evade is not cleared in MoveFollow, so we can't keep it
435  }
436  else
438 
439  if (!HasEscortState(SMART_ESCORT_ESCORTING))//dont mess up escort movement after combat
440  SetRun(mRun);
441 }
442 
444 {
445  if (!who)
446  return;
447 
449 
450  if (AssistPlayerInCombat(who))
451  return;
452 
454 }
455 
457 {
458  if (!who || !who->GetVictim())
459  return false;
460 
462  return false;
463 
464  //not a player
466  return false;
467 
468  //never attack friendly
469  if (me->IsFriendlyTo(who))
470  return false;
471 
472  //too far away and no free sight?
474  {
475  //already fighting someone?
476  if (!me->GetVictim())
477  {
478  AttackStart(who);
479  return true;
480  }
481  else
482  {
483  who->SetInCombatWith(me);
484  me->AddThreat(who, 0.0f);
485  return true;
486  }
487  }
488 
489  return false;
490 }
491 
493 {
494  mDespawnTime = 0;
495  mDespawnState = 0;
497  me->SetVisible(true);
499  me->RestoreFaction();
500  mJustReset = true;
501  JustReachedHome();
503  mFollowGuid.Clear();//do not reset follower on Reset(), we need it after combat evade
504  mFollowDist = 0;
505  mFollowAngle = 0;
506  mFollowCredit = 0;
507  mFollowArrivedTimer = 1000;
509  mFollowCreditType = 0;
510 }
511 
512 int SmartAI::Permissible(const Creature* creature)
513 {
514  if (creature->GetAIName() == "SmartAI")
515  return PERMIT_BASE_SPECIAL;
516  return PERMIT_BASE_NO;
517 }
518 
520 {
521  GetScript()->OnReset();
522 
523  if (!mJustReset)
524  {
526 
529  }
530 
531  mJustReset = false;
532 }
533 
535 {
536  me->InterruptNonMeleeSpells(false); // must be before ProcessEvents
539  SetRun(mRun);
542 }
543 
544 void SmartAI::JustDied(Unit* killer)
545 {
548  {
549  EndPath(true);
550  me->StopMoving();//force stop
552  }
553 }
554 
556 {
558 }
559 
561 {
563 }
564 
566 {
567  if (who && me->Attack(who, me->IsWithinMeleeRange(who)))
568  {
569  if (mCanCombatMove)
570  me->GetMotionMaster()->MoveChase(who);
571  }
572 }
573 
574 void SmartAI::SpellHit(Unit* unit, const SpellEntry* spellInfo)
575 {
576  GetScript()->ProcessEventsFor(SMART_EVENT_SPELLHIT, unit, 0, 0, false, spellInfo);
577 }
578 
579 void SmartAI::SpellHitTarget(Unit* target, const SpellEntry* spellInfo)
580 {
581  GetScript()->ProcessEventsFor(SMART_EVENT_SPELLHIT_TARGET, target, 0, 0, false, spellInfo);
582 }
583 
584 void SmartAI::DamageTaken(Unit* doneBy, uint32& damage)
585 {
586  GetScript()->ProcessEventsFor(SMART_EVENT_DAMAGED, doneBy, damage);
588  damage = me->GetHealth() - mInvincibilityHpLevel; // damage should not be nullified, because of player damage req.
589 }
590 
591 void SmartAI::HealReceived(Unit* doneBy, uint32& addhealth)
592 {
593  GetScript()->ProcessEventsFor(SMART_EVENT_RECEIVE_HEAL, doneBy, addhealth);
594 }
595 
596 void SmartAI::ReceiveEmote(Player* player, uint32 textEmote)
597 {
599 }
600 
602 {
604 }
605 
606 void SmartAI::DamageDealt(Unit* doneTo, uint32& damage, DamageEffectType /*damagetype*/)
607 {
609 }
610 
612 {
614 }
615 
616 void SmartAI::UpdateAIWhileCharmed(const uint32 /*diff*/) { }
617 
618 void SmartAI::CorpseRemoved(time_t respawnDelay)
619 {
620  GetScript()->ProcessEventsFor(SMART_EVENT_CORPSE_REMOVED, NULL, respawnDelay);
621 }
622 
623 void SmartAI::PassengerBoarded(Unit* who, int8 seatId, bool apply)
624 {
626 }
627 
629 {
631 
632  if (!me->isDead())
633  mJustReset = true;
634 
635  JustReachedHome();
637 }
638 
640 {
641  GetScript()->ProcessEventsFor(SMART_EVENT_CHARMED, NULL, 0, 0, apply);
642 
643  if (!apply && !me->IsInEvadeMode() && me->GetCharmerGUID())
644  if (Unit* charmer = ObjectAccessor::GetUnit(*me, me->GetCharmerGUID()))
645  AttackStart(charmer);
646 }
647 
649 {
651 }
652 
654 {
655  return 0;
656 }
657 
659 {
660  GetScript()->ProcessEventsFor(SMART_EVENT_DATA_SET, NULL, id, value);
661 }
662 
663 void SmartAI::SetGUID(const uint64& /*guid*/, int32 /*id*/) { }
664 
666 {
667  return 0;
668 }
669 
670 void SmartAI::SetRun(bool run)
671 {
672  me->SetWalk(!run);
673  mRun = run;
674 }
675 
676 void SmartAI::SetFly(bool fly)
677 {
678  me->SetLevitate(fly);
679 }
680 
681 void SmartAI::SetSwim(bool swim)
682 {
683  me->SetSwim(swim);
684 }
685 
687 {
689 }
690 
691 void SmartAI::sGossipSelect(Player* player, uint32 sender, uint32 action)
692 {
693  GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_SELECT, player, sender, action);
694 }
695 
696 void SmartAI::sGossipSelectCode(Player* /*player*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { }
697 
698 void SmartAI::QuestAccept(Player* player, Quest const* quest)
699 {
701 }
702 
703 void SmartAI::sQuestReward(Player* player, Quest const* quest, uint32 opt)
704 {
706 }
707 
708 bool SmartAI::sOnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex)
709 {
710  GetScript()->ProcessEventsFor(SMART_EVENT_DUMMY_EFFECT, caster, spellId, (uint32)effIndex);
711  return true;
712 }
713 
715 {
716  if (mCanCombatMove == on)
717  return;
718  mCanCombatMove = on;
720  {
721  if (on && me->GetVictim())
722  {
724  {
725  SetRun(mRun);
727  me->CastStop();
728  }
729  }
730  else
731  {
733  return;
734 
736  me->GetMotionMaster()->Clear(true);
737  me->StopMoving();
739  }
740  }
741 }
742 
743 void SmartAI::SetFollow(Unit* target, float dist, float angle, uint32 credit, uint32 end, uint32 creditType)
744 {
745  if (!target)
746  {
747  StopFollow();
748  return;
749  }
750 
751  SetRun(mRun);
752  mFollowGuid = target->GetGUID();
753  mFollowDist = dist >= 0.0f ? dist : PET_FOLLOW_DIST;
754  mFollowAngle = angle >= 0.0f ? angle : me->GetFollowAngle();
755  mFollowArrivedTimer = 1000;
756  mFollowCredit = credit;
757  mFollowArrivedEntry = end;
759  mFollowCreditType = creditType;
760 }
761 
763 {
765  {
766  if (!mFollowCreditType)
767  player->RewardPlayerAndGroupAtEvent(mFollowCredit, me);
768  else
769  player->GroupEventHappens(mFollowCredit, me);
770  }
771 
772  mFollowGuid.Clear();
773  mFollowDist = 0;
774  mFollowAngle = 0;
775  mFollowCredit = 0;
776  mFollowArrivedTimer = 1000;
778  mFollowCreditType = 0;
779  SetDespawnTime(5000);
780  me->StopMoving();
782  StartDespawn();
784 }
786 {
787  if (invoker)
788  GetScript()->mLastInvoker = invoker->GetGUID();
789  GetScript()->SetScript9(e, entry);
790 }
791 
792 void SmartAI::sOnGameEvent(bool start, uint16 eventId)
793 {
795 }
796 
798 {
800 }
801 
803 {
804  if (g->GetAIName() == "SmartGameObjectAI")
805  return PERMIT_BASE_SPECIAL;
806  return PERMIT_BASE_NO;
807 }
808 
810 {
811  GetScript()->OnUpdate(diff);
812 }
813 
815 {
816  GetScript()->OnInitialize(go);
817 
818  //Reset();
819 }
820 
822 {
823  GetScript()->OnReset();
824 }
825 
826 // Called when a player opens a gossip dialog with the gameobject.
828 {
829  sLog.outError("SmartGameObjectAI::GossipHello");
830  GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_HELLO, player, 0, 0, false, NULL, go);
831  return false;
832 }
833 
834 // Called when a player selects a gossip item in the gameobject's gossip menu.
836 {
837  GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_SELECT, player, sender, action, false, NULL, go);
838  return false;
839 }
840 
841 // Called when a player selects a gossip with a code in the gameobject's gossip menu.
842 bool SmartGameObjectAI::GossipSelectCode(Player* /*player*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/)
843 {
844  return false;
845 }
846 
847 // Called when a player accepts a quest from the gameobject.
848 bool SmartGameObjectAI::QuestAccept(Player* player, Quest const* quest)
849 {
850  GetScript()->ProcessEventsFor(SMART_EVENT_ACCEPTED_QUEST, player, quest->GetQuestId(), 0, false, NULL, go);
851  return false;
852 }
853 
854 // Called when a player selects a quest reward.
855 bool SmartGameObjectAI::QuestReward(Player* player, Quest const* quest, uint32 opt)
856 {
857  GetScript()->ProcessEventsFor(SMART_EVENT_REWARD_QUEST, player, quest->GetQuestId(), opt, false, NULL, go);
858  return false;
859 }
860 
861 // Called when the gameobject is destroyed (destructible buildings only).
863 {
864  GetScript()->ProcessEventsFor(SMART_EVENT_DEATH, player, eventId, 0, false, NULL, go);
865 }
866 
868 {
869  GetScript()->ProcessEventsFor(SMART_EVENT_DATA_SET, NULL, id, value);
870 }
871 
873 {
874  if (invoker)
875  GetScript()->mLastInvoker = invoker->GetGUID();
876  GetScript()->SetScript9(e, entry);
877 }
878 
879 void SmartGameObjectAI::OnGameEvent(bool start, uint16 eventId)
880 {
882 }
883 
885 {
887 }
888 
890 {
891 }
#define INTERACTION_DISTANCE
Definition: Object.h:35
bool QuestAccept(Player *player, Quest const *quest) override
Definition: SmartAI.cpp:848
void SpellHit(Unit *unit, const SpellEntry *spellInfo) override
Definition: SmartAI.cpp:574
static int Permissible(const GameObject *g)
Definition: SmartAI.cpp:802
void OnUpdate(const uint32 diff)
bool SetWalk(bool enable) override
Definition: Creature.cpp:2528
void DespawnOrUnsummon(uint32 msTimeToDespawn=0)
Definition: Creature.cpp:1718
void RemoveAllAuras()
Definition: Unit.cpp:4577
Group * GetGroup()
Definition: Player.h:2577
void UpdateAIWhileCharmed(const uint32 diff)
Definition: SmartAI.cpp:616
void StopPath(uint32 DespawnTime=0, uint32 quest=0, bool fail=false)
Definition: SmartAI.cpp:170
bool Attack(Unit *victim, bool meleeAttack)
Definition: Unit.cpp:7390
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition: Player.cpp:13634
void SetScript9(SmartScriptHolder &e, uint32 entry, Unit *invoker)
Definition: SmartAI.cpp:785
void MoveIdle(MovementSlot slot=MOTION_SLOT_ACTIVE)
void RemoveEscortState(uint32 uiEscortState)
Definition: SmartAI.h:61
bool GossipSelect(Player *player, uint32 sender, uint32 action) override
Definition: SmartAI.cpp:835
void SetRun(bool run=true)
Definition: SmartAI.cpp:670
bool UpdateVictim()
Definition: CreatureAI.cpp:276
uint32 mFollowCredit
Definition: SmartAI.h:197
float mFollowAngle
Definition: SmartAI.h:201
uint32 GetFaction() const
Definition: Unit.h:1116
void sGossipSelect(Player *player, uint32 sender, uint32 action) override
Definition: SmartAI.cpp:691
void DoAction(const int32 param=0) override
Definition: SmartAI.cpp:648
void Clear(bool reset=true)
Definition: MotionMaster.h:145
void SetFollow(Unit *target, float dist=0.0f, float angle=0.0f, uint32 credit=0, uint32 end=0, uint32 creditType=0)
Definition: SmartAI.cpp:743
void SetSwim(bool swim=true)
Definition: SmartAI.cpp:681
void AddUnitState(uint32 f)
Definition: Unit.h:1026
pet will not attack
Definition: Unit.h:760
uint32 mInvincibilityHpLevel
Definition: SmartAI.h:220
bool sOnDummyEffect(Unit *caster, uint32 spellId, SpellEffIndex effIndex) override
Definition: SmartAI.cpp:708
bool mForcedPaused
Definition: SmartAI.h:219
void AddThreat(Unit *victim, float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *threatSpell=NULL)
Definition: Unit.cpp:10208
void MoveChase(Unit *target, float dist=0.0f, float angle=0.0f)
void ReceiveEmote(Player *player, uint32 textEmote) override
Definition: SmartAI.cpp:596
void SetCombatMove(bool on)
Definition: SmartAI.cpp:714
uint64 GetCharmerGUID() const
Definition: Unit.h:1362
static int Permissible(const Creature *)
Definition: SmartAI.cpp:512
void MovepointReached(uint32 id)
Definition: SmartAI.cpp:385
bool mCanRepeatPath
Definition: SmartAI.h:215
uint32 GetWaypointPath()
Definition: Creature.h:741
MotionMaster * GetMotionMaster()
Definition: Unit.h:1890
bool IsInCombat() const
Definition: Unit.h:1243
void SetFly(bool fly=true)
Definition: SmartAI.cpp:676
bool IsEscortInvokerInRange()
Definition: SmartAI.cpp:349
bool SetSwim(bool enable) override
Definition: Creature.cpp:2539
#define sLog
Log class singleton.
Definition: Log.h:187
void OnReset()
Definition: SmartScript.cpp:87
void MoveTargetedHome()
void MoveInLineOfSight(Unit *who) override
Definition: SmartAI.cpp:443
MovementGeneratorType GetCurrentMovementGeneratorType() const
uint32 mCurrentWPID
Definition: SmartAI.h:208
uint32 mEscortQuestID
Definition: SmartAI.h:183
#define PET_FOLLOW_DIST
uint32 mDespawnTime
Definition: SmartAI.h:223
ACE_INT32 int32
Definition: Define.h:67
bool IsWithinLOSInMap(const WorldObject *obj) const
Definition: Object.cpp:1229
uint32 mFollowArrivedTimer
Definition: SmartAI.h:196
bool HasReactState(ReactStates state) const
Definition: Creature.h:497
bool IsInEvadeMode() const
Definition: Creature.cpp:2298
void CorpseRemoved(time_t respawnDelay) override
Definition: SmartAI.cpp:618
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
Definition: Player.cpp:13749
void SetScript9(SmartScriptHolder &e, uint32 entry, Unit *invoker)
Definition: SmartAI.cpp:872
WayPoint * GetNextWayPoint()
Definition: SmartAI.cpp:89
void StartPath(bool run=false, uint32 path=0, bool repeat=false, Unit *invoker=NULL)
Definition: SmartAI.cpp:108
bool IsAtGroupRewardDistance(WorldObject const *pRewardSource) const
Definition: Player.cpp:19935
void MovementInform(uint32 MovementType, uint32 Data) override
Definition: SmartAI.cpp:394
void MovePoint(uint32 id, const Position &pos, bool usePathfinding=true)
Definition: MotionMaster.h:179
void CastStop(uint32 except_spellid=0)
Definition: Unit.cpp:1216
bool mCanAutoAttack
Definition: SmartAI.h:217
void StartDespawn()
Definition: SmartAI.h:190
void OnGameEvent(bool start, uint16 eventId) override
Definition: SmartAI.cpp:879
std::string GetAIName() const
static Player * GetPlayer(WorldObject const &, uint64 guid)
void SpellHitTarget(Unit *target, const SpellEntry *spellInfo) override
Definition: SmartAI.cpp:579
void apply(T *val)
Definition: ByteConverter.h:41
uint32 mWPPauseTimer
Definition: SmartAI.h:211
void SummonedCreatureDespawn(Creature *unit) override
Definition: SmartAI.cpp:611
void OnCharmed(bool apply) override
Definition: SmartAI.cpp:639
bool IsPlayer(WorldObject *obj)
Definition: SmartScript.h:71
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.h:774
Player * ToPlayer()
Definition: Object.h:392
void ReturnToLastOOCPos()
Definition: SmartAI.cpp:252
void JustSummoned(Creature *creature) override
Definition: SmartAI.cpp:560
SmartAI(Creature *c)
Definition: SmartAI.cpp:28
void SetLootRecipient(Unit *unit)
Definition: Creature.cpp:1012
uint32 id
ACE_INT8 int8
Definition: Define.h:69
void DamageDealt(Unit *doneTo, uint32 &damage, DamageEffectType) override
Definition: SmartAI.cpp:606
bool AssistPlayerInCombat(Unit *who)
Definition: SmartAI.cpp:456
void OnStateChanged(uint32 state, Unit *unit) override
Definition: SmartAI.cpp:884
ObjectGuid mFollowGuid
Definition: SmartAI.h:199
void ClearUnitState(uint32 f)
Definition: Unit.h:1034
Creature *const me
Definition: CreatureAI.h:68
void HealReceived(Unit *doneBy, uint32 &addhealth) override
Definition: SmartAI.cpp:591
void FailQuest(uint32 questId)
Definition: Player.cpp:13171
std::list< WorldObject * > ObjectList
uint32 mDespawnState
Definition: SmartAI.h:224
void sOnGameEvent(bool start, uint16 eventId) override
Definition: SmartAI.cpp:792
void IsSummonedBy(Unit *summoner) override
Definition: SmartAI.cpp:601
void UpdateAI(const uint32 diff) override
Definition: SmartAI.cpp:319
bool SetLevitate(bool enable, bool packetOnly=false) override
Definition: Creature.cpp:2609
void DamageTaken(Unit *doneBy, uint32 &damage) override
Definition: SmartAI.cpp:584
void QuestAccept(Player *player, Quest const *quest) override
Definition: SmartAI.cpp:698
void OnInitialize(WorldObject *obj, AreaTriggerEntry const *at=NULL)
uint32 mFollowArrivedEntry
Definition: SmartAI.h:198
void Destroyed(Player *player, uint32 eventId) override
Definition: SmartAI.cpp:862
void EnterCombat(Unit *enemy) override
Definition: SmartAI.cpp:534
WayPoint * mLastWP
Definition: SmartAI.h:212
void EnterEvadeMode() override
Definition: SmartAI.cpp:405
uint32 faction
Definition: Creature.h:150
uint32 GetQuestId() const
Definition: QuestDef.h:186
bool GossipSelectCode(Player *, uint32, uint32, const char *) override
Definition: SmartAI.cpp:842
ObjectGuid mLastInvoker
Definition: SmartScript.h:238
Position mLastOOCPos
Definition: SmartAI.h:213
bool IsAlive() const
Definition: Unit.h:1336
Unit * GetVictim() const
Definition: Unit.h:1013
void PausePath(uint32 delay, bool forced=false)
Definition: SmartAI.cpp:150
float GetDistance(const WorldObject *obj) const
Definition: Object.h:718
void RestoreFaction()
Definition: Unit.cpp:13318
void JustDied(Unit *killer) override
Definition: SmartAI.cpp:544
DamageEffectType
Definition: Unit.h:537
void SetLastDamagedTime(time_t val)
Definition: Unit.h:1996
void GetPosition(float &x, float &y) const
Definition: Position.h:102
bool HasEscortState(uint32 uiEscortState) const
Definition: SmartAI.h:59
SpellEffIndex
Definition: SharedDefines.h:24
void KilledUnit(Unit *victim) override
Definition: SmartAI.cpp:555
void sGossipSelectCode(Player *player, uint32 sender, uint32 action, const char *code) override
Definition: SmartAI.cpp:696
void SetVisible(bool x)
Definition: Unit.cpp:9875
etc mysql my cnf *Then change max_allowed_packet to a bigger value
void SetDespawnTime(uint32 t)
Definition: SmartAI.h:185
uint32 mEscortState
Definition: SmartAI.h:207
bool mJustReset
Definition: SmartAI.h:227
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:7339
void SetPathId(uint32 id)
Definition: SmartScript.h:54
void CombatStop(bool cast=false)
Definition: Unit.cpp:7518
uint32 mFollowCreditType
Definition: SmartAI.h:195
#define sSmartWaypointMgr
bool QuestReward(Player *player, Quest const *quest, uint32 opt) override
Definition: SmartAI.cpp:855
void JustRespawned() override
Definition: SmartAI.cpp:492
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true)
Definition: Object.cpp:2292
bool IsInMap(const WorldObject *obj) const
Definition: Object.h:745
Corpse * GetCorpse() const
Definition: Player.cpp:4328
void OnMoveInLineOfSight(Unit *who)
void PassengerBoarded(Unit *who, int8 seatId, bool apply) override
Definition: SmartAI.cpp:623
void UpdateDespawn(const uint32 diff)
Definition: SmartAI.cpp:71
GroupReference * next()
void sQuestReward(Player *player, Quest const *quest, uint32 opt) override
Definition: SmartAI.cpp:703
float mFollowDist
Definition: SmartAI.h:200
void SetGUID(const uint64 &guid, int32 id=0) override
Definition: SmartAI.cpp:663
MovementGeneratorType GetMotionSlotType(int slot) const
bool GossipHello(Player *player) override
Definition: SmartAI.cpp:827
void SetPlayerDamaged(bool set)
Definition: Creature.cpp:1230
void Clear()
Definition: ObjectGuid.h:141
ACE_UINT64 uint64
Definition: Define.h:70
void EndPath(bool fail=false)
Definition: SmartAI.cpp:184
void StopFollow()
Definition: SmartAI.cpp:762
void OnSpellClick(Unit *clicker) override
Definition: SmartAI.cpp:797
bool isDead() const
Definition: Unit.h:1338
CreatureInfo const * GetCreatureTemplate() const
Definition: Creature.h:557
void InitializeAI() override
Definition: SmartAI.cpp:628
void DeleteThreatList()
Definition: Unit.cpp:10226
void AttackStart(Unit *who) override
Definition: SmartAI.cpp:565
void SetScript9(SmartScriptHolder &e, uint32 entry)
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:3576
void InitializeAI() override
Definition: SmartAI.cpp:814
void MovePath(uint32 path_id, bool repeatable)
void ProcessEventsFor(SMART_EVENT e, Unit *unit=NULL, uint32 var0=0, uint32 var1=0, bool bvar=false, const SpellEntry *spell=NULL, GameObject *gob=NULL)
void DoMeleeAttackIfReady()
Definition: UnitAI.cpp:45
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1030
virtual void MoveInLineOfSight(Unit *)
Definition: CreatureAI.cpp:159
void UpdateAI(uint32 diff) override
Definition: SmartAI.cpp:809
void JustReachedHome() override
Definition: SmartAI.cpp:519
uint32 GetWPCount() const
Definition: SmartAI.h:214
bool mCanCombatMove
Definition: SmartAI.h:218
void AreaExploredOrEventHappens(uint32 questId)
Definition: Player.cpp:13724
void ResumePath()
Definition: SmartAI.cpp:244
static Unit * GetUnit(WorldObject const &, uint64 guid)
void SetData(uint32 id, uint32 value) override
Definition: SmartAI.cpp:867
SmartScript * GetScript()
Definition: SmartAI.h:69
bool IsWithinMeleeRange(Unit *obj, float dist=MELEE_RANGE) const
Definition: Unit.cpp:653
uint32 GetEntry() const
Definition: Object.h:192
bool mWPReached
Definition: SmartAI.h:210
bool LoadCreaturesAddon(bool reload=false)
Definition: Creature.cpp:2140
uint32 GetData(uint32 id=0) override
Definition: SmartAI.cpp:653
uint32 type_flags
Definition: Creature.h:170
WPPath * mWayPoints
Definition: SmartAI.h:206
ACE_UINT16 uint16
Definition: Define.h:72
void SetData(uint32 id, uint32 value) override
Definition: SmartAI.cpp:658
bool LoadPath(uint32 entry)
Definition: SmartAI.cpp:136
ACE_UINT32 uint32
Definition: Define.h:71
uint32 mEscortInvokerCheckTimer
Definition: SmartAI.h:226
void AddSC_SmartScripts()
Definition: SmartAI.cpp:889
uint32 GetHealth() const
Definition: Unit.h:1074
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:158
void UpdatePath(const uint32 diff)
Definition: SmartAI.cpp:258
std::string GetAIName() const
Definition: Creature.cpp:2383
Definition: Unit.h:908
void Reset() override
Definition: SmartAI.cpp:821
void StopMoving()
Definition: Unit.cpp:11917
Definition: Player.h:922
void sGossipHello(Player *player) override
Definition: SmartAI.cpp:686
void AddEscortState(uint32 uiEscortState)
Definition: SmartAI.h:60
void SetInCombatWith(Unit *enemy)
Definition: Unit.cpp:9329
Definition: Group.h:154
bool mRun
Definition: SmartAI.h:216
virtual float GetFollowAngle() const
Definition: Unit.h:1971
void MoveFollow(Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE)
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:7641
uint32 mLastWPIDReached
Definition: SmartAI.h:209
const uint64 & GetGUID() const
Definition: Object.h:162
ObjectList * GetTargetList(uint32 id)
Definition: SmartScript.h:140
uint64 GetGUID(int32 id=0) override
Definition: SmartAI.cpp:665