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!
10 void W_Hagar_Explode (void)
12 self.event_damage = SUB_Null;
13 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);
18 void W_Hagar_Explode2 (void)
20 self.event_damage = SUB_Null;
21 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);
26 void W_Hagar_Touch (void)
32 void W_Hagar_Touch2 (void)
36 if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
40 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
41 self.angles = vectoangles (self.velocity);
43 self.projectiledeathtype |= HITTYPE_BOUNCE;
47 void W_Hagar_Attack (void)
51 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_reload_ammo);
53 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_primary_damage);
55 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
58 missile.owner = missile.realowner = self;
59 missile.classname = "missile";
60 missile.bot_dodge = TRUE;
61 missile.bot_dodgerating = autocvar_g_balance_hagar_primary_damage;
62 missile.touch = W_Hagar_Touch;
63 missile.use = W_Hagar_Explode;
64 missile.think = adaptor_think2use_hittype_splash;
65 missile.nextthink = time + autocvar_g_balance_hagar_primary_lifetime;
66 PROJECTILE_MAKETRIGGER(missile);
67 missile.projectiledeathtype = WEP_HAGAR;
68 setorigin (missile, w_shotorg);
69 setsize(missile, '0 0 0', '0 0 0');
71 missile.movetype = MOVETYPE_FLY;
72 W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_primary);
74 missile.angles = vectoangles (missile.velocity);
75 missile.flags = FL_PROJECTILE;
77 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
79 other = missile; MUTATOR_CALLHOOK(EditProjectile);
82 void W_Hagar_Attack2 (void)
86 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo, autocvar_g_balance_hagar_reload_ammo);
88 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_secondary_damage);
90 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
93 missile.owner = missile.realowner = self;
94 missile.classname = "missile";
95 missile.bot_dodge = TRUE;
96 missile.bot_dodgerating = autocvar_g_balance_hagar_secondary_damage;
97 missile.touch = W_Hagar_Touch2;
99 missile.use = W_Hagar_Explode2;
100 missile.think = adaptor_think2use_hittype_splash;
101 missile.nextthink = time + autocvar_g_balance_hagar_secondary_lifetime_min + random() * autocvar_g_balance_hagar_secondary_lifetime_rand;
102 PROJECTILE_MAKETRIGGER(missile);
103 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
104 setorigin (missile, w_shotorg);
105 setsize(missile, '0 0 0', '0 0 0');
107 missile.movetype = MOVETYPE_BOUNCEMISSILE;
108 W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_secondary);
110 missile.angles = vectoangles (missile.velocity);
111 missile.flags = FL_PROJECTILE;
113 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
115 other = missile; MUTATOR_CALLHOOK(EditProjectile);
118 .float hagarload_refire, hagarload_loaded;
120 void W_Hagar_Attack2_Load (void)
122 if not(autocvar_g_balance_hagar_secondary)
125 local entity missile, prevmissile, firstmissile;
126 local float counter, shots;
128 vector forward, right, up;
130 if(self.BUTTON_ATCK2 && !self.hagarload_loaded)
132 if(self.hagarload_refire < time)
134 self.hagar_load += 1;
135 if(self.hagar_load >= autocvar_g_balance_hagar_secondary_load_maxload)
136 self.hagarload_loaded = TRUE;
138 self.hagarload_refire = time + autocvar_g_balance_hagar_secondary_refire;
141 else if(self.hagar_load)
143 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_secondary_damage);
144 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
146 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo * self.hagar_load, autocvar_g_balance_hagar_reload_ammo);
152 shots = self.hagar_load;
154 while (counter < shots)
158 missile.owner = missile.realowner = self;
159 missile.classname = "missile";
160 missile.bot_dodge = TRUE;
161 missile.bot_dodgerating = autocvar_g_balance_hagar_secondary_damage;
163 missile.queuenext = missile;
164 missile.queueprev = missile;
166 else if(counter == 0) { // first projectile, store in firstmissile for now
167 firstmissile = missile;
169 else if(counter == shots - 1) { // last projectile, link up with first projectile
170 prevmissile.queuenext = missile;
171 firstmissile.queueprev = missile;
172 missile.queuenext = firstmissile;
173 missile.queueprev = prevmissile;
175 else { // else link up with previous projectile
176 prevmissile.queuenext = missile;
177 missile.queueprev = prevmissile;
180 prevmissile = missile;
182 missile.touch = W_Hagar_Touch;
183 missile.use = W_Hagar_Explode;
184 missile.think = adaptor_think2use_hittype_splash;
185 missile.nextthink = time + autocvar_g_balance_hagar_secondary_lifetime_min + random() * autocvar_g_balance_hagar_secondary_lifetime_rand;
186 PROJECTILE_MAKETRIGGER(missile);
187 missile.projectiledeathtype = WEP_HAGAR;
188 setorigin (missile, w_shotorg);
189 setsize(missile, '0 0 0', '0 0 0');
191 missile.movetype = MOVETYPE_FLY;
198 makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
202 s = s * autocvar_g_balance_hagar_secondary_load_spread * g_weaponspreadfactor;
203 W_SetupProjectileVelocityEx(missile, w_shotdir + right * s_y + up * s_z, v_up, cvar("g_balance_hagar_secondary_speed"), 0, 0, 0, FALSE);
205 missile.angles = vectoangles (missile.velocity);
206 missile.flags = FL_PROJECTILE;
208 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
210 other = missile; MUTATOR_CALLHOOK(EditProjectile);
212 counter = counter + 1;
216 self.hagarload_loaded = FALSE;
220 void spawnfunc_weapon_hagar (void)
222 weapon_defaultspawnfunc(WEP_HAGAR);
225 float w_hagar(float req)
230 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
233 // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
234 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
236 else if (req == WR_THINK)
238 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
239 weapon_action(self.weapon, WR_RELOAD);
240 else if (self.BUTTON_ATCK && !self.hagar_load) // not while loading secondary fire
242 if (weapon_prepareattack(0, autocvar_g_balance_hagar_primary_refire))
245 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hagar_primary_refire, w_ready);
248 else if(autocvar_g_balance_hagar_secondary_load)
249 W_Hagar_Attack2_Load(); // must run each frame
250 else if (self.BUTTON_ATCK2 && autocvar_g_balance_hagar_secondary)
252 if (weapon_prepareattack(1, autocvar_g_balance_hagar_secondary_refire))
255 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hagar_secondary_refire, w_ready);
259 else if (req == WR_PRECACHE)
261 precache_model ("models/weapons/g_hagar.md3");
262 precache_model ("models/weapons/v_hagar.md3");
263 precache_model ("models/weapons/h_hagar.iqm");
264 precache_sound ("weapons/hagar_fire.wav");
265 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
267 else if (req == WR_SETUP)
269 weapon_setup(WEP_HAGAR);
270 self.current_ammo = ammo_rockets;
272 else if (req == WR_CHECKAMMO1)
274 ammo_amount = self.ammo_rockets >= autocvar_g_balance_hagar_primary_ammo;
275 ammo_amount += self.weapon_load[WEP_HAGAR] >= autocvar_g_balance_hagar_primary_ammo;
278 else if (req == WR_CHECKAMMO2)
280 ammo_amount = self.ammo_rockets >= autocvar_g_balance_hagar_secondary_ammo;
281 ammo_amount += self.weapon_load[WEP_HAGAR] >= autocvar_g_balance_hagar_secondary_ammo;
284 else if (req == WR_RELOAD)
286 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");
292 float w_hagar(float req)
294 if(req == WR_IMPACTEFFECT)
297 org2 = w_org + w_backoff * 6;
298 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
302 sound(self, CHAN_PROJECTILE, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
303 else if (w_random<0.7)
304 sound(self, CHAN_PROJECTILE, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
306 sound(self, CHAN_PROJECTILE, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
309 else if(req == WR_PRECACHE)
311 precache_sound("weapons/hagexp1.wav");
312 precache_sound("weapons/hagexp2.wav");
313 precache_sound("weapons/hagexp3.wav");
315 else if (req == WR_SUICIDEMESSAGE)
316 w_deathtypestring = _("%s played with tiny rockets");
317 else if (req == WR_KILLMESSAGE)
319 if(w_deathtype & HITTYPE_BOUNCE) // must be secondary; unchecked: SPLASH
320 w_deathtypestring = _("%s hoped %s's missiles wouldn't bounce");
321 else // unchecked: SPLASH, SECONDARY
322 w_deathtypestring = _("%s was pummeled by %s");