From 6076e00692948c84524c3b31d2d6c09007508bdf Mon Sep 17 00:00:00 2001 From: Richard Allen Date: Wed, 3 Apr 2002 09:26:47 +0000 Subject: [PATCH] New FF system. Warns and then finally kickbans teamwounders and teamkillers --- reaction/cgame/cg_consolecmds.c | 5 ++ reaction/game/g_combat.c | 11 ++++- reaction/game/g_local.h | 11 +++++ reaction/game/g_main.c | 10 ++++ reaction/game/g_teamplay.c | 85 ++++++++++++++++++++++++++++++++- reaction/game/g_teamplay.h | 7 +++ reaction/game/g_weapon.c | 22 +++++++++ 7 files changed, 149 insertions(+), 2 deletions(-) diff --git a/reaction/cgame/cg_consolecmds.c b/reaction/cgame/cg_consolecmds.c index e4c9297f..b02d65fa 100644 --- a/reaction/cgame/cg_consolecmds.c +++ b/reaction/cgame/cg_consolecmds.c @@ -5,6 +5,10 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.42 2002/04/03 09:26:47 jbravo +// New FF system. Warns and then finally kickbans teamwounders and +// teamkillers +// // Revision 1.41 2002/03/31 23:41:45 jbravo // Added the use command // @@ -960,6 +964,7 @@ void CG_InitConsoleCommands( void ) { trap_AddCommand ("choose"); trap_AddCommand ("use"); trap_AddCommand ("drop"); + trap_AddCommand ("unzoom"); // JBravo: for zcam trap_AddCommand ("camera"); // JBravo: for radio diff --git a/reaction/game/g_combat.c b/reaction/game/g_combat.c index 3b686418..de7785c2 100644 --- a/reaction/game/g_combat.c +++ b/reaction/game/g_combat.c @@ -5,6 +5,10 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.57 2002/04/03 09:26:47 jbravo +// New FF system. Warns and then finally kickbans teamwounders and +// teamkillers +// // Revision 1.56 2002/04/03 03:13:16 blaze // NEW BREAKABLE CODE - will break all old breakables(wont appear in maps) // @@ -834,13 +838,16 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int AddKilledPlayer(attacker, self); ResetKills(self); // JBravo: make it OK to frag teammates after rounds are over. - if (attacker == self || OnSameTeam (self, attacker)) { + if (attacker == self) + AddScore(attacker, self->r.currentOrigin, -1); + else if (OnSameTeam (self, attacker)) { if (level.team_round_going) { AddScore(attacker, self->r.currentOrigin, -1); //If the kill was a TK, remove 1 from REC_KILLS to negate the one given earlyier attacker->client->pers.records[REC_KILLS]--; //Also, increment the TK's record attacker->client->pers.records[REC_TEAMKILLS]++; + Add_TeamKill(attacker); } } else { // Increase number of kills this life for attacker @@ -1614,6 +1621,8 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, if (g_friendlyFire.integer == 2 && level.team_round_going) { return; } + if (level.team_round_going) + Add_TeamWound(attacker, targ, mod); } #ifdef MISSIONPACK if (mod == MOD_PROXIMITY_MINE) { diff --git a/reaction/game/g_local.h b/reaction/game/g_local.h index 0f7f2577..1aca2528 100644 --- a/reaction/game/g_local.h +++ b/reaction/game/g_local.h @@ -5,6 +5,10 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.65 2002/04/03 09:26:47 jbravo +// New FF system. Warns and then finally kickbans teamwounders and +// teamkillers +// // Revision 1.64 2002/04/03 03:13:16 blaze // NEW BREAKABLE CODE - will break all old breakables(wont appear in maps) // @@ -520,6 +524,10 @@ struct gclient_s { int teamplayItem; int radioGender; qboolean radioOff; + int team_wounds; + int team_wounds_before; + int ff_warning; + int team_kills; }; @@ -1069,6 +1077,9 @@ extern vmCvar_t g_RQ3_lca; // JBravo: cvar to signal cgame that LCA is in prog extern vmCvar_t g_RQ3_teamCount1; // JBravo: cvar for the UI join menus extern vmCvar_t g_RQ3_teamCount2; // JBravo: cvar for the UI join menus extern vmCvar_t g_RQ3_numSpectators; // JBravo: cvar for the UI join menus +extern vmCvar_t g_RQ3_maxteamkills; // JBravo: Max teamkills +extern vmCvar_t g_RQ3_twbanrounds; // JBravo: no. of games team wounders are banned +extern vmCvar_t g_RQ3_tkbanrounds; // JBravo: no. of games team killers are banned //Slicer: Team Status Cvars for MM extern vmCvar_t RQ3_team1; extern vmCvar_t RQ3_team2; diff --git a/reaction/game/g_main.c b/reaction/game/g_main.c index 02668209..79ddf372 100644 --- a/reaction/game/g_main.c +++ b/reaction/game/g_main.c @@ -5,6 +5,10 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.42 2002/04/03 09:26:47 jbravo +// New FF system. Warns and then finally kickbans teamwounders and +// teamkillers +// // Revision 1.41 2002/04/02 04:18:58 jbravo // Made the TP scoreboard go down at round beginig (not for spectators) and // pop up at intermission. Also added special to the use command @@ -187,6 +191,9 @@ vmCvar_t g_RQ3_team2name; vmCvar_t g_RQ3_teamCount1; vmCvar_t g_RQ3_teamCount2; vmCvar_t g_RQ3_numSpectators; +vmCvar_t g_RQ3_maxteamkills; +vmCvar_t g_RQ3_twbanrounds; +vmCvar_t g_RQ3_tkbanrounds; //Slicer: Team Status Cvars for MM vmCvar_t RQ3_team1; vmCvar_t RQ3_team2; @@ -326,6 +333,9 @@ static cvarTable_t gameCvarTable[] = { { &g_RQ3_teamCount2, "g_RQ3_teamCount2", "0", CVAR_SYSTEMINFO, 0, qfalse }, { &g_RQ3_numSpectators, "g_RQ3_numSpectators", "0", CVAR_SYSTEMINFO, 0, qfalse }, { &g_RQ3_lca, "g_RQ3_lca", "0", 0, 0, qfalse}, + { &g_RQ3_maxteamkills, "g_RQ3_maxteamkills", "0", CVAR_ARCHIVE, 0, qtrue}, + { &g_RQ3_twbanrounds, "g_RQ3_twbanrounds", "2", CVAR_ARCHIVE, 0, qtrue}, + { &g_RQ3_tkbanrounds, "g_RQ3_tkbanrounds", "2", CVAR_ARCHIVE, 0, qtrue}, //Slicer: Team Status Cvars for MM { &RQ3_team1, "RQ3_team1", "0", 0, 0, qfalse}, { &RQ3_team2, "RQ3_team2", "0", 0, 0, qfalse}, diff --git a/reaction/game/g_teamplay.c b/reaction/game/g_teamplay.c index 930d9270..a0ce3c03 100644 --- a/reaction/game/g_teamplay.c +++ b/reaction/game/g_teamplay.c @@ -5,6 +5,10 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.56 2002/04/03 09:26:47 jbravo +// New FF system. Warns and then finally kickbans teamwounders and +// teamkillers +// // Revision 1.55 2002/04/02 21:45:15 jbravo // change for makro // @@ -843,7 +847,6 @@ void EquipPlayer (gentity_t *ent) if (grenades > 0) { ent->client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_GRENADE ); ent->client->ps.ammo[WP_GRENADE] = grenades; -// ent->client->uniqueWeapons++; } if (ent->client->teamplayWeapon == WP_KNIFE && !(ent->client->ps.persistant[PERS_WEAPONMODES] & RQ3_KNIFEMODE)) { ent->client->ps.generic1 = ((ent->client->ps.generic1 & ANIM_TOGGLEBIT) ^ @@ -1547,3 +1550,83 @@ void RQ3_Cmd_Use_f(gentity_t *ent) Com_sprintf (buf, sizeof(buf), "weapon %d\n", weapon); trap_SendConsoleCommand(EXEC_APPEND, buf); } + +void Add_TeamWound(gentity_t *attacker, gentity_t *victim, int mod) +{ + char userinfo[MAX_INFO_STRING]; + char *value; + + if (g_gametype.integer != GT_TEAMPLAY || !attacker->client || !victim->client) + return; + + attacker->client->team_wounds++; + + if (attacker->client->ff_warning == 0) { + attacker->client->ff_warning++; + trap_SendServerCommand(victim-g_entities, va("print \"You were hit by %s, your TEAMMATE!\n\"", + attacker->client->pers.netname)); + trap_SendServerCommand(attacker-g_entities, va("print \"You hit your TEAMMATE %s!\n\"", + victim->client->pers.netname)); + } + attacker->client->team_wounds = (attacker->client->team_wounds_before + 1); + + if (g_RQ3_maxteamkills.integer < 1) + return; + if (attacker->client->team_wounds < (g_RQ3_maxteamkills.integer * 3)) { + return; + } else if (attacker->client->team_wounds < (g_RQ3_maxteamkills.integer * 4)) { + trap_SendServerCommand(-1, va("print \"%s is in danger of being banned for wounding teammates\n\"", + attacker->client->pers.netname)); + trap_SendServerCommand(attacker-g_entities, va("print \"WARNING: You'll be temporarily banned if you continue wounding teammates!\n\"")); + return; + } else { + trap_SendServerCommand(-1, va("print \"Banning %s for team wounding\n\"", attacker->client->pers.netname)); + trap_SendServerCommand(attacker-g_entities, va("print \"You've wounded teammates too many times, and are banned for %d %s.\n\"", + g_RQ3_twbanrounds.integer, ((g_RQ3_twbanrounds.integer > 1) ? "games" : "game"))); + trap_GetUserinfo(attacker-g_entities, userinfo, sizeof(userinfo)); + value = Info_ValueForKey (userinfo, "ip"); + AddIP(value); + trap_DropClient(attacker-g_entities, "Dropped due to team wounding"); + } +} + +void Add_TeamKill(gentity_t *attacker) +{ + char userinfo[MAX_INFO_STRING]; + char *value; + + if (g_gametype.integer != GT_TEAMPLAY || !attacker->client) + return; + + attacker->client->team_kills++; + + if (attacker->client->team_wounds > attacker->client->team_wounds_before) + attacker->client->team_wounds = attacker->client->team_wounds_before; + + if ((g_RQ3_maxteamkills.integer < 1) || + (attacker->client->team_kills < ((g_RQ3_maxteamkills.integer % 2) + g_RQ3_maxteamkills.integer / 2))) { + trap_SendServerCommand(attacker-g_entities, va("print \"You killed your TEAMMATE!\n\"")); + return; + } else if (attacker->client->team_kills < g_RQ3_maxteamkills.integer) { + trap_SendServerCommand(-1, va("print \"%s is in danger of being banned for killing teammates\n\"", + attacker->client->pers.netname)); + trap_SendServerCommand(attacker-g_entities, va("print \"WARNING: You'll be temporarily banned if you continue killing teammates!\n\"")); + return; + } else { + trap_SendServerCommand(-1, va("print \"Banning %s for team killing\n\"", attacker->client->pers.netname)); + trap_SendServerCommand(attacker-g_entities, va("print \"You've killed too many teammates, and are banned for %d %s.\n", g_RQ3_tkbanrounds.integer, + ((g_RQ3_tkbanrounds.integer > 1) ? "games" : "game"))); + trap_GetUserinfo(attacker-g_entities, userinfo, sizeof(userinfo)); + value = Info_ValueForKey (userinfo, "ip"); + AddIP(value); + trap_DropClient(attacker-g_entities, "Dropped due to team killing"); + } +} + +void setFFState(gentity_t *ent) +{ + if (ent && ent->client) { + ent->client->team_wounds_before = ent->client->team_wounds; + ent->client->ff_warning = 0; + } +} diff --git a/reaction/game/g_teamplay.h b/reaction/game/g_teamplay.h index 8888ae8b..b60d8b2b 100644 --- a/reaction/game/g_teamplay.h +++ b/reaction/game/g_teamplay.h @@ -5,6 +5,10 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.10 2002/04/03 09:26:47 jbravo +// New FF system. Warns and then finally kickbans teamwounders and +// teamkillers +// // Revision 1.9 2002/04/01 02:56:50 jbravo // Some sourcecode reformatting // @@ -65,3 +69,6 @@ void RQ3_Cmd_Radio_power_f (gentity_t *ent); void RQ3_Cmd_Radiogender_f (gentity_t *ent); void ParseSayText (gentity_t * ent, char *text); void RQ3_SpectatorMode(gentity_t *ent); +void Add_TeamKill(gentity_t *attacker); +void Add_TeamWound(gentity_t *attacker, gentity_t *victim, int mod); +void setFFState(gentity_t *ent); diff --git a/reaction/game/g_weapon.c b/reaction/game/g_weapon.c index 27f23161..b0685429 100644 --- a/reaction/game/g_weapon.c +++ b/reaction/game/g_weapon.c @@ -5,6 +5,10 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.42 2002/04/03 09:26:47 jbravo +// New FF system. Warns and then finally kickbans teamwounders and +// teamkillers +// // Revision 1.41 2002/04/02 00:28:10 slicer // Reduced the "arc" knife does // @@ -1408,6 +1412,8 @@ void Weapon_Knife_Fire(gentity_t *ent) //VectorNormalize( forward ); //m = Knife_Throw(ent, muzzle, forward, THROW_DAMAGE, 1200); +// JBravo: ff + if (g_gametype.integer == GT_TEAMPLAY) setFFState(ent); m = fire_knife(ent, muzzle, forward); // m->damage *= s_quadFactor; // m->splashDamage *= s_quadFactor; @@ -1439,6 +1445,8 @@ void Weapon_M4_Fire(gentity_t *ent) } +// JBravo: ff + if (g_gametype.integer == GT_TEAMPLAY) setFFState(ent); Bullet_Fire( ent, RQ3_Spread(ent, M4_SPREAD), M4_DAMAGE, MOD_M4); /* @@ -1474,6 +1482,8 @@ void Weapon_MK23_Fire(gentity_t *ent) { spread = PISTOL_SPREAD; } +// JBravo: ff + if (g_gametype.integer == GT_TEAMPLAY) setFFState(ent); Bullet_Fire( ent, RQ3_Spread(ent, spread), PISTOL_DAMAGE, MOD_PISTOL); } @@ -1494,6 +1504,8 @@ void Weapon_SSG3000_FireOld(gentity_t *ent) { spread = RQ3_Spread(ent, SNIPER_SPREAD); } +// JBravo: ff + if (g_gametype.integer == GT_TEAMPLAY) setFFState(ent); Bullet_Fire( ent, spread, SNIPER_DAMAGE, MOD_SNIPER); //Elder: bolt action plus save last zoom @@ -1772,6 +1784,8 @@ void Weapon_MP5_Fire(gentity_t *ent) spread = MP5_SPREAD; } +// JBravo: ff + if (g_gametype.integer == GT_TEAMPLAY) setFFState(ent); Bullet_Fire( ent, RQ3_Spread(ent, MP5_SPREAD), MP5_DAMAGE, MOD_MP5); } @@ -1784,6 +1798,8 @@ void Weapon_HandCannon_Fire(gentity_t *ent) { gentity_t *tent, *tent2; +// JBravo: ff + if (g_gametype.integer == GT_TEAMPLAY) setFFState(ent); //Elder: added for damage report RQ3_InitShotgunDamageReport(); @@ -1818,6 +1834,8 @@ void Weapon_M3_Fire(gentity_t *ent) //Blaze: call to shotgun fire function here gentity_t *tent; +// JBravo: ff + if (g_gametype.integer == GT_TEAMPLAY) setFFState(ent); //Elder: added for damage report RQ3_InitShotgunDamageReport(); @@ -1916,6 +1934,8 @@ void Weapon_Akimbo_Fire(gentity_t *ent) float spread; //Blaze: Will need 2 of these spread = AKIMBO_SPREAD; +// JBravo: ff + if (g_gametype.integer == GT_TEAMPLAY) setFFState(ent); Bullet_Fire( ent, RQ3_Spread(ent, spread), AKIMBO_DAMAGE, MOD_AKIMBO); //Elder: reset plus added 1 bullet check @@ -1941,6 +1961,8 @@ void Weapon_Grenade_Fire(gentity_t *ent) //forward[2] += 0.5f; VectorNormalize( forward ); +// JBravo: ff + if (g_gametype.integer == GT_TEAMPLAY) setFFState(ent); m = fire_grenade (ent, muzzle, forward); //Elder: removed //m->damage *= s_quadFactor;