With cordite in the air, splintered steel, shell casings and powder burns, there’s only one explanation...
Discuss & improve the game engine.

Moderators: sparcdr, torhu, Tequila

More CVARS please?

Postby ReD NeCKersoN » Wed Jun 24, 2009 3:27 am

Pasted conversation from IRC:

<ReD_NeCKersoN> set g_maxteamkills "3" //amount of TK's before you get kicked when friendlyfire is 1
<ReD_NeCKersoN> but if default is 3, then why doesn't it work?
<rane> right
<rane> so it's broken!
<ReD_NeCKersoN> need to report this!
<rane> to a dev!!!
<rane> :-)
<ReD_NeCKersoN> a coding dev ;)
<rane> g_teamkillsforgettime "300" - that's cool too
<ReD_NeCKersoN> maybe in luckybro's thread?
<ReD_NeCKersoN> I'm sure tequila will see it there also & maybe torhu
<ReD_NeCKersoN> I'll just copy/paste this conversation
<rane> grelouk found some really cool stuff:-)
<ReD_NeCKersoN> look here under TEAM GAME SETTINGS
<ReD_NeCKersoN> http://forums.urbanterror.net/index.php ... ic=15323.0
<rane> btw, g_teamkillsforgettime is set to 1800
<rane> default is 30
<ReD_NeCKersoN> I don't think these cvars are SG specific, maybe carryovers from q3
<rane> we also added forcebalance...
<rane> and it works fine
<ReD_NeCKersoN> cool
Image
User avatar
ReD NeCKersoN
SG Team
 
Posts: 3245
Joined: Wed Mar 27, 2002 6:22 am
Location: VA, USA



Postby Bodie » Wed Jun 24, 2009 3:31 am

The log may be a bit cryptic so let me explain in detail. Grelouk found two variables:

g_maxteamkills default is 3
g_teamkillsforgettime default is 30

This settings seem to mean if you killl 3 of your own in space of 30 seconds you should get kicked from the server.

But it doesn't work. I killed three times my bot under forgettime and I wasn't kicked. My nickname didn't contain a space.

I guess this command just doesn't have punishment set in SG or doesn't have it set correctly.

Please fix!
SG names: Bodie (aka mS // Donnie).
Admin on Jeuxlinux, RAWHIDE, #sg.wars and some other servers.
User avatar
Bodie
Jeuxlinux Admin
 
Posts: 633
Joined: Thu Mar 26, 2009 7:59 pm



Postby Tequila » Wed Jun 24, 2009 3:32 pm

In fact, that cvars are in Urban Terror 4 game, but not in Smokin' Guns... Sorry.
Raedwul from UT4 team comfirmed me that code is not OpenSource.
Maybe we should just implement our own code.
Any volonteer ? That should be easy...
rane ? :P
User avatar
Tequila
SG Team
 
Posts: 1100
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby Conq » Fri Jun 26, 2009 12:38 pm

Hello world !
I implemented this today. That should work.

Here is the patch
Conq
Drifter
 
Posts: 13
Joined: Sun May 31, 2009 9:37 am



Postby Tequila » Fri Jun 26, 2009 5:33 pm

:D Thanks Conq,

your patch inspired me and I taked the time to enhance it. I also asked raedwulf from UT4 team how these cvars should be used. I thank him for his patience ;)

So here is my patch:
Code: Select all
Index: code/game/g_local.h
===================================================================
--- code/game/g_local.h   (revision 247)
+++ code/game/g_local.h   (working copy)
 -343,6 +343,9 @@
    int         savedMoney;         // copy of ps.stats[STAT_MONEY]
    int         savedWins;         // copy of ps.stats[STAT_WINS]
    int         savedScore;         // copy of ps.persistant[PERS_SCORE]
+// Tequila: TeamKill management inspired by Conq patch
+   int         lastTeamKillTime;
+   int         TeamKillsCount;
 #endif
 
 } clientPersistant_t;
 -1016,6 +1019,10 @@
 extern   vmCvar_t   g_scorelimit;
 #endif
 extern   vmCvar_t   g_friendlyFire;
+#ifdef SMOKINGUNS
+extern   vmCvar_t   g_maxteamkills;
+extern   vmCvar_t   g_teamkillsforgettime;
+#endif
 extern   vmCvar_t   g_password;
 extern   vmCvar_t   g_needpass;
 extern   vmCvar_t   g_gravity;
Index: code/game/g_main.c
===================================================================
--- code/game/g_main.c   (revision 247)
+++ code/game/g_main.c   (working copy)
 -104,6 +104,10 @@
 vmCvar_t   g_scorelimit;
 #endif
 vmCvar_t   g_friendlyFire;
+#ifdef SMOKINGUNS
+vmCvar_t   g_maxteamkills;
+vmCvar_t   g_teamkillsforgettime;
+#endif
 vmCvar_t   g_password;
 vmCvar_t   g_needpass;
 vmCvar_t   g_maxclients;
 -232,6 +236,8 @@
    { &g_friendlyFire, "g_friendlyFire", "0", CVAR_ARCHIVE, 0, qtrue  },
 #else
    { &g_friendlyFire, "g_friendlyFire", "1", CVAR_ARCHIVE, 0, qtrue  },
+   { &g_maxteamkills, "g_maxteamkills", "3", CVAR_ARCHIVE | CVAR_NORESTART, 0, qtrue },
+   { &g_teamkillsforgettime, "g_teamkillsforgettime", "30", CVAR_ARCHIVE | CVAR_NORESTART, 0, qtrue },
 #endif
 
    { &g_teamAutoJoin, "g_teamAutoJoin", "0", CVAR_ARCHIVE  },
Index: code/game/g_combat.c
===================================================================
--- code/game/g_combat.c   (revision 247)
+++ code/game/g_combat.c   (working copy)

 -1612,6 +1612,21 @@
          if ( !g_friendlyFire.integer ) {
             return;
          }
+
+#ifdef SMOKINGUNS
+// Tequila: TeamKill management inspired by Conq patch
+         // Check if we should reset TK count before
+         if ( level.time > attacker->client->pers.lastTeamKillTime + g_teamkillsforgettime.integer * 1000 )
+            attacker->client->pers.TeamKillsCount=0;
+         attacker->client->pers.TeamKillsCount ++;
+         attacker->client->pers.lastTeamKillTime = level.time;
+         // Kick the attacker if TK limit is hit but keep the victim alive
+         if ( attacker->client->pers.TeamKillsCount >= g_maxteamkills.integer )
+         {
+            trap_DropClient( attacker-g_entities, "You reached the limit of supported teammate kills." );
+            return;
+         }
+#endif
       }
 #ifndef SMOKINGUNS
       if (mod == MOD_PROXIMITY_MINE) {

You can get it also here.

What it changed:
- the check is done before the TK victim dies so we can transform the last TK by a g_friendlyfire not set... The victim is kept alive as the TK limit is hit.
- nothing is checked when g_friendlyfire is not set
- the TeamKillsCount is reset on map restart and after team change
- g_teamkillsforgettime is checked against the last TK time

I didn't check it btw. I will try to before commitng it.

Any though before the commit ?
User avatar
Tequila
SG Team
 
Posts: 1100
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby Tequila » Sat Jun 27, 2009 9:52 am

:(
Hey my patch is wrong...
I don't count kills but friendly fire hits... Stupid I am.
Will update it asap.
User avatar
Tequila
SG Team
 
Posts: 1100
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby Tequila » Sat Jun 27, 2009 2:59 pm

:oops:
Then I updated the code/game/g_combat.c patch by:

Code: Select all
Index: code/game/g_combat.c
===================================================================
--- code/game/g_combat.c   (revision 248)
+++ code/game/g_combat.c   (working copy)
@@ -1430,8 +1430,56 @@
 
    return take;
 }
+
+/*
+============
+CheckTeamKills
+By Tequila, TeamKill management inspired by Conq patch
+Return false when TK supported limit is not hit
+============
+*/
+static qboolean CheckTeamKills( gentity_t *attacker, gentity_t *targ ) {
+
+   if ( !attacker || !targ )
+      return qfalse;
+
+   if ( !attacker->client )
+      return qfalse;
+
+   if ( attacker == targ || !OnSameTeam (targ,attacker) )
+      return qfalse;
+
+   // Check if we should reset TK count before
+   if ( attacker->client->pers.lastTeamKillTime && level.time > attacker->client->pers.lastTeamKillTime + g_teamkillsforgettime.integer * 1000 ) {
+#ifndef NDEBUG
+      G_Printf(S_COLOR_MAGENTA "CheckTeamKills: Forget TeamKillsCount (%i) from %s\n", attacker->client->pers.TeamKillsCount, attacker->client->pers.netname);
 #endif
+      attacker->client->pers.TeamKillsCount=0;
+   }
 
+   attacker->client->pers.TeamKillsCount ++;
+#ifndef NDEBUG
+   if (attacker->client->pers.lastTeamKillTime)
+      G_Printf(S_COLOR_MAGENTA "CheckTeamKills: Last TeamKills for %s was %.2f seconds ago\n", attacker->client->pers.netname,(float)(level.time-attacker->client->pers.lastTeamKillTime)/1000.0f);
+#endif
+   attacker->client->pers.lastTeamKillTime = level.time;
+
+   // Kick the attacker if TK limit is hit and return true
+   if ( attacker->client->pers.TeamKillsCount >= g_maxteamkills.integer )
+   {
+      trap_DropClient( attacker-g_entities, "Reached the limit of supported teammate kills." );
+      return qtrue;
+   } else if ( attacker->client->pers.TeamKillsCount == g_maxteamkills.integer -1 )
+      trap_SendServerCommand( attacker-g_entities,
+         va("print \"%s" S_COLOR_YELLOW "... Be careful teammate !!! Next teammate kill could kick you from that server.\n\"",
+         attacker->client->pers.netname));
+#ifndef NDEBUG
+   G_Printf(S_COLOR_MAGENTA "CheckTeamKills: TeamKillsCount is %i for %s\n", attacker->client->pers.TeamKillsCount, attacker->client->pers.netname);
+#endif
+   return qfalse;
+}
+#endif
+
 /*
 ============
 G_Damage
@@ -1469,6 +1517,7 @@
    int         asave;
 #else
    float      take;
+   int         hsave=0;
 #endif
 
    int         knockback;
@@ -1612,6 +1661,10 @@
          if ( !g_friendlyFire.integer ) {
             return;
          }
+#ifdef SMOKINGUNS
+         // Can be used later in case of TK limit reached to protect the last victim
+         hsave = targ->health;
+#endif
       }
 #ifndef SMOKINGUNS
       if (mod == MOD_PROXIMITY_MINE) {
@@ -1835,8 +1888,17 @@
 
          targ->enemy = attacker;
 
+#ifdef SMOKINGUNS
+         // Target is not killed if TK limit is hit
+         if ( g_friendlyFire.integer && CheckTeamKills(attacker,targ) ) {
+            targ->client->ps.stats[STAT_HEALTH] = targ->health = hsave;
+            if ( g_debugDamage.integer )
+               G_LogPrintf( "%i: client:%i health:%i saved from TK by:%i\n", level.time,
+                     targ->s.number,   targ->health, attacker->s.number );
+            return;
+         }
+
          // do the hit-message before the death-message
-#ifdef SMOKINGUNS
          if(attacker->s.angles2[0] != -1 &&
             (attacker->s.eFlags & EF_HIT_MESSAGE)){
             gentity_t *tent;

I tested it and it seems to work like expected.
I also added a warning when max TeamKills is about to be reached...
:cool:
User avatar
Tequila
SG Team
 
Posts: 1100
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby Sucalakafufu » Sat Jun 27, 2009 8:02 pm

Tequila wrote::oops:
Then I updated the code/game/g_combat.c patch by:

Code: Select all
Index: code/game/g_combat.c
===================================================================
--- code/game/g_combat.c   (revision 248)
+++ code/game/g_combat.c   (working copy)
@@ -1430,8 +1430,56 @@
 
    return take;
 }
+
+/*
+============
+CheckTeamKills
+By Tequila, TeamKill management inspired by Conq patch
+Return false when TK supported limit is not hit
+============
+*/
+static qboolean CheckTeamKills( gentity_t *attacker, gentity_t *targ ) {
+
+   if ( !attacker || !targ )
+      return qfalse;
+
+   if ( !attacker->client )
+      return qfalse;
+
+   if ( attacker == targ || !OnSameTeam (targ,attacker) )
+      return qfalse;
+
+   // Check if we should reset TK count before
+   if ( attacker->client->pers.lastTeamKillTime && level.time > attacker->client->pers.lastTeamKillTime + g_teamkillsforgettime.integer * 1000 ) {
+#ifndef NDEBUG
+      G_Printf(S_COLOR_MAGENTA "CheckTeamKills: Forget TeamKillsCount (%i) from %s\n", attacker->client->pers.TeamKillsCount, attacker->client->pers.netname);
 #endif
+      attacker->client->pers.TeamKillsCount=0;
+   }
 
+   attacker->client->pers.TeamKillsCount ++;
+#ifndef NDEBUG
+   if (attacker->client->pers.lastTeamKillTime)
+      G_Printf(S_COLOR_MAGENTA "CheckTeamKills: Last TeamKills for %s was %.2f seconds ago\n", attacker->client->pers.netname,(float)(level.time-attacker->client->pers.lastTeamKillTime)/1000.0f);
+#endif
+   attacker->client->pers.lastTeamKillTime = level.time;
+
+   // Kick the attacker if TK limit is hit and return true
+   if ( attacker->client->pers.TeamKillsCount >= g_maxteamkills.integer )
+   {
+      trap_DropClient( attacker-g_entities, "Reached the limit of supported teammate kills." );
+      return qtrue;
+   } else if ( attacker->client->pers.TeamKillsCount == g_maxteamkills.integer -1 )
+      trap_SendServerCommand( attacker-g_entities,
+         va("print "%s" S_COLOR_YELLOW "... Be careful teammate !!! Next teammate kill could kick you from that server.\n"",
+         attacker->client->pers.netname));
+#ifndef NDEBUG
+   G_Printf(S_COLOR_MAGENTA "CheckTeamKills: TeamKillsCount is %i for %s\n", attacker->client->pers.TeamKillsCount, attacker->client->pers.netname);
+#endif
+   return qfalse;
+}
+#endif
+
 /*
 ============
 G_Damage
@@ -1469,6 +1517,7 @@
    int         asave;
 #else
    float      take;
+   int         hsave=0;
 #endif
 
    int         knockback;
@@ -1612,6 +1661,10 @@
          if ( !g_friendlyFire.integer ) {
             return;
          }
+#ifdef SMOKINGUNS
+         // Can be used later in case of TK limit reached to protect the last victim
+         hsave = targ->health;
+#endif
       }
 #ifndef SMOKINGUNS
       if (mod == MOD_PROXIMITY_MINE) {
@@ -1835,8 +1888,17 @@
 
          targ->enemy = attacker;
 
+#ifdef SMOKINGUNS
+         // Target is not killed if TK limit is hit
+         if ( g_friendlyFire.integer && CheckTeamKills(attacker,targ) ) {
+            targ->client->ps.stats[STAT_HEALTH] = targ->health = hsave;
+            if ( g_debugDamage.integer )
+               G_LogPrintf( "%i: client:%i health:%i saved from TK by:%i\n", level.time,
+                     targ->s.number,   targ->health, attacker->s.number );
+            return;
+         }
+
          // do the hit-message before the death-message
-#ifdef SMOKINGUNS
          if(attacker->s.angles2[0] != -1 &&
             (attacker->s.eFlags & EF_HIT_MESSAGE)){
             gentity_t *tent;

I tested it and it seems to work like expected.
I also added a warning when max TeamKills is about to be reached...
:cool:


nice! :)
SG Name: Sucalakafufu
Clan: [CWNN] - Clan With No Name
User avatar
Sucalakafufu
Gunslinger
 
Posts: 239
Joined: Thu Apr 16, 2009 8:59 am



Postby Conq » Sun Jun 28, 2009 4:16 pm

Good job tequila :-)
Conq
Drifter
 
Posts: 13
Joined: Sun May 31, 2009 9:37 am



Postby Lucky Bro » Mon Jun 29, 2009 3:12 pm

Good job Conq & his inspired follower Tequila! :)

I've got only two questions - how do I disable this feature? Usualy I would do it by setting g_maxteamkills to 0, but seems here it won't work. This is helpfull for non-public servers where this feature is not required at all.
And the second - why does teamkill check begin with lastTeamKillTime comparision even if it is the first player's teamkill? What value will have the lastTeamKillTime in that case in that check?:
Patch code wrote:// Check if we should reset TK count before
if ( attacker->client->pers.lastTeamKillTime && level.time > attacker->client->pers.lastTeamKillTime + g_teamkillsforgettime.integer * 1000 ) {...


P.S. This is not the first time when troubles come from messed configuration file(s) which is(are) going with the game. Previous time it was case with enemyModel variable. Seems 1.1 is the point when the file(s) should be cleaned from all unused values.
"You should know that the lies won't hide your flaws/No sense in hiding all of yours/You gave up on your dreams along the way" (c) "Fake it" by Seether
P.S. English isn't my native language.
User avatar
Lucky Bro
Gunslinger
 
Posts: 143
Joined: Mon Mar 09, 2009 4:12 pm



Postby Tequila » Mon Jun 29, 2009 3:37 pm

Lucky Bro wrote:Good job Conq & his inspired follower Tequila! :)

I've got only two questions - how do I disable this feature? Usualy I would do it by setting g_maxteamkills to 0, but seems here it won't work. This is helpfull for non-public servers where this feature is not required at all.
And the second - why does teamkill check begin with lastTeamKillTime comparision even if it is the first player's teamkill? What value will have the lastTeamKillTime in that case in that check?:
Patch code wrote:// Check if we should reset TK count before
if ( attacker->client->pers.lastTeamKillTime && level.time > attacker->client->pers.lastTeamKillTime + g_teamkillsforgettime.integer * 1000 ) {...


P.S. This is not the first time when troubles come from messed configuration file(s) which is(are) going with the game. Previous time it was case with enemyModel variable. Seems 1.1 is the point when the file(s) should be cleaned from all unused values.

Good point Lucky Bro !
Replacing the line:

Code: Select all
if ( g_friendlyFire.integer && CheckTeamKills(attacker,targ) ) {

by
Code: Select all
if ( g_maxteamkills.integer && g_friendlyFire.integer && CheckTeamKills(attacker,targ) ) {

should authorize to disable the feature by setting the g_maxteamkills cvar to 0.

About the check toward lastTeamKillTime, this is simpler to reset the counter here than elsewhere. You should know "pers" and its members are set to zero at the beginning of the map, so I know it is not set at the first interesting call.

About cleaning config, yes, I agree we should clean default.cfg with 1.1 engine... but that won't clean your own q3config.cfg. But I don't think that can involve big problems. Next beta should help us.

Thanks for your skilled attention ;)
User avatar
Tequila
SG Team
 
Posts: 1100
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby Lucky Bro » Mon Jun 29, 2009 4:27 pm

Tequila wrote:Replacing the line:
...
should authorize to disable the feature by setting the g_maxteamkills cvar to 0.

Yeah, that will help. Thank you :)

Tequila wrote:About the check toward lastTeamKillTime, this is simpler to reset the counter here than elsewhere. You should know "pers" and its members are set to zero at the beginning of the map, so I know it is not set at the first interesting call.

Never knew. I don't know the engine :)
I was thinking about something like:
My mind wrote:if ( attacker->client->pers.lastTeamKillTime && level.time > attacker->client->pers.lastTeamKillTime + g_teamkillsforgettime.integer * 1000 ) {...
->
if ( attacker->client->pers.TeamKillsCount && level.time > attacker->client->pers.lastTeamKillTime + g_teamkillsforgettime.integer * 1000 ) {...

And explicit reset of TeamKillsCount variable at some point. Now I see that it is not required :)
Thanks for answer!

Tequila wrote:About cleaning config, yes, I agree we should clean default.cfg with 1.1 engine... but that won't clean your own q3config.cfg. But I don't think that can involve big problems. Next beta should help us.

Bless the Beta then ;)
( btw, my q3config.cfg is almost empty :) thx to moRtem ;) )
"You should know that the lies won't hide your flaws/No sense in hiding all of yours/You gave up on your dreams along the way" (c) "Fake it" by Seether
P.S. English isn't my native language.
User avatar
Lucky Bro
Gunslinger
 
Posts: 143
Joined: Mon Mar 09, 2009 4:12 pm



Postby moRtem » Tue Jun 30, 2009 6:35 pm

( btw, my q3config.cfg is almost empty :) thx to moRtem ;) )


hih -- what exactly is my effort there? :-)

hope to see you back in the arena asap !!!


/quit
User avatar
moRtem
Gunslinger
 
Posts: 284
Joined: Sun Mar 15, 2009 5:56 pm



Postby ReD NeCKersoN » Wed Jul 01, 2009 3:48 am

If you guys want to show us your "cleaned up" cfg it would certainly save the devs some trime. :D
User avatar
ReD NeCKersoN
SG Team
 
Posts: 3245
Joined: Wed Mar 27, 2002 6:22 am
Location: VA, USA



Postby Lucky Bro » Wed Jul 01, 2009 3:09 pm

ReD NeCKersoN wrote:If you guys want to show us your "cleaned up" cfg it would certainly save the devs some trime. :D


:) No, ReD, that won't help to devs :)
All what I've done by that is just have overwritten defeault values/binds with my own (I didn't change default.cfg).
I think you need to get a clean "default.cfg" file. And as I see it - you (not personally you, ReD ;)) just remove everything from default.cfg and remove q3config.cfg file. That will force game to use its default hardcoded (written in code) values.
The only problem with current default.cfg file is that it consists of some non-game variables. And that sometimes confuses users. Because they see the value in game console but when they change it - it doesn't change a thing.

But may be I'm wrong and that is not so easy :) Hope moRtem will help then :)

P.S.
moRtem wrote:hope to see you back in the arena asap !!!

MoRtem, not on Jeux with 16 players online, 4 minutes per round and no-resonable Dago&followers campering on Durango even when they have to rob :) I hate to wait, I have hot blood :)
You may had seen my bro there. He was in Moscow last week and his ping was 70-80ms! He said that way was much easy to play :) Here we have 150-160ms :) So, you may imagine how it is fun to play with camping Dago with his 40ms :)
So, not on Jeux, friend.. :) And not this week too - still got a whole bunch of work to do :( I'm really sorry. See ya later :) Ah, and, yeah, I've learned strafe&circle jumping (not perfecto, but.. I can do famous B2R sometime)! You may proud of me :)
"You should know that the lies won't hide your flaws/No sense in hiding all of yours/You gave up on your dreams along the way" (c) "Fake it" by Seether
P.S. English isn't my native language.
User avatar
Lucky Bro
Gunslinger
 
Posts: 143
Joined: Mon Mar 09, 2009 4:12 pm



Next

Return to Code

Show Sidebar
Show Sidebar

User Control Panel

cron