Beispiel #1
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);
            }
        }
Beispiel #2
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>();
            }
        }
Beispiel #3
0
        public override void ProcessEvents(EventType eventType)
        {
            if (eventType == EventType.AfterEnforceMonsterWeightLimitsCheck)
            {
                if (IobjMonster.Uid == 1)
                {
                    // Give death dog the dead rabbit

                    if (DobjArtifact.Uid == 15)
                    {
                        DobjArtifact.SetInLimbo();

                        IobjMonster.Friendliness = (Friendliness)150;

                        IobjMonster.ResolveReaction(gCharacter);

                        PrintGiveObjToActor(DobjArtifact, IobjMonster);

                        gEngine.PrintEffectDesc(13);

                        if (IobjMonster.Reaction == Friendliness.Friend)
                        {
                            gOut.Print("{0} barks once and wags its tail!", IobjMonster.GetTheName(true));
                        }
                    }
                    else
                    {
                        gEngine.MonsterEmotes(IobjMonster);

                        gOut.WriteLine();
                    }

                    GotoCleanup = true;
                }

                // Further disable bribing

                else if (gIobjMonster(this).ShouldRefuseToAcceptGift01(DobjArtifact))
                {
                    gEngine.MonsterEmotes(IobjMonster);

                    gOut.WriteLine();

                    GotoCleanup = true;
                }
                else
                {
                    base.ProcessEvents(eventType);
                }
            }
            else if (eventType == EventType.BeforeTakePlayerGold)
            {
                // Disable bribing

                if (IobjMonster.Uid == 1 || IobjMonster.Reaction < Friendliness.Friend)
                {
                    gEngine.MonsterEmotes(IobjMonster);

                    gOut.WriteLine();

                    GotoCleanup = true;
                }
                else
                {
                    base.ProcessEvents(eventType);
                }
            }
            else
            {
                base.ProcessEvents(eventType);
            }
        }
        public override void CheckPlayerCommand(bool afterFinishParsing)
        {
            Debug.Assert(NextCommand != null);

            if (afterFinishParsing)
            {
                // Restrict various commands while paralyzed

                if (!(NextCommand is ISmileCommand || (NextCommand.Type == CommandType.Miscellaneous && !(NextCommand is ISpeedCommand || NextCommand is IPowerCommand))) && gGameState.ParalyzedTargets.ContainsKey(gGameState.Cm))
                {
                    gOut.Print("You can't do that while paralyzed!");

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

                // Restrict GiveCommand and RequestCommand when targeting paralyzed Monster

                else if ((NextCommand is IGiveCommand || NextCommand is IRequestCommand) && IobjMonster != null && gGameState.ParalyzedTargets.ContainsKey(IobjMonster.Uid))
                {
                    gOut.Print("You can't do that while {0} {1} paralyzed!", IobjMonster.GetTheName(), IobjMonster.EvalPlural("is", "are"));

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

                // Restrict SearchCommand while enemies are present

                else if (NextCommand is ISearchCommand && gGameState.GetNBTL(Friendliness.Enemy) > 0)
                {
                    NextCommand.PrintEnemiesNearby();

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

                // Restrict Commands in the graveyard at night or in heavy fog

                else if ((NextCommand is IReadCommand || NextCommand is ISearchCommand) && gActorRoom(this).IsDimLightRoomWithoutGlowingMonsters() && gGameState.Ls <= 0)
                {
                    gOut.Print("You'll need a bit more light for that!");

                    NextState = Globals.CreateInstance <IMonsterStartState>();
                }
                else
                {
                    var waterWeirdMonster = gMDB[38];

                    Debug.Assert(waterWeirdMonster != null);

                    // Large fountain and water weird

                    if (DobjArtifact != null && DobjArtifact.Uid != 24 && DobjArtifact.Uid != 40 && IobjArtifact != null && IobjArtifact.Uid == 24)
                    {
                        if (waterWeirdMonster.IsInRoom(ActorRoom))
                        {
                            gOut.Print("{0} won't let you get close enough to do that!", waterWeirdMonster.GetTheName(true));

                            NextState = Globals.CreateInstance <IMonsterStartState>();
                        }
                        else if (!gGameState.WaterWeirdKilled)
                        {
                            gEngine.PrintEffectDesc(100);

                            waterWeirdMonster.SetInRoom(ActorRoom);

                            NextState = Globals.CreateInstance <IStartState>();
                        }
                        else
                        {
                            base.CheckPlayerCommand(afterFinishParsing);
                        }
                    }
                    else
                    {
                        base.CheckPlayerCommand(afterFinishParsing);
                    }
                }
            }
            else
            {
                base.CheckPlayerCommand(afterFinishParsing);
            }
        }
Beispiel #5
0
        public override void ProcessEvents(EventType eventType)
        {
            if (eventType == EventType.AfterEnforceMonsterWeightLimitsCheck)
            {
                // Give Prince the Runcible Cargo

                if ((IobjMonster.Uid == 38 || IobjMonster.Uid == 39) && DobjArtifact.Uid == 129)
                {
                    DobjArtifact.SetCarriedByMonsterUid(38);

                    gCharacter.HeldGold += 2000;

                    gEngine.PrintEffectDesc(132);

                    GotoCleanup = true;
                }

                // Give Bandit's Guild Commander the Runcible Cargo

                else if ((IobjMonster.Uid == 27 || IobjMonster.Uid == 28) && DobjArtifact.Uid == 129)
                {
                    gEngine.PrintEffectDesc(131);

                    NextState = Globals.CreateInstance <IStartState>();

                    GotoCleanup = true;
                }

                // Give Larkspur his pills

                else if (IobjMonster.Uid == 36 && DobjArtifact.Uid == 130)
                {
                    DobjArtifact.SetInLimbo();

                    IobjMonster.Friendliness = (Friendliness)200;

                    IobjMonster.Reaction++;

                    gEngine.PrintEffectDesc(94);

                    GotoCleanup = true;
                }

                // Further disable bribing

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

                    gOut.WriteLine();

                    GotoCleanup = true;
                }

                // Nobody wants to hold the Runcible Cargo

                else if (DobjArtifact.Uid == 129)
                {
                    gOut.Print("{0} nervously refuse{1} your offer.",
                               IobjMonster.GetTheName(true),
                               IobjMonster.EvalPlural("s", ""));

                    GotoCleanup = true;
                }
                else
                {
                    base.ProcessEvents(eventType);
                }
            }
            else if (eventType == EventType.BeforeTakePlayerGold)
            {
                // Give $ to Amazon

                if (IobjMonster.Uid == 22 && IobjMonster.Reaction == Friendliness.Friend)
                {
                    var gender = Math.Min((long)ActorMonster.Gender, 1);

                    gEngine.PrintEffectDesc(153 + gGameState.GiveAmazonMoney + gender * 2);

                    gGameState.GiveAmazonMoney = 1;

                    GotoCleanup = true;
                }

                // Disable bribing

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

                    gOut.WriteLine();

                    GotoCleanup = true;
                }
                else
                {
                    base.ProcessEvents(eventType);
                }
            }
            else
            {
                base.ProcessEvents(eventType);
            }
        }