Exemplo n.º 1
0
        // Pet attacking trainer.
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            byte _masterLevel = attacker.Master.Level; // max 256
            byte _masterMaxMC = attacker.Master.MaxMC; // max 256
            int _total = (_masterLevel * 10) + _masterMaxMC;

            switch (type)
            {
                case DefenceType.ACAgility:
                    attacker.Master.ReceiveChat(damage + " AC Agility Damage inflicted on the trainer by your pet.", ChatType.Trainer);
                    break;
                case DefenceType.AC:
                    attacker.Master.ReceiveChat(damage + " AC Damage inflicted on the trainer by your pet.", ChatType.Trainer);
                    break;
                case DefenceType.MACAgility:
                    attacker.Master.ReceiveChat(damage + " MAC Agility Damage inflicted on the trainer by your pet.", ChatType.Trainer);
                    break;
                case DefenceType.MAC:
                    attacker.Master.ReceiveChat(damage + " MAC Damage inflicted on the trainer by your pet.", ChatType.Trainer);
                    break;
                case DefenceType.Agility:
                    attacker.Master.ReceiveChat(damage + " Agility Damage inflicted on the trainer by your pet.", ChatType.Trainer);
                    break;
            }

            attacker.PetExp((uint)_total);
            return 1;
        }
Exemplo n.º 2
0
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            if (DragonLink)
            {
                if (Envir.DragonSystem.LinkedMonster != null)
                {
                    MonsterObject ob = Envir.DragonSystem.LinkedMonster;
                    if (attacker.Info.AI == 6)
                        EXPOwner = null;

                    else if (attacker.Master != null)
                    {
                        if (!Functions.InRange(attacker.CurrentLocation, attacker.Master.CurrentLocation, Globals.DataRange))
                            ob.EXPOwner = null;
                        else
                        {

                            if (ob.EXPOwner == null || ob.EXPOwner.Dead)
                                ob.EXPOwner = attacker.Master;

                            if (ob.EXPOwner == attacker.Master)
                                ob.EXPOwnerTime = Envir.Time + EXPOwnerDelay;
                        }

                    }
                }
                Envir.DragonSystem.GainExp(Envir.Random.Next(1, 50));
                return 1;
            }

            return 0;
        }
Exemplo n.º 3
0
Arquivo: Wall.cs Projeto: Pete107/Mir2
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            CheckDirection();

            if (!Conquest.WarIsOn) damage = 0;

            return base.Attacked(attacker, damage, type);
        }
Exemplo n.º 4
0
 public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
 {
     if (ChildRock) ParentRock.FirstAttack = false;
     if (!ChildRock && FirstAttack == true)
     {
         Die();
         return 0;
     }
     return base.Attacked(attacker, damage, type);
 }
Exemplo n.º 5
0
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            int armour = 0;

            switch (type)
            {
                case DefenceType.ACAgility:
                    if (Envir.Random.Next(Agility + 1) > attacker.Accuracy) return 0;
                    armour = GetAttackPower(MinAC, MaxAC);
                    break;
                case DefenceType.AC:
                    armour = GetAttackPower(MinAC, MaxAC);
                    break;
                case DefenceType.MACAgility:
                    if (Envir.Random.Next(Agility + 1) > attacker.Accuracy) return 0;
                    armour = GetAttackPower(MinMAC, MaxMAC);
                    break;
                case DefenceType.MAC:
                    armour = GetAttackPower(MinAC, MaxAC);
                    break;
                case DefenceType.Agility:
                    if (Envir.Random.Next(Agility + 1) > attacker.Accuracy) return 0;
                    break;
            }

            if (armour >= damage) return 0;

            ShockTime = 0;

            for (int i = PoisonList.Count - 1; i >= 0; i--)
            {
                if (PoisonList[i].PType != PoisonType.LRParalysis) continue;

                PoisonList.RemoveAt(i);
                OperateTime = 0;
            }

            if (attacker.Info.AI == 6)
                EXPOwner = null;
            else if (attacker.Master != null)
            {
                if (EXPOwner == null || EXPOwner.Dead)
                    EXPOwner = attacker.Master;

                if (EXPOwner == attacker.Master)
                    EXPOwnerTime = Envir.Time + EXPOwnerDelay;

            }

            Broadcast(new S.ObjectStruck { ObjectID = ObjectID, AttackerID = attacker.ObjectID, Direction = Direction, Location = CurrentLocation });

            ChangeHP(-1);
            return 1;
        }
Exemplo n.º 6
0
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            int armour = 0;

            switch (type)
            {
                case DefenceType.ACAgility:
                    if (Envir.Random.Next(Agility + 1) > attacker.Accuracy) return 0;
                    armour = GetDefencePower(MinAC, MaxAC);
                    break;
                case DefenceType.AC:
                    armour = GetDefencePower(MinAC, MaxAC);
                    break;
                case DefenceType.MACAgility:
                    if (Envir.Random.Next(Agility + 1) > attacker.Accuracy) return 0;
                    armour = GetDefencePower(MinMAC, MaxMAC);
                    break;
                case DefenceType.MAC:
                    armour = GetDefencePower(MinAC, MaxAC);
                    break;
                case DefenceType.Agility:
                    if (Envir.Random.Next(Agility + 1) > attacker.Accuracy) return 0;
                    break;
            }

            if (armour >= damage) return 0;

            ShockTime = 0;

            if (attacker.Info.AI == 6)
                EXPOwner = null;
            else if (attacker.Master != null)
            {
                if (EXPOwner == null || EXPOwner.Dead)
                    EXPOwner = attacker.Master;

                if (EXPOwner == attacker.Master)
                    EXPOwnerTime = Envir.Time + EXPOwnerDelay;

            }

            Broadcast(new S.ObjectStruck { ObjectID = ObjectID, AttackerID = attacker.ObjectID, Direction = Direction, Location = CurrentLocation });

            ChangeHP(-1);
            return 1;
        }
Exemplo n.º 7
0
        public void DoSpawn(bool eventSpawn)
        {
            if (!eventSpawn)
            {
                if (Info.EventSpawn || SEnvir.Now < NextSpawn)
                {
                    return;
                }

                if (Info.Delay >= 1000000)
                {
                    TimeSpan timeofDay = TimeSpan.FromMinutes(Info.Delay - 1000000);

                    if (LastCheck.TimeOfDay >= timeofDay || SEnvir.Now.TimeOfDay < timeofDay)
                    {
                        LastCheck = SEnvir.Now;
                        return;
                    }

                    LastCheck = SEnvir.Now;
                }
                else
                {
                    if (Info.Announce)
                    {
                        NextSpawn = SEnvir.Now.AddSeconds(Info.Delay * 60);
                    }
                    else
                    {
                        NextSpawn = SEnvir.Now.AddSeconds(SEnvir.Random.Next(Info.Delay * 60) + Info.Delay * 30);
                    }
                }
            }

            for (int i = AliveCount; i < Info.Count; i++)
            {
                MonsterObject mob = MonsterObject.GetMonster(Info.Monster);

                if (!Info.Monster.IsBoss)
                {
                    if (SEnvir.Now > CurrentMap.HalloweenEventTime && SEnvir.Now <= Config.HalloweenEventEnd)
                    {
                        mob = new HalloweenMonster {
                            MonsterInfo = Info.Monster, HalloweenEventMob = true
                        };
                        CurrentMap.HalloweenEventTime = SEnvir.Now.AddHours(1);
                    }
                    else if (SEnvir.Now > CurrentMap.ChristmasEventTime && SEnvir.Now <= Config.ChristmasEventEnd)
                    {
                        mob = new ChristmasMonster {
                            MonsterInfo = Info.Monster, ChristmasEventMob = true
                        };
                        CurrentMap.ChristmasEventTime = SEnvir.Now.AddMinutes(20);
                    }
                }


                mob.SpawnInfo = this;

                if (!mob.Spawn(Info.Region))
                {
                    mob.SpawnInfo = null;
                    continue;
                }

                if (Info.Announce)
                {
                    if (Info.Delay >= 1000000)
                    {
                        foreach (SConnection con in SEnvir.Connections)
                        {
                            con.ReceiveChat($"{mob.MonsterInfo.MonsterName} has appeared.", MessageType.System);
                        }
                    }
                    else
                    {
                        foreach (SConnection con in SEnvir.Connections)
                        {
                            con.ReceiveChat(string.Format(con.Language.BossSpawn, CurrentMap.Info.Description), MessageType.System);
                        }
                    }
                }

                mob.DropSet = Info.DropSet;
                AliveCount++;
            }
        }
Exemplo n.º 8
0
 public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 9
0
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            int armour = 0;

            switch (type)
            {
            case DefenceType.ACAgility:
                if (Envir.Random.Next(Agility + 1) > attacker.Accuracy)
                {
                    return(0);
                }
                armour = GetAttackPower(MinAC, MaxAC);
                break;

            case DefenceType.AC:
                armour = GetAttackPower(MinAC, MaxAC);
                break;

            case DefenceType.MACAgility:
                if (Envir.Random.Next(Agility + 1) > attacker.Accuracy)
                {
                    return(0);
                }
                armour = GetAttackPower(MinMAC, MaxMAC);
                break;

            case DefenceType.MAC:
                armour = GetAttackPower(MinAC, MaxAC);
                break;

            case DefenceType.Agility:
                if (Envir.Random.Next(Agility + 1) > attacker.Accuracy)
                {
                    return(0);
                }
                break;
            }

            if (armour >= damage)
            {
                return(0);
            }

            ShockTime = 0;

            if (attacker.Info.AI == 6)
            {
                EXPOwner = null;
            }
            else if (attacker.Master != null)
            {
                if (EXPOwner == null || EXPOwner.Dead)
                {
                    EXPOwner = attacker.Master;
                }

                if (EXPOwner == attacker.Master)
                {
                    EXPOwnerTime = Envir.Time + EXPOwnerDelay;
                }
            }

            Broadcast(new S.ObjectStruck {
                ObjectID = ObjectID, AttackerID = attacker.ObjectID, Direction = Direction, Location = CurrentLocation
            });

            ChangeHP(-1);
            return(1);
        }
Exemplo n.º 10
0
 public void SetEggData(string monsterEvolutionRouteId)
 {
     this.eggModelId     = MonsterObject.GetEggModelId(monsterEvolutionRouteId);
     this.monsterModelId = string.Empty;
 }
Exemplo n.º 11
0
        public bool Load()
        {
            try
            {
                MonsterInfo info = Envir.GetMonsterInfo(Info.MonsterName);
                if (info == null)
                {
                    SMain.Enqueue("Failed to load Dragon (bad monster name): " + Info.MonsterName);
                    return(false);
                }
                LinkedMonster = MonsterObject.GetMonster(info);

                Map map = SMain.Envir.GetMapByNameAndInstance(Info.MapFileName);
                if (map == null)
                {
                    SMain.Enqueue("Failed to load Dragon (bad map name): " + Info.MapFileName);
                    return(false);
                }

                if (Info.Location.X > map.Width || Info.Location.Y > map.Height)
                {
                    SMain.Enqueue("Failed to load Dragon (bad map XY): " + Info.MapFileName);
                    return(false);
                }

                if (LinkedMonster.Spawn(map, Info.Location))
                {
                    if (LinkedMonster is EvilMir)
                    {
                        EvilMir mob = (EvilMir)LinkedMonster;
                        if (mob != null)
                        {
                            mob.DragonLink = true;
                        }
                    }
                    MonsterInfo bodyinfo = Envir.GetMonsterInfo(Info.BodyName);
                    if (bodyinfo != null)
                    {
                        MonsterObject bodymob;
                        Point         spawnlocation = Point.Empty;
                        for (int i = 0; i <= BodyLocations.Length - 1; i++)
                        {
                            bodymob       = MonsterObject.GetMonster(bodyinfo);
                            spawnlocation = new Point(LinkedMonster.CurrentLocation.X + BodyLocations[i].X, LinkedMonster.CurrentLocation.Y + BodyLocations[i].Y);
                            if (bodymob != null)
                            {
                                bodymob.Spawn(LinkedMonster.CurrentMap, spawnlocation);
                            }
                        }
                    }

                    DropArea = new Rectangle(Info.DropAreaTop.X, Info.DropAreaTop.Y, Info.DropAreaBottom.X - Info.DropAreaTop.X, Info.DropAreaBottom.Y - Info.DropAreaTop.Y);
                    Loaded   = true;
                    return(true);
                }
            }
            catch (Exception ex)
            {
                SMain.Enqueue(ex);
            }

            SMain.Enqueue("Failed to load Dragon");
            return(false);
        }
Exemplo n.º 12
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();
        }
Exemplo n.º 13
0
 public override bool SpawnMinion(MonsterObject mob)
 {
     return(mob.Spawn(CurrentMap.Info, CurrentLocation));
 }
Exemplo n.º 14
0
        public override void Process()
        {
            base.Process();

            if (Owner != null && (Owner.Node == null || Owner.Dead))
            {
                Despawn();
                return;
            }

            if (SEnvir.Now < TickTime)
            {
                return;
            }

            if (TickCount-- <= 0)
            {
                switch (Effect)
                {
                case SpellEffect.MonsterDeathCloud:
                    MonsterObject monster = Owner as MonsterObject;
                    if (monster == null)
                    {
                        break;
                    }

                    for (int i = CurrentCell.Objects.Count - 1; i >= 0; i--)
                    {
                        if (i >= CurrentCell.Objects.Count)
                        {
                            continue;
                        }

                        MapObject ob = CurrentCell.Objects[i];

                        if (!monster.CanAttackTarget(ob))
                        {
                            continue;
                        }


                        monster.Attack(ob, 4000, Element.None);
                        monster.Attack(ob, 4000, Element.None);
                    }


                    break;
                }

                Despawn();
                return;
            }

            TickTime = SEnvir.Now + TickFrequency;


            switch (Effect)
            {
            case SpellEffect.TrapOctagon:

                for (int i = Targets.Count - 1; i >= 0; i--)
                {
                    MapObject ob = Targets[i];

                    if (ob.Node != null && ob.ShockTime != DateTime.MinValue)
                    {
                        continue;
                    }

                    Targets.Remove(ob);
                }

                if (Targets.Count == 0)
                {
                    Despawn();
                }
                break;

            default:

                if (CurrentCell == null)
                {
                    SEnvir.Log($"[ERROR] {Effect} CurrentCell Null.");
                    return;
                }

                if (CurrentCell.Objects == null)
                {
                    SEnvir.Log($"[ERROR] {Effect} CurrentCell.Objects Null.");
                    return;
                }

                for (int i = CurrentCell.Objects.Count - 1; i >= 0; i--)
                {
                    if (i >= CurrentCell.Objects.Count)
                    {
                        continue;
                    }
                    if (CurrentCell.Objects[i] == this)
                    {
                        continue;
                    }

                    ProcessSpell(CurrentCell.Objects[i]);

                    if (CurrentCell == null)
                    {
                        SEnvir.Log($"[ERROR] {Effect} CurrentCell Null Loop.");
                        return;
                    }

                    if (CurrentCell.Objects == null)
                    {
                        SEnvir.Log($"[ERROR] {Effect} CurrentCell.Objects Null Loop.");
                        return;
                    }
                }
                break;
            }
        }
Exemplo n.º 15
0
        public void ProcessSpell(MapObject ob)
        {
            switch (Effect)
            {
            case SpellEffect.PoisonousCloud:
                if (!Owner.CanHelpTarget(ob))
                {
                    return;
                }

                BuffInfo buff      = ob.Buffs.FirstOrDefault(x => x.Type == BuffType.PoisonousCloud);
                TimeSpan remaining = TickTime - SEnvir.Now;

                if (buff != null)
                {
                    if (buff.RemainingTime > remaining)
                    {
                        return;
                    }
                }

                ob.BuffAdd(BuffType.PoisonousCloud, remaining, new Stats {
                    [Stat.Agility] = Power
                }, false, false, TimeSpan.Zero);
                break;

            case SpellEffect.FireWall:
            case SpellEffect.Tempest:
                PlayerObject player = Owner as PlayerObject;
                if (player == null || !player.CanAttackTarget(ob))
                {
                    return;
                }

                int damage = player.MagicAttack(new List <UserMagic> {
                    Magic
                }, ob, true);

                if (damage > 0 && ob.Race == ObjectType.Player)
                {
                    foreach (SpellObject spell in player.SpellList)
                    {
                        if (spell.Effect != Effect)
                        {
                            continue;
                        }

                        spell.TickCount--;
                    }
                }
                break;

            case SpellEffect.MonsterFireWall:
                MonsterObject monster = Owner as MonsterObject;
                if (monster == null || !monster.CanAttackTarget(ob))
                {
                    return;
                }

                monster.Attack(ob, monster.GetDC(), Element.Fire);
                break;

            case SpellEffect.DarkSoulPrison:
                player = Owner as PlayerObject;
                if (player == null || !player.CanAttackTarget(ob))
                {
                    return;
                }

                damage = player.MagicAttack(new List <UserMagic> {
                    Magic
                }, ob, true);

                if (damage > 0 && ob.Race == ObjectType.Player)
                {
                    foreach (SpellObject spell in player.SpellList)
                    {
                        if (spell.Effect != Effect)
                        {
                            continue;
                        }

                        spell.TickCount--;
                    }
                }
                break;
            }
        }
Exemplo n.º 16
0
        public override void Process()
        {
            base.Process();

            if (Owner != null && (Owner.Node == null || Owner.Dead))
            {
                Despawn();
                return;
            }

            if (SEnvir.Now < TickTime)
            {
                return;
            }

            if (TickCount-- <= 0)
            {
                switch (Effect)
                {
                case SpellEffect.SwordOfVengeance:
                    PlayerObject player = Owner as PlayerObject;
                    if (player == null)
                    {
                        break;
                    }

                    List <Cell> cells = CurrentMap.GetCells(CurrentLocation, 0, 3);

                    foreach (Cell cell in cells)
                    {
                        if (cell.Objects != null)
                        {
                            for (int i = cell.Objects.Count - 1; i >= 0; i--)
                            {
                                if (i >= cell.Objects.Count)
                                {
                                    continue;
                                }
                                MapObject target = cell.Objects[i];

                                if (!player.CanAttackTarget(target))
                                {
                                    continue;
                                }

                                int damage = player.MagicAttack(new List <UserMagic> {
                                    Magic
                                }, target, true);

                                ActionList.Add(new DelayedAction(
                                                   SEnvir.Now.AddMilliseconds(500),
                                                   ActionType.DelayMagic,
                                                   new List <UserMagic> {
                                    Magic
                                },
                                                   target));
                            }
                        }
                    }

                    break;

                case SpellEffect.MonsterDeathCloud:
                    MonsterObject monster = Owner as MonsterObject;
                    if (monster == null)
                    {
                        break;
                    }

                    for (int i = CurrentCell.Objects.Count - 1; i >= 0; i--)
                    {
                        if (i >= CurrentCell.Objects.Count)
                        {
                            continue;
                        }

                        MapObject ob = CurrentCell.Objects[i];

                        if (!monster.CanAttackTarget(ob))
                        {
                            continue;
                        }


                        monster.Attack(ob, 4000, Element.None);
                        monster.Attack(ob, 4000, Element.None);
                    }

                    break;
                }

                Despawn();
                return;
            }

            TickTime = SEnvir.Now + TickFrequency;


            switch (Effect)
            {
            case SpellEffect.TrapOctagon:

                for (int i = Targets.Count - 1; i >= 0; i--)
                {
                    MapObject ob = Targets[i];

                    if (ob.Node != null && ob.ShockTime != DateTime.MinValue)
                    {
                        continue;
                    }

                    Targets.Remove(ob);
                }

                if (Targets.Count == 0)
                {
                    Despawn();
                }
                break;

            default:

                if (CurrentCell == null)
                {
                    SEnvir.Log($"[ERROR] {Effect} CurrentCell Null.");
                    return;
                }

                if (CurrentCell.Objects == null)
                {
                    SEnvir.Log($"[ERROR] {Effect} CurrentCell.Objects Null.");
                    return;
                }

                for (int i = CurrentCell.Objects.Count - 1; i >= 0; i--)
                {
                    if (i >= CurrentCell.Objects.Count)
                    {
                        continue;
                    }
                    if (CurrentCell.Objects[i] == this)
                    {
                        continue;
                    }

                    ProcessSpell(CurrentCell.Objects[i]);

                    if (CurrentCell == null)
                    {
                        SEnvir.Log($"[ERROR] {Effect} CurrentCell Null Loop.");
                        return;
                    }

                    if (CurrentCell.Objects == null)
                    {
                        SEnvir.Log($"[ERROR] {Effect} CurrentCell.Objects Null Loop.");
                        return;
                    }
                }
                break;
            }
        }
Exemplo n.º 17
0
 public override bool SpawnMinion(MonsterObject mob)
 {
     return(mob.Spawn(CurrentMap.Info, Functions.Move(CurrentLocation, Functions.ShiftDirection(Direction, 3))));
 }
Exemplo n.º 18
0
 public void SetParent(MonsterObject ob)
 {
     parentObject = ob;
 }
Exemplo n.º 19
0
        private void SpawnSlaves()
        {
            int count = Math.Min(8, 40 - SlaveList.Count);

            Broadcast(new S.ObjectAttack {
                ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
            });
            ActionTime = Envir.Time + 300;
            AttackTime = Envir.Time + AttackSpeed;

            for (int i = 0; i < count; i++)
            {
                MonsterObject mob = null;
                if (Info.Name.Contains("Ancient"))
                {
                    switch (Envir.Random.Next(4))
                    {
                    case 0:
                        mob = GetMonster(Envir.GetMonsterInfo(Settings.AncBoneMonster1));
                        break;

                    case 1:
                        mob = GetMonster(Envir.GetMonsterInfo(Settings.AncBoneMonster2));
                        break;

                    case 2:
                        mob = GetMonster(Envir.GetMonsterInfo(Settings.AncBoneMonster3));
                        break;

                    case 3:
                        mob = GetMonster(Envir.GetMonsterInfo(Settings.AncBoneMonster4));
                        break;
                    }
                }
                else
                {
                    switch (Envir.Random.Next(4))
                    {
                    case 0:
                        mob = GetMonster(Envir.GetMonsterInfo(Settings.BoneMonster1));
                        break;

                    case 1:
                        mob = GetMonster(Envir.GetMonsterInfo(Settings.BoneMonster2));
                        break;

                    case 2:
                        mob = GetMonster(Envir.GetMonsterInfo(Settings.BoneMonster3));
                        break;

                    case 3:
                        mob = GetMonster(Envir.GetMonsterInfo(Settings.BoneMonster4));
                        break;
                    }
                }
                if (mob == null)
                {
                    continue;
                }

                if (!mob.Spawn(CurrentMap, Front))
                {
                    mob.Spawn(CurrentMap, CurrentLocation);
                }

                mob.Target     = Target;
                mob.ActionTime = Envir.Time + 2000;
                SlaveList.Add(mob);
            }
        }
Exemplo n.º 20
0
 public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
 {
     return(0);
 }
Exemplo n.º 21
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Return))
        {
            if (ChatBar.gameObject.activeSelf)
            {
                if (ChatBar.text.Length > 0)
                {
                    Network.Enqueue(new C.Chat()
                    {
                        Message = ChatBar.text
                    });
                }
                ChatBar.text = string.Empty;
                ChatBar.gameObject.SetActive(false);
            }
            else
            {
                ChatBar.gameObject.SetActive(true);
                ChatBar.Select();
            }
        }

        if (SelectedItemImage.gameObject.activeSelf)
        {
            SelectedItemImage.transform.position = Input.mousePosition;
            SelectedItemImage.transform.SetAsLastSibling();
        }

        MouseObject = GetMouseObject();

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (Time.time > PickUpTime)
            {
                PickUpTime = Time.time + 0.2f;
                Network.Enqueue(new C.PickUp());
            }
        }

        if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
        {
            if (Input.GetMouseButton(0))
            {
                if (!eventSystem.IsPointerOverGameObject() && CanAttack())
                {
                    GameManager.InputDelay = Time.time + 0.5f;
                    NextHitTime            = Time.time + 1.6f;
                    QueuedAction           = new QueuedAction {
                        Action = MirAction.Attack, Direction = GameManager.MouseUpdate(), Location = User.Player.CurrentLocation
                    };
                }
                return;
            }
            else if (TargetObject != null && !(TargetObject is MonsterObject) && !TargetObject.Dead && TargetObject.gameObject.activeSelf && CanAttack())
            {
                Point self = new Point((int)User.Player.CurrentLocation.x, (int)User.Player.CurrentLocation.y);
                Point targ = new Point((int)TargetObject.CurrentLocation.x, (int)TargetObject.CurrentLocation.y);
                if (Functions.InRange(self, targ, 1))
                {
                    NextHitTime = Time.time + 1.6f;
                    MirDirection direction = Functions.DirectionFromPoint(self, targ);
                    QueuedAction = new QueuedAction {
                        Action = MirAction.Attack, Direction = direction, Location = User.Player.CurrentLocation
                    };
                    return;
                }

                MirDirection targetdirection = Functions.DirectionFromPoint(self, targ);

                if (!CanWalk(targetdirection))
                {
                    return;
                }

                QueuedAction = new QueuedAction {
                    Action = MirAction.Walking, Direction = targetdirection, Location = ClientFunctions.VectorMove(User.Player.CurrentLocation, targetdirection, 1)
                };
            }
        }

        if (Input.GetMouseButton(0) && !eventSystem.IsPointerOverGameObject())
        {
            GameManager.User.CanRun = false;

            if (SelectedCell != null)
            {
                SelectedItemImage.gameObject.SetActive(false);

                MessageBox.Show($"Drop {SelectedCell.Item.Name}?", true, true);
                MessageBox.OK += () =>
                {
                    Network.Enqueue(new C.DropItem {
                        UniqueID = SelectedCell.Item.UniqueID, Count = 1
                    });
                    SelectedCell.Locked = true;
                    SelectedCell        = null;
                };
                MessageBox.Cancel += () =>
                {
                    SelectedCell = null;
                };
                return;
            }

            if (MouseObject != null)
            {
                switch (MouseObject.gameObject.layer)
                {
                case 9:     //Monster
                    MonsterObject monster = (MonsterObject)MouseObject;
                    if (monster.Dead)
                    {
                        break;
                    }
                    TargetObject = monster;
                    return;
                }
            }

            TargetObject = null;
            GameManager.CheckMouseInput();
        }
        else if (Input.GetMouseButton(1) && !eventSystem.IsPointerOverGameObject())
        {
            GameManager.CheckMouseInput();
        }
        else
        {
            GameManager.User.CanRun = false;
            if (TargetObject != null && TargetObject is MonsterObject && !TargetObject.Dead && TargetObject.gameObject.activeSelf && CanAttack())
            {
                Point self = new Point((int)User.Player.CurrentLocation.x, (int)User.Player.CurrentLocation.y);
                Point targ = new Point((int)TargetObject.CurrentLocation.x, (int)TargetObject.CurrentLocation.y);
                if (Functions.InRange(self, targ, 1))
                {
                    NextHitTime = Time.time + 1.6f;
                    MirDirection direction = Functions.DirectionFromPoint(self, targ);
                    QueuedAction = new QueuedAction {
                        Action = MirAction.Attack, Direction = direction, Location = User.Player.CurrentLocation
                    };
                    return;
                }

                MirDirection targetdirection = Functions.DirectionFromPoint(self, targ);

                if (!CanWalk(targetdirection))
                {
                    return;
                }

                QueuedAction = new QueuedAction {
                    Action = MirAction.Walking, Direction = targetdirection, Location = ClientFunctions.VectorMove(User.Player.CurrentLocation, targetdirection, 1)
                };
            }
        }
    }
Exemplo n.º 22
0
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            int armour = 0;

            switch (type)
            {
            case DefenceType.ACAgility:
                if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy])
                {
                    return(0);
                }
                armour = GetAttackPower(Stats[Stat.MinAC], Stats[Stat.MaxAC]);
                break;

            case DefenceType.AC:
                armour = GetAttackPower(Stats[Stat.MinAC], Stats[Stat.MaxAC]);
                break;

            case DefenceType.MACAgility:
                if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy])
                {
                    return(0);
                }
                armour = GetAttackPower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]);
                break;

            case DefenceType.MAC:
                armour = GetAttackPower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]);
                break;

            case DefenceType.Agility:
                if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy])
                {
                    return(0);
                }
                break;
            }

            if (armour >= damage)
            {
                return(0);
            }

            ShockTime = 0;

            for (int i = PoisonList.Count - 1; i >= 0; i--)
            {
                if (PoisonList[i].PType != PoisonType.LRParalysis)
                {
                    continue;
                }

                PoisonList.RemoveAt(i);
                OperateTime = 0;
            }

            if (attacker.Info.AI == 6)
            {
                EXPOwner = null;
            }
            else if (attacker.Master != null)
            {
                if (EXPOwner == null || EXPOwner.Dead)
                {
                    EXPOwner = attacker.Master switch
                    {
                        HeroObject hero => hero.Owner,
                                   _ => attacker.Master
                    }
                }
                ;

                if (EXPOwner == attacker.Master)
                {
                    EXPOwnerTime = Envir.Time + EXPOwnerDelay;
                }
            }

            Broadcast(new S.ObjectStruck {
                ObjectID = ObjectID, AttackerID = attacker.ObjectID, Direction = Direction, Location = CurrentLocation
            });

            ChangeHP(-1);
            return(1);
        }
Exemplo n.º 23
0
 public override bool SpawnMinion(MonsterObject mob)
 {
     return(mob.Spawn(CurrentMap, CurrentMap.GetRandomLocation(Functions.Move(CurrentLocation, MirDirection.DownLeft, 5), 4)));
 }
Exemplo n.º 24
0
    public void InitMonsterList()
    {
        List <MonsterData> list = MonsterDataMng.Instance().GetMonsterDataList();

        list = MonsterFilter.Filter(list, MonsterFilterType.GROWING_IN_GARDEN);
        MonsterDataMng.Instance().SortMDList(list);
        PushNotice.Instance.SyncGardenPushNoticeData(list);
        if (list.Count == 0)
        {
            this.cautionTextLabel.gameObject.SetActive(true);
            this.cautionTextLabel.text = StringMaster.GetString("Garden-01");
        }
        else if (this.cautionTextLabel.gameObject.activeSelf)
        {
            this.cautionTextLabel.gameObject.SetActive(false);
        }
        if (null != FarmObject_DigiGarden.Instance)
        {
            FarmObject_DigiGarden.Instance.SetAutoActiveCanEvolveParticle();
        }
        this.csSelectPanel.initLocation = true;
        this.goMN_LIST[0].SetActive(true);
        this.csSelectPanel.AllBuild(list, new Action <CMD, string, string>(this.OnBornExec), new Action <MonsterData>(this.OnPushEvolutionButton));
        this.goMN_LIST[0].SetActive(false);
        this.modelUiTex.gameObject.SetActive(list.Count != 0);
        int num = 0;

        foreach (MonsterData monsterData in list)
        {
            if (monsterData.userMonster.eggFlg == "1")
            {
                num++;
            }
        }
        foreach (PicturebookDetailController picturebookDetailController in this.eggControllerList)
        {
            picturebookDetailController.CallMethodOnClick = "OnClickEgg_Dummy";
        }
        int num2 = 0;
        int num3 = 0;

        foreach (MonsterData monsterData2 in list)
        {
            if (monsterData2.userMonster.IsEgg())
            {
                string           eggModelId       = MonsterObject.GetEggModelId(monsterData2.userMonster.monsterEvolutionRouteId);
                CommonRender3DRT commonRender3DRT = this.CreateRender3DRT(true, eggModelId, this.modelUiTex);
                this.SetRender3Dcamera(true, commonRender3DRT, false);
                DigimonActionInGarden digimonActionInGarden = this.AttachActionScript(commonRender3DRT.gameObject, true);
                this.charaActList.Add(digimonActionInGarden);
                this.eggControllerList[num2].CallMethodOnClick = this.callMeyhodsOnEggClick[num3];
                if (num != 1)
                {
                    if (num != 2)
                    {
                        if (num == 3)
                        {
                            num2++;
                            if (num2 != 1)
                            {
                                if (num2 != 2)
                                {
                                    if (num2 == 3)
                                    {
                                        digimonActionInGarden.SetPosition(this.eggPos_3);
                                    }
                                }
                                else
                                {
                                    digimonActionInGarden.SetPosition(this.eggPos_2);
                                }
                            }
                            else
                            {
                                digimonActionInGarden.SetPosition(this.eggPos_1);
                            }
                        }
                    }
                    else
                    {
                        num2++;
                        if (num2 != 1)
                        {
                            if (num2 == 2)
                            {
                                digimonActionInGarden.SetPosition(this.eggPos_2);
                            }
                        }
                        else
                        {
                            digimonActionInGarden.SetPosition(this.eggPos_1);
                        }
                    }
                }
                else
                {
                    digimonActionInGarden.SetPosition(this.eggPos_1);
                }
                digimonActionInGarden.SetDefaultAnimation(this.eggLoopAnimClipList[num3]);
            }
            else
            {
                CommonRender3DRT commonRender3DRT2 = this.CreateRender3DRT(false, monsterData2.GetMonsterMaster().Group.modelId, this.modelUiTex);
                this.SetRender3Dcamera(false, commonRender3DRT2, false);
                DigimonActionInGarden digimonActionInGarden2 = this.AttachActionScript(commonRender3DRT2.gameObject, false);
                this.charaActList.Add(digimonActionInGarden2);
                digimonActionInGarden2.RandomPosition();
                digimonActionInGarden2.WalkAction();
            }
            num3++;
        }
    }
Exemplo n.º 25
0
        protected override void ProcessTarget()
        {
            if (Target == null || !CanAttack)
            {
                return;
            }
            if (Target.Dead)
            {
                FindTarget();
                return;
            }

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

            #region Push Attack
            if (Envir.Time > pushTime - (PushTime / 2) &&
                !PushWarn)
            {
                Broadcast(new S.Chat {
                    Type = ChatType.Shout2, Message = string.Format("Be gone already you pesky ants!")
                });
                PushWarn = true;
            }

            if (Envir.Time > pushTime)
            {
                List <MapObject> list = FindAllTargets(PushAttackRange, CurrentLocation, false);
                if (list != null &&
                    list.Count > 0)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (list[i].IsAttackTarget(this))
                        {
                            list[i].Attacked(this, GetAttackPower(MinDC + MinDCBoost, MaxDC + MaxDCBoost), DefenceType.Repulsion);
                            MirDirection dir = Functions.DirectionFromPoint(CurrentLocation, list[i].CurrentLocation);
                            list[i].Pushed(this, dir, 5);
                        }
                    }
                }
                _lastHitTime = Envir.Time + _LastHitTime;
                PushTime     = Settings.Second * Envir.Random.Next(30, 60);
                pushTime     = Envir.Time + PushTime;
                PushWarn     = false;
            }
            #endregion
            #region Lowest HP Attack
            else if (Envir.Time > lowestHPAttackTime)
            {
                byte             lowestHP  = 100;
                MapObject        lowestObj = null;
                List <MapObject> list      = FindAllTargets(LowestAttackRange, CurrentLocation, false);
                if (list != null && list.Count > 0)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (list[i].IsAttackTarget(this))
                        {
                            if (list[i].PercentHealth < lowestHP)
                            {
                                lowestHP  = list[i].PercentHealth;
                                lowestObj = list[i];
                            }
                        }
                    }
                }
                if (lowestObj != null)
                {
                    if (lowestObj.Attacked(this, GetAttackPower(MinSC + MinSCBoost, MaxSC + MaxSCBoost), DefenceType.None) > 0)
                    {
                        if (lowestObj.Race == ObjectType.Player)
                        {
                            Broadcast(new S.Chat {
                                Message = string.Format("{0} how does it feel to see true POWER!", lowestObj.Name), Type = ChatType.Shout2
                            });
                        }
                        Broadcast(new S.ObjectAttack {
                            Direction = Direction, Location = CurrentLocation, ObjectID = ObjectID, Type = 4
                        });
                    }
                }
                LowestHPAttackTime = Settings.Second * Envir.Random.Next(20, 35);
                lowestHPAttackTime = Envir.Time + LowestHPAttackTime;
            }
            #endregion
            #region The Ultimate Attack
            else if (Envir.Time > ultimateAttackTime)
            {
                List <MapObject> list = FindAllTargets(UltimateAttackRange, CurrentLocation, false);
                int hitCount          = 0;
                if (list != null && list.Count > 0)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (list[i].IsAttackTarget(this))
                        {
                            if (list[i].Attacked(this, GetAttackPower(MinDC + MinDCBoost, MaxDC + MaxDCBoost), DefenceType.ACAgility) > 0)
                            {
                                hitCount++;
                            }
                        }
                    }
                }
                if (hitCount > 0)
                {
                    Broadcast(new S.ObjectAttack {
                        Direction = Direction, Type = 3, ObjectID = ObjectID, Location = CurrentLocation
                    });
                }
                UltimateAttackTime = Settings.Second * Envir.Random.Next(15, 45);
                ultimateAttackTime = Envir.Time + UltimateAttackTime;
                _lastHitTime       = Envir.Time + _LastHitTime;
            }
            #endregion
            #region Order all mobs to current Location, might be funny lol
            else if (Envir.Time > orderMobTime)
            {
                for (int x = CurrentLocation.X - OrderMobRange; x < CurrentLocation.X + OrderMobRange / 2; x++)
                {
                    for (int y = CurrentLocation.Y - OrderMobRange; y < CurrentLocation.Y + OrderMobRange / 2; y++)
                    {
                        Point tmp = new Point(x, y);
                        if (!CurrentMap.ValidPoint(tmp))
                        {
                            continue;
                        }
                        Cell cell = CurrentMap.GetCell(tmp);
                        if (cell.Objects == null)
                        {
                            continue;
                        }
                        for (int i = 0; i < cell.Objects.Count; i++)
                        {
                            if (cell.Objects[i].Race == ObjectType.Monster)
                            {
                                MonsterObject tmo = (MonsterObject)cell.Objects[i];
                                if (tmo != null &&
                                    !tmo.Dead)
                                {
                                    bool routeExists = false;
                                    //  Check if the route list is valid before trying to add to a null object
                                    if (tmo.Route == null)
                                    {
                                        //  It was null so we'll create one
                                        tmo.Route = new List <RouteInfo>();
                                    }
                                    //  Now add the route, not sure what the delay is meant to be..
                                    else
                                    {
                                        if (tmo.Route.Count > 0)
                                        {
                                            for (int o = 0; o < tmo.Route.Count; o++)
                                            {
                                                if (tmo.Route[o].Location == CurrentLocation)
                                                {
                                                    routeExists = true;
                                                }
                                            }
                                        }
                                    }
                                    //  If Route already exists (I.E it was already set to the current location)
                                    if (routeExists)
                                    {
                                        continue;
                                    }
                                    //  Route wasn't for the Current location so Add a new route to our current location.
                                    tmo.Route.Add(new RouteInfo()
                                    {
                                        Delay    = 0,
                                        Location = CurrentLocation
                                    });
                                }
                            }
                        }
                    }
                }
                //  Broadcast a message notifying players of any monsters in range coming to aid Mob01
                Broadcast(new S.Chat {
                    Message = string.Format("{0}>Come forth my brothers in arms!", Name), Type = ChatType.Shout2
                });
                //  Set the next Order time randomly
                OrderMobTime = Settings.Second * Envir.Random.Next(15, 50);
                //  Now set the order time with the random cool-down
                orderMobTime = Envir.Time + OrderMobTime;
            }
            #endregion
            #region The Class Attack
            else if (Envir.Time > classAttackTime)
            {
                MirClass lastClass   = MirClass.Wizard;
                int      repeatCount = 0;
REPEAT:
                List <MapObject> list = FindAllTargets(ClassAttackRange, CurrentLocation, false);
                if (list != null &&
                    list.Count > 0)
                {
                    for (int i = list.Count - 1; i > 0; i--)
                    {
                        if (list[i].IsAttackTarget(this))
                        {
                            if (list[i].Race == ObjectType.Player)
                            {
                                PlayerObject temp = (PlayerObject)list[i];
                                if (temp.Class != lastClass)
                                {
                                    list.RemoveAt(i);
                                }
                            }
                        }
                    }
                }
                if (repeatCount < 5)
                {
                    repeatCount++;
                    if (list != null &&
                        list.Count > 0)
                    {
                        list[0].Attacked(this, GetAttackPower(MinMC + MinMCBoost, MaxMC + MaxMCBoost), DefenceType.MAC);
                        _lastHitTime = Envir.Time + _LastHitTime;
                    }
                    else
                    {
                        if (lastClass == MirClass.Wizard)
                        {
                            lastClass = MirClass.Taoist;
                        }
                        else if (lastClass == MirClass.Taoist)
                        {
                            lastClass = MirClass.Assassin;
                        }
                        else if (lastClass == MirClass.Assassin)
                        {
                            lastClass = MirClass.Warrior;
                        }
                        else if (lastClass == MirClass.Warrior)
                        {
                            lastClass = MirClass.Archer;
                        }
                        else if (lastClass == MirClass.Archer)
                        {
                            lastClass = MirClass.Wizard;
                        }
                        goto REPEAT;
                    }
                }
                ClassAttackTime = Settings.Second * Envir.Random.Next(5, 15);
                classAttackTime = Envir.Time + ClassAttackTime;
            }
            #endregion
            #region The Debuff Attack
            else if (Envir.Time > debuffTime)
            {
                List <MapObject> list = FindAllTargets(DebuffAttackRange, CurrentLocation, false);
                DebuffTime   = Settings.Second * Envir.Random.Next(3, 10);
                BuffDuration = Settings.Second * Envir.Random.Next(5, 8);
                if (BuffDuration > DebuffTime)
                {
                    DebuffTime = BuffDuration;
                }
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].IsAttackTarget(this))
                    {
                        if (list[i].Attacked(this, GetAttackPower(MinSC, MaxSC), DefenceType.ACAgility) > 0)
                        {
                            list[i].AddBuff(new Buff {
                                Caster = this, Type = BuffType.WonderDrug, ExpireTime = Envir.Time + DebuffTime, ObjectID = list[i].ObjectID, Values = new int[] { 2, 3, 1, 5, 25 }
                            });
                            MinDCBoost  += 1;
                            MaxDCBoost  += 5;
                            MinMCBoost  += 1;
                            MaxMCBoost  += 5;
                            MinSCBoost  += 1;
                            MaxSCBoost  += 5;
                            MinMACBoost += 1;
                            MaxMACBoost += 5;
                            MinACBoost  += 1;
                            MaxACBoost  += 5;
                            AgilBoost   += 2;
                            AccBoost    += 3;
                            HealthBoost += 25;
                        }
                    }
                }
                buffDuration = Envir.Time + BuffDuration;
                debuffTime   = Envir.Time + DebuffTime;
                _lastHitTime = Envir.Time + _LastHitTime;
            }
            #endregion
            #region SpellObject Spawning
            else if (Envir.Time > randomMapAttackTime)
            {
                List <Point> locations = new List <Point>();
                RandomMapAttackTime = Settings.Second * Envir.Random.Next(8, 23);
                for (int i = 0; i < 32; i++)
                {
                    Point loc = GetRandomPoint(15, RandomMapAttackRange, CurrentMap);
                    if (CurrentMap.ValidPoint(loc))
                    {
                        locations.Add(loc);
                    }
                }
                for (int i = 0; i < locations.Count; i++)
                {
                    //                                                                                                          Damage                                                  Location        Duration
                    DelayedAction spell = new DelayedAction(DelayedType.MonsterMagic, Envir.Time + 800, this, Spell.SpecialMob, GetAttackPower(MinMC + MinMCBoost, MaxMC + MaxMCBoost), locations[i], RandomMapAttackTime);
                    CurrentMap.ActionList.Add(spell);
                }

                randomMapAttackTime = Envir.Time + RandomMapAttackTime;
            }
            #endregion
            #region Normal Attacks
            else if (InAttackRange() && !WalkAway)
            {
                Target.Attacked(this, GetAttackPower(MinDC, MaxDC), DefenceType.ACAgility);
                Broadcast(new S.ObjectAttack {
                    Type = 0, Direction = Direction, Location = CurrentLocation, ObjectID = ObjectID
                });
                _lastHitTime = Envir.Time + _LastHitTime;
            }
            else if (InAttackRange() && WalkAway)
            {
                //  Range attack once < 25% health remaining
                Target.Attacked(this, GetAttackPower(MinMC, MaxMC), DefenceType.MACAgility);
                Broadcast(new S.ObjectAttack {
                    Type = 1, Direction = Direction, Location = CurrentLocation, ObjectID = ObjectID
                });
                _lastHitTime = Envir.Time + _LastHitTime;
            }
            #endregion
            #region Check if Target died, find a new target
            if (Target.Dead)
            {
                FindTarget();
                return;
            }
            #endregion
            if (Envir.Time < ShockTime)
            {
                Target = null;
                return;
            }
            #region Walk away behaviour
            if (WalkAway)
            {
                int dist = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
                if (dist >= 13)
                {
                    MoveTo(Target.CurrentLocation);
                }
                else
                {
                    MirDirection dir = Functions.DirectionFromPoint(Target.CurrentLocation, CurrentLocation);

                    if (Walk(dir))
                    {
                        return;
                    }

                    switch (Envir.Random.Next(2)) //No favour
                    {
                    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;
                    }
                }
            }
            else
            {
                MoveTo(Target.CurrentLocation);
            }
            #endregion
        }
Exemplo n.º 26
0
 public override bool SpawnMinion(MonsterObject mob)
 {
     return(mob.Spawn(CurrentMap, CurrentMap.GetRandomLocation(CurrentLocation, 5)));
 }
Exemplo n.º 27
0
        // Pet attacking trainer.
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            if (attacker == null || attacker.Master == null) return 0;
            
            if (_currentAttacker != null && _currentAttacker != attacker.Master)
            {
                OutputAverage();
                ResetStats();
            }

            _currentAttacker = (PlayerObject)attacker.Master;
            _hitCount++;
            _totalDamage += damage;
            _lastAttackTime = Envir.Time;


            switch (type)
            {
                case DefenceType.ACAgility:
                    attacker.Master.ReceiveChat(damage + " AC Agility Damage inflicted on the trainer by your pet.", ChatType.Trainer);
                    break;
                case DefenceType.AC:
                    attacker.Master.ReceiveChat(damage + " AC Damage inflicted on the trainer by your pet.", ChatType.Trainer);
                    break;
                case DefenceType.MACAgility:
                    attacker.Master.ReceiveChat(damage + " MAC Agility Damage inflicted on the trainer by your pet.", ChatType.Trainer);
                    break;
                case DefenceType.MAC:
                    attacker.Master.ReceiveChat(damage + " MAC Damage inflicted on the trainer by your pet.", ChatType.Trainer);
                    break;
                case DefenceType.Agility:
                    attacker.Master.ReceiveChat(damage + " Agility Damage inflicted on the trainer by your pet.", ChatType.Trainer);
                    break;
            }

            return 1;
        }
Exemplo n.º 28
0
 public override bool IsAttackTarget(MonsterObject attacker)
 {
     return Visible && base.IsAttackTarget(attacker);
 }
Exemplo n.º 29
0
    void Update()
    {
        if (shopController.IsShopWindowOpen())
        {
            Debug.Log("ShopControllerIsActive");
            if (Inventory.UseShopInventoryControls())
            {
                return;
            }
        }

        if (SelectedItemImage.gameObject.activeSelf)
        {
            SelectedItemImage.transform.position = Input.mousePosition;
            SelectedItemImage.transform.SetAsLastSibling();
        }

        MouseObject = GetMouseObject();

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (Time.time > PickUpTime)
            {
                PickUpTime = Time.time + 0.2f;
                Network.Enqueue(new C.PickUp());
            }
        }

        if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
        {
            if (Input.GetMouseButton(0))
            {
                if (!eventSystem.IsPointerOverGameObject() && CanAttack())
                {
                    GameManager.InputDelay = Time.time + 0.5f;
                    NextHitTime            = Time.time + 1.6f;
                    QueuedAction           = new QueuedAction {
                        Action = MirAction.Attack, Direction = GameManager.MouseUpdate(), Location = User.Player.CurrentLocation
                    };
                }
                return;
            }
            else if (TargetObject != null && !(TargetObject is MonsterObject) && !TargetObject.Dead && TargetObject.gameObject.activeSelf && CanAttack())
            {
                Point self = new Point(User.Player.CurrentLocation.x, User.Player.CurrentLocation.y);
                Point targ = new Point(TargetObject.CurrentLocation.x, TargetObject.CurrentLocation.y);
                if (Functions.InRange(self, targ, 1))
                {
                    NextHitTime = Time.time + 1.6f;
                    MirDirection direction = Functions.DirectionFromPoint(self, targ);
                    QueuedAction = new QueuedAction {
                        Action = MirAction.Attack, Direction = direction, Location = User.Player.CurrentLocation
                    };
                    return;
                }

                MirDirection targetdirection = Functions.DirectionFromPoint(self, targ);

                if (!CanWalk(targetdirection))
                {
                    return;
                }

                QueuedAction = new QueuedAction {
                    Action = MirAction.Walking, Direction = targetdirection, Location = ClientFunctions.VectorMove(User.Player.CurrentLocation, targetdirection, 1)
                };
            }
        }

        if (Input.GetMouseButtonUp(0) && !eventSystem.IsPointerOverGameObject() && Time.time > GameManager.InputDelay)
        {
            if (SelectedCell != null)
            {
                SelectedItemImage.gameObject.SetActive(false);

                MessageBox.Show($"Drop {SelectedCell.Item.Name}?", okbutton: true, cancelbutton: true);
                MessageBox.OK += () =>
                {
                    Network.Enqueue(new C.DropItem {
                        UniqueID = SelectedCell.Item.UniqueID, Count = 1
                    });
                    SelectedCell.Locked = true;
                    SelectedCell        = null;
                };
                MessageBox.Cancel += () =>
                {
                    Debug.Log("CancelInvoke");
                    SelectedCell = null;
                };
                return;
            }
        }

        if (Input.GetMouseButton(0) && SelectedCell == null && !eventSystem.IsPointerOverGameObject() && Time.time > GameManager.InputDelay)
        {
            GameManager.User.CanRun = false;

            if (MouseObject != null)
            {
                switch (MouseObject.gameObject.layer)
                {
                case 9:     //Monster
                    MonsterObject monster = (MonsterObject)MouseObject;
                    if (monster.Dead)
                    {
                        break;
                    }
                    TargetObject           = monster;
                    GameManager.InputDelay = Time.time + 0.5f;
                    return;

                case 10:     //NPC
                    NPCObject npc = (NPCObject)MouseObject;
                    NPCName = npc.Name;
                    NPCID   = npc.ObjectID;
                    NPCCamera.transform.SetParent(npc.CameraLocation.transform, false);
                    Network.Enqueue(new C.CallNPC {
                        ObjectID = npc.ObjectID, Key = "[@Main]"
                    });
                    GameManager.InputDelay = Time.time + 0.5f;
                    return;
                }
            }

            TargetObject = null;
            GameManager.CheckMouseInput();
        }
        else if (Input.GetMouseButton(1) && !eventSystem.IsPointerOverGameObject())
        {
            GameManager.CheckMouseInput();
        }
        else
        {
            GameManager.User.CanRun = false;
            if (TargetObject != null && TargetObject is MonsterObject && !TargetObject.Dead && TargetObject.gameObject.activeSelf && CanAttack())
            {
                Point self = new Point(User.Player.CurrentLocation.x, User.Player.CurrentLocation.y);
                Point targ = new Point(TargetObject.CurrentLocation.x, TargetObject.CurrentLocation.y);
                if (Functions.InRange(self, targ, 1))
                {
                    NextHitTime = Time.time + 1.6f;
                    MirDirection direction = Functions.DirectionFromPoint(self, targ);
                    QueuedAction = new QueuedAction {
                        Action = MirAction.Attack, Direction = direction, Location = User.Player.CurrentLocation
                    };
                    return;
                }

                MirDirection targetdirection = Functions.DirectionFromPoint(self, targ);

                if (!CanWalk(targetdirection))
                {
                    return;
                }

                QueuedAction = new QueuedAction {
                    Action = MirAction.Walking, Direction = targetdirection, Location = ClientFunctions.VectorMove(User.Player.CurrentLocation, targetdirection, 1)
                };
            }
        }
    }
Exemplo n.º 30
0
        //刷新小怪,这里控制下,不要无限刷新?
        private void SpawnBomb()
        {
            //当前地图怪物超过1200,不刷新了
            if (CurrentMap.MonsterCount > 1000)
            {
                return;
            }

            int NearCount = 0;

            //周围5格的怪物超过200个,也不刷新了
            for (int d = 0; d <= 5; 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 (!CurrentMap.Valid(x, y) || CurrentMap.Objects[x, y] == null)
                        {
                            continue;
                        }
                        NearCount += CurrentMap.Objects[x, y].Count;
                    }
                }
            }
            if (NearCount > 200)
            {
                return;
            }

            int distance = RandomUtils.Next(_bombSpreadMin, _bombSpreadMax);

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

                Point location = new Point(playerLocation.X + RandomUtils.Next(-distance, distance + 1),
                                           playerLocation.Y + RandomUtils.Next(-distance, distance + 1));

                MonsterObject mob = null;
                switch (RandomUtils.Next(3))
                {
                case 0:
                    mob = GetMonster(Envir.GetMonsterInfo(Settings.HellBomb1));
                    break;

                case 1:
                    mob = GetMonster(Envir.GetMonsterInfo(Settings.HellBomb2));
                    break;

                case 2:
                    mob = GetMonster(Envir.GetMonsterInfo(Settings.HellBomb3));
                    break;
                }

                if (mob == null)
                {
                    return;
                }

                mob.Spawn(CurrentMap, location);
            }
        }
Exemplo n.º 31
0
        // Pet attacking trainer.
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            if (attacker == null || attacker.Master == null)
            {
                return(0);
            }

            if (_currentAttacker != null && _currentAttacker != attacker.Master)
            {
                OutputAverage();
                ResetStats();
            }



            int armour = 0;

            //deal with trainers defense
            switch (type)
            {
            case DefenceType.AC:
            case DefenceType.ACAgility:
                armour = GetDefencePower(MinAC, MaxAC);
                break;

            case DefenceType.MAC:
            case DefenceType.MACAgility:
                armour = GetDefencePower(MinMAC, MaxMAC);
                break;
            }
            if (armour >= damage)
            {
                BroadcastDamageIndicator(DamageType.Miss);
                return(0);
            }
            damage -= armour;

            if (_currentAttacker == null)
            {
                _StartTime = Envir.Time;
            }


            MapObject tmpAttacker = attacker.Master;

            while (true)
            {
                if (tmpAttacker.Master != null)
                {
                    tmpAttacker = tmpAttacker.Master;
                    continue;
                }
                break;
            }

            _currentAttacker = (PlayerObject)tmpAttacker;

            _hitCount++;
            _totalDamage   += damage;
            _lastAttackTime = Envir.Time;

            ReportDamage(damage, type, true);
            return(1);
        }
Exemplo n.º 32
0
 public override bool IsAttackTarget(MonsterObject attacker)
 {
     return(false);
 }
Exemplo n.º 33
0
        private void UpdateCurrentTargetDebuffBar(MonsterObject target)
        {
            try
            {
                if(CurrentTargetDebuffView == null) {return;}

                try
                {
                    if(CurrentTargetDebuffList.Count != 0)
                    {
                        foreach(var debuff in CurrentTargetDebuffList)
                        {
                            debuff.Dispose();
                        }
                    }
                    CurrentTargetDebuffList.Clear();
                }catch(Exception ex){LogError(ex);}

                if(target.Id != 0)
                {

                    if(target.DebuffSpellList.Count > 5)
                    {
                        CurrentTargetDebuffView.Width = target.DebuffSpellList.Count * 20;
                    }
                    else
                    {
                        CurrentTargetDebuffView.Width = 120;
                    }

                    if(target.DebuffSpellList.Count > 0)
                    {
                        foreach(var debuff in target.DebuffSpellList.OrderBy(x => x.SecondsRemaining))
                        {
                            HudImageStack debufficon = new HudImageStack();
                            if(debuff.SecondsRemaining <= 15) {debufficon.Add(DebuffRectangle, DebuffExpiring);}
                            else if(debuff.SecondsRemaining <= 30){debufficon.Add(DebuffRectangle, DebuffWarning);}
                            else{debufficon.Add(DebuffRectangle,DebuffCurrent);}
                            debufficon.Add(DebuffRectangle, SpellIndex[debuff.SpellId].spellicon);
                            CurrentTargetDebuffList.Add(debufficon);
                        }

                        for(int i = 0; i < CurrentTargetDebuffList.Count; i ++)
                        {
                            CurrentTargetDebuffLayout.AddControl(CurrentTargetDebuffList[i], new Rectangle((20*i) + 2,2,16,16));
                        }
                    }
                }

            }catch(Exception ex){LogError(ex);}
        }
Exemplo n.º 34
0
 public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
 {
     return Sleeping ? 0 : base.Attacked(attacker, damage, type);
 }
Exemplo n.º 35
0
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            if (type != DefenceType.Repulsion) return 0;

            return base.Attacked(attacker, damage, type);
        }
Exemplo n.º 36
0
 public override bool IsAttackTarget(MonsterObject attacker)
 {
     return(base.IsAttackTarget(attacker));
 }
Exemplo n.º 37
0
        public override void Die()
        {
            base.Die();

            if (CurrentMap.HasSafeZone)
            {
                return;
            }

            if (SEnvir.Random.Next(2) == 0)
            {
                MonsterInfo boss;

                while (true)
                {
                    boss = SEnvir.BossList[SEnvir.Random.Next(SEnvir.BossList.Count)];

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

                    break;
                }

                MonsterObject mob = GetMonster(boss);

                mob.Spawn(CurrentMap, CurrentMap.GetRandomLocation(CurrentLocation, 2));
            }
            else
            {
                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)
                    {
                        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));
                }
            }
        }
Exemplo n.º 38
0
 public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 39
0
 protected internal BlockingObject(MonsterObject parent, MonsterInfo info) : base(info)
 {
     Parent = parent;
     Visible = true;
 }
Exemplo n.º 40
0
 public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
 {
     return(Sleeping ? 0 : base.Attacked(attacker, damage, type));
 }
Exemplo n.º 41
0
        public override long Attacked(MapObject attacker, long power, Element element, bool canReflect = true, bool ignoreShield = false, bool canCrit = true, bool canStruck = true)
        {
            if (attacker == null || attacker.Race != ObjectType.Player)
            {
                return(0);
            }

            PlayerObject player = (PlayerObject)attacker;

            if (War == null)
            {
                return(0);
            }

            if (player.Character.Account.GuildMember == null)
            {
                return(0);
            }

            if (player.Character.Account.GuildMember.Guild.Castle != null)
            {
                return(0);
            }

            if (War.Participants.Count > 0 && !War.Participants.Contains(player.Character.Account.GuildMember.Guild))
            {
                return(0);
            }

            long result = base.Attacked(attacker, 1, element, canReflect, ignoreShield, canCrit);

            #region Conquest Stats

            switch (attacker.Race)
            {
            case ObjectType.Player:
                UserConquestStats conquest = SEnvir.GetConquestStats((PlayerObject)attacker);

                if (conquest != null)
                {
                    conquest.BossDamageDealt += result;
                }
                break;

            case ObjectType.Monster:
                MonsterObject mob = (MonsterObject)attacker;
                if (mob.PetOwner != null)
                {
                    conquest = SEnvir.GetConquestStats(mob.PetOwner);

                    if (conquest != null)
                    {
                        conquest.BossDamageDealt += result;
                    }
                }
                break;
            }

            #endregion


            EXPOwner = null;


            return(result);
        }
Exemplo n.º 42
0
 public override bool IsAttackTarget(MonsterObject attacker)
 {
     return !Stoned && base.IsAttackTarget(attacker);
 }
Exemplo n.º 43
0
        // Pet attacking trainer.
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            if (attacker == null || attacker.Master == null) return 0;
            
            if (_currentAttacker != null && _currentAttacker != attacker.Master)
            {
                OutputAverage();
                ResetStats();
            }



            int armour = 0;
            //deal with trainers defense
            switch (type)
            {
                case DefenceType.AC:
                case DefenceType.ACAgility:
                    armour = GetAttackPower(MinAC, MaxAC);
                    break;
                case DefenceType.MAC:
                case DefenceType.MACAgility:
                    armour = GetAttackPower(MinMAC, MaxMAC);
                    break;
            }
            if (armour >= damage)
            {
                BroadcastDamageIndicator(DamageType.Miss);
                return 0;
            }
            damage -= armour;

            if (_currentAttacker == null)
                _StartTime = Envir.Time;
            _currentAttacker = (PlayerObject)attacker.Master;
            _hitCount++;
            _totalDamage += damage;
            _lastAttackTime = Envir.Time;

            ReportDamage(damage, type, true);
            return 1;
        }
Exemplo n.º 44
0
 public override bool IsAttackTarget(MonsterObject attacker)
 {
     return true;
 }
Exemplo n.º 45
0
        public override bool IsAttackTarget(MonsterObject attacker) 
        {
            if (attacker.Master == null) return false;

            return true; 
        }
Exemplo n.º 46
0
 public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
 {
     return 0;
 }
Exemplo n.º 47
0
 protected internal BlockingObject(MonsterObject parent, MonsterInfo info) : base(info)
 {
     Parent  = parent;
     Visible = true;
 }
Exemplo n.º 48
0
 public override bool IsAttackTarget(MonsterObject attacker)
 {
     return Parent.IsAttackTarget(attacker);
 }
Exemplo n.º 49
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                CompanionDisplay      = null;
                CompanionDisplayPoint = Point.Empty;

                if (CompanionTabControl != null)
                {
                    if (!CompanionTabControl.IsDisposed)
                    {
                        CompanionTabControl.Dispose();
                    }

                    CompanionTabControl = null;
                }

                if (CompanionBagTab != null)
                {
                    if (!CompanionBagTab.IsDisposed)
                    {
                        CompanionBagTab.Dispose();
                    }

                    CompanionBagTab = null;
                }

                if (PickUpFilterTab != null)
                {
                    if (!PickUpFilterTab.IsDisposed)
                    {
                        PickUpFilterTab.Dispose();
                    }

                    PickUpFilterTab = null;
                }

                if (ItemNameFilterTab != null)
                {
                    if (!ItemNameFilterTab.IsDisposed)
                    {
                        ItemNameFilterTab.Dispose();
                    }

                    ItemNameFilterTab = null;
                }

                if (EquipmentGrid != null)
                {
                    for (int i = 0; i < EquipmentGrid.Length; i++)
                    {
                        if (EquipmentGrid[i] != null)
                        {
                            if (!EquipmentGrid[i].IsDisposed)
                            {
                                EquipmentGrid[i].Dispose();
                            }

                            EquipmentGrid[i] = null;
                        }
                    }

                    EquipmentGrid = null;
                }

                if (InventoryGrid != null)
                {
                    if (!InventoryGrid.IsDisposed)
                    {
                        InventoryGrid.Dispose();
                    }

                    InventoryGrid = null;
                }

                if (WeightLabel != null)
                {
                    if (!WeightLabel.IsDisposed)
                    {
                        WeightLabel.Dispose();
                    }

                    WeightLabel = null;
                }

                if (HungerLabel != null)
                {
                    if (!HungerLabel.IsDisposed)
                    {
                        HungerLabel.Dispose();
                    }

                    HungerLabel = null;
                }

                if (NameLabel != null)
                {
                    if (!NameLabel.IsDisposed)
                    {
                        NameLabel.Dispose();
                    }

                    NameLabel = null;
                }

                if (LevelLabel != null)
                {
                    if (!LevelLabel.IsDisposed)
                    {
                        LevelLabel.Dispose();
                    }

                    LevelLabel = null;
                }

                if (ExperienceLabel != null)
                {
                    if (!ExperienceLabel.IsDisposed)
                    {
                        ExperienceLabel.Dispose();
                    }

                    ExperienceLabel = null;
                }

                if (Level3Label != null)
                {
                    if (!Level3Label.IsDisposed)
                    {
                        Level3Label.Dispose();
                    }

                    Level3Label = null;
                }

                if (Level5Label != null)
                {
                    if (!Level5Label.IsDisposed)
                    {
                        Level5Label.Dispose();
                    }

                    Level5Label = null;
                }

                if (Level7Label != null)
                {
                    if (!Level7Label.IsDisposed)
                    {
                        Level7Label.Dispose();
                    }

                    Level7Label = null;
                }

                if (Level10Label != null)
                {
                    if (!Level10Label.IsDisposed)
                    {
                        Level10Label.Dispose();
                    }

                    Level10Label = null;
                }

                if (ModeComboBox != null)
                {
                    if (!ModeComboBox.IsDisposed)
                    {
                        ModeComboBox.Dispose();
                    }

                    ModeComboBox = null;
                }

                BagWeight     = 0;
                MaxBagWeight  = 0;
                InventorySize = 0;
            }
        }