Morrowind Construction Kit Commands

19 February 2011

This page contains a description of all the functions available for scripting in Morrowind's Construction Set.
Feel free to Contact the Webmaster to contribute any suggestions
or corrections. You can also view the Categorical Function List.
There are currently 516 different commands/variables listed on this page. Feel free to download this page to your
hardrive for faster and more convienient access.

This is a reserved script operator used to access functions for a particular object reference. Use this when you wish to
manipulate or access a specific object explicitly. Note that if multiple objects exist in the world you have no guaruntee
which one you'll access (the first one the game finds). Also note that if you wish to access an object from anywhere in
the world you will need to ensure that the object's References Persist button is checked.

If the object ID on the left of the -> has any spaces in it you will need to enclose the ID with double-quotes.
Leading underscores (_) on Object IDs also seem ti have erratic results in the script editor. In some places they work
fine, in other places the script editor chokes on them. It is reccommended not to name objects with a leading underscore.

See Also:

Includes Contributions from DinkumThinkum.

Activate

Activate, [player]

Where: player = Optional player ID which forces the object to be activated by the
player no matter where the object/player is. Undocumented.
Type: Object
Returns: none
Example: If ( OnActivate == 1 )
Activate
endif
Scripts: Dagoth_doors
Bittercup

This function tells the object to do its default activation.

Object Type Activation
NPC Dialogue Works
Container Opens Works
Door Opens Doesn't Work?
Book/Scroll Reads Works
Weapon Picks Up Works
Armor Picks Up Works
Misc, etc... Picks Up Works

There is an undocumented feature in the Activate function by specifying the player after the function, for example:

begin RemoteContainer
short OnPCEquip
if ( OnPCEquip == 1 )
set OnPCEquip to 0
"dh_remote_chest_01"->Activate, player
endif
end

If the container is persistant (references persist) this script should open the container wherever the player is. This
is a great way to create 'carryable' containers by attaching a script similar to the above to a ring or similar item.

Adds the given number of the item to the calling NPC. Note that the Count value has a short type which limits
the number of items that you can add to 65535 (or possibly 65534).

This function does accept global variables but only in dialogue results, not scripts. It doesn't work when
you set the global variable in the same dialogue result. Either set the variable before starting dialogue,
or in a dialogue line that precedes the response with the AddItem result (e.g Greeting).

When an NPC has armor added to its inventory (via AddItem or normally when you sell it to them), it will automatically equip the armor if:

The NPC's skill in using that armor is higher than that of its
currently equiped armor (NPCs with higher Unarmored skill than the
rest of the armored skills will never wear armor).

The armor value of the new piece of armor is higher than the
previous. (It will not switch to an equivalent armor piece).

Also, an NPC will not replace a lost/removed/broken armor piece unless a new one is added.

There is a related bug/feature when using AddItem/RemoveItem with a container. The game remembers when you change the
contents of this container, and if you haven't, there is no need to store the container's contents after you took all that was within.
The first AddItem will always work on a container, but after that you need first to move anything into the container (i.e., actually
have the player add an item within the game), before another AddItem shows any effect.

This function adds the given spell to the calling object. If the spell is a normal spell, it will be added to
the list of the actor's known spells. If the spell is a curse/disease it will be added to the list of spells currently
affecting the calling actor. Use RemoveSpell to remove spells added by AddSpell.

A bug related to this function is that if add a curse type spell to a creature and it, then any other creature of
that type you encounter from that point on will also be effected by that curse. To fix this simply call
RemoveSpell in an OnDeath clause in a script attached to the creature.
The fact that this happens in the first place suggests to me that the
spell is added to the creature definition, and not just that particular instance of the creature.

Allows the user to modify the levelled item/creature lists while the game is running. The functions will add the
object/level pair to the levelled list (assuming that it doesn't already exist in the list).

Adds the given dialogue topic to the players list of known topics. Known topics will appear when the player
talks to NPCs that have that topic. When creating a new plugin with new dialogue topics, you will frequently want
to add a few topics that the player already knows. To do this, create a temporary object near the related NPC and
attach a script like the following:

Although this function is in the TES Construction Set help file it is never actually used in any of the official
master files. It causes the referenced NPC/creature to attempt to activate the given object (such as an item, door, activator, etc...).

There is a known bug when using the optional Reset parameter with AiActivate (verified with Tribunal). It is therefore recommended
to not include the reset parameter. Also, this function is mostly broken in the original Morrowind game, but has been significantly
improved in Tribunal. The following actions have been tested and verified to work:

Potion - NPC drinks it (works in original Morrowind as well)

Item on Ground - NPC picks it up

Door - Opens it

Load Door - Teleports through it but only if the destination of the door is in the same cell or a currently loaded cell.
Otherwise the game crashes.

Where ActorID = The target NPC that the source NPC will be escorting.
Duration = The length of time (in seconds) that the target NPC will be escorting.
A value of 0 indicates infinite time.
CellID = Cell name where the source NPC will stop escorting.
X,Y,Z = The position that the source NPC will stop escorting the target.
[Reset] = Optional parameter, unknown, may indicate whether the current AI package
is interrupted.
Type: AI
Returns: none
Example: AiEscort, Player, 0, 70685, 126106, 835, 0
AiEscortCell, Player, "Balmora, Hecerinde's House", 0, 70685, 126106, 835, 0
Scripts: whiteguarScript (AiEscort)
Not Used (AiEscortCell)

When the NPC uses AiEscort, the player does *not* get free discretion on the path. The NPC leads the player to the
destination, and if the player decides to go somewhere else, the NPC stops and waits for the player -- in simple
terms, the player must follow the NPC all the way to the destination. If the duration is 0 it will be ignored.
When escorting someone, if the target NPC is attacked, the source NPC will come to their aid. An XYZ position of
(0,0,0) is often used for situations where you want to directly control when the NPC will stop following (no
specific location). In this case, the NPC will escort until another AI type command is given to it.

As with other AI functions, issue this command only once or the results may not be as expected.

AiEscortCell is similar to AiEscort except the target NPC will stop escorting the source NPC (ActorID) at the given position in the named cell.

Where ActorID = The target NPC that the source NPC will be following.
CellID = Cell name where the source NPC will stop following.
Duration = The length of time (in seconds) that the target NPC will be
following. A value of 0 indicates infinite time.
X,Y,Z = The position that the source NPC will stop following.
[Reset] = Optional parameter, unknown, may indicate whether the current
AI package is interrupted.
Type: AI
Returns: none
Example: "taren andoren"->AiFollow, "velyna seran" 0, 0, 0, 0
AiFollowCell, Player, "Balmora, Hecerinde's House", 0, 70685, 126106, 835, 0
Scripts: talenScript (AiFollow)
Not Used (AiFollowCell)

Similar to AiFollow where the source NPC will be set to follow the target NPC (ActorID) for the given duration (in seconds,
0 indicates infinte time) or until they reach the given position (AiFollow for exterior locations, AiFollowCell for interior locations).
When an NPC uses AiFollow, the player gets to choose where he/she goes. The NPC will follow the player
diligently the whole way.

As with other AI functions, issue this command only once or the results may not be as expected.

Starts the NPC to travel to the given exterior position. The distance to the new coordinates cannot be too great (about 3000-4000 units), or the actor will not react,
although this maybe related to trying to move the NPC to another cell (which often has problems). Use GetAiPackageDone function to determine when the actor reaches destination.
Note that sleeping, teleporting, or fast travel will cause the actor to warp to the end-coordinates, but the GetAiPackageDone function will not fire - this can be a problem.
The Z coordinates need only be approximate and all values must be literal, no variables accepted. AIpath grid helps, but is not mandatory.

As with other AI functions, issue this command only once or the results may not be as expected.

Where Range = The range, in game units, that the NPC will wander in from its
current location.
Duration = Time (in hours?) that the NPC will wander (0 indicates infinite)
Time = Possibly the start time for the wandering to occur (0 may indicate
no start time).
[Idle2]... = Optional parameters, that give the chance of the NPC to perform the
following idle movements:
Idle2: Looking around
Idle3: Looking behind
Idle4: Scratching head
Idle5: Shifting clothing or armor on shoulder
Idle6: Rubbing hands together and showing wares
Idle7: Looking at fingers and looking around furtively
Idle8: Deep thought
Idle9: Reaching for weapon
[Reset] = Optional parameter, unknown, may indicate whether the current
AI package is interrupted.
Type: AI
Returns: none
Example: AIWander, 0, 0, 0 (forces NPC to stand in one spot)
"urzul gra-agum"->AIWander, 128, 0, 0, 60, 30, 10, 0, 0, 0, 0, 0, 0
Scripts: attack_Slave
dinScript

Sets the given NPC to wander randomly in the current area using any AI grid points and performing various random idle movements.
This function is commonly used to stop NPCs from following or performing a previously assigned action.

There are two known bugs with this function. The Idle2 parameter is not output in the compiled script (verified with Tribunal). The Reset
parameter also maybe output incorrectly and should not be used.

Turns the player, NPC, or creature immediately into a werewolf. Only works properly for NPC's, however, it can be used on creatures
for some weird effects. Effected NPC's take on the werewolf mesh, removing all clothing and weapons, and retaining all AI settings.
This means an NPC turned into a werewolf may not be able to talk, but he/she will have the same Idle, Fight, and Hello, settings, etc...
(though they'll just track the PC on Hello triggers, no dialogue). Likewise, already attacking NPC's will simply keep attacking,
albeit in a new form - scripts seem to continue to run fine, as the object ID seems to remain the same. I'm unsure if stats on
NPC's affected by this function call are changed or not - Speed is definitely not changed, so presumably it's only attack
damage and/or hit chance that changes.

This command can be used on creatures, with varying effects - the creature NIF/appearance will NOT be swapped out, nor
will their 'Name' tag say 'werewolf', as it does on NPC's - and it only seems to work for certain creatures, changing
their attack sound and attack stats, if I'm not mistaken. Creatures with Weapon & Shield bone entries will unequip
whatever they're holding and go hand-to-hand - and as I said the attack sound changes to a werewolf growl, but
otherwise Idle and other sounds seem to remain the same. It's amusing when used on Reiklings - they become little snarling, boxing, midgets.

Also, The Werewolf transformation is handled almost exactly like the Vampire one, with the PCWerewolf global being used.
Using Becomewerewolf and Undowerewolf can break your game. Some quests and variables depend solely on on use of these,
so if you use one to toy around.... you may be asking for it.

This should be first line at the top of your script that states the script's ID. The script ID can be any combination of letters, numbers,
underscore or spaces. It is recommended not to use spaces for simplicity (as with any other object ID).

The calling object casts the given spell onto the target (spells only). A common use for this is to create traps that
cast a spell on the player when activated.

In the original Morrowind release, the a touch spell can be cast by any object but must be directed at a
specific REFERENCE to an NPC or creature. Targeted and self spells can only be cast by an NPC or creature.
For example:

FXSpawner->Cast, "FX_Frost_Sphere", mysterious_temple_NPC00000000

FXspawner is an activator, mysterious_temple_NPC is an NPC
object and FX_Frost_Sphere is a spell that casts 0 frost damage
over an area of 100 for 0 secs. I've found out that each NPC reference
has an eight digit number after the object name to differentiate
it from any other references (starting from 00000000). Player
is a reference and therefore a valid target for Cast as evidenced
in the shrine scripts.

It doesn't matter where the caster is, it will still activate the
effect on the NPC or creature ref and glow. Only NPCs and certain
creatures can cast a targeted spell. Some creatures like rats can't
cast spells.
Non-AI objects can cast multiple spells at once at multiple targets
or a single target whereas NPCs and creatures will target the last
ref targeted in the calling frame. Also, NPCs and creatures have to
reset back to where they where when Cast was called before casting
again.

Getting a reference to target itself is a perfect substitute in the
original Morrowind for Tribunal's ExplodeSpell Command.

Returns 1 for one frame when the player enters a cell (but not when they leave), or 0 otherwise.
Often used to disable/enable objects once the player has left the area (so they don't appear
immediately out of thin air or cause script errors/crashes).

See Also:

Includes Contributions from Klinn.

CellUpdate

CellUpdate

Type: Movement, Broken
Returns: none
Example: CellUpdate
Scripts: Not Used
Updates the current objects cell position. This should be called when moving objects over large distances. The game keeps
tracks of objects based on what cell they are in, and if an object moves a cell over from its starting position, it may not
get processed correctly when running its script.

Note that this function does not appear to work correctly. Moving items across cell boundaries (exterior) can cause them to warp
or disappear and calling CellUpdate only results in a script error.

See Also:

CellUpdate

CellUpdate

Type: Movement, Broken
Returns: none
Example: CellUpdate
Scripts: Not Used
Updates the current objects cell position. This should be called when moving objects over large distances. The game keeps
tracks of objects based on what cell they are in, and if an object moves a cell over from its starting position, it may not
get processed correctly when running its script.

Note that this function does not appear to work correctly. Moving items across cell boundaries (exterior) can cause them to warp
or disappear and calling CellUpdate only results in a script error.

Where: 'Button1'... = Text for the various choices. At least one choice is required and
up to five are allowed.
Type: Dialogue
Returns: none
Example: Choice, "Continue..." (force the player to one option)
Choice, "Yes" 1, "No" 2, "I'm not sure" 3
Scripts: Used only in dialogue results.

Used only in dialog for presenting 1 to 5 choices to the user. The choice results can be retrieved by using the
choice function in the function/variable lists in the dialogue speaker conditions area. Use values following the choice
strings to specify the exact return value if the user chooses that option (I'm unsure what values are returned if you
do no specify values, though I assume they start at 1).

Important Note: If you specify the numbers after each choice you must include a space between the ending
quote and the number.

Choice and Goodbye can be used in scripts. Choice can also be used multiple times in a row to create as many
choices as desired. I'm not sure what happens when they're used if dialogue is not open, but I suspect it would crash Morrowind.
However, when dialogue *is* open, they can be used for some very clever dialogue choices.

For example:

[in the dialogue topic]
Okay, so here's the plan. At the stroke of midnight, you
post a watch on the northern tower. Meanwhile, I'll enter
the compound, and when you hear a loud whistle, you open
the front gates and let me out. Then we'll meet later and
I'll give you your share. Understand?

The actual effect of this functions depends on the Create Maps Enable entry in MORROWIND.INI file.
The accepted values are:

0 = None
1 = XBox Maps
2 = Exterior Cell Maps

For the XBox setting, maps are created for the given input plugin filename (a .MAP is created in the Morrowind\Data Files
path). For the Exterior Cell Map setting, BMP files for all exterior cells are output to the Data Files path (I think). Note
that this takes a good deal of time so you may wish to let it run overnight.

See Also:

Day

Day

Type: Time, Global
Returns: short
Example: if ( Day > 10 )
set sValue to ( OrigDay + Day )
Scripts: expelledMG
fraldScript

Global short variable which returns the current day of the month in the game. This value can be modified using the
SET command to change the day.

Used to enable/disable objects within the game. A disabled object is saved but not visible or processed within the game (though any
scripts attached to it will still work). Not that it is dangerous to disable an object within its own script (causes crashes).
There also appears to be some minor issues involved with disabling lights.

There are many possibilities allowed with these functions. For example, the game strongholds are initially disabled and are only enabled
once the player performs the appropriate quests

The calling NPC drops the given number of the item into world at his feet. Assumably it only works if the calling actor
has enough of the item to drop. There does appear to be some problems dropping items from NPCs where the item is dropped
at the player's feet instead of the NPCs (works in the slave script though).

The IF statement block is used to test and execute conditional statements. The elseif/else blocks are both optional.
It should be noted that if statements can be used in dialogue results. You should not include any operations (add,
subtract, multiply, divide) in either the LeftValue or RightValue fields. Use a temporary variable
and a set statement before the if block if you need to use operations.

It is important to remember to use spaces surrounding the '(', compare operator, and ')'. There are known
cases where omitting the spaces will cause compiler or runtime errors in the script.

These undocumented functions display the various windows used during character creation. You should be able to use these at any time
to change/modify your character. A common use of these is to change the character creation process. See all the CharGen... scripts
for more details. EnableRaceMenu allows you to choose your race, EnableBirthMenu your birth sign, EnableClassMenu you class, etc...

The while is the only loop statement available in the scripting language. The while loop is executed within one frame until
the condition is satisfied. This can cause an unwanted pause in the game if there are many loops required.

Equips the given item on its owner. Note that this function does not work as intended some of the time.
Equipping items on the player often does not work, although I had successfully equipped repair hammers from
a script. Similarily with NPCs, equipping weapons/armor may not be possible although you can make them
quaff potions.

Note that this function appears to be broken in the original Morrowind game (you may receive a bad
function code error in the game or things simply will not work) but is fixed with the Tribunal expansion. In Tribunal
you can successfully get NPCs to equip weapons/armor as well as on the player.

Makes the calling object cast the given spell at itself. If an area effect touch range spell is used, this can make the reference 'explode'.

See Also:

Face

Face, Angle, Time (unconfirmed)
or Face, X, Y (??)

Where: Angle = The final Z-angle you want the object to face.
Time = How fast the object rotates?
X, Y = Coordinate you want the NPC to face.
Type: Movement, Undocumented
Returns: none
Example:
Scripts:

Possibly makes an NPC face a direction and how fast they turn that way. Apparently interrupts current animations.
I've used to on Wandering NPCs and they stop, Face wherever, then continue on wherever they were wandering
to as soon as the Facing movement is over. Call only once unlike the Rotate type functions.

Assumably this function causes the calling object to fall to the ground. Further testing is required.

See Also:

FillJournal

FillJournal

Type: Console
Returns: none
Example:
Scripts:

This console function adds all the available journal entries to the character's journal. The TESCK help file says this may
take a long time. The only known use of this function is for testing purposes.

See Also:

FillMap

FillMap

Type: Console
Returns: none
Example:
Scripts:

Shows all the town names on the world map.

See Also:

FixMe

FixMe

Type: Console
Returns: none
Example:
Scripts:

Reloads the current cell and attempts to 'unstick' the player from any object (jump 128 units away). Although this is a
console function you can still call this function from a script. One use is when moving objects over long distances (across
cell boundaries). Calling FixMe in this circumstance can correct certain display and clipping errors.

See Also:

Float

Float

Type: System
Example: float LocalVar
Scripts:

This is the largest and one of the three types of the scripting language. Float variables can range from
3.4e+38 to 3.4e-38 and has 7 digits of precision.

Although local variables can start with an underscore character (_), this seems to cause strange problems in
some functions. Therefore it is reccommended that you do not name variables starting with the underscore.

Makes the NPC start dialogue with the PC. Does not matter where the NPC is. The only exception to this appears to be
that NPCs not in the current cell can only be used in a script if the player has visited the cell with the NPC within 72 hours.
Note that this applies to ForceGreeting and other script functions as well. You can get around this limitation by using
a PositionCell on the NPC once per day. Even if their position is not actually changed
the 72 hour limit will no longer apply (some say you do actually have to change the NPC's cell with this technique).

Returns the current hour of the day in the game's time. The value is a floating point value that will be increased
slightly on each frame. Game hour can be modified using the SET command to change the game time.

My favourite usage is on an item I created -- the Ring of Eternal Midnight --
which causes the GameHour to be set to 0.001 constantly once the day changes -- thus, once it becomes midnight,
the ring will keep the game frozen at midnight until you remove it. When you do remove it, time will advance
normally (even if you put the ring on again) until midnight is again reached.

Another good usage of setting GameHour directly is to make time pass. 'set GameHour to GameHour + 0.5' makes time
advance a half-hour instantaneously. It correctly identifies new days, but I haven't yet tested whether or
not it also correctly identifies time passed beyond a new day -- that is, if it is currently 11:59 PM, whether or
not adding a half hour will make it 12:29 AM or simply 12:00 AM.

Where: ObjectID = Actor to get the number of times it has been killed
Type: Stats
Returns: short
Example: if ( GetDeadCount, "Vorar Helas" > 0 )
set sValue to ( GetDeadCount, "ancestor_ghost" )
Scripts: attack_slave
AhniaNote

Checks to see if the calling NPC can detect the given actor (returns 1 if it can). If not, then the given actor is invisible in some form
(such as sneaking, chameleon, or invisibility). The TES help file says that this is a slow function that should not be called too often.

Returns a float value for the distance between the calling object and the given ObjectID (in game units). If one of the objects is not unique,
the first instance of that object is used (thus you should only use the function with unique objects). Also, if you move one of the objects using
Move or MoveWorld, GetDistance will still report the original distance (use GetPos in this situation).

Returns 1 if the given spell effect is currently on the calling object. Do not confuse effects and spells (effects are what
make up the spells). You can also use an exact literal value for the EffectID if you know it. Appears to be
broken for fatigue related effects?

Returns a float value from 0.0 to 1.0 representing the calling actor's current health to maximum health ratio
(i.e., 0.0 would be dead, and 1.0 would be full health). Note that this is the correct name for the GetHealthRatio
function listed in the Construction Set help.

See Also:

GetInterior

GetInterior

Type: Misc, Undocumented
Returns: short
Example: if ( GetInterior == 1 )
set sValue to GetInterior
Scripts: Not Used

Returns the number of the objectID contained in the calling object. May not work correctly if the calling object
has more than 32267 of the given item (unconfirmed).

There is a bug with this function when used on containers (possibly related to the AddItem/
RemoveItem bug). If the player chooses the Take All button on the container then
subsequent GetItemCount calls on the container will return the number of items in the container before the player
took everything.

One way to get around this bug is to set the chest as persistant and use a temporary persistant ingrediant
in the chest. The persistant ingrediant is hidden in the sense that it is added initially to the chest from a script, removed when
the player opens the container, and added back again when the container is closed. See the below script for an example:

This function returns the index of the highest (or the last?) journal entry for that journal topic that
the player has received. Use this to keep track of the player's current location in the quest and for
scripting specific events according to the quest.

Returns the current phase of the two moons of Tamriel. Note that the GetSecundaPhase function is incorrectly
referred to as GetSecundusPhase in the Construction Set help. Another thing that should be pointed out that
the moons return whether or not they're full even during the day time, when logically the moons are invisible.

This isn't confirmed, but in practice, experimenting with both functions almost always resulted in both moons being
full immediately upon loading a saved game, and both moons remaining at the precise same phase as one another
throughout their rotation.

When the player is in an interior these functions will return the phase when you were last in an exterior cell.

Returns a float value of the calling object's current position in the world along the specified axis. Does not always return the object's position
if the object is not in the same cell (or close to) the player (returns 0 instead). In such a case, it is better to store the object's position when you
know the player is close by (such as when the item is dropped) and use them later.

Returns 1 if the given sound is currently being played by the calling object, or 0 otherwise. Sound IDs can be found from the Gameplay-Sounds menu
in the Construction Set. You can use this function to determine the current action of the player/actor, such as whether they are
casting a spell, or swinging a weapon.

Returns 1 if the calling object has the spell in their inventory, or 0 otherwise. This may work in a similar manner to AddSpell and
RemoveSpell where if the spell is a normal one, it merely checks if the calling actor knows it. If the spell is a disease or curse,
however, it may check if the calling actor is under the spell's effect.

This function immediately ends the players conversation with the NPC, forcing the user to click the Goodbye option to end dialogue.
Used only in dialogue results (unsure if it can be used in a regular script or not).

Returns 1 if the calling object has the given creature's soulgem in their inventory, or 0 otherwise.

See Also:

Help

Help

Type: Console
Example:
Scripts:

Console only command that lists some of the console specific functions.

See Also:

HitAttemptOnMeHitOnMe

HitAttemptOnMe, ObjectID
HitOnMe, ObjectID

Where: ObjectID = Number of hit points per second to damage any colliding actor (float).
Type: Combat
Returns: short
Example: Set keeningHit to HitOnMe Keening
player->HitOnMe, "chitin dagger"
Scripts: LorkhanHeart (HitOnMe)
Not Used (HitAttemptOnMe)

Returns 1 if a hit on the calling NPC is attempted (HitAttemptOnMe) or hit (HitOnMe) by ObjectID in melee.
For example, player->HitOnMe, "chitin dagger" will return 1 if the player is hit by a chitin dagger.

Where: Value = Number of hit points per second to damage any actor standing on it (float).
Value should be negative for damage, or positive for healing. This value
can be literal or a variable.
Type: Collison
Returns: none
Example: HurtStandingActor, 1 (heal 1 hitpoint per second)
HurtStandingActor, -20.0 (hurt 10 hitpoints per second)
HurtStandingActor, fDmgValue (use a variable value)
Scripts: lava
SothaHotOil

Damages any actor standing on the object the given number of health points per second. As mentioned above, a positive
value will heal the actor, and a negative value will damage them. The value can not only be a literal number, but also
a variable (local or global).

Adds a journal entry to the player's journal using the given value to determine which entry to add. Generally the a
single ID will refer to a single quest, with multiple index values to indicate various parts of the quest. The index
starts low and ends high. For instance, 10 for the starting journal entry, 20 and 30 for two middle quest journal entries, and
50 for the last, end of quest, journal entry.

This is one of the few functions that can accept a variable for the index parametrr.

This is one of the three types of the scripting language. Long variables are signed and can range from
-2,147,483,648 to 2,147,483,647. While these are the correct logical ranges, the editor appears to only
accept values up to 2,147,483,520.

Although local variables can start with an underscore character (_), this seems to cause strange problems in
some functions. Therefore it is reccommended that you do not name variables starting with the underscore.

Where: GroupName = Animation group to play.
Number = The number of times to play the animation.
Flags = Optional parameter indicating when the animation should start.
0 = Normal, the current animation will finish it’s full
cycle, and the new animation will start from its beginning.
1 = Immediate Start, the current animation will stop
regardless of the frame it is on, and the new
animation will start from its beginning.
2 = Immediate Loop, the current animation will stop
regardless of the frame it is on, and the new
animation will start at the beginning of its loop cycle.
Type: Animation
Returns: none
Example: LoopGroup, Idle3, 5
Scripts: OutsideBanner
sotha_machine1

Plays the animation group defined by GroupName the number of times specified. Optional flags can be used to start the group in different ways.
The various group names for NPCs can be found by viewing the animation menu options in the Character menu in the Construction Set.

Returns 1 if the player is currently in menu mode (i.e., has any inventory/magic menus open thus pausing the game).
It is a good idea to separate your script logic into processing of commands in and out of menumode. Certain actions like
using items are done when in menu mode.

See Also:

menutest

menutest

Type: Console, Undocumented
Returns: none
Example:
Scripts:

It seems to close is variations on inventory menus (player, NPC, container). It does not work on dialogue,
enchanting, alchemy, spell or armorer menus. It works from the console as well as from a script.

The MessageBox function has too main abilities, to display simple text messages to the player at the bottom of the
screen and to display a list of choices to the player. To display a message use the function like the following:

Use the optional variables to display numbers/strings in the message text. When displaying float values you must specify
the number of decimals places to use. You can also use the %.0f format to display short/long variables. Although the help file
only shows 1 or 2 optional variables, there can be more than 2.

There are also a number of special strings which can be used within the MessageBox string. They all begin with the ^ and not
the % character as written in the help file:

^PCName The player's name.
^PCClass The player's class.
^PCRace The player's race.
^PCRank The player's rank in the speaker's faction.
^NextPCRank The player's next rank in the speaker's faction.
^Cell The cell the player is currently in.
^Global Any global variable value (ex: ^Day). Floats display with 1 decimal.
^NPC.Name The NPC's name.
^NPC.Race The NPC's race.
^NPC.Class The NPC's class.
^NPC.Faction The NPC's faction. If they have no faction, it will be blank.
^NPC.Rank The NPC's rank.

This is the same format used in dialogue info texts although for dialogue you can omit the NPC. to use the speaker by default (if you omit the NPC.
in scripts the player is used by default).

To return the user's choice, use the GetButtonPressed function, for example:

begin TestMessageScript
short MessageOn
short Button
; Display message when the player activates the object
if ( OnActivate == 1 )
set MessageOn to 1
endif
; Display the choices to the user
if ( messageOn == 1 )
MessageBox, "Do you wish to drink from the Bitter Cup or to pick it up?", "Drink", "Pick it up"
Set messageOn to 2
endif
if ( messageOn == 2 )
set Button to GetButtonPressed
if ( Button == -1 ) ; Nothing
return;
endif
if ( Button == 0 ) ; drink it
Disable
player->ModStrength, 20
Set MessageOn to 0
return
endif
if ( Button == 1 ) ; pick it up
Activate
Set MessageOn to 0
return
endif
endif
end

Use a similar setup for asking the user other choices.

If you pop up a message box with an 'ok' button when a saved game is loaded immediately after running Morrowind,
you won't have a mouse pointer to click on the 'ok' button to get rid of the message box. The game also keeps
running while the message box is displayed; it doesn't pause as it normally does. You can right-click to get
into Menu mode, and then you'll have a mouse pointer to clear the box with. This only happens the first time
you load a save after running Morrowind; if you load a save from within the game, you do get a mouse pointer
to click the 'ok' button with. So apparently it's some sort of initialization problem.

These Mod____ functions will modify the actor's statistic by the given amount. The functions will also accept a float variable
instead of a literal number value. There are several special cases of the Mod___ functions as described below.

Changes the weather chances for the RegionID. Used to get rid of, or add weathers to an area permanently. The
values must add up to 100 or you will get odd results. Note that the last two weather types are undocumented and
currently unknown but assumably are the two new snow/blizzard weather types added with Bloodmoon.

Type: Global, Time
Returns: short
Example: set CurrentMonth to Month
Scripts:

Assumably the current month which ranges from 0 to 11. You can use the SET command to change the current month.

The Month variable ranges from 0-11, where 0 is the first month of the year (Morning Star), 1 is the second month of
the year (Sun's Dawn), etc. The game starts in Last Seed, which is month 7 (the eighth month of the year).
Morrowind does have a bug where after a year ends, the month is rolled over to 1 (which is the second month of
the year). There is a plugin-based fix for it, which you can download off of
Morrowind Summit, but of course the
best fix is for Bethesda to repair the problem.

These functions cause the referenced object to move at the given speed. The Move function uses the object's axes while
the MoveWorld always uses the world axes (positive Z is upwards). Note that the exact speed is affected slightly by
the speed of the system the game is being played. Thus, where an exact final position is required it is recommended to
test for distance rather than time.

Not a function but must be defined as a short variable in order to be used. When defined, it will be set to 1 when the player
adds the calling item to their inventory. Should be manually reset if you wish to check for additional item additions.

Not a function but must be defined as a short variable in order to be used. When defined, it will be set to 1 when the player
drops the calling item from their inventory. Should be manually reset if you wish to check for additional item drops.

Not a function but must be defined as a short variable in order to be used. When defined, it will be set to 1 when the player
equips the item, and remain 1 while the player has it equipped (unless manually reset) and is 0 otherwise.

This is not a function but must be defined as a short variable in the script to be used. When the player hits the object, the
variable will be set to 1. It must be reset to 0 when testing for it, such as in the above example script.

Not a function but must be defined as a short variable in order to be used. When defined, it will be set to 1 when the player
repairs the calling item. Should be manually reset if you wish to check for additional item repairs.

Not a function but must be defined as a short variable in order to be used. When defined, it will be set to 1 when the player
uses a soul gem for enchanting or recharging an item. Should be manually reset if you wish to check for additional soul gem uses.

Not a function but must be defined as a short variable in order to be used.
Returns 1 if calling object has been attempted to be repaired, or 0 otherwise. This function is currently
broken and does not work.

Console only commands that output object/reference info. Further testing is required.

See Also:

PayFinePayFineThief

PayFine
PayFineThief (undocumented)

Type: Misc
Returns: none
Example: PayFine
Scripts: TGDiscountScript

Pays the player's fine for committing any crimes and resets the game's AI so that guards and NPCs don't hate
the player any more. PayFine is used by the game to clear the AI after the player pays a fine to a guard or
other law enforced. It removes any stolen merchandise from the player's inventory and puts it into the evidence
chests around the island. PayFineThief is similarily used when the player uses the Thieves Guild to remove
any bounty on their head but does not remove any stolen items.

Not a function but must be defined as a short variable in order to be used. When defined, set this to 1 to skip equipping the object, or
0 otherwise. Good for popping up messages for breaking seals on books and such.

See Also:

PCVampire

PCVampire

Type: Global
Returns: short
Example:
Scripts:

A global variable that gives the state of the player's vampire status.

-1 = Has been cured
0 = Not a vampire
1 = Currently a vampire

See Also:

PCWerewolf

PCWerewolf

Type: Global, Bloodmoon
Returns: short
Example:
Scripts:

A global variable that gives the state of the player's werewolf status.

-1 = Has been cured (immune to lycanthropy)
0 = Not a Werewolf
1 = Currently a Werewolf

Places the object at the player (PlaceAtPC) or another object/activator (PlaceAtMe), in the direction you specify and the
distance. If that location is not safe (in the air, in a wall, etc), the object will be placed at one of the other axis or
at the player’s exact location (feet). It is used most often to spawn NPCs/creatures near the player/object for a coordinated and timed attack.

Sets the position of the calling object to the given exterior (Position) or interior (PositionCell) location.
If you try to teleport to an unsafe place (clipping with an object or out in the void), you will instead be placed at the next safe location.
Some people have noticed bugs using the Position function (NPCs disappearing) and reccommend using the PositionCell function instead,
which can be outside if an exterior cell name is given.

Note that the ZRot parameter does not appear to work when PositionCell is used on NPCs. It seems to work fine on the player and
other objects though. Also, if you PositionCell something you have never met into your current cell then its local script will not
start running (until you leave the area and return anyways).

A common application of this function is to create a teleportation item (though, since variables are not accepted, you can only teleport to
set locations), for example:

You should not use either function from dialogue results as it can cause the game to crash. Instead, create a script
to peform the teleporting and use a StartScript to start it from the dialogue result.

Where: ObjectID = Object to place into world
CelID = Cell name where to place the item
X,Y,Z = Exterior/interior location to place the item, can be a literal value
as well as float variables.
ZRot = World Z-axis orientation of the item (in degrees)
Type: Movement, Tribunal
Returns: none
Example: PlaceItem, "false_sunder", 10, -5006, 0, 0
PlaceItemCell, "daedric_god_helm", "Assernerairan, Shrine", NewX, NewY, NewZ, 45
Scripts: dulniScript
projectileMine

New functions added in Tribunal to create new item references into the world. PlaceItem will create a new
item in the exterior while PlaceItemCell does the same for an interior cell.
With either function, if the target cell for the reference is an exterior cell and the given coordinate is outside of that cell,
then the reference will be added to the cell containing the coordinate. This is a nice addition that allows you to add things
to the world without previously placing them in the editor.

There seems to be a bug with PlaceItemCell in that items added with the function disappear if you save, exit, and reload.
This seems to depend on the order in which things occur. For instance if you add an NPC to the clothier to a cell that the player
has never visited the NPC will be there. However, if you save the game after the NPC has been added, reload that save and then
visit the cell the NPC will not be there.

Where: GroupName = Animation group to play.
Flags = Optional parameter indicating when the animation should start.
0 = Normal, the current animation will finish it’s full
cycle, and the new animation will start from its beginning.
1 = Immediate Start, the current animation will stop
regardless of the frame it is on, and the new
animation will start from its beginning.
2 = Immediate Loop, the current animation will stop
regardless of the frame it is on, and the new
animation will start at the beginning of its loop cycle.
Type: Animation
Returns: none
Example: PlayGroup, Idle2
"taren andoren"->PlayGroup, Idle, 0
"Black Dart Malar"->PlayGroup "Death1"
Scripts: AzuraEnd
rockSlide
drowned

Plays the animation group defined by GroupName. Optional flags can be used to start the group in different ways.
The various group names can be found by viewing the animation menu options in the Character menu in the Construction Set.

These functions play sound with a variety of options. The PlaySound function will play the sound at full volume, sounding
like it comes from directly at the player's location. The 3D functions will cause the sound to be played from the calling object's
location in the game (so it will be dimmer the farther the player is away from it). The VP functions allow you to adjust the
volume and pitch of the sound, although whenever the functions are used only 1 for both volume and pitch are used. The PlayLoop
functions will play the sound continuously until a StopSound function is called.

Where: Value = One more than the maximum random number you want to generate
Type: Misc
Returns: short
Example: if ( Random, 10 == 5 )
set sValue to Random, 100 ; Random number between 0 and 99
Scripts: Main
ouch_sunder

Removes all spells currently affecting the calling actor that include the given effect. Note that this is slightly different from the
GetEffect function which accepts the sEffect___ ID rather than the numeric value.

If this script was attached to the some_unique_item and the only instance of it was removed from the player's inventory,
the game would crash. In order to successfully remove the item you will have to use a global script or from another object.
You can successfully remove items that do not exist in the calling object's inventory. The RemoveItem function accepts a
short count value which limits the number of items you can remove at a time to 65535 (or possibly 65534).

It appears that if you use RemoveItem from the player, the player's encumberence is modified, whether or not they actually have
the object. An interesting way to modify the amount the player can carry, especially in situations where uninstalled mods have
caused the player to carry around 'missing items' (i.e., the player's encumberence does not reach 0 when naked). Generally, though,
you will not want to modify the player's encumberence so check for the existence of items with the GetItemCount
before you remove them.

There is a bug related to this function when adding/removing items from a container causing the container's contents to not be
updated the second time items are added/removed. See AddItem for information on this.

Note that this function does accept global variables but only in dialogue results, not scripts.

Removes one soulgem containing the given creature's soul from the calling actor's inventory. Note that
some references incorrectly mention an optional 'Count' argument where you can specify the number of
the soulgem to remove (confirmed in script output with Bloodmoon and latest patch).

Removes the spell from the calling actors known spell list or affecting spells. If the spell is a normal spell, it is
removed from the actor's list of known spells. If the spell is a curse/disease it is removed from the list of spells
currently affecting the actor.

A bug vaguely related to this function is that if a creature dies with a curse type spell on it, then any other creature of
that type you encounter from that point on will also be effected by that curse. To fix this simply call RemoveSpell in an
OnDeath clause in a script attached to the creature. The fact that this happens in the
first place suggests to me that the spell is added to the creature definition, and not just that particular instance of the creature.

Brings actor back to life. When you do this any changes made to the actor in game (stats, inventory, etc...) will be reset
to their original value. I have experienced game crashes when using this function from the console sometimes (not consistent).

See Also:

Return

Return

Type: System
Returns: none
Example: return
Scripts:

Use this to stop processing a script before the end. This is particularily useful for long scripts that may take
some time to fully process. For example:

Rotates the object along the specified world (RotateWorld) or object (Rotate) axis at the specified number of
degrees per second. To be used properly, the function should be called continuously while rotation is desired, for example:

Use set to store a value or expression to a variable. The expression can be a complex mathematical expression
including numbers, functions, and variables. When using the set command you should make use of spaces surround all
operators and variables. You should also surrounding all functions with brackets (if you do not use brackets some
functions will not compile correctly).

Note that you can have multiple functions in the set expression, however they will all apply to the same object reference.
For example:

These Set functions will set the exact value of the statistic. The functions will also accept a float variable
instead of a literal numeric value. There are several special cases of the Set___ functions as described below.

SetScale - New in Tribunal

SetWaterLevel - New in Tribunal

SetPCCrimeLevel - Player only

SetPCVisionBonus - Player only, Undocumented

SetAlarm

SetFight

SetFlee

SetHello - When you use these functions you change the AI settings for ALL references of the actor, not just the calling reference.

SetScale - You can exceed the 0.5 to 2.0 scale limits imposed by the editor. You shouldn't call SetScale in every frame, at least
not in exteriors or other FPS-critical situations. Keep in mind that the scale will be reset to the 0.5 - 2.0 range when you reload.
Either call it regularly (about every 10 frames) or test for GetScale and reset the scale when it doesn't fit.

Note that the SetInvisible was incorrectly spelled as SetInvisibile in the original Morrowind game (fixed in a later patch or Tribunal?).

This resets the object to the original position and orientation it was given in the editor, before any movement or rotation occurred.
Be warned that this function doesn't always seem to do exactly as it should. Objects are not nessecarily reset to its editor defined position.

The SetDelete function can be used in combination with Disable to remove an object more completely.
SetDelete 1 marks a reference for deletion while SetDelete, 0 clears that flag. If the reference came
from the master file, it is still there but knows it shouldn’t be so has no art and no scripting. If
was created in game, it will actually be deleted.

Use "SetDelete, 1" to mark on object to be deleted/not saved in a save game. Objects that have been put in
the world with the editor (or perhaps those already saved in the game) seem to stay in place when it's used
on them, until a save/load has happened, and a "SetDelete, 0" could be used on them to undo the effect. Items
that are placed however, using PlaceAtPC, or PlaceItem, are immediately deleted from the world.

There are a couple of things that should be done to make this work, as I had some problems with using it crashing
the game otherwise. If you use this on an object, give it a bit of time of inactivity before you delete it, and Disable
it ahead of time. So you could put something like this in your script near the top, as an example:

That way, with the return, it stops the rest of the script if it's up near the top of it (below where you setup the variables though), and
disables it, and gives it a bit of time before it's deleted. It may not need 10 frames, but that's not long, and it worked in my scripts
It can be quite a useful function in scripting things, as it allows for a script to use PlaceAtPC or PlaceItem scripts or such to create
items within the world, at different locations, or different situations, where you may want to delete such items after.

Other useful tips for successfully using SetDelete are:

Always call setDelete from a local script.

Give at least 2 seconds if you've used Cast or ExplodeSpell, otherwise it is perfectly OK
to Disable one frame then SetDelete the next.

Sets the Journal to that index. Can move up or down. Not used so I'm not sure what purpose or use this function is.
Although it is supposedly included in the original game, it only works in Tribunal or later versions.

SetJournalIndex is primarily useful to set a Journal to an entry without displaying any journal text.
This can be used as a form of a quest variable without being forced to actually create a global variable to
govern that quest -- for example, to display something to the player, and then set a special flag for that quest you
can set the index to 46, and then check to see if the dialogue entry is 46 instead of 45 to have the NPC do
something different when reacting to the player. Essentially, it's a way of tracking the player's
shenanigans without tipping off the player with a journal entry.

You can set the journal index to values where a journal index doesn't actually exist, as well.
Whether or not you can use SetJournalIndex to repeatedly display the same journal entry over and over,
I haven't tried.

Where: Axis = World axis to set the object's position (X, Y, or Z)
Position = Position in game units to set (float). In Tribunal the function can accept
variable floats as well as literal values.
Type: Movement
Returns: none
Example: SetPos, X, 45.0
"Act_banner_Tel_Vos"->SetPos, Z, -1002.0
SetPos, Y, GetStartingPos, Y
SetPos, Y, fValue (Tribunal only)
Scripts: shrineGnisisSecret
PlagueRock1

Sets the position of the object in game units (70 units per meter) using the given world axis. In Tribunal the function also accepts
local float variables in addition to literal values (does not accept globals). This function does modify the player's position. Unfortunately
there are problems when you use SetPos to change the current cell. The cell's contents are not always loaded correctly. In this case you
may need to use the COE (CenterOnExterior) function to change the current cell and then the SetPos to modify the player's position. An easier
method is to use a FixMe function call after the player's position has changed.

A related problem is in exteriors the function will only work in the currently loaded area (the current cell plus 2-3 cells
around the current cell). It can't be used to move something to an arbitrary exterior cell.

Sets the acrobatics skill value/bonus when the player is in Werewolf form (unconfirmed).

See Also:

Short

Short

Type: System
Example: short LocalVar
Scripts:

This is one of the three types of the scripting language. Short variables are signed and can range from
-32,768 to 32,767.

Although local variables can start with an underscore character (_), this seems to cause strange problems in
some functions. Therefore it is reccommended that you do not name variables starting with the underscore.

Unknown console command (similar to ShowVars?). If you use this in a script it will prevent the script from being
compiled (you'll get no errors in the editor but the compiled script data is not saved to the plugin).

Displays the standard rest/sleep menu allowing the player to choose the amount of time they wish to rest.

See Also:

ShowSceneGraph (SSG)

ShowSceneGraph
SSG

Type: Console
Example:
Scripts: n/a

When you use this command the game will freeze for a short time (30 seconds or so). When the command is finished it will actually create
a new Window on the desktop with all the game renderer's information (use Alt-Tab or Alt-Esc to temporarily exit the game and view the
other window). The information is displayed via a tree control and those familiar with hacking NIF files may recognize some of the
information. The world objects can be found under the World Scene Graph--WorldRoot--WorldObjectRoot and then under the currently
loaded cells. You can view the various rendering information under each object. This probably won't be much use to most people but
only those performing low-level hacking/editting of Morrowind or it's data files (such as NIF files).

See Also:

ShowTargets (ST)

ShowTargets
ST

Type: Console
Example:
Scripts:

Console command that shows the selected actor's target group members.

See Also:

ShowVars (SV)

ShowVars
SV

Type: Console
Example:
Scripts:

Console command that lists all the global and/or local variables. If no object is currently selected in the console (shown by
the console title) SV will list all global variables and values. If an object is selected SV will list all the object's script
variables and values (if it has any). This console command is invaluable for debugging purposes.

Causes the current animation to not be played for this frame. One of the useful things to do with this is to create armor dummies for displaying
armour and clothing. Simply create a new NPC, set its health to 0, and attach to it a script like the following:

begin test_dummy
SkipAnim;
end

When you insert the NPC into the game it will die (since it has no hitpoints) but it will not 'fall over' since all its animations are disabled.
You can then access its inventory (since its dead) and any armour that you place in the dead body will be automatically equipped. Unfortunately it
appears that weapons are not automatically equipped in the same manner.

The calling NPC will start combat with the given ActorID. Should only be called once (not continuously) or you may experience unintended results
(such as the NPC not attacking at all). Once combat is started, the NPC is subject to the usual AI rules (such as fleeing).

This function starts a script running as a global script. It is not attached to any object, so functions like moving, rotating,
checking distances and such have no bearing in a global script (which means you must specify object IDs explicity). Note this
isn't exactly true as if you start a global script it will use the calling script object by default (i.e., if you started a global
script from within the NPC Bob's script, the global script would use Bob as the default object).
Global scripts are good for running complex quests, checking variables, or setting timers. Each global script is run every
frame so take care not to run too many at one or the game's speed will be reduced.

You can target a global script using either ObjectID->StartScript, or calling StartScript from the dialogue results box.
While both are true, they don't quite work as expected when used together. From the results box, ObjectID->StartScript
seems to attach the script to the NPC calling the dialogue and not the referenced object. When you use a targetted global script
any function call in the script will use the target object (you don't need to explicitly specify the object unless you need/want to).

This stops a currently running global script started previously with StartScript. Using StopScript
resets any local variables used by that script. A StopScript will not immediately terminate the
script when it is called. Instead, the script continues executing to the End statement, and then terminates.
Use the Return command to immediately stop a script for the current frame if desired.

If a Tribunal Start Script is terminated with StopScript, it will start up again the next time the game is loaded.

Turns the moon(s) the given color for special Werewolf effects (unconfirmed).

See Also:

UndoWerewolf

UndoWerewolf

Type: Werewolf, Bloodmoon
Returns: none
Example:
Scripts:

Will undo the werewolf change brought on by the BecomeWerewolf function. However, the NPC/creature will
essentially be naked after the switch. They have to be told to re-equip (weapons are usually re-equipped if it occurs in combat).

Using Becomewerewolf and Undowerewolf can break your game. Some quests and variables depend solely on on use of these,
so if you use one to toy around.... you may be asking for it.

Returns 1 if the given ObjectID is used on the calling object, or 0 otherwise. It appears that this function is currently broken.
UsedOnMe is probably commented out because there's no way for an object to be used on another in the Morrowind
engine. I suspect that it was early alpha stuff.

Displaythis document for printing (some pages may not display properly).

If you have any problems, suggestions or comments on this page or website, please
feel free to use the Contact Form to send
a message to the WebMaster.
This document was last modified on: Saturday, 19 February 2011, at 09:55:40
and has been accessed
? times
( /morrow/editor/mw_cscommands.shtml ).