コード例 #1
0
ファイル: ArmadiloElder.cs プロジェクト: coolzoom/mir2-master
        protected override void ProcessAI()
        {
            if (!Dead && Envir.Time > VisibleTime)
            {
                VisibleTime = Envir.Time + 2000;

                bool visible = FindNearby(4);

                if (!Visible && visible)
                {
                    Visible  = true;
                    CellTime = Envir.Time + 500;
                    Broadcast(GetInfo());
                    Broadcast(new S.ObjectShow {
                        ObjectID = ObjectID
                    });
                    ActionTime      = Envir.Time + 2000;
                    DigOutTime      = Envir.Time;
                    DigOutLocation  = CurrentLocation;
                    DigOutDirection = Direction;
                }
            }

            if (Visible && Envir.Time > DigOutTime + 800 && !DoneDigOut)
            {
                SpellObject ob = new SpellObject
                {
                    Spell           = Spell.Armadilo,
                    Value           = 1,
                    ExpireTime      = Envir.Time + (5 * 60 * 1000),
                    TickSpeed       = 2000,
                    Caster          = null,
                    CurrentLocation = DigOutLocation,
                    CurrentMap      = this.CurrentMap,
                    Direction       = DigOutDirection
                };
                CurrentMap.AddObject(ob);
                ob.Spawned();
                DoneDigOut = true;
            }

            base.ProcessAI();
        }
コード例 #2
0
 protected virtual void SpawnDigOutEffect()
 {
     if (Visible && Envir.Time > DigOutTime + 1000 && !DoneDigOut)
     {
         SpellObject ob = new SpellObject
         {
             Spell           = Spell.DigOutZombie,
             Value           = 1,
             ExpireTime      = Envir.Time + (5 * 60 * 1000),
             TickSpeed       = 2000,
             Caster          = null,
             CurrentLocation = DigOutLocation,
             CurrentMap      = this.CurrentMap,
             Direction       = DigOutDirection
         };
         CurrentMap.AddObject(ob);
         ob.Spawned();
         DoneDigOut = true;
     }
 }
コード例 #3
0
        public override void Revive(int hp, bool effect)
        {
            if (!Dead)
            {
                return;
            }

            SetHP(hp);
            SetMP(Stats[Stat.MP]);

            CurrentMap.RemoveObject(this);
            Broadcast(new S.ObjectRemove {
                ObjectID = ObjectID
            });

            Dead       = false;
            ActionTime = Envir.Time + RevivalDelay;

            CurrentMap.AddObject(this);
            BroadcastInfo();
            Broadcast(new S.ObjectRevived {
                ObjectID = ObjectID, Effect = effect
            });
        }
コード例 #4
0
ファイル: ItemObject.cs プロジェクト: coolzoom/mir2-master
        public bool Drop(Point location)
        {
            Point bestLocation = Point.Empty;

            if (CurrentMap == null)
            {
                return(false);
            }
            if (!CurrentMap.ValidPoint(location))
            {
                return(false);
            }
            bool movement = false;

            for (int i = 0; i < CurrentMap.Info.Movements.Count; i++)
            {
                MovementInfo info = CurrentMap.Info.Movements[i];
                if (info.Source != location)
                {
                    continue;
                }
                movement = true;
                break;
            }
            if (movement)
            {
                return(false);
            }

            Cell cell = CurrentMap.GetCell(location);

            CurrentLocation = location;
            CurrentMap.AddObject(this);
            Spawned();
            return(true);
        }
コード例 #5
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);
        }
コード例 #6
0
        public override void UseItem(ulong id)
        {
            S.UseItem p = new S.UseItem {
                UniqueID = id, Grid = MirGridType.HeroInventory, Success = false
            };

            UserItem item  = null;
            int      index = -1;

            for (int i = 0; i < Info.Inventory.Length; i++)
            {
                item = Info.Inventory[i];
                if (item == null || item.UniqueID != id)
                {
                    continue;
                }
                index = i;
                break;
            }

            if (item == null || index == -1 || !CanUseItem(item))
            {
                Owner.Enqueue(p);
                return;
            }

            if (Dead && !(item.Info.Type == ItemType.Scroll && item.Info.Shape == 6))
            {
                Owner.Enqueue(p);
                return;
            }

            switch (item.Info.Type)
            {
            case ItemType.Potion:
                switch (item.Info.Shape)
                {
                case 0:         //NormalPotion
                    PotHealthAmount = (ushort)Math.Min(ushort.MaxValue, PotHealthAmount + item.Info.Stats[Stat.HP]);
                    PotManaAmount   = (ushort)Math.Min(ushort.MaxValue, PotManaAmount + item.Info.Stats[Stat.MP]);
                    break;

                case 1:         //SunPotion
                    ChangeHP(item.Info.Stats[Stat.HP]);
                    ChangeMP(item.Info.Stats[Stat.MP]);
                    break;

                case 2:         //MysteryWater
                    if (UnlockCurse)
                    {
                        ReceiveChat("You can already unequip a cursed item.", ChatType.Hint);
                        Owner.Enqueue(p);
                        return;
                    }
                    ReceiveChat("You can now unequip a cursed item.", ChatType.Hint);
                    UnlockCurse = true;
                    break;

                case 3:         //Buff
                {
                    int time = item.Info.Durability;

                    if (item.GetTotal(Stat.MaxDC) > 0)
                    {
                        AddBuff(BuffType.Impact, this, time * Settings.Minute, new Stats {
                                [Stat.MaxDC] = item.GetTotal(Stat.MaxDC)
                            });
                    }

                    if (item.GetTotal(Stat.MaxMC) > 0)
                    {
                        AddBuff(BuffType.Magic, this, time * Settings.Minute, new Stats {
                                [Stat.MaxMC] = item.GetTotal(Stat.MaxMC)
                            });
                    }

                    if (item.GetTotal(Stat.MaxSC) > 0)
                    {
                        AddBuff(BuffType.Taoist, this, time * Settings.Minute, new Stats {
                                [Stat.MaxSC] = item.GetTotal(Stat.MaxSC)
                            });
                    }

                    if (item.GetTotal(Stat.AttackSpeed) > 0)
                    {
                        AddBuff(BuffType.Storm, this, time * Settings.Minute, new Stats {
                                [Stat.AttackSpeed] = item.GetTotal(Stat.AttackSpeed)
                            });
                    }

                    if (item.GetTotal(Stat.HP) > 0)
                    {
                        AddBuff(BuffType.HealthAid, this, time * Settings.Minute, new Stats {
                                [Stat.HP] = item.GetTotal(Stat.HP)
                            });
                    }

                    if (item.GetTotal(Stat.MP) > 0)
                    {
                        AddBuff(BuffType.ManaAid, this, time * Settings.Minute, new Stats {
                                [Stat.MP] = item.GetTotal(Stat.MP)
                            });
                    }

                    if (item.GetTotal(Stat.MaxAC) > 0)
                    {
                        AddBuff(BuffType.Defence, this, time * Settings.Minute, new Stats {
                                [Stat.MaxAC] = item.GetTotal(Stat.MaxAC)
                            });
                    }

                    if (item.GetTotal(Stat.MaxMAC) > 0)
                    {
                        AddBuff(BuffType.MagicDefence, this, time * Settings.Minute, new Stats {
                                [Stat.MaxMAC] = item.GetTotal(Stat.MaxMAC)
                            });
                    }

                    if (item.GetTotal(Stat.BagWeight) > 0)
                    {
                        AddBuff(BuffType.BagWeight, this, time * Settings.Minute, new Stats {
                                [Stat.BagWeight] = item.GetTotal(Stat.BagWeight)
                            });
                    }
                }
                break;

                case 4:         //Exp
                {
                    int time = item.Info.Durability;
                    AddBuff(BuffType.Exp, this, Settings.Minute * time, new Stats {
                            [Stat.ExpRatePercent] = item.GetTotal(Stat.Luck)
                        });
                }
                break;

                case 5:         //Drop
                {
                    int time = item.Info.Durability;
                    AddBuff(BuffType.Drop, this, Settings.Minute * time, new Stats {
                            [Stat.ItemDropRatePercent] = item.GetTotal(Stat.Luck)
                        });
                }
                break;
                }
                break;

            case ItemType.Scroll:
                UserItem temp;
                switch (item.Info.Shape)
                {
                case 3:         //BenedictionOil
                    if (!TryLuckWeapon())
                    {
                        Owner.Enqueue(p);
                        return;
                    }
                    break;

                case 4:         //RepairOil
                    temp = Info.Equipment[(int)EquipmentSlot.Weapon];
                    if (temp == null || temp.MaxDura == temp.CurrentDura)
                    {
                        Owner.Enqueue(p);
                        return;
                    }
                    if (temp.Info.Bind.HasFlag(BindMode.DontRepair))
                    {
                        Owner.Enqueue(p);
                        return;
                    }
                    temp.MaxDura = (ushort)Math.Max(0, temp.MaxDura - Math.Min(5000, temp.MaxDura - temp.CurrentDura) / 30);

                    temp.CurrentDura = (ushort)Math.Min(temp.MaxDura, temp.CurrentDura + 5000);
                    temp.DuraChanged = false;

                    ReceiveChat("Your weapon has been partially repaired", ChatType.Hint);
                    Owner.Enqueue(new S.ItemRepaired {
                        UniqueID = temp.UniqueID, MaxDura = temp.MaxDura, CurrentDura = temp.CurrentDura
                    });
                    break;

                case 5:         //WarGodOil
                    temp = Info.Equipment[(int)EquipmentSlot.Weapon];
                    if (temp == null || temp.MaxDura == temp.CurrentDura)
                    {
                        Owner.Enqueue(p);
                        return;
                    }
                    if (temp.Info.Bind.HasFlag(BindMode.DontRepair) || (temp.Info.Bind.HasFlag(BindMode.NoSRepair)))
                    {
                        Owner.Enqueue(p);
                        return;
                    }
                    temp.CurrentDura = temp.MaxDura;
                    temp.DuraChanged = false;

                    ReceiveChat("Your weapon has been completely repaired", ChatType.Hint);
                    Owner.Enqueue(new S.ItemRepaired {
                        UniqueID = temp.UniqueID, MaxDura = temp.MaxDura, CurrentDura = temp.CurrentDura
                    });
                    break;

                case 6:         //ResurrectionScroll
                    if (CurrentMap.Info.NoReincarnation)
                    {
                        ReceiveChat(string.Format("Cannot use on this map"), ChatType.System);
                        Owner.Enqueue(p);
                        return;
                    }
                    if (Dead)
                    {
                        MP = Stats[Stat.MP];
                        Revive(MaxHealth, true);
                    }
                    break;
                }
                break;

            case ItemType.Book:
                UserMagic magic = new UserMagic((Spell)item.Info.Shape);

                if (magic.Info == null)
                {
                    Owner.Enqueue(p);
                    return;
                }

                Info.Magics.Add(magic);
                SendMagicInfo(magic);
                RefreshStats();
                break;

            case ItemType.Food:
                temp = Info.Equipment[(int)EquipmentSlot.Mount];
                if (temp == null || temp.MaxDura == temp.CurrentDura)
                {
                    Owner.Enqueue(p);
                    return;
                }

                switch (item.Info.Shape)
                {
                case 0:
                    temp.MaxDura = (ushort)Math.Max(0, temp.MaxDura - Math.Min(1000, temp.MaxDura - (temp.CurrentDura / 30)));
                    break;

                case 1:
                    break;
                }

                temp.CurrentDura = (ushort)Math.Min(temp.MaxDura, temp.CurrentDura + item.CurrentDura);
                temp.DuraChanged = false;

                ReceiveChat("Your mount has been fed.", ChatType.Hint);
                Owner.Enqueue(new S.ItemRepaired {
                    UniqueID = temp.UniqueID, MaxDura = temp.MaxDura, CurrentDura = temp.CurrentDura
                });

                RefreshStats();
                break;

            case ItemType.Transform:     //Transforms
            {
                AddBuff(BuffType.Transform, this, (Settings.Second * item.Info.Durability), new Stats(), values: item.Info.Shape);
            }
            break;

            case ItemType.Deco:

                DecoObject decoOb = new DecoObject
                {
                    Image           = item.Info.Shape,
                    CurrentMap      = CurrentMap,
                    CurrentLocation = CurrentLocation,
                };

                CurrentMap.AddObject(decoOb);
                decoOb.Spawned();

                Owner.Enqueue(decoOb.GetInfo());

                break;

            case ItemType.MonsterSpawn:

                var monsterID    = item.Info.Stats[Stat.HP];
                var spawnAsPet   = item.Info.Shape == 1;
                var conquestOnly = item.Info.Shape == 2;

                var monsterInfo = Envir.GetMonsterInfo(monsterID);
                if (monsterInfo == null)
                {
                    break;
                }

                MonsterObject monster = MonsterObject.GetMonster(monsterInfo);
                if (monster == null)
                {
                    break;
                }

                if (spawnAsPet)
                {
                    if (Pets.Count(t => !t.Dead && t.Race != ObjectType.Creature) >= Globals.MaxPets)
                    {
                        ReceiveChat("Maximum number of pets already reached.", ChatType.Hint);
                        Owner.Enqueue(p);
                        return;
                    }

                    monster.Master      = this;
                    monster.PetLevel    = 0;
                    monster.MaxPetLevel = 7;

                    Pets.Add(monster);
                }

                if (conquestOnly)
                {
                    var con = CurrentMap.GetConquest(CurrentLocation);
                    if (con == null)
                    {
                        ReceiveChat(string.Format("{0} can only be spawned during a conquest.", monsterInfo.GameName), ChatType.Hint);
                        Owner.Enqueue(p);
                        return;
                    }
                }

                monster.Direction  = Direction;
                monster.ActionTime = Envir.Time + 5000;

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

            case ItemType.SiegeAmmo:
                //TODO;
                break;

            default:
                return;
            }

            if (item.Count > 1)
            {
                item.Count--;
            }
            else
            {
                Info.Inventory[index] = null;
            }
            RefreshBagWeight();

            Report?.ItemChanged(item, 1, 1);

            p.Success = true;
            Owner.Enqueue(p);
        }