3 void Ent_DamageInfo(float isNew)
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());
37 for(self = findradius(org, rad); self; self = self.chain)
41 thisdmg = vlen(self.origin - org) / rad;
46 thisdmg = dmg + (edge - dmg) * thisdmg;
47 thisforce = forcemul * vlen(force) * (thisdmg / dmg) * normalize(self.origin - org);
52 thisforce = forcemul * vlen(force) * normalize(self.origin - org);
58 thisforce = forcemul * force;
61 //print("check ", ftos(num_for_edict(self)), " ", self.classname, "\n");
62 //print(ftos(self.damageforcescale), "\n");
63 //print(vtos(thisforce), "\n");
64 if(self.damageforcescale)
67 self.move_velocity = self.move_velocity + self.damageforcescale * thisforce;
68 self.move_flags &~= FL_ONGROUND;
69 //print("pushed ", ftos(num_for_edict(self)), " loose\n");
76 self.event_damage(thisdmg, hittype, org, thisforce);
81 // TODO spawn particle effects and sounds based on hittype
83 if(!DEATH_ISSPECIAL(hittype))
85 float hitwep, secondary, bounce, headshot;
89 hitwep = DEATH_WEAPONOFWEAPONDEATH(hittype);
90 secondary = hittype & HITTYPE_SECONDARY;
91 bounce = hittype & HITTYPE_BOUNCE;
92 headshot = hittype & HITTYPE_HEADSHOT;
95 traceline(org - normalize(force) * 16, org + normalize(force) * 16, MOVE_NOMONSTERS, world);
96 if(trace_fraction < 1 && hitwep != WEP_NEX && hitwep != WEP_MINSTANEX)
97 backoff = trace_plane_normal;
99 backoff = -1 * normalize(force);
101 setorigin(self, org + backoff * 2); // for sound() calls
106 org2 = org + backoff * 6;
107 pointparticles(particleeffectnum("laser_impact"), org2, backoff * 1000, 1);
109 sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
112 org2 = org + backoff * 2;
113 pointparticles(particleeffectnum("shotgun_impact"), org2, backoff * 1000, 1);
117 sound(self, CHAN_PROJECTILE, "weapons/ric1.wav", VOL_BASE, ATTN_NORM);
119 sound(self, CHAN_PROJECTILE, "weapons/ric2.wav", VOL_BASE, ATTN_NORM);
121 sound(self, CHAN_PROJECTILE, "weapons/ric3.wav", VOL_BASE, ATTN_NORM);
125 org2 = org + backoff * 2;
126 pointparticles(particleeffectnum("machinegun_impact"), org2, backoff * 1000, 1);
129 sound(self, CHAN_PROJECTILE, "weapons/ric1.wav", VOL_BASE, ATTN_NORM);
131 sound(self, CHAN_PROJECTILE, "weapons/ric2.wav", VOL_BASE, ATTN_NORM);
133 sound(self, CHAN_PROJECTILE, "weapons/ric3.wav", VOL_BASE, ATTN_NORM);
135 case WEP_GRENADE_LAUNCHER:
136 org2 = org + backoff * 12;
137 pointparticles(particleeffectnum("grenade_explode"), org2, '0 0 0', 1);
139 sound(self, CHAN_PROJECTILE, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
142 org2 = org + backoff * 6;
145 pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
147 sound(self, CHAN_PROJECTILE, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
153 // this is sent as "primary bounce" to distinguish it from secondary bounced balls
154 pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
156 sound(self, CHAN_PROJECTILE, "weapons/electro_impact_combo.wav", VOL_BASE, ATTN_NORM);
160 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
162 sound(self, CHAN_PROJECTILE, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
167 org2 = org + backoff * 2;
170 pointparticles(particleeffectnum("crylink_impact"), org2, '0 0 0', 1);
172 sound(self, CHAN_PROJECTILE, "weapons/crylink_impact2.wav", VOL_BASE, ATTN_NORM);
176 pointparticles(particleeffectnum("crylink_impactbig"), org2, '0 0 0', 1);
178 sound(self, CHAN_PROJECTILE, "weapons/crylink_impact.wav", VOL_BASE, ATTN_NORM);
182 org2 = org + backoff * 6;
183 pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
185 sound(self, CHAN_PROJECTILE, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
188 org2 = org + backoff * 6;
189 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
193 sound(self, CHAN_PROJECTILE, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
195 sound(self, CHAN_PROJECTILE, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
197 sound(self, CHAN_PROJECTILE, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
200 case WEP_ROCKET_LAUNCHER:
201 org2 = org + backoff * 12;
202 pointparticles(particleeffectnum("rocket_explode"), org2, '0 0 0', 1);
204 sound(self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
207 print("Since when does Porto send DamageInfo?\n");
210 org2 = org + backoff * 6;
211 pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
213 sound(self, CHAN_PROJECTILE, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
216 org2 = org + backoff * 2;
217 pointparticles(particleeffectnum("hookbomb_explode"), org2, '0 0 0', 1);
219 sound(self, CHAN_PROJECTILE, "weapons/hookbomb_impact.wav", VOL_BASE, ATTN_NORM);
222 org2 = org + backoff * 6;
223 pointparticles(particleeffectnum("laser_impact"), org2, backoff * 1000, 1);
225 sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
227 case WEP_CAMPINGRIFLE:
228 org2 = org + backoff * 2;
229 pointparticles(particleeffectnum("machinegun_impact"), org2, backoff * 1000, 1);
233 sound(self, CHAN_PROJECTILE, "weapons/ric1.wav", VOL_BASE, ATTN_NORM);
235 sound(self, CHAN_PROJECTILE, "weapons/ric2.wav", VOL_BASE, ATTN_NORM);
237 sound(self, CHAN_PROJECTILE, "weapons/ric3.wav", VOL_BASE, ATTN_NORM);
245 org2 = org + backoff * 16;
246 pointparticles(particleeffectnum("fireball_explode"), org2, '0 0 0', 1);
248 sound(self, CHAN_PROJECTILE, "weapons/fireball_impact2.wav", VOL_BASE, ATTN_NORM * 0.25); // long range boom
252 // firemine goes out silently
256 dprint("Unhandled damage of weapon ", ftos(hitwep), "\n");
262 void DamageInfo_Precache()
264 precache_sound("weapons/crylink_impact2.wav");
265 precache_sound("weapons/crylink_impact.wav");
266 precache_sound("weapons/electro_impact.wav");
267 precache_sound("weapons/electro_impact_combo.wav");
268 precache_sound("weapons/grenade_impact.wav");
269 precache_sound("weapons/hagexp1.wav");
270 precache_sound("weapons/hagexp2.wav");
271 precache_sound("weapons/hagexp3.wav");
272 precache_sound("weapons/flacexp1.wav");
273 precache_sound("weapons/flacexp2.wav");
274 precache_sound("weapons/flacexp3.wav");
275 precache_sound("weapons/hookbomb_impact.wav");
276 precache_sound("weapons/laserimpact.wav");
277 precache_sound("weapons/neximpact.wav");
278 precache_sound("weapons/ric1.wav");
279 precache_sound("weapons/ric2.wav");
280 precache_sound("weapons/ric3.wav");
281 precache_sound("weapons/rocket_impact.wav");
282 precache_sound("weapons/fireball_impact.wav");
283 precache_sound("weapons/fireball_impact2.wav");