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);

            // Validate
            if (context != EnchantmentPayloadFlags.Strikes || targetEntity == null || sourceItem == null)
            {
                return(null);
            }

            // Entity must save vs magic
            if (FormulaHelper.SavingThrow(DFCareer.Elements.Magic, DFCareer.EffectFlags.Magic, targetEntity.Entity, 0) != 0)
            {
                // Kill target instantly - durability loss is equal to target health removed
                int healthRemoved = targetEntity.Entity.CurrentHealth;
                return(new PayloadCallbackResults()
                {
                    strikesModulateDamage = healthRemoved,
                    durabilityLoss = healthRemoved,
                });
            }

            return(null);
        }
예제 #2
0
        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);
        }
예제 #3
0
        public override bool IsEnchantmentExclusiveTo(EnchantmentSettings[] settingsToTest, EnchantmentParam?comparerParam = null)
        {
            string goodRepWithKey = EnchantmentTypes.GoodRepWith.ToString();

            foreach (EnchantmentSettings settings in settingsToTest)
            {
                // Self tests
                if (settings.EffectKey == EffectKey)
                {
                    // Exclusive with self once "All" selected
                    if (settings.ClassicParam == (int)Params.All)
                    {
                        return(true);
                    }

                    // "All" is exclusive with other groups
                    if (comparerParam != null && settings.ClassicParam != (int)Params.All && comparerParam.Value.ClassicParam == (int)Params.All)
                    {
                        return(true);
                    }
                }

                // Exclusive with opposing GoodRepWith param
                if (settings.EffectKey == goodRepWithKey && comparerParam != null && settings.ClassicParam == comparerParam.Value.ClassicParam)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #4
0
 public EffectEntry(string key, EffectSettings settings, EnchantmentParam?enchantmentParam = null)
 {
     Key              = key;
     Settings         = settings;
     EnchantmentParam = enchantmentParam;
 }
예제 #5
0
 /// <summary>
 /// Enchantment payload callback for enchantment to perform custom execution based on context.
 /// These callbacks are performed directly from template, not from a live instance of effect. Do not store state in effect during callbacks.
 /// Not used by EnchantmentPayloadFlags.Held - rather, an effect instance bundle is assigned to entity's effect manager to execute as normal.
 /// </summary>
 public virtual PayloadCallbackResults?EnchantmentPayloadCallback(EnchantmentPayloadFlags context, EnchantmentParam?param = null, DaggerfallEntityBehaviour sourceEntity = null, DaggerfallEntityBehaviour targetEntity = null, DaggerfallUnityItem sourceItem = null, int sourceDamage = 0)
 {
     return(null);
 }
예제 #6
0
 /// <summary>
 /// Gets related enchantments that will be forced onto item along with this enchantment.
 /// Only used by Soul Bound in classic gameplay.
 /// </summary>
 public virtual ForcedEnchantmentSet?GetForcedEnchantments(EnchantmentParam?param = null)
 {
     return(null);
 }
예제 #7
0
        public override PayloadCallbackResults?EnchantmentPayloadCallback(EnchantmentPayloadFlags context, EnchantmentParam?param = null, DaggerfallEntityBehaviour sourceEntity = null, DaggerfallEntityBehaviour targetEntity = null, DaggerfallUnityItem sourceItem = null, int sourceDamage = 0)
        {
            // Update world time enchantment last operated this item or when first enchanting item
            // Either striking with a weapon or "using" item from inventory / use UI will update this time
            // Payload callbacks are done in effect template (not the live effect) so we track time on an item field reserved for this effect
            if (sourceItem != null && (context == EnchantmentPayloadFlags.Strikes || context == EnchantmentPayloadFlags.Used || context == EnchantmentPayloadFlags.Enchanted))
            {
                sourceItem.timeHealthLeechLastUsed = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();
            }

            // Must specify enchantment param
            if (param == null)
            {
                return(null);
            }

            // Health leech operator on weapon strikes or casting from item
            Params type = (Params)param.Value.ClassicParam;

            if (sourceEntity != null && type == Params.WheneverUsed)
            {
                if (context == EnchantmentPayloadFlags.Strikes)
                {
                    sourceEntity.Entity.DecreaseHealth(leechWeaponAmount);
                }
                else if (context == EnchantmentPayloadFlags.Used)
                {
                    sourceEntity.Entity.DecreaseHealth(leechCastAmount);
                }
            }

            return(null);
        }
예제 #8
0
        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);

            // Validate
            if (param == null || sourceEntity == null || targetEntity == null)
            {
                return(null);
            }

            // Must be correct vampiric effect type
            Params type = (Params)param.Value.ClassicParam;

            if (type != Params.WhenStrikes)
            {
                return(null);
            }

            // Heal source entity by base damage caused to target
            // Was not able to fully confirm this how effect works, but seems close from observation alone.
            // TODO: This will likely need more research and refinement.
            sourceEntity.Entity.CurrentHealth += sourceDamage;
            //UnityEngine.Debug.LogFormat("Entity {0} drained {1} health by striking {2}", sourceEntity.Entity.Name, sourceDamage, targetEntity.Entity.Name);

            return(null);
        }
        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,
            });
        }
예제 #10
0
        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);

            // Validate
            if (context != EnchantmentPayloadFlags.Equipped || param == null || sourceEntity == null || sourceItem == null)
            {
                return(null);
            }

            // Get caster effect manager
            EntityEffectManager casterManager = sourceEntity.GetComponent <EntityEffectManager>();

            if (!casterManager)
            {
                return(null);
            }

            // Cast when held enchantment invokes a spell bundle that is permanent until item is removed
            if (!string.IsNullOrEmpty(param.Value.CustomParam))
            {
                // TODO: Instantiate a custom spell bundle
            }
            else
            {
                // Instantiate a classic spell bundle
                SpellRecord.SpellRecordData spell;
                if (GameManager.Instance.EntityEffectBroker.GetClassicSpellRecord(param.Value.ClassicParam, out spell))
                {
                    UnityEngine.Debug.LogFormat("CastWhenHeld callback found enchantment '{0}'", spell.spellName);

                    // Create effect bundle settings from classic spell
                    EffectBundleSettings bundleSettings;
                    if (GameManager.Instance.EntityEffectBroker.ClassicSpellRecordDataToEffectBundleSettings(spell, BundleTypes.HeldMagicItem, out bundleSettings))
                    {
                        // Assign bundle
                        EntityEffectBundle bundle = new EntityEffectBundle(bundleSettings, sourceEntity);
                        bundle.FromEquippedItem = sourceItem;
                        casterManager.AssignBundle(bundle, AssignBundleFlags.BypassSavingThrows);

                        // Play cast sound on equip for player only
                        if (casterManager.IsPlayerEntity)
                        {
                            casterManager.PlayCastSound(sourceEntity, casterManager.GetCastSoundID(bundle.Settings.ElementType));
                        }

                        // TODO: Apply durability loss to equipped item on equip and over time
                        // http://en.uesp.net/wiki/Daggerfall:Magical_Items#Durability_of_Magical_Items
                    }
                }
            }

            return(null);
        }
        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);

            // Validate
            if (context != EnchantmentPayloadFlags.Strikes || sourceEntity == null || targetEntity == null || sourceItem == null || sourceDamage == 0)
            {
                return(null);
            }

            // Target can saves vs magic
            if (FormulaHelper.SavingThrow(DFCareer.Elements.Magic, DFCareer.EffectFlags.Magic, targetEntity.Entity, 0) == 0)
            {
                return(null);
            }

            // Find live effect as EnchantmentPayloadCallback is only called on template and we need to change live data
            // Log error and allow effect to continue - but it will not operate fully
            MaceOfMolagBalEffect liveEffect = FindLiveEffect(sourceEntity);

            if (liveEffect == null)
            {
                Debug.LogError("MaceOfMolagBalEffect.EnchantmentPayloadCallback could not find live effect instance on source entity.");
            }

            // Seed random
            Random.InitState(Time.frameCount);

            // "The Mace of Molag Bal drains its victim's spell points and gives them to the bearer.
            // "If the victim has no spell points, he is drained of strength, which is also transferred to the wielder."
            // "Using the Mace of Molag Bal can actually give its bearer more spell points or more strength than he would have fully rested."
            // After considerable testing in classic unable to actually reproduce the first part of this effect (transfer of spell points)
            // Could be down to casters in classic dumping their spell point pool almost immediately, but even backstabs failed to transfer any spell points to wielder
            // Implementing spell point drain as per description rather than based on observation in classic
            // Assuming spell points drained are equal to damage
            // Testing in classic shows that strength increase is always 1-6
            if (targetEntity.Entity.CurrentMagicka > 0)
            {
                // First drain spell points from target
                // Limit drain to available spell points on target
                int spellPointsDrained = targetEntity.Entity.CurrentMagicka - targetEntity.Entity.DecreaseMagicka(sourceDamage);

                // Then raise spell points on source equal to amount drained
                // If this will increase over usual spell point pool amount then increase max to by overflow amount
                int overflow = sourceEntity.Entity.CurrentMagicka + spellPointsDrained - sourceEntity.Entity.MaxMagicka;
                if (overflow > 0)
                {
                    // Immediately set increase to spell point maximum to absorb all spell points drained
                    // This also needs to be set each tick so we accumulate this overflow amount to use in live effect
                    sourceEntity.Entity.ChangeMaxMagickaModifier(overflow);
                    if (liveEffect != null)
                    {
                        liveEffect.currentMaxMagickaIncrease += overflow;
                    }
                }
                sourceEntity.Entity.IncreaseMagicka(spellPointsDrained);
            }
            else
            {
                // If target is out of spell points then drain 1-6 strength from target
                int strengthDrained = Random.Range(1, 7);
                DrainTargetStrength(targetEntity, strengthDrained);

                // Accumulate drain amount as a strength buff in live effect
                // These modifiers are automatically serialized/deserialized as part of effect framework
                if (liveEffect != null)
                {
                    liveEffect.ChangeStatMaxMod(DFCareer.Stats.Strength, strengthDrained);
                    liveEffect.ChangeStatMod(DFCareer.Stats.Strength, strengthDrained);
                }
            }

            // Record last strike time
            if (liveEffect != null)
            {
                liveEffect.lastStrikeTime = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();
            }

            // Durability loss is equal to damage caused
            return(new PayloadCallbackResults()
            {
                durabilityLoss = sourceDamage,
            });
        }
예제 #12
0
        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);

            // Requires param
            if (param == null)
            {
                return(null);
            }

            // Check target is an enemy type
            EnemyEntity enemyEntity = null;

            if (targetEntity != null && (targetEntity.EntityType == EntityTypes.EnemyMonster || targetEntity.EntityType == EntityTypes.EnemyClass))
            {
                enemyEntity = targetEntity.Entity as EnemyEntity;
            }
            else
            {
                return(null);
            }

            // Check enemy matches param type
            Params type = (Params)param.Value.ClassicParam;

            if (type == Params.Undead && enemyEntity.MobileEnemy.Affinity == MobileAffinity.Undead ||
                type == Params.Daedra && enemyEntity.MobileEnemy.Affinity == MobileAffinity.Daedra ||
                type == Params.Humanoid && enemyEntity.MobileEnemy.Affinity == MobileAffinity.Human ||
                type == Params.Animals && enemyEntity.MobileEnemy.Affinity == MobileAffinity.Animal)
            {
                // Modulating damage to a lower value
                // Currently unknown what values classic uses to lower damage
                return(new PayloadCallbackResults()
                {
                    strikesModulateDamage = reduceDamageAmount
                });
            }

            return(null);
        }
예제 #13
0
        public override bool IsEnchantmentExclusiveTo(EnchantmentSettings[] settingsToTest, EnchantmentParam?comparerParam = null)
        {
            string potentVsKey = EnchantmentTypes.PotentVs.ToString();

            foreach (EnchantmentSettings settings in settingsToTest)
            {
                // Exclusive with opposing PotentVs param
                if (settings.EffectKey == potentVsKey && comparerParam != null && settings.ClassicParam == comparerParam.Value.ClassicParam)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #14
0
        public override bool IsEnchantmentExclusiveTo(EnchantmentSettings[] settingsToTest, EnchantmentParam?comparerParam = null)
        {
            // Exclusive to StrengthensArmor - no param test required
            string strengthensArmorKey = EnchantmentTypes.StrengthensArmor.ToString();

            foreach (EnchantmentSettings settings in settingsToTest)
            {
                if (settings.EffectKey == strengthensArmorKey)
                {
                    return(true);
                }
            }

            return(false);
        }
        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);

            // Validate
            if (context != EnchantmentPayloadFlags.Used || sourceEntity == null || sourceEntity.EntityType != EntityTypes.Player || sourceItem == null)
            {
                return(null);
            }

            // Start Oghma level up and remove item
            GameManager.Instance.PlayerEntity.ReadyToLevelUp = true;
            GameManager.Instance.PlayerEntity.OghmaLevelUp   = true;
            DaggerfallUI.PostMessage(DaggerfallUIMessages.dfuiOpenCharacterSheetWindow);
            GameManager.Instance.PlayerEntity.Items.RemoveItem(sourceItem);

            return(null);
        }
예제 #16
0
        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);

            // Validate
            if (context != EnchantmentPayloadFlags.Strikes || targetEntity == null || param == null || sourceDamage == 0)
            {
                return(null);
            }

            // Get target effect manager
            EntityEffectManager effectManager = targetEntity.GetComponent <EntityEffectManager>();

            if (!effectManager)
            {
                return(null);
            }

            // Cast when strikes enchantment prepares a new ready spell
            if (!string.IsNullOrEmpty(param.Value.CustomParam))
            {
                // TODO: Ready a custom spell bundle
            }
            else
            {
                // Ready a classic spell bundle
                SpellRecord.SpellRecordData spell;
                EffectBundleSettings        bundleSettings;
                EntityEffectBundle          bundle;
                if (GameManager.Instance.EntityEffectBroker.GetClassicSpellRecord(param.Value.ClassicParam, out spell))
                {
                    if (GameManager.Instance.EntityEffectBroker.ClassicSpellRecordDataToEffectBundleSettings(spell, BundleTypes.Spell, out bundleSettings))
                    {
                        bundle = new EntityEffectBundle(bundleSettings, sourceEntity);
                        effectManager.AssignBundle(bundle, AssignBundleFlags.ShowNonPlayerFailures);
                    }
                }
            }

            return(new PayloadCallbackResults()
            {
                durabilityLoss = durabilityLossOnStrike
            });
        }
예제 #17
0
        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);

            // Validate
            if ((context != EnchantmentPayloadFlags.Equipped &&
                 context != EnchantmentPayloadFlags.MagicRound &&
                 context != EnchantmentPayloadFlags.RerollEffect) ||
                param == null || sourceEntity == null || sourceItem == null)
            {
                return(null);
            }

            // Get caster effect manager
            EntityEffectManager casterManager = sourceEntity.GetComponent <EntityEffectManager>();

            if (!casterManager)
            {
                return(null);
            }

            if (context == EnchantmentPayloadFlags.Equipped)
            {
                // Cast when held enchantment invokes a spell bundle that is permanent until item is removed
                InstantiateSpellBundle(param.Value, sourceEntity, sourceItem, casterManager);
            }
            else if (context == EnchantmentPayloadFlags.MagicRound)
            {
                // Apply CastWhenHeld durability loss
                ApplyDurabilityLoss(sourceItem, sourceEntity);
            }
            else if (context == EnchantmentPayloadFlags.RerollEffect)
            {
                // Recast spell bundle - previous instance has already been removed by EntityEffectManager prior to callback
                InstantiateSpellBundle(param.Value, sourceEntity, sourceItem, casterManager, true);
            }

            return(null);
        }
        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.GetLocalizedText("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,
            });
        }
예제 #19
0
        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);

            // Validate
            if (context != EnchantmentPayloadFlags.Used || sourceEntity == null || param == null)
            {
                return(null);
            }

            // Get caster effect manager
            EntityEffectManager effectManager = sourceEntity.GetComponent <EntityEffectManager>();

            if (!effectManager)
            {
                return(null);
            }

            // Cast when used enchantment prepares a new ready spell
            if (!string.IsNullOrEmpty(param.Value.CustomParam))
            {
                // TODO: Ready a custom spell bundle
            }
            else
            {
                // Ready a classic spell bundle
                SpellRecord.SpellRecordData spell;
                EffectBundleSettings        bundleSettings;
                EntityEffectBundle          bundle;
                if (GameManager.Instance.EntityEffectBroker.GetClassicSpellRecord(param.Value.ClassicParam, out spell))
                {
                    if (GameManager.Instance.EntityEffectBroker.ClassicSpellRecordDataToEffectBundleSettings(spell, BundleTypes.Spell, out bundleSettings))
                    {
                        // Self-cast spells are all assigned directly to self, "click to cast" spells are loaded to ready spell
                        // TODO: Support multiple ready spells so all loaded spells are launched on click
                        bundle            = new EntityEffectBundle(bundleSettings, sourceEntity);
                        bundle.CastByItem = sourceItem;
                        if (bundle.Settings.TargetType == TargetTypes.CasterOnly)
                        {
                            effectManager.AssignBundle(bundle, AssignBundleFlags.BypassSavingThrows);
                        }
                        else
                        {
                            effectManager.SetReadySpell(bundle, true);
                        }
                    }
                }
            }

            return(new PayloadCallbackResults()
            {
                durabilityLoss = durabilityLossOnUse
            });
        }
예제 #20
0
 /// <summary>
 /// Enchantment can flag that it is exclusive to one or more enchantments in array provided.
 /// Used by enchanting window to prevent certain enchantments from being selected together.
 /// </summary>
 public virtual bool IsEnchantmentExclusiveTo(EnchantmentSettings[] settingsToTest, EnchantmentParam?comparerParam = null)
 {
     return(false);
 }
예제 #21
0
        public override bool IsEnchantmentExclusiveTo(EnchantmentSettings[] settingsToTest, EnchantmentParam?comparerParam = null)
        {
            // Exclusive to FeatherWeight - no param test required
            string featherWeightKey = EnchantmentTypes.FeatherWeight.ToString();

            foreach (EnchantmentSettings settings in settingsToTest)
            {
                if (settings.EffectKey == featherWeightKey)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #22
0
        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);

            // Validate
            if (sourceItem == null)
            {
                return(null);
            }

            // Used payload
            if (context == EnchantmentPayloadFlags.Used)
            {
                if (sourceItem.TrappedSoulType != MobileTypes.None)
                {
                    sourceItem.TrappedSoulType = MobileTypes.None;
                    DaggerfallUI.MessageBox(soulReleasedID);
                }
                else
                {
                    DaggerfallUI.MessageBox(noSoulToReleaseID);
                }
            }

            return(null);
        }
예제 #23
0
        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);

            // Validate
            if (context != EnchantmentPayloadFlags.Strikes || targetEntity == null)
            {
                return(null);
            }

            // Change target enemy
            if (targetEntity.Entity is EnemyEntity)
            {
                // Get enemy entity - cannot have Wabbajack active already
                EnemyEntity enemy = (EnemyEntity)targetEntity.Entity;
                if (enemy == null || enemy.WabbajackActive)
                {
                    return(null);
                }

                // Get new enemy career and transform
                MobileTypes enemyType = careerIDs[Random.Range(0, careerIDs.Length)];
                if ((int)enemyType == enemy.CareerIndex)
                {
                    enemyType = (MobileTypes)(((int)enemyType + 1) % careerIDs.Length);
                }
                Transform parentTransform = targetEntity.gameObject.transform.parent;

                // Do not disable enemy if in use by the quest system
                QuestResourceBehaviour questResourceBehaviour = targetEntity.GetComponent <QuestResourceBehaviour>();
                if (questResourceBehaviour && !questResourceBehaviour.IsFoeDead)
                {
                    return(null);
                }

                string[] enemyNames = TextManager.Instance.GetLocalizedTextList("enemyNames");
                if (enemyNames == null)
                {
                    throw new System.Exception("enemyNames array text not found");
                }

                // Switch entity
                targetEntity.gameObject.SetActive(false);
                GameObject gameObject = GameObjectHelper.CreateEnemy(enemyNames[(int)enemyType], enemyType, targetEntity.transform.localPosition, MobileGender.Unspecified, parentTransform);
                DaggerfallEntityBehaviour newEnemyBehaviour = gameObject.GetComponent <DaggerfallEntityBehaviour>();
                EnemyEntity newEnemy = (EnemyEntity)newEnemyBehaviour.Entity;
                newEnemy.WabbajackActive = true;
                newEnemy.CurrentHealth  -= enemy.MaxHealth - enemy.CurrentHealth; // carry over damage to new monster
            }

            return(null);
        }
예제 #24
0
 public EffectEntry(string key, EnchantmentParam?enchantmentParam = null)
 {
     Key              = key;
     Settings         = new EffectSettings();
     EnchantmentParam = enchantmentParam;
 }
예제 #25
0
        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);

            EnemyEntity enemy = (EnemyEntity)targetEntity.Entity;
            int         reflectedDamage;

            switch (enemy.MobileEnemy.Team)
            {
            // Animals and Spriggans
            case MobileTeams.Vermin:
            case MobileTeams.Spriggans:
            case MobileTeams.Bears:
            case MobileTeams.Tigers:
            case MobileTeams.Spiders:
            case MobileTeams.Scorpions:
                return(new PayloadCallbackResults());

            case MobileTeams.Daedra:
                reflectedDamage = sourceDamage / 2;
                break;

            case MobileTeams.Undead:
                reflectedDamage = sourceDamage * 2;
                break;

            // Everyone else (i.e. Humanoids and Monsters)
            default:
                reflectedDamage = sourceDamage;
                break;
            }
            enemy.CurrentHealth -= reflectedDamage;

            // Durability loss for this effect
            return(new PayloadCallbackResults()
            {
                durabilityLoss = reflectedDamage,
            });
        }
예제 #26
0
        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);

            // Lower weight when item is enchanted
            if (context == EnchantmentPayloadFlags.Enchanted && sourceItem != null)
            {
                sourceItem.weightInKg = weightValue;
            }

            return(null);
        }
예제 #27
0
 public override PayloadCallbackResults?EnchantmentPayloadCallback(EnchantmentPayloadFlags context, EnchantmentParam?param = null, DaggerfallEntityBehaviour sourceEntity = null, DaggerfallEntityBehaviour targetEntity = null, DaggerfallUnityItem sourceItem = null, int sourceDamage = 0)
 {
     return(base.EnchantmentPayloadCallback(context, param, sourceEntity, targetEntity, sourceItem));
 }