-- Script portals Tario (coord check). Landings kept outside reverse zones. -- Native map_link portal centers (world/50): Pandora 267,540; Snow 810,377; s01 618,216. S02_ScriptPortals = { -- Pandora {x = 267, z = 540, r = 10, map = 3424073256, tx = 480, ty = 3988, tz = 1200}, -- Snowland (mark + map_link) {x = 1014, z = 544, r = 10, map = 3424071976, tx = 232, ty = 13351, tz = 884}, {x = 810, z = 377, r = 10, map = 3424071976, tx = 232, ty = 13351, tz = 884}, -- Magic Valley {x = 616, z = 239, r = 10, map = 3000521423, tx = 880, ty = 7480, tz = 840}, -- Romen {x = 403, z = 601, r = 10, map = 3373741864, tx = 105, ty = 3000, tz = 369, txf = 411, tyf = 2955, tzf = 314, romen = 1}, -- Frontier (80+) {x = 955, z = 726, r = 10, map = 3390518568, tx = 1280, ty = 138, tz = 1200, minlevel = 80}, } S02_PortalCD = {} S02_TARION_MAP = 3424073512 S02_PORTAL_TIMER = 5600085 -- 2 sec S02_TimerRunning = {} function s02_TryTeleportRole(MapID, InstanceID, RoleID) if MapID ~= S02_TARION_MAP then return end local now = os.time() if S02_PortalCD[RoleID] ~= nil and (now - S02_PortalCD[RoleID]) < 3 then return end local x, y, z = unit.GetPosition(MapID, InstanceID, RoleID) if x == nil or z == nil then return end local i = 1 while S02_ScriptPortals[i] ~= nil do local p = S02_ScriptPortals[i] if math.abs(x - p.x) <= p.r and math.abs(z - p.z) <= p.r then if p.minlevel ~= nil then local lv = role.GetRoleLevel(MapID, InstanceID, RoleID) if lv < p.minlevel then return end end local tx, ty, tz = p.tx, p.ty, p.tz if p.romen == 1 then local sex = role.GetRoleSex(RoleID) if sex == 0 then tx, ty, tz = p.txf, p.tyf, p.tzf end end S02_PortalCD[RoleID] = now role.RoleGotoNewMap(MapID, InstanceID, RoleID, p.map, tx, ty, tz) return end i = i + 1 end end function s02_CheckAllPortals(MapID, InstanceID) local RoleTbl = map.GetMapAllRoleID(MapID, InstanceID) if RoleTbl == nil then return end for _, RoleID in pairs(RoleTbl) do if RoleID ~= nil and RoleID ~= 4294967295 then s02_TryTeleportRole(MapID, InstanceID, RoleID) end end end function s02_StartPortalTimer(MapID, InstanceID) local key = tostring(InstanceID) if S02_TimerRunning[key] then return end S02_TimerRunning[key] = true map.MapCreateColCreature(MapID, InstanceID, S02_PORTAL_TIMER, 1, 1, 1, 1) end function s02_PortalTimer_OnDisappear(MapID, InstanceID, TargetID, TargetTypeID) local key = tostring(InstanceID) if MapID == S02_TARION_MAP then S02_TimerRunning[key] = false s02_CheckAllPortals(MapID, InstanceID) s02_StartPortalTimer(MapID, InstanceID) elseif MapID == 3000521423 and m10_CheckAllPortals ~= nil then M10_TimerRunning[key] = false m10_CheckAllPortals(MapID, InstanceID) m10_StartPortalTimer(MapID, InstanceID) elseif S01_MAP ~= nil and MapID == S01_MAP and s01_CheckAllPortals ~= nil then S01_TimerRunning[key] = false s01_CheckAllPortals(MapID, InstanceID) s01_StartPortalTimer(MapID, InstanceID) elseif MapID == 3390518568 and s60_OnPortalTimer ~= nil then s60_OnPortalTimer(MapID, InstanceID) elseif S57_MAPS ~= nil and S57_MAPS[MapID] == true and S57_OnPortalTimer ~= nil then S57_OnPortalTimer(MapID, InstanceID) else -- Unknown map: release timer slot so polling can recover S02_TimerRunning[key] = false end end aux.RegisterCreatureEvent(5600085, 13, "s02_PortalTimer_OnDisappear") function s02_DoScriptTeleport(MapID, InstanceID, RoleID, ObjID) s02_TryTeleportRole(MapID, InstanceID, RoleID) end function s02_OnEnterTrigger(MapID, InstanceID, RoleID, ObjID) s02_DoScriptTeleport(MapID, InstanceID, RoleID, ObjID) end function s02_OnEnterArea(MapID, InstanceID, RoleID, ObjAreaID) s02_DoScriptTeleport(MapID, InstanceID, RoleID, ObjAreaID) end aux.RegisterMapEvent("s02", 6, "s02_OnEnterTrigger") aux.RegisterMapEvent("s02", 7, "s02_OnEnterArea") function s02_OnInit(MapID, InstanceID, CreatureID, CreatureTypeID) if huanlebiwupin == 1 then map.MapCreateCreature(3424073512, -1, 5510201, 516, 23167, 306) end map.MapCreateColCreature(MapID, InstanceID, 9010078, 266, 23139, 538, 1, "") -- Пандора map.MapCreateColCreature(MapID, InstanceID, 9010079, 1014, 23141, 544, 1, "") -- Сноуленд s02_StartPortalTimer(MapID, InstanceID) if JBZDY_Open == 1 then map.MapCreateColCreature(MapID, InstanceID, 6011030, 371, 23510, 732, 1, "") map.MapCreateColCreature(MapID, InstanceID, 5510503, 577, 22980, 443, 1, "") --?????? ?????? ????? map.MapCreateColCreature(MapID, InstanceID, 5610060, 571, 23510, 597, 1, "") --?????? ?????? ????? map.MapCreateColCreature(MapID, InstanceID, 5610113, 576, 23510, 596, 1, "") --?????? ?????? ????? map.MapCreateColCreature(MapID, InstanceID, 9010028, 589, 22980, 477, 1, "") --?????? ?????? ????? map.MapCreateColCreature(MapID, InstanceID, 5510201, 568, 22980, 444, 1, "") --?????? ?????? ????? map.MapCreateColCreature(MapID, InstanceID, 9010010, 568, 22980, 477, 1, "") --?????? ?????? ????? end map.CreateInstance(3390518568, 1) map.CreateInstance(52648950, 1) map.CreateInstance(52648182, 1) map.CreateInstance(52648438, 1) map.CreateInstance(52649718, 1) -- Кафедрал 4 map.CreateInstance(52649974, 1) map.CreateInstance(52649206, 1) map.CreateInstance(52649462, 1) map.CreateInstance(52646646, 1) map.CreateInstance(52646902, 1) map.CreateInstance(3373743400, 1) map.CreateInstance(S59_MapID, 9999) if BattlePass_Open == 1 then map.MapCreateColCreature(MapID, InstanceID, 9010676, 820, 23801, 771, 1, "") end map.MapCreateColCreature(52648438, 1, 9010247, 250, 10400, 257, 1, "") map.MapCreateColCreature(3424073512, -1, 5512001, 432, 22982, 495, "") end aux.RegisterMapEvent("s02", 0, "s02_OnInit") function s02_PlayerEnter(MapID, InstanceID, RoleID) -- Grace: native/script landings often sit inside the exit vortex S02_PortalCD[RoleID] = os.time() s02_StartPortalTimer(MapID, InstanceID) end aux.RegisterMapEvent("s02", 2, "s02_PlayerEnter") function q51010_OnComplete(MapID, InstanceID, QuestID, RoleID, NPCID) role.AddSkill(RoleID, 5944101) end aux.RegisterQuestEvent(51010, 1, "q51010_OnComplete") function Shenqi_FriendEnemy(MapID, InstanceID, SrcID, TargetID) if unit.IsPlayer(SrcID) then local roleID = cre.GetCreatureScriptData(MapID, InstanceID, TargetID, 1, 1) local creID = cre.GetCreatureScriptData(MapID, InstanceID, TargetID, 1, 0) if roleID ~= nil and roleID == SrcID then return false, true, false, true elseif creID ~= nil and (creID >= 3040380 and creID <= 3040383) then return true, false, false, true else return false, false, false, false end end end aux.RegisterMapEvent("s02", 16, "Shenqi_FriendEnemy")