diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index ba424a40..4cd3b779 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -243,6 +243,15 @@ VARP(autoscreenshot, 0, 0, 1); void deathstate(playerent *pl) { + /* + TODO:FIXME: talk to DES|V-Man about passing arguments + if(pl==player1) + { + // execute ondeath event + const char *ondeath = getalias("ondeath"); + if(ondeath && ondeath[0]) { addsleep(0, ondeath); } + } + */ pl->state = CS_DEAD; pl->spectatemode = SM_DEATHCAM; pl->respawnoffset = pl->lastpain = lastmillis; @@ -278,6 +287,7 @@ void spawnstate(playerent *d) // reset player state not persistent setscope(false); setburst(false); } + if(d->deaths==0) d->resetstats(); //NEW } playerent *newplayerent() // create a new blank player @@ -636,6 +646,15 @@ VARP(hitsound, 0, 0, 1); void dodamage(int damage, playerent *pl, playerent *actor, int gun, bool gib, bool local) { + /* + TODO:FIXME: talk to DES|V-Man about passing arguments + // execute ondamage event + if(pl==player1) + { + const char *ondamage = getalias("ondamage"); + if(ondamage && ondamage[0]) { addsleep(0, ondamage); } + } + */ if(pl->state != CS_ALIVE || intermission) return; pl->respawnoffset = pl->lastpain = lastmillis; @@ -708,12 +727,66 @@ void dokill(playerent *pl, playerent *act, bool gib, int gun) audiomgr.playsound(S_DIE1+rnd(2), pl); } -VAR(minutesremaining, 1, 0, 0); - -void timeupdate(int timeremain) +void pstat_score(int cn) { - minutesremaining = timeremain; - if(!timeremain) + if(intermission) + { + string scorestring; + int p_flags = 0; + int p_frags = 0; + int p_deaths = 0; + int p_points = 0; + playerent *pl = cn==player1->clientnum?player1:getclient(cn); + if(pl) + { + p_flags = pl->flagscore; + p_frags = pl->frags; + p_deaths = pl->deaths; + p_points = pl->points; + } + formatstring(scorestring)("%d %d %d %d %d %s", p_flags, p_frags, p_deaths, p_points, pl ? pl->team : -1, pl ? pl->name : "\"\""); + result(scorestring); + } + else result("0 0 0 0 -1 \"\""); +} +COMMAND(pstat_score, ARG_1INT); + +void pstat_weap(int cn) +{ + if(intermission) + { + string wbuf; + defformatstring(weapstring)(""); + playerent *pl = cn==player1->clientnum?player1:getclient(cn); + loopi(NUMGUNS) + { + if(pl) formatstring(wbuf)("%s%s%d %d", weapstring, strlen(weapstring)?" ":"", pl->pstatshots[i], pl->pstatdamage[i]); + else formatstring(wbuf)("%s%s0 0", weapstring, strlen(weapstring)?" ":""); + copystring(weapstring, wbuf); + } + result(weapstring); + } + else + { + defformatstring(weapstring)(""); + loopi(NUMGUNS) { defformatstring(wbuf)("%s%s0 0", weapstring, strlen(weapstring)?" ":""); copystring(weapstring, wbuf); } + result(weapstring); + } +} +COMMAND(pstat_weap, ARG_1INT); + +VAR(minutesremaining, 1, 0, 0); +VAR(gametimecurrent, 1, 0, 0); +VAR(gametimemaximum, 1, 0, 0); +int lastgametimeupdate = 0; +void timeupdate(int milliscur, int millismax) +{ + lastgametimeupdate = lastmillis; + gametimecurrent = milliscur; + gametimemaximum = millismax; + int millisremaining = gametimemaximum - gametimecurrent; + minutesremaining = ceil((1.0f*millisremaining)/60000.0f); + if(!millisremaining) { intermission = true; extern bool needsautoscreenshot; @@ -727,8 +800,9 @@ void timeupdate(int timeremain) } else { - conoutf(_("time remaining: %d minutes"), timeremain); - if(timeremain==1) + extern int clockdisplay; // only output to console if no hud-clock is being shown + if(clockdisplay==0) conoutf(_("time remaining: %d minutes"), minutesremaining); + if(millisremaining==60000) { audiomgr.musicsuggest(M_LASTMINUTE1 + rnd(2), 70*1000, true); hudoutf("1 minute left!"); diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 37d5781a..055b4723 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -540,6 +540,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) loopi(NUMGUNS) s->ammo[i] = getint(p); loopi(NUMGUNS) s->mag[i] = getint(p); s->state = CS_SPAWNING; + if(s->lifesequence==0) s->resetstats(); //NEW break; } @@ -580,7 +581,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) addmsg(SV_SPAWN, "rii", player1->lifesequence, player1->weaponsel->type); player1->weaponswitch(player1->primweap); player1->weaponchanging -= weapon::weaponchangetime/2; - + if(player1->lifesequence==0) player1->resetstats(); //NEW break; } @@ -604,6 +605,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) s->lastattackweapon = s->weapons[gun]; s->weapons[gun]->attackfx(from, to, -1); } + s->pstatshots[gun]++; //NEW break; } @@ -664,6 +666,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) { int tcn = getint(p), acn = getint(p), + gun = getint(p), damage = getint(p), armour = getint(p), health = getint(p); @@ -673,6 +676,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) target->armour = armour; target->health = health; dodamage(damage, target, actor, -1, type==SV_GIBDAMAGE, false); + actor->pstatdamage[gun]+=damage; //NEW //FIXME - no gun info provided, can we fix that? break; } @@ -756,6 +760,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) d->armour = armour; memcpy(d->ammo, ammo, sizeof(ammo)); memcpy(d->mag, mag, sizeof(mag)); + if(d->lifesequence==0) d->resetstats(); //NEW } } break; @@ -863,8 +868,12 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) break; case SV_TIMEUP: - timeupdate(getint(p)); + { + int curgamemillis = getint(p); + int curgamelimit = getint(p); + timeupdate(curgamemillis, curgamelimit); break; + } case SV_WEAPCHANGE: { diff --git a/source/src/entity.h b/source/src/entity.h index 65153331..4a75e689 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -228,10 +228,13 @@ public: int gunselect; bool akimbo; int ammo[NUMGUNS], mag[NUMGUNS], gunwait[NUMGUNS]; + int pstatshots[NUMGUNS], pstatdamage[NUMGUNS]; playerstate() : armour(0), primary(GUN_ASSAULT), nextprimary(GUN_ASSAULT), akimbo(false) {} virtual ~playerstate() {} + void resetstats() { loopi(NUMGUNS) pstatshots[i] = pstatdamage[i] = 0; } + itemstat &itemstats(int type) { switch(type) diff --git a/source/src/protos.h b/source/src/protos.h index 3d244cb8..f9bd7457 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -361,6 +361,9 @@ bool requestmasterf(const char *fmt, ...); // for AUTH et al // clientgame extern flaginfo flaginfos[2]; extern int sessionid; +extern int gametimecurrent; +extern int gametimemaximum; +extern int lastgametimeupdate; extern bool watchingdemo; struct serverstate { int autoteam; int mastermode; int matchteamsize; void reset() { autoteam = mastermode = matchteamsize = 0; }}; extern struct serverstate servstate; @@ -381,7 +384,7 @@ extern int getclientmode(); extern void zapplayer(playerent *&d); extern playerent *getclient(int cn); extern playerent *newclient(int cn); -extern void timeupdate(int timeremain); +extern void timeupdate(int milliscur, int millismax); // was (int timeremain); extern void respawnself(); extern void setskin(playerent *pl, int skin, int team = -1); extern void callvote(int type, char *arg1 = NULL, char *arg2 = NULL);