コード例 #1
0
ファイル: temp.cs プロジェクト: briansteffens/rm-lib
    public void Spawn()
    {
        var rand = new Random();

        uint area = MapInfo.Width * MapInfo.Height;

        var mop = new RM.v38.MOP();

        string fn = CONFIG.SERVER_PATH + "Data/Mop/Mop" +
                    MapInfo.Map.ToString().PadLeft(5, '0') + ".rsm";
        Console.WriteLine(fn);
        mop.Load(File.ReadAllText(fn));

        while (true)
        {
            if (mop.AllItems.Count > 1 &&
                mop.AllItems[mop.AllItems.Count - 1] is BlankLine &&
                mop.AllItems[mop.AllItems.Count - 2] is BlankLine)
            break;

            mop.AllItems.Add(new BlankLine());
        }

        mop.AllItems.Add(new CommentLine(" BEGIN [" + Comment + "]"));

        uint quantity = (uint)Math.Ceiling((float)area / QuantityDivisor);
        if (quantity < 1) quantity = 1;

        foreach (ItemID item in Items)
        {
            var l = new MOP.Line() {
                Comment = "?",
                MonsterIndex = MapInfo.Mobs[rand.Next(MapInfo.Mobs.Length)],
                Left = 5,
                Top = 5,
                Right = MapInfo.Width - 5,
                Bottom = MapInfo.Height - 5,
                Pattern = AIPattern.Normal,
                Quantity = quantity,
                RespawnTime = (uint)rand.Next(180, 360),
            };

            int chance = rand.Next(5);
            for (int i = 0; i < chance; i++)
                l.Drops.Add(new MOP.Drop() {
                    Item = item,
                    Count = 1,
                });

            mop.AllItems.Add(l);
        }

        mop.AllItems.Add(new CommentLine(" END [" + Comment + "]"));
        mop.AllItems.Add(new BlankLine());

        File.WriteAllText(fn, mop.Save());
    }
コード例 #2
0
ファイル: temp.cs プロジェクト: k3v1n1990s/rm-lib
    public void Spawn()
    {
        var rand = new Random();

        uint area = MapInfo.Width * MapInfo.Height;

        var mop = new RM.v38.MOP();

        string fn = CONFIG.SERVER_PATH + "Data/Mop/Mop" +
                    MapInfo.Map.ToString().PadLeft(5, '0') + ".rsm";

        Console.WriteLine(fn);
        mop.Load(File.ReadAllText(fn));

        while (true)
        {
            if (mop.AllItems.Count > 1 &&
                mop.AllItems[mop.AllItems.Count - 1] is BlankLine &&
                mop.AllItems[mop.AllItems.Count - 2] is BlankLine)
            {
                break;
            }

            mop.AllItems.Add(new BlankLine());
        }

        mop.AllItems.Add(new CommentLine(" BEGIN [" + Comment + "]"));

        uint quantity = (uint)Math.Ceiling((float)area / QuantityDivisor);

        if (quantity < 1)
        {
            quantity = 1;
        }

        foreach (ItemID item in Items)
        {
            var l = new MOP.Line()
            {
                Comment      = "?",
                MonsterIndex = MapInfo.Mobs[rand.Next(MapInfo.Mobs.Length)],
                Left         = 5,
                Top          = 5,
                Right        = MapInfo.Width - 5,
                Bottom       = MapInfo.Height - 5,
                Pattern      = AIPattern.Normal,
                Quantity     = quantity,
                RespawnTime  = (uint)rand.Next(180, 360),
            };

            int chance = rand.Next(5);
            for (int i = 0; i < chance; i++)
            {
                l.Drops.Add(new MOP.Drop()
                {
                    Item  = item,
                    Count = 1,
                });
            }

            mop.AllItems.Add(l);
        }

        mop.AllItems.Add(new CommentLine(" END [" + Comment + "]"));
        mop.AllItems.Add(new BlankLine());

        File.WriteAllText(fn, mop.Save());
    }