2 REGISTER_WEAPON(FIREBALL, w_fireball, IT_FUEL, 9, WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "fireball", "fireball", _("Fireball"));
5 .float bot_primary_fireballmooth; // whatever a mooth is
6 .vector fireball_impactvec;
7 .float fireball_primarytime;
9 // weapon load persistence, for weapons that support reloading
12 void W_Fireball_SetAmmoCounter()
14 // set clip_load to the weapon we have switched to, if the gun uses reloading
15 if(!autocvar_g_balance_fireball_reload_ammo)
16 self.clip_load = 0; // also keeps crosshair ammo from displaying
19 self.clip_load = self.fireball_load;
20 self.clip_size = autocvar_g_balance_fireball_reload_ammo; // for the crosshair ammo display
24 void W_Fireball_Reload()
26 // fuel can be a non-whole number, which brakes stuff here when between 0 and 1
27 if(self.ammo_fuel < 1)
30 self.reload_ammo_player = ammo_fuel;
31 self.reload_ammo_min = min(autocvar_g_balance_fireball_primary_ammo, autocvar_g_balance_fireball_secondary_ammo);
32 self.reload_ammo_amount = autocvar_g_balance_fireball_reload_ammo;
33 self.reload_time = autocvar_g_balance_fireball_reload_time;
34 self.reload_sound = "weapons/reload.wav";
39 void W_Fireball_Explode (void)
47 self.event_damage = SUB_Null;
48 self.takedamage = DAMAGE_NO;
51 d = (self.owner.health + self.owner.armorvalue);
52 RadiusDamage (self, self.realowner, autocvar_g_balance_fireball_primary_damage, autocvar_g_balance_fireball_primary_edgedamage, autocvar_g_balance_fireball_primary_radius, world, autocvar_g_balance_fireball_primary_force, self.projectiledeathtype, other);
53 if(self.realowner.health + self.realowner.armorvalue >= d)
56 modeleffect_spawn("models/sphere/sphere.md3", 0, 0, self.origin, '0 0 0', '0 0 0', '0 0 0', 0, autocvar_g_balance_fireball_primary_bfgradius, 0.2, 0.05, 0.25);
59 // NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
60 for(e = findradius(self.origin, autocvar_g_balance_fireball_primary_bfgradius); e; e = e.chain)
61 if(e != self.owner) if(e.takedamage == DAMAGE_AIM) if(e.classname != "player" || !self.owner || IsDifferentTeam(e, self))
63 // can we see fireball?
64 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
65 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
67 // can we see player who shot fireball?
68 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
69 if(trace_ent != self.realowner)
70 if(/* trace_startsolid || */ trace_fraction != 1)
72 dist = vlen(self.origin - e.origin - e.view_ofs);
73 points = (1 - sqrt(dist / autocvar_g_balance_fireball_primary_bfgradius));
76 dir = normalize(e.origin + e.view_ofs - self.origin);
78 if(accuracy_isgooddamage(self.realowner, e))
79 accuracy_add(self.realowner, WEP_FIREBALL, 0, autocvar_g_balance_fireball_primary_bfgdamage * points);
81 Damage(e, self, self.realowner, autocvar_g_balance_fireball_primary_bfgdamage * points, self.projectiledeathtype | HITTYPE_BOUNCE | HITTYPE_SPLASH, e.origin + e.view_ofs, autocvar_g_balance_fireball_primary_bfgforce * dir);
82 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
89 void W_Fireball_TouchExplode (void)
92 W_Fireball_Explode ();
95 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
104 RandomSelection_Init();
105 for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain)
106 if(e != self.owner) if(e.takedamage == DAMAGE_AIM) if(e.classname != "player" || !self.owner || IsDifferentTeam(e, self))
109 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
110 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
111 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
112 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
115 e.fireball_impactvec = p;
116 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
119 if(RandomSelection_chosen_ent)
121 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
122 d = damage + (edgedamage - damage) * (d / dist);
123 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
124 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
125 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
129 void W_Fireball_Think()
131 if(time > self.pushltime)
134 self.projectiledeathtype |= HITTYPE_SPLASH;
135 W_Fireball_Explode();
139 W_Fireball_LaserPlay(0.1, autocvar_g_balance_fireball_primary_laserradius, autocvar_g_balance_fireball_primary_laserdamage, autocvar_g_balance_fireball_primary_laseredgedamage, autocvar_g_balance_fireball_primary_laserburntime);
141 self.nextthink = time + 0.1;
144 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
148 self.health = self.health - damage;
149 if (self.health <= 0)
152 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
156 void W_Fireball_Attack1()
160 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 2, "weapons/fireball_fire2.wav", CHAN_WEAPON, autocvar_g_balance_fireball_primary_damage + autocvar_g_balance_fireball_primary_bfgdamage);
162 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
165 proj.classname = "plasma_prim";
166 proj.owner = proj.realowner = self;
167 proj.bot_dodge = TRUE;
168 proj.bot_dodgerating = autocvar_g_balance_fireball_primary_damage;
169 proj.pushltime = time + autocvar_g_balance_fireball_primary_lifetime;
170 proj.use = W_Fireball_Explode;
171 proj.think = W_Fireball_Think;
172 proj.nextthink = time;
173 proj.health = autocvar_g_balance_fireball_primary_health;
174 proj.team = self.team;
175 proj.event_damage = W_Fireball_Damage;
176 proj.takedamage = DAMAGE_YES;
177 proj.damageforcescale = autocvar_g_balance_fireball_primary_damageforcescale;
178 PROJECTILE_MAKETRIGGER(proj);
179 proj.projectiledeathtype = WEP_FIREBALL;
180 setorigin(proj, w_shotorg);
182 proj.movetype = MOVETYPE_FLY;
183 W_SETUPPROJECTILEVELOCITY(proj, g_balance_fireball_primary);
184 proj.angles = vectoangles(proj.velocity);
185 proj.touch = W_Fireball_TouchExplode;
186 setsize(proj, '-16 -16 -16', '16 16 16');
187 proj.flags = FL_PROJECTILE;
189 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
191 other = proj; MUTATOR_CALLHOOK(EditProjectile);
194 void W_Fireball_AttackEffect(float i, vector f_diff)
196 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0, 0);
197 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
198 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
201 void W_Fireball_Attack1_Frame4()
203 W_Fireball_Attack1();
204 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, w_ready);
207 void W_Fireball_Attack1_Frame3()
209 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
210 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame4);
213 void W_Fireball_Attack1_Frame2()
215 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
216 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame3);
219 void W_Fireball_Attack1_Frame1()
221 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
222 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame2);
225 void W_Fireball_Attack1_Frame0()
227 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
228 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
230 if(autocvar_g_balance_fireball_reload_ammo)
232 self.clip_load -= autocvar_g_balance_fireball_primary_ammo;
233 self.fireball_load = self.clip_load;
236 self.ammo_fuel -= autocvar_g_balance_fireball_primary_ammo;
239 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
240 sound (self, CHAN_WEAPON, "weapons/fireball_prefire2.wav", VOL_BASE, ATTN_NORM);
241 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame1);
244 void W_Firemine_Think()
246 if(time > self.pushltime)
252 // make it "hot" once it leaves its owner
255 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > autocvar_g_balance_fireball_secondary_laserradius)
265 W_Fireball_LaserPlay(0.1, autocvar_g_balance_fireball_secondary_laserradius, autocvar_g_balance_fireball_secondary_laserdamage, autocvar_g_balance_fireball_secondary_laseredgedamage, autocvar_g_balance_fireball_secondary_laserburntime);
267 self.nextthink = time + 0.1;
270 void W_Firemine_Touch (void)
273 if (other.takedamage == DAMAGE_AIM)
274 if(Fire_AddDamage(other, self.realowner, autocvar_g_balance_fireball_secondary_damage, autocvar_g_balance_fireball_secondary_damagetime, self.projectiledeathtype | HITTYPE_HEADSHOT) >= 0)
279 self.projectiledeathtype |= HITTYPE_BOUNCE;
282 void W_Fireball_Attack2()
288 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
289 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
291 if(autocvar_g_balance_fireball_reload_ammo)
293 self.clip_load -= autocvar_g_balance_fireball_secondary_ammo;
294 self.fireball_load = self.clip_load;
297 self.ammo_fuel -= autocvar_g_balance_fireball_secondary_ammo;
300 c = mod(self.bulletcounter, 4);
304 f_diff = '-1.25 -3.75 0';
307 f_diff = '+1.25 -3.75 0';
310 f_diff = '-1.25 +3.75 0';
314 f_diff = '+1.25 +3.75 0';
317 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", CHAN_WEAPON, autocvar_g_balance_fireball_secondary_damage);
318 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
319 w_shotorg = trace_endpos;
321 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
324 proj.owner = proj.realowner = self;
325 proj.classname = "grenade";
326 proj.bot_dodge = TRUE;
327 proj.bot_dodgerating = autocvar_g_balance_fireball_secondary_damage;
328 proj.movetype = MOVETYPE_BOUNCE;
329 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
330 proj.touch = W_Firemine_Touch;
331 PROJECTILE_MAKETRIGGER(proj);
332 setsize(proj, '-4 -4 -4', '4 4 4');
333 setorigin(proj, w_shotorg);
334 proj.think = W_Firemine_Think;
335 proj.nextthink = time;
336 proj.damageforcescale = autocvar_g_balance_fireball_secondary_damageforcescale;
337 proj.pushltime = time + autocvar_g_balance_fireball_secondary_lifetime;
338 W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_fireball_secondary);
340 proj.angles = vectoangles(proj.velocity);
341 proj.flags = FL_PROJECTILE;
343 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
345 other = proj; MUTATOR_CALLHOOK(EditProjectile);
348 void spawnfunc_weapon_fireball (void)
350 weapon_defaultspawnfunc(WEP_FIREBALL);
353 float w_fireball(float req)
358 self.BUTTON_ATCK = FALSE;
359 self.BUTTON_ATCK2 = FALSE;
360 if (self.bot_primary_fireballmooth == 0)
362 if(bot_aim(autocvar_g_balance_fireball_primary_speed, 0, autocvar_g_balance_fireball_primary_lifetime, FALSE))
364 self.BUTTON_ATCK = TRUE;
365 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
370 if(bot_aim(autocvar_g_balance_fireball_secondary_speed, autocvar_g_balance_fireball_secondary_speed_up, autocvar_g_balance_fireball_secondary_lifetime, TRUE))
372 self.BUTTON_ATCK2 = TRUE;
373 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
377 else if (req == WR_THINK)
379 if(autocvar_g_balance_fireball_reload_ammo && self.clip_load < min(autocvar_g_balance_fireball_primary_ammo, autocvar_g_balance_fireball_secondary_ammo)) // forced reload
381 else if (self.BUTTON_ATCK)
383 if (time >= self.fireball_primarytime)
384 if (weapon_prepareattack(0, autocvar_g_balance_fireball_primary_refire))
386 W_Fireball_Attack1_Frame0();
387 self.fireball_primarytime = time + autocvar_g_balance_fireball_primary_refire2;
390 else if (self.BUTTON_ATCK2)
392 if (weapon_prepareattack(1, autocvar_g_balance_fireball_secondary_refire))
394 W_Fireball_Attack2();
395 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_fireball_secondary_animtime, w_ready);
399 else if (req == WR_PRECACHE)
401 precache_model ("models/weapons/g_fireball.md3");
402 precache_model ("models/weapons/v_fireball.md3");
403 precache_model ("models/weapons/h_fireball.iqm");
404 precache_model ("models/sphere/sphere.md3");
405 precache_sound ("weapons/fireball_fire.wav");
406 precache_sound ("weapons/fireball_fire2.wav");
407 precache_sound ("weapons/fireball_prefire2.wav");
408 precache_sound ("weapons/reload.wav");
410 else if (req == WR_SETUP)
412 weapon_setup(WEP_FIREBALL);
413 W_Fireball_SetAmmoCounter();
415 else if (req == WR_CHECKAMMO1)
417 ammo_amount = self.ammo_fuel >= autocvar_g_balance_fireball_primary_ammo;
418 ammo_amount += self.fireball_load >= autocvar_g_balance_fireball_primary_ammo;
421 else if (req == WR_CHECKAMMO2)
423 ammo_amount = self.ammo_fuel >= autocvar_g_balance_fireball_secondary_ammo;
424 ammo_amount += self.fireball_load >= autocvar_g_balance_fireball_secondary_ammo;
427 else if (req == WR_RESETPLAYER)
429 self.fireball_primarytime = time;
431 // all weapons must be fully loaded when we spawn
432 self.fireball_load = autocvar_g_balance_fireball_reload_ammo;
434 else if (req == WR_RELOAD)
442 float w_fireball(float req)
444 if(req == 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, CHAN_PROJECTILE, "weapons/fireball_impact2.wav", VOL_BASE, ATTN_NORM * 0.25); // long range boom
459 else if(req == WR_PRECACHE)
461 precache_sound("weapons/fireball_impact2.wav");
463 else if (req == WR_SUICIDEMESSAGE)
465 if(w_deathtype & HITTYPE_SECONDARY)
466 w_deathtypestring = _("%s forgot about some firemine");
468 w_deathtypestring = _("%s should have used a smaller gun");
470 else if (req == WR_KILLMESSAGE)
472 if(w_deathtype & HITTYPE_SECONDARY)
474 if(w_deathtype & HITTYPE_HEADSHOT)
475 w_deathtypestring = _("%s tried to catch %s's firemine");
477 w_deathtypestring = _("%s fatefully ignored %s's firemine");
481 if(w_deathtype & HITTYPE_BOUNCE)
483 if(w_deathtype & HITTYPE_SPLASH) // BFG effect
484 w_deathtypestring = _("%s could not hide from %s's fireball");
486 w_deathtypestring = _("%s saw the pretty lights of %s's fireball");
488 else if(w_deathtype & HITTYPE_SPLASH)
489 w_deathtypestring = _("%s got too close to %s's fireball");
491 w_deathtypestring = _("%s tasted %s's fireball");