mirror of
https://github.com/mangosfour/server.git
synced 2025-12-27 01:37:04 +00:00
Project tidy up and sync
This commit is contained in:
parent
49fe617b55
commit
5531a0087d
44 changed files with 484 additions and 427 deletions
|
|
@ -110,7 +110,9 @@ 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())
|
||||
{
|
||||
|
|
@ -120,11 +122,11 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c),
|
|||
}
|
||||
}
|
||||
else if (IsEventFlagsFitForNormalMap(i->event_flags))
|
||||
++events_count;
|
||||
{ ++events_count; }
|
||||
}
|
||||
// EventMap had events but they were not added because they must be for instance
|
||||
if (events_count == 0)
|
||||
sLog.outErrorEventAI("Creature %u has events but no events added to list because of instance flags (spawned in map %u, difficulty %u).", m_creature->GetEntry(), m_creature->GetMapId(), m_creature->GetMap()->GetDifficulty());
|
||||
{ sLog.outErrorEventAI("Creature %u has events but no events added to list because of instance flags (spawned in map %u, difficulty %u).", m_creature->GetEntry(), m_creature->GetMapId(), m_creature->GetMap()->GetDifficulty()); }
|
||||
else
|
||||
{
|
||||
m_CreatureEventAIList.reserve(events_count);
|
||||
|
|
@ -133,29 +135,33 @@ 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())
|
||||
{
|
||||
if ((1 << (m_creature->GetMap()->GetSpawnMode() + 1)) & i->event_flags)
|
||||
storeEvent = true;
|
||||
{ storeEvent = true; }
|
||||
}
|
||||
else if (IsEventFlagsFitForNormalMap(i->event_flags))
|
||||
storeEvent = true;
|
||||
{ storeEvent = true; }
|
||||
|
||||
if (storeEvent)
|
||||
{
|
||||
m_CreatureEventAIList.push_back(CreatureEventAIHolder(*i));
|
||||
// Cache for fast use
|
||||
if (i->event_type == EVENT_T_OOC_LOS)
|
||||
{
|
||||
m_HasOOCLoSEvent = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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 \
|
||||
|
|
@ -344,6 +350,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
|
|||
// We don't really care about the whole list, just return first available
|
||||
pActionInvoker = *(pList.begin());
|
||||
|
||||
LOG_PROCESS_EVENT;
|
||||
// Repeat Timers
|
||||
pHolder.UpdateRepeatTimer(m_creature, event.friendly_is_cc.repeatMin, event.friendly_is_cc.repeatMax);
|
||||
break;
|
||||
|
|
@ -400,7 +407,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
|
|||
case EVENT_T_AURA:
|
||||
{
|
||||
if (!m_creature->IsInCombat())
|
||||
return false;
|
||||
{ return false; }
|
||||
|
||||
SpellAuraHolder* holder = m_creature->GetSpellAuraHolder(event.buffed.spellId);
|
||||
if (!holder || holder->GetStackAmount() < event.buffed.amount)
|
||||
|
|
@ -428,7 +435,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
|
|||
case EVENT_T_MISSING_AURA:
|
||||
{
|
||||
if (!m_creature->IsInCombat())
|
||||
return false;
|
||||
{ return false; }
|
||||
|
||||
SpellAuraHolder* holder = m_creature->GetSpellAuraHolder(event.buffed.spellId);
|
||||
if (holder && holder->GetStackAmount() >= event.buffed.amount)
|
||||
|
|
@ -459,12 +466,12 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
|
|||
{
|
||||
if (!m_creature->IsInCombat() || !m_creature->GetMaxPower(POWER_ENERGY))
|
||||
{ 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; }
|
||||
|
||||
|
||||
LOG_PROCESS_EVENT;
|
||||
// Repeat Timers
|
||||
pHolder.UpdateRepeatTimer(m_creature, event.percent_range.repeatMin, event.percent_range.repeatMax);
|
||||
|
|
@ -526,7 +533,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)
|
||||
if (action.type == ACTION_T_NONE) //0
|
||||
{ return; }
|
||||
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: Process action %u (script %u) triggered for %s (invoked by %s)",
|
||||
|
|
@ -535,8 +542,8 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
bool reportTargetError = false;
|
||||
switch (action.type)
|
||||
{
|
||||
case ACTION_T_TEXT:
|
||||
case ACTION_T_CHANCED_TEXT:
|
||||
case ACTION_T_TEXT: //1
|
||||
case ACTION_T_CHANCED_TEXT: //44
|
||||
{
|
||||
if (!action.text.TextId[0])
|
||||
{ return; }
|
||||
|
|
@ -546,19 +553,19 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
if (action.type == ACTION_T_TEXT)
|
||||
{
|
||||
if (action.text.TextId[1] && action.text.TextId[2])
|
||||
textId = action.text.TextId[rnd % 3];
|
||||
{ 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)
|
||||
{
|
||||
if (action.chanced_text.TextId[0] && action.chanced_text.TextId[1])
|
||||
textId = action.chanced_text.TextId[rnd % 2];
|
||||
{ textId = action.chanced_text.TextId[rnd % 2]; }
|
||||
else
|
||||
{ textId = action.chanced_text.TextId[0]; }
|
||||
{ textId = action.chanced_text.TextId[0]; }
|
||||
}
|
||||
|
||||
if (textId)
|
||||
|
|
@ -588,7 +595,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
}
|
||||
break;
|
||||
}
|
||||
case ACTION_T_SET_FACTION:
|
||||
case ACTION_T_SET_FACTION: //2
|
||||
{
|
||||
if (action.set_faction.factionId)
|
||||
{ m_creature->SetFactionTemporary(action.set_faction.factionId, action.set_faction.factionFlags); }
|
||||
|
|
@ -597,7 +604,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
|
||||
break;
|
||||
}
|
||||
case ACTION_T_MORPH_TO_ENTRY_OR_MODEL:
|
||||
case ACTION_T_MORPH_TO_ENTRY_OR_MODEL: //3
|
||||
{
|
||||
if (action.morph.creatureId || action.morph.modelId)
|
||||
{
|
||||
|
|
@ -618,30 +625,31 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
{ m_creature->DeMorph(); }
|
||||
break;
|
||||
}
|
||||
case ACTION_T_SOUND:
|
||||
case ACTION_T_SOUND: //4
|
||||
m_creature->PlayDirectSound(action.sound.soundId);
|
||||
break;
|
||||
case ACTION_T_EMOTE:
|
||||
case ACTION_T_EMOTE: //5
|
||||
m_creature->HandleEmote(action.emote.emoteId);
|
||||
break;
|
||||
case ACTION_T_RANDOM_SOUND:
|
||||
case ACTION_T_RANDOM_SOUND: //9
|
||||
{
|
||||
int32 temp = GetRandActionParam(rnd, action.random_sound.soundId1, action.random_sound.soundId2, action.random_sound.soundId3);
|
||||
if (temp >= 0)
|
||||
{ m_creature->PlayDirectSound(temp); }
|
||||
break;
|
||||
}
|
||||
case ACTION_T_RANDOM_EMOTE:
|
||||
case ACTION_T_RANDOM_EMOTE: //10
|
||||
{
|
||||
int32 temp = GetRandActionParam(rnd, action.random_emote.emoteId1, action.random_emote.emoteId2, action.random_emote.emoteId3);
|
||||
if (temp >= 0)
|
||||
{ m_creature->HandleEmote(temp); }
|
||||
break;
|
||||
}
|
||||
case ACTION_T_CAST:
|
||||
case ACTION_T_CAST: //11
|
||||
{
|
||||
uint32 selectFlags = 0;
|
||||
uint32 spellId = 0;
|
||||
|
||||
if (!(action.cast.castFlags & (CAST_TRIGGERED | CAST_FORCE_CAST | CAST_FORCE_TARGET_SELF)))
|
||||
{
|
||||
spellId = action.cast.spellId;
|
||||
|
|
@ -711,7 +719,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
|
||||
break;
|
||||
}
|
||||
case ACTION_T_SUMMON:
|
||||
case ACTION_T_SUMMON: //12
|
||||
{
|
||||
Unit* target = GetTargetByType(action.summon.target, pActionInvoker, pAIEventSender, reportTargetError);
|
||||
if (!target && reportTargetError)
|
||||
|
|
@ -730,13 +738,13 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
{ pCreature->AI()->AttackStart(target); }
|
||||
break;
|
||||
}
|
||||
case ACTION_T_THREAT_SINGLE_PCT:
|
||||
case ACTION_T_THREAT_SINGLE_PCT: //13
|
||||
if (Unit* target = GetTargetByType(action.threat_single_pct.target, pActionInvoker, pAIEventSender, reportTargetError))
|
||||
{ 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); }
|
||||
break;
|
||||
case ACTION_T_THREAT_ALL_PCT:
|
||||
case ACTION_T_THREAT_ALL_PCT: //14
|
||||
{
|
||||
ThreatList const& threatList = m_creature->GetThreatManager().getThreatList();
|
||||
for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
|
||||
|
|
@ -744,7 +752,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
{ m_creature->GetThreatManager().modifyThreatPercent(Temp, action.threat_all_pct.percent); }
|
||||
break;
|
||||
}
|
||||
case ACTION_T_QUEST_EVENT:
|
||||
case ACTION_T_QUEST_EVENT: //15
|
||||
if (Unit* target = GetTargetByType(action.quest_event.target, pActionInvoker, pAIEventSender, reportTargetError))
|
||||
{
|
||||
if (target->GetTypeId() == TYPEID_PLAYER)
|
||||
|
|
@ -753,7 +761,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
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); }
|
||||
break;
|
||||
case ACTION_T_CAST_EVENT:
|
||||
case ACTION_T_CAST_EVENT: //16
|
||||
if (Unit* target = GetTargetByType(action.cast_event.target, pActionInvoker, pAIEventSender, reportTargetError, 0, SELECT_FLAG_PLAYER))
|
||||
{
|
||||
if (target->GetTypeId() == TYPEID_PLAYER)
|
||||
|
|
@ -762,7 +770,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
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); }
|
||||
break;
|
||||
case ACTION_T_SET_UNIT_FIELD:
|
||||
case ACTION_T_SET_UNIT_FIELD: //17
|
||||
{
|
||||
Unit* target = GetTargetByType(action.set_unit_field.target, pActionInvoker, pAIEventSender, reportTargetError);
|
||||
|
||||
|
|
@ -775,21 +783,21 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
|
||||
break;
|
||||
}
|
||||
case ACTION_T_SET_UNIT_FLAG:
|
||||
case ACTION_T_SET_UNIT_FLAG: //18
|
||||
if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker, pAIEventSender, reportTargetError))
|
||||
{ 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); }
|
||||
break;
|
||||
case ACTION_T_REMOVE_UNIT_FLAG:
|
||||
case ACTION_T_REMOVE_UNIT_FLAG: //19
|
||||
if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker, pAIEventSender, reportTargetError))
|
||||
{ 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); }
|
||||
case ACTION_T_AUTO_ATTACK:
|
||||
case ACTION_T_AUTO_ATTACK: //20
|
||||
m_MeleeEnabled = action.auto_attack.state != 0;
|
||||
break;
|
||||
case ACTION_T_COMBAT_MOVEMENT:
|
||||
case ACTION_T_COMBAT_MOVEMENT: //21
|
||||
// ignore no affect case
|
||||
if (m_isCombatMovement == (action.combat_movement.state != 0) || m_creature->IsNonMeleeSpellCasted(false))
|
||||
{ return; }
|
||||
|
|
@ -801,11 +809,11 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
else if (action.combat_movement.melee && m_creature->IsInCombat() && m_creature->getVictim())
|
||||
{ m_creature->SendMeleeAttackStop(m_creature->getVictim()); }
|
||||
break;
|
||||
case ACTION_T_SET_PHASE:
|
||||
case ACTION_T_SET_PHASE: //22
|
||||
m_Phase = action.set_phase.phase;
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: ACTION_T_SET_PHASE - script %u for %s, phase is now %u", EventId, m_creature->GetGuidStr().c_str(), m_Phase);
|
||||
break;
|
||||
case ACTION_T_INC_PHASE:
|
||||
case ACTION_T_INC_PHASE: //23
|
||||
{
|
||||
int32 new_phase = int32(m_Phase) + action.set_inc_phase.step;
|
||||
if (new_phase < 0)
|
||||
|
|
@ -824,13 +832,13 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
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;
|
||||
}
|
||||
case ACTION_T_EVADE:
|
||||
case ACTION_T_EVADE: //24
|
||||
EnterEvadeMode();
|
||||
break;
|
||||
case ACTION_T_FLEE_FOR_ASSIST:
|
||||
case ACTION_T_FLEE_FOR_ASSIST: //25
|
||||
m_creature->DoFleeToGetAssistance();
|
||||
break;
|
||||
case ACTION_T_QUEST_EVENT_ALL:
|
||||
case ACTION_T_QUEST_EVENT_ALL: //26
|
||||
if (action.quest_event_all.useThreatList)
|
||||
{
|
||||
ThreatList const& threatList = m_creature->GetThreatManager().getThreatList();
|
||||
|
|
@ -841,7 +849,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
else if (pActionInvoker && pActionInvoker->GetTypeId() == TYPEID_PLAYER)
|
||||
{ ((Player*)pActionInvoker)->GroupEventHappens(action.quest_event_all.questId, m_creature); }
|
||||
break;
|
||||
case ACTION_T_CAST_EVENT_ALL:
|
||||
case ACTION_T_CAST_EVENT_ALL: //27
|
||||
{
|
||||
ThreatList const& threatList = m_creature->GetThreatManager().getThreatList();
|
||||
for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
|
||||
|
|
@ -849,13 +857,13 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
{ temp->CastedCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetObjectGuid(), action.cast_event_all.spellId); }
|
||||
break;
|
||||
}
|
||||
case ACTION_T_REMOVEAURASFROMSPELL:
|
||||
case ACTION_T_REMOVEAURASFROMSPELL: //28
|
||||
if (Unit* target = GetTargetByType(action.remove_aura.target, pActionInvoker, pAIEventSender, reportTargetError))
|
||||
{ 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); }
|
||||
break;
|
||||
case ACTION_T_RANGED_MOVEMENT:
|
||||
case ACTION_T_RANGED_MOVEMENT: //29
|
||||
m_attackDistance = (float)action.ranged_movement.distance;
|
||||
m_attackAngle = action.ranged_movement.angle / 180.0f * M_PI_F;
|
||||
|
||||
|
|
@ -869,17 +877,17 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
}
|
||||
}
|
||||
break;
|
||||
case ACTION_T_RANDOM_PHASE:
|
||||
case ACTION_T_RANDOM_PHASE: //30
|
||||
m_Phase = GetRandActionParam(rnd, action.random_phase.phase1, action.random_phase.phase2, action.random_phase.phase3);
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: ACTION_T_RANDOM_PHASE - script %u for %s, phase is now %u", EventId, m_creature->GetGuidStr().c_str(), m_Phase);
|
||||
break;
|
||||
case ACTION_T_RANDOM_PHASE_RANGE:
|
||||
case ACTION_T_RANDOM_PHASE_RANGE: //31
|
||||
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)); }
|
||||
else
|
||||
{ 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:
|
||||
case ACTION_T_SUMMON_ID: //32
|
||||
{
|
||||
Unit* target = GetTargetByType(action.summon_id.target, pActionInvoker, pAIEventSender, reportTargetError);
|
||||
if (!target && reportTargetError)
|
||||
|
|
@ -894,9 +902,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
|
||||
Creature* pCreature = NULL;
|
||||
if ((*i).second.SpawnTimeSecs)
|
||||
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_OR_DEAD_DESPAWN, i->second.SpawnTimeSecs);
|
||||
{ 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_OR_DEAD_DESPAWN, i->second.SpawnTimeSecs); }
|
||||
else
|
||||
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);
|
||||
{ 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()); }
|
||||
|
|
@ -905,7 +913,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
|
||||
break;
|
||||
}
|
||||
case ACTION_T_KILLED_MONSTER:
|
||||
case ACTION_T_KILLED_MONSTER: //33
|
||||
// first attempt player/group who tapped creature
|
||||
if (Player* pPlayer = m_creature->GetLootRecipient())
|
||||
{ pPlayer->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, m_creature); }
|
||||
|
|
@ -921,7 +929,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
{ 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:
|
||||
case ACTION_T_SET_INST_DATA: //34
|
||||
{
|
||||
InstanceData* pInst = m_creature->GetInstanceData();
|
||||
if (!pInst)
|
||||
|
|
@ -933,7 +941,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
pInst->SetData(action.set_inst_data.field, action.set_inst_data.value);
|
||||
break;
|
||||
}
|
||||
case ACTION_T_SET_INST_DATA64:
|
||||
case ACTION_T_SET_INST_DATA64: //35
|
||||
{
|
||||
Unit* target = GetTargetByType(action.set_inst_data64.target, pActionInvoker, pAIEventSender, reportTargetError);
|
||||
if (!target)
|
||||
|
|
@ -953,7 +961,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
pInst->SetData64(action.set_inst_data64.field, target->GetObjectGuid().GetRawValue());
|
||||
break;
|
||||
}
|
||||
case ACTION_T_UPDATE_TEMPLATE:
|
||||
case ACTION_T_UPDATE_TEMPLATE: //36
|
||||
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());
|
||||
|
|
@ -962,7 +970,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
|
||||
m_creature->UpdateEntry(action.update_template.creatureId, action.update_template.team ? HORDE : ALLIANCE);
|
||||
break;
|
||||
case ACTION_T_DIE:
|
||||
case ACTION_T_DIE: //37
|
||||
if (m_creature->IsDead())
|
||||
{
|
||||
sLog.outErrorEventAI("Event %d ACTION_T_DIE on dead creature. Creature %d", EventId, m_creature->GetEntry());
|
||||
|
|
@ -970,27 +978,27 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
}
|
||||
m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
|
||||
break;
|
||||
case ACTION_T_ZONE_COMBAT_PULSE:
|
||||
case ACTION_T_ZONE_COMBAT_PULSE: //38
|
||||
{
|
||||
m_creature->SetInCombatWithZone();
|
||||
break;
|
||||
}
|
||||
case ACTION_T_CALL_FOR_HELP:
|
||||
case ACTION_T_CALL_FOR_HELP: //39
|
||||
{
|
||||
m_creature->CallForHelp((float)action.call_for_help.radius);
|
||||
break;
|
||||
}
|
||||
case ACTION_T_SET_SHEATH:
|
||||
case ACTION_T_SET_SHEATH: //40
|
||||
{
|
||||
m_creature->SetSheath(SheathState(action.set_sheath.sheath));
|
||||
break;
|
||||
}
|
||||
case ACTION_T_FORCE_DESPAWN:
|
||||
case ACTION_T_FORCE_DESPAWN: //41
|
||||
{
|
||||
m_creature->ForcedDespawn(action.forced_despawn.msDelay);
|
||||
break;
|
||||
}
|
||||
case ACTION_T_SET_INVINCIBILITY_HP_LEVEL:
|
||||
case ACTION_T_SET_INVINCIBILITY_HP_LEVEL: //42
|
||||
{
|
||||
if (action.invincibility_hp_level.is_percent)
|
||||
{ m_InvinceabilityHpLevel = m_creature->GetMaxHealth() * action.invincibility_hp_level.hp_level / 100; }
|
||||
|
|
@ -998,7 +1006,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
{ m_InvinceabilityHpLevel = action.invincibility_hp_level.hp_level; }
|
||||
break;
|
||||
}
|
||||
case ACTION_T_MOUNT_TO_ENTRY_OR_MODEL:
|
||||
case ACTION_T_MOUNT_TO_ENTRY_OR_MODEL: //43
|
||||
{
|
||||
if (action.mount.creatureId || action.mount.modelId)
|
||||
{
|
||||
|
|
@ -1020,34 +1028,34 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
|
||||
break;
|
||||
}
|
||||
case ACTION_T_THROW_AI_EVENT:
|
||||
case ACTION_T_THROW_AI_EVENT: //45
|
||||
{
|
||||
SendAIEventAround(AIEventType(action.throwEvent.eventType), pActionInvoker, 0, action.throwEvent.radius);
|
||||
break;
|
||||
}
|
||||
case ACTION_T_SET_THROW_MASK:
|
||||
case ACTION_T_SET_THROW_MASK: //46
|
||||
{
|
||||
m_throwAIEventMask = action.setThrowMask.eventTypeMask;
|
||||
break;
|
||||
}
|
||||
case ACTION_T_SET_STAND_STATE:
|
||||
case ACTION_T_SET_STAND_STATE: //47
|
||||
{
|
||||
m_creature->SetStandState(action.setStandState.standState);
|
||||
break;
|
||||
}
|
||||
case ACTION_T_CHANGE_MOVEMENT:
|
||||
case ACTION_T_CHANGE_MOVEMENT: //48
|
||||
{
|
||||
switch (action.changeMovement.movementType)
|
||||
{
|
||||
case IDLE_MOTION_TYPE:
|
||||
m_creature->GetMotionMaster()->MoveIdle();
|
||||
break;
|
||||
case RANDOM_MOTION_TYPE:
|
||||
m_creature->GetMotionMaster()->MoveRandomAroundPoint(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), float(action.changeMovement.wanderDistance));
|
||||
break;
|
||||
case WAYPOINT_MOTION_TYPE:
|
||||
m_creature->GetMotionMaster()->MoveWaypoint();
|
||||
break;
|
||||
case IDLE_MOTION_TYPE:
|
||||
m_creature->GetMotionMaster()->MoveIdle();
|
||||
break;
|
||||
case RANDOM_MOTION_TYPE:
|
||||
m_creature->GetMotionMaster()->MoveRandomAroundPoint(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), float(action.changeMovement.wanderDistance));
|
||||
break;
|
||||
case WAYPOINT_MOTION_TYPE:
|
||||
m_creature->GetMotionMaster()->MoveWaypoint();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -1104,10 +1112,10 @@ void CreatureEventAI::Reset()
|
|||
break;
|
||||
}
|
||||
default:
|
||||
// TODO: enable below code line / verify this is correct to enable events previously disabled (ex. aggro yell), instead of enable this in void Aggro()
|
||||
//i->Enabled = true;
|
||||
//i->Time = 0;
|
||||
break;
|
||||
// TODO: enable below code line / verify this is correct to enable events previously disabled (ex. aggro yell), instead of enable this in void Aggro()
|
||||
//i->Enabled = true;
|
||||
//i->Time = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1234,7 +1242,7 @@ void CreatureEventAI::EnterCombat(Unit* enemy)
|
|||
// 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;
|
||||
{ i->Enabled = true; }
|
||||
break;
|
||||
// All normal events need to be re-enabled and their time set to 0
|
||||
default:
|
||||
|
|
@ -1280,11 +1288,11 @@ void CreatureEventAI::MoveInLineOfSight(Unit* who)
|
|||
|
||||
// if friendly event && who is not hostile OR hostile event && who is hostile
|
||||
if ((itr->Event.ooc_los.noHostile && !m_creature->IsHostileTo(who)) ||
|
||||
((!itr->Event.ooc_los.noHostile) && m_creature->IsHostileTo(who)))
|
||||
((!itr->Event.ooc_los.noHostile) && m_creature->IsHostileTo(who)))
|
||||
{
|
||||
// if range is ok and we are actually in LOS
|
||||
if (m_creature->IsWithinDistInMap(who, fMaxAllowedRange) && m_creature->IsWithinLOSInMap(who))
|
||||
ProcessEvent(*itr, who);
|
||||
{ ProcessEvent(*itr, who); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1344,7 +1352,7 @@ void CreatureEventAI::UpdateAI(const uint32 diff)
|
|||
{
|
||||
if (i->Time > m_EventDiff)
|
||||
{
|
||||
// Do not decrement timers if event can not trigger in this phase
|
||||
// Do not decrement timers if event cannot trigger in this phase
|
||||
if (!(i->Event.event_inverse_phase_mask & (1 << m_Phase)))
|
||||
i->Time -= m_EventDiff;
|
||||
}
|
||||
|
|
@ -1388,7 +1396,7 @@ void CreatureEventAI::UpdateAI(const uint32 diff)
|
|||
}
|
||||
else if (m_MeleeEnabled && m_creature->CanReachWithMeleeAttack(victim)
|
||||
&& !(m_creature->GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_NO_MELEE))
|
||||
DoMeleeAttackIfReady();
|
||||
{ DoMeleeAttackIfReady(); }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1520,7 +1528,7 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote)
|
|||
if (itr->Event.event_type == EVENT_T_RECEIVE_EMOTE)
|
||||
{
|
||||
if (itr->Event.receive_emote.emoteId != text_emote)
|
||||
continue;
|
||||
{ continue; }
|
||||
|
||||
PlayerCondition pcon(0, itr->Event.receive_emote.condition, itr->Event.receive_emote.conditionValue1, itr->Event.receive_emote.conditionValue2);
|
||||
if (pcon.Meets(pPlayer, m_creature->GetMap(), m_creature, CONDITION_FROM_EVENTAI))
|
||||
|
|
@ -1532,7 +1540,7 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote)
|
|||
}
|
||||
}
|
||||
|
||||
#define HEALTH_STEPS 3
|
||||
#define HEALTH_STEPS 3
|
||||
|
||||
void CreatureEventAI::DamageTaken(Unit* dealer, uint32& damage)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue