-- Frontier (s60) script portals by coordinates (ObjID 1022/1023/1031 do not fire) S60_MAP = 3390518568 S60_PortalCD = {} S60_TimerRunning = {} -- Centers from s60.mb portal rectangles (world/50) S60_ScriptPortals = { -- Cathedral: only deep inside vortex (not on the steps) {x = 844, z = 1262, r = 3, kind = "cathedral", map = 52648950, tx = 26, ty = 200, tz = 32}, -- Bastion: only deep inside vortex {x = 1882, z = 1280, r = 4, kind = "bastion", map = 52649974, tx = 440, ty = 1, tz = 768}, -- Tario {x = 1285, z = 1041, r = 6, kind = "tario", map = 3424073512, tx = 900, ty = 23802, tz = 750}, } function s60_HasCathedralCrystal(RoleID) local hunjingtype = role.GetEquipIDOnPos(RoleID, 13) if hunjingtype == 8220401 or hunjingtype == 8220403 or (hunjingtype >= 8220501 and hunjingtype <= 8220599) then return true end return false end function s60_HasBastionCrystal(RoleID) local hunjingtype = role.GetEquipIDOnPos(RoleID, 13) if hunjingtype == 8220402 or hunjingtype == 8220404 or (hunjingtype >= 8220601 and hunjingtype <= 8220699) then return true end return false end function s60_TryTeleportRole(MapID, InstanceID, RoleID) if MapID ~= S60_MAP then return end local now = os.time() if S60_PortalCD[RoleID] ~= nil and (now - S60_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 S60_ScriptPortals[i] ~= nil do local p = S60_ScriptPortals[i] if math.abs(x - p.x) <= p.r and math.abs(z - p.z) <= p.r then if p.kind == "cathedral" then if s60_HasCathedralCrystal(RoleID) ~= true then local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 26, 444304) msg.DispatchRoleMsgEvent(RoleID, MsgID) return end elseif p.kind == "bastion" then if s60_HasBastionCrystal(RoleID) ~= true then local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 26, 444309) msg.DispatchRoleMsgEvent(RoleID, MsgID) return end end S60_PortalCD[RoleID] = now role.RoleGotoNewMap(MapID, InstanceID, RoleID, p.map, p.tx, p.ty, p.tz) return end i = i + 1 end end function s60_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 s60_TryTeleportRole(MapID, InstanceID, RoleID) end end end function s60_StartPortalTimer(MapID, InstanceID) local key = tostring(InstanceID) if S60_TimerRunning[key] then return end S60_TimerRunning[key] = true map.MapCreateColCreature(MapID, InstanceID, 5600085, 1, 1, 1, 1) end function s60_OnPortalTimer(MapID, InstanceID) local key = tostring(InstanceID) S60_TimerRunning[key] = false s60_CheckAllPortals(MapID, InstanceID) s60_StartPortalTimer(MapID, InstanceID) end function s60_OnEnterTriggerArea1(MapID, InstanceID, RoleID, ObjAreaID) -- keep ObjID fallback local hunjingtype = role.GetEquipIDOnPos(RoleID, 13) if ObjAreaID == 1023 then if hunjingtype == 8220401 or hunjingtype == 8220403 or (hunjingtype >= 8220501 and hunjingtype <= 8220599) then role.RoleGotoNewMap(MapID, InstanceID, RoleID, 52648950, 26, 200, 32) else local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 26, 444304) msg.DispatchRoleMsgEvent(RoleID, MsgID) end elseif ObjAreaID == 1022 then if hunjingtype == 8220402 or hunjingtype == 8220404 or (hunjingtype >= 8220601 and hunjingtype <= 8220699) then role.RoleGotoNewMap(MapID, InstanceID, RoleID, 52649974, 440, 1, 768) else local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 26, 444309) msg.DispatchRoleMsgEvent(RoleID, MsgID) end elseif ObjAreaID == 1031 then role.RoleGotoNewMap(MapID, InstanceID, RoleID, 3424073512, 900, 23802, 750) else s60_TryTeleportRole(MapID, InstanceID, RoleID) end end aux.RegisterMapEvent("s60", 7, "s60_OnEnterTriggerArea1") aux.RegisterMapEvent("s60", 6, "s60_OnEnterTriggerArea1") function s60_PlayerEnter(MapID, InstanceID, RoleID) S60_PortalCD[RoleID] = os.time() s60_StartPortalTimer(MapID, InstanceID) end aux.RegisterMapEvent("s60", 2, "s60_PlayerEnter") function s60_OnInit(MapID, InstanceID, CreatureID, CreatureTypeID) s60_StartPortalTimer(MapID, InstanceID) end aux.RegisterMapEvent("s60", 0, "s60_OnInit") -- Dialog portal s02 Tario -> Frontier function c9010122_On_Talk(MapID, InstanceID, TargetID, TargetTypeID, RoleID, TalkIndex) local rolelevel = role.GetRoleLevel(MapID, InstanceID, RoleID) if TalkIndex == -1 then local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 20, 444302) msg.AddMsgEvent(MsgID, 24, TargetID) msg.AddMsgEvent(MsgID, 21, 4) msg.AddMsgEvent(MsgID, 1, 100001) msg.AddMsgEvent(MsgID, 21, 5) msg.AddMsgEvent(MsgID, 1, 100002) msg.DispatchRoleMsgEvent(RoleID, MsgID) elseif TalkIndex == 4 then if rolelevel >= 80 then role.RoleGotoNewMap(MapID, InstanceID, RoleID, 3390518568, 1280, 138, 1240) else local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 20, 444303) msg.AddMsgEvent(MsgID, 24, TargetID) msg.AddMsgEvent(MsgID, 21, 5) msg.AddMsgEvent(MsgID, 1, 100002) msg.DispatchRoleMsgEvent(RoleID, MsgID) end end end aux.RegisterCreatureEvent(9010122, 7, "c9010122_On_Talk") function s60_CanTakeOverWhenOnline(MapID, RoleID) return 3390518568, 638, 6913, 595 end aux.RegisterMapEvent("s60", 12, "s60_CanTakeOverWhenOnline") function s60_GetExporMapAndCoord(MapID, InstanceID, RoleID) return 1, 3424073512, 591, 22982, 176 end aux.RegisterMapEvent("s60", 13, "s60_GetExporMapAndCoord") function s60GetOnePerfectMap(MapID, InstanceID, RoleID) return 1 end aux.RegisterMapEvent("s60", 14, "s60GetOnePerfectMap") function s60_CanEnter(MapID, InstanceID, RoleID) if role.GetRoleLevel(MapID, InstanceID, RoleID) >= 80 then return 1 else return 0 end end aux.RegisterMapEvent("s60", 15, "s60_CanEnter") function s60_FriendEnemy(MapID, InstanceID, SrcID, TargetID) if unit.IsPlayer(SrcID) and unit.IsPlayer(TargetID) then return true, false, false, true end return false, false, false, false end aux.RegisterMapEvent("s60", 16, "s60_FriendEnemy") aux.RegisterMapEvent("s57_1", 16, "s60_FriendEnemy") aux.RegisterMapEvent("s57_2", 16, "s60_FriendEnemy") aux.RegisterMapEvent("s57_3", 16, "s60_FriendEnemy") aux.RegisterMapEvent("s57_4", 16, "s60_FriendEnemy") aux.RegisterMapEvent("s57_9", 16, "s60_FriendEnemy") -- Crystal buff on Cathedral/Bastion enter (do not register event 2 here - each s57_* owns it) function s57_ApplyCrystalBuff(MapID, InstanceID, RoleID) local EquipID = role.GetEquipIDOnPos(RoleID, 13) if EquipID ~= nil then if (EquipID == 8220401 or EquipID == 8220403 or (EquipID >= 8220501 and EquipID <= 8220599)) then unit.AddBuff(MapID, InstanceID, RoleID, 5941702, RoleID) elseif (EquipID == 8220402 or EquipID == 8220404 or (EquipID >= 8220601 and EquipID <= 8220699)) then unit.AddBuff(MapID, InstanceID, RoleID, 5941902, RoleID) end end end