Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using GTA;
- using GTA.Native;
- using System;
- using System.IO;
- using System.Windows.Forms;
- public class Main : Script
- {
- int prev_health = Game.Player.Character.Health;
- Random rnd = new Random();
- int NoControlTimer = -1;
- String ini = @".\scripts\PlayerBulletRagdollReactions.ini";
- ScriptSettings iniset;
- String version = "1.0.0";
- int easiness = 0;
- bool disableAtMission = false;
- public Main()
- {
- Tick += OnTick;
- KeyDown += OnKeyDown;
- KeyUp += OnKeyUp;
- Interval = 10;
- if (!File.Exists(ini))
- {
- File.Create(ini).Close();
- iniset = ScriptSettings.Load(ini);
- iniset.SetValue("Settings", "easiness", 0);
- iniset.SetValue("Settings", "disableAtMission", false);
- iniset.Save();
- }
- iniset = ScriptSettings.Load(ini);
- easiness = iniset.GetValue<int>("Settings", "easiness", 0);
- disableAtMission = iniset.GetValue<bool>("Settings", "disableAtMission", false);
- UI.Notify("Player Bullet Ragdoll Reactions version " + version + " loaded!");
- }
- void OnTick(object sender, EventArgs e)
- {
- //UI.Notify("NoControlTimer:" + NoControlTimer.ToString());
- /*
- * NoControlTimer = 50 -> EQUALS ONE SECOND
- */
- bool perform = true;
- if (Game.MissionFlag && disableAtMission)
- {
- perform = false;
- NoControlTimer = -1;
- }
- if (NoControlTimer >= 0 && perform)
- {
- Game.DisableControlThisFrame(0, GTA.Control.VehicleAccelerate);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleBrake);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleDuck);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleExit);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleHorn);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleJump);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleMoveLeft);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleMoveRight);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleParachute);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleRocketBoost);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleShuffle);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleSpecial);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleMoveLeftOnly);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleMoveRightOnly);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleSubTurnHardLeft);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleSubTurnHardRight);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleLookLeft);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleLookRight);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleMoveLeftRight);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleHandbrake);
- Game.DisableControlThisFrame(0, GTA.Control.VehiclePushbikeFrontBrake);
- Game.DisableControlThisFrame(0, GTA.Control.VehiclePushbikeRearBrake);
- Game.DisableControlThisFrame(0, GTA.Control.VehiclePushbikePedal);
- Game.DisableControlThisFrame(0, GTA.Control.VehicleGrapplingHook);
- if (Game.Player.Character.IsInVehicle())
- {
- Function.Call(Hash._START_SCREEN_EFFECT, "MinigameTransitionOut", 1000, false);
- }
- NoControlTimer -= 1;
- }
- int health = Game.Player.Character.Health;
- if (prev_health > health && perform)
- {
- //has been damaged
- bool hasBeenDamagedByWeapon = Function.Call<bool>(Hash.HAS_PED_BEEN_DAMAGED_BY_WEAPON, Game.Player.Character, 0, 2);
- if (hasBeenDamagedByWeapon)
- {
- //UI.Notify("Lost Health: " + (prev_health - health).ToString());
- int lostHealth = prev_health - health;
- if (lostHealth < 5)
- {
- }
- else if (lostHealth >= 5 && lostHealth < 8)
- {
- switch (rnd.Next(5 + easiness))
- {
- case 1:
- Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 400, 400, 3, false, false, false);
- break;
- case 2:
- Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 400, 400, 2, false, false, false);
- break;
- default:
- break;
- }
- }
- else if (lostHealth >= 8 && lostHealth < 14)
- {
- if (Game.Player.Character.IsInVehicle())
- {
- NoControlTimer = 25;
- }
- switch (rnd.Next(5 + easiness))
- {
- case 0:
- Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 500, 500, 0, false, false, false);
- break;
- case 1:
- Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 400, 400, 3, false, false, false);
- break;
- case 2:
- Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 500, 500, 2, false, false, false);
- break;
- default:
- break;
- }
- }
- else if (lostHealth >= 14 && lostHealth < 18)
- {
- if (Game.Player.Character.IsInVehicle())
- {
- NoControlTimer = 50;
- }
- switch (rnd.Next(4 + (int)Math.Round(easiness * 1.2)))
- {
- case 0:
- Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 400, 400, 0, false, false, false);
- break;
- case 1:
- Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 800, 800, 3, false, false, false);
- break;
- case 2:
- Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 800, 800, 2, false, false, false);
- break;
- case 3:
- Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 500, 500, 2, false, false, false);
- break;
- default:
- break;
- }
- }
- else
- {
- if (Game.Player.Character.IsInVehicle())
- {
- NoControlTimer = 100;
- }
- switch (rnd.Next(6 + (int)Math.Round(easiness * 1.5)))
- {
- case 0:
- Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 600, 600, 0, false, false, false);
- break;
- case 1:
- case 2:
- case 3:
- Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 1500, 1500, 2, false, false, false);
- break;
- case 4:
- case 5:
- Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 1300, 1300, 3, false, false, false);
- break;
- default:
- break;
- }
- }
- }
- else
- {
- //UI.Notify("NO WEAPON OUCH!");
- }
- }
- if (Function.Call<bool>(Hash.IS_PED_RAGDOLL) && perform)
- {
- //Function.Call(Hash.CREATE_NM_MESSAGE, 1151);
- //Function.Call(Hash.GIVE_PED_NM_MESSAGE, Game.Player.Character, true);
- Function.Call(Hash.CREATE_NM_MESSAGE, true, 275);
- Function.Call(Hash.GIVE_PED_NM_MESSAGE, Game.Player.Character);
- }
- prev_health = Game.Player.Character.Health;
- }
- void OnKeyDown(object sender, EventArgs e)
- {
- KeyEventArgs pe = (KeyEventArgs)e;
- if (pe.KeyCode == Keys.H)
- {
- }
- /*
- if (pe.KeyCode == Keys.B)
- {
- //NoControlTimer = 100;
- Ped ped = Game.Player.Character;
- Function.Call(Hash.SET_PED_TO_RAGDOLL,ped, 15000, 15000, 0, false, false, false);
- }
- if (pe.KeyCode == Keys.N)
- {
- Function.Call(Hash.SET_PED_TO_RAGDOLL, Game.Player.Character, 5000, 5000, 0, false, false, false);
- }
- */
- }
- void OnKeyUp(object sender, EventArgs e)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement