Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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
33 class AnimEvent
34 {
35  int type;
36  int slot;
37 };
38 
40 {
41  int type;
42  int handle;
43 };
44 
45 
46 typedef int[] vobject;
47 
48 class vobject
49 {
50  proto native IEntitySource ToEntitySource();
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 
104 class 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();
127  proto void ReadMatrixAsQuaternionVector(vector mat[4]);
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);
134 };
135 
142 proto native void MakeScreenshot(string name);
143 
147 proto native int GetFPS();
148 
149 //----------------------------------------------
152 
157 proto native int LoadSkyPresets(string presetsFile);
158 
163 proto native int InitSky(string presetName);
164 
171 proto native int SetSkyPreset(string presetName, float stormy, float dayTime);
172 
182 proto native int LerpSkyPreset(string presetName1, string presetName2, float dayTime, float stormy1, float stormy2, float lerpVal);
183 
197 proto native int LerpSkyPreset3(string presetName1, string presetName2, string presetName3, float dayTime, float stormy1, float stormy2, float stormy3, float w1, float w2, float w3);
198 
204 proto native void SetSkyUserPlanets(bool enabled);
205 
212 proto native bool SetSkyPlanet(int index, float azimuthDeg, float zenithDeg);
213 
219 proto native bool SetSkyPlanetSize(int index, float angleDeg);
220 
231 proto native void SetStarsObserverTime(int year, int month, int day, int hour, int minute, float sec, int offsetSec);
232 
238 proto native void SetStarsObserverPosition(float latitudeDeg, float longitudeDeg);
239 
244 proto native void SetRealStarAutoUpdate(bool update);
245 
246 
251 proto native void SetNightLayerRotMatrix(vector mat[3]);
252 
258 proto native void SetStarsRotMatrix(vector mat[3]);
259 
261 
262 //----------------------------------------------
265 typedef int[] Material;
266 
267 class Material
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 
298 int 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 //-----------------------------------------------------------------
322 int 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 //-----------------------------------------------------------------
332 int 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 //-----------------------------------------------------------------
338 int AWHITE(int a)
339 {
340  return a << 24 | 0xffffff;
341 }
342 
343 //-----------------------------------------------------------------
344 int 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 //-------------------------------------------------------------------------
361 class 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 
Release
private void Release(vector pos)
Definition: easteregg.c:185
WriteInt
proto native void WriteInt(int value)
LerpARGB
int LerpARGB(int c1, int c2)
Definition: proto.c:344
IEntitySource
Definition: enentity.c:15
WriteIntAsUByte
proto native void WriteIntAsUByte(int value)
SetSoundVolume
proto native void SetSoundVolume(float vol, float time)
LerpSkyPreset3
proto native int LerpSkyPreset3(string presetName1, string presetName2, string presetName3, float dayTime, float stormy1, float stormy2, float stormy3, float w1, float w2, float w3)
SetNightLayerRotMatrix
proto native void SetNightLayerRotMatrix(vector mat[3])
vobject
Definition: proto.c:48
AWHITE
int AWHITE(int a)
Definition: proto.c:338
GetFPS
proto native int GetFPS()
y
Icon y
SetSkyPlanet
proto native bool SetSkyPlanet(int index, float azimuthDeg, float zenithDeg)
SoundEvent
Definition: proto.c:39
SetSkyPreset
proto native int SetSkyPreset(string presetName, float stormy, float dayTime)
InitSky
proto native int InitSky(string presetName)
SetRealStarAutoUpdate
proto native void SetRealStarAutoUpdate(bool update)
PacketInputAdapter
Definition: proto.c:120
WriteIntAsHalf
proto native void WriteIntAsHalf(int value)
WriteVector
proto native void WriteVector(vector value)
vector
Definition: enconvert.c:105
SetStarsObserverTime
proto native void SetStarsObserverTime(int year, int month, int day, int hour, int minute, float sec, int offsetSec)
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
Material
Definition: proto.c:267
WriteIntAsUHalf
proto native void WriteIntAsUHalf(int value)
Object
Definition: objecttyped.c:1
SetStarsObserverPosition
proto native void SetStarsObserverPosition(float latitudeDeg, float longitudeDeg)
SetSkyUserPlanets
proto native void SetSkyUserPlanets(bool enabled)
WriteIntAsByte
proto native void WriteIntAsByte(int value)
SetStarsRotMatrix
proto native void SetStarsRotMatrix(vector mat[3])
Get
array< ref PlayerStatBase > Get()
Definition: playerstatspco.c:103
ARGBF
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Definition: proto.c:332
VectortoRGBA
int VectortoRGBA(vector vec, float h)
Definition: proto.c:298
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
init
enum MagnumStableStateID init
x
Icon x
WriteFloatAsByte
proto native void WriteFloatAsByte(float value, float min, float max)
int
Param3 int
WriteMatrixAsQuaternionVector
proto native void WriteMatrixAsQuaternionVector(vector mat[4])
vobject
int[] vobject
Definition: proto.c:46
Material
int[] Material
Definition: proto.c:265
AnimEvent
Definition: proto.c:33
LerpSkyPreset
proto native int LerpSkyPreset(string presetName1, string presetName2, float dayTime, float stormy1, float stormy2, float lerpVal)
SetSkyPlanetSize
proto native bool SetSkyPlanetSize(int index, float angleDeg)
WriteFloatAsHalf
proto native void WriteFloatAsHalf(float value, float min, float max)
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
LoadSkyPresets
proto native int LoadSkyPresets(string presetsFile)
WriteString
proto native void WriteString(string value)
MakeScreenshot
proto native void MakeScreenshot(string name)
WriteFloat
proto native void WriteFloat(float value)
ARGB
int ARGB(int a, int r, int g, int b)
Definition: proto.c:322
WriteBool
class PacketInputAdapter WriteBool