diff --git a/config/menus.cfg b/config/menus.cfg index ec507644..212c20b4 100755 --- a/config/menus.cfg +++ b/config/menus.cfg @@ -8,13 +8,16 @@ menuitem "Join Game" "servermenu" menuitem "Refresh Serverlist" "updatefrommaster" menuitem "Vote.." "showmenu gamemode" menuitem "Load Map.." "showmenu maps" +menuitem "Change Team" "showmenu team" menuitem "Disconnect" "disconnect" menuitem "Options.." "showmenu options" menuitem "Editing.." "showmenu editing" menuitem "about/credits/help" "showmenu about" menuitem "Quit" "quit" - +// menubg "textures/blah..." +// menumdl path frame range rotation-speed{0-100} scale{0-100} +// chmenumdl menuname newpath alias genmapitems [ alias n (listlen $arg1) @@ -38,8 +41,10 @@ genmapitems "ac_complex ac_mines ac_depot ac_desert" newmenu team -menuitem "Special Forces" -menuitem "Freedom Fighters" +menumdl playermodels/terrorist 0 1 50 10 +menuitem "Terrorists" "team 0" "chmenumdl team playermodels/terrorist 0 1 50 10" +menuitem "Counter Terrorists" "team 1" "chmenumdl team playermodels/counterterrorist 0 1 50 10" + newmenu gamemode @@ -236,17 +241,20 @@ menuitem "Equipment" "showmenu equipment" newmenu "primary" -menuitem "Mtp 57 Assault Rifle" "item 5;echo MK-77 Assault Rifle chosen" -menuitem "A-ARD/10 Submachine Gun" "item 3;echo A-ARD/10 Submachine Gun chosen" -menuitem "Precision Tech AD-81 Sniper Rifle" "item 4,echo Precision Tech AD-81 Sniper Rifle chosen" -menuitem "V-19 Combat Shotgun" "item 2;echo V-19 Combat Shotgun chosen" +//menumdl vwep/assault 0 1 40 60 +menuitem "Mtp 57 Assault Rifle" "item 5;echo MK-77 Assault Rifle chosen" // "chmenumdl primary vwep/assault 0 1 40 60" +menuitem "A-ARD/10 Submachine Gun" "item 3;echo A-ARD/10 Submachine Gun chosen" "chmenumdl primary vwep/subgun 0 1 40 60" +menuitem "Precision Tech AD-81 Sniper Rifle" "item 4,echo Precision Tech AD-81 Sniper Rifle chosen" "chmenumdl primary vwep/sniper 0 1 40 60" +menuitem "V-19 Combat Shotgun" "item 2;echo V-19 Combat Shotgun chosen" "chmenumdl primary vwep/shotgun 0 1 40 60" newmenu "secondary" -menuitem "Mk-77 Semi-Automatic Pistol" "item 1;echo MTP 57 Semi-Automatic Pistol Chosen" +menumdl vwep/semipistol 0 1 40 60 +menuitem "Mk-77 Semi-Automatic Pistol" "item 1;echo MTP 57 Semi-Automatic Pistol Chosen" newmenu "equipment" -menuitem "DR-17 HE-Grenade" "echo DR-17 HE-Grenade chosen" -menuitem "SN-Tech Kelvar Vest" "echo SN-Tech Kelvar Vest chosen" +menumdl vwep/grenade_static 0 1 40 80 +menuitem "DR-17 HE-Grenade" "echo DR-17 HE-Grenade chosen" "chmenumdl equipment vwep/grenade_static 0 1 40 80" +menuitem "SN-Tech Kelvar Vest" "echo SN-Tech Kelvar Vest chosen" "chmenumdl equipment pickups/kevlar 0 1 40 20" newmenu options diff --git a/packages/models/vwep/grenade_static/skin.jpg b/packages/models/vwep/grenade_static/skin.jpg new file mode 100644 index 00000000..466279ec Binary files /dev/null and b/packages/models/vwep/grenade_static/skin.jpg differ diff --git a/packages/models/vwep/grenade_static/tris.md2 b/packages/models/vwep/grenade_static/tris.md2 new file mode 100644 index 00000000..7292a80c Binary files /dev/null and b/packages/models/vwep/grenade_static/tris.md2 differ diff --git a/source/src/command.cpp b/source/src/command.cpp index 2365f26e..99dd971c 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -165,7 +165,8 @@ int execute(char *p, bool isdown) // all evaluation happens here, case ARG_1STR: if(isdown) ((void (__cdecl *)(char *))id->fun)(w[1]); break; case ARG_2STR: if(isdown) ((void (__cdecl *)(char *, char *))id->fun)(w[1], w[2]); break; case ARG_3STR: if(isdown) ((void (__cdecl *)(char *, char *, char*))id->fun)(w[1], w[2], w[3]); break; - case ARG_5STR: if(isdown) ((void (__cdecl *)(char *, char *, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5]); break; + case ARG_5STR: if(isdown) ((void (__cdecl *)(char *, char *, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5]); break; + case ARG_6STR: if(isdown) ((void (__cdecl *)(char *, char *, char*, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5], w[6]); break; case ARG_DOWN: ((void (__cdecl *)(bool))id->fun)(isdown); break; case ARG_DWN1: ((void (__cdecl *)(bool, char *))id->fun)(isdown, w[1]); break; case ARG_1EXP: if(isdown) val = ((int (__cdecl *)(int))id->fun)(execute(w[1])); break; diff --git a/source/src/cube.h b/source/src/cube.h index b7a1187f..0e270faf 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -305,7 +305,7 @@ enum // function signatures for script functions, see command.cpp { ARG_1INT, ARG_2INT, ARG_3INT, ARG_4INT, ARG_NONE, - ARG_1STR, ARG_2STR, ARG_3STR, ARG_5STR, + ARG_1STR, ARG_2STR, ARG_3STR, ARG_5STR, ARG_6STR, ARG_DOWN, ARG_DWN1, ARG_1EXP, ARG_2EXP, ARG_1EST, ARG_2EST, diff --git a/source/src/menus.cpp b/source/src/menus.cpp index 0a61a7de..cff6dc56 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -1,15 +1,20 @@ // menus.cpp: ingame menu system (also used for scores and serverlist) -#include "cube.h" +#include "cube.h" + +#define FIRSTMENU 90 -struct mitem { char *text, *action; }; +struct mitem { char *text, *action, *hoveraction; }; struct gmenu { char *name; vector items; int mwidth; - int menusel; + int menusel; + int tex; // (optional) bg tex + char *mdl; // (optional) md2 mdl + int frame, range, rotspeed, scale; }; vector menus; @@ -68,7 +73,7 @@ bool rendermenu() int h = (mdisp+2)*step; int y = (VIRTH-h)/2; int x = (VIRTW-w)/2; - blendbox(x-FONTH/2*3, y-FONTH, x+w+FONTH/2*3, y+h+FONTH, true); + blendbox(x-FONTH/2*3, y-FONTH, x+w+FONTH/2*3, y+h+FONTH, true, m.tex >= 0 ? FIRSTMENU + m.tex : -1); draw_text(title, x, y,2); y += FONTH*2; if(vmenu) @@ -82,13 +87,35 @@ bool rendermenu() y += step; }; return true; -}; +}; + +void rendermenumdl() // nasty s*** +{ + if(vmenu<0) { menustack.setsize(0); return false; }; + if(vmenu==1) refreshservers(); + gmenu &m = menus[vmenu]; + if(!m.mdl) return; + + glPushMatrix (); + + glTranslatef(player1->o.x, player1->o.z, player1->o.y); + glRotatef(player1->yaw+90+180, 0, -1, 0); + glRotatef(player1->pitch, 0, 0, 1); + + glTranslatef(2, 0, 0); + if(m.rotspeed) glRotatef(lastmillis/5.0f/100.0f*m.rotspeed, 0, 1, 0); + + rendermodel(m.mdl, m.frame, m.range, 0, 5.0f, 0, 0, 0, 0, 0, false, (float)(m.scale ? m.scale/25.0f : 1), 100, 0, 0); + glPopMatrix(); +} void newmenu(char *name) { gmenu &menu = menus.add(); menu.name = newstring(name); - menu.menusel = 0; + menu.menusel = 0; + menu.tex = -1; + menu.mdl = NULL; }; void menumanual(int m, int n, char *text) @@ -99,29 +126,77 @@ void menumanual(int m, int n, char *text) mitem.action = ""; } -void menuitem(char *text, char *action) +void menuitem(char *text, char *action, char *hoveraction) { gmenu &menu = menus.last(); mitem &mi = menu.items.add(); mi.text = newstring(text); - mi.action = action[0] ? newstring(action) : mi.text; + mi.action = action[0] ? newstring(action) : mi.text; + if(hoveraction) mi.hoveraction = newstring(hoveraction); + else mi.hoveraction = NULL; }; + +void menubg(char *tex) +{ + gmenu &menu = menus.last(); + int curmtex = 0; + loopv(menus) curmtex = max(curmtex, menus[i].tex); + if(curmtex>=100) return; + sprintf_sd(path)("packages/%s", tex); + int xs, ys; + if(installtex(FIRSTMENU + curmtex, path, xs, ys, false, true)) + menu.tex = curmtex; +}; + +void menumdl(char *mdl, char *frame, char *range, char *rotspeed, char *scale) +{ + if(!mdl || !frame || !range) return; + gmenu &menu = menus.last(); + menu.mdl = newstring(mdl, _MAXDEFSTR); + menu.frame = max(0, atoi(frame)); + menu.range = max(1, atoi(range)); + menu.rotspeed = max(0, min(atoi(rotspeed), 100)); + menu.scale = max(0, min(atoi(scale), 100)); +}; + +void chmenumdl(char *menu, char *mdl, char *frame, char *range, char *rotspeed, char *scale) +{ + if(!menu || !mdl) return; + loopv(menus) + { + gmenu &m = menus[i]; + if(strcmp(m.name, menu) == 0) + { + if(m.mdl) strcpy_s(m.mdl, mdl); + else m.mdl = newstring(mdl, _MAXDEFSTR); + m.frame = atoi(frame); + m.range = atoi(range); + m.rotspeed = max(0, min(atoi(rotspeed), 100)); + m.scale = max(0, min(atoi(scale), 100)); + return; + }; + }; +}; + -COMMAND(menuitem, ARG_2STR); +COMMAND(menuitem, ARG_3STR); COMMAND(showmenu, ARG_1STR); -COMMAND(newmenu, ARG_1STR); +COMMAND(newmenu, ARG_1STR); +COMMAND(menubg, ARG_1STR); +COMMAND(menumdl, ARG_5STR); +COMMAND(chmenumdl, ARG_6STR); bool menukey(int code, bool isdown) { if(vmenu<=0) return false; int menusel = menus[vmenu].menusel; if(isdown) - { + { + int oldmenusel = menusel; if(code==SDLK_ESCAPE) { menuset(-1); if(!menustack.empty()) menuset(menustack.pop()); - execute("musicvol 1"); return true; } else if(code==SDLK_UP || code==-4) menusel--; @@ -129,7 +204,8 @@ bool menukey(int code, bool isdown) int n = menus[vmenu].items.length(); if(menusel<0) menusel = n-1; else if(menusel>=n) menusel = 0; - menus[vmenu].menusel = menusel; + menus[vmenu].menusel = menusel; + if(menusel != oldmenusel)execute(menus[vmenu].items[menusel].hoveraction, true); } else { diff --git a/source/src/protos.h b/source/src/protos.h index 22ce90d1..a73d7ae1 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -26,7 +26,8 @@ extern void menuset(int menu); extern void menumanual(int m, int n, char *text); extern void sortmenu(int start, int num); extern bool menukey(int code, bool isdown); -extern void newmenu(char *name); +extern void newmenu(char *name); +extern void rendermenumdl(); // serverbrowser extern void addserver(char *servername); @@ -158,7 +159,7 @@ extern void newsphere(vec &o, float max, int type); extern void renderspheres(int time); extern void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater); extern void readdepth(int w, int h); -extern void blendbox(int x1, int y1, int x2, int y2, bool border); +extern void blendbox(int x1, int y1, int x2, int y2, bool border, int tex = -1); extern void damageblend(int n); extern void addshotline(dynent *d, vec &from, vec &to); extern void rendershotlines(); diff --git a/source/src/renderextras.cpp b/source/src/renderextras.cpp index 64df1bd8..e6fdcd35 100644 --- a/source/src/renderextras.cpp +++ b/source/src/renderextras.cpp @@ -42,25 +42,35 @@ void dot(int x, int y, float z) xtraverts += 4; }; -void blendbox(int x1, int y1, int x2, int y2, bool border) +void blendbox(int x1, int y1, int x2, int y2, bool border, int tex=-1) { glDepthMask(GL_FALSE); - glDisable(GL_TEXTURE_2D); - glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); + glDisable(GL_TEXTURE_2D); + if(tex>=0) + { + glBindTexture(GL_TEXTURE_2D, tex); + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + } + else + { + if(border) glColor3d(0.7, 0.7, 0.7); //glColor3d(0.5, 0.3, 0.4); + else glColor3d(1.0, 1.0, 1.0); + glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); + }; glBegin(GL_QUADS); - if(border) glColor3d(0.7, 0.7, 0.7); //glColor3d(0.5, 0.3, 0.4); - else glColor3d(1.0, 1.0, 1.0); - glVertex2i(x1, y1); - glVertex2i(x2, y1); - glVertex2i(x2, y2); - glVertex2i(x1, y2); + glTexCoord2f(0, 0); glVertex2i(x1, y1); + glTexCoord2f(1, 0); glVertex2i(x2, y1); + glTexCoord2f(1, 1); glVertex2i(x2, y2); + glTexCoord2f(0, 1); glVertex2i(x1, y2); glEnd(); - glDisable(GL_BLEND); + glDisable(GL_BLEND); + if(tex>=0) glDisable(GL_TEXTURE_2D); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glBegin(GL_POLYGON); glColor3d(0.6, 0.6, 0.6); //glColor3d(0.2, 0.7, 0.4); glVertex2i(x1, y1); - glVertex2i(x2, y1); + glVertex2i(x2, y1); glVertex2i(x2, y2); glVertex2i(x1, y2); glEnd(); @@ -391,7 +401,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat int r = 64; if(g>2) { g -= 3; r = 128; }; - if(player1->ammo[player1->gunselect] < magsize(player1->gunselect)) + if(!player1->mag[player1->gunselect] && player1->gunselect != GUN_KNIFE && player1->gunselect != GUN_GRENADE) { glEnable(GL_BLEND); drawicon((float)(g*64), (float)r, 1220, 1650); @@ -483,7 +493,7 @@ void renderphysents() loopv(physents) { physent *d = physents[i]; - if(d && d->throwed) rendermodel("vwep/grenade", 173, 1, 0, 0.2f, d->o.x, d->o.z, d->o.y, 0, 0, false, 2.0f, 100, 0, 0); + if(d && d->throwed) rendermodel("vwep/grenade_static", 0, 1, 0, 0, d->o.x, d->o.z, d->o.y, d->yaw, d->pitch, false, 2.0f, 100.0f, 0, 0); }; }; diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index 96bcc46f..be0d844f 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -78,7 +78,7 @@ bool installtex(int tnum, char *texname, int &xs, int &ys, bool clamp, bool high glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, clamp ? GL_CLAMP_TO_EDGE : GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, clamp ? GL_CLAMP_TO_EDGE : GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, highqual ? GL_LINEAR : GL_LINEAR_MIPMAP_LINEAR); //NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, highqual ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR); //NEAREST); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); xs = s->w; ys = s->h; @@ -106,7 +106,7 @@ int texy[MAXTEX]; string texname[MAXTEX]; int curtex = 0; const int FIRSTTEX = 100; // opengl id = loaded id + FIRSTTEX -// std 1+, sky 14+, mdls 20+ +// std 1+, sky 14+, md3's 30+,md2's 40+, menu 90+ const int MAXFRAMES = 2; // increase to allow more complex shader defs int mapping[256][MAXFRAMES]; // ( cube texture, frame ) -> ( opengl id, name ) @@ -295,7 +295,8 @@ void drawhudgun(int w, int h, float aspect, int farplane) gluPerspective((float)100.0f*h/w, aspect, 0.3f, farplane); // fov fixed at 100° glMatrixMode(GL_MODELVIEW); - rendermd3gun(); + rendermd3gun(); + rendermenumdl(); // lazy bastard glMatrixMode(GL_PROJECTION); glLoadIdentity(); diff --git a/source/src/rendermd2.cpp b/source/src/rendermd2.cpp index 80a70d03..cad941eb 100644 --- a/source/src/rendermd2.cpp +++ b/source/src/rendermd2.cpp @@ -249,7 +249,7 @@ void rendermodel(char *mdl, int frame, int range, int tex, float rad, float x, f { md2 *m = loadmodel(mdl); - if(isoccluded(player1->o.x, player1->o.y, x-rad, z-rad, rad*2)) return; + //if(isoccluded(player1->o.x, player1->o.y, x-rad, z-rad, rad*2)) return; delayedload(m); diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 30bcc5c5..74a71576 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -308,7 +308,7 @@ extern float rad(float x); bool nade_activated = false; physent *curnade; -void thrownade(dynent *d, vec &to, dynent *nade = NULL, int nadesec = 0) +void thrownade(dynent *d, vec &to, physent *nade = NULL, int nadesec = 0) { physent *p; if(nade) p = nade; @@ -356,21 +356,19 @@ void thrownade(dynent *d, vec &to, dynent *nade = NULL, int nadesec = 0) p->lifetime = 3000; p->o = d->o; - p->o.z += d->eyeheight; + +// float speed = sin(rad((d->pitch+90)/2.0f)); + p->vel.z = sin(rad(d->pitch)); + float speed = cos(rad(d->pitch)); + p->vel.x = sin(rad(d->yaw))*speed; + p->vel.y = -cos(rad(d->yaw))*speed; - p->vel.x = sin(rad(d->yaw)); - p->vel.y = -cos(rad(d->yaw)); - p->vel.z = 0; - - //float speed = min(135, d->pitch+45)/135; - float speed = sin(rad((d->pitch+90)/2)); - p->vel.x *= speed; - p->vel.y *= speed; - - p->vel.z = speed; -// p->vel.z = (d->pitch+90)/180*2.5f; - //p->vel.z = cos(rad(d->pitch+90)); - //vmul(p->vel, 2.0f); + vmul(p->vel, 1.5f); + + vec throwdir = p->vel; + vmul(throwdir, d->radius); + vadd(p->o, throwdir); + vadd(p->o, throwdir); if(!nade) // add new one { @@ -597,6 +595,7 @@ void shoot(dynent *d, vec &targ) if(d->gunselect==GUN_SHOTGUN) createrays(from, to); //if(d->quadmillis && attacktime>200) playsoundc(S_ITEMPUP); + shootv(d->gunselect, from, to, d, 0); addmsg(1, 9, SV_SHOT, d->gunselect, (int)(from.x*DMF), (int)(from.y*DMF), (int)(from.z*DMF), (int)(to.x*DMF), (int)(to.y*DMF), (int)(to.z*DMF), (int) grenade_throw ? lastmillis-curnade->millis : 0 ); d->gunwait = guns[d->gunselect].attackdelay;