DayZ 1.24
Loading...
Searching...
No Matches
ObjectSpawner.c
Go to the documentation of this file.
2{
3 protected static const ref TStringArray VALID_PATHS = {"DZ\\plants", "DZ\\plants_bliss", "DZ\\rocks", "DZ\\rocks_bliss", "DZ/plants", "DZ/plants_bliss", "DZ/rocks", "DZ/rocks_bliss"};
4 //---------------------------------------------------------------------------------------
5 static void SpawnObjects()
6 {
8 {
10 foreach (string spawnerFilePath: arr)
11 {
12 string path = "$mission:" + spawnerFilePath;
13
14 string errorMessage;
17 {
18 foreach (ITEM_SpawnerObject o : spawner.Objects)
20 }
21 else
23 }
24 }
25 }
26 //---------------------------------------------------------------------------------------
28 {
30
31 float scale = item.scale;
32 if (scale == 0)
33 scale = 1;
34
35 if (item.name.Contains("\\") || item.name.Contains("/"))
36 {
37 if (ValidatePath(item.name))
38 object = GetGame().CreateStaticObjectUsingP3D(item.name, vector.ArrayToVec(item.pos), vector.ArrayToVec(item.ypr), scale);
39 }
40 else
41 {
43
44 if (item.enableCEPersistency)
45 {
46 flags &= ~ECE_DYNAMIC_PERSISTENCY;
47 flags &= ~ECE_NOLIFETIME;
48 }
49
50 object = GetGame().CreateObjectEx(item.name, vector.ArrayToVec(item.pos), flags, RF_IGNORE);
51 if (object)
52 {
53 object.SetOrientation(vector.ArrayToVec(item.ypr));
54 if (item.scale != 1)
55 object.SetScale(scale);
56 }
57 }
58
59 if (!object)
60 PrintToRPT("Object spawner failed to spawn " + item.name);
61 }
62 //---------------------------------------------------------------------------------------
64 {
66 GetGame().GetWorld().ProcessMarkedObjectsForPathgraphUpdate();
67 }
68
69 //---------------------------------------------------------------------------------------
70 static bool ValidatePath(string path)
71 {
72 foreach (string p: VALID_PATHS)
73 {
74 if (path.Contains(p))
75 return true;
76 }
77 return false;
78 }
79 //---------------------------------------------------------------------------------------
80};
81
86
88{
89 string name;
90 float pos[3];
91 float ypr[3];
92 float scale;
94};
95
96
99{
101 static string m_Path = "$mission:myspawndata.json";
102
103 static void SpawnObjects()
104 {
105 Objects.Clear();
106 SpawnInit();
108 j.Objects = Objects;
109
110 string errorMessage;
113 }
114
115 static void SpawnInit()
116 {
117 AddSpawnData("Land_Wall_Gate_FenR", "8406.501953 107.736824 12782.338867", "0.000000 0.000000 0.000000");
118 AddSpawnData("Land_Wall_Gate_FenR", "8410.501953 107.736824 12782.338867", "0.000000 0.000000 0.000000");
119 AddSpawnData("Land_Wall_Gate_FenR", "8416.501953 107.736824 12782.338867", "0.000000 0.000000 0.000000");
120 AddSpawnData("Land_Wall_Gate_FenR", "8422.501953 107.736824 12782.338867", "0.000000 0.000000 0.000000");
121 }
122
124 {
126 obj.name = objectName;
127 obj.pos[0] = position[0];
128 obj.pos[1] = position[1];
129 obj.pos[2] = position[2];
130
131 obj.ypr[0] = orientation[0];
132 obj.ypr[1] = orientation[1];
133 obj.ypr[2] = orientation[2];
134
135 Objects.Insert(obj);
136 }
137}
const int ECE_SETUP
const int ECE_UPDATEPATHGRAPH
const int RF_IGNORE
const int ECE_DYNAMIC_PERSISTENCY
const int ECE_NOLIFETIME
const int ECE_CREATEPHYSICS
static TStringArray GetObjectSpawnersArr()
static void SpawnObject(ITEM_SpawnerObject item)
static bool ValidatePath(string path)
static const ref TStringArray VALID_PATHS
static void OnGameplayDataHandlerLoad()
static void SpawnObjects()
ref array< ref ITEM_SpawnerObject > Objects
Utility class that converts init.c format type of spawn commands to a json file, fill in the SpawnIni...
static void SpawnObjects()
static ref array< ref ITEM_SpawnerObject > Objects
static string m_Path
static void AddSpawnData(string objectName, vector position, vector orientation)
static void SpawnInit()
static vector ArrayToVec(float arr[])
Convert static array of floats into a vector.
Definition EnConvert.c:503
proto native CGame GetGame()
proto void PrintToRPT(void var)
Prints content of variable to RPT file (performance warning - each write means fflush!...
enum ShapeType ErrorEx
bool Contains(string sample)
Returns true if sample is substring of string.
Definition EnString.c:286