123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- local this = {}
- --玩家秒钟心跳
- function SecondHeartBP(actor)
- OnlineBP(actor)
- end
- --在线泡点
- function OnlineBP(actor)
- local nowMillis = getbaseinfo(actor, "now")
- if CheckExpConditionBP(actor) == false then
- return
- end
- local lastBPMillis = getplaydef(actor, "@lastBPMillis")
- lastBPMillis = tonumber(lastBPMillis)
- if lastBPMillis == nil or lastBPMillis <= 0 then
- setplaydef(actor, "@lastBPMillis", nowMillis)
- return
- end
- --间隔时间
- local level = getbaseinfo(actor, "level")
- local expInterval = ConfigDataManager.getTableValue("cfg_bubble_point", "expInterval", "id", level)
- if expInterval == nil or expInterval == "" then
- -- error("找不到cfg_bubble_point配置,id:"..level)
- return
- end
- expInterval = tonumber(expInterval) * 1000
- local subSec = nowMillis - lastBPMillis
- if subSec < expInterval then
- return
- end
- --满足条件,1.发放经验,2.发包给客户端,3.设置上次时间为当前时间
- setplaydef(actor, "@lastBPMillis", nowMillis)
- local expConfig = ConfigDataManager.getTableValue("cfg_bubble_point", "exp", "id", level)
- local itemMap = string.toIntIntMap(expConfig, "#", "|")
- -- 泡点经验加成
- -- itemMap = this.rateAddExpValue(actor, itemMap)
- if table.isEmpty(itemMap) then
- return
- end
- additemmaptobag(actor, itemMap, 0, 1)
- end
- function this.rateAddExpValue(actor, itemMap)
- if table.isEmpty(itemMap) then
- return
- end
- -- 过滤掉值小于1的配置
- local exp_map = {}
- -- 特权/VIP加成 已改为走属性加成
- local rate = 0
- -- local rate = this.calculatorPrivilegeExpRate(actor) / 100
- for k, v in pairs(itemMap) do
- local final_v = string.tonumber(v)
- if final_v < 1 then
- goto continue
- end
- final_v = final_v * (1 + rate / 100)
- exp_map[k] = final_v
- ::continue::
- end
- return exp_map
- end
- --获取经验事件
- function bubblePointGetExp(actor, exp, fromType, expAddRate)
- if fromType ~= 1 and fromType ~= 2 then
- return
- end
- -- 内置经验加成算法与外置不同,覆盖内置倍率逻辑
- expAddRate = 0
- -- vip与特权卡的经验加成没有走角色加属性的方式,所以此处单独处理经验加成百分比展示问题
- expAddRate = expAddRate + this.calculatorPrivilegeExpRate(actor)
- -- 获取经验药水加成值
- local expBoostAttrValue = getplaydef(actor, PlayerDefKey.player.EXP_BOOST_ATTR_VALUE)
- if expBoostAttrValue then
- expAddRate = expAddRate + expBoostAttrValue
- end
- local sendData = {
- exp = exp,
- expAddRate = expAddRate,
- fromType= fromType --1泡点,2杀怪
- }
- sendluamsg(actor, LuaMessageIdToClient.BOBBLE_POINT_SHOW, sendData)
- end
- function this.calculatorPrivilegeExpRate(actor)
- -- 杀怪经验加成值取各个功能模块的加成值之和
- local expAddRate = 0
- -- 判断是否开启了vip经验加成
- local vipOpen, vipRate = VipGiftPack.hasPrivilege(actor, VipPrivilege.Type.exp)
- if vipOpen then
- local vipRateArr = string.split(vipRate, "#")
- expAddRate = expAddRate + string.tonumber(vipRateArr[2])
- end
- -- 判断是否开启了特权经验加成
- local privilegeOpen, privilegeRate = PrivilegeMonth.hasPrivilege(actor, PrivilegeMonth.PrivilegeType.EXP_ADD_RATE)
- if privilegeOpen then
- expAddRate = expAddRate + privilegeRate
- end
- return expAddRate
- end
- --检查经验泡点条件
- function CheckExpConditionBP(actor)
- --检查是否在线
- local isOffLine = isofflineplay(actor)
- if isOffLine == true then
- return false
- end
- --检查等级限制
- local level = getbaseinfo(actor, "level")
- level = tonumber(level)
- local configLevel = ConfigDataManager.getTableValue("cfg_bubble_point", "expLevelLimit", "id", level)
- if configLevel == nil or configLevel == "" then
- -- error("找不到cfg_bubble_point配置,id:"..level)
- return false
- end
- local levelTable = string.split(configLevel, "#")
- local minLevel = tonumber(levelTable[1])
- local maxLevel = tonumber(levelTable[2])
- if level < minLevel or level > maxLevel then
- return false
- end
- --检查区域
- local mapId = getbaseinfo(actor, "map")
- local safeArea = getbaseinfo(actor, "safearea")
- local configString = ConfigDataManager.getTableValue("cfg_bubble_point", "expMap", "id", level)
- local configMap = string.toIntIntMap(configString, "#", "|")
- local checkArea = false
- for key, value in pairs(configMap) do
- mapId = tonumber(mapId)
- key = tonumber(key)
- value = tonumber(value)
- if mapId == key then
- if value == 3 then
- checkArea = true
- elseif value == 2 and safeArea == false then
- checkArea = true
- elseif value == 1 and safeArea == true then
- checkArea = true
- end
- end
- end
- if checkArea == false then
- return false
- end
- return true
- end
|