TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SmartAIMgr Class Reference

#include <SmartScriptMgr.h>

Public Member Functions

void LoadSmartAIFromDB ()
 
SmartAIEventList GetScript (int32 entry, SmartScriptType type)
 

Static Public Member Functions

static SmartAIMgrinstance ()
 
static SmartScriptHolderFindLinkedSourceEvent (SmartAIEventList &list, uint32 eventId)
 
static SmartScriptHolderFindLinkedEvent (SmartAIEventList &list, uint32 link)
 

Private Member Functions

 SmartAIMgr ()
 
 ~SmartAIMgr ()
 
bool IsEventValid (SmartScriptHolder &e)
 
bool IsTargetValid (SmartScriptHolder const &e)
 
bool IsMinMaxValid (SmartScriptHolder const &e, uint32 min, uint32 max)
 
bool NotNULL (SmartScriptHolder const &e, uint32 data)
 
bool IsCreatureValid (SmartScriptHolder const &e, uint32 entry)
 
bool IsQuestValid (SmartScriptHolder const &e, uint32 entry)
 
bool IsGameObjectValid (SmartScriptHolder const &e, uint32 entry)
 
bool IsSpellValid (SmartScriptHolder const &e, uint32 entry)
 
bool IsItemValid (SmartScriptHolder const &e, uint32 entry)
 
bool IsTextEmoteValid (SmartScriptHolder const &e, uint32 entry)
 
bool IsEmoteValid (SmartScriptHolder const &e, uint32 entry)
 
bool IsAreaTriggerValid (SmartScriptHolder const &e, uint32 entry)
 
bool IsSoundValid (SmartScriptHolder const &e, uint32 entry)
 
bool IsTextValid (SmartScriptHolder const &e, uint32 id)
 
void LoadHelperStores ()
 
void UnLoadHelperStores ()
 
CacheSpellContainerBounds GetSummonCreatureSpellContainerBounds (uint32 creatureEntry) const
 
CacheSpellContainerBounds GetSummonGameObjectSpellContainerBounds (uint32 gameObjectEntry) const
 
CacheSpellContainerBounds GetKillCreditSpellContainerBounds (uint32 killCredit) const
 
CacheSpellContainerBounds GetCreateItemSpellContainerBounds (uint32 itemId) const
 

Private Attributes

SmartAIEventMap mEventMap [SMART_SCRIPT_TYPE_MAX]
 
CacheSpellContainer SummonCreatureSpellStore
 
CacheSpellContainer SummonGameObjectSpellStore
 
CacheSpellContainer KillCreditSpellStore
 
CacheSpellContainer CreateItemSpellStore
 

Constructor & Destructor Documentation

SmartAIMgr::SmartAIMgr ( )
inlineprivate
1480 { }
SmartAIMgr::~SmartAIMgr ( )
inlineprivate
1481 { }

Member Function Documentation

static SmartScriptHolder& SmartAIMgr::FindLinkedEvent ( SmartAIEventList list,
uint32  link 
)
inlinestatic
1514  {
1515  SmartAIEventList::iterator itr = std::find_if(list.begin(), list.end(),
1516  [link](SmartScriptHolder& linked) { return linked.event_id == link && linked.GetEventType() == SMART_EVENT_LINK; });
1517 
1518  if (itr != list.end())
1519  return *itr;
1520 
1521  static SmartScriptHolder SmartScriptHolderDummy;
1522  return SmartScriptHolderDummy;
1523  }
Definition: SmartScriptMgr.h:165
Definition: SmartScriptMgr.h:1361

+ Here is the caller graph for this function:

static SmartScriptHolder& SmartAIMgr::FindLinkedSourceEvent ( SmartAIEventList list,
uint32  eventId 
)
inlinestatic
1502  {
1503  SmartAIEventList::iterator itr = std::find_if(list.begin(), list.end(),
1504  [eventId](SmartScriptHolder& source) { return source.link == eventId; });
1505 
1506  if (itr != list.end())
1507  return *itr;
1508 
1509  static SmartScriptHolder SmartScriptHolderDummy;
1510  return SmartScriptHolderDummy;
1511  }
Definition: SmartScriptMgr.h:1361

+ Here is the caller graph for this function:

CacheSpellContainerBounds SmartAIMgr::GetCreateItemSpellContainerBounds ( uint32  itemId) const
private
1379 {
1380  return CreateItemSpellStore.equal_range(itemId);
1381 }
CacheSpellContainer CreateItemSpellStore
Definition: SmartScriptMgr.h:1666

+ Here is the caller graph for this function:

CacheSpellContainerBounds SmartAIMgr::GetKillCreditSpellContainerBounds ( uint32  killCredit) const
private
1374 {
1375  return KillCreditSpellStore.equal_range(killCredit);
1376 }
CacheSpellContainer KillCreditSpellStore
Definition: SmartScriptMgr.h:1665

+ Here is the caller graph for this function:

SmartAIEventList SmartAIMgr::GetScript ( int32  entry,
SmartScriptType  type 
)
inline
1489  {
1490  SmartAIEventList temp;
1491  if (mEventMap[uint32(type)].find(entry) != mEventMap[uint32(type)].end())
1492  return mEventMap[uint32(type)][entry];
1493  else
1494  {
1495  if (entry > 0)//first search is for guid (negative), do not drop error if not found
1496  TC_LOG_DEBUG("scripts.ai", "SmartAIMgr::GetScript: Could not load Script for Entry %d ScriptType %u.", entry, uint32(type));
1497  return temp;
1498  }
1499  }
std::vector< SmartScriptHolder > SmartAIEventList
Definition: SmartScriptMgr.h:1468
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
SmartAIEventMap mEventMap[SMART_SCRIPT_TYPE_MAX]
Definition: SmartScriptMgr.h:1527
uint32_t uint32
Definition: g3dmath.h:168
CacheSpellContainerBounds SmartAIMgr::GetSummonCreatureSpellContainerBounds ( uint32  creatureEntry) const
private
1364 {
1365  return SummonCreatureSpellStore.equal_range(creatureEntry);
1366 }
CacheSpellContainer SummonCreatureSpellStore
Definition: SmartScriptMgr.h:1663

+ Here is the caller graph for this function:

CacheSpellContainerBounds SmartAIMgr::GetSummonGameObjectSpellContainerBounds ( uint32  gameObjectEntry) const
private
1369 {
1370  return SummonGameObjectSpellStore.equal_range(gameObjectEntry);
1371 }
CacheSpellContainer SummonGameObjectSpellStore
Definition: SmartScriptMgr.h:1664

+ Here is the caller graph for this function:

SmartAIMgr * SmartAIMgr::instance ( )
static
109 {
110  static SmartAIMgr instance;
111  return &instance;
112 }
static SmartAIMgr * instance()
Definition: SmartScriptMgr.cpp:108
Definition: SmartScriptMgr.h:1477
bool SmartAIMgr::IsAreaTriggerValid ( SmartScriptHolder const e,
uint32  entry 
)
inlineprivate
1633  {
1634  if (!sAreaTriggerStore.LookupEntry(entry))
1635  {
1636  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent AreaTrigger entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1637  return false;
1638  }
1639  return true;
1640  }
DBCStorage< AreaTriggerEntry > sAreaTriggerStore(AreaTriggerfmt)
#define SI64FMTD
Definition: Define.h:140
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool SmartAIMgr::IsCreatureValid ( SmartScriptHolder const e,
uint32  entry 
)
inlineprivate
1563  {
1564  if (!sObjectMgr->GetCreatureTemplate(entry))
1565  {
1566  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Creature entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1567  return false;
1568  }
1569  return true;
1570  }
#define sObjectMgr
Definition: ObjectMgr.h:1567
#define SI64FMTD
Definition: Define.h:140
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool SmartAIMgr::IsEmoteValid ( SmartScriptHolder const e,
uint32  entry 
)
inlineprivate
1623  {
1624  if (!sEmotesStore.LookupEntry(entry))
1625  {
1626  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Emote entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1627  return false;
1628  }
1629  return true;
1630  }
DBCStorage< EmotesEntry > sEmotesStore(Emotesfmt)
#define SI64FMTD
Definition: Define.h:140
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool SmartAIMgr::IsEventValid ( SmartScriptHolder e)
private
386 {
387  if (e.event.type >= SMART_EVENT_END)
388  {
389  TC_LOG_ERROR("sql.sql", "SmartAIMgr: EntryOrGuid " SI64FMTD " using event(%u) has invalid event type (%u), skipped.", e.entryOrGuid, e.event_id, e.GetEventType());
390  return false;
391  }
392 
393  // in SMART_SCRIPT_TYPE_TIMED_ACTIONLIST all event types are overriden by core
395  {
396  TC_LOG_ERROR("sql.sql", "SmartAIMgr: EntryOrGuid " SI64FMTD ", event type %u can not be used for Script type %u", e.entryOrGuid, e.GetEventType(), e.GetScriptType());
397  return false;
398  }
399 
400  if (e.action.type <= 0 || e.action.type >= SMART_ACTION_END)
401  {
402  TC_LOG_ERROR("sql.sql", "SmartAIMgr: EntryOrGuid " SI64FMTD " using event(%u) has invalid action type (%u), skipped.", e.entryOrGuid, e.event_id, e.GetActionType());
403  return false;
404  }
405 
407  {
408  TC_LOG_ERROR("sql.sql", "SmartAIMgr: EntryOrGuid " SI64FMTD " using event(%u) has invalid phase mask (%u), skipped.", e.entryOrGuid, e.event_id, e.event.event_phase_mask);
409  return false;
410  }
411 
413  {
414  TC_LOG_ERROR("sql.sql", "SmartAIMgr: EntryOrGuid " SI64FMTD " using event(%u) has invalid event flags (%u), skipped.", e.entryOrGuid, e.event_id, e.event.event_flags);
415  return false;
416  }
417 
418  if (e.link && e.link == e.event_id)
419  {
420  TC_LOG_ERROR("sql.sql", "SmartAIMgr: EntryOrGuid " SI64FMTD " SourceType %u, Event %u, Event is linking self (infinite loop), skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id);
421  return false;
422  }
423 
425  {
426  e.event.type = SMART_EVENT_UPDATE_OOC;//force default OOC, can change when calling the script!
427  if (!IsMinMaxValid(e, e.event.minMaxRepeat.min, e.event.minMaxRepeat.max))
428  return false;
429 
430  if (!IsMinMaxValid(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax))
431  return false;
432  }
433  else
434  {
435  switch (e.GetEventType())
436  {
437  case SMART_EVENT_UPDATE:
444  case SMART_EVENT_RANGE:
445  case SMART_EVENT_DAMAGED:
448  if (!IsMinMaxValid(e, e.event.minMaxRepeat.min, e.event.minMaxRepeat.max))
449  return false;
450 
451  if (!IsMinMaxValid(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax))
452  return false;
453  break;
456  if (e.event.spellHit.spell)
457  {
458  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(e.event.spellHit.spell);
459  if (!spellInfo)
460  {
461  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Spell entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.event.spellHit.spell);
462  return false;
463  }
464  if (e.event.spellHit.school && (e.event.spellHit.school & spellInfo->SchoolMask) != spellInfo->SchoolMask)
465  {
466  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses Spell entry %u with invalid school mask, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.event.spellHit.spell);
467  return false;
468  }
469  }
470  if (!IsMinMaxValid(e, e.event.spellHit.cooldownMin, e.event.spellHit.cooldownMax))
471  return false;
472  break;
473  case SMART_EVENT_OOC_LOS:
474  case SMART_EVENT_IC_LOS:
475  if (!IsMinMaxValid(e, e.event.los.cooldownMin, e.event.los.cooldownMax))
476  return false;
477  break;
478  case SMART_EVENT_RESPAWN:
479  if (e.event.respawn.type == SMART_SCRIPT_RESPAWN_CONDITION_MAP && !sMapStore.LookupEntry(e.event.respawn.map))
480  {
481  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Map entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.event.respawn.map);
482  return false;
483  }
484  if (e.event.respawn.type == SMART_SCRIPT_RESPAWN_CONDITION_AREA && !sAreaTableStore.LookupEntry(e.event.respawn.area))
485  {
486  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Area entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.event.respawn.area);
487  return false;
488  }
489  break;
491  if (!NotNULL(e, e.event.friendlyHealth.radius))
492  return false;
493 
494  if (!IsMinMaxValid(e, e.event.friendlyHealth.repeatMin, e.event.friendlyHealth.repeatMax))
495  return false;
496  break;
498  if (!IsMinMaxValid(e, e.event.friendlyCC.repeatMin, e.event.friendlyCC.repeatMax))
499  return false;
500  break;
502  {
503  if (!IsSpellValid(e, e.event.missingBuff.spell))
504  return false;
505 
506  if (!NotNULL(e, e.event.missingBuff.radius))
507  return false;
508 
509  if (!IsMinMaxValid(e, e.event.missingBuff.repeatMin, e.event.missingBuff.repeatMax))
510  return false;
511  break;
512  }
513  case SMART_EVENT_KILL:
514  if (!IsMinMaxValid(e, e.event.kill.cooldownMin, e.event.kill.cooldownMax))
515  return false;
516 
517  if (e.event.kill.creature && !IsCreatureValid(e, e.event.kill.creature))
518  return false;
519  break;
521  if (e.event.targetCasting.spellId > 0 && !sSpellMgr->GetSpellInfo(e.event.targetCasting.spellId))
522  {
523  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Spell entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.event.spellHit.spell);
524  return false;
525  }
526 
527  if (!IsMinMaxValid(e, e.event.targetCasting.repeatMin, e.event.targetCasting.repeatMax))
528  return false;
529  break;
532  if (!IsMinMaxValid(e, e.event.minMax.repeatMin, e.event.minMax.repeatMax))
533  return false;
534  break;
537  if (e.event.summoned.creature && !IsCreatureValid(e, e.event.summoned.creature))
538  return false;
539 
540  if (!IsMinMaxValid(e, e.event.summoned.cooldownMin, e.event.summoned.cooldownMax))
541  return false;
542  break;
545  if (e.event.quest.quest && !IsQuestValid(e, e.event.quest.quest))
546  return false;
547  break;
549  {
550  if (e.event.emote.emote && !IsTextEmoteValid(e, e.event.emote.emote))
551  return false;
552 
553  if (!IsMinMaxValid(e, e.event.emote.cooldownMin, e.event.emote.cooldownMax))
554  return false;
555  break;
556  }
559  {
560  if (!IsSpellValid(e, e.event.aura.spell))
561  return false;
562 
563  if (!IsMinMaxValid(e, e.event.aura.repeatMin, e.event.aura.repeatMax))
564  return false;
565  break;
566  }
568  {
569  if (e.event.transportAddCreature.creature && !IsCreatureValid(e, e.event.transportAddCreature.creature))
570  return false;
571  break;
572  }
574  {
576  {
577  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses invalid Motion type %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.event.movementInform.type);
578  return false;
579  }
580  break;
581  }
583  {
584  if (!IsMinMaxValid(e, e.event.dataSet.cooldownMin, e.event.dataSet.cooldownMax))
585  return false;
586  break;
587  }
589  {
590  if (e.event.areatrigger.id && !IsAreaTriggerValid(e, e.event.areatrigger.id))
591  return false;
592  break;
593  }
595  if (!IsTextValid(e, e.event.textOver.textGroupID))
596  return false;
597  break;
599  {
600  if (!IsSpellValid(e, e.event.dummy.spell))
601  return false;
602 
603  if (e.event.dummy.effIndex > EFFECT_2)
604  return false;
605  break;
606  }
608  {
609  if (!IsMinMaxValid(e, e.event.behindTarget.cooldownMin, e.event.behindTarget.cooldownMax))
610  return false;
611  break;
612  }
615  {
616  GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
617  if (e.event.gameEvent.gameEventId >= events.size() || !events[e.event.gameEvent.gameEventId].isValid())
618  return false;
619  break;
620  }
622  {
623  if (e.event.doAction.eventId > EVENT_CHARGE)
624  {
625  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses invalid event id %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.event.doAction.eventId);
626  return false;
627  }
628  break;
629  }
631  if (!IsMinMaxValid(e, e.event.friendlyHealthPct.repeatMin, e.event.friendlyHealthPct.repeatMax))
632  return false;
633 
634  if (e.event.friendlyHealthPct.maxHpPct > 100 || e.event.friendlyHealthPct.minHpPct > 100)
635  {
636  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u has pct value above 100, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
637  return false;
638  }
639 
640  switch (e.GetTargetType())
641  {
649  break;
650  default:
651  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses invalid target_type %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
652  return false;
653  }
654  break;
656  if (e.event.distance.guid == 0 && e.event.distance.entry == 0)
657  {
658  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Event SMART_EVENT_DISTANCE_CREATURE did not provide creature guid or entry, skipped.");
659  return false;
660  }
661 
662  if (e.event.distance.guid != 0 && e.event.distance.entry != 0)
663  {
664  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Event SMART_EVENT_DISTANCE_CREATURE provided both an entry and guid, skipped.");
665  return false;
666  }
667 
668  if (e.event.distance.guid != 0 && !sObjectMgr->GetCreatureData(e.event.distance.guid))
669  {
670  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Event SMART_EVENT_DISTANCE_CREATURE using invalid creature guid %u, skipped.", e.event.distance.guid);
671  return false;
672  }
673 
674  if (e.event.distance.entry != 0 && !sObjectMgr->GetCreatureTemplate(e.event.distance.entry))
675  {
676  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Event SMART_EVENT_DISTANCE_CREATURE using invalid creature entry %u, skipped.", e.event.distance.entry);
677  return false;
678  }
679  break;
681  if (e.event.distance.guid == 0 && e.event.distance.entry == 0)
682  {
683  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Event SMART_EVENT_DISTANCE_GAMEOBJECT did not provide gameobject guid or entry, skipped.");
684  return false;
685  }
686 
687  if (e.event.distance.guid != 0 && e.event.distance.entry != 0)
688  {
689  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Event SMART_EVENT_DISTANCE_GAMEOBJECT provided both an entry and guid, skipped.");
690  return false;
691  }
692 
693  if (e.event.distance.guid != 0 && !sObjectMgr->GetGOData(e.event.distance.guid))
694  {
695  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Event SMART_EVENT_DISTANCE_GAMEOBJECT using invalid gameobject guid %u, skipped.", e.event.distance.guid);
696  return false;
697  }
698 
699  if (e.event.distance.entry != 0 && !sObjectMgr->GetGameObjectTemplate(e.event.distance.entry))
700  {
701  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Event SMART_EVENT_DISTANCE_GAMEOBJECT using invalid gameobject entry %u, skipped.", e.event.distance.entry);
702  return false;
703  }
704  break;
706  if (!IsMinMaxValid(e, e.event.counter.cooldownMin, e.event.counter.cooldownMax))
707  return false;
708 
709  if (e.event.counter.id == 0)
710  {
711  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Event SMART_EVENT_COUNTER_SET using invalid counter id %u, skipped.", e.event.counter.id);
712  return false;
713  }
714 
715  if (e.event.counter.value == 0)
716  {
717  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Event SMART_EVENT_COUNTER_SET using invalid value %u, skipped.", e.event.counter.value);
718  return false;
719  }
720  break;
721  case SMART_EVENT_LINK:
727  case SMART_EVENT_CHARMED:
730  case SMART_EVENT_AI_INIT:
733  case SMART_EVENT_AGGRO:
734  case SMART_EVENT_DEATH:
735  case SMART_EVENT_EVADE:
737  case SMART_EVENT_RESET:
755  break;
756  default:
757  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Not handled event_type(%u), Entry " SI64FMTD " SourceType %u Event %u Action %u, skipped.", e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
758  return false;
759  }
760  }
761 
762  switch (e.GetActionType())
763  {
764  case SMART_ACTION_TALK:
766  if (!IsTextValid(e, e.action.talk.textGroupID))
767  return false;
768  break;
770  if (e.action.faction.factionID && !sFactionTemplateStore.LookupEntry(e.action.faction.factionID))
771  {
772  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Faction %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.faction.factionID);
773  return false;
774  }
775  break;
778  if (e.action.morphOrMount.creature || e.action.morphOrMount.model)
779  {
780  if (e.action.morphOrMount.creature > 0 && !sObjectMgr->GetCreatureTemplate(e.action.morphOrMount.creature))
781  {
782  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Creature entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.morphOrMount.creature);
783  return false;
784  }
785 
786  if (e.action.morphOrMount.model)
787  {
788  if (e.action.morphOrMount.creature)
789  {
790  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u has ModelID set with also set CreatureId, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
791  return false;
792  }
793  else if (!sCreatureDisplayInfoStore.LookupEntry(e.action.morphOrMount.model))
794  {
795  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Model id %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.morphOrMount.model);
796  return false;
797  }
798  }
799  }
800  break;
801  case SMART_ACTION_SOUND:
802  if (!IsSoundValid(e, e.action.sound.sound))
803  return false;
804  break;
807  if (!IsEmoteValid(e, e.action.emote.emote))
808  return false;
809  break;
812  if (!e.action.quest.quest || !IsQuestValid(e, e.action.quest.quest))
813  return false;
814  break;
816  {
817  if (!sTaxiPathStore.LookupEntry(e.action.taxi.id))
818  {
819  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses invalid Taxi path ID %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.taxi.id);
820  return false;
821  }
822  break;
823  }
825  if (e.action.randomEmote.emote1 && !IsEmoteValid(e, e.action.randomEmote.emote1))
826  return false;
827 
828  if (e.action.randomEmote.emote2 && !IsEmoteValid(e, e.action.randomEmote.emote2))
829  return false;
830 
831  if (e.action.randomEmote.emote3 && !IsEmoteValid(e, e.action.randomEmote.emote3))
832  return false;
833 
834  if (e.action.randomEmote.emote4 && !IsEmoteValid(e, e.action.randomEmote.emote4))
835  return false;
836 
837  if (e.action.randomEmote.emote5 && !IsEmoteValid(e, e.action.randomEmote.emote5))
838  return false;
839 
840  if (e.action.randomEmote.emote6 && !IsEmoteValid(e, e.action.randomEmote.emote6))
841  return false;
842  break;
844  {
845  if (std::all_of(e.action.randomSound.sounds.begin(), e.action.randomSound.sounds.end(), [](uint32 sound) { return sound == 0; }))
846  {
847  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u does not have any non-zero sound",
849  return false;
850  }
851 
852  for (uint32 sound : e.action.randomSound.sounds)
853  if (sound && !IsSoundValid(e, sound))
854  return false;
855 
856  break;
857  }
858  case SMART_ACTION_CAST:
859  {
860  if (!IsSpellValid(e, e.action.cast.spell))
861  return false;
862 
863  SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(e.action.cast.spell);
864  for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(DIFFICULTY_NONE))
865  {
866  if (effect && (effect->IsEffect(SPELL_EFFECT_KILL_CREDIT) || effect->IsEffect(SPELL_EFFECT_KILL_CREDIT2)))
867  {
868  if (effect->TargetA.GetTarget() == TARGET_UNIT_CASTER)
869  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u Effect: SPELL_EFFECT_KILL_CREDIT: (SpellId: %u targetA: %u - targetB: %u) has invalid target for this Action",
870  e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.cast.spell, effect->TargetA.GetTarget(), effect->TargetB.GetTarget());
871  }
872  }
873  break;
874  }
877  if (!IsSpellValid(e, e.action.cast.spell))
878  return false;
879  break;
882  if (Quest const* qid = sObjectMgr->GetQuestTemplate(e.action.quest.quest))
883  {
884  if (!qid->HasSpecialFlag(QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT))
885  {
886  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u SpecialFlags for Quest entry %u does not include FLAGS_EXPLORATION_OR_EVENT(2), skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.quest.quest);
887  return false;
888  }
889  }
890  else
891  {
892  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Quest entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.quest.quest);
893  return false;
894  }
895  break;
898  {
899  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u attempts to set phase %u. Phase mask cannot be used past phase %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.setEventPhase.phase, SMART_EVENT_PHASE_MAX - 1);
900  return false;
901  }
902  break;
904  if (!e.action.incEventPhase.inc && !e.action.incEventPhase.dec)
905  {
906  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u is incrementing phase by 0, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
907  return false;
908  }
910  {
911  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u attempts to increment phase by too large value, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
912  return false;
913  }
914  break;
916  if (e.action.removeAura.spell != 0 && !IsSpellValid(e, e.action.removeAura.spell))
917  return false;
918  break;
920  {
921  if (e.action.randomPhase.phase1 >= SMART_EVENT_PHASE_MAX ||
927  {
928  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u attempts to set invalid phase, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
929  return false;
930  }
931  }
932  break;
933  case SMART_ACTION_RANDOM_PHASE_RANGE: //PhaseMin, PhaseMax
934  {
935  if (e.action.randomPhaseRange.phaseMin >= SMART_EVENT_PHASE_MAX ||
937  {
938  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u attempts to set invalid phase, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
939  return false;
940  }
941 
942  if (!IsMinMaxValid(e, e.action.randomPhaseRange.phaseMin, e.action.randomPhaseRange.phaseMax))
943  return false;
944  break;
945  }
947  {
948  if (!IsCreatureValid(e, e.action.summonCreature.creature))
949  return false;
950 
952  for (CacheSpellContainer::const_iterator itr = sBounds.first; itr != sBounds.second; ++itr)
953  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u creature summon: There is a summon spell for creature entry %u (SpellId: %u, effect: %u)",
954  e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.summonCreature.creature, itr->second.first, itr->second.second);
955 
957  {
958  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses incorrect TempSummonType %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.summonCreature.type);
959  return false;
960  }
961  break;
962  }
964  {
965  if (!IsCreatureValid(e, e.action.killedMonster.creature))
966  return false;
967 
969  for (CacheSpellContainer::const_iterator itr = sBounds.first; itr != sBounds.second; ++itr)
970  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u Kill Credit: There is a killcredit spell for creatureEntry %u (SpellId: %u effect: %u)",
971  e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.killedMonster.creature, itr->second.first, itr->second.second);
972 
974  {
975  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses incorrect TargetType %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
976  return false;
977  }
978  break;
979  }
981  if (!IsCreatureValid(e, e.action.updateTemplate.creature))
982  return false;
983  break;
985  if (e.action.setSheath.sheath && e.action.setSheath.sheath >= MAX_SHEATH_STATE)
986  {
987  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses incorrect Sheath state %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.setSheath.sheath);
988  return false;
989  }
990  break;
992  {
993  if (e.action.react.state > REACT_AGGRESSIVE)
994  {
995  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Creature " SI64FMTD " Event %u Action %u uses invalid React State %u, skipped.", e.entryOrGuid, e.event_id, e.GetActionType(), e.action.react.state);
996  return false;
997  }
998  break;
999  }
1001  {
1002  if (!IsGameObjectValid(e, e.action.summonGO.entry))
1003  return false;
1004 
1006  for (CacheSpellContainer::const_iterator itr = sBounds.first; itr != sBounds.second; ++itr)
1007  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u gameobject summon: There is a summon spell for gameobject entry %u (SpellId: %u, effect: %u)",
1008  e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.summonGO.entry, itr->second.first, itr->second.second);
1009  break;
1010  }
1012  if (!IsItemValid(e, e.action.item.entry))
1013  return false;
1014 
1015  if (!NotNULL(e, e.action.item.count))
1016  return false;
1017  break;
1018  case SMART_ACTION_ADD_ITEM:
1019  {
1020  if (!IsItemValid(e, e.action.item.entry))
1021  return false;
1022 
1023  if (!NotNULL(e, e.action.item.count))
1024  return false;
1025 
1027  for (CacheSpellContainer::const_iterator itr = sBounds.first; itr != sBounds.second; ++itr)
1028  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u Create Item: There is a create item spell for item %u (SpellId: %u effect: %u)",
1029  e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.item.entry, itr->second.first, itr->second.second);
1030  break;
1031  }
1032  case SMART_ACTION_TELEPORT:
1033  if (!sMapStore.LookupEntry(e.action.teleport.mapID))
1034  {
1035  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Map entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.teleport.mapID);
1036  return false;
1037  }
1038  break;
1040  if (e.action.setCounter.counterId == 0)
1041  {
1042  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses wrong counterId %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.setCounter.counterId);
1043  return false;
1044  }
1045 
1046  if (e.action.setCounter.value == 0)
1047  {
1048  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses wrong value %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.setCounter.value);
1049  return false;
1050  }
1051 
1052  break;
1055  {
1056  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Creature " SI64FMTD " Event %u Action %u uses non-existent AI template id %u, skipped.", e.entryOrGuid, e.event_id, e.GetActionType(), e.action.installTtemplate.id);
1057  return false;
1058  }
1059  break;
1060  case SMART_ACTION_WP_STOP:
1061  if (e.action.wpStop.quest && !IsQuestValid(e, e.action.wpStop.quest))
1062  return false;
1063  break;
1064  case SMART_ACTION_WP_START:
1065  {
1066  if (!sSmartWaypointMgr->GetPath(e.action.wpStart.pathID))
1067  {
1068  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Creature " SI64FMTD " Event %u Action %u uses non-existent WaypointPath id %u, skipped.", e.entryOrGuid, e.event_id, e.GetActionType(), e.action.wpStart.pathID);
1069  return false;
1070  }
1071  if (e.action.wpStart.quest && !IsQuestValid(e, e.action.wpStart.quest))
1072  return false;
1073  if (e.action.wpStart.reactState > REACT_AGGRESSIVE)
1074  {
1075  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Creature " SI64FMTD " Event %u Action %u uses invalid React State %u, skipped.", e.entryOrGuid, e.event_id, e.GetActionType(), e.action.wpStart.reactState);
1076  return false;
1077  }
1078  break;
1079  }
1081  {
1082  if (!IsMinMaxValid(e, e.action.timeEvent.min, e.action.timeEvent.max))
1083  return false;
1084 
1085  if (!IsMinMaxValid(e, e.action.timeEvent.repeatMin, e.action.timeEvent.repeatMax))
1086  return false;
1087  break;
1088  }
1090  {
1092  return false;
1093  break;
1094  }
1098  if (e.action.power.powerType > MAX_POWERS)
1099  {
1100  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Power %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.power.powerType);
1101  return false;
1102  }
1103  break;
1105  {
1106  uint32 eventId = e.action.gameEventStop.id;
1107 
1108  GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
1109  if (eventId < 1 || eventId >= events.size())
1110  {
1111  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent event, eventId %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.gameEventStop.id);
1112  return false;
1113  }
1114 
1115  GameEventData const& eventData = events[eventId];
1116  if (!eventData.isValid())
1117  {
1118  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent event, eventId %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.gameEventStop.id);
1119  return false;
1120  }
1121  break;
1122  }
1124  {
1125  uint32 eventId = e.action.gameEventStart.id;
1126 
1127  GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
1128  if (eventId < 1 || eventId >= events.size())
1129  {
1130  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent event, eventId %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.gameEventStart.id);
1131  return false;
1132  }
1133 
1134  GameEventData const& eventData = events[eventId];
1135  if (!eventData.isValid())
1136  {
1137  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent event, eventId %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.gameEventStart.id);
1138  return false;
1139  }
1140  break;
1141  }
1142  case SMART_ACTION_EQUIP:
1143  {
1145  {
1146  int8 equipId = (int8)e.action.equip.entry;
1147 
1148  if (equipId)
1149  {
1150  EquipmentInfo const* einfo = sObjectMgr->GetEquipmentInfo(e.entryOrGuid, equipId);
1151  if (!einfo)
1152  {
1153  TC_LOG_ERROR("sql.sql", "SmartScript: SMART_ACTION_EQUIP uses non-existent equipment info id %u for creature " SI64FMTD ", skipped.", equipId, e.entryOrGuid);
1154  return false;
1155  }
1156  }
1157  }
1158  break;
1159  }
1161  {
1162  uint32 phaseId = e.action.ingamePhaseId.id;
1163  uint32 apply = e.action.ingamePhaseId.apply;
1164 
1165  if (apply != 0 && apply != 1)
1166  {
1167  TC_LOG_ERROR("sql.sql", "SmartScript: SMART_ACTION_SET_INGAME_PHASE_ID uses invalid apply value %u (Should be 0 or 1) for creature " SI64FMTD ", skipped", apply, e.entryOrGuid);
1168  return false;
1169  }
1170 
1171  PhaseEntry const* phase = sPhaseStore.LookupEntry(phaseId);
1172  if (!phase)
1173  {
1174  TC_LOG_ERROR("sql.sql", "SmartScript: SMART_ACTION_SET_INGAME_PHASE_ID uses invalid phaseid %u for creature " SI64FMTD ", skipped", phaseId, e.entryOrGuid);
1175  return false;
1176  }
1177  break;
1178  }
1180  {
1181  uint32 phaseGroup = e.action.ingamePhaseGroup.groupId;
1182  uint32 apply = e.action.ingamePhaseGroup.apply;
1183 
1184  if (apply != 0 && apply != 1)
1185  {
1186  TC_LOG_ERROR("sql.sql", "SmartScript: SMART_ACTION_SET_INGAME_PHASE_GROUP uses invalid apply value %u (Should be 0 or 1) for creature " SI64FMTD ", skipped", apply, e.entryOrGuid);
1187  return false;
1188  }
1189 
1190  if (sDB2Manager.GetPhasesForGroup(phaseGroup).empty())
1191  {
1192  TC_LOG_ERROR("sql.sql", "SmartScript: SMART_ACTION_SET_INGAME_PHASE_GROUP uses invalid phase group id %u for creature " SI64FMTD ", skipped", phaseGroup, e.entryOrGuid);
1193  return false;
1194  }
1195  break;
1196  }
1198  case SMART_ACTION_FOLLOW:
1201  case SMART_ACTION_EVADE:
1204  case SMART_ACTION_DIE:
1219  case SMART_ACTION_SET_DATA:
1222  case SMART_ACTION_WP_PAUSE:
1223  case SMART_ACTION_SET_FLY:
1224  case SMART_ACTION_SET_RUN:
1225  case SMART_ACTION_SET_SWIM:
1260  case SMART_ACTION_SET_ROOT:
1265  case SMART_ACTION_RISE_UP:
1266  break;
1267  default:
1268  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Not handled action_type(%u), event_type(%u), Entry " SI64FMTD " SourceType %u Event %u, skipped.", e.GetActionType(), e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id);
1269  return false;
1270  }
1271 
1272  return true;
1273 }
Definition: DBCEnums.h:404
Definition: SmartScriptMgr.h:106
Definition: SmartScriptMgr.h:452
struct SmartAction::@114::@156 item
Definition: SmartScriptMgr.h:175
struct SmartAction::@114::@136 randomPhaseRange
Definition: SmartScriptMgr.h:125
Definition: SmartScriptMgr.h:532
#define sDB2Manager
Definition: DB2Stores.h:224
Definition: SmartScriptMgr.h:109
Definition: SmartScriptMgr.h:491
struct SmartEvent::@77::@92 aura
const uint32 SmartAITypeMask[SMART_SCRIPT_TYPE_MAX][2]
Definition: SmartScriptMgr.h:1237
Definition: SmartScriptMgr.h:445
uint32 event_phase_mask
Definition: SmartScriptMgr.h:189
Definition: SmartScriptMgr.h:174
Definition: SmartScriptMgr.h:161
Definition: SmartScriptMgr.h:152
Definition: Object.h:61
Definition: SmartScriptMgr.h:118
Definition: SmartScriptMgr.h:1081
CacheSpellContainerBounds GetKillCreditSpellContainerBounds(uint32 killCredit) const
Definition: SmartScriptMgr.cpp:1373
Definition: SmartScriptMgr.h:556
Definition: SmartScriptMgr.h:543
uint32 emote
Definition: SmartScriptMgr.h:283
int8_t int8
Definition: Define.h:148
struct SmartAction::@114::@116 talk
Definition: SmartScriptMgr.h:529
Definition: SmartScriptMgr.h:495
CacheSpellContainerBounds GetCreateItemSpellContainerBounds(uint32 itemId) const
Definition: SmartScriptMgr.cpp:1378
Definition: SmartScriptMgr.h:474
Definition: Unit.h:1131
Definition: SmartScriptMgr.h:178
struct SmartAction::@114::@165 timeEvent
Definition: SmartScriptMgr.h:451
Definition: SmartScriptMgr.h:179
Definition: SharedDefines.h:1100
Definition: QuestDef.h:279
Definition: SmartScriptMgr.h:492
Definition: SmartScriptMgr.h:166
struct SmartAction::@114::@152 taxi
Definition: SmartScriptMgr.h:496
Definition: SmartScriptMgr.h:531
SmartEvent event
Definition: SmartScriptMgr.h:1372
Definition: SmartScriptMgr.h:503
Definition: SmartScriptMgr.h:480
Definition: SmartScriptMgr.h:173
struct SmartAction::@114::@122 react
Definition: SpellInfo.h:326
Definition: SmartScriptMgr.h:461
Definition: SmartScriptMgr.h:115
bool IsCreatureValid(SmartScriptHolder const &e, uint32 entry)
Definition: SmartScriptMgr.h:1562
Definition: SmartScriptMgr.h:151
Definition: SmartScriptMgr.h:122
bool IsSoundValid(SmartScriptHolder const &e, uint32 entry)
Definition: SmartScriptMgr.h:1642
Definition: SmartScriptMgr.h:550
Definition: SmartScriptMgr.h:112
Definition: SmartScriptMgr.h:548
Definition: SmartScriptMgr.h:460
Definition: SmartScriptMgr.h:498
struct SmartAction::@114::@132 incEventPhase
Definition: SmartScriptMgr.h:143
uint32 link
Definition: SmartScriptMgr.h:1370
Definition: SmartScriptMgr.h:181
Definition: SmartScriptMgr.h:526
struct SmartAction::@114::@125 summonCreature
struct SmartEvent::@77::@104 dummy
Definition: SmartScriptMgr.h:135
Definition: SmartScriptMgr.h:123
Definition: SmartScriptMgr.h:485
struct SmartEvent::@77::@95 dataSet
uint32 SchoolMask
Definition: SpellInfo.h:401
int8_t int8
Definition: g3dmath.h:163
Definition: SmartScriptMgr.h:140
Definition: SmartScriptMgr.h:454
Definition: SmartScriptMgr.h:108
Definition: SmartScriptMgr.h:137
struct SmartAction::@114::@173 randTimedActionList
struct SmartAction::@114::@190 gameEventStart
uint32 GetEventType() const
Definition: SmartScriptMgr.h:1377
Definition: SmartScriptMgr.h:131
Definition: SmartScriptMgr.h:489
Definition: SmartScriptMgr.h:124
Definition: SmartScriptMgr.h:518
Definition: SmartScriptMgr.h:180
Definition: SmartScriptMgr.h:478
struct SmartAction::@114::@162 setCounter
Definition: SmartScriptMgr.h:141
Definition: SmartScriptMgr.h:1082
Definition: SmartScriptMgr.h:145
Definition: SmartScriptMgr.h:150
struct SmartAction::@114::@161 teleport
Definition: SmartScriptMgr.h:525
struct SmartEvent::@77::@88 missingBuff
Definition: SmartScriptMgr.h:511
Definition: SmartScriptMgr.h:515
Definition: SmartScriptMgr.h:509
Definition: SmartScriptMgr.h:176
uint32 event_id
Definition: SmartScriptMgr.h:1369
struct SmartAction::@114::@137 killedMonster
struct SmartAction::@114::@157 installTtemplate
Definition: SmartScriptMgr.h:479
Definition: SmartScriptMgr.h:466
Definition: SmartScriptMgr.h:494
Definition: SmartScriptMgr.h:163
const uint32 SmartAIEventMask[SMART_EVENT_END][2]
Definition: SmartScriptMgr.h:1251
Definition: SmartScriptMgr.h:138
struct SmartAction::@114::@188 power
Definition: SmartScriptMgr.h:160
Definition: SmartScriptMgr.h:549
Definition: SmartScriptMgr.h:551
struct SmartEvent::@77::@105 behindTarget
Definition: SmartScriptMgr.h:177
Definition: SmartScriptMgr.h:170
struct SmartAction::@114::@145 ingamePhaseId
Definition: SmartScriptMgr.h:116
Definition: SmartScriptMgr.h:444
Definition: SmartScriptMgr.h:114
Definition: SmartScriptMgr.h:1084
Definition: SmartScriptMgr.h:130
uint32 event_flags
Definition: SmartScriptMgr.h:191
void apply(T *val)
Definition: ByteConverter.h:41
#define sObjectMgr
Definition: ObjectMgr.h:1567
struct SmartAction::@114::@155 wpStop
Definition: SmartScriptMgr.h:171
Definition: SmartScriptMgr.h:111
Definition: SmartScriptMgr.h:169
Definition: SmartScriptMgr.h:440
struct SmartEvent::@77::@83 respawn
Definition: SmartScriptMgr.h:120
struct SmartEvent::@77::@79 minMaxRepeat
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTablefmt)
Definition: SmartScriptMgr.h:127
Definition: SmartScriptMgr.h:121
Definition: SmartScriptMgr.h:148
Definition: SmartScriptMgr.h:510
Definition: SmartScriptMgr.h:432
Definition: SmartScriptMgr.h:154
Definition: SmartScriptMgr.h:158
Definition: SmartScriptMgr.h:441
Definition: SmartScriptMgr.h:462
Definition: SmartScriptMgr.h:534
Definition: SmartScriptMgr.h:499
struct SmartEvent::@77::@94 movementInform
Definition: SmartScriptMgr.h:142
struct SmartEvent::@77::@82 los
bool IsTextValid(SmartScriptHolder const &e, uint32 id)
Definition: SmartScriptMgr.cpp:1275
Definition: SmartScriptMgr.h:453
Definition: SmartScriptMgr.h:536
bool IsEmoteValid(SmartScriptHolder const &e, uint32 entry)
Definition: SmartScriptMgr.h:1622
Definition: SmartScriptMgr.h:172
Definition: SmartScriptMgr.h:110
Definition: SmartScriptMgr.h:475
Definition: SmartScriptMgr.h:507
Definition: SmartScriptMgr.h:472
Definition: SmartScriptMgr.h:128
Definition: SmartScriptMgr.h:167
Definition: SmartScriptMgr.h:477
Definition: SmartScriptMgr.h:442
Definition: SmartScriptMgr.h:547
Definition: SmartScriptMgr.h:450
Definition: SmartScriptMgr.h:469
std::pair< CacheSpellContainer::const_iterator, CacheSpellContainer::const_iterator > CacheSpellContainerBounds
Definition: SmartScriptMgr.h:1475
Definition: SmartScriptMgr.h:522
Definition: SmartScriptMgr.h:517
Definition: SmartScriptMgr.h:521
Definition: SmartScriptMgr.h:448
#define MAX_SHEATH_STATE
Definition: Unit.h:303
struct SmartAction::@114::@123 randomEmote
Definition: SmartScriptMgr.h:458
Definition: SmartScriptMgr.h:1219
Definition: SmartScriptMgr.h:490
Definition: SmartScriptMgr.h:533
struct SmartEvent::@77::@81 spellHit
Definition: SmartScriptMgr.h:1210
bool IsAreaTriggerValid(SmartScriptHolder const &e, uint32 entry)
Definition: SmartScriptMgr.h:1632
Definition: SmartScriptMgr.h:471
bool IsTextEmoteValid(SmartScriptHolder const &e, uint32 entry)
Definition: SmartScriptMgr.h:1612
struct SmartAction::@114::@135 randomPhase
Definition: SmartScriptMgr.h:502
Definition: SmartScriptMgr.h:162
Definition: SmartScriptMgr.h:470
Definition: SmartScriptMgr.h:505
struct SmartAction::@114::@142 setSheath
struct SmartEvent::@77::@85 targetCasting
Definition: SmartScriptMgr.h:473
struct SmartEvent::@77::@89 summoned
Definition: SmartScriptMgr.h:530
#define SI64FMTD
Definition: Define.h:140
DB2Storage< TaxiPathEntry > sTaxiPathStore("TaxiPath.db2", TaxiPathFormat, HOTFIX_SEL_TAXI_PATH)
Definition: SmartScriptMgr.h:149
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellInfo.h:238
Definition: SmartScriptMgr.h:468
Definition: SmartScriptMgr.h:107
Definition: SmartScriptMgr.h:157
Definition: SmartScriptMgr.h:446
bool IsSpellValid(SmartScriptHolder const &e, uint32 entry)
Definition: SmartScriptMgr.h:1592
Definition: SmartScriptMgr.h:113
uint32_t uint32
Definition: Define.h:150
Definition: SmartScriptMgr.h:455
DB2Storage< CreatureDisplayInfoEntry > sCreatureDisplayInfoStore("CreatureDisplayInfo.db2", CreatureDisplayInfoFormat, HOTFIX_SEL_CREATURE_DISPLAY_INFO)
bool NotNULL(SmartScriptHolder const &e, uint32 data)
Definition: SmartScriptMgr.h:1552
struct SmartAction::@114::@131 setEventPhase
struct SmartAction::@114::@133 removeAura
Definition: SmartScriptMgr.h:153
Definition: SmartScriptMgr.h:527
Definition: SmartScriptMgr.h:139
Definition: SmartScriptMgr.h:69
#define sSmartWaypointMgr
Definition: SmartScriptMgr.h:1670
Definition: SmartScriptMgr.h:488
Definition: SmartScriptMgr.h:86
struct SmartAction::@114::@167 equip
Definition: SmartScriptMgr.h:457
Definition: SmartScriptMgr.h:164
DBCStorage< PhaseEntry > sPhaseStore(Phasefmt)
Definition: SmartScriptMgr.h:165
Definition: SmartScriptMgr.h:449
Definition: SmartScriptMgr.h:524
SMART_EVENT type
Definition: SmartScriptMgr.h:188
Definition: SmartScriptMgr.h:465
Definition: MotionMaster.h:55
Definition: SmartScriptMgr.h:537
struct SmartAction::@114::@140 updateTemplate
Definition: SmartScriptMgr.h:459
struct SmartEvent::@77::@87 friendlyCC
struct SmartAction::@114::@150 summonGO
Definition: SmartScriptMgr.h:519
struct SmartEvent::@77::@86 friendlyHealth
Definition: DBCStructure.h:824
bool IsItemValid(SmartScriptHolder const &e, uint32 entry)
Definition: SmartScriptMgr.h:1602
Definition: SmartScriptMgr.h:105
Definition: SmartScriptMgr.h:481
Definition: SmartScriptMgr.h:1091
Definition: SmartScriptMgr.h:476
struct SmartEvent::@77::@84 minMax
Definition: SharedDefines.h:1144
Definition: SmartScriptMgr.h:487
struct SmartAction::@114::@192 randomSound
Definition: SmartScriptMgr.h:168
Definition: SmartScriptMgr.h:516
uint32 quest
Definition: SmartScriptMgr.h:278
#define sGameEventMgr
Definition: GameEventMgr.h:184
struct SmartAction::@114::@153 wpStart
Definition: SmartScriptMgr.h:1346
int64 entryOrGuid
Definition: SmartScriptMgr.h:1367
Definition: SmartScriptMgr.h:146
Definition: SmartScriptMgr.h:482
uint32 GetActionType() const
Definition: SmartScriptMgr.h:1378
SmartAction action
Definition: SmartScriptMgr.h:1373
DBCStorage< MapEntry > sMapStore(Mapfmt)
Definition: SmartScriptMgr.h:544
uint32 GetScriptType() const
Definition: SmartScriptMgr.h:1376
CacheSpellContainerBounds GetSummonGameObjectSpellContainerBounds(uint32 gameObjectEntry) const
Definition: SmartScriptMgr.cpp:1368
Definition: SmartScriptMgr.h:456
Definition: SmartScriptMgr.h:523
struct SmartEvent::@77::@101 textOver
Definition: SmartScriptMgr.h:538
Definition: SmartScriptMgr.h:134
Definition: SmartScriptMgr.h:1094
struct SmartAction::@114::@117 faction
Definition: SmartScriptMgr.h:506
Definition: SmartScriptMgr.h:545
Definition: SmartScriptMgr.h:136
Definition: SmartScriptMgr.h:119
struct SmartEvent::@77::@106 gameEvent
SpellEffectInfoVector GetEffectsForDifficulty(uint32 difficulty) const
Definition: SpellInfo.cpp:3311
std::vector< GameEventData > GameEventDataMap
Definition: GameEventMgr.h:107
Definition: SmartScriptMgr.h:514
Definition: SmartScriptMgr.h:483
Definition: SmartScriptMgr.h:117
Definition: SmartScriptMgr.h:132
Definition: SmartScriptMgr.h:520
Definition: SharedDefines.h:265
Definition: SmartScriptMgr.h:104
Definition: SmartScriptMgr.h:513
uint32 sound
Definition: SmartScriptMgr.h:585
Definition: SmartScriptMgr.h:554
Definition: SmartScriptMgr.h:1090
uint32 GetTargetType() const
Definition: SmartScriptMgr.h:1379
Definition: SmartScriptMgr.h:501
Definition: SmartScriptMgr.h:1092
Definition: SmartScriptMgr.h:147
Definition: SmartScriptMgr.h:133
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: SharedDefines.h:4413
Definition: SmartScriptMgr.h:443
struct SmartAction::@114::@124 cast
bool IsGameObjectValid(SmartScriptHolder const &e, uint32 entry)
Definition: SmartScriptMgr.h:1582
Definition: SmartScriptMgr.h:497
struct SmartEvent::@77::@80 kill
Definition: SharedDefines.h:30
Definition: SmartScriptMgr.h:493
Definition: SmartScriptMgr.h:508
struct SmartEvent::@77::@112 counter
Definition: SmartScriptMgr.h:542
Definition: SmartScriptMgr.h:1083
Definition: SmartScriptMgr.h:552
Definition: SharedDefines.h:1875
Definition: SmartScriptMgr.h:159
Definition: Creature.h:277
struct SmartEvent::@77::@109 doAction
Definition: SmartScriptMgr.h:464
struct SmartAction::@114::@118 morphOrMount
Definition: SmartScriptMgr.h:1068
Definition: GameEventMgr.h:56
Definition: SmartScriptMgr.h:447
struct SmartEvent::@77::@111 distance
Definition: SmartScriptMgr.h:512
Definition: SmartScriptMgr.h:484
Definition: SmartScriptMgr.h:467
struct SmartAction::@114::@189 gameEventStop
uint32 quest
Definition: SmartScriptMgr.h:596
Definition: SmartScriptMgr.h:463
Definition: SmartScriptMgr.h:528
Definition: SmartScriptMgr.h:500
struct SmartEvent::@77::@110 friendlyHealthPct
Definition: SmartScriptMgr.h:129
Definition: SmartScriptMgr.h:433
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplatefmt)
Definition: SmartScriptMgr.h:504
CacheSpellContainerBounds GetSummonCreatureSpellContainerBounds(uint32 creatureEntry) const
Definition: SmartScriptMgr.cpp:1363
Definition: SmartScriptMgr.h:155
Definition: SmartScriptMgr.h:126
struct SmartEvent::@77::@100 areatrigger
bool isValid() const
Definition: GameEventMgr.h:72
struct SmartEvent::@77::@97 transportAddCreature
Definition: SmartScriptMgr.h:144
Definition: SmartScriptMgr.h:535
bool IsQuestValid(SmartScriptHolder const &e, uint32 entry)
Definition: SmartScriptMgr.h:1572
SMART_ACTION type
Definition: SmartScriptMgr.h:561
bool IsMinMaxValid(SmartScriptHolder const &e, uint32 min, uint32 max)
Definition: SmartScriptMgr.h:1532
Definition: SmartScriptMgr.h:183
Definition: SmartScriptMgr.h:546
Definition: SmartScriptMgr.h:156
struct SmartAction::@114::@146 ingamePhaseGroup
uint32 emote
Definition: SmartScriptMgr.h:591
Definition: SmartScriptMgr.h:540
Definition: SmartScriptMgr.h:486
Definition: SmartScriptMgr.h:539
Definition: SmartScriptMgr.h:553
Definition: Object.h:54
Definition: SmartScriptMgr.h:541

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool SmartAIMgr::IsGameObjectValid ( SmartScriptHolder const e,
uint32  entry 
)
inlineprivate
1583  {
1584  if (!sObjectMgr->GetGameObjectTemplate(entry))
1585  {
1586  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent GameObject entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1587  return false;
1588  }
1589  return true;
1590  }
#define sObjectMgr
Definition: ObjectMgr.h:1567
#define SI64FMTD
Definition: Define.h:140
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool SmartAIMgr::IsItemValid ( SmartScriptHolder const e,
uint32  entry 
)
inlineprivate
1603  {
1604  if (!sItemStore.LookupEntry(entry))
1605  {
1606  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Item entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1607  return false;
1608  }
1609  return true;
1610  }
DB2Storage< ItemEntry > sItemStore("Item.db2", ItemFormat, HOTFIX_SEL_ITEM)
#define SI64FMTD
Definition: Define.h:140
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool SmartAIMgr::IsMinMaxValid ( SmartScriptHolder const e,
uint32  min,
uint32  max 
)
inlineprivate
1533  {
1534  if (max < min)
1535  {
1536  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses min/max params wrong (%u/%u), skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), min, max);
1537  return false;
1538  }
1539  return true;
1540  }
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
#define SI64FMTD
Definition: Define.h:140
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool SmartAIMgr::IsQuestValid ( SmartScriptHolder const e,
uint32  entry 
)
inlineprivate
1573  {
1574  if (!sObjectMgr->GetQuestTemplate(entry))
1575  {
1576  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Quest entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1577  return false;
1578  }
1579  return true;
1580  }
#define sObjectMgr
Definition: ObjectMgr.h:1567
#define SI64FMTD
Definition: Define.h:140
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool SmartAIMgr::IsSoundValid ( SmartScriptHolder const e,
uint32  entry 
)
inlineprivate
1643  {
1644  if (!sSoundEntriesStore.LookupEntry(entry))
1645  {
1646  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Sound entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1647  return false;
1648  }
1649  return true;
1650  }
#define SI64FMTD
Definition: Define.h:140
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
DB2Storage< SoundEntriesEntry > sSoundEntriesStore("SoundEntries.db2", SoundEntriesFormat, HOTFIX_SEL_SOUND_ENTRIES)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool SmartAIMgr::IsSpellValid ( SmartScriptHolder const e,
uint32  entry 
)
inlineprivate
1593  {
1594  if (!sSpellMgr->GetSpellInfo(entry))
1595  {
1596  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Spell entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1597  return false;
1598  }
1599  return true;
1600  }
#define SI64FMTD
Definition: Define.h:140
#define sSpellMgr
Definition: SpellMgr.h:756
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool SmartAIMgr::IsTargetValid ( SmartScriptHolder const e)
private
306 {
307  if (std::abs(e.target.o) > 2 * float(M_PI))
308  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u has abs(`target.o` = %f) > 2*PI (orientation is expressed in radians)",
309  e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.target.o);
310 
311  if (e.GetActionType() == SMART_ACTION_INSTALL_AI_TEMPLATE)
312  return true; // AI template has special handling
313 
314  switch (e.GetTargetType())
315  {
318  {
319  if (e.target.unitDistance.creature && !sObjectMgr->GetCreatureTemplate(e.target.unitDistance.creature))
320  {
321  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Creature entry %u as target_param1, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.target.unitDistance.creature);
322  return false;
323  }
324  break;
325  }
328  {
329  if (e.target.goDistance.entry && !sObjectMgr->GetGameObjectTemplate(e.target.goDistance.entry))
330  {
331  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent GameObject entry %u as target_param1, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.target.goDistance.entry);
332  return false;
333  }
334  break;
335  }
337  {
338  if (e.target.unitGUID.entry && !IsCreatureValid(e, e.target.unitGUID.entry))
339  return false;
340  break;
341  }
343  {
344  if (e.target.goGUID.entry && !IsGameObjectValid(e, e.target.goGUID.entry))
345  return false;
346  break;
347  }
350  {
351  if (e.target.playerDistance.dist == 0)
352  {
353  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u has maxDist 0 as target_param1, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
354  return false;
355  }
356  break;
357  }
359  case SMART_TARGET_SELF:
360  case SMART_TARGET_VICTIM:
368  case SMART_TARGET_NONE:
376  case SMART_TARGET_STORED:
377  break;
378  default:
379  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Not handled target_type(%u), Entry " SI64FMTD " SourceType %u Event %u Action %u, skipped.", e.GetTargetType(), e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
380  return false;
381  }
382  return true;
383 }
G3D::Matrix abs(const G3D::Matrix &M)
Definition: Matrix.h:632
Definition: SmartScriptMgr.h:1086
Definition: SmartScriptMgr.h:1099
Definition: SmartScriptMgr.h:1081
#define M_PI
Definition: Common.h:163
bool IsCreatureValid(SmartScriptHolder const &e, uint32 entry)
Definition: SmartScriptMgr.h:1562
Definition: SmartScriptMgr.h:1085
Definition: SmartScriptMgr.h:1098
Definition: SmartScriptMgr.h:1082
Definition: SmartScriptMgr.h:1084
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: SmartScriptMgr.h:1079
Definition: SmartScriptMgr.h:1095
Definition: SmartScriptMgr.h:1078
Definition: SmartScriptMgr.h:1096
Definition: SmartScriptMgr.h:1074
Definition: SmartScriptMgr.h:1087
#define SI64FMTD
Definition: Define.h:140
Definition: SmartScriptMgr.h:1080
Definition: SmartScriptMgr.h:1089
Definition: SmartScriptMgr.h:1088
Definition: SmartScriptMgr.h:1091
Definition: SmartScriptMgr.h:1093
Definition: SmartScriptMgr.h:1097
Definition: SmartScriptMgr.h:1073
Definition: SmartScriptMgr.h:1094
Definition: SmartScriptMgr.h:1090
Definition: SmartScriptMgr.h:1092
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
bool IsGameObjectValid(SmartScriptHolder const &e, uint32 entry)
Definition: SmartScriptMgr.h:1582
Definition: SmartScriptMgr.h:497
Definition: SmartScriptMgr.h:1075
Definition: SmartScriptMgr.h:1083
Definition: SmartScriptMgr.h:1076
Definition: SmartScriptMgr.h:1077

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool SmartAIMgr::IsTextEmoteValid ( SmartScriptHolder const e,
uint32  entry 
)
inlineprivate
1613  {
1614  if (!sEmotesTextStore.LookupEntry(entry))
1615  {
1616  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent Text Emote entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1617  return false;
1618  }
1619  return true;
1620  }
#define SI64FMTD
Definition: Define.h:140
DBCStorage< EmotesTextEntry > sEmotesTextStore(EmotesTextfmt)
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool SmartAIMgr::IsTextValid ( SmartScriptHolder const e,
uint32  id 
)
private
1276 {
1277  if (e.GetScriptType() != SMART_SCRIPT_TYPE_CREATURE)
1278  return true;
1279 
1280  uint32 entry = 0;
1281 
1282  if (e.GetEventType() == SMART_EVENT_TEXT_OVER)
1283  {
1284  entry = e.event.textOver.creatureEntry;
1285  }
1286  else
1287  {
1288  switch (e.GetTargetType())
1289  {
1293  return true; // ignore
1294  default:
1295  if (e.entryOrGuid < 0)
1296  {
1297  ObjectGuid::LowType guid = ObjectGuid::LowType(-e.entryOrGuid);
1298  CreatureData const* data = sObjectMgr->GetCreatureData(guid);
1299  if (!data)
1300  {
1301  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u using non-existent Creature guid " UI64FMTD ", skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), guid);
1302  return false;
1303  }
1304  else
1305  entry = data->id;
1306  }
1307  else
1308  entry = uint32(e.entryOrGuid);
1309  break;
1310  }
1311  }
1312 
1313  if (!entry || !sCreatureTextMgr->TextExist(entry, uint8(id)))
1314  {
1315  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD "SourceType %u Event %u Action %u using non-existent Text id %d, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), id);
1316  return false;
1317  }
1318 
1319  return true;
1320 }
Definition: Creature.h:287
uint32 id
Definition: Creature.h:293
Definition: SmartScriptMgr.h:1082
Definition: SmartScriptMgr.h:1084
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: SmartScriptMgr.h:1210
#define SI64FMTD
Definition: Define.h:140
#define UI64FMTD
Definition: Define.h:137
#define sCreatureTextMgr
Definition: CreatureTextMgr.h:113
uint32_t uint32
Definition: Define.h:150
uint8_t uint8
Definition: Define.h:152
Definition: SmartScriptMgr.h:1092
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32_t uint32
Definition: g3dmath.h:168
Definition: SmartScriptMgr.h:156

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SmartAIMgr::LoadHelperStores ( )
private
1323 {
1324  uint32 oldMSTime = getMSTime();
1325 
1326  SpellInfo const* spellInfo = NULL;
1327  for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
1328  {
1329  spellInfo = sSpellMgr->GetSpellInfo(i);
1330  if (!spellInfo)
1331  continue;
1332 
1333  for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(DIFFICULTY_NONE))
1334  {
1335  if (!effect)
1336  continue;
1337 
1338  if (effect->IsEffect(SPELL_EFFECT_SUMMON))
1339  SummonCreatureSpellStore.insert(std::make_pair(uint32(effect->MiscValue), std::make_pair(i, SpellEffIndex(effect->EffectIndex))));
1340 
1341  else if (effect->IsEffect(SPELL_EFFECT_SUMMON_OBJECT_WILD))
1342  SummonGameObjectSpellStore.insert(std::make_pair(uint32(effect->MiscValue), std::make_pair(i, SpellEffIndex(effect->EffectIndex))));
1343 
1344  else if (effect->IsEffect(SPELL_EFFECT_KILL_CREDIT) || effect->IsEffect(SPELL_EFFECT_KILL_CREDIT2))
1345  KillCreditSpellStore.insert(std::make_pair(uint32(effect->MiscValue), std::make_pair(i, SpellEffIndex(effect->EffectIndex))));
1346 
1347  else if (effect->IsEffect(SPELL_EFFECT_CREATE_ITEM))
1348  CreateItemSpellStore.insert(std::make_pair(uint32(effect->ItemType), std::make_pair(i, SpellEffIndex(effect->EffectIndex))));
1349  }
1350  }
1351 
1352  TC_LOG_INFO("server.loading", ">> Loaded SmartAIMgr Helpers in %u ms", GetMSTimeDiffToNow(oldMSTime));
1353 }
Definition: DBCEnums.h:404
Definition: SharedDefines.h:1100
Definition: SpellInfo.h:326
uint32 getMSTime()
Definition: Timer.h:24
Definition: SharedDefines.h:1038
arena_t NULL
Definition: jemalloc_internal.h:624
CacheSpellContainer CreateItemSpellStore
Definition: SmartScriptMgr.h:1666
CacheSpellContainer SummonGameObjectSpellStore
Definition: SmartScriptMgr.h:1664
CacheSpellContainer SummonCreatureSpellStore
Definition: SmartScriptMgr.h:1663
Definition: SharedDefines.h:1034
Definition: SharedDefines.h:1086
SpellEffIndex
Definition: SharedDefines.h:26
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:1144
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:42
CacheSpellContainer KillCreditSpellStore
Definition: SmartScriptMgr.h:1665
SpellEffectInfoVector GetEffectsForDifficulty(uint32 difficulty) const
Definition: SpellInfo.cpp:3311
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SmartAIMgr::LoadSmartAIFromDB ( )
115 {
117 
118  uint32 oldMSTime = getMSTime();
119 
120  for (uint8 i = 0; i < SMART_SCRIPT_TYPE_MAX; i++)
121  mEventMap[i].clear(); //Drop Existing SmartAI List
122 
124  PreparedQueryResult result = WorldDatabase.Query(stmt);
125 
126  if (!result)
127  {
128  TC_LOG_INFO("server.loading", ">> Loaded 0 SmartAI scripts. DB table `smartai_scripts` is empty.");
129  return;
130  }
131 
132  uint32 count = 0;
133 
134  do
135  {
136  Field* fields = result->Fetch();
137 
138  SmartScriptHolder temp;
139 
140  temp.entryOrGuid = fields[0].GetInt64();
141  SmartScriptType source_type = (SmartScriptType)fields[1].GetUInt8();
142  if (source_type >= SMART_SCRIPT_TYPE_MAX)
143  {
144  TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: invalid source_type (%u), skipped loading.", uint32(source_type));
145  continue;
146  }
147  if (temp.entryOrGuid >= 0)
148  {
149  switch (source_type)
150  {
152  {
153  CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate((uint32)temp.entryOrGuid);
154  if (!creatureInfo)
155  {
156  TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature entry (%u) does not exist, skipped loading.", uint32(temp.entryOrGuid));
157  continue;
158  }
159 
160  if (creatureInfo->AIName != "SmartAI")
161  {
162  TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature entry (%u) is not using SmartAI, skipped loading.", uint32(temp.entryOrGuid));
163  continue;
164  }
165  break;
166  }
168  {
169  GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate((uint32)temp.entryOrGuid);
170  if (!gameObjectInfo)
171  {
172  TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: GameObject entry (%u) does not exist, skipped loading.", uint32(temp.entryOrGuid));
173  continue;
174  }
175 
176  if (gameObjectInfo->AIName != "SmartGameObjectAI")
177  {
178  TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: GameObject entry (%u) is not using SmartGameObjectAI, skipped loading.", uint32(temp.entryOrGuid));
179  continue;
180  }
181  break;
182  }
184  {
185  if (!sAreaTriggerStore.LookupEntry((uint32)temp.entryOrGuid))
186  {
187  TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: AreaTrigger entry (%u) does not exist, skipped loading.", uint32(temp.entryOrGuid));
188  continue;
189  }
190  break;
191  }
193  break;//nothing to check, really
194  default:
195  TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: not yet implemented source_type %u", (uint32)source_type);
196  continue;
197  }
198  }
199  else
200  {
201  CreatureData const* creature = sObjectMgr->GetCreatureData(uint64(-temp.entryOrGuid));
202  if (!creature)
203  {
204  TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature guid (" SI64FMTD ") does not exist, skipped loading.", -temp.entryOrGuid);
205  continue;
206  }
207 
208  CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creature->id);
209  if (!creatureInfo)
210  {
211  TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature entry (%u) guid (" SI64FMTD ") does not exist, skipped loading.", creature->id, -temp.entryOrGuid);
212  continue;
213  }
214 
215  if (creatureInfo->AIName != "SmartAI")
216  {
217  TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature entry (%u) guid (" SI64FMTD ") is not using SmartAI, skipped loading.", creature->id, -temp.entryOrGuid);
218  continue;
219  }
220  }
221 
222  temp.source_type = source_type;
223  temp.event_id = fields[2].GetUInt16();
224  temp.link = fields[3].GetUInt16();
225  temp.event.type = (SMART_EVENT)fields[4].GetUInt8();
226  temp.event.event_phase_mask = fields[5].GetUInt8();
227  temp.event.event_chance = fields[6].GetUInt8();
228  temp.event.event_flags = fields[7].GetUInt8();
229 
230  temp.event.raw.param1 = fields[8].GetUInt32();
231  temp.event.raw.param2 = fields[9].GetUInt32();
232  temp.event.raw.param3 = fields[10].GetUInt32();
233  temp.event.raw.param4 = fields[11].GetUInt32();
234 
235  temp.action.type = (SMART_ACTION)fields[12].GetUInt8();
236  temp.action.raw.param1 = fields[13].GetUInt32();
237  temp.action.raw.param2 = fields[14].GetUInt32();
238  temp.action.raw.param3 = fields[15].GetUInt32();
239  temp.action.raw.param4 = fields[16].GetUInt32();
240  temp.action.raw.param5 = fields[17].GetUInt32();
241  temp.action.raw.param6 = fields[18].GetUInt32();
242 
243  temp.target.type = (SMARTAI_TARGETS)fields[19].GetUInt8();
244  temp.target.raw.param1 = fields[20].GetUInt32();
245  temp.target.raw.param2 = fields[21].GetUInt32();
246  temp.target.raw.param3 = fields[22].GetUInt32();
247  temp.target.x = fields[23].GetFloat();
248  temp.target.y = fields[24].GetFloat();
249  temp.target.z = fields[25].GetFloat();
250  temp.target.o = fields[26].GetFloat();
251 
252  //check target
253  if (!IsTargetValid(temp))
254  continue;
255 
256  // check all event and action params
257  if (!IsEventValid(temp))
258  continue;
259 
260  // creature entry / guid not found in storage, create empty event list for it and increase counters
261  if (mEventMap[source_type].find(temp.entryOrGuid) == mEventMap[source_type].end())
262  {
263  ++count;
264  SmartAIEventList eventList;
265  mEventMap[source_type][temp.entryOrGuid] = eventList;
266  }
267  // store the new event
268  mEventMap[source_type][temp.entryOrGuid].push_back(temp);
269  }
270  while (result->NextRow());
271 
272  // Post Loading Validation
273  for (uint8 i = 0; i < SMART_SCRIPT_TYPE_MAX; ++i)
274  {
275  for (SmartAIEventMap::iterator itr = mEventMap[i].begin(); itr != mEventMap[i].end(); ++itr)
276  {
277  for (SmartScriptHolder const& e : itr->second)
278  {
279  if (e.link)
280  {
281  if (!FindLinkedEvent(itr->second, e.link))
282  {
283  TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Entry " SI64FMTD " SourceType %u, Event %u, Link Event %u not found or invalid.",
284  e.entryOrGuid, e.GetScriptType(), e.event_id, e.link);
285  }
286  }
287 
288  if (e.GetEventType() == SMART_EVENT_LINK)
289  {
290  if (!FindLinkedSourceEvent(itr->second, e.event_id))
291  {
292  TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Entry " SI64FMTD " SourceType %u, Event %u, Link Source Event not found or invalid. Event will never trigger.",
294  }
295  }
296  }
297  }
298  }
299 
300  TC_LOG_INFO("server.loading", ">> Loaded %u SmartAI scripts in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
301 
303 }
Definition: Creature.h:287
SmartScriptType
Definition: SmartScriptMgr.h:1208
Definition: WorldDatabase.h:36
bool IsEventValid(SmartScriptHolder &e)
Definition: SmartScriptMgr.cpp:385
uint32 event_phase_mask
Definition: SmartScriptMgr.h:189
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
float GetFloat() const
Definition: Field.h:222
uint32 id
Definition: Creature.h:293
SmartEvent event
Definition: SmartScriptMgr.h:1372
void UnLoadHelperStores()
Definition: SmartScriptMgr.cpp:1355
std::string AIName
Definition: Creature.h:127
SMARTAI_TARGETS type
Definition: SmartScriptMgr.h:1117
std::vector< SmartScriptHolder > SmartAIEventList
Definition: SmartScriptMgr.h:1468
DBCStorage< AreaTriggerEntry > sAreaTriggerStore(AreaTriggerfmt)
Definition: SmartScriptMgr.h:1212
Class used to access individual fields of database query result.
Definition: Field.h:56
uint32 link
Definition: SmartScriptMgr.h:1370
std::string AIName
Definition: GameObject.h:624
int64 GetInt64() const
Definition: Field.h:203
uint32 GetEventType() const
Definition: SmartScriptMgr.h:1377
uint32 getMSTime()
Definition: Timer.h:24
Definition: GameObject.h:34
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
float y
Definition: SmartScriptMgr.h:1118
struct SmartTarget::@194::@209 raw
SMART_ACTION
Definition: SmartScriptMgr.h:437
uint32 event_id
Definition: SmartScriptMgr.h:1369
uint64_t uint64
Definition: g3dmath.h:170
struct SmartAction::@114::@193 raw
uint32 event_flags
Definition: SmartScriptMgr.h:191
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
SmartTarget target
Definition: SmartScriptMgr.h:1374
uint8 GetUInt8() const
Definition: Field.h:70
Definition: SmartScriptMgr.h:1219
Definition: SmartScriptMgr.h:1210
#define SI64FMTD
Definition: Define.h:140
SMART_EVENT
Definition: SmartScriptMgr.h:102
uint32_t uint32
Definition: Define.h:150
float z
Definition: SmartScriptMgr.h:1118
struct SmartEvent::@77::@113 raw
Definition: SmartScriptMgr.h:165
uint16 GetUInt16() const
Definition: Field.h:108
SMART_EVENT type
Definition: SmartScriptMgr.h:188
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
float x
Definition: SmartScriptMgr.h:1118
float o
Definition: SmartScriptMgr.h:1118
SmartAIEventMap mEventMap[SMART_SCRIPT_TYPE_MAX]
Definition: SmartScriptMgr.h:1527
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:42
Definition: SmartScriptMgr.h:1220
int64 entryOrGuid
Definition: SmartScriptMgr.h:1367
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
SmartAction action
Definition: SmartScriptMgr.h:1373
uint32 GetScriptType() const
Definition: SmartScriptMgr.h:1376
static SmartScriptHolder & FindLinkedSourceEvent(SmartAIEventList &list, uint32 eventId)
Definition: SmartScriptMgr.h:1501
uint32 GetUInt32() const
Definition: Field.h:146
bool IsTargetValid(SmartScriptHolder const &e)
Definition: SmartScriptMgr.cpp:305
uint8_t uint8
Definition: Define.h:152
SmartScriptType source_type
Definition: SmartScriptMgr.h:1368
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32 event_chance
Definition: SmartScriptMgr.h:190
Definition: SmartScriptMgr.h:1361
uint32_t uint32
Definition: g3dmath.h:168
Definition: SmartScriptMgr.h:1211
void LoadHelperStores()
Definition: SmartScriptMgr.cpp:1322
Definition: Creature.h:79
SMARTAI_TARGETS
Definition: SmartScriptMgr.h:1071
SMART_ACTION type
Definition: SmartScriptMgr.h:561
static SmartScriptHolder & FindLinkedEvent(SmartAIEventList &list, uint32 link)
Definition: SmartScriptMgr.h:1513

+ Here is the call graph for this function:

bool SmartAIMgr::NotNULL ( SmartScriptHolder const e,
uint32  data 
)
inlineprivate
1553  {
1554  if (!data)
1555  {
1556  TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u Parameter can not be NULL, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
1557  return false;
1558  }
1559  return true;
1560  }
#define SI64FMTD
Definition: Define.h:140
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SmartAIMgr::UnLoadHelperStores ( )
private
1356 {
1357  SummonCreatureSpellStore.clear();
1359  KillCreditSpellStore.clear();
1360  CreateItemSpellStore.clear();
1361 }
CacheSpellContainer CreateItemSpellStore
Definition: SmartScriptMgr.h:1666
CacheSpellContainer SummonGameObjectSpellStore
Definition: SmartScriptMgr.h:1664
CacheSpellContainer SummonCreatureSpellStore
Definition: SmartScriptMgr.h:1663
CacheSpellContainer KillCreditSpellStore
Definition: SmartScriptMgr.h:1665

+ Here is the caller graph for this function:

Member Data Documentation

CacheSpellContainer SmartAIMgr::CreateItemSpellStore
private
CacheSpellContainer SmartAIMgr::KillCreditSpellStore
private
SmartAIEventMap SmartAIMgr::mEventMap[SMART_SCRIPT_TYPE_MAX]
private
CacheSpellContainer SmartAIMgr::SummonCreatureSpellStore
private
CacheSpellContainer SmartAIMgr::SummonGameObjectSpellStore
private

The documentation for this class was generated from the following files: