From faf3bcbec1b1d1f589c3d5444239ddbd4e8369ff Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Fri, 17 Apr 2009 15:44:44 +0400 Subject: [PATCH] [7679] More checks for creature EventAI loading at server startup. Signed-off-by: VladimirMangos --- src/game/CreatureEventAI.cpp | 2 +- src/game/CreatureEventAI.h | 116 +++++++++--------- src/game/CreatureEventAIMgr.cpp | 253 ++++++++++++++++++++++++++++------------ src/shared/revision_nr.h | 2 +- 4 files changed, 241 insertions(+), 132 deletions(-) diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index d67dc46a..dc7ad3fe 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -47,7 +47,7 @@ CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c), InCombat(false) { //Debug check - #ifndef _DEBUG + #ifndef MANGOS_DEBUG if ((*i).event_flags & EFLAG_DEBUG_ONLY) continue; #endif diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h index eaf3bfc8..5cdbb140 100644 --- a/src/game/CreatureEventAI.h +++ b/src/game/CreatureEventAI.h @@ -32,74 +32,74 @@ class WorldObject; #define MAX_ACTIONS 3 #define TEXT_SOURCE_RANGE -1000000 //the amount of entries each text source has available -enum Event_Types +enum EventAI_Type { - EVENT_T_TIMER = 0, //InitialMin, InitialMax, RepeatMin, RepeatMax - EVENT_T_TIMER_OOC = 1, //InitialMin, InitialMax, RepeatMin, RepeatMax - EVENT_T_HP = 2, //HPMax%, HPMin%, RepeatMin, RepeatMax - EVENT_T_MANA = 3, //ManaMax%,ManaMin% RepeatMin, RepeatMax - EVENT_T_AGGRO = 4, //NONE - EVENT_T_KILL = 5, //RepeatMin, RepeatMax - EVENT_T_DEATH = 6, //NONE - EVENT_T_EVADE = 7, //NONE - EVENT_T_SPELLHIT = 8, //SpellID, School, RepeatMin, RepeatMax - EVENT_T_RANGE = 9, //MinDist, MaxDist, RepeatMin, RepeatMax - EVENT_T_OOC_LOS = 10, //NoHostile, NoFriendly, RepeatMin, RepeatMax - EVENT_T_SPAWNED = 11, //NONE - EVENT_T_TARGET_HP = 12, //HPMax%, HPMin%, RepeatMin, RepeatMax - EVENT_T_TARGET_CASTING = 13, //RepeatMin, RepeatMax - EVENT_T_FRIENDLY_HP = 14, //HPDeficit, Radius, RepeatMin, RepeatMax - EVENT_T_FRIENDLY_IS_CC = 15, //DispelType, Radius, RepeatMin, RepeatMax - EVENT_T_FRIENDLY_MISSING_BUFF = 16, //SpellId, Radius, RepeatMin, RepeatMax - EVENT_T_SUMMONED_UNIT = 17, //CreatureId, RepeatMin, RepeatMax - EVENT_T_TARGET_MANA = 18, //ManaMax%, ManaMin%, RepeatMin, RepeatMax - EVENT_T_QUEST_ACCEPT = 19, //QuestID + EVENT_T_TIMER = 0, // InitialMin, InitialMax, RepeatMin, RepeatMax + EVENT_T_TIMER_OOC = 1, // InitialMin, InitialMax, RepeatMin, RepeatMax + EVENT_T_HP = 2, // HPMax%, HPMin%, RepeatMin, RepeatMax + EVENT_T_MANA = 3, // ManaMax%,ManaMin% RepeatMin, RepeatMax + EVENT_T_AGGRO = 4, // NONE + EVENT_T_KILL = 5, // RepeatMin, RepeatMax + EVENT_T_DEATH = 6, // NONE + EVENT_T_EVADE = 7, // NONE + EVENT_T_SPELLHIT = 8, // SpellID, School, RepeatMin, RepeatMax + EVENT_T_RANGE = 9, // MinDist, MaxDist, RepeatMin, RepeatMax + EVENT_T_OOC_LOS = 10, // NoHostile, NoFriendly, RepeatMin, RepeatMax + EVENT_T_SPAWNED = 11, // NONE + EVENT_T_TARGET_HP = 12, // HPMax%, HPMin%, RepeatMin, RepeatMax + EVENT_T_TARGET_CASTING = 13, // RepeatMin, RepeatMax + EVENT_T_FRIENDLY_HP = 14, // HPDeficit, Radius, RepeatMin, RepeatMax + EVENT_T_FRIENDLY_IS_CC = 15, // DispelType, Radius, RepeatMin, RepeatMax + EVENT_T_FRIENDLY_MISSING_BUFF = 16, // SpellId, Radius, RepeatMin, RepeatMax + EVENT_T_SUMMONED_UNIT = 17, // CreatureId, RepeatMin, RepeatMax + EVENT_T_TARGET_MANA = 18, // ManaMax%, ManaMin%, RepeatMin, RepeatMax + EVENT_T_QUEST_ACCEPT = 19, // QuestID EVENT_T_QUEST_COMPLETE = 20, // - EVENT_T_REACHED_HOME = 21, //NONE - EVENT_T_RECEIVE_EMOTE = 22, //EmoteId, Condition, CondValue1, CondValue2 + EVENT_T_REACHED_HOME = 21, // NONE + EVENT_T_RECEIVE_EMOTE = 22, // EmoteId, Condition, CondValue1, CondValue2 EVENT_T_END, }; -enum Action_Types +enum EventAI_ActionType { - ACTION_T_NONE = 0, //No action - ACTION_T_TEXT = 1, //-TextId1, optionally -TextId2, optionally -TextId3(if -TextId2 exist). If more than just -TextId1 is defined, randomize. Negative values. - ACTION_T_SET_FACTION = 2, //FactionId (or 0 for default) - ACTION_T_MORPH_TO_ENTRY_OR_MODEL = 3, //Creature_template entry(param1) OR ModelId (param2) (or 0 for both to demorph) - ACTION_T_SOUND = 4, //SoundId - ACTION_T_EMOTE = 5, //EmoteId - ACTION_T_RANDOM_SAY = 6, //UNUSED - ACTION_T_RANDOM_YELL = 7, //UNUSED - ACTION_T_RANDOM_TEXTEMOTE = 8, //UNUSED + ACTION_T_NONE = 0, //*No action + ACTION_T_TEXT = 1, //*-TextId1, optionally -TextId2, optionally -TextId3(if -TextId2 exist). If more than just -TextId1 is defined, randomize. Negative values. + ACTION_T_SET_FACTION = 2, //*FactionId (or 0 for default) + ACTION_T_MORPH_TO_ENTRY_OR_MODEL = 3, //*Creature_template entry(param1) OR ModelId (param2) (or 0 for both to demorph) + ACTION_T_SOUND = 4, //*SoundId + ACTION_T_EMOTE = 5, //*EmoteId + ACTION_T_RANDOM_SAY = 6, //*UNUSED + ACTION_T_RANDOM_YELL = 7, //*UNUSED + ACTION_T_RANDOM_TEXTEMOTE = 8, //*UNUSED ACTION_T_RANDOM_SOUND = 9, //SoundId1, SoundId2, SoundId3 (-1 in any field means no output if randomed that field) - ACTION_T_RANDOM_EMOTE = 10, //EmoteId1, EmoteId2, EmoteId3 (-1 in any field means no output if randomed that field) - ACTION_T_CAST = 11, //SpellId, Target, CastFlags - ACTION_T_SUMMON = 12, //CreatureID, Target, Duration in ms - ACTION_T_THREAT_SINGLE_PCT = 13, //Threat%, Target + ACTION_T_RANDOM_EMOTE = 10, //*EmoteId1, EmoteId2, EmoteId3 (-1 in any field means no output if randomed that field) + ACTION_T_CAST = 11, //*SpellId, Target, CastFlags + ACTION_T_SUMMON = 12, //*CreatureID, Target, Duration in ms + ACTION_T_THREAT_SINGLE_PCT = 13, //*Threat%, Target ACTION_T_THREAT_ALL_PCT = 14, //Threat% - ACTION_T_QUEST_EVENT = 15, //QuestID, Target - ACTION_T_CASTCREATUREGO = 16, //QuestID, SpellId, Target - ACTION_T_SET_UNIT_FIELD = 17, //Field_Number, Value, Target - ACTION_T_SET_UNIT_FLAG = 18, //Flags (may be more than one field OR'd together), Target - ACTION_T_REMOVE_UNIT_FLAG = 19, //Flags (may be more than one field OR'd together), Target + ACTION_T_QUEST_EVENT = 15, //*QuestID, Target + ACTION_T_CASTCREATUREGO = 16, //*QuestID, SpellId, Target + ACTION_T_SET_UNIT_FIELD = 17, //*Field_Number, Value, Target + ACTION_T_SET_UNIT_FLAG = 18, //*Flags (may be more than one field OR'd together), Target + ACTION_T_REMOVE_UNIT_FLAG = 19, //*Flags (may be more than one field OR'd together), Target ACTION_T_AUTO_ATTACK = 20, //AllowAttackState (0 = stop attack, anything else means continue attacking) ACTION_T_COMBAT_MOVEMENT = 21, //AllowCombatMovement (0 = stop combat based movement, anything else continue attacking) - ACTION_T_SET_PHASE = 22, //Phase - ACTION_T_INC_PHASE = 23, //Value (may be negative to decrement phase, should not be 0) + ACTION_T_SET_PHASE = 22, //*Phase + ACTION_T_INC_PHASE = 23, //*Value (may be negative to decrement phase, should not be 0) ACTION_T_EVADE = 24, //No Params ACTION_T_FLEE = 25, //No Params - ACTION_T_QUEST_EVENT_ALL = 26, //QuestID - ACTION_T_CASTCREATUREGO_ALL = 27, //QuestId, SpellId - ACTION_T_REMOVEAURASFROMSPELL = 28, //Target, Spellid + ACTION_T_QUEST_EVENT_ALL = 26, //*QuestID + ACTION_T_CASTCREATUREGO_ALL = 27, //*QuestId, SpellId + ACTION_T_REMOVEAURASFROMSPELL = 28, //*Target, Spellid ACTION_T_RANGED_MOVEMENT = 29, //Distance, Angle ACTION_T_RANDOM_PHASE = 30, //PhaseId1, PhaseId2, PhaseId3 ACTION_T_RANDOM_PHASE_RANGE = 31, //PhaseMin, PhaseMax - ACTION_T_SUMMON_ID = 32, //CreatureId, Target, SpawnId - ACTION_T_KILLED_MONSTER = 33, //CreatureId, Target - ACTION_T_SET_INST_DATA = 34, //Field, Data - ACTION_T_SET_INST_DATA64 = 35, //Field, Target - ACTION_T_UPDATE_TEMPLATE = 36, //Entry, Team + ACTION_T_SUMMON_ID = 32, //*CreatureId, Target, SpawnId + ACTION_T_KILLED_MONSTER = 33, //*CreatureId, Target + ACTION_T_SET_INST_DATA = 34, //*Field, Data + ACTION_T_SET_INST_DATA64 = 35, //*Field, Target + ACTION_T_UPDATE_TEMPLATE = 36, //*Entry, Team ACTION_T_DIE = 37, //No Params ACTION_T_ZONE_COMBAT_PULSE = 38, //No Params @@ -152,7 +152,7 @@ enum EventFlags EFLAG_RESERVED_4 = 0x10, EFLAG_RESERVED_5 = 0x20, EFLAG_RESERVED_6 = 0x40, - EFLAG_DEBUG_ONLY = 0x80, //Event only occurs in debug build of SD2 only + EFLAG_DEBUG_ONLY = 0x80, //Event only occurs in debug build }; // String text additional data, used in (CreatureEventAI) @@ -172,10 +172,12 @@ struct CreatureEventAI_Event uint32 creature_id; - uint16 event_type; uint32 event_inverse_phase_mask; - uint8 event_chance; - uint8 event_flags; + + EventAI_Type event_type : 16; + uint8 event_chance : 8; + uint8 event_flags : 8; + union { uint32 event_param1; @@ -199,7 +201,7 @@ struct CreatureEventAI_Event struct _action { - uint16 type; + EventAI_ActionType type: 16; union { uint32 param1; diff --git a/src/game/CreatureEventAIMgr.cpp b/src/game/CreatureEventAIMgr.cpp index 857f6c32..b0e6f1a6 100644 --- a/src/game/CreatureEventAIMgr.cpp +++ b/src/game/CreatureEventAIMgr.cpp @@ -171,38 +171,41 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() Field *fields = result->Fetch(); CreatureEventAI_Event temp; - - temp.event_id = fields[0].GetUInt32(); + temp.event_id = EventAI_Type(fields[0].GetUInt32()); uint32 i = temp.event_id; + temp.creature_id = fields[1].GetUInt32(); uint32 creature_id = temp.creature_id; - temp.event_type = fields[2].GetUInt16(); + + uint32 e_type = fields[2].GetUInt32(); + //Report any errors in event + if (e_type >= EVENT_T_END) + { + sLog.outErrorDb("CreatureEventAI: Event %u have wrong type (%u), skipping.", i,e_type); + continue; + } + temp.event_type = EventAI_Type(e_type); + temp.event_inverse_phase_mask = fields[3].GetUInt32(); temp.event_chance = fields[4].GetUInt8(); - temp.event_flags = fields[5].GetUInt8(); + temp.event_flags = fields[5].GetUInt8(); temp.event_param1 = fields[6].GetUInt32(); temp.event_param2 = fields[7].GetUInt32(); temp.event_param3 = fields[8].GetUInt32(); temp.event_param4 = fields[9].GetUInt32(); - CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(temp.creature_id); //Creature does not exist in database - if (!cInfo) + if (!sCreatureStorage.LookupEntry(temp.creature_id)) { - sLog.outErrorDb("CreatureEventAI: Event %u has script for non-existing creature.", i); + sLog.outErrorDb("CreatureEventAI: Event %u has script for non-existing creature entry (%u), skipping.", i, temp.creature_id); continue; } - //Report any errors in event - if (temp.event_type >= EVENT_T_END) - sLog.outErrorDb("CreatureEventAI: Event %u has incorrect event type. Maybe DB requires updated version of SD2.", i); - //No chance of this event occuring if (temp.event_chance == 0) sLog.outErrorDb("CreatureEventAI: Event %u has 0 percent chance. Event will never trigger!", i); - //Chance above 100, force it to be 100 - if (temp.event_chance > 100) + else if (temp.event_chance > 100) { sLog.outErrorDb("CreatureEventAI: Creature %u are using event %u with more than 100 percent chance. Adjusting to 100 percent.", temp.creature_id, i); temp.event_chance = 100; @@ -211,6 +214,18 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() //Individual event checks switch (temp.event_type) { + case EVENT_T_TIMER: + case EVENT_T_TIMER_OOC: + { + if (temp.event_param2 < temp.event_param1) + sLog.outErrorDb("CreatureEventAI: Creature %u are using timed event(%u) with param2 < param1 (InitialMax < InitialMin). Event will never repeat.", temp.creature_id, i); + + if (temp.event_param4 < temp.event_param3) + sLog.outErrorDb("CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); + + break; + } + case EVENT_T_HP: case EVENT_T_MANA: case EVENT_T_TARGET_HP: @@ -226,14 +241,14 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() sLog.outErrorDb("CreatureEventAI: Creature %u has param3 and param4=0 (RepeatMin/RepeatMax) but cannot be repeatable without timers. Removing EFLAG_REPEATABLE for event %u.", temp.creature_id, i); temp.event_flags &= ~EFLAG_REPEATABLE; } + break; } - break; case EVENT_T_SPELLHIT: { if (temp.event_param1) { - SpellEntry const* pSpell = GetSpellStore()->LookupEntry(temp.event_param1); + SpellEntry const* pSpell = sSpellStore.LookupEntry(temp.event_param1); if (!pSpell) { sLog.outErrorDb("CreatureEventAI: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.event_param1, i); @@ -251,8 +266,8 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() if (temp.event_param4 < temp.event_param3) sLog.outErrorDb("CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); + break; } - break; case EVENT_T_RANGE: case EVENT_T_OOC_LOS: @@ -260,29 +275,28 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() case EVENT_T_FRIENDLY_IS_CC: case EVENT_T_FRIENDLY_MISSING_BUFF: { - if (temp.event_param4 < temp.event_param3) - sLog.outErrorDb("CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); - } - break; - - case EVENT_T_TIMER: - case EVENT_T_TIMER_OOC: - { - if (temp.event_param2 < temp.event_param1) - sLog.outErrorDb("CreatureEventAI: Creature %u are using timed event(%u) with param2 < param1 (InitialMax < InitialMin). Event will never repeat.", temp.creature_id, i); + //Disabled check for now. Check code related to events and adjust accordingly before enable. + //Events should have min/max or alternative set to a static value. + /*if (!temp.event_param3 && !temp.event_param4) + { + sLog.outErrorDb("CreatureEventAI: Creature %u are using repeatable event(%u) without param3/param4 (RepeatMin/RepeatMax). Using minimum values.", temp.creature_id, i); + temp.event_param3 = 2500; + temp.event_param4 = 2500; + }*/ if (temp.event_param4 < temp.event_param3) sLog.outErrorDb("CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); + break; } - break; case EVENT_T_KILL: case EVENT_T_TARGET_CASTING: { if (temp.event_param2 < temp.event_param1) sLog.outErrorDb("CreatureEventAI: Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); + + break; } - break; case EVENT_T_AGGRO: case EVENT_T_DEATH: @@ -295,13 +309,70 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() sLog.outErrorDb("CreatureEventAI: Creature %u has EFLAG_REPEATABLE set. Event can never be repeatable. Removing flag for event %u.", temp.creature_id, i); temp.event_flags &= ~EFLAG_REPEATABLE; } + + break; + } + + case EVENT_T_RECEIVE_EMOTE: + { + if (!sEmotesTextStore.LookupEntry(temp.event_param1)) + { + sLog.outErrorDb("CreatureEventAI: Creature %u using event %u: param1 (EmoteTextId: %u) are not valid.",temp.creature_id, i, temp.event_param1); + continue; + } + + if (temp.event_param2 == CONDITION_AD_COMMISSION_AURA || temp.event_param2 == CONDITION_NO_AURA) + { + sLog.outErrorDb("CreatureEventAI: Creature %u using event %u: param2 (Condition: %u) are not implemented for EventAI.",temp.creature_id, i, temp.event_param2); + continue; + } + + if (!PlayerCondition::IsValid(ConditionType(temp.event_param2), temp.event_param3, temp.event_param4)) + { + sLog.outErrorDb("CreatureEventAI: Creature %u using event %u: param2 (Condition: %u) are not valid.",temp.creature_id, i, temp.event_param2); + continue; + } + + if (!(temp.event_flags & EFLAG_REPEATABLE)) + { + sLog.outErrorDb("CreatureEventAI: Creature %u using event %u: EFLAG_REPEATABLE not set. Event must always be repeatable. Flag applied.", temp.creature_id, i); + temp.event_flags |= EFLAG_REPEATABLE; + } + + break; + } + + case EVENT_T_SUMMONED_UNIT: + { + if (!sCreatureStorage.LookupEntry(temp.event_param1)) + sLog.outErrorDb("CreatureEventAI: Creature %u are using event(%u) with not existed creature template id (%u) in param1, skipped.", temp.creature_id, i, temp.event_param1); + + if (temp.event_param3 < temp.event_param2) + sLog.outErrorDb("CreatureEventAI: Creature %u are using repeatable event(%u) with param3 < param2 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); + + break; } - break; + + case EVENT_T_QUEST_ACCEPT: + case EVENT_T_QUEST_COMPLETE: + sLog.outErrorDb("CreatureEventAI: Creature %u using not implemented event (%u) in event %u.", temp.creature_id, temp.event_id, i); + continue; + default: + sLog.outErrorDb("CreatureEventAI: Creature %u using not checked at load event (%u) in event %u. Need check code update?", temp.creature_id, temp.event_id, i); + break; } for (uint32 j = 0; j < MAX_ACTIONS; j++) { - temp.action[j].type = fields[10+(j*4)].GetUInt16(); + uint16 action_type = fields[10+(j*4)].GetUInt16(); + if (action_type >= ACTION_T_END) + { + sLog.outErrorDb("CreatureEventAI: Event %u Action %u has incorrect action type (%u), replace by ACTION_T_NONE.", i, j+1, action_type); + temp.action[j].type = ACTION_T_NONE; + continue; + } + + temp.action[j].type = EventAI_ActionType(action_type); temp.action[j].param1 = fields[11+(j*4)].GetUInt32(); temp.action[j].param2 = fields[12+(j*4)].GetUInt32(); temp.action[j].param3 = fields[13+(j*4)].GetUInt32(); @@ -309,6 +380,8 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() //Report any errors in actions switch (temp.action[j].type) { + case ACTION_T_NONE: + break; case ACTION_T_TEXT: { if (temp.action[j].param1_s < 0) @@ -332,10 +405,10 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() if (!temp.action[j].param1_s || !temp.action[j].param2_s) sLog.outErrorDb("CreatureEventAI: Event %u Action %u has param3, but param1 and/or param2 is not set. Required for randomized text.", i, j+1); } + break; } - break; case ACTION_T_SET_FACTION: - if (temp.action[j].param1 !=0 && !GetFactionStore()->LookupEntry(temp.action[j].param1)) + if (temp.action[j].param1 !=0 && !sFactionStore.LookupEntry(temp.action[j].param1)) { sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant FactionId %u.", i, j+1, temp.action[j].param1); temp.action[j].param1 = 0; @@ -344,13 +417,13 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() case ACTION_T_MORPH_TO_ENTRY_OR_MODEL: if (temp.action[j].param1 !=0 || temp.action[j].param2 !=0) { - if (temp.action[j].param1 && !GetCreatureTemplateStore(temp.action[j].param1)) + if (temp.action[j].param1 && !sCreatureStorage.LookupEntry(temp.action[j].param1)) { sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant Creature entry %u.", i, j+1, temp.action[j].param1); temp.action[j].param1 = 0; } - if (temp.action[j].param2 && !GetCreatureDisplayStore()->LookupEntry(temp.action[j].param2)) + if (temp.action[j].param2 && !sCreatureDisplayInfoStore.LookupEntry(temp.action[j].param2)) { sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant ModelId %u.", i, j+1, temp.action[j].param2); temp.action[j].param2 = 0; @@ -358,24 +431,38 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() } break; case ACTION_T_SOUND: - if (!GetSoundEntriesStore()->LookupEntry(temp.action[j].param1)) + if (!sSoundEntriesStore.LookupEntry(temp.action[j].param1)) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant SoundID %u.", i, j+1, temp.action[j].param1); break; -/* case ACTION_T_RANDOM_SOUND: - { - if(!GetSoundEntriesStore()->LookupEntry(temp.action[j].param1)) + if (!sSoundEntriesStore.LookupEntry(temp.action[j].param1)) sLog.outErrorDb("CreatureEventAI: Event %u Action %u param1 uses non-existant SoundID %u.", i, j+1, temp.action[j].param1); - if(!GetSoundEntriesStore()->LookupEntry(temp.action[j].param2)) + if (temp.action[j].param2_s >= 0 && !sSoundEntriesStore.LookupEntry(temp.action[j].param2)) sLog.outErrorDb("CreatureEventAI: Event %u Action %u param2 uses non-existant SoundID %u.", i, j+1, temp.action[j].param2); - if(!GetSoundEntriesStore()->LookupEntry(temp.action[j].param3)) + if (temp.action[j].param3_s >= 0 && !sSoundEntriesStore.LookupEntry(temp.action[j].param3)) sLog.outErrorDb("CreatureEventAI: Event %u Action %u param3 uses non-existant SoundID %u.", i, j+1, temp.action[j].param3); - } - break; - */ + break; + case ACTION_T_EMOTE: + //TODO: load emotes and check it's store for existing + /* + if (!sEmotesStore.LookupEntry(temp.action[j].param1)) + sLog.outErrorDb("CreatureEventAI: Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j+1, temp.action[j].param1); + */ + break; + case ACTION_T_RANDOM_EMOTE: + //TODO: load emotes and check it's store for existing + /* + if (!sEmotesStore.LookupEntry(temp.action[j].param1)) + sLog.outErrorDb("CreatureEventAI: Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j+1, temp.action[j].param1); + if (temp.action[j].param2_s >= 0 && !sEmotesStore.LookupEntry(temp.action[j].param2)) + sLog.outErrorDb("CreatureEventAI: Event %u Action %u param2 (EmoteId: %u) are not valid.", i, j+1, temp.action[j].param2); + if (temp.action[j].param3_s >= 0 && !sEmotesStore.LookupEntry(temp.action[j].param3)) + sLog.outErrorDb("CreatureEventAI: Event %u Action %u param3 (EmoteId: %u) are not valid.", i, j+1, temp.action[j].param3); + */ + break; case ACTION_T_CAST: { - const SpellEntry *spell = GetSpellStore()->LookupEntry(temp.action[j].param1); + const SpellEntry *spell = sSpellStore.LookupEntry(temp.action[j].param1); if (!spell) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant SpellID %u.", i, j+1, temp.action[j].param1); else @@ -384,26 +471,26 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() { //output as debug for now, also because there's no general rule all spells have RecoveryTime if (temp.event_param3 < spell->RecoveryTime) - debug_log("CreatureEventAI: Event %u Action %u uses SpellID %u but cooldown is longer(%u) than minumum defined in event param3(%u).", i, j+1,temp.action[j].param1, spell->RecoveryTime, temp.event_param3); + sLog.outDebug("CreatureEventAI: Event %u Action %u uses SpellID %u but cooldown is longer(%u) than minumum defined in event param3(%u).", i, j+1,temp.action[j].param1, spell->RecoveryTime, temp.event_param3); } } if (temp.action[j].param2 >= TARGET_T_END) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + break; } - break; case ACTION_T_REMOVEAURASFROMSPELL: { - if (!GetSpellStore()->LookupEntry(temp.action[j].param2)) + if (!sSpellStore.LookupEntry(temp.action[j].param2)) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant SpellID %u.", i, j+1, temp.action[j].param2); if (temp.action[j].param1 >= TARGET_T_END) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + break; } - break; case ACTION_T_QUEST_EVENT: { - if (Quest const* qid = GetQuestTemplateStore(temp.action[j].param1)) + if (Quest const* qid = objmgr.GetQuestTemplate(temp.action[j].param1)) { if (!qid->HasFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT)) sLog.outErrorDb("CreatureEventAI: Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j+1, temp.action[j].param1); @@ -413,45 +500,46 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() if (temp.action[j].param2 >= TARGET_T_END) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + + break; } - break; case ACTION_T_QUEST_EVENT_ALL: { - if (Quest const* qid = GetQuestTemplateStore(temp.action[j].param1)) + if (Quest const* qid = objmgr.GetQuestTemplate(temp.action[j].param1)) { if (!qid->HasFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT)) sLog.outErrorDb("CreatureEventAI: Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j+1, temp.action[j].param1); } else sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant Quest entry %u.", i, j+1, temp.action[j].param1); + break; } - break; case ACTION_T_CASTCREATUREGO: { - if (!GetCreatureTemplateStore(temp.action[j].param1)) + if (!sCreatureStorage.LookupEntry(temp.action[j].param1)) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant creature entry %u.", i, j+1, temp.action[j].param1); - if (!GetSpellStore()->LookupEntry(temp.action[j].param2)) + if (!sSpellStore.LookupEntry(temp.action[j].param2)) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant SpellID %u.", i, j+1, temp.action[j].param2); if (temp.action[j].param3 >= TARGET_T_END) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + break; } - break; case ACTION_T_CASTCREATUREGO_ALL: { - if (!GetQuestTemplateStore(temp.action[j].param1)) + if (!objmgr.GetQuestTemplate(temp.action[j].param1)) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant Quest entry %u.", i, j+1, temp.action[j].param1); - if (!GetSpellStore()->LookupEntry(temp.action[j].param2)) + if (!sSpellStore.LookupEntry(temp.action[j].param2)) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant SpellID %u.", i, j+1, temp.action[j].param2); + break; } - break; //2nd param target case ACTION_T_SUMMON_ID: { - if (!GetCreatureTemplateStore(temp.action[j].param1)) + if (!sCreatureStorage.LookupEntry(temp.action[j].param1)) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant creature entry %u.", i, j+1, temp.action[j].param1); if (m_CreatureEventAI_Summon_Map.find(temp.action[j].param3) == m_CreatureEventAI_Summon_Map.end()) @@ -459,34 +547,33 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() if (temp.action[j].param2 >= TARGET_T_END) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + break; } - break; case ACTION_T_KILLED_MONSTER: { - if (!GetCreatureTemplateStore(temp.action[j].param1)) + if (!sCreatureStorage.LookupEntry(temp.action[j].param1)) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant creature entry %u.", i, j+1, temp.action[j].param1); if (temp.action[j].param2 >= TARGET_T_END) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + break; } - break; case ACTION_T_SUMMON: { - if (!GetCreatureTemplateStore(temp.action[j].param1)) + if (!sCreatureStorage.LookupEntry(temp.action[j].param1)) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant creature entry %u.", i, j+1, temp.action[j].param1); if (temp.action[j].param2 >= TARGET_T_END) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + break; } - break; case ACTION_T_THREAT_SINGLE_PCT: case ACTION_T_SET_UNIT_FLAG: case ACTION_T_REMOVE_UNIT_FLAG: if (temp.action[j].param2 >= TARGET_T_END) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); break; - - //3rd param target + //3rd param target case ACTION_T_SET_UNIT_FIELD: if (temp.action[j].param1 < OBJECT_END || temp.action[j].param1 >= UNIT_END) sLog.outErrorDb("CreatureEventAI: Event %u Action %u param1 (UNIT_FIELD*). Index out of range for intended use.", i, j+1); @@ -511,8 +598,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() if (temp.action[j].param2 > 4/*SPECIAL*/) sLog.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set instance data above encounter state 4. Custom case?", i, j+1); + + break; } - break; case ACTION_T_SET_INST_DATA64: { if (!(temp.event_flags & EFLAG_NORMAL) && !(temp.event_flags & EFLAG_HEROIC)) @@ -520,23 +608,42 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() if (temp.action[j].param2 >= TARGET_T_END) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + + break; } - break; case ACTION_T_UPDATE_TEMPLATE: { - if (!GetCreatureTemplateStore(temp.action[j].param1)) + if (!sCreatureStorage.LookupEntry(temp.action[j].param1)) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant creature entry %u.", i, j+1, temp.action[j].param1); + break; } - break; + + case ACTION_T_THREAT_ALL_PCT: + if (abs(temp.action[j].param1_s) > 100) + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses invalid percent value %u.", i, j+1, temp.action[j].param1); + break; + + case ACTION_T_EVADE: //No Params + case ACTION_T_FLEE: //No Params + case ACTION_T_DIE: //No Params + case ACTION_T_ZONE_COMBAT_PULSE: //No Params + case ACTION_T_AUTO_ATTACK: //AllowAttackState (0 = stop attack, anything else means continue attacking) + case ACTION_T_COMBAT_MOVEMENT: //AllowCombatMovement (0 = stop combat based movement, anything else continue attacking) + case ACTION_T_RANGED_MOVEMENT: //Distance, Angle + break; + + case ACTION_T_RANDOM_PHASE: //PhaseId1, PhaseId2, PhaseId3 + case ACTION_T_RANDOM_PHASE_RANGE: //PhaseMin, PhaseMax + // check not implemented + break; + case ACTION_T_RANDOM_SAY: case ACTION_T_RANDOM_YELL: case ACTION_T_RANDOM_TEXTEMOTE: sLog.outErrorDb("CreatureEventAI: Event %u Action %u currently unused ACTION type. Did you forget to update database?", i, j+1); break; - default: - if (temp.action[j].type >= ACTION_T_END) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u has incorrect action type. Maybe DB requires updated version of SD2.", i, j+1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u have currently not checked at load action type (%u). Need check code update?", i, j+1, temp.action[j].type); break; } } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 700ecd90..c40e7edf 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7678" + #define REVISION_NR "7679" #endif // __REVISION_NR_H__ -- 2.11.4.GIT