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_Explode (void)
17 self.event_damage = SUB_Null;
18 self.takedamage = DAMAGE_NO;
21 d = (self.realowner.health + self.realowner.armorvalue);
22 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);
23 if(self.realowner.health + self.realowner.armorvalue >= d)
26 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);
29 // NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
30 for(e = findradius(self.origin, autocvar_g_balance_fireball_primary_bfgradius); e; e = e.chain)
31 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(e.classname != "player" || !self.realowner || IsDifferentTeam(e, self))
33 // can we see fireball?
34 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
35 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
37 // can we see player who shot fireball?
38 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
39 if(trace_ent != self.realowner)
40 if(/* trace_startsolid || */ trace_fraction != 1)
42 dist = vlen(self.origin - e.origin - e.view_ofs);
43 points = (1 - sqrt(dist / autocvar_g_balance_fireball_primary_bfgradius));
46 dir = normalize(e.origin + e.view_ofs - self.origin);
48 if(accuracy_isgooddamage(self.realowner, e))
49 accuracy_add(self.realowner, WEP_FIREBALL, 0, autocvar_g_balance_fireball_primary_bfgdamage * points);
51 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);
52 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
59 void W_Fireball_TouchExplode (void)
62 W_Fireball_Explode ();
65 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
74 RandomSelection_Init();
75 for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain)
76 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(e.classname != "player" || !self.realowner || IsDifferentTeam(e, self))
79 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
80 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
81 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
82 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
85 e.fireball_impactvec = p;
86 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
89 if(RandomSelection_chosen_ent)
91 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
92 d = damage + (edgedamage - damage) * (d / dist);
93 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
94 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
95 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
99 void W_Fireball_Think()
101 if(time > self.pushltime)
104 self.projectiledeathtype |= HITTYPE_SPLASH;
105 W_Fireball_Explode();
109 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);
111 self.nextthink = time + 0.1;
114 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
119 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
120 return; // g_projectiles_damage says to halt
122 self.health = self.health - damage;
123 if (self.health <= 0)
126 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
130 void W_Fireball_Attack1()
134 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 2, "weapons/fireball_fire2.wav", CH_WEAPON_A, autocvar_g_balance_fireball_primary_damage + autocvar_g_balance_fireball_primary_bfgdamage);
136 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
139 proj.classname = "plasma_prim";
140 proj.owner = proj.realowner = self;
141 proj.bot_dodge = TRUE;
142 proj.bot_dodgerating = autocvar_g_balance_fireball_primary_damage;
143 proj.pushltime = time + autocvar_g_balance_fireball_primary_lifetime;
144 proj.use = W_Fireball_Explode;
145 proj.think = W_Fireball_Think;
146 proj.nextthink = time;
147 proj.health = autocvar_g_balance_fireball_primary_health;
148 proj.team = self.team;
149 proj.event_damage = W_Fireball_Damage;
150 proj.takedamage = DAMAGE_YES;
151 proj.damageforcescale = autocvar_g_balance_fireball_primary_damageforcescale;
152 PROJECTILE_MAKETRIGGER(proj);
153 proj.projectiledeathtype = WEP_FIREBALL;
154 setorigin(proj, w_shotorg);
156 proj.movetype = MOVETYPE_FLY;
157 W_SETUPPROJECTILEVELOCITY(proj, g_balance_fireball_primary);
158 proj.angles = vectoangles(proj.velocity);
159 proj.touch = W_Fireball_TouchExplode;
160 setsize(proj, '-16 -16 -16', '16 16 16');
161 proj.flags = FL_PROJECTILE;
163 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
165 other = proj; MUTATOR_CALLHOOK(EditProjectile);
168 void W_Fireball_AttackEffect(float i, vector f_diff)
170 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0, 0);
171 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
172 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
175 void W_Fireball_Attack1_Frame4()
177 W_Fireball_Attack1();
178 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, w_ready);
181 void W_Fireball_Attack1_Frame3()
183 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
184 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame4);
187 void W_Fireball_Attack1_Frame2()
189 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
190 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame3);
193 void W_Fireball_Attack1_Frame1()
195 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
196 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame2);
199 void W_Fireball_Attack1_Frame0()
201 W_DecreaseAmmo(ammo_fuel, autocvar_g_balance_fireball_primary_ammo, autocvar_g_balance_fireball_reload_ammo);
203 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
204 sound (self, CH_WEAPON_SINGLE, "weapons/fireball_prefire2.wav", VOL_BASE, ATTN_NORM);
205 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame1);
208 void W_Firemine_Think()
210 if(time > self.pushltime)
216 // make it "hot" once it leaves its owner
219 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > autocvar_g_balance_fireball_secondary_laserradius)
229 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);
231 self.nextthink = time + 0.1;
234 void W_Firemine_Touch (void)
237 if (other.takedamage == DAMAGE_AIM)
238 if(Fire_AddDamage(other, self.realowner, autocvar_g_balance_fireball_secondary_damage, autocvar_g_balance_fireball_secondary_damagetime, self.projectiledeathtype | HITTYPE_HEADSHOT) >= 0)
243 self.projectiledeathtype |= HITTYPE_BOUNCE;
246 void W_Fireball_Attack2()
252 W_DecreaseAmmo(ammo_fuel, autocvar_g_balance_fireball_secondary_ammo, autocvar_g_balance_fireball_reload_ammo);
254 c = mod(self.bulletcounter, 4);
258 f_diff = '-1.25 -3.75 0';
261 f_diff = '+1.25 -3.75 0';
264 f_diff = '-1.25 +3.75 0';
268 f_diff = '+1.25 +3.75 0';
271 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", CH_WEAPON_A, autocvar_g_balance_fireball_secondary_damage);
272 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
273 w_shotorg = trace_endpos;
275 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
278 proj.owner = proj.realowner = self;
279 proj.classname = "grenade";
280 proj.bot_dodge = TRUE;
281 proj.bot_dodgerating = autocvar_g_balance_fireball_secondary_damage;
282 proj.movetype = MOVETYPE_BOUNCE;
283 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
284 proj.touch = W_Firemine_Touch;
285 PROJECTILE_MAKETRIGGER(proj);
286 setsize(proj, '-4 -4 -4', '4 4 4');
287 setorigin(proj, w_shotorg);
288 proj.think = W_Firemine_Think;
289 proj.nextthink = time;
290 proj.damageforcescale = autocvar_g_balance_fireball_secondary_damageforcescale;
291 proj.pushltime = time + autocvar_g_balance_fireball_secondary_lifetime;
292 W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_fireball_secondary);
294 proj.angles = vectoangles(proj.velocity);
295 proj.flags = FL_PROJECTILE;
297 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
299 other = proj; MUTATOR_CALLHOOK(EditProjectile);
302 void spawnfunc_weapon_fireball (void)
304 weapon_defaultspawnfunc(WEP_FIREBALL);
307 float w_fireball(float req)
312 self.BUTTON_ATCK = FALSE;
313 self.BUTTON_ATCK2 = FALSE;
314 if (self.bot_primary_fireballmooth == 0)
316 if(bot_aim(autocvar_g_balance_fireball_primary_speed, 0, autocvar_g_balance_fireball_primary_lifetime, FALSE))
318 self.BUTTON_ATCK = TRUE;
319 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
324 if(bot_aim(autocvar_g_balance_fireball_secondary_speed, autocvar_g_balance_fireball_secondary_speed_up, autocvar_g_balance_fireball_secondary_lifetime, TRUE))
326 self.BUTTON_ATCK2 = TRUE;
327 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
331 else if (req == WR_THINK)
333 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
334 weapon_action(self.weapon, WR_RELOAD);
335 else if (self.BUTTON_ATCK)
337 if (time >= self.fireball_primarytime)
338 if (weapon_prepareattack(0, autocvar_g_balance_fireball_primary_refire))
340 W_Fireball_Attack1_Frame0();
341 self.fireball_primarytime = time + autocvar_g_balance_fireball_primary_refire2 * W_WeaponRateFactor();
344 else if (self.BUTTON_ATCK2)
346 if (weapon_prepareattack(1, autocvar_g_balance_fireball_secondary_refire))
348 W_Fireball_Attack2();
349 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_fireball_secondary_animtime, w_ready);
353 else if (req == WR_PRECACHE)
355 precache_model ("models/weapons/g_fireball.md3");
356 precache_model ("models/weapons/v_fireball.md3");
357 precache_model ("models/weapons/h_fireball.iqm");
358 precache_model ("models/sphere/sphere.md3");
359 precache_sound ("weapons/fireball_fire.wav");
360 precache_sound ("weapons/fireball_fire2.wav");
361 precache_sound ("weapons/fireball_prefire2.wav");
362 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
364 else if (req == WR_SETUP)
366 weapon_setup(WEP_FIREBALL);
367 self.current_ammo = ammo_fuel;
369 else if (req == WR_CHECKAMMO1)
371 ammo_amount = self.ammo_fuel >= autocvar_g_balance_fireball_primary_ammo;
372 ammo_amount += self.(weapon_load[WEP_FIREBALL]) >= autocvar_g_balance_fireball_primary_ammo;
375 else if (req == WR_CHECKAMMO2)
377 ammo_amount = self.ammo_fuel >= autocvar_g_balance_fireball_secondary_ammo;
378 ammo_amount += self.(weapon_load[WEP_FIREBALL]) >= autocvar_g_balance_fireball_secondary_ammo;
381 else if (req == WR_RESETPLAYER)
383 self.fireball_primarytime = time;
385 else if (req == WR_RELOAD)
387 // fuel can be a non-whole number, which brakes stuff here when between 0 and 1
388 if(self.ammo_fuel < 1)
391 W_Reload(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");
397 float w_fireball(float req)
399 if(req == WR_IMPACTEFFECT)
402 if(w_deathtype & HITTYPE_SECONDARY)
404 // firemine goes out silently
408 org2 = w_org + w_backoff * 16;
409 pointparticles(particleeffectnum("fireball_explode"), org2, '0 0 0', 1);
411 sound(self, CH_SHOTS, "weapons/fireball_impact2.wav", VOL_BASE, ATTN_NORM * 0.25); // long range boom
414 else if(req == WR_PRECACHE)
416 precache_sound("weapons/fireball_impact2.wav");
418 else if (req == WR_SUICIDEMESSAGE)
420 if(w_deathtype & HITTYPE_SECONDARY)
421 w_deathtypestring = _("%s forgot about some firemine");
423 w_deathtypestring = _("%s should have used a smaller gun");
425 else if (req == WR_KILLMESSAGE)
427 if(w_deathtype & HITTYPE_SECONDARY)
429 if(w_deathtype & HITTYPE_HEADSHOT)
430 w_deathtypestring = _("%s tried to catch %s's firemine");
432 w_deathtypestring = _("%s fatefully ignored %s's firemine");
436 if(w_deathtype & HITTYPE_BOUNCE)
438 if(w_deathtype & HITTYPE_SPLASH) // BFG effect
439 w_deathtypestring = _("%s could not hide from %s's fireball");
441 w_deathtypestring = _("%s saw the pretty lights of %s's fireball");
443 else if(w_deathtype & HITTYPE_SPLASH)
444 w_deathtypestring = _("%s got too close to %s's fireball");
446 w_deathtypestring = _("%s tasted %s's fireball");