DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
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 World w = g_Game.GetWorld();
16
17 string root_path = "cfgCharacterScenes " + g_Game.GetWorldName();
18
19 int count = g_Game.ConfigGetChildrenCount(root_path);
20 int index = Math.RandomInt(0, count - 1);
21 string childName;
22 g_Game.ConfigGetChildName(root_path, index, childName);
23
24 string scene_path = root_path + " " + childName;
25 m_Target = SwapYZ(g_Game.ConfigGetVector(scene_path + " target"));
26 vector position = SwapYZ(g_Game.ConfigGetVector(scene_path + " position"));
27 TIntArray date = new TIntArray;
28 TFloatArray storm = new TFloatArray;
29 g_Game.ConfigGetIntArray(scene_path + " date", date);
30 float fov = g_Game.ConfigGetFloat(scene_path + " fov");
31 float overcast = g_Game.ConfigGetFloat(scene_path + " overcast");
32 float rain = g_Game.ConfigGetFloat(scene_path + " rain");
33 float fog = g_Game.ConfigGetFloat(scene_path + " fog");
34 float windspeed = -1;
35 if ( g_Game.ConfigIsExisting(scene_path + " windspeed") ) windspeed = g_Game.ConfigGetFloat(scene_path + " windspeed");
36 g_Game.ConfigGetFloatArray(scene_path + " storm", storm);
37
38 World world = g_Game.GetWorld();
39
40 if (world && date.Count() >= 5)
41 {
42 world.SetDate(date.Get(0), date.Get(1), date.Get(2), date.Get(3), date.Get(4));
43 }
44
46 Class.CastTo(m_Camera, g_Game.CreateObject("staticcamera", SnapToGround(position), true)); //Vector(position[0] , position[1] + 1, position[2])
47
49
50 if (m_Camera)
51 {
52 //m_Camera.SetPosition(Vector(m_Camera.GetPosition()[0],m_Camera.GetPosition()[1]+0,m_Camera.GetPosition()[2]));
53 m_Camera.LookAt(m_Target);
54 m_Camera.SetFOV(fov);
55 m_Camera.SetFocus(5.0, 0.0); //5.0, 1.0
56
57 m_Camera.SetActive(true);
58
60 m_CameraTrans[3] = m_Camera.GetPosition();
61 m_CharacterPos = Vector(0.685547, -0.988281, 3.68823).Multiply4(m_CameraTrans);
62
63 float pos_x = m_CharacterPos[0];
64 float pos_z = m_CharacterPos[2];
65 float pos_y = GetGame().SurfaceY(pos_x, pos_z);
66 vector ground_demo_pos = Vector(pos_x, pos_y, pos_z);
67 m_CharacterPos = ground_demo_pos;
68
69 vector to_cam_dir = m_Camera.GetPosition() - m_CharacterPos;
70 m_CharacterRot[0] = Math.Atan2(to_cam_dir[0], to_cam_dir[2]) * Math.RAD2DEG;
71 }
72
73 m_Weather = g_Game.GetWeather();
74 m_Weather.GetOvercast().SetLimits( overcast, overcast );
75 m_Weather.GetRain().SetLimits( rain, rain );
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.GetFog().Set( fog, 0, 0);
81
82 if ( storm.Count() == 3 )
83 {
84 m_Weather.SetStorm(storm.Get(0),storm.Get(1),storm.Get(2));
85 }
86
87 if ( windspeed != -1 )
88 {
89 m_Weather.SetWindSpeed(windspeed);
92 }
93
95 m_Character.LoadCharacterData(m_CharacterPos, m_CharacterRot);
96
97 PPEffects.Init(); //Deprecated, left in for legacy purposes only
98
100 }
101
103 {
106 }
107
108 //==============================================
109 // GetIntroSceneCharacter
110 //==============================================
112 {
113 return m_Character;
114 }
115
116 //==============================================
117 // GetIntroCamera
118 //==============================================
120 {
121 return m_Camera;
122 }
123
124 //==============================================
125 // ResetIntroCamera
126 //==============================================
128 {
130 {
131 GetIntroCamera().LookAt( GetIntroCharacter().GetPosition() + Vector( 0, 1, 0 ) );
132 //GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater( SceneCharacterSetPos, 250 );
133 }
134 }
135
137 protected void SetInitPostprocesses()
138 {
139 PPERequesterBank.GetRequester(PPERequester_BurlapSackEffects).Stop();
140 }
141
142 protected void GetSelectedUserName()
143 {
144 string name;
145 BiosUserManager user_manager = GetGame().GetUserManager();
146 if( user_manager )
147 {
148 BiosUser user = user_manager.GetSelectedUser();
149 if( user )
150 {
151 g_Game.SetPlayerGameName( user.GetName() );
152 return;
153 }
154 }
156 }
157
158 // ------------------------------------------------------------
159 protected vector SwapYZ(vector vec)
160 {
161 vector tmp;
162 tmp[0] = vec[0];
163 tmp[1] = vec[2];
164 tmp[2] = vec[1];
165
166 return tmp;
167 }
168
169 // ------------------------------------------------------------
171 {
172 float pos_x = pos[0];
173 float pos_z = pos[2];
174 float pos_y = GetGame().SurfaceY(pos_x, pos_z);
175 vector tmp_pos = Vector(pos_x, pos_y, pos_z);
176 tmp_pos[1] = tmp_pos[1] + pos[1];
177
178 return tmp_pos;
179 }
180};
DayZGame g_Game
Definition DayZGame.c:3654
PPERequesterCategory
string name
proto native owned string GetName()
proto native BiosUser GetSelectedUser()
Returns the currently selected user.
proto native void ObjectDelete(Object obj)
override ScriptCallQueue GetCallQueue(int call_category)
Definition DayZGame.c:1153
proto native BiosUserManager GetUserManager()
proto native float SurfaceY(float x, float z)
Super root of all classes in Enforce script.
Definition EnScript.c:11
protected vector m_Target
protected vector SwapYZ(vector vec)
protected Weather m_Weather
protected ref IntroSceneCharacter m_Character
protected vector SnapToGround(vector pos)
protected void GetSelectedUserName()
protected ref OptionsMenu m_OptionsMenu
protected void SetInitPostprocesses()
Since this can get created at the same time as DayZGame, non-static postprocesses need to be deffered...
protected vector m_CharacterPos
IntroSceneCharacter GetIntroCharacter()
Camera GetIntroCamera()
protected vector m_CameraTrans[4]
protected vector m_CharacterRot
protected Camera m_Camera
TODO doc.
Definition EnScript.c:118
vector GetPosition()
PlayerBase GetCharacterObj()
void IntroSceneCharacter()
Definition EnMath.c:7
Static component of PPE manager, used to hold the instance.
Definition PPEManager.c:3
static PPEManager GetPPEManager()
Returns the manager instance singleton.
Definition PPEManager.c:27
Deprecated; 'PPEManager' used instead.
Definition PPEffects.c:3
static void Init()
Definition PPEffects.c:52
proto void Call(func fn, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto native void SetStorm(float density, float threshold, float timeOut)
Sets the thunderstorm properties.
proto native void SetWindFunctionParams(float fnMin, float fnMax, float fnSpeed)
Sets function parameters that controls the wind behaviour (change in time).
proto native void SetWindMaximumSpeed(float maxSpeed)
Sets the maximal wind speed in metre per second.
proto native void SetWindSpeed(float speed)
Sets the actual wind speed in metre per second.
proto native Overcast GetOvercast()
Returns an overcast phenomenon object.
proto native Rain GetRain()
Returns a rain phenomenon object.
proto native Fog GetFog()
Returns a fog phenomenon object.
proto native void Set(float forecast, float time=0, float minDuration=0)
Sets the forecast.
proto native void SetLimits(float fnMin, float fnMax)
Sets limits of this phenomenon.
Definition World.c:2
proto native void SetDate(int year, int month, int day, int hour, int minute)
Sets actual ingame world time.
proto vector Multiply4(vector mat[4])
Transforms position.
proto native CGame GetGame()
const string DEFAULT_CHARACTER_NAME
Definition constants.c:823
array< float > TFloatArray
Definition EnScript.c:686
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
array< int > TIntArray
Definition EnScript.c:687
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto void DirectionAndUpMatrix(vector dir, vector up, out vector mat[4])
Creates rotation matrix from direction and up vector.
static void MatrixIdentity4(out vector mat[4])
Creates identity matrix.
Definition EnMath3D.c:233
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
static proto float Atan2(float y, float x)
Returns angle in radians from tangent.
static const float RAD2DEG
Definition EnMath.c:16
const int CALL_CATEGORY_GUI
Definition tools.c:9