Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.06 KB | None | 0 0
  1. quest costumeRefine begin
  2.     state start begin
  3.  
  4.         -- Params: index[0-4],applyType,applyValue
  5.  
  6.         function set_attr(index,_appType,_appValue)
  7.             item.set_value(index,_appType,_appValue)
  8.         end
  9.  
  10.         -- Params: index[0-4] || return: applyType or 0 if null
  11.         function get_attr(index)
  12.             return item.get_attr(index)
  13.         end
  14.  
  15.  
  16.         function getRandomBonus()
  17.             local _bonusTable = {{1,7500}, -- Max. HP +7500
  18.                             {17,5}, -- Strong against Half Human +5%
  19.                             {92,5}, -- Resistance from Half Human +5%
  20.                             {20,8}, -- Strong against Mystic +8%
  21.                             {19,8}, -- Strong against Orcs +8%
  22.                             {22,8}, -- Strong against Devil's +8%
  23.                             {18,8}, -- Strong against Animals +8%
  24.                             {21,8}, -- Strong against Undead +8%
  25.                             {63,5}, -- Strong against Monster +5%
  26.                             {95,8}, -- Strong vs Metin Stone +8%
  27.                             {16,7}, -- 7% Chance of Piercing Hit
  28.                             {15,7}, -- 7% Chance of Critical Hit
  29.                             {59,5}, -- 5% Strong against Warrior
  30.                             {60,5}, -- 5% Strong against Sura
  31.                             {61,5}, -- 5% Strong against Ninja
  32.                             {62,5}, -- 5% Strong against Shaman
  33.                             {78,5}, -- 5% Warrior Resistance
  34.                             {79,5}, -- 5% Sura Resistance
  35.                             {80,5}, -- 5% Ninja Resistance
  36.                             {81,5} --  5% Shaman Resistance
  37.                             }
  38.  
  39.             local _rand = math.random(1,table.getn(_bonusTable))
  40.             return _bonusTable[_rand][1], _bonusTable[_rand][2]
  41.         end
  42.  
  43.         function switchBonus(_bType)
  44.             local _bonusTable = {{1,7500}, -- Max. HP +7500
  45.                             {17,5}, -- Strong against Half Human +5%
  46.                             {92,5}, -- Resistance from Half Human +5%
  47.                             {20,8}, -- Strong against Mystic +8%
  48.                             {19,8}, -- Strong against Orcs +8%
  49.                             {22,8}, -- Strong against Devil's +8%
  50.                             {18,8}, -- Strong against Animals +8%
  51.                             {21,8}, -- Strong against Undead +8%
  52.                             {63,5}, -- Strong against Monster +5%
  53.                             {95,8}, -- Strong vs Metin Stone +8%
  54.                             {16,7}, -- 7% Chance of Piercing Hit
  55.                             {15,7}, -- 7% Chance of Critical Hit
  56.                             {59,5}, -- 5% Strong against Warrior
  57.                             {60,5}, -- 5% Strong against Sura
  58.                             {61,5}, -- 5% Strong against Ninja
  59.                             {62,5}, -- 5% Strong against Shaman
  60.                             {78,5}, -- 5% Warrior Resistance
  61.                             {79,5}, -- 5% Sura Resistance
  62.                             {80,5}, -- 5% Ninja Resistance
  63.                             {81,5} --  5% Shaman Resistance
  64.                             }
  65.             local _index
  66.             for i=1,table.getn(_bonusTable) do
  67.                 if _bonusTable[i][1] == _bType then
  68.                     _index = i
  69.                     break
  70.                 end
  71.             end
  72.             local _newTable = _bonusTable
  73.             table.remove(_newTable, _index)
  74.             local _rand = math.random(1,table.getn(_newTable))
  75.             return _newTable[_rand][1], _newTable[_rand][2]
  76.         end
  77.  
  78.  
  79.  
  80.  
  81.         -- Costume Refine system.
  82.         when 20094.take begin
  83.             local vnum = item.get_vnum()
  84.             if vnum < 19000 or vnum > 19500 then
  85.                 if vnum < 45220 or vnum > 48369 then -- Ultimi costumi aggiunti: Faction War set from 47959 to 48369
  86.                     say_title("Sarto:")
  87.                     say("non posso migliorare questo oggetto")
  88.                     return
  89.                 end
  90.             end
  91.             --local refine_success = vnum + 9
  92.             --local str_len = string.len(tostring(vnum))
  93.             ---for i=1,str_len do
  94.                 --if string.sub(vnum,i,i) == '9' and i == str_len then
  95.                     if costumeRefine.get_attr(1) == 0 then
  96.                         if pc.count_item(710051) == 0 then
  97.                             say_title("Sarto:")
  98.                             say("")
  99.                             say("hai bisogno di questo item")
  100.                             say("")
  101.                             say_item_vnum(710051)
  102.                             return
  103.                         end
  104.                         say_title("Sarto:")
  105.                         say("Vuoi aggiungere un bnus al tuo costume")
  106.                         say("")
  107.                         say_item_vnum(vnum)
  108.                         say("")
  109.                         local s = select("Si", "No") if s == 2 then return end
  110.                         local _bonusType, _bonusValue = costumeRefine.getRandomBonus()
  111.                         pc.remove_item(710051)
  112.                         costumeRefine.set_attr(1,_bonusType,_bonusValue)
  113.                         say_title("Sarto:")
  114.                         say("")
  115.                         say_item_vnum(vnum)
  116.                         say("bonus aggiunto")
  117.                         --say("Bonus: ".._bonusType.." ".._bonusValue)
  118.                         return
  119.                     end
  120.                     if costumeRefine.get_attr(1) > 0 then
  121.                         if pc.count_item(710052) == 0 then
  122.                             say_title("Sarto:")
  123.                             say("")
  124.                             say("Hai isogno di un item")
  125.                             say("")
  126.                             say_item_vnum(710052)
  127.                             return
  128.                         end
  129.                         say_title("Sarto:")
  130.                         say("Desideri cambiare bonus al tuo costume?")
  131.                         say("")
  132.                         say_item_vnum(vnum)
  133.                         local s = select("Si", "No") if s == 2 then return end
  134.                         local _currBonus = costumeRefine.get_attr(1)
  135.                         local _newBonusT, _newBonusV = costumeRefine.switchBonus(_currBonus)
  136.                         pc.remove_item(710052)
  137.                         costumeRefine.set_attr(1,_newBonusT,_newBonusV)
  138.                         say_title("Sarto:")
  139.                         say("")
  140.                         say_item_vnum(vnum)
  141.                         say("Bonus cambiato con successo")
  142.                         --say("Bonus: ".._newBonusT.." ".._newBonusV)
  143.                         return
  144.                     end
  145.                 end
  146.        
  147.         when 20084.chat."Informazioni: migliorare un Costume" begin
  148.             say_title("Sarto:")
  149.             say("Trascina un Costume su di me per migliorarlo.[ENTER]Sui Costumi Migliorati e' possibile aggiungere un bonus.")
  150.             say("")
  151.             say_item_vnum(50367)
  152.             say("Trascinalo di nuovo su di me per aggiungere un bonus, e nuovamente per cambiarlo.")
  153.             say_reward("Ricorda che può fallire")
  154.         end
  155.        
  156.        
  157.     end
  158. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement