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;
58 void spawnfunc_weapon_fireball(void) { weapon_defaultspawnfunc(WEP_FIREBALL.m_id); }
60 void W_Fireball_Explode(void)
68 self.event_damage = func_null;
69 self.takedamage = DAMAGE_NO;
72 d = (self.realowner.health + self.realowner.armorvalue);
73 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);
74 if(self.realowner.health + self.realowner.armorvalue >= d)
77 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);
80 // NOTE: this cannot be made warpzone aware by design. So, better intentionally ignore warpzones here.
81 for(e = findradius(self.origin, WEP_CVAR_PRI(fireball, bfgradius)); e; e = e.chain)
82 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
84 // can we see fireball?
85 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
86 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
88 // can we see player who shot fireball?
89 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
90 if(trace_ent != self.realowner)
91 if(/* trace_startsolid || */ trace_fraction != 1)
93 dist = vlen(self.origin - e.origin - e.view_ofs);
94 points = (1 - sqrt(dist / WEP_CVAR_PRI(fireball, bfgradius)));
97 dir = normalize(e.origin + e.view_ofs - self.origin);
99 if(accuracy_isgooddamage(self.realowner, e))
100 accuracy_add(self.realowner, WEP_FIREBALL.m_id, 0, WEP_CVAR_PRI(fireball, bfgdamage) * points);
102 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);
103 Send_Effect(EFFECT_FIREBALL_BFGDAMAGE, e.origin, -1 * dir, 1);
110 void W_Fireball_TouchExplode(void)
113 W_Fireball_Explode();
116 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
125 RandomSelection_Init();
126 for(e = WarpZone_FindRadius(self.origin, dist, true); e; e = e.chain)
127 if(e != self.realowner) if(e.takedamage == DAMAGE_AIM) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
130 p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
131 p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
132 p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
133 d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
136 e.fireball_impactvec = p;
137 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
140 if(RandomSelection_chosen_ent)
142 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
143 d = damage + (edgedamage - damage) * (d / dist);
144 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
145 //trailparticles(self, particleeffectnum(EFFECT_FIREBALL_LASER), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
146 Send_Effect(EFFECT_FIREBALL_LASER, self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
150 void W_Fireball_Think(void)
152 if(time > self.pushltime)
155 self.projectiledeathtype |= HITTYPE_SPLASH;
156 W_Fireball_Explode();
160 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));
162 self.nextthink = time + 0.1;
165 void W_Fireball_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
170 if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
171 return; // g_projectiles_damage says to halt
173 self.health = self.health - damage;
177 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
181 void W_Fireball_Attack1(void)
185 W_SetupShot_ProjectileSize(self, '-16 -16 -16', '16 16 16', false, 2, W_Sound("fireball_fire2"), CH_WEAPON_A, WEP_CVAR_PRI(fireball, damage) + WEP_CVAR_PRI(fireball, bfgdamage));
187 Send_Effect(EFFECT_FIREBALL_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
190 proj.classname = "plasma_prim";
191 proj.owner = proj.realowner = self;
192 proj.bot_dodge = true;
193 proj.bot_dodgerating = WEP_CVAR_PRI(fireball, damage);
194 proj.pushltime = time + WEP_CVAR_PRI(fireball, lifetime);
195 proj.use = W_Fireball_Explode;
196 proj.think = W_Fireball_Think;
197 proj.nextthink = time;
198 proj.health = WEP_CVAR_PRI(fireball, health);
199 proj.team = self.team;
200 proj.event_damage = W_Fireball_Damage;
201 proj.takedamage = DAMAGE_YES;
202 proj.damageforcescale = WEP_CVAR_PRI(fireball, damageforcescale);
203 PROJECTILE_MAKETRIGGER(proj);
204 proj.projectiledeathtype = WEP_FIREBALL.m_id;
205 setorigin(proj, w_shotorg);
207 proj.movetype = MOVETYPE_FLY;
208 W_SetupProjVelocity_PRI(proj, fireball);
209 proj.angles = vectoangles(proj.velocity);
210 proj.touch = W_Fireball_TouchExplode;
211 setsize(proj, '-16 -16 -16', '16 16 16');
212 proj.flags = FL_PROJECTILE;
213 proj.missile_flags = MIF_SPLASH | MIF_PROXY;
215 CSQCProjectile(proj, true, PROJECTILE_FIREBALL, true);
217 MUTATOR_CALLHOOK(EditProjectile, self, proj);
220 void W_Fireball_AttackEffect(float i, vector f_diff)
222 W_SetupShot_ProjectileSize(self, '-16 -16 -16', '16 16 16', false, 0, "", 0, 0);
223 w_shotorg += f_diff.x * v_up + f_diff.y * v_right;
224 Send_Effect(EFFECT_FIREBALL_PRE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
227 void W_Fireball_Attack1_Frame4(void)
229 W_Fireball_Attack1();
230 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready);
233 void W_Fireball_Attack1_Frame3(void)
235 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
236 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4);
239 void W_Fireball_Attack1_Frame2(void)
241 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
242 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3);
245 void W_Fireball_Attack1_Frame1(void)
247 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
248 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2);
251 void W_Fireball_Attack1_Frame0(void)
253 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
254 sound(self, CH_WEAPON_SINGLE, W_Sound("fireball_prefire2"), VOL_BASE, ATTEN_NORM);
255 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1);
258 void W_Fireball_Firemine_Think(void)
260 if(time > self.pushltime)
266 // make it "hot" once it leaves its owner
269 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > WEP_CVAR_SEC(fireball, laserradius))
279 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));
281 self.nextthink = time + 0.1;
284 void W_Fireball_Firemine_Touch(void)
287 if(other.takedamage == DAMAGE_AIM)
288 if(Fire_AddDamage(other, self.realowner, WEP_CVAR_SEC(fireball, damage), WEP_CVAR_SEC(fireball, damagetime), self.projectiledeathtype) >= 0)
293 self.projectiledeathtype |= HITTYPE_BOUNCE;
296 void W_Fireball_Attack2(void)
302 c = self.bulletcounter % 4;
306 f_diff = '-1.25 -3.75 0';
309 f_diff = '+1.25 -3.75 0';
312 f_diff = '-1.25 +3.75 0';
316 f_diff = '+1.25 +3.75 0';
319 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', false, 2, W_Sound("fireball_fire"), CH_WEAPON_A, WEP_CVAR_SEC(fireball, damage));
320 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
321 w_shotorg = trace_endpos;
323 Send_Effect(EFFECT_FIREBALL_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
326 proj.owner = proj.realowner = self;
327 proj.classname = "grenade";
328 proj.bot_dodge = true;
329 proj.bot_dodgerating = WEP_CVAR_SEC(fireball, damage);
330 proj.movetype = MOVETYPE_BOUNCE;
331 proj.projectiledeathtype = WEP_FIREBALL.m_id | HITTYPE_SECONDARY;
332 proj.touch = W_Fireball_Firemine_Touch;
333 PROJECTILE_MAKETRIGGER(proj);
334 setsize(proj, '-4 -4 -4', '4 4 4');
335 setorigin(proj, w_shotorg);
336 proj.think = W_Fireball_Firemine_Think;
337 proj.nextthink = time;
338 proj.damageforcescale = WEP_CVAR_SEC(fireball, damageforcescale);
339 proj.pushltime = time + WEP_CVAR_SEC(fireball, lifetime);
340 W_SetupProjVelocity_UP_SEC(proj, fireball);
342 proj.angles = vectoangles(proj.velocity);
343 proj.flags = FL_PROJECTILE;
344 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
346 CSQCProjectile(proj, true, PROJECTILE_FIREMINE, true);
348 MUTATOR_CALLHOOK(EditProjectile, self, proj);
351 bool W_Fireball(entity thiswep, int req)
357 self.BUTTON_ATCK = false;
358 self.BUTTON_ATCK2 = false;
359 if(self.bot_primary_fireballmooth == 0)
361 if(bot_aim(WEP_CVAR_PRI(fireball, speed), 0, WEP_CVAR_PRI(fireball, lifetime), false))
363 self.BUTTON_ATCK = true;
364 if(random() < 0.02) self.bot_primary_fireballmooth = 0;
369 if(bot_aim(WEP_CVAR_SEC(fireball, speed), WEP_CVAR_SEC(fireball, speed_up), WEP_CVAR_SEC(fireball, lifetime), true))
371 self.BUTTON_ATCK2 = true;
372 if(random() < 0.01) self.bot_primary_fireballmooth = 1;
382 if(time >= self.fireball_primarytime)
383 if(weapon_prepareattack(0, WEP_CVAR_PRI(fireball, refire)))
385 W_Fireball_Attack1_Frame0();
386 self.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor();
389 else if(self.BUTTON_ATCK2)
391 if(weapon_prepareattack(1, WEP_CVAR_SEC(fireball, refire)))
393 W_Fireball_Attack2();
394 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready);
402 precache_sound(W_Sound("fireball_fire"));
403 precache_sound(W_Sound("fireball_fire2"));
404 precache_sound(W_Sound("fireball_prefire2"));
405 FIREBALL_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
410 self.ammo_field = ammo_none;
416 return true; // fireball has infinite ammo
420 FIREBALL_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
425 self.fireball_primarytime = time;
428 case WR_SUICIDEMESSAGE:
430 if(w_deathtype & HITTYPE_SECONDARY)
431 return WEAPON_FIREBALL_SUICIDE_FIREMINE;
433 return WEAPON_FIREBALL_SUICIDE_BLAST;
437 if(w_deathtype & HITTYPE_SECONDARY)
438 return WEAPON_FIREBALL_MURDER_FIREMINE;
440 return WEAPON_FIREBALL_MURDER_BLAST;
447 bool W_Fireball(entity thiswep, int req)
451 case WR_IMPACTEFFECT:
454 if(w_deathtype & HITTYPE_SECONDARY)
456 // firemine goes out silently
460 org2 = w_org + w_backoff * 16;
461 pointparticles(particleeffectnum(EFFECT_FIREBALL_EXPLODE), org2, '0 0 0', 1);
463 sound(self, CH_SHOTS, W_Sound("fireball_impact2"), VOL_BASE, ATTEN_NORM * 0.25); // long range boom
470 precache_sound(W_Sound("fireball_impact2"));
475 // no weapon specific image for this weapon