Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --*-----------------------------------------*--
- --* dir parent : AdmiralCloak *--
- --* File name : init.lua *--
- --* Created by : Eviles *--
- --* Discord : Eviles#2759 *--
- --*-----------------------------------------*--
- print("* Loading <AdmiralCloak> init.lua" )
- --********************************************************************************************************************************--
- --##################################################Configurations################################################################--
- --********************************************************************************************************************************--
- Cloak = {}
- Cloak.conf = {
- cloakId = 9205,
- dustyId = 9204,
- cloakSlot = 5,
- maxLv = 5,
- }
- Cloak.race = {
- [1] = 71,
- [2] = 72,
- [3] = 73,
- [4] = 74
- }
- Cloak.eff01 = {
- [1] = 75,
- [2] = 76,
- [3] = 77,
- [4] = 78
- }
- Cloak.eff02 = {
- [1] = 80,
- [2] = 82,
- [3] = 84,
- [4] = 190
- }
- Cloak.eff03 = {
- [1] = 210,
- [2] = 211,
- [3] = 212,
- [4] = 213
- }
- Cloak.upRate = {}
- Cloak.upRate[0] = 1
- Cloak.upRate[1] = 1
- Cloak.upRate[2] = 1
- Cloak.upRate[3] = 1
- Cloak.upRate[4] = 1
- Cloak.upRate[5] = 1
- --********************************************************************************************************************************--
- --##################################################Functions#####################################################################--
- --********************************************************************************************************************************--
- function Cloak.hasCloak(Player)
- local slot = GetChaItem(Player, 2, (Cloak.conf['cloakSlot'] -1))
- local slotId = GetItemID(slot)
- if slotId == Cloak.conf['cloakId'] then
- return 1
- end
- return 0
- end
- function Cloak.getLv(Cloak)
- local cloakLv = GetItemAttr(Cloak, 55)
- if cloakLv == nil then
- return 0
- else
- return cloakLv
- end
- end
- function PIO_CloakUnseal(Player, Item)
- local Cha_Boat = 0
- Cha_Boat = GetCtrlBoat(Player)
- if Cha_Boat ~= nil then
- SystemNotice(Player, 'Cannot use while sailing!')
- UseItemFailed(Player)
- return
- end
- local hasDusty = CheckBagItem(Player, Cloak.conf['dustyId'])
- if hasDusty < 1 then
- BickerNotice(Player, 'You need ['..GetItemName(Cloak.conf['dustyId'])..'] in your inventory!')
- UseItemFailed(Player)
- return
- else
- TakeItem(Player, 0, Cloak.conf['dustyId'], 1)
- GiveItem(Player, 0, Cloak.conf['cloakId'], 1, 88)
- Notice(GetChaDefaultName(Player)..' succesfully unsealed a '..GetItemName(Cloak.conf['dustyId'])..'!')
- PlayEffect(Player, 345)
- end
- end
- function PIO_CloakInjection(Player, Item)
- local Cha_Boat = 0
- Cha_Boat = GetCtrlBoat(Player)
- if Cha_Boat ~= nil then
- SystemNotice(Player, 'Cannot use while sailing!')
- UseItemFailed(Player)
- return
- end
- local Injection = {}
- Injection[9193] = {AttrType = ITEMATTR_VAL_STR, AttrAdd = 1, AttrMax = 5, AttrName = 'Strength'} --Cloak Strength Injection
- Injection[9194] = {AttrType = ITEMATTR_VAL_CON, AttrAdd = 1, AttrMax = 5, AttrName = 'Constitution'} --Cloak Constitution Injection
- Injection[9195] = {AttrType = ITEMATTR_VAL_DEX, AttrAdd = 1, AttrMax = 5, AttrName = 'Accuracy'} --Cloak Accuracy Injection
- Injection[9196] = {AttrType = ITEMATTR_VAL_AGI, AttrAdd = 1, AttrMax = 5, AttrName = 'Agility'} --Cloak Agility Injection
- Injection[9197] = {AttrType = ITEMATTR_VAL_STA, AttrAdd = 1, AttrMax = 5, AttrName = 'Spirit'} --Cloak Spirit Injection
- local ItemId = GetItemID(Item)
- if Injection[ItemId] == nil then
- SystemNotice(Player, 'Internal error!')
- UseItemFailed(Player)
- return
- end
- local slot = GetChaItem(Player, 2, (Cloak.conf['cloakSlot'] -1))
- local slotId = GetItemID(slot)
- local cloakLv = Cloak.getLv(slot)
- if slot == nil then
- BickerNotice(Player, 'Please insert a item on 5th inventory slot!')
- UseItemFailed(Player)
- return
- end
- if slotId ~= Cloak.conf['cloakId'] then
- BickerNotice(Player, GetItemName(Cloak.conf['cloakId'])..' must be placed on 5th inventory slot!')
- UseItemFailed(Player)
- return
- end
- if cloakLv >= Cloak.conf['maxLv'] then
- BickerNotice(Player, GetItemName(Cloak.conf['cloakId'])..' arealdy maxed attributes!')
- UseItemFailed(Player)
- return
- end
- local upChance = Percentage_Random(Cloak.upRate[cloakLv])
- local statAdd = Injection[ItemId].AttrAdd
- local attrNum = GetItemAttr(slot, Injection[ItemId].AttrType)
- local newLv = cloakLv + 1
- if upChance == 1 then
- attrNum = attrNum + statAdd
- SetItemAttr(slot, Injection[ItemId].AttrType, attrNum)
- SetItemAttr(slot, 55, newLv)
- SystemNotice(Player, 'Congratulations! You have succesfully enchanted Admiral Cloak to LV'..newLv..'.')
- PlayEffect(Player, 345)
- RefreshCha(Player)
- else
- SystemNotice(Player, 'Enchanting failed..')
- PlayEffect(Player, 346)
- end
- end
- function State_AC_Add(Player, StateLv)
- if (IsPlayer(Player) == 1) then
- local slot = GetChaItem(Player, 2, (Cloak.conf['cloakSlot'] -1))
- local str = StrSb(Player)
- local agi = AgiSb(Player)
- local con = ConSb(Player)
- local acc = DexSb(Player)
- local spr = StaSb(Player)
- local cloakStr = GetItemAttr(slot, ITEMATTR_VAL_STR)
- local cloakSta = GetItemAttr(slot, ITEMATTR_VAL_STA)
- local cloakAgi = GetItemAttr(slot, ITEMATTR_VAL_AGI)
- local cloakCon = GetItemAttr(slot, ITEMATTR_VAL_CON)
- local cloakDex = GetItemAttr(slot, ITEMATTR_VAL_DEX)
- local strVal = 0
- local sprVal = 0
- local agiVal = 0
- local conVal = 0
- local accVal = 0
- if Cloak.hasCloak(Player) == 1 then
- strVal = str + cloakStr
- sprVal = spr + cloakSta
- agiVal = agi + cloakAgi
- conVal = con + cloakCon
- accVal = acc + cloakDex
- end
- SetCharaAttr(strVal, Player, ATTR_STATEV_STR)
- SetCharaAttr(sprVal, Player, ATTR_STATEV_STA)
- SetCharaAttr(agiVal, Player, ATTR_STATEV_AGI)
- SetCharaAttr(conVal, Player, ATTR_STATEV_CON)
- SetCharaAttr(accVal, Player, ATTR_STATEV_DEX)
- RefreshCha(Player)
- end
- end
- function State_AC_Rem(Player, StateLv)
- SetCharaAttr(0 , Player , ATTR_STATEV_STR)
- SetCharaAttr(0 , Player , ATTR_STATEV_AGI)
- SetCharaAttr(0 , Player , ATTR_STATEV_DEX)
- SetCharaAttr(0 , Player , ATTR_STATEV_CON)
- SetCharaAttr(0 , Player , ATTR_STATEV_STA)
- RefreshCha(Player)
- end
- function PIO_Effect_Cloak(Player)
- local slot = GetChaItem(Player, 2, (Cloak.conf['cloakSlot'] -1))
- local cloakLv = Cloak.getLv(slot)
- local chaType = GetChaTypeID(Player)
- local capeEff = Cloak.race[chaType]
- local glow01 = Cloak.eff01[chaType]
- local glow02 = Cloak.eff02[chaType]
- local glow03 = Cloak.eff03[chaType]
- if Cloak.hasCloak(Player) == 1 then
- AddState(Player, Player, capeEff, 1, 3600)
- else
- if GetChaStateLv(Player, capeEff) > 0 then
- RemoveState(Player, capeEff)
- end
- end
- if Cloak.hasCloak(Player) == 1 and cloakLv < 3 then
- AddState(Player, Player, glow01, 1, 3600)
- else
- if GetChaStateLv(Player, glow01) > 0 then
- RemoveState(Player, glow01)
- end
- end
- if Cloak.hasCloak(Player) == 1 and cloakLv > 2 and cloakLv < 5 then
- AddState(Player, Player, glow02, 1, 3600)
- else
- if GetChaStateLv(Player, glow02) > 0 then
- RemoveState(Player, glow02)
- end
- end
- if Cloak.hasCloak(Player) == 1 and cloakLv == 5 then
- AddState(Player, Player, glow03, 1, 3600)
- else
- if GetChaStateLv(Player, glow03) > 0 then
- RemoveState(Player, glow03)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement