]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/electro.qc
Merge branch 'terencehill/quickmenu_file_example' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / electro.qc
index 073a4e0f597ea73fab2d6c8d77d7e5b72d3dfc43..0f48bb2591688df274c36ccea961186d9d94140a 100644 (file)
@@ -13,7 +13,7 @@ CLASS(Electro, Weapon)
 /* crosshair */ ATTRIB(Electro, w_crosshair_size, float, 0.6);
 /* wepimg    */ ATTRIB(Electro, model2, string, "weaponelectro");
 /* refname   */ ATTRIB(Electro, netname, string, "electro");
-/* wepname   */ ATTRIB(Electro, message, string, _("Electro"));
+/* wepname   */ ATTRIB(Electro, m_name, string, _("Electro"));
 ENDCLASS(Electro)
 REGISTER_WEAPON(ELECTRO, NEW(Electro));
 
@@ -64,12 +64,12 @@ REGISTER_WEAPON(ELECTRO, NEW(Electro));
 ELECTRO_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 .float electro_count;
 .float electro_secondarytime;
-void W_Electro_ExplodeCombo(void);
+void W_Electro_ExplodeCombo();
 #endif
 #endif
 #ifdef IMPLEMENTATION
 #ifdef SVQC
-void spawnfunc_weapon_electro(void) { weapon_defaultspawnfunc(WEP_ELECTRO.m_id); }
+spawnfunc(weapon_electro) { weapon_defaultspawnfunc(this, WEP_ELECTRO); }
 
 void W_Electro_TriggerCombo(vector org, float rad, entity own)
 {
@@ -118,7 +118,7 @@ void W_Electro_TriggerCombo(vector org, float rad, entity own)
        }
 }
 
-void W_Electro_ExplodeCombo(void)
+void W_Electro_ExplodeCombo()
 {SELFPARAM();
        W_Electro_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
 
@@ -140,7 +140,7 @@ void W_Electro_ExplodeCombo(void)
        remove(self);
 }
 
-void W_Electro_Explode(void)
+void W_Electro_Explode()
 {SELFPARAM();
        if(other.takedamage == DAMAGE_AIM)
                if(IS_PLAYER(other))
@@ -187,13 +187,13 @@ void W_Electro_Explode(void)
        remove(self);
 }
 
-void W_Electro_TouchExplode(void)
+void W_Electro_TouchExplode()
 {
        PROJECTILE_TOUCH;
        W_Electro_Explode();
 }
 
-void W_Electro_Bolt_Think(void)
+void W_Electro_Bolt_Think()
 {SELFPARAM();
        if(time >= self.ltime)
        {
@@ -245,11 +245,11 @@ void W_Electro_Bolt_Think(void)
        else { self.nextthink = self.ltime; }
 }
 
-void W_Electro_Attack_Bolt(void)
+void W_Electro_Attack_Bolt(Weapon thiswep)
 {SELFPARAM();
        entity proj;
 
-       W_DecreaseAmmo(WEP_CVAR_PRI(electro, ammo));
+       W_DecreaseAmmo(thiswep, self, WEP_CVAR_PRI(electro, ammo));
 
        W_SetupShot_ProjectileSize(
                self,
@@ -264,8 +264,7 @@ void W_Electro_Attack_Bolt(void)
 
        Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 
-       proj = spawn();
-       proj.classname = "electro_bolt";
+       proj = new(electro_bolt);
        proj.owner = proj.realowner = self;
        proj.bot_dodge = true;
        proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
@@ -290,7 +289,7 @@ void W_Electro_Attack_Bolt(void)
        MUTATOR_CALLHOOK(EditProjectile, self, proj);
 }
 
-void W_Electro_Orb_Touch(void)
+void W_Electro_Orb_Touch()
 {SELFPARAM();
        PROJECTILE_TOUCH;
        if(other.takedamage == DAMAGE_AIM)
@@ -345,9 +344,9 @@ void W_Electro_Orb_Damage(entity inflictor, entity attacker, float damage, int d
        }
 }
 
-void W_Electro_Attack_Orb(void)
+void W_Electro_Attack_Orb(Weapon thiswep)
 {SELFPARAM();
-       W_DecreaseAmmo(WEP_CVAR_SEC(electro, ammo));
+       W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(electro, ammo));
 
        W_SetupShot_ProjectileSize(
                self,
@@ -364,8 +363,7 @@ void W_Electro_Attack_Orb(void)
 
        Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 
-       entity proj = spawn();
-       proj.classname = "electro_orb";
+       entity proj = new(electro_orb);
        proj.owner = proj.realowner = self;
        proj.use = W_Electro_Explode;
        proj.think = adaptor_think2use_hittype_splash;
@@ -406,24 +404,24 @@ void W_Electro_Attack_Orb(void)
        MUTATOR_CALLHOOK(EditProjectile, self, proj);
 }
 
-void W_Electro_CheckAttack(void)
+void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {SELFPARAM();
        if(self.electro_count > 1)
        if(self.BUTTON_ATCK2)
-       if(weapon_prepareattack(1, -1))
+       if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1))
        {
-               W_Electro_Attack_Orb();
+               W_Electro_Attack_Orb(WEP_ELECTRO);
                self.electro_count -= 1;
-               weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
+               weapon_thinkf(actor, weaponentity, 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();
+       w_ready(thiswep, actor, weaponentity, fire);
 }
 
 .float bot_secondary_electromooth;
 
-               METHOD(Electro, wr_aim, bool(entity thiswep))
+               METHOD(Electro, wr_aim, void(entity thiswep))
                {
                        self.BUTTON_ATCK = self.BUTTON_ATCK2 = false;
                        if(vlen(self.origin-self.enemy.origin) > 1000) { self.bot_secondary_electromooth = 0; }
@@ -450,54 +448,48 @@ void W_Electro_CheckAttack(void)
                                        if(random() < 0.03) self.bot_secondary_electromooth = 0;
                                }
                        }
-
-                       return true;
                }
-               METHOD(Electro, wr_think, bool(entity thiswep))
+               METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
                        {
                                float ammo_amount = 0;
-                               if(self.clip_load >= WEP_CVAR_PRI(electro, ammo))
+                               if(actor.clip_load >= WEP_CVAR_PRI(electro, ammo))
                                        ammo_amount = 1;
-                               if(self.clip_load >= WEP_CVAR_SEC(electro, ammo))
+                               if(actor.clip_load >= WEP_CVAR_SEC(electro, ammo))
                                        ammo_amount += 1;
 
                                if(!ammo_amount)
                                {
-                                       _WEP_ACTION(self.weapon, WR_RELOAD);
-                                       return false;
+                                       Weapon w = get_weaponinfo(actor.weapon);
+                                       w.wr_reload(w);
+                                       return;
                                }
-
-                               return true;
                        }
 
-                       if(self.BUTTON_ATCK)
+                       if(fire & 1)
                        {
-                               if(weapon_prepareattack(0, WEP_CVAR_PRI(electro, refire)))
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire)))
                                {
-                                               W_Electro_Attack_Bolt();
-                                               weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+                                               W_Electro_Attack_Bolt(thiswep);
+                                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
                                }
                        }
-                       else if(self.BUTTON_ATCK2)
+                       else if(fire & 2)
                        {
-                               if(time >= self.electro_secondarytime)
-                               if(weapon_prepareattack(1, WEP_CVAR_SEC(electro, refire)))
+                               if(time >= actor.electro_secondarytime)
+                               if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(electro, refire)))
                                {
-                                       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();
+                                       W_Electro_Attack_Orb(thiswep);
+                                       actor.electro_count = WEP_CVAR_SEC(electro, count);
+                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
+                                       actor.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
                                }
                        }
-
-                       return true;
                }
-               METHOD(Electro, wr_init, bool(entity thiswep))
+               METHOD(Electro, wr_init, void(entity thiswep))
                {
                        ELECTRO_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
-                       return true;
                }
                METHOD(Electro, wr_checkammo1, bool(entity thiswep))
                {
@@ -520,29 +512,26 @@ void W_Electro_CheckAttack(void)
                        }
                        return ammo_amount;
                }
-               METHOD(Electro, wr_config, bool(entity thiswep))
+               METHOD(Electro, wr_config, void(entity thiswep))
                {
                        ELECTRO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
-                       return true;
                }
-               METHOD(Electro, wr_resetplayer, bool(entity thiswep))
+               METHOD(Electro, wr_resetplayer, void(entity thiswep))
                {
                        self.electro_secondarytime = time;
-                       return true;
                }
-               METHOD(Electro, wr_reload, bool(entity thiswep))
+               METHOD(Electro, wr_reload, void(entity thiswep))
                {
-                       W_Reload(min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND(RELOAD));
-                       return true;
+                       W_Reload(self, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND(RELOAD));
                }
-               METHOD(Electro, wr_suicidemessage, bool(entity thiswep))
+               METHOD(Electro, wr_suicidemessage, int(entity thiswep))
                {
                        if(w_deathtype & HITTYPE_SECONDARY)
                                return WEAPON_ELECTRO_SUICIDE_ORBS;
                        else
                                return WEAPON_ELECTRO_SUICIDE_BOLT;
                }
-               METHOD(Electro, wr_killmessage, bool(entity thiswep))
+               METHOD(Electro, wr_killmessage, int(entity thiswep))
                {
                        if(w_deathtype & HITTYPE_SECONDARY)
                        {
@@ -560,13 +549,13 @@ void W_Electro_CheckAttack(void)
 #endif
 #ifdef CSQC
 
-               METHOD(Electro, wr_impacteffect, bool(entity thiswep))
+               METHOD(Electro, wr_impacteffect, void(entity thiswep))
                {
                        vector org2;
                        org2 = w_org + w_backoff * 6;
                        if(w_deathtype & HITTYPE_SECONDARY)
                        {
-                               pointparticles(particleeffectnum(EFFECT_ELECTRO_BALLEXPLODE), org2, '0 0 0', 1);
+                               pointparticles(EFFECT_ELECTRO_BALLEXPLODE, org2, '0 0 0', 1);
                                if(!w_issilent)
                                        sound(self, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
                        }
@@ -575,28 +564,17 @@ void W_Electro_CheckAttack(void)
                                if(w_deathtype & HITTYPE_BOUNCE)
                                {
                                        // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
-                                       pointparticles(particleeffectnum(EFFECT_ELECTRO_COMBO), org2, '0 0 0', 1);
+                                       pointparticles(EFFECT_ELECTRO_COMBO, org2, '0 0 0', 1);
                                        if(!w_issilent)
                                                sound(self, CH_SHOTS, SND_ELECTRO_IMPACT_COMBO, VOL_BASE, ATTEN_NORM);
                                }
                                else
                                {
-                                       pointparticles(particleeffectnum(EFFECT_ELECTRO_IMPACT), org2, '0 0 0', 1);
+                                       pointparticles(EFFECT_ELECTRO_IMPACT, org2, '0 0 0', 1);
                                        if(!w_issilent)
                                                sound(self, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
                                }
                        }
-
-                       return true;
-               }
-               METHOD(Electro, wr_init, bool(entity thiswep))
-               {
-                       return true;
-               }
-               METHOD(Electro, wr_zoomreticle, bool(entity thiswep))
-               {
-                       // no weapon specific image for this weapon
-                       return false;
                }
 
 #endif