Jump to content

Recommended Posts

Posted

 

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).

 

 

 

My Fallout 4 and Skyrim mods: SAC - LoversLab

 

Posted

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).

 

Posted
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? 

 

My Fallout 4 and Skyrim mods: SAC - LoversLab

 

Posted (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 by crossed99
  • Thanks 1
Posted

 

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.

 

 

My Fallout 4 and Skyrim mods: SAC - LoversLab

 

Posted

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.

Posted
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!

 

  • Like 1

 

My Fallout 4 and Skyrim mods: SAC - LoversLab

 

Posted (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 by SAC

 

My Fallout 4 and Skyrim mods: SAC - LoversLab

 

Posted

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).

  • Thanks 1
Posted
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

 

 

My Fallout 4 and Skyrim mods: SAC - LoversLab

 

  • 11 months later...
Posted

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.  

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...