.float silent; void Ent_DamageInfo(float isNew) { float hittype, dmg, rad, edge, thisdmg, forcemul; float issilent; vector force, org, thisforce; entity oldself; oldself = self; hittype = ReadShort(); issilent = (hittype & 0x8000); hittype = (hittype & 0x7FFF); org_x = ReadCoord(); org_y = ReadCoord(); org_z = ReadCoord(); dmg = ReadByte(); rad = ReadByte(); edge = ReadByte(); force = decompressShortVector(ReadShort()); if not(isNew) return; if(rad < 0) { rad = -rad; forcemul = -1; } else forcemul = 1; for(self = findradius(org, rad); self; self = self.chain) { if(rad) { thisdmg = vlen(self.origin - org) / rad; if(thisdmg >= 1) continue; if(dmg) { thisdmg = dmg + (edge - dmg) * thisdmg; thisforce = forcemul * vlen(force) * (thisdmg / dmg) * normalize(self.origin - org); } else { thisdmg = 0; thisforce = forcemul * vlen(force) * normalize(self.origin - org); } } else { thisdmg = dmg; thisforce = forcemul * force; } //print("check ", ftos(num_for_edict(self)), " ", self.classname, "\n"); //print(ftos(self.damageforcescale), "\n"); //print(vtos(thisforce), "\n"); if(self.damageforcescale) if(vlen(thisforce)) { self.move_velocity = self.move_velocity + self.damageforcescale * thisforce; self.move_flags &~= FL_ONGROUND; //print("pushed ", ftos(num_for_edict(self)), " loose\n"); } if(issilent) self.silent = 1; if(self.event_damage) self.event_damage(thisdmg, hittype, org, thisforce); } self = oldself; // TODO spawn particle effects and sounds based on hittype if(!DEATH_ISSPECIAL(hittype)) { float hitwep, secondary, bounce, headshot; vector org2, backoff; float r; hitwep = DEATH_WEAPONOFWEAPONDEATH(hittype); secondary = hittype & HITTYPE_SECONDARY; bounce = hittype & HITTYPE_BOUNCE; headshot = hittype & HITTYPE_HEADSHOT; r = prandom(); traceline(org - normalize(force) * 16, org + normalize(force) * 16, MOVE_NOMONSTERS, world); if(trace_fraction < 1) backoff = trace_plane_normal; else backoff = -1 * normalize(force); setorigin(self, org + backoff * 2); // for sound() calls switch(hitwep) { case WEP_GRABBER: org2 = org + backoff * 6; pointparticles(particleeffectnum("laser_impact"), org2, backoff * 1000, 1); if(!issilent) sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM); break; default: dprint("Unhandled damage of weapon ", ftos(hitwep), "\n"); break; } } } void DamageInfo_Precache() { }