public void StartBlockReversalLoop(SlotInput slotInput)
        {
            lock (RunBlockReversalThreadLock)
            {
                _runBlockReversalThread = true;
            }

            Thread blockReversalThread = new Thread(() =>
            {
                LogManager.Instance.WriteLine("Block Reversal Thread start");

                bool localRunBlockReversalThread = true;

                this._stroke     = this.GetReplayKeyStroke();
                int oldBlockstun = 0;

                while (localRunBlockReversalThread && !this._process.HasExited)
                {
                    try
                    {
                        int blockStun = this.GetBlockstun(2);

                        if (slotInput.WakeupFrameIndex + 2 == blockStun && oldBlockstun != blockStun)
                        {
                            this.PlayReversal();

                            Thread.Sleep(32);
                        }

                        oldBlockstun = blockStun;

                        Thread.Sleep(10);     //check about twice by frame
                    }
                    catch (Exception ex)
                    {
                        LogManager.Instance.WriteException(ex);
                        StopBlockReversalLoop();
                        BlockReversalLoopErrorOccured?.Invoke(ex);
                        return;
                    }

                    lock (RunBlockReversalThreadLock)
                    {
                        localRunBlockReversalThread = _runBlockReversalThread;
                    }

                    Thread.Sleep(1);
                }


                LogManager.Instance.WriteLine("Block Reversal Thread ended");
            })
            {
                Name = "blockReversalThread"
            };

            blockReversalThread.Start();

            this.BringWindowToFront();
        }
        public bool SetInputInSlot(int slotNumber, SlotInput slotInput)
        {
            var baseAddress = this._memoryReader.ReadWithOffsets <IntPtr>(_recordingSlotPtr);
            var slotAddress = IntPtr.Add(baseAddress, RecordingSlotSize * (slotNumber - 1));


            return(this._memoryReader.Write(slotAddress, slotInput.Content));
        }
        public void StartReversalLoop(SlotInput slotInput)
        {
            lock (RunReversalThreadLock)
            {
                _runReversalThread = true;
            }

            Thread reversalThread = new Thread(() =>
            {
                LogManager.Instance.WriteLine("Reversal Thread start");
                var currentDummy            = GetDummy();
                bool localRunReversalThread = true;

                this._stroke = this.GetReplayKeyStroke();

                while (localRunReversalThread && !this._process.HasExited)
                {
                    try
                    {
                        int wakeupTiming = GetWakeupTiming(currentDummy);


                        if (wakeupTiming != 0)
                        {
                            WaitAndReversal(slotInput, wakeupTiming);
                        }
                    }
                    catch (Exception ex)
                    {
                        LogManager.Instance.WriteException(ex);
                        StopReversalLoop();
                        ReversalLoopErrorOccured?.Invoke(ex);
                        return;
                    }

                    lock (RunReversalThreadLock)
                    {
                        localRunReversalThread = _runReversalThread;
                    }

                    Thread.Sleep(1);
                }


                LogManager.Instance.WriteLine("Reversal Thread ended");
            })
            {
                Name = "reversalThread"
            };

            reversalThread.Start();

            this.BringWindowToFront();
        }
        private void WaitAndReversal(SlotInput slotInput, int wakeupTiming)
        {
            int fc     = FrameCount();
            var frames = wakeupTiming - slotInput.WakeupFrameIndex - 1;

            while (FrameCount() < fc + frames)
            {
            }
            PlayReversal();

            Thread.Sleep(320); //20 frames, approximately, it's actually 333.333333333 ms.  Nobody should be able to be knocked down and get up in this time, causing the code to execute again.
        }
        public void StartReversalLoop(SlotInput slotInput, Action errorAction = null)
        {
            lock (RunReversalThreadLock)
            {
                _runReversalThread = true;
            }

            Thread reversalThread = new Thread(() =>
            {
                var currentDummy            = GetDummy();
                bool localRunReversalThread = true;
                _memorySharp.Write <byte>(_flagmembase, 1, false);
                _written = false;
                _memorySharp.Assembly.Inject(String.Format("jmp 0x{0}\nnop", _newmembase.ToString("X8")), _nonRelativeScriptOffset);
                while (localRunReversalThread)
                {
                    try
                    {
                        int wakeupTiming = GetWakeupTiming(currentDummy);


                        if (wakeupTiming != 0 && !_written)
                        {
                            waitAndReversal(slotInput, wakeupTiming);
                        }
                    }
                    catch (Win32Exception)
                    {
                        errorAction?.Invoke();
                    }

                    lock (RunReversalThreadLock)
                    {
                        localRunReversalThread = _runReversalThread;
                    }

                    Thread.Sleep(1);
                }

#if DEBUG
                Console.WriteLine("reversalThread ended");
#endif
            })
            {
                Name = "reversalThread"
            };

            reversalThread.Start();

            _memorySharp.Windows.MainWindow.Activate();
        }
        public bool TranslateIntoFile(string filePath, string input)
        {
            try
            {
                var slotInput = new SlotInput(input);

                return(this.WriteInputFile(filePath, slotInput.CleanInputs));
            }
            catch (Exception e)
            {
                LogManager.Instance.WriteException(e);
                return(false);
            }
        }
        public void waitAndReversal(SlotInput slotInput, int wakeupTiming)
        {
            int fc     = FrameCount();
            var frames = wakeupTiming - slotInput.WakeupFrameIndex - 1;

            while (FrameCount() < fc + frames)
            {
            }
            lock (_memorySharp)
            {
#if DEBUG
                Console.WriteLine("Reversal!");
#endif
                _memorySharp.Write <byte>(_flagmembase, 0, false);
                Thread.Sleep(320); //20 frames, approximately, it's actually 333.333333333 ms.  Nobody should be able to be knocked down and get up in this time, causing the code to execute again.
#if DEBUG
                Console.WriteLine("Reversal Wait Finished!");
#endif
            }
        }
        public void StartRandomBurstLoop(int min, int max, int replaySlot, int burstPercentage)
        {
            lock (RunRandomBurstThreadLock)
            {
                _runRandomBurstThread = true;
            }

            Thread randomBurstThread = new Thread(() =>
            {
                LogManager.Instance.WriteLine("RandomBurst Thread start");
                bool localRunRandomBurstThread = true;

                var slotInput = new SlotInput("!5HD");
                SetInputInSlot(replaySlot, slotInput);

                Random rnd = new Random();

                int valueToBurst = rnd.Next(min, max + 1);
                bool willBurst   = rnd.Next(0, 101) <= burstPercentage;

                this._stroke = this.GetReplayKeyStroke();


                while (localRunRandomBurstThread && !this._process.HasExited)
                {
                    try
                    {
                        int currentCombo = GetCurrentComboCount(1);



                        while (currentCombo > 0)
                        {
                            if (currentCombo == valueToBurst && willBurst)
                            {
                                PlayReversal();
                                Thread.Sleep(850); //50 frames, approximately, Burst recovery is around 50f.
                            }

                            currentCombo = GetCurrentComboCount(1);

                            if (currentCombo == 0)
                            {
                                valueToBurst = rnd.Next(min, max + 1);
                                willBurst    = rnd.Next(0, 101) <= burstPercentage;
                            }
                            Thread.Sleep(1);
                        }


                        lock (RunRandomBurstThreadLock)
                        {
                            localRunRandomBurstThread = _runRandomBurstThread;
                        }
                        Thread.Sleep(1);
                    }
                    catch (Exception ex)
                    {
                        LogManager.Instance.WriteException(ex);
                        StopRandomBurstLoop();
                        RandomBurstlLoopErrorOccured?.Invoke(ex);
                        return;
                    }
                }

                LogManager.Instance.WriteLine("RandomBurst Thread ended");
            })
            {
                Name = "randomBurstThread"
            };

            randomBurstThread.Start();

            this.BringWindowToFront();
        }
        public void StartWakeupReversalLoop(SlotInput slotInput, int wakeupReversalPercentage)
        {
            lock (RunReversalThreadLock)
            {
                _runReversalThread = true;
            }

            Thread reversalThread = new Thread(() =>
            {
                LogManager.Instance.WriteLine("Reversal Thread start");
                var currentDummy            = GetDummy();
                bool localRunReversalThread = true;

                Random rnd = new Random();

                bool willReversal = rnd.Next(0, 101) <= wakeupReversalPercentage;

                this._stroke = this.GetReplayKeyStroke();

                while (localRunReversalThread && !this._process.HasExited)
                {
                    try
                    {
                        int wakeupTiming = GetWakeupTiming(currentDummy);


                        if (wakeupTiming != 0)
                        {
                            int fc     = FrameCount();
                            var frames = wakeupTiming - slotInput.ReversalFrameIndex - 1;
                            while (FrameCount() < fc + frames)
                            {
                            }

                            if (willReversal)
                            {
                                PlayReversal();
                            }
                            willReversal = rnd.Next(0, 101) <= wakeupReversalPercentage;


                            Thread.Sleep(16); // ~1 frame
                            //Thread.Sleep(320); //20 frames, approximately, it's actually 333.333333333 ms.  Nobody should be able to be knocked down and get up in this time, causing the code to execute again.
                        }
                    }
                    catch (Exception ex)
                    {
                        LogManager.Instance.WriteException(ex);
                        StopReversalLoop();
                        ReversalLoopErrorOccured?.Invoke(ex);
                        return;
                    }

                    lock (RunReversalThreadLock)
                    {
                        localRunReversalThread = _runReversalThread;
                    }

                    Thread.Sleep(1);
                }


                LogManager.Instance.WriteLine("Reversal Thread ended");
            })
            {
                Name = "reversalThread"
            };

            reversalThread.Start();

            this.BringWindowToFront();
        }
Beispiel #10
0
        public void StartReversalLoop(SlotInput slotInput, Action errorAction = null)
        {
            lock (RunReversalThreadLock)
            {
                _runReversalThread = true;
            }

            Thread reversalThread = new Thread(() =>
            {
                var currentDummy            = GetDummy();
                bool localRunReversalThread = true;
                _memorySharp.Assembly.Inject(String.Format("jmp 0x{0}", _newmembase.ToString("X8")), _nonRelativeScriptOffset);
                while (localRunReversalThread)
                {
                    try
                    {
                        int wakeupTiming = GetWakeupTiming(currentDummy);


                        if (wakeupTiming != 0)
                        {
                            Thread waitThread = new Thread(() =>
                            {
                                int fc     = FrameCount();
                                var frames = wakeupTiming - slotInput.WakeupFrameIndex - 1;
                                while (FrameCount() < fc + frames)
                                {
                                }
                            })
                            {
                                Name = "waitThread"
                            };
                            waitThread.Start();
                            waitThread.Join();


                            PlayReversal();
                        }
                    }
                    catch (Win32Exception)
                    {
                        errorAction?.Invoke();
                    }

                    lock (RunReversalThreadLock)
                    {
                        localRunReversalThread = _runReversalThread;
                    }

                    Thread.Sleep(1);
                }

#if DEBUG
                Console.WriteLine("reversalThread ended");
#endif
            })
            {
                Name = "reversalThread"
            };

            reversalThread.Start();

            _memorySharp.Windows.MainWindow.Activate();
        }