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 void spawnfunc_weapon_fireball() { weapon_defaultspawnfunc(WEP_FIREBALL); }
43 .float bot_primary_fireballmooth; // whatever a mooth is
44 .vector fireball_impactvec;
45 .float fireball_primarytime;
50 void W_Fireball_Explode (void)
58 self.event_damage = func_null;
59 self.takedamage = DAMAGE_NO;
62 d = (self.realowner.health + self.realowner.armorvalue);
63 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);
64 if(self.realowner.health + self.realowner.armorvalue >= d)
67 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);
70 // NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
71 for(e = findradius(self.origin, WEP_CVAR_PRI(fireball, bfgradius)); e; e = e.chain)
72 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || IsDifferentTeam(e, self))
74 // can we see fireball?
75 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
76 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
78 // can we see player who shot fireball?
79 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
80 if(trace_ent != self.realowner)
81 if(/* trace_startsolid || */ trace_fraction != 1)
83 dist = vlen(self.origin - e.origin - e.view_ofs);
84 points = (1 - sqrt(dist / WEP_CVAR_PRI(fireball, bfgradius)));
87 dir = normalize(e.origin + e.view_ofs - self.origin);
89 if(accuracy_isgooddamage(self.realowner, e))
90 accuracy_add(self.realowner, WEP_FIREBALL, 0, WEP_CVAR_PRI(fireball, bfgdamage) * points);
92 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);
93 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
100 void W_Fireball_TouchExplode (void)
103 W_Fireball_Explode ();
106 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
115 RandomSelection_Init();
116 for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain)
117 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || IsDifferentTeam(e, self))
120 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
121 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
122 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
123 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
126 e.fireball_impactvec = p;
127 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
130 if(RandomSelection_chosen_ent)
132 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
133 d = damage + (edgedamage - damage) * (d / dist);
134 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
135 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
136 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
140 void W_Fireball_Think()
142 if(time > self.pushltime)
145 self.projectiledeathtype |= HITTYPE_SPLASH;
146 W_Fireball_Explode();
150 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));
152 self.nextthink = time + 0.1;
155 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
160 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
161 return; // g_projectiles_damage says to halt
163 self.health = self.health - damage;
164 if (self.health <= 0)
167 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
171 void W_Fireball_Attack1()
175 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));
177 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
180 proj.classname = "plasma_prim";
181 proj.owner = proj.realowner = self;
182 proj.bot_dodge = TRUE;
183 proj.bot_dodgerating = WEP_CVAR_PRI(fireball, damage);
184 proj.pushltime = time + WEP_CVAR_PRI(fireball, lifetime);
185 proj.use = W_Fireball_Explode;
186 proj.think = W_Fireball_Think;
187 proj.nextthink = time;
188 proj.health = WEP_CVAR_PRI(fireball, health);
189 proj.team = self.team;
190 proj.event_damage = W_Fireball_Damage;
191 proj.takedamage = DAMAGE_YES;
192 proj.damageforcescale = WEP_CVAR_PRI(fireball, damageforcescale);
193 PROJECTILE_MAKETRIGGER(proj);
194 proj.projectiledeathtype = WEP_FIREBALL;
195 setorigin(proj, w_shotorg);
197 proj.movetype = MOVETYPE_FLY;
198 W_SETUPPROJECTILEVELOCITY(proj, g_balance_fireball_primary);
199 proj.angles = vectoangles(proj.velocity);
200 proj.touch = W_Fireball_TouchExplode;
201 setsize(proj, '-16 -16 -16', '16 16 16');
202 proj.flags = FL_PROJECTILE;
203 proj.missile_flags = MIF_SPLASH | MIF_PROXY;
205 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
207 other = proj; MUTATOR_CALLHOOK(EditProjectile);
210 void W_Fireball_AttackEffect(float i, vector f_diff)
212 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0, 0);
213 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
214 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
217 void W_Fireball_Attack1_Frame4()
219 W_Fireball_Attack1();
220 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready);
223 void W_Fireball_Attack1_Frame3()
225 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
226 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4);
229 void W_Fireball_Attack1_Frame2()
231 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
232 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3);
235 void W_Fireball_Attack1_Frame1()
237 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
238 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2);
241 void W_Fireball_Attack1_Frame0()
243 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
244 sound (self, CH_WEAPON_SINGLE, "weapons/fireball_prefire2.wav", VOL_BASE, ATTN_NORM);
245 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1);
248 void W_Firemine_Think()
250 if(time > self.pushltime)
256 // make it "hot" once it leaves its owner
259 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > WEP_CVAR_SEC(fireball, laserradius))
269 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));
271 self.nextthink = time + 0.1;
274 void W_Firemine_Touch (void)
277 if (other.takedamage == DAMAGE_AIM)
278 if(Fire_AddDamage(other, self.realowner, WEP_CVAR_SEC(fireball, damage), WEP_CVAR_SEC(fireball, damagetime), self.projectiledeathtype) >= 0)
283 self.projectiledeathtype |= HITTYPE_BOUNCE;
286 void W_Fireball_Attack2()
292 c = mod(self.bulletcounter, 4);
296 f_diff = '-1.25 -3.75 0';
299 f_diff = '+1.25 -3.75 0';
302 f_diff = '-1.25 +3.75 0';
306 f_diff = '+1.25 +3.75 0';
309 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(fireball, damage));
310 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
311 w_shotorg = trace_endpos;
313 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
316 proj.owner = proj.realowner = self;
317 proj.classname = "grenade";
318 proj.bot_dodge = TRUE;
319 proj.bot_dodgerating = WEP_CVAR_SEC(fireball, damage);
320 proj.movetype = MOVETYPE_BOUNCE;
321 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
322 proj.touch = W_Firemine_Touch;
323 PROJECTILE_MAKETRIGGER(proj);
324 setsize(proj, '-4 -4 -4', '4 4 4');
325 setorigin(proj, w_shotorg);
326 proj.think = W_Firemine_Think;
327 proj.nextthink = time;
328 proj.damageforcescale = WEP_CVAR_SEC(fireball, damageforcescale);
329 proj.pushltime = time + WEP_CVAR_SEC(fireball, lifetime);
330 W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_fireball_secondary);
332 proj.angles = vectoangles(proj.velocity);
333 proj.flags = FL_PROJECTILE;
334 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
336 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
338 other = proj; MUTATOR_CALLHOOK(EditProjectile);
341 float w_fireball(float req)
347 self.BUTTON_ATCK = FALSE;
348 self.BUTTON_ATCK2 = FALSE;
349 if (self.bot_primary_fireballmooth == 0)
351 if(bot_aim(WEP_CVAR_PRI(fireball, speed), 0, WEP_CVAR_PRI(fireball, lifetime), FALSE))
353 self.BUTTON_ATCK = TRUE;
354 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
359 if(bot_aim(WEP_CVAR_SEC(fireball, speed), WEP_CVAR_SEC(fireball, speed_up), WEP_CVAR_SEC(fireball, lifetime), TRUE))
361 self.BUTTON_ATCK2 = TRUE;
362 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
370 if (self.BUTTON_ATCK)
372 if (time >= self.fireball_primarytime)
373 if (weapon_prepareattack(0, WEP_CVAR_PRI(fireball, refire)))
375 W_Fireball_Attack1_Frame0();
376 self.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor();
379 else if (self.BUTTON_ATCK2)
381 if (weapon_prepareattack(1, WEP_CVAR_SEC(fireball, refire)))
383 W_Fireball_Attack2();
384 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready);
392 precache_model ("models/weapons/g_fireball.md3");
393 precache_model ("models/weapons/v_fireball.md3");
394 precache_model ("models/weapons/h_fireball.iqm");
395 precache_model ("models/sphere/sphere.md3");
396 precache_sound ("weapons/fireball_fire.wav");
397 precache_sound ("weapons/fireball_fire2.wav");
398 precache_sound ("weapons/fireball_prefire2.wav");
399 WEP_SET_PROPS(FIREBALL_SETTINGS(fireball), WEP_FIREBALL)
404 weapon_setup(WEP_FIREBALL);
405 self.current_ammo = ammo_none;
411 return TRUE; // fireball has infinite ammo
415 WEP_CONFIG_SETTINGS(FIREBALL_SETTINGS(fireball))
420 self.fireball_primarytime = time;
423 case WR_SUICIDEMESSAGE:
425 if(w_deathtype & HITTYPE_SECONDARY)
426 return WEAPON_FIREBALL_SUICIDE_FIREMINE;
428 return WEAPON_FIREBALL_SUICIDE_BLAST;
432 if(w_deathtype & HITTYPE_SECONDARY)
433 return WEAPON_FIREBALL_MURDER_FIREMINE;
435 return WEAPON_FIREBALL_MURDER_BLAST;
442 float w_fireball(float req)
446 case WR_IMPACTEFFECT:
449 if(w_deathtype & HITTYPE_SECONDARY)
451 // firemine goes out silently
455 org2 = w_org + w_backoff * 16;
456 pointparticles(particleeffectnum("fireball_explode"), org2, '0 0 0', 1);
458 sound(self, CH_SHOTS, "weapons/fireball_impact2.wav", VOL_BASE, ATTN_NORM * 0.25); // long range boom
465 precache_sound("weapons/fireball_impact2.wav");