3 /* WEP_##id */ FIREBALL,
4 /* function */ w_fireball,
5 /* ammotype */ ammo_none,
7 /* flags */ WEP_FLAG_SUPERWEAPON | WEP_TYPE_SPLASH,
8 /* rating */ BOT_PICKUP_RATING_MID,
9 /* model */ "fireball",
10 /* netname */ "fireball",
11 /* fullname */ _("Fireball")
14 #define FIREBALL_SETTINGS(w_cvar,w_prop) FIREBALL_SETTINGS_LIST(w_cvar, w_prop, FIREBALL, fireball)
15 #define FIREBALL_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
16 w_cvar(id, sn, BOTH, animtime) \
17 w_cvar(id, sn, BOTH, refire) \
18 w_cvar(id, sn, BOTH, damage) \
19 w_cvar(id, sn, BOTH, damageforcescale) \
20 w_cvar(id, sn, BOTH, speed) \
21 w_cvar(id, sn, BOTH, spread) \
22 w_cvar(id, sn, BOTH, lifetime) \
23 w_cvar(id, sn, BOTH, laserburntime) \
24 w_cvar(id, sn, BOTH, laserdamage) \
25 w_cvar(id, sn, BOTH, laseredgedamage) \
26 w_cvar(id, sn, BOTH, laserradius) \
27 w_cvar(id, sn, PRI, edgedamage) \
28 w_cvar(id, sn, PRI, force) \
29 w_cvar(id, sn, PRI, radius) \
30 w_cvar(id, sn, PRI, health) \
31 w_cvar(id, sn, PRI, refire2) \
32 w_cvar(id, sn, PRI, bfgdamage) \
33 w_cvar(id, sn, PRI, bfgforce) \
34 w_cvar(id, sn, PRI, bfgradius) \
35 w_cvar(id, sn, SEC, damagetime) \
36 w_cvar(id, sn, SEC, speed_up) \
37 w_cvar(id, sn, SEC, speed_z) \
38 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
39 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
40 w_prop(id, sn, string, weaponreplace, weaponreplace) \
41 w_prop(id, sn, float, weaponstart, weaponstart) \
42 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
45 FIREBALL_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
46 .float bot_primary_fireballmooth; // whatever a mooth is
47 .vector fireball_impactvec;
48 .float fireball_primarytime;
52 void spawnfunc_weapon_fireball() { weapon_defaultspawnfunc(WEP_FIREBALL); }
54 void W_Fireball_Explode (void)
62 self.event_damage = func_null;
63 self.takedamage = DAMAGE_NO;
66 d = (self.realowner.health + self.realowner.armorvalue);
67 RadiusDamage (self, self.realowner, WEP_CVAR_PRI(fireball, damage), WEP_CVAR_PRI(fireball, edgedamage), WEP_CVAR_PRI(fireball, radius), world, world, WEP_CVAR_PRI(fireball, force), self.projectiledeathtype, other);
68 if(self.realowner.health + self.realowner.armorvalue >= d)
71 modeleffect_spawn("models/sphere/sphere.md3", 0, 0, self.origin, '0 0 0', '0 0 0', '0 0 0', 0, WEP_CVAR_PRI(fireball, bfgradius), 0.2, 0.05, 0.25);
74 // NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
75 for(e = findradius(self.origin, WEP_CVAR_PRI(fireball, bfgradius)); e; e = e.chain)
76 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
78 // can we see fireball?
79 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
80 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
82 // can we see player who shot fireball?
83 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
84 if(trace_ent != self.realowner)
85 if(/* trace_startsolid || */ trace_fraction != 1)
87 dist = vlen(self.origin - e.origin - e.view_ofs);
88 points = (1 - sqrt(dist / WEP_CVAR_PRI(fireball, bfgradius)));
91 dir = normalize(e.origin + e.view_ofs - self.origin);
93 if(accuracy_isgooddamage(self.realowner, e))
94 accuracy_add(self.realowner, WEP_FIREBALL, 0, WEP_CVAR_PRI(fireball, bfgdamage) * points);
96 Damage(e, self, self.realowner, WEP_CVAR_PRI(fireball, bfgdamage) * points, self.projectiledeathtype | HITTYPE_BOUNCE | HITTYPE_SPLASH, e.origin + e.view_ofs, WEP_CVAR_PRI(fireball, bfgforce) * dir);
97 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
104 void W_Fireball_TouchExplode (void)
107 W_Fireball_Explode ();
110 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
119 RandomSelection_Init();
120 for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain)
121 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
124 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
125 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
126 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
127 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
130 e.fireball_impactvec = p;
131 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
134 if(RandomSelection_chosen_ent)
136 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
137 d = damage + (edgedamage - damage) * (d / dist);
138 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
139 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
140 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
144 void W_Fireball_Think()
146 if(time > self.pushltime)
149 self.projectiledeathtype |= HITTYPE_SPLASH;
150 W_Fireball_Explode();
154 W_Fireball_LaserPlay(0.1, WEP_CVAR_PRI(fireball, laserradius), WEP_CVAR_PRI(fireball, laserdamage), WEP_CVAR_PRI(fireball, laseredgedamage), WEP_CVAR_PRI(fireball, laserburntime));
156 self.nextthink = time + 0.1;
159 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
164 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
165 return; // g_projectiles_damage says to halt
167 self.health = self.health - damage;
168 if (self.health <= 0)
171 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
175 void W_Fireball_Attack1()
179 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 2, "weapons/fireball_fire2.wav", CH_WEAPON_A, WEP_CVAR_PRI(fireball, damage) + WEP_CVAR_PRI(fireball, bfgdamage));
181 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
184 proj.classname = "plasma_prim";
185 proj.owner = proj.realowner = self;
186 proj.bot_dodge = TRUE;
187 proj.bot_dodgerating = WEP_CVAR_PRI(fireball, damage);
188 proj.pushltime = time + WEP_CVAR_PRI(fireball, lifetime);
189 proj.use = W_Fireball_Explode;
190 proj.think = W_Fireball_Think;
191 proj.nextthink = time;
192 proj.health = WEP_CVAR_PRI(fireball, health);
193 proj.team = self.team;
194 proj.event_damage = W_Fireball_Damage;
195 proj.takedamage = DAMAGE_YES;
196 proj.damageforcescale = WEP_CVAR_PRI(fireball, damageforcescale);
197 PROJECTILE_MAKETRIGGER(proj);
198 proj.projectiledeathtype = WEP_FIREBALL;
199 setorigin(proj, w_shotorg);
201 proj.movetype = MOVETYPE_FLY;
202 WEP_SETUPPROJVELOCITY_PRI(proj, fireball);
203 proj.angles = vectoangles(proj.velocity);
204 proj.touch = W_Fireball_TouchExplode;
205 setsize(proj, '-16 -16 -16', '16 16 16');
206 proj.flags = FL_PROJECTILE;
207 proj.missile_flags = MIF_SPLASH | MIF_PROXY;
209 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
211 other = proj; MUTATOR_CALLHOOK(EditProjectile);
214 void W_Fireball_AttackEffect(float i, vector f_diff)
216 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0, 0);
217 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
218 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
221 void W_Fireball_Attack1_Frame4()
223 W_Fireball_Attack1();
224 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready);
227 void W_Fireball_Attack1_Frame3()
229 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
230 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4);
233 void W_Fireball_Attack1_Frame2()
235 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
236 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3);
239 void W_Fireball_Attack1_Frame1()
241 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
242 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2);
245 void W_Fireball_Attack1_Frame0()
247 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
248 sound (self, CH_WEAPON_SINGLE, "weapons/fireball_prefire2.wav", VOL_BASE, ATTEN_NORM);
249 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1);
252 void W_Firemine_Think()
254 if(time > self.pushltime)
260 // make it "hot" once it leaves its owner
263 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > WEP_CVAR_SEC(fireball, laserradius))
273 W_Fireball_LaserPlay(0.1, WEP_CVAR_SEC(fireball, laserradius), WEP_CVAR_SEC(fireball, laserdamage), WEP_CVAR_SEC(fireball, laseredgedamage), WEP_CVAR_SEC(fireball, laserburntime));
275 self.nextthink = time + 0.1;
278 void W_Firemine_Touch (void)
281 if (other.takedamage == DAMAGE_AIM)
282 if(Fire_AddDamage(other, self.realowner, WEP_CVAR_SEC(fireball, damage), WEP_CVAR_SEC(fireball, damagetime), self.projectiledeathtype) >= 0)
287 self.projectiledeathtype |= HITTYPE_BOUNCE;
290 void W_Fireball_Attack2()
296 c = mod(self.bulletcounter, 4);
300 f_diff = '-1.25 -3.75 0';
303 f_diff = '+1.25 -3.75 0';
306 f_diff = '-1.25 +3.75 0';
310 f_diff = '+1.25 +3.75 0';
313 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(fireball, damage));
314 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
315 w_shotorg = trace_endpos;
317 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
320 proj.owner = proj.realowner = self;
321 proj.classname = "grenade";
322 proj.bot_dodge = TRUE;
323 proj.bot_dodgerating = WEP_CVAR_SEC(fireball, damage);
324 proj.movetype = MOVETYPE_BOUNCE;
325 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
326 proj.touch = W_Firemine_Touch;
327 PROJECTILE_MAKETRIGGER(proj);
328 setsize(proj, '-4 -4 -4', '4 4 4');
329 setorigin(proj, w_shotorg);
330 proj.think = W_Firemine_Think;
331 proj.nextthink = time;
332 proj.damageforcescale = WEP_CVAR_SEC(fireball, damageforcescale);
333 proj.pushltime = time + WEP_CVAR_SEC(fireball, lifetime);
334 WEP_SETUPPROJVELOCITY_UP_SEC(proj, fireball);
336 proj.angles = vectoangles(proj.velocity);
337 proj.flags = FL_PROJECTILE;
338 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
340 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
342 other = proj; MUTATOR_CALLHOOK(EditProjectile);
345 float w_fireball(float req)
351 self.BUTTON_ATCK = FALSE;
352 self.BUTTON_ATCK2 = FALSE;
353 if (self.bot_primary_fireballmooth == 0)
355 if(bot_aim(WEP_CVAR_PRI(fireball, speed), 0, WEP_CVAR_PRI(fireball, lifetime), FALSE))
357 self.BUTTON_ATCK = TRUE;
358 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
363 if(bot_aim(WEP_CVAR_SEC(fireball, speed), WEP_CVAR_SEC(fireball, speed_up), WEP_CVAR_SEC(fireball, lifetime), TRUE))
365 self.BUTTON_ATCK2 = TRUE;
366 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
374 if (self.BUTTON_ATCK)
376 if (time >= self.fireball_primarytime)
377 if (weapon_prepareattack(0, WEP_CVAR_PRI(fireball, refire)))
379 W_Fireball_Attack1_Frame0();
380 self.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor();
383 else if (self.BUTTON_ATCK2)
385 if (weapon_prepareattack(1, WEP_CVAR_SEC(fireball, refire)))
387 W_Fireball_Attack2();
388 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready);
396 precache_model ("models/weapons/g_fireball.md3");
397 precache_model ("models/weapons/v_fireball.md3");
398 precache_model ("models/weapons/h_fireball.iqm");
399 precache_model ("models/sphere/sphere.md3");
400 precache_sound ("weapons/fireball_fire.wav");
401 precache_sound ("weapons/fireball_fire2.wav");
402 precache_sound ("weapons/fireball_prefire2.wav");
403 FIREBALL_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
408 self.current_ammo = ammo_none;
414 return TRUE; // fireball has infinite ammo
418 FIREBALL_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
423 self.fireball_primarytime = time;
426 case WR_SUICIDEMESSAGE:
428 if(w_deathtype & HITTYPE_SECONDARY)
429 return WEAPON_FIREBALL_SUICIDE_FIREMINE;
431 return WEAPON_FIREBALL_SUICIDE_BLAST;
435 if(w_deathtype & HITTYPE_SECONDARY)
436 return WEAPON_FIREBALL_MURDER_FIREMINE;
438 return WEAPON_FIREBALL_MURDER_BLAST;
445 float w_fireball(float req)
449 case WR_IMPACTEFFECT:
452 if(w_deathtype & HITTYPE_SECONDARY)
454 // firemine goes out silently
458 org2 = w_org + w_backoff * 16;
459 pointparticles(particleeffectnum("fireball_explode"), org2, '0 0 0', 1);
461 sound(self, CH_SHOTS, "weapons/fireball_impact2.wav", VOL_BASE, ATTEN_NORM * 0.25); // long range boom
468 precache_sound("weapons/fireball_impact2.wav");