2 void Obituary (entity attacker, entity targ, float deathtype)
6 if (targ.classname == "player" || targ.classname == "corpse")
8 if (targ.classname == "corpse")
16 if (deathtype == IT_LASER)
17 bprint (s, " was unable to resist the urge to self-immolate\n");
18 else if (deathtype == IT_GRENADE_LAUNCHER)
19 bprint (s, " detonated\n");
20 else if (deathtype == IT_ELECTRO)
21 bprint (s, " played with plasma\n");
22 else if (deathtype == IT_HAGAR)
23 bprint (s, " should have used a different weapon\n");
24 else if (deathtype == IT_ROCKET_LAUNCHER)
25 bprint (s, " exploded\n");
26 else if (deathtype == DEATH_KILL)
27 bprint (s, " couldn't take it anymore\n");
29 bprint (s, " competes for the Darwin awards\n");
31 self.frags = self.frags - 1;
34 else if (attacker.classname == "player")
36 if (deathtype == IT_LASER)
37 bprint (s, " was a victim of laser surgeon ", attacker.netname, "\n");
38 else if (deathtype == IT_UZI)
39 bprint (s, " was riddled full of holes by ", attacker.netname, "\n");
40 else if (deathtype == IT_SHOTGUN)
41 bprint (s, " was gunned by ", attacker.netname, "\n");
42 else if (deathtype == IT_GRENADE_LAUNCHER)
43 bprint (s, " was blasted by ", attacker.netname, "\n");
44 else if (deathtype == IT_ELECTRO)
45 bprint (s, " bathed in ", attacker.netname, "'s plasma\n");
46 else if (deathtype == IT_CRYLINK)
47 bprint (s, " was zapped by ", attacker.netname, "\n");
48 else if (deathtype == IT_NEX)
49 bprint (s, " has been vaporized by ", attacker.netname, "\n");
50 else if (deathtype == IT_HAGAR)
51 bprint (s, " was pummeled by ", attacker.netname, "\n");
52 else if (deathtype == IT_ROCKET_LAUNCHER)
53 bprint (s, " was given a lesson in rocketry by ", attacker.netname, "\n");
55 bprint (s, " was killed by ", attacker.netname, "\n");
57 attacker.frags = attacker.frags + 1;
59 else if (deathtype == DEATH_HURTTRIGGER)
60 bprint (s, " ", attacker.message, "\n");
61 else if (deathtype == DEATH_FALL)
62 bprint (s, " hit the ground with a crunch\n");
63 else if (deathtype == DEATH_BIGFALL)
64 bprint (s, " fell into oblivion\n");
65 else if (deathtype == DEATH_DROWN)
66 bprint (s, " wished he had gills\n");
68 bprint (s, " died\n");
72 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
77 if (attacker.items & IT_STRENGTH)
79 damage = damage * POWERUP_STRENGTH_DAMAGE;
80 force = force * POWERUP_STRENGTH_FORCE;
82 if (targ.items & IT_INVINCIBLE)
83 damage = damage * POWERUP_INVINCIBLE_TAKEDAMAGE;
85 if (self.damageforcescale)
87 self.velocity = self.velocity + self.damageforcescale * force;
88 self.flags = self.flags - (self.flags & FL_ONGROUND);
91 if (self.event_damage)
92 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
96 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)
108 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
110 targ = findradius (blastorigin, rad);
113 if (targ != inflictor)
116 // LordHavoc: measure distance to nearest point on target (not origin)
117 // (this guarentees 100% damage on a touch impact)
118 nearest = blastorigin;
119 m1 = targ.origin + targ.mins;
120 m2 = targ.origin + targ.maxs;
121 if (nearest_x < m1_x) nearest_x = m1_x;
122 if (nearest_y < m1_y) nearest_y = m1_y;
123 if (nearest_z < m1_z) nearest_z = m1_z;
124 if (nearest_x > m2_x) nearest_x = m2_x;
125 if (nearest_y > m2_y) nearest_y = m2_y;
126 if (nearest_z > m2_z) nearest_z = m2_z;
127 diff = nearest - blastorigin;
128 // round up a little on the damage to ensure full damage on impacts
129 // and turn the distance into a fraction of the radius
130 power = 1 - ((vlen (diff) - 2) / rad);
132 //bprint(ftos(power));
137 finaldmg = coredamage * power + edgedamage * (1 - power);
138 force = normalize((m1 + m2) * 0.5 - blastorigin) * (finaldmg / coredamage) * forceintensity;
139 if (targ == attacker)
140 finaldmg = finaldmg * 0.6; // Partial damage if the attacker hits himself
142 Damage (targ, inflictor, attacker, finaldmg, deathtype, inflictor.origin, force);
154 void ClearMultiDamage (void)
158 multi_force = '0 0 0';
161 void ApplyMultiDamage (void)
166 Damage (self, multi_ent.origin, multi_ent, 0, multi_damage, multi_force);
169 void AddMultiDamage (entity hit, float damage, vector force)
174 if (hit != multi_ent)
180 multi_damage = multi_damage + damage;
181 multi_force = multi_force + force;
184 void FireBullets (float shotcount, vector dir, vector spread, float deathtype)
191 makevectors (self.v_angle);
193 source = self.origin + v_forward * 10; // FIXME
194 source_x = self.absmin_z + self.size_z * 0.7; // ??? whaddabout view_ofs
196 // LordHavoc: better to use normal damage
197 //ClearMultiDamage ();
198 while (shotcount > 0)
200 direction = dir + crandom () * spread_x * v_right + crandom () * spread_y * v_up;
202 traceline (source, source + direction * 2048, FALSE, self);
203 if (trace_fraction != 1.0)
205 vel = normalize (direction + v_up * crandom () + v_right * crandom ());
206 vel = vel + 2 * trace_plane_normal;
209 org = trace_endpos - direction * 4;
211 if (!trace_ent.takedamage)
213 // LordHavoc: better to use normal damage
214 //AddMultiDamage (trace_ent, 4, direction * 4);
215 Damage (trace_ent, self, self, 4, deathtype, trace_endpos, direction * 4);
218 shotcount = shotcount + 1;
221 // LordHavoc: better to use normal damage
222 //ApplyMultiDamage ();