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) FIREBALL_SETTINGS_LIST(w_cvar, w_prop, WEP_FIREBALL, fireball)
15 #define FIREBALL_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
16 w_cvar(id, sn, MO_BOTH, animtime) \
17 w_cvar(id, sn, MO_BOTH, refire) \
18 w_cvar(id, sn, MO_BOTH, damage) \
19 w_cvar(id, sn, MO_BOTH, damageforcescale) \
20 w_cvar(id, sn, MO_BOTH, speed) \
21 w_cvar(id, sn, MO_BOTH, spread) \
22 w_cvar(id, sn, MO_BOTH, lifetime) \
23 w_cvar(id, sn, MO_BOTH, laserburntime) \
24 w_cvar(id, sn, MO_BOTH, laserdamage) \
25 w_cvar(id, sn, MO_BOTH, laseredgedamage) \
26 w_cvar(id, sn, MO_BOTH, laserradius) \
27 w_cvar(id, sn, MO_PRI, edgedamage) \
28 w_cvar(id, sn, MO_PRI, force) \
29 w_cvar(id, sn, MO_PRI, radius) \
30 w_cvar(id, sn, MO_PRI, health) \
31 w_cvar(id, sn, MO_PRI, refire2) \
32 w_cvar(id, sn, MO_PRI, bfgdamage) \
33 w_cvar(id, sn, MO_PRI, bfgforce) \
34 w_cvar(id, sn, MO_PRI, bfgradius) \
35 w_cvar(id, sn, MO_SEC, damagetime) \
36 w_cvar(id, sn, MO_SEC, speed_up) \
37 w_cvar(id, sn, MO_SEC, speed_z) \
38 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
39 w_prop(id, sn, float, reloading_time, reload_time) \
40 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
41 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
42 w_prop(id, sn, string, weaponreplace, weaponreplace) \
43 w_prop(id, sn, float, weaponstart, weaponstart) \
44 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
47 FIREBALL_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
48 .float bot_primary_fireballmooth; // whatever a mooth is
49 .vector fireball_impactvec;
50 .float fireball_primarytime;
54 void spawnfunc_weapon_fireball() { weapon_defaultspawnfunc(WEP_FIREBALL); }
56 void W_Fireball_Explode (void)
64 self.event_damage = func_null;
65 self.takedamage = DAMAGE_NO;
68 d = (self.realowner.health + self.realowner.armorvalue);
69 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);
70 if(self.realowner.health + self.realowner.armorvalue >= d)
73 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);
76 // NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
77 for(e = findradius(self.origin, WEP_CVAR_PRI(fireball, bfgradius)); e; e = e.chain)
78 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
80 // can we see fireball?
81 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
82 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
84 // can we see player who shot fireball?
85 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
86 if(trace_ent != self.realowner)
87 if(/* trace_startsolid || */ trace_fraction != 1)
89 dist = vlen(self.origin - e.origin - e.view_ofs);
90 points = (1 - sqrt(dist / WEP_CVAR_PRI(fireball, bfgradius)));
93 dir = normalize(e.origin + e.view_ofs - self.origin);
95 if(accuracy_isgooddamage(self.realowner, e))
96 accuracy_add(self.realowner, WEP_FIREBALL, 0, WEP_CVAR_PRI(fireball, bfgdamage) * points);
98 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);
99 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
106 void W_Fireball_TouchExplode (void)
109 W_Fireball_Explode ();
112 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
121 RandomSelection_Init();
122 for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain)
123 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
126 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
127 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
128 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
129 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
132 e.fireball_impactvec = p;
133 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
136 if(RandomSelection_chosen_ent)
138 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
139 d = damage + (edgedamage - damage) * (d / dist);
140 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
141 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
142 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
146 void W_Fireball_Think()
148 if(time > self.pushltime)
151 self.projectiledeathtype |= HITTYPE_SPLASH;
152 W_Fireball_Explode();
156 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));
158 self.nextthink = time + 0.1;
161 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
166 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
167 return; // g_projectiles_damage says to halt
169 self.health = self.health - damage;
170 if (self.health <= 0)
173 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
177 void W_Fireball_Attack1()
181 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));
183 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
186 proj.classname = "plasma_prim";
187 proj.owner = proj.realowner = self;
188 proj.bot_dodge = TRUE;
189 proj.bot_dodgerating = WEP_CVAR_PRI(fireball, damage);
190 proj.pushltime = time + WEP_CVAR_PRI(fireball, lifetime);
191 proj.use = W_Fireball_Explode;
192 proj.think = W_Fireball_Think;
193 proj.nextthink = time;
194 proj.health = WEP_CVAR_PRI(fireball, health);
195 proj.team = self.team;
196 proj.event_damage = W_Fireball_Damage;
197 proj.takedamage = DAMAGE_YES;
198 proj.damageforcescale = WEP_CVAR_PRI(fireball, damageforcescale);
199 PROJECTILE_MAKETRIGGER(proj);
200 proj.projectiledeathtype = WEP_FIREBALL;
201 setorigin(proj, w_shotorg);
203 proj.movetype = MOVETYPE_FLY;
204 WEP_SETUPPROJVELOCITY_PRI(proj, fireball);
205 proj.angles = vectoangles(proj.velocity);
206 proj.touch = W_Fireball_TouchExplode;
207 setsize(proj, '-16 -16 -16', '16 16 16');
208 proj.flags = FL_PROJECTILE;
209 proj.missile_flags = MIF_SPLASH | MIF_PROXY;
211 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
213 other = proj; MUTATOR_CALLHOOK(EditProjectile);
216 void W_Fireball_AttackEffect(float i, vector f_diff)
218 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0, 0);
219 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
220 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
223 void W_Fireball_Attack1_Frame4()
225 W_Fireball_Attack1();
226 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready);
229 void W_Fireball_Attack1_Frame3()
231 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
232 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4);
235 void W_Fireball_Attack1_Frame2()
237 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
238 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3);
241 void W_Fireball_Attack1_Frame1()
243 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
244 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2);
247 void W_Fireball_Attack1_Frame0()
249 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
250 sound (self, CH_WEAPON_SINGLE, "weapons/fireball_prefire2.wav", VOL_BASE, ATTEN_NORM);
251 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1);
254 void W_Firemine_Think()
256 if(time > self.pushltime)
262 // make it "hot" once it leaves its owner
265 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > WEP_CVAR_SEC(fireball, laserradius))
275 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));
277 self.nextthink = time + 0.1;
280 void W_Firemine_Touch (void)
283 if (other.takedamage == DAMAGE_AIM)
284 if(Fire_AddDamage(other, self.realowner, WEP_CVAR_SEC(fireball, damage), WEP_CVAR_SEC(fireball, damagetime), self.projectiledeathtype) >= 0)
289 self.projectiledeathtype |= HITTYPE_BOUNCE;
292 void W_Fireball_Attack2()
298 c = mod(self.bulletcounter, 4);
302 f_diff = '-1.25 -3.75 0';
305 f_diff = '+1.25 -3.75 0';
308 f_diff = '-1.25 +3.75 0';
312 f_diff = '+1.25 +3.75 0';
315 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(fireball, damage));
316 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
317 w_shotorg = trace_endpos;
319 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
322 proj.owner = proj.realowner = self;
323 proj.classname = "grenade";
324 proj.bot_dodge = TRUE;
325 proj.bot_dodgerating = WEP_CVAR_SEC(fireball, damage);
326 proj.movetype = MOVETYPE_BOUNCE;
327 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
328 proj.touch = W_Firemine_Touch;
329 PROJECTILE_MAKETRIGGER(proj);
330 setsize(proj, '-4 -4 -4', '4 4 4');
331 setorigin(proj, w_shotorg);
332 proj.think = W_Firemine_Think;
333 proj.nextthink = time;
334 proj.damageforcescale = WEP_CVAR_SEC(fireball, damageforcescale);
335 proj.pushltime = time + WEP_CVAR_SEC(fireball, lifetime);
336 WEP_SETUPPROJVELOCITY_UP_SEC(proj, fireball);
338 proj.angles = vectoangles(proj.velocity);
339 proj.flags = FL_PROJECTILE;
340 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
342 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
344 other = proj; MUTATOR_CALLHOOK(EditProjectile);
347 float w_fireball(float req)
353 self.BUTTON_ATCK = FALSE;
354 self.BUTTON_ATCK2 = FALSE;
355 if (self.bot_primary_fireballmooth == 0)
357 if(bot_aim(WEP_CVAR_PRI(fireball, speed), 0, WEP_CVAR_PRI(fireball, lifetime), FALSE))
359 self.BUTTON_ATCK = TRUE;
360 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
365 if(bot_aim(WEP_CVAR_SEC(fireball, speed), WEP_CVAR_SEC(fireball, speed_up), WEP_CVAR_SEC(fireball, lifetime), TRUE))
367 self.BUTTON_ATCK2 = TRUE;
368 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
376 if (self.BUTTON_ATCK)
378 if (time >= self.fireball_primarytime)
379 if (weapon_prepareattack(0, WEP_CVAR_PRI(fireball, refire)))
381 W_Fireball_Attack1_Frame0();
382 self.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor();
385 else if (self.BUTTON_ATCK2)
387 if (weapon_prepareattack(1, WEP_CVAR_SEC(fireball, refire)))
389 W_Fireball_Attack2();
390 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready);
398 precache_model ("models/weapons/g_fireball.md3");
399 precache_model ("models/weapons/v_fireball.md3");
400 precache_model ("models/weapons/h_fireball.iqm");
401 precache_model ("models/sphere/sphere.md3");
402 precache_sound ("weapons/fireball_fire.wav");
403 precache_sound ("weapons/fireball_fire2.wav");
404 precache_sound ("weapons/fireball_prefire2.wav");
405 FIREBALL_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
410 self.current_ammo = ammo_none;
416 return TRUE; // fireball has infinite ammo
420 FIREBALL_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
425 self.fireball_primarytime = time;
428 case WR_SUICIDEMESSAGE:
430 if(w_deathtype & HITTYPE_SECONDARY)
431 return WEAPON_FIREBALL_SUICIDE_FIREMINE;
433 return WEAPON_FIREBALL_SUICIDE_BLAST;
437 if(w_deathtype & HITTYPE_SECONDARY)
438 return WEAPON_FIREBALL_MURDER_FIREMINE;
440 return WEAPON_FIREBALL_MURDER_BLAST;
447 float w_fireball(float req)
451 case WR_IMPACTEFFECT:
454 if(w_deathtype & HITTYPE_SECONDARY)
456 // firemine goes out silently
460 org2 = w_org + w_backoff * 16;
461 pointparticles(particleeffectnum("fireball_explode"), org2, '0 0 0', 1);
463 sound(self, CH_SHOTS, "weapons/fireball_impact2.wav", VOL_BASE, ATTEN_NORM * 0.25); // long range boom
470 precache_sound("weapons/fireball_impact2.wav");