diff --git a/pages/spell.php b/pages/spell.php index 323cf94c..0a5e6081 100644 --- a/pages/spell.php +++ b/pages/spell.php @@ -616,6 +616,8 @@ class SpellPage extends GenericPage ['onUseSpell', $this->subject->id], ['onSuccessSpell', $this->subject->id], ['auraSpell', $this->subject->id], ['triggeredSpell', $this->subject->id] ); + if ($_ = $this->ubSmartScript(TYPE_OBJECT)) + $conditions[] = ['id', $_]; $ubObjects = new GameObjectList($conditions); if (!$ubObjects->error) @@ -827,13 +829,12 @@ class SpellPage extends GenericPage } // tab: used by - creature - // SMART_SCRIPT_TYPE_CREATURE = 0; SMART_ACTION_CAST = 11; SMART_ACTION_ADD_AURA = 75; SMART_ACTION_INVOKER_CAST = 85; SMART_ACTION_CROSS_CAST = 86 $conditions = array( 'OR', ['spell1', $this->typeId], ['spell2', $this->typeId], ['spell3', $this->typeId], ['spell4', $this->typeId], ['spell5', $this->typeId], ['spell6', $this->typeId], ['spell7', $this->typeId], ['spell8', $this->typeId] ); - if ($_ = DB::World()->selectCol('SELECT entryOrGUID FROM smart_scripts WHERE entryorguid > 0 AND source_type = 0 AND action_type IN (11, 75, 85, 86) AND action_param1 = ?d', $this->typeId)) + if ($_ = $this->ubSmartScript(TYPE_NPC)) $conditions[] = ['id', $_]; $ubCreature = new CreatureList($conditions); @@ -2159,6 +2160,40 @@ class SpellPage extends GenericPage return $effects; } + + private function ubSmartScript(int $type) : array + { + $src = -1; + if ($type == TYPE_OBJECT) + $src = 1; + else if ($type == TYPE_NPC) + $src = 0; + else + return []; + + /* + SMART_SCRIPT_TYPE_CREATURE = 0 => SMART_ACTION_CAST = 11; SMART_ACTION_ADD_AURA = 75; SMART_ACTION_INVOKER_CAST = 85; SMART_ACTION_CROSS_CAST = 86 + SMART_SCRIPT_TYPE_TIMED_ACTIONLIST = 9 => SMART_ACTION_CALL_TIMED_ACTIONLIST = 80; SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST = 87; SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST = 88 + */ + + $ids = []; + if ($smartS = DB::World()->selectCol('SELECT entryOrGUID AS ARRAY_KEY, source_type FROM smart_scripts WHERE entryorguid > 0 AND source_type IN (?d, 9) AND action_type IN (11, 75, 85, 86) AND action_param1 = ?d', $type, $this->typeId)) + { + // filter for timed action list + if ($tal = array_filter($smartS, function($x) {return $x == 9;})) + { + if ($talIds = DB::World()->selectCol('SELECT entryOrGUID FROM smart_scripts WHERE entryorguid > 0 AND source_type = ?d AND action_type IN (80, 87, 88) AND (action_param1 IN (?a) OR action_param2 IN (?a) OR action_param3 IN (?a) OR action_param4 IN (?a) OR action_param5 IN (?a) OR action_param6 IN (?a))', $type, array_keys($tal), array_keys($tal), array_keys($tal), array_keys($tal), array_keys($tal), array_keys($tal))) + $conditions[] = ['id', $talIds]; + + $smartS = array_diff($smartS, $tal); + } + + if ($smartS); + $ids = $smartS; + } + + return $ids; + } }