MonsterTaskGoal.lua 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. ---
  2. --- Generated by EmmyLua(https://github.com/EmmyLua)
  3. --- Created by zhangkai.
  4. --- DateTime: 2024/8/28 下午9:14
  5. ---
  6. MonsterTaskGoal = {}
  7. ---@see 在指定地图对怪造成伤害
  8. function MonsterTaskGoal.FlushHurtMapMonster(actor, type, goal_id, goal_count, param)
  9. if param == nil then
  10. return goal_count
  11. end
  12. local monsterId = tonumber(param["monsterid"])
  13. local mapId = tonumber(param["mapid"])
  14. local hurt = tonumber(param["hurt"])
  15. if hurt < 1 then
  16. return goal_count
  17. end
  18. local needCount = ConfigDataManager.getTableValue("cfg_task_target", "goalcount","id", goal_id)
  19. if needCount == nil or goal_count >= tonumber(needCount) then
  20. return goal_count
  21. end
  22. local monsterCfg = tonumber(ConfigDataManager.getTableValue("cfg_task_target", "taskgoalparam","id", goal_id))
  23. local mapCfg = tonumber(ConfigDataManager.getTableValue("cfg_task_target", "taskgoalparam2","id", goal_id))
  24. if monsterId ~= monsterCfg or mapId ~= mapCfg then
  25. return goal_count
  26. end
  27. return goal_count + hurt
  28. end
  29. ---@alias 击杀指定类型怪物
  30. function MonsterTaskGoal.FlushKillTypeMonster(_, _, goal_id, goal_count, param)
  31. if table.isEmpty(param) then
  32. return goal_count
  33. end
  34. local monster_id = param[1]
  35. local cfg_map_id = param[2]
  36. local mon_type = ConfigDataManager.getTableValue("cfg_monster", "type", "id", monster_id)
  37. local map_type = ConfigDataManager.getTableValue("cfg_map_info", "type", "id", cfg_map_id)
  38. local g_config = ConfigDataManager.getById("cfg_task_target", goal_id)
  39. if table.isEmpty(g_config) then
  40. return goal_count
  41. end
  42. local target = g_config.taskgoalparam
  43. if tonumber(mon_type) ~= tonumber(target) then
  44. return goal_count
  45. end
  46. local target_2 = g_config.taskgoalparam2
  47. if target_2 and target_2 ~= "" then
  48. if tonumber(map_type) ~= tonumber(target_2) then
  49. return goal_count
  50. end
  51. end
  52. return goal_count + 1
  53. end
  54. ---@see 击杀x次指定等级以上怪物
  55. function MonsterTaskGoal.KillLevelMonster(actor, type, goal_id, goal_count, param)
  56. if param == nil then
  57. return goal_count
  58. end
  59. local monsterLv = tonumber(ConfigDataManager.getTableValue("cfg_monster", "level", "id", param))
  60. if monsterLv == nil then
  61. return goal_count
  62. end
  63. local monsterType = tonumber(ConfigDataManager.getTableValue("cfg_monster", "type", "id", param))
  64. local needType = tonumber(ConfigDataManager.getTableValue("cfg_task_target", "taskgoalparam","id", goal_id))
  65. if needType ~= nil and monsterType ~= needType then
  66. return goal_count
  67. end
  68. local levelParam = ConfigDataManager.getTableValue("cfg_task_target", "taskgoalparam2","id", goal_id)
  69. if string.isNullOrEmpty(levelParam) then
  70. return goal_count + 1
  71. end
  72. local leverArray = string.split(levelParam, "#")
  73. if #leverArray == 1 and monsterLv >= tonumber(leverArray[1]) then
  74. return goal_count + 1
  75. end
  76. if #leverArray == 2 then
  77. if monsterLv >= tonumber(leverArray[1]) and monsterLv <= tonumber(leverArray[2]) then
  78. return goal_count + 1
  79. end
  80. end
  81. return goal_count
  82. end
  83. ---@see 尾刀击杀怪物
  84. function MonsterTaskGoal.LastKillMonster(_, _, goal_id, goal_count, param)
  85. if table.isEmpty(param) then
  86. return goal_count
  87. end
  88. local monster_id = string.tonumber(param[1])
  89. local mongen_id = string.tonumber(param[3])
  90. local target = ConfigDataManager.getTableValue("cfg_task_target", "taskgoalparam","id", goal_id)
  91. local target_2 = ConfigDataManager.getTableValue("cfg_task_target", "taskgoalparam2","id", goal_id)
  92. local target_id = string.tonumber(target)
  93. local target_gen_id = string.split(target_2, "#")
  94. if target_id > 0 and #target_gen_id > 0 then
  95. if target_id == monster_id and table.contains(target_gen_id, mongen_id) then
  96. return goal_count + 1
  97. end
  98. elseif target_id > 0 and #target_gen_id < 1 then
  99. if target_id == monster_id then
  100. return goal_count + 1
  101. end
  102. elseif target_id < 1 and #target_gen_id > 0 then
  103. if table.contains(target_gen_id, mongen_id) then
  104. return goal_count + 1
  105. end
  106. end
  107. return goal_count
  108. end
  109. ---@see 首刀击杀怪物
  110. function MonsterTaskGoal.FirstAttackMonster(actor, type, goal_id, goal_count, param)
  111. if table.isEmpty(param) then
  112. return goal_count
  113. end
  114. local needCfgId = tonumber(ConfigDataManager.getTableValue("cfg_task_target", "taskgoalparam","id", goal_id))
  115. local monsterCfgId = tonumber(param[1])
  116. if needCfgId == nil or needCfgId == monsterCfgId then
  117. return goal_count + 1
  118. end
  119. return goal_count
  120. end