These are the files that make up the csqc module for the inventory.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1757 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2006-01-02 02:52:56 +00:00
parent 23ae28f5e8
commit 2f4063ce2e
8 changed files with 639 additions and 0 deletions

View file

@ -0,0 +1,9 @@
../csprogs.dat
csqc/system.qc
csqc/stdbuiltins.qc
csqc/builtins.qc
csqc/stdconstants.qc
csqc/constants.qc
csqc/invent.qc
csqc/main.qc

View file

@ -0,0 +1,75 @@
//csqc only builtins.
void() clearscene = #300; // (EXT_CSQC)
void(float mask) addentities = #301; // (EXT_CSQC)
void(entity ent) addentity = #302; // (EXT_CSQC)
float(float property, ...) setviewprop = #303; // (EXT_CSQC)
void() renderscene = #304; // (EXT_CSQC)
void(vector org, float radius, vector lightcolours) adddynamiclight = #305; // (EXT_CSQC)
//void(string texturename) R_BeginPolygon = #306; // (EXT_CSQC_???)
//void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex = #307; // (EXT_CSQC_???)
//void() R_EndPolygon = #308; // (EXT_CSQC_???)
//maths stuff that uses the current view settings.
vector (vector v) unproject = #310; // (EXT_CSQC)
vector (vector v) project = #311; // (EXT_CSQC)
//2d (immediate) operations
void(float width, vector pos1, vector pos2) drawline = #315; // (EXT_CSQC)
float(string name) iscachedpic = #316; // (EXT_CSQC)
string(string name, float trywad) precache_pic = #317; // (EXT_CSQC)
vector(string picname) draw_getimagesize = #318; // (EXT_CSQC)
void(string name) freepic = #319; // (EXT_CSQC)
float(vector position, float character, vector scale, vector rgb, float alpha, ...) drawcharacter = #320; // (EXT_CSQC, [EXT_CSQC_???])
float(vector position, string text, vector scale, vector rgb, float alpha, ...) drawstring = #321; // (EXT_CSQC, [EXT_CSQC_???])
float(vector position, string pic, vector size, vector rgb, float alpha, ...) drawpic = #322; // (EXT_CSQC, [EXT_CSQC_???])
float(vector position, vector size, vector rgb, float alpha, ...) drawfill = #323; // (EXT_CSQC, [EXT_CSQC_???])
void(float x, float y, float width, float height) drawsetcliparea = #324; // (EXT_CSQC_???)
void(void) drawresetcliparea = #325; // (EXT_CSQC_???)
float(float stnum) getstatf = #330; // (EXT_CSQC)
float(float stnum) getstati = #331; // (EXT_CSQC)
float(float stnum, float first, float count) getstatbits = #331; // (EXT_CSQC)
string(float firststnum) getstats = #332; // (EXT_CSQC)
void(entity e, float mdlindex) setmodelindex = #333; // (EXT_CSQC)
string(float mdlindex) modelnameforindex = #334; // (EXT_CSQC)
float(string effectname) particleeffectforname = #335; // (EXT_CSQC)
void(float effectnum, entity ent, vector start, vector end) trailparticles = #336; // (EXT_CSQC),
void(float effectnum, vector origin, ...) pointparticles = #337; // (EXT_CSQC)
void(string s, ...) cprint = #338; // (EXT_CSQC)
void(string s, ...) print = #339; // (EXT_CSQC)
string(float keynum) keynumtostring = #340; // (EXT_CSQC)
float(string keyname) stringtokeynum = #341; // (EXT_CSQC)
string(float keynum) getkeybind = #342; // (EXT_CSQC)
float(float framenum) getinputstate = #345; // (EXT_CSQC)
void(float sens) setsensitivityscaler = #346; // (EXT_CSQC)
void() runstandardplayerphysics = #347; // (EXT_CSQC)
string(float playernum, string keyname) getplayerkeyvalue = #348; // (EXT_CSQC)
float() isdemo = #349; // (EXT_CSQC)
float() isserver = #350; // (EXT_CSQC)
void(vector origin, vector forward, vector right, vector up) SetListener = #351; // (EXT_CSQC)
void(string cmdname) registercommand = #352; // (EXT_CSQC)
float(entity ent) wasfreed = #353; // (EXT_CSQC) (should be availabe on server too)
string(string keyname) getserverinfo = #354; // (EXT_CSQC)
//note that 'ReadEntity' is pretty hard to implement reliably. Modders should use a combination of ReadShort, and findfloat, and remember that it might not be known clientside (pvs culled or other reason)
float() readbyte = #360; // (EXT_CSQC)
float() readchar = #361; // (EXT_CSQC)
float() readshort = #362; // (EXT_CSQC)
float() readlong = #363; // (EXT_CSQC)
float() readcoord = #364; // (EXT_CSQC)
float() readangle = #365; // (EXT_CSQC)
string() readstring = #366; // (EXT_CSQC)
string() readfloat = #367; // (EXT_CSQC)

View file

@ -0,0 +1,107 @@
//FIXME: most of this should be in common/constants.qc
//
// constants
//
// point content values
float CONTENT_EMPTY = -1;
float CONTENT_SOLID = -2;
float CONTENT_WATER = -3;
float CONTENT_SLIME = -4;
float CONTENT_LAVA = -5;
float CONTENT_SKY = -6;
// sound channels
// channel 0 never willingly overrides
// other channels (1-7) allways override a playing sound on that channel
float CHAN_AUTO = 0;
float CHAN_WEAPON = 1;
float CHAN_VOICE = 2;
float CHAN_ITEM = 3;
float CHAN_BODY = 4;
float ATTN_NONE = 0;
float ATTN_NORM = 1;
float ATTN_IDLE = 2;
float ATTN_STATIC = 3;
// entity effects
float EF_BRIGHTFIELD = 1;
float EF_MUZZLEFLASH = 2;
float EF_BRIGHTLIGHT = 4;
float EF_DIMLIGHT = 8;
float MASK_ENGINE = 1; //this is special. Any entities known by the engine but not the csqc will be added.
//you can add any other masks below, remember, use bits.
float MASK_NORMAL = 2;
float INPUT_KEYDOWN = 0;
float INPUT_KEYUP = 1;
float INPUT_MOUSEMOVE = 2;
//stats 0-31 are filled by the engine.
//they are for the 'fixed function' stuff, that works without requiring csqc.
//these stats need to be standardized amoung engines, so you're not allowed to mod them, so nur.
#define STAT_HEALTH 0
#define STAT_WEAPONMODEL 2 //weapon model index, as evalutated by server code.
#define STAT_AMMO 3
#define STAT_ARMOR 4
#define STAT_WEAPONFRAME 5
#define STAT_SHELLS 6
#define STAT_NAILS 7
#define STAT_ROCKETS 8
#define STAT_CELLS 9
#define STAT_ACTIVEWEAPON 10 //the one shown on the hud
#define STAT_ITEMS 15
//stats 32 onwards are filled by the csqc.
#define FL_ONGROUND 1
enum
{
VF_MIN = 1,
VF_MIN_X = 2,
VF_MIN_Y = 3,
VF_SIZE = 4,
VF_SIZE_X = 5,
VF_SIZE_Y = 6,
VF_VIEWPORT = 7,
VF_FOV = 8,
VF_FOVX = 9,
VF_FOVY = 10,
VF_ORIGIN = 11,
VF_ORIGIN_X = 12,
VF_ORIGIN_Y = 13,
VF_ORIGIN_Z = 14,
VF_ANGLES = 15,
VF_ANGLES_X = 16,
VF_ANGLES_Y = 17,
VF_ANGLES_Z = 18,
VF_DRAWWORLD = 19,
VF_DRAWENGINESBAR = 20,
VF_DRAWCROSSHAIR = 21,
VF_PERSPECTIVE = 200
};
enumflags {
RF_VIEWMODEL,
RF_EXTERNALMODEL,
RF_DEPTHHACK,
RF_ADDATIVE,
RF_USEAXIS
};

View file

@ -0,0 +1,18 @@
void bprint(float plev, string st, string s2){}
float PRINT_MEDIUM = 1;
#include "/../inventory.qc"
void() Invent_Draw =
{
local float i;
local float it;
local string itname;
for (i = 0; i < 16; i++)
{
it = getstati(32+i);
itname = GetItemName(ToIID(it));
drawstring('0 32 0' + (i * '0 8 0'), strcat(itname, " (", ftos(ToStatus(it)), ")"), '8 8 0', '1 1 1', 1);
}
};

View file

@ -0,0 +1,77 @@
entity viewentity;
float viewmodelindex;
.float lerptime;
void() DoThatViewModelThing =
{
float newframe, newmodel;
newframe = getstati(STAT_WEAPONFRAME);
newmodel = getstati(STAT_WEAPONMODEL);
if (newmodel != viewmodelindex)
{ //changed entirly.
viewmodelindex = newmodel;
self.frame2 = self.frame = newframe;
self.lerptime = time;
}
else if (newframe != self.frame)
{
self.frame2 = self.frame;
self.frame = newframe;
self.lerptime = time;
}
self.lerpfrac = 1-(time-self.lerptime)*10;
if (self.lerpfrac < 0) self.lerpfrac = 0;
self.modelindex = viewmodelindex;
};
void() CSQC_Init =
{
viewentity = spawn();
viewentity.predraw = DoThatViewModelThing;
viewentity.drawmask = MASK_NORMAL;
viewentity.renderflags = RF_VIEWMODEL | RF_DEPTHHACK;
};
void(float do2d) CSQC_UpdateView =
{
float width,height;
float usehud;
width = cvar("vid_conwidth");
height = cvar("vid_conheight");
clearscene();
if (0)//!cvar("cg_usehud"))
{
setviewprop(VF_DRAWENGINESBAR, 0);
usehud = true;
}
else
{
setviewprop(VF_DRAWENGINESBAR, 1);
}
setviewprop(VF_DRAWCROSSHAIR, 1);
//force fullscreen views.
setviewprop(VF_MIN, '0 0 0');
setviewprop(VF_SIZE_X, width);
setviewprop(VF_SIZE_Y, height);
addentities(MASK_ENGINE | MASK_NORMAL);
renderscene();
// if (usehud)
// Hud_Draw();
Invent_Draw();
};

View file

@ -0,0 +1,148 @@
//common builtins.
void(vector ang) makevectors = #1; // sets v_forward, etc globals
void(entity e, vector o) setorigin = #2;
void(entity e, string m) setmodel = #3; // set movetype and solid first
void(entity e, vector min, vector max) setsize = #4;
void() break = #6;
float() random = #7; // returns 0 - 1
void(entity e, float chan, string samp, float vol, float atten) sound = #8;
vector(vector v) normalize = #9;
void(string e) error = #10;
void(string e) objerror = #11;
float(vector v) vlen = #12;
float(vector v) vectoyaw = #13;
entity() spawn = #14;
void(entity e) remove = #15;
// sets trace_* globals
// nomonsters can be:
// An entity will also be ignored for testing if forent == test,
// forent->owner == test, or test->owner == forent
// a forent of world is ignored
void(vector v1, vector v2, float nomonsters, entity forent) traceline = #16;
entity(entity start, .string fld, string match) find = #18;
string(string s) precache_sound = #19;
string(string s) precache_model = #20;
void(entity client, string s)stuffcmd = #21;
entity(vector org, float rad) findradius = #22;
void(string s, ...) dprint = #25;
string(float f) ftos = #26;
string(vector v) vtos = #27;
void() coredump = #28; // prints all edicts
void() traceon = #29; // turns statment trace on
void() traceoff = #30;
void(entity e) eprint = #31; // prints an entire edict
float() droptofloor= #34; // TRUE if landed on floor
float(float v) rint = #36; // round to nearest int
float(float v) floor = #37; // largest integer <= v
float(float v) ceil = #38; // smallest integer >= v
float(vector v) pointcontents = #41; // returns a CONTENT_*
float(float f) fabs = #43;
float(string s) cvar = #45; // return cvar.value
void(string s, ...) localcmd = #46; // put string into local que
entity(entity e) nextent = #47; // for looping through all ents
void(vector o, vector d, float color, float count) particle = #48;// start a particle effect
void() ChangeYaw = #49; // turn towards self.ideal_yaw
// at self.yaw_speed
vector(vector v) vectoangles = #51;
void(string var, string val) cvar_set = #72; // sets cvar.value
//string(float modelindex) name_for_modelindex;
//float(string modelname) modelindex_for_name;
string(string s) precache_file = #68; // no effect except for -copy
string(string s) precache_model2 = #75; // registered version only
string(string s) precache_sound2 = #76; // registered version only
string(string s) precache_file2 = #77; // registered version only
float(string s) stof = #81;
void(vector v1, vector min, vector max, vector v2, float nomonsters, entity forent) tracebox = #90;
void(string name, string value) registercvar = #93;
entity(entity start, .entity fld, entity match) findentity = #98;
entity(entity start, .float fld, float match) findfloat = #98;
float(string filename, float mode) fopen = #110;
void(float fhandle) fclose = #111;
string(float fhandle) fgets = #112;
void(float fhandle, string s) fputs = #113;
float(string s) strlen = #114;
string(...) strcat = #115;
string(string s, float start, float length) substring = #116;
vector(string s) stov = #117;
string(string s) strzone = #118;
void(string s) strunzone = #119;
float FILE_READ = 0;
float FILE_WRITE = 1;
float FILE_APPEND = 2;
float(string s) tokenize = #441;
string(float argnum) argv = #442;
//DP_QC_SINCOSSQRTPOW
//idea: id Software, LordHavoc
//darkplaces implementation: id Software, LordHavoc
//builtin definitions:
float(float val) sin = #60;
float(float val) cos = #61;
float(float val) sqrt = #62;
float(float a, float b) pow = #97;
//description:
//useful math functions, sine of val, cosine of val, square root of val, and raise a to power b, respectively.
//FTE_STRINGS
float(string str, string match) strstrofs = #221;
float(string str, float ofs) str2chr = #222;
string(float c, ...) chr2str = #223;
string(float ccase, float redalpha, float redchars, string str) strconv = #224;
string(string info, string key, string value) infoadd = #226;
string(string info, string key) infoget = #227;
float(string s1, string s2, float len) strncmp = #228;
float(string s1, string s2) strcasecmp = #229;
float(string s1, string s2, float len) strncasecmp = #230;
float(entity ent, string tagname) gettagindex = #451;
vector(entity ent, float tagnum) RotateVectorsByTag = #234;
void(vector angle) RotateVectorsByAngle = #235;
void(vector fwd, vector right, vector up) RotateVectorsByVectors = #236;
float(float modelindex, string skinname) skinforname = #237;
float(string skinname) shaderforname = #238;

View file

@ -0,0 +1,76 @@
float FALSE = 0;
float TRUE = 1;
noref float false = FALSE;
float true = TRUE;
// edict.flags
float FL_FLY = 1;
float FL_SWIM = 2;
float FL_CLIENT = 8; // set for all client edicts
float FL_INWATER = 16; // for enter / leave water splash
float FL_MONSTER = 32;
float FL_GODMODE = 64; // player cheat
float FL_NOTARGET = 128; // player cheat
float FL_ITEM = 256; // extra wide size for bonus items
float FL_ONGROUND = 512; // standing on something
float FL_PARTIALGROUND = 1024; // not all corners are valid
float FL_WATERJUMP = 2048; // player jumping out of water
float FL_JUMPRELEASED = 4096; // for jump debouncing
// edict.solid values
float SOLID_TRIGGER = 1; // touch on edge, but not blocking
float SOLID_BBOX = 2; // touch on edge, block
float SOLID_SLIDEBOX = 3; // touch on edge, but not an onground
float SOLID_BSP = 4; // bsp clip, touch on edge, block
// edict.movetype values
float MOVETYPE_NONE = 0; // never moves
//float MOVETYPE_ANGLENOCLIP = 1;
//float MOVETYPE_ANGLECLIP = 2;
float MOVETYPE_WALK = 3; // players only
float MOVETYPE_STEP = 4; // discrete, not real time unless fall
float MOVETYPE_FLY = 5;
float MOVETYPE_TOSS = 6; // gravity
float MOVETYPE_PUSH = 7; // no clip to world, push and crush
float MOVETYPE_NOCLIP = 8;
float MOVETYPE_FLYMISSILE = 9; // fly with extra size against monsters
float MOVETYPE_BOUNCE = 10;
float MOVETYPE_BOUNCEMISSILE = 11; // bounce with extra size
float SOLID_NOT=0;
vector VEC_ORIGIN = '0 0 0';
vector VEC_HULL_MIN = '-16 -16 -24';
vector VEC_HULL_MAX = '16 16 32';
vector VEC_HULL2_MIN = '-32 -32 -24';
vector VEC_HULL2_MAX = '32 32 64';
// items
float IT_AXE = 4096;
float IT_SHOTGUN = 1;
float IT_SUPER_SHOTGUN = 2;
float IT_NAILGUN = 4;
float IT_SUPER_NAILGUN = 8;
float IT_GRENADE_LAUNCHER = 16;
float IT_ROCKET_LAUNCHER = 32;
float IT_LIGHTNING = 64;
float IT_EXTRA_WEAPON = 128;
float IT_SHELLS = 256;
float IT_NAILS = 512;
float IT_ROCKETS = 1024;
float IT_CELLS = 2048;
float IT_ARMOR1 = 8192;
float IT_ARMOR2 = 16384;
float IT_ARMOR3 = 32768;
float IT_SUPERHEALTH = 65536;
float IT_KEY1 = 131072;
float IT_KEY2 = 262144;
float IT_INVISIBILITY = 524288;
float IT_INVULNERABILITY = 1048576;
float IT_SUIT = 2097152;
float IT_QUAD = 4194304;

View file

@ -0,0 +1,129 @@
//Don't modify this file
/*
==============================================================================
SOURCE FOR GLOBALVARS_T C STRUCTURE
==============================================================================
*/
//
// system globals
//
entity self;
entity other;
entity world;
float time;
float frametime;
float player_localentnum; //the entnum
float player_localnum; //the playernum
float maxclients; //a constant filled in by the engine. gah, portability eh?
float clientcommandframe; //player movement
float servercommandframe; //clientframe echoed off the server
string mapname; //current brief map name
float intermission; //non-zero if the server sent an svc_intermission.
//
// global variables set by built in functions
//
vector v_forward, v_up, v_right; // set by makevectors()
// set by traceline / tracebox
float trace_allsolid;
float trace_startsolid;
float trace_fraction;
vector trace_endpos;
vector trace_plane_normal;
float trace_plane_dist;
entity trace_ent;
float trace_inopen;
float trace_inwater;
//these fields are read and set by the default player physics
vector pmove_org;
vector pmove_vel;
vector pmove_mins;
vector pmove_maxs;
//retrieved from the current movement commands (read by player physics)
float input_timelength;
vector input_angles;
vector input_movevalues; //forwards, right, up.
float input_buttons; //attack, use, jump (default physics only uses jump)
float movevar_gravity;
float movevar_stopspeed;
float movevar_maxspeed;
float movevar_spectatormaxspeed; //used by NOCLIP movetypes.
float movevar_accelerate;
float movevar_airaccelerate;
float movevar_wateraccelerate;
float movevar_friction;
float movevar_waterfriction;
float movevar_entgravity; //the local player's gravity field. Is a multiple (1 is the normal value)
//================================================
void end_sys_globals; // flag for structure dumping
//================================================
/*
==============================================================================
SOURCE FOR ENTVARS_T C STRUCTURE
==============================================================================
*/
//
// system fields (*** = do not set in prog code, maintained by C code)
//
.float modelindex; // *** model index in the precached list
.vector absmin, absmax; // *** origin + mins / maxs
.float entnum; // *** the ent number as on the server
.float drawmask;
.void() predraw;
.float movetype;
.float solid;
.vector origin; // ***
.vector oldorigin; // ***
.vector velocity;
.vector angles;
.vector avelocity;
.string classname; // spawn function
.float renderflags;
.string model;
.float frame;
.float frame2;
.float lerpfrac; //the ammount of frame2 to use.
.float skin;
.vector mins, maxs; // bounding box extents reletive to origin
.vector size; // maxs - mins
.void() touch;
.void() use;
.void() think;
.void() blocked; // for doors or plats, called when can't push other
.float nextthink;
.entity chain;
.entity enemy;
.float flags;
.float colormap;
.entity owner; // who launched a missile
//================================================
void end_sys_fields; // flag for structure dumping
//================================================