3 /* WEP_##id */ FIREBALL,
4 /* function */ w_fireball,
7 /* flags */ WEP_FLAG_SUPERWEAPON | WEP_TYPE_SPLASH,
8 /* rating */ BOT_PICKUP_RATING_MID,
9 /* model */ "fireball",
10 /* shortname */ "fireball",
11 /* fullname */ _("Fireball")
15 .float bot_primary_fireballmooth; // whatever a mooth is
16 .vector fireball_impactvec;
17 .float fireball_primarytime;
19 void W_Fireball_Explode (void)
27 self.event_damage = func_null;
28 self.takedamage = DAMAGE_NO;
31 d = (self.realowner.health + self.realowner.armorvalue);
32 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);
33 if(self.realowner.health + self.realowner.armorvalue >= d)
36 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);
39 // NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
40 for(e = findradius(self.origin, autocvar_g_balance_fireball_primary_bfgradius); e; e = e.chain)
41 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || IsDifferentTeam(e, self))
43 // can we see fireball?
44 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
45 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
47 // can we see player who shot fireball?
48 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
49 if(trace_ent != self.realowner)
50 if(/* trace_startsolid || */ trace_fraction != 1)
52 dist = vlen(self.origin - e.origin - e.view_ofs);
53 points = (1 - sqrt(dist / autocvar_g_balance_fireball_primary_bfgradius));
56 dir = normalize(e.origin + e.view_ofs - self.origin);
58 if(accuracy_isgooddamage(self.realowner, e))
59 accuracy_add(self.realowner, WEP_FIREBALL, 0, autocvar_g_balance_fireball_primary_bfgdamage * points);
61 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);
62 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
69 void W_Fireball_TouchExplode (void)
72 W_Fireball_Explode ();
75 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
84 RandomSelection_Init();
85 for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain)
86 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || IsDifferentTeam(e, self))
89 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
90 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
91 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
92 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
95 e.fireball_impactvec = p;
96 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
99 if(RandomSelection_chosen_ent)
101 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
102 d = damage + (edgedamage - damage) * (d / dist);
103 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
104 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
105 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
109 void W_Fireball_Think()
111 if(time > self.pushltime)
114 self.projectiledeathtype |= HITTYPE_SPLASH;
115 W_Fireball_Explode();
119 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);
121 self.nextthink = time + 0.1;
124 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
129 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
130 return; // g_projectiles_damage says to halt
132 self.health = self.health - damage;
133 if (self.health <= 0)
136 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
140 void W_Fireball_Attack1()
144 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);
146 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
149 proj.classname = "plasma_prim";
150 proj.owner = proj.realowner = self;
151 proj.bot_dodge = TRUE;
152 proj.bot_dodgerating = autocvar_g_balance_fireball_primary_damage;
153 proj.pushltime = time + autocvar_g_balance_fireball_primary_lifetime;
154 proj.use = W_Fireball_Explode;
155 proj.think = W_Fireball_Think;
156 proj.nextthink = time;
157 proj.health = autocvar_g_balance_fireball_primary_health;
158 proj.team = self.team;
159 proj.event_damage = W_Fireball_Damage;
160 proj.takedamage = DAMAGE_YES;
161 proj.damageforcescale = autocvar_g_balance_fireball_primary_damageforcescale;
162 PROJECTILE_MAKETRIGGER(proj);
163 proj.projectiledeathtype = WEP_FIREBALL;
164 setorigin(proj, w_shotorg);
166 proj.movetype = MOVETYPE_FLY;
167 W_SETUPPROJECTILEVELOCITY(proj, g_balance_fireball_primary);
168 proj.angles = vectoangles(proj.velocity);
169 proj.touch = W_Fireball_TouchExplode;
170 setsize(proj, '-16 -16 -16', '16 16 16');
171 proj.flags = FL_PROJECTILE;
172 proj.missile_flags = MIF_SPLASH | MIF_PROXY;
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 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
213 sound (self, CH_WEAPON_SINGLE, "weapons/fireball_prefire2.wav", VOL_BASE, ATTN_NORM);
214 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame1);
217 void W_Firemine_Think()
219 if(time > self.pushltime)
225 // make it "hot" once it leaves its owner
228 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > autocvar_g_balance_fireball_secondary_laserradius)
238 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);
240 self.nextthink = time + 0.1;
243 void W_Firemine_Touch (void)
246 if (other.takedamage == DAMAGE_AIM)
247 if(Fire_AddDamage(other, self.realowner, autocvar_g_balance_fireball_secondary_damage, autocvar_g_balance_fireball_secondary_damagetime, self.projectiledeathtype) >= 0)
252 self.projectiledeathtype |= HITTYPE_BOUNCE;
255 void W_Fireball_Attack2()
261 c = mod(self.bulletcounter, 4);
265 f_diff = '-1.25 -3.75 0';
268 f_diff = '+1.25 -3.75 0';
271 f_diff = '-1.25 +3.75 0';
275 f_diff = '+1.25 +3.75 0';
278 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);
279 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
280 w_shotorg = trace_endpos;
282 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
285 proj.owner = proj.realowner = self;
286 proj.classname = "grenade";
287 proj.bot_dodge = TRUE;
288 proj.bot_dodgerating = autocvar_g_balance_fireball_secondary_damage;
289 proj.movetype = MOVETYPE_BOUNCE;
290 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
291 proj.touch = W_Firemine_Touch;
292 PROJECTILE_MAKETRIGGER(proj);
293 setsize(proj, '-4 -4 -4', '4 4 4');
294 setorigin(proj, w_shotorg);
295 proj.think = W_Firemine_Think;
296 proj.nextthink = time;
297 proj.damageforcescale = autocvar_g_balance_fireball_secondary_damageforcescale;
298 proj.pushltime = time + autocvar_g_balance_fireball_secondary_lifetime;
299 W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_fireball_secondary);
301 proj.angles = vectoangles(proj.velocity);
302 proj.flags = FL_PROJECTILE;
303 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
305 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
307 other = proj; MUTATOR_CALLHOOK(EditProjectile);
310 void spawnfunc_weapon_fireball (void)
312 weapon_defaultspawnfunc(WEP_FIREBALL);
315 float w_fireball(float req)
320 self.BUTTON_ATCK = FALSE;
321 self.BUTTON_ATCK2 = FALSE;
322 if (self.bot_primary_fireballmooth == 0)
324 if(bot_aim(autocvar_g_balance_fireball_primary_speed, 0, autocvar_g_balance_fireball_primary_lifetime, FALSE))
326 self.BUTTON_ATCK = TRUE;
327 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
332 if(bot_aim(autocvar_g_balance_fireball_secondary_speed, autocvar_g_balance_fireball_secondary_speed_up, autocvar_g_balance_fireball_secondary_lifetime, TRUE))
334 self.BUTTON_ATCK2 = TRUE;
335 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
339 else if (req == WR_THINK)
341 if (self.BUTTON_ATCK)
343 if (time >= self.fireball_primarytime)
344 if (weapon_prepareattack(0, autocvar_g_balance_fireball_primary_refire))
346 W_Fireball_Attack1_Frame0();
347 self.fireball_primarytime = time + autocvar_g_balance_fireball_primary_refire2 * W_WeaponRateFactor();
350 else if (self.BUTTON_ATCK2)
352 if (weapon_prepareattack(1, autocvar_g_balance_fireball_secondary_refire))
354 W_Fireball_Attack2();
355 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_fireball_secondary_animtime, w_ready);
359 else if (req == WR_PRECACHE)
361 precache_model ("models/weapons/g_fireball.md3");
362 precache_model ("models/weapons/v_fireball.md3");
363 precache_model ("models/weapons/h_fireball.iqm");
364 precache_model ("models/sphere/sphere.md3");
365 precache_sound ("weapons/fireball_fire.wav");
366 precache_sound ("weapons/fireball_fire2.wav");
367 precache_sound ("weapons/fireball_prefire2.wav");
368 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
370 else if (req == WR_SETUP)
372 weapon_setup(WEP_FIREBALL);
373 self.current_ammo = ammo_none;
375 else if (req == WR_CHECKAMMO1)
379 else if (req == WR_CHECKAMMO2)
383 else if (req == WR_RESETPLAYER)
385 self.fireball_primarytime = time;
387 else if (req == WR_SUICIDEMESSAGE)
389 if(w_deathtype & HITTYPE_SECONDARY)
390 return WEAPON_FIREBALL_SUICIDE_FIREMINE;
392 return WEAPON_FIREBALL_SUICIDE_BLAST;
394 else if (req == WR_KILLMESSAGE)
396 if(w_deathtype & HITTYPE_SECONDARY)
398 return WEAPON_FIREBALL_MURDER_FIREMINE;
402 return WEAPON_FIREBALL_MURDER_BLAST;
409 float w_fireball(float req)
411 if(req == WR_IMPACTEFFECT)
414 if(w_deathtype & HITTYPE_SECONDARY)
416 // firemine goes out silently
420 org2 = w_org + w_backoff * 16;
421 pointparticles(particleeffectnum("fireball_explode"), org2, '0 0 0', 1);
423 sound(self, CH_SHOTS, "weapons/fireball_impact2.wav", VOL_BASE, ATTN_NORM * 0.25); // long range boom
426 else if(req == WR_PRECACHE)
428 precache_sound("weapons/fireball_impact2.wav");