MCPcopy Create free account
hub / github.com/assaultcube/AC / dokill

Function dokill

source/src/clientgame.cpp:938–980  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

936}
937
938void dokill(playerent *pl, playerent *act, bool gib, int gun)
939{
940 if(pl->state!=CS_ALIVE || intermission) return;
941
942 exechook(HOOK_SP, "onKill", "%d %d %d %d", act->clientnum, pl->clientnum, gun, gib ? 1 : 0);
943
944 const char *pname = pl == player1 ? "you" : colorname(pl);
945 const char *aname = act == player1 ? "you" : colorname(act);
946 const char *death = killmessage(gun, gib);
947 void (*outf)(const char *s, ...) = (pl == player1 || act == player1) ? hudoutf : conoutf;
948
949 if(pl==act)
950 {
951 outf("\f2%s suicided%s", pname, pl==player1 ? "!" : "");
952 }
953 else if(isteam(pl->team, act->team))
954 {
955 if(pl==player1) outf("\f2you were %s by teammate %s", death, aname);
956 else outf("%s%s %s teammate %s", act==player1 ? "\f3" : "\f2", aname, death, pname);
957 }
958 else
959 {
960 if(pl==player1) outf("\f2you were %s by %s", death, aname);
961 else outf("\f2%s %s %s", aname, death, pname);
962 }
963
964 if(pl == act || isteam(pl->team, act->team))
965 {
966 if(pl != act) act->tks++;
967 if(!m_mp(gamemode)) act->frags--;
968 }
969 else if(!m_mp(gamemode)) act->frags += ( gib && gun != GUN_GRENADE && gun != GUN_SHOTGUN) ? 2 : 1;
970
971 if(gib)
972 {
973 if(pl!=act && gun == GUN_SNIPER) audiomgr.playsound(S_HEADSHOT, SP_LOW);
974 addgib(pl);
975 }
976
977 deathstate(pl);
978 pl->deaths++;
979 audiomgr.playsound(rnd(2) ? S_DIE1 : S_DIE2, pl);
980}
981
982void pstat_weap(int *cn)
983{

Callers 2

parsemessagesFunction · 0.85
dodamageFunction · 0.85

Calls 6

exechookFunction · 0.85
colornameFunction · 0.85
killmessageFunction · 0.85
addgibFunction · 0.85
deathstateFunction · 0.85
playsoundMethod · 0.80

Tested by

no test coverage detected