diff --git a/config/defaults.cfg b/config/defaults.cfg index 9d46e26f..7ed2cad6 100644 --- a/config/defaults.cfg +++ b/config/defaults.cfg @@ -31,6 +31,7 @@ bind 2 secondary bind 3 grenades bind 4 melee bind R reload +bind G [ if $editing [ solid 0 ] [ quicknadethrow ] ] //for alternative weapon binding (more economic) see the end of this file @@ -51,7 +52,8 @@ alias quicknadethrow [ ] loop 7 [ concatword altaction_ $i; alias $s quicknadethrow ] // quick nade throw is default -alias altaction_4 [ zoom 1; onrelease [ zoom 0 ] ] +alias altaction_4 [ zoom 1; onrelease [ zoom 0 ] ] // sniper +alias altaction_6 [ ] // grenade (none) // NOTE: by default this zoom script just devides your sensitivity by 2 while you use the scope // if you want to set your own value for it, go to the following line and diff --git a/source/src/client.cpp b/source/src/client.cpp index d3536624..ab3a2613 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -69,7 +69,7 @@ int smallerteam() void changeteam(int team) // force team and respawn { c2sinit = false; - if(m_ctf) tryflagdrop(); + if(m_ctf) tryflagdrop(NULL); s_strncpy(player1->team, team_string(team), MAXTEAMLEN+1); deathstate(player1); }; @@ -83,7 +83,7 @@ void newteam(char *name) if(!strcmp(name, player1->team)) return; // same team if(!team_valid(name)) { conoutf("\f3\"%s\" is not a valid team name (try CLA or RVSF)", name); return; }; - bool checkteamsize = autoteambalance && players.length() >= 1; + bool checkteamsize = autoteambalance && players.length() >= 1 && !m_botmode; int freeteam = smallerteam(); if(team_valid(name)) @@ -406,7 +406,7 @@ void gets2c() // get updates from the server case ENET_EVENT_TYPE_DISCONNECT: extern char *disc_reasons[]; - if(event.data>DISC_MAXCLIENTS) event.data = DISC_NONE; + if(event.data>DISC_NUM) event.data = DISC_NONE; if(!disconnecting || event.data) conoutf("\f3server network error, disconnecting (%s) ...", disc_reasons[event.data]); disconnect(); return; diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index ce19c4b2..b630384e 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -427,6 +427,8 @@ void mousemove(int dx, int dy) }; }; +void showteamkill() { player1->lastteamkill = lastmillis; }; + // damage arriving from the network, monsters, yourself, all ends up here. void selfdamage(int damage, int actor, playerent *act, bool gib, playerent *pl) @@ -457,6 +459,7 @@ void selfdamage(int damage, int actor, playerent *act, bool gib, playerent *pl) { --act->frags; conoutf("\f2%s fragged %s teammate (%s)", act==player1 ? "you" : act->name, act==player1 ? "a" : "his", pl->name); + if(act==player1) showteamkill(); } else { @@ -480,7 +483,7 @@ void selfdamage(int damage, int actor, playerent *act, bool gib, playerent *pl) showscores(true); setscope(false); addmsg(gib ? SV_GIBDIED : SV_DIED, "ri", actor); - if(m_ctf) tryflagdrop(); + if(m_ctf) tryflagdrop(act && isteam(act->team, player1->team)); }; deathstate(pl); pl->lifesequence++; diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 29d3cfd7..ef17ef7e 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -262,11 +262,8 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) { frags = -1; conoutf("you fragged a teammate (%s)", d->name); - if(m_ctf) - { - flaginfo &flag = flaginfos[team_opposite(team_int(d->team))]; - if(flag.state == CTFF_DROPPED && flag.actor == d && d->lifesequence == d->flagdroplifesequence) deathstate(player1); - }; + extern void showteamkill(); + showteamkill(); } else { diff --git a/source/src/entities.cpp b/source/src/entities.cpp index 4fa39554..c9083420 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -361,7 +361,7 @@ void flagpickup() addmsg(SV_FLAGPICKUP, "ri", f.team); }; -void tryflagdrop() +void tryflagdrop(bool reset) { flaginfo &f = flaginfos[team_opposite(team_int(player1->team))]; if(f.state==CTFF_STOLEN && f.actor==player1) @@ -369,7 +369,7 @@ void tryflagdrop() f.flag->spawned = false; f.state = CTFF_DROPPED; f.ack = false; - addmsg(SV_FLAGDROP, "ri", f.team); + addmsg(reset ? SV_FLAGRESET : SV_FLAGDROP, "ri", f.team); }; }; @@ -421,7 +421,6 @@ void flagdropped(int flag, int action, short x, short y, short z) f.flag->z = z; f.flag->spawned = true; f.ack = true; - if(f.actor) f.actor->flagdroplifesequence = f.actor->lifesequence; flagmsg(flag, action); }; diff --git a/source/src/entity.h b/source/src/entity.h index d03c26f7..1faba78f 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -143,11 +143,10 @@ struct playerent : dynent float oldpitch; int lastupdate, plag, ping; int lifesequence; // sequence id for each respawn, used in damage test - int flagdroplifesequence; int frags, flagscore; int health, armour; int gunselect, gunwait; - int lastaction, lastattackgun, lastmove, lastpain; + int lastaction, lastattackgun, lastmove, lastpain, lastteamkill; bool ismaster; bool attacking; int ammo[NUMGUNS]; @@ -168,7 +167,7 @@ struct playerent : dynent poshist history; // Previous stored locations of this player - playerent() : plag(0), ping(0), lifesequence(0), flagdroplifesequence(0), frags(0), flagscore(0), lastpain(0), ismaster(false), + playerent() : plag(0), ping(0), lifesequence(0), frags(0), flagscore(0), lastpain(0), lastteamkill(0), ismaster(false), shots(0), reloading(false), primary(GUN_ASSAULT), nextprimary(GUN_ASSAULT), skin(0), nextskin(0), inhandnade(NULL) { diff --git a/source/src/protocol.h b/source/src/protocol.h index dfeec559..534cd857 100644 --- a/source/src/protocol.h +++ b/source/src/protocol.h @@ -30,5 +30,5 @@ enum { MCMD_KICK = 0, MCMD_BAN, MCMD_REMBANS, MCMD_MASTERMODE, MCMD_AUTOTEAM }; #define DAF 1.0f #define DVF 100.0f -enum { DISC_NONE = 0, DISC_EOP, DISC_CN, DISC_MKICK, DISC_MBAN, DISC_TAGT, DISC_BANREFUSE, DISC_WRONGPW, DISC_MLOGINFAIL, DISC_MAXCLIENTS, DISC_MASTERMODE }; +enum { DISC_NONE = 0, DISC_EOP, DISC_CN, DISC_MKICK, DISC_MBAN, DISC_TAGT, DISC_BANREFUSE, DISC_WRONGPW, DISC_MLOGINFAIL, DISC_MAXCLIENTS, DISC_MASTERMODE, DISC_NUM }; diff --git a/source/src/protos.h b/source/src/protos.h index 2f41fd6d..8526b9b3 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -115,7 +115,7 @@ extern void respawnself(); extern void setskin(playerent *pl, uint skin); //game mode extras extern void flagpickup(); -extern void tryflagdrop(); +extern void tryflagdrop(bool reset = false); extern void flagreturn(); extern void flagscore(); extern void flagstolen(int flag, int action, int act); diff --git a/source/src/renderextras.cpp b/source/src/renderextras.cpp index 1600b052..5963e014 100644 --- a/source/src/renderextras.cpp +++ b/source/src/renderextras.cpp @@ -342,6 +342,8 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat else if(closeent[0]) draw_text(closeent, 20, 1570); else if(player) draw_text(player->name, 20, 1570); + bool didteamkill = player1->lastteamkill && player1->lastteamkill + 5000 > lastmillis; + if(!rendermenu()) { bool teammate_in_xhair = player ? (isteam(player->team, player1->team) && player->state!=CS_DEAD) : false; @@ -364,7 +366,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat glEnd(); glDisable(GL_ALPHA_TEST); } - else if((player1->gunselect != GUN_SNIPER || teammate_in_xhair) && !player1->reloading && !player1->state==CS_DEAD) + else if((player1->gunselect != GUN_SNIPER || teammate_in_xhair) && !player1->reloading && !player1->state==CS_DEAD && !didteamkill) { glBlendFunc(GL_ONE, GL_ONE); static Texture *teammatetex = NULL; @@ -417,22 +419,23 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat glOrtho(0, VIRTW/2, VIRTH/2, 0, -1, 1); draw_textf("%d", 90, 827, player1->health); if(player1->armour) draw_textf("%d", 390, 827, player1->armour); - //draw_textf("%d", 690, 827, player1->mag[player1->gunselect]); - if (player1->gunselect!=GUN_KNIFE) + if(player1->gunselect!=GUN_KNIFE) { - //draw_textf("%d", 690, 827, player1->mag[player1->gunselect]); - char gunstats [64]; - if (player1->gunselect!=GUN_GRENADE) - sprintf(gunstats,"%i/%i",player1->mag[player1->gunselect],player1->ammo[player1->gunselect]); + char gunstats[64]; + if(player1->gunselect!=GUN_GRENADE) sprintf(gunstats,"%i/%i",player1->mag[player1->gunselect],player1->ammo[player1->gunselect]); else sprintf(gunstats,"%i",player1->mag[player1->gunselect]); draw_text(gunstats, 690, 827); - //clean up pointer? - //delete gunstats; }; + glPopMatrix(); - glPopMatrix(); + if(didteamkill) + { + glPushMatrix(); + glOrtho(0, VIRTW/3, VIRTH/3, 0, -1, 1); + draw_text("\f3You Killed A Teammate", 0, VIRTH/3/2); + glPopMatrix(); + }; - // EDIT: AH - ctf #define ctf_scl 0.75 if(m_ctf) { @@ -474,11 +477,11 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat if(player1->health <= 20 && !m_osok) { glEnable(GL_BLEND); - drawicon(64, 0, 20, 1650); //drawicon(128, 128, 20, 1650); + drawicon(64, 0, 20, 1650); glDisable(GL_BLEND); } - else drawicon(64, 0, 20, 1650); //drawicon(128, 128, 20, 1650); - if(player1->armour) drawicon((float)(128), 0, 620, 1650); //if(player1->armour) drawicon((float)(player1->armourtype*64), 0, 620, 1650); + else drawicon(64, 0, 20, 1650); + if(player1->armour) drawicon((float)(128), 0, 620, 1650); int g = player1->gunselect; int r = 64; if(g>2) { g -= 3; r = 128; }; diff --git a/source/src/server.cpp b/source/src/server.cpp index 19523043..2315efe1 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -344,10 +344,10 @@ void flagaction(int flag, int action, int sender) }; case SV_FLAGRESET: { - if(f.state != CTFF_DROPPED || sender != -1) return; + if(sender != -1 && f.actor_cn != sender) return; f.state = CTFF_INBASE; break; - } + }; case SV_FLAGSCORE: { if(f.state != CTFF_STOLEN) return; @@ -371,7 +371,7 @@ void ctfreset() }; }; -char *disc_reasons[] = { "normal", "end of packet", "client num", "kicked by master", "banned by master", "tag type", "connection refused due to ban", "wrong password", "failed master login", "server FULL (maxclients)", "server mastermode is \"private\"" }; +char *disc_reasons[] = { "normal", "end of packet", "client num", "kicked by master", "banned by master", "tag type", "connection refused due to ban", "wrong password", "failed master login", "server FULL - maxclients", "server mastermode is \"private\"" }; void disconnect_client(int n, int reason = -1) {