OregonCore  revision fb2a440-git
Your Favourite TBC server
SmartScriptMgr.h
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 #ifndef OREGON_SMARTSCRIPTMGR_H
19 #define OREGON_SMARTSCRIPTMGR_H
20 
21 #include "Common.h"
22 #include "Creature.h"
23 #include "CreatureAI.h"
24 #include "Unit.h"
25 #include "Spell.h"
26 #include "ObjectAccessor.h"
27 #include "ObjectMgr.h"
28 
29 //#include "SmartScript.h"
30 //#include "SmartAI.h"
31 
32 struct WayPoint
33 {
34  WayPoint(uint32 _id, float _x, float _y, float _z)
35  {
36  id = _id;
37  x = _x;
38  y = _y;
39  z = _z;
40  }
41 
43  float x;
44  float y;
45  float z;
46 };
47 
49 {
61 
63 };
64 
66 {
78 };
79 
81 {
91 };
92 
94 {
95  SMART_EVENT_UPDATE_IC = 0, // InitialMin, InitialMax, RepeatMin, RepeatMax
96  SMART_EVENT_UPDATE_OOC = 1, // InitialMin, InitialMax, RepeatMin, RepeatMax
97  SMART_EVENT_HEALT_PCT = 2, // HPMin%, HPMax%, RepeatMin, RepeatMax
98  SMART_EVENT_MANA_PCT = 3, // ManaMin%, ManaMax%, RepeatMin, RepeatMax
99  SMART_EVENT_AGGRO = 4, // NONE
100  SMART_EVENT_KILL = 5, // CooldownMin0, CooldownMax1, playerOnly2, else creature entry3
101  SMART_EVENT_DEATH = 6, // NONE
102  SMART_EVENT_EVADE = 7, // NONE
103  SMART_EVENT_SPELLHIT = 8, // SpellID, School, CooldownMin, CooldownMax
104  SMART_EVENT_RANGE = 9, // MinDist, MaxDist, RepeatMin, RepeatMax
105  SMART_EVENT_OOC_LOS = 10, // NoHostile, MaxRnage, CooldownMin, CooldownMax
106  SMART_EVENT_RESPAWN = 11, // type, MapId, ZoneId
107  SMART_EVENT_TARGET_HEALTH_PCT = 12, // HPMin%, HPMax%, RepeatMin, RepeatMax
108  SMART_EVENT_VICTIM_CASTING = 13, // RepeatMin, RepeatMax, spellid
109  SMART_EVENT_FRIENDLY_HEALTH = 14, // HPDeficit, Radius, RepeatMin, RepeatMax
110  SMART_EVENT_FRIENDLY_IS_CC = 15, // Radius, RepeatMin, RepeatMax
111  SMART_EVENT_FRIENDLY_MISSING_BUFF = 16, // SpellId, Radius, RepeatMin, RepeatMax
112  SMART_EVENT_SUMMONED_UNIT = 17, // CreatureId(0 all), CooldownMin, CooldownMax
113  SMART_EVENT_TARGET_MANA_PCT = 18, // ManaMin%, ManaMax%, RepeatMin, RepeatMax
114  SMART_EVENT_ACCEPTED_QUEST = 19, // QuestID(0any)
115  SMART_EVENT_REWARD_QUEST = 20, // QuestID(0any)
117  SMART_EVENT_RECEIVE_EMOTE = 22, // EmoteId, CooldownMin, CooldownMax, condition, val1, val2, val3
118  SMART_EVENT_HAS_AURA = 23, // Param1 = SpellID, Param2 = Stack amount, Param3/4 RepeatMin, RepeatMax
119  SMART_EVENT_TARGET_BUFFED = 24, // Param1 = SpellID, Param2 = Stack amount, Param3/4 RepeatMin, RepeatMax
120  SMART_EVENT_RESET = 25, // Called after combat, when the creature respawn and spawn.
121  SMART_EVENT_IC_LOS = 26, // NoHostile, MaxRnage, CooldownMin, CooldownMax
122  SMART_EVENT_PASSENGER_BOARDED = 27, // CooldownMin, CooldownMax
123  SMART_EVENT_PASSENGER_REMOVED = 28, // CooldownMin, CooldownMax
124  SMART_EVENT_CHARMED = 29, // NONE
126  SMART_EVENT_SPELLHIT_TARGET = 31, // SpellID, School, CooldownMin, CooldownMax
127  SMART_EVENT_DAMAGED = 32, // MinDmg, MaxDmg, CooldownMin, CooldownMax
128  SMART_EVENT_DAMAGED_TARGET = 33, // MinDmg, MaxDmg, CooldownMin, CooldownMax
129  SMART_EVENT_MOVEMENTINFORM = 34, // MovementType(any), PointID
130  SMART_EVENT_SUMMON_DESPAWNED = 35, // Entry, CooldownMin, CooldownMax
132  SMART_EVENT_AI_INIT = 37, // NONE
133  SMART_EVENT_DATA_SET = 38, // Id, Value, CooldownMin, CooldownMax
134  SMART_EVENT_WAYPOINT_START = 39, // PointId(0any), pathID(0any)
135  SMART_EVENT_WAYPOINT_REACHED = 40, // PointId(0any), pathID(0any)
137  SMART_EVENT_TRANSPORT_ADDCREATURE = 42, // Entry (0 any)
140  SMART_EVENT_INSTANCE_PLAYER_ENTER = 45, // Team (0 any), CooldownMin, CooldownMax
141  SMART_EVENT_AREATRIGGER_ONTRIGGER = 46, // TriggerId(0 any)
147  SMART_EVENT_TEXT_OVER = 52, // GroupId from creature_text, creature entry who talks (0 any)
148  SMART_EVENT_RECEIVE_HEAL = 53, // MinHeal, MaxHeal, CooldownMin, CooldownMax
150  SMART_EVENT_WAYPOINT_PAUSED = 55, // PointId(0any), pathID(0any)
151  SMART_EVENT_WAYPOINT_RESUMED = 56, // PointId(0any), pathID(0any)
152  SMART_EVENT_WAYPOINT_STOPPED = 57, // PointId(0any), pathID(0any)
153  SMART_EVENT_WAYPOINT_ENDED = 58, // PointId(0any), pathID(0any)
155  SMART_EVENT_UPDATE = 60, // InitialMin, InitialMax, RepeatMin, RepeatMax
156  SMART_EVENT_LINK = 61, // INTERNAL USAGE, no params, used to link together multiple events, does not use any extra resources to iterate event lists needlessly
157  SMART_EVENT_GOSSIP_SELECT = 62, // menuID, actionID
161  SMART_EVENT_DUMMY_EFFECT = 66, // spellId, effectIndex
162  SMART_EVENT_IS_BEHIND_TARGET = 67, // cooldownMin, CooldownMax
163  SMART_EVENT_GAME_EVENT_START = 68, // game_event.Entry
164  SMART_EVENT_GAME_EVENT_END = 69, // game_event.Entry
167  SMART_EVENT_ACTION_DONE = 72, // eventId (SharedDefines.EventId)
168  SMART_EVENT_ON_SPELLCLICK = 73, // clicker (unit)
169  SMART_EVENT_FRIENDLY_HEALTH_PCT = 74, // minHpPct, maxHpPct, repeatMin, repeatMax
170  SMART_EVENT_DISTANCE_CREATURE = 75, // guid, entry, distance, repeat
171  SMART_EVENT_DISTANCE_GAMEOBJECT = 76, // guid, entry, distance, repeat
172  SMART_EVENT_COUNTER_SET = 77, // id, value, cooldownMin, cooldownMax
173 
175 };
176 
178 {
183  union
184  {
185  struct
186  {
191  } minMaxRepeat;
192 
193  struct
194  {
199  } kill;
200 
201  struct
202  {
205  uint32 cooldownMin;
206  uint32 cooldownMax;
207  } spellHit;
208 
209  struct
210  {
213  uint32 cooldownMin;
214  uint32 cooldownMax;
215  } los;
216 
217  struct
218  {
222  } respawn;
223 
224  struct
225  {
226  uint32 repeatMin;
227  uint32 repeatMax;
228  } minMax;
229 
230  struct
231  {
232  uint32 repeatMin;
233  uint32 repeatMax;
235  } targetCasting;
236 
237  struct
238  {
241  uint32 repeatMin;
242  uint32 repeatMax;
243  } friendlyHealth;
244 
245  struct
246  {
247  uint32 radius;
248  uint32 repeatMin;
249  uint32 repeatMax;
250  } friendlyCC;
251 
252  struct
253  {
254  uint32 spell;
255  uint32 radius;
256  uint32 repeatMin;
257  uint32 repeatMax;
258  } missingBuff;
259 
260  struct
261  {
262  uint32 creature;
263  uint32 cooldownMin;
264  uint32 cooldownMax;
265  } summoned;
266 
267  struct
268  {
270  } quest;
271 
272  struct
273  {
275  uint32 cooldownMin;
276  uint32 cooldownMax;
277  } emote;
278 
279  struct
280  {
281  uint32 spell;
283  uint32 repeatMin;
284  uint32 repeatMax;
285  } aura;
286 
287  struct
288  {
289  uint32 spell;
290  uint32 count;
291  uint32 repeatMin;
292  uint32 repeatMax;
293  } targetAura;
294 
295  struct
296  {
297  uint32 type;
299  } movementInform;
300 
301  struct
302  {
303  uint32 id;
305  uint32 cooldownMin;
306  uint32 cooldownMax;
307  } dataSet;
308 
309  struct
310  {
313  } waypoint;
314 
315  struct
316  {
317  uint32 creature;
318  } transportAddCreature;
319 
320  struct
321  {
322  uint32 pointID;
323  } transportRelocate;
324 
325  struct
326  {
328  uint32 cooldownMin;
329  uint32 cooldownMax;
330  } instancePlayerEnter;
331 
332  struct
333  {
334  uint32 id;
335  } areatrigger;
336 
337  struct
338  {
341  } textOver;
342 
343  struct
344  {
345  uint32 id;
346  } timedEvent;
347 
348  struct
349  {
352  } gossip;
353 
354  struct
355  {
356  uint32 spell;
358  } dummy;
359 
360  struct
361  {
362  uint32 cooldownMin;
363  uint32 cooldownMax;
364  } behindTarget;
365 
366  struct
367  {
369  } gameEvent;
370 
371  struct
372  {
374  } goStateChanged;
375 
376  struct
377  {
379  } eventInform;
380 
381  struct
382  {
383  uint32 eventId;
384  } doAction;
385 
386  struct
387  {
390  uint32 repeatMin;
391  uint32 repeatMax;
392  } friendlyHealthPct;
393 
394  struct
395  {
400  } distance;
401 
402  struct
403  {
404  uint32 id;
405  uint32 value;
406  uint32 cooldownMin;
407  uint32 cooldownMax;
408  } counter;
409 
410  struct
411  {
416  } raw;
417  };
418 };
419 
421 {
426 };
427 
429 {
430  SMART_ACTION_NONE = 0, // No action
431  SMART_ACTION_TALK = 1, // groupID from creature_text, duration to wait before TEXT_OVER event is triggered, useTalkTarget (0/1) - use target as talk target
432  SMART_ACTION_SET_FACTION = 2, // FactionId (or 0 for default)
433  SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL = 3, // Creature_template entry(param1) OR ModelId (param2) (or 0 for both to demorph)
434  SMART_ACTION_SOUND = 4, // SoundId, onlySelf
435  SMART_ACTION_PLAY_EMOTE = 5, // EmoteId
436  SMART_ACTION_FAIL_QUEST = 6, // QuestID
437  SMART_ACTION_ADD_QUEST = 7, // QuestID
440  SMART_ACTION_RANDOM_EMOTE = 10, // EmoteId1, EmoteId2, EmoteId3...
441  SMART_ACTION_CAST = 11, // SpellId, CastFlags
442  SMART_ACTION_SUMMON_CREATURE = 12, // CreatureID, summonType, duration in ms, attackInvoker
446  SMART_ACTION_UNUSED_16 = 16, // UNUSED
448  SMART_ACTION_SET_UNIT_FLAG = 18, // Flags (may be more than one field OR'd together), Target
449  SMART_ACTION_REMOVE_UNIT_FLAG = 19, // Flags (may be more than one field OR'd together), Target
450  SMART_ACTION_AUTO_ATTACK = 20, // AllowAttackState (0 = stop attack, anything else means continue attacking)
451  SMART_ACTION_ALLOW_COMBAT_MOVEMENT = 21, // AllowCombatMovement (0 = stop combat based movement, anything else continue attacking)
453  SMART_ACTION_INC_EVENT_PHASE = 23, // Value (may be negative to decrement phase, should not be 0)
454  SMART_ACTION_EVADE = 24, // No Params
455  SMART_ACTION_FLEE_FOR_ASSIST = 25, // With Emote
458  SMART_ACTION_REMOVEAURASFROMSPELL = 28, // Spellid (0 removes all auras), charges (0 removes aura)
459  SMART_ACTION_FOLLOW = 29, // Distance (0 = default), Angle (0 = default), EndCreatureEntry, credit, creditType (0monsterkill, 1event)
460  SMART_ACTION_RANDOM_PHASE = 30, // PhaseId1, PhaseId2, PhaseId3...
461  SMART_ACTION_RANDOM_PHASE_RANGE = 31, // PhaseMin, PhaseMax
463  SMART_ACTION_CALL_KILLEDMONSTER = 33, // CreatureId,
464  SMART_ACTION_SET_INST_DATA = 34, // Field, Data
467  SMART_ACTION_DIE = 37, // No Params
469  SMART_ACTION_CALL_FOR_HELP = 39, // Radius, With Emote
470  SMART_ACTION_SET_SHEATH = 40, // Sheath (0-unarmed, 1-melee, 2-ranged)
472  SMART_ACTION_SET_INVINCIBILITY_HP_LEVEL = 42, // MinHpValue(+pct, -flat)
473  SMART_ACTION_MOUNT_TO_ENTRY_OR_MODEL = 43, // Creature_template entry(param1) OR ModelId (param2) (or 0 for both to dismount)
475  SMART_ACTION_SET_DATA = 45, // Field, Data (only creature @todo)
476  SMART_ACTION_MOVE_FORWARD = 46, // distance
478  SMART_ACTION_SET_ACTIVE = 48, // on/off
480  SMART_ACTION_SUMMON_GO = 50, // GameObjectID, DespawnTime in s
483  SMART_ACTION_WP_START = 53, // run/walk, pathID, canRepeat, quest, despawntime, reactState
484  SMART_ACTION_WP_PAUSE = 54, // time
485  SMART_ACTION_WP_STOP = 55, // despawnTime, quest, fail?
486  SMART_ACTION_ADD_ITEM = 56, // itemID, count
487  SMART_ACTION_REMOVE_ITEM = 57, // itemID, count
488  SMART_ACTION_INSTALL_AI_TEMPLATE = 58, // AITemplateID
489  SMART_ACTION_SET_RUN = 59, // 0/1
490  SMART_ACTION_SET_FLY = 60, // 0/1
492  SMART_ACTION_TELEPORT = 62, // mapID,
493  SMART_ACTION_SET_COUNTER = 63, // id, value, reset (0/1)
497  SMART_ACTION_CREATE_TIMED_EVENT = 67, // id, InitialMin, InitialMax, RepeatMin(only if it repeats), RepeatMax(only if it repeats), chance
498  SMART_ACTION_PLAYMOVIE = 68, // entry
499  SMART_ACTION_MOVE_TO_POS = 69, // PointId, xyz
501  SMART_ACTION_EQUIP = 71, // entry, slotmask slot1, slot2, slot3 , only slots with mask set will be sent to client, bits are 1, 2, 4, leaving mask 0 is defaulted to mask 7 (send all), slots1-3 are only used if no entry is set
505  SMART_ACTION_ADD_AURA = 75, // spellid, targets
506  SMART_ACTION_OVERRIDE_SCRIPT_BASE_OBJECT = 76, // WARNING: CAN CRASH CORE, do not use if you dont know what you are doing
509  SMART_ACTION_SET_RANGED_MOVEMENT = 79, // Distance, angle
510  SMART_ACTION_CALL_TIMED_ACTIONLIST = 80, // ID (overwrites already running actionlist), stop after combat?(0/1), timer update type(0-OOC, 1-IC, 2-ALWAYS)
514  SMART_ACTION_SIMPLE_TALK = 84, // groupID, can be used to make players say groupID, Text_over event is not triggered, whisper can not be used (Target units will say the text)
515  SMART_ACTION_INVOKER_CAST = 85, // spellID, castFlags, if avaliable, last used invoker will cast spellId with castFlags on targets
516  SMART_ACTION_CROSS_CAST = 86, // spellID, castFlags, CasterTargetType, CasterTarget param1, CasterTarget param2, CasterTarget param3, ( + the origonal target fields as Destination target), CasterTargets will cast spellID on all Targets (use with caution if targeting multiple * multiple units)
519  SMART_ACTION_RANDOM_MOVE = 89, // maxDist
520  SMART_ACTION_SET_UNIT_FIELD_BYTES_1 = 90, // bytes, target
527  SMART_ACTION_JUMP_TO_POS = 97, // speedXY, speedZ, targetX, targetY, targetZ
528  SMART_ACTION_SEND_GOSSIP_MENU = 98, // menuId, optionId
533  SMART_ACTION_SET_ROOT = 103, // off/on
534  SMART_ACTION_SET_GO_FLAG = 104, // Flags
535  SMART_ACTION_ADD_GO_FLAG = 105, // Flags
537  SMART_ACTION_SUMMON_CREATURE_GROUP = 107, // Group, attackInvoker
538  SMART_ACTION_SET_POWER = 108, // PowerType, newPower
539  SMART_ACTION_ADD_POWER = 109, // PowerType, newPower
540  SMART_ACTION_REMOVE_POWER = 110, // PowerType, newPower
541  SMART_ACTION_GAME_EVENT_STOP = 111, // GameEventId
542  SMART_ACTION_GAME_EVENT_START = 112, // GameEventId
543  SMART_ACTION_START_CLOSEST_WAYPOINT = 113, // wp1, wp2, wp3, wp4, wp5, wp6, wp7
545  SMART_ACTION_RANDOM_SOUND = 115, // SoundId1, SoundId2, SoundId3, SoundId4, SoundId5, onlySelf
546 
548 };
549 
551 {
553 
554  union
555  {
556  struct
557  {
561  } talk;
562 
563  struct
564  {
566  } faction;
567 
568  struct
569  {
572  } morphOrMount;
573 
574  struct
575  {
579  } sound;
580 
581  struct
582  {
584  } emote;
585 
586  struct
587  {
589  } quest;
590 
591  struct
592  {
594  } react;
595 
596  struct
597  {
604  } randomEmote;
605 
606  struct
607  {
614  } cast;
615 
616  struct
617  {
618  uint32 creature;
620  uint32 duration;
622  } summonCreature;
623 
624  struct
625  {
628  } threatPCT;
629 
630  struct
631  {
638  } addUnitFlag;
639 
640  struct
641  {
642  uint32 flag1;
643  uint32 flag2;
644  uint32 flag3;
645  uint32 flag4;
646  uint32 flag5;
647  uint32 flag6;
648  } removeUnitFlag;
649 
650  struct
651  {
653  } autoAttack;
654 
655  struct
656  {
658  } combatMove;
659 
660  struct
661  {
663  } setEventPhase;
664 
665  struct
666  {
669  } incEventPhase;
670 
671  struct
672  {
673  uint32 spell;
675  } removeAura;
676 
677  struct
678  {
684  } follow;
685 
686  struct
687  {
694  } randomPhase;
695 
696  struct
697  {
700  } randomPhaseRange;
701 
702  struct
703  {
704  uint32 creature;
705  } killedMonster;
706 
707  struct
708  {
711  } setInstanceData;
712 
713  struct
714  {
715  uint32 field;
716  } setInstanceData64;
717 
718  struct
719  {
720  uint32 creature;
721  } updateTemplate;
722 
723  struct
724  {
727  } callHelp;
728 
729  struct
730  {
732  } setSheath;
733 
734  struct
735  {
737  } forceDespawn;
738 
739  struct
740  {
743  } invincHP;
744 
745  struct
746  {
748  } ingamePhaseMask;
749 
750  struct
751  {
752  uint32 field;
753  uint32 data;
754  } setData;
755 
756  struct
757  {
758  uint32 distance;
759  } moveRandom;
760 
761  struct
762  {
763  uint32 state;
764  } visibility;
765 
766  struct
767  {
768  uint32 entry;
770  } summonGO;
771 
772  struct
773  {
774  uint32 state;
775  } active;
776 
777  struct
778  {
780  } taxi;
781 
782  struct
783  {
787  uint32 quest;
788  uint32 despawnTime;
790  } wpStart;
791 
792  struct
793  {
794  uint32 delay;
795  } wpPause;
796 
797  struct
798  {
799  uint32 despawnTime;
800  uint32 quest;
802  } wpStop;
803 
804  struct
805  {
806  uint32 entry;
808  } item;
809 
810  struct
811  {
812  uint32 id;
818  } installTtemplate;
819 
820  struct
821  {
822  uint32 run;
823  } setRun;
824 
825  struct
826  {
828  } setFly;
829 
830  struct
831  {
833  } setSwim;
834 
835  struct
836  {
838  } teleport;
839 
840  struct
841  {
845  } setCounter;
846 
847  struct
848  {
849  uint32 id;
851  } storeVar;
852 
853  struct
854  {
855  uint32 id;
856  } storeTargets;
857 
858  struct
859  {
860  uint32 id;
866  } timeEvent;
867 
868  struct
869  {
870  uint32 entry;
871  } movie;
872 
873  struct
874  {
875  uint32 entry;
876  uint32 mask;
880  } equip;
881 
882  struct
883  {
885  uint32 type;
886  } unitFlag;
887 
888  struct
889  {
891  uint32 type;
892  } setunitByte;
893 
894  struct
895  {
896  uint32 byte1;
897  uint32 type;
898  } delunitByte;
899 
900  struct
901  {
903  } enterVehicle;
904 
905  struct
906  {
907  uint32 id;
909  } timedActionList;
910 
911  struct
912  {
919  } randTimedActionList;
920 
921  struct
922  {
926  } interruptSpellCasting;
927 
928  struct
929  {
931  } sendGoCustomAnim;
932 
933  struct
934  {
937  } jump;
938 
939  struct
940  {
941  uint32 withEmote;
942  } flee;
943 
944  struct
945  {
947  } RespawnTarget;
948 
949  struct
950  {
953  } MoveToPos;
954 
955  struct
956  {
959  } sendGossipMenu;
960 
961  struct
962  {
963  uint32 state;
964  } setGoLootState;
965 
966  struct
967  {
968  uint32 id;
969  } sendTargetToTarget;
970 
971  struct
972  {
973  uint32 distance;
974  uint32 angle;
975  } setRangedMovement;
976 
977  struct
978  {
980  } setHealthRegen;
981 
982  struct
983  {
985  } setRoot;
986 
987  struct
988  {
989  uint32 flag;
990  } goFlag;
991 
992  struct
993  {
995  uint32 attackInvoker;
996  } creatureGroup;
997 
998  struct
999  {
1002  } power;
1003 
1004  struct
1005  {
1006  uint32 id;
1007  } gameEventStop;
1008 
1009  struct
1010  {
1011  uint32 id;
1012  } gameEventStart;
1013 
1014  struct
1015  {
1022  } closestWaypointFromList;
1023 
1024  struct
1025  {
1026  uint32 sound[5];
1027  uint32 onlySelf;
1028  } randomSound;
1029 
1032 
1033  struct
1034  {
1035  uint32 param1;
1036  uint32 param2;
1037  uint32 param3;
1038  uint32 param4;
1039  uint32 param5;
1041  } raw;
1042  };
1043 };
1044 
1046 {
1047  SMARTAI_TEMPLATE_BASIC = 0, //nothing is preset
1048  SMARTAI_TEMPLATE_CASTER = 1, //spellid, repeatMin, repeatMax, range, manaPCT +JOIN: target_param1 as castFlag
1049  SMARTAI_TEMPLATE_TURRET = 2, //spellid, repeatMin, repeatMax +JOIN: target_param1 as castFlag
1051  SMARTAI_TEMPLATE_CAGED_GO_PART = 4, //creatureID, give credit at point end?,
1052  SMARTAI_TEMPLATE_CAGED_NPC_PART = 5, //gameObjectID, despawntime, run?, dist, TextGroupID
1054 };
1055 
1057 {
1058  SMART_TARGET_NONE = 0, // NONE, defaulting to invoket
1059  SMART_TARGET_SELF = 1, // Self cast
1060  SMART_TARGET_VICTIM = 2, // Our current target (ie: highest aggro)
1061  SMART_TARGET_HOSTILE_SECOND_AGGRO = 3, // Second highest aggro
1062  SMART_TARGET_HOSTILE_LAST_AGGRO = 4, // Dead last on aggro
1063  SMART_TARGET_HOSTILE_RANDOM = 5, // Just any random target on our threat list
1064  SMART_TARGET_HOSTILE_RANDOM_NOT_TOP = 6, // Any random target except top threat
1065  SMART_TARGET_ACTION_INVOKER = 7, // Unit who caused this Event to occur
1066  SMART_TARGET_POSITION = 8, // use xyz from event params
1067  SMART_TARGET_CREATURE_RANGE = 9, // CreatureEntry(0any), minDist, maxDist
1068  SMART_TARGET_CREATURE_GUID = 10, // guid, entry
1069  SMART_TARGET_CREATURE_DISTANCE = 11, // CreatureEntry(0any), maxDist
1070  SMART_TARGET_STORED = 12, // id, uses pre-stored target(list)
1071  SMART_TARGET_GAMEOBJECT_RANGE = 13, // entry(0any), min, max
1072  SMART_TARGET_GAMEOBJECT_GUID = 14, // guid, entry
1073  SMART_TARGET_GAMEOBJECT_DISTANCE = 15, // entry(0any), maxDist
1074  SMART_TARGET_INVOKER_PARTY = 16, // invoker's party members
1075  SMART_TARGET_PLAYER_RANGE = 17, // min, max
1077  SMART_TARGET_CLOSEST_CREATURE = 19, // CreatureEntry(0any), maxDist, dead?
1078  SMART_TARGET_CLOSEST_GAMEOBJECT = 20, // entry(0any), maxDist
1080  SMART_TARGET_ACTION_INVOKER_VEHICLE = 22, // Unit's vehicle who caused this Event to occur
1081  SMART_TARGET_OWNER_OR_SUMMONER = 23, // Unit's owner or summoner
1082  SMART_TARGET_THREAT_LIST = 24, // All units on creature's threat list
1083  SMART_TARGET_CLOSEST_ENEMY = 25, // maxDist, playerOnly
1084  SMART_TARGET_CLOSEST_FRIENDLY = 26, // maxDist, playerOnly
1085 
1087 };
1088 
1090 {
1092  {
1093  type = t;
1094  raw.param1 = p1;
1095  raw.param2 = p2;
1096  raw.param3 = p3;
1097  x = 0.0f;
1098  y = 0.0f;
1099  z = 0.0f;
1100  o = 0.0f;
1101  }
1103  float x, y, z, o;
1104  union
1105  {
1106  struct
1107  {
1111  } unitRange;
1112 
1113  struct
1114  {
1117  } unitGUID;
1118 
1119  struct
1120  {
1121  uint32 creature;
1123  } unitDistance;
1124 
1125  struct
1126  {
1127  uint32 dist;
1128  } playerDistance;
1129 
1130  struct
1131  {
1132  uint32 minDist;
1133  uint32 maxDist;
1134  } playerRange;
1135 
1136  struct
1137  {
1139  } stored;
1140 
1141  struct
1142  {
1143  uint32 entry;
1144  uint32 minDist;
1145  uint32 maxDist;
1146  } goRange;
1147 
1148  struct
1149  {
1150  uint32 dbGuid;
1151  uint32 entry;
1152  } goGUID;
1153 
1154  struct
1155  {
1156  uint32 entry;
1157  uint32 dist;
1158  } goDistance;
1159 
1160  struct
1161  {
1163  } position;
1164 
1165  struct
1166  {
1167  uint32 entry;
1168  uint32 dist;
1170  } closest;
1171 
1172  struct
1173  {
1174  uint32 maxDist;
1176  } closestAttackable;
1177 
1178  struct
1179  {
1180  uint32 maxDist;
1181  uint32 playerOnly;
1182  } closestFriendly;
1183 
1184  struct
1185  {
1189  } raw;
1190  };
1191 };
1192 
1194 {
1201 };
1202 
1204 {
1216 };
1217 
1219 {
1230 };
1231 
1233 {
1244 };
1245 
1247 {
1251  {SMART_EVENT_MANA_PCT, SMART_SCRIPT_TYPE_MASK_CREATURE },
1252  {SMART_EVENT_AGGRO, SMART_SCRIPT_TYPE_MASK_CREATURE },
1253  {SMART_EVENT_KILL, SMART_SCRIPT_TYPE_MASK_CREATURE },
1254  {SMART_EVENT_DEATH, SMART_SCRIPT_TYPE_MASK_CREATURE },
1255  {SMART_EVENT_EVADE, SMART_SCRIPT_TYPE_MASK_CREATURE },
1256  {SMART_EVENT_SPELLHIT, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1257  {SMART_EVENT_RANGE, SMART_SCRIPT_TYPE_MASK_CREATURE },
1258  {SMART_EVENT_OOC_LOS, SMART_SCRIPT_TYPE_MASK_CREATURE },
1259  {SMART_EVENT_RESPAWN, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1260  {SMART_EVENT_TARGET_HEALTH_PCT, SMART_SCRIPT_TYPE_MASK_CREATURE },
1261  {SMART_EVENT_VICTIM_CASTING, SMART_SCRIPT_TYPE_MASK_CREATURE },
1262  {SMART_EVENT_FRIENDLY_HEALTH, SMART_SCRIPT_TYPE_MASK_CREATURE },
1263  {SMART_EVENT_FRIENDLY_IS_CC, SMART_SCRIPT_TYPE_MASK_CREATURE },
1264  {SMART_EVENT_FRIENDLY_MISSING_BUFF, SMART_SCRIPT_TYPE_MASK_CREATURE },
1265  {SMART_EVENT_SUMMONED_UNIT, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1266  {SMART_EVENT_TARGET_MANA_PCT, SMART_SCRIPT_TYPE_MASK_CREATURE },
1267  {SMART_EVENT_ACCEPTED_QUEST, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1268  {SMART_EVENT_REWARD_QUEST, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1269  {SMART_EVENT_REACHED_HOME, SMART_SCRIPT_TYPE_MASK_CREATURE },
1270  {SMART_EVENT_RECEIVE_EMOTE, SMART_SCRIPT_TYPE_MASK_CREATURE },
1271  {SMART_EVENT_HAS_AURA, SMART_SCRIPT_TYPE_MASK_CREATURE },
1272  {SMART_EVENT_TARGET_BUFFED, SMART_SCRIPT_TYPE_MASK_CREATURE },
1273  {SMART_EVENT_RESET, SMART_SCRIPT_TYPE_MASK_CREATURE },
1274  {SMART_EVENT_IC_LOS, SMART_SCRIPT_TYPE_MASK_CREATURE },
1275  {SMART_EVENT_PASSENGER_BOARDED, SMART_SCRIPT_TYPE_MASK_CREATURE },
1276  {SMART_EVENT_PASSENGER_REMOVED, SMART_SCRIPT_TYPE_MASK_CREATURE },
1277  {SMART_EVENT_CHARMED, SMART_SCRIPT_TYPE_MASK_CREATURE },
1278  {SMART_EVENT_CHARMED_TARGET, SMART_SCRIPT_TYPE_MASK_CREATURE },
1279  {SMART_EVENT_SPELLHIT_TARGET, SMART_SCRIPT_TYPE_MASK_CREATURE },
1280  {SMART_EVENT_DAMAGED, SMART_SCRIPT_TYPE_MASK_CREATURE },
1281  {SMART_EVENT_DAMAGED_TARGET, SMART_SCRIPT_TYPE_MASK_CREATURE },
1282  {SMART_EVENT_MOVEMENTINFORM, SMART_SCRIPT_TYPE_MASK_CREATURE },
1283  {SMART_EVENT_SUMMON_DESPAWNED, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1284  {SMART_EVENT_CORPSE_REMOVED, SMART_SCRIPT_TYPE_MASK_CREATURE },
1285  {SMART_EVENT_AI_INIT, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1286  {SMART_EVENT_DATA_SET, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1287  {SMART_EVENT_WAYPOINT_START, SMART_SCRIPT_TYPE_MASK_CREATURE },
1288  {SMART_EVENT_WAYPOINT_REACHED, SMART_SCRIPT_TYPE_MASK_CREATURE },
1290  {SMART_EVENT_TRANSPORT_ADDCREATURE, SMART_SCRIPT_TYPE_MASK_TRANSPORT },
1291  {SMART_EVENT_TRANSPORT_REMOVE_PLAYER, SMART_SCRIPT_TYPE_MASK_TRANSPORT },
1292  {SMART_EVENT_TRANSPORT_RELOCATE, SMART_SCRIPT_TYPE_MASK_TRANSPORT },
1293  {SMART_EVENT_INSTANCE_PLAYER_ENTER, SMART_SCRIPT_TYPE_MASK_INSTANCE },
1296  {SMART_EVENT_QUEST_OBJ_COPLETETION, SMART_SCRIPT_TYPE_MASK_QUEST },
1297  {SMART_EVENT_QUEST_REWARDED, SMART_SCRIPT_TYPE_MASK_QUEST },
1298  {SMART_EVENT_QUEST_COMPLETION, SMART_SCRIPT_TYPE_MASK_QUEST },
1299  {SMART_EVENT_QUEST_FAIL, SMART_SCRIPT_TYPE_MASK_QUEST },
1300  {SMART_EVENT_TEXT_OVER, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1301  {SMART_EVENT_RECEIVE_HEAL, SMART_SCRIPT_TYPE_MASK_CREATURE },
1302  {SMART_EVENT_JUST_SUMMONED, SMART_SCRIPT_TYPE_MASK_CREATURE },
1303  {SMART_EVENT_WAYPOINT_PAUSED, SMART_SCRIPT_TYPE_MASK_CREATURE },
1304  {SMART_EVENT_WAYPOINT_RESUMED, SMART_SCRIPT_TYPE_MASK_CREATURE },
1305  {SMART_EVENT_WAYPOINT_STOPPED, SMART_SCRIPT_TYPE_MASK_CREATURE },
1306  {SMART_EVENT_WAYPOINT_ENDED, SMART_SCRIPT_TYPE_MASK_CREATURE },
1307  {SMART_EVENT_TIMED_EVENT_TRIGGERED, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1308  {SMART_EVENT_UPDATE, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1309  {SMART_EVENT_LINK, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT + SMART_SCRIPT_TYPE_MASK_AREATRIGGER + SMART_SCRIPT_TYPE_MASK_EVENT + SMART_SCRIPT_TYPE_MASK_GOSSIP + SMART_SCRIPT_TYPE_MASK_QUEST + SMART_SCRIPT_TYPE_MASK_SPELL + SMART_SCRIPT_TYPE_MASK_TRANSPORT + SMART_SCRIPT_TYPE_MASK_INSTANCE },
1310  {SMART_EVENT_GOSSIP_SELECT, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1311  {SMART_EVENT_JUST_CREATED, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1312  {SMART_EVENT_GOSSIP_HELLO, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1313  {SMART_EVENT_FOLLOW_COMPLETED, SMART_SCRIPT_TYPE_MASK_CREATURE },
1315  {SMART_EVENT_IS_BEHIND_TARGET, SMART_SCRIPT_TYPE_MASK_CREATURE },
1316  {SMART_EVENT_GAME_EVENT_START, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1317  {SMART_EVENT_GAME_EVENT_END, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1318  {SMART_EVENT_GO_STATE_CHANGED, SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1319  {SMART_EVENT_GO_EVENT_INFORM, SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
1320  {SMART_EVENT_ACTION_DONE, SMART_SCRIPT_TYPE_MASK_CREATURE },
1321  {SMART_EVENT_ON_SPELLCLICK, SMART_SCRIPT_TYPE_MASK_CREATURE },
1322  {SMART_EVENT_FRIENDLY_HEALTH_PCT, SMART_SCRIPT_TYPE_MASK_CREATURE },
1323  {SMART_EVENT_DISTANCE_CREATURE, SMART_SCRIPT_TYPE_MASK_CREATURE },
1324  {SMART_EVENT_DISTANCE_GAMEOBJECT, SMART_SCRIPT_TYPE_MASK_CREATURE },
1325  {SMART_EVENT_COUNTER_SET, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT }
1326 };
1327 
1329 {
1330  SMART_EVENT_FLAG_NOT_REPEATABLE = 0x001, //Event can not repeat
1331  SMART_EVENT_FLAG_DIFFICULTY_0 = 0x002, //Event only occurs in instance difficulty 0
1332  SMART_EVENT_FLAG_DIFFICULTY_1 = 0x004, //Event only occurs in instance difficulty 1
1333  SMART_EVENT_FLAG_DIFFICULTY_2 = 0x008, //Event only occurs in instance difficulty 2
1334  SMART_EVENT_FLAG_DIFFICULTY_3 = 0x010, //Event only occurs in instance difficulty 3
1337  SMART_EVENT_FLAG_DEBUG_ONLY = 0x080, //Event only occurs in debug build
1338  SMART_EVENT_FLAG_DONT_RESET = 0x100, //Event will not reset in SmartScript::OnReset()
1339 
1342 };
1343 
1345 {
1346  SMARTCAST_INTERRUPT_PREVIOUS = 0x01, //Interrupt any spell casting
1347  SMARTCAST_TRIGGERED = 0x02, //Triggered (this makes spell cost zero mana and have no cast time)
1348  //SMARTCAST_FORCE_CAST = 0x04, //Forces cast even if creature is out of mana or out of range
1349  //SMARTCAST_NO_MELEE_IF_OOM = 0x08, //Prevents creature from entering melee if out of mana or out of range
1350  //SMARTCAST_FORCE_TARGET_SELF = 0x10, //Forces the target to cast this spell on itself
1351  SMARTCAST_AURA_NOT_PRESENT = 0x20, //Only casts the spell if the target does not have an aura from the spell
1352  SMARTCAST_COMBAT_MOVE = 0x40 //Prevents combat movement if cast successful. Allows movement on range, OOM, LOS
1353 };
1354 
1355 // one line in DB is one event
1357 {
1358  SmartScriptHolder() : entryOrGuid(0), source_type(SMART_SCRIPT_TYPE_CREATURE)
1359  , event_id(0), link(0), event(), action(), target(), timer(0), active(false), runOnce(false)
1360  , enableTimed(false) { }
1361 
1366 
1370 
1371  uint32 GetScriptType() const { return (uint32)source_type; }
1372  uint32 GetEventType() const { return (uint32)event.type; }
1373  uint32 GetActionType() const { return (uint32)action.type; }
1374  uint32 GetTargetType() const { return (uint32)target.type; }
1375 
1377  bool active;
1378  bool runOnce;
1380 
1381  operator bool() const { return entryOrGuid != 0; }
1382 };
1383 
1384 typedef UNORDERED_MAP<uint32, WayPoint*> WPPath;
1385 
1386 typedef std::list<WorldObject*> ObjectList;
1387 
1389 {
1390  ObjectList* m_objectList;
1393 
1394 public:
1395  ObjectGuidList(ObjectList* objectList, WorldObject* baseObject)
1396  {
1397  ASSERT(objectList != NULL);
1398  m_objectList = objectList;
1399  m_baseObject = baseObject;
1400  m_guidList = new GuidList();
1401 
1402  for (ObjectList::iterator itr = objectList->begin(); itr != objectList->end(); ++itr)
1403  {
1404  m_guidList->push_back((*itr)->GetGUID());
1405  }
1406  }
1407 
1408  ObjectList* GetObjectList()
1409  {
1410  if (m_baseObject)
1411  {
1412  //sanitize list using m_guidList
1413  m_objectList->clear();
1414 
1415  for (GuidList::iterator itr = m_guidList->begin(); itr != m_guidList->end(); ++itr)
1416  {
1417  if (WorldObject* obj = ObjectAccessor::GetWorldObject(*m_baseObject, itr->GetRawValue()))
1418  m_objectList->push_back(obj);
1419  else
1420  sLog.outError("SmartScript::mTargetStorage stores a guid to an invalid object: %s", itr->GetString().c_str());
1421  }
1422  }
1423 
1424  return m_objectList;
1425  }
1426 
1427  bool Equals(ObjectList* objectList)
1428  {
1429  return m_objectList == objectList;
1430  }
1431 
1433  {
1434  delete m_objectList;
1435  delete m_guidList;
1436  }
1437 };
1438 typedef UNORDERED_MAP<uint32, ObjectGuidList*> ObjectListMap;
1439 
1441 {
1442  private:
1444  ~SmartWaypointMgr();
1445 
1446  public:
1448  {
1449  static SmartWaypointMgr instance;
1450  return &instance;
1451  }
1452 
1453  void LoadFromDB();
1454 
1455  WPPath* GetPath(uint32 id)
1456  {
1457  if (waypoint_map.find(id) != waypoint_map.end())
1458  return waypoint_map[id];
1459  else return nullptr;
1460  }
1461 
1462  private:
1463  UNORDERED_MAP<uint32, WPPath*> waypoint_map;
1464 };
1465 
1466 // all events for a single entry
1467 typedef std::vector<SmartScriptHolder> SmartAIEventList;
1468 
1469 // all events for all entries / guids
1470 typedef UNORDERED_MAP<int32, SmartAIEventList> SmartAIEventMap;
1471 
1472 // Helper Stores
1473 typedef std::map<uint32 /*entry*/, std::pair<uint32 /*spellId*/, SpellEffIndex /*effIndex*/> > CacheSpellContainer;
1474 typedef std::pair<CacheSpellContainer::const_iterator, CacheSpellContainer::const_iterator> CacheSpellContainerBounds;
1475 
1477 {
1478  private:
1481 
1482  public:
1484  {
1485  static SmartAIMgr instance;
1486  return &instance;
1487  }
1488 
1489  void LoadSmartAIFromDB();
1490 
1491  SmartAIEventList GetScript(int32 entry, SmartScriptType type)
1492  {
1493  SmartAIEventList temp;
1494  if (mEventMap[uint32(type)].find(entry) != mEventMap[uint32(type)].end())
1495  return mEventMap[uint32(type)][entry];
1496  else
1497  {
1498  if (entry > 0)//first search is for guid (negative), do not drop error if not found
1499  sLog.outError("SmartAIMgr::GetScript: Could not load Script for Entry %d ScriptType %u.", entry, uint32(type));
1500  return temp;
1501  }
1502  }
1503 
1504  static SmartScriptHolder& FindLinkedSourceEvent(SmartAIEventList& list, uint32 eventId)
1505  {
1506  SmartAIEventList::iterator itr = std::find_if(list.begin(), list.end(),
1507  [eventId](SmartScriptHolder& source) { return source.link == eventId; });
1508 
1509  if (itr != list.end())
1510  return *itr;
1511 
1512  static SmartScriptHolder SmartScriptHolderDummy;
1513  return SmartScriptHolderDummy;
1514  }
1515 
1516  static SmartScriptHolder& FindLinkedEvent(SmartAIEventList& list, uint32 link)
1517  {
1518  SmartAIEventList::iterator itr = std::find_if(list.begin(), list.end(),
1519  [link](SmartScriptHolder& linked) { return linked.event_id == link && linked.GetEventType() == SMART_EVENT_LINK; });
1520 
1521  if (itr != list.end())
1522  return *itr;
1523 
1524  static SmartScriptHolder SmartScriptHolderDummy;
1525  return SmartScriptHolderDummy;
1526  }
1527 
1528  private:
1529  //event stores
1530  SmartAIEventMap mEventMap[SMART_SCRIPT_TYPE_MAX];
1531 
1532  bool IsEventValid(SmartScriptHolder& e);
1533  bool IsTargetValid(SmartScriptHolder const& e);
1534 
1535  bool IsMinMaxValid(SmartScriptHolder const& e, uint32 min, uint32 max)
1536  {
1537  if (max < min)
1538  {
1539  sLog.outError("SmartAIMgr: Entry %d 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);
1540  return false;
1541  }
1542  return true;
1543  }
1544 
1545  /*inline bool IsPercentValid(SmartScriptHolder e, int32 pct)
1546  {
1547  if (pct < -100 || pct > 100)
1548  {
1549  TC_LOG_ERROR("SmartAIMgr: Entry %d SourceType %u Event %u Action %u has invalid Percent set (%d), skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), pct);
1550  return false;
1551  }
1552  return true;
1553  }*/
1554 
1555  bool NotNULL(SmartScriptHolder const& e, uint32 data)
1556  {
1557  if (!data)
1558  {
1559  sLog.outError("SmartAIMgr: Entry %d SourceType %u Event %u Action %u Parameter can not be NULL, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
1560  return false;
1561  }
1562  return true;
1563  }
1564 
1565  bool IsCreatureValid(SmartScriptHolder const& e, uint32 entry)
1566  {
1567  if (!sObjectMgr.GetCreatureTemplate(entry))
1568  {
1569  sLog.outError("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Creature entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1570  return false;
1571  }
1572  return true;
1573  }
1574 
1575  bool IsQuestValid(SmartScriptHolder const& e, uint32 entry)
1576  {
1577  if (!sObjectMgr.GetQuestTemplate(entry))
1578  {
1579  sLog.outError("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Quest entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1580  return false;
1581  }
1582  return true;
1583  }
1584 
1585  bool IsGameObjectValid(SmartScriptHolder const& e, uint32 entry)
1586  {
1587  if (!sObjectMgr.GetGameObjectInfo(entry))
1588  {
1589  sLog.outError("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent GameObject entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1590  return false;
1591  }
1592  return true;
1593  }
1594 
1595  bool IsSpellValid(SmartScriptHolder const& e, uint32 entry)
1596  {
1597  if (!sSpellStore.LookupEntry(entry))
1598  {
1599  sLog.outError("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Spell entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1600  return false;
1601  }
1602  return true;
1603  }
1604 
1605  bool IsItemValid(SmartScriptHolder const& e, uint32 entry)
1606  {
1607  if (!sItemStore.LookupEntry(entry))
1608  {
1609  sLog.outError("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Item entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1610  return false;
1611  }
1612  return true;
1613  }
1614 
1615  bool IsTextEmoteValid(SmartScriptHolder const& e, uint32 entry)
1616  {
1617  if (!sEmotesTextStore.LookupEntry(entry))
1618  {
1619  sLog.outError("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Text Emote entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1620  return false;
1621  }
1622  return true;
1623  }
1624 
1625  bool IsEmoteValid(SmartScriptHolder const& e, uint32 entry)
1626  {
1627  if (!sEmotesStore.LookupEntry(entry))
1628  {
1629  sLog.outError("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Emote entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1630  return false;
1631  }
1632  return true;
1633  }
1634 
1635  bool IsAreaTriggerValid(SmartScriptHolder const& e, uint32 entry)
1636  {
1637  if (!sAreaTriggerStore.LookupEntry(entry))
1638  {
1639  sLog.outError("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent AreaTrigger entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1640  return false;
1641  }
1642  return true;
1643  }
1644 
1645  bool IsSoundValid(SmartScriptHolder const& e, uint32 entry)
1646  {
1647  if (!sSoundEntriesStore.LookupEntry(entry))
1648  {
1649  sLog.outError("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Sound entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
1650  return false;
1651  }
1652  return true;
1653  }
1654 
1655  bool IsTextValid(SmartScriptHolder const& e, uint32 id);
1656 
1657  // Helpers
1658  void LoadHelperStores();
1659  void UnLoadHelperStores();
1660 
1661  CacheSpellContainerBounds GetSummonCreatureSpellContainerBounds(uint32 creatureEntry) const;
1662  CacheSpellContainerBounds GetSummonGameObjectSpellContainerBounds(uint32 gameObjectEntry) const;
1663  CacheSpellContainerBounds GetKillCreditSpellContainerBounds(uint32 killCredit) const;
1664  CacheSpellContainerBounds GetCreateItemSpellContainerBounds(uint32 itemId) const;
1665 
1666  CacheSpellContainer SummonCreatureSpellStore;
1667  CacheSpellContainer SummonGameObjectSpellStore;
1668  CacheSpellContainer KillCreditSpellStore;
1669  CacheSpellContainer CreateItemSpellStore;
1670 };
1671 
1672 #define sSmartScriptMgr SmartAIMgr::instance()
1673 #define sSmartWaypointMgr SmartWaypointMgr::instance()
1674 #endif
bool Equals(ObjectList *objectList)
SmartScriptType
const uint32 SmartAITypeMask[SMART_SCRIPT_TYPE_MAX][2]
uint32 event_phase_mask
SmartEventFlags
uint32 gossipNpcTextId
uint32 goRespawnTime
static WorldObject * GetWorldObject(WorldObject const &, uint64)
uint32 textGroupID
SMART_EVENT_PHASE_BITS
uint32 reactState
DBCStorage< EmotesEntry > sEmotesStore(EmotesEntryfmt)
SMARTAI_TARGETS type
UNORDERED_MAP< uint32, WPPath * > waypoint_map
bool IsCreatureValid(SmartScriptHolder const &e, uint32 entry)
UNORDERED_MAP< int32, SmartAIEventList > SmartAIEventMap
uint32 cooldownMin
uint32 maxHpPct
uint32 playerOnly
bool IsSoundValid(SmartScriptHolder const &e, uint32 entry)
uint32 effIndex
std::vector< SmartScriptHolder > SmartAIEventList
uint32 useTalkTarget
uint32 creatureEntry
WorldObject * m_baseObject
uint32 timerType
static SmartWaypointMgr * instance()
uint32 withDelayed
uint32 GetEventType() const
#define sLog
Log class singleton.
Definition: Log.h:187
uint32 hpDeficit
ACE_INT32 int32
Definition: Define.h:67
NULL Dbg ErrDB Arena Chat Char Map MMap false
Definition: Log.cpp:556
SmartAIEventList GetScript(int32 entry, SmartScriptType type)
SMART_ACTION
CacheSpellContainer CreateItemSpellStore
DBCStorage< AreaTriggerEntry > sAreaTriggerStore(AreaTriggerEntryfmt)
SMARTAI_TEMPLATE
const uint32 SmartAIEventMask[SMART_EVENT_END][2]
CacheSpellContainer SummonGameObjectSpellStore
uint32 regenHealth
uint32 repeatMax
CacheSpellContainer SummonCreatureSpellStore
uint32 maxDist
uint32 threatINC
const uint32 SmartPhaseMask[SMART_EVENT_PHASE_COUNT][2]
uint32 event_flags
uint32 cooldownMax
#define sObjectMgr
Definition: ObjectMgr.h:1285
ObjectGuidList(ObjectList *objectList, WorldObject *baseObject)
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)
std::list< ObjectGuid > GuidList
Definition: ObjectGuid.h:281
uint32 id
std::list< WorldObject * > ObjectList
bool IsEmoteValid(SmartScriptHolder const &e, uint32 entry)
uint32 spellId
static SmartAIMgr * instance()
uint32 factionID
std::pair< CacheSpellContainer::const_iterator, CacheSpellContainer::const_iterator > CacheSpellContainerBounds
UNORDERED_MAP< uint32, ObjectGuidList * > ObjectListMap
ObjectList * GetObjectList()
bool IsAreaTriggerValid(SmartScriptHolder const &e, uint32 entry)
uint32 targetParam2
ObjectList * m_objectList
uint32 repeatMin
bool IsTextEmoteValid(SmartScriptHolder const &e, uint32 entry)
GuidList * m_guidList
uint32 textGroupID
std::map< uint32, std::pair< uint32, SpellEffIndex > > CacheSpellContainer
SpellEffIndex
Definition: SharedDefines.h:24
DBCStorage< ItemEntry > sItemStore(Itemfmt)
etc mysql my cnf *Then change max_allowed_packet to a bigger value
bool IsSpellValid(SmartScriptHolder const &e, uint32 entry)
SMART_EVENT
uint32 gameEventId
bool NotNULL(SmartScriptHolder const &e, uint32 data)
uint32 gossipMenuId
SMART_EVENT type
uint32 transport
uint32 targetParam3
uint32 creature
uint32 creditType
DBCStorage< SoundEntriesEntry > sSoundEntriesStore(SoundEntriesfmt)
uint32 repeatMax
bool IsItemValid(SmartScriptHolder const &e, uint32 entry)
uint32 repeatMin
SmartTarget(SMARTAI_TARGETS t=SMART_TARGET_NONE, uint32 p1=0, uint32 p2=0, uint32 p3=0)
uint32 noHostile
CacheSpellContainer KillCreditSpellStore
UNORDERED_MAP< uint32, WayPoint * > WPPath
uint32 GetActionType() const
uint32 GetScriptType() const
static SmartScriptHolder & FindLinkedSourceEvent(SmartAIEventList &list, uint32 eventId)
uint32 targetType
uint32 threatDEC
#define ASSERT
Definition: Errors.h:29
eSmartAI
SmartScriptType source_type
uint32 pointID
uint32 minHpPct
uint32 GetTargetType() const
uint32 counterId
WPPath * GetPath(uint32 id)
uint32 event_chance
bool IsGameObjectValid(SmartScriptHolder const &e, uint32 entry)
uint32 targetParam1
SmartAITypeMaskId
SmartCastFlags
ACE_UINT32 uint32
Definition: Define.h:71
uint32 eventId
SMART_SCRIPT_RESPAWN_CONDITION
DBCStorage< EmotesTextEntry > sEmotesTextStore(EmotesTextEntryfmt)
WayPoint(uint32 _id, float _x, float _y, float _z)
uint32 withInstant
uint32 despawnTime
uint32 attackInvoker
uint32 withEmote
SMARTAI_TARGETS
SMART_EVENT_PHASE
bool IsQuestValid(SmartScriptHolder const &e, uint32 entry)
SMART_ACTION type
bool IsMinMaxValid(SmartScriptHolder const &e, uint32 min, uint32 max)
static SmartScriptHolder & FindLinkedEvent(SmartAIEventList &list, uint32 link)