26

Re: Something against team killers

I'd say, make a mod, take a look how well it is accepted, and eventually it might get into the standard line.

As this doesn't requiree any client changes, its up to the server admins to decide if they want to apply it...

27 (edited by azmeuk 2008-05-17 19:32:23)

Re: Something against team killers

Well, it is very dirty, but it works.
There is a patch :

diff -u -r teeworlds-0.4.2-src/src/game/server/gs_common.h teeworlds-0.4.2-src-mod/src/game/server/gs_common.h
--- teeworlds-0.4.2-src/src/game/server/gs_common.h    2008-04-05 15:13:02.000000000 +0200
+++ teeworlds-0.4.2-src-mod/src/game/server/gs_common.h    2008-05-17 17:58:09.000000000 +0200
@@ -321,6 +321,11 @@
     //
     int64 last_chat;
 
+    // punishment informations
+    int punishment_time;
+    int last_teamkills_ticks[10];
+    int punishment_count;
+
     //
     player();
     void init();
@@ -352,6 +357,9 @@
     
     virtual bool take_damage(vec2 force, int dmg, int from, int weapon);
     virtual void snap(int snaping_client);
+
+    void set_punishment_time(int time);
+    void teamkill_logging(int server_tick);
 };
 
 extern player *players;
diff -u -r teeworlds-0.4.2-src/src/game/server/gs_game.cpp teeworlds-0.4.2-src-mod/src/game/server/gs_game.cpp
--- teeworlds-0.4.2-src/src/game/server/gs_game.cpp    2008-04-05 15:13:02.000000000 +0200
+++ teeworlds-0.4.2-src-mod/src/game/server/gs_game.cpp    2008-05-17 19:08:48.000000000 +0200
@@ -207,8 +207,28 @@
         victim->score--; // suicide
     else
     {
-        if(is_teamplay && victim->team == killer->team)
+            if(is_teamplay && victim->team == killer->team){
             killer->score--; // teamkill
+            killer->teamkill_logging(server_tick());
+
+            //Teamkiller punishment
+            if(config.sv_teamkill_limit && config.sv_punishment_time > 0){
+              int teamkills_last_minute=0;
+              int tick = server_tick();
+
+              for(int i=0; i<10; i++)
+                if( killer->last_teamkills_ticks[i]>0 && (tick- killer->last_teamkills_ticks[i])/server_tickspeed() < 60)
+                  teamkills_last_minute++;
+                  
+
+              if(teamkills_last_minute >= config.sv_teamkill_limit){
+                killer->punishment_count++;
+                killer->set_punishment_time(config.sv_punishment_time * killer->punishment_count);
+
+                dbg_msg("game", "%s has been punished for abusive team kills for %i seconds" ,server_clientname(killer->client_id) ,config.sv_punishment_time * killer->punishment_count);
+              }
+            }
+        }
         else
             killer->score++; // normal kill
     }
diff -u -r teeworlds-0.4.2-src/src/game/server/gs_server.cpp teeworlds-0.4.2-src-mod/src/game/server/gs_server.cpp
--- teeworlds-0.4.2-src/src/game/server/gs_server.cpp    2008-04-05 15:13:02.000000000 +0200
+++ teeworlds-0.4.2-src-mod/src/game/server/gs_server.cpp    2008-05-17 18:54:54.000000000 +0200
@@ -707,6 +707,12 @@
     active_weapon = WEAPON_GUN;
     last_weapon = WEAPON_HAMMER;
     queued_weapon = -1;
+
+    punishment_time=0;
+    punishment_count=0;
+    for(int i=0; i<10; i++)
+      last_teamkills_ticks[i] = 0;
+
 }
 
 void player::destroy() {  }
@@ -1112,7 +1118,7 @@
 
 void player::fire_weapon()
 {
-    if(reload_timer != 0 || active_weapon == WEAPON_NINJA)
+    if(punishment_time != 0 || reload_timer != 0 || active_weapon == WEAPON_NINJA)
         return;
         
     do_weaponswitch();
@@ -1428,6 +1434,10 @@
 
     player_state = input.player_state;
 
+    // decreasing the punishment time
+    if(punishment_time != 0)
+      punishment_time--;
+
     // Previnput
     previnput = input;
     return;
@@ -1678,6 +1688,17 @@
     }
 }
 
+void player::set_punishment_time(int time){
+  punishment_time = time*server_tickspeed();
+}
+
+void player::teamkill_logging(int server_tick){
+  for(int i=10; i; i--)
+    last_teamkills_ticks[i] = last_teamkills_ticks[i-1];
+
+  last_teamkills_ticks[0] = server_tick;
+}
+
 player *players;
 
 //////////////////////////////////////////////////
diff -u -r teeworlds-0.4.2-src/src/engine/e_config_variables.h teeworlds-0.4.2-src-mod/src/engine/e_config_variables.h
--- teeworlds-0.4.2-src/src/engine/e_config_variables.h    2008-04-05 15:13:02.000000000 +0200
+++ teeworlds-0.4.2-src-mod/src/engine/e_config_variables.h    2008-05-17 17:40:07.000000000 +0200
@@ -67,3 +67,6 @@
 MACRO_CONFIG_STR(dbg_stress_server, 32, "localhost")
 
 MACRO_CONFIG_INT(sv_map_reload, 0, 0, 1)
+
+MACRO_CONFIG_INT(sv_punishment_time, 30, 0, 120)
+MACRO_CONFIG_INT(sv_teamkill_limit, 3, 0, 10)

Apply it with

patch -ul -d teeworlds-0.4.2-src -p1 < tkpunish.patch

and compile.

It makes a player be unable to use his weapons during <sv_punishment_time> if he does <sv_teamkill_limit> in one minute.

Play ctf_fall if you dare!

28

Re: Something against team killers

Lol didn't you read my reply about my patch ? xD

29

Re: Something against team killers

Erf, I just ... forgot. Thank you.
I really think that such a improvement should be "officialized" . What does the admin team think about that ?

Play ctf_fall if you dare!

30

Re: Something against team killers

I don't think so. It's more for a mod that people add if they want cause if they have to add all of little stuff like that there is no end.

31 (edited by catpaw 2008-05-19 20:30:08)

Re: Something against team killers

I have a completely new idea about this issue. This should also at least as well, if not better teach people not to shoot around while not coming with the same problems slumbering in the souls of people to turn into onpurpose teamkillers or just not caring...

Say instead of teamkilling and penalizing people not being able to shoot when hitting teammates, what about turing the damage around first place. If you hit a teammate, *YOU* get the damage you would have inflicted to him!

32 (edited by catpaw 2008-05-19 21:14:31)

Re: Something against team killers

Show me the code? Here it is. Following patch will allow two new values for sv_teamdamage 0 and 1 will behave as always, 0 no damage, 1 damage on team mate. But now it will support 2 for damage on both players, and 3 for damage on shooter only.

I use negative damage values to distinguish already "reflected" shots in take_damage so not to have an endless "reflection", not very elegant, but it does the job.

diff -ru teeworlds-0.4.2-org/src/game/g_variables.h teeworlds-0.4.2-src/src/game/g_variables.h
--- teeworlds-0.4.2-org/src/game/g_variables.h  2008-04-05 15:13:02.000000000 +0200
+++ teeworlds-0.4.2-src/src/game/g_variables.h  2008-05-19 21:27:25.000000000 +0200
@@ -46,7 +46,7 @@

MACRO_CONFIG_INT(sv_warmup, 0, 0, 0)
MACRO_CONFIG_STR(sv_motd, 900, "")
-MACRO_CONFIG_INT(sv_teamdamage, 0, 0, 1)
+MACRO_CONFIG_INT(sv_teamdamage, 0, 0, 3)
MACRO_CONFIG_STR(sv_maprotation, 512, "")
MACRO_CONFIG_INT(sv_rounds_per_map, 1, 1, 100)
MACRO_CONFIG_INT(sv_powerups, 1, 0, 1)
diff -ru teeworlds-0.4.2-org/src/game/server/gs_server.cpp teeworlds-0.4.2-src/src/game/server/gs_server.cpp
--- teeworlds-0.4.2-org/src/game/server/gs_server.cpp   2008-04-05 15:13:02.000000000 +0200
+++ teeworlds-0.4.2-src/src/game/server/gs_server.cpp   2008-05-19 21:36:38.000000000 +0200
@@ -1526,6 +1552,17 @@
        if(gameobj->is_friendly_fire(client_id, from) && !config.sv_teamdamage)
                return false;

+       // shoot back teamkills.
+       if(config.sv_teamdamage >= 2 && dmg > 0 && gameobj->is_friendly_fire(client_id, from)) {
+               get_player(from)->take_damage(vec2(0,0), -dmg, client_id, weapon);
+               if (config.sv_teamdamage == 3) {
+                       return false;
+               }
+       }
+       if (dmg < 0) {
+               dmg = -dmg;
+       }
+
        // player only inflicts half damage on self
        if(from == client_id)
                dmg = max(1, dmg/2);