Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
pluginconfigscene.c
Go to the documentation of this file.
1 class PluginConfigScene extends PluginConfigHandler
2 {
3  protected string FILE_ROOT = "$saves:";
4  protected const string FILE_ROOT_SCENES = "scenes";
5 
6  protected const string PARAM_MISSION = "Mission";
7  protected const string PARAM_TIME = "InitTime";
8  protected const string PARAM_YEAR = "InitYear";
9  protected const string PARAM_MONTH = "InitMonth";
10  protected const string PARAM_DAY = "InitDay";
11  protected const string PARAM_HOUR = "InitHour";
12  protected const string PARAM_MINUTE = "InitMinute";
13  protected const string PARAM_OVERCAST = "WeatherInitOvercast";
14  protected const string PARAM_RAIN = "WeatherInitRain";
15  protected const string PARAM_FOG = "WeatherInitFog";
16  protected const string PARAM_WIND_F = "WeatherInitWindForce";
17  protected const string PARAM_PLAYER = "Player";
18  protected const string PARAM_OBJ_COUNT = "SceneObjectsCount";
19  protected const string PARAM_OBJ_NAME = "SceneObject";
20  protected const string PARAM_OBJ_ATT = "Att";
21  protected const string PARAM_OBJ_LNK = "Lnk";
22  protected const string PARAM_OBJ_TYPE = "type";
23  protected const string PARAM_OBJ_POS = "position";
24  protected const string PARAM_OBJ_ROT = "rotation";
25  protected const string PARAM_OBJ_DMG = "damage";
26  protected const string PARAM_OBJ_HLT = "health";
27  protected const string PARAM_OBJ_ISCR = "init_script";
28 
29  TStringArray m_CfgTemplate;
30 
31  protected string m_FileSceneName;
32 
33  //========================================
34  // OnInit
35  //========================================
36  override void OnInit()
37  {
38  //super.OnInit();
39 
40  FILE_ROOT = g_Game.GetMissionFolderPath();
41  }
42 
43  //========================================
44  // GetPathScenes
45  //========================================
46  string GetPathScenes()
47  {
48  return FILE_ROOT+"\\"+FILE_ROOT_SCENES;
49  }
50 
51  //========================================
52  // GetFileName
53  //========================================
54  override string GetFileName()
55  {
56  return GetPathScenes()+"\\"+m_FileSceneName;
57  }
58 
59  //========================================
60  // SceneRename
61  //========================================
62  void SceneRename(string scene_name, string scene_name_new)
63  {
64  string file_path = GetPathScenes()+"\\"+scene_name+"."+PluginSceneManager.SCENE_SUFIX;
65  string file_path_new = GetPathScenes()+"\\"+scene_name_new+"."+PluginSceneManager.SCENE_SUFIX;
66  PluginFileHandler.FileRename(file_path, file_path_new);
67  }
68 
69  //========================================
70  // SceneDelete
71  //========================================
72  void SceneDelete(string scene_name)
73  {
74  string file_path = GetPathScenes()+"\\"+scene_name+"."+PluginSceneManager.SCENE_SUFIX;
75  PluginFileHandler.FileDelete(file_path);
76  }
77 
78  //========================================
79  // SceneDuplicate
80  //========================================
81  void SceneDuplicate(string scene_name)
82  {
83  string file_path = GetPathScenes()+"\\"+scene_name+"."+PluginSceneManager.SCENE_SUFIX;
84  string file_path_new = file_path;
85 
86  int i = 0;
87  while ( FileExist(file_path_new) )
88  {
89  file_path_new = GetPathScenes()+"\\"+scene_name+"_copy"+i.ToString()+"."+PluginSceneManager.SCENE_SUFIX;
90  i++;
91  }
92 
93  PluginFileHandler.FileDuplicate(file_path, file_path_new);
94  }
95 
96  //========================================
97  // GetSceneList
98  //========================================
99  TStringArray GetSceneList()
100  {
101  if ( !FileExist( GetPathScenes() ) )
102  {
103  MakeDirectory( GetPathScenes() );
104  }
105 
106  string file_name;
107  int file_attr;
108  int flags;
109  TStringArray list = new TStringArray;
110 
111  string path_find_pattern = GetPathScenes()+"/*."+PluginSceneManager.SCENE_SUFIX; //*/
112  FindFileHandle file_handler = FindFile(path_find_pattern, file_name, file_attr, flags);
113 
114  bool found = true;
115  while ( found )
116  {
117  int pos = file_name.IndexOf(".");
118 
119  if ( pos > -1 )
120  {
121  list.Insert( file_name.Substring(0, pos) );
122  }
123 
124  found = FindNextFile(file_handler, file_name, file_attr);
125  }
126 
127  return list;
128  }
129 
130  //========================================
131  // EncodeInitScript
132  //========================================
133  string EncodeInitScript( string script )
134  {
135  script.Replace( "\"", "^" );
136  script.Replace( "\n", "$" );
137  return script;
138  }
139 
140  //========================================
141  // DecodeInitScript
142  //========================================
143  string DecodeInitScript( string script )
144  {
145  script.Replace( "^", "\"" );
146  script.Replace( "$", "\n" );
147  return script;
148  }
149 
150 //=====================================================================================
151 //=====================================================================================
152 // SAVE SCENE
153 //=====================================================================================
154 //=====================================================================================
155 
156  //========================================
157  // SceneSave
158  //========================================
159  void SceneDataSave(SceneData scene)
160  {
161  PluginSceneManager module_scene_editor = PluginSceneManager.Cast( GetPlugin(PluginSceneManager) );
162 
163  EntityAI player = PluginSceneManager.PLAYER;
164 
165  // Log("Saving started....")
166  m_FileSceneName = scene.GetNameScene()+"."+PluginSceneManager.SCENE_SUFIX;
167 
168  // Save Settings
169  SaveSceneSettings(scene);
170 
171  // Save Weater
172  SaveSceneWeather(scene);
173 
174  // Save Players
175  SaveScenePlayer(scene);
176 
177  // Save Objects
178  SaveSceneObjects(scene);
179 
180  // Save To File
181  SaveConfigToFile();
182  }
183 
184 
185  //=============================================
186  // SAVE: SaveSceneSettings (Mission Name, Time, Year, Month, Day, Hour, Minute)
187  //=============================================
188  void SaveSceneSettings(SceneData scene)
189  {
190  // Save Mission Name
191  CfgParamString cfg_mission = CfgParamString.Cast( GetParamByName(PARAM_MISSION, CFG_TYPE_STRING) );
192  cfg_mission.SetValue(scene.GetNameMission());
193 
194  // Save Time
195  CfgParamFloat cfg_time = CfgParamFloat.Cast( GetParamByName(PARAM_TIME, CFG_TYPE_FLOAT) );
196  cfg_time.SetValue(scene.GetInitTime());
197 
198  // Save Year
199  CfgParamInt cfg_year = CfgParamInt.Cast( GetParamByName(PARAM_YEAR, CFG_TYPE_INT) );
200  cfg_year.SetValue(scene.GetInitYear());
201 
202  // Save Month
203  CfgParamInt cfg_month = CfgParamInt.Cast( GetParamByName(PARAM_MONTH, CFG_TYPE_INT) );
204  cfg_month.SetValue(scene.GetInitMonth());
205 
206  // Save Day
207  CfgParamInt cfg_day = CfgParamInt.Cast( GetParamByName(PARAM_DAY, CFG_TYPE_INT) );
208  cfg_day.SetValue(scene.GetInitDay());
209 
210  // Save Hour
211  CfgParamInt cfg_hour = CfgParamInt.Cast( GetParamByName(PARAM_HOUR, CFG_TYPE_INT) );
212  cfg_hour.SetValue(scene.GetInitHour());
213 
214  // Save Minute
215  CfgParamInt cfg_minute = CfgParamInt.Cast( GetParamByName(PARAM_MINUTE, CFG_TYPE_INT) );
216  cfg_minute.SetValue(scene.GetInitMinute());
217  }
218 
219  //=============================================
220  // SAVE: SaveSceneWeather (Overcast, Rain, Fog, Wind Force)
221  //=============================================
222  void SaveSceneWeather(SceneData scene)
223  {
224  // Save Weather Overcast
225  CfgParamFloat cfg_overcast = CfgParamFloat.Cast( GetParamByName(PARAM_OVERCAST, CFG_TYPE_FLOAT) );
226  cfg_overcast.SetValue(scene.GetInitOvercast());
227 
228  // Save Weather Rain
229  CfgParamFloat cfg_rain = CfgParamFloat.Cast( GetParamByName(PARAM_RAIN, CFG_TYPE_FLOAT) );
230  cfg_rain.SetValue(scene.GetInitRain());
231 
232  // Save Weather Fog
233  CfgParamFloat cfg_fog = CfgParamFloat.Cast( GetParamByName(PARAM_FOG, CFG_TYPE_FLOAT) );
234  cfg_fog.SetValue(scene.GetInitFog());
235 
236  // Save Weather Wind Force
237  CfgParamFloat cfg_wind_force = CfgParamFloat.Cast( GetParamByName(PARAM_WIND_F, CFG_TYPE_FLOAT) );
238  cfg_wind_force.SetValue(scene.GetInitWindForce());
239  }
240 
241  //=============================================
242  // SAVE: SaveScenePlayer (position, rotation, health, script)
243  //=============================================
244  void SaveScenePlayer(SceneData scene)
245  {
246  array<ref ScenePlayer> players = scene.GetScenePlayers();
247 
248  if ( players.Count() > 0 )
249  {
250  ScenePlayer plyr = players.Get(0);
251 
252  // Save Player
253  CfgParamArray cfg_param_player = CfgParamArray.Cast( GetParamByName(PARAM_PLAYER, CFG_TYPE_ARRAY) );
254 
255  // Obj Position
256  CfgParamString cfg_param_player_pos = CfgParamString.Cast( cfg_param_player.GetValueByName(PARAM_OBJ_POS, CFG_TYPE_STRING) );
257  cfg_param_player_pos.SetValue(plyr.GetPositionAsString());
258 
259  // Obj Rotation
260  CfgParamFloat cfg_param_player_rot = CfgParamFloat.Cast( cfg_param_player.GetValueByName(PARAM_OBJ_ROT, CFG_TYPE_FLOAT) );
261  cfg_param_player_rot.SetValue(plyr.GetRotation());
262 
263  // Obj Health
264  CfgParamFloat cfg_param_player_hlt = CfgParamFloat.Cast( cfg_param_player.GetValueByName(PARAM_OBJ_HLT, CFG_TYPE_FLOAT) );
265  cfg_param_player_hlt.SetValue(plyr.GetHealth());
266 
267  // Obj Init Script
268  CfgParamString cfg_param_player_iscr = CfgParamString.Cast( cfg_param_player.GetValueByName(PARAM_OBJ_ISCR, CFG_TYPE_STRING) );
269  cfg_param_player_iscr.SetValue( EncodeInitScript(plyr.GetInitScript()) );
270  }
271  }
272 
273  //=============================================
274  // SAVE: SaveSceneObjects (position, rotation, health, script, scripted links)
275  //=============================================
276  void SaveSceneObjects(SceneData scene)
277  {
278  array<ref SceneObject> objects = scene.GetSceneObjects();
279 
280  // Save Objects
281  for ( int i = 0; i < objects.Count(); ++i )
282  {
283  SceneObject obj = objects.Get(i);
284 
285  string param_name;
286 
287  param_name = PARAM_OBJ_NAME+"_"+i.ToString();
288 
289  // Save Scene Object
290  CfgParamArray cfg_param_obj = CfgParamArray.Cast( GetParamByName(param_name, CFG_TYPE_ARRAY) );
291 
292  // Obj Type Name
293  CfgParamString cfg_param_obj_type = CfgParamString.Cast( cfg_param_obj.GetValueByName(PARAM_OBJ_TYPE, CFG_TYPE_STRING) );
294  cfg_param_obj_type.SetValue(obj.GetTypeName());
295 
296  // Obj Position
297  CfgParamString cfg_param_obj_pos = CfgParamString.Cast( cfg_param_obj.GetValueByName(PARAM_OBJ_POS, CFG_TYPE_STRING) );
298  cfg_param_obj_pos.SetValue(obj.GetPositionAsString());
299 
300  // Obj Rotation
301  CfgParamFloat cfg_param_obj_rot = CfgParamFloat.Cast( cfg_param_obj.GetValueByName(PARAM_OBJ_ROT, CFG_TYPE_FLOAT) );
302  cfg_param_obj_rot.SetValue(obj.GetRotation());
303 
304  // Obj Health
305  CfgParamFloat cfg_param_obj_hlt = CfgParamFloat.Cast( cfg_param_obj.GetValueByName(PARAM_OBJ_HLT, CFG_TYPE_FLOAT) );
306  cfg_param_obj_hlt.SetValue(obj.GetHealth());
307 
308  // Obj Init Script
309  CfgParamString cfg_param_obj_iscr = CfgParamString.Cast( cfg_param_obj.GetValueByName(PARAM_OBJ_ISCR, CFG_TYPE_STRING) );
310  cfg_param_obj_iscr.SetValue( EncodeInitScript(obj.GetInitScript()) );
311 
312  EntityAI e_obj = obj.GetObject();
313 
314  int attcount = e_obj.GetInventory().AttachmentCount();
315 
316  if ( attcount > 0 )
317  {
318  string param_name_att = param_name+"_"+PARAM_OBJ_ATT;
319  CfgParamArray cfg_param_att = CfgParamArray.Cast( GetParamByName(param_name_att, CFG_TYPE_ARRAY) );
320  cfg_param_att.Clear();
321 
322  for (int att = 0; att < attcount; att++)
323  {
324  EntityAI attachment = e_obj.GetInventory().GetAttachmentFromIndex(att);
325 
326  CfgParamString cfg_param_att_str = new CfgParamString("");
327  cfg_param_att_str.SetValue( attachment.GetType() );
328  cfg_param_att.InsertValue( cfg_param_att_str );
329  }
330  }
331 
332  array<SceneObject> linked_scene_objects = obj.GetLinkedSceneObjects();
333  if ( linked_scene_objects.Count() > 0 )
334  {
335  string param_name_lnk = param_name + "_" + PARAM_OBJ_LNK;
336  CfgParamArray cfg_param_lnk = CfgParamArray.Cast( GetParamByName( param_name_lnk, CFG_TYPE_ARRAY ) );
337  cfg_param_lnk.Clear();
338 
339  for ( int lnk = 0; lnk < linked_scene_objects.Count(); lnk++ )
340  {
341  CfgParamInt cfg_param_lnk_int = new CfgParamInt("");
342 
343  int index = objects.Find( linked_scene_objects.Get(lnk) );
344 
345  if ( index >= 0 )
346  {
347  cfg_param_lnk_int.SetValue( index );
348  cfg_param_lnk.InsertValue( cfg_param_lnk_int );
349  }
350  }
351  }
352  }
353 
354  // Save Count Of objects
355  CfgParamInt cfg_obj_count = CfgParamInt.Cast( GetParamByName(PARAM_OBJ_COUNT, CFG_TYPE_INT) );
356  cfg_obj_count.SetValue(objects.Count());
357  }
358 
359 //=====================================================================================
360 //=====================================================================================
361 // LOAD SCENE
362 //=====================================================================================
363 //=====================================================================================
364 
365  //=============================================
366  // LOAD: SceneDataLoad (Settings, Weather, Player, Objects)
367  //=============================================
368  SceneData SceneDataLoad(string scene_name)
369  {
370  m_FileSceneName = scene_name+"."+PluginSceneManager.SCENE_SUFIX;
371 
372 //PrintString("Loading scene: "+ scene_name);
373 
374  LoadConfigFile();
375 
376  // Load Scene name
377  SceneData scene = new SceneData;
378  scene.SetNameScene(scene_name);
379 
380  // Load Scene settings
381  LoadSceneSettings(scene);
382 
383  // Load Scene Weather
384  LoadSceneWeather(scene);
385 
386  // Load Scene Player
387  LoadScenePlayer(scene);
388 
389  // Load Scene Objects
390  LoadSceneObjects(scene);
391 
392  if ( !FileExist(GetFileName()) )
393  {
394  SceneDataSave(scene);
395  }
396 
397  return scene;
398  }
399 
400  //=============================================
401  // LOAD: LoadSceneSettings (Mission Name, Time, Year, Month, Day, Hour, Minute)
402  //=============================================
403  void LoadSceneSettings(SceneData scene)
404  {
405  // Load Mission Name
406  CfgParamString cfg_mission = CfgParamString.Cast( GetParamByName(PARAM_MISSION, CFG_TYPE_STRING) );
407  scene.SetNameMission(cfg_mission.GetValue());
408 
409  // Load Time
410  CfgParamFloat cfg_time = CfgParamFloat.Cast( GetParamByName(PARAM_TIME, CFG_TYPE_FLOAT) );
411  scene.SetInitTime(cfg_time.GetValue());
412 
413  int year, month, day, hour, minute;
414  GetGame().GetWorld().GetDate( year, month, day, hour, minute );
415 
416  // Load Year
417  if ( ParamExist(PARAM_YEAR) )
418  {
419  CfgParamInt cfg_year = CfgParamInt.Cast( GetParamByName( PARAM_YEAR, CFG_TYPE_INT ) );
420  scene.SetInitYear( cfg_year.GetValue() );
421  }
422  else
423  {
424  scene.SetInitYear( year );
425  }
426 
427  // Load Month
428  if ( ParamExist(PARAM_MONTH) )
429  {
430  CfgParamInt cfg_month = CfgParamInt.Cast( GetParamByName( PARAM_MONTH, CFG_TYPE_INT ) );
431  scene.SetInitMonth( cfg_month.GetValue() );
432  }
433  else
434  {
435  scene.SetInitMonth( month );
436  }
437 
438  // Load Day
439  if ( ParamExist(PARAM_DAY) )
440  {
441  CfgParamInt cfg_day = CfgParamInt.Cast( GetParamByName( PARAM_DAY, CFG_TYPE_INT ) );
442  scene.SetInitDay( cfg_day.GetValue() );
443  }
444  else
445  {
446  scene.SetInitDay( day );
447  }
448 
449  // Load Hour
450  if ( ParamExist(PARAM_HOUR) )
451  {
452  CfgParamInt cfg_hour = CfgParamInt.Cast( GetParamByName( PARAM_HOUR, CFG_TYPE_INT ) );
453  scene.SetInitHour( cfg_hour.GetValue() );
454  }
455  else
456  {
457  scene.SetInitHour( hour );
458  }
459 
460  // Load Minute
461  if ( ParamExist(PARAM_MINUTE) )
462  {
463  CfgParamInt cfg_minute = CfgParamInt.Cast( GetParamByName( PARAM_MINUTE, CFG_TYPE_INT ) );
464  scene.SetInitMinute( cfg_minute.GetValue() );
465  }
466  else
467  {
468  scene.SetInitMinute( minute );
469  }
470  }
471 
472  //=============================================
473  // LOAD: LoadSceneWeather (Overcast, Rain, Fog, Wind Force)
474  //=============================================
475  void LoadSceneWeather(SceneData scene)
476  {
477  //Load Weather Overcast
478  if ( ParamExist(PARAM_OVERCAST) )
479  {
480  CfgParamFloat cfg_overcast = CfgParamFloat.Cast( GetParamByName(PARAM_OVERCAST, CFG_TYPE_FLOAT) );
481  scene.SetInitOvercast(cfg_overcast.GetValue());
482  }
483 
484  //Load Weather Rain
485  if ( ParamExist(PARAM_RAIN) )
486  {
487  CfgParamFloat cfg_rain = CfgParamFloat.Cast( GetParamByName(PARAM_RAIN, CFG_TYPE_FLOAT) );
488  scene.SetInitRain(cfg_rain.GetValue());
489  }
490 
491  //Load Weather Fog
492  if ( ParamExist(PARAM_FOG) )
493  {
494  CfgParamFloat cfg_fog = CfgParamFloat.Cast( GetParamByName(PARAM_FOG, CFG_TYPE_FLOAT) );
495  scene.SetInitFog(cfg_fog.GetValue());
496  }
497 
498  //Load Weather Wind Force
499  if ( ParamExist(PARAM_WIND_F) )
500  {
501  CfgParamFloat cfg_wind_force = CfgParamFloat.Cast( GetParamByName(PARAM_WIND_F, CFG_TYPE_FLOAT) );
502  scene.SetInitWindForce(cfg_wind_force.GetValue());
503  }
504  }
505 
506  //=============================================
507  // LOAD: LoadScenePlayer (position, rotation, health, script)
508  //=============================================
509  void LoadScenePlayer(SceneData scene)
510  {
511  // Only in local game (without server, (GetGame.GetPlayer is null on server! -> by design)
512  if ( GetGame().GetPlayer() != NULL )
513  {
514  CfgParamArray cfg_player = CfgParamArray.Cast( GetParamByName(PARAM_PLAYER, CFG_TYPE_ARRAY) );
515  CfgParamString cfg_ply_pos = CfgParamString.Cast( cfg_player.GetValueByName(PARAM_OBJ_POS, CFG_TYPE_STRING) );
516  CfgParamFloat cfg_ply_rot = CfgParamFloat.Cast( cfg_player.GetValueByName(PARAM_OBJ_ROT, CFG_TYPE_FLOAT) );
517  CfgParamFloat cfg_ply_hlt = CfgParamFloat.Cast( cfg_player.GetValueByName(PARAM_OBJ_HLT, CFG_TYPE_FLOAT) );
518  CfgParamString cfg_ply_iscr = CfgParamString.Cast( cfg_player.GetValueByName(PARAM_OBJ_ISCR, CFG_TYPE_STRING) );
519 
520  ScenePlayer scn_player = scene.CreateScenePlayer();
521  scn_player.LinkEntityAI(GetGame().GetPlayer());
522 
523  if ( PluginSceneManager.GetInstance().GetLoadPlayerPos() )
524  {
525  // start scene position
526  vector start_pos = cfg_ply_pos.GetValue().ToVector();
527 
528  if ( start_pos != vector.Zero )
529  {
530  // Set Position
531  scn_player.SetPosition(cfg_ply_pos.GetValue().ToVector());
532 
533  // Set Rotation
534  scn_player.SetRotation(cfg_ply_rot.GetValue());
535  }
536  }
537 
538  // Set Health
539  // Health check. Do not spawn player character as dead. He can still be spawned as injured.
540  float health2 = cfg_ply_hlt.GetValue();
541  if (health2 <= 0)
542  health2 = scn_player.GetMaxHealth();
543 
544  scn_player.SetHealth(health2);
545 
546  // Exe Script
547  scn_player.SetInitScript( DecodeInitScript(cfg_ply_iscr.GetValue()) );
548  }
549 //PrintString("LoadScenePlayer.. Finished");
550  }
551 
552  //=============================================
553  // LOAD: LoadSceneObjects (position, rotation, health, script, scripted links)
554  //=============================================
555  void LoadSceneObjects(SceneData scene)
556  {
557  CfgParamInt cfg_obj_count = CfgParamInt.Cast( GetParamByName(PARAM_OBJ_COUNT, CFG_TYPE_INT) );
558  int obj_count = cfg_obj_count.GetValue();
559 
560  for ( int i = 0; i < obj_count; ++i )
561  {
562  string param_name = PARAM_OBJ_NAME+"_"+i.ToString();
563 
564  // Load scene object name
565  CfgParamArray cfg_obj = CfgParamArray.Cast( GetParamByName(param_name, CFG_TYPE_ARRAY) );
566 
567  CfgParamString cfg_obj_type = CfgParamString.Cast( cfg_obj.GetValueByName(PARAM_OBJ_TYPE, CFG_TYPE_STRING) );
568  CfgParamString cfg_obj_pos = CfgParamString.Cast( cfg_obj.GetValueByName(PARAM_OBJ_POS, CFG_TYPE_STRING) );
569  CfgParamFloat cfg_obj_rot = CfgParamFloat.Cast( cfg_obj.GetValueByName(PARAM_OBJ_ROT, CFG_TYPE_FLOAT) );
570  CfgParamFloat cfg_obj_hlt = CfgParamFloat.Cast( cfg_obj.GetValueByName(PARAM_OBJ_HLT, CFG_TYPE_FLOAT) );
571  CfgParamString cfg_obj_iscr = CfgParamString.Cast( cfg_obj.GetValueByName(PARAM_OBJ_ISCR, CFG_TYPE_STRING) );
572 
573 //PrintString(itoa(i)+ " Loading param_name: "+ param_name+ " => object type: "+ cfg_obj_type.GetValue());
574 
575  // Create Scene Object + position
576  SceneObject scn_obj = scene.CreateSceneObject(cfg_obj_type.GetValue(), cfg_obj_pos.GetValue().ToVector());
577 
578  // Setup rotation
579  scn_obj.SetRotation(cfg_obj_rot.GetValue());
580  // Setup health
581  scn_obj.SetHealth(cfg_obj_hlt.GetValue());
582  // Setup init script
583  scn_obj.SetInitScript( DecodeInitScript(cfg_obj_iscr.GetValue()) );
584 
585  // Setup indices for linked objects
586  CfgParamArray cfg_obj_param_links = CfgParamArray.Cast( GetParamByName(param_name + "_" + PARAM_OBJ_LNK, CFG_TYPE_ARRAY) );
587  array<ref CfgParam> cfg_obj_links = cfg_obj_param_links.GetValues();
588 
589  for ( int lnko = 0; lnko < cfg_obj_links.Count(); lnko++ )
590  {
591  CfgParamInt cfg_obj_param_lnk_int = CfgParamInt.Cast( cfg_obj_links.Get(lnko) );
592  scn_obj.m_LinkedSceneObjectsIndices.Insert( cfg_obj_param_lnk_int.GetValue() );
593  }
594 
595  string param_name_att = param_name +"_"+ PARAM_OBJ_ATT;
596 
597  if ( ParamExist(param_name_att) )
598  {
599  CfgParamArray cfg_param_att = CfgParamArray.Cast( GetParamByName(param_name_att, CFG_TYPE_ARRAY) );
600 
601  array<ref CfgParam> cfg_param_attachments = cfg_param_att.GetValues();
602 
603  for ( int j = 0; j < cfg_param_attachments.Count(); ++j )
604  {
605  CfgParamString cfg_param_att_str = CfgParamString.Cast( cfg_param_attachments.Get(j) );
606  scn_obj.GetObject().GetInventory().CreateAttachment( cfg_param_att_str.GetValue() );
607  }
608  }
609  }
610  }
611 }
GetFileName
override string GetFileName()
Definition: pluginlocalenscripthistory.c:7
GetGame
proto native CGame GetGame()
PluginFileHandler
Definition: pluginconfighandler.c:1
MakeDirectory
proto native bool MakeDirectory(string name)
Makes a directory.
TStringArray
array< string > TStringArray
Definition: enscript.c:685
FileExist
proto bool FileExist(string name)
Check existence of file.
FindNextFile
proto bool FindNextFile(FindFileHandle handle, out string fileName, out FileAttr fileAttributes)
SceneObject
Definition: sceneobject.c:1
FindFileHandle
int[] FindFileHandle
Definition: ensystem.c:503
CFG_TYPE_STRING
const int CFG_TYPE_STRING
Definition: cfgparam.c:1
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition: pluginmanager.c:316
vector
Definition: enconvert.c:105
CFG_TYPE_INT
const int CFG_TYPE_INT
Definition: cfgparam.c:2
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
CFG_TYPE_ARRAY
const int CFG_TYPE_ARRAY
Definition: cfgparam.c:5
FindFile
enum FindFileFlags FindFile(string pattern, out string fileName, out FileAttr fileAttributes, FindFileFlags flags)
PluginConfigHandler
Definition: pluginconfigdebugprofile.c:2
CFG_TYPE_FLOAT
const int CFG_TYPE_FLOAT
Definition: cfgparam.c:3
array< string >
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
OnInit
void OnInit()
Definition: aibehaviour.c:49
EntityAI
Definition: building.c:5
SceneData
Definition: scenedata.c:1