public override void ProcessEvents(long eventType) { if (eventType == PeBeforeCommandPromptPrint && ShouldPreTurnProcess()) { var characterMonster = gMDB[gGameState.Cm]; Debug.Assert(characterMonster != null); var room = characterMonster.GetInRoom(); Debug.Assert(room != null); // Special events part 2 // ----------------------- // Dream effects if (room.Uid < 7) { if (gGameState.DreamCounter == 4) { gEngine.PrintEffectDesc(1); } if (gGameState.DreamCounter == 8) { gEngine.PrintEffectDesc(2); } if (gGameState.DreamCounter == 12) { gEngine.PrintEffectDesc(3); } gGameState.DreamCounter++; } var fortunetellerArtifact = gADB[101]; Debug.Assert(fortunetellerArtifact != null); // Swarmy if (room.Uid == 66 && fortunetellerArtifact.IsInRoom(room)) { if (gGameState.SwarmyCounter == 1) { gEngine.PrintEffectDesc(91); } gGameState.SwarmyCounter++; if (gGameState.SwarmyCounter > 3) { gGameState.SwarmyCounter = 1; } } // In the burning room if (room.Uid == 7) { gEngine.PrintEffectDesc(13); var combatSystem = Globals.CreateInstance <ICombatSystem>(x => { x.SetNextStateFunc = s => NextState = s; x.DfMonster = characterMonster; x.OmitArmor = true; }); combatSystem.ExecuteCalculateDamage(1, 1); if (gGameState.Die > 0) { GotoCleanup = true; goto Cleanup; } } var hokasTokasMonster = gMDB[4]; Debug.Assert(hokasTokasMonster != null); // Hokas scolds you if (room.Uid == 8 && gGameState.R3 == 9 && hokasTokasMonster.IsInRoom(room)) { hokasTokasMonster.SetInRoomUid(1); gEngine.PrintEffectDesc(11); NextState = Globals.CreateInstance <IStartState>(); GotoCleanup = true; goto Cleanup; } var ovenArtifact = gADB[80]; Debug.Assert(ovenArtifact != null); var ac = ovenArtifact.InContainer; Debug.Assert(ac != null); var billMonster = gMDB[23]; Debug.Assert(billMonster != null); // Bill in oven if (room.Uid == 55 && !ac.IsOpen() && !billMonster.Seen) { gEngine.PrintEffectDesc(52); } // Bandit camp if (room.Uid == 59 && gGameState.R3 == 58) { gGameState.R3 = 59; gEngine.PrintEffectDesc(71 + gGameState.CargoInRoom); } var westernDoorArtifact = gADB[112]; Debug.Assert(westernDoorArtifact != null); var easternDoorArtifact = gADB[113]; Debug.Assert(easternDoorArtifact != null); ac = easternDoorArtifact.DoorGate; Debug.Assert(ac != null); // University doors if (room.Uid == 74 && billMonster.IsInRoom(room) && ac.GetKeyUid() == -1) { ac.SetKeyUid(0); ac.SetOpen(true); gEngine.PrintEffectDesc(86); } if (room.Uid == 74 && (gGameState.R3 == 85 || gGameState.R3 == 79)) { var doorArtifact = easternDoorArtifact; var effectUid = 87L; if (gGameState.R3 == 79) { doorArtifact = westernDoorArtifact; effectUid = 152; } gGameState.R3 = room.Uid; Debug.Assert(doorArtifact != null); ac = doorArtifact.DoorGate; Debug.Assert(ac != null); if (!ac.IsOpen()) { ac.SetKeyUid(0); ac.SetOpen(true); gEngine.PrintEffectDesc(effectUid); } } var jailCellArtifact = gADB[41]; Debug.Assert(jailCellArtifact != null); ac = jailCellArtifact.InContainer; Debug.Assert(ac != null); var lilMonster = gMDB[37]; Debug.Assert(lilMonster != null); // Lil in jail if (room.Uid == 102 && !ac.IsOpen() && !lilMonster.Seen) { gEngine.PrintEffectDesc(122); } var amazonMonster = gMDB[22]; Debug.Assert(amazonMonster != null); // Amazon and Bill if (amazonMonster.IsInRoom(room) && billMonster.IsInRoom(room) && !gGameState.BillAndAmazonMeet) { gEngine.PrintEffectDesc(53); gGameState.BillAndAmazonMeet = true; } var princeAndGuardsDead = false; var commanderMonster = gMDB[27]; Debug.Assert(commanderMonster != null); var soldiersMonster = gMDB[28]; Debug.Assert(soldiersMonster != null); // Bandit Commander and all soldiers are dead! var commanderAndSoldiersDead = commanderMonster.IsInLimbo() && soldiersMonster.IsInLimbo(); if (!commanderAndSoldiersDead) { var princeMonster = gMDB[38]; Debug.Assert(princeMonster != null); var guardsMonster = gMDB[39]; Debug.Assert(guardsMonster != null); // Bandit Prince and all Praetorian Guards are dead! princeAndGuardsDead = princeMonster.IsInLimbo() && guardsMonster.IsInLimbo(); } if (commanderAndSoldiersDead || princeAndGuardsDead) { var effectUid = commanderAndSoldiersDead ? 60L : 142L; gOut.Print("{0}", Globals.LineSep); gEngine.PrintEffectDesc(effectUid); Globals.In.KeyPress(Globals.Buf); gGameState.Die = 0; Globals.ExitType = ExitType.FinishAdventure; Globals.MainLoop.ShouldShutdown = true; NextState = Globals.CreateInstance <IStartState>(); GotoCleanup = true; goto Cleanup; } // Amazon and Bill warn about Lil if (lilMonster.IsInRoom(room)) // && (room.Uid == 18 || room.Uid == 21 || room.Uid == 38 || room.Uid == 53) { if (!gGameState.AmazonLilWarning && amazonMonster.IsInRoom(room) && room.Uid != 50 && room.IsLit()) { gEngine.PrintEffectDesc(117); gGameState.AmazonLilWarning = true; } if (!gGameState.BillLilWarning && billMonster.IsInRoom(room) && room.Uid != 55 && room.IsLit()) { gEngine.PrintEffectDesc(118); gGameState.BillLilWarning = true; } } var cargoArtifact = gADB[129]; Debug.Assert(cargoArtifact != null); var explosiveDeviceArtifact = gADB[43]; Debug.Assert(explosiveDeviceArtifact != null); var remoteDetonatorArtifact = gADB[45]; Debug.Assert(remoteDetonatorArtifact != null); // Bill (or Amazon) hint at using explosives if (room.Uid == 92 && (cargoArtifact.IsInRoom(room) || cargoArtifact.IsCarriedByCharacter()) && (explosiveDeviceArtifact.IsInRoom(room) || explosiveDeviceArtifact.IsCarriedByCharacter()) && (remoteDetonatorArtifact.IsInRoom(room) || remoteDetonatorArtifact.IsCarriedByCharacter())) { var effectUid = 0L; if (amazonMonster.IsInRoom(room) && amazonMonster.Friendliness > Friendliness.Enemy) { effectUid = 124; } if (billMonster.IsInRoom(room) && billMonster.Friendliness > Friendliness.Enemy) { effectUid = 123; } if (effectUid > 0 && !gGameState.Explosive) { gEngine.PrintEffectDesc(effectUid); gGameState.Explosive = true; } } Eamon.Framework.Primitive.Classes.IArtifactCategory ac01 = null; // Maintenance grate, sewer grate, and (Barney) Rubble var doubleDoors = Globals.DoubleDoors.Where(dd => dd.RoomUid == room.Uid).ToList(); foreach (var dd in doubleDoors) { var doorArtifact = gADB[dd.ArtifactUid1]; Debug.Assert(doorArtifact != null); var doorArtifact01 = gADB[dd.ArtifactUid2]; Debug.Assert(doorArtifact01 != null); ac = doorArtifact.DoorGate; Debug.Assert(ac != null); ac01 = doorArtifact01.DoorGate; Debug.Assert(ac01 != null); doorArtifact01.Seen = doorArtifact.Seen; doorArtifact01.StateDesc = Globals.CloneInstance(doorArtifact.StateDesc); ac01.Field2 = ac.Field2; ac01.Field3 = ac.Field3; } } base.ProcessEvents(eventType); Cleanup: ; }
public override void ProcessEvents(EventType eventType) { RetCode rc; var gameState = Globals.GameState as Framework.IGameState; Debug.Assert(gameState != null); if (eventType == EventType.BeforePrintPlayerRoom && ShouldPreTurnProcess()) { var charMonster = gMDB[gameState.Cm]; Debug.Assert(charMonster != null); var room = charMonster.GetInRoom(); Debug.Assert(room != null); // Special events part 1 // ----------------------- // Move from dream to fire if (room.Uid < 7 && gameState.DreamCounter >= 13) { var lookCommand = Globals.LastCommand as ILookCommand; if (lookCommand != null) { Globals.Engine.PrintPlayerRoom(); } // Globals.SentenceParser.PrintDiscardingCommands() not called for this abrupt reality shift Globals.SentenceParser.Clear(); // Nothing in the dream affects the real world; revert game state now that player is awake var filesetTable = Globals.CloneInstance(Globals.Database.FilesetTable); Debug.Assert(filesetTable != null); var gameState01 = Globals.CloneInstance(gameState); Debug.Assert(gameState01 != null); rc = Globals.PopDatabase(); Debug.Assert(Globals.Engine.IsSuccess(rc)); rc = Globals.RestoreDatabase(Constants.SnapshotFileName); Debug.Assert(Globals.Engine.IsSuccess(rc)); Globals.Database.FilesetTable = filesetTable; Globals.Config = Globals.Engine.GetConfig(); Globals.Character = Globals.Database.CharacterTable.Records.FirstOrDefault(); Globals.Module = Globals.Engine.GetModule(); Globals.GameState = Globals.Engine.GetGameState(); gameState = Globals.GameState as Framework.IGameState; gameState.PookaMet = Globals.CloneInstance(gameState01.PookaMet); gameState.Ro = 7; gameState.R2 = 7; gameState.R3 = 7; gameState.Vr = gameState01.Vr; gameState.Vm = gameState01.Vm; gameState.Va = gameState01.Va; gameState.MatureContent = gameState01.MatureContent; gameState.EnhancedParser = gameState01.EnhancedParser; gameState.ShowPronounChanges = gameState01.ShowPronounChanges; gameState.ShowFulfillMessages = gameState01.ShowFulfillMessages; gameState.PauseCombatMs = gameState01.PauseCombatMs; charMonster = Globals.MDB[gameState.Cm]; room = Globals.RDB[gameState.Ro]; charMonster.SetInRoom(room); // TODO: determine if AfterPlayerMoveState is needed Globals.Engine.PrintEffectDesc(7); } // Out the burning window if (room.Uid == 8 && !gameState.FireEscaped) { gEngine.PrintEffectDesc(8); gameState.FireEscaped = true; } Eamon.Framework.Primitive.Classes.IArtifactCategory ac = null; // Shop doors if (gameState.R3 == 19 && (room.Uid == 12 || room.Uid == 20)) { gameState.R3 = 12; var shopDoorArtifact = gADB[room.Uid == 20 ? 136 : 17]; Debug.Assert(shopDoorArtifact != null); ac = shopDoorArtifact.DoorGate; Debug.Assert(ac != null); ac.SetOpen(false); gEngine.PrintEffectDesc(48); } // Out the Window of Ill Repute if (gameState.R3 == 18 && room.Uid == 50 && !gameState.AmazonMet) { gEngine.PrintEffectDesc(47); gameState.AmazonMet = true; } // Bandit camp if (room.Uid == 59 && !gameState.CampEntered) { gameState.R3 *= gameState.CargoInRoom; gEngine.PrintEffectDesc(68); gameState.CampEntered = true; } var larkspurMonster = gMDB[36]; Debug.Assert(larkspurMonster != null); // Meet Larkspur if (room.Uid == 88 && larkspurMonster.IsInRoom(room) && !larkspurMonster.Seen) { gEngine.PrintEffectDesc(92); } var lilMonster = gMDB[37]; Debug.Assert(lilMonster != null); var cargoArtifact = gADB[129]; Debug.Assert(cargoArtifact != null); // Lil steals Runcible Cargo if (room.Uid != 102 && room.Uid != 43 && (room.Uid < 86 || room.Uid > 88)) { if ((cargoArtifact.IsInRoom(room) || cargoArtifact.IsCarriedByCharacter()) && lilMonster.IsInRoom(room)) { cargoArtifact.SetCarriedByMonster(lilMonster); gEngine.PrintEffectDesc(119); lilMonster.Friendliness = (Friendliness)100; lilMonster.Reaction = Friendliness.Enemy; } } var princeMonster = gMDB[38]; Debug.Assert(princeMonster != null); // The Prince would like the Cargo, please if (room.Uid == 96 && princeMonster.IsInRoom(room) && !gameState.PrinceMet) { gameState.R3 = 96; gEngine.PrintEffectDesc(125); gameState.PrinceMet = true; } if (room.Uid == 96 && gameState.R3 == 95 && princeMonster.IsInRoom(room) && princeMonster.Reaction > Friendliness.Enemy && !cargoArtifact.IsCarriedByMonster(princeMonster) && gameState.PrinceMet) { gameState.R3 = 96; gEngine.PrintEffectDesc(127); } var guardsMonster = gMDB[39]; Debug.Assert(guardsMonster != null); var gatesArtifact = gADB[137]; Debug.Assert(gatesArtifact != null); // Gates of Frukendorf slam shut if (room.Uid == 93 && cargoArtifact.IsCarriedByMonster(princeMonster) && princeMonster.Reaction > Friendliness.Enemy && !guardsMonster.IsInLimbo()) { ac = gatesArtifact.DoorGate; Debug.Assert(ac != null); if (ac.IsOpen()) { ac.SetOpen(false); gEngine.PrintEffectDesc(140); } } ac = cargoArtifact.InContainer; Debug.Assert(ac != null); // Cargo open counter if ((cargoArtifact.IsInRoom(room) || cargoArtifact.IsCarriedByCharacter()) && ac.IsOpen()) { gameState.CargoOpenCounter++; if (gameState.CargoOpenCounter == 3) { ac.SetOpen(false); gEngine.PrintEffectDesc(130); } } } base.ProcessEvents(eventType); }