game.c 50 KB

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