コード例 #1
0
        /// <summary>
        /// Generate EffectBundleSettings for an artifact of a specified SpecialArtifactEffect index
        /// </summary>
        /// <param name="settings">Settings for artifact effect (if found)</param>
        /// <returns>True if spell found, otherwise false.</returns>
        public bool GetArtifactBundleSettings(out EffectBundleSettings settings, int effectIndex)
        {
            string      effectKey        = string.Empty;
            TargetTypes effectTargetType = TargetTypes.None;

            switch (effectIndex)
            {
            case (int)ArtifactsSubTypes.Wabbajack:
                effectKey        = "WabbajackEffect";
                effectTargetType = TargetTypes.ByTouch;
                break;

            case (int)ArtifactsSubTypes.Mehrunes_Razor:
                effectKey        = "MehrunesRazorEffect";
                effectTargetType = TargetTypes.ByTouch;
                break;

            case (int)ArtifactsSubTypes.Sanguine_Rose:
                effectKey        = "SanguineRoseEffect";
                effectTargetType = TargetTypes.CasterOnly;
                break;
            }
            settings = new EffectBundleSettings
            {
                Effects    = new EffectEntry[] { new EffectEntry(effectKey) },
                TargetType = effectTargetType
            };

            return(effectKey != string.Empty);
        }
コード例 #2
0
 /// <summary>
 /// Allows a mod to register custom spell bundles for sale at the spell maker along with classic spells.
 /// </summary>
 /// <param name="key">Unique key of bundle for tracking.</param>
 /// <param name="bundleSettings">EffectBundleSettings of spell bundle to offer.</param>
 public void RegisterCustomSpellBundleOffer(string key, EffectBundleSettings bundleSettings)
 {
     if (customSpellBundleOffers.ContainsKey(key))
     {
         Debug.LogErrorFormat("RegisterCustomSpellBundleOffer: Duplicate bundle key '{0}'", key);
         return;
     }
     customSpellBundleOffers.Add(key, bundleSettings);
 }
コード例 #3
0
        /// <summary>
        /// Generate EffectBundleSettings from classic SpellRecordData.
        /// </summary>
        /// <param name="spellRecordData">Classic spell record data.</param>
        /// <param name="bundleType">Type of bundle to create.</param>
        /// <param name="effectBundleSettingsOut">Effect bundle created by conversion.</param>
        /// <returns>True if successful, otherwise false.</returns>
        public bool ClassicSpellRecordDataToEffectBundleSettings(SpellRecord.SpellRecordData spellRecordData, BundleTypes bundleType, out EffectBundleSettings effectBundleSettingsOut)
        {
            // Spell record data must have effect records
            if (spellRecordData.effects == null || spellRecordData.effects.Length == 0)
            {
                effectBundleSettingsOut = new EffectBundleSettings();
                return(false);
            }

            // Create bundle
            effectBundleSettingsOut = new EffectBundleSettings()
            {
                Version            = EntityEffectBroker.CurrentSpellVersion,
                BundleType         = bundleType,
                TargetType         = ClassicTargetIndexToTargetType(spellRecordData.rangeType),
                ElementType        = ClassicElementIndexToElementType(spellRecordData.element),
                Name               = spellRecordData.spellName,
                IconIndex          = spellRecordData.icon,
                Icon               = new SpellIcon(),
                StandardSpellIndex = spellRecordData.index,
            };
            effectBundleSettingsOut.Icon.index = effectBundleSettingsOut.IconIndex;

            // Assign effects
            List <EffectEntry> foundEffects = new List <EffectEntry>();

            for (int i = 0; i < spellRecordData.effects.Length; i++)
            {
                // Skip unused effect slots
                if (spellRecordData.effects[i].type == -1)
                {
                    continue;
                }

                // Get entry from effect
                EffectEntry entry;
                if (!ClassicEffectRecordToEffectEntry(spellRecordData.effects[i], out entry))
                {
                    continue;
                }

                // Assign to valid effects
                foundEffects.Add(entry);
            }

            // Must have assigned at least one valid effect
            if (foundEffects.Count == 0)
            {
                return(false);
            }

            // Assign effects to bundle
            effectBundleSettingsOut.Effects = foundEffects.ToArray();

            return(true);
        }
コード例 #4
0
        /// <summary>
        /// Helper to create a disease effect bundle from any effect key.
        /// This is just here for testing right now as no custom diseases exist.
        /// </summary>
        /// <param name="key">Effect key to use as infection.</param>
        /// <returns>EntityEffectBundle.</returns>
        public EntityEffectBundle CreateDisease(string key)
        {
            EffectBundleSettings settings = new EffectBundleSettings()
            {
                Version    = EntityEffectBroker.CurrentSpellVersion,
                BundleType = BundleTypes.Disease,
                Effects    = new EffectEntry[] { new EffectEntry(key) },
            };

            return(new EntityEffectBundle(settings, entityBehaviour));
        }
コード例 #5
0
        /// <summary>
        /// Helper to create a classic disease effect bundle.
        /// </summary>
        /// <param name="diseaseType">Classic disease type.</param>
        /// <returns>EntityEffectBundle.</returns>
        public EntityEffectBundle CreateDisease(Diseases diseaseType)
        {
            EffectBundleSettings settings = new EffectBundleSettings()
            {
                Version    = EntityEffectBroker.CurrentSpellVersion,
                BundleType = BundleTypes.Disease,
                Effects    = new EffectEntry[] { new EffectEntry(DiseaseEffect.GetClassicDiseaseEffectKey(diseaseType)) },
            };

            return(new EntityEffectBundle(settings, entityBehaviour));
        }
コード例 #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);
        }
コード例 #7
0
 /// <summary>
 /// Settings + caster constructor.
 /// </summary>
 /// <param name="settings">Settings of this effect bundle.</param>
 /// <param name="casterEntityBehaviour">Caster of this effect bundle (optional).</param>
 public EntityEffectBundle(EffectBundleSettings settings, DaggerfallEntityBehaviour casterEntityBehaviour = null)
 {
     this.settings = settings;
     this.casterEntityBehaviour = casterEntityBehaviour;
 }