Jump to content

Recommended Posts

I need some help with creating a salute script. Having AI salute you seems fairly easy to produce.  I want to create a script where you have to salute an office. I was in the army and same with the other guys I am building this map for so as a Joke I want them to have to salute an officer in the Air Base in order to continue.  Can someone help me out setting this script up? I wouldnt mind having it outcome to the office AI shooting player onsite. at the least freeze the player until they salute the AI. 

 

Thanks!

Share this post


Link to post
Share on other sites

Had something similar for SP, fixed it up to work for MP.

Should work fine for multiple players on dedicated.

 

  • Place a unit named "officer" and give it an appropriate rank in the editor.

 

initServer.sqf:

_salute = [officer] execVM "scripts\GOM\GOM_fnc_saluteOfficer.sqf";

scripts\GOM\GOM_fnc_saluteOfficer.sqf:

params [["_officer",objNull],["_forceWalk",true],["_forceWalkDistance",25],["_saluteDistance",3]];



GOM_fnc_simpleTask = {


params ["_taskDetails"];

_taskDetails params ["_taskID","_taskOwner","_taskTitle","_taskText","_taskMarker","_taskPosition"];

_create = [_taskID,_taskOwner,[_taskText,_taskTitle,_taskMarker],_taskPosition,"ASSIGNED",1,true,true,"MOVE",false] call BIS_fnc_setTask;

true

};



GOM_fnc_approachOfficer = {

	params ["_officer","_player","_saluteDistance"];

	[_player,["WeaponOnBack", _player]] remoteExec ["action",_player];

	_taskID = str _player + "001";
	_taskOwner = _player;
	_taskTitle = format ["Approach %1 %2!",[_officer,"displayName"] call BIS_fnc_rankParams,((name _officer) splitString " ")#1];
	_taskText = format ["Approach %1 %2!",[_officer,"displayName"] call BIS_fnc_rankParams,((name _officer) splitString " ")#1];
	_taskMarker = "";
	_taskPosition = getPosATL _officer;

	_task1 = [[_taskID,_taskOwner,_taskTitle,_taskText,_taskMarker,_taskPosition]] spawn GOM_fnc_simpleTask;

	waitUntil {_player distance _officer < _saluteDistance};
_salute = [_officer,_player] spawn GOM_fnc_saluteOfficer;
	[_taskID,"SUCCEEDED"] call BIS_fnc_taskSetState;


	true
};


GOM_fnc_saluteOfficer = {

	params ["_officer","_player"];

	_taskID = str _player + "002";
	_taskOwner = _player;
	_taskTitle = format ["Salute %1 %2!",[_officer,"displayName"] call BIS_fnc_rankParams,((name _officer) splitString " ")#1];
	_taskText = format ["Salute %1 %2!",[_officer,"displayName"] call BIS_fnc_rankParams,((name _officer) splitString " ")#1];
	_taskMarker = "";
	_taskPosition = getPosATL _officer;

	_task1 = [[_taskID,_taskOwner,_taskTitle,_taskText,_taskMarker,_taskPosition]] spawn GOM_fnc_simpleTask;

	waitUntil {animationstate _player in ["amovpercmstpslowwrfldnon_salute","amovpercmstpsraswpstdnon_salute","amovpercmstpsnonwnondnon_salute"]};

	[_player,false] remoteExec ["forceWalk",_player];

	[_taskID,"SUCCEEDED"] call BIS_fnc_taskSetState;


	true
};

while {alive _officer} do {

	_nearPlayers = [];
	waitUntil {
		_nearPlayers = _officer nearEntities ["Man",_forceWalkDistance] select {isPlayer _x AND !(_x getVariable ["GOM_fnc_saluteInProgress",false])};
		!alive _officer OR count _nearPlayers > 0
	};
	if (!alive _officer) exitWith {diag_log "Officer has been killed"};
	{
		[_x,true] remoteExec ["forceWalk",_x];
		_x setVariable ["GOM_fnc_saluteInProgress",true];
		_approach = [_officer,_x,_saluteDistance] spawn GOM_fnc_approachOfficer;
	} forEach _nearPlayers;


};

As an example players are forced to walk slowly when approaching the officer, and are only allowed to sprint again after saluting (not shown in the video).

You could easily adapt on it, punish players who fail to salute within n seconds to make some pushups etc.

Should get you started.

 

 

Demo mission.

 

 

Cheers

  • Like 4
  • Thanks 1

Share this post


Link to post
Share on other sites

hi! need help here. is there any way to make an AI stand and salute.? somthing like this....                                                               

[this,"SALUTE"] call BIS_fnc_ambientAnim;

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

×