Jump to content
doubledizz

AI holster/shoulder weapon?

Recommended Posts

I've been looking on the forums for a while for an answer to this and nothing has worked yet.

 

I'm arming some civilians with weapons (they're farmers going hunting) to add confusion to my mission, but I want the civilians to shoulder the weapons. I've tried the "Switchweapon" action, but it hasn't worked yet.

 

How do I get AI Civs to shoulder their rifles?

Share this post


Link to post
Share on other sites

Great question. 

 

And the opposite: how do we script an AI unit to holster or hide or at least lower their weapon/handgun?

Share this post


Link to post
Share on other sites
player action ["SwitchWeapon", player, player, -1];

You can use this for AI but you'll obviously have to change "player" to whatever. AI won't automatically decide to holster though, you'll have to do some scripting for that.

Share this post


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

player action ["SwitchWeapon", player, player, -1];

You can use this for AI but you'll obviously have to change "player" to whatever. AI won't automatically decide to holster though, you'll have to do some scripting for that.

Doesn't work for AI unfortunately, as far as I know there's no way to make them put rifles on the back.

AI put rifles on the back sometime during alpha, when in safe mode, no idea why this has been removed.

 

Cheers

Share this post


Link to post
Share on other sites

In init field of the AI:

this switchMove "AmovPercMstpSrasWrflDnon_AmovPercMstpSnonWnonDnon"; this disableAi "anim"

You need to "enableAI anim" again for exiting this posture.

 

But this is not the solution for a walking AI. In this case, I'm afraid, the only solution so far, is to attach a weapon on AI's shoulder. Something like:

this attachTo [bob,[-0.1,-0.2,0], "RightShoulder"]; this setVectorDirAndUp [ [0.5, 0.5, 0], [-0.5, 0.5, 0] ] ; // bob is the AI

in the init field of the weapon (object placed on ground in editor). This works for stance "up". You need to cope with other stances if needed.

 

  • Like 3

Share this post


Link to post
Share on other sites
18 minutes ago, pierremgi said:

In init field of the AI:

this switchMove "AmovPercMstpSrasWrflDnon_AmovPercMstpSnonWnonDnon"; this disableAi "anim"

 

You need to "enableAI anim" again for exiting this posture.

 

Most likely the only viable solution, if static AI are no problem.

Downside is that the AI is absolutely static and won't play idle animations, besides the occasional head movement.

 

A basic way to "free" the AI again would be:

_holster = [this] spawn {

	params ["_unit"];

 	_unit switchMove "AmovPercMstpSrasWrflDnon_AmovPercMstpSnonWnonDnon";
 	_unit disableAi "anim";

	waitUntil {behaviour _unit isEqualTo "COMBAT"};

	_unit enableAI "anim";
	true
};

Cheers

  • Like 3

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

×