public override PayloadCallbackResults?EnchantmentPayloadCallback(EnchantmentPayloadFlags context, EnchantmentParam?param = null, DaggerfallEntityBehaviour sourceEntity = null, DaggerfallEntityBehaviour targetEntity = null, DaggerfallUnityItem sourceItem = null, int sourceDamage = 0) { base.EnchantmentPayloadCallback(context, param, sourceEntity, targetEntity, sourceItem, sourceDamage); // Must be Used payload if (context != EnchantmentPayloadFlags.Used) { return(null); } // Must have nearby enemies List <PlayerGPS.NearbyObject> nearby = GameManager.Instance.PlayerGPS.GetNearbyObjects(PlayerGPS.NearbyObjectFlags.Enemy, enemyRange) .Where(x => ((EnemyEntity)x.gameObject.GetComponent <DaggerfallEntityBehaviour>().Entity).Team != MobileTeams.PlayerAlly).ToList(); if (nearby.Count == 0) { DaggerfallUI.Instance.PopupMessage(TextManager.Instance.GetText(textDatabase, "noMonstersNearby")); return(null); } // Summon a Daedroth to fight for the player GameObjectHelper.CreateFoeSpawner(foeType: MobileTypes.Daedroth, spawnCount: 1, alliedToPlayer: true); // Durability loss for this effect return(new PayloadCallbackResults() { durabilityLoss = 100, }); }
public override void MagicRound() { base.MagicRound(); if (GameManager.Instance.AreEnemiesNearby()) { // Summon a Daedroth to fight for the player. GameObjectHelper.CreateFoeSpawner(foeType: MobileTypes.Daedroth, spawnCount: 1, alliedToPlayer: true); ItemCollection items = GameManager.Instance.PlayerEntity.Items; DaggerfallUnityItem item = items.GetItem(ItemGroups.Artifacts, (int)ArtifactsSubTypes.Sanguine_Rose); for (int i = 0; i < items.Count; i++) { item = items.GetItem(i); if (IsRose(item)) { break; } } if (item != null) { item.currentCondition -= 100; } } else { DaggerfallUI.Instance.PopupMessage(HardStrings.noMonstersNearby); } }
public override void Leave() { base.Leave(); // When leaving they will try to forcibly 'retire' you! int deathSquad = 4 + (GameManager.Instance.PlayerEntity.Level / 2); GameObjectHelper.CreateFoeSpawner(false, MobileTypes.Assassin, deathSquad, 1, 5); GameObjectHelper.CreateFoeSpawner(false, MobileTypes.Nightblade, deathSquad, 4, 16); }
public override void Leave() { base.Leave(); // When leaving they will try to forcibly 'retire' you! int deathSquad = 4 + (int)(GameManager.Instance.PlayerEntity.Level / 1.5); GameObjectHelper.CreateFoeSpawner(false, MobileTypes.Rogue, deathSquad, 1, 8); GameObjectHelper.CreateFoeSpawner(false, MobileTypes.Thief, deathSquad, 1, 4); }
public override PayloadCallbackResults?EnchantmentPayloadCallback(EnchantmentPayloadFlags context, EnchantmentParam?param = null, DaggerfallEntityBehaviour sourceEntity = null, DaggerfallEntityBehaviour targetEntity = null, DaggerfallUnityItem sourceItem = null, int sourceDamage = 0) { base.EnchantmentPayloadCallback(context, param, sourceEntity, targetEntity, sourceItem, sourceDamage); // Must be Used payload if (context != EnchantmentPayloadFlags.Used) { return(null); } // Must have nearby non-allied enemies List <PlayerGPS.NearbyObject> nearby = GameManager.Instance.PlayerGPS.GetNearbyObjects(PlayerGPS.NearbyObjectFlags.Enemy, enemyRange) .Where(x => ((EnemyEntity)x.gameObject.GetComponent <DaggerfallEntityBehaviour>().Entity).Team != MobileTeams.PlayerAlly).ToList(); MobileTypes nearestType; if (nearby.Count == 0) { ShowSummonFailMessage(); return(null); } else { // Use nearest enemy for cloning PlayerGPS.NearbyObject nearest = nearby[0]; foreach (PlayerGPS.NearbyObject nearbyObject in nearby.Skip(1)) { if (nearbyObject.distance < nearest.distance) { nearest = nearbyObject; } } EnemyEntity enemy = (EnemyEntity)nearest.gameObject.GetComponent <DaggerfallEntityBehaviour>().Entity; if (enemy.Team == MobileTeams.PlayerAlly) { ShowSummonFailMessage(); return(null); } nearestType = (MobileTypes)enemy.MobileEnemy.ID; } // Spawn clone GameObjectHelper.CreateFoeSpawner(foeType: nearestType, spawnCount: 1, alliedToPlayer: true); // Durability loss for this effect return(new PayloadCallbackResults() { durabilityLoss = 100, }); }
public override PayloadCallbackResults?EnchantmentPayloadCallback(EnchantmentPayloadFlags context, EnchantmentParam?param = null, DaggerfallEntityBehaviour sourceEntity = null, DaggerfallEntityBehaviour targetEntity = null, DaggerfallUnityItem sourceItem = null, int sourceDamage = 0) { base.EnchantmentPayloadCallback(context, param, sourceEntity, targetEntity, sourceItem); // Remove soul trap item filled with enemy type if (param != null && context == EnchantmentPayloadFlags.Enchanted) { RemoveFilledTrap(param.Value.ClassicParam); } // Spawn enemy for trapped soul when item breaks if (param != null && context == EnchantmentPayloadFlags.Breaks) { GameObjectHelper.CreateFoeSpawner(false, (MobileTypes)param.Value.ClassicParam, 1); } return(null); }
public override void Update() { base.Update(); if (lastChunk && !answerGiven) { if (Input.GetKey(KeyCode.Y)) { HandleAnswer(QuestMachine.QuestMessages.AcceptQuest); QuestMachine.Instance.InstantiateQuest(daedraQuest); } else if (Input.GetKey(KeyCode.N)) { HandleAnswer(QuestMachine.QuestMessages.RefuseQuest); GameObjectHelper.CreateFoeSpawner(true, DaggerfallQuestPopupWindow.daedricFoes[UnityEngine.Random.Range(0, 5)], UnityEngine.Random.Range(3, 6), 8, 64); } } }
public override void Update() { base.Update(); if (lastChunk && !answerGiven) { HotkeySequence.KeyModifiers keyModifiers = HotkeySequence.GetKeyboardKeyModifiers(); if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.Yes).IsUpWith(keyModifiers)) { HandleAnswer(QuestMachine.QuestMessages.AcceptQuest); QuestMachine.Instance.StartQuest(daedraQuest); } else if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.No).IsUpWith(keyModifiers)) { HandleAnswer(QuestMachine.QuestMessages.RefuseQuest); GameObjectHelper.CreateFoeSpawner(true, DaggerfallQuestPopupWindow.daedricFoes[UnityEngine.Random.Range(0, 5)], UnityEngine.Random.Range(3, 6), 8, 64); } } }
private void ConfirmSummon_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton) { sender.CloseWindow(); if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes) { PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; int summonCost = FormulaHelper.CalculateDaedraSummoningCost(summonerFactionData.rep); if (playerEntity.GetGoldAmount() >= summonCost) { playerEntity.DeductGoldAmount(summonCost); WeatherManager weatherManager = GameManager.Instance.WeatherManager; // Sheogorath has a 5% (15% if stormy) chance to replace selected daedra. int sheoChance = (weatherManager.IsStorming) ? 15 : 5; if (Dice100.Roll() <= sheoChance) { daedraToSummon = daedraData[8]; } // Default 30% bonus is only applicable to some Daedra in specific weather conditions. int bonus = 0; if (daedraToSummon.bonusCond == Weather.WeatherType.Rain && weatherManager.IsRaining || daedraToSummon.bonusCond == Weather.WeatherType.Thunder && weatherManager.IsStorming || daedraToSummon.bonusCond == Weather.WeatherType.None) { bonus = 30; } // Get summoning chance for selected daedra and roll. int chance = FormulaHelper.CalculateDaedraSummoningChance(playerEntity.FactionData.GetReputation(daedraToSummon.factionId), bonus); int roll = Dice100.Roll(); Debug.LogFormat("Summoning {0} with chance = {1}%, Sheogorath chance = {2}%, roll = {3}, summoner rep = {4}, cost: {5}", daedraToSummon.vidFile.Substring(0, daedraToSummon.vidFile.Length - 4), chance, sheoChance, roll, summonerFactionData.rep, summonCost); if (roll > chance) { // Daedra stood you up! DaggerfallUI.MessageBox(SummonFailed, this); // Spawn daedric foes if failed at a witches coven. if (summonerFactionData.ggroup == (int)FactionFile.GuildGroups.Witches) { GameObjectHelper.CreateFoeSpawner(true, daedricFoes[Random.Range(0, 5)], Random.Range(1, 4), 4, 64); } return; } // Has this Daedra already been summoned by the player? if (playerEntity.FactionData.GetFlag(daedraToSummon.factionId, FactionFile.Flags.Summoned)) { // Close menu and push DaggerfallDaedraSummoningWindow here for video and dismissal.. CloseWindow(); uiManager.PushWindow(UIWindowFactory.GetInstanceWithArgs(UIWindowType.DaedraSummoned, new object[] { uiManager, daedraToSummon, SummonBefore, this })); } else { // Record the summoning. playerEntity.FactionData.SetFlag(daedraToSummon.factionId, FactionFile.Flags.Summoned); // Offer the quest to player. offeredQuest = GameManager.Instance.QuestListsManager.GetQuest(daedraToSummon.quest, summonerFactionData.id); if (offeredQuest != null) { // Close menu and push DaggerfallDaedraSummoningWindow here for video and custom quest offer.. CloseWindow(); uiManager.PushWindow(UIWindowFactory.GetInstanceWithArgs(UIWindowType.DaedraSummoned, new object[] { uiManager, daedraToSummon, offeredQuest })); } } } else { // Display customised not enough gold message so players don't need to guess the cost. TextFile.Token[] notEnoughGold = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(DaggerfallTradeWindow.NotEnoughGoldId); TextFile.Token[] msg = new TextFile.Token[] { new TextFile.Token() { formatting = TextFile.Formatting.Text, text = TextManager.Instance.GetLocalizedText("serviceSummonCost1") }, new TextFile.Token() { formatting = TextFile.Formatting.JustifyCenter }, new TextFile.Token() { formatting = TextFile.Formatting.Text, text = TextManager.Instance.GetLocalizedText("serviceSummonCost2") + summonCost + TextManager.Instance.GetLocalizedText("serviceSummonCost3") }, new TextFile.Token() { formatting = TextFile.Formatting.JustifyCenter }, new TextFile.Token() { formatting = TextFile.Formatting.NewLine }, notEnoughGold[0], new TextFile.Token() { formatting = TextFile.Formatting.JustifyCenter }, }; DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow); messageBox.SetTextTokens(msg, this); messageBox.ClickAnywhereToClose = false; messageBox.Show(); } } }