Ejemplo n.º 1
0
        public override bool HitByProjectile(Projectile projectile, RealmTime time)
        {
            if (HasConditionEffect(ConditionEffects.Invincible))
                return false;
            bool projOwnerTest = false;
            if (ObjectDesc.Enemy)
                if (projectile.ProjectileOwner is Player)
                    projOwnerTest = true;
                else
                    projOwnerTest = false;
            else
                if ((projectile.ProjectileOwner is Enemy) && !(projectile.ProjectileOwner is NPC))
                    projOwnerTest = true;
                else
                    projOwnerTest = false;
            if (projectile.ProjectileOwner is NPC)
                if ((projectile.ProjectileOwner as NPC).ObjectDesc.Enemy != ObjectDesc.Enemy)
                    projOwnerTest = true;
            if (projOwnerTest &&
                !HasConditionEffect(ConditionEffects.Paused) &&
                !HasConditionEffect(ConditionEffects.Stasis))
            {
                var def = this.ObjectDesc.Defense;
                if (projectile.Descriptor.ArmorPiercing)
                    def = 0;
                int dmg = (int)StatsManager.GetDefenseDamage(this, projectile.Damage, def);
                if (!HasConditionEffect(ConditionEffects.Invulnerable))
                    HP -= dmg;
                ApplyConditionEffect(projectile.Descriptor.Effects);
                Owner.BroadcastPacket(new DamagePacket()
                {
                    TargetId = this.Id,
                    Effects = projectile.ConditionEffects,
                    Damage = (ushort)dmg,
                    Killed = HP < 0,
                    BulletId = projectile.ProjectileId,
                    ObjectId = projectile.ProjectileOwner.Self.Id
                }, projectile.ProjectileOwner is Player ? projectile.ProjectileOwner as Player : null);

                foreach (var i in CondBehaviors)
                    if ((i.Condition & BehaviorCondition.OnHit) != 0)
                        i.Behave(BehaviorCondition.OnHit, this, time, projectile);

                if (projectile.ProjectileOwner is Player) DamageCounter.HitBy(projectile.ProjectileOwner as Player, projectile, dmg);

                if (HP < 0)
                {
                    Entity chr = projectile.ProjectileOwner.Self;
                    string enName = chr.Name == "" ? null : chr.Name;
                    string killer = enName ??
                            chr.ObjectDesc.DisplayId ??
                            chr.ObjectDesc.ObjectId;
                    if (HP <= 0) Death(killer);
                }
                UpdateCount++;
                return true;
            }
            return false;
        }
 public void Hit(Projectile proj, Enemy enemy)
 {
     if (projs.Contains(proj))
     {
         projs.Remove(proj);
         stats.ShotsThatDamage++;
     }
 }
Ejemplo n.º 3
0
        public void HitBy(Player player, RealmTime time, Projectile projectile, int dmg)
        {
            int totalDmg;
            if (!hitters.TryGetValue(player, out totalDmg))
                totalDmg = 0;
            totalDmg += dmg;
            hitters[player] = totalDmg;

            LastProjectile = projectile;
            LastHitter = player;

            player.FameCounter.Hit(projectile, enemy);
        }
Ejemplo n.º 4
0
 public override bool HitByProjectile(Projectile projectile, RealmTime time)
 {
     if (!Vulnerable || !(projectile.ProjectileOwner is Player)) return true;
     var prevHp = HP;
     var dmg = (int)StatsManager.GetDefenseDamage(this, projectile.Damage, ObjectDesc.Defense);
     HP -= dmg;
     Owner.BroadcastPacket(new DamagePacket
     {
         TargetId = Id,
         Effects = 0,
         Damage = (ushort)dmg,
         Killed = !CheckHP(),
         BulletId = projectile.ProjectileId,
         ObjectId = projectile.ProjectileOwner.Self.Id
     }, HP < 0 && !IsOneHit(dmg, prevHp) ? null : projectile.ProjectileOwner as Player);
     return true;
 }
Ejemplo n.º 5
0
 public override bool HitByProjectile(Projectile projectile, RealmTime time)
 {
     if (Vulnerable && projectile.ProjectileOwner is Player)
     {
         var dmg = (int)StatsManager.GetDefenseDamage(this, projectile.Damage, ObjectDesc.Defense);
         HP -= dmg;
         Owner.BroadcastPacket(new DamagePacket()
         {
             TargetId = this.Id,
             Effects = 0,
             Damage = (ushort)dmg,
             Killed = !CheckHP(),
             BulletId = projectile.ProjectileId,
             ObjectId = projectile.ProjectileOwner.Self.Id
         }, null);
     }
     return true;
 }
        public override bool HitByProjectile(Projectile projectile, RealmTime time)
        {
            if (Static || !Vulnerable) return false;
            if (HasConditionEffect(ConditionEffectIndex.Invincible))
                return false;
            if (projectile.ProjectileOwner is Player &&
                !HasConditionEffect(ConditionEffectIndex.Paused) &&
                !HasConditionEffect(ConditionEffectIndex.Stasis))
            {
                int def = ObjectDesc.Defense;
                if (projectile.Descriptor.ArmorPiercing)
                    def = 0;
                int dmg = (int)StatsManager.GetDefenseDamage(this, projectile.Damage, def);
                if (!HasConditionEffect(ConditionEffectIndex.Invulnerable))
                    HP -= dmg;
                foreach (ConditionEffect effect in projectile.Descriptor.Effects)
                {
                    if (effect.Effect == ConditionEffectIndex.Stunned && ObjectDesc.StunImmune ||
                        effect.Effect == ConditionEffectIndex.Paralyzed && ObjectDesc.ParalyzedImmune ||
                        effect.Effect == ConditionEffectIndex.Dazed && ObjectDesc.DazedImmune)
                        continue;
                    ApplyConditionEffect(effect);
                }
                Owner.BroadcastPacket(new DamagePacket
                {
                    TargetId = Id,
                    Effects = projectile.ConditionEffects,
                    Damage = (ushort)dmg,
                    Killed = HP < 0,
                    BulletId = projectile.ProjectileId,
                    ObjectId = projectile.ProjectileOwner.Self.Id
                }, projectile.ProjectileOwner as Player);

                if (HP <= 0 && Owner != null)
                    Owner.LeaveWorld(this);

                UpdateCount++;
                return true;
            }
            return false;
        }
Ejemplo n.º 7
0
 protected Entity(short objType, bool interactive)
 {
     this.interactive = interactive;
     this.ObjectType = objType;
     Name = "";
     Size = 100;
     XmlDatas.ObjectDescs.TryGetValue(objType, out desc);
     BehaviorDb.ResolveBehavior(this);
     if (this is Portal)
     {
         this.Usable = true;
     }
     if (interactive)
     {
         posHistory = new Position[256];
         projectiles = new Projectile[256];
         effects = new int[EFFECT_COUNT];
     }
     if (objType == 0x072f)
         Usable = true;
 }
Ejemplo n.º 8
0
        public int Damage(Player from, RealmTime time, int dmg, bool noDef, bool fromProjectile, Projectile proj, params ConditionEffect[] effs)
        {
            if (stat) return 0;
            if (HasConditionEffect(ConditionEffects.Invincible))
                return 0;
            if (!HasConditionEffect(ConditionEffects.Paused) &&
                !HasConditionEffect(ConditionEffects.Stasis))
            {
                int def = Defense;
                if (noDef)
                    def = 0;
                dmg = (int) StatsManager.GetDefenseDamage(this, dmg, def);
                int effDmg = dmg;
                if (effDmg > HP)
                    effDmg = HP;
                if (!HasConditionEffect(ConditionEffects.Invulnerable))
                    HP -= dmg;
                ApplyConditionEffect(effs);
                Owner.BroadcastPacket(new DamagePacket
                {
                    TargetId = Id,
                    Effects = 0,
                    Damage = (ushort) dmg,
                    Killed = HP <= 0,
                    BulletId = 0,
                    ObjectId = from.Id
                }, fromProjectile ? from : null);

                counter.HitBy(from, time, proj, dmg);

                if (HP <= 0 && Owner != null)
                {
                    Death(time);
                }

                UpdateCount++;
                return effDmg;
            }
            return 0;
        }
Ejemplo n.º 9
0
 public override bool HitByProjectile(Projectile projectile, RealmTime time)
 {
     return false;
 }
Ejemplo n.º 10
0
        public override bool HitByProjectile(Projectile projectile, RealmTime time)
        {
            if (projectile.ProjectileOwner is Player ||
                HasConditionEffect(ConditionEffects.Paused) ||
                HasConditionEffect(ConditionEffects.Stasis) ||
                HasConditionEffect(ConditionEffects.Invincible))
                return false;

            /*Character pac;
            if (projectile.ProjectileOwner is Character)
                if ((pac = projectile.ProjectileOwner as Character).isNPC)
                    if (pac.ObjectDesc.Enemy != true)
                        return false;*/

            return base.HitByProjectile(projectile, time);
        }
Ejemplo n.º 11
0
        public override bool HitByProjectile(Projectile projectile, RealmTime time)
        {
            if (projectile.ProjectileOwner is Player ||
                HasConditionEffect(ConditionEffects.Paused) ||
                HasConditionEffect(ConditionEffects.Stasis) ||
                HasConditionEffect(ConditionEffects.Invincible))
                return false;

            var dmg = (int)statsMgr.GetDefenseDamage(projectile.Damage, projectile.Descriptor.ArmorPiercing);
            if (!HasConditionEffect(ConditionEffects.Invulnerable))
                HP -= dmg;
            ApplyConditionEffect(projectile.Descriptor.Effects);
            UpdateCount++;
            Owner.BroadcastPacket(new DamagePacket()
            {
                TargetId = this.Id,
                Effects = HasConditionEffect(ConditionEffects.Invincible) ? 0 : projectile.ConditionEffects,
                Damage = (ushort)dmg,
                Killed = HP <= 0,
                BulletId = projectile.ProjectileId,
                ObjectId = projectile.ProjectileOwner.Self.Id
            }, this);

            if (HP <= 0) Death(
                projectile.ProjectileOwner.Self.ObjectDesc.DisplayId ??
                projectile.ProjectileOwner.Self.ObjectDesc.ObjectId);

            return base.HitByProjectile(projectile, time);
        }
Ejemplo n.º 12
0
        public override bool HitByProjectile(Projectile projectile, RealmTime time)
        {
            if (stat) return false;
            if (HasConditionEffect(ConditionEffectIndex.Invincible))
                return false;
            if (projectile.ProjectileOwner is Player &&
                !HasConditionEffect(ConditionEffectIndex.Paused) &&
                !HasConditionEffect(ConditionEffectIndex.Stasis))
            {
                var prevHp = HP;
                var dmg = (int)StatsManager.GetDefenseDamage(this, projectile.Damage, projectile.Descriptor.ArmorPiercing ? 0 : ObjectDesc.Defense);
                if (!HasConditionEffect(ConditionEffectIndex.Invulnerable))
                    HP -= dmg;
                foreach (ConditionEffect effect in projectile.Descriptor.Effects.Where(effect => (effect.Effect != ConditionEffectIndex.Stunned || !ObjectDesc.StunImmune) && (effect.Effect != ConditionEffectIndex.Paralyzed || !ObjectDesc.ParalyzedImmune) && (effect.Effect != ConditionEffectIndex.Dazed || !ObjectDesc.DazedImmune)))
                    ApplyConditionEffect(effect);

                Owner.BroadcastPacket(new DamagePacket
                {
                    TargetId = Id,
                    Effects = projectile.ConditionEffects,
                    Damage = (ushort)dmg,
                    Killed = HP < 0,
                    BulletId = projectile.ProjectileId,
                    ObjectId = projectile.ProjectileOwner.Self.Id
                }, HP < 0 && !IsOneHit(dmg, prevHp) ? null : projectile.ProjectileOwner as Player);

                counter.HitBy(projectile.ProjectileOwner as Player, time, projectile, dmg);

                if (HP <= 0 && Owner != null)
                {
                    Death(time);
                }
                UpdateCount++;
                return true;
            }
            return false;
        }
Ejemplo n.º 13
0
 public void Shoot(Projectile proj)
 {
     stats.Shots++;
     projs.Add(proj);
 }
Ejemplo n.º 14
0
 public void RemoveProjectile(Projectile projectile)
 {
     if(projs.Contains(projectile))
         projs.Remove(projectile);
 }
Ejemplo n.º 15
0
        public override bool HitByProjectile(Projectile projectile, RealmTime time)
        {
            if (projectile.ProjectileOwner is Player ||
                HasConditionEffect(ConditionEffects.Paused) ||
                HasConditionEffect(ConditionEffects.Stasis) ||
                HasConditionEffect(ConditionEffects.Invincible))
                return false;

            return base.HitByProjectile(projectile, time);
        }
Ejemplo n.º 16
0
        public override bool HitByProjectile(Projectile projectile, RealmTime time)
        {
            if (stat) return false;
            if (HasConditionEffect(ConditionEffects.Invincible))
                return false;

            var player = projectile.ProjectileOwner is Player;
            var pet = projectile.ProjectileOwner.Self.isPet;

            if ((player || pet) &&
                !HasConditionEffect(ConditionEffects.Paused) &&
                !HasConditionEffect(ConditionEffects.Stasis))
            {
                var plr = pet ? projectile.ProjectileOwner.Self.PlayerOwner : projectile.ProjectileOwner as Player;

                var def = ObjectDesc.Defense;
                if (projectile.Descriptor.ArmorPiercing)
                    def = 0;
                var dmg = (int)StatsManager.GetDefenseDamage(this, projectile.Damage, def);
                if (!HasConditionEffect(ConditionEffects.Invulnerable))
                    HP -= dmg;
                ApplyConditionEffect(projectile.Descriptor.Effects);
                Owner.BroadcastPacket(new DamagePacket
                {
                    TargetId = Id,
                    Effects = projectile.ConditionEffects,
                    Damage = (ushort)dmg,
                    Killed = HP < 0,
                    BulletId = projectile.ProjectileId,
                    ObjectId = projectile.ProjectileOwner.Self.Id
                }, pet ? null : plr);

                foreach (var i in CondBehaviors)
                    if ((i.Condition & BehaviorCondition.OnHit) != 0)
                        i.Behave(BehaviorCondition.OnHit, this, time, projectile);
                counter.HitBy(plr, projectile, dmg);

                if (HP < 0)
                {
                    foreach (var i in CondBehaviors)
                        if ((i.Condition & BehaviorCondition.OnDeath) != 0)
                            i.Behave(BehaviorCondition.OnDeath, this, time, counter);
                    counter.Death();
                    if (Owner != null)
                        Owner.LeaveWorld(this);
                }
                UpdateCount++;
                return true;
            }
            return false;
        }
Ejemplo n.º 17
0
 public virtual bool HitByProjectile(Projectile projectile, RealmTime time)
 {
     //Console.WriteLine("HIT! " + Id);
     if (ObjectDesc == null)
         return true;
     else
         return ObjectDesc.OccupySquare || ObjectDesc.EnemyOccupySquare || ObjectDesc.FullOccupy;
 }
Ejemplo n.º 18
0
        public Projectile CreateProjectile(ProjectileDesc desc, short container, int dmg, long time, Position pos, float angle)
        {
            var ret = new Projectile(desc) //Assume only one
            {
                ProjectileOwner = this,
                ProjectileId = projectileId++,
                Container = container,
                Damage = dmg,

                BeginTime = time,
                BeginPos = pos,
                Angle = angle,

                X = pos.X,
                Y = pos.Y
            };
            if (projectiles[ret.ProjectileId] != null)
                projectiles[ret.ProjectileId].Destroy(true);
            projectiles[ret.ProjectileId] = ret;
            return ret;
        }
Ejemplo n.º 19
0
 public void HitBy(Character chr, Projectile projectile, int dmg)
 {
     LastProjectile = projectile;
     LastHitterChar = chr;
 }
Ejemplo n.º 20
0
        public void HitBy(NPC npc, Projectile projectile, int dmg)
        {
            int totalDmg;
            if (!NPChitters.TryGetValue(npc, out totalDmg))
                totalDmg = 0;
            totalDmg += dmg;
            NPChitters[npc] = totalDmg;

            LastProjectile = projectile;
            LastHitterNPC = npc;
            LastHitterChar = npc as Character;
        }
Ejemplo n.º 21
0
        public override bool HitByProjectile(Projectile projectile, RealmTime time)
        {
            if (stat) return false;
            if (HasConditionEffect(ConditionEffects.Invincible))
                return false;
            if (projectile.ProjectileOwner is Player &&
                !HasConditionEffect(ConditionEffects.Paused) &&
                !HasConditionEffect(ConditionEffects.Stasis))
            {
                var def = this.ObjectDesc.Defense;
                if (projectile.Descriptor.ArmorPiercing)
                    def = 0;
                int dmg = (int)StatsManager.GetDefenseDamage(this, projectile.Damage, def);
                if (!HasConditionEffect(ConditionEffects.Invulnerable))
                    HP -= dmg;
                ApplyConditionEffect(projectile.Descriptor.Effects);
                Owner.BroadcastPacket(new DamagePacket()
                {
                    TargetId = this.Id,
                    Effects = projectile.ConditionEffects,
                    Damage = (ushort)dmg,
                    Killed = HP < 0,
                    BulletId = projectile.ProjectileId,
                    ObjectId = projectile.ProjectileOwner.Self.Id
                }, projectile.ProjectileOwner as Player);

                counter.HitBy(projectile.ProjectileOwner as Player, time, projectile, dmg);

                if (HP < 0 && Owner != null)
                {
                    Death(time);
                }
                UpdateCount++;
                return true;
            }
            return false;
        }
Ejemplo n.º 22
0
        public void Hit(Projectile proj)
        {
            var dmg = (int) statsMgr.GetDefenseDamage(proj.Damage, proj.Descriptor.ArmorPiercing);
            if (!HasConditionEffect(ConditionEffects.Invulnerable))
                HP -= dmg;
            ApplyConditionEffect(proj.Descriptor.Effects);
            UpdateCount++;
            Owner.BroadcastPacket(new DamagePacket
            {
                TargetId = Id,
                Effects = HasConditionEffect(ConditionEffects.Invincible) ? 0 : proj.ConditionEffects,
                Damage = (ushort) dmg,
                Killed = HP <= 0,
                BulletId = proj.ProjectileId,
                ObjectId = proj.ProjectileOwner.Self.Id
            }, this);

            string killerName = proj.ProjectileOwner is Player
                ? proj.ProjectileOwner.Self.Name
                : (proj.ProjectileOwner.Self.ObjectDesc.DisplayId ?? proj.ProjectileOwner.Self.ObjectDesc.ObjectId);

            if (HP <= 0) Death(killerName);
        }
Ejemplo n.º 23
0
 public virtual void ProjectileHit(Projectile projectile, Entity target)
 {
 }
Ejemplo n.º 24
0
        public override bool HitByProjectile(Projectile projectile, RealmTime time)
        {
            if (stat) return false;
            if (HasConditionEffect(ConditionEffects.Invincible))
                return false;
            bool projOwnerTest = false;
            Character pac = null;
            if (projectile.ProjectileOwner is Player)
                projOwnerTest = true;
            if (projectile.ProjectileOwner is Enemy)
                if ((pac = projectile.ProjectileOwner as Enemy).isNPC)
                    if (pac.ObjectDesc.Enemy != ObjectDesc.Enemy)
                        projOwnerTest = true;
            if (projOwnerTest &&
                !HasConditionEffect(ConditionEffects.Paused) &&
                !HasConditionEffect(ConditionEffects.Stasis))
            {
                var def = this.ObjectDesc.Defense;
                if (projectile.Descriptor.ArmorPiercing)
                    def = 0;
                int dmg = (int)StatsManager.GetDefenseDamage(this, projectile.Damage, def);
                if (!HasConditionEffect(ConditionEffects.Invulnerable))
                    HP -= dmg;
                ApplyConditionEffect(projectile.Descriptor.Effects);
                Owner.BroadcastPacket(new DamagePacket()
                {
                    TargetId = this.Id,
                    Effects = projectile.ConditionEffects,
                    Damage = (ushort)dmg,
                    Killed = HP < 0,
                    BulletId = projectile.ProjectileId,
                    ObjectId = projectile.ProjectileOwner.Self.Id
                }, projectile.ProjectileOwner is Player ? projectile.ProjectileOwner as Player : null);

                foreach (var i in CondBehaviors)
                    if ((i.Condition & BehaviorCondition.OnHit) != 0)
                        i.Behave(BehaviorCondition.OnHit, this, time, projectile);

                if(projectile.ProjectileOwner is Player) counter.HitBy(projectile.ProjectileOwner as Player, projectile, dmg);
                else if(projectile.ProjectileOwner is NPC) counter.HitBy(projectile.ProjectileOwner as NPC, projectile, dmg);

                if (HP < 0)
                {
                    foreach (var i in CondBehaviors)
                        if ((i.Condition & BehaviorCondition.OnDeath) != 0)
                            i.Behave(BehaviorCondition.OnDeath, this, time, counter);
                    counter.Death();
                    if (Owner != null)
                        Owner.LeaveWorld(this);
                }
                UpdateCount++;
                return true;
            }
            return false;
        }