Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
dayzintroscenexbox.c
Go to the documentation of this file.
2 {
3  protected bool m_IsCharFemale;
4  protected int m_LastPlayedCharacterID;
5 
6  protected ref TStringArray m_genderList;
7  protected ref TStringArray m_CharPersonalityMaleList;
8  protected ref TStringArray m_CharPersonalityFemaleList;
9  protected ref TStringArray m_CharShirtList;
10  protected ref TStringArray m_CharPantsList;
11  protected ref TStringArray m_CharShoesList;
12  protected ref TStringArray m_AllCharacters;
13 
14  protected ref IntroSceneCharacter m_Character;
15  protected Camera m_SceneCamera;
16  protected Weather m_Weather;
17  protected Object m_Clutter;
18  protected vector m_CharacterPos;
19  protected vector m_CharacterDir;
20  protected ref TIntArray m_Date = new TIntArray;
21 
22  protected MenuData m_MenuData;
23 
24  protected ref MenuCarEngineSmoke m_FXParticleCarSmoke;
25  protected ref MenuEvaporation m_FXParticleStreamLeft;
26  protected ref MenuEvaporation m_FXParticleStreamRight;
27 
28  ref Timer m_TimerUpdate = new Timer( CALL_CATEGORY_GAMEPLAY );
29  ref Timer m_TimerParticle = new Timer( CALL_CATEGORY_GAMEPLAY );
30  ref Timer m_TimerDate = new Timer( CALL_CATEGORY_GAMEPLAY );
31  ref Timer m_TimerClientUpdate = new Timer( CALL_CATEGORY_GAMEPLAY );
32 
33  //==================================
34  // DayZIntroSceneXbox
35  //==================================
36  void DayZIntroSceneXbox()
37  {
38  m_MenuData = g_Game.GetMenuData();
39 
40  m_LastPlayedCharacterID = m_MenuData.GetLastPlayedCharacter();
41  m_CharacterPos = "0 0 0";
42  m_CharacterDir = "0 0 0";
43 
44  //g_Game.m_PlayerName = "Survivor"; //default
45  if ( m_MenuData.GetCharactersCount() == 0 )
46  {
47  m_LastPlayedCharacterID = -1;
48  }
49 
50  if ( m_LastPlayedCharacterID > -1 )
51  {
52  m_MenuData.GetCharacterName(m_LastPlayedCharacterID, g_Game.GetPlayerGameName());
53  }
54 
55  // Camera Setup
56  vector camera_position;
57  camera_position[0] = 1323.0; // X
58  camera_position[1] = 1.0; // Y
59  camera_position[2] = 1590.37; // Z
60  float camera_rotation_h = 100;
61  float camera_rotation_v = -3;
62  float camera_fov = 0.85;
63  float camera_focus_distance = 0.0;
64  float camera_focus_streght = 0.0;
65 
66  // Character
67  float character_distance = 2.25;
68 
69  // Camera Setup
70  m_SceneCamera = CameraCreate(camera_position, camera_rotation_h, camera_rotation_v, camera_fov, camera_focus_distance, camera_focus_streght);
71  m_SceneCamera.SetActive(true);
72 
73  PPEffects.Init(); //Deprecated, left in for legacy purposes only
74 
75  // Character Setup
76  vector cam_dir = m_SceneCamera.GetDirection();
77  m_CharacterPos = camera_position + ( cam_dir * character_distance );
78  m_CharacterPos[1] = GetGame().SurfaceY(m_CharacterPos[0], m_CharacterPos[2]);
79  m_CharacterDir = (camera_position - m_CharacterPos);
80 
81  float overcast = 0.42;
82  float rain = 0.0;
83  float fog = 0.0;
84 
85  m_Weather = g_Game.GetWeather();
86  m_Weather.GetOvercast().SetLimits(overcast, overcast);
87  m_Weather.GetRain().SetLimits(rain, rain);
88  m_Weather.GetFog().SetLimits(fog, fog);
89 
90  m_Weather.GetOvercast().Set(overcast, 0, 0);
91  m_Weather.GetRain().Set(rain, 0, 0);
92  m_Weather.GetFog().Set(fog, 0, 0);
93 
94  m_Character = new IntroSceneCharacter();
95  m_Character.LoadCharacterData(m_CharacterPos, m_CharacterDir);
96 
97  m_TimerParticle.Run(0.1, this, "SetupParticles", null, false);
98  //m_TimerDate.Run(2.0, this, "SetupDate", null, false);
99  m_TimerUpdate.Run(0.5, this, "SetupCharacter", null, true);
100 
101  vector clut_pos = SnapToGround( m_CharacterPos + "-1 0 0" );
102  m_Clutter = GetGame().CreateObject( "ClutterCutter2x2", clut_pos, true );
103 
104  // Xbox check update
105  CheckXboxClientUpdateLoopStart();
106 
107  g_Game.SetHudBrightness(g_Game.GetHUDBrightnessSetting());
108 
109  GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(SetInitPostprocesses);
110  }
111 
112  void ~DayZIntroSceneXbox()
113  {
114  if ( m_TimerUpdate )
115  {
116  m_TimerUpdate.Stop();
117  delete m_TimerUpdate;
118  m_TimerUpdate = null;
119  }
120 
121  if ( m_TimerParticle )
122  {
123  m_TimerParticle.Stop();
124  delete m_TimerParticle;
125  m_TimerParticle = null;
126  }
127 
128 
129  if ( m_TimerDate )
130  {
131  m_TimerDate.Stop();
132  delete m_TimerDate;
133  m_TimerDate = null;
134  }
135 
136  CheckXboxClientUpdateLoopStop();
137 
138  GetGame().ObjectDelete( m_SceneCamera );
139 
140  if ( m_MenuData )
141  {
142  m_MenuData.ClearCharacters();
143  }
144 
145  SEffectManager.DestroyEffect(m_FXParticleCarSmoke);
146  SEffectManager.DestroyEffect(m_FXParticleStreamLeft);
147  SEffectManager.DestroyEffect(m_FXParticleStreamRight);
148 
149  PPEManagerStatic.GetPPEManager().StopAllEffects(PPERequesterCategory.ALL);
150  }
151 
152  protected void SetInitPostprocesses()
153  {
154  PPERequester_MenuEffects requester;
155  Class.CastTo(requester,PPERequesterBank.GetRequester(PPERequester_MenuEffects));
156 
157  requester.SetVignetteIntensity(0.3);
158  PPERequesterBank.GetRequester(PPERequester_IntroChromAbb).Start();
159  }
160 
161  //==============================================
162  // GetIntroSceneCharacter
163  //==============================================
164  IntroSceneCharacter GetIntroCharacter()
165  {
166  return m_Character;
167  }
168 
169  //==================================
170  // SetupCharacter
171  //==================================
172  void SetupCharacter()
173  {
174  if ( m_Character.GetCharacterObj() )
175  {
176  vector v = m_Character.GetCharacterObj().GetOrientation();
177  v[0] = -75;
178  m_Character.GetCharacterObj().SetOrientation(v);
179  }
180  }
181 
182  //==================================
183  // SetupParticles
184  //==================================
185  void SetupParticles()
186  {
187  m_FXParticleCarSmoke = new MenuCarEngineSmoke();
188  //SEffectManager.PlayInWorld(m_FXParticleCarSmoke, "1330.36 2.11628 1594.31");
189  //SEffectManager.PlayInWorld(m_FXParticleCarSmoke, "1333.88 1.51392 1594.88");
190  SEffectManager.PlayInWorld(m_FXParticleCarSmoke, "1331.52 2.34052 1593.55");
191 
192  vector pos = m_SceneCamera.GetPosition() + m_SceneCamera.GetDirection() * 1.5;
193  vector dir = m_SceneCamera.GetDirection();
194  float temp = dir[0];
195  dir[0] = dir[2];
196  dir[2] = -temp;
197 
198  vector pos_right = pos + (dir * 1.5);
199  vector pos_left = pos + (-dir * 1.5);
200 
201  m_FXParticleStreamLeft = new MenuEvaporation();
202  SEffectManager.PlayInWorld(m_FXParticleStreamLeft, pos_right);
203 
204  m_FXParticleStreamRight = new MenuEvaporation();
205  SEffectManager.PlayInWorld(m_FXParticleStreamRight, pos_left);
206  }
207 
208  //==================================
209  // SetupDate
210  //==================================
211  void SetupDate()
212  {
213  //g_Game.GetWorld().SetDate(m_Date.Get(0), m_Date.Get(1), m_Date.Get(2), m_Date.Get(3), m_Date.Get(4));
214  //g_Game.GetWorld().SetDate(2020, 10, 15, 18, 20);
215  }
216 
217  //==================================
218  // CheckXboxClientUpdateLoopStart
219  //==================================
220  void CheckXboxClientUpdateLoopStart()
221  {
222  if ( CheckXboxClientUpdate() )
223  {
224  m_TimerClientUpdate.Run(30, this, "CheckXboxClientUpdate", null, true);
225  }
226  }
227 
228  //==================================
229  // CheckXboxClientUpdateLoopStop
230  //==================================
231  void CheckXboxClientUpdateLoopStop()
232  {
233  if ( m_TimerClientUpdate )
234  {
235  m_TimerClientUpdate.Stop();
236  delete m_TimerClientUpdate;
237  m_TimerClientUpdate = null;
238  }
239  }
240 
241  //==================================
242  // CheckXboxClientUpdate
243  //==================================
244  bool CheckXboxClientUpdate()
245  {
246  return OnlineServices.CheckUpdate();
247  }
248 
249  //==================================
250  // CameraCreate
251  //==================================
252  protected Camera CameraCreate(vector cam_pos, float cam_rot_h, float cam_rot_v, float cam_fov, float cam_focus_dist, float cam_focus_strg)
253  {
254  Camera cam = Camera.Cast( g_Game.CreateObject("staticcamera", SnapToGround(cam_pos), true));
255  cam.SetOrientation( Vector( cam_rot_h, cam_rot_v, 0) );
256  cam.SetFOV( cam_fov );
257  cam.SetFocus(cam_focus_dist, cam_focus_strg);
258 
259  return cam;
260  }
261 
262  //==================================
263  // GetCamera
264  //==================================
265  Camera GetCamera()
266  {
267  return m_SceneCamera;
268  }
269 
270  //==================================
271  // ResetIntroCamera
272  //==================================
273  void ResetIntroCamera()
274  {
275 
276  }
277 
278  //==================================
279  // SetCharacterFemale
280  //==================================
281  void SetCharacterFemale(bool fem)
282  {
283  m_IsCharFemale = fem;
284  }
285 
286  //==================================
287  // IsCharacterFemale
288  //==================================
289  bool IsCharacterFemale()
290  {
291  return m_IsCharFemale;
292  }
293 
294  //==================================
295  // CreateRandomCharacter
296  //==================================
297  void CreateRandomCharacter()
298  {
299  string character_name;
300  string params[2];
301 
302  m_IsCharFemale = Math.RandomInt(0, 2);
303 
304  if (m_IsCharFemale)
305  {
306  character_name = m_CharPersonalityFemaleList.GetRandomElement();
307  }
308  else
309  {
310  character_name = m_CharPersonalityMaleList.GetRandomElement();
311  }
312 
313  GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(UpdateCharacterPos, 250);
314  }
315 
316  void UpdateSelectedUserName()
317  {
318  string name;
319  BiosUserManager user_manager = GetGame().GetUserManager();
320  if( user_manager )
321  {
322  BiosUser user = user_manager.GetSelectedUser();
323  if( user )
324  {
325  g_Game.SetPlayerGameName( user.GetName() );
326  return;
327  }
328  }
329  g_Game.SetPlayerGameName(GameConstants.DEFAULT_CHARACTER_NAME);
330  }
331 
332  void UpdateCharacterPos()
333  {
334  if (m_Character.GetCharacterObj())
335  {
336  m_Character.GetCharacterObj().SetPosition(m_CharacterPos);
337  m_Character.GetCharacterObj().SetDirection(m_CharacterDir.Normalized() );
338  }
339  }
340 
341  void SaveCharName( string name )
342  {
343  GetDayZGame().InitCharacterMenuDataInfo(m_MenuData.GetCharactersCount());
344 
345  //if (!GetDayZGame().IsNewCharacter() && m_LastPlayedCharacterID > -1)
346  //{
347  m_MenuData.SetCharacterName(m_LastPlayedCharacterID, name);
348  //}
349  if (m_Character.IsDefaultCharacter())
350  {
351  GetGame().GetMenuDefaultCharacterData().SetCharacterName(name);
352  }
353  m_MenuData.SaveCharactersLocal();
354  }
355 
356  // ------------------------------------------------------------
357  vector SnapToGround(vector pos)
358  {
359  float pos_x = pos[0];
360  float pos_z = pos[2];
361  float pos_y = GetGame().SurfaceY(pos_x, pos_z);
362  vector tmp_pos = Vector(pos_x, pos_y, pos_z);
363  tmp_pos[1] = tmp_pos[1] + pos[1];
364 
365  return tmp_pos;
366  }
367 };
GetGame
proto native CGame GetGame()
CALL_CATEGORY_GAMEPLAY
const int CALL_CATEGORY_GAMEPLAY
Definition: tools.c:10
GetDayZGame
DayZGame GetDayZGame()
Definition: dayzgame.c:3729
Managed
TODO doc.
Definition: enscript.c:117
CALL_CATEGORY_GUI
const int CALL_CATEGORY_GUI
Definition: tools.c:9
TIntArray
array< int > TIntArray
Definition: enscript.c:687
PPEManagerStatic
Static component of PPE manager, used to hold the instance.
Definition: ppemanager.c:2
vector
Definition: enconvert.c:105
DayZIntroSceneXbox
Definition: dayzintroscenexbox.c:1
MenuCarEngineSmoke
Definition: menucarenginesmoke.c:1
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
Object
Definition: objecttyped.c:1
BiosUserManager
Definition: biosusermanager.c:16
array< string >
MenuEvaporation
Definition: menuevaporation.c:1
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PPERequesterCategory
PPERequesterCategory
Definition: ppeconstants.c:27
MenuData
Definition: gameplay.c:895
GameConstants
Definition: constants.c:612
Camera
Definition: camera.c:69
PPEffects
Deprecated; 'PPEManager' used instead.
Definition: ppeffects.c:2
Timer
Definition: dayzplayerimplement.c:62
BiosUser
Definition: biosusermanager.c:8
Math
Definition: enmath.c:6
m_TimerUpdate
ref Timer m_TimerUpdate
Definition: huddebug.c:95
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
SEffectManager
Manager class for managing Effect (EffectParticle, EffectSound)
Definition: effectmanager.c:5
Weather
Definition: weather.c:154
OnlineServices
Definition: onlineservices.c:1
Vector
proto native vector Vector(float x, float y, float z)
Vector constructor from components.