warscript 0.0.1-dev.a4deb44 → 0.0.1-dev.a5a2f5e

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 (319) hide show
  1. package/attributes.d.ts +18 -0
  2. package/attributes.lua +32 -0
  3. package/binaryreader.d.ts +1 -0
  4. package/binaryreader.lua +3 -0
  5. package/config.d.ts +5 -0
  6. package/config.lua +10 -0
  7. package/core/types/effect.d.ts +14 -6
  8. package/core/types/effect.lua +131 -35
  9. package/core/types/frame.d.ts +8 -1
  10. package/core/types/frame.lua +164 -23
  11. package/core/types/group.d.ts +0 -1
  12. package/core/types/handle.d.ts +2 -1
  13. package/core/types/handle.lua +5 -0
  14. package/core/types/image.d.ts +0 -1
  15. package/core/types/item.d.ts +1 -0
  16. package/core/types/item.lua +1 -0
  17. package/core/types/missile.d.ts +2 -2
  18. package/core/types/missile.lua +8 -2
  19. package/core/types/player.d.ts +17 -1
  20. package/core/types/player.lua +70 -24
  21. package/core/types/playerCamera.d.ts +2 -0
  22. package/core/types/playerCamera.lua +123 -5
  23. package/core/types/sound.d.ts +17 -24
  24. package/core/types/sound.lua +100 -25
  25. package/core/types/tileCell.d.ts +11 -1
  26. package/core/types/tileCell.lua +97 -0
  27. package/core/types/timer.d.ts +9 -8
  28. package/core/types/timer.lua +45 -23
  29. package/core/types/unit.lua +8 -0
  30. package/core/util.d.ts +1 -1
  31. package/core/util.lua +18 -1
  32. package/decl/index.d.ts +1 -0
  33. package/decl/native.d.ts +846 -790
  34. package/destroyable.d.ts +1 -0
  35. package/destroyable.lua +9 -0
  36. package/engine/ability.d.ts +1 -1
  37. package/engine/behavior.d.ts +24 -11
  38. package/engine/behavior.lua +233 -73
  39. package/engine/behaviour/ability/always-enabled.d.ts +7 -0
  40. package/engine/behaviour/ability/always-enabled.lua +31 -0
  41. package/engine/behaviour/ability/apply-buff.d.ts +8 -5
  42. package/engine/behaviour/ability/apply-buff.lua +36 -4
  43. package/engine/behaviour/ability/apply-unit-behavior.d.ts +13 -4
  44. package/engine/behaviour/ability/apply-unit-behavior.lua +32 -9
  45. package/engine/behaviour/ability/damage.d.ts +42 -11
  46. package/engine/behaviour/ability/damage.lua +89 -37
  47. package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
  48. package/engine/behaviour/ability/emulate-impact.lua +44 -0
  49. package/engine/behaviour/ability/heal.d.ts +33 -6
  50. package/engine/behaviour/ability/heal.lua +89 -10
  51. package/engine/behaviour/ability/instant-impact.d.ts +2 -2
  52. package/engine/behaviour/ability/instant-impact.lua +4 -15
  53. package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
  54. package/engine/behaviour/ability/on-command-impact.lua +25 -0
  55. package/engine/behaviour/ability/remove-buffs.d.ts +25 -0
  56. package/engine/behaviour/ability/remove-buffs.lua +49 -0
  57. package/engine/behaviour/ability/restore-mana.d.ts +15 -0
  58. package/engine/behaviour/ability/restore-mana.lua +29 -0
  59. package/engine/behaviour/ability.d.ts +35 -7
  60. package/engine/behaviour/ability.lua +183 -27
  61. package/engine/behaviour/unit/stun-immunity.d.ts +12 -7
  62. package/engine/behaviour/unit/stun-immunity.lua +57 -31
  63. package/engine/behaviour/unit.d.ts +48 -4
  64. package/engine/behaviour/unit.lua +292 -2
  65. package/engine/buff.d.ts +160 -53
  66. package/engine/buff.lua +711 -269
  67. package/engine/game-map.d.ts +7 -0
  68. package/engine/game-map.lua +32 -0
  69. package/engine/internal/ability.d.ts +23 -14
  70. package/engine/internal/ability.lua +129 -85
  71. package/engine/internal/item/ability.lua +162 -4
  72. package/engine/internal/item/fields.d.ts +12 -0
  73. package/engine/internal/item/fields.lua +33 -0
  74. package/engine/internal/item+owner.lua +12 -6
  75. package/engine/internal/item.d.ts +16 -19
  76. package/engine/internal/item.lua +174 -94
  77. package/engine/internal/mechanics/ability-duration.d.ts +1 -3
  78. package/engine/internal/mechanics/ability-duration.lua +3 -1
  79. package/engine/internal/mechanics/cast-ability.lua +89 -0
  80. package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
  81. package/engine/internal/misc/ability-disable-counter.lua +13 -0
  82. package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
  83. package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
  84. package/engine/internal/misc/frame-coordinates.d.ts +2 -0
  85. package/engine/internal/misc/frame-coordinates.lua +21 -0
  86. package/engine/internal/misc/get-terrain-z.d.ts +2 -0
  87. package/engine/internal/misc/get-terrain-z.lua +11 -0
  88. package/engine/internal/misc/player-local-handle.d.ts +2 -0
  89. package/engine/internal/misc/player-local-handle.lua +5 -0
  90. package/engine/internal/object-data/armor-bonus.d.ts +2 -0
  91. package/engine/internal/object-data/attribute-bonus.lua +2 -2
  92. package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
  93. package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
  94. package/engine/internal/object-data/evasion-probability.d.ts +2 -0
  95. package/engine/internal/object-data/evasion-probability.lua +16 -0
  96. package/engine/internal/object-data/health-bonus.d.ts +2 -0
  97. package/engine/internal/object-data/health-bonus.lua +16 -0
  98. package/engine/internal/object-data/mana-bonus.d.ts +2 -0
  99. package/engine/internal/object-data/mana-bonus.lua +16 -0
  100. package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
  101. package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
  102. package/engine/internal/unit/ability.d.ts +45 -1
  103. package/engine/internal/unit/ability.lua +128 -17
  104. package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
  105. package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
  106. package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
  107. package/engine/internal/unit/add-item-to-slot.lua +52 -0
  108. package/engine/internal/unit/allowed-targets.d.ts +1 -1
  109. package/engine/internal/unit/allowed-targets.lua +9 -1
  110. package/engine/internal/unit/attributes.d.ts +17 -0
  111. package/engine/internal/unit/attributes.lua +46 -0
  112. package/engine/internal/unit/bonus.d.ts +17 -8
  113. package/engine/internal/unit/bonus.lua +56 -4
  114. package/engine/internal/unit/detach-missiles.d.ts +7 -0
  115. package/engine/internal/unit/detach-missiles.lua +30 -0
  116. package/engine/internal/unit/fly-height.d.ts +7 -0
  117. package/engine/internal/unit/fly-height.lua +20 -0
  118. package/engine/internal/unit/ignore-events-items.d.ts +2 -0
  119. package/engine/internal/unit/ignore-events-items.lua +5 -0
  120. package/engine/internal/unit/interrupts.d.ts +12 -0
  121. package/engine/internal/unit/interrupts.lua +28 -0
  122. package/engine/internal/unit/item.d.ts +24 -0
  123. package/engine/internal/unit/item.lua +78 -0
  124. package/engine/internal/unit/main-selected.d.ts +13 -0
  125. package/engine/internal/unit/main-selected.lua +36 -0
  126. package/engine/internal/unit/order.d.ts +20 -0
  127. package/engine/internal/unit/order.lua +136 -0
  128. package/engine/internal/unit/range-event.d.ts +12 -0
  129. package/engine/internal/unit/range-event.lua +90 -0
  130. package/engine/internal/unit/scale.d.ts +7 -0
  131. package/engine/internal/unit/scale.lua +20 -0
  132. package/engine/internal/unit+ability.lua +12 -3
  133. package/engine/internal/unit+bonus.lua +3 -3
  134. package/engine/internal/unit+damage.d.ts +2 -11
  135. package/engine/internal/unit+damage.lua +10 -14
  136. package/engine/internal/unit+spellSteal.lua +1 -2
  137. package/engine/internal/unit+transport.lua +4 -10
  138. package/engine/internal/unit-missile-launch.lua +70 -13
  139. package/engine/internal/unit.d.ts +97 -36
  140. package/engine/internal/unit.lua +701 -336
  141. package/engine/internal/utility.lua +12 -0
  142. package/engine/lightning.d.ts +12 -5
  143. package/engine/lightning.lua +48 -14
  144. package/engine/local-client.d.ts +14 -2
  145. package/engine/local-client.lua +168 -1
  146. package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
  147. package/engine/object-data/auxiliary/animation-name.lua +16 -0
  148. package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
  149. package/engine/object-data/auxiliary/armor-type.lua +46 -0
  150. package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -3
  151. package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
  152. package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
  153. package/engine/object-data/auxiliary/attack-type.lua +42 -0
  154. package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
  155. package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
  156. package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
  157. package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
  158. package/engine/object-data/auxiliary/movement-type.lua +22 -0
  159. package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
  160. package/engine/object-data/auxiliary/sound-eax.lua +2 -0
  161. package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
  162. package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
  163. package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
  164. package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
  165. package/engine/object-data/entry/ability-type/{armor-increase.d.ts → armor-bonus.d.ts} +3 -3
  166. package/engine/object-data/entry/ability-type/{armor-increase.lua → armor-bonus.lua} +9 -9
  167. package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
  168. package/engine/object-data/entry/ability-type/berserk.lua +13 -0
  169. package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
  170. package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
  171. package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
  172. package/engine/object-data/entry/ability-type/blink.d.ts +10 -0
  173. package/engine/object-data/entry/ability-type/blink.lua +39 -0
  174. package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
  175. package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
  176. package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
  177. package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
  178. package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
  179. package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
  180. package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
  181. package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
  182. package/engine/object-data/entry/ability-type/health-bonus.d.ts +8 -0
  183. package/engine/object-data/entry/ability-type/health-bonus.lua +26 -0
  184. package/engine/object-data/entry/ability-type/mana-bonus.d.ts +8 -0
  185. package/engine/object-data/entry/ability-type/mana-bonus.lua +26 -0
  186. package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
  187. package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
  188. package/engine/object-data/entry/ability-type/mine.d.ts +10 -0
  189. package/engine/object-data/entry/ability-type/mine.lua +39 -0
  190. package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
  191. package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
  192. package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
  193. package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
  194. package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
  195. package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
  196. package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
  197. package/engine/object-data/entry/ability-type/reincarnation.d.ts +8 -0
  198. package/engine/object-data/entry/ability-type/reincarnation.lua +26 -0
  199. package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
  200. package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
  201. package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
  202. package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
  203. package/engine/object-data/entry/ability-type/spirit-touch.d.ts +2 -2
  204. package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
  205. package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
  206. package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
  207. package/engine/object-data/entry/ability-type/web.d.ts +12 -0
  208. package/engine/object-data/entry/ability-type/web.lua +52 -0
  209. package/engine/object-data/entry/ability-type.d.ts +21 -18
  210. package/engine/object-data/entry/ability-type.lua +177 -40
  211. package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
  212. package/engine/object-data/entry/buff-type/applicable.lua +143 -202
  213. package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
  214. package/engine/object-data/entry/buff-type.d.ts +6 -13
  215. package/engine/object-data/entry/buff-type.lua +13 -29
  216. package/engine/object-data/entry/destructible-type.d.ts +28 -3
  217. package/engine/object-data/entry/destructible-type.lua +155 -0
  218. package/engine/object-data/entry/item-type/blank.d.ts +0 -1
  219. package/engine/object-data/entry/item-type.d.ts +15 -2
  220. package/engine/object-data/entry/item-type.lua +93 -2
  221. package/engine/object-data/entry/lightning-type.d.ts +1 -2
  222. package/engine/object-data/entry/sound-preset.d.ts +33 -0
  223. package/engine/object-data/entry/sound-preset.lua +140 -0
  224. package/engine/object-data/entry/unit-type.d.ts +65 -5
  225. package/engine/object-data/entry/unit-type.lua +555 -62
  226. package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
  227. package/engine/object-data/entry/upgrade.d.ts +1 -2
  228. package/engine/object-data/entry/upgrade.lua +4 -4
  229. package/engine/object-data/entry.d.ts +18 -17
  230. package/engine/object-data/entry.lua +60 -32
  231. package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
  232. package/engine/object-field/ability.d.ts +28 -5
  233. package/engine/object-field/ability.lua +61 -7
  234. package/engine/object-field/item.d.ts +22 -0
  235. package/engine/object-field/item.lua +118 -0
  236. package/engine/object-field/unit.d.ts +72 -3
  237. package/engine/object-field/unit.lua +268 -7
  238. package/engine/object-field.d.ts +26 -8
  239. package/engine/object-field.lua +362 -117
  240. package/engine/random.d.ts +11 -0
  241. package/engine/random.lua +30 -0
  242. package/engine/standard/entries/buff-type.d.ts +3 -0
  243. package/engine/standard/entries/buff-type.lua +3 -0
  244. package/engine/standard/entries/sound-preset.d.ts +10 -0
  245. package/engine/standard/entries/sound-preset.lua +10 -0
  246. package/engine/standard/entries/unit-type.d.ts +42 -1
  247. package/engine/standard/entries/unit-type.lua +42 -1
  248. package/engine/standard/fields/ability.d.ts +5 -3
  249. package/engine/standard/fields/ability.lua +5 -3
  250. package/engine/standard/fields/item.d.ts +4 -0
  251. package/engine/standard/fields/item.lua +6 -0
  252. package/engine/standard/fields/unit.d.ts +12 -0
  253. package/engine/standard/fields/unit.lua +20 -0
  254. package/engine/synchronization.d.ts +11 -0
  255. package/engine/synchronization.lua +77 -0
  256. package/engine/text-tag.d.ts +36 -2
  257. package/engine/text-tag.lua +250 -10
  258. package/engine/unit.d.ts +10 -0
  259. package/engine/unit.lua +19 -2
  260. package/event.d.ts +2 -3
  261. package/event.lua +9 -5
  262. package/global/vec2.lua +1 -0
  263. package/index.d.ts +1 -0
  264. package/index.lua +1 -0
  265. package/lualib_bundle.lua +147 -43
  266. package/math/vec2.d.ts +2 -9
  267. package/math.d.ts +2 -2
  268. package/math.lua +14 -0
  269. package/net/socket.d.ts +7 -1
  270. package/net/socket.lua +45 -4
  271. package/network.d.ts +1 -0
  272. package/network.lua +3 -2
  273. package/objutil/ability.d.ts +0 -1
  274. package/objutil/buff.d.ts +0 -1
  275. package/objutil/buff.lua +12 -11
  276. package/objutil/object.d.ts +0 -1
  277. package/objutil/object.lua +1 -1
  278. package/objutil/unit.d.ts +0 -1
  279. package/objutil/unit.lua +8 -0
  280. package/operation.lua +1 -4
  281. package/package.json +13 -14
  282. package/patch-lua.d.ts +0 -0
  283. package/patch-lua.lua +25 -0
  284. package/patch-lualib.lua +1 -1
  285. package/property.d.ts +55 -0
  286. package/property.lua +374 -0
  287. package/string.d.ts +30 -0
  288. package/string.lua +14 -0
  289. package/util/stream.d.ts +0 -1
  290. package/utility/arrays.d.ts +13 -5
  291. package/utility/arrays.lua +45 -3
  292. package/utility/bit-set.d.ts +0 -2
  293. package/utility/callback-array.d.ts +17 -0
  294. package/utility/callback-array.lua +61 -0
  295. package/utility/functions.d.ts +8 -0
  296. package/utility/functions.lua +13 -0
  297. package/utility/lazy.d.ts +2 -0
  298. package/utility/lazy.lua +14 -0
  299. package/utility/linked-map.d.ts +35 -0
  300. package/utility/linked-map.lua +107 -0
  301. package/utility/linked-set.d.ts +16 -4
  302. package/utility/linked-set.lua +54 -3
  303. package/utility/lua-maps.d.ts +16 -4
  304. package/utility/lua-maps.lua +53 -2
  305. package/utility/lua-sets.d.ts +3 -2
  306. package/utility/lua-sets.lua +7 -0
  307. package/utility/records.lua +20 -1
  308. package/utility/reflection.lua +11 -7
  309. package/utility/types.d.ts +6 -2
  310. package/utility/unordered-map.d.ts +27 -0
  311. package/utility/unordered-map.lua +99 -0
  312. package/core/mapbounds.d.ts +0 -8
  313. package/core/mapbounds.lua +0 -12
  314. package/core/types/order.d.ts +0 -25
  315. package/core/types/order.lua +0 -55
  316. /package/engine/internal/{object-data/armor-increase.d.ts → mechanics/cast-ability.d.ts} +0 -0
  317. /package/engine/internal/object-data/{armor-increase.lua → armor-bonus.lua} +0 -0
  318. /package/engine/object-data/entry/ability-type/{attribute-increase.d.ts → attribute-bonus.d.ts} +0 -0
  319. /package/engine/object-data/entry/ability-type/{attribute-increase.lua → attribute-bonus.lua} +0 -0
@@ -1,9 +1,9 @@
1
1
  local ____exports = {}
2
2
  local ____unit = require("engine.internal.unit")
3
3
  local Unit = ____unit.Unit
4
- local ____armor_2Dincrease = require("engine.internal.object-data.armor-increase")
5
- local ARMOR_BONUS_DUMMY_ABILITY_FIELD = ____armor_2Dincrease.ARMOR_BONUS_DUMMY_ABILITY_FIELD
6
- local ARMOR_BONUS_DUMMY_ABILITY_TYPE_ID = ____armor_2Dincrease.ARMOR_BONUS_DUMMY_ABILITY_TYPE_ID
4
+ local ____armor_2Dbonus = require("engine.internal.object-data.armor-bonus")
5
+ local ARMOR_BONUS_DUMMY_ABILITY_FIELD = ____armor_2Dbonus.ARMOR_BONUS_DUMMY_ABILITY_FIELD
6
+ local ARMOR_BONUS_DUMMY_ABILITY_TYPE_ID = ____armor_2Dbonus.ARMOR_BONUS_DUMMY_ABILITY_TYPE_ID
7
7
  local ____utility = require("engine.internal.utility")
8
8
  local addInternalAbility = ____utility.addInternalAbility
9
9
  local ____arrays = require("utility.arrays")
@@ -21,10 +21,44 @@ local AUTO_ATTACK_DAMAGE_INCREASE_DUMMY_ABILITY_TYPE_ID = ____auto_2Dattack_2Dda
21
21
  local ____movement_2Dspeed_2Dincrease_2Dfactor = require("engine.internal.object-data.movement-speed-increase-factor")
22
22
  local MOVEMENT_SPEED_INCREASE_FACTOR_ABILITY_FIELD = ____movement_2Dspeed_2Dincrease_2Dfactor.MOVEMENT_SPEED_INCREASE_FACTOR_ABILITY_FIELD
23
23
  local MOVEMENT_SPEED_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID = ____movement_2Dspeed_2Dincrease_2Dfactor.MOVEMENT_SPEED_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID
24
+ local ____evasion_2Dprobability = require("engine.internal.object-data.evasion-probability")
25
+ local EVASION_PROBABILITY_ABILITY_FIELD = ____evasion_2Dprobability.EVASION_PROBABILITY_ABILITY_FIELD
26
+ local EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID = ____evasion_2Dprobability.EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID
27
+ local ____health_2Dbonus = require("engine.internal.object-data.health-bonus")
28
+ local HEALTH_BONUS_DUMMY_ABILITY_FIELD = ____health_2Dbonus.HEALTH_BONUS_DUMMY_ABILITY_FIELD
29
+ local HEALTH_BONUS_DUMMY_ABILITY_TYPE_ID = ____health_2Dbonus.HEALTH_BONUS_DUMMY_ABILITY_TYPE_ID
30
+ local ____mana_2Dbonus = require("engine.internal.object-data.mana-bonus")
31
+ local MANA_BONUS_DUMMY_ABILITY_FIELD = ____mana_2Dbonus.MANA_BONUS_DUMMY_ABILITY_FIELD
32
+ local MANA_BONUS_DUMMY_ABILITY_TYPE_ID = ____mana_2Dbonus.MANA_BONUS_DUMMY_ABILITY_TYPE_ID
33
+ local ____mana_2Dregeneration_2Drate_2Dincrease_2Dfactor = require("engine.internal.object-data.mana-regeneration-rate-increase-factor")
34
+ local MANA_REGENERATION_RATE_INCREASE_FACTOR_ABILITY_FIELD = ____mana_2Dregeneration_2Drate_2Dincrease_2Dfactor.MANA_REGENERATION_RATE_INCREASE_FACTOR_ABILITY_FIELD
35
+ local MANA_REGENERATION_RATE_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID = ____mana_2Dregeneration_2Drate_2Dincrease_2Dfactor.MANA_REGENERATION_RATE_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID
36
+ local damageFactorByUnit = {}
24
37
  local receivedDamageFactorByUnit = {}
38
+ local function atLeastOnceProbability(array)
39
+ local oppositeEventProbability = 1
40
+ for i = 1, #array do
41
+ oppositeEventProbability = oppositeEventProbability * (1 - array[i])
42
+ end
43
+ return 1 - oppositeEventProbability
44
+ end
25
45
  ____exports.UnitBonusType = {}
26
46
  local UnitBonusType = ____exports.UnitBonusType
27
47
  do
48
+ UnitBonusType.HEALTH = {
49
+ abilityTypeId = HEALTH_BONUS_DUMMY_ABILITY_TYPE_ID,
50
+ field = HEALTH_BONUS_DUMMY_ABILITY_FIELD,
51
+ integer = true,
52
+ reduce = sum,
53
+ initialValue = 0
54
+ }
55
+ UnitBonusType.MANA = {
56
+ abilityTypeId = MANA_BONUS_DUMMY_ABILITY_TYPE_ID,
57
+ field = MANA_BONUS_DUMMY_ABILITY_FIELD,
58
+ integer = true,
59
+ reduce = sum,
60
+ initialValue = 0
61
+ }
28
62
  UnitBonusType.ARMOR = {
29
63
  abilityTypeId = ARMOR_BONUS_DUMMY_ABILITY_TYPE_ID,
30
64
  field = ARMOR_BONUS_DUMMY_ABILITY_FIELD,
@@ -46,14 +80,29 @@ do
46
80
  reduce = sum,
47
81
  initialValue = 0
48
82
  }
49
- UnitBonusType.DAMAGE = {
83
+ UnitBonusType.AUTO_ATTACK_DAMAGE = {
50
84
  abilityTypeId = AUTO_ATTACK_DAMAGE_INCREASE_DUMMY_ABILITY_TYPE_ID,
51
85
  field = AUTO_ATTACK_DAMAGE_INCREASE_ABILITY_FIELD,
52
86
  integer = false,
53
87
  reduce = sum,
54
88
  initialValue = 0
55
89
  }
90
+ UnitBonusType.DAMAGE_FACTOR = {reduce = product, valueByUnit = damageFactorByUnit, initialValue = 1}
56
91
  UnitBonusType.RECEIVED_DAMAGE_FACTOR = {reduce = product, valueByUnit = receivedDamageFactorByUnit, initialValue = 1}
92
+ UnitBonusType.EVASION_PROBABILITY = {
93
+ abilityTypeId = EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID,
94
+ field = EVASION_PROBABILITY_ABILITY_FIELD,
95
+ integer = false,
96
+ reduce = atLeastOnceProbability,
97
+ initialValue = 0
98
+ }
99
+ UnitBonusType.MANA_REGENERATION_RATE_FACTOR = {
100
+ abilityTypeId = MANA_REGENERATION_RATE_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID,
101
+ field = MANA_REGENERATION_RATE_INCREASE_FACTOR_ABILITY_FIELD,
102
+ integer = false,
103
+ reduce = sum,
104
+ initialValue = 0
105
+ }
57
106
  end
58
107
  local bonusesByUnitByBonusType = {}
59
108
  local nextId = 1
@@ -180,6 +229,9 @@ end
180
229
  Unit.onDamage:addListener(
181
230
  4,
182
231
  function(source, target, event)
232
+ if source ~= nil and damageFactorByUnit[source] ~= nil then
233
+ event.amount = event.amount * damageFactorByUnit[source]
234
+ end
183
235
  if receivedDamageFactorByUnit[target] ~= nil then
184
236
  event.amount = event.amount * receivedDamageFactorByUnit[target]
185
237
  end
@@ -0,0 +1,7 @@
1
+ /** @noSelfInFile */
2
+ declare module "../unit" {
3
+ interface Unit {
4
+ detachMissiles(this: Unit): void;
5
+ }
6
+ }
7
+ export {};
@@ -0,0 +1,30 @@
1
+ local ____exports = {}
2
+ local ____unit = require("engine.internal.unit")
3
+ local Unit = ____unit.Unit
4
+ local ____cast_2Dability = require("engine.internal.mechanics.cast-ability")
5
+ local castAbility = ____cast_2Dability.castAbility
6
+ local ____blink = require("engine.object-data.entry.ability-type.blink")
7
+ local BlinkAbilityType = ____blink.BlinkAbilityType
8
+ local ____math = require("math")
9
+ local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
10
+ local getUnitX = GetUnitX
11
+ local getUnitY = GetUnitY
12
+ local setUnitX = SetUnitX
13
+ local setUnitY = SetUnitY
14
+ local BLINK_ABILITY_TYPE_ID = compiletime(function()
15
+ local abilityType = BlinkAbilityType:create()
16
+ abilityType.minimumRange = 0
17
+ abilityType.maximumRange = MAXIMUM_INTEGER
18
+ abilityType.manaCost = 0
19
+ abilityType.cooldown = 0
20
+ return abilityType.id
21
+ end)
22
+ Unit.prototype.detachMissiles = function(self)
23
+ local nativeUnit = self.handle
24
+ local x = getUnitX(nativeUnit)
25
+ local y = getUnitY(nativeUnit)
26
+ castAbility(nativeUnit, BLINK_ABILITY_TYPE_ID)
27
+ setUnitX(nativeUnit, x)
28
+ setUnitY(nativeUnit, y)
29
+ end
30
+ return ____exports
@@ -0,0 +1,7 @@
1
+ /** @noSelfInFile */
2
+ declare module "../unit" {
3
+ interface Unit {
4
+ flyHeight: number;
5
+ }
6
+ }
7
+ export {};
@@ -0,0 +1,20 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
3
+ local ____exports = {}
4
+ local ____unit = require("engine.internal.unit")
5
+ local Unit = ____unit.Unit
6
+ local ____unit = require("engine.standard.fields.unit")
7
+ local FLY_HEIGHT_UNIT_FIELD = ____unit.FLY_HEIGHT_UNIT_FIELD
8
+ __TS__ObjectDefineProperty(
9
+ Unit.prototype,
10
+ "flyHeight",
11
+ {
12
+ get = function(self)
13
+ return FLY_HEIGHT_UNIT_FIELD:getValue(self)
14
+ end,
15
+ set = function(self, value)
16
+ FLY_HEIGHT_UNIT_FIELD:setValue(self, value)
17
+ end
18
+ }
19
+ )
20
+ return ____exports
@@ -0,0 +1,2 @@
1
+ /** @noSelfInFile */
2
+ export {};
@@ -0,0 +1,5 @@
1
+ local ____exports = {}
2
+ ---
3
+ -- @internal For use by internal systems only.
4
+ ____exports.ignoreEventsItems = {}
5
+ return ____exports
@@ -0,0 +1,12 @@
1
+ /** @noSelfInFile */
2
+ declare module "../unit" {
3
+ interface Unit {
4
+ interruptAttack(this: Unit): void;
5
+ }
6
+ }
7
+ declare module "../unit" {
8
+ interface Unit {
9
+ interruptMovement(this: Unit): void;
10
+ }
11
+ }
12
+ export {};
@@ -0,0 +1,28 @@
1
+ local ____exports = {}
2
+ local ____unit = require("engine.internal.unit")
3
+ local Unit = ____unit.Unit
4
+ local ____unit_2Dmissile_2Dlaunch = require("engine.internal.unit-missile-launch")
5
+ local resetAutoAttackTimer = ____unit_2Dmissile_2Dlaunch.resetAutoAttackTimer
6
+ local unitDisableAbility = BlzUnitDisableAbility
7
+ local unitInterruptAttack = BlzUnitInterruptAttack
8
+ Unit.prototype.interruptAttack = function(self)
9
+ unitInterruptAttack(self.handle)
10
+ resetAutoAttackTimer(self)
11
+ end
12
+ Unit.prototype.interruptMovement = function(self)
13
+ local handle = self.handle
14
+ unitDisableAbility(
15
+ handle,
16
+ fourCC("Amov"),
17
+ true,
18
+ false
19
+ )
20
+ unitDisableAbility(
21
+ handle,
22
+ fourCC("Amov"),
23
+ false,
24
+ false
25
+ )
26
+ resetAutoAttackTimer(self)
27
+ end
28
+ return ____exports
@@ -0,0 +1,24 @@
1
+ /** @noSelfInFile */
2
+ import { Item } from "../item";
3
+ export interface UnitItems extends ReadonlyArray<Item | undefined> {
4
+ readonly length: 0 | 1 | 2 | 3 | 4 | 5 | 6;
5
+ [0]: Item | undefined;
6
+ [1]: Item | undefined;
7
+ [2]: Item | undefined;
8
+ [3]: Item | undefined;
9
+ [4]: Item | undefined;
10
+ [5]: Item | undefined;
11
+ }
12
+ export declare class UnitItems {
13
+ constructor(handle: junit);
14
+ findSlot(item: Item): 0 | 1 | 2 | 3 | 4 | 5 | undefined;
15
+ protected __newindex(slot: number, item: Item | undefined): void;
16
+ protected __index(key: string | number): unknown;
17
+ protected __len(): number;
18
+ protected __ipairs(): LuaIterator<LuaMultiReturn<[number, Item | undefined]>, junit>;
19
+ }
20
+ declare module "../unit" {
21
+ interface Unit {
22
+ readonly items: UnitItems;
23
+ }
24
+ }
@@ -0,0 +1,78 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__New = ____lualib.__TS__New
4
+ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
5
+ local ____exports = {}
6
+ local ____item = require("engine.internal.item")
7
+ local Item = ____item.Item
8
+ local ____unit = require("engine.internal.unit")
9
+ local Unit = ____unit.Unit
10
+ local ____utility = require("engine.internal.utility")
11
+ local findUnitItemSlot = ____utility.findUnitItemSlot
12
+ local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
13
+ local unitAddItemToSlot = ____add_2Ditem_2Dto_2Dslot.unitAddItemToSlot
14
+ local rawset = _G.rawset
15
+ local ____type = _G.type
16
+ local isItemPowerup = IsItemPowerup
17
+ local setItemBooleanField = BlzSetItemBooleanField
18
+ local unitInventorySize = UnitInventorySize
19
+ local unitItemInSlot = UnitItemInSlot
20
+ local unitRemoveItemFromSlot = UnitRemoveItemFromSlot
21
+ local handleByUnitItems = setmetatable({}, {__mode = "k"})
22
+ local function unitItemsNext(handle, index)
23
+ local slot = index & 7
24
+ if index >> 3 == slot then
25
+ return nil, nil
26
+ end
27
+ return index + 1, Item:of(unitItemInSlot(handle, slot))
28
+ end
29
+ ____exports.UnitItems = __TS__Class()
30
+ local UnitItems = ____exports.UnitItems
31
+ UnitItems.name = "UnitItems"
32
+ function UnitItems.prototype.____constructor(self, handle)
33
+ handleByUnitItems[self] = handle
34
+ end
35
+ function UnitItems.prototype.findSlot(self, item)
36
+ return findUnitItemSlot(handleByUnitItems[self], item.handle)
37
+ end
38
+ function UnitItems.prototype.__newindex(self, slot, item)
39
+ local handle = handleByUnitItems[self]
40
+ if slot < 1 or slot > unitInventorySize(handle) then
41
+ return
42
+ end
43
+ unitRemoveItemFromSlot(handle, slot - 1)
44
+ if item ~= nil then
45
+ local itemHandle = item.handle
46
+ local isPowerup = isItemPowerup(itemHandle)
47
+ if isPowerup then
48
+ setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
49
+ end
50
+ unitAddItemToSlot(handle, itemHandle, slot - 1)
51
+ if isPowerup then
52
+ setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
53
+ end
54
+ end
55
+ end
56
+ function UnitItems.prototype.__index(self, key)
57
+ if ____type(key) == "number" then
58
+ return Item:of(unitItemInSlot(handleByUnitItems[self], key - 1))
59
+ end
60
+ return rawget(____exports.UnitItems.prototype, key)
61
+ end
62
+ function UnitItems.prototype.__len(self)
63
+ return unitInventorySize(handleByUnitItems[self])
64
+ end
65
+ function UnitItems.prototype.__ipairs(self)
66
+ local handle = handleByUnitItems[self]
67
+ return unitItemsNext, handle, unitInventorySize(handle) << 3
68
+ end
69
+ __TS__ObjectDefineProperty(
70
+ Unit.prototype,
71
+ "items",
72
+ {get = function(self)
73
+ local items = __TS__New(____exports.UnitItems, self.handle)
74
+ rawset(self, "items", items)
75
+ return items
76
+ end}
77
+ )
78
+ return ____exports
@@ -0,0 +1,13 @@
1
+ /** @noSelfInFile */
2
+ import { Player } from "../../../core/types/player";
3
+ import { Event } from "../../../event";
4
+ declare module "../unit" {
5
+ namespace Unit {
6
+ const mainSelectedUnitChangeEvent: Event<[Player]>;
7
+ }
8
+ }
9
+ declare module "../unit" {
10
+ namespace Unit {
11
+ const getMainSelectedOf: (player: Player) => Unit | undefined;
12
+ }
13
+ }
@@ -0,0 +1,36 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__New = ____lualib.__TS__New
3
+ local ____exports = {}
4
+ local ____local_2Dclient = require("engine.local-client")
5
+ local LocalClient = ____local_2Dclient.LocalClient
6
+ local ____unit = require("engine.internal.unit")
7
+ local Unit = ____unit.Unit
8
+ local ____event = require("event")
9
+ local Event = ____event.Event
10
+ local ____synchronization = require("engine.synchronization")
11
+ local ObjectBus = ____synchronization.ObjectBus
12
+ local mainSelectedUnitChangeEvent = __TS__New(Event)
13
+ rawset(Unit, "mainSelectedUnitChangeEvent", mainSelectedUnitChangeEvent)
14
+ local mainSelectedUnitByPlayer = {}
15
+ local unitBus = __TS__New(
16
+ ObjectBus,
17
+ function(unit) return unit.syncId end,
18
+ function(syncId) return Unit:getBySyncId(syncId) end
19
+ )
20
+ LocalClient.mainSelectedUnitChangeEvent:addListener(function()
21
+ unitBus:send(LocalClient.mainSelectedUnit)
22
+ end)
23
+ unitBus.event:addListener(function(player, unit)
24
+ if unit ~= mainSelectedUnitByPlayer[player] then
25
+ mainSelectedUnitByPlayer[player] = unit
26
+ Event.invoke(mainSelectedUnitChangeEvent, player)
27
+ end
28
+ end)
29
+ rawset(
30
+ Unit,
31
+ "getMainSelectedOf",
32
+ function(player)
33
+ return mainSelectedUnitByPlayer[player]
34
+ end
35
+ )
36
+ return ____exports
@@ -0,0 +1,20 @@
1
+ /** @noSelfInFile */
2
+ import { Widget } from "../../../core/types/widget";
3
+ export declare const enum OrderType {
4
+ IMMEDIATE = 0,
5
+ POINT = 1,
6
+ TARGET = 2
7
+ }
8
+ declare module "../unit" {
9
+ interface Unit {
10
+ readonly currentOrderType: OrderType;
11
+ readonly currentOrderId: number;
12
+ readonly currentOrderStartTime: number;
13
+ readonly currentOrderStartX: number;
14
+ readonly currentOrderStartY: number;
15
+ readonly currentOrderTargetX: number;
16
+ readonly currentOrderTargetY: number;
17
+ readonly currentOrderTarget?: Widget;
18
+ issueOrder(...order: [orderType: OrderType.IMMEDIATE, orderId: number] | [orderType: OrderType.POINT, orderId: number, x: number, y: number] | [orderType: OrderType.TARGET, orderId: number, target: Widget]): boolean;
19
+ }
20
+ }
@@ -0,0 +1,136 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
3
+ local ____exports = {}
4
+ local ____attributes = require("attributes")
5
+ local attribute = ____attributes.attribute
6
+ local ____unit = require("engine.internal.unit")
7
+ local Unit = ____unit.Unit
8
+ local ____game = require("core.game")
9
+ local elapsedTime = ____game.elapsedTime
10
+ local getUnitCurrentOrder = GetUnitCurrentOrder
11
+ local issueImmediateOrderById = IssueImmediateOrderById
12
+ local issuePointOrderById = IssuePointOrderById
13
+ local issueTargetOrderById = IssueTargetOrderById
14
+ local unitLastOrderTypeAttribute = attribute()
15
+ local unitLastOrderIdAttribute = attribute()
16
+ local unitLastOrderStartTimeAttribute = attribute()
17
+ local unitLastOrderStartXAttribute = attribute()
18
+ local unitLastOrderStartYAttribute = attribute()
19
+ local unitLastOrderTargetXAttribute = attribute()
20
+ local unitLastOrderTargetYAttribute = attribute()
21
+ local unitLastOrderTargetAttribute = attribute()
22
+ Unit.onImmediateOrder:addListener(
23
+ 4,
24
+ function(unit, orderId)
25
+ unit[unitLastOrderTypeAttribute] = 0
26
+ unit[unitLastOrderIdAttribute] = orderId
27
+ unit[unitLastOrderStartTimeAttribute] = elapsedTime()
28
+ unit[unitLastOrderStartXAttribute] = unit.x
29
+ unit[unitLastOrderStartYAttribute] = unit.y
30
+ unit[unitLastOrderTargetXAttribute] = nil
31
+ unit[unitLastOrderTargetYAttribute] = nil
32
+ unit[unitLastOrderTargetAttribute] = nil
33
+ end
34
+ )
35
+ Unit.onPointOrder:addListener(
36
+ 4,
37
+ function(unit, orderId, x, y)
38
+ unit[unitLastOrderTypeAttribute] = 1
39
+ unit[unitLastOrderIdAttribute] = orderId
40
+ unit[unitLastOrderStartTimeAttribute] = elapsedTime()
41
+ unit[unitLastOrderStartXAttribute] = unit.x
42
+ unit[unitLastOrderStartYAttribute] = unit.y
43
+ unit[unitLastOrderTargetXAttribute] = x
44
+ unit[unitLastOrderTargetYAttribute] = y
45
+ unit[unitLastOrderTargetAttribute] = nil
46
+ end
47
+ )
48
+ Unit.onTargetOrder:addListener(
49
+ 4,
50
+ function(unit, orderId, target)
51
+ unit[unitLastOrderTypeAttribute] = 2
52
+ unit[unitLastOrderIdAttribute] = orderId
53
+ unit[unitLastOrderStartTimeAttribute] = elapsedTime()
54
+ unit[unitLastOrderStartXAttribute] = unit.x
55
+ unit[unitLastOrderStartYAttribute] = unit.y
56
+ unit[unitLastOrderTargetXAttribute] = target.x
57
+ unit[unitLastOrderTargetYAttribute] = target.y
58
+ unit[unitLastOrderTargetAttribute] = target
59
+ end
60
+ )
61
+ local function toUndefinedIfCurrentOrderDoesNotMatchLast(unit, value)
62
+ local currentOrderId = getUnitCurrentOrder(unit.handle)
63
+ local lastOrderId = unit[unitLastOrderIdAttribute]
64
+ local ____temp_0
65
+ if currentOrderId == lastOrderId or currentOrderId == orderId("patrolAI") and lastOrderId == orderId("patrol") then
66
+ ____temp_0 = value
67
+ else
68
+ ____temp_0 = nil
69
+ end
70
+ return ____temp_0
71
+ end
72
+ __TS__ObjectDefineProperty(
73
+ Unit.prototype,
74
+ "currentOrderType",
75
+ {get = function(self)
76
+ return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTypeAttribute]) or 0
77
+ end}
78
+ )
79
+ __TS__ObjectDefineProperty(
80
+ Unit.prototype,
81
+ "currentOrderId",
82
+ {get = function(self)
83
+ return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderIdAttribute]) or 0
84
+ end}
85
+ )
86
+ __TS__ObjectDefineProperty(
87
+ Unit.prototype,
88
+ "currentOrderStartTime",
89
+ {get = function(self)
90
+ return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderStartTimeAttribute]) or 0
91
+ end}
92
+ )
93
+ __TS__ObjectDefineProperty(
94
+ Unit.prototype,
95
+ "currentOrderStartX",
96
+ {get = function(self)
97
+ return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderStartXAttribute]) or 0
98
+ end}
99
+ )
100
+ __TS__ObjectDefineProperty(
101
+ Unit.prototype,
102
+ "currentOrderStartY",
103
+ {get = function(self)
104
+ return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderStartYAttribute]) or 0
105
+ end}
106
+ )
107
+ __TS__ObjectDefineProperty(
108
+ Unit.prototype,
109
+ "currentOrderTargetX",
110
+ {get = function(self)
111
+ return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTargetXAttribute]) or 0
112
+ end}
113
+ )
114
+ __TS__ObjectDefineProperty(
115
+ Unit.prototype,
116
+ "currentOrderTargetY",
117
+ {get = function(self)
118
+ return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTargetYAttribute]) or 0
119
+ end}
120
+ )
121
+ __TS__ObjectDefineProperty(
122
+ Unit.prototype,
123
+ "currentOrderTarget",
124
+ {get = function(self)
125
+ return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTargetAttribute])
126
+ end}
127
+ )
128
+ local issueOrderByType = {
129
+ [0] = issueImmediateOrderById,
130
+ [1] = issuePointOrderById,
131
+ [2] = function(unitHandle, orderId, widget) return issueTargetOrderById(unitHandle, orderId, widget.handle) end
132
+ }
133
+ Unit.prototype.issueOrder = function(self, orderType, orderId, xOrTarget, y)
134
+ return issueOrderByType[orderType](self.handle, orderId, xOrTarget, y)
135
+ end
136
+ return ____exports
@@ -0,0 +1,12 @@
1
+ /** @noSelfInFile */
2
+ import { Event } from "../../../event";
3
+ declare module "../unit" {
4
+ interface Unit {
5
+ readonly unitInRangeEvent: Record<number, Event<[unit: Unit, range: number, unitInRange: Unit]>>;
6
+ }
7
+ }
8
+ declare module "../unit" {
9
+ interface Unit {
10
+ readonly unitOutOfRangeEvent: Record<number, Event<[unit: Unit, range: number, unitOutOfRange: Unit]>>;
11
+ }
12
+ }
@@ -0,0 +1,90 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__New = ____lualib.__TS__New
3
+ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
4
+ local ____exports = {}
5
+ local ____event = require("event")
6
+ local Event = ____event.Event
7
+ local InitializingEvent = ____event.InitializingEvent
8
+ local TriggerEvent = ____event.TriggerEvent
9
+ local ____unit = require("engine.internal.unit")
10
+ local Unit = ____unit.Unit
11
+ local ____timer = require("core.types.timer")
12
+ local Timer = ____timer.Timer
13
+ local ____attributes = require("attributes")
14
+ local attribute = ____attributes.attribute
15
+ local ____linked_2Dmap = require("utility.linked-map")
16
+ local mutableLinkedMap = ____linked_2Dmap.mutableLinkedMap
17
+ local ____linked_2Dset = require("utility.linked-set")
18
+ local LinkedSet = ____linked_2Dset.LinkedSet
19
+ local mutableLinkedSet = ____linked_2Dset.mutableLinkedSet
20
+ local getTriggerUnit = GetTriggerUnit
21
+ local triggerRegisterUnitInRange = TriggerRegisterUnitInRange
22
+ local eventInvoke = Event.invoke
23
+ __TS__ObjectDefineProperty(
24
+ Unit.prototype,
25
+ "unitInRangeEvent",
26
+ {get = function(self)
27
+ local unit = self
28
+ local handle = self.handle
29
+ local unitInRangeEvent = setmetatable(
30
+ {},
31
+ {__index = function(self, value)
32
+ local event = __TS__New(
33
+ TriggerEvent,
34
+ function(trigger)
35
+ triggerRegisterUnitInRange(trigger, handle, value, nil)
36
+ end,
37
+ function() return unit, value, Unit:of(getTriggerUnit()) end
38
+ )
39
+ rawset(self, value, event)
40
+ return event
41
+ end}
42
+ )
43
+ rawset(self, "unitInRangeEvent", unitInRangeEvent)
44
+ return unitInRangeEvent
45
+ end}
46
+ )
47
+ local units = __TS__New(LinkedSet)
48
+ local unitsInRangeByRangeAttribute = attribute()
49
+ local function registerUnitOfRangeEvent(unit, range, unitInRange)
50
+ units:add(unit)
51
+ unit:getOrPut(unitsInRangeByRangeAttribute, mutableLinkedMap):getOrPut(range, mutableLinkedSet):add(unitInRange)
52
+ end
53
+ __TS__ObjectDefineProperty(
54
+ Unit.prototype,
55
+ "unitOutOfRangeEvent",
56
+ {get = function(self)
57
+ local unit = self
58
+ local unitOutOfRangeEvent = setmetatable(
59
+ {},
60
+ {__index = function(self, value)
61
+ local event = __TS__New(
62
+ InitializingEvent,
63
+ function()
64
+ unit.unitInRangeEvent[value]:addListener(999999, registerUnitOfRangeEvent)
65
+ end
66
+ )
67
+ rawset(self, value, event)
68
+ return event
69
+ end}
70
+ )
71
+ rawset(self, "unitOutOfRangeEvent", unitOutOfRangeEvent)
72
+ return unitOutOfRangeEvent
73
+ end}
74
+ )
75
+ Timer.onPeriod[1]:addListener(function()
76
+ for unit in pairs(units) do
77
+ local unitsInRangeByRange = unit[unitsInRangeByRangeAttribute]
78
+ if unitsInRangeByRange ~= nil then
79
+ for range, unitsInRange in pairs(unitsInRangeByRange) do
80
+ for unitInRange in pairs(unitsInRange) do
81
+ if unit:getDistanceTo(unitInRange) > range then
82
+ unitsInRange:remove(unitInRange)
83
+ eventInvoke(unit.unitOutOfRangeEvent[range], unit, range, unitInRange)
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end)
90
+ return ____exports
@@ -0,0 +1,7 @@
1
+ /** @noSelfInFile */
2
+ declare module "../unit" {
3
+ interface Unit {
4
+ scale: number;
5
+ }
6
+ }
7
+ export {};
@@ -0,0 +1,20 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
3
+ local ____exports = {}
4
+ local ____unit = require("engine.internal.unit")
5
+ local Unit = ____unit.Unit
6
+ local ____unit = require("engine.standard.fields.unit")
7
+ local SCALING_VALUE_UNIT_FIELD = ____unit.SCALING_VALUE_UNIT_FIELD
8
+ __TS__ObjectDefineProperty(
9
+ Unit.prototype,
10
+ "scale",
11
+ {
12
+ get = function(self)
13
+ return SCALING_VALUE_UNIT_FIELD:getValue(self)
14
+ end,
15
+ set = function(self, value)
16
+ SCALING_VALUE_UNIT_FIELD:setValue(self, value)
17
+ end
18
+ }
19
+ )
20
+ return ____exports