Blocktypes

Post » Thu Sep 09, 2010 10:14 am

A couple of the Shivering Isles weapon enchantments cause random effects by moving an invisible object next to the target and having it cast a spell on them. This is done in two blocks; the first, a ScriptEffectStart block, sets the target with GetSelf, and sets a short variable to 1. The second block is a BeginGamemode block. If the short variable is 1, the activator moves and casts the spell then the short variable is set back to 0. Why is it done this way? Couldn't the effect be in the first block and the short variable not be included? Also, I would like to know what type of activator is used for this.
User avatar
Gracie Dugdale
 
Posts: 3397
Joined: Wed Jun 14, 2006 11:02 pm

Post » Thu Sep 09, 2010 5:53 pm

A couple of the Shivering Isles weapon enchantments cause random effects by moving an invisible object next to the target and having it cast a spell on them. This is done in two blocks; the first, a ScriptEffectStart block, sets the target with GetSelf, and sets a short variable to 1. The second block is a BeginGamemode block. If the short variable is 1, the activator moves and casts the spell then the short variable is set back to 0. Why is it done this way? Couldn't the effect be in the first block and the short variable not be included?


The variable is needed for the Begin GameMode block, which runs once per frame. The variable gets set to 1 in the ScriptEffectStart block, which only runs once. The GameMode block uses that setting to get a random percentage then sets the variable to 2. In the next frame, the new setting tells the GameMode block it's time to cast a spell based on what the random percentage is. There are other ways to do it, but this one is pretty good.

Also, I would like to know what type of activator is used for this.


Actually, it's an Xmarker, not an activator. I think an Xmarker was used because it's invisible in game.
User avatar
Kat Stewart
 
Posts: 3355
Joined: Sun Feb 04, 2007 12:30 am

Post » Thu Sep 09, 2010 8:24 pm

Thanks Vyper. Does the gamemode block run every frame until the script duration is over and why couldn't all of that be done at once in the scripteffectstart block? I know a block can register variables set in it, so is gamemode just used to avoid slowing the fps?
User avatar
Ricky Rayner
 
Posts: 3339
Joined: Fri Jul 13, 2007 2:13 am

Post » Thu Sep 09, 2010 11:03 am

Thanks Vyper. Does the gamemode block run every frame until the script duration is over


Indeed it does, which makes that block pretty versatile.

and why couldn't all of that be done at once in the scripteffectstart block?


Not enough room in the block for everything. If you declare the variable and the random percent, move the Xmarker and cast the spell all in one frame, the spell will likely miss if it fires at all. This is why the variable and random percent are initially declared in ScriptEffectStart and updated across multiple frames in GameMode. Using a variable in a GameMode block is very versatile since you can change it in as many frames as you want for very rapid effect changes. An alternate method of setting something like this up would be to set the random percent in the ScriptEffectStart block, move the Xmarker in ScriptEffectUpdate and cast the spell in ScriptEffectFinish. With this method, you wouldn't need the other variable used in the SI script, but you lose the versatility of the GameMode block and could take a FPS hit, depending on how much your script has to do.

I know a block can register variables set in it, so is gamemode just used to avoid slowing the fps?


It's used to quickly update the script multiple times in a single block without having to use multiple ScriptEffect blocks. With fewer things to check for, this will have less effect on FPS, especially in a complex script.
User avatar
Carlos Rojas
 
Posts: 3391
Joined: Thu Aug 16, 2007 11:19 am


Return to IV - Oblivion