Skip to content

Commit

Permalink
Added ability to disable bullet cocking
Browse files Browse the repository at this point in the history
  • Loading branch information
timmybo5 committed Sep 14, 2021
1 parent 38dcfd4 commit afba584
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions code/swb_base/ViewModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public override void PostCameraSetup(ref CameraSetup camSetup)
if (liveEditing && weapon.RunAnimData != null)
{
// Zooming
TargetVectorRot = MathUtil.ToVector3(new Angles(-2.8f, -1.5f, -4f));
TargetVectorPos = new Vector3(-6.34f, 6, 0.57f);
TargetVectorRot = MathUtil.ToVector3(new Angles(-0.21f, -0.05f, 0));
TargetVectorPos = new Vector3(-2.317f, -3f, 1.56f);
TargetFOV = weapon.ZoomFOV;
return;

Expand Down
1 change: 1 addition & 0 deletions code/swb_base/WeaponBase.Var.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public partial class WeaponBase
public virtual bool PlayHitmarkerSound => true; // Play the hitmarker sound
public virtual bool CanDrop => true; // Can manually drop weapon
public virtual bool DropWeaponOnDeath => true; // Drop the weapon on death
public virtual bool BulletCocking => true; // Can bullets be cocked in the barrel? ( clip ammo + 1 )
public virtual string FreezeViewModelOnZoom => null; // Some weapons have looping idle animations -> force spam another animation to "freeze" it
public virtual int FOV => 65; // Default FOV
public virtual int ZoomFOV => 65; // FOV while zooming
Expand Down
6 changes: 4 additions & 2 deletions code/swb_base/WeaponBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ public virtual void Reload()
if (IsReloading || IsAnimating)
return;

if (Primary.Ammo >= (Primary.ClipSize + 1) || Primary.ClipSize == -1)
var maxClipSize = BulletCocking ? Primary.ClipSize + 1 : Primary.ClipSize;

if (Primary.Ammo >= maxClipSize || Primary.ClipSize == -1)
return;

var isEmptyReload = Primary.ReloadEmptyTime > 0 ? Primary.Ammo == 0 : false;
Expand Down Expand Up @@ -187,7 +189,7 @@ public virtual void OnReloadFinish()
{
var newAmmo = Primary.ClipSize;

if (Primary.Ammo > 0)
if (BulletCocking && Primary.Ammo > 0)
newAmmo += 1;

Primary.Ammo = newAmmo;
Expand Down
2 changes: 1 addition & 1 deletion code/swb_base/structures/ClipInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class ClipInfo
// Strings
public string ShootAnim { get; set; } = "fire"; // Shooting animation
public string ReloadAnim { get; set; } = "reload"; // Reloading animation
public string ReloadEmptyAnim { get; set; } = "reload_empty"; // Reloading animation
public string ReloadEmptyAnim { get; set; } = "reload_empty"; // Reloading animation when clip is empty
public string DrawAnim { get; set; } = "deploy"; // Draw animation
public string DrawEmptyAnim { get; set; } = ""; // Draw animation when there is no ammo
public string DryFireSound { get; set; } // Firing sound when clip is empty
Expand Down

0 comments on commit afba584

Please sign in to comment.