Jump to content

A small script, need a bit of help.


Frozen2Dream

Recommended Posts

ScriptName RemFrostyStatue

Short IsFrozen

 

Begin ScriptEffectStart

If IsFrozen==1

StopMagicShaderVisuals RemIceEffect

ToggleActorsAI

SetRestrained 0

Set IsFrozen to 0

Endif

If IsFrozen==0

PlayMagicShaderVisuals RemIceEffect

ToggleActorsAI

SetRestrained 1

Set IsFrozen to 1

Endif

 

End

 

 

So, I think you see what happens.

My problem, is that how the script flows.

This is my first script, to bear with me if im stupid.

The script goes down, so if it IS frozen, it unfreezes him...then freezes him again lol.

I see why, I just dont know how to fix it, any pointers?

Oh and this is a spell. You cast it on someone and it turns em to ice.

Im trying to make it so if you cast it again, itll unfreeze them.

 

Or do I need to make a simple cure spell?

 

 

 

Also, if this is a bad place to post, please say so. I have a TESNexus account so I thought I might as well try here.

Edited by Frozen2Dream
Link to comment
Share on other sites

A much better way would be to have an ability which takes care of the freezing/unfreezing and a spell which adds/removes the ability.

 

For the Ability, just have a single script effect:

SCN RemFrostyStatueAbility

Begin ScriptEffectStart
PlayMagicShaderVisuals RemIceEffect
ToggleActorsAI
SetRestrained 1
end

Begin ScriptEffectFinish
StopMagicShaderVisuals RemIceEffect
ToggleActorsAI
SetRestrained 0
end

 

For the Spell:

SCN RemFrostyStatue

Begin ScriptEffectStart
If RemoveSpell **** == 0
 AddSpell ****
EndIf
end

Just replace **** with the Object ID of the actual ability spell

Edited by Skevitj
Link to comment
Share on other sites

I think your post should probably in the mod troubleshooting forum. As for me, what I would do to get that script to work is make IsFrozen a global variable, and change the script to this:

 

ScriptName RemFrostyStatue

Begin ScriptEffectStart

if IsFrozen == 1
	StopMagicShaderVisuals RemIceEffect
	ToggleActorsAI
	SetRestrained 0
	set IsFrozen to 0
elseif IsFrozen == 0
	PlayMagicShaderVisuals RemIceEffect
	ToggleActorsAI
	SetRestrained 1
	set IsFrozen to 1
endif

End

Link to comment
Share on other sites

ScriptEffectStart runs once at the beginning of a spell, and ScriptEffectFinish runs once at the end of a spell, so a much better option would be:

SCN RemFrostyStatue

Begin ScriptEffectStart
PlayMagicShaderVisuals  RemIceEffect
ToggleActorsAI
SetRestrained 1
end

Begin ScriptEffectFinish
StopMagicShaderVisuals RemIceEffect
ToggleActorsAI
SetRestrained 0
end

Yes but the end effect is only by a timer, right? Or can you trigger it somehow?

I dont want the 'statue' effect to end, I want it to stay until somehow I trigger it to end.

The easy way would just be to make a cure spell, but I am hoping to make it all in one script somehow.

 

Edit: Herp, I posted to quick and didnt see your edit, lol.

 

 

I think your post should probably in the mod troubleshooting forum. As for me, what I would do to get that script to work is make IsFrozen a global variable, and change the script to this:

 

ScriptName RemFrostyStatue

Begin ScriptEffectStart

if IsFrozen == 1
	StopMagicShaderVisuals RemIceEffect
	ToggleActorsAI
	SetRestrained 0
	set IsFrozen to 0
elseif IsFrozen == 0
	PlayMagicShaderVisuals RemIceEffect
	ToggleActorsAI
	SetRestrained 1
	set IsFrozen to 1
endif

End

Oooh, that looks like it would work.

Thanks, I will test it and post again if it doesnt work.

How would I be able to make IsFrozen a global, and whats the difference? If you dont mind explaining. XP

And acturally, if I set it as a global, would the script still be able to work with multiple people/objects?

 

By the sound of 'global' I assume the variable would be set for everyone, not just one specfic actor. So it being a global wouldnt be script specfic?

If that makes any sense..

Edited by Frozen2Dream
Link to comment
Share on other sites

Well I'm not sure whether or not variables from a magic effect script would stay initialized after the spell's duration is over, so I suggested making it a global variable. But now that I think about it, having it as a global isn't a good idea because it could get a bit messy when you try to freeze more than 1 NPC. In other words, just use your original script but change the middle to using elseif.

 

And a global variable means that it's a variable stored outside of any scripts, references, etc. Any script, reference, etc. can use them at any time.

Edited by fg109
Link to comment
Share on other sites

Well I'm not sure whether or not variables from a magic effect script would stay initialized after the spell's duration is over, so I suggested making it a global variable. But now that I think about it, having it as a global isn't a good idea because it could get a bit messy when you try to freeze more than 1 NPC. In other words, just use your original script but change the middle to using elseif.

 

And a global variable means that it's a variable stored outside of any scripts, references, etc. Any script, reference, etc. can use them at any time.

Thats what im going to try, thank you for the help.

Link to comment
Share on other sites

Sorry 'bout that, for some reason almost every time I try and edit something the formatting kills itself. Takes a while to fix it all up. My post #2 should work fine as it at the moment.

 

A Global for this is a bad idea, simply due to the fact it will apply that value to everyone, hence if someone is frozen, and you try to freeze someone else, all that will happen is their AI will be shut off.

 

The reason your first script failed (assuming you use the elseif correction fg109 used) is that magic scripts are trashed as soon as the spell effect ends, ie, the variables don't carry over, so the use of an ability kludges a way for them to persist as well as providing a solution which will work for any number of casts.

Edited by Skevitj
Link to comment
Share on other sites

Sorry 'bout that, for some reason almost every time I try and edit something the formatting kills itself. Takes a while to fix it all up. My post #2 should work fine as it at the moment.

 

A Global for this is a bad idea, simply due to the fact it will apply that value to everyone, hence if someone is frozen, and you try to freeze someone else, all that will happen is their AI will be shut off.

 

The reason your first script failed (assuming you use the elseif correction fg109 used) is that magic scripts are trashed as soon as the spell effect ends, ie, the variables don't carry over, so the use of an ability kludges a way for them to persist as well as providing a solution which will work for any number of casts.

 

Yeah, I realized the global wouldn't work well for this (see my second post). And now I guess I know for sure that magic script variables are very temporary, thanks. Your idea about having the spell add an ability sounds great.

Edited by fg109
Link to comment
Share on other sites

Well, it half worked, the original problem still persists though.

When I cast a second time, it doesn't unfreeze like it should. It seems to just refreeze the character/object.

 

The reason your first script failed (assuming you use the elseif correction fg109 used) is that magic scripts are trashed as soon as the spell effect ends, ie, the variables don't carry over, so the use of an ability kludges a way for them to persist as well as providing a solution which will work for any number of casts.

Even if the duration is set to 0? I would figure 0 would mean forever =\ oh well.

"so the use of an ability kludges a way for them to persist as well as providing a solution which will work for any number of casts"

some reason I dont understand that?

The use of an ability? What ability? Or am I supposed to make the script in the form of a ability?

sorry for being retarded, lol.

 

 

By reading that, I ran another test. I turned the duration of the spell to 900.

I figured if I set it higher, the script would 'continue running'(?) and it would allow the script to unfreeze the actor.

even if the timer did it, you could cast twice, once to refreeze and reactivate the script, and two to unfreeze.

 

However, this didnt even work. even with a higher duration. If I casted twice, it would only refreeze again anyway.

 

Also, snapshot for laughs.

http://img851.imageshack.us/img851/2144/frozen.png

And yes, I missed and hit the door.

Edited by Frozen2Dream
Link to comment
Share on other sites

The idea from my post is you create an ability which contains a script effect with the first script, not a spell.

 

The actual spell you cast contains a different script effect, with the second short script in it.

 

I didn't put any checks in it so it will apply the freeze to all objects, simply adding in a GetDead==0 check to the second script should make sure that it only effects living creatures.

 

EDIT: Done... I've just rigged up a copy/paste version of what I posted in #2. The spell should be added to the PC when as soon as it is loaded. I haven't included the GetDead check, but I just tested it then and it seems to work perfectly. Freezing them on the first cast and unfreezing them on the second. I had to change the shader effect since I don't have your custom one.

 

 

EDIT2: Just to clarify, When you cast a scripted spell at a target for a second time, it will apply a new version of the script, not re-run any already on them. Hence variables stuck inside a script are contained within that single spell cast. So even if the duration was infinite, you would just be infinitely re-freezing them every time as your script couldn't see the effect already on them.<br>

Edited by Skevitj
Link to comment
Share on other sites

  • Recently Browsing   0 members

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