private void Timer_Tick(object sender, EventArgs e) { try { myProcess = Process.GetProcessesByName(processName).FirstOrDefault(); if (myProcess != null) { if (foundProcess == false) { TTimer.Interval = 1000; } foundProcess = true; } else { foundProcess = false; } if (foundProcess) { // The game is running, ready for memory reading. LB_Running.Text = processName + " is running"; LB_Running.ForeColor = Color.Green; cpHex = Trainer.ReadPointerByteArray(myProcess, checkpointHex, 16); inCutsceneInt = Trainer.ReadPointerInteger(myProcess, inCutscene); positionAddress.ReadSet(myProcess, out readCoordX, out readCoordY, out readCoordZ); if (!cpHex[0].Equals(0x00) && readCoordX == 0 && readCoordY == 0 && readCoordZ == 0 && inCutsceneInt != 0) { //player has checkpoint reloaded when not in a cutscene, reset the counter for checkpoints they have seen in this checkpoint cutscenesSeen = 0; } if (cpHex[0].Equals(0x00)) { shouldSkip = false; // dont skip cutscenes when loading to and from the main menu } if (inCutsceneInt == 0 && shouldSkip && CheckpointLookup.getCutsceneCountForCheckpoint(cpHex) == cutscenesSeen) { bool val = CheckpointLookup.swapCheckPointIfInTable(myProcess, checkpointHex, cpHex); shouldSkip = !val; if (shouldSkip) { // if the swap is called and does not swap, just increment the cutscene counter cutscenesSeen++; } else { // if the swap is called and does swap, stop the counter from incrementing til the checkpoint is reloaded shouldIncrementCounter = false; } } else { if (inCutsceneInt != 0) { shouldSkip = true; shouldIncrementCounter = true; } else if (shouldIncrementCounter == true) // if your in a cutscene, and havent already incremented the counter for this cutscene, increment it { cutscenesSeen++; shouldIncrementCounter = false; } } //reset the cutscene count when the checkpoint changes if (!byteArrayEquals(cpHex, lastcpHex)) { lastcpHex = cpHex; cutscenesSeen = 0; } //Checkpoint specific fixes //Before final boss, first time you enter this cutscene the checkpoint fires in the cutscene itself, but the checkpoint loads you before the cutscene // this leads to different cutscene counts if you die or reload in that jump sequence. // this will increment the value up to what its meant to be in the first instance if (byteArrayEquals(cpHex, new byte[] { 0xDB, 0xFE, 0xA0, 0x31, 0x50, 0xE8, 0x28, 0xF6, 0x59, 0x4D, 0x55, 0x52, 0x50, 0x48, 0x59, 0x30 }) && inCutsceneInt == 0 && cutscenesSeen == 0) { cutscenesSeen++; } ShouldReload.Text = shouldSkip ? "Waiting for cutscene to skip" : "Checkpoint reload to skip this cutscene!"; ShouldReload.ForeColor = shouldSkip ? Color.Red : Color.Green; StringBuilder hex = new StringBuilder(cpHex.Length * 2); foreach (byte b in cpHex) { hex.AppendFormat("{0:x2} ", b); } CheckpointVal.Text = cutscenesSeen + " " + hex.ToString(); InCutsceneBool.Text = inCutsceneInt == 0 ? "True" : "False"; TTimer.Interval = 100; } else { // The game process has not been found, reseting values. LB_Running.Text = processName + " is not running"; LB_Running.ForeColor = Color.Red; ResetValues(); } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } }
/*------------------ * -- INITIALIZATION -- * ------------------*/ public MainForm() { InitializeComponent(); CheckpointLookup.initialiseSwapTable(); }