1 void Ent_DamageInfo(float isNew)
3 float dmg, rad, edge, thisdmg, forcemul;
4 vector force, thisforce;
9 w_deathtype = ReadShort();
10 w_issilent = (w_deathtype & 0x8000);
11 w_deathtype = (w_deathtype & 0x7FFF);
13 w_org_x = ReadCoord();
14 w_org_y = ReadCoord();
15 w_org_z = ReadCoord();
20 force = decompressShortVector(ReadShort());
33 for(self = findradius(w_org, rad + MAX_DAMAGEEXTRARADIUS); self; self = self.chain)
35 vector nearest = NearestPointOnBox(self, w_org);
38 thisdmg = ((vlen (nearest - w_org) - bound(MIN_DAMAGEEXTRARADIUS, self.damageextraradius, MAX_DAMAGEEXTRARADIUS)) / rad);
45 thisdmg = dmg + (edge - dmg) * thisdmg;
46 thisforce = forcemul * vlen(force) * (thisdmg / dmg) * normalize(self.origin - w_org);
51 thisforce = forcemul * vlen(force) * normalize(self.origin - w_org);
56 if(vlen(nearest - w_org) > bound(MIN_DAMAGEEXTRARADIUS, self.damageextraradius, MAX_DAMAGEEXTRARADIUS))
60 thisforce = forcemul * force;
63 if(self.damageforcescale)
66 self.move_velocity = self.move_velocity + damage_explosion_calcpush(self.damageforcescale * thisforce, self.move_velocity, autocvar_g_balance_damagepush_speedfactor);
67 self.move_flags &~= FL_ONGROUND;
74 self.event_damage(thisdmg, w_deathtype, w_org, thisforce);
79 if(DEATH_ISVEHICLE(w_deathtype))
81 traceline(w_org - normalize(force) * 16, w_org + normalize(force) * 16, MOVE_NOMONSTERS, world);
82 if(trace_plane_normal != '0 0 0')
83 w_backoff = trace_plane_normal;
85 w_backoff = -1 * normalize(w_org - (w_org + normalize(force) * 16));
87 setorigin(self, w_org + w_backoff * 2); // for sound() calls
96 _snd = strcat("weapons/ric", ftos(1 + rint(random() * 2)), ".waw");
97 sound(self, CH_SHOTS, _snd, VOL_BASE, ATTN_NORM);
98 pointparticles(particleeffectnum("spiderbot_minigun_impact"), self.origin, w_backoff * 1000, 1);
101 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
102 pointparticles(particleeffectnum("spiderbot_rocket_explode"), self.origin, w_backoff * 1000, 1);
105 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_MIN);
106 pointparticles(particleeffectnum("explosion_big"), self.origin, w_backoff * 1000, 1);
110 sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
111 pointparticles(particleeffectnum("wakizashi_gun_impact"), self.origin, w_backoff * 1000, 1);
113 case DEATH_WAKIROCKET:
114 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
115 pointparticles(particleeffectnum("wakizashi_rocket_explode"), self.origin, w_backoff * 1000, 1);
117 case DEATH_WAKIBLOWUP:
118 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_MIN);
119 pointparticles(particleeffectnum("explosion_big"), self.origin, w_backoff * 1000, 1);
122 case DEATH_RAPTOR_CANNON:
123 sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
124 pointparticles(particleeffectnum("raptor_cannon_impact"), self.origin, w_backoff * 1000, 1);
126 case DEATH_RAPTOR_BOMB_SPLIT:
129 for(i = 1; i < 4; ++i)
131 vel = normalize(w_org - (w_org + normalize(force) * 16)) + randomvec() * 128;
132 ang = vectoangles(vel);
133 RaptorCBShellfragToss(w_org, vel, ang + '0 0 1' * (120 * i));
137 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
138 pointparticles(particleeffectnum("raptor_bomb_spread"), self.origin, w_backoff * 1000, 1);
140 case DEATH_RAPTOR_BOMB:
141 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
142 pointparticles(particleeffectnum("raptor_bomb_impact"), self.origin, w_backoff * 1000, 1);
144 case DEATH_RAPTOR_DEATH:
145 sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_MIN);
146 pointparticles(particleeffectnum("explosion_big"), self.origin, w_backoff * 1000, 1);
152 if(DEATH_ISTURRET(w_deathtype))
155 traceline(w_org - normalize(force) * 16, w_org + normalize(force) * 16, MOVE_NOMONSTERS, world);
156 if(trace_plane_normal != '0 0 0')
157 w_backoff = trace_plane_normal;
159 w_backoff = -1 * normalize(w_org - (w_org + normalize(force) * 16));
161 setorigin(self, w_org + w_backoff * 2); // for sound() calls
165 case DEATH_TURRET_EWHEEL:
166 sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_MIN);
167 pointparticles(particleeffectnum("laser_impact"), self.origin, w_backoff * 1000, 1);
170 case DEATH_TURRET_FLAC:
171 pointparticles(particleeffectnum("hagar_explode"), w_org, '0 0 0', 1);
172 _snd = strcat("weapons/hagexp", ftos(1 + rint(random() * 2)), ".waw");
173 sound(self, CH_SHOTS, _snd, VOL_BASE, ATTN_NORM);
176 case DEATH_TURRET_MLRS:
177 case DEATH_TURRET_HK:
178 case DEATH_TURRET_WALKER_ROCKET:
179 case DEATH_TURRET_HELLION:
180 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_MIN);
181 pointparticles(particleeffectnum("rocket_explode"), self.origin, w_backoff * 1000, 1);
184 case DEATH_TURRET_MACHINEGUN:
185 case DEATH_TURRET_WALKER_GUN:
186 _snd = strcat("weapons/ric", ftos(1 + rint(random() * 2)), ".waw");
187 sound(self, CH_SHOTS, _snd, VOL_BASE, ATTN_NORM);
188 pointparticles(particleeffectnum("machinegun_impact"), self.origin, w_backoff * 1000, 1);
191 case DEATH_TURRET_PLASMA:
192 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTN_MIN);
193 pointparticles(particleeffectnum("electro_impact"), self.origin, w_backoff * 1000, 1);
196 case DEATH_TURRET_WALKER_MEELE:
197 sound(self, CH_SHOTS, "weapons/ric1.wav", VOL_BASE, ATTN_MIN);
198 pointparticles(particleeffectnum("TE_SPARK"), self.origin, w_backoff * 1000, 1);
201 case DEATH_TURRET_PHASER:
204 case DEATH_TURRET_TESLA:
205 te_smallflash(self.origin);
211 // TODO spawn particle effects and sounds based on w_deathtype
212 if(!DEATH_ISSPECIAL(w_deathtype))
216 hitwep = DEATH_WEAPONOFWEAPONDEATH(w_deathtype);
217 w_random = prandom();
219 traceline(w_org - normalize(force) * 16, w_org + normalize(force) * 16, MOVE_NOMONSTERS, world);
220 if(trace_fraction < 1 && hitwep != WEP_NEX && hitwep != WEP_MINSTANEX)
221 w_backoff = trace_plane_normal;
223 w_backoff = -1 * normalize(force);
224 setorigin(self, w_org + w_backoff * 2); // for sound() calls
226 (get_weaponinfo(hitwep)).weapon_func(WR_IMPACTEFFECT);
230 void DamageInfo_Precache()
233 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
234 (get_weaponinfo(i)).weapon_func(WR_PRECACHE);