123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- Buffer = {}
- NOVICE_PROTECT = "T$_noviceProtect"
- function Buffer.buffeffect(actor, buffCfgId, layers)
- local buffConfig = ConfigDataManager.getById("cfg_buff", buffCfgId)
- if table.isNullOrEmpty(buffConfig) then
- return
- end
- local buffCountStr = buffConfig["buffcount"]
- -- 计算公式
- local buffCount = string.split(buffCountStr, "#")
- local buffValueStr = buffConfig["buffvalue"]
- local buffValueShuXian = string.split(buffValueStr, "|")
- local buffParamStr = buffConfig["buffparam"]
- local buffParamShuXian = string.split(buffParamStr, "|")
- --local allAttr = getallattrinfo(actor)
- --jprint("测试buff1",buffCountStr, buffValueStr, buffParamStr)
- local attr = {}
- for i = 1, #buffParamShuXian do
- local type = tonumber(buffCount[i])
- if type == 7 then
- local paramShuXian = buffParamShuXian[i]
- local strJinHao = string.split(paramShuXian, "#")
- local attrId = strJinHao[1]
- local attrName = attrid2name(actor, attrId)
- local strValue = buffValueShuXian[i]
- local value = string.split(strValue, "#")
- local attr1 = value[1]
- local rate = value[2]
- --local currAttr = tonumber(allAttr[attr1])
- local currAttr = getattrinfo(actor, attrid2name(attr1))
- local result = (currAttr * 0.0001 * rate) * layers
- local oldValue = attr[attrName] or 0
- attr[attrName] = oldValue + result
- --jprint("测试buff2", "i", i, "strShuXian", paramShuXian, "#buffParamShuXian", #buffParamShuXian, "attrId", attrId, "type", type, "strValue", strValue, "attr1", attr1, "rate", rate
- --, "currAttr",currAttr, "result", result, "attr", attrName, "layers", layers)
- end
- end
- for attrName, addValue in pairs(attr) do
- jprint("类型7的buff属性查看",attrName,addValue)
- updateattrgroup(actor, tostring(buffCfgId), attrName, addValue)
- end
- end
- function Buffer.bufflose(actor, buffCfgId)
- clearattrgroup(actor, tostring(buffCfgId))
- end
- function buffertest(actor)
- local petActor = getactor(10942, 2056193)
- local tab = getallattrinfo(petActor)
- jprint("tab数据:",tab)
- jprint("petActor:",petActor)
- jprint("207011:",tab["207011"])
- end
- -- 完成任务添加buff
- function Buffer.taskProgressComplete(actor,taskId)
- local taskTable = ConfigDataManager.getTableValue("cfg_global","value","id","15001")
- if not taskTable then
- return
- end
- local taskInfo = string.split(taskTable,"#")
- local have = false
- for index, task in pairs(taskInfo) do
- if tonumber(task) == taskId then
- have = true
- end
- end
- local maxLevel = ConfigDataManager.getTableValue("cfg_global","value","id","15002")
- if have and getbaseinfo(actor,"level") < tonumber(maxLevel) then
- local buffCfgId = ConfigDataManager.getTableValue("cfg_global","value","id","15003")
- buffer(actor,buffCfgId)
- setplaydef(actor,NOVICE_PROTECT,true)
- end
- end
- function Buffer.levelUp(actor,level)
- local maxLevel = ConfigDataManager.getTableValue("cfg_global","value","id","15002")
- if tonumber(maxLevel) < level then
- local buffCfgId = ConfigDataManager.getTableValue("cfg_global","value","id","15003")
- delbuff(actor,buffCfgId)
- setplaydef(actor,NOVICE_PROTECT,false)
- end
- end
- --- 添加安全区域buff
- ---@param actor table 玩家对象
- function Buffer.safetyAreaBuff(actor)
- local globalVar = ConfigDataManager.getTableValue("cfg_global", "value", "id", GlobalConfigId.SAFETY_AREA_BUFF_CONFIG)
- if not globalVar or string.isNullOrEmpty(globalVar) then
- jprint("========================================>Buffer.safetyAreaBuff globalVar is nil")
- return
- end
- local onlineState = getbaseinfo(actor, "onlinestate")
- local mapId = getbaseinfo(actor, "mapid")
- local mapConfigId = ConfigDataManager.getTableValue("cfg_global", "value", "id", GlobalConfigId.SAFETY_AREA_MAP_CONFIG)
- if not mapConfigId or mapConfigId == "" then
- jprint("========================================>Buffer.safetyAreaBuff mapConfigId is nil")
- return
- end
- local splitTable = string.split(globalVar, "#")
- if not splitTable or not next(splitTable) then
- return
- end
- local mapIds = string.split(mapConfigId, "#")
- if insafezone(actor) and onlineState == 1 and table.getKey(mapIds, tostring(mapId)) then
- for _, buffCfgId in pairs(splitTable) do
- if not hasbuff(actor, buffCfgId) then
- buffer(actor, buffCfgId)
- end
- end
- else
- for _, buffCfgId in pairs(splitTable) do
- if hasbuff(actor, buffCfgId) then
- delbuff(actor, buffCfgId)
- --setplaydef(actor, PlayerDefKey.player.SAFETY_AREA_BUFF, false)
- local roleInfo = getsysvar(SystemVarConst.AUTO_RECOVERY_MAGIC_ROLE_INFO)
- if not roleInfo or roleInfo == "" then
- return
- end
- for k, v in pairs(roleInfo) do
- local play = v["actor"]
- if play:toString() == actor:toString() then
- table.remove(roleInfo, k)
- end
- end
- setsysvar(SystemVarConst.AUTO_RECOVERY_MAGIC_ROLE_INFO, roleInfo)
- end
- end
- end
- end
- --[[
- Buffer = {}
- local SKILL_TYPE = 1
- local ATTACK_TYPE = 2
- local bufferConfigMap;
- function Buffer.initBufferConfigMap()
- bufferConfigMap = {}
- bufferConfigMap[SKILL_TYPE] = {}
- bufferConfigMap[ATTACK_TYPE] = {}
-
- local bufferConfigList = ConfigDataManager.getTable("cfg_buff")
- for _, buffConfig in pairs(bufferConfigList) do
- local bufftrigger = buffConfig["bufftrigger"]
- if not string.isNullOrEmpty(bufftrigger) then
- local data = bufferConfigMap[tonumber(bufftrigger)]
- if data ~= nil then
- table.insert(data, buffConfig)
- end
- end
- end
- end
- function Buffer.getBufferConfigList(trigger)
- if bufferConfigMap == nil then
- Buffer.initBufferConfigMap()
- end
- return bufferConfigMap[tonumber(trigger)]
- end
- function Buffer.OnAttack(actor, targetActor)
- local bufferConfigs = Buffer.getBufferConfigList(ATTACK_TYPE)
- for _, buffConfig in ipairs(bufferConfigs) do
- addbuff(targetActor, buffConfig["id"], 1, actor)
- end
- end
- function Buffer.OnReleaseSkill(actor, targetActorlist)
- local bufferConfigs = Buffer.getBufferConfigList(SKILL_TYPE)
- for _, buffConfig in ipairs(bufferConfigs) do
- for _, targetActor in pairs(targetActorlist) do
- addbuff(targetActor, buffConfig["id"], 1, actor)
- end
- end
- end ]]
|