コード例 #1
0
        public void AgroAllMobsInRange()
        {
            for (int d = 0; d <= Info.ViewRange; 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];
                            switch (ob.Race)
                            {
                            case ObjectType.Monster:
                                if (!ob.IsAttackTarget(this))
                                {
                                    continue;
                                }
                                if (ob.Hidden && (!CoolEye || Level < ob.Level))
                                {
                                    continue;
                                }
                                if (((MonsterObject)ob).Info.CoolEye == 100)
                                {
                                    continue;
                                }
                                ob.Target = this;    //Agro the mobs in range - Very simple agro system overwriting mobs target
                                continue;

                            default:
                                continue;
                            }
                        }
                    }
                }
            }
        }
コード例 #2
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);
        }
コード例 #3
0
        private void SpawnQuakes()
        {
            int count    = Envir.Random.Next(1, _raged ? _quakeCount * 2 : _quakeCount);
            int distance = Envir.Random.Next(_quakeSpreadMin, _quakeSpreadMax);

            for (int j = 0; j < CurrentMap.Players.Count; j++)
            {
                Point playerLocation = CurrentMap.Players[j].CurrentLocation;

                for (int i = 0; i < count; i++)
                {
                    Point location = new Point(playerLocation.X + Envir.Random.Next(-distance, distance + 1),
                                               playerLocation.Y + Envir.Random.Next(-distance, distance + 1));

                    if (Envir.Random.Next(10) == 0)
                    {
                        location = playerLocation;
                    }

                    if (!CurrentMap.ValidPoint(location))
                    {
                        continue;
                    }

                    SpellObject spellObj = null;

                    switch (Envir.Random.Next(2))
                    {
                    case 0:
                    {
                        spellObj = new SpellObject
                        {
                            Spell           = Spell.MapQuake1,
                            Value           = Envir.Random.Next(Envir.Random.Next(MinDC, MaxDC)),
                            ExpireTime      = Envir.Time + (2000),
                            TickSpeed       = 500,
                            Caster          = null,
                            CurrentLocation = location,
                            CurrentMap      = CurrentMap,
                            Direction       = MirDirection.Up
                        };
                    }
                    break;

                    case 1:
                    {
                        spellObj = new SpellObject
                        {
                            Spell           = Spell.MapQuake2,
                            Value           = Envir.Random.Next(Envir.Random.Next(MinDC, MaxDC)),
                            ExpireTime      = Envir.Time + (2000),
                            TickSpeed       = 500,
                            Caster          = null,
                            CurrentLocation = location,
                            CurrentMap      = CurrentMap,
                            Direction       = MirDirection.Up
                        };
                    }
                    break;
                    }

                    DelayedAction action = new DelayedAction(DelayedType.Spawn, Envir.Time + Envir.Random.Next(5000), spellObj);
                    CurrentMap.ActionList.Add(action);
                }
            }
        }
コード例 #4
0
        protected override void ProcessAI()
        {
            if (!Dead && Envir.Time > VisibleTime)
            {
                VisibleTime = Envir.Time + 2000;

                if (!Visible)
                {
                    //判断附近7格内有有没玩家,有玩家就移动到玩家生活,显现出来,直接释放毒液
                    Point rp = CurrentMap.RandomValidPoint(CurrentLocation.X, CurrentLocation.Y, 3);

                    List <MapObject> list = CurrentMap.getMapObjects(CurrentLocation.X, CurrentLocation.Y, 7);
                    for (int o = 0; o < list.Count; o++)
                    {
                        MapObject ob = list[o];
                        if (ob.Race == ObjectType.Player)
                        {
                            if (!ob.IsAttackTarget(this))
                            {
                                continue;
                            }
                            if (CurrentMap.ValidPoint(ob.Back))
                            {
                                rp = ob.Back;
                                break;
                            }
                            if (CurrentMap.ValidPoint(ob.Front))
                            {
                                rp = ob.Front;
                                break;
                            }
                        }
                    }

                    //CurrentLocation = rp;
                    SetHP(MaxHP);
                    Visible  = true;
                    CellTime = Envir.Time + 500;
                    Broadcast(GetInfo());
                    Broadcast(new S.ObjectShow {
                        ObjectID = ObjectID
                    });
                    ActionTime = Envir.Time + 1000;
                    Teleport(CurrentMap, rp, false);
                    show = true;
                }
                //隐身5-10秒,满血
                if (Visible && !hide && HP < MaxHP / 2)
                {
                    Visible     = false;
                    VisibleTime = Envir.Time + RandomUtils.Next(5, 10) * 1000;
                    Broadcast(new S.ObjectHide {
                        ObjectID = ObjectID
                    });

                    hide = true;
                }
            }

            base.ProcessAI();
        }
コード例 #5
0
ファイル: MapObject.cs プロジェクト: Fenarir/mir2
        public void BroadcastHealthChange()
        {
            if (Race != ObjectType.Player && Race != ObjectType.Monster)
            {
                return;
            }

            byte   time = Math.Min(byte.MaxValue, (byte)Math.Max(5, (RevTime - Envir.Time) / 1000));
            Packet p    = new S.ObjectHealth {
                ObjectID = ObjectID, Percent = PercentHealth, Expire = time
            };

            if (Envir.Time < RevTime)
            {
                CurrentMap.Broadcast(p, CurrentLocation);
                return;
            }

            if (Race == ObjectType.Monster && !AutoRev && Master == null)
            {
                return;
            }

            if (Race == ObjectType.Player)
            {
                if (GroupMembers != null) //Send HP to group
                {
                    for (int i = 0; i < GroupMembers.Count; i++)
                    {
                        PlayerObject member = GroupMembers[i];

                        if (this == member)
                        {
                            continue;
                        }
                        if (member.CurrentMap != CurrentMap || !Functions.InRange(member.CurrentLocation, CurrentLocation, Globals.DataRange))
                        {
                            continue;
                        }
                        member.Enqueue(p);
                    }
                }

                return;
            }

            if (Master != null && Master.Race == ObjectType.Player)
            {
                PlayerObject player = (PlayerObject)Master;

                player.Enqueue(p);

                if (player.GroupMembers != null) //Send pet HP to group
                {
                    for (int i = 0; i < player.GroupMembers.Count; i++)
                    {
                        PlayerObject member = player.GroupMembers[i];

                        if (player == member)
                        {
                            continue;
                        }

                        if (member.CurrentMap != CurrentMap || !Functions.InRange(member.CurrentLocation, CurrentLocation, Globals.DataRange))
                        {
                            continue;
                        }
                        member.Enqueue(p);
                    }
                }
            }


            if (EXPOwner != null && EXPOwner.Race == ObjectType.Player)
            {
                PlayerObject player = (PlayerObject)EXPOwner;

                if (player.IsMember(Master))
                {
                    return;
                }

                player.Enqueue(p);

                if (player.GroupMembers != null)
                {
                    for (int i = 0; i < player.GroupMembers.Count; i++)
                    {
                        PlayerObject member = player.GroupMembers[i];

                        if (player == member)
                        {
                            continue;
                        }
                        if (member.CurrentMap != CurrentMap || !Functions.InRange(member.CurrentLocation, CurrentLocation, Globals.DataRange))
                        {
                            continue;
                        }
                        member.Enqueue(p);
                    }
                }
            }
        }
コード例 #6
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);
        }
コード例 #7
0
        public override void Process()
        {
            RefreshNameColour();

            if (Target != null && (Target.CurrentMap != CurrentMap || !Functions.InRange(CurrentLocation, Target.CurrentLocation, Globals.DataRange)))
            {
                Target = null;
            }

            if (Dead && Envir.Time >= DeadTime)
            {
                CurrentMap.RemoveObject(this);
                if (Master != null)
                {
                    Master.Pets.Remove(this);
                    Master = null;
                }

                Despawn();
                return;
            }

            if (Fullness == 0)//unable to operate with food level 0
            {
                CreatureTimedSay("I'm starving!!.");
                return;
            }

            DecreaseFullness(1);                                   //Decrease Feeding

            if (doDelayedPickup && Target != null && DoTargetList) //delayed pickup
            {
                if (Envir.Time > delayedpickupTicker)
                {
                    PickupAllItems(Target.CurrentLocation);
                    Target          = null;
                    doDelayedPickup = false;
                    if (TargetList.Count > 0)
                    {
                        TargetList.RemoveAt(0);
                    }
                    if (TargetList.Count == 0)
                    {
                        DoTargetList          = false;
                        TargetListTargetClean = false;
                        return;
                    }
                }
                else
                {
                    return;
                }
            }

            if (DoTargetList)//Semi-auto | mouse pickup
            {
                ProcessTargetList();
                return;
            }

            if (Target == null)
            {
                shortcheck = true;
                FindTarget();
            }

            if (Target == null)
            {
                ProcessAI();
            }
            else
            {
                ProcessTarget();
            }

            //ProcessBuffs();
            ProcessRegen();
        }
コード例 #8
0
        public override void Process()
        {
            if (Caster != null && Caster.Node == null)
            {
                Caster = null;
            }

            if (Envir.Time > ExpireTime || ((Spell == Spell.FireWall || Spell == Spell.ExplosiveTrap) && 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.ReincarnationReady      = true;
                    Caster.ReincarnationExpireTime = Envir.Time + 6000;
                }

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

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

            if (Spell == Spell.ExplosiveTrap && FindObject(Caster.ObjectID, 20) == null && Caster != null)//ArcherSpells - Explosive Trap
            {
                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;
            }
        }
コード例 #9
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }
            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            int damage   = GetAttackPower(MinDC, MaxDC);
            int distance = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
            int delay    = distance * 50 + 750; //50 MS per Step

            if (distance == 3)
            {
                attckType = 1;
            }
            else
            {
                if (HP < MaxHP / 2 && RandomUtils.Next(10) < 5)
                {
                    attckType = 2;
                }
                if (RandomUtils.Next(10) < 3)
                {
                    attckType = 1;
                }
            }

            DelayedAction action;

            //砸地板
            if (attckType == 0)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0
                });
                List <MapObject> list = CurrentMap.getMapObjects(Target.CurrentLocation.X, Target.CurrentLocation.Y, 2);
                for (int o = 0; o < list.Count; o++)
                {
                    MapObject ob = list[o];
                    if (ob.Race == ObjectType.Monster || ob.Race == ObjectType.Player)
                    {
                        if (!ob.IsAttackTarget(this))
                        {
                            continue;
                        }
                        action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage, DefenceType.MAC);
                        ActionList.Add(action);
                    }
                }
            }
            //射线
            if (attckType == 1)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                });

                action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage * 2, DefenceType.ACAgility);
                ActionList.Add(action);
            }
            //回血
            if (attckType == 2)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2
                });

                List <MapObject> list = CurrentMap.getMapObjects(CurrentLocation.X, CurrentLocation.Y, 2);
                for (int o = 0; o < list.Count; o++)
                {
                    MapObject ob = list[o];
                    if (ob.Race == ObjectType.Monster || ob.Race == ObjectType.Player)
                    {
                        if (!ob.IsAttackTarget(this))
                        {
                            continue;
                        }
                        action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage, DefenceType.MAC);
                        ActionList.Add(action);
                    }
                }
                //回血
                ChangeHP(RandomUtils.Next((int)MaxHP / 5, (int)MaxHP / 2));
            }
            ShockTime  = 0;
            ActionTime = Envir.Time + 500;
            AttackTime = Envir.Time + (AttackSpeed);
        }
コード例 #10
0
        // Choose next unit for orders. If all units ended turn, update cities.
        public void ChooseNextUnit()
        {
            var units = _activeCiv.Units.Where(u => !u.Dead).ToList();

            //Look for units on this square or neighbours of this square
            var nextUnit = ActiveTile.UnitsHere.FirstOrDefault(u => u.AwaitingOrders) ?? CurrentMap
                           .Neighbours(ActiveTile)
                           .SelectMany(t => t.UnitsHere.Where(u => u.Owner == _activeCiv && u.AwaitingOrders))
                           .FirstOrDefault();

            nextUnit ??= units.FirstOrDefault(u => u.AwaitingOrders);

            ActiveUnit = nextUnit;

            // End turn if no units awaiting orders
            if (nextUnit == null)
            {
                var anyUnitsMoved = units.Any(u => u.MovePointsLost > 0);
                if ((!anyUnitsMoved || Options.AlwaysWaitAtEndOfTurn) && _activeCiv.PlayerType != PlayerType.AI)
                {
                    OnPlayerEvent?.Invoke(null, new PlayerEventArgs(PlayerEventType.WaitingAtEndOfTurn, _activeCiv.Id));
                }
                else
                {
                    if (ProcessEndOfTurn())
                    {
                        ChoseNextCiv();
                        return;
                    }
                }
            }
            //
            //
            // if (_activeUnit != null)
            // {
            //     TriggerUnitEvent(new ActivationEventArgs(_activeUnit, false, false));
            // }
        }
コード例 #11
0
 public override bool SpawnMinion(MonsterObject mob)
 {
     return(mob.Spawn(CurrentMap.Info, CurrentMap.GetRandomLocation(CurrentLocation, 5)));
 }
コード例 #12
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }
            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            int damage   = GetAttackPower(MinDC, MaxDC);
            int distance = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
            int delay    = distance * 50 + 550; //50 MS per Step
            int rd       = RandomUtils.Next(100);

            //
            if (distance > 2)
            {
                if (rd < 60)
                {
                    attType = 3;
                }
                else
                {
                    attType = 4;
                }
            }
            else
            {
                if (rd < 40)
                {
                    attType = 1;
                }
                else if (rd < 70)
                {
                    attType = 3;
                }
                else
                {
                    attType = 4;
                }
            }

            if (distance == 1 && RandomUtils.Next(3) == 0)
            {
                attType = 0;
            }
            //如果中毒了,几率解毒
            if (PoisonList != null && PoisonList.Count > 0 && RandomUtils.Next(5) == 0)
            {
                attType = 2;
            }

            //如果血量过少,则加血哦
            if (HP < MaxHP / 3 && RandomUtils.Next(5) == 0)
            {
                attType = 2;
            }

            DelayedAction    action = null;
            List <MapObject> listtargets;

            switch (attType)
            {
            case 0:
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0
                });
                action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.ACAgility);
                ActionList.Add(action);
                break;

            case 1:
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                });
                //抖花粉 封印技能
                listtargets = CurrentMap.getMapObjects(CurrentLocation.X, CurrentLocation.Y, 2);
                for (int o = 0; o < listtargets.Count; o++)
                {
                    MapObject ob = listtargets[o];
                    if (ob.Race == ObjectType.Monster || ob.Race == ObjectType.Player)
                    {
                        if (!ob.IsAttackTarget(this))
                        {
                            continue;
                        }
                        action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage, DefenceType.MAC);
                        ActionList.Add(action);
                        if (RandomUtils.Next(Settings.PoisonResistWeight) >= ob.PoisonResist)
                        {
                            ob.ApplyPoison(new Poison
                            {
                                Owner     = this,
                                Duration  = RandomUtils.Next(5, 15),
                                PType     = PoisonType.Stun,
                                Value     = damage,
                                TickSpeed = 1000
                            }, this);
                        }
                    }
                }
                break;

            case 2:
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2
                });
                //血量恢复
                ChangeHP(damage * 3);
                //解除中毒
                PoisonList.Clear();
                break;

            case 3:
                //放追踪技能
                Broadcast(new S.ObjectRangeAttack {
                    ObjectID = ObjectID, Direction = Direction, TargetID = Target.ObjectID, Location = CurrentLocation, Type = 0
                });
                action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.MAC);
                ActionList.Add(action);
                break;

            case 4:
                Broadcast(new S.ObjectRangeAttack {
                    ObjectID = ObjectID, Direction = Direction, TargetID = Target.ObjectID, Location = CurrentLocation, Type = 1
                });
                listtargets = CurrentMap.getMapObjects(Target.CurrentLocation.X, Target.CurrentLocation.Y, 2);
                for (int o = 0; o < listtargets.Count; o++)
                {
                    MapObject ob = listtargets[o];
                    if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                    {
                        continue;
                    }
                    if (!ob.IsAttackTarget(this))
                    {
                        continue;
                    }
                    action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage * 2 / 3, DefenceType.MAC);
                    ActionList.Add(action);
                    if (RandomUtils.Next(Settings.PoisonResistWeight) >= ob.PoisonResist && RandomUtils.Next(100) < 50)
                    {
                        ob.ApplyPoison(new Poison
                        {
                            Owner     = this,
                            Duration  = RandomUtils.Next(4, 8),
                            PType     = PoisonType.Frozen,
                            Value     = damage,
                            TickSpeed = 1000
                        }, this);
                    }
                }
                break;
            }


            ShockTime  = 0;
            ActionTime = Envir.Time + 500;
            AttackTime = Envir.Time + (AttackSpeed);
        }
コード例 #13
0
        public void CheckVisible(PlayerObject Player, bool Force = false)
        {
            VisibleLog.TryGetValue(Player.Info.Index, out bool canSee);

            if (Conq != null && Conq.WarIsOn)
            {
                if (canSee)
                {
                    CurrentMap.Broadcast(new S.ObjectRemove {
                        ObjectID = ObjectID
                    }, CurrentLocation, Player);
                }
                VisibleLog[Player.Info.Index] = false;
                return;
            }

            if (Info.FlagNeeded != 0 && !Player.Info.Flags[Info.FlagNeeded])
            {
                if (canSee)
                {
                    CurrentMap.Broadcast(new S.ObjectRemove {
                        ObjectID = ObjectID
                    }, CurrentLocation, Player);
                }
                VisibleLog[Player.Info.Index] = false;
                return;
            }

            if (Info.MinLev != 0 && Player.Level < Info.MinLev || Info.MaxLev != 0 && Player.Level > Info.MaxLev)
            {
                if (canSee)
                {
                    CurrentMap.Broadcast(new S.ObjectRemove {
                        ObjectID = ObjectID
                    }, CurrentLocation, Player);
                }
                VisibleLog[Player.Info.Index] = false;
                return;
            }

            if (Info.ClassRequired != "" && Player.Class.ToString() != Info.ClassRequired)
            {
                if (canSee)
                {
                    CurrentMap.Broadcast(new S.ObjectRemove {
                        ObjectID = ObjectID
                    }, CurrentLocation, Player);
                }
                VisibleLog[Player.Info.Index] = false;
                return;
            }

            if (Visible && !canSee)
            {
                CurrentMap.Broadcast(GetInfo(), CurrentLocation, Player);
            }
            else if (Force && Visible)
            {
                CurrentMap.Broadcast(GetInfo(), CurrentLocation, Player);
            }

            VisibleLog[Player.Info.Index] = true;
        }
コード例 #14
0
ファイル: WoomaTaurus.cs プロジェクト: scriptkitz/mir2
        protected override void ProcessAI()
        {
            if (Dead)
            {
                return;
            }

            if (_madTime > 0 && Envir.Time > _madTime)
            {
                _madTime = 0;
                RefreshAll();
            }

            if (Envir.Time > _teleTime)
            {
                _teleTime = Envir.Time + TeleDelay;

                int          count = 0;
                MirDirection dir   = Direction;

                for (int i = 0; i < 8; i++)
                {
                    Point location = Functions.PointMove(CurrentLocation, dir, 1);

                    if (CurrentMap.ValidPoint(location))
                    {
                        Cell cell = CurrentMap.GetCell(location);

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

                        for (int o = 0; o < cell.Objects.Count; o++)
                        {
                            if (!cell.Objects[o].Blocking)
                            {
                                continue;
                            }
                            count++;
                            break;
                        }
                    }
                    else
                    {
                        count++;
                    }

                    dir = Functions.NextDir(dir);
                }

                if (count >= 5)
                {
                    Target = null;
                    TeleportRandom(4, 0);
                }
            }


            if (Stats[Stat.HP] >= 7)
            {
                byte stage = (byte)(HP / (Stats[Stat.HP] / 7));

                if (stage < _stage)
                {
                    _madTime    = Envir.Time + 8000;
                    MoveSpeed   = 400;
                    AttackSpeed = 500;
                }
                _stage = stage;
            }


            base.ProcessAI();
        }
コード例 #15
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);
                                    if (item.Item.Info.Grade >= ItemFilter.PickupGrade)
                                    {
                                        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;
        }
コード例 #16
0
        public override void Die()
        {
            if (SEnvir.Random.Next(15) == 0)
            {
                for (int i = CurrentMap.Objects.Count - 1; i >= 0; i--)
                {
                    MonsterObject mob = CurrentMap.Objects[i] as MonsterObject;

                    if (mob == null)
                    {
                        continue;
                    }

                    if (mob.PetOwner != null)
                    {
                        continue;
                    }

                    if (mob is Guard || mob is ChristmasMonster)
                    {
                        continue;
                    }

                    if (mob.Dead || mob.MoveDelay == 0 || !mob.CanMove)
                    {
                        continue;
                    }

                    if (mob.Target != null)
                    {
                        continue;
                    }

                    if (mob.Level >= 300)
                    {
                        continue;
                    }

                    mob.Teleport(CurrentMap, CurrentMap.GetRandomLocation(CurrentLocation, 15));
                }
            }

            if (EXPOwner != null)
            {
                List <MapObject> targets = EXPOwner.GetTargets(CurrentMap, CurrentLocation, 18);

                foreach (MapObject mapObject in targets)
                {
                    if (mapObject.Race != ObjectType.Monster)
                    {
                        continue;
                    }

                    MonsterObject mob = (MonsterObject)mapObject;

                    if (mob.MonsterInfo.IsBoss || mob.Dead)
                    {
                        continue;
                    }

                    if (mob.EXPOwner != null && mob.EXPOwner != EXPOwner)
                    {
                        continue;
                    }

                    if (mob is ChristmasMonster)
                    {
                        continue;
                    }

                    mob.ExtraExperienceRate = Math.Max(mob.ExtraExperienceRate, ExtraExperienceRate);
                    mob.EXPOwner            = EXPOwner;
                    mob.SetHP(0);
                }
            }


            base.Die();
        }
コード例 #17
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))
                                {
                                    if (item.Item.Info.Grade >= ItemFilter.PickupGrade)
                                    {
                                        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);
        }
コード例 #18
0
ファイル: ManTree.cs プロジェクト: ValhallaMir/mir2
        protected override void CompleteAttack(IList <object> data)
        {
            MapObject   target             = (MapObject)data[0];
            int         damage             = (int)data[1];
            DefenceType defence            = (DefenceType)data[2];
            bool        halfMoonAttack     = (bool)data[3];
            bool        boulderSmashAttack = (bool)data[4];

            if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null)
            {
                return;
            }

            if (halfMoonAttack)
            {
                MirDirection dir = Functions.PreviousDir(Direction);

                for (int i = 0; i < 4; i++)
                {
                    Point halfMoontarget = Functions.PointMove(CurrentLocation, dir, 1);
                    dir = Functions.NextDir(dir);

                    if (!CurrentMap.ValidPoint(halfMoontarget))
                    {
                        continue;
                    }

                    Cell cell = CurrentMap.GetCell(halfMoontarget);
                    if (cell.Objects == null)
                    {
                        continue;
                    }

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

                        ob.Attacked(this, damage, defence);
                        break;
                    }
                }

                return;
            }

            if (boulderSmashAttack)
            {
                List <MapObject> targets = FindAllTargets(1, target.CurrentLocation);
                if (targets.Count == 0)
                {
                    return;
                }

                for (int i = 0; i < targets.Count; i++)
                {
                    if (targets[i].IsAttackTarget(this))
                    {
                        if (targets[i].Attacked(this, damage, defence) <= 0)
                        {
                            continue;
                        }
                        PoisonTarget(targets[Envir.Random.Next(targets.Count)], 5, 5, PoisonType.Stun);
                    }
                }

                return;
            }

            target.Attacked(this, damage, defence);
        }
コード例 #19
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).Enqueue(new S.IntelligentCreaturePickup {
                            ObjectID = ObjectID
                        });
                    }

                    ((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;
                }
            }
        }
コード例 #20
0
        public override void DoTurn()
        {
            try {
                base.DoTurn();

                CheckTile(false);

                if (AuxUtils.Chance(25))
                {
                    int idx;
                    if (Size == 1)
                    {
                        idx = 0;
                    }
                    else
                    {
                        idx = RandomHelper.GetRandom(Size);
                    }

                    IvySegment seg = (IvySegment)GetSegment(idx);

                    if (dbIvyBranches[seg.Id].Kind == IvyBranches.ibkLeaf)
                    {
                        idx = GetBranchByDir(seg.EntryDir, new IvyBranches(IvyBranches.ibkBranch));

                        if (idx >= 0)
                        {
                            Directions avEntries = new Directions(dbIvyBranches[idx].Entries);
                            avEntries.Exclude(seg.EntryDir);

                            seg.Id = idx;
                            seg.AvailableEntries = avEntries;
                            seg.ImageIndex       = idx;
                        }
                    }

                    int        cnt     = 0;
                    List <int> entries = new List <int>();

                    for (int dir = Directions.DtNorth; dir <= Directions.DtEast; dir++)
                    {
                        if (seg.AvailableEntries.Contains(dir))
                        {
                            cnt++;
                            entries.Add(dir);
                        }
                    }

                    if (cnt == 0)
                    {
                        return;
                    }

                    idx = RandomHelper.GetRandom(cnt);
                    int bdir = entries[idx];
                    int nx   = seg.X + Directions.Data[bdir].DX;
                    int ny   = seg.Y + Directions.Data[bdir].DY;
                    seg.AvailableEntries.Exclude(bdir);

                    int i = FindByPos(nx, ny);

                    if (!CurrentMap.IsBarrier(nx, ny) && i < 0)
                    {
                        int opposite = Directions.Data[bdir].Opposite;
                        idx = GetBranchByDir(opposite, new IvyBranches(IvyBranches.ibkBranch, IvyBranches.ibkLeaf));
                        if (idx >= 0)
                        {
                            Directions avEntries = new Directions(dbIvyBranches[idx].Entries);
                            avEntries.Exclude(opposite);

                            IvySegment newSeg = (IvySegment)Add();
                            newSeg.X                = nx;
                            newSeg.Y                = ny;
                            newSeg.Id               = idx;
                            newSeg.EntryDir         = opposite;
                            newSeg.AvailableEntries = avEntries;
                            newSeg.ImageIndex       = idx;
                        }
                    }
                }

                CheckTile(true);
            } catch (Exception ex) {
                Logger.Write("IvyCreeper.doTurn(): " + ex.Message);
            }
        }
コード例 #21
0
        private void LineAttack(int distance)
        {
            int damage = GetAttackPower(MinDC, MaxDC);

            if (damage == 0)
            {
                return;
            }

            for (int i = 1; i <= distance; i++)
            {
                Point target = Functions.PointMove(CurrentLocation, Direction, i);

                if (target == Target.CurrentLocation)
                {
                    if (Envir.Random.Next(Settings.MagicResistWeight) >= Target.MagicResist)
                    {
                        if (Target.Attacked(this, damage, DefenceType.MACAgility) > 0 && Envir.Random.Next(8) == 0)
                        {
                            int poison = GetAttackPower(MinSC, MaxSC);

                            Target.ApplyPoison(new Poison
                            {
                                Owner     = this,
                                Duration  = 5,
                                PType     = PoisonType.Green,
                                Value     = poison,
                                TickSpeed = 2000
                            }, this);
                        }
                    }
                }
                else
                {
                    if (!CurrentMap.ValidPoint(target))
                    {
                        continue;
                    }

                    Cell cell = CurrentMap.GetCell(target);
                    if (cell.Objects == null)
                    {
                        continue;
                    }

                    for (int o = 0; o < cell.Objects.Count; o++)
                    {
                        MapObject ob = cell.Objects[o];
                        if (ob.Race == ObjectType.Monster || ob.Race == ObjectType.Player)
                        {
                            if (!ob.IsAttackTarget(this))
                            {
                                continue;
                            }
                            if (Envir.Random.Next(Settings.MagicResistWeight) < ob.MagicResist)
                            {
                                continue;
                            }
                            if (ob.Attacked(this, damage, DefenceType.MACAgility) > 0 && Envir.Random.Next(8) == 0)
                            {
                                int poison = GetAttackPower(MinSC, MaxSC);

                                ob.ApplyPoison(new Poison
                                {
                                    Owner     = this,
                                    Duration  = 5,
                                    PType     = PoisonType.Green,
                                    Value     = poison,
                                    TickSpeed = 2000
                                }, this);
                            }
                        }
                        else
                        {
                            continue;
                        }

                        break;
                    }
                }
            }
        }
コード例 #22
0
ファイル: Unit.cs プロジェクト: rio900/voins
        public IUnit RemoveUnit(IUnit demagedUnit)
        {
            Dead       = true;
            IsUnitStun = false;

            IUnit returnUnit = this;

            Player player = demagedUnit as Player;

            if (player == null && demagedUnit is Unit)
            {
                player = (demagedUnit as Unit).MasterPlayer;
            }

            if (player != null)
            {
                player.GetAward(this);

                if (this.GameObject.EnumCallType == EnumCallType.UnitBlock)
                {
                    player.StatisticData.BlockKills += 1;
                }
                if (this.GameObject.EnumCallType == EnumCallType.Unit)
                {
                    player.StatisticData.MobKills += 1;
                }
            }

            var call = CurrentMap.Calls.Single(p => p.IndexLeft == PositionX && p.IndexTop == PositionY);

            call.IUnits.Remove(this);
            if (!call.IUnits.Any())
            {
                call.Used = false;
            }
            CurrentMap.GameObjectInCall.Remove(this.GameObject);

            #region Отображение предмета на месте убитого юнита
            if (this.NItem != null)
            {
                ItemClass item = this.NItem;
                call.Item.Add(item);
                item.PositionX = PositionX;
                item.PositionY = PositionY;
                item.ItemPosition();
                item.View.ApplayMargin(new Thickness(8));
                CurrentMap.MapCanvas.Children.Add(item.View);

                ///Тут будет анимироватся
                CurrentMap.MapCanvas.Children.Remove(this.GameObject.View);
                returnUnit = this;
            }
            #endregion
            if (DeadEvent != null)
            {
                DeadEvent(this, null);
            }

            if (this.GameObject.EnumCallType == EnumCallType.UnitBlock &&
                CurrentMap.BlockBonusGame &&
                player != null)
            {
                int bonusGamePoint = CurrentMap.CheckNumber(this);
                player.PlayerGamePoint = NGamePoint + bonusGamePoint;
            }
            // else
            ///Тут будет анимироватся
            CurrentMap.MapCanvas.Children.Remove(this.GameObject.View);

            foreach (var item in this.Spells)
            {
                IMoveSpell itemMove = item as IMoveSpell;
                if (itemMove != null)
                {
                    itemMove.StopMoveSpell();
                }
            }

            if (this.AI != null)
            {
                this.AI.StopAI();
                this.AI = null;
            }
            DeleteUnit();

            UnitGenerator.Soul(demagedUnit, this);

            return(returnUnit);
        }
コード例 #23
0
ファイル: MapObject.cs プロジェクト: Fenarir/mir2
        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;
                return;
            }

            Buffs.Add(b);
        }
コード例 #24
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }
            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            int           damage   = GetAttackPower(MinDC, MaxDC);
            int           distance = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
            int           delay    = distance * 50 + 500; //50 MS per Step
            DelayedAction action   = null;

            if (RandomUtils.Next(100) < 65 && distance < 3)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0
                });
                List <MapObject> listtargets = CurrentMap.getMapObjects(CurrentLocation.X, CurrentLocation.Y, 2);
                for (int o = 0; o < listtargets.Count; o++)
                {
                    MapObject ob = listtargets[o];
                    if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                    {
                        continue;
                    }
                    if (!ob.IsAttackTarget(this))
                    {
                        continue;
                    }
                    action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage, DefenceType.MAC);
                    ActionList.Add(action);

                    if (RandomUtils.Next(Settings.PoisonResistWeight) >= ob.PoisonResist && RandomUtils.Next(100) < 40)
                    {
                        ob.ApplyPoison(new Poison {
                            Owner = this, Duration = damage / 10, PType = PoisonType.Green, Value = damage / 10, TickSpeed = 2000
                        }, this);
                    }
                }
            }
            else
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                });
                List <MapObject> listtargets = CurrentMap.getMapObjects(CurrentLocation.X, CurrentLocation.Y, 3);
                for (int o = 0; o < listtargets.Count; o++)
                {
                    MapObject ob = listtargets[o];
                    if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                    {
                        continue;
                    }
                    if (!ob.IsAttackTarget(this))
                    {
                        continue;
                    }
                    action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage * 3 / 2, DefenceType.MAC);
                    ActionList.Add(action);
                    if (RandomUtils.Next(Settings.PoisonResistWeight) >= ob.PoisonResist && RandomUtils.Next(100) < 40)
                    {
                        ob.ApplyPoison(new Poison {
                            Owner = this, Duration = damage / 10, PType = PoisonType.Green, Value = damage / 5, TickSpeed = 2000
                        }, this);
                    }
                }
            }


            ShockTime  = 0;
            ActionTime = Envir.Time + 500;
            AttackTime = Envir.Time + (AttackSpeed);
        }
コード例 #25
0
ファイル: ZumaMonster.cs プロジェクト: zhaokai1982/mir2
        public override bool Walk(MirDirection dir)
        {
            if (!CanMove)
            {
                return(false);
            }

            Point location = Functions.PointMove(CurrentLocation, dir, 1);

            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 (AvoidFireWall && ob.Race == ObjectType.Spell)
                    {
                        if (((SpellObject)ob).Spell == Spell.FireWall)
                        {
                            return(false);
                        }
                    }

                    if (!ob.Blocking)
                    {
                        continue;
                    }

                    return(false);
                }
            }

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

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

            if (Hidden)
            {
                RemoveBuff(BuffType.Hiding);
            }

            CellTime   = Envir.Time + 500;
            ActionTime = Envir.Time + 300;
            MoveTime   = Envir.Time + MoveSpeed;

            if (MoveTime > AttackTime)
            {
                AttackTime = MoveTime;
            }

            InSafeZone = CurrentMap.GetSafeZone(CurrentLocation) != null;

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

            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(true);
        }
コード例 #26
0
ファイル: ManectricBlest.cs プロジェクト: scriptkitz/mir2
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);

            if (_attackCount >= 5)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2
                });

                int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);

                List <MapObject> targets = FindAllTargets(3, CurrentLocation);

                for (int i = 0; i < targets.Count; i++)
                {
                    targets[i].Attacked(this, damage, DefenceType.MAC);

                    if (Envir.Random.Next(Settings.PoisonResistWeight) >= targets[i].Stats[Stat.PoisonResist])
                    {
                        if (Envir.Random.Next(5) == 0)
                        {
                            targets[i].ApplyPoison(new Poison {
                                PType = PoisonType.Frozen, Duration = 5, TickSpeed = 1000
                            }, this);
                        }
                    }
                }

                _attackCount = 0;

                return;
            }

            switch (Envir.Random.Next(3))
            {
            case 0:
            case 1:
                _attackCount++;
                base.Attack();
                break;

            case 2:
            {
                int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);

                Broadcast(new S.ObjectAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                    });

                MirDirection dir = Functions.PreviousDir(Direction);
                Point        tar;
                Cell         cell;

                for (int i = 0; i < 8; i++)
                {
                    tar = Functions.PointMove(CurrentLocation, dir, 1);
                    dir = Functions.NextDir(dir);
                    if (tar == Front)
                    {
                        continue;
                    }

                    if (!CurrentMap.ValidPoint(tar))
                    {
                        continue;
                    }

                    cell = CurrentMap.GetCell(tar);

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

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

                        ob.Attacked(this, damage, DefenceType.Agility);
                        break;
                    }
                }
                break;
            }
            }

            ActionTime = Envir.Time + 300;
            AttackTime = Envir.Time + AttackSpeed;
            ShockTime  = 0;
        }
コード例 #27
0
ファイル: OrcMutant.cs プロジェクト: coolzoom/mir2-master
        private void StunAndRepulse(int dmg)
        {
            int col = 5;
            int row = 3;

            List <MapObject> TargetsList = new List <MapObject>();

            Point[] loc = new Point[col]; //0 = left 1 = center 2 = right
            loc[0] = Functions.PointMove(CurrentLocation, Functions.PreviousDir(Direction), 1);
            loc[1] = Functions.PointMove(CurrentLocation, Direction, 1);
            loc[2] = Functions.PointMove(CurrentLocation, Functions.NextDir(Direction), 1);
            loc[3] = Functions.PointMove(loc[0], Functions.PreviousDir(Direction), 1);
            loc[4] = Functions.PointMove(loc[2], Functions.NextDir(Direction), 1);

            for (int i = 0; i < col; i++)
            {
                Point startPoint = loc[i];
                for (int j = 0; j < row; j++)
                {
                    Point hitPoint = Functions.PointMove(startPoint, Direction, j);

                    if (!CurrentMap.ValidPoint(hitPoint))
                    {
                        continue;
                    }

                    Cell cell = CurrentMap.GetCell(hitPoint);

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

                    for (int k = 0; k < cell.Objects.Count; k++)
                    {
                        MapObject target = cell.Objects[k];
                        switch (target.Race)
                        {
                        case ObjectType.Monster:
                        case ObjectType.Player:
                        case ObjectType.Hero:
                            //Only targets
                            if (target.IsAttackTarget(this))
                            {
                                DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, target, dmg, DefenceType.MAC);
                                ActionList.Add(action);

                                TargetsList.Add(target);
                            }
                            break;
                        }
                    }
                }
            }

            foreach (var t in TargetsList)
            {
                t.Pushed(this, Direction, 2 + Envir.Random.Next(4));
                if (Envir.Random.Next(Settings.PoisonResistWeight) >= t.PoisonResist)
                {
                    t.ApplyPoison(new Poison {
                        PType = PoisonType.Paralysis, Duration = 3 + Envir.Random.Next(4), TickSpeed = 1000
                    }, this, true);
                }
            }
        }
コード例 #28
0
ファイル: FireBird.cs プロジェクト: mrgreaper/mir3insanity
        public override void LineAoE(int distance, int min, int max, MagicType magic, Element element, MirDirection dir)
        {
            List <uint>  targetIDs = new List <uint>();
            List <Point> locations = new List <Point>();

            Broadcast(new S.ObjectMagic {
                ObjectID = ObjectID, Direction = dir, CurrentLocation = CurrentLocation, Cast = true, Type = magic, Targets = targetIDs, Locations = locations, AttackElement = Element.None
            });

            UpdateAttackTime();


            for (int d = min; d <= max; d++)
            {
                MirDirection direction = Functions.ShiftDirection(dir, d);

                for (int i = 1; i <= distance; i++)
                {
                    Point location = Functions.Move(CurrentLocation, direction, i);
                    Cell  cell     = CurrentMap.GetCell(location);

                    if (cell == null)
                    {
                        continue;
                    }

                    locations.Add(cell.Location);

                    if (cell.Objects != null)
                    {
                        foreach (MapObject ob in cell.Objects)
                        {
                            if (!CanAttackTarget(ob))
                            {
                                continue;
                            }

                            ActionList.Add(new DelayedAction(
                                               SEnvir.Now.AddMilliseconds(500 + i * 75),
                                               ActionType.DelayAttack,
                                               ob,
                                               GetMC(),
                                               element));
                        }
                    }

                    switch (direction)
                    {
                    case MirDirection.Up:
                    case MirDirection.Right:
                    case MirDirection.Down:
                    case MirDirection.Left:
                        cell = CurrentMap.GetCell(Functions.Move(location, Functions.ShiftDirection(direction, -2)));

                        if (cell == null)
                        {
                            continue;
                        }

                        locations.Add(cell.Location);

                        if (cell?.Objects != null)
                        {
                            foreach (MapObject ob in cell.Objects)
                            {
                                if (!CanAttackTarget(ob))
                                {
                                    continue;
                                }

                                ActionList.Add(new DelayedAction(
                                                   SEnvir.Now.AddMilliseconds(500 + i * 75),
                                                   ActionType.DelayAttack,
                                                   ob,
                                                   GetMC(),
                                                   element));
                            }
                        }
                        cell = CurrentMap.GetCell(Functions.Move(location, Functions.ShiftDirection(direction, 2)));

                        if (cell == null)
                        {
                            continue;
                        }

                        locations.Add(cell.Location);

                        if (cell?.Objects != null)
                        {
                            foreach (MapObject ob in cell.Objects)
                            {
                                if (!CanAttackTarget(ob))
                                {
                                    continue;
                                }

                                ActionList.Add(new DelayedAction(
                                                   SEnvir.Now.AddMilliseconds(500 + i * 75),
                                                   ActionType.DelayAttack,
                                                   ob,
                                                   GetMC(),
                                                   element));
                            }
                        }
                        break;

                    case MirDirection.UpRight:
                    case MirDirection.DownRight:
                    case MirDirection.DownLeft:
                    case MirDirection.UpLeft:
                        cell = CurrentMap.GetCell(Functions.Move(location, Functions.ShiftDirection(direction, -1)));

                        if (cell == null)
                        {
                            continue;
                        }

                        locations.Add(cell.Location);

                        if (cell?.Objects != null)
                        {
                            foreach (MapObject ob in cell.Objects)
                            {
                                if (!CanAttackTarget(ob))
                                {
                                    continue;
                                }

                                ActionList.Add(new DelayedAction(
                                                   SEnvir.Now.AddMilliseconds(500 + i * 75),
                                                   ActionType.DelayAttack,
                                                   ob,
                                                   GetMC(),
                                                   element));
                            }
                        }
                        cell = CurrentMap.GetCell(Functions.Move(location, Functions.ShiftDirection(direction, 1)));

                        if (cell == null)
                        {
                            continue;
                        }

                        locations.Add(cell.Location);

                        if (cell?.Objects != null)
                        {
                            foreach (MapObject ob in cell.Objects)
                            {
                                if (!CanAttackTarget(ob))
                                {
                                    continue;
                                }

                                ActionList.Add(new DelayedAction(
                                                   SEnvir.Now.AddMilliseconds(500 + i * 75),
                                                   ActionType.DelayAttack,
                                                   ob,
                                                   GetMC(),
                                                   element));
                            }
                        }
                        break;
                    }
                }
            }
        }
コード例 #29
0
ファイル: Player.cs プロジェクト: Furfoxsnakes/DiabloRL_Unity
 private void OnPlayerMove(object sender, ItemMovedEventArgs <IGameObject> e)
 {
     // Engine.E.Map.CalculateFOV(Position, Awareness);
     CurrentMap.CalculateFOV(Position, Stats[StatTypes.AWARENESS]);
 }
コード例 #30
0
ファイル: EditorEngine.cs プロジェクト: oxysoft/PokeSharp
        public void Draw(Microsoft.Xna.Framework.GameTime time)
        {
            if (!Initialized || World == null)
            {
                return;
            }
            if (CurrentMap == null)
            {
                return;
            }
            int w = CurrentMap.Width << 4;
            int h = CurrentMap.Height << 4;

            GraphicsDevice.Clear(new Color(0x2f, 0x2f, 0x2f));
            SpriteBatch batch = World.ViewData.SpriteBatch;

            batch.Begin(Matrix.CreateScale(1));

            SelectionUtil.FillRectangle(World.ViewData.SpriteBatch, Color.White * 0.5f, new Rectangle((int)World.Camera.Location.X, (int)World.Camera.Location.Y, (int)(w * World.Camera.Scale), (int)(h * World.Camera.Scale)));

            CurrentMap.Draw(time);

            if (this.World.Camera.Scale <= 0)
            {
                this.World.Camera.Scale = 1f;
            }

            StateMachine.Draw(time);

            if (Options.Instance.Grid)
            {
                if (CurrentMap != null)
                {
                    //We could draw a rectangle for every Tiles...
                    //Or we could be smart and draw lines for columns and rows!

                    Color c1 = Color.DeepSkyBlue;
                    Color c2 = Color.Black;

                    float trans_white = Options.Instance.GridOpacity;
                    float trans_black = Options.Instance.GridOpacity;

                    //rows
                    for (int y = 0; y < CurrentMap.Height; y++)
                    {
                        SelectionUtil.DrawStraightLine(World.ViewData.SpriteBatch, c1, trans_white, 0, (y << 4), CurrentMap.Width * 16, 1);
                        SelectionUtil.DrawStraightLine(World.ViewData.SpriteBatch, c2, trans_black, 0, (y << 4) + 1, CurrentMap.Width * 16, 1);
                    }

                    //columns
                    for (int x = 0; x < CurrentMap.Width; x++)
                    {
                        SelectionUtil.DrawStraightLine(World.ViewData.SpriteBatch, c1, trans_white, x << 4, 0, 1, CurrentMap.Height << 4);
                        SelectionUtil.DrawStraightLine(World.ViewData.SpriteBatch, c2, trans_black, (x << 4) + 1, 0, 1, CurrentMap.Height << 4);
                    }
                }
            }

            ScreenInterface.Draw(time);
            //batch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise);
            //batch.Draw(renderTarget, new Rectangle(xCam, yCam, (int) (renderTarget.Width * Zoom), (int) (renderTarget.Height * Zoom)), Color.White);
            batch.End();
        }