Log in to reply
 

can't get peds to fight one another, they just run away



  • I've looked over countless examples here and nothing seems to do the trick. I would be grateful if someone could help.

    No matter what I do, when I spawn two peds and assign them the relevant properties so that they should fight, they just run away really fast.

        if (e.KeyCode == Keys.NumPad1)
        {
            UI.ShowSubtitle("create cop new");
            Ped player = Game.Player.Character;
            GTA.Math.Vector3 spawnLoc = player.Position + (player.ForwardVector * 5f);
    
    
            // set up relationships so newly spawned peds hate one another
            int copgroup1 = World.AddRelationshipGroup("cops1");
            int copgroup2 = World.AddRelationshipGroup("cops2");
            int playerRGroup = player.RelationshipGroup;
    
            World.SetRelationshipBetweenGroups(Relationship.Hate, copgroup1, copgroup2);
            World.SetRelationshipBetweenGroups(Relationship.Hate, copgroup2, copgroup1);
    
            string model_name = "s_m_y_cop_01";
            Ped cop1 = GTA.World.CreatePed(model_name, spawnLoc);
            Ped cop2 = GTA.World.CreatePed(model_name, spawnLoc);
    
            cop1.RelationshipGroup = copgroup1;
            cop2.RelationshipGroup = copgroup2;
    
            Function.Call(Hash.SET_BLOCKING_OF_NON_TEMPORARY_EVENTS, cop1, true);
            Function.Call(Hash.SET_PED_COMBAT_ATTRIBUTES, cop1, 46, true);
            Function.Call(Hash.SET_PED_FLEE_ATTRIBUTES, cop1, 0, 0);
    
            Function.Call(Hash.SET_BLOCKING_OF_NON_TEMPORARY_EVENTS, cop2, true);
            Function.Call(Hash.SET_PED_COMBAT_ATTRIBUTES, cop2, 46, true);
            Function.Call(Hash.SET_PED_FLEE_ATTRIBUTES, cop2, 0, 0);
    
            cop1.Weapons.Give(WeaponHash.SMG, 999, true, true);
    
            cop1.Task.FightAgainst(cop2);
            cop2.Task.FightAgainst(cop1);
          
        }
    }

Log in to reply
 

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