@v12-engine/engine 0.1.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (951) hide show
  1. package/dist/abilities/amounts.d.ts +28 -0
  2. package/dist/abilities/amounts.js +74 -0
  3. package/dist/abilities/amounts.js.map +1 -0
  4. package/dist/abilities/buffs.d.ts +106 -6
  5. package/dist/abilities/buffs.js +443 -0
  6. package/dist/abilities/buffs.js.map +1 -0
  7. package/dist/abilities/castTold.d.ts +2 -0
  8. package/dist/abilities/castTold.js +66 -0
  9. package/dist/abilities/castTold.js.map +1 -0
  10. package/dist/abilities/chance.d.ts +38 -0
  11. package/dist/abilities/chance.js +77 -0
  12. package/dist/abilities/chance.js.map +1 -0
  13. package/dist/abilities/charges.d.ts +18 -0
  14. package/dist/abilities/charges.js +101 -0
  15. package/dist/abilities/charges.js.map +1 -0
  16. package/dist/abilities/control.d.ts +28 -0
  17. package/dist/abilities/control.js +113 -0
  18. package/dist/abilities/control.js.map +1 -0
  19. package/dist/abilities/dispel.js +51 -0
  20. package/dist/abilities/dispel.js.map +1 -0
  21. package/dist/abilities/effectFields.d.ts +1 -1
  22. package/dist/abilities/effectFields.js +676 -0
  23. package/dist/abilities/effectFields.js.map +1 -0
  24. package/dist/abilities/effectIndex.d.ts +27 -0
  25. package/dist/abilities/effectIndex.js +64 -0
  26. package/dist/abilities/effectIndex.js.map +1 -0
  27. package/dist/abilities/effects/buff.d.ts +9 -3
  28. package/dist/abilities/effects/buff.js +84 -0
  29. package/dist/abilities/effects/buff.js.map +1 -0
  30. package/dist/abilities/effects/conditions.d.ts +2 -0
  31. package/dist/abilities/effects/conditions.js +41 -0
  32. package/dist/abilities/effects/conditions.js.map +1 -0
  33. package/dist/abilities/effects/core.js +54 -0
  34. package/dist/abilities/effects/core.js.map +1 -0
  35. package/dist/abilities/effects/damage.d.ts +1 -1
  36. package/dist/abilities/effects/damage.js +43 -0
  37. package/dist/abilities/effects/damage.js.map +1 -0
  38. package/dist/abilities/effects/heal.d.ts +2 -2
  39. package/dist/abilities/effects/heal.js +51 -0
  40. package/dist/abilities/effects/heal.js.map +1 -0
  41. package/dist/abilities/effects/missile.d.ts +13 -1
  42. package/dist/abilities/effects/missile.js +104 -0
  43. package/dist/abilities/effects/missile.js.map +1 -0
  44. package/dist/abilities/effects/morph.d.ts +5 -0
  45. package/dist/abilities/effects/morph.js +43 -0
  46. package/dist/abilities/effects/morph.js.map +1 -0
  47. package/dist/abilities/effects/moves.d.ts +16 -4
  48. package/dist/abilities/effects/moves.js +212 -0
  49. package/dist/abilities/effects/moves.js.map +1 -0
  50. package/dist/abilities/effects/passives.d.ts +19 -9
  51. package/dist/abilities/effects/passives.js +131 -0
  52. package/dist/abilities/effects/passives.js.map +1 -0
  53. package/dist/abilities/effects/proxy.d.ts +5 -0
  54. package/dist/abilities/effects/proxy.js +60 -0
  55. package/dist/abilities/effects/proxy.js.map +1 -0
  56. package/dist/abilities/effects/sight.d.ts +2 -2
  57. package/dist/abilities/effects/sight.js +39 -0
  58. package/dist/abilities/effects/sight.js.map +1 -0
  59. package/dist/abilities/effects/spawn.d.ts +5 -2
  60. package/dist/abilities/effects/spawn.js +40 -0
  61. package/dist/abilities/effects/spawn.js.map +1 -0
  62. package/dist/abilities/effects/timed.d.ts +2 -2
  63. package/dist/abilities/effects/timed.js +96 -0
  64. package/dist/abilities/effects/timed.js.map +1 -0
  65. package/dist/abilities/effects/trade.d.ts +1 -1
  66. package/dist/abilities/effects/trade.js +25 -0
  67. package/dist/abilities/effects/trade.js.map +1 -0
  68. package/dist/abilities/effects.d.ts +97 -23
  69. package/dist/abilities/effects.js +860 -0
  70. package/dist/abilities/effects.js.map +1 -0
  71. package/dist/abilities/land.d.ts +38 -4
  72. package/dist/abilities/land.js +189 -0
  73. package/dist/abilities/land.js.map +1 -0
  74. package/dist/abilities/recast.d.ts +45 -0
  75. package/dist/abilities/recast.js +118 -0
  76. package/dist/abilities/recast.js.map +1 -0
  77. package/dist/abilities/scaled.js +40 -0
  78. package/dist/abilities/scaled.js.map +1 -0
  79. package/dist/abilities/screen.d.ts +6 -0
  80. package/dist/abilities/screen.js +83 -0
  81. package/dist/abilities/screen.js.map +1 -0
  82. package/dist/abilities/shapes.d.ts +66 -0
  83. package/dist/abilities/shapes.js +122 -0
  84. package/dist/abilities/shapes.js.map +1 -0
  85. package/dist/abilities/text.d.ts +14 -2
  86. package/dist/abilities/text.js +204 -0
  87. package/dist/abilities/text.js.map +1 -0
  88. package/dist/abilities/triggers.d.ts +98 -0
  89. package/dist/abilities/triggers.js +351 -0
  90. package/dist/abilities/triggers.js.map +1 -0
  91. package/dist/abilityChanges.d.ts +131 -0
  92. package/dist/abilityChanges.js +345 -0
  93. package/dist/abilityChanges.js.map +1 -0
  94. package/dist/ai/area.d.ts +4 -1
  95. package/dist/ai/brain.d.ts +4 -1
  96. package/dist/ai/brain.js +844 -0
  97. package/dist/ai/brain.js.map +1 -0
  98. package/dist/ai/budget.js +74 -0
  99. package/dist/ai/budget.js.map +1 -0
  100. package/dist/ai/checks.d.ts +9 -1
  101. package/dist/ai/checks.js +242 -0
  102. package/dist/ai/checks.js.map +1 -0
  103. package/dist/ai/computer.d.ts +11 -4
  104. package/dist/ai/computer.js +251 -0
  105. package/dist/ai/computer.js.map +1 -0
  106. package/dist/ai/defence.d.ts +4 -0
  107. package/dist/ai/defence.js +430 -0
  108. package/dist/ai/defence.js.map +1 -0
  109. package/dist/ai/define.d.ts +3 -2
  110. package/dist/ai/define.js +31 -0
  111. package/dist/ai/define.js.map +1 -0
  112. package/dist/ai/economy.d.ts +10 -7
  113. package/dist/ai/economy.js +780 -0
  114. package/dist/ai/economy.js.map +1 -0
  115. package/dist/ai/geometry.js +38 -0
  116. package/dist/ai/geometry.js.map +1 -0
  117. package/dist/ai/goals.d.ts +1 -0
  118. package/dist/ai/goals.js +560 -0
  119. package/dist/ai/goals.js.map +1 -0
  120. package/dist/ai/knowledge.d.ts +72 -7
  121. package/dist/ai/knowledge.js +804 -0
  122. package/dist/ai/knowledge.js.map +1 -0
  123. package/dist/ai/lanes.d.ts +10 -2
  124. package/dist/ai/lanes.js +715 -0
  125. package/dist/ai/lanes.js.map +1 -0
  126. package/dist/ai/melee/build.js +264 -0
  127. package/dist/ai/melee/build.js.map +1 -0
  128. package/dist/ai/melee/goals.d.ts +7 -0
  129. package/dist/ai/melee/goals.js +720 -0
  130. package/dist/ai/melee/goals.js.map +1 -0
  131. package/dist/ai/melee/heroes.js +68 -0
  132. package/dist/ai/melee/heroes.js.map +1 -0
  133. package/dist/ai/melee/index.d.ts +1 -1
  134. package/dist/ai/melee/index.js +51 -0
  135. package/dist/ai/melee/index.js.map +1 -0
  136. package/dist/ai/melee/production.js +29 -0
  137. package/dist/ai/melee/production.js.map +1 -0
  138. package/dist/ai/melee/surrender.js +64 -0
  139. package/dist/ai/melee/surrender.js.map +1 -0
  140. package/dist/ai/micro.d.ts +9 -0
  141. package/dist/ai/micro.js +1316 -0
  142. package/dist/ai/micro.js.map +1 -0
  143. package/dist/ai/mission.d.ts +9 -2
  144. package/dist/ai/mission.js +538 -0
  145. package/dist/ai/mission.js.map +1 -0
  146. package/dist/ai/missionRules.d.ts +1 -1
  147. package/dist/ai/missionRules.js +26 -0
  148. package/dist/ai/missionRules.js.map +1 -0
  149. package/dist/ai/module.d.ts +6 -2
  150. package/dist/ai/module.js +37 -0
  151. package/dist/ai/module.js.map +1 -0
  152. package/dist/ai/options.d.ts +3 -3
  153. package/dist/ai/plans/build.d.ts +20 -1
  154. package/dist/ai/plans/build.js +608 -0
  155. package/dist/ai/plans/build.js.map +1 -0
  156. package/dist/ai/plans/placement.d.ts +4 -1
  157. package/dist/ai/plans/placement.js +295 -0
  158. package/dist/ai/plans/placement.js.map +1 -0
  159. package/dist/ai/plans/plans.d.ts +9 -0
  160. package/dist/ai/plans/plans.js +110 -0
  161. package/dist/ai/plans/plans.js.map +1 -0
  162. package/dist/ai/plans/production.d.ts +14 -2
  163. package/dist/ai/plans/production.js +434 -0
  164. package/dist/ai/plans/production.js.map +1 -0
  165. package/dist/ai/plans/purse.d.ts +6 -3
  166. package/dist/ai/plans/purse.js +139 -0
  167. package/dist/ai/plans/purse.js.map +1 -0
  168. package/dist/ai/plans/tech.d.ts +6 -0
  169. package/dist/ai/plans/tech.js +122 -0
  170. package/dist/ai/plans/tech.js.map +1 -0
  171. package/dist/ai/profiles.d.ts +4 -4
  172. package/dist/{profiles-B3NS9jwk.js → ai/profiles.js} +3 -98
  173. package/dist/ai/profiles.js.map +1 -0
  174. package/dist/ai/reach.js +54 -0
  175. package/dist/ai/reach.js.map +1 -0
  176. package/dist/ai/report.d.ts +8 -0
  177. package/dist/ai/report.js +87 -0
  178. package/dist/ai/report.js.map +1 -0
  179. package/dist/ai/roles.d.ts +4 -0
  180. package/dist/ai/roles.js +207 -0
  181. package/dist/ai/roles.js.map +1 -0
  182. package/dist/ai/rules.d.ts +8 -2
  183. package/dist/ai/rules.js +416 -0
  184. package/dist/ai/rules.js.map +1 -0
  185. package/dist/ai/scouting.d.ts +6 -0
  186. package/dist/ai/scouting.js +324 -0
  187. package/dist/ai/scouting.js.map +1 -0
  188. package/dist/ai/settings.js +99 -0
  189. package/dist/ai/settings.js.map +1 -0
  190. package/dist/ai/squads.d.ts +21 -2
  191. package/dist/ai/squads.js +916 -0
  192. package/dist/ai/squads.js.map +1 -0
  193. package/dist/ai/strength.js +320 -0
  194. package/dist/ai/strength.js.map +1 -0
  195. package/dist/ai/task.d.ts +3 -1
  196. package/dist/ai/task.js +17 -0
  197. package/dist/ai/task.js.map +1 -0
  198. package/dist/ai/tasks/attack.js +24 -0
  199. package/dist/ai/tasks/attack.js.map +1 -0
  200. package/dist/ai/tasks/capture.d.ts +3 -3
  201. package/dist/ai/tasks/capture.js +37 -0
  202. package/dist/ai/tasks/capture.js.map +1 -0
  203. package/dist/ai/tasks/creep.js +29 -0
  204. package/dist/ai/tasks/creep.js.map +1 -0
  205. package/dist/ai/tasks/defend.js +61 -0
  206. package/dist/ai/tasks/defend.js.map +1 -0
  207. package/dist/ai/tasks/drop.js +81 -0
  208. package/dist/ai/tasks/drop.js.map +1 -0
  209. package/dist/ai/tasks/escort.js +59 -0
  210. package/dist/ai/tasks/escort.js.map +1 -0
  211. package/dist/ai/tasks/gather.js +48 -0
  212. package/dist/ai/tasks/gather.js.map +1 -0
  213. package/dist/ai/tasks/harass.js +39 -0
  214. package/dist/ai/tasks/harass.js.map +1 -0
  215. package/dist/ai/tasks/hold.js +32 -0
  216. package/dist/ai/tasks/hold.js.map +1 -0
  217. package/dist/ai/tasks/index.js +34 -0
  218. package/dist/ai/tasks/index.js.map +1 -0
  219. package/dist/ai/tasks/move.js +26 -0
  220. package/dist/ai/tasks/move.js.map +1 -0
  221. package/dist/ai/tasks/patrol.js +59 -0
  222. package/dist/ai/tasks/patrol.js.map +1 -0
  223. package/dist/ai/tasks/retreat.js +28 -0
  224. package/dist/ai/tasks/retreat.js.map +1 -0
  225. package/dist/ai/tasks/scout.js +73 -0
  226. package/dist/ai/tasks/scout.js.map +1 -0
  227. package/dist/ai/tasks/shared.d.ts +1 -1
  228. package/dist/ai/tasks/shared.js +137 -0
  229. package/dist/ai/tasks/shared.js.map +1 -0
  230. package/dist/ai/team.d.ts +18 -1
  231. package/dist/ai/team.js +492 -0
  232. package/dist/ai/team.js.map +1 -0
  233. package/dist/ai/threat.d.ts +6 -0
  234. package/dist/ai/threat.js +206 -0
  235. package/dist/ai/threat.js.map +1 -0
  236. package/dist/ai/view.d.ts +21 -7
  237. package/dist/ai/view.js +677 -0
  238. package/dist/ai/view.js.map +1 -0
  239. package/dist/ai/waves.d.ts +6 -0
  240. package/dist/ai/waves.js +410 -0
  241. package/dist/ai/waves.js.map +1 -0
  242. package/dist/ai.js +54 -6239
  243. package/dist/aiTesting.d.ts +6 -3
  244. package/dist/aiTesting.js +229 -0
  245. package/dist/aiTesting.js.map +1 -0
  246. package/dist/areas.d.ts +4 -1
  247. package/dist/areas.js +295 -0
  248. package/dist/areas.js.map +1 -0
  249. package/dist/attacks.d.ts +3 -3
  250. package/dist/attacks.js +127 -0
  251. package/dist/attacks.js.map +1 -0
  252. package/dist/burning.d.ts +267 -0
  253. package/dist/burning.js +795 -0
  254. package/dist/burning.js.map +1 -0
  255. package/dist/bytes.js +21 -0
  256. package/dist/bytes.js.map +1 -0
  257. package/dist/callings.d.ts +71 -0
  258. package/dist/callings.js +157 -0
  259. package/dist/callings.js.map +1 -0
  260. package/dist/cameraOrders.d.ts +78 -0
  261. package/dist/cameraOrders.js +114 -0
  262. package/dist/cameraOrders.js.map +1 -0
  263. package/dist/camps.d.ts +70 -4
  264. package/dist/camps.js +501 -0
  265. package/dist/camps.js.map +1 -0
  266. package/dist/capture.d.ts +15 -3
  267. package/dist/capture.js +304 -0
  268. package/dist/capture.js.map +1 -0
  269. package/dist/cellLayers.d.ts +78 -13
  270. package/dist/cellLayers.js +275 -0
  271. package/dist/cellLayers.js.map +1 -0
  272. package/dist/cellPatches.d.ts +24 -0
  273. package/dist/cellPatches.js +73 -0
  274. package/dist/cellPatches.js.map +1 -0
  275. package/dist/cinematics.d.ts +10 -5
  276. package/dist/cinematics.js +161 -0
  277. package/dist/cinematics.js.map +1 -0
  278. package/dist/clock.d.ts +2 -2
  279. package/dist/clock.js +78 -0
  280. package/dist/clock.js.map +1 -0
  281. package/dist/commands.d.ts +36 -4
  282. package/dist/commands.js +636 -0
  283. package/dist/commands.js.map +1 -0
  284. package/dist/components.d.ts +31 -10
  285. package/dist/components.js +74 -0
  286. package/dist/components.js.map +1 -0
  287. package/dist/computers.d.ts +4 -4
  288. package/dist/computers.js +194 -0
  289. package/dist/computers.js.map +1 -0
  290. package/dist/concealment.d.ts +25 -2
  291. package/dist/concealment.js +409 -0
  292. package/dist/concealment.js.map +1 -0
  293. package/dist/coreComponents.js +130 -0
  294. package/dist/coreComponents.js.map +1 -0
  295. package/dist/createGame.d.ts +306 -0
  296. package/dist/createGame.js +405 -0
  297. package/dist/createGame.js.map +1 -0
  298. package/dist/dashing.d.ts +18 -2
  299. package/dist/dashing.js +41 -0
  300. package/dist/dashing.js.map +1 -0
  301. package/dist/debug.d.ts +8 -0
  302. package/dist/debug.js +5 -3
  303. package/dist/debug2.js +76 -0
  304. package/dist/debug2.js.map +1 -0
  305. package/dist/debugCommands.d.ts +6 -6
  306. package/dist/debugCommands.js +537 -0
  307. package/dist/debugCommands.js.map +1 -0
  308. package/dist/debugging.d.ts +1 -0
  309. package/dist/defaultSets.d.ts +183 -0
  310. package/dist/defaultSets.js +216 -0
  311. package/dist/defaultSets.js.map +1 -0
  312. package/dist/definitions.d.ts +6 -0
  313. package/dist/definitions.js +78 -0
  314. package/dist/definitions.js.map +1 -0
  315. package/dist/defs.d.ts +1895 -165
  316. package/dist/defs.js +380 -0
  317. package/dist/defs.js.map +1 -0
  318. package/dist/denying.d.ts +4 -4
  319. package/dist/denying.js +106 -0
  320. package/dist/denying.js.map +1 -0
  321. package/dist/destructibles.d.ts +2 -2
  322. package/dist/destructibles.js +36 -0
  323. package/dist/destructibles.js.map +1 -0
  324. package/dist/determinism.d.ts +4 -4
  325. package/dist/determinism.js +247 -0
  326. package/dist/determinism.js.map +1 -0
  327. package/dist/dialog.d.ts +17 -2
  328. package/dist/dialog.js +108 -0
  329. package/dist/dialog.js.map +1 -0
  330. package/dist/effectRefs.js +28 -0
  331. package/dist/effectRefs.js.map +1 -0
  332. package/dist/effects.d.ts +27 -11
  333. package/dist/effects.js +110 -0
  334. package/dist/effects.js.map +1 -0
  335. package/dist/endings.d.ts +1 -1
  336. package/dist/endings.js +78 -0
  337. package/dist/endings.js.map +1 -0
  338. package/dist/engagement.d.ts +40 -6
  339. package/dist/engagement.js +530 -0
  340. package/dist/engagement.js.map +1 -0
  341. package/dist/engineEvents.d.ts +72 -9
  342. package/dist/engineEvents.js +520 -0
  343. package/dist/engineEvents.js.map +1 -0
  344. package/dist/entity.d.ts +275 -26
  345. package/dist/entity.js +441 -0
  346. package/dist/entity.js.map +1 -0
  347. package/dist/entityIndex.d.ts +10 -3
  348. package/dist/entityIndex.js +149 -0
  349. package/dist/entityIndex.js.map +1 -0
  350. package/dist/errors.d.ts +6 -2
  351. package/dist/errors.js +59 -0
  352. package/dist/errors.js.map +1 -0
  353. package/dist/events.d.ts +11 -5
  354. package/dist/events.js +158 -0
  355. package/dist/events.js.map +1 -0
  356. package/dist/exactMath.js +273 -0
  357. package/dist/exactMath.js.map +1 -0
  358. package/dist/features.d.ts +1 -1
  359. package/dist/features.js +127 -0
  360. package/dist/features.js.map +1 -0
  361. package/dist/fields.d.ts +25 -5
  362. package/dist/fields.js +140 -0
  363. package/dist/fields.js.map +1 -0
  364. package/dist/fixture.d.ts +3 -3
  365. package/dist/fixture.js +512 -0
  366. package/dist/fixture.js.map +1 -0
  367. package/dist/fog.d.ts +26 -3
  368. package/dist/fog.js +333 -0
  369. package/dist/fog.js.map +1 -0
  370. package/dist/foliage.d.ts +476 -0
  371. package/dist/foliage.js +1478 -0
  372. package/dist/foliage.js.map +1 -0
  373. package/dist/foliageDebug.d.ts +57 -0
  374. package/dist/foliageDebug.js +172 -0
  375. package/dist/foliageDebug.js.map +1 -0
  376. package/dist/foliageRegrowth.d.ts +20 -0
  377. package/dist/foliageRegrowth.js +332 -0
  378. package/dist/foliageRegrowth.js.map +1 -0
  379. package/dist/formState.d.ts +67 -0
  380. package/dist/formState.js +65 -0
  381. package/dist/formState.js.map +1 -0
  382. package/dist/formation.d.ts +46 -8
  383. package/dist/formation.js +297 -0
  384. package/dist/formation.js.map +1 -0
  385. package/dist/forms.d.ts +58 -0
  386. package/dist/forms.js +146 -0
  387. package/dist/forms.js.map +1 -0
  388. package/dist/friendlyFire.d.ts +2 -2
  389. package/dist/friendlyFire.js +37 -0
  390. package/dist/friendlyFire.js.map +1 -0
  391. package/dist/game.d.ts +141 -48
  392. package/dist/game.js +834 -0
  393. package/dist/game.js.map +1 -0
  394. package/dist/gameData.d.ts +96 -22
  395. package/dist/gameData.js +1690 -0
  396. package/dist/gameData.js.map +1 -0
  397. package/dist/gameFiles.d.ts +3 -3
  398. package/dist/gameFiles.js +14 -0
  399. package/dist/gameFiles.js.map +1 -0
  400. package/dist/gates.js +92 -0
  401. package/dist/gates.js.map +1 -0
  402. package/dist/generate.d.ts +28 -1
  403. package/dist/generate.js +1062 -0
  404. package/dist/generate.js.map +1 -0
  405. package/dist/generateWorker.d.ts +7 -3
  406. package/dist/generateWorker.js +86 -0
  407. package/dist/generateWorker.js.map +1 -0
  408. package/dist/grid.d.ts +9 -0
  409. package/dist/grid.js +102 -0
  410. package/dist/grid.js.map +1 -0
  411. package/dist/ground.d.ts +17 -1
  412. package/dist/ground.js +375 -0
  413. package/dist/ground.js.map +1 -0
  414. package/dist/groundObjects.d.ts +70 -0
  415. package/dist/groundObjects.js +371 -0
  416. package/dist/groundObjects.js.map +1 -0
  417. package/dist/groundSpeed.d.ts +20 -3
  418. package/dist/groundSpeed.js +117 -0
  419. package/dist/groundSpeed.js.map +1 -0
  420. package/dist/hero.d.ts +126 -10
  421. package/dist/hero.js +432 -0
  422. package/dist/hero.js.map +1 -0
  423. package/dist/holds.d.ts +94 -0
  424. package/dist/holds.js +305 -0
  425. package/dist/holds.js.map +1 -0
  426. package/dist/home.d.ts +1 -1
  427. package/dist/home.js +30 -0
  428. package/dist/home.js.map +1 -0
  429. package/dist/hooks.d.ts +339 -57
  430. package/dist/hooks.js +105 -0
  431. package/dist/hooks.js.map +1 -0
  432. package/dist/hotReload.d.ts +6 -5
  433. package/dist/hotReload.js +145 -0
  434. package/dist/hotReload.js.map +1 -0
  435. package/dist/ids.d.ts +3 -3
  436. package/dist/ids.js +30 -0
  437. package/dist/ids.js.map +1 -0
  438. package/dist/idsFile.d.ts +36 -0
  439. package/dist/idsFile.js +134 -0
  440. package/dist/idsFile.js.map +1 -0
  441. package/dist/index.d.ts +105 -68
  442. package/dist/index.js +194 -4701
  443. package/dist/inspect.d.ts +29 -2
  444. package/dist/{inspect-D9dWHmZ0.js → inspect.js} +21 -12
  445. package/dist/inspect.js.map +1 -0
  446. package/dist/inventory.d.ts +14 -1
  447. package/dist/inventory.js +84 -0
  448. package/dist/inventory.js.map +1 -0
  449. package/dist/items.d.ts +136 -8
  450. package/dist/items.js +585 -0
  451. package/dist/items.js.map +1 -0
  452. package/dist/lanes.d.ts +12 -3
  453. package/dist/lanes.js +496 -0
  454. package/dist/lanes.js.map +1 -0
  455. package/dist/life.d.ts +6 -2
  456. package/dist/life.js +287 -0
  457. package/dist/life.js.map +1 -0
  458. package/dist/log.d.ts +26 -3
  459. package/dist/log.js +192 -0
  460. package/dist/log.js.map +1 -0
  461. package/dist/manaBurn.d.ts +2 -2
  462. package/dist/manaBurn.js +75 -0
  463. package/dist/manaBurn.js.map +1 -0
  464. package/dist/map/file.d.ts +56 -3
  465. package/dist/map/file.js +264 -0
  466. package/dist/map/file.js.map +1 -0
  467. package/dist/map/images.js +61 -0
  468. package/dist/map/images.js.map +1 -0
  469. package/dist/map/look.d.ts +1 -1
  470. package/dist/map/look.js +30 -0
  471. package/dist/map/look.js.map +1 -0
  472. package/dist/map/pathProfile.js +183 -0
  473. package/dist/map/pathProfile.js.map +1 -0
  474. package/dist/map/resize.d.ts +4 -0
  475. package/dist/map/resize.js +136 -0
  476. package/dist/map/resize.js.map +1 -0
  477. package/dist/map/schema.js +257 -0
  478. package/dist/map/schema.js.map +1 -0
  479. package/dist/map/terrain.js +214 -0
  480. package/dist/map/terrain.js.map +1 -0
  481. package/dist/map/types.d.ts +92 -13
  482. package/dist/map/types.js +251 -0
  483. package/dist/map/types.js.map +1 -0
  484. package/dist/mapCheck/cells.js +94 -0
  485. package/dist/mapCheck/cells.js.map +1 -0
  486. package/dist/mapCheck/rules/foliage.d.ts +9 -0
  487. package/dist/mapCheck/rules/foliage.js +83 -0
  488. package/dist/mapCheck/rules/foliage.js.map +1 -0
  489. package/dist/mapCheck/rules/names.js +39 -0
  490. package/dist/mapCheck/rules/names.js.map +1 -0
  491. package/dist/mapCheck/rules/objects.d.ts +1 -1
  492. package/dist/mapCheck/rules/objects.js +56 -0
  493. package/dist/mapCheck/rules/objects.js.map +1 -0
  494. package/dist/mapCheck/rules/paths.js +32 -0
  495. package/dist/mapCheck/rules/paths.js.map +1 -0
  496. package/dist/mapCheck/rules/players.js +20 -0
  497. package/dist/mapCheck/rules/players.js.map +1 -0
  498. package/dist/mapCheck/rules/races.js +56 -0
  499. package/dist/mapCheck/rules/races.js.map +1 -0
  500. package/dist/mapCheck/rules/random.js +47 -0
  501. package/dist/mapCheck/rules/random.js.map +1 -0
  502. package/dist/mapCheck/rules/regions.js +30 -0
  503. package/dist/mapCheck/rules/regions.js.map +1 -0
  504. package/dist/mapCheck/rules/targets.js +31 -0
  505. package/dist/mapCheck/rules/targets.js.map +1 -0
  506. package/dist/mapCheck/rules/walking.js +45 -0
  507. package/dist/mapCheck/rules/walking.js.map +1 -0
  508. package/dist/mapCheck.d.ts +2 -2
  509. package/dist/mapCheck.js +63 -0
  510. package/dist/mapCheck.js.map +1 -0
  511. package/dist/mapFields.d.ts +25 -2
  512. package/dist/mapFields.js +134 -0
  513. package/dist/mapFields.js.map +1 -0
  514. package/dist/mapFile.js +176 -0
  515. package/dist/mapFile.js.map +1 -0
  516. package/dist/mapMeasure.d.ts +8 -0
  517. package/dist/mapMeasure.js +283 -0
  518. package/dist/mapMeasure.js.map +1 -0
  519. package/dist/mapMerge.d.ts +1 -0
  520. package/dist/mapMerge.js +172 -0
  521. package/dist/mapMerge.js.map +1 -0
  522. package/dist/mapObjectives.js +138 -0
  523. package/dist/mapObjectives.js.map +1 -0
  524. package/dist/mapObjects.js +80 -0
  525. package/dist/mapObjects.js.map +1 -0
  526. package/dist/math.d.ts +37 -7
  527. package/dist/math.js +155 -0
  528. package/dist/math.js.map +1 -0
  529. package/dist/messages.d.ts +71 -4
  530. package/dist/messages.js +29 -0
  531. package/dist/messages.js.map +1 -0
  532. package/dist/missionRules.d.ts +10 -2
  533. package/dist/{missionRules-C-bGxm0Q.js → missionRules.js} +30 -150
  534. package/dist/missionRules.js.map +1 -0
  535. package/dist/mods.d.ts +39 -20
  536. package/dist/mods.js +271 -0
  537. package/dist/mods.js.map +1 -0
  538. package/dist/moves.d.ts +87 -0
  539. package/dist/moves.js +539 -0
  540. package/dist/moves.js.map +1 -0
  541. package/dist/names.d.ts +7 -0
  542. package/dist/names.js +122 -0
  543. package/dist/names.js.map +1 -0
  544. package/dist/navigation/agentParams.js +14 -0
  545. package/dist/navigation/agentParams.js.map +1 -0
  546. package/dist/navigation/air.d.ts +7 -3
  547. package/dist/navigation/air.js +401 -0
  548. package/dist/navigation/air.js.map +1 -0
  549. package/dist/navigation/builds.d.ts +34 -2
  550. package/dist/navigation/builds.js +287 -0
  551. package/dist/navigation/builds.js.map +1 -0
  552. package/dist/navigation/groundAreas.d.ts +59 -1
  553. package/dist/navigation/groundAreas.js +407 -0
  554. package/dist/navigation/groundAreas.js.map +1 -0
  555. package/dist/navigation/navigation.d.ts +98 -9
  556. package/dist/navigation/recast.d.ts +194 -18
  557. package/dist/navigation/recast.js +1379 -0
  558. package/dist/navigation/recast.js.map +1 -0
  559. package/dist/navigation/sidePaths.d.ts +8 -3
  560. package/dist/navigation/sidePaths.js +241 -0
  561. package/dist/navigation/sidePaths.js.map +1 -0
  562. package/dist/navigation/sized.js +243 -0
  563. package/dist/navigation/sized.js.map +1 -0
  564. package/dist/nearest.js +32 -0
  565. package/dist/nearest.js.map +1 -0
  566. package/dist/noise.js +59 -0
  567. package/dist/noise.js.map +1 -0
  568. package/dist/objectives.d.ts +12 -3
  569. package/dist/objectives.js +144 -0
  570. package/dist/objectives.js.map +1 -0
  571. package/dist/orders/basic.d.ts +5 -5
  572. package/dist/orders/basic.js +417 -0
  573. package/dist/orders/basic.js.map +1 -0
  574. package/dist/orders/build.js +278 -0
  575. package/dist/orders/build.js.map +1 -0
  576. package/dist/orders/cast.d.ts +13 -3
  577. package/dist/orders/cast.js +558 -0
  578. package/dist/orders/cast.js.map +1 -0
  579. package/dist/orders/facts.js +16 -0
  580. package/dist/orders/facts.js.map +1 -0
  581. package/dist/orders/harvest.d.ts +21 -5
  582. package/dist/orders/harvest.js +540 -0
  583. package/dist/orders/harvest.js.map +1 -0
  584. package/dist/orders/idle.d.ts +3 -1
  585. package/dist/orders/idle.js +234 -0
  586. package/dist/orders/idle.js.map +1 -0
  587. package/dist/orders/items.js +92 -0
  588. package/dist/orders/items.js.map +1 -0
  589. package/dist/orders/queue.js +108 -0
  590. package/dist/orders/queue.js.map +1 -0
  591. package/dist/orders/waiting.d.ts +39 -0
  592. package/dist/orders/waiting.js +149 -0
  593. package/dist/orders/waiting.js.map +1 -0
  594. package/dist/pack.schema.js +13 -0
  595. package/dist/pack.schema.js.map +1 -0
  596. package/dist/pack.schema.json +7622 -841
  597. package/dist/packs/director/index.d.ts +13 -5
  598. package/dist/packs/director/index.js +204 -0
  599. package/dist/packs/director/index.js.map +1 -0
  600. package/dist/packs/heroes/campaign.d.ts +3 -2
  601. package/dist/packs/heroes/campaign.js +241 -0
  602. package/dist/packs/heroes/campaign.js.map +1 -0
  603. package/dist/packs/heroes/carry.d.ts +6 -0
  604. package/dist/packs/heroes/carry.js +112 -0
  605. package/dist/packs/heroes/carry.js.map +1 -0
  606. package/dist/packs/heroes/commands.js +115 -0
  607. package/dist/packs/heroes/commands.js.map +1 -0
  608. package/dist/packs/heroes/fallen.d.ts +43 -0
  609. package/dist/packs/heroes/fallen.js +61 -0
  610. package/dist/packs/heroes/fallen.js.map +1 -0
  611. package/dist/packs/heroes/hire.js +60 -0
  612. package/dist/packs/heroes/hire.js.map +1 -0
  613. package/dist/packs/heroes/index.d.ts +7 -6
  614. package/dist/packs/heroes/index.js +130 -0
  615. package/dist/packs/heroes/index.js.map +1 -0
  616. package/dist/packs/heroes/loop.d.ts +95 -0
  617. package/dist/packs/heroes/loop.js +250 -0
  618. package/dist/packs/heroes/loop.js.map +1 -0
  619. package/dist/packs/heroes/making.d.ts +6 -3
  620. package/dist/packs/heroes/making.js +55 -0
  621. package/dist/packs/heroes/making.js.map +1 -0
  622. package/dist/packs/heroes/respawn.d.ts +3 -3
  623. package/dist/packs/heroes/respawn.js +87 -0
  624. package/dist/packs/heroes/respawn.js.map +1 -0
  625. package/dist/packs/heroes/sets.d.ts +32 -0
  626. package/dist/packs/heroes/sets.js +51 -0
  627. package/dist/packs/heroes/sets.js.map +1 -0
  628. package/dist/packs/heroes/spells.d.ts +16 -0
  629. package/dist/packs/heroes/spells.js +269 -0
  630. package/dist/packs/heroes/spells.js.map +1 -0
  631. package/dist/packs/items/defaults.d.ts +43 -0
  632. package/dist/packs/items/defaults.js +1504 -0
  633. package/dist/packs/items/defaults.js.map +1 -0
  634. package/dist/packs/items/index.d.ts +27 -0
  635. package/dist/packs/items/index.js +214 -0
  636. package/dist/packs/items/index.js.map +1 -0
  637. package/dist/packs/moba/index.d.ts +3 -3
  638. package/dist/packs/moba/index.js +174 -0
  639. package/dist/packs/moba/index.js.map +1 -0
  640. package/dist/packs/pack.d.ts +15 -15
  641. package/dist/packs/pack.js +14 -0
  642. package/dist/packs/pack.js.map +1 -0
  643. package/dist/packs.d.ts +15 -7
  644. package/dist/packs.js +222 -0
  645. package/dist/packs.js.map +1 -0
  646. package/dist/paths.d.ts +2 -0
  647. package/dist/paths.js +109 -0
  648. package/dist/paths.js.map +1 -0
  649. package/dist/plain.js +57 -0
  650. package/dist/plain.js.map +1 -0
  651. package/dist/player.d.ts +33 -10
  652. package/dist/player.js +159 -0
  653. package/dist/player.js.map +1 -0
  654. package/dist/portals.d.ts +1 -1
  655. package/dist/portals.js +194 -0
  656. package/dist/portals.js.map +1 -0
  657. package/dist/prefabs.d.ts +25 -2
  658. package/dist/prefabs.js +239 -0
  659. package/dist/prefabs.js.map +1 -0
  660. package/dist/presetBuildings.js +58 -0
  661. package/dist/presetBuildings.js.map +1 -0
  662. package/dist/presetFoliage.d.ts +27 -0
  663. package/dist/presetFoliage.js +98 -0
  664. package/dist/presetFoliage.js.map +1 -0
  665. package/dist/presetGround.js +65 -0
  666. package/dist/presetGround.js.map +1 -0
  667. package/dist/proxies.d.ts +12 -0
  668. package/dist/proxies.js +79 -0
  669. package/dist/proxies.js.map +1 -0
  670. package/dist/query.d.ts +56 -0
  671. package/dist/query.js +88 -0
  672. package/dist/query.js.map +1 -0
  673. package/dist/races.d.ts +15 -14
  674. package/dist/races.js +172 -0
  675. package/dist/races.js.map +1 -0
  676. package/dist/randomGroups.js +91 -0
  677. package/dist/randomGroups.js.map +1 -0
  678. package/dist/registry.d.ts +117 -53
  679. package/dist/registry.js +323 -0
  680. package/dist/registry.js.map +1 -0
  681. package/dist/remains.d.ts +11 -9
  682. package/dist/remains.js +188 -0
  683. package/dist/remains.js.map +1 -0
  684. package/dist/replication.d.ts +12 -7
  685. package/dist/replication.js +100 -0
  686. package/dist/replication.js.map +1 -0
  687. package/dist/rng.d.ts +2 -0
  688. package/dist/rng.js +40 -0
  689. package/dist/rng.js.map +1 -0
  690. package/dist/rules.d.ts +186 -99
  691. package/dist/rules.js +179 -0
  692. package/dist/rules.js.map +1 -0
  693. package/dist/rulesCheck.d.ts +5 -4
  694. package/dist/rulesCheck.js +693 -0
  695. package/dist/rulesCheck.js.map +1 -0
  696. package/dist/runes.d.ts +2 -2
  697. package/dist/runes.js +80 -0
  698. package/dist/runes.js.map +1 -0
  699. package/dist/save.d.ts +37 -12
  700. package/dist/save.js +532 -0
  701. package/dist/save.js.map +1 -0
  702. package/dist/scenario.d.ts +2 -2
  703. package/dist/scenario.js +99 -0
  704. package/dist/scenario.js.map +1 -0
  705. package/dist/scheduler.d.ts +3 -0
  706. package/dist/scheduler.js +156 -0
  707. package/dist/scheduler.js.map +1 -0
  708. package/dist/score.d.ts +19 -19
  709. package/dist/score.js +709 -0
  710. package/dist/score.js.map +1 -0
  711. package/dist/sequences.d.ts +10 -6
  712. package/dist/sequences.js +206 -0
  713. package/dist/sequences.js.map +1 -0
  714. package/dist/server/doorman.js +154 -0
  715. package/dist/server/doorman.js.map +1 -0
  716. package/dist/server/gameServer.d.ts +16 -1
  717. package/dist/server/gameServer.js +643 -0
  718. package/dist/server/gameServer.js.map +1 -0
  719. package/dist/server/index.d.ts +1 -1
  720. package/dist/server/lobby.js +199 -0
  721. package/dist/server/lobby.js.map +1 -0
  722. package/dist/server/log.js +18 -0
  723. package/dist/server/log.js.map +1 -0
  724. package/dist/server/match.js +267 -0
  725. package/dist/server/match.js.map +1 -0
  726. package/dist/server/mode.d.ts +18 -9
  727. package/dist/server/mode.js +220 -0
  728. package/dist/server/mode.js.map +1 -0
  729. package/dist/{navigation-worker.js → server/navigation-worker.js} +1 -1
  730. package/dist/server/navigation-worker.js.map +1 -0
  731. package/dist/server/navigation.js +39 -0
  732. package/dist/server/navigation.js.map +1 -0
  733. package/dist/server/ops.d.ts +4 -0
  734. package/dist/server/ops.js +137 -0
  735. package/dist/server/ops.js.map +1 -0
  736. package/dist/server/packs.d.ts +3 -3
  737. package/dist/server/packs.js +32 -0
  738. package/dist/server/packs.js.map +1 -0
  739. package/dist/server/ratings.d.ts +5 -0
  740. package/dist/server/ratings.js +104 -0
  741. package/dist/server/ratings.js.map +1 -0
  742. package/dist/server/relay.d.ts +12 -2
  743. package/dist/server/relay.js +144 -0
  744. package/dist/server/relay.js.map +1 -0
  745. package/dist/server/rooms.d.ts +9 -2
  746. package/dist/server/rooms.js +442 -0
  747. package/dist/server/rooms.js.map +1 -0
  748. package/dist/server/seat.js +116 -0
  749. package/dist/server/seat.js.map +1 -0
  750. package/dist/server/seatSettings.d.ts +3 -3
  751. package/dist/server/seatSettings.js +63 -0
  752. package/dist/server/seatSettings.js.map +1 -0
  753. package/dist/server/secret.js +13 -0
  754. package/dist/server/secret.js.map +1 -0
  755. package/dist/server/start.d.ts +13 -6
  756. package/dist/server/start.js +76 -0
  757. package/dist/server/start.js.map +1 -0
  758. package/dist/server/websocket.d.ts +9 -1
  759. package/dist/server/websocket.js +306 -0
  760. package/dist/server/websocket.js.map +1 -0
  761. package/dist/server.js +15 -2861
  762. package/dist/session/can.js +26 -0
  763. package/dist/session/can.js.map +1 -0
  764. package/dist/session/commandReplay.d.ts +8 -2
  765. package/dist/session/commandReplay.js +293 -0
  766. package/dist/session/commandReplay.js.map +1 -0
  767. package/dist/session/debug.js +151 -0
  768. package/dist/session/debug.js.map +1 -0
  769. package/dist/session/delay.js +62 -0
  770. package/dist/session/delay.js.map +1 -0
  771. package/dist/session/delta.d.ts +14 -1
  772. package/dist/session/delta.js +407 -0
  773. package/dist/session/delta.js.map +1 -0
  774. package/dist/session/entityState.js +415 -0
  775. package/dist/session/entityState.js.map +1 -0
  776. package/dist/session/local.d.ts +47 -5
  777. package/dist/session/local.js +670 -0
  778. package/dist/session/local.js.map +1 -0
  779. package/dist/session/memory.d.ts +20 -2
  780. package/dist/session/memory.js +131 -0
  781. package/dist/session/memory.js.map +1 -0
  782. package/dist/session/protocol.d.ts +325 -31
  783. package/dist/session/protocol.js +55 -0
  784. package/dist/session/protocol.js.map +1 -0
  785. package/dist/session/remote.d.ts +74 -12
  786. package/dist/session/remote.js +1394 -0
  787. package/dist/session/remote.js.map +1 -0
  788. package/dist/session/replay.d.ts +11 -2
  789. package/dist/session/replay.js +160 -0
  790. package/dist/session/replay.js.map +1 -0
  791. package/dist/session/seed.js +12 -0
  792. package/dist/session/seed.js.map +1 -0
  793. package/dist/session/share.d.ts +5 -1
  794. package/dist/session/share.js +94 -0
  795. package/dist/session/share.js.map +1 -0
  796. package/dist/session/socket.d.ts +1 -1
  797. package/dist/session/socket.js +29 -0
  798. package/dist/session/socket.js.map +1 -0
  799. package/dist/session/wire.d.ts +5 -0
  800. package/dist/session/wire.js +84 -0
  801. package/dist/session/wire.js.map +1 -0
  802. package/dist/session/worker.d.ts +77 -12
  803. package/dist/session/worker.js +499 -0
  804. package/dist/session/worker.js.map +1 -0
  805. package/dist/shared.d.ts +31 -5
  806. package/dist/shared.js +166 -0
  807. package/dist/shared.js.map +1 -0
  808. package/dist/sides.d.ts +9 -3
  809. package/dist/sides.js +149 -0
  810. package/dist/sides.js.map +1 -0
  811. package/dist/sight.js +85 -0
  812. package/dist/sight.js.map +1 -0
  813. package/dist/simulate-worker.js +1 -1
  814. package/dist/simulate.d.ts +12 -8
  815. package/dist/{simulate-oXBiw1Ff.js → simulate.js} +10 -11
  816. package/dist/simulate.js.map +1 -0
  817. package/dist/smart.js +77 -0
  818. package/dist/smart.js.map +1 -0
  819. package/dist/spatial.d.ts +32 -16
  820. package/dist/spatial.js +234 -0
  821. package/dist/spatial.js.map +1 -0
  822. package/dist/spawning.d.ts +1 -0
  823. package/dist/spawning.js +224 -0
  824. package/dist/spawning.js.map +1 -0
  825. package/dist/stances.d.ts +6 -3
  826. package/dist/stances.js +169 -0
  827. package/dist/stances.js.map +1 -0
  828. package/dist/start.d.ts +10 -10
  829. package/dist/start.js +75 -0
  830. package/dist/start.js.map +1 -0
  831. package/dist/stats.d.ts +42 -16
  832. package/dist/stats.js +290 -0
  833. package/dist/stats.js.map +1 -0
  834. package/dist/summoned.d.ts +52 -0
  835. package/dist/summoned.js +38 -0
  836. package/dist/summoned.js.map +1 -0
  837. package/dist/summons.d.ts +10 -13
  838. package/dist/summons.js +271 -0
  839. package/dist/summons.js.map +1 -0
  840. package/dist/systems/abilities.js +224 -0
  841. package/dist/systems/abilities.js.map +1 -0
  842. package/dist/systems/combat.d.ts +35 -1
  843. package/dist/systems/combat.js +677 -0
  844. package/dist/systems/combat.js.map +1 -0
  845. package/dist/systems/combatTold.d.ts +3 -1
  846. package/dist/systems/combatTold.js +85 -0
  847. package/dist/systems/combatTold.js.map +1 -0
  848. package/dist/systems/construction.js +80 -0
  849. package/dist/systems/construction.js.map +1 -0
  850. package/dist/systems/economy.d.ts +0 -6
  851. package/dist/systems/economy.js +128 -0
  852. package/dist/systems/economy.js.map +1 -0
  853. package/dist/systems/fog.d.ts +1 -1
  854. package/dist/systems/fog.js +120 -0
  855. package/dist/systems/fog.js.map +1 -0
  856. package/dist/systems/life.js +32 -0
  857. package/dist/systems/life.js.map +1 -0
  858. package/dist/systems/movement.d.ts +24 -12
  859. package/dist/systems/movement.js +1247 -0
  860. package/dist/systems/movement.js.map +1 -0
  861. package/dist/systems/orders.js +64 -0
  862. package/dist/systems/orders.js.map +1 -0
  863. package/dist/systems/production.js +322 -0
  864. package/dist/systems/production.js.map +1 -0
  865. package/dist/systems/productionQueue.js +120 -0
  866. package/dist/systems/productionQueue.js.map +1 -0
  867. package/dist/systems/victory.d.ts +1 -1
  868. package/dist/systems/victory.js +56 -0
  869. package/dist/systems/victory.js.map +1 -0
  870. package/dist/talk.d.ts +6 -6
  871. package/dist/talk.js +153 -0
  872. package/dist/talk.js.map +1 -0
  873. package/dist/targeting.d.ts +142 -0
  874. package/dist/targeting.js +49 -0
  875. package/dist/targeting.js.map +1 -0
  876. package/dist/tech.d.ts +20 -3
  877. package/dist/tech.js +239 -0
  878. package/dist/tech.js.map +1 -0
  879. package/dist/techTree.d.ts +7 -0
  880. package/dist/techTree.js +90 -0
  881. package/dist/techTree.js.map +1 -0
  882. package/dist/terrain.d.ts +59 -7
  883. package/dist/terrain.js +389 -0
  884. package/dist/terrain.js.map +1 -0
  885. package/dist/terrainSave.d.ts +6 -0
  886. package/dist/terrainSave.js +74 -0
  887. package/dist/terrainSave.js.map +1 -0
  888. package/dist/testing.d.ts +8 -7
  889. package/dist/testing.js +13 -739
  890. package/dist/testing.js.map +1 -1
  891. package/dist/tiles.d.ts +1 -1
  892. package/dist/tiles.js +43 -0
  893. package/dist/tiles.js.map +1 -0
  894. package/dist/timers.d.ts +29 -4
  895. package/dist/timers.js +242 -0
  896. package/dist/timers.js.map +1 -0
  897. package/dist/tomes.d.ts +4 -4
  898. package/dist/tomes.js +94 -0
  899. package/dist/tomes.js.map +1 -0
  900. package/dist/trade.js +103 -0
  901. package/dist/trade.js.map +1 -0
  902. package/dist/transport.d.ts +6 -1
  903. package/dist/transport.js +281 -0
  904. package/dist/transport.js.map +1 -0
  905. package/dist/tunables.d.ts +10 -3
  906. package/dist/tunables.js +56 -0
  907. package/dist/tunables.js.map +1 -0
  908. package/dist/unitResources.d.ts +67 -0
  909. package/dist/unitResources.js +266 -0
  910. package/dist/unitResources.js.map +1 -0
  911. package/dist/upkeep.d.ts +6 -1
  912. package/dist/upkeep.js +26 -0
  913. package/dist/upkeep.js.map +1 -0
  914. package/dist/veterancy.d.ts +8 -3
  915. package/dist/veterancy.js +131 -0
  916. package/dist/veterancy.js.map +1 -0
  917. package/dist/vision.d.ts +36 -0
  918. package/dist/vision.js +133 -0
  919. package/dist/vision.js.map +1 -0
  920. package/dist/walls.d.ts +1 -1
  921. package/dist/walls.js +278 -0
  922. package/dist/walls.js.map +1 -0
  923. package/dist/world.d.ts +606 -88
  924. package/dist/world.js +1263 -0
  925. package/dist/world.js.map +1 -0
  926. package/package.json +2 -2
  927. package/dist/ai.js.map +0 -1
  928. package/dist/attributes.d.ts +0 -66
  929. package/dist/brain-BvVdUhX8.js +0 -7659
  930. package/dist/brain-BvVdUhX8.js.map +0 -1
  931. package/dist/builds-C6LfgvEU.js +0 -460
  932. package/dist/builds-C6LfgvEU.js.map +0 -1
  933. package/dist/coreComponents-syuh2fPG.js +0 -5149
  934. package/dist/coreComponents-syuh2fPG.js.map +0 -1
  935. package/dist/debugCommands-CzjrSm66.js +0 -14739
  936. package/dist/debugCommands-CzjrSm66.js.map +0 -1
  937. package/dist/determinism-BCymQwiE.js +0 -518
  938. package/dist/determinism-BCymQwiE.js.map +0 -1
  939. package/dist/game-DiJEN-Ks.js +0 -5800
  940. package/dist/game-DiJEN-Ks.js.map +0 -1
  941. package/dist/index.js.map +0 -1
  942. package/dist/inspect-D9dWHmZ0.js.map +0 -1
  943. package/dist/local-Dkovq42k.js +0 -1379
  944. package/dist/local-Dkovq42k.js.map +0 -1
  945. package/dist/missionRules-C-bGxm0Q.js.map +0 -1
  946. package/dist/navigation-worker.js.map +0 -1
  947. package/dist/packs-g5thvmGn.js +0 -3199
  948. package/dist/packs-g5thvmGn.js.map +0 -1
  949. package/dist/profiles-B3NS9jwk.js.map +0 -1
  950. package/dist/server.js.map +0 -1
  951. package/dist/simulate-oXBiw1Ff.js.map +0 -1
@@ -0,0 +1,916 @@
1
+ import { distSq } from "../math.js";
2
+ import { heroOfState } from "../hero.js";
3
+ import { DEFAULT_STANCE, stance, stanceCommand } from "../stances.js";
4
+ import { defineModule } from "./module.js";
5
+ import "./reach.js";
6
+ import { UnitSet } from "./view.js";
7
+ import { pair, plural, point, where } from "./geometry.js";
8
+ import { capturePointsOf } from "./tasks/shared.js";
9
+ import { ATTACK } from "./tasks/attack.js";
10
+ import { HARASS } from "./tasks/harass.js";
11
+ import { CREEP } from "./tasks/creep.js";
12
+ import { DEFEND_TASK } from "./tasks/defend.js";
13
+ import { HOLD } from "./tasks/hold.js";
14
+ import { MOVE } from "./tasks/move.js";
15
+ import { CAPTURE } from "./tasks/capture.js";
16
+ import { RETREAT } from "./tasks/retreat.js";
17
+ import { ESCORT } from "./tasks/escort.js";
18
+ import { SCOUT_TASK } from "./tasks/scout.js";
19
+ import { PATROL } from "./tasks/patrol.js";
20
+ import { GATHER } from "./tasks/gather.js";
21
+ import { DROP } from "./tasks/drop.js";
22
+ import { TASKS } from "./tasks/index.js";
23
+ //#region src/ai/squads.ts
24
+ /** Seconds a squad waits for its stragglers at most, regrouping, before it goes on with what it has */
25
+ var REGROUP_FOR = 10;
26
+ /** Seconds between two calls for reinforcements */
27
+ var REINFORCE_EVERY = 5;
28
+ /** How far aside of the hottest place on its way a squad that avoids looks for a way round, then half as far again */
29
+ var DETOUR = 24;
30
+ /** Seconds a sighting of their army counts as where it is, for a squad that avoids it */
31
+ var AVOID_SEEN = 60;
32
+ /**
33
+ * A squad of the brain (`ai.squads.make`, `named`, `all`): a handle over its data, with the task methods. A squad's
34
+ * units are as of the think's picture: the dead and those its owner no longer holds are dropped as the squads module
35
+ * looks at it
36
+ *
37
+ * @beta
38
+ */
39
+ var Squad = class {
40
+ squads;
41
+ data;
42
+ constructor(squads, data) {
43
+ this.squads = squads;
44
+ this.data = data;
45
+ }
46
+ /** Its name: unique among the brain's squads */
47
+ get name() {
48
+ return this.data.name;
49
+ }
50
+ /** Who it belongs to: the goal, rule or module that made it */
51
+ get owner() {
52
+ return this.data.owner;
53
+ }
54
+ /** What it is doing: none for a squad told nothing yet */
55
+ get current() {
56
+ return this.data.task;
57
+ }
58
+ /** How its task ended: none while it goes on, or while it has none */
59
+ get done() {
60
+ return this.data.task?.done;
61
+ }
62
+ /** Whether it has nothing to do: no task, or its task is over */
63
+ get idle() {
64
+ return !this.data.task || this.data.task.done !== void 0;
65
+ }
66
+ /** Whether it is still one of the brain's squads: not once disbanded */
67
+ get alive() {
68
+ return this.squads.named(this.data.name) === this;
69
+ }
70
+ /** How it behaves: its own options over the brain's */
71
+ get options() {
72
+ return this.data.options;
73
+ }
74
+ /** Its units, as of the think's picture: those alive and the player's */
75
+ units() {
76
+ const { view } = this.squads.ai;
77
+ return new UnitSet(view, this.data.units.map((id) => view.byId(id)).filter((unit) => !!unit && unit.health > 0));
78
+ }
79
+ /** How many units it has */
80
+ get length() {
81
+ return this.data.units.length;
82
+ }
83
+ /** How strong it is together (`UnitSet.strength`) */
84
+ strength() {
85
+ return this.units().strength();
86
+ }
87
+ /** Its middle: none with no unit left */
88
+ centre() {
89
+ return this.units().centre();
90
+ }
91
+ /**
92
+ * How far from its middle a unit may be before it counts as strayed (`SquadOptions.spread`): grows with the squad
93
+ * when not given
94
+ */
95
+ spread() {
96
+ return this.data.options.spread ?? Math.max(8, 3 * Math.sqrt(this.data.units.length));
97
+ }
98
+ /** Adds units: what its owner may have (see `Squads.make`), taken out of any other squad */
99
+ add(units, why = "given") {
100
+ const added = this.squads.enlist(this, ids(units));
101
+ if (added.length) {
102
+ this.data.size = Math.max(this.data.size, this.data.units.length);
103
+ this.changed(`${why}: ${plural(added.length)}`);
104
+ }
105
+ return this;
106
+ }
107
+ /** Takes units out: they go back to the pool (its owner lets go of them) */
108
+ remove(units, why = "taken out") {
109
+ const gone = new Set(ids(units));
110
+ const removed = this.data.units.filter((id) => gone.has(id));
111
+ if (!removed.length) return this;
112
+ this.data.units = this.data.units.filter((id) => !gone.has(id));
113
+ this.squads.ai.goals.drop(this.data.owner, removed);
114
+ this.changed(`${why}: ${plural(removed.length)}`);
115
+ return this;
116
+ }
117
+ /** Disbands it: its units go back to its owner (a goal's), or to the pool (a squad of its own) */
118
+ disband(why = "disbanded") {
119
+ this.squads.disband(this, why);
120
+ }
121
+ /** Writes down the last change of its units or task, for the report */
122
+ changed(why) {
123
+ this.data.changed = {
124
+ tick: this.squads.ai.tick,
125
+ why
126
+ };
127
+ }
128
+ task(kind, data = {}) {
129
+ this.squads.give(this, kind, data);
130
+ return this;
131
+ }
132
+ /** Ends its task, saying how: what a task's `think` calls once it is over */
133
+ finish(done) {
134
+ const state = this.data.task;
135
+ if (!state || state.done !== void 0) return;
136
+ state.done = done;
137
+ state.doneAt = this.squads.ai.tick;
138
+ state.phase = "done";
139
+ state.phaseSince = this.squads.ai.tick;
140
+ }
141
+ /**
142
+ * Goes to fight at a place or a target (an entity, or its id): attack-moves there, fighting what it meets, regroups
143
+ * on the way, retreats on the odds. Done `cleared` once there with nothing left to fight, `lost` when the target is
144
+ * gone. `avoid: 'army'` goes round where their strength is on the way (the threat map and their army as last seen),
145
+ * when there is a way round. `via`: a place to go by on the way (a way of its own: Random Paths). `then`: the task after it
146
+ */
147
+ attack(target, options = {}) {
148
+ return this.task(ATTACK, {
149
+ ...targetOf(this.squads.ai, target),
150
+ ...options
151
+ });
152
+ }
153
+ /** Attack-moves to a place, as a group of units would on a click: the squad's attack without its regroup */
154
+ attackMove(at, options = {}) {
155
+ return this.task(ATTACK, {
156
+ at: point(at),
157
+ regroup: false,
158
+ ...options
159
+ });
160
+ }
161
+ /**
162
+ * Holds a place against what comes within `radius` of it (16 when left out): fights what comes, goes back once it is
163
+ * gone. Never over by itself: its owner says when
164
+ */
165
+ defend(at, radius = 16) {
166
+ return this.task(DEFEND_TASK, {
167
+ at: point(at),
168
+ radius
169
+ });
170
+ }
171
+ /** Goes to a place (where it stands when left out) and holds it: stands, fighting only what comes within reach */
172
+ hold(at) {
173
+ const there = at ?? this.centre();
174
+ return this.task(HOLD, there ? { at: point(there) } : {});
175
+ }
176
+ /** Walks to a place, fighting nothing on the way. Done `arrived` */
177
+ move(at, options = {}) {
178
+ return this.task(MOVE, {
179
+ at: point(at),
180
+ ...options
181
+ });
182
+ }
183
+ /** Goes with a unit of the player's or an ally's, fighting what comes near it. Done `lost` when it is gone */
184
+ escort(target) {
185
+ return this.task(ESCORT, { target: typeof target === "number" ? target : target.id });
186
+ }
187
+ /**
188
+ * Goes for the workers at a place, round where their army is (`avoid: 'army'` unless told otherwise), the workers
189
+ * first once there. Done `cleared`
190
+ */
191
+ harass(at, options = {}) {
192
+ return this.task(HARASS, {
193
+ at: point(at),
194
+ avoid: "army",
195
+ ...options
196
+ });
197
+ }
198
+ /** Goes to look at places, one after the other: each is looked at once in sight, or reached as near as the ground lets. Done `arrived` */
199
+ scout(points) {
200
+ return this.task(SCOUT_TASK, { points: points.map(point) });
201
+ }
202
+ /**
203
+ * Gathers at a rally point before going on (`then`): until `minForces` of it (a share, 1 when left out) is there,
204
+ * or `seconds` have gone by. Done `arrived`, and on to `then`
205
+ */
206
+ gather(at, options = {}) {
207
+ return this.task(GATHER, {
208
+ at: point(at),
209
+ ...options
210
+ });
211
+ }
212
+ /** Falls back to a place (home when left out), fighting nothing on the way. Done `retreated` */
213
+ retreat(to, why) {
214
+ const home = to ?? this.squads.ai.view.home();
215
+ return this.task(RETREAT, {
216
+ ...home && { at: point(home) },
217
+ ...why && { why }
218
+ });
219
+ }
220
+ /**
221
+ * Walks a round of places, one after the other and back to the first, fighting what it meets on the way (an
222
+ * attack-move to each): a mission's guards on the road, a watch round the walls. Never over by itself: its owner
223
+ * says when
224
+ */
225
+ patrol(points) {
226
+ return this.task(PATROL, { points: points.map(point) });
227
+ }
228
+ /** Takes a camp of creeps: fights there until the camp is cleared. Done `cleared` */
229
+ creep(camp) {
230
+ return this.task(CREEP, { at: point(camp) });
231
+ }
232
+ /**
233
+ * Carried by transports to a place it cannot walk to, let out on the land nearest it (the `drop` task): done
234
+ * `landed`, then what `then` says (an attack where it landed)
235
+ */
236
+ drop(at, transports, options = {}) {
237
+ return this.task(DROP, {
238
+ at: point(at),
239
+ transports: [...transports],
240
+ ...options.then && { then: options.then }
241
+ });
242
+ }
243
+ /** Sends its units an order (`move`, `hold`, the game's), all or some of them: counted as the task's last */
244
+ order(order, units = this.data.units, queue = false) {
245
+ units = this.living(units);
246
+ if (!units.length) return;
247
+ this.squads.ai.send({
248
+ type: "order",
249
+ entities: [...units],
250
+ order,
251
+ ...queue && { queue: true }
252
+ });
253
+ this.sent();
254
+ }
255
+ /**
256
+ * Puts its units, all or some, in a stance, where the game has stances (`stancesPack`): those not in it already. A
257
+ * squad that holds is defensive, one sent to fight aggressive
258
+ */
259
+ setStance(id, units = this.data.units) {
260
+ if (!this.squads.ai.registry.command("stance")) return;
261
+ const change = [];
262
+ for (const unit of this.units()) {
263
+ if (!units.includes(unit.id)) continue;
264
+ if ((unit.components?.[stance.id] ?? "aggressive") !== id) change.push(unit.id);
265
+ }
266
+ if (change.length) this.squads.ai.send(stanceCommand.make({
267
+ entities: change,
268
+ stance: id
269
+ }));
270
+ }
271
+ /**
272
+ * Sends its units to take a capture point of the game's (`capturePack`), by its id: they fight their way in and
273
+ * stand in it until it is theirs (`captured`), or it is gone (`lost`)
274
+ */
275
+ capture(id) {
276
+ const found = capturePointsOf(this.squads.ai).find((each) => each.id === id);
277
+ return this.task(CAPTURE, {
278
+ point: id,
279
+ ...found && { at: point({
280
+ x: found.x,
281
+ z: found.z
282
+ }) }
283
+ });
284
+ }
285
+ /** Sends its units, all or some, to fight at a place, or a target there: an attack-move, or an attack */
286
+ fight(at, units = this.data.units, target, queue = false) {
287
+ units = this.living(units);
288
+ if (!units.length) return;
289
+ this.setStance(DEFAULT_STANCE, units);
290
+ this.squads.ai.send({
291
+ type: "attack",
292
+ entities: [...units],
293
+ point: point(at),
294
+ ...target !== void 0 && { target },
295
+ ...queue && { queue: true }
296
+ });
297
+ this.sent();
298
+ }
299
+ /**
300
+ * Of some of its units, those the picture has: a unit that died since the squads were last looked at (a task given by a
301
+ * goal before the `squads()` module ran) is no one to order
302
+ */
303
+ living(units) {
304
+ const { mine } = this.squads.ai.view;
305
+ return units.every((id) => mine.has(id)) ? units : units.filter((id) => mine.has(id));
306
+ }
307
+ /** Its units that stand with nothing to do: what lost its order, or never had one */
308
+ idleUnits() {
309
+ return this.units().filter((unit) => !!unit.own && !unit.own.order && !unit.own.hidden);
310
+ }
311
+ /** Whether its last order was sent long enough ago to send one again (`RESEND` seconds): what keeps a stuck unit from being told every think */
312
+ mayResend() {
313
+ const state = this.data.task;
314
+ const { ai } = this.squads;
315
+ return !state || state.sent === void 0 || ai.tick - state.sent >= 3 * ai.session.tickRate;
316
+ }
317
+ sent() {
318
+ if (this.data.task) this.data.task.sent = this.squads.ai.tick;
319
+ }
320
+ };
321
+ /**
322
+ * Some squads together (`ai.squads.all()`, `idle()`): read as a list, told as one (`ai.squads.all().defend(home)`:
323
+ * each squad is given the task)
324
+ *
325
+ * @beta
326
+ */
327
+ var SquadGroup = class {
328
+ ai;
329
+ squads;
330
+ constructor(ai, squads) {
331
+ this.ai = ai;
332
+ this.squads = squads;
333
+ }
334
+ /** Iterates the squads, so that the set reads as a list */
335
+ [Symbol.iterator]() {
336
+ return this.squads[Symbol.iterator]();
337
+ }
338
+ /** How many squads */
339
+ get length() {
340
+ return this.squads.length;
341
+ }
342
+ /** Their units together, as a set */
343
+ units() {
344
+ const { view } = this.ai;
345
+ const all = this.squads.flatMap((squad) => squad.units().items);
346
+ all.sort((a, b) => view.indexOf(a) - view.indexOf(b));
347
+ return new UnitSet(view, all);
348
+ }
349
+ /** How strong they are together */
350
+ strength() {
351
+ return this.units().strength();
352
+ }
353
+ task(kind, data = {}) {
354
+ for (const squad of this.squads) squad.squads.give(squad, kind, data);
355
+ return this;
356
+ }
357
+ /** Tells each squad to attack a point, an entity or an entity id, as `Squad.attack` does, and returns the set */
358
+ attack(target, options = {}) {
359
+ for (const squad of this.squads) squad.attack(target, options);
360
+ return this;
361
+ }
362
+ /** Tells each squad to defend a place within a radius as `Squad.defend` does; does nothing without a place; returns the set */
363
+ defend(at, radius) {
364
+ if (at) for (const squad of this.squads) squad.defend(at, radius);
365
+ return this;
366
+ }
367
+ /** Tells each squad to hold at a place, or where it is, as `Squad.hold` does, and returns the set */
368
+ hold(at) {
369
+ for (const squad of this.squads) squad.hold(at);
370
+ return this;
371
+ }
372
+ /** Tells each squad to move to a point as `Squad.move` does, and returns the set */
373
+ move(at) {
374
+ for (const squad of this.squads) squad.move(at);
375
+ return this;
376
+ }
377
+ /** Tells each squad to retreat to a point, or home when left out, as `Squad.retreat` does, and returns the set */
378
+ retreat(to) {
379
+ for (const squad of this.squads) squad.retreat(to);
380
+ return this;
381
+ }
382
+ /** Each disbanded */
383
+ disband(why) {
384
+ for (const squad of [...this.squads]) squad.disband(why);
385
+ }
386
+ };
387
+ /** The ids of units given as entities or ids, each once */
388
+ function ids(units) {
389
+ const result = [];
390
+ for (const unit of units) {
391
+ const id = typeof unit === "number" ? unit : unit.id;
392
+ if (!result.includes(id)) result.push(id);
393
+ }
394
+ return result;
395
+ }
396
+ /** A target as an attack's data: a place, or an entity and where it is */
397
+ function targetOf(ai, target) {
398
+ if (typeof target === "number") {
399
+ const entity = ai.view.byId(target);
400
+ return {
401
+ target,
402
+ ...entity && { at: point(entity) }
403
+ };
404
+ }
405
+ if ("id" in target && typeof target.id === "number") return {
406
+ target: target.id,
407
+ at: point(target)
408
+ };
409
+ return { at: point(target) };
410
+ }
411
+ /**
412
+ * A brain's squads (`ai.squads`): made by its goals, rules and modules, watched by the `squads()` module each think
413
+ * (`think`): the dead dropped, what the owner let go of let go of, each task looked at, regroups, retreats and
414
+ * reinforcements seen to. Kept in the brain's memory (`BrainMemory.squads`)
415
+ *
416
+ * @beta
417
+ */
418
+ var Squads = class {
419
+ ai;
420
+ /** Its id among the brain's areas: what its memory and its report are kept under */
421
+ id = "squads";
422
+ /** What the log says where a save's memory of it is of a shape it does not read */
423
+ afresh = "the save remembers the computer player’s squads in a shape this brain does not read: they are let go of";
424
+ list = [];
425
+ tasks = /* @__PURE__ */ new Map();
426
+ thoughtAt = -1;
427
+ /** How a squad behaves where it says nothing and the brain's settings say nothing either: the `squads()` module's */
428
+ moduleOptions = {};
429
+ constructor(ai, tasks = []) {
430
+ this.ai = ai;
431
+ for (const def of TASKS) this.tasks.set(def.id, def);
432
+ for (const def of tasks) this.define(def);
433
+ }
434
+ /** Puts the `squads()` module's options under the brain's settings */
435
+ configure(options) {
436
+ this.moduleOptions = options;
437
+ }
438
+ /** How a squad behaves where it says nothing: the module's options, the brain's settings over them (`ai.settings.squads`) */
439
+ get defaults() {
440
+ const { tasks: _tasks, ...settings } = this.ai.settings.squads ?? {};
441
+ return {
442
+ ...this.moduleOptions,
443
+ ...settings
444
+ };
445
+ }
446
+ /** Registers a task of the game's own, so that a squad on it is carried on after a load. Given by `BrainDef.squads.tasks` */
447
+ define(def) {
448
+ const known = this.tasks.get(def.id);
449
+ if (known && known !== def && TASKS.includes(known)) throw new Error(`"${def.id}" is a task of the kit's: a task of the game's needs a name of its own`);
450
+ this.tasks.set(def.id, def);
451
+ }
452
+ /** A kind of task by its id: the kit's, or one registered */
453
+ taskDef(id) {
454
+ return this.tasks.get(id);
455
+ }
456
+ /**
457
+ * Makes a squad of units under a name (one of that name already is disbanded first), with how it behaves where it
458
+ * is not the brain's way. Whose it is (`owner`): what `options.owner` names (a goal makes its own with
459
+ * `claimed.squad`), else its own (`squad:<name>`). A goal's squad is made of what the goal holds, and what
460
+ * nothing holds is given to it; a squad of a rule or a module takes its units from whatever holds them (the goal
461
+ * told: `stop('told')`) and holds them until it is disbanded. A unit in another squad leaves it
462
+ */
463
+ make(name, units, options = {}) {
464
+ if (!name) throw new Error("A squad needs a name");
465
+ const { ai } = this;
466
+ const { owner: named, ...own } = options;
467
+ const owner = named ?? `squad:${name}`;
468
+ const old = this.named(name);
469
+ if (old) this.disband(old, "made anew", old.owner !== owner);
470
+ const behaves = {
471
+ ...this.defaults,
472
+ ...own
473
+ };
474
+ const squad = new Squad(this, {
475
+ name,
476
+ owner,
477
+ units: [],
478
+ options: behaves,
479
+ size: 0,
480
+ made: ai.tick,
481
+ retreats: 0
482
+ });
483
+ this.list.push(squad);
484
+ this.enlist(squad, ids(units));
485
+ squad.data.size = squad.data.units.length;
486
+ squad.changed(`made by ${owner === `squad:${name}` ? "itself" : owner}: ${plural(squad.data.units.length)}`);
487
+ return squad;
488
+ }
489
+ /**
490
+ * Puts units in a squad: those its owner may have (held by it, or given from the pool for a goal; taken for a rule's
491
+ * or a module's), out of any other squad. Those put in, by id
492
+ */
493
+ enlist(squad, wanted) {
494
+ const { goals, view, session, tick } = this.ai;
495
+ const owner = squad.data.owner;
496
+ const units = wanted.filter((id) => view.mine.has(id) && !squad.data.units.includes(id));
497
+ if (!units.length) return [];
498
+ let put;
499
+ if (goals.get(owner)) {
500
+ goals.give(owner, units);
501
+ put = units.filter((id) => goals.holder(id) === owner);
502
+ } else {
503
+ const hold = goals.held(owner);
504
+ const seconds = !hold || hold.kept ? Infinity : Math.max(1, (hold.until - tick) / session.tickRate);
505
+ goals.take(units, "told", {
506
+ id: owner,
507
+ seconds
508
+ });
509
+ put = units.filter((id) => goals.held(owner)?.units.includes(id));
510
+ }
511
+ if (!put.length) return put;
512
+ for (const other of [...this.list]) {
513
+ if (other === squad || !other.data.units.some((id) => put.includes(id))) continue;
514
+ other.data.units = other.data.units.filter((id) => !put.includes(id));
515
+ other.changed(`${plural(put.length)} went to ${squad.name}`);
516
+ if (!other.data.units.length) this.disband(other, `its units went to ${squad.name}`);
517
+ }
518
+ squad.data.units = squad.data.units.filter((id) => view.mine.has(id));
519
+ squad.data.units.push(...put);
520
+ squad.data.units.sort((a, b) => view.indexOf(view.byId(a)) - view.indexOf(view.byId(b)));
521
+ return put;
522
+ }
523
+ /** A squad by name: none for one there is not */
524
+ named(name) {
525
+ return this.list.find((squad) => squad.data.name === name);
526
+ }
527
+ /** Every squad, as made */
528
+ all() {
529
+ return new SquadGroup(this.ai, this.list);
530
+ }
531
+ /** The squads with nothing to do: told nothing, or their task over */
532
+ idle() {
533
+ return new SquadGroup(this.ai, this.list.filter((squad) => squad.idle));
534
+ }
535
+ /** The squads a goal, rule or module owns */
536
+ of(owner) {
537
+ return new SquadGroup(this.ai, this.list.filter((squad) => squad.data.owner === owner));
538
+ }
539
+ /** The squad a unit is in, by the unit or its id: none for a unit in none */
540
+ squadOf(unit) {
541
+ const id = typeof unit === "number" ? unit : unit.id;
542
+ return this.list.find((squad) => squad.data.units.includes(id));
543
+ }
544
+ /** The player's units nothing holds (`ai.goals.pool`, buildings left out): what a squad is made of, or reinforced from */
545
+ pool() {
546
+ return this.ai.goals.pool().units();
547
+ }
548
+ /** Disbands a squad: a squad that held its units itself lets them go back to the pool */
549
+ disband(squad, why = "disbanded", letGo = true) {
550
+ const index = this.list.indexOf(squad);
551
+ if (index < 0) return;
552
+ this.list.splice(index, 1);
553
+ const { goals } = this.ai;
554
+ if (letGo && !goals.get(squad.data.owner) && goals.held(squad.data.owner)) {
555
+ const others = new Set(this.list.filter((other) => other.data.owner === squad.data.owner).flatMap((other) => other.data.units));
556
+ goals.drop(squad.data.owner, squad.data.units.filter((id) => !others.has(id)));
557
+ }
558
+ if (squad.data.units.length || why !== "made anew") this.ai.decide(`squad ${squad.name} disbanded: ${why}`, { kind: "squad" });
559
+ }
560
+ /**
561
+ * Gives a squad a task: what it was doing is over, and the new one's first orders go at once. What it has now is what
562
+ * reinforcements make up to from then on (`SquadData.size`), but for a task it goes on to by itself (`going on`: a
563
+ * task's `then`, a fall back on the odds), which keeps what the task before was given. The task it is on given
564
+ * again changes nothing, its `size` kept: what it lost since is what reinforcements make up
565
+ */
566
+ give(squad, kind, data, goingOn = false) {
567
+ const { ai } = this;
568
+ const def = typeof kind === "string" ? this.tasks.get(kind) : kind;
569
+ if (!def) throw new Error(`The squad "${squad.name}" was given a task "${String(kind)}" the brain does not know: list it in its squads' tasks (defineTask)`);
570
+ if (typeof kind !== "string" && !this.tasks.has(def.id)) this.define(def);
571
+ const before = squad.data.task;
572
+ if (before && before.done === void 0 && before.kind === def.id && sameData(before.data, data)) return;
573
+ const state = {
574
+ kind: def.id,
575
+ data: { ...data },
576
+ since: ai.tick,
577
+ phase: "starting",
578
+ phaseSince: ai.tick,
579
+ memory: {}
580
+ };
581
+ squad.data.task = state;
582
+ if (!goingOn) squad.data.size = squad.data.units.length;
583
+ squad.changed(before && before.done === void 0 ? `${before.kind} → ${def.id}` : `on to ${def.id}`);
584
+ if (squad.data.units.length) def.start(ai, squad, state);
585
+ }
586
+ /**
587
+ * Looks at every squad, once a think: its units (the dead, and what its owner let go of, dropped; a squad of a goal
588
+ * that stopped disbanded), then its task (retreat on the odds, the task's own look, regroup, reinforcements). What the
589
+ * `squads()` module runs; a module may call it sooner
590
+ */
591
+ think() {
592
+ const { ai } = this;
593
+ if (this.thoughtAt !== ai.tick) {
594
+ this.thoughtAt = ai.tick;
595
+ this.prune();
596
+ this.advancing = [...this.list];
597
+ this.cursor = 0;
598
+ } else if (!this.advancing) return;
599
+ const squads = this.advancing;
600
+ for (; this.cursor < squads.length; this.cursor++) {
601
+ const squad = squads[this.cursor];
602
+ this.advance(squad);
603
+ if (!ai.budget.spent(squad.data.units.length || 1) && this.cursor + 1 < squads.length) {
604
+ this.cursor++;
605
+ return ai.budget.later();
606
+ }
607
+ }
608
+ this.advancing = void 0;
609
+ }
610
+ /** The squads still to be looked at this think, where a pass stopped for the tick's budget, and the next of them */
611
+ advancing;
612
+ cursor = 0;
613
+ /** Every squad's units looked at, as a think begins: the dead and what its owner let go of dropped, a squad with none left disbanded */
614
+ prune() {
615
+ const { ai } = this;
616
+ const { goals, view } = ai;
617
+ for (const squad of [...this.list]) {
618
+ const hold = goals.held(squad.data.owner);
619
+ if (!hold) {
620
+ this.disband(squad, `${squad.data.owner} let go`, false);
621
+ continue;
622
+ }
623
+ if (!goals.get(squad.data.owner) && hold.units.some((id) => !view.mine.has(id))) hold.units = hold.units.filter((id) => view.mine.has(id));
624
+ const kept = squad.data.units.filter((id) => hold.units.includes(id) && view.mine.has(id) && view.byId(id).health > 0);
625
+ if (kept.length !== squad.data.units.length) squad.data.units = kept;
626
+ if (!kept.length) {
627
+ squad.finish("wiped");
628
+ this.disband(squad, "none of its units left", false);
629
+ }
630
+ }
631
+ }
632
+ /** One squad's think: retreat on the odds, the task's own look, then on to the next task, regroup, reinforcements */
633
+ advance(squad) {
634
+ const { ai } = this;
635
+ const state = squad.data.task;
636
+ const def = state && this.tasks.get(state.kind);
637
+ const handles = def?.handles ?? [];
638
+ if (state && def && state.done === void 0) {
639
+ if (!handles.includes("retreat") && this.losing(squad)) return;
640
+ const over = def.done?.(ai, squad, state);
641
+ if (over) squad.finish(over);
642
+ else def.think(ai, squad, state);
643
+ if (state.done === void 0 && !handles.includes("regroup") && state.data.regroup !== false) this.regroup(squad, state, def);
644
+ const then = state.data.then;
645
+ if (state.done !== void 0 && state.done !== "lost" && state.done !== "wiped" && then?.kind && this.tasks.has(then.kind)) this.give(squad, then.kind, then.data ?? {}, true);
646
+ }
647
+ if (squad.data.options.reinforce && !handles.includes("reinforce")) this.reinforce(squad);
648
+ }
649
+ /**
650
+ * Whether a squad in a fight away from home is losing it (its odds under `retreatAt`), and so falls back: its task
651
+ * becomes `retreat`, home, and it is said why
652
+ */
653
+ losing(squad) {
654
+ const { ai } = this;
655
+ const { view } = ai;
656
+ const at = squad.data.options.retreatAt ?? .3;
657
+ if (at === false || !(at > 0)) return false;
658
+ const units = squad.units();
659
+ const middle = units.centre();
660
+ const home = view.home();
661
+ if (!middle || !home) return false;
662
+ const safe = squad.data.options.home ?? 20;
663
+ if (distSq(middle, home) < safe * safe) return false;
664
+ const foes = view.hostile.units().alive().near(middle, 14);
665
+ if (!foes.length || !foes.some((foe) => units.some((unit) => distSq(unit, foe) <= 64))) return false;
666
+ const odds = view.strength.odds(units.near(middle, 14), foes);
667
+ if (odds >= at) return false;
668
+ const was = squad.data.task?.kind ?? "nothing";
669
+ squad.data.retreats++;
670
+ this.give(squad, "retreat", {
671
+ at: point(home),
672
+ why: "odds"
673
+ }, true);
674
+ ai.decide(`squad ${squad.name} falls back home with ${plural(units.length)}: ${was} lost (odds ${odds.toFixed(2)} under ${at})`, { kind: "squad" });
675
+ return true;
676
+ }
677
+ /**
678
+ * Regroups a squad that is strung out on its way: too many of its units (`regroupWhen`) further than `spread` from its
679
+ * middle, and no fight near. It gathers on its middle and goes on once together, or once it has waited long enough
680
+ */
681
+ regroup(squad, state, def) {
682
+ const { ai } = this;
683
+ const units = squad.units();
684
+ if (units.length < 3) return;
685
+ const middle = units.centre();
686
+ const spread = squad.spread();
687
+ if (state.phase === "regrouping") {
688
+ const together = units.every((unit) => distSq(unit, middle) <= spread * spread * .36);
689
+ if (together || ai.tick - state.phaseSince >= REGROUP_FOR * ai.session.tickRate) {
690
+ def.start(ai, squad, state);
691
+ ai.decide(`squad ${squad.name} regrouped${together ? "" : " as much as it waits for"}: on with ${state.kind}`, { kind: "squad" });
692
+ }
693
+ return;
694
+ }
695
+ if (state.phase !== "going") return;
696
+ const when = squad.data.options.regroupWhen ?? .4;
697
+ if (when === false) return;
698
+ const strayed = units.filter((unit) => distSq(unit, middle) > spread * spread).length;
699
+ if (strayed <= units.length * when) return;
700
+ if (ai.view.hostile.alive().near(middle, 14).length) return;
701
+ state.phase = "regrouping";
702
+ state.phaseSince = ai.tick;
703
+ squad.order({
704
+ type: "move",
705
+ point: point(middle)
706
+ });
707
+ ai.decide(`squad ${squad.name} regroups at ${where(middle)}: ${strayed} of ${units.length} strung out`, { kind: "squad" });
708
+ }
709
+ /**
710
+ * Makes up what a squad lost since its task began from the pool: the idle fighters nothing holds, the nearest
711
+ * first, given to its owner and sent to join it. Never a hero: one crossing the map alone to a fight dies on the
712
+ * way, and heroes are sent with a squad, not after it. Not while it falls back, nor more often than every few seconds
713
+ */
714
+ reinforce(squad) {
715
+ const { ai } = this;
716
+ const { data } = squad;
717
+ const missing = data.size - data.units.length;
718
+ if (missing <= 0 || data.task?.kind === "retreat" && data.task.done === void 0) return;
719
+ if (data.nextReinforce !== void 0 && ai.tick < data.nextReinforce) return;
720
+ data.nextReinforce = ai.tick + REINFORCE_EVERY * ai.session.tickRate;
721
+ const join = squad.centre() ?? this.whereOf(squad) ?? ai.view.home();
722
+ if (!join) return;
723
+ const { strength } = ai.view;
724
+ const chosen = [...this.pool().fighters().idle()].filter((unit) => !heroOfState(unit) && unit.health >= WOUNDED * (unit.maxHealth ?? strength.statsOf(unit).health)).sort((a, b) => distSq(a, join) - distSq(b, join) || a.id - b.id).slice(0, missing).map((unit) => unit.id);
725
+ if (!chosen.length) return;
726
+ const size = data.size;
727
+ squad.add(chosen, "reinforced");
728
+ data.size = size;
729
+ const added = chosen.filter((id) => data.units.includes(id));
730
+ if (!added.length) return;
731
+ ai.send({
732
+ type: "attack",
733
+ entities: added,
734
+ point: point(join)
735
+ });
736
+ ai.decide(`squad ${squad.name} reinforced with ${plural(added.length)}`, { kind: "squad" });
737
+ }
738
+ /** The place a squad's task is about: none for a task about no place */
739
+ whereOf(squad) {
740
+ const state = squad.data.task;
741
+ const def = state && this.tasks.get(state.kind);
742
+ return state && def?.where?.(this.ai, squad, state);
743
+ }
744
+ /**
745
+ * The way to a place round where the enemy is strong (`avoid: 'army'`): the waypoint to go by, where the straight way
746
+ * crosses their strength (the threat map, with what is remembered of their towers, and their army as last seen) and a
747
+ * way round is less hot, tried on either side and then further out, twice at most. A heuristic, not a safe route:
748
+ * none where the straight way is cool enough, or where there is no way round (`note` says so)
749
+ */
750
+ route(from, to, squad) {
751
+ const { ai } = this;
752
+ const { view } = ai;
753
+ const units = squad.units();
754
+ const flying = units.length > 0 && units.every((unit) => !!view.def(unit).flying);
755
+ const layer = flying ? "air" : "ground";
756
+ const seen = ai.def.knowledge === false ? [] : ai.knowledge.enemy.armySeen(AVOID_SEEN);
757
+ const danger = (at) => {
758
+ let enemy = view.threat.at(at, {
759
+ layer,
760
+ remembered: true
761
+ }).enemy;
762
+ for (const army of seen) if (distSq(army.at, at) < 144) enemy += army.strength;
763
+ return enemy;
764
+ };
765
+ const hottest = (path) => {
766
+ let worst = {
767
+ at: path[0] ?? from,
768
+ enemy: 0
769
+ };
770
+ for (let i = 1; i < path.length; i++) {
771
+ const a = path[i - 1];
772
+ const b = path[i];
773
+ const steps = Math.max(1, Math.ceil(Math.sqrt(distSq(a, b)) / 6));
774
+ for (let s = 1; s <= steps; s++) {
775
+ const at = {
776
+ x: a.x + (b.x - a.x) * s / steps,
777
+ z: a.z + (b.z - a.z) * s / steps
778
+ };
779
+ const enemy = danger(at);
780
+ if (enemy > worst.enemy) worst = {
781
+ at,
782
+ enemy
783
+ };
784
+ }
785
+ }
786
+ return worst;
787
+ };
788
+ const worst = hottest([from, ...view.findPath(from, to, flying) ?? [from, to]]);
789
+ const bearable = Math.max(1e-9, units.strength() * .5);
790
+ if (worst.enemy <= bearable) return { waypoints: [] };
791
+ const { width, depth } = view.session.terrain;
792
+ const dx = to.x - from.x;
793
+ const dz = to.z - from.z;
794
+ const length = Math.sqrt(dx * dx + dz * dz) || 1;
795
+ const aside = {
796
+ x: -dz / length,
797
+ z: dx / length
798
+ };
799
+ let best;
800
+ for (let attempt = 0; attempt < 2; attempt++) {
801
+ const far = DETOUR * (1 + attempt / 2);
802
+ for (const side of [1, -1]) {
803
+ const at = {
804
+ x: Math.min(width - 1, Math.max(1, worst.at.x + aside.x * far * side)),
805
+ z: Math.min(depth - 1, Math.max(1, worst.at.z + aside.z * far * side))
806
+ };
807
+ const there = view.findPath(from, at, flying);
808
+ const on = there && view.findPath(at, to, flying);
809
+ if (!there || !on) continue;
810
+ const enemy = Math.max(hottest([from, ...there]).enemy, hottest([at, ...on]).enemy);
811
+ if (!best || enemy < best.enemy) best = {
812
+ at,
813
+ enemy
814
+ };
815
+ }
816
+ if (best && best.enemy <= bearable) return {
817
+ waypoints: [point(best.at)],
818
+ note: `round ${where(worst.at)} by ${where(best.at)}`
819
+ };
820
+ }
821
+ if (best && best.enemy < worst.enemy) return {
822
+ waypoints: [point(best.at)],
823
+ note: `no way round ${where(worst.at)} that is safe: by ${where(best.at)}, the least hot`
824
+ };
825
+ return {
826
+ waypoints: [],
827
+ note: `no way round ${where(worst.at)}: straight`
828
+ };
829
+ }
830
+ /** Every squad as the report shows it */
831
+ report() {
832
+ return this.list.map((squad) => {
833
+ const { data } = squad;
834
+ const units = squad.units();
835
+ const middle = units.centre();
836
+ const state = data.task;
837
+ const at = this.whereOf(squad);
838
+ return {
839
+ name: data.name,
840
+ owner: data.owner,
841
+ units: [...data.units],
842
+ strength: units.strength(),
843
+ ...middle && { at: pair(middle) },
844
+ size: data.size,
845
+ ...state && { task: {
846
+ kind: state.kind,
847
+ phase: state.phase,
848
+ since: state.since,
849
+ ...at && { at: pair(at) },
850
+ ...state.done !== void 0 && { done: state.done }
851
+ } },
852
+ retreats: data.retreats,
853
+ ...data.changed && { changed: { ...data.changed } }
854
+ };
855
+ });
856
+ }
857
+ /** What the squads are, for a save: copies */
858
+ /** Whether it has anything to remember now: one that does not is left out of a save */
859
+ remembers() {
860
+ return this.all().length > 0;
861
+ }
862
+ /** Gives the squads' data as plain data for a save of the brain */
863
+ save() {
864
+ return {
865
+ v: 1,
866
+ squads: this.list.map((squad) => structuredClone(squad.data))
867
+ };
868
+ }
869
+ /** Takes back what `save` gave: whether it was read. A squad on a task the brain does not know is kept, and does nothing */
870
+ restore(memory) {
871
+ const given = memory;
872
+ if (!given || typeof given !== "object" || given.v !== 1 || !Array.isArray(given.squads)) return false;
873
+ this.list = given.squads.filter((data) => data && typeof data.name === "string" && Array.isArray(data.units)).map((data) => new Squad(this, structuredClone(data)));
874
+ for (const squad of this.list) {
875
+ const kind = squad.data.task?.kind;
876
+ if (kind && !this.tasks.has(kind)) this.ai.log.info("ai", `the squad "${squad.name}" is on a task "${kind}" this brain does not know: it waits`, { squad: squad.name });
877
+ }
878
+ return true;
879
+ }
880
+ };
881
+ /** The share of its health under which a unit is not sent as a reinforcement */
882
+ var WOUNDED = .5;
883
+ /** Whether two tasks' data say the same: plain data, field by field */
884
+ function sameData(a, b) {
885
+ if (a === b) return true;
886
+ if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
887
+ if (Array.isArray(a) !== Array.isArray(b)) return false;
888
+ const keys = Object.keys(a).filter((key) => a[key] !== void 0);
889
+ const others = Object.keys(b).filter((key) => b[key] !== void 0);
890
+ return keys.length === others.length && keys.every((key) => sameData(a[key], b[key]));
891
+ }
892
+ /**
893
+ * The squads module: looks at every squad of the brain each think (`ai.squads.think`), after the goals, the rules and
894
+ * the words that make them: their units, their tasks, regroups, retreats, reinforcements. With how they behave where the
895
+ * brain's definition and the seat's options say nothing
896
+ *
897
+ * @beta
898
+ */
899
+ var squads = (options = {}) => defineModule({
900
+ id: "squads",
901
+ make: (ai) => {
902
+ for (const def of options.tasks ?? []) ai.squads.define(def);
903
+ const { tasks: _tasks, ...defaults } = options;
904
+ ai.squads.configure(defaults);
905
+ return {
906
+ id: "squads",
907
+ phase: "act",
908
+ after: ["goals"],
909
+ think: () => ai.squads.think()
910
+ };
911
+ }
912
+ });
913
+ //#endregion
914
+ export { Squad, SquadGroup, Squads, squads };
915
+
916
+ //# sourceMappingURL=squads.js.map