vector GetHeadshotMins(entity targ)
{
- return '0.6 0 0' * targ.mins_x + '0 0.6 0' * targ.mins_y + '0 0 1' * (1.3 * targ.view_ofs_z - 0.3 * targ.maxs_z);
+ return '-0.5 0 0' * PL_HEAD_x + '0 -0.5 0' * PL_HEAD_y + '0 0 1' * (targ.maxs_z - PL_HEAD_z);
}
vector GetHeadshotMaxs(entity targ)
{
- return '0.6 0 0' * targ.maxs_x + '0 0.6 0' * targ.maxs_y + '0 0 1' * targ.maxs_z;
+ return '0.5 0 0' * PL_HEAD_x + '0 0.5 0' * PL_HEAD_y + '0 0 1' * targ.maxs_z;
}
void UpdateFrags(entity player, float f)
// NOTE: f=0 means still count as a (positive) kill, but count no frags for it
void W_SwitchWeapon_Force(entity e, float w);
-void GiveFrags (entity attacker, entity targ, float f)
+void GiveFrags (entity attacker, entity targ, float f, float deathtype)
{
float w;
{
// teamkill
PlayerScore_Add(attacker, SP_KILLS, -1); // or maybe add a teamkills field?
+ PlayerStats_Event(attacker, PLAYERSTATS_KILLS, -1);
}
}
else
{
// regular frag
PlayerScore_Add(attacker, SP_KILLS, 1);
+ PlayerStats_Event(attacker, PLAYERSTATS_KILLS, 1);
}
PlayerScore_Add(targ, SP_DEATHS, 1);
if(g_arena || g_ca)
- if(cvar("g_arena_roundbased"))
+ if(autocvar_g_arena_roundbased)
return;
if(targ != attacker) // not for suicides
if(g_weaponarena_random)
{
- // after a frag, choose another random weapon set
- if(inWarmupStage)
- w = warmup_start_weapons;
- else
- w = start_weapons;
+ // after a frag, exchange the current weapon (or the culprit, if detectable) by a new random weapon
+ float culprit;
+ culprit = DEATH_WEAPONOF(deathtype);
+ if(!culprit || !(attacker.weapons & W_WeaponBit(culprit)))
+ culprit = attacker.weapon;
- attacker.weapons = randombits(w - (w & W_WeaponBit(attacker.weapon)), g_weaponarena_random, TRUE);
- if(attacker.weapons < 0)
+ if(g_weaponarena_random_with_laser && culprit == WEPBIT_LASER)
{
- // error from randombits: no weapon available
- // this means we can just give ALL weapons
- attacker.weapons = w;
+ // no exchange
}
+ else
+ {
+ if(inWarmupStage)
+ w = warmup_start_weapons;
+ else
+ w = start_weapons;
+
+ // all others (including the culprit): remove
+ w &~= attacker.weapons;
+
+ // among the remaining ones, choose one by random
+ w = randombits(w, 1, FALSE);
+ if(w)
+ {
+ attacker.weapons |= w;
+ attacker.weapons &~= W_WeaponBit(culprit);
+ }
+ }
+
+ // after a frag, choose another random weapon set
if not(attacker.weapons & W_WeaponBit(attacker.weapon))
W_SwitchWeapon_Force(attacker, w_getbestweapon(attacker));
}
void LogDeath(string mode, float deathtype, entity killer, entity killed)
{
string s;
- if(!cvar("sv_eventlog"))
+ if(!autocvar_sv_eventlog)
return;
s = strcat(":kill:", mode);
s = strcat(s, ":", ftos(killer.playerid));
WriteString(MSG_ALL, s1);
WriteString(MSG_ALL, s2);
WriteString(MSG_ALL, s3);
- WriteByte(MSG_ALL, msg);
+ WriteShort(MSG_ALL, msg);
WriteByte(MSG_ALL, type);
}
-// TODO: writespectatable?
// Function is used to send a generic centerprint whose content CSQC gets to decide (gentle version or not in the below cases)
-void Send_CSQC_Centerprint(entity e, string s1, float deathtype)
+void Send_CSQC_Centerprint(entity e, string s1, string s2, float msg, float type)
{
- msg_entity = e;
- WriteByte(MSG_ONE, SVC_TEMPENTITY);
- WriteByte(MSG_ONE, TE_CSQC_NOTIFY);
- WriteByte(MSG_ONE, CSQC_CENTERPRINT);
- WriteString(MSG_ONE, s1);
- WriteByte(MSG_ONE, deathtype);
+ if (clienttype(e) == CLIENTTYPE_REAL)
+ {
+ msg_entity = e;
+ WRITESPECTATABLE_MSG_ONE({
+ WriteByte(MSG_ONE, SVC_TEMPENTITY);
+ WriteByte(MSG_ONE, TE_CSQC_NOTIFY);
+ WriteByte(MSG_ONE, CSQC_CENTERPRINT);
+ WriteString(MSG_ONE, s1);
+ WriteString(MSG_ONE, s2);
+ WriteShort(MSG_ONE, msg);
+ WriteByte(MSG_ONE, type);
+ });
+ }
}
void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
{
string s, a, msg;
- float p, w, type;
+ float w, type;
if (targ.classname == "player" || targ.classname == "corpse")
{
{
if (deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE)
msg = ColoredTeamName(targ.team); // TODO: check if needed?
- /*
- if (deathtype == DEATH_TEAMCHANGE) {
- centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", ColoredTeamName(targ.team)));
- } else if (deathtype == DEATH_AUTOTEAMCHANGE) {
- centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", ColoredTeamName(targ.team)));
- return;
- } else if (deathtype == DEATH_CAMP) {
- if(sv_gentle)
- centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
- else
- centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
- } else if (deathtype == DEATH_NOAMMO) {
- if(sv_gentle)
- centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
- else
- centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
- } else if (deathtype == DEATH_ROT) {
- if(sv_gentle)
- centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
- else
- centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
- } else if (deathtype == DEATH_MIRRORDAMAGE) {
- if(sv_gentle)
- centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
- else
- centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
- } else if (deathtype == DEATH_QUIET) {
- // do nothing
- } else {
- if(sv_gentle)
- centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
- else
- centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
- }
- */
- Send_CSQC_Centerprint(targ, msg, deathtype);
-
- // TODO: message
- /*
- if(sv_gentle) {
- if (deathtype == DEATH_CAMP)
- bprint ("^1",s, "^1 thought they found a nice camping ground\n");
- else if (deathtype == DEATH_MIRRORDAMAGE)
- bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
- else
- bprint ("^1",s, "^1 will be reinserted into the game due to their own actions\n");
+ if(!g_cts) // no "killed your own dumb self" message in CTS
+ Send_CSQC_Centerprint(targ, msg, "", deathtype, MSG_SUICIDE);
- if(deathtype != DEATH_TEAMCHANGE && deathtype != DEATH_QUIET)
- {
- LogDeath("suicide", deathtype, targ, targ);
- GiveFrags(attacker, targ, -1);
- }
- if (targ.killcount > 2)
- bprint ("^1",s,"^1 faded after a ",ftos(targ.killcount)," point spree\n");
- } else {
- else if (deathtype == DEATH_KILL)
- bprint ("^1",s, "^1 couldn't take it anymore\n");
- else if (deathtype == DEATH_ROT)
- bprint ("^1",s, "^1 died\n");
- else if (deathtype == DEATH_NOAMMO)
- bprint ("^7",s, "^7 committed suicide. What's the point of living without ammo?\n");
- else if (deathtype == DEATH_CAMP)
- bprint ("^1",s, "^1 thought they found a nice camping ground\n");
- else if (deathtype == DEATH_MIRRORDAMAGE)
- bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
- else if (deathtype == DEATH_CHEAT)
- bprint ("^1",s, "^1 unfairly eliminated themself\n");
- else if (deathtype == DEATH_FIRE)
- bprint ("^1",s, "^1 burned to death\n");
- else if (deathtype != DEATH_TEAMCHANGE && deathtype != DEATH_QUIET)
- bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
-
- bprint ("^1",s,"^1 ended it all after a ",ftos(targ.killcount)," kill spree\n");
- }
- */
-
- w = DEATH_WEAPONOF(deathtype);
- bprint("deathtype: ", ftos(deathtype), "\n");
- if(WEP_VALID(w))
- {
- msg = ftos(deathtype);
- deathtype = DEATH_WEAPON;
- }
-
- // TODO: wut is this?
- // givefrags for logging apparently?
if(deathtype != DEATH_TEAMCHANGE && deathtype != DEATH_QUIET)
{
LogDeath("suicide", deathtype, targ, targ);
- GiveFrags(attacker, targ, -1);
+ GiveFrags(attacker, targ, -1, deathtype);
}
if (targ.killcount > 2)
msg = ftos(targ.killcount);
+ if(teams_matter && deathtype == DEATH_MIRRORDAMAGE)
+ {
+ if(attacker.team == COLOR_TEAM1)
+ deathtype = KILL_TEAM_RED;
+ else
+ deathtype = KILL_TEAM_BLUE;
+ }
+
Send_KillNotification(s, msg, ftos(w), deathtype, MSG_SUICIDE);
}
else if (attacker.classname == "player" || attacker.classname == "gib")
{
if(teams_matter && attacker.team == targ.team)
{
- type = KILL_TEAM;
- /*
- if(sv_gentle) {
- // TODO: the centerprint!
- centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against a team mate!"));
- bprint ("^1", a, "^1 took action against a team mate\n");
- } else {
- centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s, ", a team mate!"));
- bprint ("^1", a, "^1 mows down a team mate\n");
- }
- */
- GiveFrags(attacker, targ, -1);
- /*
- if (targ.killcount > 2) {
- if(sv_gentle)
- bprint ("^1",s,"'s ^1",ftos(targ.killcount)," scoring spree was ended by a team mate!\n");
- else
- bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was ended by a team mate!\n");
- }
- if (attacker.killcount > 2) {
- if(sv_gentle)
- bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," scoring spree by going against a team mate\n");
- else
- bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a team mate\n");
- }
- */
+ if(attacker.team == COLOR_TEAM1)
+ type = KILL_TEAM_RED;
+ else
+ type = KILL_TEAM_BLUE;
+
+ GiveFrags(attacker, targ, -1, deathtype);
+
+ Send_CSQC_Centerprint(attacker, s, "", type, MSG_KILL);
if (targ.killcount > 2) {
msg = ftos(targ.killcount);
- a = s;
}
+
if (attacker.killcount > 2) {
msg = ftos(attacker.killcount);
type = KILL_TEAM_SPREE;
}
+ Send_KillNotification(a, s, msg, type, MSG_KILL);
attacker.killcount = 0;
LogDeath("tk", deathtype, attacker, targ);
- Send_CSQC_Centerprint(attacker, s, MSG_KILL);
- Send_KillNotification(a, msg, "", type, MSG_KILL);
}
else
{
- string blood_message, victim_message;
if (!checkrules_firstblood)
{
checkrules_firstblood = TRUE;
Send_KillNotification(a, "", "", KILL_FIRST_BLOOD, MSG_KILL);
- //bprint("^1",a, "^1 drew first blood", "\n");
- // TODO: make these print at newline if they dont
- Send_CSQC_Centerprint(attacker, "", KILL_FIRST_BLOOD);
- Send_CSQC_Centerprint(targ, "", KILL_FIRST_VICTIM);
- //blood_message = "^1First blood\n";
- //victim_message = "^1First victim\n"; // or First casualty
+ // TODO: make these print a newline if they dont
+ Send_CSQC_Centerprint(attacker, "", "", KILL_FIRST_BLOOD, MSG_KILL);
+ Send_CSQC_Centerprint(targ, "", "", KILL_FIRST_VICTIM, MSG_KILL);
}
- //if(sv_gentle > 0) {
- // centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^4You scored against ^7", s, GetAdvancedDeathReports(targ)));
- // centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, a,"^1 scored against you ^7", GetAdvancedDeathReports(attacker)));
-
- if((cvar("sv_fragmessage_information_typefrag")) && (targ.BUTTON_CHAT)) {
- Send_CSQC_Centerprint(attacker, s, KILL_TYPEFRAG);
- //centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^1You typefragged ^7", s, GetAdvancedDeathReports(targ)));
- Send_CSQC_Centerprint(targ, a, KILL_TYPEFRAGGED);
- //centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, victim_message, "^1You were typefragged by ^7", a, GetAdvancedDeathReports(attacker)));
+
+ if((autocvar_sv_fragmessage_information_typefrag) && (targ.BUTTON_CHAT)) {
+ Send_CSQC_Centerprint(attacker, s, GetAdvancedDeathReports(targ), KILL_TYPEFRAG, MSG_KILL);
+ Send_CSQC_Centerprint(targ, a, GetAdvancedDeathReports(attacker), KILL_TYPEFRAGGED, MSG_KILL);
} else {
- Send_CSQC_Centerprint(attacker, s, KILL_FRAG);
- //centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^4You fragged ^7", s, GetAdvancedDeathReports(targ)));
- Send_CSQC_Centerprint(targ, a, KILL_FRAGGED);
- //centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, victim_message, "^1You were fragged by ^7", a, GetAdvancedDeathReports(attacker)));
+ Send_CSQC_Centerprint(attacker, s, GetAdvancedDeathReports(targ), KILL_FRAG, MSG_KILL);
+ Send_CSQC_Centerprint(targ, a, GetAdvancedDeathReports(attacker), KILL_FRAGGED, MSG_KILL);
}
+
attacker.taunt_soundtime = time + 1;
- // TODO: more msg
- //if(sv_gentle) {
- // bprint ("^1",s, "^1 needs a restart thanks to ", a, "\n");
- //} else {
- /*
- w = DEATH_WEAPONOF(deathtype);
- if(WEP_VALID(w))
- {
- w_deathtypestring = "was blasted by";
- w_deathtype = deathtype;
- weapon_action(w, WR_KILLMESSAGE);
- p = strstrofs(w_deathtypestring, "#", 0);
- if(p < 0)
- bprint("^1", s, "^1 ", w_deathtypestring, " ", a, "\n");
- else
- bprint("^1", s, "^1 ", substring(w_deathtypestring, 0, p), a, "^1", substring(w_deathtypestring, p+1, strlen(w_deathtypestring) - (p+1)), "\n");
- }
- else if (deathtype == DEATH_TELEFRAG)
- bprint ("^1",s, "^1 was telefragged by ", a, "\n");
- else if (deathtype == DEATH_DROWN)
- bprint ("^1",s, "^1 was drowned by ", a, "\n");
- else if (deathtype == DEATH_SLIME)
- bprint ("^1",s, "^1 was slimed by ", a, "\n");
- else if (deathtype == DEATH_LAVA)
- bprint ("^1",s, "^1 was cooked by ", a, "\n");
- else if (deathtype == DEATH_FALL)
- bprint ("^1",s, "^1 was grounded by ", a, "\n");
- else if (deathtype == DEATH_SHOOTING_STAR)
- bprint ("^1",s, "^1 was shot into space by ", a, "\n");
- else if (deathtype == DEATH_SWAMP)
- bprint ("^1",s, "^1 was conserved by ", a, "\n");
- else if (deathtype == DEATH_HURTTRIGGER && inflictor.message2 != "")
- {
- p = strstrofs(inflictor.message2, "#", 0);
- if(p < 0)
- bprint("^1", s, "^1 ", inflictor.message2, " ", a, "\n");
- else
- bprint("^1", s, "^1 ", substring(inflictor.message2, 0, p), a, "^1", substring(inflictor.message2, p+1, strlen(inflictor.message2) - (p+1)), "\n");
- }
- else if(deathtype == DEATH_SBCRUSH)
- bprint ("^1",s, "^1 was crushed by ^1", a, "\n");
- else if(deathtype == DEATH_SBMINIGUN)
- bprint ("^1",s, "^1 got shredded by ^1", a, "\n");
- else if(deathtype == DEATH_SBROCKET)
- bprint ("^1",s, "^1 was blased to bits by ^1", a, "\n");
- else if(deathtype == DEATH_SBBLOWUP)
- [
- bprint ("^1",s, "^1 got cought in the destruction of ^1", a, "'s vehicle\n");
-
- else if(deathtype == DEATH_WAKIGUN)
- bprint ("^1",s, "^1 was bolted down by ^1", a, "\n");
- else if(deathtype == DEATH_WAKIROCKET)
- bprint ("^1",s, "^1 could find no shelter from ^1", a, "'s rockets\n");
- else if(deathtype == DEATH_WAKIBLOWUP)
- bprint ("^1",s, "^1 dies when ^1", a, "'s wakizashi dies.\n");
-
- else if(deathtype == DEATH_TURRET)
- bprint ("^1",s, "^1 was pushed into the line of fire by ^1", a, "\n");
- else if(deathtype == DEATH_TOUCHEXPLODE)
- bprint ("^1",s, "^1 was pushed into an accident by ^1", a, "\n");
- else if(deathtype == DEATH_CHEAT)
- bprint ("^1",s, "^1 was unfairly eliminated by ^1", a, "\n");
- else if (deathtype == DEATH_FIRE)
- bprint ("^1",s, "^1 was burnt to death by ^1", a, "\n");
- else if (deathtype == DEATH_CUSTOM)
- bprint ("^1",s, "^1 ", deathmessage, " by ^1", a, "\n");
- else
- bprint ("^1",s, "^1 was fragged by ", a, "\n");
- */
-
- //w = DEATH_WEAPONOF(deathtype);
- bprint("deathtype: ", ftos(deathtype), "\n");
- if(WEP_VALID(w))
- {
- deathtype = DEATH_WEAPON;
- }
+ // TODO: fix this?
+ if (deathtype == DEATH_CUSTOM)
+ msg = deathmessage;
+ else
+ msg = inflictor.message2;
- msg = a;
- if (deathtype == DEATH_CUSTOM)
- msg = strcat(deathmessage, " by ^1", msg);
- Send_KillNotification(s, msg, ftos(w), deathtype, MSG_KILL);
- //}
+ if(strstrofs(msg, "%", 0) < 0)
+ msg = strcat("%s ", msg, " by %s");
+
+ Send_KillNotification(a, s, msg, deathtype, MSG_KILL);
if(g_ctf && targ.flagcarried)
{
UpdateFrags(attacker, ctf_score_value("score_kill"));
PlayerScore_Add(attacker, SP_CTF_FCKILLS, 1);
- GiveFrags(attacker, targ, 0); // for logging
+ GiveFrags(attacker, targ, 0, deathtype); // for logging
}
else
- GiveFrags(attacker, targ, 1);
+ GiveFrags(attacker, targ, 1, deathtype);
if (targ.killcount > 2) {
- /*
- if(sv_gentle)
- bprint ("^1",s,"'s ^1", ftos(targ.killcount), " scoring spree was ended by ", a, "\n");
- else
- bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", a, "\n");
- */
Send_KillNotification(s, ftos(targ.killcount), a, KILL_END_SPREE, MSG_SPREE);
}
attacker.killcount = attacker.killcount + 1;
if (attacker.killcount > 2) {
- /*
- if(sv_gentle)
- bprint ("^1",a,"^1 made ",ftos(attacker.killcount)," scores in a row\n");
- else
- bprint ("^1",a,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
- */
Send_KillNotification(a, ftos(attacker.killcount), "", KILL_SPREE, MSG_SPREE);
}
-
- LogDeath("frag", deathtype, attacker, targ);
-
- if (attacker.killcount == 3)
+ else if (attacker.killcount == 3)
{
- //if(sv_gentle) {
- // bprint (a,"^7 made a ^1TRIPLE SCORE\n");
- //} else {
- // bprint (a,"^7 made a ^1TRIPLE FRAG\n");
- //
Send_KillNotification(a, "", "", KILL_SPREE_3, MSG_SPREE);
AnnounceTo(attacker, "03kills");
-
- //}
}
else if (attacker.killcount == 5)
{
- //if(sv_gentle) {
- // bprint (a,"^7 unleashes ^1SCORING RAGE\n");
- //} else {
- // bprint (a,"^7 unleashes ^1RAGE\n");
Send_KillNotification(a, "", "", KILL_SPREE_5, MSG_SPREE);
AnnounceTo(attacker, "05kills");
- //}
}
else if (attacker.killcount == 10)
{
- //if(sv_gentle) {
- // bprint (a,"^7 made ^1TEN SCORES IN A ROW!\n");
- //} else {
- // bprint (a,"^7 starts the ^1MASSACRE!\n");
Send_KillNotification(a, "", "", KILL_SPREE_10, MSG_SPREE);
AnnounceTo(attacker, "10kills");
- //}
}
else if (attacker.killcount == 15)
{
- /*
- if(sv_gentle) {
- bprint (a,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
- } else {
- bprint (a,"^7 executes ^1MAYHEM!\n");
- AnnounceTo(attacker, "15kills");
- }
- */
Send_KillNotification(a, "", "", KILL_SPREE_15, MSG_SPREE);
AnnounceTo(attacker, "15kills");
}
else if (attacker.killcount == 20)
{
- /*
- if(sv_gentle) {
- bprint (a,"^7 made ^1TWENTY SCORES IN A ROW!\n");
- } else {
- bprint (a,"^7 is a ^1BERSERKER!\n");
- AnnounceTo(attacker, "20kills");
- }
- */
Send_KillNotification(a, "", "", KILL_SPREE_20, MSG_SPREE);
AnnounceTo(attacker, "20kills");
}
else if (attacker.killcount == 25)
{
- /*
- if(sv_gentle) {
- bprint (a,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
- } else {
- bprint (a,"^7 inflicts ^1CARNAGE!\n");
- AnnounceTo(attacker, "25kills");
- }*/
Send_KillNotification(a, "", "", KILL_SPREE_25, MSG_SPREE);
AnnounceTo(attacker, "25kills");
}
else if (attacker.killcount == 30)
{
- /*
- if(sv_gentle) {
- bprint (a,"^7 made ^1THIRTY SCORES IN A ROW!\n");
- } else {
- bprint (a,"^7 unleashes ^1ARMAGEDDON!\n");
- AnnounceTo(attacker, "30kills");
- }
- */
Send_KillNotification(a, "", "", KILL_SPREE_30, MSG_SPREE);
AnnounceTo(attacker, "30kills");
}
+ LogDeath("frag", deathtype, attacker, targ);
}
}
else
{
- //centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
- Send_CSQC_Centerprint(targ, "", MSG_KILL_ACTION);
+ Send_CSQC_Centerprint(targ, "", "", deathtype, MSG_KILL_ACTION);
if (deathtype == DEATH_HURTTRIGGER && inflictor.message != "")
msg = inflictor.message;
else if (deathtype == DEATH_CUSTOM)
msg = deathmessage;
- //bprint ("^1",s, "^1 ", inflictor.message, "\n");
- /*else if (deathtype == DEATH_DROWN)
- if(sv_gentle)
- bprint ("^1",s, "^1 was in the water for too long\n");
- else
- bprint ("^1",s, "^1 drowned\n");
- else if (deathtype == DEATH_SLIME)
- bprint ("^1",s, "^1 was slimed\n");
- else if (deathtype == DEATH_LAVA)
- if(sv_gentle)
- bprint ("^1",s, "^1 found a hot place\n");
- else
- bprint ("^1",s, "^1 turned into hot slag\n");
- else if (deathtype == DEATH_FALL)
- if(sv_gentle)
- bprint ("^1",s, "^1 tested gravity (and it worked)\n");
- else
- bprint ("^1",s, "^1 hit the ground with a crunch\n");
- else if (deathtype == DEATH_SHOOTING_STAR)
- bprint ("^1",s, "^1 became a shooting star\n");
- else if (deathtype == DEATH_SWAMP)
- if(sv_gentle)
- bprint ("^1",s, "^1 discovered a swamp\n");
- else
- bprint ("^1",s, "^1 is now conserved for centuries to come\n");
- else if(deathtype == DEATH_TURRET)
- bprint ("^1",s, "^1 was mowed down by a turret \n");
- else if (deathtype == DEATH_CUSTOM)
- bprint ("^1",s, "^1 ", deathmessage, "\n");
- else if(deathtype == DEATH_TOUCHEXPLODE)
- bprint ("^1",s, "^1 died in an accident\n");
- else if(deathtype == DEATH_CHEAT)
- bprint ("^1",s, "^1 was unfairly eliminated\n");
- else if(deathtype == DEATH_FIRE)
- if(sv_gentle)
- bprint ("^1",s, "^1 felt a little hot\n");
- else
- bprint ("^1",s, "^1 burnt to death\n");
- else
- if(sv_gentle)
- bprint ("^1",s, "^1 needs a restart\n");
- else
- bprint ("^1",s, "^1 died\n");
- */
- GiveFrags(targ, targ, -1);
+ if(strstrofs(msg, "%", 0) < 0)
+ msg = strcat("%s ", msg);
+
+ GiveFrags(targ, targ, -1, deathtype);
if(PlayerScore_Add(targ, SP_SCORE, 0) == -5) {
AnnounceTo(targ, "botlike");
}
if (targ.killcount > 2)
Send_KillNotification(s, ftos(targ.killcount), "", 0, MSG_KILL_ACTION_SPREE);
- //if(sv_gentle)
- // bprint ("^1",s,"^1 needs a restart after a ",ftos(targ.killcount)," scoring spree\n");
- //else
- // bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
LogDeath("accident", deathtype, targ, targ);
}
entity damage_targ;
entity damage_inflictor;
entity damage_attacker;
+.float prevhitsound;
void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
{
damage = 0;
force = '0 0 0';
}
- else if(attacker.team == targ.team)
+ else if(teams_matter && attacker.team == targ.team)
{
- if(teamplay == 1)
+ if(autocvar_teamplay_mode == 1)
damage = 0;
else if(attacker != targ)
{
- if(teamplay == 3)
+ if(autocvar_teamplay_mode == 3)
damage = 0;
- else if(teamplay == 4)
+ else if(autocvar_teamplay_mode == 4)
{
if(targ.classname == "player" && targ.deadflag == DEAD_NO)
{
- teamdamage0 = max(attacker.dmg_team, cvar("g_teamdamage_threshold"));
+ teamdamage0 = max(attacker.dmg_team, autocvar_g_teamdamage_threshold);
attacker.dmg_team = attacker.dmg_team + damage;
if(attacker.dmg_team > teamdamage0 && !g_ca)
- mirrordamage = cvar("g_mirrordamage") * (attacker.dmg_team - teamdamage0);
- mirrorforce = cvar("g_mirrordamage") * vlen(force);
+ mirrordamage = autocvar_g_mirrordamage * (attacker.dmg_team - teamdamage0);
+ mirrorforce = autocvar_g_mirrordamage * vlen(force);
if(g_minstagib)
{
- if(cvar("g_friendlyfire") == 0)
+ if(autocvar_g_friendlyfire == 0)
damage = 0;
}
else if(g_ca)
damage = 0;
else
- damage = cvar("g_friendlyfire") * damage;
+ damage = autocvar_g_friendlyfire * damage;
// mirrordamage will be used LATER
+
+ if(autocvar_g_mirrordamage_virtual)
+ {
+ vector v;
+ v = healtharmor_applydamage(attacker.armorvalue, autocvar_g_balance_armor_blockpercent, mirrordamage);
+ attacker.dmg_take += v_x;
+ attacker.dmg_save += v_y;
+ attacker.dmg_inflictor = inflictor;
+ mirrordamage = 0;
+ mirrorforce = 0;
+ }
+
+ if(autocvar_g_friendlyfire_virtual)
+ {
+ vector v;
+ v = healtharmor_applydamage(targ.armorvalue, autocvar_g_balance_armor_blockpercent, damage);
+ targ.dmg_take += v_x;
+ targ.dmg_save += v_y;
+ targ.dmg_inflictor = inflictor;
+ damage = 0;
+ force = '0 0 0';
+ }
}
else
damage = 0;
if(attacker.classname == "player")
if(attacker != targ)
{
- targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
- attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
+ targ.lms_traveled_distance = autocvar_g_lms_campcheck_distance;
+ attacker.lms_traveled_distance = autocvar_g_lms_campcheck_distance;
}
if(targ.classname == "player")
if (DEATH_ISWEAPON(deathtype, WEP_LASER))
{
damage = 0;
+ mirrordamage = 0;
if (targ != attacker)
{
if ((targ.health >= 1) && (targ.classname == "player"))
centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "Secondary fire inflicts no damage!"));
- damage = 0;
- mirrordamage = 0;
force = '0 0 0';
// keep mirrorforce
attacker = targ;
force = force * g_weaponforcefactor;
mirrorforce *= g_weaponforcefactor;
}
-
+
+ // should this be changed at all? If so, in what way?
+ frag_attacker = attacker;
+ frag_target = targ;
+ frag_damage = damage;
+ frag_force = force;
+ frag_deathtype = deathtype;
+ MUTATOR_CALLHOOK(PlayerDamage_Calculate);
+ damage = frag_damage;
+ force = frag_force;
+
// apply strength multiplier
if ((attacker.items & IT_STRENGTH) && !g_minstagib)
{
if(targ == attacker)
{
- damage = damage * cvar("g_balance_powerup_strength_selfdamage");
- force = force * cvar("g_balance_powerup_strength_selfforce");
+ damage = damage * autocvar_g_balance_powerup_strength_selfdamage;
+ force = force * autocvar_g_balance_powerup_strength_selfforce;
}
else
{
- damage = damage * cvar("g_balance_powerup_strength_damage");
- force = force * cvar("g_balance_powerup_strength_force");
+ damage = damage * autocvar_g_balance_powerup_strength_damage;
+ force = force * autocvar_g_balance_powerup_strength_force;
}
}
// apply invincibility multiplier
if (targ.items & IT_INVINCIBLE && !g_minstagib)
- damage = damage * cvar("g_balance_powerup_invincible_takedamage");
+ damage = damage * autocvar_g_balance_powerup_invincible_takedamage;
if (targ == attacker)
{
- if(g_ca || (g_cts && !cvar("g_cts_selfdamage")))
+ if(g_ca || (g_cts && !autocvar_g_cts_selfdamage))
damage = 0;
else
- damage = damage * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
+ damage = damage * autocvar_g_balance_selfdamagepercent; // Partial damage if the attacker hits himself
}
// CTF: reduce damage/force
if(targ == attacker)
if(targ.flagcarried)
{
- damage = damage * cvar("g_ctf_flagcarrier_selfdamage");
- force = force * cvar("g_ctf_flagcarrier_selfforce");
+ damage = damage * autocvar_g_ctf_flagcarrier_selfdamage;
+ force = force * autocvar_g_ctf_flagcarrier_selfforce;
}
if(g_runematch)
{
if(attacker.runes & CURSE_WEAK) // have both curse & rune
{
- damage = damage * cvar("g_balance_rune_strength_combo_damage");
- force = force * cvar("g_balance_rune_strength_combo_force");
+ damage = damage * autocvar_g_balance_rune_strength_combo_damage;
+ force = force * autocvar_g_balance_rune_strength_combo_force;
}
else
{
- damage = damage * cvar("g_balance_rune_strength_damage");
- force = force * cvar("g_balance_rune_strength_force");
+ damage = damage * autocvar_g_balance_rune_strength_damage;
+ force = force * autocvar_g_balance_rune_strength_force;
}
}
else if (attacker.runes & CURSE_WEAK)
{
- damage = damage * cvar("g_balance_curse_weak_damage");
- force = force * cvar("g_balance_curse_weak_force");
+ damage = damage * autocvar_g_balance_curse_weak_damage;
+ force = force * autocvar_g_balance_curse_weak_force;
}
// apply defense rune
if (targ.runes & RUNE_DEFENSE)
{
if (targ.runes & CURSE_VULNER) // have both curse & rune
- damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
+ damage = damage * autocvar_g_balance_rune_defense_combo_takedamage;
else
- damage = damage * cvar("g_balance_rune_defense_takedamage");
+ damage = damage * autocvar_g_balance_rune_defense_takedamage;
}
else if (targ.runes & CURSE_VULNER)
- damage = damage * cvar("g_balance_curse_vulner_takedamage");
+ damage = damage * autocvar_g_balance_curse_vulner_takedamage;
}
// count the damage
{
if(damage > 0)
{
- if(targ.BUTTON_CHAT)
- attacker.typehitsound += 1;
- else
- attacker.hitsound += 1;
+ if(attacker.weapon != WEP_ELECTRO && attacker.weapon != WEP_LASER || ((attacker.weapon == WEP_ELECTRO && autocvar_g_balance_electro_lightning || attacker.weapon == WEP_LASER) && attacker.prevhitsound + autocvar_sv_hitsound_antispam_time < time))
+ {
+ if(targ.BUTTON_CHAT)
+ attacker.typehitsound += 1;
+ else
+ attacker.hitsound += 1;
+ attacker.prevhitsound = time;
+ }
damage_goodhits += 1;
damage_gooddamage += damage;
if(deathtype & HITTYPE_HEADSHOT)
headshot = 1;
}
+ if(g_ca)
+ PlayerScore_Add(attacker, SP_SCORE, damage * autocvar_g_ca_damage2score_multiplier);
}
}
else
if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
{
- // Savage: vampire mode
- if (g_vampire)
- if (!g_minstagib)
- if (time >= self.spawnshieldtime)
- {
- attacker.health += damage;
- }
if(g_runematch)
{
if (attacker.runes & RUNE_VAMPIRE)
// apply vampire rune
if (attacker.runes & CURSE_EMPATHY) // have the curse too
{
- //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
+ //attacker.health = attacker.health + damage * autocvar_g_balance_rune_vampire_combo_absorb;
attacker.health = bound(
- cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
- attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
- cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
+ autocvar_g_balance_curse_empathy_minhealth, // LA: was 3, now 40
+ attacker.health + damage * autocvar_g_balance_rune_vampire_combo_absorb,
+ autocvar_g_balance_rune_vampire_maxhealth); // LA: was 1000, now 500
}
else
{
- //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
+ //attacker.health = attacker.health + damage * autocvar_g_balance_rune_vampire_absorb;
attacker.health = bound(
attacker.health, // LA: was 3, but changed so that you can't lose health
// empathy won't let you gain health in the same way...
- attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
- cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
+ attacker.health + damage * autocvar_g_balance_rune_vampire_absorb,
+ autocvar_g_balance_rune_vampire_maxhealth); // LA: was 1000, now 500
}
}
// apply empathy curse
else if (attacker.runes & CURSE_EMPATHY)
{
attacker.health = bound(
- cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
- attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
+ autocvar_g_balance_curse_empathy_minhealth, // LA: was 3, now 20
+ attacker.health + damage * autocvar_g_balance_curse_empathy_takedamage,
attacker.health);
}
}
{
attacker = attacker_save;
if(g_minstagib)
- if(mirrordamage > 0)
+ if(mirrordamage > 0)
+ {
+ // just lose extra LIVES, don't kill the player for mirror damage
+ if(attacker.armorvalue > 0)
{
- // just lose extra LIVES, don't kill the player for mirror damage
- if(attacker.armorvalue > 0)
- {
- attacker.armorvalue = attacker.armorvalue - 1;
- centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(attacker.armorvalue)));
- attacker.hitsound += 1;
- }
- mirrordamage = 0;
+ attacker.armorvalue = attacker.armorvalue - 1;
+ centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(attacker.armorvalue)));
+ attacker.hitsound += 1;
}
+ mirrordamage = 0;
+ }
+
force = normalize(attacker.origin + attacker.view_ofs - hitloc) * mirrorforce;
Damage(attacker, inflictor, attacker, mirrordamage, DEATH_MIRRORDAMAGE, attacker.origin, force);
}
}
-vector NearestPointOnBox(entity box, vector org)
-{
- vector m1, m2, nearest;
-
- m1 = box.mins + box.origin;
- m2 = box.maxs + box.origin;
-
- nearest_x = bound(m1_x, org_x, m2_x);
- nearest_y = bound(m1_y, org_y, m2_y);
- nearest_z = bound(m1_z, org_z, m2_z);
-
- return nearest;
-}
-
-void Damage_RecordDamage(entity attacker, float deathtype, float damage)
-{
- float weaponid;
- weaponid = DEATH_WEAPONOF(deathtype);
-
- if not(inWarmupStage)
- if (weaponid)
- if ((clienttype(attacker) == CLIENTTYPE_REAL) | (clienttype(attacker) == CLIENTTYPE_BOT)) {
- attacker.stats_hit[weaponid - 1] += damage;
- attacker.stat_hit = weaponid + 64 * floor(attacker.stats_hit[weaponid - 1]);
- }
-}
-
float RadiusDamage_running;
float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype, entity directhitentity)
// Returns total damage applies to creatures
float tfloorforce;
float stat_damagedone;
- float stat_maxdamage;
if(RadiusDamage_running)
{
- string save;
- print("RadiusDamage called recursively!\n");
- print("Expect stuff to go HORRIBLY wrong.\n");
- print("Causing a stack trace...\n");
- save = cvar_string("prvm_backtraceforwarnings");
- cvar_set("prvm_backtraceforwarnings", "1");
- fclose(-1); // calls VM_Warning
- cvar_set("prvm_backtraceforwarnings", save);
+ backtrace("RadiusDamage called recursively! Expect stuff to go HORRIBLY wrong.");
return 0;
}
RadiusDamage_running = 1;
- tfloordmg = cvar("g_throughfloor_damage");
- tfloorforce = cvar("g_throughfloor_force");
+ tfloordmg = autocvar_g_throughfloor_damage;
+ tfloorforce = autocvar_g_throughfloor_force;
blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
total_damage_to_creatures = 0;
}
stat_damagedone = 0;
- stat_maxdamage = 0;
targ = WarpZone_FindRadius (blastorigin, rad, FALSE);
while (targ)
finaldmg = finaldmg * a;
a = bound(0, tfloorforce + (1-tfloorforce) * hitratio, 1);
force = force * a;
+
+ // laser force adjustments :P
+ if(DEATH_WEAPONOF(deathtype) == WEP_LASER)
+ {
+ vector vel;
+
+ float force_zscale;
+ float force_velocitybiasramp;
+ float force_velocitybias;
+
+ force_velocitybiasramp = autocvar_sv_maxspeed;
+ if(deathtype & HITTYPE_SECONDARY)
+ {
+ force_zscale = autocvar_g_balance_laser_secondary_force_zscale;
+ force_velocitybias = autocvar_g_balance_laser_secondary_force_velocitybias;
+ }
+ else
+ {
+ force_zscale = autocvar_g_balance_laser_primary_force_zscale;
+ force_velocitybias = autocvar_g_balance_laser_primary_force_velocitybias;
+ }
+
+ vel = targ.velocity;
+ vel_z = 0;
+ vel = normalize(vel) * bound(0, vlen(vel) / force_velocitybiasramp, 1) * force_velocitybias;
+ force =
+ vlen(force)
+ *
+ normalize(normalize(force) + vel);
+
+ force_z *= force_zscale;
+ }
+
//if (targ == attacker)
//{
// print("hits ", ftos(hits), " / ", ftos(total));
{
total_damage_to_creatures += finaldmg;
- if(targ.flags & FL_CLIENT)
- if(targ.deadflag == DEAD_NO)
- if(targ != attacker)
- if(!teamplay || targ.team != attacker.team)
- {
+ if(accuracy_isgooddamage(attacker, targ))
stat_damagedone += finaldmg;
- stat_maxdamage += coredamage;
- }
}
if(targ == directhitentity || DEATH_ISSPECIAL(deathtype))
RadiusDamage_running = 0;
- Damage_RecordDamage(attacker, deathtype, min(stat_maxdamage, stat_damagedone));
+ if(!DEATH_ISSPECIAL(deathtype))
+ accuracy_add(attacker, DEATH_WEAPONOFWEAPONDEATH(deathtype), 0, min(coredamage, stat_damagedone));
return total_damage_to_creatures;
}
e.fire_hitsound = FALSE;
}
}
+ if(accuracy_isgooddamage(o, e))
+ accuracy_add(o, DEATH_WEAPONOFWEAPONDEATH(dt), 0, max(0, totaldamage - mindamage));
return max(0, totaldamage - mindamage); // can never be negative, but to make sure
}
else
e.fire_deathtype = dt;
e.fire_owner = o;
e.fire_hitsound = FALSE;
+ if(accuracy_isgooddamage(o, e))
+ accuracy_add(o, DEATH_WEAPONOFWEAPONDEATH(dt), 0, d);
return d;
}
}
if not(Fire_IsBurning(e))
return;
- o = e.owner;
- while(o.owner)
- o = o.owner;
+ for(t = 0, o = e.owner; o.owner && t < 16; o = o.owner, ++t);
if(clienttype(o) == CLIENTTYPE_NOTACLIENT)
o = e.fire_owner;
}
e.fire_hitsound = TRUE;
- Damage_RecordDamage(e.fire_owner, e.fire_deathtype, d);
-
if not(IS_INDEPENDENT_PLAYER(e))
FOR_EACH_PLAYER(other) if(e != other)
{
if not(IS_INDEPENDENT_PLAYER(other))
if(boxesoverlap(e.absmin, e.absmax, other.absmin, other.absmax))
{
- t = cvar("g_balance_firetransfer_time") * (e.fire_endtime - time);
- d = cvar("g_balance_firetransfer_damage") * e.fire_damagepersec * t;
+ t = autocvar_g_balance_firetransfer_time * (e.fire_endtime - time);
+ d = autocvar_g_balance_firetransfer_damage * e.fire_damagepersec * t;
Fire_AddDamage(other, o, d, t, DEATH_FIRE);
}
}