Jump to content

Requesting help on two scripts for magic effects


kire12

Recommended Posts

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 pmagicitem

short doonce

float spelltimer

float holytimer

short EffectMag

short EffectDur

short EffectIndex

short Dam

short Dam2

short Dam3

short rest

short rest2

short 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 0

set rest to effectmag

set 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

 

endif

end

 

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

 

endif

endif

 

if doonce==1

dispel pmagicitem

endif

end

 

 

 

 

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 time

short effectdur

short effectmag

short effectindex

ref self

short 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 1

end

 

begin scripteffectupdate

 

set time2 to effectdur

 

 

 

if time>0

set time to time2 - ScriptEffectElapsedSeconds

 

else

self.removeitem aaaaholyhealingsalvation 1

endif

 

 

end

 

 

 

anyone that could help me fix these scripts would be greatly appreciated.

Link to comment
Share on other sites

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 > 0

set 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 by RagnaHighArc
Link to comment
Share on other sites

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 time

short effectdur

short effectmag

short effectindex

ref 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 effectdur

end

 

begin scripteffectupdate

 

if time > 0

set time to (time - ScriptEffectElapsedSeconds)

 

else

self.unequipitemns aaaaholyhealingsalvation

self.removeitemns aaaaholyhealingsalvation 1

endif

 

 

end

 

 

Link to comment
Share on other sites

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 by kire12
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...