コード例 #1
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null && IobjArtifact != null);

            if (!DobjArtifact.IsCarriedByCharacter())
            {
                if (!GetCommandCalled)
                {
                    RedirectToGetCommand <IPutCommand>(DobjArtifact);
                }
                else if (DobjArtifact.DisguisedMonster == null)
                {
                    NextState = Globals.CreateInstance <IStartState>();
                }

                goto Cleanup;
            }

            IobjArtAc = gEngine.EvalContainerType(ContainerType, IobjArtifact.InContainer, IobjArtifact.OnContainer, IobjArtifact.UnderContainer, IobjArtifact.BehindContainer);

            DobjAllContainerArtifactList = DobjArtifact.GetContainedList(containerType: (ContainerType)(-1), recurse: true);

            DobjAllContainerArtifactList.Add(DobjArtifact);

            if (DobjAllContainerArtifactList.Contains(IobjArtifact) || IobjArtAc == null)
            {
                PrintDontFollowYou();

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if ((IobjArtifact.IsCarriedByCharacter() && !IobjArtifact.ShouldAddContentsWhenCarried(ContainerType)) || (IobjArtifact.IsWornByCharacter() && !IobjArtifact.ShouldAddContentsWhenWorn(ContainerType)))
            {
                if (IobjArtifact.IsCarriedByCharacter())
                {
                    PrintNotWhileCarryingObj(IobjArtifact);
                }
                else
                {
                    PrintNotWhileWearingObj(IobjArtifact);
                }

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (IobjArtAc == IobjArtifact.InContainer && !IobjArtAc.IsOpen() && !IobjArtifact.ShouldExposeInContentsWhenClosed())
            {
                PrintMustFirstOpen(IobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if ((IobjArtAc == IobjArtifact.InContainer && IobjArtAc.GetKeyUid() == -2) || (IobjArtAc == IobjArtifact.OnContainer && IobjArtifact.InContainer != null && IobjArtifact.InContainer.GetKeyUid() == -2 && IobjArtifact.IsInContainerOpenedFromTop()))
            {
                PrintBrokeIt(IobjArtifact);

                goto Cleanup;
            }

            if (IobjArtAc == IobjArtifact.OnContainer && IobjArtifact.InContainer != null && IobjArtifact.InContainer.IsOpen() && IobjArtifact.IsInContainerOpenedFromTop())
            {
                PrintMustFirstClose(IobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            IobjArtifactCount = 0;

            IobjArtifactWeight = 0;

            rc = IobjArtifact.GetContainerInfo(ref _iobjArtifactCount, ref _iobjArtifactWeight, ContainerType, false);

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

            if (IobjArtAc.Field3 < 1 || IobjArtAc.Field4 < 1)
            {
                PrintDontNeedTo();

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            MaxItemsReached = IobjArtifactCount >= IobjArtAc.Field4;

            if ((!MaxItemsReached && IobjArtifactWeight + DobjArtifact.Weight > IobjArtAc.Field3) || !IobjArtifact.ShouldAddContents(DobjArtifact, ContainerType))
            {
                PrintWontFit(DobjArtifact);

                goto Cleanup;
            }

            if (MaxItemsReached || IobjArtifactWeight + DobjArtifact.Weight > IobjArtAc.Field3)
            {
                if (IobjArtAc == IobjArtifact.InContainer)
                {
                    PrintFull(IobjArtifact);
                }
                else
                {
                    PrintOutOfSpace(IobjArtifact);
                }

                goto Cleanup;
            }

            DobjArtifact.SetCarriedByContainer(IobjArtifact, ContainerType);

            if (gGameState.Ls == DobjArtifact.Uid)
            {
                Debug.Assert(DobjArtifact.LightSource != null);

                gEngine.LightOut(DobjArtifact);
            }

            if (ActorMonster.Weapon == DobjArtifact.Uid)
            {
                Debug.Assert(DobjArtifact.GeneralWeapon != null);

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

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

                ActorMonster.Weapon = -1;
            }

            gOut.Print("Done.");

            ProcessEvents(EventType.AfterPutArtifact);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
コード例 #2
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null);

            // Remove orb from metal pedestal

            if (DobjArtifact.Uid == 4 && IobjArtifact != null && IobjArtifact.Uid == 43)
            {
                gOut.Print("{0} {1} stuck to {2} and won't budge.", DobjArtifact.GetTheName(true), DobjArtifact.EvalPlural("is", "are"), IobjArtifact.GetTheName(buf: Globals.Buf01));

                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
            else
            {
                base.Execute();
            }
        }
コード例 #3
0
        public override void ProcessEvents(EventType eventType)
        {
            if (eventType == EventType.AfterPutArtifact)
            {
                // Put anything in slime destroys it

                if (IobjArtifact.Uid == 24 || IobjArtifact.Uid == 25)
                {
                    gOut.Print("{0} start{1} dissolving on contact with {2}!", DobjArtifact.GetTheName(true), DobjArtifact.EvalPlural("s", ""), IobjArtifact.GetTheName(buf: Globals.Buf01));

                    gOut.Print("{0} {1} destroyed!", DobjArtifact.GetTheName(true), DobjArtifact.EvalPlural("is", "are"));

                    DobjArtifact.SetInLimbo();
                }

                // Put orb in metal pedestal

                else if (DobjArtifact.Uid == 4 && IobjArtifact.Uid == 43)
                {
                    gEngine.PrintEffectDesc(43);

                    gEngine.PrintEffectDesc(44);

                    var adjacentRoom = gRDB[45];

                    Debug.Assert(adjacentRoom != null);

                    var newRoom = gRDB[15];

                    Debug.Assert(newRoom != null);

                    adjacentRoom.SetDirs(Direction.South, 15);

                    IobjArtifact.IsListed = false;

                    gEngine.TransportPlayerBetweenRooms(ActorRoom, newRoom, null);

                    NextState = Globals.CreateInstance <IAfterPlayerMoveState>();
                }
                else
                {
                    base.ProcessEvents(eventType);
                }
            }
            else
            {
                base.ProcessEvents(eventType);
            }
        }
コード例 #4
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);
                });
            }
        }