Quantcast

Jump to content

» «
Photo

[Q] AI has unlimited ammo

1 reply to this topic
ins1de
  • ins1de

    Vi Veri Veniversum Vivus Vici

  • Members
  • Joined: 23 Apr 2016
  • Antarctica

#1

Posted 23 March 2017 - 06:36 PM Edited by ins1de, 23 March 2017 - 06:38 PM.

Why does the game give unlimited ammo to NPCs?

Whenever you spawn one ped with a weapon, it won't have the specified ammo you requested..

 

Unfortunately, it seems to work half of the time with some weapons :

  • MG
  • Automatic pistol

I haven't tried all of them yet, but there are probably some weapons that are not controlled by some external game script.

While trying something in one of my custom scripts, I wanted one ped to shoot only and only 1 rocket with the RPG. It turns out that the ped has 1 RPG weapon, but not 1 rocket.

So I thought setting the ammo to 1 should solve it and I went looking for the rocket hashes without success because the actual problem was located in the CLIP itself.

 

In other words, I have not found any other solution than counting the reloading attempts. Are there any natives that could do the job for us or other ways around?

 

In C#, I got this :

  if(counter >= 1)
                    {
                        if(retard.Weapons.Current.Hash == WeaponHash.RPG)
                        {
                            Function.Call(Hash.SET_PED_DROPS_WEAPON, retard);
                        }
                    }

counter should only be triggered by the IS_PED_RELOADING native.

//In a tick
if (Function.Call<bool>(Hash.IS_PED_RELOADING, retard)) counter++;

if(retard.Weapons.Current.Hash == WeaponHash.RPG) //Prevent dropping errors
                        {
                            Function.Call(Hash.SET_PED_DROPS_WEAPON, retard);
                        } 

Video Result :

 

*Info : In the first part of the video you can see the default behaviour, and in the last part you see the script in action.

 

https://player.vimeo...video/209786872


templargfx
  • templargfx

    Player Hater

  • New Members
  • Joined: 20 Apr 2017
  • Australia

#2

Posted 20 April 2017 - 01:00 AM

Hi,

 

I am new to GTA modding, so excuse me if this is unrelated.

 

In data\ai\loudouts.meta most of the ped types in there have 

<Flags>InfiniteAmmo</Flags>
  • jedijosh920 and ins1de like this




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users