]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/w_electro.qc
Clean up SetupProjectileVelocity a little bit
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_electro.qc
index 53fb053a8deed280833722ff02ac2ee090b0c4fb..352e4eeae5d282c325f10eefb3eb1f3fc2345d5c 100644 (file)
@@ -6,6 +6,7 @@ REGISTER_WEAPON(
 /* impulse  */ 5,
 /* flags    */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH,
 /* rating   */ BOT_PICKUP_RATING_MID,
+/* color       */ '0 0.5 1',
 /* model    */ "electro",
 /* netname  */ "electro",
 /* fullname */ _("Electro")
@@ -13,38 +14,38 @@ REGISTER_WEAPON(
 
 #define ELECTRO_SETTINGS(w_cvar,w_prop) ELECTRO_SETTINGS_LIST(w_cvar, w_prop, ELECTRO, electro)
 #define ELECTRO_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
-       w_cvar(id, sn, MO_BOTH, ammo) \
-       w_cvar(id, sn, MO_BOTH, animtime) \
-       w_cvar(id, sn, MO_BOTH, damage) \
-       w_cvar(id, sn, MO_BOTH, edgedamage) \
-       w_cvar(id, sn, MO_BOTH, force) \
-       w_cvar(id, sn, MO_BOTH, radius) \
-       w_cvar(id, sn, MO_BOTH, refire) \
-       w_cvar(id, sn, MO_BOTH, speed) \
-       w_cvar(id, sn, MO_BOTH, spread) \
-       w_cvar(id, sn, MO_BOTH, lifetime) \
-       w_cvar(id, sn, MO_PRI,  comboradius) \
-       w_cvar(id, sn, MO_PRI,  midaircombo_explode) \
-       w_cvar(id, sn, MO_PRI,  midaircombo_interval) \
-       w_cvar(id, sn, MO_PRI,  midaircombo_radius) \
-       w_cvar(id, sn, MO_SEC,  bouncefactor) \
-       w_cvar(id, sn, MO_SEC,  bouncestop) \
-       w_cvar(id, sn, MO_SEC,  count) \
-       w_cvar(id, sn, MO_SEC,  damageforcescale) \
-       w_cvar(id, sn, MO_SEC,  damagedbycontents) \
-       w_cvar(id, sn, MO_SEC,  health) \
-       w_cvar(id, sn, MO_SEC,  refire2) \
-       w_cvar(id, sn, MO_SEC,  speed_up) \
-       w_cvar(id, sn, MO_SEC,  speed_z) \
-       w_cvar(id, sn, MO_SEC,  touchexplode) \
-       w_cvar(id, sn, MO_NONE, combo_comboradius) \
-       w_cvar(id, sn, MO_NONE, combo_comboradius_thruwall) \
-       w_cvar(id, sn, MO_NONE, combo_damage) \
-       w_cvar(id, sn, MO_NONE, combo_edgedamage) \
-       w_cvar(id, sn, MO_NONE, combo_force) \
-       w_cvar(id, sn, MO_NONE, combo_radius) \
-       w_cvar(id, sn, MO_NONE, combo_speed) \
-       w_cvar(id, sn, MO_NONE, combo_safeammocheck) \
+       w_cvar(id, sn, BOTH, ammo) \
+       w_cvar(id, sn, BOTH, animtime) \
+       w_cvar(id, sn, BOTH, damage) \
+       w_cvar(id, sn, BOTH, edgedamage) \
+       w_cvar(id, sn, BOTH, force) \
+       w_cvar(id, sn, BOTH, radius) \
+       w_cvar(id, sn, BOTH, refire) \
+       w_cvar(id, sn, BOTH, speed) \
+       w_cvar(id, sn, BOTH, spread) \
+       w_cvar(id, sn, BOTH, lifetime) \
+       w_cvar(id, sn, PRI,  comboradius) \
+       w_cvar(id, sn, PRI,  midaircombo_explode) \
+       w_cvar(id, sn, PRI,  midaircombo_interval) \
+       w_cvar(id, sn, PRI,  midaircombo_radius) \
+       w_cvar(id, sn, SEC,  bouncefactor) \
+       w_cvar(id, sn, SEC,  bouncestop) \
+       w_cvar(id, sn, SEC,  count) \
+       w_cvar(id, sn, SEC,  damageforcescale) \
+       w_cvar(id, sn, SEC,  damagedbycontents) \
+       w_cvar(id, sn, SEC,  health) \
+       w_cvar(id, sn, SEC,  refire2) \
+       w_cvar(id, sn, SEC,  speed_up) \
+       w_cvar(id, sn, SEC,  speed_z) \
+       w_cvar(id, sn, SEC,  touchexplode) \
+       w_cvar(id, sn, NONE, combo_comboradius) \
+       w_cvar(id, sn, NONE, combo_comboradius_thruwall) \
+       w_cvar(id, sn, NONE, combo_damage) \
+       w_cvar(id, sn, NONE, combo_edgedamage) \
+       w_cvar(id, sn, NONE, combo_force) \
+       w_cvar(id, sn, NONE, combo_radius) \
+       w_cvar(id, sn, NONE, combo_speed) \
+       w_cvar(id, sn, NONE, combo_safeammocheck) \
        w_prop(id, sn, float,  reloading_ammo, reload_ammo) \
        w_prop(id, sn, float,  reloading_time, reload_time) \
        w_prop(id, sn, float,  switchdelay_raise, switchdelay_raise) \
@@ -57,18 +58,18 @@ REGISTER_WEAPON(
 ELECTRO_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 .float electro_count;
 .float electro_secondarytime;
-void W_Plasma_Explode_Combo(void);
+void W_Electro_ExplodeCombo(void);
 #endif
 #else
 #ifdef SVQC
 void spawnfunc_weapon_electro() { weapon_defaultspawnfunc(WEP_ELECTRO); }
 
-void W_Plasma_TriggerCombo(vector org, float rad, entity own)
+void W_Electro_TriggerCombo(vector org, float rad, entity own)
 {
        entity e = WarpZone_FindRadius(org, rad, !WEP_CVAR(electro, combo_comboradius_thruwall));
        while(e)
        {
-               if(e.classname == "plasma")
+               if(e.classname == "electro_orb")
                {
                        // do we allow thruwall triggering?
                        if(WEP_CVAR(electro, combo_comboradius_thruwall))
@@ -89,10 +90,10 @@ void W_Plasma_TriggerCombo(vector org, float rad, entity own)
                        // change owner to whoever caused the combo explosion
                        e.realowner = own;
                        e.takedamage = DAMAGE_NO;
-                       e.classname = "plasma_chain";
+                       e.classname = "electro_orb_chain";
                        
                        // now set the next one to trigger as well
-                       e.think = W_Plasma_Explode_Combo;
+                       e.think = W_Electro_ExplodeCombo;
                        
                        // delay combo chains, looks cooler
                        e.nextthink =
@@ -110,7 +111,29 @@ void W_Plasma_TriggerCombo(vector org, float rad, entity own)
        }
 }
 
-void W_Plasma_Explode(void)
+void W_Electro_ExplodeCombo(void)
+{
+       W_Electro_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
+
+       self.event_damage = func_null;
+       
+       RadiusDamage(
+               self,
+               self.realowner,
+               WEP_CVAR(electro, combo_damage),
+               WEP_CVAR(electro, combo_edgedamage),
+               WEP_CVAR(electro, combo_radius),
+               world,
+               world,
+               WEP_CVAR(electro, combo_force),
+               WEP_ELECTRO | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce
+               world
+       );
+
+       remove(self);
+}
+
+void W_Electro_Explode(void)
 {
        if(other.takedamage == DAMAGE_AIM)
                if(IS_PLAYER(other))
@@ -139,7 +162,7 @@ void W_Plasma_Explode(void)
        }
        else
        {
-               W_Plasma_TriggerCombo(self.origin, WEP_CVAR_PRI(electro, comboradius), self.realowner);
+               W_Electro_TriggerCombo(self.origin, WEP_CVAR_PRI(electro, comboradius), self.realowner);
                RadiusDamage(
                        self,
                        self.realowner,
@@ -157,90 +180,13 @@ void W_Plasma_Explode(void)
        remove(self);
 }
 
-void W_Plasma_Explode_Combo(void)
-{
-       W_Plasma_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
-
-       self.event_damage = func_null;
-       
-       RadiusDamage(
-               self,
-               self.realowner,
-               WEP_CVAR(electro, combo_damage),
-               WEP_CVAR(electro, combo_edgedamage),
-               WEP_CVAR(electro, combo_radius),
-               world,
-               world,
-               WEP_CVAR(electro, combo_force),
-               WEP_ELECTRO | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce
-               world
-       );
-
-       remove(self);
-}
-
-void W_Plasma_Touch(void)
+void W_Electro_TouchExplode(void)
 {
        PROJECTILE_TOUCH;
-       if(other.takedamage == DAMAGE_AIM)
-               { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Plasma_Explode(); } }
-       else
-       {
-               //UpdateCSQCProjectile(self);
-               spamsound(self, CH_SHOTS, "weapons/electro_bounce.wav", VOL_BASE, ATTEN_NORM);
-               self.projectiledeathtype |= HITTYPE_BOUNCE;
-       }
-}
-
-void W_Plasma_TouchExplode(void)
-{
-       PROJECTILE_TOUCH;
-       W_Plasma_Explode();
+       W_Electro_Explode();
 }
 
-void W_Plasma_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
-{
-       if(self.health <= 0)
-               return;
-
-       // note: combos are usually triggered by W_Plasma_TriggerCombo, not damage
-       float is_combo = (inflictor.classname == "plasma_chain" || inflictor.classname == "plasma_prim");
-
-       if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_combo ? 1 : -1)))
-               return; // g_projectiles_damage says to halt
-
-       self.health = self.health - damage;
-       if(self.health <= 0)
-       {
-               self.takedamage = DAMAGE_NO;
-               self.nextthink = time;
-               if(is_combo)
-               {
-                       // change owner to whoever caused the combo explosion
-                       self.realowner = inflictor.realowner;
-                       self.classname = "plasma_chain";
-                       self.think = W_Plasma_Explode_Combo;
-                       self.nextthink = time +
-                               (
-                                       // bound the length, inflictor may be in a galaxy far far away (warpzones)
-                                       min(
-                                               WEP_CVAR(electro, combo_radius),
-                                               vlen(self.origin - inflictor.origin)
-                                       )
-                                       /
-                                       // delay combo chains, looks cooler
-                                       WEP_CVAR(electro, combo_speed)
-                               );
-               }
-               else
-               {
-                       self.use = W_Plasma_Explode;
-                       self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
-               }
-       }
-}
-
-void W_Plasma_Think()
+void W_Electro_Bolt_Think()
 {
        if(time >= self.ltime)
        {
@@ -256,15 +202,15 @@ void W_Plasma_Think()
                // loop through nearby orbs and trigger them
                while(e)
                {
-                       if(e.classname == "plasma")
+                       if(e.classname == "electro_orb")
                        {
                                // change owner to whoever caused the combo explosion
                                e.realowner = self.realowner;
                                e.takedamage = DAMAGE_NO;
-                               e.classname = "plasma_chain";
+                               e.classname = "electro_orb_chain";
 
                                // now set the next one to trigger as well
-                               e.think = W_Plasma_Explode_Combo;
+                               e.think = W_Electro_ExplodeCombo;
                                
                                // delay combo chains, looks cooler
                                e.nextthink =
@@ -296,19 +242,19 @@ void W_Electro_Attack_Bolt(void)
 {
        entity proj;
 
-       W_DecreaseAmmo(ammo_cells, WEP_CVAR_PRI(electro, ammo), autocvar_g_balance_electro_reload_ammo);//weapontodo
+       W_DecreaseAmmo(WEP_CVAR_PRI(electro, ammo));
 
        W_SetupShot_ProjectileSize(self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(electro, damage));
 
        pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
 
        proj = spawn ();
-       proj.classname = "plasma_prim";
+       proj.classname = "electro_bolt";
        proj.owner = proj.realowner = self;
        proj.bot_dodge = TRUE;
        proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
-       proj.use = W_Plasma_Explode;
-       proj.think = W_Plasma_Think;
+       proj.use = W_Electro_Explode;
+       proj.think = W_Electro_Bolt_Think;
        proj.nextthink = time;
        proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
        PROJECTILE_MAKETRIGGER(proj);
@@ -316,9 +262,9 @@ void W_Electro_Attack_Bolt(void)
        setorigin(proj, w_shotorg);
 
        proj.movetype = MOVETYPE_FLY;
-       WEP_SETUPPROJVELOCITY_PRI(proj, electro);
+       WEP_SPV_PRI(proj, electro);
        proj.angles = vectoangles(proj.velocity);
-       proj.touch = W_Plasma_TouchExplode;
+       proj.touch = W_Electro_TouchExplode;
        setsize(proj, '0 0 -3', '0 0 -3');
        proj.flags = FL_PROJECTILE;
        proj.missile_flags = MIF_SPLASH;
@@ -328,9 +274,64 @@ void W_Electro_Attack_Bolt(void)
        other = proj; MUTATOR_CALLHOOK(EditProjectile);
 }
 
-void W_Electro_Attack_Orbs(void)
+void W_Electro_Orb_Touch(void)
+{
+       PROJECTILE_TOUCH;
+       if(other.takedamage == DAMAGE_AIM)
+               { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(); } }
+       else
+       {
+               //UpdateCSQCProjectile(self);
+               spamsound(self, CH_SHOTS, "weapons/electro_bounce.wav", VOL_BASE, ATTEN_NORM);
+               self.projectiledeathtype |= HITTYPE_BOUNCE;
+       }
+}
+
+void W_Electro_Orb_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
+{
+       if(self.health <= 0)
+               return;
+
+       // note: combos are usually triggered by W_Electro_TriggerCombo, not damage
+       float is_combo = (inflictor.classname == "electro_orb_chain" || inflictor.classname == "electro_bolt");
+
+       if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_combo ? 1 : -1)))
+               return; // g_projectiles_damage says to halt
+
+       self.health = self.health - damage;
+       if(self.health <= 0)
+       {
+               self.takedamage = DAMAGE_NO;
+               self.nextthink = time;
+               if(is_combo)
+               {
+                       // change owner to whoever caused the combo explosion
+                       self.realowner = inflictor.realowner;
+                       self.classname = "electro_orb_chain";
+                       self.think = W_Electro_ExplodeCombo;
+                       self.nextthink = time +
+                               (
+                                       // bound the length, inflictor may be in a galaxy far far away (warpzones)
+                                       min(
+                                               WEP_CVAR(electro, combo_radius),
+                                               vlen(self.origin - inflictor.origin)
+                                       )
+                                       /
+                                       // delay combo chains, looks cooler
+                                       WEP_CVAR(electro, combo_speed)
+                               );
+               }
+               else
+               {
+                       self.use = W_Electro_Explode;
+                       self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
+               }
+       }
+}
+
+void W_Electro_Attack_Orb(void)
 {
-       W_DecreaseAmmo(ammo_cells, WEP_CVAR_SEC(electro, ammo), autocvar_g_balance_electro_reload_ammo);//weapontodo
+       W_DecreaseAmmo(WEP_CVAR_SEC(electro, ammo));
 
        W_SetupShot_ProjectileSize(self, '0 0 -4', '0 0 -4', FALSE, 2, "weapons/electro_fire2.wav", CH_WEAPON_A, WEP_CVAR_SEC(electro, damage));
 
@@ -339,9 +340,9 @@ void W_Electro_Attack_Orbs(void)
        pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
 
        entity proj = spawn();
-       proj.classname = "plasma";
+       proj.classname = "electro_orb";
        proj.owner = proj.realowner = self;
-       proj.use = W_Plasma_Explode;
+       proj.use = W_Electro_Explode;
        proj.think = adaptor_think2use_hittype_splash;
        proj.bot_dodge = TRUE;
        proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
@@ -353,13 +354,13 @@ void W_Electro_Attack_Orbs(void)
        //proj.glow_size = 50;
        //proj.glow_color = 45;
        proj.movetype = MOVETYPE_BOUNCE;
-       WEP_SETUPPROJVELOCITY_UP_SEC(proj, electro);
-       proj.touch = W_Plasma_Touch;
+       WEP_SPV_UP_SEC(proj, electro);
+       proj.touch = W_Electro_Orb_Touch;
        setsize(proj, '0 0 -4', '0 0 -4');
        proj.takedamage = DAMAGE_YES;
        proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
        proj.health = WEP_CVAR_SEC(electro, health);
-       proj.event_damage = W_Plasma_Damage;
+       proj.event_damage = W_Electro_Orb_Damage;
        proj.flags = FL_PROJECTILE;
        proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents));
 
@@ -386,11 +387,12 @@ void W_Electro_CheckAttack()
        if(self.BUTTON_ATCK2)
        if(weapon_prepareattack(1, -1))
        {
-               W_Electro_Attack_Orbs();
+               W_Electro_Attack_Orb();
                self.electro_count -= 1;
                weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
                return;
        }
+       // WEAPONTODO: when the player releases the button, cut down the length of refire2? 
        w_ready();
 }
 
@@ -462,7 +464,7 @@ float W_Electro(float req)
                                if(time >= self.electro_secondarytime)
                                if(weapon_prepareattack(1, WEP_CVAR_SEC(electro, refire)))
                                {
-                                       W_Electro_Attack_Orbs();
+                                       W_Electro_Attack_Orb();
                                        self.electro_count = WEP_CVAR_SEC(electro, count);
                                        weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
                                        self.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
@@ -484,14 +486,9 @@ float W_Electro(float req)
                        ELECTRO_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
                        return TRUE;
                }
-               case WR_SETUP:
-               {
-                       self.current_ammo = ammo_cells;
-                       return TRUE;
-               }
                case WR_CHECKAMMO1:
                {
-                       ammo_amount = self.ammo_cells >= WEP_CVAR_PRI(electro, ammo);
+                       ammo_amount = self.AMMO_VAL(WEP_ELECTRO) >= WEP_CVAR_PRI(electro, ammo);
                        ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_PRI(electro, ammo);
                        return ammo_amount;
                }
@@ -499,12 +496,12 @@ float W_Electro(float req)
                {
                        if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
                        {
-                               ammo_amount = self.ammo_cells >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
+                               ammo_amount = self.AMMO_VAL(WEP_ELECTRO) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
                                ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
                        }
                        else
                        {
-                               ammo_amount = self.ammo_cells >= WEP_CVAR_SEC(electro, ammo);
+                               ammo_amount = self.AMMO_VAL(WEP_ELECTRO) >= WEP_CVAR_SEC(electro, ammo);
                                ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo);
                        }
                        return ammo_amount;