Esempio n. 1
0
        public static bool CheckGrip(CharacterInstance ch, CharacterInstance victim, IRepositoryManager dbManager = null)
        {
            if (!victim.IsAwake())
            {
                return(false);
            }

            if (victim.IsNpc() && !victim.Defenses.IsSet((int)DefenseTypes.Grip))
            {
                return(false);
            }

            var skill = (dbManager ?? RepositoryManager.Instance).GetEntity <SkillData>("grip");

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

            int chance;

            if (victim.IsNpc())
            {
                chance = 60.GetLowestOfTwoNumbers(2 * victim.Level);
            }
            else
            {
                chance = (int)Macros.LEARNED(victim, (int)skill.ID) / 2;
            }

            chance += 2 * (victim.GetCurrentLuck() - 13);

            if (SmaugRandom.D100() >= chance + victim.Level - ch.Level)
            {
                skill.LearnFromFailure(victim);
                return(false);
            }

            comm.act(ATTypes.AT_SKILL, "You evade $n's attempt to disarm you.", ch, null, victim, ToTypes.Victim);
            comm.act(ATTypes.AT_SKILL, "$N holds $S weapon strongly, and is not disarmed.", ch, null, victim, ToTypes.Character);
            skill.LearnFromSuccess(victim);
            return(true);
        }
Esempio n. 2
0
 public static bool chance_attrib(CharacterInstance ch, short percent, short attrib)
 {
     return(SmaugRandom.D100() - ch.GetCurrentLuck() + 13 - attrib + 13 +
            (ch.IsDevoted() ? ((PlayerInstance)ch).PlayerData.Favor / -500 : 0) <= percent);
 }
Esempio n. 3
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);
        }