2 float checkrules_firstblood;
3 void Obituary (entity attacker, entity targ, float deathtype)
7 if (targ.classname == "player" || targ.classname == "corpse")
9 if (targ.classname == "corpse")
16 if (deathtype == IT_GRENADE_LAUNCHER)
17 bprint ("^1",s, " detonated\n");
18 else if (deathtype == IT_ELECTRO)
19 bprint ("^1",s, " played with plasma\n");
20 else if (deathtype == IT_ROCKET_LAUNCHER)
21 bprint ("^1",s, " exploded\n");
22 else if (deathtype == DEATH_KILL)
23 bprint ("^1",s, " couldn't take it anymore\n");
25 bprint ("^1",s, " couldn't resist the urge to self immolate\n");
26 targ.frags = targ.frags - 1;
27 if (targ.killcount > 2)
28 bprint ("^1",s," ended it all with a ",ftos(targ.killcount)," kill spree\n");
30 else if (teamplay && attacker.team == targ.team)
32 bprint ("^1", attacker.netname, " mows down a teammate\n");
33 attacker.frags = attacker.frags - 1;
34 if (targ.killcount > 2)
35 bprint ("^1",s,"'s ",ftos(targ.killcount)," kill spree was endeded by a teammate!\n");
36 if (attacker.killcount > 2)
37 bprint ("^1",attacker.netname," ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
38 attacker.killcount = 0;
40 else if (attacker.classname == "player")
42 if (!checkrules_firstblood)
44 checkrules_firstblood = TRUE;
45 //sound(world, CHAN_AUTO, "announcer/firstblood.wav", 1, ATTN_NONE);
46 bprint("^1",attacker.netname, " drew first blood", "\n");
49 if (deathtype == IT_LASER)
50 bprint ("^1",s, " was blasted by ", attacker.netname, "\n");
51 else if (deathtype == IT_UZI)
52 bprint ("^1",s, " was riddled full of holes by ", attacker.netname, "\n");
53 else if (deathtype == IT_SHOTGUN)
54 bprint ("^1",s, " was gunned by ", attacker.netname, "\n");
55 else if (deathtype == IT_GRENADE_LAUNCHER)
56 bprint ("^1", s, " was blasted by ", attacker.netname, "\n");
57 else if (deathtype == IT_ELECTRO)
58 bprint ("^1",s, " was blasted by ", attacker.netname, "\n");
59 else if (deathtype == IT_CRYLINK)
60 bprint ("^1",s, " was blasted by ", attacker.netname, "\n");
61 else if (deathtype == IT_NEX)
62 bprint ("^1",s, " has been vaporized by ", attacker.netname, "\n");
63 else if (deathtype == IT_HAGAR)
64 bprint ("^1",s, " was pummeled by ", attacker.netname, "\n");
65 else if (deathtype == IT_ROCKET_LAUNCHER)
66 bprint ("^1",s, " was blasted by ", attacker.netname, "\n");
67 else if (deathtype == DEATH_TELEFRAG)
68 bprint ("^1",s, " was telefragged by ", attacker.netname, "\n");
70 bprint ("^1",s, " was killed by ", attacker.netname, "\n");
72 attacker.frags = attacker.frags + 1;
73 if (targ.killcount > 2)
74 bprint ("^1",s,"'s ", ftos(targ.killcount), " kill spree was ended by ", attacker.netname, "\n");
75 attacker.killcount = attacker.killcount + 1;
76 if (attacker.killcount > 2)
77 bprint ("^1",attacker.netname," has ",ftos(attacker.killcount)," kills in a row\n");
81 if (deathtype == DEATH_HURTTRIGGER)
82 bprint ("^1",s, " ", attacker.message, "\n");
83 else if (deathtype == DEATH_DROWN)
84 bprint ("^1",s, " drowned\n");
85 else if (deathtype == DEATH_SLIME)
86 bprint ("^1",s, " was slimed\n");
87 else if (deathtype == DEATH_LAVA)
88 bprint ("^1",s, " turned into hot slag\n");
89 else if (deathtype == DEATH_FALL)
90 bprint ("^1",s, " hit the ground with a crunch\n");
91 targ.frags = targ.frags - 1;
92 if (targ.killcount > 2)
93 bprint ("^1",s," died with a ",ftos(targ.killcount)," kill spree\n");
95 // FIXME: this should go in PutClientInServer
101 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
103 local entity oldself;
106 // nullify damage if teamplay is on
109 if (attacker.team == targ.team)
110 if (teamplay == 1 || (teamplay == 3 && attacker != targ))
112 // apply strength multiplier
113 if (attacker.items & IT_STRENGTH)
115 damage = damage * cvar("g_balance_powerup_strength_damage");
116 force = force * cvar("g_balance_powerup_strength_force");
118 // apply invincibility multiplier
119 if (targ.items & IT_INVINCIBLE)
120 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
122 if (self.damageforcescale)
124 self.velocity = self.velocity + self.damageforcescale * force;
125 self.flags = self.flags - (self.flags & FL_ONGROUND);
128 if (self.event_damage)
129 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
132 // Savage: vampire mode
133 if(cvar("g_vampire") && targ.classname == "player" && attacker.classname == "player" && attacker != targ) {
134 attacker.health += damage;
138 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)
150 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
152 targ = findradius (blastorigin, rad);
155 if (targ != inflictor)
158 // LordHavoc: measure distance to nearest point on target (not origin)
159 // (this guarentees 100% damage on a touch impact)
160 nearest = blastorigin;
161 m1 = targ.origin + targ.mins;
162 m2 = targ.origin + targ.maxs;
163 if (nearest_x < m1_x) nearest_x = m1_x;
164 if (nearest_y < m1_y) nearest_y = m1_y;
165 if (nearest_z < m1_z) nearest_z = m1_z;
166 if (nearest_x > m2_x) nearest_x = m2_x;
167 if (nearest_y > m2_y) nearest_y = m2_y;
168 if (nearest_z > m2_z) nearest_z = m2_z;
169 diff = nearest - blastorigin;
170 // round up a little on the damage to ensure full damage on impacts
171 // and turn the distance into a fraction of the radius
172 power = 1 - ((vlen (diff) - 2) / rad);
174 //bprint(ftos(power));
179 finaldmg = coredamage * power + edgedamage * (1 - power);
182 force = normalize((m1 + m2) * 0.5 - blastorigin) * (finaldmg / coredamage) * forceintensity;
183 if (targ == attacker)
184 finaldmg = finaldmg * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
185 Damage (targ, inflictor, attacker, finaldmg, deathtype, inflictor.origin, force);
198 void ClearMultiDamage (void)
202 multi_force = '0 0 0';
205 void ApplyMultiDamage (void)
210 Damage (self, multi_ent.origin, multi_ent, 0, multi_damage, multi_force);
213 void AddMultiDamage (entity hit, float damage, vector force)
218 if (hit != multi_ent)
224 multi_damage = multi_damage + damage;
225 multi_force = multi_force + force;
228 void FireBullets (float shotcount, vector dir, vector spread, float deathtype)
235 makevectors (self.v_angle);
237 source = self.origin + v_forward * 10; // FIXME
238 source_x = self.absmin_z + self.size_z * 0.7; // ??? whaddabout view_ofs
240 // LordHavoc: better to use normal damage
241 //ClearMultiDamage ();
242 while (shotcount > 0)
244 direction = dir + crandom () * spread_x * v_right + crandom () * spread_y * v_up;
246 traceline (source, source + direction * 2048, FALSE, self);
247 if (trace_fraction != 1.0)
249 vel = normalize (direction + v_up * crandom () + v_right * crandom ());
250 vel = vel + 2 * trace_plane_normal;
253 org = trace_endpos - direction * 4;
255 if (!trace_ent.takedamage)
257 // LordHavoc: better to use normal damage
258 //AddMultiDamage (trace_ent, 4, direction * 4);
259 Damage (trace_ent, self, self, 4, deathtype, trace_endpos, direction * 4);
262 shotcount = shotcount + 1;
265 // LordHavoc: better to use normal damage
266 //ApplyMultiDamage ();