Ejemplo n.º 1
0
        public static void do_bestowarea(CharacterInstance ch, string argument)
        {
            ch.SetColor(ATTypes.AT_IMMORT);

            if (string.IsNullOrEmpty(argument))
            {
                ch.SendTo("Syntax:");
                ch.SendTo("bestowarea <victim> <filename>.are");
                ch.SendTo("bestowarea <victim> none (removes bestowed areas)");
                ch.SendTo("bestowarea <victim> list (lists bestowed areas)");
                ch.SendTo("bestowarea <victim>      (lists bestowed areas)");
                return;
            }

            var firstArg = argument.FirstWord();

            var victim = ch.GetCharacterInWorld(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNpc(ch, victim, "You can't give special abilities to a mob!"))
            {
                return;
            }
            if (!victim.IsImmortal())
            {
                ch.SendTo("They aren't an immortal.");
                return;
            }

            var secondArg = argument.SecondWord();

            if (string.IsNullOrEmpty(secondArg) || secondArg.EqualsIgnoreCase("list"))
            {
                var areaNames = ((PlayerInstance)victim).PlayerData.Bestowments.Where(x => x.EndsWith(".are"));
                ch.SendTo($"Bestowed Areas: {string.Join(", ", areaNames)}");
                return;
            }

            if (secondArg.EqualsIgnoreCase("none"))
            {
                ((PlayerInstance)victim).PlayerData.Bestowments = ((PlayerInstance)victim).PlayerData.Bestowments.Where(x => !x.EndsWith(".are")).ToList();
                ch.SendTo("Done.");
                return;
            }

            if (!secondArg.EndsWith(".are"))
            {
                ch.SendTo("You can only bestow an area name.");
                ch.SendTo("e.g. bestow joe sam.are");
                return;
            }

            ((PlayerInstance)victim).PlayerData.Bestowments.Add(secondArg);
            victim.SetColor(ATTypes.AT_IMMORT);
            victim.SendTo($"{ch.Name} has bestowed on you the area: {secondArg}");
            ch.SendTo("Done.");
        }
Ejemplo n.º 2
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);
        }
        public void CheckIfNpc()
        {
            var actor = new CharacterInstance(1, "TestNpc");

            actor.Act.SetBit((int)ActFlags.IsNpc);

            Assert.That(CheckFunctions.CheckIfNpc(actor, actor), Is.True);
        }
Ejemplo n.º 4
0
        public static void do_bamfin(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfNpc(ch, ch))
            {
                return;
            }

            //smash_tilde(argument);
            ((PlayerInstance)ch).PlayerData.bamfin = argument;
            ch.SendTo("&YBamfin set.");
        }
Ejemplo n.º 5
0
        public static void do_afk(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfNpc(ch, ch))
            {
                return;
            }

            if (ch.Act.IsSet((int)PlayerFlags.AwayFromKeyboard))
            {
                ch.Act.RemoveBit((int)PlayerFlags.AwayFromKeyboard);
            }
            else
            {
                ch.Act.SetBit((int)PlayerFlags.AwayFromKeyboard);
            }

            var isAfkSet = ch.Act.IsSet((int)PlayerFlags.AwayFromKeyboard);

            ch.SendTo(isAfkSet ? "You are no longer afk." : "You are now afk.");
            comm.act(ATTypes.AT_GREY, isAfkSet ? "$n is no longer afk." : "$n is now afk.", ch, null, null,
                     ToTypes.CanSee);
        }
Ejemplo n.º 6
0
        public static void do_advance(CharacterInstance ch, string argument)
        {
            ch.SetColor(ATTypes.AT_IMMORT);

            string firstArg  = argument.FirstWord();
            string secondArg = argument.SecondWord();

            if (CheckFunctions.CheckIf(ch,
                                       () => string.IsNullOrEmpty(firstArg) || string.IsNullOrEmpty(secondArg) || !secondArg.IsNumeric(),
                                       "Syntax:  advance <character> <Level>"))
            {
                return;
            }

            var victim = ch.GetCharacterInRoom(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, victim, "That character is not in the room."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNpc(ch, victim, "You cannot advance a non-player-character."))
            {
                return;
            }
            if (CheckFunctions.CheckIf(ch, () => ch.Trust <= victim.Trust || ch == victim, "You can't do that."))
            {
                return;
            }

            var level = Convert.ToInt32(secondArg);

            if (CheckFunctions.CheckIf(ch, () => level < 1 || level > GameConstants.GetConstant <int>("MaximumLevel"),
                                       $"Level range is 1 to {GameConstants.GetConstant<int>("MaximumLevel")}."))
            {
                return;
            }
            if (CheckFunctions.CheckIf(ch, () => level > ch.Trust, "Level limited to your trust level."))
            {
                return;
            }

            if (level <= victim.Level)
            {
                LowerVictimLevel(ch, victim, level);
            }
            else
            {
                RaiseVictimLevel(ch, victim, level);
            }

            for (int i = victim.Level; i < level; i++)
            {
                if (level < LevelConstants.ImmortalLevel)
                {
                    victim.SendTo("You raise a level!");
                }
                victim.Level += 1;
                if (victim is PlayerInstance)
                {
                    ((PlayerInstance)victim).AdvanceLevel();
                }
            }

            victim.Experience = victim.GetExperienceLevel(victim.Level);
            victim.Trust      = 0;
        }
Ejemplo n.º 7
0
        public static void do_quit(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfNpc(ch, ch))
            {
                return;
            }

            if (CheckFunctions.CheckIf(ch, HelperFunctions.IsInFightingPosition,
                                       "No way! You are fighting.", new List <object> {
                ch
            }, ATTypes.AT_RED))
            {
                return;
            }

            if (CheckFunctions.CheckIf(ch, args => ((CharacterInstance)args[0]).CurrentPosition == PositionTypes.Stunned,
                                       "You're not DEAD yet.", new List <object> {
                ch
            }, ATTypes.AT_BLOOD))
            {
                return;
            }

            var timer = ch.Timers.FirstOrDefault(x => x.Type == TimerTypes.RecentFight);

            if (timer != null && !ch.IsImmortal())
            {
                ch.SetColor(ATTypes.AT_RED);
                ch.SendTo("Your adrenaline is pumping too hard to quit now!");
                return;
            }

            // TODO: auction
            if (CheckFunctions.CheckIf(ch, args =>
            {
                var actor = (CharacterInstance)args[0];
                return(actor.IsPKill() && actor.wimpy > actor.MaximumHealth / 2.25f);
            }, "Your wimpy has been adjusted to the maximum level for deadlies.", new List <object> {
                ch
            }))
            {
                Wimpy.do_wimpy(ch, "max");
            }

            if (ch.CurrentPosition == PositionTypes.Mounted)
            {
                Dismount.do_dismount(ch, string.Empty);
            }

            ch.SetColor(ATTypes.AT_WHITE);
            ch.SendTo("Your surroundings begin to fade as a mystical swirling vortex of colors\r\nenvelops your body... When you come to, things are not as they were.\r\n\r\n");
            comm.act(ATTypes.AT_SAY, "A strange voice says, 'We await your return, $n...'", ch, null, null, ToTypes.Character);
            comm.act(ATTypes.AT_BYE, "$n has left the game.", ch, null, null, ToTypes.CanSee);
            ch.SetColor(ATTypes.AT_GREY);

            // TODO quitting_char = ch;
            save.save_char_obj(ch);

            if (GameManager.Instance.SystemData.SavePets && ((PlayerInstance)ch).PlayerData.Pet != null)
            {
                comm.act(ATTypes.AT_BYE, "$N follows $S master into the Void.", ch, null, ((PlayerInstance)ch).PlayerData.Pet, ToTypes.Room);
                ((PlayerInstance)ch).PlayerData.Pet.Extract(true);
            }

            //if (ch.PlayerData.Clan != null)
            //   ch.PlayerData.Clan.Save();

            // TODO saving_char = null;

            for (var x = 0; x < GameConstants.MaximumWearLocations; x++)
            {
                for (var y = 0; y < GameConstants.MaximumWearLayers; y++)
                {
                    // TODO Save equipment
                }
            }

            LogManager.Instance.Info(
                $"{ch.Name} has quit (Room {ch.CurrentRoom?.ID ?? -1}).",
                LogTypes.Info, ch.Trust);

            ch.Extract(true);
        }
Ejemplo n.º 8
0
        public static void do_devote(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfNpc(ch, ch, "Huh?"))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, ch.Level < GameConstants.GetSystemValue <int>("MinimumDevotionLevel"),
                                           "You are not yet prepared for such devotion."))
            {
                return;
            }

            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Devote yourself to which deity?"))
            {
                return;
            }

            if (firstArg.EqualsIgnoreCase("none"))
            {
                RemoveDevotion((PlayerInstance)ch);
                return;
            }

            var deity = RepositoryManager.Instance.GetEntity <DeityData>(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, deity, "No such deity holds weight on this world."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNotNullObject(ch, ((PlayerInstance)ch).PlayerData.CurrentDeity,
                                                    "You are already devoted to a deity."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, WillDeityDenyPlayerClass(ch, deity),
                                           "That deity will not accept your worship due to your class."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, WillDeityDenyPlayerGender(ch, deity),
                                           "That deity will not accept worshippers of your gender."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, WillDeityDenyPlayerRace(ch, deity),
                                           "That deity will not accept worshippers of your race."))
            {
                return;
            }

            var pch = (PlayerInstance)ch;

            pch.PlayerData.CurrentDeity = deity;

            if (pch.PlayerData.Favor > deity.AffectedNum)
            {
                pch.AffectedBy.SetBits(deity.Affected);
            }
            if (pch.PlayerData.Favor > deity.ElementNum)
            {
                pch.Resistance.SetBit(deity.Element);
            }
            if (pch.PlayerData.Favor > deity.SusceptNum)
            {
                pch.Susceptibility.SetBit(deity.Suscept);
            }

            comm.act(ATTypes.AT_MAGIC, "Body and soul, you devote yourself to $t!", ch, deity.Name, null, ToTypes.Character);
            deity.Worshippers++;

            // TODO: Save deity worshipper data to database
            // save_deity( ch->pcdata->deity );

            save.save_char_obj(ch);
        }
Ejemplo n.º 9
0
        public static void do_aid(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfTrue(ch, ch.IsNpc() && ch.IsAffected(AffectedByTypes.Charm),
                                           Resources.CANNOT_CONCENTRATE))
            {
                return;
            }

            var arg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, arg, Resources.AID_WHO))
            {
                return;
            }

            var victim = ch.GetCharacterInRoom(arg);

            if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNpc(ch, victim, "Not on mobs."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNotNullObject(ch, ch.CurrentMount, "You can't do that while mounted."))
            {
                return;
            }
            if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "Aid yourself?"))
            {
                return;
            }

            if ((int)victim.CurrentPosition >= (int)PositionTypes.Stunned)
            {
                comm.act(ATTypes.AT_PLAIN, "$N doesn't need your help.", ch, null, victim, ToTypes.Character);
                return;
            }

            if (victim.CurrentHealth <= -6)
            {
                comm.act(ATTypes.AT_PLAIN, "$N's condition is beyond your aiding ability.", ch, null, victim, ToTypes.Character);
                return;
            }

            var percent = SmaugRandom.D100() - ch.GetCurrentLuck() - 13;

            var skill = RepositoryManager.Instance.GetEntity <SkillData>("aid");

            if (skill == null)
            {
                throw new ObjectNotFoundException("Skill 'aid' was not found.");
            }

            Macros.WAIT_STATE(ch, skill.Rounds);
            if (!ch.CanUseSkill(percent, skill))
            {
                ch.SendTo("You fail.");
                skill.LearnFromFailure((PlayerInstance)ch);
                return;
            }

            comm.act(ATTypes.AT_SKILL, "You aid $N!", ch, null, victim, ToTypes.Character);
            comm.act(ATTypes.AT_SKILL, "$n aids $N!", ch, null, victim, ToTypes.Room);
            skill.LearnFromSuccess((PlayerInstance)ch);
            ((PlayerInstance)ch).AdjustFavor(DeityFieldTypes.Aid, 1);

            if (victim.CurrentHealth < 1)
            {
                victim.CurrentHealth = 1;
            }

            victim.UpdatePositionByCurrentHealth();
            comm.act(ATTypes.AT_SKILL, "$n aids you!", ch, null, victim, ToTypes.Victim);
        }
Ejemplo n.º 10
0
        public static void do_drag(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfNpc(ch, ch, "Only characters can drag."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, ch.HasTimer(TimerTypes.PKilled), "You can't drag a player right now."))
            {
                return;
            }

            var pch = (PlayerInstance)ch;

            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(pch, firstArg, "Drag whom?"))
            {
                return;
            }

            var victim = pch.GetCharacterInRoom(firstArg);

            if (CheckFunctions.CheckIfNullObject(pch, victim, "They aren't here."))
            {
                return;
            }
            if (CheckFunctions.CheckIfEquivalent(pch, pch, victim,
                                                 "You take yourself by the scruff of your neck, but go nowhere."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNpc(ch, victim, "You can only drag characters."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch,
                                           !victim.Act.IsSet((int)PlayerFlags.ShoveDrag) || (!victim.IsNpc() && !victim.IsDeadly()),
                                           "That character doesn't seem to appreciate your attentions."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, victim.HasTimer(TimerTypes.PKilled),
                                           "You can't drag that player right now."))
            {
                return;
            }
            if (CheckFunctions.CheckIf(ch, HelperFunctions.IsFighting,
                                       "You try, but can't get close enough.", new List <object> {
                ch
            }))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, !ch.IsNpc() && !victim.IsDeadly() && ch.IsDeadly(),
                                           "You can't drag a deadly character."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, !ch.IsNpc() && !ch.IsDeadly() && (int)ch.CurrentPosition > 3,
                                           "They don't seem to need your assistance."))
            {
                return;
            }

            var secondArg = argument.SecondWord();

            if (CheckFunctions.CheckIfEmptyString(ch, secondArg, "Drag them in which direction?"))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, Math.Abs(ch.Level - victim.Level) > 5,
                                           "There is too great an experience difference for you to even bother."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch,
                                           victim.CurrentRoom.Flags.IsSet(RoomFlags.Safe) && victim.GetTimer(TimerTypes.ShoveDrag) == null,
                                           "That character cannot be dragged right now."))
            {
                return;
            }

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

            if (CheckFunctions.CheckIfNullObject(ch, exit, "There's no exit in that direction."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, !IsPassable(exit, victim), "There's no exit in that direction."))
            {
                return;
            }

            var toRoom = exit.GetDestination();

            if (CheckFunctions.CheckIfSet(ch, toRoom.Flags, RoomFlags.Death,
                                          "You cannot drag someone into a death trap."))
            {
                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 = CalculateChanceToDrag(ch, victim);

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

            if ((int)victim.CurrentPosition < (int)PositionTypes.Standing)
            {
                DragIntoNextRoom(ch, victim, exit);
                return;
            }

            ch.SendTo("You cannot do that to someone who is standing.");
        }
Ejemplo n.º 11
0
        public static void do_bestow(CharacterInstance ch, string argument)
        {
            ch.SetColor(ATTypes.AT_IMMORT);

            var firstArg = argument.FirstWord();

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

            var victim = ch.GetCharacterInWorld(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNpc(ch, victim, "You can't give special abilities to a mob!"))
            {
                return;
            }
            if (CheckFunctions.CheckIfInsufficientTrust(ch, victim, "You aren't powerful enough..."))
            {
                return;
            }

            if (!((PlayerInstance)victim).PlayerData.Bestowments.Any())
            {
                ((PlayerInstance)victim).PlayerData.Bestowments.Clear();
            }

            var secondArg = argument.SecondWord();

            if (string.IsNullOrEmpty(secondArg) || secondArg.EqualsIgnoreCase("show list"))
            {
                ch.SendTo($"Current bestowed commands on {victim.Name}: {string.Join(", ", ((PlayerInstance)victim).PlayerData.Bestowments)}");
                return;
            }

            if (secondArg.EqualsIgnoreCase("none"))
            {
                ((PlayerInstance)victim).PlayerData.Bestowments.Clear();
                ch.SendTo($"Bestowments removed from {victim.Name}");
                victim.SendTo($"{ch.Name} has removed your bestowed commands.");
                handler.check_switch(victim, false);
                return;
            }

            var allArgsExceptFirst = argument.RemoveWord(0).Split(' ');

            if (!allArgsExceptFirst.Any())
            {
                ch.SendTo("Good job, knucklehead... you just bestowed them with that master command called 'NOTHING!'");
                return;
            }

            foreach (var arg in allArgsExceptFirst)
            {
                var command = CommandManager.Instance.FindCommand(arg);
                if (command == null)
                {
                    ch.SendTo($"No such command as {arg}!");
                    continue;
                }

                if (command.Level > ch.Trust)
                {
                    ch.SendTo($"You can't bestow the {arg} command!");
                    continue;
                }

                if (!((PlayerInstance)victim).PlayerData.Bestowments.Any(x => x.EqualsIgnoreCase(arg)))
                {
                    ((PlayerInstance)victim).PlayerData.Bestowments.Add(command.Name);
                    continue;
                }
            }

            victim.SetColor(ATTypes.AT_IMMORT);
            victim.SendTo($"{ch.Name} has bestowed on you the command(s): {string.Join(", ", allArgsExceptFirst)}");
            ch.SendTo("Done.");
        }
Ejemplo n.º 12
0
        public static void do_balzhur(CharacterInstance ch, string argument)
        {
            ch.SetColor(ATTypes.AT_BLOOD);

            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Who is deserving of such a fate?"))
            {
                return;
            }

            var victim = ch.GetCharacterInWorld(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't currently playing."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNpc(ch, victim, "This will do little good on mobiles."))
            {
                return;
            }
            if (CheckFunctions.CheckIf(ch, () => ch.Trust <= victim.Level || ch == victim, "I wouldn't even think of that if I were you..."))
            {
                return;
            }

            victim.Level = 2;
            victim.Trust = 0;
            // TODO check_switch(victim, true)

            ch.SetColor(ATTypes.AT_WHITE);
            ch.SendTo("You summon the demon Balzhur to wreak your wrath!");
            ch.SendTo("Balzhur sneers at you evilly, then vanishes in a puff of smoke");

            victim.SetColor(ATTypes.AT_IMMORT);
            victim.SendTo("You hear an ungodly sound in the distance that makes your blood run cold!");
            victim.SendTo($"Balzhur screams, 'You are MINE {victim.Name}!!!");

            // echo_to_all(AT_IMMORT, ECHOTAR_ALL)

            victim.Experience      = 2000;
            victim.MaximumHealth   = 10;
            victim.MaximumMana     = 100;
            victim.MaximumMovement = 100;
            ((PlayerInstance)victim).PlayerData.ClearLearnedSkills();
            victim.Practice        = 0;
            victim.CurrentHealth   = victim.MaximumHealth;
            victim.CurrentMana     = victim.MaximumMana;
            victim.CurrentMovement = victim.MaximumMovement;

            //snprintf(buf, MAX_STRING_LENGTH, "%s%s", GOD_DIR, capitalize(victim->name));

            ch.SetColor(ATTypes.AT_RED);

            // TODO act_wiz.c lines 3527 to 3556 (writing it out to data file)

            ((PlayerInstance)victim).AdvanceLevel();
            Help.do_help(victim, "M_BALZHUR_");
            victim.SetColor(ATTypes.AT_WHITE);
            victim.SendTo("You awake after a long period of time...");
            if (victim.Carrying.Any())
            {
                //extract_obj(victim.Carrying.First());
            }
        }