private static void AddOrcish(ItemCollection loot, int enemyEntityID) { int roll = UnityEngine.Random.Range(0, 101) + (luckMod - 5); bool addOrcishItem = false; if ((enemyEntityID == (int)MobileTypes.OrcWarlord && roll > 80) || (enemyEntityID == (int)MobileTypes.OrcShaman && roll > 90) || (enemyEntityID == (int)MobileTypes.OrcSergeant && roll > 95) || (enemyEntityID == (int)MobileTypes.Orc && roll > 98)) { addOrcishItem = true; } if (addOrcishItem) { int typeRoll = UnityEngine.Random.Range(0, 100); DaggerfallUnityItem item; if (typeRoll > 50) { Weapons weapon = (Weapons)UnityEngine.Random.Range((int)Weapons.Dagger, (int)Weapons.Long_Bow + 1); item = ItemBuilder.CreateItem(ItemGroups.Weapons, (int)weapon); ItemBuilder.ApplyWeaponMaterial(item, WeaponMaterialTypes.Orcish); item.currentCondition = (int)(UnityEngine.Random.Range(0.3f, 0.75f) * item.maxCondition); loot.AddItem(item); } else { Armor armor = (Armor)UnityEngine.Random.Range((int)Armor.Cuirass, (int)Armor.Tower_Shield + 1); item = ItemBuilder.CreateItem(ItemGroups.Armor, (int)armor); ItemBuilder.ApplyArmorMaterial(item, ArmorMaterialTypes.Orcish); item.currentCondition = (int)(UnityEngine.Random.Range(0.3f, 0.75f) * item.maxCondition); loot.AddItem(item); } } }
protected virtual ItemCollection GetThiefItems() { PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; ItemCollection items = new ItemCollection(); //int numOfItems = (buildingDiscoveryData.quality / 2) + 1; //int numOfItems = (playerEntity.Stats.LiveLuck / 10) + UnityEngine.Random.Range(1, 5); //int seed = (int)(DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime() / DaggerfallDateTime.MinutesPerDay); //UnityEngine.Random.InitState(seed); //for (int i = 0; i <= numOfItems; i++) //{ // DaggerfallUnityItem thiefItem; // thiefItem = ItemBuilder.CreateItem(ItemGroups.MiscItems, ThiefOverhaul.templateIndex_Ring); // items.AddItem(thiefItem); //} items.AddItem(ItemBuilder.CreateItem(ItemGroups.MiscItems, ThiefOverhaul.templateIndex_Ring)); items.AddItem(ItemBuilder.CreateItem(ItemGroups.MiscItems, ThiefOverhaul.templateIndex_Mark)); items.AddItem(ItemBuilder.CreateItem(ItemGroups.MiscItems, ThiefOverhaul.templateIndex_Bracelet)); items.AddItem(ItemBuilder.CreateItem(ItemGroups.MiscItems, ThiefOverhaul.templateIndex_Bracer)); items.AddItem(ItemBuilder.CreateItem(ItemGroups.MiscItems, ThiefOverhaul.templateIndex_Crystal)); Debug.Log("GetThiefItems finished."); return(items); }
private static void AddDaedric(ItemCollection loot, int enemyEntityID) { int roll = UnityEngine.Random.Range(0, 101) + (luckMod - 5); bool addDaedricItem = false; if ((enemyEntityID == (int)MobileTypes.DaedraLord && roll > 70) || (enemyEntityID == (int)MobileTypes.DaedraSeducer && roll > 75) || ((enemyEntityID == (int)MobileTypes.FireDaedra || enemyEntityID == (int)MobileTypes.FrostDaedra) && roll > 80) || (enemyEntityID == (int)MobileTypes.Daedroth && roll > 80)) { addDaedricItem = true; } if (addDaedricItem) { int typeRoll = UnityEngine.Random.Range(0, 100); DaggerfallUnityItem item; if (typeRoll > 50 || enemyEntityID == (int)MobileTypes.DaedraSeducer) { Weapons weapon = (Weapons)UnityEngine.Random.Range((int)Weapons.Dagger, (int)Weapons.Long_Bow + 1); item = ItemBuilder.CreateItem(ItemGroups.Weapons, (int)weapon); ItemBuilder.ApplyWeaponMaterial(item, WeaponMaterialTypes.Daedric); item.currentCondition = (int)(UnityEngine.Random.Range(0.3f, 0.75f) * item.maxCondition); loot.AddItem(item); } else { Armor armor = (Armor)UnityEngine.Random.Range((int)Armor.Cuirass, (int)Armor.Tower_Shield + 1); item = ItemBuilder.CreateItem(ItemGroups.Armor, (int)armor); ItemBuilder.ApplyArmorMaterial(item, ArmorMaterialTypes.Daedric); item.currentCondition = (int)(UnityEngine.Random.Range(0.3f, 0.75f) * item.maxCondition); loot.AddItem(item); } } }
/// <summary> /// Randomly add a map /// </summary> public void RandomlyAddMap(int chance) { if (Random.Range(1, 101) <= chance) { DaggerfallUnityItem map = new DaggerfallUnityItem(ItemGroups.MiscItems, 8); items.AddItem(map); } }
protected virtual void Refresh() { // Update labels goldLabel.Text = GameManager.Instance.PlayerEntity.GetGoldAmount().ToString(); // Add ingredient items to list and gather recipes - from inventory and wagon ingredients.Clear(); List <DaggerfallUnityItem> recipeItems = new List <DaggerfallUnityItem>(); foreach (ItemCollection playerItems in new ItemCollection[] { GameManager.Instance.PlayerEntity.Items, GameManager.Instance.PlayerEntity.WagonItems }) { for (int i = 0; i < playerItems.Count; i++) { DaggerfallUnityItem item = playerItems.GetItem(i); if (item.IsIngredient && !item.IsEnchanted) { ingredients.AddItem(item.Clone()); } else if (item.IsPotionRecipe) { recipeItems.Add(item); } } } RefreshIngredientsList(); ingredientsListScroller.Items = ingredientsList; // Clear cauldron and assign to scroller cauldron.Clear(); cauldronListScroller.Items = cauldron; // Populate picker from recipe items recipes.Clear(); recipePicker.ListBox.ClearItems(); foreach (DaggerfallUnityItem recipeItem in recipeItems) { PotionRecipe potionRecipe = GameManager.Instance.EntityEffectBroker.GetPotionRecipe(recipeItem.PotionRecipeKey); if (!recipes.Contains(potionRecipe)) { recipes.Add(potionRecipe); } } recipes.Sort((x, y) => (x.DisplayName.CompareTo(y.DisplayName))); foreach (PotionRecipe potionRecipe in recipes) { recipePicker.ListBox.AddItem(potionRecipe.DisplayName); } }
public void AddItem() { ItemCollection items = new ItemCollection(); items.AddItem(new Journal("marko", 1, "sfarim", 56, "04/07/2010", "lll", 0)); Assert.IsTrue(items.Items.Count == 1); }
/// <summary> /// Randomly add a potion /// </summary> public static void RandomlyAddPotion(int chance, ItemCollection collection) { if (Dice100.SuccessRoll(chance)) { collection.AddItem(ItemBuilder.CreateRandomPotion()); } }
/// <summary> /// Randomly add a potion /// </summary> public static void RandomlyAddPotion(int chance, ItemCollection collection) { if (Random.Range(1, 101) < chance) { collection.AddItem(ItemBuilder.CreateRandomPotion()); } }
public override void MoveItem(uint uid, int quantity) { if (!IsReady) { CharacterItemRecord item = Character.Inventory.GetItem(uid); if (item != null && CanMoveItem(item, quantity)) { if (SecondTrader.GetDialog <PlayerTradeExchange>().IsReady) { SecondTrader.GetDialog <PlayerTradeExchange>().Ready(false, 0); } if (quantity > 0) { if (item.Quantity >= quantity) { ExchangedItems.AddItem(item, (uint)quantity); } } else { ExchangedItems.RemoveItem(item.UId, (uint)(Math.Abs(quantity))); } } } }
public override void MoveItem(uint uid, int quantity) { if (quantity > 0) { CharacterItemRecord item = Character.Inventory.GetItem(uid); if (item != null && item.Quantity >= quantity && item.CanBeExchanged()) { var bankItem = item.ToBankItemRecord(Character.Client.Account.Id); bankItem.Quantity = (uint)quantity; Character.Inventory.RemoveItem(item.UId, (uint)quantity); m_items.AddItem(bankItem); } } else { BankItemRecord item = m_items.GetItem(uid); uint removedQuantity = (uint)Math.Abs(quantity); if (item != null && item.Quantity >= removedQuantity) { var characterItemRecord = item.ToCharacterItemRecord(Character.Id); characterItemRecord.Quantity = removedQuantity; m_items.RemoveItem(uid, removedQuantity); Character.Inventory.AddItem(characterItemRecord); } } }
// TODO: replace with proper merchant item generation... // classic seems to have a deterministic method for generating magic items being sold ItemCollection GetMerchantMagicItems() { if (merchantItems == null) { PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; ItemCollection items = new ItemCollection(); DaggerfallUnityItem magicArm = ItemBuilder.CreateRandomArmor(playerEntity.Level, playerEntity.Gender, playerEntity.Race); magicArm.legacyMagic = new int[] { 1, 87, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535 }; items.AddItem(magicArm); DaggerfallUnityItem magicWeap = ItemBuilder.CreateRandomWeapon(playerEntity.Level); magicWeap.legacyMagic = new int[] { 1, 87, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535 }; items.AddItem(magicWeap); merchantItems = items; } return(merchantItems); }
private void EntityLoot_OnEntityDeath(Entity obj) { if (Random.Range(0, 1) < entity.Data.FindParameterFloat("LootChance")) { PI.AddItem(entity.Data.FindParameterString("Loot")); } }
ItemCollection GetMerchantMagicItems(bool onlySoulGems = false) { PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; ItemCollection items = new ItemCollection(); int numOfItems = (buildingDiscoveryData.quality / 2) + 1; // Seed random from game time to rotate magic stock every 24 game hours // This more or less resolves issue of magic item stock not being deterministic every time player opens window // Doesn't match classic exactly as classic stocking method unknown, but should be "good enough" for now int seed = (int)(DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime() / DaggerfallDateTime.MinutesPerDay); UnityEngine.Random.InitState(seed); if (!onlySoulGems) { for (int i = 0; i <= numOfItems; i++) { // Create magic item which is already identified DaggerfallUnityItem magicItem = ItemBuilder.CreateRandomMagicItem(playerEntity.Level, playerEntity.Gender, playerEntity.Race); magicItem.IdentifyItem(); items.AddItem(magicItem); } items.AddItem(ItemBuilder.CreateItem(ItemGroups.MiscItems, (int)MiscItems.Spellbook)); } if (guild.CanAccessService(GuildServices.BuySoulgems)) { for (int i = 0; i <= numOfItems; i++) { DaggerfallUnityItem magicItem; if (Dice100.FailedRoll(25)) { // Empty soul trap magicItem = ItemBuilder.CreateItem(ItemGroups.MiscItems, (int)MiscItems.Soul_trap); magicItem.value = 5000; magicItem.TrappedSoulType = MobileTypes.None; } else { // Filled soul trap magicItem = ItemBuilder.CreateRandomlyFilledSoulTrap(); } items.AddItem(magicItem); } } return(items); }
ItemCollection GetMerchantMagicItems() { if (merchantItems == null) { PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; ItemCollection items = new ItemCollection(); int numOfItems = (buildingDiscoveryData.quality / 2) + 1; for (int i = 0; i <= numOfItems; i++) { DaggerfallUnityItem magicItem = ItemBuilder.CreateRandomMagicItem(playerEntity.Level, playerEntity.Gender, playerEntity.Race); // Item is already identified magicItem.flags |= 0x20; items.AddItem(magicItem); } items.AddItem(ItemBuilder.CreateItem(ItemGroups.MiscItems, (int)MiscItems.Spellbook)); if (guild.Rank >= 4) { for (int i = 0; i <= numOfItems; i++) { DaggerfallUnityItem magicItem = ItemBuilder.CreateItem(ItemGroups.MiscItems, (int)MiscItems.Soul_trap); magicItem.value = 5000; if (UnityEngine.Random.Range(1, 101) >= 25) { magicItem.TrappedSoulType = MobileTypes.None; } else { int id = UnityEngine.Random.Range(0, 43); magicItem.TrappedSoulType = (MobileTypes)id; MobileEnemy mobileEnemy = GameObjectHelper.EnemyDict[id]; magicItem.value += mobileEnemy.SoulPts; } items.AddItem(magicItem); } } merchantItems = items; } return(merchantItems); }
public override bool UseItem(ItemCollection collection) { if (!GameManager.Instance.PlayerEnterExit.IsPlayerInsideDungeon) { DaggerfallUI.MessageBox(FAIL_ACTIVATE_MSG); } else { int exploredPercent = Automap.instance.ExploredPercentage(); LocatorDevice locatorDevice = Object.FindObjectOfType <LocatorDevice>(); if (locatorDevice != null) { if (nativeMaterialValue == INACTIVE) { if (!locatorDevice.enabled) { int requiredExploration = (value * BASEACTIVATION_EXPLORATION) / BASEVALUE; if (DaggerfallUnity.Settings.SmallerDungeons) { requiredExploration *= 2; } Debug.LogFormat("Explored: {0} Required: {1}", exploredPercent, requiredExploration); if (exploredPercent < requiredExploration) { DaggerfallUI.MessageBox(EXPLORATION_NEEDED_MSG); } else { if (stackCount > 1) { stackCount -= 1; } else { collection.RemoveItem(this); } LocatorItem activeLocator = new LocatorItem(); activeLocator.nativeMaterialValue = ACTIVATED; collection.AddItem(activeLocator, ItemCollection.AddPosition.DontCare, true); locatorDevice.ActivateDevice(); DaggerfallUI.MessageBox(ACTIVATION_MSG); } } } else { collection.RemoveItem(this); locatorDevice.DeactivateDevice(); DaggerfallUI.MessageBox(DEACTIVATION_MSG); } } else { Debug.Log("Can't find locator device object."); } } return(true); }
/// <summary> /// Randomly add a map /// </summary> public static void RandomlyAddMap(int chance, ItemCollection collection) { if (Dice100.SuccessRoll(chance)) { DaggerfallUnityItem map = new DaggerfallUnityItem(ItemGroups.MiscItems, 8); collection.AddItem(map); } }
/// <summary> /// Randomly add a map /// </summary> public static void RandomlyAddMap(int chance, ItemCollection collection) { if (Random.Range(1, 101) <= chance) { DaggerfallUnityItem map = new DaggerfallUnityItem(ItemGroups.MiscItems, 8); collection.AddItem(map); } }
public void IndexerByPredicate() { ItemCollection items = new ItemCollection(); Journal journal = new Journal("mark", 1, "sfari", 56, "04/07/2010", "lll", 0); items.AddItem(journal); Assert.IsTrue(items[x => x.Publisher == "sfari"].Count == 1); }
public void IndexerByISBN() { ItemCollection items = new ItemCollection(); Journal journal = new Journal("marko", 1, "sfarim", 56, "04/07/2010", "lll", 0); items.AddItem(journal); Assert.AreEqual(journal, items[13]); }
public void RentItem() { ItemCollection items = new ItemCollection(); Journal journal = new Journal("mark", 1, "sfari", 56, "04/07/2010", "lll", 0); items.AddItem(journal); Assert.IsTrue(items.RentItem(journal)); }
public void OnAdd(OnInventoryAddEventData e) { Items.AddItem(e.Item); e.Item.Emitter.Emit(new OnItemCollectEventData( gameObject )); InventoryUI.RefreshRenderedItems(); }
public void IndexerByName() { ItemCollection items = new ItemCollection(); Journal journal = new Journal("mark", 1, "sfarim", 56, "04/07/2010", "lll", 0); items.AddItem(journal); Assert.IsInstanceOfType(items["mark"], typeof(List <AbstractItem>)); }
/// <summary> /// Queues an item to be added to Foe inventory. /// Clone of item will be added to all instances of Foe, current and future. /// </summary> /// <param name="item">Item to add.</param> public void QueueItem(DaggerfallUnityItem item) { if (itemQueue == null) { itemQueue = new ItemCollection(); } itemQueue.AddItem(item); }
/// <summary> /// Assigns character items from classic save tree. /// </summary> public void AssignItems(SaveTree saveTree) { // Find character record, should always be a singleton CharacterRecord characterRecord = (CharacterRecord)saveTree.FindRecord(RecordTypes.Character); if (characterRecord == null) { return; } // Find all character-owned items List <SaveTreeBaseRecord> itemRecords = saveTree.FindRecords(RecordTypes.Item, characterRecord); // Filter for container-based inventory items List <SaveTreeBaseRecord> filteredRecords = saveTree.FilterRecordsByParentType(itemRecords, RecordTypes.Container); // Add interim Daggerfall Unity items foreach (var record in filteredRecords) { // Get container parent ContainerRecord containerRecord = (ContainerRecord)record.Parent; // Create item, grabbing trapped soul if needed DaggerfallUnityItem newItem = new DaggerfallUnityItem((ItemRecord)record); if (newItem.ItemGroup == ItemGroups.MiscItems && newItem.GroupIndex == 1) { if (record.Children.Count > 0) { TrappedSoulRecord soulRecord = (TrappedSoulRecord)record.Children[0]; newItem.TrappedSoulType = (MobileTypes)soulRecord.RecordRoot.SpriteIndex; } else { newItem.TrappedSoulType = MobileTypes.None; } } // Add to local inventory or wagon if (containerRecord.IsWagon) { wagonItems.AddItem(newItem); } else { items.AddItem(newItem); } // Equip to player if equipped in save for (int i = 0; i < characterRecord.ParsedData.equippedItems.Length; i++) { if (characterRecord.ParsedData.equippedItems[i] == record.RecordRoot.RecordID) { equipTable.EquipItem(newItem, true, false); } } } }
static ItemCollection GetLocatorDevices(int number, int value) { ItemCollection locators = new ItemCollection(); for (int i = 0; i < number; i++) { locators.AddItem(new LocatorItem(value), ItemCollection.AddPosition.DontCare, true); } return(locators); }
// TODO: classic seems to generate each time player select buy potions.. should we make more persistent for DFU? ItemCollection GetMerchantPotions() { ItemCollection potions = new ItemCollection(); for (int n = UnityEngine.Random.Range(12, 20); n > 0; n--) { potions.AddItem(ItemBuilder.CreateRandomPotion()); } return(potions); }
public void ReturnItem() { ItemCollection items = new ItemCollection(); Journal journal = new Journal("mark", 1, "sfari", 56, "04/07/2010", "lll", 0); items.AddItem(journal); items.ReturnItem(journal); items.ReturnItem(journal); Assert.IsTrue(journal.NumOfAvailableCopies() == 1); }
/// <summary> /// Randomly add a potion recipe /// </summary> public static void RandomlyAddPotionRecipe(int chance, ItemCollection collection) { if (Random.Range(1, 101) < chance) { DaggerfallUnityItem potionRecipe = new DaggerfallUnityItem(ItemGroups.MiscItems, 4); byte recipe = (byte)Random.Range(0, 20); potionRecipe.typeDependentData = recipe; collection.AddItem(potionRecipe); } }
// TODO: classic seems to generate each time player select buy potions.. should we make more persistent for DFU? ItemCollection GetMerchantPotions() { ItemCollection potions = new ItemCollection(); int n = buildingDiscoveryData.quality; while (n-- >= 0) { potions.AddItem(ItemBuilder.CreateRandomPotion(UnityEngine.Random.Range(1, 5))); } return(potions); }
public void IntersectDelegatesForSearch() { ItemCollection items = new ItemCollection(); Journal journal = new Journal("mark", 7, "sfari", 56, "04/07/2010", "lll", 0); items.AddItem(journal); Predicate <AbstractItem>[] predicates = new Predicate <AbstractItem> [2]; predicates[0] = x => x.Publisher == "sfari"; predicates[1] = x => x.NumOfAvailableCopies() == 7; Assert.IsTrue(items.IntersectDelegatesForSearch(predicates).Contains(journal)); }
public Parser(byte[] source) { if (source == null || source.Length <= 0) { return; } this.source = source; items = new ItemCollection(); // преобразуем данные в текст string sourceString = GetSourceAsString(); // при запросе // первая строка содержит метод запроса, путь и версию HTTP протокола string httpInfo = sourceString.Substring(0, sourceString.IndexOf("\r\n")); var myReg = new Regex(@"(?<method>.+)\s+(?<path>.+)\s+HTTP/(?<version>[\d\.]+)", RegexOptions.Multiline); if (myReg.IsMatch(httpInfo)) { Match m = myReg.Match(httpInfo); if (m.Groups["method"].Value.ToUpper() == "POST") { method = MethodsList.POST; } else if (m.Groups["method"].Value.ToUpper() == "CONNECT") { method = MethodsList.CONNECT; } else { method = MethodsList.GET; } // или можно определить метод вот так // _Method = (MethodsList)Enum.Parse(typeof(MethodsList), m.Groups["method"].Value.ToUpper()); // но надежней всеже использовать условие path = m.Groups["path"].Value; httpVersion = m.Groups["version"].Value; } else { // при ответе // первая строка содержит код состояния myReg = new Regex(@"HTTP/(?<version>[\d\.]+)\s+(?<status>\d+)\s*(?<msg>.*)", RegexOptions.Multiline); Match m = myReg.Match(httpInfo); int.TryParse(m.Groups["status"].Value, out statusCode); statusMessage = m.Groups["msg"].Value; httpVersion = m.Groups["version"].Value; } // выделяем заголовки (до первых двух переводов строк) headersTail = sourceString.IndexOf("\r\n\r\n"); if (headersTail != -1) { // хвост найден, отделяем заголовки sourceString = sourceString.Substring(sourceString.IndexOf("\r\n") + 2, headersTail - sourceString.IndexOf("\r\n") - 2); } // парсим заголовки и заносим их в коллекцию myReg = new Regex(@"^(?<key>[^\x3A]+)\:\s{1}(?<value>.+)$", RegexOptions.Multiline); MatchCollection mc = myReg.Matches(sourceString); foreach (Match mm in mc) { string key = mm.Groups["key"].Value; if (!items.ContainsKey(key)) { // если указанного заголовка нет в коллекции, добавляем его items.AddItem(key, mm.Groups["value"].Value.Trim("\r\n ".ToCharArray())); } } }