示例#1
0
        public static void ReturnToLoad(CharData ch)
        {
            if (!ch || !ch.InRoom)
            {
                return;
            }
            if (ch.InRoom.Area != Room.GetRoom(ch.LoadRoomIndexNumber).Area)
            {
                return;
            }

            Exit.Direction dir = FindPath(ch.InRoom.IndexNumber, ch.LoadRoomIndexNumber, ch, -40000, true);

            if (dir == Exit.Direction.invalid)
            {
                return;
            }

            if (ch.InRoom.ExitData[(int)dir].HasFlag(Exit.ExitFlag.closed) &&
                !ch.IsAffected(Affect.AFFECT_PASS_DOOR) && !ch.HasInnate(Race.RACE_PASSDOOR))
            {
                CommandType.Interpret(ch, "unlock " + dir.ToString());
                CommandType.Interpret(ch, "open " + dir.ToString());
                return;
            }

            ch.Move(dir);

            if (!ch.InRoom)
            {
                string text = "Return_to_load: no ch._inRoom!  Mob #" + ch.MobileTemplate.IndexNumber + ", _name: " +
                              ch.Name + ".  Placing mob in limbo (mob.AddToRoom()).";
                Log.Error(text, 0);
                ch.AddToRoom(Room.GetRoom(StaticRooms.GetRoomNumber("ROOM_NUMBER_LIMBO")));
                ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_SPAM, 0, text);
                return;
            }
            return;
        }
示例#2
0
        /// <summary>
        /// Initialize a new PC with default values.
        /// </summary>
        public PC()
        {
            ++NumPc;
            Prompt         = "&+g<%hhp %mm %vmv>\r\n<&n%D %B&+g>&n ";
            Score          = 0.0;
            PageLength     = 25;
            IsSwitched     = false;
            Speaking       = 0;
            ActionFlags[0] = PLAYER_CAST_TICK.Vector | PLAYER_TELL.Vector | PLAYER_SHOUT.Vector |
                             PLAYER_PROMPT.Vector | PLAYER_COMBINE.Vector | PLAYER_MAP.Vector |
                             PLAYER_PAGER.Vector | PLAYER_AUTOWRAP.Vector | PLAYER_COLOR.Vector | PLAYER_VICIOUS.Vector;
            HitpointModifier = 0;
            GuildRank        = 0;
            Train            = 0;
            Frags            = 0;
            PlayerKills      = 0;
            PlayerDeaths     = 0;
            MobKills         = 0;
            MobDeaths        = 0;
            FirstaidTimer    = 0;
            CreationTime     = new DateTime(); // Creation time, actual.
            Created          = new ItemStatus();
            Destroyed        = new ItemStatus();
            Birthdate        = new DateTime(); // Creation time used for age calculations.  Unlike creation time, it can change.
            OriginalHome     = StaticRooms.GetRoomNumber("ROOM_NUMBER_START");
            CurrentHome      = StaticRooms.GetRoomNumber("ROOM_NUMBER_START");
            Height           = 60 + MUDMath.Dice(2, 10);
            Weight           = 15 + (Height * 2);
            RaceStrMod       = 0;
            RaceIntMod       = 0;
            RaceWisMod       = 0;
            RaceDexMod       = 0;
            RaceConMod       = 0;
            RaceAgiMod       = 0;
            RaceChaMod       = 0;
            RacePowMod       = 0;
            RaceLukMod       = 0;
            MaxStrMod        = 0;
            MaxIntMod        = 0;
            MaxWisMod        = 0;
            MaxDexMod        = 0;
            MaxConMod        = 0;
            MaxAgiMod        = 0;
            MaxChaMod        = 0;
            MaxPowMod        = 0;
            MaxLukMod        = 0;
            AggressiveLevel  = -1;
            Tradition        = 0;
            SkillPoints      = 0;
            Chi                 = 0;
            MaxChi              = 0;
            Stance              = String.Empty;
            LastRentLocation    = 0;
            LostHp              = 0;
            MonkRestriction     = 0;
            IsWieldingTwohanded = false;
            Editing             = SocketConnection.EditState.none;
            Security            = 0;
            int count;

            SpellAptitude = new SerializableDictionary <String, Int32>();
            SkillAptitude = new SerializableDictionary <String, Int32>();
            SongAptitude  = new SerializableDictionary <String, Int32>();
            MonkAptitude  = new SerializableDictionary <String, Int32>();

            LanguageAptitude = new int[Race.MAX_LANG];
            for (count = 0; count < Race.MAX_LANG; ++count)
            {
                LanguageAptitude[count] = 0;
            }
            TrophyData = new TrophyData[Limits.MAX_LEVEL];
            for (count = 0; count < Limits.MAX_LEVEL; ++count)
            {
                TrophyData[count] = new TrophyData();
                TrophyData[count].MobIndexNumber = 0;
                TrophyData[count].NumberKilled   = 0;
            }
            Thirst        = 48;
            Hunger        = 48;
            Drunk         = 0;
            Bank          = new Coins();
            Bank.Copper   = 0;
            Bank.Silver   = 0;
            Bank.Gold     = 0;
            Bank.Platinum = 0;
        }
示例#3
0
        /// <summary>
        /// Tracking code.
        /// </summary>
        /// <param name="ch"></param>
        public static void HuntVictim(CharData ch)
        {
            if (!ch || !ch.Hunting || !ch.IsAffected(Affect.AFFECT_TRACK))
            {
                return;
            }

            if (ch.CurrentPosition != Position.standing)
            {
                if (ch.IsAffected(Affect.AFFECT_TRACK))
                {
                    ch.SendText("You abort your tracking effort.\r\n");
                    ch.RemoveAffect(Affect.AFFECT_TRACK);
                    Combat.StopHunting(ch);
                }
                return;
            }

            CharData tmp = null;

            try
            {
                /*
                 * Make sure the victim still exists.
                 */
                bool found = false;
                foreach (CharData it in Database.CharList)
                {
                    ch = it;
                    if (ch.Hunting != null && ch.Hunting.Who == tmp)
                    {
                        found = true;
                    }
                }

                if (!found || !CharData.CanSee(ch, ch.Hunting.Who))
                {
                    if (!ch.IsAffected(Affect.AFFECT_TRACK))
                    {
                        CommandType.Interpret(ch, "say Damn!  My prey is gone!");
                    }
                    else
                    {
                        ch.SendText("The trail seems to disappear.\r\n");
                        ch.RemoveAffect(Affect.AFFECT_TRACK);
                    }
                    Combat.StopHunting(ch);
                    return;
                }

                if (ch.InRoom == ch.Hunting.Who.InRoom)
                {
                    if (ch.Fighting)
                    {
                        return;
                    }
                    FoundPrey(ch, ch.Hunting.Who);
                    return;
                }

                ch.WaitState(Skill.SkillList["track"].Delay);
                Exit.Direction dir = FindPath(ch.InRoom.IndexNumber, ch.Hunting.Who.InRoom.IndexNumber, ch, -40000, true);

                if (dir == Exit.Direction.invalid)
                {
                    if (!ch.IsAffected(Affect.AFFECT_TRACK))
                    {
                        SocketConnection.Act("$n&n says 'Damn! Lost $M!'", ch, null, ch.Hunting.Who, SocketConnection.MessageTarget.room);
                    }
                    else
                    {
                        ch.SendText("You lose the trail.\r\n");
                        ch.RemoveAffect(Affect.AFFECT_TRACK);
                        Combat.StopHunting(ch);
                    }
                    return;
                }

                /*
                 * Give a random direction if the mob misses the die roll.
                 */
                if (MUDMath.NumberPercent() > 75)   /* @ 25% */
                {
                    do
                    {
                        dir = Database.RandomDoor();
                    }while (!(ch.InRoom.ExitData[(int)dir]) || !(ch.InRoom.ExitData[(int)dir].TargetRoom));
                }

                if (ch.InRoom.ExitData[(int)dir].HasFlag(Exit.ExitFlag.closed))
                {
                    CommandType.Interpret(ch, "open " + dir.ToString());
                    return;
                }
                ImmortalChat.SendImmortalChat(null, ImmortalChat.IMMTALK_HUNTING, 0, String.Format("{0}&n leaves room {1} to the {2}.",
                                                                                                   ch.ShortDescription, ch.InRoom.IndexNumber, dir.ToString()));
                if (ch.IsAffected(Affect.AFFECT_TRACK))
                {
                    SocketConnection.Act(String.Format("You sense $N&n's trail {0} from here...", dir.ToString()),
                                         ch, null, ch.Hunting.Who, SocketConnection.MessageTarget.character);
                }
                ch.Move(dir);
                if (ch.IsAffected(Affect.AFFECT_TRACK))
                {
                    SocketConnection.Act("$n&n peers around looking for tracks.", ch, null, null, SocketConnection.MessageTarget.room);
                }

                if (!ch.Hunting)
                {
                    if (!ch.InRoom)
                    {
                        string text = String.Empty;
                        text = String.Format("Hunt_victim: no ch.in_room!  Mob #{0}, _name: {1}.  Placing mob in limbo (ch.AddToRoom()).",
                                             ch.MobileTemplate.IndexNumber, ch.Name);
                        Log.Error(text, 0);
                        ch.AddToRoom(Room.GetRoom(StaticRooms.GetRoomNumber("ROOM_NUMBER_LIMBO")));
                        text = String.Format("{0}&n has gone to limbo while hunting {1}.", ch.ShortDescription, ch.Hunting.Name);
                        ImmortalChat.SendImmortalChat(null, ImmortalChat.IMMTALK_HUNTING, 0, text);
                        return;
                    }
                    CommandType.Interpret(ch, "say Damn!  Lost my prey!");
                    return;
                }
                if (ch.InRoom == ch.Hunting.Who.InRoom)
                {
                    FoundPrey(ch, ch.Hunting.Who);
                }
                return;
            }
            catch (Exception ex)
            {
                Log.Error("Exception in HuntVictim: " + ex.ToString());
            }
        }
示例#4
0
        /// <summary>
        /// Loads the entire MUD database including all classes, races, areas, helps, sytem data, etc.
        /// </summary>
        public void LoadDatabase()
        {
            DatabaseIsBooting = true;

            Log.Trace(DateTime.Now.ToShortDateString() + " BOOT: -------------------------[ Boot Log ]-------------------------");

            Log.Trace("Validating that player directories exist.");
            for (Char letter = 'a'; letter <= 'z'; letter++)
            {
                String directory = FileLocation.PlayerDirectory + letter;
                if (!Directory.Exists(directory))
                {
                    Log.Trace("Creating directory: " + directory + ".");
                    Directory.CreateDirectory(directory);
                }
            }
            Log.Trace("Player directories validated.");

            Log.Trace("Loading Database.SystemData.");
            Sysdata.Load();
            SystemData.CurrentTime  = DateTime.Now;
            SystemData.GameBootTime = SystemData.CurrentTime;

            // Set time and weather.
            Log.Trace("Setting time and weather.");
            SystemData.SetWeather();

            Log.Trace("Loading static rooms.");
            StaticRooms.Load();
            Log.Trace("Loaded " + StaticRooms.Count + " static rooms.");

            Log.Trace("Loading spells.");
            Spell.LoadSpells();
            Log.Trace("Loaded " + Spell.SpellList.Count + " spells.");

            Log.Trace("Loading skills.");
            Skill.LoadSkills();
            Log.Trace("Loaded " + Skill.SkillList.Count + " skills.");

            Log.Trace("Loading races.");
            Race.LoadRaces();
            Log.Trace("Loaded " + Race.Count + " races.");

            Log.Trace("Initializing skill Levels.");
            {
                int cclass;

                foreach (KeyValuePair <String, Skill> kvp in Skill.SkillList)
                {
                    for (cclass = 0; cclass < CharClass.ClassList.Length; cclass++)
                    {
                        kvp.Value.ClassAvailability[cclass] = Limits.LEVEL_LESSER_GOD;
                    }
                }
                foreach (KeyValuePair <String, Spell> kvp in Spell.SpellList)
                {
                    for (cclass = 0; cclass < CharClass.ClassList.Length; cclass++)
                    {
                        kvp.Value.SpellCircle[cclass] = Limits.MAX_CIRCLE + 3;
                    }
                }
            }

            Log.Trace("Loading classes.");
            CharClass.LoadClasses(true);
            Log.Trace("Loaded " + CharClass.Count + " classes.");

            Log.Trace("Assigning spell circles.");
            AssignSpellCircles();
            Log.Trace("Assigned spell circles.");

            Log.Trace("Loading socials.");
            SocialList = Socials.Load();
            Log.Trace("Loaded " + Social.Count + " socials.");

            Log.Trace("Loading bans.");
            LoadBans();
            Log.Trace("Loaded " + BanList.Count + " bans.");

            Log.Trace("Loading help entries.");
            HelpList = Help.Load(FileLocation.SystemDirectory + FileLocation.HelpFile);
            Log.Trace("Loaded " + Help.Count + " help entries.");

            Log.Trace("Loading screens.");
            Screen.Load(FileLocation.SystemDirectory + FileLocation.ScreenFile, FileLocation.BlankSystemFileDirectory + FileLocation.ScreenFile);
            Log.Trace("Loaded " + Screen.Count + " screens.");

            // Chatbots have to be loaded before mobs.
            Log.Trace("Loading chatbots.");
            ChatterBot.Load();
            Log.Trace("Loaded " + ChatterBot.Count + " chatbots.");

            // Read in all the area files.
            Log.Trace("Reading in area files...");
            LoadAreaFiles();
            Log.Trace("Loaded " + Area.Count + " areas.");

            string buf = String.Format("Loaded {0} mobs, {1} objects, {2} rooms, {3} shops, {4} helps, {5} resets, and {6} quests.",
                                       MobTemplate.Count, ObjTemplate.Count, Room.Count, Shop.Count, Help.Count, Reset.Count, QuestData.Count);

            Log.Trace(buf);

            Log.Trace("Loading guilds.");
            Guild.LoadGuilds();
            Log.Trace("Loaded " + Guild.Count + " guilds.");

            Log.Trace("Loading corpses.");
            CorpseList = CorpseData.Load();
            Log.Trace("Loaded " + CorpseData.Count + " corpses.");

            Log.Trace("Loading crimes.");
            Crime.Load();
            Log.Trace("Loaded " + Crime.Count + " crimes.");

            Log.Trace("Loading fraglist.");
            FraglistData.Fraglist.Load();

            Log.Trace("Loading issues.");
            Issue.Load();
            Log.Trace("Loaded " + Issue.Count + " issues.");

            Log.Trace("Loading bounties.");
            Bounty.Load();
            Log.Trace("Loaded " + Bounty.Count + " bounties.");

            Log.Trace("Initializing movement parameters.");
            Movement.Initialize();
            Log.Trace("Movement parameters initialized.");

            // Only compile spells that have attached code.  Otherwise use default handlers.
            Log.Trace("Compiling spells.");
            int good = 0;
            int bad  = 0;

            foreach (KeyValuePair <String, Spell> kvp in Spell.SpellList)
            {
                if (!String.IsNullOrEmpty(kvp.Value.Code))
                {
                    if (!SpellFunction.CompileSpell(kvp.Value))
                    {
                        ++bad;
                    }
                    else
                    {
                        ++good;
                    }
                }
            }
            Log.Trace("Done compiling spells. " + good + " were successful, " + bad + " failed.");

            // Links up exits and makes rooms runtime-ready so we can access them.
            Log.Trace("Linking exits.");
            LinkExits();

            // This has to be after LinkExits().
            Log.Trace("Loading zone connections.");
            ZoneConnectionList = ZoneConnection.Load();
            // Link zones together based on file.
            foreach (ZoneConnection connection in ZoneConnectionList)
            {
                RoomTemplate   room1     = Room.GetRoom(connection.FirstRoomNumber);
                RoomTemplate   room2     = Room.GetRoom(connection.SecondRoomNumber);
                Exit.Direction direction = connection.FirstToSecondDirection;
                if (room1 != null && room2 != null && direction != Exit.Direction.invalid)
                {
                    Exit exit = new Exit();
                    exit.TargetRoom  = room2;
                    exit.IndexNumber = connection.SecondRoomNumber;
                    room1.ExitData[(int)direction] = exit;
                    exit             = new Exit();
                    exit.TargetRoom  = room1;
                    exit.IndexNumber = connection.FirstRoomNumber;
                    room2.ExitData[(int)Exit.ReverseDirection(direction)] = exit;
                    Log.Trace("Connected " + room1.Area.Name + " to " + room2.Area.Name + " at " + room1.IndexNumber);
                }
                else
                {
                    Log.Error("Unable to connect room " + connection.FirstRoomNumber + " to " + connection.SecondRoomNumber + " in direction " + connection.FirstToSecondDirection);
                }
            }
            Log.Trace("Loaded " + ZoneConnectionList.Count + " zone connections.");


            DatabaseIsBooting = false;
            Log.Trace("Resetting areas.");
            AreaUpdate();

            Log.Trace("Creating events.");
            Event.CreateEvent(Event.EventType.save_corpses, Event.TICK_SAVE_CORPSES, null, null, null);
            Event.CreateEvent(Event.EventType.save_sysdata, Event.TICK_SAVE_SYSDATA, null, null, null);
            Event.CreateEvent(Event.EventType.violence_update, Event.TICK_COMBAT_UPDATE, null, null, null);
            Event.CreateEvent(Event.EventType.area_update, Event.TICK_AREA, null, null, null);
            Event.CreateEvent(Event.EventType.room_update, Event.TICK_ROOM, null, null, null);
            Event.CreateEvent(Event.EventType.object_special, Event.TICK_OBJECT, null, null, null);
            Event.CreateEvent(Event.EventType.mobile_update, Event.TICK_MOBILE, null, null, null);
            Event.CreateEvent(Event.EventType.weather_update, Event.TICK_WEATHER, null, null, null);
            Event.CreateEvent(Event.EventType.char_update, Event.TICK_CHAR_UPDATE, null, null, null);
            Event.CreateEvent(Event.EventType.object_update, Event.TICK_OBJ_UPDATE, null, null, null);
            Event.CreateEvent(Event.EventType.aggression_update, Event.TICK_AGGRESS, null, null, null);
            Event.CreateEvent(Event.EventType.memorize_update, Event.TICK_MEMORIZE, null, null, null);
            Event.CreateEvent(Event.EventType.hit_gain, Event.TICK_HITGAIN, null, null, null);
            Event.CreateEvent(Event.EventType.mana_gain, Event.TICK_MANAGAIN, null, null, null);
            Event.CreateEvent(Event.EventType.move_gain, Event.TICK_MOVEGAIN, null, null, null);
            Event.CreateEvent(Event.EventType.heartbeat, Event.TICK_WEATHER, null, null, null);

            return;
        }