예제 #1
0
        public bool OnCommand(Character chr, string args)
        {
            if (chr is PC && chr.CommandWeight > 3)
            {
                return(true);
            }

            if (chr.CommandsProcessed.Contains(CommandTasker.CommandType.Movement))
            {
                if (chr is PC && !chr.HasEffect(Effect.EffectTypes.Speed))
                {
                    chr.WriteToDisplay("You do not have the ability to move and attack in the same round.");
                    return(true);
                }
                else if (chr is NPC && (chr as NPC).Speed <= 3 && !chr.HasEffect(Effect.EffectTypes.Speed))
                {
                    chr.WriteToDisplay("You do not have the ability to move and attack in the same round.");
                    return(true);
                }
            }

            if (string.IsNullOrEmpty(args))
            {
                chr.WriteToDisplay("Fight what?");
                return(true);
            }

            chr.CommandType = CommandTasker.CommandType.Attack;

            Item weapon = chr.RightHand;

            string[] sArgs = args.Split(" ".ToCharArray());

            Character target = null;

            // If hands are empty and gauntlets are worn, gauntlets become the weapon used for calculations.
            if (weapon == null)
            {
                weapon = chr.GetInventoryItem(Globals.eWearLocation.Hands);
            }

            if (sArgs.Length == 2)
            {
                if (int.TryParse(sArgs[0], out int countTo))
                {
                    target = TargetAcquisition.FindTargetInView(chr, sArgs[1].ToLower(), countTo);
                }
                else
                {
                    target = TargetAcquisition.FindTargetInCell(chr, sArgs[0].ToLower());
                }
            }
            else
            {
                target = TargetAcquisition.FindTargetInCell(chr, sArgs[0].ToLower());
            }

            if (target == null)
            {
                if (EntityLists.EntityListContains(EntityLists.LONGARMED, chr.entity))
                {
                    target = TargetAcquisition.FindTargetInNextCells(chr, sArgs[0].ToLower());
                }

                if (target == null)
                {
                    chr.WriteToDisplay(GameSystems.Text.TextManager.NullTargetMessage(sArgs[0]));
                    return(true);
                }
            }

            if (weapon != null)
            {
                if (weapon.skillType == Globals.eSkillType.Bow) // check if a bow is nocked
                {
                    chr.WriteToDisplay("You must nock a bow before shooting it.");
                    return(true);
                }

                if (weapon.IsAttunedToOther(chr)) // check if a weapon is attuned
                {
                    chr.CurrentCell.Add(weapon);
                    chr.WriteToDisplay("The " + weapon.name + " leaps from your hand!");
                    chr.UnequipRightHand(weapon);
                    return(true);
                }

                if (!weapon.AlignmentCheck(chr)) // check if a weapon has an alignment
                {
                    chr.CurrentCell.Add(weapon);
                    chr.WriteToDisplay("The " + weapon.name + " singes your hand and falls to the ground!");
                    if (weapon.wearLocation == Globals.eWearLocation.Hands)
                    {
                        chr.RemoveWornItem(weapon);
                    }
                    else
                    {
                        chr.UnequipRightHand(weapon);
                    }
                    Combat.DoDamage(chr, chr, Rules.RollD(1, 4), false);
                    return(true);
                }
            }

            // Do combat.
            Combat.DoCombat(chr, target, weapon);

            // Check double attack.
            Combat.CheckDoubleAttack(chr, target, weapon);

            // Hummingbird special attribute is an extra attack.
            Combat.CheckSpecialWeaponAttack(chr, target, weapon);

            // Check dual wield. Double attack is checked again for dual wielded weapon. Dual wielded hummingbird longsword is also checked here.
            Combat.CheckDualWield(chr, target, chr.LeftHand);

            return(true);
        }
예제 #2
0
        public bool OnCast(Character caster, string args)
        {
            Character target = ReferenceSpell.FindAndConfirmSpellTarget(caster, args);

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

            int modifier = 0;

            if (caster.IsWisdomCaster)
            {
                modifier = Rules.GetFullAbilityStat(caster, Globals.eAbilityStat.Wisdom) - Rules.GetFullAbilityStat(target, Globals.eAbilityStat.Dexterity);
            }
            else
            {
                modifier = Rules.GetFullAbilityStat(caster, Globals.eAbilityStat.Intelligence) - Rules.GetFullAbilityStat(target, Globals.eAbilityStat.Dexterity);
            }

            ReferenceSpell.SendGenericCastMessage(caster, target, true);

            if (EntityLists.PLANT.Contains(target.entity) || EntityLists.INCORPOREAL.Contains(target.entity) || EntityLists.IsPhysicallyMassive(target))
            {
                ReferenceSpell.SendGenericUnaffectedMessage(caster, target);
            }
            else if (Combat.DND_CheckSavingThrow(target, Combat.SavingThrow.PetrificationPolymorph, modifier)) // makes saving throw
            {
                ReferenceSpell.SendGenericResistMessages(caster, target);
                target.EmitSound(ReferenceSpell.SoundFile);
            }
            else
            {
                ReferenceSpell.SendGenericStrickenMessage(caster, target);
                Effect.CreateCharacterEffect(Effect.EffectTypes.Ensnare, Skills.GetSkillLevel(caster.magic), target, Rules.RollD(2, 4) + 2, caster);
            }
            return(true);
        }