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,
10 /* modelname */ "fireball",
11 /* simplemdl */ "foobar",
12 /* crosshair */ "gfx/crosshairfireball",
13 /* wepimg */ "weaponfireball",
14 /* refname */ "fireball",
15 /* wepname */ _("Fireball")
18 #define FIREBALL_SETTINGS(w_cvar,w_prop) FIREBALL_SETTINGS_LIST(w_cvar, w_prop, FIREBALL, fireball)
19 #define FIREBALL_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
20 w_cvar(id, sn, BOTH, animtime) \
21 w_cvar(id, sn, BOTH, refire) \
22 w_cvar(id, sn, BOTH, damage) \
23 w_cvar(id, sn, BOTH, damageforcescale) \
24 w_cvar(id, sn, BOTH, speed) \
25 w_cvar(id, sn, BOTH, spread) \
26 w_cvar(id, sn, BOTH, lifetime) \
27 w_cvar(id, sn, BOTH, laserburntime) \
28 w_cvar(id, sn, BOTH, laserdamage) \
29 w_cvar(id, sn, BOTH, laseredgedamage) \
30 w_cvar(id, sn, BOTH, laserradius) \
31 w_cvar(id, sn, PRI, edgedamage) \
32 w_cvar(id, sn, PRI, force) \
33 w_cvar(id, sn, PRI, radius) \
34 w_cvar(id, sn, PRI, health) \
35 w_cvar(id, sn, PRI, refire2) \
36 w_cvar(id, sn, PRI, bfgdamage) \
37 w_cvar(id, sn, PRI, bfgforce) \
38 w_cvar(id, sn, PRI, bfgradius) \
39 w_cvar(id, sn, SEC, damagetime) \
40 w_cvar(id, sn, SEC, speed_up) \
41 w_cvar(id, sn, SEC, speed_z) \
42 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
43 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
44 w_prop(id, sn, string, weaponreplace, weaponreplace) \
45 w_prop(id, sn, float, weaponstart, weaponstart) \
46 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
49 FIREBALL_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
50 .float bot_primary_fireballmooth; // whatever a mooth is
51 .vector fireball_impactvec;
52 .float fireball_primarytime;
56 void spawnfunc_weapon_fireball() { weapon_defaultspawnfunc(WEP_FIREBALL); }
58 void W_Fireball_Explode (void)
66 self.event_damage = func_null;
67 self.takedamage = DAMAGE_NO;
70 d = (self.realowner.health + self.realowner.armorvalue);
71 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);
72 if(self.realowner.health + self.realowner.armorvalue >= d)
75 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);
78 // NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
79 for(e = findradius(self.origin, WEP_CVAR_PRI(fireball, bfgradius)); e; e = e.chain)
80 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
82 // can we see fireball?
83 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
84 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
86 // can we see player who shot fireball?
87 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
88 if(trace_ent != self.realowner)
89 if(/* trace_startsolid || */ trace_fraction != 1)
91 dist = vlen(self.origin - e.origin - e.view_ofs);
92 points = (1 - sqrt(dist / WEP_CVAR_PRI(fireball, bfgradius)));
95 dir = normalize(e.origin + e.view_ofs - self.origin);
97 if(accuracy_isgooddamage(self.realowner, e))
98 accuracy_add(self.realowner, WEP_FIREBALL, 0, WEP_CVAR_PRI(fireball, bfgdamage) * points);
100 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);
101 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
108 void W_Fireball_TouchExplode (void)
111 W_Fireball_Explode ();
114 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
123 RandomSelection_Init();
124 for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain)
125 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
128 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
129 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
130 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
131 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
134 e.fireball_impactvec = p;
135 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
138 if(RandomSelection_chosen_ent)
140 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
141 d = damage + (edgedamage - damage) * (d / dist);
142 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
143 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
144 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
148 void W_Fireball_Think()
150 if(time > self.pushltime)
153 self.projectiledeathtype |= HITTYPE_SPLASH;
154 W_Fireball_Explode();
158 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));
160 self.nextthink = time + 0.1;
163 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
168 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
169 return; // g_projectiles_damage says to halt
171 self.health = self.health - damage;
172 if (self.health <= 0)
175 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
179 void W_Fireball_Attack1()
183 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));
185 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
188 proj.classname = "plasma_prim";
189 proj.owner = proj.realowner = self;
190 proj.bot_dodge = TRUE;
191 proj.bot_dodgerating = WEP_CVAR_PRI(fireball, damage);
192 proj.pushltime = time + WEP_CVAR_PRI(fireball, lifetime);
193 proj.use = W_Fireball_Explode;
194 proj.think = W_Fireball_Think;
195 proj.nextthink = time;
196 proj.health = WEP_CVAR_PRI(fireball, health);
197 proj.team = self.team;
198 proj.event_damage = W_Fireball_Damage;
199 proj.takedamage = DAMAGE_YES;
200 proj.damageforcescale = WEP_CVAR_PRI(fireball, damageforcescale);
201 PROJECTILE_MAKETRIGGER(proj);
202 proj.projectiledeathtype = WEP_FIREBALL;
203 setorigin(proj, w_shotorg);
205 proj.movetype = MOVETYPE_FLY;
206 W_SetupProjVelocity_PRI(proj, fireball);
207 proj.angles = vectoangles(proj.velocity);
208 proj.touch = W_Fireball_TouchExplode;
209 setsize(proj, '-16 -16 -16', '16 16 16');
210 proj.flags = FL_PROJECTILE;
211 proj.missile_flags = MIF_SPLASH | MIF_PROXY;
213 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
215 other = proj; MUTATOR_CALLHOOK(EditProjectile);
218 void W_Fireball_AttackEffect(float i, vector f_diff)
220 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0, 0);
221 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
222 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
225 void W_Fireball_Attack1_Frame4()
227 W_Fireball_Attack1();
228 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready);
231 void W_Fireball_Attack1_Frame3()
233 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
234 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4);
237 void W_Fireball_Attack1_Frame2()
239 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
240 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3);
243 void W_Fireball_Attack1_Frame1()
245 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
246 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2);
249 void W_Fireball_Attack1_Frame0()
251 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
252 sound (self, CH_WEAPON_SINGLE, "weapons/fireball_prefire2.wav", VOL_BASE, ATTEN_NORM);
253 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1);
256 void W_Fireball_Firemine_Think()
258 if(time > self.pushltime)
264 // make it "hot" once it leaves its owner
267 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > WEP_CVAR_SEC(fireball, laserradius))
277 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));
279 self.nextthink = time + 0.1;
282 void W_Fireball_Firemine_Touch (void)
285 if (other.takedamage == DAMAGE_AIM)
286 if(Fire_AddDamage(other, self.realowner, WEP_CVAR_SEC(fireball, damage), WEP_CVAR_SEC(fireball, damagetime), self.projectiledeathtype) >= 0)
291 self.projectiledeathtype |= HITTYPE_BOUNCE;
294 void W_Fireball_Attack2()
300 c = mod(self.bulletcounter, 4);
304 f_diff = '-1.25 -3.75 0';
307 f_diff = '+1.25 -3.75 0';
310 f_diff = '-1.25 +3.75 0';
314 f_diff = '+1.25 +3.75 0';
317 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(fireball, damage));
318 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
319 w_shotorg = trace_endpos;
321 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
324 proj.owner = proj.realowner = self;
325 proj.classname = "grenade";
326 proj.bot_dodge = TRUE;
327 proj.bot_dodgerating = WEP_CVAR_SEC(fireball, damage);
328 proj.movetype = MOVETYPE_BOUNCE;
329 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
330 proj.touch = W_Fireball_Firemine_Touch;
331 PROJECTILE_MAKETRIGGER(proj);
332 setsize(proj, '-4 -4 -4', '4 4 4');
333 setorigin(proj, w_shotorg);
334 proj.think = W_Fireball_Firemine_Think;
335 proj.nextthink = time;
336 proj.damageforcescale = WEP_CVAR_SEC(fireball, damageforcescale);
337 proj.pushltime = time + WEP_CVAR_SEC(fireball, lifetime);
338 W_SetupProjVelocity_UP_SEC(proj, fireball);
340 proj.angles = vectoangles(proj.velocity);
341 proj.flags = FL_PROJECTILE;
342 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
344 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
346 other = proj; MUTATOR_CALLHOOK(EditProjectile);
349 float W_Fireball(float req)
355 self.BUTTON_ATCK = FALSE;
356 self.BUTTON_ATCK2 = FALSE;
357 if (self.bot_primary_fireballmooth == 0)
359 if(bot_aim(WEP_CVAR_PRI(fireball, speed), 0, WEP_CVAR_PRI(fireball, lifetime), FALSE))
361 self.BUTTON_ATCK = TRUE;
362 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
367 if(bot_aim(WEP_CVAR_SEC(fireball, speed), WEP_CVAR_SEC(fireball, speed_up), WEP_CVAR_SEC(fireball, lifetime), TRUE))
369 self.BUTTON_ATCK2 = TRUE;
370 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
378 if (self.BUTTON_ATCK)
380 if (time >= self.fireball_primarytime)
381 if (weapon_prepareattack(0, WEP_CVAR_PRI(fireball, refire)))
383 W_Fireball_Attack1_Frame0();
384 self.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor();
387 else if (self.BUTTON_ATCK2)
389 if (weapon_prepareattack(1, WEP_CVAR_SEC(fireball, refire)))
391 W_Fireball_Attack2();
392 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready);
400 precache_model ("models/weapons/g_fireball.md3");
401 precache_model ("models/weapons/v_fireball.md3");
402 precache_model ("models/weapons/h_fireball.iqm");
403 precache_model ("models/sphere/sphere.md3");
404 precache_sound ("weapons/fireball_fire.wav");
405 precache_sound ("weapons/fireball_fire2.wav");
406 precache_sound ("weapons/fireball_prefire2.wav");
407 FIREBALL_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
412 self.ammo_field = ammo_none;
418 return TRUE; // fireball has infinite ammo
422 FIREBALL_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
427 self.fireball_primarytime = time;
430 case WR_SUICIDEMESSAGE:
432 if(w_deathtype & HITTYPE_SECONDARY)
433 return WEAPON_FIREBALL_SUICIDE_FIREMINE;
435 return WEAPON_FIREBALL_SUICIDE_BLAST;
439 if(w_deathtype & HITTYPE_SECONDARY)
440 return WEAPON_FIREBALL_MURDER_FIREMINE;
442 return WEAPON_FIREBALL_MURDER_BLAST;
449 float W_Fireball(float req)
453 case WR_IMPACTEFFECT:
456 if(w_deathtype & HITTYPE_SECONDARY)
458 // firemine goes out silently
462 org2 = w_org + w_backoff * 16;
463 pointparticles(particleeffectnum("fireball_explode"), org2, '0 0 0', 1);
465 sound(self, CH_SHOTS, "weapons/fireball_impact2.wav", VOL_BASE, ATTEN_NORM * 0.25); // long range boom
472 precache_sound("weapons/fireball_impact2.wav");
477 // no weapon specific image for this weapon