CustomTransmit_1.lua 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. CustomTransmit = {}
  2. function CustomTransmit.GetPointFromMapMove(mapId)
  3. -- 处理自定义坐标
  4. local mapMoveCfg = ConfigDataManager.getTableFirst("cfg_mapmove", "mapid", mapId)
  5. if mapMoveCfg == nil then
  6. return nil
  7. end
  8. local mapX = mapMoveCfg["mapx"]
  9. local mapY = mapMoveCfg["mapy"]
  10. if not string.isNullOrEmpty(mapX) and not string.isNullOrEmpty(mapY) then
  11. return tonumber(mapX), tonumber(mapY)
  12. end
  13. local poz = mapMoveCfg["poz"]
  14. local pointMap = string.toIntIntMap(poz, "#", "|")
  15. if table.isNullOrEmpty(pointMap) then
  16. return nil
  17. end
  18. local num = math.random(0, table.count(pointMap) - 1)
  19. local index = 0
  20. for x, y in pairs(pointMap) do
  21. if num == index then
  22. return x, y
  23. end
  24. index = index + 1
  25. end
  26. return nil
  27. end
  28. function CustomTransmit.CustomToTransmit(actor, targetMap, targetLine, currX, currY, x, y, fromMapMove)
  29. local checkResult = CustomTransmit.checkTransmit(actor, targetMap, targetLine, currX, currY, x, y)
  30. if checkResult ~= nil then
  31. return checkResult
  32. end
  33. -- 如果坐标来自mapMove表,则再次自定义计算坐标点
  34. if fromMapMove then
  35. -- 判断地图是不是相同的地图.如果是.则坐标不变
  36. local pInfoMap = getbaseinfo(actor, "map")
  37. local line = getbaseinfo(actor, "line")
  38. if pInfoMap == targetMap and line ~= targetLine then
  39. local px = getbaseinfo(actor, "x")
  40. local py = getbaseinfo(actor, "y")
  41. local result = {
  42. result = false,
  43. x = px,
  44. y = py
  45. }
  46. return result
  47. end
  48. local x, y = CustomTransmit.GetPointFromMapMove(targetMap)
  49. if x == nil or y == nil then
  50. return nil
  51. end
  52. local result = {
  53. result = false,
  54. x = x,
  55. y = y
  56. }
  57. -- jprint("自定义传送新坐标", targetMap, result)
  58. return result
  59. end
  60. end
  61. function CustomTransmit.checkTransmit(actor, targetMap, targetLine, currX, currY, x, y)
  62. local mapId = getbaseinfo(actor, "unimapid")
  63. local dupInfo = getduplicate(mapId)
  64. if dupInfo then
  65. local dupType = dupInfo['type']
  66. if dupType == DuplicateType.WAR_ALLIANCE then
  67. return WarAlliance.CheckTransfer(actor, currX, currY, x, y)
  68. end
  69. end
  70. -- 检查能不能进入特权地图
  71. local inGoldMap = TripleIncome.CheckInGoldMap(actor, targetMap)
  72. if inGoldMap ~= nil then
  73. return inGoldMap
  74. end
  75. -- 内置传送校验跨服地图条件
  76. local targetMapConfig = ConfigDataManager.getById("cfg_map_info", targetMap)
  77. if table.isEmpty(targetMapConfig) then
  78. return nil
  79. end
  80. if targetMapConfig.serverType == CrossMap.CROSS_MAP_TYPE then
  81. return CrossMap.canEnter(actor, targetMap)
  82. end
  83. end
  84. function CustomTransmit.DoTransmit(actor, msgData)
  85. -- mapCfgId, line, x, y
  86. local mapCfgId = msgData.mapCfgId
  87. local line = msgData.line
  88. if string.isNullOrEmpty(mapCfgId) then
  89. mapCfgId = getbaseinfo(actor, "mapid")
  90. end
  91. if string.isNullOrEmpty(line) then
  92. line = getbaseinfo(actor, "line")
  93. end
  94. local x = msgData.x
  95. local y = msgData.y
  96. maptransfer(actor, x, y, mapCfgId, line)
  97. sendluamsg(actor, LuaMessageIdToClient.RES_CUSTOME_TRANSFER, {})
  98. end