1 .float bot_secondary_fireballmooth; // whatever a mooth is
2 .vector fireball_impactvec;
4 void W_Fireball_Explode (void)
12 self.event_damage = SUB_Null;
15 d = (self.owner.health + self.owner.armorvalue);
16 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);
17 if(self.realowner.health + self.realowner.armorvalue >= d)
20 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);
23 for(e = findradius(self.origin, cvar("g_balance_fireball_secondary_bfgradius")); e; e = e.chain)
24 if(e != self.owner) if(e.takedamage == DAMAGE_AIM) if(e.classname != "player" || !self.owner || IsDifferentTeam(e, self))
26 // can we see fireball?
27 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
28 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
30 // can we see player who shot fireball?
31 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
32 if(trace_ent != self.realowner)
33 if(/* trace_startsolid || */ trace_fraction != 1)
35 dist = vlen(self.origin - e.origin - e.view_ofs);
36 points = (1 - sqrt(dist / cvar("g_balance_fireball_secondary_bfgradius")));
39 dir = normalize(e.origin + e.view_ofs - self.origin);
40 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);
41 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
43 Damage_RecordDamage(self.owner, self.projectiledeathtype, cvar("g_balance_fireball_secondary_bfgdamage") * points);
50 void W_Fireball_TouchExplode (void)
53 W_Fireball_Explode ();
56 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
62 RandomSelection_Init();
63 for(e = findradius(self.origin, dist); e; e = e.chain)
64 if(e != self.owner) if(e.takedamage == DAMAGE_AIM) if(e.classname != "player" || !self.owner || IsDifferentTeam(e, self))
67 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
68 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
69 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
70 d = vlen(self.origin - p);
73 traceline(p, self.origin, MOVE_NORMAL, e);
74 if(/* trace_startsolid || */ trace_fraction != 1)
76 e.fireball_impactvec = p;
77 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
80 if(RandomSelection_chosen_ent)
82 d = vlen(self.origin - RandomSelection_chosen_ent.fireball_impactvec);
83 d = damage + (edgedamage - damage) * (d / dist);
84 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
85 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
86 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
90 void W_Fireball_Think()
92 if(time > self.pushltime)
99 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"));
101 self.nextthink = time + 0.1;
104 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
108 self.health = self.health - damage;
109 if (self.health <= 0)
112 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
116 void W_Fireball_Attack2()
120 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"));
122 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
125 proj.classname = "plasma_prim";
126 proj.owner = proj.realowner = self;
127 proj.bot_dodge = TRUE;
128 proj.bot_dodgerating = cvar("g_balance_fireball_secondary_damage");
129 proj.pushltime = time + cvar("g_balance_fireball_secondary_lifetime");
130 proj.use = W_Fireball_Explode;
131 proj.think = W_Fireball_Think;
132 proj.nextthink = time;
133 proj.health = cvar("g_balance_fireball_secondary_health");
134 proj.team = self.team;
135 proj.event_damage = W_Fireball_Damage;
136 proj.takedamage = DAMAGE_YES;
137 proj.damageforcescale = cvar("g_balance_fireball_secondary_damageforcescale");
138 PROJECTILE_MAKETRIGGER(proj);
139 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
140 setorigin(proj, w_shotorg);
142 proj.movetype = MOVETYPE_FLY;
143 proj.velocity = w_shotdir * cvar("g_balance_fireball_secondary_speed");
144 W_SetupProjectileVelocity(proj);
145 proj.angles = vectoangles(proj.velocity);
146 proj.touch = W_Fireball_TouchExplode;
147 setsize(proj, '-16 -16 -16', '16 16 16');
148 proj.flags = FL_PROJECTILE;
150 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
153 void W_Fireball_AttackEffect(float i, vector f_diff)
155 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0);
156 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
157 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
160 void W_Fireball_Attack2_Frame4()
162 W_Fireball_Attack2();
163 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), w_ready);
166 void W_Fireball_Attack2_Frame3()
168 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
169 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), W_Fireball_Attack2_Frame4);
172 void W_Fireball_Attack2_Frame2()
174 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
175 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), W_Fireball_Attack2_Frame3);
178 void W_Fireball_Attack2_Frame1()
180 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
181 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), W_Fireball_Attack2_Frame2);
184 void W_Fireball_Attack2_Frame0()
186 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
187 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_fireball_secondary_ammo");
189 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
190 sound (self, CHAN_WEAPON, "weapons/fireball_prefire2.wav", VOL_BASE, ATTN_NORM);
191 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), W_Fireball_Attack2_Frame1);
194 void W_Firemine_Think()
196 if(time > self.pushltime)
202 // make it "hot" once it leaves its owner
204 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > cvar("g_balance_fireball_primary_laserradius"))
207 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"));
209 self.nextthink = time + 0.1;
212 void W_Firemine_Touch (void)
215 if (other.takedamage == DAMAGE_AIM)
216 if(Fire_AddDamage(other, self.realowner, cvar("g_balance_fireball_primary_damage"), cvar("g_balance_fireball_primary_damagetime"), self.projectiledeathtype | HITTYPE_HEADSHOT) >= 0)
221 self.projectiledeathtype |= HITTYPE_BOUNCE;
224 void W_Fireball_Attack1()
230 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
231 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_fireball_primary_ammo");
233 c = mod(self.bulletcounter, 4);
237 f_diff = '-1.25 -3.75 0';
240 f_diff = '+1.25 -3.75 0';
243 f_diff = '-1.25 +3.75 0';
247 f_diff = '+1.25 +3.75 0';
250 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", cvar("g_balance_fireball_primary_damage"));
251 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
252 w_shotorg = trace_endpos;
254 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
257 proj.owner = proj.realowner = self;
258 proj.classname = "grenade";
259 proj.bot_dodge = TRUE;
260 proj.bot_dodgerating = cvar("g_balance_fireball_primary_damage");
261 proj.movetype = MOVETYPE_BOUNCE;
262 proj.projectiledeathtype = WEP_FIREBALL;
263 proj.touch = W_Firemine_Touch;
264 PROJECTILE_MAKETRIGGER(proj);
265 setsize(proj, '-4 -4 -4', '4 4 4');
266 setorigin(proj, w_shotorg);
267 proj.think = W_Firemine_Think;
268 proj.nextthink = time;
269 proj.damageforcescale = cvar("g_balance_fireball_primary_damageforcescale");
270 proj.velocity = w_shotdir * cvar("g_balance_fireball_primary_speed") + v_up * cvar("g_balance_fireball_primary_speed_up");
271 proj.pushltime = time + cvar("g_balance_fireball_primary_lifetime");
272 W_SetupProjectileVelocity(proj);
274 proj.angles = vectoangles(proj.velocity);
275 proj.flags = FL_PROJECTILE;
277 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
280 void spawnfunc_weapon_fireball (void)
282 weapon_defaultspawnfunc(WEP_FIREBALL);
285 float w_fireball(float req)
289 self.BUTTON_ATCK = FALSE;
290 self.BUTTON_ATCK2 = FALSE;
291 if (self.bot_secondary_fireballmooth == 0)
293 if(bot_aim(cvar("g_balance_fireball_primary_speed"), cvar("g_balance_fireball_primary_speed_up"), cvar("g_balance_fireball_primary_lifetime"), TRUE))
295 self.BUTTON_ATCK = TRUE;
296 if(random() < 0.01) self.bot_secondary_fireballmooth = 1;
301 if(bot_aim(cvar("g_balance_fireball_secondary_speed"), 0, cvar("g_balance_fireball_secondary_lifetime"), FALSE))
303 self.BUTTON_ATCK2 = TRUE;
304 if(random() < 0.02) self.bot_secondary_fireballmooth = 0;
308 else if (req == WR_THINK)
310 if (self.BUTTON_ATCK)
311 if (weapon_prepareattack(0, cvar("g_balance_fireball_primary_refire")))
313 W_Fireball_Attack1();
314 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_fireball_primary_animtime"), w_ready);
316 if (self.BUTTON_ATCK2)
317 if (weapon_prepareattack(1, cvar("g_balance_fireball_secondary_refire")))
319 W_Fireball_Attack2_Frame0();
322 else if (req == WR_PRECACHE)
324 precache_model ("models/weapons/g_fireball.md3");
325 precache_model ("models/weapons/v_fireball.md3");
326 precache_model ("models/weapons/h_fireball.dpm");
327 precache_model ("models/sphere/sphere.md3");
328 precache_sound ("weapons/fireball_fire.wav");
329 precache_sound ("weapons/fireball_fire2.wav");
330 precache_sound ("weapons/fireball_prefire2.wav");
332 else if (req == WR_SETUP)
333 weapon_setup(WEP_FIREBALL);
334 else if (req == WR_CHECKAMMO1)
335 return self.ammo_rockets >= cvar("g_balance_fireball_primary_ammo");
336 else if (req == WR_CHECKAMMO2)
337 return self.ammo_rockets >= cvar("g_balance_fireball_secondary_ammo");
338 else if (req == WR_SUICIDEMESSAGE)
340 if(w_deathtype & HITTYPE_SECONDARY)
341 w_deathtypestring = "should have used a smaller gun";
343 w_deathtypestring = "forgot about some firemine";
345 else if (req == WR_KILLMESSAGE)
347 if(w_deathtype & HITTYPE_SECONDARY)
349 if(w_deathtype & HITTYPE_BOUNCE)
351 if(w_deathtype & HITTYPE_SPLASH) // BFG effect
353 w_deathtypestring = "could not hide from #'s fireball";
357 w_deathtypestring = "saw the pretty lights of #'s fireball";
360 else if(w_deathtype & HITTYPE_SPLASH)
361 w_deathtypestring = "got too close to #'s fireball";
363 w_deathtypestring = "tasted #'s fireball";
367 if(w_deathtype & HITTYPE_HEADSHOT)
368 w_deathtypestring = "tried to catch #'s firemine";
370 w_deathtypestring = "fatefully ignored #'s firemine";