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 /* netname */ "fireball",
11 /* fullname */ _("Fireball")
15 void spawnfunc_weapon_fireball() { weapon_defaultspawnfunc(WEP_FIREBALL); }
17 .float bot_primary_fireballmooth; // whatever a mooth is
18 .vector fireball_impactvec;
19 .float fireball_primarytime;
21 void W_Fireball_Explode (void)
29 self.event_damage = func_null;
30 self.takedamage = DAMAGE_NO;
33 d = (self.realowner.health + self.realowner.armorvalue);
34 RadiusDamage (self, self.realowner, autocvar_g_balance_fireball_primary_damage, autocvar_g_balance_fireball_primary_edgedamage, autocvar_g_balance_fireball_primary_radius, world, world, autocvar_g_balance_fireball_primary_force, self.projectiledeathtype, other);
35 if(self.realowner.health + self.realowner.armorvalue >= d)
38 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);
41 // NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
42 for(e = findradius(self.origin, autocvar_g_balance_fireball_primary_bfgradius); e; e = e.chain)
43 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || IsDifferentTeam(e, self))
45 // can we see fireball?
46 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
47 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
49 // can we see player who shot fireball?
50 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
51 if(trace_ent != self.realowner)
52 if(/* trace_startsolid || */ trace_fraction != 1)
54 dist = vlen(self.origin - e.origin - e.view_ofs);
55 points = (1 - sqrt(dist / autocvar_g_balance_fireball_primary_bfgradius));
58 dir = normalize(e.origin + e.view_ofs - self.origin);
60 if(accuracy_isgooddamage(self.realowner, e))
61 accuracy_add(self.realowner, WEP_FIREBALL, 0, autocvar_g_balance_fireball_primary_bfgdamage * points);
63 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);
64 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
71 void W_Fireball_TouchExplode (void)
74 W_Fireball_Explode ();
77 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
86 RandomSelection_Init();
87 for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain)
88 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || IsDifferentTeam(e, self))
91 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
92 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
93 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
94 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
97 e.fireball_impactvec = p;
98 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
101 if(RandomSelection_chosen_ent)
103 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
104 d = damage + (edgedamage - damage) * (d / dist);
105 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
106 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
107 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
111 void W_Fireball_Think()
113 if(time > self.pushltime)
116 self.projectiledeathtype |= HITTYPE_SPLASH;
117 W_Fireball_Explode();
121 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);
123 self.nextthink = time + 0.1;
126 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
131 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
132 return; // g_projectiles_damage says to halt
134 self.health = self.health - damage;
135 if (self.health <= 0)
138 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
142 void W_Fireball_Attack1()
146 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);
148 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
151 proj.classname = "plasma_prim";
152 proj.owner = proj.realowner = self;
153 proj.bot_dodge = TRUE;
154 proj.bot_dodgerating = autocvar_g_balance_fireball_primary_damage;
155 proj.pushltime = time + autocvar_g_balance_fireball_primary_lifetime;
156 proj.use = W_Fireball_Explode;
157 proj.think = W_Fireball_Think;
158 proj.nextthink = time;
159 proj.health = autocvar_g_balance_fireball_primary_health;
160 proj.team = self.team;
161 proj.event_damage = W_Fireball_Damage;
162 proj.takedamage = DAMAGE_YES;
163 proj.damageforcescale = autocvar_g_balance_fireball_primary_damageforcescale;
164 PROJECTILE_MAKETRIGGER(proj);
165 proj.projectiledeathtype = WEP_FIREBALL;
166 setorigin(proj, w_shotorg);
168 proj.movetype = MOVETYPE_FLY;
169 W_SETUPPROJECTILEVELOCITY(proj, g_balance_fireball_primary);
170 proj.angles = vectoangles(proj.velocity);
171 proj.touch = W_Fireball_TouchExplode;
172 setsize(proj, '-16 -16 -16', '16 16 16');
173 proj.flags = FL_PROJECTILE;
174 proj.missile_flags = MIF_SPLASH | MIF_PROXY;
176 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
178 other = proj; MUTATOR_CALLHOOK(EditProjectile);
181 void W_Fireball_AttackEffect(float i, vector f_diff)
183 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0, 0);
184 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
185 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
188 void W_Fireball_Attack1_Frame4()
190 W_Fireball_Attack1();
191 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, w_ready);
194 void W_Fireball_Attack1_Frame3()
196 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
197 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame4);
200 void W_Fireball_Attack1_Frame2()
202 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
203 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame3);
206 void W_Fireball_Attack1_Frame1()
208 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
209 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame2);
212 void W_Fireball_Attack1_Frame0()
214 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
215 sound (self, CH_WEAPON_SINGLE, "weapons/fireball_prefire2.wav", VOL_BASE, ATTN_NORM);
216 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_fireball_primary_animtime, W_Fireball_Attack1_Frame1);
219 void W_Firemine_Think()
221 if(time > self.pushltime)
227 // make it "hot" once it leaves its owner
230 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > autocvar_g_balance_fireball_secondary_laserradius)
240 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);
242 self.nextthink = time + 0.1;
245 void W_Firemine_Touch (void)
248 if (other.takedamage == DAMAGE_AIM)
249 if(Fire_AddDamage(other, self.realowner, autocvar_g_balance_fireball_secondary_damage, autocvar_g_balance_fireball_secondary_damagetime, self.projectiledeathtype) >= 0)
254 self.projectiledeathtype |= HITTYPE_BOUNCE;
257 void W_Fireball_Attack2()
263 c = mod(self.bulletcounter, 4);
267 f_diff = '-1.25 -3.75 0';
270 f_diff = '+1.25 -3.75 0';
273 f_diff = '-1.25 +3.75 0';
277 f_diff = '+1.25 +3.75 0';
280 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);
281 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
282 w_shotorg = trace_endpos;
284 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
287 proj.owner = proj.realowner = self;
288 proj.classname = "grenade";
289 proj.bot_dodge = TRUE;
290 proj.bot_dodgerating = autocvar_g_balance_fireball_secondary_damage;
291 proj.movetype = MOVETYPE_BOUNCE;
292 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
293 proj.touch = W_Firemine_Touch;
294 PROJECTILE_MAKETRIGGER(proj);
295 setsize(proj, '-4 -4 -4', '4 4 4');
296 setorigin(proj, w_shotorg);
297 proj.think = W_Firemine_Think;
298 proj.nextthink = time;
299 proj.damageforcescale = autocvar_g_balance_fireball_secondary_damageforcescale;
300 proj.pushltime = time + autocvar_g_balance_fireball_secondary_lifetime;
301 W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_fireball_secondary);
303 proj.angles = vectoangles(proj.velocity);
304 proj.flags = FL_PROJECTILE;
305 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
307 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
309 other = proj; MUTATOR_CALLHOOK(EditProjectile);
312 float w_fireball(float req)
318 self.BUTTON_ATCK = FALSE;
319 self.BUTTON_ATCK2 = FALSE;
320 if (self.bot_primary_fireballmooth == 0)
322 if(bot_aim(autocvar_g_balance_fireball_primary_speed, 0, autocvar_g_balance_fireball_primary_lifetime, FALSE))
324 self.BUTTON_ATCK = TRUE;
325 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
330 if(bot_aim(autocvar_g_balance_fireball_secondary_speed, autocvar_g_balance_fireball_secondary_speed_up, autocvar_g_balance_fireball_secondary_lifetime, TRUE))
332 self.BUTTON_ATCK2 = TRUE;
333 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
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);
363 precache_model ("models/weapons/g_fireball.md3");
364 precache_model ("models/weapons/v_fireball.md3");
365 precache_model ("models/weapons/h_fireball.iqm");
366 precache_model ("models/sphere/sphere.md3");
367 precache_sound ("weapons/fireball_fire.wav");
368 precache_sound ("weapons/fireball_fire2.wav");
369 precache_sound ("weapons/fireball_prefire2.wav");
374 weapon_setup(WEP_FIREBALL);
375 self.current_ammo = ammo_none;
381 return TRUE; // fireball has infinite ammo
385 self.fireball_primarytime = time;
388 case WR_SUICIDEMESSAGE:
390 if(w_deathtype & HITTYPE_SECONDARY)
391 return WEAPON_FIREBALL_SUICIDE_FIREMINE;
393 return WEAPON_FIREBALL_SUICIDE_BLAST;
397 if(w_deathtype & HITTYPE_SECONDARY)
398 return WEAPON_FIREBALL_MURDER_FIREMINE;
400 return WEAPON_FIREBALL_MURDER_BLAST;
407 float w_fireball(float req)
411 case 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
430 precache_sound("weapons/fireball_impact2.wav");