mirror of
https://github.com/mangosfour/server.git
synced 2025-12-28 13:37:13 +00:00
I'm not taking any credits of this commit.
Implement spell effects 62042, 62278 and 64767
Also limit the targets for 62577 and 62603
----------
Update git_id to reflect recent sql formatting changes
----------
Update to a safer code version and also add GO caster scenarios
----------
Allow aura 62038 to stack at every 3 seconds
----------
Improve handling of TargetMMGen
This will have impact on Chase and Follow Movement.
----------
* Refactor code to check if a new position is required for the MMGen into the new function RequiresNewPosition
* Refactor code to get the current targeted distance into function GetDynamicTargetDistance
* Change ChaseMMGen (angle = 0.0f case) chase to best contact point, not zero angle.
Thanks to Cala and X-Savior for testing. Special thanks to cala for also suggesting improved values for the magic numbers
----------
Improve ObjectPosSelector
Now a spot already occupied by the searcher will be prefered
----------
Get rid of bounding radius in GetNearPoint[2D] and ObjectPosSelector
----------
This changes how ObjectPosSelector is used.
It changes the way how the functions Object::GetNearPoint and Object::GetNearPoint2d behave.
----------
So you need to check all places where these functions are used if they are still used correctly.
----------
Especially check your scripts!
----------
Remove not required duplicate indexes
----------
Implement TARGET_92 as TARGET_SUMMONER
This target is used only as TargetA and the related spells are used only by temporary summoned creatures
----------
Implement some spell effects used by Hodir in Ulduar
Dummy spells 62797, 63499, 63545 and 64543
Periodic dummy auras: 61968, 62038, 62039 and 65272
Limit targets for spells: 62797, 63545, 64543, 62476 and 62477
----------
Implement some spells used at Algalon encounter
Spell aura entries 64345, 62018 and 64412
Positive target exception for spell 64996
Aura stacking exception for spells 62169, 62168, 65250 and 64417
----------
Implement effect for spell 63633
----------
EventAI - Ingame output of script state
----------
With this the command .npc aiinfo will give more output about the current state.
Remark that this output is only given if the LogFilter for EventAIDev mode is disabled
----------
FindGit.cmake already ships with CMake
No reason for us to ship it too. Also, we had an outdated version which
had not been used anyway, because we set the include path in such a way,
that the CMake delivered version is always found first.
----------
FindOpenSSL.cmake already ships with CMake
No reason for us to ship it too. Also, we had an outdated version which
had not been used anyway, because we set the include path in such a way,
that the CMake delivered version is always found first.
----------
EventAI - Add more developing error output
----------
Fix some target-type handling for EventAI
Also increase log-output for bad target-types
----------
Fix crash due to bad compiler (author Xfurry)
----------
Add special condition id for Ulduar
Will be used to check the availability of the siege vehicles for players
----------
Update spells 62374 and 62907
* limit spell targets of spell 62374
* implement spell effect for spell 62907
----------
Remove effect for spell 64503
Will be handled in script library. For details please check 8502cdfa64
----------
Implement spells 64489 and 64673
Both are used by Auriaya (Ulduar)
----------
Implement some spells for Ignis the Furnace Master
Spell entries: 62717, 62381, 62488, 62707, 64475 and 64503
----------
Implement spells 61187 and 61190
----------
CMake: generic way to build a script library
Added new parameter INCLUDE_BINDINGS_DIR which can be set to the name of a
folder inside src/bindings/.
Includes the script library in src/bindings/ with the defined name.
The name must correspond to the name of the folder and the folder must contain
a valid CMakeLists.txt
Note: if you currently use a script library, you will probably get a merge
problem on src/bindings/CMakeLists.txt as you will have modified this file
manually. Please use the new version of this file and rerun CMake once with the
parameter -DINCLUDE_BINDINGS_DIR=ScriptDev2 (if you are not using SD2 but
another script library, replace ScriptDev2 with the name of the folder in
src/bindings/).
If you do not use a script library you should not have any merge problems
and you don't need to do anything.
----------
Add CMake source groups to target 'game'
This is the exact same grouping as it is currently in the VC 2012 files.
These groupings will have to be refactored at some point as they are not
very logical.
----------
Add CMake source groups to target 'framework'
This is the exact same grouping as it is currently in the VC 2012 files.
This is part of cmangos/issues#67
----------
Add CMake source groups to target 'shared'
This is the exact same grouping as it is currently in the VC 2012 files.
----------
Add new parameter 'expansion' to command 'account create'
----------
Update some Sunwell Plateau spells
Limit targets and allow positive effect for spell 46650
Implement effect for spells 46289 and 46637
Remove effect for spell 44845 - will be handled in script library
----------
Implement some custom use for Effect Activate Object spells
This will fix the summoning events for the Wind Stones, Ice Stones, Skettis bosses and quest 11865
----------
Sync mangos.sql with other versions
----------
Redump sql databases to unify formatting
The main reason for this was because classic/cata has updated the sql formatting and manually syncing would be a pain so redumping from master->tbc->classic->cata is easier.
Only the formatting was changed. The values were not changed at all.
mysqldump was used however manual modifications had to be done.
Dump the database:
C:/mysql/bin/mysqldump.exe mangos > sql/mangos.sql
Split insert values into multiple rows:
Replace "),(" with "),\n("
Replace "VALUES (" with "VALUES\n("
Remove the character sets by replacing them with an empty string
Custom formatting of mangos.sql:
Move db_version to the very top
Create all dbscripts_on_* tables based on dbscripts_on_creature_movement
Preserve our custom insert formatting of spell_affect (tbc/classic), spell_bonus_data, spell_chain, spell_elixir, spell_proc_event, spell_proc_item_enchant, spell_template, spell_threat
Remove autoincrement values from insert values of pet_name_generation and remove AUTO_INCREMENT=261 value from its table structure
Custom formatting of characters.sql:
Move character_db_version to the very top
Custom formatting of realmd.sql:
Move realmd_db_version to the very top
----------
Immediately remove corpses when ForcedDespawn is used
Thanks to Neotmiren for pointing, special thanks to cala for testing!
----------
Fix use of config values related to quest-status and level
This fixes use of negative value in config values Quests.LowLevelHideDiff and Quests.HighLevelHideDiff
Also add some documentation around the related code
Thanks to Neotmiren for pointing and to cala for testing.
----------
Loot-System: Fix reference loading check
This fixes a false error output for loot references that are only used with spell loot.
Thanks to X-Savior for properly reporting both error messages and use case
----------
Add missing spell 61437 to playercreate spells for bloodelves
Thanks to NeatElves for porting from TC and pointing to this
----------
Fix load bar step for alendarMgr::LoadCalendarsFromDB
----------
Cody Style Improvements
Also remove an unused variable (thanks to Den for this!)
----------
Implement the spells used in the Chess Event encounter
Combat spell entries: 37775, 37824, 39338, 39342, 39341, 39344, 45260
Melee spells: 37142, 37143, 37147, 37149, 37150, 37220, 37227, 37228, 37337, 37339, 37345, 37348
Chess movement spells: 30012, 32312, 37388, 30284, 37144, 37146, 37148, 37151, 37152, 37153
Aura stacking exception: 32261 and 39400
----------
And more hotfixes with these format strings
----------
Hotfix to recent text loading functions
----------
Use possible changed model names with vmap extraction
----------
Fix some warnings
----------
Store how many texts are loaded for validity checks. Use this with EventAI
----------
EventAI: Use generic DoDisplayText and loading of additional text data
----------
Add generic DoDisplayText function and use additional data of dbscripts table
----------
Add const-correctness to Text related functions
----------
Add database changes to support more data for DB Script texts
----------
Add stacking exception for spells 39993 and 40041
----------
Allow spell effect 86 - Activate Object to use the misc value
----------
Allow player pets to swim
----------
Enable resummoning of warlock pets
----------
Do not remove FLY auras on Evade
Also consider npcs which have SPELL_AURA_FLY as being able to fly
----------
EventAI: Improve code
* Drop rather pointless bool to check if the number of assigned events is empty
* Before the phase was resetted on death if and only if the npc has Events defined
* DoMeleeAttackIfReady could have been called even though combat state could have changed while processing events
----------
EventAI: Implement ACTION_T_SET_THROW_MASK (46)
This Action can be used to set which AIEvents should be thrown automatically, if you need more flexibility, you can always use the manual ACTION_TH_THROW_AI_EVENT version.
* Also clean some error-log output a bit.
----------
Forward original caster GUID to script library
----------
Fixup commit 12511 Thanks to Zakamurite for pointing
Also thanks to him for giving a helping hand in correcting the commit
----------
Implement some spells for Felmyst encounter
Spell entries: 45714, 45717 and 45918. Limit targets of spell 45391
Also add stacking exception for auras 45068 and 45582
----------
Fix invisible spirit healers & such on death near them
This fixes an issue that occurs if you die close to a spirit healer/guide.
----------
Fix take ammo for most ranged spells
Fix spells like Arcane Shot not taking ammo while they should
----------
Check cast spell 51690
----------
Fix SpellDamage modifier of SPELL_AURA_MOD_DAMAGE_DONE_CREATURE
This aura modifies a flat value, not a percent value.
----------
Implement proc effect of spells 67712, 67758
related to items 47316, 47477.
----------
Improve proc of spell 50421
----------
Add and implement server-side spell 23770
----------
EventAI: Improve TargetSelection related ErrorLog output
----------
DBScripts Engine: Change behaviour to search for a different npc when using buddy-search
With this an npc buddy will be interpreted as "another npc with entry"
Also toggle command 31 - TERMINATE_SCRIPT to also look only for other npcs of entry
----------
DBScripts Engine: Allow pets as buddy
Add new flag SCRIPT_FLAG_BUDDY_IS_PET (0x20) that will search not for a normal npc with buddy-search, but also for pets
----------
DBScripts Engine: Support buddy search by guid
* Add new `data_flags` flag SCRIPT_FLAG_BUDDY_BY_GUID (0x10)
If this flag is set, the content of `search_distance` is interpreted as db-guid of the requested buddy
* Also switch most error log output to DB-error log output (though this will include false positives)
----------
912 lines
54 KiB
C++
912 lines
54 KiB
C++
/**
|
|
* This code is part of MaNGOS. Contributor & Copyright details are in AUTHORS/THANKS.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
#include "Common.h"
|
|
#include "Database/DatabaseEnv.h"
|
|
#include "SQLStorages.h"
|
|
#include "CreatureEventAI.h"
|
|
#include "CreatureEventAIMgr.h"
|
|
#include "ObjectMgr.h"
|
|
#include "ProgressBar.h"
|
|
#include "Policies/Singleton.h"
|
|
#include "ObjectGuid.h"
|
|
#include "GridDefines.h"
|
|
#include "SpellMgr.h"
|
|
#include "World.h"
|
|
|
|
INSTANTIATE_SINGLETON_1(CreatureEventAIMgr);
|
|
|
|
// -------------------
|
|
void CreatureEventAIMgr::LoadCreatureEventAI_Texts(bool check_entry_use)
|
|
{
|
|
// Load EventAI Text
|
|
sObjectMgr.LoadMangosStrings(WorldDatabase, "creature_ai_texts", MIN_CREATURE_AI_TEXT_STRING_ID, MAX_CREATURE_AI_TEXT_STRING_ID, true);
|
|
if (check_entry_use)
|
|
CheckUnusedAITexts();
|
|
}
|
|
|
|
void CreatureEventAIMgr::CheckUnusedAITexts()
|
|
{
|
|
if (m_usedTextsAmount == sObjectMgr.GetLoadedStringsCount(MIN_CREATURE_AI_TEXT_STRING_ID))
|
|
return;
|
|
|
|
sLog.outString("Checking EventAI for unused texts, this might take a while");
|
|
|
|
std::set<int32> idx_set;
|
|
// check not used strings this is negative range
|
|
for (int32 i = MAX_CREATURE_AI_TEXT_STRING_ID + 1; i <= MIN_CREATURE_AI_TEXT_STRING_ID; ++i)
|
|
if (sObjectMgr.GetMangosStringLocale(i))
|
|
idx_set.insert(i);
|
|
|
|
for (CreatureEventAI_Event_Map::const_iterator itr = m_CreatureEventAI_Event_Map.begin(); itr != m_CreatureEventAI_Event_Map.end(); ++itr)
|
|
{
|
|
for (size_t i = 0; i < itr->second.size(); ++i)
|
|
{
|
|
CreatureEventAI_Event const& event = itr->second[i];
|
|
|
|
for (int j = 0; j < MAX_ACTIONS; ++j)
|
|
{
|
|
CreatureEventAI_Action const& action = event.action[j];
|
|
switch (action.type)
|
|
{
|
|
case ACTION_T_TEXT:
|
|
case ACTION_T_CHANCED_TEXT:
|
|
{
|
|
// ACTION_T_CHANCED_TEXT contains a chance value in first param
|
|
int k = action.type == ACTION_T_TEXT ? 0 : 1;
|
|
for (; k < 3; ++k)
|
|
if (action.text.TextId[k])
|
|
idx_set.erase(action.text.TextId[k]);
|
|
break;
|
|
}
|
|
default: break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
for (std::set<int32>::const_iterator itr = idx_set.begin(); itr != idx_set.end(); ++itr)
|
|
sLog.outErrorEventAI("Entry %i in table `creature_ai_texts` but not used in EventAI scripts.", *itr);
|
|
}
|
|
|
|
/// Helper function to check if a target-suite is suitable for the event-type
|
|
bool IsValidTargetType(EventAI_Type eventType, EventAI_ActionType actionType, uint32 targetType, uint32 eventId, uint8 action)
|
|
{
|
|
switch (targetType)
|
|
{
|
|
case TARGET_T_SELF:
|
|
if (actionType == ACTION_T_QUEST_EVENT || actionType == ACTION_T_CAST_EVENT || actionType == ACTION_T_QUEST_EVENT_ALL || actionType == ACTION_T_KILLED_MONSTER)
|
|
{
|
|
sLog.outErrorEventAI("Event %u Action%u uses incorrect Target type %u for event-type %u (must target player)", eventId, action, targetType, eventType);
|
|
return false;
|
|
}
|
|
return true; // Can always be used
|
|
case TARGET_T_HOSTILE_RANDOM:
|
|
case TARGET_T_HOSTILE_RANDOM_NOT_TOP:
|
|
if (actionType == ACTION_T_QUEST_EVENT || actionType == ACTION_T_CAST_EVENT || actionType == ACTION_T_QUEST_EVENT_ALL || actionType == ACTION_T_KILLED_MONSTER)
|
|
sLog.outErrorEventAI("Event %u Action%u uses LIKELY bad Target type %u for event-type %u (must target player)", eventId, action, targetType, eventType);
|
|
// no break, check if valid at all
|
|
case TARGET_T_HOSTILE:
|
|
case TARGET_T_HOSTILE_SECOND_AGGRO:
|
|
case TARGET_T_HOSTILE_LAST_AGGRO:
|
|
case TARGET_T_HOSTILE_RANDOM_PLAYER:
|
|
case TARGET_T_HOSTILE_RANDOM_NOT_TOP_PLAYER:
|
|
switch (eventType)
|
|
{
|
|
case EVENT_T_TIMER_OOC:
|
|
case EVENT_T_OOC_LOS:
|
|
case EVENT_T_REACHED_HOME:
|
|
sLog.outErrorEventAI("Event %u Action%u uses incorrect Target type %u for event-type %u (cannot be used OOC)", eventId, action, targetType, eventType);
|
|
return false;
|
|
case EVENT_T_TIMER_GENERIC:
|
|
sLog.outErrorEventAI("Event %u Action%u uses LIKELY incorrect Target type %u for event-type %u (cannot be used OOC)", eventId, action, targetType, eventType);
|
|
return true; // Does not need to be an error
|
|
default:
|
|
return true;
|
|
}
|
|
case TARGET_T_ACTION_INVOKER: // Unit who caused this Event to occur (only works for EVENT_T_AGGRO, EVENT_T_KILL, EVENT_T_DEATH, EVENT_T_SPELLHIT, EVENT_T_OOC_LOS, EVENT_T_FRIENDLY_HP, EVENT_T_FRIENDLY_IS_CC, EVENT_T_FRIENDLY_MISSING_BUFF, EVENT_T_RECEIVE_EMOTE, EVENT_T_RECEIVE_AI_EVENT)
|
|
case TARGET_T_ACTION_INVOKER_OWNER: // Unit who is responsible for Event to occur (only works for EVENT_T_AGGRO, EVENT_T_KILL, EVENT_T_DEATH, EVENT_T_SPELLHIT, EVENT_T_OOC_LOS, EVENT_T_FRIENDLY_HP, EVENT_T_FRIENDLY_IS_CC, EVENT_T_FRIENDLY_MISSING_BUFF, EVENT_T_RECEIVE_EMOTE, EVENT_T_RECEIVE_AI_EVENT)
|
|
switch (eventType)
|
|
{
|
|
case EVENT_T_AGGRO:
|
|
case EVENT_T_KILL:
|
|
case EVENT_T_DEATH:
|
|
case EVENT_T_SPELLHIT:
|
|
case EVENT_T_OOC_LOS:
|
|
case EVENT_T_FRIENDLY_HP:
|
|
case EVENT_T_FRIENDLY_IS_CC:
|
|
case EVENT_T_FRIENDLY_MISSING_BUFF:
|
|
case EVENT_T_RECEIVE_EMOTE:
|
|
case EVENT_T_RECEIVE_AI_EVENT:
|
|
return true;
|
|
default:
|
|
sLog.outErrorEventAI("Event %u Action%u uses incorrect Target type %u for event-type %u", eventId, action, targetType, eventType);
|
|
return false;
|
|
}
|
|
case TARGET_T_EVENT_SENDER: // Unit who sent an AIEvent that was received with EVENT_T_RECEIVE_AI_EVENT
|
|
if (eventType != EVENT_T_RECEIVE_AI_EVENT)
|
|
{
|
|
sLog.outErrorEventAI("Event %u Action%u uses incorrect Target type %u for event-type %u", eventId, action, targetType, eventType);
|
|
return false;
|
|
}
|
|
return true;
|
|
default:
|
|
sLog.outErrorEventAI("Event %u Action%u uses incorrect Target type", eventId, action);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// -------------------
|
|
void CreatureEventAIMgr::LoadCreatureEventAI_Summons(bool check_entry_use)
|
|
{
|
|
// Drop Existing EventSummon Map
|
|
m_CreatureEventAI_Summon_Map.clear();
|
|
|
|
// Gather additional data for EventAI
|
|
QueryResult* result = WorldDatabase.Query("SELECT id, position_x, position_y, position_z, orientation, spawntimesecs FROM creature_ai_summons");
|
|
if (result)
|
|
{
|
|
BarGoLink bar(result->GetRowCount());
|
|
uint32 Count = 0;
|
|
|
|
do
|
|
{
|
|
bar.step();
|
|
Field* fields = result->Fetch();
|
|
|
|
CreatureEventAI_Summon temp;
|
|
|
|
temp.id = fields[0].GetUInt32();
|
|
temp.position_x = fields[1].GetFloat();
|
|
temp.position_y = fields[2].GetFloat();
|
|
temp.position_z = fields[3].GetFloat();
|
|
temp.orientation = fields[4].GetFloat();
|
|
temp.SpawnTimeSecs = fields[5].GetUInt32();
|
|
|
|
if (!MaNGOS::IsValidMapCoord(temp.position_x, temp.position_y, temp.position_z, temp.orientation))
|
|
{
|
|
sLog.outErrorEventAI("Summon id %u have wrong coordinates (%f, %f, %f, %f), skipping.", temp.id, temp.position_x, temp.position_y, temp.position_z, temp.orientation);
|
|
continue;
|
|
}
|
|
|
|
// Add to map
|
|
m_CreatureEventAI_Summon_Map[temp.id] = temp;
|
|
++Count;
|
|
}
|
|
while (result->NextRow());
|
|
|
|
delete result;
|
|
|
|
if (check_entry_use)
|
|
CheckUnusedAISummons();
|
|
|
|
sLog.outString();
|
|
sLog.outString(">> Loaded %u CreatureEventAI summon definitions", Count);
|
|
}
|
|
else
|
|
{
|
|
BarGoLink bar(1);
|
|
bar.step();
|
|
sLog.outString();
|
|
sLog.outString(">> Loaded 0 CreatureEventAI Summon definitions. DB table `creature_ai_summons` is empty.");
|
|
}
|
|
}
|
|
|
|
void CreatureEventAIMgr::CheckUnusedAISummons()
|
|
{
|
|
std::set<int32> idx_set;
|
|
// check not used strings this is negative range
|
|
for (CreatureEventAI_Summon_Map::const_iterator itr = m_CreatureEventAI_Summon_Map.begin(); itr != m_CreatureEventAI_Summon_Map.end(); ++itr)
|
|
idx_set.insert(itr->first);
|
|
|
|
for (CreatureEventAI_Event_Map::const_iterator itr = m_CreatureEventAI_Event_Map.begin(); itr != m_CreatureEventAI_Event_Map.end(); ++itr)
|
|
{
|
|
for (size_t i = 0; i < itr->second.size(); ++i)
|
|
{
|
|
CreatureEventAI_Event const& event = itr->second[i];
|
|
|
|
for (int j = 0; j < MAX_ACTIONS; ++j)
|
|
{
|
|
CreatureEventAI_Action const& action = event.action[j];
|
|
switch (action.type)
|
|
{
|
|
case ACTION_T_SUMMON_ID:
|
|
{
|
|
if (action.summon_id.spawnId)
|
|
idx_set.erase(action.summon_id.spawnId);
|
|
break;
|
|
}
|
|
default: break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
for (std::set<int32>::const_iterator itr = idx_set.begin(); itr != idx_set.end(); ++itr)
|
|
sLog.outErrorEventAI("Entry %i in table `creature_ai_summons` but not used in EventAI scripts.", *itr);
|
|
}
|
|
|
|
// -------------------
|
|
void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
|
|
{
|
|
// Drop Existing EventAI List
|
|
m_CreatureEventAI_Event_Map.clear();
|
|
std::set<int32> usedTextIds;
|
|
|
|
// Gather event data
|
|
QueryResult* result = WorldDatabase.Query("SELECT id, creature_id, event_type, event_inverse_phase_mask, event_chance, event_flags, "
|
|
"event_param1, event_param2, event_param3, event_param4, "
|
|
"action1_type, action1_param1, action1_param2, action1_param3, "
|
|
"action2_type, action2_param1, action2_param2, action2_param3, "
|
|
"action3_type, action3_param1, action3_param2, action3_param3 "
|
|
"FROM creature_ai_scripts");
|
|
if (result)
|
|
{
|
|
BarGoLink bar(result->GetRowCount());
|
|
uint32 Count = 0;
|
|
|
|
do
|
|
{
|
|
bar.step();
|
|
Field* fields = result->Fetch();
|
|
|
|
CreatureEventAI_Event temp;
|
|
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;
|
|
|
|
uint32 e_type = fields[2].GetUInt32();
|
|
// Report any errors in event
|
|
if (e_type >= EVENT_T_END)
|
|
{
|
|
sLog.outErrorEventAI("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.raw.param1 = fields[6].GetUInt32();
|
|
temp.raw.param2 = fields[7].GetUInt32();
|
|
temp.raw.param3 = fields[8].GetUInt32();
|
|
temp.raw.param4 = fields[9].GetUInt32();
|
|
|
|
// Creature does not exist in database
|
|
if (!sCreatureStorage.LookupEntry<CreatureInfo>(temp.creature_id))
|
|
{
|
|
sLog.outErrorEventAI("Event %u has script for non-existing creature entry (%u), skipping.", i, temp.creature_id);
|
|
continue;
|
|
}
|
|
|
|
// No chance of this event occuring
|
|
if (temp.event_chance == 0)
|
|
sLog.outErrorEventAI("Event %u has 0 percent chance. Event will never trigger!", i);
|
|
// Chance above 100, force it to be 100
|
|
else if (temp.event_chance > 100)
|
|
{
|
|
sLog.outErrorEventAI("Creature %u are using event %u with more than 100 percent chance. Adjusting to 100 percent.", temp.creature_id, i);
|
|
temp.event_chance = 100;
|
|
}
|
|
|
|
// Individual event checks
|
|
switch (temp.event_type)
|
|
{
|
|
case EVENT_T_TIMER_IN_COMBAT:
|
|
case EVENT_T_TIMER_OOC:
|
|
case EVENT_T_TIMER_GENERIC:
|
|
if (temp.timer.initialMax < temp.timer.initialMin)
|
|
sLog.outErrorEventAI("Creature %u are using timed event(%u) with param2 < param1 (InitialMax < InitialMin). Event will never repeat.", temp.creature_id, i);
|
|
if (temp.timer.repeatMax < temp.timer.repeatMin)
|
|
sLog.outErrorEventAI("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:
|
|
case EVENT_T_TARGET_MANA:
|
|
if (temp.percent_range.percentMax > 100)
|
|
sLog.outErrorEventAI("Creature %u are using percentage event(%u) with param2 (MinPercent) > 100. Event will never trigger! ", temp.creature_id, i);
|
|
|
|
if (temp.percent_range.percentMax <= temp.percent_range.percentMin)
|
|
sLog.outErrorEventAI("Creature %u are using percentage event(%u) with param1 <= param2 (MaxPercent <= MinPercent). Event will never trigger! ", temp.creature_id, i);
|
|
|
|
if (temp.event_flags & EFLAG_REPEATABLE && !temp.percent_range.repeatMin && !temp.percent_range.repeatMax)
|
|
{
|
|
sLog.outErrorEventAI("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;
|
|
case EVENT_T_SPELLHIT:
|
|
if (temp.spell_hit.spellId)
|
|
{
|
|
SpellEntry const* pSpell = sSpellStore.LookupEntry(temp.spell_hit.spellId);
|
|
if (!pSpell)
|
|
{
|
|
sLog.outErrorEventAI("Creature %u has nonexistent SpellID(%u) defined in event %u.", temp.creature_id, temp.spell_hit.spellId, i);
|
|
continue;
|
|
}
|
|
|
|
if ((temp.spell_hit.schoolMask & pSpell->SchoolMask) != pSpell->SchoolMask)
|
|
sLog.outErrorEventAI("Creature %u has param1(spellId %u) but param2 is not -1 and not equal to spell's school mask. Event %u can never trigger.", temp.creature_id, temp.spell_hit.schoolMask, i);
|
|
}
|
|
|
|
if (!temp.spell_hit.schoolMask)
|
|
sLog.outErrorEventAI("Creature %u is using invalid SpellSchoolMask(%u) defined in event %u.", temp.creature_id, temp.spell_hit.schoolMask, i);
|
|
|
|
if (temp.spell_hit.repeatMax < temp.spell_hit.repeatMin)
|
|
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
|
|
break;
|
|
case EVENT_T_RANGE:
|
|
if (temp.range.maxDist < temp.range.minDist)
|
|
sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (MaxDist < MinDist). Event will never repeat.", temp.creature_id, i);
|
|
if (temp.range.repeatMax < temp.range.repeatMin)
|
|
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
|
|
break;
|
|
case EVENT_T_OOC_LOS:
|
|
if (temp.ooc_los.repeatMax < temp.ooc_los.repeatMin)
|
|
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
|
|
break;
|
|
case EVENT_T_SPAWNED:
|
|
switch (temp.spawned.condition)
|
|
{
|
|
case SPAWNED_EVENT_ALWAY:
|
|
break;
|
|
case SPAWNED_EVENT_MAP:
|
|
if (!sMapStore.LookupEntry(temp.spawned.conditionValue1))
|
|
sLog.outErrorEventAI("Creature %u are using spawned event(%u) with param1 = %u 'map specific' but map (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1);
|
|
break;
|
|
case SPAWNED_EVENT_ZONE:
|
|
if (!GetAreaEntryByAreaID(temp.spawned.conditionValue1))
|
|
sLog.outErrorEventAI("Creature %u are using spawned event(%u) with param1 = %u 'area specific' but area (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1);
|
|
break;
|
|
default:
|
|
sLog.outErrorEventAI("Creature %u are using invalid spawned event %u mode (%u) in param1", temp.creature_id, i, temp.spawned.condition);
|
|
break;
|
|
}
|
|
break;
|
|
case EVENT_T_FRIENDLY_HP:
|
|
if (temp.friendly_hp.repeatMax < temp.friendly_hp.repeatMin)
|
|
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
|
|
break;
|
|
case EVENT_T_FRIENDLY_IS_CC:
|
|
if (temp.friendly_is_cc.repeatMax < temp.friendly_is_cc.repeatMin)
|
|
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
|
|
break;
|
|
case EVENT_T_FRIENDLY_MISSING_BUFF:
|
|
{
|
|
SpellEntry const* pSpell = sSpellStore.LookupEntry(temp.friendly_buff.spellId);
|
|
if (!pSpell)
|
|
{
|
|
sLog.outErrorEventAI("Creature %u has nonexistent SpellID(%u) defined in event %u.", temp.creature_id, temp.friendly_buff.spellId, i);
|
|
continue;
|
|
}
|
|
if (temp.friendly_buff.radius <= 0)
|
|
{
|
|
sLog.outErrorEventAI("Creature %u has wrong radius (%u) for EVENT_T_FRIENDLY_MISSING_BUFF defined in event %u.", temp.creature_id, temp.friendly_buff.radius, i);
|
|
continue;
|
|
}
|
|
if (temp.friendly_buff.repeatMax < temp.friendly_buff.repeatMin)
|
|
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
|
|
break;
|
|
}
|
|
case EVENT_T_KILL:
|
|
if (temp.kill.repeatMax < temp.kill.repeatMin)
|
|
sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
|
|
break;
|
|
case EVENT_T_TARGET_CASTING:
|
|
if (temp.target_casting.repeatMax < temp.target_casting.repeatMin)
|
|
sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
|
|
break;
|
|
case EVENT_T_SUMMONED_UNIT:
|
|
case EVENT_T_SUMMONED_JUST_DIED:
|
|
case EVENT_T_SUMMONED_JUST_DESPAWN:
|
|
if (!sCreatureStorage.LookupEntry<CreatureInfo>(temp.summoned.creatureId))
|
|
sLog.outErrorEventAI("Creature %u are using event(%u) with nonexistent creature template id (%u) in param1, skipped.", temp.creature_id, i, temp.summoned.creatureId);
|
|
if (temp.summoned.repeatMax < temp.summoned.repeatMin)
|
|
sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
|
|
break;
|
|
case EVENT_T_QUEST_ACCEPT:
|
|
case EVENT_T_QUEST_COMPLETE:
|
|
if (!sObjectMgr.GetQuestTemplate(temp.quest.questId))
|
|
sLog.outErrorEventAI("Creature %u are using event(%u) with nonexistent quest id (%u) in param1, skipped.", temp.creature_id, i, temp.quest.questId);
|
|
sLog.outErrorEventAI("Creature %u using not implemented event (%u) in event %u.", temp.creature_id, temp.event_id, i);
|
|
continue;
|
|
|
|
case EVENT_T_AGGRO:
|
|
case EVENT_T_DEATH:
|
|
case EVENT_T_EVADE:
|
|
case EVENT_T_REACHED_HOME:
|
|
{
|
|
if (temp.event_flags & EFLAG_REPEATABLE)
|
|
{
|
|
sLog.outErrorEventAI("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.receive_emote.emoteId))
|
|
{
|
|
sLog.outErrorEventAI("Creature %u using event %u: param1 (EmoteTextId: %u) are not valid.", temp.creature_id, i, temp.receive_emote.emoteId);
|
|
continue;
|
|
}
|
|
|
|
if (!PlayerCondition::IsValid(0, ConditionType(temp.receive_emote.condition), temp.receive_emote.conditionValue1, temp.receive_emote.conditionValue2))
|
|
{
|
|
sLog.outErrorEventAI("Creature %u using event %u: param2 (Condition: %u) are not valid.", temp.creature_id, i, temp.receive_emote.condition);
|
|
continue;
|
|
}
|
|
|
|
if (!(temp.event_flags & EFLAG_REPEATABLE))
|
|
{
|
|
sLog.outErrorEventAI("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_AURA:
|
|
case EVENT_T_TARGET_AURA:
|
|
case EVENT_T_MISSING_AURA:
|
|
case EVENT_T_TARGET_MISSING_AURA:
|
|
{
|
|
SpellEntry const* pSpell = sSpellStore.LookupEntry(temp.buffed.spellId);
|
|
if (!pSpell)
|
|
{
|
|
sLog.outErrorEventAI("Creature %u has nonexistent SpellID(%u) defined in event %u.", temp.creature_id, temp.buffed.spellId, i);
|
|
continue;
|
|
}
|
|
if (temp.buffed.amount < 1)
|
|
{
|
|
sLog.outErrorEventAI("Creature %u has wrong spell stack size (%u) defined in event %u.", temp.creature_id, temp.buffed.amount, i);
|
|
continue;
|
|
}
|
|
if (temp.buffed.repeatMax < temp.buffed.repeatMin)
|
|
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
|
|
break;
|
|
}
|
|
case EVENT_T_RECEIVE_AI_EVENT:
|
|
{
|
|
// Sender-Creature does not exist in database
|
|
if (temp.receiveAIEvent.senderEntry && !sCreatureStorage.LookupEntry<CreatureInfo>(temp.receiveAIEvent.senderEntry))
|
|
{
|
|
sLog.outErrorEventAI("Event %u has nonexisting creature (%u) defined for event RECEIVE_AI_EVENT, skipping.", i, temp.receiveAIEvent.senderEntry);
|
|
continue;
|
|
}
|
|
// Event-Type is not defined
|
|
if (temp.receiveAIEvent.eventType >= MAXIMAL_AI_EVENT_EVENTAI)
|
|
{
|
|
sLog.outErrorEventAI("Event %u has unfitting event-type (%u) defined for event RECEIVE_AI_EVENT (must be less than %u), skipping.", i, temp.receiveAIEvent.eventType, MAXIMAL_AI_EVENT_EVENTAI);
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
sLog.outErrorEventAI("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)
|
|
{
|
|
uint16 action_type = fields[10 + (j * 4)].GetUInt16();
|
|
if (action_type >= ACTION_T_END)
|
|
{
|
|
sLog.outErrorEventAI("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;
|
|
}
|
|
|
|
CreatureEventAI_Action& action = temp.action[j];
|
|
|
|
action.type = EventAI_ActionType(action_type);
|
|
action.raw.param1 = fields[11 + (j * 4)].GetUInt32();
|
|
action.raw.param2 = fields[12 + (j * 4)].GetUInt32();
|
|
action.raw.param3 = fields[13 + (j * 4)].GetUInt32();
|
|
|
|
// Report any errors in actions
|
|
switch (action.type)
|
|
{
|
|
case ACTION_T_NONE:
|
|
break;
|
|
case ACTION_T_CHANCED_TEXT:
|
|
// Check first param as chance
|
|
if (!action.chanced_text.chance)
|
|
sLog.outErrorEventAI("Event %u Action %u has not set chance param1. Text will not be displayed", i, j + 1);
|
|
else if (action.chanced_text.chance >= 100)
|
|
sLog.outErrorEventAI("Event %u Action %u has set chance param1 >= 100. Text will always be displayed", i, j + 1);
|
|
// no break here to check texts
|
|
case ACTION_T_TEXT:
|
|
{
|
|
bool not_set = false;
|
|
int firstTextParam = action.type == ACTION_T_TEXT ? 0 : 1;
|
|
for (int k = firstTextParam; k < 3; ++k)
|
|
{
|
|
if (action.text.TextId[k])
|
|
{
|
|
if (k > firstTextParam && not_set)
|
|
sLog.outErrorEventAI("Event %u Action %u has param%d, but it follow after not set param. Required for randomized text.", i, j + 1, k + 1);
|
|
|
|
if (!action.text.TextId[k])
|
|
not_set = true;
|
|
// range negative
|
|
else if (action.text.TextId[k] > MIN_CREATURE_AI_TEXT_STRING_ID || action.text.TextId[k] <= MAX_CREATURE_AI_TEXT_STRING_ID)
|
|
{
|
|
sLog.outErrorEventAI("Event %u Action %u param%d references out-of-range entry (%i) in texts table.", i, j + 1, k + 1, action.text.TextId[k]);
|
|
action.text.TextId[k] = 0;
|
|
}
|
|
else if (!sObjectMgr.GetMangosStringLocale(action.text.TextId[k]))
|
|
{
|
|
sLog.outErrorEventAI("Event %u Action %u param%d references non-existing entry (%i) in texts table.", i, j + 1, k + 1, action.text.TextId[k]);
|
|
action.text.TextId[k] = 0;
|
|
}
|
|
else
|
|
usedTextIds.insert(action.text.TextId[k]);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ACTION_T_SET_FACTION:
|
|
if (action.set_faction.factionId != 0 && !sFactionTemplateStore.LookupEntry(action.set_faction.factionId))
|
|
{
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent FactionId %u.", i, j + 1, action.set_faction.factionId);
|
|
action.set_faction.factionId = 0;
|
|
}
|
|
break;
|
|
case ACTION_T_MORPH_TO_ENTRY_OR_MODEL:
|
|
if (action.morph.creatureId != 0 || action.morph.modelId != 0)
|
|
{
|
|
if (action.morph.creatureId && !sCreatureStorage.LookupEntry<CreatureInfo>(action.morph.creatureId))
|
|
{
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent Creature entry %u.", i, j + 1, action.morph.creatureId);
|
|
action.morph.creatureId = 0;
|
|
}
|
|
|
|
if (action.morph.modelId)
|
|
{
|
|
if (action.morph.creatureId)
|
|
{
|
|
sLog.outErrorEventAI("Event %u Action %u have unused ModelId %u with also set creature id %u.", i, j + 1, action.morph.modelId, action.morph.creatureId);
|
|
action.morph.modelId = 0;
|
|
}
|
|
else if (!sCreatureDisplayInfoStore.LookupEntry(action.morph.modelId))
|
|
{
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent ModelId %u.", i, j + 1, action.morph.modelId);
|
|
action.morph.modelId = 0;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case ACTION_T_SOUND:
|
|
if (!sSoundEntriesStore.LookupEntry(action.sound.soundId))
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent SoundID %u.", i, j + 1, action.sound.soundId);
|
|
break;
|
|
case ACTION_T_EMOTE:
|
|
if (!sEmotesStore.LookupEntry(action.emote.emoteId))
|
|
sLog.outErrorEventAI("Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j + 1, action.emote.emoteId);
|
|
break;
|
|
case ACTION_T_RANDOM_SOUND:
|
|
if (!sSoundEntriesStore.LookupEntry(action.random_sound.soundId1))
|
|
sLog.outErrorEventAI("Event %u Action %u param1 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId1);
|
|
if (action.random_sound.soundId2 >= 0 && !sSoundEntriesStore.LookupEntry(action.random_sound.soundId2))
|
|
sLog.outErrorEventAI("Event %u Action %u param2 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId2);
|
|
if (action.random_sound.soundId3 >= 0 && !sSoundEntriesStore.LookupEntry(action.random_sound.soundId3))
|
|
sLog.outErrorEventAI("Event %u Action %u param3 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId3);
|
|
break;
|
|
case ACTION_T_RANDOM_EMOTE:
|
|
if (!sEmotesStore.LookupEntry(action.random_emote.emoteId1))
|
|
sLog.outErrorEventAI("Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId1);
|
|
if (action.random_emote.emoteId2 >= 0 && !sEmotesStore.LookupEntry(action.random_emote.emoteId2))
|
|
sLog.outErrorEventAI("Event %u Action %u param2 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId2);
|
|
if (action.random_emote.emoteId3 >= 0 && !sEmotesStore.LookupEntry(action.random_emote.emoteId3))
|
|
sLog.outErrorEventAI("Event %u Action %u param3 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId3);
|
|
break;
|
|
case ACTION_T_CAST:
|
|
{
|
|
const SpellEntry* spell = sSpellStore.LookupEntry(action.cast.spellId);
|
|
if (!spell)
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast.spellId);
|
|
/* FIXME: temp.raw.param3 not have event tipes with recovery time in it....
|
|
else
|
|
{
|
|
if (spell->RecoveryTime > 0 && temp.event_flags & EFLAG_REPEATABLE)
|
|
{
|
|
// output as debug for now, also because there's no general rule all spells have RecoveryTime
|
|
if (temp.event_param3 < spell->RecoveryTime)
|
|
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "CreatureEventAI: Event %u Action %u uses SpellID %u but cooldown is longer(%u) than minumum defined in event param3(%u).", i, j+1,action.cast.spellId, spell->RecoveryTime, temp.event_param3);
|
|
}
|
|
}
|
|
*/
|
|
|
|
// Cast is always triggered if target is forced to cast on self
|
|
if (action.cast.castFlags & CAST_FORCE_TARGET_SELF)
|
|
action.cast.castFlags |= CAST_TRIGGERED;
|
|
|
|
IsValidTargetType(temp.event_type, action.type, action.cast.target, i, j + 1);
|
|
|
|
// Some Advanced target type checks - Can have false positives
|
|
if (!sLog.HasLogFilter(LOG_FILTER_EVENT_AI_DEV) && spell)
|
|
{
|
|
// spell must be cast on self, but is not
|
|
if ((IsOnlySelfTargeting(spell) || spell->rangeIndex == SPELL_RANGE_IDX_SELF_ONLY) && action.cast.target != TARGET_T_SELF && !(action.cast.castFlags & CAST_FORCE_TARGET_SELF))
|
|
sLog.outErrorEventAI("Event %u Action %u uses SpellID %u that must be self cast (target is %u)", i, j + 1, action.cast.spellId, action.cast.target);
|
|
|
|
// TODO: spell must be cast on enemy, but is not
|
|
|
|
// used TARGET_T_ACTION_INVOKER, but likely should be _INVOKER_OWNER instead
|
|
if (action.cast.target == TARGET_T_ACTION_INVOKER &&
|
|
(IsSpellHaveEffect(spell, SPELL_EFFECT_QUEST_COMPLETE) || IsSpellHaveEffect(spell, SPELL_EFFECT_CREATE_RANDOM_ITEM) || IsSpellHaveEffect(spell, SPELL_EFFECT_DUMMY)
|
|
|| IsSpellHaveEffect(spell, SPELL_EFFECT_KILL_CREDIT_PERSONAL) || IsSpellHaveEffect(spell, SPELL_EFFECT_KILL_CREDIT_GROUP)))
|
|
sLog.outErrorEventAI("Event %u Action %u has TARGET_T_ACTION_INVOKER(%u) target type, but should have TARGET_T_ACTION_INVOKER_OWNER(%u).", i, j + 1, TARGET_T_ACTION_INVOKER, TARGET_T_ACTION_INVOKER_OWNER);
|
|
|
|
// Spell that should only target players, but could get any
|
|
if (spell->HasAttribute(SPELL_ATTR_EX3_TARGET_ONLY_PLAYER) &&
|
|
(action.cast.target == TARGET_T_ACTION_INVOKER || action.cast.target == TARGET_T_HOSTILE_RANDOM || action.cast.target == TARGET_T_HOSTILE_RANDOM_NOT_TOP))
|
|
sLog.outErrorEventAI("Event %u Action %u uses Target type %u for a spell (%u) that should only target players. This could be wrong.", i, j + 1, action.cast.target, action.cast.spellId);
|
|
}
|
|
break;
|
|
}
|
|
case ACTION_T_SUMMON:
|
|
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.summon.creatureId))
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.summon.creatureId);
|
|
|
|
IsValidTargetType(temp.event_type, action.type, action.summon.target, i, j + 1);
|
|
break;
|
|
case ACTION_T_THREAT_SINGLE_PCT:
|
|
if (std::abs(action.threat_single_pct.percent) > 100)
|
|
sLog.outErrorEventAI("Event %u Action %u uses invalid percent value %u.", i, j + 1, action.threat_single_pct.percent);
|
|
IsValidTargetType(temp.event_type, action.type, action.threat_single_pct.target, i, j + 1);
|
|
break;
|
|
case ACTION_T_THREAT_ALL_PCT:
|
|
if (std::abs(action.threat_all_pct.percent) > 100)
|
|
sLog.outErrorEventAI("Event %u Action %u uses invalid percent value %u.", i, j + 1, action.threat_all_pct.percent);
|
|
break;
|
|
case ACTION_T_QUEST_EVENT:
|
|
if (Quest const* qid = sObjectMgr.GetQuestTemplate(action.quest_event.questId))
|
|
{
|
|
if (!qid->HasSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT))
|
|
sLog.outErrorEventAI("Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j + 1, action.quest_event.questId);
|
|
}
|
|
else
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent Quest entry %u.", i, j + 1, action.quest_event.questId);
|
|
|
|
IsValidTargetType(temp.event_type, action.type, action.quest_event.target, i, j + 1);
|
|
break;
|
|
case ACTION_T_CAST_EVENT:
|
|
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.cast_event.creatureId))
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.cast_event.creatureId);
|
|
if (!sSpellStore.LookupEntry(action.cast_event.spellId))
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast_event.spellId);
|
|
IsValidTargetType(temp.event_type, action.type, action.cast_event.target, i, j + 1);
|
|
break;
|
|
case ACTION_T_SET_UNIT_FIELD:
|
|
if (action.set_unit_field.field < OBJECT_END || action.set_unit_field.field >= UNIT_END)
|
|
sLog.outErrorEventAI("Event %u Action %u param1 (UNIT_FIELD*). Index out of range for intended use.", i, j + 1);
|
|
IsValidTargetType(temp.event_type, action.type, action.set_unit_field.target, i, j + 1);
|
|
break;
|
|
case ACTION_T_SET_UNIT_FLAG:
|
|
case ACTION_T_REMOVE_UNIT_FLAG:
|
|
IsValidTargetType(temp.event_type, action.type, action.unit_flag.target, i, j + 1);
|
|
break;
|
|
case ACTION_T_SET_PHASE:
|
|
if (action.set_phase.phase >= MAX_PHASE)
|
|
sLog.outErrorEventAI("Event %u Action %u attempts to set phase >= %u. Phase mask cannot be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1);
|
|
break;
|
|
case ACTION_T_INC_PHASE:
|
|
if (action.set_inc_phase.step == 0)
|
|
sLog.outErrorEventAI("Event %u Action %u is incrementing phase by 0. Was this intended?", i, j + 1);
|
|
else if (std::abs(action.set_inc_phase.step) > MAX_PHASE - 1)
|
|
sLog.outErrorEventAI("Event %u Action %u is change phase by too large for any use %i.", i, j + 1, action.set_inc_phase.step);
|
|
break;
|
|
case ACTION_T_QUEST_EVENT_ALL:
|
|
if (Quest const* qid = sObjectMgr.GetQuestTemplate(action.quest_event_all.questId))
|
|
{
|
|
if (!qid->HasSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT))
|
|
sLog.outErrorEventAI("Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j + 1, action.quest_event_all.questId);
|
|
}
|
|
else
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent Quest entry %u.", i, j + 1, action.quest_event_all.questId);
|
|
break;
|
|
case ACTION_T_CAST_EVENT_ALL:
|
|
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.cast_event_all.creatureId))
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.cast_event_all.creatureId);
|
|
if (!sSpellStore.LookupEntry(action.cast_event_all.spellId))
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast_event_all.spellId);
|
|
break;
|
|
case ACTION_T_REMOVEAURASFROMSPELL:
|
|
if (!sSpellStore.LookupEntry(action.remove_aura.spellId))
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.remove_aura.spellId);
|
|
IsValidTargetType(temp.event_type, action.type, action.remove_aura.target, i, j + 1);
|
|
break;
|
|
case ACTION_T_RANDOM_PHASE: // PhaseId1, PhaseId2, PhaseId3
|
|
if (action.random_phase.phase1 >= MAX_PHASE)
|
|
sLog.outErrorEventAI("Event %u Action %u attempts to set phase1 >= %u. Phase mask cannot be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1);
|
|
if (action.random_phase.phase2 >= MAX_PHASE)
|
|
sLog.outErrorEventAI("Event %u Action %u attempts to set phase2 >= %u. Phase mask cannot be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1);
|
|
if (action.random_phase.phase3 >= MAX_PHASE)
|
|
sLog.outErrorEventAI("Event %u Action %u attempts to set phase3 >= %u. Phase mask cannot be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1);
|
|
break;
|
|
case ACTION_T_RANDOM_PHASE_RANGE: // PhaseMin, PhaseMax
|
|
if (action.random_phase_range.phaseMin >= MAX_PHASE)
|
|
sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMin >= %u. Phase mask cannot be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1);
|
|
if (action.random_phase_range.phaseMin >= MAX_PHASE)
|
|
sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMax >= %u. Phase mask cannot be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1);
|
|
if (action.random_phase_range.phaseMin >= action.random_phase_range.phaseMax)
|
|
{
|
|
sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMax <= phaseMin.", i, j + 1);
|
|
std::swap(action.random_phase_range.phaseMin, action.random_phase_range.phaseMax);
|
|
// equal case processed at call
|
|
}
|
|
break;
|
|
case ACTION_T_SUMMON_ID:
|
|
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.summon_id.creatureId))
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.summon_id.creatureId);
|
|
IsValidTargetType(temp.event_type, action.type, action.summon_id.target, i, j + 1);
|
|
if (m_CreatureEventAI_Summon_Map.find(action.summon_id.spawnId) == m_CreatureEventAI_Summon_Map.end())
|
|
sLog.outErrorEventAI("Event %u Action %u summons missing CreatureEventAI_Summon %u", i, j + 1, action.summon_id.spawnId);
|
|
break;
|
|
case ACTION_T_KILLED_MONSTER:
|
|
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.killed_monster.creatureId))
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.killed_monster.creatureId);
|
|
IsValidTargetType(temp.event_type, action.type, action.killed_monster.target, i, j + 1);
|
|
break;
|
|
case ACTION_T_SET_INST_DATA:
|
|
if (!(temp.event_flags & EFLAG_DIFFICULTY_ALL))
|
|
sLog.outErrorEventAI("Event %u Action %u. Cannot set instance data without difficulty event flags.", i, j + 1);
|
|
if (action.set_inst_data.value > 4/*SPECIAL*/)
|
|
sLog.outErrorEventAI("Event %u Action %u attempts to set instance data above encounter state 4. Custom case?", i, j + 1);
|
|
break;
|
|
case ACTION_T_SET_INST_DATA64:
|
|
if (!(temp.event_flags & EFLAG_DIFFICULTY_ALL))
|
|
sLog.outErrorEventAI("Event %u Action %u. Cannot set instance data without difficulty event flags.", i, j + 1);
|
|
IsValidTargetType(temp.event_type, action.type, action.set_inst_data64.target, i, j + 1);
|
|
break;
|
|
case ACTION_T_UPDATE_TEMPLATE:
|
|
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.update_template.creatureId))
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.update_template.creatureId);
|
|
break;
|
|
case ACTION_T_SET_SHEATH:
|
|
if (action.set_sheath.sheath >= MAX_SHEATH_STATE)
|
|
{
|
|
sLog.outErrorEventAI("Event %u Action %u uses wrong sheath state %u.", i, j + 1, action.set_sheath.sheath);
|
|
action.set_sheath.sheath = SHEATH_STATE_UNARMED;
|
|
}
|
|
break;
|
|
case ACTION_T_SET_INVINCIBILITY_HP_LEVEL:
|
|
if (action.invincibility_hp_level.is_percent)
|
|
{
|
|
if (action.invincibility_hp_level.hp_level > 100)
|
|
{
|
|
sLog.outErrorEventAI("Event %u Action %u uses wrong percent value %u.", i, j + 1, action.invincibility_hp_level.hp_level);
|
|
action.invincibility_hp_level.hp_level = 100;
|
|
}
|
|
}
|
|
break;
|
|
case ACTION_T_MOUNT_TO_ENTRY_OR_MODEL:
|
|
if (action.mount.creatureId != 0 || action.mount.modelId != 0)
|
|
{
|
|
if (action.mount.creatureId && !sCreatureStorage.LookupEntry<CreatureInfo>(action.mount.creatureId))
|
|
{
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent Creature entry %u.", i, j + 1, action.mount.creatureId);
|
|
action.morph.creatureId = 0;
|
|
}
|
|
|
|
if (action.mount.modelId)
|
|
{
|
|
if (action.mount.creatureId)
|
|
{
|
|
sLog.outErrorEventAI("Event %u Action %u have unused ModelId %u with also set creature id %u.", i, j + 1, action.mount.modelId, action.mount.creatureId);
|
|
action.mount.modelId = 0;
|
|
}
|
|
else if (!sCreatureDisplayInfoStore.LookupEntry(action.mount.modelId))
|
|
{
|
|
sLog.outErrorEventAI("Event %u Action %u uses nonexistent ModelId %u.", i, j + 1, action.mount.modelId);
|
|
action.mount.modelId = 0;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case ACTION_T_EVADE: // No Params
|
|
case ACTION_T_FLEE_FOR_ASSIST: // No Params
|
|
case ACTION_T_DIE: // No Params
|
|
case ACTION_T_ZONE_COMBAT_PULSE: // No Params
|
|
case ACTION_T_FORCE_DESPAWN: // Delay
|
|
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
|
|
case ACTION_T_CALL_FOR_HELP: // Distance
|
|
break;
|
|
|
|
case ACTION_T_RANDOM_SAY:
|
|
case ACTION_T_RANDOM_YELL:
|
|
case ACTION_T_RANDOM_TEXTEMOTE:
|
|
sLog.outErrorEventAI("Event %u Action %u currently unused ACTION type. Did you forget to update database?", i, j + 1);
|
|
break;
|
|
|
|
case ACTION_T_THROW_AI_EVENT:
|
|
if (action.throwEvent.eventType >= MAXIMAL_AI_EVENT_EVENTAI)
|
|
{
|
|
sLog.outErrorEventAI("Event %u Action %u uses invalid event type %u (must be less than %u), skipping", i, j + 1, action.throwEvent.eventType, MAXIMAL_AI_EVENT_EVENTAI);
|
|
continue;
|
|
}
|
|
if (action.throwEvent.radius > SIZE_OF_GRIDS)
|
|
sLog.outErrorEventAI("Event %u Action %u uses unexpectedly huge radius %u (expected to be less than %f)", i, j + 1, action.throwEvent.radius, SIZE_OF_GRIDS);
|
|
|
|
if (action.throwEvent.radius == 0)
|
|
{
|
|
sLog.outErrorEventAI("Event %u Action %u uses unexpected radius 0 (set to %f of CONFIG_FLOAT_CREATURE_FAMILY_ASSISTANCE_RADIUS)", i, j + 1, sWorld.getConfig(CONFIG_FLOAT_CREATURE_FAMILY_ASSISTANCE_RADIUS));
|
|
action.throwEvent.radius = uint32(sWorld.getConfig(CONFIG_FLOAT_CREATURE_FAMILY_ASSISTANCE_RADIUS));
|
|
}
|
|
|
|
break;
|
|
|
|
case ACTION_T_SET_THROW_MASK:
|
|
if (action.setThrowMask.eventTypeMask & ~((1 << MAXIMAL_AI_EVENT_EVENTAI) - 1))
|
|
{
|
|
sLog.outErrorEventAI("Event %u Action %u uses invalid AIEvent-typemask %u (must be smaller than %u)", i, j + 1, action.setThrowMask.eventTypeMask, MAXIMAL_AI_EVENT_EVENTAI << 1);
|
|
continue;
|
|
}
|
|
break;
|
|
default:
|
|
sLog.outErrorEventAI("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;
|
|
}
|
|
}
|
|
|
|
// Add to list
|
|
m_CreatureEventAI_Event_Map[creature_id].push_back(temp);
|
|
++Count;
|
|
}
|
|
while (result->NextRow());
|
|
|
|
delete result;
|
|
m_usedTextsAmount = usedTextIds.size();
|
|
|
|
// post check
|
|
for (uint32 i = 1; i < sCreatureStorage.GetMaxEntry(); ++i)
|
|
{
|
|
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
|
|
{
|
|
bool ainame = strcmp(cInfo->AIName, "EventAI") == 0;
|
|
bool hasevent = m_CreatureEventAI_Event_Map.find(i) != m_CreatureEventAI_Event_Map.end();
|
|
if (ainame && !hasevent)
|
|
sLog.outErrorEventAI("EventAI not has script for creature entry (%u), but AIName = '%s'.", i, cInfo->AIName);
|
|
else if (!ainame && hasevent)
|
|
sLog.outErrorEventAI("EventAI has script for creature entry (%u), but AIName = '%s' instead 'EventAI'.", i, cInfo->AIName);
|
|
}
|
|
}
|
|
|
|
CheckUnusedAITexts();
|
|
CheckUnusedAISummons();
|
|
|
|
sLog.outString();
|
|
sLog.outString(">> Loaded %u CreatureEventAI scripts", Count);
|
|
}
|
|
else
|
|
{
|
|
BarGoLink bar(1);
|
|
bar.step();
|
|
sLog.outString();
|
|
sLog.outString(">> Loaded 0 CreatureEventAI scripts. DB table `creature_ai_scripts` is empty.");
|
|
}
|
|
}
|