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.damageforcescale = cvar("g_balance_fireball_secondary_damageforcescale");
137 PROJECTILE_MAKETRIGGER(proj);
138 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
139 setorigin(proj, w_shotorg);
141 proj.movetype = MOVETYPE_FLY;
142 proj.velocity = w_shotdir * cvar("g_balance_fireball_secondary_speed");
143 W_SetupProjectileVelocity(proj);
144 proj.angles = vectoangles(proj.velocity);
145 proj.touch = W_Fireball_TouchExplode;
146 setsize(proj, '-16 -16 -16', '16 16 16');
147 proj.flags = FL_PROJECTILE;
149 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
152 void W_Fireball_AttackEffect(float i, vector f_diff)
154 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0);
155 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
156 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
159 void W_Fireball_Attack2_Frame4()
161 W_Fireball_Attack2();
162 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), w_ready);
165 void W_Fireball_Attack2_Frame3()
167 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
168 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), W_Fireball_Attack2_Frame4);
171 void W_Fireball_Attack2_Frame2()
173 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
174 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), W_Fireball_Attack2_Frame3);
177 void W_Fireball_Attack2_Frame1()
179 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
180 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), W_Fireball_Attack2_Frame2);
183 void W_Fireball_Attack2_Frame0()
185 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
186 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_fireball_secondary_ammo");
188 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
189 sound (self, CHAN_WEAPON, "weapons/fireball_prefire2.wav", VOL_BASE, ATTN_NORM);
190 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), W_Fireball_Attack2_Frame1);
193 void W_Firemine_Think()
195 if(time > self.pushltime)
201 // make it "hot" once it leaves its owner
203 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > cvar("g_balance_fireball_primary_laserradius"))
206 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"));
208 self.nextthink = time + 0.1;
211 void W_Firemine_Touch (void)
214 if (other.takedamage == DAMAGE_AIM)
216 Fire_AddDamage(other, self.realowner, cvar("g_balance_fireball_primary_damage"), cvar("g_balance_fireball_primary_damagetime"), self.projectiledeathtype | HITTYPE_HEADSHOT);
221 self.projectiledeathtype |= HITTYPE_BOUNCE;
225 void W_Fireball_Attack1()
231 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
232 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_fireball_primary_ammo");
234 c = mod(self.bulletcounter, 4);
238 f_diff = '-1.25 -3.75 0';
241 f_diff = '+1.25 -3.75 0';
244 f_diff = '-1.25 +3.75 0';
248 f_diff = '+1.25 +3.75 0';
251 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", cvar("g_balance_fireball_primary_damage"));
252 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
253 w_shotorg = trace_endpos;
255 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
258 proj.owner = proj.realowner = self;
259 proj.classname = "grenade";
260 proj.bot_dodge = TRUE;
261 proj.bot_dodgerating = cvar("g_balance_fireball_primary_damage");
262 proj.movetype = MOVETYPE_BOUNCE;
263 proj.projectiledeathtype = WEP_FIREBALL;
264 proj.touch = W_Firemine_Touch;
265 PROJECTILE_MAKETRIGGER(proj);
266 setsize(proj, '-4 -4 -4', '4 4 4');
267 setorigin(proj, w_shotorg);
268 proj.think = W_Firemine_Think;
269 proj.nextthink = time;
270 proj.damageforcescale = cvar("g_balance_fireball_primary_damageforcescale");
271 proj.velocity = w_shotdir * cvar("g_balance_fireball_primary_speed") + v_up * cvar("g_balance_fireball_primary_speed_up");
272 proj.pushltime = time + cvar("g_balance_fireball_primary_lifetime");
273 W_SetupProjectileVelocity(proj);
275 proj.angles = vectoangles(proj.velocity);
276 proj.flags = FL_PROJECTILE;
278 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
281 void spawnfunc_weapon_fireball (void)
283 weapon_defaultspawnfunc(WEP_FIREBALL);
286 float w_fireball(float req)
290 self.BUTTON_ATCK = FALSE;
291 self.BUTTON_ATCK2 = FALSE;
292 if (self.bot_secondary_fireballmooth == 0)
294 if(bot_aim(cvar("g_balance_fireball_primary_speed"), cvar("g_balance_fireball_primary_speed_up"), cvar("g_balance_fireball_primary_lifetime"), TRUE))
296 self.BUTTON_ATCK = TRUE;
297 if(random() < 0.01) self.bot_secondary_fireballmooth = 1;
302 if(bot_aim(cvar("g_balance_fireball_secondary_speed"), 0, cvar("g_balance_fireball_secondary_lifetime"), FALSE))
304 self.BUTTON_ATCK2 = TRUE;
305 if(random() < 0.02) self.bot_secondary_fireballmooth = 0;
309 else if (req == WR_THINK)
311 if (self.BUTTON_ATCK)
312 if (weapon_prepareattack(0, cvar("g_balance_fireball_primary_refire")))
314 W_Fireball_Attack1();
315 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_fireball_primary_animtime"), w_ready);
317 if (self.BUTTON_ATCK2)
318 if (weapon_prepareattack(1, cvar("g_balance_fireball_secondary_refire")))
320 W_Fireball_Attack2_Frame0();
323 else if (req == WR_PRECACHE)
325 precache_model ("models/weapons/g_fireball.md3");
326 precache_model ("models/weapons/v_fireball.md3");
327 precache_model ("models/weapons/h_fireball.dpm");
328 precache_model ("models/sphere/sphere.md3");
329 precache_sound ("weapons/fireball_fire.wav");
330 precache_sound ("weapons/fireball_fire2.wav");
331 precache_sound ("weapons/fireball_prefire2.wav");
333 else if (req == WR_SETUP)
334 weapon_setup(WEP_FIREBALL);
335 else if (req == WR_CHECKAMMO1)
336 return self.ammo_rockets >= cvar("g_balance_fireball_primary_ammo");
337 else if (req == WR_CHECKAMMO2)
338 return self.ammo_rockets >= cvar("g_balance_fireball_secondary_ammo");
339 else if (req == WR_SUICIDEMESSAGE)
341 if(w_deathtype & HITTYPE_SECONDARY)
342 w_deathtypestring = "should have used a smaller gun";
344 w_deathtypestring = "forgot about some firemine";
346 else if (req == WR_KILLMESSAGE)
348 if(w_deathtype & HITTYPE_SECONDARY)
350 if(w_deathtype & HITTYPE_BOUNCE)
352 if(w_deathtype & HITTYPE_SPLASH) // BFG effect
354 w_deathtypestring = "could not hide from #'s fireball";
358 w_deathtypestring = "saw the pretty lights of #'s fireball";
361 else if(w_deathtype & HITTYPE_SPLASH)
362 w_deathtypestring = "got too close to #'s fireball";
364 w_deathtypestring = "tasted #'s fireball";
368 if(w_deathtype & HITTYPE_HEADSHOT)
369 w_deathtypestring = "tried to catch #'s firemine";
371 w_deathtypestring = "fatefully ignored #'s firemine";