kusanagy

NPC Enchanter Lua

Nov 1st, 2016
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.54 KB | None | 0 0
  1. --credits Foereaper
  2.  
  3.  
  4. local npcid = 1
  5.  
  6. local T = {
  7.         ["Menu"] = {
  8.                 {"Headpiece", 0},
  9.                 {"Shoulders", 2},
  10.                 {"Chest", 4},
  11.                 {"Legs", 6},
  12.                 {"Boots", 7},
  13.                 {"Bracers", 8},
  14.                 {"Gloves", 9},
  15.                 {"Cloak", 14},
  16.                 {"Main-Hand Weapons", 15},
  17.                 {"Two-Handed Weapons", 151},
  18.                 {"Off-Hand Weapons", 16},
  19.                 {"Shields", 161};
  20.         },
  21.        
  22.         [0] = { -- Headpiece
  23.                 {"Arcanum of Burning Mysteries", 3820, false},
  24.                 {"Arcanum of Blissful Mending", 3819, false},
  25.                 {"Arcanum of the Stalward Protector", 3818, false},
  26.                 {"Arcanum of Torment", 3817, false},
  27.                 {"Arcanum of the Savage Gladiator", 3842, false},
  28.                 {"Arcanum of Triumph", 3795, false},
  29.                 {"Arcanum of Dominance", 3797, false};
  30.         },
  31.  
  32.         [2] = { -- Shoulders
  33.                 {"Inscription of Triumph", 3793, false},
  34.                 {"Inscription of Dominance", 3794, false},
  35.                 {"Greater Inscription of the Gladiator", 3852, false},
  36.                 {"Greater Inscription of the Axe", 3808, false},
  37.                 {"Greater Inscription of the Crag", 3809, false},
  38.                 {"Greater Inscription of the Pinnacle", 3811, false},
  39.                 {"Greater Inscription of the Storm", 3810, false};
  40.         },
  41.  
  42.         [4] = { -- Chest
  43.                 {"Enchant Chest - Powerful Stats", 3832, false},
  44.                 {"Enchant Chest - Super Health", 3297, false},
  45.                 {"Enchant Chest - Greater Mana Restoration", 2381, false},
  46.                 {"Enchant Chest - Exceptional Resilience", 3245, false},
  47.                 {"Enchant Chest - Greater Defense", 1953, false};
  48.         },
  49.  
  50.         [6] = { -- Legs
  51.                 {"Earthen Leg Armor", 3853, false},
  52.                 {"Frosthide Leg Armor", 3822, false},
  53.                 {"Icescale Leg Armor", 3823, false},
  54.                 {"Brilliant Spellthread", 3719, false},
  55.                 {"Sapphire Spellthread", 3721, false};
  56.         },    
  57.  
  58.         [7] = { -- Boots
  59.                 {"Enchant Boots - Greater Assault", 1597, false},
  60.                 {"Enchant Boots - Tuskars Vitality", 3232, false},
  61.                 {"Enchant Boots - Superior Agility", 983, false},
  62.                 {"Enchant Boots - Greater Spirit", 1147, false},
  63.                 {"Enchant Boots - Greater Vitality", 3244, false},
  64.                 {"Enchant Boots - Icewalker", 3826, false},
  65.                 {"Enchant Boots - Greater Fortitude", 1075, false};
  66.         },
  67.  
  68.         [8] = { -- Bracers
  69.                 {"Enchant Bracers - Major Stamina", 3850, false},
  70.                 {"Enchant Bracers - Superior Spellpower", 2332, false},
  71.                 {"Enchant Bracers - Greater Assault", 3845, false},
  72.                 {"Enchant Bracers - Major Spirit", 1147, false},
  73.                 {"Enchant Bracers - Expertise", 3231, false},
  74.                 {"Enchant Bracers - Greater Stats", 2661, false},
  75.                 {"Enchant Bracers - Exceptional Intellect", 1119, false};
  76.         },
  77.  
  78.         [9] = { -- Gloves
  79.                 {"Enchant Gloves - Greater Blasting", 3249, false},
  80.                 {"Enchant Gloves - Armsman", 3253, false},
  81.                 {"Enchant Gloves - Crusher", 1603, false},
  82.                 {"Enchant Gloves - Agility", 3222, false},
  83.                 {"Enchant Gloves - Precision", 3234, false},
  84.                 {"Enchant Gloves - Expertise", 3231, false},
  85.                 {"Enchant Gloves - Exceptional Spellpower", 3246, false};
  86.         },
  87.  
  88.         [14] = { -- Cloak
  89.                 {"Enchant Cloak - Shadow Armor", 3256, false},
  90.                 {"Enchant Cloak - Wisdom", 3296, false},
  91.                 {"Enchant Cloak - Titan Weave", 1951, false},
  92.                 {"Enchant Cloak - Greater Speed", 3831, false},
  93.                 {"Enchant Cloak - Mighty Armor", 3294, false},
  94.                 {"Enchant Cloak - Major Agility", 1099, false},
  95.                 {"Enchant Cloak - Spell Piercing", 1262, false};
  96.         },
  97.  
  98.         [15] = {
  99.                 -- Main Hand
  100.                 {"Enchant Weapon - Titan Guard", 3851, false},
  101.                 {"Enchant Weapon - Accuracy", 3788, false},
  102.                 {"Enchant Weapon - Berserking", 3789, false},
  103.                 {"Enchant Weapon - Black Magic", 3790, false},
  104.                 {"Enchant Weapon - Mighty Spellpower", 3834, false},
  105.                 {"Enchant Weapon - Superior Potency", 3833, false},
  106.                 {"Enchant Weapon - Ice Breaker", 3239, false},
  107.                 {"Enchant Weapon - Lifeward", 3241, false},
  108.                 {"Enchant Weapon - Blood Draining", 3870, false},
  109.                 {"Enchant Weapon - Blade Ward", 3869, false},
  110.                 {"Enchant Weapon - Exceptional Agility", 1103, false},
  111.                 {"Enchant Weapon - Exceptional Spirit", 3844, false},
  112.                 {"Enchant Weapon - Executioner", 3225, false},
  113.                 {"Enchant Weapon - Mongoose", 2673, false},
  114.                
  115.                 -- Two-Handed
  116.                 {"Enchant 2H Weapon - Massacre", 3827, true},
  117.                 {"Enchant 2H Weapon - Scourgebane", 3247, true},
  118.                 {"Enchant 2H Weapon - Giant Slayer", 3251, true},
  119.                 {"Enchant 2H Weapon - Greater Spellpower", 3854, true};
  120.         },
  121.        
  122.         [16] = {
  123.                 -- Offhand
  124.                 {"Enchant Weapon - Titan Guard", 3851, false},
  125.                 {"Enchant Weapon - Accuracy", 3788, false},
  126.                 {"Enchant Weapon - Berserking", 3789, false},
  127.                 {"Enchant Weapon - Black Magic", 3790, false},
  128.                 {"Enchant Weapon - Mighty Spellpower", 3834, false},
  129.                 {"Enchant Weapon - Superior Potency", 3833, false},
  130.                 {"Enchant Weapon - Ice Breaker", 3239, false},
  131.                 {"Enchant Weapon - Lifeward", 3241, false},
  132.                 {"Enchant Weapon - Blood Draining", 3870, false},
  133.                 {"Enchant Weapon - Blade Ward", 3869, false},
  134.                 {"Enchant Weapon - Exceptional Agility", 1103, false},
  135.                 {"Enchant Weapon - Exceptional Spirit", 3844, false},
  136.                 {"Enchant Weapon - Executioner", 3225, false},
  137.                 {"Enchant Weapon - Mongoose", 2673, false},
  138.                
  139.                 -- Shields
  140.                 {"Enchant Shield - Defense", 1952, true},
  141.                 {"Enchant Shield - Greater Intellect", 1128, true},
  142.                 {"Enchant Shield - Shield Block", 2655, true},
  143.                 {"Enchant Shield - Resilience", 3229, true},
  144.                 {"Enchant Shield - Major Stamina", 1071, true},
  145.                 {"Enchant Shield - Tough Shield", 2653, true};
  146.         },
  147. };
  148. local pVar = {};
  149.  
  150. function Enchanter(event, plr, unit)
  151.         pVar[plr:GetName()] = nil;
  152.  
  153.         for _, v in ipairs(T["Menu"]) do
  154.                 plr:GossipMenuAddItem(3, "|cFF008000Enchant "..v[1]..".|R", 0, v[2])
  155.         end
  156.         plr:GossipSendMenu(1, unit)
  157. end
  158.  
  159. function EnchanterSelect(event, plr, unit, sender, intid, code)
  160.         if (intid < 500) then
  161.                 local ID = intid
  162.                 local f
  163.                 if(intid == 161 or intid == 151) then
  164.                         ID = math.floor(intid/10)
  165.                         f = true
  166.                 end
  167.                 pVar[plr:GetName()] = intid;
  168.                 if(T[ID]) then
  169.                         for i, v in ipairs(T[ID]) do
  170.                                 if((not f and not v[3]) or (f and v[3])) then
  171.                                         plr:GossipMenuAddItem(3, "|cFF008000Enchant "..v[1]..".|R", 0, v[2])
  172.                                 end
  173.                         end
  174.                 end
  175.                 plr:GossipMenuAddItem(3, "[Back]", 0, 500)
  176.                 plr:GossipSendMenu(1, unit)
  177.         elseif (intid == 500) then
  178.                 Enchanter(event, plr, unit)
  179.         elseif (intid >= 900) then
  180.                 local ID = pVar[plr:GetName()]
  181.                 if(ID == 161 or ID == 151) then
  182.                         ID = math.floor(ID/10)
  183.                 end
  184.                 for k, v in pairs(T[ID]) do
  185.                         if v[2] == intid then
  186.                                 local item = plr:GetEquippedItemBySlot(ID)
  187.                                 if item then
  188.                                         if v[3] then
  189.                                                 local WType = item:GetSubClass()
  190.                                                 if pVar[plr:GetName()] == 151 then
  191.                                                         if(WType == 1 or WType == 5 or WType == 6 or WType == 8 or WType == 10) then
  192.                                                                 item:ClearEnchantment(0,0)
  193.                                                                 item:SetEnchantment(intid, 0, 0)
  194.                                                         else
  195.                                                                 plr:SendAreaTriggerMessage("You do not have a Two-Handed Weapon equipped!")
  196.                                                         end    
  197.                                                 elseif pVar[plr:GetName()] == 161 then
  198.                                                         if(WType == 6) then
  199.                                                                 item:ClearEnchantment(0,0)
  200.                                                                 item:SetEnchantment(intid, 0, 0)
  201.                                                         else
  202.                                                                 plr:SendAreaTriggerMessage("You do not have a Shield equipped!")
  203.                                                         end
  204.                                                 end
  205.                                         else
  206.                                                 item:ClearEnchantment(0,0)
  207.                                                 item:SetEnchantment(intid, 0, 0)
  208.                                                 plr:CastSpell(plr, 36937)
  209.                                         end
  210.                                 else
  211.                                         plr:SendAreaTriggerMessage("You have no item to enchant in the selected slot!")
  212.                                 end
  213.                         end
  214.                 end
  215.                 EnchanterSelect(event, plr, unit, sender, pVar[plr:GetName()], nil)
  216.         end
  217. end
  218.  
  219. RegisterCreatureGossipEvent(npcid, 1, Enchanter)
  220. RegisterCreatureGossipEvent(npcid, 2, EnchanterSelect)
Advertisement
Add Comment
Please, Sign In to add comment