Jump to content
AZCoder

Flip Flopping Dead Dudes

Recommended Posts

Looking for suggestions to fix a bizarre animation bug.

I have a patrol script that I wrote https://github.com/AZCoder/AZC-LIB/blob/master/patrol/fn_APM.sqf

and when a dude on patrol reaches a position, he will animate with one of the "InBaseMoves_patrolling" animations. I mean, I can't have him standing there scratching his body parts!

 

The problem is that if you kill a unit in the middle of animation, the body will intermittently glitch by standing up again and slumping down. If you turn around and face the body again, he will often stand up and fall back down. It's like night of the living dead, but without the moaning. I currently have this event handler


_unit addEventHandler ["Killed", {

_unit = _this select 0;

_unit switchMove "";

_unit enableAI "ANIM";

// trying to fix problem of body going vertical multiple times upon being shot!

_unit switchMove "AinjPpneMstpSnonWnonDnon";

}];

 

I chose the animation in there because it seemed to force the body down and thought it was resolved, but 2 days later it is happening again. Anybody dealt with this problem before, or have any good ideas? Thanks!

  • Like 1

Share this post


Link to post
Share on other sites

That's the problem for all interrupted animations by death or unconsciousness. for instance, if you shoot at a medic while he's healing another unit, you'll obtain some weird behavior: the animation will continue or restart after after healing the medic at his turn. Some times, the healed/interrupted unit will seem to be healed (flipping from back to prone-ready gun position, but he's stuck like this. This can affect also players as well. The unconscious "status" is "fragile" for animations. The switchMove "" is the unique solution I found. The problem is when apply this. Your EH should work. In SP or MP, don't add anything else. The EH "killed" can be fired very soon (before the ragdoll falling death). So, you should spawn the EH code in order to let some sleep time.

Note: in MP, you need to remoteExec the switchmove:

[_yourUnit,''] remoteExec ['switchMove'] because the effect is local.

Last but not least: On heavy scenario, multiple mods, you always struggle against 0.3 ms slot time scheduler and that turns weird for animations, remote Executions and even spawned scripts anyway. No miracle here.

 

  • Like 2
  • Thanks 1

Share this post


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

// trying to fix problem of body going vertical multiple times upon being shot!

 

Hello there AZCoder !

 

Since you want to play this on killed :

addMissionEventHandler ["EntityKilled", 
{
	params ["_killed", "_killer"];	
	if (_killed isKindOf "CAManBase"  
) then
	{
			
	_killed = _this select 0;
	_killed switchMove "";
	_killed enableAI "ANIM";
	_killed switchMove "AinjPpneMstpSnonWnonDnon";
	
	systemchat "ok";
	};
}];

if you want to add sleep in the code then create a .sqf and add this in the addMissionEventHandler

 

like

_killed execVM "somescript.sqf";

 

somescript.sqf :

 

sleep 2;
	_this switchMove "";
	_this enableAI "ANIM";
	_this switchMove "AinjPpneMstpSnonWnonDnon";
  • Like 1

Share this post


Link to post
Share on other sites

( * I haven't fully understand what you want to succeed! )

 

check this is working :

_killed switchMove "ApanPercMstpSnonWnonDnon_ApanPpneMstpSnonWnonDnon";

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Yeah it's kind of a heavy mod mission. I had one guy on a patrol on top of a hill do flip flops all the way down after I shot him. It was rather funny TBH.

I'll try these ideas out tonight, thanks.

  • Like 1

Share this post


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

I'll try these

 

The second post maybe is the solution , it's giving a falling (panic) animation , as i check ( if it's working for your script )

it's better

 

this:

addMissionEventHandler ["EntityKilled", 
{
	params ["_killed", "_killer"];	
	if (_killed isKindOf "CAManBase"  
) then
	{
			
	_killed = _this select 0;
	_killed switchMove "";
	_killed enableAI "ANIM";
	_killed switchMove "ApanPercMstpSnonWnonDnon_ApanPpneMstpSnonWnonDnon"; 
	
	systemchat "ok";
	};
}];

 

Share this post


Link to post
Share on other sites

Strange question, but you can only be killed once right? I don't have to remove that event handler, or should I?

  • Haha 1

Share this post


Link to post
Share on other sites
1 minute ago, AZCoder said:

but you can only be killed once right?

 

ok that was a good one !

 

Remove , and try  the code above (try also the addEventHandler )

  • Like 1

Share this post


Link to post
Share on other sites

Hmmmmmmmmm.

This is extreme but works:

 


_unit addEventHandler ["Killed", {
    _unit = _this select 0;
    if (_unit isKindOf "CAManBase") then
    {
        [_unit] spawn
        {
            params["_unit"];
            _unit removeAllEventHandlers "Killed";
            // trying to fix problem of body going vertical multiple times upon being shot!
            waitUntil { animationState _unit == "deadstate" };
            _unit disableAI "ANIM";
            _unit switchMove "deadstate";
            sleep 1;
            _unit enableSimulation false;
        };
    };
}];

 

However disabling simulation means you cannot loot the body.

 

I also tried forcing him back to dead state on animation change:


_unit addEventHandler ["AnimStateChanged", {
                params ["_unit", "_anim"];
                _unit switchMove "deadstate";
                systemChat "cheeki breeki!";
            }];

 

It's called for sure, but you still get the flip flop. So I replaced "deadstate" with just switchMove "" and got this:

 

 

  • Haha 1

Share this post


Link to post
Share on other sites
12 hours ago, AZCoder said:

 _unit enableSimulation false;

 

Did you tried without?

 

Since you are using addEventHandler you can create a while true to get set a variable about this , like :

 

EXAMPLE

GF_HEADSHOT = { 
_this addEventHandler 
..................... your code


[]spawn{	
while {true} do 
{
	{	
		if (!(_x getVariable ["GF_EΗ_HEADSHOT",false])) then {
			  _x spawn GF_HEADSHOT};						
			  _x setVariable ["GF_EΗ_HEADSHOT",true];	

			 {waitUntil {!alive _x};
			 _x setVariable ["GF_EΗ_HEADSHOT",false];							
		};
	}forEach allUnits;	 
};
};

 

It should work like this ( maybe ! )

Did you tried the code above?

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, GEORGE FLOROS GR said:

 

Did you tried without?

 

Since you are using addEventHandler you can create a while true to get set a variable about this , like :

 

EXAMPLE

 

It should work like this ( maybe ! )

Did you tried the code above?

 

Yeah I tried all the code before without disabling sim, but the animation state will automatically change when you look away or try to loot it (not always). I should probably check for a bug report on it. I had a play tester see a similar glitch on an AI that was just using the "normal" animations (nothing I did). So it's certainly an engine bug. However, if I could find a way to enable/disable simulation when a player loots the body (IF they loot it), then I would have a workaround. I was testing the open & close inventory event handler, the dead body is the "container". Then I got too sleepy and stopped for the night.

  • Like 1

Share this post


Link to post
Share on other sites

If it is for me also  to be able to check this also ,

is the only script you are using this one:

On 2/5/2018 at 5:42 AM, AZCoder said:

 

or is there any other script interfering  with ?

Share this post


Link to post
Share on other sites

It uses all 3 in the patrol folder, if you go up one level. One just finds buildings to patrol, the other sets the animation for standing around at a waypoint.

  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, AZCoder said:

sets the animation for standing around at a waypoint.

 

If you don't use an animation and put him to do something different instead ?

( just a different approach ?! )

Share this post


Link to post
Share on other sites

Yes that's on my to-do list if I can stay awake after work.

 

  • Like 1

Share this post


Link to post
Share on other sites

I have it mostly resolved. If I don't set an animation during patrol, there's no issue, but as I said in the first post I don't want the guy just standing there. So I decided to create a replacement unit on death. It copies over all the gear and sets the new unit in the exact same location and direction while deleting the original glitchy unit. There is a slight visual glitch during the replacement, but it's way better than having them stand up repeatedly. I'm done for tonight but will update my GitHub once it meets my needs.

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×