Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

Controlling ped melee combat


whorse
 Share

Recommended Posts

Hello, I am working on an ASI melee-only riot mod and I am having a little trouble getting the peds to fight back against eachother when they are damaged by one another. I have a method to find any ped's most recent attacker if that ped is hurt, but the rioting peds rarely seem to listen to it. Often times they will just keep getting hit and will not react to the person hitting them.

 

90% of the time, it seems like the thing that is keeping them from switching targets to their attacker is that they are locked in a "stare-down" with another ped that is not even fighting them. After a while, they will say something like "That's right, walk away bitch" to the ped they were staring at and THEN they can switch targets and start fighting. But in the meantime, they may get punched and knocked down 3 or more times before they finally give up the staredown.

 

Is there any way I can have this stupid stare-down animation/scenario/whatever be aborted so the peds can initialize combat with a new target? I have the following natives active on the peds:

PED::SET_BLOCKING_OF_NON_TEMPORARY_EVENTS(ped, true);PED::SET_PED_FLEE_ATTRIBUTES(ped, 0, 0);PED::SET_PED_COMBAT_ATTRIBUTES(ped, 46, TRUE);

And I use these two whenever I have them pick a new target:

AI::CLEAR_PED_TASKS(ped);AI::CLEAR_PED_SECONDARY_TASK(ped);

And I use this method to find the attacker of a ped:

void findAttacker(Ped ped){        attacker = NULL;        for (int c = 0; c < peds.size(); c++)        {	        if (ENTITY::HAS_ENTITY_BEEN_DAMAGED_BY_ENTITY(ped, peds.at©, true)){ 		        if (peds.at© != player){			        attacker = peds.at©;			        break;		        }	        }        }}

Can anyone tell me what I can do to make the peds able break their stare-downs and just start fighting? Or if I'm doing something very wrong? I am very new to C++ and haven't really programmed in Java since high school.

Thanks guys

Edited by whorse
Link to comment
Share on other sites


GTA.Math.Vector3 spawn = player.Position + (player.ForwardVector * 10);

var attackped = World.CreatePed(PedHash.Cyclist01, spawn);


if(attackped.HasBeenDamagedBy(player))

attackped.Task.FightAgainst(player);



works in C# there's almost no delay and sometimes sprint (if you also set task to sprint) and punch at the same time. (in you case riot)


I'm not sure how you'd convert that to C++ though. ofc you are also making random peds fight so it'd be completely different.


anyways, good luck, just thought i'd try help, i doubt it does help tough :)

Link to comment
Share on other sites

 

GTA.Math.Vector3 spawn = player.Position + (player.ForwardVector * 10);
var attackped = World.CreatePed(PedHash.Cyclist01, spawn);
if(attackped.HasBeenDamagedBy(player))
attackped.Task.FightAgainst(player);
works in C# there's almost no delay and sometimes sprint (if you also set task to sprint) and punch at the same time. (in you case riot)
I'm not sure how you'd convert that to C++ though. ofc you are also making random peds fight so it'd be completely different.
anyways, good luck, just thought i'd try help, i doubt it does help tough :)

 

Maybe it's in the way I am commanding them to fight eachother, I use:

AI::TASK_PUT_PED_DIRECTLY_INTO_MELEE(Any ped, Any targetPed, float 0, float 0, float 0, Any 0);

What are the four parameters after the ped and target ped? I've tried using coordinates for the target ped -1s and 1s and none of them work as well as just 0,0,0,0. But still it doesnt let them fight immediately all the time, sometimes the peds have to stare at their target for like 10 seconds before they finally go into actual combat (they may be getting hit during this time)

 

I think I've pretty much fixed them so they will always turn and face eachother if they hit eachother, but they still have that annoying stare-down.

Link to comment
Share on other sites

Does anyone know how you use this native and what it does? Not sure if its what I'm looking for since its under the GRAPHICS category, but the name sounds promising

static Any GRAPHICS::MELEE_SEETHROUGH_SKIPPED() { return invoke<Any>(0x0D6CA79EEEBD8CA3); } // 0x0D6CA79EEEBD8CA3 0x65376C9B

I also found this one, but I tried it and it doesnt seem to help too much:

AI::TASK_CLEAR_LOOK_AT(Any p0)

I see other ones like ped "blending" and ped "decision making" etc... does anyone know what natives might affect this behavior? It is apparently timed, and the peds will start fighting after a certain amount of time staring.

Link to comment
Share on other sites

I worked on it for a while, trying various natives and other things, and it seems that the "stare down" is a natural part of the melee combat in this game and you cant really remove it.

 

However, I was able to mostly negate it by forcing the peds to switch targets randomly every 6 seconds or so if they are standing still, since switching targets seems to make them keep their fists up and react much faster to getting hit. Making it so that a ped could not be targeted by two peds in a row also seemed to reduce the amount of people waiting around (waiting for their turn)

 

Also, I noticed that a lot of male peds would not hit female peds until the female had almost beat them to death. I think this is intentional as well, so I just made most of the targeting functions search for male targets only, except for one that searches for females only (which is the function that females themselves use to find targets). Now females only fight males if there are no female targets for them (happens quite often), and the males will usually respond instantly to this.

 

Does anyone know how you can force a skittish animal to fight another entity that is not the player? Most animals just ignore the TASK COMBAT and TASK PUT INTO MELEE natives, and will just run away unless I use "TASK_COMBAT_HATED_TARGETS_AROUND_PED", wherein they will pretty much only attack the player. Would creating a new group for all the rioting animals and making the group have hostile relations with everyone work?

Edited by whorse
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.