コード例 #1
0
        public static void LoadFromArea(StringReader sr)
        {
            while (true)
            {
                var letter = sr.ReadLetter();
                switch (letter)
                {
                case 'S':
                    return;

                case '*':
                    sr.ReadToEOL();
                    break;

                case 'M':
                    MobileDef md;
                    if (MobileDef.TryGetMobileDef(sr.ReadVnum(), out md))
                    {
                        SpecType st;
                        if (!TryLookup(sr.ReadWord(), out st))
                        {
                            throw new Exception($"Load_specials: 'M': vnum {md.Vnum}.");
                        }
                        md.SpecFun = st.SpecFun;
                    }
                    sr.ReadToEOL();
                    break;

                default:
                    throw new Exception($"Load_specials: letter '{letter}' not *MS.");
                }
            }
        }
コード例 #2
0
        public static void LoadFromArea(StringReader sr)
        {
            while (true)
            {
                var vnum = sr.ReadVnum();
                if (vnum == Vnum.None)
                {
                    break;
                }

                var sd = new ShopData {
                    Keeper = vnum
                };
                for (int i = 0; i < MAX_TRADE; ++i)
                {
                    sd.BuyType[i] = sr.ReadShort();
                }

                sd.ProfitBuy  = sr.ReadShort();
                sd.ProfitSell = sr.ReadShort();
                var open  = sr.ReadShort();
                var close = sr.ReadShort();
                sd.Hours = new Range <short>(open, close);
                sr.ReadToEOL();

                MobileDef md;
                if (MobileDef.TryGetMobileDef(sd.Keeper, out md))
                {
                    md.Shops.Add(sd);
                }
                else
                {
                    throw new Exception($"Keeper {sd.Keeper} not found for shop.");
                }
            }
        }
コード例 #3
0
        public static void LoadFromArea(StringReader sr)
        {
            while (true)
            {
                var letter = sr.ReadLetter();

                if (letter == 'S')
                {
                    break;
                }
                if (letter == '*')
                {
                    sr.ReadToEOL();
                    continue;
                }

                var rd = new ResetData {
                    Command = letter
                };
                sr.ReadNumber(); // if_flag
                rd.Arg1 = sr.ReadNumber();
                rd.Arg2 = sr.ReadNumber();
                if (letter != 'G' && letter != 'R')
                {
                    rd.Arg3 = sr.ReadNumber();
                }
                sr.ReadToEOL();

                Vnum      lastObj  = Vnum.None;
                Vnum      lastRoom = Vnum.None;
                RoomDef   roomData;
                MobileDef mobData;
                ObjectDef objData;
                ExitData  exitData;

                switch (rd.Command)
                {
                case 'M':
                    if (MobileDef.TryGetMobileDef((Vnum)rd.Arg1, out mobData) && RoomDef.TryGetRoomDef((Vnum)rd.Arg3, out roomData))
                    {
                        roomData.AddReset(rd);
                        lastRoom = roomData.Vnum;
                    }
                    break;

                case 'O':
                    if (ObjectDef.TryGetObjectData((Vnum)rd.Arg1, out objData) && RoomDef.TryGetRoomDef((Vnum)rd.Arg3, out roomData))
                    {
                        roomData.AddReset(rd);
                        lastObj = roomData.Vnum;
                    }
                    break;

                case 'P':
                    if (ObjectDef.TryGetObjectData((Vnum)rd.Arg1, out objData) && RoomDef.TryGetRoomDef(lastObj, out roomData))
                    {
                        roomData.AddReset(rd);
                    }
                    break;

                case 'G':
                case 'E':
                    if (ObjectDef.TryGetObjectData((Vnum)rd.Arg1, out objData) && RoomDef.TryGetRoomDef(lastRoom, out roomData))
                    {
                        roomData.AddReset(rd);
                        lastObj = lastRoom;
                    }
                    break;

                case 'D':
                    if (rd.Arg2 < 0 ||
                        rd.Arg2 > 5 ||
                        !RoomDef.TryGetRoomDef((Vnum)rd.Arg1, out roomData) ||
                        !roomData.TryGetExit(rd.Arg2, out exitData) ||
                        !exitData.IsDoor)
                    {
                        throw new Exception($"Load_resets: 'D': exit {rd.Arg2} not door.");
                    }

                    switch (rd.Arg3)
                    {
                    case 0: break;

                    case 1:
                        exitData.RSFlags |= ExitFlags.Closed;
                        break;

                    case 2:
                        exitData.RSFlags |= ExitFlags.Closed | ExitFlags.Locked;
                        break;

                    default:
                        throw new Exception($"Load_resets: 'D': bad 'locks': {rd.Arg3}.");
                    }
                    break;

                case 'R':
                    if (rd.Arg2 < 0 || rd.Arg2 > 6)
                    {
                        throw new Exception($"Load_resets: 'R': bad exit {rd.Arg2}.");
                    }

                    if (RoomDef.TryGetRoomDef((Vnum)rd.Arg2, out roomData))
                    {
                        roomData.AddReset(rd);
                    }
                    break;

                default:
                    throw new Exception($"Load_resets: bad command '{rd.Command}'.");
                }
            }
        }
コード例 #4
0
        static CharData LoadCharData(StringReader sr, UserConnection conn)
        {
            var ch = new CharData(conn);

            while (true)
            {
                var word = sr.ReadWord();
                switch (word)
                {
                // A ----------------
                case "Act": ch.Act = sr.ReadNumber(); break;

                case "AffectedBy": ch.AffectedBy = sr.ReadNumber(); break;

                case "Alignment": ch.Alignment = sr.ReadNumber(); break;

                case "Armor": ch.Armor = sr.ReadNumber(); break;

                case "Avatarmessage": ch.PCData.AvatarMessage = sr.ReadString(); break;

                case "Awin": ch.PCData.Awins = sr.ReadNumber(); break;

                case "Alos": ch.PCData.Alosses = sr.ReadNumber(); break;

                case "Affect":
                case "AffectData":
                    var aff = new AffectData();
                    if (word == "Affect")
                    {
                        aff.Type = sr.ReadShort();
                    }
                    else
                    {
                        aff.Type = (short)SkillType.Lookup(sr.ReadWord());
                    }
                    aff.Duration  = sr.ReadShort();
                    aff.Modifier  = sr.ReadShort();
                    aff.Location  = sr.ReadShort();
                    aff.BitVector = sr.ReadNumber();
                    ch.Affected.Add(aff);
                    // TODO add to affect_free
                    break;

                case "AttrMod":
                    ch.PCData.ModStr = sr.ReadShort();
                    ch.PCData.ModInt = sr.ReadShort();
                    ch.PCData.ModWis = sr.ReadShort();
                    ch.PCData.ModDex = sr.ReadShort();
                    ch.PCData.ModCon = sr.ReadShort();
                    break;

                case "AttrPerm":
                    ch.PCData.PermStr = sr.ReadShort();
                    ch.PCData.PermInt = sr.ReadShort();
                    ch.PCData.PermWis = sr.ReadShort();
                    ch.PCData.PermDex = sr.ReadShort();
                    ch.PCData.PermCon = sr.ReadShort();
                    break;

                case "Alias":
                    var ad = new AliasData();
                    ad.ShortN = sr.ReadString();
                    ad.LongN  = sr.ReadString();
                    ch.PCData.Alias.Add(ad);
                    // add to alias_free
                    break;

                // B ----------------
                case "Bamfin": ch.PCData.Bamfin = sr.ReadString(); break;

                case "Bamfout": ch.PCData.Bamfout = sr.ReadString(); break;

                case "Beast": ch.Beast = sr.ReadShort(); break;

                case "Bounty": ch.PCData.Bounty = sr.ReadNumber(); break;

                case "Breath1": sr.ReadNumber(); break;

                case "Breath2": sr.ReadNumber(); break;

                case "Breath3": sr.ReadNumber(); break;

                case "Breath4": sr.ReadNumber(); break;

                case "Breath5": sr.ReadNumber(); break;

                case "Boards":
                    var numBoards = sr.ReadNumber();
                    for (int i = 0; i < numBoards; ++i)
                    {
                        var boardname = sr.ReadWord();
                        var lastNote  = sr.ReadNumberAsDateTime();

                        var board = BoardData.Lookup(boardname);
                        if (board == -1)
                        {
                            Content.log.Warn($"{ch.Name} had unknown board name: {boardname}. Skipped.");
                        }
                        else
                        {
                            ch.PCData.LastNote[i] = lastNote;
                        }
                    }
                    break;

                // C ----------------
                case "Clan": ch.Clan = sr.ReadString(); break;

                case "Class": ch.Class_ = sr.ReadNumber(); break;

                case "CurrentForm": ch.CurForm = sr.ReadShort(); break;

                case "Combat":
                    ch.Cmbt = ReadArray(sr, _ => _.ReadShort(), 8);
                    break;

                case "Chi":
                    ch.Chi = ReadArray(sr, _ => _.ReadShort(), 2);
                    break;

                case "Conception":
                    ch.PCData.Conception = sr.ReadString();
                    break;

                case "Condition":
                    ch.PCData.Condition = ReadArray(sr, _ => _.ReadShort(), 3);
                    break;

                case "CPower":
                    ch.Power = ReadArray(sr, _ => _.ReadNumber(), 44);
                    break;

                case "Cparents": ch.PCData.CParents = sr.ReadString(); break;

                case "Cprompt": ch.CPrompt = sr.ReadString(); break;

                case "Createtime": ch.CreateTime = sr.ReadString(); break;

                // D ----------------
                case "Damroll": ch.DamRoll = sr.ReadNumber(); break;

                case "Deaf": ch.Deaf = sr.ReadNumber(); break;

                case "Decapmessage": ch.PCData.DecapMessage = sr.ReadString(); break;

                case "Demonic": sr.ReadNumber(); break;

                case "Description": ch.Description = sr.ReadString(); break;

                case "DiscRese": ch.PCData.DiscResearch = sr.ReadNumber(); break;

                case "DiscPoin": ch.PCData.DiscPoints = sr.ReadNumber(); break;

                case "Dragonaff": sr.ReadNumber(); break;

                case "Dragonage": sr.ReadNumber(); break;

                case "Disc": for (int i = 0; i < 11; ++i)
                    {
                        sr.ReadNumber();
                    }
                    break;

                case "Drowaff": sr.ReadNumber(); break;

                case "Drowpwr": sr.ReadNumber(); break;

                case "Drowmag": sr.ReadNumber(); break;

                // E ----------------
                case "Email": sr.ReadString(); break;

                case "End": return(ch);

                case "Exhaustion": ch.PCData.Exhaustion = sr.ReadShort(); break;

                case "Exp": ch.Exp = sr.ReadNumber(); break;

                case "Explevel": ch.ExpLevel = sr.ReadNumber(); break;

                case "Expgained": ch.ExpGained = sr.ReadNumber(); break;

                case "Extra": ch.Extra = sr.ReadNumber(); break;

                // F ----------------
                case "FakeCon":
                    ch.PCData.FakeSkill  = sr.ReadShort();
                    ch.PCData.FakeStance = sr.ReadShort();
                    ch.PCData.FakeHit    = sr.ReadShort();
                    ch.PCData.FakeDam    = sr.ReadShort();
                    ch.PCData.FakeAC     = sr.ReadNumber();
                    ch.PCData.FakeHP     = sr.ReadShort();
                    ch.PCData.FakeMana   = sr.ReadShort();
                    ch.PCData.FakeMove   = sr.ReadShort();
                    break;

                case "Focus":
                    ch.Focus = ReadArray(sr, _ => _.ReadShort(), 2);
                    break;

                case "Flag2": ch.Flag2 = sr.ReadNumber(); break;

                case "Flag3": ch.Flag3 = sr.ReadNumber(); break;

                case "Flag4": ch.Flag4 = sr.ReadNumber(); break;

                case "Form": ch.Form = sr.ReadNumber(); break;

                // G ----------------
                case "Generation": ch.Generation = sr.ReadShort(); break;

                case "Gnosis": ch.Gnosis = new short[Garou.GMAXIMUM] {
                        sr.ReadShort()
                }; break;

                case "Genes":
                    ch.PCData.Genes = ReadArray(sr, _ => _.ReadNumber(), 10);
                    break;

                case "Garou1": ch.Garou1 = sr.ReadNumber(); break;

                case "Garou2": ch.Garou2 = sr.ReadNumber(); break;

                case "Gifts":
                    ch.Gifts = ReadArray(sr, _ => _.ReadNumber(), 21);
                    break;

                case "Gold": ch.Gold = sr.ReadNumber(); break;

                // H ----------------
                case "Hitroll": ch.HitRoll = sr.ReadNumber(); break;

                case "Home": ch.Home = sr.ReadNumber(); break;

                case "Hatch": sr.ReadNumber(); break;

                case "HpManaMove":
                    ch.Hit     = sr.ReadNumber();
                    ch.MaxHit  = sr.ReadNumber();
                    ch.Mana    = sr.ReadNumber();
                    ch.MaxMana = sr.ReadNumber();
                    ch.Move    = sr.ReadNumber();
                    ch.MaxMove = sr.ReadNumber();
                    break;

                // I ----------------
                case "Immune": ch.Immune = sr.ReadNumber(); break;

                case "Itemaffect": ch.ItemAffect = sr.ReadNumber(); break;

                // J ----------------
                case "Jflags": ch.PCData.JFlags = sr.ReadNumber(); break;

                // K ----------------
                case "Kingdom": ch.PCData.Kingdom = sr.ReadNumber(); break;

                // L ----------------
                case "Language":
                    ch.PCData.Language = ReadArray(sr, _ => _.ReadNumber(), 2);
                    break;

                case "Lasthost": ch.LastHost = sr.ReadString(); break;

                case "Lastdecap1": ch.PCData.LastDecap[0] = sr.ReadString(); break;

                case "Lastdecap2": ch.PCData.LastDecap[1] = sr.ReadString(); break;

                case "Lasttime": ch.LastTime = sr.ReadString(); break;

                case "Level": ch.Level = sr.ReadNumber(); break;

                case "Levelexp": sr.ReadNumber(); break;

                case "Locationhp":
                    ch.LocHP = ReadArray(sr, _ => _.ReadShort(), 7);
                    break;

                case "Loginmessage": ch.PCData.LoginMessage = sr.ReadString(); break;

                case "Logoutmessage": ch.PCData.LogoutMessage = sr.ReadString(); break;

                case "LongDescr": ch.LongDescription = sr.ReadString(); break;

                case "Lord": ch.Lord = sr.ReadString(); break;

                // M ----------------
                case "MageFlags": sr.ReadNumber(); break;

                case "Monkab":
                    ch.MonkAb = ReadArray(sr, _ => _.ReadNumber(), 4);
                    break;

                case "Meanparadox": ch.PCData.MeanParadoxCounter = sr.ReadShort(); break;

                case "Monkstuff": ch.MonkStuff = sr.ReadNumber(); break;

                case "Monkcrap": ch.MonkCrap = sr.ReadNumber(); break;

                case "Marriage": ch.PCData.Marriage = sr.ReadString(); break;

                case "Morph": ch.Morph = sr.ReadString(); break;

                // N ----------------
                case "Newbits": ch.NewBits = sr.ReadNumber(); break;

                case "Name": sr.ReadToEOL(); break;

                // O ----------------
                case "Objvnum": ch.PCData.ObjVNum = sr.ReadVnum(); break;

                case "ObjDesc": ch.ObjDesc = sr.ReadString(); break;

                // P ----------------
                case "Paradox":
                    ch.Paradox = ReadArray(sr, _ => _.ReadNumber(), 3);
                    break;

                case "Parents": ch.PCData.Parents = sr.ReadString(); break;

                case "Password": ch.PCData.Pwd = sr.ReadString(); break;

                case "Played": ch.Played = sr.ReadNumber(); break;

                case "Polyaff": ch.PolyAff = sr.ReadNumber(); break;

                case "Power_Point": sr.ReadNumber(); break;

                case "Power":
                    ch.PCData.Powers = ReadArray(sr, _ => _.ReadNumber(), 20);
                    break;

                case "Poweraction": ch.PowerAction = sr.ReadString(); break;

                case "Powertype": ch.PowerType = sr.ReadString(); break;

                case "Position": ch.Position = sr.ReadNumber(); break;

                case "Practice": ch.Practice = sr.ReadNumber(); break;

                case "PkPdMkMd":
                    ch.PKill  = sr.ReadNumber();
                    ch.PDeath = sr.ReadNumber();
                    ch.MKill  = sr.ReadNumber();
                    ch.MDeath = sr.ReadNumber();
                    break;

                case "Prompt": ch.Prompt = sr.ReadString(); break;

                // Q ----------------
                case "Quest": ch.PCData.Quest = sr.ReadNumber(); break;

                case "Questsrun": ch.PCData.QuestsRun = sr.ReadNumber(); break;

                case "Queststotal": ch.PCData.QuestsTotal = sr.ReadNumber(); break;

                // R ----------------
                case "Race": ch.PCData.Quest = sr.ReadNumber(); break;

                case "Rage": ch.Rage = sr.ReadShort(); break;

                case "Rank": ch.PCData.Rank = sr.ReadShort(); break;

                case "Relrank": ch.PCData.RelRank = sr.ReadShort(); break;

                case "Revision": ch.PCData.Revision = sr.ReadShort(); break;

                case "Runecount": ch.PCData.RuneCount = sr.ReadShort(); break;

                case "Room":
                    RoomDef room;
                    if (RoomDef.TryGetRoomDef(sr.ReadVnum(), out room))
                    {
                        ch.InRoom = room;
                    }
                    break;

                case "Runes":
                    ReadArray(sr, _ => _.ReadNumber(), 4);
                    break;

                // S ----------------
                case "Smite": sr.ReadString(); break;

                case "SavingThrow": ch.SavingThrow = sr.ReadNumber(); break;

                case "Switchname": ch.PCData.SwitchName = sr.ReadString(); break;

                case "SilTol": ch.SilTol = sr.ReadShort(); break;

                case "Souls": ch.PCData.Souls = sr.ReadShort(); break;

                case "Score":
                    ch.PCData.Score = ReadArray(sr, _ => _.ReadNumber(), 6);
                    break;

                case "Sex": ch.Sex = (Gender)sr.ReadShort(); break;

                case "ShortDescr": ch.ShortDescription = sr.ReadString(); break;

                case "Security": ch.PCData.Security = sr.ReadNumber(); break;

                case "Skill":
                    var value = sr.ReadShort();
                    var sn    = SkillType.Lookup(sr.ReadWord());
                    if (sn >= 0)
                    {
                        ch.PCData.Learned[sn] = value;
                    }
                    break;

                case "Specpower": ch.SpecPower = sr.ReadShort(); break;

                case "Spectype": ch.SpecType = sr.ReadShort(); break;

                case "Special": ch.Special = sr.ReadNumber(); break;

                case "Spells":
                    ch.Spl = ReadArray(sr, _ => _.ReadShort(), 5);
                    break;

                case "Stage":
                    ch.PCData.Stage = ReadArray(sr, _ => _.ReadShort(), 3);
                    break;

                case "Stance":
                    for (int i = 0; i < 12; ++i)
                    {
                        ch.Stance[i] = sr.ReadNumber();
                    }
                    break;

                case "Stance2":
                    for (int i = 0; i < 12; ++i)
                    {
                        ch.Stance[i + 12] = sr.ReadNumber();
                    }
                    break;

                case "StatAbility":
                    ch.PCData.StatAbility = ReadArray(sr, _ => _.ReadShort(), 4);
                    break;

                case "StatAmount":
                    ch.PCData.StatAmount = ReadArray(sr, _ => _.ReadShort(), 4);
                    break;

                case "StatDuration":
                    ch.PCData.StatDuration = ReadArray(sr, _ => _.ReadShort(), 4);
                    break;

                case "Stats":
                    ch.PCData.Stats = ReadArray(sr, _ => _.ReadNumber(), 12);
                    break;

                // T ----------------
                case "Tiemessage": ch.PCData.TimeMessage = sr.ReadString(); break;

                case "Trust": ch.Trust = sr.ReadShort(); break;

                case "Title":
                    var title = sr.ReadString().Trim();
                    ch.PCData.Title = " " + title;
                    break;

                // U ----------------
                case "Upgradelevel": ch.PCData.UpgradeLevel = sr.ReadShort(); break;

                // V ----------------
                case "Vampaff": sr.ReadNumber(); break;

                case "Vampgen": sr.ReadNumber(); break;

                case "Vnum":
                    var       mdvnum = sr.ReadVnum();
                    MobileDef md;
                    if (MobileDef.TryGetMobileDef(mdvnum, out md))
                    {
                        ch.IndexData = md;
                    }
                    break;

                // W ----------------
                case "Warps": ch.Warp = sr.ReadNumber(); break;

                case "WarpCount": ch.WarpCount = sr.ReadShort(); break;

                case "Weapons":
                    ch.Wpn = ReadArray(sr, _ => _.ReadShort(), 13);
                    break;

                case "Wimpy": ch.Wimpy = sr.ReadShort(); break;

                case "Wolf": sr.ReadShort(); break;

                case "Wolfform":
                    sr.ReadNumber();
                    sr.ReadNumber();
                    break;

                // X ----------------
                case "XHitroll": ch.XHitRoll = sr.ReadNumber(); break;

                case "XDamroll": ch.XDamRoll = sr.ReadNumber(); break;

                default:
                    Content.log.Error($"no match.WORD: {word}");
                    sr.ReadToEOL();
                    break;
                }
            }
        }