// Create stack of gold pieces DaggerfallUnityItem CreateGold(int rangeLow, int rangeHigh) { // Get amount int amount = 0; if (rangeLow == -1 || rangeHigh == -1) { Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; int playerMod = (playerEntity.Level / 2) + 1; int factionMod = 50; IGuild guild = null; if (ParentQuest.FactionId != 0) { guild = GameManager.Instance.GuildManager.GetGuild(ParentQuest.FactionId); if (guild != null && !(guild is NonMemberGuild)) { // If this is a faction quest, playerMod is (player factionrank + 1) rather than level playerMod = guild.Rank + 1; // If this is a faction quest, factionMod = faction.power rather than 50 FactionFile.FactionData factionData; if (playerEntity.FactionData.GetFactionData(ParentQuest.FactionId, out factionData)) { factionMod = factionData.power; } } } if (playerMod > 10) { playerMod = 10; } PlayerGPS gps = GameManager.Instance.PlayerGPS; int regionPriceMod = playerEntity.RegionData[gps.CurrentRegionIndex].PriceAdjustment / 2; amount = UnityEngine.Random.Range(150 * playerMod, (200 * playerMod) + 1) * (regionPriceMod + 500) / 1000 * (factionMod + 50) / 100; if (guild != null) { amount = guild.AlterReward(amount); } } else { amount = UnityEngine.Random.Range(rangeLow, rangeHigh + 1); } if (amount < 1) { amount = 1; } // Create item DaggerfallUnityItem result = new DaggerfallUnityItem(ItemGroups.Currency, 0); result.stackCount = amount; result.LinkQuestItem(ParentQuest.UID, Symbol.Clone()); return(result); }
// Create by item class and subclass DaggerfallUnityItem CreateItem(int itemClass, int itemSubClass) { // Validate if (itemClass == -1) { throw new Exception(string.Format("Tried to create Item with class {0}", itemClass)); } DaggerfallUnityItem result; // Handle random magic items if (itemClass == (int)ItemGroups.MagicItems && itemSubClass == -1) { Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; result = ItemBuilder.CreateRandomMagicItem(playerEntity.Level, playerEntity.Gender, playerEntity.Race); } else { // Handle random subclass if (itemSubClass == -1) { Array enumArray = DaggerfallUnity.Instance.ItemHelper.GetEnumArray((ItemGroups)itemClass); itemSubClass = UnityEngine.Random.Range(0, enumArray.Length); } // Create item result = new DaggerfallUnityItem((ItemGroups)itemClass, itemSubClass); } // Link item to quest result.LinkQuestItem(ParentQuest.UID, Symbol.Clone()); return(result); }
/// <summary> /// Creates a new SiteLink at Place. /// </summary> public static void CreateSiteLink(Quest parentQuest, Symbol placeSymbol) { // Attempt to get Place resource Place place = parentQuest.GetPlace(placeSymbol); if (place == null) throw new Exception(string.Format("Attempted to add SiteLink for invalid Place symbol {0}", placeSymbol.Name)); // Create SiteLink in QuestMachine SiteLink siteLink = new SiteLink(); siteLink.questUID = parentQuest.UID; siteLink.placeSymbol = placeSymbol.Clone(); siteLink.siteType = place.SiteDetails.siteType; siteLink.mapId = place.SiteDetails.mapId; siteLink.buildingKey = place.SiteDetails.buildingKey; Instance.AddSiteLink(siteLink); // Output debug information switch (siteLink.siteType) { case SiteTypes.Building: Debug.LogFormat("Created Building SiteLink to {0} in {1}/{2}", place.SiteDetails.buildingName, place.SiteDetails.regionName, place.SiteDetails.locationName); break; case SiteTypes.Dungeon: Debug.LogFormat("Created Dungeon SiteLink to {0}/{1}", place.SiteDetails.regionName, place.SiteDetails.locationName); break; } }
/// <summary> /// Start tracking a new questor. /// </summary> /// <param name="personSymbol">Symbol of new questor.</param> public void AddQuestor(Symbol personSymbol) { // Must be a valid resource if (personSymbol == null || string.IsNullOrEmpty(personSymbol.Name)) { throw new Exception("AddQuestor() must receive a named symbol."); } // Person must not be a questor already if (questors.ContainsKey(personSymbol.Name)) { Debug.LogWarningFormat("Person {0} is already a questor for quest {1} [{2}]", personSymbol.Original, uid, displayName); return; } // Attempt to get person resources Person person = GetPerson(personSymbol); if (person == null) { Debug.LogWarningFormat("Could not find matching Person resource to add questor {0}", personSymbol.Original); return; } // Set person as questor person.IsQuestor = true; // Create new questor symbol string key = personSymbol.Name; QuestorData qd = new QuestorData(); qd.symbol = personSymbol.Clone(); qd.name = person.DisplayName; questors.Add(personSymbol.Name, qd); // Dynamically relink individual NPC and associated QuestResourceBehaviour (if any) in current scene if (person.IsIndividualNPC) { QuestResourceBehaviour[] behaviours = GameObject.FindObjectsOfType <QuestResourceBehaviour>(); foreach (var questResourceBehaviour in behaviours) { // Get StaticNPC if present StaticNPC npc = questResourceBehaviour.GetComponent <StaticNPC>(); if (!npc) { continue; } // Link up resource and behaviour if this person found in scene if (person.FactionData.id == npc.Data.factionID) { questResourceBehaviour.AssignResource(person); person.QuestResourceBehaviour = questResourceBehaviour; } } } }
// Create by item class and subclass DaggerfallUnityItem CreateItem(int itemClass, int itemSubClass, int itemKey = -1) { // Validate if (itemClass == -1) { throw new Exception(string.Format("Tried to create Item with class {0}", itemClass)); } DaggerfallUnityItem result; // Handle random magic items if (itemClass == (int)ItemGroups.MagicItems) { Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; result = ItemBuilder.CreateRegularMagicItem(itemSubClass, playerEntity.Level, playerEntity.Gender, playerEntity.Race); } // Handle books else if (itemClass == (int)ItemGroups.Books) { result = (itemKey != -1) ? ItemBuilder.CreateBook(itemKey) : ItemBuilder.CreateRandomBook(); } // Handle potions else if (itemClass == (int)ItemGroups.UselessItems1 && itemSubClass == 1) { result = (itemKey != -1) ? ItemBuilder.CreatePotion(itemKey) : ItemBuilder.CreateRandomPotion(); } else { // Handle random subclass if (itemSubClass == -1) { Array enumArray = DaggerfallUnity.Instance.ItemHelper.GetEnumArray((ItemGroups)itemClass); itemSubClass = UnityEngine.Random.Range(0, enumArray.Length); } // Create item result = new DaggerfallUnityItem((ItemGroups)itemClass, itemSubClass); } // Link item to quest result.LinkQuestItem(ParentQuest.UID, Symbol.Clone()); string name = result.shortName.Replace("%it", result.ItemTemplate.name); QuestMachine.LogFormat( ParentQuest, "Generated \"{0}\" from Class {1} and Subclass {2} for item {3}", name, itemClass, itemSubClass, Symbol.Original ); return(result); }
// Create by item class and subclass DaggerfallUnityItem CreateItem(int itemClass, int itemSubClass) { // Validate if (itemClass == -1) { throw new Exception(string.Format("Tried to create Item with class {0}", itemClass)); } // Handle random magic item by redirecting itemClass to one of several supported types // Currently unknown how many types this supports - will expand later // May also need to account for gender if offering clothing // Item should have a world texture as may be placed in world by quest // Only goal currently to have more variety than "ruby" for everything bool isMagicItem = false; if (itemClass == (int)ItemGroups.MagicItems && itemSubClass == -1) { ItemGroups[] randomMagicGroups = new ItemGroups[] { ItemGroups.Armor, ItemGroups.Weapons, ItemGroups.ReligiousItems, ItemGroups.Gems, }; itemClass = UnityEngine.Random.Range(0, randomMagicGroups.Length); isMagicItem = true; } // Handle random subclass if (itemSubClass == -1) { Array enumArray = DaggerfallUnity.Instance.ItemHelper.GetEnumArray((ItemGroups)itemClass); itemSubClass = UnityEngine.Random.Range(0, enumArray.Length); } // Create item DaggerfallUnityItem result = new DaggerfallUnityItem((ItemGroups)itemClass, itemSubClass); // Assign dummy magic effects so item becomes enchanted // This will need to be ported to real magic system in future if (isMagicItem) { result.legacyMagic = new DaggerfallEnchantment[1]; result.legacyMagic[0].type = EnchantmentTypes.CastWhenHeld; result.legacyMagic[0].param = 87; } // Link item to quest result.LinkQuestItem(ParentQuest.UID, Symbol.Clone()); return(result); }
// Create stack of gold pieces DaggerfallUnityItem CreateGold(int rangeLow, int rangeHigh) { // Get amount int amount = 0; if (rangeLow == -1 || rangeHigh == -1) { Entity.PlayerEntity player = GameManager.Instance.PlayerEntity; // TODO: If this is a faction quest, playerMod is (player factionrank + 1) rather than level int playerMod = (player.Level / 2) + 1; if (playerMod > 10) { playerMod = 10; } // TODO: If this is a faction quest, factionMod = faction.power rather than 50 int factionMod = 50; PlayerGPS gps = GameManager.Instance.PlayerGPS; int regionPriceMod = player.RegionData[gps.CurrentRegionIndex].PriceAdjustment / 2; amount = UnityEngine.Random.Range(150 * playerMod, (200 * playerMod) + 1) * (regionPriceMod + 500) / 1000 * (factionMod + 50) / 100; } else { amount = UnityEngine.Random.Range(rangeLow, rangeHigh + 1); } if (amount < 1) { amount = 1; } // Create item DaggerfallUnityItem result = new DaggerfallUnityItem(ItemGroups.Currency, 0); result.stackCount = amount; result.LinkQuestItem(ParentQuest.UID, Symbol.Clone()); return(result); }
// Create stack of gold pieces DaggerfallUnityItem CreateGold(int rangeLow, int rangeHigh) { // Get amount int amount = 0; if (rangeLow == -1 || rangeHigh == -1) { amount = GameManager.Instance.PlayerEntity.Level * UnityEngine.Random.Range(90, 110); } else { amount = UnityEngine.Random.Range(rangeLow, rangeHigh + 1); } // Create item DaggerfallUnityItem result = new DaggerfallUnityItem(ItemGroups.Currency, 0); result.stackCount = amount; result.LinkQuestItem(ParentQuest.UID, Symbol.Clone()); return(result); }
// Create by item class and subclass DaggerfallUnityItem CreateItem(int itemClass, int itemSubClass) { // Validate if (itemClass == -1) { throw new Exception(string.Format("Tried to create Item with class {0}", itemClass)); } // Handle random subclass if (itemSubClass == -1) { Array enumArray = DaggerfallUnity.Instance.ItemHelper.GetEnumArray((ItemGroups)itemClass); itemSubClass = UnityEngine.Random.Range(0, enumArray.Length); } // Create item DaggerfallUnityItem result = new DaggerfallUnityItem((ItemGroups)itemClass, itemSubClass); result.LinkQuestItem(ParentQuest.UID, Symbol.Clone()); return(result); }