Freakyy 35 Posted May 10, 2015 Share Posted May 10, 2015 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 GroupFirst 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 GroupsThe 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 GroupNow 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) DoneThis will stop random peds from fleeing (as long as you actually assign the hash). 4 Link to post Share on other sites
MAFINS 60 Posted May 10, 2015 Share Posted May 10, 2015 Radical. B) Link to post Share on other sites
dehan 14 Posted May 11, 2015 Share Posted May 11, 2015 They still get in the vehicle look at you get out then repeat that with this Link to post Share on other sites
xsploit 2 Posted May 11, 2015 Share Posted May 11, 2015 So if i spawned the zombie model they would still attack if i pointed a weapon at them even when unarmed? Link to post Share on other sites
XenoxX 2,193 Posted May 30, 2015 Share Posted May 30, 2015 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 ? Link to post Share on other sites
ChOcOsKiZo 149 Posted May 30, 2015 Share Posted May 30, 2015 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 1 Link to post Share on other sites
Ethenal 41 Posted May 30, 2015 Share Posted May 30, 2015 (edited) 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 May 30, 2015 by Ethenal Link to post Share on other sites
XenoxX 2,193 Posted May 31, 2015 Share Posted May 31, 2015 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. ? Link to post Share on other sites
Ethenal 41 Posted May 31, 2015 Share Posted May 31, 2015 // 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. 3 Link to post Share on other sites
whorse 26 Posted July 22, 2015 Share Posted July 22, 2015 (edited) 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 July 25, 2015 by whorse Link to post Share on other sites
froggz19 2 Posted September 30, 2015 Share Posted September 30, 2015 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? Link to post Share on other sites
whorse 26 Posted October 1, 2015 Share Posted October 1, 2015 (edited) 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 October 1, 2015 by whorse Link to post Share on other sites
froggz19 2 Posted October 1, 2015 Share Posted October 1, 2015 (edited) 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 October 1, 2015 by froggz19 Link to post Share on other sites
froggz19 2 Posted December 5, 2015 Share Posted December 5, 2015 (edited) sharkie sharkie Edited December 5, 2015 by froggz19 Link to post Share on other sites