Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
dayzintroscene.c
Go to the documentation of this file.
2 {
3  protected ref IntroSceneCharacter m_Character;
4  protected Camera m_Camera;
5  protected vector m_CameraTrans[4];
6  protected vector m_CharacterPos;
7  protected vector m_CharacterRot;
8  protected Weather m_Weather;
9  protected vector m_Target;
10 
11  protected ref OptionsMenu m_OptionsMenu;
12 
13  void DayZIntroScene()
14  {
15  string root_path = "cfgCharacterScenes " + g_Game.GetWorldName();
16 
17  int count = g_Game.ConfigGetChildrenCount(root_path);
18  int index = Math.RandomInt(0, count - 1);
19  string childName;
20  g_Game.ConfigGetChildName(root_path, index, childName);
21 
22  string scene_path = root_path + " " + childName;
23  m_Target = SwapYZ(g_Game.ConfigGetVector(scene_path + " target"));
24  vector position = SwapYZ(g_Game.ConfigGetVector(scene_path + " position"));
25  TIntArray date = new TIntArray;
26  TFloatArray storm = new TFloatArray;
27  g_Game.ConfigGetIntArray(scene_path + " date", date);
28  float fov = g_Game.ConfigGetFloat(scene_path + " fov");
29  float overcast = g_Game.ConfigGetFloat(scene_path + " overcast");
30  float rain = g_Game.ConfigGetFloat(scene_path + " rain");
31  float fog = g_Game.ConfigGetFloat(scene_path + " fog");
32  float windspeed = -1;
33  if ( g_Game.ConfigIsExisting(scene_path + " windspeed") ) windspeed = g_Game.ConfigGetFloat(scene_path + " windspeed");
34  g_Game.ConfigGetFloatArray(scene_path + " storm", storm);
35 
36  World world = g_Game.GetWorld();
37 
38  if (world && date.Count() >= 5)
39  {
40  world.SetDate(date.Get(0), date.Get(1), date.Get(2), date.Get(3), date.Get(4));
41  }
42 
43  GetGame().ObjectDelete( m_Camera );
44  Class.CastTo(m_Camera, g_Game.CreateObject("staticcamera", SnapToGround(position), true)); //Vector(position[0] , position[1] + 1, position[2])
45 
46  Math3D.MatrixIdentity4(m_CameraTrans);
47 
48  if (m_Camera)
49  {
50  //m_Camera.SetPosition(Vector(m_Camera.GetPosition()[0],m_Camera.GetPosition()[1]+0,m_Camera.GetPosition()[2]));
51  m_Camera.LookAt(m_Target);
52  m_Camera.SetFOV(fov);
53  m_Camera.SetFocus(5.0, 0.0); //5.0, 1.0
54 
55  m_Camera.SetActive(true);
56 
57  Math3D.DirectionAndUpMatrix(m_Target - SnapToGround(position), "0 1 0", m_CameraTrans);
58  m_CameraTrans[3] = m_Camera.GetPosition();
59  m_CharacterPos = Vector(0.685547, -0.988281, 3.68823).Multiply4(m_CameraTrans);
60 
61  float pos_x = m_CharacterPos[0];
62  float pos_z = m_CharacterPos[2];
63  float pos_y = GetGame().SurfaceY(pos_x, pos_z);
64  vector ground_demo_pos = Vector(pos_x, pos_y, pos_z);
65  m_CharacterPos = ground_demo_pos;
66 
67  vector to_cam_dir = m_Camera.GetPosition() - m_CharacterPos;
68  m_CharacterRot[0] = Math.Atan2(to_cam_dir[0], to_cam_dir[2]) * Math.RAD2DEG;
69  }
70 
71  m_Weather = g_Game.GetWeather();
72  m_Weather.GetOvercast().SetLimits( overcast, overcast );
73  m_Weather.GetRain().SetLimits( rain, rain );
74  m_Weather.GetFog().SetLimits( fog, fog );
75 
76  m_Weather.GetOvercast().Set( overcast, 0, 0);
77  m_Weather.GetRain().Set( rain, 0, 0);
78  m_Weather.GetFog().Set( fog, 0, 0);
79 
80  if ( storm.Count() == 3 )
81  {
82  m_Weather.SetStorm(storm.Get(0),storm.Get(1),storm.Get(2));
83  }
84 
85  if ( windspeed != -1 )
86  {
87  m_Weather.SetWindSpeed(windspeed);
88  m_Weather.SetWindMaximumSpeed(windspeed);
89  m_Weather.SetWindFunctionParams(1,1,1);
90  }
91 
92  m_Character = new IntroSceneCharacter();
93  m_Character.LoadCharacterData(m_CharacterPos, m_CharacterRot);
94 
95  PPEffects.Init(); //Deprecated, left in for legacy purposes only
96 
97  GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(SetInitPostprocesses);
98  }
99 
100  void ~DayZIntroScene()
101  {
102  if (PPEManagerStatic.GetPPEManager())
103  PPEManagerStatic.GetPPEManager().StopAllEffects(PPERequesterCategory.ALL);
104  }
105 
106  //==============================================
107  // GetIntroSceneCharacter
108  //==============================================
109  IntroSceneCharacter GetIntroCharacter()
110  {
111  return m_Character;
112  }
113 
114  //==============================================
115  // GetIntroCamera
116  //==============================================
117  Camera GetIntroCamera()
118  {
119  return m_Camera;
120  }
121 
122  //==============================================
123  // ResetIntroCamera
124  //==============================================
125  void ResetIntroCamera()
126  {
127  if ( GetIntroCharacter().GetCharacterObj() )
128  {
129  GetIntroCamera().LookAt( GetIntroCharacter().GetPosition() + Vector( 0, 1, 0 ) );
130  //GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater( SceneCharacterSetPos, 250 );
131  }
132  }
133 
135  protected void SetInitPostprocesses()
136  {
137  PPERequesterBank.GetRequester(PPERequester_BurlapSackEffects).Stop();
138  }
139 
140  protected void GetSelectedUserName()
141  {
142  string name;
143  BiosUserManager user_manager = GetGame().GetUserManager();
144  if( user_manager )
145  {
146  BiosUser user = user_manager.GetSelectedUser();
147  if( user )
148  {
149  g_Game.SetPlayerGameName( user.GetName() );
150  return;
151  }
152  }
153  g_Game.SetPlayerGameName(GameConstants.DEFAULT_CHARACTER_NAME);
154  }
155 
156  // ------------------------------------------------------------
157  protected vector SwapYZ(vector vec)
158  {
159  vector tmp;
160  tmp[0] = vec[0];
161  tmp[1] = vec[2];
162  tmp[2] = vec[1];
163 
164  return tmp;
165  }
166 
167  // ------------------------------------------------------------
168  protected vector SnapToGround(vector pos)
169  {
170  float pos_x = pos[0];
171  float pos_z = pos[2];
172  float pos_y = GetGame().SurfaceY(pos_x, pos_z);
173  vector tmp_pos = Vector(pos_x, pos_y, pos_z);
174  tmp_pos[1] = tmp_pos[1] + pos[1];
175 
176  return tmp_pos;
177  }
178 };
GetGame
proto native CGame GetGame()
m_Target
ref ActionTarget m_Target
Definition: actionbase.c:17
TFloatArray
array< float > TFloatArray
Definition: enscript.c:686
Managed
TODO doc.
Definition: enscript.c:117
World
Definition: world.c:1
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
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
vector
Definition: enconvert.c:105
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
DayZIntroScene
Definition: dayzintroscene.c:1
BiosUserManager
Definition: biosusermanager.c:16
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PPERequesterCategory
PPERequesterCategory
Definition: ppeconstants.c:27
GameConstants
Definition: constants.c:612
Camera
Definition: camera.c:69
PPEffects
Deprecated; 'PPEManager' used instead.
Definition: ppeffects.c:2
BiosUser
Definition: biosusermanager.c:8
Math
Definition: enmath.c:6
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
Weather
Definition: weather.c:154
Vector
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
Math3D
Definition: enmath3d.c:27