Beispiel #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);
                });
            }
        }
        public override void Execute()
        {
            if (DobjArtifact != null && !Enum.IsDefined(typeof(ContainerType), ContainerType))
            {
                var diaryArtifact = gADB[3];

                Debug.Assert(diaryArtifact != null);

                var leverArtifact = gADB[48];

                Debug.Assert(leverArtifact != null);

                // Find dead zombies are in disguise

                if (DobjArtifact.Uid >= 58 && DobjArtifact.Uid <= 63)
                {
                    gEngine.PrintEffectDesc(15);
                }

                // Find diary on dead adventurer

                else if (DobjArtifact.Uid == 2 && diaryArtifact.IsInLimbo())
                {
                    gEngine.PrintEffectDesc(16);

                    diaryArtifact.SetInRoom(ActorRoom);
                }

                // Examine slime

                else if (DobjArtifact.Uid == 24 || DobjArtifact.Uid == 25)
                {
                    gEngine.PrintEffectDesc(17);
                }

                // Examine green device, find lever

                else if (DobjArtifact.Uid == 44 && DobjArtifact.IsInRoom(ActorRoom))
                {
                    base.Execute();

                    if (leverArtifact.IsInLimbo())
                    {
                        leverArtifact.SetInRoom(ActorRoom);
                    }
                }
                else if (DobjArtifact.IsCharOwned)
                {
                    gOut.Print("You see nothing unusual about {0}.", DobjArtifact.GetArticleName());
                }

                // If not special dead body, send msg

                else if (DobjArtifact.Uid >= 51)
                {
                    gOut.Print("You find nothing special about {0}.", DobjArtifact.GetTheName());
                }
                else
                {
                    base.Execute();
                }

                if (NextState == null)
                {
                    NextState = Globals.CreateInstance <IMonsterStartState>();
                }
            }
            else
            {
                base.Execute();
            }
        }
Beispiel #3
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null && IobjArtifact != null && Prep != null && Enum.IsDefined(typeof(ContainerType), Prep.ContainerType));

            Debug.Assert(DobjArtifact.IsCarriedByContainer(IobjArtifact) && DobjArtifact.GetCarriedByContainerContainerType() == Prep.ContainerType);

            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} removes {1} from {2} {3}.", MonsterName, DobjArtifact.GetArticleName(), gEngine.EvalContainerType(Prep.ContainerType, "inside", "on", "under", "behind"), OmitWeightCheck ? IobjArtifact.GetArticleName(buf: Globals.Buf01) : IobjArtifact.GetTheName(buf: Globals.Buf01));
                        }
                        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);
                });
            }
        }