-
Notifications
You must be signed in to change notification settings - Fork 405
/
fn_spawnObjects.sqf
74 lines (63 loc) · 2.29 KB
/
fn_spawnObjects.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
/*
Spawns objects from compact array format.
Notes for global spawned objects:
- Recommend running on server machine only.
- Always present global objects use the most resources. Damage and other updates about them are regularly sent over the network.
Notes for local spawned objects:
- Always present local objects are more performant than global, but less performant than town generator (spawning locally only when player is nearby)
- Recommend running on every machine including the server, so all units know about the object and vehicles parked on top are not affected.
- Recommend running unscheduled before player_monitor.fsm and server_monitor.sqf, so units and vehicles spawned on top do not fall through.
- Not recommended for destructible or removable objects. Damage and deleted status are not synced across machines.
- Not recommended for objects with animations (like gates). Anim status is not synced across machines.
Params:
[
[
["ObjectType1", [position], dir, vectorUp(optional)],
["ObjectType2", [position], dir, vectorUp(optional)],
["ObjectType3", [position], dir, vectorUp(optional)]
],
false, // Block damage
false, // Use setPosATL instead of setPos
true // Spawn objects locally
] call fnc_spawnObjects;
*/
private ["_atl","_blockDamage","_fires","_local","_object","_objects","_type"];
_objects = _this select 0;
_blockDamage = _this select 1;
_atl = _this select 2;
_local = _this select 3;
_fires = [
"Base_Fire_DZ",
"flamable_DZ",
"Land_Camp_Fire_DZ",
"Land_Campfire",
"Land_Campfire_burning",
"Land_Fire",
"Land_Fire_burning",
"Land_Fire_DZ",
"Land_Fire_barrel",
"Land_Fire_barrel_burning",
"Misc_TyreHeap"
];
{
_type = _x select 0;
if (_local) then {
_object = _type createVehicleLocal [0,0,0];
_object setVariable ["",true,false]; // stops global setVariable by sched_townGenerator, checked in player_spawnCheck for loot spawn
} else {
_object = _type createVehicle [0,0,0];
};
_object setDir (_x select 2);
if (_atl) then {
_object setPosATL (_x select 1);
} else {
_object setPos (_x select 1);
};
if (count _x > 3) then {
_object setVectorUp (_x select 3);
};
if (_blockDamage) then {
_object addEventHandler ["HandleDamage",{0}];
if !(_type in _fires) then {_object enableSimulation false;};
};
} forEach _objects;