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)); } }
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; } 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; } //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; //Dismiss Follower case 1: 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)); } }