private KeyboardMovementInput ProcessInputForLocalPlayer(GameTime gameTime, InputInformation inputInfo) { KeyboardMovementInput input = new KeyboardMovementInput(); // Keyboard/Dpad controls if (inputInfo.CurrentKeyboardState.IsKeyDown(Keys.Left) || inputInfo.CurrentGamePadState.DPad.Left == ButtonState.Pressed) { input.LeftPressed = true; } if (inputInfo.CurrentKeyboardState.IsKeyDown(Keys.Right) || inputInfo.CurrentGamePadState.DPad.Right == ButtonState.Pressed) { input.RightPressed = true; } if (inputInfo.CurrentKeyboardState.IsKeyDown(Keys.Up) || inputInfo.CurrentGamePadState.DPad.Up == ButtonState.Pressed) { input.UpPressed = true; } if (inputInfo.CurrentKeyboardState.IsKeyDown(Keys.Down) || inputInfo.CurrentGamePadState.DPad.Down == ButtonState.Pressed) { input.DownPressed = true; } if (inputInfo.CurrentKeyboardState.IsKeyDown(Keys.Space) || inputInfo.CurrentGamePadState.Buttons.X == ButtonState.Pressed) { var laser = _laserManager.FireLocalLaserClient(gameTime, _localPlayer.Position, _localPlayer.Rotation, _playerColours[_localPlayer.NetworkID]); if (laser != null) { input.FirePressed = true; var dataPacket = _localPlayer.BuildUpdatePacket(); PlayerFiredPacket packet = NetworkPacketFactory.Instance.MakePlayerFiredPacket(dataPacket.XPosition, dataPacket.YPosition, dataPacket.Speed, dataPacket.Rotation); packet.TotalGameTime = (float)gameTime.TotalGameTime.TotalSeconds; // TOTAL GAME TIME NOT ELAPSED TIME! packet.LaserID = laser.LaserID; // Send the packet to the server SendMessageToTheServer(packet, MessageType.GI_ClientSend_PlayerFired); } } if (Application.APPLY_CLIENT_SIDE_PREDICTION) { _localPlayer.ApplyInputToPlayer(input, (float)gameTime.ElapsedGameTime.TotalSeconds); _localPlayer.Update((float)gameTime.ElapsedGameTime.TotalSeconds); } _localPlayer.UpdateAnimation(gameTime); return(input); }
public GameScreen Update(GameTime gameTime) { weapon.Update(); testFigure.Update(); dummyFigure.Update(); // These two lines stay here, even after we delete testing stuff world.Step((float)gameTime.ElapsedGameTime.TotalSeconds); return(this); }
//Updates the game when the player is alive. private void UpdateGameStateAlive() { while (SDL.SDL_PollEvent(out SDL.SDL_Event e) != 0) { localPlayer.HandleEvents(e); if (Hardware.IsKeyPressed(SDL.SDL_Keycode.SDLK_ESCAPE, e)) { Disconnect(); } } //Update the players and bullet positions localPlayer.SetAngle(camera); localPlayer.Update(deltaTime, map.Hitboxes); localPlayer.Shoot(camera); camera.SetPos(localPlayer, Player.SPRITE_WIDTH, Player.SPRITE_HEIGHT); players.Update(deltaTime); bullets.Update(deltaTime); }
internal static void Loop() { var x = Memory.Read <IntPtr>(EngineDll.BaseAddress + Offsets.signatures.dwClientState, false); var f = Memory.Read <int>(x + 0x100, false); if (f != 6) { return; } LocalPlayer.Update(); Entities.Update(); Crosshair.Update(); // TODO!! Make better aimbot //foreach (var enemies in Entities.Entities) //foreach (var player in LocalPlayer.Localplayer) //{ // //Console.WriteLine(player.CurrentWeapon); // if (enemies.Health <= 1) continue; // var currentViewAngle = player.ViewAngles; // var localHeadPos = player.LocalEyePosition; // var enemyHeadPos = enemies.BonePosition(8); // var calculatedAngle = localHeadPos.CalcAngle(enemyHeadPos); // var clampedAngle = calculatedAngle.ClampAngle(); // var Fov = // System.Math.Sqrt(System.Math.Pow(clampedAngle.X - currentViewAngle.X, 2) + // System.Math.Pow(clampedAngle.Y - currentViewAngle.Y, 2)); // var IsDown = (Vector3.GetKeyState(0x01) & 0xFF00) != 0; // if (!(Fov < 2)) continue; // if (IsDown) // { // } // } //Bunnyhop.Activated(); //TriggerBot.Activated(); Bspotted.Activated(); }
/// <summary> /// Updates the scene. /// </summary> /// <param name="gameTime">Game frame interval.</param> public void Update(GameTime gameTime) { // Update networking NetworkManager.HandleIncomingMessages(); // Update input InputState io = LocalPlayer.Update(gameTime); if (io != null) { // Send to game server NetworkHandler.SendMessage(PacketWriter.UpdatePlayerInput(io)); } // Update entities EntityManager.Update(gameTime, Camera); // Update GUI Gui.Update(gameTime); }
private void SetupInstance() { _device = new D2DDevice(new DeviceOptions { AntiAliasing = true, Hwnd = _window.WindowHandle, MeasureFps = true, MultiThreaded = false, VSync = false }); _procUtils = new ProcUtils(ProcessName, WinApi.ProcessAccessFlags.VirtualMemoryRead | WinApi.ProcessAccessFlags.VirtualMemoryWrite | WinApi.ProcessAccessFlags.VirtualMemoryOperation); MemUtils.Handle = _procUtils.Handle; _frameTimer = new FrameTimer(_device, 100); _window.OnWindowBoundsChanged += _window_OnWindowBoundsChanged; _initializeGraphicObjects = true; _frameTimer.OnFrameStarting += _frameTimer_OnFrameStarting; _frameTimer.OnFrame += _frameTimer_OnFrame; _frameTimer.Start(); Task.Run(async() => { while (true) { var targetWnd = Managed.FindWindow(GameClass, GameName); if (targetWnd != IntPtr.Zero) { Managed.GetWindowRect(targetWnd, out var targetSize); if (targetSize.Left < 0 && targetSize.Top < 0 && targetSize.Right < 0 && targetSize.Bottom < 0 || GetWindow() != ProcessName || !IsGameRun()) { CanDraw = false; } else { CanDraw = true; } } else { CanDraw = false; } await Task.Delay(500); } }); LocalPlayer = new LocalPlayer(); Players = new List <Player>(); for (var i = 0; i < MaxPlayersOnMap; i++) { var p = new Player(i); if (p.Entity == LocalPlayer.Entity) { continue; } Players.Add(p); } Task.Run(async() => { while (!IsInGame()) { await Task.Delay(500); } LocalPlayer.Update(); Loaded(); }); }
private void Loaded() { Task.Run(async() => { while (true) { if (InGame) { LocalPlayer.Update(); foreach (var player in Players) { player.Update(); } if (Program.IsEspEnabled) { foreach (var justEntity in ListOfGlow.ToList()) { justEntity.Update(); } } await Task.Delay(1); } else { await Task.Delay(100); } } }); Task.Run(async() => { while (true) { if (Program.IsTriggerBot && InGame) { if (LocalPlayer.PlayerInCrosshair != null) { var myWeapon = LocalPlayer.GetCurrentWeapon(); if (myWeapon == WeaponHandler.ItemDefinitionIndex.WeaponAwp || myWeapon == WeaponHandler.ItemDefinitionIndex.WeaponScar20 || myWeapon == WeaponHandler.ItemDefinitionIndex.WeaponG3sg1 || myWeapon == WeaponHandler.ItemDefinitionIndex.WeaponSsg08) { if (LocalPlayer.IsScoping()) { WinApi.mouse_event(WinApi.MOUSEEVENTF.LEFTDOWN, 0, 0, 0, 0); await Task.Delay(1); WinApi.mouse_event(WinApi.MOUSEEVENTF.LEFTUP, 0, 0, 0, 0); } } else { WinApi.mouse_event(WinApi.MOUSEEVENTF.LEFTDOWN, 0, 0, 0, 0); await Task.Delay(1); WinApi.mouse_event(WinApi.MOUSEEVENTF.LEFTUP, 0, 0, 0, 0); } } } else { await Task.Delay(100); } } }); Task.Run(async() => { while (true) { if (Program.IsAimEnabled && Program.IsAimInAction && InGame) { if (IsCanNewTarget) { foreach (var player in Players.Where(x => x.IsValid && x.IsEnemy && x.IsAlive)) { var w2SHead = MathUtils.WorldToScreen(LocalPlayer.ViewMatrix, new Vector2(_sizeX, _sizeY), player.GetEntityBonePosition(8)); FindClosest(player, w2SHead); } } if (Closed != null) { IsCanNewTarget = false; } if (Closed == null || LocalPlayer.GetWeaponClip() <= 0 || !Closed.IsAlive || !Closed.IsValid) { Closed = null; continue; } AimFunction(); } else { IsCanNewTarget = true; Closed = null; await Task.Delay(1); } } }); Task.Run(async() => { var ignoreClassList = new List <int>() { 38, 50, 139, 242 }; while (true) { if (Program.IsEspEnabled && InGame) { var glowObj = MemUtils.ReadInt32(Client + Signatures.dwGlowObjectManager); var glowCount = MemUtils.ReadInt32(Client + Signatures.dwGlowObjectManager + 4); /*Printer.PrintInfo($"GlowCOunt: {glowCount}"); * Printer.PrintInfo( * $"Classes {MemUtils.ReadString(Client + Signatures.dwGetAllClasses, 128, Encoding.ASCII)}");*/ for (var i = 0; i <= glowCount; i++) { var entity = MemUtils.ReadInt32((IntPtr)(glowObj + i * 0x38)); if (entity == 0) { continue; } var one = MemUtils.ReadInt32((IntPtr)(entity + 8)); var two = MemUtils.ReadInt32((IntPtr)(one + 2 * 4)); var three = MemUtils.ReadInt32((IntPtr)(two + 1)); var classId = MemUtils.ReadInt32((IntPtr)(three + 20)); //Printer.PrintInfo($"[{i}] Entity: {entity} | {one} | {two} | {three} | {classId}"); if (classId > 0 && ignoreClassList.All(x => x != classId)) { if (!ListOfGlow.Any(x => x.Entity.Equals(entity))) { ListOfGlow.Add(new JustEntity(entity)); } MemUtils.WriteFloat((IntPtr)(glowObj + i * 0x38 + 0x4), 255); MemUtils.WriteFloat((IntPtr)(glowObj + i * 0x38 + 0x8), 0); MemUtils.WriteFloat((IntPtr)(glowObj + i * 0x38 + 0xC), 255); MemUtils.WriteFloat((IntPtr)(glowObj + i * 0x38 + 0x10), 255); MemUtils.Write((IntPtr)(glowObj + i * 0x38 + 0x24), new byte[] { 1 }); MemUtils.Write((IntPtr)(glowObj + i * 0x38 + 0x25), new byte[] { 0 }); } } foreach (var p in Players.Where(x => x.IsValid && x.IsAlive)) { var glowIndex = MemUtils.ReadInt32((IntPtr)(p.Entity + Netvars.m_iGlowIndex)); if (p.IsAlly) { MemUtils.WriteFloat((IntPtr)(glowObj + glowIndex * 0x38 + 0x4), 0); MemUtils.WriteFloat((IntPtr)(glowObj + glowIndex * 0x38 + 0x8), 155); MemUtils.WriteFloat((IntPtr)(glowObj + glowIndex * 0x38 + 0xC), 255); MemUtils.WriteFloat((IntPtr)(glowObj + glowIndex * 0x38 + 0x10), 255); MemUtils.Write((IntPtr)(glowObj + glowIndex * 0x38 + 0x24), new byte[] { 1 }); MemUtils.Write((IntPtr)(glowObj + glowIndex * 0x38 + 0x25), new byte[] { 0 }); } else { MemUtils.WriteFloat((IntPtr)(glowObj + glowIndex * 0x38 + 0x4), 255); MemUtils.WriteFloat((IntPtr)(glowObj + glowIndex * 0x38 + 0x8), 0); MemUtils.WriteFloat((IntPtr)(glowObj + glowIndex * 0x38 + 0xC), 0); MemUtils.WriteFloat((IntPtr)(glowObj + glowIndex * 0x38 + 0x10), 255); MemUtils.Write((IntPtr)(glowObj + glowIndex * 0x38 + 0x24), new byte[] { 1 }); MemUtils.Write((IntPtr)(glowObj + glowIndex * 0x38 + 0x25), new byte[] { 0 }); } } } await Task.Delay(10); } }); Task.Run(async() => { while (true) { if (!Program.IsBunnyHopEnabled || !Program.IsBunnyHopSpaced || !LocalPlayer.IsValid || !LocalPlayer.IsAlive) { continue; } var flags = MemUtils.ReadInt32((IntPtr)LocalPlayer.Entity + Netvars.m_fFlags); if (flags == (int)FlagType.Jump) { continue; } MemUtils.WriteInt32(Client + Signatures.dwForceJump, 5); await Task.Delay(25); MemUtils.WriteInt32(Client + Signatures.dwForceJump, 4); await Task.Delay(50); } }); Task.Run(async() => { while (true) { var newInGame = IsInGame(); if (newInGame && newInGame != InGame) { ClientState = MemUtils.ReadInt32(Engine + Signatures.dwClientState); _mapName = MemUtils.ReadString((IntPtr)ClientState + Signatures.dwClientState_Map, 32, Encoding.ASCII).TrimStart('_'); Players.Clear(); MaxPlayersOnMap = GetMapPlayers(); Printer.PrintSuccess($"NewMapLoaded: {_mapName} (MaxPlayers: {_mapName})"); for (var i = 0; i < MaxPlayersOnMap; i++) { var p = new Player(i); if (p.Entity == LocalPlayer.Entity) { continue; } Players.Add(p); } } InGame = newInGame; await Task.Delay(200); } }); }