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 self.projectiledeathtype |= HITTYPE_SPLASH;
102 W_Fireball_Explode();
106 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"));
108 self.nextthink = time + 0.1;
111 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
115 self.health = self.health - damage;
116 if (self.health <= 0)
119 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
123 void W_Fireball_Attack1()
127 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"));
129 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
132 proj.classname = "plasma_prim";
133 proj.owner = proj.realowner = self;
134 proj.bot_dodge = TRUE;
135 proj.bot_dodgerating = cvar("g_balance_fireball_primary_damage");
136 proj.pushltime = time + cvar("g_balance_fireball_primary_lifetime");
137 proj.use = W_Fireball_Explode;
138 proj.think = W_Fireball_Think;
139 proj.nextthink = time;
140 proj.health = cvar("g_balance_fireball_primary_health");
141 proj.team = self.team;
142 proj.event_damage = W_Fireball_Damage;
143 proj.takedamage = DAMAGE_YES;
144 proj.damageforcescale = cvar("g_balance_fireball_primary_damageforcescale");
145 PROJECTILE_MAKETRIGGER(proj);
146 proj.projectiledeathtype = WEP_FIREBALL;
147 setorigin(proj, w_shotorg);
149 proj.movetype = MOVETYPE_FLY;
150 W_SETUPPROJECTILEVELOCITY(proj, g_balance_fireball_primary);
151 proj.angles = vectoangles(proj.velocity);
152 proj.touch = W_Fireball_TouchExplode;
153 setsize(proj, '-16 -16 -16', '16 16 16');
154 proj.flags = FL_PROJECTILE;
156 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
159 void W_Fireball_AttackEffect(float i, vector f_diff)
161 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0);
162 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
163 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
166 void W_Fireball_Attack1_Frame4()
168 W_Fireball_Attack1();
169 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_primary_animtime"), w_ready);
172 void W_Fireball_Attack1_Frame3()
174 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
175 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_primary_animtime"), W_Fireball_Attack1_Frame4);
178 void W_Fireball_Attack1_Frame2()
180 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
181 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_primary_animtime"), W_Fireball_Attack1_Frame3);
184 void W_Fireball_Attack1_Frame1()
186 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
187 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_primary_animtime"), W_Fireball_Attack1_Frame2);
190 void W_Fireball_Attack1_Frame0()
192 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
193 self.ammo_fuel = self.ammo_fuel - cvar("g_balance_fireball_primary_ammo");
195 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
196 sound (self, CHAN_WEAPON, "weapons/fireball_prefire2.wav", VOL_BASE, ATTN_NORM);
197 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_primary_animtime"), W_Fireball_Attack1_Frame1);
200 void W_Firemine_Think()
202 if(time > self.pushltime)
208 // make it "hot" once it leaves its owner
211 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > cvar("g_balance_fireball_secondary_laserradius"))
221 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"));
223 self.nextthink = time + 0.1;
226 void W_Firemine_Touch (void)
229 if (other.takedamage == DAMAGE_AIM)
230 if(Fire_AddDamage(other, self.realowner, cvar("g_balance_fireball_secondary_damage"), cvar("g_balance_fireball_secondary_damagetime"), self.projectiledeathtype | HITTYPE_HEADSHOT) >= 0)
235 self.projectiledeathtype |= HITTYPE_BOUNCE;
238 void W_Fireball_Attack2()
244 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
245 self.ammo_fuel = self.ammo_fuel - cvar("g_balance_fireball_secondary_ammo");
247 c = mod(self.bulletcounter, 4);
251 f_diff = '-1.25 -3.75 0';
254 f_diff = '+1.25 -3.75 0';
257 f_diff = '-1.25 +3.75 0';
261 f_diff = '+1.25 +3.75 0';
264 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", cvar("g_balance_fireball_secondary_damage"));
265 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
266 w_shotorg = trace_endpos;
268 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
271 proj.owner = proj.realowner = self;
272 proj.classname = "grenade";
273 proj.bot_dodge = TRUE;
274 proj.bot_dodgerating = cvar("g_balance_fireball_secondary_damage");
275 proj.movetype = MOVETYPE_BOUNCE;
276 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
277 proj.touch = W_Firemine_Touch;
278 PROJECTILE_MAKETRIGGER(proj);
279 setsize(proj, '-4 -4 -4', '4 4 4');
280 setorigin(proj, w_shotorg);
281 proj.think = W_Firemine_Think;
282 proj.nextthink = time;
283 proj.damageforcescale = cvar("g_balance_fireball_secondary_damageforcescale");
284 proj.pushltime = time + cvar("g_balance_fireball_secondary_lifetime");
285 W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_fireball_secondary);
287 proj.angles = vectoangles(proj.velocity);
288 proj.flags = FL_PROJECTILE;
290 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
293 void spawnfunc_weapon_fireball (void)
295 weapon_defaultspawnfunc(WEP_FIREBALL);
298 float w_fireball(float req)
302 self.BUTTON_ATCK = FALSE;
303 self.BUTTON_ATCK2 = FALSE;
304 if (self.bot_primary_fireballmooth == 0)
306 if(bot_aim(cvar("g_balance_fireball_primary_speed"), 0, cvar("g_balance_fireball_primary_lifetime"), FALSE))
308 self.BUTTON_ATCK = TRUE;
309 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
314 if(bot_aim(cvar("g_balance_fireball_secondary_speed"), cvar("g_balance_fireball_secondary_speed_up"), cvar("g_balance_fireball_secondary_lifetime"), TRUE))
316 self.BUTTON_ATCK2 = TRUE;
317 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
321 else if (req == WR_THINK)
323 if (self.BUTTON_ATCK)
324 if (time >= self.fireball_primarytime)
325 if (weapon_prepareattack(1, cvar("g_balance_fireball_primary_refire")))
327 W_Fireball_Attack1_Frame0();
328 self.fireball_primarytime = time + cvar("g_balance_fireball_primary_refire2");
330 if (self.BUTTON_ATCK2)
331 if (weapon_prepareattack(0, cvar("g_balance_fireball_secondary_refire")))
333 W_Fireball_Attack2();
334 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_fireball_secondary_animtime"), w_ready);
337 else if (req == WR_PRECACHE)
339 precache_model ("models/weapons/g_fireball.md3");
340 precache_model ("models/weapons/v_fireball.md3");
341 precache_model ("models/weapons/h_fireball.iqm");
342 precache_model ("models/sphere/sphere.md3");
343 precache_sound ("weapons/fireball_fire.wav");
344 precache_sound ("weapons/fireball_fire2.wav");
345 precache_sound ("weapons/fireball_prefire2.wav");
347 else if (req == WR_SETUP)
348 weapon_setup(WEP_FIREBALL);
349 else if (req == WR_CHECKAMMO1)
350 return self.ammo_fuel >= cvar("g_balance_fireball_primary_ammo");
351 else if (req == WR_CHECKAMMO2)
352 return self.ammo_fuel >= cvar("g_balance_fireball_secondary_ammo");
353 else if (req == WR_SUICIDEMESSAGE)
355 if(w_deathtype & HITTYPE_SECONDARY)
356 w_deathtypestring = "forgot about some firemine";
358 w_deathtypestring = "should have used a smaller gun";
360 else if (req == WR_KILLMESSAGE)
362 if(w_deathtype & HITTYPE_SECONDARY)
364 if(w_deathtype & HITTYPE_HEADSHOT)
365 w_deathtypestring = "tried to catch #'s firemine";
367 w_deathtypestring = "fatefully ignored #'s firemine";
371 if(w_deathtype & HITTYPE_BOUNCE)
373 if(w_deathtype & HITTYPE_SPLASH) // BFG effect
375 w_deathtypestring = "could not hide from #'s fireball";
379 w_deathtypestring = "saw the pretty lights of #'s fireball";
382 else if(w_deathtype & HITTYPE_SPLASH)
383 w_deathtypestring = "got too close to #'s fireball";
385 w_deathtypestring = "tasted #'s fireball";
388 else if (req == WR_RESETPLAYER)
390 self.fireball_primarytime = time;