centraleconomy.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. /** @file */
  2. // -------------------------------------------------------------------------
  3. // object (SF) Spawn Flags (use to setup behavior and/ or trigger functionality)
  4. //
  5. const int ECE_NONE = 0;
  6. const int ECE_SETUP = 2; // process full entity setup (when creating NEW entity)
  7. const int ECE_TRACE = 4; // trace under entity when being placed (from the point of creation)
  8. const int ECE_CENTER = 8; // use center from shape (model) for placement
  9. const int ECE_UPDATEPATHGRAPH = 32; // update navmesh when object placed upon it
  10. const int ECE_ROTATIONFLAGS = 512; // enable rotation flags for object placement
  11. const int ECE_CREATEPHYSICS = 1024; // create collision envelope and related physics data (if object has them)
  12. const int ECE_INITAI = 2048; // init ai
  13. const int ECE_AIRBORNE = 4096; // create flying unit in the air
  14. const int ECE_EQUIP_ATTACHMENTS = 8192; // equip with configured ATTACHMENTS
  15. const int ECE_EQUIP_CARGO = 16384; // equip with configured CARGO
  16. const int ECE_EQUIP = 24576; // equip with configured (ATTACHMENTS + CARGO)
  17. const int ECE_EQUIP_CONTAINER = 2097152; // populate DE/ group CONTAINER during spawn
  18. const int ECE_LOCAL = 1073741824; // create object locally
  19. const int ECE_NOSURFACEALIGN = 262144; // do not align object on surface/ terrain
  20. const int ECE_KEEPHEIGHT = 524288; // keep height when creating object (do not use trace or placement on surface)
  21. const int ECE_NOLIFETIME = 4194304; // do not set lifetime when creating the object
  22. const int ECE_NOPERSISTENCY_WORLD = 8388608; // do not save this object in world
  23. const int ECE_NOPERSISTENCY_CHAR = 16777216; // do not save this object in character
  24. const int ECE_DYNAMIC_PERSISTENCY = 33554432; // spawns in without persistency, once player takes it, persistency will be enabled if available
  25. // note: use predefined combination when not solving something specific
  26. //
  27. const int ECE_IN_INVENTORY = 787456; // ECE_CREATEPHYSICS|ECE_KEEPHEIGHT|ECE_NOSURFACEALIGN
  28. const int ECE_PLACE_ON_SURFACE = 1060; // ECE_CREATEPHYSICS|ECE_UPDATEPATHGRAPH|ECE_TRACE
  29. const int ECE_OBJECT_SWAP = 787488; // ECE_CREATEPHYSICS|ECE_UPDATEPATHGRAPH|ECE_KEEPHEIGHT|ECE_NOSURFACEALIGN
  30. const int ECE_FULL = 25126; // ECE_SETUP|ECE_TRACE|ECE_ROTATIONFLAGS|ECE_UPDATEPATHGRAPH|ECE_EQUIP
  31. // -------------------------------------------------------------------------
  32. // object (RF) Rotation Flags (use to force and/ or invoke placement rotation)
  33. //
  34. const int RF_NONE = 0;
  35. const int RF_FRONT = 1; // front side placement
  36. const int RF_TOP = 2; // top side placement
  37. const int RF_LEFT = 4; // left side placement
  38. const int RF_RIGHT = 8; // right side placement
  39. const int RF_BACK = 16; // back side placement
  40. const int RF_BOTTOM = 32; // bottom side placement
  41. const int RF_ALL = 63; // RF_FRONT|RF_TOP|RF_LEFT|RF_RIGHT|RF_BACK|RF_BOTTOM
  42. const int RF_IGNORE = 64; // ignore placement RF flags - object will spawn as model was created
  43. const int RF_TOPBOTTOM = 34; // RF_TOP|RF_BOTTOM
  44. const int RF_LEFTRIGHT = 12; // RF_LEFT|RF_RIGHT
  45. const int RF_FRONTBACK = 17; // RF_FRONT|RF_BACK
  46. const int RF_RANDOMROT = 64; // allow random rotation around axis when placing
  47. const int RF_ORIGINAL = 128; // use default placement setuped on object in config
  48. const int RF_DECORRECTION = 256; // angle correction when spawning InventoryItem at Building angle
  49. const int RF_DEFAULT = 512; // use default placement setuped on object in config
  50. // -------------------------------------------------------------------------
  51. //! Categories for CEApi.EconomyLog
  52. class EconomyLogCategories
  53. {
  54. private void EconomyLogCategories();
  55. private void ~EconomyLogCategories();
  56. const string Economy = "economy";
  57. const string EconomyRespawn = "economy_respawn";
  58. const string RespawnQueue = "respawn_queue";
  59. const string Container = "container";
  60. const string Matrix = "matrix";
  61. const string UniqueLoot = "uniqueloot";
  62. const string Bind = "bind";
  63. const string SetupFail = "setupfail";
  64. const string Storage = "storage";
  65. const string Classes = "class";
  66. const string Category = "category";
  67. const string Tag = "tag";
  68. const string SCategory = "s_category";
  69. const string STag = "s_tag";
  70. const string SAreaflags = "s_areaflags";
  71. const string SCrafted = "s_crafted";
  72. const string MapGroup = "map_group";
  73. const string MapComplete = "map_complete";
  74. const string InfectedZone = "infected_zone";
  75. }
  76. // -------------------------------------------------------------------------
  77. //! Special strings for CEApi.EconomyMap
  78. class EconomyMapStrings
  79. {
  80. private void EconomyMapStrings();
  81. private void ~EconomyMapStrings();
  82. /**
  83. \brief Generates string that will make CEApi.EconomyMap use all items with this category
  84. \note This is refering to the CE categories of loot defined in cfglimitsdefinition.xml
  85. \warning This is persistent per session, when you set it, it will persist until it is set to something else
  86. \param category \p string The desired loot category
  87. \return \p string The string to pass into CEApi.EconomyMap
  88. @code
  89. GetCEApi().EconomyMap(EconomyMapStrings.Category("food"));
  90. @endcode
  91. */
  92. static string Category(string category)
  93. {
  94. return string.Format("category:%1", category);
  95. }
  96. /**
  97. \brief Generates string that will make CEApi.EconomyMap use all items with this tag
  98. \note This is refering to the CE tags of loot defined in cfglimitsdefinition.xml
  99. \warning This is persistent per session, when you set it, it will persist until it is set to something else
  100. \param category \p string The desired loot tag
  101. \return \p string The string to pass into CEApi.EconomyMap
  102. @code
  103. GetCEApi().EconomyMap(EconomyMapStrings.Tag("floor"));
  104. @endcode
  105. */
  106. static string Tag(string tag)
  107. {
  108. return string.Format("tag:%1", tag);
  109. }
  110. //! Everything
  111. const string ALL_ALL = "all:all";
  112. //! All loot
  113. const string ALL_LOOT = "all:loot";
  114. //! All vehicles
  115. const string ALL_VEHICLE = "all:vehicle";
  116. //! All infected
  117. const string ALL_INFECTED = "all:infected";
  118. //! All animals
  119. const string ALL_ANIMAL = "all:animal";
  120. //! All players
  121. const string ALL_PLAYER = "all:player";
  122. //! All proxies
  123. const string ALL_PROXY = "all:proxy";
  124. //! All static loot spawns
  125. const string ALL_PROXY_STATIC = "all:proxystatic";
  126. //! All dynamic loot spawns
  127. const string ALL_PROXY_DYNAMIC = "all:proxydynamic";
  128. //! All abandoned loot spawns
  129. const string ALL_PROXY_ABANDONED = "all:proxyabandoned";
  130. }
  131. // -------------------------------------------------------------------------
  132. //! Special strings for CEApi.EconomyOutput
  133. class EconomyOutputStrings
  134. {
  135. private void EconomyOutputStrings();
  136. private void ~EconomyOutputStrings();
  137. /**
  138. \brief Lists stats regarding which loot spawn) that are linked together and how many there are
  139. \note In logs: "[linked_groups]"
  140. */
  141. const string LINKS = "links";
  142. /**
  143. \brief Lists loot spawns that have more loot than their maximum + 4
  144. \note In logs: "[autotest:ListSuspiciousGroups]"
  145. */
  146. const string SUSPICIOUS = "suspicious";
  147. /**
  148. \brief Lists DE spawns that have positions that are within supplied range (< fRange, not equal)
  149. \note In logs: "[ClosePosition]"
  150. */
  151. const string DE_CLOSE_POINT = "declosepoint";
  152. /**
  153. \brief Lists loot spawns that have been marked as abandoned
  154. \note In logs: "[autotest:ListAbandonedGroups]"
  155. */
  156. const string ABANDONED = "abandoned";
  157. /**
  158. \brief Lists loot spawns that are not abandoned but have no loot
  159. \note In logs: "[autotest:ListEmptyGroups]"
  160. */
  161. const string EMPTY = "empty";
  162. /**
  163. \brief Lists loot spawns that are not abandoned and within the supplied range (< fRange, not equal)
  164. \note In logs: "[autotest:ListCloseGroups]"
  165. \note Is the same as CEApi.ListCloseProxy
  166. */
  167. const string CLOSE = "close";
  168. /**
  169. \brief Lists the number of objects inside of categories
  170. \note In logs: "[autotest:ProcessDebugLog]"
  171. */
  172. const string WORLD = "world";
  173. /**
  174. \brief Lists overall CE stats
  175. \note In logs: "[autotest:OverallStatus]"
  176. */
  177. const string STATUS = "status";
  178. /**
  179. \brief Lists the maxlootsize of all CE items
  180. \note In logs: "[autotest:ListLootSize]"
  181. */
  182. const string LOOT_SIZE = "lootsize";
  183. }
  184. // -------------------------------------------------------------------------
  185. enum ESpawnVolumeVis
  186. {
  187. OFF = 0,
  188. ADAPTIVE,
  189. VOLUME,
  190. OCCUPIED,
  191. }
  192. // -------------------------------------------------------------------------
  193. /**
  194. \brief API to interact with Central Economy
  195. \note Accessible through GetCEApi, make sure to read the documentation for that as well
  196. \note Any mention of 'storage/' means the '$mission:storage_#' folder
  197. */
  198. class CEApi
  199. {
  200. private void CEApi() {}
  201. private void ~CEApi() {}
  202. /**
  203. \brief Regenerates "storage/spawnpoints.bin" if necessary
  204. \note Already happens automatically when server starts before it is loaded in
  205. @code
  206. GetCEApi().ExportSpawnData();
  207. @endcode
  208. */
  209. proto native void ExportSpawnData();
  210. /**
  211. \brief Generates "storage/export/mapgrouppos.xml"
  212. \param vCenter \p vector Center of area to generate from
  213. \note When using a zero vector, this will automatically get the world center
  214. \param fRadius \p float Radius in meters of area to generate from
  215. \note When 0, this will automatically get a radius covering the map
  216. @code
  217. // Export for whole map
  218. GetCEApi().ExportProxyData();
  219. @endcode
  220. */
  221. proto native void ExportProxyData( vector vCenter = vector.Zero, float fRadius = 0 );
  222. /**
  223. \brief Generates "storage/export/mapgroupcluster.xml"
  224. @code
  225. GetCEApi().ExportClusterData();
  226. @endcode
  227. */
  228. proto native void ExportClusterData();
  229. /**
  230. \brief Generates "storage/export/mapgroupproto.xml"
  231. @code
  232. GetCEApi().ExportProxyProto();
  233. @endcode
  234. */
  235. proto native void ExportProxyProto();
  236. /**
  237. \brief Invalidates loot spawn points which are closer than the radius supplied
  238. \note Will output a message indicating how many points were invalidated
  239. \param fRadius \p float The minimum desired distance in meters between loot spawn points
  240. \note When 0 it will use a radius of 0.5
  241. \param bAllSelections \p bool When false, will only check the points within a container against each other, when true will against all points
  242. @code
  243. // Example: I want there to be a minimum distance of 0.3m between any loot spawn point
  244. GetCEApi().MarkCloseProxy(0.3, true);
  245. @endcode
  246. */
  247. proto native void MarkCloseProxy( float fRadius, bool bAllSelections );
  248. /**
  249. \brief Removes all invalid points
  250. \note Is best paired with a MarkCloseProxy call first to invalidate unwanted points
  251. \note Will output a message indicating the amount of deleted points
  252. @code
  253. GetCEApi().RemoveCloseProxy();
  254. @endcode
  255. */
  256. proto native void RemoveCloseProxy();
  257. /**
  258. \brief Outputs a list of all loot points closer than specified radius
  259. \note This will automatically be checking all points against all points
  260. \note This is a better way of handling it than the above two methods, as it can be then be removed manually from the xmls
  261. \note Is the same as CEApi.EconomyOutput(EconomyOutputStrings.CLOSE, fRadius)
  262. \param fRadius \p float The minimum desired distance in meters between loot spawn points
  263. @code
  264. GetCEApi().ListCloseProxy(0.3);
  265. @endcode
  266. */
  267. proto native void ListCloseProxy( float fRadius );
  268. /**
  269. \brief Will emulate the spawning of the item which is being looked at and generate images (.tga) in storage/lmap and output logs
  270. \note DEVELOPER/DIAG ONLY
  271. \note This will only work if the loot spawner is active
  272. \param sClassName \p string The class name of the desired item to analyze
  273. \note When using "*" as class name, instead of generating images, it will generate a .csv in storage/log containing the output of all spawnable items
  274. \return \p bool Whether the operation was successful, it might fail in certain scenarios if the CE doesn't update in time
  275. @code
  276. GetCEApi().SpawnAnalyze("FlatCap_Grey");
  277. @endcode
  278. */
  279. proto native bool SpawnAnalyze( string sClassName );
  280. /**
  281. \brief Subtracts the supplied value from the current lifetime of all items in the world
  282. \note Uses RadiusLifetimeDecrease under the hood and then calculates the parameters to fit the world
  283. \note Will automatically clamp result between min and max lifetime [3, 316224000] (3 seconds to 10 years)
  284. \param fShift \p float The value in seconds which will be subtracted from the current lifetimes
  285. @code
  286. // Shortens the lifetimes of all items in the world by 3 seconds
  287. GetCEApi().TimeShift(3);
  288. @endcode
  289. */
  290. proto native void TimeShift( float fShift );
  291. /**
  292. \brief Fills in the Debug Lifetime, which will be used for any new DE spawned
  293. \param fLifeTime \p float The lifetime for any DE spawned after this call
  294. \note When this is set back to 0, it will stop using the Debug Lifetime
  295. @code
  296. // Any DE spawned after this call will have a lifetime of 300 seconds
  297. GetCEApi().OverrideLifeTime(300);
  298. @endcode
  299. */
  300. proto native void OverrideLifeTime( float fLifeTime );
  301. /**
  302. \brief Force spawn specific prototype group + loot at position
  303. \note DEVELOPER/DIAG ONLY
  304. \note This can also spawn in other CE & DE related objects, but is best used exclusively for testing prototype groups
  305. \param sGroupName \p string The group name to spawn
  306. \param vPos \p vector The position to spawn the Entity at
  307. \param fAngle \p float Angle to spawn the Entity with in degrees [0, 360]
  308. \note When a negative value, will pick a random one
  309. \return \p Entity The spawned Entity or null if unsuccessful
  310. @code
  311. GetCEApi().SpawnGroup("Land_Shed_M1", Vector(5, 10, 5));
  312. @endcode
  313. */
  314. proto native Entity SpawnGroup( string sGroupName, vector vPos, float fAngle = -1 );
  315. /**
  316. \brief Force spawn specific dynamic event
  317. \note DEVELOPER/DIAG ONLY
  318. \note Versatile, can be used for Animal, Infected, Static, Item and Vehicle
  319. \note Is the only one capable of spawning DE's that have DE Groups
  320. \note Is the same as the next one, but has ECE_FULL flags and a hidden flag which overrides herd limit
  321. \note This is also FORCE spawn, so it will bypass any limit and avoidance checks
  322. \param sEvName \p string The DE to spawn
  323. \param vPos \p vector The position to spawn the Entity at
  324. \param fAngle \p float Angle to spawn the Entity with in degrees [0, 360]
  325. \note When a negative value, will pick a random one
  326. \return \p bool Whether the spawn was successful
  327. @code
  328. GetCEApi().SpawnDE("StaticHeliCrash", Vector(5, 10, 5));
  329. @endcode
  330. */
  331. proto native void SpawnDE( string sEvName, vector vPos, float fAngle = -1 );
  332. /**
  333. \brief Force spawn specific dynamic event
  334. \note DEVELOPER/DIAG ONLY
  335. \note Is the same one as above but with the possibility of custom flags
  336. \param sEvName \p string The DE to spawn
  337. \param vPos \p vector The position to spawn the Entity at
  338. \param fAngle \p float Angle to spawn the Entity with in degrees [0, 360]
  339. \note When a negative value, will pick a random one
  340. \param uFlags \p int ECE flags to apply while spawning the DE
  341. \return \p bool Whether the spawn was successful
  342. @code
  343. GetCEApi().SpawnDEEx("StaticHeliCrash", Vector(5, 10, 5), ECE_FULL);
  344. @endcode
  345. */
  346. proto native void SpawnDEEx( string sEvName, vector vPos, float fAngle, int uFlags );
  347. /**
  348. \brief Spawn an item through CE
  349. \note DEVELOPER/DIAG ONLY
  350. \param sEvName \p string The DE to spawn
  351. \param vPos \p vector The position to spawn the Entity at
  352. \param fAngle \p float Angle to spawn the Entity with in degrees [0, 360]
  353. \note When a negative value, will pick a random one
  354. \param iCount \p int The amount of items
  355. \param fRange \p float Circle radius
  356. \note When iCount is larger than 1, changing this will make it so that they are spawned in a circle around vPos
  357. @code
  358. GetCEApi().SpawnLoot("Deagle", Vector(5, 10, 5), 0, 9, 1);
  359. @endcode
  360. */
  361. proto native void SpawnLoot( string sEvName, vector vPos, float fAngle, int iCount = 1, float fRange = 1 );
  362. /**
  363. \brief Spawn all entities with dynamic category through CE
  364. \note DEVELOPER/DIAG ONLY
  365. \note Will print additional logs to RPT
  366. \param vPos \p vector The position to spawn the Entities at
  367. \note This will be the starting position, the items will be split into segments by CE BBox size (smallest to largest)
  368. \param bShowCylinders \p bool Whether to draw the CE BBox with debug shapes
  369. \note Red: Invalid BBox; Yellow: Not in DB; Green: All ok
  370. \param fDefaultDistance \p float The default distance to use when the entity does not have a CE BBox
  371. \note This means that all the ones with invalid CE BBoxes will be piled up at the starting position when this is 0
  372. @code
  373. GetCEApi().SpawnDynamic(Vector(5, 10, 5), true);
  374. @endcode
  375. */
  376. proto native void SpawnDynamic( vector vPos, bool bShowCylinders = true, float fDefaultDistance = 0 );
  377. /**
  378. \brief Spawn all entities with vehicles category through CE
  379. \note DEVELOPER/DIAG ONLY
  380. \note Will print additional logs to RPT
  381. \param vPos \p vector The position to spawn the Entities at
  382. \note This will be the starting position, vehicles spawn with 20m spacing
  383. \note Make sure you do it on a surface as flat and open as possible, they need a lot of space
  384. \param bShowCylinders \p bool Does nothing for Vehicles, left for backwards compat
  385. \param fDefaultDistance \p float The default distance to use when the entity does not have a CE BBox
  386. \note This means that all the ones with invalid CE BBoxes will be piled up at the starting position when this is 0
  387. @code
  388. GetCEApi().SpawnVehicles(Vector(5, 10, 5));
  389. @endcode
  390. */
  391. proto native void SpawnVehicles( vector vPos, bool bShowCylinders = false, float fDefaultDistance = 20 );
  392. /**
  393. \brief Spawn all entities with building category through CE
  394. \note DEVELOPER/DIAG ONLY
  395. \note Will print additional logs to RPT
  396. \param vPos \p vector The position to spawn the Entities at
  397. \note This will be the starting position, the items will be split into segments by CE BBox size (smallest to largest)
  398. \param bShowCylinders \p bool Whether to draw the CE BBox with debug shapes
  399. \note Red: Invalid BBox; Yellow: Not in DB; Green: All ok
  400. \note These will most likely just always be red
  401. \param fDefaultDistance \p float The default distance to use when the entity does not have a CE BBox
  402. \note This means that all the ones with invalid CE BBoxes will be piled up at the starting position when this is 0
  403. @code
  404. GetCEApi().SpawnBuilding(Vector(5, 10, 5), true);
  405. @endcode
  406. */
  407. proto native void SpawnBuilding( vector vPos, bool bShowCylinders = false, float fDefaultDistance = 20 );
  408. /**
  409. \brief Spawn an entity through CE
  410. \note DEVELOPER/DIAG ONLY
  411. \note Is similar to SpawnLoot, but works better on Animal/Infected/Vehicle
  412. \param sClassName \p string The entity to spawn
  413. \param vPos \p vector The position to spawn the Entity at
  414. \param fRange \p float Circle radius
  415. \note When iCount is larger than 1, changing this will make it so that they are spawned in a circle around vPos
  416. \param iCount \p int The amount of items
  417. @code
  418. GetCEApi().SpawnEntity("Deagle", Vector(5, 10, 5), 1, 9);
  419. @endcode
  420. */
  421. proto native void SpawnEntity( string sClassName, vector vPos, float fRange, int iCount );
  422. /**
  423. \brief Spawn an entity through CE
  424. \note DEVELOPER/DIAG ONLY
  425. \note Is the same as SpawnEntity, but spawns only one and returns the spawned Object
  426. \param sClassName \p string The entity to spawn
  427. \param vPos \p vector The position to spawn the Entity at
  428. \return \p Object The spawned Object
  429. @code
  430. GetCEApi().SpawnSingleEntity("Deagle", Vector(5, 10, 5));
  431. @endcode
  432. */
  433. proto native Object SpawnSingleEntity( string sClassName, vector vPos );
  434. /**
  435. \brief Spawn an entity through CE
  436. \note DEVELOPER/DIAG ONLY
  437. \note Is the same as SpawnEntity, under the hood it just defaults to RF_ORIGINAL
  438. \param sClassName \p string The entity to spawn
  439. \param vPos \p vector The position to spawn the Entity at
  440. \param fRange \p float Circle radius
  441. \note When iCount is larger than 1, changing this will make it so that they are spawned in a circle around vPos
  442. \param iCount \p int The amount of items
  443. \param iFlags \p int The rotation flags to apply
  444. @code
  445. GetCEApi().SpawnRotation("Deagle", Vector(5, 10, 5), 1, 9, RF_ALL);
  446. @endcode
  447. */
  448. proto native void SpawnRotation( string sClassName, vector vPos, float fRange, int iCount, int iFlags );
  449. /**
  450. \brief Spawn an entity through CE, x amount of times in a grid
  451. \note DEVELOPER/DIAG ONLY
  452. \note The name may imply it does something else, but a profiler is needed to actually benchmark it
  453. \note The position starts at 0 0 0
  454. \param sClassName \p string The entity to spawn
  455. \param iCount \p int The amount of items
  456. @code
  457. GetCEApi().SpawnPerfTest("Deagle", 30);
  458. @endcode
  459. */
  460. proto native void SpawnPerfTest( string sClassName, int iCount );
  461. /**
  462. \brief Queue up the depleting of lifetime of everything in the world
  463. \note DEVELOPER/DIAG ONLY
  464. @code
  465. GetCEApi().CleanMap();
  466. @endcode
  467. */
  468. proto native void CleanMap();
  469. /**
  470. \brief Outputs debug file to storage/log/*.csv
  471. \note DEVELOPER/DIAG ONLY
  472. \param sLogType \p string The type of log (EconomyLogCategories)
  473. @code
  474. GetCEApi().EconomyLog(EconomyLogCategories.Economy);
  475. @endcode
  476. */
  477. proto native void EconomyLog( string sLogType );
  478. /**
  479. \brief Outputs debug file to storage/lmap/*.tga showing the current places this is spawned
  480. \note DEVELOPER/DIAG ONLY
  481. \note This works best when you have an image of the map to overlay the tga with afterwards
  482. \param sMapType \p string The type of lmap, can be just a class name or a special string
  483. \note There are several prefixes and sets of strings that can be passed in here, see EconomyMapStrings
  484. @code
  485. // To check only a specific item
  486. GetCEApi().EconomyMap("Deagle");
  487. @endcode
  488. */
  489. proto native void EconomyMap( string sMapType );
  490. /**
  491. \brief Outputs debug logs into server log or rpt
  492. \note DEVELOPER/DIAG ONLY
  493. \param sOutputType \p string One of the strings specified in EconomyOutputStrings
  494. \param fRange \p float Range parameter used for some of the options
  495. @code
  496. GetCEApi().EconomyOutput(EconomyOutputStrings.CLOSE, 3);
  497. @endcode
  498. */
  499. proto native void EconomyOutput( string sOutputType, float fRange );
  500. /**
  501. \brief Process lifetime increase within radius by value (sec)
  502. \note Will automatically clamp result between min and max lifetime [3, 316224000] (3 seconds to 10 years)
  503. \param vCenter \p vector The center point
  504. \param fRadius \p float The radius around the center point
  505. \param fValue \p float The value to increase the lifetime by
  506. \note When 0, this will reset it to default instead (but it's better to use RadiusLifetimeReset still)
  507. @code
  508. GetCEApi().RadiusLifetimeIncrease(Vector(500, 0, 500), 3, 500);
  509. @endcode
  510. */
  511. proto native void RadiusLifetimeIncrease( vector vCenter, float fRadius, float fValue );
  512. /**
  513. \brief Process lifetime decrease within radius by value (sec)
  514. \note Will automatically clamp result between min and max lifetime [3, 316224000] (3 seconds to 10 years)
  515. \param vCenter \p vector The center point
  516. \param fRadius \p float The radius around the center point
  517. \param fValue \p float The value to decrease the lifetime by
  518. @code
  519. GetCEApi().RadiusLifetimeDecrease(Vector(500, 0, 500), 3, 500);
  520. @endcode
  521. */
  522. proto native void RadiusLifetimeDecrease( vector vCenter, float fRadius, float fValue );
  523. /**
  524. \brief Process lifetime reset to default value from DB within radius
  525. \param vCenter \p vector The center point
  526. \param fRadius \p float The radius around the center point
  527. @code
  528. GetCEApi().RadiusLifetimeReset(Vector(500, 0, 500), 3);
  529. @endcode
  530. */
  531. proto native void RadiusLifetimeReset( vector vCenter, float fRadius );
  532. /** \name Globals API
  533. Get values from globals.xml
  534. */
  535. //@{
  536. /**
  537. \brief Get int from globals.xml
  538. \note type="0"
  539. \param varName \p string The name of the entry
  540. \return \p int The value or int.MIN if not found/not an int
  541. */
  542. proto native int GetCEGlobalInt(string varName);
  543. /**
  544. \brief Get float from globals.xml
  545. \note type="1"
  546. \param varName \p string The name of the entry
  547. \return \p float The value or float.MIN if not found/not a float
  548. */
  549. proto native float GetCEGlobalFloat(string varName);
  550. /**
  551. \brief Get string from globals.xml
  552. \note type="2"
  553. \param varName \p string The name of the entry
  554. \return \p string The value or empty string if not found/not a string
  555. */
  556. proto native string GetCEGlobalString(string varName);
  557. //@}
  558. /** \name Avoidance API
  559. Optimized internal methods that the CE uses to avoid spawning DE within certain distances
  560. */
  561. //@{
  562. /**
  563. \brief Check if there is a player within a radius
  564. \param vPos \p vector The center point
  565. \param fDistance \p float The radius around the center point
  566. \return \p bool Returns false when there is a player inside supplied area, true when it successfully avoided players
  567. @code
  568. GetCEApi().AvoidPlayer(Vector(500, 0, 500), 20);
  569. @endcode
  570. */
  571. proto native bool AvoidPlayer(vector vPos, float fDistance); // return false when there is a player
  572. /**
  573. \brief Check if there is a vehicle within a radius
  574. \param vPos \p vector The center point
  575. \param fDistance \p float The radius around the center point
  576. \param sDEName \p string A specific DE to avoid, if left empty, will avoid all vehicles
  577. \return \p bool Returns false when there is a vehicle inside supplied area, true when it successfully avoided vehicles
  578. @code
  579. GetCEApi().AvoidVehicle(Vector(500, 0, 500), 500, "VehicleCivilianSedan");
  580. @endcode
  581. */
  582. proto native bool AvoidVehicle(vector vPos, float fDistance, string sDEName = "");
  583. /**
  584. \brief Check if there is a vehicle within a radius
  585. \param vPos \p vector The center point
  586. \param fRange \p float The radius around the center point
  587. \return \p int The amoutn of players inside supplied area
  588. @code
  589. GetCEApi().CountPlayersWithinRange(Vector(500, 0, 500), 500);
  590. @endcode
  591. */
  592. proto native int CountPlayersWithinRange(vector vPos, float fRange);
  593. //@}
  594. /** \name CE Debug menu Script API
  595. DIAG ONLY: These options are available from the in-game debug menu on Diag exe (Game > Central Economy), documentation can be found on wiki
  596. */
  597. //@{
  598. // "Loot Spawn Edit"
  599. //{
  600. //! "Spawn Volume Vis"
  601. proto native void LootSetSpawnVolumeVisualisation(ESpawnVolumeVis mode);
  602. //! "Setup Vis"
  603. proto native void LootToggleSpawnSetup(bool mode);
  604. //! "Edit Volume"
  605. proto native void LootToggleVolumeEditing(bool mode);
  606. //! "Re-Trace Group Points"
  607. proto native void LootRetraceGroupPoints();
  608. //! "Export Group >>"
  609. proto native void LootExportGroup();
  610. //! "Export All Groups >>>>" / GetCEApi.ExportProxyProto();
  611. proto native void LootExportAllGroups();
  612. //! "<<< Export Map" / GetCEApi.ExportProxyData(vector.Zero, 0);
  613. proto native void LootExportMap();
  614. //! "<<< Export Clusters" / GetCEApi().ExportClusterData()
  615. proto native void LootExportClusters();
  616. //}
  617. // "Loot Tool"
  618. //{
  619. //! "Deplete Lifetime"
  620. proto native void LootDepleteLifetime();
  621. //! "Set Damage = 1.0"
  622. proto native void LootSetDamageToOne();
  623. //! "Damage + Deplete"
  624. proto native void LootDepleteAndDamage();
  625. //}
  626. // "Infected"
  627. //{
  628. //! "Infected Vis"
  629. proto native void InfectedToggleVisualisation(bool mode);
  630. //! "Infected Zone Info"
  631. proto native void InfectedToggleZoneInfo(bool mode);
  632. //! "Infected Spawn"
  633. proto native void InfectedSpawn();
  634. //! "Reset Cleanup"
  635. proto native void InfectedResetCleanup();
  636. //}
  637. // "Animal"
  638. //{
  639. //! "Animal Vis"
  640. proto native void AnimalToggleVisualisation(bool mode);
  641. //! "Animal Spawn"
  642. proto native void AnimalSpawn();
  643. //! "Ambient Spawn"
  644. proto native void AnimalAmbientSpawn();
  645. //}
  646. //! "Vehicle&Wreck Vis"
  647. proto native void ToggleVehicleAndWreckVisualisation(bool mode);
  648. //! "Loot Vis"
  649. proto native void ToggleLootVisualisation(bool mode);
  650. //! "Cluster Vis"
  651. proto native void ToggleClusterVisualisation(bool mode);
  652. //! "Dynamic Events Status"
  653. proto native void ToggleDynamicEventStatus(bool mode);
  654. //! "Dynamic Events Vis"
  655. proto native void ToggleDynamicEventVisualisation(bool mode);
  656. //! "Dynamic Events Spawn"
  657. proto native void DynamicEventSpawn();
  658. //! "Export Dyn Event >>"
  659. proto native void DynamicEventExport();
  660. //! "Overall Stats"
  661. proto native void ToggleOverallStats(bool mode);
  662. //@}
  663. /** \name DEPRECATED/LEGACY
  664. These don't do anything anymore but are left for backwards compatibility
  665. */
  666. //@{
  667. proto native void PlatformStatTest();
  668. proto native void LootToggleProxyEditing(bool mode);
  669. proto native void OnUpdate();
  670. //@}
  671. };
  672. /**
  673. \brief Get the CE API
  674. \warning Only exists when the game has CE enabled
  675. \note This means that this will work on anything which is running a mission with an initialized Hive
  676. \note Client does not have Hive when connected to a server, only the server does if it was set up in the init.c
  677. */
  678. proto native CEApi GetCEApi();
  679. // -------------------------------------------------------------------------
  680. class CEItemProfile
  681. {
  682. private void CEItemProfile() {}
  683. private void ~CEItemProfile() {}
  684. proto native int GetNominal(); // nominal - how many items should be aproximately in map
  685. proto native int GetMin(); // min - minimal count should be available in map
  686. proto native float GetQuantityMin(); // min quantity (0.0 - 1.0) (like ammobox - this determine how many bullets are there, or water bottle)
  687. proto native float GetQuantityMax(); // max quantity (0.0 - 1.0) (like ammobox - this determine how many bullets are there, or water bottle)
  688. proto native float GetQuantity(); // random quantity (0.0 - 1.0)
  689. proto native float GetLifetime(); // maximum lifetime in (seconds) - what is the idle before item abandoned at ground gets deleted
  690. proto native float GetRestock(); // restock is oposite of lifetime - idle before item is allowed to respawn when required
  691. proto native int GetCost(); // cost of item determines its 'value' for players (this serve as priority during respawn and cleanup operation)
  692. proto native int GetUsageFlags(); // area usage flags (each bit has assigned group - which as part of map overlay effectively affects spawning)
  693. proto native int GetValueFlags(); // area value flags (each bit has assigned group - which as part of map overlay effectively affects spawning)
  694. };