Merge branch 'master' into mirceakitsune/universal_reload_system
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Thu, 17 Feb 2011 14:32:47 +0000 (16:32 +0200)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Thu, 17 Feb 2011 14:32:47 +0000 (16:32 +0200)
Conflicts:
qcsrc/common/constants.qh

1  2 
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/common/constants.qh
qcsrc/server/autocvars.qh
qcsrc/server/cl_client.qc
qcsrc/server/defs.qh
qcsrc/server/g_world.qc

diff --combined qcsrc/client/Main.qc
@@@ -136,6 -136,8 +136,8 @@@ void CSQC_Init(void
        WaypointSprite_Load();
  
        // precaches
+       precache_sound("misc/hit.wav");
+       precache_sound("misc/typehit.wav");
        Projectile_Precache();
        Hook_Precache();
        GibSplash_Precache();
@@@ -1092,6 -1094,8 +1094,6 @@@ void Ent_Init(
  
        serverflags = ReadByte();
  
 -      cr_maxbullets = ReadByte();
 -
        g_trueaim_minrange = ReadCoord();
  
        if(!postinit)
diff --combined qcsrc/client/View.qc
@@@ -353,6 -353,9 +353,9 @@@ vector freeze_pmove_org, freeze_input_a
  entity nightvision_noise, nightvision_noise2;
  
  float pickup_crosshair_time, pickup_crosshair_size;
+ float hit_time, typehit_time;
+ float nextsound_hit_time, nextsound_typehit_time;
+ float hitindication_crosshair_time, hitindication_crosshair_size;
  float use_nex_chargepool;
  
  float myhealth, myhealth_prev;
@@@ -809,6 -812,19 +812,19 @@@ void CSQC_UpdateView(float w, float h
  
        scoreboard_active = HUD_WouldDrawScoreboard();
  
+       hit_time = getstatf(STAT_HIT_TIME);
+       if(hit_time > nextsound_hit_time && autocvar_cl_hitsound)
+       {
+               sound(world, CHAN_AUTO, "misc/hit.wav", VOL_BASE, ATTN_NONE);
+               nextsound_hit_time = time + autocvar_cl_hitsound_antispam_time;
+       }
+       typehit_time = getstatf(STAT_TYPEHIT_TIME);
+       if(typehit_time > nextsound_typehit_time)
+       {
+               sound(world, CHAN_AUTO, "misc/typehit.wav", VOL_BASE, ATTN_NONE);
+               nextsound_typehit_time = time + autocvar_cl_hitsound_antispam_time;
+       }
        float hud;
        hud = getstati(STAT_HUD);
        if(hud == HUD_SPIDERBOT)
  
                        // TrueAim check
                        float shottype;
 -                      float bullets, ring_scale;
 +                      float weapon_clipload, weapon_clipsize, 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;
  
                                wcross_scale += sin(pickup_crosshair_size) * autocvar_crosshair_pickup;
                        }
+                       
+                       vector hitindication_color;
+                       if(autocvar_crosshair_hitindication)
+                       {
+                               hitindication_color = stov(autocvar_crosshair_hitindication_color);
+                               if(hitindication_crosshair_time < hit_time)
+                               {
+                                       hitindication_crosshair_size = 1;
+                                       hitindication_crosshair_time = hit_time;
+                               }
+                               if(hitindication_crosshair_size > 0)
+                                       hitindication_crosshair_size -= autocvar_crosshair_hitindication_speed * frametime;
+                               else
+                                       hitindication_crosshair_size = 0;
+                               wcross_scale += sin(hitindication_crosshair_size) * autocvar_crosshair_hitindication;
+                               wcross_color_x += sin(hitindication_crosshair_size) * hitindication_color_x;
+                               wcross_color_y += sin(hitindication_crosshair_size) * hitindication_color_y;
+                               wcross_color_z += sin(hitindication_crosshair_size) * hitindication_color_z;
+                       }
  
                        if(shottype == SHOTTYPE_HITENEMY)
                                wcross_scale *= autocvar_crosshair_hittest; // is not queried if hittest is 0
                        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)
 +                      // ring around crosshair representing bullets left in weapon clip
 +                      weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD);
 +                      if (weapon_clipload)
                        {
 -                              bullets = getstati(STAT_BULLETS_LOADED);
 -                              f = bound(0, bullets / cr_maxbullets, 1);
 +                              weapon_clipsize = getstati(STAT_WEAPON_CLIPSIZE);
 +                              f = bound(0, weapon_clipload / weapon_clipsize, 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 (activeweapon == WEP_NEX && nex_charge) // ring around crosshair representing velocity-dependent damage for the nex
                        {
                                if(nex_chargepool || use_nex_chargepool)
                                {
@@@ -62,6 -62,7 +62,6 @@@ const float TE_CSQC_TARGET_MUSIC = 111
  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 RACE_NET_CHECKPOINT_HIT_QUALIFYING = 0; // byte checkpoint, short time, short recordtime, string recordholder
  const float RACE_NET_CHECKPOINT_CLEAR = 1;
@@@ -307,12 -308,13 +307,14 @@@ const float STAT_FUEL = 44
  const float STAT_NB_METERSTART = 45;
  const float STAT_SHOTORG = 46; // compressShotOrigin
  const float STAT_LEADLIMIT = 47;
 -const float STAT_BULLETS_LOADED = 48;
 -const float STAT_NEX_CHARGE = 49;
 -const float STAT_LAST_PICKUP = 50;
 -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_WEAPON_CLIPLOAD = 48;
 +const float STAT_WEAPON_CLIPSIZE = 49;
 +const float STAT_NEX_CHARGE = 50;
 +const float STAT_LAST_PICKUP = 51;
 +const float STAT_HUD = 52;
 +const float STAT_NEX_CHARGEPOOL = 53;
++const float STAT_HIT_TIME = 54;
++const float STAT_TYPEHIT_TIME = 55;
  
  // see DP source, quakedef.h
  const float STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW = 222;
@@@ -621,7 -623,6 +623,7 @@@ float WR_KILLMESSAGE    = 8; // (CSQC) 
  float WR_RELOAD         = 9; // (SVQC) does not need to do anything
  float WR_RESETPLAYER    = 10; // (SVQC) does not need to do anything
  float WR_IMPACTEFFECT = 11; // (CSQC) impact effect
 +float WR_SWITCHABLE   = 12; // (CSQC) impact effect
  
  
  float HUD_PANEL_WEAPONS               = 0;
@@@ -82,7 -82,9 +82,7 @@@ float autocvar_g_balance_armor_rot
  float autocvar_g_balance_armor_rotlinear;
  float autocvar_g_balance_armor_rotstable;
  float autocvar_g_balance_armor_start;
 -float autocvar_g_balance_sniperrifle_auto_reload_on_switch;
  float autocvar_g_balance_sniperrifle_bursttime;
 -float autocvar_g_balance_sniperrifle_magazinecapacity;
  float autocvar_g_balance_sniperrifle_primary_ammo;
  float autocvar_g_balance_sniperrifle_primary_animtime;
  float autocvar_g_balance_sniperrifle_primary_bulletconstant;
@@@ -96,6 -98,7 +96,6 @@@ float autocvar_g_balance_sniperrifle_pr
  float autocvar_g_balance_sniperrifle_primary_speed;
  float autocvar_g_balance_sniperrifle_primary_spread;
  float autocvar_g_balance_sniperrifle_primary_tracer;
 -float autocvar_g_balance_sniperrifle_reloadtime;
  float autocvar_g_balance_sniperrifle_secondary;
  float autocvar_g_balance_sniperrifle_secondary_ammo;
  float autocvar_g_balance_sniperrifle_secondary_animtime;
@@@ -111,8 -114,6 +111,8 @@@ float autocvar_g_balance_sniperrifle_se
  float autocvar_g_balance_sniperrifle_secondary_speed;
  float autocvar_g_balance_sniperrifle_secondary_spread;
  float autocvar_g_balance_sniperrifle_secondary_tracer;
 +float autocvar_g_balance_sniperrifle_reload_ammo;
 +float autocvar_g_balance_sniperrifle_reload_time;
  float autocvar_g_balance_cloaked_alpha;
  float autocvar_g_balance_crylink_primary_ammo;
  float autocvar_g_balance_crylink_primary_animtime;
@@@ -165,8 -166,6 +165,8 @@@ float autocvar_g_balance_crylink_second
  float autocvar_g_balance_crylink_secondary_shots;
  float autocvar_g_balance_crylink_secondary_speed;
  float autocvar_g_balance_crylink_secondary_spread;
 +float autocvar_g_balance_crylink_reload_ammo;
 +float autocvar_g_balance_crylink_reload_time;
  float autocvar_g_balance_ctf_damageforcescale;
  float autocvar_g_balance_ctf_delay_collect;
  float autocvar_g_balance_curse_empathy_minhealth;
@@@ -216,8 -215,6 +216,8 @@@ float autocvar_g_balance_electro_second
  float autocvar_g_balance_electro_secondary_refire;
  float autocvar_g_balance_electro_secondary_refire2;
  float autocvar_g_balance_electro_secondary_speed;
 +float autocvar_g_balance_electro_reload_ammo;
 +float autocvar_g_balance_electro_reload_time;
  float autocvar_g_balance_falldamage_deadminspeed;
  float autocvar_g_balance_falldamage_factor;
  float autocvar_g_balance_falldamage_maxdamage;
@@@ -254,8 -251,6 +254,8 @@@ float autocvar_g_balance_fireball_secon
  float autocvar_g_balance_fireball_secondary_refire;
  float autocvar_g_balance_fireball_secondary_speed;
  float autocvar_g_balance_fireball_secondary_speed_up;
 +float autocvar_g_balance_fireball_reload_ammo;
 +float autocvar_g_balance_fireball_reload_time;
  float autocvar_g_balance_firetransfer_damage;
  float autocvar_g_balance_firetransfer_time;
  float autocvar_g_balance_fuel_limit;
@@@ -304,8 -299,6 +304,8 @@@ float autocvar_g_balance_grenadelaunche
  float autocvar_g_balance_grenadelauncher_secondary_speed;
  float autocvar_g_balance_grenadelauncher_secondary_speed_up;
  float autocvar_g_balance_grenadelauncher_secondary_type;
 +float autocvar_g_balance_grenadelauncher_reload_ammo;
 +float autocvar_g_balance_grenadelauncher_reload_time;
  float autocvar_g_balance_hagar_primary_ammo;
  float autocvar_g_balance_hagar_primary_damage;
  float autocvar_g_balance_hagar_primary_edgedamage;
@@@ -323,8 -316,6 +323,8 @@@ float autocvar_g_balance_hagar_secondar
  float autocvar_g_balance_hagar_secondary_lifetime_rand;
  float autocvar_g_balance_hagar_secondary_radius;
  float autocvar_g_balance_hagar_secondary_refire;
 +float autocvar_g_balance_hagar_reload_ammo;
 +float autocvar_g_balance_hagar_reload_time;
  float autocvar_g_balance_health_limit;
  float autocvar_g_balance_health_regen;
  float autocvar_g_balance_health_regenlinear;
@@@ -359,8 -350,6 +359,8 @@@ float autocvar_g_balance_hlac_secondary
  float autocvar_g_balance_hlac_secondary_speed;
  float autocvar_g_balance_hlac_secondary_spread;
  float autocvar_g_balance_hlac_secondary_spread_crouchmod;
 +float autocvar_g_balance_hlac_reload_ammo;
 +float autocvar_g_balance_hlac_reload_time;
  float autocvar_g_balance_hook_primary_animtime;
  float autocvar_g_balance_hook_primary_fuel;
  float autocvar_g_balance_hook_primary_hooked_fuel;
@@@ -421,8 -410,6 +421,8 @@@ float autocvar_g_balance_laser_secondar
  float autocvar_g_balance_laser_secondary_lifetime;
  float autocvar_g_balance_laser_secondary_radius;
  float autocvar_g_balance_laser_secondary_speed;
 +float autocvar_g_balance_laser_reload_ammo;
 +float autocvar_g_balance_laser_reload_time;
  float autocvar_g_balance_minelayer_ammo;
  float autocvar_g_balance_minelayer_animtime;
  float autocvar_g_balance_minelayer_damage;
@@@ -444,14 -431,9 +444,14 @@@ float autocvar_g_balance_minelayer_remo
  float autocvar_g_balance_minelayer_remote_radius;
  float autocvar_g_balance_minelayer_speed;
  float autocvar_g_balance_minelayer_time;
 +float autocvar_g_balance_minelayer_reload_ammo;
 +float autocvar_g_balance_minelayer_reload_time;
  float autocvar_g_balance_minstanex_ammo;
 +float autocvar_g_balance_minstanex_laser_ammo;
  float autocvar_g_balance_minstanex_animtime;
  float autocvar_g_balance_minstanex_refire;
 +float autocvar_g_balance_minstanex_reload_ammo;
 +float autocvar_g_balance_minstanex_reload_time;
  float autocvar_g_balance_nex_charge;
  float autocvar_g_balance_nex_charge_animlimit;
  float autocvar_g_balance_nex_charge_limit;
@@@ -489,8 -471,6 +489,8 @@@ float autocvar_g_balance_nex_secondary_
  float autocvar_g_balance_nex_secondary_damagefalloff_mindist;
  float autocvar_g_balance_nex_secondary_force;
  float autocvar_g_balance_nex_secondary_refire;
 +float autocvar_g_balance_nex_reload_ammo;
 +float autocvar_g_balance_nex_reload_time;
  float autocvar_g_balance_nexball_primary_animtime;
  float autocvar_g_balance_nexball_primary_refire;
  float autocvar_g_balance_nexball_primary_speed;
@@@ -557,8 -537,6 +557,8 @@@ float autocvar_g_balance_rocketlauncher
  float autocvar_g_balance_rocketlauncher_speed;
  float autocvar_g_balance_rocketlauncher_speedaccel;
  float autocvar_g_balance_rocketlauncher_speedstart;
 +float autocvar_g_balance_rocketlauncher_reload_ammo;
 +float autocvar_g_balance_rocketlauncher_reload_time;
  float autocvar_g_balance_rune_defense_combo_takedamage;
  float autocvar_g_balance_rune_defense_takedamage;
  float autocvar_g_balance_rune_regen_combo_hpmod;
@@@ -616,8 -594,6 +616,8 @@@ float autocvar_g_balance_seeker_tag_hea
  float autocvar_g_balance_seeker_tag_lifetime;
  float autocvar_g_balance_seeker_tag_refire;
  float autocvar_g_balance_seeker_tag_speed;
 +float autocvar_g_balance_seeker_reload_ammo;
 +float autocvar_g_balance_seeker_reload_time;
  float autocvar_g_balance_selfdamagepercent;
  float autocvar_g_balance_shotgun_primary_ammo;
  float autocvar_g_balance_shotgun_primary_animtime;
@@@ -637,8 -613,6 +637,8 @@@ float autocvar_g_balance_shotgun_second
  float autocvar_g_balance_shotgun_secondary_melee_swing;
  float autocvar_g_balance_shotgun_secondary_melee_time;
  float autocvar_g_balance_shotgun_secondary_refire;
 +float autocvar_g_balance_shotgun_reload_ammo;
 +float autocvar_g_balance_shotgun_reload_time;
  float autocvar_g_balance_teams;
  float autocvar_g_balance_teams_force;
  float autocvar_g_balance_teams_prevent_imbalance;
@@@ -672,8 -646,6 +672,8 @@@ float autocvar_g_balance_uzi_sustained_
  float autocvar_g_balance_uzi_sustained_force;
  float autocvar_g_balance_uzi_sustained_refire;
  float autocvar_g_balance_uzi_sustained_spread;
 +float autocvar_g_balance_uzi_reload_ammo;
 +float autocvar_g_balance_uzi_reload_time;
  float autocvar_g_balance_weaponswitchdelay;
  float autocvar_g_ballistics_density_corpse;
  float autocvar_g_ballistics_density_player;
@@@ -832,7 -804,6 +832,6 @@@ float autocvar_g_midair_shieldtime
  float autocvar_g_minstagib_ammo_drop;
  float autocvar_g_minstagib_extralives;
  float autocvar_g_minstagib_speed_highspeed;
- float autocvar_g_mirrordamage;
  #define autocvar_g_mirrordamage cvar("g_mirrordamage")
  #define autocvar_g_mirrordamage_virtual cvar("g_mirrordamage_virtual")
  float autocvar_g_monster_zombie_attack_run_damage;
@@@ -1148,7 -1119,6 +1147,6 @@@ float autocvar_sv_friction
  float autocvar_sv_friction_on_land;
  float autocvar_sv_gameplayfix_q2airaccelerate;
  #define autocvar_sv_gravity cvar("sv_gravity")
- float autocvar_sv_hitsound_antispam_time;
  string autocvar_sv_intermission_cdtrack;
  string autocvar_sv_jumpspeedcap_max;
  float autocvar_sv_jumpspeedcap_max_disable_on_ramps;
@@@ -1050,16 -1050,8 +1050,16 @@@ void PutClientInServer (void
  
                // reset fields the weapons may use
                for (j = WEP_FIRST; j <= WEP_LAST; ++j)
 +              {
                        weapon_action(j, WR_RESETPLAYER);
  
 +                      // all weapons must be fully loaded when we spawn
 +                      entity e;
 +                      e = get_weaponinfo(j);
 +                      if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars
 +                              self.weapon_load[j] = cvar(strcat("g_balance_", e.netname, "_reload_ammo"));
 +              }
 +
                oldself = self;
                self = spot;
                        activator = oldself;
                self.cnt = self.switchweapon;
                self.weapon = 0;
  
 -        self.wish_reload = 0;
 -
                if(!self.alivetime)
                        self.alivetime = time;
        } else if(self.classname == "observer" || (g_ca && !allowed_to_spawn)) {
@@@ -1115,6 -1109,7 +1115,6 @@@ float ClientInit_SendEntity(entity to, 
        WriteByte(MSG_ENTITY, autocvar_g_balance_nex_secondary); // client has to know if it should zoom or not
        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
        WriteCoord(MSG_ENTITY, autocvar_g_trueaim_minrange);
        return TRUE;
  }
@@@ -2346,13 -2341,12 +2346,14 @@@ void SpectateCopy(entity spectatee) 
        self.ammo_nails = spectatee.ammo_nails;
        self.ammo_rockets = spectatee.ammo_rockets;
        self.ammo_fuel = spectatee.ammo_fuel;
 +      self.clip_load = spectatee.clip_load;
 +      self.clip_size = spectatee.clip_size;
        self.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
        self.health = spectatee.health;
        self.impulse = 0;
        self.items = spectatee.items;
        self.last_pickup = spectatee.last_pickup;
+       self.hit_time = spectatee.hit_time;
        self.metertime = spectatee.metertime;
        self.strength_finished = spectatee.strength_finished;
        self.invincible_finished = spectatee.invincible_finished;
@@@ -2949,10 -2943,6 +2950,10 @@@ void PlayerPreThink (void
        }
  
        target_voicescript_next(self);
 +
 +      // if a player goes unarmed after holding a loaded weapon, empty his clip size and remove the crosshair ammo ring
 +      if(!self.weapon)
 +              self.clip_load = self.clip_size = 0;
  }
  
  float isInvisibleString(string s)
diff --combined qcsrc/server/defs.qh
@@@ -605,6 -605,9 +605,9 @@@ string matchid
  
  .float last_pickup;
  
+ .float hit_time; 
+ .float typehit_time; 
  .float stat_leadlimit;
  
  float radar_showennemies;
@@@ -614,13 -617,8 +617,13 @@@ float client_cefc_accumulator
  float client_cefc_accumulatortime;
  #endif
  
 -.float sniperrifle_bulletcounter;
 -.float wish_reload;
 +..float current_ammo;
 +
 +.float weapon_load[WEP_MAXCOUNT]; FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(weapon_load);
 +.float ammo_none; // used by the reloading system, must always be 0
 +.float clip_load;
 +.float old_clip_load;
 +.float clip_size;
  
  #define PROJECTILE_MAKETRIGGER(e) (e).solid = SOLID_CORPSE; (e).dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE
  // when doing this, hagar can go through clones
diff --combined qcsrc/server/g_world.qc
@@@ -823,9 -823,10 +823,11 @@@ void spawnfunc_worldspawn (void
        addstat(STAT_FUEL, AS_INT, ammo_fuel);
        addstat(STAT_SHOTORG, AS_INT, stat_shotorg);
        addstat(STAT_LEADLIMIT, AS_FLOAT, stat_leadlimit);
 -      addstat(STAT_BULLETS_LOADED, AS_INT, sniperrifle_bulletcounter);
 +      addstat(STAT_WEAPON_CLIPLOAD, AS_INT, clip_load);
 +      addstat(STAT_WEAPON_CLIPSIZE, AS_INT, clip_size);
        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_NEX_CHARGE, AS_FLOAT, nex_charge);
        addstat(STAT_NEX_CHARGEPOOL, AS_FLOAT, nex_chargepool_ammo);
@@@ -2841,16 -2842,16 +2843,16 @@@ void EndFrame(
                if(self.classname == "spectator")
                {
                        if(self.enemy.typehitsound)
-                               play2(self, "misc/typehit.wav");
+                               self.typehit_time = time;
                        else if(self.enemy.hitsound && self.cvar_cl_hitsound)
-                               play2(self, "misc/hit.wav");
+                               self.hit_time = time;
                }
                else
                {
                        if(self.typehitsound)
-                               play2(self, "misc/typehit.wav");
+                               self.typehit_time = time;
                        else if(self.hitsound && self.cvar_cl_hitsound)
-                               play2(self, "misc/hit.wav");
+                               self.hit_time = time;
                }
        }
        altime = time + frametime * (1 + autocvar_g_antilag_nudge);