Jump to content
×
×
  • Create New...

Ped Relationships - Stop peds from shooting each other


Dominic1337
 Share

Reason for Locking
Inactivity

By Benzaboy, on 10/26/20 02:23 PM.

Recommended Posts

Has anyone found a way to spawn multiple peds and have them shoot the player? They automatically start killing each other, regardless if they are in a gang or not.

 

I have experimented with some ped relationship natives but so far have found none that work.

 

Example of what I am trying to do. (Very simple script but the peds keep killing each other)

suspect1.Weapons.Give(WeaponHash.HeavySniper, 600, true, true);
suspect2.Weapons.Give(WeaponHash.CarbineRifle, 600, true, true);
suspect3.Weapons.Give(WeaponHash.SweeperShotgun, 600, true, true);

suspect1.Task.FightAgainst(player);
suspect2.Task.FightAgainst(player);
suspect3.Task.FightAgainst(player);

Thanks

Edited by Dominic1337
Link to post
Share on other sites

  • 1 month later...

working on this also and just can not get there! you can see everything is good the AI are running at the player until one of them shoot at me, the one shoots the other!! hope someone can fix this soon

 

Link to post
Share on other sites

Is it confirmed that `player` is the player itself and not another entity? I don't see a reason why this code wouldn't work. I'd also make sure that the suspect's relationship between each other is positive or whichever GTA has, so they're not going to automatically start fighting each other.

NorthCam18

Arguably the best VIP member here

 

GitHub Account

Link to post
Share on other sites

I didn't think about the relationship of the two, have to read up on that lol. I am using 

suspect.AlwaysKeepTask = true; and I guess that's what is stoping them from shooting each other at first.

3 hours ago, NorthCam18 said:

Is it confirmed that `player` is the player itself and not another entity? I don't see a reason why this code wouldn't work. I'd also make sure that the suspect's relationship between each other is positive or whichever GTA has, so they're not going to automatically start fighting each other.

 

Link to post
Share on other sites

50 minutes ago, CrazyKelly said:

I didn't think about the relationship of the two, have to read up on that lol. I am using 

suspect.AlwaysKeepTask = true; and I guess that's what is stoping them from shooting each other at first.

 

Sounds good, did that fix the issue?

NorthCam18

Arguably the best VIP member here

 

GitHub Account

Link to post
Share on other sites

1 hour ago, NorthCam18 said:

Sounds good, did that fix the issue?

It stopped them from killing one and other until one of them shoots ,then the other one turn and shoots him. Like you said it sounds like an relationship issue.

I just dont know how to do a relationship group yet lol.

Link to post
Share on other sites

10 hours ago, NorthCam18 said:

Is it confirmed that `player` is the player itself and not another entity? I don't see a reason why this code wouldn't work. I'd also make sure that the suspect's relationship between each other is positive or whichever GTA has, so they're not going to automatically start fighting each other.

Player is confirmed the player itself. The problem is once the first shot is fired they see each other as hostile and it ruins whatever task they were currently working at. 

Link to post
Share on other sites

I encountered this same problem, and found the solution for me was to not create my own new PedGroup, but instead to just assign the AI to an existing PedGroup that shares the characteristics I wanted.

 

For me, I found the AMBIENT_GANG_WEICHENG group to suitable so I just used the following:
 

ped.RelationshipGroup = (RelationshipGroup) "AMBIENT_GANG_WEICHENG";

I assigned each ped I wanted to not shoot each other into this group, and this also made them aggressive toward the player and cop NPCs while making them friendly toward other gangs.

 

If I don't use this, even with ped.AlwaysKeepTask = true; being active, the peds would shoot one round and then begin to slaughter each other.

 

You can find more default ped relationship groups at this link:

https://gist.github.com/ghermans/30b7e578fca2494b20616f8d4725d05c

 

I hope this helps.

Edited by SGTPayne
Link to post
Share on other sites

50 minutes ago, SGTPayne said:

I encountered this same problem, and found the solution for me was to not create my own new PedGroup, but instead to just assign the AI to an existing PedGroup that shares the characteristics I wanted.

 

For me, I found the AMBIENT_GANG_WEICHENG group to suitable so I just used the following:
 


ped.RelationshipGroup = (RelationshipGroup) "AMBIENT_GANG_WEICHENG";

I assigned each ped I wanted to not shoot each other into this group, and this also made them aggressive toward the player and cop NPCs while making them friendly toward other gangs.

 

If I don't use this, even with ped.AlwaysKeepTask = true; being active, the peds would shoot one round and then begin to slaughter each other.

 

You can find more default ped relationship groups at this link:

https://gist.github.com/ghermans/30b7e578fca2494b20616f8d4725d05c

 

I hope this helps.

Can you include some more examples of your code? I would like to see how it all comes together

 

Thanks

Link to post
Share on other sites

22 minutes ago, Dominic1337 said:

Can you include some more examples of your code? I would like to see how it all comes together

 

Thanks

 

bo1.AlwaysKeepTask = true;

bo1.BlockPermanentEvents = true;

bo1.RelationshipGroup = (RelationshipGroup) "AMBIENT_GANG_WEICHENG";

bo1.Task.FightAgainst(AssignedPlayers[0]);

This all happens after spawning them, assigning weapons, and then other ambient values for the callout. This same set is repeated several times over for the entirety of that group with that task, and others that I do not want to be shot at by the group are also included in their group, though are assigned tasks like cowering.

 

To go off of the example you provided,

 

suspect1.Weapons.Give(WeaponHash.HeavySniper, 600, true, true);
suspect2.Weapons.Give(WeaponHash.CarbineRifle, 600, true, true);
suspect3.Weapons.Give(WeaponHash.SweeperShotgun, 600, true, true);

suspect1.RelationshipGroup = (RelationshipGroup) "AMBIENT_GANG_WEICHENG";
suspect2.RelationshipGroup = (RelationshipGroup) "AMBIENT_GANG_WEICHENG";
suspect3.RelationshipGroup = (RelationshipGroup) "AMBIENT_GANG_WEICHENG";

suspect1.Task.FightAgainst(player);
suspect2.Task.FightAgainst(player);
suspect3.Task.FightAgainst(player);

should work and prevent them from shooting each other, but still allowing for aggression towards the player.

Edited by SGTPayne
  • Like 1
Link to post
Share on other sites

  • 3 months later...
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

Important Information

Please view the site: Terms of Use, Privacy Policy, and Guidelines. // IMPORTANT: We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.