Global reference variables?

Post » Sun Aug 08, 2010 9:39 am

Just a quick question here. I'm making a spell that's supposed to rain fire from the sky on somebody and I'm using reference variables to mark the spell's target. The only problem is, I don't know how to make the spellcaster fire at the target. I just need to know how to either carry a reference variable from one script to another or how to make a script move a separate object (how to make the targeting spell move the spellcaster). Does anyone know?
User avatar
Bryanna Vacchiano
 
Posts: 3425
Joined: Wed Jan 31, 2007 9:54 pm

Post » Sun Aug 08, 2010 7:35 pm

Reference variable in a quest script can be called from anywhere. Refer to it with questname.variablename
User avatar
~Amy~
 
Posts: 3478
Joined: Sat Aug 12, 2006 5:38 am

Post » Sun Aug 08, 2010 9:58 am

Reference variable in a quest script can be called from anywhere. Refer to it with questname.variablename

Well, I tried that, but whenever I try to save the script the editor crashes. How about a script that moves a different object (so the entire thing can be run on a single script)? I tried a line like:
MovingObject.SetPos X Target.GetPos X
but it says that only object references and reference variables are allowed in that context, so is there a way to do this?
User avatar
CArla HOlbert
 
Posts: 3342
Joined: Wed Feb 21, 2007 11:35 pm

Post » Sun Aug 08, 2010 9:26 am

You probably cannot set the 'X' position like that.

float myXbegin Gamemode   set myX to Target.GetPos X   MovingObject.SetPos X myXend


If you don't want to use quest variable, you can create a global variable that will work anywhere and is much easier to use.

On the toolbar, >Gameplay >Globals
Right-click in the list and select 'New'. Give it a name and you can now use that name in any script, quest, conditions, anything.
User avatar
christelle047
 
Posts: 3407
Joined: Mon Apr 09, 2007 12:50 pm

Post » Sun Aug 08, 2010 9:37 pm

Ach. Thought it was working until I tested the spell and the game crashed on me. I don't even know the problem this time. If anyone would like to check I used this script for the spell:
Scn Z13_FireAttack_Targref Z13FireAttackTargetBegin ScriptEffectStart	set GetSelf to Z13FireAttackTarget	set Z13FireAttackStarted to 1end


and this for the caster:

SCN Z13FireCasterScriptref Z13FireAttackTargetshort XPosshort YPosshort ZPosshort InPositionfloat roundsfiredshort firingBegin GameMode	if Z13FireAttackStarted == 1		if InPosition == 0			Set XPos to Z13FireAttackTarget.GetPos, X			Set YPos to Z13FireAttackTarget.GetPos, Y			Set ZPos to Z13FireAttackTarget.GetPos, Z + 5000			SetPos, X  XPos			SetPos, Y YPos			SetPos, Z ZPos			set InPosition to 1			set firing to 1		endif	endif 	if firing == 1		if roundsfired < 30			cast Z13FireAttackFXS Z13FireAttackTarget			set roundsfired to roundsfired + 1		elseif roundsfired >= 30			set firing to 0			set inposition to 0			set xpos to 0			set ypos to 0			set zpos to 0			set roundsfired to 0			set Z13FireAttackStarted to 0		endif		endif	endifend


I'm so lost right now. Thanks for the help, Hiei and WillieSea :)
User avatar
Raymond J. Ramirez
 
Posts: 3390
Joined: Sun Oct 14, 2007 8:28 am

Post » Sun Aug 08, 2010 8:31 am

1. You cannot use GetSelf like that.
set Z13FireAttackTarget to GetSelf


2. In your script for Z13FireCasterScript you have one too many Endif's.
An 'ElseIf' goes with the parent 'If' and does not require an additional Endif. Delete the 'repeated' endif you have.
User avatar
sarah taylor
 
Posts: 3490
Joined: Thu Nov 16, 2006 3:36 pm


Return to IV - Oblivion