2 REGISTER_WEAPON(HAGAR, w_hagar, IT_ROCKETS, 8, WEP_FLAG_NORMAL | 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_SetAmmoCounter()
9 // set clip_load to the weapon we have switched to, if the gun uses reloading
10 if(!autocvar_g_balance_hagar_reload_ammo)
11 self.clip_load = 0; // also keeps crosshair ammo from displaying
14 self.clip_load = self.hagar_load;
15 self.clip_size = autocvar_g_balance_hagar_reload_ammo; // for the crosshair ammo display
19 void W_Hagar_ReloadedAndReady()
23 // now do the ammo transfer
24 self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading
25 while(self.clip_load < autocvar_g_balance_hagar_reload_ammo && self.ammo_rockets) // make sure we don't add more ammo than we have
28 self.ammo_rockets -= 1;
30 self.hagar_load = self.clip_load;
32 t = ATTACK_FINISHED(self) - autocvar_g_balance_hagar_reload_time - 1;
33 ATTACK_FINISHED(self) = t;
39 // return if reloading is disabled for this weapon
40 if(!autocvar_g_balance_hagar_reload_ammo)
43 if(!W_ReloadCheck(self.ammo_rockets, min(autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_secondary_ammo)))
48 sound (self, CHAN_WEAPON2, "weapons/reload.wav", VOL_BASE, ATTN_NORM);
50 t = max(time, ATTACK_FINISHED(self)) + autocvar_g_balance_hagar_reload_time + 1;
51 ATTACK_FINISHED(self) = t;
53 weapon_thinkf(WFRAME_RELOAD, autocvar_g_balance_hagar_reload_time, W_Hagar_ReloadedAndReady);
55 self.old_clip_load = self.clip_load;
59 void W_Hagar_Explode (void)
61 self.event_damage = SUB_Null;
62 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);
67 void W_Hagar_Explode2 (void)
69 self.event_damage = SUB_Null;
70 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);
75 void W_Hagar_Touch (void)
81 void W_Hagar_Touch2 (void)
85 if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
89 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
90 self.angles = vectoangles (self.velocity);
92 self.projectiledeathtype |= HITTYPE_BOUNCE;
96 void W_Hagar_Attack (void)
100 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
101 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
103 if(autocvar_g_balance_hagar_reload_ammo)
105 self.clip_load -= autocvar_g_balance_hagar_primary_ammo;
106 self.hagar_load = self.clip_load;
109 self.ammo_rockets -= autocvar_g_balance_hagar_primary_ammo;
112 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_primary_damage);
114 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
117 missile.owner = missile.realowner = self;
118 missile.classname = "missile";
119 missile.bot_dodge = TRUE;
120 missile.bot_dodgerating = autocvar_g_balance_hagar_primary_damage;
121 missile.touch = W_Hagar_Touch;
122 missile.use = W_Hagar_Explode;
123 missile.think = adaptor_think2use_hittype_splash;
124 missile.nextthink = time + autocvar_g_balance_hagar_primary_lifetime;
125 PROJECTILE_MAKETRIGGER(missile);
126 missile.projectiledeathtype = WEP_HAGAR;
127 setorigin (missile, w_shotorg);
128 setsize(missile, '0 0 0', '0 0 0');
130 missile.movetype = MOVETYPE_FLY;
131 W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_primary);
133 missile.angles = vectoangles (missile.velocity);
134 missile.flags = FL_PROJECTILE;
136 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
138 other = missile; MUTATOR_CALLHOOK(EditProjectile);
141 void W_Hagar_Attack2 (void)
143 local entity missile;
145 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
146 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
148 if(autocvar_g_balance_hagar_reload_ammo)
150 self.clip_load -= autocvar_g_balance_hagar_secondary_ammo;
151 self.hagar_load = self.clip_load;
154 self.ammo_rockets -= autocvar_g_balance_hagar_secondary_ammo;
157 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_secondary_damage);
159 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
162 missile.owner = missile.realowner = self;
163 missile.classname = "missile";
164 missile.bot_dodge = TRUE;
165 missile.bot_dodgerating = autocvar_g_balance_hagar_secondary_damage;
166 missile.touch = W_Hagar_Touch2;
168 missile.use = W_Hagar_Explode2;
169 missile.think = adaptor_think2use_hittype_splash;
170 missile.nextthink = time + autocvar_g_balance_hagar_secondary_lifetime_min + random() * autocvar_g_balance_hagar_secondary_lifetime_rand;
171 PROJECTILE_MAKETRIGGER(missile);
172 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
173 setorigin (missile, w_shotorg);
174 setsize(missile, '0 0 0', '0 0 0');
176 missile.movetype = MOVETYPE_BOUNCEMISSILE;
177 W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_secondary);
179 missile.angles = vectoangles (missile.velocity);
180 missile.flags = FL_PROJECTILE;
182 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
184 other = missile; MUTATOR_CALLHOOK(EditProjectile);
187 void spawnfunc_weapon_hagar (void)
189 weapon_defaultspawnfunc(WEP_HAGAR);
192 float w_hagar(float req)
196 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
199 // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
200 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
202 else if (req == WR_THINK)
204 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
206 else if (self.BUTTON_ATCK)
208 if (weapon_prepareattack(0, autocvar_g_balance_hagar_primary_refire))
211 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hagar_primary_refire, w_ready);
214 else if (self.BUTTON_ATCK2 && autocvar_g_balance_hagar_secondary)
216 if (weapon_prepareattack(1, autocvar_g_balance_hagar_secondary_refire))
219 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hagar_secondary_refire, w_ready);
223 else if (req == WR_PRECACHE)
225 precache_model ("models/weapons/g_hagar.md3");
226 precache_model ("models/weapons/v_hagar.md3");
227 precache_model ("models/weapons/h_hagar.iqm");
228 precache_sound ("weapons/hagar_fire.wav");
229 precache_sound ("weapons/reload.wav");
231 else if (req == WR_SETUP)
233 weapon_setup(WEP_HAGAR);
234 W_Hagar_SetAmmoCounter();
236 else if (req == WR_CHECKAMMO1)
238 if(autocvar_g_balance_hagar_reload_ammo)
239 return self.hagar_load >= autocvar_g_balance_hagar_primary_ammo;
241 return self.ammo_rockets >= autocvar_g_balance_hagar_primary_ammo;
243 else if (req == WR_CHECKAMMO2)
245 if(autocvar_g_balance_hagar_reload_ammo)
246 return self.hagar_load >= autocvar_g_balance_hagar_secondary_ammo;
248 return self.ammo_rockets >= autocvar_g_balance_hagar_secondary_ammo;
250 else if (req == WR_RELOAD)
254 else if (req == WR_SWITCHABLE)
256 // checks if this weapon can be switched to, when reloading is enabled
257 // returns true if there's either enough load in the weapon to use it,
258 // or we have enough ammo to reload the weapon to a usable point
260 ammo_amount = min(autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_secondary_ammo);
261 return self.hagar_load >= ammo_amount || self.ammo_rockets >= ammo_amount;
267 float w_hagar(float req)
269 if(req == WR_IMPACTEFFECT)
272 org2 = w_org + w_backoff * 6;
273 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
277 sound(self, CHAN_PROJECTILE, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
278 else if (w_random<0.7)
279 sound(self, CHAN_PROJECTILE, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
281 sound(self, CHAN_PROJECTILE, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
284 else if(req == WR_PRECACHE)
286 precache_sound("weapons/hagexp1.wav");
287 precache_sound("weapons/hagexp2.wav");
288 precache_sound("weapons/hagexp3.wav");
290 else if (req == WR_SUICIDEMESSAGE)
291 w_deathtypestring = "%s played with tiny rockets";
292 else if (req == WR_KILLMESSAGE)
294 if(w_deathtype & HITTYPE_BOUNCE) // must be secondary; unchecked: SPLASH
295 w_deathtypestring = "%s hoped %s's missiles wouldn't bounce";
296 else // unchecked: SPLASH, SECONDARY
297 w_deathtypestring = "%s was pummeled by %s";