initial commit
This commit is contained in:
45
functions/Util/fn_attachToRelative.sqf
Normal file
45
functions/Util/fn_attachToRelative.sqf
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Author: Djeeberjr (code based on killzonekid)
|
||||
|
||||
Description:
|
||||
Attaches an object realtive to its current position.
|
||||
|
||||
Parameter(s):
|
||||
0: OBJECT - to attach
|
||||
1: OBJECT - to attach to
|
||||
|
||||
*/
|
||||
|
||||
params ["_child","_parent"];
|
||||
|
||||
_vis = _parent worldToModelVisual [0,0,0];
|
||||
_vector = [
|
||||
_parent worldToModelVisual vectorDirVisual _child vectorDiff _vis,
|
||||
_parent worldToModelVisual vectorUpVisual _child vectorDiff _vis
|
||||
];
|
||||
|
||||
_child attachTo [_parent];
|
||||
_child setVectorDirAndUp _vector;
|
||||
|
||||
/*
|
||||
KK_fnc_attachToRelative = {
|
||||
private ["_o","_v"];
|
||||
_o = _this select 0;
|
||||
_v = _this call KK_fnc_vectorDirAndUpRelative;
|
||||
_o attachTo [_this select 1];
|
||||
_o setVectorDirAndUp _v;
|
||||
};
|
||||
|
||||
KK_fnc_vectorDirAndUpRelative = {
|
||||
private ["_o1","_o2","_v"];
|
||||
_o1 = _this select 0;
|
||||
_o2 = _this select 1;
|
||||
_v = _o2 worldToModelVisual [0,0,0];
|
||||
[
|
||||
_o2 worldToModelVisual vectorDirVisual _o1 vectorDiff _v,
|
||||
_o2 worldToModelVisual vectorUpVisual _o1 vectorDiff _v
|
||||
]
|
||||
};
|
||||
|
||||
[child,parent] call KK_fnc_attachToRelative;
|
||||
*/
|
||||
33
functions/Util/fn_getSyncClass.sqf
Normal file
33
functions/Util/fn_getSyncClass.sqf
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Author: Djeeberjr
|
||||
|
||||
Description:
|
||||
Get all object from synchronizedObjects with.
|
||||
|
||||
Parameter(s):
|
||||
0: OBJECT - self
|
||||
1: ARRAY or STRING - className or array of classnames
|
||||
|
||||
Return:
|
||||
ARRAY - [obj1,...]
|
||||
*/
|
||||
|
||||
params ["_self","_filter"];
|
||||
|
||||
if(typeName _filter == "STRING")then{
|
||||
_filter = [_filter];
|
||||
};
|
||||
|
||||
_returnValue = [];
|
||||
|
||||
{
|
||||
_y = _x;
|
||||
{
|
||||
if(typeOf _y == _x)then{
|
||||
_returnValue pushBack _y;
|
||||
};
|
||||
} forEach _filter;
|
||||
|
||||
} forEach synchronizedObjects _self;
|
||||
|
||||
_returnValue;
|
||||
31
functions/Util/fn_getSyncType.sqf
Normal file
31
functions/Util/fn_getSyncType.sqf
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Author: Djeeberjr
|
||||
|
||||
Description:
|
||||
Gets all object from "synchronizedObjects" by the type
|
||||
|
||||
|
||||
Parameter(s):
|
||||
0: OBJECT - most of the time: "this"
|
||||
1: STRING - type
|
||||
|
||||
Returns:
|
||||
ARRAY - [[syncedObject,parametr],...]
|
||||
*/
|
||||
|
||||
params ["_self","_type"];
|
||||
|
||||
_syncedObjects = synchronizedObjects _self;
|
||||
_returnValue = [];
|
||||
{
|
||||
_e = _x getVariable ["DLib_SType",objNull];
|
||||
if( (typeName _e ) == "ARRAY")then{
|
||||
if((_e select 0) == _type)then{
|
||||
_returnValue pushBack [_x,_e select 1];
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
} forEach _syncedObjects;
|
||||
|
||||
_returnValue;
|
||||
28
functions/Util/fn_getSyncTypeTrigger.sqf
Normal file
28
functions/Util/fn_getSyncTypeTrigger.sqf
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
Author: Djeeberjr
|
||||
|
||||
Description:
|
||||
Gets all Trigger from "synchronizedObjects" by the type. Type is set in the editor unter Text
|
||||
|
||||
|
||||
Parameter(s):
|
||||
0: OBJECT - most of the time: "this"
|
||||
1: STRING - type
|
||||
|
||||
Returns:
|
||||
ARRAY - [[syncedTrigger],...]
|
||||
*/
|
||||
params ["_self","_type"];
|
||||
|
||||
_syncedObjects = synchronizedObjects _self;
|
||||
_returnValue = [];
|
||||
{
|
||||
if(_x isKindOf "EmptyDetector")then{
|
||||
if(triggerText _x == _type)then{
|
||||
_returnValue pushBack _x;
|
||||
};
|
||||
};
|
||||
|
||||
} forEach _syncedObjects;
|
||||
|
||||
_returnValue;
|
||||
17
functions/Util/fn_holsterWeapon.sqf
Normal file
17
functions/Util/fn_holsterWeapon.sqf
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
Author: Djeeberjr
|
||||
|
||||
Description:
|
||||
Holsters the weapons for a unit.
|
||||
|
||||
Parameter(s):
|
||||
0: OBJECT - the unit
|
||||
|
||||
*/
|
||||
params ["_unit"];
|
||||
|
||||
if(DLib_isInit) then{
|
||||
[_unit,{_this action ["SwitchWeapon", _this,_this,-1];}] call DLib_fnc_runPost;
|
||||
}else{
|
||||
_unit action ["SwitchWeapon", _unit,_unit,-1];
|
||||
}
|
||||
19
functions/Util/fn_runPost.sqf
Normal file
19
functions/Util/fn_runPost.sqf
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Author: Djeeberjr
|
||||
|
||||
Description:
|
||||
Calls the function on "postInit". See https://community.bistudio.com/wiki/Initialization_Order
|
||||
|
||||
Parameters:
|
||||
0: ANY - arguments
|
||||
1: CODE
|
||||
|
||||
*/
|
||||
|
||||
params ["_args","_code"];
|
||||
|
||||
if (isNil "DLib_post_calls") then {
|
||||
DLib_post_calls = [];
|
||||
};
|
||||
|
||||
DLib_post_calls pushBack [_args,_code];
|
||||
16
functions/Util/fn_setSyncType.sqf
Normal file
16
functions/Util/fn_setSyncType.sqf
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
Author: Djeeberjr
|
||||
|
||||
Description:
|
||||
Sets the "type" of an object so you can better get it from "synchronizedObjects".
|
||||
|
||||
Parameter(s):
|
||||
0: OBJECT - most of the time: "this"
|
||||
1: STRING - type
|
||||
2 (optional): ANY - optional parameters
|
||||
*/
|
||||
|
||||
params ["_self","_type",["_params",objNull]];
|
||||
|
||||
_self setVariable ["DLib_SType",[_type,_params]];
|
||||
|
||||
Reference in New Issue
Block a user