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

AI sitting with ACE3 function

Recommended Posts

Hello,

I'm trying to get AI units to sit on chairs with ACE3 sitting function.

I got in the addon files and saw a function that should make them sitting but it's not working.

 

There is probably something else to do.

 

first I tried this:

[chair1, this] call ace_sitting_fnc_sit;

But only thing happens to the AI unit is that he changes his position to the center of the chair and then I saw this:

 

 

// Overwrite weird position, because Arma decides to set it differently based on current animation/stance...   _player switchMove "amovpknlmstpsraswrfldnon";

 

So I tried these lines:

[chair, this] call ace_sitting_fnc_sit;
this switchMove "amovpknlmstpsraswrfldnon";

But the unit still standing in the center of the chair.

 

Is there a way to use ACE3 function to make an AI unit to sit?

 

I'd apperciate your help.

Share this post


Link to post
Share on other sites

Haven't used ACE for a while, but here's a script I helped someone with the other day:

// Code based on code from MacRae and Quicksilver  
// https://forums.bistudio.com/topic/152556-simple-sitting-script-download-included/page-2#entry2811933

params ["_chair", "_unit", "_action", "_args"];

_mode = _args select 0;

// player setVariable ["QS_seated", false];
//this addaction ["Sit Down", "sit.sqf", ["sit"], 10, true, true, "", "!(player getVariable 'QS_seated')"];

switch (_mode) do {
	case ("sit"): {
		_chair setVectorUp [0,0,1];
		_unit switchMove "Crew";
		_unit setVariable ['QS_seated',true];
		_unit setPos (getPos _chair); 
		_unit setDir ((getDir _chair) - 180);
		_unit switchMove "Crew";
		standup = _unit addaction [
			"Stand Up",
			"sit.sqf",
			["stand"],
			10,
			true,
			true,
			"",
			"(_target getVariable 'QS_seated')"
		];
		_unit setPos [getPos _unit select 0, getPos _unit select 1,((getPos _unit select 2) +1)];
	};
	case ("stand"): {
		_unit setVariable ['QS_seated',false];
		_unit switchMove "";
		_unit removeAction standup;
	};

};

Share this post


Link to post
Share on other sites

Haven't used ACE for a while, but here's a script I helped someone with the other day:

params ["_chair", "_unit", "_action", "_args"];

_mode = _args select 0;

// player setVariable ["QS_seated", false];
//this addaction ["Sit Down", "sit.sqf", ["sit"], 10, true, true, "", "!(player getVariable 'QS_seated')"];

switch (_mode) do {
	case ("sit"): {
		_chair setVectorUp [0,0,1];
		_unit switchMove "Crew";
		_unit setVariable ['QS_seated',true];
		_unit setPos (getPos _chair); 
		_unit setDir ((getDir _chair) - 180);
		_unit switchMove "Crew";
		standup = _unit addaction [
			"Stand Up",
			"sit.sqf",
			["stand"],
			10,
			true,
			true,
			"",
			"(_target getVariable 'QS_seated')"
		];
		_unit setPos [getPos _unit select 0, getPos _unit select 1,((getPos _unit select 2) +1)];
	};
	case ("stand"): {
		_unit setVariable ['QS_seated',false];
		_unit switchMove "";
		_unit removeAction standup;
	};

};

Im pretty noob at scripting, can you please explain me what to do with this?

I guess its a function, so I save it for example like this? ace_fnc_sit.sqf ?

So its like this?

[seat5, this, sit, arg] call ace_fnc_sit;

Im not really sure what the arg param is.

Share this post


Link to post
Share on other sites

Save all that code to sit.sqf in your mission folder.

 

The brown comments there say how to use it.  In your player's init put:

this setVariable ["QS_seated", false];

In your init of your chair put:

this addaction ["Sit Down", "sit.sqf", ["sit"], 10, true, true, "", "!(_target getVariable 'QS_seated')"];

Then walk up to a chair and action menu 'Sit Down'.

Share this post


Link to post
Share on other sites

Save all that code to sit.sqf in your mission folder.

 

The brown comments there say how to use it.  In your player's init put:

this setVariable ["QS_seated", false];

In your init of your chair put:

this addaction ["Sit Down", "sit.sqf", ["sit"], 10, true, true, "", "!(_target getVariable 'QS_seated')"];

Then walk up to a chair and action menu 'Sit Down'.

oh thanks, but as I said.. I want an AI to sit on the chair.

Share this post


Link to post
Share on other sites

Save all that code to sit.sqf in your mission folder.

 

The brown comments there say how to use it.  In your player's init put:

this setVariable ["QS_seated", false];

In your init of your chair put:

this addaction ["Sit Down", "sit.sqf", ["sit"], 10, true, true, "", "!(_target getVariable 'QS_seated')"];

Then walk up to a chair and action menu 'Sit Down'.

what I write a script like this:

seat1 setVectorUp [0,0,1];
guest1 switchMove "Crew";
guest1 setVariable ['QS_seated',true];
guest1 setPos (getPos seat1); 
guest1 setDir ((getDir seat1) - 180);
guest1 switchMove "Crew";

and execute it by init.sqf?

Share this post


Link to post
Share on other sites

That's even easier.  In the chair's init: (where p4 is the name of your AI)

null = [this, p4] execVM "sit.sqf";

and sit.sqf:

params ["_chair", "_unit"];

_chair setVectorUp [0,0,1];
_unit switchMove "Crew";
_unit setPosWorld (getPosWorld _chair); 
_unit setDir ((getDir _chair) - 180);
_unit switchMove "Crew";

Works with all the chairs but Rattan it seems...

D4B2F4AD848625BDE52303E09A9F607E63A17CE6

Share this post


Link to post
Share on other sites

That's even easier.  In the chair's init: (where p4 is the name of your AI)

null = [this, p4] execVM "sit.sqf";

and sit.sqf:

params ["_chair", "_unit"];

_chair setVectorUp [0,0,1];
_unit switchMove "Crew";
_unit setPosWorld (getPosWorld _chair); 
_unit setDir ((getDir _chair) - 180);
_unit switchMove "Crew";

Works with all the chairs but Rattan it seems...

D4B2F4AD848625BDE52303E09A9F607E63A17CE6

Thanks, but it still doesn't work. They are just standing infront of the chair.

I've done exactly what you told me to do.

Share this post


Link to post
Share on other sites

That's even easier.  In the chair's init: (where p4 is the name of your AI)

null = [this, p4] execVM "sit.sqf";

and sit.sqf:

params ["_chair", "_unit"];

_chair setVectorUp [0,0,1];
_unit switchMove "Crew";
_unit setPosWorld (getPosWorld _chair); 
_unit setDir ((getDir _chair) - 180);
_unit switchMove "Crew";

Works with all the chairs but Rattan it seems...

D4B2F4AD848625BDE52303E09A9F607E63A17CE6

 

in the chair's init:

null = [this, brai1] execVM "scripts\sit.sqf";

sit.sqf:

params ["_chair", "_unit"];

_chair setVectorUp [0,0,1];
_unit switchMove "Crew";
_unit setPosWorld (getPosWorld _chair); 
_unit setDir ((getDir _chair) - 180);
_unit switchMove "Crew";

Share this post


Link to post
Share on other sites

solved it by using the ACE3 function.

 

[chair_name, unit_name] call ace_sitting_fnc_sit;

 

executed from InitServer.sqf since switchMove doesn't work from init fields.

Share this post


Link to post
Share on other sites

×