]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/vaporizer.qc
Merge W_RocketMinsta_Attack2 and W_RocketMinsta_Attack3 code and do some minor cleanu...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / vaporizer.qc
index 0059e92ed3260b7c663f6b16becb7428b4e4c165..09d8ef36b696e04e142611f3df648f3464a01f26 100644 (file)
@@ -184,106 +184,62 @@ void W_RocketMinsta_Laser_Touch(entity this, entity toucher)
        delete(this);
 }
 
-void W_RocketMinsta_Attack2(entity actor, .entity weaponentity)
+// mode 0 fires many projectiles
+// mode 1 fires 1 projectile
+void W_RocketMinsta_Attack(entity actor, .entity weaponentity, int mode)
 {
        makevectors(actor.v_angle);
 
        entity proj;
-       float counter = 0;
-       float total = autocvar_g_rm_laser_count;
-       float spread = autocvar_g_rm_laser_spread;
-       float rndspread = autocvar_g_rm_laser_spread_random;
-
-       W_SetupShot_ProjectileSize (actor, weaponentity, '0 0 -3', '0 0 -3', false, 2, SND_CRYLINK_FIRE, CH_WEAPON_A, autocvar_g_rm_laser_damage, WEP_ELECTRO.m_id);
+       int laser_count = max(1, autocvar_g_rm_laser_count);
+       int total = (mode == 0) ? laser_count : 1;
+       Sound snd = (mode == 0) ? SND_CRYLINK_FIRE : SND_ELECTRO_FIRE2;
+       W_SetupShot_ProjectileSize(actor, weaponentity, '0 0 -3', '0 0 -3', false, 2, snd, CH_WEAPON_A, autocvar_g_rm_laser_damage, WEP_ELECTRO.m_id);
 
        // uses electro effects
        W_MuzzleFlash(WEP_ELECTRO, actor, weaponentity, w_shotorg, w_shotdir);
 
-    while(counter < total)
+       for (int counter = 0; counter < total; counter++)
        {
-        proj = new(plasma_prim);
-        proj.owner = proj.realowner = actor;
-        proj.bot_dodge = true;
-        proj.bot_dodgerating = autocvar_g_rm_laser_damage;
-        proj.use = W_RocketMinsta_Laser_Explode_use;
-        setthink(proj, adaptor_think2use_hittype_splash);
-        proj.nextthink = time + autocvar_g_rm_laser_lifetime;
-        PROJECTILE_MAKETRIGGER(proj);
-        proj.projectiledeathtype = WEP_ELECTRO.m_id;
-        proj.weaponentity_fld = weaponentity;
-        setorigin(proj, w_shotorg);
+               proj = new(plasma_prim);
+               proj.owner = proj.realowner = actor;
+               proj.bot_dodge = true;
+               proj.bot_dodgerating = autocvar_g_rm_laser_damage;
+               proj.use = W_RocketMinsta_Laser_Explode_use;
+               setthink(proj, adaptor_think2use_hittype_splash);
+               proj.nextthink = time + autocvar_g_rm_laser_lifetime;
+               PROJECTILE_MAKETRIGGER(proj);
+               proj.projectiledeathtype = WEP_ELECTRO.m_id;
+               proj.weaponentity_fld = weaponentity;
+               setorigin(proj, w_shotorg);
 
                proj.rm_laser_count = total;
 
-        //W_SetupProjectileVelocity(proj, autocvar_g_rm_laser_speed, spread * (rndspread ? random() : 1) * autocvar_g_rm_laser_speed);
-
-        set_movetype(proj, MOVETYPE_BOUNCEMISSILE);
-        //W_SETUPPROJECTILEVELOCITY(proj, g_balance_minstanex_laser);
-               proj.velocity = (w_shotdir + (((counter + 0.5) / total) * 2 - 1) * v_right * (spread * (rndspread ? random() : 1))) * cvar("g_rm_laser_speed");
-               proj.velocity_z = proj.velocity_z + cvar("g_rm_laser_zspread") * (random() - 0.5);
+               //W_SetupProjectileVelocity(proj, autocvar_g_rm_laser_speed, spread * (rndspread ? random() : 1) * autocvar_g_rm_laser_speed);
+
+               set_movetype(proj, MOVETYPE_BOUNCEMISSILE);
+               if (mode == 0)
+               {
+                       float spread = autocvar_g_rm_laser_spread * (autocvar_g_rm_laser_spread_random ? random() : 1);
+                       //W_SETUPPROJECTILEVELOCITY(proj, g_balance_minstanex_laser);
+                       proj.velocity = (w_shotdir + (((counter + 0.5) / total) * 2 - 1) * v_right * spread) * cvar("g_rm_laser_speed");
+                       proj.velocity.z += cvar("g_rm_laser_zspread") * (random() - 0.5);
+               }
+               else
+                       proj.velocity = w_shotdir * autocvar_g_rm_laser_speed;
                proj.velocity = W_CalculateProjectileVelocity(actor, actor.velocity, proj.velocity, true);
-        proj.angles = vectoangles(proj.velocity);
-        settouch(proj, W_RocketMinsta_Laser_Touch);
-        setsize(proj, '0 0 -3', '0 0 -3');
-        proj.flags = FL_PROJECTILE;
-        IL_PUSH(g_projectiles, proj);
-        IL_PUSH(g_bot_dodge, proj);
-        proj.missile_flags = MIF_SPLASH;
-
-        CSQCProjectile(proj, true, PROJECTILE_ROCKETMINSTA_LASER, true);
-
-        MUTATOR_CALLHOOK(EditProjectile, actor, proj);
-        counter++;
-    }
-}
-
-void W_RocketMinsta_Attack3 (entity actor, .entity weaponentity)
-{
-       makevectors(actor.v_angle);
-
-       entity proj;
-       float counter = 0;
-       float total = 1;
-
-       W_SetupShot_ProjectileSize (actor, weaponentity, '0 0 -3', '0 0 -3', false, 2, SND_ELECTRO_FIRE2, CH_WEAPON_A, autocvar_g_rm_laser_damage, WEP_ELECTRO.m_id);
+               proj.angles = vectoangles(proj.velocity);
+               settouch(proj, W_RocketMinsta_Laser_Touch);
+               setsize(proj, '0 0 -3', '0 0 -3');
+               proj.flags = FL_PROJECTILE;
+               IL_PUSH(g_projectiles, proj);
+               IL_PUSH(g_bot_dodge, proj);
+               proj.missile_flags = MIF_SPLASH;
 
-       // uses electro effects
-       W_MuzzleFlash(WEP_ELECTRO, actor, weaponentity, w_shotorg, w_shotdir);
-
-    while(counter < total)
-       {
-        proj = new(plasma_prim);
-        proj.owner = proj.realowner = actor;
-        proj.bot_dodge = true;
-        proj.bot_dodgerating = autocvar_g_rm_laser_damage;
-        proj.use = W_RocketMinsta_Laser_Explode_use;
-        setthink(proj, adaptor_think2use_hittype_splash);
-        proj.nextthink = time + autocvar_g_rm_laser_lifetime;
-        PROJECTILE_MAKETRIGGER(proj);
-        proj.projectiledeathtype = WEP_ELECTRO.m_id;
-        proj.weaponentity_fld = weaponentity;
-        setorigin(proj, w_shotorg);
-
-               proj.rm_laser_count = total;
-
-        //W_SetupProjectileVelocity(proj, autocvar_g_rm_laser_speed, spread * (rndspread ? random() : 1) * autocvar_g_rm_laser_speed);
+               CSQCProjectile(proj, true, PROJECTILE_ROCKETMINSTA_LASER, true);
 
-        set_movetype(proj, MOVETYPE_BOUNCEMISSILE);
-               proj.velocity = w_shotdir * autocvar_g_rm_laser_speed;
-               proj.velocity = W_CalculateProjectileVelocity(actor, actor.velocity, proj.velocity, true);
-        proj.angles = vectoangles(proj.velocity);
-        settouch(proj, W_RocketMinsta_Laser_Touch);
-        setsize(proj, '0 0 -3', '0 0 -3');
-        proj.flags = FL_PROJECTILE;
-        IL_PUSH(g_projectiles, proj);
-        IL_PUSH(g_bot_dodge, proj);
-        proj.missile_flags = MIF_SPLASH;
-
-        CSQCProjectile(proj, true, PROJECTILE_ROCKETMINSTA_LASER, true);
-
-        MUTATOR_CALLHOOK(EditProjectile, actor, proj);
-        counter++;
-    }
+               MUTATOR_CALLHOOK(EditProjectile, actor, proj);
+       }
 }
 
 METHOD(Vaporizer, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
@@ -322,13 +278,13 @@ METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponent
                 actor.(weaponentity).jump_interval = time + autocvar_g_rm_laser_refire;
                 actor.(weaponentity).jump_interval2 = time + autocvar_g_rm_laser_rapid_delay;
                 impressive_hits = 0;
-                W_RocketMinsta_Attack2(actor, weaponentity);
+                W_RocketMinsta_Attack(actor, weaponentity, 0);
             }
             else if(rapid && actor.(weaponentity).jump_interval2 <= time && actor.(weaponentity).held_down)
             {
                 actor.(weaponentity).jump_interval2 = time + autocvar_g_rm_laser_rapid_refire;
                 impressive_hits = 0;
-                W_RocketMinsta_Attack3(actor, weaponentity);
+                W_RocketMinsta_Attack(actor, weaponentity, 1);
                 //weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_rm_laser_rapid_animtime, w_ready);
             }
         }