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;
13 self.takedamage = DAMAGE_NO;
16 d = (self.owner.health + self.owner.armorvalue);
17 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);
18 if(self.realowner.health + self.realowner.armorvalue >= d)
21 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);
24 for(e = findradius(self.origin, cvar("g_balance_fireball_secondary_bfgradius")); e; e = e.chain)
25 if(e != self.owner) if(e.takedamage == DAMAGE_AIM) if(e.classname != "player" || !self.owner || IsDifferentTeam(e, self))
27 // can we see fireball?
28 traceline(e.origin + e.view_ofs, self.origin, MOVE_NORMAL, e);
29 if(/* trace_startsolid || */ trace_fraction != 1) // startsolid should be never happening anyway
31 // can we see player who shot fireball?
32 traceline(e.origin + e.view_ofs, self.realowner.origin + self.realowner.view_ofs, MOVE_NORMAL, e);
33 if(trace_ent != self.realowner)
34 if(/* trace_startsolid || */ trace_fraction != 1)
36 dist = vlen(self.origin - e.origin - e.view_ofs);
37 points = (1 - sqrt(dist / cvar("g_balance_fireball_secondary_bfgradius")));
40 dir = normalize(e.origin + e.view_ofs - self.origin);
41 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);
42 pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
44 Damage_RecordDamage(self.owner, self.projectiledeathtype, cvar("g_balance_fireball_secondary_bfgdamage") * points);
51 void W_Fireball_TouchExplode (void)
54 W_Fireball_Explode ();
57 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
63 RandomSelection_Init();
64 for(e = findradius(self.origin, dist); e; e = e.chain)
65 if(e != self.owner) if(e.takedamage == DAMAGE_AIM) if(e.classname != "player" || !self.owner || IsDifferentTeam(e, self))
68 p_x += e.mins_x + random() * (e.maxs_x - e.mins_x);
69 p_y += e.mins_y + random() * (e.maxs_y - e.mins_y);
70 p_z += e.mins_z + random() * (e.maxs_z - e.mins_z);
71 d = vlen(self.origin - p);
74 traceline(p, self.origin, MOVE_NORMAL, e);
75 if(/* trace_startsolid || */ trace_fraction != 1)
77 e.fireball_impactvec = p;
78 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
81 if(RandomSelection_chosen_ent)
83 d = vlen(self.origin - RandomSelection_chosen_ent.fireball_impactvec);
84 d = damage + (edgedamage - damage) * (d / dist);
85 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
86 //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
87 pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
91 void W_Fireball_Think()
93 if(time > self.pushltime)
100 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"));
102 self.nextthink = time + 0.1;
105 void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
109 self.health = self.health - damage;
110 if (self.health <= 0)
113 W_PrepareExplosionByDamage(attacker, W_Fireball_Explode);
117 void W_Fireball_Attack2()
121 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"));
123 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
126 proj.classname = "plasma_prim";
127 proj.owner = proj.realowner = self;
128 proj.bot_dodge = TRUE;
129 proj.bot_dodgerating = cvar("g_balance_fireball_secondary_damage");
130 proj.pushltime = time + cvar("g_balance_fireball_secondary_lifetime");
131 proj.use = W_Fireball_Explode;
132 proj.think = W_Fireball_Think;
133 proj.nextthink = time;
134 proj.health = cvar("g_balance_fireball_secondary_health");
135 proj.team = self.team;
136 proj.event_damage = W_Fireball_Damage;
137 proj.takedamage = DAMAGE_YES;
138 proj.damageforcescale = cvar("g_balance_fireball_secondary_damageforcescale");
139 PROJECTILE_MAKETRIGGER(proj);
140 proj.projectiledeathtype = WEP_FIREBALL | HITTYPE_SECONDARY;
141 setorigin(proj, w_shotorg);
143 proj.movetype = MOVETYPE_FLY;
144 proj.velocity = w_shotdir * cvar("g_balance_fireball_secondary_speed");
145 W_SetupProjectileVelocity(proj);
146 proj.angles = vectoangles(proj.velocity);
147 proj.touch = W_Fireball_TouchExplode;
148 setsize(proj, '-16 -16 -16', '16 16 16');
149 proj.flags = FL_PROJECTILE;
151 CSQCProjectile(proj, TRUE, PROJECTILE_FIREBALL, TRUE);
154 void W_Fireball_AttackEffect(float i, vector f_diff)
156 W_SetupShot_ProjectileSize (self, '-16 -16 -16', '16 16 16', FALSE, 0, "", 0);
157 w_shotorg += f_diff_x * v_up + f_diff_y * v_right;
158 pointparticles(particleeffectnum("fireball_preattack_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
161 void W_Fireball_Attack2_Frame4()
163 W_Fireball_Attack2();
164 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), w_ready);
167 void W_Fireball_Attack2_Frame3()
169 W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
170 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), W_Fireball_Attack2_Frame4);
173 void W_Fireball_Attack2_Frame2()
175 W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
176 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), W_Fireball_Attack2_Frame3);
179 void W_Fireball_Attack2_Frame1()
181 W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
182 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), W_Fireball_Attack2_Frame2);
185 void W_Fireball_Attack2_Frame0()
187 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
188 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_fireball_secondary_ammo");
190 W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
191 sound (self, CHAN_WEAPON, "weapons/fireball_prefire2.wav", VOL_BASE, ATTN_NORM);
192 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_fireball_secondary_animtime"), W_Fireball_Attack2_Frame1);
195 void W_Firemine_Think()
197 if(time > self.pushltime)
203 // make it "hot" once it leaves its owner
206 if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > cvar("g_balance_fireball_primary_laserradius"))
216 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"));
218 self.nextthink = time + 0.1;
221 void W_Firemine_Touch (void)
224 if (other.takedamage == DAMAGE_AIM)
225 if(Fire_AddDamage(other, self.realowner, cvar("g_balance_fireball_primary_damage"), cvar("g_balance_fireball_primary_damagetime"), self.projectiledeathtype | HITTYPE_HEADSHOT) >= 0)
230 self.projectiledeathtype |= HITTYPE_BOUNCE;
233 void W_Fireball_Attack1()
239 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
240 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_fireball_primary_ammo");
242 c = mod(self.bulletcounter, 4);
246 f_diff = '-1.25 -3.75 0';
249 f_diff = '+1.25 -3.75 0';
252 f_diff = '-1.25 +3.75 0';
256 f_diff = '+1.25 +3.75 0';
259 W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 2, "weapons/fireball_fire.wav", cvar("g_balance_fireball_primary_damage"));
260 traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, self);
261 w_shotorg = trace_endpos;
263 pointparticles(particleeffectnum("fireball_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
266 proj.owner = proj.realowner = self;
267 proj.classname = "grenade";
268 proj.bot_dodge = TRUE;
269 proj.bot_dodgerating = cvar("g_balance_fireball_primary_damage");
270 proj.movetype = MOVETYPE_BOUNCE;
271 proj.projectiledeathtype = WEP_FIREBALL;
272 proj.touch = W_Firemine_Touch;
273 PROJECTILE_MAKETRIGGER(proj);
274 setsize(proj, '-4 -4 -4', '4 4 4');
275 setorigin(proj, w_shotorg);
276 proj.think = W_Firemine_Think;
277 proj.nextthink = time;
278 proj.damageforcescale = cvar("g_balance_fireball_primary_damageforcescale");
279 proj.velocity = w_shotdir * cvar("g_balance_fireball_primary_speed") + v_up * cvar("g_balance_fireball_primary_speed_up");
280 proj.pushltime = time + cvar("g_balance_fireball_primary_lifetime");
281 W_SetupProjectileVelocity(proj);
283 proj.angles = vectoangles(proj.velocity);
284 proj.flags = FL_PROJECTILE;
286 CSQCProjectile(proj, TRUE, PROJECTILE_FIREMINE, TRUE);
289 void spawnfunc_weapon_fireball (void)
291 weapon_defaultspawnfunc(WEP_FIREBALL);
294 float w_fireball(float req)
298 self.BUTTON_ATCK = FALSE;
299 self.BUTTON_ATCK2 = FALSE;
300 if (self.bot_secondary_fireballmooth == 0)
302 if(bot_aim(cvar("g_balance_fireball_primary_speed"), cvar("g_balance_fireball_primary_speed_up"), cvar("g_balance_fireball_primary_lifetime"), TRUE))
304 self.BUTTON_ATCK = TRUE;
305 if(random() < 0.01) self.bot_secondary_fireballmooth = 1;
310 if(bot_aim(cvar("g_balance_fireball_secondary_speed"), 0, cvar("g_balance_fireball_secondary_lifetime"), FALSE))
312 self.BUTTON_ATCK2 = TRUE;
313 if(random() < 0.02) self.bot_secondary_fireballmooth = 0;
317 else if (req == WR_THINK)
319 if (self.BUTTON_ATCK)
320 if (weapon_prepareattack(0, cvar("g_balance_fireball_primary_refire")))
322 W_Fireball_Attack1();
323 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_fireball_primary_animtime"), w_ready);
325 if (self.BUTTON_ATCK2)
326 if (weapon_prepareattack(1, cvar("g_balance_fireball_secondary_refire")))
328 W_Fireball_Attack2_Frame0();
331 else if (req == WR_PRECACHE)
333 precache_model ("models/weapons/g_fireball.md3");
334 precache_model ("models/weapons/v_fireball.md3");
335 precache_model ("models/weapons/h_fireball.dpm");
336 precache_model ("models/sphere/sphere.md3");
337 precache_sound ("weapons/fireball_fire.wav");
338 precache_sound ("weapons/fireball_fire2.wav");
339 precache_sound ("weapons/fireball_prefire2.wav");
341 else if (req == WR_SETUP)
342 weapon_setup(WEP_FIREBALL);
343 else if (req == WR_CHECKAMMO1)
344 return self.ammo_rockets >= cvar("g_balance_fireball_primary_ammo");
345 else if (req == WR_CHECKAMMO2)
346 return self.ammo_rockets >= cvar("g_balance_fireball_secondary_ammo");
347 else if (req == WR_SUICIDEMESSAGE)
349 if(w_deathtype & HITTYPE_SECONDARY)
350 w_deathtypestring = "should have used a smaller gun";
352 w_deathtypestring = "forgot about some firemine";
354 else if (req == WR_KILLMESSAGE)
356 if(w_deathtype & HITTYPE_SECONDARY)
358 if(w_deathtype & HITTYPE_BOUNCE)
360 if(w_deathtype & HITTYPE_SPLASH) // BFG effect
362 w_deathtypestring = "could not hide from #'s fireball";
366 w_deathtypestring = "saw the pretty lights of #'s fireball";
369 else if(w_deathtype & HITTYPE_SPLASH)
370 w_deathtypestring = "got too close to #'s fireball";
372 w_deathtypestring = "tasted #'s fireball";
376 if(w_deathtype & HITTYPE_HEADSHOT)
377 w_deathtypestring = "tried to catch #'s firemine";
379 w_deathtypestring = "fatefully ignored #'s firemine";