Пример #1
0
    private void StartMagazineReload()
    {
        if (reloading)
        {
            return;
        }

        startReload  = Time.time;
        reloading    = true;
        tss.pitchMod = 1f;

        bool magIsEmpty = (AntiHackSystem.RetrieveInt("currentAmmo") <= 0);

        tss.GetComponent <AudioSource>().PlayOneShot((magIsEmpty && reloadSoundEmpty != null) ? reloadSoundEmpty : reloadSound, 0.5f);
        curReloadDur = (magIsEmpty && reloadSoundEmpty != null) ? reloadLengthEmpty : reloadLength;

        if (Topan.Network.isConnected && wm.rootNetView)
        {
            wm.rootNetView.RPC(Topan.RPCMode.Others, "NetworkReload", magIsEmpty);
        }

        //Assign a new variable called AnimationContainer instead of using parents...

        /*
         *      if(reloadAnim != "" && !transform.parent.parent.parent.animation.isPlaying) {
         *              transform.parent.parent.parent.animation.Play(reloadAnim);
         *      }
         */
    }
Пример #2
0
 private void ClampGrenadeAmount()
 {
     typeOneMaxGrenades = AntiHackSystem.RetrieveInt("t1GrenadeMax");
     typeTwoMaxGrenades = AntiHackSystem.RetrieveInt("t2GrenadeMax");
     typeOneGrenades    = Mathf.Clamp(AntiHackSystem.RetrieveInt("t1Grenade"), 0, typeOneMaxGrenades);
     typeTwoGrenades    = Mathf.Clamp(AntiHackSystem.RetrieveInt("t2Grenade"), 0, typeTwoMaxGrenades);
 }
Пример #3
0
    private void CheckAmmo()
    {
        int retrievedAmmo        = AntiHackSystem.RetrieveInt("currentAmmo");
        int retrievedAmmoLeft    = AntiHackSystem.RetrieveInt("ammoLeft");
        int retrievedAmmoLeftCap = AntiHackSystem.RetrieveInt("ammoLeftCap");

        ammoLeft = Mathf.Clamp(retrievedAmmoLeft, 0, retrievedAmmoLeftCap);

        if (!reloadOnMouseClick && cInput.GetButtonDown("Fire Weapon") && (Time.time - lastClick) > 0.3f && retrievedAmmo <= 0 && !reloading && !RestrictionManager.restricted)
        {
            if (Topan.Network.isConnected && wm.rootNetView)
            {
                wm.rootNetView.UnreliableRPC(Topan.RPCMode.Others, "NetworkEmptyClick");
            }

            firePos.GetComponent <AudioSource>().PlayOneShot(emptySound);
            dm.EmptyAnimation();
            lastClick = Time.time;
        }

        int newMaxSize = AntiHackSystem.RetrieveInt("clipSize") + ((bulletInChamber) ? 1 : 0);

        currentAmmo = Mathf.Clamp(retrievedAmmo, 0, newMaxSize);
        ammoDif     = newMaxSize - retrievedAmmo;
        percent     = (float)retrievedAmmo / (float)newMaxSize;
    }
Пример #4
0
    void Update()
    {
        ClampGrenadeAmount();

        if (Time.time - lastUpdateTime >= 0.1f)
        {
            slotOneLabel.text = (pe.hasEMP) ? Random.Range(0, 10).ToString() : AntiHackSystem.RetrieveInt("t1Grenade").ToString();
            slotTwoLabel.text = (pe.hasEMP) ? Random.Range(0, 10).ToString() : AntiHackSystem.RetrieveInt("t2Grenade").ToString();

            lastUpdateTime = Time.time;
        }
    }
Пример #5
0
    private void InsertBullet()
    {
        int retrievedAmmo     = AntiHackSystem.RetrieveInt("currentAmmo");
        int retrievedAmmoLeft = AntiHackSystem.RetrieveInt("ammoLeft");
        int retrievedClipSize = AntiHackSystem.RetrieveInt("clipSize");

        if (retrievedAmmo >= retrievedClipSize || retrievedAmmoLeft <= 0 || queueStopReload)
        {
            if (!doneReloading)
            {
                StartCoroutine(StopSingularReload());
            }

            return;
        }

        if (retrievedAmmo < retrievedClipSize && retrievedAmmoLeft > 0)
        {
            if (ammoDif < reloadAmount)
            {
                AntiHackSystem.ProtectInt("currentAmmo", currentAmmo + ammoDif);
                AntiHackSystem.ProtectInt("ammoLeft", ammoLeft - ammoDif);
            }
            else if (reloadAmount >= retrievedAmmoLeft)
            {
                AntiHackSystem.ProtectInt("currentAmmo", currentAmmo + ammoLeft);
                AntiHackSystem.ProtectInt("ammoLeft", 0);
            }
            else
            {
                AntiHackSystem.ProtectInt("currentAmmo", currentAmmo + reloadAmount);
                AntiHackSystem.ProtectInt("ammoLeft", ammoLeft - reloadAmount);
            }

            tss.pitchMod = Random.Range(0.95f, 1f);
            tss.GetComponent <AudioSource>().PlayOneShot(reloadSound, 0.5f);
            queueStopReload = forceStopReload;
            //Reload insert shell animation play.
        }

        reloadImpulseGUI += 0.1f;
    }
Пример #6
0
    private IEnumerator Burst(float cwm, float vf, float af)
    {
        bursting = true;
        float burstTimer = 0f;
        int   fireCount  = 0;

        while (fireCount < bulletsPerBurst && AntiHackSystem.RetrieveInt("currentAmmo") > 0)
        {
            burstTimer += Time.deltaTime;
            if (burstTimer >= burstInterval)
            {
                Shoot(cwm, vf, af);
                fireCount++;
                burstTimer -= burstInterval;
            }
            yield return(null);
        }
        yield return(new WaitForSeconds(burstCooldown));

        bursting = false;
    }
Пример #7
0
    public void MakePickup(Vector3 force)
    {
        Rigidbody body = gameObject.AddComponent <Rigidbody>();

        body.mass = 3f;

        UsableObject uo = gameObject.AddComponent <UsableObject>();

        uo.weaponPickup                 = new UsableObject.WeaponPickup();
        uo.weaponPickup.enabled         = true;
        uo.weaponPickup.ammoAmount      = AntiHackSystem.RetrieveInt("currentAmmo");
        uo.weaponPickup.reserveAmmo     = AntiHackSystem.RetrieveInt("ammoLeft");
        uo.weaponPickup.chamberedBullet = bulletInChamber;
        uo.weaponPickup.weaponID        = weaponID;
        transform.parent                = null;

        body.AddForce(force * 7f, ForceMode.Impulse);
        body.AddTorque(Random.rotation.eulerAngles * 3f, ForceMode.Impulse);

        uo.objectName = gunName;
        StripFunctions(false);
    }
Пример #8
0
    private void Reload()
    {
        int retrievedAmmoLeft = AntiHackSystem.RetrieveInt("ammoLeft");

        bulletInChamber = (AntiHackSystem.RetrieveInt("currentAmmo") > 0 && includeChamberRound);
        CheckAmmo();

        AntiHackSystem.ProtectInt("currentAmmo", currentAmmo + ((ammoDif > retrievedAmmoLeft) ? retrievedAmmoLeft : (ammoDif + ((bulletInChamber) ? 1 : 0))));

        if (ammoDif > retrievedAmmoLeft)
        {
            AntiHackSystem.ProtectInt("ammoLeft", 0);
        }
        else
        {
            AntiHackSystem.ProtectInt("ammoLeft", ammoLeft - ammoDif);
        }

        reloadImpulseGUI += 0.1f;
        bsna              = baseSpreadAmount;
        endReload         = Time.time;
        reloading         = false;
    }
Пример #9
0
    void Update()
    {
        int retrievedMaxHealth = AntiHackSystem.RetrieveInt("maxHealth");
        int retrievedMaxShield = AntiHackSystem.RetrieveInt("maxShield");

        if (GameManager.boundarySettings != null)
        {
            bool inMapBounds = GameManager.boundarySettings.mapBounds.Contains(transform.position);
            if (!inMapBounds)
            {
                ApplyDamageMain((curHealth + curShield) * 2, false);
            }
        }

        if (Input.GetKey(KeyCode.X))
        {
            if (Input.GetKeyDown(KeyCode.B))
            {
                ApplyDamageMain(Random.Range(10, 15), true);
                HitIndicator(transform.position + DarkRef.RandomVector3(Vector3.one * -5f, Vector3.one * 5f));
            }
            else if (Input.GetKeyDown(KeyCode.K))
            {
                ApplyDamageMain(retrievedMaxHealth + retrievedMaxShield + 1, false);
            }
        }

        AdjustGUISize();
        ManageIndicatorGUI();

        if (recovering && curHealth < retrievedMaxHealth)
        {
            timer += Time.deltaTime;
        }

        if (shRecovering)
        {
            if (curShield < retrievedMaxShield)
            {
                shTimer += Time.deltaTime;
            }

            shieldAlarmSource.volume = 0f;

            if (!shGlowRecover)
            {
                shieldTexture.color = shieldTexture.defaultColor;
                shieldAlpha         = 0.21f;
                shGlowRecover       = true;
            }
        }
        else
        {
            shGlowRecover = false;
            if (retrievedMaxShield > 0f)
            {
                if (pe.hasEMP)
                {
                    shieldAlarmSource.volume = 0f;
                }
                else
                {
                    shieldAlarmSource.volume = Mathf.Clamp01(0.5f - shPercent) * 0.12f;
                }
            }
        }

        if (Time.time - lastDamage > 0.3f)
        {
            Color lerpHurtColor = Color.Lerp(hurtColor, Color.white, Mathf.Clamp01((percent - 0.2f) * 3.5f));
            healthText.color = Color.Lerp(healthText.color, lerpHurtColor, Time.unscaledDeltaTime * 5f);
            Color lerpShieldColor = Color.Lerp(new Color(0.8f, 0.8f, 0.8f, 1f), Color.white, Mathf.Clamp01(shPercent * 5f));
            shieldText.color = Color.Lerp(shieldText.color, lerpShieldColor, Time.unscaledDeltaTime * 5f);
        }

        curShield = Mathf.Clamp(curShield, 0, retrievedMaxShield);
        float fallDmgMod = (fallDamageTotal > 0) ? 0.8f : 1f;

        if (retrievedMaxShield > 0)
        {
            shPercent = (float)curShield / (float)retrievedMaxShield;

            float shRecoverRate = (shieldRecoverySpeed * fallDmgMod);
            if (shTimer >= shRecoverRate && (curShield < retrievedMaxShield))
            {
                curShield += shieldRecoverAmount;

                if (fallDamageTotal > 0)
                {
                    fallDamageTotal--;
                }

                shTimer -= shRecoverRate;
            }
        }
        else
        {
            shPercent = 0f;
        }

        curHealth  = Mathf.Clamp(curHealth, 0, retrievedMaxHealth);
        maxHealth  = retrievedMaxHealth;
        maxShield  = retrievedMaxShield;
        curStamina = Mathf.Clamp(curStamina, 0, 100);

        float recoverRate = (healthRecoverySpeed * (1f + (percent * healthRecoverInfluence)) * fallDmgMod);

        if (timer >= recoverRate && (curHealth < retrievedMaxHealth))
        {
            curHealth += healthRecoverAmount;

            if (fallDamageTotal > 0)
            {
                fallDamageTotal--;
            }

            timer -= recoverRate;
        }

        if (!dead)
        {
            if (startRecoveryTimer)
            {
                rTimer += Time.deltaTime;
            }

            if (startShRecoveryTimer)
            {
                shrTimer += Time.deltaTime;
            }
        }

        if (rTimer >= healthRecoverDelay && !dead)
        {
            startRecoveryTimer = false;
            rTimer             = 0f;
            recovering         = true;
        }

        if (maxShield > 0 && shrTimer >= shieldRecoverDelay && !dead)
        {
            startShRecoveryTimer = false;
            shrTimer             = 0f;
            shRecovering         = true;

            fallDamageSource.GetComponent <TimeScaleSound>().pitchMod = 1f;
            fallDamageSource.PlayOneShot(shieldRegen, 0.1f);
        }

        float steepSlopeFactor = (pm.grounded) ? Mathf.Clamp01(pm.controller.velocity.normalized.y) : 0f;

        if (pm.grounded && (pm.sprinting || pm.sprintReloadBoost > 1f) && pm.xyVelocity >= 0.75f)
        {
            rattleTSS.pitchMod           = 1f;
            equipmentRattleSource.volume = Mathf.Lerp(equipmentRattleSource.volume, rattleVolumeSprint, Time.deltaTime * 9f);
            dTimer += Time.deltaTime * (pm.controllerVeloMagn / pm.movement.sprintSpeed);

            float requirement = staminaDepletionRate * (1f - (wc.weightPercentage * 0.8f)) * (1f - (steepSlopeFactor * 0.22f));
            if (dTimer >= requirement && curStamina > 0f)
            {
                curStamina -= 1 + Mathf.RoundToInt((1f / requirement) * Time.deltaTime);
                dTimer      = 0f;
            }
        }
        else
        {
            float velocityFactor = Mathf.Clamp01(pm.xyVelocity / pm.movement.runSpeed);
            if (jumpRattleEquip)
            {
                rattleTimer += Time.deltaTime;

                if (pm.xyVelocity < 0.75f)
                {
                    rattleTSS.pitchMod           = 1f;
                    equipmentRattleSource.volume = Mathf.Lerp(equipmentRattleSource.volume, Mathf.Lerp(rattleVolumeNormal, rattleVolumeSprint, 0.5f), Time.deltaTime * 11f);
                }

                if (rattleTimer >= 0.4f)
                {
                    rattleTimer     = 0f;
                    jumpRattleEquip = false;
                }
            }
            else
            {
                if (pm.grounded)
                {
                    if (pm.xyVelocity >= 0.75f)
                    {
                        rattleTSS.pitchMod           = (pm.crouching) ? 0.8f : 0.96f;
                        equipmentRattleSource.volume = Mathf.Lerp(equipmentRattleSource.volume, rattleVolumeNormal * velocityFactor, Time.deltaTime * 9f);
                    }
                    else
                    {
                        equipmentRattleSource.volume = Mathf.Lerp(equipmentRattleSource.volume, 0f, Time.deltaTime * 9f);
                    }
                }
                else
                {
                    equipmentRattleSource.volume = Mathf.Lerp(equipmentRattleSource.volume, 0f, Time.deltaTime * 9f);
                }
            }

            sTimer += Time.deltaTime;

            float requirement = (staminaRecoverySpeed * (2f - Mathf.Clamp(Time.time - lastDe, 0f, 1f)) * (1f + Mathf.Clamp01((pm.xyVelocity * 0.17f) / pm.movement.runSpeed)) + (steepSlopeFactor * 0.16f));
            if (sTimer >= requirement && curStamina < 100 && !staminaCooldown)
            {
                curStamina += 1 + Mathf.RoundToInt((1f / requirement) * Time.deltaTime);
                sTimer      = 0f;
            }
        }

        curStamina = Mathf.Clamp(curStamina, 0, 100);

        if (curStamina <= 1f && canSprint)
        {
            StartCoroutine(CalmingStage());
        }

        shieldAlpha  = Mathf.Clamp(shieldAlpha, 0f, 0.35f);
        shieldAlpha  = Mathf.MoveTowards(shieldAlpha, 0f, Time.deltaTime * 0.6f);
        finalShAlpha = Mathf.Lerp(finalShAlpha, shieldAlpha, Time.deltaTime * 8.5f);

        shieldTexture.alpha = finalShAlpha * ((shGlowRecover) ? 1f : (0.3f + (Mathf.PerlinNoise(Mathf.PingPong(Time.time * 22f, 250f), 0f) * 0.7f)));
        damageEffect        = Mathf.Lerp(damageEffect, 0f, (Time.time - lastDe) * 5f);
        chromAbb            = Mathf.Lerp(chromAbb, Mathf.Clamp(damageEffect, 0f, 30f) + ((0.3f - Mathf.Min(percent, 0.3f)) * 25f), Time.deltaTime * 5f);

        bloodEffect             = Mathf.Clamp01(Mathf.Lerp(bloodEffect, 0f, Time.deltaTime * 0.068f));
        uic.gManager.damageBlur = Mathf.Clamp(Mathf.Lerp(uic.gManager.damageBlur, 0f, Time.deltaTime * dmgBlurRestore) + ((percent <= 0.2f) ? 0.001f : 0f), 0f, 0.85f);

        foreach (FlickeringGUI fg in flickeringGUI)
        {
            if (pe.hasEMP)
            {
                fg.dimAlpha         = Random.Range(0.1f, 1f);
                fg.updateFrequency  = 0.03f;
                fg.flickerFrequency = 0.8f;
            }
            else
            {
                fg.dimAlpha         = Mathf.Clamp01(0.3f + flickerIntensity * 2f);
                fg.updateFrequency  = 0.05f;
                fg.flickerFrequency = 0.85f;
            }
        }

        float stPercent = Mathf.Clamp01((float)curStamina / 100f);
        float hbVolume  = Mathf.Clamp(0.5f - percent, 0f, 0.5f) * 0.3f;

        heartbeatSound.volume = hbVolume + ((1f - stPercent) * 0.05f);

        float nVolume = Mathf.Clamp(0.25f - percent, 0f, 0.25f) / 0.25f;

        noiseSource.volume = nVolume * 0.2f;

        if (Time.time - lastHeartTime >= 1f)
        {
            hbEffectTarget = 3.1f;
            lastHeartTime  = Time.time;
        }

        if (pe.hasEMP)
        {
            grainEMP   = Mathf.Lerp(grainEMP, 0.035f, Time.deltaTime * 1.3f);
            distortEMP = Mathf.Lerp(distortEMP, 0.15f, Time.deltaTime * 1.3f);
        }
        else
        {
            grainEMP   = Mathf.Lerp(grainEMP, 0f, Time.deltaTime * 3f);
            distortEMP = Mathf.Lerp(distortEMP, 0f, Time.deltaTime * 3f);
        }

        vignetteEMP  = Mathf.Lerp(vignetteEMP, 0f, Time.deltaTime * 4f);
        ne.empEffect = grainEMP;

        hbEffectTarget  = Mathf.MoveTowards(hbEffectTarget, 0f, Time.deltaTime * 4.3f);
        heartbeatEffect = Mathf.Lerp(heartbeatEffect, hbEffectTarget + 0.05f, Time.deltaTime * 11f);

        percent          = curHealth / (float)retrievedMaxHealth;
        flickerIntensity = Mathf.Lerp(flickerIntensity, percent, Time.deltaTime * 0.5f * Mathf.Clamp((Time.time - initTime) * 0.5f, 0f, 4f));
        hearingPenalty   = Mathf.Lerp(hearingPenalty, 1f, Time.deltaTime * 0.2f);

        if (percent <= 0.25f)
        {
            standardFreq      = Mathf.Lerp(standardFreq, (pe.hasEMP) ? empMuffle : Mathf.Lerp(muffleRange.x, muffleRange.y, Mathf.Clamp01(percent * 4f)), Time.deltaTime * 9f);
            ne.grainIntensity = Mathf.Lerp(0f, 0.0075f, 1f - Mathf.Clamp01(percent * 4f));
        }
        else
        {
            standardFreq      = Mathf.Lerp(standardFreq, (pe.hasEMP) ? empMuffle : 20000f, Time.deltaTime * ((pe.hasEMP) ? 3.5f : 0.7f));
            ne.grainIntensity = Mathf.Lerp(ne.grainIntensity, 0f, Time.deltaTime * 5f);
        }

        healthLowPass.cutoffFrequency = standardFreq * hearingPenalty;

        ne.enabled         = (ne.grainIntensity + grainEMP > 0f);
        disE.enabled       = (ne.enabled || distortEMP > 0f);
        disE.baseIntensity = (ne.grainIntensity * 4f) + distortEMP;
        disE.splitOffset   = (pe.hasEMP) ? 0.05f : 0f;

        if (staminaBlinking)
        {
            sBlinkTimer += Time.deltaTime * 6.75f;
            sBlinkValue  = Mathf.Sin(sBlinkTimer);

            Color redCol = defStaminaBGCol;
            redCol.r *= 3f;
            staminaBackground.color = Color.Lerp(defStaminaBGCol, redCol, sBlinkValue);
        }
        else
        {
            sBlinkTimer = 0f;
            sBlinkValue = 0f;

            staminaBackground.color = defStaminaBGCol;
        }

        damageBreathBoost     = Mathf.Clamp(Mathf.MoveTowards(damageBreathBoost, 0f, Time.deltaTime * 0.05f), 0f, 0.42f);
        dBreath               = Mathf.Lerp(dBreath, damageBreathBoost, Time.deltaTime * 7f);
        breathingSound.volume = (0.05f + (hbVolume * 0.11f) + (0.148f * (1f - stPercent)) + dBreath) * breathFactor;
        breathingSound.GetComponent <TimeScaleSound>().pitchMod = 1f + (hbVolume * 0.03f) + (0.145f * (1f - stPercent));

        imageEffect                    = Mathf.Lerp(imageEffect, Mathf.Clamp01(1f - (percent + 0.45f)) * effectIntensity, Time.deltaTime * 3f);
        vignetting.intensity           = imageEffect + vignetteEMP + (heartbeatEffect * Mathf.Clamp01(1f - (percent * 2f)));
        vignetting.blur                = (imageEffect * 0.2f) + aimEffect;
        vignetting.blurSpread          = aimEffect * 0.5f;
        vignetting.heartbeatBlur       = heartbeatEffect * Mathf.Clamp01(1f - (percent * 2f)) * 0.45f;
        vignetting.chromaticAberration = chromAbb * (1f + ((1 - percent) * 0.3f));

        float saturation = Mathf.Clamp01(0.45f + (percent * 0.88f));

        sa.saturationAmount = Mathf.Lerp(sa.saturationAmount, (pe.hasEMP) ? Random.value * Random.value : saturation, Time.deltaTime * 4f);
        sa.colorTint        = Vector4.Lerp(new Vector4(1.1f, 0.95f, 0.95f, 1f), Vector4.one, Mathf.Clamp01(percent * 2.5f));

        if (!dead)
        {
            alpha = Mathf.Lerp(alpha, bloodEffect + ((1 - percent) * 0.15f), Time.deltaTime * 8f);
            bloodyScreen.material.color = DarkRef.SetAlpha(bloodyScreen.material.color, alpha * 0.82f);
        }

        healthBar.value = Mathf.Lerp(healthBar.value, (pe.hasEMP) ? Random.value : percent, Time.unscaledDeltaTime * 7.5f);
        shieldBar.value = Mathf.Lerp(shieldBar.value, (pe.hasEMP) ? Random.value : shPercent, Time.unscaledDeltaTime * 7.5f);

        if (pe.hasEMP)
        {
            if (Time.time - lastUpdateTime >= 0.1f)
            {
                healthText.text = (dead) ? "INACTIVE" : (Random.Range(0, 999) + "/" + Random.Range(0, 999));
                lastUpdateTime  = Time.time;
            }
        }
        else
        {
            healthText.text = (dead) ? "INACTIVE" : (curHealth + "/" + retrievedMaxHealth);
        }

        if (shrTimer < 0f || maxShield <= 0)
        {
            shieldText.color = new Color(1f, 0.4f, 0.2f);
            shieldText.text  = "DISABLED";
        }
        else
        {
            shieldText.color = shieldText.defaultColor;
            shieldText.text  = curShield + "/" + retrievedMaxShield;
        }

        staminaBar.value = Mathf.Lerp(staminaBar.value, (pe.hasEMP) ? Random.value : stPercent, Time.deltaTime * 8f);
    }
Пример #10
0
    void Update()
    {
        if (mpReferenceOnly || ownedByBot)
        {
            return;
        }

        int retrievedAmmo = AntiHackSystem.RetrieveInt("currentAmmo");

        CheckAmmo();
        WeaponGUI();

        float curTime = Time.time;

        if (curTime - timeSinceLastFire >= Mathf.Min(0.5f, (1f + Time.deltaTime) / GetFireRate()))
        {
            bsna = Mathf.MoveTowards(bsna, baseSpreadAmount, Time.deltaTime * recoverSpeed);
        }
        else
        {
            bsna = Mathf.MoveTowards(bsna, baseSpreadAmount, Time.deltaTime * recoverSpeed * 0.1f);
        }

        bsna = Mathf.Clamp(bsna, baseSpreadAmount, maxSpreadAmount);

        if (timer > 0f)
        {
            timer -= Time.deltaTime * GetFireRate();
        }

        if (curTime - initializeTime < 0.5f)
        {
            return;
        }

        if (cInput.GetButton("Fire Weapon") && currentAmmo > 0)
        {
            if (!startCounting)
            {
                startCounting = true;
            }
        }
        else
        {
            if (startCounting)
            {
                fireCount     = 0;
                startCounting = false;
            }
        }

        float cwm        = (pm.crouching || pm.walking) ? crouchWalkModifier : 1f;
        float veloFactor = Mathf.Clamp01(pm.controllerVeloMagn / pm.movement.runSpeed) * movementSpreadAmount * asm;
        float airFactor  = ((pm.grounded) ? 1f : (1f + (Mathf.Clamp01(Mathf.Max(0.1f, Mathf.Abs(pm.controller.velocity.y) - 2.5f) * 0.15f) * (ac.isAiming ? 32f : 1f))));

        spreadReal = (bsna * cwm * asm * airFactor) + veloFactor;

        if (!RestrictionManager.restricted && !RestrictionManager.mpMatchRestrict && timer <= 0f && retrievedAmmo > 0 && !reloading && !pm.sprinting && !switching && !acs.clipping && !pm.onLadder && !dm.animationIsPlaying && !dm.terminalVelocity && Time.time - endReload >= 0.15f && !ac.isTransitioning)
        {
            if (cInput.GetButtonDown("Fire Weapon") && currentFireMode == FireMode.SemiAuto)
            {
                Shoot(cwm, veloFactor, airFactor);
            }

            if (cInput.GetButton("Fire Weapon"))
            {
                if (currentFireMode == FireMode.FullAuto)
                {
                    Shoot(cwm, veloFactor, airFactor);
                }
                else if (currentFireMode == FireMode.BurstFire && !bursting)
                {
                    StartCoroutine(Burst(cwm, veloFactor, airFactor));
                }
            }
        }

        if (reloading)
        {
            if (reloadMethod == ReloadMethod.Magazine)
            {
                if (curTime - startReload >= curReloadDur)
                {
                    Reload();
                }
            }
            else if (reloadMethod == ReloadMethod.Singular)
            {
                if (cInput.GetButtonDown("Reload") || cInput.GetButtonDown("Fire Weapon"))
                {
                    forceStopReload = true;
                }

                if (rDelayDone)
                {
                    rIntervalTimer += Time.deltaTime;

                    if (rIntervalTimer >= reloadInterval)
                    {
                        InsertBullet();
                        rIntervalTimer -= reloadInterval;
                    }
                }
                else
                {
                    rDelayTimer += Time.deltaTime;
                    if (rDelayTimer >= reloadDelay)
                    {
                        rIntervalTimer = reloadInterval;
                        rDelayTimer    = 0f;
                        rDelayDone     = true;
                    }
                }
            }
        }

        if (ac.isAiming && !pm.onLadder)
        {
            asm = aimSpreadModifier;
            pl.aimMouseModifier = mouseSensitivityAim;
            pm.speedAimMod      = playerSpeedAim;
            if (sniperAimEffect)
            {
                ac.aimEffect = true;
            }
        }
        else
        {
            asm = 1f;
            pl.aimMouseModifier = 1f;
            pm.speedAimMod      = 1f;
            if (sniperAimEffect)
            {
                ac.aimEffect = false;
            }
        }

        if (!pm.onLadder && !RestrictionManager.restricted)
        {
            if (cInput.GetButtonDown("Fire Mode") && secondMode != FireMode.None && canSwitchModes && !switching)
            {
                SwitchFireModes();
            }

            if (!reloading && (Time.time - timeSinceLastFire > 0.2f) && AntiHackSystem.RetrieveInt("ammoLeft") > 0 && !pm.sprinting && ((cInput.GetButtonDown("Reload") && ammoDif > 0) || (retrievedAmmo <= 0 && reloadOnMouseClick && cInput.GetButtonDown("Fire Weapon"))))
            {
                if (reloadMethod == ReloadMethod.Magazine)
                {
                    StartMagazineReload();
                }
                else if (reloadMethod == ReloadMethod.Singular && !reloading)
                {
                    reloading = true;
                }
            }
        }
    }