public override IQuestAction CreateNew(string source, Quest parentQuest) { // Source must match pattern Match match = Test(source); if (!match.Success) { return(null); } // Factory new action CastSpellOnFoe action = new CastSpellOnFoe(parentQuest); string sourceSpellName = match.Groups["aSpell"].Value; action.spell.CustomKey = match.Groups["aCustomSpell"].Value; action.foeSymbol = new Symbol(match.Groups["aFoe"].Value); // Get classic spell ID if (string.IsNullOrEmpty(action.spell.CustomKey)) { Table spellsTable = QuestMachine.Instance.SpellsTable; if (spellsTable.HasValue(sourceSpellName)) { action.spell.ClassicID = int.Parse(spellsTable.GetValue("id", sourceSpellName)); } else { QuestMachine.LogFormat("CastSpellOnFoe could not resolve classic spell '{0}' in Quests-Spells data table", sourceSpellName); SetComplete(); } } return(action); }
/// <summary> /// Check if player click has been triggered. /// </summary> public void SetPlayerClicked() { if (this is Person && ((this as Person).IsMuted || (this as Person).IsDestroyed)) { QuestMachine.LogFormat("Ignoring click on muted or destroyed Person {0}.", Symbol.Original); return; } hasPlayerClicked = true; }
// 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); }
void LogHomePlace(Place homePlace) { QuestMachine.LogFormat( ParentQuest, "Generated Home for Person {0} [{1}] at '{2}/{3}' in building '{4}'", Symbol.Original, DisplayName, HomeRegionName, HomeTownName, HomeBuildingName); }
public override IQuestAction CreateNew(string source, Quest parentQuest) { // Source must match pattern Match match = Test(source); if (!match.Success) { return(null); } // Factory new action CastSpellDo action = new CastSpellDo(parentQuest); string sourceSpellName = match.Groups["aSpell"].Value; action.taskSymbol = new Symbol(match.Groups["aTask"].Value); // Cache classic effects to match Table spellsTable = QuestMachine.Instance.SpellsTable; if (spellsTable.HasValue(sourceSpellName)) { action.spellID = int.Parse(spellsTable.GetValue("id", sourceSpellName)); SpellRecord.SpellRecordData spellRecord; if (GameManager.Instance.EntityEffectBroker.GetClassicSpellRecord(action.spellID, out spellRecord)) { action.classicEffects = spellRecord.effects; } else { QuestMachine.LogFormat("CastSpellDo could not find spell matching spellID '{0}' from spell '{1}'", spellID, sourceSpellName); SetComplete(); } } else { QuestMachine.LogFormat("CastSpellDo could not resolve spell '{0}' in Quests-Spells data table", sourceSpellName); SetComplete(); } return(action); }