conan513

Untitled

Jun 24th, 2016
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.73 KB | None | 0 0
  1. function RollEnchant(item)
  2.     rarityRoll = math.random(100)
  3.     local itemClass = ""
  4.     if (item:GetClass() == 2) then
  5.         itemClass = "WEAPON"
  6.     elseif (item:GetClass() == 4) then
  7.         itemClass = "ARMOR"
  8.     end
  9.     if (rarityRoll <= 44) then
  10.         local query = WorldDBQuery("SELECT enchantID FROM item_enchantment_random_tiers WHERE tier=1 AND exclusiveSubClass=NULL AND class='"..itemClass.."' OR exclusiveSubClass="..item:GetSubClass().." OR class='ANY' ORDER BY RAND() LIMIT 1")
  11.         return query:GetUInt32(0)
  12.     elseif (rarityRoll <= 64) then
  13.         local query = WorldDBQuery("SELECT enchantID FROM item_enchantment_random_tiers WHERE tier=2 AND exclusiveSubClass=NULL AND class='"..itemClass.."' OR exclusiveSubClass="..item:GetSubClass().." OR class='ANY' ORDER BY RAND() LIMIT 1")
  14.         return query:GetUInt32(0)
  15.     elseif (rarityRoll <= 79) then
  16.         local query = WorldDBQuery("SELECT enchantID FROM item_enchantment_random_tiers WHERE tier=3 AND exclusiveSubClass=NULL AND class='"..itemClass.."' OR exclusiveSubClass="..item:GetSubClass().." OR class='ANY' ORDER BY RAND() LIMIT 1")
  17.         return query:GetUInt32(0)
  18.     elseif (rarityRoll <= 92) then
  19.         local query = WorldDBQuery("SELECT enchantID FROM item_enchantment_random_tiers WHERE tier=4 AND exclusiveSubClass=NULL AND class='"..itemClass.."' OR exclusiveSubClass="..item:GetSubClass().." OR class='ANY' ORDER BY RAND() LIMIT 1")
  20.         return query:GetUInt32(0)
  21.     else
  22.         local query = WorldDBQuery("SELECT enchantID FROM item_enchantment_random_tiers WHERE tier=5 AND exclusiveSubClass=NULL AND class='"..itemClass.."' OR exclusiveSubClass="..item:GetSubClass().." OR class='ANY' ORDER BY RAND() LIMIT 1")
  23.         return query:GetUInt32(0)
  24.     end
  25. end
  26.  
  27. function OnLoot(event, player, item, count)
  28.     local slotBools     = {}
  29.     local slotIDs       = {}
  30.     local its           = 0
  31.    
  32.     local boolRoll1     = math.random(100)
  33.     if (boolRoll1 >= 60) then
  34.         slotBools[1]    = true
  35.         slotIDs[1]      = RollEnchant(item)
  36.     else slotBools[1]   = false
  37.     end
  38.    
  39.     local boolRoll2     = math.random(100)
  40.     if (boolRoll2 >=65) and (slotBools[1] == true) then
  41.         slotBools[2]    = true
  42.         slotIDs[2]      = RollEnchant(item)
  43.     else slotBools[2] = false
  44.     end
  45.    
  46.     local boolRoll3     = math.random(100)
  47.     if (boolRoll2 >=70) and (slotBools[2] == true) then
  48.         slotBools[3]    = true
  49.         slotIDs[3]      = RollEnchant(item)
  50.     else slotBools[3] = false
  51.     end
  52.    
  53.     local boolRoll4     = math.random(100)
  54.     if (boolRoll2 >=75) and (slotBools[3] == true) then
  55.         slotBools[4]    = true
  56.         slotIDs[4]      = RollEnchant(item)
  57.     else slotBools[4] = false
  58.     end
  59.    
  60.     if (slotBools[1] == true) then
  61.         for i, id in ipairs(slotIDs) do
  62.             if (its == 2) then
  63.                 its = its + 3
  64.             end
  65.             if (slotBools[i] == true) then
  66.                 item:SetEnchantment(id, its)
  67.                 its = its + 1
  68.             end
  69.         end
  70.     end
  71. end
  72.  
  73. RegisterPlayerEvent(32, OnLoot)
Add Comment
Please, Sign In to add comment