-
Notifications
You must be signed in to change notification settings - Fork 148
/
fnc_init.sqf
75 lines (59 loc) · 1.9 KB
/
fnc_init.sqf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* ----------------------------------------------------------------------------
Function: CBA_fnc_init
Description:
Runs Init and InitPost event handlers on this object.
Internal use only.
Parameters:
0: Any CfgVehicles object <OBJECT>
Returns:
None
Examples:
(begin example)
[_unit] call CBA_fnc_init;
(end)
Author:
commy2
---------------------------------------------------------------------------- */
#define DEBUG_SYNCHRONOUS
#include "script_component.hpp"
params ["_this"];
if (_this call CBA_fnc_isTerrainObject) exitWith {
INFO_2("Abort init event for terrain object %1. Class: %2.",_this,typeOf _this);
};
if !(ISINITIALIZED(_this)) then {
SETINITIALIZED(_this);
// run Init
{
[_this] call _x;
} forEach (_this getVariable QGVAR(init));
// run InitPost or put on stack
if (SLX_XEH_MACHINE select 8) then {
[{
{
[_this] call _x;
} forEach (_this getVariable QGVAR(initPost));
}, _this] call CBA_fnc_execNextFrame;
} else {
GVAR(initPostStack) pushBack _this;
};
// fix for respawnVehicle clearing the object namespace
_this addEventHandler ["respawn", {
params ["_vehicle", "_wreck"];
if (ISINITIALIZED(_vehicle)) exitWith {}; // Exit if unit respawned normaly with copied variables (e.g. humans)
SETINITIALIZED(_vehicle);
{
private ["_vehicle", "_wreck"];
call _x;
} forEach (_wreck getVariable QGVAR(respawn));
{
private _varName = format [QGVAR(%1), _x];
private _events = _vehicle getVariable _varName;
if (!isNil "_events") then {
_vehicle setVariable [_varName, _events, true];
};
} forEach [XEH_EVENTS];
}];
#ifdef DEBUG_MODE_FULL
diag_log ["Init", _unit, local _unit, typeOf _unit];
#endif
};