Exemple #1
0
 /// <summary>
 /// int[] array of item template IDs constructor.
 /// </summary>
 /// <param name="displayName">Potion name to use for this recipe.</param>
 /// <param name="price">Value of potion in gp.</param>
 /// <param name="settings">Settings for this potion recipe.</param>
 /// <param name="ids">Array of item template IDs.</param>
 public PotionRecipe(string displayName, int price, EffectSettings settings, params int[] ids)
 {
     DisplayName   = displayName;
     Price         = price;
     this.Settings = settings;
     Array.Sort(ids);
     if (ids != null && ids.Length > 0)
     {
         ingredients = new Ingredient[ids.Length];
         for (int i = 0; i < ids.Length; i++)
         {
             ingredients[i].id = ids[i];
         }
     }
 }
Exemple #2
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="key">Effect key.</param>
        /// <param name="settings">Effect settings.</param>
        /// <returns>Interface to new effect instance.</returns>
        public IEntityEffect InstantiateEffect(string key, EffectSettings settings)
        {
            if (!HasEffectTemplate(key))
            {
                return(null);
            }

            IEntityEffect effectTemplate = magicEffectTemplates[key];
            IEntityEffect effectInstance = Activator.CreateInstance(effectTemplate.GetType()) as IEntityEffect;

            effectInstance.Settings       = settings;
            effectInstance.CurrentVariant = effectTemplate.CurrentVariant;

            return(effectInstance);
        }
Exemple #3
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public BaseEntityEffect()
        {
            // Set default properties
            properties.ShowSpellIcon           = true;
            properties.SupportDuration         = false;
            properties.SupportChance           = false;
            properties.SupportMagnitude        = false;
            properties.AllowedTargets          = TargetTypes.CasterOnly;
            properties.AllowedElements         = ElementTypes.Magic;
            properties.AllowedCraftingStations = MagicCraftingStations.None;
            properties.MagicSkill = DFCareer.MagicSkills.None;

            // Set default settings
            settings = GetDefaultSettings();

            // Allow effect to set own properties
            SetProperties();
        }
Exemple #4
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);
        }
Exemple #5
0
        public static EffectSettings DefaultEffectSettings()
        {
            EffectSettings defaultSettings = new EffectSettings();

            // Default duration is 1 + 1 per level
            defaultSettings.DurationBase     = 1;
            defaultSettings.DurationPlus     = 1;
            defaultSettings.DurationPerLevel = 1;

            // Default chance is 1 + 1 per level
            defaultSettings.ChanceBase     = 1;
            defaultSettings.ChancePlus     = 1;
            defaultSettings.ChancePerLevel = 1;

            // Default magnitude is 1-1 + 1-1 per level
            defaultSettings.MagnitudeBaseMin  = 1;
            defaultSettings.MagnitudeBaseMax  = 1;
            defaultSettings.MagnitudePlusMin  = 1;
            defaultSettings.MagnitudePlusMax  = 1;
            defaultSettings.MagnitudePerLevel = 1;

            return(defaultSettings);
        }
Exemple #6
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);
        }
 public EffectEntry(string key, EffectSettings settings, EnchantmentParam?enchantmentParam = null)
 {
     Key              = key;
     Settings         = settings;
     EnchantmentParam = enchantmentParam;
 }
 public EffectEntry(string key, EnchantmentParam?enchantmentParam = null)
 {
     Key              = key;
     Settings         = new EffectSettings();
     EnchantmentParam = enchantmentParam;
 }
Exemple #9
0
 public EffectEntry(string key, EffectSettings settings)
 {
     Key      = key;
     Settings = settings;
 }
Exemple #10
0
 public EffectEntry(string key)
 {
     Key      = key;
     Settings = new EffectSettings();
 }
Exemple #11
0
 /// <summary>
 /// Ingredient[] array constructor.
 /// </summary>
 /// <param name="settings">Settings for this potion recipe.</param>
 /// <param name="ingredients">Ingredient array.</param>
 public PotionRecipe(EffectSettings settings, params Ingredient[] ingredients)
 {
     this.settings    = settings;
     this.ingredients = ingredients;
 }
Exemple #12
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public PotionRecipe()
 {
     settings = BaseEntityEffect.DefaultEffectSettings();
 }