MOHAA scripting language, Appendix A :: Bjarne Grönnevik
Commands
When you know how to script, its time to start using the commands
that you can invoke from the scripting language. This document is
a list of commands paired with descriptions and other explanations
of how best to use them. It is by no means all of the commands,
just the most common and / or the ones that needs to be explained
the most. For a complete ( but short ) definition of ALL commands,
see the file g_allclasses.html
( for Allied Assault ) and MOH_GameClasses.html
( for Spearhead ).
Example: cansee( Entity entity, [ Float
fov ], [ Float vision_distance ] ). Example explanation: The class 'Entity' supports a command
named 'cansee'. This command requires a parameter of the class
'Entity', and you may also supply the two 'Float' parameters fov
& vision_distance. Any place where a certain class is required,
any class inheriting from that class will also work just as well.
In short:
A commands parameter list is written within parentheses - ( ).
An optional command is written within 'square' parentheses - [
].
General
Command:
thread
Syntax:
thread ( String label )
Example:
exec background_player_scanner
Description:
This command executes from the specified label in a new thread.
Command:
waitthread
Syntax:
waitthread ( String label )
Example:
waitthread initialize_spawns
Description:
This command executes from the specified label in a new thread
and waits until the called thread group is finished. That means
the next line in the script wont be executed until the other
thread is done.
Command:
exec
Syntax:
exec ( String script )
Example:
exec my_personal_script_file.scr
Description:
This command executes the specified script.
Command:
waitexec
Syntax:
waitexec ( String script )
Example:
waitexec my_personal_script_file.scr
Description:
This command executes the specified script and waits until
the called thread group is finished. That means the next line
in the script wont be executed until the other executed script
is done.
This command hides an object so that it is invisible to the
player. It's status is not sent from the server to the client,
so a player will not experuience it. The object still exists.
If it is already hidden, nothing happens.
Command:
show
Syntax:
show
Example:
$document_to_steal show
Description:
This command shows an object so that it is visible to the
player. If it was already shown... nothing really happens.
Command:
remove
Syntax:
remove
Example:
$document_to_steal remove
Description:
This command removes an object so that it no longer exists
in the game.
Rotation
Command:
rotateX, rotateY, rotateZ
Syntax:
rotateX ( Float angular_velocity )
Example:
$fan rotateX 1.5
Description:
Rotate about the X ( or Y or Z ) axis at the specified angular
velocity. The angular_velocity represents the speed to rotate
the object.
Command:
rotateXdown, rotateYdown, rotateZdown
Syntax:
rotateXdown ( Float angle )
Example:
$trapdoor rotateXdown 45.0
Description:
Rotate the X ( or Y or Z ) down by the specified angle. The
angle represents the angle to rotate the object.
Command:
rotateXup, rotateYup, rotateZup
Syntax:
rotateXup ( Float angle )
Example:
$trapdoor rotateXup 45.0
Description:
Rotate the X ( or Y or Z ) up by the specified angle. The
angle parameter represents the angle to rotate the object.
Command:
rotateXdownto, rotateYdownto,
rotateZdownto
Syntax:
rotateXdownto ( Float angle )
Example:
$trapdoor rotateXdownto 45.0
Description:
Rotate the X ( or Y or Z ) down to angle. The angle parameter
represents the angle to rotate the object.
Command:
rotateXupto, rotateYupto, rotateZupto
Syntax:
rotateXdownto ( Float angle )
Example:
$trapdoor rotateXdownto 45.0
Description:
Rotate the X ( or Y or Z ) up to angle. The angle parameter
represents the angle to rotate the object.
Movement
Command:
move, waitmove
Syntax:
move
Example:
$elevator moveto $waypoint_down
$elevator move
Description:
Move the script slave. This command executes the previous
movement commands sent to a ScriptSlave ( the class of a script_object
). The waitmove command also waits for the move to complete
before continuing execution.
Move the specified distance ( Measured in world units ).
Object status tests
Command:
isAlive
Syntax:
isAlive
Example:
if !(isAlive $vip_player) { teamwin axis }
Description:
This command checks to see if something is alive. If it is,
1 is returned else 0 is returned ( if it is "dead"
that is ).
The definition of life ( in MOH ) is to have more than 0 in
health.
Command:
isTouching
Syntax:
isTouching ( Entity entity )
Example:
if !($player[local.index] isTouching $it) { teamwin axis }
Description:
This command checks to see if something is touching the object.
If it is, 1 is returned else 0 is returned. ( Not sure about
his commands usage and function, tell me more! ).
Performs a trace line from the start to the end, returns
0 if something was hit and 1 otherwise.
The pass_entities sets the number of entity bounding boxes
that are assumed to be 'invisible'.
mins and maxs set the bounding box within the sighttrace.
It is performed to save CPU usage. (See also setsize command).
Comment:
The same command is found in the Entity class.
Damage
Some commands have a parameter named meansofdeath ( damage
and killed in the Player class as an example). It is an integer
that use these values:
Id
Name
Description
0
MOD_NONE
1
MOD_SUICIDE
2
MOD_CRUSH
3
MOD_CRUSH_EVERY_FRAME
4
MOD_TELEFRAG
5
MOD_LAVA
6
MOD_SLIME
7
MOD_FALLING
8
MOD_LAST_SELF_INFLICTED
9
MOD_EXPLOSION
10
MOD_EXPLODEWALL
11
MOD_ELECTRIC
12
MOD_ELECTRICWATER
13
MOD_THROWNOBJECT
14
MOD_BEAM
15
MOD_ROCKET
16
MOD_IMPACT
17
MOD_BULLET
18
MOD_FAST_BULLET
19
MOD_VEHICLE
20
MOD_FIRE
21
MOD_FLASHBANG
22
MOD_ON_FIRE
23
MOD_GIB
24
MOD_IMPALE
25
MOD_BASH
26
MOD_TOTAL_NUMBER
Sound
Sound is played on a distinct channel, here is a list of the available
channels:
Id
Name
Description
0
auto
This is considered the lowest audio channel priority. It always
plays if possible (hardware audio channel available) and they
don't override previously played sounds. If no channels are
available, the sound will just not play. This is best used for
things that do not have a particular entity or character related
to them (like bullet hit sounds), or are not overly important
sound (like shell casing landing sounds or footsteps).
1
body
These are sounds made by a characters body. These include
sounds like impact sounds (from falling & landing hard)
and equipment movement jingles.
2
item
These are sounds made by items on a character, or that represent
some sort of item related sound. These would include sounds
made by any misc items carried by a character like papers or
binorulars, but could also be used as a second weapon sound
channel if it is required for a weapon to play two different
sounds at the same time. This is also the channel that should
be used for weapon reload sound to prevent them from cutting
off long firing sounds.
3
weaponidle
Is for constant sound made by weapons or possibly the character
itself. An example from Quake3 would be the rail gun hum, but
I can't think of any examples from MoH, exept a low mumbling
of the player commenting on how mush he/she loves his/her gun..
4
voice
These are vocal sounds made by a character such as pain, death,
and yelling during combat. This is effectively a lower priority
dialog channel for general use throughout the majority of the
game.
5
local
This plays a sound that is considered to be "local"
to the player. Meaning, it does not do 3D spatialization on
the sound. It does adjust the volume of the sound according
to distance though. This is best used for playing sounds that
should sound omni-directional like rain or lightning.
6
weapon
These are the sound that are made by the characters' weapons.
These include the firing sounds, but not reloading sounds.
7
dialog_secondary
This is a secondary backup dialog channel. Good for use with
lower priority dialog such as idle chatter between characters,
as it's considered to be lower priority than regular dialog.
This should only include spoken dialog that will have subtitle
text.
8
dialog
This is the primary sound channel for playing character dialog.
This should only include spoken dialog that will have subtitle
text.
9
menu
This is the sound channel for menu sounds to play on.
Play a looped-sound with a certain volume and minimum_distance
which is attached to the current entity.
Command:
stoploopsound
Syntax:
stoploopsound
Example:
$radio stoploopsound
Description:
Stop the looped-sound on this entity.
Text printing
Command:
print, println
Syntax:
print ( String text )
Example:
print "It came from the script ( desert? )!"
Description:
Prints a message in the consol. The println version is followed
by a line break.
Command:
iprintln, iprintlnbold
Syntax:
iprintln ( String text )
Example:
iprintln "It came from the script ( desert? )!"
Description:
Prints a message on the left side of the screen in yellow
( no clicking sound ) followed by a line break. The bold version
uses the same font, but in white and clicking.
Command:
iprintln_noloc, iprintlnbold_noloc
Syntax:
iprintln_noloc ( String text )
Example:
iprintln_noloc "Elvis has left the building!"
Description:
Prints a message on the left side of the screen in white
( with a clicking sound ) followed by a line break. Bold version
uses a bold font.
Command:
locprint
Syntax:
locprint ( Integer X_offset, Integer
Y_offset, String text )
Example:
locprint 30, 100, "Here I am!"
Description:
Prints a message in the specified X-Y location of all player's
screens.
Command:
centerprint
Syntax:
centerprint ( String stuffToPrint )
Example:
centerprint "5 health penalty awarded!"
Description:
Prints the text desired into the center of the screen,
On all resolutions.
Mathematic
Command:
abs
Syntax:
abs ( Float argument )
Example:
abs -23.656
Description:
Returns the absolute value of the parameter. abs 15.3 returns
15.3. abs -2 returns 2. abs -5.999 returns 5.999. So it basically
converts any number to a positive one by removing the minus
sign.
Command:
randomfloat
Syntax:
randomfloat ( Float max )
Example:
randomfloat 14.9
Description:
Returns a random number between 0 and 'max'.
Command:
randomint
Syntax:
randomint ( Integer max )
Example:
randomint 10
Description:
Returns a random number between 0 and 'max'.
AI
Command:
moveto
Syntax:
moveto ( String anim, String dest )
Example:
$evil_one moveto "anim/my_animation" "there"
Description:
Specify the location to move the actor to, with the animation
anim used.