Buffer_1.lua 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. Buffer = {}
  2. NOVICE_PROTECT = "T$_noviceProtect"
  3. function Buffer.buffeffect(actor, buffCfgId, layers, casterActor)
  4. local buffConfig = ConfigDataManager.getById("cfg_buff", buffCfgId)
  5. if table.isNullOrEmpty(buffConfig) then
  6. return
  7. end
  8. local buffCountStr = buffConfig["buffcount"]
  9. -- 计算公式
  10. local buffCount = string.split(buffCountStr, "#")
  11. local buffValueStr = buffConfig["buffvalue"]
  12. local buffValueShuXian = string.split(buffValueStr, "|")
  13. local buffParamStr = buffConfig["buffparam"]
  14. local buffParamShuXian = string.split(buffParamStr, "|")
  15. --local allAttr = getallattrinfo(actor)
  16. --jprint("测试buff1",buffCountStr, buffValueStr, buffParamStr)
  17. local attr = {}
  18. for i = 1, #buffParamShuXian do
  19. local type = tonumber(buffCount[i])
  20. if type == 7 then
  21. local paramShuXian = buffParamShuXian[i]
  22. local strJinHao = string.split(paramShuXian, "#")
  23. local attrId = strJinHao[1]
  24. local attrName = attrid2name(casterActor, attrId)
  25. local strValue = buffValueShuXian[i]
  26. local value = string.split(strValue, "#")
  27. local attr1 = value[1]
  28. local rate = value[2]
  29. --local currAttr = tonumber(allAttr[attr1])
  30. local currAttr = getattrinfo(casterActor, attrid2name(attr1))
  31. local result = (currAttr * 0.0001 * rate) * layers
  32. local oldValue = attr[attrName] or 0
  33. attr[attrName] = oldValue + result
  34. --jprint("测试buff2", "i", i, "strShuXian", paramShuXian, "#buffParamShuXian", #buffParamShuXian, "attrId", attrId, "type", type, "strValue", strValue, "attr1", attr1, "rate", rate
  35. --, "currAttr",currAttr, "result", result, "attr", attrName, "layers", layers)
  36. end
  37. end
  38. for attrName, addValue in pairs(attr) do
  39. -- jprint("类型7的buff属性查看",attrName,addValue)
  40. updateattrgroup(actor, tostring(buffCfgId), attrName, addValue)
  41. end
  42. end
  43. function Buffer.bufflose(actor, buffCfgId)
  44. clearattrgroup(actor, tostring(buffCfgId))
  45. end
  46. function buffertest(actor)
  47. local petActor = getactor(10942, 2056193)
  48. local tab = getallattrinfo(petActor)
  49. -- jprint("tab数据:",tab)
  50. -- jprint("petActor:",petActor)
  51. -- jprint("207011:",tab["207011"])
  52. end
  53. -- 完成任务添加buff
  54. function Buffer.taskProgressComplete(actor,taskId)
  55. local taskTable = ConfigDataManager.getTableValue("cfg_global","value","id","15001")
  56. if not taskTable then
  57. return
  58. end
  59. local taskInfo = string.split(taskTable,"#")
  60. local have = false
  61. for index, task in pairs(taskInfo) do
  62. if tonumber(task) == taskId then
  63. have = true
  64. end
  65. end
  66. local maxLevel = ConfigDataManager.getTableValue("cfg_global","value","id","15002")
  67. if have and getbaseinfo(actor,"level") < tonumber(maxLevel) then
  68. local buffCfgId = ConfigDataManager.getTableValue("cfg_global","value","id","15003")
  69. buffer(actor,buffCfgId)
  70. setplaydef(actor,NOVICE_PROTECT,true)
  71. end
  72. end
  73. function Buffer.levelUp(actor,level)
  74. local maxLevel = ConfigDataManager.getTableValue("cfg_global","value","id","15002")
  75. if tonumber(maxLevel) < level then
  76. local buffCfgId = ConfigDataManager.getTableValue("cfg_global","value","id","15003")
  77. delbuff(actor,buffCfgId)
  78. setplaydef(actor,NOVICE_PROTECT,false)
  79. end
  80. end
  81. --- 添加安全区域buff
  82. ---@param actor table 玩家对象
  83. function Buffer.safetyAreaBuff(actor)
  84. local globalVar = ConfigDataManager.getTableValue("cfg_global", "value", "id", GlobalConfigId.SAFETY_AREA_BUFF_CONFIG)
  85. if not globalVar or string.isNullOrEmpty(globalVar) then
  86. -- jprint("========================================>Buffer.safetyAreaBuff globalVar is nil")
  87. return
  88. end
  89. local onlineState = getbaseinfo(actor, "onlinestate")
  90. local mapId = getbaseinfo(actor, "mapid")
  91. local mapConfigId = ConfigDataManager.getTableValue("cfg_global", "value", "id", GlobalConfigId.SAFETY_AREA_MAP_CONFIG)
  92. if not mapConfigId or mapConfigId == "" then
  93. -- jprint("========================================>Buffer.safetyAreaBuff mapConfigId is nil")
  94. return
  95. end
  96. local splitTable = string.split(globalVar, "#")
  97. if not splitTable or not next(splitTable) then
  98. return
  99. end
  100. local mapIds = string.split(mapConfigId, "#")
  101. if insafezone(actor) and onlineState == 1 and table.getKey(mapIds, tostring(mapId)) then
  102. for _, buffCfgId in pairs(splitTable) do
  103. if not hasbuff(actor, buffCfgId) then
  104. buffer(actor, buffCfgId)
  105. end
  106. end
  107. else
  108. for _, buffCfgId in pairs(splitTable) do
  109. if hasbuff(actor, buffCfgId) then
  110. delbuff(actor, buffCfgId)
  111. --setplaydef(actor, PlayerDefKey.player.SAFETY_AREA_BUFF, false)
  112. local roleInfo = getsysvar(SystemVarConst.AUTO_RECOVERY_MAGIC_ROLE_INFO)
  113. if not roleInfo or roleInfo == "" then
  114. return
  115. end
  116. for k, v in pairs(roleInfo) do
  117. local play = v["actor"]
  118. if play:toString() == actor:toString() then
  119. table.remove(roleInfo, k)
  120. end
  121. end
  122. setsysvar(SystemVarConst.AUTO_RECOVERY_MAGIC_ROLE_INFO, roleInfo)
  123. end
  124. end
  125. end
  126. end
  127. --幻影导师 添加buff
  128. function Buffer.onAddBuff(actor, msgData)
  129. -- msgData = {41000011,41000012 }
  130. local globalVar = ConfigDataManager.getTableValue("cfg_global", "value", "id", GlobalConfigId.PHANTOM_MENTOR_BUFF)
  131. local splitTable = string.split(globalVar, "#")
  132. if next(splitTable) then
  133. for _, buffCfgId in pairs(splitTable) do
  134. addbuff(actor, tonumber(buffCfgId))
  135. end
  136. end
  137. TaskHandler.TriggerTaskGoal(actor, TaskTargetType.ADD_DOUBLE_EXP_BUFF, true)
  138. -- local buff_info = getbuffinfo(actor)
  139. -- if next(buff_info) then
  140. -- for i = 1, #buff_info do
  141. -- info(buff_info[i].buffcfgid)
  142. -- end
  143. -- end
  144. end
  145. --[[
  146. Buffer = {}
  147. local SKILL_TYPE = 1
  148. local ATTACK_TYPE = 2
  149. local bufferConfigMap;
  150. function Buffer.initBufferConfigMap()
  151. bufferConfigMap = {}
  152. bufferConfigMap[SKILL_TYPE] = {}
  153. bufferConfigMap[ATTACK_TYPE] = {}
  154. local bufferConfigList = ConfigDataManager.getTable("cfg_buff")
  155. for _, buffConfig in pairs(bufferConfigList) do
  156. local bufftrigger = buffConfig["bufftrigger"]
  157. if not string.isNullOrEmpty(bufftrigger) then
  158. local data = bufferConfigMap[tonumber(bufftrigger)]
  159. if data ~= nil then
  160. table.insert(data, buffConfig)
  161. end
  162. end
  163. end
  164. end
  165. function Buffer.getBufferConfigList(trigger)
  166. if bufferConfigMap == nil then
  167. Buffer.initBufferConfigMap()
  168. end
  169. return bufferConfigMap[tonumber(trigger)]
  170. end
  171. function Buffer.OnAttack(actor, targetActor)
  172. local bufferConfigs = Buffer.getBufferConfigList(ATTACK_TYPE)
  173. for _, buffConfig in ipairs(bufferConfigs) do
  174. addbuff(targetActor, buffConfig["id"], 1, actor)
  175. end
  176. end
  177. function Buffer.OnReleaseSkill(actor, targetActorlist)
  178. local bufferConfigs = Buffer.getBufferConfigList(SKILL_TYPE)
  179. for _, buffConfig in ipairs(bufferConfigs) do
  180. for _, targetActor in pairs(targetActorlist) do
  181. addbuff(targetActor, buffConfig["id"], 1, actor)
  182. end
  183. end
  184. end ]]