mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/SmartScripts: fixup SMART_EVENT_FLAG_WHILE_CHARMED behaviour to only mean charmed creatures (#17738 follow-up)
Unit::IsControlledByPlayer is a expected value for TempSummons (like some triggers used in quests, summoned by spells). Previous logic broke a lot of quests which use triggers to do stuff. Allow JustSummoned and events linked from other events with flag set also in charmed (prevents breaking event chains) Allow vehicles (needed for vehicles with SmartAI, eg Iron Rune Constructs and You: Rocket Jumping)
This commit is contained in:
23
sql/updates/world/3.3.5/2016_10_14_00_world.sql
Normal file
23
sql/updates/world/3.3.5/2016_10_14_00_world.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
-- Always for SMART_EVENT_JUST_SUMMONED (Creature can be summoned already charmed by player ie TempSummons)
|
||||
UPDATE `smart_scripts` SET `event_flags`=`event_flags`|0x200 WHERE `source_type` = 0 AND `event_type`=54;
|
||||
|
||||
-- Event linked actions (Many levels of linked calls, do 8 times)
|
||||
UPDATE `smart_scripts` `ss` LEFT JOIN `smart_scripts` `ssl` ON `ss`.`entryorguid` = `ssl`.`entryorguid` AND `ss`.`source_type` = `ssl`.`source_type` AND `ss`.`id` = `ssl`.`link` SET `ss`.`event_flags`=`ss`.`event_flags`|0x200 WHERE `ss`.`source_type`=0 AND
|
||||
`ss`.`event_type` = 61 AND (`ssl`.`event_flags` & 0x200) != 0;
|
||||
UPDATE `smart_scripts` `ss` LEFT JOIN `smart_scripts` `ssl` ON `ss`.`entryorguid` = `ssl`.`entryorguid` AND `ss`.`source_type` = `ssl`.`source_type` AND `ss`.`id` = `ssl`.`link` SET `ss`.`event_flags`=`ss`.`event_flags`|0x200 WHERE `ss`.`source_type`=0 AND
|
||||
`ss`.`event_type` = 61 AND (`ssl`.`event_flags` & 0x200) != 0;
|
||||
UPDATE `smart_scripts` `ss` LEFT JOIN `smart_scripts` `ssl` ON `ss`.`entryorguid` = `ssl`.`entryorguid` AND `ss`.`source_type` = `ssl`.`source_type` AND `ss`.`id` = `ssl`.`link` SET `ss`.`event_flags`=`ss`.`event_flags`|0x200 WHERE `ss`.`source_type`=0 AND
|
||||
`ss`.`event_type` = 61 AND (`ssl`.`event_flags` & 0x200) != 0;
|
||||
UPDATE `smart_scripts` `ss` LEFT JOIN `smart_scripts` `ssl` ON `ss`.`entryorguid` = `ssl`.`entryorguid` AND `ss`.`source_type` = `ssl`.`source_type` AND `ss`.`id` = `ssl`.`link` SET `ss`.`event_flags`=`ss`.`event_flags`|0x200 WHERE `ss`.`source_type`=0 AND
|
||||
`ss`.`event_type` = 61 AND (`ssl`.`event_flags` & 0x200) != 0;
|
||||
UPDATE `smart_scripts` `ss` LEFT JOIN `smart_scripts` `ssl` ON `ss`.`entryorguid` = `ssl`.`entryorguid` AND `ss`.`source_type` = `ssl`.`source_type` AND `ss`.`id` = `ssl`.`link` SET `ss`.`event_flags`=`ss`.`event_flags`|0x200 WHERE `ss`.`source_type`=0 AND
|
||||
`ss`.`event_type` = 61 AND (`ssl`.`event_flags` & 0x200) != 0;
|
||||
UPDATE `smart_scripts` `ss` LEFT JOIN `smart_scripts` `ssl` ON `ss`.`entryorguid` = `ssl`.`entryorguid` AND `ss`.`source_type` = `ssl`.`source_type` AND `ss`.`id` = `ssl`.`link` SET `ss`.`event_flags`=`ss`.`event_flags`|0x200 WHERE `ss`.`source_type`=0 AND
|
||||
`ss`.`event_type` = 61 AND (`ssl`.`event_flags` & 0x200) != 0;
|
||||
UPDATE `smart_scripts` `ss` LEFT JOIN `smart_scripts` `ssl` ON `ss`.`entryorguid` = `ssl`.`entryorguid` AND `ss`.`source_type` = `ssl`.`source_type` AND `ss`.`id` = `ssl`.`link` SET `ss`.`event_flags`=`ss`.`event_flags`|0x200 WHERE `ss`.`source_type`=0 AND
|
||||
`ss`.`event_type` = 61 AND (`ssl`.`event_flags` & 0x200) != 0;
|
||||
UPDATE `smart_scripts` `ss` LEFT JOIN `smart_scripts` `ssl` ON `ss`.`entryorguid` = `ssl`.`entryorguid` AND `ss`.`source_type` = `ssl`.`source_type` AND `ss`.`id` = `ssl`.`link` SET `ss`.`event_flags`=`ss`.`event_flags`|0x200 WHERE `ss`.`source_type`=0 AND
|
||||
`ss`.`event_type` = 61 AND (`ssl`.`event_flags` & 0x200) != 0;
|
||||
|
||||
-- Vehicles
|
||||
UPDATE `smart_scripts` SET `event_flags`=`event_flags`|0x200 WHERE `source_type` = 0 AND `entryorguid` IN (SELECT `entry` FROM `creature_template` WHERE `AIName` = "SmartAI" AND `VehicleId` != 0);
|
||||
@@ -73,11 +73,7 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c)
|
||||
|
||||
bool SmartAI::IsAIControlled() const
|
||||
{
|
||||
if (me->IsControlledByPlayer())
|
||||
return false;
|
||||
if (mIsCharmed)
|
||||
return false;
|
||||
return true;
|
||||
return !mIsCharmed;
|
||||
}
|
||||
|
||||
void SmartAI::UpdateDespawn(const uint32 diff)
|
||||
|
||||
@@ -1174,7 +1174,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (!IsCreature(*itr))
|
||||
continue;
|
||||
|
||||
if (!(e.event.event_flags & SMART_EVENT_FLAG_WHILE_CHARMED) && !IsCreatureInControlOfSelf(*itr))
|
||||
if (!(e.event.event_flags & SMART_EVENT_FLAG_WHILE_CHARMED) && IsCharmedCreature(*itr))
|
||||
continue;
|
||||
|
||||
Position pos = (*itr)->GetPosition();
|
||||
@@ -2852,7 +2852,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
if ((e.event.event_phase_mask && !IsInPhase(e.event.event_phase_mask)) || ((e.event.event_flags & SMART_EVENT_FLAG_NOT_REPEATABLE) && e.runOnce))
|
||||
return;
|
||||
|
||||
if (!(e.event.event_flags & SMART_EVENT_FLAG_WHILE_CHARMED) && IsCreature(me) && !IsCreatureInControlOfSelf(me))
|
||||
if (!(e.event.event_flags & SMART_EVENT_FLAG_WHILE_CHARMED) && IsCharmedCreature(me))
|
||||
return;
|
||||
|
||||
switch (e.GetEventType())
|
||||
|
||||
@@ -78,12 +78,15 @@ class TC_GAME_API SmartScript
|
||||
return obj && obj->GetTypeId() == TYPEID_UNIT;
|
||||
}
|
||||
|
||||
static bool IsCreatureInControlOfSelf(WorldObject* obj)
|
||||
static bool IsCharmedCreature(WorldObject* obj)
|
||||
{
|
||||
if (Creature* creatureObj = obj ? obj->ToCreature() : nullptr)
|
||||
return !creatureObj->IsCharmed() && !creatureObj->IsControlledByPlayer();
|
||||
else
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
if (Creature* creatureObj = obj->ToCreature())
|
||||
return creatureObj->IsCharmed();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IsGameObject(WorldObject* obj)
|
||||
|
||||
Reference in New Issue
Block a user