]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/w_arc.qc
Merge branch 'master' into TimePath/waypointsprites
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_arc.qc
index 5931f2fcc57624a52c11e8c72b2322c0c21450b0..893311441c82d5f0b6c52b453572e0857c518ef7 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef REGISTER_WEAPON
+#ifndef IMPLEMENTATION
 REGISTER_WEAPON(
 /* WEP_##id  */ ARC,
 /* function  */ W_Arc,
@@ -123,11 +123,12 @@ float Draw_ArcBeam_callback_last_thickness;
 vector Draw_ArcBeam_callback_last_top; // NOTE: in same coordinate system as player.
 vector Draw_ArcBeam_callback_last_bottom; // NOTE: in same coordinate system as player.
 #endif
-#else
+#endif
+#ifdef IMPLEMENTATION
 #ifdef SVQC
-void spawnfunc_weapon_arc(void) { weapon_defaultspawnfunc(WEP_ARC); }
+void spawnfunc_weapon_arc(void) { weapon_defaultspawnfunc(WEP_ARC.m_id); }
 
-float W_Arc_Beam_Send(entity to, float sf)
+float W_Arc_Beam_Send(entity to, int sf)
 {
        WriteByte(MSG_ENTITY, ENT_CLIENT_ARC_BEAM);
 
@@ -264,16 +265,17 @@ void W_Arc_Beam_Think(void)
 
                        if ( WEP_CVAR(arc, overheat_max) > 0 && self.beam_heat >= WEP_CVAR(arc, overheat_max) )
                        {
-                               pointparticles( particleeffectnum("arc_overheat"),
+                               Send_Effect("arc_overheat",
                                        self.beam_start, self.beam_wantdir, 1 );
-                               sound(self, CH_WEAPON_A, "weapons/arc_stop.wav", VOL_BASE, ATTN_NORM);
+                               sound(self, CH_WEAPON_A, W_Sound("arc_stop"), VOL_BASE, ATTN_NORM);
                        }
                }
 
                if(self == self.owner.arc_beam) { self.owner.arc_beam = world; }
                entity oldself = self;
                self = self.owner;
-               if(!WEP_ACTION(WEP_ARC, WR_CHECKAMMO1) && !WEP_ACTION(WEP_ARC, WR_CHECKAMMO2))
+               if(!WEP_ACTION(WEP_ARC.m_id, WR_CHECKAMMO1) && !WEP_ACTION(WEP_ARC.m_id, WR_CHECKAMMO2))
+               if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        // note: this doesn't force the switch
                        W_SwitchToOtherWeapon(self);
@@ -448,11 +450,11 @@ void W_Arc_Beam_Think(void)
                new_dir = WarpZone_TransformVelocity(WarpZone_trace_transform, new_dir);
 
                float is_player = (
-                       trace_ent.classname == "player"
+                       IS_PLAYER(trace_ent)
                        ||
                        trace_ent.classname == "body"
                        ||
-                       (trace_ent.flags & FL_MONSTER)
+                       IS_MONSTER(trace_ent)
                );
 
                if(trace_ent && trace_ent.takedamage && (is_player || WEP_CVAR(arc, beam_nonplayerdamage)))
@@ -529,7 +531,7 @@ void W_Arc_Beam_Think(void)
                                {
                                        accuracy_add(
                                                self.owner,
-                                               WEP_ARC,
+                                               WEP_ARC.m_id,
                                                0,
                                                rootdamage * coefficient * falloff
                                        );
@@ -540,7 +542,7 @@ void W_Arc_Beam_Think(void)
                                        self.owner,
                                        self.owner,
                                        rootdamage * coefficient * falloff,
-                                       WEP_ARC,
+                                       WEP_ARC.m_id,
                                        hitorigin,
                                        WEP_CVAR(arc, beam_force) * new_dir * coefficient * falloff
                                );
@@ -578,9 +580,7 @@ void W_Arc_Beam(float burst)
 
        // only play fire sound if 1 sec has passed since player let go the fire button
        if(time - self.beam_prev > 1)
-       {
-               sound(self, CH_WEAPON_A, "weapons/arc_fire.wav", VOL_BASE, ATTN_NORM);
-       }
+               sound(self, CH_WEAPON_A, W_Sound("arc_fire"), VOL_BASE, ATTN_NORM);
 
        entity beam = self.arc_beam = spawn();
        beam.classname = "W_Arc_Beam";
@@ -608,14 +608,14 @@ void Arc_Smoke()
        if ( self.arc_overheat > time )
        {
                if ( random() < self.arc_heat_percent )
-                       pointparticles( particleeffectnum("arc_smoke"), smoke_origin, '0 0 0', 1 );
+                       Send_Effect("arc_smoke", smoke_origin, '0 0 0', 1 );
                if ( self.BUTTON_ATCK || self.BUTTON_ATCK2 )
                {
-                       pointparticles( particleeffectnum("arc_overheat_fire"), smoke_origin, w_shotdir, 1 );
+                       Send_Effect("arc_overheat_fire", smoke_origin, w_shotdir, 1 );
                        if ( !self.arc_smoke_sound )
                        {
                                self.arc_smoke_sound = 1;
-                               sound(self, CH_SHOTS_SINGLE, "weapons/arc_loop_overheat.wav", VOL_BASE, ATTN_NORM);
+                               sound(self, CH_SHOTS_SINGLE, W_Sound("arc_loop_overheat"), VOL_BASE, ATTN_NORM);
                        }
                }
        }
@@ -624,18 +624,18 @@ void Arc_Smoke()
        {
                if ( random() < (self.arc_beam.beam_heat-WEP_CVAR(arc, overheat_min)) /
                                ( WEP_CVAR(arc, overheat_max)-WEP_CVAR(arc, overheat_min) ) )
-                       pointparticles( particleeffectnum("arc_smoke"), smoke_origin, '0 0 0', 1 );
+                       Send_Effect("arc_smoke", smoke_origin, '0 0 0', 1 );
        }
 
        if (  self.arc_smoke_sound && ( self.arc_overheat <= time ||
-               !( self.BUTTON_ATCK || self.BUTTON_ATCK2 ) ) || self.switchweapon != WEP_ARC )
+               !( self.BUTTON_ATCK || self.BUTTON_ATCK2 ) ) || self.switchweapon != WEP_ARC.m_id )
        {
                self.arc_smoke_sound = 0;
                sound(self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTEN_NORM);
        }
 }
 
-float W_Arc(float req)
+bool W_Arc(int req)
 {
        switch(req)
        {
@@ -699,7 +699,7 @@ float W_Arc(float req)
 
                        if(self.arc_BUTTON_ATCK_prev != 0)
                        {
-                               sound(self, CH_WEAPON_A, "weapons/arc_stop.wav", VOL_BASE, ATTN_NORM);
+                               sound(self, CH_WEAPON_A, W_Sound("arc_stop"), VOL_BASE, ATTN_NORM);
                                weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
                                ATTACK_FINISHED(self) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor();
                        }
@@ -720,19 +720,19 @@ float W_Arc(float req)
                }
                case WR_INIT:
                {
-                       precache_model("models/weapons/g_arc.md3");
-                       precache_model("models/weapons/v_arc.md3");
-                       precache_model("models/weapons/h_arc.iqm");
-                       precache_sound("weapons/arc_fire.wav");
-                       precache_sound("weapons/arc_loop.wav");
-                       precache_sound("weapons/arc_stop.wav");
-                       precache_sound("weapons/arc_loop_overheat.wav");
+                       precache_model(W_Model("g_arc.md3"));
+                       precache_model(W_Model("v_arc.md3"));
+                       precache_model(W_Model("h_arc.iqm"));
+                       precache_sound(W_Sound("arc_fire"));
+                       precache_sound(W_Sound("arc_loop"));
+                       precache_sound(W_Sound("arc_stop"));
+                       precache_sound(W_Sound("arc_loop_overheat"));
                        if(!arc_shotorigin[0])
                        {
-                               arc_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), false, false, 1);
-                               arc_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), false, false, 2);
-                               arc_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), false, false, 3);
-                               arc_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), false, false, 4);
+                               arc_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC.m_id), false, false, 1);
+                               arc_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC.m_id), false, false, 2);
+                               arc_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC.m_id), false, false, 3);
+                               arc_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC.m_id), false, false, 4);
                        }
                        ARC_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
                        return true;
@@ -765,7 +765,7 @@ float W_Arc(float req)
                }
                case WR_PICKUP:
                {
-                       if ( !client_hasweapon(self, WEP_ARC, false, false) &&
+                       if ( !client_hasweapon(self, WEP_ARC.m_id, false, false) &&
                                weapon_dropevent_item.arc_overheat > time )
                        {
                                self.arc_overheat = weapon_dropevent_item.arc_overheat;
@@ -1187,7 +1187,7 @@ void Ent_ReadArcBeam(float isnew)
                self.draw = Draw_ArcBeam;
                self.entremove = Remove_ArcBeam;
                self.move_time = time;
-               loopsound(self, CH_SHOTS_SINGLE, "weapons/arc_loop.wav", VOL_BASE, ATTEN_NORM);
+               loopsound(self, CH_SHOTS_SINGLE, W_Sound("arc_loop"), VOL_BASE, ATTEN_NORM);
 
                flash = spawn();
                flash.owner = self;
@@ -1520,7 +1520,7 @@ void Ent_ReadArcBeam(float isnew)
        }
 }
 
-float W_Arc(float req)
+bool W_Arc(int req)
 {
        switch(req)
        {
@@ -1531,7 +1531,7 @@ float W_Arc(float req)
                }
                case WR_INIT:
                {
-                       precache_sound("weapons/arc_loop.wav");
+                       precache_sound(W_Sound("arc_loop"));
                        return true;
                }
                case WR_ZOOMRETICLE: