X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fw_hagar.qc;h=a628be25bbd3521e14a4204cf7ee2905ff010ae5;hb=ff52b5b146e83d1d61dc7304918fdb1f5b7d63f3;hp=c54164299a8f05cbbbeeeb2100efab68483d94b5;hpb=695cd1f79336cc38ce083bafe2118b44a638fde5;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/w_hagar.qc b/qcsrc/server/w_hagar.qc index c54164299..a628be25b 100644 --- a/qcsrc/server/w_hagar.qc +++ b/qcsrc/server/w_hagar.qc @@ -4,9 +4,6 @@ REGISTER_WEAPON(HAGAR, w_hagar, IT_ROCKETS, 8, WEP_FLAG_NORMAL | WEP_FLAG_RELOAD #ifdef SVQC // NO bounce protection, as bounces are limited! -.entity queuenext; -.entity queueprev; - void W_Hagar_Explode (void) { self.event_damage = SUB_Null; @@ -50,7 +47,7 @@ void W_Hagar_Attack (void) W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_reload_ammo); - W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_primary_damage); + W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, autocvar_g_balance_hagar_primary_damage); pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1); @@ -85,7 +82,7 @@ void W_Hagar_Attack2 (void) W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo, autocvar_g_balance_hagar_reload_ammo); - W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_secondary_damage); + W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, autocvar_g_balance_hagar_secondary_damage); pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1); @@ -115,116 +112,151 @@ void W_Hagar_Attack2 (void) other = missile; MUTATOR_CALLHOOK(EditProjectile); } -.float hagarload_refire; -void W_Hagar_Attack2_Load (void) +.float hagar_loadstep, hagar_loadblock, hagar_loadbeep; +void W_Hagar_Attack2_Load_Release (void) { - if not(weapon_action(self.weapon, WR_CHECKAMMO2)) - { - W_SwitchToOtherWeapon(self); - return; - } + // time to release the rockets we've loaded - local entity missile, prevmissile, firstmissile; - local float counter, shots, loaded; - local float used_ammo, enough_ammo; + local entity missile; + local float counter, shots; local vector s; vector forward, right, up; - loaded = self.hagar_load >= autocvar_g_balance_hagar_secondary_load_maxload; + if(!self.hagar_load) + return; - // check if we have enough ammo for another rocket - used_ammo = autocvar_g_balance_hagar_secondary_ammo; - if(autocvar_g_balance_hagar_reload_ammo) - enough_ammo = self.weapon_load[WEP_HAGAR] >= used_ammo + (used_ammo * self.hagar_load); - else - enough_ammo = self.ammo_rockets >= used_ammo + (used_ammo * self.hagar_load); + weapon_prepareattack_do(1, autocvar_g_balance_hagar_secondary_refire); + + W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, autocvar_g_balance_hagar_secondary_damage); + pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1); + + forward = v_forward; + right = v_right; + up = v_up; - if(self.BUTTON_ATCK2 && !loaded && enough_ammo) + shots = self.hagar_load; + missile = world; + while (counter < shots) { - // we can attempt to load another rocket - if(self.hagarload_refire < time) + missile = spawn (); + missile.owner = missile.realowner = self; + missile.classname = "missile"; + missile.bot_dodge = TRUE; + missile.bot_dodgerating = autocvar_g_balance_hagar_secondary_damage; + + missile.touch = W_Hagar_Touch; // not bouncy + missile.use = W_Hagar_Explode2; + missile.think = adaptor_think2use_hittype_splash; + missile.nextthink = time + autocvar_g_balance_hagar_secondary_lifetime_min + random() * autocvar_g_balance_hagar_secondary_lifetime_rand; + PROJECTILE_MAKETRIGGER(missile); + missile.projectiledeathtype = WEP_HAGAR; + setorigin (missile, w_shotorg); + setsize(missile, '0 0 0', '0 0 0'); + missile.movetype = MOVETYPE_FLY; + + s = '0 0 0'; + if (counter == 0) + s = '0 0 0'; + else { - self.hagar_load += 1; - sound(self, CHAN_WEAPON2, "weapons/hagar_load.wav", VOL_BASE, ATTN_NORM); - - self.hagarload_refire = time + autocvar_g_balance_hagar_secondary_refire; + makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1))); + s_y = v_forward_x; + s_z = v_forward_y; } + s = s * cvar("g_balance_hagar_secondary_spread") * g_weaponspreadfactor; + W_SetupProjectileVelocityEx(missile, w_shotdir + right * s_y + up * s_z, v_up, cvar("g_balance_hagar_secondary_speed"), 0, 0, 0, FALSE); + + missile.angles = vectoangles (missile.velocity); + missile.flags = FL_PROJECTILE; + + CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE); + + other = missile; MUTATOR_CALLHOOK(EditProjectile); + + counter = counter + 1; } - else if(self.hagar_load && (!self.BUTTON_ATCK2 || ((loaded || !enough_ammo) && !autocvar_g_balance_hagar_secondary_load_canhold))) - { - // time to release the rockets we've loaded - W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_secondary_damage); - pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1); + weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hagar_secondary_refire, w_ready); + self.hagar_loadstep = time + autocvar_g_balance_hagar_secondary_refire; + self.hagar_load = 0; +} + +void W_Hagar_Attack2_Load (void) +{ + // loadable hagar secondary attack, must always run each frame - W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo * self.hagar_load, autocvar_g_balance_hagar_reload_ammo); + local float loaded, enough_ammo; + loaded = self.hagar_load >= autocvar_g_balance_hagar_secondary_load_max; - forward = v_forward; - right = v_right; - up = v_up; + // this is different than WR_CHECKAMMO when it comes to reloading + if(autocvar_g_balance_hagar_reload_ammo) + enough_ammo = self.weapon_load[WEP_HAGAR] >= autocvar_g_balance_hagar_secondary_ammo; + else + enough_ammo = self.ammo_rockets >= autocvar_g_balance_hagar_secondary_ammo; - shots = self.hagar_load; - missile = world; - while (counter < shots) + if(self.BUTTON_ATCK2) + { + if(self.BUTTON_ATCK && autocvar_g_balance_hagar_secondary_load_abort) { - missile = spawn (); - missile.owner = missile.realowner = self; - missile.classname = "missile"; - missile.bot_dodge = TRUE; - missile.bot_dodgerating = autocvar_g_balance_hagar_secondary_damage; - - if(shots == 1) { - missile.queuenext = missile; - missile.queueprev = missile; - } - else if(counter == 0) { // first projectile, store in firstmissile for now - firstmissile = missile; - } - else if(counter == shots - 1) { // last projectile, link up with first projectile - prevmissile.queuenext = missile; - firstmissile.queueprev = missile; - missile.queuenext = firstmissile; - missile.queueprev = prevmissile; + if(self.hagar_load) + { + // if we pressed primary fire while loading, unload all rockets and abort + W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo + self.hagar_load = 0; + sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM); + + // pause until we can load rockets again, once we re-press the alt fire button + self.hagar_loadstep = time + autocvar_g_balance_hagar_secondary_load_speed; + + // require letting go of the alt fire button before we can load again + self.hagar_loadblock = TRUE; } - else { // else link up with previous projectile - prevmissile.queuenext = missile; - missile.queueprev = prevmissile; + } + else + { + // check if we can attempt to load another rocket + if(!loaded && enough_ammo) + { + if(!self.hagar_loadblock && self.hagar_loadstep < time) + { + W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo, autocvar_g_balance_hagar_reload_ammo); + self.hagar_load += 1; + sound(self, CH_WEAPON_B, "weapons/hagar_load.wav", VOL_BASE, ATTN_NORM); + + self.hagar_loadstep = time + autocvar_g_balance_hagar_secondary_load_speed; + } } - prevmissile = missile; - - missile.touch = W_Hagar_Touch; - missile.use = W_Hagar_Explode; - missile.think = adaptor_think2use_hittype_splash; - missile.nextthink = time + autocvar_g_balance_hagar_secondary_lifetime_min + random() * autocvar_g_balance_hagar_secondary_lifetime_rand; - PROJECTILE_MAKETRIGGER(missile); - missile.projectiledeathtype = WEP_HAGAR; - setorigin (missile, w_shotorg); - setsize(missile, '0 0 0', '0 0 0'); - missile.movetype = MOVETYPE_FLY; - - s = '0 0 0'; - if (counter == 0) - s = '0 0 0'; - else + else if(!self.hagar_loadbeep && self.hagar_load) // prevents the beep from playing each frame { - makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1))); - s_y = v_forward_x; - s_z = v_forward_y; + // if this is the last rocket we can load, play a beep sound to notify the player + sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM); + self.hagar_loadbeep = TRUE; } - s = s * autocvar_g_balance_hagar_secondary_load_spread * g_weaponspreadfactor; - W_SetupProjectileVelocityEx(missile, w_shotdir + right * s_y + up * s_z, v_up, cvar("g_balance_hagar_secondary_speed"), 0, 0, 0, FALSE); - - missile.angles = vectoangles (missile.velocity); - missile.flags = FL_PROJECTILE; - - CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE); - - other = missile; MUTATOR_CALLHOOK(EditProjectile); - - counter = counter + 1; } + } + else if(self.hagar_loadblock) + { + // the alt fire button has been released, so re-enable loading if blocked + self.hagar_loadblock = FALSE; + } - self.hagar_load = 0; + if(self.hagar_load) + { + self.weapon_forbidchange = TRUE; + if(!self.BUTTON_ATCK2 || ((loaded || !enough_ammo) && self.hagar_loadstep < time && !autocvar_g_balance_hagar_secondary_load_hold)) + W_Hagar_Attack2_Load_Release(); + } + else + { + self.weapon_forbidchange = FALSE; + self.hagar_loadbeep = FALSE; + } + + // we aren't checking ammo during an attack, so we must do it here + if not(weapon_action(self.weapon, WR_CHECKAMMO1) + weapon_action(self.weapon, WR_CHECKAMMO2)) + { + W_SwitchToOtherWeapon(self); + return; } } @@ -246,9 +278,14 @@ float w_hagar(float req) } else if (req == WR_THINK) { + local float loadable_secondary; + loadable_secondary = autocvar_g_balance_hagar_secondary_load && autocvar_g_balance_hagar_secondary; + + if (loadable_secondary) + W_Hagar_Attack2_Load(); // must always run each frame 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 weapon_action(self.weapon, WR_RELOAD); - else if (self.BUTTON_ATCK && !self.hagar_load) // not while loading the secondary fire + else if (self.BUTTON_ATCK && !self.hagar_load && !self.hagar_loadblock) // not while secondary is loaded or awaiting reset { if (weapon_prepareattack(0, autocvar_g_balance_hagar_primary_refire)) { @@ -256,9 +293,7 @@ float w_hagar(float req) weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hagar_primary_refire, w_ready); } } - else if(autocvar_g_balance_hagar_secondary_load && autocvar_g_balance_hagar_secondary) - W_Hagar_Attack2_Load(); // must run each frame - else if (self.BUTTON_ATCK2 && autocvar_g_balance_hagar_secondary) + else if (self.BUTTON_ATCK2 && !loadable_secondary && autocvar_g_balance_hagar_secondary) { if (weapon_prepareattack(1, autocvar_g_balance_hagar_secondary_refire)) { @@ -274,14 +309,20 @@ float w_hagar(float req) precache_model ("models/weapons/h_hagar.iqm"); precache_sound ("weapons/hagar_fire.wav"); precache_sound ("weapons/hagar_load.wav"); + precache_sound ("weapons/hagar_beep.wav"); //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else } else if (req == WR_SETUP) { weapon_setup(WEP_HAGAR); self.current_ammo = ammo_rockets; + self.hagar_loadblock = FALSE; - self.hagar_load = 0; + if(self.hagar_load) + { + W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo if necessary + self.hagar_load = 0; + } } else if (req == WR_CHECKAMMO1) { @@ -295,9 +336,20 @@ float w_hagar(float req) ammo_amount += self.weapon_load[WEP_HAGAR] >= autocvar_g_balance_hagar_secondary_ammo; return ammo_amount; } + else if (req == WR_RESETPLAYER) + { + self.hagar_load = 0; + } + else if (req == WR_PLAYERDEATH) + { + // if we have any rockets loaded when we die, release them + if(self.hagar_load && autocvar_g_balance_hagar_secondary_load_releasedeath) + W_Hagar_Attack2_Load_Release(); + } else if (req == WR_RELOAD) { - 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"); + if not(self.hagar_load) // require releasing loaded rockets first + 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"); } return TRUE; }; @@ -313,11 +365,11 @@ float w_hagar(float req) if(!w_issilent) { if (w_random<0.15) - sound(self, CHAN_PROJECTILE, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM); + sound(self, CH_SHOTS, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM); else if (w_random<0.7) - sound(self, CHAN_PROJECTILE, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM); + sound(self, CH_SHOTS, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM); else - sound(self, CHAN_PROJECTILE, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM); + sound(self, CH_SHOTS, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM); } } else if(req == WR_PRECACHE)