Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Diamond Casino Heist
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Red Dead Online

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

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

    2. GTA 6

      1. St Andrews Cathedral
    3. GTA V

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

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

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    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. DYOM
      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
    3. Gangs

    1. Announcements

    2. Support

    3. Suggestions

eXntrc

Calling All Critters

Recommended Posts

eXntrc

Hey Folks,

 

I've been working off and on over the last 3 days on a mod I've named "Calling All Critters". It's similar to some of the existing body guard mods but instead of spawning a new bodyguard and instead of the bodyguard being humans, I am searching for existing animals nearby and having them join the player.

 

 

I have a good portion of this working already:

 

  1. Player making a whistling sound and facial expression
    • // Play call animation
      player.Task.PlayAnimation("[email protected][email protected]@elkcall", "mood_elkcal_1");

      // Play call sound
      Audio.PlaySoundFromEntity("Franklin_Whistle_For_Chop", player, "SPEECH_RELATED_SOUNDS");
  2. Locate all animals within a specified radius
    • newCritters = World.GetNearbyPeds(player, SeparationRange).Where(p => p.GetPedType() == PedType.Animal && !p.IsDead).ToList();
  3. Turn on friendly blip
    • if (critter.CurrentBlip == null)
      {
      critter.AddBlip();
      }
      critter.CurrentBlip.IsFriendly = true;
  4. Animals join the players group
    • // Get the player group
      var playerGroup = player.RelationshipGroup;

      // Add critter to player group
      critter.SetAsGroupMember(playerGroup);
  5. Animals run to the player and stays with group
    • // The following needs to be done as a task sequence
      var seq = new TaskSequence();
      seq.AddTask.RunTo(posNear);
      seq.AddTask.FightAgainstHatedTargets(5000f);
      seq.Close();
      critter.AlwaysKeepTask = true;
      critter.Task.PerformSequence(seq);

 

 

What I have NOT been able to accomplish:

 

  1. The animals will NOT attack hated targets. i.e. if I am wanted and the cops are shooting at me they don't do anything
    • I read in other forum posts that when you spawn a bodyguard you must give it a weapon or else it won't fight for you. Just for the heck of it I tried giving the animals weapons. I noticed the pistol attached to the paw of cats and dogs (how cute) and I noticed that sometimes the model for the dogs would contort and I think they were shooting back. But it happened very rarely.
  2. I can't keep the animals from turning on me sometimes.
    • I noticed a forum post saying to make sure the bodyguards are set to "not be damaged by my relationship group". But I haven't been able to figure out how to do this.
    • I have had zero luck creating new relationship groups

 

 

So, my questions are:

 

1. How can I get the animals to attack without giving them weapons? The Pet Shop mod apparently does this:

 

 

 

2. How can I stop my critters from turning on me? This native is undocumented and trying to call it seems to crash my mod:

 

void SET_ENTITY_CAN_BE_DAMAGED_BY_RELATIONSHIP_GROUP(Any p0, BOOL p1, Any p2) // E22D8FDE858B8119 34165B5D

 

 

Creating a new relationship group with World.AddRelationshipGroup("CRITTER_GROUP") returns a new handle, but I can't get any of the critters to join that group. After I assign critter.RelationshipGroup I check critter.IsInGroup and it always returns false. They also don't stick around. (And yes I added a relationship between that group and the player.)

 

For this part I tried to follow this article exactly but it doesn't seem to work for me:

 

http://gtaforums.com/topic/793324-relationship-groups-stopping-random-peds-from-fleeing/

 

The two obvious differences are that I'm working with animals instead of humans and I'm using Script Hook .Net instead of raw C++. It's possible I'm somehow getting a parameter wrong.

 

 

 

Thanks everyone for any help you can provide.

 

 

 

Just for reference and completeness, here are other articles I've read attempting to fix this on my own:

 

Get and set relationships in bodyguard mod

http://gtaforums.com/topic/807822-which-relationship-group-prison-guard-belongs/?hl=relationship

Another sample for bodyguard

http://gtaforums.com/topic/793962-bodyguards/

Peds in same group attacking each other

http://gtaforums.com/topic/796282-luapeds-in-same-group-attacking-eachother/?hl=relationship&do=findComment&comment=1067500937

SUCCESSFULLY Assigned Group (Stop From Fleeing)

http://gtaforums.com/topic/793324-relationship-groups-stopping-random-peds-from-fleeing/

Relationship Commands in .NET

http://gtaforums.com/topic/807822-which-relationship-group-prison-guard-belongs/?hl=relationship

 

Share this post


Link to post
Share on other sites
GeorgeZhang

To my knowing setting relationship group to player's relationship group stops ped from attacking you, instead of working for you. However, you can use

"int playergroupid = Function.Call<int>(Hash.GET_PLAYER_GROUP, player)"

to get the player's "group", and then add your critters using

"Function.Call<int>(Hash.SET_PED_AS_GROUP_MEMBER, ped, playergroupid)"

 

so basically what I mean: group is different from relationship group.

 

hope it helped

 

btw can i ask you somthing?how did you get the name of ingame sound, so that you can play it?

Edited by GeorgeZhang

Share this post


Link to post
Share on other sites
eXntrc

Thank you George, I'll try your suggestion tomorrow night. Can you help me better understand the difference between group and relationship group? I've seen other forum posts with people doing crazy stuff like setting all peds group (or relationship group?) to "cougar" and turning everyone against each other. I was under the impression that you could create a group and then set its relationship with other groups (i.e. 'Hated') but I can't seem to get any of that working right.

 

 

As far as the sounds, I'm more than happy to help you out. First I found the sound I wanted using OpenIV, but of course the sound names shown in OpenIV don't match exactly what you need to call in code. Once I had some idea what the developers were referring to that sound as, I searched for something similar in one of these three amazing dumped lists by Konijima.

 

Full list of FRONT_END Sounds

http://konijima.com/assets/PLAY_SOUND_FRONTEND.txt

Full list of ENTITY Sounds

http://konijima.com/assets/PLAY_SOUND_FROM_ENTITY.txt

Full list of COORD Sounds

http://konijima.com/assets/PLAY_SOUND_FROM_COORD.txt

 

These are absolutely invaluable and should be stickied somewhere. However, Konijima has stated that they're too big to host in PasteBin so he's hosting them on his own server. That means they could disappear someday. I highly recommend you save all three of them locally (which I have done).

 

 

IMPORTANT NOTE: It appears that some of the sounds don't play even when copied directly from those lists. My gut tells me that's because they're not loaded, similarly to how you need to load an animation before it plays. Unfortunately I don't see a native similar to Native::Hash::REQUEST_ANIM_DICT for sounds.

Share this post


Link to post
Share on other sites
GeorgeZhang

thanks for helping out with the sounds:)

these are what i know, someone correct me if i'm wrong.

group:
group is what its name implies. a group with leaders and members, members will literally follow the leader, and guard the leader if you task them to.

relationship group:
this one doesn't exactly feel like a group. It's more like a identifier that tells the game what type of people you are. Players, gamg members, and others like cops, armies etc. has their own relationship group, and these relationship groups have default relationships with each others(like, hate, neutral and more).
However, you can set peds' relationship groups with some codes. Relationship groups can also be created, and the relationships between relationship groups can be assigned as well.

Here an example I used in my mod:
personal protection, which guard the player, shoud be added to player's group, which can be obtained through "Function.Call<int>(Hash.GET_PLAYER_GROUP, player)". And after that, task them to fight against hated targets to assign them to protect you.

In gangwar minigame, I create an relationship group for enemy as "Rgroup0". And also get the player's relationship group as well. Then, I set every enemy's relationship group to Rgroup0, and every friendly to player's. Finally, I set the relationship between those two groups as "Hate". It turns out great result.

EDIT: plus, peds in your relationship group won't follow you. However, you can't shoot them, and they can't shoot you either.

Edited by GeorgeZhang

Share this post


Link to post
Share on other sites
eXntrc

Here an example I used in my mod:

personal protection, which guard the player, shoud be added to player's group, which can be obtained through "Function.Call<int>(Hash.GET_PLAYER_GROUP, player)". And after that, task them to fight against hated targets to assign them to protect you.

 

In gangwar minigame, I create an relationship group for enemy as "Rgroup0". And also get the player's relationship group as well. Then, I set every enemy's relationship group to Rgroup0, and every friendly to player's. Finally, I set the relationship between those two groups as "Hate". It turns out great result.

EDIT: plus, peds in your relationship group won't follow you. However, you can't shoot them, and they can't shoot you either.

 

Awesome George, thank you. Any chance you'd be willing to paste in some of the code from that section above? Specifically I'd really like to see the methods you used to create "Rgroup0", how you assigned people to those groups and how you made them "Hate" each other.

 

Also, you said "(regular group) members will literally follow the leader, and guard the leader if you task them to."

 

What code do you use to ask them to guard the leader? Is it just the call to fight hated targets or something else?

 

Thanks again so much man.

Share this post


Link to post
Share on other sites
GeorgeZhang

 

Here an example I used in my mod:

personal protection, which guard the player, shoud be added to player's group, which can be obtained through "Function.Call<int>(Hash.GET_PLAYER_GROUP, player)". And after that, task them to fight against hated targets to assign them to protect you.

 

In gangwar minigame, I create an relationship group for enemy as "Rgroup0". And also get the player's relationship group as well. Then, I set every enemy's relationship group to Rgroup0, and every friendly to player's. Finally, I set the relationship between those two groups as "Hate". It turns out great result.

EDIT: plus, peds in your relationship group won't follow you. However, you can't shoot them, and they can't shoot you either.

Awesome George, thank you. Any chance you'd be willing to paste in some of the code from that section above? Specifically I'd really like to see the methods you used to create "Rgroup0", how you assigned people to those groups and how you made them "Hate" each other.

 

Also, you said "(regular group) members will literally follow the leader, and guard the leader if you task them to."

 

What code do you use to ask them to guard the leader? Is it just the call to fight hated targets or something else?

 

Thanks again so much man.

I'll use scripthookVDotNet:

 

1.create:

 

int EnemyRGroup = World.AddRelationshipGroup("youwontseethis");int playerRGroup = player.RelationShipGroup;
2.set:

 

assault.RelationShipGroup = EnemyRGroup;World.SetRelationshipBetweenGroups(Relationship.Hate, EnemyRGroup, playerRGroup);World.SetRelationshipBetweenGroups(Relationship.Hate, playerRGroup, EnemyRGroup);
3.assign bodyguards

 

int playergrp = Function.Call<int>(Hash.GET_PLAYER_GROUP, player);Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, myped, playergrp);myped.Task.FightAgainstHatedTargets(500);
you're welcome:)

 

EDIT:

you can get existing ingame relationshipgroup hashes by:

 

int copHash = Function.Call<int>(Hash.GET_HASH_KEY, "COP");
more ingame relationship groups/informations check this post(and check replies as well)

http://gtaforums.com/topic/793324-relationship-groups-stopping-random-peds-from-fleeing/

Edited by GeorgeZhang
  • Like 1

Share this post


Link to post
Share on other sites
eXntrc

Many thanks again George. With your help I'm 90% of the way there.

 

Here are some things I've noticed:

 

  1. The animals join my group and follow me around
  2. The animals still will not attack other peds, even if I set that ped into the EnemyRGroup.
  3. #2 is almost certainly because they are not armed. I allowed humans to join my group and they also would not fight back until I armed them.
  4. The animals will still get scared and run away when people start shooting at me. I believe this can be fixed with one of the "keep from fleeing" hacks mentioned in the linked posts.
  5. The animals will still turn on me once in a while, even though they're in my group and relationship group. I think this is maybe if I accidentally aim at them? I don't know how to fix this.

Any thoughts on creative ways to fix #2? I don't want to arm them with weapons since they look rather silly and again I know it's possible since the Animal Ark mod does it. I sure wish I could check out their source. Wait a second, that's a .NET mode! I'll pull out Reflector and see what I can find.

 

Any ideas on #5?

Share this post


Link to post
Share on other sites
eXntrc

I'm so close it's just so disheartening. They're following. They don't run away. They just won't attack. I even tried making the critters take on the Cougar RelationshipGroup. It didn't seem to change anything. I must be missing something.

 

I was able to pull down the source from Animal Ark. It gave me some pointers but apparently Animal Ark is not the one in this YouTube video:

 

 

 

There is no menu item in the Animal Ark source that seems to do anything like 'Attack Nearest Pedestrian". At least not the version downloadable from here:

 

https://www.gta5-mods.com/scripts/animal-ark-shelter

 

Please, anyone, help me get this last part done.

Share this post


Link to post
Share on other sites
eXntrc

Well, I think I just figured it out. At least part of it.

 

The version I downloaded was old. The current version can be downloaded from here:

 

http://www.gtainside.com/gta5/mods/76871-animal-ark-shelter/download/

 

The code is simple:

case 1:        {            Ped closestPed = World.GetClosestPed(Game.Player.Character.Position, 10f);            if (closestPed == null)            {                UI.Notify("No nearby pedestrian found!");                break;            }            this.Pet.Task.FightAgainst(closestPed);            this.Pet.AlwaysKeepTask = true;            break;}

But I was hoping to have the critters automatically attack anyone who is attacking me. I was hoping to do that automatically by having them in my group or relationship group. That seems to work for Humans as long as you provide them with a weapon, but it doesn't seem to work for Animals.

 

I guess maybe I can just do

Ped closestPed = World.GetClosestPed(critter.Position, 20f);

and then check that peds relationship with the player. And if it's hated, go ahead and attack it.

 

I'll try that tomorrow night. If anyone has a better idea please let me know.

Edited by eXntrc

Share this post


Link to post
Share on other sites
GeorgeZhang

well, i have no idea. That issue (unarmed peds not attack) has been there, I'm not sure whether it's solved or not. You can check other posts maybe it'll help, good luck:)

 

EDIT: btw, I was looking for the sound effect that played when the game tell you something, for example when you enter Ammunation and is about to buy weapons, the game will notify you to press E to browse weapons, and that notification sound is what i want, do you(or anyone) know what name it is?i can't find it in decompiled scripts...

Edited by GeorgeZhang

Share this post


Link to post
Share on other sites
eXntrc

I don't know it off the top of my head but I'd look in:

 

http://konijima.com/assets/PLAY_SOUND_FRONTEND.txt

 

And look at sounds in the "HUD_AMMO_SHOP_SOUNDSET" or "HUD_FRONTEND_CLOTHESSHOP_SOUNDSET".

 

Maybe the "SELECT" sound? Or "NAV" or "NAV_UP_DOWN"?

Share this post


Link to post
Share on other sites
eXntrc

Just wanted to report back that I have this mod 98% done now. Critters follow the player. All dogs attack other targets. Cats and smaller animals run away but they eventually come back when the danger is clear. It appears that the moment I set a smaller animal to combat against a target it actually usually runs away instead. I may just try to make them ignore the target so they don't run away, but watching them run away and come back is actually kind of cool.

 

I've built a whole system around keeping the most powerful creatures in your primary group (up to 8 peds) but still allowing more than 8 critters to follow you and attack enemies. The only thing that's significantly different between the primary group and secondary group is that the primary group usually goes with you when you teleport (though not always).

 

If a new critter is found and the primary group is full, we look for a weaker critter in the primary group and demote it to the secondary group.

 

When a critter from the primary group dies, the strongest critter in the secondary group is automatically promoted.

 

The system works pretty well so I'm ready to share it. I'm a big believer of open source so I'm making the full mod source available here:

 

https://github.com/jbienz/GTAVMods/tree/master/Critters

 

The only thing I have left to implement is a menu system to switch targeting modes and look up critter statistics. Then I'll release it as a binary.

 

I've also put a lot of work into identifying animals (Class, Name, Strength, etc.) and I should probably merge those back into Scripthook V .NET too.

Share this post


Link to post
Share on other sites
julionib

Thank you George, I'll try your suggestion tomorrow night. Can you help me better understand the difference between group and relationship group? I've seen other forum posts with people doing crazy stuff like setting all peds group (or relationship group?) to "cougar" and turning everyone against each other. I was under the impression that you could create a group and then set its relationship with other groups (i.e. 'Hated') but I can't seem to get any of that working right.

 

 

As far as the sounds, I'm more than happy to help you out. First I found the sound I wanted using OpenIV, but of course the sound names shown in OpenIV don't match exactly what you need to call in code. Once I had some idea what the developers were referring to that sound as, I searched for something similar in one of these three amazing dumped lists by Konijima.

 

Full list of FRONT_END Sounds

http://konijima.com/assets/PLAY_SOUND_FRONTEND.txt

Full list of ENTITY Sounds

http://konijima.com/assets/PLAY_SOUND_FROM_ENTITY.txt

Full list of COORD Sounds

http://konijima.com/assets/PLAY_SOUND_FROM_COORD.txt

 

These are absolutely invaluable and should be stickied somewhere. However, Konijima has stated that they're too big to host in PasteBin so he's hosting them on his own server. That means they could disappear someday. I highly recommend you save all three of them locally (which I have done).

 

 

IMPORTANT NOTE: It appears that some of the sounds don't play even when copied directly from those lists. My gut tells me that's because they're not loaded, similarly to how you need to load an animation before it plays. Unfortunately I don't see a native similar to Native::Hash::REQUEST_ANIM_DICT for sounds.

 

hey man, can you reupload those lists somewhere for me? my internet conn seems to have issues loading this site

Share this post


Link to post
Share on other sites
Skorpro

hey man, can you reupload those lists somewhere for me? my internet conn seems to have issues loading this site

Hi JulioNIB!

 

Maybe it's useful: I'm using FileLocator Lite to make such lists :)

 

Share this post


Link to post
Share on other sites
julionib

 

hey man, can you reupload those lists somewhere for me? my internet conn seems to have issues loading this site

Hi JulioNIB!

 

Maybe it's useful: I'm using FileLocator Lite to make such lists :)

 

 

 

thx, let me try

Share this post


Link to post
Share on other sites
c39687

try setting Ped Combat attributes

 

PED::SET_PED_COMBAT_ATTRIBUTES Hashes: 0x9F7794730795E019 0x81D64248
void SET_PED_COMBAT_ATTRIBUTES(Ped ped, int attributeIndex, BOOL enabled)// 0x9F7794730795E019 0x81D64248

These combat attributes seem to be the same as the BehaviourFlags from combatbehaviour.meta.
So far, these are the equivalents found:
enum CombatAttributes
{
BF_CanUseCover = 0,
BF_CanUseVehicles = 1,
BF_CanDoDrivebys = 2,
BF_CanLeaveVehicle = 3,
BF_CanFightArmedPedsWhenNotArmed = 5,
BF_CanTauntInVehicle = 20,
BF_AlwaysFight = 46,
BF_IgnoreTrafficWhenDriving = 52
};

Research thread: gtaforums.com/topic/833391-researchguide-combat-behaviour-flags/

 

use flag 46 to ensure they always fight or 5 for specifically what u want, this should hopefully make them attack while unarmed

Edited by c39687

Share this post


Link to post
Share on other sites
ghostlysounds

Hi eXntrc, I'm trying to figure out how to replace an existing sound in OpenIV and play it via code, but can't find a match between the list and the files I'm browsing in OpenIV.

I was wondering if you remember where the whistle sound is located in OpenIV that you're using here:

 

Audio.PlaySoundFromEntity("Franklin_Whistle_For_Chop", player, "SPEECH_RELATED_SOUNDS");

 

or if you know of any other files in OpenIV that relate to a PLAY_SOUND_FROM_ENTITY that is listed in one of the pastebins?

 

Thanks for any leads!

Share this post


Link to post
Share on other sites

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.


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