From d95a523f80a87d93c31475bb06336a241a43877f Mon Sep 17 00:00:00 2001 From: Spoike Date: Fri, 20 May 2011 04:10:59 +0000 Subject: [PATCH] Just messing with stuff. git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3794 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- quakec/csqctest/src/common/classes.qc | 5 +- quakec/csqctest/src/common/combuiltins.qc | 3 +- quakec/csqctest/src/common/extensions.qc | 5 +- quakec/csqctest/src/cs/csbuiltins.qc | 6 +- quakec/csqctest/src/cs/defs.qc | 16 +- quakec/csqctest/src/cs/editor_lights.qc | 244 ++++++++++++++++++++++ quakec/csqctest/src/cs/editor_terrain.qc | 57 +++++ quakec/csqctest/src/cs/entrypoints.qc | 106 ++++++---- quakec/csqctest/src/cs/hlpm.qc | 3 - quakec/csqctest/src/cs/hud.qc | 26 +-- quakec/csqctest/src/cs/menu.qc | 2 +- quakec/csqctest/src/cs/player.qc | 54 ++++- quakec/csqctest/src/cs/prediction.qc | 16 +- quakec/csqctest/src/cs/q3playerm.qc | 8 +- quakec/csqctest/src/cs/q4player.qc | 227 ++++++++++++++++++++ quakec/csqctest/src/csprogs.src | 4 + quakec/csqctest/src/optsall.qc | 40 +++- quakec/csqctest/src/ss/weapons.qc | 16 +- quakec/csqctest/src/ss/world.qc | 11 +- 19 files changed, 756 insertions(+), 93 deletions(-) create mode 100644 quakec/csqctest/src/cs/editor_lights.qc create mode 100644 quakec/csqctest/src/cs/editor_terrain.qc create mode 100644 quakec/csqctest/src/cs/q4player.qc diff --git a/quakec/csqctest/src/common/classes.qc b/quakec/csqctest/src/common/classes.qc index 0cbaf76d0..ff096170c 100644 --- a/quakec/csqctest/src/common/classes.qc +++ b/quakec/csqctest/src/common/classes.qc @@ -2,12 +2,13 @@ #define _CLASSES_QC_ -#define eclasses eclass(CLASS_ROCKET, ParseRocketClass) eclass(CLASS_GIB, ParseGibbing) eclass(CLASS_PLAYER, ParsePlayer) eclass(CLASS_EXPLOSION, ParseExplosion) eclass(CLASS_DEADBODY, ParseBody) eclass(CLASS_NAIL, ParseNailClass) - +#define eclasses eclass(CLASS_ROCKET, ParseRocketClass) eclass(CLASS_GIB, ParseGibbing) eclass(CLASS_PLAYER, ParsePlayer) eclass(CLASS_EXPLOSION, ParseExplosion) eclass(CLASS_NAIL, ParseNailClass) +#ifdef CSQC #define eclass(eid,func) void(float isnew) func; eclasses #undef eclass +#endif enum { diff --git a/quakec/csqctest/src/common/combuiltins.qc b/quakec/csqctest/src/common/combuiltins.qc index f5a9c29f7..db9b5c32e 100644 --- a/quakec/csqctest/src/common/combuiltins.qc +++ b/quakec/csqctest/src/common/combuiltins.qc @@ -8,6 +8,7 @@ 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; +void(entity e, float chan, string samp, float vol, float atten, float ppct) soundp = #8; vector(vector v) normalize = #9; void(string e) error = #10; void(string e) objerror = #11; @@ -26,7 +27,7 @@ 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; +float(string s) precache_model = #20; void(entity client, string s)stuffcmd = #21; entity(vector org, float rad) findradius = #22; diff --git a/quakec/csqctest/src/common/extensions.qc b/quakec/csqctest/src/common/extensions.qc index f8a59b16b..622fc2748 100644 --- a/quakec/csqctest/src/common/extensions.qc +++ b/quakec/csqctest/src/common/extensions.qc @@ -155,4 +155,7 @@ void(vector org, float colorstart, float colorlength) te_explosion2 = #427; void(entity own, vector start, vector end) te_lightning1 = #428; void(entity own, vector start, vector end) te_lightning2 = #429; void(entity own, vector start, vector end) te_lightning3 = #430; -void(entity own, vector start, vector end) te_beam = #431; \ No newline at end of file +void(entity own, vector start, vector end) te_beam = #431; + +//DP_QC_WHICHPACK +string(string filename) whichpack = #503; diff --git a/quakec/csqctest/src/cs/csbuiltins.qc b/quakec/csqctest/src/cs/csbuiltins.qc index 964e97133..f6a85a3ce 100644 --- a/quakec/csqctest/src/cs/csbuiltins.qc +++ b/quakec/csqctest/src/cs/csbuiltins.qc @@ -9,6 +9,8 @@ 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) +float(float property) getviewpropf = #309; // (EXT_CSQC) +vector(float property) getviewpropv = #309; // (EXT_CSQC) void(vector org, float radius, vector lightcolours) adddynamiclight = #305; // (EXT_CSQC) @@ -33,8 +35,8 @@ void(vector position, vector size, vector rgb, float alpha, ...) drawfill = # void(vector position, string text, vector scale, float alpha, ...) drawstring = #326; // (EXT_CSQC_1) -float(float stnum) getstatf = #330; // (EXT_CSQC) -float(float stnum) getstati = #331; // (EXT_CSQC) +float(float stnum) getstati = #330; // (EXT_CSQC) +float(float stnum) getstatf = #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) diff --git a/quakec/csqctest/src/cs/defs.qc b/quakec/csqctest/src/cs/defs.qc index d2de40951..91df5e1b7 100644 --- a/quakec/csqctest/src/cs/defs.qc +++ b/quakec/csqctest/src/cs/defs.qc @@ -67,4 +67,18 @@ void() Menu_Main; void() Menu_Think; var void(float event, float button, float mousex, float mousey) MenuEventFunc; -void() Movetype_Bounce; \ No newline at end of file +void() Movetype_Bounce; + +DEFCVAR_FLOAT(cg_editor, 0) +DEFCVAR_FLOAT(cg_hudtype, 2) +DEFCVAR_FLOAT(cg_noerror, 0) +DEFCVAR_FLOAT(cg_nostep, 0) +DEFCVAR_FLOAT(cg_nopred, 0) +DEFCVAR_FLOAT(cg_thirdPerson, 0) +DEFCVAR_FLOAT(cg_thirdPersonAngle, 0) +DEFCVAR_FLOAT(cg_thirdPersonRange, 96) +DEFCVAR_FLOAT(cg_thirdPersonHeight, 24) +DEFCVAR_FLOAT(cg_noselfsounds, 0) +DEFCVAR_FLOAT(cg_noselfjumpsound, 0) +DEFCVAR_FLOAT(v_viewheight, 0) +DEFCVAR_STRING(cg_forceskin, "") \ No newline at end of file diff --git a/quakec/csqctest/src/cs/editor_lights.qc b/quakec/csqctest/src/cs/editor_lights.qc new file mode 100644 index 000000000..0b2f226a3 --- /dev/null +++ b/quakec/csqctest/src/cs/editor_lights.qc @@ -0,0 +1,244 @@ +/*FTE has some special light editing builtins, I don't ever expect them to be standard or anything, but they're handy for this*/ +enum +{ + lf_origin=0, + lf_colour=1, + lf_radius=2, + lf_flags=3, + lf_style=4 +}; +float(float l, float f) dl_getf = #372; +vector(float l, float f) dl_getv = #372; +void(float l, float f, float v) dl_setf = #373; +void(float l, float f, vector v) dl_setv = #373; + +/*If you want to edit lights for hexen2, edit this cvar, use models/s_light.spr or something.*/ +DEFCVAR_STRING(cg_editor_lightmodel, "progs/s_light.spr") + +static float selectedlight; +static float editfield; +static string editvalue; +static entity tempent; +void() editor_lights_add = +{ + float l; + if (!tempent) + tempent = spawn(); + + l = dl_getf(-1, -1); + setmodel(tempent, CVARS(cg_editor_lightmodel)); + while(l > 0) + { + l = l-1; + if (l == selectedlight) + { + if (time*5 & 1) + continue; + tempent.effects |= 8192; + } + else + tempent.effects (-) 8192; + if (!dl_getf(l, lf_radius)) + continue; + setorigin(tempent, dl_getv(l, lf_origin)); + addentity(tempent); + } +}; + +static string fldname[8] = { + "bad", + "num", + "org", + "rgb", + "rad", + "flg", + "sty", + "???" +}; +static string(float fld, float foredit) readfield = +{ + switch(fld) + { + case 1: + if (foredit) + return ftos(selectedlight); + return strcat(ftos(selectedlight), " / ", ftos(dl_getf(-1, -1))); + case 2: + return vtos(dl_getv(selectedlight, lf_origin)); + case 3: + return vtos(dl_getv(selectedlight, lf_colour)); + case 4: + return ftos(dl_getf(selectedlight, lf_radius)); + case 5: + float fl = dl_getf(selectedlight, lf_flags); + if (foredit) + return ftos(fl); + return strcat( ((fl & 1)?" alwaysvisible":""), + ((fl & 2)?" realtime":""), + ((fl & 65536)?" no-shadows":"") + ); + case 6: + return ftos(dl_getf(selectedlight, lf_style)); + default: + return ""; + } +}; + +static void(float fld, string newval) writefield = +{ + switch(fld) + { + case 1: + selectedlight = stof(newval); + return; + case 2: + dl_setv(selectedlight, lf_origin, stov(newval)); + return; + case 3: + dl_setv(selectedlight, lf_colour, stov(newval)); + return; + case 4: + dl_setf(selectedlight, lf_radius, stof(newval)); + return; + case 5: + dl_getf(selectedlight, lf_flags, stof(newval)); + return; + case 6: + dl_getf(selectedlight, lf_style, stof(newval)); + return; + default: + return ""; + } +}; + +void() editor_lights_overlay = +{ + float i; + string s; +//void(vector position, string text, vector scale, vector rgb, float alpha, ...) drawrawstring + drawrawstring('0 0 0', "LIGHTS EDITOR", '8 8 0', '1 1 1', 1); + for (i = 1; i < 8; i++) + { + if (editfield == i) + s = editvalue; + else + s = readfield(i, 0); + s = strcat(ftos(i), " ", fldname[i], ": ", s); + drawrawstring('0 32 0' + '0 8 0' * i, s, '8 8 0', ((editfield == i)?'1 0 0':'1 1 1'), 1); + } +}; + +static void(vector fwd, vector vorg) selectbestlight = +{ + float l, b=selectedlight, d, bd = 0; + vector ldir; + l = dl_getf(-1, -1); + while(l > 0) + { + l--; + ldir = dl_getv(l, lf_origin); + ldir = normalize(ldir - vorg); + d = fwd*ldir; + if (d > bd) + { + bd = d; + b = l; + } + } + selectedlight = b; +}; + +float(float keyc, float unic) editor_lights_key = +{ + vector v, o; + string ns; + if (editfield) + { + ns = strcat(editvalue); + if (keyc == 10 || keyc == 13) + { + writefield(editfield, ns); + editfield = 0; + } + else if (keyc == 127) + { + if (ns != "") + ns = substring(ns, 0, -2); + } + else if (keyc == 8) + { + ns = ""; + } + else + ns = strcat(ns, chr2str(unic)); + + ns = strzone(ns); + strunzone(editvalue); + editvalue = ns; + + writefield(editfield, ns); + } + else if (keyc >= '0' && keyc <= '9') + { + editfield = keyc - '0'; + editvalue = strzone(readfield(editfield, 1)); + } + else if (keyc == '=') + selectedlight++; + else if (keyc == '-') + selectedlight--; + else if (keyc == 'n') + localcmd("noclip\n"); + else if (keyc == 's') + { + v = getviewpropv(15); + o = getviewpropv(11); + makevectors(v); + selectbestlight(v_forward, o); + } + else if (keyc == 'm') + { + v = getviewpropv(15); + o = getviewpropv(11); + makevectors(v); + traceline(o, o + v_forward*8192, true, world); + dl_setv(selectedlight, lf_origin, trace_endpos + trace_plane_normal*4); + } + else if (keyc == 'i') + { + for (selectedlight = 32; ; selectedlight++) + { + if (!dl_getf(selectedlight, lf_radius)) + { + dl_setf(selectedlight, lf_radius, 300); + v = getviewpropv(15); + o = getviewpropv(11); + makevectors(v); + traceline(o, o + v_forward*8192, true, world); + dl_setv(selectedlight, lf_origin, trace_endpos + trace_plane_normal*4); + break; + } + } + } + else if (keyc == '[') + { + v = getviewpropv(15); + o = getviewpropv(11); + makevectors(v); + traceline(o, o + v_forward*8192, true, world); + dl_setv(selectedlight, lf_origin, dl_getv(selectedlight, lf_origin) - trace_plane_normal); + } + else if (keyc == ']') + { + v = getviewpropv(15); + o = getviewpropv(11); + makevectors(v); + traceline(o, o + v_forward*8192, true, world); + dl_setv(selectedlight, lf_origin, dl_getv(selectedlight, lf_origin) + trace_plane_normal); + } + else if (keyc == 127) + dl_setf(selectedlight, lf_radius, 0); + else + return false; + return true; +}; diff --git a/quakec/csqctest/src/cs/editor_terrain.qc b/quakec/csqctest/src/cs/editor_terrain.qc new file mode 100644 index 000000000..2d1205121 --- /dev/null +++ b/quakec/csqctest/src/cs/editor_terrain.qc @@ -0,0 +1,57 @@ +enum +{ + ter_reload = 0, + ter_save = 1, + ter_set = 2, + ter_smooth = 3, + ter_raise = 4, + ter_lower = 5 +}; + + +void(float action, vector pos, float radius, float quant) terrain_edit = #278; + +float(float keyc, float unic) editor_terrain_key = +{ + vector v, o; + if (keyc == '[') + { + v = getviewpropv(VF_ANGLES); + o = getviewpropv(VF_ORIGIN); + makevectors(v); + traceline(o, o + v_forward*8192, true, world); + + terrain_edit(ter_lower, trace_endpos, 256, 8); + } + else if (keyc == '=') + { + v = getviewpropv(VF_ANGLES); + o = getviewpropv(VF_ORIGIN); + makevectors(v); + traceline(o, o + v_forward*8192, true, world); + + terrain_edit(ter_set, trace_endpos, 256, 8); + } + + else if (keyc == 13) + { + v = getviewpropv(VF_ANGLES); + o = getviewpropv(VF_ORIGIN); + makevectors(v); + traceline(o, o + v_forward*8192, true, world); + + terrain_edit(ter_smooth, trace_endpos, 256, 8); + } + else if (keyc == ']') + { + v = getviewpropv(VF_ANGLES); + o = getviewpropv(VF_ORIGIN); + makevectors(v); + traceline(o, o + v_forward*8192, true, world); + + terrain_edit(ter_raise, trace_endpos, 256, 8); + } + else return false; + + return true; +}; diff --git a/quakec/csqctest/src/cs/entrypoints.qc b/quakec/csqctest/src/cs/entrypoints.qc index 1d60f803e..6ae8a2587 100644 --- a/quakec/csqctest/src/cs/entrypoints.qc +++ b/quakec/csqctest/src/cs/entrypoints.qc @@ -5,6 +5,8 @@ float show_scoreboard; string dbgstr; +void() CSQC_Shutdown = {}; + //check engine extensions, and give suitable warning void() checkengineversion = { @@ -190,9 +192,6 @@ float(string str) CSQC_ConsoleCommand = void(string msg, float type) CSQC_Parse_Print = { - print("parse_print(", ftos(type), "): "); - print(msg); - cprint(msg); if (dbgstr) @@ -213,8 +212,8 @@ void(entity ve) DoThatViewModelThing = { float newframe, newmodel; - newframe = getstati(STAT_WEAPONFRAME); - newmodel = getstati(STAT_WEAPONMODEL); + newframe = getstatf(STAT_WEAPONFRAME); + newmodel = getstatf(STAT_WEAPONMODEL); if (newmodel != ve.modelindex) { //changed entirly. @@ -247,18 +246,6 @@ void() CSQC_Init = checkengineversion(); checkcompilerversion(); - //set some cvars to their defaults, and create them at the same time - if (cvar_string("cg_giblevel") == "") localcmd("set cg_giblevel 1\n"); - if (cvar_string("cg_thirdPerson") == "") localcmd("set cg_thirdPerson 0\n"); - if (cvar_string("cg_forceskin") == "") localcmd("set cg_forceskin \"\"\n"); - if (cvar_string("cg_hudtype") == "") localcmd("set cg_hudtype 1\n"); - if (cvar_string("cg_nopred") == "") localcmd("set cg_nopred 0\n"); - if (cvar_string("v_viewheight") == "") localcmd("set v_viewheight 0\n");//normally an engine cvar in quakeworld. - if (cvar_string("cg_nostep") == "") localcmd("set cg_nostep 0\n"); - if (cvar_string("cg_noerror") == "") localcmd("set cg_noerror 0\n"); - if (cvar_string("cg_noselfsounds") == "") localcmd("set cg_noselfsounds 0\n"); - if (cvar_string("cg_noselfjumpsound") == "") localcmd("set cg_noselfjumpsound 0\n"); - viewentity = spawn(); viewentity.renderflags = RF_VIEWMODEL|RF_DEPTHHACK; @@ -329,24 +316,36 @@ void() CSQC_Delta_Remove = remove(self); }; + +float (float event, float parama, float paramb) CSQC_InputEvent = +{ + if (event == 0) + { + switch(CVARF(cg_editor)) + { + case 1: + if (editor_lights_key(parama, paramb)) + return true; + break; + case 2: + if (editor_terrain_key(parama, paramb)) + return true; + break; + } + } + return Menu_InputEvent(event, parama, paramb); +}; + void(float width, float height, float do2d) CSQC_UpdateView = { - float hudtype = cvar("cg_hudtype"); + float hudtype = CVARF(cg_hudtype); - chasecam = cvar("cg_thirdPerson"); - if (getstati(STAT_HEALTH) <= 0) + chasecam = CVARF(cg_thirdPerson); + if (getstatf(STAT_HEALTH) <= 0) chasecam = 1; clearscene(); - if (hudtype != 1) - { - setviewprop(VF_DRAWENGINESBAR, 0); - } - else - { - setviewprop(VF_DRAWENGINESBAR, 1); - } setviewprop(VF_DRAWCROSSHAIR, 1); //force fullscreen views (ignore viewsize). @@ -359,6 +358,16 @@ void(float width, float height, float do2d) CSQC_UpdateView = setviewprop(VF_SIZE_X, width/2); setviewprop(VF_SIZE_Y, height/2); #endif + + if (hudtype != 1) + { + setviewprop(VF_DRAWENGINESBAR, 0); + } + else + { + setviewprop(VF_DRAWENGINESBAR, 1); + } + addentities(MASK_NORMAL|MASK_ENGINE); if (player_local) @@ -380,28 +389,43 @@ void(float width, float height, float do2d) CSQC_UpdateView = addentities(MASK_ENGINEVIEWMODEL); } + switch(CVARF(cg_editor)) + { + case 1: + /*add light ents*/ + editor_lights_add(); + hudtype = 0; + break; + case 2: + break; + } + renderscene(); -#if 0 -clearscene(); - setviewprop(VF_MIN_X, 0); - setviewprop(VF_MIN_Y, 0); - setviewprop(VF_SIZE_X, width/2); - setviewprop(VF_SIZE_Y, height/2); - addentities(MASK_NORMAL|MASK_ENGINE); -renderscene(); -#endif + if (do2d) { - if (hudtype) - Hud_Draw(hudtype, show_scoreboard, width, height); + switch(CVARF(cg_editor)) + { + case 1: + /*add light ents*/ + editor_lights_overlay(); + hudtype = 0; + break; + case 2: + break; + default: + if (hudtype) + Hud_Draw(hudtype, show_scoreboard, width, height); + break; + } Menu_Think(); } if (dbgstr) { - drawrawstring('16 64 0', dbgstr, '16 16 16', '1 1 1', 0.5); - drawstring('16 80 0', dbgstr, '16 16 16', 0.5); +// drawrawstring('16 64 0', dbgstr, '16 16 16', '1 1 1', 0.5); +// drawstring('16 80 0', dbgstr, '16 16 16', 0.5); } }; diff --git a/quakec/csqctest/src/cs/hlpm.qc b/quakec/csqctest/src/cs/hlpm.qc index 78b351490..b0c3281ba 100644 --- a/quakec/csqctest/src/cs/hlpm.qc +++ b/quakec/csqctest/src/cs/hlpm.qc @@ -17,9 +17,6 @@ //FTE_CSQC_HALFLIFE_MODELS .float bonecontrol1, bonecontrol2, bonecontrol3, bonecontrol4; -//DP_QC_WHICHPACK -string(string fname) whichpack = #503; - #pragma noref 0 .float starttime; diff --git a/quakec/csqctest/src/cs/hud.qc b/quakec/csqctest/src/cs/hud.qc index 4a382619d..3e6d9f963 100644 --- a/quakec/csqctest/src/cs/hud.qc +++ b/quakec/csqctest/src/cs/hud.qc @@ -140,17 +140,17 @@ void(vector pos) Hud_CoopScores_SBar = vector sbar = screensize_y * ' 0 1 0' - '0 24 0'; drawpic(sbar, "scorebar", '320 24 0', '1 1 1', 0.333, 0); - s = strcat("Monsters:", FormatFloat(getstati(STAT_KILLEDMONSTERS), 3, " "), "/", FormatFloat(getstati(STAT_TOTALMONSTERS), 3, " ")); - drawstring(sbar + '8 4', s, '8 8 8', 1, 0); - s = strcat("Secrets :", FormatFloat(getstati(STAT_FOUNDSECRETS), 3, " "), "/", FormatFloat(getstati(STAT_TOTALSECRETS), 3, " ")); - drawstring(sbar + '8 12', s, '8 8 8', 1, 0); + s = strcat("Monsters:", FormatFloat(getstatf(STAT_KILLEDMONSTERS), 3, " "), "/", FormatFloat(getstatf(STAT_TOTALMONSTERS), 3, " ")); + drawstring(sbar + '8 4', s, '8 8 0', 1, 0); + s = strcat("Secrets :", FormatFloat(getstatf(STAT_FOUNDSECRETS), 3, " "), "/", FormatFloat(getstatf(STAT_TOTALSECRETS), 3, " ")); + drawstring(sbar + '8 12', s, '8 8 0', 1, 0); mins = floor(time/60); secs = floor(time - mins*60); s = strcat("Time :", FormatFloat(mins, 3, " "), ":", FormatFloat(secs, 2, "0")); - drawstring(sbar + '184 4', s, '8 8 8', 1, 0); + drawstring(sbar + '184 4', s, '8 8 0', 1, 0); - drawstring(sbar + '232 12' - strlen(levelname)*'4 0', levelname, '8 8 8', 1, 0); + drawstring(sbar + '232 12' - strlen(levelname)*'4 0', levelname, '8 8 0', 1, 0); }; void Hud_DrawSBar(vector pos) @@ -164,7 +164,7 @@ void Hud_DrawSBar(vector pos) } else { - Hud_DrawLargeValue(pos+'24 0 0', getstati(STAT_ARMOR), 25); + Hud_DrawLargeValue(pos+'24 0 0', getstatf(STAT_ARMOR), 25); if (items & IT_ARMOR3) drawpic(pos, "sb_armor3", '24 24 0', '1 1 1', 1, 0); else if (items & IT_ARMOR2) @@ -173,7 +173,7 @@ void Hud_DrawSBar(vector pos) drawpic(pos, "sb_armor1", '24 24 0', '1 1 1', 1, 0); } - Hud_DrawLargeValue(pos+'136 0 0', getstati(STAT_HEALTH), 25); + Hud_DrawLargeValue(pos+'136 0 0', getstatf(STAT_HEALTH), 25); if (items & IT_SHELLS) drawpic(pos+'224 0 0', "sb_shells", '24 24 0', '1 1 1', 1, 0); @@ -183,7 +183,7 @@ void Hud_DrawSBar(vector pos) drawpic(pos+'224 0 0', "sb_rocket", '24 24 0', '1 1 1', 1, 0); else if (items & IT_CELLS) drawpic(pos+'224 0 0', "sb_cells", '24 24 0', '1 1 1', 1, 0); - Hud_DrawLargeValue(pos+'248 0 0', getstati(STAT_AMMO), 10); + Hud_DrawLargeValue(pos+'248 0 0', getstatf(STAT_AMMO), 10); }; void Hud_DrawIBar(vector pos) @@ -345,9 +345,9 @@ void Hud_Q3(vector pos) Hud_Draw3dItem(pos+'0 0', '24 24', "models/powerups/armor/armor_red.md3", '80 0 -10', '0 1 0'*360*(time/6)); Hud_DrawQ3Head(pos+'112 0', '24 24', cvar_string("cg_forceskin"), '0 180 0'+'0 20 0'*sin(time)); - Hud_DrawQ3Number(pos+'24 0 0', getstati(STAT_ARMOR), '1 1 1'); - Hud_DrawQ3Number(pos+'136 0 0', getstati(STAT_HEALTH), '1 1 1'); - Hud_DrawQ3Number(pos+'248 0 0', getstati(STAT_AMMO), '1 1 1'); + Hud_DrawQ3Number(pos+'24 0 0', getstatf(STAT_ARMOR), '1 1 1'); + Hud_DrawQ3Number(pos+'136 0 0', getstatf(STAT_HEALTH), '1 1 1'); + Hud_DrawQ3Number(pos+'248 0 0', getstatf(STAT_AMMO), '1 1 1'); } nonstatic void Hud_Draw(float hudtype, float scoreboard, float width, float height) @@ -366,7 +366,7 @@ nonstatic void Hud_Draw(float hudtype, float scoreboard, float width, float heig //if hudtype == 0 then the engine already drew it. if (hudtype == 3) { - Hud_Q3(); + Hud_Q3(pos - '0 24 0'); return; } else if (hudtype == 2) diff --git a/quakec/csqctest/src/cs/menu.qc b/quakec/csqctest/src/cs/menu.qc index 513e7cdc8..015560a7c 100644 --- a/quakec/csqctest/src/cs/menu.qc +++ b/quakec/csqctest/src/cs/menu.qc @@ -14,7 +14,7 @@ nonstatic void(void(float, float, float, float) fnc) Menu_Activate = }; noref vector mousepos; //z is not set -float (float event, float parama, float paramb) CSQC_InputEvent = +float (float event, float parama, float paramb) Menu_InputEvent = { if (!inmenu) return false; //let the engine do what it wants. diff --git a/quakec/csqctest/src/cs/player.qc b/quakec/csqctest/src/cs/player.qc index 550d433cb..78c7c3908 100644 --- a/quakec/csqctest/src/cs/player.qc +++ b/quakec/csqctest/src/cs/player.qc @@ -15,8 +15,14 @@ enum #ifdef MD3PMODELS MF_QUAKE3, #endif +#ifdef Q4PMODELS + MF_QUAKE4, +#endif #ifdef HLPMODELS MF_HLPM, +#endif +#ifdef XM + MF_XM, #endif MF_QUAKE }; @@ -40,10 +46,20 @@ static void() Player_Interpolate = Anim_Draw(); break; #endif +#ifdef Q4PMODELS + case MF_QUAKE4: + Q4PM_Draw(); + break; +#endif #ifdef HLPMODELS case MF_HLPM: HLPM_Draw(); break; +#endif +#ifdef XM + case MF_XM: + XM_Draw(); + break; #endif default: if (self.lerptime) @@ -97,7 +113,7 @@ static void(float g) Player_SetLocalInfoGender = if (player_local == self) { //if it was forced, don't lie to everyone else. - if (cvar_string("cg_forceskin") != "") + if (CVARS(cg_forceskin) != "") return; switch(g) @@ -119,7 +135,8 @@ static void(float g) Player_SetLocalInfoGender = static void() Player_SetQ1Model = { self.modelstyle = MF_QUAKE; - + self.drawmask = MASK_NORMAL; + setmodel(self, "progs/player.mdl"); Player_SetLocalInfoGender(GENDER_MALE); } @@ -136,6 +153,19 @@ static void(string skinname) Player_SetQ3Model = }; #endif +#ifdef Q4PMODELS +static void(string skinname) Player_SetQ4Model = +{ + if (!Q4PM_SetModel(skinname)) + { + Q4PM_UnsetModel(); + return; + } + Player_SetLocalInfoGender(GENDER_MALE); + self.modelstyle = MF_QUAKE4; +}; +#endif + #ifdef HLPMODELS static void(string skinname) Player_SetHLModel = { @@ -158,6 +188,11 @@ static void() Player_UnsetModel = Anim_UnsetModel(); break; #endif +#ifdef Q4PMODELS + case MF_QUAKE4: + Q4PM_UnsetModel(); + break; +#endif #ifdef HLPMODELS case MF_HLPM: HLPM_UnsetModel(); @@ -182,6 +217,11 @@ static entity() Player_DupModel = e = Anim_DupModel(); break; #endif +#ifdef Q4PMODELS + case MF_QUAKE4: + e = Q4PM_DupModel(); + break; +#endif #ifdef HLPMODELS case MF_HLPM: e = HLPM_DupModel(); @@ -336,7 +376,7 @@ void(float isnew) RefreshPlayer = } else { - newskin = cvar_string("cg_forceskin"); + newskin = CVARS(cg_forceskin); if (newskin == "") newskin = getplayerkeyvalue(self.entnum-1, "model"); if (newskin == "") @@ -355,11 +395,15 @@ void(float isnew) RefreshPlayer = #ifdef MD3PMODELS if (self.modelstyle == MF_BAD && newskin != "") - Player_SetHLModel(newskin); + Player_SetQ3Model(newskin); +#endif +#ifdef Q4PMODELS + if (self.modelstyle == MF_BAD && newskin != "") + Player_SetQ4Model(newskin); #endif #ifdef HLPMODELS if (self.modelstyle == MF_BAD && newskin != "") - Player_SetQ3Model(newskin); + Player_SetHLModel(newskin); #endif if (self.modelstyle == MF_BAD) Player_SetQ1Model(); diff --git a/quakec/csqctest/src/cs/prediction.qc b/quakec/csqctest/src/cs/prediction.qc index c479dca1b..e42523b4b 100644 --- a/quakec/csqctest/src/cs/prediction.qc +++ b/quakec/csqctest/src/cs/prediction.qc @@ -73,7 +73,7 @@ nonstatic void(entity ent) Pred_PlayerUpdated = v = ent.velocity; pmf = ent.pmove_flags; - noerror = cvar("cg_noerror"); + noerror = CVARF(cg_noerror); //reset the prediction to last-known-good state Pred_ResetPlayerPrediction(ent); @@ -139,7 +139,7 @@ void(entity ent, float endframe) Pred_RunMovement = Pred_ResetPlayerPrediction(); #endif - if (getstati(STAT_HEALTH) <= 0) + if (getstatf(STAT_HEALTH) <= 0) { pmoveframe = clientcommandframe; //just update the angles @@ -149,7 +149,7 @@ void(entity ent, float endframe) Pred_RunMovement = return; //dead, so don't run prediction. :D } - if (cvar("cg_nopred")) + if (CVARF(cg_nopred)) { pmoveframe = clientcommandframe; //just update the angles @@ -196,29 +196,29 @@ nonstatic void(entity ent) Pred_UpdateLocalMovement = pmove_step_oldz = ent.origin_z; //allow the user to move the viewheight down 6 units so it's at +16, where projectiles come from. - viewheight = cvar("v_viewheight"); + viewheight = CVARF(v_viewheight); if (viewheight < -7) viewheight = -7; else if (viewheight > 7) viewheight = 7; vieworg = ent.origin; //the default view height - vieworg_z += getstati(STAT_VIEWHEIGHT) + viewheight; + vieworg_z += getstatf(STAT_VIEWHEIGHT) + viewheight; //correct the view position to compensate for any errors, slowly over time, 0.1 seconds. if (pmove_errortime - time > 0) vieworg += (pmove_errortime - time)*ERRORTIME * pmove_error; - if (!cvar("cg_nostep")) + if (!CVARF(cg_nostep)) if (pmove_steptime - time > 0) vieworg_z += (pmove_steptime - time)*STEPTIME * pmove_step; if (chasecam) { - view_angles_y += cvar("cg_thirdPersonAngle"); + view_angles_y += CVARF(cg_thirdPersonAngle); makevectors(view_angles); - traceline(self.origin, vieworg - v_forward * cvar("cg_thirdPersonRange")+v_up*cvar("cg_thirdPersonHeight"), TRUE, self); + traceline(self.origin, vieworg - v_forward * CVARF(cg_thirdPersonRange)+v_up*CVARF(cg_thirdPersonHeight), TRUE, self); vieworg = trace_endpos + v_forward*8; } }; diff --git a/quakec/csqctest/src/cs/q3playerm.qc b/quakec/csqctest/src/cs/q3playerm.qc index b682494ee..115edc9f6 100644 --- a/quakec/csqctest/src/cs/q3playerm.qc +++ b/quakec/csqctest/src/cs/q3playerm.qc @@ -246,7 +246,7 @@ void(entity ent, string soundname) sexedsound = { string str, full; if (self == player_local) - if (cvar("cg_noselfsounds")) + if (CVARF(cg_noselfsounds)) return; //option to disable sounds from local player str = strcat("player/", anim_name[self.modelnum], "/", soundname); @@ -254,13 +254,13 @@ void(entity ent, string soundname) sexedsound = if (fileexists(full)) { precache_sound(str); - sound(self, CHAN_VOICE, str, 1, 1); + soundp(self, CHAN_VOICE, str, 1, 1, 95 + random()*10); } else { str = strcat("player/sarge/", soundname); // :( precache_sound(str); - sound(self, CHAN_VOICE, str, 1, 1); + soundp(self, CHAN_VOICE, str, 1, 1, 95 + random()*10); } }; @@ -1167,7 +1167,7 @@ float(float channel, string soundname, vector pos, float vol, float attenuation) if (soundname == "player/plyrjmp8.wav") { if (self == player_local) - if (cvar("cg_noselfjumpsound")) + if (CVARF(cg_noselfjumpsound)) return true; //option to disable jump noise for local player. sexedsound(self, "jump1.wav"); return true; diff --git a/quakec/csqctest/src/cs/q4player.qc b/quakec/csqctest/src/cs/q4player.qc new file mode 100644 index 000000000..70b6775e5 --- /dev/null +++ b/quakec/csqctest/src/cs/q4player.qc @@ -0,0 +1,227 @@ +float(float modlindex) skel_create = #263; // create a skeleton (be sure to assign the value to .skeletonindex for use), returns skeleton index (1 or higher) on success, returns 0 on failure (for example if the modelindex is not skeletal) +float(float skel, entity ent, float modlindex, float retainfrac, float firstbone, float lastbone) skel_build = #264; // blend in a percentage of standard animation, 0 replaces entirely, 1 does nothing, 0.5 blends half, etc, and this only alters the bones in the specified range for which out of bounds values like 0,100000 are safe (uses .frame, .frame2, .frame3, .frame4, .lerpfrac, .lerpfrac3, .lerpfrac4, .frame1time, .frame2time, .frame3time, .frame4time), returns skel on success, 0 on failure +float(float skel) skel_get_numbones = #265; // returns how many bones exist in the created skeleton +string(float skel, float bonenum) skel_get_bonename = #266; // returns name of bone (as a tempstring) +float(float skel, float bonenum) skel_get_boneparent = #267; // returns parent num for supplied bonenum, -1 if bonenum has no parent or bone does not exist (returned value is always less than bonenum, you can loop on this) +float(float skel, string tagname) skel_find_bone = #268; // get number of bone with specified name, 0 on failure, tagindex (bonenum+1) on success, same as using gettagindex on the modelindex +vector(float skel, float bonenum) skel_get_bonerel = #269; // get matrix of bone in skeleton relative to its parent - sets v_forward, v_right, v_up, returns origin (relative to parent bone) +vector(float skel, float bonenum) skel_get_boneabs = #270; // get matrix of bone in skeleton in model space - sets v_forward, v_right, v_up, returns origin (relative to entity) +void(float skel, float bonenum, vector org, vector fwd, vector rgt, vector up) skel_set_bone = #271; // set matrix of bone relative to its parent, reads v_forward, v_right, v_up, takes origin as parameter (relative to parent bone) +void(float skel, float bonenum, vector org) skel_mul_bone = #272; // transform bone matrix (relative to its parent) by the supplied matrix in v_forward, v_right, v_up, takes origin as parameter (relative to parent bone) +void(float skel, float startbone, float endbone, vector org, vector f, vector r, vector u) skel_mul_bones = #273; // transform bone matrices (relative to their parents) by the supplied matrix in v_forward, v_right, v_up, takes origin as parameter (relative to parent bones) +void(float skeldst, float skelsrc, float startbone, float endbone) skel_copybones = #274; // copy bone matrices (relative to their parents) from one skeleton to another, useful for copying a skeleton to a corpse +void(float skel) skel_delete = #275; // deletes skeleton at the beginning of the next frame (you can add the entity, delete the skeleton, renderscene, and it will still work) +//float(float modlindex, string framename) frameforname = #276; // finds number of a specified frame in the animation, returns -1 if no match found +float(float modlindex, float framenum) frameduration = #277; // returns the intended play time (in seconds) of the specified framegroup, if it does not exist the result is 0, if it is a single frame it may be a small value around 0.1 or 0. +.float skeletonindex; + + +enum +{ +ANIM_FORWARD, +ANIM_BACK, +ANIM_LEFT, +ANIM_RIGHT, +ANIM_IDLE, +ANIM_MAX +}; + +float anim[ANIM_MAX]; + +.vector lastorg; + +.float aweight[ANIM_MAX]; +.float atime[ANIM_MAX]; + +.float rangle; + +/*pick an angle for the legs to run in such that the movement is in 0, 90, 180, -90 angles from movement direction. attempt to clamp past a full circle*/ +float() anglequadrant = +{ + float ideal, diff; + + if (!self.velocity_x && !self.velocity_y) + ideal = self.angles_y; + else + ideal = vectoyaw(self.velocity); + diff = ideal - self.angles_y; + if (diff > 180) + diff -= 360; + if (diff < -180) + diff += 360; + + if (diff < -180) + return self.angles_y + 180; + else if (diff > 180) + return self.angles_y - 180; + else if (diff < -150) + return ideal + 180; + else if (diff > 150) + return ideal - 180; + else if (diff > 75) + return ideal - 90; + else if (diff < -75) + return ideal + 90; + else + return ideal; +}; + +void(float ideal, float speed) mychangeyaw = +{ + float move; + move = ideal - self.angles_y; + speed *= frametime; + if (move > 180) + move -= 360; + if (move < -180) + move += 360; + if (move >= 0) + { + if (move > speed) + move = speed; + } + else + { + if (move < -speed) + move = -speed; + } + self.angles_y = self.angles_y + move; +}; + +void() Q4PM_Draw = +{ + float fw, rt; + float tweight; + float i; + float ideal; + vector aimang; + + vector move = self.origin - self.lastorg; + self.lastorg = self.origin; + + if (!self.skeletonindex) + { + self.skeletonindex = skel_create(self.modelindex); + if (!self.skeletonindex) + return; + } + + ideal = anglequadrant(); + aimang_x = self.angles_y; + aimang_z = self.angles_x*-3; + + self.angles_x = 0; + self.angles_y = self.rangle; + self.angles_z = 0; + mychangeyaw(ideal, 360); + self.rangle = self.angles_y; + + makevectors(self.angles); + + fw = (move * v_forward)/(320); + rt = (move * v_right)/(320); + + aimang_x -= self.angles_y; + aimang_y = 0; + if (aimang_x > 180) + aimang_x -= 360; + if (aimang_x < -180) + aimang_x += 360; + makevectors(aimang*0.333); + + if (fw*fw > 0) + { + if (fw > 0) + self.aweight[ANIM_FORWARD] += fw*32; + else + self.aweight[ANIM_BACK] -= fw*32; + } + if (fw > 0) + self.atime[ANIM_FORWARD] += fw; + else + self.atime[ANIM_BACK] -= fw; + if (rt*rt > 0) + { + if (rt > 0) + self.aweight[ANIM_RIGHT] += rt*32; + else + self.aweight[ANIM_LEFT] -= rt*32; + } + if (rt > 0) + self.atime[ANIM_RIGHT] += rt; + else + self.atime[ANIM_LEFT] -= rt; + if (move_x == 0 && move_y == 0) + self.aweight[ANIM_IDLE] += frametime*4; + self.atime[ANIM_IDLE] += frametime; + + + tweight = self.aweight[ANIM_FORWARD]+self.aweight[ANIM_BACK]+self.aweight[ANIM_LEFT]+self.aweight[ANIM_RIGHT]+self.aweight[ANIM_IDLE]; + if (tweight > 1) + { + tweight = 1/tweight; + self.aweight[ANIM_FORWARD] *= tweight; + self.aweight[ANIM_BACK] *= tweight; + self.aweight[ANIM_LEFT] *= tweight; + self.aweight[ANIM_RIGHT] *= tweight; + self.aweight[ANIM_IDLE] *= tweight; + } + else + { + self.aweight[ANIM_IDLE] += 1-tweight; + self.atime[ANIM_IDLE] += frametime; + } + + self.origin_z += self.mins_z; + setmodel(self, self.model); + for (i = 0; i < ANIM_MAX; i++) + { + self.frame = 0; + self.frame2 = 0; + self.lerpfrac = 0; + self.frame1time = self.atime[i]; + self.frame2time = self.atime[i]; + skel_build(self.skeletonindex, self, anim[i], ((i==0)?0:1), 0, -1, self.aweight[i]); + } + + skel_mul_bone(self.skeletonindex, 18, '0 0 0', v_forward, v_right, v_up); + skel_mul_bone(self.skeletonindex, 19, '0 0 0', v_forward, v_right, v_up); + skel_mul_bone(self.skeletonindex, 20, '0 0 0', v_forward, v_right, v_up); + + //obliterate the bone movement, so that it doesn't move forwards. + skel_get_bonerel(self.skeletonindex, 1); + skel_set_bone(self.skeletonindex, 1, '0 0 0', v_forward*(64/72), v_right*(64/72), v_up*(64/72)); +}; + +float(string skinname) Q4PM_SetModel = +{ + string mname = strcat("models/characters/player/", skinname, ".md5mesh"); + + //check to see if it exists + if not (whichpack(mname)) + return false; + + anim[ANIM_IDLE] = precache_model("models/characters/player/idle.md5anim"); + anim[ANIM_FORWARD] = precache_model("models/characters/player/run.md5anim"); + anim[ANIM_BACK] = precache_model("models/characters/player/run_backwards.md5anim"); + anim[ANIM_RIGHT] = precache_model("models/characters/player/strafe_right.md5anim"); + anim[ANIM_LEFT] = precache_model("models/characters/player/strafe_left.md5anim"); + + setmodel(self, mname); + + self.rangle = self.angles_y; + + return true; +}; + +void() Q4PM_UnsetModel = +{ + if (self.skeletonindex) + skel_delete(self.skeletonindex); + self.skeletonindex = 0; +}; + +entity() Q4PM_DupModel +{ + return spawn(); +}; \ No newline at end of file diff --git a/quakec/csqctest/src/csprogs.src b/quakec/csqctest/src/csprogs.src index 860aafd4a..0ec8be49c 100644 --- a/quakec/csqctest/src/csprogs.src +++ b/quakec/csqctest/src/csprogs.src @@ -23,8 +23,12 @@ cs/keys.qc common/makeallstatic.qc +cs/editor_lights.qc +cs/editor_terrain.qc + cs/prediction.qc cs/q3playerm.qc +cs/q4player.qc cs/hlpm.qc cs/player.qc cs/hud.qc diff --git a/quakec/csqctest/src/optsall.qc b/quakec/csqctest/src/optsall.qc index 5a65eab91..94e00fd0c 100644 --- a/quakec/csqctest/src/optsall.qc +++ b/quakec/csqctest/src/optsall.qc @@ -1,11 +1,13 @@ //#define WORKINDP //use workarounds for DP. -//#define FTEDEPENDANT //explicitly depend upon FTE-only extensions (mostly prototype EXT_CSQC_1 features). +#define FTEDEPENDANT //explicitly depend upon FTE-only extensions (mostly prototype EXT_CSQC_1 features). //#define OWNPLAYERPHYSICS //run our own prediction code, instead of the engine-supplied default +#define AUTOCVAR + #define MD3PMODELS //support Q3 segmented player models #define HLPMODELS //support HalfLife skeletal models #define POWERUP_SHELLS //show shells around players for powerups - +#define Q4PMODELS //#define NOEXTENSIONS #ifdef NOEXTENSIONS @@ -24,3 +26,37 @@ # warning "FTEDEPENDANT defined: Mod will only work properly in FTE" # pragma TARGET FTE #endif + + + + + + + + + + + + + + + + + + + + + + + +#ifdef AUTOCVAR +#define DEFCVAR_FLOAT(n,d) var float autocvar_##n = d; +#define DEFCVAR_STRING(n,d) var string autocvar_##n = d; +#define CVARF(n) autocvar_##n +#define CVARS(n) autocvar_##n +#else +#define DEFCVAR_FLOAT(n,d) +#define DEFCVAR_STRING(n,d) +#define CVARF(n) cvar(#n) +#define CVARS(n) cvar_string(#n) +#endif \ No newline at end of file diff --git a/quakec/csqctest/src/ss/weapons.qc b/quakec/csqctest/src/ss/weapons.qc index d9881b950..7361f7f9b 100644 --- a/quakec/csqctest/src/ss/weapons.qc +++ b/quakec/csqctest/src/ss/weapons.qc @@ -354,12 +354,16 @@ float(entity toplayer) SendExplosion = return TRUE; }; -void() s_explode1 = [0, s_explode2] {}; -void() s_explode2 = [1, s_explode3] {}; -void() s_explode3 = [2, s_explode4] {}; -void() s_explode4 = [3, s_explode5] {}; -void() s_explode5 = [4, s_explode6] {}; -void() s_explode6 = [5, SUB_Remove] {}; +/*this is for shits and giggles*/ +void(float action, vector pos, float radius, float quant) terrain_edit = #278; +void() makevolcano = +{ +#ifdef FTEDEPENDANT + terrain_edit(4, self.origin, 512, 64/3); + terrain_edit(5, self.origin, 256, 32/3); +#endif +}; +void() s_explode1 = {self.think = s_explode1; if (self.frame >= 6) {remove(self); return;}makevolcano(); self.frame += 0.5; self.nextthink = time + 0.05;}; void() BecomeExplosion = { diff --git a/quakec/csqctest/src/ss/world.qc b/quakec/csqctest/src/ss/world.qc index 3bb8ecad2..5d23243f4 100644 --- a/quakec/csqctest/src/ss/world.qc +++ b/quakec/csqctest/src/ss/world.qc @@ -1,6 +1,10 @@ float infokeyworks; void() InitBodyQue; +void(float num, float type, .float field) addstatf = #232; +void(float num, float type, .string field) addstats = #232; +void(float num, float type, .vector field) addstatv = #232; + void() main = { dprint ("main function\n"); @@ -334,10 +338,11 @@ void() worldspawn = lightstyle(63, "a"); infokeyworks = checkextension("QW_ENGINE"); -#ifdef WORKINDP - serverusingcsqc = TRUE; -#else + serverusingcsqc = checkextension("EXT_CSQC") || checkextension("EXT_CSQC_1"); +#ifdef WORKINDP + if (isdp) + serverusingcsqc = TRUE; #endif };