Guest User

Item Awakening - Nightmare Helm

a guest
Dec 13th, 2016
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.71 KB | None | 0 0
  1. --[[
  2.  
  3.                                                 ##################################################
  4.                                                 #      - Item Awakening: Nightmare Helm -         #
  5.                                                 #                >> By: Satan <<                 #
  6.                                                 ##################################################
  7.        
  8.     >> Installation:
  9.         * Call this file with DoFile. Eg: DoFile(GetResPath("script/addon/Awakening.lua");
  10.         * Note: Make sure you added the itemquality(25) and it's attributes(0) in Creat_Item() function;
  11.  
  12.         - Open AttrCalculate.lua and find: 
  13.    
  14. function Creat_Item(item, item_type, item_lv, item_event) -- AttrCalculate.lua
  15.  
  16.         - Below, local Num = 0 add the following:
  17.  
  18.     if item_event == 25 then
  19.         Add_Item_Attr( ITEMATTR_COE_MXSP , 0);
  20.         Add_Item_Attr( ITEMATTR_COE_MXHP , 0);
  21.         Add_Item_Attr( ITEMATTR_COE_MSPD, 0);
  22.         Add_Item_Attr( ITEMATTR_VAL_PDEF, 0);      
  23.     end
  24.  
  25.     >> ITEMINFO.TXT:
  26.    
  27. 57  Nightmare Demonic Helm  e1043   10110001    0000920001  0001930001  0002991001  0003010301  0   0   20  0   0   0   0   1   0   1   0   1   1   1   2000    -1,-2,-2,-2 100 -1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2    0   0   0,-2,-2,-2,-2,-2,-2,-2,-2,-2    -1,-2,-2,-2,-2,-2,-2,-2,-2,-2   0   0   0   0   0   0   0   0   0   0   0   0   0,30    0,30    0   0   0   0   0   0   0,30    0   0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,30    0   7000,7000   20000,20000 0   0   0   0   0   0   0   0   0   0   0   0,0,0,0,0,0,0,0 0,0,0,0,0,0,0,0 0,0 0   0   Nightmare Demonic equipments
  28. 7576    Dusty Nightmare Helm    n0322   10130015    0   0   0   0   0   0   31  0   0   0   0   0   1   1   0   1   99  0   2000    -1,-2,-2,-2 0   -1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2    0   0   -1,-2,-2,-2,-2,-2,-2,-2,-2,-2   -1,-2,-2,-2,-2,-2,-2,-2,-2,-2   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0   0,0 0,0 0   0   0   0   0   0   0   0   0   DustyNightmare  0   0,0,0,0,0,0,0,0 0,0,0,0,0,0,0,0 0,0 0,0 0,0 Double click to obtain a Nightmare Demonic Helm
  29. 7577    Scroll of Awakening n0350   10130005    0   0   0   0   0   0   31  0   0   0   0   0   1   1   1   1   1   0   2000    -1,-2,-2,-2 0   -1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2    0   0   -1,-2,-2,-2,-2,-2,-2,-2,-2,-2   -1,-2,-2,-2,-2,-2,-2,-2,-2,-2   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0   0,0 0,0 0   0   0   0   0   0   0   0   0   AwakeningScroll 0   0,0,0,0,0,0,0,0 0,0,0,0,0,0,0,0 0,0 0,0 0,0 A item created due the darkness place on Nightmare monsters. Can be use to enchant your Nightmare Helm. Double click to use. (Possible failure)
  30.  
  31. --]]
  32.  
  33. NaHelm = {}
  34.     NaHelm.conf = {
  35.         HelmID          = 57,       -- Nightmare Helm ID
  36.         dustID          = 7576,     -- Dusty Nightmare Helm ID
  37.         enSlot          = 1,        -- Slot to awaken helm
  38.         maxEn           = 10,       -- Max of Awakening
  39.         Mxhp_Awaken     = 10,       -- MAX HP Modulus Bonus obtained: 1%
  40.         Mxsp_Awaken     = 10,       -- MAX SP Modulus Bonus obtained: 1%
  41.         Mspd_Awaken     = 10,       -- MSPD Modulus Bonus obtained: 1%
  42.         Pr_Awaken       = 1         -- Physical Resist Obtained: 1
  43.     }
  44.    
  45.     NaHelm.awRate               = {};
  46.         NaHelm.awRate[0]            = 1         -- Lv0 to Lv1: 100%
  47.         NaHelm.awRate[1]            = .9        -- Lv1 to Lv2: 90%
  48.         NaHelm.awRate[2]            = .8        -- Lv2 to Lv3: 80%
  49.         NaHelm.awRate[3]            = .7        -- Lv3 to Lv4: 70%
  50.         NaHelm.awRate[4]            = .6        -- Lv4 to Lv5: 60%
  51.         NaHelm.awRate[5]            = .5        -- Lv5 to Lv6: 50%
  52.         NaHelm.awRate[6]            = .4        -- Lv6 to Lv7: 40%
  53.         NaHelm.awRate[7]            = .3        -- Lv7 to Lv8: 30%
  54.         NaHelm.awRate[8]            = .2        -- Lv8 to Lv9: 20%
  55.         NaHelm.awRate[9]            = .1        -- Lv9 to Lv10: 10%
  56.    
  57. ---------------------------------------
  58. -- * Obtain the awaken level of helm --
  59. ---------------------------------------
  60. NaHelm.getLv = function(item)
  61.     local getLv = GetItemAttr(item, 55)
  62.         if getLv > 0 then
  63.             return getLv
  64.         end
  65.     return 0
  66. end
  67.  
  68. -------------------------------------
  69. -- * Dusty Nightmare Helm function --
  70. -------------------------------------
  71. DustyNightmare = function(role, Item)
  72.     local Cha_Boat = GetCtrlBoat ( role )
  73.     if Cha_Boat ~=  nil then
  74.         SystemNotice( role , "Cannot use while sailing" )
  75.         UseItemFailed ( role )
  76.         return
  77.     end
  78.     local HasItem = CheckBagItem(role, NaHelm.conf['dustID']);
  79.     if HasItem < 1 then
  80.         BickerNotice(role,"["..GetItemName(NaHelm.conf['dustID']).."] is not in inventory!");
  81.         UseItemFailed(role);
  82.         return
  83.     else   
  84.         ----------------------------------------------------------------
  85.         -- Set attributes to helm by default: +1% Mx HP/SP, +1% Mspd; --
  86.         ----------------------------------------------------------------       
  87.         local r1, r2 = MakeItem(role, NaHelm.conf['HelmID'], 1, 25) -- If not set quality 25, awaken will not work;
  88.         local Awaken = GetChaItem(role,  2, r2)
  89.         SetItemAttr(Awaken, ITEMATTR_COE_MXHP, NaHelm.conf['Mxhp_Awaken']);     -- MAX HP Modulus Bonus;
  90.         SetItemAttr(Awaken, ITEMATTR_COE_MXSP, NaHelm.conf['Mxsp_Awaken']);     -- MAX SP Modulus Bonus;
  91.         SetItemAttr(Awaken, ITEMATTR_COE_MSPD, NaHelm.conf['Mspd_Awaken']);     -- MSPD Modulus Bonus;
  92.         SetItemAttr(Awaken, 55, 1);                                             -- Set Awaken level;
  93.         Notice(''..GetChaDefaultName(role)..', sucesfully unsealed '..GetItemName(NaHelm.conf['dustID'])..'!');
  94.     end
  95. end
  96.  
  97. ------------------------------------
  98. -- * Scroll of Awakening function --
  99. ------------------------------------
  100. AwakeningScroll = function(role, Item)
  101.     local Cha_Boat = GetCtrlBoat ( role )
  102.         if Cha_Boat ~=  nil then
  103.         SystemNotice( role , "Cannot use while sailing" )
  104.         UseItemFailed ( role )
  105.         return
  106.     end
  107.    
  108.     -- Obtains helm slot to awaken, 1st slot;
  109.     local helm = GetChaItem(role, 2, (NaHelm.conf['enSlot'] - 1))
  110.     local slotId = GetItemID(helm)
  111.     local helmLv = NaHelm.getLv(helm)
  112.     local sourceId = GetItemID(Item)
  113.     if slotId ~= NaHelm.conf['HelmID'] then
  114.         BickerNotice(role, 'Cannot use ['..GetItemName(sourceId)..'] on '..GetItemName(slotId)..'!')
  115.         UseItemFailed(role)
  116.         return
  117.     end
  118.    
  119.     -- Check if awaken level of helm is not max;
  120.     if helmLv >= NaHelm.conf['maxEn'] then
  121.         BickerNotice(role, '['..GetItemName(slotId)..'] already maxed Nightmare Helm!')
  122.         UseItemFailed(role)
  123.         return
  124.     end
  125.    
  126.     -- Awakening from Lv1 to Lv6 with sucess rate and Lv addition;
  127.     local success_Rate = Percentage_Random(NaHelm.awRate[helmLv]);
  128.     local LvAddition = helmLv + 1  
  129.     local physical = GetItemAttr(helm, ITEMATTR_VAL_PDEF)
  130.         if helmLv >= 1 and helmLv <= 6 then
  131.         if success_Rate == 1 then
  132.             SetItemAttr(helm, ITEMATTR_COE_MXHP, (LvAddition * NaHelm.conf['Mxhp_Awaken']));    -- MAX HP Modulus Bonus;
  133.             SetItemAttr(helm, ITEMATTR_COE_MXSP, (LvAddition * NaHelm.conf['Mxsp_Awaken']));    -- MAX SP Modulus Bonus;
  134.             SetItemAttr(helm, ITEMATTR_COE_MSPD, (LvAddition * NaHelm.conf['Mspd_Awaken']));    -- MSPD Modulus Bonus;
  135.             SetItemAttr(helm, 55, helmLv + 1);                                                  -- Set Awaken level;       
  136.             PlayEffect(role, 345);                                                              -- Success effect; 
  137.         else
  138.             SystemNotice(role , "Sorry, awaken has failed!");
  139.             PlayEffect(role, 346);                                                              -- Failure effect;
  140.         end            
  141.     end
  142.     -- Awakening from Lv7 to Lv10 with sucess rate and Lv addition, increases physical resist at Lv8-10;   
  143.         if helmLv >= 7 and helmLv <= 9 then
  144.         if success_Rate == 1 then
  145.             SetItemAttr(helm, ITEMATTR_COE_MXHP, (LvAddition * NaHelm.conf['Mxhp_Awaken']));    -- MAX HP Modulus Bonus;
  146.             SetItemAttr(helm, ITEMATTR_COE_MXSP, (LvAddition * NaHelm.conf['Mxsp_Awaken']));    -- MAX SP Modulus Bonus;
  147.             SetItemAttr(helm, ITEMATTR_COE_MSPD, (LvAddition * NaHelm.conf['Mspd_Awaken']));    -- MSPD Modulus Bonus;
  148.             SetItemAttr(helm, ITEMATTR_VAL_PDEF, (physical + NaHelm.conf['Pr_Awaken']));        -- Physical Resist Bonus;
  149.             SetItemAttr(helm, 55, helmLv + 1);                                                  -- Set Awaken level;       
  150.             PlayEffect(role, 345);                                                              -- Success effect;     
  151.         else
  152.             SystemNotice(role , "Sorry, awaken has failed!");
  153.             PlayEffect(role, 346);                                                              -- Failure effect;
  154.         end            
  155.     end        
  156. end
Add Comment
Please, Sign In to add comment