mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[12774] Merged cmangos last changes, special thanks for xfurry, Dramacydal, cala, Schmoozerd,
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)
----------
This commit is contained in:
parent
8f8068714c
commit
ae7348f6b0
73 changed files with 2633 additions and 1503 deletions
|
|
@ -59,6 +59,20 @@ void CreatureEventAI::GetAIInformation(ChatHandler& reader)
|
|||
reader.PSendSysMessage(LANG_NPC_EVENTAI_PHASE, (uint32)m_Phase);
|
||||
reader.PSendSysMessage(LANG_NPC_EVENTAI_MOVE, reader.GetOnOffStr(m_isCombatMovement));
|
||||
reader.PSendSysMessage(LANG_NPC_EVENTAI_COMBAT, reader.GetOnOffStr(m_MeleeEnabled));
|
||||
|
||||
if (sLog.HasLogFilter(LOG_FILTER_EVENT_AI_DEV)) // Give some more details if in EventAI Dev Mode
|
||||
return;
|
||||
|
||||
reader.PSendSysMessage("Current events of this creature:");
|
||||
for (CreatureEventAIList::const_iterator itr = m_CreatureEventAIList.begin(); itr != m_CreatureEventAIList.end(); ++itr)
|
||||
{
|
||||
if (itr->Event.action[2].type != ACTION_T_NONE)
|
||||
reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) actions[type(param1)]: %2u(%5u) -- %2u(%u) -- %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time/1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1, itr->Event.action[1].type, itr->Event.action[1].raw.param1, itr->Event.action[2].type, itr->Event.action[2].raw.param1);
|
||||
else if (itr->Event.action[1].type != ACTION_T_NONE)
|
||||
reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) actions[type(param1)]: %2u(%5u) -- %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time/1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1, itr->Event.action[1].type, itr->Event.action[1].raw.param1);
|
||||
else
|
||||
reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) action[type(param1)]: %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time/1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1);
|
||||
}
|
||||
}
|
||||
|
||||
// For Non Dungeon map only allow non-difficulty flags or EFLAG_DIFFICULTY_0 mode
|
||||
|
|
@ -68,7 +82,12 @@ inline bool IsEventFlagsFitForNormalMap(uint8 eFlags)
|
|||
(eFlags & EFLAG_DIFFICULTY_0);
|
||||
}
|
||||
|
||||
CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c)
|
||||
CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c),
|
||||
m_Phase(0),
|
||||
m_MeleeEnabled(true),
|
||||
m_InvinceabilityHpLevel(0),
|
||||
m_throwAIEventMask(0),
|
||||
m_throwAIEventStep(0)
|
||||
{
|
||||
// Need make copy for filter unneeded steps and safe in case table reload
|
||||
CreatureEventAI_Event_Map::const_iterator creatureEventsItr = sEventAIMgr.GetCreatureEventAIMap().find(m_creature->GetEntry());
|
||||
|
|
@ -94,7 +113,7 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c)
|
|||
}
|
||||
// EventMap had events but they were not added because they must be for instance
|
||||
if (events_count == 0)
|
||||
sLog.outError("CreatureEventAI: Creature %u has events but no events added to list because of instance flags.", m_creature->GetEntry());
|
||||
sLog.outErrorEventAI("Creature %u has events but no events added to list because of instance flags.", m_creature->GetEntry());
|
||||
else
|
||||
{
|
||||
m_CreatureEventAIList.reserve(events_count);
|
||||
|
|
@ -121,12 +140,6 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c)
|
|||
else
|
||||
sLog.outErrorEventAI("EventMap for Creature %u is empty but creature is using CreatureEventAI.", m_creature->GetEntry());
|
||||
|
||||
m_bEmptyList = m_CreatureEventAIList.empty();
|
||||
m_Phase = 0;
|
||||
m_MeleeEnabled = true;
|
||||
|
||||
m_InvinceabilityHpLevel = 0;
|
||||
|
||||
// Handle Spawned Events, also calls Reset()
|
||||
JustRespawned();
|
||||
}
|
||||
|
|
@ -476,6 +489,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: Process action %u (script %u) triggered for %s (invoked by %s)",
|
||||
action.type, EventId, m_creature->GetGuidStr().c_str(), pActionInvoker ? pActionInvoker->GetGuidStr().c_str() : "<no invoker>");
|
||||
|
||||
bool reportTargetError = false;
|
||||
switch (action.type)
|
||||
{
|
||||
case ACTION_T_TEXT:
|
||||
|
|
@ -484,27 +498,27 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
if (!action.text.TextId[0])
|
||||
return;
|
||||
|
||||
int32 temp = 0;
|
||||
int32 textId = 0;
|
||||
|
||||
if (action.type == ACTION_T_TEXT)
|
||||
{
|
||||
if (action.text.TextId[1] && action.text.TextId[2])
|
||||
temp = action.text.TextId[urand(0, 2)];
|
||||
textId = action.text.TextId[urand(0, 2)];
|
||||
else if (action.text.TextId[1] && urand(0, 1))
|
||||
temp = action.text.TextId[1];
|
||||
textId = action.text.TextId[1];
|
||||
else
|
||||
temp = action.text.TextId[0];
|
||||
textId = action.text.TextId[0];
|
||||
}
|
||||
// ACTION_T_CHANCED_TEXT, chance hits
|
||||
else if (urand(0, 99) < action.chanced_text.chance)
|
||||
{
|
||||
if (action.chanced_text.TextId[0] && action.chanced_text.TextId[1])
|
||||
temp = action.chanced_text.TextId[urand(0, 1)];
|
||||
textId = action.chanced_text.TextId[urand(0, 1)];
|
||||
else
|
||||
temp = action.chanced_text.TextId[0];
|
||||
textId = action.chanced_text.TextId[0];
|
||||
}
|
||||
|
||||
if (temp)
|
||||
if (textId)
|
||||
{
|
||||
Unit* target = NULL;
|
||||
|
||||
|
|
@ -526,7 +540,8 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
target = owner;
|
||||
}
|
||||
|
||||
DoScriptText(temp, m_creature, target);
|
||||
if (!DoDisplayText(m_creature, textId, target))
|
||||
sLog.outErrorEventAI("Error attempting to display text %i, used by script %u", textId, EventId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -590,10 +605,11 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
selectFlags = SELECT_FLAG_IN_LOS;
|
||||
}
|
||||
|
||||
Unit* target = GetTargetByType(action.cast.target, pActionInvoker, pAIEventSender, spellId, selectFlags);
|
||||
Unit* target = GetTargetByType(action.cast.target, pActionInvoker, pAIEventSender, reportTargetError, spellId, selectFlags);
|
||||
if (!target)
|
||||
{
|
||||
sLog.outErrorEventAI("NULL target for ACTION_T_CAST creature entry %u casting spell id %u", m_creature->GetEntry(), action.cast.spellId);
|
||||
if (reportTargetError)
|
||||
sLog.outErrorEventAI("NULL target for ACTION_T_CAST creature entry %u casting spell id %u", m_creature->GetEntry(), action.cast.spellId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -631,7 +647,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
}
|
||||
case ACTION_T_SUMMON:
|
||||
{
|
||||
Unit* target = GetTargetByType(action.summon.target, pActionInvoker, pAIEventSender);
|
||||
Unit* target = GetTargetByType(action.summon.target, pActionInvoker, pAIEventSender, reportTargetError);
|
||||
if (!target && reportTargetError)
|
||||
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SUMMON(%u), target-type %u", EventId, action.type, action.summon.target);
|
||||
|
||||
Creature* pCreature = NULL;
|
||||
|
||||
|
|
@ -647,8 +665,10 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
break;
|
||||
}
|
||||
case ACTION_T_THREAT_SINGLE_PCT:
|
||||
if (Unit* target = GetTargetByType(action.threat_single_pct.target, pActionInvoker, pAIEventSender))
|
||||
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:
|
||||
{
|
||||
|
|
@ -659,36 +679,48 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
break;
|
||||
}
|
||||
case ACTION_T_QUEST_EVENT:
|
||||
if (Unit* target = GetTargetByType(action.quest_event.target, pActionInvoker, pAIEventSender))
|
||||
if (Unit* target = GetTargetByType(action.quest_event.target, pActionInvoker, pAIEventSender, reportTargetError))
|
||||
{
|
||||
if (target->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)target)->AreaExploredOrEventHappens(action.quest_event.questId);
|
||||
}
|
||||
else if (reportTargetError)
|
||||
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_QUEST_EVENT(%u), target-type %u", EventId, action.type, action.quest_event.target);
|
||||
|
||||
break;
|
||||
case ACTION_T_CAST_EVENT:
|
||||
if (Unit* target = GetTargetByType(action.cast_event.target, pActionInvoker, pAIEventSender, 0, SELECT_FLAG_PLAYER))
|
||||
if (Unit* target = GetTargetByType(action.cast_event.target, pActionInvoker, pAIEventSender, reportTargetError, 0, SELECT_FLAG_PLAYER))
|
||||
{
|
||||
if (target->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)target)->CastedCreatureOrGO(action.cast_event.creatureId, m_creature->GetObjectGuid(), action.cast_event.spellId);
|
||||
}
|
||||
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:
|
||||
{
|
||||
Unit* target = GetTargetByType(action.set_unit_field.target, pActionInvoker, pAIEventSender);
|
||||
Unit* target = GetTargetByType(action.set_unit_field.target, pActionInvoker, pAIEventSender, reportTargetError);
|
||||
|
||||
// not allow modify important for integrity object fields
|
||||
if (action.set_unit_field.field < OBJECT_END || action.set_unit_field.field >= UNIT_END)
|
||||
return;
|
||||
|
||||
if (target)
|
||||
target->SetUInt32Value(action.set_unit_field.field, action.set_unit_field.value);
|
||||
else if (reportTargetError)
|
||||
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SET_UNIT_FIELD(%u), target-type %u", EventId, action.type, action.set_unit_field.target);
|
||||
|
||||
break;
|
||||
}
|
||||
case ACTION_T_SET_UNIT_FLAG:
|
||||
if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker, pAIEventSender))
|
||||
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:
|
||||
if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker, pAIEventSender))
|
||||
if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker, pAIEventSender, reportTargetError))
|
||||
target->RemoveFlag(UNIT_FIELD_FLAGS, action.unit_flag.value);
|
||||
break;
|
||||
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:
|
||||
m_MeleeEnabled = action.auto_attack.state != 0;
|
||||
break;
|
||||
|
|
@ -746,8 +778,10 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
break;
|
||||
}
|
||||
case ACTION_T_REMOVEAURASFROMSPELL:
|
||||
if (Unit* target = GetTargetByType(action.remove_aura.target, pActionInvoker, pAIEventSender))
|
||||
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:
|
||||
m_attackDistance = (float)action.ranged_movement.distance;
|
||||
|
|
@ -775,8 +809,10 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
break;
|
||||
case ACTION_T_SUMMON_ID:
|
||||
{
|
||||
Unit* target = GetTargetByType(action.summon_id.target, pActionInvoker, pAIEventSender);
|
||||
|
||||
Unit* target = GetTargetByType(action.summon_id.target, pActionInvoker, pAIEventSender, reportTargetError);
|
||||
if (!target && reportTargetError)
|
||||
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SUMMON_ID(%u), target-type %u", EventId, action.type, action.summon_id.target);
|
||||
|
||||
CreatureEventAI_Summon_Map::const_iterator i = sEventAIMgr.GetCreatureEventAISummonMap().find(action.summon_id.spawnId);
|
||||
if (i == sEventAIMgr.GetCreatureEventAISummonMap().end())
|
||||
{
|
||||
|
|
@ -804,9 +840,13 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
else
|
||||
{
|
||||
// if not available, use pActionInvoker
|
||||
if (Unit* pTarget = GetTargetByType(action.killed_monster.target, pActionInvoker, 0, SELECT_FLAG_PLAYER))
|
||||
if (Unit* pTarget = GetTargetByType(action.killed_monster.target, pActionInvoker, pAIEventSender, reportTargetError, 0, SELECT_FLAG_PLAYER))
|
||||
{
|
||||
if (Player* pPlayer2 = pTarget->GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||
pPlayer2->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, m_creature);
|
||||
}
|
||||
else if (reportTargetError)
|
||||
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_KILLED_MONSTER(%u), target-type %u", EventId, action.type, action.killed_monster.target);
|
||||
}
|
||||
break;
|
||||
case ACTION_T_SET_INST_DATA:
|
||||
|
|
@ -823,10 +863,11 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
}
|
||||
case ACTION_T_SET_INST_DATA64:
|
||||
{
|
||||
Unit* target = GetTargetByType(action.set_inst_data64.target, pActionInvoker, pAIEventSender);
|
||||
Unit* target = GetTargetByType(action.set_inst_data64.target, pActionInvoker, pAIEventSender, reportTargetError);
|
||||
if (!target)
|
||||
{
|
||||
sLog.outErrorEventAI("Event %d attempt to set instance data64 but Target == NULL. Creature %d", EventId, m_creature->GetEntry());
|
||||
if (reportTargetError)
|
||||
sLog.outErrorEventAI("Event %d attempt to set instance data64 but Target == NULL. Creature %d", EventId, m_creature->GetEntry());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -911,7 +952,12 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
}
|
||||
case ACTION_T_THROW_AI_EVENT:
|
||||
{
|
||||
SendAIEvent(AIEventType(action.throwEvent.eventType), pActionInvoker, 0, action.throwEvent.radius);
|
||||
SendAIEventAround(AIEventType(action.throwEvent.eventType), pActionInvoker, 0, action.throwEvent.radius);
|
||||
break;
|
||||
}
|
||||
case ACTION_T_SET_THROW_MASK:
|
||||
{
|
||||
m_throwAIEventMask = action.setThrowMask.eventTypeMask;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -921,9 +967,6 @@ void CreatureEventAI::JustRespawned() // NOTE that this is
|
|||
{
|
||||
Reset();
|
||||
|
||||
if (m_bEmptyList)
|
||||
return;
|
||||
|
||||
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
|
||||
{
|
||||
// Reset generic timer
|
||||
|
|
@ -943,8 +986,7 @@ void CreatureEventAI::Reset()
|
|||
m_EventUpdateTime = EVENT_UPDATE_TIME;
|
||||
m_EventDiff = 0;
|
||||
|
||||
if (m_bEmptyList)
|
||||
return;
|
||||
m_throwAIEventStep = 0;
|
||||
|
||||
// Reset all events to enabled
|
||||
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
|
||||
|
|
@ -970,13 +1012,10 @@ void CreatureEventAI::Reset()
|
|||
|
||||
void CreatureEventAI::JustReachedHome()
|
||||
{
|
||||
if (!m_bEmptyList)
|
||||
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
|
||||
{
|
||||
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
|
||||
{
|
||||
if ((*i).Event.event_type == EVENT_T_REACHED_HOME)
|
||||
ProcessEvent(*i);
|
||||
}
|
||||
if ((*i).Event.event_type == EVENT_T_REACHED_HOME)
|
||||
ProcessEvent(*i);
|
||||
}
|
||||
|
||||
Reset();
|
||||
|
|
@ -1015,10 +1054,10 @@ void CreatureEventAI::JustDied(Unit* killer)
|
|||
m_creature->SendZoneUnderAttackMessage(pKiller);
|
||||
}
|
||||
|
||||
if (m_bEmptyList)
|
||||
return;
|
||||
if (m_throwAIEventMask & (1 << AI_EVENT_JUST_DIED))
|
||||
SendAIEventAround(AI_EVENT_JUST_DIED, killer, 0, AIEVENT_DEFAULT_THROW_RADIUS);
|
||||
|
||||
// Handle Evade events
|
||||
// Handle On Death events
|
||||
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
|
||||
{
|
||||
if ((*i).Event.event_type == EVENT_T_DEATH)
|
||||
|
|
@ -1031,7 +1070,7 @@ void CreatureEventAI::JustDied(Unit* killer)
|
|||
|
||||
void CreatureEventAI::KilledUnit(Unit* victim)
|
||||
{
|
||||
if (m_bEmptyList || victim->GetTypeId() != TYPEID_PLAYER)
|
||||
if (victim->GetTypeId() != TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
|
||||
|
|
@ -1043,9 +1082,6 @@ void CreatureEventAI::KilledUnit(Unit* victim)
|
|||
|
||||
void CreatureEventAI::JustSummoned(Creature* pUnit)
|
||||
{
|
||||
if (m_bEmptyList || !pUnit)
|
||||
return;
|
||||
|
||||
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
|
||||
{
|
||||
if ((*i).Event.event_type == EVENT_T_SUMMONED_UNIT)
|
||||
|
|
@ -1055,9 +1091,6 @@ void CreatureEventAI::JustSummoned(Creature* pUnit)
|
|||
|
||||
void CreatureEventAI::SummonedCreatureJustDied(Creature* pUnit)
|
||||
{
|
||||
if (m_bEmptyList || !pUnit)
|
||||
return;
|
||||
|
||||
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
|
||||
{
|
||||
if ((*i).Event.event_type == EVENT_T_SUMMONED_JUST_DIED)
|
||||
|
|
@ -1067,9 +1100,6 @@ void CreatureEventAI::SummonedCreatureJustDied(Creature* pUnit)
|
|||
|
||||
void CreatureEventAI::SummonedCreatureDespawn(Creature* pUnit)
|
||||
{
|
||||
if (m_bEmptyList || !pUnit)
|
||||
return;
|
||||
|
||||
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
|
||||
{
|
||||
if ((*i).Event.event_type == EVENT_T_SUMMONED_JUST_DESPAWN)
|
||||
|
|
@ -1079,8 +1109,7 @@ void CreatureEventAI::SummonedCreatureDespawn(Creature* pUnit)
|
|||
|
||||
void CreatureEventAI::ReceiveAIEvent(AIEventType eventType, Creature* pSender, Unit* pInvoker, uint32 miscValue)
|
||||
{
|
||||
if (m_bEmptyList || !pSender)
|
||||
return;
|
||||
MANGOS_ASSERT(pSender);
|
||||
|
||||
for (CreatureEventAIList::iterator itr = m_CreatureEventAIList.begin(); itr != m_CreatureEventAIList.end(); ++itr)
|
||||
{
|
||||
|
|
@ -1093,28 +1122,25 @@ void CreatureEventAI::ReceiveAIEvent(AIEventType eventType, Creature* pSender, U
|
|||
void CreatureEventAI::EnterCombat(Unit* enemy)
|
||||
{
|
||||
// Check for on combat start events
|
||||
if (!m_bEmptyList)
|
||||
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
|
||||
{
|
||||
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
|
||||
CreatureEventAI_Event const& event = (*i).Event;
|
||||
switch (event.event_type)
|
||||
{
|
||||
CreatureEventAI_Event const& event = (*i).Event;
|
||||
switch (event.event_type)
|
||||
{
|
||||
case EVENT_T_AGGRO:
|
||||
(*i).Enabled = true;
|
||||
ProcessEvent(*i, enemy);
|
||||
break;
|
||||
// Reset all in combat timers
|
||||
case EVENT_T_TIMER_IN_COMBAT:
|
||||
if ((*i).UpdateRepeatTimer(m_creature, event.timer.initialMin, event.timer.initialMax))
|
||||
(*i).Enabled = true;
|
||||
break;
|
||||
// All normal events need to be re-enabled and their time set to 0
|
||||
default:
|
||||
(*i).Enabled = true;
|
||||
(*i).Time = 0;
|
||||
break;
|
||||
}
|
||||
case EVENT_T_AGGRO:
|
||||
(*i).Enabled = true;
|
||||
ProcessEvent(*i, enemy);
|
||||
break;
|
||||
// Reset all in combat timers
|
||||
case EVENT_T_TIMER_IN_COMBAT:
|
||||
if ((*i).UpdateRepeatTimer(m_creature, event.timer.initialMin, event.timer.initialMax))
|
||||
(*i).Enabled = true;
|
||||
break;
|
||||
// All normal events need to be re-enabled and their time set to 0
|
||||
default:
|
||||
(*i).Enabled = true;
|
||||
(*i).Time = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1143,7 +1169,7 @@ void CreatureEventAI::MoveInLineOfSight(Unit* who)
|
|||
return;
|
||||
|
||||
// Check for OOC LOS Event
|
||||
if (!m_bEmptyList && !m_creature->getVictim())
|
||||
if (!m_creature->getVictim())
|
||||
{
|
||||
for (CreatureEventAIList::iterator itr = m_CreatureEventAIList.begin(); itr != m_CreatureEventAIList.end(); ++itr)
|
||||
{
|
||||
|
|
@ -1192,10 +1218,6 @@ void CreatureEventAI::MoveInLineOfSight(Unit* who)
|
|||
|
||||
void CreatureEventAI::SpellHit(Unit* pUnit, const SpellEntry* pSpell)
|
||||
{
|
||||
|
||||
if (m_bEmptyList)
|
||||
return;
|
||||
|
||||
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
|
||||
if ((*i).Event.event_type == EVENT_T_SPELLHIT)
|
||||
// If spell id matches (or no spell id) & if spell school matches (or no spell school)
|
||||
|
|
@ -1209,74 +1231,71 @@ void CreatureEventAI::UpdateAI(const uint32 diff)
|
|||
// Check if we are in combat (also updates calls threat update code)
|
||||
bool Combat = m_creature->SelectHostileTarget() && m_creature->getVictim();
|
||||
|
||||
if (!m_bEmptyList)
|
||||
// Events are only updated once every EVENT_UPDATE_TIME ms to prevent lag with large amount of events
|
||||
if (m_EventUpdateTime < diff)
|
||||
{
|
||||
// Events are only updated once every EVENT_UPDATE_TIME ms to prevent lag with large amount of events
|
||||
if (m_EventUpdateTime < diff)
|
||||
m_EventDiff += diff;
|
||||
|
||||
// Check for time based events
|
||||
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
|
||||
{
|
||||
m_EventDiff += diff;
|
||||
|
||||
// Check for time based events
|
||||
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
|
||||
// Decrement Timers
|
||||
if ((*i).Time)
|
||||
{
|
||||
// Decrement Timers
|
||||
if ((*i).Time)
|
||||
if ((*i).Time > m_EventDiff)
|
||||
{
|
||||
if ((*i).Time > m_EventDiff)
|
||||
{
|
||||
// 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;
|
||||
|
||||
// Skip processing of events that have time remaining
|
||||
continue;
|
||||
}
|
||||
else (*i).Time = 0;
|
||||
// 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;
|
||||
|
||||
// Skip processing of events that have time remaining
|
||||
continue;
|
||||
}
|
||||
else (*i).Time = 0;
|
||||
}
|
||||
|
||||
// Events that are updated every EVENT_UPDATE_TIME
|
||||
switch ((*i).Event.event_type)
|
||||
{
|
||||
case EVENT_T_TIMER_OOC:
|
||||
case EVENT_T_TIMER_GENERIC:
|
||||
// Events that are updated every EVENT_UPDATE_TIME
|
||||
switch ((*i).Event.event_type)
|
||||
{
|
||||
case EVENT_T_TIMER_OOC:
|
||||
case EVENT_T_TIMER_GENERIC:
|
||||
ProcessEvent(*i);
|
||||
break;
|
||||
case EVENT_T_TIMER_IN_COMBAT:
|
||||
case EVENT_T_MANA:
|
||||
case EVENT_T_HP:
|
||||
case EVENT_T_TARGET_HP:
|
||||
case EVENT_T_TARGET_CASTING:
|
||||
case EVENT_T_FRIENDLY_HP:
|
||||
case EVENT_T_AURA:
|
||||
case EVENT_T_TARGET_AURA:
|
||||
case EVENT_T_MISSING_AURA:
|
||||
case EVENT_T_TARGET_MISSING_AURA:
|
||||
if (Combat)
|
||||
ProcessEvent(*i);
|
||||
break;
|
||||
case EVENT_T_TIMER_IN_COMBAT:
|
||||
case EVENT_T_MANA:
|
||||
case EVENT_T_HP:
|
||||
case EVENT_T_TARGET_HP:
|
||||
case EVENT_T_TARGET_CASTING:
|
||||
case EVENT_T_FRIENDLY_HP:
|
||||
case EVENT_T_AURA:
|
||||
case EVENT_T_TARGET_AURA:
|
||||
case EVENT_T_MISSING_AURA:
|
||||
case EVENT_T_TARGET_MISSING_AURA:
|
||||
if (Combat)
|
||||
ProcessEvent(*i);
|
||||
break;
|
||||
case EVENT_T_RANGE:
|
||||
if (Combat)
|
||||
{
|
||||
if (m_creature->getVictim() && m_creature->IsInMap(m_creature->getVictim()))
|
||||
if (m_creature->IsInRange(m_creature->getVictim(), (float)(*i).Event.range.minDist, (float)(*i).Event.range.maxDist))
|
||||
ProcessEvent(*i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case EVENT_T_RANGE:
|
||||
if (Combat)
|
||||
{
|
||||
if (m_creature->getVictim() && m_creature->IsInMap(m_creature->getVictim()))
|
||||
if (m_creature->IsInRange(m_creature->getVictim(), (float)(*i).Event.range.minDist, (float)(*i).Event.range.maxDist))
|
||||
ProcessEvent(*i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
m_EventDiff = 0;
|
||||
m_EventUpdateTime = EVENT_UPDATE_TIME;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_EventDiff += diff;
|
||||
m_EventUpdateTime -= diff;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_EventDiff += diff;
|
||||
m_EventUpdateTime -= diff;
|
||||
}
|
||||
|
||||
// Melee Auto-Attack (recheck m_creature->getVictim in case of combat state was changed while processing events)
|
||||
if (Combat && m_MeleeEnabled)
|
||||
if (Combat && m_MeleeEnabled && m_creature->getVictim())
|
||||
DoMeleeAttackIfReady();
|
||||
}
|
||||
|
||||
|
|
@ -1308,33 +1327,63 @@ inline int32 CreatureEventAI::GetRandActionParam(uint32 rnd, int32 param1, int32
|
|||
return 0;
|
||||
}
|
||||
|
||||
inline Unit* CreatureEventAI::GetTargetByType(uint32 Target, Unit* pActionInvoker, Creature* pAIEventSender, uint32 forSpellId, uint32 selectFlags)
|
||||
inline Unit* CreatureEventAI::GetTargetByType(uint32 Target, Unit* pActionInvoker, Creature* pAIEventSender, bool& isError, uint32 forSpellId, uint32 selectFlags)
|
||||
{
|
||||
Unit* resTarget;
|
||||
switch (Target)
|
||||
{
|
||||
case TARGET_T_SELF:
|
||||
return m_creature;
|
||||
case TARGET_T_HOSTILE:
|
||||
return m_creature->getVictim();
|
||||
resTarget = m_creature->getVictim();
|
||||
if (!resTarget)
|
||||
isError = true;
|
||||
return resTarget;
|
||||
case TARGET_T_HOSTILE_SECOND_AGGRO:
|
||||
return m_creature->SelectAttackingTarget(ATTACKING_TARGET_TOPAGGRO, 1, forSpellId, selectFlags);
|
||||
case TARGET_T_HOSTILE_LAST_AGGRO:
|
||||
return m_creature->SelectAttackingTarget(ATTACKING_TARGET_BOTTOMAGGRO, 0, forSpellId, selectFlags);
|
||||
case TARGET_T_HOSTILE_RANDOM:
|
||||
return m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, forSpellId, selectFlags);
|
||||
case TARGET_T_HOSTILE_RANDOM_NOT_TOP:
|
||||
return m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1, forSpellId, selectFlags);
|
||||
case TARGET_T_HOSTILE_RANDOM_PLAYER:
|
||||
return m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, forSpellId, SELECT_FLAG_PLAYER | selectFlags);
|
||||
case TARGET_T_HOSTILE_RANDOM_NOT_TOP_PLAYER:
|
||||
return m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1, forSpellId, SELECT_FLAG_PLAYER | selectFlags);
|
||||
case TARGET_T_ACTION_INVOKER:
|
||||
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_TOPAGGRO, 1, forSpellId, selectFlags);
|
||||
if (!resTarget && ((forSpellId == 0 && selectFlags == 0 && m_creature->getThreatManager().getThreatList().size() > 1) || m_creature->getThreatManager().getThreatList().empty()))
|
||||
isError = true;
|
||||
return resTarget;
|
||||
case TARGET_T_HOSTILE_LAST_AGGRO:
|
||||
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_BOTTOMAGGRO, 0, forSpellId, selectFlags);
|
||||
if (!resTarget && m_creature->getThreatManager().getThreatList().empty())
|
||||
isError = true;
|
||||
return resTarget;
|
||||
case TARGET_T_HOSTILE_RANDOM:
|
||||
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, forSpellId, selectFlags);
|
||||
if (!resTarget && m_creature->getThreatManager().getThreatList().empty())
|
||||
isError = true;
|
||||
return resTarget;
|
||||
case TARGET_T_HOSTILE_RANDOM_NOT_TOP:
|
||||
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1, forSpellId, selectFlags);
|
||||
if (!resTarget && ((forSpellId == 0 && selectFlags == 0 && m_creature->getThreatManager().getThreatList().size() > 1) || m_creature->getThreatManager().getThreatList().empty()))
|
||||
isError = true;
|
||||
return resTarget;
|
||||
case TARGET_T_HOSTILE_RANDOM_PLAYER:
|
||||
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, forSpellId, SELECT_FLAG_PLAYER | selectFlags);
|
||||
if (!resTarget)
|
||||
isError = true;
|
||||
return resTarget;
|
||||
case TARGET_T_HOSTILE_RANDOM_NOT_TOP_PLAYER:
|
||||
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1, forSpellId, SELECT_FLAG_PLAYER | selectFlags);
|
||||
if (!resTarget && ((forSpellId == 0 && selectFlags == 0 && m_creature->getThreatManager().getThreatList().size() > 1) || m_creature->getThreatManager().getThreatList().empty()))
|
||||
isError = true;
|
||||
return resTarget;
|
||||
case TARGET_T_ACTION_INVOKER:
|
||||
if (!pActionInvoker)
|
||||
isError = true;
|
||||
return pActionInvoker;
|
||||
case TARGET_T_ACTION_INVOKER_OWNER:
|
||||
return pActionInvoker ? pActionInvoker->GetCharmerOrOwnerOrSelf() : NULL;
|
||||
case TARGET_T_EVENT_SENDER:
|
||||
return pAIEventSender;
|
||||
default:
|
||||
case TARGET_T_ACTION_INVOKER_OWNER:
|
||||
resTarget = pActionInvoker ? pActionInvoker->GetCharmerOrOwnerOrSelf() : NULL;
|
||||
if (!resTarget)
|
||||
isError = true;
|
||||
return resTarget;
|
||||
case TARGET_T_EVENT_SENDER:
|
||||
if (!pAIEventSender)
|
||||
isError = true;
|
||||
return pAIEventSender;
|
||||
default:
|
||||
isError = true;
|
||||
return NULL;
|
||||
};
|
||||
}
|
||||
|
|
@ -1371,85 +1420,8 @@ void CreatureEventAI::DoFindFriendlyMissingBuff(std::list<Creature*>& _list, flo
|
|||
//*********************************
|
||||
//*** Functions used globally ***
|
||||
|
||||
void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target)
|
||||
{
|
||||
if (!pSource)
|
||||
{
|
||||
sLog.outErrorEventAI("DoScriptText entry %i, invalid Source pointer.", textEntry);
|
||||
return;
|
||||
}
|
||||
|
||||
if (textEntry >= 0)
|
||||
{
|
||||
sLog.outErrorEventAI("DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), textEntry);
|
||||
return;
|
||||
}
|
||||
|
||||
CreatureEventAI_TextMap::const_iterator i = sEventAIMgr.GetCreatureEventAITextMap().find(textEntry);
|
||||
|
||||
if (i == sEventAIMgr.GetCreatureEventAITextMap().end())
|
||||
{
|
||||
sLog.outErrorEventAI("DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), textEntry);
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "CreatureEventAI: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u", textEntry, (*i).second.SoundId, (*i).second.Type, (*i).second.Language, (*i).second.Emote);
|
||||
|
||||
if ((*i).second.SoundId)
|
||||
{
|
||||
if (GetSoundEntriesStore()->LookupEntry((*i).second.SoundId))
|
||||
pSource->PlayDirectSound((*i).second.SoundId);
|
||||
else
|
||||
sLog.outErrorEventAI("DoScriptText entry %i tried to process invalid sound id %u.", textEntry, (*i).second.SoundId);
|
||||
}
|
||||
|
||||
if ((*i).second.Emote)
|
||||
{
|
||||
if (pSource->GetTypeId() == TYPEID_UNIT || pSource->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
((Unit*)pSource)->HandleEmote((*i).second.Emote);
|
||||
}
|
||||
else
|
||||
sLog.outErrorEventAI("DoScriptText entry %i tried to process emote for invalid TypeId (%u).", textEntry, pSource->GetTypeId());
|
||||
}
|
||||
|
||||
switch ((*i).second.Type)
|
||||
{
|
||||
case CHAT_TYPE_SAY:
|
||||
pSource->MonsterSay(textEntry, (*i).second.Language, target);
|
||||
break;
|
||||
case CHAT_TYPE_YELL:
|
||||
pSource->MonsterYell(textEntry, (*i).second.Language, target);
|
||||
break;
|
||||
case CHAT_TYPE_TEXT_EMOTE:
|
||||
pSource->MonsterTextEmote(textEntry, target);
|
||||
break;
|
||||
case CHAT_TYPE_BOSS_EMOTE:
|
||||
pSource->MonsterTextEmote(textEntry, target, true);
|
||||
break;
|
||||
case CHAT_TYPE_WHISPER:
|
||||
{
|
||||
if (target && target->GetTypeId() == TYPEID_PLAYER)
|
||||
pSource->MonsterWhisper(textEntry, target);
|
||||
else sLog.outErrorEventAI("DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry);
|
||||
} break;
|
||||
case CHAT_TYPE_BOSS_WHISPER:
|
||||
{
|
||||
if (target && target->GetTypeId() == TYPEID_PLAYER)
|
||||
pSource->MonsterWhisper(textEntry, target, true);
|
||||
else sLog.outErrorEventAI("DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry);
|
||||
} break;
|
||||
case CHAT_TYPE_ZONE_YELL:
|
||||
pSource->MonsterYellToZone(textEntry, (*i).second.Language, target);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote)
|
||||
{
|
||||
if (m_bEmptyList)
|
||||
return;
|
||||
|
||||
for (CreatureEventAIList::iterator itr = m_CreatureEventAIList.begin(); itr != m_CreatureEventAIList.end(); ++itr)
|
||||
{
|
||||
if ((*itr).Event.event_type == EVENT_T_RECEIVE_EMOTE)
|
||||
|
|
@ -1467,7 +1439,9 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote)
|
|||
}
|
||||
}
|
||||
|
||||
void CreatureEventAI::DamageTaken(Unit* /*done_by*/, uint32& damage)
|
||||
#define HEALTH_STEPS 3
|
||||
|
||||
void CreatureEventAI::DamageTaken(Unit* dealer, uint32& damage)
|
||||
{
|
||||
if (m_InvinceabilityHpLevel > 0 && m_creature->GetHealth() < m_InvinceabilityHpLevel + damage)
|
||||
{
|
||||
|
|
@ -1476,6 +1450,46 @@ void CreatureEventAI::DamageTaken(Unit* /*done_by*/, uint32& damage)
|
|||
else
|
||||
damage = m_creature->GetHealth() - m_InvinceabilityHpLevel;
|
||||
}
|
||||
|
||||
uint32 step = m_throwAIEventStep != 100 ? m_throwAIEventStep : 0;
|
||||
if (step < HEALTH_STEPS)
|
||||
{
|
||||
// Throw at 90%, 50% and 10% health
|
||||
float healthSteps[HEALTH_STEPS] = { 90.0f, 50.0f, 10.0f };
|
||||
float newHealthPercent = (m_creature->GetHealth() - damage) * 100.0f / m_creature->GetMaxHealth();
|
||||
AIEventType sendEvent[HEALTH_STEPS] = { AI_EVENT_LOST_SOME_HEALTH, AI_EVENT_LOST_HEALTH, AI_EVENT_CRITICAL_HEALTH };
|
||||
|
||||
if (newHealthPercent > healthSteps[step])
|
||||
return; // Not reached the next mark
|
||||
|
||||
// search for highest reached mark (with actual event attached)
|
||||
for (uint32 i = HEALTH_STEPS - 1; i > step; --i)
|
||||
{
|
||||
if (newHealthPercent < healthSteps[i] && (m_throwAIEventMask & (1 << sendEvent[i])))
|
||||
{
|
||||
step = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_throwAIEventMask & (1 << sendEvent[step]))
|
||||
SendAIEventAround(sendEvent[step], dealer, 0, AIEVENT_DEFAULT_THROW_RADIUS);
|
||||
|
||||
m_throwAIEventStep = step + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void CreatureEventAI::HealedBy(Unit* healer, uint32& healedAmount)
|
||||
{
|
||||
if (m_throwAIEventStep == 100)
|
||||
return;
|
||||
|
||||
if (m_creature->GetHealth() + healedAmount >= m_creature->GetMaxHealth())
|
||||
{
|
||||
if (m_throwAIEventMask & (1 << AI_EVENT_GOT_FULL_HEALTH))
|
||||
SendAIEventAround(AI_EVENT_GOT_FULL_HEALTH, healer, 0, AIEVENT_DEFAULT_THROW_RADIUS);
|
||||
m_throwAIEventStep = 100;
|
||||
}
|
||||
}
|
||||
|
||||
bool CreatureEventAI::SpawnedEventConditionsCheck(CreatureEventAI_Event const& event)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue