コード例 #1
0
        private static void Example()
        {
            while (ExternalCounterstrike.IsAttached)
            {
                Thread.Sleep(1);
                if (EngineClient.IsInMenu)
                {
                    continue;
                }
                EngineClient.ClearCache();
                BaseClient.ClearCache();
                BaseClient.Update();
                var localPlayer = BaseClient.LocalPlayer;
                if (localPlayer == null)
                {
                    continue;
                }

                var closestPlayer = GetClosestPlayer();
                if (closestPlayer == null)
                {
                    continue;
                }

                var bone           = closestPlayer.GetBonesPos(6);
                var calculatedBone = CalculateAngle(localPlayer.GetEyePos(), bone);
                EngineClient.ViewAngles = calculatedBone;
            }
        }
コード例 #2
0
        private static void DrawingLoop()
        {
            ExternalCounterstrike.Overlay = new OverlayWindow(ExternalCounterstrike.Process.MainWindowHandle, false);

            Overlay.Show();

            var greenColor = Color.FromArgb(255, Color.Green);
            var blackColor = Color.Black;

            var brushGreen = Overlay.Graphics.CreateBrush(greenColor);
            var brushBlack = Overlay.Graphics.CreateBrush(blackColor);
            var brushWhite = Overlay.Graphics.CreateBrush(Color.White);
            var oldAngle   = new Vector3D();

            var font = Overlay.Graphics.CreateFont("Visitor TT2 (BRK)", 17);

            var pointCrosshair = new Vector2D(Overlay.Width / 2, Overlay.Height / 2);

            while (ExternalCounterstrike.IsAttached)
            {
                Thread.Sleep(0);
                if (ExternalCounterstrike.Process.HasExited)
                {
                    ExternalCounterstrike.IsAttached = false;
                    System.Environment.Exit(0);
                }
                EngineClient.ClearCache();
                BaseClient.ClearCache();
                //EntityList.ClearCache();
                EntityBase.ClearCache();

                var entityList = EntityBase.GetEntityList();

                // Begin scene of direct2d device to initialize drawing
                Overlay.Graphics.BeginScene();
                // Clear the scene so everything what we have drawn is getting deleted
                Overlay.Graphics.ClearScene();
                // Draw text (kek)
                Overlay.Graphics.DrawText("External Counterstrike", font, brushWhite, 10, 10);

                var localPlayer = entityList.GetLocalPlayer();
                if (localPlayer == null)
                {
                    Overlay.Graphics.EndScene();
                    continue;
                }

                foreach (var player in entityList.Players)
                {
                    if (player.IsDormant())
                    {
                        continue;
                    }
                    if (player.GetHealth() < 1)
                    {
                        continue;
                    }
                    if (player == localPlayer)
                    {
                        continue;
                    }

                    var origin    = player.GetPosition();
                    var w2sOrigin = BaseClient.WorldToScreen(origin);
                    if (w2sOrigin.IsEmpty())
                    {
                        continue;
                    }

                    var brush = EngineClient.Map.IsVisible(localPlayer.GetEyePos(), origin) ? brushGreen : brushWhite;

                    Overlay.Graphics.DrawText(player.GetClientClass().GetClassName(), font, brush, w2sOrigin.X, w2sOrigin.Y);
                }

                //foreach(var ent in EntityList.Entities)
                //{
                //    var origin = ent.GetPosition();
                //    var w2sOrigin = BaseClient.WorldToScreen(origin);
                //    Overlay.Graphics.DrawText(ent.GetClientClass().GetClassName(), font, brushWhite, w2sOrigin.X, w2sOrigin.Y);
                //}

                // Tell the direct2d device to end the scene and apply all drawings
                Overlay.Graphics.EndScene();

                Vector3D newViewangle = EngineClient.ViewAngles + oldAngle;
                //var closestPlayer = GetClosestPlayer();
                //if (closestPlayer != null)
                //{
                //    var bone = closestPlayer.GetBonesPos(CommandHandler.GetParameter("aimbot", "bone").Value.ToInt32());
                //    newViewangle = CalculateAngle(localPlayer.GetEyePos(), bone);
                //}

                if (CommandHandler.GetParameter("misc", "norecoil").Value.ToBool())
                {
                    newViewangle -= localPlayer.GetAimPunchAngle() * BaseClient.ConVars.FindFast("weapon_recoil_scale").GetFloat();
                    oldAngle      = localPlayer.GetAimPunchAngle() * BaseClient.ConVars.FindFast("weapon_recoil_scale").GetFloat();
                }
                BaseClient.ConVars.FindFast("sv_cheats").SetValue(1);

                localPlayer.FlashAlpha = CommandHandler.GetParameter("misc", "flashalpha").Value.ToFloat();

                EngineClient.ViewAngles = newViewangle;
            }
        }