Talk:MessageBox Tutorial/Spell Scripts
< Talk:MessageBox Tutorial
Jump to navigation
Jump to search
Revision as of 01:57, 1 June 2008 by imported>Wrye (Talk:MessageBox Tutorial: Spell Scripts moved to Talk:MessageBox Tutorial/Spell Scripts: Rename as subpage.)
See Talk:MessageBox_Tutorial for the discussion.
Haama, out of curiosity, why do you have so many
If (Choice == -1) ;No choice yet Set Choice to GetButtonPressed
statements in the script? If you use a couple more If statements, you could just put one of those in and remove that If statement from each of the additional menu sections. I don't even think you need to use an If statement with GetButtonPressed to begin with.
--ShadowDancer 05:59, 29 August 2007 (EDT)
- See here. It's rare, but I've needed to do it, and I've had to answer a couple of threads on it.
- --Haama 11:50, 29 August 2007 (EDT)
- OK, I can understand the reasoning behind using the If statement and that makes sense. However all of the GetButtonPressed statements can still be handled by just one If statement outside of the main If/ElseIf statements can't they? If the If statement were the first in the ScriptEffectUpdate, it won't fire because choice will be zero during the first iteration, but will then be overridden once any button is clicked from the MessageBox section including moving to a new menu. Once that section starts looping, it will keep looking for a return of something besides -1 and will eventually produce the key choice. At that point, even if you are doing looping for counting items, choice will no longer be -1 and it won't fire during those loops. And if it is -1 because the Magic Effect script ran out of time, ScriptEffectUpdate will still just return -1 and loop.
- BTW, there is one small issue here that hasn't been explored yet (as far as I know). If someone clicked on a button and it hasn't returned from the GetButtonPressed and you run out of time, your Choosing will be positive on recasting of the spell. I am not sure if that button press will show up after the recasting of the spell. Do you have any idea about this? I am also adding in the dispel section that I wrote in the other Talk section of the original article so that when finishing the spell by choice it dispels the spell.
- --ShadowDancer 08:05, 30 August 2007 (EDT)
- wrt Choice == -1: It just didn't come up while explaining the common mistakes. In fact, I have it in an extra here. In a sense, I also didn't put it in because it would reduce some flexibility, but I can't really imagine a scenario where you would want one menu to use GetButtonPressed differently from another.
- wrt Spells ending: Hmm... I know that the button press won't be returned to another object's script, and I don't think 2 spells would be any different, but I don't know. Maybe 2 iterations of the same spells on the same NPC/PC will work, but, yeah, I doubt it.
- Is there a way to easily tell how much time the spell has left? Maybe if there's only 1 second left then it'll go ahead and cast the next spell? I don't really like 'GetSecondsPassed' too much, as it's CPU heavy, and I think 15 frames will be the important factor.
- Also, if you cast the spell at a TargetRef near the player (say an activator over their head), that would prevent any Magic symbols from coming up, right? (or, really, if you cast this spell on the player, a symbol would come up, right?)
- --Haama 14:37, 30 August 2007 (EDT)
- Yes, if you cast this spell on a character, it will produce a spell icon in the upper right corner of the screen, which is why I included the section for the spell to be dispelled so it doesn't hang around for no reason. I don't know of an easy way to tell how much time is left in a spell other than using GetSecondsPassed. However, I just ran an interesting test. I loaded a MessageBox in the ScriptEffectFinish block with 2 buttons to choose from and added a section to the ScriptEffectUpdate block that didn't even start checking for GetButtonPressed until a set number of frames passed. The next casting of the spell still managed to catch the button press after 120 frames of not looking for it.
Script:
Scriptname SCTrialEffect Short Button Short SEUCount Short GMCount Short MBVariable Ref TargetRef Begin ScriptEffectStart Set TargetRef to GetSelf Player.PlayMagicShaderVisuals effectAtronachFlame Message "Spell Started" End Begin ScriptEffectUpdate If MBVariable == 0 && SEUCount > 120 Set Button to GetButtonPressed If Button == 0 MessageBox "Script Effect Update Mode" Set MBVariable to 1 ElseIf Button == 1 MessageBox "Game Mode" Set MBVariable to 1 Endif Endif Set SEUCount to SEUCount + 1 End Begin GameMode Set GMCount to GMCount + 1 End Begin ScriptEffectFinish Player.StopMagicShaderVisuals effectAtronachFlame MessageBox "ScriptEffectUpdate Count = %3.0f GameMode Count = %3.0f", SEUCount, GMCount, "SEU Mode", "Game Mode" Set Button to GetButtonPressed TargetRef.Cast SCTestFire TargetRef End
I was thinking that the StopMagicShaderVisuals statement should be down in the ScriptEffectFinish section so that it always stops the shader even if time runs out while the timer is counting down. Would you agree with that assessment?
--ShadowDancer 08:23, 30 August 2007 (EDT)
- Sounds good, but this post is bugging me.
- --Haama 14:37, 30 August 2007 (EDT)
- Hmm. Interesting, but not very likely in a 4 second duration. I think you would have to be actively trying to get that to happen in 4 seconds. Could drop the effect shader duration though, or even do the StopMagicShaderVisuals twice, once in the ScriptEffectUpdate section and once in the ScriptEffectFinish.
- --ShadowDancer 16:59, 30 August 2007 (EDT)
- Umm, apparently I am not sure what they are talking about. I tried resting in the Dispel section of the spell and still got the MessageBox popping up in the middle of the countdown for resting/sleeping, so I know that the ScriptEffectFinish block is firing while resting. This is after setting rest time and starting the countdown for resting. The only thing that didn't work properly is the spell being recast due to resting, but then again, at the point of dispelling the spell, it wouldn't be recast anyways. The effect shader was still there on waking but immediately fades away, which makes a peculiar sort of sense with the way they work in Oblivion since there is always a fadeout time on them.
Script:
Scriptname SCTrialEffect Float Timer Short Button Short DoOnce Short SEUCount Short GMCount Short MBVariable Short MMCount Ref TargetRef Begin ScriptEffectStart Set TargetRef to GetSelf Message "Spell Started" End Begin ScriptEffectUpdate If MBVariable == 0 && SEUCount > 120 Set Button to GetButtonPressed If Button == 0 MessageBox "Script Effect Update Mode" Set MBVariable to 1 ElseIf Button == 1 MessageBox "Game Mode" Set MBVariable to 1 EndIf ;Start Dispel Block If (DoOnce == 0) PlayMagicShaderVisuals effectAtronachFlame Set DoOnce to 1 Set Timer to 4 ElseIf (Timer > 0) Set Timer to Timer - GetSecondsPassed ElseIf (Timer < 0) StopMagicShaderVisuals effectAtronachFlame Set Timer to 0 TargetRef.Dispel SCTestFire EndIf ;End Dispel Block EndIf Set SEUCount to SEUCount + 1 End Begin GameMode Set GMCount to GMCount + 1 End Begin ScriptEffectFinish Player.StopMagicShaderVisuals effectAtronachFlame MessageBox "ScriptEffectUpdate Count = %3.0f GameMode Count = %3.0f", SEUCount, GMCount, "SEU Mode", "Game Mode" Set Button to GetButtonPressed TargetRef.Cast SCTestFire TargetRef End
- --ShadowDancer 06:58, 31 August 2007 (EDT)