Пример #1
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null || DobjMonster != null);

            if (BlastSpell || ActorMonster.Weapon > 0)
            {
                // Attack Bozworth

                if (DobjMonster != null && DobjMonster.Uid == 20)
                {
                    gEngine.PrintEffectDesc(20);

                    DobjMonster.SetInLimbo();

                    NextState = Globals.CreateInstance <IStartState>();
                }

                // Attack/BLAST backpack

                else if (DobjArtifact != null && DobjArtifact.Uid == 13)
                {
                    PrintDontNeedTo();

                    NextState = Globals.CreateInstance <IStartState>();
                }
                else
                {
                    base.Execute();
                }
            }
            else
            {
                base.Execute();
            }
        }
Пример #2
0
        public override void ProcessEvents(EventType eventType)
        {
            // BLAST Bozworth

            if (eventType == EventType.AfterCastSpellCheck && DobjMonster != null && DobjMonster.Uid == 20)
            {
                gEngine.PrintEffectDesc(21);

                DobjMonster.SetInLimbo();

                NextState = Globals.CreateInstance <IStartState>();

                GotoCleanup = true;
            }
            else
            {
                base.ProcessEvents(eventType);
            }
        }
Пример #3
0
        public override void Execute()
        {
            Debug.Assert(DobjMonster != null);

            if (CastSpell && !gEngine.CheckPlayerSpellCast(Spell.Heal, ShouldAllowSkillGains()))
            {
                goto Cleanup;
            }

            IsCharMonster = DobjMonster.IsCharacterMonster();

            if (DobjMonster.DmgTaken > 0)
            {
                if (Globals.IsRulesetVersion(5, 15, 25))
                {
                    Globals.Buf.SetFormat("{0}Some of {1}",
                                          Environment.NewLine,
                                          IsCharMonster ? "your" :
                                          DobjMonster.EvalPlural(DobjMonster.GetTheName(buf: Globals.Buf01),
                                                                 DobjMonster.GetArticleName(false, true, false, true, Globals.Buf02)));
                }
                else
                {
                    Globals.Buf.SetFormat("{0}{1}",
                                          Environment.NewLine,
                                          IsCharMonster ? "Your" :
                                          DobjMonster.EvalPlural(DobjMonster.GetTheName(true, buf: Globals.Buf01),
                                                                 DobjMonster.GetArticleName(true, true, false, true, Globals.Buf02)));
                }

                if (!IsCharMonster)
                {
                    gEngine.GetPossessiveName(Globals.Buf);
                }

                if (Globals.IsRulesetVersion(5, 15, 25))
                {
                    Globals.Buf.AppendFormat(" wounds seem to clear up.{0}", Environment.NewLine);
                }
                else
                {
                    Globals.Buf.AppendFormat(" health improves!{0}", Environment.NewLine);
                }

                gOut.Write("{0}", Globals.Buf);

                DamageHealed = gEngine.RollDice(1, Globals.IsRulesetVersion(5, 15, 25) ? 10 : 12, 0);

                DobjMonster.DmgTaken -= DamageHealed;
            }

            if (DobjMonster.DmgTaken < 0)
            {
                DobjMonster.DmgTaken = 0;
            }

            Globals.Buf.SetFormat("{0}{1} {2} ",
                                  Environment.NewLine,
                                  IsCharMonster ? "You" : DobjMonster.GetTheName(true, true, false, true, Globals.Buf01),
                                  IsCharMonster ? "are" : "is");

            DobjMonster.AddHealthStatus(Globals.Buf);

            gOut.Write("{0}", Globals.Buf);

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Пример #4
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null || DobjMonster != null);

            if (DobjMonster != null)
            {
                Globals.Buf.Clear();

                rc = DobjMonster.BuildPrintedFullDesc(Globals.Buf, false);

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

                gOut.Write("{0}", Globals.Buf);

                DobjMonster.Seen = true;

                if (DobjMonster.Reaction == Friendliness.Friend && DobjMonster.ShouldShowContentsWhenExamined())
                {
                    RedirectCommand01 = Globals.CreateInstance <IInventoryCommand>();

                    CopyCommandData(RedirectCommand01);

                    NextState = RedirectCommand01;

                    goto Cleanup;
                }

                if (DobjMonster.ShouldShowHealthStatusWhenExamined())
                {
                    IsUninjuredGroupMonster = DobjMonster.CurrGroupCount > 1 && DobjMonster.DmgTaken == 0;

                    Globals.Buf.SetFormat("{0}{1} {2} ",
                                          Environment.NewLine,
                                          IsUninjuredGroupMonster ? "They" : DobjMonster.GetTheName(true, true, false, true, Globals.Buf01),
                                          IsUninjuredGroupMonster ? "are" : "is");

                    DobjMonster.AddHealthStatus(Globals.Buf);

                    gOut.Write("{0}", Globals.Buf);
                }

                goto Cleanup;
            }

            DobjArtAc = DobjArtifact.GetArtifactCategory(ArtTypes, false);

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

            Debug.Assert(DobjArtAc != null);

            if (DobjArtifact.IsEmbeddedInRoom(ActorRoom))
            {
                DobjArtifact.SetInRoom(ActorRoom);
            }

            if (DobjArtAc.Type == ArtifactType.DoorGate)
            {
                DobjArtAc.Field4 = 0;
            }

            if (DobjArtAc.Type == ArtifactType.DisguisedMonster)
            {
                gEngine.RevealDisguisedMonster(ActorRoom, DobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            Globals.Buf.Clear();

            if (!Enum.IsDefined(typeof(ContainerType), ContainerType) || DobjArtifact.IsWornByCharacter())
            {
                rc = DobjArtifact.BuildPrintedFullDesc(Globals.Buf, false);

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

                gOut.Write("{0}", Globals.Buf);

                DobjArtifact.Seen = true;

                ProcessEvents(EventType.AfterPrintArtifactFullDesc);

                if (GotoCleanup)
                {
                    goto Cleanup;
                }

                if ((DobjArtAc.Type == ArtifactType.Drinkable || DobjArtAc.Type == ArtifactType.Edible) && DobjArtAc.Field2 != Constants.InfiniteDrinkableEdible)
                {
                    gOut.Print("There {0}{1}{2}{3} left.",
                               DobjArtAc.Field2 != 1 ? "are " : "is ",
                               DobjArtAc.Field2 > 0 ? gEngine.GetStringFromNumber(DobjArtAc.Field2, false, Globals.Buf) : "no",
                               DobjArtAc.Type == ArtifactType.Drinkable ? " swallow" : " bite",
                               DobjArtAc.Field2 != 1 ? "s" : "");
                }

                if (((DobjArtAc.Type == ArtifactType.InContainer && (DobjArtAc.IsOpen() || DobjArtifact.ShouldExposeInContentsWhenClosed())) || DobjArtAc.Type == ArtifactType.OnContainer || DobjArtAc.Type == ArtifactType.UnderContainer || DobjArtAc.Type == ArtifactType.BehindContainer) && DobjArtifact.ShouldShowContentsWhenExamined())
                {
                    RedirectCommand = Globals.CreateInstance <IInventoryCommand>(x =>
                    {
                        x.AllowExtendedContainers = true;
                    });

                    CopyCommandData(RedirectCommand);

                    NextState = RedirectCommand;

                    goto Cleanup;
                }

                goto Cleanup;
            }

            ContainerArtType = gEngine.EvalContainerType(ContainerType, ArtifactType.InContainer, ArtifactType.OnContainer, ArtifactType.UnderContainer, ArtifactType.BehindContainer);

            DobjArtContainerAc = DobjArtifact.GetArtifactCategory(ContainerArtType);

            if (DobjArtContainerAc == null)
            {
                PrintYouSeeNothingSpecial();

                goto Cleanup;
            }

            if (DobjArtContainerAc == DobjArtifact.InContainer && !DobjArtContainerAc.IsOpen() && !DobjArtifact.ShouldExposeInContentsWhenClosed())
            {
                PrintMustFirstOpen(DobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            ContainerArtifactList = DobjArtifact.GetContainedList(containerType: ContainerType);

            ShowCharOwned = !DobjArtifact.IsCarriedByCharacter() /* && !DobjArtifact.IsWornByCharacter() */;

            if (ContainerArtifactList.Count > 0)
            {
                Globals.Buf.SetFormat("{0}{1} {2} you see ",
                                      Environment.NewLine,
                                      gEngine.EvalContainerType(ContainerType, "Inside", "On", "Under", "Behind"),
                                      DobjArtifact.GetTheName(false, ShowCharOwned, false, false, Globals.Buf01));

                rc = gEngine.GetRecordNameList(ContainerArtifactList.Cast <IGameBase>().ToList(), ArticleType.A, ShowCharOwned, StateDescDisplayCode.None, false, false, Globals.Buf);

                Debug.Assert(gEngine.IsSuccess(rc));
            }
            else
            {
                Globals.Buf.SetFormat("{0}There's nothing {1} {2}",
                                      Environment.NewLine,
                                      gEngine.EvalContainerType(ContainerType, "inside", "on", "under", "behind"),
                                      DobjArtifact.GetTheName(false, ShowCharOwned, false, false, Globals.Buf01));
            }

            Globals.Buf.AppendFormat(".{0}", Environment.NewLine);

            gOut.Write("{0}", Globals.Buf);

            ProcessEvents(EventType.AfterPrintArtifactContents);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Пример #5
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null || DobjMonster != null);

            if (!BlastSpell && ActorMonster.Weapon <= 0)
            {
                PrintMustFirstReadyWeapon();

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (DobjMonster != null)
            {
                ProcessEvents(EventType.BeforeAttackMonster);

                if (GotoCleanup)
                {
                    goto Cleanup;
                }

                if (!DobjMonster.IsAttackable(ActorMonster))
                {
                    PrintWhyAttack(DobjMonster);

                    NextState = Globals.CreateInstance <IStartState>();

                    goto Cleanup;
                }

                if (!CheckAttack && DobjMonster.Reaction != Friendliness.Enemy)
                {
                    gOut.Write("{0}Attack non-enemy (Y/N): ", Environment.NewLine);

                    Globals.Buf.Clear();

                    rc = Globals.In.ReadField(Globals.Buf, Constants.BufSize02, null, ' ', '\0', false, null, gEngine.ModifyCharToUpper, gEngine.IsCharYOrN, null);

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

                    if (Globals.Buf.Length == 0 || Globals.Buf[0] == 'N')
                    {
                        NextState = Globals.CreateInstance <IStartState>();

                        goto Cleanup;
                    }

                    CheckAttack = true;

                    gEngine.MonsterGetsAggravated(DobjMonster);
                }

                CombatSystem = Globals.CreateInstance <ICombatSystem>(x =>
                {
                    x.SetNextStateFunc = s => NextState = s;

                    x.OfMonster = ActorMonster;

                    x.DfMonster = DobjMonster;

                    x.MemberNumber = MemberNumber;

                    x.AttackNumber = AttackNumber;

                    x.BlastSpell = BlastSpell;

                    x.OmitSkillGains = !BlastSpell && !ShouldAllowSkillGains();
                });

                CombatSystem.ExecuteAttack();

                goto Cleanup;
            }

            ProcessEvents(EventType.BeforeAttackArtifact);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

            DobjArtAc = null;

            if (!DobjArtifact.IsAttackable01(ref _dobjArtAc))
            {
                PrintWhyAttack(DobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            Debug.Assert(DobjArtAc != null);

            if (DobjArtAc.Type == ArtifactType.DeadBody)
            {
                if (BlastSpell)
                {
                    gOut.Print("{0}", gEngine.GetBlastDesc());
                }

                DobjArtifact.SetInLimbo();

                PrintHackToBits();

                goto Cleanup;
            }

            if (DobjArtAc.Type == ArtifactType.DisguisedMonster)
            {
                gEngine.RevealDisguisedMonster(ActorRoom, DobjArtifact);

                DisguisedMonster = gMDB[DobjArtAc.Field1];

                Debug.Assert(DisguisedMonster != null);

                RedirectCommand = null;

                if (BlastSpell)
                {
                    RedirectCommand = Globals.CreateInstance <IBlastCommand>(x =>
                    {
                        x.CastSpell = false;
                    });
                }
                else
                {
                    RedirectCommand = Globals.CreateInstance <IAttackCommand>();
                }

                CopyCommandData(RedirectCommand);

                RedirectCommand.Dobj = DisguisedMonster;

                NextState = RedirectCommand;

                goto Cleanup;
            }

            /*
             *      Damage it...
             */

            KeyArtifactUid = DobjArtAc.GetKeyUid();

            if (KeyArtifactUid == -2)
            {
                PrintAlreadyBrokeIt(DobjArtifact);

                goto Cleanup;
            }

            BreakageStrength = DobjArtAc.GetBreakageStrength();

            if (BreakageStrength < 1000)
            {
                gOut.Print("Nothing happens.");

                goto Cleanup;
            }

            BreakageDice = 0;

            BreakageSides = 0;

            if (BlastSpell)
            {
                if (Globals.IsRulesetVersion(5, 15, 25))
                {
                    BreakageDice = 1;

                    BreakageSides = 6;
                }
                else
                {
                    BreakageDice = 2;

                    BreakageSides = 5;
                }

                Globals.Buf.SetPrint("{0}", gEngine.GetBlastDesc());
            }
            else
            {
                ActorWeapon = gADB[ActorMonster.Weapon];

                Debug.Assert(ActorWeapon != null);

                ActorWeaponAc = ActorWeapon.GeneralWeapon;

                Debug.Assert(ActorWeaponAc != null);

                BreakageDice = ActorWeaponAc.Field3;

                BreakageSides = ActorWeaponAc.Field4;

                BuildWhamHitObj();
            }

            gOut.Write("{0}", Globals.Buf);

            BreakageDamage = gEngine.RollDice(BreakageDice, BreakageSides, 0);

            BreakageStrength -= BreakageDamage;

            if (BreakageStrength > 1000)
            {
                DobjArtAc.SetBreakageStrength(BreakageStrength);

                goto Cleanup;
            }

            /*
             *      Broken!
             */

            DobjArtAc.SetOpen(true);

            DobjArtAc.SetKeyUid(-2);

            DobjArtAc.Field4 = 0;

            DobjArtifact.Value = 0;

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

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

            BuildSmashesToPieces();

            if (DobjArtAc.Type == ArtifactType.InContainer)
            {
                SpilledArtifactList = DobjArtifact.GetContainedList(containerType: ContainerType.In);

                if (DobjArtifact.OnContainer != null && DobjArtifact.IsInContainerOpenedFromTop())
                {
                    SpilledArtifactList.AddRange(DobjArtifact.GetContainedList(containerType: ContainerType.On));
                }

                foreach (var artifact in SpilledArtifactList)
                {
                    artifact.SetInRoom(ActorRoom);
                }

                if (SpilledArtifactList.Count > 0)
                {
                    BuildContentsSpillToFloor();
                }

                DobjArtAc.Field3 = 0;
            }

            Globals.Buf.AppendFormat("!{0}", Environment.NewLine);

            gOut.Write("{0}", Globals.Buf);

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Пример #6
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null || DobjMonster != null);

            if (!ActorRoom.IsLit())
            {
                Debug.Assert(DobjMonster != null && DobjMonster.IsCharacterMonster());
            }

            if (DobjArtifact != null)
            {
                DobjArtAc = DobjArtifact.InContainer;

                if (DobjArtAc == null)
                {
                    DobjArtAc = DobjArtifact.OnContainer;
                }

                if (DobjArtAc == null && AllowExtendedContainers)
                {
                    DobjArtAc = DobjArtifact.UnderContainer;
                }

                if (DobjArtAc == null && AllowExtendedContainers)
                {
                    DobjArtAc = DobjArtifact.BehindContainer;
                }

                if (DobjArtAc == null)
                {
                    PrintCantVerbObj(DobjArtifact);

                    NextState = Globals.CreateInstance <IStartState>();

                    goto Cleanup;
                }

                DobjArtContainerType = gEngine.GetContainerType(DobjArtAc.Type);

                if (DobjArtifact.IsEmbeddedInRoom(ActorRoom))
                {
                    DobjArtifact.SetInRoom(ActorRoom);
                }

                if (DobjArtAc == DobjArtifact.InContainer && !DobjArtAc.IsOpen() && !DobjArtifact.ShouldExposeInContentsWhenClosed())
                {
                    PrintMustFirstOpen(DobjArtifact);

                    NextState = Globals.CreateInstance <IStartState>();

                    goto Cleanup;
                }

                DobjArtContainedArtifactList = DobjArtifact.GetContainedList(containerType: DobjArtContainerType);

                ShowCharOwned = !DobjArtifact.IsCarriedByCharacter() && !DobjArtifact.IsWornByCharacter();

                if (DobjArtContainedArtifactList.Count > 0)
                {
                    Globals.Buf.SetFormat("{0}{1} {2} you see ",
                                          Environment.NewLine,
                                          gEngine.EvalContainerType(DobjArtContainerType, "Inside", "On", "Under", "Behind"),
                                          DobjArtifact.GetTheName(false, ShowCharOwned, false, false, Globals.Buf01));

                    rc = gEngine.GetRecordNameList(DobjArtContainedArtifactList.Cast <IGameBase>().ToList(), ArticleType.A, ShowCharOwned, StateDescDisplayCode.None, false, false, Globals.Buf);

                    Debug.Assert(gEngine.IsSuccess(rc));
                }
                else
                {
                    Globals.Buf.SetFormat("{0}There's nothing {1} {2}",
                                          Environment.NewLine,
                                          gEngine.EvalContainerType(DobjArtContainerType, "inside", "on", "under", "behind"),
                                          DobjArtifact.GetTheName(false, ShowCharOwned, false, false, Globals.Buf01));
                }

                Globals.Buf.AppendFormat(".{0}", Environment.NewLine);

                gOut.Write("{0}", Globals.Buf);

                goto Cleanup;
            }

            IsCharMonster = DobjMonster.IsCharacterMonster();

            if (!IsCharMonster && DobjMonster.Reaction < Friendliness.Friend)
            {
                gEngine.MonsterEmotes(DobjMonster);

                gOut.WriteLine();

                goto Cleanup;
            }

            HasWornInventory = DobjMonster.HasWornInventory();

            if (HasWornInventory)
            {
                DobjMonsterWornArtifactList = DobjMonster.GetWornList();

                if (DobjMonsterWornArtifactList.Count > 0)
                {
                    Globals.Buf.SetFormat("{0}{1} {2} {3}",
                                          Environment.NewLine,
                                          IsCharMonster ? "You" : DobjMonster.EvalPlural(DobjMonster.GetTheName(true, true, false, true, Globals.Buf01), "They"),
                                          IsCharMonster ? "are" : DobjMonster.EvalPlural("is", "are"),
                                          IsCharMonster ? "wearing " : DobjMonster.EvalPlural("wearing ", "wearing among them "));

                    rc = gEngine.GetRecordNameList(DobjMonsterWornArtifactList.Cast <IGameBase>().ToList(), ArticleType.A, IsCharMonster ? false : true, IsCharMonster ? StateDescDisplayCode.AllStateDescs : StateDescDisplayCode.SideNotesOnly, IsCharMonster ? true : false, false, Globals.Buf);

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

                    Globals.Buf.AppendFormat(".{0}", Environment.NewLine);

                    gOut.Write("{0}", Globals.Buf);
                }
            }

            HasCarriedInventory = DobjMonster.HasCarriedInventory();

            if (HasCarriedInventory)
            {
                DobjMonsterCarriedArtifactList = DobjMonster.GetCarriedList();

                if (IsCharMonster)
                {
                    // use total debt for characters with no assets; otherwise use HeldGold (which may be debt or asset)

                    TotalGold = gCharacter.HeldGold < 0 && gCharacter.BankGold < 0 ? gCharacter.HeldGold + gCharacter.BankGold : gCharacter.HeldGold;

                    if (TotalGold != 0)
                    {
                        GoldArtifact = Globals.CreateInstance <IArtifact>(x =>
                        {
                            x.Name = string.Format("{0}{1} gold piece{2}",
                                                   TotalGold < 0 ? "a debt of " : "",
                                                   gEngine.GetStringFromNumber(Math.Abs(TotalGold), false, Globals.Buf),
                                                   Math.Abs(TotalGold) != 1 ? "s" : "");
                        });

                        DobjMonsterCarriedArtifactList.Add(GoldArtifact);
                    }
                }

                Globals.Buf.SetFormat("{0}{1} {2} {3}",
                                      Environment.NewLine,
                                      IsCharMonster ? "You" : DobjMonster.EvalPlural(DobjMonster.GetTheName(true, true, false, true, Globals.Buf01), "They"),
                                      IsCharMonster ? "are" : DobjMonster.EvalPlural("is", "are"),
                                      DobjMonsterCarriedArtifactList.Count == 0 ? "" :
                                      IsCharMonster ? "carrying " : DobjMonster.EvalPlural("carrying ", "carrying among them "));

                if (DobjMonsterCarriedArtifactList.Count > 0)
                {
                    rc = gEngine.GetRecordNameList(DobjMonsterCarriedArtifactList.Cast <IGameBase>().ToList(), ArticleType.A, IsCharMonster ? false : true, IsCharMonster ? StateDescDisplayCode.AllStateDescs : StateDescDisplayCode.SideNotesOnly, IsCharMonster ? true : false, false, Globals.Buf);

                    Debug.Assert(gEngine.IsSuccess(rc));
                }
                else
                {
                    Globals.Buf.Append("empty handed");
                }

                Globals.Buf.AppendFormat(".{0}", Environment.NewLine);

                gOut.Write("{0}", Globals.Buf);
            }

            ShouldShowHealthStatusWhenInventoried = DobjMonster.ShouldShowHealthStatusWhenInventoried();

            if (ShouldShowHealthStatusWhenInventoried)
            {
                IsUninjuredGroup = DobjMonster.CurrGroupCount > 1 && DobjMonster.DmgTaken == 0;

                Globals.Buf.SetFormat("{0}{1} {2} ",
                                      Environment.NewLine,
                                      IsCharMonster ? "You" :
                                      IsUninjuredGroup ? "They" :
                                      DobjMonster.GetTheName(true, true, false, true, Globals.Buf01),
                                      IsCharMonster || IsUninjuredGroup ? "are" : "is");

                DobjMonster.AddHealthStatus(Globals.Buf);

                gOut.Write("{0}", Globals.Buf);
            }

            if (GoldArtifact != null)
            {
                GoldArtifact.Dispose();

                GoldArtifact = null;
            }

            if (!HasWornInventory && !HasCarriedInventory && !ShouldShowHealthStatusWhenInventoried)
            {
                PrintCantVerbObj(DobjMonster);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }