gameplay.c 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541
  1. /** @file */
  2. /// tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
  3. enum InventoryTraversalType
  4. {
  5. PREORDER,
  6. INORDER,
  7. POSTORDER,
  8. LEVELORDER
  9. };
  10. const int INDEX_NOT_FOUND = -1;
  11. //-----------------------------------------------------------------------------
  12. typedef Serializer ParamsReadContext;
  13. typedef Serializer ParamsWriteContext;
  14. /**
  15. \brief Class for sending RPC over network
  16. @code
  17. // example sending
  18. void Send()
  19. {
  20. ScriptRPC rpc = new ScriptRPC();
  21. rpc.Write(645);
  22. rpc.Write("hello");
  23. array<float> farray = {1.2, 5.6, 8.1};
  24. rpc.Write(farray);
  25. rpc.Send(m_Player, ERPCs.RPC_TEST, true, m_Player.GetIdentity());
  26. }
  27. // example receive
  28. void OnRPC(ParamsReadContext ctx)
  29. {
  30. int num;
  31. string text;
  32. array<float> farray;
  33. ctx.Read(num);
  34. ctx.Read(text);
  35. ctx.Read(farray);
  36. }
  37. @endcode
  38. */
  39. class JsonSerializer: Serializer
  40. {
  41. void JsonSerializer() {}
  42. void ~JsonSerializer() {}
  43. /**
  44. \brief Script variable serialization to json string
  45. @param variable_out script variable to be serialized to string
  46. @param nice if the string should be formated for human readability
  47. @param result from the serialization, output or error depending on the return value
  48. \return if the serialization was successful
  49. @code
  50. Data data;
  51. string textOut;
  52. bool nice = false;
  53. JsonSerializer js = new JsonSerializer();
  54. bool ok = js.WriteToString(data, false, textOut);
  55. @endcode
  56. */
  57. proto bool WriteToString(void variable_out, bool nice, out string result);
  58. /**
  59. \brief Json string deserialization to script variable
  60. @param variable_in script variable to be deserialized from string
  61. @param jsonString the input string
  62. @param error from the deserialization. Is used only if the return value of the function is false
  63. \return if the deserialization was successful
  64. @code
  65. // Example json
  66. // {
  67. // "i": 6, // Int
  68. // "f": 3.5, // Float
  69. // "v": [1.1,2.2,3.3] // Vector3 is static array of size 3
  70. // "s": "string", // String
  71. // "subData": { // Object
  72. // "staticIArr": [9,8], // Static array (of ints)
  73. // "dynamicSArr": ["string1","string2"] // Dynamic array (of strings)
  74. // }, //
  75. // "fSet": [12.3,14.7], // Set (of floats)
  76. // "ifMap": { // Map (of int, float), only valid key type is int, enum, string
  77. // "3": 4.5, // Map key has to be as string
  78. // "4": 5.5
  79. // }
  80. // }
  81. Data data = new Data;
  82. string input = // valid json string;
  83. string error;
  84. bool ok = js.ReadFromString(data, input, error);
  85. @endcode
  86. */
  87. proto bool ReadFromString(void variable_in, string jsonString, out string error);
  88. };
  89. class ScriptRPC: ParamsWriteContext
  90. {
  91. void ScriptRPC();
  92. void ~ScriptRPC();
  93. //! Reset internal buffer which stores written data. After Reset is callded, ScriptRPC can be used again as "new" ScriptRPC
  94. proto native void Reset();
  95. /**
  96. \brief Initiate remote procedure call. When called on client, RPC is evaluated on server; When called on server, RPC is executed on all clients.
  97. Do not reset ScriptRPC internal state, so if is Send called multiple times in a row, it sends same (previously written) data again and again, until is Reset() called.
  98. @param target object on which remote procedure is called, when NULL, RPC is evaluated by CGame as global
  99. @param rpc_type user defined identification of RPC
  100. @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)
  101. */
  102. proto native void Send(Object target, int rpc_type, bool guaranteed,PlayerIdentity recipient = NULL);
  103. };
  104. class ScriptInputUserData : ParamsWriteContext
  105. {
  106. void ScriptInputUserData ();
  107. void ~ScriptInputUserData ();
  108. proto native void Reset ();
  109. proto native void Send ();
  110. proto native bool CopyFrom(ParamsReadContext other);
  111. //! Returns true when the channel is free, AND the InputBuffer is NOT full (same as '!IsNetworkInputBufferFull()')
  112. proto native static bool CanStoreInputUserData ();
  113. };
  114. class ScriptReadWriteContext
  115. {
  116. void ScriptReadWriteContext ();
  117. void ~ScriptReadWriteContext ();
  118. proto native ParamsWriteContext GetWriteContext ();
  119. proto native ParamsReadContext GetReadContext ();
  120. };
  121. class ScriptRemoteInputUserData : ParamsWriteContext
  122. {
  123. void ScriptRemoteInputUserData ();
  124. void ~ScriptRemoteInputUserData ();
  125. proto native void Reset ();
  126. };
  127. class ScriptJunctureData : ParamsWriteContext
  128. {
  129. void ScriptJunctureData ();
  130. void ~ScriptJunctureData ();
  131. proto native void Reset ();
  132. };
  133. //-----------------------------------------------------------------------------
  134. class MeleeCombatData
  135. {
  136. proto native int GetModesCount();
  137. proto native owned string GetModeName(int index);
  138. proto native owned string GetAmmoTypeName(int index);
  139. proto native float GetModeRange(int index);
  140. private void MeleeCombatData();
  141. private void ~MeleeCombatData();
  142. }
  143. //-----------------------------------------------------------------------------
  144. const string NullStringArray[1] = { "" };
  145. //-----------------------------------------------------------------------------
  146. //! Selection class
  147. class Selection
  148. {
  149. private void Selection() {}
  150. private void ~Selection() {}
  151. proto native owned string GetName();
  152. proto native int GetVertexCount();
  153. proto native int GetLODVertexIndex(int sel_vertex_index);
  154. vector GetVertexPosition(LOD lod, int index)
  155. {
  156. int lodIndex = GetLODVertexIndex(index);
  157. if (lodIndex == -1)
  158. {
  159. Error("Vertex doesn't exist");
  160. return vector.Zero;
  161. }
  162. return lod.GetVertexPosition(lodIndex);
  163. }
  164. };
  165. //-----------------------------------------------------------------------------
  166. //! LOD class
  167. class LOD
  168. {
  169. // standard(BI) LOD names in p3d
  170. static const string NAME_GEOMETRY = "geometry";
  171. static const string NAME_VIEW = "view";
  172. static const string NAME_FIRE = "fire";
  173. static const string NAME_MEMORY = "memory";
  174. static const string NAME_ROADWAY = "roadway";
  175. private void LOD() {}
  176. private void ~LOD() {}
  177. proto native int GetSelectionCount();
  178. proto native bool GetSelections(notnull out array<Selection> selections);
  179. proto native vector GetVertexPosition(int vertex_index);
  180. proto native owned string GetName(Object myObject);
  181. Selection GetSelectionByName(string name)
  182. {
  183. array<Selection> selections = new array<Selection>;
  184. GetSelections(selections);
  185. for (int i = 0; i < selections.Count(); ++i)
  186. {
  187. string selection_name = selections.Get(i).GetName();
  188. selection_name.ToLower();
  189. name.ToLower();
  190. if (selection_name == name)
  191. {
  192. return selections.Get(i);
  193. }
  194. }
  195. return null;
  196. }
  197. proto native int GetPropertyCount();
  198. proto native owned string GetPropertyName(int index);
  199. proto native owned string GetPropertyValue(int index);
  200. }
  201. class Plant extends Object
  202. {
  203. };
  204. /*
  205. class ParamEntry
  206. {
  207. proto string GetString(string entryName);
  208. proto int GetInt(string entryName);
  209. proto float GetFloat(string entryName);
  210. proto ref ParamEntry GetEntry(string entryName);
  211. proto int GetNumChildren();
  212. proto ref ParamEntry GetNumChildren(int n);
  213. };
  214. */
  215. //-----------------------------------------------------------------------------
  216. //-----------------------------------------------------------------------------
  217. class ProxyInventory extends ObjectTyped
  218. {
  219. };
  220. //-----------------------------------------------------------------------------
  221. class ProxySubpart extends Entity
  222. {
  223. };
  224. //-----------------------------------------------------------------------------
  225. // custom widgets
  226. //-----------------------------------------------------------------------------
  227. class ItemPreviewWidget: Widget
  228. {
  229. proto native void SetItem(EntityAI object);
  230. proto native EntityAI GetItem();
  231. proto native int GetView();
  232. /**
  233. * 0 - default boundingbox_min + boundingbox_max + invView
  234. * 1 - boundingbox_min2 + boundingbox_max2 + invView2
  235. * 2 - boundingbox_min3 + boundingbox_max3 + invView3
  236. * ...
  237. */
  238. proto native void SetView(int viewIndex);
  239. proto native void SetModelOrientation(vector vOrientation);
  240. proto native vector GetModelOrientation();
  241. proto native void SetModelPosition(vector vPos);
  242. proto native vector GetModelPosition();
  243. proto native void SetForceFlipEnable(bool enable);
  244. proto native void SetForceFlip(bool value);
  245. };
  246. //-----------------------------------------------------------------------------
  247. class PlayerPreviewWidget: Widget
  248. {
  249. proto native void UpdateItemInHands(EntityAI object);
  250. proto native void SetPlayer(DayZPlayer player);
  251. //proto native void SetPlayerType(string type);
  252. proto native DayZPlayer GetDummyPlayer();
  253. proto native void Refresh();
  254. proto native void SetModelOrientation(vector vOrientation);
  255. proto native vector GetModelOrientation();
  256. proto native void SetModelPosition(vector vPos);
  257. proto native vector GetModelPosition();
  258. };
  259. //-----------------------------------------------------------------------------
  260. class HtmlWidget extends RichTextWidget
  261. {
  262. proto native void LoadFile(string path);
  263. };
  264. //-----------------------------------------------------------------------------
  265. class MapWidget: Widget
  266. {
  267. proto native void ClearUserMarks();
  268. proto native void AddUserMark(vector pos, string text, int color /*ARGB*/, string texturePath);
  269. proto native vector GetMapPos();
  270. proto native void SetMapPos(vector worldPos);
  271. proto native float GetScale();
  272. proto native void SetScale(float scale);
  273. proto native float GetContourInterval();
  274. proto native float GetCellSize(float pLegendWidth);
  275. proto native vector MapToScreen(vector worldPos);
  276. proto native vector ScreenToMap(vector screenPos);
  277. };
  278. //-----------------------------------------------------------------------------
  279. //! Player description (base engine class)
  280. class PlayerIdentityBase : Managed
  281. {
  282. //! ping range estimation
  283. proto int GetPingAct();
  284. //! ping range estimation
  285. proto int GetPingMin();
  286. //! ping range estimation
  287. proto int GetPingMax();
  288. //! ping range estimation
  289. proto int GetPingAvg();
  290. //! bandwidth estimation (in kbps)
  291. proto int GetBandwidthMin();
  292. //! bandwidth estimation (in kbps)
  293. proto int GetBandwidthMax();
  294. //! bandwidth estimation (in kbps)
  295. proto int GetBandwidthAvg();
  296. //! Throttling performed on output bandwidth since last update (percentage [0,1])
  297. proto float GetOutputThrottle();
  298. //! Throttling performed on input bandwidth since last update(percentage [0,1]) (unknown value on Server)
  299. proto float GetInputThrottle();
  300. //! nick (short) name of player
  301. proto string GetName();
  302. //! nick without any processing
  303. proto string GetPlainName();
  304. //! full name of player
  305. proto string GetFullName();
  306. //! unique id of player (hashed steamID, database Xbox id...) can be used in database or logs
  307. proto string GetId();
  308. //! plaintext unique id of player (cannot be used in database or logs)
  309. proto string GetPlainId();
  310. //! id of player in one session (is reused after player disconnects)
  311. proto int GetPlayerId();
  312. //! get player
  313. proto Man GetPlayer();
  314. #ifdef FEATURE_NETWORK_RECONCILIATION
  315. //! Possess a pawn
  316. proto native void Possess(Pawn pawn);
  317. #endif
  318. //! This is a C++ managed class, so script has no business managing the lifetime
  319. private void PlayerIdentityBase();
  320. private void ~PlayerIdentityBase();
  321. };
  322. //! The class that will be instanced (moddable)
  323. class PlayerIdentity : PlayerIdentityBase
  324. {
  325. }
  326. //-----------------------------------------------------------------------------
  327. const int PROGRESS_START = 0;
  328. const int PROGRESS_FINISH = 1;
  329. const int PROGRESS_PROGRESS = 2;
  330. const int PROGRESS_UPDATE = 3;
  331. //-----------------------------------------------------------------------------
  332. typedef int ChatChannel;
  333. //-----------------------------------------------------------------------------
  334. //! state, progress, title
  335. typedef Param3<int, float, string> ProgressEventParams;
  336. typedef Param1<string> ScriptLogEventParams;
  337. //! channel, from, text, color config class
  338. typedef Param4<int, string, string, string> ChatMessageEventParams;
  339. typedef Param1<int> ChatChannelEventParams;
  340. typedef Param1<int> SQFConsoleEventParams;
  341. //! Name, uid
  342. typedef Param2<string, string> ClientConnectedEventParams;
  343. //! PlayerIdentity, useDB, pos, yaw, preloadTimeout (= additional time in seconds to how long server waits for loginData)
  344. typedef Param5<PlayerIdentity, bool, vector, float, int> ClientPrepareEventParams;
  345. //! PlayerIdentity, PlayerPos, Top, Bottom, Shoe, Skin
  346. typedef Param3<PlayerIdentity, vector, Serializer> ClientNewEventParams;
  347. //! PlayerIdentity, Man
  348. typedef Param2<PlayerIdentity, Man> ClientNewReadyEventParams;
  349. //! PlayerIdentity, Man
  350. typedef Param2<PlayerIdentity, Man> ClientRespawnEventParams;
  351. //! PlayerIdentity, Man
  352. typedef Param2<PlayerIdentity, Man> ClientReadyEventParams;
  353. //! PlayerIdentity, Man
  354. typedef Param2<PlayerIdentity, Man> ClientReconnectEventParams;
  355. //! PlayerIdentity, Man, LogoutTime, AuthFailed
  356. typedef Param4<PlayerIdentity, Man, int, bool> ClientDisconnectedEventParams;
  357. //! LoginTime
  358. typedef Param1<int> LoginTimeEventParams;
  359. //! RespawnTime
  360. typedef Param1<int> RespawnEventParams;
  361. //! Position
  362. typedef Param1<vector> PreloadEventParams;
  363. //! Player
  364. typedef Param1<Man> LogoutCancelEventParams;
  365. //! PlayerIdentity
  366. typedef Param1<PlayerIdentity> ConnectivityStatsUpdatedEventParams;
  367. //! average server fps, highest frame time, skipped physics simulation steps server/client
  368. typedef Param4<float, float, int, int> ServerFpsStatsUpdatedEventParams;
  369. //! text message for line 1, text message for line 2
  370. typedef Param2<string, string> LoginStatusEventParams;
  371. //! logoutTime
  372. typedef Param1<int> LogoutEventParams;
  373. //! Width, Height, Windowed
  374. typedef Param3<int, int, bool> WindowsResizeEventParams;
  375. //! listening, toggled
  376. typedef Param2<bool, bool> VONStateEventParams;
  377. //! player name, player id
  378. typedef Param2<string, string> VONStartSpeakingEventParams;
  379. //! player name, player id
  380. typedef Param2<string, string> VONStopSpeakingEventParams;
  381. //! world name
  382. typedef Param1<string> DLCOwnerShipFailedParams;
  383. //! Camera
  384. typedef Param1<FreeDebugCamera> SetFreeCameraEventParams;
  385. //! Duration
  386. typedef Param1<int> MPConnectionLostEventParams;
  387. //! EClientKicked, AdditionalInfo
  388. typedef Param2<int, string> MPConnectionCloseEventParams;
  389. //! Player, "Killer" (Beware: Not necessarily actually the killer, Client doesn't have this info)
  390. typedef Param2<DayZPlayer, Object> PlayerDeathEventParams;
  391. //! isFull
  392. typedef Param1<bool> NetworkInputBufferEventParams;
  393. //-----------------------------------------------------------------------------
  394. //! no params
  395. const EventType StartupEventTypeID;
  396. //! no params
  397. const EventType WorldCleaupEventTypeID;
  398. //-----------------------------------------------------------------------------
  399. //! no params
  400. const EventType MPSessionStartEventTypeID;
  401. //! no params
  402. const EventType MPSessionEndEventTypeID;
  403. //! no params
  404. const EventType MPSessionFailEventTypeID;
  405. //! no params
  406. const EventType MPSessionPlayerReadyEventTypeID;
  407. //! params: \ref MPConnectionLostEventParams
  408. const EventType MPConnectionLostEventTypeID;
  409. //! params: \ref MPConnectionCloseEventParams
  410. const EventType MPConnectionCloseEventTypeID;
  411. //-----------------------------------------------------------------------------
  412. //! params: \ref ProgressEventParams
  413. const EventType ProgressEventTypeID;
  414. //! no params
  415. const EventType NetworkManagerClientEventTypeID;
  416. //! no params
  417. const EventType NetworkManagerServerEventTypeID;
  418. //! no params
  419. const EventType DialogQueuedEventTypeID;
  420. //-----------------------------------------------------------------------------
  421. //! params: \ref ChatMessageEventParams
  422. const EventType ChatMessageEventTypeID;
  423. //! params: \ref ChatChannelEventParams
  424. const EventType ChatChannelEventTypeID;
  425. //-----------------------------------------------------------------------------
  426. //! params: \ref ClientConnectedEventParams
  427. const EventType ClientConnectedEventTypeID;
  428. //! params: \ref ClientPrepareEventParams
  429. const EventType ClientPrepareEventTypeID;
  430. //! params: \ref ClientNewEventParams
  431. const EventType ClientNewEventTypeID;
  432. //! params: \ref ClientNewReadyEventParams
  433. const EventType ClientNewReadyEventTypeID;
  434. //! params: \ref ClientRespawnEventParams
  435. const EventType ClientRespawnEventTypeID;
  436. //! params: \ref ClientReconnectEventParams
  437. const EventType ClientReconnectEventTypeID;
  438. //! params: \ref ClientReadyEventParams
  439. const EventType ClientReadyEventTypeID;
  440. //! params: \ref ClientDisconnectedEventParams
  441. const EventType ClientDisconnectedEventTypeID;
  442. //! no params
  443. const EventType ClientRemovedEventTypeID;
  444. //-----------------------------------------------------------------------------
  445. //! params: \ref ConnectivityStatsUpdatedEventParams
  446. const EventType ConnectivityStatsUpdatedEventTypeID;
  447. //! params: \ref ServerFpsStatsUpdatedEventParams
  448. const EventType ServerFpsStatsUpdatedEventTypeID;
  449. //! params: \ref LogoutCancelEventParams
  450. const EventType LogoutCancelEventTypeID;
  451. //! params: \ref LoginTimeEventParams
  452. const EventType LoginTimeEventTypeID;
  453. //! params: \ref RespawnEventParams
  454. const EventType RespawnEventTypeID;
  455. //! params: \ref PreloadEventParams
  456. const EventType PreloadEventTypeID;
  457. //! params: \ref LogoutEventParams
  458. const EventType LogoutEventTypeID;
  459. //! params: \ref LoginStatusEventParams
  460. const EventType LoginStatusEventTypeID;
  461. //-----------------------------------------------------------------------------
  462. //! no params
  463. const EventType SelectedUserChangedEventTypeID;
  464. //! params: \ref ScriptLogEventParams
  465. const EventType ScriptLogEventTypeID;
  466. //-----------------------------------------------------------------------------
  467. //! params: \ref VONStateEventParams
  468. const EventType VONStateEventTypeID;
  469. //! params: \ref VONStartSpeakingEventParams
  470. const EventType VONStartSpeakingEventTypeID;
  471. //! params: \ref VONStopSpeakingEventParams
  472. const EventType VONStopSpeakingEventTypeID;
  473. //! no params
  474. const EventType VONUserStartedTransmittingAudioEventTypeID;
  475. //! no params
  476. const EventType VONUserStoppedTransmittingAudioEventTypeID;
  477. //! no params
  478. //-----------------------------------------------------------------------------
  479. const EventType PartyChatStatusChangedEventTypeID;
  480. //! params: \ref DLCOwnerShipFailedParams
  481. const EventType DLCOwnerShipFailedEventTypeID;
  482. //! params: \ref SetFreeCameraEventParams
  483. const EventType SetFreeCameraEventTypeID;
  484. //! no params
  485. const EventType ConnectingStartEventTypeID;
  486. //! no params
  487. const EventType ConnectingAbortEventTypeID;
  488. //! params: \ref PlayerDeathEventParams
  489. const EventType PlayerDeathEventTypeID;
  490. //! params: \ref NetworkInputBufferEventParams
  491. const EventType NetworkInputBufferEventTypeID;
  492. //possible in engine events not accessable from script
  493. //ReloadShadersEvent
  494. //LoadWorldProgressEvent
  495. //SignStatusEvent
  496. //SetPausedEvent
  497. //TerminationEvent
  498. //UserSettingsChangedEvent
  499. //StorageChangedEvent
  500. //BeforeResetEvent
  501. //AfterRenderEvent
  502. //AfterResetEvent
  503. //CrashLogEvent
  504. //ConsoleEvent
  505. class CursorIcons
  506. {
  507. const string None = "";
  508. const string Cursor = "set:dayz_gui image:cursor";
  509. const string CloseDoors = "set:dayz_gui image:close";
  510. const string OpenDoors = "set:dayz_gui image:open";
  511. const string OpenCarDoors = "set:dayz_gui image:open_car";
  512. const string CloseCarDoors = "set:dayz_gui image:close_car";
  513. const string EngineOff = "set:dayz_gui image:engine_off";
  514. const string EngineOn = "set:dayz_gui image:engine_on";
  515. const string LadderDown = "set:dayz_gui image:ladderdown";
  516. const string LadderOff = "set:dayz_gui image:ladderoff";
  517. const string LadderUp = "set:dayz_gui image:ladderup";
  518. const string LootCorpse = "set:dayz_gui image:gear";
  519. const string CloseHood = "set:dayz_gui image:close_hood";
  520. const string OpenHood = "set:dayz_gui image:open_hood";
  521. const string GetOut = "set:dayz_gui image:getout";
  522. const string GetInCargo = "set:dayz_gui image:get_in_cargo";
  523. const string Reload = "set:dayz_gui image:reload";
  524. const string GetInDriver = "set:dayz_gui image:get_in_driver";
  525. const string GetInCommander = "set:dayz_gui image:get_in_commander";
  526. const string GetInPilot = "set:dayz_gui image:get_in_pilot";
  527. const string GetInGunner = "set:dayz_gui image:get_in_gunner";
  528. };
  529. // some defs for CGame::ShowDialog()
  530. /*
  531. const int DBB_NONE = 0;
  532. const int DBB_OK = 1;
  533. const int DBB_YES = 2;
  534. const int DBB_NO = 3;
  535. const int DBB_CANCEL = 4;
  536. const int DBT_OK = 0; //just OK button
  537. const int DBT_YESNO = 1; //Yes and No buttons
  538. const int DBT_YESNOCANCEL = 2; //Yes, No, Cancel buttons
  539. const int DMT_NONE = 0;
  540. const int DMT_INFO = 1;
  541. const int DMT_WARNING = 2;
  542. const int DMT_QUESTION = 3;
  543. const int DMT_EXCLAMATION = 4;
  544. */
  545. proto native CGame GetGame();
  546. class Hud : Managed
  547. {
  548. ref Timer m_Timer;
  549. void Init(Widget hud_panel_widget) {}
  550. void DisplayNotifier(int key, int tendency, int status) {}
  551. void DisplayBadge(int key, int value) {}
  552. void SetStamina(int value, int range) {}
  553. void DisplayStance(int stance) {}
  554. void DisplayPresence() {}
  555. void ShowCursor() { }
  556. void HideCursor() { }
  557. void SetCursorIcon(string icon) { }
  558. void SetCursorIconScale(string type, float percentage) { }
  559. void SetCursorIconOffset(string type, float x, float y) { }
  560. void SetCursorIconSize(string type, float x, float y) { }
  561. void ShowWalkieTalkie(bool show) { }
  562. void ShowWalkieTalkie(int fadeOutSeconds) { }
  563. void SetWalkieTalkieText(string text) { }
  564. void RefreshQuickbar(bool itemChanged = false) {}
  565. void Show(bool show) {}
  566. void UpdateBloodName() {}
  567. void SetTemperature(string temp);
  568. void SetStaminaBarVisibility(bool show);
  569. void Update(float timeslice){}
  570. void ShowVehicleInfo();
  571. void HideVehicleInfo();
  572. void InitHeatBufferUI(Man player);
  573. void ShowQuickbarUI(bool show);
  574. void ShowQuickbarPlayer(bool show);
  575. void ShowHudPlayer(bool show);
  576. void ShowHudUI(bool show);
  577. void ShowHudInventory(bool show);
  578. void ShowQuickBar(bool show);
  579. void UpdateQuickbarGlobalVisibility();
  580. void ShowHud(bool show);
  581. void OnResizeScreen();
  582. void OnPlayerLoaded(); // player connects or respawns
  583. void SetPermanentCrossHair(bool show) {}
  584. void SpawnHitDirEffect(DayZPlayer player, float hit_direction,float intensity_max);
  585. void SetConnectivityStatIcon(EConnectivityStatType type, EConnectivityStatLevel level);
  586. };
  587. //-----------------------------------------------------------------------------
  588. //! Mission class
  589. class Mission
  590. {
  591. ScriptModule MissionScript;
  592. ref array<vector> m_ActiveRefresherLocations;
  593. protected ref ScriptInvoker m_OnInputDeviceChanged = new ScriptInvoker();
  594. protected ref ScriptInvoker m_OnInputPresetChanged = new ScriptInvoker();
  595. protected ref ScriptInvoker m_OnInputDeviceConnected = new ScriptInvoker();
  596. protected ref ScriptInvoker m_OnInputDeviceDisconnected = new ScriptInvoker();
  597. protected ref ScriptInvoker m_OnModMenuVisibilityChanged = new ScriptInvoker();
  598. protected ref ScriptInvoker m_OnTimeChanged = new ScriptInvoker();
  599. private void ~Mission();
  600. void OnInit() {}
  601. void OnMissionStart() {}
  602. void OnMissionFinish() {}
  603. void OnUpdate(float timeslice)
  604. {
  605. #ifdef FEATURE_CURSOR
  606. m_TimeStamp++;
  607. #endif
  608. }
  609. void OnKeyPress(int key) {}
  610. void OnKeyRelease(int key) {}
  611. void OnMouseButtonPress(int button){}
  612. void OnMouseButtonRelease(int button){}
  613. void OnEvent(EventType eventTypeId, Param params) {}
  614. void OnItemUsed(InventoryItem item, Man owner) {}
  615. void AddDummyPlayerToScheduler(Man player){}
  616. void Reset(){}
  617. void ResetGUI(){}
  618. void OnGameplayDataHandlerLoad(){}
  619. Hud GetHud()
  620. {
  621. return null;
  622. }
  623. ObjectSnapCallback GetInventoryDropCallback()
  624. {
  625. return null;
  626. }
  627. bool IsPlayerDisconnecting(Man player);
  628. UIScriptedMenu CreateScriptedMenu(int id)
  629. {
  630. return null;
  631. }
  632. UIScriptedWindow CreateScriptedWindow(int id)
  633. {
  634. return null;
  635. }
  636. WorldData GetWorldData()
  637. {
  638. return null;
  639. }
  640. WorldLighting GetWorldLighting()
  641. {
  642. return null;
  643. }
  644. DynamicMusicPlayer GetDynamicMusicPlayer()
  645. {
  646. return null;
  647. }
  648. bool IsPaused()
  649. {
  650. return false;
  651. }
  652. bool IsGame()
  653. {
  654. return false;
  655. }
  656. bool IsServer()
  657. {
  658. return false;
  659. }
  660. void Pause() {}
  661. void Continue() {}
  662. void AbortMission() {}
  663. void CreateLogoutMenu(UIMenuPanel parent) {}
  664. void StartLogoutMenu(int time) {}
  665. void CreateDebugMonitor() {}
  666. void HideDebugMonitor() {}
  667. void RefreshCrosshairVisibility() {}
  668. void HideCrosshairVisibility() {}
  669. bool IsMissionGameplay()
  670. {
  671. return false;
  672. }
  673. bool IsControlDisabled() {}
  674. int GetControlDisabledMode() {}
  675. void PlayerControlEnable(bool bForceSupress); //!deprecated
  676. void PlayerControlDisable(int mode); //!deprecated
  677. void RemoveActiveInputExcludes(array<string> excludes, bool bForceSupress = false);
  678. void RemoveActiveInputRestriction(int restrictor);
  679. void AddActiveInputExcludes(array<string> excludes);
  680. void AddActiveInputRestriction(int restrictor);
  681. void RefreshExcludes();
  682. bool IsInputExcludeActive(string exclude);
  683. bool IsInputRestrictionActive(int restriction);
  684. void EnableAllInputs(bool bForceSupress = false);
  685. void ShowInventory() {}
  686. void HideInventory() {}
  687. void ShowChat() {}
  688. void HideChat() {}
  689. void UpdateVoiceLevelWidgets(int level) {}
  690. void HideVoiceLevelWidgets() {}
  691. bool IsVoNActive() {}
  692. void SetVoNActive(bool active) {}
  693. bool InsertCorpse(Man player)
  694. {
  695. return false;
  696. }
  697. UIScriptedMenu GetNoteMenu();
  698. void SetNoteMenu(UIScriptedMenu menu);
  699. void SetPlayerRespawning(bool state);
  700. void OnPlayerRespawned(Man player);
  701. bool IsPlayerRespawning();
  702. array<vector> GetActiveRefresherLocations();
  703. //! for client-side usage
  704. void SetRespawnModeClient(int mode);
  705. int GetRespawnModeClient()
  706. {
  707. return -1;
  708. }
  709. //! server-side
  710. void SyncRespawnModeInfo(PlayerIdentity identity);
  711. ImageWidget GetMicrophoneIcon()
  712. {
  713. return null;
  714. }
  715. WidgetFadeTimer GetMicWidgetFadeTimer();
  716. GameplayEffectWidgets_base GetEffectWidgets();
  717. map<int,ImageWidget> GetVoiceLevelWidgets();
  718. map<int,ref WidgetFadeTimer> GetVoiceLevelTimers();
  719. ScriptInvoker GetOnInputDeviceChanged()
  720. {
  721. if (!m_OnInputDeviceChanged)
  722. m_OnInputDeviceChanged = new ScriptInvoker();
  723. return m_OnInputDeviceChanged;
  724. }
  725. ScriptInvoker GetOnInputPresetChanged()
  726. {
  727. if (!m_OnInputPresetChanged)
  728. m_OnInputPresetChanged = new ScriptInvoker();
  729. return m_OnInputPresetChanged;
  730. }
  731. ScriptInvoker GetOnInputDeviceConnected()
  732. {
  733. if (!m_OnInputDeviceConnected)
  734. m_OnInputDeviceConnected = new ScriptInvoker();
  735. return m_OnInputDeviceConnected;
  736. }
  737. ScriptInvoker GetOnInputDeviceDisconnected()
  738. {
  739. if (!m_OnInputDeviceDisconnected)
  740. m_OnInputDeviceDisconnected = new ScriptInvoker();
  741. return m_OnInputDeviceDisconnected;
  742. }
  743. ScriptInvoker GetOnModMenuVisibilityChanged()
  744. {
  745. if (!m_OnModMenuVisibilityChanged)
  746. m_OnModMenuVisibilityChanged = new ScriptInvoker();
  747. return m_OnModMenuVisibilityChanged;
  748. }
  749. ScriptInvoker GetOnTimeChanged()
  750. {
  751. if (!m_OnTimeChanged)
  752. m_OnTimeChanged = new ScriptInvoker();
  753. return m_OnTimeChanged;
  754. }
  755. #ifdef FEATURE_CURSOR
  756. int m_TimeStamp = 0;
  757. int GetTimeStamp()
  758. {
  759. return m_TimeStamp;
  760. }
  761. #endif
  762. #ifdef DEVELOPER
  763. bool m_SuppressNextFrame = true;
  764. void SetInputSuppression(bool state);
  765. bool GetInputSuppression();
  766. #endif
  767. };
  768. // -------------------------------------------------------------------------
  769. class MenuData: Managed
  770. {
  771. proto native int GetCharactersCount();
  772. proto native int GetLastPlayedCharacter();
  773. //! Return Character person or null if character initialization failed (inventory load, or corrupted data)
  774. proto native Man CreateCharacterPerson(int index);
  775. proto void GetLastServerAddress(int index, out string address);
  776. proto native int GetLastServerPort(int index);
  777. proto native int GetLastSteamQueryPort(int index);
  778. proto void GetLastServerName(int index, out string address);
  779. proto void RequestSetDefaultCharacterData();
  780. proto bool RequestGetDefaultCharacterData();
  781. //! Actual DefaultCharacter saving
  782. void OnSetDefaultCharacter(ParamsWriteContext ctx)
  783. {
  784. if (!GetMenuDefaultCharacterDataInstance()/* || GetGame().IsServer()*/)
  785. {
  786. Error("MenuData | OnSetDefaultCharacter - failed to get data class!");
  787. return;
  788. }
  789. GetMenuDefaultCharacterDataInstance().SerializeCharacterData(ctx);
  790. SaveCharactersLocal();
  791. }
  792. //! Actual DefaultCharacter loading
  793. bool OnGetDefaultCharacter(ParamsReadContext ctx)
  794. {
  795. if (!GetMenuDefaultCharacterDataInstance())
  796. {
  797. Error("MenuData | OnGetDefaultCharacter - failed to get data class!");
  798. return false;
  799. }
  800. if (GetMenuDefaultCharacterDataInstance().DeserializeCharacterData(ctx))
  801. {
  802. return true;
  803. }
  804. return false;
  805. }
  806. proto void GetCharacterName(int index, out string name);
  807. proto native void SetCharacterName(int index, string newName);
  808. // save character is set as last played character
  809. proto native void SaveCharacter(bool localPlayer, bool verified);
  810. proto native void SaveDefaultCharacter(Man character);
  811. //! Saves characters menu data to file
  812. proto native void SaveCharactersLocal();
  813. //! Loads characters menu data from file
  814. proto native void LoadCharactersLocal();
  815. proto native void ClearCharacters();
  816. MenuDefaultCharacterData GetMenuDefaultCharacterDataInstance()
  817. {
  818. return GetGame().GetMenuDefaultCharacterData();
  819. }
  820. //proto native void GetCharacterStringList(int characterID, string name, out TStringArray values);
  821. //proto bool GetCharacterString(int characterID,string name, out string value);
  822. };
  823. //holds 'default character' data
  824. class MenuDefaultCharacterData
  825. {
  826. //const int MODE_SERVER = 0;
  827. //const int MODE_CLIENT = 1;
  828. string m_CharacterName;
  829. string m_CharacterType;
  830. ref map<int,string> m_AttachmentsMap;
  831. bool m_ForceRandomCharacter;
  832. void MenuDefaultCharacterData()
  833. {
  834. Init();
  835. }
  836. void Init()
  837. {
  838. if (!GetGame().IsDedicatedServer())
  839. {
  840. GetGame().GetMenuData().LoadCharactersLocal();
  841. }
  842. m_AttachmentsMap = new map<int,string>;
  843. }
  844. void ClearAttachmentsMap()
  845. {
  846. m_AttachmentsMap.Clear();
  847. }
  848. void SetDefaultAttachment(int slotID, string type)
  849. {
  850. m_AttachmentsMap.Set(slotID,type); //using 'Set' instead of 'Insert' for convenience
  851. }
  852. void GenerateRandomEquip()
  853. {
  854. ClearAttachmentsMap();
  855. int slot_ID;
  856. string attachment_type;
  857. for (int i = 0; i < DefaultCharacterCreationMethods.GetAttachmentSlotsArray().Count(); i++)
  858. {
  859. slot_ID = DefaultCharacterCreationMethods.GetAttachmentSlotsArray().Get(i);
  860. if (DefaultCharacterCreationMethods.GetConfigArrayCountFromSlotID(slot_ID) > 0)
  861. {
  862. attachment_type = DefaultCharacterCreationMethods.GetConfigAttachmentTypes(slot_ID).GetRandomElement();
  863. //if (attachment_type != "")
  864. SetDefaultAttachment(slot_ID,attachment_type);
  865. }
  866. }
  867. }
  868. void EquipDefaultCharacter(Man player)
  869. {
  870. if (!player)
  871. {
  872. ErrorEx("WARNING - trying to equip non-existent object! | MenuDefaultCharacterData::EquipDefaultCharacter");
  873. return;
  874. }
  875. int slot_ID;
  876. string attachment_type;
  877. string current_attachment_type;
  878. EntityAI current_attachment_object;
  879. for (int i = 0; i < m_AttachmentsMap.Count(); i++)
  880. {
  881. attachment_type = "";
  882. current_attachment_type = "";
  883. slot_ID = m_AttachmentsMap.GetKey(i);
  884. attachment_type = m_AttachmentsMap.GetElement(i); //Get(i)
  885. current_attachment_object = player.GetInventory().FindAttachment(slot_ID);
  886. if (current_attachment_object)
  887. {
  888. current_attachment_type = current_attachment_object.GetType();
  889. }
  890. if (current_attachment_type != attachment_type)
  891. {
  892. if (current_attachment_object)
  893. g_Game.ObjectDelete(current_attachment_object);
  894. if (attachment_type != "")
  895. player.GetInventory().CreateAttachmentEx(attachment_type,slot_ID);
  896. }
  897. }
  898. }
  899. //!serializes data into a param array to be used by "StoreLoginData(notnull array<ref Param> params);"
  900. void SerializeCharacterData(ParamsWriteContext ctx)
  901. {
  902. ctx.Write(m_CharacterType);
  903. ctx.Write(m_AttachmentsMap);
  904. ctx.Write(m_ForceRandomCharacter);
  905. ctx.Write(m_CharacterName);
  906. //DumpAttMapContents();
  907. }
  908. bool DeserializeCharacterData(ParamsReadContext ctx)
  909. {
  910. if (!ctx.Read(m_CharacterType))
  911. return false;
  912. if (!ctx.Read(m_AttachmentsMap))
  913. return false;
  914. if (!ctx.Read(m_ForceRandomCharacter))
  915. return false;
  916. if (!ctx.Read(m_CharacterName))
  917. return false;
  918. //DumpAttMapContents();
  919. return true;
  920. }
  921. void SetCharacterName(string name)
  922. {
  923. m_CharacterName = name;
  924. }
  925. string GetCharacterName()
  926. {
  927. return m_CharacterName;
  928. }
  929. void SetCharacterType(string character_type)
  930. {
  931. m_CharacterType = character_type;
  932. }
  933. string GetCharacterType()
  934. {
  935. return m_CharacterType;
  936. }
  937. void SetRandomCharacterForced(bool state)
  938. {
  939. m_ForceRandomCharacter = state;
  940. }
  941. bool IsRandomCharacterForced()
  942. {
  943. return m_ForceRandomCharacter;
  944. }
  945. map<int,string> GetAttachmentMap()
  946. {
  947. return m_AttachmentsMap;
  948. }
  949. //DEBUG
  950. void DumpAttMapContents()
  951. {
  952. int debugID;
  953. string debugType;
  954. Print("-----------");
  955. Print("m_AttachmentsMap contents:");
  956. for (int j = 0; j < m_AttachmentsMap.Count(); j++)
  957. {
  958. debugID = m_AttachmentsMap.GetKey(j);
  959. debugType = m_AttachmentsMap.GetElement(j);
  960. Print("index " + j);
  961. Print("debugID: " + debugID);
  962. Print("debugType: " + debugType);
  963. }
  964. Print("-----------");
  965. }
  966. }
  967. class DefaultCharacterCreationMethods
  968. {
  969. static ref array<int> m_AttachmentSlots = {
  970. InventorySlots.SHOULDER,
  971. InventorySlots.MELEE,
  972. InventorySlots.HEADGEAR,
  973. InventorySlots.MASK,
  974. InventorySlots.EYEWEAR,
  975. InventorySlots.GLOVES,
  976. InventorySlots.ARMBAND,
  977. InventorySlots.BODY,
  978. InventorySlots.VEST,
  979. InventorySlots.BACK,
  980. InventorySlots.HIPS,
  981. InventorySlots.LEGS,
  982. InventorySlots.FEET
  983. };
  984. //conversion nescesssary for legacy reasons...
  985. static ref array<string> m_ConfigArrayNames = {
  986. "shoulder",
  987. "melee",
  988. "headgear",
  989. "mask",
  990. "eyewear",
  991. "gloves",
  992. "armband",
  993. "top",
  994. "vests",
  995. "backpacks",
  996. "hips",
  997. "bottom",
  998. "shoe"
  999. };
  1000. const static string m_Path = "cfgCharacterCreation";
  1001. //! Returns config path of att. slot category, empty if undefined
  1002. static string GetPathFromSlotID(int slot_ID)
  1003. {
  1004. int idx = m_AttachmentSlots.Find(slot_ID);
  1005. string path = "" + m_Path + " " + m_ConfigArrayNames.Get(idx);
  1006. return path;
  1007. }
  1008. //! How many 'default equip' types are listed in the corresponding array
  1009. static int GetConfigArrayCountFromSlotID(int slot_ID)
  1010. {
  1011. TStringArray types = new TStringArray;
  1012. GetGame().ConfigGetTextArray(GetPathFromSlotID(slot_ID),types);
  1013. return types.Count();
  1014. }
  1015. //! Lists all configured types (if any) for the appropriate attachment
  1016. static array<string> GetConfigAttachmentTypes(int slot_ID)
  1017. {
  1018. TStringArray types = new TStringArray;
  1019. GetGame().ConfigGetTextArray(GetPathFromSlotID(slot_ID),types);
  1020. return types;
  1021. }
  1022. //! Lists all customizable InventorySlots
  1023. static array<int> GetAttachmentSlotsArray()
  1024. {
  1025. return m_AttachmentSlots;
  1026. }
  1027. //! for conversion of slot ID to config array's string
  1028. static array<string> GetConfigArrayNames()
  1029. {
  1030. return m_ConfigArrayNames;
  1031. }
  1032. }
  1033. //! C++ OptionAccessType
  1034. enum OptionAccessType
  1035. {
  1036. AT_UNKNOWN,
  1037. AT_OBJECTS_DETAIL,
  1038. AT_TEXTURE_DETAIL,
  1039. AT_HDR_DETAIL,
  1040. AT_FSAA_DETAIL,
  1041. AT_VSYNC_VALUE,
  1042. AT_ANISO_DETAIL,
  1043. AT_OPTIONS_FXAA_VALUE,
  1044. AT_OPTIONS_SW_VALUE,
  1045. AT_POSTPROCESS_EFFECTS,
  1046. AT_QUALITY_PREFERENCE,
  1047. AT_ATOC_DETAIL,
  1048. AT_AMBIENT_OCCLUSION,
  1049. AT_BLOOM,
  1050. AT_ROTATION_BLUR,
  1051. AT_SHADOW_DETAIL,
  1052. AT_OPTIONS_TERRAIN,
  1053. AT_OPTIONS_RESOLUTION,
  1054. AT_OPTIONS_GAMMA_SLIDER,
  1055. AT_OPTIONS_BRIGHT_SLIDER,
  1056. AT_OPTIONS_VISIBILITY_SLIDER,
  1057. AT_OPTIONS_OBJECT_VISIBILITY_SLIDER,
  1058. AT_OPTIONS_SHADOW_VISIBILITY_SLIDER,
  1059. AT_OPTIONS_DRAWDISTANCE_SLIDER,
  1060. AT_ASPECT_RATIO,
  1061. AT_OPTIONS_FIELD_OF_VIEW,
  1062. AT_OPTIONS_MUSIC_SLIDER,
  1063. AT_OPTIONS_EFFECTS_SLIDER,
  1064. AT_OPTIONS_VON_SLIDER,
  1065. AT_OPTIONS_MASTER_VOLUME,
  1066. AT_OPTIONS_HWACC,
  1067. AT_OPTIONS_EAX,
  1068. AT_OPTIONS_LANGUAGE,
  1069. AT_OPTIONS_RADIO,
  1070. AT_CONFIG_MOUSE_FILTERING,
  1071. AT_CONFIG_HEAD_BOB,
  1072. AT_OPTIONS_DISPLAY_MODE,
  1073. AT_OPTIONS_TERRAIN_SHADER,
  1074. AT_OPTIONS_AIM_HELPER,
  1075. AT_OPTIONS_MOUSE_AND_KEYBOARD,
  1076. AT_OPTIONS_PAUSE,
  1077. AT_OPTIONS_FLIPMODE,
  1078. AT_OPTIONS_VON_THRESHOLD_SLIDER,
  1079. AT_OPTIONS_MOUSE_YAXIS_INVERTED,
  1080. AT_OPTIONS_MOUSE_XAXIS,
  1081. AT_OPTIONS_MOUSE_YAXIS,
  1082. AT_OPTIONS_MOUSE_XAXIS_AIM_MOD,
  1083. AT_OPTIONS_MOUSE_YAXIS_AIM_MOD,
  1084. AT_OPTIONS_CONTROLLER_LS_XAXIS,
  1085. AT_OPTIONS_CONTROLLER_LS_YAXIS,
  1086. AT_OPTIONS_CONTROLLER_LS_XAXIS_VEHICLE_MOD,
  1087. AT_OPTIONS_CONTROLLER_RS_YAXIS_INVERTED,
  1088. AT_OPTIONS_CONTROLLER_RS_XAXIS,
  1089. AT_OPTIONS_CONTROLLER_RS_YAXIS,
  1090. AT_OPTIONS_CONTROLLER_RS_XAXIS_AIM_MOD,
  1091. AT_OPTIONS_CONTROLLER_RS_YAXIS_AIM_MOD,
  1092. AT_OPTIONS_VON_INPUT_MODE,
  1093. AT_OPTIONS_CONTROLLER_LS_DEADZONE,
  1094. AT_OPTIONS_CONTROLLER_RS_DEADZONE,
  1095. AT_OPTIONS_VISIBILITY_COMBO,
  1096. AT_OPTIONS_OBJECT_VISIBILITY_COMBO,
  1097. };
  1098. //! Used for script-based game options. For anything C++ based, you would most likely use "Option Access Type" above
  1099. enum OptionIDsScript
  1100. {
  1101. OPTION_HUD = 100, //starts at 100 to avoid ID conflict with AT_
  1102. OPTION_HUD_VEHICLE,
  1103. OPTION_CROSSHAIR,
  1104. OPTION_GAME_MESSAGES,
  1105. OPTION_ADMIN_MESSAGES,
  1106. OPTION_PLAYER_MESSAGES,
  1107. OPTION_QUICKBAR,
  1108. OPTION_SERVER_INFO,
  1109. OPTION_BLEEDINGINDICATION,
  1110. OPTION_CONNECTIVITY_INFO,
  1111. OPTION_HUD_BRIGHTNESS,
  1112. OPTION_AMBIENT_MUSIC_MODE
  1113. };
  1114. // -------------------------------------------------------------------------
  1115. /*
  1116. // Option Access Control Type
  1117. const int OA_CT_NUMERIC = 0;
  1118. const int OA_CT_SWITCH = 1;
  1119. const int OA_CT_LIST = 2;
  1120. // Option Field of view constants
  1121. const float OPTIONS_FIELD_OF_VIEW_MIN = 0.75242724772f;
  1122. const float OPTIONS_FIELD_OF_VIEW_MAX = 1.30322025726f;
  1123. */
  1124. class OptionsAccess: Managed
  1125. {
  1126. //proto private void ~OptionsAccess();
  1127. //proto private void OptionsAccess();
  1128. /**
  1129. \brief AccessType of current option
  1130. \return AccessType
  1131. */
  1132. proto native int GetAccessType();
  1133. /**
  1134. \brief Current option controller type. OA_CT_NUMERIC = 0, OA_CT_SWITCH = 1, OA_CT_LIST = 2
  1135. \return ControlType
  1136. */
  1137. proto native int GetControlType();
  1138. /**
  1139. \brief Applies the option value if the value has changed and forgets the old value. This function has no effect on internal options, see OptionsAccess::Test
  1140. */
  1141. proto native void Apply();
  1142. /**
  1143. \brief Sets the option value internaly if the value has changed and wasnt set immediately upon change
  1144. */
  1145. proto native void Test();
  1146. /**
  1147. \brief Reverts the option value to old value if the value has changed and wasnt applied. This function has effect on internal options
  1148. */
  1149. proto native void Revert();
  1150. /**
  1151. \brief If the option value is changed and not applied or reverted. Value can already be set internally if the value was changed immediately
  1152. \return 1 if the value is changed, 0 othewise
  1153. */
  1154. proto native int IsChanged();
  1155. /**
  1156. \brief If the option value will take effect only after the game is restarted
  1157. \return 1 if the value is changed, 0 othewise
  1158. */
  1159. proto native int NeedRestart();
  1160. /**
  1161. \brief If the value is changed internally immediately upon change.
  1162. \return 1 if the value is changed immediately, 0 othewise
  1163. */
  1164. proto native int SetChangeImmediately();
  1165. //proto native void Initialize();
  1166. /** \name Script Events API
  1167. Setting and getting of ScriptEvents
  1168. */
  1169. //@{
  1170. /**
  1171. \brief Set the events
  1172. \param events \p Managed The events to set
  1173. */
  1174. private proto void SetScriptEvents(Managed events);
  1175. /**
  1176. \brief Get the events
  1177. \return \p Managed If there is any events set, this will return them
  1178. */
  1179. private proto Managed GetScriptEvents();
  1180. /**
  1181. \brief Get the events
  1182. \return \p ParticleManagerEvents If there is any events set, this will return them so that additional functionality can be bound to them
  1183. */
  1184. OptionsAccessEvents GetEvents()
  1185. {
  1186. return OptionsAccessEvents.Cast(GetScriptEvents());
  1187. }
  1188. //@}
  1189. /** \name Events
  1190. Events called from C++
  1191. */
  1192. //@{
  1193. void OnRevert()
  1194. {
  1195. GetEvents().Event_OnRevert.Invoke(this);
  1196. }
  1197. //@}
  1198. };
  1199. //! Invokers for ParticleManager events
  1200. class OptionsAccessEvents
  1201. {
  1202. ref ScriptInvoker Event_OnRevert = new ScriptInvoker();
  1203. }
  1204. // -------------------------------------------------------------------------
  1205. class NumericOptionsAccess extends OptionsAccess
  1206. {
  1207. proto native float ReadValue();
  1208. proto native void WriteValue(float value);
  1209. proto native float GetMin();
  1210. proto native float GetMax();
  1211. proto native float GetDefault();
  1212. };
  1213. // -------------------------------------------------------------------------
  1214. class ListOptionsAccess extends OptionsAccess
  1215. {
  1216. proto native int GetIndex();
  1217. proto native int GetDefaultIndex();
  1218. proto native void SetIndex(int index);
  1219. proto native int GetItemsCount();
  1220. proto void GetItemText(int index, out string value);
  1221. void GetAllItemsText(array<string> output)
  1222. {
  1223. string s;
  1224. for (int i = 0; i < GetItemsCount(); ++i)
  1225. {
  1226. GetItemText(i, s);
  1227. output.Insert(s);
  1228. }
  1229. }
  1230. };
  1231. // -------------------------------------------------------------------------
  1232. class SwitchOptionsAccess extends OptionsAccess
  1233. {
  1234. proto native void Switch();
  1235. proto void GetItemText(out string value);
  1236. proto native int GetIndex();
  1237. proto native int GetDefaultIndex();
  1238. };
  1239. // -------------------------------------------------------------------------
  1240. class GameOptions: Managed
  1241. {
  1242. /**
  1243. \brief Tests, Applies every option and save config with options to file, see OptionsAccess::Test, OptionsAccess::Apply
  1244. */
  1245. proto native void Apply();
  1246. /**
  1247. \brief Load config with options and Revert every option, see OptionsAccess::Revert
  1248. */
  1249. proto native void Revert();
  1250. /**
  1251. \brief Tests every option, see OptionsAccess::Test
  1252. */
  1253. proto native void Test();
  1254. /**
  1255. \brief Get option by index
  1256. @param index
  1257. \return OptionsAccess
  1258. */
  1259. proto native OptionsAccess GetOption(int index);
  1260. /**
  1261. \brief Get option by AccessType
  1262. @param AccessType
  1263. \return OptionsAccess
  1264. */
  1265. proto native OptionsAccess GetOptionByType(int accessType);
  1266. /**
  1267. \brief Registered options count
  1268. \return number of options
  1269. */
  1270. proto native int GetOptionsCount();
  1271. /**
  1272. \brief Checks if any option is changed and needs restart, see OptionsAccess::IsChanged, OptionsAccess::NeedRestart
  1273. \return 1 if such option was found, 0 othewise
  1274. */
  1275. proto native int NeedRestart();
  1276. /**
  1277. \brief Checks if any option is changed, see OptionsAccess::IsChanged
  1278. \return 1 if such option was found, 0 othewise
  1279. */
  1280. proto native int IsChanged();
  1281. /**
  1282. \brief Initializes option values with the current users settings
  1283. */
  1284. proto native void Initialize();
  1285. };
  1286. typedef Link<Object> OLinkT;
  1287. /**
  1288. * @fn SpawnEntity
  1289. * @brief Spawns entity in known inventory location
  1290. *
  1291. * @param[in] object_name \p string Name of item class
  1292. * @param[in] inv_loc \p Inventory Location of the spawned item
  1293. * @return created entity in case of success, null otherwise
  1294. **/
  1295. EntityAI SpawnEntity (string object_name, notnull InventoryLocation inv_loc, int iSetupFlags, int iRotation)
  1296. {
  1297. return GameInventory.LocationCreateEntity(inv_loc, object_name,iSetupFlags,iRotation);
  1298. }
  1299. class Static : Object
  1300. {
  1301. };
  1302. class PrtTest // Temporal class for toggling particles on guns
  1303. {
  1304. static bool m_GunParticlesState = true;
  1305. }
  1306. // #include "Scripts/Classes/Component/_include.c"