cjhorberg Posted June 23, 2019 Share Posted June 23, 2019 Hello Everyone I just have a question regarding spell scripting. I am trying to create a spell which contains a scripted effect which calculates how encumbered the character is as a percentage of maximum encumbrance. I have this sorted out so far. Then I want the spell to modify the magnitude of a "drain attribute" spell that is effecting the character, so that the more you are carrying, the more the spell drains your speed. I was trying to do this by having a spell called something like "Encumbrance effect" that has both a Script effect item and a Drain attribute effect item, and have the script effect modify the value of the Drain attribute effect in the same spell. I was trying to use "SetNthEffectItemMagnitude" to change the magnitude of the Drain Attribute spell effect, but this requires me to refer to the particular spell (in this case, the spell called "Encumbrance Effect"), but I don't know how to access it... Now that I think about it, is it even possible to effect the magnitude of a spell differently on different NPCs? Cheers Link to comment Share on other sites More sharing options...
Surilindur Posted July 11, 2019 Share Posted July 11, 2019 (edited) Hi and sorry about the massive delay, it has been a while since I opened the Construction Set and there were some problems getting it working. :sweat: As for how to get the active effect on a character, or more like, how to adjust the magnitude of an active effect on a character - yes, you can do that using some OBSE functions! As for whether it has any effect, like, whether the new magnitude is being applied as it is being changed - no idea. For testing purposes, I made the following custom function (classified as Object Script in the Construction Set) that takes as its parametersthe spell base form (the one that was cast/added/whatever to the character, listed under spells in the CS),the effect index (index of the effect in the effect list fo the spell in the CS, starts with 0 at the top), andthe new magnitude. scriptname ActiveEffectMagnitudeAdjustmentFunction ref SpellBaseForm ; base form of the spell that applied the effect float NewMagnitude ; new magnitude for the effect int MagicItemIndex ; index of the effect within the spell short ActiveEffectIndex ref ActiveEffectItem int ActiveEffectItemIndex begin _Function { SpellBaseForm MagicItemIndex NewMagnitude } let ActiveEffectIndex := GetActiveEffectCount PrintToConsole "ActiveEffect: Checking effects..." while ( ActiveEffectIndex > 0 ) let ActiveEffectIndex -= 1 let ActiveEffectItem := GetNthActiveEffectMagicItem ActiveEffectIndex PrintToConsole "%i : %n" ActiveEffectItem ActiveEffectItem if ( ActiveEffectItem != SpellBaseForm ) continue endif let ActiveEffectItemIndex := GetNthActiveEffectMagicItemIndex ActiveEffectIndex if ( ActiveEffectItemIndex != MagicItemIndex ) continue endif PrintToConsole "Found it! -> %i %n %d" ActiveEffectItem ActiveEffectItem ActiveEffectItemIndex SetNthActiveEffectMagnitude NewMagnitude ActiveEffectIndex break loop PrintToConsole "ActiveEffect: Checking finished" endAnd one could call it like: SomeCharacterRef.call ActiveEffectMagnitudeAdjustmentFunction SomeCustomSpell EffectIndex CustomMagnitudeI tested it, and it does set the magnitude of an active effect as seen in the character menus (in the active effects list), but I am not sure if the magnitude is actually being applied when it is changed. Like, I made it change the magnitude of a speed drain effect to 100 but the character was not slowed down at all, so I am not sure. At least the effect magnitude as shown in the list was adjusted! Yaaaaay progress! :happy: The .esp file I used for testing is available here, if it helps: link. Edited November 26, 2019 by Contrathetix Link to comment Share on other sites More sharing options...
Recommended Posts