Advertisement
zSatan

Admiral Cloak - Addon

Jul 30th, 2018
568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.28 KB | None | 0 0
  1. --*-----------------------------------------*--
  2. --* dir parent  : AdmiralCloak              *--
  3. --* File name   : init.lua                  *--
  4. --* Created by  : Eviles                    *--
  5. --* Discord     : Eviles#2759               *--
  6. --*-----------------------------------------*--
  7. print("* Loading <AdmiralCloak> init.lua" )
  8. --********************************************************************************************************************************--  
  9. --##################################################Configurations################################################################--
  10. --********************************************************************************************************************************--  
  11.     Cloak                           = {}
  12.         Cloak.conf                  = {
  13.             cloakId                 = 9205,
  14.             dustyId                 = 9204,
  15.             cloakSlot               = 5,
  16.             maxLv                   = 5,
  17.         }
  18.         Cloak.race                  = {
  19.             [1]                     = 71,
  20.             [2]                     = 72,
  21.             [3]                     = 73,
  22.             [4]                     = 74
  23.         }
  24.         Cloak.eff01                 = {
  25.             [1]                     = 75,
  26.             [2]                     = 76,
  27.             [3]                     = 77,
  28.             [4]                     = 78
  29.         }
  30.         Cloak.eff02                 = {
  31.             [1]                     = 80,
  32.             [2]                     = 82,
  33.             [3]                     = 84,
  34.             [4]                     = 190
  35.         }  
  36.         Cloak.eff03                 = {
  37.             [1]                     = 210,
  38.             [2]                     = 211,
  39.             [3]                     = 212,
  40.             [4]                     = 213
  41.         }  
  42.         Cloak.upRate                = {}
  43.         Cloak.upRate[0]             = 1
  44.         Cloak.upRate[1]             = 1
  45.         Cloak.upRate[2]             = 1
  46.         Cloak.upRate[3]             = 1
  47.         Cloak.upRate[4]             = 1
  48.         Cloak.upRate[5]             = 1
  49. --********************************************************************************************************************************--
  50. --##################################################Functions#####################################################################--
  51. --********************************************************************************************************************************--
  52.     function Cloak.hasCloak(Player)
  53.         local slot                  = GetChaItem(Player, 2, (Cloak.conf['cloakSlot'] -1))
  54.         local slotId                = GetItemID(slot)
  55.         if slotId == Cloak.conf['cloakId'] then
  56.             return 1
  57.         end
  58.         return 0
  59.     end
  60.     function Cloak.getLv(Cloak)
  61.         local cloakLv               = GetItemAttr(Cloak, 55)
  62.         if cloakLv == nil then
  63.             return 0
  64.         else
  65.             return cloakLv
  66.         end
  67.     end
  68.    
  69.     function PIO_CloakUnseal(Player, Item)
  70.         local Cha_Boat              = 0
  71.         Cha_Boat                    = GetCtrlBoat(Player)
  72.         if Cha_Boat ~= nil then
  73.             SystemNotice(Player, 'Cannot use while sailing!')
  74.             UseItemFailed(Player)
  75.             return
  76.         end
  77.         local hasDusty              = CheckBagItem(Player, Cloak.conf['dustyId'])
  78.         if hasDusty < 1 then
  79.             BickerNotice(Player, 'You need ['..GetItemName(Cloak.conf['dustyId'])..'] in your inventory!')
  80.             UseItemFailed(Player)
  81.             return
  82.         else
  83.             TakeItem(Player, 0, Cloak.conf['dustyId'], 1)
  84.             GiveItem(Player, 0, Cloak.conf['cloakId'], 1, 88)
  85.             Notice(GetChaDefaultName(Player)..' succesfully unsealed a '..GetItemName(Cloak.conf['dustyId'])..'!')
  86.             PlayEffect(Player, 345)
  87.         end
  88.     end
  89.    
  90.     function PIO_CloakInjection(Player, Item)
  91.         local Cha_Boat              = 0
  92.         Cha_Boat                    = GetCtrlBoat(Player)
  93.         if Cha_Boat ~= nil then
  94.             SystemNotice(Player, 'Cannot use while sailing!')
  95.             UseItemFailed(Player)
  96.             return
  97.         end
  98.         local Injection             = {}
  99.         Injection[9193]             = {AttrType = ITEMATTR_VAL_STR, AttrAdd = 1, AttrMax = 5, AttrName = 'Strength'}        --Cloak Strength Injection
  100.         Injection[9194]             = {AttrType = ITEMATTR_VAL_CON, AttrAdd = 1, AttrMax = 5, AttrName = 'Constitution'}    --Cloak Constitution Injection
  101.         Injection[9195]             = {AttrType = ITEMATTR_VAL_DEX, AttrAdd = 1, AttrMax = 5, AttrName = 'Accuracy'}        --Cloak Accuracy Injection
  102.         Injection[9196]             = {AttrType = ITEMATTR_VAL_AGI, AttrAdd = 1, AttrMax = 5, AttrName = 'Agility'}         --Cloak Agility Injection
  103.         Injection[9197]             = {AttrType = ITEMATTR_VAL_STA, AttrAdd = 1, AttrMax = 5, AttrName = 'Spirit'}          --Cloak Spirit Injection
  104.         local ItemId                = GetItemID(Item)
  105.         if Injection[ItemId] == nil then
  106.             SystemNotice(Player, 'Internal error!')
  107.             UseItemFailed(Player)
  108.             return
  109.         end
  110.         local slot                  = GetChaItem(Player, 2, (Cloak.conf['cloakSlot'] -1))
  111.         local slotId                = GetItemID(slot)
  112.         local cloakLv               = Cloak.getLv(slot)
  113.         if slot == nil then
  114.             BickerNotice(Player, 'Please insert a item on 5th inventory slot!')
  115.             UseItemFailed(Player)
  116.             return
  117.         end
  118.         if slotId ~= Cloak.conf['cloakId'] then
  119.             BickerNotice(Player, GetItemName(Cloak.conf['cloakId'])..' must be placed on 5th inventory slot!')
  120.             UseItemFailed(Player)
  121.             return
  122.         end
  123.         if cloakLv >= Cloak.conf['maxLv'] then
  124.             BickerNotice(Player, GetItemName(Cloak.conf['cloakId'])..' arealdy maxed attributes!')
  125.             UseItemFailed(Player)
  126.             return
  127.         end
  128.         local upChance              = Percentage_Random(Cloak.upRate[cloakLv])    
  129.         local statAdd               = Injection[ItemId].AttrAdd
  130.         local attrNum               = GetItemAttr(slot, Injection[ItemId].AttrType)
  131.         local newLv                 = cloakLv + 1      
  132.         if upChance == 1 then
  133.             attrNum                 = attrNum + statAdd
  134.             SetItemAttr(slot, Injection[ItemId].AttrType, attrNum)
  135.             SetItemAttr(slot, 55, newLv)
  136.             SystemNotice(Player, 'Congratulations! You have succesfully enchanted Admiral Cloak to LV'..newLv..'.')
  137.             PlayEffect(Player, 345)
  138.             RefreshCha(Player)
  139.         else
  140.             SystemNotice(Player, 'Enchanting failed..')
  141.             PlayEffect(Player, 346)
  142.         end
  143.     end
  144.    
  145.  function State_AC_Add(Player, StateLv)
  146.         if (IsPlayer(Player) == 1) then
  147.             local slot              = GetChaItem(Player, 2, (Cloak.conf['cloakSlot'] -1))
  148.             local str               = StrSb(Player)
  149.             local agi               = AgiSb(Player)
  150.             local con               = ConSb(Player)
  151.             local acc               = DexSb(Player)
  152.             local spr               = StaSb(Player)
  153.             local cloakStr          = GetItemAttr(slot, ITEMATTR_VAL_STR)
  154.             local cloakSta          = GetItemAttr(slot, ITEMATTR_VAL_STA)          
  155.             local cloakAgi          = GetItemAttr(slot, ITEMATTR_VAL_AGI)          
  156.             local cloakCon          = GetItemAttr(slot, ITEMATTR_VAL_CON)
  157.             local cloakDex          = GetItemAttr(slot, ITEMATTR_VAL_DEX)
  158.             local strVal            = 0
  159.             local sprVal            = 0
  160.             local agiVal            = 0
  161.             local conVal            = 0
  162.             local accVal            = 0
  163.             if Cloak.hasCloak(Player) == 1 then
  164.                 strVal              = str + cloakStr
  165.                 sprVal              = spr + cloakSta
  166.                 agiVal              = agi + cloakAgi
  167.                 conVal              = con + cloakCon
  168.                 accVal              = acc + cloakDex
  169.             end
  170.             SetCharaAttr(strVal, Player, ATTR_STATEV_STR)
  171.             SetCharaAttr(sprVal, Player, ATTR_STATEV_STA)
  172.             SetCharaAttr(agiVal, Player, ATTR_STATEV_AGI)
  173.             SetCharaAttr(conVal, Player, ATTR_STATEV_CON)
  174.             SetCharaAttr(accVal, Player, ATTR_STATEV_DEX)        
  175.             RefreshCha(Player)        
  176.         end
  177.     end
  178.    
  179.     function State_AC_Rem(Player, StateLv)
  180.         SetCharaAttr(0 , Player , ATTR_STATEV_STR)
  181.         SetCharaAttr(0 , Player , ATTR_STATEV_AGI)
  182.         SetCharaAttr(0 , Player , ATTR_STATEV_DEX)
  183.         SetCharaAttr(0 , Player , ATTR_STATEV_CON)
  184.         SetCharaAttr(0 , Player , ATTR_STATEV_STA)
  185.         RefreshCha(Player)    
  186.     end
  187.    
  188.     function PIO_Effect_Cloak(Player)
  189.         local slot                  = GetChaItem(Player, 2, (Cloak.conf['cloakSlot'] -1))
  190.         local cloakLv               = Cloak.getLv(slot)
  191.         local chaType               = GetChaTypeID(Player)
  192.         local capeEff               = Cloak.race[chaType]
  193.         local glow01                = Cloak.eff01[chaType]
  194.         local glow02                = Cloak.eff02[chaType]
  195.         local glow03                = Cloak.eff03[chaType]
  196.         if Cloak.hasCloak(Player) == 1 then
  197.             AddState(Player, Player, capeEff, 1, 3600)
  198.         else
  199.             if GetChaStateLv(Player, capeEff) > 0 then
  200.                 RemoveState(Player, capeEff)
  201.             end
  202.         end
  203.         if Cloak.hasCloak(Player) == 1 and cloakLv < 3 then
  204.             AddState(Player, Player, glow01, 1, 3600)
  205.         else
  206.             if GetChaStateLv(Player, glow01) > 0 then
  207.                 RemoveState(Player, glow01)
  208.             end
  209.         end
  210.         if Cloak.hasCloak(Player) == 1 and cloakLv > 2 and cloakLv < 5 then
  211.             AddState(Player, Player, glow02, 1, 3600)
  212.         else
  213.             if GetChaStateLv(Player, glow02) > 0 then
  214.                 RemoveState(Player, glow02)
  215.             end
  216.         end
  217.         if Cloak.hasCloak(Player) == 1 and cloakLv == 5 then
  218.             AddState(Player, Player, glow03, 1, 3600)
  219.         else
  220.             if GetChaStateLv(Player, glow03) > 0 then
  221.                 RemoveState(Player, glow03)
  222.             end
  223.         end        
  224.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement