Itsemurhapommiskripti

Post Reply
User avatar
Anatooli
Posts: 164
Joined: 26 Jul 2013, 18:15

Itsemurhapommiskripti

Post by Anatooli »

Tästä oli lyhyt ketju, jonka siirsin arkistoon.

ACE:n interaction menun kautta toimiva skripti itsemurhapommien asettamiseen ja laukaisemiseen. Pelaaja pystyy köyttämään itseensä kiinni kolme demochargea tai yhden satchelchargen olettaen että räjähteet löytyvät pelaajan inventorysta.

Mahdolliset laukaisutavat:
  • Toisen pelaajan toimesta kännykällä:
    Interaction menu: "Attach cellphone detonator" --> Normaalisti ACE:n kännykällä soittaminen
  • Deadmanswitch:
    Self-interaction menu: "Attach deadmanswitch detonator" --> menetä henkesi
  • Manuaalisesti clackerilla tai deadmanswitchillä:
    Self-interaction menu: "Attach deadmanswitch / clacker detonator" --> Self-interaction menu: "Detonate"
  • Ammuttaessa räjähteisiin
Laukaisuvaihtoehdot vaativat että pelaajalta löytyy inventorystä asianmukainen laukaisuväline. Räjähteet voi purkaa toisen pelaajan yltä ACE:n defuse kitillä ja itselle laitetut räjähteet voi poistaa yltään self-interaction menun kautta.

Skriptin alusta löytyvän enable_while_surrendering muuttujan arvon vaihtamalla false:ksi toiminnot kuten räjähteiden räjäyttäminen estetään yksikön antautuessa. Oletuksena kyseiset toiminnot ovat sallittuja antautuessa.

init.sqf:

Code: Select all

execVM "kaboom.sqf";
kaboom.sqf:

Code: Select all

waitUntil {!isNull player};

enable_while_surrendering = true; // Change to false to disable actions during surrendering

fn_attach_explosives_proxy = {
	_target = _this select 0;
	_bombs =  _target getVariable "suicidebombs";
	_proxy = "Sign_Sphere10cm_F" createVehicle position _target;
	_proxy setObjectTextureGlobal [0,'#(argb,8,8,3)color(0,0,0,0)'];
	_proxy attachTo [_target, [0, 0.3, 0.25], "Pelvis"];

	waitUntil {sleep 1; {alive _x} count _bombs == 0};
	{deleteVehicle _x} forEach (_bombs + [_proxy]);
	_target setVariable ["suicidebombs", nil, true];
};

fn_attach_demoblocks = {
	_target = _this select 0;
	_demo = "DemoCharge_Remote_Ammo_Scripted";
	for "_i" from 1 to 3 do {_target removeMagazine "DemoCharge_Remote_Mag"};
	_expl1 = _demo createVehicle position _target;
	_expl1 attachTo [_target, [-0.1, 0.15, 0.15], "Pelvis"];
	[_expl1, [ [0.5, 0.5, 0], [-0.5, 0.5, 0] ]] remoteExec ["setVectorDirAndUp"];
	_expl2 = _demo createVehicle position _target;
	_expl2 attachTo [_target, [0, 0.2, 0.15], "Pelvis"];
	[_expl2, [ [1, 0, 0], [0, 1, 0] ]] remoteExec ["setVectorDirAndUp"];
	_expl3 = _demo createVehicle position _target;
	_expl3 attachTo [_target, [0.1, 0.15, 0.15], "Pelvis"];
	[_expl3, [ [0.5, -0.5, 0], [0.5, 0.5, 0] ]] remoteExec ["setVectorDirAndUp"];
	_target setVariable ["suicidebombs", [_expl1, _expl2, _expl3], true];

	[_target] spawn fn_attach_explosives_proxy;
};

fn_attach_satchelcharge = {
	_target = _this select 0;
	_target removeMagazine "SatchelCharge_Remote_Mag";
	_expl = "SatchelCharge_Remote_Ammo_Scripted" createVehicle position _target;
	_expl attachTo [_target, [0, 0.2, 0.25], "Pelvis"];
	[_expl, [ [1, 0, 0], [0, 1, 0] ]] remoteExec ["setVectorDirAndUp"];
	_target setVariable ["suicidebombs", [_expl], true];

	[_target] spawn fn_attach_explosives_proxy;
};

fn_detach_explosives = {
	_victim = _this select 0;
	_bombs = _victim getVariable "suicidebombs";
	_loot = "groundweaponholder" createVehicle (getpos _victim);
	_loot setPosATL getPosATL _victim;
	_type_old = typeOf (_bombs select 0);
	_type_new = (([_type_old, "Ammo_Scripted"] call CBA_fnc_split) select 0) + "Mag";
	_loot addMagazineCargoGlobal [_type_new, count _bombs];
	{deleteVehicle _x} forEach _bombs;

	{_loot addItemCargoGlobal [_x, 1]} forEach (_victim getVariable ["suicidetriggers", []]);
	_victim setVariable ["suicidetriggers", nil];
};

fn_attach_deadmanswitch = {
	_victim = _this select 0;
	_bombs = _victim getVariable "suicidebombs";
	[_victim, "ACE_DeadManSwitch"] call fn_add_suicide_trigger;
	waitUntil {
		sleep 1;
		!alive _victim && "ACE_DeadManSwitch" in (_victim getVariable ["suicidetriggers", []])
	};
	{_x setDamage 1} forEach _bombs;
};

fn_add_suicide_trigger = {
	params ["_victim", "_trigger"];
	_triggers =  _victim getVariable ["suicidetriggers", []];
	if (!(_trigger in _triggers)) then {
		_victim setVariable ["suicidetriggers", _triggers + [_trigger]];
		_victim removeItem _trigger;
	};
};

fn_remove_suicide_trigger = {
	params ["_victim", "_trigger"];
	_triggers =  _victim getVariable ["suicidetriggers", []];
	if ((_trigger in _triggers)) then {
		_victim setVariable ["suicidetriggers", _triggers - [_trigger]];
		_victim addItem _trigger;
	};
};

_attach_detonator_phone_action = [
	"phone", "Attach cellphone detonator", "",
	{
		_victim = attachedTo (_this select 0);
		_bombs = _victim getVariable "suicidebombs";
		_bomb = _bombs select (floor random count _bombs);
		[player, _bomb, typeOf _bomb] call ACE_Explosives_fnc_addCellphoneIED;
	},{!isNil {attachedTo (_this select 0) getVariable "suicidebombs"} && "ACE_Cellphone" in items player}
] call ace_interact_menu_fnc_createAction;
["Sign_Sphere10cm_F", 0, ["ACE_MainActions"], _attach_detonator_phone_action] call ace_interact_menu_fnc_addActionToClass;

_attach_detonator_deadmanswitch_action = [
	"deadmanswitch", "Attach deadmanswitch detonator", "",
	{ [_this select 0] spawn fn_attach_deadmanswitch },
	{
		!isNil {player getVariable "suicidebombs"} &&
		"ACE_DeadManSwitch" in items player &&
		!("ACE_DeadManSwitch" in (player getVariable ["suicidetriggers", []])) &&
		(enable_while_surrendering || animationState player != "ace_amovpercmstpssurwnondnon")
	}
] call ace_interact_menu_fnc_createAction;
[typeOf player, 1, ["ACE_SelfActions"], _attach_detonator_deadmanswitch_action] call ace_interact_menu_fnc_addActionToClass;

_detach_detonator_deadmanswitch_action = [
	"deadmanswitch", "Detach deadmanswitch detonator", "",
	{ [player, "ACE_DeadManSwitch"] call fn_remove_suicide_trigger },
	{
		!isNil {player getVariable "suicidebombs"} &&
		("ACE_DeadManSwitch" in (player getVariable ["suicidetriggers", []])) &&
		(enable_while_surrendering || animationState player != "ace_amovpercmstpssurwnondnon")
	}
] call ace_interact_menu_fnc_createAction;
[typeOf player, 1, ["ACE_SelfActions"], _detach_detonator_deadmanswitch_action] call ace_interact_menu_fnc_addActionToClass;

_attach_detonator_clacker_action = [
	"clacker", "Attach M57 clacker detonator", "",
	{ [player, "ACE_Clacker"] call fn_add_suicide_trigger },
	{
		!isNil {player getVariable "suicidebombs"} &&
		"ACE_Clacker" in items player &&
		!("ACE_Clacker" in (player getVariable ["suicidetriggers", []])) &&
		(enable_while_surrendering || animationState player != "ace_amovpercmstpssurwnondnon")
	}
] call ace_interact_menu_fnc_createAction;
[typeOf player, 1, ["ACE_SelfActions"], _attach_detonator_clacker_action] call ace_interact_menu_fnc_addActionToClass;

_attach_detonator_clackerm26_action = [
	"clackerm26", "Attach M26 clacker detonator", "",
	{ [player, "ACE_M26_Clacker"] call fn_add_suicide_trigger },
	{
		!isNil {player getVariable "suicidebombs"} &&
		"ACE_M26_Clacker" in items player &&
		!("ACE_M26_Clacker" in (player getVariable ["suicidetriggers", []])) &&
		(enable_while_surrendering || animationState player != "ace_amovpercmstpssurwnondnon")
	}
] call ace_interact_menu_fnc_createAction;
[typeOf player, 1, ["ACE_SelfActions"], _attach_detonator_clackerm26_action] call ace_interact_menu_fnc_addActionToClass;

_detonate_manual_action = [
	"manualdetonate", "Detonate yourself", "",
	{
		_bombs =  player getVariable "suicidebombs";
		{_x setDamage 1} forEach _bombs;
	},
	{
		!isNil {player getVariable "suicidebombs"} &&
		{
			(_x in (player getVariable ["suicidetriggers", []]))
		} count ["ACE_M26_Clacker", "ACE_Clacker", "ACE_DeadManSwitch"] > 0 &&
		(enable_while_surrendering || animationState player != "ace_amovpercmstpssurwnondnon")
	}
] call ace_interact_menu_fnc_createAction;
[typeOf player, 1, ["ACE_SelfActions"], _detonate_manual_action] call ace_interact_menu_fnc_addActionToClass;

_attach_demoblocks_action = [
	"demoblocks", "Attach demoblocks to yourself", "",
	{
		player playMove "ainvpercmstpsraswrfldnon";
		[
			5, [player], {(_this select 0) call fn_attach_demoblocks; hint "Explosives attached";},
			{hint "Canceled action"}, "Attaching explosives"
		] call ace_common_fnc_progressBar;
	},
	{
		isNil {player getVariable "suicidebombs"} &&
		{_x == "DemoCharge_Remote_Mag"} count magazines player >= 3 &&
		(enable_while_surrendering || animationState player != "ace_amovpercmstpssurwnondnon")
	}
] call ace_interact_menu_fnc_createAction;
[typeOf player, 1, ["ACE_SelfActions"], _attach_demoblocks_action] call ace_interact_menu_fnc_addActionToClass;

_attach_satchelcharge_action = [
	"satchelcharge", "Attach a satchelcharge to yourself", "",
	{
		player playMove "ainvpercmstpsraswrfldnon";
		[
			5, [player], {(_this select 0) call fn_attach_satchelcharge; hint "Explosives attached";},
			{hint "Canceled action"}, "Attaching explosives"
		] call ace_common_fnc_progressBar;
	},
	{
		isNil {player getVariable "suicidebombs"} &&
		"SatchelCharge_Remote_Mag" in magazines player &&
		(enable_while_surrendering || animationState player != "ace_amovpercmstpssurwnondnon")
	}
] call ace_interact_menu_fnc_createAction;
[typeOf player, 1, ["ACE_SelfActions"], _attach_satchelcharge_action] call ace_interact_menu_fnc_addActionToClass;

_detach_explosives_action = [
	"detachexplosives", "Detach explosives from yourself", "",
	{
		player playMove "ainvpercmstpsraswrfldnon";
		[
			5, [player], {(_this select 0) call fn_detach_explosives; hint "Explosives detached";},
			{hint "Canceled action"}, "Detaching explosives"
		] call ace_common_fnc_progressBar;
	},
	{
		count (player getVariable ["suicidebombs",[]]) > 0 &&
		(enable_while_surrendering || animationState player != "ace_amovpercmstpssurwnondnon")
	}
] call ace_interact_menu_fnc_createAction;
[typeOf player, 1, ["ACE_SelfActions"], _detach_explosives_action] call ace_interact_menu_fnc_addActionToClass;
Semper ubi sub ubi
Post Reply