-- Script portals: Magic Valley -> Tario M10_MAP = 3000521423 M10_ScriptPortals = { -- Land on Tario south of MV vortex (616,239), not inside it {x = 908, z = 879, r = 10, map = 3424073512, tx = 616, ty = 23046, tz = 200, minlevel = 10}, {x = 908, z = 869, r = 10, map = 3424073512, tx = 616, ty = 23046, tz = 200, minlevel = 10}, } M10_PortalCD = {} M10_TimerRunning = {} function m10_TryTeleportRole(MapID, InstanceID, RoleID) if MapID ~= M10_MAP then return end local now = os.time() if M10_PortalCD[RoleID] ~= nil and (now - M10_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 M10_ScriptPortals[i] ~= nil do local p = M10_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 local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 26, 400001) msg.DispatchRoleMsgEvent(RoleID, MsgID) return end end M10_PortalCD[RoleID] = now role.RoleGotoNewMap(MapID, InstanceID, RoleID, p.map, p.tx, p.ty, p.tz) return end i = i + 1 end end function m10_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 m10_TryTeleportRole(MapID, InstanceID, RoleID) end end end function m10_StartPortalTimer(MapID, InstanceID) local key = tostring(InstanceID) if M10_TimerRunning[key] then return end M10_TimerRunning[key] = true map.MapCreateColCreature(MapID, InstanceID, 5600085, 1, 1, 1, 1) end function m10_OnEnterTrigger(MapID, InstanceID, RoleID, ObjID) if ObjID == 1071 then local RoleLevel = role.GetRoleLevel(MapID, InstanceID, RoleID) if RoleLevel >= 10 then role.RoleGotoNewMap(MapID, InstanceID, RoleID, 3424073512, 616, 23046, 200) else local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 26, 400001) msg.DispatchRoleMsgEvent(RoleID, MsgID) end else m10_TryTeleportRole(MapID, InstanceID, RoleID) end end aux.RegisterMapEvent("m10", 6, "m10_OnEnterTrigger") aux.RegisterMapEvent("m10", 7, "m10_OnEnterTrigger") function m10_PlayerEnter(MapID, InstanceID, RoleID) M10_PortalCD[RoleID] = os.time() m10_StartPortalTimer(MapID, InstanceID) end aux.RegisterMapEvent("m10", 2, "m10_PlayerEnter") function m10_OnInit(MapID, InstanceID, CreatureID, CreatureTypeID) m10_StartPortalTimer(MapID, InstanceID) end aux.RegisterMapEvent("m10", 0, "m10_OnInit") function c6011105_OnDie(MapID, InstanceID, TargetID, TargetTypeID, RoleID) role.QuestAddRoleItem(MapID, InstanceID, RoleID, -1, 6601289, 1, -1, 420) local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 102, 900290) msg.DispatchRoleMsgEvent(RoleID, MsgID) end aux.RegisterCreatureEvent(6011105, 6, "c6011105_OnDie") function I7000036_OnUse(MapID, InstanceID, TypeID, TargetID) role.AddRoleExp(MapID, InstanceID, TargetID, 2147483647) role.AddRoleExp(MapID, InstanceID, TargetID, 2147483647) role.AddRoleExp(MapID, InstanceID, TargetID, 2147483647) role.AddRoleExp(MapID, InstanceID, TargetID, 2147483647) role.AddRoleExp(MapID, InstanceID, TargetID, 2147483647) role.AddRoleExp(MapID, InstanceID, TargetID, 2147483647) role.AddRoleExp(MapID, InstanceID, TargetID, 2147483647) role.AddRoleExp(MapID, InstanceID, TargetID, 2147483647) role.AddRoleExp(MapID, InstanceID, TargetID, 2147483647) role.AddRoleExp(MapID, InstanceID, TargetID, 2147483647) role.AddRoleExp(MapID, InstanceID, TargetID, 2147483647) role.AddRoleExp(MapID, InstanceID, TargetID, 2147483647) role.AddRoleExp(MapID, InstanceID, TargetID, 2147483647) role.AddRoleExp(MapID, InstanceID, TargetID, 2147483647) role.AddRoleExp(MapID, InstanceID, TargetID, 2147483647) end aux.RegisterItemEvent(7000036, 1, "I7000036_OnUse") function m10_RoleDie(MapID, InstanceID, RoleID, KillerID) if unit.IsPlayer(RoleID) and unit.IsPlayer(KillerID) then role.SetTrialCompleteNum(KillerID, 2016, role.GetTrialCompleteNum(KillerID, 2016) + 1) if role.GetTrialState(KillerID, 2016) == 1 and role.GetTrialCompleteNum(KillerID, 2016) >= Trail_maxnum[2016] then role.TrialComplete(KillerID, 2016) end end end aux.RegisterMapEvent("m10", 5, "m10_RoleDie")