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)
197 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
200 // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
201 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
203 else if (req == WR_THINK)
205 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
207 else if (self.BUTTON_ATCK)
209 if (weapon_prepareattack(0, autocvar_g_balance_hagar_primary_refire))
212 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hagar_primary_refire, w_ready);
215 else if (self.BUTTON_ATCK2 && autocvar_g_balance_hagar_secondary)
217 if (weapon_prepareattack(1, autocvar_g_balance_hagar_secondary_refire))
220 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hagar_secondary_refire, w_ready);
225 if(self.switchweapon == self.weapon)
227 if(self.weaponentity.state == WS_READY)
229 self.wish_reload = 0;
235 else if (req == WR_PRECACHE)
237 precache_model ("models/weapons/g_hagar.md3");
238 precache_model ("models/weapons/v_hagar.md3");
239 precache_model ("models/weapons/h_hagar.iqm");
240 precache_sound ("weapons/hagar_fire.wav");
241 precache_sound ("weapons/reload.wav");
243 else if (req == WR_SETUP)
245 weapon_setup(WEP_HAGAR);
246 W_Hagar_SetAmmoCounter();
248 else if (req == WR_CHECKAMMO1)
250 ammo_amount = self.ammo_rockets >= autocvar_g_balance_hagar_primary_ammo;
251 ammo_amount += (autocvar_g_balance_hagar_reload_ammo && self.hagar_load >= autocvar_g_balance_hagar_primary_ammo);
254 else if (req == WR_CHECKAMMO2)
256 ammo_amount = self.ammo_rockets >= autocvar_g_balance_hagar_secondary_ammo;
257 ammo_amount += (autocvar_g_balance_hagar_reload_ammo && self.hagar_load >= autocvar_g_balance_hagar_secondary_ammo);
260 else if (req == WR_RELOAD)
268 float w_hagar(float req)
270 if(req == WR_IMPACTEFFECT)
273 org2 = w_org + w_backoff * 6;
274 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
278 sound(self, CHAN_PROJECTILE, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
279 else if (w_random<0.7)
280 sound(self, CHAN_PROJECTILE, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
282 sound(self, CHAN_PROJECTILE, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
285 else if(req == WR_PRECACHE)
287 precache_sound("weapons/hagexp1.wav");
288 precache_sound("weapons/hagexp2.wav");
289 precache_sound("weapons/hagexp3.wav");
291 else if (req == WR_SUICIDEMESSAGE)
292 w_deathtypestring = "%s played with tiny rockets";
293 else if (req == WR_KILLMESSAGE)
295 if(w_deathtype & HITTYPE_BOUNCE) // must be secondary; unchecked: SPLASH
296 w_deathtypestring = "%s hoped %s's missiles wouldn't bounce";
297 else // unchecked: SPLASH, SECONDARY
298 w_deathtypestring = "%s was pummeled by %s";