Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Jetrise

Animation Query regarding animationstate

Recommended Posts

Hello All,

 

So after some work tonight on my basic medical system, I have made it so that the player goes unconscious when hit! 

 

I know it's basic, but the issue I have right now is that I want to 'double tap' players as such. So once they're unconscious, they can be shot again to be killed. 

 

Below you can see the code:

MedSys_F_DamageHandler = 
{
	_selection	= _this select 1;
	
	if((alive player)&& !skipDmg) then {
	hint "Cheeky Hint";
		_vehicle	= _this select 0;
		_damage	= _this select 2;
		_shooter	= _this select 3;          
		_vcls = nearestobjects [getpos _vehicle, ["LandVehicle", "Air", "ship"],8];
		_vcl = _vcls select 0;
	  
	 
		if(call plr_isUnConscious) then { player setDamage 1;} else {
			hint "Cheeky Hint #2";
			[_selection,_damage,_shooter, _vcls] spawn {
				_selection	= _this select 0;
				_damage		= _this select 1;
				_shooter	= _this select 2;
				_vcls		= _this select 3;
				_vcl		= _vcls select 0;
				
				
				
			if(alive player) then {
			hint "Cheeky Hint #3";
			vdamage = vdamage + _damage;
				
				if (vdamage > 0.99) then {
				hint "Cheeky Hint #4";
					skipDmg = true;    
					if (vehicle player != player) then {			
					player action ["eject", vehicle player]; sleep 2; sleep 0.5; };
					
					player playActionNow "agonyStart";
					sleep 5;
					
					while { dialog } do { closeDialog 0; };
					titleText ["You have been KO'd!", "WHITE OUT", 2];
					sleep 1;
					skipDmg = false; 
				};
			} else { player setDamage vdamage; };
				
			  
				if(!(alive player)) then {};
			};
		};
	};
  
  
  
  0
};

plr_isUnConscious = 
{
if((alive player) && (animationstate player == "agonyStart") && (player isKindOf "Man")) then { true } else { false };
};

It's important to note that this has been called already and the above are functions. 

 

In my code, I have a function call, "if(call plr_isUnConscious) then { player setDamage 1;}". Obviously, it goes down to the plr_isUnConscious function on the bottom and checks a couple of things. 

 

However, is this correct, "animationstate player == "agonyStart""? I mean, does animation state work with that? Would I need to use actionstate or something equivalent to that. 

 

My question:

Can you use animationstate to check if a player is in playActionNow?

 

Thanks in advance!

 

Shaun. 

Share this post


Link to post
Share on other sites

Also, the cheeky hints are only there for testing purpose, in-case any of you are wondering xD 

Share this post


Link to post
Share on other sites

To determine the true animation name you need, I recommend bringing up a new clean mission with nothing in it, put down a player, and run it.

 

Then use Escape and go to the debug console.

 

In top of console type this liine and click Execute:

player playActionNow "agonyStart";

Then in one of the variable lines lower in the console, type this to see what animation value is returned.

You will then know the exact animation name.

animationState player

An entirely different approach would be to add a variable to the player in your init.sqf called "unitInAgony" and set it to false.

player setVariable ["unitInAgony", false, true];

Then in your eventhandler code above, you would set this value to true when you playActionNow "agonyStart".

And finally you wouldn't need your function anymore. Instead you would change your IF statement in handler to be:

if(player getvariable "unitInAgony") then { player setDamage 1;} else {
  • Like 1

Share this post


Link to post
Share on other sites

Thanks! Really appreciate the help, I'll try it out tomorrow morning and I'll get back to you. 

  • Like 1

Share this post


Link to post
Share on other sites

Resolved!

 

animatestate was actually, "ainjppnemstpsnonwrfldnon". Kinda weird but never mind. Thanks @johnnyboy

  • Like 1

Share this post


Link to post
Share on other sites

×