2 REGISTER_WEAPON(FIREBALL, w_fireball, IT_FUEL, 9, WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "fireball", "fireball", "Fireball");
4 .float bot_primary_fireballmooth; // whatever a mooth is
5 .vector fireball_impactvec;
6 .float fireball_primarytime;
8 void W_Fireball_Explode (void)
16 self.event_damage = SUB_Null;
17 self.takedamage = DAMAGE_NO;
20 d = (self.owner.health + self.owner.armorvalue);
21 RadiusDamage (self, self.realowner, cvar("g_balance_fireball_primary_damage"), cvar("g_balance_fireball_primary_edgedamage"), cvar("g_balance_fireball_primary_radius"), world, cvar("g_balance_fireball_primary_force"), self.projectiledeathtype, other);
22 if(self.realowner.health + self.realowner.armorvalue >= d)
25 modeleffect_spawn("models/sphere/sphere.md3", 0, 0, self.origin, '0 0 0', '0 0 0', '0 0 0', 0, cvar("g_balance_fireball_primary_bfgradius"), 0.2, 0.05, 0.25);
28 // NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
29 for(e = findradius(self.origin, cvar("g_balance_fireball_primary_bfgradius")); e; e = e.chain)
30 if(e != self.owner) if(e.takedamage == DAMAGE_AIM) if(e.classname != "player" || !self.owner || IsDifferentTeam(e, self))
32 // can we see fireball?
33 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
34 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
36 // can we see player who shot fireball?
37 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
38 if(trace_ent != self.realowner)
39 if(/* trace_startsolid || */ trace_fraction != 1)
41 dist = vlen(self.origin - e.origin - e.view_ofs);
42 points = (1 - sqrt(dist / cvar("g_balance_fireball_primary_bfgradius")));
45 dir = normalize(e.origin + e.view_ofs - self.origin);
46 Damage(e, self, self.realowner, cvar("g_balance_fireball_primary_bfgdamage") * points, self.projectiledeathtype | HITTYPE_BOUNCE | HITTYPE_SPLASH, e.origin + e.view_ofs, cvar("g_balance_fireball_primary_bfgforce") * dir);
47 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
49 Damage_RecordDamage(self.owner, self.projectiledeathtype, cvar("g_balance_fireball_primary_bfgdamage") * points);
56 void W_Fireball_TouchExplode (void)
59 W_Fireball_Explode ();
62 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
71 RandomSelection_Init();
72 for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain)
73 if(e != self.owner) if(e.takedamage == DAMAGE_AIM) if(e.classname != "player" || !self.owner || IsDifferentTeam(e, self))
76 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
77 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
78 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
79 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
82 e.fireball_impactvec = p;
83 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
86 if(RandomSelection_chosen_ent)
88 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
89 d = damage + (edgedamage - damage) * (d / dist);
90 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
91 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
92 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
96 void W_Fireball_Think()
98 if(time > self.pushltime)
101 W_Fireball_Explode();
105 W_Fireball_LaserPlay(0.1, cvar("g_balance_fireball_primary_laserradius"), cvar("g_balance_fireball_primary_laserdamage"), cvar("g_balance_fireball_primary_laseredgedamage"), cvar("g_balance_fireball_primary_laserburntime"));
107 self.nextthink = time + 0.1;
110 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
114 self.health = self.health - damage;
115 if (self.health <= 0)
118 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
122 void W_Fireball_Attack1()
126 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 2, "weapons/fireball_fire2.wav", cvar("g_balance_fireball_primary_damage") + cvar("g_balance_fireball_primary_bfgdamage"));
128 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
131 proj.classname = "plasma_prim";
132 proj.owner = proj.realowner = self;
133 proj.bot_dodge = TRUE;
134 proj.bot_dodgerating = cvar("g_balance_fireball_primary_damage");
135 proj.pushltime = time + cvar("g_balance_fireball_primary_lifetime");
136 proj.use = W_Fireball_Explode;
137 proj.think = W_Fireball_Think;
138 proj.nextthink = time;
139 proj.health = cvar("g_balance_fireball_primary_health");
140 proj.team = self.team;
141 proj.event_damage = W_Fireball_Damage;
142 proj.takedamage = DAMAGE_YES;
143 proj.damageforcescale = cvar("g_balance_fireball_primary_damageforcescale");
144 PROJECTILE_MAKETRIGGER(proj);
145 proj.projectiledeathtype = WEP_FIREBALL;
146 setorigin(proj, w_shotorg);
148 proj.movetype = MOVETYPE_FLY;
149 W_SETUPPROJECTILEVELOCITY(proj, g_balance_fireball_primary);
150 proj.angles = vectoangles(proj.velocity);
151 proj.touch = W_Fireball_TouchExplode;
152 setsize(proj, '-16 -16 -16', '16 16 16');
153 proj.flags = FL_PROJECTILE;
155 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
158 void W_Fireball_AttackEffect(float i, vector f_diff)
160 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0);
161 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
162 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
165 void W_Fireball_Attack1_Frame4()
167 W_Fireball_Attack1();
168 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_primary_animtime"), w_ready);
171 void W_Fireball_Attack1_Frame3()
173 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
174 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_primary_animtime"), W_Fireball_Attack1_Frame4);
177 void W_Fireball_Attack1_Frame2()
179 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
180 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_primary_animtime"), W_Fireball_Attack1_Frame3);
183 void W_Fireball_Attack1_Frame1()
185 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
186 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_primary_animtime"), W_Fireball_Attack1_Frame2);
189 void W_Fireball_Attack1_Frame0()
191 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
192 self.ammo_fuel = self.ammo_fuel - cvar("g_balance_fireball_primary_ammo");
194 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
195 sound (self, CHAN_WEAPON, "weapons/fireball_prefire2.wav", VOL_BASE, ATTN_NORM);
196 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_primary_animtime"), W_Fireball_Attack1_Frame1);
199 void W_Firemine_Think()
201 if(time > self.pushltime)
207 // make it "hot" once it leaves its owner
210 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > cvar("g_balance_fireball_secondary_laserradius"))
220 W_Fireball_LaserPlay(0.1, cvar("g_balance_fireball_secondary_laserradius"), cvar("g_balance_fireball_secondary_laserdamage"), cvar("g_balance_fireball_secondary_laseredgedamage"), cvar("g_balance_fireball_secondary_laserburntime"));
222 self.nextthink = time + 0.1;
225 void W_Firemine_Touch (void)
228 if (other.takedamage == DAMAGE_AIM)
229 if(Fire_AddDamage(other, self.realowner, cvar("g_balance_fireball_secondary_damage"), cvar("g_balance_fireball_secondary_damagetime"), self.projectiledeathtype | HITTYPE_HEADSHOT) >= 0)
234 self.projectiledeathtype |= HITTYPE_BOUNCE;
237 void W_Fireball_Attack2()
243 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
244 self.ammo_fuel = self.ammo_fuel - cvar("g_balance_fireball_secondary_ammo");
246 c = mod(self.bulletcounter, 4);
250 f_diff = '-1.25 -3.75 0';
253 f_diff = '+1.25 -3.75 0';
256 f_diff = '-1.25 +3.75 0';
260 f_diff = '+1.25 +3.75 0';
263 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", cvar("g_balance_fireball_secondary_damage"));
264 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
265 w_shotorg = trace_endpos;
267 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
270 proj.owner = proj.realowner = self;
271 proj.classname = "grenade";
272 proj.bot_dodge = TRUE;
273 proj.bot_dodgerating = cvar("g_balance_fireball_secondary_damage");
274 proj.movetype = MOVETYPE_BOUNCE;
275 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
276 proj.touch = W_Firemine_Touch;
277 PROJECTILE_MAKETRIGGER(proj);
278 setsize(proj, '-4 -4 -4', '4 4 4');
279 setorigin(proj, w_shotorg);
280 proj.think = W_Firemine_Think;
281 proj.nextthink = time;
282 proj.damageforcescale = cvar("g_balance_fireball_secondary_damageforcescale");
283 proj.pushltime = time + cvar("g_balance_fireball_secondary_lifetime");
284 W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_fireball_secondary);
286 proj.angles = vectoangles(proj.velocity);
287 proj.flags = FL_PROJECTILE;
289 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
292 void spawnfunc_weapon_fireball (void)
294 weapon_defaultspawnfunc(WEP_FIREBALL);
297 float w_fireball(float req)
301 self.BUTTON_ATCK = FALSE;
302 self.BUTTON_ATCK2 = FALSE;
303 if (self.bot_primary_fireballmooth == 0)
305 if(bot_aim(cvar("g_balance_fireball_primary_speed"), 0, cvar("g_balance_fireball_primary_lifetime"), FALSE))
307 self.BUTTON_ATCK = TRUE;
308 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
313 if(bot_aim(cvar("g_balance_fireball_secondary_speed"), cvar("g_balance_fireball_secondary_speed_up"), cvar("g_balance_fireball_secondary_lifetime"), TRUE))
315 self.BUTTON_ATCK2 = TRUE;
316 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
320 else if (req == WR_THINK)
322 if (self.BUTTON_ATCK)
323 if (time >= self.fireball_primarytime)
324 if (weapon_prepareattack(1, cvar("g_balance_fireball_primary_refire")))
326 W_Fireball_Attack1_Frame0();
327 self.fireball_primarytime = time + cvar("g_balance_fireball_primary_refire2");
329 if (self.BUTTON_ATCK2)
330 if (weapon_prepareattack(0, cvar("g_balance_fireball_secondary_refire")))
332 W_Fireball_Attack2();
333 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_fireball_secondary_animtime"), w_ready);
336 else if (req == WR_PRECACHE)
338 precache_model ("models/weapons/g_fireball.md3");
339 precache_model ("models/weapons/v_fireball.md3");
340 precache_model ("models/weapons/h_fireball.iqm");
341 precache_model ("models/sphere/sphere.md3");
342 precache_sound ("weapons/fireball_fire.wav");
343 precache_sound ("weapons/fireball_fire2.wav");
344 precache_sound ("weapons/fireball_prefire2.wav");
346 else if (req == WR_SETUP)
347 weapon_setup(WEP_FIREBALL);
348 else if (req == WR_CHECKAMMO1)
349 return self.ammo_fuel >= cvar("g_balance_fireball_primary_ammo");
350 else if (req == WR_CHECKAMMO2)
351 return self.ammo_fuel >= cvar("g_balance_fireball_secondary_ammo");
352 else if (req == WR_SUICIDEMESSAGE)
354 if(w_deathtype & HITTYPE_SECONDARY)
355 w_deathtypestring = "forgot about some firemine";
357 w_deathtypestring = "should have used a smaller gun";
359 else if (req == WR_KILLMESSAGE)
361 if(w_deathtype & HITTYPE_SECONDARY)
363 if(w_deathtype & HITTYPE_HEADSHOT)
364 w_deathtypestring = "tried to catch #'s firemine";
366 w_deathtypestring = "fatefully ignored #'s firemine";
370 if(w_deathtype & HITTYPE_BOUNCE)
372 if(w_deathtype & HITTYPE_SPLASH) // BFG effect
374 w_deathtypestring = "could not hide from #'s fireball";
378 w_deathtypestring = "saw the pretty lights of #'s fireball";
381 else if(w_deathtype & HITTYPE_SPLASH)
382 w_deathtypestring = "got too close to #'s fireball";
384 w_deathtypestring = "tasted #'s fireball";
387 else if (req == WR_RESETPLAYER)
389 self.fireball_primarytime = time;