Jump to content
zloganrox08

Making Ped(cop) aim while taking cover

Recommended Posts

Posted (edited)

I'm making a bank robbery callout where the player is SWAT and has to go in and rescue the hostage, and obviously, in a situation like this, the first police officers there aren't SWAT, but would still be aiming at the bank door in case the robbers come out guns blazing. I've tried a couple functions and haven't found one that gets them to aim at the door properly. I've used TakeCoverFrom() for sure, to no avail. Maybe my timeout duration is too short(set at 100 seconds. I think it's pointless to have a duration anyways) but by the time I get there, they aren't aiming at anything, they're just standing there. I'm tempted to try AimWeaponAt() but I still don't like the duration thing, and the duration might not even be my problem.

 

Second question, related enough to be covered under this topic, I also try to make the officers open their driver door first, and only 2/3 of them do it. Here's the code for both these tasks:

 

Quote

                Officer1.Tasks.EnterVehicle(Sheriff1, -1, EnterVehicleFlags.DoNotEnter).WaitForCompletion(5000);
                Officer2.Tasks.EnterVehicle(Sheriff2, -1, EnterVehicleFlags.DoNotEnter).WaitForCompletion(5000);
                Officer3.Tasks.EnterVehicle(Sheriff3, -1, EnterVehicleFlags.DoNotEnter).WaitForCompletion(5000);

                Officer1.Tasks.TakeCoverFrom(BankDoor, 100000, false);
                Officer2.Tasks.TakeCoverFrom(BankDoor, 100000, false);
                Officer3.Tasks.TakeCoverFrom(BankDoor, 100000, false);

 

Edited by zloganrox08
Put code in quote

Share this post


Link to post
Share on other sites
Posted (edited)

1. unlimited duration = -1

2. you could just open the doors with vehicle.Doors[doorIndex].Open(bool p1, bool p2);

3. make sure you are running a new fiber when using something like wait for completion

Edited by NoNameSet

Share this post


Link to post
Share on other sites

Thanks for the replies,

 

The behavior I've noticed when doing wait for completion without a game fiber is that the rest of the game runs, but my code waits until the person finishes the task. I like this because then I can give 2 tasks at the same time (like the above) and not worry about the first one not getting done.

Share this post


Link to post
Share on other sites
2 hours ago, zloganrox08 said:

Thanks for the replies,

 

The behavior I've noticed when doing wait for completion without a game fiber is that the rest of the game runs, but my code waits until the person finishes the task. I like this because then I can give 2 tasks at the same time (like the above) and not worry about the first one not getting done.

don't run wait for completion without a fiber as it sleeps the current fiber which then will be null and won't end good for you or the user.

Share this post


Link to post
Share on other sites
7 hours ago, NoNameSet said:

don't run wait for completion without a fiber as it sleeps the current fiber which then will be null and won't end good for you or the user.

 

I'll add in a fiber, see if it helps anything. Sidenote, I'm  not PLANNING to release these callouts to people, as I use addon vehicles, but good coding practice is a good idea anyways.

Share this post


Link to post
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

×