How do I introduce a local variable into a script?

I Must Be Crazy 2

First time out of the vault
Suppose that I wanted to introduce a local variable into a critter's script that will always be remembered by the game when I leave the critter's map or when I save the game and load it again.

How would I go about doing this?

For example, in scmikey.int (the guy who sells iguana-on-a-stick in NCR Bazaar), only local_var(0) through local_var(8 ) are utilized in this script. Would there be a problem if I tried to use a command such as set_local_var(9, 2) or set_local_var(13, 3) in scmikey.int?

Also, when I leave and re-enter NCR, will the game remember that Mikey's local_var(9) is 2 and local_var(13) is 3?
 
scripts.lst
Code:
...
SCMikey.int     ; Mikey the Lizard Dealer in NCR entrance       # local_vars=10
...

See to "local_vars=10". Max local_var in the script - 9. You can change this to needed number. Also you can use any local_vars except for already used.

Sorry for my English.
 
As Avega posted how many local vars you can use in script is written in scripts.lst in local_vars=10 parameter.
As You see SCMikey.int script has 10 local vars set (from 0 to 9).
If You want to use var number 13 then set it to:

Code:
SCMikey.int     ; Mikey the Lizard Dealer in NCR entrance       # local_vars=14


Also, when I leave and re-enter NCR, will the game remember that Mikey's local_var(9) is 2 and local_var(13) is 3?

Yes local vars are saved.
 
This is not a question specifically about introducing local vars, but it is about them. I had posted this under the unofficial patch thread, but I am guessing it was missed and hopefully can be answer here. My question is..
I noticed a good while ago that many scripts begin their LVARS at 4 rather than at zero. Investigating further, I saw that there are some hardcoded things that appear to use 0-3. (like reactions) Is this the case? And if so, does that mean that if a script has a local var from 0-3 declared, things may become broken?
 
It is not really hardcoded. It's just that in critter script You will find often something like that:

Code:
procedure talk_p_proc begin 
   Evil_Critter:=0; 
   Slavery_Tolerant:=SLAVE_TOLERANT; 
   Karma_Perception:=KARMA_PERCEPTION1; 
 
   CheckKarma; 
 
   GetReaction;
This GetReaction macro from modreact.h file uses those wars :

// LOCAL VARS WHICH WILL BE SAVED FOR EACH CRITTER
Code:
#define LVAR_reaction                   (0)             // Holds reaction number value. 
#define LVAR_reaction_level             (1)             // Holds reaction level: BAD, NEUTRAL, GOOD. 
#define LVAR_got_reaction               (2)             // Makes sure to modify reaction only once. 
#define LVAR_base_reaction              (3)
So in that script you should not use local vars below 4 since every time talk_p_proc is called values of those vars will change.

But as you will find those values are almost never really used.
GetReaction macro just roll a test and puts reaction in those vars.
So if those vars are never used in script you can use them (but don't forget to comment out GetReaction)
 
Back
Top