Exemplo n.º 1
0
        public void VisibulletHit(VisibulletPacket pkt)
        {
            //Possible bug I can see right now:
            //  If enemy does not exist, no condition effects can be applied.
            if (pkt.EnemyId == -2)
            {
                HP = 0;
                UpdateCount++;
                Death("Unknown");
                return;
            }
            var enemy  = Owner.GetEntity(pkt.EnemyId);
            var killer = "Unknown";

            if (!HasConditionEffect(ConditionEffects.Invulnerable))
            {
                HP -= pkt.Damage;
            }
            ConditionEffects?ceffects = null;

            if (enemy != null)
            {
                killer = enemy.ObjectDesc.DisplayId ??
                         enemy.ObjectDesc.ObjectId;
                var proj = (enemy as IProjectileOwner).Projectiles[pkt.BulletId];
                if (proj != null)
                {
                    if (!HasConditionEffect(ConditionEffects.Invincible))
                    {
                        ceffects = proj.ConditionEffects;
                    }
                    if (!HasConditionEffect(ConditionEffects.Blessed))
                    {
                        ApplyConditionEffect(proj.Descriptor.Effects);
                    }
                }
            }
            UpdateCount++;

            Owner.BroadcastPacket(new DamagePacket
            {
                TargetId = Id,
                Effects  = (!ceffects.HasValue) ? 0 : (ConditionEffects)ceffects,
                Damage   = (ushort)pkt.Damage,
                Killed   = HP <= 0,
                BulletId = pkt.BulletId,
                ObjectId = pkt.EnemyId
            }, this);

            if (HP <= 0)
            {
                Death(killer);
            }
        }
Exemplo n.º 2
0
        public void VisibulletHit(VisibulletPacket pkt)
        {
            if (pkt.EnemyId == -2)
            {
                HP = 0;
                UpdateCount++;
                return;
            }
            Entity enemy  = Owner.GetEntity(pkt.EnemyId);
            string killer = "[object _-0Cm]";

            if (!HasConditionEffect(ConditionEffects.Invulnerable))
            {
                HP -= pkt.Damage;
            }
            ConditionEffects?ceffects = null;

            if (enemy != null)
            {
                killer = enemy.ObjectDesc.DisplayId ??
                         enemy.ObjectDesc.ObjectId;
                Projectile proj = (enemy as IProjectileOwner).Projectiles[pkt.BulletId];
                if (proj != null)
                {
                    if (!HasConditionEffect(ConditionEffects.Invincible))
                    {
                        ceffects = proj.ConditionEffects;
                    }
                    ApplyConditionEffect(proj.Descriptor.Effects);
                }
            }
            UpdateCount++;
            Owner.BroadcastPacket(new DamagePacket()
            {
                TargetId = this.Id,
                Effects  = (!ceffects.HasValue) ? 0 : (ConditionEffects)ceffects,
                Damage   = (ushort)pkt.Damage,
                Killed   = HP <= 0,
                BulletId = pkt.BulletId,
                ObjectId = pkt.EnemyId
            }, this);
        }