Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

[I] Script idea - headshot.


lolleroz
 Share

Recommended Posts

Here is a simple script idea I had on my mind, if someone has scripting abilities and doesn't have idea he can always use this ^^.

Okay so we can notice, AIs (peds, cops etc) always die by headshot. However, player doesn't.

So why not make a script where your HP drops to 0 if you get a headshot?

Naturally, there would be chance of dying, like 40% (customizable in ini). Why is that? Because you could get shot in the face, not in the brain (which makes a difference) if you would get shot in the cheek with 9mm you wouldn't instantly die (although it wouldn't be totally non-lethal as well)

so basicly here's what you can do

 

As you know whenever Niko gets shot, you can see bloodstains on his clothes depending on where he got shot

you can often see blood stain on his head indicating he got shot in the head, but he doesnt die

so the point is, make a script which detects if niko has blood decal on his head (im sure this is possible to do) and then execute a script line, where script would determine if his HP drops to 0 or not (based on the chance user sets in the ini, if you set it to 100% you die right away, if to 50% theres a chance of surviving)

Link to comment
Share on other sites

Here is a simple script idea I had on my mind, if someone has scripting abilities and doesn't have idea he can always use this ^^.

Okay so we can notice, AIs (peds, cops etc) always die by headshot. However, player doesn't.

So why not make a script where your HP drops to 0 if you get a headshot?

Naturally, there would be chance of dying, like 40% (customizable in ini). Why is that? Because you could get shot in the face, not in the brain (which makes a difference) if you would get shot in the cheek with 9mm you wouldn't instantly die (although it wouldn't be totally non-lethal as well)

so basicly here's what you can do

 

As you know whenever Niko gets shot, you can see bloodstains on his clothes depending on where he got shot

you can often see blood stain on his head indicating he got shot in the head, but he doesnt die

so the point is, make a script which detects if niko has blood decal on his head (im sure this is possible to do) and then execute a script line, where script would determine if his HP drops to 0 or not (based on the chance user sets in the ini, if you set it to 100% you die right away, if to 50% theres a chance of surviving)

The game doesn't actually apply decals on where the player is shot, it only has various levels of blood. Even if the game does that, there isn't a function to detect the place of decals.

 

But what you described is totally possible:

 

Here's some pseudo-code using things in scripting.h from Scripthook. Should work, but for name of limbs, I have no idea.

 

 

GetCharLastDamageBone(PlayerChar, &placeshot);if (placeshot == head){DamageChar(PlayerChar, hitPoints, true);}

 

 

If you want, give it a shot. Coding isn't very hard to smile.gif

Link to comment
Share on other sites

Thanks, I'll try to work something out even if I haz no experience.

Link to comment
Share on other sites

Done biggrin.gif

This should anyone give a small start.

 

I'm not very good with C# but this is what I got so far (it works).

 

using System;using GTA;public class HeadshotTest : Script{   public HeadshotTest()   {       Interval = 250;       this.Tick += new EventHandler(this.HeadshotTest_Tick);   }   private void HeadshotTest_Tick(object sender, EventArgs e)   {       GTA.Native.Pointer BonePointer = typeof(Int32);       GTA.Native.Function.Call("GET_CHAR_LAST_DAMAGE_BONE", Player.Character, BonePointer);       string sBone = BonePointer.ToString();       // GTA.Bone.Neck = 1204 (BONE_NECK: 0x4B4)       // GTA.Bone.Head = 1205 (BONE_HEAD: 0x4B5)       switch (sBone)       {           case "1205":               Game.DisplayText("HEADSHOT!!");               break;           //case "":           //    ........           //    break;           //case "":           //    ........           //    break;       }   }}

 

Link to comment
Share on other sites

Done biggrin.gif

This should anyone give a small start.

 

I'm not very good with C# but this is what I got so far (it works).

 

using System;using GTA;public class HeadshotTest : Script{   public HeadshotTest()   {       Interval = 250;       this.Tick += new EventHandler(this.HeadshotTest_Tick);   }   private void HeadshotTest_Tick(object sender, EventArgs e)   {       GTA.Native.Pointer BonePointer = typeof(Int32);       GTA.Native.Function.Call("GET_CHAR_LAST_DAMAGE_BONE", Player.Character, BonePointer);       string sBone = BonePointer.ToString();       // GTA.Bone.Neck = 1204 (BONE_NECK: 0x4B4)       // GTA.Bone.Head = 1205 (BONE_HEAD: 0x4B5)       switch (sBone)       {           case "1205":               Game.DisplayText("HEADSHOT!!");               break;           //case "":           //    ........           //    break;           //case "":           //    ........           //    break;       }   }}

 

So if I understand properly, with your script whenever Niko gets a headshot he dies and a text 'HEADSHOT!' appears? Sounds really cool, testing it at the time. Thanks alot for your effort guys, to be honest I expected no answer.

Link to comment
Share on other sites

For now it only displays the text, but you can do whatever you want when he gets a headshot. :-)

Link to comment
Share on other sites

Oh, cool, thank you ^^

Link to comment
Share on other sites

In C++ for Scripthook:

 

void CustomThread::RunTick(){Player PlayerIndex = ConvertIntToPlayerIndex(GetPlayerId());   Ped PlayerChar;   GetPlayerChar(PlayerIndex, &PlayerChar);ePedBone placeshot;GetCharLastDamageBone(PlayerChar, &placeshot);u32 randInt;GenerateRandomIntInRange(0, 1000, &randInt); //generates random int between 0 and 1000if (((placeshot == 0x4B4) || (placeshot == 0x4B5)) && (randInt > 800)) //neckshot or headshot, 80% chance of lethality{ DamageChar(PlayerChar, 1000, true); //1000 to make sure player will be dead with armor}if (((placeshot == 0x4B4) || (placeshot == 0x4B5)) && (randInt <= 200)) //neckshot or headshot, 20% survivable{ DamageChar(PlayerChar, 150, true); //150 is enough to kill you when the health bar blinks red, otherwise it will make it blink. (150 should be 75% health)}}

 

Paste and it should work.

 

If you want to be even more accurate, open the url mentioned above with bone info and modify stuff. You can even choose eyes, mouth and forehead, so it should be entirely possible to make something realistic. It's even possible to detect if Niko is hit in his spine and make him ragdoll, but that's too realistic to be fun. Breaking (disabling) limbs should be very possible. Or make Niko lay o the ground when hit in the nuts.

 

ENDLESS POSSIBILITIES!

Edited by ikt
Link to comment
Share on other sites

Not really, they don't hit many spots...

On my tests they didn't even hit the neck or forehead.

Link to comment
Share on other sites

Not really, they don't hit many spots...

On my tests they didn't even hit the neck or forehead.

Oh well, limping is an option.

Link to comment
Share on other sites

I think there's one problem though, I think the game never removes the value from GET_CHAR_LAST_DAMAGE_BONE...

Because I just died twice after getting a headshot....

 

Also, I don't think you need to give damage when you don't kill Niko, headshots do a lot of damage already.

So with this script, it's either a lot of damage or death (70% chance).

 

Here's my new version btw, was kind of figuring out how to get the proper type from the pointer, since it only gave me the ToString() function...

 

http://pastebin.com/Ni1S3GCq

 

using System;using GTA;// CAPTURING HEADSHOTS// ©2011 LouNGeR// For http://www.gtaforums.com/index.php?act=ST&t=475837public class HeadshotTest : Script{   public HeadshotTest()   {       Interval = 250;       this.Tick += new EventHandler(this.HeadshotTest_Tick);   }   private void HeadshotTest_Tick(object sender, EventArgs e)   {       GTA.Native.Pointer BonePointer = typeof(Int32);       GTA.Native.Function.Call("GET_CHAR_LAST_DAMAGE_BONE", Player.Character, BonePointer);       Int32 iBone = Convert.ToInt32(BonePointer.Value);       // http://www.gtamodding.com/index.php?title=Ped_Bones       // BONE_NECK: 0x4B4       // BONE_HEAD: 0x4B5       switch (iBone)       {           case 0x4B5:               //Game.DisplayText("HEADSHOT!!");                     // Received a headshot               Random RNG = new Random((int)DateTime.Now.Ticks);               Double RandomNumber = RNG.NextDouble();               if (RandomNumber < .7)                              // Let's say Niko has a 70% chance of dying                   Player.Character.Die();               break;       }   }}

 

Edited by L0uNGeR
Link to comment
Share on other sites

Marry me and let's have a threesome

 

Wait...wat.

 

Thanks alot for your help guys, I'm editing Lounger's (great job mate!) script at the time, trying to add more possibilities of damages...I just wish we could do the same to peds (it would prolly slow down the game as hell)

 

Can't wait to be unable to move after getting shot 3 times in my back with AK...lol.

It's pretty good along with my realistic weapon statistics, I made the weapons more powerfull but made AI less accurate (although, they are still very lethal!) as well to balance things out (I didn't like how they could shoot you 5 times when running in slalom anyway)

Link to comment
Share on other sites

I just wish we could do the same to peds (it would prolly slow down the game as hell)

If you would apply this endless loop to every ped in the game, yes...

But there are ways, like doing checks on all peds withing a reasonable radius.

Link to comment
Share on other sites

Didn't know about that, cool, cool ^^

Link to comment
Share on other sites

  • 8 months later...

this sounds like a promising conversation. so if i am to understand correctly, i could adapt these scripts to "checks on all peds withing a reasonable radius" then 'ragdoll' specific limbs, or make their model disappear (like first person mod)?

 

oh my god.

Link to comment
Share on other sites

lindsayslorach

How about you cast the integer from last damage bone to type GTA.Bone? It would make it so much easier! Then in your switch statement you could do "case Bone.Head:" or whatever.

 

@jitsuin: In your code you have a comment saying that you can remove the Exists() check if including Niko, but that check has nothing to do with checking if "p" is Niko, it's checking if "p" exists. You also don't even use the Ped variable "p" you defined at the top of the script.

Link to comment
Share on other sites

I figure niko will exist so if u do something with p it will always have ped p,

 

confused.gif crashed when i shot someone in the head, i missed something

Edited by jitsuin
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.