Jump to content

Variable Types


Miloch

Recommended Posts

From the Variable Types page:

LOCALS: SetGlobal("XXXXXX", "LOCALS", 1)

The above command sets the XXXXXX variable to 1 in the local scope. The local scope is only valid for creatures (as opposed to area scripts or baldur.bcs). Only the creature that has set a variable in the local scope can see it. This allows for several creatures to use the same script (with the same variable names) as the value assigned to variables are for each creature. Local scope variables are often used for tracking things that are unique to a particular creature (e.g. number of spells left, a specific one-shot dialog option has been chosen etc.). In BG1, local variables are not saved - they are temporary to the current game session.

Italics added on last sentence. Is there any evidence that local variables are saved in BG2? If so, where? I couldn't find them anywhere in the .gam file variables, which tracks only GLOBALS as far as I can tell, nor in the .sav game .are files, which track only area variables, nor in the actors/embedded .cre files, which don't have anywhere to store variables that I can see.

 

The upshot, at least as far as I can see, is that if an actor was doing something that depends on a local variable, then whatever that actor was doing will get cleared after a reload.

Link to comment
Lately, I've been using Variable Checker
Did you have to pay for it? (j/k :))

 

It's not so much a matter of tracking variables, but LOCALS values in scripts that appear to malfunction on rare occasions (like here). I looked at that saved game and saw the LOCALS did appear indeed to be stored correctly as an effect attached to a .cre who is embedded in an actor who is indexed in an .are file which is compressed in a .sav file :suspect:. So I'm "assuming" the game is picking up the LOCALS properly and that making it a GLOBAL probably wouldn't make a difference, but who knows.

Link to comment

Sorry, I see what you mean, and I can corroborate your experience. When I was testing Master Grolim, the gift-seller I added to BG2 Gavin, I first tried using local variables to determine whether a gift had already been purchased for a particular NPC. When it didn't work, I was forced to change it to area variables instead. I guess non-joinable CREs cannot store local variables. I wonder how that works in combat scripts.

Link to comment

Right, but at the risk of derailing this topic even more, lots of mage AI scripts rely on local variables to determine if the mage is still buffing or if he's switched over to offensive spells. If local variables don't work, he would just stand there and buff until he ran out of spells.

Link to comment

If we're talking about BG2 (or really any IE but BG/TotSC and PST), LOCALS is a supported non-fragile variable scope.

 

Effects, including variable storage effects, work just fine on all actors (they cannot be used for non-actor AI objects, however). Note that every single instance of a particular actor has their own separate, fresh CRE structure, and nothing is shared between the "duplicates."

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...