From 9e6147ebfeeaf78ca6989a48f62bc1cf6bc50130 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Tue, 16 Jan 2007 02:03:54 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@823 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientextras.cpp | 7 ------- source/src/cube.h | 1 + source/src/protos.h | 2 +- source/src/renderextras.cpp | 8 ++++---- source/src/rendergl.cpp | 2 ++ source/src/weapon.cpp | 11 +++++++---- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/source/src/clientextras.cpp b/source/src/clientextras.cpp index 38575c3e..de7dfa88 100644 --- a/source/src/clientextras.cpp +++ b/source/src/clientextras.cpp @@ -60,13 +60,6 @@ void renderclients() playerent *d; loopv(players) if((d = players[i]) && (!demoplayback || i!=democlientnum)) { -#if 0 - if(strcmp(d->name, "dummy") == 0) - { - d->gunselect = player1->gunselect; - d->health != 1 ? d->state=CS_ALIVE : d->state=CS_DEAD; - }; -#endif renderplayer(d); }; diff --git a/source/src/cube.h b/source/src/cube.h index 77b07616..f07c0fe7 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -113,6 +113,7 @@ extern vector bounceents; extern bool editmode; extern vector ents; // map entities extern vec worldpos, camup, camright; // current target of the crosshair in the world +extern vec hitpos; extern int lastmillis; // last time extern int curtime; // current frame time extern int gamemode, nextmode; diff --git a/source/src/protos.h b/source/src/protos.h index 8526b9b3..7aaf0e3d 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -196,7 +196,7 @@ extern void linestyle(float width, int r, int g, int b); 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 readdepth(int w, int h, vec &pos = worldpos); 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); diff --git a/source/src/renderextras.cpp b/source/src/renderextras.cpp index 08385a96..42841127 100644 --- a/source/src/renderextras.cpp +++ b/source/src/renderextras.cpp @@ -246,14 +246,14 @@ float depthcorrect(float d) // also hits map entities which is unwanted. // could be replaced by a more acurate version of monster.cpp los() if needed -void readdepth(int w, int h) +void readdepth(int w, int h, vec &pos) { glReadPixels(w/2, h/2, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &cursordepth); double worldx = 0, worldy = 0, worldz = 0; gluUnProject(w/2, h/2, depthcorrect(cursordepth), mm, pm, viewport, &worldx, &worldz, &worldy); - worldpos.x = (float)worldx; - worldpos.y = (float)worldy; - worldpos.z = (float)worldz; + pos.x = (float)worldx; + pos.y = (float)worldy; + pos.z = (float)worldz; }; void drawicon(float tx, float ty, int x, int y, Texture *tex = NULL, float scaling = 1/3.0f) // EDIT: AH diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index 597ef8d1..f238b2d5 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -418,6 +418,8 @@ void gl_drawframe(int w, int h, float changelod, float curfps) renderclients(); + if(player1->state==CS_ALIVE) readdepth(w, h, hitpos); + renderspheres(curtime); renderents(); diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 1312ee17..1af66bce 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -463,6 +463,9 @@ void shorten(vec &from, vec &to, vec &target) target.sub(from).normalize().mul(from.dist(to)).add(from); }; +const float HEADSIZE = 0.8f; +vec hitpos; + void raydamage(vec &from, vec &to, playerent *d) { int i = -1, gdam = guns[d->gunselect].damage; @@ -495,10 +498,10 @@ void raydamage(vec &from, vec &to, playerent *d) } else if((o = intersectclosest(from, to, i, d))) { - playerent head = *o; // check headshot - head.eyeheight = head.aboveeye/4; - head.radius = 2; - if(d->gunselect == GUN_SNIPER && intersect(&head, from, to)) gdam = guns[d->gunselect].damage * 3; + if(d==player1 && d->gunselect==GUN_SNIPER + && worldpos!=hitpos && hitpos.z>=o->o.z+o->aboveeye-HEADSIZE + && intersect(o, from, hitpos)) + gdam *= 3; hitpush(i, gdam, o, d, from, to); shorten(from, o->o, to);