Esempio n. 1
0
        void OnRPC_ClProject(Message packet)
        {
            ProjectileShoot projectileShoot = ProjectileShoot.Deserialize(packet.read);

            if (projectileShoot.projectiles.Count > ItemOwner.Information.BaseProjectile.ProjectilesPerShot)
            {
                ConsoleSystem.Log($"projectiles.Count[{projectileShoot.projectiles.Count}] > ProjectilesPerShot[{ItemOwner.Information.BaseProjectile.ProjectilesPerShot}]");
                Release();
                return;
            }

            if (AmmoCount <= 0)
            {
                ConsoleSystem.Log($"AmmoCount[{AmmoCount}] <= 0");
                Release();
                return;
            }

            AmmoCount--;

            foreach (var projectile in projectileShoot.projectiles)
            {
                PlayerOwner.firedProjectiles.Add(projectile.projectileID, ItemOwner.Information);
            }
            base.SignalBroadcast(E_Signal.Attack, string.Empty, packet.connection);

            Release();

            void Release()
            {
                projectileShoot.Dispose();
                Pool.Free(ref projectileShoot);
            }
        }
Esempio n. 2
0
 private bool RPC_OnCLProject(ERPCNetworkType type, Message message)
 {
     using (ProjectileShoot projectileShoot = ProjectileShoot.Deserialize(message.read))
     {
         foreach (ProjectileShoot.Projectile projectile in projectileShoot.projectiles)
         {
             RangeAim.NoteFiredProjectile(projectile.projectileID, PrefabID, AmmoType);
         }
     }
     return(false);
 }
Esempio n. 3
0
        void OnRPC_CLProject(Message packet)
        {
            ProjectileShoot projectileShoot = ProjectileShoot.Deserialize(packet.read);

            foreach (var projectile in projectileShoot.projectiles)
            {
                PlayerOwner.firedProjectiles.Add(projectile.projectileID, ItemOwner.Information);
            }

            var container = ItemOwner.Container;

            container.RemoveItemFromContainer(ItemOwner);
            container.OnItemConainerUpdate();

            Release();

            void Release()
            {
                projectileShoot.Dispose();
                Pool.Free(ref projectileShoot);
            }
        }
Esempio n. 4
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);
            }
        }
    }
    private void CLProject(BaseEntity.RPCMessage msg)
    {
        BasePlayer basePlayer = msg.player;

        if (!this.VerifyClientAttack(basePlayer))
        {
            base.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
            return;
        }
        if (basePlayer == null)
        {
            return;
        }
        if (basePlayer.IsHeadUnderwater())
        {
            return;
        }
        if (!this.canThrowAsProjectile)
        {
            AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Not throwable (", base.ShortPrefabName, ")"));
            basePlayer.stats.combat.Log(this, "not_throwable");
            return;
        }
        Item item = this.GetItem();

        if (item == null)
        {
            AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Item not found (", base.ShortPrefabName, ")"));
            basePlayer.stats.combat.Log(this, "item_missing");
            return;
        }
        ItemModProjectile component = item.info.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;
        }
        ProjectileShoot projectileShoot = ProjectileShoot.Deserialize(msg.read);

        if (projectileShoot.projectiles.Count != 1)
        {
            AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Projectile count mismatch (", base.ShortPrefabName, ")"));
            basePlayer.stats.combat.Log(this, "count_mismatch");
            return;
        }
        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, item.info, item);
                Effect effect = new Effect();
                effect.Init(Effect.Type.Projectile, projectile.startPos, projectile.startVel, msg.connection);
                effect.scale        = 1f;
                effect.pooledString = component.projectileObject.resourcePath;
                effect.number       = projectile.seed;
                EffectNetwork.Send(effect);
            }
            else
            {
                AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Duplicate ID (", projectile.projectileID, ")"));
                basePlayer.stats.combat.Log(this, "duplicate_id");
            }
        }
        item.SetParent(null);
        Interface.CallHook("OnMeleeThrown", basePlayer, item);
        if (this.canAiHearIt)
        {
            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;
                        }
                    }
                }
            }
            if (basePlayer != null)
            {
                Sensation sensation = new Sensation()
                {
                    Type            = SensationType.ThrownWeapon,
                    Position        = basePlayer.transform.position,
                    Radius          = 50f,
                    DamagePotential = single,
                    InitiatorPlayer = basePlayer,
                    Initiator       = basePlayer
                };
                Sense.Stimulate(sensation);
            }
        }
    }
Esempio n. 6
0
    private void CLProject(BaseEntity.RPCMessage msg)
    {
        BasePlayer player = msg.player;

        if (!this.VerifyClientAttack(player))
        {
            this.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
        }
        else
        {
            if (Object.op_Equality((Object)player, (Object)null) || player.IsHeadUnderwater())
            {
                return;
            }
            if (!this.canThrowAsProjectile)
            {
                AntiHack.Log(player, AntiHackType.ProjectileHack, "Not throwable (" + this.ShortPrefabName + ")");
                player.stats.combat.Log((AttackEntity)this, "not_throwable");
            }
            else
            {
                Item pickupItem = this.GetItem();
                if (pickupItem == null)
                {
                    AntiHack.Log(player, AntiHackType.ProjectileHack, "Item not found (" + this.ShortPrefabName + ")");
                    player.stats.combat.Log((AttackEntity)this, "item_missing");
                }
                else
                {
                    ItemModProjectile component1 = (ItemModProjectile)((Component)pickupItem.info).GetComponent <ItemModProjectile>();
                    if (Object.op_Equality((Object)component1, (Object)null))
                    {
                        AntiHack.Log(player, AntiHackType.ProjectileHack, "Item mod not found (" + this.ShortPrefabName + ")");
                        player.stats.combat.Log((AttackEntity)this, "mod_missing");
                    }
                    else
                    {
                        ProjectileShoot projectileShoot = ProjectileShoot.Deserialize((Stream)msg.read);
                        if (((List <ProjectileShoot.Projectile>)projectileShoot.projectiles).Count != 1)
                        {
                            AntiHack.Log(player, AntiHackType.ProjectileHack, "Projectile count mismatch (" + this.ShortPrefabName + ")");
                            player.stats.combat.Log((AttackEntity)this, "count_mismatch");
                        }
                        else
                        {
                            player.CleanupExpiredProjectiles();
                            using (List <ProjectileShoot.Projectile> .Enumerator enumerator = ((List <ProjectileShoot.Projectile>)projectileShoot.projectiles).GetEnumerator())
                            {
                                while (enumerator.MoveNext())
                                {
                                    ProjectileShoot.Projectile current = enumerator.Current;
                                    if (player.HasFiredProjectile((int)current.projectileID))
                                    {
                                        AntiHack.Log(player, AntiHackType.ProjectileHack, "Duplicate ID (" + (object)(int)current.projectileID + ")");
                                        player.stats.combat.Log((AttackEntity)this, "duplicate_id");
                                    }
                                    else if (this.ValidateEyePos(player, (Vector3)current.startPos))
                                    {
                                        player.NoteFiredProjectile((int)current.projectileID, (Vector3)current.startPos, (Vector3)current.startVel, (AttackEntity)this, pickupItem.info, pickupItem);
                                        Effect effect = new Effect();
                                        effect.Init(Effect.Type.Projectile, (Vector3)current.startPos, (Vector3)current.startVel, msg.connection);
                                        effect.scale        = (__Null)1.0;
                                        effect.pooledString = component1.projectileObject.resourcePath;
                                        effect.number       = current.seed;
                                        EffectNetwork.Send(effect);
                                    }
                                }
                            }
                            pickupItem.SetParent((ItemContainer)null);
                            Interface.CallHook("OnMeleeThrown", (object)player, (object)pickupItem);
                            if (!this.canAiHearIt)
                            {
                                return;
                            }
                            float num = 0.0f;
                            if (component1.projectileObject != null)
                            {
                                GameObject gameObject = component1.projectileObject.Get();
                                if (Object.op_Inequality((Object)gameObject, (Object)null))
                                {
                                    Projectile component2 = (Projectile)gameObject.GetComponent <Projectile>();
                                    if (Object.op_Inequality((Object)component2, (Object)null))
                                    {
                                        foreach (DamageTypeEntry damageType in component2.damageTypes)
                                        {
                                            num += damageType.amount;
                                        }
                                    }
                                }
                            }
                            if (!Object.op_Inequality((Object)player, (Object)null))
                            {
                                return;
                            }
                            Sense.Stimulate(new Sensation()
                            {
                                Type            = SensationType.ThrownWeapon,
                                Position        = ((Component)player).get_transform().get_position(),
                                Radius          = 50f,
                                DamagePotential = num,
                                InitiatorPlayer = player,
                                Initiator       = (BaseEntity)player
                            });
                        }
                    }
                }
            }
        }
    }
Esempio n. 7
0
    private void CLProject(RPCMessage msg)
    {
        BasePlayer player = msg.player;

        if (!VerifyClientAttack(player))
        {
            SendNetworkUpdate();
        }
        else
        {
            if (player == null || player.IsHeadUnderwater())
            {
                return;
            }
            if (!canThrowAsProjectile)
            {
                AntiHack.Log(player, AntiHackType.ProjectileHack, "Not throwable (" + base.ShortPrefabName + ")");
                player.stats.combat.Log(this, "not_throwable");
                return;
            }
            Item item = GetItem();
            if (item == null)
            {
                AntiHack.Log(player, AntiHackType.ProjectileHack, "Item not found (" + base.ShortPrefabName + ")");
                player.stats.combat.Log(this, "item_missing");
                return;
            }
            ItemModProjectile component = item.info.GetComponent <ItemModProjectile>();
            if (component == null)
            {
                AntiHack.Log(player, AntiHackType.ProjectileHack, "Item mod not found (" + base.ShortPrefabName + ")");
                player.stats.combat.Log(this, "mod_missing");
                return;
            }
            ProjectileShoot projectileShoot = ProjectileShoot.Deserialize(msg.read);
            if (projectileShoot.projectiles.Count != 1)
            {
                AntiHack.Log(player, AntiHackType.ProjectileHack, "Projectile count mismatch (" + base.ShortPrefabName + ")");
                player.stats.combat.Log(this, "count_mismatch");
                return;
            }
            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, item.info, item);
                    Effect effect = new Effect();
                    effect.Init(Effect.Type.Projectile, projectile.startPos, projectile.startVel, msg.connection);
                    effect.scale        = 1f;
                    effect.pooledString = component.projectileObject.resourcePath;
                    effect.number       = projectile.seed;
                    EffectNetwork.Send(effect);
                }
            }
            projectileShoot?.Dispose();
            item.SetParent(null);
            Interface.CallHook("OnMeleeThrown", player, item);
            if (!canAiHearIt)
            {
                return;
            }
            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;
                        }
                    }
                }
            }
            if (player != null)
            {
                Sensation sensation = default(Sensation);
                sensation.Type            = SensationType.ThrownWeapon;
                sensation.Position        = player.transform.position;
                sensation.Radius          = 50f;
                sensation.DamagePotential = num;
                sensation.InitiatorPlayer = player;
                sensation.Initiator       = player;
                Sense.Stimulate(sensation);
            }
        }
    }
Esempio n. 8
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);
            }
        }
    }