public override void Explode()
 {
     if ((double)this.WaterFactor() >= 0.5)
     {
         this.FinishUp();
     }
     else
     {
         if (this.IsOn())
         {
             return;
         }
         this.Invoke(new Action(this.FinishUp), this.smokeDuration);
         this.SetFlag(BaseEntity.Flags.On, true, false, true);
         this.SetFlag(BaseEntity.Flags.Open, true, false, true);
         this.InvalidateNetworkCache();
         this.SendNetworkUpdateImmediate(false);
         SmokeGrenade.activeGrenades.Add(this);
         Sense.Stimulate(new Sensation()
         {
             Type            = SensationType.Explosion,
             Position        = ((Component)this.creatorEntity).get_transform().get_position(),
             Radius          = this.explosionRadius * 17f,
             DamagePotential = 0.0f,
             InitiatorPlayer = this.creatorEntity as BasePlayer,
             Initiator       = this.creatorEntity
         });
     }
 }
    public override void Explode()
    {
        if (this.WaterFactor() >= 0.5f)
        {
            this.FinishUp();
            return;
        }
        if (base.IsOn())
        {
            return;
        }
        base.Invoke(new Action(this.FinishUp), this.smokeDuration);
        base.SetFlag(BaseEntity.Flags.On, true, false, true);
        base.SetFlag(BaseEntity.Flags.Open, true, false, true);
        base.InvalidateNetworkCache();
        base.SendNetworkUpdateImmediate(false);
        SmokeGrenade.activeGrenades.Add(this);
        Sensation sensation = new Sensation()
        {
            Type            = SensationType.Explosion,
            Position        = this.creatorEntity.transform.position,
            Radius          = this.explosionRadius * 17f,
            DamagePotential = 0f,
            InitiatorPlayer = this.creatorEntity as BasePlayer,
            Initiator       = this.creatorEntity
        };

        Sense.Stimulate(sensation);
    }
    private void DoThrow(BaseEntity.RPCMessage msg)
    {
        if (!this.HasItemAmount() || this.HasAttackCooldown())
        {
            return;
        }
        Vector3 vector3_1  = msg.read.Vector3();
        Vector3 vector3_2  = msg.read.Vector3();
        Vector3 normalized = ((Vector3) ref vector3_2).get_normalized();
        float   num1       = Mathf.Clamp01(msg.read.Float());

        if (msg.player.isMounted || msg.player.HasParent())
        {
            vector3_1 = msg.player.eyes.position;
        }
        else if (!this.ValidateEyePos(msg.player, vector3_1))
        {
            return;
        }
        BaseEntity entity = GameManager.server.CreateEntity(this.prefabToThrow.resourcePath, vector3_1, Quaternion.LookRotation(Vector3.op_Equality(this.overrideAngle, Vector3.get_zero()) ? Vector3.op_UnaryNegation(normalized) : this.overrideAngle), true);

        if (Object.op_Equality((Object)entity, (Object)null))
        {
            return;
        }
        entity.creatorEntity = (BaseEntity)msg.player;
        entity.SetVelocity(Vector3.op_Addition(Vector3.op_Addition(msg.player.GetInheritedThrowVelocity(), Vector3.op_Multiply(Vector3.op_Multiply(normalized, this.maxThrowVelocity), num1)), Vector3.op_Multiply(msg.player.estimatedVelocity, 0.5f)));
        if ((double)this.tumbleVelocity > 0.0)
        {
            entity.SetAngularVelocity(Vector3.op_Multiply(new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f)), this.tumbleVelocity));
        }
        entity.Spawn();
        this.StartAttackCooldown(this.repeatDelay);
        Interface.CallHook("OnExplosiveThrown", (object)msg.player, (object)entity);
        this.UseItemAmount(1);
        BasePlayer player = msg.player;

        if (!Object.op_Inequality((Object)player, (Object)null))
        {
            return;
        }
        TimedExplosive timedExplosive = entity as TimedExplosive;

        if (Object.op_Inequality((Object)timedExplosive, (Object)null))
        {
            float num2 = 0.0f;
            foreach (DamageTypeEntry damageType in timedExplosive.damageTypes)
            {
                num2 += damageType.amount;
            }
            Sense.Stimulate(new Sensation()
            {
                Type            = SensationType.ThrownWeapon,
                Position        = ((Component)player).get_transform().get_position(),
                Radius          = 50f,
                DamagePotential = num2,
                InitiatorPlayer = player,
                Initiator       = (BaseEntity)player,
                UsedEntity      = (BaseEntity)timedExplosive
            });
        }
        else
        {
            Sense.Stimulate(new Sensation()
            {
                Type            = SensationType.ThrownWeapon,
                Position        = ((Component)player).get_transform().get_position(),
                Radius          = 50f,
                DamagePotential = 0.0f,
                InitiatorPlayer = player,
                Initiator       = (BaseEntity)player,
                UsedEntity      = (BaseEntity)this
            });
        }
    }
    public void ServerThrow(Vector3 targetPosition)
    {
        if (this.isClient || !this.HasItemAmount() || this.HasAttackCooldown())
        {
            return;
        }
        BasePlayer ownerPlayer = this.GetOwnerPlayer();

        if (Object.op_Equality((Object)ownerPlayer, (Object)null))
        {
            return;
        }
        Vector3 position = ownerPlayer.eyes.position;
        Vector3 vector3  = ownerPlayer.eyes.BodyForward();
        float   num1     = 1f;

        this.SignalBroadcast(BaseEntity.Signal.Throw, string.Empty, (Connection)null);
        BaseEntity entity = GameManager.server.CreateEntity(this.prefabToThrow.resourcePath, position, Quaternion.LookRotation(Vector3.op_Equality(this.overrideAngle, Vector3.get_zero()) ? Vector3.op_UnaryNegation(vector3) : this.overrideAngle), true);

        if (Object.op_Equality((Object)entity, (Object)null))
        {
            return;
        }
        entity.creatorEntity = (BaseEntity)ownerPlayer;
        Vector3 aimDir = Vector3.op_Addition(vector3, Quaternion.op_Multiply(Quaternion.AngleAxis(10f, Vector3.get_right()), Vector3.get_up()));
        float   f      = this.GetThrowVelocity(position, targetPosition, aimDir);

        if (float.IsNaN(f))
        {
            aimDir = Vector3.op_Addition(vector3, Quaternion.op_Multiply(Quaternion.AngleAxis(20f, Vector3.get_right()), Vector3.get_up()));
            f      = this.GetThrowVelocity(position, targetPosition, aimDir);
            if (float.IsNaN(f))
            {
                f = 5f;
            }
        }
        entity.SetVelocity(Vector3.op_Multiply(Vector3.op_Multiply(aimDir, f), num1));
        if ((double)this.tumbleVelocity > 0.0)
        {
            entity.SetAngularVelocity(Vector3.op_Multiply(new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f)), this.tumbleVelocity));
        }
        entity.Spawn();
        this.StartAttackCooldown(this.repeatDelay);
        this.UseItemAmount(1);
        TimedExplosive timedExplosive = entity as TimedExplosive;

        if (Object.op_Inequality((Object)timedExplosive, (Object)null))
        {
            float num2 = 0.0f;
            foreach (DamageTypeEntry damageType in timedExplosive.damageTypes)
            {
                num2 += damageType.amount;
            }
            Sense.Stimulate(new Sensation()
            {
                Type            = SensationType.ThrownWeapon,
                Position        = ((Component)ownerPlayer).get_transform().get_position(),
                Radius          = 50f,
                DamagePotential = num2,
                InitiatorPlayer = ownerPlayer,
                Initiator       = (BaseEntity)ownerPlayer,
                UsedEntity      = (BaseEntity)timedExplosive
            });
        }
        else
        {
            Sense.Stimulate(new Sensation()
            {
                Type            = SensationType.ThrownWeapon,
                Position        = ((Component)ownerPlayer).get_transform().get_position(),
                Radius          = 50f,
                DamagePotential = 0.0f,
                InitiatorPlayer = ownerPlayer,
                Initiator       = (BaseEntity)ownerPlayer,
                UsedEntity      = (BaseEntity)this
            });
        }
    }
示例#5
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);
            }
        }
    }
示例#6
0
    private void DoThrow(BaseEntity.RPCMessage msg)
    {
        Sensation sensation;

        if (!base.HasItemAmount() || base.HasAttackCooldown())
        {
            return;
        }
        Vector3 vector3  = msg.read.Vector3();
        Vector3 vector31 = msg.read.Vector3().normalized;
        float   single   = Mathf.Clamp01(msg.read.Float());

        if (msg.player.isMounted || msg.player.HasParent())
        {
            vector3 = msg.player.eyes.position;
        }
        else if (!base.ValidateEyePos(msg.player, vector3))
        {
            return;
        }
        BaseEntity baseEntity = GameManager.server.CreateEntity(this.prefabToThrow.resourcePath, vector3, Quaternion.LookRotation((this.overrideAngle == Vector3.zero ? -vector31 : this.overrideAngle)), true);

        if (baseEntity == null)
        {
            return;
        }
        baseEntity.creatorEntity = msg.player;
        baseEntity.SetVelocity((msg.player.GetInheritedThrowVelocity() + ((vector31 * this.maxThrowVelocity) * single)) + (msg.player.estimatedVelocity * 0.5f));
        if (this.tumbleVelocity > 0f)
        {
            baseEntity.SetAngularVelocity(new Vector3(UnityEngine.Random.Range(-1f, 1f), UnityEngine.Random.Range(-1f, 1f), UnityEngine.Random.Range(-1f, 1f)) * this.tumbleVelocity);
        }
        baseEntity.Spawn();
        base.StartAttackCooldown(this.repeatDelay);
        Interface.CallHook("OnExplosiveThrown", msg.player, baseEntity, this);
        base.UseItemAmount(1);
        BasePlayer basePlayer = msg.player;

        if (basePlayer != null)
        {
            TimedExplosive timedExplosive = baseEntity as TimedExplosive;
            if (timedExplosive != null)
            {
                float single1 = 0f;
                foreach (DamageTypeEntry damageType in timedExplosive.damageTypes)
                {
                    single1 += damageType.amount;
                }
                sensation = new Sensation()
                {
                    Type            = SensationType.ThrownWeapon,
                    Position        = basePlayer.transform.position,
                    Radius          = 50f,
                    DamagePotential = single1,
                    InitiatorPlayer = basePlayer,
                    Initiator       = basePlayer,
                    UsedEntity      = timedExplosive
                };
                Sense.Stimulate(sensation);
                return;
            }
            sensation = new Sensation()
            {
                Type            = SensationType.ThrownWeapon,
                Position        = basePlayer.transform.position,
                Radius          = 50f,
                DamagePotential = 0f,
                InitiatorPlayer = basePlayer,
                Initiator       = basePlayer,
                UsedEntity      = this
            };
            Sense.Stimulate(sensation);
        }
    }
示例#7
0
    public void ServerThrow(Vector3 targetPosition)
    {
        Sensation sensation;

        if (base.isClient)
        {
            return;
        }
        if (!base.HasItemAmount() || base.HasAttackCooldown())
        {
            return;
        }
        BasePlayer ownerPlayer = base.GetOwnerPlayer();

        if (ownerPlayer == null)
        {
            return;
        }
        Vector3 vector3  = ownerPlayer.eyes.position;
        Vector3 vector31 = ownerPlayer.eyes.BodyForward();
        float   single   = 1f;

        base.SignalBroadcast(BaseEntity.Signal.Throw, string.Empty, null);
        BaseEntity baseEntity = GameManager.server.CreateEntity(this.prefabToThrow.resourcePath, vector3, Quaternion.LookRotation((this.overrideAngle == Vector3.zero ? -vector31 : this.overrideAngle)), true);

        if (baseEntity == null)
        {
            return;
        }
        baseEntity.creatorEntity = ownerPlayer;
        Vector3 vector32      = vector31 + (Quaternion.AngleAxis(10f, Vector3.right) * Vector3.up);
        float   throwVelocity = this.GetThrowVelocity(vector3, targetPosition, vector32);

        if (float.IsNaN(throwVelocity))
        {
            vector32      = vector31 + (Quaternion.AngleAxis(20f, Vector3.right) * Vector3.up);
            throwVelocity = this.GetThrowVelocity(vector3, targetPosition, vector32);
            if (float.IsNaN(throwVelocity))
            {
                throwVelocity = 5f;
            }
        }
        baseEntity.SetVelocity((vector32 * throwVelocity) * single);
        if (this.tumbleVelocity > 0f)
        {
            baseEntity.SetAngularVelocity(new Vector3(UnityEngine.Random.Range(-1f, 1f), UnityEngine.Random.Range(-1f, 1f), UnityEngine.Random.Range(-1f, 1f)) * this.tumbleVelocity);
        }
        baseEntity.Spawn();
        base.StartAttackCooldown(this.repeatDelay);
        base.UseItemAmount(1);
        TimedExplosive timedExplosive = baseEntity as TimedExplosive;

        if (timedExplosive == null)
        {
            sensation = new Sensation()
            {
                Type            = SensationType.ThrownWeapon,
                Position        = ownerPlayer.transform.position,
                Radius          = 50f,
                DamagePotential = 0f,
                InitiatorPlayer = ownerPlayer,
                Initiator       = ownerPlayer,
                UsedEntity      = this
            };
            Sense.Stimulate(sensation);
            return;
        }
        float single1 = 0f;

        foreach (DamageTypeEntry damageType in timedExplosive.damageTypes)
        {
            single1 += damageType.amount;
        }
        sensation = new Sensation()
        {
            Type            = SensationType.ThrownWeapon,
            Position        = ownerPlayer.transform.position,
            Radius          = 50f,
            DamagePotential = single1,
            InitiatorPlayer = ownerPlayer,
            Initiator       = ownerPlayer,
            UsedEntity      = timedExplosive
        };
        Sense.Stimulate(sensation);
    }
 public virtual void Explode()
 {
     ((Collider)((Component)this).GetComponent <Collider>()).set_enabled(false);
     if (this.explosionEffect.isValid)
     {
         Effect.server.Run(this.explosionEffect.resourcePath, this.PivotPoint(), this.explosionUsesForward ? ((Component)this).get_transform().get_forward() : Vector3.get_up(), (Connection)null, true);
     }
     if (this.damageTypes.Count > 0)
     {
         if (this.onlyDamageParent)
         {
             DamageUtil.RadiusDamage(this.creatorEntity, this.LookupPrefab(), this.CenterPoint(), this.minExplosionRadius, this.explosionRadius, this.damageTypes, 141568, true);
             BaseEntity       parentEntity = this.GetParentEntity();
             BaseCombatEntity baseCombatEntity;
             for (baseCombatEntity = parentEntity as BaseCombatEntity; Object.op_Equality((Object)baseCombatEntity, (Object)null) && Object.op_Inequality((Object)parentEntity, (Object)null) && parentEntity.HasParent(); baseCombatEntity = parentEntity as BaseCombatEntity)
             {
                 parentEntity = parentEntity.GetParentEntity();
             }
             if (Object.op_Implicit((Object)baseCombatEntity))
             {
                 HitInfo info = new HitInfo();
                 info.Initiator    = this.creatorEntity;
                 info.WeaponPrefab = this.LookupPrefab();
                 info.damageTypes.Add(this.damageTypes);
                 baseCombatEntity.Hurt(info);
             }
             if (Object.op_Inequality((Object)this.creatorEntity, (Object)null) && this.damageTypes != null)
             {
                 float num = 0.0f;
                 foreach (DamageTypeEntry damageType in this.damageTypes)
                 {
                     num += damageType.amount;
                 }
                 Sense.Stimulate(new Sensation()
                 {
                     Type            = SensationType.Explosion,
                     Position        = ((Component)this.creatorEntity).get_transform().get_position(),
                     Radius          = this.explosionRadius * 17f,
                     DamagePotential = num,
                     InitiatorPlayer = this.creatorEntity as BasePlayer,
                     Initiator       = this.creatorEntity
                 });
             }
         }
         else
         {
             DamageUtil.RadiusDamage(this.creatorEntity, this.LookupPrefab(), this.CenterPoint(), this.minExplosionRadius, this.explosionRadius, this.damageTypes, 1075980544, true);
             if (Object.op_Inequality((Object)this.creatorEntity, (Object)null) && this.damageTypes != null)
             {
                 float num = 0.0f;
                 foreach (DamageTypeEntry damageType in this.damageTypes)
                 {
                     num += damageType.amount;
                 }
                 Sense.Stimulate(new Sensation()
                 {
                     Type            = SensationType.Explosion,
                     Position        = ((Component)this.creatorEntity).get_transform().get_position(),
                     Radius          = this.explosionRadius * 17f,
                     DamagePotential = num,
                     InitiatorPlayer = this.creatorEntity as BasePlayer,
                     Initiator       = this.creatorEntity
                 });
             }
         }
     }
     if (this.IsDestroyed)
     {
         return;
     }
     this.Kill(BaseNetworkable.DestroyMode.None);
 }
    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);
            }
        }
    }
示例#10
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
                            });
                        }
                    }
                }
            }
        }
    }
示例#11
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);
            }
        }
    }
示例#12
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);
            }
        }
    }
示例#13
0
    public virtual void Explode()
    {
        BaseCombatEntity i;
        Sensation        sensation;

        base.GetComponent <Collider>().enabled = false;
        if (this.explosionEffect.isValid)
        {
            Effect.server.Run(this.explosionEffect.resourcePath, base.PivotPoint(), (this.explosionUsesForward ? base.transform.forward : Vector3.up), null, true);
        }
        if (this.damageTypes.Count > 0)
        {
            if (!this.onlyDamageParent)
            {
                DamageUtil.RadiusDamage(this.creatorEntity, base.LookupPrefab(), base.CenterPoint(), this.minExplosionRadius, this.explosionRadius, this.damageTypes, 1075980544, true);
                if (this.creatorEntity != null && this.damageTypes != null)
                {
                    float single = 0f;
                    foreach (DamageTypeEntry damageType in this.damageTypes)
                    {
                        single += damageType.amount;
                    }
                    sensation = new Sensation()
                    {
                        Type            = SensationType.Explosion,
                        Position        = this.creatorEntity.transform.position,
                        Radius          = this.explosionRadius * 17f,
                        DamagePotential = single,
                        InitiatorPlayer = this.creatorEntity as BasePlayer,
                        Initiator       = this.creatorEntity
                    };
                    Sense.Stimulate(sensation);
                }
            }
            else
            {
                DamageUtil.RadiusDamage(this.creatorEntity, base.LookupPrefab(), base.CenterPoint(), this.minExplosionRadius, this.explosionRadius, this.damageTypes, 141568, true);
                BaseEntity parentEntity = base.GetParentEntity();
                for (i = parentEntity as BaseCombatEntity; i == null && parentEntity != null && parentEntity.HasParent(); i = parentEntity as BaseCombatEntity)
                {
                    parentEntity = parentEntity.GetParentEntity();
                }
                if (i)
                {
                    HitInfo hitInfo = new HitInfo()
                    {
                        Initiator    = this.creatorEntity,
                        WeaponPrefab = base.LookupPrefab()
                    };
                    hitInfo.damageTypes.Add(this.damageTypes);
                    i.Hurt(hitInfo);
                }
                if (this.creatorEntity != null && this.damageTypes != null)
                {
                    float single1 = 0f;
                    foreach (DamageTypeEntry damageTypeEntry in this.damageTypes)
                    {
                        single1 += damageTypeEntry.amount;
                    }
                    sensation = new Sensation()
                    {
                        Type            = SensationType.Explosion,
                        Position        = this.creatorEntity.transform.position,
                        Radius          = this.explosionRadius * 17f,
                        DamagePotential = single1,
                        InitiatorPlayer = this.creatorEntity as BasePlayer,
                        Initiator       = this.creatorEntity
                    };
                    Sense.Stimulate(sensation);
                }
            }
        }
        if (base.IsDestroyed)
        {
            return;
        }
        base.Kill(BaseNetworkable.DestroyMode.Gib);
    }