2 REGISTER_WEAPON(HAGAR, w_hagar, IT_ROCKETS, 8, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "hagar", "hagar", _("Hagar"))
5 // NO bounce protection, as bounces are limited!
7 void W_Hagar_Explode (void)
9 self.event_damage = SUB_Null;
10 RadiusDamage (self, self.realowner, autocvar_g_balance_hagar_primary_damage, autocvar_g_balance_hagar_primary_edgedamage, autocvar_g_balance_hagar_primary_radius, world, autocvar_g_balance_hagar_primary_force, self.projectiledeathtype, other);
15 void W_Hagar_Explode2 (void)
17 self.event_damage = SUB_Null;
18 RadiusDamage (self, self.realowner, autocvar_g_balance_hagar_secondary_damage, autocvar_g_balance_hagar_secondary_edgedamage, autocvar_g_balance_hagar_secondary_radius, world, autocvar_g_balance_hagar_secondary_force, self.projectiledeathtype, other);
23 void W_Hagar_Touch (void)
29 void W_Hagar_Touch2 (void)
33 if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
37 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
38 self.angles = vectoangles (self.velocity);
40 self.projectiledeathtype |= HITTYPE_BOUNCE;
44 void W_Hagar_Attack (void)
48 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_reload_ammo);
50 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_primary_damage);
52 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
55 missile.owner = missile.realowner = self;
56 missile.classname = "missile";
57 missile.bot_dodge = TRUE;
58 missile.bot_dodgerating = autocvar_g_balance_hagar_primary_damage;
59 missile.touch = W_Hagar_Touch;
60 missile.use = W_Hagar_Explode;
61 missile.think = adaptor_think2use_hittype_splash;
62 missile.nextthink = time + autocvar_g_balance_hagar_primary_lifetime;
63 PROJECTILE_MAKETRIGGER(missile);
64 missile.projectiledeathtype = WEP_HAGAR;
65 setorigin (missile, w_shotorg);
66 setsize(missile, '0 0 0', '0 0 0');
68 missile.movetype = MOVETYPE_FLY;
69 W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_primary);
71 missile.angles = vectoangles (missile.velocity);
72 missile.flags = FL_PROJECTILE;
74 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
76 other = missile; MUTATOR_CALLHOOK(EditProjectile);
79 void W_Hagar_Attack2 (void)
83 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo, autocvar_g_balance_hagar_reload_ammo);
85 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_secondary_damage);
87 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
90 missile.owner = missile.realowner = self;
91 missile.classname = "missile";
92 missile.bot_dodge = TRUE;
93 missile.bot_dodgerating = autocvar_g_balance_hagar_secondary_damage;
94 missile.touch = W_Hagar_Touch2;
96 missile.use = W_Hagar_Explode2;
97 missile.think = adaptor_think2use_hittype_splash;
98 missile.nextthink = time + autocvar_g_balance_hagar_secondary_lifetime_min + random() * autocvar_g_balance_hagar_secondary_lifetime_rand;
99 PROJECTILE_MAKETRIGGER(missile);
100 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
101 setorigin (missile, w_shotorg);
102 setsize(missile, '0 0 0', '0 0 0');
104 missile.movetype = MOVETYPE_BOUNCEMISSILE;
105 W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_secondary);
107 missile.angles = vectoangles (missile.velocity);
108 missile.flags = FL_PROJECTILE;
110 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
112 other = missile; MUTATOR_CALLHOOK(EditProjectile);
115 .float hagar_loadtime, hagar_loadreset;
116 void W_Hagar_Attack2_Load (void)
118 // loadable hagar secondary attack, must always run each frame
120 if not(weapon_action(self.weapon, WR_CHECKAMMO2))
122 W_SwitchToOtherWeapon(self);
126 local entity missile;
127 local float counter, shots, loaded;
128 local float used_ammo, enough_ammo;
130 vector forward, right, up;
132 loaded = self.hagar_load >= autocvar_g_balance_hagar_secondary_load_max;
134 // check if we have enough ammo for another rocket
135 used_ammo = autocvar_g_balance_hagar_secondary_ammo;
136 if(autocvar_g_balance_hagar_reload_ammo)
137 enough_ammo = self.weapon_load[WEP_HAGAR] >= used_ammo + (used_ammo * self.hagar_load);
139 enough_ammo = self.ammo_rockets >= used_ammo + (used_ammo * self.hagar_load);
141 if(self.BUTTON_ATCK2)
147 // if we press the primary fire button while loading rockets, unload them and abort the loading
149 sound(self, CHAN_WEAPON2, "weapons/hagar_load.wav", VOL_BASE, ATTN_NORM);
151 // require letting go of both firing buttons before we can load again
152 self.hagar_loadreset = TRUE;
156 // check if we can attempt to load another rocket
157 if(!self.hagar_loadreset && !loaded && enough_ammo)
158 if(self.hagar_loadtime < time)
160 self.hagar_load += 1;
161 sound(self, CHAN_WEAPON2, "weapons/hagar_load.wav", VOL_BASE, ATTN_NORM);
163 self.hagar_loadtime = time + autocvar_g_balance_hagar_secondary_load_speed;
167 else if(self.hagar_loadreset)
169 // both firing buttons were released, which means we can load again
170 self.hagar_loadreset = FALSE;
174 if(!self.BUTTON_ATCK2 || ((loaded || !enough_ammo) && self.hagar_loadtime < time && !autocvar_g_balance_hagar_secondary_load_hold))
175 if(weapon_prepareattack(0, autocvar_g_balance_hagar_secondary_refire))
177 // time to release the rockets we've loaded
179 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo * self.hagar_load, autocvar_g_balance_hagar_reload_ammo);
181 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_secondary_damage);
182 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
188 shots = self.hagar_load;
190 while (counter < shots)
193 missile.owner = missile.realowner = self;
194 missile.classname = "missile";
195 missile.bot_dodge = TRUE;
196 missile.bot_dodgerating = autocvar_g_balance_hagar_secondary_damage;
198 missile.touch = W_Hagar_Touch; // not bouncy
199 missile.use = W_Hagar_Explode2;
200 missile.think = adaptor_think2use_hittype_splash;
201 missile.nextthink = time + autocvar_g_balance_hagar_secondary_lifetime_min + random() * autocvar_g_balance_hagar_secondary_lifetime_rand;
202 PROJECTILE_MAKETRIGGER(missile);
203 missile.projectiledeathtype = WEP_HAGAR;
204 setorigin (missile, w_shotorg);
205 setsize(missile, '0 0 0', '0 0 0');
206 missile.movetype = MOVETYPE_FLY;
213 makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
217 s = s * cvar("g_balance_hagar_secondary_spread") * g_weaponspreadfactor;
218 W_SetupProjectileVelocityEx(missile, w_shotdir + right * s_y + up * s_z, v_up, cvar("g_balance_hagar_secondary_speed"), 0, 0, 0, FALSE);
220 missile.angles = vectoangles (missile.velocity);
221 missile.flags = FL_PROJECTILE;
223 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
225 other = missile; MUTATOR_CALLHOOK(EditProjectile);
227 counter = counter + 1;
230 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hagar_secondary_refire, w_ready);
231 self.hagar_loadtime = time + autocvar_g_balance_hagar_secondary_refire;
236 void spawnfunc_weapon_hagar (void)
238 weapon_defaultspawnfunc(WEP_HAGAR);
241 float w_hagar(float req)
246 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
249 // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
250 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
252 else if (req == WR_THINK)
254 if(autocvar_g_balance_hagar_reload_ammo && self.clip_load < min(autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_secondary_ammo)) // forced reload
255 weapon_action(self.weapon, WR_RELOAD);
258 local float loadable_secondary;
259 loadable_secondary = autocvar_g_balance_hagar_secondary_load && autocvar_g_balance_hagar_secondary;
261 if (loadable_secondary)
262 W_Hagar_Attack2_Load(); // must run each frame, even when no firing buttons are pressed
263 if (self.BUTTON_ATCK && !(self.BUTTON_ATCK2 && loadable_secondary))
265 if (!self.hagar_load) // not while the secondary fire is loaded
266 if (weapon_prepareattack(0, autocvar_g_balance_hagar_primary_refire))
269 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hagar_primary_refire, w_ready);
272 else if (self.BUTTON_ATCK2 && !loadable_secondary && autocvar_g_balance_hagar_secondary)
274 if (weapon_prepareattack(1, autocvar_g_balance_hagar_secondary_refire))
277 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hagar_secondary_refire, w_ready);
282 else if (req == WR_PRECACHE)
284 precache_model ("models/weapons/g_hagar.md3");
285 precache_model ("models/weapons/v_hagar.md3");
286 precache_model ("models/weapons/h_hagar.iqm");
287 precache_sound ("weapons/hagar_fire.wav");
288 precache_sound ("weapons/hagar_load.wav");
289 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
291 else if (req == WR_SETUP)
293 weapon_setup(WEP_HAGAR);
294 self.current_ammo = ammo_rockets;
297 else if (req == WR_CHECKAMMO1)
299 ammo_amount = self.ammo_rockets >= autocvar_g_balance_hagar_primary_ammo;
300 ammo_amount += self.weapon_load[WEP_HAGAR] >= autocvar_g_balance_hagar_primary_ammo;
303 else if (req == WR_CHECKAMMO2)
305 ammo_amount = self.ammo_rockets >= autocvar_g_balance_hagar_secondary_ammo;
306 ammo_amount += self.weapon_load[WEP_HAGAR] >= autocvar_g_balance_hagar_secondary_ammo;
309 else if (req == WR_RELOAD)
311 W_Reload(min(autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_secondary_ammo), autocvar_g_balance_hagar_reload_ammo, autocvar_g_balance_hagar_reload_time, "weapons/reload.wav");
317 float w_hagar(float req)
319 if(req == WR_IMPACTEFFECT)
322 org2 = w_org + w_backoff * 6;
323 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
327 sound(self, CHAN_PROJECTILE, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
328 else if (w_random<0.7)
329 sound(self, CHAN_PROJECTILE, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
331 sound(self, CHAN_PROJECTILE, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
334 else if(req == WR_PRECACHE)
336 precache_sound("weapons/hagexp1.wav");
337 precache_sound("weapons/hagexp2.wav");
338 precache_sound("weapons/hagexp3.wav");
340 else if (req == WR_SUICIDEMESSAGE)
341 w_deathtypestring = _("%s played with tiny rockets");
342 else if (req == WR_KILLMESSAGE)
344 if(w_deathtype & HITTYPE_BOUNCE) // must be secondary; unchecked: SPLASH
345 w_deathtypestring = _("%s hoped %s's missiles wouldn't bounce");
346 else // unchecked: SPLASH, SECONDARY
347 w_deathtypestring = _("%s was pummeled by %s");