User:Candlemaster/Absorb Frost/Progress
First AttemptEdit
if ( Timer < 1 ) set Timer to ( Timer + GetSecondsPassed ) Return else if ( HasMagicEffect FRDG == 1 ) set FrostMag to GetTotalActiveEffectMagnitude FRDG ;This function uses OBSE set FrostMag to ( FrostMag * 2 ) ModAV2 Health FrostMag ;ModAV2 is also OBSE endif set Timer to 0 endif
The idea was to calculate how much frost damage the user is currently experiencing it, then use ModAV2 to restore health (double the magnitude of the frost) every second. There are many problems with this script, the most obvious is that is has an extremely low chance of catching instant-duration spells.
Second AttemptEdit
scn HVHAbsorbFrostScriptOBSE long FrostMag ref UserRef Begin OnAdd set UserRef to GetContainer End Begin OnEquip UserRef.PlayMagicShaderVisuals GhostEffect UserRef.AddSpellNS HVHAbsorbFrostHeal End Begin OnUnequip UserRef.StopMagicShaderVisuals GhostEffect UserRef.RemoveSpellNS HVHAbsorbFrostHeal End Begin GameMode if ( UserRef.HasMagicEffect FRDG == 1 ) set FrostMag to UserRef.GetTotalActiveEffectMagnitude FRDG set FrostMag to ( FrostMag * 2 ) else set FrostMag to 0 endif SetNthEffectItemMagnitude FrostMag HVHAbsorbFrostHeal 0 End
This script is attached to a wearable item. When the user puts on the item, the script applies an ability to the player - the ability only has a single effect, Restore Health 0 points. The script is supposed to detect how much frost damage the user is feeling at any given frame, then change the magnitude of the restore health ability to double the total magnitude of frost damage. The shader effect and healing ability is applied to the player as desired, but no healing takes place. At this time, I have no idea why this script doesn't work.
Third AttemptEdit
scn HVHAbsorbFrostScriptOBSE long TempMag ;This variable stores the magnitude of the frost damage, and alterations are made upon it. long EffectCode ;Stores the effect code of the desired magic effect, since "GetNthActiveEffectCode" returns longs instead of chars ref UserRef ;The user (in most cases, the player - This exists instead of "player" to allow you to give it to npc's or companions) long NumEffects long CurrentEffect Begin OnAdd set UserRef to GetContainer End Begin GameMode if ( UserRef.GetEquipped HVHIceRobeOBSE == 0 ) return ;Do nothing if the user doesn't have the item equipped endif set NumEffects to UserRef.GetActiveEffectCount set CurrentEffect to 0 set EffectCode to GetMagicEffectCode FRDGÂ ; Sets "Frost Damage" as the affected magic effect if ( NumEffects <= 0 ) return ;stops the loop from running at all if the player doesn't have any active effects endif Label ;The loop begins here If ( UserRef.GetNthActiveEffectCode CurrentEffect == EffectCode ) ;Only apply the script to the effect you want set TempMag to UserRef.GetNthActiveEffectMagnitude CurrentEffect if ( TempMag > 0 ) ;Only apply to magnitudes that we haven't already reversed set TempMag to ( TempMag * -1 ) UserRef.SetNthActiveEffectMagnitude TempMag CurrentEffect endif endif set CurrentEffect to ( CurrentEffect + 1 ) if ( CurrentEffect < NumEffects ) GoTo ;The loop ends here, but only if you have no more effects to go through. endif End
This script finds each individual frost damage effect on the player, and reverses the magnitude to a negative of itself. This script was made under the asumption that negative-magnitude frost damage would heal the target instead of damage. It appears that this assumption was incorrect, as the player will takes damage. However, in the "active effects" menu in-game, "frost damage" displays as a positive magnitude - this could indicate that the effects are not being properly reversed. I will assume, at this point, that the script works properly, but negative-magnitude frost damage works the same as positive-magnitude frost damage. This script may work with other effects however, such as Damage Health.
It should be noted that, if my assumptions are correct, this script should work fine with effects where negative magnitudes result in a desirable effect - Damage Health is noted to work, and I believe that fortify/drain effects may work too. This requires further testing.
Fourth AttemptEdit
scn HVHAbsorbFrostScriptOBSE long FrostMag ref UserRef Begin OnEquip UserRef.PlayMagicShaderVisuals HVHEffectAbsorbFrost End Begin OnUnequip UserRef.StopMagicShaderVisuals HVHEffectAbsorbFrost End Begin GameMode set UserRef to GetContainer if ( UserRef.GetEquipped HVHIceRobeOBSE == 0 ) return endif set FrostMag to UserRef.GetTotalActiveEffectMagnitude FRDG if ( FrostMag >= 1 ) if ( UserRef.HasSpell HVHAbsorbFrostHeal == 0 ) UserRef.AddSpellNS HVHAbsorbFrostHeal endif set FrostMag to ( FrostMag * 2 ) SetNthEffectItemMagnitude FrostMag HVHAbsorbFrostHeal 0 else if ( UserRef.HasSpell HVHAbsorbFrostHeal == 1 ) UserRef.RemoveSpellNS HVHAbsorbFrostHeal endif endif End
Here's attempt #4. I modified attempt #2, under the assumption the problem was the 0-magnitude restore health ability. This method instead uses a 1-point restore health ability, applied only when the user is experiencing frost damage, and removed otherwise. Otherwise, it is the same as attempt #2. This script doesn't do much more than the previous 3 attempts however, but something interesting happened that may be significant.
When i looked in my "Active effects" page, I saw "Frost Damage" present (17 points of it, in fact). However, "restore health" was nowhere to be seen. This means that, for whatever reason, "UserRef.AddSpellNS HVHAbsorbFrostHeal" did not happen.
Current ProgressEdit
I'm currently re-looking at Attempt #2, specifically at why it doesn't do what it should do. Discussion is continuing Here[1].
Through console printouts, I've found something extremely interesting. When the player is hit by frost damage, it registers the magnitude as a negative. This could change everything, but more testing is needed right now.