/* smart scripts */
UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` IN 
(594, 598 ,619, 622, 623, 624, 625, 634, 639, 641, 642, 644, 645, 647, 657, 1725, 1727, 1729, 1731, 1732, 1763, 3586, 3947, 4416, 4417, 4418);
DELETE FROM `smart_scripts` WHERE `source_type` = 0 AND `entryorguid` IN 
(594, 598 ,619, 622, 623, 624, 625, 634, 639, 641, 642, 644, 645, 647, 657, 1725, 1727, 1729, 1731, 1732, 1763, 3586, 3947, 4416, 4417, 4418);

INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, 
`event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, 
`action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, 
`target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES 
--
(594, 0, 0, 0, 4, 0, 15, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                          'Defias Henchman - On Aggro - Say Line 0'),
(594, 0, 1, 0, 13, 0, 100, 1, 3000, 13000, 0, 0, 0, 0, 11, 8242, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0,             'Defias Henchman - Target Casting - Cast Shield Slam (No Repeat)'),
(594, 0, 2, 0, 0, 0, 100, 1, 3600, 18800, 0, 0, 0, 0, 11, 3248, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,              'Defias Henchman - In Combat - Cast Improved Blocking (No Repeat)'),
(594, 0, 3, 0, 2, 0, 100, 1, 0, 15, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                       'Defias Henchman - Between 0-15% Health - Flee For Assist (No Repeat)'),
(598, 0, 0, 0, 0, 0, 100, 0, 1000, 7000, 34000, 56000, 0, 0, 11, 6016, 32, 0, 0, 0, 0, 21, 5, 0, 0, 0, 0, 0, 0, 0,     'Defias Miner - Within 0-5 Range - Cast Pierce Armor'),
(598, 0, 1, 0, 2, 0, 100, 1, 0, 15, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                       'Defias Miner - Between 0-15% Health - Flee For Assist'),
(619, 0, 0, 0, 1, 0, 100, 0, 1000, 1000, 1800000, 1800000, 0, 0, 11, 12544, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,  'Defias Conjurer - Out of Combat - Cast Frost Armor'),
(619, 0, 1, 0, 0, 0, 100, 0, 0, 0, 2000, 2000, 0, 0, 11, 9053, 64, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,              'Defias Conjurer - In Combat - Cast Fireball'),
(619, 0, 2, 0, 2, 0, 100, 1, 0, 15, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                       'Defias Conjurer - Between 0-15% Health - Flee For Assist'),
(622, 0, 0, 0, 9, 0, 100, 0, 0, 0, 4000, 4000, 30, 60, 21, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                'Goblin Engineer - Outside 30 Range - Start Combat Movement'),
(622, 0, 1, 0, 9, 0, 100, 0, 0, 0, 4000, 4000, 5, 30, 21, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                 'Goblin Engineer - Within 5-30 Range - Stop Combat Movement'),
(622, 0, 2, 0, 9, 0, 100, 0, 0, 0, 4000, 4000, 0, 5, 21, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                  'Goblin Engineer - Within 0-5 Range - Start Combat Movement'),
(622, 0, 3, 0, 9, 0, 100, 0, 0, 0, 2000, 4000, 5, 30, 11, 6660, 64, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,             'Goblin Engineer - Within Range 5-30yd - Cast Shoot'),
(622, 0, 4, 0, 0, 0, 100, 0, 0, 1000, 70000, 90000, 0, 0, 11, 3605, 64, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,         'Goblin Engineer - Out of Combat - Cast Summon Remote-Controlled Golem'),
(622, 0, 5, 0, 2, 0, 100, 1, 0, 15, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                       'Goblin Engineer - Between 0-15% Health - Flee For Assist'),
(623, 0, 0, 0, 0, 0, 100, 0, 5000, 16000, 12000, 19000, 0, 0, 11, 11976, 0, 0, 0, 0, 0, 21, 5, 0, 0, 0, 0, 0, 0, 0,    'Skeletal Miner - Within 0-5 Range - Cast Strike'),
(624, 0, 0, 0, 9, 0, 100, 0, 0, 8000, 2000, 17000, 0, 5, 11, 5137, 32, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,          'Undead Excavator - Within 0-5 Range - Cast Call of the Grave'),
(625, 0, 0, 0, 0, 0, 100, 0, 1000, 4000, 14000, 32000, 0, 0, 11, 7395, 64, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,      'Undead Dynamiter - In Combat - Cast Deadmines Dynamite'),
(634, 0, 0, 0, 0, 0, 100, 0, 4000, 17000, 24000, 43000, 0, 0, 11, 5115, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,      'Defias Overseer - In Combat - Cast Battle Command'),
(634, 0, 1, 0, 2, 0, 100, 1, 0, 15, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                       'Defias Overseer - Between 0-15% Health - Flee For Assist'),
--
(639, 0, 0, 0, 1, 0, 100, 257, 1000, 1000, 0, 0, 0, 0, 11, 674, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,              'Edwin VanCleef - Out of Combat - Cast Dual Wield (No Repeat)'),
(639, 0, 1, 0, 4, 0, 100, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                         'Edwin VanCleef - On Aggro - Say Line 0'),
(639, 0, 3, 0, 2, 0, 100, 1, 50, 75, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                       'Edwin VanCleef - Between 50-75% Health - Say Line 1 (No Repeat)'),
(639, 0, 4, 5, 2, 0, 100, 1, 45, 50, 0, 0, 0, 0, 11, 5200, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                   'Edwin VanCleef - At 50% Health - Cast VanCleefs Allies (No Repeat)'), -- https://www.hcguides.com/dungeons/the-deadmines
(639, 0, 5, 0, 61, 0, 100, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                        'Edwin VanCleef - On Summon Allies - Say Line 2'),
(639, 0, 6, 0, 2, 0, 100, 1, 0, 35, 0, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                        'Edwin VanCleef - Between 0-35% Health - Say Line 3 (No Repeat)'),
(639, 0, 7, 0, 2, 0, 100, 1, 0, 10, 0, 0, 0, 0, 1, 5, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                        'Edwin VanCleef - Between 0-10% Health - Say Line 5 (No Repeat)'),
(639, 0, 8, 0, 5, 0, 100, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                         'Edwin VanCleef - On Killed Unit - Say Line 4'),
(639, 0, 9, 0, 0, 0, 100, 0, 8000, 12000, 15000, 20000, 0, 0, 11, 3391, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,      'Edwin VanCleef - In Combat - Cast Thrash'),
--
(641, 0, 0, 0, 0, 0, 80, 1, 1000, 4000, 0, 0, 0, 0, 11, 6466, 64, 0, 0, 0, 0, 21, 20, 0, 0, 0, 0, 0, 0, 0,             'Goblin Woodcarver - Within 0-20 Range - Cast Axe Toss (No Repeat)'),
(641, 0, 1, 0, 0, 0, 100, 0, 1000, 9000, 15000, 34000, 0, 0, 11, 40505, 0, 0, 0, 0, 0, 21, 5, 0, 0, 0, 0, 0, 0, 0,     'Goblin Woodcarver - Within 0-5 Range - Cast Cleave'),
(642, 0, 0, 0, 0, 0, 100, 0, 9000, 14000, 15000, 21000, 0, 0, 11, 7399, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0,      'Sneeds Shredder - In Combat - Cast Terrify'),
(642, 0, 1, 0, 0, 0, 100, 0, 8000, 12000, 48000, 54000, 0, 0, 11, 3603, 0, 0, 0, 0, 0, 21, 5, 0, 0, 0, 0, 0, 0, 0,     'Sneeds Shredder - Within 0-5 Range - Cast Distracting Pain'),
(642, 0, 2, 0, 6, 0, 100, 0, 0, 0, 0, 0, 0, 0, 11, 5141, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                     'Sneeds Shredder - On Just Died - Cast Eject Sneed'),
(644, 0, 0, 0, 4, 0, 100, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                         'Rhahk\'Zor - On Aggro - Say Line 0'),
(644, 0, 1, 0, 0, 0, 100, 0, 1000, 8000, 17000, 27000, 0, 0, 11, 6304, 0, 0, 0, 0, 0, 21, 5, 0, 0, 0, 0, 0, 0, 0,      'Rhahk\'Zor - Within 0-5 Range - Cast Rhahk Zor Slam'),
(644, 0, 2, 3, 6, 0, 100, 514, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 14, 30533, 13965, 0, 0, 0, 0, 0, 0,              'Rhahk\'Zor - On Just Died - Activate Gameobject (Normal Dungeon)'),
(644, 0, 3, 0, 61, 0, 100, 514, 0, 0, 0, 0, 0, 0, 34, 0, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                     'Rhahk\'Zor - On Just Died - Set Instance Data 0 to 3 (Normal Dungeon)'),
(645, 0, 0, 0, 0, 0, 100, 0, 5000, 5000, 27000, 36000, 0, 0, 11, 6306, 64, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,      'Cookie - In Combat - Cast Acid Splash'),
(645, 0, 1, 0, 2, 0, 100, 0, 0, 50, 10000, 15000, 0, 0, 11, 5174, 64, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,           'Cookie - In Combat - Cast Cookies Cooking'),
(645, 0, 2, 0, 2, 0, 100, 1, 0, 15, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                       'Cookie - Between 0-15% Health - Flee For Assist'),
(647, 0, 0, 0, 0, 0, 100, 0, 5000, 18000, 17000, 42000, 0, 0, 11, 40505, 0, 0, 0, 0, 0, 21, 5, 0, 0, 0, 0, 0, 0, 0,    'Captain Greenskin - Within 0-5 Range - Cast Cleave'),
(647, 0, 1, 0, 0, 0, 100, 0, 6000, 13000, 37000, 97000, 0, 0, 11, 5208, 96, 0, 0, 0, 0, 5, 10, 0, 0, 0, 0, 0, 0, 0,    'Captain Greenskin - Within 0-10 Range - Cast Poisoned Harpoon'),
(657, 0, 0, 0, 1, 0, 50, 1, 0, 0, 0, 0, 0, 0, 11, 5172, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                      'Defias Pirate - Out of Combat - Cast Bloodsail Companion (No Repeat)'),
(1725, 0, 0, 0, 9, 0, 100, 0, 0, 0, 4000, 4000, 30, 60, 21, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,               'Defias Watchman - Outside 30 Range - Start Combat Movement'),
(1725, 0, 1, 0, 9, 0, 100, 0, 0, 0, 4000, 4000, 5, 30, 21, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                'Defias Watchman - Within 5-30 Range - Stop Combat Movement'),
(1725, 0, 2, 0, 9, 0, 100, 0, 0, 0, 4000, 4000, 0, 5, 21, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                 'Defias Watchman - Within 0-5 Range - Start Combat Movement'),
(1725, 0, 3, 0, 9, 0, 100, 0, 0, 0, 2000, 4000, 5, 30, 11, 6660, 64, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,            'Defias Watchman - Within Range 5-30yd - Cast Shoot'),
(1725, 0, 4, 0, 2, 0, 100, 1, 0, 15, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                      'Defias Watchman - Between 0-15% Health - Flee For Assist'),
(1727, 0, 0, 0, 2, 0, 100, 1, 0, 15, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                      'Defias Worker - Between 0-15% Health - Flee For Assist (No Repeat)'),
(1729, 0, 0, 0, 1, 0, 100, 0, 1000, 1000, 1800000, 1800000, 0, 0, 11, 12544, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Defias Evoker - Out of Combat - Cast Frost Armor'),
(1729, 0, 1, 0, 0, 0, 100, 0, 0, 1000, 3000, 17000, 0, 0, 11, 11829, 64, 0, 0, 0, 0, 5, 30, 0, 0, 0, 0, 0, 0, 0,       'Defias Evoker - In Combat - Cast Flamestrike'),
(1729, 0, 2, 0, 0, 0, 100, 0, 1000, 1000, 42000, 63000, 0, 0, 11, 4979, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,      'Defias Evoker - In Combat - Cast Quick Flame Ward'),
(1729, 0, 3, 0, 2, 0, 100, 1, 0, 15, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                      'Defias Evoker - Between 0-15% Health - Flee For Assist (No Repeat)'),
(1731, 0, 0, 0, 0, 0, 100, 0, 5000, 9000, 25000, 52000, 0, 0, 11, 5159, 0, 0, 0, 0, 0, 21, 5, 0, 0, 0, 0, 0, 0, 0,     'Goblin Craftsman - Within 0-5 Range - Cast Melt Ore'),
(1731, 0, 1, 0, 2, 0, 100, 1, 0, 15, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                      'Goblin Craftsman - Between 0-15% Health - Flee For Assist (No Repeat)'),
(1732, 0, 0, 0, 1, 0, 100, 0, 1000, 1000, 1800000, 1800000, 0, 0, 11, 12544, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Defias Squallshaper - Out of Combat - Cast Frost Armor'),
(1732, 0, 1, 0, 9, 0, 100, 0, 0, 3000, 8000, 33000, 0, 20, 11, 2138, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,         'Defias Squallshaper - Within 0-20 Range - Cast Fire Blast'),
(1732, 0, 2, 0, 106, 0, 100, 0, 0, 0, 23500, 33500, 0, 8, 11, 4979, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,          'Defias Squallshaper - Within 0-8 Range - Cast Frost Nova'),
(1732, 0, 3, 0, 2, 0, 100, 1, 0, 15, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                      'Defias Squallshaper - Between 0-15% Health - Flee For Assist (No Repeat)'),
(1732, 0, 4, 0, 54, 0, 100, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, -102.2, -660.64, 7.43, 0,        'Defias Squallshaper - Is Summoned - Move Point'),
(1763, 0, 0, 0, 0, 0, 100, 0, 2000, 3000, 23000, 44000, 0, 0, 11, 5213, 0, 0, 0, 0, 0, 21, 5, 0, 0, 0, 0, 0, 0, 0,     'Gilnid - Within 0-5 Range - Cast Molten Metal'),
(1763, 0, 1, 0, 1, 0, 100, 0, 120000, 120000, 120000, 120000, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,    'Gilnid - Out of Combat - Say Line 0'),
(3586, 0, 0, 0, 37, 0, 60, 2, 0, 0, 0, 0, 0, 0, 41, 500, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                     'Miner Johnson - On AI Init - Despawn (Normal Dungeon)'),
(3586, 0, 1, 0, 0, 0, 100, 0, 1000, 7000, 34000, 56000, 0, 0, 11, 12097, 32, 0, 0, 0, 0, 21, 5, 0, 0, 0, 0, 0, 0, 0,   'Miner Johnson - Within 0-5 Range - Cast Pierce Armor'),
(3947, 0, 0, 0, 2, 0, 100, 1, 0, 15, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                      'Goblin Shipbuilder - Between 0-15% Health - Flee For Assist (No Repeat)'),
(4416, 0, 0, 0, 0, 0, 100, 0, 2000, 12000, 45000, 54000, 0, 0, 11, 6016, 0, 0, 0, 0, 0, 21, 5, 0, 0, 0, 0, 0, 0, 0,    'Defias Strip Miner - Within 0-5 Range - Cast Pierce Armor'),
(4417, 0, 0, 0, 9, 0, 100, 0, 0, 0, 4000, 4000, 30, 60, 21, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,               'Defias Taskmaster - Outside 30 Range - Start Combat Movement'),
(4417, 0, 1, 0, 9, 0, 100, 0, 0, 0, 4000, 4000, 5, 30, 21, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                'Defias Taskmaster - Within 5-30 Range - Stop Combat Movement'),
(4417, 0, 2, 0, 9, 0, 100, 0, 0, 0, 4000, 4000, 0, 5, 21, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,                 'Defias Taskmaster - Within 0-5 Range - Start Combat Movement'),
(4417, 0, 3, 0, 9, 0, 100, 0, 0, 0, 2000, 4000, 5, 30, 11, 6660, 64, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,            'Defias Taskmaster - Within Range 5-30yd - Cast Shoot'),
(4417, 0, 4, 0, 0, 0, 100, 0, 0, 0, 30000, 40000, 0, 0, 11, 6685, 0, 0, 0, 0, 0, 28, 30, 1, 1, 5, 0, 0, 0, 0,          'Defias Taskmaster - In Combat - Cast Piercing Shot'),
(4418, 0, 0, 0, 0, 0, 100, 0, 0, 0, 2000, 2000, 0, 0, 11, 9053, 64, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,             'Defias Wizard - In Combat - Cast Fireball'),
(4418, 0, 1, 0, 0, 0, 100, 0, 3000, 8000, 10000, 15000, 0, 0, 11, 113, 96, 0, 0, 0, 0, 5, 30, 0, 0, 0, 0, 0, 0, 0,     'Defias Wizard - In Combat - Cast Chains of Ice'),
(4418, 0, 2, 0, 0, 0, 100, 0, 1000, 1000, 40000, 65000, 0, 0, 11, 4979, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,      'Defias Wizard - In Combat - Cast Quick Flame Ward'),
(4418, 0, 3, 0, 2, 0, 100, 1, 0, 15, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                      'Defias Wizard - Between 0-15% Health - Flee For Assist (No Repeat)');
