3 /* WEP_##id */ FIREBALL,
4 /* function */ w_fireball,
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) \
15 w_cvar(WEP_FIREBALL, fireball, MO_BOTH, animtime) \
16 w_cvar(WEP_FIREBALL, fireball, MO_BOTH, refire) \
17 w_cvar(WEP_FIREBALL, fireball, MO_BOTH, damage) \
18 w_cvar(WEP_FIREBALL, fireball, MO_BOTH, damageforcescale) \
19 w_cvar(WEP_FIREBALL, fireball, MO_BOTH, speed) \
20 w_cvar(WEP_FIREBALL, fireball, MO_BOTH, spread) \
21 w_cvar(WEP_FIREBALL, fireball, MO_BOTH, lifetime) \
22 w_cvar(WEP_FIREBALL, fireball, MO_BOTH, laserburntime) \
23 w_cvar(WEP_FIREBALL, fireball, MO_BOTH, laserdamage) \
24 w_cvar(WEP_FIREBALL, fireball, MO_BOTH, laseredgedamage) \
25 w_cvar(WEP_FIREBALL, fireball, MO_BOTH, laserradius) \
26 w_cvar(WEP_FIREBALL, fireball, MO_PRI, edgedamage) \
27 w_cvar(WEP_FIREBALL, fireball, MO_PRI, force) \
28 w_cvar(WEP_FIREBALL, fireball, MO_PRI, radius) \
29 w_cvar(WEP_FIREBALL, fireball, MO_PRI, health) \
30 w_cvar(WEP_FIREBALL, fireball, MO_PRI, refire2) \
31 w_cvar(WEP_FIREBALL, fireball, MO_PRI, bfgdamage) \
32 w_cvar(WEP_FIREBALL, fireball, MO_PRI, bfgforce) \
33 w_cvar(WEP_FIREBALL, fireball, MO_PRI, bfgradius) \
34 w_cvar(WEP_FIREBALL, fireball, MO_SEC, damagetime) \
35 w_cvar(WEP_FIREBALL, fireball, MO_SEC, speed_up) \
36 w_cvar(WEP_FIREBALL, fireball, MO_SEC, speed_z) \
37 w_prop(WEP_FIREBALL, fireball, float, reloading_ammo, reload_ammo) \
38 w_prop(WEP_FIREBALL, fireball, float, reloading_time, reload_time) \
39 w_prop(WEP_FIREBALL, fireball, float, switchdelay_raise, switchdelay_raise) \
40 w_prop(WEP_FIREBALL, fireball, float, switchdelay_drop, switchdelay_drop) \
41 w_prop(WEP_FIREBALL, fireball, string, weaponreplace, weaponreplace) \
42 w_prop(WEP_FIREBALL, fireball, float, weaponstart, weaponstart) \
43 w_prop(WEP_FIREBALL, fireball, float, weaponstartoverride, weaponstartoverride)
46 FIREBALL_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
47 .float bot_primary_fireballmooth; // whatever a mooth is
48 .vector fireball_impactvec;
49 .float fireball_primarytime;
53 void spawnfunc_weapon_fireball() { weapon_defaultspawnfunc(WEP_FIREBALL); }
55 void W_Fireball_Explode (void)
63 self.event_damage = func_null;
64 self.takedamage = DAMAGE_NO;
67 d = (self.realowner.health + self.realowner.armorvalue);
68 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);
69 if(self.realowner.health + self.realowner.armorvalue >= d)
72 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);
75 // NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
76 for(e = findradius(self.origin, WEP_CVAR_PRI(fireball, bfgradius)); e; e = e.chain)
77 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
79 // can we see fireball?
80 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
81 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
83 // can we see player who shot fireball?
84 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
85 if(trace_ent != self.realowner)
86 if(/* trace_startsolid || */ trace_fraction != 1)
88 dist = vlen(self.origin - e.origin - e.view_ofs);
89 points = (1 - sqrt(dist / WEP_CVAR_PRI(fireball, bfgradius)));
92 dir = normalize(e.origin + e.view_ofs - self.origin);
94 if(accuracy_isgooddamage(self.realowner, e))
95 accuracy_add(self.realowner, WEP_FIREBALL, 0, WEP_CVAR_PRI(fireball, bfgdamage) * points);
97 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);
98 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
105 void W_Fireball_TouchExplode (void)
108 W_Fireball_Explode ();
111 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
120 RandomSelection_Init();
121 for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain)
122 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
125 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
126 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
127 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
128 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
131 e.fireball_impactvec = p;
132 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
135 if(RandomSelection_chosen_ent)
137 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
138 d = damage + (edgedamage - damage) * (d / dist);
139 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
140 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
141 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
145 void W_Fireball_Think()
147 if(time > self.pushltime)
150 self.projectiledeathtype |= HITTYPE_SPLASH;
151 W_Fireball_Explode();
155 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));
157 self.nextthink = time + 0.1;
160 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
165 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
166 return; // g_projectiles_damage says to halt
168 self.health = self.health - damage;
169 if (self.health <= 0)
172 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
176 void W_Fireball_Attack1()
180 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));
182 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
185 proj.classname = "plasma_prim";
186 proj.owner = proj.realowner = self;
187 proj.bot_dodge = TRUE;
188 proj.bot_dodgerating = WEP_CVAR_PRI(fireball, damage);
189 proj.pushltime = time + WEP_CVAR_PRI(fireball, lifetime);
190 proj.use = W_Fireball_Explode;
191 proj.think = W_Fireball_Think;
192 proj.nextthink = time;
193 proj.health = WEP_CVAR_PRI(fireball, health);
194 proj.team = self.team;
195 proj.event_damage = W_Fireball_Damage;
196 proj.takedamage = DAMAGE_YES;
197 proj.damageforcescale = WEP_CVAR_PRI(fireball, damageforcescale);
198 PROJECTILE_MAKETRIGGER(proj);
199 proj.projectiledeathtype = WEP_FIREBALL;
200 setorigin(proj, w_shotorg);
202 proj.movetype = MOVETYPE_FLY;
203 WEP_SETUPPROJVELOCITY_PRI(proj, fireball);
204 proj.angles = vectoangles(proj.velocity);
205 proj.touch = W_Fireball_TouchExplode;
206 setsize(proj, '-16 -16 -16', '16 16 16');
207 proj.flags = FL_PROJECTILE;
208 proj.missile_flags = MIF_SPLASH | MIF_PROXY;
210 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
212 other = proj; MUTATOR_CALLHOOK(EditProjectile);
215 void W_Fireball_AttackEffect(float i, vector f_diff)
217 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0, 0);
218 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
219 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
222 void W_Fireball_Attack1_Frame4()
224 W_Fireball_Attack1();
225 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready);
228 void W_Fireball_Attack1_Frame3()
230 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
231 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4);
234 void W_Fireball_Attack1_Frame2()
236 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
237 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3);
240 void W_Fireball_Attack1_Frame1()
242 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
243 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2);
246 void W_Fireball_Attack1_Frame0()
248 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
249 sound (self, CH_WEAPON_SINGLE, "weapons/fireball_prefire2.wav", VOL_BASE, ATTEN_NORM);
250 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1);
253 void W_Firemine_Think()
255 if(time > self.pushltime)
261 // make it "hot" once it leaves its owner
264 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > WEP_CVAR_SEC(fireball, laserradius))
274 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));
276 self.nextthink = time + 0.1;
279 void W_Firemine_Touch (void)
282 if (other.takedamage == DAMAGE_AIM)
283 if(Fire_AddDamage(other, self.realowner, WEP_CVAR_SEC(fireball, damage), WEP_CVAR_SEC(fireball, damagetime), self.projectiledeathtype) >= 0)
288 self.projectiledeathtype |= HITTYPE_BOUNCE;
291 void W_Fireball_Attack2()
297 c = mod(self.bulletcounter, 4);
301 f_diff = '-1.25 -3.75 0';
304 f_diff = '+1.25 -3.75 0';
307 f_diff = '-1.25 +3.75 0';
311 f_diff = '+1.25 +3.75 0';
314 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(fireball, damage));
315 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
316 w_shotorg = trace_endpos;
318 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
321 proj.owner = proj.realowner = self;
322 proj.classname = "grenade";
323 proj.bot_dodge = TRUE;
324 proj.bot_dodgerating = WEP_CVAR_SEC(fireball, damage);
325 proj.movetype = MOVETYPE_BOUNCE;
326 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
327 proj.touch = W_Firemine_Touch;
328 PROJECTILE_MAKETRIGGER(proj);
329 setsize(proj, '-4 -4 -4', '4 4 4');
330 setorigin(proj, w_shotorg);
331 proj.think = W_Firemine_Think;
332 proj.nextthink = time;
333 proj.damageforcescale = WEP_CVAR_SEC(fireball, damageforcescale);
334 proj.pushltime = time + WEP_CVAR_SEC(fireball, lifetime);
335 WEP_SETUPPROJVELOCITY_UP_SEC(proj, fireball);
337 proj.angles = vectoangles(proj.velocity);
338 proj.flags = FL_PROJECTILE;
339 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
341 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
343 other = proj; MUTATOR_CALLHOOK(EditProjectile);
346 float w_fireball(float req)
352 self.BUTTON_ATCK = FALSE;
353 self.BUTTON_ATCK2 = FALSE;
354 if (self.bot_primary_fireballmooth == 0)
356 if(bot_aim(WEP_CVAR_PRI(fireball, speed), 0, WEP_CVAR_PRI(fireball, lifetime), FALSE))
358 self.BUTTON_ATCK = TRUE;
359 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
364 if(bot_aim(WEP_CVAR_SEC(fireball, speed), WEP_CVAR_SEC(fireball, speed_up), WEP_CVAR_SEC(fireball, lifetime), TRUE))
366 self.BUTTON_ATCK2 = TRUE;
367 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
375 if (self.BUTTON_ATCK)
377 if (time >= self.fireball_primarytime)
378 if (weapon_prepareattack(0, WEP_CVAR_PRI(fireball, refire)))
380 W_Fireball_Attack1_Frame0();
381 self.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor();
384 else if (self.BUTTON_ATCK2)
386 if (weapon_prepareattack(1, WEP_CVAR_SEC(fireball, refire)))
388 W_Fireball_Attack2();
389 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready);
397 precache_model ("models/weapons/g_fireball.md3");
398 precache_model ("models/weapons/v_fireball.md3");
399 precache_model ("models/weapons/h_fireball.iqm");
400 precache_model ("models/sphere/sphere.md3");
401 precache_sound ("weapons/fireball_fire.wav");
402 precache_sound ("weapons/fireball_fire2.wav");
403 precache_sound ("weapons/fireball_prefire2.wav");
404 FIREBALL_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
409 self.current_ammo = ammo_none;
415 return TRUE; // fireball has infinite ammo
419 FIREBALL_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
424 self.fireball_primarytime = time;
427 case WR_SUICIDEMESSAGE:
429 if(w_deathtype & HITTYPE_SECONDARY)
430 return WEAPON_FIREBALL_SUICIDE_FIREMINE;
432 return WEAPON_FIREBALL_SUICIDE_BLAST;
436 if(w_deathtype & HITTYPE_SECONDARY)
437 return WEAPON_FIREBALL_MURDER_FIREMINE;
439 return WEAPON_FIREBALL_MURDER_BLAST;
446 float w_fireball(float req)
450 case WR_IMPACTEFFECT:
453 if(w_deathtype & HITTYPE_SECONDARY)
455 // firemine goes out silently
459 org2 = w_org + w_backoff * 16;
460 pointparticles(particleeffectnum("fireball_explode"), org2, '0 0 0', 1);
462 sound(self, CH_SHOTS, "weapons/fireball_impact2.wav", VOL_BASE, ATTEN_NORM * 0.25); // long range boom
469 precache_sound("weapons/fireball_impact2.wav");