| 1884 | } |
| 1885 | |
| 1886 | void serverdamage(client *target, client *actor, int damage, int gun, bool gib, const vec &hitpush = vec(0, 0, 0)) |
| 1887 | { |
| 1888 | if ( m_arena && gun == GUN_GRENADE && sg->arenaroundstartmillis + 2000 > sg->gamemillis && target != actor ) return; |
| 1889 | clientstate &ts = target->state; |
| 1890 | ts.dodamage(damage, gun); |
| 1891 | if(damage < INT_MAX) |
| 1892 | { |
| 1893 | actor->state.damage += damage; |
| 1894 | |
| 1895 | sendf(-1, 1, "ri7", gib ? SV_GIBDAMAGE : SV_DAMAGE, target->clientnum, actor->clientnum, gun, damage, ts.armour, ts.health); |
| 1896 | |
| 1897 | if (!isteam(target->team, actor->team)) |
| 1898 | { |
| 1899 | actor->incrementvitacounter(VS_DAMAGE, damage); |
| 1900 | actor->state.enemyfire += damage; |
| 1901 | } |
| 1902 | else |
| 1903 | { |
| 1904 | actor->incrementvitacounter(VS_FRIENDLYDAMAGE, damage); |
| 1905 | actor->state.friendlyfire += damage; |
| 1906 | } |
| 1907 | |
| 1908 | if(target!=actor) |
| 1909 | { |
| 1910 | if(!hitpush.iszero()) |
| 1911 | { |
| 1912 | vec v(hitpush); |
| 1913 | if(!v.iszero()) v.normalize(); |
| 1914 | sendf(target->clientnum, 1, "ri6", SV_HITPUSH, gun, damage, |
| 1915 | int(v.x*DNF), int(v.y*DNF), int(v.z*DNF)); |
| 1916 | } |
| 1917 | } |
| 1918 | } |
| 1919 | if(ts.health<=0) |
| 1920 | { |
| 1921 | int targethasflag = clienthasflag(target->clientnum); |
| 1922 | bool tk = false, suic = false; |
| 1923 | target->state.deaths++; |
| 1924 | target->incrementvitacounter(VS_DEATHS, 1); |
| 1925 | |
| 1926 | if(target!=actor) |
| 1927 | { |
| 1928 | if(!isteam(target->team, actor->team)) |
| 1929 | { |
| 1930 | actor->state.frags += gib && gun != GUN_GRENADE && gun != GUN_SHOTGUN ? 2 : 1; |
| 1931 | actor->incrementvitacounter(VS_FRAGS, 1); |
| 1932 | } |
| 1933 | else |
| 1934 | { |
| 1935 | actor->state.frags--; |
| 1936 | actor->state.teamkills++; |
| 1937 | actor->incrementvitacounter(VS_TKS, 1); |
| 1938 | tk = true; |
| 1939 | } |
| 1940 | } |
| 1941 | else |
| 1942 | { // suicide |
| 1943 | actor->state.frags--; |
no test coverage detected