Beispiel #1
0
        public ItemObject(MapObject dropper, uint gold, Point manuallocation)
        {
            ExpireTime = Envir.Time + Settings.ItemTimeOut * Settings.Minute;

            Gold = gold;

            CurrentMap = dropper.CurrentMap;
            CurrentLocation = manuallocation;
        }
Beispiel #2
0
 public Buff(BinaryReader reader)
 {
     Type = (BuffType)reader.ReadByte();
     Caster = null;
     Visible = reader.ReadBoolean();
     ObjectID = reader.ReadUInt32();
     ExpireTime = reader.ReadInt64();
     Value = reader.ReadInt32();
     Infinite = reader.ReadBoolean();
 }
Beispiel #3
0
 public Buff(Buff buff)
 {
     Type = buff.Type;
     Caster = buff.Caster;
     Visible = buff.Visible;
     ObjectID = buff.ObjectID;
     ExpireTime = buff.ExpireTime;
     Value = buff.Value;
     Infinite = buff.Infinite;
 }
Beispiel #4
0
        public ItemObject(MapObject dropper, UserItem item, Point manualpoint)
        {
            ExpireTime = Envir.Time + Settings.ItemTimeOut * Settings.Minute;

            Item = item;
            if (Item.IsAdded)
                NameColour = Color.Cyan;

            CurrentMap = dropper.CurrentMap;
            CurrentLocation = manualpoint;
        }
Beispiel #5
0
        public ItemObject(MapObject dropper, UserItem item, bool DeathDrop = false)
        {
            if (DeathDrop)//player dropped it when he died: allow for time to run back and pickup his drops
                ExpireTime = Envir.Time + Settings.PlayerDiedItemTimeOut * Settings.Minute;
            else
                ExpireTime = Envir.Time + Settings.ItemTimeOut * Settings.Minute;

            Item = item;
            if (Item.IsAdded)
                NameColour = Color.Cyan;

            CurrentMap = dropper.CurrentMap;
            CurrentLocation = dropper.CurrentLocation;
        }
Beispiel #6
0
        public Buff(BinaryReader reader)
        {
            Type = (BuffType)reader.ReadByte();
            Caster = null;
            Visible = reader.ReadBoolean();
            ObjectID = reader.ReadUInt32();
            ExpireTime = reader.ReadInt64();

            if (Envir.LoadVersion < 56)
            {
                Values = new int[] { reader.ReadInt32() };
            }
            else
            {
                Values = new int[reader.ReadInt32()];

                for (int i = 0; i < Values.Length; i++)
                {
                    Values[i] = reader.ReadInt32();
                }
            }

            Infinite = reader.ReadBoolean();
        }
Beispiel #7
0
 public abstract void ApplyPoison(Poison p, MapObject Caster = null, bool NoResist = false);
Beispiel #8
0
        public bool IsMember(MapObject member)
        {
            if (member == this) return true;
            if (GroupMembers == null || member == null) return false;

            for (int i = 0; i < GroupMembers.Count; i++)
                if (GroupMembers[i] == member) return true;

            return false;
        }
        public void ArcherSummon(UserMagic magic, MapObject target, Point location)
        {
            if (target != null && target.IsAttackTarget(this))
                location = target.CurrentLocation;
            if (!CanFly(location)) return;

            uint duration = (uint)((magic.Level * 5 + 10) * 1000);
            int value = (int)duration;
            int delay = Functions.MaxDistance(CurrentLocation, location) * 50 + 500; //50 MS per Step

            DelayedAction action = new DelayedAction(DelayedType.Magic, Envir.Time + delay, magic, value, location, target);
            ActionList.Add(action);
        }
        public override void ApplyPoison(Poison p, MapObject Caster = null, bool NoResist = false, bool ignoreDefence = true)
        {
            if ((Caster != null) && (!NoResist))
                if (((Caster.Race != ObjectType.Player) || Settings.PvpCanResistPoison) && (Envir.Random.Next(Settings.PoisonResistWeight) < PoisonResist))
                    return;

            if (!ignoreDefence && (p.PType == PoisonType.Green))
            {
                int armour = GetAttackPower(MinMAC, MaxMAC);

                if (p.Value > armour)
                    p.PType = PoisonType.None;
                else
                    p.Value -= armour;
            }

            if (p.Owner != null && p.Owner.Race == ObjectType.Player && Envir.Time > BrownTime && PKPoints < 200)
                p.Owner.BrownTime = Envir.Time + Settings.Minute;
            if ((p.PType == PoisonType.Green) || (p.PType == PoisonType.Red)) p.Duration = Math.Max(0, p.Duration - PoisonRecovery);
            if (p.Duration == 0) return;


            for (int i = 0; i < PoisonList.Count; i++)
            {
                if (PoisonList[i].PType != p.PType) continue;
                if ((PoisonList[i].PType == PoisonType.Green) && (PoisonList[i].Value > p.Value)) return;//cant cast weak poison to cancel out strong poison
                if ((PoisonList[i].PType != PoisonType.Green) && ((PoisonList[i].Duration - PoisonList[i].Time) > p.Duration)) return;//cant cast 1 second poison to make a 1minute poison go away!
                if ((PoisonList[i].PType == PoisonType.Frozen) || (PoisonList[i].PType == PoisonType.Slow) || (PoisonList[i].PType == PoisonType.Paralysis) || (PoisonList[i].PType == PoisonType.LRParalysis)) return;//prevents mobs from being perma frozen/slowed
                if (p.PType == PoisonType.DelayedExplosion) return;
                ReceiveChat("You have been poisoned.", ChatType.System2);
                PoisonList[i] = p;
                return;
            }

            if (p.PType == PoisonType.DelayedExplosion)
            {
                ExplosionInflictedTime = Envir.Time + 4000;
                Enqueue(new S.ObjectEffect { ObjectID = ObjectID, Effect = SpellEffect.DelayedExplosion });
                Broadcast(new S.ObjectEffect { ObjectID = ObjectID, Effect = SpellEffect.DelayedExplosion });
                ReceiveChat("You are a walking explosive.", ChatType.System);
            }
            else
                ReceiveChat("You have been poisoned.", ChatType.System2);

            PoisonList.Add(p);
        }
Beispiel #11
0
        protected virtual void FindTarget()
        {
            Map Current = CurrentMap;

            for (int d = 0; d <= ViewRange; d++)
            {
                for (int y = CurrentLocation.Y - d; y <= CurrentLocation.Y + d; y++)
                {
                    if (y < 0)
                    {
                        continue;
                    }
                    if (y >= Current.Height)
                    {
                        break;
                    }

                    for (int x = CurrentLocation.X - d; x <= CurrentLocation.X + d; x += Math.Abs(y - CurrentLocation.Y) == d ? 1 : d * 2)
                    {
                        if (x < 0)
                        {
                            continue;
                        }
                        if (x >= Current.Width)
                        {
                            break;
                        }
                        Cell cell = Current.Cells[x, y];
                        if (cell.Objects == null || !cell.Valid)
                        {
                            continue;
                        }
                        for (int i = 0; i < cell.Objects.Count; i++)
                        {
                            MapObject ob = cell.Objects[i];
                            switch (ob.Race)
                            {
                            case ObjectType.Monster:
                            case ObjectType.Hero:
                                if (ob is TownArcher)
                                {
                                    continue;
                                }
                                if (!ob.IsAttackTarget(Owner))
                                {
                                    continue;
                                }
                                if (ob.Hidden && (!CoolEye || Level < ob.Level))
                                {
                                    continue;
                                }
                                if (ob.Master != null && Target != ob)
                                {
                                    continue;
                                }
                                if (Owner.Info.HeroBehaviour == HeroBehaviour.CounterAttack && ob.Target != this && ob.Target != Owner)
                                {
                                    continue;
                                }

                                Target = ob;
                                return;

                            case ObjectType.Player:
                                PlayerObject playerob = (PlayerObject)ob;
                                if (!ob.IsAttackTarget(Owner))
                                {
                                    continue;
                                }
                                if (playerob.GMGameMaster || ob.Hidden && (!CoolEye || Level < ob.Level))
                                {
                                    continue;
                                }
                                if (Target != ob && Owner.LastHitter != ob && ob.LastHitter != Owner)
                                {
                                    continue;
                                }

                                Target = ob;

                                if (Owner != null)
                                {
                                    for (int j = 0; j < playerob.Pets.Count; j++)
                                    {
                                        MonsterObject pet = playerob.Pets[j];

                                        if (!pet.IsAttackTarget(this))
                                        {
                                            continue;
                                        }
                                        Target = pet;
                                        break;
                                    }
                                }
                                return;

                            default:
                                continue;
                            }
                        }
                    }
                }
            }
        }
        public void SpecialArrowShot(MapObject target, UserMagic magic)
        {
            if (target == null || !target.IsAttackTarget(this)) return;
            if ((Info.MentalState != 1) && !CanFly(target.CurrentLocation)) return;
            int distance = Functions.MaxDistance(CurrentLocation, target.CurrentLocation);
            int damage = (GetAttackPower(MinMC, MaxMC) + magic.GetPower());
            if (magic.Spell != Spell.CrippleShot)
                damage = (int)(damage * Math.Max(1, (distance * 0.4)));//range boost
            damage = ApplyArcherState(damage);

            int delay = distance * 50 + 500; //50 MS per Step

            DelayedAction action = new DelayedAction(DelayedType.Magic, Envir.Time + delay, magic, damage, target);
            ActionList.Add(action);
        }
Beispiel #13
0
        private bool FillTargetList(Point location)
        {
            int range = CreatureRules.SemiAutoPickupRange;

            TargetList.Clear();
            for (int d = 0; d <= range; d++)
            {
                for (int y = location.Y - d; y <= location.Y + d; y++)
                {
                    if (y < 0)
                    {
                        continue;
                    }
                    if (y >= CurrentMap.Height)
                    {
                        break;
                    }

                    for (int x = location.X - d; x <= location.X + d; x += Math.Abs(y - location.Y) == d ? 1 : d * 2)
                    {
                        if (x < 0)
                        {
                            continue;
                        }
                        if (x >= CurrentMap.Width)
                        {
                            break;
                        }

                        Cell cell = CurrentMap.GetCell(x, y);
                        if (!cell.Valid || cell.Objects == null)
                        {
                            continue;
                        }

                        for (int i = 0; i < cell.Objects.Count; i++)
                        {
                            MapObject ob = cell.Objects[i];
                            if (ob == null)
                            {
                                continue;
                            }
                            if (ob.Race != ObjectType.Item)
                            {
                                continue;
                            }
                            if (ob.Owner != null && ob.Owner != this && ob.Owner != Master && !IsMasterGroupMember(ob.Owner))
                            {
                                continue;
                            }

                            ItemObject item = (ItemObject)ob;
                            if (item.Item != null)
                            {
                                if (!((PlayerObject)Master).CanGainItem(item.Item))
                                {
                                    continue;
                                }
                                if (CheckItemAgainstFilter(item.Item.Info.Type))
                                {
                                    TargetList.Add(ob);
                                    break;
                                }
                            }
                            else
                            {
                                if (item.Gold > 0)
                                {
                                    if (!((PlayerObject)Master).CanGainGold(item.Gold))
                                    {
                                        continue;
                                    }
                                    if (ItemFilter.PetPickupAll || ItemFilter.PetPickupGold)
                                    {
                                        TargetList.Add(ob);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(TargetList.Count > 0);
        }
 public override void ApplyPoison(Poison p, MapObject Caster = null, bool NoResist = false)
 {
     //FindTarget();
 }
Beispiel #15
0
 public override Buff AddBuff(BuffType type, MapObject owner, int duration, Stats stat, bool visible = false, bool infinite = false, bool stackable = false, bool refreshStats = true, params int[] values)
 {
     throw new NotSupportedException();
 }
Beispiel #16
0
        private void FindItemTarget()
        {
            int range = shortcheck ? 4 : CreatureRules.AutoPickupRange;

            for (int d = 0; d <= range; d++)
            {
                for (int y = CurrentLocation.Y - d; y <= CurrentLocation.Y + d; y++)
                {
                    if (y < 0)
                    {
                        continue;
                    }
                    if (y >= CurrentMap.Height)
                    {
                        break;
                    }

                    for (int x = CurrentLocation.X - d; x <= CurrentLocation.X + d; x += Math.Abs(y - CurrentLocation.Y) == d ? 1 : d * 2)
                    {
                        if (x < 0)
                        {
                            continue;
                        }
                        if (x >= CurrentMap.Width)
                        {
                            break;
                        }

                        Cell cell = CurrentMap.GetCell(x, y);
                        if (!cell.Valid || cell.Objects == null)
                        {
                            continue;
                        }

                        for (int i = 0; i < cell.Objects.Count; i++)
                        {
                            MapObject ob = cell.Objects[i];
                            if (ob == null)
                            {
                                continue;
                            }
                            if (ob.Race != ObjectType.Item)
                            {
                                continue;
                            }
                            if (ob.Owner != null && ob.Owner != this && ob.Owner != Master && !IsMasterGroupMember(ob.Owner))
                            {
                                continue;
                            }

                            ItemObject item = (ItemObject)ob;
                            if (item.Item != null)
                            {
                                if (!((PlayerObject)Master).CanGainItem(item.Item))
                                {
                                    continue;
                                }
                                if (CheckItemAgainstFilter(item.Item.Info.Type))
                                {
                                    //Master.ReceiveChat("YEAH ITEM I CAN GAIN {" + item.Item.FriendlyName + "} " + item.Item.Info.Type.ToString(), ChatType.System);
                                    Target     = ob;
                                    shortcheck = false;
                                    return;
                                }
                            }
                            else
                            {
                                if (item.Gold > 0)
                                {
                                    if (!((PlayerObject)Master).CanGainGold(item.Gold))
                                    {
                                        continue;
                                    }
                                    if (ItemFilter.PetPickupAll || ItemFilter.PetPickupGold)
                                    {
                                        //Master.ReceiveChat("YEAH GOLD I CAN GAIN {" + item.Gold + "}", ChatType.System);
                                        Target     = ob;
                                        shortcheck = false;
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            shortcheck = false;
        }
Beispiel #17
0
 public override Buff AddBuff(BuffType type, MapObject owner, int duration, Stats stats, bool refreshStats = true, params int[] values)
 {
     throw new NotSupportedException();
 }
Beispiel #18
0
 public abstract int Pushed(MapObject pusher, MirDirection dir, int distance);
Beispiel #19
0
        public virtual void AddBuff(Buff b)
        {
            switch (b.Type)
            {
            case BuffType.MoonLight:
            case BuffType.Hiding:
            case BuffType.DarkBody:
                Hidden = true;

                if (b.Type == BuffType.MoonLight || b.Type == BuffType.DarkBody)
                {
                    Sneaking = true;
                }

                for (int y = CurrentLocation.Y - Globals.DataRange; y <= CurrentLocation.Y + Globals.DataRange; y++)
                {
                    if (y < 0)
                    {
                        continue;
                    }
                    if (y >= CurrentMap.Height)
                    {
                        break;
                    }

                    for (int x = CurrentLocation.X - Globals.DataRange; x <= CurrentLocation.X + Globals.DataRange; x++)
                    {
                        if (x < 0)
                        {
                            continue;
                        }
                        if (x >= CurrentMap.Width)
                        {
                            break;
                        }
                        if (x < 0 || x >= CurrentMap.Width)
                        {
                            continue;
                        }

                        Cell cell = CurrentMap.GetCell(x, y);

                        if (!cell.Valid || cell.Objects == null)
                        {
                            continue;
                        }

                        for (int i = 0; i < cell.Objects.Count; i++)
                        {
                            MapObject ob = cell.Objects[i];
                            if (ob.Race != ObjectType.Monster)
                            {
                                continue;
                            }

                            if (ob.Target == this && (!ob.CoolEye || ob.Level < Level))
                            {
                                ob.Target = null;
                            }
                        }
                    }
                }
                break;
            }


            for (int i = 0; i < Buffs.Count; i++)
            {
                if (Buffs[i].Type != b.Type)
                {
                    continue;
                }

                Buffs[i]        = b;
                Buffs[i].Paused = false;
                return;
            }

            Buffs.Add(b);
        }
Beispiel #20
0
 public abstract int Pushed(MapObject pusher, MirDirection dir, int distance);
Beispiel #21
0
        private bool CheckAndMoveTo(Point location)
        {
            if (CurrentLocation == location)
            {
                return(true);
            }

            bool inRange = Functions.InRange(location, CurrentLocation, 1);

            if (inRange)
            {
                if (!CurrentMap.ValidPoint(location))
                {
                    return(false);
                }
                Cell cell = CurrentMap.GetCell(location);
                if (cell.Objects != null)
                {
                    for (int i = 0; i < cell.Objects.Count; i++)
                    {
                        MapObject ob = cell.Objects[i];
                        if (!ob.Blocking)
                        {
                            continue;
                        }
                        return(false);
                    }
                }
            }

            MirDirection dir = Functions.DirectionFromPoint(CurrentLocation, location);

            if (Walk(dir))
            {
                return(true);
            }

            switch (Envir.Random.Next(2)) //No favour
            {
            case 0:
                for (int i = 0; i < 7; i++)
                {
                    dir = Functions.NextDir(dir);

                    if (Walk(dir))
                    {
                        return(true);
                    }
                }
                break;

            default:
                for (int i = 0; i < 7; i++)
                {
                    dir = Functions.PreviousDir(dir);

                    if (Walk(dir))
                    {
                        return(true);
                    }
                }
                break;
            }
            return(false);
        }
Beispiel #22
0
 public abstract void ApplyPoison(Poison p, MapObject Caster = null, bool NoResist = false);
Beispiel #23
0
        public void PickUpItem(Point location)
        {
            if (Dead || Master == null)
            {
                return;
            }

            Cell cell = CurrentMap.GetCell(location);

            if (!cell.Valid || cell.Objects == null)
            {
                return;
            }
            for (int i = 0; i < cell.Objects.Count; i++)
            {
                MapObject ob = cell.Objects[i];
                if (ob == null)
                {
                    continue;
                }
                if (ob.Race != ObjectType.Item)
                {
                    continue;
                }
                if (ob.Owner != null && ob.Owner != this && ob.Owner != Master && !IsMasterGroupMember(ob.Owner))
                {
                    continue;
                }

                ItemObject item = (ItemObject)ob;
                if (item == null)
                {
                    continue;
                }
                if (item.Item != null)
                {
                    if (!((PlayerObject)Master).CanGainItem(item.Item))
                    {
                        continue;
                    }

                    if (item.Item.Info.ShowGroupPickup && IsMasterGroupMember(Master))
                    {
                        for (int j = 0; j < Master.GroupMembers.Count; j++)
                        {
                            Master.GroupMembers[j].ReceiveChat(Name + " Picked up: {" + item.Item.Name + "}", ChatType.Hint);
                        }
                    }

                    if (item.Item.Info.Grade == ItemGrade.Mythical || item.Item.Info.Grade == ItemGrade.Legendary)
                    {
                        Master.ReceiveChat("Pet Picked up: {" + item.Item.Name + "}", ChatType.Hint);
                    }
                    ((PlayerObject)Master).GainItem(item.Item);
                    CurrentMap.RemoveObject(ob);
                    ob.Despawn();
                    return;
                }
                else
                {
                    if (ob == null)
                    {
                        continue;
                    }
                    if (!((PlayerObject)Master).CanGainGold(item.Gold))
                    {
                        continue;
                    }
                    ((PlayerObject)Master).GainGold(item.Gold);
                    CurrentMap.RemoveObject(ob);
                    ob.Despawn();
                    return;
                }
            }
        }
Beispiel #24
0
 public override void ApplyPoison(Poison p, MapObject Caster = null, bool NoResist = false)
 {
     throw new NotSupportedException();
 }
Beispiel #25
0
 public override void ApplyPoison(Poison p, MapObject Caster = null, bool NoResist = false)
 {
     //FindTarget();
 }
        public void BindingShot(UserMagic magic, MapObject target, out bool cast)
        {
            cast = false;

            if (target == null || !target.IsAttackTarget(this) || !(target is MonsterObject)) return;
            if ((Info.MentalState != 1) && !CanFly(target.CurrentLocation)) return;
            if (target.Level > Level + 2) return;
            if (((MonsterObject)target).ShockTime >= Envir.Time) return;//Already shocked


            uint duration = (uint)((magic.Level * 5 + 10) * 1000);
            int value = (int)duration;
            int delay = Functions.MaxDistance(CurrentLocation, target.CurrentLocation) * 50 + 500; //50 MS per Step

            DelayedAction action = new DelayedAction(DelayedType.Magic, Envir.Time + delay, magic, value, target);
            ActionList.Add(action);

            cast = true;
        }
Beispiel #27
0
        public void ProcessSpell(MapObject ob)
        {
            if (Envir.Time < StartTime)
            {
                return;
            }
            switch (Spell)
            {
            case Spell.FireWall:
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }

                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }
                ob.Attacked(Caster, Value, DefenceType.MAC, false);
                break;

            case Spell.Healing:     //SafeZone
                if (ob.Race != ObjectType.Player && (ob.Race != ObjectType.Monster || ob.Master == null || ob.Master.Race != ObjectType.Player))
                {
                    return;
                }
                if (ob.Dead || ob.HealAmount != 0 || ob.PercentHealth == 100)
                {
                    return;
                }

                ob.HealAmount += 25;
                Broadcast(new S.ObjectEffect {
                    ObjectID = ob.ObjectID, Effect = SpellEffect.Healing
                });
                break;

            case Spell.PoisonCloud:
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }

                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }
                ob.Attacked(Caster, Value, DefenceType.MAC, false);
                if (!ob.Dead)
                {
                    ob.ApplyPoison(new Poison
                    {
                        Duration  = 15,
                        Owner     = Caster,
                        PType     = PoisonType.Green,
                        TickSpeed = 2000,
                        Value     = Value / 20
                    }, Caster, false, false);
                }
                break;

            case Spell.Blizzard:
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (Caster != null && Caster.ActiveBlizzard == false)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }
                ob.Attacked(Caster, Value, DefenceType.MAC, false);
                if (!ob.Dead && Envir.Random.Next(8) == 0)
                {
                    ob.ApplyPoison(new Poison
                    {
                        Duration  = 5 + Envir.Random.Next(Caster.Freezing),
                        Owner     = Caster,
                        PType     = PoisonType.Slow,
                        TickSpeed = 2000,
                    }, Caster);
                }
                break;

            case Spell.MeteorStrike:
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (Caster != null && Caster.ActiveBlizzard == false)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }
                ob.Attacked(Caster, Value, DefenceType.MAC, false);
                break;

            case Spell.ExplosiveTrap:
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }
                if (DetonatedTrap)
                {
                    return;                   //make sure explosion happens only once
                }
                DetonateTrapNow();
                ob.Attacked(Caster, Value, DefenceType.MAC, false);
                break;

            case Spell.MapLava:
                if (ob is PlayerObject)
                {
                    PlayerObject pOb = (PlayerObject)ob;
                    if (pOb.Account.AdminAccount && pOb.Observer)
                    {
                        return;
                    }
                }
                break;

            case Spell.MapLightning:
                if (ob is PlayerObject)
                {
                    PlayerObject pOb = (PlayerObject)ob;
                    if (pOb.Account.AdminAccount && pOb.Observer)
                    {
                        return;
                    }
                }
                break;

            case Spell.MapQuake1:
            case Spell.MapQuake2:
                if (Value == 0)
                {
                    return;
                }
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                ob.Struck(Value, DefenceType.MAC);
                break;

            case Spell.Portal:
                if (ob.Race != ObjectType.Player)
                {
                    return;
                }
                if (Caster != ob && (Caster == null || (Caster.GroupMembers == null) || (!Caster.GroupMembers.Contains((PlayerObject)ob))))
                {
                    return;
                }

                if (ExitMap == null)
                {
                    return;
                }

                MirDirection dir = ob.Direction;

                Point newExit = Functions.PointMove(ExitCoord, dir, 1);

                if (!ExitMap.ValidPoint(newExit))
                {
                    return;
                }

                ob.Teleport(ExitMap, newExit, false);

                Value = Value - 1;

                if (Value < 1)
                {
                    ExpireTime = Envir.Time;
                    return;
                }

                break;
            }
        }
        public void NapalmShot(MapObject target, UserMagic magic)
        {
            if (target == null || !target.IsAttackTarget(this)) return;
            if ((Info.MentalState != 1) && !CanFly(target.CurrentLocation)) return;

            int distance = Functions.MaxDistance(CurrentLocation, target.CurrentLocation);
            int damage = (GetAttackPower(MinMC, MaxMC) + magic.GetPower());
            damage = ApplyArcherState(damage);

            int delay = distance * 50 + 500; //50 MS per Step

            DelayedAction action = new DelayedAction(DelayedType.Magic, Envir.Time + delay, this, magic, damage, target.CurrentLocation);
            CurrentMap.ActionList.Add(action);
        }
Beispiel #29
0
        public bool DragonDrop(int distance)
        {
            if (CurrentMap == null)
            {
                return(false);
            }

            Cell  best         = null;
            int   bestCount    = 0;
            Point bestLocation = Point.Empty;

            for (int d = 0; d <= distance; d++)
            {
                for (int y = CurrentLocation.Y + 3; y <= CurrentLocation.Y + (d * 2); y++)
                {
                    if (y < 0)
                    {
                        continue;
                    }
                    if (y >= CurrentMap.Height)
                    {
                        break;
                    }

                    for (int x = CurrentLocation.X - d; x <= CurrentLocation.X + d; x += Math.Abs(y - CurrentLocation.Y) == d ? 1 : d * 2)
                    {
                        if (x < 0)
                        {
                            continue;
                        }
                        if (x >= CurrentMap.Width)
                        {
                            break;
                        }
                        if (!CurrentMap.ValidPoint(x, y))
                        {
                            continue;
                        }

                        bool movement = false;
                        for (int i = 0; i < CurrentMap.Info.Movements.Count; i++)
                        {
                            MovementInfo info = CurrentMap.Info.Movements[i];
                            if (info.Source != new Point(x, y))
                            {
                                continue;
                            }
                            movement = true;
                            break;
                        }

                        if (movement)
                        {
                            continue;
                        }

                        Cell cell = CurrentMap.GetCell(x, y);

                        if (cell.Objects == null)
                        {
                            CurrentLocation = new Point(x, y);
                            CurrentMap.AddObject(this);
                            Spawned();
                            return(true);
                        }

                        int  count    = 0;
                        bool blocking = false;

                        for (int i = 0; i < cell.Objects.Count; i++)
                        {
                            MapObject ob = cell.Objects[i];
                            if (ob.Blocking)
                            {
                                blocking = true;
                                break;
                            }
                            if (ob.Race == ObjectType.Item)
                            {
                                count++;
                            }
                        }

                        if (blocking || count >= Settings.DropStackSize)
                        {
                            continue;
                        }

                        if (count == 0)
                        {
                            CurrentLocation = new Point(x, y);
                            CurrentMap.AddObject(this);
                            Spawned();
                            return(true);
                        }

                        if (best == null || count < bestCount)
                        {
                            best         = cell;
                            bestCount    = count;
                            bestLocation = new Point(x, y);
                        }
                    }
                }
            }

            if (best == null)
            {
                return(false);
            }

            CurrentLocation = bestLocation;
            CurrentMap.AddObject(this);
            Spawned();
            return(true);
        }
        public void OneWithNature(MapObject target, UserMagic magic)
        {
            int damage = GetAttackPower(MinMC, MaxMC) + magic.GetPower();

            DelayedAction action = new DelayedAction(DelayedType.Magic, Envir.Time + 500, this, magic, damage, CurrentLocation);
            CurrentMap.ActionList.Add(action);
        }
Beispiel #31
0
 public override void ApplyPoison(Poison p, MapObject Caster = null, bool NoResist = false)
 {
     throw new NotSupportedException();
 }
Beispiel #32
0
        protected List <MapObject> FindAllTargets(int dist, Point location, bool needSight = true)
        {
            List <MapObject> targets = new List <MapObject>();

            for (int d = 0; d <= dist; d++)
            {
                for (int y = location.Y - d; y <= location.Y + d; y++)
                {
                    if (y < 0)
                    {
                        continue;
                    }
                    if (y >= CurrentMap.Height)
                    {
                        break;
                    }

                    for (int x = location.X - d; x <= location.X + d; x += Math.Abs(y - location.Y) == d ? 1 : d * 2)
                    {
                        if (x < 0)
                        {
                            continue;
                        }
                        if (x >= CurrentMap.Width)
                        {
                            break;
                        }

                        Cell cell = CurrentMap.GetCell(x, y);
                        if (!cell.Valid || cell.Objects == null)
                        {
                            continue;
                        }

                        for (int i = 0; i < cell.Objects.Count; i++)
                        {
                            MapObject ob = cell.Objects[i];
                            switch (ob.Race)
                            {
                            case ObjectType.Monster:
                            case ObjectType.Player:
                            case ObjectType.Hero:
                                if (!ob.IsAttackTarget(this))
                                {
                                    continue;
                                }
                                if (ob.Hidden && (!CoolEye || Level < ob.Level) && needSight)
                                {
                                    continue;
                                }
                                if (ob.Race == ObjectType.Player)
                                {
                                    PlayerObject player = ((PlayerObject)ob);
                                    if (player.GMGameMaster)
                                    {
                                        continue;
                                    }
                                }
                                targets.Add(ob);
                                continue;

                            default:
                                continue;
                            }
                        }
                    }
                }
            }
            return(targets);
        }
Beispiel #33
0
 public override int Pushed(MapObject pusher, MirDirection dir, int distance)
 {
     throw new NotSupportedException();
 }
Beispiel #34
0
        public override void Process()
        {
            if (Decoration)
            {
                return;
            }

            if (Caster != null && Caster.Node == null)
            {
                Caster = null;
            }

            if (Envir.Time > ExpireTime || ((Spell == Spell.FireWall || Spell == Spell.Portal || Spell == Spell.ExplosiveTrap || Spell == Spell.Reincarnation) && Caster == null) || (Spell == Spell.TrapHexagon && Target != null) || (Spell == Spell.Trap && Target != null))
            {
                if (Spell == Spell.TrapHexagon && Target != null || Spell == Spell.Trap && Target != null)
                {
                    MonsterObject ob = (MonsterObject)Target;

                    if (Envir.Time < ExpireTime && ob.ShockTime != 0)
                    {
                        return;
                    }
                }

                if (Spell == Spell.Reincarnation && Caster != null)
                {
                    ((PlayerObject)Caster).ReincarnationReady      = true;
                    ((PlayerObject)Caster).ReincarnationExpireTime = Envir.Time + 6000;
                }

                CurrentMap.RemoveObject(this);
                Despawn();
                return;
            }

            if (Spell == Spell.FireWall)
            {
                if (CurrentMap != Caster?.CurrentMap)
                {
                    CurrentMap.RemoveObject(this);
                    Despawn();
                    return;
                }
            }

            if (Spell == Spell.Reincarnation && !((PlayerObject)Caster).ActiveReincarnation)
            {
                CurrentMap.RemoveObject(this);
                Despawn();
                return;
            }

            if (Spell == Spell.ExplosiveTrap && Caster != null && !Functions.InRange(CurrentLocation, Caster.CurrentLocation, 15))
            {
                CurrentMap.RemoveObject(this);
                Despawn();
                return;
            }

            if (Envir.Time < TickTime)
            {
                return;
            }
            TickTime = Envir.Time + TickSpeed;

            Cell cell = CurrentMap.GetCell(CurrentLocation);

            for (int i = 0; i < cell.Objects.Count; i++)
            {
                ProcessSpell(cell.Objects[i]);
            }

            if ((Spell == Spell.MapLava) || (Spell == Spell.MapLightning))
            {
                Value = 0;
            }
        }
Beispiel #35
0
        public void Add(MapObject mapObject)
        {
            if (Objects == null) Objects = new List<MapObject>();

            Objects.Add(mapObject);
        }
Beispiel #36
0
        public virtual void Process()
        {
            if (Master != null && Master.Node == null) Master = null;
            if (LastHitter != null && LastHitter.Node == null) LastHitter = null;
            if (EXPOwner != null && EXPOwner.Node == null) EXPOwner = null;
            if (Target != null && (Target.Node == null || Target.Dead)) Target = null;
            if (Owner != null && Owner.Node == null) Owner = null;

            if (Envir.Time > PKPointTime && PKPoints > 0)
            {
                PKPointTime = Envir.Time + Settings.PKDelay * Settings.Second;
                PKPoints--;
            }

            if (LastHitter != null && Envir.Time > LastHitTime)
                LastHitter = null;

            if (EXPOwner != null && Envir.Time > EXPOwnerTime)
            {
                EXPOwner = null;
            }

            for (int i = 0; i < ActionList.Count; i++)
            {
                if (Envir.Time < ActionList[i].Time) continue;
                Process(ActionList[i]);
                ActionList.RemoveAt(i);
            }
        }
Beispiel #37
0
        public void AddObject(MapObject ob)
        {
            if (ob.Race == ObjectType.Player)
            {
                Players.Add((PlayerObject)ob);
                InactiveTime = Envir.Time;
            }
            if (ob.Race == ObjectType.Merchant) NPCs.Add((NPCObject)ob);

            GetCell(ob.CurrentLocation).Add(ob);
        }
Beispiel #38
0
        public void RemoveObject(MapObject ob)
        {
            if (ob.Race == ObjectType.Player) Players.Remove((PlayerObject)ob);
            if (ob.Race == ObjectType.Merchant) NPCs.Remove((NPCObject)ob);

            GetCell(ob.CurrentLocation).Remove(ob);
        }
Beispiel #39
0
 public abstract void ApplyPoison(Poison p, MapObject Caster = null, bool NoResist = false, bool ignoreDefence = true);
Beispiel #40
0
 public void Remove(MapObject mapObject)
 {
     Objects.Remove(mapObject);
     if (Objects.Count == 0) Objects = null;
 }
Beispiel #41
0
 public override int Pushed(MapObject pusher, MirDirection dir, int distance)
 {
     throw new NotSupportedException();
 }
        public void ProcessSpell(MapObject ob)
        {
            if (Envir.Time < StartTime) return;
            switch (Spell)
            {
                case Spell.FireWall:
                    if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) return;
                    if (ob.Dead) return;

                    if (!ob.IsAttackTarget(Caster)) return;
                    ob.Attacked(Caster, Value, DefenceType.MAC, false);
                    break;
                case Spell.Healing: //SafeZone
                    if (ob.Race != ObjectType.Player && (ob.Race != ObjectType.Monster || ob.Master == null || ob.Master.Race != ObjectType.Player)) return;
                    if (ob.Dead || ob.HealAmount != 0 || ob.PercentHealth == 100) return;

                    ob.HealAmount += 25;
                    Broadcast(new S.ObjectEffect {ObjectID = ob.ObjectID, Effect = SpellEffect.Healing});
                    break;
                case Spell.PoisonCloud:
                    if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) return;
                    if (ob.Dead) return;

                    if (!ob.IsAttackTarget(Caster)) return;
                    ob.Attacked(Caster, Value, DefenceType.None, false);
                    if (!ob.Dead)
                    ob.ApplyPoison(new Poison
                        {
                            Duration = 15,
                            Owner = Caster,
                            PType = PoisonType.Green,
                            TickSpeed = 2000,
                            Value = Value/20
                        }, Caster, false, false);
                    break;
                case Spell.Blizzard:
                    if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) return;
                    if (ob.Dead) return;
                    if (Caster.ActiveBlizzard == false) return;
                    if (!ob.IsAttackTarget(Caster)) return;
                    ob.Attacked(Caster, Value, DefenceType.MAC, false);
                    if (!ob.Dead && Envir.Random.Next(8) == 0)
                        ob.ApplyPoison(new Poison
                        {
                            Duration = 5 + Envir.Random.Next(Caster.Freezing),
                            Owner = Caster,
                            PType = PoisonType.Slow,
                            TickSpeed = 2000,
                        }, Caster);
                    break;
                case Spell.MeteorStrike:
                    if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) return;
                    if (ob.Dead) return;
                    if (Caster.ActiveBlizzard == false) return;
                    if (!ob.IsAttackTarget(Caster)) return;
                    ob.Attacked(Caster, Value, DefenceType.MAC, false);
                    break;
                case Spell.ExplosiveTrap:
                    if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) return;
                    if (ob.Dead) return;
                    if (!ob.IsAttackTarget(Caster)) return;
                    if (DetonatedTrap) return;//make sure explosion happens only once
                    DetonateTrapNow();
                    ob.Attacked(Caster, Value, DefenceType.MAC, false);
                    break;
                case Spell.MapLava:
                case Spell.MapLightning:
                    if (Value == 0) return;
                    if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) return;
                    if (ob.Dead) return;
                    ob.Struck(Value, DefenceType.MAC);
                    break;

                case Spell.Portal:
                    if (ob.Race != ObjectType.Player) return;
                    if (Caster != ob && (Caster == null || (Caster.GroupMembers == null) || (!Caster.GroupMembers.Contains((PlayerObject)ob)))) return;

                    if (ExitMap == null) return;

                    MirDirection dir = ob.Direction;

                    Point newExit = Functions.PointMove(ExitCoord, dir, 1);

                    if (!ExitMap.ValidPoint(newExit)) return;

                    ob.Teleport(ExitMap, newExit, false);

                    break;
            }
        }
Beispiel #43
0
        public override int Pushed(MapObject pusher, MirDirection dir, int distance)
        {
            if (!Info.CanPush) return 0;
            //if (!CanMove) return 0; //stops mobs that can't move (like cannibalplants) from being pushed

            int result = 0;
            MirDirection reverse = Functions.ReverseDirection(dir);
            for (int i = 0; i < distance; i++)
            {
                Point location = Functions.PointMove(CurrentLocation, dir, 1);

                if (!CurrentMap.ValidPoint(location)) return result;

                Cell cell = CurrentMap.GetCell(location);

                bool stop = false;
                if (cell.Objects != null)
                    for (int c = 0; c < cell.Objects.Count; c++)
                    {
                        MapObject ob = cell.Objects[c];
                        if (!ob.Blocking) continue;
                        stop = true;
                    }
                if (stop) break;

                CurrentMap.GetCell(CurrentLocation).Remove(this);

                Direction = reverse;
                RemoveObjects(dir, 1);
                CurrentLocation = location;
                CurrentMap.GetCell(CurrentLocation).Add(this);
                AddObjects(dir, 1);

                Broadcast(new S.ObjectPushed { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });

                result++;
            }

            ActionTime = Envir.Time + 300 * result;
            MoveTime = Envir.Time + 500 * result;

            if (result > 0)
            {
                Cell cell = CurrentMap.GetCell(CurrentLocation);

                for (int i = 0; i < cell.Objects.Count; i++)
                {
                    if (cell.Objects[i].Race != ObjectType.Spell) continue;
                    SpellObject ob = (SpellObject)cell.Objects[i];

                    ob.ProcessSpell(this);
                    break;
                }
            }

            return result;
        }
 private bool IsMasterGroupMember(MapObject player)
 {
     if (player.Race != ObjectType.Player || Master == null) return false;
     return ((PlayerObject)Master).GroupMembers != null && ((PlayerObject)Master).GroupMembers.Contains((PlayerObject)player);
 }
Beispiel #45
0
        public void ProcessSpell(MapObject ob)
        {
            if (Envir.Time < StartTime)
            {
                return;
            }
            switch (Spell)
            {
            case Spell.FireWall:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }

                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }
                ob.Attacked(((PlayerObject)Caster), Value, DefenceType.MAC, false);
            }
            break;

            case Spell.Healing:     //SafeZone
            {
                if (ob.Race != ObjectType.Player && (ob.Race != ObjectType.Monster || ob.Master == null || ob.Master.Race != ObjectType.Player))
                {
                    return;
                }
                if (ob.Dead || ob.HealAmount != 0 || ob.PercentHealth == 100)
                {
                    return;
                }

                ob.HealAmount += 25;
                Broadcast(new S.ObjectEffect {
                        ObjectID = ob.ObjectID, Effect = SpellEffect.Healing
                    });
            }
            break;

            case Spell.PoisonCloud:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }

                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }
                ob.Attacked(((PlayerObject)Caster), Value, DefenceType.MAC, false);
                if (!ob.Dead)
                {
                    ob.ApplyPoison(new Poison
                        {
                            Duration  = 12,
                            Owner     = Caster,
                            PType     = PoisonType.Green,
                            TickSpeed = TickSpeed,
                            Value     = (Caster.Stats[Stat.MinSC] + Caster.Stats[Stat.MaxSC]) / 2 + BonusDmg
                        }, Caster, false, false);
                }
            }
            break;

            case Spell.Blizzard:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (Caster != null && ((PlayerObject)Caster).ActiveBlizzard == false)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }
                ob.Attacked(((PlayerObject)Caster), Value, DefenceType.MAC, false);
                if (!ob.Dead && Envir.Random.Next(8) == 0)
                {
                    ob.ApplyPoison(new Poison
                        {
                            Duration  = 5 + Envir.Random.Next(Caster.Stats[Stat.Freezing]),
                            Owner     = Caster,
                            PType     = PoisonType.Slow,
                            TickSpeed = 2000,
                        }, Caster);
                }
            }
            break;

            case Spell.MeteorStrike:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (Caster != null && ((PlayerObject)Caster).ActiveBlizzard == false)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }
                ob.Attacked(((PlayerObject)Caster), Value, DefenceType.MAC, false);
            }
            break;

            case Spell.ExplosiveTrap:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }
                if (DetonatedTrap)
                {
                    return;
                }
                DetonateTrapNow();
                ob.Attacked(((PlayerObject)Caster), Value, DefenceType.MAC, false);
            }
            break;

            case Spell.MapLava:
            case Spell.MapLightning:
            {
                if (ob is PlayerObject player)
                {
                    if (player.Account.AdminAccount && player.Observer)
                    {
                        return;
                    }
                    player.Struck(Value, DefenceType.MAC);
                }
            }
            break;

            case Spell.MapQuake1:
            case Spell.MapQuake2:
            {
                if (Value == 0)
                {
                    return;
                }
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                ob.Struck(Value, DefenceType.MAC);
            }
            break;

            case Spell.GeneralMeowMeowThunder:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (ob == Caster)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }

                if (Value == 0)
                {
                    return;
                }
                ob.Struck(Value, DefenceType.MAC);
            }
            break;

            case Spell.TreeQueenRoot:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (ob == Caster)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }

                if (Value == 0)
                {
                    return;
                }
                ob.Struck(Value, DefenceType.MAC);
            }
            break;

            case Spell.TreeQueenMassRoots:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (ob == Caster)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }

                if (Value == 0)
                {
                    return;
                }
                ob.Struck(Value, DefenceType.MAC);
            }
            break;

            case Spell.TreeQueenGroundRoots:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (ob == Caster)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }

                ob.Struck(Value, DefenceType.MAC);

                if (Envir.Random.Next(3) > 0)
                {
                    ob.ApplyPoison(new Poison {
                            PType = PoisonType.Paralysis, Duration = 5, TickSpeed = 1000
                        }, this);
                }
            }
            break;

            case Spell.StoneGolemQuake:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (ob == Caster)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }

                if (Value == 0)
                {
                    return;
                }
                ob.Struck(Value, DefenceType.AC);
            }
            break;

            case Spell.EarthGolemPile:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (ob == Caster)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }

                if (Value == 0)
                {
                    return;
                }
                ob.Struck(Value, DefenceType.AC);
            }
            break;

            case Spell.TucsonGeneralRock:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (ob == Caster)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }

                if (Value == 0)
                {
                    return;
                }
                ob.Struck(Value, DefenceType.AC);
            }
            break;

            case Spell.Portal:
            {
                if (ob.Race != ObjectType.Player)
                {
                    return;
                }
                if (Caster != ob && (Caster == null || (Caster.GroupMembers == null) || (!Caster.GroupMembers.Contains((PlayerObject)ob))))
                {
                    return;
                }

                var portal = Envir.Spells.SingleOrDefault(ob => ob != this && ob.Node != null &&
                                                          ob.Spell == Spell.Portal &&
                                                          ob.Caster == Caster);

                if (portal != null)
                {
                    Point newExit = Functions.PointMove(portal.CurrentLocation, ob.Direction, 1);

                    if (!portal.CurrentMap.ValidPoint(newExit))
                    {
                        return;
                    }

                    ob.Teleport(portal.CurrentMap, newExit, false);
                }

                Value -= 1;

                if (Value < 1)
                {
                    ExpireTime = 0;
                }
            }
            break;

            case Spell.FlyingStatueIceTornado:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (ob == Caster)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }

                ob.Struck(Value, DefenceType.MAC);

                if (Envir.Random.Next(8) == 0)
                {
                    ob.ApplyPoison(new Poison {
                            PType = PoisonType.Slow, Duration = 5, TickSpeed = 1000
                        }, this);
                }
            }
            break;

            case Spell.DarkOmaKingNuke:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (ob == Caster)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }

                ob.Struck(Value, DefenceType.AC);
                ob.ApplyPoison(new Poison {
                        PType = PoisonType.Dazed, Duration = 5, TickSpeed = 1000
                    }, this);
            }
            break;

            case Spell.HornedSorcererDustTornado:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (ob == Caster)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }

                if (Value == 0)
                {
                    return;
                }
                ob.Struck(Value, DefenceType.AC);
            }
            break;

            case Spell.HornedCommanderRockFall:
            case Spell.HornedCommanderRockSpike:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (ob == Caster)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }

                if (Value == 0)
                {
                    return;
                }
                ob.Struck(Value, DefenceType.AC);
            }
            break;
            }
        }
        private bool DoubleShot(MapObject target, UserMagic magic)
        {
            if (target == null || !target.IsAttackTarget(this)) return false;
            if ((Info.MentalState != 1) && !CanFly(target.CurrentLocation)) return false;
            int distance = Functions.MaxDistance(CurrentLocation, target.CurrentLocation);
            int damage = (GetAttackPower(MinMC, MaxMC) + magic.GetPower());
            damage = (int)(damage * Math.Max(1, (distance * 0.25)));//range boost
            damage = ApplyArcherState(damage);
            int delay = distance * 50 + 500; //50 MS per Step

            DelayedAction action = new DelayedAction(DelayedType.Magic, Envir.Time + delay, magic, damage, target);

            ActionList.Add(action);

            action = new DelayedAction(DelayedType.Magic, Envir.Time + delay + 50, magic, damage, target);

            ActionList.Add(action);

            return true;
        }
Beispiel #47
0
        protected virtual void MoveTo(Point location)
        {
            if (CurrentLocation == location)
            {
                return;
            }

            bool inRange    = Functions.InRange(location, CurrentLocation, 1);
            bool inRunRange = RidingMount ? Functions.InRange(location, CurrentLocation, 2) : inRange;

            if (inRange)
            {
                if (!CurrentMap.ValidPoint(location))
                {
                    return;
                }
                Cell cell = CurrentMap.GetCell(location);
                if (cell.Objects != null)
                {
                    for (int i = 0; i < cell.Objects.Count; i++)
                    {
                        MapObject ob = cell.Objects[i];
                        if (!ob.Blocking)
                        {
                            continue;
                        }
                        return;
                    }
                }
            }

            MirDirection dir = Functions.DirectionFromPoint(CurrentLocation, location);

            if (!inRunRange && _stepCounter > 0 && Run(dir))
            {
                return;
            }

            if (Walk(dir))
            {
                return;
            }

            switch (Envir.Random.Next(2))
            {
            case 0:
                for (int i = 0; i < 7; i++)
                {
                    dir = Functions.NextDir(dir);

                    if (Walk(dir))
                    {
                        return;
                    }
                }
                break;

            default:
                for (int i = 0; i < 7; i++)
                {
                    dir = Functions.PreviousDir(dir);

                    if (Walk(dir))
                    {
                        return;
                    }
                }
                break;
            }
        }
        private bool DelayedExplosion(MapObject target, UserMagic magic)
        {
            if (target == null || !target.IsAttackTarget(this) || !CanFly(target.CurrentLocation)) return false;

            int power = GetAttackPower(MinMC, MaxMC) + magic.GetPower();
            int delay = Functions.MaxDistance(CurrentLocation, target.CurrentLocation) * 50 + 500; //50 MS per Step

            DelayedAction action = new DelayedAction(DelayedType.Magic, Envir.Time + delay, magic, power, target);
            ActionList.Add(action);
            return true;
        }
        public void DoKnockback(MapObject target, UserMagic magic)//ElementalShot - knockback
        {
            Cell cell = CurrentMap.GetCell(target.CurrentLocation);
            if (!cell.Valid || cell.Objects == null) return;

            if (target.CurrentLocation.Y < 0 || target.CurrentLocation.Y >= CurrentMap.Height || target.CurrentLocation.X < 0 || target.CurrentLocation.X >= CurrentMap.Height) return;

            if (target.Race != ObjectType.Monster && target.Race != ObjectType.Player) return;
            if (!target.IsAttackTarget(this) || target.Level >= Level) return;

            if (Envir.Random.Next(20) >= 6 + magic.Level * 3 + ElementsLevel + Level - target.Level) return;
            int distance = 1 + Math.Max(0, magic.Level - 1) + Envir.Random.Next(2);
            MirDirection dir = Functions.DirectionFromPoint(CurrentLocation, target.CurrentLocation);

            target.Pushed(this, dir, distance);
        }
Beispiel #50
0
        public override void ApplyPoison(Poison p, MapObject Caster = null, bool NoResist = false)
        {
            if (p.Owner != null && p.Owner.IsAttackTarget(this))
                Target = p.Owner;

            if (Master != null && p.Owner != null && p.Owner.Race == ObjectType.Player && p.Owner != Master)
            {
                if (Envir.Time > Master.BrownTime && Master.PKPoints < 200)
                    p.Owner.BrownTime = Envir.Time + Settings.Minute;
            }

            for (int i = 0; i < PoisonList.Count; i++)
            {
                if (PoisonList[i].PType != p.PType) continue;
                if ((PoisonList[i].PType == PoisonType.Green) && (PoisonList[i].Value > p.Value)) return;//cant cast weak poison to cancel out strong poison
                if ((PoisonList[i].PType != PoisonType.Green) && ((PoisonList[i].Duration - PoisonList[i].Time) > p.Duration)) return;//cant cast 1 second poison to make a 1minute poison go away!
                if (p.PType == PoisonType.DelayedExplosion) return;
                if ((PoisonList[i].PType == PoisonType.Frozen) || (PoisonList[i].PType == PoisonType.Slow) || (PoisonList[i].PType == PoisonType.Paralysis)) return;//prevents mobs from being perma frozen/slowed
                PoisonList[i] = p;
                return;
            }

            if (p.PType == PoisonType.DelayedExplosion)
            {
                ExplosionInflictedTime = Envir.Time + 4000;
                Broadcast(new S.ObjectEffect { ObjectID = ObjectID, Effect = SpellEffect.DelayedExplosion });
            }

            PoisonList.Add(p);
        }
Beispiel #51
0
        public void ProcessSpell(MapObject ob)
        {
            if (Envir.Time < StartTime)
            {
                return;
            }
            switch (Spell)
            {
            case Spell.MoonMist:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster && ob.Race != ObjectType.Hero)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (Caster != null && !Caster.ActiveBlizzard)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }

                if (ob.Race == ObjectType.Player)
                {
                    ob.Attacked(Caster, PvPValue, DefenceType.ACAgility, false);
                }
                else
                {
                    ob.Attacked(Caster, Value, DefenceType.ACAgility, false);
                }
            }
            break;

            case Spell.FireWall:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster && ob.Race != ObjectType.Hero)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }

                if (ob.Race == ObjectType.Player)
                {
                    ob.Attacked(Caster, PvPValue, DefenceType.MAC, false);
                }
                else
                {
                    ob.Attacked(Caster, Value, DefenceType.MAC, false);
                }
            }
            break;

            case Spell.HealingCircle:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster && ob.Race != ObjectType.Hero)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (Caster != null && ob.ObjectID == Caster.ObjectID)
                {
                    return;
                }
                if (ob.Race == ObjectType.Player)
                {
                    if (Caster.AMode == AttackMode.All)
                    {
                        if (ob.IsAttackTarget(Caster))
                        {
                            ob.Attacked(Caster, PvPValue, DefenceType.MAC, false);
                            return;
                        }
                    }
                    else if (Caster.AMode == AttackMode.Group)
                    {
                        if (Caster.GroupMembers != null &&
                            Caster.GroupMembers.Contains(ob))
                        {
                            if (ob.Health < ob.MaxHealth)
                            {
                                ob.HealAmount  = (ushort)Math.Min(ushort.MaxValue, ob.HealAmount + Value);
                                ob.OperateTime = 0;
                                return;
                            }
                        }
                        else
                        {
                            if (ob.IsAttackTarget(Caster))
                            {
                                ob.Attacked(Caster, PvPValue, DefenceType.MAC, false);
                                return;
                            }
                        }
                    }
                    else if (Caster.AMode == AttackMode.Guild)
                    {
                        if (Caster.MyGuild != null)
                        {
                            if (ob.Race == ObjectType.Player)
                            {
                                PlayerObject tmp = (PlayerObject)ob;
                                if (tmp.MyGuild != null &&
                                    tmp.MyGuild == Caster.MyGuild)
                                {
                                    if (ob.Health < ob.MaxHealth)
                                    {
                                        ob.HealAmount  = (ushort)Math.Min(ushort.MaxValue, ob.HealAmount + Value);
                                        ob.OperateTime = 0;
                                        return;
                                    }
                                }
                                else
                                {
                                    if (ob.IsAttackTarget(Caster))
                                    {
                                        ob.Attacked(Caster, PvPValue, DefenceType.MAC, false);
                                        return;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (ob.IsAttackTarget(Caster))
                            {
                                ob.Attacked(Caster, PvPValue, DefenceType.MAC, false);
                                return;
                            }
                        }
                    }
                    else if (Caster.AMode == AttackMode.RedBrown)
                    {
                        if (ob.IsAttackTarget(Caster))
                        {
                            if (ob.Race == ObjectType.Player)
                            {
                                PlayerObject tmp = (PlayerObject)ob;        //PKPoints < 200 & Envir.Time > BrownTime
                                if (tmp.PKPoints > 200 && Envir.Time > ob.BrownTime)
                                {
                                    ob.Attacked(Caster, PvPValue, DefenceType.MAC, false);
                                    return;
                                }
                            }
                        }
                    }
                    else if (ob.Race == ObjectType.Player)
                    {
                        if (ob.Health < ob.MaxHealth)
                        {
                            ob.HealAmount  = (ushort)Math.Min(ushort.MaxValue, ob.HealAmount + Value);
                            ob.OperateTime = 0;
                            return;
                        }
                    }
                }
                else
                {
                    if (ob.IsAttackTarget(Caster))
                    {
                        ob.Attacked(Caster, Value, DefenceType.MAC, false);
                    }
                    return;
                }
            }
            break;

            case Spell.Healing:     //SafeZone
            {
                if (ob.Race != ObjectType.Player && (ob.Race != ObjectType.Monster || ob.Master == null || ob.Master.Race != ObjectType.Player))
                {
                    return;
                }
                if (ob.Dead || ob.HealAmount != 0 || ob.PercentHealth == 100)
                {
                    return;
                }

                ob.HealAmount += 25;
                Broadcast(new S.ObjectEffect {
                        ObjectID = ob.ObjectID, Effect = SpellEffect.Healing
                    });
            }
            break;

            case Spell.MobFireWall:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster && ob.Race != ObjectType.Hero)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }

                if (!ob.IsAttackTarget(MobCaster))
                {
                    return;
                }

                ob.Attacked(MobCaster, Value, DefenceType.MAC);
            }
            break;

            case Spell.CrystalBeastBlizz:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster && ob.Race != ObjectType.Hero)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (!ob.IsAttackTarget(MobCaster))
                {
                    return;
                }
                ob.Attacked(MobCaster, Value, DefenceType.MAC);
                if (!ob.Dead && Envir.Random.Next(8) == 0)
                {
                    ob.ApplyPoison(new Poison
                        {
                            Duration  = Envir.Random.Next(5),
                            Owner     = MobCaster,
                            PType     = PoisonType.Slow,
                            TickSpeed = 2000,
                        }, MobCaster);
                }
            }
            break;

            case Spell.MobPoisonCloud:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster && ob.Race != ObjectType.Hero)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }

                if (!ob.IsAttackTarget(MobCaster))
                {
                    return;
                }
                ob.Attacked(MobCaster, Value, DefenceType.MAC);
                if (!ob.Dead)
                {
                    ob.ApplyPoison(new Poison
                        {
                            Duration  = 15,
                            Owner     = MobCaster,
                            PType     = PoisonType.Green,
                            TickSpeed = 2000,
                            Value     = Value / 20
                        }, MobCaster, false, false);
                }
            }
            break;

            case Spell.MobBlizzard:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster && ob.Race != ObjectType.Hero)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (!ob.IsAttackTarget(MobCaster))
                {
                    return;
                }
                ob.Attacked(MobCaster, Value, DefenceType.MAC);
                if (!ob.Dead && Envir.Random.Next(8) == 0)
                {
                    ob.ApplyPoison(new Poison
                        {
                            Duration  = 5,
                            Owner     = MobCaster,
                            PType     = PoisonType.Slow,
                            TickSpeed = 2000,
                        }, MobCaster);
                }
            }
            break;

            case Spell.MobMeteorStrike:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster && ob.Race != ObjectType.Hero)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (!ob.IsAttackTarget(MobCaster))
                {
                    return;
                }
                ob.Attacked(MobCaster, Value, DefenceType.MAC);
            }
            break;

            case Spell.PoisonCloud:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }

                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }
                if (ob.Race == ObjectType.Player)
                {
                    ob.Attacked(Caster, PvPValue, DefenceType.MAC, false);
                }
                else
                {
                    ob.Attacked(Caster, Value, DefenceType.MAC, false);
                }
                if (!ob.Dead)
                {
                    if (ob.Race == ObjectType.Player)
                    {
                        ob.ApplyPoison(new Poison
                            {
                                Duration  = 15,
                                Owner     = Caster,
                                PType     = PoisonType.Green,
                                TickSpeed = 2000,
                                Value     = PvPValue / 20,
                            }, Caster);
                    }
                    else
                    {
                        ob.ApplyPoison(new Poison
                            {
                                Duration  = 15,
                                Owner     = Caster,
                                PType     = PoisonType.Green,
                                TickSpeed = 2000,
                                Value     = Value / 20,
                            }, Caster);
                    }
                }
            }
            break;

            case Spell.Blizzard:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster && ob.Race != ObjectType.Hero)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (Caster != null && !Caster.ActiveBlizzard)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }
                //  This is the map event, every time the Process is trigger it'll run this code until it's expired
                if (ob.Race == ObjectType.Player)
                {
                    ob.Attacked(Caster, PvPValue, DefenceType.MAC, false);
                }
                else
                {
                    ob.Attacked(Caster, Value, DefenceType.MAC, false);
                }


                if (!ob.Dead && Envir.Random.Next(8) == 0)
                {
                    ob.ApplyPoison(new Poison
                        {
                            Duration  = 5 + Envir.Random.Next(Caster.Freezing),
                            Owner     = Caster,
                            PType     = PoisonType.Slow,
                            TickSpeed = 2000,
                        }, Caster);
                }
            }
            break;

            case Spell.FrozenRains:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster && ob.Race != ObjectType.Hero)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }

                if (Caster != null && !Caster.ActiveBlizzard)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }
                if (ob.Race == ObjectType.Player)
                {
                    ob.Attacked(Caster, PvPValue, DefenceType.MAC, false);
                }
                else
                {
                    ob.Attacked(Caster, Value, DefenceType.MAC, false);
                }

                if (!ob.Dead && Envir.Random.Next(8) == 0)
                {
                    ob.ApplyPoison(new Poison
                        {
                            Duration  = 5 + Envir.Random.Next(Caster.Freezing),
                            Owner     = Caster,
                            PType     = PoisonType.Slow,
                            TickSpeed = 2000,
                        }, Caster);
                }
            }
            break;

            case Spell.LavaKing:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster && ob.Race != ObjectType.Hero)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (Caster != null && !Caster.ActiveBlizzard)
                {
                    return;
                }
                if (Caster != null)
                {
                    if (!ob.IsAttackTarget(Caster))
                    {
                        return;
                    }
                    byte magicLevel = 0;
                    int  poisonVal  = 2;

                    if (ob.Race == ObjectType.Player)
                    {
                        poisonVal =
                            magicLevel == 0 ? 2 :
                            magicLevel == 1 ? 3 :
                            magicLevel == 2 ? 4 : 6;
                    }
                    else
                    {
                        poisonVal =
                            magicLevel == 0 ? 2 :
                            magicLevel == 1 ? 4 :
                            magicLevel == 2 ? 6 : 8;
                    }
                    if (ob.Race == ObjectType.Player)
                    {
                        ob.Attacked(Caster, PvPValue, DefenceType.MAC, false);
                    }
                    else
                    {
                        ob.Attacked(Caster, Value, DefenceType.MAC, false);
                    }
                    if (!ob.Dead && Envir.Random.Next(8) == 0)
                    {
                        ob.ApplyPoison(new Poison
                            {
                                Duration  = Envir.Random.Next(2, 8),
                                Owner     = Caster,
                                PType     = PoisonType.Burning,
                                TickSpeed = 2000,
                                Value     = poisonVal
                            }, Caster);
                    }
                }
                else if (MobCaster != null)
                {
                    if (!ob.IsAttackTarget(MobCaster))
                    {
                        return;
                    }
                    ob.Attacked(MobCaster, ob.Race == ObjectType.Player ? (int)(Value * 0.75f) : Value, DefenceType.MAC);
                    if (!ob.Dead && Envir.Random.Next(8) == 0)
                    {
                        ob.ApplyPoison(new Poison
                            {
                                Duration  = Envir.Random.Next(2, 8),
                                Owner     = MobCaster,
                                PType     = PoisonType.Burning,
                                TickSpeed = 2000,
                                Value     = ob.Race == ObjectType.Player ? 2 : 4
                            }, Caster);
                    }
                }
                else
                {
                    return;
                }
            }
            break;

            case Spell.MeteorStrike:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster && ob.Race != ObjectType.Hero)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (Caster != null && !Caster.ActiveBlizzard)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }
                if (ob.Race == ObjectType.Player)
                {
                    ob.Attacked(Caster, PvPValue, DefenceType.MAC, false);
                }
                else
                {
                    ob.Attacked(Caster, Value, DefenceType.MAC, false);
                }
            }
            break;

            case Spell.SoulReaper:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster && ob.Race != ObjectType.Hero)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (MobCaster == null)
                {
                    if (Caster == null)
                    {
                        return;
                    }
                    if (ob.IsAttackTarget(Caster))
                    {
                        if (ob.Race == ObjectType.Player)
                        {
                            if (ob.Attacked(Caster, PvPValue, DefenceType.MAC) > 0 &&
                                !ob.Dead && Envir.Random.Next(8) == 0)
                            {
                                ob.ApplyPoison(new Poison
                                    {
                                        Duration  = 3,
                                        Owner     = Caster,
                                        PType     = PoisonType.Frozen,
                                        TickSpeed = 2000
                                    }, Caster);
                            }
                        }
                        else
                        if (ob.Attacked(Caster, Value, DefenceType.MAC) > 0 &&
                            !ob.Dead && Envir.Random.Next(8) == 0)
                        {
                            ob.ApplyPoison(new Poison
                                {
                                    Duration  = 3,
                                    Owner     = Caster,
                                    PType     = PoisonType.Frozen,
                                    TickSpeed = 2000
                                }, Caster);
                        }
                    }
                }
                else
                {
                    if (MobCaster.Master == null)
                    {
                        return;
                    }
                    if (!ob.IsAttackTarget(((PlayerObject)MobCaster.Master)))
                    {
                        return;
                    }
                    ob.Attacked(MobCaster, Value, DefenceType.MAC);
                    if (!ob.Dead && Envir.Random.Next(8) == 0)
                    {
                        ob.ApplyPoison(new Poison
                            {
                                Duration  = 3,
                                Owner     = MobCaster,
                                PType     = PoisonType.Frozen,
                                TickSpeed = 2000,
                            }, MobCaster);
                    }
                }
            }
            break;

            case Spell.ExplosiveTrap:
            {
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                if (!ob.IsAttackTarget(Caster))
                {
                    return;
                }
                if (DetonatedTrap)
                {
                    return;                       //make sure explosion happens only once
                }
                DetonateTrapNow();
                if (ob.Race == ObjectType.Player)
                {
                    ob.Attacked(Caster, PvPValue, DefenceType.MAC, false);
                }
                else
                {
                    ob.Attacked(Caster, Value, DefenceType.MAC, false);
                }
            }
            break;

            case Spell.MapLava:
            case Spell.MapLightning:
            case Spell.MapQuake1:
            case Spell.MapQuake2:
            {
                if (Value == 0)
                {
                    return;
                }
                if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster && ob.Race != ObjectType.Hero)
                {
                    return;
                }
                if (ob.Dead)
                {
                    return;
                }
                ob.Struck(Value, DefenceType.MAC);
            }
            break;

            case Spell.Portal:
            {
                if (ob.Race != ObjectType.Player)
                {
                    return;
                }
                if (Caster != ob && (Caster == null || (Caster.GroupMembers == null) || (!Caster.GroupMembers.Contains((PlayerObject)ob))))
                {
                    return;
                }

                if (ExitMap == null)
                {
                    return;
                }

                MirDirection dir = ob.Direction;

                Point newExit = Functions.PointMove(ExitCoord, dir, 1);

                if (!ExitMap.ValidPoint(newExit))
                {
                    return;
                }

                ob.Teleport(ExitMap, newExit, false);

                Value = Value - 1;

                if (Value < 1)
                {
                    ExpireTime = Envir.Time;
                    return;
                }
            }
            break;
            }
        }