]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/w_minelayer.qc
Even more cleanup of SetupProjVelocity
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_minelayer.qc
index 4e1092eed9cf1a639c9938c735ea7fccbdf73d5c..6e70043ae190aa91ca7bc56c33f9ee3a8f5ef345 100644 (file)
@@ -1,11 +1,12 @@
 #ifdef REGISTER_WEAPON
 REGISTER_WEAPON(
 /* WEP_##id */ MINE_LAYER,
-/* function */ w_minelayer,
+/* function */ W_MineLayer,
 /* ammotype */ ammo_rockets,
 /* impulse  */ 4,
 /* flags    */ WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH,
 /* rating   */ BOT_PICKUP_RATING_HIGH,
+/* color       */ '0.75 1 0',
 /* model    */ "minelayer",
 /* netname  */ "minelayer",
 /* fullname */ _("Mine Layer")
@@ -13,27 +14,27 @@ REGISTER_WEAPON(
 
 #define MINELAYER_SETTINGS(w_cvar,w_prop) MINELAYER_SETTINGS_LIST(w_cvar, w_prop, MINE_LAYER, minelayer)
 #define MINELAYER_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
-       w_cvar(id, sn, MO_NONE, ammo) \
-       w_cvar(id, sn, MO_NONE, animtime) \
-       w_cvar(id, sn, MO_NONE, damage) \
-       w_cvar(id, sn, MO_NONE, damageforcescale) \
-       w_cvar(id, sn, MO_NONE, detonatedelay) \
-       w_cvar(id, sn, MO_NONE, edgedamage) \
-       w_cvar(id, sn, MO_NONE, force) \
-       w_cvar(id, sn, MO_NONE, health) \
-       w_cvar(id, sn, MO_NONE, lifetime) \
-       w_cvar(id, sn, MO_NONE, lifetime_countdown) \
-       w_cvar(id, sn, MO_NONE, limit) \
-       w_cvar(id, sn, MO_NONE, protection) \
-       w_cvar(id, sn, MO_NONE, proximityradius) \
-       w_cvar(id, sn, MO_NONE, radius) \
-       w_cvar(id, sn, MO_NONE, refire) \
-       w_cvar(id, sn, MO_NONE, remote_damage) \
-       w_cvar(id, sn, MO_NONE, remote_edgedamage) \
-       w_cvar(id, sn, MO_NONE, remote_force) \
-       w_cvar(id, sn, MO_NONE, remote_radius) \
-       w_cvar(id, sn, MO_NONE, speed) \
-       w_cvar(id, sn, MO_NONE, time) \
+       w_cvar(id, sn, NONE, ammo) \
+       w_cvar(id, sn, NONE, animtime) \
+       w_cvar(id, sn, NONE, damage) \
+       w_cvar(id, sn, NONE, damageforcescale) \
+       w_cvar(id, sn, NONE, detonatedelay) \
+       w_cvar(id, sn, NONE, edgedamage) \
+       w_cvar(id, sn, NONE, force) \
+       w_cvar(id, sn, NONE, health) \
+       w_cvar(id, sn, NONE, lifetime) \
+       w_cvar(id, sn, NONE, lifetime_countdown) \
+       w_cvar(id, sn, NONE, limit) \
+       w_cvar(id, sn, NONE, protection) \
+       w_cvar(id, sn, NONE, proximityradius) \
+       w_cvar(id, sn, NONE, radius) \
+       w_cvar(id, sn, NONE, refire) \
+       w_cvar(id, sn, NONE, remote_damage) \
+       w_cvar(id, sn, NONE, remote_edgedamage) \
+       w_cvar(id, sn, NONE, remote_force) \
+       w_cvar(id, sn, NONE, remote_radius) \
+       w_cvar(id, sn, NONE, speed) \
+       w_cvar(id, sn, NONE, time) \
        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) \
@@ -44,7 +45,7 @@ REGISTER_WEAPON(
 
 #ifdef SVQC
 MINELAYER_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
-void W_Mine_Think (void);
+void W_MineLayer_Think (void);
 .float minelayer_detonate, mine_explodeanyway;
 .float mine_time;
 .vector mine_orientation;
@@ -53,7 +54,7 @@ void W_Mine_Think (void);
 #ifdef SVQC
 void spawnfunc_weapon_minelayer() { weapon_defaultspawnfunc(WEP_MINE_LAYER); }
 
-void W_Mine_Stick (entity to)
+void W_MineLayer_Stick (entity to)
 {
        spamsound (self, CH_SHOTS, "weapons/mine_stick.wav", VOL_BASE, ATTN_NORM);
 
@@ -88,7 +89,7 @@ void W_Mine_Stick (entity to)
        newmine.mine_time = self.mine_time;
 
        newmine.touch = func_null;
-       newmine.think = W_Mine_Think;
+       newmine.think = W_MineLayer_Think;
        newmine.nextthink = time;
        newmine.cnt = self.cnt;
        newmine.flags = self.flags;
@@ -100,7 +101,7 @@ void W_Mine_Stick (entity to)
                SetMovetypeFollow(self, to);
 }
 
-void W_Mine_Explode ()
+void W_MineLayer_Explode()
 {
        if(other.takedamage == DAMAGE_AIM)
                if(IS_PLAYER(other))
@@ -131,7 +132,7 @@ void W_Mine_Explode ()
        remove (self);
 }
 
-void W_Mine_DoRemoteExplode ()
+void W_MineLayer_DoRemoteExplode ()
 {
        self.event_damage = func_null;
        self.takedamage = DAMAGE_NO;
@@ -158,7 +159,7 @@ void W_Mine_DoRemoteExplode ()
        remove (self);
 }
 
-void W_Mine_RemoteExplode ()
+void W_MineLayer_RemoteExplode ()
 {
        if(self.realowner.deadflag == DEAD_NO)
                if((self.spawnshieldtime >= 0)
@@ -166,11 +167,11 @@ void W_Mine_RemoteExplode ()
                        : (vlen(NearestPointOnBox(self.realowner, self.origin) - self.origin) > WEP_CVAR(minelayer, remote_radius)) // safety device
                )
                {
-                       W_Mine_DoRemoteExplode();
+                       W_MineLayer_DoRemoteExplode();
                }
 }
 
-void W_Mine_ProximityExplode ()
+void W_MineLayer_ProximityExplode ()
 {
        // make sure no friend is in the mine's radius. If there is any, explosion is delayed until he's at a safe distance
        if(WEP_CVAR(minelayer, protection) && self.mine_explodeanyway == 0)
@@ -186,10 +187,10 @@ void W_Mine_ProximityExplode ()
        }
 
        self.mine_time = 0;
-       W_Mine_Explode();
+       W_MineLayer_Explode();
 }
 
-float W_Mine_Count(entity e)
+float W_MineLayer_Count(entity e)
 {
        float minecount = 0;
        entity mine;
@@ -199,7 +200,7 @@ float W_Mine_Count(entity e)
        return minecount;
 }
 
-void W_Mine_Think (void)
+void W_MineLayer_Think (void)
 {
        entity head;
 
@@ -230,7 +231,7 @@ void W_Mine_Think (void)
        {
                other = world;
                self.projectiledeathtype |= HITTYPE_BOUNCE;
-               W_Mine_Explode();
+               W_MineLayer_Explode();
                return;
        }
 
@@ -251,7 +252,7 @@ void W_Mine_Think (void)
        // explode if it's time to
        if(self.mine_time && time >= self.mine_time)
        {
-               W_Mine_ProximityExplode();
+               W_MineLayer_ProximityExplode();
                return;
        }
 
@@ -259,10 +260,10 @@ void W_Mine_Think (void)
        if (self.realowner.weapon == WEP_MINE_LAYER)
        if (self.realowner.deadflag == DEAD_NO)
        if (self.minelayer_detonate)
-               W_Mine_RemoteExplode();
+               W_MineLayer_RemoteExplode();
 }
 
-void W_Mine_Touch (void)
+void W_MineLayer_Touch (void)
 {
        if(self.movetype == MOVETYPE_NONE || self.movetype == MOVETYPE_FOLLOW)
                return; // we're already a stuck mine, why do we get called? TODO does this even happen?
@@ -281,11 +282,11 @@ void W_Mine_Touch (void)
        }
        else
        {
-               W_Mine_Stick(other);
+               W_MineLayer_Stick(other);
        }
 }
 
-void W_Mine_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
+void W_MineLayer_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
 {
        if (self.health <= 0)
                return;
@@ -299,10 +300,10 @@ void W_Mine_Damage (entity inflictor, entity attacker, float damage, float death
        self.angles = vectoangles(self.velocity);
        
        if (self.health <= 0)
-               W_PrepareExplosionByDamage(attacker, W_Mine_Explode);
+               W_PrepareExplosionByDamage(attacker, W_MineLayer_Explode);
 }
 
-void W_Mine_Attack (void)
+void W_MineLayer_Attack()
 {
        entity mine;
        entity flash;
@@ -319,7 +320,7 @@ void W_Mine_Attack (void)
                }
        }
 
-       W_DecreaseAmmo(ammo_rockets, WEP_CVAR(minelayer, ammo), autocvar_g_balance_minelayer_reload_ammo);
+       W_DecreaseAmmo(WEP_CVAR(minelayer, ammo));
 
        W_SetupShot_ProjectileSize (self, '-4 -4 -4', '4 4 4', FALSE, 5, "weapons/mine_fire.wav", CH_WEAPON_A, WEP_CVAR(minelayer, damage));
        pointparticles(particleeffectnum("rocketlauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
@@ -337,7 +338,7 @@ void W_Mine_Attack (void)
        mine.takedamage = DAMAGE_YES;
        mine.damageforcescale = WEP_CVAR(minelayer, damageforcescale);
        mine.health = WEP_CVAR(minelayer, health);
-       mine.event_damage = W_Mine_Damage;
+       mine.event_damage = W_MineLayer_Damage;
        mine.damagedbycontents = TRUE;
 
        mine.movetype = MOVETYPE_TOSS;
@@ -346,11 +347,11 @@ void W_Mine_Attack (void)
        setsize (mine, '-4 -4 -4', '4 4 4'); // give it some size so it can be shot
 
        setorigin (mine, w_shotorg - v_forward * 4); // move it back so it hits the wall at the right point
-       W_SetupProjectileVelocity(mine, WEP_CVAR(minelayer, speed), 0);
+       W_SetupProjVelocity_Basic(mine, WEP_CVAR(minelayer, speed), 0);
        mine.angles = vectoangles (mine.velocity);
 
-       mine.touch = W_Mine_Touch;
-       mine.think = W_Mine_Think;
+       mine.touch = W_MineLayer_Touch;
+       mine.think = W_MineLayer_Think;
        mine.nextthink = time;
        mine.cnt = time + (WEP_CVAR(minelayer, lifetime) - WEP_CVAR(minelayer, lifetime_countdown));
        mine.flags = FL_PROJECTILE;
@@ -369,10 +370,10 @@ void W_Mine_Attack (void)
 
        other = mine; MUTATOR_CALLHOOK(EditProjectile);
        
-       self.minelayer_mines = W_Mine_Count(self);
+       self.minelayer_mines = W_MineLayer_Count(self);
 }
 
-float W_PlacedMines(float detonate)
+float W_MineLayer_PlacedMines(float detonate)
 {
        entity mine;
        float minfound = 0;
@@ -393,7 +394,7 @@ float W_PlacedMines(float detonate)
        return minfound;
 }
 
-float w_minelayer(float req)
+float W_MineLayer(float req)
 {
        entity mine;
        float ammo_amount;
@@ -504,21 +505,21 @@ float w_minelayer(float req)
                        if(autocvar_g_balance_minelayer_reload_ammo && self.clip_load < WEP_CVAR(minelayer, ammo)) // forced reload
                        {
                                // not if we're holding the minelayer without enough ammo, but can detonate existing mines
-                               if(!(W_PlacedMines(FALSE) && self.ammo_rockets < WEP_CVAR(minelayer, ammo)))
+                               if(!(W_MineLayer_PlacedMines(FALSE) && self.AMMO_VAL(WEP_MINE_LAYER) < WEP_CVAR(minelayer, ammo)))
                                        WEP_ACTION(self.weapon, WR_RELOAD);
                        }
                        else if (self.BUTTON_ATCK)
                        {
                                if(weapon_prepareattack(0, WEP_CVAR(minelayer, refire)))
                                {
-                                       W_Mine_Attack();
+                                       W_MineLayer_Attack();
                                        weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready);
                                }
                        }
 
                        if (self.BUTTON_ATCK2)
                        {
-                               if(W_PlacedMines(TRUE))
+                               if(W_MineLayer_PlacedMines(TRUE))
                                        sound (self, CH_WEAPON_B, "weapons/mine_det.wav", VOL_BASE, ATTN_NORM);
                        }
                        
@@ -538,17 +539,12 @@ float w_minelayer(float req)
                        MINELAYER_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
                        return TRUE;
                }
-               case WR_SETUP:
-               {
-                       self.current_ammo = ammo_rockets;
-                       return TRUE;
-               }
                case WR_CHECKAMMO1:
                {
                        // don't switch while placing a mine
                        if (ATTACK_FINISHED(self) <= time || self.weapon != WEP_MINE_LAYER)
                        {
-                               ammo_amount = self.ammo_rockets >= WEP_CVAR(minelayer, ammo);
+                               ammo_amount = self.AMMO_VAL(WEP_MINE_LAYER) >= WEP_CVAR(minelayer, ammo);
                                ammo_amount += self.(weapon_load[WEP_MINE_LAYER]) >= WEP_CVAR(minelayer, ammo);
                                return ammo_amount;
                        }
@@ -556,7 +552,7 @@ float w_minelayer(float req)
                }
                case WR_CHECKAMMO2:
                {
-                       if (W_PlacedMines(FALSE))
+                       if (W_MineLayer_PlacedMines(FALSE))
                                return TRUE;
                        else
                                return FALSE;
@@ -589,7 +585,7 @@ float w_minelayer(float req)
 }
 #endif
 #ifdef CSQC
-float w_minelayer(float req)
+float W_MineLayer(float req)
 {
        switch(req)
        {