Jump to content
pognivet

Forcing a player to do an animation without it being cancelled

Recommended Posts

I'm making a Cold War mission where Americans are attacking a small Soviet base. There's a USSR flag in the base. I want it so that after that flag is lowered and an American flag is raised on the same flagpole the mission concludes.

 

I don't want players to just sprint past the flagpole and hit the addaction to sort of glitch out the mission and let them win.

 

The raising and lowering of the flagpole and changing the flag texture when its lowered is working, but I wanted whoever is manipulating the flagpole to have some sort of animation like "repair vehicle while standing" that they can't exit out of until the American flag is fully raised. This prevents the person lowering the flagpole from fighting in combat simultaneously and makes it so you want the area to be secure before taking 30 seconds to hoist the thing down.

 

The only problem is that I'm having difficulty forcing a player into an animation state and holding them there for a set period of time (from the time they start pulling the flag down until the time where the new one is raised). I've tried many commands and techniques but the player is still able to move around and even run far away from the flagpole as its being brought down or up.

 

Long story short: is there a simple way to force a player to play an animation, making them unable to move or escape the animation, until they can be manually reset to normal at the end of the script?

 

I know there must be a simple way to do this, but for the life of me I can't get it to function properly.

 

Any help would be appreciated.

 

Thanks.

Share this post


Link to post
Share on other sites

disable movement keyboard input for anim length? ithink it should work through displayAddEventHandler keydown , check movement keys through  actionKeys

Share this post


Link to post
Share on other sites

disableUserInput

 

MAKE SURE TO TURN IT BACK ON lol Not that I personally have any experience with testing a script and forgetting that part :sarcasm:

  • Haha 2

Share this post


Link to post
Share on other sites

Modified version of another script of mine:

_flag = this;
_afterCommand = {};

_fncOwnFlag = {
	params ["_winSide"];
	_flagPath = "\a3\data_f\flags\%1.paa";
	_fileFlag = switch _winSide do {
		case west: {"flag_nato_co"};
		case east: {"flag_csat_co"};
		case independent: {"flag_aaf_co"};
		default {"flag_white_co"}
	};
	format [_flagPath,_fileFlag];
};
_actionParams = ["_flag", "_caller", "_actionId", "_arguments"];

_flag setflagAnimationPhase 1;
_flag setFlagTexture (civilian call _fncOwnFlag);
_flag setVariable ["TER_flagSide",civilian];
_icon = "\a3\ui_f\data\igui\cfg\holdactions\holdaction_takeoff2_ca.paa";
_duration = 10;
_addID = [_flag, "Capture Flag", _icon, _icon,
	"_target getVariable [""TER_flagSide"",civilian] != side _this",
	"true",
	{
		params ["_flag", "_caller", "_actionId", "_arguments"];
		_caller playMove "acts_millerChopper_loop";
	},
	{
		params ["_flag", "_caller", "_actionId", "_arguments","_progress","_maxProgress"];
		_arguments params ["_actionParams","_fncOwnFlag","_afterCommand"];
		_relProgress = _progress/_maxProgress;
		if (_relProgress < 0.5) then {
			_flag setFlagAnimationPhase (1-(2*_relProgress));
		} else {
			if (_relProgress == 0.5) then {_flag setFlagTexture (side _caller call _fncOwnFlag)};
			_flag setFlagAnimationPhase ((2*_relProgress)-1);
		};
	},
	{
		params ["_flag", "_caller", "_actionId", "_arguments"];
		_arguments params ["_actionParams","_fncOwnFlag","_afterCommand"];
		_flag setVariable ["TER_flagSide",side _caller];
		[] call _afterCommand;
		[_caller,""] remoteExec ["switchMove",0];
	},
	{
		params ["_flag", "_caller", "_actionId", "_arguments"];
		_arguments params ["_actionParams","_fncOwnFlag","_afterCommand"];
		_flag setFlagAnimationPhase 1;
		_side = _flag getVariable ["TER_flagSide",civilian];
		_flag setFlagTexture (_side call _fncOwnFlag);
		[_caller,""] remoteExec ["switchMove",0];
	},
[_actionParams,_fncOwnFlag,_afterCommand], _duration, 1.5, false] call BIS_fnc_holdActionAdd;

_addID

 

Add this to the init field of the flag. You can also use another animation  by modifying this line:
 

_caller playMove "acts_millerChopper_loop";

Haven't tested in MP but I am confident that it will work.

  • Like 2

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

×