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 W_Reload(ammo_fuel, min(autocvar_g_balance_fireball_primary_ammo, autocvar_g_balance_fireball_secondary_ammo), autocvar_g_balance_fireball_reload_ammo, autocvar_g_balance_fireball_reload_time, "weapons/reload.wav");
18 void W_Fireball_Explode (void)
26 self.event_damage = SUB_Null;
27 self.takedamage = DAMAGE_NO;
30 d = (self.owner.health + self.owner.armorvalue);
31 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);
32 if(self.realowner.health + self.realowner.armorvalue >= d)
35 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);
38 // NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
39 for(e = findradius(self.origin, autocvar_g_balance_fireball_primary_bfgradius); e; e = e.chain)
40 if(e != self.owner) if(e.takedamage == DAMAGE_AIM) if(e.classname != "player" || !self.owner || IsDifferentTeam(e, self))
42 // can we see fireball?
43 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
44 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
46 // can we see player who shot fireball?
47 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
48 if(trace_ent != self.realowner)
49 if(/* trace_startsolid || */ trace_fraction != 1)
51 dist = vlen(self.origin - e.origin - e.view_ofs);
52 points = (1 - sqrt(dist / autocvar_g_balance_fireball_primary_bfgradius));
55 dir = normalize(e.origin + e.view_ofs - self.origin);
57 if(accuracy_isgooddamage(self.realowner, e))
58 accuracy_add(self.realowner, WEP_FIREBALL, 0, autocvar_g_balance_fireball_primary_bfgdamage * points);
60 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);
61 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
68 void W_Fireball_TouchExplode (void)
71 W_Fireball_Explode ();
74 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
83 RandomSelection_Init();
84 for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain)
85 if(e != self.owner) if(e.takedamage == DAMAGE_AIM) if(e.classname != "player" || !self.owner || IsDifferentTeam(e, self))
88 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
89 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
90 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
91 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
94 e.fireball_impactvec = p;
95 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
98 if(RandomSelection_chosen_ent)
100 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
101 d = damage + (edgedamage - damage) * (d / dist);
102 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
103 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
104 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
108 void W_Fireball_Think()
110 if(time > self.pushltime)
113 self.projectiledeathtype |= HITTYPE_SPLASH;
114 W_Fireball_Explode();
118 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);
120 self.nextthink = time + 0.1;
123 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
127 self.health = self.health - damage;
128 if (self.health <= 0)
131 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
135 void W_Fireball_Attack1()
139 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);
141 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
144 proj.classname = "plasma_prim";
145 proj.owner = proj.realowner = self;
146 proj.bot_dodge = TRUE;
147 proj.bot_dodgerating = autocvar_g_balance_fireball_primary_damage;
148 proj.pushltime = time + autocvar_g_balance_fireball_primary_lifetime;
149 proj.use = W_Fireball_Explode;
150 proj.think = W_Fireball_Think;
151 proj.nextthink = time;
152 proj.health = autocvar_g_balance_fireball_primary_health;
153 proj.team = self.team;
154 proj.event_damage = W_Fireball_Damage;
155 proj.takedamage = DAMAGE_YES;
156 proj.damageforcescale = autocvar_g_balance_fireball_primary_damageforcescale;
157 PROJECTILE_MAKETRIGGER(proj);
158 proj.projectiledeathtype = WEP_FIREBALL;
159 setorigin(proj, w_shotorg);
161 proj.movetype = MOVETYPE_FLY;
162 W_SETUPPROJECTILEVELOCITY(proj, g_balance_fireball_primary);
163 proj.angles = vectoangles(proj.velocity);
164 proj.touch = W_Fireball_TouchExplode;
165 setsize(proj, '-16 -16 -16', '16 16 16');
166 proj.flags = FL_PROJECTILE;
168 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
170 other = proj; MUTATOR_CALLHOOK(EditProjectile);
173 void W_Fireball_AttackEffect(float i, vector f_diff)
175 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0, 0);
176 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
177 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
180 void W_Fireball_Attack1_Frame4()
182 W_Fireball_Attack1();
183 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, w_ready);
186 void W_Fireball_Attack1_Frame3()
188 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
189 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame4);
192 void W_Fireball_Attack1_Frame2()
194 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
195 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame3);
198 void W_Fireball_Attack1_Frame1()
200 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
201 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame2);
204 void W_Fireball_Attack1_Frame0()
206 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
207 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
209 if(autocvar_g_balance_fireball_reload_ammo)
211 self.clip_load -= autocvar_g_balance_fireball_primary_ammo;
212 self.weapon_load[WEP_FIREBALL] = self.clip_load;
215 self.ammo_fuel -= autocvar_g_balance_fireball_primary_ammo;
218 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
219 sound (self, CHAN_WEAPON, "weapons/fireball_prefire2.wav", VOL_BASE, ATTN_NORM);
220 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame1);
223 void W_Firemine_Think()
225 if(time > self.pushltime)
231 // make it "hot" once it leaves its owner
234 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > autocvar_g_balance_fireball_secondary_laserradius)
244 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);
246 self.nextthink = time + 0.1;
249 void W_Firemine_Touch (void)
252 if (other.takedamage == DAMAGE_AIM)
253 if(Fire_AddDamage(other, self.realowner, autocvar_g_balance_fireball_secondary_damage, autocvar_g_balance_fireball_secondary_damagetime, self.projectiledeathtype | HITTYPE_HEADSHOT) >= 0)
258 self.projectiledeathtype |= HITTYPE_BOUNCE;
261 void W_Fireball_Attack2()
267 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
268 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
270 if(autocvar_g_balance_fireball_reload_ammo)
272 self.clip_load -= autocvar_g_balance_fireball_secondary_ammo;
273 self.weapon_load[WEP_FIREBALL] = self.clip_load;
276 self.ammo_fuel -= autocvar_g_balance_fireball_secondary_ammo;
279 c = mod(self.bulletcounter, 4);
283 f_diff = '-1.25 -3.75 0';
286 f_diff = '+1.25 -3.75 0';
289 f_diff = '-1.25 +3.75 0';
293 f_diff = '+1.25 +3.75 0';
296 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", CHAN_WEAPON, autocvar_g_balance_fireball_secondary_damage);
297 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
298 w_shotorg = trace_endpos;
300 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
303 proj.owner = proj.realowner = self;
304 proj.classname = "grenade";
305 proj.bot_dodge = TRUE;
306 proj.bot_dodgerating = autocvar_g_balance_fireball_secondary_damage;
307 proj.movetype = MOVETYPE_BOUNCE;
308 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
309 proj.touch = W_Firemine_Touch;
310 PROJECTILE_MAKETRIGGER(proj);
311 setsize(proj, '-4 -4 -4', '4 4 4');
312 setorigin(proj, w_shotorg);
313 proj.think = W_Firemine_Think;
314 proj.nextthink = time;
315 proj.damageforcescale = autocvar_g_balance_fireball_secondary_damageforcescale;
316 proj.pushltime = time + autocvar_g_balance_fireball_secondary_lifetime;
317 W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_fireball_secondary);
319 proj.angles = vectoangles(proj.velocity);
320 proj.flags = FL_PROJECTILE;
322 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
324 other = proj; MUTATOR_CALLHOOK(EditProjectile);
327 void spawnfunc_weapon_fireball (void)
329 weapon_defaultspawnfunc(WEP_FIREBALL);
332 float w_fireball(float req)
337 self.BUTTON_ATCK = FALSE;
338 self.BUTTON_ATCK2 = FALSE;
339 if (self.bot_primary_fireballmooth == 0)
341 if(bot_aim(autocvar_g_balance_fireball_primary_speed, 0, autocvar_g_balance_fireball_primary_lifetime, FALSE))
343 self.BUTTON_ATCK = TRUE;
344 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
349 if(bot_aim(autocvar_g_balance_fireball_secondary_speed, autocvar_g_balance_fireball_secondary_speed_up, autocvar_g_balance_fireball_secondary_lifetime, TRUE))
351 self.BUTTON_ATCK2 = TRUE;
352 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
356 else if (req == WR_THINK)
358 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
360 else if (self.BUTTON_ATCK)
362 if (time >= self.fireball_primarytime)
363 if (weapon_prepareattack(0, autocvar_g_balance_fireball_primary_refire))
365 W_Fireball_Attack1_Frame0();
366 self.fireball_primarytime = time + autocvar_g_balance_fireball_primary_refire2;
369 else if (self.BUTTON_ATCK2)
371 if (weapon_prepareattack(1, autocvar_g_balance_fireball_secondary_refire))
373 W_Fireball_Attack2();
374 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_fireball_secondary_animtime, w_ready);
378 else if (req == WR_PRECACHE)
380 precache_model ("models/weapons/g_fireball.md3");
381 precache_model ("models/weapons/v_fireball.md3");
382 precache_model ("models/weapons/h_fireball.iqm");
383 precache_model ("models/sphere/sphere.md3");
384 precache_sound ("weapons/fireball_fire.wav");
385 precache_sound ("weapons/fireball_fire2.wav");
386 precache_sound ("weapons/fireball_prefire2.wav");
387 precache_sound ("weapons/reload.wav");
389 else if (req == WR_SETUP)
391 weapon_setup(WEP_FIREBALL);
393 else if (req == WR_CHECKAMMO1)
395 ammo_amount = self.ammo_fuel >= autocvar_g_balance_fireball_primary_ammo;
396 ammo_amount += self.weapon_load[WEP_FIREBALL] >= autocvar_g_balance_fireball_primary_ammo;
399 else if (req == WR_CHECKAMMO2)
401 ammo_amount = self.ammo_fuel >= autocvar_g_balance_fireball_secondary_ammo;
402 ammo_amount += self.weapon_load[WEP_FIREBALL] >= autocvar_g_balance_fireball_secondary_ammo;
405 else if (req == WR_RESETPLAYER)
407 self.fireball_primarytime = time;
409 else if (req == WR_RELOAD)
417 float w_fireball(float req)
419 if(req == WR_IMPACTEFFECT)
422 if(w_deathtype & HITTYPE_SECONDARY)
424 // firemine goes out silently
428 org2 = w_org + w_backoff * 16;
429 pointparticles(particleeffectnum("fireball_explode"), org2, '0 0 0', 1);
431 sound(self, CHAN_PROJECTILE, "weapons/fireball_impact2.wav", VOL_BASE, ATTN_NORM * 0.25); // long range boom
434 else if(req == WR_PRECACHE)
436 precache_sound("weapons/fireball_impact2.wav");
438 else if (req == WR_SUICIDEMESSAGE)
440 if(w_deathtype & HITTYPE_SECONDARY)
441 w_deathtypestring = _("%s forgot about some firemine");
443 w_deathtypestring = _("%s should have used a smaller gun");
445 else if (req == WR_KILLMESSAGE)
447 if(w_deathtype & HITTYPE_SECONDARY)
449 if(w_deathtype & HITTYPE_HEADSHOT)
450 w_deathtypestring = _("%s tried to catch %s's firemine");
452 w_deathtypestring = _("%s fatefully ignored %s's firemine");
456 if(w_deathtype & HITTYPE_BOUNCE)
458 if(w_deathtype & HITTYPE_SPLASH) // BFG effect
459 w_deathtypestring = _("%s could not hide from %s's fireball");
461 w_deathtypestring = _("%s saw the pretty lights of %s's fireball");
463 else if(w_deathtype & HITTYPE_SPLASH)
464 w_deathtypestring = _("%s got too close to %s's fireball");
466 w_deathtypestring = _("%s tasted %s's fireball");