I wrote a generic script that i could attach to multiple effects and fill with the properties as required, which is below. This script works without any problems.
Spoiler
Scriptname FoodFillValueScript_XQFoods extends activemagiceffect {Script to add a fill value to food}Actor Property PlayerRef AutoGlobalVariable Property Glob_FillValue_XQFoods AutoMagicEffect Property FoodCDEffect AutoMagicEffect Property FoodEffect1 AutoMagicEffect Property FoodEffect2 AutoSpell Property SP_Bloated_XQFoods AutoString Property Effect1 AutoString Property Effect2 AutoInt Property FoodValue AutoInt Property FX1Mag AutoInt Property FX2Mag AutoFloat CurFillValFloat FillValueEvent OnEffectStart(Actor akCaster, Actor akTarget) CalculateFillValue(PlayerRef) Game.EnablePlayerControls() CurFillVal = Glob_FillValue_XQFoods.GetValue() Glob_FillValue_XQFoods.SetValue(CurFillVal+FoodValue) debug.notification("Fill Value ="http://forums.bethsoft.com/topic/1431342-obtaining-active-magic-effect-using-a-generic-script/+Glob_FillValue_XQFoods.GetValue()) if (Glob_FillValue_XQFoods.GetValue())> FillValue RemoveEffects(PlayerRef) endif EndEventEvent OnEffectFinish(Actor akCaster, Actor akTarget) CurFillVal = Glob_FillValue_XQFoods.GetValue() Glob_FillValue_XQFoods.SetValue(CurFillVal-FoodValue) debug.notification ("Fill Value = "http://forums.bethsoft.com/topic/1431342-obtaining-active-magic-effect-using-a-generic-script/+Glob_FillValue_XQFoods.GetValue())EndEvent Function RemoveEffects(Actor akCaster) SP_Bloated_XQFoods.Cast(PlayerRef) PlayerRef.DamageActorValue(Effect1, FX1Mag) PlayerRef.DamageActorValue(Effect2, FX2Mag)EndFunction Function CalculateFillValue(Actor akCaster)Float PlyLvl = PlayerRef.GetLevel() FillValue = 10+ Math.Floor(PlyLvl/8) Debug.notification("Calulated fill value = "http://forums.bethsoft.com/topic/1431342-obtaining-active-magic-effect-using-a-generic-script/+FillValue) Game.DisablePlayerControls() Utility.Wait(0.1)EndFunction
Once the player eats too much food, the last piece of food they eat, i wanted to dispel only those effects. This is not a problem with instant effects such as heal 10 points, as i can damage the stat by the same amount.
It is those effects which are duration based which i have a problem dispelling.
Since food is classed as a potion, i cannot use DispelSpell(), another way was to use a keyword (KYWD_Bloated_XQFoods) attached to all effects, so that when the spell SP_Bloated_XQFoods is applied to the player, all the magic effects with that keyword are dispelled.
Whilst Papyrus will compile an ActiveMagicEffect as a property, you cannot fill that property in the CK (the fill options are greyed out).
I looked at the dispel function, however this requires an active magic effect, yet i cannot find a way to create a generic way of defining/obtaining the active magic effect.
Any suggestions would be appreciated