kire12 Posted August 21, 2011 Share Posted August 21, 2011 I'm looking for help troubleshooting two scripts I've been working on for OBME effects. The first script is supposed to lower magic resistance depending on creature / actor type. It does this correctly, but does not restore the values as specified at the end of the duration. scriptname aaaapurifyundead ref pmagicitemshort dooncefloat spelltimerfloat holytimershort EffectMagshort EffectDurshort EffectIndexshort Damshort Dam2short Dam3short restshort rest2short rest3 Begin scripteffectstart set EffectIndex to GetScriptActiveEffectIndex set EffectMag to GetNthActiveEffectMagnitude EffectIndex set EffectDur to GetNthActiveEffectDuration EffectIndex set holytimer to effectdur set spelltimer to spelltimer+scripteffectelapsedseconds set pMagicItem to (GetNthActiveEffectMagicItem EffectIndex) set Dam to (0-EffectMag)set Dam2 to (0-EffectMag*.50)set Dam3 to 0set rest to effectmagset rest2 to (effectmag*1.5)set rest3 to 0 if iscreature==0 if isactorevil==1 modav2 resistmagic dam2 set doonce to 0 elseif isactorevil==0 modav2 resistmagic dam3 set doonce to 0 endif elseif iscreature==1 if (getcreaturetype==1) modav2 resistmagic dam2 set doonce to 0 elseif (getcreaturetype==2) modav2 resistmagic dam set doonce to 0 else modav2 resistmagic dam3 set doonce to 0 endif endifend begin scripteffectupdate if spelltimer>holytimer if iscreature==0 if isactorevil==1 modav2 resistmagic rest2 set doonce to 1 elseif isactorevil==0 modav2 resistmagic rest3 set doonce to 1 endif elseif iscreature==1 if (getcreaturetype==1) modav2 resistmagic rest2 set doonce to 1 elseif (getcreaturetype==2) modav2 resistmagic rest set doonce to 1 else modav2 resistmagic rest3 set doonce to 1 endif endifendif if doonce==1 dispel pmagicitem endifend The second script is having a similar problem. It is not removing the item that is added after the duration of the spell has ended scn aaaaholymiscitemadd short timeshort effectdurshort effectmagshort effectindexref selfshort time2 begin scripteffectstart set EffectIndex to GetScriptActiveEffectIndex set EffectMag to GetNthActiveEffectMagnitude EffectIndex set EffectDur to GetNthActiveEffectDuration EffectIndex set self to getself self.additemns aaaaholyhealingsalvation 1 self.equipitemns aaaaholyhealingsalvation set time to 1end begin scripteffectupdate set time2 to effectdur if time>0 set time to time2 - ScriptEffectElapsedSeconds else self.removeitem aaaaholyhealingsalvation 1endif end anyone that could help me fix these scripts would be greatly appreciated. Link to comment Share on other sites More sharing options...
RagnaHighArc Posted August 22, 2011 Share Posted August 22, 2011 (edited) On the second script, the obvious problem is that it never reaches the "else remove item" part. When the logic is true then the problem could be the way the code is written. Try this: if time > 0set time to (time - ScriptEffectElapsedSeconds)else... A space between "time" and "0" and parenthesis. Also, if you added an item with additemNS then maybe it also requires you to use removeitemNS or even just un-equipping the item first before removing it. Sounds dumb, but little things like that have caused me headaches before. Edited August 22, 2011 by RagnaHighArc Link to comment Share on other sites More sharing options...
kire12 Posted August 22, 2011 Author Share Posted August 22, 2011 Thank for the reply. I only have mediocre scripting experience. I noticed the infinite loop problem earlier, but forgot to remove it. This is the changed script. It now is removing the item directly after being cast. scn aaaaholymiscitemadd short timeshort effectdurshort effectmagshort effectindexref self begin scripteffectstart set EffectIndex to GetScriptActiveEffectIndex set EffectMag to GetNthActiveEffectMagnitude EffectIndex set EffectDur to GetNthActiveEffectDuration EffectIndex set self to getself self.additemns aaaaholyhealingsalvation 1 self.equipitemns aaaaholyhealingsalvation set time to effectdurend begin scripteffectupdate if time > 0 set time to (time - ScriptEffectElapsedSeconds) else self.unequipitemns aaaaholyhealingsalvation self.removeitemns aaaaholyhealingsalvation 1endif end Link to comment Share on other sites More sharing options...
kire12 Posted August 25, 2011 Author Share Posted August 25, 2011 (edited) Also I've been wondering. When creating an effect through a script is there anyway of assigning a kill caused by the spell to the player for compatibility with Oblivion XP? edit: Nevermind, figured that out. Edited August 25, 2011 by kire12 Link to comment Share on other sites More sharing options...
Recommended Posts