CustomTransmit.lua 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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