DayZ 1.24
Loading...
Searching...
No Matches
proto.c
Go to the documentation of this file.
1
4/*
5 Function/method modifiers:
6 proto - prototyping of internal function (C++ side)
7 native - native call convention of internal function (C++ side)
8 volatile - internal function that may call back to script (hint for
9 compiler that context need to be saved on stack)
10 private - function may not be called from script
11 event - hint for tools that the function should be exposed as
12 Entity script event.
13
14 Variable modifiers:
15 owned - modifier for returing internal functions. Tells to script-VM,
16 that returning variable (string or array) must not be released
17 out - modifier for function parameters. It tells that variable will
18 be changed by function call (used mainly by internal functions)
19 inout - modifier for function parameters. It tells that variable will
20 be used and then changed by function call (used mainly by internal functions)
21
22 const - constants. May not be modified.
23 reference - hint for tools (Material editor), that the variable may be used
24 as parameter in material
25*/
26
27
28/*===================================================================*/
29/* Enforce engine API */
30/*===================================================================*/
31
32//placeholder
34{
35 int type;
36 int slot;
37};
38
40{
41 int type;
42 int handle;
43};
44
45
46typedef int[] vobject;
47
49{
51}
52
53#ifdef ENF_DONE
54
55 //------------------------------------------
56 // SOUND API
57 //------------------------------------------
58 //TODO:
59 typedef int[] HSOUND;
60
61 //flags
63 //SFX_ONCE
65 //SFX_MUSIC
67 //SFX_AMBIENT
69 //SFX_3D
71 //SFX_DISCARDABLE
73 //SFX_DIRECTIONAL
75 //SFX_DOPPLER
77 //SFX_STATIC
79 //SFX_NOTEST
80
81 //proto volatile HSOUND PlaySound(int soundScene, IEntity source, string sshader, int flags);
82 proto volatile native void EndSound(HSOUND snd);
83
84 //volume 0...1. Logaritmic scale
85 proto native int SetSoundVolume(HSOUND sound, float volume)
86 proto native int SetSoundFrequency(HSOUND sound, int freq)
87
88
89 //returns 0, if soundid is not valid
90 proto native int GetSoundLength(HSOUND sound)
91
92 //returns -1, if soundid is not valid
93 proto native int GetSoundPosition(HSOUND sound)
94
95 //defaultne se pouziva EAX prostredi nadefinovane v mape, ale lze ho prebit touto fci.
96 // Mohou se michat dve ruzna prostredi v pomeru danem hodnotou fade (fade==0 -> 100% env1, fade==1 -> 100% env2).
97 //pokud chceme michat aktualni prostredi s nejakym jinym, lze pouzit zastupny nazev "$current".
98 //Tim lze dosahnout nafadovani vlastniho prostredi, kdyz fci postupne volame napr. takto:
99 //SetEAXEnvironment("$current", "Drugged", fade)
100 //pricemz hodnota fade postupne narusta od nuly do jedne
101 //proto native bool SetEAXEnvironment(string env1, string env2, float fade)
102#endif
103
104class PacketOutputAdapter
105{
106 proto native void WriteBool(bool value); //size: 1 byte
107 proto native void WriteInt(int value); //size: 4 bytes
108 proto native void WriteFloat(float value); //size: 4 bytes
109 proto native void WriteString(string value); //size: n bytes (string length)
110 proto native void WriteVector(vector value); //size: 12 bytes
111 proto native void WriteMatrixAsQuaternionVector(vector mat[4]); //size: 28 bytes
112 proto native void WriteIntAsByte(int value); //write int in range <-128, 127> size: 1 byte
113 proto native void WriteIntAsUByte(int value); //write int in range <0, 255> size: 1 byte
114 proto native void WriteIntAsHalf(int value); //write int in range <-32768, 32768> size: 2 bytes
115 proto native void WriteIntAsUHalf(int value); //write int in range <0, 65535> size: 2 bytes
116 proto native void WriteFloatAsByte(float value, float min, float max); // size: 1 byte
117 proto native void WriteFloatAsHalf(float value, float min, float max); // size: 2 bytes
118};
119
121{
122 proto native bool ReadBool();
123 proto native int ReadInt();
124 proto native float ReadFloat();
125 proto string ReadString();
126 proto native vector ReadVector();
128 proto native int ReadIntAsByte();
129 proto native int ReadIntAsUByte();
130 proto native int ReadIntAsHalf();
131 proto native int ReadIntAsUHalf();
132 proto native float ReadFloatAsByte(float min, float max);
133 proto native float ReadFloatAsHalf(float min, float max);
135
142proto native void MakeScreenshot(string name);
143
147proto native int GetFPS();
148
149//----------------------------------------------
152
157proto native int LoadSkyPresets(string presetsFile);
158
163proto native int InitSky(string presetName);
164
171proto native int SetSkyPreset(string presetName, float stormy, float dayTime);
172
182proto native int LerpSkyPreset(string presetName1, string presetName2, float dayTime, float stormy1, float stormy2, float lerpVal);
183
197proto native int LerpSkyPreset3(string presetName1, string presetName2, string presetName3, float dayTime, float stormy1, float stormy2, float stormy3, float w1, float w2, float w3);
198
204proto native void SetSkyUserPlanets(bool enabled);
205
212proto native bool SetSkyPlanet(int index, float azimuthDeg, float zenithDeg);
213
219proto native bool SetSkyPlanetSize(int index, float angleDeg);
220
231proto native void SetStarsObserverTime(int year, int month, int day, int hour, int minute, float sec, int offsetSec);
232
238proto native void SetStarsObserverPosition(float latitudeDeg, float longitudeDeg);
239
244proto native void SetRealStarAutoUpdate(bool update);
245
246
251proto native void SetNightLayerRotMatrix(vector mat[3]);
252
258proto native void SetStarsRotMatrix(vector mat[3]);
259
261
262//----------------------------------------------
265typedef int[] Material;
266
268{
274 proto bool SetParam(string propertyName, void value);
275
280 proto native void ResetParam(string propertyName);
281
287 proto native int GetParamIndex(string paramName);
288
294 proto void SetParamByIndex(int paramIndex, void value);
295};
297
298int VectortoRGBA(vector vec, float h)
299{
300 float x, y, z;
301 int r, g, b, a, rgba;
302
303 x = vec[0];
304 y = vec[1];
305 z = vec[2];
306
307 x = x * 127.0 + 128.0;
308 y = y * 127.0 + 128.0;
309 z = z * 127.0 + 128.0;
310 h = h * 255.0;
311
312 a = (int)h << 24;
313 r = (int)x << 16;
314 g = (int)y << 8;
315 b = z;
316
317 return r | g | b | a;
318}
319
320
321//-----------------------------------------------------------------
322int ARGB(int a, int r, int g, int b)
323{
324 a = a << 24;
325 r = r << 16;
326 g = g << 8;
327 return a | r | g | b;
328}
329
330//-----------------------------------------------------------------
332int ARGBF(float fa, float fr, float fg, float fb)
333{
334 return ARGB((float)(fa * 255.0), (float)(fr * 255.0), (float)(fg * 255.0), (float)(fb * 255.0));
335}
336
337//-----------------------------------------------------------------
338int AWHITE(int a)
339{
340 return a << 24 | 0xffffff;
341}
342
343//-----------------------------------------------------------------
344int LerpARGB(int c1, int c2)
345{
346 int cb1, cb2;
347 const int cmask = 0x00ff00ff;
348
349 cb1 = c1 >> 8 & cmask;
350 cb2 = c2 >> 8 & cmask;
351 cb1 = cb1 + cb2 >> 1;
352
353 c1 = c1 & cmask;
354 c2 = c2 & cmask;
355 c1 = c1 + c2 >> 1;
356
357 return cb1 << 8 | c1;
358}
359
360//-------------------------------------------------------------------------
361class Link<Class T>
362{
363 proto private native void Init(T init);
364 proto private native Object Get();
365
366 void Release()
367 {
368 T obj = Get();
369 if (obj)
370 obj.Release();
371 }
372 void Link(T init)
373 {
374 Init(init);
375 }
376
377 T Ptr()
378 {
379 return Get();
380 }
381
382 bool IsNull()
383 {
384 if (!Get())
385 return true;
386
387 return false;
388 }
389};
390
Param3 int
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
override Widget Init()
Definition DayZGame.c:120
Icon x
Icon y
enum MagnumStableStateID init
array< ref PlayerStatBase > Get()
proto native void SetSoundVolume(float vol, float time)
int slot
Definition proto.c:36
int type
Definition proto.c:35
Super root of all classes in Enforce script.
Definition EnScript.c:11
proto native void ResetParam(string propertyName)
proto bool SetParam(string propertyName, void value)
proto void SetParamByIndex(int paramIndex, void value)
proto native int GetParamIndex(string paramName)
proto void ReadMatrixAsQuaternionVector(vector mat[4])
proto native bool ReadBool()
proto native float ReadFloatAsByte(float min, float max)
proto native vector ReadVector()
proto string ReadString()
proto native float ReadFloat()
proto native float ReadFloatAsHalf(float min, float max)
proto native int ReadIntAsHalf()
proto native int ReadIntAsUHalf()
proto native int ReadIntAsByte()
proto native int ReadIntAsUByte()
proto native int ReadInt()
int type
Definition proto.c:41
int handle
Definition proto.c:42
proto native IEntitySource ToEntitySource()
proto native void WriteIntAsUHalf(int value)
proto native void SetRealStarAutoUpdate(bool update)
proto native int LoadSkyPresets(string presetsFile)
int ARGB(int a, int r, int g, int b)
Definition proto.c:322
proto native void SetSkyUserPlanets(bool enabled)
proto native int SetSkyPreset(string presetName, float stormy, float dayTime)
proto native void SetStarsObserverTime(int year, int month, int day, int hour, int minute, float sec, int offsetSec)
proto native void WriteIntAsHalf(int value)
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Definition proto.c:332
proto native void MakeScreenshot(string name)
int VectortoRGBA(vector vec, float h)
Definition proto.c:298
proto native void SetStarsRotMatrix(vector mat[3])
int[] Material
Definition proto.c:265
proto native void WriteVector(vector value)
int[] vobject
Definition proto.c:46
proto native bool SetSkyPlanet(int index, float azimuthDeg, float zenithDeg)
proto native void WriteInt(int value)
proto native int InitSky(string presetName)
proto native int LerpSkyPreset3(string presetName1, string presetName2, string presetName3, float dayTime, float stormy1, float stormy2, float stormy3, float w1, float w2, float w3)
proto native void WriteFloatAsByte(float value, float min, float max)
proto native int GetFPS()
proto native void WriteMatrixAsQuaternionVector(vector mat[4])
proto native void WriteString(string value)
proto native int LerpSkyPreset(string presetName1, string presetName2, float dayTime, float stormy1, float stormy2, float lerpVal)
proto native void SetNightLayerRotMatrix(vector mat[3])
proto native bool SetSkyPlanetSize(int index, float angleDeg)
proto native void WriteIntAsUByte(int value)
class PacketInputAdapter WriteBool
proto native void SetStarsObserverPosition(float latitudeDeg, float longitudeDeg)
proto native void WriteIntAsByte(int value)
proto native void WriteFloatAsHalf(float value, float min, float max)
int AWHITE(int a)
Definition proto.c:338
proto native void WriteFloat(float value)
int LerpARGB(int c1, int c2)
Definition proto.c:344