예제 #1
0
        public static int CanCarryN(this CharacterInstance ch)
        {
            var penalty = 0;

            if (!ch.IsNpc() && ch.Level >= LevelConstants.ImmortalLevel)
            {
                return(ch.Trust * 200);
            }
            if (ch.IsNpc() && ch.Act.IsSet((int)ActFlags.Immortal))
            {
                return(ch.Level * 200);
            }
            if (ch.GetEquippedItem(WearLocations.Wield) != null)
            {
                ++penalty;
            }
            if (ch.GetEquippedItem(WearLocations.DualWield) != null)
            {
                ++penalty;
            }
            if (ch.GetEquippedItem(WearLocations.WieldMissile) != null)
            {
                ++penalty;
            }
            if (ch.GetEquippedItem(WearLocations.Hold) != null)
            {
                ++penalty;
            }
            if (ch.GetEquippedItem(WearLocations.Shield) != null)
            {
                ++penalty;
            }
            return(((ch.Level + 15) / 5 + ch.GetCurrentDexterity() - 13 - penalty).GetNumberThatIsBetween(5, 20));
        }
예제 #2
0
        public static void do_brandish(CharacterInstance ch, string argument)
        {
            var obj = ch.GetEquippedItem(WearLocations.Hold);

            if (CheckFunctions.CheckIfNullObject(ch, obj, "You hold nothing in your hand."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, obj.ItemType != ItemTypes.Staff, "You can brandish only with a staff."))
            {
                return;
            }

            if (obj.Value.ToList()[3] <= 0)
            {
                throw new InvalidDataException($"Object {obj.ID} has no skill ID assigned to Value[3]");
            }

            Macros.WAIT_STATE(ch, 2 * GameConstants.GetSystemValue <int>("PulseViolence"));

            if (obj.Value.ToList()[2] > 0)
            {
                BrandishStaff(ch, obj);
            }

            if (--obj.Value.ToList()[2] <= 0)
            {
                comm.act(ATTypes.AT_MAGIC, "$p blazes bright and vanishes from $n's hands!", ch, obj, null, ToTypes.Room);
                comm.act(ATTypes.AT_MAGIC, "$p blazes bright and is gone!", ch, obj, null, ToTypes.Character);
                obj.Extract();
            }
        }
예제 #3
0
        public static bool CheckParry(CharacterInstance ch, CharacterInstance victim, IRepositoryManager dbManager = null,
                                      IGameManager gameManager = null)
        {
            if (!victim.IsAwake())
            {
                return(false);
            }

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

            int chances;

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

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

            if (victim.IsNpc())
            {
                chances = 60.GetLowestOfTwoNumbers(2 * victim.Level);
            }
            else
            {
                if (victim.GetEquippedItem(WearLocations.Wield) == null)
                {
                    return(false);
                }
                chances = (int)Macros.LEARNED(victim, (int)skill.ID) /
                          (gameManager ?? GameManager.Instance).SystemData.ParryMod;
            }

            if (chances != 0 && victim.CurrentMorph != null)
            {
                chances += victim.CurrentMorph.Morph.ParryChances;
            }

            if (!victim.Chance(chances + victim.Level - ch.Level))
            {
                skill.LearnFromFailure(victim);
                return(false);
            }

            if (!victim.IsNpc() && !((PlayerInstance)victim).PlayerData.Flags.IsSet(PCFlags.Gag))
            {
                comm.act(ATTypes.AT_SKILL, "You parry $n's attack.", ch, null, victim, ToTypes.Victim);
            }

            if (!ch.IsNpc() && !((PlayerInstance)ch).PlayerData.Flags.IsSet(PCFlags.Gag))
            {
                comm.act(ATTypes.AT_SKILL, "$N parries your attack.", ch, null, victim, ToTypes.Character);
            }

            skill.LearnFromSuccess(victim);
            return(true);
        }
예제 #4
0
        public static bool RemoveFrom(this CharacterInstance ch, WearLocations location, bool replace)
        {
            var obj = ch.GetEquippedItem(location);

            if (obj == null)
            {
                return(true);
            }

            if (!replace && ch.CarryNumber + obj.ObjectNumber > ch.CanCarryN())
            {
                comm.act(ATTypes.AT_PLAIN, "$d: you can't carry that many items.", ch, null, obj.ShortDescription,
                         ToTypes.Character);
                return(false);
            }

            if (!replace)
            {
                return(false);
            }

            if (obj.ExtraFlags.IsSet((int)ItemExtraFlags.NoRemove))
            {
                comm.act(ATTypes.AT_PLAIN, "You can't remove $p.", ch, obj, null, ToTypes.Character);
                return(false);
            }

            var tObj = ch.GetEquippedItem(WearLocations.DualWield);

            if (obj == ch.GetEquippedItem(WearLocations.Wield) && tObj != null)
            {
                tObj.WearLocation = WearLocations.Wield;
            }

            ch.Unequip(obj);

            comm.act(ATTypes.AT_ACTION, "$n stop using $p.", ch, obj, null, ToTypes.Room);
            comm.act(ATTypes.AT_ACTION, "You stop using $p.", ch, obj, null, ToTypes.Character);
            MudProgHandler.ExecuteObjectProg(MudProgTypes.Remove, ch, obj);

            return(ch.GetEquippedItem(location) == null);
        }
예제 #5
0
        private static void ItemWearHold(ObjectInstance obj, CharacterInstance ch, bool replace)
        {
            if (ch.GetEquippedItem(WearLocations.DualWield) != null ||
                (ch.GetEquippedItem(WearLocations.Wield) != null &&
                 (ch.GetEquippedItem(WearLocations.WieldMissile) != null ||
                  ch.GetEquippedItem(WearLocations.Shield) != null)))
            {
                ch.SendTo(
                    ch.GetEquippedItem(WearLocations.Shield) != null
                        ? "You cannot hold something while using a weapon and a shield!"
                        : "You cannot hold something AND two weapons!");
                return;
            }

            if (!ch.RemoveFrom(WearLocations.Hold, replace))
            {
                return;
            }

            if (obj.ItemType == ItemTypes.Wand ||
                obj.ItemType == ItemTypes.Staff ||
                obj.ItemType == ItemTypes.Food ||
                obj.ItemType == ItemTypes.Cook ||
                obj.ItemType == ItemTypes.Pill ||
                obj.ItemType == ItemTypes.Potion ||
                obj.ItemType == ItemTypes.Scroll ||
                obj.ItemType == ItemTypes.DrinkContainer ||
                obj.ItemType == ItemTypes.Blood ||
                obj.ItemType == ItemTypes.Pipe ||
                obj.ItemType == ItemTypes.Herb ||
                obj.ItemType == ItemTypes.Key ||
                !MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
            {
                comm.act(ATTypes.AT_ACTION, "$n holds $p in $s hands.", ch, obj, null, ToTypes.Room);
                comm.act(ATTypes.AT_ACTION, "You hold $p in your hands.", ch, obj, null, ToTypes.Character);
            }

            ch.Equip(obj, WearLocations.Hold);
            MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
        }
예제 #6
0
        private static void ItemWearShield(ObjectInstance obj, CharacterInstance ch, bool replace)
        {
            if (ch.GetEquippedItem(WearLocations.DualWield) != null ||
                (ch.GetEquippedItem(WearLocations.Wield) != null &&
                 ch.GetEquippedItem(WearLocations.WieldMissile) != null) ||
                (ch.GetEquippedItem(WearLocations.Wield) != null &&
                 ch.GetEquippedItem(WearLocations.Hold) != null))
            {
                ch.SendTo(
                    ch.GetEquippedItem(WearLocations.Hold) != null
                        ? "You can't use a shield while using a weapon and holding something!"
                        : "You can't use a shield AND two weapons!");
                return;
            }
            if (!ch.RemoveFrom(WearLocations.Shield, replace))
            {
                return;
            }
            if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
            {
                comm.act(ATTypes.AT_ACTION, "$n uses $p as a shield.", ch, obj, null, ToTypes.Room);
                comm.act(ATTypes.AT_ACTION, "You use $p as a shield.", ch, obj, null, ToTypes.Character);
            }

            ch.Equip(obj, WearLocations.Shield);
            MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
        }
예제 #7
0
        private static void ItemWearAnkle(ObjectInstance obj, CharacterInstance ch, bool replace)
        {
            if (ch.GetEquippedItem(WearLocations.LeftAnkle) != null &&
                ch.GetEquippedItem(WearLocations.RightAnkle) != null &&
                !ch.RemoveFrom(WearLocations.LeftAnkle, replace) &&
                !ch.RemoveFrom(WearLocations.RightAnkle, replace))
            {
                return;
            }

            if (ch.GetEquippedItem(WearLocations.LeftAnkle) != null)
            {
                if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
                {
                    comm.act(ATTypes.AT_ACTION, "$n fit $p around $s left ankle.", ch, obj, null, ToTypes.Room);
                    comm.act(ATTypes.AT_ACTION, "You fit $p around your left ankle.", ch, obj, null, ToTypes.Character);
                }

                ch.Equip(obj, WearLocations.LeftAnkle);
                MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
                return;
            }

            if (ch.GetEquippedItem(WearLocations.RightAnkle) != null)
            {
                if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
                {
                    comm.act(ATTypes.AT_ACTION, "$n fit $p around $s right ankle.", ch, obj, null, ToTypes.Room);
                    comm.act(ATTypes.AT_ACTION, "You fit $p around your right ankle.", ch, obj, null, ToTypes.Character);
                }

                ch.Equip(obj, WearLocations.RightAnkle);
                MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
                return;
            }

            ch.SendTo("You already wear two ankle items.");
        }
예제 #8
0
        private static void ItemWearNeck(ObjectInstance obj, CharacterInstance ch, bool replace)
        {
            if (ch.GetEquippedItem(WearLocations.Neck_1) != null &&
                ch.GetEquippedItem(WearLocations.Neck_2) != null &&
                !ch.RemoveFrom(WearLocations.Neck_1, replace) &&
                !ch.RemoveFrom(WearLocations.Neck_2, replace))
            {
                return;
            }

            if (ch.GetEquippedItem(WearLocations.Neck_1) != null)
            {
                if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
                {
                    comm.act(ATTypes.AT_ACTION, "$n wears $p around $s neck.", ch, obj, null, ToTypes.Room);
                    comm.act(ATTypes.AT_ACTION, "You wear $p around your neck.", ch, obj, null, ToTypes.Character);
                }

                ch.Equip(obj, WearLocations.Neck_1);
                MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
                return;
            }

            if (ch.GetEquippedItem(WearLocations.Neck_2) != null)
            {
                if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
                {
                    comm.act(ATTypes.AT_ACTION, "$n wears $p around $s neck.", ch, obj, null, ToTypes.Room);
                    comm.act(ATTypes.AT_ACTION, "You wear $p around your neck.", ch, obj, null, ToTypes.Character);
                }

                ch.Equip(obj, WearLocations.Neck_2);
                MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
                return;
            }

            ch.SendTo("You already wear two neck items.");
        }
예제 #9
0
        private static void ItemWearFinger(ObjectInstance obj, CharacterInstance ch, bool replace)
        {
            if (ch.GetEquippedItem(WearLocations.LeftFinger) != null &&
                ch.GetEquippedItem(WearLocations.RightFinger) != null &&
                !ch.RemoveFrom(WearLocations.LeftFinger, replace) &&
                !ch.RemoveFrom(WearLocations.RightFinger, replace))
            {
                return;
            }

            if (ch.GetEquippedItem(WearLocations.LeftFinger) != null)
            {
                if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
                {
                    comm.act(ATTypes.AT_ACTION, "$n slips $s left finger into $p.", ch, obj, null, ToTypes.Room);
                    comm.act(ATTypes.AT_ACTION, "You slip your left finger into $p.", ch, obj, null, ToTypes.Character);
                }

                ch.Equip(obj, WearLocations.LeftFinger);
                MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
                return;
            }

            if (ch.GetEquippedItem(WearLocations.RightFinger) != null)
            {
                if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
                {
                    comm.act(ATTypes.AT_ACTION, "$n slips $s right finger into $p.", ch, obj, null, ToTypes.Room);
                    comm.act(ATTypes.AT_ACTION, "You slip your right finger into $p.", ch, obj, null, ToTypes.Character);
                }

                ch.Equip(obj, WearLocations.RightFinger);
                MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
                return;
            }

            ch.SendTo("You already wear something on both fingers.");
        }
예제 #10
0
        private static int ModifyDamageForEquipment(CharacterInstance victim, int dam)
        {
            var wearLoc = GetRandomWearLocation();
            var obj     = victim.GetEquippedItem(wearLoc);

            if (obj != null && dam > obj.GetResistance() && SmaugRandom.Bits(1) == 0)
            {
                handler.set_cur_obj(obj);
                obj.CauseDamageTo();
                return(dam - 5);
            }

            return(dam + 5);
        }
예제 #11
0
        public static void CheckDisarm(CharacterInstance ch, CharacterInstance victim, IRepositoryManager dbManager = null)
        {
            var obj = victim.GetEquippedItem(WearLocations.Wield);

            if (CheckFunctions.CheckIfNullObject(ch, obj))
            {
                return;
            }

            var tempObj = victim.GetEquippedItem(WearLocations.DualWield);

            if (tempObj != null && SmaugRandom.Bits(1) == 0)
            {
                obj = tempObj;
            }

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

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

            if (!ch.IsNpc() && ch.GetEquippedItem(WearLocations.Wield) == null && SmaugRandom.Bits(1) == 0)
            {
                skill.LearnFromFailure(ch);
                return;
            }

            if (!ch.IsNpc() && !ch.CanSee(obj) && SmaugRandom.Bits(1) == 0)
            {
                skill.LearnFromFailure(ch);
                return;
            }

            if (Grip.CheckGrip(ch, victim) && !ch.IsNpc())
            {
                skill.LearnFromFailure(ch);
                return;
            }

            comm.act(ATTypes.AT_SKILL, "$n DISARMS you!", ch, null, victim, ToTypes.Victim);
            comm.act(ATTypes.AT_SKILL, "You disarm $N!", ch, null, victim, ToTypes.Character);
            comm.act(ATTypes.AT_SKILL, "$n disarms $N!", ch, null, victim, ToTypes.Room);

            skill.LearnFromFailure(ch);

            obj.RemoveFrom();

            if (!victim.IsNpc() && victim.CanPKill() && !obj.ExtraFlags.IsSet((int)ItemExtraFlags.Loyal))
            {
                obj.MagicFlags.SetBit(ItemMagicFlags.PKDisarmed);
                obj.Value.ToList()[5] = victim.Level;
            }

            if (victim.IsNpc() || (obj.ExtraFlags.IsSet((int)ItemExtraFlags.Loyal) && victim.IsPKill() && !ch.IsNpc()))
            {
                obj.AddTo(victim);
            }
            else
            {
                victim.CurrentRoom.AddTo(obj);
            }
        }
예제 #12
0
        public static void show_char_to_char_1(CharacterInstance victim, PlayerInstance ch)
        {
            if (victim.CanSee(ch) && !ch.IsNpc() &&
                !ch.Act.IsSet((int)PlayerFlags.WizardInvisibility))
            {
                comm.act(ATTypes.AT_ACTION, "$n looks at you.", ch, null, victim, ToTypes.Victim);
                comm.act(ATTypes.AT_ACTION, victim != ch ? "$n looks at $N." : "$n looks at $mself.", ch, null, victim,
                         ToTypes.NotVictim);
            }

            if (!string.IsNullOrEmpty(victim.Description))
            {
                ch.SendTo(victim.CurrentMorph?.Morph != null
                    ? victim.CurrentMorph.Morph.Description
                    : victim.Description);
            }
            else
            {
                if (victim.CurrentMorph?.Morph != null)
                {
                    ch.SendTo(victim.CurrentMorph.Morph.Description);
                }
                else if (victim.IsNpc())
                {
                    comm.act(ATTypes.AT_PLAIN, "You see nothing special about $M.", ch, null, victim, ToTypes.Character);
                }
                else if (ch != victim)
                {
                    comm.act(ATTypes.AT_PLAIN, "$E isn't much to look at...", ch, null, victim, ToTypes.Character);
                }
                else
                {
                    comm.act(ATTypes.AT_PLAIN, "You're not much to look at...", ch, null, null, ToTypes.Character);
                }
            }

            ch.ShowRaceOf(victim);
            ch.ShowConditionTo(victim);

            var found = false;

            for (var i = 0; i < GameConstants.MaximumWearLocations; i++)
            {
                var wearLoc = EnumerationExtensions.GetEnum <WearLocations>(i);
                var obj     = victim.GetEquippedItem(wearLoc);
                if (obj != null && ch.CanSee(obj))
                {
                    if (!found)
                    {
                        ch.SendTo("\r\n");
                        if (victim != ch)
                        {
                            comm.act(ATTypes.AT_PLAIN, "$n is using:", ch, null, victim, ToTypes.Character);
                        }
                        else
                        {
                            comm.act(ATTypes.AT_PLAIN, "You are using:", ch, null, null, ToTypes.Character);
                        }
                        found = true;
                    }

                    if (!victim.IsNpc())
                    {
                        var race = RepositoryManager.Instance.GetRace(victim.CurrentRace);
                        ch.SendTo(race.WhereNames.ToList()[i]);
                    }
                    else
                    {
                        ch.SendTo(LookupManager.Instance.GetLookup("WhereNames", i));
                    }
                    ch.SendTo(obj.GetFormattedDescription(ch, true));
                    ch.SendTo("\r\n");
                }
            }

            if (ch.IsNpc() || victim == ch)
            {
                return;
            }

            if (ch.IsImmortal())
            {
                if (victim.IsNpc())
                {
                    ch.Printf("\r\nMobile #%d '%s' ", ((MobileInstance)victim).MobIndex.ID, victim.Name);
                }
                else
                {
                    ch.Printf("\r\n%s ", victim.Name);
                }

                ch.Printf("is a level %d %s %s.\r\n", victim.Level,
                          RepositoryManager.Instance.GetRace(victim.CurrentRace).Name,
                          RepositoryManager.Instance.GetClass(victim.CurrentClass).Name);
            }

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

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

            if (SmaugRandom.D100() < Macros.LEARNED(ch, (int)skill.ID))
            {
                ch.Printf("\r\nYou peek at %s inventory:\r\n", victim.Gender.PossessivePronoun());
                show_list_to_char(victim.Carrying.ToList(), ch, true, true);
                skill.LearnFromSuccess(ch);
            }
            else if (ch.PlayerData.GetSkillMastery(skill.ID) > skill.GetMasteryLevel(ch))
            {
                skill.LearnFromFailure(ch);
            }
        }
예제 #13
0
        public static void ModifyAffect(this CharacterInstance ch, AffectData affect, bool add)
        {
            var mod = affect.Modifier;

            if (add)
            {
                mod = ModifyAndAddAffect(ch, affect, mod);
            }
            else
            {
                ch.AffectedBy.RemoveBit((int)affect.Type);

                if ((int)affect.Location % Program.REVERSE_APPLY == (int)ApplyTypes.RecurringSpell)
                {
                    mod = Math.Abs(mod);
                    var skill = RepositoryManager.Instance.SKILLS.Values.ToList()[mod];

                    if (!Macros.IS_VALID_SN(mod) || skill == null || skill.Type != SkillTypes.Spell)
                    {
                        throw new InvalidDataException($"RecurringSpell with bad SN {mod}");
                    }
                    ch.AffectedBy.RemoveBit((int)AffectedByTypes.RecurringSpell);
                    return;
                }

                switch ((int)affect.Location % Program.REVERSE_APPLY)
                {
                case (int)ApplyTypes.Affect:
                    return;

                case (int)ApplyTypes.ExtendedAffect:
                    ch.AffectedBy.RemoveBit(mod);
                    return;

                case (int)ApplyTypes.Resistance:
                    ch.Resistance.RemoveBit(mod);
                    return;

                case (int)ApplyTypes.Immunity:
                    ch.Immunity.RemoveBit(mod);
                    return;

                case (int)ApplyTypes.Susceptibility:
                    ch.Susceptibility.RemoveBit(mod);
                    return;

                case (int)ApplyTypes.Remove:
                    return;
                }
                mod = 0 - mod;
            }

            var applyType = Common.EnumerationExtensions.GetEnum <ApplyTypes>((int)affect.Location % Program.REVERSE_APPLY);

            switch (applyType)
            {
            case ApplyTypes.Strength:
                ch.ModStrength += mod;
                break;

            case ApplyTypes.Dexterity:
                ch.ModDexterity += mod;
                break;

            case ApplyTypes.Intelligence:
                ch.ModIntelligence += mod;
                break;

            case ApplyTypes.Wisdom:
                ch.ModWisdom += mod;
                break;

            case ApplyTypes.Constitution:
                ch.ModConstitution += mod;
                break;

            case ApplyTypes.Charisma:
                ch.ModCharisma += mod;
                break;

            case ApplyTypes.Luck:
                ch.ModLuck += mod;
                break;

            case ApplyTypes.Gender:
                //ch.Gender = (ch.Gender + mod) % 3;
                // TODO Fix this
                //if (ch.Gender < 0)
                //    ch.Gender += 2;
                //ch.Gender = Check.Range(0, ch.Gender, 2);
                break;

            case ApplyTypes.Height:
                ch.Height += mod;
                break;

            case ApplyTypes.Weight:
                ch.Weight += mod;
                break;

            case ApplyTypes.Mana:
                ch.MaximumMana += mod;
                break;

            case ApplyTypes.Hit:
                ch.MaximumHealth += mod;
                break;

            case ApplyTypes.Movement:
                ch.MaximumMovement += mod;
                break;

            case ApplyTypes.ArmorClass:
                ch.ArmorClass += mod;
                break;

            case ApplyTypes.HitRoll:
                ch.HitRoll.SizeOf += mod;
                break;

            case ApplyTypes.DamageRoll:
                ch.DamageRoll.SizeOf += mod;
                break;

            case ApplyTypes.SaveVsPoison:
                ch.SavingThrows.SaveVsPoisonDeath += mod;
                break;

            case ApplyTypes.SaveVsRod:
                ch.SavingThrows.SaveVsWandRod += mod;
                break;

            case ApplyTypes.SaveVsParalysis:
                ch.SavingThrows.SaveVsParalysisPetrify += mod;
                break;

            case ApplyTypes.SaveVsBreath:
                ch.SavingThrows.SaveVsBreath += mod;
                break;

            case ApplyTypes.SaveVsSpell:
                ch.SavingThrows.SaveVsSpellStaff += mod;
                break;

            case ApplyTypes.Affect:
                ch.AffectedBy.Bits[0].SetBit(mod);
                break;

            case ApplyTypes.ExtendedAffect:
                ch.AffectedBy.SetBit(mod);
                break;

            case ApplyTypes.Resistance:
                ch.Resistance.SetBit(mod);
                break;

            case ApplyTypes.Immunity:
                ch.Immunity.SetBit(mod);
                break;

            case ApplyTypes.Susceptibility:
                ch.Susceptibility.SetBit(mod);
                break;

            case ApplyTypes.Remove:
                ch.AffectedBy.Bits[0].RemoveBit(mod);
                break;

            case ApplyTypes.Full:
            case ApplyTypes.Thirst:
            case ApplyTypes.Drunk:
            case ApplyTypes.Blood:
                HandlePlayerCondition(ch, applyType, mod);
                break;

            case ApplyTypes.MentalState:
                ch.MentalState = (ch.MentalState + mod).GetNumberThatIsBetween(-100, 100);
                break;

            case ApplyTypes.Emotion:
                ch.EmotionalState = ch.EmotionalState.GetNumberThatIsBetween(-100, 100);
                break;

            case ApplyTypes.StripSN:
                if (Macros.IS_VALID_SN(mod))
                {
                    ch.StripAffects(mod);
                }
                else
                {
                    LogManager.Instance.Bug("apply_modify: ApplyTypes.StripSN invalid SN %d", mod);
                }
                break;

            case ApplyTypes.WearSpell:
            case ApplyTypes.RemoveSpell:
                if (ch.CurrentRoom.Flags.IsSet(RoomFlags.NoMagic) ||
                    ch.Immunity.IsSet(ResistanceTypes.Magic) ||
                    (applyType == ApplyTypes.WearSpell && !add) ||
                    (applyType == ApplyTypes.RemoveSpell && add) ||
                    handler.SavingCharacter == ch ||
                    handler.LoadingCharacter == ch)
                {
                    return;
                }

                mod = Math.Abs(mod);
                var skill = RepositoryManager.Instance.SKILLS.Values.ToList()[mod];

                if (Macros.IS_VALID_SN(mod) && skill != null && skill.Type == SkillTypes.Spell)
                {
                    if (skill.Target == TargetTypes.Ignore ||
                        skill.Target == TargetTypes.InventoryObject)
                    {
                        LogManager.Instance.Bug("ApplyTypes.WearSpell trying to apply bad target spell. SN is %d.", mod);
                        return;
                    }
                    var retcode = skill.SpellFunction.Value.Invoke(mod, ch.Level, ch, ch);
                    if (retcode == ReturnTypes.CharacterDied || ch.CharDied())
                    {
                        return;
                    }
                }
                break;

            default:
                var skillData = RepositoryManager.Instance.GetEntity <SkillData>(applyType.GetName());
                if (skillData != null)
                {
                    ch.ModifySkill((int)skillData.Type, mod, add);
                }
                else
                {
                    LogManager.Instance.Bug("affect_modify: unknown location %d", affect.Location);
                }
                break;
            }

            var wield       = ch.GetEquippedItem(WearLocations.Wield);
            var strWieldMod = (int)LookupManager.Instance.GetStatMod("Strength", ch.GetCurrentStrength(),
                                                                     StrengthModTypes.Wield);

            if (!ch.IsNpc() && handler.SavingCharacter != ch && wield != null && wield.GetWeight() > strWieldMod)
            {
                if (Depth == 0)
                {
                    Depth++;
                    comm.act(ATTypes.AT_ACTION, "You are too weak to wield $p any longer.", ch, wield, null,
                             ToTypes.Character);
                    comm.act(ATTypes.AT_ACTION, "$n stops wielding $p.", ch, wield, null, ToTypes.Room);
                    ch.Unequip(wield);
                    Depth--;
                }
            }
        }
예제 #14
0
        private static void ItemWearWield(ObjectInstance obj, CharacterInstance ch, bool replace, ItemWearFlags wearFlag)
        {
            var strWieldMod = (int)LookupManager.Instance.GetStatMod("Strength", ch.GetCurrentStrength(),
                                                                     StrengthModTypes.Wield);

            if (!ch.CouldDualWield())
            {
                if (!ch.RemoveFrom(WearLocations.WieldMissile, replace) ||
                    !ch.RemoveFrom(WearLocations.Wield, replace))
                {
                    return;
                }
            }
            else
            {
                var tobj = ch.GetEquippedItem(WearLocations.Wield);
                var mw   = ch.GetEquippedItem(WearLocations.WieldMissile);
                var dw   = ch.GetEquippedItem(WearLocations.DualWield);
                var hd   = ch.GetEquippedItem(WearLocations.Hold);
                var sd   = ch.GetEquippedItem(WearLocations.Shield);

                if (CheckFunctions.CheckIfTrue(ch, hd != null && sd != null,
                                               "You are already holding something and wearing a shield."))
                {
                    return;
                }

                if (tobj != null)
                {
                    if (!ch.CanDualWield())
                    {
                        return;
                    }

                    if (CheckFunctions.CheckIfTrue(ch,
                                                   obj.GetWeight() + tobj.GetWeight() > strWieldMod, "It is too heavy for you to wield."))
                    {
                        return;
                    }

                    if (CheckFunctions.CheckIfTrue(ch, hd != null || sd != null,
                                                   "You're already wielding a weapon AND holding something."))
                    {
                        return;
                    }

                    if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
                    {
                        comm.act(ATTypes.AT_ACTION, "$n dual-wields $p.", ch, obj, null, ToTypes.Room);
                        comm.act(ATTypes.AT_ACTION, "You dual-wield $p.", ch, obj, null, ToTypes.Character);
                    }

                    ch.Equip(obj, wearFlag == ItemWearFlags.MissileWield
                        ? WearLocations.WieldMissile : WearLocations.DualWield);
                    MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
                    return;
                }

                if (mw != null)
                {
                    ItemEquipMissileWeapon(obj, ch, mw, dw, hd, sd);
                    return;
                }
            }

            if (CheckFunctions.CheckIfTrue(ch, obj.GetWeight() > strWieldMod, "It is too heavy for you to wield."))
            {
                return;
            }

            if (!MudProgHandler.ExecuteObjectProg(MudProgTypes.Use, ch, obj, null, null))
            {
                comm.act(ATTypes.AT_ACTION, "$n wields $p.", ch, obj, null, ToTypes.Room);
                comm.act(ATTypes.AT_ACTION, "You wield $p.", ch, obj, null, ToTypes.Character);
            }

            ch.Equip(obj, wearFlag == ItemWearFlags.MissileWield ? WearLocations.WieldMissile : WearLocations.Wield);
            MudProgHandler.ExecuteObjectProg(MudProgTypes.Wear, ch, obj);
        }