Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- *******************************************************************************************************************************
- ###############################################################################################################################
- *******************************************************************************************************************************
- Installation:
- 1) Change 'path' on ampData.Conf to you desired save path.
- 2) Setup ampData.Fruit to have the amp, bonuses, time in minutes that the amp will provide upon use as the value
- eg:
- [1128] = { Bonus = {'EXP'} , Rate = 4 , MinLv = 00, MaxLv = 40 , Min = 05},
- Means the item 1128 will provide EXP, 2x bonus (4/2), no minimum lv req, can be used until lv40 and 5min duration
- As well you can provide either just EXP or EXP and DROP in a amplifier, here a eg:
- [0898] = { Bonus = {'EXP','DROP'} , Rate = 4 , MinLv = 30, MaxLv = lm , Min = 15},
- 3) Paste the codes inside function AmplifierADS(ignore, role) at cha_timer and remove Hook:AddPostHook if you don't have custom_timer
- 4) Open exp_and_level.lua
- Find at GetExp_PKM(dead, atk):
- if ChaIsBoat (k[item_host] ) == 1 then
- local ship_lv = GetChaAttr ( k[item_host] , ATTR_LV )
- local shipowner_lv = GetChaAttr ( TurnToCha ( k[item_host] ) , ATTR_LV )
- local ship_exp = GetChaAttr ( k[item_host] , ATTR_CEXP )
- local ship_expadd = math.floor ( math.min ( 7 , ( dead_lv / 10 + 2 ) ) )
- local lv_limit = math.min ( ship_lv , shipowner_lv ) - 10
- if dead_lv >= lv_limit then
- ship_exp = ship_exp + ship_expadd
- SetCharaAttr ( ship_exp , k[item_host] ,ATTR_CEXP )
- end
- end
- Replace with:
- if ChaIsBoat(k[item_host]) == 1 then
- local SHIP_RAID = 1
- local StateLv = ampData.GetChaStateLv(TurnToCha(k[item_host]), 'EXP')
- if StateLv > 0 and StateLv <= 20 then
- SHIP_RAID = SHIP_RAID * StateLv/2
- end
- local ship_lv = GetChaAttr(k[item_host], ATTR_LV)
- local shipowner_lv = GetChaAttr(TurnToCha(k[item_host]), ATTR_LV)
- local ship_exp = GetChaAttr(k[item_host], ATTR_CEXP)
- local ship_expadd = math.floor(math.min(7, (dead_lv/10 + 2)))
- local lv_limit = math.min(ship_lv, shipowner_lv) - 10
- if dead_lv >= lv_limit then
- ship_exp = ship_exp + ship_expadd
- SetCharaAttr(ship_exp * SHIP_EXP * SHIP_RAID, k[item_host] ,ATTR_CEXP)
- end
- end
- Find at ShareTeamEXP(dead, team_atker, dead_exp, The_Killer, expsource):
- local EXP_RAID_STATE = 1
- local StateLv = GetChaStateLv ( t[i] , STATE_SBJYGZ )
- if StateLv > 0 and StateLv <= 10 then
- if StateLv == 1 then
- EXP_RAID_STATE = StateLv + 1
- end
- if StateLv == 2 then
- EXP_RAID_STATE = 2
- end
- if StateLv == 3 then
- EXP_RAID_STATE = 2.5
- end
- if StateLv == 4 then
- EXP_RAID_STATE = 5
- end
- if StateLv == 5 then
- EXP_RAID_STATE = 3
- end
- end
- Replace with:
- local EXP_RAID_STATE = 1
- local StateLv = ampData.GetChaStateLv(t[i], 'EXP')
- if StateLv > 0 and StateLv <= 20 then
- EXP_RAID_STATE = StateLv/2
- end
- Find GetExp_MKP(dead , atk) and paste the following inside:
- AmpDeathPunish(dead, atk)
- Do the same above with GetExp_PKP(dead, atk)
- 5) Open skilleffect.lua
- Find at Check_Baoliao(ATKER, DEFER, ...):
- local StateLv = GetChaStateLv(ATKER, STATE_SBJYGZ)
- if StateLv >= 0 and StateLv <= 10 then
- if StateLv == 1 then
- MF_RAID_STATE = StateLv + 1
- end
- if StateLv == 2 then
- MF_RAID_STATE = 2.5
- end
- if StateLv == 3 then
- MF_RAID_STATE = 3
- end
- end
- Replace with:
- local StateLv = ampData.GetChaStateLv(ATKER, 'DROP')
- if StateLv > 0 and StateLv <= 20 then
- MF_RAID_STATE = StateLv/2
- end
- 6) Load this file with DoFile()
- Information:
- 1) Database file named with every single PlayerID
- 2) No longer use STATES to provide EXP or DROP bonus to players
- 3) Upon getting killed (by monsters and players), players will lose their bonus
- 4) EXP and DROP rate will persist throughout diconnection and/or server restart
- 5) Every couple minutes, players will receive a message on the remaining time
- 6) Players will not be allowed to use same or lower tier amps if another tier activated
- 7) Players will be notified when an amp has come to an end
- 8) Bonuses will work while player sailing
- 9) Global function to all amplifiers PKO_AMP_SYS. Must replace original function on amps at ItemInfo.txt to this new one!
- 10) Fixed amps bonuses based on their description
- --]]
- --*-----------------------------------------*--
- --* dir parent : addon *--
- --* File name : AmpHandler.lua *--
- --* Last Mod : 02/17/2018 - 02:20PM *--
- --* Created by : Eviles *--
- --* Discord : #2759 *--
- --* Credits : Billy, KONG *--
- --*-----------------------------------------*--
- print('* Loading <AmpHandler> init.lua')
- local lm = LV_LIMIT
- ampData = {}
- ampData.Temp = {}
- ampData.Conf = {
- path = GetResPath('script/addon/AmpHandler/data/')
- }
- function ampData.CreateDB(file)
- t = io.open(file, 'r')
- if t ~= nil then
- io.close(t)
- else
- table.save({},file, 'w')
- end
- end
- function ampData.GetChaStateLv(role, type)
- local chaId = GetCharID(role)
- if file_exists(ampData.Conf['path']..chaId..'.txt') == true then
- local data = table.load(ampData.Conf['path']..chaId..'.txt', 'r')
- local chaId = GetCharID(role)
- if data ~= nil then
- if data[type] ~= nil then
- return data[type].Rate
- end
- end
- end
- return 0
- end
- function ampData.GetChaStateTime(role, type)
- local chaId = GetCharID(role)
- if file_exists(ampData.Conf['path']..chaId..'.txt') == true then
- local data = table.load(ampData.Conf['path']..chaId..'.txt', 'r')
- if data ~= nil then
- if data[type] ~= nil then
- return data[type].Time
- end
- end
- end
- return 0
- end
- function AmplifierADS(ignore, role)
- local chaId = GetCharID(role)
- if file_exists(ampData.Conf['path']..chaId..'.txt') == true then
- local data = table.load(ampData.Conf['path']..chaId..'.txt', 'r')
- if data ~= nil then
- if data['EXP'] ~= nil then
- if os.time() < data['EXP'].Time then
- local expTime = data['EXP'].Time - os.time()
- local expState = data['EXP'].Rate
- if ampData.Temp['EXP'] == nil then
- ampData.Temp['EXP'] = {}
- end
- if ampData.Temp['EXP'][chaId] == nil then
- local xpcycle = math.random(120, 240)
- ampData.Temp['EXP'][chaId] = xpcycle
- end
- if math.mod(now_tick, ampData.Temp['EXP'][chaId]) == 0 and now_tick > 0 then
- BickerNotice(role, 'Remaining '..(expState/2)..'x EXP: '..ToClockFormat(expTime)..'!')
- ampData.Temp['EXP'][chaId] = nil
- end
- end
- local expState = data['EXP'].Rate
- if os.time() >= data['EXP'].Time then
- if expState ~= 0 then
- BickerNotice(role, (expState/2)..'x EXP bonus has vanished...')
- data['EXP'] = nil
- table.save(data, ampData.Conf['path']..chaId..'.txt', 'w')
- end
- end
- end
- if data['DROP'] ~= nil then
- if os.time() < data['DROP'].Time then
- local dropTime = data['DROP'].Time - os.time()
- local dropState = data['DROP'].Rate
- if ampData.Temp['DROP'] == nil then
- ampData.Temp['DROP'] = {}
- end
- if ampData.Temp['DROP'][chaId] == nil then
- local mfcycle = math.random(120, 240)
- ampData.Temp['DROP'][chaId] = mfcycle
- end
- if math.mod(now_tick, ampData.Temp['DROP'][chaId]) == 0 and now_tick > 0 then
- BickerNotice(role, 'Remaining '..(dropState/2)..'x DROP: '..ToClockFormat(dropTime)..'!')
- ampData.Temp['DROP'][chaId] = nil
- end
- end
- local dropState = data['DROP'].Rate
- if os.time() >= data['DROP'].Time then
- if dropState ~= 0 then
- BickerNotice(role, (dropState/2)..'x DROP bonus has vanished...')
- data['DROP'] = nil
- table.save(data, ampData.Conf['path']..chaId..'.txt', 'w')
- end
- end
- end
- end
- end
- end
- function AmpDeathPunish(dead, atk)
- local chaId = GetCharID(atk)
- if file_exists(ampData.Conf['path']..chaId..'.txt') == true then
- local data = table.load(ampData.Conf['path']..chaId..'.txt', 'r')
- if data ~= nil then
- if data['EXP'] ~= nil then
- local expBonus = ampData.GetChaStateLv(dead, 'EXP')
- SystemNotice(dead, (expBonus/2)..'x EXP bonus has vanished...')
- data['EXP'] = nil
- end
- if data['DROP'] ~= nil then
- local dropBonus = ampData.GetChaStateLv(dead, 'DROP')
- SystemNotice(dead, (dropBonus/2)..'x DROP bonus has vanished...')
- data['DROP'] = nil
- end
- table.save(data, ampData.Conf['path']..chaId..'.txt', 'w')
- end
- end
- end
- function PKO_AMP_SYS(role, Item)
- local chaId = GetCharID(role)
- local chaLv = GetChaAttr(role, ATTR_LV)
- local ampId = GetItemID(Item)
- local ampName = GetItemName(ampId)
- ampData.CreateDB(ampData.Conf['path']..chaId..'.txt')
- local ampFruit = {
- -- EXP
- [0048] = { Bonus = {'EXP'} , Rate = 10 , MinLv = 00, MaxLv = 85 , Min = 02 }, --Hairy Crab
- [0056] = { Bonus = {'EXP'} , Rate = 40 , MinLv = 00, MaxLv = 85 , Min = 02 }, --Steamed Crab
- [0898] = { Bonus = {'EXP','DROP'} , Rate = 4 , MinLv = 30, MaxLv = lm , Min = 15 }, --Mystical Fruit
- [0993] = { Bonus = {'EXP'} , Rate = 20 , MinLv = 00, MaxLv = 48 , Min = 15 }, --Super Booster
- [0998] = { Bonus = {'EXP'} , Rate = 20 , MinLv = 65, MaxLv = 75 , Min = 30 }, --Thruster of Mystic
- [1128] = { Bonus = {'EXP'} , Rate = 04 , MinLv = 00, MaxLv = 40 , Min = 05 }, --Mini Amp
- [2586] = { Bonus = {'EXP'} , Rate = 07 , MinLv = 76, MaxLv = lm , Min = 30 }, --3.5X Amplifier of Strive
- [2587] = { Bonus = {'EXP'} , Rate = 08 , MinLv = 81, MaxLv = lm , Min = 30 }, --4X Amplifier of Strive
- [3039] = { Bonus = {'EXP'} , Rate = 10 , MinLv = 00, MaxLv = 70 , Min = 30 }, --Level pushing Machine
- [3094] = { Bonus = {'EXP'} , Rate = 04 , MinLv = 00, MaxLv = lm , Min = 30 }, --Amp of Strive
- [3095] = { Bonus = {'EXP'} , Rate = 05 , MinLv = 60, MaxLv = lm , Min = 30 }, --Hi-Amp of Strive
- [3844] = { Bonus = {'EXP'} , Rate = 04 , MinLv = 00, MaxLv = lm , Min = 15 }, --Heaven's Berry
- [3879] = { Bonus = {'EXP'} , Rate = 04 , MinLv = 40, MaxLv = lm , Min = 15 }, --Special Mystic Fruit
- [3880] = { Bonus = {'EXP'} , Rate = 05 , MinLv = 60, MaxLv = lm , Min = 15 }, --Super Mystic Fruit
- [5616] = { Bonus = {'EXP'} , Rate = 20 , MinLv = 00, MaxLv = 49 , Min = 15 }, --Novice 10X Exp Fruit
- [5617] = { Bonus = {'EXP'} , Rate = 10 , MinLv = 00, MaxLv = 70 , Min = 30 }, --5X Exp Fruit
- [5638] = { Bonus = {'EXP'} , Rate = 04 , MinLv = 00, MaxLv = 40 , Min = 60+5*(chaLv-1) }, --Novice 2X Exp Fruit
- [5639] = { Bonus = {'EXP'} , Rate = 06 , MinLv = 50, MaxLv = lm , Min = 30 }, --3x Exp Fruit
- [5694] = { Bonus = {'EXP'} , Rate = 07 , MinLv = 75, MaxLv = lm , Min = 30 }, --3.5x EXP Amp
- [5695] = { Bonus = {'EXP'} , Rate = 08 , MinLv = 80, MaxLv = lm , Min = 30 }, --4X EXP Amp
- [5767] = { Bonus = {'EXP'} , Rate = 06 , MinLv = 70, MaxLv = lm , Min = 30 }, --3X EXP Amp
- [5894] = { Bonus = {'EXP'} , Rate = 04 , MinLv = 00, MaxLv = 45 , Min = 30 }, --Enhanced Newbie Leveling Fruit
- [6017] = { Bonus = {'EXP'} , Rate = 04 , MinLv = 00, MaxLv = lm , Min = 30 }, --Fine 2x Exp Fruit
- [6405] = { Bonus = {'EXP'} , Rate = 04 , MinLv = 00, MaxLv = 40 , Min = 60+5*(chaLv-1) }, --Magic Lucky Fruit
- [6406] = { Bonus = {'EXP'} , Rate = 10 , MinLv = 50, MaxLv = 75 , Min = 30 }, --Magic Blessing Fruit
- [7451] = { Bonus = {'EXP'} , Rate = 06 , MinLv = 50, MaxLv = lm , Min = 30 }, --3X EXP Fruit
- [8330] = { Bonus = {'EXP'} , Rate = 06 , MinLv = 50, MaxLv = lm , Min = 30 }, --3x Exp Fruit
- -- DROP
- [1006] = { Bonus = {'DROP'} , Rate = 04 , MinLv = 00, MaxLv = lm , Min = 15 }, --Loveless Tear
- [3096] = { Bonus = {'DROP'} , Rate = 04 , MinLv = 00, MaxLv = lm , Min = 30 }, --Amp of Luck
- [3097] = { Bonus = {'DROP'} , Rate = 06 , MinLv = 60, MaxLv = lm , Min = 30 }, --Hi-Amp of Luck
- [3845] = { Bonus = {'DROP'} , Rate = 04 , MinLv = 00, MaxLv = lm , Min = 15 }, --Charmed Berry
- [3881] = { Bonus = {'DROP'} , Rate = 05 , MinLv = 40, MaxLv = lm , Min = 15 }, --Special Luck Fruit
- [3882] = { Bonus = {'DROP'} , Rate = 06 , MinLv = 60, MaxLv = lm , Min = 15 }, --Super Luck Fruit
- [5640] = { Bonus = {'DROP'} , Rate = 06 , MinLv = 60, MaxLv = lm , Min = 30 }, --3x Drop Fruit
- [6018] = { Bonus = {'DROP'} , Rate = 04 , MinLv = 00, MaxLv = lm , Min = 30 }, --Fine 2x Drop Fruit
- [8331] = { Bonus = {'DROP'} , Rate = 06 , MinLv = 60, MaxLv = lm , Min = 30 } --3x Drop Fruit
- }
- local data = table.load(ampData.Conf['path']..chaId..'.txt', 'r')
- if ampFruit[ampId] == nil then
- SystemNotice(role, ampName..': is not registered!')
- UseItemFailed(role)
- return
- end
- if chaLv < ampFruit[ampId].MinLv then
- SystemNotice(role, ampName.. ': for Lv'..ampFruit[ampId].MinLv..' and above!')
- UseItemFailed(role)
- return
- end
- if chaLv > ampFruit[ampId].MaxLv then
- SystemNotice(role, ampName.. ': for Lv'..ampFruit[ampId].MaxLv..' and below!')
- UseItemFailed(role)
- return
- end
- local duration = ampFruit[ampId].Min * 60
- local stateSec = os.time() + duration
- if data == nil then
- data = {}
- table.save(data, ampData.Conf['path']..chaId..'.txt', 'w')
- end
- local Boat = 0
- Boat = GetCtrlBoat(role)
- for k,v in pairs(ampFruit[ampId].Bonus) do
- if Boat == nil then
- local ampBonus = ampFruit[ampId].Bonus[k]
- local ampState = ampFruit[ampId].Rate
- local chastateLv = ampData.GetChaStateLv(role, ampBonus)
- if chastateLv > ampState then
- SystemNotice(role, 'Better or same fruit in effect. Please use again later...')
- UseItemFailed(role)
- return
- end
- if chastateLv == ampState then
- local stateTime = data[ampBonus].Time - os.time()
- BickerNotice(role, 'Better fruit still in effect for '..ToClockFormat(stateTime)..'!')
- UseItemFailed(role)
- return
- end
- data[v] = {Time = stateSec , Rate = ampState}
- SystemNotice(role, 'Feels the effect of '..ampName..'. Granted '..(ampState/2)..'x times of '..ampBonus..' for duration '..ToClockFormat(duration)..'!')
- else
- local ampBonus = ampFruit[ampId].Bonus[k]
- local ampState = ampFruit[ampId].Rate
- local chastateLv = ampData.GetChaStateLv(role, ampBonus)
- if chastateLv > ampState then
- SystemNotice(Boat, 'Better or same fruit in effect. Please use again later...')
- UseItemFailed(Boat)
- return
- end
- if chastateLv == ampState then
- local stateTime = data[ampBonus].Time - os.time()
- BickerNotice(Boat, 'Better fruit still in effect for '..ToClockFormat(stateTime)..'!')
- UseItemFailed(Boat)
- return
- end
- data[v] = {Time = stateSec , Rate = ampState}
- SystemNotice(Boat, 'Feels the effect of '..ampName..'. Granted '..(ampState/2)..'x times of '..ampBonus..' for duration '..ToClockFormat(duration)..'!')
- end
- end
- table.save(data, ampData.Conf['path']..chaId..'.txt', 'w')
- end
- Hook:AddPostHook('player_timer', AmplifierADS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement