37 if (repeatMin == repeatMax)
39 else if (repeatMax > repeatMin)
66 std::vector<CreatureEventAI_Event>::const_iterator i;
67 for (i = (*CreatureEvents).second.begin(); i != (*CreatureEvents).second.end(); ++i)
95 sLog.outError(
"CreatureEventAI: Creature %u has events but no events added to list because of instance flags.",
me->
GetEntry());
98 sLog.outError(
"CreatureEventAI: EventMap for Creature %u is empty but creature is using CreatureEventAI.",
me->
GetEntry());
127 switch (event.event_type)
150 if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
154 pHolder.
UpdateRepeatTimer(
me, event.percent_range.repeatMin, event.percent_range.repeatMax);
164 if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
168 pHolder.
UpdateRepeatTimer(
me, event.percent_range.repeatMin, event.percent_range.repeatMax);
203 if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
207 pHolder.
UpdateRepeatTimer(
me, event.percent_range.repeatMin, event.percent_range.repeatMax);
215 pHolder.
UpdateRepeatTimer(
me, event.target_casting.repeatMin, event.target_casting.repeatMax);
226 pActionInvoker = pUnit;
237 std::list<Creature*> pList;
245 pActionInvoker = *(pList.begin());
248 pHolder.
UpdateRepeatTimer(
me, event.friendly_is_cc.repeatMin, event.friendly_is_cc.repeatMax);
253 std::list<Creature*> pList;
261 pActionInvoker = *(pList.begin());
264 pHolder.
UpdateRepeatTimer(
me, event.friendly_buff.repeatMin, event.friendly_buff.repeatMax);
290 if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
294 pHolder.
UpdateRepeatTimer(
me, event.percent_range.repeatMin, event.percent_range.repeatMax);
320 Aura* aura = pActionInvoker->
GetAura(event.buffed.spellId, 0);
383 if (!action.
text.TextId[0])
390 if (action.
text.TextId[1] && action.
text.TextId[2])
392 else if (action.
text.TextId[1] &&
urand(0, 1))
393 temp = action.
text.TextId[1];
395 temp = action.
text.TextId[0];
413 target = pActionInvoker;
450 if (action.
morph.creatureId || action.
morph.modelId)
453 if (action.
morph.creatureId)
534 if (action.
summon.duration)
540 sLog.outErrorDb(
"CreatureEventAI: failed to spawn creature %u. Spawn event %d is on creature %d", action.
summon.creatureId, EventId,
me->
GetEntry());
552 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
560 target->ToPlayer()->AreaExploredOrEventHappens(action.
quest_event.questId);
611 sLog.outErrorDb(
"CreatureEventAI: Event %d decrease Phase under 0. CreatureEntry = %d", EventId,
me->
GetEntry());
616 sLog.outErrorDb(
"CreatureEventAI: Event %d incremented Phase above %u. Phase mask cannot be used with phases past %u. CreatureEntry = %d", EventId,
MAX_PHASE - 1,
MAX_PHASE - 1,
me->
GetEntry());
641 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
649 target->RemoveAurasDueToSpell(action.
remove_aura.spellId);
671 sLog.outErrorDb(
"CreatureEventAI: ACTION_T_RANDOM_PHASE_RANGE cannot have Param2 < Param1. Event = %d. CreatureEntry = %d", EventId,
me->
GetEntry());
677 CreatureEventAI_Summon_Map::const_iterator i =
CreatureEAI_Mgr.GetCreatureEventAISummonMap().find(action.
summon_id.spawnId);
680 sLog.outErrorDb(
"CreatureEventAI: failed to spawn creature %u. Summon map index %u does not exist. EventID %d. CreatureID %d", action.
summon_id.creatureId, action.
summon_id.spawnId, EventId,
me->
GetEntry());
685 if ((*i).second.SpawnTimeSecs)
691 sLog.outErrorDb(
"CreatureEventAI: failed to spawn creature %u. EventId %d.Creature %d", action.
summon_id.creatureId, EventId,
me->
GetEntry());
700 pPlayer->RewardPlayerAndGroupAtEvent(action.
killed_monster.creatureId, pPlayer);
706 pPlayer2->RewardPlayerAndGroupAtEvent(action.
killed_monster.creatureId, pPlayer2);
714 sLog.outErrorDb(
"CreatureEventAI: Event %d attempt to set instance data without instance script. Creature %d", EventId,
me->
GetEntry());
726 sLog.outErrorDb(
"CreatureEventAI: Event %d attempt to set instance data64 but Target == NULL. Creature %d", EventId,
me->
GetEntry());
733 sLog.outErrorDb(
"CreatureEventAI: Event %d attempt to set instance data64 without instance script. Creature %d", EventId,
me->
GetEntry());
744 sLog.outErrorDb(
"CreatureEventAI: Event %d ACTION_T_UPDATE_TEMPLATE call with param1 == current entry. Creature %d", EventId,
me->
GetEntry());
754 sLog.outErrorDb(
"CreatureEventAI: Event %d ACTION_T_DIE on dead creature. Creature %d", EventId,
me->
GetEntry());
786 sLog.outErrorDb(
"OSCR: EventAI failed to spawn object %u. Spawn event %d is on creature %d", action.
raw.param1, EventId,
me->
GetEntry());
810 if (action.
mount.creatureId || action.
mount.modelId)
813 if (action.
mount.creatureId)
858 switch (event.event_type)
863 if ((*i).UpdateRepeatTimer(
me, event.timer.initialMin, event.timer.initialMax))
956 switch (event.event_type)
964 if ((*i).UpdateRepeatTimer(
me, event.timer.initialMin, event.timer.initialMax))
1020 if ((aiEvent.
ooc_los.noHostile && !isHostile) ||
1021 (!aiEvent.
ooc_los.noHostile && isHostile))
1024 float fMaxAllowedRange = aiEvent.
ooc_los.maxRange;
1048 if (!(*i).Event.spell_hit.spellId || pSpell->
Id == (*i).Event.spell_hit.spellId)
1049 if (pSpell->
SchoolMask & (*i).Event.spell_hit.schoolMask)
1074 if (!((*i).Event.event_inverse_phase_mask & (1 <<
Phase)))
1084 switch ((*i).Event.event_type)
1167 return pActionInvoker;
1225 sLog.outErrorDb(
"CreatureEventAI: DoScriptText entry %i, invalid Source pointer.", textEntry);
1231 sLog.outErrorDb(
"CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.", pSource->
GetEntry(), pSource->
GetTypeId(), pSource->
GetGUIDLow(), textEntry);
1235 CreatureEventAI_TextMap::const_iterator i =
CreatureEAI_Mgr.GetCreatureEventAITextMap().find(textEntry);
1239 sLog.outErrorDb(
"CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.", pSource->
GetEntry(), pSource->
GetTypeId(), pSource->
GetGUIDLow(), textEntry);
1243 sLog.outDebug(
"CreatureEventAI: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u", textEntry, (*i).second.SoundId, (*i).second.Type, (*i).second.Language, (*i).second.Emote);
1245 if ((*i).second.SoundId)
1250 sLog.outErrorDb(
"CreatureEventAI: DoScriptText entry %i tried to process invalid sound id %u.", textEntry, (*i).second.SoundId);
1253 if ((*i).second.Emote)
1256 ((
Unit*)pSource)->HandleEmoteCommand((*i).second.Emote);
1258 sLog.outErrorDb(
"CreatureEventAI: DoScriptText entry %i tried to process emote for invalid TypeId (%u).", textEntry, pSource->
GetTypeId());
1261 switch ((*i).second.Type)
1264 pSource->
MonsterSay(textEntry, (*i).second.Language, target ? target->
GetGUID() : 0);
1267 pSource->
MonsterYell(textEntry, (*i).second.Language, target ? target->
GetGUID() : 0);
1279 else sLog.outErrorDb(
"CreatureEventAI: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry);
1286 else sLog.outErrorDb(
"CreatureEventAI: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry);
1304 sLog.outErrorDb(
"CreatureEventAI::CanCast by creature entry %u attempt to cast spell but spell does not exist.",
me->
GetEntry());
1345 caster->
CastSpell(target, spell, flags & CAST_TRIGGERED, NULL, NULL);
1361 if ((*itr).Event.receive_emote.emoteId != text_emote)
1370 if (cond->
Meets(info))
1372 sLog.outDebug(
"CreatureEventAI: ReceiveEmote CreatureEventAI: Condition ok, processing");
1395 switch (event.
spawned.condition)
1402 return me->
GetMapId() ==
event.spawned.conditionValue1;
1405 return me->
GetZoneId() ==
event.spawned.conditionValue1 ||
me->
GetAreaId() ==
event.spawned.conditionValue1;
bool UpdateRepeatTimer(Creature *creature, uint32 repeatMin, uint32 repeatMax)
void KilledUnit(Unit *victim)
virtual void EnterEvadeMode()
Unit * GetTargetByType(uint32 Target, Unit *pActionInvoker)
GameObject * SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime)
void SendPlaySound(uint32 Sound, bool OnlySelf)
struct CreatureEventAI_Action::@3::@34 update_template
struct CreatureEventAI_Action::@3::@12 cast
Unit * DoSelectLowestHpFriendly(float range, uint32 MinHPDiff)
bool Attack(Unit *victim, bool meleeAttack)
uint32 CalculatePowerCost(SpellEntry const *spellInfo, Unit const *caster, SpellSchoolMask schoolMask)
struct CreatureEventAI_Action::@3::@27 ranged_movement
void DamageTaken(Unit *done_by, uint32 &damage)
void Mount(uint32 mount, uint32 spellId=0)
struct CreatureEventAI_Action::@3::@17 cast_event
void MoveIdle(MovementSlot slot=MOTION_SLOT_ACTIVE)
uint32 GetMaxHealth() const
struct CreatureEventAI_Action::@3::@31 killed_monster
DBCStorage< SpellRangeEntry > const * GetSpellRangeStore()
void modifyThreatPercent(Unit *victim, int32 percent)
uint32 GetFaction() const
struct CreatureEventAI_Action::@3::@37 invincibility_hp_level
void Clear(bool reset=true)
bool ProcessEvent(CreatureEventAIHolder &pHolder, Unit *pActionInvoker=NULL)
void ProcessAction(CreatureEventAI_Action const &action, uint32 rnd, uint32 EventId, Unit *pActionInvoker)
void SendMeleeAttackStop(Unit *victim=NULL)
void MonsterTextEmote(const char *text, uint64 TargetGuid, bool IsBossEmote=false)
void MonsterSay(const char *text, uint32 language, uint64 TargetGuid)
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false) const
void MoveChase(Unit *target, float dist=0.0f, float angle=0.0f)
struct CreatureEventAI_Action::@3::@23 set_inc_phase
static int Permissible(const Creature *)
Unit * SelectNearestTarget(float dist=0, bool playerOnly=false) const
void SetCombatMovement(bool enable)
Set combat movement (on/off)
MotionMaster * GetMotionMaster()
struct CreatureEventAI_Action::@3::@22 set_phase
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
#define sLog
Log class singleton.
MovementGeneratorType GetCurrentMovementGeneratorType() const
ThreatContainer::StorageType const & getThreatList() const
void SetUInt32Value(uint16 index, uint32 value)
bool IsWithinLOSInMap(const WorldObject *obj) const
struct CreatureEventAI_Action::@3::@13 summon
void JustSummoned(Creature *pUnit)
bool IsInEvadeMode() const
void ReceiveEmote(Player *pPlayer, uint32 text_emote)
bool IsWithinLOS(float x, float y, float z) const
struct CreatureEventAI_Action::@3::@7 morph
uint32 GetGUIDLow() const
void MonsterYell(const char *text, uint32 language, uint64 TargetGuid)
uint32 DealDamage(Unit *victim, uint32 damage, CleanDamage const *cleanDamage=NULL, DamageEffectType damagetype=DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *spellProto=NULL, bool durabilityLoss=true)
Aura * GetAura(uint32 spellId, uint32 effindex)
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)
void ForcedDespawn(uint32 timeMSToDespawn=0)
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
uint32 GetPower(Powers power) const
#define EVENT_UPDATE_TIME
void MonsterWhisper(const char *text, uint64 receiver, bool IsBossWhisper=false)
struct CreatureEventAI_Action::@3::@30 summon_id
SpellSchoolMask GetSpellSchoolMask(SpellEntry const *spellInfo)
struct CreatureEventAI_Action::@3::@40 raw
void DoFleeToGetAssistance()
struct CreatureEventAI_Action::@3::@11 random_emote
CreatureEventAI_Action action[MAX_ACTIONS]
struct CreatureEventAI_Action::@3::@38 mount
uint32 GetMaxPower(Powers power) const
DBCStorage< SoundEntriesEntry > const * GetSoundEntriesStore()
struct CreatureEventAI_Action::@3::@35 call_for_help
void SetDisplayId(uint32 modelId)
struct CreatureEventAI_Action::@3::@5 text
struct CreatureEventAI_Event::@41::@48 ooc_los
void DoScriptText(int32 textEntry, WorldObject *pSource, Unit *target)
uint32 InvinceabilityHpLevel
float GetPositionY() const
SpellCastResult CanCast(Unit *target, SpellEntry const *spell, uint32 flags)
virtual void SetData(uint32, uint32)
void CastSpell(Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
void GetPosition(float &x, float &y) const
void UpdateAI(const uint32 diff)
float GetPositionZ() const
void CallForHelp(float fRadius)
void SendMeleeAttackStart(Unit *victim)
void SpellHit(Unit *pUnit, const SpellEntry *pSpell)
std::list< CreatureEventAIHolder > CreatureEventAIList
uint32 event_inverse_phase_mask
bool CombatMovementEnabled
Combat movement currently enabled.
bool IsInMap(const WorldObject *obj) const
struct CreatureEventAI_Action::@3::@9 emote
struct CreatureEventAI_Action::@3::@16 quest_event
void MoveInLineOfSight(Unit *who)
despawns after a specified time after the creature is out of combat
CreatureEventAI(Creature *c)
virtual void SetSheath(SheathState sheathed)
bool SpawnedEventConditionsCheck(CreatureEventAI_Event const &event)
CreatureEventAI_Event Event
struct CreatureEventAI_Event::@41::@49 spawned
void DoFindFriendlyCC(std::list< Creature * > &_list, float range)
ReactStates
Pet's behavior.
struct CreatureEventAI_Action::@3::@19 unit_flag
CellCoord ComputeCellCoord(float x, float y)
void MonsterYellToZone(int32 textId, uint32 language, uint64 TargetGuid)
void DoFindFriendlyMissingBuff(std::list< Creature * > &_list, float range, uint32 spellid)
struct CreatureEventAI_Action::@3::@21 combat_movement
struct CreatureEventAI_Action::@3::@6 set_faction
struct CreatureEventAI_Action::@3::@14 threat_single_pct
despawns after a specified time OR when the creature disappears
Player * GetLootRecipient() const
bool IsInRange(WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
struct CreatureEventAI_Action::@3::@32 set_inst_data
struct CreatureEventAI_Action::@3::@25 cast_event_all
uint32 GetRandActionParam(uint32 rnd, uint32 param1, uint32 param2, uint32 param3)
struct CreatureEventAI_Action::@3::@15 threat_all_pct
struct CreatureEventAI_Action::@3::@26 remove_aura
CreatureInfo const * GetCreatureTemplateStore(uint32 entry)
bool Meets(ConditionSourceInfo &sourceInfo)
bool UpdateEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData *data=NULL)
std::list< HostileReference * > StorageType
void SetFaction(uint32 faction)
struct CreatureEventAI_Action::@3::@10 random_sound
void EnterCombat(Unit *enemy)
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
ThreatManager & getThreatManager()
struct CreatureEventAI_Action::@3::@18 set_unit_field
bool IsHostileTo(Unit const *unit) const
void DoMeleeAttackIfReady()
struct CreatureEventAI_Action::@3::@39 chanced_text
void SetInCombatWithZone()
virtual void MoveInLineOfSight(Unit *)
void HandleEmoteCommand(uint32 anim_id)
static Unit * GetUnit(WorldObject &object, uint64 guid)
bool HasFlag(uint16 index, uint32 flag) const
float GetPositionX() const
struct CreatureEventAI_Action::@3::@24 quest_event_all
std::string GetAIName() const
Unit * SelectTarget(SelectAggroTarget target, uint32 position=0, float dist=0, bool playerOnly=false, int32 aura=0)
void SetReactState(ReactStates st)
virtual void AttackStart(Unit *)
float AttackDistance
How should an enemy be chased.
void Visit(CellCoord const &, TypeContainerVisitor< T, CONTAINER > &visitor, Map &, WorldObject const &, float) const
struct CreatureEventAI_Action::@3::@33 set_inst_data64
struct CreatureEventAI_Action::@3::@20 auto_attack
struct CreatureEventAI_Action::@3::@28 random_phase
struct CreatureEventAI_Action::@3::@8 sound
struct CreatureEventAI_Action::@3::@29 random_phase_range
uint32 urand(uint32 min, uint32 max)
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
struct CreatureEventAI_Action::@3::@36 set_sheath
bool HasAura(uint32 spellId, uint8 effIndex=0) const
InstanceData * GetInstanceData()
void AttackStart(Unit *who)