SAC 28 Posted December 29, 2021 Share Posted December 29, 2021 Looking to accomplish the following use cases: 1. Have an NPC declared public enemy, and every NPC around attacks them I have tried to run this on the victim NPC, nothing happens PED::SET_PED_RELATIONSHIP_GROUP_HASH(aimed_target_ped, MISC::GET_HASH_KEY("REL_WILD_ANIMAL")); Any other ideas? Make them "relationship outlaw" or "wanted"? 2. Have a civilian NPC attack another civilian NPC bool enemy_found = false; Ped victimArr[20]; int count = worldGetAllPeds(victimArr, 20); for (int i = 0; i < count; i++) { if (sac_is_valid_victim_model(victimArr[i])) // optional personal preference, not relevant to the logic { enemy_found = true; TASK::CLEAR_PED_TASKS_IMMEDIATELY(aimed_target_ped, false, false); PED::SET_PED_RELATIONSHIP_GROUP_HASH(victimArr[i], MISC::GET_HASH_KEY("REL_WILD_ANIMAL")); PED::SET_PED_COMBAT_MOVEMENT(aimed_target_ped, 2); TASK::TASK_COMBAT_PED(aimed_target_ped, victimArr[i], 0, 16); break; } } Works only if the aggressor is a cop, not if the aggressor is an ordinary civilian. And works only sometimes. 3. Have wild animals (e.g. alligators) attack NPCs, this one I haven't tried yet. As is, alligators only eat dead NPC corpses, not attack live NPCs. I have a hunch events.meta is a possible solution for this, but I haven't found the relevant behavior there (yet). Quote My Fallout 4 and Skyrim mods: SAC - LoversLab Link to comment Share on other sites More sharing options...
crossed99 43 Posted December 29, 2021 Share Posted December 29, 2021 You can create your own relationship group: Hash myRelGroup; PED::ADD_RELATIONSHIP_GROUP("MyRelGroup", &myRelGroup); PED::SET_RELATIONSHIP_BETWEEN_GROUPS(6, 707888648/*LAW*/, myRelGroup); // 6 means the first group will attack the second on sight Pretty sure lawmen would attack whoever you add to this group with PED::SET_PED_RELATIONSHIP_GROUP_HASH(aimed_target_ped, myRelGroup); unless I got the hash for lawmen wrong, not 100% sure, but you can check with GET_PED_RELATIONSHIP_GROUP_HASH(Ped ped). Quote Link to comment Share on other sites More sharing options...
SAC 28 Posted December 29, 2021 Author Share Posted December 29, 2021 11 minutes ago, crossed99 said: You can create your own relationship group: Hash myRelGroup; PED::ADD_RELATIONSHIP_GROUP("MyRelGroup", &myRelGroup); PED::SET_RELATIONSHIP_BETWEEN_GROUPS(6, 707888648/*LAW*/, myRelGroup); // 6 means the first group will attack the second on sight Pretty sure lawmen would attack whoever you add to this group with PED::SET_PED_RELATIONSHIP_GROUP_HASH(aimed_target_ped, myRelGroup); unless I got the hash for lawmen wrong, not 100% sure, but you can check with GET_PED_RELATIONSHIP_GROUP_HASH(Ped ped). Ok, sounds good, but how do I make any civilians attack the NPC? Quote My Fallout 4 and Skyrim mods: SAC - LoversLab Link to comment Share on other sites More sharing options...
crossed99 43 Posted December 29, 2021 Share Posted December 29, 2021 (edited) You have to make civilian relationship groups hate your group with the same method. PED::SET_RELATIONSHIP_BETWEEN_GROUPS(6, 2318650831, myRelGroup); // townfolk male ? PED::SET_RELATIONSHIP_BETWEEN_GROUPS(6, 841021282, myRelGroup); // townfolk female ? I don't really know relationship groups, but you can target any ped and check their rel group with the native I posted in the other post. Some peds might set to always avoid combat though, you might have to look into config flags or combat attributes if you want everybody to fight. SET_PED_COMBAT_ATTRIBUTES https://alloc8or.re/rdr3/doc/enums/eCombatAttribute.txt SET_PED_CONFIG_FLAG https://alloc8or.re/rdr3/doc/enums/ePedScriptConfigFlags.txt Edited December 29, 2021 by crossed99 1 Quote Link to comment Share on other sites More sharing options...
SAC 28 Posted December 31, 2021 Author Share Posted December 31, 2021 I've tried to set the target ped in hate relationship with CIVMALE and REL_CIVMALE, nothing happened. I've looked at the various civilian peds around, their relationship groups are quite varied and I don't know how to dehash them / where to look them up. Next I am going to try picking a few random civilians around the target ped, and putting them in another group of my own, which hates the target ped group. Best effort, store their previous groups in a map and restoring them once the target is dead (but this is nice to have). Otherwise, unless there is some sort of universal enemy relationship group, I don't know how to approach this. Quote My Fallout 4 and Skyrim mods: SAC - LoversLab Link to comment Share on other sites More sharing options...
crossed99 43 Posted December 31, 2021 Share Posted December 31, 2021 You don't have to dehash them, the code I posted makes most peds attack on sight in towns. You can get all their rel groups with the getAllPeds function. Quote Link to comment Share on other sites More sharing options...
SAC 28 Posted December 31, 2021 Author Share Posted December 31, 2021 2 hours ago, crossed99 said: You don't have to dehash them, the code I posted makes most peds attack on sight in towns. You can get all their rel groups with the getAllPeds function. You are right, your code works. I was using a lobotomized events.meta which prevented aggro. Thank you very much! 1 Quote My Fallout 4 and Skyrim mods: SAC - LoversLab Link to comment Share on other sites More sharing options...
SAC 28 Posted January 1, 2022 Author Share Posted January 1, 2022 (edited) One more thing, I've had the code actually crash the game on some NPCs so I have added a <clear_tasks> step before adding them to the hostile rel group (and the code does not crash the game anymore, so it should be right). The fleeing is just cosmetic TASK::CLEAR_PED_TASKS_IMMEDIATELY(ped, false, false); TASK::TASK_SMART_FLEE_PED(ped, ped, -1, -1, 0, 3.0f, 0); WAIT(2000); Hash rel_group_pariah_hash; PED::ADD_RELATIONSHIP_GROUP("rel_group_pariah", &rel_group_pariah_hash); PED::SET_PED_RELATIONSHIP_GROUP_HASH(ped, rel_group_pariah_hash); The intended aggro triggers, albeit sometimes with delay, which is why I have added this to my general population sandboxing routine PED::REGISTER_HATED_TARGETS_AROUND_PED(peds[i], 10); Can't say if it makes a difference but it makes sense intuitively, I am juggling a lot of changes at one time without thorough testing for each. Edited January 1, 2022 by SAC Quote My Fallout 4 and Skyrim mods: SAC - LoversLab Link to comment Share on other sites More sharing options...
HughJanus 244 Posted January 2, 2022 Share Posted January 2, 2022 The WAIT(2000) happens for every ped - so the script will pause for 2 seconds after each ped is tasked with fleeing (this will delay all other things in your script as well). You could work around this with timers (you remember the timestamp for a ped and only proceed with the rest of the functions (for this ped) when two seconds have passed). 1 Quote Link to comment Share on other sites More sharing options...
SAC 28 Posted January 2, 2022 Author Share Posted January 2, 2022 22 minutes ago, HughJanus said: The WAIT(2000) happens for every ped - so the script will pause for 2 seconds after each ped is tasked with fleeing (this will delay all other things in your script as well). You could work around this with timers (you remember the timestamp for a ped and only proceed with the rest of the functions (for this ped) when two seconds have passed). You are correct, I'll implement a timer Quote My Fallout 4 and Skyrim mods: SAC - LoversLab Link to comment Share on other sites More sharing options...
AlexLifeson2112 7 Posted December 13, 2022 Share Posted December 13, 2022 I hope someone is still looking into this - Hostile Alligators Mod? (attack NPCs who are tied up and dropped or step near them etc..) The only way I have gotten alligators to attack humans was to use srgnt joes battle creator and either spawn a team of humans (or even ones spawned via rampage/jedi/native) and a bunch of alligators on team B.. And they take them out (especially in water in an aggressive way) but only for the first 2 or 3 seconds, then I would have to stop fight, then start fight (not exit, but eventually exit bc the alligators move away and do not attack the team thats supposed to fight them, they look for the player and attack ...) I would love to see alligators in regular gameplay attack people like they do boars who get too close to water/gators. There are a couple npcs that can be killed when tied up (i believe ped is swamp freak or something - but that might just be triggered by the event in the actual gameplay, I need to spawn him with every spawner to see if one of them will be killable by a gator. Alligators are incapable of being aggressive towards anything other than the player, but I would love to toss a npc into the water from the tracks on the way to st denis and have them grab them and take them underwater. If I can find a ped that they do attack, I will post it because I wish I understood modding but want to help provide as much info a possible because this would be a great addition to the game ... Hostile Alligators Mod... and yes, maybe one that had Bears that dont need to be spawned by the player attack npcs who wonder close to them , like the player, in rdr2 they are incapable of killing npcs .. only the ones I spawn as body guards etc.. but having bears and alligators naturally be able to attack npcs puts the game into a whole new level of immersion - I could spend hundreds of hours baiting an area for grizzleys and waiting for bounty hunters to come and investigate and get mauled by a bear, or walk into a swamp and get pulled in... Im sure they would kill them quickly.. but to have realistic animal behavior, not not just attack only the player, it would be amazing and would be the greatest mod ever created for rdr2. I hope it can some day be done. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.