Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
dayzintroscene.c
Go to the documentation of this file.
2{
4 protected Camera m_Camera;
5 protected vector m_CameraTrans[4];
8 protected Weather m_Weather;
9 protected vector m_Target;
10
11 protected ref OptionsMenu m_OptionsMenu;
12
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 snowfall = g_Game.ConfigGetFloat(scene_path + " snowfall");
32 float fog = g_Game.ConfigGetFloat(scene_path + " fog");
33 float windspeed = -1;
34 if ( g_Game.ConfigIsExisting(scene_path + " windspeed") ) windspeed = g_Game.ConfigGetFloat(scene_path + " windspeed");
35 g_Game.ConfigGetFloatArray(scene_path + " storm", storm);
36
37 World world = g_Game.GetWorld();
38
39 if (world && date.Count() >= 5)
40 {
41 world.SetDate(date.Get(0), date.Get(1), date.Get(2), date.Get(3), date.Get(4));
42 }
43
44 GetGame().ObjectDelete( m_Camera );
45 Class.CastTo(m_Camera, g_Game.CreateObject("staticcamera", SnapToGround(position), true)); //Vector(position[0] , position[1] + 1, position[2])
46
47 Math3D.MatrixIdentity4(m_CameraTrans);
48
49 if (m_Camera)
50 {
51 //m_Camera.SetPosition(Vector(m_Camera.GetPosition()[0],m_Camera.GetPosition()[1]+0,m_Camera.GetPosition()[2]));
52 m_Camera.LookAt(m_Target);
53 m_Camera.SetFOV(fov);
54 m_Camera.SetFocus(5.0, 0.0); //5.0, 1.0
55
56 m_Camera.SetActive(true);
57
58 Math3D.DirectionAndUpMatrix(m_Target - SnapToGround(position), "0 1 0", m_CameraTrans);
59 m_CameraTrans[3] = m_Camera.GetPosition();
60 m_CharacterPos = Vector(0.685547, -0.988281, 3.68823).Multiply4(m_CameraTrans);
61
62 float pos_x = m_CharacterPos[0];
63 float pos_z = m_CharacterPos[2];
64 float pos_y = GetGame().SurfaceY(pos_x, pos_z);
65 vector ground_demo_pos = Vector(pos_x, pos_y, pos_z);
66 m_CharacterPos = ground_demo_pos;
67
68 vector to_cam_dir = m_Camera.GetPosition() - m_CharacterPos;
69 m_CharacterRot[0] = Math.Atan2(to_cam_dir[0], to_cam_dir[2]) * Math.RAD2DEG;
70 }
71
72 m_Weather = g_Game.GetWeather();
73 m_Weather.GetOvercast().SetLimits( overcast, overcast );
74 m_Weather.GetRain().SetLimits( rain, rain );
75 m_Weather.GetSnowfall().SetLimits( snowfall, snowfall );
76 m_Weather.GetFog().SetLimits( fog, fog );
77
78 m_Weather.GetOvercast().Set( overcast, 0, 0);
79 m_Weather.GetRain().Set( rain, 0, 0);
80 m_Weather.GetSnowfall().Set( snowfall, 0, 0);
81 m_Weather.GetFog().Set( fog, 0, 0);
82
83 if ( storm.Count() == 3 )
84 {
85 m_Weather.SetStorm(storm.Get(0),storm.Get(1),storm.Get(2));
86 }
87
88 if ( windspeed != -1 )
89 {
90 m_Weather.SetWindSpeed(windspeed);
91 m_Weather.SetWindMaximumSpeed(windspeed);
92 m_Weather.SetWindFunctionParams(1,1,1);
93 }
94
96 m_Character.LoadCharacterData(m_CharacterPos, m_CharacterRot);
97
98 PPEffects.Init(); //Deprecated, left in for legacy purposes only
99
100 GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(SetInitPostprocesses);
101 }
102
104 {
105 if (PPEManagerStatic.GetPPEManager())
106 PPEManagerStatic.GetPPEManager().StopAllEffects(PPERequesterCategory.ALL);
107 }
108
109 //==============================================
110 // GetIntroSceneCharacter
111 //==============================================
116
117 //==============================================
118 // GetIntroCamera
119 //==============================================
121 {
122 return m_Camera;
123 }
124
125 //==============================================
126 // ResetIntroCamera
127 //==============================================
129 {
131 {
132 GetIntroCamera().LookAt( GetIntroCharacter().GetPosition() + Vector( 0, 1, 0 ) );
133 //GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater( SceneCharacterSetPos, 250 );
134 }
135 }
136
138 protected void SetInitPostprocesses()
139 {
140 PPERequesterBank.GetRequester(PPERequester_BurlapSackEffects).Stop();
141 }
142
143 protected void GetSelectedUserName()
144 {
145 string name;
146 BiosUserManager user_manager = GetGame().GetUserManager();
147 if( user_manager )
148 {
149 BiosUser user = user_manager.GetSelectedUser();
150 if( user )
151 {
152 g_Game.SetPlayerGameName( user.GetName() );
153 return;
154 }
155 }
156 g_Game.SetPlayerGameName(GameConstants.DEFAULT_CHARACTER_NAME);
157 }
158
159 // ------------------------------------------------------------
160 protected vector SwapYZ(vector vec)
161 {
162 vector tmp;
163 tmp[0] = vec[0];
164 tmp[1] = vec[2];
165 tmp[2] = vec[1];
166
167 return tmp;
168 }
169
170 // ------------------------------------------------------------
172 {
173 float pos_x = pos[0];
174 float pos_z = pos[2];
175 float pos_y = GetGame().SurfaceY(pos_x, pos_z);
176 vector tmp_pos = Vector(pos_x, pos_y, pos_z);
177 tmp_pos[1] = tmp_pos[1] + pos[1];
178
179 return tmp_pos;
180 }
181};
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
proto native float SurfaceY(float x, float z)
proto native BiosUserManager GetUserManager()
Super root of all classes in Enforce script.
Definition enscript.c:11
void GetSelectedUserName()
vector m_CharacterPos
vector SwapYZ(vector vec)
IntroSceneCharacter GetIntroCharacter()
ref OptionsMenu m_OptionsMenu
void SetInitPostprocesses()
Since this can get created at the same time as DayZGame, non-static postprocesses need to be deffered...
Camera GetIntroCamera()
vector m_CameraTrans[4]
ref IntroSceneCharacter m_Character
vector m_CharacterRot
vector SnapToGround(vector pos)
TODO doc.
Definition enscript.c:118
PlayerBase GetCharacterObj()
vector GetPosition()
void IntroSceneCharacter()
Definition enmath.c:7
Static component of PPE manager, used to hold the instance.
Definition ppemanager.c:3
Deprecated; 'PPEManager' used instead.
Definition ppeffects.c:3
Definition world.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZGame g_Game
Definition dayzgame.c:3868
proto native CGame GetGame()
array< float > TFloatArray
Definition enscript.c:710
array< int > TIntArray
Definition enscript.c:711
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
const int CALL_CATEGORY_GUI
Definition tools.c:9
PPERequesterCategory