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)
43 FIREBALL_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
44 .float bot_primary_fireballmooth; // whatever a mooth is
45 .vector fireball_impactvec;
46 .float fireball_primarytime;
50 void spawnfunc_weapon_fireball() { weapon_defaultspawnfunc(WEP_FIREBALL); }
52 void W_Fireball_Explode (void)
60 self.event_damage = func_null;
61 self.takedamage = DAMAGE_NO;
64 d = (self.realowner.health + self.realowner.armorvalue);
65 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);
66 if(self.realowner.health + self.realowner.armorvalue >= d)
69 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);
72 // NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
73 for(e = findradius(self.origin, WEP_CVAR_PRI(fireball, bfgradius)); e; e = e.chain)
74 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
76 // can we see fireball?
77 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
78 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
80 // can we see player who shot fireball?
81 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
82 if(trace_ent != self.realowner)
83 if(/* trace_startsolid || */ trace_fraction != 1)
85 dist = vlen(self.origin - e.origin - e.view_ofs);
86 points = (1 - sqrt(dist / WEP_CVAR_PRI(fireball, bfgradius)));
89 dir = normalize(e.origin + e.view_ofs - self.origin);
91 if(accuracy_isgooddamage(self.realowner, e))
92 accuracy_add(self.realowner, WEP_FIREBALL, 0, WEP_CVAR_PRI(fireball, bfgdamage) * points);
94 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);
95 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
102 void W_Fireball_TouchExplode (void)
105 W_Fireball_Explode ();
108 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
117 RandomSelection_Init();
118 for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain)
119 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
122 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
123 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
124 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
125 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
128 e.fireball_impactvec = p;
129 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
132 if(RandomSelection_chosen_ent)
134 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
135 d = damage + (edgedamage - damage) * (d / dist);
136 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
137 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
138 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
142 void W_Fireball_Think()
144 if(time > self.pushltime)
147 self.projectiledeathtype |= HITTYPE_SPLASH;
148 W_Fireball_Explode();
152 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));
154 self.nextthink = time + 0.1;
157 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
162 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
163 return; // g_projectiles_damage says to halt
165 self.health = self.health - damage;
166 if (self.health <= 0)
169 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
173 void W_Fireball_Attack1()
177 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));
179 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
182 proj.classname = "plasma_prim";
183 proj.owner = proj.realowner = self;
184 proj.bot_dodge = TRUE;
185 proj.bot_dodgerating = WEP_CVAR_PRI(fireball, damage);
186 proj.pushltime = time + WEP_CVAR_PRI(fireball, lifetime);
187 proj.use = W_Fireball_Explode;
188 proj.think = W_Fireball_Think;
189 proj.nextthink = time;
190 proj.health = WEP_CVAR_PRI(fireball, health);
191 proj.team = self.team;
192 proj.event_damage = W_Fireball_Damage;
193 proj.takedamage = DAMAGE_YES;
194 proj.damageforcescale = WEP_CVAR_PRI(fireball, damageforcescale);
195 PROJECTILE_MAKETRIGGER(proj);
196 proj.projectiledeathtype = WEP_FIREBALL;
197 setorigin(proj, w_shotorg);
199 proj.movetype = MOVETYPE_FLY;
200 WEP_SETUPPROJVELOCITY_PRI(proj, fireball);
201 proj.angles = vectoangles(proj.velocity);
202 proj.touch = W_Fireball_TouchExplode;
203 setsize(proj, '-16 -16 -16', '16 16 16');
204 proj.flags = FL_PROJECTILE;
205 proj.missile_flags = MIF_SPLASH | MIF_PROXY;
207 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
209 other = proj; MUTATOR_CALLHOOK(EditProjectile);
212 void W_Fireball_AttackEffect(float i, vector f_diff)
214 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0, 0);
215 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
216 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
219 void W_Fireball_Attack1_Frame4()
221 W_Fireball_Attack1();
222 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready);
225 void W_Fireball_Attack1_Frame3()
227 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
228 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4);
231 void W_Fireball_Attack1_Frame2()
233 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
234 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3);
237 void W_Fireball_Attack1_Frame1()
239 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
240 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2);
243 void W_Fireball_Attack1_Frame0()
245 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
246 sound (self, CH_WEAPON_SINGLE, "weapons/fireball_prefire2.wav", VOL_BASE, ATTEN_NORM);
247 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1);
250 void W_Firemine_Think()
252 if(time > self.pushltime)
258 // make it "hot" once it leaves its owner
261 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > WEP_CVAR_SEC(fireball, laserradius))
271 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));
273 self.nextthink = time + 0.1;
276 void W_Firemine_Touch (void)
279 if (other.takedamage == DAMAGE_AIM)
280 if(Fire_AddDamage(other, self.realowner, WEP_CVAR_SEC(fireball, damage), WEP_CVAR_SEC(fireball, damagetime), self.projectiledeathtype) >= 0)
285 self.projectiledeathtype |= HITTYPE_BOUNCE;
288 void W_Fireball_Attack2()
294 c = mod(self.bulletcounter, 4);
298 f_diff = '-1.25 -3.75 0';
301 f_diff = '+1.25 -3.75 0';
304 f_diff = '-1.25 +3.75 0';
308 f_diff = '+1.25 +3.75 0';
311 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(fireball, damage));
312 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
313 w_shotorg = trace_endpos;
315 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
318 proj.owner = proj.realowner = self;
319 proj.classname = "grenade";
320 proj.bot_dodge = TRUE;
321 proj.bot_dodgerating = WEP_CVAR_SEC(fireball, damage);
322 proj.movetype = MOVETYPE_BOUNCE;
323 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
324 proj.touch = W_Firemine_Touch;
325 PROJECTILE_MAKETRIGGER(proj);
326 setsize(proj, '-4 -4 -4', '4 4 4');
327 setorigin(proj, w_shotorg);
328 proj.think = W_Firemine_Think;
329 proj.nextthink = time;
330 proj.damageforcescale = WEP_CVAR_SEC(fireball, damageforcescale);
331 proj.pushltime = time + WEP_CVAR_SEC(fireball, lifetime);
332 WEP_SETUPPROJVELOCITY_UP_SEC(proj, fireball);
334 proj.angles = vectoangles(proj.velocity);
335 proj.flags = FL_PROJECTILE;
336 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
338 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
340 other = proj; MUTATOR_CALLHOOK(EditProjectile);
343 float w_fireball(float req)
349 self.BUTTON_ATCK = FALSE;
350 self.BUTTON_ATCK2 = FALSE;
351 if (self.bot_primary_fireballmooth == 0)
353 if(bot_aim(WEP_CVAR_PRI(fireball, speed), 0, WEP_CVAR_PRI(fireball, lifetime), FALSE))
355 self.BUTTON_ATCK = TRUE;
356 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
361 if(bot_aim(WEP_CVAR_SEC(fireball, speed), WEP_CVAR_SEC(fireball, speed_up), WEP_CVAR_SEC(fireball, lifetime), TRUE))
363 self.BUTTON_ATCK2 = TRUE;
364 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
372 if (self.BUTTON_ATCK)
374 if (time >= self.fireball_primarytime)
375 if (weapon_prepareattack(0, WEP_CVAR_PRI(fireball, refire)))
377 W_Fireball_Attack1_Frame0();
378 self.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor();
381 else if (self.BUTTON_ATCK2)
383 if (weapon_prepareattack(1, WEP_CVAR_SEC(fireball, refire)))
385 W_Fireball_Attack2();
386 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready);
394 precache_model ("models/weapons/g_fireball.md3");
395 precache_model ("models/weapons/v_fireball.md3");
396 precache_model ("models/weapons/h_fireball.iqm");
397 precache_model ("models/sphere/sphere.md3");
398 precache_sound ("weapons/fireball_fire.wav");
399 precache_sound ("weapons/fireball_fire2.wav");
400 precache_sound ("weapons/fireball_prefire2.wav");
401 FIREBALL_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
406 self.current_ammo = ammo_none;
412 return TRUE; // fireball has infinite ammo
416 FIREBALL_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
421 self.fireball_primarytime = time;
424 case WR_SUICIDEMESSAGE:
426 if(w_deathtype & HITTYPE_SECONDARY)
427 return WEAPON_FIREBALL_SUICIDE_FIREMINE;
429 return WEAPON_FIREBALL_SUICIDE_BLAST;
433 if(w_deathtype & HITTYPE_SECONDARY)
434 return WEAPON_FIREBALL_MURDER_FIREMINE;
436 return WEAPON_FIREBALL_MURDER_BLAST;
443 float w_fireball(float req)
447 case WR_IMPACTEFFECT:
450 if(w_deathtype & HITTYPE_SECONDARY)
452 // firemine goes out silently
456 org2 = w_org + w_backoff * 16;
457 pointparticles(particleeffectnum("fireball_explode"), org2, '0 0 0', 1);
459 sound(self, CH_SHOTS, "weapons/fireball_impact2.wav", VOL_BASE, ATTEN_NORM * 0.25); // long range boom
466 precache_sound("weapons/fireball_impact2.wav");