5 float hittype, dmg, rad, edge, thisdmg, forcemul;
7 vector force, org, thisforce;
12 hittype = ReadShort();
14 issilent = (hittype & 0x8000);
15 hittype = (hittype & 0x7FFF);
24 force = decompressShortVector(ReadShort());
34 for(self = findradius(org, rad); self; self = self.chain)
38 thisdmg = vlen(self.origin - org) / rad;
43 thisdmg = dmg + (edge - dmg) * thisdmg;
44 thisforce = forcemul * vlen(force) * (thisdmg / dmg) * normalize(self.origin - org);
49 thisforce = forcemul * vlen(force) * normalize(self.origin - org);
55 thisforce = forcemul * force;
58 //print("check ", ftos(num_for_edict(self)), " ", self.classname, "\n");
59 //print(ftos(self.damageforcescale), "\n");
60 //print(vtos(thisforce), "\n");
61 if(self.damageforcescale)
64 self.move_velocity = self.move_velocity + self.damageforcescale * thisforce;
65 self.move_flags &~= FL_ONGROUND;
66 //print("pushed ", ftos(num_for_edict(self)), " loose\n");
73 self.event_damage(thisdmg, hittype, org, thisforce);
78 // TODO spawn particle effects and sounds based on hittype
80 if(!DEATH_ISSPECIAL(hittype))
82 float hitwep, secondary, bounce, headshot;
86 hitwep = DEATH_WEAPONOFWEAPONDEATH(hittype);
87 secondary = hittype & HITTYPE_SECONDARY;
88 bounce = hittype & HITTYPE_BOUNCE;
89 headshot = hittype & HITTYPE_HEADSHOT;
92 traceline(org - normalize(force) * 16, org + normalize(force) * 16, MOVE_NOMONSTERS, world);
93 if(trace_fraction < 1 && hitwep != WEP_NEX && hitwep != WEP_MINSTANEX)
94 backoff = trace_plane_normal;
96 backoff = -1 * normalize(force);
98 setorigin(self, org + backoff * 2); // for sound() calls
103 org2 = org + backoff * 6;
104 pointparticles(particleeffectnum("laser_impact"), org2, backoff * 1000, 1);
106 sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
109 org2 = org + backoff * 2;
110 pointparticles(particleeffectnum("shotgun_impact"), org2, backoff * 1000, 1);
114 sound(self, CHAN_PROJECTILE, "weapons/ric1.wav", VOL_BASE, ATTN_NORM);
116 sound(self, CHAN_PROJECTILE, "weapons/ric2.wav", VOL_BASE, ATTN_NORM);
118 sound(self, CHAN_PROJECTILE, "weapons/ric3.wav", VOL_BASE, ATTN_NORM);
122 org2 = org + backoff * 2;
123 pointparticles(particleeffectnum("machinegun_impact"), org2, backoff * 1000, 1);
126 sound(self, CHAN_PROJECTILE, "weapons/ric1.wav", VOL_BASE, ATTN_NORM);
128 sound(self, CHAN_PROJECTILE, "weapons/ric2.wav", VOL_BASE, ATTN_NORM);
130 sound(self, CHAN_PROJECTILE, "weapons/ric3.wav", VOL_BASE, ATTN_NORM);
132 case WEP_GRENADE_LAUNCHER:
133 org2 = org + backoff * 12;
134 pointparticles(particleeffectnum("grenade_explode"), org2, '0 0 0', 1);
136 sound(self, CHAN_PROJECTILE, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
139 org2 = org + backoff * 6;
142 pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
144 sound(self, CHAN_PROJECTILE, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
150 // this is sent as "primary bounce" to distinguish it from secondary bounced balls
151 pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
153 sound(self, CHAN_PROJECTILE, "weapons/electro_impact_combo.wav", VOL_BASE, ATTN_NORM);
157 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
159 sound(self, CHAN_PROJECTILE, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
164 org2 = org + backoff * 2;
167 pointparticles(particleeffectnum("crylink_impact"), org2, '0 0 0', 1);
169 sound(self, CHAN_PROJECTILE, "weapons/crylink_impact2.wav", VOL_BASE, ATTN_NORM);
173 pointparticles(particleeffectnum("crylink_impactbig"), org2, '0 0 0', 1);
175 sound(self, CHAN_PROJECTILE, "weapons/crylink_impact.wav", VOL_BASE, ATTN_NORM);
179 org2 = org + backoff * 6;
180 pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
182 sound(self, CHAN_PROJECTILE, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
185 org2 = org + backoff * 6;
186 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
190 sound(self, CHAN_PROJECTILE, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
192 sound(self, CHAN_PROJECTILE, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
194 sound(self, CHAN_PROJECTILE, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
197 case WEP_ROCKET_LAUNCHER:
198 org2 = org + backoff * 12;
199 pointparticles(particleeffectnum("rocket_explode"), org2, '0 0 0', 1);
201 sound(self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
204 print("Since when does Porto send DamageInfo?\n");
207 org2 = org + backoff * 6;
208 pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
210 sound(self, CHAN_PROJECTILE, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
213 org2 = org + backoff * 2;
214 pointparticles(particleeffectnum("hookbomb_explode"), org2, '0 0 0', 1);
216 sound(self, CHAN_PROJECTILE, "weapons/hookbomb_impact.wav", VOL_BASE, ATTN_NORM);
219 org2 = org + backoff * 6;
220 pointparticles(particleeffectnum("laser_impact"), org2, backoff * 1000, 1);
222 sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
224 case WEP_CAMPINGRIFLE:
225 org2 = org + backoff * 2;
226 pointparticles(particleeffectnum("machinegun_impact"), org2, backoff * 1000, 1);
230 sound(self, CHAN_PROJECTILE, "weapons/ric1.wav", VOL_BASE, ATTN_NORM);
232 sound(self, CHAN_PROJECTILE, "weapons/ric2.wav", VOL_BASE, ATTN_NORM);
234 sound(self, CHAN_PROJECTILE, "weapons/ric3.wav", VOL_BASE, ATTN_NORM);
242 org2 = org + backoff * 16;
243 pointparticles(particleeffectnum("fireball_explode"), org2, '0 0 0', 1);
245 sound(self, CHAN_PROJECTILE, "weapons/fireball_impact2.wav", VOL_BASE, ATTN_NORM * 0.25); // long range boom
249 // firemine goes out silently
253 dprint("Unhandled damage of weapon ", ftos(hitwep), "\n");
259 void DamageInfo_Precache()
261 precache_sound("weapons/crylink_impact2.wav");
262 precache_sound("weapons/crylink_impact.wav");
263 precache_sound("weapons/electro_impact.wav");
264 precache_sound("weapons/electro_impact_combo.wav");
265 precache_sound("weapons/grenade_impact.wav");
266 precache_sound("weapons/hagexp1.wav");
267 precache_sound("weapons/hagexp2.wav");
268 precache_sound("weapons/hagexp3.wav");
269 precache_sound("weapons/flacexp1.wav");
270 precache_sound("weapons/flacexp2.wav");
271 precache_sound("weapons/flacexp3.wav");
272 precache_sound("weapons/hookbomb_impact.wav");
273 precache_sound("weapons/laserimpact.wav");
274 precache_sound("weapons/neximpact.wav");
275 precache_sound("weapons/ric1.wav");
276 precache_sound("weapons/ric2.wav");
277 precache_sound("weapons/ric3.wav");
278 precache_sound("weapons/rocket_impact.wav");
279 precache_sound("weapons/fireball_impact.wav");
280 precache_sound("weapons/fireball_impact2.wav");