From 979b70ea78c346a1bec5370974474bb77cba7fc9 Mon Sep 17 00:00:00 2001 From: driAn Date: Fri, 22 Aug 2008 20:03:47 +0000 Subject: [PATCH] delay when respawning from spect mode git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2352 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 30 ++++++++++++++++++++---------- source/src/entity.h | 3 ++- source/src/protos.h | 1 + 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 4eb0f22f..51119843 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -138,7 +138,7 @@ void deathstate(playerent *pl) { pl->state = CS_DEAD; pl->spectatemode = SM_DEATHCAM; - pl->lastpain = pl->lastaction = lastmillis; + pl->respawnoffset = pl->lastpain = pl->lastaction = lastmillis; pl->move = pl->strafe = 0; pl->pitch = pl->roll = 0; pl->attacking = false; @@ -393,14 +393,24 @@ void respawnself() bool tryrespawn() { - if(player1->state==CS_DEAD && lastmillis>player1->lastpain+(m_ctf ? 5000 : 2000)) - { - player1->attacking = false; - if(m_arena) { conoutf("waiting for new round to start..."); return false; } - respawnself(); - player1->weaponswitch(player1->primweap); - player1->lastaction -= weapon::weaponchangetime/2; - return true; + if(player1->state==CS_DEAD) + { + if(lastmillis>player1->respawnoffset+(m_ctf ? 5000 : 2000)) + { + if(player1->isspectating() && player1->spectatemode!=SM_DEATHCAM) + { + spectate(SM_DEATHCAM); + player1->respawnoffset = lastmillis+2000; + return false; + } + + player1->attacking = false; + if(m_arena) { conoutf("waiting for new round to start..."); return false; } + respawnself(); + player1->weaponswitch(player1->primweap); + player1->lastaction -= weapon::weaponchangetime/2; + return true; + } } return false; } @@ -411,7 +421,7 @@ void dodamage(int damage, playerent *pl, playerent *actor, bool gib, bool local) { if(pl->state != CS_ALIVE || intermission) return; - pl->lastpain = lastmillis; + pl->respawnoffset = pl->lastpain = lastmillis; if(local) damage = pl->dodamage(damage); else if(actor==player1) return; diff --git a/source/src/entity.h b/source/src/entity.h index 8245e13e..8bdf97c3 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -351,6 +351,7 @@ struct playerent : dynent, playerstate int skin, nextskin; // skin after respawning int spectatemode, followplayercn; int eardamagemillis; + int respawnoffset; virtual float dyneyeheight() { return (state==CS_DEAD || state==CS_SPECTATE) && spectatemode==SM_FLY ? 1.0f : physent::dyneyeheight(); } bool allowmove() { return state!=CS_DEAD || spectatemode==SM_FLY; } @@ -363,7 +364,7 @@ struct playerent : dynent, playerstate int smoothmillis; playerent() : clientnum(-1), lastupdate(0), plag(0), ping(0), lifesequence(0), frags(0), flagscore(0), deaths(0), lastpain(0), lastvoicecom(0), clientrole(CR_DEFAULT), - skin(0), nextskin(0), spectatemode(SM_NONE), followplayercn(-1), eardamagemillis(0), + skin(0), nextskin(0), spectatemode(SM_NONE), followplayercn(-1), eardamagemillis(0), respawnoffset(0), weaponsel(NULL), nextweaponsel(NULL), primweap(NULL), nextprimweap(NULL), lastattackweapon(NULL), smoothmillis(-1) { diff --git a/source/src/protos.h b/source/src/protos.h index 75b9ad53..c22f8b2f 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -318,6 +318,7 @@ extern char *colorname(playerent *d, int num = 0, char *name = NULL, const char extern char *colorping(int ping); extern void togglespect(); extern playerent *findfollowplayer(int shiftdirection = 0); +extern void spectate(int mode); struct votedisplayinfo {