Advertisement
Guest User

Untitled

a guest
Aug 1st, 2017
1,106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 20.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using UnityEngine;
  5. using System.Reflection;
  6. using System.Runtime.InteropServices;
  7. using System.IO;
  8. using System.Reflection.Emit;
  9. using RuntimeHelpers = System.Runtime.CompilerServices.RuntimeHelpers;
  10.  
  11.  
  12. class Hack : MonoBehaviour
  13. {
  14.     bool bAimbot = true;
  15.     bool bAimVisible = true;
  16.     bool bAimTarget = true;
  17.  
  18.     bool bNoRecoil = true;
  19.     bool bNoSpread = true;
  20.  
  21.     bool bBuildRange = true;
  22.     bool bInstantReload = true;
  23.  
  24.     bool bChams = true;
  25.     bool bChamsFriendly = false;
  26.     bool bChamsEnemy = true;
  27.  
  28.     bool bLines = true;
  29.     bool bLinesBottom = true;
  30.     bool bLinesFriend = false;
  31.     bool bLinesEnemy = true;
  32.  
  33.     bool bHealth = true;
  34.     bool bHealthFriend = false;
  35.     bool bHealthEnemy = true;
  36.  
  37.  
  38.  
  39.     Material lineMaterial = null;
  40.     void CreateLineMaterial()
  41.     {
  42.         if (!lineMaterial)
  43.         {
  44.             lineMaterial = new Material("Shader \"Lines/Colored Blended\" {" +
  45.                 "SubShader { Pass { " +
  46.                 "    Blend SrcAlpha OneMinusSrcAlpha " +
  47.                 "    ZWrite Off Cull Off Fog { Mode Off } " +
  48.                 "    ZTest Always" +
  49.                 "    BindChannels {" +
  50.                 "      Bind \"vertex\", vertex Bind \"color\", color }" +
  51.                 "} } }");
  52.             lineMaterial.hideFlags = HideFlags.HideAndDontSave;
  53.             lineMaterial.shader.hideFlags = HideFlags.HideAndDontSave;
  54.         }
  55.     }
  56.  
  57.     public void DrawLine(Vector3 Start, Vector3 End, Color color)
  58.     {
  59.         lineMaterial.SetPass(0);
  60.  
  61.         GL.PushMatrix();
  62.         GL.LoadOrtho();
  63.         GL.Begin(GL.LINES);
  64.         GL.Color(color);
  65.         GL.Vertex3(Start.x / Screen.width, Start.y / Screen.height, 0);
  66.         GL.Vertex3(End.x / Screen.width, End.y / Screen.height, 0);
  67.         GL.End();
  68.         GL.PopMatrix();
  69.     }
  70.  
  71.     void DrawBox(Vector3 Pos, float Width, float Height, Color color)
  72.     {
  73.         DrawLine(new Vector3(Pos.x, Pos.y, 0), new Vector3(Pos.x + Width, Pos.y, 0), color);
  74.         DrawLine(new Vector3(Pos.x + Width, Pos.y, 0), new Vector3(Pos.x + Width, Pos.y + Height, 0), color);
  75.         DrawLine(new Vector3(Pos.x + Width, Pos.y + Height, 0), new Vector3(Pos.x, Pos.y + Height, 0), color);
  76.         DrawLine(new Vector3(Pos.x, Pos.y + Height, 0), new Vector3(Pos.x, Pos.y, 0), color);
  77.     }
  78.  
  79.     public void DrawCircle(Vector3 Pos, float r, float s, Color color)
  80.     {
  81.         float Step = 3.14159265f * 2.0f / s;
  82.         for (float a = 0; a < 3.14159265 * 2.0; a += Step)
  83.         {
  84.             float x1 = r * Mathf.Cos(a) + Pos.x;
  85.             float y1 = r * Mathf.Sin(a) + Pos.y;
  86.             float x2 = r * Mathf.Cos(a + Step) + Pos.x;
  87.             float y2 = r * Mathf.Sin(a + Step) + Pos.y;
  88.             DrawLine(new Vector3(x1, y1, 0), new Vector3(x2, y2, 0), color);
  89.         }
  90.     }
  91.  
  92.  
  93.     Material ChamMaterial = null;
  94.     Material[] ChamMats;
  95.     void CreateChamMaterial()
  96.     {
  97.         if (!ChamMaterial)
  98.         {
  99.             ChamMaterial = new Material(
  100.                     "Shader \"Custom/Cham\"" +
  101.                     "{" +
  102.                     "   SubShader " +
  103.                     "   {" +
  104.                     "       Pass " +
  105.                     "       {" +
  106.                     "           ZTest Less" +
  107.                     "           ZWrite On" +
  108.                     "           Color (1,0,0,1) " +
  109.                     "       }" +
  110.                     "       Pass " +
  111.                     "       {" +
  112.                     "           ZTest Greater" +
  113.                     "           ZWrite Off" +
  114.                     "           Color (0,0,1,1)" +
  115.                     "       }" +
  116.                     "   }" +
  117.                     "}");
  118.  
  119.  
  120.             ChamMaterial.hideFlags = HideFlags.HideAndDontSave;
  121.             ChamMaterial.shader.hideFlags = HideFlags.HideAndDontSave;
  122.  
  123.             ChamMats = new Material[] { ChamMaterial, ChamMaterial, ChamMaterial, ChamMaterial, ChamMaterial, ChamMaterial, ChamMaterial, ChamMaterial, ChamMaterial, ChamMaterial, ChamMaterial };
  124.         }
  125.     }
  126.  
  127.     Material ChamMaterial2 = null;
  128.     Material[] ChamMats2;
  129.     void CreateChamMaterial2()
  130.     {
  131.         if (!ChamMaterial2)
  132.         {
  133.             ChamMaterial2 = new Material(
  134.                     "Shader \"Custom/Cham\"" +
  135.                     "{" +
  136.                     "   SubShader " +
  137.                     "   {" +
  138.                     "       Pass " +
  139.                     "       {" +
  140.                     "           ZTest Less" +
  141.                     "           ZWrite On" +
  142.                     "           Color (1,1,0,1) " +
  143.                     "       }" +
  144.                     "       Pass " +
  145.                     "       {" +
  146.                     "           ZTest Greater" +
  147.                     "           ZWrite Off" +
  148.                     "           Color (0,1,0,1)" +
  149.                     "       }" +
  150.                     "   }" +
  151.                     "}");
  152.  
  153.  
  154.             ChamMaterial2.hideFlags = HideFlags.HideAndDontSave;
  155.             ChamMaterial2.shader.hideFlags = HideFlags.HideAndDontSave;
  156.  
  157.             ChamMats2 = new Material[] { ChamMaterial2, ChamMaterial2, ChamMaterial2, ChamMaterial2, ChamMaterial2, ChamMaterial2, ChamMaterial2, ChamMaterial2, ChamMaterial2, ChamMaterial2, ChamMaterial2 };
  158.         }
  159.     }
  160.  
  161.     //bool BlockFunction(MethodBase Original)
  162.     //{
  163.     //    if (Original == null) return false;
  164.  
  165.     //    IntPtr pBody1 = Original.MethodHandle.GetFunctionPointer();
  166.  
  167.     //    if (pBody1 == null) return false;
  168.  
  169.     //    unsafe
  170.     //    {
  171.     //        var ptr = (byte*)pBody1.ToPointer();
  172.     //        (*(byte*)(ptr + 0)) = 0xC3;
  173.     //    }
  174.     //    return true;
  175.     //}
  176.  
  177.     bool IsVisible(GameObject obj, Vector3 Position)
  178.     {
  179.         RaycastHit hit;
  180.         if (Physics.Linecast(Camera.main.transform.position, Position, out hit))
  181.         {
  182.             if (hit.collider)
  183.             {
  184.                 if (hit.collider.gameObject.transform.root.gameObject == obj.transform.root.gameObject) return true;
  185.             }
  186.         }
  187.         return false;
  188.     }
  189.  
  190.     //void Aimbot()
  191.     //{
  192.     //    Vector3 target = Vector3.zero;
  193.     //    float bestDistance = 100000;
  194.  
  195.     //    GUILayout.BeginVertical();
  196.  
  197.     //    Unit local = UnitsRegistry.Instance.GetPlayer();
  198.     //    if (local == null) return;
  199.        
  200.     //    MouseLook ml = local.gameObject.GetComponent<MouseLook>();
  201.     //    if (ml == null) return;
  202.  
  203.     //    List<Unit> players = UnitsRegistry.Instance.GetAllPlayers();
  204.  
  205.  
  206.     //    int c = 0;
  207.     //    foreach (Unit player in players)
  208.     //    {
  209.     //        if (player == local) continue;
  210.     //        if (local.Team != player.Team)
  211.     //        {
  212.     //            foreach (SkinnedMeshRenderer skin in player.gameObject.GetComponentsInChildren<SkinnedMeshRenderer>())
  213.     //            {
  214.     //                foreach (Transform bone in skin.bones)
  215.     //                {
  216.     //                    if (bone.name.ToLower().Contains("neck") || bone.name.ToLower().Contains("head") || bone.name.ToLower().Contains("cameraroot"))
  217.     //                    //if (bone.name.ToLower().Contains("cameraroot"))
  218.     //                    {
  219.     //                        Vector3 Position = Camera.main.WorldToScreenPoint(bone.position);
  220.     //                        if (Position.z > 0)
  221.     //                        {
  222.     //                            if (IsVisible(bone.root.gameObject, bone.position))
  223.     //                            {
  224.     //                                DrawCircle(Position, 10, 10, Color.green);
  225.  
  226.     //                                Vector2 s;
  227.     //                                s.x = Screen.width / 2 - Position.x;
  228.     //                                s.y = Screen.height / 2 - Position.y;
  229.  
  230.     //                                if (s.magnitude < bestDistance)
  231.     //                                {
  232.     //                                    bestDistance = s.magnitude;
  233.     //                                    target = bone.position;
  234.     //                                }
  235.     //                            }
  236.     //                            else
  237.     //                                DrawCircle(Position, 10, 10, Color.red);
  238.     //                        }
  239.     //                        break;
  240.     //                    }
  241.     //                }
  242.  
  243.     //            }
  244.     //        }
  245.     //    }
  246.     //    //Transform tr = ml.GetType().GetField("cameraRoot", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ml) as Transform;
  247.  
  248.     //    Vector3 targetESP = Camera.main.WorldToScreenPoint(target);
  249.     //    DrawCircle(targetESP, 12, 10, Color.cyan);
  250.  
  251.     //    if (target != Vector3.zero && Input.GetKey(KeyCode.LeftShift))
  252.     //    //if (Input.GetKey(KeyCode.LeftShift))
  253.     //    {
  254.     //        GameObject obj = new GameObject();
  255.     //        obj.transform.position = Camera.main.transform.position;
  256.     //        obj.transform.LookAt(target);
  257.  
  258.     //        float ax = obj.transform.eulerAngles.x;
  259.     //        if (ax > 90) ax -= 360;
  260.     //        ml.RotationX = ax;
  261.     //        ml.RotationY = obj.transform.eulerAngles.y;
  262.  
  263.     //        GUILayout.Label("eulerAngles " + obj.transform.eulerAngles.ToString());
  264.     //    }
  265.  
  266.     //    GUILayout.EndVertical();
  267.     //}
  268.  
  269.     void DoAimbot()
  270.     {
  271.         if (!bAimbot) return;
  272.  
  273.         Vector3 target = Vector3.zero;
  274.         float bestDistance = 100000;
  275.  
  276.         Unit local = UnitsRegistry.Instance.GetPlayer();
  277.         if (local == null) return;
  278.  
  279.         MouseLook ml = local.gameObject.GetComponent<MouseLook>();
  280.         if (ml == null) return;
  281.  
  282.         List<Unit> players = UnitsRegistry.Instance.GetAllPlayers();
  283.  
  284.         foreach (Unit player in players)
  285.         {
  286.             if (player == local) continue;
  287.             if (local.Team != player.Team)
  288.             {
  289.                 foreach (SkinnedMeshRenderer skin in player.gameObject.GetComponentsInChildren<SkinnedMeshRenderer>())
  290.                 {
  291.                     foreach (Transform bone in skin.bones)
  292.                     {
  293.                         //if (bone.name.ToLower().Contains("neck") || bone.name.ToLower().Contains("head") || bone.name.ToLower().Contains("cameraroot"))
  294.                         if (bone.name.ToLower().Contains("neck"))
  295.                         {
  296.                             Vector3 Position = Camera.main.WorldToScreenPoint(bone.position);
  297.                             if (Position.z > 0)
  298.                             {
  299.                                 bool bWasVisible = IsVisible(bone.root.gameObject, bone.position);
  300.                                 if (!bAimVisible) bWasVisible = true;
  301.  
  302.                                 if (bWasVisible)
  303.                                 {
  304.                                     if (bAimTarget) DrawCircle(Position, 10, 10, Color.green);
  305.  
  306.                                     Vector2 s;
  307.                                     s.x = Screen.width / 2 - Position.x;
  308.                                     s.y = Screen.height / 2 - Position.y;
  309.  
  310.                                     if (s.magnitude < bestDistance)
  311.                                     {
  312.                                         bestDistance = s.magnitude;
  313.                                         target = bone.position;
  314.                                     }
  315.                                 }
  316.                                 else
  317.                                 {
  318.                                     if (bAimTarget) DrawCircle(Position, 10, 10, Color.red);
  319.                                 }
  320.                             }
  321.                             break;
  322.                         }
  323.                     }
  324.  
  325.                 }
  326.             }
  327.         }
  328.  
  329.         if (bAimTarget && target != Vector3.zero)
  330.         {
  331.             Vector3 targetESP = Camera.main.WorldToScreenPoint(target);
  332.             DrawCircle(targetESP, 12, 10, Color.cyan);
  333.         }
  334.  
  335.         if (target != Vector3.zero && Input.GetKey(KeyCode.LeftShift))
  336.         {
  337.             GameObject obj = new GameObject();
  338.             obj.transform.position = Camera.main.transform.position;
  339.             obj.transform.LookAt(target);
  340.  
  341.             float ax = obj.transform.eulerAngles.x;
  342.             if (ax > 90) ax -= 360;
  343.             ml.RotationX = ax;
  344.             ml.RotationY = obj.transform.eulerAngles.y;
  345.        }
  346.     }
  347.  
  348.     void DoESP()
  349.     {
  350.         Unit local = UnitsRegistry.Instance.GetPlayer();
  351.         if (local == null) return;
  352.  
  353.         List<Unit> players = UnitsRegistry.Instance.GetAllPlayers();
  354.  
  355.         foreach (Unit player in players)
  356.         {
  357.             if (player == local) continue;
  358.             foreach (SkinnedMeshRenderer skin in player.gameObject.GetComponentsInChildren<SkinnedMeshRenderer>())
  359.             {
  360.                 foreach (Transform bone in skin.bones)
  361.                 {
  362.                         //if (bone.name.ToLower().Contains("neck") || bone.name.ToLower().Contains("head") || bone.name.ToLower().Contains("cameraroot"))
  363.                     if (bone.name.ToLower().Contains("neck"))
  364.                     {
  365.                         Vector3 Position = Camera.main.WorldToScreenPoint(bone.position);
  366.                         if (Position.z > 0)
  367.                         {
  368.                             if (bLines)
  369.                             {
  370.                                 Vector3 LineStart = new Vector3(Screen.width / 2, 0, 0);
  371.                                 if (!bLinesBottom) LineStart.y = Screen.height/2;
  372.  
  373.                                 if (bLinesFriend && player.Team == local.Team) DrawLine(LineStart, Position, Color.green);
  374.                                 if (bLinesEnemy && player.Team != local.Team) DrawLine(LineStart, Position, Color.red);
  375.                             }
  376.                             if (bHealth)
  377.                             {
  378.                                float Health = player.Health;
  379.  
  380.                                 Color cHealth = Color.green;
  381.                                 if (Health < 70) cHealth = Color.yellow;
  382.                                 if (Health < 35) cHealth = Color.red;
  383.  
  384.                                 Vector3 HealthPos = Position;
  385.                                 HealthPos.x -= 25;
  386.                                 HealthPos.y += 16;
  387.  
  388.                                 if (bHealthFriend && player.Team == local.Team)
  389.                                 {
  390.                                     DrawBox(HealthPos, 50, 1, Color.black);
  391.                                     DrawBox(HealthPos, Health / 2, 1, cHealth);
  392.                                 }
  393.                                 if (bHealthEnemy && player.Team != local.Team)
  394.                                 {
  395.                                     DrawBox(HealthPos, 50, 1, Color.black);
  396.                                     DrawBox(HealthPos, Health / 2, 1, cHealth);
  397.                                 }
  398.                             }
  399.  
  400.                         }
  401.                         break;
  402.                     }
  403.                 }
  404.  
  405.             }
  406.         }
  407.  
  408.     }
  409.  
  410.     void DoChams()
  411.     {
  412.         if (!bChams) return;
  413.  
  414.         Unit local = UnitsRegistry.Instance.GetPlayer();
  415.         if (local == null) return;
  416.  
  417.         List<Unit> players = UnitsRegistry.Instance.GetAllPlayers();
  418.  
  419.         foreach (Unit player in players)
  420.         {
  421.             if (player == local) continue;
  422.  
  423.             foreach (SkinnedMeshRenderer skin in player.gameObject.GetComponentsInChildren<SkinnedMeshRenderer>())
  424.             {
  425.                 if (local.Team == player.Team)
  426.                 {
  427.                     if (bChamsFriendly) skin.materials = ChamMats2;
  428.                 }
  429.                 else
  430.                 {
  431.                     if (bChamsEnemy) skin.materials = ChamMats;
  432.                 }
  433.             }
  434.         }
  435.     }
  436.  
  437.     void DoBuildDistance()
  438.     {
  439.         if (!bBuildRange) return;
  440.  
  441.         Unit local = UnitsRegistry.Instance.GetPlayer();
  442.         if (local == null) return;
  443.  
  444.         BuildGhostController bgc = local.gameObject.GetComponent<BuildGhostController>();
  445.         if (bgc != null)
  446.         {
  447.             ToolLogicBuild tlb = (ToolLogicBuild)bgc.GetType().GetField("tool", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(bgc);
  448.             if (tlb != null)
  449.             {
  450.                 if (tlb.SpecialTool != null)
  451.                 {
  452.                     tlb.SpecialTool.Range = 5.0f;
  453.                 }
  454.             }
  455.         }
  456.     }
  457.  
  458.     void DoInstantReload()
  459.     {
  460.         if (!bInstantReload) return;
  461.  
  462.         Unit local = UnitsRegistry.Instance.GetPlayer();
  463.         if (local == null) return;
  464.  
  465.         local.ReloadEnd = 0;
  466.     }
  467.  
  468.     void DoNoSpread()
  469.     {
  470.         if (!bNoSpread) return;
  471.  
  472.         Unit local = UnitsRegistry.Instance.GetPlayer();
  473.         if (local == null) return;
  474.  
  475.         BloomLogic bl = local.gameObject.GetComponent<BloomLogic>();
  476.         if (bl != null)
  477.         {
  478.             bl.Angle = 0.0f;
  479.         }
  480.     }
  481.  
  482.     void DoNoRecoil()
  483.     {
  484.         if (!bNoRecoil) return;
  485.  
  486.         Unit local = UnitsRegistry.Instance.GetPlayer();
  487.         if (local == null) return;
  488.  
  489.         RecoilLogic rl = local.gameObject.GetComponent<RecoilLogic>();
  490.         if (rl != null)
  491.         {
  492.             rl.RecoilAngles = Vector2.zero;
  493.         }
  494.     }
  495.  
  496.     void DoHacks()
  497.     {
  498.         DoChams();
  499.         DoBuildDistance();
  500.         DoInstantReload();
  501.         DoNoSpread();
  502.         DoNoRecoil();
  503.         DoESP();
  504.         DoAimbot();
  505.     }
  506.  
  507.     void OnRenderObject()
  508.     {
  509.         CreateLineMaterial();
  510.         CreateChamMaterial();
  511.         CreateChamMaterial2();
  512.  
  513.         DoHacks();
  514.     }
  515.  
  516.  
  517.     DebugMenu _menu = null;
  518.  
  519.     bool bMenu = false;
  520.     Rect windowRect = new Rect(16, 70, 192, 600);
  521.  
  522.     void Update()
  523.     {
  524.        if (Input.GetKeyDown(KeyCode.Home)) bMenu = !bMenu;
  525.     }
  526.  
  527.     void OnGUI()
  528.     {
  529.         //GUI.color = Color.yellow;
  530.         GUI.color = Color.red;
  531.  
  532.         if (GUI.Button(new Rect(Screen.width - 300, 32, 300, 20), "GameAnarchy Block N Load V1.01")) bMenu = !bMenu;
  533.         if (bMenu)
  534.         {
  535.             GUI.Window(50, windowRect, WindowFunction, "Hacks");
  536.         }
  537.     }
  538.  
  539.     void WindowFunction(int windowID)
  540.     {
  541.         GUI.color = Color.white;
  542.         GUILayout.BeginVertical();
  543.  
  544.         if (GUILayout.Button("HELP"))
  545.         {
  546.             Application.OpenURL("http://gameanarchy.net/666/index.php");
  547.         }
  548.  
  549.         if (GUILayout.Button("Game Debug Menu"))
  550.         {
  551.             if (_menu != null)
  552.                 _menu.Show();
  553.             else
  554.             {
  555.                 _menu = this.gameObject.AddComponent<DebugMenu>();
  556.                 _menu.Show();
  557.             }
  558.         }
  559.  
  560.         GUILayout.Label("- AIM -");
  561.  
  562.         bAimbot = GUILayout.Toggle(bAimbot, "Aimbot");
  563.         bAimVisible = GUILayout.Toggle(bAimVisible, "Aim Visible");
  564.         bAimTarget = GUILayout.Toggle(bAimTarget, "Show Aim Targets");
  565.  
  566.         GUILayout.Label("- WEAPON -");
  567.  
  568.         bNoRecoil = GUILayout.Toggle(bNoRecoil, "No Recoil");
  569.         bNoSpread = GUILayout.Toggle(bNoSpread, "No Spread");
  570.         bInstantReload = GUILayout.Toggle(bInstantReload, "Instant Reload");
  571.  
  572.         bBuildRange = GUILayout.Toggle(bBuildRange, "Increase Build Distance");
  573.  
  574.         GUILayout.Label("- CHAMS -");
  575.  
  576.         bChams = GUILayout.Toggle(bChams, "Chams");
  577.         bChamsFriendly = GUILayout.Toggle(bChamsFriendly, "Friendly Chams");
  578.         bChamsEnemy = GUILayout.Toggle(bChamsEnemy, "Enemy Chams");
  579.  
  580.         GUILayout.Label("- ESP -");
  581.  
  582.         bLines = GUILayout.Toggle(bLines, "Lines");
  583.         bLinesBottom = GUILayout.Toggle(bLinesBottom, "From Bottom");
  584.         bLinesFriend = GUILayout.Toggle(bLinesFriend, "Friendly Lines");
  585.         bLinesEnemy = GUILayout.Toggle(bLinesEnemy, "Enemy Lines");
  586.  
  587.         bHealth = GUILayout.Toggle(bHealth, "Health");
  588.         bHealthFriend = GUILayout.Toggle(bHealthFriend, "Friendly Health");
  589.         bHealthEnemy = GUILayout.Toggle(bHealthEnemy, "Enemy Health");
  590.  
  591.         GUILayout.EndVertical();
  592.         GUI.DragWindow();
  593.     }
  594.  
  595.  
  596. }
  597.  
  598.  
  599. class _HOOK
  600. {
  601.     public static GameObject tst = null;
  602.     static void InitHack()
  603.     {
  604.         if (tst == null)
  605.         {
  606.             tst = new GameObject();
  607.             tst.AddComponent<Hack>();
  608.             GameObject.DontDestroyOnLoad(tst);
  609.         }
  610.     }
  611. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement