3 /* WEP_##id */ FIREBALL,
4 /* function */ W_Fireball,
5 /* ammotype */ ammo_none,
7 /* flags */ WEP_FLAG_SUPERWEAPON | WEP_TYPE_SPLASH,
8 /* rating */ BOT_PICKUP_RATING_MID,
10 /* modelname */ "fireball",
11 /* simplemdl */ "foobar",
12 /* crosshair */ "gfx/crosshairfireball",
13 /* refname */ "fireball",
14 /* wepname */ _("Fireball")
17 #define FIREBALL_SETTINGS(w_cvar,w_prop) FIREBALL_SETTINGS_LIST(w_cvar, w_prop, FIREBALL, fireball)
18 #define FIREBALL_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
19 w_cvar(id, sn, BOTH, animtime) \
20 w_cvar(id, sn, BOTH, refire) \
21 w_cvar(id, sn, BOTH, damage) \
22 w_cvar(id, sn, BOTH, damageforcescale) \
23 w_cvar(id, sn, BOTH, speed) \
24 w_cvar(id, sn, BOTH, spread) \
25 w_cvar(id, sn, BOTH, lifetime) \
26 w_cvar(id, sn, BOTH, laserburntime) \
27 w_cvar(id, sn, BOTH, laserdamage) \
28 w_cvar(id, sn, BOTH, laseredgedamage) \
29 w_cvar(id, sn, BOTH, laserradius) \
30 w_cvar(id, sn, PRI, edgedamage) \
31 w_cvar(id, sn, PRI, force) \
32 w_cvar(id, sn, PRI, radius) \
33 w_cvar(id, sn, PRI, health) \
34 w_cvar(id, sn, PRI, refire2) \
35 w_cvar(id, sn, PRI, bfgdamage) \
36 w_cvar(id, sn, PRI, bfgforce) \
37 w_cvar(id, sn, PRI, bfgradius) \
38 w_cvar(id, sn, SEC, damagetime) \
39 w_cvar(id, sn, SEC, speed_up) \
40 w_cvar(id, sn, SEC, speed_z) \
41 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
42 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
43 w_prop(id, sn, string, weaponreplace, weaponreplace) \
44 w_prop(id, sn, float, weaponstart, weaponstart) \
45 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
48 FIREBALL_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
49 .float bot_primary_fireballmooth; // whatever a mooth is
50 .vector fireball_impactvec;
51 .float fireball_primarytime;
55 void spawnfunc_weapon_fireball() { weapon_defaultspawnfunc(WEP_FIREBALL); }
57 void W_Fireball_Explode (void)
65 self.event_damage = func_null;
66 self.takedamage = DAMAGE_NO;
69 d = (self.realowner.health + self.realowner.armorvalue);
70 RadiusDamage (self, self.realowner, WEP_CVAR_PRI(fireball, damage), WEP_CVAR_PRI(fireball, edgedamage), WEP_CVAR_PRI(fireball, radius), world, world, WEP_CVAR_PRI(fireball, force), self.projectiledeathtype, other);
71 if(self.realowner.health + self.realowner.armorvalue >= d)
74 modeleffect_spawn("models/sphere/sphere.md3", 0, 0, self.origin, '0 0 0', '0 0 0', '0 0 0', 0, WEP_CVAR_PRI(fireball, bfgradius), 0.2, 0.05, 0.25);
77 // NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
78 for(e = findradius(self.origin, WEP_CVAR_PRI(fireball, bfgradius)); e; e = e.chain)
79 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
81 // can we see fireball?
82 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
83 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
85 // can we see player who shot fireball?
86 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
87 if(trace_ent != self.realowner)
88 if(/* trace_startsolid || */ trace_fraction != 1)
90 dist = vlen(self.origin - e.origin - e.view_ofs);
91 points = (1 - sqrt(dist / WEP_CVAR_PRI(fireball, bfgradius)));
94 dir = normalize(e.origin + e.view_ofs - self.origin);
96 if(accuracy_isgooddamage(self.realowner, e))
97 accuracy_add(self.realowner, WEP_FIREBALL, 0, WEP_CVAR_PRI(fireball, bfgdamage) * points);
99 Damage(e, self, self.realowner, WEP_CVAR_PRI(fireball, bfgdamage) * points, self.projectiledeathtype | HITTYPE_BOUNCE | HITTYPE_SPLASH, e.origin + e.view_ofs, WEP_CVAR_PRI(fireball, bfgforce) * dir);
100 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
107 void W_Fireball_TouchExplode (void)
110 W_Fireball_Explode ();
113 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
122 RandomSelection_Init();
123 for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain)
124 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
127 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
128 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
129 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
130 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
133 e.fireball_impactvec = p;
134 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
137 if(RandomSelection_chosen_ent)
139 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
140 d = damage + (edgedamage - damage) * (d / dist);
141 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
142 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
143 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
147 void W_Fireball_Think()
149 if(time > self.pushltime)
152 self.projectiledeathtype |= HITTYPE_SPLASH;
153 W_Fireball_Explode();
157 W_Fireball_LaserPlay(0.1, WEP_CVAR_PRI(fireball, laserradius), WEP_CVAR_PRI(fireball, laserdamage), WEP_CVAR_PRI(fireball, laseredgedamage), WEP_CVAR_PRI(fireball, laserburntime));
159 self.nextthink = time + 0.1;
162 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
167 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
168 return; // g_projectiles_damage says to halt
170 self.health = self.health - damage;
171 if (self.health <= 0)
174 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
178 void W_Fireball_Attack1()
182 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 2, "weapons/fireball_fire2.wav", CH_WEAPON_A, WEP_CVAR_PRI(fireball, damage) + WEP_CVAR_PRI(fireball, bfgdamage));
184 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
187 proj.classname = "plasma_prim";
188 proj.owner = proj.realowner = self;
189 proj.bot_dodge = TRUE;
190 proj.bot_dodgerating = WEP_CVAR_PRI(fireball, damage);
191 proj.pushltime = time + WEP_CVAR_PRI(fireball, lifetime);
192 proj.use = W_Fireball_Explode;
193 proj.think = W_Fireball_Think;
194 proj.nextthink = time;
195 proj.health = WEP_CVAR_PRI(fireball, health);
196 proj.team = self.team;
197 proj.event_damage = W_Fireball_Damage;
198 proj.takedamage = DAMAGE_YES;
199 proj.damageforcescale = WEP_CVAR_PRI(fireball, damageforcescale);
200 PROJECTILE_MAKETRIGGER(proj);
201 proj.projectiledeathtype = WEP_FIREBALL;
202 setorigin(proj, w_shotorg);
204 proj.movetype = MOVETYPE_FLY;
205 W_SetupProjVelocity_PRI(proj, fireball);
206 proj.angles = vectoangles(proj.velocity);
207 proj.touch = W_Fireball_TouchExplode;
208 setsize(proj, '-16 -16 -16', '16 16 16');
209 proj.flags = FL_PROJECTILE;
210 proj.missile_flags = MIF_SPLASH | MIF_PROXY;
212 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
214 other = proj; MUTATOR_CALLHOOK(EditProjectile);
217 void W_Fireball_AttackEffect(float i, vector f_diff)
219 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0, 0);
220 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
221 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
224 void W_Fireball_Attack1_Frame4()
226 W_Fireball_Attack1();
227 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready);
230 void W_Fireball_Attack1_Frame3()
232 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
233 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4);
236 void W_Fireball_Attack1_Frame2()
238 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
239 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3);
242 void W_Fireball_Attack1_Frame1()
244 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
245 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2);
248 void W_Fireball_Attack1_Frame0()
250 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
251 sound (self, CH_WEAPON_SINGLE, "weapons/fireball_prefire2.wav", VOL_BASE, ATTEN_NORM);
252 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1);
255 void W_Fireball_Firemine_Think()
257 if(time > self.pushltime)
263 // make it "hot" once it leaves its owner
266 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > WEP_CVAR_SEC(fireball, laserradius))
276 W_Fireball_LaserPlay(0.1, WEP_CVAR_SEC(fireball, laserradius), WEP_CVAR_SEC(fireball, laserdamage), WEP_CVAR_SEC(fireball, laseredgedamage), WEP_CVAR_SEC(fireball, laserburntime));
278 self.nextthink = time + 0.1;
281 void W_Fireball_Firemine_Touch (void)
284 if (other.takedamage == DAMAGE_AIM)
285 if(Fire_AddDamage(other, self.realowner, WEP_CVAR_SEC(fireball, damage), WEP_CVAR_SEC(fireball, damagetime), self.projectiledeathtype) >= 0)
290 self.projectiledeathtype |= HITTYPE_BOUNCE;
293 void W_Fireball_Attack2()
299 c = mod(self.bulletcounter, 4);
303 f_diff = '-1.25 -3.75 0';
306 f_diff = '+1.25 -3.75 0';
309 f_diff = '-1.25 +3.75 0';
313 f_diff = '+1.25 +3.75 0';
316 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(fireball, damage));
317 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
318 w_shotorg = trace_endpos;
320 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
323 proj.owner = proj.realowner = self;
324 proj.classname = "grenade";
325 proj.bot_dodge = TRUE;
326 proj.bot_dodgerating = WEP_CVAR_SEC(fireball, damage);
327 proj.movetype = MOVETYPE_BOUNCE;
328 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
329 proj.touch = W_Fireball_Firemine_Touch;
330 PROJECTILE_MAKETRIGGER(proj);
331 setsize(proj, '-4 -4 -4', '4 4 4');
332 setorigin(proj, w_shotorg);
333 proj.think = W_Fireball_Firemine_Think;
334 proj.nextthink = time;
335 proj.damageforcescale = WEP_CVAR_SEC(fireball, damageforcescale);
336 proj.pushltime = time + WEP_CVAR_SEC(fireball, lifetime);
337 W_SetupProjVelocity_UP_SEC(proj, fireball);
339 proj.angles = vectoangles(proj.velocity);
340 proj.flags = FL_PROJECTILE;
341 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
343 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
345 other = proj; MUTATOR_CALLHOOK(EditProjectile);
348 float W_Fireball(float req)
354 self.BUTTON_ATCK = FALSE;
355 self.BUTTON_ATCK2 = FALSE;
356 if (self.bot_primary_fireballmooth == 0)
358 if(bot_aim(WEP_CVAR_PRI(fireball, speed), 0, WEP_CVAR_PRI(fireball, lifetime), FALSE))
360 self.BUTTON_ATCK = TRUE;
361 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
366 if(bot_aim(WEP_CVAR_SEC(fireball, speed), WEP_CVAR_SEC(fireball, speed_up), WEP_CVAR_SEC(fireball, lifetime), TRUE))
368 self.BUTTON_ATCK2 = TRUE;
369 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
377 if (self.BUTTON_ATCK)
379 if (time >= self.fireball_primarytime)
380 if (weapon_prepareattack(0, WEP_CVAR_PRI(fireball, refire)))
382 W_Fireball_Attack1_Frame0();
383 self.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor();
386 else if (self.BUTTON_ATCK2)
388 if (weapon_prepareattack(1, WEP_CVAR_SEC(fireball, refire)))
390 W_Fireball_Attack2();
391 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready);
399 precache_model ("models/weapons/g_fireball.md3");
400 precache_model ("models/weapons/v_fireball.md3");
401 precache_model ("models/weapons/h_fireball.iqm");
402 precache_model ("models/sphere/sphere.md3");
403 precache_sound ("weapons/fireball_fire.wav");
404 precache_sound ("weapons/fireball_fire2.wav");
405 precache_sound ("weapons/fireball_prefire2.wav");
406 FIREBALL_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
411 self.ammo_field = ammo_none;
417 return TRUE; // fireball has infinite ammo
421 FIREBALL_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
426 self.fireball_primarytime = time;
429 case WR_SUICIDEMESSAGE:
431 if(w_deathtype & HITTYPE_SECONDARY)
432 return WEAPON_FIREBALL_SUICIDE_FIREMINE;
434 return WEAPON_FIREBALL_SUICIDE_BLAST;
438 if(w_deathtype & HITTYPE_SECONDARY)
439 return WEAPON_FIREBALL_MURDER_FIREMINE;
441 return WEAPON_FIREBALL_MURDER_BLAST;
448 float W_Fireball(float req)
452 case WR_IMPACTEFFECT:
455 if(w_deathtype & HITTYPE_SECONDARY)
457 // firemine goes out silently
461 org2 = w_org + w_backoff * 16;
462 pointparticles(particleeffectnum("fireball_explode"), org2, '0 0 0', 1);
464 sound(self, CH_SHOTS, "weapons/fireball_impact2.wav", VOL_BASE, ATTEN_NORM * 0.25); // long range boom
471 precache_sound("weapons/fireball_impact2.wav");
476 // no weapon specific image for this weapon