CustomTransmit.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. local x, y = CustomTransmit.GetPointFromMapMove(targetMap)
  36. if x == nil or y == nil then
  37. return nil
  38. end
  39. local result = {
  40. result= false,
  41. x= x,
  42. y= y
  43. }
  44. jprint("自定义传送新坐标", targetMap, result)
  45. return result
  46. end
  47. end
  48. function CustomTransmit.checkTransmit(actor, targetMap, targetLine, currX, currY, x, y)
  49. local mapId = getbaseinfo(actor, "unimapid")
  50. local dupInfo = getduplicate(mapId)
  51. if dupInfo then
  52. local dupType = dupInfo['type']
  53. if dupType == DuplicateType.WAR_ALLIANCE then
  54. return WarAlliance.CheckTransfer(actor, currX, currY, x, y)
  55. end
  56. end
  57. --检查能不能进入特权地图
  58. local inGoldMap = TripleIncome.CheckInGoldMap(actor, targetMap)
  59. if inGoldMap ~= nil then
  60. return inGoldMap
  61. end
  62. -- 内置传送校验跨服地图条件
  63. local targetMapConfig = ConfigDataManager.getById("cfg_map_info", targetMap)
  64. if table.isEmpty(targetMapConfig) then
  65. return nil
  66. end
  67. if targetMapConfig.serverType == CrossMap.CROSS_MAP_TYPE then
  68. return CrossMap.canEnter(actor, targetMap)
  69. end
  70. end
  71. function CustomTransmit.DoTransmit(actor, msgData)
  72. --mapCfgId, line, x, y
  73. local mapCfgId = msgData.mapCfgId
  74. local line = msgData.line
  75. if string.isNullOrEmpty(mapCfgId) then
  76. mapCfgId = getbaseinfo(actor, "mapid")
  77. end
  78. if string.isNullOrEmpty(line) then
  79. line = getbaseinfo(actor, "line")
  80. end
  81. local x = msgData.x
  82. local y = msgData.y
  83. maptransfer(actor, x, y, mapCfgId, line)
  84. sendluamsg(actor,LuaMessageIdToClient.RES_CUSTOME_TRANSFER, {})
  85. end