Jump to content

CPR Help & General Help


Fiskey111

Recommended Posts

Hello!

I'm back from my if you may, student sabbatical, and I'm ready to go with ideas for my callouts!

Last night I began work on a newly updated Officer Shot callout.  My goal for the final release of Secondary callouts is to make each callout a bit more in depth.  So, the newest version of OS will require the player (if they want to save the officer) to do CPR on the subject.  I'm having some issues with this though - I've gotten the player to stay in the end frame of the intro animation, but I can't get them to continue to the next push.  I had tried to do:

Spoiler

if (Game.IsKeyDown.Y)
{
//play animation
//sleep gamefiber
//Check to see if cop is alive now
}

 

But that didn't end up working!  The player doesn't end up actually playing the animation he's frozen there.  I'm going to look into it more, but if anyone's seen this before let me know what the issue is!

Secondly, I want to have the peds line up (like how in the CPR intro they spread the body out flat).  How can I correctly line up the peds?  Right now I just make the player be on the specific side of a person, but I don't know how to make them line up perfectly.  Specifically, I can't get the cop to lie flat when he dies.  Is there a way to do that?  It would save all my troubles!

I'll update this with any other questions I have on my last release of Secondary Callouts!

 

 

Link to comment
Share on other sites

Just an idea, but maybe try adding .WaitForCompletion() to the end of the animation task instead of sleeping it for a set time? I've found a few cases where this works better, even when the task has a set time it should be running.

My YouTube Channel: Darkmyre Gaming (Australian LSPDFR patrols, plugins in development, and other games)

My Discord Server | AusGamer Network

 

Please do not PM me for technical support or bug reports, use the appropriate forum or plugin's comments instead.

Link to comment
Share on other sites

At one point @DemNinjas had CPR in PoliceToolbox. I don't recall if they did CPR or not. I know @gangrenn's rescue mod definitely has CPR in it, and the rescue peds will decrumple the injured body and line up just right. Perhaps one of them can comment with some suggestions? 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

Link to comment
Share on other sites

It was quite a long time ago, but I remember CPR is not just a single animation. You'd play in the correct order :

Spoiler

"mini@cpr@char_a@cpr_def", "cpr_intro"

then

"mini@cpr@char_a@cpr_str", "cpr_pumpchest"

then 

"mini@cpr@char_a@cpr_def", "cpr_pumpchest_idle"

then 

"mini@cpr@char_b@cpr_str", "cpr_success"  OR  "mini@cpr@char_a@cpr_str", "cpr_fail" depending on the victim's state

with the right amount of time between the animations. I suggest the player would have to press a key, and you would then play "cpr_pumpchest", and get back to "cpr_pumpchest_idle" after the other animation is done.

I remember freezing the dead ped to avoid multiple problems when the player is performing CPR, and de-freezing it when it lives again.

I think you only played the "cpr_intro" so this is why the player is stuck after the intro.

Also, playing the animation won't revive the ped, you have to do it yourself :)

Link to comment
Share on other sites

6 hours ago, DemNinjas said:

It was quite a long time ago, but I remember CPR is not just a single animation. You'd play in the correct order :

  Reveal hidden contents

"mini@cpr@char_a@cpr_def", "cpr_intro"

then

"mini@cpr@char_a@cpr_str", "cpr_pumpchest"

then 

"mini@cpr@char_a@cpr_def", "cpr_pumpchest_idle"

then 

"mini@cpr@char_b@cpr_str", "cpr_success"  OR  "mini@cpr@char_a@cpr_str", "cpr_fail" depending on the victim's state

with the right amount of time between the animations. I suggest the player would have to press a key, and you would then play "cpr_pumpchest", and get back to "cpr_pumpchest_idle" after the other animation is done.

I remember freezing the dead ped to avoid multiple problems when the player is performing CPR, and de-freezing it when it lives again.

I think you only played the "cpr_intro" so this is why the player is stuck after the intro.

Also, playing the animation won't revive the ped, you have to do it yourself :)

Yes, sorry, I should have been clearer.

Further on in my code I have the remaining animations, but it keeps being hung up at that specific point.  When I go to do "pumpchest" it freezes my character.  I haven't looked into it for a couple days, but the biggest thing is lining up the peds and getting the cop to be on his back.

Thank you!

 

 

Link to comment
Share on other sites

So, I haven't gotten a way to force the player into a position (like pull them to the correct side of the cop), but I did get all the animations to work!!!!!

I wanted to set an arrow to appear (or some sort of marker) on the correct side of the ped on the screen (not the minimap - like I want them to walk into the marker).  I thought it would have been NativeFunction.CallByName<uint>("SET_BLIP_SHOW_CONE", CPRBlip, true); but that doesn't work (or maybe I'm using it wrong?)

In addition, my cop keeps dying after he plays the animation for CPR success.  Any idea why? I don't kill him anywhere except for when he dies after the failure CPR animation, and I actually try to force him to have a certain health  Any idea why?  Is that amount of health a correct amount?  Here's the code:

Spoiler

                    if (k == 1)
                    {
                        if (Game.LocalPlayer.Character.IsFemale)
                        { this.CopSucceed.Play(); }

                        GameFiber.StartNew(delegate
                        {
                            Cop.Tasks.PlayAnimation("mini@cpr@char_b@cpr_str", "cpr_success", 4f, AnimationFlags.None).WaitForCompletion();
                            Cop.Health = 15;
                        });
                        GameFiber.StartNew(delegate
                        {
                            Game.LocalPlayer.Character.Tasks.PlayAnimation("mini@cpr@char_a@cpr_str", "cpr_success", 4f, AnimationFlags.None).WaitForCompletion();
                        });
                        Cop.Health = 100;
                        if (Cop.IsAlive)
                        { state = EOfficerDownState.CPRSuccess; }

                        Game.DisplayHelp("Get in your cruiser and take the officer to the ~g~hospital~w~!");
                    }
                    else if (k == 2)
                    {
                        GameFiber.StartNew(delegate
                        {
                            GameFiber.Sleep(4000);
                            this.CopFail.Play();
                        });
                        GameFiber.StartNew(delegate
                        {
                            Cop.Tasks.PlayAnimation("mini@cpr@char_b@cpr_str", "cpr_fail", 4f, AnimationFlags.None).WaitForCompletion();
                        });
                        GameFiber.StartNew(delegate
                        {
                            Game.LocalPlayer.Character.Tasks.PlayAnimation("mini@cpr@char_a@cpr_str", "cpr_fail", 4f, AnimationFlags.None).WaitForCompletion();
                        });
                        Cop.Kill();
                        state = EOfficerDownState.CPRFail;
                    } 

 

 

 

 

Link to comment
Share on other sites

  • 3 weeks later...
On 4/11/2016 at 10:09 PM, fiskey111 said:

So, I haven't gotten a way to force the player into a position (like pull them to the correct side of the cop), but I did get all the animations to work!!!!!

I wanted to set an arrow to appear (or some sort of marker) on the correct side of the ped on the screen (not the minimap - like I want them to walk into the marker).  I thought it would have been NativeFunction.CallByName<uint>("SET_BLIP_SHOW_CONE", CPRBlip, true); but that doesn't work (or maybe I'm using it wrong?)

In addition, my cop keeps dying after he plays the animation for CPR success.  Any idea why? I don't kill him anywhere except for when he dies after the failure CPR animation, and I actually try to force him to have a certain health  Any idea why?  Is that amount of health a correct amount?  Here's the code:

  Hide contents


                    if (k == 1)
                    {
                        if (Game.LocalPlayer.Character.IsFemale)
                        { this.CopSucceed.Play(); }

                        GameFiber.StartNew(delegate
                        {
                            Cop.Tasks.PlayAnimation("mini@cpr@char_b@cpr_str", "cpr_success", 4f, AnimationFlags.None).WaitForCompletion();
                            Cop.Health = 15;
                        });
                        GameFiber.StartNew(delegate
                        {
                            Game.LocalPlayer.Character.Tasks.PlayAnimation("mini@cpr@char_a@cpr_str", "cpr_success", 4f, AnimationFlags.None).WaitForCompletion();
                        });
                        Cop.Health = 100;
                        if (Cop.IsAlive)
                        { state = EOfficerDownState.CPRSuccess; }

                        Game.DisplayHelp("Get in your cruiser and take the officer to the ~g~hospital~w~!");
                    }
                    else if (k == 2)
                    {
                        GameFiber.StartNew(delegate
                        {
                            GameFiber.Sleep(4000);
                            this.CopFail.Play();
                        });
                        GameFiber.StartNew(delegate
                        {
                            Cop.Tasks.PlayAnimation("mini@cpr@char_b@cpr_str", "cpr_fail", 4f, AnimationFlags.None).WaitForCompletion();
                        });
                        GameFiber.StartNew(delegate
                        {
                            Game.LocalPlayer.Character.Tasks.PlayAnimation("mini@cpr@char_a@cpr_str", "cpr_fail", 4f, AnimationFlags.None).WaitForCompletion();
                        });
                        Cop.Kill();
                        state = EOfficerDownState.CPRFail;
                    } 

 

 

How'd you get the CPR animation itself to be smooth? I'm having issues... the ped doing CPR keeps jerking up and down suddenly instead of smoothly doing CPR. Something to do with the timing parameter maybe? 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

Link to comment
Share on other sites

48 minutes ago, PNWParksFan said:

How'd you get the CPR animation itself to be smooth? I'm having issues... the ped doing CPR keeps jerking up and down suddenly instead of smoothly doing CPR. Something to do with the timing parameter maybe? 

I had the last part of the playanimation() be something.StayInEndFrame   (blanking on the actual part, but it's the last thing in the task)

That seemed to work well!

 

 

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