Jump to content

Home

About using Local Variables (TSL)


stoffe

Recommended Posts

Mod note: This is a post lifted from this thread since it might be useful as a local variable reference list, even though the list isn't fully complete. ~M

 

Unlike global variables, which are set to one value for each index/name for the entire game, local variables can be set on individual objects and will only have their value for that object (like a creature, placeable, waypoint, area or module).

 

To set a local, pick an index that's not already occupied. If you have no standard scripts running on the placeable (such as Random Loot generation for container placeables) you could pick any index between 0 and 159. Then you use a script to set it.

 

If it's in a dialog you can use the script a_local_set that comes with the game for this. Assign it to a Script slot of a dialog node and set the first parameter (P1) to the index of the LocalBoolean slot you wish to set.

 

If you want to set it in one of your own scripts you use the SetLocalBoolean() function, where you set the first parameter to the object you wish to set it on, the second to the index you wish to set, and the third to the TRUE/FALSE value you want to set.

 

To check if it's set in your scripts you similarily use the GetLocalBoolean() function where the first parameter is the object to check the local value on and the second is the LocalBoolean index to check.

 

One important thing to keep in mind with GetLocalBoolean() is that it does not return TRUE or FALSE for some reason. It returns either FALSE or not FALSE. Thus, never do this when using that function since you'll get unpredictable results:

   if (GetLocalBoolean(OBJECT_SELF, 12) == TRUE) {
       ...
   }

Instead, check like this for the desired result:

   if (GetLocalBoolean(OBJECT_SELF, 12)) {
       ...
   }

 

Here is an incomplete list of which LocalBooleans and LocalNumbers are generally already in use on different types of objects. This is in general, for specific standard game objects others may be set as well during quests and conversations.

 

Creatures:

Boolean 1-3 - Creature AI, ambient NPC settings.

Boolean 10 - Dialogs, used to set that the creature has been talked to once.

Boolean 20-28 - Creature AI, used to activate userdefined script events.

Boolean 29 - Creature AI, used to set if NPC should play ambient animations when idle.

Boolean 30-64 - Reserved range for scenario/plot specific uses, some NPCs use them, most do not.

Boolean 65 - Creature AI, used to set of the NPC should walk around randomly when idle.

Boolean 66-86 - Creature AI, various settings set in the NPC spawn scripts.

Boolean 87 - Creature AI, blocks out the AI for this creature if set.

Boolean 88 - Creature AI defined, but likely unused in K2:TSL.

Boolean 89 - Creature AI, sets the creature to use the Boss Combat AI, overriding their normal AI style.

Boolean 90 - Creature AI, sets that the creature has activated their energy shield in combat.

Boolean 91 - Creature AI, toggles userdefined event for the OnDialogEnd event handler.

Boolean 92 - Creature AI, sets that a force using NPC has buffed with Resist/Immunity at start of battle.

Boolean 94 - Creature AI, sets that the creature has entered combat.

Boolean 95 - Creature AI, sets the creature to use the KotOR1 Malak end fight AI.

Boolean 96 - Creature AI, sets creature to use a zone controller to determine their combat zone.

Boolean 97 - Creature AI, setting for the OnDialog event.

Boolean 98-109 - Creature AI, used by the waypoint walking/ambient animation system.

Boolean 110-159 - Generally unused as far as I can tell.

 

Number 0-2 - Creature AI, used by the waypoint walking/ambient animation system.

Number 3-6 - Creature AI, internal state info for last attack used, chosen attack pattern etc.

Number 7 - Creature AI, Zone Controller this creature is attached to, if any.

Number 8-9 - Creature AI, settings for healer AI, how much to heal and how often.

Number 10-11 - Creature AI, used for turrets to determine rate of fire.

Number 12-31 - Generally unused as far as I can tell.

 

 

Placeables:

Boolean 10-19 - Security terminals, used to set the user's choice of action.

Boolean 55 - Containers, container has been bashed and broken item substituted.

Boolean 57 - Containers, used to set that random loot has been spawned.

 

 

Triggers:

Boolean 40 - Used to set that the trigger has been tripped for one-shot triggers.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...