85 if (!smart && !silent)
100 if (!smart && !silent)
127 itr->second.AddGuid(obj->GetGUID());
134 return itr->second.GetObjectVector(ref);
144 itr->second += value;
165 if (bounds.first == bounds.second)
168 return bounds.first->second;
174 if (bounds.first == bounds.second)
177 auto creatureItr = std::find_if(bounds.first, bounds.second, [](Map::CreatureBySpawnIdContainer::value_type
const& pair)
179 return pair.second->IsAlive();
182 return creatureItr != bounds.second ? creatureItr->second : bounds.first->second;
193 event.runOnce =
false;
247 TC_LOG_WARN(
"scripts.ai",
"SmartScript::ProcessEventsFor: reached the limit of max allowed nested ProcessEventsFor() calls with event {}, skipping!\n{}", e,
GetBaseObject()->
GetDebugInfo());
284 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction: Invoker: {} {}", tempInvoker->GetName(), tempInvoker->GetGUID().ToString());
287 GetTargets(targets, e, Coalesce<WorldObject>(unit, gob));
294 Unit* talkTarget =
nullptr;
298 if (
IsCreature(target) && !target->ToCreature()->IsPet())
328 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction: SMART_ACTION_TALK: talker: {} {}, textGuid: {}",
341 sCreatureTextMgr->SendChat(
me,
uint8(e.
action.
simpleTalk.
textGroupID),
IsPlayer(templastInvoker) ? templastInvoker :
nullptr,
CHAT_MSG_ADDON,
LANG_ADDON,
TEXT_RANGE_NORMAL, 0,
SoundKitPlayType::Normal,
TEAM_OTHER,
false, target->ToPlayer());
343 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_SIMPLE_TALK: talker: {} {}, textGroupId: {}",
354 target->ToUnit()->HandleEmoteCommand(
static_cast<Emote>(e.
action.
emote.emote));
355 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_PLAY_EMOTE: target: {} {}, emote: {}",
356 target->GetName(), target->GetGUID().ToString(), e.
action.
emote.emote);
372 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: {} {}, sound: {}, onlyself: {}",
387 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature {} set faction to {}",
394 if (target->ToCreature()->GetFaction() != ci->faction)
396 target->ToCreature()->SetFaction(ci->faction);
397 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature {} set faction to {}",
398 target->GetGUID().ToString(), ci->faction);
422 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature {} set displayid to {}",
430 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature {} set displayid to {}",
436 target->ToCreature()->DeMorph();
437 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature {} demorphs.",
438 target->GetGUID().ToString());
449 target->ToPlayer()->FailQuest(e.
action.
quest.quest);
450 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_FAIL_QUEST: Player {} fails quest {}",
451 target->GetGUID().ToString(), e.
action.
quest.quest);
479 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player {} - quest {} added",
500 std::vector<uint32> emotes;
502 std::back_inserter(emotes), [](
uint32 emote) { return emote != 0; });
509 target->ToUnit()->HandleEmoteCommand(emote);
510 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_RANDOM_EMOTE: Creature {} handle random emote {}",
511 target->GetGUID().ToString(), emote);
524 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_THREAT_ALL_PCT: Creature {} modify threat for unit {}, value {}",
539 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_THREAT_SINGLE_PCT: Creature {} modify threat for unit {}, value {}",
551 if (
Vehicle* vehicle = target->ToUnit()->GetVehicleKit())
552 for (std::pair<int8 const, VehicleSeat>& seat : vehicle->Seats)
558 target->ToPlayer()->AreaExploredOrEventHappens(e.
action.
quest.quest);
560 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS: Player {} credited quest {}",
561 target->GetGUID().ToString(), e.
action.
quest.quest);
574 bool failedSpellCast =
false, successfulSpellCast =
false;
611 failedSpellCast =
true;
613 successfulSpellCast =
true;
618 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_CAST:: {} casts spell {} on target {} with castflags {}",
622 TC_LOG_DEBUG(
"scripts.ai",
"Spell {} not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target ({}) already has the aura", e.
action.
cast.
spell, target->GetGUID().ToString());
626 if (failedSpellCast && !successfulSpellCast)
670 if (!tempLastInvoker)
699 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_INVOKER_CAST: Invoker {} casts spell {} on target {} with castflags {}",
703 TC_LOG_DEBUG(
"scripts.ai",
"Spell {} not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target ({}) already has the aura", e.
action.
cast.
spell, target->GetGUID().ToString());
714 target->ToGameObject()->SetLootState(
GO_READY);
715 target->ToGameObject()->UseDoorOrButton(0,
false, unit);
716 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_ACTIVATE_GOBJECT. Gameobject {} activated",
717 target->GetGUID().ToString());
728 target->ToGameObject()->ResetDoorOrButton();
729 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_RESET_GOBJECT. Gameobject {} reset",
730 target->GetGUID().ToString());
742 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_SET_EMOTE_STATE. Unit {} set emotestate to {}",
743 target->GetGUID().ToString(), e.
action.
emote.emote);
751 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_AUTO_ATTACK: Creature: {} bool on = {}",
762 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_ALLOW_COMBAT_MOVEMENT: Creature {} bool on = {}",
772 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_SET_EVENT_PHASE: Creature {} set event phase {}",
783 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_INC_EVENT_PHASE: Creature {} inc event phase by {}, "
795 float homeX, homeY, homeZ, homeO;
816 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_FLEE_FOR_ASSIST: Creature {} DoFleeToGetAssistance",
me->
GetGUID().
ToString());
829 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction: SMART_ACTION_CALL_GROUPEVENTHAPPENS: Player {}, group credit for quest {}",
835 for (std::pair<int8 const, VehicleSeat>& seat : vehicle->Seats)
875 target->ToUnit()->RemoveAllAuras();
877 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction: SMART_ACTION_REMOVEAURASFROMSPELL: Unit {}, spell {}",
899 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction: SMART_ACTION_FOLLOW: Creature {} following target {}",
911 std::vector<uint32> phases;
913 std::back_inserter(phases), [](
uint32 phase) { return phase != 0; });
917 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE: Creature {} sets event phase to {}",
928 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE_RANGE: Creature {} sets event phase to {}",
944 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player {}, Killcredit: {}",
956 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player {}, Killcredit: {}",
960 if (
Vehicle* vehicle = target->ToUnit()->GetVehicleKit())
961 for (std::pair<int8 const, VehicleSeat>& seat : vehicle->Seats)
988 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA: SetData Field: {}, data: {}",
993 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA: SetBossState BossId: {}, State: {} ({})",
1017 if (targets.empty())
1021 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA64: Field: {}, data: {}",
1069 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction: SMART_ACTION_SET_SHEATH: Creature {}, State: {}",
1078 if (despawnDelay <= 0ms)
1086 creature->DespawnOrUnsummon(despawnDelay, forceRespawnTimer);
1088 goTarget->DespawnOrUnsummon(despawnDelay, forceRespawnTimer);
1132 target->ToUnit()->Dismount();
1181 unitTarget->AttackStop();
1224 if (targets.empty())
1248 target->GetPosition(x, y, z, o);
1253 for (
uint32 counter = 0; counter < spawnsCount; counter++)
1257 summon->AI()->AttackStart(target->ToUnit());
1264 for (
uint32 counter = 0; counter < spawnsCount; counter++)
1268 summon->AI()->AttackStart(unit);
1299 target->ToUnit()->KillSelf();
1359 if (!targets.empty())
1368 TC_LOG_ERROR(
"sql.sql",
"SmartScript: Action target for SMART_ACTION_SET_COUNTER is not using SmartAI, skipping");
1375 TC_LOG_ERROR(
"sql.sql",
"SmartScript: Action target for SMART_ACTION_SET_COUNTER is not using SmartGameObjectAI, skipping");
1447 else if (!targets.empty())
1470 if (!targets.empty())
1498 TC_LOG_WARN(
"sql.sql",
"Invalid creature target '{}' (entry {}, spawnId {}) specified for SMART_ACTION_ENABLE_TEMP_GOBJ", target->GetName(), target->GetEntry(), target->ToCreature()->GetSpawnId());
1501 if (target->ToGameObject()->isSpawnedByDefault())
1502 TC_LOG_WARN(
"sql.sql",
"Invalid gameobject target '{}' (entry {}, spawnId {}) for SMART_ACTION_ENABLE_TEMP_GOBJ - the object is spawned by default", target->GetName(), target->GetEntry(), target->ToGameObject()->GetSpawnId());
1513 target->ToPlayer()->PlayerTalkClass->SendCloseGossip();
1522 std::array<EquipmentItem, MAX_EQUIPMENT_ITEMS> slot;
1528 TC_LOG_ERROR(
"sql.sql",
"SmartScript: SMART_ACTION_EQUIP uses non-existent equipment info id {} for creature {}", equipId, npc->GetEntry());
1532 npc->SetCurrentEquipmentId(equipId);
1534 std::copy(std::begin(eInfo->
Items), std::end(eInfo->
Items), std::begin(slot));
1545 npc->SetVirtualItem(i, slot[i].
ItemId, slot[i].AppearanceModId, slot[i].ItemVisual);
1610 if (
IsSmart(creature) && creature->GetVictim())
1612 creature->StartDefaultCombatMovement(creature->GetVictim(), attackDistance, attackAngle);
1666 if (targets.empty())
1670 GetTargets(casters,
CreateSmartEvent(
SMART_EVENT_UPDATE_IC, 0, 0, 0, 0, 0, 0,
SMART_ACTION_NONE, 0, 0, 0, 0, 0, 0, 0, (
SMARTAI_TARGETS)e.
action.
crossCast.
targetType, e.
action.
crossCast.
targetParam1, e.
action.
crossCast.
targetParam2, e.
action.
crossCast.
targetParam3, 0, 0), unit);
1679 bool interruptedSpell =
false;
1691 interruptedSpell =
true;
1697 TC_LOG_DEBUG(
"scripts.ai",
"Spell {} not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target ({}) already has the aura", e.
action.
crossCast.
spell, target->GetGUID().ToString());
1704 std::vector<uint32> actionLists;
1706 std::back_inserter(actionLists), [](
uint32 actionList) { return actionList != 0; });
1764 target->ToPlayer()->ActivateTaxiPathTo(e.
action.
taxi.
id);
1769 bool foundTarget =
false;
1780 target->ToCreature()->GetMotionMaster()->MoveIdle();
1850 if (!targets.empty())
1909 TC_LOG_ERROR(
"sql.sql",
"SmartScript: Action target for SMART_ACTION_SEND_TARGET_TO_TARGET is not using SmartAI, skipping");
1916 TC_LOG_ERROR(
"sql.sql",
"SmartScript: Action target for SMART_ACTION_SEND_TARGET_TO_TARGET is not using SmartGameObjectAI, skipping");
1926 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_SEND_GOSSIP_MENU: gossipMenuId {}, gossipNpcTextId {}",
1945 if (!gossipNpcTextId)
1971 target->ToCreature()->SetHomePosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation());
1974 TC_LOG_ERROR(
"sql.sql",
"SmartScript: Action target for SMART_ACTION_SET_HOME_POS is invalid, skipping");
1995 std::list<TempSummon*> summonList;
2000 summon->AI()->AttackStart(unit);
2029 TC_LOG_ERROR(
"sql.sql",
"SmartScript::ProcessAction: At case SMART_ACTION_GAME_EVENT_STOP, inactive event (id: {})", eventId);
2040 TC_LOG_ERROR(
"sql.sql",
"SmartScript::ProcessAction: At case SMART_ACTION_GAME_EVENT_START, already activated event (id: {})", eventId);
2048 std::vector<uint32> waypoints;
2050 std::back_inserter(waypoints), [](
uint32 wp) { return wp != 0; });
2052 float distanceToClosest = std::numeric_limits<float>::max();
2053 std::pair<uint32, uint32> closest = { 0, 0 };
2061 for (
uint32 pathId : waypoints)
2064 if (!path || path->
Nodes.empty())
2070 if (distanceToThisNode < distanceToClosest)
2072 distanceToClosest = distanceToThisNode;
2073 closest.first = pathId;
2079 if (closest.first != 0)
2080 ENSURE_AI(
SmartAI, creature->AI())->StartPath(closest.first,
true,
nullptr, closest.second);
2088 std::vector<uint32> sounds;
2090 std::back_inserter(sounds), [](
uint32 sound) { return sound != 0; });
2100 target->PlayDistanceSound(sound, onlySelf ? target->ToPlayer() :
nullptr);
2102 target->PlayDirectSound(sound, onlySelf ? target->ToPlayer() :
nullptr);
2104 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_RANDOM_SOUND: target: {} ({}), sound: {}, onlyself: {}",
2105 target->GetName(), target->GetGUID().ToString(), sound, onlySelf ?
"true" :
"false");
2246 map = obj->GetMap();
2247 else if (!targets.empty())
2248 map = targets.front()->GetMap();
2263 target->ToCreature()->PlayOneShotAnimKitId(e.
action.
animKit.animKit);
2265 target->ToCreature()->SetAIAnimKitId(e.
action.
animKit.animKit);
2267 target->ToCreature()->SetMeleeAnimKitId(e.
action.
animKit.animKit);
2269 target->ToCreature()->SetMovementAnimKitId(e.
action.
animKit.animKit);
2271 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_PLAY_ANIMKIT: target: {} ({}), AnimKit: {}, Type: {}",
2279 target->ToGameObject()->SetAnimKitId(e.
action.
animKit.animKit,
true);
2282 target->ToGameObject()->SetAnimKitId(e.
action.
animKit.animKit,
false);
2288 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_PLAY_ANIMKIT: target: {} ({}), AnimKit: {}, Type: {}",
2326 float speed = float(speedInteger) + float(speedFraction) / std::pow(10, std::floor(std::log10(
float(speedFraction ? speedFraction : 1)) + 1));
2343 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_PLAY_SPELL_VISUAL_KIT: target: {} ({}), SpellVisualKit: {}",
2355 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction: SMART_ACTION_OVERRIDE_LIGHT: {} sets zone override light (zoneId: {}, areaLightId: {}, overrideLightId: {}, transitionMilliseconds: {})",
2365 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript::ProcessAction: SMART_ACTION_OVERRIDE_WEATHER: {} sets zone weather (zoneId: {}, weatherId: {}, intensity: {})",
2393 *playerTarget, playerTarget->GetGUID(),
nullptr);
2395 TC_LOG_WARN(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_CREATE_CONVERSATION: id {}, baseObject {}, target {} - failed to create conversation",
2454 if (!targets.empty())
2459 TC_LOG_WARN(
"scripts.ai",
"SmartScript::ProcessAction:: SMART_ACTION_ADD_TO_STORED_TARGET_LIST: var {}, baseObject {}, event {} - tried to add no targets to stored target list",
2468 auto doCreatePersonalClone = [&](
Position const& position,
Player* privateObjectOwner)
2480 doCreatePersonalClone(baseObject->
GetPosition(), playerTarget);
2511 if (unitTarget->GetAI())
2532 ProcessEvent(linked, unit, var0, var1, bvar, spell, gob, varString);
2544 ProcessAction(e, unit, var0, var1, bvar, spell, gob, varString);
2547 RecalcTimer(e, std::min<uint32>(min, 5000), std::min<uint32>(min, 5000));
2550SmartScriptHolder SmartScript::CreateSmartEvent(
SMART_EVENT e,
uint32 event_flags,
uint32 event_param1,
uint32 event_param2,
uint32 event_param3,
uint32 event_param4,
uint32 event_param5,
SMART_ACTION action,
uint32 action_param1,
uint32 action_param2,
uint32 action_param3,
uint32 action_param4,
uint32 action_param5,
uint32 action_param6,
uint32 action_param7,
SMARTAI_TARGETS t,
uint32 target_param1,
uint32 target_param2,
uint32 target_param3,
uint32 target_param4,
uint32 phaseMask)
2587 scriptTrigger = invoker;
2589 scriptTrigger = tempLastInvoker;
2596 targets.push_back(baseObject);
2601 targets.push_back(victim);
2609 targets.push_back(u);
2612 targets.push_back(u);
2621 targets.push_back(u);
2624 targets.push_back(u);
2633 targets.push_back(u);
2636 targets.push_back(u);
2645 targets.push_back(u);
2648 targets.push_back(u);
2655 targets.push_back(u);
2660 targets.push_back(scriptTrigger);
2673 for (
GroupReference* groupRef = group->GetFirstMember(); groupRef !=
nullptr; groupRef = groupRef->
next())
2674 if (
Player* member = groupRef->GetSource())
2675 if (member->IsInMap(
player))
2676 targets.push_back(member);
2682 targets.push_back(scriptTrigger);
2690 ref = scriptTrigger;
2694 TC_LOG_ERROR(
"sql.sql",
"SMART_TARGET_CREATURE_RANGE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
2711 targets.push_back(unit);
2732 targets.push_back(unit);
2753 targets.push_back(unit);
2764 ref = scriptTrigger;
2768 TC_LOG_ERROR(
"sql.sql",
"SMART_TARGET_GAMEOBJECT_RANGE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
2785 targets.push_back(unit);
2794 if (!scriptTrigger && !baseObject)
2796 TC_LOG_ERROR(
"sql.sql",
"SMART_TARGET_CREATURE_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
2803 targets.push_back(target);
2808 if (!scriptTrigger && !baseObject)
2810 TC_LOG_ERROR(
"sql.sql",
"SMART_TARGET_GAMEOBJECT_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
2817 targets.push_back(target);
2825 if (!units.empty() && baseObject)
2828 targets.push_back(unit);
2838 targets.push_back(unit);
2845 ref = scriptTrigger;
2849 TC_LOG_ERROR(
"sql.sql",
"SMART_TARGET_STORED: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
2855 targets.assign(stored->begin(), stored->end());
2862 ref = scriptTrigger;
2866 TC_LOG_ERROR(
"sql.sql",
"SMART_TARGET_CLOSEST_CREATURE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
2872 targets.push_back(target);
2879 ref = scriptTrigger;
2883 TC_LOG_ERROR(
"sql.sql",
"SMART_TARGET_CLOSEST_GAMEOBJECT: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
2889 targets.push_back(target);
2896 ref = scriptTrigger;
2900 TC_LOG_ERROR(
"sql.sql",
"SMART_TARGET_CLOSEST_PLAYER: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
2906 targets.push_back(target);
2915 if (!charmerOrOwnerGuid)
2917 if (
WorldObject* summoner = tempSummon->GetSummoner())
2918 charmerOrOwnerGuid = summoner->GetGUID();
2920 if (!charmerOrOwnerGuid)
2924 targets.push_back(owner);
2929 targets.push_back(owner);
2939 targets.push_back(base);
2948 targets.push_back(ref->GetVictim());
2955 targets.push_back(target);
2962 targets.push_back(target);
2970 targets.push_back(tapper);
2980 targets.push_back(u);
2986 targets.push_back(target);
3091 std::vector<Creature*> creatures;
3093 if (creatures.empty())
3104 std::vector<Creature*> creatures;
3107 if (creatures.empty())
3415 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript: Gossip Select: menu {} action {}", var0, var1);
3455 Unit* unitTarget =
nullptr;
3471 if (
IsUnit(target) &&
me->
IsFriendlyTo(target->ToUnit()) && target->ToUnit()->IsAlive() && target->ToUnit()->IsInCombat())
3473 uint32 healthPct =
uint32(target->ToUnit()->GetHealthPct());
3477 unitTarget = target->
ToUnit();
3514 std::list<Creature*> list;
3518 creature = list.front();
3544 std::list<GameObject*> list;
3548 gameobject = list.front();
3574 ProcessAction(e, unit, var0, 0,
false,
nullptr,
nullptr, varString);
3669 Unit* invoker =
nullptr;
3677 if (scriptholder.event_id > e.
event_id)
3679 scriptholder.enableTimed =
true;
3716 mEvents.push_back(installevent);
3728 if (i->event_id ==
id)
3777 return creatureObj->IsCharmed();
3803 bool needCleanup =
true;
3806 if (scriptholder.enableTimed)
3807 needCleanup =
false;
3830 SmartAIEventStoredList::iterator i, icurr;
3838 bool needCleanup =
true;
3849 needCleanup =
false;
3884 std::sort(events.begin(), events.end());
3903 if (ignoreChanceRoll)
3914 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript: EventMap for Entry {} is empty but is using SmartScript.", obj->
GetEntry());
3916 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript: EventMap for AreaTrigger {} is empty but is using SmartScript.", at->
ID);
3918 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript: EventMap for SceneId {} is empty but is using SmartScript.", scene->
SceneId);
3922 TC_LOG_DEBUG(
"scripts.ai",
"SmartScript: EventMap for Event {} is empty but is using SmartScript.",
event);
3927 #ifndef TRINITY_DEBUG
3932 if (obj && scriptholder.Difficulties.size())
3934 bool foundValidDifficulty =
false;
3935 for (
Difficulty difficulty : scriptholder.Difficulties)
3939 foundValidDifficulty =
true;
3944 if (!foundValidDifficulty)
3949 mEvents.push_back(scriptholder);
3964 FillScript(std::move(e),
me,
nullptr,
nullptr,
nullptr, 0);
3970 FillScript(std::move(e),
go,
nullptr,
nullptr,
nullptr, 0);
4008 TC_LOG_ERROR(
"misc",
"SmartScript::OnInitialize: source is AreaTrigger with id {}, missing trigger player",
trigger->
ID);
4022 TC_LOG_ERROR(
"misc",
"SmartScript::OnInitialize: source is Scene with id {}, missing trigger player", scene->
SceneId);
4036 TC_LOG_ERROR(
"misc",
"SmartScript::OnInitialize: source is Quest with id {}, missing trigger player", qst->
GetQuestId());
4064 TC_LOG_ERROR(
"misc",
"SmartScript::OnInitialize: source is Event {}, missing trigger WorldObject",
event);
4088 TC_LOG_ERROR(
"misc",
"SmartScript::OnInitialize: Unhandled TypeID !WARNING!");
4094 TC_LOG_ERROR(
"misc",
"SmartScript::OnInitialize: !WARNING! Initialized objects are NULL.");
4123 Unit* unit =
nullptr;
4136 Unit* unit =
nullptr;
4168 Unit* unit =
nullptr;
std::chrono::seconds Seconds
Seconds shorthand typedef.
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
std::string GetDebugInfo()
@ BROADCAST_TEXT_CALL_FOR_HELP
@ BROADCAST_TEXT_FLEE_FOR_ASSIST
#define TC_LOG_WARN(filterType__,...)
#define TC_LOG_DEBUG(filterType__,...)
#define TC_LOG_ERROR(filterType__,...)
uint32 urand(uint32 min, uint32 max)
bool roll_chance_i(int chance)
if(posix_memalign(&__mallocedMemory, __align, __size)) return NULL
@ SPELL_FAILED_SPELL_IN_PROGRESS
@ SMART_SCRIPT_TYPE_TIMED_ACTIONLIST
@ SMART_SCRIPT_TYPE_CREATURE
@ SMART_SCRIPT_TYPE_AREATRIGGER_ENTITY_CUSTOM
@ SMART_SCRIPT_TYPE_GAMEOBJECT
@ SMART_SCRIPT_TYPE_AREATRIGGER
@ SMART_SCRIPT_TYPE_AREATRIGGER_ENTITY
@ SMART_SCRIPT_TYPE_EVENT
@ SMART_SCRIPT_TYPE_SCENE
@ SMART_SCRIPT_TYPE_QUEST
std::vector< SmartScriptHolder > SmartAIEventList
@ SMART_EVENT_FLAG_WHILE_CHARMED
@ SMART_EVENT_FLAG_DONT_RESET
@ SMART_EVENT_FLAG_DEBUG_ONLY
@ SMART_EVENT_FLAG_TEMP_IGNORE_CHANCE_ROLL
@ SMART_EVENT_FLAG_NOT_REPEATABLE
@ SMART_TARGET_LOOT_RECIPIENTS
@ SMART_TARGET_CLOSEST_CREATURE
@ SMART_TARGET_CREATURE_DISTANCE
@ SMART_TARGET_HOSTILE_RANDOM_NOT_TOP
@ SMART_TARGET_INVOKER_PARTY
@ SMART_TARGET_CLOSEST_FRIENDLY
@ SMART_TARGET_CLOSEST_GAMEOBJECT
@ SMART_TARGET_VEHICLE_PASSENGER
@ SMART_TARGET_GAMEOBJECT_RANGE
@ SMART_TARGET_CREATURE_GUID
@ SMART_TARGET_PLAYER_RANGE
@ SMART_TARGET_CLOSEST_UNSPAWNED_GAMEOBJECT
@ SMART_TARGET_GAMEOBJECT_DISTANCE
@ SMART_TARGET_CREATURE_RANGE
@ SMART_TARGET_CLOSEST_PLAYER
@ SMART_TARGET_HOSTILE_RANDOM
@ SMART_TARGET_GAMEOBJECT_GUID
@ SMART_TARGET_HOSTILE_SECOND_AGGRO
@ SMART_TARGET_OWNER_OR_SUMMONER
@ SMART_TARGET_ACTION_INVOKER
@ SMART_TARGET_HOSTILE_LAST_AGGRO
@ SMART_TARGET_ACTION_INVOKER_VEHICLE
@ SMART_TARGET_THREAT_LIST
@ SMART_TARGET_CLOSEST_ENEMY
@ SMART_TARGET_PLAYER_DISTANCE
std::vector< WorldObject * > ObjectVector
@ SMART_SCRIPT_RESPAWN_CONDITION_AREA
@ SMART_SCRIPT_RESPAWN_CONDITION_MAP
@ SMART_ACTION_REMOVE_TIMED_EVENT
@ SMART_ACTION_UPDATE_TEMPLATE
@ SMART_ACTION_STORE_TARGET_LIST
@ SMART_ACTION_SET_HEALTH_REGEN
@ SMART_ACTION_ACTIVATE_GOBJECT
@ SMART_ACTION_FORCE_DESPAWN
@ SMART_ACTION_GAME_EVENT_START
@ SMART_ACTION_CREATE_CONVERSATION
@ SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST
@ SMART_ACTION_REMOVE_UNIT_FIELD_BYTES_1
@ SMART_ACTION_SET_DISABLE_GRAVITY
@ SMART_ACTION_SET_INST_DATA64
@ SMART_ACTION_SET_FACTION
@ SMART_ACTION_THREAT_SINGLE_PCT
@ SMART_ACTION_OFFER_QUEST
@ SMART_ACTION_OVERRIDE_LIGHT
@ SMART_ACTION_SET_UNIT_FIELD_BYTES_1
@ SMART_ACTION_CLOSE_GOSSIP
@ SMART_ACTION_DISABLE_EVADE
@ SMART_ACTION_LOAD_EQUIPMENT
@ SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS
@ SMART_ACTION_ATTACK_START
@ SMART_ACTION_BECOME_PERSONAL_CLONE_FOR_PLAYER
@ SMART_ACTION_CALL_GROUPEVENTHAPPENS
@ SMART_ACTION_MOUNT_TO_ENTRY_OR_MODEL
@ SMART_ACTION_INVOKER_CAST
@ SMART_ACTION_SCENE_PLAY
@ SMART_ACTION_JUMP_TO_POS
@ SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST
@ SMART_ACTION_SEND_GOSSIP_MENU
@ SMART_ACTION_SET_COUNTER
@ SMART_ACTION_FLEE_FOR_ASSIST
@ SMART_ACTION_ATTACK_STOP
@ SMART_ACTION_SIMPLE_TALK
@ SMART_ACTION_SPAWN_SPAWNGROUP
@ SMART_ACTION_ALLOW_COMBAT_MOVEMENT
@ SMART_ACTION_THREAT_ALL_PCT
@ SMART_ACTION_SET_MOVEMENT_SPEED
@ SMART_ACTION_PLAY_CINEMATIC
@ SMART_ACTION_ADD_NPC_FLAG
@ SMART_ACTION_FAIL_QUEST
@ SMART_ACTION_INTERRUPT_SPELL
@ SMART_ACTION_RANDOM_SOUND
@ SMART_ACTION_SET_IMMUNE_PC
@ SMART_ACTION_SCENE_CANCEL
@ SMART_ACTION_SEND_TARGET_TO_TARGET
@ SMART_ACTION_SET_INGAME_PHASE_ID
@ SMART_ACTION_REMOVE_POWER
@ SMART_ACTION_GO_SET_GO_STATE
@ SMART_ACTION_MOVE_OFFSET
@ SMART_ACTION_REMOVE_ITEM
@ SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL
@ SMART_ACTION_RANDOM_PHASE
@ SMART_ACTION_SET_EMOTE_STATE
@ SMART_ACTION_CROSS_CAST
@ SMART_ACTION_GAME_EVENT_STOP
@ SMART_ACTION_CALL_KILLEDMONSTER
@ SMART_ACTION_TRIGGER_GAME_EVENT
@ SMART_ACTION_CALL_SCRIPT_RESET
@ SMART_ACTION_PLAY_SPELL_VISUAL_KIT
@ SMART_ACTION_COMBAT_STOP
@ SMART_ACTION_SET_INGAME_PHASE_GROUP
@ SMART_ACTION_ACTIVATE_GAMEOBJECT
@ SMART_ACTION_ADD_TO_STORED_TARGET_LIST
@ SMART_ACTION_SET_HEALTH_PCT
@ SMART_ACTION_AUTO_ATTACK
@ SMART_ACTION_SET_INVINCIBILITY_HP_LEVEL
@ SMART_ACTION_SET_VISIBILITY
@ SMART_ACTION_RANDOM_PHASE_RANGE
@ SMART_ACTION_GO_SET_LOOT_STATE
@ SMART_ACTION_SET_INST_DATA
@ SMART_ACTION_PLAY_ANIMKIT
@ SMART_ACTION_CALL_FOR_HELP
@ SMART_ACTION_SET_UNINTERACTIBLE
@ SMART_ACTION_OVERRIDE_WEATHER
@ SMART_ACTION_ADD_THREAT
@ SMART_ACTION_TRIGGER_RANDOM_TIMED_EVENT
@ SMART_ACTION_PLAY_EMOTE
@ SMART_ACTION_SET_EVENT_PHASE
@ SMART_ACTION_DESPAWN_SPAWNGROUP
@ SMART_ACTION_SET_CORPSE_DELAY
@ SMART_ACTION_SET_SHEATH
@ SMART_ACTION_SET_ORIENTATION
@ SMART_ACTION_RESPAWN_BY_SPAWNID
@ SMART_ACTION_SET_NPC_FLAG
@ SMART_ACTION_MOVE_TO_POS
@ SMART_ACTION_RANDOM_EMOTE
@ SMART_ACTION_INC_EVENT_PHASE
@ SMART_ACTION_ENABLE_TEMP_GOBJ
@ SMART_ACTION_CREATE_TIMED_EVENT
@ SMART_ACTION_REMOVE_NPC_FLAG
@ SMART_ACTION_SUMMON_CREATURE
@ SMART_ACTION_RESET_GOBJECT
@ SMART_ACTION_CALL_TIMED_ACTIONLIST
@ SMART_ACTION_SET_IN_COMBAT_WITH_ZONE
@ SMART_ACTION_SET_HOME_POS
@ SMART_ACTION_SET_ACTIVE
@ SMART_ACTION_SET_RANGED_MOVEMENT
@ SMART_ACTION_ACTIVATE_TAXI
@ SMART_ACTION_START_CLOSEST_WAYPOINT
@ SMART_ACTION_SUMMON_CREATURE_GROUP
@ SMART_ACTION_SET_REACT_STATE
@ SMART_ACTION_RANDOM_MOVE
@ SMART_ACTION_SET_IMMUNE_NPC
@ SMART_ACTION_TRIGGER_TIMED_EVENT
@ SMART_ACTION_REMOVEAURASFROMSPELL
@ SMART_ACTION_PAUSE_MOVEMENT
@ SMART_EVENT_ACTION_DONE
@ SMART_EVENT_SUMMON_DESPAWNED
@ SMART_EVENT_SCENE_START
@ SMART_EVENT_RECEIVE_EMOTE
@ SMART_EVENT_FRIENDLY_HEALTH_PCT
@ SMART_EVENT_RECEIVE_HEAL
@ SMART_EVENT_TIMED_EVENT_TRIGGERED
@ SMART_EVENT_SCENE_COMPLETE
@ SMART_EVENT_QUEST_COMPLETION
@ SMART_EVENT_JUST_CREATED
@ SMART_EVENT_AREATRIGGER_ONTRIGGER
@ SMART_EVENT_DISTANCE_GAMEOBJECT
@ SMART_EVENT_ON_SPELLCLICK
@ SMART_EVENT_MOVEMENTINFORM
@ SMART_EVENT_PASSENGER_REMOVED
@ SMART_EVENT_INSTANCE_PLAYER_ENTER
@ SMART_EVENT_WAYPOINT_PAUSED
@ SMART_EVENT_REACHED_HOME
@ SMART_EVENT_TRANSPORT_ADDCREATURE
@ SMART_EVENT_REWARD_QUEST
@ SMART_EVENT_GO_EVENT_INFORM
@ SMART_EVENT_GO_LOOT_STATE_CHANGED
@ SMART_EVENT_SCENE_CANCEL
@ SMART_EVENT_JUST_SUMMONED
@ SMART_EVENT_ON_SPELL_CAST
@ SMART_EVENT_SPELLHIT_TARGET
@ SMART_EVENT_GAME_EVENT_START
@ SMART_EVENT_TRANSPORT_REMOVE_PLAYER
@ SMART_EVENT_GOSSIP_HELLO
@ SMART_EVENT_GOSSIP_SELECT
@ SMART_EVENT_CORPSE_REMOVED
@ SMART_EVENT_PASSENGER_BOARDED
@ SMART_EVENT_SCENE_TRIGGER
@ SMART_EVENT_TRANSPORT_ADDPLAYER
@ SMART_EVENT_WAYPOINT_ENDED
@ SMART_EVENT_ACCEPTED_QUEST
@ SMART_EVENT_COUNTER_SET
@ SMART_EVENT_FRIENDLY_MISSING_BUFF
@ SMART_EVENT_WAYPOINT_RESUMED
@ SMART_EVENT_ON_SPELL_FAILED
@ SMART_EVENT_WAYPOINT_REACHED
@ SMART_EVENT_TARGET_BUFFED
@ SMART_EVENT_QUEST_ACCEPTED
@ SMART_EVENT_QUEST_REWARDED
@ SMART_EVENT_TRANSPORT_RELOCATE
@ SMART_EVENT_GAME_EVENT_END
@ SMART_EVENT_FOLLOW_COMPLETED
@ SMART_EVENT_QUEST_OBJ_COMPLETION
@ SMART_EVENT_DISTANCE_CREATURE
@ SMART_EVENT_WAYPOINT_STOPPED
@ SMART_EVENT_SUMMONED_UNIT_DIES
@ SMART_EVENT_FRIENDLY_IS_CC
@ SMART_EVENT_SEND_EVENT_TRIGGER
@ SMART_EVENT_ON_SPELL_START
@ SMART_EVENT_VICTIM_CASTING
@ SMART_EVENT_DAMAGED_TARGET
@ SMART_EVENT_SUMMONED_UNIT
SmartActionSummonCreatureFlags
@ SMARTAI_SPAWN_FLAG_FORCE_SPAWN
@ SMARTAI_SPAWN_FLAG_NOSAVE_RESPAWN
@ SMARTAI_SPAWN_FLAG_IGNORE_RESPAWN
@ SMARTCAST_INTERRUPT_PREVIOUS
@ SMARTCAST_AURA_NOT_PRESENT
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
@ TRIGGERED_NONE
Not triggered.
NPCFlags
Non Player Character flags.
#define MAX_EQUIPMENT_ITEMS
@ UNIT_FLAG_IMMUNE_TO_NPC
@ UNIT_STATE_LOST_CONTROL
static float waypoint[6][3]
static Conversation * CreateConversation(uint32 conversationEntry, Unit *creator, Position const &pos, ObjectGuid privateObjectOwner, SpellInfo const *spellInfo=nullptr, bool autoStart=true)
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
void AttackStart(Unit *victim) override
== Triggered Actions Requested ==================
static void SendChatPacket(WorldObject *source, Builder const &builder, ChatMsg msgType, WorldObject const *whisperTarget=nullptr, CreatureTextRange range=TEXT_RANGE_NORMAL, Team team=TEAM_OTHER, bool gmOnly=false)
void SetHomePosition(float x, float y, float z, float o)
void SetCanMelee(bool canMelee, bool fleeFromMelee=false)
void GetRespawnPosition(float &x, float &y, float &z, float *ori=nullptr, float *dist=nullptr) const
void CallForHelp(float fRadius)
void GetHomePosition(float &x, float &y, float &z, float &ori) const
void GetTransportHomePosition(float &x, float &y, float &z, float &ori) const
bool IsEngaged() const override
GuidUnorderedSet const & GetTapList() const
void DoFleeToGetAssistance()
ObjectGuid::LowType GetSpawnId() const
Unit * SelectNearestTarget(float dist=0, bool playerOnly=false) const
bool IsInEvadeMode() const
virtual void SetData(uint32, uint32)
ObjectGuid GetOwnerGUID() const override
GameObjectAI * AI() const
ObjectGuid::LowType GetSpawnId() const
virtual bool SetBossState(uint32 id, EncounterState state)
static char const * GetBossStateName(uint8 state)
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Difficulty GetDifficultyID() const
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
bool SpawnGroupDespawn(uint32 groupId, bool deleteRespawnTimes=false, size_t *count=nullptr)
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
void Respawn(RespawnInfo *info, CharacterDatabaseTransaction dbTrans=nullptr)
void MoveJumpWithGravity(Position const &pos, float speedXY, float gravity, uint32 id=EVENT_JUMP, bool hasOrientation=false, JumpArrivalCastArgs const *arrivalCast=nullptr, Movement::SpellEffectExtraData const *spellEffectExtraData=nullptr)
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false, JumpArrivalCastArgs const *arrivalCast=nullptr, Movement::SpellEffectExtraData const *spellEffectExtraData=nullptr)
void MoveRandom(float wanderDistance=0.0f, Optional< Milliseconds > duration={}, MovementSlot slot=MOTION_SLOT_DEFAULT)
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
static ObjectGuid const Empty
std::string ToString() const
static CreatureModel const * ChooseDisplayId(CreatureTemplate const *cinfo, CreatureData const *data=nullptr)
static Creature * ToCreature(Object *o)
static Unit * ToUnit(Object *o)
static GameObject * ToGameObject(Object *o)
bool IsGameObject() const
GameObject * ToGameObject()
static AreaTrigger * ToAreaTrigger(Object *o)
static ObjectGuid GetGUID(Object const *o)
static Player * ToPlayer(Object *o)
static void AddPhase(WorldObject *object, uint32 phaseId, bool updateVisibility)
static void AddPhaseGroup(WorldObject *object, uint32 phaseGroupId, bool updateVisibility)
static void RemovePhaseGroup(WorldObject *object, uint32 phaseGroupId, bool updateVisibility)
static void RemovePhase(WorldObject *object, uint32 phaseId, bool updateVisibility)
void KilledMonsterCredit(uint32 entry, ObjectGuid guid=ObjectGuid::Empty)
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
WorldSession * GetSession() const
void AddQuestAndCheckCompletion(Quest const *quest, Object *questGiver)
bool CanTakeQuest(Quest const *quest, bool msg) const
void AreaExploredOrEventHappens(uint32 questId)
Group * GetGroup(Optional< uint8 > partyIndex)
void PrepareGossipMenu(WorldObject *source, uint32 menuId, bool showQuests=false)
uint32 GetGossipTextId(uint32 menuId, WorldObject *source)
std::unique_ptr< PlayerMenu > PlayerTalkClass
uint32 GetQuestId() const
static SmartScriptHolder & FindLinkedEvent(SmartAIEventList &list, uint32 link)
void SetInvincibilityHpLevel(uint32 level)
bool CheckTimer(SmartScriptHolder const &e) const
static constexpr uint32 MAX_NESTED_EVENTS
void DoFindFriendlyMissingBuff(std::vector< Creature * > &creatures, float range, uint32 spellid) const
void OnUpdate(const uint32 diff)
void DoFindFriendlyCC(std::vector< Creature * > &creatures, float range) const
SmartScriptType mScriptType
void UpdateTimer(SmartScriptHolder &e, uint32 const diff)
void ProcessEventsFor(SMART_EVENT e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr, std::string const &varString="")
void FillScript(SmartAIEventList e, WorldObject *obj, AreaTriggerEntry const *at, SceneTemplate const *scene, Quest const *quest, uint32 event=0)
void SortEvents(SmartAIEventList &events)
SceneTemplate const * sceneTemplate
static void RecalcTimer(SmartScriptHolder &e, uint32 min, uint32 max)
void OnInitialize(WorldObject *obj, AreaTriggerEntry const *at=nullptr, SceneTemplate const *scene=nullptr, Quest const *qst=nullptr, uint32 evnt=0)
uint32 GetCounterValue(uint32 id) const
static bool IsCharmedCreature(WorldObject *obj)
void StoreTargetList(ObjectVector const &targets, uint32 id)
static bool IsUnit(WorldObject *obj)
void AddToStoredTargetList(ObjectVector const &targets, uint32 id)
void ProcessTimedAction(SmartScriptHolder &e, uint32 const &min, uint32 const &max, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr, std::string const &varString="")
void RetryLater(SmartScriptHolder &e, bool ignoreChanceRoll=false)
SmartAIEventStoredList mStoredEvents
void RaisePriority(SmartScriptHolder &e)
static bool IsPlayer(WorldObject *obj)
Unit * GetLastInvoker(Unit *invoker=nullptr) const
static bool IsCreature(WorldObject *obj)
void OnMoveInLineOfSight(Unit *who)
bool IsSmart(Creature *c, bool silent=false) const
WorldObject * GetBaseObjectOrUnitInvoker(Unit *invoker)
Unit * DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) const
bool IsInPhase(uint32 p) const
SmartAIEventList mInstallEvents
static void InitTimer(SmartScriptHolder &e)
AreaTriggerEntry const * trigger
Unit * DoSelectLowestHpPercentFriendly(float range, uint32 minHpPct, uint32 maxHpPct) const
AreaTrigger * areaTrigger
void ProcessEvent(SmartScriptHolder &e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr, std::string const &varString="")
void StoreCounter(uint32 id, uint32 value, uint32 reset)
WorldObject * GetBaseObject() const
void GetWorldObjectsInDist(ObjectVector &objects, float dist) const
uint32 mNestedEventsCounter
Creature * FindCreatureNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
static bool IsGameObject(WorldObject *obj)
void ProcessAction(SmartScriptHolder &e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr, std::string const &varString="")
void GetTargets(ObjectVector &targets, SmartScriptHolder const &e, WorldObject *invoker=nullptr) const
bool isProcessingTimedActionList
ObjectVector const * GetStoredTargetVector(uint32 id, WorldObject const &ref) const
Unit * DoFindClosestFriendlyInRange(float range, bool playerOnly) const
static SmartScriptHolder CreateSmartEvent(SMART_EVENT e, uint32 event_flags, uint32 event_param1, uint32 event_param2, uint32 event_param3, uint32 event_param4, uint32 event_param5, SMART_ACTION action, uint32 action_param1, uint32 action_param2, uint32 action_param3, uint32 action_param4, uint32 action_param5, uint32 action_param6, uint32 action_param7, SMARTAI_TARGETS t, uint32 target_param1, uint32 target_param2, uint32 target_param3, uint32 target_param4, uint32 phaseMask)
SmartAIEventList mTimedActionList
ObjectVectorMap _storedTargets
bool mEventSortingRequired
ObjectGuid mTimedActionListInvoker
void RemoveStoredEvent(uint32 id)
void SetTimedActionList(SmartScriptHolder &e, uint32 entry, Unit *invoker, uint32 startFromEventId=0)
std::vector< uint32 > mRemIDs
GameObject * FindGameObjectNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
void ModifyThreatByPercent(Unit *target, int32 percent)
Trinity::IteratorPair< ThreatListIterator, std::nullptr_t > GetUnsortedThreatList() const
void AddThreat(Unit *target, float amount, SpellInfo const *spell=nullptr, bool ignoreModifiers=false, bool ignoreRedirects=false)
== AFFECT MY THREAT LIST ==
std::vector< ThreatReference * > GetModifiableThreatList()
virtual void SetData(uint32, uint32)
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Vehicle * GetVehicle() const
float GetHealthPct() const
void CombatStop(bool includingCast=false, bool mutualPvP=true, bool(*unitFilter)(Unit const *otherUnit)=nullptr)
bool CanHaveThreatList() const
====================== THREAT & COMBAT ====================
ThreatManager & GetThreatManager()
bool IsWithinCombatRange(Unit const *obj, float dist2compare) const
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
MotionMaster * GetMotionMaster()
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
void SetFacingToObject(WorldObject const *object, bool force=true)
int32 GetMaxPower(Powers power) const
TempSummon * ToTempSummon()
ObjectGuid GetCharmerOrOwnerGUID() const override
ObjectGuid GetCreatorGUID() const override
void SetSheath(SheathState sheathed)
Unit * EnsureVictim() const
uint32 GetAuraCount(uint32 spellId) const
uint64 GetMaxHealth() const
TransportBase * GetDirectTransport() const
Returns the transport this unit is on directly (if on vehicle and transport, return vehicle)
void SetFacingTo(float const ori, bool force=true)
bool HasUnitState(const uint32 f) const
float GetPowerPct(Powers power) const
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Vehicle * GetVehicleKit() const
void KillSelf(bool durabilityLoss=true, bool skipSettingDeathState=false)
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
SeatMap Seats
The collection of all seats on the vehicle. Including vacant ones.
TempSummon * SummonPersonalClone(Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, Player *privateObjectOwner=nullptr)
Player * SelectNearestPlayer(float range) const
GameObject * FindNearestGameObject(uint32 entry, float range, bool spawnedOnly=true) const
InstanceScript * GetInstanceScript() const
void GetCreatureListWithEntryInGrid(Container &creatureContainer, uint32 entry, float maxSearchRange=250.0f) const
ObjectGuid GetPrivateObjectOwner() const
void GetGameObjectListWithEntryInGrid(Container &gameObjectContainer, uint32 entry, float maxSearchRange=250.0f) const
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
bool IsHostileTo(WorldObject const *target) const
virtual ObjectGuid GetCharmerOrOwnerGUID() const
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
TransportBase * GetTransport() const
bool IsPrivateObject() const
GameObject * SummonGameObject(uint32 entry, Position const &pos, QuaternionData const &rot, Seconds respawnTime, GOSummonType summonType=GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)
std::string const & GetName() const
bool IsWithinLOSInMap(WorldObject const *obj, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing) const
void GetContactPoint(WorldObject const *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
GameObject * FindNearestUnspawnedGameObject(uint32 entry, float range) const
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
bool IsInRange(WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
bool IsFriendlyTo(WorldObject const *target) const
Player session in the World.
virtual void SetData(uint32, uint32)
virtual void SetGuidData(uint32, ObjectGuid)
TC_GAME_API void Trigger(uint32 gameEventId, WorldObject *source, WorldObject *target)
TC_GAME_API WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const &)
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
void EraseIf(Container &c, Predicate p)
void RandomResize(C &container, std::size_t requestedSize)
std::string ToString(Type &&val, Params &&... params)
static void VisitAllObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
EquipmentItem Items[MAX_EQUIPMENT_ITEMS]
constexpr float GetPositionX() const
constexpr float GetPositionY() const
Position GetPositionWithOffset(Position const &offset) const
constexpr void GetPosition(float &x, float &y) const
constexpr float GetOrientation() const
constexpr float GetPositionZ() const
static QuaternionData fromEulerAnglesZYX(float Z, float Y, float X)
struct SmartAction::@66::@135 setRoot
struct SmartAction::@66::@166 addToStoredTargets
SAIBool UseDefaultGravity
struct SmartAction::@66::@143 randomSound
struct SmartAction::@66::@79 crossCast
struct SmartAction::@66::@95 callHelp
struct SmartAction::@66::@128 enableTempGO
struct SmartAction::@66::@85 setEventPhase
struct SmartAction::@66::@161 conversation
struct SmartAction::@66::@144 corpseDelay
struct SmartAction::@66::@160 setHealthPct
struct SmartAction::@66::@108 wpPause
struct SmartAction::@66::@92 setInstanceData
struct SmartAction::@66::@131 setGoLootState
struct SmartAction::@66::@130 sendGossipMenu
struct SmartAction::@66::@105 active
struct SmartAction::@66::@115 storeTargets
uint32 wps[SMART_ACTION_PARAM_COUNT]
struct SmartAction::@66::@91 killedMonster
struct SmartAction::@66::@111 setRun
struct SmartAction::@66::@107 wpStart
struct SmartAction::@66::@137 creatureGroup
struct SmartAction::@66::@102 moveRandom
struct SmartAction::@66::@120 setunitByte
struct SmartAction::@66::@142 moveOffset
struct SmartAction::@66::@104 summonGO
uint32 emotes[SMART_ACTION_PARAM_COUNT]
struct SmartAction::@66::@106 taxi
struct SmartAction::@66::@146 groupSpawn
struct SmartAction::@66::@162 setImmunePC
uint32 transitionMilliseconds
struct SmartAction::@66::@81 threatPCT
struct SmartAction::@66::@118 equip
struct SmartAction::@66::@148 randomTimedEvent
struct SmartAction::@66::@134 setHealthRegen
struct SmartAction::@66::@96 setSheath
SAIBool toRespawnPosition
struct SmartAction::@66::@70 faction
struct SmartAction::@66::@129 moveToPos
struct SmartAction::@66::@69 simpleTalk
struct SmartAction::@66::@88 follow
struct SmartAction::@66::@97 forceDespawn
struct SmartAction::@66::@155 spellVisualKit
struct SmartAction::@66::@77 randomEmote
struct SmartAction::@66::@117 movie
struct SmartAction::@66::@140 gameEventStart
struct SmartAction::@66::@80 summonCreature
struct SmartAction::@66::@167 becomePersonalClone
struct SmartAction::@66::@109 wpStop
struct SmartAction::@66::@75 questOffer
struct SmartAction::@66::@138 power
struct SmartAction::@66::@123 randTimedActionList
struct SmartAction::@66::@165 activateGameObject
struct SmartAction::@66::@122 timedActionList
struct SmartAction::@66::@101 setData
struct SmartAction::@66::@94 updateTemplate
struct SmartAction::@66::@141 closestWaypointFromList
struct SmartAction::@66::@103 visibility
struct SmartAction::@66::@152 scene
struct SmartAction::@66::@158 setHover
struct SmartAction::@66::@154 movementSpeed
struct SmartAction::@66::@159 evade
uint32 actionLists[SMART_ACTION_PARAM_COUNT]
struct SmartAction::@66::@86 incEventPhase
struct SmartAction::@66::@125 interruptSpellCasting
struct SmartAction::@66::@93 setInstanceData64
uint32 phases[SMART_ACTION_PARAM_COUNT]
struct SmartAction::@66::@83 autoAttack
struct SmartAction::@66::@99 ingamePhaseId
struct SmartAction::@66::@113 teleport
struct SmartAction::@66::@153 cinematic
struct SmartAction::@66::@112 setDisableGravity
struct SmartAction::@66::@87 removeAura
struct SmartAction::@66::@145 disableEvade
struct SmartAction::@66::@98 invincHP
struct SmartAction::@66::@100 ingamePhaseGroup
struct SmartAction::@66::@124 randRangeTimedActionList
struct SmartAction::@66::@116 timeEvent
SAIBool disablePathfinding
struct SmartAction::@66::@139 gameEventStop
struct SmartAction::@66::@156 overrideLight
struct SmartAction::@66::@168 triggerGameEvent
struct SmartAction::@66::@136 goState
SAIBool useSaiTargetAsGameEventSource
struct SmartAction::@66::@126 jump
struct SmartAction::@66::@133 setRangedMovement
struct SmartAction::@66::@164 setUninteractible
struct SmartAction::@66::@163 setImmuneNPC
struct SmartAction::@66::@76 react
struct SmartAction::@66::@78 cast
struct SmartAction::@66::@127 fleeAssist
struct SmartAction::@66::@84 combatMove
struct SmartAction::@66::@110 item
struct SmartAction::@66::@169 doAction
struct SmartAction::@66::@89 randomPhase
struct SmartAction::@66::@132 sendTargetToTarget
struct SmartAction::@66::@68 talk
struct SmartAction::@66::@149 pauseMovement
struct SmartAction::@66::@150 respawnData
struct SmartAction::@66::@157 overrideWeather
struct SmartAction::@66::@170 raw
struct SmartAction::@66::@82 threat
struct SmartAction::@66::@71 morphOrMount
struct SmartAction::@66::@90 randomPhaseRange
struct SmartAction::@66::@147 loadEquipment
struct SmartAction::@66::@114 setCounter
struct SmartEvent::@29::@36 minMax
struct SmartEvent::@29::@65 raw
struct SmartEvent::@29::@47 dataSet
struct SmartEvent::@29::@46 movementInform
struct SmartEvent::@29::@32 kill
struct SmartEvent::@29::@48 waypoint
struct SmartEvent::@29::@40 summoned
struct SmartEvent::@29::@58 goLootStateChanged
struct SmartEvent::@29::@55 gossipHello
struct SmartEvent::@29::@37 targetCasting
struct SmartEvent::@29::@62 distance
struct SmartEvent::@29::@60 doAction
struct SmartEvent::@29::@59 eventInform
struct SmartEvent::@29::@39 missingBuff
uint32 hostilityMode
Hostility mode of the event. 0: hostile, 1: not hostile, 2: any
struct SmartEvent::@29::@63 counter
struct SmartEvent::@29::@38 friendlyCC
struct SmartEvent::@29::@34 los
struct SmartEvent::@29::@35 respawn
struct SmartEvent::@29::@56 gossip
struct SmartEvent::@29::@61 friendlyHealthPct
struct SmartEvent::@29::@45 charm
struct SmartEvent::@29::@52 areatrigger
struct SmartEvent::@29::@33 spellHit
struct SmartEvent::@29::@42 questObjective
struct SmartEvent::@29::@50 transportRelocate
struct SmartEvent::@29::@54 timedEvent
struct SmartEvent::@29::@64 spellCast
struct SmartEvent::@29::@49 transportAddCreature
struct SmartEvent::@29::@51 instancePlayerEnter
struct SmartEvent::@29::@57 gameEvent
struct SmartEvent::@29::@44 aura
struct SmartEvent::@29::@31 minMaxRepeat
struct SmartEvent::@29::@53 textOver
static constexpr uint32 DEFAULT_PRIORITY
uint32 GetScriptType() const
uint32 GetEventType() const
uint32 GetTargetType() const
SmartScriptType source_type
uint32 GetActionType() const
struct SmartTarget::@171::@178 playerDistance
struct SmartTarget::@171::@175 unitRange
struct SmartTarget::@171::@185 goClosest
struct SmartTarget::@171::@187 closestFriendly
SAIBool useCharmerOrOwner
struct SmartTarget::@171::@184 unitClosest
struct SmartTarget::@171::@182 goGUID
struct SmartTarget::@171::@190 threatList
struct SmartTarget::@171::@183 goDistance
struct SmartTarget::@171::@191 raw
struct SmartTarget::@171::@186 closestAttackable
struct SmartTarget::@171::@189 vehicle
struct SmartTarget::@171::@177 unitDistance
struct SmartTarget::@171::@181 goRange
struct SmartTarget::@171::@173 hostilRandom
struct SmartTarget::@171::@176 unitGUID
struct SmartTarget::@171::@188 owner
struct SmartTarget::@171::@174 farthest
struct SmartTarget::@171::@179 playerRange
struct SmartTarget::@171::@180 stored
std::vector< WaypointNode > Nodes