Ejemplo n.º 1
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null);

            if (DobjArtifact.IsReadyableByMonster(ActorMonster) && DobjArtifact.IsCarriedByMonster(ActorMonster))
            {
                ActorWeapon = gADB[ActorMonster.Weapon];

                if (ActorWeapon != null)
                {
                    rc = ActorWeapon.RemoveStateDesc(ActorWeapon.GetReadyWeaponDesc());

                    Debug.Assert(gEngine.IsSuccess(rc));
                }

                ActorMonster.Weapon = DobjArtifact.Uid;

                rc = DobjArtifact.AddStateDesc(DobjArtifact.GetReadyWeaponDesc());

                Debug.Assert(gEngine.IsSuccess(rc));

                Debug.Assert(gCharMonster != null);

                if (gCharMonster.IsInRoom(ActorRoom))
                {
                    if (ActorRoom.IsLit())
                    {
                        MonsterName = ActorMonster.EvalPlural(ActorMonster.GetTheName(true), ActorMonster.GetArticleName(true, true, false, true, Globals.Buf01));

                        gOut.Print("{0} readies {1}.", MonsterName, DobjArtifact.GetArticleName());
                    }
                    else
                    {
                        MonsterName = string.Format("An unseen {0}", ActorMonster.CheckNBTLHostility() ? "offender" : "entity");

                        gOut.Print("{0} readies {1}.", MonsterName, "a weapon");
                    }

                    if (ActorMonster.CheckNBTLHostility())
                    {
                        Globals.Thread.Sleep(gGameState.PauseCombatMs);
                    }
                }
            }

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IErrorState>(x =>
                {
                    x.ErrorMessage = string.Format("{0}: NextState == null", Name);
                });
            }
        }
Ejemplo n.º 2
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null);

            ArtTypes = new ArtifactType[] { ArtifactType.DisguisedMonster, ArtifactType.DeadBody, ArtifactType.BoundMonster, ArtifactType.Weapon, ArtifactType.MagicWeapon };

            DobjArtAc = DobjArtifact.GetArtifactCategory(ArtTypes, false);

            if (DobjArtAc == null)
            {
                DobjArtAc = DobjArtifact.GetCategories(0);
            }

            if (DobjArtAc != null && DobjArtAc.Type != ArtifactType.DisguisedMonster && DobjArtifact.Weight <= 900 && !DobjArtifact.IsUnmovable01() && (DobjArtAc.Type != ArtifactType.DeadBody || DobjArtAc.Field1 == 1) && DobjArtAc.Type != ArtifactType.BoundMonster)
            {
                OmitWeightCheck = DobjArtifact.IsCarriedByMonster(ActorMonster, true);

                DobjArtifactCount = 0;

                DobjArtifactWeight = DobjArtifact.Weight;

                if (DobjArtifact.GeneralContainer != null)
                {
                    rc = DobjArtifact.GetContainerInfo(ref _dobjArtifactCount, ref _dobjArtifactWeight, ContainerType.In, true);

                    Debug.Assert(gEngine.IsSuccess(rc));

                    rc = DobjArtifact.GetContainerInfo(ref _dobjArtifactCount, ref _dobjArtifactWeight, ContainerType.On, true);

                    Debug.Assert(gEngine.IsSuccess(rc));
                }

                ActorMonsterInventoryWeight = 0;

                rc = ActorMonster.GetFullInventoryWeight(ref _actorMonsterInventoryWeight, recurse: true);

                Debug.Assert(gEngine.IsSuccess(rc));

                if (!gEngine.EnforceMonsterWeightLimits || OmitWeightCheck || (DobjArtifactWeight <= ActorMonster.GetWeightCarryableGronds() && DobjArtifactWeight + ActorMonsterInventoryWeight <= ActorMonster.GetWeightCarryableGronds() * ActorMonster.CurrGroupCount))
                {
                    DobjArtifact.SetCarriedByMonster(ActorMonster);

                    Debug.Assert(gCharMonster != null);

                    if (gCharMonster.IsInRoom(ActorRoom))
                    {
                        if (ActorRoom.IsLit())
                        {
                            MonsterName = ActorMonster.EvalPlural(ActorMonster.GetTheName(true), ActorMonster.GetArticleName(true, true, false, true, Globals.Buf01));

                            gOut.Print("{0} picks up {1}.", MonsterName, DobjArtifact.GetTheName());
                        }
                        else
                        {
                            MonsterName = string.Format("An unseen {0}", ActorMonster.CheckNBTLHostility() ? "offender" : "entity");

                            gOut.Print("{0} picks up {1}.", MonsterName, "a weapon");
                        }
                    }

                    // when a weapon is picked up all monster affinities to that weapon are broken

                    FumbleMonsterList = gEngine.GetMonsterList(m => m.Weapon == -DobjArtifact.Uid - 1 && m != ActorMonster);

                    foreach (var monster in FumbleMonsterList)
                    {
                        monster.Weapon = -1;
                    }
                }
            }

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IErrorState>(x =>
                {
                    x.ErrorMessage = string.Format("{0}: NextState == null", Name);
                });
            }
        }