Skip to content

Commit a375d34

Browse files
committed
ArsenalsInit: Initialise arsenals (markers/trashcan init) during server init.
1 parent 4f38f1d commit a375d34

4 files changed

Lines changed: 91 additions & 33 deletions

File tree

mission/config/functions.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class CfgFunctions
3737
postinit = 1;
3838
};
3939
class adv_revive_params {};
40+
class arsenals_init {};
4041
class init_mission_handlers {};
4142
};
4243

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
File: fn_arsenals_init.sqf
3+
Author: Savage Game Design
4+
Public: No
5+
6+
Description:
7+
Sets up arsenals with Arsenal map markers
8+
and finds nearby trashcans to initialise when player joins
9+
10+
Parameter(s): none
11+
12+
Returns: nothing
13+
14+
Example(s):
15+
Not called directly
16+
*/
17+
18+
19+
diag_log "Loading arsenals ...";
20+
21+
private _allLogics = allMissionObjects "Logic";
22+
23+
private _wlArsenalLogicIdx =_allLogics findIf {
24+
private _allVars = allVariables _x;
25+
// all three of these are present as non-BI variables in the WL Arsenals module
26+
// found with `(allMissionObjects "Logic") apply { allVariables _x }`
27+
"scope" in _allVars && "rank" in _allVars && "side" in _allVars;
28+
};
29+
30+
private _arsenals = synchronizedObjects (_allLogics select _wlArsenalLogicIdx);
31+
32+
{
33+
// store an array of nearby trashcans for clients to
34+
// initialise the 'Clean Up' action on server join
35+
private _trash_cans = (nearestObjects [_x, [], 10, true]) select {
36+
typeOf _x isEqualTo "Land_vn_object_trashcan_01"
37+
};
38+
_x setVariable ["trashcans", _trash_cans];
39+
40+
// create map markers for arsenal objects
41+
_marker = createMarkerLocal [format["vn_mf_arsenal_", _forEachIndex], _x];
42+
_marker setMarkerTextLocal "Arsenal";
43+
_marker setMarkerTypeLocal "mil_dot";
44+
_marker setMarkerColorLocal "ColorPink";
45+
_marker setMarkerAlpha 1;
46+
} forEach _arsenals;
47+
48+
missionNamespace setVariable ["vn_mf_arsenals", _arsenals];
49+
diag_log format ["Loaded %1 arsenals.", _arsenals];
50+
true;
Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,45 @@
11
/*
2-
File: fn_arsenal_trash_cleanup_init.sqf
3-
Author: Savage Game Design
4-
Public: Yes
2+
File: fn_arsenal_trash_cleanup_init.sqf
3+
Author: Savage Game Design
4+
Public: Yes
55
6-
Description:
7-
Called to initialise the trashcans on the map near arsenals.
6+
Description:
7+
Called to initialise the trashcans on the map near arsenals.
88
9-
Parameter(s):
10-
None
9+
Parameter(s):
10+
None
1111
12-
Returns:
13-
None
12+
Returns:
13+
None
1414
15-
Example(s):
16-
call vn_mf_fnc_arsenal_trash_cleanup_init;
15+
Example(s):
16+
call vn_mf_fnc_arsenal_trash_cleanup_init;
1717
*/
1818

19-
private _arsenals = allMapMarkers select {_x find "arsenal" isEqualTo 0};
19+
private _arsenals = missionNamespace getVariable ["vn_mf_arsenals", []];
2020

21-
{
22-
private _trashCan = missionNamespace getVariable [format["arsenal_cleanup_%1",_forEachIndex], objNull];
23-
_trashCan addAction
24-
[
25-
"Clean Up",
26-
{
27-
params ["_target", "_caller", "_actionId", "_arguments"];
28-
["arsenalcleanup", [_target]] call para_c_fnc_call_on_server;
29-
},
30-
nil,
31-
1.5,
32-
true,
33-
true,
34-
"",
35-
"true",
36-
5,
37-
false,
38-
"",
39-
""
40-
];
41-
} forEach _arsenals;
21+
_arsenals apply {
22+
private _trashcans = _x getVariable ["trashcans", []];
23+
_trashcans apply {
24+
_x addAction
25+
[
26+
"Clean Up",
27+
{
28+
params ["_target", "_caller", "_actionId", "_arguments"];
29+
["arsenalcleanup", [_target]] call para_c_fnc_call_on_server;
30+
},
31+
nil,
32+
1.5,
33+
true,
34+
true,
35+
"",
36+
"true",
37+
5,
38+
false,
39+
"",
40+
""
41+
];
42+
};
43+
};
44+
45+
true;

mission/para_server_init.sqf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ enableenvironment [[false,true] select _ambientlife,[false,true] select _ambient
139139
//Set up respawn points.
140140
[] call vn_mf_fnc_respawn_points_init;
141141

142+
// setup arsenals
143+
[] call vn_mf_fnc_arsenals_init;
144+
142145
// start scheduler
143146
diag_log "VN MikeForce: Starting scheduler";
144147
[] call para_g_fnc_scheduler_subsystem_init;

0 commit comments

Comments
 (0)