예제 #1
0
    private void CLProject(BaseEntity.RPCMessage msg)
    {
        BasePlayer basePlayer = msg.player;

        if (!this.VerifyClientAttack(basePlayer))
        {
            base.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
            return;
        }
        if (this.reloadFinished && this.HasReloadCooldown())
        {
            AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Reloading (", base.ShortPrefabName, ")"));
            basePlayer.stats.combat.Log(this, "reload_cooldown");
            return;
        }
        this.reloadStarted  = false;
        this.reloadFinished = false;
        if (this.primaryMagazine.contents <= 0 && !this.UsingInfiniteAmmoCheat)
        {
            AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Magazine empty (", base.ShortPrefabName, ")"));
            basePlayer.stats.combat.Log(this, "ammo_missing");
            return;
        }
        ItemDefinition  itemDefinition  = this.primaryMagazine.ammoType;
        ProjectileShoot projectileShoot = ProjectileShoot.Deserialize(msg.read);

        if (itemDefinition.itemid != projectileShoot.ammoType)
        {
            AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Ammo mismatch (", base.ShortPrefabName, ")"));
            basePlayer.stats.combat.Log(this, "ammo_mismatch");
            return;
        }
        if (!this.UsingInfiniteAmmoCheat)
        {
            this.primaryMagazine.contents--;
        }
        ItemModProjectile component = itemDefinition.GetComponent <ItemModProjectile>();

        if (component == null)
        {
            AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Item mod not found (", base.ShortPrefabName, ")"));
            basePlayer.stats.combat.Log(this, "mod_missing");
            return;
        }
        if (projectileShoot.projectiles.Count > component.numProjectiles)
        {
            AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Count mismatch (", base.ShortPrefabName, ")"));
            basePlayer.stats.combat.Log(this, "count_mismatch");
            return;
        }
        Interface.CallHook("OnWeaponFired", this, msg.player, component, projectileShoot);
        base.SignalBroadcast(BaseEntity.Signal.Attack, string.Empty, msg.connection);
        basePlayer.CleanupExpiredProjectiles();
        foreach (ProjectileShoot.Projectile projectile in projectileShoot.projectiles)
        {
            if (!basePlayer.HasFiredProjectile(projectile.projectileID))
            {
                if (!base.ValidateEyePos(basePlayer, projectile.startPos))
                {
                    continue;
                }
                basePlayer.NoteFiredProjectile(projectile.projectileID, projectile.startPos, projectile.startVel, this, itemDefinition, null);
                this.CreateProjectileEffectClientside(component.projectileObject.resourcePath, projectile.startPos, projectile.startVel, projectile.seed, msg.connection, this.IsSilenced(), false);
            }
            else
            {
                AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Duplicate ID (", projectile.projectileID, ")"));
                basePlayer.stats.combat.Log(this, "duplicate_id");
            }
        }
        basePlayer.stats.Add(string.Concat(component.category, "_fired"), projectileShoot.projectiles.Count <ProjectileShoot.Projectile>(), Stats.Steam);
        base.StartAttackCooldown(this.ScaleRepeatDelay(this.repeatDelay) + this.animationDelay);
        basePlayer.MarkHostileFor(60f);
        this.UpdateItemCondition();
        this.DidAttackServerside();
        float single = 0f;

        if (component.projectileObject != null)
        {
            GameObject gameObject = component.projectileObject.Get();
            if (gameObject != null)
            {
                Projectile component1 = gameObject.GetComponent <Projectile>();
                if (component1 != null)
                {
                    foreach (DamageTypeEntry damageType in component1.damageTypes)
                    {
                        single += damageType.amount;
                    }
                }
            }
        }
        float noiseRadius = this.NoiseRadius;

        if (this.IsSilenced())
        {
            noiseRadius *= AI.npc_gun_noise_silencer_modifier;
        }
        Sensation sensation = new Sensation()
        {
            Type            = SensationType.Gunshot,
            Position        = basePlayer.transform.position,
            Radius          = noiseRadius,
            DamagePotential = single,
            InitiatorPlayer = basePlayer,
            Initiator       = basePlayer
        };

        Sense.Stimulate(sensation);
        if (EACServer.playerTracker != null)
        {
            using (TimeWarning timeWarning = TimeWarning.New("LogPlayerShooting", 0.1f))
            {
                UnityEngine.Vector3    networkPosition = basePlayer.GetNetworkPosition();
                UnityEngine.Quaternion networkRotation = basePlayer.GetNetworkRotation();
                Item item = this.GetItem();
                int  num  = (item != null ? item.info.itemid : 0);
                EasyAntiCheat.Server.Hydra.Client client = EACServer.GetClient(basePlayer.net.connection);
                PlayerUseWeapon playerUseWeapon          = new PlayerUseWeapon()
                {
                    Position     = new EasyAntiCheat.Server.Cerberus.Vector3(networkPosition.x, networkPosition.y, networkPosition.z),
                    ViewRotation = new EasyAntiCheat.Server.Cerberus.Quaternion(networkRotation.x, networkRotation.y, networkRotation.z, networkRotation.w),
                    WeaponID     = num
                };
                EACServer.playerTracker.LogPlayerUseWeapon(client, playerUseWeapon);
            }
        }
    }
예제 #2
0
    private void CLProject(RPCMessage msg)
    {
        BasePlayer player = msg.player;

        if (!VerifyClientAttack(player))
        {
            SendNetworkUpdate();
            return;
        }
        if (reloadFinished && HasReloadCooldown())
        {
            AntiHack.Log(player, AntiHackType.ProjectileHack, "Reloading (" + base.ShortPrefabName + ")");
            player.stats.combat.Log(this, "reload_cooldown");
            return;
        }
        reloadStarted  = false;
        reloadFinished = false;
        if (primaryMagazine.contents <= 0 && !UsingInfiniteAmmoCheat)
        {
            AntiHack.Log(player, AntiHackType.ProjectileHack, "Magazine empty (" + base.ShortPrefabName + ")");
            player.stats.combat.Log(this, "ammo_missing");
            return;
        }
        ItemDefinition  primaryMagazineAmmo = PrimaryMagazineAmmo;
        ProjectileShoot projectileShoot     = ProjectileShoot.Deserialize(msg.read);

        if (primaryMagazineAmmo.itemid != projectileShoot.ammoType)
        {
            AntiHack.Log(player, AntiHackType.ProjectileHack, "Ammo mismatch (" + base.ShortPrefabName + ")");
            player.stats.combat.Log(this, "ammo_mismatch");
            return;
        }
        if (!UsingInfiniteAmmoCheat)
        {
            primaryMagazine.contents--;
        }
        ItemModProjectile component = primaryMagazineAmmo.GetComponent <ItemModProjectile>();

        if (component == null)
        {
            AntiHack.Log(player, AntiHackType.ProjectileHack, "Item mod not found (" + base.ShortPrefabName + ")");
            player.stats.combat.Log(this, "mod_missing");
            return;
        }
        if (projectileShoot.projectiles.Count > component.numProjectiles)
        {
            AntiHack.Log(player, AntiHackType.ProjectileHack, "Count mismatch (" + base.ShortPrefabName + ")");
            player.stats.combat.Log(this, "count_mismatch");
            return;
        }
        Interface.CallHook("OnWeaponFired", this, msg.player, component, projectileShoot);
        if (player.InGesture)
        {
            return;
        }
        SignalBroadcast(Signal.Attack, string.Empty, msg.connection);
        player.CleanupExpiredProjectiles();
        foreach (ProjectileShoot.Projectile projectile in projectileShoot.projectiles)
        {
            if (player.HasFiredProjectile(projectile.projectileID))
            {
                AntiHack.Log(player, AntiHackType.ProjectileHack, "Duplicate ID (" + projectile.projectileID + ")");
                player.stats.combat.Log(this, "duplicate_id");
            }
            else if (ValidateEyePos(player, projectile.startPos))
            {
                player.NoteFiredProjectile(projectile.projectileID, projectile.startPos, projectile.startVel, this, primaryMagazineAmmo);
                if (!player.limitNetworking)
                {
                    CreateProjectileEffectClientside(component.projectileObject.resourcePath, projectile.startPos, projectile.startVel, projectile.seed, msg.connection, IsSilenced());
                }
            }
        }
        player.MakeNoise(player.transform.position, BaseCombatEntity.ActionVolume.Loud);
        player.stats.Add(component.category + "_fired", projectileShoot.projectiles.Count(), (Stats)5);
        player.LifeStoryShotFired(this);
        StartAttackCooldown(ScaleRepeatDelay(repeatDelay) + animationDelay);
        player.MarkHostileFor();
        UpdateItemCondition();
        DidAttackServerside();
        float num = 0f;

        if (component.projectileObject != null)
        {
            GameObject gameObject = component.projectileObject.Get();
            if (gameObject != null)
            {
                Projectile component2 = gameObject.GetComponent <Projectile>();
                if (component2 != null)
                {
                    foreach (DamageTypeEntry damageType in component2.damageTypes)
                    {
                        num += damageType.amount;
                    }
                }
            }
        }
        float num2 = NoiseRadius;

        if (IsSilenced())
        {
            num2 *= AI.npc_gun_noise_silencer_modifier;
        }
        Sensation sensation = default(Sensation);

        sensation.Type            = SensationType.Gunshot;
        sensation.Position        = player.transform.position;
        sensation.Radius          = num2;
        sensation.DamagePotential = num;
        sensation.InitiatorPlayer = player;
        sensation.Initiator       = player;
        Sense.Stimulate(sensation);
        if (EACServer.playerTracker != null)
        {
            using (TimeWarning.New("LogPlayerShooting"))
            {
                UnityEngine.Vector3    networkPosition = player.GetNetworkPosition();
                UnityEngine.Quaternion networkRotation = player.GetNetworkRotation();
                int weaponID = GetItem()?.info.itemid ?? 0;
                EasyAntiCheat.Server.Hydra.Client client = EACServer.GetClient(player.net.connection);
                PlayerUseWeapon eventParams = default(PlayerUseWeapon);
                eventParams.Position     = new EasyAntiCheat.Server.Cerberus.Vector3(networkPosition.x, networkPosition.y, networkPosition.z);
                eventParams.ViewRotation = new EasyAntiCheat.Server.Cerberus.Quaternion(networkRotation.w, networkRotation.x, networkRotation.y, networkRotation.z);
                eventParams.WeaponID     = weaponID;
                EACServer.playerTracker.LogPlayerUseWeapon(client, eventParams);
            }
        }
    }