1 .float bot_secondary_fireballmooth; // whatever a mooth is
2 .vector fireball_impactvec;
3 .float fireball_secondarytime;
5 void W_Fireball_Explode (void)
13 self.event_damage = SUB_Null;
14 self.takedamage = DAMAGE_NO;
17 d = (self.owner.health + self.owner.armorvalue);
18 RadiusDamage (self, self.realowner, cvar("g_balance_fireball_secondary_damage"), cvar("g_balance_fireball_secondary_edgedamage"), cvar("g_balance_fireball_secondary_radius"), world, cvar("g_balance_fireball_secondary_force"), self.projectiledeathtype, other);
19 if(self.realowner.health + self.realowner.armorvalue >= d)
22 modeleffect_spawn("models/sphere/sphere.md3", 0, 0, self.origin, '0 0 0', '0 0 0', '0 0 0', 0, cvar("g_balance_fireball_secondary_bfgradius"), 0.2, 0.05, 0.25);
25 for(e = findradius(self.origin, cvar("g_balance_fireball_secondary_bfgradius")); e; e = e.chain)
26 if(e != self.owner) if(e.takedamage == DAMAGE_AIM) if(e.classname != "player" || !self.owner || IsDifferentTeam(e, self))
28 // can we see fireball?
29 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
30 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
32 // can we see player who shot fireball?
33 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
34 if(trace_ent != self.realowner)
35 if(/* trace_startsolid || */ trace_fraction != 1)
37 dist = vlen(self.origin - e.origin - e.view_ofs);
38 points = (1 - sqrt(dist / cvar("g_balance_fireball_secondary_bfgradius")));
41 dir = normalize(e.origin + e.view_ofs - self.origin);
42 Damage(e, self, self.realowner, cvar("g_balance_fireball_secondary_bfgdamage") * points, self.projectiledeathtype | HITTYPE_BOUNCE | HITTYPE_SPLASH, e.origin + e.view_ofs, cvar("g_balance_fireball_secondary_bfgforce") * dir);
43 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
45 Damage_RecordDamage(self.owner, self.projectiledeathtype, cvar("g_balance_fireball_secondary_bfgdamage") * points);
52 void W_Fireball_TouchExplode (void)
55 W_Fireball_Explode ();
58 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
67 RandomSelection_Init();
68 for(e = findradius(self.origin, dist); e; e = e.chain)
69 if(e != self.owner) if(e.takedamage == DAMAGE_AIM) if(e.classname != "player" || !self.owner || IsDifferentTeam(e, self))
72 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
73 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
74 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
75 d = vlen(self.origin - p);
78 traceline(p, self.origin, MOVE_NORMAL, e);
79 if(/* trace_startsolid || */ trace_fraction != 1)
81 e.fireball_impactvec = p;
82 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
85 if(RandomSelection_chosen_ent)
87 d = vlen(self.origin - RandomSelection_chosen_ent.fireball_impactvec);
88 d = damage + (edgedamage - damage) * (d / dist);
89 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
90 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
91 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
95 void W_Fireball_Think()
97 if(time > self.pushltime)
100 W_Fireball_Explode();
104 W_Fireball_LaserPlay(0.1, cvar("g_balance_fireball_secondary_laserradius"), cvar("g_balance_fireball_secondary_laserdamage"), cvar("g_balance_fireball_secondary_laseredgedamage"), cvar("g_balance_fireball_secondary_laserburntime"));
106 self.nextthink = time + 0.1;
109 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
113 self.health = self.health - damage;
114 if (self.health <= 0)
117 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
121 void W_Fireball_Attack2()
125 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 2, "weapons/fireball_fire2.wav", cvar("g_balance_fireball_secondary_damage") + cvar("g_balance_fireball_secondary_bfgdamage"));
127 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
130 proj.classname = "plasma_prim";
131 proj.owner = proj.realowner = self;
132 proj.bot_dodge = TRUE;
133 proj.bot_dodgerating = cvar("g_balance_fireball_secondary_damage");
134 proj.pushltime = time + cvar("g_balance_fireball_secondary_lifetime");
135 proj.use = W_Fireball_Explode;
136 proj.think = W_Fireball_Think;
137 proj.nextthink = time;
138 proj.health = cvar("g_balance_fireball_secondary_health");
139 proj.team = self.team;
140 proj.event_damage = W_Fireball_Damage;
141 proj.takedamage = DAMAGE_YES;
142 proj.damageforcescale = cvar("g_balance_fireball_secondary_damageforcescale");
143 PROJECTILE_MAKETRIGGER(proj);
144 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
145 setorigin(proj, w_shotorg);
147 proj.movetype = MOVETYPE_FLY;
148 W_SETUPPROJECTILEVELOCITY(proj, g_balance_fireball_secondary);
149 proj.angles = vectoangles(proj.velocity);
150 proj.touch = W_Fireball_TouchExplode;
151 setsize(proj, '-16 -16 -16', '16 16 16');
152 proj.flags = FL_PROJECTILE;
154 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
157 void W_Fireball_AttackEffect(float i, vector f_diff)
159 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0);
160 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
161 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
164 void W_Fireball_Attack2_Frame4()
166 W_Fireball_Attack2();
167 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), w_ready);
170 void W_Fireball_Attack2_Frame3()
172 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
173 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), W_Fireball_Attack2_Frame4);
176 void W_Fireball_Attack2_Frame2()
178 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
179 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), W_Fireball_Attack2_Frame3);
182 void W_Fireball_Attack2_Frame1()
184 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
185 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), W_Fireball_Attack2_Frame2);
188 void W_Fireball_Attack2_Frame0()
190 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
191 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_fireball_secondary_ammo");
193 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
194 sound (self, CHAN_WEAPON, "weapons/fireball_prefire2.wav", VOL_BASE, ATTN_NORM);
195 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), W_Fireball_Attack2_Frame1);
198 void W_Firemine_Think()
200 if(time > self.pushltime)
206 // make it "hot" once it leaves its owner
209 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > cvar("g_balance_fireball_primary_laserradius"))
219 W_Fireball_LaserPlay(0.1, cvar("g_balance_fireball_primary_laserradius"), cvar("g_balance_fireball_primary_laserdamage"), cvar("g_balance_fireball_primary_laseredgedamage"), cvar("g_balance_fireball_primary_laserburntime"));
221 self.nextthink = time + 0.1;
224 void W_Firemine_Touch (void)
227 if (other.takedamage == DAMAGE_AIM)
228 if(Fire_AddDamage(other, self.realowner, cvar("g_balance_fireball_primary_damage"), cvar("g_balance_fireball_primary_damagetime"), self.projectiledeathtype | HITTYPE_HEADSHOT) >= 0)
233 self.projectiledeathtype |= HITTYPE_BOUNCE;
236 void W_Fireball_Attack1()
242 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
243 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_fireball_primary_ammo");
245 c = mod(self.bulletcounter, 4);
249 f_diff = '-1.25 -3.75 0';
252 f_diff = '+1.25 -3.75 0';
255 f_diff = '-1.25 +3.75 0';
259 f_diff = '+1.25 +3.75 0';
262 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", cvar("g_balance_fireball_primary_damage"));
263 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
264 w_shotorg = trace_endpos;
266 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
269 proj.owner = proj.realowner = self;
270 proj.classname = "grenade";
271 proj.bot_dodge = TRUE;
272 proj.bot_dodgerating = cvar("g_balance_fireball_primary_damage");
273 proj.movetype = MOVETYPE_BOUNCE;
274 proj.projectiledeathtype = WEP_FIREBALL;
275 proj.touch = W_Firemine_Touch;
276 PROJECTILE_MAKETRIGGER(proj);
277 setsize(proj, '-4 -4 -4', '4 4 4');
278 setorigin(proj, w_shotorg);
279 proj.think = W_Firemine_Think;
280 proj.nextthink = time;
281 proj.damageforcescale = cvar("g_balance_fireball_primary_damageforcescale");
282 proj.pushltime = time + cvar("g_balance_fireball_primary_lifetime");
283 W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_fireball_primary);
285 proj.angles = vectoangles(proj.velocity);
286 proj.flags = FL_PROJECTILE;
288 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
291 void spawnfunc_weapon_fireball (void)
293 weapon_defaultspawnfunc(WEP_FIREBALL);
296 float w_fireball(float req)
300 self.BUTTON_ATCK = FALSE;
301 self.BUTTON_ATCK2 = FALSE;
302 if (self.bot_secondary_fireballmooth == 0)
304 if(bot_aim(cvar("g_balance_fireball_primary_speed"), cvar("g_balance_fireball_primary_speed_up"), cvar("g_balance_fireball_primary_lifetime"), TRUE))
306 self.BUTTON_ATCK = TRUE;
307 if(random() < 0.01) self.bot_secondary_fireballmooth = 1;
312 if(bot_aim(cvar("g_balance_fireball_secondary_speed"), 0, cvar("g_balance_fireball_secondary_lifetime"), FALSE))
314 self.BUTTON_ATCK2 = TRUE;
315 if(random() < 0.02) self.bot_secondary_fireballmooth = 0;
319 else if (req == WR_THINK)
321 if (self.BUTTON_ATCK)
322 if (weapon_prepareattack(0, cvar("g_balance_fireball_primary_refire")))
324 W_Fireball_Attack1();
325 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_fireball_primary_animtime"), w_ready);
327 if (self.BUTTON_ATCK2)
328 if (time >= self.fireball_secondarytime)
329 if (weapon_prepareattack(1, cvar("g_balance_fireball_secondary_refire")))
331 W_Fireball_Attack2_Frame0();
332 self.fireball_secondarytime = time + cvar("g_balance_fireball_secondary_refire2");
335 else if (req == WR_PRECACHE)
337 precache_model ("models/weapons/g_fireball.md3");
338 precache_model ("models/weapons/v_fireball.md3");
339 precache_model ("models/weapons/h_fireball.dpm");
340 precache_model ("models/sphere/sphere.md3");
341 precache_sound ("weapons/fireball_fire.wav");
342 precache_sound ("weapons/fireball_fire2.wav");
343 precache_sound ("weapons/fireball_prefire2.wav");
345 else if (req == WR_SETUP)
346 weapon_setup(WEP_FIREBALL);
347 else if (req == WR_CHECKAMMO1)
348 return self.ammo_rockets >= cvar("g_balance_fireball_primary_ammo");
349 else if (req == WR_CHECKAMMO2)
350 return self.ammo_rockets >= cvar("g_balance_fireball_secondary_ammo");
351 else if (req == WR_SUICIDEMESSAGE)
353 if(w_deathtype & HITTYPE_SECONDARY)
354 w_deathtypestring = "should have used a smaller gun";
356 w_deathtypestring = "forgot about some firemine";
358 else if (req == WR_KILLMESSAGE)
360 if(w_deathtype & HITTYPE_SECONDARY)
362 if(w_deathtype & HITTYPE_BOUNCE)
364 if(w_deathtype & HITTYPE_SPLASH) // BFG effect
366 w_deathtypestring = "could not hide from #'s fireball";
370 w_deathtypestring = "saw the pretty lights of #'s fireball";
373 else if(w_deathtype & HITTYPE_SPLASH)
374 w_deathtypestring = "got too close to #'s fireball";
376 w_deathtypestring = "tasted #'s fireball";
380 if(w_deathtype & HITTYPE_HEADSHOT)
381 w_deathtypestring = "tried to catch #'s firemine";
383 w_deathtypestring = "fatefully ignored #'s firemine";
386 else if (req == WR_RESETPLAYER)
388 self.fireball_secondarytime = time;