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")
13 #define FIREBALL_SETTINGS(weapon) \
14 WEP_ADD_CVAR(weapon, MO_BOTH, animtime) \
15 WEP_ADD_CVAR(weapon, MO_BOTH, refire) \
16 WEP_ADD_CVAR(weapon, MO_BOTH, damage) \
17 WEP_ADD_CVAR(weapon, MO_BOTH, damageforcescale) \
18 WEP_ADD_CVAR(weapon, MO_BOTH, speed) \
19 WEP_ADD_CVAR(weapon, MO_BOTH, lifetime) \
20 WEP_ADD_CVAR(weapon, MO_BOTH, laserburntime) \
21 WEP_ADD_CVAR(weapon, MO_BOTH, laserdamage) \
22 WEP_ADD_CVAR(weapon, MO_BOTH, laseredgedamage) \
23 WEP_ADD_CVAR(weapon, MO_BOTH, laserradius) \
24 WEP_ADD_CVAR(weapon, MO_PRI, edgedamage) \
25 WEP_ADD_CVAR(weapon, MO_PRI, force) \
26 WEP_ADD_CVAR(weapon, MO_PRI, radius) \
27 WEP_ADD_CVAR(weapon, MO_PRI, health) \
28 WEP_ADD_CVAR(weapon, MO_PRI, refire2) \
29 WEP_ADD_CVAR(weapon, MO_PRI, bfgdamage) \
30 WEP_ADD_CVAR(weapon, MO_PRI, bfgforce) \
31 WEP_ADD_CVAR(weapon, MO_PRI, bfgradius) \
32 WEP_ADD_CVAR(weapon, MO_SEC, damagetime) \
33 WEP_ADD_CVAR(weapon, MO_SEC, speed_up) \
34 WEP_ADD_PROP(weapon, reloading_ammo, reload_ammo) \
35 WEP_ADD_PROP(weapon, reloading_time, reload_time) \
36 WEP_ADD_PROP(weapon, switchdelay_raise, switchdelay_raise) \
37 WEP_ADD_PROP(weapon, switchdelay_drop, switchdelay_drop)
40 FIREBALL_SETTINGS(fireball)
41 .float bot_primary_fireballmooth; // whatever a mooth is
42 .vector fireball_impactvec;
43 .float fireball_primarytime;
47 void spawnfunc_weapon_fireball() { weapon_defaultspawnfunc(WEP_FIREBALL); }
49 void W_Fireball_Explode (void)
57 self.event_damage = func_null;
58 self.takedamage = DAMAGE_NO;
61 d = (self.realowner.health + self.realowner.armorvalue);
62 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);
63 if(self.realowner.health + self.realowner.armorvalue >= d)
66 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);
69 // NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
70 for(e = findradius(self.origin, WEP_CVAR_PRI(fireball, bfgradius)); e; e = e.chain)
71 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || IsDifferentTeam(e, self))
73 // can we see fireball?
74 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
75 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
77 // can we see player who shot fireball?
78 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
79 if(trace_ent != self.realowner)
80 if(/* trace_startsolid || */ trace_fraction != 1)
82 dist = vlen(self.origin - e.origin - e.view_ofs);
83 points = (1 - sqrt(dist / WEP_CVAR_PRI(fireball, bfgradius)));
86 dir = normalize(e.origin + e.view_ofs - self.origin);
88 if(accuracy_isgooddamage(self.realowner, e))
89 accuracy_add(self.realowner, WEP_FIREBALL, 0, WEP_CVAR_PRI(fireball, bfgdamage) * points);
91 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);
92 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
99 void W_Fireball_TouchExplode (void)
102 W_Fireball_Explode ();
105 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
114 RandomSelection_Init();
115 for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain)
116 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || IsDifferentTeam(e, self))
119 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
120 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
121 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
122 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
125 e.fireball_impactvec = p;
126 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
129 if(RandomSelection_chosen_ent)
131 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
132 d = damage + (edgedamage - damage) * (d / dist);
133 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
134 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
135 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
139 void W_Fireball_Think()
141 if(time > self.pushltime)
144 self.projectiledeathtype |= HITTYPE_SPLASH;
145 W_Fireball_Explode();
149 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));
151 self.nextthink = time + 0.1;
154 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
159 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
160 return; // g_projectiles_damage says to halt
162 self.health = self.health - damage;
163 if (self.health <= 0)
166 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
170 void W_Fireball_Attack1()
174 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));
176 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
179 proj.classname = "plasma_prim";
180 proj.owner = proj.realowner = self;
181 proj.bot_dodge = TRUE;
182 proj.bot_dodgerating = WEP_CVAR_PRI(fireball, damage);
183 proj.pushltime = time + WEP_CVAR_PRI(fireball, lifetime);
184 proj.use = W_Fireball_Explode;
185 proj.think = W_Fireball_Think;
186 proj.nextthink = time;
187 proj.health = WEP_CVAR_PRI(fireball, health);
188 proj.team = self.team;
189 proj.event_damage = W_Fireball_Damage;
190 proj.takedamage = DAMAGE_YES;
191 proj.damageforcescale = WEP_CVAR_PRI(fireball, damageforcescale);
192 PROJECTILE_MAKETRIGGER(proj);
193 proj.projectiledeathtype = WEP_FIREBALL;
194 setorigin(proj, w_shotorg);
196 proj.movetype = MOVETYPE_FLY;
197 W_SETUPPROJECTILEVELOCITY(proj, g_balance_fireball_primary);
198 proj.angles = vectoangles(proj.velocity);
199 proj.touch = W_Fireball_TouchExplode;
200 setsize(proj, '-16 -16 -16', '16 16 16');
201 proj.flags = FL_PROJECTILE;
202 proj.missile_flags = MIF_SPLASH | MIF_PROXY;
204 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
206 other = proj; MUTATOR_CALLHOOK(EditProjectile);
209 void W_Fireball_AttackEffect(float i, vector f_diff)
211 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0, 0);
212 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
213 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
216 void W_Fireball_Attack1_Frame4()
218 W_Fireball_Attack1();
219 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready);
222 void W_Fireball_Attack1_Frame3()
224 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
225 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4);
228 void W_Fireball_Attack1_Frame2()
230 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
231 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3);
234 void W_Fireball_Attack1_Frame1()
236 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
237 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2);
240 void W_Fireball_Attack1_Frame0()
242 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
243 sound (self, CH_WEAPON_SINGLE, "weapons/fireball_prefire2.wav", VOL_BASE, ATTN_NORM);
244 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1);
247 void W_Firemine_Think()
249 if(time > self.pushltime)
255 // make it "hot" once it leaves its owner
258 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > WEP_CVAR_SEC(fireball, laserradius))
268 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));
270 self.nextthink = time + 0.1;
273 void W_Firemine_Touch (void)
276 if (other.takedamage == DAMAGE_AIM)
277 if(Fire_AddDamage(other, self.realowner, WEP_CVAR_SEC(fireball, damage), WEP_CVAR_SEC(fireball, damagetime), self.projectiledeathtype) >= 0)
282 self.projectiledeathtype |= HITTYPE_BOUNCE;
285 void W_Fireball_Attack2()
291 c = mod(self.bulletcounter, 4);
295 f_diff = '-1.25 -3.75 0';
298 f_diff = '+1.25 -3.75 0';
301 f_diff = '-1.25 +3.75 0';
305 f_diff = '+1.25 +3.75 0';
308 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(fireball, damage));
309 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
310 w_shotorg = trace_endpos;
312 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
315 proj.owner = proj.realowner = self;
316 proj.classname = "grenade";
317 proj.bot_dodge = TRUE;
318 proj.bot_dodgerating = WEP_CVAR_SEC(fireball, damage);
319 proj.movetype = MOVETYPE_BOUNCE;
320 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
321 proj.touch = W_Firemine_Touch;
322 PROJECTILE_MAKETRIGGER(proj);
323 setsize(proj, '-4 -4 -4', '4 4 4');
324 setorigin(proj, w_shotorg);
325 proj.think = W_Firemine_Think;
326 proj.nextthink = time;
327 proj.damageforcescale = WEP_CVAR_SEC(fireball, damageforcescale);
328 proj.pushltime = time + WEP_CVAR_SEC(fireball, lifetime);
329 W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_fireball_secondary);
331 proj.angles = vectoangles(proj.velocity);
332 proj.flags = FL_PROJECTILE;
333 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
335 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
337 other = proj; MUTATOR_CALLHOOK(EditProjectile);
340 float w_fireball(float req)
346 self.BUTTON_ATCK = FALSE;
347 self.BUTTON_ATCK2 = FALSE;
348 if (self.bot_primary_fireballmooth == 0)
350 if(bot_aim(WEP_CVAR_PRI(fireball, speed), 0, WEP_CVAR_PRI(fireball, lifetime), FALSE))
352 self.BUTTON_ATCK = TRUE;
353 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
358 if(bot_aim(WEP_CVAR_SEC(fireball, speed), WEP_CVAR_SEC(fireball, speed_up), WEP_CVAR_SEC(fireball, lifetime), TRUE))
360 self.BUTTON_ATCK2 = TRUE;
361 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
369 if (self.BUTTON_ATCK)
371 if (time >= self.fireball_primarytime)
372 if (weapon_prepareattack(0, WEP_CVAR_PRI(fireball, refire)))
374 W_Fireball_Attack1_Frame0();
375 self.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor();
378 else if (self.BUTTON_ATCK2)
380 if (weapon_prepareattack(1, WEP_CVAR_SEC(fireball, refire)))
382 W_Fireball_Attack2();
383 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready);
391 precache_model ("models/weapons/g_fireball.md3");
392 precache_model ("models/weapons/v_fireball.md3");
393 precache_model ("models/weapons/h_fireball.iqm");
394 precache_model ("models/sphere/sphere.md3");
395 precache_sound ("weapons/fireball_fire.wav");
396 precache_sound ("weapons/fireball_fire2.wav");
397 precache_sound ("weapons/fireball_prefire2.wav");
398 WEP_SET_PROPS(FIREBALL_SETTINGS(fireball), WEP_FIREBALL)
403 self.current_ammo = ammo_none;
409 return TRUE; // fireball has infinite ammo
413 WEP_CONFIG_SETTINGS(FIREBALL_SETTINGS(fireball))
418 self.fireball_primarytime = time;
421 case WR_SUICIDEMESSAGE:
423 if(w_deathtype & HITTYPE_SECONDARY)
424 return WEAPON_FIREBALL_SUICIDE_FIREMINE;
426 return WEAPON_FIREBALL_SUICIDE_BLAST;
430 if(w_deathtype & HITTYPE_SECONDARY)
431 return WEAPON_FIREBALL_MURDER_FIREMINE;
433 return WEAPON_FIREBALL_MURDER_BLAST;
440 float w_fireball(float req)
444 case WR_IMPACTEFFECT:
447 if(w_deathtype & HITTYPE_SECONDARY)
449 // firemine goes out silently
453 org2 = w_org + w_backoff * 16;
454 pointparticles(particleeffectnum("fireball_explode"), org2, '0 0 0', 1);
456 sound(self, CH_SHOTS, "weapons/fireball_impact2.wav", VOL_BASE, ATTN_NORM * 0.25); // long range boom
463 precache_sound("weapons/fireball_impact2.wav");