public ArenaController GetAvailableArena() { ArenaController arena = null; foreach (ArenaController arenaController in m_Arenas) { if (arenaController == null) { continue; } if (arenaController.Deleted) { continue; } if (!arenaController.Enabled) { continue; } if (arenaController.m_ArenaFight == null) { return(arenaController); } if (arenaController.m_ArenaFight.Deleted) { return(arenaController); } } return(arena); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); ArenaController = (ArenaController)reader.ReadItem(); //----- if (Items.Count > 0) { m_Timer = new ArenaTrashBarrelEmptyTimer(this); m_Timer.Start(); } m_Instances.Add(this); }
public static ArenaTrashBarrel GetArenaTrashBarrel(ArenaController arenaController) { foreach (ArenaTrashBarrel arenaTrashBarrel in m_Instances) { if (arenaTrashBarrel == null) { continue; } if (arenaTrashBarrel.Deleted) { continue; } if (arenaTrashBarrel.m_ArenaController == arenaController) { return(arenaTrashBarrel); } } return(null); }
public static void StableNewFollower(Mobile vendor, PlayerMobile player, int page) { if (player == null || vendor == null) { return; } if (ArenaController.GetArenaAtLocation(player.Location, player.Map) != null) { player.SendMessage("You cannot access stables while at that location."); return; } if (!player.Alive) { player.SendMessage("You must be alive to do that."); player.CloseGump(typeof(StableGump)); player.SendGump(new StableGump(vendor, player, page)); return; } if (player.AllFollowers.Count == 0) { player.SendMessage("You do not have any followers currently."); player.CloseGump(typeof(StableGump)); player.SendGump(new StableGump(vendor, player, page)); return; } player.SendMessage("Which follower do you wish to stable?"); player.Target = new StableFollowerTarget(vendor, player, page); }
public override void OnResponse(NetState sender, RelayInfo info) { if (m_Player == null) { return; } if (m_Vendor == null) { return; } if (m_Creature == null) { return; } if (m_Vendor.Deleted || !m_Vendor.Alive) { return; } if (m_Creature.Deleted) { return; } if (!m_Player.Alive) { m_Player.SendMessage("You must be alive to do that."); m_Player.CloseGump(typeof(StableGump)); m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page)); return; } if (Utility.GetDistance(m_Vendor.Location, m_Player.Location) >= 15) { m_Player.SendMessage("You are too far away to continue that."); m_Player.CloseGump(typeof(StableGump)); m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page)); return; } if (ArenaController.GetArenaAtLocation(m_Player.Location, m_Player.Map) != null) { m_Player.SendMessage("You cannot access stables while in that location."); return; } if (info.ButtonID == 1) { if (m_Player.Stabled.Contains(m_Creature)) { m_Player.Stabled.Remove(m_Creature); } m_Player.SendSound(m_Creature.GetDeathSound()); m_Creature.Delete(); m_Player.SendMessage("You permanently dismiss the follower."); } m_Player.CloseGump(typeof(StableGump)); m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page)); }
public override void OnResponse(NetState sender, RelayInfo info) { if (m_Player == null) { return; } if (m_Vendor == null) { return; } if (m_Vendor.Deleted || !m_Vendor.Alive) { return; } if (!m_Player.Alive) { m_Player.SendMessage("You must be alive to do that."); return; } if (Utility.GetDistance(m_Vendor.Location, m_Player.Location) >= 15) { m_Player.SendMessage("You are too far away to continue that."); m_Player.CloseGump(typeof(StableGump)); m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page)); return; } if (ArenaController.GetArenaAtLocation(m_Player.Location, m_Player.Map) != null) { m_Player.SendMessage("You cannot access stables while in that location."); return; } bool closeGump = true; int usedStableSlots = Stables.GetUsedStableSlots(m_Player); int maxStableSlots = Stables.GetMaxStableSlots(m_Player); int totalFollowers = m_Player.Stabled.Count; int totalPages = (int)(Math.Ceiling((double)totalFollowers / (double)FollowersPerPage)); if (m_Page >= totalPages) { m_Page = 0; } if (m_Page < 0) { m_Page = 0; } int creatureStartIndex = m_Page * FollowersPerPage; int creatureEndIndex = (m_Page * FollowersPerPage) + (FollowersPerPage - 1); if (creatureEndIndex >= totalFollowers) { creatureEndIndex = totalFollowers - 1; } switch (info.ButtonID) { //Guide case 1: closeGump = false; break; //Previous Page case 2: if (m_Page > 0) { m_Page--; m_Player.SendSound(changeGumpSound); } closeGump = false; break; //Stable New Follower case 3: Stables.StableNewFollower(m_Vendor, m_Player, m_Page); break; //Next Page case 4: if (m_Page < totalPages - 1) { m_Page++; m_Player.SendSound(changeGumpSound); } closeGump = false; break; //Retrieve Lost Followers case 5: int stableSlotsRemaining = Stables.GetMaxStableSlots(m_Player) - Stables.GetUsedStableSlots(m_Player); int stabledCreatures = 0; int unableToStableCount = 0; int packsDropped = 0; Queue m_Queue = new Queue(); Queue m_BackpackQueue = new Queue(); for (int a = 0; a < m_Player.AllFollowers.Count; a++) { BaseCreature bc_Follower = m_Player.AllFollowers[a] as BaseCreature; if (bc_Follower == null) { continue; } if (bc_Follower.Summoned) { continue; } if (bc_Follower.IsStabled) { continue; } if (!(bc_Follower.Controlled && bc_Follower.ControlMaster == m_Player)) { continue; } if (bc_Follower.GetDistanceToSqrt(m_Player.Location) < Stables.RetrieveFollowerMinimumDistance) { continue; } if (bc_Follower.ControlSlots <= stableSlotsRemaining) { stabledCreatures++; stableSlotsRemaining -= bc_Follower.ControlSlots; m_Queue.Enqueue(bc_Follower); } else { unableToStableCount++; } } while (m_Queue.Count > 0) { BaseCreature bc_Follower = (BaseCreature)m_Queue.Dequeue(); if (bc_Follower == null) { continue; } if (bc_Follower.Backpack is StrongBackpack) { if (bc_Follower.Backpack.TotalItems > 0) { packsDropped++; DropBackpack dropBackpack = new DropBackpack(); foreach (Item item in bc_Follower.Backpack.Items) { m_BackpackQueue.Enqueue(item); } while (m_BackpackQueue.Count > 0) { Item item = (Item)m_BackpackQueue.Dequeue(); dropBackpack.DropItem(item); } dropBackpack.MoveToWorld(m_Player.Location, m_Player.Map); } } Stables.StableFollower(m_Vendor, m_Player, bc_Follower, 0, false, true); } if (stabledCreatures > 0 && unableToStableCount == 0) { m_Player.SendMessage("Your lost followers have been successfully stabled."); } else if (stabledCreatures == 0 && unableToStableCount > 0) { m_Player.SendMessage("None of your lost followers were stabled as you have exceeded your maximum stable control slot allotment."); } else if (stabledCreatures > 0 && unableToStableCount > 0) { m_Player.SendMessage("Some of your lost followers were unable to be stabled as you have exceeded your maximum stable control slot allotment."); } else if (stabledCreatures == 0 && unableToStableCount == 0) { m_Player.SendMessage("You do not currently have any lost followers at the moment."); } if (packsDropped > 0) { m_Player.SendMessage(2550, "One or more of your lost pack creatures have left their pack's contents at your feet."); } closeGump = false; break; } //Follower if (info.ButtonID >= 10) { int creatureIndex = (int)(Math.Floor((double)info.ButtonID / 10)) - 1; int buttonPressed = info.ButtonID % 10; if (creatureIndex < m_Player.Stabled.Count) { BaseCreature bc_Creature = m_Player.Stabled[creatureIndex] as BaseCreature; if (bc_Creature != null) { if (bc_Creature.IsStabled) { switch (buttonPressed) { //Claim Follower case 0: if (m_Player.RecentlyInCombat) { m_Player.SendMessage("You have been in combat too recently to claim a follower."); } else if (m_Player.RecentlyInPlayerCombat) { m_Player.SendMessage("You have been in combat with another player too recently claim a follower."); } else if (bc_Creature.ControlSlots + m_Player.Followers > m_Player.FollowersMax) { m_Player.SendMessage("You do not have enough control slots available to claim that follower."); } else { int goldCost = Stables.GetClaimCost(m_Vendor, m_Player, bc_Creature); if (Banker.GetBalance(m_Player) < goldCost) { m_Player.SendMessage("You do not have enough gold in your bank to claim that follower."); } else { Banker.Withdraw(m_Player, goldCost); Stables.ClaimFollower(m_Vendor, m_Player, bc_Creature, m_Page); m_Player.SendSound(0x2E6); } } break; //Animal Lore case 1: m_Player.CloseGump(typeof(StableGump)); m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page)); m_Player.SendGump(new AnimalLoreGump(m_Player, new AnimalLoreGumpObject(bc_Creature))); m_Player.SendSound(openGumpSound); return; break; //Dismiss Follower case 2: m_Player.CloseGump(typeof(StableDismissFollowerGump)); m_Player.SendGump(new StableDismissFollowerGump(m_Vendor, m_Player, bc_Creature, m_Page)); m_Player.SendSound(openGumpSound); return; break; } } else { //If Somehow Still in Stabled List but Not Set as Stabled if (m_Player.Stabled.Contains(bc_Creature)) { m_Player.Stabled.Remove(bc_Creature); } } } } closeGump = false; } if (!closeGump) { m_Player.CloseGump(typeof(StableGump)); m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page)); } }
protected override void OnTarget(Mobile from, object target) { if (m_Player == null) { return; } if (m_Vendor == null) { return; } if (m_Vendor.Deleted || !m_Vendor.Alive) { return; } if (ArenaController.GetArenaAtLocation(m_Player.Location, m_Player.Map) != null) { m_Player.SendMessage("You cannot access stables while at that location."); return; } if (!m_Player.Alive) { m_Player.SendMessage("You must be alive to do that."); m_Player.CloseGump(typeof(StableGump)); m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page)); return; } if (Utility.GetDistance(m_Vendor.Location, m_Player.Location) >= 15) { m_Player.SendMessage("You are too far away to continue that."); m_Player.CloseGump(typeof(StableGump)); m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page)); return; } if (!(target is BaseCreature)) { m_Player.SendMessage("That is not a valid follower."); m_Player.CloseGump(typeof(StableGump)); m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page)); return; } BaseCreature bc_Target = target as BaseCreature; if (Utility.GetDistance(m_Player.Location, bc_Target.Location) >= 8) { m_Player.SendMessage("That follower is too far away."); m_Player.CloseGump(typeof(StableGump)); m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page)); return; } if (!m_Player.InLOS(bc_Target) || bc_Target.Hidden) { m_Player.SendMessage("That follower cannot be seen."); m_Player.CloseGump(typeof(StableGump)); m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page)); return; } if (bc_Target.Summoned) { m_Player.SendMessage("That type of follower cannot be stabled."); m_Player.CloseGump(typeof(StableGump)); m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page)); return; } if (!(bc_Target.Controlled && bc_Target.ControlMaster is PlayerMobile)) { m_Player.SendMessage("That follower does not belong to you."); m_Player.CloseGump(typeof(StableGump)); m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page)); return; } if (bc_Target.RecentlyInCombat) { m_Player.SendMessage("That follower has been in combat too recently to be stabled."); m_Player.CloseGump(typeof(StableGump)); m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page)); return; } if (bc_Target.RecentlyInPlayerCombat) { m_Player.SendMessage("You have been in combat with another player too recently for that follower to be stabled."); m_Player.CloseGump(typeof(StableGump)); m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page)); return; } if (bc_Target.Backpack is StrongBackpack) { if (bc_Target.Backpack.Items.Count > 0) { m_Player.SendMessage("You must clear that follower's backpack of items before it may be stabled."); m_Player.CloseGump(typeof(StableGump)); m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page)); return; } } if (bc_Target.ControlSlots + Stables.GetUsedStableSlots(m_Player) > Stables.GetMaxStableSlots(m_Player)) { m_Player.SendMessage("You have exceeded your maximum stable control slot allotment."); m_Player.CloseGump(typeof(StableGump)); m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page)); return; } StableFollower(m_Vendor, m_Player, bc_Target, m_Page, true, false); }
protected override void OnTick() { if (m_ArenaGroupController == null) { Stop(); return; } if (m_ArenaGroupController.Deleted) { Stop(); return; } if (!m_ArenaGroupController.Enabled) { Stop(); return; } if (DateTime.UtcNow >= m_ArenaGroupController.m_NextListingAudit) { m_ArenaGroupController.AuditListings(); } ArenaController emptyArena = m_ArenaGroupController.GetAvailableArena(); if (emptyArena != null) { foreach (ArenaMatch arenaMatch in m_ArenaGroupController.m_MatchListings) { if (!ArenaMatch.IsValidArenaMatch(arenaMatch, null, false)) { continue; } if (DateTime.UtcNow < arenaMatch.m_NextReadyCheck) { continue; } if (!arenaMatch.IsReadyToStart()) { continue; } List <KeyValuePair <PlayerMobile, ArenaRuleset.ArenaRulesetFailureType> > m_RulesetViolations = new List <KeyValuePair <PlayerMobile, ArenaRuleset.ArenaRulesetFailureType> >(); bool rulesetViolationExists = false; foreach (ArenaTeam arenaTeam in arenaMatch.m_Teams) { if (arenaTeam == null) { continue; } if (arenaTeam.Deleted) { continue; } foreach (ArenaParticipant arenaParticipant in arenaTeam.m_Participants) { if (arenaParticipant == null) { continue; } if (arenaParticipant.Deleted) { continue; } if (arenaParticipant.m_Player == null) { continue; } if (arenaParticipant.Deleted == null) { continue; } if (arenaMatch.m_Ruleset == null) { continue; } ArenaRuleset.ArenaRulesetFailureType rulesetFailure = arenaMatch.m_Ruleset.CheckForRulesetViolations(arenaMatch, arenaParticipant.m_Player); m_RulesetViolations.Add(new KeyValuePair <PlayerMobile, ArenaRuleset.ArenaRulesetFailureType>(arenaParticipant.m_Player, rulesetFailure)); if (rulesetFailure != ArenaRuleset.ArenaRulesetFailureType.None) { rulesetViolationExists = true; } } } if (rulesetViolationExists) { arenaMatch.BroadcastMessage("Unable to start match due to the following ruleset violations:", 0); bool arenaError = false; foreach (KeyValuePair <PlayerMobile, ArenaRuleset.ArenaRulesetFailureType> rulesetViolation in m_RulesetViolations) { string message = ""; PlayerMobile player = rulesetViolation.Key; ArenaRuleset.ArenaRulesetFailureType rule = rulesetViolation.Value; if (player == null) { continue; } switch (rulesetViolation.Value) { case ArenaRuleset.ArenaRulesetFailureType.ArenaInvalid: arenaError = true; break; case ArenaRuleset.ArenaRulesetFailureType.Dead: message = player.RawName + ": Not Alive"; break; case ArenaRuleset.ArenaRulesetFailureType.EquipmentAllowed: message = player.RawName + ": Has Restricted Equipment (worn or in backpack)"; break; case ArenaRuleset.ArenaRulesetFailureType.Follower: message = player.RawName + ": Exceeds Follower Control Slots Allowed"; break; case ArenaRuleset.ArenaRulesetFailureType.PackAnimal: message = player.RawName + ": Pack Animals Not Allowed"; break; case ArenaRuleset.ArenaRulesetFailureType.Mount: message = player.RawName + ": Mounts Not Allowed"; break; case ArenaRuleset.ArenaRulesetFailureType.NotInArenaRegion: message = player.RawName + ": Outside of Arena Region"; break; case ArenaRuleset.ArenaRulesetFailureType.NotOnline: message = player.RawName + ": Not Online"; break; case ArenaRuleset.ArenaRulesetFailureType.PoisonedWeapon: message = player.RawName + ": Exceeds Allowed Number of Poisoned Weapons"; break; case ArenaRuleset.ArenaRulesetFailureType.Transformed: message = player.RawName + ": Transformed or Disguised"; break; case ArenaRuleset.ArenaRulesetFailureType.Young: message = player.RawName + ": Young Status"; break; case ArenaRuleset.ArenaRulesetFailureType.NotEnoughArenaCredits: message = player.RawName + ": Insufficient Arena Credits"; break; } if (message != "") { arenaMatch.BroadcastMessage(message, 1256); } } if (arenaError) { arenaMatch.BroadcastMessage("Arena Configuration Error", 1256); } arenaMatch.m_NextReadyCheck = DateTime.UtcNow + ArenaMatch.ReadyCheckInterval; string timeRemaining = Utility.CreateTimeRemainingString(DateTime.UtcNow, arenaMatch.m_NextReadyCheck, false, true, true, true, true); arenaMatch.BroadcastMessage("Match will re-attempt to start in " + timeRemaining + ".", 0); } else { arenaMatch.m_MatchStatus = ArenaMatch.MatchStatusType.Fighting; ArenaFight arenaFight = new ArenaFight(); arenaFight.m_ArenaController = emptyArena; arenaFight.m_ArenaMatch = arenaMatch; arenaMatch.m_ArenaFight = arenaFight; emptyArena.m_ArenaFight = arenaFight; arenaFight.Initialize(); } } } }