aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/game/Fire.java
blob: 9a68b085879e4d19804dee3d4eb7fac9fd20f10f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
/*
Copyright (C) 1997-2001 Id Software, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/

// Created on 04.12.2003 by RST.
// $Id: Fire.java,v 1.1 2004-07-07 19:58:52 hzi Exp $

package jake2.game;


 import jake2.*;
 import jake2.client.*;
 import jake2.qcommon.*;
 import jake2.render.*;
 import jake2.server.*;
import jake2.util.*;

public class Fire {

	/*
	=================
	fire_hit
	
	Used for all impact (hit/punch/slash) attacks
	=================
	*/
	public static  boolean fire_hit(edict_t self, float[] aim, int damage, int kick) {
		trace_t tr;
		float[] forward= { 0, 0, 0 }, right= { 0, 0, 0 }, up= { 0, 0, 0 };
		float[] v= { 0, 0, 0 };
		float[] point= { 0, 0, 0 };
		float range;
		float[] dir= { 0, 0, 0 };
	
		//see if enemy is in range
		Math3D.VectorSubtract(self.enemy.s.origin, self.s.origin, dir);
		range= Math3D.VectorLength(dir);
		if (range > aim[0])
			return false;
	
		if (aim[1] > self.mins[0] && aim[1] < self.maxs[0]) {
			// the hit is straight on so back the range up to the edge of their bbox
			range -= self.enemy.maxs[0];
		} else {
			// this is a side hit so adjust the "right" value out to the edge of their bbox
			if (aim[1] < 0)
				aim[1]= self.enemy.mins[0];
			else
				aim[1]= self.enemy.maxs[0];
		}
	
		Math3D.VectorMA(self.s.origin, range, dir, point);
	
		tr= GameBase.gi.trace(self.s.origin, null, null, point, self, Defines.MASK_SHOT);
		if (tr.fraction < 1) {
			if (0 == tr.ent.takedamage)
				return false;
			// if it will hit any client/monster then hit the one we wanted to hit
			if ((tr.ent.svflags & Defines.SVF_MONSTER) != 0 || (tr.ent.client != null))
				tr.ent= self.enemy;
		}
	
		Math3D.AngleVectors(self.s.angles, forward, right, up);
		Math3D.VectorMA(self.s.origin, range, forward, point);
		Math3D.VectorMA(point, aim[1], right, point);
		Math3D.VectorMA(point, aim[2], up, point);
		Math3D.VectorSubtract(point, self.enemy.s.origin, dir);
	
		// do the damage
		GameUtil.T_Damage(
			tr.ent,
			self,
			self,
			dir,
			point,
			GameBase.vec3_origin,
			damage,
			kick / 2,
			Defines.DAMAGE_NO_KNOCKBACK,
			Defines.MOD_HIT);
	
		if (0 == (tr.ent.svflags & Defines.SVF_MONSTER) && (null == tr.ent.client))
			return false;
	
		// do our special form of knockback here
		Math3D.VectorMA(self.enemy.absmin, 0.5f, self.enemy.size, v);
		Math3D.VectorSubtract(v, point, v);
		Math3D.VectorNormalize(v);
		Math3D.VectorMA(self.enemy.velocity, kick, v, self.enemy.velocity);
		if (self.enemy.velocity[2] > 0)
			self.enemy.groundentity= null;
		return true;
	}
	/*
	=================
	fire_lead
	
	This is an internal support routine used for bullet/pellet based weapons.
	=================
	*/
	public static  void fire_lead(
		edict_t self,
		float[] start,
		float[] aimdir,
		int damage,
		int kick,
		int te_impact,
		int hspread,
		int vspread,
		int mod) {
		trace_t tr;
		float[] dir= { 0, 0, 0 };
		float[] forward= { 0, 0, 0 }, right= { 0, 0, 0 }, up= { 0, 0, 0 };
		float[] end= { 0, 0, 0 };
		float r;
		float u;
		float[] water_start= { 0, 0, 0 };
		boolean water= false;
		int content_mask= Defines.MASK_SHOT | Defines.MASK_WATER;
	
		tr= GameBase.gi.trace(self.s.origin, null, null, start, self, Defines.MASK_SHOT);
		if (!(tr.fraction < 1.0)) {
			Math3D.vectoangles(aimdir, dir);
			Math3D.AngleVectors(dir, forward, right, up);
	
			r= Lib.crandom() * hspread;
			u= Lib.crandom() * vspread;
			Math3D.VectorMA(start, 8192, forward, end);
			Math3D.VectorMA(end, r, right, end);
			Math3D.VectorMA(end, u, up, end);
	
			if ((GameBase.gi.pointcontents.pointcontents(start) & Defines.MASK_WATER) != 0) {
				water= true;
				Math3D.VectorCopy(start, water_start);
				content_mask &= ~Defines.MASK_WATER;
			}
	
			tr= GameBase.gi.trace(start, null, null, end, self, content_mask);
	
			// see if we hit water
			if ((tr.contents & Defines.MASK_WATER) != 0) {
				int color;
	
				water= true;
				Math3D.VectorCopy(tr.endpos, water_start);
	
				if (0 == Math3D.VectorCompare(start, tr.endpos)) {
					if ((tr.contents & Defines.CONTENTS_WATER) != 0) {
						if (Lib.strcmp(tr.surface.name, "*brwater") == 0)
							color= Defines.SPLASH_BROWN_WATER;
						else
							color= Defines.SPLASH_BLUE_WATER;
					} else if ((tr.contents & Defines.CONTENTS_SLIME) != 0)
						color= Defines.SPLASH_SLIME;
					else if ((tr.contents & Defines.CONTENTS_LAVA) != 0)
						color= Defines.SPLASH_LAVA;
					else
						color= Defines.SPLASH_UNKNOWN;
	
					if (color != Defines.SPLASH_UNKNOWN) {
						GameBase.gi.WriteByte(Defines.svc_temp_entity);
						GameBase.gi.WriteByte(Defines.TE_SPLASH);
						GameBase.gi.WriteByte(8);
						GameBase.gi.WritePosition(tr.endpos);
						GameBase.gi.WriteDir(tr.plane.normal);
						GameBase.gi.WriteByte(color);
						GameBase.gi.multicast(tr.endpos, Defines.MULTICAST_PVS);
					}
	
					// change bullet's course when it enters water
					Math3D.VectorSubtract(end, start, dir);
					Math3D.vectoangles(dir, dir);
					Math3D.AngleVectors(dir, forward, right, up);
					r= Lib.crandom() * hspread * 2;
					u= Lib.crandom() * vspread * 2;
					Math3D.VectorMA(water_start, 8192, forward, end);
					Math3D.VectorMA(end, r, right, end);
					Math3D.VectorMA(end, u, up, end);
				}
	
				// re-trace ignoring water this time
				tr= GameBase.gi.trace(water_start, null, null, end, self, Defines.MASK_SHOT);
			}
		}
	
		// send gun puff / flash
		if (!((tr.surface != null) && 0 != (tr.surface.flags & Defines.SURF_SKY))) {
			if (tr.fraction < 1.0) {
				if (tr.ent.takedamage != 0) {
					GameUtil.T_Damage(
						tr.ent,
						self,
						self,
						aimdir,
						tr.endpos,
						tr.plane.normal,
						damage,
						kick,
						Defines.DAMAGE_BULLET,
						mod);
				} else {
					if (!"sky".equals(tr.surface.name)) {
						GameBase.gi.WriteByte(Defines.svc_temp_entity);
						GameBase.gi.WriteByte(te_impact);
						GameBase.gi.WritePosition(tr.endpos);
						GameBase.gi.WriteDir(tr.plane.normal);
						GameBase.gi.multicast(tr.endpos, Defines.MULTICAST_PVS);
	
						if (self.client != null)
							GameWeapon.PlayerNoise(self, tr.endpos, Defines.PNOISE_IMPACT);
					}
				}
			}
		}
	
		// if went through water, determine where the end and make a bubble trail
		if (water) {
			float[] pos= { 0, 0, 0 };
	
			Math3D.VectorSubtract(tr.endpos, water_start, dir);
			Math3D.VectorNormalize(dir);
			Math3D.VectorMA(tr.endpos, -2, dir, pos);
			if ((Game.gi.pointcontents.pointcontents(pos) & Defines.MASK_WATER) != 0)
				Math3D.VectorCopy(pos, tr.endpos);
			else
				tr= GameBase.gi.trace(pos, null, null, water_start, tr.ent, Defines.MASK_WATER);
	
			Math3D.VectorAdd(water_start, tr.endpos, pos);
			Math3D.VectorScale(pos, 0.5f, pos);
	
			GameBase.gi.WriteByte(Defines.svc_temp_entity);
			GameBase.gi.WriteByte(Defines.TE_BUBBLETRAIL);
			GameBase.gi.WritePosition(water_start);
			GameBase.gi.WritePosition(tr.endpos);
			GameBase.gi.multicast(pos, Defines.MULTICAST_PVS);
		}
	}
	/*
	=================
	fire_bullet
	
	Fires a single round.  Used for machinegun and chaingun.  Would be fine for
	pistols, rifles, etc....
	=================
	*/
	public static  void fire_bullet(
		edict_t self,
		float[] start,
		float[] aimdir,
		int damage,
		int kick,
		int hspread,
		int vspread,
		int mod) {
		fire_lead(self, start, aimdir, damage, kick, Defines.TE_GUNSHOT, hspread, vspread, mod);
	}
	/*
	=================
	fire_shotgun
	
	Shoots shotgun pellets.  Used by shotgun and super shotgun.
	=================
	*/
	public static  void fire_shotgun(
		edict_t self,
		float[] start,
		float[] aimdir,
		int damage,
		int kick,
		int hspread,
		int vspread,
		int count,
		int mod) {
		int i;
	
		for (i= 0; i < count; i++)
			fire_lead(self, start, aimdir, damage, kick, Defines.TE_SHOTGUN, hspread, vspread, mod);
	}
	public static  void fire_blaster(
		edict_t self,
		float[] start,
		float[] dir,
		int damage,
		int speed,
		int effect,
		boolean hyper) {
		edict_t bolt;
		trace_t tr;
	
		Math3D.VectorNormalize(dir);
	
		bolt= GameUtil.G_Spawn();
		bolt.svflags= Defines.SVF_DEADMONSTER;
		// yes, I know it looks weird that projectiles are deadmonsters
		// what this means is that when prediction is used against the object
		// (blaster/hyperblaster shots), the player won't be solid clipped against
		// the object.  Right now trying to run into a firing hyperblaster
		// is very jerky since you are predicted 'against' the shots.
		Math3D.VectorCopy(start, bolt.s.origin);
		Math3D.VectorCopy(start, bolt.s.old_origin);
		Math3D.vectoangles(dir, bolt.s.angles);
		Math3D.VectorScale(dir, speed, bolt.velocity);
		bolt.movetype= Defines.MOVETYPE_FLYMISSILE;
		bolt.clipmask= Defines.MASK_SHOT;
		bolt.solid= Defines.SOLID_BBOX;
		bolt.s.effects |= effect;
		Math3D.VectorClear(bolt.mins);
		Math3D.VectorClear(bolt.maxs);
		bolt.s.modelindex= GameBase.gi.modelindex("models/objects/laser/tris.md2");
		bolt.s.sound= GameBase.gi.soundindex("misc/lasfly.wav");
		bolt.owner= self;
		bolt.touch= GameWeapon.blaster_touch;
		bolt.nextthink= GameBase.level.time + 2;
		bolt.think= GameUtil.G_FreeEdictA;
		bolt.dmg= damage;
		bolt.classname= "bolt";
		if (hyper)
			bolt.spawnflags= 1;
		GameBase.gi.linkentity(bolt);
	
		if (self.client != null)
			GameWeapon.check_dodge(self, bolt.s.origin, dir, speed);
	
		tr= GameBase.gi.trace(self.s.origin, null, null, bolt.s.origin, bolt, Defines.MASK_SHOT);
		if (tr.fraction < 1.0) {
			Math3D.VectorMA(bolt.s.origin, -10, dir, bolt.s.origin);
			bolt.touch.touch(bolt, tr.ent, null, null);
		}
	}
	/*
	=================
	fire_grenade
	=================
	*/
	
	public static  void fire_grenade(
		edict_t self,
		float[] start,
		float[] aimdir,
		int damage,
		int speed,
		float timer,
		float damage_radius) {
		edict_t grenade;
		float[] dir= { 0, 0, 0 };
		float[] forward= { 0, 0, 0 }, right= { 0, 0, 0 }, up= { 0, 0, 0 };
	
		Math3D.vectoangles(aimdir, dir);
		Math3D.AngleVectors(dir, forward, right, up);
	
		grenade= GameUtil.G_Spawn();
		Math3D.VectorCopy(start, grenade.s.origin);
		Math3D.VectorScale(aimdir, speed, grenade.velocity);
		Math3D.VectorMA(grenade.velocity, 200f + Lib.crandom() * 10.0f, up, grenade.velocity);
		Math3D.VectorMA(grenade.velocity, Lib.crandom() * 10.0f, right, grenade.velocity);
		Math3D.VectorSet(grenade.avelocity, 300, 300, 300);
		grenade.movetype= Defines.MOVETYPE_BOUNCE;
		grenade.clipmask= Defines.MASK_SHOT;
		grenade.solid= Defines.SOLID_BBOX;
		grenade.s.effects |= Defines.EF_GRENADE;
		Math3D.VectorClear(grenade.mins);
		Math3D.VectorClear(grenade.maxs);
		grenade.s.modelindex= GameBase.gi.modelindex("models/objects/grenade/tris.md2");
		grenade.owner= self;
		grenade.touch= GameWeapon.Grenade_Touch;
		grenade.nextthink= GameBase.level.time + timer;
		grenade.think= GameWeapon.Grenade_Explode;
		grenade.dmg= damage;
		grenade.dmg_radius= damage_radius;
		grenade.classname= "grenade";
	
		GameBase.gi.linkentity(grenade);
	}
	public static  void fire_grenade2(
		edict_t self,
		float[] start,
		float[] aimdir,
		int damage,
		int speed,
		float timer,
		float damage_radius,
		boolean held) {
		edict_t grenade;
		float[] dir= { 0, 0, 0 };
		float[] forward= { 0, 0, 0 }, right= { 0, 0, 0 }, up= { 0, 0, 0 };
	
		Math3D.vectoangles(aimdir, dir);
		Math3D.AngleVectors(dir, forward, right, up);
	
		grenade= GameUtil.G_Spawn();
		Math3D.VectorCopy(start, grenade.s.origin);
		Math3D.VectorScale(aimdir, speed, grenade.velocity);
		Math3D.VectorMA(grenade.velocity, 200f + Lib.crandom() * 10.0f, up, grenade.velocity);
		Math3D.VectorMA(grenade.velocity, Lib.crandom() * 10.0f, right, grenade.velocity);
		Math3D.VectorSet(grenade.avelocity, 300f, 300f, 300f);
		grenade.movetype= Defines.MOVETYPE_BOUNCE;
		grenade.clipmask= Defines.MASK_SHOT;
		grenade.solid= Defines.SOLID_BBOX;
		grenade.s.effects |= Defines.EF_GRENADE;
		Math3D.VectorClear(grenade.mins);
		Math3D.VectorClear(grenade.maxs);
		grenade.s.modelindex= GameBase.gi.modelindex("models/objects/grenade2/tris.md2");
		grenade.owner= self;
		grenade.touch= GameWeapon.Grenade_Touch;
		grenade.nextthink= GameBase.level.time + timer;
		grenade.think= GameWeapon.Grenade_Explode;
		grenade.dmg= damage;
		grenade.dmg_radius= damage_radius;
		grenade.classname= "hgrenade";
		if (held)
			grenade.spawnflags= 3;
		else
			grenade.spawnflags= 1;
		grenade.s.sound= GameBase.gi.soundindex("weapons/hgrenc1b.wav");
	
		if (timer <= 0.0)
			GameWeapon.Grenade_Explode.think(grenade);
		else {
			GameBase.gi.sound(self, Defines.CHAN_WEAPON, GameBase.gi.soundindex("weapons/hgrent1a.wav"), 1, Defines.ATTN_NORM, 0);
			GameBase.gi.linkentity(grenade);
		}
	}
	public static  void fire_rocket(
		edict_t self,
		float[] start,
		float[] dir,
		int damage,
		int speed,
		float damage_radius,
		int radius_damage) {
		edict_t rocket;
	
		rocket= GameUtil.G_Spawn();
		Math3D.VectorCopy(start, rocket.s.origin);
		Math3D.VectorCopy(dir, rocket.movedir);
		Math3D.vectoangles(dir, rocket.s.angles);
		Math3D.VectorScale(dir, speed, rocket.velocity);
		rocket.movetype= Defines.MOVETYPE_FLYMISSILE;
		rocket.clipmask= Defines.MASK_SHOT;
		rocket.solid= Defines.SOLID_BBOX;
		rocket.s.effects |= Defines.EF_ROCKET;
		Math3D.VectorClear(rocket.mins);
		Math3D.VectorClear(rocket.maxs);
		rocket.s.modelindex= GameBase.gi.modelindex("models/objects/rocket/tris.md2");
		rocket.owner= self;
		rocket.touch= GameWeapon.rocket_touch;
		rocket.nextthink= GameBase.level.time + 8000 / speed;
		rocket.think= GameUtil.G_FreeEdictA;
		rocket.dmg= damage;
		rocket.radius_dmg= radius_damage;
		rocket.dmg_radius= damage_radius;
		rocket.s.sound= GameBase.gi.soundindex("weapons/rockfly.wav");
		rocket.classname= "rocket";
	
		if (self.client != null)
			GameWeapon.check_dodge(self, rocket.s.origin, dir, speed);
	
		GameBase.gi.linkentity(rocket);
	}
	/*
	=================
	fire_rail
	=================
	*/
	public static  void fire_rail(edict_t self, float[] start, float[] aimdir, int damage, int kick) {
		float[] from= { 0, 0, 0 };
		float[] end= { 0, 0, 0 };
		trace_t tr= null;
		edict_t ignore;
		int mask;
		boolean water;
	
		Math3D.VectorMA(start, 8192f, aimdir, end);
		Math3D.VectorCopy(start, from);
		ignore= self;
		water= false;
		mask= Defines.MASK_SHOT | Defines.CONTENTS_SLIME | Defines.CONTENTS_LAVA;
		while (ignore != null) {
			tr= GameBase.gi.trace(from, null, null, end, ignore, mask);
	
			if ((tr.contents & (Defines.CONTENTS_SLIME | Defines.CONTENTS_LAVA)) != 0) {
				mask &= ~(Defines.CONTENTS_SLIME | Defines.CONTENTS_LAVA);
				water= true;
			} else {
				//ZOID--added so rail goes through SOLID_BBOX entities (gibs, etc)
				if ((tr.ent.svflags & Defines.SVF_MONSTER) != 0
					|| (tr.ent.client != null)
					|| (tr.ent.solid == Defines.SOLID_BBOX))
					ignore= tr.ent;
				else
					ignore= null;
	
				if ((tr.ent != self) && (tr.ent.takedamage != 0))
					GameUtil.T_Damage(
						tr.ent,
						self,
						self,
						aimdir,
						tr.endpos,
						tr.plane.normal,
						damage,
						kick,
						0,
						Defines.MOD_RAILGUN);
			}
	
			Math3D.VectorCopy(tr.endpos, from);
		}
	
		// send gun puff / flash
		GameBase.gi.WriteByte(Defines.svc_temp_entity);
		GameBase.gi.WriteByte(Defines.TE_RAILTRAIL);
		GameBase.gi.WritePosition(start);
		GameBase.gi.WritePosition(tr.endpos);
		GameBase.gi.multicast(self.s.origin, Defines.MULTICAST_PHS);
		//		gi.multicast (start, MULTICAST_PHS);
		if (water) {
			GameBase.gi.WriteByte(Defines.svc_temp_entity);
			GameBase.gi.WriteByte(Defines.TE_RAILTRAIL);
			GameBase.gi.WritePosition(start);
			GameBase.gi.WritePosition(tr.endpos);
			GameBase.gi.multicast(tr.endpos, Defines.MULTICAST_PHS);
		}
	
		if (self.client != null)
			GameWeapon.PlayerNoise(self, tr.endpos, Defines.PNOISE_IMPACT);
	}
	public static  void fire_bfg(
		edict_t self,
		float[] start,
		float[] dir,
		int damage,
		int speed,
		float damage_radius) {
		edict_t bfg;
	
		bfg= GameUtil.G_Spawn();
		Math3D.VectorCopy(start, bfg.s.origin);
		Math3D.VectorCopy(dir, bfg.movedir);
		Math3D.vectoangles(dir, bfg.s.angles);
		Math3D.VectorScale(dir, speed, bfg.velocity);
		bfg.movetype= Defines.MOVETYPE_FLYMISSILE;
		bfg.clipmask= Defines.MASK_SHOT;
		bfg.solid= Defines.SOLID_BBOX;
		bfg.s.effects |= Defines.EF_BFG | Defines.EF_ANIM_ALLFAST;
		Math3D.VectorClear(bfg.mins);
		Math3D.VectorClear(bfg.maxs);
		bfg.s.modelindex= GameBase.gi.modelindex("sprites/s_bfg1.sp2");
		bfg.owner= self;
		bfg.touch= GameWeapon.bfg_touch;
		bfg.nextthink= GameBase.level.time + 8000 / speed;
		bfg.think= GameUtil.G_FreeEdictA;
		bfg.radius_dmg= damage;
		bfg.dmg_radius= damage_radius;
		bfg.classname= "bfg blast";
		bfg.s.sound= GameBase.gi.soundindex("weapons/bfg__l1a.wav");
	
		bfg.think= GameWeapon.bfg_think;
		bfg.nextthink= GameBase.level.time + Defines.FRAMETIME;
		bfg.teammaster= bfg;
		bfg.teamchain= null;
	
		if (self.client != null)
			GameWeapon.check_dodge(self, bfg.s.origin, dir, speed);
	
		GameBase.gi.linkentity(bfg);
	}
}