Log in to reply

Why don't the cops fight each other?

  • I've been programming the police in GTA and came across this behavior recently. It seems that no matter what I do, the cops will not fight each other.

    I'm giving them the same instructions as other characters, who fight without issue. A police officer will attack a civilian without issue, but when I use the same code for two police officers, they run away from each other instead of fighting.

    What could cause this behavior? Does anyone have any ideas on how to fix it?

    the cop has no problems attacking a regular pedestrian
    the cop has no problems attacking a regular pedestrian

    the cops will not fight each other
    the cops will not fight each other

  • @prismspecs My best guess is it's something to do with their Relationship group. If you set your character's Relationship group as Police using Simple Trainer for example, they also partially ignore you as well. You are still getting wanted level and having cops dispatch at your location but you are like being invisible to them. They are coming right next to you but acting like you are not there and in radar it's looking like you are out of their line of sight despite they are right next to you :/

  • @Aurora11 thank you for responding. I did think of that, and tried creating new Relationship Groups for the two spawned peds, but it doesn't seem to work when applied to police officers. It's as if their Relationship Groups cannot be modified.

            // experiment 3
            GTA.UI.Screen.ShowSubtitle("creating two cops to fight each other, using relationship groups");
            Ped player = Game.Player.Character;
            string model_name = "s_m_y_cop_01";
            Ped cop1 = GTA.World.CreatePed(model_name, player.Position + (player.ForwardVector * 5f));
            cop1.Weapons.Give(WeaponHash.Bat, 999, true, true);
            model_name = "s_m_y_cop_01";
            Ped cop2 = GTA.World.CreatePed(model_name, player.Position + (player.ForwardVector * 6f));
            // create a new relationship group
            RelationshipGroup newGroup1 = World.AddRelationshipGroup("newgroup1");
            cop1.RelationshipGroup = newGroup1;
            RelationshipGroup newGroup2 = World.AddRelationshipGroup("newgroup2");
            cop1.RelationshipGroup = newGroup2;
            newGroup1.SetRelationshipBetweenGroups(newGroup2, Relationship.Hate);
            newGroup2.SetRelationshipBetweenGroups(newGroup1, Relationship.Hate);
            cop1.AlwaysKeepTask = true;
            // 46 is the "fight to the death" attribute
            Function.Call(Hash.SET_PED_COMBAT_ATTRIBUTES, cop1, 46, true);
            Function.Call(Hash.SET_PED_FLEE_ATTRIBUTES, cop1, 0, 0);

  • @prismspecs Oh :( I see :/ If it's their Relationship Group hardcoded, the only alternative I could think of is duplicating the s_m_y_cop_01 with a different name, like ..._02 and making them civilian instead. But this is just an alternative way around of course.

  • @Aurora11 This is what I suspected. It is interesting that the police in GTA have a hard coded, immutable relationship. This seems to be similar to the way police are in the real world. Even if one of them does something wrong, the others will not fight him.

    So you mean to say that I will have to create a new model for a police officer, and then use something like AddonPeds to load it into the game, yes?

    Thank you for your help

  • @prismspecs
    Not tested but have you tried setting the ped to not be a cop before changing the relationship?


  • @prismspecs Haha true :D They are driving faster than speed limits, unnecessarily using emergency lanes, cuz they are above the laws. and no one doing anything. One day they were wrote ticket to me because I was using my fog lights, but they are fine with using their blindingly bright emergency lights...

    Yup. Just copy&duplicate the s_m_y_cop_01 and make it s_m_y_cop_02 or smycopcivilian, however you like. I have actually never thought about addon peds, was thinking adding them inside the game directory ( x64e I think ) and adding their data inside peds.ymt but Addon Peds sounds fine too and probably will be a lot easier and faster. Though you can't get the props work (like glasses, hats) if you do it with Addon Peds :(

  • There is also this native, looks interesting.


Log in to reply

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