Merge remote-tracking branch 'origin/samual/crosshair_ring_updates'
authorRudolf Polzer <divverent@alientrap.org>
Tue, 1 Mar 2011 18:09:46 +0000 (19:09 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Tue, 1 Mar 2011 18:09:46 +0000 (19:09 +0100)
12 files changed:
defaultXonotic.cfg
gfx/crosshair_ring_nexgun.tga [new file with mode: 0644]
gfx/crosshair_ring_sniperrifle.tga [new file with mode: 0644]
qcsrc/client/Defs.qc
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/autocvars.qh
qcsrc/common/constants.qh
qcsrc/server/cl_client.qc
qcsrc/server/defs.qh
qcsrc/server/g_world.qc
qcsrc/server/w_minelayer.qc

index d038dc5..95adfb7 100644 (file)
@@ -188,12 +188,16 @@ seta crosshair_fireball_size 1    "crosshair size when wielding the fireball"
 seta crosshair_color_by_health 0 "if enabled, crosshair color will depend on current health"
 
 // ring around crosshair, used for various purposes (such as indicating bullets left in clip, nex charge)
+seta crosshair_ring 1 "main cvar to enable or disable crosshair rings"
+seta crosshair_ring_inner 0 "allow inner rings to be drawn too"
 seta crosshair_ring_size 2     "bullet counter ring size for Rifle, velocity ring for Nex"
 seta crosshair_ring_alpha 0.2  "ring alpha"
 
+seta crosshair_ring_sniperrifle 1 "draw a ring showing the ammount of ammo left in the sniperrifle
 seta crosshair_ring_sniperrifle_alpha 0.15
 
-seta crosshair_ring_nex_outer_alpha 0.15
+seta crosshair_ring_nex 1 "draw a ring showing the current charge of the nexgun"
+seta crosshair_ring_nex_alpha 0.15
 seta crosshair_ring_nex_inner_alpha 0.15
 seta crosshair_ring_nex_inner_color_red 0.8
 seta crosshair_ring_nex_inner_color_green 0
@@ -201,6 +205,9 @@ seta crosshair_ring_nex_inner_color_blue 0
 seta crosshair_ring_nex_currentcharge_scale 30
 seta crosshair_ring_nex_currentcharge_movingavg_rate 0.05
 
+seta crosshair_ring_minelayer 1
+seta crosshair_ring_minelayer_alpha 0.15
+
 seta cl_reticle_stretch 0 "whether to stretch reticles so they fit the screen (brakes image proportions)"
 seta cl_reticle_item_nex 1 "draw aiming reticle for the nex weapon's zoom, 0 disables and values between 0 and 1 change alpha"
 seta cl_reticle_item_normal 1 "draw reticle when zooming with the zoom button, 0 disables and values between 0 and 1 change alpha"
diff --git a/gfx/crosshair_ring_nexgun.tga b/gfx/crosshair_ring_nexgun.tga
new file mode 100644 (file)
index 0000000..6100096
Binary files /dev/null and b/gfx/crosshair_ring_nexgun.tga differ
diff --git a/gfx/crosshair_ring_sniperrifle.tga b/gfx/crosshair_ring_sniperrifle.tga
new file mode 100644 (file)
index 0000000..b25e350
Binary files /dev/null and b/gfx/crosshair_ring_sniperrifle.tga differ
index 3d15295..99c8d5c 100644 (file)
@@ -263,6 +263,8 @@ float nex_scope;
 
 float cr_maxbullets;
 
+float minelayer_maxmines;
+
 float bgmtime;
 
 string weaponorder_byimpulse;
index 8614863..f24b483 100644 (file)
@@ -1095,6 +1095,8 @@ void Ent_Init()
        serverflags = ReadByte();
 
        cr_maxbullets = ReadByte();
+       
+       minelayer_maxmines = ReadByte();
 
        g_trueaim_minrange = ReadCoord();
 
index 7270a9c..6746cfe 100644 (file)
@@ -866,7 +866,6 @@ void CSQC_UpdateView(float w, float h)
 
                        // TrueAim check
                        float shottype;
-                       float bullets, ring_scale;
                        // wcross_origin = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
                        wcross_origin = project_3d_to_2d(view_origin + MAX_SHOT_DISTANCE * view_forward);
                        wcross_origin_z = 0;
@@ -1064,50 +1063,63 @@ void CSQC_UpdateView(float w, float h)
 
                        wcross_scale *= 1 - autocvar__menu_alpha;
                        wcross_alpha *= 1 - autocvar__menu_alpha;
-
-                       ring_scale = autocvar_crosshair_ring_size;
-
                        wcross_size = drawgetimagesize(wcross_name) * wcross_scale;
 
-                       float nex_charge, nex_chargepool;
-                       nex_charge = getstatf(STAT_NEX_CHARGE);
-                       nex_chargepool = getstatf(STAT_NEX_CHARGEPOOL);
-
-                       if(nex_charge_movingavg == 0) // this should only happen if we have just loaded up the game
-                               nex_charge_movingavg = nex_charge;
-
-                       // ring around crosshair representing bullets left in camping rifle clip
-                       if (activeweapon == WEP_SNIPERRIFLE && cr_maxbullets)
-                       {
-                               bullets = getstati(STAT_BULLETS_LOADED);
-                               f = bound(0, bullets / cr_maxbullets, 1);
-
-                               a = autocvar_crosshair_ring_sniperrifle_alpha;
-                               DrawCircleClippedPic(wcross_origin, wcross_size_x * ring_scale, "gfx/crosshair_ring.tga", f, wcross_color, wcross_alpha * a, DRAWFLAG_ADDITIVE);
-                       }
-                       else if (activeweapon == WEP_NEX && nex_charge) // ring around crosshair representing velocity-dependent damage for the nex
+                       if (autocvar_crosshair_ring)
                        {
-                               if(nex_chargepool || use_nex_chargepool)
+                               float ring_value, ring_alpha, ring_inner_value, ring_inner_alpha;
+                               string ring_image, ring_inner_image;
+                               vector ring_rgb, ring_inner_rgb;
+                               
+                               float ring_scale = autocvar_crosshair_ring_size;
+                               
+                               float nex_charge, nex_chargepool;
+                               nex_charge = getstatf(STAT_NEX_CHARGE);
+                               nex_chargepool = getstatf(STAT_NEX_CHARGEPOOL);
+                               
+                               if(nex_charge_movingavg == 0) // this should only happen if we have just loaded up the game
+                                       nex_charge_movingavg = nex_charge;
+                               
+                               if (activeweapon == WEP_SNIPERRIFLE && cr_maxbullets && autocvar_crosshair_ring_sniperrifle) // ring around crosshair representing bullets left in camping rifle clip
+                               { 
+                                       ring_value = bound(0, getstati(STAT_BULLETS_LOADED) / cr_maxbullets, 1); // if you later need to use the count of bullets in another place, then add a float for it. For now, no need to.
+                                       ring_alpha = wcross_alpha * autocvar_crosshair_ring_sniperrifle_alpha;
+                                       ring_image = "gfx/crosshair_ring_sniperrifle.tga";
+                                       ring_rgb = wcross_color;
+                               }
+                               else if (activeweapon == WEP_NEX && nex_charge && autocvar_crosshair_ring_nex) // ring around crosshair representing velocity-dependent damage for the nex
                                {
-                                       use_nex_chargepool = 1;
-
-                                       a = autocvar_crosshair_ring_nex_inner_alpha;
-                                       rgb = eX * autocvar_crosshair_ring_nex_inner_color_red + eY * autocvar_crosshair_ring_nex_inner_color_green + eZ * autocvar_crosshair_ring_nex_inner_color_blue;
-                                       DrawCircleClippedPic(wcross_origin, wcross_size_x * ring_scale, "gfx/crosshair_ring_inner.tga", nex_chargepool, rgb, wcross_alpha * a, DRAWFLAG_ADDITIVE);
+                                       if (nex_chargepool || use_nex_chargepool) { 
+                                               use_nex_chargepool = 1; 
+                                               ring_inner_value = nex_chargepool;
+                                       } else { 
+                                               nex_charge_movingavg = (1 - autocvar_crosshair_ring_nex_currentcharge_movingavg_rate) * nex_charge_movingavg + autocvar_crosshair_ring_nex_currentcharge_movingavg_rate * nex_charge;
+                                               ring_inner_value = bound(0, autocvar_crosshair_ring_nex_currentcharge_scale * (nex_charge - nex_charge_movingavg), 1); 
+                                       }
+                                               
+                                       ring_inner_alpha = wcross_alpha * autocvar_crosshair_ring_nex_inner_alpha;
+                                       ring_inner_image = "gfx/crosshair_ring_inner.tga";
+                                       ring_inner_rgb = eX * autocvar_crosshair_ring_nex_inner_color_red + eY * autocvar_crosshair_ring_nex_inner_color_green + eZ * autocvar_crosshair_ring_nex_inner_color_blue;
+
+                                       // draw the outer ring to show the current charge of the weapon
+                                       ring_value = nex_charge;
+                                       ring_alpha = wcross_alpha * autocvar_crosshair_ring_nex_alpha;
+                                       ring_image = "gfx/crosshair_ring_nexgun.tga";
+                                       ring_rgb = wcross_color;
                                }
-                               else
+                               else if (activeweapon == WEP_MINE_LAYER && minelayer_maxmines && autocvar_crosshair_ring_minelayer) 
                                {
-                                       // indicate how much we're charging right now with an inner circle
-                                       a = autocvar_crosshair_ring_nex_inner_alpha;
-                                       nex_charge_movingavg = (1 - autocvar_crosshair_ring_nex_currentcharge_movingavg_rate) * nex_charge_movingavg + autocvar_crosshair_ring_nex_currentcharge_movingavg_rate * nex_charge;
-
-                                       rgb = eX * autocvar_crosshair_ring_nex_inner_color_red + eY * autocvar_crosshair_ring_nex_inner_color_green + eZ * autocvar_crosshair_ring_nex_inner_color_blue;
-                                       DrawCircleClippedPic(wcross_origin, wcross_size_x * ring_scale, "gfx/crosshair_ring_inner.tga", bound(0, autocvar_crosshair_ring_nex_currentcharge_scale * (nex_charge - nex_charge_movingavg), 1), rgb, wcross_alpha * a, DRAWFLAG_ADDITIVE);
+                                       ring_value = bound(0, getstati(STAT_LAYED_MINES) / minelayer_maxmines, 1); // if you later need to use the count of bullets in another place, then add a float for it. For now, no need to.
+                                       ring_alpha = wcross_alpha * autocvar_crosshair_ring_minelayer_alpha;
+                                       ring_image = "gfx/crosshair_ring.tga";
+                                       ring_rgb = wcross_color;
                                }
-
-                               // draw the charge
-                               a = autocvar_crosshair_ring_nex_outer_alpha;
-                               DrawCircleClippedPic(wcross_origin, wcross_size_x * ring_scale, "gfx/crosshair_ring.tga", nex_charge, wcross_color, wcross_alpha * a, DRAWFLAG_ADDITIVE);
+                               
+                               if (autocvar_crosshair_ring_inner && ring_inner_value) // lets draw a ring inside a ring so you can ring while you ring
+                                       DrawCircleClippedPic(wcross_origin, wcross_size_x * ring_scale, ring_inner_image, ring_inner_value, ring_inner_rgb, ring_inner_alpha, DRAWFLAG_ADDITIVE);
+                               
+                               if (ring_value)
+                                       DrawCircleClippedPic(wcross_origin, wcross_size_x * ring_scale, ring_image, ring_value, ring_rgb, ring_alpha, DRAWFLAG_ADDITIVE);
                        }
 
 #define CROSSHAIR_DO_BLUR(M,sz,wcross_name,wcross_alpha) \
index 0cf1e4b..867859c 100644 (file)
@@ -108,15 +108,21 @@ float autocvar_crosshair_hittest_showimpact;
 float autocvar_crosshair_per_weapon;
 float autocvar_crosshair_pickup;
 float autocvar_crosshair_pickup_speed;
-float autocvar_crosshair_ring_sniperrifle_alpha;
+float autocvar_crosshair_ring;
+float autocvar_crosshair_ring_inner;
+float autocvar_crosshair_ring_minelayer;
+float autocvar_crosshair_ring_minelayer_alpha;
+float autocvar_crosshair_ring_nex;
+float autocvar_crosshair_ring_nex_alpha;
 float autocvar_crosshair_ring_nex_currentcharge_movingavg_rate;
 float autocvar_crosshair_ring_nex_currentcharge_scale;
 float autocvar_crosshair_ring_nex_inner_alpha;
 float autocvar_crosshair_ring_nex_inner_color_blue;
 float autocvar_crosshair_ring_nex_inner_color_green;
 float autocvar_crosshair_ring_nex_inner_color_red;
-float autocvar_crosshair_ring_nex_outer_alpha;
 float autocvar_crosshair_ring_size;
+float autocvar_crosshair_ring_sniperrifle;
+float autocvar_crosshair_ring_sniperrifle_alpha;
 float autocvar_crosshair_size;
 float autocvar_ekg;
 float autocvar_fov;
index 60633f5..d5df658 100644 (file)
@@ -63,6 +63,7 @@ const float TE_CSQC_NOTIFY = 112;
 const float TE_CSQC_WEAPONCOMPLAIN = 113;
 const float TE_CSQC_NEX_SCOPE = 116;
 const float TE_CSQC_CR_MAXBULLETS = 117;
+const float TE_CSQC_MINELAYER_MAXMINES = 118;
 
 const float RACE_NET_CHECKPOINT_HIT_QUALIFYING = 0; // byte checkpoint, short time, short recordtime, string recordholder
 const float RACE_NET_CHECKPOINT_CLEAR = 1;
@@ -315,6 +316,7 @@ const float STAT_HUD = 51;
 const float STAT_NEX_CHARGEPOOL = 52;
 const float STAT_HIT_TIME = 53;
 const float STAT_TYPEHIT_TIME = 54;
+const float STAT_LAYED_MINES = 55;
 
 // see DP source, quakedef.h
 const float STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW = 222;
index 71584d3..6247aaf 100644 (file)
@@ -1110,6 +1110,7 @@ float ClientInit_SendEntity(entity to, float sf)
        WriteByte(MSG_ENTITY, autocvar_g_balance_sniperrifle_secondary); // client has to know if it should zoom or not
        WriteByte(MSG_ENTITY, serverflags); // client has to know if it should zoom or not
        WriteByte(MSG_ENTITY, autocvar_g_balance_sniperrifle_magazinecapacity); // rifle max bullets
+       WriteByte(MSG_ENTITY, autocvar_g_balance_minelayer_limit); // minelayer max mines
        WriteCoord(MSG_ENTITY, autocvar_g_trueaim_minrange);
        return TRUE;
 }
@@ -2354,6 +2355,10 @@ void SpectateCopy(entity spectatee) {
        self.weapons = spectatee.weapons;
        self.switchweapon = spectatee.switchweapon;
        self.weapon = spectatee.weapon;
+       self.nex_charge = spectatee.nex_charge;
+       self.nex_chargepool_ammo = spectatee.nex_chargepool_ammo;
+       self.sniperrifle_bulletcounter = spectatee.sniperrifle_bulletcounter;
+       self.minelayer_mines = spectatee.minelayer_mines;
        self.punchangle = spectatee.punchangle;
        self.view_ofs = spectatee.view_ofs;
        self.v_angle = spectatee.v_angle;
index 32ff5ab..d008f15 100644 (file)
@@ -611,6 +611,7 @@ float client_cefc_accumulator;
 float client_cefc_accumulatortime;
 #endif
 
+.float minelayer_mines;
 .float sniperrifle_bulletcounter;
 .float wish_reload;
 
index 84402f0..374f17c 100644 (file)
@@ -827,6 +827,7 @@ void spawnfunc_worldspawn (void)
        addstat(STAT_LAST_PICKUP, AS_FLOAT, last_pickup);
        addstat(STAT_HIT_TIME, AS_FLOAT, hit_time);
        addstat(STAT_TYPEHIT_TIME, AS_FLOAT, typehit_time);
+       addstat(STAT_LAYED_MINES, AS_INT, minelayer_mines);
 
        addstat(STAT_NEX_CHARGE, AS_FLOAT, nex_charge);
        addstat(STAT_NEX_CHARGEPOOL, AS_FLOAT, nex_chargepool_ammo);
index 7e4749c..88e720e 100644 (file)
@@ -3,7 +3,7 @@ REGISTER_WEAPON(MINE_LAYER, w_minelayer, IT_ROCKETS, 4, WEP_FLAG_NORMAL | WEP_TY
 #else
 #ifdef SVQC
 void W_Mine_Think (void);
-.float minelayer_detonate, minelayer_mines;
+.float minelayer_detonate, mine_explodeanyway;
 .float mine_time;
 
 void spawnfunc_weapon_minelayer (void)
@@ -73,6 +73,7 @@ void W_Mine_Explode ()
                        self.owner.switchweapon = w_getbestweapon(self.owner);
                }
        }
+       self.owner.minelayer_mines -= 1;
        remove (self);
 }
 
@@ -92,6 +93,7 @@ void W_Mine_DoRemoteExplode ()
                        self.owner.switchweapon = w_getbestweapon(self.owner);
                }
        }
+       self.owner.minelayer_mines -= 1;
        remove (self);
 }
 
@@ -110,7 +112,7 @@ void W_Mine_RemoteExplode ()
 void W_Mine_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(autocvar_g_balance_minelayer_protection && self.minelayer_mines == 0)
+       if(autocvar_g_balance_minelayer_protection && self.mine_explodeanyway == 0)
        {
                entity head;
                head = findradius(self.origin, autocvar_g_balance_minelayer_radius);
@@ -126,6 +128,16 @@ void W_Mine_ProximityExplode ()
        W_Mine_Explode();
 }
 
+float W_Mine_Count(entity e)
+{
+       float minecount;
+       entity mine;
+       for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == e)
+               minecount += 1;
+               
+       return minecount;
+}
+
 void W_Mine_Think (void)
 {
        entity head;
@@ -139,7 +151,7 @@ void W_Mine_Think (void)
                if(autocvar_g_balance_minelayer_lifetime_countdown > 0)
                        spamsound (self, CHAN_PROJECTILE, "weapons/mine_trigger.wav", VOL_BASE, ATTN_NORM);
                self.mine_time = time + autocvar_g_balance_minelayer_lifetime_countdown;
-               self.minelayer_mines = 1; // make the mine super aggressive
+               self.mine_explodeanyway = 1; // make the mine super aggressive -- Samual: Rather, make it not care if a team mate is near.
        }
 
        // a player's mines shall explode if he disconnects or dies
@@ -207,11 +219,8 @@ void W_Mine_Attack (void)
        // scan how many mines we placed, and return if we reached our limit
        if(autocvar_g_balance_minelayer_limit)
        {
-               self.minelayer_mines = 0;
-               for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == self)
-                       self.minelayer_mines += 1;
-
-               if(self.minelayer_mines >= autocvar_g_balance_minelayer_limit)
+       
+               if(W_Mine_Count(self) >= autocvar_g_balance_minelayer_limit)
                {
                        // the refire delay keeps this message from being spammed
                        sprint(self, strcat("You cannot place more than ^2", ftos(autocvar_g_balance_minelayer_limit), " ^7mines at a time\n") );
@@ -268,6 +277,8 @@ void W_Mine_Attack (void)
        // common properties
 
        other = mine; MUTATOR_CALLHOOK(EditProjectile);
+       
+       self.minelayer_mines = W_Mine_Count(self);
 }
 
 void spawnfunc_weapon_minelayer (void); // defined in t_items.qc