123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- CustomTransmit = {}
- function CustomTransmit.GetPointFromMapMove(mapId)
- --处理自定义坐标
- local mapMoveCfg = ConfigDataManager.getTableFirst("cfg_mapmove", "mapid", mapId)
- if mapMoveCfg == nil then
- return nil
- end
- local mapX = mapMoveCfg["mapx"]
- local mapY = mapMoveCfg["mapy"]
- if not string.isNullOrEmpty(mapX) and not string.isNullOrEmpty(mapY) then
- return tonumber(mapX), tonumber(mapY)
- end
- local poz = mapMoveCfg["poz"]
- local pointMap = string.toIntIntMap(poz, "#","|")
- if table.isNullOrEmpty(pointMap) then
- return nil
- end
- local num = math.random(0, table.count(pointMap) - 1)
- local index = 0
- for x, y in pairs(pointMap) do
- if num == index then
- return x, y
- end
- index = index + 1
- end
- return nil
- end
- function CustomTransmit.CustomToTransmit(actor, targetMap, targetLine, currX, currY, x, y, fromMapMove)
- local checkResult = CustomTransmit.checkTransmit(actor, targetMap, targetLine, currX, currY, x, y)
- if checkResult ~= nil then
- return checkResult
- end
- --如果坐标来自mapMove表,则再次自定义计算坐标点
- if fromMapMove then
- local x, y = CustomTransmit.GetPointFromMapMove(targetMap)
- if x == nil or y == nil then
- return nil
- end
- local result = {
- result= false,
- x= x,
- y= y
- }
- jprint("自定义传送新坐标", targetMap, result)
- return result
- end
- end
- function CustomTransmit.checkTransmit(actor, targetMap, targetLine, currX, currY, x, y)
- local mapId = getbaseinfo(actor, "unimapid")
- local dupInfo = getduplicate(mapId)
- if dupInfo then
- local dupType = dupInfo['type']
- if dupType == DuplicateType.WAR_ALLIANCE then
- return WarAlliance.CheckTransfer(actor, currX, currY, x, y)
- end
- end
- --检查能不能进入特权地图
- local inGoldMap = TripleIncome.CheckInGoldMap(actor, targetMap)
- if inGoldMap ~= nil then
- return inGoldMap
- end
- -- 内置传送校验跨服地图条件
- local targetMapConfig = ConfigDataManager.getById("cfg_map_info", targetMap)
- if table.isEmpty(targetMapConfig) then
- return nil
- end
- if targetMapConfig.serverType == CrossMap.CROSS_MAP_TYPE then
- return CrossMap.canEnter(actor, targetMap)
- end
- end
- function CustomTransmit.DoTransmit(actor, msgData)
- --mapCfgId, line, x, y
- local mapCfgId = msgData.mapCfgId
- local line = msgData.line
- if string.isNullOrEmpty(mapCfgId) then
- mapCfgId = getbaseinfo(actor, "mapid")
- end
- if string.isNullOrEmpty(line) then
- line = getbaseinfo(actor, "line")
- end
- local x = msgData.x
- local y = msgData.y
- maptransfer(actor, x, y, mapCfgId, line)
- sendluamsg(actor,LuaMessageIdToClient.RES_CUSTOME_TRANSFER, {})
- end
|