Log in to reply
 

Native to make game register bumping into and getting jacked?



  • Hey. I love playing as a freemode character in SP and giving her a voice to make her feel more alive. But there are still some things missing. I want her to react to being bumped into and getting jacked. (Although that happens very rarely.) I'm looking for the natives. Does anyone know them?

    I already found the jacking ones, I think.

    IS_PED_JACKING(Ped ped)
    IS_PED_BEING_JACKED(Ped ped)
    IS_PED_BEING_STUNNED(Ped ped, int p1)
    GET_PEDS_JACKER(Ped ped)
    GET_JACK_TARGET(Ped ped)



  • These might help:

    IS_ENTITY_TOUCHING_ENTITY(Entity entity, Entity targetEntity)
    IS_ENTITY_TOUCHING_MODEL(Entity entity, Hash modelHash)
    BOOL HAS_ENTITY_COLLIDED_WITH_ANYTHING(Entity entity)



  • @LeeC2202 Thanks. I'm going to test those. :)



  • Hello folks. I'm sorry for necro-ing this, but I'd like to pick up where I...uh... gave up 2 years ago. :grin:

    So, would someone be so kind and give an example for how I would go about making the player character register one of these:

    IS_PED_JACKING(Ped ped)
    IS_PED_BEING_JACKED(Ped ped)
    IS_PED_BEING_STUNNED(Ped ped, int p1)
    GET_PEDS_JACKER(Ped ped)
    GET_JACK_TARGET(Ped ped)
    IS_ENTITY_TOUCHING_ENTITY(Entity entity, Entity targetEntity)
    IS_ENTITY_TOUCHING_MODEL(Entity entity, Hash modelHash)
    BOOL HAS_ENTITY_COLLIDED_WITH_ANYTHING(Entity entity)

    and then playing speech?

    That would be immensely helpful and maybe I could continue from there. :)


  • MODERATOR

    First off - do you know some GTA scripting? Calling natives is straightforward and depending on the SDK you use easy to mock up a thing rather quickly.



  • @ikt Hi. Thanks for answering. I have some script sources I can work with. The problem is I do not understand the syntax of for example "IS_ENTITY_TOUCHING_ENTITY(Entity entity, Entity targetEntity)". Why is "entity" used thrice? Wouldn't it suffice to have it once and "targetEntity". Pure logic would dictate that "Entity" would be touching "targetEntity"?! :(


  • MODERATOR

    @Phnx What do you mean thrice? There are only two entity parameters. One should be set as PLAYED_PED_ID() and the other as the closest ped.


  • MODERATOR

    @Phnx
    No.

    First of all, the SHV SDK exposes it as BOOL IS_ENTITY_TOUCHING_ENTITY(Entity entity, Entity targetEntity);

    BOOL: Return type
    IS_ENTITY_TOUCHING_ENTITY: Function name
    Entity: Type
    entity: variable
    Entity: Type
    targetEntity: other variable

    You really need to look into some programming basics first.

    using System;
    using GTA;
    
    public class Blergh : Script
    {
        enum Touchable
        {
            Nothing,
            Vehicle,
            Ped,
            Object,
            Entity
        }
    
    	public Blergh()
    	{
    		Tick += OnTick;
    	}
    
    	void OnTick(object sender, EventArgs e)
    	{
    		Ped player = Game.Player.Character;
    
    	    if (player.HasCollidedWithAnything)
    	    {
    	        // do something
    	    }
    
    	    if (player.IsBeingJacked)
    	    {
    	        // do something else
    	    }
    
    	    if (player.IsJacking)
    	    {
    	        // more stuff
    	    }
    	}
    }
    

    Here's a quick .cs script. Get the SHVDN SDK to help you complete this by playing some audio.



  • @ikt Thanks so much! Yeah, you're right. My programming skills are nigh non-existent. I am able though to modify existing scripts. rappo provided his "The Bird" as open source. I already modified that to somewhat randomize the speech in that and I could use that as a base. Also I wasn't aware that the SDK provides a lot of documentation, sorry. One more thing though, then I may be all set, instead of player.HasCollidedWithAnything how would I tell the game that my player is touching a ped. I would need to use IS_ENTITY_TOUCHING_ENTITY(Entity entity, Entity targetEntity) so I can apply it to all peds not a specific model hash. Also, I'm asking because HasCollidedWithAnything probably includes objects.


  • MODERATOR

    The native only recognizes anything, nothing specific. You'd need to either loop through all peds and check (costly) or read the members of your ped (needs some memory fiddling).

    Here is a thread on GTAF about it though I don't know if the offsets are still up-to-date nor do I see the context (dereference playerPed as CEntity? idk)



  • Thanks again for the help!

    The script currently looks like this but isn't working:

    using GTA;
    using GTA.Math;
    using GTA.Native;
    using System;
    using System.Windows.Forms;

    public class Blergh : Script
    {
    enum Touchable
    {
    Nothing,
    Vehicle,
    Ped,
    Object,
    Entity
    }

    public Blergh()
    {
        Tick += OnTick;
    }
    System.Random random1 = new System.Random();
    //public void OnTick(object sender, EventArgs e)
    //{
    //Ped[] nearbyPeds = World.GetNearbyPeds(Game.Player.Character, 1);
    //foreach (Ped p in nearbyPeds)
    //{
    //if (p.IsTouching(Game.Player.Character))
    void OnTick(object sender, EventArgs e)
    {
        Ped player = Game.Player.Character;
    
            if (player.HasCollidedWithAnything)
            {
                // do something
                //switch (random1.Next(4))
                //{
                //case 3:
                Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument)Game.Player.Character, (InputArgument)"BUMP_01", (InputArgument)"SPEECH_PARAMS_FORCE", (InputArgument)0);
                //break;
                //case 2:
                //Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument)Game.Player.Character, (InputArgument)"BUMP_02", (InputArgument)"SPEECH_PARAMS_FORCE", (InputArgument)0);
                //break;
                //case 1:
                //Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument)Game.Player.Character, (InputArgument)"BUMP_03", (InputArgument)"SPEECH_PARAMS_FORCE", (InputArgument)0);
                //break;
            }
            //if (p.IsBeingJacked)
            if (player.IsJacking)
            //switch (random1.Next(4))
            {
                //case 3:
                Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument)Game.Player.Character, (InputArgument)"Hash._0x0006D643", (InputArgument)"SPEECH_PARAMS_FORCE", (InputArgument)0);
                //break;
                //case 2:
                //Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument)Game.Player.Character, (InputArgument)"Hash._0x00BED030", (InputArgument)"SPEECH_PARAMS_FORCE", (InputArgument)0);
                //break;
                //case 1:
                //Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument)Game.Player.Character, (InputArgument)"Hash._0x042EA3B4", (InputArgument)"SPEECH_PARAMS_FORCE", (InputArgument)0);
                //break;
            }
            //if (p.IsJacking)
            if (player.IsBeingJacked)
            //switch (random1.Next(4))
            {
                //case 3:
                Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument)Game.Player.Character, (InputArgument)"JACKED_GENERIC_01", (InputArgument)"SPEECH_PARAMS_FORCE", (InputArgument)0);
                //break;
                //case 2:
                //Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument) Game.Player.Character, (InputArgument) "JACKED_GENERIC_02", (InputArgument) "SPEECH_PARAMS_FORCE", (InputArgument) 0);
                //break;
                //case 1:
                //Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument) Game.Player.Character, (InputArgument) "JACKED_GENERIC_03", (InputArgument) "SPEECH_PARAMS_FORCE", (InputArgument) 0);
                //break;
            }
        //}
    }
    

    }

    As you can see by the parts commented out I have also experimented with a method different from yours, but it's not working as well.


  • MODERATOR

    Enclose your code in code tags. That's three backticks: ```

    Fixed it and cleaned it up:

    using GTA;
    using GTA.Math;
    using GTA.Native;
    using System;
    using System.Windows.Forms;
    
    public class Blergh : Script
    {
        public Blergh()
        {
            Tick += OnTick;
        }
    	    
        void OnTick(object sender, EventArgs e)
        {
            Ped player = Game.Player.Character;
    
    		if (player.HasCollidedWithAnything)
    		{
    			Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument)Game.Player.Character, (InputArgument)"BUMP_01", (InputArgument)"SPEECH_PARAMS_FORCE", (InputArgument)0);
    		}
    		if (player.IsJacking)
    		{
    			Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument)Game.Player.Character, (InputArgument)"Hash._0x0006D643", (InputArgument)"SPEECH_PARAMS_FORCE", (InputArgument)0);
    		}
    		if (player.IsBeingJacked)
    		{
    			Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument)Game.Player.Character, (InputArgument)"JACKED_GENERIC_01", (InputArgument)"SPEECH_PARAMS_FORCE", (InputArgument)0);
    		}
        }
    }
    

    The code looks fine, though I don't know the arguments you need to provide. You should consider checking out the NativeDB. That one for example links to this list that you can use to choose a proper speech thing from.

    Get the basics working first, then do your other things.



  • Hey. I was wondering what the code for that was. Thanks. Also, I'm sooo stupid. Actually the script DOES work, finally! Thanks again SO MUCH!!! I used incorrect code for the speech. It's just funny that even when bumping into ANYTHING my character now comments on how rude the dust bin is for standing in her way, lol! :D

    using GTA.Math;
    using GTA.Native;
    using System;
    using System.Windows.Forms;
    
    public class Bumped : Script
    {
        public Bumped()
        {
            Tick += OnTick;
        }
        System.Random random1 = new System.Random();
        void OnTick(object sender, EventArgs e)
        {
            Ped player = Game.Player.Character;
    
                if (player.HasCollidedWithAnything)
                    switch (random1.Next(3))
                    {
                    case 2:
                        Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument)Game.Player.Character, (InputArgument)"BUMP", (InputArgument)"SPEECH_PARAMS_FORCE", (InputArgument)0);
                        break;
                    case 1:
                        Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument)Game.Player.Character, (InputArgument)"PROVOKE_BUMPED_INTO", (InputArgument)"SPEECH_PARAMS_FORCE", (InputArgument)0);
                        break;
                    }
                if (player.IsJacking)
                    switch (random1.Next(3))
                    {
                    case 2:
                    Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument)Game.Player.Character, (InputArgument)"NICE_CAR", (InputArgument)"SPEECH_PARAMS_FORCE", (InputArgument)0);
                    break;
                    case 1:
                    Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument)Game.Player.Character, (InputArgument)"NICE_CAR_SHOUT", (InputArgument)"SPEECH_PARAMS_FORCE", (InputArgument)0);
                    break;
                    }
                if (player.IsBeingJacked)
                {
                    Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument)Game.Player.Character, (InputArgument)"JACKED_GENERIC", (InputArgument)"SPEECH_PARAMS_FORCE", (InputArgument)0);
                }
        }
    }

Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.