Log in to reply

Question about peds and groups...

  • How does grouping work in vanilla story mode? I'm looking to spawn some enemy peds and have them stick together, will this be what I need to look into or does grouping do something else entirely?

    Is there some c# references or samples (mods) that already do this?

  • This post is deleted!

  • @dimedius You have 2 types of groups.

    One type i would call a Team or a Squad. This group will have a leader and all members will fight along side / follow the leader, kind of protecting them (aslong as they are capable).
    These groups have a maximum size of 7 (i believe this can be changed within the game files).

    void MakeGroup()
                PedGroup myGroup= new PedGroup();
                myGroup.Add(ped1, true);
                myGroup.Add(ped2, false);
                // or
                myGroup.Add(ped1, true)
                ped1.CurrentGroup.Add(ped2, false)

    Now if i tell ped1 to fight someone, ped 2 will join them.. If i tell ped 1 to get into a car ped 2 will also get into that car.
    If someone attacks ped1, ped2 will attack them back. (aslong as they are within a certain distance of each other, groups have a maximum range at a member can be from its leader, reaching this max will cause the member to stop functioning as a group member)

    Then there are Relationship groups, which are some basic parameters defining who the members of the relationship group like/dislike. Relationship groups do not have a leader or a maximum size and no one will follow anyone else, but they may fight together and even help each other out.
    Think of relationship groups as a way of controlling how a ped reacts to a given situation without directly controlling the ped.
    A ped who respects another ped, is more likely to help that respected ped if hes in trouble. A ped who dislikes another ped is more likely to attack that disliked ped.. There is a sliding scale from Companion to Enemy.
    This is the system that controls gang members when they fight along side each other vs the cops or when Chamberlain gangs shoot at cops that are after Franklin, they respect Frank, so they help him.

            /// to make a new group
            public static int customers= World.AddRelationshipGroup("LSCUSTOMER");
            public static int workers = World.AddRelationshipGroup("LSWORKERS");
            public static int rival_nutral = World.AddRelationshipGroup("LSRIVAL_N");
            public static int rival_enemy = World.AddRelationshipGroup("LSRIVAL_E");
            /// to get an existing group, there are more possible strings for all the pre existing groups in the game
            public static int playerRelationship = Function.Call<int>(Hash.GET_HASH_KEY, "PLAYER");
                            /// to configure the groups.
                            World.SetRelationshipBetweenGroups(Relationship.Pedestrians, workers , customers);
                            World.SetRelationshipBetweenGroups(Relationship.Companion, workers , playerRelationship);
                            World.SetRelationshipBetweenGroups(Relationship.Neutral, workers , rival_nutral);
                            World.SetRelationshipBetweenGroups(Relationship.Hate, workers , rival_enemy);
                            World.SetRelationshipBetweenGroups(Relationship.Pedestrians, playerRelationship, customers);
                            World.SetRelationshipBetweenGroups(Relationship.Companion, playerRelationship, workers);
                            World.SetRelationshipBetweenGroups(Relationship.Neutral, playerRelationship, rival_nutral);
                            World.SetRelationshipBetweenGroups(Relationship.Hate, playerRelationship, rival_nutral);
                            World.SetRelationshipBetweenGroups(Relationship.Pedestrians, rival_nutral, customers);
                            World.SetRelationshipBetweenGroups(Relationship.Neutral, rival_nutral, workers);
                            World.SetRelationshipBetweenGroups(Relationship.Neutral, rival_nutral, playerRelationship);
                            World.SetRelationshipBetweenGroups(Relationship.Respect, rival_nutral, rival_enemy);
                            World.SetRelationshipBetweenGroups(Relationship.Pedestrians, rival_enemy, customers);
                            World.SetRelationshipBetweenGroups(Relationship.Hate, rival_enemy, workers);
                            World.SetRelationshipBetweenGroups(Relationship.Hate, rival_enemy, playerRelationship);
                            World.SetRelationshipBetweenGroups(Relationship.Respect, rival_enemy, rival_nutral);
                            World.SetRelationshipBetweenGroups(Relationship.Companion, customers, workers);
                            World.SetRelationshipBetweenGroups(Relationship.Companion, customers, playerRelationship);
                            World.SetRelationshipBetweenGroups(Relationship.Companion, customers, rival_nutral);
                            World.SetRelationshipBetweenGroups(Relationship.Companion, customers, rival_enemy);

    This is an example of how relationship groups are made, gotten and configured.

  • Thanks, @mcal9909, you're one of a few people I've come across that have been extremely helpful! I'm mostly interested in that first bit. I have the second part setup but it has some weirdness like they split up sometimes, one gets into a gunfight, the other casually strolls in the opposite direction.

    Edit: Oh will the created group require a leader ?

  • @dimedius Yes the group needs a leader, this is who members follow. If the leader dies, you need to manually find a new leader. In my example ped1 is the leader.

Log in to reply

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