Parameter Info:
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
[thothie][/thothie] = Entry added by Thothie based on working script or code

<command> - Means the parameter is required
[command] - Means the parameter is optional
(target) - indicates origin is to be used instead of entity id
_idx - indicates client model index rather than entity id

(r,g,b) is a color in the format "(red,green,blue)".  Each value ranges from 0-255 //thothie - with the exception of some client side effects, including beams, which are 0-1.0

$rand(<low>,<high>) 
$randf(<low>,<high>) 
	Returns a random number bewtween <low> and <high>.  Floating point uses $randf()
$vec(x,y,z) 
	Returns (x,y,z), with all parameters resolved (you can use constants or variables for x, y and z)
$vec.<x/y/z/pitch/yaw/roll>(<vector>) 
	Returns the x, y, z, pitch, yaw or roll value of the specified vector
	pitch, yaw and roll correspond to x, y and z respectively, but are named for clarity
$anglediff(<destang>,<srcang>) 
	Returns the difference between two angles.  Accounts for 360 degree wrap-around
$relpos(r,f,u) 
	Is a relative position in the format "$relPos(units Right,units Forward,units Up)"
	For example, $relpos(-1,10,0) Means 1 unit to the left (negative), 10 units forward,
 	and 0 units up from the origin of the item or NPC that is running the script command.

$relpos($vec(pitch,yaw,roll),$vec(r,f,u)) 
	Returns a relative position, same as the above command, except you specify the source
	angles instead of using the entity's angles.  A string such as,
	"$relpos((0,90,0),(60,60,10))"
	will *not* work.  You must use $vec(), such as "$relpos($vec(0,90,0),$vec(60,60,10))"
	Or use variables, such as "$relpos(ANGLES_VAR,OFFSET_VAR)"

$relvel(r,f,u) 
	Is a relative velocity in a similar format to $relpos()
	For example, $relvel(-1,10,0) Means 1 unit to the left (negative), 10 units forward,
 	and 0 units up based on the direction the item or NPC is facing

$relvel($vec(pitch,yaw,roll),$vec(r,f,u)) 
	Returns a relative velocity, same as the above command, except the source angles
	are specified instead of using the entity's angles.  Syntax rules are similar to $relpos

$cansee(<enttype>,[distance]) 
	Returns 1 if the monster can see <enttype> or 0 if not.  When [distance]
	is specified, the target must be within this distance to be successful.  
	<enttype> may be "enemy", "ally", "player", or a monster or player name.
	//note $cansee(enemy) doesn't conform to relations used by $get(ent_lastheard,relation,ent_me) etc.

$dist(<start origin>,<end origin>) 
	Returns a float indicating the distance between the two points

$veclen(<vector>) 
	Returns the length of a vector

$veclen2D(<vector>) 
	Returns the length of a vector, excluding the z component

$dir(<start origin>,<end origin>) 
	Returns a normalized vector indicating the direction from <start origin> to <end origin>

$within_cone(<point origin>,<cone origin>,<cone angles>,<cone apex angle>) 
$within_cone2D(<point origin>,<cone origin>,<cone angles>,<cone apex angle>) 
	Returns 1 if the point is within the defined infinite cone

$cone_dot(<point origin>,<cone origin>,<cone angles>) 
$cone_dot2D(<point origin>,<cone origin>,<cone angles>) 
	Returns -1 to 1 indicating how far off the point is from straight forward in the view cone

$anim_exists(<name>)
	Checks if anim <name> exists within the scripted monster or player.

$get_sky_height(<origin>)
	Returns the sky height at <origin>.  Returns "none" if sky not found or if <origin> 
	is above the sky
$get_ground_height(<origin>)
	Returns the ground height at <origin>.  Returns "none" if ground not found or if <origin> 
	is below the ground

$get_skill_ratio(<ratio(0-1)>,<Min Amt>,<Max Amt>)
	Returns a number between Min and Max based on the ratio. If the ratio is .5, this returns
	a number halfway between Min and Max.  If .1, the number is 10% of the way towards Max.

$int(<number>) 
	Returns <number> as an integer
$float(<precision>,<number>) 
	Returns <number> as a float with <precision> decimal places
$stradd(<string1>,<string2>,<string3>,etc.)
	Adds strings together //Thothie - never seen this work, but the code looks fine :\
$get_token(<token string>,<idx>)
	Retrieves one token from a token string.
	A token string is an array of strings separated by semi-colons (ex: "string;string2;etc")
$get_token_amt(<token string>)
	Determines the number of tokens (a.k.a array elements) in a token string.

$get(<target>,<value>,[extra])
$get_by_idx(<target idx>,<value>,[extra])

	Returns a value of the <target> entity ($get_by_idx uses an entity index for <Target>)
	<value> may be: 

	Entities:
	========
	"name" - returns the name of <target>
	"name.full" - returns the full name of <target> (an Orc, 2 fire arrows, the Gaurd, etc.)
	"name.full.capital" - returns the full name of <target>, but starting with a capital letter
	"id" - returns an id that can be used as a <target>
	"index" - returns an entity index that can be sent to the client and used in $getcl()
	"exists" - returns 1 if the entity still exists

	"alive" - returns 1 if the entity is alive
	"speed","speed2D" - returns the current total speed or ground speed (speed2D)
	"onground" - returns 1 if the entity is currently on the ground
	"gravity" - returns the entity's current gravity (0 is the same as 1.0)
	"height" - returns distance from top to bottom of the bounding box
	"origin" - returns the origin in (x,y,z) format
	"origin_center" - returns the entity bbox center in (x,y,z) format
	"velocity" - returns the current velocity in (x,y,z) format
	"angles" - returns the current angles in (x,y,z) format
	"range" - returns the distance to the entity (from bounding box to bounding box)
	"range2D" - returns the distance to the entity, excluding height
	"relationship" - returns "ally", "enemy" or "neutral"
	"isplayer" - returns 1 if <target> is a player

	Scripted:
	========
	"scriptvar" - Returns the value of the Variable named [extra] in scripted entity <target> 
	//Thothie - there maybe an issue with this, if the script calling for the scriptvar has a matching scriptvar set
	//- place variable name in single quotes to prevent this, eg. $get(MY_MASTER,scriptvar,'NPCATK_TARGET')

	NPCs:
	====
	"race" - returns the race
	"movedest.origin" - returns the current move destination
	"movedest.prox" - returns the current move destination proximity //Thothie-seems to actually return a 1 until rest reached - use $dist(game.monster.origin,<origin>) or $get(<target_ent>,range)
	"moveprox" - returns the monster's default move proximity, based on bbox size
	
	Player Only:
	===========
	"target" - returns a player's current target in entity format
	"gender" - returns "male" or "female"
	"eyepos" - returns the position of the player's eye (camera)
	"jumping" - returns 1 if the player is jumping
	"ducking" - returns 1 if the player is ducking
	<stat.<name>[.max/.ratio] - returns a player's Natural stat (Concentration, Awareness, Fitness, etc.)
		Ex: stat.concentration or stat.strength.ratio
	<skill.<name>[.prof/.balance/.power][.max/.ratio]>
		Returns the current skill amount (Ex: skill.spellcasting or skill.smallarms.power)
		If [.max] is added, it returns the max amount possible of that skill
		If [.ratio] is added, it returns a ratio of the current amount to the max
	"canattack" - returns 1 if can attack //Thothie AUG2007a


$getcl(<target idx>,<value>,[value2])
	Returns a value of the <target idx> entity on the client.
	<target idx> is the entity index, which is usually sent from the server

	"exists" - returns 1 if the entity still exists
	"visible" - returns 1 if the entity is visible
	"isplayer" - returns 1 if the entity is a player
	"gravity" - returns the entity's current gravity (0 is the same as 1.0)
	"origin" - returns the origin in (x,y,z) format
	"center" - returns the center in (x,y,z) format
	"velocity" - returns the current velocity in (x,y,z) format
	"angles" - returns the current angles in (x,y,z) format
	"scale" - returns the current scale
	"bonepos" - returns the last rendered position of bone #[value2]
	"model" - returns the name of the model, or "0" if none
	"modelidx" - returns model index number
	"anim" - returns the current animation index
	"frame" - returns the current animation frame
	"framerate" - returns the current animation framerate

$get_by_name(<name>)
	Returns the id of an entity that is named <name>

game.x.x
	Returns the current state of something
	Examples: game.time  |  game.monster.isalive

	    game
		.time
		.map
			.name - Name of the map
			.skyname - Prefix for the current sky
		.players	- Number of players
		.clientside	- Whether the script is currently running on the client
		.serverside	- Whether the script is currently running on the server

		.sound		- Game constants / Sound channels and volumes
		      .weapon
		      .voice
		      .item
		      .body
		      .stream
		      .static
		      .maxvol
		      .silentvol

		.monster	- A value from the current monster (that the script is running on)
			.name
			.origin
			.....etc, etc, etc <same as $get()>
	
		.tempent	- A value from the current temp entity (Only valid during a callback function)
			.origin
			.angles
			.velocity
			.scale
			.deathtime
			.bouncefactor

		.script	- Values returned by a command
			.last_sent_id - ID of last script send to a client
			.last_light_id - ID of last dynamic light
			.iteration - Current iteration when called in a loop

		.localplayer - Client-side values associated with the local player
			.index - Local player index
			.thirdperson - Whether the player is in thirdperson
			.viewmodel.left.id - Left view model entity index
			.viewmodel.right.id - Right view model entity index
			.viewmodel.active.id - Active view model (left or right) entity index (-1 if none)

		//Thothie new
		.pvp		- returns ms_pklevel var
		.revision	- returns version
		.central	- returns ms_central_enabled var
			
Targets:

ent_lastseen: 	 The entity the monster last saw
ent_lastheard:	 The entity the monster last heard
ent_lastspoke:	 The entity the monster last heard text from
ent_lastoffered: The entity the monster last game somthing to //Thothie - defunct
ent_lastgave:	 The entity the monster recieved something from //Thothie - defunct
ent_laststole:	 The entity the monster last noticed trying to steal from him //Thothie - defunct
ent_lastused:	 The entity the monster by last used by
ent_laststruck:	 The entity the monster was last hit by
ent_laststruckbyme: 	The npc I last hit
ent_lastprojectile:	Last projectile created (via tossprojectile)
ent_lastcreated: 	Last entity created (via createnpc/createitem)
ent_me: 	 Myself
ent_owner: 	 My owner (items only)
ent_creationowner:  The entity that created me (via createnpc/createitem)
ent_target: 	 My current target (player only)
ent_expowner: 	 The player that will receive credit for my damage and kills (projectiles)

Compares:

strings:
a equals b	If a is alphabetically equal to b //Thothie - use also for comparing vectors or entity ID's
a isnot b	If a is not alphabetically equal to b
a contains b	True if a occurs anywhere in b (case sensitive, new JUN2007)
a startswith b	True if a starts with b (case sensitive, new JUN2007), you can use $lcase() to convert case

numberical:
a == b		If a is numerically equal to b
a != b		If a is not numerically equal to b
a > b		If a is numerically more than b
a < b		If a is numerically less than b
a >= b		If a is numerically more than or equal to b 
a <= b		If a is numerically less than or equal to b 
(math compares are order sensitive, meaning: "=>" isnot ">=", etc.)

All vars are effectively strings, so you can do string comparisons of numbers, and the like.
Use string compares when comparing target id's.

Commands
ŻŻŻŻŻŻŻŻ

{ [[scope]] [event name]
	Starts an event.  Commands can only be executed within an event.
	[[scope]] == [server] 			- Event is server-side only
	[[scope]] == [client]   		- Event is client-side only
	[[scope]] == nothing or [shared]   	- Event is used on the client and server
}
	Closes an event.
Thothie: remember if an event is both on client and server, the variables and available properties may not match up

dbg <text1> <text2...>
	Prints text to the console (dev mode 1).  The parameters can be variables.
	//Thothie: Only appears in alpha builds
hp <#>
	Sets the monster's current and max hit points.
fov <0-360>
	Sets the monster's field of vision (range in front of it that it can see)
	Thothie: DON'T USE THIS - it eventually leads to all monsters on the map "going blind"
gold <#>
	Sets the ammount of gold a monster currently has
width <#>
	Monster's clipping box width (the rectangle's width)
height <#>
	Monster's clipping box height
stepsize <#>
	Highest stair height the monster can walk up
	Thothie: base_monster_shared will make this half the monster's height by default
maxslope <0-90>
	Max slope angle the monster can walk up.
race <racename>
	Monster's alignment
	Thothie: see \races.script
skilllevel <#>
	Sets how much exp is gained from from killing this monster
setbbox [mins] [maxs]
	Sets an entity's clipping box size (Example: "setbox (-1,-1,-1) (1,1,1)" )
setbbox <animsize/npcsize>
	npcsize: Sets an NPC's clipping box to it's normal size (-Width/2,-Width/2,0) (Width/2,Width/2,Height)	
	animsize: Sets an NPC's clipping box to the bbox extracted from the anim
setsolid <none/box/slidebox/trigger>
	Sets the solidity of the object.  Default is box for monsters
	"none" - Not solid
	"box" - Use the entity's bounding box (width x width x height)
	"slidebox" - Similar to box, but for objects that move without AI
	"trigger" - Non-blocking, but responds to a touch
setalive <0/1>
	Marks the creature as alive or dead
	Thothie: playing with this will fool monster spawners and may cause issues
setprop <target> <property> <value>
	Sets a core value of an entity.  These values are used directly by the engine.  Useful for direct
	control over an entity or brush.  No validation checks are done.  Erroneous values for the 
	particular entity type will cause undefined behavior and crashing. 
	<property> may be:
		"speed"			float
		"skin"			int
		"modelindex"		int
		"model"			string
		"solid"			int
		"movetype"		int [see movetype entries at end - thothie]
		"classname"		string
		"basevelocity"		vector
		"avelocity"		vector
		"velocity"		vector
		"movedir"		vector
		"ltime"			float
		"nextthink"		float
		"friction"		float
		"frame"			float
		"animtime"		float
		"sequence"		int
		"playerclass"		int (used for glass brushes - not related to MS player)
		"target"		string
		"targetname"		string
		"netname"		string
		"view_ofs"		vector
		"deadflag"		int
		"health"		float
		"controller0"		byte
		"controller1"		byte
		"controller2"		byte
		"controller3"		byte
		"blending0"		byte
		"blending1"		byte
		//thoithie added DEC2007
		"rendermode"		1-5 (see hammer)
		"renderamt"		0-255

setcallback <think/touch/blocked/render> <enable/disable>
		Sets whether the game calls script functions on these events.  Calling script
		events slows down the game, so only enable the callbacks you use.

		"think" - Calls game_think every frame.  Enabled by default
		"touch" - Calls game_touch every frame that the enity is touching something.  
			  PARAM1 is the other entity.  Disabled by default
		"blocked" - Calls game_blocked when movement is blocked by anther entity.
			  PARAM1 is the other entity.  Disabled by default
		"render" - Calls game_prerender every frame on the client.
			   Calls game_render every frame on the client.
			   Default off

name <name>
	Monster's name as shown when looking at it, or when it's speaking
	Also sets the unique name to <name>
name_prefix <name>
	Sets the prefix to the name (Ex. "a","the","a pair of")
	Thothie: this can be sent in name (above) with a file pipe, eg. an|Orc, a pair of|Gauntlets, etc.
name_unique <name>
	Sets a unique name, for reference with $get_by_name()
	Thothie: subsequent spawns of script with idenitcal name_unique will be ignored
roam <0|1>
	Turns on/off monsters ability to freely move around
blood <type>
	Sets the blood type.  <type> can be "red", "green", or "none"
movespeed <multiplier>
	Multiplies the npc's speed by <multiplier>
drop_to_floor [target]
	Drops the entity to the floor. If no [target], the entity running the script is used
setmodel <modelpath>
	Sets the monster's current model
setmoveanim <animation name>
	Sets the monster's current movement animation
setidleanim <animation name>
	Sets the monster's current idle animation
setmonsterclip <1|0>
	Enables or Disables adheres to monsterclip (Default: Enabled)
setangle <angle> <value>
	When <angle> == "velocity", <value> is not used.  The model angle is set forward based on the object's velocity.
	When <angle> == "view.<pitch/yaw/roll>", The view angle is set to <value>
	When <angle> == "add_view.<pitch/yaw/roll>", <value> is added to the current view angle
	When <angle> == "view", <value> can be a <ent_target> or a (pitch,yaw,roll) value
		The view angles are set to either face a target or to the specified value
	When <angle> == "view_origin", <value> can be a (x,y,z) value
		The view angles are set to face the location
	When <angle> == "face", <value> can be a <ent_target> or a (pitch,yaw,roll) value
		The model and view angles are set to either face a target or to the specified value
	When <angle> == "face_origin", <value> can be a (x,y,z) value
		The model and view angles are set to face the location
*setorigin <target> <(x,y,z)>
	sets <target> location to the specified value
setvelocity <target> <(x,y,z)>
	Sets the velocity on <target> to the specified value
addvelocity <target> <(x,y,z)>
	Adds a velocity to <targeT>
catchspeech <eventname> <text to catch>
	Allows the monster to listen to players and respond to what they say
repeatdelay <#>
	Sets the function to repeat every <#> seconds
setmovedest <target/(origin)> <stopdistance>
	Causes the monster to move towards <target> or (origin) until <stopdistance> close.
	//careful! setting setmovedest to invalid location formats can cause crash! (must be ID's or $relpos)
	//sometiems setting an origin location inside the stopdistance will cause crash
	//too many setmovedests set at the same time will cause crash
setmovedest none
	Removes the monster's current destination
volume <#>
	Sets the volume at which the monster's sounds are played. Value must be between 0 and 10
playsound <channel #> <volume> [sound1]
	Plays a sound on <channel #> at <volume> (1-10)
playrandomsound <channel #> <volume> [sound1] [sound2] [sound3] [none] etc..
	Plays a random sound between sound1, sound2, sound3... (Any may be ommited, or replaced with 'none').
	# sets the channel the sound plays on.
sound.play3d <sound> <volume> <origin> [attenuation (default: 0.8)]
	Plays a sound at a location
sound.pm_play <sound> <volume> <channel>
	** Only available from physics event:  game_playermove
	Plays a sound for the current player on whom physics is being run
	(Always the local player, if run on client)
	On client: Plays for the local player
	On Server: Sound sent to everyone *except* the current player (his sound plays clientside)
sound.setvolume <channel #> <sound> <volume>
	Changes the volume of an already playing sound
say <sound>[length] [sound][length] [sound][length] etc..

	Example: say chitchat[.5]
	This would play sound/npc/chitchat.wav and open the NPC's mouth for .5 seconds

	Example: say iam[.5] [.5] fine[.7]
	This would play sound/npc/iam.wav and open the NPC's mouth for .5 seconds.  After .5 seconds, the
	NPC would open his mouth again for another .5 seconds (Assuming the wav file contained the words
	"I am", this would simulate the NPC mouthing the words).  Then the sound sound/npc/fine.wav is played
	and the mouth opened for .7 seconds.

callevent [delay] <eventname> [PARAM1] [PARAM2] etc...
	Executes the named event after [delay] seconds (optional)
	Can pass parameters to the event
	[thothie]Note: you cannot use PARAMs if you use a delay, pass with setvard instead
		Also note you cannot pass PARAMs or keywords directly from one scriptevent to another
		for instance:
		callevent do_stuff PARAM1 PARAM2 ent_me
		is invalid, the event will recieve the literal strings ("PARAM1", "ent_me", etc.) instead of a variable
		instead use:
		local OUT_PARAM1 PARAM1
		local OUT_PARAM2 PARAM2
		callevent do_stuff OUT_PARAM1 OUT_PARAM2 $get(ent_me,id)
		this applys whenever you send a param or substution to another script or event
		be it via callevent, callexternal, applyeffect, createnpc, or what not
	[/thothie]
callexternal <target> [delay] <eventname> [PARAM1] [PARAM2] etc...
	Executes the script event <eventname> on <target> after [delay] seconds (server side only)

callexternal all <eventname> [PARAM1] [PARAM2] etc...
	Calls the script event on every existing player, npc, and item in the game.
	//thothie - you can use "players" in place of all, to only call the script event on players

calleventloop <loops> <eventname> [PARAM1] [PARAM2] etc...
	Executes the script event <eventname> <loops> times in a row
	Can pass parameters to the event
	Recieving event gets game.script.iteration to count loops (count starts at 0)
dodamage <target> <range> <dmg> <cth> [type]
	Causes monster to attack <target> up to a distance of <range> for damage <dmg> at 
	a chance to hit of <cth> (in %)
dodamage <target> "direct" <dmg> <cth> <dmg source> [type]
	Causes direct damage to be dealt, without range checking.  <dmg source> is the attacker
dodamage <position> <range> <dmg> <cth> <attn> <flags> [type]
	Does radius damage at <position> with <range>, <cth> and falloff <attn>.
	<attn> == 1.0 Means linear falloff | 0.0 is no damage falloff with ranage.
        Higher <attn> values make damage falloff faster
	Flags:
		"reflective": Can damage yourself
		"normal": Cannot damage self
	[type] = damage type (eg. slash, pierce, blunt, fire, lightning, cold, poison, etc.) - defaults to "generic" //New as of JAN2007

[Thothie]
AOE damage (the third type) seems to have some sort of bug where it needs to be near (or maybe LOS) of the calling script
Using xdodamage may prevent this issue (see ms.stx)

related events (called whithin the attacking monsters script when he does damage to a target): 
{ game_dodamage //1:AttackHit(1/0)  2:EntityHit  3:StartOrigin  4:EndOrigin
{ game_damaged_other //PARAM1=ent hit PARAM2=damage
{ game_struck //PARAM1=incoming damage
{ game_damaged //PARAM1=attacker PARAM2=Damage PARAM3=DamageType
[/Thothie]

tossprojectile <dir> <speed> <dmg> <cof> <projectile scriptname> [start offset]
	Causes monster to launch <projectile scriptname> in <dir> at <speed> for <dmg> starting from
        [start offset] with cone of fire <cof>
	  If <dir> == "view": Use current view angles for direction
	  If <dir> == (origin): Aim directly at (origin)
	  If <dir> == (target): Aim directly at (target)
createnpc <scriptname> <position> [PARAM1] [PARAM2] etc...
	Creates an NPC with <scriptname> at <position>
	The entity's script will have have "game_dynamically_created" called, and at that time
        PARAM1, PARAM2, etc. will be defined with the specified parameters. 
        (Note: These aren't defined yet at "game_spawn")
createitem <itemname> <position> [PARAM1] [PARAM2] etc...
	Creates an item with <itemname> at <position>
	The item's script will have have "game_dynamically_created" called, and at that time
        PARAM1, PARAM2, etc. will be defined with the specified parameters. 
        (Note: These aren't defined yet at "game_spawn")
companion <add/remove> <target companion> <target player>
	Associates the NPC <target companion> with the player.  The NPC will spawn with the player across 
	transitions. The npc's ent_owner is set to the player.
	'remove' - removes the companion from the player.
	//Thothie - Defunct, companions use quest data for better dependability / less character corruption
emitsound <source entity> <origin> <volume> <duration> <type> [danger radius (only for "danger")]
	Creates a sound that monsters can respond to.
	<type> Can be:
		"danger": Monsters should avoid <origin> up to [danger radius] units
		"combat": A combat action has been initiated by  <source entity>
		"move": <source entity> is moving
	<volume> Acts as the radius for the sound.  However this radius will be multiplied
	for npcs that have hearingsensitivity set higher than 1.  They will hear further.
	When an NPC hears a sound (hearingsensitivity taken into account), the event
	game_hearsound is called with:
		ent_lastheard: Source Entity
		PARAM1 - Sound type
		PARAM2 - Sound Origin
		PARAM3 - Danger Radius (If danger sound)
helptip <target> <tipname> <title> <text>
	Displays a help tip on the player's screen, if it hasn't already been displayed.
	Use a bar (|) as a carriage return.
	//Thothie - tipname 'generic' is repeatable
quest set <target> <questname> <questdata>
	Sets the data of a quest for <target> player.  This is saved to the player's file.
quest unset <target> <questname>
	Removes the data of a quest for <target> player.  This is saved to the player's file.
usetrigger <trigger1> [trigger2] [trigger3] etc..
	Fires map triggers named <trigger1>, [trigger2], etc..
saytext <speech>
	Causes the monster to say <speech>
saytextrange "default"/<range>
	Changes the range of <saytext>.  "Default" sets it back to the game default (300)
givehp <amount>
givemp <amount>
	Gives <amount> HP/MP to npc.
storage
  <openaccount> <storagename> <target> <callback>
	Opens a storage account in storage <storagename> for <target>
	Calls "<callback>_exists" if account already exists
	Calls "<callback>_success" if successful
  <checkaccount> <storagename> <target> <callback>
	Checks if <target> owns an account in storage <storagename>
	Calls "<callback>_success" if successful
	Calls "<callback>_failed" if failed
  <trade> <storagename> <target> <feeratio> <displayname> <callback>
	Gives <target> access to storage <storagename>
	Retrieval will cost the item price times <feeratio>
	Calls "<callback>_noaccount" if player has no account
	Calls "<callback>_success" if successful
//Thothie - all "storage" commands are defunct- this method of banking corrupts characters

VAR TYPES:	
const <var> <val>
	Replaces all subsequent instances of <var> with <val>
	const is only executed at loadtime
	A const can only be defined once.  All subsequent definitions are ignored
	[Thothie]
	Use this for any static value
	Only subsequent "const" definitions are ignored - setvar and setvard's are not
	Redefining a const as a setvar/d causes strange and unpredictable behavior
	[/Thohie]
local <var> <val>
	Sets an event variable <var> to now be equal to <val>
	These variables are local to the event, and deleted at the end of the event
	[thothie]
	Use this whenever the var is not needed outside of an event, such as with one-time calculations and adjustments
	These may static in calleventloop's - I've not tested
	[/thothie]
setvar <var> <val>
	Sets a script variable <var> to now be equal to <val>
	setvar is executed at loadtime and runtime
	[thothie]
	This should ONLY be used if the var MUST be defined pre-spawn AND is adjusted later (ie. almost never)
	if the setvar is defined ANYWHERE else in the script, it will pick up the subsequent definition prior to script processing
	since such behavior is difficult to predict, it is best to avoid use of these when possible
	[/thothie]
setvarg <var> <val>
	Sets a global variable <var> to now be equal to <val>
	setvarg is only executed at runtime.
	[thothie]
	These stay after map transitions, but not server crashes - they are not always 100% dependable
	Convention says all setvarg's should start with "G_"
	You can *usually* use these whenever a bunch of different npcs need to share a count
	You cannot use this to pass var from server to client or visa versa (setvarg's are server side)
	[/thothie]
setvard <var> <val>
	Sets a script variable <var> to now be equal to <val>
	setvard is only executed at runtime.
	[thothie]
	Most variables should use this function
	Do not use this to change a setvar or const or strange things will happen
	[/thothie]
//Thothie
- Try not to mix and match var types - especially via #include - I've not yet discovered the paticulars, but it can result in unpredictable behavior
- such as vars not getting set, or even swapping positions with other vars
- suspect something in the code needs to be fixed in this regards
- Note that anything in game_spawn or npc_spawn is pre-loaded
- thus vars used to define things there (such as setanimidle or setmodel) must be setvar or const
- to avoid confusion, define as little as possible there (just the model) and use use npc_post_spawn to define the rest
- script specific:
- ANIM_IDLE should always be a setvar (often loaded in game_spawn, thus is preload))
- ANIM_RUN should always be a setvar (often loaded in game_spawn, thus is preload))
- ANIM_WALK should always be a setvar (often loaded in game_spawn, thus is preload)
- All other vars used by base_monster_xxx should be always setvard instead (ATTACK_RANGE, MOVE_RANGE, etc.)
	
CONDITIONALS:
if ( <var> <compare> <val> ) <command>
else <else_command>

	If the <compare> between <var> and <val> is true, execute <command>
	otherwise, optionally execute <else_command>
	Example: if( MY_VARIABLE > 1 ) callevent my_event

if ( <var> <compare> <val> )
{
   <commands>
   <commands>
}
else
{
   <else_command>
   <else_command>
}

	If the <compare> between <var> and <val> is true, execute <commands>
	otherwise, optionally execute <else_commands>


add <var> <val>
subtract <var> <val>
multiply <var> <val>
divide <var> <val>
mod <var> <val>
	Adds, subtracts, multiplies, divides, or does modulus on <var> by <val>
capvar <var> <minvalue> <maxvalue>
	Caps a variable, numerically, between <minvalue> and <maxvalue>
vectoradd 	<result> <vector1> <vector2>
vectormultiply 	<result> <vector1> <vector2>
	Adds/multiplies <vector1> to <vector2> and places the resulting vector in <result>
vectoradd 	<result> <vector1>
vectormultiply 	<result> <vector1>
	Adds/multiplies <vector1> to <result> and places the resulting vector back into <result>
vectoradd 	<result> <x/y/z> <value>
vectormultiply 	<result> <x/y/z> <value>
	Adds/multiplies <value> to x, y, or z of <result> and places the resulting vector back into <result>
vectormultiply 	<result> <value>
	Multiplies x, y and z of <result> by <value> and places the resulting vector back into <result>
vectorset <sourcevec> <x/y/z> <value>
	Sets x, y, or z of <sourcevec> to <value>

=========== String Parsing ===========

stradd <result> <string1> <string2>
	Concatenates <string1> to <string2> and places the resulting string in <result>
stradd <result> <string>
	Concatenates <string> to <result> and places the resulting string back into <result>
token.add <token string> <new token>
	Adds a token to <token string>.  Basically it adds new text separated by a semi-colon.
token.del <token string> <idx>
	Deletes a token from <token string>

========== Entity Parsing ============

storeentity <type> <target>
	Stores an entity in the npc's local storage.
        <type> can be any valid ent type. Manually storing some types (such as ent_owner, ent_lastheard)
               may interfere what the game expects to be stored in that slot and cause a crash
deleteent <target> ["fade"]
	Deletes the target entity
	If "fade" is specified, the entity will fade away and be deleted after a delay

traceline <startpos> <endpos> <flags> [ignoreent]
	//Thothie - this does not work, use $get_traceline([vec],[vec],[flag]) (see entry)
	Does a traceline and stores the result in variables.
	<flags> can be:
		
		"normal"		Hit entites and world
		"worldonly"		Only hit the world
		"ignoreglass" 		Goes through glass (Can be combined with other flags)
		"simplebox" 		Uses bounding boxes instead of hitboxes (Can be combined with other flags)
		
	The result is stored in the following variables:

	game.trace.hit		[0/1] Whether the trace hit anything.
	game.trace.fraction	[0-1] Ratio of how far the trace traveled before a collision
	game.trace.hitent	Server: id of entity hit.  |  Client: index of entity hit | or "none" if hit wall
	game.trace.endpos	Ending position of trace

[Thothie]This does not work - use $get_traceline(<start>,<end>,[type]) - see ms.stx[/Thothie]

	
#include [scope][casual] <file> ["allowduplicate"]
	Includes another script file at this point in the current script file.
	A script file can only be included once within another script, unless you specify "allowduplicate"
	[scope]  == Optional scope.  Can be [client] or [server]
	[casual] == Doesn't error if file not found

#scope <scope>
	Sets the default event scope [server/client/shared]
	Events found after this line will use this scope if one isn't explicitly set
	//Thothie - this does not always seem to work

precache <model/sprite/sound>
	Precaches the model, sprite or sound
	Executed at loadtime
precachefile <scriptname>
	Precaches the models, sprites and sounds used in the specified script
	Executed at runtime
	//Thothie - This only works inside the { game_precache event

Scripting effects

====================================================

registereffect
	Registers a scripted effect. An effect is meant to temporarily modify an entity's behavior.
	This command accepts parameters from the following variables values:

EFFECT.NAME	- Name
EFFECT.TYPE	- normal: Effect is applied from the applyeffect command
		  player_action: Effect is automatically applied to players on their initial spawn
EFFECT.SCRIPT	- The effect's scriptfile

====================================================

applyeffect <target> <effect name> [Param1] [Param2]...
	Applies an effect to <target>.  The affect is applied server-side

====================================================

clientevent new <target> <scriptname> [param1] [param2] etc..
	Sends an effect to a client.  The effect will always attach to the local player.
	<target> may be:
		"all" - All clients on the server
		"all_in_sight" -  All clients in the potientially visible area
		<target> - A player entity

====================================================

clientevent update <target> <ID> <Eventname> [param1] [param2] etc..
	Updates a client-side effect.  When the effect is created with "new", 
	store game.script.last_sent_id in a variable.  Then use it here for <ID>

clientevent remove <target> <ID>
	Removes a client-side effect
	//Thothie - not always reliable, better to update and use "removescript" command client side

====================================================

effect
	Initiates a server-side special effect:

	beam point <spritename> <width> <startpos> <endpos> <(r,g,b)> <brightness> <noise> <duration>
	beam end <spritename> <width> <startpos> <target> <attachment index> <(r,g,b)> <brightness> <noise> <duration>
	beam ents <spritename> <width> <target> <attachment index> <(r,g,b)> <brightness> <noise> <duration>
	//thoth variant:
	beam ents <spritename> <width> <target1> <attach#> <target2> <attach#> <(r,g,b)> <brightness> <noise> <duration>
	beam vector <spritename> <width> <startpos> <endpos> <(r,g,b)> <brightness> <noise> <duration>

	//beam ents under the thoth variant are stored in ent_lastcreated and G_LAST_BEAM,
	//they can be modified via:
	 effect beam update <beam_id> <property> <value> [option]
	- properties include:
	- color <(r,g,b)>
	- start_target <entity> [attachment_index]
	- end_target <entity> [attachment_index]
	- end_origin <origin> //untested
	- start_origin <origin> //untested
	- vector <start_origin> <end_origin> //may only work with beams created with vector, not sure
	- brightness <value>
	- noise <value>
	- remove (no params) - removes beam on next think


	tempent gibs <modelname/spritename> <position> <size> <velocity> <randomness> <amount> <duration>
	tempent spray <modelname/spritename> <position> <direction> <count> <speed> <noise>
	tempent trail <modelname/spritename> <start> <dest> <count> <life> <scale> <speed> <randomness>

	glow <target> <(r,g,b)> <amount> <duration> <fadeduration>

	screenshake <position> <amplitude> <frequency> <duration> <radius>
	screenfade <target/"all"> <duration> <holdtime> <(r,g,b)> <alpha> <fadin|fadeout|noblend|perm>


====================================================

cleffect

 	Initiates a client-side special effect
 
	tempent sprite <spritename> <position> <creation event> <update event>
	tempent model <modelname> <position> <creation event> <update event>
		Creates a sprite or model on the client
		<creation event> is called when the sprite is created
		<update event> is called each frame that the sprite needs to be updated
		
		
	tempent set_current_prop <property> <value>
		Sets the properties of the current client-side ent being updated
		Can only be used from <callback event> or from "game_update_tempent"

		<property> can be:
			origin		-  Set the origin
			velocity	-  Set the Velovity
			model		-  Set a new sprite/model
			death_delay	-  [tempent] Die after delay (Default is 1 second)
			bouncefactor	-  Amount of bounce from hitting something
			gravity		-  Gravity
			frame		-  Current frame
			frames		-  Number of frames in a sprite or animation (if a model vanishes, set frames to 9999)
			framerate	-  Framerate //for models this is a ratio, for sprites it is FPS
			scale		-  Sprite/model scale
			collide		-  "world" - Collide with World only
					   "all" - Collide with entities and World
					   "die" - Die on collision.  Must be combined with one of the above
					   "none" - Turn off collisions
			update		-  Sets whether the callback event is called
			rendermode	-  The render mode
					   "normal" - For models or non-transparant sprites
					   "color" - Render sprite transparency by color
					   "texture" - Render sprite transparency by texture
					   "glow" - Always display sprite on top
					   "alpha" - Render transparency by renderamt
					   "add" - Render sprite transparency by color & renderamt
			renderfx	-  A render special effect
					   "normal" - No effect
					   "glow" - A shell around the object using rendercolor and renderamt
					   "player" - Object is not a player but should be rendered as one
			renderamt	-  Amount of effect applied by rendermode and/or renderfx
			rendercolor	-  (r,g,b) color
			iuser[1-4]	-  Custom integer data
			fuser[1-4]	-  Custom floating point data
			inwater		-  "1" if bottom of model is underwater | "0" if not
			waterorigin	-  Origin of the water surface, if in water | "none" if not found
			timer <dl> <cb>	-  [tempent] Calls event named <cb> after <dl> delay
			fadeout <dl> 	-  [tempent] Fades out the sprite over <dl> time, or use 'lifetime' in place of <dl>
			cb_hitwater <cb> -  [tempent] Calls event named <cb> if the tempent enters water
			cb_die <cb>	- [tempent] Calls event named <cb> if the tempent dies from collision

			//Thothie - some not mentioned
			angles (PITCH,YAW,ROLL)
			body [index] - model body index (raw)

	frameent <model/sprite> <resourcename> <position> <creation event>
		Creates a sprite or model entity on the client that lasts one frame
		<creation event> is called when the entity is created

	frameent set_current_prop <property> <value>
		Sets the properties of the current client-side one-frame ent being updated
		Can only be used from <callback event> or from "game_update_tempent"

		<property> - Same propties as the tempent set_current_prop command

	setprop <ent index> <property> <value>
		Sets the properties of a client-side ent

		<property> - Same propties as the tempent set_current_prop command

	light <"new"/id> <origin> <radius> <(color)> <death delay> <flags>
		Creates a dynamic light.
		The id of this new light is stored in game.script.last_light_id
		This can be stored and used later to modify the same light.

		<flags> Can include:
			entity		-  Lights entities only
			dark		-  Creates darkness instead of light
	beam_points <startpos> <endpos> <modelname/spritename> <life> <width> <amplitude> <brightness> <speed> <framerate> <(r,g,b)>

		Create a type of beam on the client


====================================================

wearable <slots taken> <position name;position name;position name>
	Specifies a position that an item takes up when worn.  Can take up multiple positions.
	The position names match with names used in "setwearpos" in the player script.

====================================================

wearable 0
	Removes wearable status from the item.

====================================================

registerattack
--------------
	Adds a new attack to an item.
	This command accepts parameters from the following variables:

reg.attack.type		- The type of attack
	"strike-land"	- Standard melee attack.  Do damage to closest target in front of player
	"target"	- Does callbacks on closest target in front, but doesn't auto-aim or do damage
	"charge-throw-projectile" - Does a ranged attack using player origin and straight forward as start points
	"hold-strike"	- Holds the attack while attack button is held.
reg.attack.range	- Range
reg.attack.dmg		- Damage
reg.attack.dmg.range 	- Damage will randomly be +/- this range (ex: dmg=40 & dmgrng=10 == 50-30 dmg)
reg.attack.dmg.type	- Custom attack type.  Corresponds to monster "takedmg" command
reg.attack.aoe.range	- Splash damage range
reg.attack.aoe.falloff	- Splash damage falloff - 0: no falloff | 1: linear falloff | 2+: high falloff
reg.attack.energydrain	- Stamina consumed
reg.attack.mpdrain	- MP drained and required for attack
reg.attack.stat		- Player stat associated with this attack.  Sets prof., balance and power to use this stat
reg.attack.stat.prof	- Stat used for proficiency.  Used to determine if you're high enough skill to use an attack
reg.attack.stat.balance	- Stat used for accuracy
reg.attack.stat.power	- Stat used for power
reg.attack.stat.exp	- Stat that gains exp from a kill using this attack
reg.attack.noise	- World noise made by player (higher = monsters further away can hear you)
reg.attack.callback	- Prefix for callback events (<callback>_start, <callback>_strike, <callback>_toss, <callback>_end)
reg.attack.ofs.startpos - Attack start, Offset (r,f,u) from player origin
reg.attack.ofs.aimang   - Attack direction, Offset (pitch,yaw,roll) from straight forward
reg.attack.priority	- When selecting attacks to perform, this ranks attacks (higer=more priority)
reg.attack.keys		- Indicates the last x keys that must have been pressed in a short time frame
			  + This key must have been pressed
			  - This key must have been released
			  ~ This key must have been pressed, then released

			  attack1 - The key that activates the item (default could be mouse1 or mouse2)
			  forward, back, moveleft, moveright, use, jump - Game keys
reg.attack.dmg.ignore	- Call the callbacks, but don't do damage



	Melee Attacks
	-------------
reg.attack.hitchance	- % chance attack will hit
reg.attack.delay.end	- Duration of entire attack.
reg.attack.delay.strike	- Time until damage is done and <reg.attack.callback>_strike is called
reg.attack.dmg.noautoaim - Uses traceline for detection instead of vicinity/FOV aiming (Auto-aim)

	Ranged Attacks
	--------------
reg.attack.ammodrain	- Ammo used up this attack (defaults to 1 if not specified) (ranged attacks only)
reg.attack.hold_min&max - <min>;<max> - Min seconds until the attack goes off; Max seconds the attack can be usefully charged
reg.attack.projectile	- Name of the ammo.  An itemname substring search is done through player inventory for ammo
reg.attack.COF		- <wide>;<narrow> - Starting COF (uncharged attack); Narrow COF (when charged fully)
reg.attack.delay.end	- Duration of the attack after the attack button is released.

====================================================


registerspell
-------------

	Treats the item like a spell.  
	The item will only last in the player hands for a limited time.  It can't be worn, and if dropped
	it disappears.
	This command accepts parameters from the following variables:

reg.spell.reqskill	- Skill required to learn the spell from a scroll
reg.spell.fizzletime	- Duration the spell will last in the player hands
reg.spell.castsuccess	- % Chance that the spell will immediately fizzle
reg.spell.preparetime	- Delay until the spell is usable


====================================================


learnspell <spell scriptname>
	Causes the player holding this item to attempt to learn <spell scriptname>
        If successful, "game_learnspell_success" will be called
	If not, "game_learnspell_failed" will be called


====================================================
==================================================

Most NPC commands can be used with players as well

==================================================

playanim <once/hold/critical/break> <animname>
	Plays the animation <animname>
	<once> - Plays the animation once. Won't stop a once or hold anim currently playing
	<hold> - Plays the animation once, then holds the last frame until a critical or 
	         break animation is called
	<critical> - Plays the animation once.  Breaks out of any currently playing anim
	<break> - Breaks out of any currently playing anim. You should follow this with a line
	          that sets a new animation to play
	
giveitem <itemname> [amount]
	Gives the item itemname to monster at body part loc (location may be ommited)
	If the item is groupable (arrows) then [amount] specifies the amount in the bundle
removeitem itemname
	Removes the item itemname from the monster
recvoffer <action>
	Responds to a trade from a player. Action may be "accept" or "reject" //Thothie defunct
takedmg <type> <amount>
	Damage multiplier for incoming damage to a monster.  If type is "all", it affects all incoming damage.
	Otherwise <type> corresponds to the ATTACK_DAMAGE_TYPE variable of an attack.
	Multiple takedmg amounts can be set for varying types

===============================

Stores (Shops, Chest inventory)

===============================

npcstore.create <storename>
(Old Name: createstore)

	Creates a global store (Either a shop or chest inventory)

npcstore.additem <storename> <item scriptname> [quantity] [costratio] [sellratio] [bundleamt]
(Old Name: addstoreitem)

	Adds an item either to a store.

	[costratio] - % of cost, based on item value
	[sellratio] - Ratio of sell worth, based on cost
	[bundleamt] - For groupable items (arrows), specifies the amount

npsstore.remove <storename> item <item scriptname>
	Removes an item from a store

npsstore.remove <storename> allitems
	Removes all items from a store

npsstore.remove
	Removes a store

npsstore.offer <storename> <target player> [flags] [callback]
(Old Name: offerstore)

	Opens the store VGUI for a player
	Note: Any npc can offer any store, allowing:
		- Two NPCs to sell from the same store.  In a 32 player game some stores might have higher demand
		  than one NPC can handle.
		- An NPC to have "hidden" stores, accessed by completing a quest or saying a secret message

	[flags] can contain:
		buy - Allows player to buy items from the store
		sell - Allows player to sell items to the store
		inv - Allows player to take any item for free (In chests, for example)

	[callback] - Prefix for events that get called during the transaction
		[callback]_success - Called when the player successfully gains access to the store
		[callback]_fail - Called if the store doesn't exist
		[callback]_busy - Called if the NPC is already in a transaction with another player
		[callback]_done - Called when the player has closed the store dialog

===============================

Interaction Menus

===============================

Event: get_menu_options //Thothie - this wrong, it is: game_menu_getoptions
PARAM1: player entity

This is called when a player chooses to access an NPC or player menu, The NPC/player script
should fill the menu using menuitem.register.


menuitem.register

	Enables a menu item to be displayed when a player uses this NPC
	This can only be used during the call to get_menu_options (see above)

	"reg.mitem.id"		- A custom ID, used for later removal
	"reg.mitem.title"	- Title of the item
	"reg.mitem.cb_failed"	- Event that is called if the action fails
	"reg.mitem.type"	- Type of menu item

		"callback"	- Game calls event x.callback if this option is chosen (PARAM1 = player entity and PARAM2 = x.data)
				//Thothie: Up until my changes to the ms.dll (msmonsterserver.cpp) this didn't seem to be returning PARAM2
		"say"		- If player chooses this item, he will say x.data in NPC chat
		"payment"	- If player chooses this item, he will pay the NPC.  x.data may be set to
		   "gold:[amt]"      - Payment will cost this much gold
		   "[itemname]:[amt] - Payment will cost [amt] items named [itemname]
				x.data can consist of multiple payments, separated by a semicolon
				Ex: "local reg.mitem.data gold:10;skins_ratpelt:3;item_torch"
				(This payment requires 10 gold, 3 rat pelts, and one torch)
				If payment succeeds, x.callback is called.   If player is can't pay, x.cb_failed is called.
		"payment_silent" - Same as payment, except if you don't have all the items/gold,
				   the game won't tell you what you're missing.
				   [Thothie - This crashes if the player gives the NPC the wrong item! Don't use it, rather use $item_exists() to verify the item exists before displaying the menu option]
		"disabled"	- Show the item as disabled 
				//Thothie - beware sometimes disabled
				//menu items can still be selected via keystrokes
		"itemdesc"	- Displays active item description
		"forgive"	- Uses "forgive" command

	"reg.mitem.data"	- Custom data, used differently depending on type
	"reg.mitem.callback"	- Event that is called if this option is chosen
	"reg.mitem.cb_failed"	- Event that is called if the action fails

menuitem.remove <ID>

	Removes an item from an NPC's menu.  Use the custom ID that was set when the 
	item was registered.

menu.open <target player>

	Opens the interact menu with the target player

menu.autoopen

	Opens the interact menu with any player that presses "+use" on the NPC
Master Sword uses a scripting system to control most interations.

There's a few different types of scripts, specialized for a purpose in the game.


NPCs
====================================================

NPC scripts are very generic.  It doesn't neccesarily have to be an npc.  These can
be thought of more as 'entity' scripts.  But for now, they're named NPC scripts.
An NPC script can create a monster that attacks, or it could be a rock that disappears
when destroyed, opening a secret passage.

- NPC scripts are re-loaded from file each time one is spawned
- When spawned..

  > Game calls: game_spawn

- When killed by player

  > Game calls: game_death
  > If the script doesn't use setalive to revive the NPC, then after this event
    repeatdelay events won't be called.  This effectively disables AI while the dead
    body sits.

------------------

Items
====================================================

Items scripts are treated differently than NPC scripts.

- Item scripts are loaded...
  > Once at startup, on client 
  > Each map load, on server
  > From items.txt (so the game knows what all the item scripts are at startup)
  > Preprocessing is done once for all items at load time, and never again.
    (Consts are replaced with their const value and the const commands deleted)
    (The script text format is converted to binary)
    (Whenever a new item is spawned, a copy of this 'pre-processed' version is used instead of reloading)

- When an item comes into existence

  > Game calls: game_spawn
  > This happens at various times.  Sometimes the item is spawned quickly just to grab some HUD
    info about it and then it's immediately deleted (especially during VGUI).  So you 
    can't assume much during an item spawn.  Set appropriate item values, but don't do any actions.

- When an item is picked up...

  > Game calls: game_pickup
  > Called anytime the player receives an item. The item may be placed into player hands, or
    straight into a pack.

- When an item becomes available for use...

  > Game calls: game_deploy
  > The item is now in player hands, ready to be used.  This is generally when the item is picked up 
    from the ground or removed from pack.

- When an item is dropped

  > Game calls: game_drop   (Only called when the player presses "drop")
  > Game calls: game_remove (This is called anytime the item is removed from player, even forcefully)

------------------

Effects
====================================================

- Effect scripts

Effect scripts are meant to modify other scripts.
For example, you might want the player to have a bash ability that stuns any NPC it hits.
The bash would be made into a an 'effect' script.  This script can be attached to any NPC 
and modify or override values of the NPCs.  In this case it would attach to the target of 
the bash attack, then override the framerate and movespeed, causing the NPC to attack and 
move slower.  Effect scripts can also be attached to players.


- Special Effect scripts

Any script can be run on either the server or client side.  The most common reason to run
a script client-side is for visual special effects (with no stress on the server).  You could 
have an NPC cast a spell serverside, then handle the spell effects client-side.  You can either
do this in the same NPC script or split the client and server tasks between scripts for 
organization.

However when a script is sent to the client, it ALWAYS attaches to the local player.  This is
fine for effects that change the player's movement or view, but sometimes the script needs to
affect entities other than the local player.

For example, if you want a fire sprite to continuously track an NPC (client-side), then you'd
transmit the NPC's index from the server script to the client script (SFX script).  The SFX
script can find the corresponding entity on the client, and create a fire sprite at the
entity's location each frame.

setwearpos <position name> <max slots>
	Adds or modifies a position for wearable items on a player. ("head","chest","waist", etc.)
setwearpos clearall
	Removes all the available positions for a player to wear items.
drainstamina <target player> <amount>
	Drains or Gives stamina
playermessage <target> <message>
	Sends a message to player's HUD.  Message words may be variables
	//thothie: you can also use rplayermessage, glayermessage, bplayermessageb, yplayermessagey, and //dplayermessage for red, green, blue, yellow, and gray hud messages, respectively (MAR2007)
consolemsg <target> <message>
	Sends a message to player's console.  Message words may be variables
infomsg <target/"all"> <title> <message>
	Sends a message to player's Info Window (top left fading window). //Thothie - vars must be pre-parsed (see player/player_main event game_learnskill for example)
respawn <target/"all">
	Moves the player to his respawn point.
setgaitspeed
	Sets the movement speed at which the legs (gait) anim fps should be played at 100% (normal speed)
	If the current speed varies from this movement speed, then the gait anim is played at a ratio.


CONSTANTS:
	setvarg CHAN_AUTO	0
	setvarg CHAN_WEAPON	1
	setvarg CHAN_VOICE	2
	setvarg CHAN_ITEM	3
	setvarg CHAN_BODY	4

//Thothie's unlisted (from code)
setturnrate - untested (you can use setvard CANT_TURN 1 to stop a mon from facing opponents)
setanim.frame - set anim frame #
setanim.framerate - set anim frame rate
stopmoving - untested
roamdelay - untested
look - unknown function, but is in code and scripts
setstatus - is player in water?
cancelattack - doesn't work?


//============= CODE SNIPPETS
//NPC Commands
scriptcmdname_t( "say" ) );
scriptcmdname_t( "hp" ) );
scriptcmdname_t( "width" ) );
scriptcmdname_t( "height" ) );
scriptcmdname_t( "stepsize" ) );
scriptcmdname_t( "race" ) );
scriptcmdname_t( "gold" ) );
scriptcmdname_t( "fov" ) );
scriptcmdname_t( "hearingsensitivity" ) );
scriptcmdname_t( "float" ) );
scriptcmdname_t( "fly" ) );
scriptcmdname_t( "setanim.movespeed" ) );
scriptcmdname_t( "movespeed" ) );
scriptcmdname_t( "maxslope" ) );
scriptcmdname_t( "invincible" ) );
scriptcmdname_t( "gaitframerate" ) );
scriptcmdname_t( "roam" ) );
scriptcmdname_t( "roamdelay" ) );
scriptcmdname_t( "skilllevel" ) );
scriptcmdname_t( "giveitem" ) );
scriptcmdname_t( "removeitem" ) );
scriptcmdname_t( "offer" )
scriptcmdname_t( "catchspeech" )
scriptcmdname_t( "saytext" )
scriptcmdname_t( "saytextrange" )
scriptcmdname_t( "setstat" )
//scriptcmdname_t( "setskin" ) - be nice to have this one back
scriptcmdname_t( "setidleanim" )
scriptcmdname_t( "setmoveanim" )
//scriptcmdname_t( "setactionanim" )
scriptcmdname_t( "setmovedest" )
scriptcmdname_t( "createstore" )
scriptcmdname_t( "addstoreitem" )
scriptcmdname_t( "offerstore" )
scriptcmdname_t( "npcstore.create" )
scriptcmdname_t( "npcstore.additem" )
scriptcmdname_t( "npcstore.offer" )
scriptcmdname_t( "npcstore.remove" )
scriptcmdname_t( "recvoffer" )
scriptcmdname_t( "dodamage" )
scriptcmdname_t( "tossprojectile" )
scriptcmdname_t( "cancelattack" )
scriptcmdname_t( "look" )
scriptcmdname_t( "takedmg" )
scriptcmdname_t( "storage" )
scriptcmdname_t( "blood" )
scriptcmdname_t( "stopmoving" )
scriptcmdname_t( "setanimtorso" )
scriptcmdname_t( "setanimlegs" )
scriptcmdname_t( "setturnrate" )
scriptcmdname_t( "setstatus" )
scriptcmdname_t( "setanim.frame" )
scriptcmdname_t( "setanim.framerate" )
scriptcmdname_t( "setmonsterclip" )
scriptcmdname_t( "menuitem.register" )
scriptcmdname_t( "menuitem.remove" )
scriptcmdname_t( "menu.open" )
scriptcmdname_t( "menu.autoopen" )

//setprop <target> movetype entries discovered by code diving
// const.movetype.toss works but odd effects
// .walk crashes
// .push slides through wall based on relvel (maybe useful for spells)
// .bounce, well does what you'd expect (LOL) (may also be useful)
// .none does what you'd expect
// .pushstep acts similar to .toss
// .follow similar to toss
// .step standard movement
// .noclip pass through most objects, but not solids

//======== ADDED BY THOTHIE
$get_map_valid(<target>)
- <target> must be player 
- returns 1 if player was at proper transition during map change

$get_lastmap(<target>) 
- <target> must be player 
- returns name of destmap from last trans (buggy sometimes, returns odd but consistant strings)

$get_jointype(<target>)
- <target> must be player 
- retrieves map join type: "Travel" | "Start Map" | "GM" | "Previously Visited" | "Not Allowed"


//newly discovered things

//This is npcmove format, used in magic_hand_summon_base

//**************************** NPCMOVE *****************************
command:
npcmove <target> <(destination)>

first register:
reg.npcmove.endpos <(X,y,z)> - guessing startpos is $relpos(0,0,0)
reg.npcmove.testonly (0|1) - don't actually do the move, just report result

returns:
game.ret.npcmove.success - 1|0
game.ret.npcmove.dist - distance moved (or would have moved)
game.ret.npcmove.hitstep - 1|0 (I guess weather or not NPC had to jump a step)

//**************************** SETENV *****************************

used by several weather scripts, affects all clients
setenv <prop> <value>
eg:
setenv sky.texture <string>
setenv lightgamma (<float-red>,<float-green>,<float-blue>)
setenv maxviewdist <distance>
setenv fog.enabled <1|0>
setenv fog.color (<float-red>,<float-green>,<float-blue>)
setenv fog.density <value>
setenv fog.start <distance from client>
setenv fog.end <distance from client?>
setenv fog.type <exp|exp2|linear> - only linear seems to be of any use
setenv screen.tint (<float-red>,<float-green>,<float-blue>)?(maybe a fourth alpha value, not sure)
by <float-red> etc, I mean these colors work on a float ramp, instead of color ramp (I guess 32-bit color)
meaning, (1.0,0.0,0.0) = pure red (1.0,0.0,1.0) = purple, (0.5,0.5,0.5) = grey, etc. etc.

//**************************** removescript *****************************

removescript is absolutely CRUICIAL to removing client side scripts
if no removescript is called when the client side effects end, the effect will effectively never go away

//**************************** $item_exists *****************************

$item_exists(<target>,<item_name>,[flags])
Rather critical for item menu interaction
Returns if player has an item in his inventory
* not sure if this works outside the scope of NPCs searching players
Valid flags are:
"nohands" - do not search hands
"noworn" - do not search worn items
"notinpack" - not in pack
"partialname" - search by partial item_name (eg. "armor_") //not sure if this works
"remove" - removes the item if found (new hack in the hard code by Thothie@JAN2007a)
"name" - returns the proper name of the item, if found (for storage system by Thothie@JAN2007a)

//**************************** $get_traceline(<start_origin>,<end_origin>,<flags>) *****************************

Added FEB2007
Traces a vector from start_origin to end_origin, returns strike result:

Flags are:
ent - Returns ent struck (returns vector end, if none struck)
worldonly - Returns end position or where traceline struck world object (wall, etc)


//************************** $get_insphere(<search_type>,<radius>,[source_origin]) ***************************
Added MAY2007a
<search_type> can be:
 player - returns nearest player id
 monster - returns nearest monster id
 any - returns nearest living MSC ent (either player or monster)
 <id> - returns 1 if sought id found

 if [source_origin] is omited, scan centers on calling script ent

getents <search_type> <radius>

//************************** getents <search_type> <radius> [source_origin] ***************************
Added MAY2007a
<search_type> can be:
 player - returns nearest player id
 monster - returns nearest monster id
 any - returns nearest living MSC ent (either player or monster)

Similar to $get_insphere but stores ents into an "array", as follows:
GET_COUNT - # of ents captured in scan
GET_COUNT1, GET_COUNT2, GET_COUNT3... GET_COUNT9 - stores first 9 found ID's

//useful related code sample (stun all enemies within 256 units)

{ stun_sphere
	getents any 256
	setvard LOOP_COUNT 0
	calleventloop GET_COUNT stun_insphere
}

{ stun_insphere
	add LOOP_COUNT 1
	if ( LOOP_COUNT == 1 ) local CHECK_ENT GET_ENT1
	if ( LOOP_COUNT == 2 ) local CHECK_ENT GET_ENT2
	if ( LOOP_COUNT == 3 ) local CHECK_ENT GET_ENT3
	if ( LOOP_COUNT == 4 ) local CHECK_ENT GET_ENT4
	if ( LOOP_COUNT == 5 ) local CHECK_ENT GET_ENT5
	if ( LOOP_COUNT == 6 ) local CHECK_ENT GET_ENT6
	if ( LOOP_COUNT == 7 ) local CHECK_ENT GET_ENT7
	if ( LOOP_COUNT == 8 ) local CHECK_ENT GET_ENT8
	if ( LOOP_COUNT == 9 ) local CHECK_ENT GET_ENT9

	if $get(CHECK_ENT,relationship,MY_OWNER) equals enemy
	
	if ( OWNER_ISPLAYER )
	{
		if game.pvp == 0
		if $get(CHECK_ENT,isplayer)
		local EXIT_SUB 1
	}
	if !EXIT_SUB

	applyeffect CHECK_ENT effects/effect_stun 5.0 0 1
}

//************************** GETPLAYERS <var> ***************************
getplayers <var>
JUN2007A
Stores all player targets, globally, in a tokenized string.
These can be pulled into indivudal vars via $get_token like so:

{ some_event
	getplayers TEST_PLAYERS
	setvard LOOP_COUNT 0
	calleventloop $get_token_amt(TEST_PLAYERS) list_players
}

{ list_players
	local CUR_PLAYER $get_token(TEST_PLAYERS,LOOP_COUNT)
	consolemsg ent_currentplayer Player # LOOP_COUNT - $get(CUR_PLAYER,name) alv $get(CUR_PLAYER,alive)
	add LOOP_COUNT 1
}

Each player token is about 12 characters long, so on a server with more than 20 players,
any script that uses this may "drop" players and thus be bugged. 
This due to the fact that strings are limited to 255 characters.
Shouldn't be an issue, as  generally servers run 8 players or less. 
(20 players would just dominate our monsters in addition to being unmanagable)


//************************** STRING PARSERS ***************************
$lcase(<string>) Returns lower case of <string> for more dependable comparison (APR2007a)
$left(<string>,<num>) Returns first <num> characters of <string> (MAY2007a)
(other string handler enhancements will be placed here)

//************************** playmp3 ***************************
(MAY2007a)
playmp3 <target|all> <minutes> <file> [range]
plays an mp3 or midi file on client(s), minutes maybe decimal
[range] plays music only on those within range of calling script
will be ignored by clients standing inside msarea_music brushes



[thothie]
//effects reference (incomplete)
applyeffect PARAM2 effects/blind		;<duration>
applyeffect PARAM2 effects/effect_burn		;<duration> <inflictor_id> [damage] [glow_shell-1|0] [light-1|0]
applyeffect PARAM2 effects/effect_drunk		;<duration>
applyeffect PARAM2 effects/effect_flames	;<duration> - fx only
applyeffect PARAM2 effects/effect_freeze	;<duration> <???> - secondary djinn effect
applyeffect PARAM2 effects/effect_frost		;<duration> [inflictor_id] <dmg> [glow-0|1] - (djinn_ice version)
applyeffect PARAM2 effects/effect_frostbite	;<duration> [inflictor_id]
applyeffect PARAM2 effects/effect_frostbite_dmg	;<duration> <inflictor_id> <dmg>
applyeffect PARAM2 effects/effect_iceshield	;<duration> <dmg_multiplier>
applyeffect PARAM2 effects/effect_light		;<duration> <radius> <color>
applyeffect PARAM2 effects/effect_poison	;<duration> <inflictor_id> <dmg> <disease/poison-0|1>
applyeffect PARAM2 effects/effect_push		;<duration> <(vel)> [screenshake-0|1]
applyeffect PARAM2 effects/effect_rejuv2	;<heal_amt> [divinaion_skill] [healer_id]
applyeffect PARAM2 effects/effect_shock_dmg	;<duration> <inflictor_id> [dmg]
applyeffect PARAM2 effects/effect_stun		;<duration> [slow_push-0|1] [cant_attack-0|1]
applyeffect PARAM2 effects/freeze_solid		;<duration> <inflictor_id> [damage]
applyeffect PARAM2 effects/generic_damage	;<dmg> <inflictor_id> [noise-0|1] [dmg_type]
applyeffect PARAM2 effects/greater_poison	;<duration> <inflictor_id> <dmg>
applyeffect PARAM2 effects/heavy_stun		;<duration> [inflictor_id]
applyeffect PARAM2 effects/protection		;<duration> <dmg_multiplier>
applyeffect PARAM2 effects/sfx_motionblur	;<ent_idx> [duration]
applyeffect PARAM2 effects/speed		;<duration> <speed%> <framerate> - not sure if this works 100%
applyeffect PARAM2 effects/torch_flame		;<duration> - less sticky than items/base_lighted
clientevent new all effects/make_light		;<(pos)> <rad> <color> <duration>

//summon reference (incomplete)
monsters/summon/stun_burst (pos) <owner> <range> [throw-0|1] [damage]
monsters/summon/flame_burst (pos) <owner> [damage] [one_shot-0|1]
monsters/summon/keledros_fire_wall (pos) <owner> <angles> <dmg> [duration] //duration is currently locked at 10 secs
monsters/summon/summon_blizzard (pos) <owner> <angles> <dmg> <duration>
monsters/summon/npc_volcano (pos) <owner> <damage> <duration>
monsters/summon/ice_blast (pos) <owner> <freeze_duration> <(sphere_destination)>
monsters/summon/flame_skull (pos) <owner> <dmg> <radius>
[/thothie]

