Jump to content

Simple Toggle Spell - Help


Recommended Posts

I'm trying to create a simple toggle spell effect script that when you cast once, toggles on then on second cast toggles off but it stays as untoggled. Can anyone please explain how to get this working?

 

ScriptName SimpleToggle Extends activemagiceffect

Bool bToggle

Event OnEffectStart(Actor Target, Actor Caster)
bToggle = !bToggle ; Set Bool to whatever it's not
If bToggle
	Debug.MessageBox("Toggle")	
Else
	Debug.MessageBox("Un-Toggled")
Endif
EndEvent

 

Thanks

Link to comment
Share on other sites

First of, everything needs to be sent in as a property. Second, I doubt that's the best way to do it. Use something like this instead:

 

ScriptName SimpleToggleSpell Extends activemagiceffect

Spell Property dummyToogleSpell auto
MagicEffect Property dummyToogleEffect auto

Event OnEffectStart(Actor Target, Actor Caster)
if(Caster.hasMagicEffect(dummyToogleEffect)
	dummyToogleSpell.cast(Caster)
Else
	dummyToogleEffect.dispel(Caster)
Endif
EndEvent

 

You need two spells for this to work, one self cast spell with this script attached to it, and a dummy spell which has the actual effect.

I havn't worked with toogles before, but I think this is how you do it. Perhaps you need to use perks with abilities attached to them, but I'm not sure.

Link to comment
Share on other sites

You could attach a magic effect to a constant effect ability. You'd use HasSpell() to see if the player has the ability. If (s)he does, remove it. If (s)he doesn't, add it.

 

Edit: Nvm, I see they didn't set up the constant effect dropdown as well in Skyrim as they did in Oblivion. This method doesn't work as well and as universally as it did in Oblivion.

Edited by mojodajojo
Link to comment
Share on other sites

First of, everything needs to be sent in as a property. Second, I doubt that's the best way to do it. Use something like this instead:

 

ScriptName SimpleToggleSpell Extends activemagiceffect

Spell Property dummyToogleSpell auto
MagicEffect Property dummyToogleEffect auto

Event OnEffectStart(Actor Target, Actor Caster)
if(Caster.hasMagicEffect(dummyToogleEffect)
	dummyToogleSpell.cast(Caster)
Else
	dummyToogleEffect.dispel(Caster)
Endif
EndEvent

 

 

You need two spells for this to work, one self cast spell with this script attached to it, and a dummy spell which has the actual effect.

I havn't worked with toogles before, but I think this is how you do it. Perhaps you need to use perks with abilities attached to them, but I'm not sure.

 

Afraid when I pasted your script in place of my own I got an compiling error when saving:

"Starting 1 compile threads for 1 files...

Compiling "ToggleHelmet"...

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\ToggleHelmet.psc(7,51): missing RPAREN at '\\r\\n'

No output generated for ToggleHelmet, compilation failed.

 

Batch compile of 1 files finished. 0 succeeded, 1 failed.

Failed on ToggleHelmet"

Link to comment
Share on other sites

Nvm.. actually looked at the code and it was missing a bracket >.<

 

EDIT:

 

The line

dummyToogleEffect.Dispel(Caster)

Comes up with the error (14,20): Dispel is not a function or does not exist

 

I tried replacing it with

Caster.DispelSpell(dummyToogleEffect)

but that gets the error (13,7): type mismatch on parameter 1 (did you forget a cast?)

Edited by maniczombie
Link to comment
Share on other sites

Sorry if this sounds stupid but what is a spell parameter? I haven't done much with scripts or spells so some of the terminology is lost on me

 

Take a look at:

 

DispelSpell(Spell akSpell)

 

akSpell is the parameter in this function. Functions (and events) can have multiple parameters, such as:

 

Event OnEffectStart(Actor akTarget, Actor akCaster)

 

akTarget and akCaster are the parameters in this Event.

 

An updated toogle script based on previous comments:

 

ScriptName SimpleToggleSpell Extends activemagiceffect

Spell Property dummyConstantSpell auto

Event OnEffectStart(Actor Target, Actor Caster)
       if(Caster.hasSpell(dummyConstantSpell))
               Caster.removespell(dummyConstantSpell)
       Else
               Caster.addspell(dummyConstantSpell)
       Endif
EndEvent

Edited by Sjogga
Link to comment
Share on other sites

  • Recently Browsing   0 members

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