Advertisement
Eddlm

SUPERHOT

Feb 28th, 2016
1,079
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 11.74 KB | None | 0 0
  1. using GTA;
  2. using GTA.Math;
  3. using GTA.Native;
  4. using System;
  5. using System.Windows.Forms;
  6. using NativeUI;
  7. using System.Collections.Generic;
  8. using System.IO;
  9.  
  10. public class SuperHot : Script
  11. {
  12.     string ScreenEffect = "RaceTurbo";
  13.     string ScriptName = "SUPERHOT Abilities";
  14.     string ScriptVer = "v1.2";
  15.     // List<WeaponHash> SingleShotWeapons = new List<WeaponHash>();
  16.     List<string> EmptyClipMessages = new List<string> { "YOU'RE OUT","MAGAZINE EMPTY", "NO AMMO"};
  17.  
  18.     List<string> CreepyMessages = new List<string> { "YOU'RE NOT IN CONTROL", "SUPERHOT.EXE", "DANCE FOR US","WE OWN YOU","WE'RE WATCHING YOU","MIND IS SOFTWARE","BODY IS DISPOSABLE"};
  19.  
  20.     bool SuperHotEnabled =false;
  21.     bool CanNotifyOfEmptyClip = true;
  22.     bool CanHotSwitch = true;
  23.     int ticks = 0;
  24.     int HotSwitchCoolDown = Game.GameTime;
  25.  
  26.  
  27.  
  28.     //SETTINGS
  29.     float minTimeScale = 0.1f;
  30.     float maxTimeScale =1.0f;
  31.     int HotSwitchCooldownTime = 5;
  32.  
  33.     int SuperHotNotification = 0;
  34.     public SuperHot()
  35.     {
  36.         Tick += OnTick;
  37.         LoadSettings();
  38.     }
  39.  
  40.     void HandleSuperHotToggle()
  41.     {
  42.  
  43.         if (Game.CurrentInputMode == InputMode.MouseAndKeyboard)
  44.         {
  45.             if (Game.Player.IsAiming && Game.IsKeyPressed(Keys.ShiftKey) && Game.IsControlJustPressed(2, GTA.Control.Context))
  46.             {
  47.                 if((SuperHotEnabled && !CanWeUse(Game.Player.GetTargetedEntity()) || !SuperHotEnabled))
  48.                 {
  49.                     SuperHotEnabled = !SuperHotEnabled;
  50.  
  51.                     if (SuperHotEnabled)
  52.                     {
  53.                         LoadSettings();
  54.                         Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
  55.                         BigMessageThread.MessageInstance.ShowColoredShard("SUPER HOT", "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_BLUE, 300);
  56.                         ticks = 3;
  57.                         SuperHotNotification = 1;
  58.                     }
  59.                     if (!SuperHotEnabled)
  60.                     {
  61.                         Game.TimeScale = 1;
  62.                         Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
  63.                         BigMessageThread.MessageInstance.ShowColoredShard(CreepyMessages[RandomInt(0, CreepyMessages.Count - 1)], "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_RED, 300);
  64.                         ticks = 1;
  65.  
  66.  
  67.                         if (ScreenEffect.Length > 0) Function.Call(Hash._STOP_SCREEN_EFFECT, ScreenEffect);
  68.  
  69.                     }
  70.                 }
  71.  
  72.             }
  73.         }
  74.         else
  75.         {
  76.             if (Game.Player.IsAiming && Game.IsControlJustPressed(2, GTA.Control.Context))
  77.             {
  78.                 SuperHotEnabled = !SuperHotEnabled;
  79.                 if (SuperHotEnabled)
  80.                 {
  81.                     Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
  82.                     BigMessageThread.MessageInstance.ShowColoredShard("SUPER HOT", "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_BLUE, 300);
  83.                     ticks = 3;
  84.                     SuperHotNotification = 1;
  85.                 }
  86.                 if (!SuperHotEnabled)
  87.                 {
  88.                     Game.TimeScale = 1;
  89.                     Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
  90.                     BigMessageThread.MessageInstance.ShowColoredShard(CreepyMessages[RandomInt(0, CreepyMessages.Count - 1)], "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_RED, 300);
  91.                     ticks = 1;
  92.                 }
  93.             }
  94.         }
  95.  
  96.     }
  97.     void OnTick(object sender, EventArgs e)
  98.     {
  99.         HandleSuperHotToggle();
  100.  
  101.         if (!CanHotSwitch && Game.GameTime > HotSwitchCoolDown)
  102.         {
  103.             CanHotSwitch = true;
  104.  
  105.             Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
  106.             BigMessageThread.MessageInstance.ShowColoredShard("HOTSWITCH READY", "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_BLUE, 300);
  107.             ticks = 1;
  108.         }
  109.         if (ticks > 0) ticks++;
  110.         if (SuperHotNotification > 3) SuperHotNotification = 0;
  111.         if (SuperHotEnabled)
  112.         {
  113.             if (!Game.Player.IsAlive) SuperHotEnabled = false;
  114.             HandleSuperHot();
  115.             HandleClip();
  116.             if(ticks > 10)
  117.             {
  118.                 BigMessageThread.MessageInstance.ShowSimpleShard("", "", 0);
  119.                 ticks = 0;
  120.                 if (SuperHotNotification > 0)
  121.                 {
  122.                     Wait(50);
  123.                     SuperHotNotification++;
  124.                     Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
  125.                     BigMessageThread.MessageInstance.ShowColoredShard("SUPER HOT", "",HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_BLUE, 300);
  126.                     ticks = 3;
  127.                 }
  128.             }
  129.         }
  130.     }
  131.     int RandomInt(int min, int max)
  132.     {
  133.         max++;
  134.         return Function.Call<int>(GTA.Native.Hash.GET_RANDOM_INT_IN_RANGE, min, max);
  135.     }
  136.     void HandleClip()
  137.     {
  138.         if (CanNotifyOfEmptyClip == true && Game.Player.IsAlive && Game.Player.Character.Weapons.Current.DefaultClipSize > 1 && Game.Player.Character.Weapons.Current.AmmoInClip == 0 && (Game.Player.Character.IsShooting))
  139.         {
  140.             Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
  141.             BigMessageThread.MessageInstance.ShowColoredShard(EmptyClipMessages[RandomInt(0,EmptyClipMessages.Count-1)], "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_BLUE, 300);
  142.             ticks = 1;
  143.             CanNotifyOfEmptyClip = false;
  144.         }
  145.         if (CanNotifyOfEmptyClip == false &&  Game.Player.Character.Weapons.Current.AmmoInClip != 0) CanNotifyOfEmptyClip = true;
  146.        
  147.     }
  148.     bool CanWeUse(Entity entity)
  149.     {
  150.         return entity != null && entity.Exists();
  151.     }
  152.  
  153.     void LoadSettings()
  154.     {
  155.         if (File.Exists(@"scripts\\SUPERHOT.ini"))
  156.         {
  157.             ScriptSettings config = ScriptSettings.Load(@"scripts\SUPERHOT.ini");
  158.             minTimeScale = config.GetValue<float>("GENERAL_SETTINGS", "minTimeScale", 0.03f);
  159.             maxTimeScale = config.GetValue<float>("GENERAL_SETTINGS", "maxTimeScale", 1.0f);
  160.             HotSwitchCooldownTime = (int)config.GetValue<float>("GENERAL_SETTINGS", "HotSwitchCooldownTime", 5f) *1000;
  161.  
  162.             ScreenEffect = config.GetValue<string>("GENERAL_SETTINGS", "ScreenEffect", "");
  163.  
  164.         }
  165.         else
  166.         {
  167.             WarnPlayer(ScriptName+" "+ScriptVer, "CONFIG NOT FOUND", "SUPERHOT.ini not found. Loading default values.");
  168.         }
  169.     }
  170.  
  171.     void WarnPlayer(string script_name, string title, string message)
  172.     {
  173.         Function.Call(Hash._SET_NOTIFICATION_TEXT_ENTRY, "STRING");
  174.         Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, message);
  175.         Function.Call(Hash._SET_NOTIFICATION_MESSAGE, "CHAR_SOCIAL_CLUB", "CHAR_SOCIAL_CLUB", true, 0, title, "~b~"+script_name);
  176.     }
  177.  
  178.     void HandleSuperHot()
  179.     {
  180.         if(ScreenEffect.Length>0) Function.Call(Hash._START_SCREEN_EFFECT, ScreenEffect, 0, false);
  181.  
  182.         if (Game.Player.IsAiming  && Game.IsControlJustPressed(2,GTA.Control.Context)&& CanWeUse(Game.Player.GetTargetedEntity()))
  183.         {
  184.             if(CanHotSwitch)
  185.             {
  186.                 if (Function.Call<bool>(Hash.IS_ENTITY_A_PED, Game.Player.GetTargetedEntity()))
  187.                 {
  188.                     Ped victim = Game.Player.GetTargetedEntity() as Ped;
  189.  
  190.                     if (victim.IsSittingInVehicle())
  191.                     {
  192.                         Vehicle playerveh = Game.Player.Character.CurrentVehicle;
  193.                         Vehicle veh = victim.CurrentVehicle;
  194.                         Vector3 pos = victim.Position - victim.UpVector;
  195.                         float heading = victim.Heading;
  196.  
  197.  
  198.                         victim.Position = Game.Player.Character.Position;
  199.                         victim.Heading = Game.Player.Character.Heading;
  200.  
  201.                         Game.Player.Character.SetIntoVehicle(veh, VehicleSeat.Driver);
  202.  
  203.                         if (CanWeUse(playerveh))
  204.                         {
  205.                             victim.SetIntoVehicle(playerveh, VehicleSeat.Driver);
  206.                             playerveh.SoundHorn(0);
  207.                         }
  208.                     }
  209.                     else
  210.                     {
  211.                         Vector3 pos = victim.Position - victim.UpVector;
  212.                         float heading = victim.Heading;
  213.                         victim.Position = Game.Player.Character.Position;
  214.                         victim.Heading = Game.Player.Character.Heading;
  215.                         Game.Player.Character.Position = pos;
  216.                         Game.Player.Character.Heading = heading;
  217.  
  218.                         if (victim.IsDead)
  219.                         {
  220.                             victim.Position = victim.Position - (new Vector3(0, 0, victim.HeightAboveGround));
  221.                         }
  222.                     }
  223.  
  224.                     HotSwitchCoolDown = Game.GameTime + HotSwitchCooldownTime;
  225.                     Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
  226.                     BigMessageThread.MessageInstance.ShowColoredShard("NEW BODY", "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_BLUE, 300);
  227.                     ticks = 1;
  228.                     CanHotSwitch = false;
  229.                 }
  230.             }
  231.             else
  232.             {
  233.                 Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
  234.                 BigMessageThread.MessageInstance.ShowColoredShard("NOT READY", "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_BLUE, 300);
  235.                 ticks = 1;
  236.             }
  237.         }
  238.         if (!Game.Player.Character.IsOnFoot)
  239.         {
  240.             Game.TimeScale = 1f;
  241.         }
  242.         else
  243.         {
  244.             float speed = Game.Player.Character.Velocity.Length();
  245.             float mouse = Math.Abs(((Function.Call<float>(Hash.GET_CONTROL_NORMAL, 0, (int)GTA.Control.LookLeftRight) + Function.Call<float>(Hash.GET_CONTROL_NORMAL, 0, (int)GTA.Control.LookUpDown)) / 2) * 5);
  246.             float rot = Math.Max(Function.Call<Vector3>(Hash.GET_ENTITY_ROTATION_VELOCITY, Game.Player.Character).Z, mouse);
  247.             float scale = Math.Max(rot, speed);
  248.             scale = scale / 4;
  249.  
  250.             if (Game.Player.Character.IsRagdoll || Game.Player.Character.IsGettingUp) Game.TimeScale = 1;
  251.             else
  252.             {
  253.                 if (scale < minTimeScale)
  254.                 {
  255.                     Game.TimeScale = minTimeScale;
  256.                 }
  257.  
  258.                 if (scale >= minTimeScale)
  259.                 {
  260.                     Game.TimeScale = scale;
  261.                 }
  262.                 if (scale < 0.3f && Game.IsControlPressed(2, GTA.Control.Attack) && Game.Player.Character.Weapons.Current.AmmoInClip != 0)
  263.                 {
  264.                     Game.TimeScale = 0.3f;
  265.                 }
  266.                 if (scale < 0.2f && IsPlayerTryingToMove()) Game.TimeScale = 0.2f;
  267.  
  268.                 if (scale > maxTimeScale)
  269.                 {
  270.                     Game.TimeScale = maxTimeScale;
  271.                 }
  272.  
  273.             }
  274.            // UI.ShowSubtitle("~r~" + (Math.Round(scale,2)).ToString());
  275.  
  276.         }
  277.  
  278.     }
  279.  
  280.  
  281.     bool IsPlayerTryingToMove()
  282.     {
  283.         if (Game.IsControlPressed(2, GTA.Control.MoveDownOnly) || Game.IsControlPressed(2, GTA.Control.MoveUpOnly) || Game.IsControlPressed(2, GTA.Control.MoveLeftOnly) || Game.IsControlPressed(2, GTA.Control.MoveRightOnly)) return true;
  284.         return false;
  285.     }
  286.  
  287.     protected override void Dispose(bool dispose)
  288.     {
  289.         Game.TimeScale = 1;
  290.         base.Dispose(dispose);
  291.     }
  292. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement