SceneMap_1.lua 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. SceneMap = {}
  2. local this = {}
  3. SceneMap.viewKey = {
  4. -- VIP数据
  5. VIP_LV = "vipLv",
  6. KUN_DUN_FACTION = "kunDunFaction",
  7. DEMON_HERMIT_SKILL = "demonHermitSkill",
  8. }
  9. --- 指定坐标是否为阻挡点 地图ID可不填 (T-非阻挡点, F-阻挡点)
  10. function SceneMap.notBlockPoint(actor, map_x, map_y, map_id)
  11. return this.notBlockPoint(actor, map_x, map_y, map_id)
  12. end
  13. --- 传送到指定地图
  14. function SceneMap.doTransfer(actor, map_id, map_line, map_x, map_y, range)
  15. this.doTransfer0(actor, map_id, map_line, map_x, map_y, range)
  16. end
  17. --- 玩家进入视野发送全量消息(发送玩家进入视野)
  18. function SceneMap.playerEnterView(actor, target)
  19. local s, e = xpcall(this.playerEnterView, debug.traceback, actor, target)
  20. gameDebug.assertPrint(s, "外置玩家进入视野同步信息异常!", e)
  21. end
  22. --- 发送单个信息(更新给周围玩家视野内容变动)
  23. function SceneMap.sendEnterViewInfoByType(actor, ...)
  24. this.sendRangeViewChange(actor, ...)
  25. end
  26. -- ----------------------------------------------------------------- --
  27. function this.notBlockPoint(actor, map_x, map_y, map_id)
  28. if map_id == nil then
  29. return notblockpoint(actor, map_x, map_y)
  30. end
  31. return notblockpoint(actor, map_x, map_y, map_id)
  32. end
  33. function this.isBlockPoint(actor, map_x, map_y, map_id)
  34. return not this.notBlockPoint(actor, map_x, map_y, map_id)
  35. end
  36. function this.doTransfer0(actor, map_id, map_line, map_x, map_y, range)
  37. maptransfer(actor, map_x, map_y, map_id, map_line, range)
  38. end
  39. function this.playerEnterView(actor, target)
  40. local data = {}
  41. data.rid = target:toString()
  42. gameDebug.print("玩家进入视野同步信息:", "actor", actor, "target", target)
  43. data[SceneMap.viewKey.VIP_LV] = VipGiftPack.getVipLv(target)
  44. if KunDun.isInKunDun(target) then
  45. data[SceneMap.viewKey.KUN_DUN_FACTION] = KunDun.getKunDunViewData(target)
  46. end
  47. data[SceneMap.viewKey.DEMON_HERMIT_SKILL] = getplaydef(target, PlayerDefKey.skill.DEMON_HERMIT_SKILL)
  48. -- 发送通知
  49. sendluamsg(actor, LuaMessageIdToClient.RES_PLAYER_ENTER_VIEW_INFO, data)
  50. end
  51. function this.sendRangeViewChange(actor, ...)
  52. -- 参数必须是偶数
  53. local args = {...}
  54. if #args % 2 > 0 then
  55. return
  56. end
  57. local data = {}
  58. data.rid = actor:toString()
  59. -- 解析参数
  60. for i = 1, #args, 2 do
  61. local type = args[i]
  62. local param = args[i + 1]
  63. data[type] = param
  64. end
  65. sendrefluamsg(actor, LuaMessageIdToClient.RES_PLAYER_ENTER_VIEW_INFO, data)
  66. end
  67. -- ----------------------------------------------------------------- --
  68. MapMoveTransfer = {}
  69. --- MapMove传送
  70. function MapMoveTransfer.mapMove(actor, move_id)
  71. this.doMapMove(actor, move_id)
  72. end
  73. function MapMoveTransfer.mapMoveWithLine(actor, move_id, line)
  74. this.doMapMove(actor, move_id, line)
  75. end
  76. function this.doMapMove(actor, move_id, line)
  77. local canTransfer, strTip = LineManager.CheckCanEnterLineMap(actor, tonumber(move_id))
  78. if not canTransfer then
  79. tipinfo(actor, strTip)
  80. return
  81. end
  82. if line == nil then
  83. kmlmapmove(actor, move_id)
  84. return
  85. end
  86. kmlmapmove(actor, move_id, line)
  87. end
  88. --- 请求地图内定点传送
  89. function MapMoveTransfer.transferWithinMap(actor, msgData)
  90. this.transferWithinMap(actor, msgData)
  91. end
  92. function this.transferWithinMap(actor, msgData)
  93. if table.isEmpty(msgData) then
  94. return
  95. end
  96. if DuplicateCommon.IsInDuplicate(actor) then
  97. tipinfo(actor, "当前地图不可使用")
  98. return
  99. end
  100. local map_x = tonumber(msgData[1])
  101. local map_y = tonumber(msgData[2])
  102. if this.isBlockPoint(actor, map_x, map_y) then
  103. tipinfo(actor, "目标地点无法抵达")
  104. return
  105. end
  106. local map_id = getbaseinfo(actor, "mapid")
  107. local line = getbaseinfo(actor, "line")
  108. local range = 1
  109. local cost_map = {}
  110. local cost_str = ConfigDataManager.getTableValue("cfg_global", "value", "id", GlobalConfigId.TRANSFER_WITHIN_MAP)
  111. if not string.isNullOrEmpty(cost_str) then
  112. string.putIntIntMap(cost_map, cost_str, "#", "|")
  113. end
  114. if not table.isNullOrEmpty(cost_map) then
  115. if not Bag.checkCostMap(actor, cost_map) then
  116. tipinfo(actor, "道具不足")
  117. return
  118. end
  119. Bag.costMap(actor, cost_map)
  120. end
  121. this.doTransfer0(actor, map_id, line, map_x, map_y, range)
  122. end
  123. --- 发送单个信息(更新给周围玩家视野内容变动)
  124. function MapMoveTransfer.transferToMapSelect(actor, msgData)
  125. this.transferToMapSelect(actor, msgData)
  126. end
  127. function this.transferToMapSelect(actor, msgData)
  128. ---@type cfg_mapMove_column
  129. local configMapMove = ConfigDataManager.getById("cfg_mapMove", 1101)
  130. if configMapMove == nil then
  131. return
  132. end
  133. if msgData == nil or msgData.mapId == nil or msgData.itemNeedIndex == nil then
  134. tipinfo(actor, "请求参数错误")
  135. return
  136. end
  137. local mapId = tonumber(msgData.mapId)
  138. local canTransfer, strTip = LineManager.CheckCanEnterLineMap(actor, mapId)
  139. if not canTransfer then
  140. tipinfo(actor, strTip)
  141. return
  142. end
  143. canTransfer, strTip = LineManager.CheckEnterLineMapItemsNeed(actor, mapId, msgData.itemNeedIndex)
  144. if not canTransfer then
  145. tipinfo(actor, strTip)
  146. return
  147. end
  148. local transPointId = -1
  149. if msgData.transPointId ~= nil then
  150. transPointId = tonumber(msgData.transPointId)
  151. end
  152. local transferPos = { [1] = 24, [2] = 73 }
  153. if transPointId > 0 then
  154. local transPoint = ConfigDataManager.getTableValue("cfg_transfer_point", "targetPosition", "id", transPointId)
  155. if transPoint ~= nil and transPoint ~= "" then
  156. local tmpTransferPos = string.split(transPoint, "#")
  157. transferPos = { [1] = tonumber(tmpTransferPos[1]), [2] = tonumber(tmpTransferPos[2]) }
  158. end
  159. elseif configMapMove.poz ~= nil and configMapMove.poz ~= "" then
  160. local tmpTransferPosArr = string.split(configMapMove.poz, "|")[1]
  161. local tmpTransferPos = string.split(tmpTransferPosArr, "#")
  162. transferPos = { [1] = tonumber(tmpTransferPos[1]), [2] = tonumber(tmpTransferPos[2]) }
  163. end
  164. this.doTransfer0(actor, mapId, 1, transferPos[1], transferPos[2], tonumber(configMapMove.range))
  165. end