Ejemplo n.º 1
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null || DobjMonster != null);

            // Can't attack armoire/bookshelf/pouch

            if ((BlastSpell || ActorMonster.Weapon > 0) && DobjArtifact != null && (DobjArtifact.Uid == 3 || DobjArtifact.Uid == 11 || DobjArtifact.Uid == 15))
            {
                var ac = DobjArtifact.GetArtifactCategory(new ArtifactType[] { ArtifactType.InContainer, ArtifactType.User1 });

                Debug.Assert(ac != null);

                var type = ac.Type;

                ac.Type = ArtifactType.Gold;

                base.Execute();

                ac.Type = type;
            }
            else
            {
                base.Execute();
            }
        }
Ejemplo n.º 2
0
        public override void ProcessEvents(EventType eventType)
        {
            // Plain scroll increases BLAST ability

            if (eventType == EventType.AfterReadArtifact && DobjArtifact.Uid == 29)
            {
                var spell = gEngine.GetSpells(Spell.Blast);

                Debug.Assert(spell != null);

                DobjArtifact.SetInLimbo();

                gCharacter.ModSpellAbilities(Spell.Blast, 10);

                if (gCharacter.GetSpellAbilities(Spell.Blast) > spell.MaxValue)
                {
                    gCharacter.SetSpellAbilities(Spell.Blast, spell.MaxValue);
                }

                gGameState.ModSa(Spell.Blast, 250);

                if (gGameState.GetSa(Spell.Blast) > spell.MaxValue)
                {
                    gGameState.SetSa(Spell.Blast, spell.MaxValue);
                }
            }

            base.ProcessEvents(eventType);
        }
Ejemplo n.º 3
0
        public override void Execute()
        {
            // Can't give away gold

            if (GoldAmount > 0)
            {
                gEngine.PrintEffectDesc(60);
                NextState = Globals.CreateInstance <IStartState>();
            }

            // Give necklace to Lisa

            else if (DobjArtifact?.Uid == 27 && IobjMonster?.Uid == 3 && IobjMonster.Reaction == Friendliness.Neutral)
            {
                gEngine.PrintEffectDesc(31);
                gEngine.PrintEffectDesc(32);
                gEngine.PrintEffectDesc(33);
                gEngine.PrintEffectDesc(34);
                gEngine.PrintEffectDesc(35);
                gEngine.PrintEffectDesc(36);
                gLMKKP1.NecklaceTaken = 2;
                DobjArtifact.SetCarriedByMonster(IobjMonster);
                NextState = Globals.CreateInstance <IStartState>();

                //Set damage taken to zero:
                ActorMonster.DmgTaken  = 0;
                ActorMonster.Hardiness = 55;
            }
            else
            {
                base.Execute();
            }
        }
Ejemplo n.º 4
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null);

            // Waspicide and vial

            if (DobjArtifact.Uid == 5 || DobjArtifact.Uid == 6)
            {
                DobjArtifact.SetInLimbo();

                var effectUid = 6;

                if (DobjArtifact.Uid == 6)
                {
                    effectUid = 11;

                    gGameState.DrankVial = true;
                }

                gEngine.PrintEffectDesc(effectUid);

                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
            else
            {
                base.Execute();
            }
        }
Ejemplo n.º 5
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.º 6
0
        public override void ProcessEvents(EventType eventType)
        {
            if (eventType == EventType.AfterReadArtifact)
            {
                // Scroll vanishes

                if (DobjArtifact.Uid == 3)
                {
                    DobjArtifact.SetInLimbo();
                }
            }

            base.ProcessEvents(eventType);
        }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
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();
            }
        }
Ejemplo n.º 9
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null);

            // Remove magical amulet in forest

            if (gGameState.Ro >= 65 && gGameState.Ro != 92 && gGameState.Ro != 93 && DobjArtifact.Uid == 18)
            {
                gOut.Print("If you remove {0}, you'll be paralysed with fear!", DobjArtifact.GetTheName());

                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
            else
            {
                base.Execute();
            }
        }
Ejemplo n.º 10
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null);

            // Crimson cloak boosts armor class

            if (DobjArtifact.Uid == 19 && DobjArtifact.IsCarriedByCharacter())
            {
                var armorArtifact = gGameState.Ar > 0 ? gADB[gGameState.Ar] : null;

                if (armorArtifact != null)
                {
                    armorArtifact.Wearable.Field1 += 2;
                }
                else
                {
                    DobjArtifact.Wearable.Field1 += 2;
                }
            }

            base.Execute();
        }
Ejemplo n.º 11
0
        public override void ProcessEvents(EventType eventType)
        {
            // Book

            if (eventType == EventType.AfterReadArtifact && DobjArtifact.Uid == 61)
            {
                DobjArtifact.SetInRoom(ActorRoom);

                gGameState.Ro = 58;

                gGameState.R2 = gGameState.Ro;

                NextState = Globals.CreateInstance <IAfterPlayerMoveState>(x =>
                {
                    x.MoveMonsters = false;
                });

                GotoCleanup = true;
            }
            else
            {
                base.ProcessEvents(eventType);
            }
        }
Ejemplo n.º 12
0
        public override void Execute()
        {
            RetCode rc;

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

            if (IobjMonster.Reaction < Friendliness.Friend)
            {
                gEngine.MonsterEmotes(IobjMonster);

                gOut.WriteLine();

                goto Cleanup;
            }

            if (!DobjArtifact.IsRequestable())
            {
                PrintObjBelongsToActor(DobjArtifact, IobjMonster);

                goto Cleanup;
            }

            if (!GetCommandCalled)
            {
                RedirectToGetCommand <IRequestCommand>(DobjArtifact, false);

                goto Cleanup;
            }

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

                goto Cleanup;
            }

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

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

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

                IobjMonster.Weapon = -1;
            }

            if (ActorMonster.Weapon <= 0 && DobjArtifact.IsReadyableByCharacter() && NextState == null)
            {
                NextState = Globals.CreateInstance <IReadyCommand>();

                CopyCommandData(NextState as ICommand, false);
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Ejemplo n.º 13
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null || DobjMonster != null);

            if (BlastSpell || ActorMonster.Weapon > 0)
            {
                // ATTACK/BLAST statue

                if (DobjArtifact != null && DobjArtifact.Uid == 50)
                {
                    gEngine.PrintMonsterAlive(DobjArtifact);

                    DobjArtifact.SetInLimbo();

                    var ngurctMonster = gMDB[53];

                    Debug.Assert(ngurctMonster != null);

                    ngurctMonster.SetInRoom(ActorRoom);

                    var command = Globals.CreateInstance <IAttackCommand>(x =>
                    {
                        x.BlastSpell = BlastSpell;

                        x.CheckAttack = CheckAttack;
                    });

                    CopyCommandData(command);

                    command.Dobj = ngurctMonster;

                    NextState = command;
                }

                // Fireball wand

                else if (!BlastSpell && DobjMonster != null && ActorMonster.Weapon == 63)
                {
                    gOut.Write("{0}What is the trigger word? ", Environment.NewLine);

                    Globals.Buf.SetFormat("{0}", Globals.In.ReadLine());

                    if (!Globals.Buf.ToString().Equals("fire", StringComparison.OrdinalIgnoreCase))
                    {
                        gOut.Print("Wrong!  Nothing happens!");

                        NextState = Globals.CreateInstance <IMonsterStartState>();

                        goto Cleanup;
                    }

                    if (gGameState.WandCharges <= 0)
                    {
                        gOut.Print("The fireball wand is exhausted!");

                        NextState = Globals.CreateInstance <IMonsterStartState>();

                        goto Cleanup;
                    }

                    gGameState.WandCharges--;

                    gOut.Print("The {0} is filled with an incandescent fireball!", ActorRoom.EvalRoomType("room", "area"));

                    var slaveGirlFireballCheck = false;

                    var slaveGirlArtifact = gADB[81];

                    Debug.Assert(slaveGirlArtifact != null);

                    var slaveGirlMonster = gMDB[54];

                    Debug.Assert(slaveGirlMonster != null);

                    if (slaveGirlArtifact.IsInRoom(ActorRoom))
                    {
                        slaveGirlMonster.SetInRoom(ActorRoom);

                        slaveGirlMonster.Seen = true;

                        slaveGirlFireballCheck = true;
                    }

                    var monsterList = gEngine.GetRandomMonsterList(9, m => !m.IsCharacterMonster() && m.Uid != DobjMonster.Uid && m.Seen && m.IsInRoom(ActorRoom));

                    Debug.Assert(monsterList != null);

                    if (monsterList.Count > 0)
                    {
                        monsterList.Insert(0, DobjMonster);
                    }
                    else
                    {
                        monsterList.Add(DobjMonster);
                    }

                    Globals.FireDamage = true;

                    foreach (var m in monsterList)
                    {
                        var rl = gEngine.RollDice(1, 100, 0);

                        var savedVsFire = (m.Hardiness / 4) > 4 && rl < 51;

                        gEngine.MonsterGetsAggravated(m);

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

                            x.DfMonster = m;

                            x.OmitArmor = true;
                        });

                        combatSystem.ExecuteCalculateDamage(savedVsFire ? 3 : 6, 6);

                        Globals.Thread.Sleep(gGameState.PauseCombatMs);
                    }

                    Globals.FireDamage = false;

                    if (slaveGirlFireballCheck)
                    {
                        slaveGirlMonster.Seen = false;

                        if (slaveGirlMonster.IsInLimbo())
                        {
                            slaveGirlArtifact.SetInLimbo();
                        }
                        else
                        {
                            slaveGirlMonster.SetInLimbo();
                        }
                    }

                    NextState = Globals.CreateInstance <IMonsterStartState>();

                    goto Cleanup;
                }
                else
                {
                    base.Execute();
                }
            }
            else
            {
                base.Execute();
            }

Cleanup:

            ;
        }
Ejemplo n.º 14
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>();
            }
        }
Ejemplo n.º 15
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(GoldAmount > 0 || DobjArtifact != null);

            Debug.Assert(IobjMonster != null);

            if (GoldAmount > 0)
            {
                gOut.Print("Give {0} gold piece{1} to {2}.",
                           gEngine.GetStringFromNumber(GoldAmount, false, Globals.Buf),
                           GoldAmount > 1 ? "s" : "",
                           IobjMonster.GetTheName(buf: Globals.Buf01));

                gOut.Write("{0}Are you sure (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;
                }

                if (gCharacter.HeldGold < GoldAmount)
                {
                    PrintNotEnoughGold();

                    NextState = Globals.CreateInstance <IStartState>();

                    goto Cleanup;
                }

                ProcessEvents(EventType.BeforeTakePlayerGold);

                if (GotoCleanup)
                {
                    goto Cleanup;
                }

                gOut.Print("{0} take{1} the money.",
                           IobjMonster.GetTheName(true),
                           IobjMonster.EvalPlural("s", ""));

                gCharacter.HeldGold -= GoldAmount;

                if (Globals.IsRulesetVersion(5, 25))
                {
                    IobjMonster.CalculateGiftFriendliness(GoldAmount, false);

                    IobjMonster.ResolveReaction(gCharacter);
                }
                else
                {
                    if (IobjMonster.Reaction == Friendliness.Neutral && GoldAmount > 4999)
                    {
                        IobjMonster.Friendliness = (Friendliness)200;

                        IobjMonster.Reaction = Friendliness.Friend;

                        gEngine.MonsterEmotes(IobjMonster);

                        gOut.WriteLine();
                    }
                }

                goto Cleanup;
            }

            if (DobjArtifact.IsWornByCharacter())
            {
                PrintWearingRemoveFirst(DobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

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

                goto Cleanup;
            }

            if (IobjMonster.ShouldRefuseToAcceptGift(DobjArtifact))
            {
                gEngine.MonsterEmotes(IobjMonster);

                gOut.WriteLine();

                goto Cleanup;
            }

            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));
            }

            if (gEngine.EnforceMonsterWeightLimits)
            {
                IobjMonsterInventoryWeight = 0;

                rc = IobjMonster.GetFullInventoryWeight(ref _iobjMonsterInventoryWeight, recurse: true);

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

                if (DobjArtifactWeight > IobjMonster.GetWeightCarryableGronds() || DobjArtifactWeight + IobjMonsterInventoryWeight > IobjMonster.GetWeightCarryableGronds() * IobjMonster.CurrGroupCount)
                {
                    PrintTooHeavy(DobjArtifact);

                    goto Cleanup;
                }
            }

            ProcessEvents(EventType.AfterEnforceMonsterWeightLimitsCheck);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

            if (DobjArtifact.DeadBody != null && IobjMonster.ShouldRefuseToAcceptDeadBody(DobjArtifact))
            {
                PrintPolitelyRefuses(IobjMonster);

                goto Cleanup;
            }

            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;
            }

            ProcessEvents(EventType.AfterGiveReadiedWeaponCheck);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

            PrintGiveObjToActor(DobjArtifact, IobjMonster);

            DobjArtAc = DobjArtifact.GetArtifactCategory(new ArtifactType[] { ArtifactType.Drinkable, ArtifactType.Edible });

            if (Globals.IsRulesetVersion(5, 25) || DobjArtAc == null || DobjArtAc.Field2 <= 0)
            {
                DobjArtifact.SetCarriedByMonster(IobjMonster);

                if (Globals.IsRulesetVersion(5, 25))
                {
                    IobjMonster.CalculateGiftFriendliness(DobjArtifact.Value, true);

                    IobjMonster.ResolveReaction(gCharacter);
                }
                else
                {
                    if (IobjMonster.Reaction == Friendliness.Neutral)
                    {
                        IobjMonster.Friendliness = (Friendliness)200;

                        IobjMonster.Reaction = Friendliness.Friend;

                        gEngine.MonsterEmotes(IobjMonster);

                        gOut.WriteLine();
                    }
                }

                goto Cleanup;
            }

            IobjMonsterName = IobjMonster.EvalPlural(IobjMonster.GetTheName(true), IobjMonster.GetArticleName(true, true, false, true, Globals.Buf01));

            Globals.Buf01.Clear();

            if (!DobjArtAc.IsOpen())
            {
                Globals.Buf01.SetFormat(" opens {0}", DobjArtifact.GetTheName());

                DobjArtAc.SetOpen(true);
            }

            if (DobjArtAc.Field2 != Constants.InfiniteDrinkableEdible)
            {
                DobjArtAc.Field2--;
            }

            if (DobjArtAc.Field2 > 0)
            {
                Globals.Buf.SetPrint("{0}{1}{2} takes a {3} and hands {4} back.",
                                     IobjMonsterName,
                                     Globals.Buf01,
                                     Globals.Buf01.Length > 0 ? "," : "",
                                     DobjArtAc.Type == ArtifactType.Edible ? "bite" : "drink",
                                     DobjArtifact.EvalPlural("it", "them"));
            }
            else
            {
                DobjArtifact.Value = 0;

                if (DobjArtAc.Type == ArtifactType.Edible)
                {
                    DobjArtifact.SetInLimbo();

                    Globals.Buf.SetPrint("{0}{1}{2} eats {3} all.",
                                         IobjMonsterName,
                                         Globals.Buf01,
                                         Globals.Buf01.Length > 0 ? " and" : "",
                                         DobjArtifact.EvalPlural("it", "them"));
                }
                else
                {
                    rc = DobjArtifact.AddStateDesc(DobjArtifact.GetEmptyDesc());

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

                    Globals.Buf.SetPrint("{0}{1}{2} drinks {3} all and hands {4} back.",
                                         IobjMonsterName,
                                         Globals.Buf01,
                                         Globals.Buf01.Length > 0 ? "," : "",
                                         DobjArtifact.EvalPlural("it", "them"),
                                         DobjArtifact.EvalPlural("it", "them"));
                }
            }

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

            if (DobjArtAc.Field1 == 0)
            {
                goto Cleanup;
            }

            IobjMonster.DmgTaken -= DobjArtAc.Field1;

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

            Globals.Buf.SetFormat("{0}{1} is ",
                                  Environment.NewLine,
                                  IobjMonster.GetTheName(true, true, false, true, Globals.Buf01));

            IobjMonster.AddHealthStatus(Globals.Buf);

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

            if (IobjMonster.IsDead())
            {
                gEngine.MonsterDies(ActorMonster, IobjMonster);
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Ejemplo n.º 16
0
        public override void Execute()
        {
            Debug.Assert(DropAll || DobjArtifact != null);

            if (DobjArtifact != null)
            {
                if (DobjArtifact.IsWornByCharacter())
                {
                    PrintWearingRemoveFirst(DobjArtifact);

                    NextState = Globals.CreateInstance <IStartState>();

                    goto Cleanup;
                }

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

                    goto Cleanup;
                }
            }

            ProcessLightSource();

            DroppedArtifactList = DropAll ? ActorMonster.GetCarriedList() : new List <IArtifact>()
            {
                DobjArtifact
            };

            if (DroppedArtifactList.Count <= 0)
            {
                gOut.Print("There's nothing for you to drop.");

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            foreach (var artifact in DroppedArtifactList)
            {
                ProcessArtifact(artifact);
            }

            gOut.WriteLine();

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Ejemplo n.º 17
0
        public override void Execute()
        {
            Debug.Assert(Direction == 0 || Enum.IsDefined(typeof(Direction), Direction));

            if (DobjArtifact != null && DobjArtifact.DoorGate == null)
            {
                PrintDontFollowYou();

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (!ActorMonster.CheckNBTLHostility())
            {
                PrintCalmDown();

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (DobjArtifact == null)
            {
                NumExits = 0;

                gEngine.CheckNumberOfExits(ActorRoom, ActorMonster, true, ref _numExits);

                if (NumExits == 0)
                {
                    PrintNoPlaceToGo();

                    NextState = Globals.CreateInstance <IStartState>();

                    goto Cleanup;
                }
            }

            ProcessEvents(EventType.AfterNumberOfExitsCheck);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

            if (DobjArtifact == null)
            {
                if (Direction == 0)
                {
                    RandomDirection = 0;

                    gEngine.GetRandomMoveDirection(ActorRoom, ActorMonster, true, ref _randomDirection);

                    Direction = RandomDirection;
                }

                Debug.Assert(Enum.IsDefined(typeof(Direction), Direction));
            }

            if (DobjArtifact != null)
            {
                Globals.Buf.SetFormat("{0}", DobjArtifact.GetDoorGateFleeDesc());
            }
            else if (Direction == Direction.Up || Direction == Direction.Down || Direction == Direction.In || Direction == Direction.Out)
            {
                Globals.Buf.SetFormat(" {0}ward", Direction.ToString().ToLower());
            }
            else
            {
                Globals.Buf.SetFormat(" to the {0}", Direction.ToString().ToLower());
            }

            gOut.Print("Attempting to flee{0}.", Globals.Buf);

            gGameState.R2 = DobjArtifact != null ? 0 : ActorRoom.GetDirs(Direction);

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IPlayerMoveCheckState>(x =>
                {
                    x.Direction = Direction;

                    x.DoorGateArtifact = DobjArtifact;

                    x.Fleeing = true;
                });
            }
        }
Ejemplo n.º 18
0
        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();
            }
        }
Ejemplo n.º 19
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null);

            DobjArtAc = DobjArtifact.LightSource;

            if (DobjArtAc == null)
            {
                if (ActorMonster.IsInRoomLit() || DobjArtifact.IsCarriedByCharacter())
                {
                    PrintCantVerbObj(DobjArtifact);
                }

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

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

                    goto Cleanup;
                }
            }

            if (DobjArtAc.Field1 == 0)
            {
                PrintWontLight(DobjArtifact);

                NextState = Globals.CreateInstance <IMonsterStartState>();

                goto Cleanup;
            }

            if (gGameState.Ls == DobjArtifact.Uid)
            {
                gOut.Write("{0}Extinguish {1} (Y/N): ", Environment.NewLine, DobjArtifact.GetTheName());

                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] == 'Y')
                {
                    rc = DobjArtifact.RemoveStateDesc(DobjArtifact.GetProvidingLightDesc());

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

                    gGameState.Ls = 0;

                    PrintLightExtinguished(DobjArtifact);
                }

                NextState = Globals.CreateInstance <IMonsterStartState>();

                goto Cleanup;
            }

            if (gGameState.Ls > 0)
            {
                LsArtifact = gADB[gGameState.Ls];

                Debug.Assert(LsArtifact != null && LsArtifact.LightSource != null);

                gEngine.LightOut(LsArtifact);
            }

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

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

            gGameState.Ls = DobjArtifact.Uid;

            PrintLightObj(DobjArtifact);

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Ejemplo n.º 20
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null || DobjMonster != null);

            var diaryArtifact = gADB[3];

            Debug.Assert(diaryArtifact != null);

            var wpnArtifact = ActorMonster.Weapon > 0 ? gADB[ActorMonster.Weapon] : null;

            var ac = wpnArtifact != null ? wpnArtifact.GeneralWeapon : null;

            // Find diary on dead adventurer

            if ((BlastSpell || ActorMonster.Weapon > 0) && DobjArtifact != null && DobjArtifact.Uid == 2 && diaryArtifact.IsInLimbo())
            {
                base.Execute();

                gOut.Print("Inside the tattered shirt is a small cloth-bound book that appears to be a diary.");

                diaryArtifact.SetInRoom(ActorRoom);
            }
            else if (BlastSpell)
            {
                // Blast rock

                if (DobjArtifact != null && DobjArtifact.Uid == 17)
                {
                    gEngine.PrintEffectDesc(14);

                    DobjArtifact.SetInLimbo();

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

                // Blast slime

                else if (DobjArtifact != null && (DobjArtifact.Uid == 24 || DobjArtifact.Uid == 25))
                {
                    var slimeArtifact1 = gADB[24];

                    Debug.Assert(slimeArtifact1 != null);

                    var slimeArtifact2 = gADB[25];

                    Debug.Assert(slimeArtifact2 != null);

                    gGameState.SlimeBlasts++;

                    gEngine.PrintEffectDesc(1 + gGameState.SlimeBlasts);

                    if (gGameState.SlimeBlasts == 3)
                    {
                        slimeArtifact1.SetInLimbo();

                        slimeArtifact2.SetInLimbo();
                    }

                    NextState = Globals.CreateInstance <IMonsterStartState>();
                }
                else
                {
                    base.Execute();
                }
            }

            // Attack slime will dissolve weapon (bows excluded)

            else if (DobjArtifact != null && (DobjArtifact.Uid == 24 || DobjArtifact.Uid == 25) && ac != null && ac.Field2 != (long)Weapon.Bow)
            {
                gEngine.PrintEffectDesc(18);

                if (gGameState.Ls == wpnArtifact.Uid)
                {
                    gEngine.LightOut(wpnArtifact);
                }

                wpnArtifact.SetInLimbo();

                var rc = wpnArtifact.RemoveStateDesc(wpnArtifact.GetReadyWeaponDesc());

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

                ActorMonster.Weapon = -1;

                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
            else
            {
                base.Execute();
            }
        }
Ejemplo n.º 21
0
        public override void ProcessEvents(EventType eventType)
        {
            if (eventType == EventType.AfterEnforceMonsterWeightLimitsCheck)
            {
                // Give obsidian scroll case to Emerald Warrior

                if (IobjMonster.Uid == 14 && DobjArtifact.Uid == 51)
                {
                    DobjArtifact.SetInLimbo();

                    IobjMonster.SetInLimbo();

                    gEngine.PrintEffectDesc(14);

                    GotoCleanup = true;
                }
                else
                {
                    base.ProcessEvents(eventType);
                }
            }
            else if (eventType == EventType.BeforeTakePlayerGold)
            {
                // Buy potion from gnome

                if (IobjMonster.Uid == 20)
                {
                    if (GoldAmount >= 100)
                    {
                        var redPotionArtifact = gADB[40];

                        Debug.Assert(redPotionArtifact != null);

                        var bluePotionArtifact = gADB[41];

                        Debug.Assert(bluePotionArtifact != null);

                        if (redPotionArtifact.IsCarriedByMonsterUid(20) || bluePotionArtifact.IsCarriedByMonsterUid(20))
                        {
                            gCharacter.HeldGold -= GoldAmount;

                            if (GoldAmount > 100)
                            {
                                gEngine.PrintEffectDesc(30);
                            }

                            var potionArtifact = redPotionArtifact.IsCarriedByMonsterUid(20) ? redPotionArtifact : bluePotionArtifact;

                            potionArtifact.SetInRoomUid(gGameState.Ro);

                            gEngine.PrintEffectDesc(31);

                            NextState = Globals.CreateInstance <IStartState>();
                        }
                        else
                        {
                            gEngine.PrintEffectDesc(29);
                        }
                    }
                    else
                    {
                        gEngine.PrintEffectDesc(28);
                    }

                    GotoCleanup = true;
                }
                else
                {
                    base.ProcessEvents(eventType);
                }
            }
            else
            {
                base.ProcessEvents(eventType);
            }
        }
Ejemplo n.º 22
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null);

            InContainerAc = DobjArtifact.InContainer;

            DoorGateAc = DobjArtifact.DoorGate;

            DisguisedMonsterAc = DobjArtifact.DisguisedMonster;

            DrinkableAc = DobjArtifact.Drinkable;

            EdibleAc = DobjArtifact.Edible;

            ReadableAc = DobjArtifact.Readable;

            DobjArtAc = InContainerAc != null ? InContainerAc :
                        DoorGateAc != null ? DoorGateAc :
                        DisguisedMonsterAc != null ? DisguisedMonsterAc :
                        DrinkableAc != null ? DrinkableAc :
                        EdibleAc != null ? EdibleAc :
                        ReadableAc;

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

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

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

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

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

                goto Cleanup;
            }

            KeyArtifactUid = DobjArtAc.GetKeyUid();

            KeyArtifact = KeyArtifactUid > 0 ? gADB[KeyArtifactUid] : null;

            if (DobjArtAc.IsOpen() || KeyArtifactUid == -2)
            {
                PrintAlreadyOpen(DobjArtifact);

                goto Cleanup;
            }

            if (DobjArtAc.Type == ArtifactType.Drinkable || DobjArtAc.Type == ArtifactType.Edible || DobjArtAc.Type == ArtifactType.Readable)
            {
                DobjArtAc.SetOpen(true);

                ProcessEvents(EventType.BeforePrintArtifactOpen);

                if (GotoCleanup)
                {
                    goto Cleanup;
                }

                PrintOpened(DobjArtifact);

                goto Cleanup;
            }

            if (DobjArtAc.Type == ArtifactType.InContainer && DobjArtifact.OnContainer != null && DobjArtifact.IsInContainerOpenedFromTop())
            {
                OnContainerArtifactList = DobjArtifact.GetContainedList(containerType: ContainerType.On);

                if (OnContainerArtifactList.Count > 0)
                {
                    PrintContainerNotEmpty(DobjArtifact, ContainerType.On, OnContainerArtifactList.Count > 1 || OnContainerArtifactList[0].IsPlural);

                    goto Cleanup;
                }
            }

            if (KeyArtifactUid == -1)
            {
                PrintWontOpen(DobjArtifact);

                goto Cleanup;
            }

            if (KeyArtifact != null && !KeyArtifact.IsCarriedByCharacter() && !KeyArtifact.IsWornByCharacter() && !KeyArtifact.IsInRoom(ActorRoom))
            {
                PrintLocked(DobjArtifact);

                goto Cleanup;
            }

            if (KeyArtifactUid == 0 && DobjArtAc.GetBreakageStrength() > 0)
            {
                PrintHaveToForceOpen(DobjArtifact);

                goto Cleanup;
            }

            DobjArtAc.SetKeyUid(0);

            DobjArtAc.SetOpen(true);

            ProcessEvents(EventType.BeforePrintArtifactOpen);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

            if (KeyArtifact != null)
            {
                PrintOpenObjWithKey(DobjArtifact, KeyArtifact);
            }
            else
            {
                PrintOpened(DobjArtifact);
            }

            if (DobjArtAc.Type == ArtifactType.InContainer && DobjArtifact.ShouldShowContentsWhenOpened())
            {
                NextState = Globals.CreateInstance <IInventoryCommand>();

                CopyCommandData(NextState as ICommand);
            }

            ProcessEvents(EventType.AfterOpenArtifact);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Ejemplo n.º 23
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null);

            ProcessEvents(EventType.BeforeUseArtifact);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

            DobjArtAc = DobjArtifact.GetArtifactCategory(ArtTypes, false);

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

                goto Cleanup;
            }

            if (DobjArtAc.IsWeapon01())
            {
                NextState = Globals.CreateInstance <IReadyCommand>();

                CopyCommandData(NextState as ICommand);

                goto Cleanup;
            }

            if (DobjArtAc.Type == ArtifactType.DisguisedMonster)
            {
                if (!DobjArtifact.IsUnmovable() && !DobjArtifact.IsCarriedByCharacter())
                {
                    if (DobjArtifact.IsCarriedByContainer())
                    {
                        PrintRemovingFirst(DobjArtifact);
                    }
                    else
                    {
                        PrintTakingFirst(DobjArtifact);
                    }
                }

                gEngine.RevealDisguisedMonster(ActorRoom, DobjArtifact);

                NextState = Globals.CreateInstance <IMonsterStartState>();

                goto Cleanup;
            }

            if (DobjArtAc.Type == ArtifactType.Drinkable)
            {
                NextState = Globals.CreateInstance <IDrinkCommand>();

                CopyCommandData(NextState as ICommand);

                goto Cleanup;
            }

            if (DobjArtAc.Type == ArtifactType.Edible)
            {
                NextState = Globals.CreateInstance <IEatCommand>();

                CopyCommandData(NextState as ICommand);

                goto Cleanup;
            }

            Debug.Assert(DobjArtAc.Type == ArtifactType.Wearable);

            NextState = Globals.CreateInstance <IWearCommand>();

            CopyCommandData(NextState as ICommand);

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Ejemplo n.º 24
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>();
            }
        }
Ejemplo n.º 25
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);
                });
            }
        }
Ejemplo n.º 26
0
 public override bool ShouldAllowSkillGains()
 {
     return(DobjMonster != null || DobjArtifact.IsAttackable());
 }
Ejemplo n.º 27
0
        public override void Execute()
        {
            RetCode rc;

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

            if (GetAll)
            {
                // screen out all weapons in the room which have monsters present with affinities to those weapons

                TakenArtifactList = ActorRoom.GetTakeableList().Where(a => gEngine.GetMonsterList(m => m.IsInRoom(ActorRoom) && m.Weapon == -a.Uid - 1 && m != ActorMonster).FirstOrDefault() == null).ToList();
            }
            else
            {
                TakenArtifactList = new List <IArtifact>()
                {
                    DobjArtifact
                };
            }

            if (TakenArtifactList.Count <= 0)
            {
                gOut.Print("There's nothing for you to get.");

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

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

            NewlineFlag = false;

            foreach (var artifact in TakenArtifactList)
            {
                DobjArtAc = artifact.GetArtifactCategory(ArtTypes, false);

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

                Debug.Assert(DobjArtAc != null);

                OmitWeightCheck = artifact.IsCarriedByCharacter(true);

                ProcessArtifact(artifact, DobjArtAc, ref _newlineFlag);

                if (artifact.IsCarriedByCharacter())
                {
                    // when a weapon is picked up all monster affinities to that weapon are broken

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

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

                    WeaponArtifactAc = artifact.GeneralWeapon;

                    if (artifact.IsReadyableByCharacter() && (WeaponArtifact == null || gEngine.WeaponPowerCompare(artifact, WeaponArtifact) > 0) && (!GetAll || TakenArtifactList.Count == 1 || gGameState.Sh < 1 || WeaponArtifactAc.Field5 < 2))
                    {
                        WeaponArtifact = artifact;
                    }
                }
            }

            if (NewlineFlag)
            {
                gOut.WriteLine();

                NewlineFlag = false;
            }

            if (ActorRoom.IsLit())
            {
                if (!gEngine.AutoDisplayUnseenArtifactDescs && !GetAll && DobjArtifact.IsCarriedByCharacter() && !DobjArtifact.Seen)
                {
                    Globals.Buf.Clear();

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

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

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

                    DobjArtifact.Seen = true;
                }
            }

            if (ActorMonster.Weapon <= 0 && WeaponArtifact != null && NextState == null)
            {
                RedirectCommand = Globals.CreateInstance <IReadyCommand>();

                CopyCommandData(RedirectCommand);

                RedirectCommand.Dobj = WeaponArtifact;

                NextState = RedirectCommand;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Ejemplo n.º 28
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null);

            DobjArtAc = DobjArtifact.GetArtifactCategory(ArtTypes, false);

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

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (DobjArtAc.Type == ArtifactType.Wearable)
            {
                NextState = Globals.CreateInstance <IWearCommand>();

                CopyCommandData(NextState as ICommand);

                goto Cleanup;
            }

            if (!DobjArtifact.IsReadyableByCharacter())
            {
                PrintNotReadyableWeapon(DobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

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

                goto Cleanup;
            }

            // can't use two-handed weapon while wearing shield

            if (gGameState.Sh > 0 && DobjArtAc.Field5 > 1)
            {
                ShieldArtifact = gADB[gGameState.Sh];

                Debug.Assert(ShieldArtifact != null);

                PrintCantReadyWeaponWithShield(DobjArtifact, ShieldArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            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));

            gOut.Print("{0} readied.", DobjArtifact.GetNoneName(true, false));

            ProcessEvents(EventType.AfterReadyArtifact);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Ejemplo n.º 29
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null);

            DmgTaken = ActorMonster.DmgTaken;

            var ac = DobjArtifact.Drinkable;

            // Sulphuric acid

            if (DobjArtifact.Uid == 53 && ac.IsOpen())
            {
                gEngine.PrintEffectDesc(29);

                gGameState.Die = 1;

                NextState = Globals.CreateInstance <IPlayerDeadState>(x =>
                {
                    x.PrintLineSep = true;
                });
            }

            // Human blood

            else if (DobjArtifact.Uid == 52 && ac.IsOpen())
            {
                gEngine.PrintEffectDesc(30);

                DrankItAll = true;

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

            // Wine

            else if (DobjArtifact.Uid == 69 && ac.IsOpen())
            {
                var stat = gEngine.GetStats(Stat.Agility);

                Debug.Assert(stat != null);

                gEngine.PrintEffectDesc(31);

                ActorMonster.Agility *= 2;

                ActorMonster.Agility = (long)Math.Round((double)ActorMonster.Agility / 3);

                if (ActorMonster.Agility < stat.MinValue)
                {
                    ActorMonster.Agility = stat.MinValue;
                }

                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
            else
            {
                base.Execute();
            }

            if (DrankItAll)
            {
                DobjArtifact.Value = 0;

                DobjArtifact.SetInLimbo();
            }
        }
Ejemplo n.º 30
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null);

            DrinkableAc = DobjArtifact.Drinkable;

            EdibleAc = DobjArtifact.Edible;

            DobjArtAc = DrinkableAc != null ? DrinkableAc : EdibleAc;

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

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (DobjArtAc.Type == ArtifactType.Edible)
            {
                NextState = Globals.CreateInstance <IEatCommand>();

                CopyCommandData(NextState as ICommand);

                goto Cleanup;
            }

            if (!DobjArtAc.IsOpen())
            {
                PrintMustFirstOpen(DobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (DobjArtAc.Field2 < 1)
            {
                PrintNoneLeft(DobjArtifact);

                goto Cleanup;
            }

            if (DobjArtAc.Field2 != Constants.InfiniteDrinkableEdible)
            {
                DobjArtAc.Field2--;
            }

            ProcessEvents(EventType.BeforeNowEmptyArtifactCheck);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

            if (DobjArtAc.Field2 < 1)
            {
                DobjArtifact.Value = 0;

                DobjArtifact.AddStateDesc(DobjArtifact.GetEmptyDesc());

                PrintVerbItAll(DobjArtifact);
            }
            else if (DobjArtAc.Field1 == 0)
            {
                PrintOkay(DobjArtifact);
            }

            if (DobjArtAc.Field1 != 0)
            {
                ActorMonster.DmgTaken -= DobjArtAc.Field1;

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

                if (DobjArtAc.Field1 > 0)
                {
                    PrintFeelBetter(DobjArtifact);
                }
                else
                {
                    PrintFeelWorse(DobjArtifact);
                }

                Globals.Buf.SetFormat("{0}You are ", Environment.NewLine);

                ActorMonster.AddHealthStatus(Globals.Buf);

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

                if (ActorMonster.IsDead())
                {
                    gGameState.Die = 1;

                    NextState = Globals.CreateInstance <IPlayerDeadState>(x =>
                    {
                        x.PrintLineSep = true;
                    });

                    goto Cleanup;
                }
            }

            ProcessEvents(EventType.AfterDrinkArtifact);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

Cleanup:

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