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 // weapon load persistence, for weapons that support reloading
10 void W_Hagar_SetAmmoCounter()
12 // set clip_load to the weapon we have switched to, if the gun uses reloading
13 if(!autocvar_g_balance_hagar_reload_ammo)
14 self.clip_load = 0; // also keeps crosshair ammo from displaying
17 self.clip_load = self.hagar_load;
18 self.clip_size = autocvar_g_balance_hagar_reload_ammo; // for the crosshair ammo display
22 void W_Hagar_ReloadedAndReady()
26 // now do the ammo transfer
27 self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading
28 while(self.clip_load < autocvar_g_balance_hagar_reload_ammo && self.ammo_rockets) // make sure we don't add more ammo than we have
31 self.ammo_rockets -= 1;
33 self.hagar_load = self.clip_load;
35 t = ATTACK_FINISHED(self) - autocvar_g_balance_hagar_reload_time - 1;
36 ATTACK_FINISHED(self) = t;
42 // return if reloading is disabled for this weapon
43 if(!autocvar_g_balance_hagar_reload_ammo)
46 if(!W_ReloadCheck(self.ammo_rockets, min(autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_secondary_ammo)))
51 sound (self, CHAN_WEAPON2, "weapons/reload.wav", VOL_BASE, ATTN_NORM);
53 t = max(time, ATTACK_FINISHED(self)) + autocvar_g_balance_hagar_reload_time + 1;
54 ATTACK_FINISHED(self) = t;
56 weapon_thinkf(WFRAME_RELOAD, autocvar_g_balance_hagar_reload_time, W_Hagar_ReloadedAndReady);
58 self.old_clip_load = self.clip_load;
62 void W_Hagar_Explode (void)
64 self.event_damage = SUB_Null;
65 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);
70 void W_Hagar_Explode2 (void)
72 self.event_damage = SUB_Null;
73 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);
78 void W_Hagar_Touch (void)
84 void W_Hagar_Touch2 (void)
88 if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
92 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
93 self.angles = vectoangles (self.velocity);
95 self.projectiledeathtype |= HITTYPE_BOUNCE;
99 void W_Hagar_Attack (void)
101 local entity missile;
103 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
104 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
106 if(autocvar_g_balance_hagar_reload_ammo)
108 self.clip_load -= autocvar_g_balance_hagar_primary_ammo;
109 self.hagar_load = self.clip_load;
112 self.ammo_rockets -= autocvar_g_balance_hagar_primary_ammo;
115 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_primary_damage);
117 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
120 missile.owner = missile.realowner = self;
121 missile.classname = "missile";
122 missile.bot_dodge = TRUE;
123 missile.bot_dodgerating = autocvar_g_balance_hagar_primary_damage;
124 missile.touch = W_Hagar_Touch;
125 missile.use = W_Hagar_Explode;
126 missile.think = adaptor_think2use_hittype_splash;
127 missile.nextthink = time + autocvar_g_balance_hagar_primary_lifetime;
128 PROJECTILE_MAKETRIGGER(missile);
129 missile.projectiledeathtype = WEP_HAGAR;
130 setorigin (missile, w_shotorg);
131 setsize(missile, '0 0 0', '0 0 0');
133 missile.movetype = MOVETYPE_FLY;
134 W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_primary);
136 missile.angles = vectoangles (missile.velocity);
137 missile.flags = FL_PROJECTILE;
139 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
141 other = missile; MUTATOR_CALLHOOK(EditProjectile);
144 void W_Hagar_Attack2 (void)
146 local entity missile;
148 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
149 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
151 if(autocvar_g_balance_hagar_reload_ammo)
153 self.clip_load -= autocvar_g_balance_hagar_secondary_ammo;
154 self.hagar_load = self.clip_load;
157 self.ammo_rockets -= autocvar_g_balance_hagar_secondary_ammo;
160 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_secondary_damage);
162 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
165 missile.owner = missile.realowner = self;
166 missile.classname = "missile";
167 missile.bot_dodge = TRUE;
168 missile.bot_dodgerating = autocvar_g_balance_hagar_secondary_damage;
169 missile.touch = W_Hagar_Touch2;
171 missile.use = W_Hagar_Explode2;
172 missile.think = adaptor_think2use_hittype_splash;
173 missile.nextthink = time + autocvar_g_balance_hagar_secondary_lifetime_min + random() * autocvar_g_balance_hagar_secondary_lifetime_rand;
174 PROJECTILE_MAKETRIGGER(missile);
175 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
176 setorigin (missile, w_shotorg);
177 setsize(missile, '0 0 0', '0 0 0');
179 missile.movetype = MOVETYPE_BOUNCEMISSILE;
180 W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_secondary);
182 missile.angles = vectoangles (missile.velocity);
183 missile.flags = FL_PROJECTILE;
185 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
187 other = missile; MUTATOR_CALLHOOK(EditProjectile);
190 void spawnfunc_weapon_hagar (void)
192 weapon_defaultspawnfunc(WEP_HAGAR);
195 float w_hagar(float req)
200 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
203 // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
204 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
206 else if (req == WR_THINK)
208 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
210 else if (self.BUTTON_ATCK)
212 if (weapon_prepareattack(0, autocvar_g_balance_hagar_primary_refire))
215 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hagar_primary_refire, w_ready);
218 else if (self.BUTTON_ATCK2 && autocvar_g_balance_hagar_secondary)
220 if (weapon_prepareattack(1, autocvar_g_balance_hagar_secondary_refire))
223 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hagar_secondary_refire, w_ready);
227 else if (req == WR_PRECACHE)
229 precache_model ("models/weapons/g_hagar.md3");
230 precache_model ("models/weapons/v_hagar.md3");
231 precache_model ("models/weapons/h_hagar.iqm");
232 precache_sound ("weapons/hagar_fire.wav");
233 precache_sound ("weapons/reload.wav");
235 else if (req == WR_SETUP)
237 weapon_setup(WEP_HAGAR);
238 W_Hagar_SetAmmoCounter();
240 else if (req == WR_CHECKAMMO1)
242 ammo_amount = self.ammo_rockets >= autocvar_g_balance_hagar_primary_ammo;
243 ammo_amount += self.hagar_load >= autocvar_g_balance_hagar_primary_ammo;
246 else if (req == WR_CHECKAMMO2)
248 ammo_amount = self.ammo_rockets >= autocvar_g_balance_hagar_secondary_ammo;
249 ammo_amount += self.hagar_load >= autocvar_g_balance_hagar_secondary_ammo;
252 else if (req == WR_RESETPLAYER)
254 // all weapons must be fully loaded when we spawn
255 self.hagar_load = autocvar_g_balance_hagar_reload_ammo;
257 else if (req == WR_RELOAD)
265 float w_hagar(float req)
267 if(req == WR_IMPACTEFFECT)
270 org2 = w_org + w_backoff * 6;
271 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
275 sound(self, CHAN_PROJECTILE, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
276 else if (w_random<0.7)
277 sound(self, CHAN_PROJECTILE, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
279 sound(self, CHAN_PROJECTILE, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
282 else if(req == WR_PRECACHE)
284 precache_sound("weapons/hagexp1.wav");
285 precache_sound("weapons/hagexp2.wav");
286 precache_sound("weapons/hagexp3.wav");
288 else if (req == WR_SUICIDEMESSAGE)
289 w_deathtypestring = _("%s played with tiny rockets");
290 else if (req == WR_KILLMESSAGE)
292 if(w_deathtype & HITTYPE_BOUNCE) // must be secondary; unchecked: SPLASH
293 w_deathtypestring = _("%s hoped %s's missiles wouldn't bounce");
294 else // unchecked: SPLASH, SECONDARY
295 w_deathtypestring = _("%s was pummeled by %s");