示例#1
0
        static bool SpecHum(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (hit)
            {
                return(false);
            }

            if (!keeper || !keeper.InRoom)
            {
                return(false);
            }

            if (MUDMath.NumberPercent() < 9)
            {
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lcarried by&n $n&n.",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lyou are carrying.&n",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.character);
                return(true);
            }

            return(false);
        }
示例#2
0
        static bool SpecWindsabre(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (!keeper || !keeper.Fighting || !hit)
            {
                return(false);
            }

            if (MUDMath.NumberPercent() < 10 + keeper.Level / 10 && (keeper.Fighting.Hitpoints >= -9))
            {
                SocketConnection.Act("&+c$n's&n $p&n &+csummons forth a &+Cgust&n&+c of &+Wstrong winds!&N",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.everyone_but_victim);
                SocketConnection.Act("&+cYour&n $p&n &+csummons forth a &+Cgust&n&+c of &+Wstrong winds&N&+c, cutting into &n$N&n&+c!&N ",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.character);
                SocketConnection.Act("&+c$n's&n $p&n &+csummons forth a &+Cgust&n&+c of &+Wstrong winds&N&+c, cutting into you!&N ",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.victim);
                Spell spell = Spell.SpellList["chill touch"];
                if (spell != null)
                {
                    spell.Invoke(keeper, keeper.Level, keeper.Fighting);
                }
                return(true);
            }

            return(false);
        }
示例#3
0
        static bool SpecCelestial(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (!keeper || !keeper.Fighting || !hit)
            {
                return(false);
            }

            if (MUDMath.NumberPercent() < 10 && (keeper.Fighting.Hitpoints >= -9))
            {
                SocketConnection.Act("&+b$n's&n $p&n &+bs&+Bp&+ca&+Wr&n&+Ck&n&+cl&N&+Be&n&+bs with a &+csoft &+Bblue &n&+wg&+Wl&n&+wi&+Wtt&N&+we&+Wr&n&+b...&N",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.everyone_but_victim);
                SocketConnection.Act("&+bYour&n $p&n &+bs&+Bp&N&+ca&+Cr&+Wk&+Cl&+Be&n&+bs at &n$N&n&+b, &+Bglowing&N&+b with a&+c soft &+Bblue &N&+wg&+Wl&n&+wi&+Wtt&n&+we&+Wr&n&+b!&N ",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.character);
                SocketConnection.Act("&+b$n's&n $p&n &+bs&+Bp&N&+ca&+Cr&+Wk&+Cl&+Be&n&+bs at you, &+Bglowing&N&+b with a&+c soft &+Bblue &N&+wg&+Wl&n&+wi&+Wtt&n&+we&+Wr&n&+b!&N ",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.victim);
                Spell spl = Spell.SpellList["magic missile"];
                if (spl != null)
                {
                    spl.Invoke(keeper, keeper.Level, keeper.Fighting);
                }
                return(true);
            }

            return(false);
        }
示例#4
0
        static bool SpecGhoulbane(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (!keeper || !keeper.Fighting || !hit)
            {
                return(false);
            }

            CharData victim = keeper.Fighting;

            if (victim.IsUndead())
            {
                if (MUDMath.NumberPercent() < 10 && (keeper.Fighting.Hitpoints >= -9))
                {
                    SocketConnection.Act("&+w$n's&n $p&n &+Wglows&n &+wwith a powerful light!&N",
                                         keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.everyone_but_victim);
                    SocketConnection.Act("&+wYour&n $p&n &+Wglows&n &+was it bites into its victim!&n", keeper,
                                         (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("&+w$n's&n $p&n &+Wglows&n &+win an angry light as it burns you horribly!&N", keeper,
                                         (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.victim);
                    Spell.SpellList["destroy undead"].Invoke(keeper, 1, keeper.Fighting);
                    return(true);
                }
            }
            return(false);
        }
示例#5
0
        static bool SpecGiggle(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (hit)
            {
                return(false);
            }

            if (!keeper || !keeper.InRoom)
            {
                return(false);
            }

            if (MUDMath.NumberPercent() < 5)
            {
                SocketConnection.Act("$p&n carried by $n&n starts giggling to itself!",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("$p&n carried by you starts giggling to itself!",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.character);
                return(true);
            }

            return(false);
        }
示例#6
0
        static bool SpecWpBonethunder(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (keeper == null || keeper.Fighting == null || !hit)
            {
                return(false);
            }

            if (MUDMath.NumberPercent() < 10 && (keeper.Fighting.Hitpoints >= -9))
            {
                Spell spell = StringLookup.SpellLookup("bonethunder");
                if (!spell)
                {
                    Log.Error("SpecWpBonethunder: 'bonethunder' spell not found. Check the spells file.");
                    return(false);
                }
                SocketConnection.Act("&+w$n's&n $p&n &+wemits a horrible &+WCRACKING&n &+wnoise and&n $N&n &+wshreaks in agony!&N",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.everyone_but_victim);
                SocketConnection.Act("&+wYour&n $p&n &+wmakes a horrible&n &+WCRACKING&n &+wnoise and&n $N&n &+wshreaks in pain!", keeper,
                                     (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.character);
                SocketConnection.Act("&+w$n's&n $p&n &+wmakes a horrible&n &+WCRACKING&n &+wnoise and you feel your bones breaking!&N", keeper,
                                     (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.victim);
                spell.Invoke(keeper, keeper.Level, keeper.Fighting);
                return(true);
            }

            return(false);
        }
示例#7
0
        static bool SpecSoulMoan(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (hit)
            {
                return(false);
            }

            if (!keeper || !keeper.InRoom)
            {
                return(false);
            }

            if (MUDMath.NumberPercent() < 3)
            {
                SocketConnection.Act("The soul in $p&n carried by $n&n moans in agony.",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("The soul in $p&n carried by you moans to be set free!",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.character);
                return(true);
            }

            if (MUDMath.NumberPercent() < 2)
            {
                SocketConnection.Act("The soul in $p&n carried by $n&n tries to free itself!",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("The soul in $p&n carried by you starts writhing!",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.character);
                return(true);
            }

            return(false);
        }
示例#8
0
        /// <summary>
        /// Resets a single area.
        /// </summary>
        public static void ResetArea(Area area)
        {
            if (area == null)
            {
                return;
            }
            Room room;
            int  indexNumber;

            area.DefenderSquads         = 0;
            area.NumDefendersDispatched = 0;
            for (indexNumber = area.LowRoomIndexNumber; indexNumber <= area.HighRoomIndexNumber; indexNumber++)
            {
                if (indexNumber == 0)
                {
                    continue;
                }
                room = Room.GetRoom(indexNumber);
                if (room && room.Area == area)
                {
                    room.ResetRoom(area.TimesReset);
                }
            }
            area.AgeInSeconds = MUDMath.NumberRange(-Event.AREA_RESET_VARIABILITY, Event.AREA_RESET_VARIABILITY);
            area.TimesReset++;
            return;
        }
示例#9
0
        static bool SpecAutumndecay(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (!keeper || !keeper.Fighting || !hit)
            {
                return(false);
            }

            if (MUDMath.NumberPercent() < 10 && (keeper.Fighting.Hitpoints >= -9) &&
                !keeper.Fighting.IsAffected(Affect.AFFECT_WITHER))
            {
                SocketConnection.Act("&+y$n's&n $p&n &+ydives into &n$N&n&+y, and a &+Lblack m&N&+wis&+Lt&n&+y flows into the &+rwound!&N",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.everyone_but_victim);
                SocketConnection.Act("&+yYour&n $p&n &+ydives into &n$N&n&+y, and a &+Lblack m&N&+wis&+Lt&n&+y flows into the &+rwound!&N",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.character);
                SocketConnection.Act("&+y$n's&n $p&n &+ydives into you, and a &+Lblack m&N&+wis&+Lt&n&+y flows into the &+rwound!&N",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.victim);
                Spell spl = Spell.SpellList["wither"];
                if (spl != null)
                {
                    spl.Invoke(keeper, keeper.Level, keeper.Fighting);
                }
                return(true);
            }

            return(false);
        }
示例#10
0
        static bool SpecInferno(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            /* check to make sure the object has an owner and he's in the room */

            if (!keeper || !keeper.InRoom)
            {
                return(false);
            }

            if (MUDMath.NumberPercent() < 10)
            {
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lcarried by&n $n&n.",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lyou are carrying.&n",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.character);
                return(true);
            }

            /* check to see if the weapon is in combat */
            if (!keeper.Fighting || !hit)
            {
                return(false);
            }


            if (keeper.Fighting && keeper.InRoom && MUDMath.NumberPercent() < 10 &&
                keeper.Fighting.Hitpoints >= -9)
            {
                SocketConnection.Act("&+r$n&+r's $p&+r glows brightly and emits a storm of fire!&n",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("Your $p&+r glows brightly and emits a storm of fire!&n",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.character);
                int dam = MUDMath.Dice(10, 10) + 150;
                foreach (CharData victim in keeper.InRoom.People)
                {
                    if (victim.IsSameGroup(keeper) ||
                        victim == keeper || victim.Hitpoints < -9)
                    {
                        continue;
                    }
                    if (victim.FlightLevel != keeper.FlightLevel)
                    {
                        continue;
                    }
                    if (Magic.SpellSavingThrow(((Object)obj).Level, victim, AttackType.DamageType.fire))
                    {
                        Combat.InflictSpellDamage(keeper, victim, dam / 2, "inferno", AttackType.DamageType.fire);
                    }
                    else
                    {
                        Combat.InflictSpellDamage(keeper, victim, dam, "inferno", AttackType.DamageType.fire);
                    }
                }
            }

            return(false);
        }
示例#11
0
        static bool SpecSki(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            /* check to make sure the object has an owner and he's in the room */

            if (!keeper || !keeper.InRoom)
            {
                return(false);
            }

            if (MUDMath.NumberPercent() < 20)
            {
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lcarried by&n $n&n.",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lyou are carrying.&n",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.character);
                return(true);
            }

            /* chance of weapon screaming */

            if (MUDMath.NumberPercent() < 20)
            {
                SocketConnection.Act("&+LThe soul in&n $p&n &+Lcarried b&ny $n&n &+Lmoans in&n &+Ragony&n&+L.&n",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("&+LThe soul in&n $p&n &+Lcarried by you&n &+Rmoans&n &+Lto be set free!&n",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.character);
                return(true);
            }

            if (MUDMath.NumberPercent() < 20)
            {
                SocketConnection.Act("&+LThe soul in&n $p&n &+Lcarried by&n $n&n &+Ltries to free itself!&n",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("&+LThe soul in&n $p&n &+Lcarried by you starts&n &+Bwrithing!&n",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.character);
                return(true);
            }

            /* check to see if the weapon is in combat */

            if (!keeper.Fighting || !hit)
            {
                return(false);
            }

            /* harm proc - note that there has to be a spec_wp_harm above before this
             * will work */

            if (MUDMath.NumberPercent() < 20 && (keeper.Fighting.Hitpoints >= -9))
            {
                Spell.SpellList["harm"].Invoke(keeper, keeper.Level, keeper.Fighting);
                return(true);
            }

            return(false);
        }
示例#12
0
        /// <summary>
        /// Generates a random sentence.
        /// </summary>
        /// <returns></returns>
        public static string RandomSentence()
        {
            string text;

            NounType noun = Table[MUDMath.NumberRange(0, Table.Length - 1)];
            VerbType verb = VerbType.Table[MUDMath.NumberRange(0, VerbType.Table.Length - 1)];

            while (noun.Animate == false)
            {
                noun = Table[MUDMath.NumberRange(0, Table.Length - 1)];
            }

            if (MUDMath.NumberPercent() > 50)
            {
                if (MUDString.IsVowel(noun.Name))
                {
                    text = String.Format("An ");
                }
                else
                {
                    text = String.Format("A ");
                }
            }
            else
            {
                text = String.Format("The ");
            }

            text += noun.Name;
            text += " ";
            text += verb.Name;
            if (verb.DirectObject != VerbType.DirectObjectType.none)
            {
                noun = Table[MUDMath.NumberRange(0, Table.Length - 1)];

                if (MUDString.IsVowel(noun.Name))
                {
                    text += " an ";
                }
                else
                {
                    text += " a ";
                }

                text += noun.Name;
            }

            if (MUDMath.NumberPercent() > 80)
            {
                text += "!";
            }
            else
            {
                text += ".";
            }

            return(text);
        }
示例#13
0
        static bool SpecHornofplenty(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            /* check to make sure the object has an owner and he's in the room */

            if (!keeper || !keeper.InRoom)
            {
                return(false);
            }

            if (MUDMath.NumberPercent() < 2)
            {
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lcarried by&n $n&n.",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lyou are carrying.&n",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.character);
                return(true);
            }

            /* we need to make sure it doesn't check for hunger on an NPC/
             *
             * /* check for the hunger level of the holder */

            if (((PC)keeper).Hunger < 1 || ((PC)keeper).Thirst < 1)
            {
                SocketConnection.Act("$n's $p&n &+mglows&n&+y softly.&n",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("&+yYour&n $p&n &+mglows&n&+y softly.&n",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.character);

                foreach (CharData victim in keeper.InRoom.People)
                {
                    if (victim.IsNPC())
                    {
                        continue;
                    }

                    if (((PC)victim).Hunger < 30)
                    {
                        ((PC)victim).Hunger = 30;
                        victim.SendText("You feel full.\r\n");
                    }

                    if (((PC)victim).Thirst < 30)
                    {
                        ((PC)victim).Thirst = 30;
                        victim.SendText("You do not feel thirsty.\r\n");
                    }
                }
                return(true);
            }

            return(false);
        }
示例#14
0
        /// <summary>
        /// Returns a random room on one of the maps.
        /// Argument: 0 = any map
        ///           1 = Surface map 1
        ///           2 = Surface map 2
        ///           3 = Underdark map 1
        ///           4 = Underdark map 2
        ///           5 = Underdark map 3
        /// </summary>
        /// <param name="map"></param>
        /// <returns></returns>
        public static Room GetRandomMapRoom(Area map)
        {
            if (Room.Count < 1)
            {
                throw new IndexOutOfRangeException("No rooms loaded, cannot get a random map room.");
            }

            if (map == null)
            {
                List <Area> zones = new List <Area>();
                foreach (Area area in Database.AreaList)
                {
                    if (area.HasFlag(Area.AREA_WORLDMAP) && area.Rooms.Count > 0)
                    {
                        zones.Add(area);
                    }
                }
                if (zones.Count < 1)
                {
                    throw new IndexOutOfRangeException("GetRandomMapRoom(): No zones found with AREA_WORLDMAP flag set.");
                }
                int val = MUDMath.NumberRange(0, (zones.Count - 1));
                map = zones[val];
            }

            int max = map.Rooms.Count;

            if (max < 1)
            {
                throw new IndexOutOfRangeException("GetRandomMapRoom(): No rooms found in target zone.");
            }

            int  target = MUDMath.NumberRange(0, (map.Rooms.Count - 1));
            Room room   = Room.GetRoom(target);

            if (!room ||
                room.WorldmapTerrainType == 92 ||
                room.WorldmapTerrainType == 101 ||
                room.WorldmapTerrainType == 102 ||
                room.WorldmapTerrainType == 116 ||
                room.WorldmapTerrainType == 130 ||
                room.WorldmapTerrainType == 131 ||
                room.WorldmapTerrainType == 132 ||
                room.WorldmapTerrainType == 136 ||
                room.WorldmapTerrainType == 137 ||
                room.HasFlag(RoomTemplate.ROOM_PRIVATE) ||
                room.HasFlag(RoomTemplate.ROOM_SOLITARY) ||
                room.HasFlag(RoomTemplate.ROOM_NO_TELEPORT) ||
                room.TerrainType == TerrainType.underground_impassable)
            {
                room = GetRandomMapRoom(map);
            }
            return(room);
        }
示例#15
0
        /// <summary>
        /// Makes a string look drunk.
        /// </summary>
        /// <param name="inputString"></param>
        /// <param name="ch"></param>
        /// <returns></returns>
        public static string MakeDrunk(string inputString, CharData ch)
        {
            int drunklevel = 0;

            if (!ch.IsNPC())
            {
                drunklevel = ((PC)ch).Drunk;
            }

            // Nothing to do here.
            if (drunklevel == 0)
            {
                return(inputString);
            }

            string output = String.Empty;

            // Check how drunk a person is...
            for (int pos = 0; pos < inputString.Length; pos++)
            {
                char temp = inputString[pos];

                if ((char.ToUpper(temp) >= 'A') && (char.ToUpper(temp) <= 'Z'))
                {
                    int drunkpos = char.ToUpper(temp) - 'A';
                    if (drunklevel > _drunkSubstitution[drunkpos]._minDrunkLevel)
                    {
                        int randomnum = MUDMath.NumberRange(0, _drunkSubstitution[drunkpos]._numReplacements);
                        output += _drunkSubstitution[drunkpos]._replacement[randomnum];
                    }
                    else
                    {
                        output += temp;
                    }
                }
                else
                {
                    if (drunklevel < 4)
                    {
                        output += MUDMath.FuzzyNumber(temp);
                    }
                    else if ((temp >= '0') && (temp <= '9'))
                    {
                        output += MUDMath.NumberRange(0, 9).ToString();
                    }
                    else
                    {
                        output += temp;
                    }
                }
            }
            return(output);
        }
示例#16
0
        static bool SpecWpCuttingBreeze(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (!keeper || !keeper.Fighting || !hit)
            {
                return(false);
            }

            if (MUDMath.NumberPercent() < 10 && (keeper.Fighting.Hitpoints >= -9))
            {
                Spell.SpellList["cutting breeze"].Invoke(keeper, keeper.Level, keeper.Fighting);
                return(true);
            }

            return(false);
        }
示例#17
0
文件: Room.cs 项目: xuesong/ModernMUD
 /// <summary>
 /// Checks whether a spell cast by the player is swallowed by one of the starshell types.
 /// </summary>
 /// <param name="ch">The caster</param>
 /// <returns>true if the spell was eaten.</returns>
 public bool CheckStarshell(CharData ch)
 {
     if (!ch.IsClass(CharClass.Names.bard))
     {
         if (ch.InRoom.HasFlag(ROOM_EARTHEN_STARSHELL))
         {
             ch.SendText("You start casting...\r\n");
             ch.SendText("&+lThe &+yearth&n &+lcomes up &+yand engulfs &+lyour spell.\r\n");
             Combat.InflictSpellDamage(ch, ch, 1, "earthen starshell", AttackType.DamageType.fire);
             ch.WaitState(6);
             return(true);
         }
         if (ch.InRoom.HasFlag(ROOM_AIRY_STARSHELL))
         {
             ch.SendText("You start casting...\r\n");
             ch.SendText("&+CAir swir&n&+cls a&+Cnd absorbs y&n&+cour spell.&n\r\n");
             ch.WaitState(6);
             if (ch.CurrentPosition > Position.reclining && MUDMath.NumberPercent() + 50 > ch.GetCurrAgi())
             {
                 ch.CurrentPosition = Position.reclining;
                 ch.WaitState(6);
                 ch.SendText("You are knocked over!\r\n");
             }
             return(true);
         }
         if (ch.InRoom.HasFlag(ROOM_WATERY_STARSHELL))
         {
             ch.SendText("You start casting...\r\n");
             ch.SendText("&+bWater b&+Bursts up a&n&+bnd absor&+Bbs your spell.&n\r\n");
             ch.WaitState(6);
             ch.CurrentMoves -= 20;
             ch.SendText("You feel tired!\r\n");
             return(true);
         }
         if (ch.InRoom.HasFlag(ROOM_FIERY_STARSHELL))
         {
             ch.SendText("You start casting...\r\n");
             ch.SendText("&+RFire&n&+r engu&+Rlfs y&n&+rour s&+Rpell.&n\r\n");
             Combat.InflictSpellDamage(ch, ch, 1, "fiery starshell", AttackType.DamageType.fire);
             ch.WaitState(6);
             return(true);
         }
     }
     return(false);
 }
示例#18
0
        /// <summary>
        /// Random room generation function.
        /// </summary>
        /// <returns></returns>
        public static Room GetRandomRoom()
        {
            Room room;

            for ( ; ;)
            {
                room = Room.GetRoom(MUDMath.NumberRange(0, 65535));
                if (room)
                {
                    if (!room.HasFlag(RoomTemplate.ROOM_PRIVATE) && !room.HasFlag(RoomTemplate.ROOM_SOLITARY))
                    {
                        break;
                    }
                }
            }

            return(room);
        }
示例#19
0
        static bool SpecWpDestroyUndead(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (!keeper || !keeper.Fighting || !hit)
            {
                return(false);
            }

            if (keeper.Fighting.IsUndead())
            {
                if (MUDMath.NumberPercent() < 10 && (keeper.Fighting.Hitpoints >= -9))
                {
                    Spell.SpellList["destroy undead"].Invoke(keeper, 1, keeper.Fighting);
                    return(true);
                }
            }
            return(false);
        }
示例#20
0
        /// <summary>
        /// Sets the level of an undead creature based on info from the character,
        /// the corpse, and the type of undead being raised.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="corpseLevel"></param>
        /// <param name="petType"></param>
        /// <returns></returns>
        public static int FuzzyLevel(CharData ch, int corpseLevel, int petType)
        {
            int temp = corpseLevel;

            if ((corpseLevel > Table[petType].MaxLevel) && (corpseLevel <= ch.Level))
            {
                return(Table[petType].MaxLevel);
            }
            if ((corpseLevel >= ch.Level) &&
                (ch.Level <= Table[petType].MaxLevel))
            {
                temp = (ch.Level + ((MUDMath.Dice(1, ((corpseLevel + 1) - ch.Level))) - 1));
                return(Math.Min(temp, Table[petType].MaxLevel));
            }
            if (ch.Level >= corpseLevel)
            {
                return(Math.Min(ch.Level, Table[petType].MaxLevel));
            }
            return(temp);
        }
示例#21
0
        /// <summary>
        /// Song of quagmire (move drain).
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="spell"></param>
        /// <param name="level"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public static bool SongQuagmire(CharData ch, Spell spell, int level, Target target)
        {
            foreach (CharData victim in ch.InRoom.People)
            {
                if (victim.CurrentMoves < 0)
                {
                    continue;
                }

                victim.CurrentMoves -= MUDMath.Dice(2, (level / 2)) + 5;

                if (victim.CurrentMoves < 0)
                {
                    victim.CurrentMoves = 0;
                }

                victim.SendText("Your feet feel mired to the ground.\r\n");
            }
            return(true);
        }
示例#22
0
        static bool SpecWpMagicMissile(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (!keeper || !keeper.Fighting || !hit)
            {
                return(false);
            }

            if (MUDMath.NumberPercent() < 10 && (keeper.Fighting.Hitpoints >= -9))
            {
                Spell spl = Spell.SpellList["magic missile"];
                if (spl != null)
                {
                    spl.Invoke(keeper, keeper.Level, keeper.Fighting);
                }
                return(true);
            }

            return(false);
        }
示例#23
0
        /// <summary>
        /// Song of healing.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="spell"></param>
        /// <param name="level"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public static bool SongHealing(CharData ch, Spell spell, int level, Target target)
        {
            foreach (CharData victim in ch.InRoom.People)
            {
                if (!ch.IsSameGroup(victim))
                {
                    continue;
                }

                int heal = MUDMath.Dice(4, (level / 3)) + 1;

                if (victim.Hitpoints < victim.GetMaxHit())
                {
                    victim.Hitpoints = Math.Min(victim.Hitpoints + heal, victim.GetMaxHit());
                }
                victim.UpdatePosition();

                victim.SendText("&+WYour wounds begin to heal.&n\r\n");
            }
            return(true);
        }
示例#24
0
        static bool SpecTrident(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (!keeper || !keeper.Fighting || !hit)
            {
                return(false);
            }

            // Hum
            if (MUDMath.NumberPercent() < 10)
            {
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lcarried by&n $n&n.",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lyou are carrying.&n",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.character);
                return(true);
            }

            // Weapon proc
            if (keeper.Fighting && MUDMath.NumberPercent() < 15)
            {
                Spell spell = StringLookup.SpellLookup("lightanddark");
                if (!spell)
                {
                    Log.Error("SpecTrident: 'lightanddark' spell not found. Check the spells file.");
                    return(false);
                }
                SocketConnection.Act("&n$n&+c's &n&+Ctr&n&+cident &n&+bglows &+Bblue&n&+c as &n&+Csur&n&+crea&n&+Cl &n&+Bwat&n&+bers " +
                                     "&n&+Bbeg&n&+bin &n&+cto &n&+Cg&n&+cath&n&+Cer &n&+bat i&n&+Bt&n&+bs &n&+Cti&n&+cp.&n",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.room);
                spell.Invoke(keeper, keeper.Level, keeper.Fighting);
                return(true);
            }

            return(false);
        }
示例#25
0
        static bool SpecLightanddark(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (!keeper || !keeper.Fighting || !hit)
            {
                return(false);
            }

            //Hum
            if (MUDMath.NumberPercent() < 10)
            {
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lcarried by&n $n&n.",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lyou are carrying.&n",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.character);
                return(true);
            }

            // Weapon proc
            if (keeper.Fighting && MUDMath.NumberPercent() < 15)
            {
                Spell spell = StringLookup.SpellLookup("lightanddark");
                if (!spell)
                {
                    Log.Error("SpecLightanddark: 'lightanddark' spell not found. Check the spells file.");
                    return(false);
                }
                SocketConnection.Act("&n$n&+L's sword fulgurates fiercely as a &+Csearing &+clight &+Lcollects at the blade's end. ",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.room);
                spell.Invoke(keeper, keeper.Level, keeper.Fighting);
                return(true);
            }

            return(false);
        }
示例#26
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());
            }
        }
示例#27
0
        /// <summary>
        /// Tracking mob has found the person its after. Attack or react accordingly.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="victim"></param>
        public static void FoundPrey(CharData ch, CharData victim)
        {
            string victname = String.Empty;
            string text     = String.Empty;
            string lbuf     = String.Empty;

            if (!victim)
            {
                Log.Error("FoundPrey: null victim", 0);
                return;
            }

            if (!victim.InRoom)
            {
                Log.Error("FoundPrey: null victim._inRoom", 0);
                return;
            }
            ImmortalChat.SendImmortalChat(null, ImmortalChat.IMMTALK_HUNTING, 0, string.Format("{0}&n has found {1}.", ch.ShortDescription, victim.Name));

            if (ch.IsAffected(Affect.AFFECT_TRACK))
            {
                ch.RemoveAffect(Affect.AFFECT_TRACK);
                Combat.StopHunting(ch);
                return;
            }
            if (ch.IsAffected(Affect.AFFECT_JUSTICE_TRACKER))
            {
                /* Give Justice the ability to ground flying culprits */
                if (victim.FlightLevel != 0)
                {
                    SocketConnection.Act("$n&n forces you to land!", ch, null, victim, SocketConnection.MessageTarget.victim);
                    SocketConnection.Act("$n&n forces $N&n to land!", ch, null, victim, SocketConnection.MessageTarget.room_vict);
                    victim.FlightLevel = 0;
                }

                SocketConnection.Act("$n&n says, 'Stop, $N&n, you're under ARREST!'", ch, null, victim, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n says, 'Stop, $N&n, you're under ARREST!'", ch, null, victim, SocketConnection.MessageTarget.room);
                SocketConnection.Act("$n&n chains you up.", ch, null, victim, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n binds $N&n so $E can't move.", ch, null, victim, SocketConnection.MessageTarget.room);
                victim.SetAffectBit(Affect.AFFECT_BOUND);
                victim.RemoveFromRoom();

                if (ch.InRoom.Area.JailRoom != 0)
                {
                    victim.AddToRoom(Room.GetRoom(victim.InRoom.Area.JailRoom));
                }
                else
                {
                    victim.SendText("Justice is broken in this town - there is no jail and you're screwed.\r\n");
                }
                Combat.StopHunting(ch);
                return;
            }

            victname = victim.IsNPC() ? victim.ShortDescription : victim.Name;

            if (ch.FlightLevel != victim.FlightLevel)
            {
                if (ch.CanFly())
                {
                    if (ch.FlightLevel < victim.FlightLevel && ch.FlightLevel < CharData.FlyLevel.high)
                    {
                        Command.Fly(ch, new string[] { "up" });
                    }
                    else
                    {
                        Command.Fly(ch, new string[] { "down" });
                    }
                }
                else
                {
                    SocketConnection.Act("$n peers around looking for something.", ch, null, null, SocketConnection.MessageTarget.room);
                }
                return;
            }
            if (!CharData.CanSee(ch, victim))
            {
                if (MUDMath.NumberPercent() < 90)
                {
                    return;
                }
                switch (MUDMath.NumberBits(5))
                {
                case 0:
                    text = String.Format("You can't hide forever, {0}!", victname);
                    Command.Say(ch, new string[] { text });
                    break;

                case 1:
                    SocketConnection.Act("$n&n sniffs around the room.", ch, null, victim, SocketConnection.MessageTarget.room);
                    text = "I can smell your blood!";
                    Command.Say(ch, new string[] { text });
                    break;

                case 2:
                    text = String.Format("I'm going to tear {0} apart!", victname);
                    Command.Yell(ch, new string[] { text });
                    break;

                case 3:
                    Command.Say(ch, new string[] { "Just wait until I find you..." });
                    break;

                default:
                    SocketConnection.Act("$p peers about looking for something.", ch, null, null, SocketConnection.MessageTarget.room);
                    break;
                }
                return;
            }

            if (ch.InRoom.HasFlag(RoomTemplate.ROOM_SAFE) && ch.IsNPC())
            {
                text = String.Format("Hunting mob {0} found a safe room {1}.", ch.MobileTemplate.IndexNumber, ch.InRoom.IndexNumber);
                Log.Trace(text);
                return;
            }

            if (ch.CurrentPosition > Position.kneeling)
            {
                switch (MUDMath.NumberBits(5))
                {
                case 0:
                    text = String.Format("I will eat your heart, {0}!", victname);
                    Command.Say(ch, new string[] { text });
                    break;

                case 1:
                    text = String.Format("You want a piece of me, {0}?", victname);
                    Command.Say(ch, new string[] { text });
                    break;

                case 2:
                    text = String.Format("How does your flesh taste {0}, like chicken?", victname);
                    Command.Say(ch, new string[] { text });
                    break;

                case 3:
                    SocketConnection.Act("$n&n howls gleefully and lunges at $N&n!", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim);
                    SocketConnection.Act("$n&n howls gleefully and lunges at you!", ch, null, victim, SocketConnection.MessageTarget.victim);
                    break;

                case 4:
                    SocketConnection.Act("$n&n charges headlong into $N&n!", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim);
                    SocketConnection.Act("$n&n charges headlong into you!", ch, null, victim, SocketConnection.MessageTarget.victim);
                    break;

                default:
                    break;
                }
                Combat.StopHunting(ch);
                Combat.CheckAggressive(victim, ch);
                if (ch.Fighting)
                {
                    return;
                }

                // Backstab if able, otherwise just kill them.
                // Kill if they don't have the skill or if they don't have a stabber.
                if (!ch.HasSkill("backstab"))
                {
                    Combat.CombatRound(ch, victim, String.Empty);
                }
                else if (!Combat.Backstab(ch, victim))
                {
                    Combat.CombatRound(ch, victim, String.Empty);
                }
            }
            return;
        }
示例#28
0
文件: Room.cs 项目: xuesong/ModernMUD
        /// <summary>
        /// Resets a room, reloading according to resets.
        /// </summary>
        /// <param name="notInitial"></param>
        /// <returns></returns>
        public bool ResetRoom(int notInitial)
        {
            Exit     exit = null;
            CharData mobile;
            CharData lastMob = null;
            int      level   = 0;
            bool     last    = true;
            // Added for debugging.
            string text = String.Empty;

            foreach (Reset reset in Area.Resets)
            {
                if (!reset.IsRoomReset(this))
                {
                    continue;
                }
                Object      obj;
                Object      lastObj;
                MobTemplate mobIndex;
                ObjTemplate objTemplate;
                Room        room;

                switch (reset.Command)
                {
                default:
                    Log.Error("RoomIndex.Reset(): bad command %c.", reset.Command);
                    break;

                case 'M':
                    mobIndex = Database.GetMobTemplate(reset.Arg1);
                    if (!mobIndex)
                    {
                        Log.Error("RoomIndex.Reset(): 'M': bad mob index number {0} for arg1.", reset.Arg1);
                        continue;
                    }

                    room = GetRoom(reset.Arg3);
                    if (!room)
                    {
                        Log.Error("RoomIndex.Reset(): 'R': bad room index number {0} for arg3.", reset.Arg3);
                        continue;
                    }

                    if ((mobIndex.HasSpecFun("spec_cast_ghost")) &&
                        (Database.SystemData.WeatherData.Sunlight > SunType.night) &&
                        (Database.SystemData.WeatherData.Sunlight < SunType.moonrise))
                    {
                        last = false;
                        continue;
                    }

                    level = Macros.Range(0, mobIndex.Level - 2, Limits.LEVEL_HERO);

                    if (mobIndex.NumActive >= reset.Arg2)
                    {
                        last = false;
                        break;
                    }
                    mobile = Database.CreateMobile(mobIndex);

                    // Check for pet shop.
                    Room prevRoom = GetRoom(room.IndexNumber - 1);
                    if (prevRoom && prevRoom.HasFlag(ROOM_PET_SHOP))
                    {
                        mobile.SetActionBit(MobTemplate.ACT_PET);
                    }

                    if (room.IsDark())
                    {
                        mobile.SetAffectBit(Affect.AFFECT_INFRAVISION);
                    }

                    mobile.AddToRoom(room);
                    mobile.LoadRoomIndexNumber = room.IndexNumber;

                    // This code makes mounts make their mounters mount them.
                    if (reset.Arg0 == -1 && lastMob)
                    {
                        // If set to be mounted.
                        String[] keywords = mobile.Name.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        Command.Mount(lastMob, keywords);
                    }

                    lastMob = mobile;

                    level = Macros.Range(0, mobile.Level - 2, Limits.LEVEL_HERO);
                    last  = true;
                    break;

                case 'F':
                    mobIndex = Database.GetMobTemplate(reset.Arg1);
                    if (!mobIndex)
                    {
                        Log.Error("RoomIndex.Reset(): 'F': bad mob index number {0} for arg1.", reset.Arg1);
                        continue;
                    }

                    room = GetRoom(reset.Arg3);
                    if (!room)
                    {
                        Log.Error("RoomIndex.Reset(): 'F': bad room index number {0} for arg3.", reset.Arg3);
                        continue;
                    }

                    if (mobIndex.HasSpecFun("spec_cast_ghost") && (Database.SystemData.WeatherData.Sunlight > SunType.night) &&
                        (Database.SystemData.WeatherData.Sunlight < SunType.moonrise))
                    {
                        last = false;
                        continue;
                    }

                    level = Macros.Range(0, mobIndex.Level - 2, Limits.LEVEL_HERO);

                    if (mobIndex.NumActive >= reset.Arg2)
                    {
                        last = false;
                        break;
                    }
                    mobile = Database.CreateMobile(mobIndex);

                    Room prev = GetRoom(room.IndexNumber - 1);
                    if (prev && prev.HasFlag(ROOM_PET_SHOP))
                    {
                        mobile.SetActionBit(MobTemplate.ACT_PET);
                    }

                    if (room.IsDark())
                    {
                        mobile.SetAffectBit(Affect.AFFECT_INFRAVISION);
                    }

                    // Set following bit. Can't have a message sent because
                    // there is no valid room number (causes a segmentation fault)
                    CharData.AddFollowerWithoutMessage(mobile, lastMob);

                    lastMob = mobile;
                    mobile.AddToRoom(room);
                    mobile.LoadRoomIndexNumber = room.IndexNumber;
                    level = Macros.Range(0, mobile.Level - 2, Limits.LEVEL_HERO);
                    last  = true;
                    break;

                case 'O':
                    if (notInitial != 0)
                    {
                        last = false;
                        continue;
                    }
                    objTemplate = Database.GetObjTemplate(reset.Arg1);
                    if (!objTemplate)
                    {
                        Log.Error("RoomIndex.Reset(): 'O': bad obj index number {0} for arg1.", reset.Arg1);
                        continue;
                    }

                    room = GetRoom(reset.Arg3);
                    if (!room)
                    {
                        Log.Error("RoomIndex.Reset(): 'O': bad room index number {0} for arg3.", reset.Arg3);
                        continue;
                    }

                    if (Area.NumPlayers > 0 || room._contents.Count != 0 && (Object.CountObjectInList(objTemplate, room._contents) > 0))
                    {
                        last = false;
                        break;
                    }
                    // check if is unique/arti
                    if (Database.IsArtifact(objTemplate.IndexNumber))
                    {
                        text += "RoomIndex.Reset(): Artifact found: " + objTemplate.Name + " (" + objTemplate.IndexNumber + ")";
                        Log.Trace(text);
                    }     //end if artiact

                    obj = Database.CreateObject(objTemplate, MUDMath.FuzzyNumber(level));
                    if (obj != null)
                    {
                        obj.Cost = 0;
                        obj.AddToRoom(this);
                        last = true;
                    }
                    else
                    {
                        Log.Error("RoomIndex.Reset(): Unable to Database.CreateObject {0}", reset.Arg3);
                    }
                    break;

                case 'P':
                    if (notInitial != 0)
                    {
                        last = false;
                        continue;
                    }
                    objTemplate = Database.GetObjTemplate(reset.Arg1);
                    if (!objTemplate)
                    {
                        Log.Error("RoomIndex.Reset(): 'P': bad obj index number {0} for arg3.", reset.Arg1);
                        continue;
                    }

                    ObjTemplate targetObjTemplate = Database.GetObjTemplate(reset.Arg3);
                    if (!targetObjTemplate)
                    {
                        Log.Error("RoomIndex.Reset(): 'P': bad obj index number {0} for arg3.", reset.Arg3);
                        continue;
                    }

                    if (Area.NumPlayers > 0 || !(lastObj = Object.GetFirstObjectOfTemplateType(targetObjTemplate)) ||
                        lastObj.Contains.Count != 0 && (Object.CountObjectInList(objTemplate, lastObj.Contains) > 0))
                    {
                        last = false;
                        break;
                    }
                    // check if is unique/arti
                    if (Database.IsArtifact(objTemplate.IndexNumber))
                    {
                        text += "RoomIndex.Reset(): Artifact found: " + objTemplate.Name + " (" + objTemplate.IndexNumber + ")";
                        Log.Trace(text);
                    }     //end if artifact

                    obj = Database.CreateObject(objTemplate, MUDMath.FuzzyNumber(lastObj.Level));
                    lastObj.AddToObject(obj);
                    last = true;

                    // Ensure that the container gets Reset.
                    if ((lastObj.ItemType == ObjTemplate.ObjectType.container) || (lastObj.ItemType == ObjTemplate.ObjectType.drink_container))
                    {
                        lastObj.Values[1] = lastObj.ObjIndexData.Values[1];
                    }
                    break;

                case 'G':
                case 'E':
                    if (notInitial != 0)
                    {
                        last = false;
                        continue;
                    }
                    objTemplate = Database.GetObjTemplate(reset.Arg1);
                    if (!objTemplate)
                    {
                        Log.Error("RoomIndex.Reset(): 'E' or 'G': bad obj index number {0} for arg1.", reset.Arg1);
                        continue;
                    }

                    if (!last)
                    {
                        break;
                    }

                    if (!lastMob)
                    {
                        Log.Error("RoomIndex.Reset(): 'E' or 'G': null mob for index number {0} for arg1.", reset.Arg1);
                        last = false;
                        break;
                    }
                    // check if is unique/arti
                    if (Database.IsArtifact(objTemplate.IndexNumber))
                    {
                        text += "RoomIndex.Reset(): Artifact found: " + objTemplate.Name + " (" + objTemplate.IndexNumber + ")";
                        Log.Trace(text);
                    }                                    //end if artifact

                    if (lastMob.MobileTemplate.ShopData) /* Shop-keeper? */
                    {
                        int olevel;

                        switch (objTemplate.ItemType)
                        {
                        default:
                            olevel = 0;
                            break;

                        case ObjTemplate.ObjectType.pill:
                            olevel = MUDMath.NumberRange(0, 10);
                            break;

                        case ObjTemplate.ObjectType.potion:
                            olevel = MUDMath.NumberRange(0, 10);
                            break;

                        case ObjTemplate.ObjectType.scroll:
                            olevel = MUDMath.NumberRange(5, 15);
                            break;

                        case ObjTemplate.ObjectType.wand:
                            olevel = MUDMath.NumberRange(10, 20);
                            break;

                        case ObjTemplate.ObjectType.staff:
                            olevel = MUDMath.NumberRange(15, 25);
                            break;

                        case ObjTemplate.ObjectType.armor:
                            olevel = MUDMath.NumberRange(5, 15);
                            break;

                        case ObjTemplate.ObjectType.other:
                            olevel = MUDMath.NumberRange(5, 15);
                            break;

                        case ObjTemplate.ObjectType.clothing:
                            olevel = MUDMath.NumberRange(5, 15);
                            break;

                        case ObjTemplate.ObjectType.weapon:
                            if (reset.Command == 'G')
                            {
                                olevel = MUDMath.NumberRange(5, 15);
                            }
                            else
                            {
                                olevel = MUDMath.FuzzyNumber(level);
                            }
                            break;
                        }

                        obj = Database.CreateObject(objTemplate, olevel);
                        if (reset.Command == 'G')
                        {
                            obj.AddFlag(ObjTemplate.ITEM_INVENTORY);
                        }
                    }
                    else
                    {
                        obj = Database.CreateObject(objTemplate, MUDMath.FuzzyNumber(level));
                    }
                    obj.ObjToChar(lastMob);
                    if (reset.Command == 'E')
                    {
                        lastMob.EquipObject(ref obj, (ObjTemplate.WearLocation)reset.Arg3);
                    }
                    last = true;
                    break;

                case 'D':
                    if (reset.Arg2 < 0 || reset.Arg2 >= Limits.MAX_DIRECTION || !(exit = ExitData[reset.Arg2]) ||
                        !exit.HasFlag(Exit.ExitFlag.is_door))
                    {
                        Log.Error("RoomIndex.Reset(): 'D': exit {0} not door for arg2.", reset.Arg2);
                    }

                    switch (reset.Arg3)
                    {
                    default:
                        Log.Error("RoomIndex.Reset(): 'D': bad 'locks': {0} for arg3.", reset.Arg3);
                        break;

                    case 0:
                        break;

                    case 1:
                        exit.AddFlag(Exit.ExitFlag.closed);
                        break;

                    case 2:
                        exit.AddFlag(Exit.ExitFlag.closed | Exit.ExitFlag.locked);
                        break;

                    case 4:
                        exit.AddFlag(Exit.ExitFlag.secret);
                        break;

                    case 5:
                        exit.AddFlag(Exit.ExitFlag.secret | Exit.ExitFlag.closed);
                        break;

                    case 6:
                        exit.AddFlag(Exit.ExitFlag.secret | Exit.ExitFlag.closed | Exit.ExitFlag.locked);
                        break;

                    case 8:
                        exit.AddFlag(Exit.ExitFlag.blocked);
                        break;

                    case 9:
                        exit.AddFlag(Exit.ExitFlag.blocked | Exit.ExitFlag.closed);
                        break;

                    case 10:
                        exit.AddFlag(Exit.ExitFlag.blocked | Exit.ExitFlag.closed | Exit.ExitFlag.locked);
                        break;

                    case 12:
                        exit.AddFlag(Exit.ExitFlag.blocked | Exit.ExitFlag.secret);
                        break;

                    case 13:
                        exit.AddFlag(Exit.ExitFlag.blocked | Exit.ExitFlag.secret | Exit.ExitFlag.closed);
                        break;

                    case 14:
                        exit.AddFlag(Exit.ExitFlag.blocked | Exit.ExitFlag.secret | Exit.ExitFlag.closed | Exit.ExitFlag.locked);
                        break;
                    }
                    break;

                case 'R':
                    Log.Trace("Unsupported randomize room exits call.  Please implement this.");
                    break;
                }
            }

            return(true);
        }
示例#29
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;
        }
示例#30
0
        /// <summary>
        /// Create an instance of a mobile from the provided template.
        /// </summary>
        /// <param name="mobTemplate"></param>
        /// <returns></returns>
        public static CharData CreateMobile(MobTemplate mobTemplate)
        {
            int count;

            if (!mobTemplate)
            {
                Log.Error("CreateMobile: null MobTemplate.", 0);
                throw new NullReferenceException();
            }

            CharData mob = new CharData();

            mob.MobileTemplate       = mobTemplate;
            mob.Followers            = null;
            mob.Name                 = mobTemplate.PlayerName;
            mob.ShortDescription     = mobTemplate.ShortDescription;
            mob.FullDescription      = mobTemplate.FullDescription;
            mob.Description          = mobTemplate.Description;
            mob.SpecialFunction      = mobTemplate.SpecFun;
            mob.SpecialFunctionNames = mobTemplate.SpecFunNames;
            mob.CharacterClass       = mobTemplate.CharacterClass;
            mob.Level                = MUDMath.FuzzyNumber(mobTemplate.Level);
            mob.ActionFlags          = mobTemplate.ActionFlags;
            mob.CurrentPosition      = mobTemplate.DefaultPosition;
            mob.ChatterBotName       = mobTemplate.ChatterBotName;
            // TODO: Look up the chatter bot name and load a runtime bot into the variable.
            mob.ChatBot = null;
            for (count = 0; count < Limits.NUM_AFFECT_VECTORS; ++count)
            {
                mob.AffectedBy[count] = mobTemplate.AffectedBy[count];
            }
            mob.Alignment = mobTemplate.Alignment;
            mob.Gender    = mobTemplate.Gender;
            mob.SetPermRace(mobTemplate.Race);
            mob.CurrentSize = Race.RaceList[mob.GetRace()].DefaultSize;
            if (mob.HasActionBit(MobTemplate.ACT_SIZEMINUS))
            {
                mob.CurrentSize--;
            }
            if (mob.HasActionBit(MobTemplate.ACT_SIZEPLUS))
            {
                mob.CurrentSize++;
            }

            mob.CastingSpell         = 0;
            mob.CastingTime          = 0;
            mob.PermStrength         = MUDMath.Dice(2, 46) + 8;
            mob.PermIntelligence     = MUDMath.Dice(2, 46) + 8;
            mob.PermWisdom           = MUDMath.Dice(2, 46) + 8;
            mob.PermDexterity        = MUDMath.Dice(2, 46) + 8;
            mob.PermConstitution     = MUDMath.Dice(2, 46) + 7;
            mob.PermAgility          = MUDMath.Dice(2, 46) + 8;
            mob.PermCharisma         = MUDMath.Dice(2, 46) + 8;
            mob.PermPower            = MUDMath.Dice(2, 46) + 8;
            mob.PermLuck             = MUDMath.Dice(2, 46) + 8;
            mob.ModifiedStrength     = 0;
            mob.ModifiedIntelligence = 0;
            mob.ModifiedWisdom       = 0;
            mob.ModifiedDexterity    = 0;
            mob.ModifiedConstitution = 0;
            mob.ModifiedAgility      = 0;
            mob.ModifiedCharisma     = 0;
            mob.ModifiedPower        = 0;
            mob.ModifiedLuck         = 0;
            mob.Resistant            = mobTemplate.Resistant;
            mob.Immune      = mobTemplate.Immune;
            mob.Susceptible = mobTemplate.Susceptible;
            mob.Vulnerable  = mobTemplate.Vulnerable;
            mob.MaxMana     = mob.Level * 10;
            if (Race.RaceList[mobTemplate.Race].Coins)
            {
                int level = mobTemplate.Level;
                mob.ReceiveCopper(MUDMath.Dice(12, level) / 32);
                mob.ReceiveSilver(MUDMath.Dice(9, level) / 32);
                mob.ReceiveGold(MUDMath.Dice(5, level) / 32);
                mob.ReceivePlatinum(MUDMath.Dice(2, level) / 32);
            }
            else
            {
                mob.SetCoins(0, 0, 0, 0);
            }
            mob.ArmorPoints = MUDMath.Interpolate(mob.Level, 100, -100);

            // * MOB HITPOINTS *
            //
            // Was level d 8, upped it to level d 13
            // considering mobs *still* won't have as many hitpoints as some players until
            // at least level 10, this shouldn't be too big an upgrade.
            //
            // Mob hitpoints are not based on constitution *unless* they have a
            // constitution modifier from an item, spell, or other affect

            // In light of recent player dissatisfaction with the
            // mob hitpoints, I'm implementing a log curve, using
            //  hp = exp( 2.15135 + level*0.151231)
            // This will will result in the following hp matrix:
            //     Level    Hitpoints
            //      20        175
            //      30        803
            //      40        3643
            //      50        16528
            //      55        35207
            //      60        75000
            mob.MaxHitpoints = MUDMath.Dice(mob.Level, 13) + 1;
            // Mob hps are non-linear above level 10.
            if (mob.Level > 20)
            {
                int upper = (int)Math.Exp(1.85 + mob.Level * 0.151231);
                int lower = (int)Math.Exp(1.80 + mob.Level * 0.151231);
                mob.MaxHitpoints += MUDMath.NumberRange(lower, upper);
            }
            else if (mob.Level > 10)
            {
                mob.MaxHitpoints += MUDMath.NumberRange(mob.Level * 2, ((mob.Level - 8) ^ 2 * mob.Level) / 2);
            }

            // Demons/devils/dragons gain an extra 30 hitpoints per level (+1500 at lvl 50).
            if (mob.GetRace() == Race.RACE_DEMON || mob.GetRace() == Race.RACE_DEVIL || mob.GetRace() == Race.RACE_DRAGON)
            {
                mob.MaxHitpoints += (mob.Level * 30);
            }

            mob.Hitpoints = mob.GetMaxHit();

            // Horses get more moves, necessary for mounts.
            if (Race.RaceList[mob.GetRace()].Name.Equals("Horse", StringComparison.CurrentCultureIgnoreCase))
            {
                mob.MaxMoves     = 290 + MUDMath.Dice(4, 5);
                mob.CurrentMoves = mob.MaxMoves;
            }
            mob.LoadRoomIndexNumber = 0;

            // Insert in list.
            CharList.Add(mob);
            // Increment count of in-game instances of mob.
            mobTemplate.NumActive++;
            return(mob);
        }