warscript 0.0.1-dev.ff5dbcd → 0.0.1-dev.fff719b

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 (170) hide show
  1. package/attributes.d.ts +6 -0
  2. package/attributes.lua +17 -1
  3. package/core/types/effect.d.ts +1 -3
  4. package/core/types/effect.lua +26 -29
  5. package/core/types/frame.lua +24 -21
  6. package/core/types/player.d.ts +16 -0
  7. package/core/types/player.lua +60 -15
  8. package/core/types/playerCamera.d.ts +2 -0
  9. package/core/types/playerCamera.lua +123 -5
  10. package/core/types/sound.d.ts +17 -25
  11. package/core/types/sound.lua +85 -44
  12. package/core/types/tileCell.d.ts +11 -1
  13. package/core/types/tileCell.lua +97 -0
  14. package/core/types/timer.d.ts +9 -8
  15. package/core/types/timer.lua +45 -23
  16. package/decl/native.d.ts +846 -790
  17. package/destroyable.d.ts +1 -0
  18. package/destroyable.lua +9 -0
  19. package/engine/behavior.d.ts +14 -1
  20. package/engine/behavior.lua +230 -70
  21. package/engine/behaviour/ability/apply-buff.lua +5 -5
  22. package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
  23. package/engine/behaviour/ability/damage.d.ts +9 -3
  24. package/engine/behaviour/ability/damage.lua +26 -38
  25. package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
  26. package/engine/behaviour/ability/emulate-impact.lua +18 -3
  27. package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
  28. package/engine/behaviour/ability/remove-buffs.lua +21 -0
  29. package/engine/behaviour/ability/restore-mana.d.ts +1 -1
  30. package/engine/behaviour/ability/restore-mana.lua +6 -6
  31. package/engine/behaviour/ability.d.ts +7 -2
  32. package/engine/behaviour/ability.lua +28 -22
  33. package/engine/behaviour/unit/stun-immunity.d.ts +12 -6
  34. package/engine/behaviour/unit/stun-immunity.lua +57 -31
  35. package/engine/behaviour/unit.d.ts +40 -2
  36. package/engine/behaviour/unit.lua +269 -6
  37. package/engine/buff.d.ts +32 -14
  38. package/engine/buff.lua +249 -152
  39. package/engine/internal/ability.d.ts +7 -1
  40. package/engine/internal/ability.lua +49 -9
  41. package/engine/internal/item/ability.lua +63 -11
  42. package/engine/internal/item+owner.lua +12 -6
  43. package/engine/internal/item.d.ts +18 -17
  44. package/engine/internal/item.lua +135 -49
  45. package/engine/internal/mechanics/ability-duration.lua +1 -1
  46. package/engine/internal/mechanics/cast-ability.lua +6 -3
  47. package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
  48. package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
  49. package/engine/internal/misc/frame-coordinates.d.ts +2 -0
  50. package/engine/internal/misc/frame-coordinates.lua +21 -0
  51. package/engine/internal/misc/get-terrain-z.d.ts +2 -0
  52. package/engine/internal/misc/get-terrain-z.lua +11 -0
  53. package/engine/internal/misc/player-local-handle.d.ts +2 -0
  54. package/engine/internal/misc/player-local-handle.lua +5 -0
  55. package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
  56. package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
  57. package/engine/internal/unit/ability.d.ts +35 -0
  58. package/engine/internal/unit/ability.lua +98 -9
  59. package/engine/internal/unit/allowed-targets.d.ts +1 -1
  60. package/engine/internal/unit/allowed-targets.lua +9 -1
  61. package/engine/internal/unit/attributes.d.ts +17 -0
  62. package/engine/internal/unit/attributes.lua +46 -0
  63. package/engine/internal/unit/bonus.d.ts +2 -0
  64. package/engine/internal/unit/bonus.lua +10 -0
  65. package/engine/internal/unit/fly-height.d.ts +7 -0
  66. package/engine/internal/unit/fly-height.lua +20 -0
  67. package/engine/internal/unit/interrupts.d.ts +12 -0
  68. package/engine/internal/unit/interrupts.lua +28 -0
  69. package/engine/internal/unit/main-selected.lua +12 -27
  70. package/engine/internal/unit/order.d.ts +20 -0
  71. package/engine/internal/unit/order.lua +136 -0
  72. package/engine/internal/unit/scale.d.ts +7 -0
  73. package/engine/internal/unit/scale.lua +20 -0
  74. package/engine/internal/unit+ability.lua +10 -1
  75. package/engine/internal/unit+damage.d.ts +2 -11
  76. package/engine/internal/unit+damage.lua +10 -14
  77. package/engine/internal/unit+spellSteal.lua +1 -2
  78. package/engine/internal/unit-missile-launch.lua +52 -14
  79. package/engine/internal/unit.d.ts +42 -24
  80. package/engine/internal/unit.lua +377 -232
  81. package/engine/local-client.d.ts +2 -0
  82. package/engine/local-client.lua +30 -0
  83. package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
  84. package/engine/object-data/auxiliary/armor-type.lua +46 -0
  85. package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
  86. package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
  87. package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
  88. package/engine/object-data/auxiliary/attack-type.lua +42 -0
  89. package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
  90. package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
  91. package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
  92. package/engine/object-data/auxiliary/movement-type.lua +22 -0
  93. package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
  94. package/engine/object-data/auxiliary/sound-eax.lua +2 -0
  95. package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
  96. package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
  97. package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
  98. package/engine/object-data/entry/ability-type/berserk.lua +13 -0
  99. package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
  100. package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
  101. package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
  102. package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
  103. package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
  104. package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
  105. package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
  106. package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
  107. package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
  108. package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
  109. package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
  110. package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
  111. package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
  112. package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
  113. package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
  114. package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
  115. package/engine/object-data/entry/ability-type/web.d.ts +12 -0
  116. package/engine/object-data/entry/ability-type/web.lua +52 -0
  117. package/engine/object-data/entry/ability-type.d.ts +11 -11
  118. package/engine/object-data/entry/ability-type.lua +35 -13
  119. package/engine/object-data/entry/buff-type/applicable.lua +5 -0
  120. package/engine/object-data/entry/buff-type.d.ts +5 -11
  121. package/engine/object-data/entry/buff-type.lua +11 -27
  122. package/engine/object-data/entry/destructible-type.d.ts +27 -1
  123. package/engine/object-data/entry/destructible-type.lua +155 -0
  124. package/engine/object-data/entry/sound-preset.d.ts +17 -0
  125. package/engine/object-data/entry/sound-preset.lua +104 -0
  126. package/engine/object-data/entry/unit-type.d.ts +17 -4
  127. package/engine/object-data/entry/unit-type.lua +197 -85
  128. package/engine/object-field/ability.d.ts +4 -4
  129. package/engine/object-field/ability.lua +7 -6
  130. package/engine/object-field/unit.d.ts +72 -3
  131. package/engine/object-field/unit.lua +268 -7
  132. package/engine/object-field.d.ts +25 -6
  133. package/engine/object-field.lua +357 -118
  134. package/engine/random.d.ts +9 -0
  135. package/engine/random.lua +13 -0
  136. package/engine/standard/entries/buff-type.d.ts +3 -0
  137. package/engine/standard/entries/buff-type.lua +3 -0
  138. package/engine/standard/fields/ability.d.ts +2 -2
  139. package/engine/standard/fields/ability.lua +2 -2
  140. package/engine/standard/fields/unit.d.ts +12 -0
  141. package/engine/standard/fields/unit.lua +20 -0
  142. package/engine/synchronization.d.ts +11 -0
  143. package/engine/synchronization.lua +77 -0
  144. package/engine/text-tag.d.ts +36 -2
  145. package/engine/text-tag.lua +250 -10
  146. package/engine/unit.d.ts +5 -0
  147. package/engine/unit.lua +5 -0
  148. package/net/socket.lua +1 -1
  149. package/objutil/buff.lua +11 -10
  150. package/package.json +2 -2
  151. package/patch-lua.lua +9 -0
  152. package/patch-lualib.lua +1 -1
  153. package/utility/arrays.d.ts +2 -0
  154. package/utility/arrays.lua +11 -0
  155. package/utility/callback-array.d.ts +17 -0
  156. package/utility/callback-array.lua +61 -0
  157. package/utility/functions.d.ts +8 -0
  158. package/utility/functions.lua +13 -0
  159. package/utility/linked-map.d.ts +26 -0
  160. package/utility/linked-map.lua +66 -0
  161. package/utility/linked-set.d.ts +2 -0
  162. package/utility/linked-set.lua +26 -1
  163. package/utility/lua-maps.d.ts +15 -2
  164. package/utility/lua-maps.lua +53 -2
  165. package/utility/lua-sets.d.ts +2 -0
  166. package/utility/lua-sets.lua +7 -0
  167. package/utility/records.lua +20 -1
  168. package/utility/types.d.ts +3 -0
  169. package/core/types/order.d.ts +0 -25
  170. package/core/types/order.lua +0 -55
@@ -0,0 +1,46 @@
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 AGILITY_UNIT_FIELD = ____unit.AGILITY_UNIT_FIELD
8
+ local INTELLIGENCE_UNIT_FIELD = ____unit.INTELLIGENCE_UNIT_FIELD
9
+ local STRENGTH_UNIT_FIELD = ____unit.STRENGTH_UNIT_FIELD
10
+ __TS__ObjectDefineProperty(
11
+ Unit.prototype,
12
+ "strengthBase",
13
+ {
14
+ get = function(self)
15
+ return STRENGTH_UNIT_FIELD:getValue(self)
16
+ end,
17
+ set = function(self, value)
18
+ STRENGTH_UNIT_FIELD:setValue(self, value)
19
+ end
20
+ }
21
+ )
22
+ __TS__ObjectDefineProperty(
23
+ Unit.prototype,
24
+ "agilityBase",
25
+ {
26
+ get = function(self)
27
+ return AGILITY_UNIT_FIELD:getValue(self)
28
+ end,
29
+ set = function(self, value)
30
+ AGILITY_UNIT_FIELD:setValue(self, value)
31
+ end
32
+ }
33
+ )
34
+ __TS__ObjectDefineProperty(
35
+ Unit.prototype,
36
+ "intelligenceBase",
37
+ {
38
+ get = function(self)
39
+ return INTELLIGENCE_UNIT_FIELD:getValue(self)
40
+ end,
41
+ set = function(self, value)
42
+ INTELLIGENCE_UNIT_FIELD:setValue(self, value)
43
+ end
44
+ }
45
+ )
46
+ return ____exports
@@ -12,6 +12,7 @@ export type UnitAutoAttackDamageBonusId = UnitBonusId<"autoAttackDamage">;
12
12
  export type UnitDamageFactorBonusId = UnitBonusId<"damageFactor">;
13
13
  export type UnitReceivedDamageFactorBonusId = UnitBonusId<"receivedDamageFactor">;
14
14
  export type UnitEvasionProbabilityBonusId = UnitBonusId<"evasionProbability">;
15
+ export type UnitManaRegenerationRateFactorBonusId = UnitBonusId<"manaRegenerationRateFactor">;
15
16
  export type UnitBonusType<Id extends UnitBonusId = UnitBonusId> = ({
16
17
  abilityTypeId: AbilityTypeId;
17
18
  field: jabilityintegerlevelfield;
@@ -36,6 +37,7 @@ export declare namespace UnitBonusType {
36
37
  const DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
37
38
  const RECEIVED_DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
38
39
  const EVASION_PROBABILITY: UnitBonusType<UnitEvasionProbabilityBonusId>;
40
+ const MANA_REGENERATION_RATE_FACTOR: UnitBonusType<UnitManaRegenerationRateFactorBonusId>;
39
41
  }
40
42
  export declare const addUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, value: number) => Id;
41
43
  export declare const removeUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id) => boolean;
@@ -24,6 +24,9 @@ local MOVEMENT_SPEED_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID = ____movement_2Dspee
24
24
  local ____evasion_2Dprobability = require("engine.internal.object-data.evasion-probability")
25
25
  local EVASION_PROBABILITY_ABILITY_FIELD = ____evasion_2Dprobability.EVASION_PROBABILITY_ABILITY_FIELD
26
26
  local EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID = ____evasion_2Dprobability.EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID
27
+ local ____mana_2Dregeneration_2Drate_2Dincrease_2Dfactor = require("engine.internal.object-data.mana-regeneration-rate-increase-factor")
28
+ local MANA_REGENERATION_RATE_INCREASE_FACTOR_ABILITY_FIELD = ____mana_2Dregeneration_2Drate_2Dincrease_2Dfactor.MANA_REGENERATION_RATE_INCREASE_FACTOR_ABILITY_FIELD
29
+ local MANA_REGENERATION_RATE_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID = ____mana_2Dregeneration_2Drate_2Dincrease_2Dfactor.MANA_REGENERATION_RATE_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID
27
30
  local damageFactorByUnit = {}
28
31
  local receivedDamageFactorByUnit = {}
29
32
  local function atLeastOnceProbability(array)
@@ -73,6 +76,13 @@ do
73
76
  reduce = atLeastOnceProbability,
74
77
  initialValue = 0
75
78
  }
79
+ UnitBonusType.MANA_REGENERATION_RATE_FACTOR = {
80
+ abilityTypeId = MANA_REGENERATION_RATE_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID,
81
+ field = MANA_REGENERATION_RATE_INCREASE_FACTOR_ABILITY_FIELD,
82
+ integer = false,
83
+ reduce = sum,
84
+ initialValue = 0
85
+ }
76
86
  end
77
87
  local bonusesByUnitByBonusType = {}
78
88
  local nextId = 1
@@ -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,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
@@ -1,46 +1,31 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__New = ____lualib.__TS__New
3
3
  local ____exports = {}
4
- local ____player = require("core.types.player")
5
- local Player = ____player.Player
6
- local ____math = require("math")
7
- local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
8
- local MINIMUM_INTEGER = ____math.MINIMUM_INTEGER
9
4
  local ____local_2Dclient = require("engine.local-client")
10
5
  local LocalClient = ____local_2Dclient.LocalClient
11
6
  local ____unit = require("engine.internal.unit")
12
7
  local Unit = ____unit.Unit
13
8
  local ____event = require("event")
14
9
  local Event = ____event.Event
10
+ local ____synchronization = require("engine.synchronization")
11
+ local ObjectBus = ____synchronization.ObjectBus
15
12
  local mainSelectedUnitChangeEvent = __TS__New(Event)
16
13
  rawset(Unit, "mainSelectedUnitChangeEvent", mainSelectedUnitChangeEvent)
17
14
  local mainSelectedUnitByPlayer = {}
18
- local syncSlider = BlzCreateFrameByType(
19
- "SLIDER",
20
- "UnitSyncId",
21
- BlzGetOriginFrame(ORIGIN_FRAME_WORLD_FRAME, 0),
22
- "",
23
- 0
15
+ local unitBus = __TS__New(
16
+ ObjectBus,
17
+ function(unit) return unit.syncId end,
18
+ function(syncId) return Unit:getBySyncId(syncId) end
24
19
  )
25
- BlzFrameSetMinMaxValue(syncSlider, MINIMUM_INTEGER, MAXIMUM_INTEGER)
26
20
  LocalClient.mainSelectedUnitChangeEvent:addListener(function()
27
- local ____opt_0 = LocalClient.mainSelectedUnit
28
- local syncId = ____opt_0 and ____opt_0.syncId
29
- BlzFrameSetValue(syncSlider, syncId or 0)
21
+ unitBus:send(LocalClient.mainSelectedUnit)
30
22
  end)
31
- local trg = CreateTrigger()
32
- BlzTriggerRegisterFrameEvent(trg, syncSlider, FRAMEEVENT_SLIDER_VALUE_CHANGED)
33
- TriggerAddAction(
34
- trg,
35
- function()
36
- local player = Player:of(GetTriggerPlayer())
37
- local mainSelectedUnit = Unit:getBySyncId(BlzGetTriggerFrameValue())
38
- if mainSelectedUnit ~= mainSelectedUnitByPlayer[player] then
39
- mainSelectedUnitByPlayer[player] = mainSelectedUnit
40
- Event.invoke(mainSelectedUnitChangeEvent, player)
41
- end
23
+ unitBus.event:addListener(function(player, unit)
24
+ if unit ~= mainSelectedUnitByPlayer[player] then
25
+ mainSelectedUnitByPlayer[player] = unit
26
+ Event.invoke(mainSelectedUnitChangeEvent, player)
42
27
  end
43
- )
28
+ end)
44
29
  rawset(
45
30
  Unit,
46
31
  "getMainSelectedOf",
@@ -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,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
@@ -7,8 +7,8 @@ local UnitAbility = ____ability.UnitAbility
7
7
  local ____unit = require("engine.internal.unit")
8
8
  local Unit = ____unit.Unit
9
9
  local ____event = require("event")
10
- local Event = ____event.Event
11
10
  local createDispatchingEvent = ____event.createDispatchingEvent
11
+ local Event = ____event.Event
12
12
  local abilityGainedEvent = createDispatchingEvent(
13
13
  __TS__New(Event),
14
14
  function(unit, ability) return ability.typeId end
@@ -40,6 +40,15 @@ ItemAbility.onCreate:addListener(
40
40
  end
41
41
  end
42
42
  )
43
+ ItemAbility.destroyEvent:addListener(
44
+ 4,
45
+ function(ability)
46
+ local unit = ability.owner.owner
47
+ if unit ~= nil then
48
+ Event.invoke(abilityLostEvent, unit, ability)
49
+ end
50
+ end
51
+ )
43
52
  Unit.itemPickedUpEvent:addListener(
44
53
  0,
45
54
  function(unit, item)
@@ -1,15 +1,6 @@
1
1
  /** @noSelfInFile */
2
2
  import { Widget } from "../../core/types/widget";
3
- export type AttackType = jattacktype;
4
- export declare namespace AttackType {
5
- const SPELL: jattacktype;
6
- const NORMAL: jattacktype;
7
- const PIERCE: jattacktype;
8
- const SIEGE: jattacktype;
9
- const MAGIC: jattacktype;
10
- const CHAOS: jattacktype;
11
- const HERO: jattacktype;
12
- }
3
+ import { AttackType } from "../object-data/auxiliary/attack-type";
13
4
  export type DamageType = jdamagetype;
14
5
  export declare namespace DamageType {
15
6
  const UNKNOWN: jdamagetype;
@@ -64,6 +55,6 @@ export declare namespace WeaponType {
64
55
  }
65
56
  declare module "./unit" {
66
57
  interface Unit {
67
- damageTarget(target: Widget, amount: number, attack?: boolean, ranged?: boolean, attackType?: AttackType, damageType?: DamageType, weaponType?: WeaponType): boolean;
58
+ damageTarget(target: Widget, amount: number, attack?: boolean, ranged?: boolean, attackType?: AttackType, damageType?: DamageType, weaponType?: WeaponType, metadata?: unknown): boolean;
68
59
  }
69
60
  }
@@ -7,21 +7,14 @@ local ____player = require("core.types.player")
7
7
  local Player = ____player.Player
8
8
  local ____dummy = require("objutil.dummy")
9
9
  local dummyUnitId = ____dummy.dummyUnitId
10
+ local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
11
+ local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
12
+ local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
13
+ local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
10
14
  local createUnit = CreateUnit
11
15
  local getOwningPlayer = GetOwningPlayer
12
16
  local showUnit = ShowUnit
13
17
  local unitDamageTarget = UnitDamageTarget
14
- ____exports.AttackType = {}
15
- local AttackType = ____exports.AttackType
16
- do
17
- AttackType.SPELL = ATTACK_TYPE_NORMAL
18
- AttackType.NORMAL = ATTACK_TYPE_MELEE
19
- AttackType.PIERCE = ATTACK_TYPE_PIERCE
20
- AttackType.SIEGE = ATTACK_TYPE_SIEGE
21
- AttackType.MAGIC = ATTACK_TYPE_MAGIC
22
- AttackType.CHAOS = ATTACK_TYPE_CHAOS
23
- AttackType.HERO = ATTACK_TYPE_HERO
24
- end
25
18
  ____exports.DamageType = {}
26
19
  local DamageType = ____exports.DamageType
27
20
  do
@@ -88,7 +81,7 @@ for ____, player in ipairs(Player.all) do
88
81
  showUnit(dummy, false)
89
82
  dummies[player] = dummy
90
83
  end
91
- Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, attackType, damageType, weaponType)
84
+ Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, attackType, damageType, weaponType, metadata)
92
85
  if attack == nil then
93
86
  attack = false
94
87
  end
@@ -96,7 +89,7 @@ Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, att
96
89
  ranged = false
97
90
  end
98
91
  if attackType == nil then
99
- attackType = ____exports.AttackType.SPELL
92
+ attackType = 0
100
93
  end
101
94
  if damageType == nil then
102
95
  damageType = ____exports.DamageType.MAGIC
@@ -109,13 +102,16 @@ Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, att
109
102
  if not getOwningPlayer(handle) then
110
103
  handle = dummies[__TS__InstanceOf(target, Unit) and target.owner or (self._owner or Player.neutralAggressive)]
111
104
  end
105
+ if __TS__InstanceOf(target, Unit) then
106
+ damageMetadataByTarget[target] = metadata
107
+ end
112
108
  return unitDamageTarget(
113
109
  handle,
114
110
  targetHandle,
115
111
  amount,
116
112
  attack,
117
113
  ranged,
118
- attackType,
114
+ attackTypeToNative(attackType),
119
115
  damageType,
120
116
  weaponType
121
117
  )
@@ -6,7 +6,6 @@ local ____exports = {}
6
6
  local ____unit = require("engine.internal.unit")
7
7
  local Unit = ____unit.Unit
8
8
  local ____unit_2Bdamage = require("engine.internal.unit+damage")
9
- local AttackType = ____unit_2Bdamage.AttackType
10
9
  local DamageType = ____unit_2Bdamage.DamageType
11
10
  local ____event = require("event")
12
11
  local Event = ____event.Event
@@ -33,7 +32,7 @@ local spellStealEventStack = {}
33
32
  Unit.onDamaging:addListener(function(source, target, event)
34
33
  if event.amount == 0 and source ~= nil then
35
34
  local count = countByUnit[source] or 0
36
- if count > 0 and event.attackType == AttackType.SPELL then
35
+ if count > 0 and event.attackType == 0 then
37
36
  if event.damageType == DamageType.UNKNOWN then
38
37
  spellStealEventStack[#spellStealEventStack + 1] = {
39
38
  sourceBuffIds = source.buffIds,
@@ -9,9 +9,18 @@ local ____timer = require("core.types.timer")
9
9
  local Timer = ____timer.Timer
10
10
  local ____lua_2Dsets = require("utility.lua-sets")
11
11
  local luaSetOf = ____lua_2Dsets.luaSetOf
12
+ local ____attributes = require("attributes")
13
+ local attribute = ____attributes.attribute
14
+ local ____linked_2Dset = require("utility.linked-set")
15
+ local LinkedSet = ____linked_2Dset.LinkedSet
16
+ local ____math = require("math")
17
+ local ceil = ____math.ceil
12
18
  local autoAttackFinishEvent = __TS__New(Event)
13
19
  rawset(Unit, "autoAttackFinishEvent", autoAttackFinishEvent)
14
- local eventTimerByUnit = {}
20
+ local units = __TS__New(LinkedSet)
21
+ local targetAttribute = attribute()
22
+ local impactDelayAttribute = attribute()
23
+ local passedTimeAttribute = attribute()
15
24
  local instantOrderIds = luaSetOf(
16
25
  orderId("avatar"),
17
26
  orderId("berserk"),
@@ -27,25 +36,54 @@ local instantOrderIds = luaSetOf(
27
36
  orderId("undivineshield"),
28
37
  orderId("unimmolation")
29
38
  )
30
- local function reset(source, orderId)
39
+ ---
40
+ -- @internal For use by internal systems only.
41
+ ____exports.resetAutoAttackTimer = function(unit)
42
+ if units:remove(unit) then
43
+ unit[targetAttribute] = nil
44
+ unit[impactDelayAttribute] = nil
45
+ unit[passedTimeAttribute] = nil
46
+ end
47
+ end
48
+ local function reset(unit, orderId)
31
49
  if not (instantOrderIds[orderId] ~= nil) then
32
- local eventTimer = eventTimerByUnit[source]
33
- if eventTimer then
34
- eventTimer:destroy()
35
- eventTimerByUnit[source] = nil
36
- end
50
+ ____exports.resetAutoAttackTimer(unit)
37
51
  end
38
52
  end
39
53
  Unit.onImmediateOrder:addListener(reset)
40
54
  Unit.onPointOrder:addListener(reset)
41
55
  Unit.onTargetOrder:addListener(reset)
42
- local function timerCallback(source, target)
43
- eventTimerByUnit[source] = nil
44
- Event.invoke(autoAttackFinishEvent, source, target)
56
+ local timerPeriod = 1 / 64
57
+ local function invokeEvent(unit)
58
+ units:remove(unit)
59
+ local target = unit[targetAttribute]
60
+ unit[targetAttribute] = nil
61
+ unit[impactDelayAttribute] = nil
62
+ unit[passedTimeAttribute] = nil
63
+ Event.invoke(autoAttackFinishEvent, unit, target)
64
+ end
65
+ local function checkUnit(unit)
66
+ local passedTime = unit[passedTimeAttribute] + timerPeriod
67
+ local impactDelay = unit[impactDelayAttribute]
68
+ if passedTime >= impactDelay and ceil(passedTime / 0.02) >= ceil(impactDelay / 0.02) then
69
+ invokeEvent(unit)
70
+ else
71
+ unit[passedTimeAttribute] = passedTime
72
+ end
45
73
  end
46
- Unit.autoAttackStartEvent:addListener(function(source, target)
47
- local attackPoint = source.weapons[1].impactDelay
48
- local timer = Timer:simple(attackPoint, timerCallback, source, target)
49
- eventTimerByUnit[source] = timer
74
+ Timer.onPeriod[timerPeriod]:addListener(function()
75
+ units:forEach(checkUnit)
50
76
  end)
77
+ Unit.autoAttackStartEvent:addListener(
78
+ 999999,
79
+ function(source, target)
80
+ if source[targetAttribute] ~= nil then
81
+ invokeEvent(source)
82
+ end
83
+ source[targetAttribute] = target
84
+ source[impactDelayAttribute] = (source:chooseWeapon(target) or source.firstWeapon).impactDelay
85
+ source[passedTimeAttribute] = -timerPeriod
86
+ units:add(source)
87
+ end
88
+ )
51
89
  return ____exports