game.c 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471
  1. /**
  2. * Game Class provide most "world" or global engine API functions.
  3. */
  4. static int GAME_STORAGE_VERSION = 140;
  5. class CGame
  6. {
  7. // enableDebugMonitor in server config
  8. int m_DebugMonitorEnabled;
  9. ScriptModule GameScript;
  10. private ref array<ref Param> m_ParamCache;
  11. //analytics
  12. ref AnalyticsManagerServer m_AnalyticsManagerServer;
  13. ref AnalyticsManagerClient m_AnalyticsManagerClient;
  14. ref MenuDefaultCharacterData m_CharacterData;
  15. #ifdef DIAG_DEVELOPER
  16. ref array<ComponentEnergyManager> m_EnergyManagerArray;
  17. void EnableEMPlugs(bool enable)
  18. {
  19. for (int i = 0; i < GetGame().m_EnergyManagerArray.Count(); ++i)
  20. {
  21. if (GetGame().m_EnergyManagerArray[i])
  22. GetGame().m_EnergyManagerArray[i].SetDebugPlugs(enable);
  23. }
  24. }
  25. #endif
  26. void CGame()
  27. {
  28. Math.Randomize(-1);
  29. LogManager.Init();
  30. m_ParamCache = new array<ref Param>;
  31. m_ParamCache.Insert(null);
  32. //analytics
  33. m_AnalyticsManagerServer = new AnalyticsManagerServer;
  34. m_AnalyticsManagerClient = new AnalyticsManagerClient;
  35. //m_CharacterData = new MenuCharacrerData;
  36. // actual script version - increase by one when you make changes
  37. StorageVersion(GAME_STORAGE_VERSION);
  38. #ifdef DIAG_DEVELOPER
  39. m_EnergyManagerArray = new array<ComponentEnergyManager>;
  40. #endif
  41. if (!IsDedicatedServer())
  42. {
  43. SEffectManager.Init();
  44. AmmoEffects.Init();
  45. VONManager.Init();
  46. if (!IsMultiplayer())
  47. {
  48. SEffectManager.InitServer();
  49. }
  50. }
  51. else
  52. {
  53. SEffectManager.InitServer();
  54. }
  55. }
  56. private void ~CGame()
  57. {
  58. // Clean these up even if it is dedicated server, just to be safe
  59. SEffectManager.Cleanup();
  60. AmmoEffects.Cleanup();
  61. VONManager.CleanupInstance();
  62. // Is initialized in StartupEvent
  63. ParticleManager.CleanupInstance();
  64. }
  65. proto native WorkspaceWidget GetWorkspace();
  66. proto native WorkspaceWidget GetLoadingWorkspace();
  67. //!
  68. /**
  69. \brief Called when some system event occur.
  70. @param eventTypeId event type.
  71. @param params Param object, cast to specific param class to get parameters for particular event.
  72. */
  73. void OnEvent(EventType eventTypeId, Param params)
  74. {
  75. }
  76. //PLM Type: 0 == RESUMED, 1 == SUSPENDED
  77. void OnProcessLifetimeChanged(int plmtype)
  78. {
  79. }
  80. void OnLicenseChanged()
  81. {
  82. }
  83. /**
  84. \brief Called after creating of CGame instance
  85. */
  86. void OnAfterCreate()
  87. {
  88. }
  89. /**
  90. \brief Called when recieving focus (windows)
  91. */
  92. void OnActivateMessage()
  93. {
  94. }
  95. /**
  96. \brief Called when loosing focus (windows)
  97. */
  98. void OnDeactivateMessage()
  99. {
  100. }
  101. /**
  102. \brief Called once before game update loop starts, ret value indicates if init was done in scripts, otherwise it is done in the engine
  103. */
  104. bool OnInitialize()
  105. {
  106. return false;
  107. }
  108. /**
  109. \brief Called when inputs is not possible (Steam overlay active or something), all internal script variables should be reset here!
  110. */
  111. void OnDeviceReset()
  112. {
  113. }
  114. /**
  115. \brief Called on World update
  116. @param doSim False when simulation is paused, True otherwise
  117. @param timeslice time elapsed from last call
  118. */
  119. void OnUpdate(bool doSim, float timeslice)
  120. {
  121. }
  122. /**
  123. \brief Called on World update after simulation of entities
  124. @param doSim False when simulation is paused, True otherwise
  125. @param timeslice time elapsed from last call
  126. */
  127. void OnPostUpdate(bool doSim, float timeslice)
  128. {
  129. }
  130. /**
  131. \brief Called when key is pressed
  132. @param key direct input key code (DIK)
  133. */
  134. void OnKeyPress(int key)
  135. {
  136. }
  137. /**
  138. \brief Called when key is released
  139. @param key direct input key code (DIK)
  140. */
  141. void OnKeyRelease(int key)
  142. {
  143. }
  144. /**
  145. \brief Called when mouse button is pressed
  146. @param button - number of button \ref Mouse
  147. */
  148. void OnMouseButtonPress(int button)
  149. {
  150. }
  151. /**
  152. \brief Called when mouse button is released
  153. @param button - number of button \ref Mouse
  154. */
  155. void OnMouseButtonRelease(int button)
  156. {
  157. }
  158. /**
  159. \brief create custom main menu part (submenu)
  160. */
  161. UIScriptedMenu CreateScriptedMenu( int id ) { }
  162. /**
  163. \brief create custom window part
  164. */
  165. UIScriptedWindow CreateScriptedWindow( int id ) { }
  166. /**
  167. \brief Called after remote procedure call is recieved for this object
  168. @param target object on which remote procedure is called, when NULL, RPC is evaluated by CGame as global
  169. @param rpc_type user defined identification of RPC
  170. @param ctx read context for params
  171. */
  172. void OnRPC(PlayerIdentity sender, Object target, int rpc_type, ParamsReadContext ctx)
  173. {
  174. }
  175. /**
  176. \brief Sets exit code and quits in the right moment
  177. */
  178. proto native void RequestExit( int code );
  179. /**
  180. \brief Sets exit code and restart in the right moment
  181. */
  182. proto native void RequestRestart(int code);
  183. /**
  184. \brief Returns if the application is focused on PC, returns true always on console
  185. */
  186. proto native bool IsAppActive();
  187. /**
  188. \brief Gets the server address. (from client)
  189. */
  190. proto bool GetHostAddress( out string address, out int port );
  191. /**
  192. \brief Gets the server name. (from client)
  193. */
  194. proto owned string GetHostName();
  195. /**
  196. \brief Gets the server data. (from client)
  197. */
  198. proto GetServersResultRow GetHostData();
  199. /**
  200. \brief Connects to IsServer
  201. @param IpAddress of the server
  202. @param port of the server set to 0 for default port
  203. @param password of the server
  204. \return 0 on success, error code from ErrorModuleHandler on not success
  205. */
  206. proto native int Connect( UIScriptedMenu parent , string IpAddress, int port, string password );
  207. /**
  208. \brief Connects to last success network session
  209. \return 0 on success, error code from ErrorModuleHandler on not success
  210. */
  211. proto native int ConnectLastSession( UIScriptedMenu parent , int selectedCharacter = -1 );
  212. /**
  213. \brief Disconnects from current multiplayer session
  214. */
  215. proto native void DisconnectSession();
  216. /**
  217. \brief Forces disconnect from current multiplayer session even if not yet in the game
  218. */
  219. proto native void DisconnectSessionForce();
  220. // profile functions
  221. /**
  222. \brief Gets array of strings from profile variable
  223. @param name of the variable
  224. @param values output values
  225. \n usage:
  226. @code
  227. TStringArray lastInventoryArray = new TStringArray;
  228. GetGame().GetProfileStringList("lastInventory", lastInventoryArray);
  229. @endcode
  230. */
  231. proto native void GetProfileStringList(string name, out TStringArray values);
  232. /**
  233. \brief Gets string from profile variable
  234. @param name of the variable
  235. @param value output value
  236. \return true when successful
  237. */
  238. proto bool GetProfileString(string name, out string value);
  239. /**
  240. \brief Sets array of strings to profile variable
  241. @param name of the variable
  242. @param values to set
  243. */
  244. proto native void SetProfileStringList(string name, TStringArray values);
  245. /**
  246. \brief Sets string to profile variable
  247. @param name of the variable
  248. @param value to set
  249. */
  250. proto native void SetProfileString(string name, string value);
  251. /**
  252. \brief Saves profile on disk.
  253. */
  254. proto native void SaveProfile();
  255. /**
  256. \brief Gets current player name
  257. @param name output value
  258. */
  259. proto void GetPlayerName(out string name);
  260. /**
  261. \brief Gets current player name. If length of player name is grater than maxLength, then it is omitted and append ellipsis
  262. @param maxLength - max chars in name
  263. @param name - output value of player name with 'maxLength' characters and then ellipsis "..."
  264. */
  265. proto void GetPlayerNameShort(int maxLength, out string name);
  266. /**
  267. \brief Sets current player name
  268. @param name
  269. */
  270. proto native void SetPlayerName(string name);
  271. /**
  272. \brief Assign player entity to client (in multiplayer)
  273. \note Works only on server
  274. @param name
  275. */
  276. proto native Entity CreatePlayer(PlayerIdentity identity, string name, vector pos, float radius, string spec);
  277. /**
  278. \brief Selects player's controlled object
  279. @param identity identity used in MP (use NULL in singleplayer)
  280. @param player object which should be controlled by player
  281. \note We can use only instances of DayZPlayer now
  282. */
  283. proto native void SelectPlayer(PlayerIdentity identity, Object player);
  284. /**
  285. \brief returns player's network id from identity id in out parameters
  286. @param identity PlayerIdentity.id used in MP (use NULL in singleplayer)
  287. @param networkIdLowBits lower bits of 64bit network id
  288. @param networkIdHighBits higher bits of 64bit network id
  289. \note Usable only on server
  290. */
  291. proto void GetPlayerNetworkIDByIdentityID( int playerIdentityID, out int networkIdLowBits, out int networkIdHightBits );
  292. /**
  293. \brief Returns entity identified by network id
  294. @param networkIdLowBits identity used in MP (use NULL in singleplayer)
  295. @param networkIdHighBits object which should be controlled by player
  296. */
  297. proto native Object GetObjectByNetworkId( int networkIdLowBits, int networkIdHighBits );
  298. /**
  299. \brief Static objects cannot be replicated by default (there are too many objects on the map). Use this method when you want to replicate some scripted variables. Cannot be called in object's constructor, because networking is not initialized yet
  300. @param object static object to replicate
  301. @return false, if registration wasn't successful or when object is already registered
  302. */
  303. proto native bool RegisterNetworkStaticObject(Object object);
  304. /**
  305. \brief Creates spectator object (mostly cameras)
  306. @param identity identity used in MP (use NULL in singleplayer)
  307. @param spectatorObjType classname for spectator object (like cameras)
  308. @param position where to create spectator instance
  309. */
  310. proto native void SelectSpectator(PlayerIdentity identity, string spectatorObjType, vector position);
  311. /**
  312. \brief Updates spectator position on server = position of network bubble
  313. @param position
  314. */
  315. proto native void UpdateSpectatorPosition(vector position);
  316. /**
  317. \brief Inform client about logout time (creates logout screen on specified client)
  318. \note Works only on server
  319. @param player object which is logging out
  320. @param time length of logout
  321. */
  322. proto native void SendLogoutTime(Object player, int time);
  323. /**
  324. \brief Destroy player info and disconnect
  325. \note Works only on server
  326. */
  327. proto native void DisconnectPlayer(PlayerIdentity identity, string uid = "");
  328. /**
  329. \brief Add player to reconnect cache to be able to rejoin character still existing in the world
  330. \note Works only on server and no database requests are sent
  331. @param identity of player
  332. */
  333. proto native void AddToReconnectCache(PlayerIdentity identity);
  334. /**
  335. \brief Remove player from reconnect cache
  336. \note Works only on server
  337. @param uid of the player
  338. */
  339. proto native void RemoveFromReconnectCache(string uid);
  340. /**
  341. \brief Remove all player from reconnect cache
  342. \note Works only on server
  343. */
  344. proto native void ClearReconnectCache();
  345. /**
  346. \brief Set actual storage version - for next save
  347. */
  348. proto native void StorageVersion( int iVersion );
  349. /**
  350. \brief Returns actual storage version - loading
  351. */
  352. proto native int LoadVersion();
  353. /**
  354. \brief Returns actual storage version - saving
  355. */
  356. proto native int SaveVersion();
  357. /**
  358. \brief Returns current daytime on server
  359. */
  360. proto native float GetDayTime();
  361. // config functions
  362. /**
  363. \brief Get string value from config on path.
  364. @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  365. @param value output
  366. \return true on success
  367. */
  368. proto bool ConfigGetText(string path, out string value);
  369. /**
  370. \brief Get raw string value from config on path.
  371. @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  372. @param value output in raw format (localization keys '$STR_' are not translated)
  373. \return true on success
  374. \note use 'FormatRawConfigStringKeys' method to change localization keys to script-friendly
  375. */
  376. proto bool ConfigGetTextRaw(string path, out string value);
  377. /**
  378. \brief Get string value from config on path.
  379. @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  380. \return value output string
  381. */
  382. string ConfigGetTextOut(string path)
  383. {
  384. string ret_s;
  385. ConfigGetText(path, ret_s);
  386. return ret_s;
  387. }
  388. /**
  389. \brief Changes localization key format to script-friendly format.
  390. @param original config string.
  391. \return value output string with '$' substituted to script-friendly '#'. If not found, does nothing.
  392. */
  393. bool FormatRawConfigStringKeys(inout string value)
  394. {
  395. int ret;
  396. ret = value.Replace("$STR_","#STR_");
  397. return ret > 0;
  398. }
  399. /**
  400. \brief Get name of the p3d file of the given class name.
  401. @param class name of the desired object
  402. \return Name of the object's p3d file (without the '.p3d' suffix)
  403. */
  404. string GetModelName(string class_name)
  405. {
  406. if ( class_name != "" )
  407. {
  408. string cfg = "CfgVehicles " + class_name + " model";
  409. string model_path;
  410. if ( GetGame().ConfigGetText(cfg, model_path) )
  411. {
  412. int to_substring_end = model_path.Length() - 4; // -4 to leave out the '.p3d' suffix
  413. int to_substring_start = 0;
  414. // Currently we have model path. To get the name out of it we need to parse this string from the end and stop at the first found '\' sign
  415. for (int i = to_substring_end; i > 0; i--)
  416. {
  417. string sign = model_path.Get(i);
  418. if ( sign == "\\" )
  419. {
  420. to_substring_start = i + 1;
  421. break
  422. }
  423. }
  424. string model_name = model_path.Substring(to_substring_start, to_substring_end - to_substring_start);
  425. return model_name;
  426. }
  427. }
  428. return "UNKNOWN_P3D_FILE";
  429. }
  430. /**
  431. \brief Get float value from config on path.
  432. @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  433. \return value
  434. */
  435. proto native float ConfigGetFloat(string path);
  436. /**
  437. \brief Get vector value from config on path.
  438. @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  439. \return value
  440. */
  441. proto native vector ConfigGetVector(string path);
  442. /**
  443. \brief Get int value from config on path.
  444. @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  445. \return value
  446. */
  447. proto native int ConfigGetInt(string path);
  448. /**
  449. \brief Returns type of config value
  450. @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  451. \return one of constants CT_INT, CT_FLOAT, CT_STRING, CT_ARRAY, CT_CLASS, CT_OTHER
  452. */
  453. proto native int ConfigGetType(string path);
  454. /**
  455. \brief Get array of strings from config on path.
  456. @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  457. @param value output
  458. \n usage :
  459. @code
  460. TStringArray characterAnimations = new TStringArray;
  461. GetGame().ConfigGetTextArray("CfgMovesMaleSdr2 States menu_idleUnarmed0 variantsPlayer", characterAnimations);
  462. @endcode
  463. */
  464. proto native void ConfigGetTextArray(string path, out TStringArray values);
  465. /**
  466. \brief Get array of raw strings from config on path.
  467. @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  468. @param value output in raw format (localization keys '$STR_' are not translated)
  469. \n usage :
  470. @code
  471. TStringArray characterAnimations = new TStringArray;
  472. GetGame().ConfigGetTextArrayRaw("CfgMovesMaleSdr2 States menu_idleUnarmed0 variantsPlayer", characterAnimations);
  473. @endcode
  474. \note use 'FormatRawConfigStringKeys' method to change localization keys to script-friendly
  475. */
  476. proto native void ConfigGetTextArrayRaw(string path, out TStringArray values);
  477. /**
  478. \brief Get array of floats from config on path.
  479. @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  480. @param value output
  481. */
  482. proto native void ConfigGetFloatArray(string path, out TFloatArray values);
  483. /**
  484. \brief Get array of integers from config on path.
  485. @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  486. @param value output
  487. */
  488. proto native void ConfigGetIntArray(string path, out TIntArray values);
  489. /**
  490. \brief Get name of subclass in config class on path.
  491. @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  492. @param index of subclass in class
  493. @param name output
  494. \return true on success, false if path or child is not found
  495. */
  496. proto bool ConfigGetChildName(string path, int index, out string name);
  497. /**
  498. \brief Get name of base class of config class on path.
  499. @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  500. @param name output
  501. \return true on success, false if path or base is not exists
  502. */
  503. proto bool ConfigGetBaseName(string path, out string base_name);
  504. /**
  505. \brief Get count of subclasses in config class on path.
  506. @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  507. @param index of parameter in class
  508. @param name output
  509. \return true on success, false if path or child is not found
  510. */
  511. proto native int ConfigGetChildrenCount(string path);
  512. proto native bool ConfigIsExisting(string path);
  513. proto native void ConfigGetFullPath(string path, out TStringArray full_path);
  514. proto native void ConfigGetObjectFullPath(Object obj, out TStringArray full_path);
  515. proto native void GetModInfos(notnull out array<ref ModInfo> modArray);
  516. proto native bool GetModToBeReported();
  517. /**
  518. \brief Converts array of strings into single string.
  519. \param Array of strings like {"All", "AllVehicles", "Land"}
  520. \return Converts given array into something lile "All AllVehicles Land".
  521. @code
  522. ???
  523. @endcode
  524. */
  525. string ConfigPathToString(TStringArray array_path)
  526. {
  527. string return_path = "";
  528. int count = array_path.Count();
  529. for (int i = 0; i < count; i++)
  530. {
  531. return_path += array_path.Get(i);
  532. if ( i < count - 1 )
  533. {
  534. return_path += " ";
  535. }
  536. }
  537. return return_path;
  538. }
  539. /**
  540. \brief Get command line parameter value.
  541. @param name of parameter
  542. @param value output
  543. \return true when parameter exists, false otherwise
  544. \n usage :
  545. @code
  546. // you run e.g.: DayZInt.exe -scriptDebug=true
  547. string value;
  548. if (GetGame().CommandlineGetParam("scriptDebug", value) && value == "true")
  549. {
  550. Print("Script debugging on!");
  551. }
  552. @endcode
  553. */
  554. proto bool CommandlineGetParam(string name, out string value);
  555. proto native void CopyToClipboard(string text);
  556. proto void CopyFromClipboard(out string text);
  557. proto native void BeginOptionsVideo();
  558. proto native void EndOptionsVideo();
  559. proto native void AdminLog(string text);
  560. // entity functions
  561. /**
  562. \brief Preload objects with certain type in certain distance from camera.
  563. @param type of objects which should be preloaded
  564. @param distance from camera in which objects should be preloaded
  565. \return true on success
  566. */
  567. proto native bool PreloadObject( string type, float distance );
  568. proto native Object CreateStaticObjectUsingP3D(string p3dFilename, vector position, vector orientation, float scale = 1.0, bool createLocal = false);
  569. /**
  570. \brief Creates object of certain type
  571. @param type of objects to create
  572. @param pos position where to create object
  573. @param create_local if True, object is not spawned on clients only on server
  574. @param init_ai if creating object is LightAI class, by this param is initialised AI or not
  575. \return new Object
  576. */
  577. proto native Object CreateObject( string type, vector pos, bool create_local = false, bool init_ai = false, bool create_physics = true );
  578. proto native SoundOnVehicle CreateSoundOnObject(Object source, string sound_name, float distance, bool looped, bool create_local = false);
  579. proto native SoundWaveOnVehicle CreateSoundWaveOnObject(Object source, SoundObject soundObject, AbstractWave soundWave);
  580. /**
  581. \brief Creates object of certain type
  582. @param type of objects to create
  583. @param pos position where to create object
  584. @param iFlags are used to setup object and/ or spawn behavior
  585. @param iRotation are used to setup object rotation on spawn (or default if not specified)
  586. \return new Object
  587. */
  588. proto native Object CreateObjectEx( string type, vector pos, int iFlags, int iRotation = RF_DEFAULT );
  589. proto native void ObjectDelete( Object obj );
  590. proto native void ObjectDeleteOnClient( Object obj );
  591. proto native void RemoteObjectDelete( Object obj ); /// RemoteObjectDelete - deletes only remote object (unregisters from network). do not use if not sure what you do
  592. proto native void RemoteObjectTreeDelete( Object obj ); /// RemoteObjectDelete - deletes only remote object tree (unregisters from network). do not use if not sure what you do
  593. proto native void RemoteObjectCreate( Object obj ); /// RemoteObjectCreate - postponed registration of network object (and creation of remote object). do not use if not sure what you do
  594. proto native void RemoteObjectTreeCreate( Object obj ); /// RemoteObjectTreeCreate - postponed registration of network object tree (and creation of remote objects). do not use if not sure what you do
  595. proto native int ObjectRelease( Object obj );
  596. proto void ObjectGetType( Object obj, out string type );
  597. proto void ObjectGetDisplayName( Object obj, out string name );
  598. proto native vector ObjectGetSelectionPosition(Object obj, string name);
  599. proto native vector ObjectGetSelectionPositionLS(Object obj, string name);
  600. proto native vector ObjectGetSelectionPositionMS(Object obj, string name);
  601. proto native vector ObjectGetSelectionPositionWS(Object obj, string name);
  602. proto native vector ObjectModelToWorld(Object obj, vector modelPos);
  603. proto native vector ObjectWorldToModel(Object obj, vector worldPos);
  604. //! returns true if player can access item's cargo/attachments (check only distance)
  605. proto native bool IsObjectAccesible(EntityAI item, Man player);
  606. #ifdef DIAG_DEVELOPER
  607. proto native void ReloadShape(Object obj);
  608. #endif
  609. // input
  610. proto native Input GetInput();
  611. // camera
  612. proto native vector GetCurrentCameraPosition();
  613. proto native vector GetCurrentCameraDirection();
  614. // sound
  615. proto native AbstractSoundScene GetSoundScene();
  616. // noise
  617. proto native NoiseSystem GetNoiseSystem();
  618. // inventory
  619. proto native bool AddInventoryJuncture(Man player, notnull EntityAI item, InventoryLocation dst, bool test_dst_occupancy, int timeout_ms);
  620. bool AddInventoryJunctureEx(Man player, notnull EntityAI item, InventoryLocation dst, bool test_dst_occupancy, int timeout_ms)
  621. {
  622. bool result = AddInventoryJuncture(player, item, dst, test_dst_occupancy, timeout_ms/*10000000*/);
  623. #ifdef ENABLE_LOGGING
  624. if ( LogManager.IsInventoryReservationLogEnable() )
  625. {
  626. Debug.InventoryReservationLog("STS = " + player.GetSimulationTimeStamp() + " result: " + result + " item:" + item + " dst: " + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "AddInventoryJuncture",player.ToString() );
  627. }
  628. #endif
  629. //Print("Juncture - STS = " + player.GetSimulationTimeStamp() + " item:" + item + " dst: " + InventoryLocation.DumpToStringNullSafe(dst));
  630. return result;
  631. }
  632. //Has inventory juncture for any player
  633. proto native bool HasInventoryJunctureItem(notnull EntityAI item);
  634. proto native bool HasInventoryJunctureDestination(Man player, notnull InventoryLocation dst);
  635. proto native bool AddActionJuncture(Man player, notnull EntityAI item, int timeout_ms);
  636. proto native bool ExtendActionJuncture(Man player, notnull EntityAI item, int timeout_ms);
  637. proto native bool ClearJuncture(Man player, notnull EntityAI item);
  638. bool ClearJunctureEx(Man player, notnull EntityAI item)
  639. {
  640. #ifdef ENABLE_LOGGING
  641. if ( LogManager.IsInventoryReservationLogEnable() )
  642. {
  643. Debug.InventoryReservationLog("STS = " + player.GetSimulationTimeStamp()+ " item:" + item, "n/a" , "n/a", "ClearJuncture",player.ToString() );
  644. }
  645. #endif
  646. return ClearJuncture( player, item);
  647. }
  648. // support
  649. //! Delevoper only: Executes Enforce Script expression, if there is an error, is printed into the script console
  650. proto native bool ExecuteEnforceScript(string expression, string mainFnName);
  651. //! Delevoper only: Dump all script allocations
  652. proto native void DumpInstances(bool csvFormatting);
  653. proto native bool ScriptTest();
  654. //! Get list of all debug modes
  655. proto native void GetDiagModeNames(out TStringArray diag_names);
  656. //! Set specific debug mode
  657. proto native void SetDiagModeEnable(int diag_mode, bool enabled);
  658. //! Gets state of specific debug mode
  659. proto native bool GetDiagModeEnable(int diag_mode);
  660. //! Get list of all debug draw modes
  661. proto native void GetDiagDrawModeNames(out TStringArray diag_names);
  662. //! Set debug draw mode
  663. proto native void SetDiagDrawMode(int diag_draw_mode);
  664. //! Gets current debug draw mode
  665. proto native int GetDiagDrawMode();
  666. //! If physics extrapolation is enabled, always true on retail release builds
  667. proto native bool IsPhysicsExtrapolationEnabled();
  668. /**
  669. \brief Returns average FPS of last 16 frames
  670. @return fps in milliseconds
  671. */
  672. proto native float GetFps();
  673. /**
  674. \brief Returns current time from start of the game
  675. @return time in seconds
  676. */
  677. proto native float GetTickTime();
  678. proto void GetInventoryItemSize(InventoryItem item, out int width, out int height);
  679. /**
  680. \brief Returns list of all objects in circle "radius" around position "pos"
  681. @param pos
  682. @param radius
  683. @param objects output array
  684. */
  685. proto native void GetObjectsAtPosition(vector pos, float radius, out array<Object> objects, out array<CargoBase> proxyCargos);
  686. /**
  687. \brief Returns list of all objects in sphere "radius" around position "pos"
  688. @param pos
  689. @param radius
  690. @param objects output array
  691. */
  692. proto native void GetObjectsAtPosition3D(vector pos, float radius, out array<Object> objects, out array<CargoBase> proxyCargos);
  693. proto native World GetWorld();
  694. proto void GetWorldName( out string world_name );
  695. string GetWorldName()
  696. {
  697. string world_name;
  698. g_Game.GetWorldName(world_name);
  699. return world_name;
  700. }
  701. proto native bool VerifyWorldOwnership( string sWorldName );
  702. proto native bool GoBuyWorldDLC( string sWorldName );
  703. proto void FormatString( string format, string params[], out string output);
  704. proto void GetVersion( out string version );
  705. proto native UIManager GetUIManager();
  706. proto native DayZPlayer GetPlayer();
  707. proto native void GetPlayers( out array<Man> players );
  708. DayZPlayer GetPlayerByIndex(int index = 0)
  709. {
  710. array<Man> players();
  711. GetPlayers(players);
  712. if (index >= players.Count())
  713. return null;
  714. return DayZPlayer.Cast(players[index]);
  715. }
  716. //! Stores login userdata as parameters which are sent to server
  717. proto native void StoreLoginData(ParamsWriteContext ctx);
  718. //! Returns the direction where the mouse points, from the camera view
  719. proto native vector GetPointerDirection();
  720. //! Transforms position in world to position in screen in pixels as x, y component of vector, z parameter represents distance between camera and world_pos
  721. proto native vector GetWorldDirectionFromScreen(vector world_pos);
  722. //! Transforms position in world to position in screen in pixels as x, y component of vector, z parameter represents distance between camera and world_pos
  723. proto native vector GetScreenPos(vector world_pos);
  724. //! Transforms position in world to position in screen in percentage (0.0 - 1.0) as x, y component of vector, z parameter represents distance between camera and world_pos
  725. proto native vector GetScreenPosRelative(vector world_pos);
  726. //! Return singleton of MenuData class - at main menu contains characters played with current profile.
  727. proto native MenuData GetMenuData();
  728. /**
  729. \brief Initiate remote procedure call. When called on client, RPC is evaluated on server; When called on server, RPC is executed on all clients
  730. @param target object on which remote procedure is called, when NULL, RPC is evaluated by CGame as global
  731. @param rpc_type user defined identification of RPC
  732. @param params custom params array
  733. @param recipient specified client to send RPC to. If NULL, RPC will be send to all clients (specifying recipient increase security and decrease network traffic)
  734. @code
  735. const int RPC_LOW_BLOOD_PRESSURE_EFFECT = 0;
  736. ...
  737. // on server side, after blood pressure of player is low...
  738. Param1<float> p = new Param1<float>(m_blood_pressure);
  739. array<param> params = new array<param>;
  740. params.Insert(p);
  741. GetGame().RPC(player, RPC_LOW_BLOOD_PRESSURE_EFFECT, params);
  742. // or shortcut
  743. GetGame().RPCSingleParam(player, RPC_LOW_BLOOD_PRESSURE_EFFECT, p);
  744. ...
  745. // on client
  746. class PlayerBase
  747. {
  748. // override OnRPC function
  749. void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
  750. {
  751. // dont forget to propagate this call trough class hierarchy!
  752. super.OnRPC(rpc_type, ctx);
  753. switch(rpc_type)
  754. {
  755. case RPC_LOW_BLOOD_PRESSURE_EFFECT:
  756. Param1<float> p = Param1<float>(0);
  757. if (ctx.Read(p))
  758. {
  759. float blood_pressure = p.param1;
  760. float effect_intensity = 1.0 - blood_pressure;
  761. ShowFancyScreenEffect(effect_intensity);
  762. }
  763. break;
  764. }
  765. }
  766. }
  767. @endcode
  768. */
  769. proto native void RPC(Object target, int rpcType, notnull array<ref Param> params, bool guaranteed,PlayerIdentity recipient = null);
  770. //! see CGame.RPC
  771. void RPCSingleParam(Object target, int rpc_type, Param param, bool guaranteed, PlayerIdentity recipient = null)
  772. {
  773. m_ParamCache.Set(0, param);
  774. RPC(target, rpc_type, m_ParamCache, guaranteed, recipient);
  775. }
  776. //! Not actually an RPC, as it will send it only to yourself
  777. proto native void RPCSelf(Object target, int rpcType, notnull array<ref Param> params);
  778. void RPCSelfSingleParam(Object target, int rpcType, Param param)
  779. {
  780. m_ParamCache.Set(0, param);
  781. RPCSelf(target, rpcType, m_ParamCache);
  782. }
  783. //! Use for profiling code from start to stop, they must match have same name, look wiki pages for more info: https://confluence.bistudio.com/display/EN/Profiler
  784. proto native void ProfilerStart(string name);
  785. //! Use for profiling code from start to stop, they must match have same name, look wiki pages for more info: https://confluence.bistudio.com/display/EN/Profiler
  786. proto native void ProfilerStop(string name);
  787. /**
  788. \brief Prints text into game chat.
  789. \param text to print
  790. \param colorClass ??
  791. \n usage :
  792. @code
  793. GetGame().Chat("Item splitted", "colorAction");
  794. @endcode
  795. */
  796. proto native void Chat(string text, string colorClass);
  797. proto native void ChatMP(Man recipient, string text, string colorClass);
  798. proto native void ChatPlayer(string text);
  799. /**
  800. \brief Mutes voice of source player to target player
  801. @param muteUID uid of player you want to mute
  802. @param playerUID uid of player that (doesnt't) want to hear muteUID
  803. */
  804. proto native void MutePlayer(string muteUID, string playerUID, bool mute);
  805. /**
  806. \brief Mute all players for listenerId
  807. @param listenerId uid of player
  808. @param mute true, if player can not listen anybody. Otherwise false.
  809. */
  810. proto native void MuteAllPlayers(string listenerId, bool mute);
  811. /**
  812. \brief Enable/disable VoN for target player
  813. @param player in question
  814. @param enable sets if player can use VoN
  815. */
  816. proto native void EnableVoN(Object player, bool enable);
  817. /**
  818. \brief Enable/disable VoN effect (only on server)
  819. @param player in question
  820. @param voice effect (VoiceEffectMumbling = 1, VoiceEffectExtortion = 2, VoiceEffectObstruction = 4)
  821. @param enable or disable effect
  822. */
  823. proto native void SetVoiceEffect(Object player, int effect, bool enable);
  824. /**
  825. \brief Set voice level of VoN (only on client) (VoiceLevelWhisper = 0, VoiceLevelNormal = 1, VoiceLevelShout = 2)
  826. @param level of voice
  827. */
  828. proto native void SetVoiceLevel(int level);
  829. /**
  830. \brief Get voice level of VoN (on both client and server) (VoiceLevelWhisper = 0, VoiceLevelNormal = 1, VoiceLevelShout = 2)
  831. */
  832. proto native int GetVoiceLevel(Object player = null);
  833. /**
  834. \brief Enable microphone to locally capture audio from user. Audio heard does NOT automatically get transmitted over network
  835. @param enable enables or disabled listening
  836. */
  837. proto native void EnableMicCapture(bool enable);
  838. /**
  839. \brief Returns whether mic is currently capturing audio from user
  840. */
  841. proto native bool IsMicCapturing();
  842. /**
  843. \brief Returns whether user is currently in a voice party (currently only supported on xbox)
  844. */
  845. proto native bool IsInPartyChat();
  846. // mission
  847. proto native Mission GetMission();
  848. proto native void SetMission(Mission mission);
  849. //! Starts intro
  850. proto native void StartRandomCutscene(string world);
  851. //! Starts mission (equivalent for SQF playMission). You MUST use double slash \\
  852. proto native void PlayMission(string path);
  853. //! Create only enforce script mission, used for mission script reloading
  854. proto protected native void CreateMission(string path);
  855. proto native void RestartMission();
  856. //! Returns to main menu, leave world empty for using last mission world
  857. proto native void AbortMission();
  858. proto native void RespawnPlayer();
  859. proto native bool CanRespawnPlayer();
  860. proto native void SetLoginTimerFinished();
  861. proto native void SetMainMenuWorld(string world);
  862. proto native owned string GetMainMenuWorld();
  863. //! Logout methods
  864. proto native void LogoutRequestTime();
  865. proto native void LogoutRequestCancel();
  866. proto native bool IsMultiplayer();
  867. proto native bool IsClient();
  868. proto native bool IsServer();
  869. /**
  870. \brief Robust check which is preferred than the above, as it is valid much sooner
  871. \note You may want to use #ifdef SERVER instead for slight performance gain...
  872. */
  873. proto native bool IsDedicatedServer();
  874. //! Server config parsing. Returns 0 if not found.
  875. proto native int ServerConfigGetInt(string name);
  876. // Internal build
  877. proto native bool IsDebug();
  878. //#ifdef PLATFORM_XBOX
  879. static bool IsDigitalCopy()
  880. {
  881. return OnlineServices.IsGameActive(false);
  882. }
  883. //#endif
  884. /*bool IsNewMenu()
  885. {
  886. return m_ParamNewMenu;
  887. }*/
  888. void SetDebugMonitorEnabled(int value)
  889. {
  890. m_DebugMonitorEnabled = value;
  891. }
  892. bool IsDebugMonitor()
  893. {
  894. return IsServer() && m_DebugMonitorEnabled;
  895. }
  896. proto native void GetPlayerIndentities( out array<PlayerIdentity> identities );
  897. proto native float SurfaceY(float x, float z);
  898. proto native float SurfaceRoadY(float x, float z, RoadSurfaceDetection rsd = RoadSurfaceDetection.LEGACY);
  899. proto native float SurfaceRoadY3D(float x, float y, float z, RoadSurfaceDetection rsd);
  900. //! Returns: Y position the surface was found
  901. proto float SurfaceGetType(float x, float z, out string type);
  902. //! Y input: Maximum Y to trace down from; Returns: Y position the surface was found
  903. proto float SurfaceGetType3D(float x, float y, float z, out string type);
  904. proto void SurfaceUnderObject(notnull Object object, out string type, out int liquidType);
  905. proto void SurfaceUnderObjectEx(notnull Object object, out string type, out string impact, out int liquidType);
  906. proto void SurfaceUnderObjectByBone(notnull Object object, int boneType, out string type, out int liquidType);
  907. proto native float SurfaceGetNoiseMultiplier(Object directHit, vector pos, int componentIndex);
  908. proto native vector SurfaceGetNormal(float x, float z);
  909. proto native float SurfaceGetSeaLevelMin();
  910. proto native float SurfaceGetSeaLevelMax();
  911. proto native float SurfaceGetSeaLevel();
  912. proto native bool SurfaceIsSea(float x, float z);
  913. proto native bool SurfaceIsPond(float x, float z);
  914. proto native float GetWaterDepth(vector posWS);
  915. proto native void UpdatePathgraphRegion(vector regionMin, vector regionMax);
  916. //! Returns the largest height difference between the given positions
  917. float GetHighestSurfaceYDifference( array<vector> positions)
  918. {
  919. float high = -9999999;
  920. float low = 99999999;
  921. for (int i = 0; i < positions.Count(); i++)
  922. {
  923. vector pos = positions.Get(i);
  924. pos[1] = SurfaceRoadY( pos[0], pos[2]);
  925. float y = pos[1];
  926. if ( y > high )
  927. high = y;
  928. if ( y < low )
  929. low = y;
  930. ;
  931. }
  932. return high - low;
  933. }
  934. //! Returns tilt of the ground on the given position in degrees, so you can use this value to rotate any item according to terrain.
  935. vector GetSurfaceOrientation(float x, float z)
  936. {
  937. vector normal = GetGame().SurfaceGetNormal(x, z);
  938. vector angles = normal.VectorToAngles();
  939. angles[1] = angles[1]+270; // This fixes rotation of item so it stands vertically. Feel free to change, but fix existing use cases.
  940. //Hack because setorientation and similar functions break and flip stuff upside down when using exactly this vector ¯\_(ツ)_/¯ (note: happens when surface is flat)
  941. if (angles == "0 540 0")
  942. angles = "0 0 0";
  943. return angles;
  944. }
  945. //! Checks if the surface is digable
  946. bool IsSurfaceDigable(string surface)
  947. {
  948. return ConfigGetInt("CfgSurfaces " + surface + " isDigable");
  949. }
  950. bool GetSurfaceDigPile(string surface, out string result)
  951. {
  952. return ConfigGetText("CfgSurfaces " + surface + " digPile", result);
  953. }
  954. //! Checks if the surface is fertile
  955. bool IsSurfaceFertile(string surface)
  956. {
  957. return ConfigGetInt("CfgSurfaces " + surface + " isFertile");
  958. }
  959. int CorrectLiquidType(int liquidType)
  960. {
  961. if (liquidType == -1)
  962. return LIQUID_NONE;
  963. if (liquidType == 0)
  964. return LIQUID_SALTWATER;
  965. return liquidType;
  966. }
  967. void SurfaceUnderObjectCorrectedLiquid(notnull Object object, out string type, out int liquidType)
  968. {
  969. SurfaceUnderObject(object, type, liquidType);
  970. liquidType = CorrectLiquidType(liquidType);
  971. }
  972. void SurfaceUnderObjectExCorrectedLiquid(notnull Object object, out string type, out string impact, out int liquidType)
  973. {
  974. SurfaceUnderObjectEx(object, type, impact, liquidType);
  975. liquidType = CorrectLiquidType(liquidType);
  976. }
  977. void SurfaceUnderObjectByBoneCorrectedLiquid(notnull Object object, int boneType, out string type, out int liquidType)
  978. {
  979. SurfaceUnderObjectByBone(object, boneType, type, liquidType);
  980. liquidType = CorrectLiquidType(liquidType);
  981. }
  982. void UpdatePathgraphRegionByObject(Object object)
  983. {
  984. if ( object )
  985. {
  986. vector pos = object.GetPosition();
  987. vector min_max[2];
  988. float radius = object.ClippingInfo ( min_max );
  989. vector min = Vector ( pos[0] - radius, pos[1], pos[2] - radius );
  990. vector max = Vector ( pos[0] + radius, pos[1], pos[2] + radius );
  991. UpdatePathgraphRegion( min, max );
  992. }
  993. }
  994. /**
  995. \brief Finds all objects that are in choosen oriented bounding box (OBB)
  996. \param center \p vector, center of OBB
  997. \param orientation \p vector, direction (front vector), used for calculation of OBB rotation
  998. \param edgeLength \p vector, sizes of whole box
  999. \param excludeObjects \p array<Object>, objects that should be excluded from collision check
  1000. \param collidedObjects \p array<Object>, out parameter, objects that collided with OBB
  1001. \returns \p bool, \p true if at least one object collided with OBB, \p false otherwise
  1002. \note Object that doesn't have collision geometry will be ignored, as this only uses geometry
  1003. @code
  1004. vector pos = GetPosition();
  1005. vector orientation = GetOrientation();
  1006. vector size = "10 4 8";
  1007. array<Object> excluded_objects = new array<Object>;
  1008. excluded_objects.Insert(this);
  1009. array<Object> nearby_objects = new array<Object>;
  1010. if(GetGame().IsBoxColliding( pos, orientation, size, excluded_objects, nearby_objects))
  1011. {
  1012. for (int i = 0, c = nearby_objects.Count(); i < c; ++i)
  1013. {
  1014. PrintString("object " + i.ToString());
  1015. }
  1016. }
  1017. @endcode
  1018. */
  1019. proto native bool IsBoxColliding(vector center, vector orientation, vector edgeLength, array<Object> excludeObjects, array<Object> collidedObjects = NULL);
  1020. /**
  1021. \brief Finds all objects with geometry iType that are in choosen oriented bounding box (OBB)
  1022. \param center \p vector, center of OBB
  1023. \param orientation \p vector, direction (front vector), used for calculation of OBB rotation
  1024. \param edgeLength \p vector, sizes of whole box
  1025. \param iPrimaryType \p int, type of intersection, possible values ObjIntersectFire(0), ObjIntersectView(1), ObjIntersectGeom(2), ObjIntersectIFire(3),
  1026. ObjIntersectNone(4)
  1027. \param iSecondaryType \p int, type of intersection, possible values ObjIntersectFire(0), ObjIntersectView(1), ObjIntersectGeom(2), ObjIntersectIFire(3),
  1028. ObjIntersectNone(4)
  1029. \param excludeObjects \p array<Object>, objects that should be excluded from collision check
  1030. \param collidedObjects \p array<Object>, out parameter, objects that collided with OBB
  1031. \returns \p bool, \p true if at least one object collided with OBB, \p false otherwise
  1032. @code
  1033. vector pos = GetPosition();
  1034. vector orientation = GetOrientation();
  1035. vector size = "10 4 8";
  1036. array<Object> excluded_objects = new array<Object>;
  1037. excluded_objects.Insert(this);
  1038. array<Object> nearby_objects = new array<Object>;
  1039. if(GetGame().IsBoxCollidingGeometry( pos, orientation, size, ObjIntersectView, ObjIntersectGeom, excluded_objects, nearby_objects))
  1040. {
  1041. for (int i = 0, c = nearby_objects.Count(); i < c; ++i)
  1042. {
  1043. PrintString("object " + i.ToString());
  1044. }
  1045. }
  1046. @endcode
  1047. */
  1048. proto native bool IsBoxCollidingGeometry(vector center, vector orientation, vector edgeLength, int iPrimaryType, int iSecondaryType, array<Object> excludeObjects, array<Object> collidedObjects = NULL);
  1049. proto native bool IsBoxCollidingGeometryProxy(notnull BoxCollidingParams params, array<Object> excludeObjects, array<ref BoxCollidingResult> collidedObjects = NULL);
  1050. //! Returns weather controller object.
  1051. proto native Weather GetWeather();
  1052. //! Sets custom camera camera EV. range: -50.0..50.0? //TODO
  1053. proto native void SetEVUser(float value);
  1054. proto native void OverrideDOF(bool enable, float focusDistance, float focusLength, float focusLengthNear, float blur, float focusDepthOffset);
  1055. proto native void AddPPMask(float ndcX, float ndcY, float ndcRadius, float ndcBlur);
  1056. proto native void ResetPPMask();
  1057. /*!
  1058. override inventory light
  1059. \param diffuse directional light
  1060. \param ambient ambient light
  1061. \param ground ground light
  1062. \param dir direction of light, Vector(0,0,1) is from camera
  1063. */
  1064. proto native void OverrideInventoryLights(vector diffuse, vector ambient, vector ground, vector dir);
  1065. /*!
  1066. set night vission parameters (set to zero when to disable it)
  1067. \param lightIntensityMul multiplicator of lights intensity
  1068. \param noiseIntensity intensity of noise PP
  1069. */
  1070. proto native void NightVissionLightParams(float lightIntensityMul, float noiseIntensity);
  1071. proto native void OpenURL(string url);
  1072. //! Initialization of damage effects
  1073. proto native void InitDamageEffects(Object effect);
  1074. //-----------------------------------------------------------------------------
  1075. // persitence
  1076. //-----------------------------------------------------------------------------
  1077. //! Returns EntityAI by its persistent ID parts
  1078. //! or null if entity with given persistent ID does not exists.
  1079. /*!
  1080. This function returns valid data only inside AfterLoad event.
  1081. Do not use this in anywhere else.
  1082. Its main purpose is only for keep track on object connections
  1083. after server restarts, all data related to this function are deleted
  1084. when server initialization is done.
  1085. */
  1086. proto native EntityAI GetEntityByPersitentID( int b1, int b2, int b3, int b4 );
  1087. //-----------------------------------------------------------------------------
  1088. /**
  1089. \brief Returns is class name inherited from parent class name
  1090. \param cfg_class_name \p Config Class name ("Animal_CervusElaphus")
  1091. \param cfg_parent_name \p Parent Config Class name ("DZ_LightAI")
  1092. \returns \p bool is class name inherited from parent class name
  1093. @code
  1094. bool is_kind = GetGame().IsKindOf( "Animal_CervusElaphus", "DZ_LightAI");
  1095. PrintString(ToString(is_kind));
  1096. >> 1
  1097. @endcode
  1098. */
  1099. bool IsKindOf(string cfg_class_name, string cfg_parent_name)
  1100. {
  1101. TStringArray full_path = new TStringArray;
  1102. ConfigGetFullPath("CfgVehicles " + cfg_class_name, full_path);
  1103. if (full_path.Count() == 0)
  1104. {
  1105. ConfigGetFullPath("CfgAmmo " + cfg_class_name, full_path);
  1106. }
  1107. if (full_path.Count() == 0)
  1108. {
  1109. ConfigGetFullPath("CfgMagazines " + cfg_class_name, full_path);
  1110. }
  1111. if (full_path.Count() == 0)
  1112. {
  1113. ConfigGetFullPath("cfgWeapons " + cfg_class_name, full_path);
  1114. }
  1115. if (full_path.Count() == 0)
  1116. {
  1117. ConfigGetFullPath("CfgNonAIVehicles " + cfg_class_name, full_path);
  1118. }
  1119. cfg_parent_name.ToLower();
  1120. for (int i = 0; i < full_path.Count(); i++)
  1121. {
  1122. string tmp = full_path.Get(i);
  1123. tmp.ToLower();
  1124. if (tmp == cfg_parent_name)
  1125. {
  1126. return true;
  1127. }
  1128. }
  1129. return false;
  1130. }
  1131. /**
  1132. \brief Returns is object inherited from parent class name
  1133. \param object \p Object
  1134. \param cfg_parent_name \p Parent Config Class name ("DZ_LightAI")
  1135. \returns \p bool is object inherited from parent class name
  1136. @code
  1137. bool is_kind = GetGame().IsKindOf( my_animal, "DZ_LightAI");
  1138. PrintString(ToString(is_kind));
  1139. >> 1
  1140. @endcode
  1141. */
  1142. bool ObjectIsKindOf(Object object, string cfg_parent_name)
  1143. {
  1144. TStringArray full_path = new TStringArray;
  1145. ConfigGetObjectFullPath(object, full_path);
  1146. cfg_parent_name.ToLower();
  1147. for (int i = 0; i < full_path.Count(); i++)
  1148. {
  1149. string tmp = full_path.Get(i);
  1150. tmp.ToLower();
  1151. if (tmp == cfg_parent_name)
  1152. {
  1153. return true;
  1154. }
  1155. }
  1156. return false;
  1157. }
  1158. /**
  1159. Searches given config path (config_path) for the given member (searched_member) and returns its index.
  1160. \nReturns -1 if not found.
  1161. \n usage:
  1162. * @code
  1163. * int skinning_class_index = g_Game.ConfigFindClassIndex(cfgPath_animal, "Skinning");
  1164. * @endcode
  1165. */
  1166. int ConfigFindClassIndex(string config_path, string searched_member)
  1167. {
  1168. int class_count = ConfigGetChildrenCount(config_path);
  1169. for (int index = 0; index < class_count; index++)
  1170. {
  1171. string found_class = "";
  1172. ConfigGetChildName(config_path, index, found_class);
  1173. if (found_class == searched_member)
  1174. {
  1175. return index;
  1176. }
  1177. }
  1178. return -1;
  1179. }
  1180. //!returns mission time in milliseconds
  1181. proto int GetTime();
  1182. /**
  1183. Returns CallQueue for certain category
  1184. @param call_category call category, valid values are:
  1185. \n CALL_CATEGORY_SYSTEM - calls & timers in this queue are processed every time without any restrictions
  1186. \n CALL_CATEGORY_GUI - calls & timers in this queue are processed when GUI is enabled (even during pase game)
  1187. \n CALL_CATEGORY_GAMEPLAY - calls & timers in this queue are processed only during mission, when game is not paused
  1188. \n usage:
  1189. * @code
  1190. * GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(this, "Refresh"); // calls "Refresh" function on "this" with no arguments
  1191. * GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(this, "Show", new Param1<bool>(true)); // calls "Show" function on "this" with one bool argument
  1192. * GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(this, "SetPos", new Param2<float, float>(0.2, 0.5)); // calls "SetPos" function on "this" with two float arguments
  1193. * @endcode
  1194. */
  1195. ScriptCallQueue GetCallQueue(int call_category) {}
  1196. ScriptInvoker GetUpdateQueue(int call_category) {}
  1197. ScriptInvoker GetPostUpdateQueue(int call_category) {}
  1198. /**
  1199. Returns TimerQueue for certain category
  1200. @param call_category call category, valid values are:
  1201. \n CALL_CATEGORY_SYSTEM - calls & timers in this queue are processed every time without any restrictions
  1202. \n CALL_CATEGORY_GUI - calls & timers in this queue are processed when GUI is enabled (even during pase game)
  1203. \n CALL_CATEGORY_GAMEPLAY - calls & timers in this queue are processed only during mission, when game is not paused
  1204. */
  1205. TimerQueue GetTimerQueue(int call_category) {}
  1206. /**
  1207. Returns DragQueue. Callbacks are called on mouse move until mouse button is released, then the queue is cleaned.
  1208. */
  1209. DragQueue GetDragQueue() {}
  1210. //!returns class name of first valid survivor (TODO address confusing naming?)
  1211. string CreateDefaultPlayer() {}
  1212. //!returns class name of random survivor (TODO address confusing naming?)
  1213. string CreateRandomPlayer() {}
  1214. //!outputs array of all valid survivor class names
  1215. TStringArray ListAvailableCharacters() {}
  1216. bool IsInventoryOpen()
  1217. {
  1218. }
  1219. proto native BiosUserManager GetUserManager();
  1220. //! Return DLC service (service for entitlement keys for unlock content)
  1221. proto native ContentDLC GetContentDLCService();
  1222. //! Returns true when current mission is Main Menu
  1223. bool IsMissionMainMenu()
  1224. {
  1225. return (g_Game.GetMissionState() == DayZGame.MISSION_STATE_MAINMENU);
  1226. }
  1227. MenuDefaultCharacterData GetMenuDefaultCharacterData(bool fill_data = true)
  1228. {
  1229. //Print("GetMenuDefaultCharacterData");
  1230. //DumpStack();
  1231. //if used on server, creates an empty container to be filled by received data
  1232. if (!m_CharacterData)
  1233. {
  1234. m_CharacterData = new MenuDefaultCharacterData;
  1235. if (fill_data)
  1236. GetGame().GetMenuData().RequestGetDefaultCharacterData(); //fills the structure
  1237. }
  1238. return m_CharacterData;
  1239. }
  1240. //Analytics Manager
  1241. AnalyticsManagerServer GetAnalyticsServer()
  1242. {
  1243. return m_AnalyticsManagerServer;
  1244. }
  1245. AnalyticsManagerClient GetAnalyticsClient()
  1246. {
  1247. return m_AnalyticsManagerClient;
  1248. }
  1249. };