ActiveMagicEffect and global variables

Post » Thu Sep 11, 2014 4:29 pm

I'm trying to have a ActiveMagicEffect class read a float value from a global variable in order to decide whether or not to execute conditional code. The way I have it set up is that another script (which extends the Quest class) initially sets the value, then the ActiveMagicEffect later reads it, as shown in the below code:

myQuestScript

GlobalVariable Property BreakSuccessChance  auto[...];static value of 45 for testing purposesfloat successChance = 45.0000BreakSuccessChance.SetValue( successChance )

myActiveMagicEffect

GlobalVariable Property BreakSuccessChance  auto[...]float successChance = BreakSuccessChance.GetValue()Debug.Notification("received value is " + successChance )

The problem is that the Debug.Notification always returns 0.0000. Both of the scripts have Global properties targetting the same variable ID, I double-checked. I also used the "show " command on the console and have confirmed that myQuestScript is editing the value to 45 as it should. However, myActiveMagicEffect seems incapable of fetching the value.

Does a script need to extend the Quest class in order to be able to access global variables? If so, how do I get my scrip that extends ActiveMagicEffect to fetch the variable I need?

User avatar
Hannah Barnard
 
Posts: 3421
Joined: Fri Feb 09, 2007 9:42 am

Post » Thu Sep 11, 2014 9:18 pm

You probably forgot to fill your script properties in the CK. In the Magic Effect where you attach your script, click the "Properties" button and then fill in the value of your global variable (if it is the same name in your script as it is in the CK, you can hit "Auto-Fill" and it should fill the property for you, otherwise you'll have to choose it from the dropdown menu).

User avatar
Cagla Cali
 
Posts: 3431
Joined: Tue Apr 10, 2007 8:36 am

Post » Thu Sep 11, 2014 2:49 pm

As I said in the opening post, I did double-check for that. So active magic effects are supposedly able to access global vars, correctly? I must be missing something or made a mistake somewhere. I'll try doing this again from the start.

User avatar
Sabrina Steige
 
Posts: 3396
Joined: Mon Aug 20, 2007 9:51 pm

Post » Thu Sep 11, 2014 12:59 pm

Any script can access global variables. Does your magic effect script extend ActiveMagicEffect? It will help if you post your entire scripts. It may also be a good idea to look at your papyrus logs, they will often give you a clue about what is wrong.

User avatar
Kirsty Wood
 
Posts: 3461
Joined: Tue Aug 15, 2006 10:41 am


Return to V - Skyrim