[Sync] Some long overdue project sync

This commit is contained in:
Antz 2019-01-08 23:04:45 +00:00 committed by Antz
parent a479a2ccc5
commit 65ec4ea06e
76 changed files with 1693 additions and 1489 deletions

View file

@ -40,9 +40,9 @@
bool CreatureEventAIHolder::UpdateRepeatTimer(Creature* creature, uint32 repeatMin, uint32 repeatMax)
{
if (repeatMin == repeatMax)
Time = repeatMin;
{ Time = repeatMin; }
else if (repeatMax > repeatMin)
Time = urand(repeatMin, repeatMax);
{ Time = urand(repeatMin, repeatMax); }
else
{
sLog.outErrorEventAI("Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", creature->GetEntry(), Event.event_id, Event.event_type);
@ -56,7 +56,7 @@ bool CreatureEventAIHolder::UpdateRepeatTimer(Creature* creature, uint32 repeatM
int CreatureEventAI::Permissible(const Creature* creature)
{
if (creature->GetAIName() == "EventAI")
return PERMIT_BASE_SPECIAL;
{ return PERMIT_BASE_SPECIAL; }
return PERMIT_BASE_NO;
}
@ -67,17 +67,17 @@ void CreatureEventAI::GetAIInformation(ChatHandler& reader)
reader.PSendSysMessage(LANG_NPC_EVENTAI_COMBAT, reader.GetOnOffStr(m_MeleeEnabled));
if (sLog.HasLogFilter(LOG_FILTER_EVENT_AI_DEV)) // Give some more details if in EventAI Dev Mode
return;
{ return; }
reader.PSendSysMessage("Current events of this creature:");
for (CreatureEventAIList::const_iterator itr = m_CreatureEventAIList.begin(); itr != m_CreatureEventAIList.end(); ++itr)
{
if (itr->Event.action[2].type != ACTION_T_NONE)
reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) actions[type(param1)]: %2u(%5u) -- %2u(%u) -- %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time/1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1, itr->Event.action[1].type, itr->Event.action[1].raw.param1, itr->Event.action[2].type, itr->Event.action[2].raw.param1);
{ reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) actions[type(param1)]: %2u(%5u) -- %2u(%u) -- %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time / 1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1, itr->Event.action[1].type, itr->Event.action[1].raw.param1, itr->Event.action[2].type, itr->Event.action[2].raw.param1); }
else if (itr->Event.action[1].type != ACTION_T_NONE)
reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) actions[type(param1)]: %2u(%5u) -- %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time/1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1, itr->Event.action[1].type, itr->Event.action[1].raw.param1);
{ reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) actions[type(param1)]: %2u(%5u) -- %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time / 1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1, itr->Event.action[1].type, itr->Event.action[1].raw.param1); }
else
reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) action[type(param1)]: %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time/1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1);
{ reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) action[type(param1)]: %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time / 1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1); }
}
}
@ -110,7 +110,7 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c),
// Debug check
#ifndef MANGOS_DEBUG
if (i->event_flags & EFLAG_DEBUG_ONLY)
continue;
{ continue; }
#endif
if (m_creature->GetMap()->IsDungeon())
{
@ -133,7 +133,7 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c),
// Debug check
#ifndef MANGOS_DEBUG
if (i->event_flags & EFLAG_DEBUG_ONLY)
continue;
{ continue; }
#endif
bool storeEvent = false;
if (m_creature->GetMap()->IsDungeon())
@ -155,7 +155,7 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c),
}
}
else
sLog.outErrorEventAI("EventMap for Creature %u is empty but creature is using CreatureEventAI.", m_creature->GetEntry());
{ sLog.outErrorEventAI("EventMap for Creature %u is empty but creature is using CreatureEventAI.", m_creature->GetEntry()); }
}
#define LOG_PROCESS_EVENT \
@ -186,21 +186,21 @@ inline bool IsTimerBasedEvent(EventAI_Type type)
}
}
bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker, Creature* pAIEventSender)
bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker, Creature* pAIEventSender /*=NULL*/)
{
if (!pHolder.Enabled || pHolder.Time)
return false;
{ return false; }
// Check the inverse phase mask (event doesn't trigger if current phase bit is set in mask)
if (pHolder.Event.event_inverse_phase_mask & (1 << m_Phase))
{
if (!IsTimerBasedEvent(pHolder.Event.event_type))
DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: Event %u skipped because of phasemask %u. Current phase %u", pHolder.Event.event_id, pHolder.Event.event_inverse_phase_mask, m_Phase);
{ DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: Event %u skipped because of phasemask %u. Current phase %u", pHolder.Event.event_id, pHolder.Event.event_inverse_phase_mask, m_Phase); }
return false;
}
if (!IsTimerBasedEvent(pHolder.Event.event_type))
LOG_PROCESS_EVENT;
{ LOG_PROCESS_EVENT; }
CreatureEventAI_Event const& event = pHolder.Event;
@ -209,7 +209,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
{
case EVENT_T_TIMER_IN_COMBAT:
if (!m_creature->IsInCombat())
return false;
{ return false; }
LOG_PROCESS_EVENT;
// Repeat Timers
@ -217,7 +217,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
break;
case EVENT_T_TIMER_OOC:
if (m_creature->IsInCombat() || m_creature->IsInEvadeMode())
return false;
{ return false; }
LOG_PROCESS_EVENT;
// Repeat Timers
@ -231,12 +231,12 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_HP:
{
if (!m_creature->IsInCombat() || !m_creature->GetMaxHealth())
return false;
{ return false; }
uint32 perc = (m_creature->GetHealth() * 100) / m_creature->GetMaxHealth();
if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
return false;
{ return false; }
LOG_PROCESS_EVENT;
// Repeat Timers
@ -246,12 +246,12 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_MANA:
{
if (!m_creature->IsInCombat() || !m_creature->GetMaxPower(POWER_MANA))
return false;
{ return false; }
uint32 perc = (m_creature->GetPower(POWER_MANA) * 100) / m_creature->GetMaxPower(POWER_MANA);
if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
return false;
{ return false; }
LOG_PROCESS_EVENT;
// Repeat Timers
@ -293,12 +293,12 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_TARGET_HP:
{
if (!m_creature->IsInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxHealth())
return false;
{ return false; }
uint32 perc = (m_creature->getVictim()->GetHealth() * 100) / m_creature->getVictim()->GetMaxHealth();
if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
return false;
{ return false; }
LOG_PROCESS_EVENT;
// Repeat Timers
@ -307,7 +307,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
}
case EVENT_T_TARGET_CASTING:
if (!m_creature->IsInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->IsNonMeleeSpellCasted(false, false, true))
return false;
{ return false; }
LOG_PROCESS_EVENT;
// Repeat Timers
@ -316,11 +316,11 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_FRIENDLY_HP:
{
if (!m_creature->IsInCombat())
return false;
{ return false; }
Unit* pUnit = DoSelectLowestHpFriendly((float)event.friendly_hp.radius, event.friendly_hp.hpDeficit);
if (!pUnit)
return false;
{ return false; }
pActionInvoker = pUnit;
@ -332,14 +332,14 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_FRIENDLY_IS_CC:
{
if (!m_creature->IsInCombat())
return false;
{ return false; }
std::list<Creature*> pList;
DoFindFriendlyCC(pList, (float)event.friendly_is_cc.radius);
// List is empty
if (pList.empty())
return false;
{ return false; }
// We don't really care about the whole list, just return first available
pActionInvoker = *(pList.begin());
@ -355,7 +355,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
// List is empty
if (pList.empty())
return false;
{ return false; }
// We don't really care about the whole list, just return first available
pActionInvoker = *(pList.begin());
@ -370,11 +370,11 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
{
// Prevent event from occuring on no unit or non creatures
if (!pActionInvoker || pActionInvoker->GetTypeId() != TYPEID_UNIT)
return false;
{ return false; }
// Creature id doesn't match up
if (((Creature*)pActionInvoker)->GetEntry() != event.summoned.creatureId)
return false;
{ return false; }
// Repeat Timers
pHolder.UpdateRepeatTimer(m_creature, event.summoned.repeatMin, event.summoned.repeatMax);
@ -383,12 +383,12 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_TARGET_MANA:
{
if (!m_creature->IsInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxPower(POWER_MANA))
return false;
{ return false; }
uint32 perc = (m_creature->getVictim()->GetPower(POWER_MANA) * 100) / m_creature->getVictim()->GetMaxPower(POWER_MANA);
if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
return false;
{ return false; }
// Repeat Timers
pHolder.UpdateRepeatTimer(m_creature, event.percent_range.repeatMin, event.percent_range.repeatMax);
@ -404,7 +404,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
SpellAuraHolder* holder = m_creature->GetSpellAuraHolder(event.buffed.spellId);
if (!holder || holder->GetStackAmount() < event.buffed.amount)
return false;
{ return false; }
LOG_PROCESS_EVENT;
// Repeat Timers
@ -414,11 +414,11 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_TARGET_AURA:
{
if (!m_creature->IsInCombat() || !m_creature->getVictim())
return false;
{ return false; }
SpellAuraHolder* holder = m_creature->getVictim()->GetSpellAuraHolder(event.buffed.spellId);
if (!holder || holder->GetStackAmount() < event.buffed.amount)
return false;
{ return false; }
LOG_PROCESS_EVENT;
// Repeat Timers
@ -432,7 +432,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
SpellAuraHolder* holder = m_creature->GetSpellAuraHolder(event.buffed.spellId);
if (holder && holder->GetStackAmount() >= event.buffed.amount)
return false;
{ return false; }
LOG_PROCESS_EVENT;
// Repeat Timers
@ -442,11 +442,11 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_TARGET_MISSING_AURA:
{
if (!m_creature->IsInCombat() || !m_creature->getVictim())
return false;
{ return false; }
SpellAuraHolder* holder = m_creature->getVictim()->GetSpellAuraHolder(event.buffed.spellId);
if (holder && holder->GetStackAmount() >= event.buffed.amount)
return false;
{ return false; }
LOG_PROCESS_EVENT;
// Repeat Timers
@ -458,13 +458,13 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_ENERGY:
{
if (!m_creature->IsInCombat() || !m_creature->GetMaxPower(POWER_ENERGY))
return false;
{ return false; }
uint32 perc = (m_creature->GetPower(POWER_ENERGY) * 100) / m_creature->GetMaxPower(POWER_ENERGY);
if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
return false;
{ return false; }
LOG_PROCESS_EVENT;
// Repeat Timers
pHolder.UpdateRepeatTimer(m_creature, event.percent_range.repeatMin, event.percent_range.repeatMax);
@ -477,20 +477,20 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
// Disable non-repeatable events
if (!(pHolder.Event.event_flags & EFLAG_REPEATABLE))
pHolder.Enabled = false;
{ pHolder.Enabled = false; }
// Store random here so that all random actions match up
uint32 rnd = rand();
// Return if chance for event is not met
if (pHolder.Event.event_chance <= rnd % 100)
return false;
{ return false; }
// Process actions, normal case
if (!(pHolder.Event.event_flags & EFLAG_RANDOM_ACTION))
{
for (uint32 j = 0; j < MAX_ACTIONS; ++j)
ProcessAction(pHolder.Event.action[j], rnd, pHolder.Event.event_id, pActionInvoker, pAIEventSender);
{ ProcessAction(pHolder.Event.action[j], rnd, pHolder.Event.event_id, pActionInvoker, pAIEventSender); }
}
// Process actions, random case
else
@ -499,7 +499,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
uint32 count = 0;
for (uint32 j = 0; j < MAX_ACTIONS; ++j)
if (pHolder.Event.action[j].type != ACTION_T_NONE)
++count;
{ ++count; }
if (count)
{
@ -513,7 +513,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
if (pHolder.Event.action[j].type != ACTION_T_NONE)
{
if (!idx)
break;
{ break; }
--idx;
}
}
@ -527,7 +527,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 EventId, Unit* pActionInvoker, Creature* pAIEventSender)
{
if (action.type == ACTION_T_NONE)
return;
{ return; }
DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: Process action %u (script %u) triggered for %s (invoked by %s)",
action.type, EventId, m_creature->GetGuidStr().c_str(), pActionInvoker ? pActionInvoker->GetGuidStr().c_str() : "<no invoker>");
@ -539,7 +539,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
case ACTION_T_CHANCED_TEXT:
{
if (!action.text.TextId[0])
return;
{ return; }
int32 textId = 0;
@ -548,9 +548,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
if (action.text.TextId[1] && action.text.TextId[2])
textId = action.text.TextId[rnd % 3];
else if (action.text.TextId[1] && (rnd % 2))
textId = action.text.TextId[1];
{ textId = action.text.TextId[1]; }
else
textId = action.text.TextId[0];
{ textId = action.text.TextId[0]; }
}
// ACTION_T_CHANCED_TEXT, chance hits
else if ((rnd % 100) < action.chanced_text.chance)
@ -558,7 +558,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
if (action.chanced_text.TextId[0] && action.chanced_text.TextId[1])
textId = action.chanced_text.TextId[rnd % 2];
else
textId = action.chanced_text.TextId[0];
{ textId = action.chanced_text.TextId[0]; }
}
if (textId)
@ -568,11 +568,11 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
if (pActionInvoker)
{
if (pActionInvoker->GetTypeId() == TYPEID_PLAYER)
target = pActionInvoker;
{ target = pActionInvoker; }
else if (Unit* owner = pActionInvoker->GetOwner())
{
if (owner->GetTypeId() == TYPEID_PLAYER)
target = owner;
{ target = owner; }
}
}
else if ((target = m_creature->getVictim()))
@ -580,20 +580,20 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
if (target->GetTypeId() != TYPEID_PLAYER)
if (Unit* owner = target->GetOwner())
if (owner->GetTypeId() == TYPEID_PLAYER)
target = owner;
{ target = owner; }
}
if (!DoDisplayText(m_creature, textId, target))
sLog.outErrorEventAI("Error attempting to display text %i, used by script %u", textId, EventId);
{ sLog.outErrorEventAI("Error attempting to display text %i, used by script %u", textId, EventId); }
}
break;
}
case ACTION_T_SET_FACTION:
{
if (action.set_faction.factionId)
m_creature->SetFactionTemporary(action.set_faction.factionId, action.set_faction.factionFlags);
{ m_creature->SetFactionTemporary(action.set_faction.factionId, action.set_faction.factionFlags); }
else // no id provided, assume reset and then use default
m_creature->ClearTemporaryFaction();
{ m_creature->ClearTemporaryFaction(); }
break;
}
@ -612,10 +612,10 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
}
// if no param1, then use value from param2 (modelId)
else
m_creature->SetDisplayId(action.morph.modelId);
{ m_creature->SetDisplayId(action.morph.modelId); }
}
else
m_creature->DeMorph();
{ m_creature->DeMorph(); }
break;
}
case ACTION_T_SOUND:
@ -628,14 +628,14 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
{
int32 temp = GetRandActionParam(rnd, action.random_sound.soundId1, action.random_sound.soundId2, action.random_sound.soundId3);
if (temp >= 0)
m_creature->PlayDirectSound(temp);
{ m_creature->PlayDirectSound(temp); }
break;
}
case ACTION_T_RANDOM_EMOTE:
{
int32 temp = GetRandActionParam(rnd, action.random_emote.emoteId1, action.random_emote.emoteId2, action.random_emote.emoteId3);
if (temp >= 0)
m_creature->HandleEmote(temp);
{ m_creature->HandleEmote(temp); }
break;
}
case ACTION_T_CAST:
@ -652,7 +652,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
if (!target)
{
if (reportTargetError)
sLog.outErrorEventAI("NULL target for ACTION_T_CAST creature entry %u casting spell id %u", m_creature->GetEntry(), action.cast.spellId);
{ sLog.outErrorEventAI("NULL target for ACTION_T_CAST creature entry %u casting spell id %u", m_creature->GetEntry(), action.cast.spellId); }
return;
}
@ -715,53 +715,52 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
{
Unit* target = GetTargetByType(action.summon.target, pActionInvoker, pAIEventSender, reportTargetError);
if (!target && reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SUMMON(%u), target-type %u", EventId, action.type, action.summon.target);
{ sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SUMMON(%u), target-type %u", EventId, action.type, action.summon.target); }
Creature* pCreature = NULL;
if (action.summon.duration)
pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OOC_OR_DEAD_DESPAWN, action.summon.duration);
{ pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OOC_OR_DEAD_DESPAWN, action.summon.duration); }
else
pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OOC_DESPAWN, 0);
{ pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OOC_DESPAWN, 0); }
if (!pCreature)
sLog.outErrorEventAI("failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, EventId, m_creature->GetEntry());
{ sLog.outErrorEventAI("failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, EventId, m_creature->GetEntry()); }
else if (action.summon.target != TARGET_T_SELF && target)
pCreature->AI()->AttackStart(target);
{ pCreature->AI()->AttackStart(target); }
break;
}
case ACTION_T_THREAT_SINGLE_PCT:
if (Unit* target = GetTargetByType(action.threat_single_pct.target, pActionInvoker, pAIEventSender, reportTargetError))
m_creature->GetThreatManager().modifyThreatPercent(target, action.threat_single_pct.percent);
{ m_creature->GetThreatManager().modifyThreatPercent(target, action.threat_single_pct.percent); }
else if (reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_THREAT_SINGLE_PCT(%u), target-type %u", EventId, action.type, action.threat_single_pct.target);
{ sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_THREAT_SINGLE_PCT(%u), target-type %u", EventId, action.type, action.threat_single_pct.target); }
break;
case ACTION_T_THREAT_ALL_PCT:
{
ThreatList const& threatList = m_creature->GetThreatManager().getThreatList();
for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
if (Unit* Temp = m_creature->GetMap()->GetUnit((*i)->getUnitGuid()))
m_creature->GetThreatManager().modifyThreatPercent(Temp, action.threat_all_pct.percent);
{ m_creature->GetThreatManager().modifyThreatPercent(Temp, action.threat_all_pct.percent); }
break;
}
case ACTION_T_QUEST_EVENT:
if (Unit* target = GetTargetByType(action.quest_event.target, pActionInvoker, pAIEventSender, reportTargetError))
{
if (target->GetTypeId() == TYPEID_PLAYER)
((Player*)target)->AreaExploredOrEventHappens(action.quest_event.questId);
{ ((Player*)target)->AreaExploredOrEventHappens(action.quest_event.questId); }
}
else if (reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_QUEST_EVENT(%u), target-type %u", EventId, action.type, action.quest_event.target);
{ sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_QUEST_EVENT(%u), target-type %u", EventId, action.type, action.quest_event.target); }
break;
case ACTION_T_CAST_EVENT:
if (Unit* target = GetTargetByType(action.cast_event.target, pActionInvoker, pAIEventSender, reportTargetError, 0, SELECT_FLAG_PLAYER))
{
if (target->GetTypeId() == TYPEID_PLAYER)
((Player*)target)->CastedCreatureOrGO(action.cast_event.creatureId, m_creature->GetObjectGuid(), action.cast_event.spellId);
{ ((Player*)target)->CastedCreatureOrGO(action.cast_event.creatureId, m_creature->GetObjectGuid(), action.cast_event.spellId); }
}
else if (reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_CST_EVENT(%u), target-type %u", EventId, action.type, action.cast_event.target);
{ sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_CST_EVENT(%u), target-type %u", EventId, action.type, action.cast_event.target); }
break;
case ACTION_T_SET_UNIT_FIELD:
{
@ -769,38 +768,38 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
// not allow modify important for integrity object fields
if (action.set_unit_field.field < OBJECT_END || action.set_unit_field.field >= UNIT_END)
return;
{ return; }
else if (reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SET_UNIT_FIELD(%u), target-type %u", EventId, action.type, action.set_unit_field.target);
{ sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SET_UNIT_FIELD(%u), target-type %u", EventId, action.type, action.set_unit_field.target); }
break;
}
case ACTION_T_SET_UNIT_FLAG:
if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker, pAIEventSender, reportTargetError))
target->SetFlag(UNIT_FIELD_FLAGS, action.unit_flag.value);
{ target->SetFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); }
else if (reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SET_UNIT_FLAG(%u), target-type %u", EventId, action.type, action.unit_flag.target);
{ sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SET_UNIT_FLAG(%u), target-type %u", EventId, action.type, action.unit_flag.target); }
break;
case ACTION_T_REMOVE_UNIT_FLAG:
if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker, pAIEventSender, reportTargetError))
target->RemoveFlag(UNIT_FIELD_FLAGS, action.unit_flag.value);
{ target->RemoveFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); }
else if (reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_REMOVE_UNIT_FLAG(%u), target-type %u", EventId, action.type, action.unit_flag.target);
{ sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_REMOVE_UNIT_FLAG(%u), target-type %u", EventId, action.type, action.unit_flag.target); }
case ACTION_T_AUTO_ATTACK:
m_MeleeEnabled = action.auto_attack.state != 0;
break;
case ACTION_T_COMBAT_MOVEMENT:
// ignore no affect case
if (m_isCombatMovement == (action.combat_movement.state != 0) || m_creature->IsNonMeleeSpellCasted(false))
return;
{ return; }
SetCombatMovement(action.combat_movement.state != 0, true);
if (m_isCombatMovement && action.combat_movement.melee && m_creature->IsInCombat() && m_creature->getVictim())
m_creature->SendMeleeAttackStart(m_creature->getVictim());
{ m_creature->SendMeleeAttackStart(m_creature->getVictim()); }
else if (action.combat_movement.melee && m_creature->IsInCombat() && m_creature->getVictim())
m_creature->SendMeleeAttackStop(m_creature->getVictim());
{ m_creature->SendMeleeAttackStop(m_creature->getVictim()); }
break;
case ACTION_T_SET_PHASE:
m_Phase = action.set_phase.phase;
@ -816,11 +815,11 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
}
else if (new_phase >= MAX_PHASE)
{
sLog.outErrorEventAI("Event %d incremented Phase above %u. Phase mask cannot be used with phases past %u. CreatureEntry = %d", EventId, MAX_PHASE - 1, MAX_PHASE - 1, m_creature->GetEntry());
sLog.outErrorEventAI("Event %d incremented Phase above %u. Phase mask can not be used with phases past %u. CreatureEntry = %d", EventId, MAX_PHASE - 1, MAX_PHASE - 1, m_creature->GetEntry());
m_Phase = MAX_PHASE - 1;
}
else
m_Phase = new_phase;
{ m_Phase = new_phase; }
DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: ACTION_T_INC_PHASE - script %u for %s, phase is now %u", EventId, m_creature->GetGuidStr().c_str(), m_Phase);
break;
@ -840,21 +839,21 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
temp->GroupEventHappens(action.quest_event_all.questId, m_creature);
}
else if (pActionInvoker && pActionInvoker->GetTypeId() == TYPEID_PLAYER)
((Player*)pActionInvoker)->GroupEventHappens(action.quest_event_all.questId, m_creature);
{ ((Player*)pActionInvoker)->GroupEventHappens(action.quest_event_all.questId, m_creature); }
break;
case ACTION_T_CAST_EVENT_ALL:
{
ThreatList const& threatList = m_creature->GetThreatManager().getThreatList();
for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
if (Player* temp = m_creature->GetMap()->GetPlayer((*i)->getUnitGuid()))
temp->CastedCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetObjectGuid(), action.cast_event_all.spellId);
{ temp->CastedCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetObjectGuid(), action.cast_event_all.spellId); }
break;
}
case ACTION_T_REMOVEAURASFROMSPELL:
if (Unit* target = GetTargetByType(action.remove_aura.target, pActionInvoker, pAIEventSender, reportTargetError))
target->RemoveAurasDueToSpell(action.remove_aura.spellId);
{ target->RemoveAurasDueToSpell(action.remove_aura.spellId); }
else if (reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_REMOVEAURASFROMSPELL(%u), target-type %u", EventId, action.type, action.remove_aura.target);
{ sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_REMOVEAURASFROMSPELL(%u), target-type %u", EventId, action.type, action.remove_aura.target); }
break;
case ACTION_T_RANGED_MOVEMENT:
m_attackDistance = (float)action.ranged_movement.distance;
@ -876,16 +875,16 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
break;
case ACTION_T_RANDOM_PHASE_RANGE:
if (action.random_phase_range.phaseMax > action.random_phase_range.phaseMin)
m_Phase = action.random_phase_range.phaseMin + (rnd % (action.random_phase_range.phaseMax - action.random_phase_range.phaseMin));
{ m_Phase = action.random_phase_range.phaseMin + (rnd % (action.random_phase_range.phaseMax - action.random_phase_range.phaseMin)); }
else
sLog.outErrorEventAI("ACTION_T_RANDOM_PHASE_RANGE cannot have Param2 <= Param1. Divide by Zero. Event = %d. CreatureEntry = %d", EventId, m_creature->GetEntry());
{ sLog.outErrorEventAI("ACTION_T_RANDOM_PHASE_RANGE can not have Param2 <= Param1. Divide by Zero. Event = %d. CreatureEntry = %d", EventId, m_creature->GetEntry()); }
break;
case ACTION_T_SUMMON_ID:
{
Unit* target = GetTargetByType(action.summon_id.target, pActionInvoker, pAIEventSender, reportTargetError);
if (!target && reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SUMMON_ID(%u), target-type %u", EventId, action.type, action.summon_id.target);
{ sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SUMMON_ID(%u), target-type %u", EventId, action.type, action.summon_id.target); }
CreatureEventAI_Summon_Map::const_iterator i = sEventAIMgr.GetCreatureEventAISummonMap().find(action.summon_id.spawnId);
if (i == sEventAIMgr.GetCreatureEventAISummonMap().end())
{
@ -900,26 +899,26 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
pCreature = m_creature->SummonCreature(action.summon_id.creatureId, i->second.position_x, i->second.position_y, i->second.position_z, i->second.orientation, TEMPSUMMON_TIMED_OOC_DESPAWN, 0);
if (!pCreature)
sLog.outErrorEventAI("failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, EventId, m_creature->GetEntry());
{ sLog.outErrorEventAI("failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, EventId, m_creature->GetEntry()); }
else if (action.summon_id.target != TARGET_T_SELF && target)
pCreature->AI()->AttackStart(target);
{ pCreature->AI()->AttackStart(target); }
break;
}
case ACTION_T_KILLED_MONSTER:
// first attempt player/group who tapped creature
if (Player* pPlayer = m_creature->GetLootRecipient())
pPlayer->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, m_creature);
{ pPlayer->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, m_creature); }
else
{
// if not available, use pActionInvoker
if (Unit* pTarget = GetTargetByType(action.killed_monster.target, pActionInvoker, pAIEventSender, reportTargetError, 0, SELECT_FLAG_PLAYER))
{
if (Player* pPlayer2 = pTarget->GetCharmerOrOwnerPlayerOrPlayerItself())
pPlayer2->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, m_creature);
{ pPlayer2->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, m_creature); }
}
else if (reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_KILLED_MONSTER(%u), target-type %u", EventId, action.type, action.killed_monster.target);
{ sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_KILLED_MONSTER(%u), target-type %u", EventId, action.type, action.killed_monster.target); }
}
break;
case ACTION_T_SET_INST_DATA:
@ -940,7 +939,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
if (!target)
{
if (reportTargetError)
sLog.outErrorEventAI("Event %d attempt to set instance data64 but Target == NULL. Creature %d", EventId, m_creature->GetEntry());
{ sLog.outErrorEventAI("Event %d attempt to set instance data64 but Target == NULL. Creature %d", EventId, m_creature->GetEntry()); }
return;
}
@ -957,7 +956,6 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
case ACTION_T_UPDATE_TEMPLATE:
if (m_creature->GetEntry() == action.update_template.creatureId)
{
sLog.outErrorEventAI("Event %d ACTION_T_UPDATE_TEMPLATE call with param1 == current entry. Creature %d", EventId, m_creature->GetEntry());
return;
}
@ -967,7 +965,6 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
case ACTION_T_DIE:
if (m_creature->IsDead())
{
sLog.outErrorEventAI("Event %d ACTION_T_DIE on dead creature. Creature %d", EventId, m_creature->GetEntry());
return;
}
@ -996,9 +993,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
case ACTION_T_SET_INVINCIBILITY_HP_LEVEL:
{
if (action.invincibility_hp_level.is_percent)
m_InvinceabilityHpLevel = m_creature->GetMaxHealth() * action.invincibility_hp_level.hp_level / 100;
{ m_InvinceabilityHpLevel = m_creature->GetMaxHealth() * action.invincibility_hp_level.hp_level / 100; }
else
m_InvinceabilityHpLevel = action.invincibility_hp_level.hp_level;
{ m_InvinceabilityHpLevel = action.invincibility_hp_level.hp_level; }
break;
}
case ACTION_T_MOUNT_TO_ENTRY_OR_MODEL:
@ -1016,10 +1013,10 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
}
// if no param1, then use value from param2 (modelId)
else
m_creature->Mount(action.mount.modelId);
{ m_creature->Mount(action.mount.modelId); }
}
else
m_creature->Unmount();
{ m_creature->Unmount(); }
break;
}
@ -1079,11 +1076,11 @@ void CreatureEventAI::JustRespawned() // NOTE that this is
if (i->Event.event_type == EVENT_T_TIMER_GENERIC)
{
if (i->UpdateRepeatTimer(m_creature, i->Event.timer.initialMin, i->Event.timer.initialMax))
i->Enabled = true;
{ i->Enabled = true; }
}
// Handle Spawned Events
else if (SpawnedEventConditionsCheck((*i).Event))
ProcessEvent(*i);
{ ProcessEvent(*i); }
}
}
@ -1099,7 +1096,7 @@ void CreatureEventAI::Reset()
CreatureEventAI_Event const& event = i->Event;
switch (event.event_type)
{
// Reset all out of combat timers
// Reset all out of combat timers
case EVENT_T_TIMER_OOC:
{
if (i->UpdateRepeatTimer(m_creature, event.timer.initialMin, event.timer.initialMax))
@ -1120,7 +1117,7 @@ void CreatureEventAI::JustReachedHome()
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
{
if (i->Event.event_type == EVENT_T_REACHED_HOME)
ProcessEvent(*i);
{ ProcessEvent(*i); }
}
Reset();
@ -1134,7 +1131,7 @@ void CreatureEventAI::EnterEvadeMode()
// only alive creatures that are not on transport can return to home position
if (m_creature->IsAlive() && !m_creature->IsBoarded())
m_creature->GetMotionMaster()->MoveTargetedHome();
{ m_creature->GetMotionMaster()->MoveTargetedHome(); }
m_creature->SetLootRecipient(NULL);
@ -1142,7 +1139,7 @@ void CreatureEventAI::EnterEvadeMode()
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
{
if (i->Event.event_type == EVENT_T_EVADE)
ProcessEvent(*i);
{ ProcessEvent(*i); }
}
}
@ -1154,17 +1151,17 @@ void CreatureEventAI::JustDied(Unit* killer)
{
// Send Zone Under Attack message to the LocalDefense and WorldDefense Channels
if (Player* pKiller = killer->GetCharmerOrOwnerPlayerOrPlayerItself())
m_creature->SendZoneUnderAttackMessage(pKiller);
{ m_creature->SendZoneUnderAttackMessage(pKiller); }
}
if (m_throwAIEventMask & (1 << AI_EVENT_JUST_DIED))
SendAIEventAround(AI_EVENT_JUST_DIED, killer, 0, AIEVENT_DEFAULT_THROW_RADIUS);
{ SendAIEventAround(AI_EVENT_JUST_DIED, killer, 0, AIEVENT_DEFAULT_THROW_RADIUS); }
// Handle On Death events
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
{
if (i->Event.event_type == EVENT_T_DEATH)
ProcessEvent(*i, killer);
{ ProcessEvent(*i, killer); }
}
// reset phase after any death state events
@ -1174,12 +1171,12 @@ void CreatureEventAI::JustDied(Unit* killer)
void CreatureEventAI::KilledUnit(Unit* victim)
{
if (victim->GetTypeId() != TYPEID_PLAYER)
return;
{ return; }
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
{
if (i->Event.event_type == EVENT_T_KILL)
ProcessEvent(*i, victim);
{ ProcessEvent(*i, victim); }
}
}
@ -1188,7 +1185,7 @@ void CreatureEventAI::JustSummoned(Creature* pUnit)
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
{
if (i->Event.event_type == EVENT_T_SUMMONED_UNIT)
ProcessEvent(*i, pUnit);
{ ProcessEvent(*i, pUnit); }
}
}
@ -1197,7 +1194,7 @@ void CreatureEventAI::SummonedCreatureJustDied(Creature* pUnit)
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
{
if (i->Event.event_type == EVENT_T_SUMMONED_JUST_DIED)
ProcessEvent(*i, pUnit);
{ ProcessEvent(*i, pUnit); }
}
}
@ -1206,7 +1203,7 @@ void CreatureEventAI::SummonedCreatureDespawn(Creature* pUnit)
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
{
if (i->Event.event_type == EVENT_T_SUMMONED_JUST_DESPAWN)
ProcessEvent(*i, pUnit);
{ ProcessEvent(*i, pUnit); }
}
}
@ -1217,8 +1214,8 @@ void CreatureEventAI::ReceiveAIEvent(AIEventType eventType, Creature* pSender, U
for (CreatureEventAIList::iterator itr = m_CreatureEventAIList.begin(); itr != m_CreatureEventAIList.end(); ++itr)
{
if (itr->Event.event_type == EVENT_T_RECEIVE_AI_EVENT &&
itr->Event.receiveAIEvent.eventType == eventType && (!itr->Event.receiveAIEvent.senderEntry || itr->Event.receiveAIEvent.senderEntry == pSender->GetEntry()))
ProcessEvent(*itr, pInvoker, pSender);
itr->Event.receiveAIEvent.eventType == eventType && (!itr->Event.receiveAIEvent.senderEntry || itr->Event.receiveAIEvent.senderEntry == pSender->GetEntry()))
{ ProcessEvent(*itr, pInvoker, pSender); }
}
}
@ -1234,12 +1231,12 @@ void CreatureEventAI::EnterCombat(Unit* enemy)
i->Enabled = true;
ProcessEvent(*i, enemy);
break;
// Reset all in combat timers
// Reset all in combat timers
case EVENT_T_TIMER_IN_COMBAT:
if (i->UpdateRepeatTimer(m_creature, event.timer.initialMin, event.timer.initialMax))
i->Enabled = true;
break;
// All normal events need to be re-enabled and their time set to 0
// All normal events need to be re-enabled and their time set to 0
default:
i->Enabled = true;
i->Time = 0;
@ -1254,7 +1251,7 @@ void CreatureEventAI::EnterCombat(Unit* enemy)
void CreatureEventAI::AttackStart(Unit* who)
{
if (!who || !m_creature->CanAttackByItself())
return;
{ return; }
if (m_creature->Attack(who, m_MeleeEnabled))
{
@ -1269,7 +1266,7 @@ void CreatureEventAI::AttackStart(Unit* who)
void CreatureEventAI::MoveInLineOfSight(Unit* who)
{
if (!who)
return;
{ return; }
// Check for OOC LOS Event
if (m_HasOOCLoSEvent && !m_creature->getVictim())
@ -1294,13 +1291,13 @@ void CreatureEventAI::MoveInLineOfSight(Unit* who)
}
if (m_creature->IsCivilian() || m_creature->IsNeutralToAll())
return;
{ return; }
if (m_creature->CanInitiateAttack() && who->IsTargetableForAttack() &&
m_creature->IsHostileTo(who) && who->isInAccessablePlaceFor(m_creature))
m_creature->IsHostileTo(who) && who->isInAccessablePlaceFor(m_creature))
{
if (!m_creature->CanFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
return;
{ return; }
float attackRadius = m_creature->GetAttackDistance(who);
if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who))
@ -1326,7 +1323,7 @@ void CreatureEventAI::SpellHit(Unit* pUnit, const SpellEntry* pSpell)
// If spell id matches (or no spell id) & if spell school matches (or no spell school)
if (!i->Event.spell_hit.spellId || pSpell->Id == i->Event.spell_hit.spellId)
if (pSpell->SchoolMask & i->Event.spell_hit.schoolMask)
ProcessEvent(*i, pUnit);
{ ProcessEvent(*i, pUnit); }
}
void CreatureEventAI::UpdateAI(const uint32 diff)
@ -1347,7 +1344,7 @@ void CreatureEventAI::UpdateAI(const uint32 diff)
{
if (i->Time > m_EventDiff)
{
// Do not decrement timers if event cannot trigger in this phase
// Do not decrement timers if event can not trigger in this phase
if (!(i->Event.event_inverse_phase_mask & (1 << m_Phase)))
i->Time -= m_EventDiff;
}
@ -1433,52 +1430,52 @@ inline Unit* CreatureEventAI::GetTargetByType(uint32 Target, Unit* pActionInvoke
case TARGET_T_HOSTILE:
resTarget = m_creature->getVictim();
if (!resTarget)
isError = true;
{ isError = true; }
return resTarget;
case TARGET_T_HOSTILE_SECOND_AGGRO:
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_TOPAGGRO, 1, forSpellId, selectFlags);
if (!resTarget && ((forSpellId == 0 && selectFlags == 0 && m_creature->GetThreatManager().getThreatList().size() > 1) || m_creature->GetThreatManager().getThreatList().empty()))
isError = true;
{ isError = true; }
return resTarget;
case TARGET_T_HOSTILE_LAST_AGGRO:
case TARGET_T_HOSTILE_LAST_AGGRO:
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_BOTTOMAGGRO, 0, forSpellId, selectFlags);
if (!resTarget && m_creature->GetThreatManager().getThreatList().empty())
isError = true;
{ isError = true; }
return resTarget;
case TARGET_T_HOSTILE_RANDOM:
case TARGET_T_HOSTILE_RANDOM:
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, forSpellId, selectFlags);
if (!resTarget && m_creature->GetThreatManager().getThreatList().empty())
isError = true;
{ isError = true; }
return resTarget;
case TARGET_T_HOSTILE_RANDOM_NOT_TOP:
case TARGET_T_HOSTILE_RANDOM_NOT_TOP:
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1, forSpellId, selectFlags);
if (!resTarget && ((forSpellId == 0 && selectFlags == 0 && m_creature->GetThreatManager().getThreatList().size() > 1) || m_creature->GetThreatManager().getThreatList().empty()))
isError = true;
{ isError = true; }
return resTarget;
case TARGET_T_HOSTILE_RANDOM_PLAYER:
case TARGET_T_HOSTILE_RANDOM_PLAYER:
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, forSpellId, SELECT_FLAG_PLAYER | selectFlags);
if (!resTarget)
isError = true;
{ isError = true; }
return resTarget;
case TARGET_T_HOSTILE_RANDOM_NOT_TOP_PLAYER:
case TARGET_T_HOSTILE_RANDOM_NOT_TOP_PLAYER:
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1, forSpellId, SELECT_FLAG_PLAYER | selectFlags);
if (!resTarget && ((forSpellId == 0 && selectFlags == 0 && m_creature->GetThreatManager().getThreatList().size() > 1) || m_creature->GetThreatManager().getThreatList().empty()))
isError = true;
{ isError = true; }
return resTarget;
case TARGET_T_ACTION_INVOKER:
case TARGET_T_ACTION_INVOKER:
if (!pActionInvoker)
isError = true;
{ isError = true; }
return pActionInvoker;
case TARGET_T_ACTION_INVOKER_OWNER:
case TARGET_T_ACTION_INVOKER_OWNER:
resTarget = pActionInvoker ? pActionInvoker->GetCharmerOrOwnerOrSelf() : NULL;
if (!resTarget)
isError = true;
{ isError = true; }
return resTarget;
case TARGET_T_EVENT_SENDER:
case TARGET_T_EVENT_SENDER:
if (!pAIEventSender)
isError = true;
{ isError = true; }
return pAIEventSender;
default:
default:
isError = true;
return NULL;
};
@ -1493,7 +1490,7 @@ Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff)
/*
typedef TYPELIST_4(GameObject, Creature*except pets*, DynamicObject, Corpse*Bones*) AllGridObjectTypes;
This means that if we only search grid then we cannot possibly return pets or players so this is safe
This means that if we only search grid then we can not possibly return pets or players so this is safe
*/
Cell::VisitGridObjects(m_creature, searcher, range);
return pUnit;
@ -1542,9 +1539,9 @@ void CreatureEventAI::DamageTaken(Unit* dealer, uint32& damage)
if (m_InvinceabilityHpLevel > 0 && m_creature->GetHealth() < m_InvinceabilityHpLevel + damage)
{
if (m_creature->GetHealth() <= m_InvinceabilityHpLevel)
damage = 0;
{ damage = 0; }
else
damage = m_creature->GetHealth() - m_InvinceabilityHpLevel;
{ damage = m_creature->GetHealth() - m_InvinceabilityHpLevel; }
}
uint32 step = m_throwAIEventStep != 100 ? m_throwAIEventStep : 0;
@ -1556,7 +1553,7 @@ void CreatureEventAI::DamageTaken(Unit* dealer, uint32& damage)
AIEventType sendEvent[HEALTH_STEPS] = { AI_EVENT_LOST_SOME_HEALTH, AI_EVENT_LOST_HEALTH, AI_EVENT_CRITICAL_HEALTH };
if (newHealthPercent > healthSteps[step])
return; // Not reached the next mark
{ return; } // Not reached the next mark
// search for highest reached mark (with actual event attached)
for (uint32 i = HEALTH_STEPS - 1; i > step; --i)
@ -1569,7 +1566,7 @@ void CreatureEventAI::DamageTaken(Unit* dealer, uint32& damage)
}
if (m_throwAIEventMask & (1 << sendEvent[step]))
SendAIEventAround(sendEvent[step], dealer, 0, AIEVENT_DEFAULT_THROW_RADIUS);
{ SendAIEventAround(sendEvent[step], dealer, 0, AIEVENT_DEFAULT_THROW_RADIUS); }
m_throwAIEventStep = step + 1;
}
@ -1578,12 +1575,12 @@ void CreatureEventAI::DamageTaken(Unit* dealer, uint32& damage)
void CreatureEventAI::HealedBy(Unit* healer, uint32& healedAmount)
{
if (m_throwAIEventStep == 100)
return;
{ return; }
if (m_creature->GetHealth() + healedAmount >= m_creature->GetMaxHealth())
{
if (m_throwAIEventMask & (1 << AI_EVENT_GOT_FULL_HEALTH))
SendAIEventAround(AI_EVENT_GOT_FULL_HEALTH, healer, 0, AIEVENT_DEFAULT_THROW_RADIUS);
{ SendAIEventAround(AI_EVENT_GOT_FULL_HEALTH, healer, 0, AIEVENT_DEFAULT_THROW_RADIUS); }
m_throwAIEventStep = 100;
}
}
@ -1591,7 +1588,7 @@ void CreatureEventAI::HealedBy(Unit* healer, uint32& healedAmount)
bool CreatureEventAI::SpawnedEventConditionsCheck(CreatureEventAI_Event const& event)
{
if (event.event_type != EVENT_T_SPAWNED)
return false;
{ return false; }
switch (event.spawned.condition)
{