reaction/reaction/code/game/g_combat.c

2468 lines
77 KiB
C
Raw Normal View History

//-----------------------------------------------------------------------------
//
// $Id$
//
//-----------------------------------------------------------------------------
//
2001-12-31 16:28:42 +00:00
// $Log$
// Revision 1.142 2007/02/03 15:02:21 jbravo
// Renamed RQ3 to Reaction, Dropped loading of various baseq3 media, disabled the follow command, fixed grenades killing teammates and some cleanups
//
// Revision 1.141 2005/02/15 16:33:39 makro
// Tons of updates (entity tree attachment system, UI vectors)
//
// Revision 1.140 2003/04/26 22:33:06 jbravo
// Wratted all calls to G_FreeEnt() to avoid crashing and provide debugging
//
2003-04-26 02:03:51 +00:00
// Revision 1.139 2003/04/26 02:03:51 jbravo
// Helmet fixes
//
// Revision 1.138 2003/04/23 20:32:28 slicer
// With allWeapon/allItems enable it won't toss weapons/items when you die
//
// Revision 1.137 2003/04/19 15:27:30 jbravo
// Backing out of most of unlagged. Only optimized prediction and smooth clients
// remains.
//
2003-04-07 12:29:33 +00:00
// Revision 1.136 2003/04/07 12:29:33 jbravo
// Minor FF system fix
//
// Revision 1.135 2003/03/28 10:36:02 jbravo
// Tweaking the replacement system a bit. Reactionmale now the default model
//
2003-03-22 20:29:26 +00:00
// Revision 1.134 2003/03/22 20:29:26 jbravo
// wrapping linkent and unlinkent calls
//
2003-03-09 21:30:39 +00:00
// Revision 1.133 2003/03/09 21:30:38 jbravo
// Adding unlagged. Still needs work.
//
// Revision 1.132 2003/02/27 03:58:35 jbravo
// Fixed the FF system after adding TDM broke it. Added color to error messages
//
2002-10-30 20:04:34 +00:00
// Revision 1.131 2002/10/30 20:04:34 jbravo
// Adding helmet
//
2002-10-26 22:03:43 +00:00
// Revision 1.130 2002/10/26 22:03:43 jbravo
// Made TeamDM work RQ3 style.
//
// Revision 1.129 2002/10/26 00:37:18 jbravo
// New multiple item code and added PB support to the UI
//
// Revision 1.128 2002/10/04 20:52:39 jbravo
// Think I finally have the mp5 damage right
//
2002-09-29 16:06:45 +00:00
// Revision 1.127 2002/09/29 16:06:44 jbravo
// Work done at the HPWorld expo
//
// Revision 1.126 2002/09/24 05:06:17 blaze
// fixed spectating so ref\'s can now use all the chasecam modes.
//
2002-09-02 02:21:41 +00:00
// Revision 1.125 2002/09/02 02:21:13 niceass
// removed spherical head detection
//
// Revision 1.124 2002/08/28 23:10:06 jbravo
// Added cg_RQ3_SuicideLikeARealMan, timestamping to server logs and
// fixed stats for non-TP modes.
//
// Revision 1.123 2002/08/27 11:28:43 jbravo
// Kevlar hits didnt tell the target who was shooting or of the kevlar got hit
//
// Revision 1.122 2002/08/27 07:50:55 jbravo
// Players can now use the kill cmd, plummet and kill teammates after rounds in
// tp without loosing frags.
//
// Revision 1.121 2002/08/27 01:25:22 jbravo
// Fixed scoring in TOURNAMENT mode and made it a legit gametype.
//
// Revision 1.120 2002/08/23 23:07:01 blaze
// Should have fixed the unkickable thing breaking explosive breakables.
//
// Revision 1.119 2002/08/22 05:00:01 blaze
// Allow func_buttons to be unkickable too (set spawnflags to 8)
//
// Revision 1.118 2002/08/21 03:35:16 niceass
// only get damage points if attacking a client
//
// Revision 1.117 2002/08/21 02:56:08 blaze
// added spawnflags 8 for breakables, lets mappers turn off kicking
//
2002-08-18 20:26:35 +00:00
// Revision 1.116 2002/08/18 20:26:35 jbravo
// New hitboxes. Fixed CTB awards (flags)
//
// Revision 1.115 2002/08/07 16:13:33 jbravo
// Case carrier glowing removed. Ignorenum bug fixed
//
// Revision 1.114 2002/08/03 06:52:35 jbravo
// Fixed the plost3 sound in all radiopaks and now damage is only tracked for
// players you hit that are not on your team
//
// Revision 1.113 2002/07/31 19:56:32 makro
// Fixed the code for doors with health and the wait key set to a negative value
//
2002-07-24 02:17:38 +00:00
// Revision 1.112 2002/07/24 02:17:38 jbravo
// Added a respawn delay for CTB
//
2002-07-20 18:26:25 +00:00
// Revision 1.111 2002/07/20 18:26:25 jbravo
// FF 2 fix for CTB
//
// Revision 1.110 2002/07/20 02:25:53 jbravo
// Added the AQDT CTB sounds to the base radio paks
//
// Revision 1.109 2002/07/07 18:36:13 jbravo
// Added an AntiIdle system. Can play insane sounds for idle players, drop them
// from teams or kick them. Upped version to Beta 2.1
//
// Revision 1.108 2002/07/04 04:20:41 jbravo
// Fixed my weaponchange cancel in the Use cmd, and fixed the bug where players
// that where in eye spectating someone moved on to another player instantly on death.
//
// Revision 1.107 2002/07/02 03:41:59 jbravo
// Fixed a 2 frags pr kill bug, the use cmd now cancels weaponchanges in progress
// and fixed the captain status lingering on people after switching from MM
//
// Revision 1.106 2002/06/30 17:33:01 jbravo
// New radio sounds and the 0wned sound was added.
//
2002-06-29 20:57:25 +00:00
// Revision 1.105 2002/06/29 20:57:25 niceass
// small change to kevlar detection
//
2002-06-24 05:51:51 +00:00
// Revision 1.104 2002/06/24 05:51:51 jbravo
// CTF mode is now semi working
//
2002-06-23 18:29:21 +00:00
// Revision 1.103 2002/06/23 18:29:21 jbravo
// Suicides now always gib.
//
2002-06-22 00:12:53 +00:00
// Revision 1.102 2002/06/22 00:12:53 jbravo
// Cleanup
//
2002-06-21 16:54:15 +00:00
// Revision 1.101 2002/06/21 16:54:15 makro
// Crash bug fix
//
// Revision 1.100 2002/06/21 15:04:55 makro
// Health functionality for movers should be complete now
//
// Revision 1.99 2002/06/20 22:32:43 jbravo
// Added last damaged player and fixed a test2 model problem (atrimum my ass :)
// Changed g_RQ3_printOwnObits to g_RQ3_showOwnKills and it also controls $K
//
2002-06-16 20:09:42 +00:00
// Revision 1.98 2002/06/16 20:09:42 niceass
// knockback fix
//
// Revision 1.97 2002/06/16 20:06:14 jbravo
// Reindented all the source files with "indent -kr -ut -i8 -l120 -lc120 -sob -bad -bap"
//
// Revision 1.96 2002/06/16 17:38:00 jbravo
// Removed the MISSIONPACK ifdefs and missionpack only code.
//
2002-06-13 21:03:31 +00:00
// Revision 1.95 2002/06/13 21:03:31 jbravo
// MOre gibfixes
//
2002-06-13 19:38:43 +00:00
// Revision 1.94 2002/06/13 19:38:43 jbravo
// Small gib fix
//
2002-06-11 23:40:18 +00:00
// Revision 1.93 2002/06/11 23:40:18 jbravo
// Made the head sphere larger
//
2002-06-05 21:54:38 +00:00
// Revision 1.92 2002/06/05 21:54:38 jbravo
// Never say 100% done again ;)
//
// Revision 1.91 2002/06/05 20:52:47 jbravo
// Fixed sniper explode gib and sniper stomach gib. Gibs are now 100% :)
//
2002-06-05 19:53:10 +00:00
// Revision 1.90 2002/06/05 19:53:10 niceass
// gib fix
//
// Revision 1.89 2002/06/05 15:17:51 jbravo
// Gibbed players now vanish (gibs with them tho :() and suicide is no
// longer -2 frags. Added Obit handling for telefrags and better handling
// for unhandled mod's
//
2002-06-03 05:31:31 +00:00
// Revision 1.88 2002/06/03 05:31:31 niceass
// kill message fixed
//
2002-06-03 00:40:25 +00:00
// Revision 1.87 2002/06/03 00:40:25 blaze
// some more breakables fixes(ssg chips)
//
2002-05-31 17:32:11 +00:00
// Revision 1.86 2002/05/31 17:32:11 jbravo
// HC gibs almost working :)
//
2002-05-30 18:22:20 +00:00
// Revision 1.85 2002/05/30 18:22:20 jbravo
// Misc fixes
//
2002-05-28 01:46:58 +00:00
// Revision 1.84 2002/05/28 01:46:58 jbravo
// Added stomach gibbing
//
2002-05-28 01:17:01 +00:00
// Revision 1.83 2002/05/28 01:17:01 jbravo
// More gib fixes. g_RQ3_gib added
//
2002-05-27 06:50:37 +00:00
// Revision 1.82 2002/05/27 06:50:37 niceass
// headless code
//
2002-05-21 17:55:26 +00:00
// Revision 1.81 2002/05/21 17:55:26 jbravo
// Telefrags gave attacker 100000 dmg.
//
2002-05-20 04:59:33 +00:00
// Revision 1.80 2002/05/20 04:59:33 jbravo
// Lots of small fixes.
//
2002-05-19 21:04:37 +00:00
// Revision 1.79 2002/05/19 21:04:37 jbravo
// Tkok popup system
//
// Revision 1.78 2002/05/19 04:48:50 jbravo
// Added sniper headshot and hc really hard hit gibbing. HC event gets lost
// between game and cgame
//
// Revision 1.77 2002/05/18 14:52:16 makro
// Bot stuff. Other stuff. Just... stuff :p
//
// Revision 1.76 2002/05/16 06:57:54 makro
// Doors with health (again !), bot-only trigger_pushes
//
// Revision 1.75 2002/05/15 17:13:22 makro
// Restored Q3A code for movers with health
//
2002-05-15 13:58:35 +00:00
// Revision 1.74 2002/05/15 13:58:35 makro
// Health for movers
//
// Revision 1.73 2002/05/15 05:38:36 niceass
// Knife fix and disabled new headshot code
//
2002-05-12 18:07:08 +00:00
// Revision 1.72 2002/05/12 18:07:08 jbravo
// Yet another obit fix
//
// Revision 1.71 2002/05/11 15:00:04 jbravo
// Fix for autojoin and a very minir for for Obits
//
// Revision 1.70 2002/05/10 08:10:18 jbravo
// Fixed a bug in the Obit system and a give (weapons or all) bug
//
2002-05-10 07:47:23 +00:00
// Revision 1.69 2002/05/10 07:47:23 jbravo
// Forgot grenade obits
//
2002-05-10 04:06:27 +00:00
// Revision 1.68 2002/05/10 04:06:27 jbravo
// Added Ignore
//
// Revision 1.67 2002/05/09 20:58:30 jbravo
// New Obit system and a warning cleanup in zcam
//
2002-05-06 00:35:49 +00:00
// Revision 1.66 2002/05/06 00:35:49 jbravo
// Small fixes to misc stuff
//
2002-05-04 16:13:05 +00:00
// Revision 1.65 2002/05/04 16:13:04 makro
// Bots
//
// Revision 1.64 2002/04/26 04:09:11 jbravo
// Got rid of the grey excelent icon over players heads.
//
// Revision 1.63 2002/04/26 03:39:34 jbravo
// added tkok, fixed players always leaving zcam modes when player thats
// beeing tracked dies
//
// Revision 1.62 2002/04/24 04:25:14 jbravo
// No rewards (humiliation on dead player or Icon on attacker) for knife kills
//
2002-04-22 16:43:34 +00:00
// Revision 1.61 2002/04/22 16:43:34 blaze
// Hey look, breakables explode now! :)
//
2002-04-20 23:54:55 +00:00
// Revision 1.60 2002/04/20 23:54:55 blaze
// opps, breabable fix
//
2002-04-07 03:22:48 +00:00
// Revision 1.59 2002/04/07 03:22:48 jbravo
// Tweaks and crashbug fixes
//
2002-04-06 20:47:24 +00:00
// Revision 1.58 2002/04/06 20:47:24 niceass
// fall damage bug fix
//
// Revision 1.57 2002/04/03 09:26:47 jbravo
// New FF system. Warns and then finally kickbans teamwounders and
// teamkillers
//
// Revision 1.56 2002/04/03 03:13:16 blaze
// NEW BREAKABLE CODE - will break all old breakables(wont appear in maps)
//
2002-03-31 03:31:24 +00:00
// Revision 1.55 2002/03/31 03:31:24 jbravo
// Compiler warning cleanups
//
// Revision 1.54 2002/03/30 17:37:48 jbravo
// Added damage tracking to the server. Added zcam flic mode. cleaned up g_damage.
//
2002-03-18 19:19:08 +00:00
// Revision 1.53 2002/03/18 19:18:39 slicer
// Fixed bandage bugs ( i hope )
//
// Revision 1.52 2002/03/18 12:25:10 jbravo
// Live players dont get fraglines, except their own. Cleanups and some
// hacks to get bots to stop using knives only.
//
2002-03-17 03:35:29 +00:00
// Revision 1.51 2002/03/17 03:35:29 jbravo
// More radio tewaks and cleanups.
//
// Revision 1.50 2002/03/14 23:54:12 jbravo
// Added a variable system from AQ. Works the same except it uses $ for %
//
// Revision 1.49 2002/03/12 04:55:31 blaze
// stats should only be recored when the round is in progress
//
// Revision 1.48 2002/03/04 21:28:57 jbravo
// Make spectators that are following someone who dies stop at the time of
// death and not respawn somewhere else.
//
2002-03-03 21:46:26 +00:00
// Revision 1.47 2002/03/03 21:46:26 blaze
// weapon stats, done, beta test for bugs
//
2002-03-01 18:21:26 +00:00
// Revision 1.46 2002/03/01 18:21:26 jbravo
// Cleanups and removal of g_RQ3_sniperup
//
// Revision 1.45 2002/02/25 19:41:53 jbravo
// Fixed the use ESC and join menu to join teams when dead players are
// spectating in TP mode.
// Tuned the autorespawn system a bit. Now dead ppl. are dead for a very
// small time before they are made into spectators.
//
// Revision 1.44 2002/02/24 18:49:21 jbravo
// Make it OK to frag teammates after rounds are over (no -1)
//
2002-02-22 02:13:13 +00:00
// Revision 1.43 2002/02/22 02:13:13 jbravo
// Fixed a few bugs and did some cleanups
//
// Revision 1.42 2002/02/10 21:21:23 slicer
// Saving persistant and other data on some events..
//
// Revision 1.41 2002/02/07 23:31:22 niceass
// fixed a bug in G_Combat that assumed pointers waren't NULL (only in DLLs was it a problem)
//
// Revision 1.40 2002/02/07 21:01:48 niceass
// AddScore bug fixed. I thought I put this in already!
//
// Revision 1.39 2002/02/06 03:10:43 jbravo
// Fix the instant spectate on death and an attempt to fix the scores
//
// Revision 1.38 2002/02/05 10:45:31 jbravo
// Cleaning up player_die and possibly fixing the scores
//
// Revision 1.37 2002/01/31 01:53:30 jbravo
// FF/no-FF fixes. g_friendlyFire 0 = no FF, 1 = FF, 2 = no FF + knockback
//
// Revision 1.36 2002/01/12 20:02:16 hal9000
// Verify we have a valid client pointer before using its members
//
2002-01-11 20:20:58 +00:00
// Revision 1.35 2002/01/11 20:20:58 jbravo
// Adding TP to main branch
//
// Revision 1.34 2002/01/11 19:48:30 jbravo
// Formatted the source in non DOS format.
//
2001-12-31 16:28:42 +00:00
// Revision 1.33 2001/12/31 16:28:42 jbravo
// I made a Booboo with the Log tag.
//
//
//-----------------------------------------------------------------------------
2001-05-06 20:50:27 +00:00
// Copyright (C) 1999-2000 Id Software, Inc.
//
// g_combat.c
#include "g_local.h"
/*
============
ScorePlum
============
*/
void ScorePlum(gentity_t * ent, vec3_t origin, int score)
{
2001-05-06 20:50:27 +00:00
gentity_t *plum;
plum = G_TempEntity(origin, EV_SCOREPLUM);
2001-05-06 20:50:27 +00:00
// only send this temp entity to a single client
plum->r.svFlags |= SVF_SINGLECLIENT;
2001-12-17 15:08:34 +00:00
2001-05-06 20:50:27 +00:00
plum->r.singleClient = ent->s.number;
//
plum->s.otherEntityNum = ent->s.number;
plum->s.time = score;
}
/*
============
AddScore
Adds score to both the client and his team
============
*/
void AddScore(gentity_t * ent, vec3_t origin, int score)
{
if (!ent->client) {
2001-05-06 20:50:27 +00:00
return;
}
// no scoring during pre-match warmup
//if ( level.warmupTime ) {
// return;
//}
2001-05-06 20:50:27 +00:00
// show score plum
// JBravo: not in TP
if (g_gametype.integer != GT_TEAMPLAY)
ScorePlum(ent, origin, score);
2001-05-06 20:50:27 +00:00
//
ent->client->ps.persistant[PERS_SCORE] += score;
2002-10-26 22:03:43 +00:00
if (g_gametype.integer == GT_TEAM && score > 0)
level.teamScores[ent->client->ps.persistant[PERS_TEAM]] += score;
2001-05-06 20:50:27 +00:00
CalculateRanks();
}
/*
=================
TossClientItems
Toss the weapon and powerups for the killed player
=================
*/
void TossClientItems(gentity_t * self)
{
gitem_t *item, *dropitem;
int weapon, i;
float angle;
gentity_t *drop;
//Elder: added
int weaponInventory;
2001-05-06 20:50:27 +00:00
// drop the weapon if not a gauntlet or machinegun
weapon = self->s.weapon;
//Slicer: don't drop weapons with all weapons enable..
if(g_RQ3_allWeapons.integer)
return;
//Elder: run through player STAT_WEAPONS and drop any unique weapons
//That way, we can also account for servers with extra weapons
//BTW, that means no cheating to get all weapons or it'll spawn mad!!
weaponInventory = self->client->ps.stats[STAT_WEAPONS];
//Elder: throw items in a "circle" starting at a random angle
i = level.time;
angle = Q_random(&i) * 30;
//angle = 0;
//Elder: added hadUniqueWeapons check - returns to qfalse if died with the gun
//as opposed to dropping it, then died
2001-11-25 23:04:08 +00:00
2002-09-29 16:06:45 +00:00
if ((weaponInventory & (1 << WP_M3)) == (1 << WP_M3) && ((int) g_RQ3_weaponban.integer & WPF_M3)) {
while (self->client->weaponCount[WP_M3]) {
item = BG_FindItemForWeapon(WP_M3);
Drop_Item(self, item, angle);
self->client->pers.hadUniqueWeapon[WP_M3] = qfalse;
self->client->uniqueWeapons--;
angle += 30;
self->client->weaponCount[WP_M3]--;
}
}
2001-11-25 23:04:08 +00:00
2002-09-29 16:06:45 +00:00
if ((weaponInventory & (1 << WP_M4)) == (1 << WP_M4) && ((int) g_RQ3_weaponban.integer & WPF_M4)) {
while (self->client->weaponCount[WP_M4]) {
item = BG_FindItemForWeapon(WP_M4);
Drop_Item(self, item, angle);
self->client->pers.hadUniqueWeapon[WP_M4] = qfalse;
self->client->uniqueWeapons--;
angle += 30;
self->client->weaponCount[WP_M4]--;
}
}
2001-11-25 23:04:08 +00:00
2002-09-29 16:06:45 +00:00
if ((weaponInventory & (1 << WP_MP5)) == (1 << WP_MP5) && ((int) g_RQ3_weaponban.integer & WPF_MP5)) {
while (self->client->weaponCount[WP_MP5]) {
item = BG_FindItemForWeapon(WP_MP5);
Drop_Item(self, item, angle);
self->client->pers.hadUniqueWeapon[WP_MP5] = qfalse;
self->client->uniqueWeapons--;
angle += 30;
self->client->weaponCount[WP_MP5]--;
}
}
2001-11-25 23:04:08 +00:00
2002-09-29 16:06:45 +00:00
if ((weaponInventory & (1 << WP_HANDCANNON)) == (1 << WP_HANDCANNON) && ((int) g_RQ3_weaponban.integer & WPF_HC)) {
while (self->client->weaponCount[WP_HANDCANNON]) {
item = BG_FindItemForWeapon(WP_HANDCANNON);
Drop_Item(self, item, angle);
self->client->pers.hadUniqueWeapon[WP_HANDCANNON] = qfalse;
self->client->uniqueWeapons--;
angle += 30;
self->client->weaponCount[WP_HANDCANNON]--;
}
}
2001-11-25 23:04:08 +00:00
2002-09-29 16:06:45 +00:00
if ((weaponInventory & (1 << WP_SSG3000)) == (1 << WP_SSG3000) && ((int) g_RQ3_weaponban.integer & WPF_SNIPER)) {
while (self->client->weaponCount[WP_SSG3000]) {
item = BG_FindItemForWeapon(WP_SSG3000);
Drop_Item(self, item, angle);
self->client->pers.hadUniqueWeapon[WP_SSG3000] = qfalse;
self->client->uniqueWeapons--;
angle += 30;
self->client->weaponCount[WP_SSG3000]--;
}
}
//Elder: Always drop the pistol
2002-09-29 16:06:45 +00:00
if ((int) g_RQ3_weaponban.integer & WPF_MK23) {
item = BG_FindItemForWeapon(WP_PISTOL);
Drop_Item(self, item, angle);
angle += 30;
}
//Elder: drop a knife if player has at least one
2002-09-29 16:06:45 +00:00
if (self->client->ps.ammo[WP_KNIFE] > 0 && ((int) g_RQ3_weaponban.integer & WPF_KNIFE)) {
item = BG_FindItemForWeapon(WP_KNIFE);
Drop_Item(self, item, angle);
angle += 30;
}
//Slicer: don't drop Items with all weapons enable..
if(g_RQ3_allItems.integer)
return;
// JBravo: drop all items in the new item system.
for (i = HI_NUM_HOLDABLE - 1; i > 0; i--) {
if (self->client->ps.stats[STAT_HOLDABLE_ITEM] & (1 << i)) {
dropitem = BG_FindItemForHoldable(i);
Drop_Item(self, dropitem, angle);
angle += 30;
}
}
2001-05-06 20:50:27 +00:00
// drop all the powerups if not in teamplay
if (g_gametype.integer != GT_TEAM) {
2001-05-06 20:50:27 +00:00
angle = 45;
for (i = 1; i < PW_NUM_POWERUPS; i++) {
if (self->client->ps.powerups[i] > level.time) {
item = BG_FindItemForPowerup(i);
if (!item) {
2001-05-06 20:50:27 +00:00
continue;
}
drop = Drop_Item(self, item, angle);
2001-05-06 20:50:27 +00:00
// decide how many seconds it has left
drop->count = (self->client->ps.powerups[i] - level.time) / 1000;
if (drop->count < 1) {
2001-05-06 20:50:27 +00:00
drop->count = 1;
}
angle += 45;
}
}
}
}
/*
==================
LookAtKiller
==================
*/
void LookAtKiller(gentity_t * self, gentity_t * inflictor, gentity_t * attacker)
{
vec3_t dir;
vec3_t angles;
if (attacker && attacker != self) {
VectorSubtract(attacker->s.pos.trBase, self->s.pos.trBase, dir);
} else if (inflictor && inflictor != self) {
VectorSubtract(inflictor->s.pos.trBase, self->s.pos.trBase, dir);
2001-05-06 20:50:27 +00:00
} else {
self->client->ps.stats[STAT_DEAD_YAW] = self->s.angles[YAW];
return;
}
self->client->ps.stats[STAT_DEAD_YAW] = vectoyaw(dir);
2001-05-06 20:50:27 +00:00
angles[YAW] = vectoyaw(dir);
2001-11-25 23:04:08 +00:00
angles[PITCH] = 0;
2001-05-06 20:50:27 +00:00
angles[ROLL] = 0;
}
/*
==================
GibEntity
==================
*/
void GibEntity(gentity_t * self, int killer)
{
2002-06-13 21:03:31 +00:00
if (g_RQ3_gib.integer < 3)
return;
G_AddEvent(self, EV_GIB_PLAYER, killer);
2001-05-06 20:50:27 +00:00
self->takedamage = qfalse;
self->s.eType = ET_INVISIBLE;
self->r.contents = 0;
}
2002-05-28 01:17:01 +00:00
// JBravo: head gibbing
void GibEntity_Headshot(gentity_t * self, int killer)
{
G_AddEvent(self, EV_GIB_PLAYER_HEADSHOT, 0);
2002-05-28 01:17:01 +00:00
self->client->noHead = qtrue;
}
2002-05-28 01:46:58 +00:00
// JBravo: stomach gibbing
void GibEntity_Stomach(gentity_t * self, int killer)
{
G_TempEntity(self->r.currentOrigin, EV_GIB_PLAYER_STOMACH);
2002-05-28 01:46:58 +00:00
}
2001-05-06 20:50:27 +00:00
/*
==================
body_die
==================
*/
void body_die(gentity_t * self, gentity_t * inflictor, gentity_t * attacker, int damage, int meansOfDeath)
{
if (self->health > GIB_HEALTH) {
2001-05-06 20:50:27 +00:00
return;
}
2002-05-28 01:17:01 +00:00
// JBravo: Gib control
if (g_RQ3_gib.integer == 0) {
return;
}
if (!g_blood.integer) {
self->health = GIB_HEALTH + 1;
2001-05-06 20:50:27 +00:00
return;
}
2002-08-18 20:26:35 +00:00
if (attacker->client
&& ((g_gametype.integer == GT_TEAMPLAY && level.team_round_going) || g_gametype.integer != GT_TEAMPLAY))
attacker->client->pers.records[REC_GIBSHOTS]++;
GibEntity(self, 0);
2001-05-06 20:50:27 +00:00
}
// these are just for logging, the client prints its own messages
char *modNames[] = {
2001-05-06 20:50:27 +00:00
"MOD_UNKNOWN",
"MOD_SHOTGUN",
"MOD_GAUNTLET",
"MOD_MACHINEGUN",
"MOD_GRENADE",
"MOD_GRENADE_SPLASH",
"MOD_ROCKET",
"MOD_ROCKET_SPLASH",
"MOD_PLASMA",
"MOD_PLASMA_SPLASH",
"MOD_RAILGUN",
"MOD_LIGHTNING",
"MOD_BFG",
"MOD_BFG_SPLASH",
"MOD_WATER",
"MOD_SLIME",
"MOD_LAVA",
"MOD_CRUSH",
"MOD_TELEFRAG",
"MOD_FALLING",
"MOD_SUICIDE",
"MOD_TARGET_LASER",
"MOD_TRIGGER_HURT",
"MOD_GRAPPLE",
//Blaze: Reaction MOD's
"MOD_KNIFE",
"MOD_KNIFE_THROWN",
"MOD_PISTOL",
"MOD_M4",
"MOD_SNIPER",
"MOD_MP5",
"MOD_AKIMBO",
"MOD_M3",
"MOD_HANDCANNON",
"MOD_KICK",
"MOD_BLEEDING",
//Makro - entity-defined
"MOD_CUSTOM"
2001-05-06 20:50:27 +00:00
};
/*
==================
CheckAlmostCapture
==================
*/
void CheckAlmostCapture(gentity_t * self, gentity_t * attacker)
{
gentity_t *ent;
vec3_t dir;
char *classname;
2001-05-06 20:50:27 +00:00
// if this player was carrying a flag
if (self->client->ps.powerups[PW_REDFLAG] ||
self->client->ps.powerups[PW_BLUEFLAG] || self->client->ps.powerups[PW_NEUTRALFLAG]) {
2001-05-06 20:50:27 +00:00
// get the goal flag this player should have been going for
if (g_gametype.integer == GT_CTF) {
if (self->client->sess.sessionTeam == TEAM_BLUE) {
2001-05-06 20:50:27 +00:00
classname = "team_CTF_blueflag";
} else {
2001-05-06 20:50:27 +00:00
classname = "team_CTF_redflag";
}
} else {
if (self->client->sess.sessionTeam == TEAM_BLUE) {
2001-05-06 20:50:27 +00:00
classname = "team_CTF_redflag";
} else {
2001-05-06 20:50:27 +00:00
classname = "team_CTF_blueflag";
}
}
ent = NULL;
do {
2001-05-06 20:50:27 +00:00
ent = G_Find(ent, FOFS(classname), classname);
} while (ent && (ent->flags & FL_DROPPED_ITEM));
// if we found the destination flag and it's not picked up
if (ent && !(ent->r.svFlags & SVF_NOCLIENT)) {
2001-05-06 20:50:27 +00:00
// if the player was *very* close
VectorSubtract(self->client->ps.origin, ent->s.origin, dir);
if (VectorLength(dir) < 200) {
2001-05-06 20:50:27 +00:00
self->client->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_HOLYSHIT;
if (attacker->client) {
2001-05-06 20:50:27 +00:00
attacker->client->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_HOLYSHIT;
}
}
}
}
}
/*
==================
CheckAlmostScored
==================
*/
void CheckAlmostScored(gentity_t * self, gentity_t * attacker)
{
gentity_t *ent;
vec3_t dir;
char *classname;
2001-05-06 20:50:27 +00:00
// if the player was carrying cubes
if (self->client->ps.generic1) {
if (self->client->sess.sessionTeam == TEAM_BLUE) {
2001-05-06 20:50:27 +00:00
classname = "team_redobelisk";
} else {
2001-05-06 20:50:27 +00:00
classname = "team_blueobelisk";
}
ent = G_Find(NULL, FOFS(classname), classname);
// if we found the destination obelisk
if (ent) {
2001-05-06 20:50:27 +00:00
// if the player was *very* close
VectorSubtract(self->client->ps.origin, ent->s.origin, dir);
if (VectorLength(dir) < 200) {
2001-05-06 20:50:27 +00:00
self->client->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_HOLYSHIT;
if (attacker->client) {
2001-05-06 20:50:27 +00:00
attacker->client->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_HOLYSHIT;
}
}
}
}
}
/*
==================
SendObit
JBravo: actually send the messages
==================
*/
void SendObit(char *msg, gentity_t * deadguy, gentity_t * attacker)
{
int i;
gentity_t *other;
if (g_gametype.integer != GT_TEAMPLAY) {
trap_SendServerCommand(-1, va("print \"%s\"", msg));
} else {
if (g_RQ3_showOwnKills.integer == 0) {
for (i = 0; i < level.maxclients; i++) {
//Blaze: Prit out some Debug info
if (&g_entities[i] == NULL) G_Printf("Ln 0693\n");
other = &g_entities[i];
if (!other->inuse || !other->client)
continue;
if (deadguy != other && level.team_round_going
&& other->client->sess.sessionTeam != TEAM_SPECTATOR)
continue;
trap_SendServerCommand(other - g_entities, va("print \"%s\"", msg));
}
} else {
for (i = 0; i < level.maxclients; i++) {
//Blaze: Prit out some Debug info
if (&g_entities[i] == NULL) G_Printf("Ln 1399\n");
other = &g_entities[i];
if (!other->inuse || !other->client)
continue;
if (deadguy != other && other != attacker &&
level.team_round_going && other->client->sess.sessionTeam != TEAM_SPECTATOR)
continue;
trap_SendServerCommand(other - g_entities, va("print \"%s\"", msg));
}
}
}
}
/*
==================
PrintDeathMessage
JBravo: new Obit system
==================
*/
void PrintDeathMessage(gentity_t * target, gentity_t * attacker, int location, int meansOfDeath)
{
int n, gender;
char message[128], message2[128], death_msg[512];
gender = target->client->radioGender;
message[0] = message2[0] = '\0';
switch (meansOfDeath) {
case MOD_SUICIDE:
Q_strncpyz(message, "suicides", sizeof(message));
break;
case MOD_FALLING:
if (gender == GENDER_FEMALE)
Q_strncpyz(message, "plummets to her death", sizeof(message));
else if (gender == GENDER_NEUTER)
Q_strncpyz(message, "plummets to its death", sizeof(message));
else
Q_strncpyz(message, "plummets to his death", sizeof(message));
break;
case MOD_CRUSH:
Q_strncpyz(message, "was flattened", sizeof(message));
break;
case MOD_WATER:
Q_strncpyz(message, "sank like a rock", sizeof(message));
break;
case MOD_SLIME:
Q_strncpyz(message, "melted", sizeof(message));
break;
case MOD_LAVA:
Q_strncpyz(message, "does a back flip into the lava", sizeof(message));
break;
case MOD_TARGET_LASER:
Q_strncpyz(message, "saw the light", sizeof(message));
break;
case MOD_TRIGGER_HURT:
Q_strncpyz(message, "was in the wrong place", sizeof(message));
break;
case MOD_BLEEDING:
Q_strncpyz(message, "bleeds to death", sizeof(message));
break;
default:
//Makro - added check for MOD_CUSTOM+index mods
if (meansOfDeath >= MOD_CUSTOM && meansOfDeath - MOD_CUSTOM < level.numCustomDeathMsg)
{
//TODO: replace %he% with he/she/it based on gender. Same thing for %his%
Q_strncpyz(message, level.customDeathMsg[meansOfDeath-MOD_CUSTOM], sizeof(message));
} else {
message[0] = '\0';
}
break;
}
if (attacker == target) {
switch (meansOfDeath) {
case MOD_GRENADE_SPLASH:
if (gender == GENDER_FEMALE)
Q_strncpyz(message, "didn't throw her grenade far enough", sizeof(message));
else if (gender == GENDER_NEUTER)
Q_strncpyz(message, "didn't throw its grenade far enough", sizeof(message));
else
Q_strncpyz(message, "didn't throw his grenade far enough", sizeof(message));
break;
case MOD_ROCKET_SPLASH:
if (gender == GENDER_FEMALE)
Q_strncpyz(message, "blew herself up", sizeof(message));
else if (gender == GENDER_NEUTER)
Q_strncpyz(message, "blew itself up", sizeof(message));
else
Q_strncpyz(message, "blew himself up", sizeof(message));
break;
case MOD_PLASMA_SPLASH:
if (gender == GENDER_FEMALE)
Q_strncpyz(message, "melted herself", sizeof(message));
else if (gender == GENDER_NEUTER)
Q_strncpyz(message, "melted itself", sizeof(message));
else
Q_strncpyz(message, "melted himself", sizeof(message));
break;
case MOD_BFG_SPLASH:
Q_strncpyz(message, "should have used a smaller gun", sizeof(message));
break;
default:
if (gender == GENDER_FEMALE)
Q_strncpyz(message, "killed herself", sizeof(message));
else if (gender == GENDER_NEUTER)
Q_strncpyz(message, "killed itself", sizeof(message));
else
Q_strncpyz(message, "killed himself", sizeof(message));
break;
}
}
if (attacker->client && attacker != target)
message[0] = '\0';
if (message[0] != '\0') {
Com_sprintf(death_msg, sizeof(death_msg), "%s^7 %s\n", target->client->pers.netname, message);
SendObit(death_msg, target, attacker);
return;
}
if (attacker->client) {
switch (meansOfDeath) {
case MOD_FALLING:
Q_strncpyz(message, " was taught how to fly by", sizeof(message));
break;
case MOD_PISTOL:
switch (location) {
case LOC_HDAM:
if (gender == GENDER_NEUTER)
Q_strncpyz(message, " has a hole in its head from", sizeof(message));
else if (gender == GENDER_FEMALE)
Q_strncpyz(message, " has a hole in her head from", sizeof(message));
else
Q_strncpyz(message, " has a hole in his head from", sizeof(message));
Q_strncpyz(message2, "'s Mark 23 pistol", sizeof(message2));
break;
case LOC_CDAM:
Q_strncpyz(message, " loses a vital chest organ thanks to", sizeof(message));
Q_strncpyz(message2, "'s Mark 23 pistol", sizeof(message2));
break;
case LOC_SDAM:
if (gender == GENDER_NEUTER)
Q_strncpyz(message, " loses its lunch to", sizeof(message));
else if (gender == GENDER_FEMALE)
Q_strncpyz(message, " loses her lunch to", sizeof(message));
else
Q_strncpyz(message, " loses his lunch to", sizeof(message));
Q_strncpyz(message2, "'s .45 caliber pistol round", sizeof(message));
break;
case LOC_LDAM:
Q_strncpyz(message, " is legless because of", sizeof(message));
Q_strncpyz(message2, "'s Mark 23 pistol", sizeof(message2));
break;
default:
Q_strncpyz(message, "was shot by", sizeof(message));
Q_strncpyz(message2, "'s Mark 23 Pistol", sizeof(message2));
}
break;
case MOD_MP5:
switch (location) {
case LOC_HDAM:
Q_strncpyz(message, "'s brains are on the wall thanks to", sizeof(message));
Q_strncpyz(message2, "'s 10mm MP5/10 round", sizeof(message));
break;
case LOC_CDAM:
Q_strncpyz(message, " feels some chest pain via", sizeof(message));
Q_strncpyz(message2, "'s MP5/10 Submachinegun", sizeof(message));
break;
case LOC_SDAM:
Q_strncpyz(message, " needs some Pepto Bismol after", sizeof(message));
Q_strncpyz(message2, "'s 10mm MP5 round", sizeof(message2));
2002-05-10 07:47:23 +00:00
break;
case LOC_LDAM:
if (gender == GENDER_NEUTER)
Q_strncpyz(message, " had its legs blown off thanks to", sizeof(message));
else if (gender == GENDER_FEMALE)
Q_strncpyz(message, " had her legs blown off thanks to", sizeof(message));
else
Q_strncpyz(message, " had his legs blown off thanks to", sizeof(message));
Q_strncpyz(message2, "'s MP5/10 Submachinegun", sizeof(message2));
2002-05-10 07:47:23 +00:00
break;
default:
Q_strncpyz(message, " was shot by", sizeof(message));
Q_strncpyz(message2, "'s MP5/10 Submachinegun", sizeof(message2));
}
break;
case MOD_M4:
switch (location) {
case LOC_HDAM:
Q_strncpyz(message, " had a makeover by", sizeof(message));
Q_strncpyz(message2, "'s M4 Assault Rifle", sizeof(message2));
break;
case LOC_CDAM:
Q_strncpyz(message, " feels some heart burn thanks to", sizeof(message));
Q_strncpyz(message2, "'s M4 Assault Rifle", sizeof(message2));
break;
case LOC_SDAM:
Q_strncpyz(message, " has an upset stomach thanks to", sizeof(message));
Q_strncpyz(message2, "'s M4 Assault Rifle", sizeof(message2));
break;
case LOC_LDAM:
Q_strncpyz(message, " is now shorter thanks to", sizeof(message));
Q_strncpyz(message2, "'s M4 Assault Rifle", sizeof(message2));
break;
default:
Q_strncpyz(message, " was shot by", sizeof(message));
Q_strncpyz(message2, "'s M4 Assault Rifle", sizeof(message2));
}
break;
case MOD_M3:
n = rand() % 2 + 1;
if (n == 1) {
Q_strncpyz(message, " accepts", sizeof(message));
Q_strncpyz(message2, "'s M3 Super 90 Assault Shotgun in hole-y matrimony",
sizeof(message2));
} else {
Q_strncpyz(message, " is full of buckshot from", sizeof(message));
Q_strncpyz(message2, "'s M3 Super 90 Assault Shotgun", sizeof(message2));
}
break;
case MOD_HANDCANNON:
n = rand() % 2 + 1;
if (n == 1) {
Q_strncpyz(message, " ate", sizeof(message));
Q_strncpyz(message2, "'s sawed-off 12 gauge", sizeof(message2));
} else {
Q_strncpyz(message, " is full of buckshot from", sizeof(message));
Q_strncpyz(message2, "'s sawed off shotgun", sizeof(message2));
}
break;
case MOD_GRENADE:
Q_strncpyz(message, " ate", sizeof(message));
Q_strncpyz(message2, "'s grenade", sizeof(message2));
break;
case MOD_GRENADE_SPLASH:
Q_strncpyz(message, " was shredded by", sizeof(message));
Q_strncpyz(message2, "'s shrapnel", sizeof(message2));
break;
case MOD_SNIPER:
switch (location) {
case LOC_HDAM:
if (RQ3_isZoomed(target)) {
if (gender == GENDER_NEUTER)
Q_strncpyz(message,
" saw the sniper bullet go through its scope thanks to",
sizeof(message));
else if (gender == GENDER_FEMALE)
Q_strncpyz(message,
" saw the sniper bullet go through her scope thanks to",
sizeof(message));
else
Q_strncpyz(message,
" saw the sniper bullet go through his scope thanks to",
sizeof(message));
} else {
Q_strncpyz(message, " caught a sniper bullet between the eyes from",
sizeof(message));
}
break;
case LOC_CDAM:
Q_strncpyz(message, " was picked off by", sizeof(message));
break;
case LOC_SDAM:
Q_strncpyz(message, " was sniped in the stomach by", sizeof(message));
break;
case LOC_LDAM:
Q_strncpyz(message, " was shot in the legs by", sizeof(message));
break;
default:
Q_strncpyz(message, " was sniped by", sizeof(message));
}
break;
case MOD_AKIMBO:
switch (location) {
case LOC_HDAM:
Q_strncpyz(message, " was trepanned by", sizeof(message));
Q_strncpyz(message2, "'s akimbo Mark 23 pistols", sizeof(message2));
break;
case LOC_CDAM:
Q_strncpyz(message, " was John Woo'd by", sizeof(message));
break;
case LOC_SDAM:
Q_strncpyz(message, " needs some new kidneys thanks to", sizeof(message));
Q_strncpyz(message2, "'s akimbo Mark 23 pistols", sizeof(message2));
break;
case LOC_LDAM:
Q_strncpyz(message, " was shot in the legs by", sizeof(message));
Q_strncpyz(message2, "'s akimbo Mark 23 pistols", sizeof(message2));
break;
default:
Q_strncpyz(message, " was shot by", sizeof(message));
Q_strncpyz(message2, "'s pair of Mark 23 Pistols", sizeof(message2));
}
break;
case MOD_KNIFE:
switch (location) {
case LOC_HDAM:
if (gender == GENDER_NEUTER)
Q_strncpyz(message, " had its throat slit by", sizeof(message));
else if (gender == GENDER_FEMALE)
Q_strncpyz(message, " had her throat slit by", sizeof(message));
else
Q_strncpyz(message, " had his throat slit by", sizeof(message));
break;
case LOC_CDAM:
Q_strncpyz(message, " had open heart surgery, compliments of", sizeof(message));
break;
case LOC_SDAM:
Q_strncpyz(message, " was gutted by", sizeof(message));
break;
case LOC_LDAM:
Q_strncpyz(message, " was stabbed repeatedly in the legs by", sizeof(message));
break;
default:
Q_strncpyz(message, " was slashed apart by", sizeof(message));
Q_strncpyz(message2, "'s Combat Knife", sizeof(message2));
}
break;
case MOD_KNIFE_THROWN:
switch (location) {
case LOC_HDAM:
Q_strncpyz(message, " caught", sizeof(message));
if (gender == GENDER_NEUTER)
Q_strncpyz(message2, "'s flying knife with its forehead", sizeof(message2));
else if (gender == GENDER_FEMALE)
Q_strncpyz(message2, "'s flying knife with her forehead", sizeof(message2));
else
Q_strncpyz(message2, "'s flying knife with his forehead", sizeof(message2));
break;
case LOC_CDAM:
Q_strncpyz(message, "'s ribs don't help against", sizeof(message));
Q_strncpyz(message2, "'s flying knife", sizeof(message2));
break;
case LOC_SDAM:
if (gender == GENDER_NEUTER)
Q_strncpyz(message, " sees the contents of its own stomach thanks to",
sizeof(message));
else if (gender == GENDER_FEMALE)
Q_strncpyz(message, " sees the contents of her own stomach thanks to",
sizeof(message));
else
Q_strncpyz(message, " sees the contents of his own stomach thanks to",
sizeof(message));
Q_strncpyz(message2, "'s flying knife", sizeof(message2));
break;
case LOC_LDAM:
if (gender == GENDER_NEUTER)
Q_strncpyz(message, " had its legs cut off thanks to", sizeof(message));
else if (gender == GENDER_FEMALE)
Q_strncpyz(message, " had her legs cut off thanks to", sizeof(message));
else
Q_strncpyz(message, " had his legs cut off thanks to", sizeof(message));
Q_strncpyz(message2, "'s flying knife", sizeof(message2));
break;
default:
Q_strncpyz(message, " was hit by", sizeof(message));
Q_strncpyz(message2, "'s flying Combat Knife", sizeof(message2));
}
break;
case MOD_KICK:
n = rand() % 3 + 1;
if (n == 1) {
if (gender == GENDER_NEUTER)
Q_strncpyz(message, " got its ass kicked by", sizeof(message));
else if (gender == GENDER_FEMALE)
Q_strncpyz(message, " got her ass kicked by", sizeof(message));
else
Q_strncpyz(message, " got his ass kicked by", sizeof(message));
} else if (n == 2) {
Q_strncpyz(message, " couldn't remove", sizeof(message));
if (gender == GENDER_NEUTER)
Q_strncpyz(message2, "'s boot from its ass", sizeof(message2));
else if (gender == GENDER_FEMALE)
Q_strncpyz(message2, "'s boot from her ass", sizeof(message2));
else
Q_strncpyz(message2, "'s boot from his ass", sizeof(message2));
} else {
if (gender == GENDER_NEUTER)
Q_strncpyz(message, " had a Bruce Lee put on it by", sizeof(message));
else if (gender == GENDER_FEMALE)
Q_strncpyz(message, " had a Bruce Lee put on her by", sizeof(message));
else
Q_strncpyz(message, " had a Bruce Lee put on him by", sizeof(message));
Q_strncpyz(message2, ", with a quickness", sizeof(message2));
}
break;
case MOD_TELEFRAG:
Q_strncpyz(message, " tried to invade", sizeof(message));
Q_strncpyz(message2, "'s personal space", sizeof(message2));
break;
default:
Q_strncpyz(message, " died.", sizeof(message));
break;
// Com_sprintf (message, sizeof(message), "died via unhandled MOD %i. Report this to JBravo", meansOfDeath);
}
Com_sprintf(death_msg, sizeof(death_msg), "%s^7%s %s^7%s\n", target->client->pers.netname, message,
attacker->client->pers.netname, message2);
SendObit(death_msg, target, attacker);
}
}
2001-05-06 20:50:27 +00:00
/*
==================
player_die
==================
*/
void player_die(gentity_t * self, gentity_t * inflictor, gentity_t * attacker, int damage, int meansOfDeath)
{
gentity_t *DMReward;
int anim, contents, killer, i, hurt;
char *killerName, *obit;
2001-11-25 23:04:08 +00:00
hurt = 0;
2001-05-06 20:50:27 +00:00
//Blaze: Stop bleeding when dead
if (self->client) {
//Elder: drop the primed grenade
if (self->client->ps.weapon == WP_GRENADE && self->client->ps.weaponstate == WEAPON_COCKED) {
FireWeapon(self);
}
// Hawkins put spread back and zoom out
//Elder: remove zoom bits
2002-05-12 18:07:08 +00:00
// JBravo: moving this down below the Obit printout
// Cmd_Unzoom(self);
self->client->bleeding = 0;
self->client->bleed_remain = 0;
//Elder: added;
// self->client->ps.stats[STAT_RQ3] &= ~RQ3_BANDAGE_WORK;
self->client->ps.stats[STAT_RQ3] &= ~RQ3_BANDAGE_NEED;
self->client->killStreak = 0;
//Elder: stop reload attempts
self->client->reloadAttempts = 0;
2002-02-22 02:13:13 +00:00
//JBravo: switch off the lasersight
if (self->client->lasersight) {
G_FreeEntity(self->client->lasersight, __LINE__, __FILE__);
2002-02-22 02:13:13 +00:00
self->client->lasersight = NULL;
}
2002-05-31 17:32:11 +00:00
// JBravo: clear the gib flag
self->client->gibbed = qfalse;
}
if (self->client->ps.pm_type == PM_DEAD) {
2001-05-06 20:50:27 +00:00
return;
}
if (level.intermissiontime) {
2001-05-06 20:50:27 +00:00
return;
}
2003-03-09 21:30:39 +00:00
2002-01-11 20:20:58 +00:00
// JBravo: lets not bother with those CTF functions in Teamplay
2002-10-26 22:03:43 +00:00
if (g_gametype.integer == GT_CTF) {
// check for an almost capture
CheckAlmostCapture(self, attacker);
// check for a player that almost brought in cubes
CheckAlmostScored(self, attacker);
2002-01-11 20:20:58 +00:00
}
2001-05-06 20:50:27 +00:00
self->client->ps.pm_type = PM_DEAD;
if (attacker) {
2001-05-06 20:50:27 +00:00
killer = attacker->s.number;
if (attacker->client) {
2001-05-06 20:50:27 +00:00
killerName = attacker->client->pers.netname;
} else {
killerName = "<non-client>";
}
} else {
killer = ENTITYNUM_WORLD;
killerName = "<world>";
}
if (killer < 0 || killer >= MAX_CLIENTS) {
2001-05-06 20:50:27 +00:00
killer = ENTITYNUM_WORLD;
killerName = "<world>";
// Elder: Statistics tracking
if ((g_gametype.integer == GT_TEAMPLAY && level.team_round_going) || g_gametype.integer != GT_TEAMPLAY)
self->client->pers.records[REC_WORLDDEATHS]++;
2001-05-06 20:50:27 +00:00
}
if ( meansOfDeath < 0 || meansOfDeath >= ARRAY_LEN( modNames ) ) {
2001-05-06 20:50:27 +00:00
obit = "<bad obituary>";
} else {
obit = modNames[meansOfDeath];
2001-05-06 20:50:27 +00:00
}
2001-11-25 23:04:08 +00:00
G_LogPrintf("Kill: %i %i %i: %s killed %s by %s\n",
killer, self->s.number, meansOfDeath, killerName, self->client->pers.netname, obit);
2001-05-06 20:50:27 +00:00
// broadcast the death event to everyone
// Elder: use appropriate obit event and update statistics tracking
// JBravo: Im redoing the Obits.
if ((self->client->lasthurt_location & LOCATION_HEAD) == LOCATION_HEAD ||
(self->client->lasthurt_location & LOCATION_FACE) == LOCATION_FACE) {
// head kill
if ((g_gametype.integer == GT_TEAMPLAY && level.team_round_going) || g_gametype.integer != GT_TEAMPLAY) {
self->client->pers.records[REC_HEADDEATHS]++;
if (attacker && attacker->client)
attacker->client->pers.records[REC_HEADKILLS]++;
}
PrintDeathMessage(self, attacker, LOC_HDAM, meansOfDeath);
hurt = LOC_HDAM;
} else if ((self->client->lasthurt_location & LOCATION_CHEST) == LOCATION_CHEST ||
(self->client->lasthurt_location & LOCATION_SHOULDER) == LOCATION_SHOULDER) {
// chest kill
if ((g_gametype.integer == GT_TEAMPLAY && level.team_round_going) || g_gametype.integer != GT_TEAMPLAY) {
self->client->pers.records[REC_CHESTDEATHS]++;
if (attacker && attacker->client)
attacker->client->pers.records[REC_CHESTKILLS]++;
}
PrintDeathMessage(self, attacker, LOC_CDAM, meansOfDeath);
hurt = LOC_CDAM;
} else if ((self->client->lasthurt_location & LOCATION_STOMACH) == LOCATION_STOMACH ||
(self->client->lasthurt_location & LOCATION_GROIN) == LOCATION_GROIN) {
// stomach kill
if ((g_gametype.integer == GT_TEAMPLAY && level.team_round_going) || g_gametype.integer != GT_TEAMPLAY) {
self->client->pers.records[REC_STOMACHDEATHS]++;
if (attacker && attacker->client)
attacker->client->pers.records[REC_STOMACHKILLS]++;
}
PrintDeathMessage(self, attacker, LOC_SDAM, meansOfDeath);
hurt = LOC_SDAM;
} else if ((self->client->lasthurt_location & LOCATION_LEG) == LOCATION_LEG ||
(self->client->lasthurt_location & LOCATION_FOOT) == LOCATION_FOOT) {
// leg kill
if ((g_gametype.integer == GT_TEAMPLAY && level.team_round_going) || g_gametype.integer != GT_TEAMPLAY) {
self->client->pers.records[REC_LEGDEATHS]++;
if (attacker && attacker->client)
attacker->client->pers.records[REC_LEGKILLS]++;
}
PrintDeathMessage(self, attacker, LOC_LDAM, meansOfDeath);
hurt = LOC_LDAM;
} else {
// non-location/world kill
PrintDeathMessage(self, attacker, LOC_NOLOC, meansOfDeath);
hurt = 0;
}
2002-05-12 18:07:08 +00:00
Cmd_Unzoom(self);
// Elder: Statistics tracking
//Blaze: make sure the game is in progress before recording stats
if ((g_gametype.integer == GT_TEAMPLAY && level.team_round_going) || g_gametype.integer != GT_TEAMPLAY) {
switch (meansOfDeath) {
case MOD_KNIFE:
if (attacker && attacker->client)
attacker->client->pers.records[REC_KNIFESLASHKILLS]++;
self->client->pers.records[REC_KNIFESLASHDEATHS]++;
break;
case MOD_KNIFE_THROWN:
if (attacker && attacker->client)
attacker->client->pers.records[REC_KNIFETHROWKILLS]++;
self->client->pers.records[REC_KNIFETHROWDEATHS]++;
break;
case MOD_PISTOL:
if (attacker && attacker->client)
attacker->client->pers.records[REC_MK23KILLS]++;
self->client->pers.records[REC_MK23DEATHS]++;
break;
case MOD_M3:
if (attacker && attacker->client)
attacker->client->pers.records[REC_M3KILLS]++;
self->client->pers.records[REC_M3DEATHS]++;
break;
case MOD_M4:
if (attacker && attacker->client)
attacker->client->pers.records[REC_M4KILLS]++;
self->client->pers.records[REC_M4DEATHS]++;
break;
case MOD_MP5:
if (attacker && attacker->client)
attacker->client->pers.records[REC_MP5KILLS]++;
self->client->pers.records[REC_MP5DEATHS]++;
break;
case MOD_SNIPER:
if (attacker && attacker->client)
attacker->client->pers.records[REC_SSG3000KILLS]++;
self->client->pers.records[REC_SSG3000DEATHS]++;
break;
case MOD_HANDCANNON:
if (attacker && attacker->client)
attacker->client->pers.records[REC_HANDCANNONKILLS]++;
self->client->pers.records[REC_HANDCANNONDEATHS]++;
break;
case MOD_AKIMBO:
if (attacker && attacker->client)
attacker->client->pers.records[REC_AKIMBOKILLS]++;
self->client->pers.records[REC_AKIMBODEATHS]++;
break;
case MOD_GRENADE:
case MOD_GRENADE_SPLASH:
if (attacker && attacker->client)
attacker->client->pers.records[REC_GRENADEKILLS]++;
self->client->pers.records[REC_GRENADEDEATHS]++;
break;
case MOD_KICK:
if (attacker && attacker->client)
attacker->client->pers.records[REC_KICKKILLS]++;
self->client->pers.records[REC_KICKDEATHS]++;
break;
// JBravo: adding a default here to catch potential bugs
default:
break;
}
}
2001-05-06 20:50:27 +00:00
self->enemy = attacker;
if ((g_gametype.integer == GT_TEAMPLAY && level.team_round_going) || g_gametype.integer != GT_TEAMPLAY) {
2002-05-04 16:13:05 +00:00
//Makro - crash bug fix
if ((self->client != NULL) && (attacker->client != NULL)) {
self->client->ps.persistant[PERS_KILLED]++;
//Blaze: Give the attacker 1 kill
attacker->client->pers.records[REC_KILLS]++;
}
}
2001-05-06 20:50:27 +00:00
if (attacker && attacker->client) {
// JBravo: Add multiple last killed system.
AddKilledPlayer(attacker, self);
ResetKills(self);
// JBravo: make it OK to frag teammates after rounds are over.
if (attacker == self) {
if (g_gametype.integer == GT_TEAMPLAY && !level.team_round_going && !self->client->SuicideLikeARealMan) {
} else
AddScore(attacker, self->r.currentOrigin, -1);
} else if (OnSameTeam(self, attacker)) {
2002-06-24 05:51:51 +00:00
if (g_gametype.integer == GT_TEAMPLAY && level.team_round_going) {
AddScore(attacker, self->r.currentOrigin, -1);
//If the kill was a TK, remove 1 from REC_KILLS to negate the one given earlyier
attacker->client->pers.records[REC_KILLS]--;
//Also, increment the TK's record
attacker->client->pers.records[REC_TEAMKILLS]++;
Add_TeamKill(attacker);
trap_SendServerCommand(self - g_entities,
va("rq3_cmd %i %s", TKOK, attacker->client->pers.netname));
2002-10-26 22:03:43 +00:00
} else if (g_gametype.integer == GT_CTF || g_gametype.integer == GT_TEAM) {
2002-06-24 05:51:51 +00:00
AddScore(attacker, self->r.currentOrigin, -1);
attacker->client->pers.records[REC_KILLS]--;
attacker->client->pers.records[REC_TEAMKILLS]++;
Add_TeamKill(attacker);
trap_SendServerCommand(self - g_entities,
2002-08-18 20:26:35 +00:00
va("rq3_cmd %i %s", TKOK, attacker->client->pers.netname));
}
2001-05-06 20:50:27 +00:00
} else {
2001-06-26 00:07:55 +00:00
// Increase number of kills this life for attacker
2002-01-11 20:20:58 +00:00
// JBravo: unless we are in teamplay
if (g_gametype.integer == GT_TEAMPLAY) {
2002-03-17 03:35:29 +00:00
attacker->client->killStreak++;
AddScore(attacker, self->r.currentOrigin, 1);
} else if (g_gametype.integer == GT_CTF || g_gametype.integer == GT_TOURNAMENT) {
2002-06-24 05:51:51 +00:00
attacker->client->killStreak = 0;
AddScore(attacker, self->r.currentOrigin, 1);
} else {
attacker->client->killStreak++;
2002-01-11 20:20:58 +00:00
}
2001-06-26 00:07:55 +00:00
// DM reward scoring, should add an if statement to get around this when
// we add teamplay.
// JBravo: Done ;)
2002-10-26 22:03:43 +00:00
if (g_gametype.integer == GT_FFA || g_gametype.integer == GT_TEAM) {
if (attacker->client->killStreak < 4)
AddScore(attacker, self->r.currentOrigin, 1);
else if (attacker->client->killStreak < 8) {
AddScore(attacker, self->r.currentOrigin, 2);
DMReward = G_TempEntity(self->r.currentOrigin, EV_DMREWARD);
DMReward->s.otherEntityNum2 = killer;
DMReward->s.eventParm = attacker->client->killStreak;
DMReward->r.svFlags = SVF_BROADCAST;
} else if (attacker->client->killStreak < 16) {
AddScore(attacker, self->r.currentOrigin, 4);
DMReward = G_TempEntity(self->r.currentOrigin, EV_DMREWARD);
DMReward->s.otherEntityNum2 = killer;
DMReward->s.eventParm = attacker->client->killStreak;
DMReward->r.svFlags = SVF_BROADCAST;
} else if (attacker->client->killStreak < 32) {
AddScore(attacker, self->r.currentOrigin, 8);
DMReward = G_TempEntity(self->r.currentOrigin, EV_DMREWARD);
DMReward->s.otherEntityNum2 = killer;
DMReward->s.eventParm = attacker->client->killStreak;
DMReward->r.svFlags = SVF_BROADCAST;
} else {
AddScore(attacker, self->r.currentOrigin, 16);
DMReward = G_TempEntity(self->r.currentOrigin, EV_DMREWARD);
DMReward->s.otherEntityNum2 = killer;
DMReward->s.eventParm = attacker->client->killStreak;
DMReward->r.svFlags = SVF_BROADCAST;
}
2001-06-25 23:46:12 +00:00
}
// JBravo: adding the 0wned sound
if (meansOfDeath == MOD_KNIFE) {
2002-09-29 16:06:45 +00:00
trap_SendServerCommand(attacker - g_entities, va("rq3_cmd %i", OWNED));
trap_SendServerCommand(self - g_entities, va("rq3_cmd %i", OWNED));
}
2001-05-06 20:50:27 +00:00
attacker->client->lastKillTime = level.time;
}
} else {
if (g_gametype.integer == GT_TEAMPLAY && !level.team_round_going && !self->client->SuicideLikeARealMan) {
} else
AddScore(self, self->r.currentOrigin, -1);
2001-05-06 20:50:27 +00:00
}
// Add team bonuses
2002-01-11 20:20:58 +00:00
// JBravo: unless we are in teamplay
if (g_gametype.integer != GT_TEAMPLAY) {
Team_FragBonuses(self, inflictor, attacker);
2002-01-11 20:20:58 +00:00
}
2001-05-06 20:50:27 +00:00
// if I committed suicide, the flag does not fall, it returns.
2002-01-11 20:20:58 +00:00
// Unless we are in teamplay
2001-05-06 20:50:27 +00:00
if (meansOfDeath == MOD_SUICIDE) {
// Elder: Statistics tracking
if ((g_gametype.integer == GT_TEAMPLAY && level.team_round_going) || g_gametype.integer != GT_TEAMPLAY) {
self->client->pers.records[REC_SUICIDES]++;
self->client->pers.records[REC_KILLS]--;
}
2002-10-26 22:03:43 +00:00
if (g_gametype.integer == GT_CTF) {
if (self->client->ps.powerups[PW_NEUTRALFLAG]) { // only happens in One Flag CTF
Team_ReturnFlag(TEAM_FREE);
self->client->ps.powerups[PW_NEUTRALFLAG] = 0;
} else if (self->client->ps.powerups[PW_REDFLAG]) { // only happens in standard CTF
Team_ReturnFlag(TEAM_RED);
self->client->ps.powerups[PW_REDFLAG] = 0;
} else if (self->client->ps.powerups[PW_BLUEFLAG]) { // only happens in standard CTF
Team_ReturnFlag(TEAM_BLUE);
self->client->ps.powerups[PW_BLUEFLAG] = 0;
}
2001-05-06 20:50:27 +00:00
}
}
// if client is in a nodrop area, don't drop anything (but return CTF flags!)
contents = trap_PointContents(self->r.currentOrigin, -1);
if (!(contents & CONTENTS_NODROP)) {
TossClientItems(self);
} else {
2002-10-26 22:03:43 +00:00
if (g_gametype.integer == GT_CTF) {
if (self->client->ps.powerups[PW_NEUTRALFLAG]) { // only happens in One Flag CTF
Team_ReturnFlag(TEAM_FREE);
} else if (self->client->ps.powerups[PW_REDFLAG]) { // only happens in standard CTF
Team_ReturnFlag(TEAM_RED);
} else if (self->client->ps.powerups[PW_BLUEFLAG]) { // only happens in standard CTF
Team_ReturnFlag(TEAM_BLUE);
}
} else if ( g_gametype.integer == GT_FFA ) {
int i=0;
for (i=0; i < HI_NUM_HOLDABLE; i++)
{
if ( self->client->ps.stats[STAT_HOLDABLE_ITEM] & (1<< i))
{
RQ3_ResetItem(i);
}
}
2002-01-11 20:20:58 +00:00
}
2001-05-06 20:50:27 +00:00
}
// JBravo: no need for automatic scoreboard on deaths.
if (g_gametype.integer != GT_TEAMPLAY) {
Cmd_Score_f(self); // show scores
}
// send updated scores to any clients that are following this one,
// or they would get stale scoreboards
for (i = 0; i < level.maxclients; i++) {
gclient_t *client;
client = &level.clients[i];
if (client->pers.connected != CON_CONNECTED) {
continue;
}
if (client->sess.sessionTeam != TEAM_SPECTATOR) {
continue;
}
// JBravo: make clients that are following this one stop following.
// JBravo: Moved the code to move followers over to MakeSpectator.
if (g_gametype.integer != GT_TEAMPLAY) {
Cmd_Score_f(g_entities + i);
2001-05-06 20:50:27 +00:00
}
}
self->takedamage = qtrue; // can still be gibbed
self->s.weapon = WP_NONE;
self->s.powerups = 0;
2001-11-25 23:04:08 +00:00
// Elder: HC smoke
if (meansOfDeath == MOD_HANDCANNON && self->client->damage_knockback > RQ3_HANDCANNON_KICK * 4) {
self->client->ps.eFlags |= EF_HANDCANNON_SMOKED;
}
2001-11-25 23:04:08 +00:00
2001-05-06 20:50:27 +00:00
self->r.contents = CONTENTS_CORPSE;
self->s.angles[0] = 0;
self->s.angles[2] = 0;
LookAtKiller(self, inflictor, attacker);
VectorCopy(self->s.angles, self->client->ps.viewangles);
2001-05-06 20:50:27 +00:00
self->s.loopSound = 0;
self->r.maxs[2] = -8;
// don't allow respawn until the death anim is done
// g_forcerespawn may force spawning at some later time
2002-01-11 20:20:58 +00:00
// JBravo: we dont want automatic respawning of players in teamplay
if (g_gametype.integer == GT_TEAMPLAY) {
self->client->respawnTime = level.time + 1000;
} else {
self->client->respawnTime = level.time + 1700;
2002-01-11 20:20:58 +00:00
}
2002-07-24 02:17:38 +00:00
// JBravo: set the time of death for CTB
if (g_gametype.integer == GT_CTF) {
self->client->time_of_death = level.time;
}
2001-05-06 20:50:27 +00:00
// remove powerups
memset(self->client->ps.powerups, 0, sizeof(self->client->ps.powerups));
2001-05-06 20:50:27 +00:00
2002-05-27 06:50:37 +00:00
// JBravo: AQ style Sniper and HC gibbing
2002-05-28 01:17:01 +00:00
if (g_RQ3_gib.integer > 0) {
if (meansOfDeath == MOD_SNIPER && hurt == LOC_HDAM) {
2002-05-28 01:46:58 +00:00
if (g_RQ3_gib.integer < 3) {
2002-05-28 01:17:01 +00:00
// NiceAss: beheading =D
self->client->ps.eFlags |= EF_HEADLESS;
GibEntity_Headshot(self, killer);
2002-05-31 17:32:11 +00:00
} else {
//GibEntity (self, killer);
G_TempEntity(self->r.currentOrigin, EV_GIB_PLAYER);
2002-05-31 17:32:11 +00:00
self->client->gibbed = qtrue;
2003-03-22 20:29:26 +00:00
trap_RQ3UnlinkEntity(self, __LINE__, __FILE__);
2002-05-31 17:32:11 +00:00
}
} else if (meansOfDeath == MOD_HANDCANNON && g_RQ3_gib.integer > 1 && self->health <= -15) {
2002-05-28 01:17:01 +00:00
self->client->noHead = qfalse;
2002-06-05 19:53:10 +00:00
//GibEntity (self, killer);
G_TempEntity(self->r.currentOrigin, EV_GIB_PLAYER);
2002-05-31 17:32:11 +00:00
self->client->gibbed = qtrue;
2003-03-22 20:29:26 +00:00
trap_RQ3UnlinkEntity(self, __LINE__, __FILE__);
2002-05-28 01:17:01 +00:00
}
}
2001-05-06 20:50:27 +00:00
// never gib in a nodrop
2002-06-23 18:29:21 +00:00
if (g_RQ3_gib.integer > 3 && !self->client->gibbed
2002-08-18 20:26:35 +00:00
&& (self->health <= GIB_HEALTH && !(contents & CONTENTS_NODROP) && g_blood.integer)) {
2001-05-06 20:50:27 +00:00
// gib death
GibEntity(self, killer);
2002-06-23 18:29:21 +00:00
} else if (meansOfDeath == MOD_SUICIDE) {
G_AddEvent(self, EV_GIB_PLAYER, killer);
self->takedamage = qfalse;
self->s.eType = ET_INVISIBLE;
self->r.contents = 0;
2002-05-31 17:32:11 +00:00
} else if (self->client->gibbed) {
self->client->gibbed = qtrue; // JBravo: Basicly do nothing
2001-05-06 20:50:27 +00:00
} else {
// normal death
static int i;
switch (i) {
2001-05-06 20:50:27 +00:00
case 0:
anim = BOTH_DEATH1;
break;
case 1:
anim = BOTH_DEATH2;
break;
case 2:
default:
anim = BOTH_DEATH3;
break;
}
// for the no-blood option, we need to prevent the health
// from going to gib level
if (self->health <= GIB_HEALTH) {
self->health = GIB_HEALTH + 1;
2001-05-06 20:50:27 +00:00
}
self->client->ps.legsAnim = ((self->client->ps.legsAnim & ANIM_TOGGLEBIT) ^ ANIM_TOGGLEBIT) | anim;
self->client->ps.torsoAnim = ((self->client->ps.torsoAnim & ANIM_TOGGLEBIT) ^ ANIM_TOGGLEBIT) | anim;
2001-05-06 20:50:27 +00:00
// Elder: only do death sounds if not hit in the head
2002-05-31 17:32:11 +00:00
if ((level.time - self->client->headShotTime > 400) && !self->client->gibbed)
G_AddEvent(self, EV_DEATH1 + i, killer);
2001-05-06 20:50:27 +00:00
// the body can still be gibbed
self->die = body_die;
// globally cycle through the different death animations
i = (i + 1) % 3;
2001-05-06 20:50:27 +00:00
}
self->physicsObject = qfalse;
2002-05-31 17:32:11 +00:00
// JBravo: lets not relink players that have been gibbed here.
if (!self->client->gibbed)
2003-03-22 20:29:26 +00:00
trap_RQ3LinkEntity(self, __LINE__, __FILE__);
2001-05-06 20:50:27 +00:00
}
/*
================
CheckArmor
================
*/
int CheckArmor(gentity_t * ent, int damage, int dflags)
2001-05-06 20:50:27 +00:00
{
gclient_t *client;
int save;
int count;
2001-05-06 20:50:27 +00:00
if (!damage)
return 0;
client = ent->client;
if (!client)
return 0;
if (dflags & DAMAGE_NO_ARMOR)
return 0;
// armor
count = client->ps.stats[STAT_ARMOR];
save = ceil(damage * ARMOR_PROTECTION);
2001-05-06 20:50:27 +00:00
if (save >= count)
save = count;
if (!save)
return 0;
client->ps.stats[STAT_ARMOR] -= save;
return save;
}
/*
================
RaySphereIntersections
================
*/
int RaySphereIntersections(vec3_t origin, float radius, vec3_t point, vec3_t dir, vec3_t intersections[2])
{
2001-05-06 20:50:27 +00:00
float b, c, d, t;
// | origin - (point + t * dir) | = radius
// a = dir[0]^2 + dir[1]^2 + dir[2]^2;
// b = 2 * (dir[0] * (point[0] - origin[0]) + dir[1] * (point[1] - origin[1]) + dir[2] * (point[2] - origin[2]));
// c = (point[0] - origin[0])^2 + (point[1] - origin[1])^2 + (point[2] - origin[2])^2 - radius^2;
2001-05-06 20:50:27 +00:00
// normalize dir so a = 1
VectorNormalize(dir);
b = 2 * (dir[0] * (point[0] - origin[0]) + dir[1] * (point[1] - origin[1]) + dir[2] * (point[2] - origin[2]));
c = (point[0] - origin[0]) * (point[0] - origin[0]) +
(point[1] - origin[1]) * (point[1] - origin[1]) +
(point[2] - origin[2]) * (point[2] - origin[2]) - radius * radius;
2001-05-06 20:50:27 +00:00
d = b * b - 4 * c;
if (d > 0) {
t = (-b + sqrt(d)) / 2;
2001-05-06 20:50:27 +00:00
VectorMA(point, t, dir, intersections[0]);
t = (-b - sqrt(d)) / 2;
2001-05-06 20:50:27 +00:00
VectorMA(point, t, dir, intersections[1]);
return 2;
} else if (d == 0) {
t = (-b) / 2;
2001-05-06 20:50:27 +00:00
VectorMA(point, t, dir, intersections[0]);
return 1;
}
return 0;
}
/*
============
G_Damage
2001-05-06 20:50:27 +00:00
targ entity that is being damaged
inflictor entity that is causing the damage
attacker entity that caused the inflictor to damage targ
example: targ=monster, inflictor=rocket, attacker=player
dir direction of the attack for knockback
point point at which the damage is being inflicted, used for headshots
damage amount of damage being inflicted
knockback force to be applied against targ as a result of the damage
inflictor, attacker, dir, and point can be NULL for environmental effects
dflags these flags are used to control how T_Damage works
DAMAGE_RADIUS damage was indirect (from a nearby explosion)
DAMAGE_NO_ARMOR armor does not protect from this damage
DAMAGE_NO_KNOCKBACK do not affect velocity, just view angles
DAMAGE_NO_PROTECTION kills godmode, armor, everything
============
*/
2002-08-18 20:26:35 +00:00
void VerifyHeadShot(vec3_t point, vec3_t dir, float height, vec3_t newpoint)
{
vec3_t normdir, normdir2;
VectorNormalize2(dir, normdir);
VectorScale(normdir, height, normdir2);
VectorAdd(point, normdir2, newpoint);
}
#define LEG_DAMAGE (height/2.2) - abs(targ->r.mins[2]) - 3 // -1.545455
#define STOMACH_DAMAGE (height/1.8) - abs(targ->r.mins[2]) // 7.111111
#define CHEST_DAMAGE (height/1.4) - abs(targ->r.mins[2]) // 16.000000
#define HEAD_HEIGHT 12.0
void G_Damage(gentity_t * targ, gentity_t * inflictor, gentity_t * attacker,
vec3_t dir, vec3_t point, int damage, int dflags, int mod)
{
gclient_t *client;
gentity_t *tent;
2009-07-06 22:08:53 +00:00
// int take, save, asave, knockback;
int take, save, knockback;
2002-08-18 20:26:35 +00:00
int bleeding = 0, instant_dam = 1, height;
float z_rel, targ_maxs2, from_top;
vec3_t line, new_point;
vec_t dist;
2001-11-25 23:04:08 +00:00
2001-05-06 20:50:27 +00:00
if (!targ->takedamage) {
return;
}
2002-10-26 22:03:43 +00:00
if (g_gametype.integer >= GT_TEAM && level.lights_camera_action) {
2002-01-11 20:20:58 +00:00
return; // JBravo: No dmg during LCA
}
2003-04-07 12:29:33 +00:00
// NiceAss: Fixed pointer bug causing DLLs to crash
// JBravo: FF control
2003-04-07 12:29:33 +00:00
if (attacker && targ && targ->client && attacker->client && targ != attacker) {
if (g_gametype.integer >= GT_TEAM && targ->client->sess.savedTeam == attacker->client->sess.savedTeam) {
if (g_gametype.integer == GT_TEAMPLAY) {
if (level.team_round_going && g_friendlyFire.integer == 0)
return;
} else if (g_gametype.integer >= GT_TEAM) {
if (g_friendlyFire.integer == 0)
return;
}
}
}
2001-05-06 20:50:27 +00:00
// the intermission has allready been qualified for, so don't
// allow any extra scoring
if (level.intermissionQueued) {
2001-05-06 20:50:27 +00:00
return;
}
// Elder: respawn protection -- only for gunfire though!
// No safety from falling!
2001-11-25 23:04:08 +00:00
// NiceAss: Or TELEFAGS!
if (targ->client && inflictor &&
level.time - targ->client->respawnTime < g_RQ3_respawnProtectTime.integer * 1000 && mod != MOD_TELEFRAG)
return;
if (!inflictor) {
2001-05-06 20:50:27 +00:00
inflictor = &g_entities[ENTITYNUM_WORLD];
}
2001-11-25 23:04:08 +00:00
if (!attacker) {
2001-05-06 20:50:27 +00:00
attacker = &g_entities[ENTITYNUM_WORLD];
}
// shootable doors / buttons don't actually have any health
// Makro - they do now !
if (targ->s.eType == ET_MOVER) {
targ->health -= damage;
if (targ->health <= 0) {
if (targ->use
2002-08-18 20:26:35 +00:00
&& (targ->moverState == MOVER_POS1 || targ->moverState == ROTATOR_POS1
|| (targ->spawnflags & 8))) {
targ->use(targ, inflictor, attacker);
}
if (targ->wait < 0) {
targ->takedamage = qfalse;
}
targ->health = targ->health_saved;
}
return;
2001-05-06 20:50:27 +00:00
}
//Elder: from action source
// damage reduction for shotgun and mk23/akimbo
// if far away, reduce it to original action levels
//Note: doesn't handle shots on non-clients (e.g. breakables)
if (targ->client && inflictor->client) {
if (mod == MOD_M3) {
VectorSubtract(targ->client->ps.origin, inflictor->client->ps.origin, line);
dist = VectorLength(line);
if (dist > 450.0) {
2001-11-25 23:04:08 +00:00
damage -= 2;
}
} else if (mod == MOD_PISTOL || mod == MOD_AKIMBO) {
VectorSubtract(targ->client->ps.origin, inflictor->client->ps.origin, line);
dist = VectorLength(line);
if (dist > 600.0 && dist < 1400.0) {
damage = (int) (damage * 2 / 3);
}
//Elder: added >= ... 1400.0 is a magic number for perfect shots if not in :)
else if (dist >= 1400.0) {
damage = (int) (damage * 1 / 2);
}
2001-11-25 23:04:08 +00:00
}
}
2001-05-06 20:50:27 +00:00
//Blaze: If we shot a breakable item subtract the damage from its health and try to break it
if (targ->s.eType == ET_BREAKABLE) {
if (!targ->unbreakable) {
targ->health -= damage;
}
if (targ->exploded == qfalse)
G_BreakGlass(targ, inflictor, attacker, point, mod, damage);
return;
}
2001-05-06 20:50:27 +00:00
client = targ->client;
if (client) {
if (client->noclip) {
2001-05-06 20:50:27 +00:00
return;
}
}
if (!dir) {
2001-05-06 20:50:27 +00:00
dflags |= DAMAGE_NO_KNOCKBACK;
} else {
VectorNormalize(dir);
}
if (targ->flags & FL_NO_KNOCKBACK) {
2001-05-06 20:50:27 +00:00
knockback = 0;
} else if (dflags & DAMAGE_NO_KNOCKBACK) {
2001-05-06 20:50:27 +00:00
knockback = 0;
} else {
//Elder: select knockback
switch (mod) {
case MOD_HANDCANNON:
knockback = RQ3_HANDCANNON_KICK;
break;
case MOD_M3:
knockback = RQ3_M3_KICK;
break;
case MOD_M4:
knockback = RQ3_M4_KICK;
break;
case MOD_MP5:
knockback = RQ3_MP5_KICK;
break;
case MOD_SNIPER:
knockback = RQ3_SNIPER_KICK;
break;
case MOD_PISTOL:
knockback = RQ3_PISTOL_KICK;
break;
case MOD_AKIMBO:
knockback = RQ3_AKIMBO_KICK;
break;
case MOD_GRENADE_SPLASH:
case MOD_GRENADE:
knockback = (int) (0.75 * damage);
break;
case MOD_KNIFE:
knockback = RQ3_KNIFE_KICK;
break;
case MOD_KNIFE_THROWN:
knockback = RQ3_THROW_KICK;
break;
case MOD_KICK:
//Elder: do some calculation here?
knockback = 400;
break;
case MOD_TRIGGER_HURT:
knockback = (int) (0.75 * damage);
break;
default:
//Makro - custom death message implies a trigger_hurt
if (mod >= MOD_CUSTOM && mod - MOD_CUSTOM < level.numCustomDeathMsg)
{
knockback = (int) (0.75 * damage);
} else {
G_Printf("G_Damage: Received unknown MOD - using default knockback\n");
knockback = 50;
}
break;
}
}
2001-05-06 20:50:27 +00:00
2001-12-17 15:08:34 +00:00
// NiceAss: Make sure it hit the player before doing this stuff.
// This was added when the possibility of missing was added from spherical head detection.
// We don't want someone flying back from a sniper to the head when it actually missed!
// Hal: Make sure we have valid pointers before accessing them
2002-08-18 20:26:35 +00:00
if ((dir != NULL) && (point != NULL)) {
2001-12-17 15:08:34 +00:00
// figure momentum add, even if the damage won't be taken
if (knockback && targ->client) {
vec3_t kvel, flydir;
float mass;
2001-12-17 15:08:34 +00:00
2011-03-12 21:58:56 +00:00
// JBravo: flydir was uninitialized in the case of MOD_FALLING. Dont know why it does not like to have flydir set
// but I guess flydir = dir in MOD_FALLING is still better than random stack space has.
VectorCopy(dir, flydir);
/* if (mod != MOD_FALLING) {
2001-12-17 15:08:34 +00:00
VectorCopy(dir, flydir);
2002-06-16 20:09:42 +00:00
// NiceAss: Although AQ2 has this, it was being much more
// severe in RQ3 than AQ2. Removed!
//flydir[2] += 0.4f;
2001-12-17 15:08:34 +00:00
}
2011-03-12 21:58:56 +00:00
*/
2001-12-17 15:08:34 +00:00
mass = 200;
if (targ->client && attacker == targ)
VectorScale(flydir, 1600.0 * (float) knockback / mass, kvel);
2001-12-17 15:08:34 +00:00
else
VectorScale(flydir, 500.0 * (float) knockback / mass, kvel);
VectorAdd(targ->client->ps.velocity, kvel, targ->client->ps.velocity);
2001-12-17 15:08:34 +00:00
// set the timer so that the other client can't cancel
// out the movement immediately
if (!targ->client->ps.pm_time) {
int t;
2001-12-17 15:08:34 +00:00
t = knockback * 2;
if (t < 50) {
2001-12-17 15:08:34 +00:00
t = 50;
}
if (t > 200) {
2001-12-17 15:08:34 +00:00
t = 200;
}
targ->client->ps.pm_time = t;
targ->client->ps.pm_flags |= PMF_TIME_KNOCKBACK;
}
}
// NiceAss: This was moved too
// add to the attacker's hit counter (if the target isn't a general entity like a prox mine)
2002-05-04 16:13:05 +00:00
//Makro - added check; q3 crashed sometimes with .dlls
if ((attacker != NULL) && (client != NULL) && (targ != NULL)) {
2002-05-04 16:13:05 +00:00
if (attacker->client && targ != attacker && targ->health > 0 &&
targ->s.eType != ET_MISSILE && targ->s.eType != ET_GENERAL) {
2002-05-04 16:13:05 +00:00
if (OnSameTeam(targ, attacker)) {
attacker->client->ps.persistant[PERS_HITS]--;
} else {
attacker->client->ps.persistant[PERS_HITS]++;
}
attacker->client->ps.persistant[PERS_ATTACKEE_ARMOR] =
(targ->health << 8) | (client->ps.stats[STAT_ARMOR]);
2001-12-17 15:08:34 +00:00
}
}
}
2001-05-06 20:50:27 +00:00
// check for completely getting out of the damage
if (!(dflags & DAMAGE_NO_PROTECTION)) {
2001-05-06 20:50:27 +00:00
// if TF_NO_FRIENDLY_FIRE is set, don't do damage to the target
// if the attacker was on the same team
if (targ != attacker && OnSameTeam(targ, attacker)) {
// JBravo: more FF tweaks
if (g_gametype.integer == GT_TEAMPLAY) {
if (g_friendlyFire.integer == 2 && level.team_round_going)
return;
2003-04-07 12:29:33 +00:00
if (level.team_round_going)
Add_TeamWound(attacker, targ, mod);
} else if (g_gametype.integer >= GT_TEAM) {
if (g_friendlyFire.integer == 2)
return;
2003-04-07 12:29:33 +00:00
else
Add_TeamWound(attacker, targ, mod);
2001-05-06 20:50:27 +00:00
}
}
// check for godmode
if (targ->flags & FL_GODMODE) {
2001-05-06 20:50:27 +00:00
return;
}
}
2001-06-11 06:12:32 +00:00
//Blaze: Add falling damage for limping
if (mod == MOD_FALLING)
targ->client->ps.stats[STAT_RQ3] |= RQ3_LEGDAMAGE;
2001-11-25 23:04:08 +00:00
if (damage < 1) {
2001-05-06 20:50:27 +00:00
damage = 1;
}
take = damage;
save = 0;
2001-11-25 23:04:08 +00:00
2001-05-06 20:50:27 +00:00
// save some from armor
// JBravo: armor ? dont think so.
// asave = CheckArmor(targ, take, dflags);
// take -= asave;
2001-05-06 20:50:27 +00:00
if (g_debugDamage.integer) {
2009-07-06 22:03:39 +00:00
G_Printf("%i: client:%i health:%i damage:%i\n", level.time, targ->s.number,
targ->health, take);
2001-05-06 20:50:27 +00:00
}
// See if it's the player hurting the emeny flag carrier
if (g_gametype.integer == GT_CTF) {
Team_CheckHurtCarrier(targ, attacker);
2001-05-06 20:50:27 +00:00
}
2002-08-18 20:26:35 +00:00
// aasimon: start calculations for hit location determination
if (targ->client) {
2001-05-06 20:50:27 +00:00
// set the last client who damaged the target
targ->client->lasthurt_client = attacker->s.number;
targ->client->lasthurt_mod = mod;
// Modify the damage for location damage
if (point && targ && targ->health > 0 && attacker && take) {
2001-11-25 23:04:08 +00:00
// First things first. If we're not damaging them, why are we here?
// Elder: removed M3, handcannon, and grenades from location damage code
2001-11-25 23:04:08 +00:00
2002-03-31 03:31:24 +00:00
if (take && (mod == MOD_M3 || mod == MOD_HANDCANNON ||
mod == MOD_GRENADE || mod == MOD_GRENADE_SPLASH || mod == MOD_TRIGGER_HURT ||
//Makro - custom death message implies a trigger_hurt
mod >= MOD_CUSTOM)) {
bleeding = 1;
instant_dam = 0;
2001-11-25 23:04:08 +00:00
//No location damage
targ->client->lasthurt_location = LOCATION_NONE | LOCATION_FRONT;
//Elder: we'll use the shotgun damage report model from AQ2
if (mod == MOD_HANDCANNON || mod == MOD_M3) {
//Elder: do shotgun report like AQ2
int playernum = targ - g_entities;
2001-11-25 23:04:08 +00:00
if (playernum >= 0 && playernum < MAX_CLIENTS)
tookShellHit[playernum] = 1;
} else {
2001-08-18 19:59:25 +00:00
// Grenade stuff - don't print if you hurt yourself
// We could re-use the shotgun report for grenades
if (targ != attacker)
trap_SendServerCommand(attacker - g_entities,
va("print \"You hit %s^7\n\"",
targ->client->pers.netname));
}
2002-03-31 03:31:24 +00:00
} else if (take && (mod == MOD_PISTOL || mod == MOD_M4 ||
mod == MOD_SNIPER || mod == MOD_MP5 || mod == MOD_AKIMBO ||
mod == MOD_KNIFE || mod == MOD_KNIFE_THROWN)) {
2002-08-18 20:26:35 +00:00
bleeding = 1;
instant_dam = 0;
2001-05-06 20:50:27 +00:00
2002-08-18 20:26:35 +00:00
// JBravo: calulate where the bullet hit
targ->client->lasthurt_location = 0;
targ_maxs2 = targ->r.maxs[2];
height = abs(targ->r.mins[2]) + targ_maxs2;
z_rel = point[2] - targ->r.currentOrigin[2];
from_top = targ_maxs2 - z_rel;
//G_Printf("z_rel = %f, height = %d, from_top = %f\n", z_rel, height, from_top);
if (from_top < 2 * HEAD_HEIGHT) {
VerifyHeadShot (point, dir, HEAD_HEIGHT, new_point);
VectorSubtract (new_point, targ->r.currentOrigin, new_point);
if ((targ_maxs2 - new_point[2]) < HEAD_HEIGHT
&& (abs(new_point[1])) < HEAD_HEIGHT*.8
&& (abs(new_point[0])) < HEAD_HEIGHT*.8) {
targ->client->lasthurt_location = LOCATION_HEAD;
}
}
if (z_rel < LEG_DAMAGE) {
targ->client->lasthurt_location = LOCATION_LEG;
} else if (z_rel < STOMACH_DAMAGE) {
targ->client->lasthurt_location = LOCATION_STOMACH;
} else if (targ->client->lasthurt_location == 0){
targ->client->lasthurt_location = LOCATION_CHEST;
2001-11-25 23:04:08 +00:00
}
2002-08-18 20:26:35 +00:00
switch (targ->client->lasthurt_location) {
case LOCATION_HEAD:
if (attacker->client && ((g_gametype.integer == GT_TEAMPLAY && level.team_round_going) || g_gametype.integer != GT_TEAMPLAY))
attacker->client->pers.records[REC_HEADSHOTS]++;
2002-10-30 20:04:34 +00:00
// JBravo: helmet stuff
if ((targ->client->ps.stats[STAT_HOLDABLE_ITEM] & (1 << HI_HELMET)) &&
mod != MOD_SNIPER && mod != MOD_KNIFE && mod != MOD_KNIFE_THROWN) {
trap_SendServerCommand(attacker - g_entities,
2003-04-26 02:03:51 +00:00
va("print \"%s^7 has a Kevlar Helmet - AIM FOR THE BODY!\n\"",
2002-10-30 20:04:34 +00:00
targ->client->pers.netname));
trap_SendServerCommand(targ - g_entities,
2003-04-26 02:03:51 +00:00
va("print \"Kevlar Helmet absorbed a part of %s^7's shot\n\"",
2002-10-30 20:04:34 +00:00
attacker->client->pers.netname));
tent = G_TempEntity(targ->s.pos.trBase, EV_BULLET_HIT_KEVLAR);
tent->s.eventParm = DirToByte(dir);
2002-10-30 20:04:34 +00:00
take = (take / 2);
targ->client->kevlarHit = qtrue;
instant_dam = 1;
bleeding = 0;
2003-04-26 02:03:51 +00:00
break;
2002-10-30 20:04:34 +00:00
} else if ((targ->client->ps.stats[STAT_HOLDABLE_ITEM] & (1 << HI_HELMET)) &&
mod == MOD_SNIPER) {
trap_SendServerCommand(attacker - g_entities,
2003-04-26 02:03:51 +00:00
va("print \"%s^7 has a Kevlar Helmet, too bad you have AP rounds...\n\"",
2002-10-30 20:04:34 +00:00
targ->client->pers.netname));
trap_SendServerCommand(targ - g_entities,
2003-04-26 02:03:51 +00:00
va("print \"Kevlar Helmet absorbed some of %s^7's AP sniper round\n\"",
2002-10-30 20:04:34 +00:00
attacker->client->pers.netname));
take = (take * 0.325);
instant_dam = 1;
bleeding = 1;
2003-04-26 02:03:51 +00:00
break;
2002-10-30 20:04:34 +00:00
} else {
//save headshot time for player_die
targ->client->headShotTime = level.time;
line[0] = line[1] = 0;
line[2] = 20;
trap_SendServerCommand(attacker - g_entities,
va("print \"You hit %s^7 in the head.\n\"",
targ->client->pers.netname));
trap_SendServerCommand(targ - g_entities, va("print \"Head Damage.\n\""));
//Setup headshot spray and sound
//Only do if not knife or SSG -- SSG has its own trail of blood
if (mod != MOD_SNIPER && mod != MOD_KNIFE && mod != MOD_KNIFE_THROWN) {
VectorAdd(targ->s.pos.trBase, line, line);
tent = G_TempEntity(line, EV_HEADSHOT);
tent->s.eventParm = DirToByte(dir);
tent->s.otherEntityNum = targ->s.clientNum;
}
// JBravo: order is important
take = (take * 1.8) + 1;
break;
}
case LOCATION_CHEST:
if (attacker->client && ((g_gametype.integer == GT_TEAMPLAY && level.team_round_going) || g_gametype.integer != GT_TEAMPLAY))
attacker->client->pers.records[REC_CHESTSHOTS]++;
// Vest stuff - is the knife supposed to be affected?
// NiceAss: Added mod != MOD_KNIFE_THROWN so kevlar doesn't help against thrown knives
// JBravo: added mod != MOD_KNIFE so kevlar doesn't help against slashing knives either
// JBravo: the new itemscode.
if ((targ->client->ps.stats[STAT_HOLDABLE_ITEM] & (1 << HI_KEVLAR)) &&
mod != MOD_KNIFE_THROWN && mod != MOD_KNIFE) {
targ->client->kevlarHit = qtrue;
if (attacker->client->ps.weapon == WP_SSG3000) {
trap_SendServerCommand(attacker - g_entities,
va("print \"%s^7 has a Kevlar Vest, too bad you have AP rounds...\n\"",
targ->client->pers.netname));
trap_SendServerCommand(targ - g_entities,
va("print \"Kevlar Vest absorbed some of %s^7's AP sniper round\n\"",
attacker->client->pers.netname));
take = take * 0.325;
} else {
trap_SendServerCommand(attacker - g_entities,
va("print \"%s^7 has a Kevlar Vest - AIM FOR THE HEAD!\n\"",
targ->client->pers.netname));
trap_SendServerCommand(targ - g_entities,
va("print \"Kevlar Vest absorbed most of %s^7's shot\n\"",
attacker->client->pers.netname));
take = take / 10;
instant_dam = 1;
bleeding = 0;
}
//Kevlar sound
tent = G_TempEntity(targ->s.pos.trBase, EV_BULLET_HIT_KEVLAR);
tent->s.eventParm = DirToByte(dir);
} else {
trap_SendServerCommand(attacker - g_entities,
va("print \"You hit %s^7 in the chest.\n\"",
targ->client->pers.netname));
trap_SendServerCommand(targ - g_entities,
va("print \"Chest Damage.\n\""));
take *= 0.65;
}
break;
case LOCATION_STOMACH:
if (attacker->client && ((g_gametype.integer == GT_TEAMPLAY && level.team_round_going) || g_gametype.integer != GT_TEAMPLAY))
attacker->client->pers.records[REC_STOMACHSHOTS]++;
trap_SendServerCommand(attacker - g_entities,
va("print \"You hit %s^7 in the stomach.\n\"",
targ->client->pers.netname));
trap_SendServerCommand(targ - g_entities, va("print \"Stomach Damage.\n\""));
take *= 0.4;
if (attacker->client && attacker->client->ps.weapon == WP_SSG3000
&& g_RQ3_gib.integer >= 1) {
G_TempEntity(targ->r.currentOrigin, EV_GIB_PLAYER_STOMACH);
}
break;
case LOCATION_LEG:
if (attacker->client && ((g_gametype.integer == GT_TEAMPLAY && level.team_round_going) || g_gametype.integer != GT_TEAMPLAY))
attacker->client->pers.records[REC_LEGSHOTS]++;
trap_SendServerCommand(attacker - g_entities,
va("print \"You hit %s^7 in the leg.\n\"",
targ->client->pers.netname));
trap_SendServerCommand(targ - g_entities, va("print \"Leg Damage.\n\""));
targ->client->ps.stats[STAT_RQ3] |= RQ3_LEGDAMAGE;
take *= 0.25;
break;
2001-05-06 20:50:27 +00:00
}
}
} else
targ->client->lasthurt_location = LOCATION_NONE;
2001-05-06 20:50:27 +00:00
}
// add to the damage inflicted on a player this frame
// the total will be turned into screen blends and view angle kicks
// at the end of the frame
if (client) {
if (attacker) {
client->ps.persistant[PERS_ATTACKER] = attacker->s.number;
} else {
client->ps.persistant[PERS_ATTACKER] = ENTITYNUM_WORLD;
}
2009-07-06 22:08:53 +00:00
//JBravo: no armour
// client->damage_armor += asave;
client->damage_blood += take;
client->damage_knockback += knockback;
if (dir) {
VectorCopy(dir, client->damage_from);
client->damage_fromWorld = qfalse;
} else {
VectorCopy(targ->r.currentOrigin, client->damage_from);
client->damage_fromWorld = qtrue;
}
}
2001-05-06 20:50:27 +00:00
// do the damage
if (take) {
2002-04-06 20:47:24 +00:00
// JBravo: for Damage delt tracking
if (attacker && attacker->client && targ->health > 0 && targ->client) {
if (mod == MOD_TELEFRAG) {
2002-05-21 17:55:26 +00:00
attacker->client->ps.persistant[PERS_DAMAGE_DELT] += 100;
} else {
if (g_gametype.integer >= GT_TEAM) {
if (attacker->client->sess.sessionTeam != targ->client->sess.sessionTeam)
attacker->client->ps.persistant[PERS_DAMAGE_DELT] += take;
} else {
attacker->client->ps.persistant[PERS_DAMAGE_DELT] += take;
}
}
2002-06-21 16:54:15 +00:00
//Makro - crash bug fix
if (targ && targ->client) {
2002-08-18 20:26:35 +00:00
Com_sprintf(attacker->client->last_damaged_players,
sizeof(attacker->client->last_damaged_players), "%s^7",
targ->client->pers.netname);
2002-06-21 16:54:15 +00:00
}
2002-05-21 17:55:26 +00:00
}
if (instant_dam) {
2001-12-17 15:08:34 +00:00
// G_Printf("(%d) instant damage\n",take);
2001-05-06 20:50:27 +00:00
targ->health = targ->health - take;
}
if (targ->client) {
2001-05-06 20:50:27 +00:00
targ->client->ps.stats[STAT_HEALTH] = targ->health;
}
2001-11-25 23:04:08 +00:00
if (targ->health <= 0) {
if (targ->health < -999) {
2001-05-06 20:50:27 +00:00
targ->health = -999;
}
2001-05-06 20:50:27 +00:00
targ->enemy = attacker;
2002-05-04 16:13:05 +00:00
//Makro - crash bug fix
if (targ->die)
targ->die(targ, inflictor, attacker, take, mod);
2001-05-06 20:50:27 +00:00
return;
} else if (targ->pain) {
targ->pain(targ, attacker, take);
}
2001-05-06 20:50:27 +00:00
}
2001-11-25 23:04:08 +00:00
if (client) {
if (client->lasthurt_location && bleeding) {
// Elder: use the server FPS
int realBleedTime;
2001-11-25 23:04:08 +00:00
realBleedTime = trap_Cvar_VariableIntegerValue("sv_fps");
if (realBleedTime <= 0)
realBleedTime = BLEED_TIME;
client->bleeding += take * realBleedTime;
// Elder: Splash damage bleeding happens from the origin
if (dflags == DAMAGE_RADIUS)
VectorClear(targ->client->bleedloc_offset);
else
VectorSubtract(point, targ->r.currentOrigin, targ->client->bleedloc_offset);
2001-05-06 20:50:27 +00:00
}
}
2001-11-25 23:04:08 +00:00
}
2001-05-06 20:50:27 +00:00
/*
============
CanDamage
Returns qtrue if the inflictor can directly damage the target. Used for
explosions and melee attacks.
============
*/
qboolean CanDamage(gentity_t * targ, vec3_t origin)
{
vec3_t dest;
trace_t tr;
vec3_t midpoint;
2001-05-06 20:50:27 +00:00
// use the midpoint of the bounds instead of the origin, because
// bmodels may have their origin is 0,0,0
VectorAdd(targ->r.absmin, targ->r.absmax, midpoint);
VectorScale(midpoint, 0.5, midpoint);
2001-05-06 20:50:27 +00:00
VectorCopy(midpoint, dest);
trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
2001-12-17 15:08:34 +00:00
2001-05-06 20:50:27 +00:00
if (tr.fraction == 1.0 || tr.entityNum == targ->s.number)
return qtrue;
2001-11-25 23:04:08 +00:00
// this should probably check in the plane of projection,
2001-05-06 20:50:27 +00:00
// rather than in world coordinate, and also include Z
VectorCopy(midpoint, dest);
2001-05-06 20:50:27 +00:00
dest[0] += 15.0;
dest[1] += 15.0;
trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
2001-05-06 20:50:27 +00:00
if (tr.fraction == 1.0)
return qtrue;
VectorCopy(midpoint, dest);
2001-05-06 20:50:27 +00:00
dest[0] += 15.0;
dest[1] -= 15.0;
trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
2001-05-06 20:50:27 +00:00
if (tr.fraction == 1.0)
return qtrue;
VectorCopy(midpoint, dest);
2001-05-06 20:50:27 +00:00
dest[0] -= 15.0;
dest[1] += 15.0;
trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
2001-05-06 20:50:27 +00:00
if (tr.fraction == 1.0)
return qtrue;
VectorCopy(midpoint, dest);
2001-05-06 20:50:27 +00:00
dest[0] -= 15.0;
dest[1] -= 15.0;
trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
2001-05-06 20:50:27 +00:00
if (tr.fraction == 1.0)
return qtrue;
return qfalse;
}
/*
============
G_RadiusDamage
Elder: this sucker needed a lot of minor tweaks to behave like AQ2
2001-05-06 20:50:27 +00:00
============
*/
qboolean G_RadiusDamage(vec3_t origin, gentity_t * attacker, float damage, float radius, gentity_t * ignore, int mod)
{
float points, dist;
gentity_t *ent;
int entityList[MAX_GENTITIES];
2002-09-29 16:06:45 +00:00
int numListedEntities, i, e;
vec3_t mins, maxs, v, dir;
qboolean hitClient = qfalse;
if (radius < 1) {
2001-05-06 20:50:27 +00:00
radius = 1;
}
for (i = 0; i < 3; i++) {
2001-05-06 20:50:27 +00:00
mins[i] = origin[i] - radius;
maxs[i] = origin[i] + radius;
}
numListedEntities = trap_EntitiesInBox(mins, maxs, entityList, MAX_GENTITIES);
2001-05-06 20:50:27 +00:00
for (e = 0; e < numListedEntities; e++) {
//Blaze: Prit out some Debug info
if (&g_entities[entityList[e]] == NULL) G_Printf("Ln 2499\n");
ent = &g_entities[entityList[e]];
2001-05-06 20:50:27 +00:00
if (ent == ignore)
continue;
if (!ent->takedamage)
continue;
// find the distance from the edge of the bounding box
for (i = 0; i < 3; i++) {
if (origin[i] < ent->r.absmin[i]) {
2001-05-06 20:50:27 +00:00
v[i] = ent->r.absmin[i] - origin[i];
} else if (origin[i] > ent->r.absmax[i]) {
2001-05-06 20:50:27 +00:00
v[i] = origin[i] - ent->r.absmax[i];
} else {
v[i] = 0;
}
}
dist = VectorLength(v);
if (dist > radius) {
2001-05-06 20:50:27 +00:00
continue;
}
//Blaze: lets use the q3 damage because it works the same for grenades, but lets breakables work better.
// Q2 radius damage
//points = damage - 0.5f * dist;
// Q3 radius damage
points = damage * (1.0 - dist / radius);
2001-05-06 20:50:27 +00:00
//Elder: reduce grenade damage if crouching
if (ent->r.maxs[2] < 20) {
points = points * 0.5f; // hefty reduction in damage
}
if (CanDamage(ent, origin)) {
if (LogAccuracyHit(ent, attacker)) {
2001-05-06 20:50:27 +00:00
hitClient = qtrue;
}
VectorSubtract(ent->r.currentOrigin, origin, dir);
2001-05-06 20:50:27 +00:00
// push the center of mass higher than the origin so players
// get knocked into the air more
// dir[2] += 24;
2001-11-25 23:04:08 +00:00
G_Damage(ent, NULL, attacker, dir, origin, (int) (points * 0.75f), DAMAGE_RADIUS, mod);
2001-05-06 20:50:27 +00:00
}
}
return hitClient;
}