From 64c9966ca0d6d450d8e0a88789742f1d5ecfde09 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Mon, 10 Dec 2007 20:53:37 +0000 Subject: added option for teamdamage --- src/game/server/game_server.cpp | 3 +++ src/game/server/srv_common.cpp | 13 +++++++++++++ src/game/server/srv_common.h | 4 +++- 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'src/game/server') diff --git a/src/game/server/game_server.cpp b/src/game/server/game_server.cpp index 96183457..c146d5c4 100644 --- a/src/game/server/game_server.cpp +++ b/src/game/server/game_server.cpp @@ -1064,6 +1064,9 @@ void player::die(int killer, int weapon) bool player::take_damage(vec2 force, int dmg, int from, int weapon) { core.vel += force; + + if(gameobj->is_friendly_fire(client_id, from) && !config.sv_teamdamage) + return false; // player only inflicts half damage on self if(from == client_id) diff --git a/src/game/server/srv_common.cpp b/src/game/server/srv_common.cpp index 1c338897..21400d63 100644 --- a/src/game/server/srv_common.cpp +++ b/src/game/server/srv_common.cpp @@ -145,6 +145,19 @@ void gameobject::do_warmup(int seconds) warmup = seconds*SERVER_TICK_SPEED; } +bool gameobject::is_friendly_fire(int cid1, int cid2) +{ + if(cid1 == cid2) + return false; + + if(is_teamplay) + { + if(players[cid1].team == players[cid2].team) + return true; + } + + return false; +} void gameobject::tick() { diff --git a/src/game/server/srv_common.h b/src/game/server/srv_common.h index 82375d25..209d99e0 100644 --- a/src/game/server/srv_common.h +++ b/src/game/server/srv_common.h @@ -141,7 +141,9 @@ public: void startround(); void endround(); - + + bool is_friendly_fire(int cid1, int cid2); + virtual void post_reset(); virtual void tick(); -- cgit 1.4.1