Пример #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]);
        }
Пример #2
0
        private static void LockObject(CharacterInstance ch, ObjectInstance obj, string arg)
        {
            if (CheckFunctions.CheckIfTrue(ch, obj.ItemType != ItemTypes.Container, "That's not a container."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNotSet(ch, obj.Values.Flags, ContainerFlags.Closed, "It's not closed."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, obj.Values.KeyID <= 0, "It can't be locked."))
            {
                return;
            }

            var key = ch.HasKey((int)obj.Values.KeyID);

            if (CheckFunctions.CheckIfNullObject(ch, key, "You lack the key."))
            {
                return;
            }
            if (CheckFunctions.CheckIfSet(ch, obj.Values.Flags, ContainerFlags.Locked, "It's already locked."))
            {
                return;
            }

            obj.Values.Flags = obj.Values.Flags.SetBit(ContainerFlags.Locked);
            ch.SendTo("*Click*");
            var count = key.Count;

            key.Count = 1;
            comm.act(ATTypes.AT_ACTION, "$n locks $p with $P.", ch, obj, key, ToTypes.Room);
            key.Count = count;
        }
Пример #3
0
        private static ReturnTypes CastDefensiveOrSelfSpell(SkillData skill, int level, CharacterInstance ch, object vo)
        {
            if (CheckFunctions.CheckIfTrue(ch, skill.Flags.IsSet(SkillFlags.NoFight) && ch.IsInCombatPosition(),
                                           "You can't concentrate enough for that!"))
            {
                return(ReturnTypes.None);
            }
            if (vo != null && Macros.SPELL_ACTION(skill) == (int)SpellActTypes.Destroy)
            {
                if (Macros.SPELL_DAMAGE(skill) == (int)SpellDamageTypes.Poison)
                {
                    var poisonSkill = RepositoryManager.Instance.GetEntity <SkillData>("poison");
                    if (poisonSkill == null)
                    {
                        throw new ObjectNotFoundException("Skill 'poison' not found");
                    }

                    // TODO Do something with poison skill
                }

                if (Macros.SPELL_CLASS(skill) == (int)SpellClassTypes.Illusion)
                {
                    var blindSkill = RepositoryManager.Instance.GetEntity <SkillData>("blindness");
                    if (blindSkill == null)
                    {
                        throw new ObjectNotFoundException("Skill 'blindness' not found");
                    }

                    // TODO Do something with blindness skill
                }
            }
            return(Affect.spell_affect((int)skill.ID, level, ch, vo));
        }
Пример #4
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);
            }
        }
Пример #5
0
        public static void do_auction(CharacterInstance ch, string argument, IAuctionManager auctionManager = null)
        {
            if (ch.IsNpc())
            {
                return;
            }

            ch.SetColor(ATTypes.AT_LBLUE);
            if (CheckFunctions.CheckIfTrue(ch, ch.Level < GameConstants.GetSystemValue <int>("MinimumAuctionLevel"),
                                           "You need to gain more experience to use the auction..."))
            {
                return;
            }

            // TODO: Do we really want time restrictions on auctions?

            var firstArg = argument.FirstWord();

            if (firstArg.IsNullOrEmpty())
            {
                ReviewAuction(ch, auctionManager);
            }
            if (ch.IsImmortal() && firstArg.EqualsIgnoreCase("stop"))
            {
                StopAuction(ch, "Sale of {0} has been stopped by an Immortal.", auctionManager);
            }
            if (firstArg.EqualsIgnoreCase("bid"))
            {
                PlaceBid(ch, argument, auctionManager);
            }
            PlaceItemForAuction(ch, argument, auctionManager);
        }
Пример #6
0
        private static void EmptyToGround(CharacterInstance ch, ObjectInstance obj)
        {
            if (ch.CurrentRoom.Flags.IsSet(RoomFlags.NoDrop) || ch.Act.IsSet((int)PlayerFlags.Litterbug))
            {
                ch.SendTo("&[magic]A magical force stops you!");
                ch.SendTo("&[tell]Someone tells you, 'No littering here!");
                return;
            }

            if (CheckFunctions.CheckIfTrue(ch,
                                           ch.CurrentRoom.Flags.IsSet(RoomFlags.NoDropAll) || ch.CurrentRoom.Flags.IsSet(RoomFlags.ClanStoreroom),
                                           "You can't seem to do that here..."))
            {
                return;
            }

            if (CheckFunctions.CheckIfTrue(ch, !obj.Empty(null, ch.CurrentRoom), "Hmmm... didn't work."))
            {
                return;
            }

            comm.act(ATTypes.AT_ACTION, "You empty $p.", ch, obj, null, ToTypes.Character);
            comm.act(ATTypes.AT_ACTION, "$n empties $p.", ch, obj, null, ToTypes.Room);

            if (GetSaveFlags().IsSet(AutoSaveFlags.Empty))
            {
                save.save_char_obj(ch);
            }
        }
Пример #7
0
        public static void do_brandish(CharacterInstance ch, string argument)
        {
            var obj = ch.GetEquippedItem(WearLocations.Hold);

            if (CheckFunctions.CheckIfNullObject(ch, obj, "You hold nothing in your hand."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, obj.ItemType != ItemTypes.Staff, "You can brandish only with a staff."))
            {
                return;
            }

            if (obj.Value.ToList()[3] <= 0)
            {
                throw new InvalidDataException($"Object {obj.ID} has no skill ID assigned to Value[3]");
            }

            Macros.WAIT_STATE(ch, 2 * GameConstants.GetSystemValue <int>("PulseViolence"));

            if (obj.Value.ToList()[2] > 0)
            {
                BrandishStaff(ch, obj);
            }

            if (--obj.Value.ToList()[2] <= 0)
            {
                comm.act(ATTypes.AT_MAGIC, "$p blazes bright and vanishes from $n's hands!", ch, obj, null, ToTypes.Room);
                comm.act(ATTypes.AT_MAGIC, "$p blazes bright and is gone!", ch, obj, null, ToTypes.Character);
                obj.Extract();
            }
        }
Пример #8
0
        private static ReturnTypes CreateWaterSpellAction(SkillData skill, int level, CharacterInstance ch, ObjectInstance obj, WeatherCell cell)
        {
            if (CheckFunctions.CheckIfTrue(ch, obj.ItemType != ItemTypes.DrinkContainer, "It is unable to hold water."))
            {
                return(ReturnTypes.SpellFailed);
            }
            if (CheckFunctions.CheckIfTrue(ch, obj.Value.ToList()[2] != 0 && obj.Value.ToList()[1] != 0, "It contains some other liquid."))
            {
                return(ReturnTypes.SpellFailed);
            }

            var minVal = (!string.IsNullOrEmpty(skill.Dice) ? magic.ParseDiceExpression(ch, skill.Dice) : level) *
                         (cell.Precipitation >= 0 ? 2 : 1);
            var water = minVal.GetLowestOfTwoNumbers(obj.Value.ToList()[0] - obj.Value.ToList()[1]);

            if (water > 0)
            {
                obj.Split();
                obj.Value.ToList()[2]  = 0;
                obj.Value.ToList()[1] += water;
                if (obj.Name.EqualsIgnoreCase("water"))
                {
                    // TODO Set name to:  string.format("{0} water", obj.Name)
                }
            }

            ch.SuccessfulCast(skill, null, obj);
            return(ReturnTypes.None);
        }
Пример #9
0
        private static ReturnTypes OtherSpellAction(SkillData skill, CharacterInstance ch, ObjectInstance obj)
        {
            if (Macros.SPELL_DAMAGE(skill) == (int)SpellDamageTypes.Poison)
            {
                if (CheckFunctions.CheckIfTrue(ch,
                                               obj.ItemType != ItemTypes.DrinkContainer && obj.ItemType != ItemTypes.Food &&
                                               obj.ItemType != ItemTypes.Cook, "It doesn't look poisoned."))
                {
                    return(ReturnTypes.None);
                }

                if (CheckFunctions.CheckIfTrue(ch, obj.ItemType == ItemTypes.Cook && obj.Value.ToList()[2] == 0,
                                               "It looks undercooked."))
                {
                    return(ReturnTypes.None);
                }
                if (CheckFunctions.CheckIfTrue(ch, obj.Value.ToList()[3] != 0, "You smell poisonous fumes."))
                {
                    return(ReturnTypes.None);
                }

                ch.SendTo("It looks very delicious.");
            }
            return(ReturnTypes.None);
        }
Пример #10
0
        private static object TargetCharacterWithDefensiveSpell(string arg, CharacterInstance ch, bool silence,
                                                                SkillData skill)
        {
            CharacterInstance victim;

            if (arg.IsNullOrEmpty())
            {
                victim = ch;
            }
            else
            {
                victim = ch.GetCharacterInRoom(arg);
                if (CheckFunctions.CheckIfNullObject(ch, victim, !silence ? "They aren't here." : ""))
                {
                    return(null);
                }
            }

            // Nuisance flag will pick who you are fighting for defensive spells up to 36% of the time
            if (!ch.IsNpc() && ch.CurrentFighting != null && ((PlayerInstance)ch).PlayerData.Nuisance != null &&
                ((PlayerInstance)ch).PlayerData.Nuisance.Flags > 5 &&
                SmaugRandom.D100() < (((PlayerInstance)ch).PlayerData.Nuisance.Flags - 5) * 8 + 6 * ((PlayerInstance)ch).PlayerData.Nuisance.Power)
            {
                victim = ch.GetMyTarget();
            }

            return(CheckFunctions.CheckIfTrue(ch, ch == victim && skill.Flags.IsSet(SkillFlags.NoSelf),
                                              !silence ? "You can't cast this on yourself!" : "") ? null : victim);
        }
Пример #11
0
        public static void do_drink(CharacterInstance ch, string argument)
        {
            var arg = argument.FirstWord();

            if (arg.EqualsIgnoreCase("from"))
            {
                arg = arg.SecondWord();
            }

            var obj = GetDrinkSource(ch, arg);

            if (obj == null)
            {
                throw new ObjectNotFoundException($"Object {arg} was not found.");
            }

            if (obj.Count > 1 && obj.ItemType != ItemTypes.Fountain)
            {
                obj.Split();
            }

            if (CheckFunctions.CheckIfTrue(ch,
                                           !ch.IsNpc() && ((PlayerInstance)ch).GetCondition(ConditionTypes.Drunk) > GetMaximumCondition() - 8,
                                           "You fail to reach your mouth.  *Hic*"))
            {
                return;
            }

            DrinkFrom(ch, obj);

            var pulsesPerSecond = GameConstants.GetSystemValue <int>("PulsesPerSecond");

            Macros.WAIT_STATE(ch, ch.GetMyTarget() != null && ch.IsPKill() ? pulsesPerSecond / 3 : pulsesPerSecond);
        }
Пример #12
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.");
        }
Пример #13
0
        public static ReturnTypes spell_cure_blindness(int sn, int level, CharacterInstance ch, object vo)
        {
            var victim = (CharacterInstance)vo;
            var skill  = RepositoryManager.Instance.GetEntity <SkillData>(sn);

            ch.SetColor(ATTypes.AT_MAGIC);

            if (CheckFunctions.CheckIfTrueCasting(victim.IsImmune(ResistanceTypes.Magic), skill, ch,
                                                  CastingFunctionType.Immune, victim))
            {
                return(ReturnTypes.SpellFailed);
            }

            if (CheckFunctions.CheckIfTrue(ch, ch.IsAffected(AffectedByTypes.Blind),
                                           ch != victim
                    ? "You work your cure, but it has no apparent effect."
                    : "You don't seem to be blind."))
            {
                return(ReturnTypes.SpellFailed);
            }

            victim.StripAffects((int)AffectedByTypes.Blind);
            victim.SetColor(ATTypes.AT_MAGIC);
            victim.SendTo("Your vision returns!");
            if (ch != victim)
            {
                ch.SendTo("You work your cure, restoring vision.");
            }
            return(ReturnTypes.None);
        }
Пример #14
0
        public static void do_pager(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfNpc(ch, ch))
            {
                return;
            }

            ch.SetColor(ATTypes.AT_NOTE);
            var firstArg = argument.FirstWord();

            if (string.IsNullOrEmpty(firstArg))
            {
                TogglePager(ch);
                return;
            }

            if (CheckFunctions.CheckIfTrue(ch, !firstArg.IsNumber(), "Set page pausing to how many lines?"))
            {
                return;
            }

            ((PlayerInstance)ch).PlayerData.PagerLineCount = Convert.ToInt32(firstArg);
            if (((PlayerInstance)ch).PlayerData.PagerLineCount < 5)
            {
                ((PlayerInstance)ch).PlayerData.PagerLineCount = 5;
            }

            ch.Printf("Page pausing set to {0} lines.", ((PlayerInstance)ch).PlayerData.PagerLineCount);
        }
Пример #15
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;
            }
        }
Пример #16
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;
            }
        }
Пример #17
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);
        }
Пример #18
0
        private static void DrinkFromBlood(PlayerInstance ch, ObjectInstance obj)
        {
            if (CheckFunctions.CheckIfTrue(ch, !ch.IsVampire(), "It is not in your nature to do such things."))
            {
                return;
            }

            if (obj.Timer < 0 && ch.Level > 5 && ch.GetCondition(ConditionTypes.Bloodthirsty) > 5 + ch.Level / 10)
            {
                ch.SendTo("It is beneath you to stoop to drinking blood from the ground!");
                ch.SendTo("Unless in dire need, you'd much rather have blood from a victim's neck!");
                return;
            }

            if (CheckFunctions.CheckIfTrue(ch, ch.GetCondition(ConditionTypes.Bloodthirsty) >= 10 + ch.Level,
                                           "Alas... you cannot consume any more blood."))
            {
                return;
            }

            var maxCond = GetMaximumCondition();

            if (CheckFunctions.CheckIfTrue(ch, ch.GetCondition(ConditionTypes.Bloodthirsty) >= maxCond ||
                                           ch.GetCondition(ConditionTypes.Thirsty) >= maxCond,
                                           "You are too full to drink any blood."))
            {
                return;
            }

            if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
            {
                comm.act(ATTypes.AT_BLOOD, "$n drinks from the spilled blood.", ch, null, null, ToTypes.Room);
                ch.SetColor(ATTypes.AT_BLOOD);
                ch.SendTo("You relish in the replenishment of this vital fluid...");

                if (obj.Values.Quantity <= 1)
                {
                    ch.SetColor(ATTypes.AT_BLOOD);
                    ch.SendTo("You drink the last drop of blood from the spill");
                    comm.act(ATTypes.AT_BLOOD, "$n drinks the last drop of blood from the spill.", ch, null, null,
                             ToTypes.Room);
                }
            }

            ch.GainCondition(ConditionTypes.Bloodthirsty, 1);
            ch.GainCondition(ConditionTypes.Full, 1);
            ch.GainCondition(ConditionTypes.Thirsty, 1);

            if (obj.Values.Quantity - 1 <= 0)
            {
                obj.Extract();
                ObjectFactory.CreateBloodstain(ch, RepositoryManager.Instance);
            }
        }
Пример #19
0
        private static void EmptyDrinkContainer(CharacterInstance ch, ObjectInstance obj)
        {
            if (CheckFunctions.CheckIfTrue(ch, obj.Values.Quantity < 1, "It's already empty."))
            {
                return;
            }

            comm.act(ATTypes.AT_ACTION, "You empty $p.", ch, obj, null, ToTypes.Character);
            comm.act(ATTypes.AT_ACTION, "$n empties $p.", ch, obj, null, ToTypes.Room);
            obj.Values.Quantity = 0;
        }
Пример #20
0
        private static void FromSleeping(CharacterInstance ch)
        {
            if (CheckFunctions.CheckIfTrue(ch, ch.IsAffected(AffectedByTypes.Sleep), "You can't seem to wake up!"))
            {
                return;
            }

            ch.SendTo("You wake and climb quickly to your feet.");
            comm.act(ATTypes.AT_ACTION, "$n arises from $s slumber.", ch, null, null, ToTypes.Room);
            ch.CurrentPosition = PositionTypes.Standing;
        }
Пример #21
0
        private static void OpenDoor(CharacterInstance ch, ExitData exit, string arg)
        {
            if (exit.Flags.IsSet(ExitFlags.Secret) && !exit.Keywords.IsAnyEqual(arg))
            {
                ch.Printf("You see no %s here.", arg);
                return;
            }

            if (CheckFunctions.CheckIfTrue(ch, !exit.Flags.IsSet(ExitFlags.IsDoor) ||
                                           exit.Flags.IsSet(ExitFlags.Dig), "You can't do that."))
            {
                return;
            }

            if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.Closed, "It's already open."))
            {
                return;
            }

            if (CheckFunctions.CheckIfTrue(ch, exit.Flags.IsSet(ExitFlags.Locked) &&
                                           exit.Flags.IsSet(ExitFlags.Bolted), "The bolt is locked."))
            {
                return;
            }

            if (CheckFunctions.CheckIfSet(ch, exit.Flags, ExitFlags.Bolted, "It's bolted."))
            {
                return;
            }
            if (CheckFunctions.CheckIfSet(ch, exit.Flags, ExitFlags.Locked, "It's locked."))
            {
                return;
            }

            if (!exit.Flags.IsSet(ExitFlags.Secret) || exit.Keywords.IsAnyEqual(arg))
            {
                comm.act(ATTypes.AT_ACTION, "$n opens the $d.", ch, null, exit.Keywords, ToTypes.Room);
                comm.act(ATTypes.AT_ACTION, "You open the $d.", ch, null, exit.Keywords, ToTypes.Character);

                var reverseExit = exit.GetReverse();
                if (reverseExit != null)
                {
                    var room = exit.GetDestination(RepositoryManager.Instance);
                    foreach (var vch in room.Persons)
                    {
                        comm.act(ATTypes.AT_ACTION, "The $d opens.", vch, null, reverseExit.Keywords, ToTypes.Character);
                    }
                }

                exit.RemoveFlagFromSelfAndReverseExit(ExitFlags.Closed);

                // TODO Check for traps
            }
        }
Пример #22
0
        private static void FromSleeping(CharacterInstance ch)
        {
            if (CheckFunctions.CheckIfTrue(ch, ch.IsAffected(AffectedByTypes.Sleep), "You can't seem to wake up!"))
            {
                return;
            }

            ch.SendTo("You wake and sit up.");
            comm.act(ATTypes.AT_ACTION, "$n wakes and sits up.", ch, null, null, ToTypes.Room);
            ch.CurrentPosition = PositionTypes.Sitting;
        }
Пример #23
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");
        }
Пример #24
0
        public static void do_newbiechat(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfTrue(ch,
                                           ch.IsNpc() ||
                                           (!ch.IsNotAuthorized() && !ch.IsImmortal() &&
                                            !(((PlayerInstance)ch).PlayerData.Council != null && ((PlayerInstance)ch).PlayerData.Council.Name.Equals("Newbie Council"))), "Huh?"))
            {
                return;
            }

            ChatManager.talk_channel(ch, argument, ChannelTypes.Newbie, "newbiechat");
        }
Пример #25
0
        private static void SupplicateForCorpse(PlayerInstance ch, string argument)
        {
            var oldfavor = ch.PlayerData.Favor;

            if (CheckFunctions.CheckIfTrue(ch, ch.PlayerData.Favor < ch.PlayerData.CurrentDeity.SupplicateCorpseCost,
                                           "You are not favored enough for a corpse retrieval."))
            {
                return;
            }
            if (CheckFunctions.CheckIfSet(ch, ch.CurrentRoom.Flags, RoomFlags.ClanStoreroom,
                                          "You cannot supplicate in a storage room."))
            {
                return;
            }

            var corpse =
                ch.CurrentRoom.Contents.FirstOrDefault(
                    x => x.ShortDescription.Equals($"the corpse of {ch.Name}"));

            if (CheckFunctions.CheckIfNullObject(ch, corpse, "No corpse of yours litters the world..."))
            {
                return;
            }
            if (CheckFunctions.CheckIfSet(ch, corpse.InRoom.Flags, RoomFlags.NoSupplicate,
                                          "The image of your corpse appears, but suddenly fades away."))
            {
                return;
            }

            comm.act(ATTypes.AT_MAGIC, "Your corpse appears suddenly, surrounded by a divine presence...", ch, null, null, ToTypes.Character);
            comm.act(ATTypes.AT_MAGIC, "$n's corpse appears suddenly, surrounded by a divine force...", ch, null, null, ToTypes.Room);
            corpse.InRoom.RemoveFrom(corpse);
            ch.CurrentRoom.AddTo(corpse);
            corpse.ExtraFlags.RemoveBit((int)ItemExtraFlags.Buried);

            ch.PlayerData.Favor -= ch.PlayerData.CurrentDeity.SupplicateCorpseCost;

            if (ch.PlayerData.Favor < ch.PlayerData.CurrentDeity.SusceptNum)
            {
                ch.Susceptibility.SetBit(ch.PlayerData.CurrentDeity.Suscept);
            }

            if ((oldfavor > ch.PlayerData.CurrentDeity.AffectedNum &&
                 ch.PlayerData.Favor <= ch.PlayerData.CurrentDeity.AffectedNum) ||
                (oldfavor > ch.PlayerData.CurrentDeity.ElementNum &&
                 ch.PlayerData.Favor <= ch.PlayerData.CurrentDeity.ElementNum) ||
                (oldfavor < ch.PlayerData.CurrentDeity.SusceptNum &&
                 ch.PlayerData.Favor >= ch.PlayerData.CurrentDeity.SusceptNum))
            {
                ch.update_aris();
            }
        }
Пример #26
0
        public static void do_counciltalk(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfNotAuthorized(ch, ch, "Huh?"))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, ch.IsNpc() || ((PlayerInstance)ch).PlayerData.Council == null, "Huh?"))
            {
                return;
            }

            ChatManager.talk_channel(ch, argument, ChannelTypes.Council, "counciltalk");
        }
Пример #27
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);
        }
Пример #28
0
        public static void do_glance(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfNullObject(ch, ((PlayerInstance)ch).Descriptor))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, (int)ch.CurrentPosition < (int)PositionTypes.Sleeping,
                                           "You can't see anything but stars!"))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, ch.CurrentPosition == PositionTypes.Sleeping,
                                           "You can't see anything, you're sleeping!"))
            {
                return;
            }
            if (CheckFunctions.CheckIfBlind(ch, "You can't see a thing!"))
            {
                return;
            }

            ch.SetColor(ATTypes.AT_ACTION);

            var firstWord = argument.FirstWord();

            if (string.IsNullOrEmpty(firstWord))
            {
                GlanceAtRoom(ch);
                return;
            }

            var victim = ch.GetCharacterInRoom(firstWord);

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

            if (victim.CanSee(ch))
            {
                comm.act(ATTypes.AT_ACTION, "$n glances at you.", ch, null, victim, ToTypes.Victim);
                comm.act(ATTypes.AT_ACTION, "$n glances at $N.", ch, null, victim, ToTypes.NotVictim);
            }

            if (ch.IsImmortal() && victim != ch)
            {
                GlanceFromImmortal(ch, victim);
            }
        }
Пример #29
0
        private static void UnlockDoor(CharacterInstance ch, ExitData exit, string firstArg)
        {
            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.CheckIfTrue(ch, exit.Key < 0, "It can't be unlocked."))
            {
                return;
            }

            var key = ch.HasKey(exit.Key);

            if (CheckFunctions.CheckIfNullObject(ch, key, "You lack the key."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.Locked, "It's already unlocked."))
            {
                return;
            }

            if (!exit.Flags.IsSet(ExitFlags.Secret) || exit.Keywords.IsAnyEqual(firstArg))
            {
                ch.SendTo("*Click*");
                var count = key.Count;
                key.Count = 1;
                comm.act(ATTypes.AT_ACTION, "$n unlocks the $d with $p.", ch, key, exit.Keywords, ToTypes.Room);
                key.Count = count;

                if (exit.Flags.IsSet(ExitFlags.EatKey))
                {
                    key.Split();
                    key.Extract();
                }

                exit.RemoveFlagFromSelfAndReverseExit(ExitFlags.Locked);
            }
        }
Пример #30
0
        public static void do_clantalk(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfNotAuthorized(ch, ch, "Huh?"))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, ch.IsNpc() || ((PlayerInstance)ch).PlayerData.Clan == null ||
                                           ((PlayerInstance)ch).PlayerData.Clan.ClanType == ClanTypes.Order ||
                                           ((PlayerInstance)ch).PlayerData.Clan.ClanType == ClanTypes.Guild, "Huh?"))
            {
                return;
            }

            ChatManager.talk_channel(ch, argument, ChannelTypes.Clan, "clantalk");
        }