[C#] Possible to make a ped use any explosive (grenades, proximity mines, etc.)?
-
Hello, I did a search on Google and gtaforums but I couldn't find any information on it, except for @InfamousSabre mentioning that he couldn't figure out how to get peds to use "grenades or molotovs". If that's still not possible, I can definitely settle with using a proximity mine instead. Anyone know? I've tried the following method but the ped always switches back to their gun. If I leave the ShootAt task, the game just crashes
void GrenadeTask(Ped p) { if (!p.Weapons.HasWeapon(WeaponHash.Grenade)) { p.Weapons.Give(WeaponHash.Grenade, 1, true, true); } else { p.Weapons.Select(WeaponHash.Grenade); p.CanSwitchWeapons = false; //p.Task.ShootAt(player.Position, 3000); } }
Thanks in advance!
-
Well, there is a native that seems interesting. AI::TASK_THROW_PROJECTILE
I will give it a try when I find the time!
-
@stillhere said in [C#] Possible to make a ped use any explosive (grenades, proximity mines, etc.)?:
Well, there is a native that seems interesting. AI::TASK_THROW_PROJECTILE
I will give it a try when I find the time!Did it work?
-
@GTATerminal It works! I was able to get a normal ped to use a grenade, but for some reasons cops always switch back to their default weapons (they do hold the grenade for a second), even if I use p.CanSwitchWeapons = false; OnTick for 20 seconds after giving them the grenade. I think I can figure this out though!
-
@stillhere What if you remove all of their weapons, then add a grenade as their only weapon?
-
@GTATerminal I tried that and they just run away, probably because they have no weapons for a moment. So I gave them ped attributes like so (which should make them attack even if they have no weapon):
Function.Call(Hash.SET_PED_COMBAT_ATTRIBUTES, p, 17, 1); Function.Call(Hash.SET_PED_COMBAT_ATTRIBUTES, p, 46, 1); Function.Call(Hash.SET_PED_COMBAT_ATTRIBUTES, p, 5, 1);
But some of them just start to have a "vibrating" effect, like they are constantly switching between 2 animations.
I haven't tested that extensively though. I've tried all those attributes altogether, and attribute 17 by itself, but the results are the same. I haven't tried attribute 46 or 5 by themselves yet.
-
ca i get this script plzzz ? im building missions and i want enemy ped to use grenade and ball at me ( i moded ball into a grenade )
-
Necro.