/* 
	builtins.r

	Master builtins list

	Copyright (C) 2002 Jeff Teunissen <deek@d2dc.net>

	This program is free software; you can redistribute it and/or modify it
	under the terms of the GNU Lesser General Public License as published by
	the Free Software Foundation; either version 2.1 of the License, or (at
	your option) any later version.

	This program is distributed in the hope that it will be useful,	but
	WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

	See the GNU Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public
	License along with this program; if not, write to:

		Free Software Foundation, Inc.
		59 Temple Place - Suite 330
		Boston, MA  02111-1307, USA

	$Id$
*/

#include "config.rh"

/****************************************************************************
 *								MATH FUNCTIONS								*
 ****************************************************************************/

/*
	ceil

	Returns v, rounded up to the next higher integer
*/
@extern float (float v) ceil;

/*
	fabs

	Returns the absolute value of v
*/
@extern float (float v) fabs;

/*
	floor

	Returns v, rounded down to the next lower integer
*/
@extern float (float v) floor;

/*
	makevectors

	Sets v_forward, v_up, v_right global vectors from the vector ang
*/
@extern void (vector ang) makevectors;

/*
	normalize

	Transform vector v into a unit vector (a vector with a length of 1)
*/
@extern vector (vector v) normalize;

/*
	random

	Generate a random number such that 0 <= num <= 1
*/
@extern float () random;

/*
	rint

	Returns v, rounded to the closest integer. x.5 rounds up.
*/
@extern float (float v) rint;

/*
	vectoangles

	Returns a vector 'pitch yaw 0' corresponding to vector v.
*/
@extern vector (vector v) vectoangles;

/*
	vectoyaw

	Returns the yaw angle ("bearing"), in degrees, associated with vector v.
*/
@extern float (vector v) vectoyaw;
/*
	vlen

	Return the length of vector v
*/
@extern float (vector v) vlen;

/****************************************************************************
 *								ENTITY FUNCTIONS							*
 ****************************************************************************/

/*
	makestatic

	Make entity e static (part of the world).
	Static entities do not interact with the game.
*/
@extern void (entity e) makestatic;

/*
	remove

	Remove entity e.
*/
@extern void (entity e) remove;

/*
	setmodel

	Sets the model name for entity e to string m.
	Set the entity's move type and solid type before calling.
*/
@extern void (entity e, string m) setmodel;

/*
	setorigin

	Sets origin for entity e to vector o.
*/
@extern void (entity e, vector o) setorigin;

/*
	setsize

	Set the size of entity e to a cube with the bounds ( x1 y1 z1 ) ( x2 y2 z2 )
*/
@extern void (entity e, vector min, vector max) setsize;

/*
	spawn

	Creates a new entity and returns it.
*/
@extern entity () spawn;

// -------------------------------------------------------------------------

/****************************************************************************
 *							DEBUGGING FUNCTIONS								*
 ****************************************************************************/

/*
	abort (in QuakeC, this was break)

	Tell the engine to abort (stop) code processing.
*/
@extern void () abort;

/*
	coredump

	Tell the engine to print all edicts (entities)
*/
@extern void () coredump;

/*
	traceon

	Enable instruction trace in the interpreter
*/
@extern void () traceon;

/*
	traceoff

	Disable instruction trace in the interpreter
*/
@extern void () traceoff;

/*
	eprint

	Print all information on an entity to the server console
*/
@extern void (entity e) eprint;

/****************************************************************************
 *							CLIENT/SERVER FUNCTIONS							*
 ****************************************************************************/

/*
	cvar

	Get the value of one of the server's configuration variables.
	Doesn't really supply anything useful for string or vector Cvars.
*/
@extern float (string s) cvar;

/*
	cvar_set

	Set the value of one of the server's configuration variables.
*/
@extern void (string var, string val) cvar_set;

/*
	infokey

	Get an info key for an entity. Using an entity of zero (world) reads the
	serverinfo/localinfo.
*/
#ifdef QUAKEWORLD
@extern string (entity e, string key) infokey;

/*
	setinfokey (QuakeForge-only)

	Set an info key for an entity. Using an entity of zero (world) sets a key
	in the server's localinfo. Does nothing if the entity is not a player.
*/
# ifndef __VERSION6__
@extern void (entity e, string key, string value) setinfokey;
# endif
#endif

#if 0
	PR_AddBuiltin (pr, "vectoyaw", PF_vectoyaw, 13);	// float (vector v) vectoyaw
	PR_AddBuiltin (pr, "find", PF_Find, 18);	// entity (entity start, .(...) fld, ... match) find
	PR_AddBuiltin (pr, "dprint", PF_dprint, 25);  // void (string s) dprint
#endif
