Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
      4. Frontier Pursuits
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. DLC
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
      7. The Diamond Casino Heist
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA IV Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA SA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA VC Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA III Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

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

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

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

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

    2. Forum Support

    3. Site Suggestions

Freakyy

Relationship Groups (stopping random peds from fleeing)

Recommended Posts

Freakyy

In order to stop random peds from fleeing, you'll need to set up a relationship group for them.
I was looking through the decompiled scripts yesterday, and these are my findings. I am not sure if it has been posted before, but in the Skype group with other ScriptHookV developers, many people had problems with this.

Setting up a Relationship Group
First of all, you set up a relationship group:

PED::ADD_RELATIONSHIP_GROUP(char* name, Any* out_hash)


I suggest you use a name that is not used by the game internally, so be creative. The function will setup the relationship group, the second parameter will contain the hashed string.

Relationship to other Groups
The next step is to setup the Relationship to other Relationship Groups.

PED::SET_RELATIONSHIP_BETWEEN_GROUPS(int relation, Any group_1, Any group_2)


group_1 and group_2 are both hashes. 0x6F0783F5 (string: "PLAYER") is your player.

Quick Example:

PED::SET_RELATIONSHIP_BETWEEN_GROUPS(1, new_group, 0x6F0783F5)
PED::SET_RELATIONSHIP_BETWEEN_GROUPS(5, 0x6F0783F5, new_group)


This will stop random peds from fleeing, because they are "allies" (1) to you. However, if you aim at them your crosshair will be red since they are an enemy (5) to you. I am not sure about the other numbers used, but 2/3 seems to be neutral. In some scripts 255 is also used, but I really have no clue for what.

Assigning peds the Relationship Group
Now that you have set the Relationship Group up, be sure to assign the hash to a ped.

PED::SET_PED_RELATIONSHIP_GROUP_HASH(Any ped_id, Any hash)


Done
This will stop random peds from fleeing (as long as you actually assign the hash).

  • Like 4

Share this post


Link to post
Share on other sites
MAFINS

Radical. B)

Share this post


Link to post
Share on other sites
dehan

They still get in the vehicle look at you get out then repeat that with this

Share this post


Link to post
Share on other sites
xsploit

So if i spawned the zombie model they would still attack if i pointed a weapon at them even when unarmed?

Share this post


Link to post
Share on other sites
XenoxX

I have a problem with the second parameter of this:

PED::ADD_RELATIONSHIP_GROUP(char* name, Any* out_hash)

In the natives it isnt Any* but Hash

so:

PED::ADD_RELATIONSHIP_GROUP(char* name, Hash* group_hash)

But where do I get the "group hashes" ? Shall I just define one ?

Share this post


Link to post
Share on other sites
ChOcOsKiZo

I have a problem with the second parameter of this:

 

PED::ADD_RELATIONSHIP_GROUP(char* name, Any* out_hash)

In the natives it isnt Any* but Hash

so:

PED::ADD_RELATIONSHIP_GROUP(char* name, Hash* group_hash)

But where do I get the "group hashes" ? Shall I just define one ?

if you create a group , like bodyguards you can define one like "mygroup" or whatever you want

 

the groups names are (i'm on ps3) in the data folder from the common rpf , here http://prntscr.com/7b5ez1

 

 

#	Acquaintance options:#	- Hate#	- Dislike #	- Like	#	- RespectPLAYERCIVMALE	CIVFEMALE	COP SECURITY_GUARDPRIVATE_SECURITYFIREMANGANG_1GANG_2GANG_9GANG_10AMBIENT_GANG_LOSTAMBIENT_GANG_MEXICANAMBIENT_GANG_FAMILYAMBIENT_GANG_BALLASAMBIENT_GANG_MARABUNTEAMBIENT_GANG_CULTAMBIENT_GANG_SALVAAMBIENT_GANG_WEICHENGAMBIENT_GANG_HILLBILLYDEALERHATES_PLAYERHENWILD_ANIMALSHARKCOUGARNO_RELATIONSHIPSPECIALMISSION2MISSION3MISSION4MISSION5MISSION6MISSION7MISSION8ARMYGUARD_DOGAGGRESSIVE_INVESTIGATEMEDIC#PLAYER	Like PLAYERCIVMALE	#   Respect CIVMALE#   Respect CIVFEMALECIVFEMALE	#   Respect CIVFEMALE#   Respect CIVMALECOP     Respect MEDIC FIREMAN COP    Respect ARMY    Like SECURITY_GUARDARMY    Like ARMY    Respect COP SECURITY_GUARD    Like COP SECURITY_GUARD GUARD_DOGPRIVATE_SECURITY	Like PRIVATE_SECURITY GUARD_DOGPRISONER	Like PRISONER    Hate PLAYERFIREMAN    Respect MEDIC FIREMAN COPGANG_1	Respect GANG_1GANG_2	Respect GANG_2GANG_9	Respect GANG_9GANG_10	Respect GANG_10HATES_PLAYER	Hate PLAYER	Like HATES_PLAYER AGGRESSIVE_INVESTIGATEHEN	Dislike PLAYERAMBIENT_GANG_LOST	Like AMBIENT_GANG_LOST GUARD_DOGAMBIENT_GANG_MEXICAN	Like AMBIENT_GANG_MEXICAN GUARD_DOGAMBIENT_GANG_FAMILY	Like AMBIENT_GANG_FAMILY GUARD_DOGAMBIENT_GANG_BALLAS	Like AMBIENT_GANG_BALLAS GUARD_DOGAMBIENT_GANG_MARABUNTE	Like AMBIENT_GANG_MARABUNTE GUARD_DOGAMBIENT_GANG_CULT	Like AMBIENT_GANG_CULT GUARD_DOGAMBIENT_GANG_SALVA	Like AMBIENT_GANG_SALVA GUARD_DOGAMBIENT_GANG_WEICHENG	Like AMBIENT_GANG_WEICHENG GUARD_DOGAMBIENT_GANG_HILLBILLY	Like AMBIENT_GANG_HILLBILLY GUARD_DOGDOMESTIC_ANIMAL	Hate PLAYER	Like CIVMALE CIVFEMALE COP SECURITY_GUARD DOMESTIC_ANIMAL FIREMAN GANG_1 GANG_2 GANG_9 GANG_10 AMBIENT_GANG_LOST AMBIENT_GANG_MEXICAN AMBIENT_GANG_BALLAS AMBIENT_GANG_FAMILY DEALER HATES_PLAYERWILD_ANIMAL	Hate PLAYER CIVMALE CIVFEMALE COP SECURITY_GUARD FIREMAN GANG_1 GANG_2 GANG_9 GANG_10 AMBIENT_GANG_LOST AMBIENT_GANG_MEXICAN AMBIENT_GANG_BALLAS AMBIENT_GANG_FAMILY DEALER HATES_PLAYERDEER	Hate PLAYER CIVMALE CIVFEMALE COP SECURITY_GUARD FIREMAN GANG_1 GANG_2 GANG_9 GANG_10 AMBIENT_GANG_LOST AMBIENT_GANG_MEXICAN AMBIENT_GANG_BALLAS AMBIENT_GANG_FAMILY DEALER HATES_PLAYER	Respect DEERSHARK	Hate PLAYERGUARD_DOG	Like GUARD_DOG CIVMALE CIVFEMALE SECURITY_GUARD AMBIENT_GANG_LOST AMBIENT_GANG_MEXICAN AMBIENT_GANG_FAMILY AMBIENT_GANG_BALLAS AMBIENT_GANG_MARABUNTE AMBIENT_GANG_CULT AMBIENT_GANG_SALVA AMBIENT_GANG_WEICHENG AMBIENT_GANG_HILLBILLY PRIVATE_SECURITYAGGRESSIVE_INVESTIGATE	Hate PLAYER	Like HATES_PLAYER AGGRESSIVE_INVESTIGATEMEDIC	Like MEDIC	Respect COP ARMY SECURITY_GUARD FIREMANCOUGAR	Hate PLAYER CIVMALE CIVFEMALE SECURITY_GUARD AMBIENT_GANG_LOST AMBIENT_GANG_MEXICAN AMBIENT_GANG_FAMILY AMBIENT_GANG_BALLAS AMBIENT_GANG_MARABUNTE AMBIENT_GANG_CULT AMBIENT_GANG_SALVA AMBIENT_GANG_WEICHENG AMBIENT_GANG_HILLBILLY PRIVATE_SECURITY COP ARMY PRISONER FIREMAN
  • Like 1

Share this post


Link to post
Share on other sites
Ethenal

So then presumably one would use GAMEPLAY::GET_HASH_KEY with the argument "COP" (or any other string from relationships.dat) and then you can supply that hash to the relationship commands.

 

I'll try that out soon, I'm trying to get the police to attack certain people.

Edited by Ethenal

Share this post


Link to post
Share on other sites
XenoxX

Allright I fiddled a little with relationships, and I came to the conclusion, that relationships applied to created Peds does not have any affect what so ever, you would need to script those in yourselfs,

or did anyone found a way to use the default Ped actions from Pedestrians, Gangs etc. ?

Share this post


Link to post
Share on other sites
Ethenal
// spawn criminal        unsafe public void SpawnCriminal()        {            // spawn a ped that will flee from the police            // first load our ped models            Model pedModel = new Model(PedHash.Business01AMY);            if ((pedModel.IsInCdImage && pedModel.IsPed && pedModel.Request(1000)))            {                // get position in front of player                Ped player = Game.Player.Character;                Vector3 spawnPos = player.Position + (player.ForwardVector * 7.5f);                // now spawn the ped                Ped newPed = World.CreatePed(pedModel, spawnPos.Around(5.0f));                if ((newPed != null) && newPed.Exists())                {                    // for deleting ped later                    pedList.Add(newPed);                    // set ped relationship (long winded)                    int pedHash = 0;                    int* pedHashP = &pedHash;                    int copHash = Function.Call<int>(Hash.GET_HASH_KEY, "COP");                    Function.Call(Hash.ADD_RELATIONSHIP_GROUP, "TEST123", pedHashP);                    Function.Call(Hash.SET_PED_RELATIONSHIP_GROUP_HASH, newPed.Handle, pedHash);                    Function.Call(Hash.SET_RELATIONSHIP_BETWEEN_GROUPS, 5, copHash, pedHash);                    Function.Call(Hash.SET_RELATIONSHIP_BETWEEN_GROUPS, 5, pedHash, copHash);                    // arm ped                    newPed.Weapons.Give(WeaponHash.CarbineRifle, 3000, true, true);                    newPed.CanSwitchWeapons = true;                                        // ped should fight nearby targets                    newPed.Task.FightAgainstHatedTargets(300.0f);                }            }        }

That worked for me with latest version of scripthookvdotnet from github.

  • Like 3

Share this post


Link to post
Share on other sites
whorse

I have been messing with relationship groups in my riot mod. For most peds on the street (with their default groups and relationships), they will fight eachother and the player and will not flee even if you shoot them so long as you use these commands:

PED::SET_BLOCKING_OF_NON_TEMPORARY_EVENTS(pedHandle, true);// thenAI::TASK_PUT_PED_DIRECTLY_INTO_MELEE(pedHandle, targetPed, 0, 0, 0, 0);// orAI::TASK_COMBAT_PED(pedHandle, targetPed, 0, 16);

However, animals like the coyote and the retriever will always trot away (I guess they're fleeing?) unless I set their relationship group to "cougar" or to "wild animal". I tried setting all the peds to relationship group cougar or wild_animal and it works great -- cops will attack SWAT, etc -- but they are too hostile against the player when I set their player-group relationship to 3, 3 . If I change it to 2,3, they wont chase you so much, but if I try changing it back to 3,3 without restarting the game, about half of the peds start running away from the player in fear, and nothing I try seems to fix it (not even setting it to 5,5 or 1,1). How do I use "CLEAR_RELATIONSHIP_BETWEEN_GROUPS"? It has an integer value like the SET commands, even though you are clearing the value.. Would I have to clear both 2 and 3 for all groups involved?

 

They also would flee when I tried setting the values to 1 thru 5 using my own groups (which had default relationship values of "255" to eachother)

 

EDIT: Nevermind, I think it was because the regular civilain groups have a default reaction to flee anyone from the cougar group, so since the script couldnt touch every single ped, a ton of them were running away from the cougars. I fixed it by changing the civmale and civfemale relationships with the cougar group both to 1

Edited by whorse

Share this post


Link to post
Share on other sites
froggz19

I have been messing with relationship groups in my riot mod. For most peds on the street (with their default groups and relationships), they will fight eachother and the player and will not flee even if you shoot them so long as you use these commands:

PED::SET_BLOCKING_OF_NON_TEMPORARY_EVENTS(pedHandle, true);// thenAI::TASK_PUT_PED_DIRECTLY_INTO_MELEE(pedHandle, targetPed, 0, 0, 0, 0);// orAI::TASK_COMBAT_PED(pedHandle, targetPed, 0, 16);

However, animals like the coyote and the retriever will always trot away (I guess they're fleeing?) unless I set their relationship group to "cougar" or to "wild animal". I tried setting all the peds to relationship group cougar or wild_animal and it works great -- cops will attack SWAT, etc -- but they are too hostile against the player when I set their player-group relationship to 3, 3 . If I change it to 2,3, they wont chase you so much, but if I try changing it back to 3,3 without restarting the game, about half of the peds start running away from the player in fear, and nothing I try seems to fix it (not even setting it to 5,5 or 1,1). How do I use "CLEAR_RELATIONSHIP_BETWEEN_GROUPS"? It has an integer value like the SET commands, even though you are clearing the value.. Would I have to clear both 2 and 3 for all groups involved?

 

They also would flee when I tried setting the values to 1 thru 5 using my own groups (which had default relationship values of "255" to eachother)

 

EDIT: Nevermind, I think it was because the regular civilain groups have a default reaction to flee anyone from the cougar group, so since the script couldnt touch every single ped, a ton of them were running away from the cougars. I fixed it by changing the civmale and civfemale relationships with the cougar group both to 1

 

This is how I set the relationship to cougar?

Ped spawnedPed = PED::CREATE_PED(28, ModelHash, coords.x, coords.y, coords.z, ENTITY::GET_ENTITY_HEADING(playerPed), TRUE, FALSE);Hash MTLION = GAMEPLAY::GET_HASH_KEY("COUGAR");PED::SET_PED_RELATIONSHIP_GROUP_HASH(spawnedPed, MTLION);

It doesn't work, shark always runs away :(

 

Any help please?

Share this post


Link to post
Share on other sites
whorse

 

This is how I set the relationship to cougar?

Ped spawnedPed = PED::CREATE_PED(28, ModelHash, coords.x, coords.y, coords.z, ENTITY::GET_ENTITY_HEADING(playerPed), TRUE, FALSE);Hash MTLION = GAMEPLAY::GET_HASH_KEY("COUGAR");PED::SET_PED_RELATIONSHIP_GROUP_HASH(spawnedPed, MTLION);

It doesn't work, shark always runs away :(

 

Any help please?

 

Yeah that should work, though you can combine the last two lines:

PED::SET_PED_RELATIONSHIP_GROUP_HASH(spawnedPed, GAMEPLAY::GET_HASH_KEY("COUGAR"));

I've never even seen a shark flee from anything, but you could try telling it specifically to attack whatever target you want it to attack with:

TASK_COMBAT_PED(shark, targetPed, 0 ,16);//orPED::REGISTER_HATED_TARGETS_AROUND_PED(shark, 200); //not sure if this is necessaryAI::TASK_COMBAT_HATED_TARGETS_AROUND_PED(shark, 200, 0);//orAI::TASK_PUT_PED_DIRECTLY_INTO_MELEE(shark, targetPed, 0,0,0,0);

And also by setting its flee attributes and combat attributes as described in my post you quoted.

 

I have no experience doing this with acquatic animals, though, and just getting regular animals like dogs to fight is hard enough to do. You might need to clear the shark's tasks or use REMOVE_PED_FROM_GROUP or something to get it to stop doing whatever pre-programmed shark-tasks it was doing before.

Edited by whorse

Share this post


Link to post
Share on other sites
froggz19

 

 

This is how I set the relationship to cougar?

Ped spawnedPed = PED::CREATE_PED(28, ModelHash, coords.x, coords.y, coords.z, ENTITY::GET_ENTITY_HEADING(playerPed), TRUE, FALSE);Hash MTLION = GAMEPLAY::GET_HASH_KEY("COUGAR");PED::SET_PED_RELATIONSHIP_GROUP_HASH(spawnedPed, MTLION);

It doesn't work, shark always runs away :(

 

Any help please?

 

Yeah that should work, though you can combine the last two lines:

PED::SET_PED_RELATIONSHIP_GROUP_HASH(spawnedPed, GAMEPLAY::GET_HASH_KEY("COUGAR"));

I've never even seen a shark flee from anything, but you could try telling it specifically to attack whatever target you want it to attack with:

TASK_COMBAT_PED(shark, targetPed, 0 ,16);//orPED::REGISTER_HATED_TARGETS_AROUND_PED(shark, 200); //not sure if this is necessaryAI::TASK_COMBAT_HATED_TARGETS_AROUND_PED(shark, 200, 0);//orAI::TASK_PUT_PED_DIRECTLY_INTO_MELEE(shark, targetPed, 0,0,0,0);

And also by setting its flee attributes and combat attributes as described in my post you quoted.

 

I have no experience doing this with acquatic animals, though, and just getting regular animals like dogs to fight is hard enough to do. You might need to clear the shark's tasks or use REMOVE_PED_FROM_GROUP or something to get it to stop doing whatever pre-programmed shark-tasks it was doing before.

 

 

Thank you very much!

 

This one works, every animal is trying to attack, even the rabbit :))

AI::TASK_PUT_PED_DIRECTLY_INTO_MELEE(shark, targetPed, 0,0,0,0);
Edited by froggz19

Share this post


Link to post
Share on other sites
froggz19

sharkie sharkie

Edited by froggz19

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 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.