Jump to content
Sign in to follow this  
D. Patterson

Force lowered weapon?

Recommended Posts

Is there a way to force a player to lower their weapon, and keep it that way, until it's unforced?

Share this post


Link to post
Share on other sites

I believe setBehavior "SAFE" can mimic the effect you are looking for. Units should have their weapons lowered until they spot an enemy or get fired upon.

EDIT: if that doesn't work you could use:

while {true} do
{
waitUntil {behavior GROUP != "safe"};
GROUP setBehavior "SAFE";
};

Might do the trick

Share this post


Link to post
Share on other sites

Im trying to make it so the player cannot raise their weapon. The weapononback allows the player to raise their weapon immediately after.

Share this post


Link to post
Share on other sites

Yup. I posted an action to lower your weapon. You'd need to check if the weapon isn't lowered and activate the action on the player object if it's true. Something like a loop or stacked EH onEachFrame.

Untested. Add sleeps where you see fit (except in stacked EH). Or not.. W/e.

loop #1

if (isDedicated) exitWith {};
waitUntil {!(isNull player)};

while {true} do {
waitUntil {!(weaponLowered player)};
player action ["WeaponOnBack", player];
};

loop#2

if (isDedicated) exitWith {};
waitUntil {!(isNull player)};

while {true} do {
if (!(weaponLowered player)) then {
	player action ["WeaponOnBack", player];
};
};

stacked EH

if (isDedicated) exitWith {};
waitUntil {!(isNull player)};

["WOBID", "onEachFrame", { 
if (!(weaponLowered player)) then {
	player action ["WeaponOnBack", player];
};
}] call BIS_fnc_addStackedEventHandler;

---------- Post added at 01:18 ---------- Previous post was at 00:02 ----------

Alternatively, I just noticed there are animation eventhandlers. I'm unfamiliar with these particular Ehs and animations in general, but maybe something like this could work :confused:

if (isDedicated) exitWith {};
waitUntil {!(isNull player)};

player addEventhandler ["animDone", { // also available: "AnimStateChanged", "AnimChanged"
   if (!(weaponLowered player)) then {
       player action ["WeaponOnBack", player];
   };
}];  

Edited by Iceman77
  • Like 1

Share this post


Link to post
Share on other sites

I'm not sure if the anim-Events trigger for "gestures". I think they're a separate system.

Share this post


Link to post
Share on other sites

I tried something similar to Iceman77's last bit of code a while ago and ended up with AI just sliding along the ground in a frozen stance. I would dearly love a way to have squad AI not constantly run around with raised weapons. Probably needs some kind of FSM editing, which I have no smarts with.

Share this post


Link to post
Share on other sites

I know mate. I wasn't dissing your code ideas, merely saying that using eventhandlers to switch between animation states can lead to player/AI apparently not animating at all.

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
Sign in to follow this  

×