5 Returns a point at least 12 units away from walls
6 (useful for explosion animations, although the blast is performed where it really happened)
10 vector findbetterlocation (vector org, float mindist)
12 vector loc, norm, norm2;
19 vec = mindist * '1 0 0';
23 traceline (org, org + vec, MOVE_WORLDONLY, world);
25 if (trace_fraction < 1)
28 norm2 = trace_plane_normal;
29 traceline (loc, loc + vec, MOVE_WORLDONLY, world);
30 if (trace_fraction >= 1)
46 trace_plane_normal = norm;
53 float hittype, dmg, rad, edge, thisdmg;
54 vector force, org, thisforce;
59 hittype = ReadShort();
67 force = decompressShortVector(ReadShort());
69 for(self = findradius(org, rad); self; self = self.chain)
73 thisdmg = vlen(self.origin - org) / rad;
76 thisdmg = dmg + (edge - dmg) * thisdmg;
77 thisforce = vlen(force) * normalize(self.origin - org);
85 if(self.damageforcescale)
88 self.move_velocity = self.move_velocity + self.damageforcescale * thisforce;
89 self.move_flags &~= FL_ONGROUND;
93 self.event_damage(thisdmg, hittype, org, thisforce);
98 setorigin(self, org); // for sound() calls
100 // TODO spawn particle effects and sounds based on hittype
102 if(!DEATH_ISSPECIAL(hittype))
104 float hitwep, secondary, bounce, headshot;
108 hitwep = DEATH_WEAPONOFWEAPONDEATH(hittype);
109 secondary = hittype & HITTYPE_SECONDARY;
110 bounce = hittype & HITTYPE_BOUNCE;
111 headshot = hittype & HITTYPE_HEADSHOT;
117 org2 = findbetterlocation (org, 8);
118 pointparticles(particleeffectnum("laser_impact"), org2, trace_plane_normal * 1000, 1);
119 sound (self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
122 org2 = findbetterlocation (org, 2);
123 pointparticles(particleeffectnum("shotgun_impact"), org2, trace_plane_normal * 1000, 1);
126 org2 = findbetterlocation (org, 2);
127 pointparticles(particleeffectnum("machinegun_impact"), org2, trace_plane_normal * 1000, 1);
129 case WEP_GRENADE_LAUNCHER:
130 org2 = findbetterlocation (org, 12);
131 pointparticles(particleeffectnum("grenade_explode"), org2, '0 0 0', 1);
132 sound (self, CHAN_PROJECTILE, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
135 org2 = findbetterlocation (org, 8);
138 sound (self, CHAN_PROJECTILE, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
139 pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
145 // this is sent as "primary bounce" to distinguish it from secondary bounced balls
146 sound (self, CHAN_PROJECTILE, "weapons/electro_impact_combo.wav", VOL_BASE, ATTN_NORM);
147 pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
151 sound (self, CHAN_PROJECTILE, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
152 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
158 sound (self, CHAN_PROJECTILE, "weapons/crylink_impact2.wav", VOL_BASE, ATTN_NORM);
159 pointparticles(particleeffectnum("crylink_impact"), org, '0 0 0', 1);
163 sound (self, CHAN_PROJECTILE, "weapons/crylink_impact.wav", VOL_BASE, ATTN_NORM);
164 pointparticles(particleeffectnum("crylink_impactbig"), org, '0 0 0', 1);
168 sound(self, CHAN_PROJECTILE, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
169 pointparticles(particleeffectnum("nex_impact"), org - normalize(force) * 6, '0 0 0', 1);
172 org2 = findbetterlocation (org, 12);
174 sound (self, CHAN_PROJECTILE, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
176 sound (self, CHAN_PROJECTILE, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
178 sound (self, CHAN_PROJECTILE, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
179 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
181 case WEP_ROCKET_LAUNCHER:
182 org2 = findbetterlocation (org, 16);
183 sound (self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
184 pointparticles(particleeffectnum("rocket_explode"), org2, '0 0 0', 1);
187 print("Since when does Porto send DamageInfo?\n");
190 sound(self, CHAN_PROJECTILE, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
191 pointparticles(particleeffectnum("nex_impact"), org - normalize(force) * 6, '0 0 0', 1);
194 org2 = findbetterlocation (org, 12);
195 sound (self, CHAN_PROJECTILE, "weapons/hookbomb_impact.wav", VOL_BASE, ATTN_NORM);
196 pointparticles(particleeffectnum("hookbomb_explode"), org2, '0 0 0', 1);
199 org2 = findbetterlocation (org, 12);
203 sound (self, CHAN_PROJECTILE, "weapons/flacexp1.wav", 1, ATTN_NORM);
205 sound (self, CHAN_PROJECTILE, "weapons/flacexp2.wav", 1, ATTN_NORM);
207 sound (self, CHAN_PROJECTILE, "weapons/flacexp3.wav", 1, ATTN_NORM);
208 pointparticles(particleeffectnum("flac_explode"), org2, '0 0 0', 1);
215 sound (self, CHAN_PROJECTILE, "weapons/tagexp1.wav", 1, ATTN_NORM);
217 sound (self, CHAN_PROJECTILE, "weapons/tagexp2.wav", 1, ATTN_NORM);
219 sound (self, CHAN_PROJECTILE, "weapons/tagexp3.wav", 1, ATTN_NORM);
220 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
224 sound (self, CHAN_PROJECTILE, "weapons/tag_impact.wav", 1, ATTN_NORM);
229 sound (self, CHAN_PROJECTILE, "weapons/seekerexp1.wav", 1, ATTN_NORM);
231 sound (self, CHAN_PROJECTILE, "weapons/seekerexp2.wav", 1, ATTN_NORM);
233 sound (self, CHAN_PROJECTILE, "weapons/seekerexp3.wav", 1, ATTN_NORM);
234 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
239 org2 = findbetterlocation (org, 12);
240 sound (self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
241 pointparticles(particleeffectnum("laser_impact"), org2, trace_plane_normal * 1000, 1);
243 case WEP_CAMPINGRIFLE:
244 org2 = findbetterlocation (org, 2);
245 pointparticles(particleeffectnum("machinegun_impact"), org, trace_plane_normal * 1000, 1);
248 dprint("Unhandled damage of weapon ", ftos(hitwep), "\n");