Jump to content
tpw

setunconscious not working on player when called from a script

Recommended Posts

Hi all. 

 

I've been using setunconscious as a convenient way to ragdoll units (AI and player) when they take a hit. Just recently I noticed that my script to do this had stopped working for the player, but still dropped the AI no worries.

 

The strange thing is that player setunconscious true works just fine from the debug console

 

If in the console I run the command 

{_x setunconscious true} foreach units group player; 

then me and everyone in my squad will hit the deck.

If I run the same command from a script then I will remain upright while the rest of the squad passes out.

 

Anyone got any ideas? Is this a bug or a design decision?

 

Thanks in advance.

 

 

 

Share this post


Link to post
Share on other sites

Might help to see that script you're refering to. The issue could be somewhere else.

Share this post


Link to post
Share on other sites

Thanks Tajin

 

It's any script called by execm. Even a single line script as per below.

 

{_x setunconscious true} foreach units group player; 

Share this post


Link to post
Share on other sites

Hi,

 

I'm using something similar for respawn and it works fine (here's an excerpt):

 

        _unit switchMove "";
        _unit setUnconscious true;
        openMap [false,false];
        closeDialog 0;
        clearRadio;
        enableRadio false;
        "dynamicBlur" ppEffectEnable false;
        _unit allowDamage false;
        _unit setCaptive true;
        if (same(group _unit,group _source)
            and {diff(_unit,_source)}
        ) then {
            _text = format [
                "
                    <t size='3.2'color='#FF0000'align='center'shadow='2'>
                    %1 was killed by group member: %2
                    </t>
                ",
                name _unit,
                name _source
            ];
            _text remoteExecCall [
                "horde_fnc_displayActionRejMessage",
                units group _source
            ];
        };
        [_unit,_unit] call  horde_fnc_handleRespawn;

Fairly standard stuff, but then I am only ever using on just the player, not any AI and definitely not at the same time.

 

Maybe you should try it

1 - just on player

2 - then on an AI

3 - then player and some AI, but spaced out by 2 or 3 secs - {_x setunconscious true; sleep 3} foreach units group player;

 

Hopefully you can see where it fails (perhaps the engine can only process one setunconscious command per frame or something similar). 

 

EDIT:  I just called from debug console with me and 3 AI and we all passed out.

Share this post


Link to post
Share on other sites

Are you on dev or stable Das? It used to work fine on dev  up until a few weeks ago.

Share this post


Link to post
Share on other sites

I'm on dev mate - have you definitely ruled out mods or other scripts interfering with it (or maybe even a respawn template doing something funky or something like that)?

Share this post


Link to post
Share on other sites

Guys I have same problem - cant get it work on player. Im scripting @AISS2 mod and im using this command line (I want it to run on Exile server):
 

[ [_unit, true],"setUnconscious",false,true] call BIS_fnc_MP;

Share this post


Link to post
Share on other sites

 

Guys I have same problem - cant get it work on player. Im scripting @AISS2 mod and im using this command line (I want it to run on Exile server):

 

[ [_unit, true],"setUnconscious",false,true] call BIS_fnc_MP;

[ [player, true],"setUnconscious",false,true] call BIS_fnc_MP;

[ [AI_dude, true],"setUnconscious",false,true] call BIS_fnc_MP;

 

I just tried this on player and an AI unit and did not work for me either.

Share this post


Link to post
Share on other sites
Quote

 

[ [player, true],"setUnconscious",false,true] call BIS_fnc_MP;

[ [AI_dude, true],"setUnconscious",false,true] call BIS_fnc_MP;

 

I just tried this on player and an AI unit and did not work for me either.

 

SetUnconcious is a AL ( argument local ) command so needs to be run on the machine where the unit is local.

Your using False as the target which means run on the server.

 

For AI this is only going to be true if they are not running from a headless client and are not in a players group or is hosted(and host is running the command) or SP game.

You can use either of the following.

[[ [AI_dude, true], "setUnconscious", AI_dude ] call BIS_fnc_MP;
[ AI_dude, true ] remoteExec [ "setUnconscious", AI_dude ];

Here you use the actual unit as the target, so the command is run where the unit is local.

 

For player, as you are using the command player then you must already be on that clients machine so it would just be..

player setUnconscious true;

Here is a test mission showing all possible combinations via player actions for both the player and an AI, run from a dedicated server.

Self State - will set unconscious for the player, player automatically becomes conscious again after 5 seconds as being unconscious you lose the ability to run addActions

Self Server - will set unconscious for the player via a sever function, as above auto conscious after 5 seconds

AI State - will set/unset unconscious for a targeted local AI

AI Server- will set/unset unconscious for a remote targeted AI via a server function

AI Remote - will set/unset unconscious for a remote targeted AI directly via remoteExec

Join Group and Remove Group will make a targeted AI join/leave(and hand back to server) the players group so as to test changing locality

  • Like 3

Share this post


Link to post
Share on other sites

I tried Larrow demo mission on dedicated server, all fine but for Ai , it won't show unconscious animations on the server.

You can see screenshots i got it from server here 

https://forums.bistudio.com/topic/196150-setunconscious-animation-on-dedicated-server/

 

any way to show unconscious animations?

I do not see the same behaviour Persian, for me, using the my previous posts mission on a dedicated, the AI roll on to their backs and after about 7-8seconds will start playing their unconscious anims.

This is on a clean stable build.

 

EDIT: After restarting(#missions) or login out and back in on a persistent server I have now experienced what you are seeing a couple of times. I would post it up in the FBT see if BI can replicate and fix it.

  • Like 1

Share this post


Link to post
Share on other sites
For player, as you are using the command player then you must already be on that clients machine so it would just be..

player setUnconscious true;

 

Still, it doesnt work on dedicated if AI shots player - player wont be set to unconscious.

 

Share this post


Link to post
Share on other sites

Works ok for me in a quick test mission. How exactly do you detect a shot?

Share this post


Link to post
Share on other sites

I have modified the @AISS2 mod: http://www.armaholic.com/page.php?id=22892

There is file CA_HIT.sqf, which is called when unit is hit.

My current version looks like this:
 

private ["_hit","_position","_cvr_pos"];
_hit = _this select 0;
_position = position _hit;
_hit setVariable ["suppressed", true, true];
_hit setVariable ["Stime", time + ((skill _hit) * 3), true];
(group _hit) setVariable ["Stance_check", true, true];
//_cvr_pos = [(_position select 0) + random 28 - random 28,(_position select 1) + random 28 - random 28];
if (vehicle _hit isKindof "MAN" and alive _hit) then {

	systemChat "Unit hit!";
	_hit forceSpeed 10;
	_hit setBehaviour "COMBAT";
	
	//_hit domove _cvr_pos;
	//_time = time + (.5*skill (_this select 0)*.5);
	//waitUntil {getPos _hit distance _cvr_pos < 1 or _time < time};
	//sleep ((skill _supr)*.1);
	
	if ( {!isNull _hit} && {random 1 > 0.15} ) then 
	{
		//[_hit] spawn FUNC(fallDown);
		
		_hit setUnconscious true;
		
		// By Nerexis, better falldown behaviour
		[_hit] spawn {
			private["_unit"];
			_unit = _this select 0;
			hint "Unconscious AISS";
			sleep (random 5);
			_unit setUnconscious false;
			hint "Conscious";
			
			//_unit playMoveNow "amovppnemstpsraswrfldnon";
			
			if (unitPos _unit != "DOWN") then {		
				_unit setUnitPos "DOWN";
			};
			_unit forceSpeed -1;
			_unit setBehaviour "COMBAT";
		};
	};
	

};

Share this post


Link to post
Share on other sites

Old thread but directly on point.

 

After calling 'Loon setUnconscious true' on AI guy, unit ragdolls and settles and ~1 sec later, he flips onto his back with arms to the side.  At this point I would expect 'Loon setUnconscious false' to rejuvenate and get him standing again, but instead does nothing, and AI keeps laying there.  Which command(s) might I be missing?

 

Spoiler

This is my first time messing with ragdoll on living units, anyhow I (apparently) need this for my upcoming AI mod, for deaths which happen during forced movement, so they can look clean.  I don't necessarily need to get the ragdolled guys up and moving again (because I'm just killing them off once down), but need to know how to do this in order to try and overcome a couple of related obstacles.

 

On 10/19/2016 at 12:39 AM, Larrow said:

Here is a test mission showing all possible combinations via player actions for both the player and an AI, run from a dedicated server.

Self State - will set unconscious for the player, player automatically becomes conscious again after 5 seconds as being unconscious you lose the ability to run addActions

Self Server - will set unconscious for the player via a sever function, as above auto conscious after 5 seconds

AI State - will set/unset unconscious for a targeted local AI

AI Server- will set/unset unconscious for a remote targeted AI via a server function

AI Remote - will set/unset unconscious for a remote targeted AI directly via remoteExec

Join Group and Remove Group will make a targeted AI join/leave(and hand back to server) the players group so as to test changing locality

 

That looks super helpful, but unfortunately link (to your test mission) is dead.  @Larrow - Do you (or anyone) still happen to have this test mission?  Or otherwise recall how to get an AI back up standing and moving after '_unit setUnconscious true' called on him?  Many thanks.

 

Share this post


Link to post
Share on other sites

this is an old method ... 

 

use "addForce" instead

 

if (local bob) then
{
	[] spawn
	{
		bob addForce [bob vectorModelToWorld [0,-200,0], bob selectionPosition "rightfoot"];
		sleep 5;
		bob setUnconscious false;
	};
};

 

  • Like 1

Share this post


Link to post
Share on other sites
On 5/20/2023 at 1:02 AM, madrussian said:

unfortunately link (to your test mission) is dead.

Updated my links in this thread, this is old I have not confirmed these are working or any longer the correct way to handle this, I have just updated the links to the original files.

  • Thanks 1

Share this post


Link to post
Share on other sites

 

6 hours ago, Larrow said:

Updated my links in this thread, this is old I have not confirmed these are working or any longer the correct way to handle this, I have just updated the links to the original files.

 

Many thanks!  I fired it up (SP only for now)... Still seems to work great.

 

On 5/20/2023 at 5:45 AM, fn_Quiksilver said:

this is an old method ... 

 

use "addForce" instead

 

Thanks, I tried that too.  Finally got them standing back up.  (Btw - Interestingly, whether I make them unconscious via setUnconscious or addForce, it doesn't seem to change much in terms of issues I'm experiencing or overcoming them.  Surely, I didn't try everything though.)

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

×