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 p = NearestPointOnBox(self, w_org);
36 if(vlen(p - w_org) > rad + self.damageextraradius)
41 thisdmg = vlen(self.origin - w_org) / rad;
46 thisdmg = dmg + (edge - dmg) * thisdmg;
47 thisforce = forcemul * vlen(force) * (thisdmg / dmg) * normalize(self.origin - w_org);
52 thisforce = forcemul * vlen(force) * normalize(self.origin - w_org);
58 thisforce = forcemul * force;
61 if(self.damageforcescale)
64 self.move_velocity = self.move_velocity + damage_explosion_calcpush(self.damageforcescale * thisforce, self.move_velocity, autocvar_g_balance_damagepush_speedfactor);
65 self.move_flags &~= FL_ONGROUND;
72 self.event_damage(thisdmg, w_deathtype, w_org, thisforce);
77 if(DEATH_ISVEHICLE(w_deathtype))
79 traceline(w_org - normalize(force) * 16, w_org + normalize(force) * 16, MOVE_NOMONSTERS, world);
80 if(trace_plane_normal != '0 0 0')
81 w_backoff = trace_plane_normal;
83 w_backoff = -1 * normalize(w_org - (w_org + normalize(force) * 16));
85 setorigin(self, w_org + w_backoff * 2); // for sound() calls
94 _snd = strcat("weapons/ric", ftos(1 + rint(random() * 2)), ".waw");
95 sound(self, CH_SHOTS, _snd, VOL_BASE, ATTN_NORM);
96 pointparticles(particleeffectnum("spiderbot_minigun_impact"), self.origin, w_backoff * 1000, 1);
99 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
100 pointparticles(particleeffectnum("spiderbot_rocket_explode"), self.origin, w_backoff * 1000, 1);
103 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_MIN);
104 pointparticles(particleeffectnum("explosion_big"), self.origin, w_backoff * 1000, 1);
108 sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
109 pointparticles(particleeffectnum("wakizashi_gun_impact"), self.origin, w_backoff * 1000, 1);
111 case DEATH_WAKIROCKET:
112 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
113 pointparticles(particleeffectnum("wakizashi_rocket_explode"), self.origin, w_backoff * 1000, 1);
115 case DEATH_WAKIBLOWUP:
116 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_MIN);
117 pointparticles(particleeffectnum("explosion_big"), self.origin, w_backoff * 1000, 1);
120 case DEATH_RAPTOR_CANNON:
121 sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
122 pointparticles(particleeffectnum("raptor_cannon_impact"), self.origin, w_backoff * 1000, 1);
124 case DEATH_RAPTOR_BOMB_SPLIT:
127 for(i = 1; i < 4; ++i)
129 vel = normalize(w_org - (w_org + normalize(force) * 16)) + randomvec() * 128;
130 ang = vectoangles(vel);
131 RaptorCBShellfragToss(w_org, vel, ang + '0 0 1' * (120 * i));
135 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
136 pointparticles(particleeffectnum("raptor_bomb_spread"), self.origin, w_backoff * 1000, 1);
138 case DEATH_RAPTOR_BOMB:
139 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
140 pointparticles(particleeffectnum("raptor_bomb_impact"), self.origin, w_backoff * 1000, 1);
142 case DEATH_RAPTOR_DEATH:
143 sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_MIN);
144 pointparticles(particleeffectnum("explosion_big"), self.origin, w_backoff * 1000, 1);
150 if(DEATH_ISTURRET(w_deathtype))
153 traceline(w_org - normalize(force) * 16, w_org + normalize(force) * 16, MOVE_NOMONSTERS, world);
154 if(trace_plane_normal != '0 0 0')
155 w_backoff = trace_plane_normal;
157 w_backoff = -1 * normalize(w_org - (w_org + normalize(force) * 16));
159 setorigin(self, w_org + w_backoff * 2); // for sound() calls
163 case DEATH_TURRET_EWHEEL:
164 sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_MIN);
165 pointparticles(particleeffectnum("laser_impact"), self.origin, w_backoff * 1000, 1);
168 case DEATH_TURRET_FLAC:
169 pointparticles(particleeffectnum("hagar_explode"), w_org, '0 0 0', 1);
170 _snd = strcat("weapons/hagexp", ftos(1 + rint(random() * 2)), ".waw");
171 sound(self, CH_SHOTS, _snd, VOL_BASE, ATTN_NORM);
174 case DEATH_TURRET_MLRS:
175 case DEATH_TURRET_HK:
176 case DEATH_TURRET_WALKER_ROCKET:
177 case DEATH_TURRET_HELLION:
178 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_MIN);
179 pointparticles(particleeffectnum("rocket_explode"), self.origin, w_backoff * 1000, 1);
182 case DEATH_TURRET_MACHINEGUN:
183 case DEATH_TURRET_WALKER_GUN:
184 _snd = strcat("weapons/ric", ftos(1 + rint(random() * 2)), ".waw");
185 sound(self, CH_SHOTS, _snd, VOL_BASE, ATTN_NORM);
186 pointparticles(particleeffectnum("machinegun_impact"), self.origin, w_backoff * 1000, 1);
189 case DEATH_TURRET_PLASMA:
190 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTN_MIN);
191 pointparticles(particleeffectnum("electro_impact"), self.origin, w_backoff * 1000, 1);
194 case DEATH_TURRET_WALKER_MEELE:
195 sound(self, CH_SHOTS, "weapons/ric1.wav", VOL_BASE, ATTN_MIN);
196 pointparticles(particleeffectnum("TE_SPARK"), self.origin, w_backoff * 1000, 1);
199 case DEATH_TURRET_PHASER:
202 case DEATH_TURRET_TESLA:
203 te_smallflash(self.origin);
209 // TODO spawn particle effects and sounds based on w_deathtype
210 if(!DEATH_ISSPECIAL(w_deathtype))
214 hitwep = DEATH_WEAPONOFWEAPONDEATH(w_deathtype);
215 w_random = prandom();
217 traceline(w_org - normalize(force) * 16, w_org + normalize(force) * 16, MOVE_NOMONSTERS, world);
218 if(trace_fraction < 1 && hitwep != WEP_NEX && hitwep != WEP_MINSTANEX)
219 w_backoff = trace_plane_normal;
221 w_backoff = -1 * normalize(force);
222 setorigin(self, w_org + w_backoff * 2); // for sound() calls
224 (get_weaponinfo(hitwep)).weapon_func(WR_IMPACTEFFECT);
228 void DamageInfo_Precache()
231 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
232 (get_weaponinfo(i)).weapon_func(WR_PRECACHE);