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 /* wepimg */ "weaponfireball",
14 /* refname */ "fireball",
15 /* wepname */ _("Fireball")
18 #define FIREBALL_SETTINGS(w_cvar,w_prop) FIREBALL_SETTINGS_LIST(w_cvar, w_prop, FIREBALL, fireball)
19 #define FIREBALL_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
20 w_cvar(id, sn, BOTH, animtime) \
21 w_cvar(id, sn, BOTH, refire) \
22 w_cvar(id, sn, BOTH, damage) \
23 w_cvar(id, sn, BOTH, damageforcescale) \
24 w_cvar(id, sn, BOTH, speed) \
25 w_cvar(id, sn, BOTH, spread) \
26 w_cvar(id, sn, BOTH, lifetime) \
27 w_cvar(id, sn, BOTH, laserburntime) \
28 w_cvar(id, sn, BOTH, laserdamage) \
29 w_cvar(id, sn, BOTH, laseredgedamage) \
30 w_cvar(id, sn, BOTH, laserradius) \
31 w_cvar(id, sn, PRI, edgedamage) \
32 w_cvar(id, sn, PRI, force) \
33 w_cvar(id, sn, PRI, radius) \
34 w_cvar(id, sn, PRI, health) \
35 w_cvar(id, sn, PRI, refire2) \
36 w_cvar(id, sn, PRI, bfgdamage) \
37 w_cvar(id, sn, PRI, bfgforce) \
38 w_cvar(id, sn, PRI, bfgradius) \
39 w_cvar(id, sn, SEC, damagetime) \
40 w_cvar(id, sn, SEC, speed_up) \
41 w_cvar(id, sn, SEC, speed_z) \
42 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
43 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
44 w_prop(id, sn, string, weaponreplace, weaponreplace) \
45 w_prop(id, sn, float, weaponstart, weaponstart) \
46 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride) \
47 w_prop(id, sn, float, weaponthrowable, weaponthrowable)
50 FIREBALL_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
51 .float bot_primary_fireballmooth; // whatever a mooth is
52 .vector fireball_impactvec;
53 .float fireball_primarytime;
57 void spawnfunc_weapon_fireball(void) { weapon_defaultspawnfunc(WEP_FIREBALL); }
59 void W_Fireball_Explode(void)
67 self.event_damage = func_null;
68 self.takedamage = DAMAGE_NO;
71 d = (self.realowner.health + self.realowner.armorvalue);
72 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);
73 if(self.realowner.health + self.realowner.armorvalue >= d)
76 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);
79 // NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
80 for(e = findradius(self.origin, WEP_CVAR_PRI(fireball, bfgradius)); e; e = e.chain)
81 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
83 // can we see fireball?
84 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
85 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
87 // can we see player who shot fireball?
88 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
89 if(trace_ent != self.realowner)
90 if(/* trace_startsolid || */ trace_fraction != 1)
92 dist = vlen(self.origin - e.origin - e.view_ofs);
93 points = (1 - sqrt(dist / WEP_CVAR_PRI(fireball, bfgradius)));
96 dir = normalize(e.origin + e.view_ofs - self.origin);
98 if(accuracy_isgooddamage(self.realowner, e))
99 accuracy_add(self.realowner, WEP_FIREBALL, 0, WEP_CVAR_PRI(fireball, bfgdamage) * points);
101 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);
102 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
109 void W_Fireball_TouchExplode(void)
112 W_Fireball_Explode();
115 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
124 RandomSelection_Init();
125 for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain)
126 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
129 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
130 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
131 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
132 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
135 e.fireball_impactvec = p;
136 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
139 if(RandomSelection_chosen_ent)
141 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
142 d = damage + (edgedamage - damage) * (d / dist);
143 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
144 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
145 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
149 void W_Fireball_Think(void)
151 if(time > self.pushltime)
154 self.projectiledeathtype |= HITTYPE_SPLASH;
155 W_Fireball_Explode();
159 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));
161 self.nextthink = time + 0.1;
164 void W_Fireball_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
169 if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
170 return; // g_projectiles_damage says to halt
172 self.health = self.health - damage;
176 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
180 void W_Fireball_Attack1(void)
184 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));
186 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
189 proj.classname = "plasma_prim";
190 proj.owner = proj.realowner = self;
191 proj.bot_dodge = TRUE;
192 proj.bot_dodgerating = WEP_CVAR_PRI(fireball, damage);
193 proj.pushltime = time + WEP_CVAR_PRI(fireball, lifetime);
194 proj.use = W_Fireball_Explode;
195 proj.think = W_Fireball_Think;
196 proj.nextthink = time;
197 proj.health = WEP_CVAR_PRI(fireball, health);
198 proj.team = self.team;
199 proj.event_damage = W_Fireball_Damage;
200 proj.takedamage = DAMAGE_YES;
201 proj.damageforcescale = WEP_CVAR_PRI(fireball, damageforcescale);
202 PROJECTILE_MAKETRIGGER(proj);
203 proj.projectiledeathtype = WEP_FIREBALL;
204 setorigin(proj, w_shotorg);
206 proj.movetype = MOVETYPE_FLY;
207 W_SetupProjVelocity_PRI(proj, fireball);
208 proj.angles = vectoangles(proj.velocity);
209 proj.touch = W_Fireball_TouchExplode;
210 setsize(proj, '-16 -16 -16', '16 16 16');
211 proj.flags = FL_PROJECTILE;
212 proj.missile_flags = MIF_SPLASH | MIF_PROXY;
214 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
216 other = proj; MUTATOR_CALLHOOK(EditProjectile);
219 void W_Fireball_AttackEffect(float i, vector f_diff)
221 W_SetupShot_ProjectileSize(self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0, 0);
222 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
223 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
226 void W_Fireball_Attack1_Frame4(void)
228 W_Fireball_Attack1();
229 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready);
232 void W_Fireball_Attack1_Frame3(void)
234 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
235 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4);
238 void W_Fireball_Attack1_Frame2(void)
240 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
241 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3);
244 void W_Fireball_Attack1_Frame1(void)
246 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
247 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2);
250 void W_Fireball_Attack1_Frame0(void)
252 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
253 sound(self, CH_WEAPON_SINGLE, "weapons/fireball_prefire2.wav", VOL_BASE, ATTEN_NORM);
254 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1);
257 void W_Fireball_Firemine_Think(void)
259 if(time > self.pushltime)
265 // make it "hot" once it leaves its owner
268 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > WEP_CVAR_SEC(fireball, laserradius))
278 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));
280 self.nextthink = time + 0.1;
283 void W_Fireball_Firemine_Touch(void)
286 if(other.takedamage == DAMAGE_AIM)
287 if(Fire_AddDamage(other, self.realowner, WEP_CVAR_SEC(fireball, damage), WEP_CVAR_SEC(fireball, damagetime), self.projectiledeathtype) >= 0)
292 self.projectiledeathtype |= HITTYPE_BOUNCE;
295 void W_Fireball_Attack2(void)
301 c = self.bulletcounter % 4;
305 f_diff = '-1.25 -3.75 0';
308 f_diff = '+1.25 -3.75 0';
311 f_diff = '-1.25 +3.75 0';
315 f_diff = '+1.25 +3.75 0';
318 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(fireball, damage));
319 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
320 w_shotorg = trace_endpos;
322 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
325 proj.owner = proj.realowner = self;
326 proj.classname = "grenade";
327 proj.bot_dodge = TRUE;
328 proj.bot_dodgerating = WEP_CVAR_SEC(fireball, damage);
329 proj.movetype = MOVETYPE_BOUNCE;
330 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
331 proj.touch = W_Fireball_Firemine_Touch;
332 PROJECTILE_MAKETRIGGER(proj);
333 setsize(proj, '-4 -4 -4', '4 4 4');
334 setorigin(proj, w_shotorg);
335 proj.think = W_Fireball_Firemine_Think;
336 proj.nextthink = time;
337 proj.damageforcescale = WEP_CVAR_SEC(fireball, damageforcescale);
338 proj.pushltime = time + WEP_CVAR_SEC(fireball, lifetime);
339 W_SetupProjVelocity_UP_SEC(proj, fireball);
341 proj.angles = vectoangles(proj.velocity);
342 proj.flags = FL_PROJECTILE;
343 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
345 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
347 other = proj; MUTATOR_CALLHOOK(EditProjectile);
350 float W_Fireball(float req)
356 self.BUTTON_ATCK = FALSE;
357 self.BUTTON_ATCK2 = FALSE;
358 if(self.bot_primary_fireballmooth == 0)
360 if(bot_aim(WEP_CVAR_PRI(fireball, speed), 0, WEP_CVAR_PRI(fireball, lifetime), FALSE))
362 self.BUTTON_ATCK = TRUE;
363 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
368 if(bot_aim(WEP_CVAR_SEC(fireball, speed), WEP_CVAR_SEC(fireball, speed_up), WEP_CVAR_SEC(fireball, lifetime), TRUE))
370 self.BUTTON_ATCK2 = TRUE;
371 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
381 if(time >= self.fireball_primarytime)
382 if(weapon_prepareattack(0, WEP_CVAR_PRI(fireball, refire)))
384 W_Fireball_Attack1_Frame0();
385 self.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor();
388 else if(self.BUTTON_ATCK2)
390 if(weapon_prepareattack(1, WEP_CVAR_SEC(fireball, refire)))
392 W_Fireball_Attack2();
393 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready);
401 precache_model("models/weapons/g_fireball.md3");
402 precache_model("models/weapons/v_fireball.md3");
403 precache_model("models/weapons/h_fireball.iqm");
404 precache_model("models/sphere/sphere.md3");
405 precache_sound("weapons/fireball_fire.wav");
406 precache_sound("weapons/fireball_fire2.wav");
407 precache_sound("weapons/fireball_prefire2.wav");
408 FIREBALL_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
413 self.ammo_field = ammo_none;
419 return TRUE; // fireball has infinite ammo
423 FIREBALL_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
428 self.fireball_primarytime = time;
431 case WR_SUICIDEMESSAGE:
433 if(w_deathtype & HITTYPE_SECONDARY)
434 return WEAPON_FIREBALL_SUICIDE_FIREMINE;
436 return WEAPON_FIREBALL_SUICIDE_BLAST;
440 if(w_deathtype & HITTYPE_SECONDARY)
441 return WEAPON_FIREBALL_MURDER_FIREMINE;
443 return WEAPON_FIREBALL_MURDER_BLAST;
450 float W_Fireball(float req)
454 case WR_IMPACTEFFECT:
457 if(w_deathtype & HITTYPE_SECONDARY)
459 // firemine goes out silently
463 org2 = w_org + w_backoff * 16;
464 pointparticles(particleeffectnum("fireball_explode"), org2, '0 0 0', 1);
466 sound(self, CH_SHOTS, "weapons/fireball_impact2.wav", VOL_BASE, ATTEN_NORM * 0.25); // long range boom
473 precache_sound("weapons/fireball_impact2.wav");
478 // no weapon specific image for this weapon