Ejemplo n.º 1
0
        private static void EnterExit(CharacterInstance ch)
        {
            var exit = ch.CurrentRoom.Exits.FirstOrDefault(x => x.Flags.IsSet(ExitFlags.xEnter));

            if (exit != null)
            {
                Move.move_char(ch, exit, 0);
                return;
            }

            if (ch.CurrentRoom.SectorType != SectorTypes.Inside && ch.IsOutside())
            {
                foreach (var xit in ch.CurrentRoom.Exits)
                {
                    var room = xit.GetDestination(RepositoryManager.Instance);
                    if (room == null ||
                        (room.SectorType != SectorTypes.Inside && !room.Flags.IsSet(RoomFlags.Indoors)))
                    {
                        continue;
                    }

                    Move.move_char(ch, xit, 0);
                    return;
                }
            }

            ch.SendTo("You cannot find an entrance here.");
        }
Ejemplo n.º 2
0
        public static void do_enter(CharacterInstance ch, string argument)
        {
            if (string.IsNullOrEmpty(argument))
            {
                EnterExit(ch);
                return;
            }

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

            if (exit != null && exit.Flags.IsSet(ExitFlags.xEnter))
            {
                Move.move_char(ch, exit, 0);
                return;
            }

            ch.SendTo("You cannot enter that.");
        }
Ejemplo n.º 3
0
        private static void DragIntoNextRoom(CharacterInstance ch, CharacterInstance victim, ExitData exit)
        {
            var temp = victim.CurrentPosition;

            victim.CurrentPosition = PositionTypes.Drag;

            comm.act(ATTypes.AT_ACTION, "You drag $M into the next room.", ch, victim, null, ToTypes.Character);
            comm.act(ATTypes.AT_ACTION, "$n grabs your hair and drags you.", ch, victim, null, ToTypes.Victim);
            Move.move_char(victim, exit, 0);

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

            Move.move_char(ch, exit, 0);
            Macros.WAIT_STATE(ch, 12);
        }
Ejemplo n.º 4
0
        public static void do_leave(CharacterInstance ch, string argument)
        {
            if (string.IsNullOrEmpty(argument))
            {
                LeaveRoom(ch);
                return;
            }

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

            if (exit != null && exit.Flags.IsSet(ExitFlags.xLeave))
            {
                Move.move_char(ch, exit, 0);
                return;
            }

            ch.SendTo("You cannot leave that way.");
        }
Ejemplo n.º 5
0
        public static void do_climb(CharacterInstance ch, string argument)
        {
            if (string.IsNullOrEmpty(argument))
            {
                foreach (var ext in ch.CurrentRoom.Exits.Where(ext => ext.Flags.IsSet(ExitFlags.xClimb)))
                {
                    Move.move_char(ch, ext, 0);
                    return;
                }

                ch.SendTo("You cannot climb here.");
                return;
            }

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

            if (exit != null && exit.Flags.IsSet(ExitFlags.xClimb))
            {
                Move.move_char(ch, exit, 0);
                return;
            }

            ch.SendTo("You cannot climb there.");
        }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
0
        private static bool MakeFleeAttempt(CharacterInstance ch, RoomTemplate wasIn)
        {
            var door = db.number_door();
            var exit = wasIn.GetExit(door);

            if (exit?.GetDestination() == null || exit.Flags.IsSet(ExitFlags.NoFlee) || exit.Flags.IsSet(ExitFlags.Closed) || !ch.IsAffected(AffectedByTypes.PassDoor) || (ch.IsNpc() && exit.GetDestination().Flags.IsSet(RoomFlags.NoMob)))
            {
                return(false);
            }

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

            if (sneak == null)
            {
                return(false);
            }

            ch.StripAffects((int)sneak.ID);
            ch.AffectedBy.RemoveBit((int)AffectedByTypes.Sneak);

            if (ch.CurrentMount?.CurrentFighting != null)
            {
                ch.CurrentMount.StopFighting(true);
            }
            Move.move_char(ch, exit, 0);

            var nowIn = ch.CurrentRoom;

            if (nowIn == wasIn)
            {
                return(false);
            }

            ch.CurrentRoom = wasIn;
            comm.act(ATTypes.AT_FLEE, "$n flees head over heels!", ch, null, null, ToTypes.Room);

            ch.CurrentRoom = nowIn;
            comm.act(ATTypes.AT_FLEE, "$n glances around for signs of pursuit.", ch, null, null, ToTypes.Room);

            if (!ch.IsNpc())
            {
                var wf  = ch.GetMyTarget();
                var pch = (PlayerInstance)ch;

                comm.act(ATTypes.AT_FLEE, "You flee head over heels from combat!", pch, null, null, ToTypes.Character);

                if (pch.Level < LevelConstants.AvatarLevel)
                {
                    LoseExperience(pch);
                }

                if (wf != null)
                {
                    if (pch.PlayerData.CurrentDeity != null)
                    {
                        var ratio = 1.GetNumberThatIsBetween(wf.Level / pch.Level, LevelConstants.MaxLevel);
                        if (wf.CurrentRace == pch.PlayerData.CurrentDeity.NPCRace)
                        {
                            pch.AdjustFavor(DeityFieldTypes.FleeNPCRace, ratio);
                        }
                        else if (wf.CurrentRace == pch.PlayerData.CurrentDeity.NPCFoe)
                        {
                            pch.AdjustFavor(DeityFieldTypes.FleeNPCFoe, ratio);
                        }
                        else
                        {
                            pch.AdjustFavor(DeityFieldTypes.Flee, ratio);
                        }
                    }
                }
            }

            ch.StopFighting(true);
            return(true);
        }