Advertisement
SirBackenbart

Player Bullet Ragdoll Reactions

Apr 30th, 2018
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.22 KB | None | 0 0
  1. using GTA;
  2. using GTA.Native;
  3. using System;
  4. using System.IO;
  5. using System.Windows.Forms;
  6.  
  7. public class Main : Script
  8. {
  9.  
  10.     int prev_health = Game.Player.Character.Health;
  11.     Random rnd = new Random();
  12.     int NoControlTimer = -1;
  13.     String ini = @".\scripts\PlayerBulletRagdollReactions.ini";
  14.     ScriptSettings iniset;
  15.     String version = "1.0.0";
  16.     int easiness = 0;
  17.     bool disableAtMission = false;
  18.  
  19.     public Main()
  20.     {
  21.         Tick += OnTick;
  22.         KeyDown += OnKeyDown;
  23.         KeyUp += OnKeyUp;
  24.  
  25.         Interval = 10;
  26.  
  27.         if (!File.Exists(ini))
  28.         {
  29.             File.Create(ini).Close();
  30.             iniset = ScriptSettings.Load(ini);
  31.             iniset.SetValue("Settings", "easiness", 0);
  32.             iniset.SetValue("Settings", "disableAtMission", false);
  33.             iniset.Save();
  34.         }
  35.         iniset = ScriptSettings.Load(ini);
  36.         easiness = iniset.GetValue<int>("Settings", "easiness", 0);
  37.         disableAtMission = iniset.GetValue<bool>("Settings", "disableAtMission", false);
  38.  
  39.  
  40.         UI.Notify("Player Bullet Ragdoll Reactions version " + version + " loaded!");
  41.     }
  42.  
  43.     void OnTick(object sender, EventArgs e)
  44.     {
  45.         //UI.Notify("NoControlTimer:" + NoControlTimer.ToString());
  46.  
  47.         /*
  48.          *   NoControlTimer = 50 -> EQUALS ONE SECOND
  49.          */
  50.         bool perform = true;
  51.         if (Game.MissionFlag && disableAtMission)
  52.         {
  53.             perform = false;
  54.             NoControlTimer = -1;
  55.         }
  56.  
  57.         if (NoControlTimer >= 0 && perform)
  58.         {
  59.  
  60.             Game.DisableControlThisFrame(0, GTA.Control.VehicleAccelerate);
  61.             Game.DisableControlThisFrame(0, GTA.Control.VehicleBrake);
  62.             Game.DisableControlThisFrame(0, GTA.Control.VehicleDuck);
  63.             Game.DisableControlThisFrame(0, GTA.Control.VehicleExit);
  64.             Game.DisableControlThisFrame(0, GTA.Control.VehicleHorn);
  65.             Game.DisableControlThisFrame(0, GTA.Control.VehicleJump);
  66.             Game.DisableControlThisFrame(0, GTA.Control.VehicleMoveLeft);
  67.             Game.DisableControlThisFrame(0, GTA.Control.VehicleMoveRight);
  68.             Game.DisableControlThisFrame(0, GTA.Control.VehicleParachute);
  69.             Game.DisableControlThisFrame(0, GTA.Control.VehicleRocketBoost);
  70.             Game.DisableControlThisFrame(0, GTA.Control.VehicleShuffle);
  71.             Game.DisableControlThisFrame(0, GTA.Control.VehicleSpecial);
  72.             Game.DisableControlThisFrame(0, GTA.Control.VehicleMoveLeftOnly);
  73.             Game.DisableControlThisFrame(0, GTA.Control.VehicleMoveRightOnly);
  74.             Game.DisableControlThisFrame(0, GTA.Control.VehicleSubTurnHardLeft);
  75.             Game.DisableControlThisFrame(0, GTA.Control.VehicleSubTurnHardRight);
  76.             Game.DisableControlThisFrame(0, GTA.Control.VehicleLookLeft);
  77.             Game.DisableControlThisFrame(0, GTA.Control.VehicleLookRight);
  78.             Game.DisableControlThisFrame(0, GTA.Control.VehicleMoveLeftRight);
  79.             Game.DisableControlThisFrame(0, GTA.Control.VehicleHandbrake);
  80.             Game.DisableControlThisFrame(0, GTA.Control.VehiclePushbikeFrontBrake);
  81.             Game.DisableControlThisFrame(0, GTA.Control.VehiclePushbikeRearBrake);
  82.             Game.DisableControlThisFrame(0, GTA.Control.VehiclePushbikePedal);
  83.             Game.DisableControlThisFrame(0, GTA.Control.VehicleGrapplingHook);
  84.             if (Game.Player.Character.IsInVehicle())
  85.             {
  86.                 Function.Call(Hash._START_SCREEN_EFFECT, "MinigameTransitionOut", 1000, false);
  87.             }
  88.            
  89.             NoControlTimer -= 1;
  90.         }
  91.  
  92.         int health = Game.Player.Character.Health;
  93.         if (prev_health > health && perform)
  94.         {
  95.             //has been damaged
  96.             bool hasBeenDamagedByWeapon = Function.Call<bool>(Hash.HAS_PED_BEEN_DAMAGED_BY_WEAPON, Game.Player.Character, 0, 2);
  97.             if (hasBeenDamagedByWeapon)
  98.             {
  99.                 //UI.Notify("Lost Health: " + (prev_health - health).ToString());
  100.                 int lostHealth = prev_health - health;
  101.                 if (lostHealth < 5)
  102.                 {
  103.  
  104.                 }
  105.                 else if (lostHealth >= 5 && lostHealth < 8)
  106.                 {
  107.                     switch (rnd.Next(5 + easiness))
  108.                     {
  109.                         case 1:
  110.                             Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 400, 400, 3, false, false, false);
  111.                             break;
  112.                         case 2:
  113.                             Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 400, 400, 2, false, false, false);
  114.                             break;
  115.                         default:
  116.                             break;
  117.                     }
  118.                 }
  119.                 else if (lostHealth >= 8 && lostHealth < 14)
  120.                 {
  121.                     if (Game.Player.Character.IsInVehicle())
  122.                     {
  123.                         NoControlTimer = 25;
  124.                     }
  125.                     switch (rnd.Next(5 + easiness))
  126.                     {
  127.                         case 0:
  128.                             Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 500, 500, 0, false, false, false);
  129.                             break;
  130.                         case 1:
  131.                             Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 400, 400, 3, false, false, false);
  132.                             break;
  133.                         case 2:
  134.                             Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 500, 500, 2, false, false, false);
  135.                             break;
  136.                         default:
  137.                             break;
  138.                     }
  139.                 }
  140.                 else if (lostHealth >= 14 && lostHealth < 18)
  141.                 {
  142.                     if (Game.Player.Character.IsInVehicle())
  143.                     {
  144.                         NoControlTimer = 50;
  145.                     }
  146.                     switch (rnd.Next(4 + (int)Math.Round(easiness * 1.2)))
  147.                     {
  148.                         case 0:
  149.                             Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 400, 400, 0, false, false, false);
  150.                             break;
  151.                         case 1:
  152.                             Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 800, 800, 3, false, false, false);
  153.                             break;
  154.                         case 2:
  155.                             Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 800, 800, 2, false, false, false);
  156.                             break;
  157.                         case 3:
  158.                             Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 500, 500, 2, false, false, false);
  159.                             break;
  160.                         default:
  161.                             break;
  162.                     }
  163.                 }
  164.                 else
  165.                 {
  166.                     if (Game.Player.Character.IsInVehicle())
  167.                     {
  168.                         NoControlTimer = 100;
  169.                     }
  170.                     switch (rnd.Next(6 + (int)Math.Round(easiness * 1.5)))
  171.                     {
  172.                         case 0:
  173.                             Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 600, 600, 0, false, false, false);
  174.                             break;
  175.                         case 1:
  176.                         case 2:
  177.                         case 3:
  178.                             Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 1500, 1500, 2, false, false, false);
  179.                             break;
  180.                         case 4:
  181.                         case 5:
  182.                             Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 1300, 1300, 3, false, false, false);
  183.                             break;
  184.                         default:
  185.                             break;
  186.                     }
  187.                 }
  188.  
  189.             }
  190.             else
  191.             {
  192.                 //UI.Notify("NO WEAPON OUCH!");
  193.             }
  194.  
  195.         }
  196.         if (Function.Call<bool>(Hash.IS_PED_RAGDOLL) && perform)
  197.         {
  198.             //Function.Call(Hash.CREATE_NM_MESSAGE, 1151);
  199.             //Function.Call(Hash.GIVE_PED_NM_MESSAGE, Game.Player.Character, true);
  200.             Function.Call(Hash.CREATE_NM_MESSAGE, true, 275);
  201.             Function.Call(Hash.GIVE_PED_NM_MESSAGE, Game.Player.Character);
  202.  
  203.         }
  204.  
  205.         prev_health = Game.Player.Character.Health;
  206.     }
  207.  
  208.     void OnKeyDown(object sender, EventArgs e)
  209.     {
  210.         KeyEventArgs pe = (KeyEventArgs)e;
  211.  
  212.         if (pe.KeyCode == Keys.H)
  213.         {
  214.         }
  215.         /*
  216.         if (pe.KeyCode == Keys.B)
  217.         {
  218.             //NoControlTimer = 100;
  219.             Ped ped = Game.Player.Character;
  220.             Function.Call(Hash.SET_PED_TO_RAGDOLL,ped, 15000, 15000, 0, false, false, false);
  221.         }
  222.  
  223.         if (pe.KeyCode == Keys.N)
  224.         {
  225.             Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 5000, 5000, 0, false, false, false);
  226.         }
  227.         */
  228.     }
  229.  
  230.     void OnKeyUp(object sender, EventArgs e)
  231.     {
  232.  
  233.     }
  234. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement