Skip to content
This repository has been archived by the owner on Oct 30, 2021. It is now read-only.

Commit

Permalink
initial import
Browse files Browse the repository at this point in the history
Signed-off-by: freghar <[email protected]>
  • Loading branch information
freghar committed May 17, 2016
1 parent 1e3b00c commit bed7edc
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 0 deletions.
4 changes: 4 additions & 0 deletions COPYING.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Copyright 2016 Freghar (https://forums.bistudio.com/user/1115862-freghar/)

Content licensed under CC BY 4.0
https://creativecommons.org/licenses/by/4.0/
103 changes: 103 additions & 0 deletions addons/chestpack/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
class CfgPatches
{
class Chestpack
{
units[] = {};
weapons[] = {};
//requiredAddons[] = {};
requiredAddons[] = {"ace_interact_menu"};
};
};

class CfgVehicles {
class Man;
class CAManBase : Man {
class ACE_SelfActions {
class ACE_Equipment {
class Chestpack_onChest {
displayName = "Backpack on Chest";
statement = "[(_this select 0), ((_this select 0) call Chestpack_fnc_removeBackpack)] call Chestpack_fnc_setChestpack;";
condition = "isNil {(_this select 0) getVariable ""Chestpack_pack""} && !isNull unitBackpack (_this select 0)";
exceptions[] = {"isNotInside", "isNotSwimming"};
};
class Chestpack_onBack {
displayName = "Chestpack on Back";
statement = "[(_this select 0), ((_this select 0) call Chestpack_fnc_removeChestpack)] call Chestpack_fnc_setBackpack;";
condition = "!isNil {(_this select 0) getVariable ""Chestpack_pack""} && isNull unitBackpack (_this select 0)";
exceptions[] = {"isNotInside", "isNotSwimming"};
};
/*class Chestpack_onGround {
displayName = "Chestpack on Ground";
statement = "call Chestpack_onGround";
condition = "!isNil {(_this select 0) getVariable ""Chestpack_pack""}";
exceptions[] = {"isNotInside", "isNotSwimming"};
};*/
class Chestpack_swapPacks {
displayName = "Swap Chest/Back packs";
statement = "private _back = (_this select 0) call Chestpack_fnc_removeBackpack; [(_this select 0), ((_this select 0) call Chestpack_fnc_removeChestpack)] call Chestpack_fnc_setBackpack; [(_this select 0), _back] call Chestpack_fnc_setChestpack;";
condition = "!isNil {(_this select 0) getVariable ""Chestpack_pack""} && !isNull unitBackpack (_this select 0)";
exceptions[] = {"isNotInside", "isNotSwimming"};
};
};
};
class ACE_Actions {
class ACE_MainActions {
/* corpse or unconscious */
class Chestpack_onChest {
displayName = "Backpack on Chest";
statement = "[(_this select 0), ((_this select 0) call Chestpack_fnc_removeBackpack)] call Chestpack_fnc_setChestpack;";
condition = "isNil {(_this select 0) getVariable ""Chestpack_pack""} && !isNull unitBackpack (_this select 0) && {!alive (_this select 0) || (_this select 0) getVariable [""ACE_isUnconscious"", false]}";
exceptions[] = {"isNotInside", "isNotSwimming"};
};
class Chestpack_onBack {
displayName = "Chestpack on Back";
statement = "[(_this select 0), ((_this select 0) call Chestpack_fnc_removeChestpack)] call Chestpack_fnc_setBackpack;";
condition = "!isNil {(_this select 0) getVariable ""Chestpack_pack""} && isNull unitBackpack (_this select 0) && {!alive (_this select 0) || (_this select 0) getVariable [""ACE_isUnconscious"", false]}";
exceptions[] = {"isNotInside", "isNotSwimming"};
};
/*class Chestpack_onGround {
displayName = "Chestpack on Ground";
statement = "call Chestpack_onGround";
condition = "!isNil {(_this select 0) getVariable ""Chestpack_pack""} && {!alive (_this select 0) || (_this select 0) getVariable [""ACE_isUnconscious"", false]}";
exceptions[] = {"isNotInside", "isNotSwimming"};
};*/
class Chestpack_swapPacks {
displayName = "Swap Chest/Back packs";
statement = "private _back = (_this select 0) call Chestpack_fnc_removeBackpack; [(_this select 0), ((_this select 0) call Chestpack_fnc_removeChestpack)] call Chestpack_fnc_setBackpack; [(_this select 0), _back] call Chestpack_fnc_setChestpack;";
condition = "!isNil {(_this select 0) getVariable ""Chestpack_pack""} && !isNull unitBackpack (_this select 0) && {!alive (_this select 0) || (_this select 0) getVariable [""ACE_isUnconscious"", false]}";
exceptions[] = {"isNotInside", "isNotSwimming"};
};
};
};
/* vanilla Actions */
/*class UserActions {
class Chestpack_onChest {};
class Chestpack_onBack {};
};*/
};
/*class Reammobox;
class Bag_base : Reammobox {
class ACE_Actions {
class ACE_MainActions {
class Chestpack_onChest {
displayName = "Groundpack on Chest";
statement = "call Chestpack_fromGround";
condition = "!isNil {(_this select 1) getVariable ""Chestpack_pack""}";
};
};
};
};*/
};

class CfgFunctions {
class Chestpack {
class All {
file = "\chestpack\functions";
//class init { postInit = 1; };
class setChestpack;
class removeChestpack;
class setBackpack;
class removeBackpack;
};
};
};
12 changes: 12 additions & 0 deletions addons/chestpack/functions/fn_removeBackpack.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* delete the backpack of '_unit', returning its class and contents,
* as getUnitLoadout provides it */

params ["_unit"];

private _packinfo = getUnitLoadout _unit;
if (count _packinfo > 0) then {
/* https://community.bistudio.com/wiki/Talk:getUnitLoadout */
_packinfo = _packinfo select 5;
removeBackpackGlobal _unit;
};
_packinfo;
13 changes: 13 additions & 0 deletions addons/chestpack/functions/fn_removeChestpack.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* delete the chestpack of '_unit', returning its class and contents,
* as getUnitLoadout provides it */

params ["_unit"];

private _chestpack = _unit getVariable "Chestpack_pack";
if (isNil "_chestpack") exitWith {};
_unit setVariable ["Chestpack_pack", nil, true];
_unit forceWalk false;

_chestpack params ["_obj", "_packinfo"];
deleteVehicle _obj;
_packinfo;
9 changes: 9 additions & 0 deletions addons/chestpack/functions/fn_setBackpack.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* add backpack to '_unit', according to getUnitLoadout-formatted
* '_backinfo' (backpack array), saved by fn_delBackpack */

params ["_unit", "_packinfo"];

private _loadout = getUnitLoadout _unit;
/* https://community.bistudio.com/wiki/Talk:getUnitLoadout */
_loadout set [5, _packinfo];
_unit setUnitLoadout _loadout;
26 changes: 26 additions & 0 deletions addons/chestpack/functions/fn_setChestpack.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* add chestpack to '_unit', according to getUnitLoadout-formatted
* '_backinfo' (backpack array), saved by fn_delBackpack */

params ["_unit", "_packinfo"];
_packinfo params ["_packclass"];

/* sometimes has .p3d, sometimes doesn't, starts with leading \, etc. */
//getText (configFile >> "CfgVehicles" >> _packclass >> "model");

private _temp = _packclass createVehicleLocal [0,0,0];
private _model = (getModelInfo _temp) select 1;
deleteVehicle _temp;

private _obj = createSimpleObject [_model, [0,0,0]];
_obj attachTo [_unit, [0.02,-0.04,-0.3], "pelvis"];

_unit forceWalk true;
_unit setVariable ["Chestpack_pack", [_obj, _packinfo], true];


/*
obj = createVehicle ["GroundWeaponHolder", player, [], 0, "CAN_COLLIDE"];
obj addBackpackCargoGlobal [(typeof unitbackpack player), 1];
obj attachTo [player, [0.02,-0.04,-0.3], "pelvis"];
obj setVectorUp [0,1,0];
*/
4 changes: 4 additions & 0 deletions mod.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name = "Chestpack";
author = "Freghar";
hideName = 0;
overview = "Yet another mod for moving backpacks on one's chest/belly.";

0 comments on commit bed7edc

Please sign in to comment.