From 80c024f151878facc3d4476e7631d813cc4c0414 Mon Sep 17 00:00:00 2001 From: Rafael Barreto Date: Wed, 11 Aug 2010 23:57:43 +0000 Subject: [PATCH] fix quick switch, include perm nade icon (to control better how many nades someone is carrying), clean up, different gib messages (as suggested in the forum) git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5602 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 12 ++++++++---- source/src/clients2c.cpp | 2 +- source/src/entity.h | 28 +++++++++++++++++++--------- source/src/protos.h | 2 +- source/src/renderhud.cpp | 27 ++++++++++++++++----------- source/src/server.cpp | 2 +- source/src/weapon.cpp | 11 +++++++---- 7 files changed, 53 insertions(+), 31 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 84d87102..b7ddae1c 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -634,7 +634,7 @@ VARP(hitsound, 0, 0, 1); // damage arriving from the network, monsters, yourself, all ends up here. -void dodamage(int damage, playerent *pl, playerent *actor, bool gib, bool local) +void dodamage(int damage, playerent *pl, playerent *actor, int gun, bool gib, bool local) { if(pl->state != CS_ALIVE || intermission) return; @@ -647,7 +647,11 @@ void dodamage(int damage, playerent *pl, playerent *actor, bool gib, bool local) lasthit = lastmillis; } - damageeffect(damage, pl); + if (pl != player1) + { + damageeffect(damage, pl); + audiomgr.playsound(S_PAIN1+rnd(5), pl); + } if(local) damage = pl->dodamage(damage); else if(actor==player1) return; @@ -659,7 +663,7 @@ void dodamage(int damage, playerent *pl, playerent *actor, bool gib, bool local) pl->damageroll(damage); } - if(pl->health<=0) { if(local) dokill(pl, actor, gib, actor->weaponsel->type); } + if(pl->health<=0) { if(local) dokill(pl, actor, gib, gun >= 0 ? gun : actor->weaponsel->type); } else if(pl==player1) audiomgr.playsound(S_PAIN6, SP_HIGH); else audiomgr.playsound(S_PAIN1+rnd(5), pl); } @@ -671,7 +675,7 @@ void dokill(playerent *pl, playerent *act, bool gib, int gun) string pname, aname, death; copystring(pname, pl==player1 ? "you" : colorname(pl)); copystring(aname, act==player1 ? "you" : colorname(act)); - copystring(death, gib ? "gibbed" : "fragged"); + copystring(death, gib ? gib_message(gun) : "fragged"); void (*outf)(const char *s, ...) = (pl == player1 || act == player1) ? hudoutf : conoutf; if(pl==act) diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 92a90f49..7e460365 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -651,7 +651,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) if(!target || !actor) break; target->armour = armour; target->health = health; - dodamage(damage, target, actor, type==SV_GIBDAMAGE, false); + dodamage(damage, target, actor, -1, type==SV_GIBDAMAGE, false); break; } diff --git a/source/src/entity.h b/source/src/entity.h index 2de1bdcf..5c78b9f1 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -52,7 +52,6 @@ enum { GUN_KNIFE = 0, GUN_PISTOL, GUN_RIFLE, GUN_SHOTGUN, GUN_SUBGUN, GUN_SNIPER struct itemstat { int add, start, max, sound; }; extern itemstat ammostats[NUMGUNS]; - extern itemstat powerupstats[I_ARMOUR-I_HEALTH+1]; struct guninfo { string modelname; short sound, reload, reloadtime, attackdelay, damage, projspeed, part, spread, recoil, magsize, mdl_kick_rot, mdl_kick_back, recoilincrease, recoilbase, maxrecoil, recoilbackfade, pushfactor; bool isauto; }; @@ -237,8 +236,8 @@ public: { switch(type) { - case I_CLIPS: { return ammostats[GUN_PISTOL]; } - case I_AMMO: { return ammostats[primary]; } + case I_CLIPS: return ammostats[GUN_PISTOL]; + case I_AMMO: return ammostats[primary]; case I_GRENADE: return ammostats[GUN_GRENADE]; case I_AKIMBO: return ammostats[GUN_AKIMBO]; case I_HEALTH: @@ -282,9 +281,9 @@ public: case I_AMMO: additem(ammostats[primary], ammo[primary]); break; case I_GRENADE: additem(ammostats[GUN_GRENADE], mag[GUN_GRENADE]); break; case I_HEALTH: additem(powerupstats[type-I_HEALTH], health); break; - case I_HELMET: + case I_HELMET: case I_ARMOUR: - additem(powerupstats[type-I_HEALTH], armour); break; + additem(powerupstats[type-I_HEALTH], armour); break; case I_AKIMBO: akimbo = true; mag[GUN_AKIMBO] = guns[GUN_AKIMBO].magsize; @@ -469,7 +468,6 @@ public: extern int lastmillis; weaponsel->ondeselecting(); weaponchanging = lastmillis; - prevweaponsel = weaponsel; nextweaponsel = w; w->onselecting(); } @@ -513,10 +511,10 @@ enum { CTFF_INBASE = 0, CTFF_STOLEN, CTFF_DROPPED, CTFF_IDLE }; struct flaginfo { - int team; + int team; entity *flagent; - int actor_cn; - playerent *actor; + int actor_cn; + playerent *actor; vec pos; int state; // one of CTFF_* bool ack; @@ -577,3 +575,15 @@ public: enum {MD_FRAGS = 0, MD_DEATHS, END_MDS}; struct medalsst {bool assigned; int cn; int item;}; + +inline const char * gib_message(int gun) +{ + switch (gun) + { + case GUN_KNIFE: return "knifed"; + case GUN_SNIPER: return "headshotted"; + case GUN_SHOTGUN: return "splattered"; + case GUN_GRENADE: + default: return "gibbed"; + } +} diff --git a/source/src/protos.h b/source/src/protos.h index c8e37a63..44cd3298 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -344,7 +344,7 @@ extern void changemap(const char *name); extern void initclient(); extern void deathstate(playerent *pl); extern void spawnplayer(playerent *d); -extern void dodamage(int damage, playerent *pl, playerent *actor, bool gib = false, bool local = true); +extern void dodamage(int damage, playerent *pl, playerent *actor, int gun = -1, bool gib = false, bool local = true); extern void dokill(playerent *pl, playerent *act, bool gib = false, int gun = 0); extern playerent *newplayerent(); extern botent *newbotent(); diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 1b54c991..abd7af0d 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -203,7 +203,7 @@ void drawcrosshair(playerent *p, int n, color *c, float size) } } float s = size>0 ? size : (float)crosshairsize; - float chsize = s * (p->weaponsel->type==GUN_ASSAULT && p->weaponsel->shots > 3 ? 1.4f : 1.0f) * (n==CROSSHAIR_TEAMMATE ? 2.0f : 1.0f); + float chsize = s * (p->weaponsel->type==GUN_ASSAULT && p->weaponsel->shots > 3 ? 1.4f : 1.0f) * (n==CROSSHAIR_TEAMMATE ? 2.0f : 1.0f); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, 0); glVertex2f(VIRTW/2 - chsize, VIRTH/2 - chsize); glTexCoord2f(1, 0); glVertex2f(VIRTW/2 + chsize, VIRTH/2 - chsize); @@ -268,6 +268,8 @@ void drawdmgindicator() glEnable(GL_TEXTURE_2D); } +VARP(xpos1, 0, 1700, 3000); // REMOVE + void drawequipicons(playerent *p) { glDisable(GL_BLEND); @@ -277,14 +279,15 @@ void drawequipicons(playerent *p) // health & armor if(p->armour) drawequipicon(620, 1650, (p->armour-1)/25, 2, false); drawequipicon(20, 1650, 2, 3, (p->state!=CS_DEAD && p->health<=20 && !m_osok)); + if(p->mag[GUN_GRENADE]) drawequipicon(xpos1, 1650, 3, 1, false); // weapons - int c = p->weaponsel->type, r = 0; + int c = p->weaponsel->type != GUN_GRENADE ? p->weaponsel->type : p->prevweaponsel->type, r = 0; if(c==GUN_AKIMBO || c==GUN_CPISTOL) c = GUN_PISTOL; // same icon for akimb & pistol - if(c==GUN_GRENADE) c--; // FIXME if(c>3) { c -= 4; r = 1; } - if(p->weaponsel && p->weaponsel->type>=GUN_KNIFE && p->weaponsel->typeweaponsel->mag && p->weaponsel->type != GUN_KNIFE && p->weaponsel->type != GUN_GRENADE)); + if(p->weaponsel && p->weaponsel->type>=GUN_KNIFE && p->weaponsel->typeweaponsel->mag && p->weaponsel->type != GUN_KNIFE && p->weaponsel->type != GUN_GRENADE)); glEnable(GL_BLEND); } @@ -893,12 +896,12 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat if(!hidespecthud && spectating && player1->spectatemode!=SM_DEATHCAM) { glLoadIdentity(); - glOrtho(0, VIRTW, VIRTH, 0, -1, 1); - const char *specttext = "GHOST [free]";//SPECTATING"; - if(player1->team == TEAM_SPECT) specttext = "GHOST"; - else if(player1->team == TEAM_CLA_SPECT) specttext = "[CLA]"; - else if(player1->team == TEAM_RVSF_SPECT) specttext = "[RVSF]"; - draw_text(specttext, VIRTW/40, VIRTH/10*7); + glOrtho(0, VIRTW, VIRTH, 0, -1, 1); + const char *specttext = "GHOST [free]";//SPECTATING"; + if(player1->team == TEAM_SPECT) specttext = "GHOST"; + else if(player1->team == TEAM_CLA_SPECT) specttext = "[CLA]"; + else if(player1->team == TEAM_RVSF_SPECT) specttext = "[RVSF]"; + draw_text(specttext, VIRTW/40, VIRTH/10*7); if(player1->spectatemode==SM_FOLLOW1ST || player1->spectatemode==SM_FOLLOW3RD || player1->spectatemode==SM_FOLLOW3RD_TRANSPARENT) { if(players.inrange(player1->followplayercn) && players[player1->followplayercn]) @@ -922,7 +925,9 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat if(p->weaponsel && p->weaponsel->type>=GUN_KNIFE && p->weaponsel->typeweaponsel->renderstats(); + if (p->weaponsel->type!=GUN_GRENADE) p->weaponsel->renderstats(); + else p->prevweaponsel->renderstats(); + if(p->mag[GUN_GRENADE]) p->weapons[GUN_GRENADE]->renderstats(); glMatrixMode(GL_PROJECTION); } popfont(); diff --git a/source/src/server.cpp b/source/src/server.cpp index d5b47b10..cb475270 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -1337,7 +1337,7 @@ void serverdamage(client *target, client *actor, int damage, int gun, bool gib, target->position.setsize(0); ts.state = CS_DEAD; ts.lastdeath = gamemillis; - if(!suic) logline(ACLOG_INFO, "[%s] %s %s%s %s", actor->hostname, actor->name, gib ? (gun==GUN_GRENADE?"splattered":"gibbed") : "fragged", tk ? " his teammate" : "", target->name); + if(!suic) logline(ACLOG_INFO, "[%s] %s %s%s %s", actor->hostname, actor->name, gib ? gib_message(gun) : "fragged", tk ? " his teammate" : "", target->name); if(m_flags && targethasflag >= 0) { if(m_ctf) diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index d35fe887..decdaa2c 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -23,8 +23,9 @@ void checkweaponswitch() addmsg(SV_WEAPCHANGE, "ri", player1->weaponsel->type); player1->weaponchanging = 0; } - else if(timeprogress>weapon::weaponchangetime/2) + else if(timeprogress>(weapon::weaponchangetime>>1) && player1->weaponsel != player1->nextweaponsel) { + player1->prevweaponsel = player1->weaponsel; player1->weaponsel = player1->nextweaponsel; } } @@ -349,7 +350,7 @@ void hit(int damage, playerent *d, playerent *at, const vec &vel, int gun, bool // lasthit = lastmillis; // } - if(!m_mp(gamemode)) dodamage(damage, d, at, gib); + if(!m_mp(gamemode)) dodamage(damage, d, at, gun, gib); else { hitmsg &h = hits.add(); @@ -369,7 +370,7 @@ void hit(int damage, playerent *d, playerent *at, const vec &vel, int gun, bool { h.dir = ivec(int(vel.x*DNF), int(vel.y*DNF), int(vel.z*DNF)); // damageeffect(damage, d); - audiomgr.playsound(S_PAIN1+rnd(5), d); +// audiomgr.playsound(S_PAIN1+rnd(5), d); } } } @@ -944,11 +945,13 @@ void grenades::dropnade() thrownade(n); } +VARP(xpos2, 0, 920, 3000); // REMOVE + void grenades::renderstats() { char gunstats[64]; sprintf(gunstats, "%i", mag); - draw_text(gunstats, 690, 827); + draw_text(gunstats, xpos2, 827); } bool grenades::selectable() { return weapon::selectable() && state != GST_INHAND && mag; }