Page 1 of 1

Script: Disarm and Surrender

Posted: Wed Jan 23, 2013 9:02 pm
by Black Mamba
Reading those fantastic tales of prisoner taking (and executing) in the last AAR just made me want to finish this quick script solution for disarming wounded enemies and surrendering.
This gives anyone the ability to disarm a wounded enemy, so that he can then be healed safely, and, why not, used as a human shield. It can also give the ability to anyone to surrender, by putting your arms on your head and dropping all of your weapons to the floor.
I have found no use to it yet, but maybe one of the mission makers around will.

This script pack is ready to be included in any mission and is designed to be used in adversarials.
All three scripts are to be put in a Custom folder, at the root of your mission.

BM_disarmInit.sqf

Code: Select all

_isDisarmEnabled = _this select 0;
_isSurrenderEnabled = _this select 1;
BM_Disarmed = "";

if (_isDisarmEnabled) then {
	if (!isDedicated) then {
		{
			if (side _x != side player) then {
				_act = _x addAction ["Search/Disarm", "Custom\BM_disarm.sqf", [], 6, false, true, "", "lifeState _target == ""UNCONSCIOUS"""];
			};
		} forEach playableUnits;
		BM_fn_disarm = {
			_unit = _this;
			{_unit action ["dropWeapon", _unit, _x] } forEach (weapons _unit);
			{_unit action ["DropMagazine", _unit, _x] } forEach (magazines _unit);
		};
		"BM_Disarmed" addPublicVariableEventHandler {
			_unit = _this select 1;
			_unit call BM_fn_disarm;
			BM_Disarmed = "";
		};
	};
	if (isServer) then {
		"BM_Disarmed" addPublicVariableEventHandler {
			_unit = _this select 1;
			_owner = owner _unit;
			_owner publicVariableClient "BM_Disarmed";
			BM_Disarmed = "";
		};
	};
};

if (_isSurrenderEnabled && !isDedicated) then {
	player addAction ["Surrender", "Custom\BM_surrender.sqf", [], 3, false, true];
};
BM_disarm.sqf

Code: Select all

private ["_unit"];

_unit = _this select 0;
if (local _unit) then {
	{_unit action ["dropWeapon", _unit, _x] } forEach (weapons _unit);
	{_unit action ["DropMagazine", _unit, _x] } forEach (magazines _unit);
} else {
	if (isServer) then {
		_owner = owner _unit;
		BM_Disarmed = _unit;
		_owner publicVariableClient "BM_Disarmed";
		BM_Disarmed = "";
	} else {
		BM_Disarmed = _unit;
		publicVariableServer "BM_Disarmed";
		BM_Disarmed = "";
	};
};
BM_surrender.sqf

Code: Select all

{player action ["dropWeapon", player, _x] } forEach (weapons player);
{player action ["DropMagazine", player, _x] } forEach (magazines player);
player playmove "AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon";
This would be called in the init.sqf, the first parameter activates the disarming system, the second the surrender system.

Code: Select all

[true, true] execVM "Custom\BM_disarmInit.sqf";
This would launch both systems.

Re: Script: Disarm and Surrender

Posted: Thu Jan 24, 2013 12:40 am
by Anvilfolk
Ooooooooooooh, this is great :)

Is there any sort of tutorial on this stuff? I would be interested in trying some of it out.

Re: Script: Disarm and Surrender

Posted: Thu Jan 24, 2013 8:35 am
by wolfenswan
Wrong forum mamba :P Moved.
Anvilfolk wrote:Ooooooooooooh, this is great :)

Is there any sort of tutorial on this stuff? I would be interested in trying some of it out.
You'd probably want to get started by getting comfortable with the Editor (it's fairly well documented on the BI Wiki) and the F2 Mission Framework. For the latter two stubs exist that are meant to ease new mission makers into creating missions.

Check the stickies in this forum for links on how to get started.

Re: Script: Disarm and Surrender

Posted: Thu Jan 24, 2013 12:35 pm
by Black Mamba
Aaaaww. Totally forgot about that sub-forum.

Anvil, if you wanna start scripting a bit, yeah, try and get comfy with the editor first. After that, scripting can be learned pretty quickly, depending whether you have previous experience with coding or not (took me around three months to get to a decent level, but I did have quite a lot of experience programming math stuff, though). After that, the wiki is your friend, and you can get some help on the BI Forums or here.

Re: Script: Disarm and Surrender

Posted: Thu Jan 24, 2013 1:31 pm
by Anvilfolk
Thanks for the info! I checked the wiki, which I remember being mostly just a listing of all available functions. Given how much modding has contributed to the longevity of the ArmA series, I'm actually surprised there isn't something easier to get into than that. Ah well, I might dig into it if I find the time :)

Thanks again!