Exemplo n.º 1
0
        public static void do_repeat(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfTrue(ch,
                                           ch.IsNpc() || !ch.IsImmortal() || ((PlayerInstance)ch).PlayerData.TellHistory == null || !((PlayerInstance)ch).PlayerData.TellHistory.Any(),
                                           "Huh?"))
            {
                return;
            }

            int tellIndex;

            if (string.IsNullOrWhiteSpace(argument))
            {
                tellIndex = ((PlayerInstance)ch).PlayerData.TellHistory.Count - 1;
            }
            else if (char.IsLetter(argument.ToCharArray()[0]) && argument.Length == 1)
            {
                tellIndex = char.ToLower(argument.ToCharArray()[0]) - 'a';
            }
            else
            {
                ch.Printf("You may only index your tell history using a single letter.");
                return;
            }

            if (CheckFunctions.CheckIfEmptyString(ch, ((PlayerInstance)ch).PlayerData.TellHistory.ToList()[tellIndex],
                                                  "No one like that has sent you a tell."))
            {
                return;
            }

            ch.SetColor(ATTypes.AT_TELL);
            ch.SendTo(((PlayerInstance)ch).PlayerData.TellHistory.ToList()[tellIndex]);
        }
Exemplo n.º 2
0
        public static void do_dismiss(CharacterInstance ch, string argument)
        {
            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Dismiss whom?"))
            {
                return;
            }

            var victim = ch.GetCharacterInRoom(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here."))
            {
                return;
            }

            if (victim.IsAffected(AffectedByTypes.Charm) &&
                victim.IsNpc() && victim.Master == ch)
            {
                victim.StopFollower();
                ((MobileInstance)victim).StopHating();
                ((MobileInstance)victim).StopHunting();
                ((MobileInstance)victim).StopFearing();
                comm.act(ATTypes.AT_ACTION, "$n dismisses $N.", ch, null, victim, ToTypes.NotVictim);
                comm.act(ATTypes.AT_ACTION, "You dismiss $N.", ch, null, victim, ToTypes.Character);
                return;
            }

            ch.SendTo("You cannot dismiss them.");
        }
Exemplo n.º 3
0
        public static void do_title(CharacterInstance ch, string argument)
        {
            if (ch.IsNpc())
            {
                return;
            }

            ch.SetColor(ATTypes.AT_SCORE);

            if (CheckFunctions.CheckIfTrue(ch, ch.Level < 5,
                                           "Sorry... you must be at least level 5 to set your title..."))
            {
                return;
            }
            if (CheckFunctions.CheckIfSet(ch, ((PlayerInstance)ch).PlayerData.Flags, PCFlags.NoTitle,
                                          "The gods prohibit you from changing your title."))
            {
                return;
            }
            if (CheckFunctions.CheckIfEmptyString(ch, argument, "Change your title to what?"))
            {
                return;
            }

            var buffer = argument.Length > 50 ? argument.Substring(0, 50) : argument;

            buffer.SmashTilde();
            player.set_title((PlayerInstance)ch, buffer);
            ch.SendTo("Ok.");
        }
Exemplo n.º 4
0
        public static void do_consider(CharacterInstance ch, string argument)
        {
            var arg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, arg, "Consider killing whom?"))
            {
                return;
            }

            var victim = ch.GetCharacterInRoom(arg);

            if (CheckFunctions.CheckIfNullObject(ch, victim, "They're not here."))
            {
                return;
            }
            if (CheckFunctions.CheckIfEquivalent(ch, ch, victim,
                                                 "You decide you're pretty sure you could take yourself in a fight."))
            {
                return;
            }

            var levelDiff = victim.Level - ch.Level;

            var msg = GetLevelConsiderMessage(levelDiff);

            comm.act(ATTypes.AT_CONSIDER, msg, ch, null, victim, ToTypes.Character);

            levelDiff = (victim.MaximumHealth - ch.MaximumHealth) / 6;
            msg       = GetHealthConsiderMessage(levelDiff);
            comm.act(ATTypes.AT_CONSIDER, msg, ch, null, victim, ToTypes.Character);
        }
Exemplo n.º 5
0
        public static void do_bashdoor(CharacterInstance ch, string argument)
        {
            var skill = RepositoryManager.Instance.GetEntity <SkillData>("bashdoor");

            if (CheckFunctions.CheckIfTrue(ch, !ch.IsNpc() && ch.Level < skill.SkillLevels.ToList()[(int)ch.CurrentClass],
                                           "You're not enough of a warrior to bash doors!"))
            {
                return;
            }

            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Bash what?"))
            {
                return;
            }
            if (CheckFunctions.CheckIfNotNullObject(ch, ch.CurrentFighting, "You can't break off your fight."))
            {
                return;
            }

            var exit = ch.FindExit(firstArg);

            if (exit == null)
            {
                Bash(ch, skill, "wall");
            }
            else
            {
                BashSomething(ch, exit, skill, firstArg);
            }
        }
Exemplo n.º 6
0
        public static void do_open(CharacterInstance ch, string argument)
        {
            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Open what?"))
            {
                return;
            }

            var exit = ch.FindExit(firstArg, true);

            if (exit != null)
            {
                OpenDoor(ch, exit, firstArg);
                return;
            }

            var obj = ch.GetObjectOnMeOrInRoom(firstArg);

            if (obj != null)
            {
                OpenObject(ch, obj, firstArg);
                return;
            }

            ch.Printf("You see no %s here.", firstArg);
        }
Exemplo n.º 7
0
        public static void do_track(CharacterInstance ch, string argument)
        {
            var skill = RepositoryManager.Instance.GetEntity <SkillData>("track");

            if (CheckFunctions.CheckIfTrue(ch, !ch.IsNpc() && ((PlayerInstance)ch).PlayerData.GetSkillMastery(skill.ID) <= 0,
                                           "You do not know of this skill yet."))
            {
                return;
            }

            var arg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, arg, "Whom are you trying to track?"))
            {
                return;
            }

            Macros.WAIT_STATE(ch, skill.Rounds);

            var victim = ch.GetCharacterInWorld(arg);

            if (CheckFunctions.CheckIfNullObject(ch, victim, "You can't find a trail of anyone like that."))
            {
                return;
            }
        }
Exemplo n.º 8
0
        public static void do_split(CharacterInstance ch, string argument)
        {
            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Split how much?"))
            {
                return;
            }

            var amount = Convert.ToInt32(firstArg);

            if (CheckFunctions.CheckIfTrue(ch, amount < 0, "Your group wouldn't like that."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, amount == 0, "You hand out zero coins, but no one notices."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, ch.CurrentCoin < amount, "You don't have that much coin."))
            {
                return;
            }

            var members = ch.CurrentRoom.Persons.Count(x => x.IsSameGroup(ch));

            if (ch.Act.IsSet((int)PlayerFlags.AutoGold) && members < 2)
            {
                return;
            }

            if (CheckFunctions.CheckIfTrue(ch, members < 2, "Just keep it all."))
            {
                return;
            }

            var share = amount / members;

            if (CheckFunctions.CheckIfTrue(ch, share == 0, "Don't even bother, cheapskate."))
            {
                return;
            }

            var extra = amount % members;

            ch.CurrentCoin -= amount;
            ch.CurrentCoin += share + extra;

            ch.SetColor(ATTypes.AT_GOLD);
            ch.Printf("You split %d gold coins.  Your share is %d gold coins.\r\n", amount, share + extra);

            var buffer = $"$n splits {amount} gold coins. Your share is {share} gold coins.";

            foreach (var gch in ch.CurrentRoom.Persons.Where(x => x.IsSameGroup(ch) && x != ch))
            {
                comm.act(ATTypes.AT_GOLD, buffer, ch, null, gch, ToTypes.Victim);
                gch.CurrentCoin += share;
            }
        }
Exemplo n.º 9
0
        public static void do_empty(CharacterInstance ch, string argument)
        {
            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Empty what?"))
            {
                return;
            }
            if (handler.FindObject_CheckMentalState(ch))
            {
                return;
            }

            var obj = ch.GetCarriedObject(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, obj, "You aren't carrying that."))
            {
                return;
            }

            if (obj.Count > 1)
            {
                obj.Split();
            }

            var secondArg = argument.SecondWord();

            if (secondArg.EqualsIgnoreCase("into"))
            {
                secondArg = argument.ThirdWord();
            }

            switch (obj.ItemType)
            {
            case ItemTypes.Pipe:
                EmptyPipe(ch, obj);
                break;

            case ItemTypes.DrinkContainer:
                EmptyDrinkContainer(ch, obj);
                break;

            case ItemTypes.Quiver:
            case ItemTypes.Container:
                EmptyContainerOrQuiver(ch, obj);
                break;

            case ItemTypes.KeyRing:
                EmptyKeyRing(ch, obj, secondArg);
                break;

            default:
                comm.act(ATTypes.AT_ACTION, "You shake $p in an attempt to empty it...", ch, obj, null, ToTypes.Character);
                comm.act(ATTypes.AT_ACTION, "$n begins to shake $p in an attempt to empty it...", ch, obj, null, ToTypes.Room);
                break;
            }
        }
Exemplo n.º 10
0
        public static void do_follow(CharacterInstance ch, string argument)
        {
            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Follow whom?"))
            {
                return;
            }


            var victim = ch.GetCharacterInRoom(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here."))
            {
                return;
            }

            if (ch.IsAffected(AffectedByTypes.Charm) && ch.Master != null)
            {
                comm.act(ATTypes.AT_PLAIN, "But you'd rather follow $N!", ch, null, ch.Master, ToTypes.Character);
                return;
            }

            if (victim == ch)
            {
                if (CheckFunctions.CheckIfNullObject(ch, ch.Master, "You already follow yourself."))
                {
                    return;
                }

                ch.StopFollower();
                return;
            }

            if ((ch.Level - victim.Level < -10 ||
                 ch.Level - victim.Level > 10) &&
                !ch.IsHero() && !(ch.Level < 15 && !victim.IsNpc() &&
                                  ((PlayerInstance)victim).PlayerData.Council != null &&
                                  !((PlayerInstance)victim).PlayerData.Council.Name.Equals("Newbie Council")))
            {
                ch.SendTo("You are not of the right caliber to follow.");
                return;
            }

            if (CheckFunctions.CheckIfTrue(ch, ch.IsCircleFollowing(victim),
                                           "Following in loops is not allowed... sorry."))
            {
                return;
            }

            if (ch.Master != null)
            {
                ch.StopFollower();
            }

            ch.AddFollower(victim);
        }
Exemplo n.º 11
0
        private static object TargetObjectInInventory(string arg, CharacterInstance ch, bool silence)
        {
            if (CheckFunctions.CheckIfEmptyString(ch, arg, !silence ? "What should the spell be cast upon?" : ""))
            {
                return(null);
            }

            var obj = ch.GetCarriedObject(arg);

            return(CheckFunctions.CheckIfNullObject(ch, obj, !silence ? "You are not carrying that." : "") ? null : obj);
        }
Exemplo n.º 12
0
        public static void do_atobj(CharacterInstance ch, string argument)
        {
            ch.SetColor(ATTypes.AT_IMMORT);

            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "At where what?"))
            {
                return;
            }

            ObjectInstance obj = RepositoryManager.Instance.GetEntity <ObjectInstance>(argument);

            if (CheckFunctions.CheckIf(ch, () => obj?.InRoom == null,
                                       "No such object in existence."))
            {
                return;
            }

            RoomTemplate location = obj.InRoom;

            if (location.IsPrivate())
            {
                if (CheckFunctions.CheckIf(ch, () => ch.Trust < LevelConstants.GetLevel(ImmortalTypes.Greater),
                                           "That room is private right now."))
                {
                    return;
                }
                ch.SendTo("Overriding private flag!");
            }

            CharacterInstance victim = location.IsDoNotDisturb(ch);

            if (victim != null)
            {
                ch.PagerPrintf("That room is \"do not disturb\" right now.");
                victim.PagerPrintf("Your do-not-disturb flag just foiled %s's atobj command.", ch.Name);
                return;
            }

            ch.SetColor(ATTypes.AT_PLAIN);
            RoomTemplate original = ch.CurrentRoom;

            ch.CurrentRoom.RemoveFrom(ch);
            location.AddTo(ch);
            interp.interpret(ch, argument);

            if (ch.CharDied())
            {
                return;
            }
            ch.CurrentRoom.RemoveFrom(ch);
            original.AddTo(ch);
        }
Exemplo n.º 13
0
        public static void do_idea(CharacterInstance ch, string argument)
        {
            ch.SetColor(ATTypes.AT_PLAIN);
            if (CheckFunctions.CheckIfEmptyString(ch, argument, "Usage:  'idea <message>'\r\n"))
            {
                return;
            }

            db.append_file(ch, SystemConstants.GetSystemFile(SystemFileTypes.Idea), argument);
            ch.SendTo("Thanks, your idea has been recorded.");
        }
Exemplo n.º 14
0
        public static void do_mix(CharacterInstance ch, string argument)
        {
            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "What would you like to mix together?"))
            {
                return;
            }

            var secondArg = argument.SecondWord();

            if (CheckFunctions.CheckIfEmptyString(ch, secondArg, "What would you like to mix together?"))
            {
                return;
            }

            var firstObj = ch.GetCarriedObject(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, firstObj, "You aren't carrying that."))
            {
                return;
            }

            var secondObj = ch.GetCarriedObject(secondArg);

            if (CheckFunctions.CheckIfNullObject(ch, secondObj, "You aren't carrying that."))
            {
                return;
            }

            if (CheckFunctions.CheckIfTrue(ch,
                                           firstObj.ItemType != ItemTypes.DrinkContainer && firstObj.ItemType != ItemTypes.DrinkMixture &&
                                           secondObj.ItemType != ItemTypes.DrinkContainer && secondObj.ItemType != ItemTypes.DrinkMixture,
                                           "You can't mix that!"))
            {
                return;
            }

            if (CheckFunctions.CheckIfTrue(ch, firstObj.Values.Quantity <= 0 || secondObj.Values.Quantity <= 0,
                                           "It's empty."))
            {
                return;
            }

            var success = CheckMixture(firstObj, secondObj);

            if (CheckFunctions.CheckIfTrue(ch, !success, "Those two don't mix well together."))
            {
                return;
            }

            ch.SendTo("&cYou mix them together.&g");
        }
Exemplo n.º 15
0
        public static void do_kill(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfEmptyString(ch, argument, "Kill whom?"))
            {
                return;
            }

            var firstArg = argument.FirstWord();
            var victim   = ch.GetCharacterInRoom(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, victim.IsNpc() && victim.CurrentMorph != null,
                                           "This creature appears strange to you. Look upon it more closely before attempting to kill it."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, !victim.IsNpc() && !victim.Act.IsSet((int)PlayerFlags.Killer) &&
                                           !victim.Act.IsSet((int)PlayerFlags.Thief), "You must MURDER a player."))
            {
                return;
            }
            if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "You hit yourself.  Ouch!"))
            {
                fight.multi_hit(ch, ch, Program.TYPE_UNDEFINED);
                return;
            }
            if (fight.is_safe(ch, victim, true))
            {
                return;
            }

            if (ch.IsAffected(AffectedByTypes.Charm) && ch.Master == victim)
            {
                comm.act(ATTypes.AT_PLAIN, "$N is your beloved master.", ch, null, victim, ToTypes.Character);
                return;
            }

            if (CheckFunctions.CheckIfTrue(ch, ch.IsInCombatPosition(), "You do the best you can!"))
            {
                return;
            }

            Macros.WAIT_STATE(ch, 1 * GameConstants.GetSystemValue <int>("PulseViolence"));
            ch.CheckAttackForAttackerFlag(victim);
            fight.multi_hit(ch, victim, Program.TYPE_UNDEFINED);
        }
Exemplo n.º 16
0
        public static void do_bug(CharacterInstance ch, string argument)
        {
            var tm = DateTime.Now;

            ch.SetColor(ATTypes.AT_PLAIN);
            if (CheckFunctions.CheckIfEmptyString(ch, argument,
                                                  "Usage:  'bug <message>'  (your location is automatically recorded)"))
            {
                return;
            }

            db.append_file(ch, SystemConstants.GetSystemFile(SystemFileTypes.PBug),
                           $"({tm.ToLongDateString()}):  {argument}");
            ch.SendTo("Thanks, your bug notice has been recorded.");
        }
Exemplo n.º 17
0
        public static void do_unbolt(CharacterInstance ch, string argument)
        {
            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Unbolt what?"))
            {
                return;
            }

            var exit = ch.FindExit(firstArg, true);

            if (exit == null)
            {
                ch.Printf("You see no %s here.", firstArg);
                return;
            }

            if (exit.Flags.IsSet(ExitFlags.Secret) && !exit.Keywords.IsAnyEqual(firstArg))
            {
                ch.Printf("You see no %s here.", firstArg);
                return;
            }

            if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.IsDoor, "You can't do that."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.Closed, "It's not closed."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.IsBolt, "You don't see a bolt."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.Bolted, "It's already unbolted."))
            {
                return;
            }

            if (!exit.Flags.IsSet(ExitFlags.Secret))
            {
                ch.SendTo("*Clunk*");
                comm.act(ATTypes.AT_ACTION, "$n unbolts the $d.", ch, null, exit.Keywords, ToTypes.Room);
                exit.RemoveFlagFromSelfAndReverseExit(ExitFlags.Bolted);
            }
        }
Exemplo n.º 18
0
        public static void do_mpapply(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfTrue(ch,
                                           !ch.IsNpc() || ((PlayerInstance)ch).Descriptor != null || ch.IsAffected(AffectedByTypes.Charm), "Huh?"))
            {
                return;
            }

            if (CheckFunctions.CheckIfEmptyString(ch, argument, "Mpapply - bad syntax"))
            {
                return;
            }

            var victim = ch.GetCharacterInRoom(argument);

            if (CheckFunctions.CheckIfNullObject(ch, victim, "Mpapply - no such player in room."))
            {
                return;
            }

            if (CheckFunctions.CheckIfNullObject(ch, !victim.IsNpc() && ((PlayerInstance)victim).Descriptor != null, "Not on link-dead players"))
            {
                return;
            }

            if (!victim.IsNotAuthorized())
            {
                return;
            }
            if (!victim.IsNpc() && ((PlayerInstance)victim).PlayerData.AuthState != AuthorizationStates.None)
            {
                return;
            }

            var buf =
                $"{victim.Name}@{(victim.IsNpc() ? string.Empty : ((PlayerInstance)victim).Descriptor.host)} new {victim.CurrentRace.GetName()} {victim.CurrentClass.GetName()} {(victim.IsPKill() ? "(Deadly)" : "(Peaceful)")} applying...";

            ChatManager.to_channel(buf, ChannelTypes.Auth, "Auth", LevelConstants.ImmortalLevel);
            if (!victim.IsNpc())
            {
                ((PlayerInstance)victim).PlayerData.AuthState = AuthorizationStates.None;
            }
        }
Exemplo n.º 19
0
        public static void do_rip(CharacterInstance ch, string argument)
        {
            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Rip ON or OFF?"))
            {
                return;
            }

            if (firstArg.EqualsIgnoreCase("on"))
            {
                EnableRip((PlayerInstance)ch);
            }
            else if (firstArg.EqualsIgnoreCase("off"))
            {
                DisableRip((PlayerInstance)ch);
            }
            else
            {
                ch.SendTo("Huh?!?");
            }
        }
Exemplo n.º 20
0
        public static void do_slay(CharacterInstance ch, string argument)
        {
            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Slay whom?"))
            {
                return;
            }

            var victim = ch.GetCharacterInRoom(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here."))
            {
                return;
            }
            if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "Suicide is a mortal sin."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, !victim.IsNpc() && victim.Trust >= ch.Trust, "You failed."))
            {
                return;
            }

            var secondArg = argument.SecondWord();

            if (SlayTable.ContainsKey(secondArg.ToLower()))
            {
                SlayTable[secondArg.ToLower()].Invoke(ch, victim);
            }
            else
            {
                Default(ch, victim);
            }

            handler.set_cur_char(victim);
            ch.RawKill(victim);
        }
Exemplo n.º 21
0
        public static void do_pull(CharacterInstance ch, string argument)
        {
            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Pull what?"))
            {
                return;
            }

            if (handler.FindObject_CheckMentalState(ch))
            {
                return;
            }

            var obj = ch.GetObjectOnMeOrInRoom(firstArg);

            if (obj == null)
            {
                comm.act(ATTypes.AT_PLAIN, "I see no $T here.", ch, null, null, ToTypes.Character);
                return;
            }

            PullOrPush.pullorpush(ch, obj, true);
        }
Exemplo n.º 22
0
        public static void do_typo(CharacterInstance ch, string argument)
        {
            ch.SetColor(ATTypes.AT_PLAIN);

            if (CheckFunctions.CheckIfEmptyString(ch, argument,
                                                  "Usage:  'typo <message>'  (your location is automatically recorded)"))
            {
                if (ch.Trust >= LevelConstants.GetLevel(ImmortalTypes.Ascendant))
                {
                    ch.SendTo("Usage:  'typo list' or 'typo clear now'");
                }
                return;
            }

            if (!argument.EqualsIgnoreCase("clear now") || ch.Trust < LevelConstants.GetLevel(ImmortalTypes.Ascendant))
            {
                return;
            }
            var path = SystemConstants.GetSystemFile(SystemFileTypes.Typo);

            using (var proxy = new TextWriterProxy(new StreamWriter(path, false)))
                proxy.Write(string.Empty);
            ch.SendTo("Typo file cleared.");
        }
Exemplo n.º 23
0
        public static void do_supplicate(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfTrue(ch, ch.IsNpc() || ((PlayerInstance)ch).PlayerData.CurrentDeity == null,
                                           "You have no deity to supplicate to."))
            {
                return;
            }

            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Supplicate for what?"))
            {
                return;
            }

            if (SupplicateTable.ContainsKey(firstArg.ToLower()))
            {
                SupplicateTable[firstArg.ToLower()].Invoke((PlayerInstance)ch, argument);
            }
            else
            {
                ch.SendTo("You cannot supplicate for that.");
            }
        }
Exemplo n.º 24
0
        public static void do_drop(CharacterInstance ch, string argument)
        {
            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Drop what?"))
            {
                return;
            }
            if (handler.FindObject_CheckMentalState(ch))
            {
                return;
            }
            if (!ch.IsNpc() && ch.Act.IsSet((int)PlayerFlags.Litterbug))
            {
                ch.SetColor(ATTypes.AT_YELLOW);
                ch.SendTo("A godly force prevents you from dropping anything...");
                return;
            }

            if (ch.CurrentRoom.Flags.IsSet(RoomFlags.NoDrop) && ch != db.Supermob)
            {
                ch.SetColor(ATTypes.AT_MAGIC);
                ch.SendTo("A magical force stops you!");
                ch.SetColor(ATTypes.AT_TELL);
                ch.SendTo("Someone tells you, 'No littering here!'");
                return;
            }

            var number = 0;
            var qty    = firstArg.ParseWord(1, ".");

            if (!qty.IsNullOrEmpty() && qty.IsNumber())
            {
                number = qty.ToInt32();
            }

            if (CheckFunctions.CheckIfTrue(ch, number < 1, "That was easy..."))
            {
                return;
            }

            firstArg = firstArg.ParseWord(2, ".");

            if (number > 0 && (firstArg.EqualsIgnoreCase("coins") || firstArg.EqualsIgnoreCase("coin")))
            {
                DropCoins(ch, number);
            }
            else if (number <= 1 && !firstArg.EqualsIgnoreCase("all") && !firstArg.StartsWithIgnoreCase("all."))
            {
                DropObject(ch, firstArg);
            }
            else
            {
                DropAllOrSome(ch, firstArg);
            }

            if (GameManager.Instance.SystemData.SaveFlags.IsSet(AutoSaveFlags.Drop))
            {
                save.save_char_obj(ch);
            }
        }
Exemplo n.º 25
0
        public static void do_say(CharacterInstance ch, string argument)
        {
#if !SCRAMBLE
            var speaking = -1;

            /*foreach (int key in GameConstants.LanguageTable.Keys
             *  .Where(key => (key & ch.Speaking) > 0))
             * {
             *  speaking = key;
             *  break;
             * }*/
#endif

            if (CheckFunctions.CheckIfEmptyString(ch, argument, "Say what?"))
            {
                return;
            }
            if (CheckFunctions.CheckIf(ch,
                                       args => ((CharacterInstance)args[0]).CurrentRoom.Flags.IsSet((int)RoomFlags.Silence),
                                       "You can't do that here.", new List <object> {
                ch
            }))
            {
                return;
            }

            var actflags = ch.Act;
            if (ch.IsNpc())
            {
                ch.Act.RemoveBit((int)ActFlags.Secretive);
            }

            foreach (var vch in ch.CurrentRoom.Persons.Where(vch => vch != ch))
            {
                var sbuf = argument;
                if (vch.IsIgnoring(ch))
                {
                    if (!ch.IsImmortal() || vch.Trust > ch.Trust)
                    {
                        continue;
                    }

                    vch.SetColor(ATTypes.AT_IGNORE);
                    vch.Printf("You attempt to ignore %s, but are unable to do so.\r\n", ch.Name);
                }

#if !SCRAMBLE
                /*if (speaking != -1 && (!ch.IsNpc() || ch.Speaking != 0))
                 * {
                 *  int speakswell = vch.KnowsLanguage(ch.Speaking, ch).GetLowestOfTwoNumbers(ch.KnowsLanguage(ch.Speaking, vch));
                 *  if (speakswell < 75)
                 *      sbuf = act_comm.TranslateLanguage(speakswell, argument, GameConstants.LanguageTable[speaking]);
                 * }*/
#else
                if (KnowsLanguage(vch, ch.Speaking, ch) == 0 &&
                    (!ch.IsNpc() || ch.Speaking != 0))
                {
                    sbuf = ScrambleText(argument, ch.Speaking);
                }
#endif
                sbuf = sbuf.Drunkify(ch);

                // TODO Toggle global mobtrigger flag
                comm.act(ATTypes.AT_SAY, "$n says '$t'", ch, sbuf, vch, ToTypes.Victim);
            }

            ch.Act = actflags;
            // TODO Toggle global mobtrigger flag
            comm.act(ATTypes.AT_SAY, "You say '%T'", ch, null, argument.Drunkify(ch), ToTypes.Character);

            if (ch.CurrentRoom.Flags.IsSet((int)RoomFlags.LogSpeech))
            {
                db.append_to_file(SystemConstants.GetSystemFile(SystemFileTypes.Log),
                                  $"{(ch.IsNpc() ? ch.ShortDescription : ch.Name)}: {argument}");
            }

            MudProgHandler.ExecuteMobileProg(MudProgTypes.Speech, argument, ch);
            if (ch.CharDied())
            {
                return;
            }
            MudProgHandler.ExecuteObjectProg(MudProgTypes.Speech, argument, ch);
            if (ch.CharDied())
            {
                return;
            }
            MudProgHandler.ExecuteRoomProg(MudProgTypes.Speech, argument, ch);
        }
Exemplo n.º 26
0
        public static void do_shove(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfTrue(ch, ch.IsNpc() || !((PlayerInstance)ch).PlayerData.Flags.IsSet(PCFlags.Deadly),
                                           "Only deadly characters can shove."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, ch.HasTimer(TimerTypes.PKilled), "You can't shove a player right now."))
            {
                return;
            }

            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Shove whom?"))
            {
                return;
            }

            var victim = ch.GetCharacterInRoom(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here."))
            {
                return;
            }
            if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "You shove yourself around, to no avail."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, victim.IsNpc() || !((PlayerInstance)victim).PlayerData.Flags.IsSet(PCFlags.Deadly),
                                           "You can only shove deadly characters."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, ch.Level.GetAbsoluteDifference(victim.Level) > 5,
                                           "There is too great an experience difference for you to even bother."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNullObject(ch, victim.HasTimer(TimerTypes.PKilled),
                                                 "You can't shove that player right now."))
            {
                return;
            }

            if (victim.CurrentPosition != PositionTypes.Standing)
            {
                comm.act(ATTypes.AT_PLAIN, "$N isn't standing up.", ch, null, victim, ToTypes.Character);
                return;
            }

            var secondArg = argument.SecondWord();

            if (CheckFunctions.CheckIfEmptyString(ch, secondArg, "Shove them in which direction?"))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch,
                                           victim.CurrentRoom.Flags.IsSet(RoomFlags.Safe) && !ch.HasTimer(TimerTypes.ShoveDrag),
                                           "That character cannot be shoved right now."))
            {
                return;
            }

            victim.CurrentPosition = PositionTypes.Shove;

            var exitDir = EnumerationExtensions.GetEnumByName <DirectionTypes>(secondArg);
            var exit    = ch.CurrentRoom.GetExit(exitDir);

            if (CheckFunctions.CheckIfNullObject(ch, exit, "There's no exit in that direction."))
            {
                victim.CurrentPosition = PositionTypes.Standing;
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch,
                                           exit.Flags.IsSet(ExitFlags.Closed) &&
                                           (!victim.IsAffected(AffectedByTypes.PassDoor) || exit.Flags.IsSet(ExitFlags.NoPassDoor)),
                                           "There's no exit in that direction."))
            {
                victim.CurrentPosition = PositionTypes.Standing;
                return;
            }

            var toRoom = exit.GetDestination();

            if (CheckFunctions.CheckIfSet(ch, toRoom.Flags, RoomFlags.Death,
                                          "You cannot shove someone into a death trap."))
            {
                victim.CurrentPosition = PositionTypes.Standing;
                return;
            }

            if (CheckFunctions.CheckIfTrue(ch, ch.CurrentRoom.Area != toRoom.Area && !toRoom.Area.IsInHardRange(victim),
                                           "That character cannot enter that area."))
            {
                victim.CurrentPosition = PositionTypes.Standing;
                return;
            }

            var chance = GetChanceByCharacterClass(ch);

            chance += (ch.GetCurrentStrength() - 15) * 3;
            chance += ch.Level - victim.Level;
            chance += GetBonusByCharacterRace(ch);

            if (CheckFunctions.CheckIfTrue(ch, chance < SmaugRandom.D100(), "You failed."))
            {
                victim.CurrentPosition = PositionTypes.Standing;
                return;
            }

            comm.act(ATTypes.AT_ACTION, "You shove $M.", ch, null, victim, ToTypes.Character);
            comm.act(ATTypes.AT_ACTION, "$n shoves you.", ch, null, victim, ToTypes.Victim);
            Move.move_char(victim, exit, 0);

            if (!victim.CharDied())
            {
                victim.CurrentPosition = PositionTypes.Standing;
            }

            Macros.WAIT_STATE(ch, 12);

            if (ch.CurrentRoom.Flags.IsSet(RoomFlags.Safe) && !ch.HasTimer(TimerTypes.ShoveDrag))
            {
                ch.AddTimer(TimerTypes.ShoveDrag, 10);
            }
        }
Exemplo n.º 27
0
        public static void do_apply(CharacterInstance ch, string argument)
        {
            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Apply what?"))
            {
                return;
            }

            var secondArg = argument.SecondWord();

            if (CheckFunctions.CheckIfNotNullObject(ch, ch.CurrentFighting, "You're too busy fighting..."))
            {
                return;
            }
            if (handler.FindObject_CheckMentalState(ch))
            {
                return;
            }

            var salve = ch.GetCarriedObject(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, salve, "You do not have that."))
            {
                return;
            }

            CharacterInstance victim;
            ObjectInstance    obj = null;

            if (string.IsNullOrEmpty(secondArg))
            {
                victim = ch;
            }
            else
            {
                victim = ch.GetCharacterInRoom(secondArg);
                obj    = ch.GetObjectOnMeOrInRoom(secondArg);

                if (CheckFunctions.CheckIfTrue(ch, victim == null && obj == null, "Apply it to what or whom?"))
                {
                    return;
                }
            }

            if (CheckFunctions.CheckIfNotNullObject(ch, obj, "You can't do that... yet."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNotNullObject(ch, victim.CurrentFighting,
                                                    "Wouldn't work very well while they're fighting..."))
            {
                return;
            }

            if (salve.ItemType != ItemTypes.Salve)
            {
                ApplyNonSalve(salve, ch, victim);
                return;
            }

            salve.Split();
            salve.Values.Charges -= 1;

            if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, salve, null, null))
            {
                UseSalve(salve, ch, victim);
            }

            Macros.WAIT_STATE(ch, salve.Values.Delay);
            var retcode = ch.ObjectCastSpell((int)salve.Values.Skill1ID, (int)salve.Values.SpellLevel, victim);

            if (retcode == ReturnTypes.None)
            {
                retcode = ch.ObjectCastSpell((int)salve.Values.Skill2ID, (int)salve.Values.SpellLevel, victim);
            }
            if (retcode == ReturnTypes.CharacterDied || retcode == ReturnTypes.BothDied)
            {
                throw new CharacterDiedException("Salve {0}, Actor {1}, Victim {2}", salve.ID, ch.ID, victim.ID);
            }

            if (!handler.obj_extracted(salve) && salve.Values.Charges <= 0)
            {
                salve.Extract();
            }
        }
Exemplo n.º 28
0
        public static void do_at(CharacterInstance ch, string argument)
        {
            ch.SetColor(ATTypes.AT_IMMORT);

            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "At where what?"))
            {
                return;
            }

            RoomTemplate      location       = null;
            CharacterInstance worldCharacter = null;

            if (argument.IsNumber())
            {
                location = RepositoryManager.Instance.GetEntity <RoomTemplate>(argument);
            }
            else if (argument.EqualsIgnoreCase("pk"))
            {
                // todo get last pkroom
            }
            else
            {
                worldCharacter = RepositoryManager.Instance.GetEntity <CharacterInstance>(argument);
                if (CheckFunctions.CheckIf(ch, () => worldCharacter?.CurrentRoom == null,
                                           "No such mobile or player in the world."))
                {
                    return;
                }
            }

            if (location == null && worldCharacter != null)
            {
                location = worldCharacter.CurrentRoom;
            }

            if (CheckFunctions.CheckIfNullObject(ch, location, "No such location exists."))
            {
                return;
            }

            if (worldCharacter != null && !worldCharacter.IsNpc())
            {
                if (((PlayerInstance)worldCharacter).PlayerData.Flags.IsSet(PCFlags.DoNotDisturb))
                {
                    ch.PagerPrintf("Sorry. %s does not wish to be disturbed.", worldCharacter.Name);
                    worldCharacter.PagerPrintf("Your Do-Not-Disturb flag just foiled %s's AT command.", ch.Name);
                    return;
                }
            }

            if (location.IsPrivate())
            {
                if (CheckFunctions.CheckIf(ch, () => ch.Trust < LevelConstants.GetLevel(ImmortalTypes.Greater),
                                           "That room is private right now."))
                {
                    return;
                }
                ch.SendTo("Overriding private flag!");
            }

            CharacterInstance victim = location.IsDoNotDisturb(ch);

            if (victim != null)
            {
                ch.PagerPrintf("That room is \"do not disturb\" right now.");
                victim.PagerPrintf("Your do-not-disturb flag just foiled %s's atmob command.", ch.Name);
                return;
            }

            ch.SetColor(ATTypes.AT_PLAIN);
            RoomTemplate original = ch.CurrentRoom;

            ch.CurrentRoom.RemoveFrom(ch);
            location.AddTo(ch);
            interp.interpret(ch, argument);

            if (!ch.CharDied())
            {
                ch.CurrentRoom.RemoveFrom(ch);
                original.AddTo(ch);
            }
        }
Exemplo n.º 29
0
        public void CheckIfEmptyString()
        {
            var actor = new CharacterInstance(1, "TestNpc");

            Assert.That(CheckFunctions.CheckIfEmptyString(actor, string.Empty, string.Empty), Is.True);
        }
Exemplo n.º 30
0
        public static void do_murder(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfEmptyString(ch, argument, "Murder whom?"))
            {
                return;
            }

            var firstArg = argument.FirstWord();
            var victim   = ch.GetCharacterInRoom(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here."))
            {
                return;
            }
            if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "Suicide is a mortal sin."))
            {
                return;
            }

            if (fight.is_safe(ch, victim, true))
            {
                return;
            }

            if (ch.IsAffected(AffectedByTypes.Charm))
            {
                if (ch.Master == victim)
                {
                    comm.act(ATTypes.AT_PLAIN, "$N is your beloeved master.", ch, null, victim, ToTypes.Character);
                    return;
                }

                ch.Master?.Act.SetBit((int)PlayerFlags.Attacker);
            }

            if (CheckFunctions.CheckIfTrue(ch, ch.IsInCombatPosition(), "You do the best you can!"))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, !victim.IsNpc() && ch.Act.IsSet((int)PlayerFlags.Nice),
                                           "You feel too nice to do that!"))
            {
                return;
            }

            // TODO Log the murder

            Macros.WAIT_STATE(ch, 1 & GameConstants.GetSystemValue <int>("PulseViolence"));

            var buf = $"Help!  I am being attacked by {(ch.IsNpc() ? ch.ShortDescription : ch.Name)}!";

            if (victim.IsPKill())
            {
                Wartalk.do_wartalk(victim, buf);
            }
            else
            {
                Yell.do_yell(victim, buf);
            }

            fight.check_illegal_pk(ch, victim);
            ch.CheckAttackForAttackerFlag(victim);
            fight.multi_hit(ch, victim, Program.TYPE_UNDEFINED);
        }