public void AddEntry(User user, HorseInstance horse) { if (Entries.Length + 1 > Slots) { if (Entries.Length + 1 > Slots) { byte[] enterFailed = PacketBuilder.CreateChat(Messages.ArenaFullErrorMessage, PacketBuilder.CHAT_BOTTOM_RIGHT); user.LoggedinClient.SendPacket(enterFailed); GameServer.UpdateArea(user.LoggedinClient); return; } } if (!UserHasHorseEntered(user)) { ArenaEntry arenaEntry = new ArenaEntry(); arenaEntry.EnteredUser = user; arenaEntry.EnteredHorse = horse; entries.Add(arenaEntry); } user.TakeMoney(EntryCost); byte[] enteredIntoCompetition = PacketBuilder.CreateChat(Messages.ArenaEnteredInto, PacketBuilder.CHAT_BOTTOM_RIGHT); user.LoggedinClient.SendPacket(enteredIntoCompetition); GameServer.UpdateAreaForAll(user.X, user.Y, true); return; }
public void DeleteHorse(HorseInstance horse, bool removeFromDb = true) { if (removeFromDb) { Database.RemoveHorse(horse.RandomId); } horsesList.Remove(horse); }
public void AddHorse(HorseInstance horse, bool addToDb = true) { if (HorseList.Length + 1 > baseUser.MaxHorses) { throw new InventoryFullException(); } horse.Owner = baseUser.Id; if (addToDb) { Database.AddHorse(horse); } horsesList.Add(horse); }
public static int CalculateTotalPrice(HorseInstance horse) { HorseInfo.StatCalculator speedStat = new HorseInfo.StatCalculator(horse, HorseInfo.StatType.SPEED); HorseInfo.StatCalculator strengthStat = new HorseInfo.StatCalculator(horse, HorseInfo.StatType.STRENGTH); HorseInfo.StatCalculator conformationStat = new HorseInfo.StatCalculator(horse, HorseInfo.StatType.CONFORMATION); HorseInfo.StatCalculator agilityStat = new HorseInfo.StatCalculator(horse, HorseInfo.StatType.AGILITY); HorseInfo.StatCalculator enduranceStat = new HorseInfo.StatCalculator(horse, HorseInfo.StatType.ENDURANCE); int basePrice = GetPawneerBasePriceForHorse(horse.Breed); int additionalPrice = speedStat.BreedOffset * 350; additionalPrice += strengthStat.BreedOffset * 350; additionalPrice += conformationStat.BreedOffset * 350; additionalPrice += agilityStat.BreedOffset * 350; additionalPrice += enduranceStat.BreedOffset * 350; additionalPrice += horse.BasicStats.Health * 40; additionalPrice += horse.BasicStats.Shoes * 20; int price = basePrice + additionalPrice; return(price); }
public static bool Give(string message, string[] args, User user) { if (args.Length <= 0) { return(false); } if (!user.Administrator) { return(false); } if (args[0].ToUpper() == "OBJECT") { int itemId = 0; try { if (args[1] != "RANDOM") { itemId = int.Parse(args[1]); } else { itemId = Item.GetRandomItem().Id; } Item.GetItemById(itemId); // Calling this makes sure this item id exists. ItemInstance newItemInstance = new ItemInstance(itemId); if (itemId == Item.Present) { newItemInstance.Data = Item.GetRandomItem().Id; } if (args.Length >= 3) { if (args[2] == "ALL") { foreach (GameClient client in GameClient.ConnectedClients) { if (client.LoggedIn) { ItemInstance itmInstance = new ItemInstance(itemId); if (itemId == Item.Present) { itmInstance.Data = Item.GetRandomItem().Id; } client.LoggedinUser.Inventory.AddIgnoringFull(itmInstance); } } } else { findNamePartial(args[2]).Inventory.AddIgnoringFull(newItemInstance); } } else { user.Inventory.AddIgnoringFull(newItemInstance); } } catch (Exception) { return(false); } } else if (args[0].ToUpper() == "HORSE") { int horseId = 0; try { horseId = int.Parse(args[1]); HorseInstance horse = new HorseInstance(HorseInfo.GetBreedById(horseId)); if (args.Length >= 3) { findNamePartial(args[2]).HorseInventory.AddHorse(horse); } else { user.HorseInventory.AddHorse(horse); } } catch (Exception) { return(false); } } else if (args[0].ToUpper() == "AWARD") { int awardId = 0; try { awardId = int.Parse(args[1]); if (args.Length >= 3) { findNamePartial(args[2]).Awards.AddAward(Award.GetAwardById(awardId)); } else { user.Awards.AddAward(Award.GetAwardById(awardId)); } } catch (Exception) { return(false); } } else if (args[0].ToUpper() == "MONEY") { int money = 0; try { money = int.Parse(args[1]); if (args.Length >= 3) { findNamePartial(args[2]).AddMoney(money); } else { user.AddMoney(money); } } catch (Exception) { return(false); } } else if (args[0].ToUpper() == "QUEST") { int questId = 0; try { questId = int.Parse(args[1]); if (args.Length >= 3) { if (args[2].ToUpper() == "FORCE") { Quest.CompleteQuest(user, Quest.GetQuestById(questId)); goto msg; } } Quest.ActivateQuest(user, Quest.GetQuestById(questId)); } catch (Exception) { return(false); } } else { return(false); } msg :; byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT); user.LoggedinClient.SendPacket(chatPacket); return(true); }
public void OfferHorse(HorseInstance horse) { horsesOffered.Add(horse); }
public void RemoveOfferedHorse(HorseInstance horse) { horsesOffered.Remove(horse); }
public static void ExecuteRandomEvent(User user) { while (true) { RandomEvent rngEvent = RandomEvent.GetRandomEvent(); if (rngEvent.HorseHealthDown != 0 && user.HorseInventory.HorseList.Length <= 0) { continue; } if (rngEvent.Text.Contains("%HORSENAME%") && user.HorseInventory.HorseList.Length <= 0) { continue; } int moneyEarned = 0; if (rngEvent.MinMoney != 0 || rngEvent.MaxMoney != 0) { moneyEarned = GameServer.RandomNumberGenerator.Next(rngEvent.MinMoney, rngEvent.MaxMoney); } if (moneyEarned < 0) { if (user.Money + moneyEarned < 0) { continue; } } if (rngEvent.GiveObject != 0) { user.Inventory.AddIgnoringFull(new ItemInstance(rngEvent.GiveObject)); } if (moneyEarned != 0) { user.AddMoney(moneyEarned); } HorseInstance effectedHorse = null; if (user.HorseInventory.HorseList.Length > 0) { int randomHorseIndex = GameServer.RandomNumberGenerator.Next(0, user.HorseInventory.HorseList.Length); effectedHorse = user.HorseInventory.HorseList[randomHorseIndex]; } if (rngEvent.HorseHealthDown != 0) { effectedHorse.BasicStats.Health -= rngEvent.HorseHealthDown; } string horseName = "[This Message Should Not Appear, if it does its a bug.]"; if (effectedHorse != null) { horseName = effectedHorse.Name; } string msg = Messages.FormatRandomEvent(rngEvent.Text, moneyEarned, horseName); byte[] chatPacket = PacketBuilder.CreateChat(Messages.RandomEventPrefix + msg, PacketBuilder.CHAT_BOTTOM_RIGHT); user.LoggedinClient.SendPacket(chatPacket); return; } }
public void DeleteHorse(HorseInstance horse, bool removeFromDb = true) { DeleteHorseId(horse.RandomId, removeFromDb); }
public TackShopGiveaway() { List <World.SpecialTile> specialTiles = new List <World.SpecialTile>(); foreach (World.SpecialTile sTile in World.SpecialTiles) { if (sTile.Code != null) { if (sTile.Code.StartsWith("STORE-")) { int storeId = int.Parse(sTile.Code.Split("-")[1]); Shop shopData = Shop.GetShopById(storeId); if (shopData.BuysItemTypes.Contains("TACK")) { Npc.NpcEntry[] npcShop = Npc.GetNpcByXAndY(sTile.X, sTile.Y); if (npcShop.Length > 0) { specialTiles.Add(sTile); } } } } } string npcName = "ERROR"; string npcDesc = "OBTAINING NAME"; int shpIdx = GameServer.RandomNumberGenerator.Next(0, specialTiles.Count); Location = specialTiles[shpIdx]; Npc.NpcEntry[] npcShops = Npc.GetNpcByXAndY(Location.X, Location.Y); npcName = npcShops[0].Name.Split(" ")[0]; if (npcShops[0].ShortDescription.ToLower().Contains("tack")) { npcDesc = npcShops[0].ShortDescription.Substring(npcShops[0].ShortDescription.ToLower().IndexOf("tack")); ShopName = npcName + "'s " + npcDesc; } else { ShopName = npcName + "'s Gear"; } while (true) { int hrsIdx = GameServer.RandomNumberGenerator.Next(0, HorseInfo.Breeds.Count); HorseInfo.Breed breed = HorseInfo.Breeds[hrsIdx]; if (breed.SpawnInArea == "none") { continue; } HorseGiveaway = new HorseInstance(breed); HorseGiveaway.Name = "Tack Shop Giveaway"; break; } if (World.InTown(Location.X, Location.Y)) { Town = World.GetTown(Location.X, Location.Y); } }