Jump to content

How do i have suspect fire weapon at empty vehicle?


lowercaseK

Recommended Posts

Hello,

I am having a go at making some callouts and am really enjoying it.

I have come unstuck and would love some advice. I've been doing a lot of reading, but dont have a great grasp on the API yet.

I want to make a PED shoot at an empty vehicle (or better yet a vector location), that has no PED or player inside.

 

To prove basic feature of my code I have tried:

Suspect1.Tasks.AimWeaponAt(Game.LocalPlayer.LastVehicle,5000);

 

This works in that the PED will follow (pointing) the car with their drawn weapon as i drive past.

 

Then i tried this, but it just has the PED point the weapon, but never fires the shots:

Suspect1.Tasks.FireWeaponAt(Game.LocalPlayer.LastVehicle, 10000, FiringPattern.FullAutomatic);

 

And this works to make the PED shoot the player. But directly substituting PED for vehicle doesnt work.

Suspect1.Tasks.FireWeaponAt(Game.LocalPlayer.Character, 10000, FiringPattern.FullAutomatic);

 

 

I also looked at Ped.Tasks.FightAgainst(parameters) as i read in another post, doesnt work as thats for PEDs only.

 

 

Any suggestions or direction to put me back on track?

LowercaseK

Link to comment
Share on other sites

14 hours ago, Rich said:

You might try the TASK_SHOOT_AT_ENTITY native.

Thanks for the suggestion Rich, i appreciate the quick response!

 

Ive just been trying a handful of things around task_shoot_at_entity.

If i use;

Rage.Native.NativeFunction.Natives.Task_Shoot_At_Entity(Suspect1, Game.LocalPlayer.Character, 20000, 0xC6EE6B4C);

 

The suspect will shoot at me, so it works using a Ped.

 

But as soon as i try;

Rage.Native.NativeFunction.Natives.Task_Shoot_At_Entity(Suspect1, Game.LocalPlayer.LastVehicle, 20000, 0xC6EE6B4C);

 

The suspect will not fire. They continue to point. I put a Game.DisplayHelp("SHOOTING"); after the nativefunction which executes so im assuming the game is executing it.

 

In both cases i am setting a task for the suspect to aim, using;

Suspect1.Tasks.AimWeaponAt(Game.LocalPlayer.LastVehicle, 20000);

 

That works okay. When i get out of the car the suspect maintains aiming at the car.

 

I am getting confused what an entity is. Can an vehicle be an entity? Do i need to define a vehicle as an Entity?

If the parameters are:

Syntax:
TaskShootAtEntity (entity,target,duration,firingPattern)
Parameters:
entity: Entity -
target: Entity -
duration: Int -
firingPattern: Hash -

LowercaseK

Link to comment
Share on other sites

I feel like i've just finished reading the internet, and im now more lost 🤣

Ive tried using:

Rage.Native.NativeFunction.Natives.TASK_SHOOT_AT_COORD(Suspect1, 467.837921f, -1254.23413f, 29.5068264f, 5000, 0xC6EE6B4C);

This has Ped point at coord, but not shoot.

void TASK_SHOOT_AT_COORD ( Ped ped, float x, float y, float z, int duration, Hash firingPattern )

 

Also tried:

                Rage.Native.NativeFunction.Natives.SET_PED_SHOOT_RATE(Suspect1, 900);
                Rage.Native.NativeFunction.Natives.SET_PED_SHOOTS_AT_COORD(Suspect1, playersVehicle, true);

This works except it has the PED fire only one shot (using an smg). The coord works well. Just need to get multiple shots using a firepattern or something?

 

 

 

LowercaseK

Link to comment
Share on other sites

On 1/13/2022 at 3:43 AM, lowercaseK said:

Then i tried this, but it just has the PED point the weapon, but never fires the shots:

Suspect1.Tasks.FireWeaponAt(Game.LocalPlayer.LastVehicle, 10000, FiringPattern.FullAutomatic);

What about Game.LocalPlayer.LastVehicle.Position?

Released plugins

Automatic Siren Cutout | Rich's Police EnhancementsScene Manager | Rich Ambiance

Retired - No more updates

Link to comment
Share on other sites

10 hours ago, Rich said:

What about Game.LocalPlayer.LastVehicle.Position?

Nah that didnt work either. Seems it has to be a Ped (entity target), not a position.

It works if i use:

Suspect1.Tasks.FireWeaponAt(Suspect2, 5000, FiringPattern.FullAutomatic);

Where Suspect2 is defined as a PED.

 

Natives.TASK_SHOOT_AT_COORD seems like a perfect description of what i am trying to achieve, but i just cant find a way, or any examples of it working.

 

void TASK_SHOOT_AT_COORD ( Ped ped, float x, float y, float z, int duration, Hash firingPattern )

 

LowercaseK

Link to comment
Share on other sites

4 hours ago, lowercaseK said:

Nah that didnt work either. Seems it has to be a Ped (entity target), not a position.

It works if i use:

Suspect1.Tasks.FireWeaponAt(Suspect2, 5000, FiringPattern.FullAutomatic);

Where Suspect2 is defined as a PED.

 

Natives.TASK_SHOOT_AT_COORD seems like a perfect description of what i am trying to achieve, but i just cant find a way, or any examples of it working.

 

void TASK_SHOOT_AT_COORD ( Ped ped, float x, float y, float z, int duration, Hash firingPattern )

 

 

The second overload for FireWeaponAt takes a Vector3, so an entity is not required.  This method is just a wrapper for the TASK_SHOOT_AT_COORD native.

Released plugins

Automatic Siren Cutout | Rich's Police EnhancementsScene Manager | Rich Ambiance

Retired - No more updates

Link to comment
Share on other sites

21 minutes ago, Rich said:

 

The second overload for FireWeaponAt takes a Vector3, so an entity is not required.  This method is just a wrapper for the TASK_SHOOT_AT_COORD native.

Oh ok, i think i understand what you mean.

So when i call FireWeapon task, i can give the arguments as either Entity or Vector, and the task will know which to use?

 

 

FireWeaponAt(Entity, Int32, FiringPattern)    
FireWeaponAt(Vector3, Int32, FiringPattern)

 

Im not sure what you mean by wrapper, but thats ok.

 

So...

Like you suggested i tried:

Suspect1.Tasks.FireWeaponAt(Game.LocalPlayer.LastVehicle.Position, 10000, FiringPattern.FullAutomatic);

 

Which should work, but doesnt. Is it possible then that the 'Suspect1' is being 'interupted' by LSPDFR or something else in my script? Or I might need a task before i call FireWeaponAt? I just find it strange that if i pass the same line and use a PED instead of position, it works perfect. If i pass a position instead of PED it doesnt work.

   

LowercaseK

Link to comment
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.



×
×
  • Create New...