gameplay.c 42 KB

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