123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026 |
- ---@class PrivilegeCardManager
- PrivilegeCardManager = {}
- local this = PrivilegeCardManager
- function this.Init()
- this.RegistEvents()
- this.all_info = {}
- this.auto_buy_drug = 0
- local cfg = SL:GetConfigTable('cfg_free_buff')
- local one_num = 1
- if cfg then
- for k, v in pairs(cfg) do
- if v.autoPick then
- one_num = v.autoPick[1]
- break
- end
- end
- end
- SL:StartFastPickUp(3,1,50)
- -- ---@type cfg_privilege_column
- -- this.goldCfg = SL:GetConfig("cfg_privilege", 1)
- -- ---@type cfg_privilege_column
- -- this.diamondCfg = SL:GetConfig("cfg_privilege", 2)
- this.goldPrivilege = false
- this.diamondPrivilege = false
- this.all_pricilege_id = {}
- this.message = {}
- end
- function this.RegistEvents()
- SL:RegisterLUAEvent(LUA_EVENT_LOGIN_MAP, this.LoginReq)
- SL:RegisterLUAEvent(LUA_EVENT_ONHOOK_STATE_CHANGE,this.LUA_EVENT_ONHOOK_STATE_CHANGE)
- SL:RegisterLUAEvent(LUA_EVENT_DROPITEM_OUT_OF_VIEW,this.LUA_EVENT_DROPITEM_OUT_OF_VIEW)
- SL:RegisterLUAEvent(LUA_EVENT_MAIN_PLAYER_REVIVE,this.LUA_EVENT_MAIN_PLAYER_REVIVE)
- SL:RegisterLUAEvent(LUA_EVENT_PICK_UP_SETTING_CHANGE,this.LUA_EVENT_PICK_UP_SETTING_CHANGE)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.SET_AUTO_BUY_POTION_RESULT,this.ResSetAutoBuy)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.CURRENT_AUTO_BUY_POTION_RESULT,this.AutoBuyStatus)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_PRIVILEGE_RESULT,this.ResAllPrivilegeCardInfo)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.PRIVILEGE_INFO_TIP,this.ResCardChange)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_GET_MONTH_PRIVILEGE_DATA,this.RES_GET_MONTH_PRIVILEGE_DATA)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_PRIVILEGE_CARD_ACTIVATION,this.RES_PRIVILEGE_CARD_ACTIVATION)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_GET_ROLE_ATTR_POINT_PROGRAMME, this.RES_GET_ROLE_ATTR_POINT_PROGRAMME)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_CHANGE_ROLE_ATTR_POINT_PROGRAMME, this.RES_CHANGE_ROLE_ATTR_POINT_PROGRAMME)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_MONTH_PRIVILEGE_TIME_OUT, this.RES_MONTH_PRIVILEGE_TIME_OUT)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.TRIPLE_INCOME_INFO, this.TRIPLE_INCOME_INFO)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_PRIVILEGE_MONTH_BUBBLE_DATA, this.RES_PRIVILEGE_MONTH_BUBBLE_DATA)
- SL:RegisterLuaNetMsg(MessageDef.ResMonsterStatusChangeMessage, this.ResMonsterStatusChangeMessage)
- end
- function this.Update()
- ---特权巡逻挂机,击杀黄金boss后捡完装备,去下一家
- if this.checkHaveDrop then
- local data = SL:GetMetaValue(EMetaVarGetKey.GET_MONSTER_DROP_ITEM_LIST)
- if type(data) == "table" and next(data) then
- this.checkHaveDrop = false
- this.LUA_EVENT_DROPITEM_OUT_OF_VIEW()
- else
- this.checkHaveDrop = false
- this:GetThisMapGoldBossAttack()
- end
- end
- if this.is_wait_req then
- if this.check_req_time + 100 < Time.GetServerTime() then
- local panel = GUI:GetUI("dev/ui/MainUI/Panel/KLUIPlayerInfo/KLUIPlayerInfoPanel")
- if panel then
- this.is_wait_req = false
- this.REQ_GET_MONTH_PRIVILEGE_DATA()
- end
- end
- end
- end
- function this.UnRegistEvents()
- SL:UnRegisterLUAEvent(LUA_EVENT_LOGIN_MAP,this.LoginReq)
- end
- function this.Reset()
- if this.scheduleId then
- SL:UnSchedule(this.scheduleId)
- this.scheduleId = nil
- end
- this.UnRegistEvents()
- end
- function this:LoginReq()
- this.all_info = {}
- this.pickupType = {}
- this.hideDiamondPopover = false
- this.hideGoldPopover = false
- this.startFindWay = false
- this.finishFindWay = false
- this.onHookType = EOnHookType.Situ
- this.goldPrivilegeStopTime = nil
- this.diamondPrivilegeStopTime = nil
- --this.ReqPrivilegeCardAllInfo()
- local panel = GUI:GetUI("dev/ui/MainUI/Panel/KLUIPlayerInfo/KLUIPlayerInfoPanel")
- if panel then
- this.is_wait_req = false
- this.REQ_GET_MONTH_PRIVILEGE_DATA()
- else
- this.is_wait_req = true
- this.check_req_time = Time.GetServerTime()
- end
- --特权功能请求买药状态
- --this.ReqAutoBuyStatus()
- end
- ---请求设置自动吃药
- function this.ReqAutoBuyDrug()
- SL:SendLuaNetMsg(LuaMessageIdToSever.OPEN_OR_CLOSE_AUTO_BUY_POTION, {})
- end
- ---请求设置自动吃药回包
- function this.ResSetAutoBuy(_id,message)
- --SL:LogError("ResSetAutoBuy")
- this.auto_buy_drug = message.isOn
- SL:onLUAEvent(LUA_EVENT_AUTO_BUY_POTION_RESULT, {})
- end
- --获得当前自动购买药水状态
- function this.ReqAutoBuyStatus()
- SL:SendLuaNetMsg(LuaMessageIdToSever.GET_CURRENT_AUTO_BUY_POTION, {})
- end
- --获得当前自动购买药水状态回包
- function this.AutoBuyStatus(_id,message)
- --SL:LogError(message.isOn)
- this.auto_buy_drug = message.isOn
- if this.AutoBuyIsOpen() then
- if not this.isautoPotion() then
- this.ReqAutoBuyDrug()
- end
- end
- end
- function this.AutoBuyIsOpen()
- if this.auto_buy_drug and this.auto_buy_drug == 1 then
- return true
- end
- return false
- end
- ---获取已有的特权信息
- function this.ReqPrivilegeCardAllInfo()
- SL:SendLuaNetMsg(LuaMessageIdToSever.GET_PRIVILEGES, {})
- end
- function this.LUA_EVENT_MAIN_PLAYER_REVIVE()
- this.REQ_GET_MONTH_PRIVILEGE_DATA()
- end
- function this:LUA_EVENT_PICK_UP_SETTING_CHANGE()
- this.pickupType = SL:GetMetaValue(EMetaVarGetKey.GET_ATUO_PICKUP_ITEM)
- end
- ---获取已有的特权信息
- function this.REQ_GET_MONTH_PRIVILEGE_DATA()
- SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_GET_MONTH_PRIVILEGE_DATA, {})
- end
- ---获取特权项结果
- function this.ResAllPrivilegeCardInfo(_id,message)
- --SL:LogError(message)
- this.all_info = message
- this.ReqAutoBuyStatus()
- this.UpdateData()
- end
- function this.ResCardChange(_id,message)
- if message.withstore then
- this.all_info.withstore = "0"
- end
- if message.withwarehouse then
- this.all_info.withwarehouse = "0"
- end
- if message.autopotion then
- this.all_info.autopotion = "0"
- end
- if message.autorecovery then
- this.all_info.autorecovery = "0"
- end
- if message.autopick then
- this.all_info.autopick = "0"
- end
- this.ReqAutoBuyStatus()
- this.UpdateData()
- end
- -- ---@param message table<number,PrivilegeTypeData>
- -- ---@class PrivilegeTypeData
- -- ---@field id number
- -- ---@field start_time number
- -- ---@field durationtime number 持续时长 单位小时
- -- ---@field timerid number
- -- function this.RES_GET_MONTH_PRIVILEGE_DATA(_, message)
- -- SL:LogTable(message,true)
- -- --判断激活特权特殊展示
- -- local showType = 0
- -- if message then
- -- for i, v in pairs(message) do
- -- if v.id == 1 and not this.goldPrivilege then
- -- --新激活黄金特权开启自动买药
- -- this.ReqAutoBuyDrug()
- -- showType = 1
- -- end
- -- if v.id == 2 and not this.diamondPrivilege then
- -- showType = 2
- -- end
- -- end
- -- end
- -- --刷新特权信息
- -- this.goldPrivilege = false
- -- this.goldServerInfo = nil
- -- this.diamondPrivilege = false
- -- this.diamondServerInfo = nil
- -- if message then
- -- for _, v in pairs(message) do
- -- if v.id == 1 then
- -- local time = v.start_time + v.durationtime * 3600000
- -- if time > Time.GetServerTime() then
- -- this.goldPrivilege = true
- -- this.goldServerInfo = v
- -- this.goldServerInfo["stop_time"] = time
- -- end
- -- end
-
- -- if v.id == 2 then
- -- local time = v.start_time + v.durationtime * 3600000
- -- if time > Time.GetServerTime() then
- -- this.diamondPrivilege = true
- -- this.diamondServerInfo = v
- -- this.diamondServerInfo["stop_time"] = time
- -- end
- -- end
- -- end
- -- end
- -- SL:onLUAEvent(LUA_EVENT_PRIVILEGE_INFO_CHANGE, showType)
- -- this.CheckPriviegeBoss()
- -- end
- ---@param message table<number,PrivilegeTypeData>
- ---@class PrivilegeTypeData
- ---@field id number
- ---@field start_time number
- ---@field durationtime number 持续时长 单位小时
- ---@field timerid number
- function this.RES_GET_MONTH_PRIVILEGE_DATA(_, message)
- --SL:LogTable(message,true)
- --判断激活特权特殊展示
- local is_drug = false
- local is_pick_up = false
- local is_recovery = false
-
- --刷新特权信息
- this.goldPrivilege = false
- this.goldServerInfo = nil
- this.diamondPrivilege = false
- this.diamondServerInfo = nil
- this.message = message
- this.all_pricilege_id = {}
- if message then
- for _, v in pairs(message) do
- local time = v.start_time + v.durationtime * 3600000
- if time > Time.GetServerTime() or v.durationtime == -1 then
- local tab = SL:GetConfig("cfg_privilege",v.id)
- local PrivilegelList = tab.PrivilegelList
- for ii, one_id in ipairs(PrivilegelList) do
- if not table.contains(this.all_pricilege_id,one_id) then
- table.insert(this.all_pricilege_id,one_id)
- end
- end
- local myId = SL:GetMetaValue("MAIN_ACTOR_ID")
- local buff_id = tab.buff
- local _buffText = SL:GetConfig("cfg_buff",buff_id).buffText
- --local buffChangeData = {{cfgId = 30000001,endTime = time}}
- if v.durationtime == -1 then
- time = v.durationtime
- end
- local fuffData = {updateType=0,buff={buffTbl={showIcon="aa"},cfgId=buff_id,endTime=time,buffText=_buffText},roleId=myId}
- --SL:LogTable(fuffData,true)
- SL:onLUAEvent(LUA_EVENT_BUFFCHANHE, fuffData)
- end
- end
- end
- if not this.isautoPick() then
- local is_open = SL:GetPlayerAutoPickIsOpen()
- if is_open then
- --去掉勾选自动范围拾取
- SL:SetPlayerAutoPick(false)
- SL:SendPlayerAutoPickChange(false)
- end
- end
- if not this.isautoRecovery() then
- --去掉勾选自动回收
- SL:SendPlayerAutoRecoverChange(false)
- end
- --SL:LogTable(this.all_pricilege_id,true)
- this.CheckPriviegeBoss()
- this.ReqAutoBuyStatus()
- end
- function this.RES_PRIVILEGE_CARD_ACTIVATION(_, message)
- if message then
- local id = tonumber(message)
- local PrivilegelList = SL:GetConfig("cfg_privilege",id).PrivilegelList
- if table.contains(PrivilegelList,6) and not not table.contains(this.all_pricilege_id,6) then
- --新激特权开启自动买药
- if not this.AutoBuyIsOpen() then
- this.ReqAutoBuyDrug()
- end
- end
- if table.contains(PrivilegelList,16) and not not table.contains(this.all_pricilege_id,16) then
- --新激活特权开启自动范围拾取
- local is_open = SL:GetPlayerAutoPickIsOpen()
- if not is_open then
- ---设置一下数据
- SL:SetPlayerAutoPick(true)
- ---发给服务器
- SL:SendPlayerAutoPickChange(true)
- end
- end
- if table.contains(PrivilegelList,17) and not not table.contains(this.all_pricilege_id,17) then
- --新激活特权开启自动回收
- local is_open = SL:GetPlayerAutoRecoverIsOpen()
- if not is_open then
- ---发给服务器
- SL:SendPlayerAutoRecoverChange(true)
- end
-
- end
- end
- end
- function this.HavePriviege()
- if this.all_pricilege_id and #this.all_pricilege_id > 0 then
- return true
- end
- return false
- end
- ---@class freeSwitchAttrPointData
- ---@field id number
- ---@field attr table
- ---@field name string
- ---@param message RoleAttrProgrammeData
- ---@class RoleAttrProgrammeData
- ---@field current number 当前方案
- ---@field FreeSwitchAttrPointData table<number,freeSwitchAttrPointData>
- function this.RES_GET_ROLE_ATTR_POINT_PROGRAMME(_, message)
- if message then
- this.currentAttrType = message.current or 1
- this.freeFirstSwitchInfo = message.freeSwitchAttrPointData and message.freeSwitchAttrPointData["1"] or nil
- this.freeSecondSwitchInfo = message.freeSwitchAttrPointData and message.freeSwitchAttrPointData["2"] or nil
- else
- this.currentAttrType = 1
- this.freeFirstSwitchInfo = nil
- this.freeSecondSwitchInfo = nil
- end
- end
- function this.RES_CHANGE_ROLE_ATTR_POINT_PROGRAMME(_, message)
- this.currentAttrType = message
- end
- ---特权到期
- -- function this.RES_MONTH_PRIVILEGE_TIME_OUT(_, message)
- -- if message then
- -- if message == 1 then
- -- this.goldPrivilege = false
- -- this.goldServerInfo = nil
- -- else
- -- this.diamondPrivilege = false
- -- this.diamondServerInfo = nil
- -- end
- -- end
- -- SL:onLUAEvent(LUA_EVENT_PRIVILEGE_INFO_CHANGE)
- -- end
- function this.RES_MONTH_PRIVILEGE_TIME_OUT(_, message)
- if message then
- if not this.message[tostring(message)] then
- return
- end
- local data = this.message[tostring(message)]
- local tab = SL:GetConfig("cfg_privilege",data.id)
- local time = data.start_time + data.durationtime * 3600000
- local myId = SL:GetMetaValue("MAIN_ACTOR_ID")
- local buff_id = tab.buff
- local _buffText = SL:GetConfig("cfg_buff",buff_id).buffText
- local fuffData = {updateType=1,buff={buffTbl={showIcon="aa"},cfgId=buff_id,endTime=time,buffText=_buffText},roleId=myId}
- SL:onLUAEvent(LUA_EVENT_BUFFCHANHE, fuffData)
- this.message[tostring(message)] = nil
- this.all_pricilege_id = {}
- if this.message then
- for _, v in pairs(this.message) do
- local time = v.start_time + v.durationtime * 3600000
- if time > Time.GetServerTime() then
- local PrivilegelList = SL:GetConfig("cfg_privilege",v.id).PrivilegelList
- for ii, one_id in ipairs(PrivilegelList) do
- if not table.contains(this.all_pricilege_id,one_id) then
- table.insert(this.all_pricilege_id,one_id)
- end
- end
- end
- end
- end
- end
- if not this.isautoPick() then
- local is_open = SL:GetPlayerAutoPickIsOpen()
- if is_open then
- --去掉勾选自动范围拾取
- SL:SetPlayerAutoPick(false)
- SL:SendPlayerAutoPickChange(false)
- end
- end
- if not this.isautoRecovery() then
- --去掉勾选自动回收
- SL:SendPlayerAutoRecoverChange(false)
- end
- this.ReqAutoBuyStatus()
- SL:onLUAEvent(LUA_EVENT_PRIVILEGE_INFO_CHANGE)
- end
- function this.TRIPLE_INCOME_INFO(_, message)
- if this.scheduleId then
- SL:UnSchedule(this.scheduleId)
- this.scheduleId = nil
- end
- if message then
- this.tripleEarningsInfo = message
- if this.tripleEarningsInfo.effectSec > 0 then
- this.scheduleId = SL:ScheduleOnce(this.tripleEarningsInfo.effectSec, function()
- SL:SendLuaNetMsg(LuaMessageIdToSever.TRIPLE_INCOME_PANEL)
- end)
- end
- end
- SL:onLUAEvent(LUA_EVENT_PRIVILEGE_INFO_CHANGE)
- end
- function this.RES_PRIVILEGE_MONTH_BUBBLE_DATA(_, message)
- for i, v in pairs(message) do
- if i == "1" then
- this.goldPrivilegeStopTime = v
- elseif i == "2" then
- this.diamondPrivilegeStopTime = v
- end
- end
- end
- function this.SetHideGoldPopover(state)
- this.hideGoldPopover = state
- end
- function this.SetHideDiamondPopover(state)
- this.hideDiamondPopover = state
- end
- function this.GetGoldPrivilegePopoverState()
- if this.hideGoldPopover then
- return false
- end
- if this.goldPrivilege then
- local gold_stop_time = SL:GetConfig("cfg_global", 14001).value
- local remind_time = this.goldServerInfo.stop_time - Time.GetServerTime()
- if remind_time < gold_stop_time * 3600000 then
- return true
- end
- else
- local gold_stop_day = SL:GetConfig("cfg_global", 14002).value
- if this.goldPrivilegeStopTime then
- local gold_stop_time = Time.GetServerTime() - this.goldPrivilegeStopTime
- if gold_stop_time < gold_stop_day * 3600000 then
- return true
- end
- end
- end
- return false
- end
- function this.GetDiamondPrivilegePopoverState()
- if this.hideDiamondPopover then
- return false
- end
- if this.diamondPrivilege then
- local diamond_stop_time = SL:GetConfig("cfg_global", 14001).value
- local remind_time = this.diamondServerInfo.stop_time - Time.GetServerTime()
- if remind_time < diamond_stop_time * 3600000 then
- return true
- end
- else
- local diamond_stop_day = SL:GetConfig("cfg_global", 14002).value
- if this.diamondPrivilegeStopTime then
- local diamond_stop_time = Time.GetServerTime() - this.diamondPrivilegeStopTime
- if diamond_stop_time < diamond_stop_day * 3600000 then
- return true
- end
- end
- end
- return false
- end
- function this.GetCurrentAttrPointPlan()
- if this.currentAttrType == 1 then
- return this.freeFirstSwitchInfo and this.freeFirstSwitchInfo.attr or nil
- else
- return this.freeSecondSwitchInfo and this.freeSecondSwitchInfo.attr or nil
- end
- end
- ---返回毫秒值
- function this.GetPrivilegeRemainTime(type)
- if type == 1 then
- if this.goldPrivilege then
- local totalTime = this.goldServerInfo.start_time + this.goldServerInfo.durationtime * 3600000
- local now = Time.GetServerTime()
- return totalTime - now
- else
- return 0
- end
- elseif type == 2 then
- if this.diamondPrivilege then
- local totalTime = this.diamondServerInfo.start_time + this.diamondServerInfo.durationtime * 3600000
- local now = Time.GetServerTime()
- return totalTime - now
- else
- return 0
- end
- end
- end
- function this.SendMessageSetFreeAttrInfo(id, attr, name)
- local info
- if not id then
- id = this.currentAttrType
- end
- if id == 1 then
- info = this.freeFirstSwitchInfo or {}
- else
- info = this.freeSecondSwitchInfo or {}
- end
- local message = {}
- message["id"] = id
- if attr then
- message["attr"] = attr
- else
- message["attr"] = info.attr or {}
- end
- if name then
- message["name"] = name
- else
- message["name"] = info.name
- end
- SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_SET_ROLE_ATTR_POINT_PROGRAMME, message)
- end
- function this.ClearPrivilegeCardAllInfo()
- this.all_info = {}
- this.auto_buy_drug = 0
- end
- ---刷新特权的时候如果某个特权没了,要把勾选取消掉
- function this.UpdateData()
- if not this.isautoPick() then
- --自动拾取勾选修改
- SL:SetPlayerAutoPick(false)
- SL:SendPlayerAutoPickChange(false)
- end
- if not this.isautoRecovery() then
- --修改回收
- SL:SendPlayerAutoRecoverChange(false)
- end
- if this.isautoPick() then
- local strList = string.split(this.all_info.autopick,'#')
- local num = tonumber(strList[1])
- local speed = tonumber(strList[2])
- SL:StartFastPickUp(num,1,30*speed)
- end
- end
- -- function this.SendMU()
- -- SL:SendLuaNetMsg(LuaMessageIdToSever.RECRUIT_INFO_REQ, {id=10002})
- -- end
- ---是否拥有开启随身商店特权
- function this.iswithStore()
- --if this.all_info.withstore and this.all_info.withstore ~= "" and this.all_info.withstore ~= "0" then
- -- return true
- --end
- --return false
- --return this.goldPrivilege
- if not this.all_pricilege_id then
- return false
- end
- return table.contains(this.all_pricilege_id,2)
- end
- ---是否拥有开启随身仓库特权
- function this.iswithWarehouse()
- --if this.all_info.withwarehouse and this.all_info.withwarehouse ~= "" and this.all_info.withwarehouse ~= "0" then
- -- return true
- --end
- --return false
- --return this.diamondPrivilege
- if not this.all_pricilege_id then
- return false
- end
- return table.contains(this.all_pricilege_id,13)
- end
- ---是否拥有开启自动买药特权
- function this.isautoPotion()
- --if this.all_info.autopotion and this.all_info.autopotion ~= "" and this.all_info.autopotion ~= "0" then
- -- return true
- --end
- --return false
- --return this.goldPrivilege
- if not this.all_pricilege_id then
- return false
- end
- return table.contains(this.all_pricilege_id,6)
- end
- ---是否拥有开启自动回收特权
- function this.isautoRecovery()
- -- if this.all_info.autorecovery and this.all_info.autorecovery ~= "" and this.all_info.autorecovery ~= "0" then
- -- return true
- -- end
- -- return false
- if not this.all_pricilege_id then
- return false
- end
- return table.contains(this.all_pricilege_id,17)
- end
- ---是否拥有开启自动拾取
- function this.isautoPick()
- -- if this.all_info.autopick and this.all_info.autopick ~= "" and this.all_info.autopick ~= "0" then
- -- return true
- -- end
- -- return false
- if not this.all_pricilege_id then
- return false
- end
- return table.contains(this.all_pricilege_id,16)
- end
- ---是否拥有交易行寄售特权
- function this.isSalesAdd()
- if not this.all_pricilege_id then
- return false
- end
- return table.contains(this.all_pricilege_id,19)
- end
- ---是否拥有扫荡特权
- function this.isSaoDangOpen()
- if not this.all_pricilege_id then
- return false
- end
- return table.contains(this.all_pricilege_id,20)
- end
- function this.FreeSwitchAttrPoint()
- return this.goldPrivilege
- end
- ---获取激活特权需要展示的背包行数
- function this.GetBagCanShowRow(row)
- -- row = row or 0
- -- local lockRow = this.GetLockGridRowWithoutPrivilege()
- -- local increaseRow, gridNum = this.GetBagIncreaseRowCount()
- -- if gridNum == this.goldCfg.backpackUp + this.diamondCfg.backpackUp then
- -- return increaseRow, 0
- -- else
- -- ---获取背包道具最大占用格子数
- -- local maxItemRow = 0
- -- local bagItemList = SL:GetMetaValue("BAG_DATA")[1]
- -- for i, v in pairs(bagItemList) do
- -- local holdGrid = SL:GetConfig("cfg_item", v.cfgId).holdGrid
- -- local itemRow = holdGrid[2] + math.modf(i / 100) - 1
- -- if itemRow > maxItemRow then
- -- maxItemRow = itemRow
- -- end
- -- end
- -- if maxItemRow > increaseRow + row - lockRow then
- -- return maxItemRow - row + lockRow, maxItemRow - increaseRow - row + lockRow
- -- else
- -- return increaseRow, 0
- -- end
- -- end
- end
- function this.GetLockGridRowWithoutPrivilege()
- local lockGrid = SL:GetMetaValue("BAG_FORBID_COUNT")
- local privilegeGrid = this.GetBagSiftLockGridNum()
- local num = (lockGrid - privilegeGrid) / 8
- if num > 0 then
- ---有非特权格子未解锁
- return math.floor(num)
- end
- ---非特权格子全解锁
- return 0
- end
- ---返回未解锁特权需要隐藏的格子数
- function this.GetBagSiftLockGridNum()
- --local num = 0
- --if not this.goldPrivilege then
- -- num = num + this.goldCfg.backpackUp
- --end
- --if not this.diamondPrivilege then
- -- num = num + this.diamondCfg.backpackUp
- --end
- --return num
- return 0
- end
- ---返回未开启特权减少的背包行数
- function this.GetBagIncreaseRowCount()
- local bag_info = string.split(SL:GetConfig("cfg_global", 6).value, '#')
- local maxVet = tonumber(bag_info[2])
- local num = 0
- local girdNum = 0
- if this.goldPrivilege then
- num = num + this.goldCfg.backpackUp / maxVet
- girdNum = girdNum + this.goldCfg.backpackUp
- end
- if this.diamondPrivilege then
- num = num + this.diamondCfg.backpackUp / maxVet
- girdNum = girdNum + this.diamondCfg.backpackUp
- end
- return math.floor(num), girdNum
- end
- ---返回特权增加特权仓库页数
- function this.GetDepotUp()
- local num = 0
- if this.goldPrivilege then
- num = num + #this.goldCfg.DepotUp
- end
- if this.diamondPrivilege then
- num = num + #this.diamondCfg.DepotUp
- end
- return num
- end
- ---返回交易行增加数量
- function this.GetTradingShelvesUp()
- local num = 0
- if this.goldPrivilege then
- num = num + this.goldCfg.TradingGhelvesUp
- end
- if this.diamondPrivilege then
- num = num + this.diamondCfg.TradingGhelvesUp
- end
- return num
- end
- ---返回经验提升
- function this.GetExperienceUp()
- local num = 0
- if this.goldPrivilege then
- num = this.goldCfg.ExperienceUp
- end
- if this.diamondPrivilege then
- num = this.diamondCfg.ExperienceUp
- end
- return num
- end
- ---返回掉落提升
- function this.GetDropsUp()
- local num = 0
- if this.goldPrivilege then
- num = num + (this.goldCfg.DropsUp[2] / 100)
- end
- if this.diamondPrivilege then
- num = num + (this.diamondCfg.DropsUp[2] / 100)
- end
- return num
- end
- ---返回回收收益提升
- function this.GetReclaimUp()
- local num = 0
- if this.goldPrivilege then
- num = num + this.goldCfg.reclaimUp
- end
- if this.diamondPrivilege then
- num = num + this.diamondCfg.reclaimUp
- end
- return num
- end
- function this.GetFreeSwitchAttrPoint()
- --return this.goldPrivilege
- if not this.all_pricilege_id then
- return false
- end
- return table.contains(this.all_pricilege_id,7)
- end
- function this.CheckPriviegeBoss()
- if this.goldPrivilege then
- this.SendPriviegeBoss(1)
- end
- if this.diamondPrivilege then
- this.SendPriviegeBoss(2)
- end
- end
- ---通知特权boss
- ---@param value 活动类型 1—黄金特权卡 2—钻石特权卡 3—月卡 4-日卡
- function this.SendPriviegeBoss(value)
- SL:SendLuaNetMsg(LuaMessageIdToSever.PRIVILEGE_BOSS_COUNT_INIT,value)
- end
- function this.isAutoPatrolOnHook()
- --return this.diamondPrivilege
- if not this.all_pricilege_id then
- return false
- end
- return table.contains(this.all_pricilege_id,12)
- end
- ---@param state number @1.挂机中, 2.暂停挂机, 3.停止挂机
- function this.LUA_EVENT_ONHOOK_STATE_CHANGE(_, state)
- if this.onHookType == EOnHookType.Patrol then
- if state == EAutoOnHookStatus.OnHooking then
- this.patrolOnHookState = true
- elseif state == EAutoOnHookStatus.PauseOnHook then
- if this.startFindWay then
- this.patrolOnHookState = false
- this.startFindWay = false
- end
- if this.finishFindWay then
- this.finishFindWay = false
- this.patrolOnHookState = false
- end
- elseif state == EAutoOnHookStatus.StopOnHook then
- if this.startFindWay then
- this.patrolOnHookState = false
- this.startFindWay = false
- end
- if this.finishFindWay then
- this.finishFindWay = false
- this.patrolOnHookState = false
- end
- end
- end
- end
- ---道具是否捡完可以继续巡逻
- function this.LUA_EVENT_DROPITEM_OUT_OF_VIEW()
- if this.patrolOnHookState then
- local bagFull = false
- local data = SL:GetMetaValue(EMetaVarGetKey.GET_MONSTER_DROP_ITEM_LIST)
- for i, v in pairs(data) do
- if v.isMeCanPickUp then
- ---勾选自动拾取组才进行判断
- if this.pickupType and this.pickupType[v.tbl.pickgroup[1]] then
- if SL:CanPutToBag(v.tbl.id, 1) then
- return false
- else
- bagFull = true
- end
- end
- end
- end
- if bagFull then
- SL:TipMessage(SL:GetConfig('cfg_string',30001).text,1, NoticeType.NoticeMid)
- ---@type KLUISystemLeftPanel
- local ui = GUI:GetUI("dev/ui/MainUI/Panel/KLUISystemLeft/KLUISystemLeftPanel")
- if ui then
- ui:OnClickAutoHookIconContainerBtn_2()
- end
- else
- this:GetThisMapGoldBossAttack()
- end
- end
- end
- function this.ResMonsterStatusChangeMessage(_, message)
- if this.patrolOnHookState then
- if message.monsterId == this.attackGoldBossId and message.status == 0 then
- ---把掉落物刷新出来
- SL:ScheduleOnce(1, function()
- this.checkHaveDrop = true
- end)
- elseif this.readyFindMonster then
- if message.status == 1 and this.allGoldMonsterTbl[message.configId] then
- ---等待1秒让怪物数据后台更新
- SL:ScheduleOnce(1, function()
- this:GetThisMapGoldBossAttack()
- end)
- end
- end
- end
- end
- function this:RefreshPatrolHookState(state)
- if state then
- this:GetThisMapGoldBossList()
- end
- end
- ---缓存所有黄金boss
- function this:GetAllMapGoldBossList()
- this.allGoldMonsterTbl = {}
- ---@type cfg_monster_column[]
- local cfg_monster = SL:GetConfigTable("cfg_monster")
- for i, v in pairs(cfg_monster) do
- if v.type == 2 then
- this.allGoldMonsterTbl[v.id] = v
- end
- end
- end
- function this.IsCanOnHookCheck()
- if SL:GetMetaValue(EMetaVarGetKey.GET_IS_SAFEAREA) then
- --SL:TipMessage(EAutoFightErrorTip.SafeArea, 1, NoticeType.NoticeMid)
- return false
- else
- return true
- end
- end
- ---开始巡逻挂机
- function this.StartPatrolOnHook()
- this.patrolOnHookState = false
- ---是否安全区等检测
- if this.IsCanOnHookCheck() then
- this.patrolOnHookState = true
- this.stopPatrol = false
- end
- this.pickupType = SL:GetMetaValue(EMetaVarGetKey.GET_ATUO_PICKUP_ITEM)
- return this.patrolOnHookState
- end
- function this.StopPatrolOnHook()
- this.patrolOnHookState = false
- --中途退出寻路标签,回调不自动打怪
- this.stopPatrol = true
- SL:Me_StopMove(true, true)
- end
- ---获取当前地图存活黄金boss前往击杀
- function this:GetThisMapGoldBossAttack()
- if not this.patrolOnHookState then
- return
- end
- this.readyFindMonster = false
- if not this.allGoldMonsterTbl or not next(this.allGoldMonsterTbl) then
- self:GetAllMapGoldBossList()
- end
- ---获取所有怪
- local mapGoldMonsterTbl = {}
- local allMonster = SL:GetMetaValue(EMetaVarGetKey.MAP_GET_MONSTERS)
- for i, v in pairs(allMonster) do
- if this.allGoldMonsterTbl[v.configId] and v.status == 1 then
- mapGoldMonsterTbl[#mapGoldMonsterTbl + 1] = v
- end
- end
- ---没有黄金怪
- if #mapGoldMonsterTbl == 0 then
- SL:TipMessage( SL:GetConfig("cfg_string",443).text ,1, NoticeType.NoticeMid )
- ---地图没有黄金怪标识
- this.readyFindMonster = true
- return true
- end
- ---找直线距离最近的
- local playerPos = SL:GetMetaValue(EMetaVarGetKey.MAP_PLAYER_POS)
- local attackGoldBossDistance = 99999
- local monsterId = 0
- local x,y
- for i, v in ipairs(mapGoldMonsterTbl) do
- local distance = math.abs(playerPos.x - v.pointX) + math.abs(playerPos.z - v.pointY)
- if distance < attackGoldBossDistance then
- attackGoldBossDistance = distance
- monsterId = v.configId
- x = v.pointX
- y = v.pointY
- this.attackGoldBossId = v.monsterId
- end
- end
- ---生成快捷指令
- ---@type cfg_mapMove_column[]
- local cfg_mapMove = SL:GetConfigTable("cfg_mapMove")
- local mapMoveId
- for i, v in pairs(cfg_mapMove) do
- if v.mapID == SL:GetMetaValue(EMetaVarGetKey.MAP_ID) then
- mapMoveId = v.id
- break
- end
- end
- local param = {}
- param[1] = "moveTo"
- param[2] = mapMoveId
- param[3] = x
- param[4] = y
- ---是否到达寻路终点,用于是否处于巡逻挂机判断
- this.finishFindWay = false
- local moveToArriveCallBack = function()
- if not this.stopPatrol then
- --AutoFightManager.StartAutoFight(false, true, monsterId)
- if not SL:GetMetaValue(EMetaVarGetKey.GET_IS_SAFEAREA) then
- SL:StartOnHook(false, true, monsterId)
- end
- end
- this.stopPatrol = false
- this.startFindWay = false
- this.finishFindWay = true
- end
- this.startFindWay = false
- SL:ShortcutDO(param,nil,nil,moveToArriveCallBack)
- ---是否开始寻路,用于是否处于巡逻挂机判断
- this.startFindWay = true
- end
- return this
|