private static bool CheckFull(BaseInstance instance, Character chr) { if (instance.MaxPlayerCount != 0 && instance.PlayerCount >= instance.MaxPlayerCount && !chr.GodMode) { //chr.SendSystemMessage("Instance full: {0}/{1}", instance.PlayerCount, instance.MaxPlayerCount); MovementHandler.SendTransferFailure(chr.Client, instance.Id, MapTransferError.TRANSFER_ABORT_MAX_PLAYERS); return(false); } return(true); }
private static bool CheckFull(BaseInstance instance, Character chr) { if (instance.MaxPlayerCount == 0 || instance.PlayerCount < instance.MaxPlayerCount || chr.GodMode) { return(true); } MovementHandler.SendTransferFailure(chr.Client, instance.Id, MapTransferError.TRANSFER_ABORT_MAX_PLAYERS); return(false); }
/// <summary> /// Binds the instance /// </summary> public void BindTo(BaseInstance instance) { var bindings = GetOrCreateBindingList(instance.Difficulty.BindingType); lock (bindings) { if (bindings.Count >= InstanceMgr.MaxInstancesPerHour) { log.Error("{0} was saved to \"{1}\" but exceeded the MaxInstancesPerCharPerHour limit.", m_character, instance); } bindings.Add(new InstanceBinding(instance.InstanceId, instance.Id, instance.Difficulty.Index)); } }
/// <summary>Binds the instance</summary> public void BindTo(BaseInstance instance) { List <InstanceBinding> bindingList = this.GetOrCreateBindingList(instance.Difficulty.BindingType); lock (bindingList) { if (bindingList.Count >= InstanceMgr.MaxInstancesPerHour) { InstanceCollection.log.Error( "{0} was saved to \"{1}\" but exceeded the MaxInstancesPerCharPerHour limit.", (object)this.m_character, (object)instance); } bindingList.Add(new InstanceBinding(instance.InstanceId, instance.Id, instance.Difficulty.Index)); } }
/// <param name="creator">Can be null</param> private static BaseInstance SetupInstance(Character creator, BaseInstance instance, InstanceTemplate template, uint difficultyIndex = 0) { if (instance != null) { instance.difficulty = template.MapTemplate.GetDifficulty(difficultyIndex) ?? template.MapTemplate.Difficulties[0]; if (creator != null) { instance.m_OwningFaction = creator.FactionGroup; instance.Owner = creator.InstanceLeader; instance.IsActive = true; } instance.InitMap(template.MapTemplate); Instances.AddInstance(instance.MapId, instance); } return(instance); }
/// <summary> /// Checks the list of stored Raid and Heroic instances and the list of recently run Normal /// instances for a reference to the given map. /// </summary> /// <param name="template">The MapInfo of the Instance in question.</param> /// <returns>The Instance if found, else null.</returns> public BaseInstance GetActiveInstance(MapTemplate template) { Character character = Character; if (character == null) { return(null); } InstanceBinding binding = GetBinding(template.Id, template.GetDifficulty(character.GetInstanceDifficulty(template.IsRaid)).BindingType); if (binding != null) { BaseInstance instance = InstanceMgr.Instances.GetInstance(binding.MapId, binding.InstanceId); if (instance != null && instance.IsActive) { return(instance); } } return(null); }
/// <summary>Convinience method for development</summary> /// <param name="creator">Can be null</param> public static BaseInstance CreateInstance(Character creator, MapId mapId) { MapTemplate mapTemplate = World.GetMapTemplate(mapId); if (mapTemplate == null || !mapTemplate.IsInstance) { return(null); } uint difficultyIndex; if (creator != null) { creator.EnsurePureStaffGroup(); difficultyIndex = creator.GetInstanceDifficulty(mapTemplate.IsRaid); } else { difficultyIndex = 0U; } BaseInstance instance = mapTemplate.InstanceTemplate.Create(); return(SetupInstance(creator, instance, mapTemplate.InstanceTemplate, difficultyIndex)); }
/// <summary> /// Binds the instance /// </summary> public void BindTo(BaseInstance instance) { var bindings = GetOrCreateBindingList(instance.Difficulty.BindingType); lock (bindings) { if (bindings.Count >= InstanceMgr.MaxInstancesPerHour) { log.Error("{0} was saved to \"{1}\" but exceeded the MaxInstancesPerCharPerHour limit.", m_character, instance); } bindings.Add(new InstanceBinding(instance.InstanceId, instance.Id, instance.Difficulty.Index)); } }
/// <param name="creator">Can be null</param> public static BaseInstance CreateInstance(Character creator, InstanceTemplate template, uint difficultyIndex) { BaseInstance instance = template.Create(); return(SetupInstance(creator, instance, template, difficultyIndex)); }
/// <summary> /// This is called when an area trigger causes entering an instance /// </summary> public static bool EnterInstance(Character chr, MapTemplate mapTemplate, Vector3 targetPos) { if (!mapTemplate.IsInstance) { log.Error("Character {0} tried to enter \"{1}\" as Instance.", chr, mapTemplate); return(false); } bool isRaid = mapTemplate.Type == MapType.Raid; Group group = chr.Group; if (isRaid && !chr.Role.IsStaff && !group.Flags.HasFlag(GroupFlags.Raid)) { InstanceHandler.SendRequiresRaid(chr.Client, 0); return(false); } if (!mapTemplate.MayEnter(chr)) { return(false); } chr.SendSystemMessage("Entering instance..."); InstanceCollection instances = chr.Instances; BaseInstance instance = instances.GetActiveInstance(mapTemplate); if (instance == null) { if (mapTemplate.GetDifficulty(chr.GetInstanceDifficulty(isRaid)).BindingType == BindingType.Soft && !instances.HasFreeInstanceSlot && !chr.GodMode) { MovementHandler.SendTransferFailure(chr.Client, mapTemplate.Id, MapTransferError.TRANSFER_ABORT_TOO_MANY_INSTANCES); return(false); } if (group != null) { instance = group.GetActiveInstance(mapTemplate); if (instance != null && !CheckFull(instance, chr)) { return(false); } } if (instance == null) { instance = CreateInstance(chr, mapTemplate.InstanceTemplate, chr.GetInstanceDifficulty(isRaid)); if (instance == null) { log.Warn("Could not create Instance \"{0}\" for: {1}", mapTemplate, chr); return(false); } } } else if (!chr.GodMode) { if (!CheckFull(instance, chr)) { return(false); } if (isRaid) { if (group == null) { MovementHandler.SendTransferFailure(chr.Client, instance.Id, MapTransferError.TRANSFER_ABORT_NEED_GROUP); return(false); } InstanceBinding binding1 = group.InstanceLeaderCollection.GetBinding(mapTemplate.Id, BindingType.Hard); InstanceBinding binding2 = instances.GetBinding(mapTemplate.Id, BindingType.Hard); if (binding2 != null && binding1 != binding2) { MovementHandler.SendTransferFailure(chr.Client, instance.Id, MapTransferError.TRANSFER_ABORT_NOT_FOUND); return(false); } } } instance.TeleportInside(chr, targetPos); return(true); }
protected InstanceSettings(BaseInstance instance) { Instance = instance; }
public RaidInstanceSettings(BaseInstance instance) : base(instance) { }