2 void Obituary (entity attacker, entity targ, float deathtype)
5 if (targ.classname == "player" || targ.classname == "corpse")
8 if (targ.classname == "corpse")
12 if (deathtype == IT_LASER) {bprint(s);bprint(" was unable to resist the urge to self-immolate\n");}
13 else if (deathtype == IT_GRENADE_LAUNCHER) {bprint(s);bprint(" detonated\n");}
14 else if (deathtype == IT_ELECTRO) {bprint(s);bprint(" played with plasma\n");}
15 else if (deathtype == IT_HAGAR) {bprint(s);bprint(" should have used a different weapon\n");}
16 else if (deathtype == IT_ROCKET_LAUNCHER) {bprint(s);bprint(" exploded\n");}
17 else {bprint(s);bprint(" competes for the darwin awards\n");}
19 else if (attacker.classname == "player")
21 if (deathtype == IT_LASER) {bprint(s);bprint(" was a victim of laser surgeon ");bprint(attacker.netname);bprint("\n");}
22 else if (deathtype == IT_UZI) {bprint(s);bprint(" was gunned down by ");bprint(attacker.netname);bprint("\n");}
23 else if (deathtype == IT_SHOTGUN) {bprint(s);bprint(" was gunned down by ");bprint(attacker.netname);bprint("\n");}
24 else if (deathtype == IT_GRENADE_LAUNCHER) {bprint(s);bprint(" was blasted by ");bprint(attacker.netname);bprint("\n");}
25 else if (deathtype == IT_ELECTRO) {bprint(s);bprint(" bathed in plasma from ");bprint(attacker.netname);bprint("\n");}
26 else if (deathtype == IT_CRYLINK) {bprint(s);bprint(" was zapped by ");bprint(attacker.netname);bprint("\n");}
27 else if (deathtype == IT_NEX) {bprint(s);bprint(" sports a new hole from ");bprint(attacker.netname);bprint("\n");}
28 else if (deathtype == IT_HAGAR) {bprint(s);bprint(" was pummeled by ");bprint(attacker.netname);bprint("\n");}
29 else if (deathtype == IT_ROCKET_LAUNCHER) {bprint(s);bprint(" was given a lesson in rocketry by ");bprint(attacker.netname);bprint("\n");}
30 else {bprint(s);bprint(" was killed by ");bprint(attacker.netname);bprint("\n");}
34 {bprint(s);bprint(" died\n");}
39 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
45 if (self.damageforcescale)
47 self.velocity = self.velocity + self.damageforcescale * force;
48 self.flags = self.flags - (self.flags & FL_ONGROUND);
51 if (self.event_damage)
52 self.event_damage (hitloc, damage, inflictor, attacker, deathtype);
56 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float radius, entity ignore, float forceintensity, float deathtype)
68 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
70 targ = findradius (blastorigin, radius);
73 if (targ != inflictor)
76 // LordHavoc: measure distance to nearest point on target (not origin)
77 // (this guarentees 100% damage on a touch impact)
78 nearest = blastorigin;
79 m1 = targ.origin + targ.mins;
80 m2 = targ.origin + targ.maxs;
81 if (nearest_x < m1_x) nearest_x = m1_x;
82 if (nearest_y < m1_y) nearest_y = m1_y;
83 if (nearest_z < m1_z) nearest_z = m1_z;
84 if (nearest_x > m2_x) nearest_x = m2_x;
85 if (nearest_y > m2_y) nearest_y = m2_y;
86 if (nearest_z > m2_z) nearest_z = m2_z;
87 diff = nearest - blastorigin;
88 // round up a little on the damage to ensure full damage on impacts
89 // and turn the distance into a fraction of the radius
90 power = 1 - ((vlen (diff) - 2) / radius);
92 //bprint(ftos(power));
97 finaldmg = coredamage * power + edgedamage * (1 - power);
98 force = normalize(diff) * (finaldmg / coredamage) * forceintensity;
100 finaldmg = finaldmg * 0.6; // Partial damage if the attacker hits himself
102 Damage (targ, inflictor, attacker, finaldmg, deathtype, inflictor.origin, force);
114 void ClearMultiDamage (void)
118 multi_force = '0 0 0';
121 void ApplyMultiDamage (void)
126 Damage (self, multi_ent.origin, multi_ent, 0, multi_damage, multi_force);
129 void AddMultiDamage (entity hit, float damage, vector force)
134 if (hit != multi_ent)
140 multi_damage = multi_damage + damage;
141 multi_force = multi_force + force;
144 void FireBullets (float shotcount, vector dir, vector spread, float deathtype)
151 makevectors (self.v_angle);
153 source = self.origin + v_forward * 10; // FIXME
154 source_x = self.absmin_z + self.size_z * 0.7; // ??? whaddabout view_ofs
156 // LordHavoc: better to use normal damage
157 //ClearMultiDamage ();
158 while (shotcount > 0)
160 direction = dir + crandom () * spread_x * v_right + crandom () * spread_y * v_up;
162 traceline (source, source + direction * 2048, FALSE, self);
163 if (trace_fraction != 1.0)
165 vel = normalize (direction + v_up * crandom () + v_right * crandom ());
166 vel = vel + 2 * trace_plane_normal;
169 org = trace_endpos - direction * 4;
171 if (!trace_ent.takedamage)
173 // LordHavoc: better to use normal damage
174 //AddMultiDamage (trace_ent, 4, direction * 4);
175 Damage (trace_ent, self, self, 4, deathtype, trace_endpos, direction * 4);
178 shotcount = shotcount + 1;
181 // LordHavoc: better to use normal damage
182 //ApplyMultiDamage ();