예제 #1
0
        /// <summary>
        /// Generate EffectEntry from classic EffectRecordData.
        /// </summary>
        /// <param name="effectRecordData">Classic effect record data.</param>
        /// <returns>EffectEntry.</returns>
        public bool ClassicEffectRecordToEffectEntry(SpellRecord.EffectRecordData effectRecordData, out EffectEntry effectEntryOut)
        {
            // Get template
            IEntityEffect effectTemplate = GetEffectTemplateFromClassicEffectRecordData(effectRecordData);

            if (effectTemplate == null)
            {
                effectEntryOut = new EffectEntry();
                return(false);
            }

            // Get settings and create entry
            EffectSettings effectSettings = ClassicEffectRecordToEffectSettings(
                effectRecordData,
                effectTemplate.Properties.SupportDuration,
                effectTemplate.Properties.SupportChance,
                effectTemplate.Properties.SupportMagnitude);

            effectEntryOut = new EffectEntry(effectTemplate.Key, effectSettings);

            return(true);
        }
예제 #2
0
        void RegisterCustomEffectDemo()
        {
            // This method is an example of how to create a fully custom spell bundle
            // and expose it to other systems like spells for sale and item enchanter
            // The process is mostly just setting up data, something that can be automated with helpers

            // First register custom effect with broker
            // This will make it available to crafting stations supported by effect
            // We're using variant 0 of this effect here (Inferno)
            MageLight templateEffect = new MageLight();

            templateEffect.CurrentVariant = 0;
            RegisterEffectTemplate(templateEffect);

            // Create effect settings for our custom spell
            // These are Chance, Duration, and Magnitude required by spell - usually seen in spellmaker
            // No need to define settings not used by effect
            // For our custom spell, we're using same Duration settings as Light spell: 1 + 4 per level
            // Note these settings will also control final cost of spell to buy and cast
            EffectSettings effectSettings = new EffectSettings()
            {
                DurationBase     = 1,
                DurationPlus     = 4,
                DurationPerLevel = 1,
            };

            // Create an EffectEntry
            // This links the effect key with settings
            // Each effect entry in bundle needs its own settings - most spells only have a single effect
            EffectEntry effectEntry = new EffectEntry()
            {
                Key      = templateEffect.Properties.Key,
                Settings = effectSettings,
            };

            // Create a custom spell bundle
            // This is a portable version of the spell for other systems
            // For example, every spell in the player's spellbook is a bundle
            // Bundle target and elements settings should follow effect requirements
            EffectBundleSettings mageLightInferoSpell = new EffectBundleSettings()
            {
                Version     = CurrentSpellVersion,
                BundleType  = BundleTypes.Spell,
                TargetType  = TargetTypes.CasterOnly,
                ElementType = ElementTypes.Magic,
                Name        = "Magelight Inferno",
                IconIndex   = 12,
                Effects     = new EffectEntry[] { effectEntry },
            };

            // Create a custom spell offer
            // This informs other systems if they can use this bundle
            CustomSpellBundleOffer mageLightInferoOffer = new CustomSpellBundleOffer()
            {
                Key   = "MageLightInferno-CustomOffer",                         // This key is for the offer itself and must be unique
                Usage = CustomSpellBundleOfferUsage.SpellsForSale |             // Available in spells for sale
                        CustomSpellBundleOfferUsage.CastWhenUsedEnchantment |   // Available for "cast on use" enchantments
                        CustomSpellBundleOfferUsage.CastWhenHeldEnchantment,    // Available for "cast on held" enchantments
                BundleSetttings = mageLightInferoSpell,                         // The spell bundle created earlier
                EnchantmentCost = 250,                                          // Cost to use spell at item enchanter if enabled
            };

            // Register the offer
            RegisterCustomSpellBundleOffer(mageLightInferoOffer);
        }
예제 #3
0
 /// <summary>
 /// Creates a new instance of effect with specified settings.
 /// Use this to create a new effect with unique settings for actual use.
 /// </summary>
 /// <param name="effectEntry">EffectEntry with effect settings.</param>
 /// <returns>Interface to new effect instance.</returns>
 public IEntityEffect InstantiateEffect(EffectEntry effectEntry)
 {
     return(InstantiateEffect(effectEntry.Key, effectEntry.Settings));
 }
예제 #4
0
    public static TextFile.Token[] PotionSpellEffectsTextTokens(DaggerfallWorkshop.Game.Items.DaggerfallUnityItem item)
    {
        TextFile.Token[] tokens          = null;
        string           effectDuration  = "";
        string           effectMagnitude = "";
        string           effectChance    = "";

        DaggerfallWorkshop.Game.MagicAndEffects.EntityEffectBroker effectBroker = GameManager.Instance.EntityEffectBroker;
        DaggerfallWorkshop.Game.MagicAndEffects.PotionRecipe       potionRecipe = effectBroker.GetPotionRecipe(item.PotionRecipeKey);
        DaggerfallWorkshop.Game.MagicAndEffects.IEntityEffect      potionEffect = effectBroker.GetPotionRecipeEffect(potionRecipe);

        DaggerfallWorkshop.Game.MagicAndEffects.EffectEntry[] potionEffects;
        List <string> secondaryEffects = potionRecipe.SecondaryEffects;

        if (secondaryEffects != null)
        {
            potionEffects    = new DaggerfallWorkshop.Game.MagicAndEffects.EffectEntry[secondaryEffects.Count + 1];
            potionEffects[0] = new DaggerfallWorkshop.Game.MagicAndEffects.EffectEntry(potionEffect.Key, potionRecipe.Settings);
            for (int i = 0; i < secondaryEffects.Count; i++)
            {
                DaggerfallWorkshop.Game.MagicAndEffects.IEntityEffect effect = effectBroker.GetEffectTemplate(secondaryEffects[i]);
                potionEffects[i + 1] = new DaggerfallWorkshop.Game.MagicAndEffects.EffectEntry(effect.Key, potionRecipe.Settings);
            }
        }
        else
        {
            potionEffects = new DaggerfallWorkshop.Game.MagicAndEffects.EffectEntry[] { new DaggerfallWorkshop.Game.MagicAndEffects.EffectEntry(potionEffect.Key, potionRecipe.Settings) };
        }


        for (int i = 0; i < potionEffects.Length; ++i)
        {
            if (potionEffects[i].Settings.DurationBase <= 1)
            {
                effectDuration = "Instant";
            }
            else
            {
                effectDuration = potionEffects[i].Settings.DurationBase.ToString() + " Rounds";
            }

            if (potionEffects[i].Settings.MagnitudeBaseMax <= 1 && !potionEffects[i].Key.Contains("Regenerate"))
            {
                effectMagnitude = "N/A";
            }
            else
            {
                effectMagnitude = potionEffects[i].Settings.MagnitudeBaseMax.ToString();
            }

            if (potionEffects[i].Settings.ChanceBase <= 1)
            {
                effectChance = "N/A";
            }
            else
            {
                effectChance = potionEffects[i].Settings.ChanceBase.ToString() + "%";
            }

            string effectName = potionEffects[i].Key.Replace("-", " ");
            effectName = effectName.Replace("Elemental", "");
            effectName = effectName.Replace("SpellResistance", "Spell Resistance");
            effectName = effectName.Replace("Resistance ", "Resist ");
            effectName = effectName.Replace("WaterBreathing", "Water Breathing");
            effectName = effectName.Replace("SpellPoints", "Spell-Points");
            effectName = effectName.Replace("FreeAction", "Free Action");
            effectName = effectName.Replace("SpellReflection", "Spell Reflection");
            effectName = effectName.Replace("SpellAbsorption", "Spell Absorption");
            effectName = effectName.Replace("WaterWalking", "Water Walking");
            effectName = effectName.Replace("ComprehendLanguages", "Comprehend Languages");
            effectName = effectName + ": " + " Dur = " + effectDuration + "," + "  Mag = " + effectMagnitude + "," + "  Chan = " + effectChance;
            TextFile.Token[] effectTitle = DaggerfallUnity.Instance.TextProvider.CreateTokens(TextFile.Formatting.JustifyCenter, effectName);
            tokens = TextFile.AppendTokens(tokens, effectTitle, false);
        }

        return(tokens);
    }