DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ObjectSpawner.c
См. документацию.
2{
3 protected static const ref TStringArray VALID_PATHS = {
4 "DZ\\plants","DZ\\plants_bliss", "DZ\\plants_sakhal",
5 "DZ\\rocks", "DZ\\rocks_bliss", "DZ\\rocks_sakhal",
6 "DZ/plants","DZ/plants_bliss", "DZ/plants_sakhal",
7 "DZ/rocks", "DZ/rocks_bliss", "DZ/rocks_sakhal",
8 };
9
10 //---------------------------------------------------------------------------------------
11 static void SpawnObjects()
12 {
14 {
16 foreach (string spawnerFilePath: arr)
17 {
18 string path = "$mission:" + spawnerFilePath;
19
20 string errorMessage;
21 ObjectSpawnerJson spawner;
22 if (JsonFileLoader<ObjectSpawnerJson>.LoadFile(path, spawner, errorMessage))
23 {
24 foreach (ITEM_SpawnerObject o : spawner.Objects)
25 SpawnObject(o);
26 }
27 else
28 ErrorEx(errorMessage);
29 }
30 }
31 }
32 //---------------------------------------------------------------------------------------
34 {
35 Object object;
36
37 float scale = item.scale;
38 if (scale == 0)
39 scale = 1;
40
41 if (item.name.Contains("\\") || item.name.Contains("/"))
42 {
43 if (ValidatePath(item.name))
44 object = GetGame().CreateStaticObjectUsingP3D(item.name, vector.ArrayToVec(item.pos), vector.ArrayToVec(item.ypr),scale);
45 }
46 else
47 {
49
50 if (item.enableCEPersistency)
51 {
53 flags &= ~ECE_NOLIFETIME;
54 }
55
56 object = GetGame().CreateObjectEx(item.name, vector.ArrayToVec(item.pos), flags, RF_IGNORE);
57 if (object)
58 {
59 object.SetOrientation( vector.ArrayToVec(item.ypr));
60 if (item.scale != 1)
61 object.SetScale(scale);
62
63 object.OnSpawnByObjectSpawner(item);
64 }
65 }
66
67 if (!object)
68 PrintToRPT("Object spawner failed to spawn "+item.name);
69 }
70 //---------------------------------------------------------------------------------------
72 {
73 if (g_Game && g_Game.IsServer())
74 {
77 }
78 }
79
80 //---------------------------------------------------------------------------------------
81 static bool ValidatePath(string path)
82 {
83 foreach (string p: VALID_PATHS)
84 {
85 if (path.Contains(p))
86 return true;
87 }
88
89 PrintToRPT("Object spawner: invalid path "+ path);
90 return false;
91 }
92 //---------------------------------------------------------------------------------------
93};
94
99
101{
102 string name;
103 float pos[3];
104 float ypr[3];
105 float scale;
108};
109
110
113{
115 static string m_Path = "$mission:myspawndata.json";
116
117 static void SpawnObjects()
118 {
119 Objects.Clear();
120 SpawnInit();
122 j.Objects = Objects;
123
124 string errorMessage;
125 if (!JsonFileLoader<ObjectSpawnerJson>.SaveFile(m_Path, j, errorMessage))
126 ErrorEx(errorMessage);
127 }
128
129 static void SpawnInit()
130 {
131 AddSpawnData("Land_Wall_Gate_FenR", "8406.501953 107.736824 12782.338867", "0.000000 0.000000 0.000000");
132 AddSpawnData("Land_Wall_Gate_FenR", "8410.501953 107.736824 12782.338867", "0.000000 0.000000 0.000000");
133 AddSpawnData("Land_Wall_Gate_FenR", "8416.501953 107.736824 12782.338867", "0.000000 0.000000 0.000000");
134 AddSpawnData("Land_Wall_Gate_FenR", "8422.501953 107.736824 12782.338867", "0.000000 0.000000 0.000000");
135 }
136
137 static void AddSpawnData(string objectName, vector position, vector orientation)
138 {
140 obj.name = objectName;
141 obj.pos[0] = position[0];
142 obj.pos[1] = position[1];
143 obj.pos[2] = position[2];
144
145 obj.ypr[0] = orientation[0];
146 obj.ypr[1] = orientation[1];
147 obj.ypr[2] = orientation[2];
148
149 Objects.Insert(obj);
150 }
151}
const int ECE_SETUP
Определения CentralEconomy.c:9
const int ECE_UPDATEPATHGRAPH
Определения CentralEconomy.c:13
const int RF_IGNORE
Определения CentralEconomy.c:56
const int ECE_DYNAMIC_PERSISTENCY
Определения CentralEconomy.c:32
const int ECE_NOLIFETIME
Определения CentralEconomy.c:29
const int ECE_CREATEPHYSICS
Определения CentralEconomy.c:16
DayZGame g_Game
Определения DayZGame.c:3868
string path
Определения OptionSelectorMultistate.c:142
proto native World GetWorld()
proto native Object CreateObjectEx(string type, vector pos, int iFlags, int iRotation=RF_DEFAULT)
Creates object of certain type.
proto native Object CreateStaticObjectUsingP3D(string p3dFilename, vector position, vector orientation, float scale=1.0, bool createLocal=false)
static TStringArray GetObjectSpawnersArr()
Определения CfgGameplayHandler.c:141
string customString
Определения ObjectSpawner.c:107
float scale
Определения ObjectSpawner.c:105
float ypr[3]
Определения ObjectSpawner.c:104
bool enableCEPersistency
Определения ObjectSpawner.c:106
float pos[3]
Определения ObjectSpawner.c:103
string name
Определения ObjectSpawner.c:102
Определения ObjectTyped.c:2
static void SpawnObject(ITEM_SpawnerObject item)
Определения ObjectSpawner.c:33
static bool ValidatePath(string path)
Определения ObjectSpawner.c:81
static const ref TStringArray VALID_PATHS
Определения ObjectSpawner.c:3
static void OnGameplayDataHandlerLoad()
Определения ObjectSpawner.c:71
static void SpawnObjects()
Определения ObjectSpawner.c:11
ref array< ref ITEM_SpawnerObject > Objects
Определения ObjectSpawner.c:97
static void SpawnObjects()
Определения ObjectSpawner.c:117
static ref array< ref ITEM_SpawnerObject > Objects
Определения ObjectSpawner.c:114
static string m_Path
Определения ObjectSpawner.c:115
static void AddSpawnData(string objectName, vector position, vector orientation)
Определения ObjectSpawner.c:137
static void SpawnInit()
Определения ObjectSpawner.c:129
Utility class that converts init.c format type of spawn commands to a json file, fill in the SpawnIni...
Определения ObjectSpawner.c:113
proto native void ProcessMarkedObjectsForPathgraphUpdate()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static vector ArrayToVec(float arr[])
Convert static array of floats into a vector.
Определения EnConvert.c:502
Определения EnConvert.c:106
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
array< string > TStringArray
Определения EnScript.c:685
bool Contains(string sample)
Returns true if sample is substring of string.
Определения EnString.c:286