diff options
Diffstat (limited to 'src/game/server')
| -rw-r--r-- | src/game/server/game_server.cpp | 3 | ||||
| -rw-r--r-- | src/game/server/srv_common.cpp | 13 | ||||
| -rw-r--r-- | src/game/server/srv_common.h | 4 |
3 files changed, 19 insertions, 1 deletions
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(); |