2 REGISTER_WEAPON(FIREBALL, w_fireball, IT_FUEL, 9, WEP_FLAG_RELOADABLE | 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 void W_Fireball_Reload()
11 // fuel can be a non-whole number, which brakes stuff here when between 0 and 1
12 if(self.ammo_fuel < 1)
15 self.reload_ammo_player = ammo_fuel;
16 self.reload_ammo_min = min(autocvar_g_balance_fireball_primary_ammo, autocvar_g_balance_fireball_secondary_ammo);
17 self.reload_ammo_amount = autocvar_g_balance_fireball_reload_ammo;
18 self.reload_time = autocvar_g_balance_fireball_reload_time;
19 self.reload_sound = "weapons/reload.wav";
24 void W_Fireball_Explode (void)
32 self.event_damage = SUB_Null;
33 self.takedamage = DAMAGE_NO;
36 d = (self.owner.health + self.owner.armorvalue);
37 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);
38 if(self.realowner.health + self.realowner.armorvalue >= d)
41 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);
44 // NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
45 for(e = findradius(self.origin, autocvar_g_balance_fireball_primary_bfgradius); e; e = e.chain)
46 if(e != self.owner) if(e.takedamage == DAMAGE_AIM) if(e.classname != "player" || !self.owner || IsDifferentTeam(e, self))
48 // can we see fireball?
49 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
50 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
52 // can we see player who shot fireball?
53 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
54 if(trace_ent != self.realowner)
55 if(/* trace_startsolid || */ trace_fraction != 1)
57 dist = vlen(self.origin - e.origin - e.view_ofs);
58 points = (1 - sqrt(dist / autocvar_g_balance_fireball_primary_bfgradius));
61 dir = normalize(e.origin + e.view_ofs - self.origin);
63 if(accuracy_isgooddamage(self.realowner, e))
64 accuracy_add(self.realowner, WEP_FIREBALL, 0, autocvar_g_balance_fireball_primary_bfgdamage * points);
66 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);
67 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
74 void W_Fireball_TouchExplode (void)
77 W_Fireball_Explode ();
80 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
89 RandomSelection_Init();
90 for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain)
91 if(e != self.owner) if(e.takedamage == DAMAGE_AIM) if(e.classname != "player" || !self.owner || IsDifferentTeam(e, self))
94 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
95 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
96 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
97 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
100 e.fireball_impactvec = p;
101 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
104 if(RandomSelection_chosen_ent)
106 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
107 d = damage + (edgedamage - damage) * (d / dist);
108 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
109 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
110 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
114 void W_Fireball_Think()
116 if(time > self.pushltime)
119 self.projectiledeathtype |= HITTYPE_SPLASH;
120 W_Fireball_Explode();
124 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);
126 self.nextthink = time + 0.1;
129 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
133 self.health = self.health - damage;
134 if (self.health <= 0)
137 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
141 void W_Fireball_Attack1()
145 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);
147 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
150 proj.classname = "plasma_prim";
151 proj.owner = proj.realowner = self;
152 proj.bot_dodge = TRUE;
153 proj.bot_dodgerating = autocvar_g_balance_fireball_primary_damage;
154 proj.pushltime = time + autocvar_g_balance_fireball_primary_lifetime;
155 proj.use = W_Fireball_Explode;
156 proj.think = W_Fireball_Think;
157 proj.nextthink = time;
158 proj.health = autocvar_g_balance_fireball_primary_health;
159 proj.team = self.team;
160 proj.event_damage = W_Fireball_Damage;
161 proj.takedamage = DAMAGE_YES;
162 proj.damageforcescale = autocvar_g_balance_fireball_primary_damageforcescale;
163 PROJECTILE_MAKETRIGGER(proj);
164 proj.projectiledeathtype = WEP_FIREBALL;
165 setorigin(proj, w_shotorg);
167 proj.movetype = MOVETYPE_FLY;
168 W_SETUPPROJECTILEVELOCITY(proj, g_balance_fireball_primary);
169 proj.angles = vectoangles(proj.velocity);
170 proj.touch = W_Fireball_TouchExplode;
171 setsize(proj, '-16 -16 -16', '16 16 16');
172 proj.flags = FL_PROJECTILE;
174 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
176 other = proj; MUTATOR_CALLHOOK(EditProjectile);
179 void W_Fireball_AttackEffect(float i, vector f_diff)
181 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0, 0);
182 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
183 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
186 void W_Fireball_Attack1_Frame4()
188 W_Fireball_Attack1();
189 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, w_ready);
192 void W_Fireball_Attack1_Frame3()
194 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
195 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame4);
198 void W_Fireball_Attack1_Frame2()
200 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
201 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame3);
204 void W_Fireball_Attack1_Frame1()
206 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
207 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame2);
210 void W_Fireball_Attack1_Frame0()
212 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
213 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
215 if(autocvar_g_balance_fireball_reload_ammo)
217 self.clip_load -= autocvar_g_balance_fireball_primary_ammo;
218 self.weapon_load[WEP_FIREBALL] = self.clip_load;
221 self.ammo_fuel -= autocvar_g_balance_fireball_primary_ammo;
224 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
225 sound (self, CHAN_WEAPON, "weapons/fireball_prefire2.wav", VOL_BASE, ATTN_NORM);
226 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame1);
229 void W_Firemine_Think()
231 if(time > self.pushltime)
237 // make it "hot" once it leaves its owner
240 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > autocvar_g_balance_fireball_secondary_laserradius)
250 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);
252 self.nextthink = time + 0.1;
255 void W_Firemine_Touch (void)
258 if (other.takedamage == DAMAGE_AIM)
259 if(Fire_AddDamage(other, self.realowner, autocvar_g_balance_fireball_secondary_damage, autocvar_g_balance_fireball_secondary_damagetime, self.projectiledeathtype | HITTYPE_HEADSHOT) >= 0)
264 self.projectiledeathtype |= HITTYPE_BOUNCE;
267 void W_Fireball_Attack2()
273 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
274 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
276 if(autocvar_g_balance_fireball_reload_ammo)
278 self.clip_load -= autocvar_g_balance_fireball_secondary_ammo;
279 self.weapon_load[WEP_FIREBALL] = self.clip_load;
282 self.ammo_fuel -= autocvar_g_balance_fireball_secondary_ammo;
285 c = mod(self.bulletcounter, 4);
289 f_diff = '-1.25 -3.75 0';
292 f_diff = '+1.25 -3.75 0';
295 f_diff = '-1.25 +3.75 0';
299 f_diff = '+1.25 +3.75 0';
302 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", CHAN_WEAPON, autocvar_g_balance_fireball_secondary_damage);
303 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
304 w_shotorg = trace_endpos;
306 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
309 proj.owner = proj.realowner = self;
310 proj.classname = "grenade";
311 proj.bot_dodge = TRUE;
312 proj.bot_dodgerating = autocvar_g_balance_fireball_secondary_damage;
313 proj.movetype = MOVETYPE_BOUNCE;
314 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
315 proj.touch = W_Firemine_Touch;
316 PROJECTILE_MAKETRIGGER(proj);
317 setsize(proj, '-4 -4 -4', '4 4 4');
318 setorigin(proj, w_shotorg);
319 proj.think = W_Firemine_Think;
320 proj.nextthink = time;
321 proj.damageforcescale = autocvar_g_balance_fireball_secondary_damageforcescale;
322 proj.pushltime = time + autocvar_g_balance_fireball_secondary_lifetime;
323 W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_fireball_secondary);
325 proj.angles = vectoangles(proj.velocity);
326 proj.flags = FL_PROJECTILE;
328 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
330 other = proj; MUTATOR_CALLHOOK(EditProjectile);
333 void spawnfunc_weapon_fireball (void)
335 weapon_defaultspawnfunc(WEP_FIREBALL);
338 float w_fireball(float req)
343 self.BUTTON_ATCK = FALSE;
344 self.BUTTON_ATCK2 = FALSE;
345 if (self.bot_primary_fireballmooth == 0)
347 if(bot_aim(autocvar_g_balance_fireball_primary_speed, 0, autocvar_g_balance_fireball_primary_lifetime, FALSE))
349 self.BUTTON_ATCK = TRUE;
350 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
355 if(bot_aim(autocvar_g_balance_fireball_secondary_speed, autocvar_g_balance_fireball_secondary_speed_up, autocvar_g_balance_fireball_secondary_lifetime, TRUE))
357 self.BUTTON_ATCK2 = TRUE;
358 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
362 else if (req == WR_THINK)
364 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
366 else if (self.BUTTON_ATCK)
368 if (time >= self.fireball_primarytime)
369 if (weapon_prepareattack(0, autocvar_g_balance_fireball_primary_refire))
371 W_Fireball_Attack1_Frame0();
372 self.fireball_primarytime = time + autocvar_g_balance_fireball_primary_refire2;
375 else if (self.BUTTON_ATCK2)
377 if (weapon_prepareattack(1, autocvar_g_balance_fireball_secondary_refire))
379 W_Fireball_Attack2();
380 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_fireball_secondary_animtime, w_ready);
384 else if (req == WR_PRECACHE)
386 precache_model ("models/weapons/g_fireball.md3");
387 precache_model ("models/weapons/v_fireball.md3");
388 precache_model ("models/weapons/h_fireball.iqm");
389 precache_model ("models/sphere/sphere.md3");
390 precache_sound ("weapons/fireball_fire.wav");
391 precache_sound ("weapons/fireball_fire2.wav");
392 precache_sound ("weapons/fireball_prefire2.wav");
393 precache_sound ("weapons/reload.wav");
395 else if (req == WR_SETUP)
397 weapon_setup(WEP_FIREBALL);
399 else if (req == WR_CHECKAMMO1)
401 ammo_amount = self.ammo_fuel >= autocvar_g_balance_fireball_primary_ammo;
402 ammo_amount += self.weapon_load[WEP_FIREBALL] >= autocvar_g_balance_fireball_primary_ammo;
405 else if (req == WR_CHECKAMMO2)
407 ammo_amount = self.ammo_fuel >= autocvar_g_balance_fireball_secondary_ammo;
408 ammo_amount += self.weapon_load[WEP_FIREBALL] >= autocvar_g_balance_fireball_secondary_ammo;
411 else if (req == WR_RESETPLAYER)
413 self.fireball_primarytime = time;
415 else if (req == WR_RELOAD)
423 float w_fireball(float req)
425 if(req == WR_IMPACTEFFECT)
428 if(w_deathtype & HITTYPE_SECONDARY)
430 // firemine goes out silently
434 org2 = w_org + w_backoff * 16;
435 pointparticles(particleeffectnum("fireball_explode"), org2, '0 0 0', 1);
437 sound(self, CHAN_PROJECTILE, "weapons/fireball_impact2.wav", VOL_BASE, ATTN_NORM * 0.25); // long range boom
440 else if(req == WR_PRECACHE)
442 precache_sound("weapons/fireball_impact2.wav");
444 else if (req == WR_SUICIDEMESSAGE)
446 if(w_deathtype & HITTYPE_SECONDARY)
447 w_deathtypestring = _("%s forgot about some firemine");
449 w_deathtypestring = _("%s should have used a smaller gun");
451 else if (req == WR_KILLMESSAGE)
453 if(w_deathtype & HITTYPE_SECONDARY)
455 if(w_deathtype & HITTYPE_HEADSHOT)
456 w_deathtypestring = _("%s tried to catch %s's firemine");
458 w_deathtypestring = _("%s fatefully ignored %s's firemine");
462 if(w_deathtype & HITTYPE_BOUNCE)
464 if(w_deathtype & HITTYPE_SPLASH) // BFG effect
465 w_deathtypestring = _("%s could not hide from %s's fireball");
467 w_deathtypestring = _("%s saw the pretty lights of %s's fireball");
469 else if(w_deathtype & HITTYPE_SPLASH)
470 w_deathtypestring = _("%s got too close to %s's fireball");
472 w_deathtypestring = _("%s tasted %s's fireball");