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);
            }
        }
Exemple #2
0
        public static bool CheckAbility(CharacterInstance ch, string command, string argument,
                                        IRepositoryManager databaseManager = null)
        {
            var sn = ch.GetIDOfSkillCharacterKnows(command);

            if (sn == -1)
            {
                return(false);
            }

            var skill = (databaseManager ?? RepositoryManager.Instance).GetEntity <SkillData>(sn);

            if (skill.SkillFunction == null || skill.SpellFunction == null ||
                ch.CanUseSkill(0, sn))
            {
                return(false);
            }

            if (!interp.check_pos(ch, skill.MinimumPosition))
            {
                return(true);
            }

            if (CheckFunctions.CheckIf(ch, HelperFunctions.IsCharmedOrPossessed,
                                       "For some reason, you seem unable to perform that...",
                                       new List <object> {
                ch
            }))
            {
                comm.act(ATTypes.AT_GREY, "$n wanders around aimlessly.", ch, null, null, ToTypes.Room);
                return(true);
            }

            //// Check if mana is required
            int mana = 0, blood = 0;

            if (skill.MinimumMana > 0)
            {
                mana = ch.IsNpc() ? 0 : skill.MinimumMana
                       .GetHighestOfTwoNumbers(100 / (2 + ch.Level - skill.RaceLevel.ToList()[(int)ch.CurrentRace]));

                if (CheckFunctions.CheckIf(ch, HelperFunctions.HasSufficientBloodPower,
                                           "You don't have enough blood power.",
                                           new List <object> {
                    ch, blood
                }))
                {
                    return(true);
                }

                if (CheckFunctions.CheckIf(ch, HelperFunctions.HasSufficientMana, "You don't have enough mana.",
                                           new List <object> {
                    ch, mana
                }))
                {
                    return(true);
                }
            }

            DateTime start, end;

            //// Is this a real d-fun or just a spell?
            if (skill.SkillFunction == null)
            {
                CharacterInstance victim = null;
                ObjectInstance    obj    = null;
                var    targetName        = string.Empty;
                object vo;

                switch (skill.Target)
                {
                default:
                    LogManager.Instance.Bug("Bad target to Skill {0}", sn);
                    ch.SendTo("Something went wrong...");
                    return(true);

                case TargetTypes.Ignore:
                    vo         = null;
                    victim     = ch.GetMyTarget();
                    targetName = argument.IsNullOrEmpty() && victim != null ? victim.Name : argument;
                    break;

                case TargetTypes.OffensiveCharacter:
                    victim = ch.GetMyTarget();

                    if (argument.IsNullOrEmpty() && victim == null)
                    {
                        ch.Printf("Confusion overcomes you as your '%s' has no target.\r\n", skill.Name);
                        return(true);
                    }

                    victim = ch.GetCharacterInRoom(argument);
                    if (CheckFunctions.CheckIfTrue(ch, !argument.IsNullOrEmpty() && victim == null,
                                                   "They aren't here."))
                    {
                        return(true);
                    }

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

                    if (CheckFunctions.CheckIfTrue(ch, ch == victim && skill.Flags.IsSet(SkillFlags.NoSelf),
                                                   "You can't target yourself!"))
                    {
                        return(true);
                    }

                    if (!ch.IsNpc())
                    {
                        if (!victim.IsNpc())
                        {
                            if (CheckFunctions.CheckIfNotNullObject(ch, ch.GetTimer(TimerTypes.PKilled),
                                                                    "You have been killed in the last five minutes."))
                            {
                                return(true);
                            }
                            if (CheckFunctions.CheckIfNotNullObject(ch, victim.GetTimer(TimerTypes.PKilled),
                                                                    "This player has been killed in the last five minutes."))
                            {
                                return(true);
                            }
                            if (CheckFunctions.CheckIfEquivalent(ch, ch, victim,
                                                                 "You really shouldn't do this to another player..."))
                            {
                                return(true);
                            }
                        }

                        if (CheckFunctions.CheckIfTrue(ch,
                                                       ch.IsAffected(AffectedByTypes.Charm) && ch.Master == victim,
                                                       "You can't do that on your own follower."))
                        {
                            return(true);
                        }
                    }

                    if (CheckFunctions.CheckIfTrue(ch, fight.check_illegal_pk(ch, victim),
                                                   "You can't do that to another player!"))
                    {
                        return(true);
                    }

                    vo = victim;
                    break;

                case TargetTypes.DefensiveCharacter:
                    victim = ch.GetCharacterInRoom(argument);
                    if (CheckFunctions.CheckIfTrue(ch, !argument.IsNullOrEmpty() && victim == null,
                                                   "They aren't here."))
                    {
                        return(true);
                    }

                    if (CheckFunctions.CheckIfTrue(ch, ch == victim && skill.Flags.IsSet(SkillFlags.NoSelf),
                                                   "You can't target yourself!"))
                    {
                        return(true);
                    }

                    vo = victim;
                    break;

                case TargetTypes.Self:
                    victim = ch;
                    vo     = ch;
                    break;

                case TargetTypes.InventoryObject:
                    obj = ch.GetCarriedObject(argument);
                    if (CheckFunctions.CheckIfNullObject(ch, obj, "You can't find that."))
                    {
                        return(true);
                    }

                    vo = obj;
                    break;
                }

                Macros.WAIT_STATE(ch, skill.Rounds);

                //// Check for failure
                if (SmaugRandom.D100() + skill.difficulty * 5 > (ch.IsNpc() ? 75 : Macros.LEARNED(ch, (int)skill.ID)))
                {
                    ch.FailedCast(skill, victim, obj);
                    skill.LearnFromFailure((PlayerInstance)ch);
                    if (mana > 0)
                    {
                        if (ch.IsVampire())
                        {
                            ((PlayerInstance)ch).GainCondition(ConditionTypes.Bloodthirsty, -blood / 2);
                        }
                        else
                        {
                            ch.CurrentMana -= mana / 2;
                        }
                    }
                    return(true);
                }
                if (mana > 0)
                {
                    if (ch.IsVampire())
                    {
                        ((PlayerInstance)ch).GainCondition(ConditionTypes.Bloodthirsty, -blood);
                    }
                    else
                    {
                        ch.CurrentMana -= mana;
                    }
                }

                start = DateTime.Now;
                var retcode = skill.SpellFunction.Value.Invoke((int)skill.ID, ch.Level, ch, vo);
                end = DateTime.Now;
                skill.UseHistory.Use(ch, end.Subtract(start));

                if (retcode == ReturnTypes.CharacterDied || retcode == ReturnTypes.Error || ch.CharDied())
                {
                    return(true);
                }

                if (retcode == ReturnTypes.SpellFailed)
                {
                    skill.LearnFromFailure((PlayerInstance)ch);
                    retcode = ReturnTypes.None;
                }
                else
                {
                    skill.AbilityLearnFromSuccess((PlayerInstance)ch);
                }

                if (skill.Target == TargetTypes.OffensiveCharacter &&
                    victim != ch &&
                    !victim.CharDied())
                {
                    if (ch.CurrentRoom.Persons.Any(vch => victim == vch && victim.CurrentFighting == null && victim.Master != ch))
                    {
                        retcode = fight.multi_hit(victim, ch, Program.TYPE_UNDEFINED);
                    }
                }

                return(true);
            }

            if (mana > 0)
            {
                if (ch.IsVampire())
                {
                    ((PlayerInstance)ch).GainCondition(ConditionTypes.Bloodthirsty, -blood);
                }
                else
                {
                    ch.CurrentMana -= mana;
                }
            }

            ch.LastCommand = skill.SkillFunction;
            start          = DateTime.Now;
            skill.SkillFunction.Value.Invoke(ch, argument);
            end = DateTime.Now;
            skill.UseHistory.Use(ch, end.Subtract(start));

            // TODO: Tail chain?

            return(true);
        }
        public void CheckIfNotNullObject()
        {
            var actor = new CharacterInstance(1, "TestNpc");

            Assert.That(CheckFunctions.CheckIfNotNullObject(actor, new object(), string.Empty), Is.True);
        }
Exemple #4
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();
            }
        }
Exemple #5
0
        public static ReturnTypes move_char(CharacterInstance ch, ExitData pexit, int fall)
        {
            var    drunk    = false;
            var    nuisance = false;
            string txt;

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

                if (ch.IsDrunk(2) && ch.CurrentPosition != PositionTypes.Shove &&
                    ch.CurrentPosition != PositionTypes.Drag)
                {
                    drunk = true;
                }

                if (pch.PlayerData.Nuisance != null && pch.PlayerData.Nuisance.Flags > 8 &&
                    ch.CurrentPosition != PositionTypes.Shove &&
                    ch.CurrentPosition != PositionTypes.Drag &&
                    SmaugRandom.D100() > pch.PlayerData.Nuisance.Flags * pch.PlayerData.Nuisance.Power)
                {
                    nuisance = true;
                }
            }

            int      door;
            ExitData exit = null;

            // Nuisance flag, makes them walk in random directions 50% of the time
            if ((nuisance || drunk) && fall == 0)
            {
                door = db.number_door();
                exit = ch.CurrentRoom.GetExit(door);
            }

#if DEBUG
            if (exit != null)
            {
                LogManager.Instance.Info("{0} to door {1}", ch.Name, pexit.Direction);
            }
#endif

            if (ch.IsNpc() && ch.Act.IsSet((int)ActFlags.Mounted))
            {
                return(ReturnTypes.None);
            }

            var          inRoom   = ch.CurrentRoom;
            var          fromRoom = inRoom;
            RoomTemplate toRoom   = null;

            if (exit?.Destination == null)
            {
                if (drunk && ch.CurrentPosition != PositionTypes.Mounted &&
                    ch.CurrentRoom.SectorType != SectorTypes.ShallowWater &&
                    ch.CurrentRoom.SectorType != SectorTypes.DeepWater &&
                    ch.CurrentRoom.SectorType != SectorTypes.Underwater &&
                    ch.CurrentRoom.SectorType != SectorTypes.OceanFloor)
                {
                    switch (SmaugRandom.Bits(4))
                    {
                    default:
                        comm.act(ATTypes.AT_ACTION, "You drunkenly stumble into some obstacle.", ch, null, null, ToTypes.Character);
                        comm.act(ATTypes.AT_ACTION, "$n drunkenly stumbles into a nearby obstacle.", ch, null, null, ToTypes.Room);
                        break;

                    case 3:
                        comm.act(ATTypes.AT_ACTION, "In your drunken stupor you trip over your own feet and tumble to the ground.", ch, null, null, ToTypes.Character);
                        comm.act(ATTypes.AT_ACTION, "$n stumbles drunkenly, trips and tumbles to the ground.", ch, null, null, ToTypes.Room);
                        ch.CurrentPosition = PositionTypes.Resting;
                        break;

                    case 4:
                        comm.act(ATTypes.AT_SOCIAL, "You utter a string of slurred obscenities.", ch, null, null, ToTypes.Character);
                        comm.act(ATTypes.AT_ACTION, "Something blurry and immovable has intercepted you as you stagger along.", ch, null, null, ToTypes.Character);
                        comm.act(ATTypes.AT_HURT, "Oh geez... THAT really hurt.  Everything slowly goes dark and numb...", ch, null, null, ToTypes.Character);
                        comm.act(ATTypes.AT_ACTION, "$n drunkenly staggers into something.", ch, null, null, ToTypes.Room);
                        comm.act(ATTypes.AT_SOCIAL, "$n utters a string of slurred obscenities: @*&^%@*&!", ch, null, null, ToTypes.Room);
                        comm.act(ATTypes.AT_ACTION, "$n topples to the ground with a thud.", ch, null, null, ToTypes.Room);
                        ch.CurrentPosition = PositionTypes.Incapacitated;
                        break;
                    }
                }
                else if (nuisance)
                {
                    comm.act(ATTypes.AT_ACTION, "You stare around trying to remember where you where going.", ch, null, null, ToTypes.Character);
                }
                else if (drunk)
                {
                    comm.act(ATTypes.AT_ACTION, "You stare around trying to make sense of things through your drunken stupor.", ch, null, null, ToTypes.Character);
                }
                else
                {
                    ch.SendTo("Alas, you cannot go that way.\r\n");
                }
                return(ReturnTypes.None);
            }

            door = (int)exit.Direction;
            var distance = exit.Distance;

            // Exit is only a "window", there is no way to travel in that direction unless it's a door with a window in it
            if (CheckFunctions.CheckIfTrue(ch, exit.Flags.IsSet(ExitFlags.Window) && !exit.Flags.IsSet(ExitFlags.IsDoor),
                                           "Alas, you cannot go that way."))
            {
                return(ReturnTypes.None);
            }

            if (ch.IsNpc())
            {
                if (exit.Flags.IsSet(ExitFlags.Portal))
                {
                    comm.act(ATTypes.AT_PLAIN, "Mobs can't use portals.", ch, null, null, ToTypes.Character);
                    return(ReturnTypes.None);
                }

                if (exit.Flags.IsSet(ExitFlags.NoMob) || toRoom.Flags.IsSet(RoomFlags.NoMob))
                {
                    comm.act(ATTypes.AT_PLAIN, "Mobs can't enter there.", ch, null, null, ToTypes.Character);
                    return(ReturnTypes.None);
                }
            }

            if (exit.Flags.IsSet(ExitFlags.Closed) && (!ch.IsAffected(AffectedByTypes.PassDoor) || exit.Flags.IsSet(ExitFlags.NoPassDoor)))
            {
                if (!exit.Flags.IsSet(ExitFlags.Secret) && !exit.Flags.IsSet(ExitFlags.Dig))
                {
                    if (drunk)
                    {
                        comm.act(ATTypes.AT_PLAIN, "$n runs into the $d in $s drunken state.", ch, null, null,
                                 ToTypes.Room);
                        comm.act(ATTypes.AT_PLAIN, "You run into the $d in your drunken state.", ch, null, null,
                                 ToTypes.Character);
                    }
                    else
                    {
                        comm.act(ATTypes.AT_PLAIN, "The $d is closed.", ch, null, exit.Keywords,
                                 ToTypes.Character);
                    }
                }
                else
                {
                    ch.SendTo(drunk
                        ? "You stagger around in your drunken state.\r\n"
                        : "Alas, you cannot go that way.\r\n");
                }

                return(ReturnTypes.None);
            }

            // Crazy virtual room idea, created upon demand.
            if (distance > 1)
            {
                toRoom = act_move.generate_exit(inRoom, exit);
                if (toRoom == null)
                {
                    ch.SendTo("Alas, you cannot go that way.");
                }
            }

            if (CheckFunctions.CheckIfTrue(ch, fall == 0 && ch.IsAffected(AffectedByTypes.Charm) &&
                                           ch.Master != null && inRoom == ch.Master.CurrentRoom, "What?  And leave your beloved master?"))
            {
                return(ReturnTypes.None);
            }

            if (CheckFunctions.CheckIfTrue(ch, toRoom.IsPrivate(), "That room is private right now."))
            {
                return(ReturnTypes.None);
            }

            if (CheckFunctions.CheckIfNotNullObject(ch, toRoom.IsDoNotDisturb(ch),
                                                    "That room is \"do not disturb\" right now."))
            {
                return(ReturnTypes.None);
            }

            if (!ch.IsImmortal() && !ch.IsNpc() &&
                ch.CurrentRoom.Area != toRoom.Area)
            {
                if (ch.Level < toRoom.Area.LowHardRange)
                {
                    ch.SetColor(ATTypes.AT_TELL);
                    switch (toRoom.Area.LowHardRange - ch.Level)
                    {
                    case 1:
                        ch.SendTo("A voice in your mind says, 'You are nearly ready to go that way...'");
                        break;

                    case 2:
                        ch.SendTo("A voice in your mind says, 'Soon you shall be ready to travel down this path... soon.'");
                        break;

                    case 3:
                        ch.SendTo("A voice in your mind says, 'You are not ready to go down that path... yet.'");
                        break;

                    default:
                        ch.SendTo("A voice in your mind says, 'You are not ready to go down that path.'");
                        break;
                    }

                    return(ReturnTypes.None);
                }
                if (ch.Level > toRoom.Area.HighHardRange)
                {
                    ch.SetColor(ATTypes.AT_TELL);
                    ch.SendTo("A voice in your mind says, 'There is nothing more for you down that path.'");
                    return(ReturnTypes.None);
                }
            }

            if (fall == 0 && !ch.IsNpc())
            {
                int move;

                // Prevent deadlies from entering a nopkill-flagged area from a non-flagged area,
                // but allow them to move around if already inside a nopkill area.
                if (toRoom.Area.Flags.IsSet(AreaFlags.NoPlayerVsPlayer) && !ch.CurrentRoom.Area.Flags.IsSet(AreaFlags.NoPlayerVsPlayer) &&
                    ch.IsPKill() && !ch.IsImmortal())
                {
                    ch.SetColor(ATTypes.AT_MAGIC);
                    ch.SendTo("\r\nA godly force forbids deadly characters from entering that area...");
                    return(ReturnTypes.None);
                }

                if (inRoom.SectorType == SectorTypes.Air ||
                    toRoom.SectorType == SectorTypes.Air ||
                    exit.Flags.IsSet(ExitFlags.Fly))
                {
                    if (CheckFunctions.CheckIfTrue(ch,
                                                   ch.CurrentMount != null && !ch.CurrentMount.IsAffected(AffectedByTypes.Flying),
                                                   "Your mount can't fly."))
                    {
                        return(ReturnTypes.None);
                    }
                    if (CheckFunctions.CheckIfTrue(ch, ch.CurrentMount == null && !ch.IsAffected(AffectedByTypes.Flying),
                                                   "You'd need to fly to go there."))
                    {
                        return(ReturnTypes.None);
                    }
                }

                if (inRoom.SectorType == SectorTypes.DeepWater || toRoom.SectorType == SectorTypes.DeepWater)
                {
                    if ((ch.CurrentMount != null && !ch.CurrentMount.IsFloating()) || !ch.IsFloating())
                    {
                        // Look for a boat. We can use the boat obj for a more detailed description.
                        var boat = ch.GetObjectOfType(ItemTypes.Boat);
                        if (CheckFunctions.CheckIfNullObject(ch, boat,
                                                             ch.CurrentMount != null ? "Your mount would drown!" : "You'd need a boat to go there."))
                        {
                            return(ReturnTypes.None);
                        }

                        txt = drunk ? "paddles unevenly" : "paddles";
                    }
                }

                if (exit.Flags.IsSet(ExitFlags.Climb))
                {
                    var found = false;
                    if (ch.CurrentMount != null && ch.CurrentMount.IsAffected(AffectedByTypes.Flying))
                    {
                        found = true;
                    }
                    else if (ch.IsAffected(AffectedByTypes.Flying))
                    {
                        found = true;
                    }

                    if (!found && ch.CurrentMount == null)
                    {
                        // TODO Climbing
                    }

                    if (CheckFunctions.CheckIfTrue(ch, !found, "You can't climb."))
                    {
                        return(ReturnTypes.None);
                    }
                }

                if (ch.CurrentMount != null)
                {
                    if (PositionMoveMessage.ContainsKey(ch.CurrentMount.CurrentPosition))
                    {
                        ch.SendTo(PositionMoveMessage[ch.CurrentMount.CurrentPosition]);
                        return(ReturnTypes.None);
                    }

                    if (!ch.CurrentMount.IsFloating())
                    {
                    }    // TODO
                }
            }

            return(ReturnTypes.None);
        }
Exemple #6
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);
        }
Exemple #7
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);
        }