warscript 0.0.1-dev.e196516 → 0.0.1-dev.e3899e3

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 (110) hide show
  1. package/attributes.d.ts +1 -0
  2. package/attributes.lua +9 -0
  3. package/core/types/frame.lua +24 -21
  4. package/core/types/player.d.ts +16 -0
  5. package/core/types/player.lua +60 -15
  6. package/core/types/playerCamera.d.ts +2 -0
  7. package/core/types/playerCamera.lua +123 -5
  8. package/core/types/tileCell.d.ts +11 -1
  9. package/core/types/tileCell.lua +97 -0
  10. package/core/types/timer.d.ts +3 -1
  11. package/core/types/timer.lua +27 -2
  12. package/decl/native.d.ts +6 -4
  13. package/destroyable.d.ts +1 -0
  14. package/destroyable.lua +9 -0
  15. package/engine/behavior.d.ts +14 -1
  16. package/engine/behavior.lua +230 -70
  17. package/engine/behaviour/ability/apply-buff.lua +5 -5
  18. package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
  19. package/engine/behaviour/ability/emulate-impact.lua +2 -1
  20. package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
  21. package/engine/behaviour/ability/remove-buffs.lua +21 -0
  22. package/engine/behaviour/ability/restore-mana.d.ts +1 -1
  23. package/engine/behaviour/ability/restore-mana.lua +6 -6
  24. package/engine/behaviour/ability.d.ts +2 -1
  25. package/engine/behaviour/ability.lua +9 -17
  26. package/engine/behaviour/unit/stun-immunity.d.ts +11 -5
  27. package/engine/behaviour/unit/stun-immunity.lua +53 -28
  28. package/engine/behaviour/unit.d.ts +26 -5
  29. package/engine/behaviour/unit.lua +170 -27
  30. package/engine/buff.d.ts +17 -6
  31. package/engine/buff.lua +160 -97
  32. package/engine/internal/ability.d.ts +3 -1
  33. package/engine/internal/ability.lua +34 -11
  34. package/engine/internal/item/ability.lua +51 -1
  35. package/engine/internal/item+owner.lua +12 -6
  36. package/engine/internal/item.d.ts +13 -15
  37. package/engine/internal/item.lua +63 -49
  38. package/engine/internal/misc/frame-coordinates.d.ts +2 -0
  39. package/engine/internal/misc/frame-coordinates.lua +21 -0
  40. package/engine/internal/misc/get-terrain-z.d.ts +2 -0
  41. package/engine/internal/misc/get-terrain-z.lua +11 -0
  42. package/engine/internal/misc/player-local-handle.d.ts +2 -0
  43. package/engine/internal/misc/player-local-handle.lua +5 -0
  44. package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
  45. package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
  46. package/engine/internal/unit/ability.d.ts +35 -5
  47. package/engine/internal/unit/ability.lua +96 -21
  48. package/engine/internal/unit/bonus.d.ts +2 -0
  49. package/engine/internal/unit/bonus.lua +10 -0
  50. package/engine/internal/unit/fly-height.d.ts +7 -0
  51. package/engine/internal/unit/fly-height.lua +20 -0
  52. package/engine/internal/unit/main-selected.lua +12 -27
  53. package/engine/internal/unit/order.d.ts +20 -0
  54. package/engine/internal/unit/order.lua +136 -0
  55. package/engine/internal/unit/scale.d.ts +7 -0
  56. package/engine/internal/unit/scale.lua +20 -0
  57. package/engine/internal/unit+ability.lua +10 -1
  58. package/engine/internal/unit-missile-launch.lua +45 -14
  59. package/engine/internal/unit.d.ts +19 -16
  60. package/engine/internal/unit.lua +170 -136
  61. package/engine/local-client.d.ts +2 -0
  62. package/engine/local-client.lua +30 -0
  63. package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
  64. package/engine/object-data/auxiliary/armor-type.lua +46 -0
  65. package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
  66. package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
  67. package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
  68. package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
  69. package/engine/object-data/entry/ability-type.lua +5 -4
  70. package/engine/object-data/entry/destructible-type.d.ts +27 -1
  71. package/engine/object-data/entry/destructible-type.lua +155 -0
  72. package/engine/object-data/entry/unit-type.d.ts +15 -2
  73. package/engine/object-data/entry/unit-type.lua +135 -33
  74. package/engine/object-field/ability.d.ts +3 -3
  75. package/engine/object-field/ability.lua +7 -6
  76. package/engine/object-field/unit.d.ts +31 -5
  77. package/engine/object-field/unit.lua +95 -0
  78. package/engine/object-field.d.ts +9 -3
  79. package/engine/object-field.lua +242 -119
  80. package/engine/random.d.ts +9 -0
  81. package/engine/random.lua +13 -0
  82. package/engine/standard/fields/ability.d.ts +2 -2
  83. package/engine/standard/fields/ability.lua +2 -2
  84. package/engine/standard/fields/unit.d.ts +7 -0
  85. package/engine/standard/fields/unit.lua +13 -0
  86. package/engine/synchronization.d.ts +11 -0
  87. package/engine/synchronization.lua +77 -0
  88. package/engine/text-tag.d.ts +26 -3
  89. package/engine/text-tag.lua +217 -11
  90. package/engine/unit.d.ts +3 -0
  91. package/engine/unit.lua +3 -0
  92. package/net/socket.lua +1 -1
  93. package/objutil/buff.lua +1 -1
  94. package/package.json +2 -2
  95. package/patch-lualib.lua +1 -1
  96. package/utility/arrays.d.ts +1 -0
  97. package/utility/arrays.lua +8 -0
  98. package/utility/callback-array.d.ts +17 -0
  99. package/utility/callback-array.lua +61 -0
  100. package/utility/functions.d.ts +7 -0
  101. package/utility/functions.lua +12 -0
  102. package/utility/linked-set.d.ts +1 -0
  103. package/utility/linked-set.lua +19 -1
  104. package/utility/lua-maps.d.ts +11 -2
  105. package/utility/lua-maps.lua +33 -2
  106. package/utility/lua-sets.d.ts +1 -0
  107. package/utility/lua-sets.lua +4 -0
  108. package/utility/types.d.ts +3 -0
  109. package/core/types/order.d.ts +0 -26
  110. package/core/types/order.lua +0 -65
@@ -20,6 +20,7 @@ local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slo
20
20
  local unitAddItemToSlot = ____add_2Ditem_2Dto_2Dslot.unitAddItemToSlot
21
21
  local isItemOwned = IsItemOwned
22
22
  local isItemPowerup = IsItemPowerup
23
+ local getItemAbility = BlzGetItemAbility
23
24
  local getItemX = GetItemX
24
25
  local getItemY = GetItemY
25
26
  local setAbilityRealLevelField = BlzSetAbilityRealLevelField
@@ -31,6 +32,8 @@ local unitAddItem = UnitAddItem
31
32
  local unitRemoveItem = UnitRemoveItem
32
33
  local unitUseItem = UnitUseItem
33
34
  local unitResetCooldown = UnitResetCooldown
35
+ local unitInventorySize = UnitInventorySize
36
+ local unitItemInSlot = UnitItemInSlot
34
37
  local COOLDOWN_STARTER_ABILITY_TYPE_ID = compiletime(function()
35
38
  if not currentMap then
36
39
  return 0
@@ -65,7 +68,7 @@ ____exports.itemAbilityDummy = assert(CreateUnit(
65
68
  270
66
69
  ))
67
70
  local cooldownStarterItem = UnitAddItemById(____exports.itemAbilityDummy, COOLDOWN_STARTER_ITEM_TYPE_ID)
68
- local cooldownStarterAbility = BlzGetItemAbility(cooldownStarterItem, COOLDOWN_STARTER_ABILITY_TYPE_ID)
71
+ local cooldownStarterAbility = getItemAbility(cooldownStarterItem, COOLDOWN_STARTER_ABILITY_TYPE_ID)
69
72
  ShowUnit(____exports.itemAbilityDummy, false)
70
73
  local function startItemCooldownInternal(handle, cooldown)
71
74
  local cooldownGroup = getItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP)
@@ -153,4 +156,51 @@ ____exports.doAbilityActionForceDummy = function(handle, owner, action, ...)
153
156
  end
154
157
  return result
155
158
  end
159
+ local depth = 0
160
+ local itemBySlot = {}
161
+ ---
162
+ -- @internal For use by internal systems only.
163
+ ____exports.doUnitAbilityAction = function(unit, abilityTypeId, action, ...)
164
+ local ____depth_0 = depth
165
+ depth = ____depth_0 + 1
166
+ local offset = 6 * ____depth_0
167
+ for slot = 0, unitInventorySize(unit) - 1 do
168
+ local item = unitItemInSlot(unit, slot)
169
+ if getItemAbility(item, abilityTypeId) ~= nil then
170
+ local isAlreadyIgnoredInEvents = ignoreEventsItems[item] ~= nil
171
+ if not isAlreadyIgnoredInEvents then
172
+ ignoreEventsItems[item] = true
173
+ end
174
+ unitRemoveItem(unit, item)
175
+ if not isAlreadyIgnoredInEvents then
176
+ ignoreEventsItems[item] = nil
177
+ end
178
+ itemBySlot[offset + slot] = item
179
+ end
180
+ end
181
+ local result = action(unit, ...)
182
+ for slot = 0, unitInventorySize(unit) - 1 do
183
+ local item = itemBySlot[offset + slot]
184
+ if item ~= nil then
185
+ local isAlreadyIgnoredInEvents = ignoreEventsItems[item] ~= nil
186
+ if not isAlreadyIgnoredInEvents then
187
+ ignoreEventsItems[item] = true
188
+ end
189
+ local isPowerup = isItemPowerup(item)
190
+ if isPowerup then
191
+ setItemBooleanField(item, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
192
+ end
193
+ unitAddItemToSlot(unit, item, slot)
194
+ if isPowerup then
195
+ setItemBooleanField(item, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
196
+ end
197
+ if not isAlreadyIgnoredInEvents then
198
+ ignoreEventsItems[item] = nil
199
+ end
200
+ itemBySlot[offset + slot] = nil
201
+ end
202
+ end
203
+ depth = depth - 1
204
+ return result
205
+ end
156
206
  return ____exports
@@ -6,12 +6,18 @@ local Item = ____item.Item
6
6
  local ____unit = require("engine.internal.unit")
7
7
  local Unit = ____unit.Unit
8
8
  local ownerByItem = setmetatable({}, {__mode = "kv"})
9
- Unit.itemPickedUpEvent:addListener(function(unit, item)
10
- ownerByItem[item] = unit
11
- end)
12
- Unit.itemDroppedEvent:addListener(function(unit, item)
13
- ownerByItem[item] = nil
14
- end)
9
+ Unit.itemPickedUpEvent:addListener(
10
+ 4,
11
+ function(unit, item)
12
+ ownerByItem[item] = unit
13
+ end
14
+ )
15
+ Unit.itemDroppedEvent:addListener(
16
+ 4,
17
+ function(unit, item)
18
+ ownerByItem[item] = nil
19
+ end
20
+ )
15
21
  __TS__ObjectDefineProperty(
16
22
  Item.prototype,
17
23
  "owner",
@@ -8,12 +8,10 @@ import { AbilityTypeId } from "../object-data/entry/ability-type";
8
8
  import type { ItemTypeId } from "../object-data/entry/item-type";
9
9
  type DefenseType = 0 | 1 | 2 | 3 | 4 | 5;
10
10
  declare const enum ItemPropertyKey {
11
- ABILITIES = 100,
12
- LUA_INDEX_BY_ABILITY_TYPE_ID = 101
11
+ ABILITIES = 100
13
12
  }
14
13
  export declare class Item extends Handle<jitem> {
15
14
  private readonly [ItemPropertyKey.ABILITIES];
16
- private readonly [ItemPropertyKey.LUA_INDEX_BY_ABILITY_TYPE_ID];
17
15
  constructor(handle: jitem);
18
16
  protected onDestroy(): HandleDestructor;
19
17
  static create<T extends Item>(this: typeof Item & (new (handle: jitem) => T), id: number, x: number, y: number, skinId?: number): T;
@@ -30,22 +28,22 @@ export declare class Item extends Handle<jitem> {
30
28
  get extendedTooltip(): string;
31
29
  set iconPath(v: string);
32
30
  get iconPath(): string;
33
- set dropOnDeath(v: boolean);
34
- get dropOnDeath(): boolean;
35
- set droppable(v: boolean);
36
- get droppable(): boolean;
37
- set pawnable(v: boolean);
38
- get pawnable(): boolean;
39
- set perishable(v: boolean);
40
- get perishable(): boolean;
41
- set powerup(v: boolean);
42
- get powerup(): boolean;
31
+ set dropsOnDeath(dropsOnDeath: boolean);
32
+ get dropsOnDeath(): boolean;
33
+ set canBeDropped(canBeDropped: boolean);
34
+ get canBeDropped(): boolean;
35
+ set canBeSold(canBeSold: boolean);
36
+ get canBeSold(): boolean;
37
+ set perishes(perishes: boolean);
38
+ get perishes(): boolean;
39
+ set isPowerUp(isPowerUp: boolean);
40
+ get isPowerUp(): boolean;
43
41
  get isAlive(): boolean;
44
42
  get isDead(): boolean;
45
43
  set isInvulnerable(isInvulnerable: boolean);
46
44
  get isInvulnerable(): boolean;
47
- set usable(v: boolean);
48
- get usable(): boolean;
45
+ set isActivelyUsed(isActivelyUsed: boolean);
46
+ get isActivelyUsed(): boolean;
49
47
  set visible(v: boolean);
50
48
  get visible(): boolean;
51
49
  set level(v: number);
@@ -46,9 +46,18 @@ local getItemY = GetItemY
46
46
  local getItemCharges = GetItemCharges
47
47
  local setItemCharges = SetItemCharges
48
48
  local unitRemoveAbility = UnitRemoveAbility
49
+ local unitRemoveItem = UnitRemoveItem
49
50
  local unitUseItem = UnitUseItem
50
51
  local unitUseItemPoint = UnitUseItemPoint
51
52
  local unitUseItemTarget = UnitUseItemTarget
53
+ local setItemDropOnDeath = SetItemDropOnDeath
54
+ local setItemDroppable = SetItemDroppable
55
+ local setItemPawnable = SetItemPawnable
56
+ local isItemPawnable = IsItemPawnable
57
+ local getItemIntegerField = BlzGetItemIntegerField
58
+ local setItemBooleanField = BlzSetItemBooleanField
59
+ local getItemBooleanField = BlzGetItemBooleanField
60
+ local tableRemove = table.remove
52
61
  _G.SetItemCharges = function(whichItem, charges)
53
62
  setItemCharges(whichItem, charges)
54
63
  invoke(
@@ -56,9 +65,6 @@ _G.SetItemCharges = function(whichItem, charges)
56
65
  ____exports.Item:of(whichItem)
57
66
  )
58
67
  end
59
- local getItemIntegerField = BlzGetItemIntegerField
60
- local setItemBooleanField = BlzSetItemBooleanField
61
- local getItemBooleanField = BlzGetItemBooleanField
62
68
  invoke = Event.invoke
63
69
  local enumRect = Rect:create(0, 0, 0, 0).handle
64
70
  ---
@@ -137,15 +143,13 @@ Item.name = "Item"
137
143
  __TS__ClassExtends(Item, Handle)
138
144
  function Item.prototype.____constructor(self, handle)
139
145
  Handle.prototype.____constructor(self, handle)
140
- local abilities = doAbilityAction(handle, getItemAbilities, self)
141
- self[100] = abilities
142
- local luaIndexByAbilityTypeId = {}
143
- for i = 1, #abilities do
144
- luaIndexByAbilityTypeId[abilities[i].typeId] = i
145
- end
146
- self[101] = luaIndexByAbilityTypeId
146
+ self[100] = doAbilityAction(handle, getItemAbilities, self)
147
147
  end
148
148
  function Item.prototype.onDestroy(self)
149
+ local owner = self.owner
150
+ if owner ~= nil then
151
+ unitRemoveItem(owner.handle, self.handle)
152
+ end
149
153
  local abilities = self[100]
150
154
  for i = 1, #abilities do
151
155
  abilities[i]:destroy()
@@ -191,33 +195,32 @@ function Item.prototype.addAbility(self, abilityTypeId)
191
195
  if nativeAbility ~= nil then
192
196
  local ability = ItemAbility:of(nativeAbility, abilityTypeId, self)
193
197
  local abilities = self[100]
194
- local luaIndex = #abilities + 1
195
- abilities[luaIndex] = ability
196
- self[101][abilityTypeId] = luaIndex
198
+ abilities[#abilities + 1] = ability
197
199
  return ability
198
200
  end
199
201
  return nil
200
202
  end
201
203
  function Item.prototype.removeAbility(self, abilityTypeId)
202
- local luaIndexByAbilityTypeId = self[101]
203
- local luaIndex = luaIndexByAbilityTypeId[abilityTypeId]
204
- if luaIndex ~= nil and doAbilityAction(self.handle, itemRemoveAbility, abilityTypeId) then
205
- luaIndexByAbilityTypeId[abilityTypeId] = nil
206
- local abilities = self[100]
207
- abilities[luaIndex]:destroy()
208
- local abilityTypeIdsLength = #abilities
209
- for j = luaIndex, abilityTypeIdsLength do
210
- abilities[j] = abilities[j + 1]
204
+ local abilities = self[100]
205
+ for i = 1, #abilities do
206
+ if abilities[i].typeId == abilityTypeId then
207
+ local ability = abilities[i]
208
+ tableRemove(abilities, i)
209
+ ability:destroy()
210
+ return true
211
211
  end
212
212
  end
213
- return false
213
+ return doAbilityAction(self.handle, itemRemoveAbility, abilityTypeId)
214
214
  end
215
215
  function Item.prototype.hasAbility(self, abilityTypeId)
216
- return self[101][abilityTypeId] ~= nil
216
+ return doAbilityAction(self.handle, getItemAbility, abilityTypeId) ~= nil
217
217
  end
218
218
  function Item.prototype.getAbility(self, abilityTypeId)
219
- local ability = self[101][abilityTypeId] ~= nil and doAbilityAction(self.handle, getItemAbility, abilityTypeId)
220
- return ability and ItemAbility:of(ability, abilityTypeId, self) or nil
219
+ return ItemAbility:of(
220
+ doAbilityAction(self.handle, getItemAbility, abilityTypeId),
221
+ abilityTypeId,
222
+ self
223
+ )
221
224
  end
222
225
  function Item.getInRange(self, x, y, range)
223
226
  targetCollection = {}
@@ -329,65 +332,68 @@ __TS__SetDescriptor(
329
332
  )
330
333
  __TS__SetDescriptor(
331
334
  Item.prototype,
332
- "dropOnDeath",
335
+ "dropsOnDeath",
333
336
  {
334
337
  get = function(self)
335
- return BlzGetItemBooleanField(self.handle, ITEM_BF_DROPPED_WHEN_CARRIER_DIES)
338
+ return getItemBooleanField(self.handle, ITEM_BF_DROPPED_WHEN_CARRIER_DIES)
336
339
  end,
337
- set = function(self, v)
338
- SetItemDropOnDeath(self.handle, v)
340
+ set = function(self, dropsOnDeath)
341
+ setItemDropOnDeath(self.handle, dropsOnDeath)
339
342
  end
340
343
  },
341
344
  true
342
345
  )
343
346
  __TS__SetDescriptor(
344
347
  Item.prototype,
345
- "droppable",
348
+ "canBeDropped",
346
349
  {
347
350
  get = function(self)
348
- return BlzGetItemBooleanField(self.handle, ITEM_BF_CAN_BE_DROPPED)
351
+ return getItemBooleanField(self.handle, ITEM_BF_CAN_BE_DROPPED)
349
352
  end,
350
- set = function(self, v)
351
- SetItemDroppable(self.handle, v)
353
+ set = function(self, canBeDropped)
354
+ setItemDroppable(self.handle, canBeDropped)
352
355
  end
353
356
  },
354
357
  true
355
358
  )
356
359
  __TS__SetDescriptor(
357
360
  Item.prototype,
358
- "pawnable",
361
+ "canBeSold",
359
362
  {
360
363
  get = function(self)
361
- return IsItemPawnable(self.handle)
364
+ return isItemPawnable(self.handle)
362
365
  end,
363
- set = function(self, v)
364
- SetItemPawnable(self.handle, v)
366
+ set = function(self, canBeSold)
367
+ setItemPawnable(self.handle, canBeSold)
365
368
  end
366
369
  },
367
370
  true
368
371
  )
369
372
  __TS__SetDescriptor(
370
373
  Item.prototype,
371
- "perishable",
374
+ "perishes",
372
375
  {
373
376
  get = function(self)
374
377
  return getItemBooleanField(self.handle, ITEM_BF_PERISHABLE)
375
378
  end,
376
- set = function(self, v)
377
- BlzSetItemBooleanField(self.handle, ITEM_BF_PERISHABLE, v)
379
+ set = function(self, perishes)
380
+ local handle = self.handle
381
+ local powerUp = isItemPowerup(handle)
382
+ setItemBooleanField(handle, ITEM_BF_PERISHABLE, perishes)
383
+ setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, powerUp)
378
384
  end
379
385
  },
380
386
  true
381
387
  )
382
388
  __TS__SetDescriptor(
383
389
  Item.prototype,
384
- "powerup",
390
+ "isPowerUp",
385
391
  {
386
392
  get = function(self)
387
393
  return isItemPowerup(self.handle)
388
394
  end,
389
- set = function(self, v)
390
- setItemBooleanField(self.handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, v)
395
+ set = function(self, isPowerUp)
396
+ setItemBooleanField(self.handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, isPowerUp)
391
397
  end
392
398
  },
393
399
  true
@@ -423,16 +429,24 @@ __TS__SetDescriptor(
423
429
  )
424
430
  __TS__SetDescriptor(
425
431
  Item.prototype,
426
- "usable",
432
+ "isActivelyUsed",
427
433
  {
428
434
  get = function(self)
429
435
  return getItemBooleanField(self.handle, ITEM_BF_ACTIVELY_USED)
430
436
  end,
431
- set = function(self, v)
437
+ set = function(self, isActivelyUsed)
432
438
  local handle = self.handle
433
- local powerup = isItemPowerup(handle)
434
- setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, v)
435
- setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, powerup)
439
+ local powerUp = isItemPowerup(handle)
440
+ local perishes = getItemBooleanField(handle, ITEM_BF_PERISHABLE)
441
+ local dropsOnDeath = getItemBooleanField(handle, ITEM_BF_DROPPED_WHEN_CARRIER_DIES)
442
+ local canBeDropped = getItemBooleanField(handle, ITEM_BF_CAN_BE_DROPPED)
443
+ local canBeSold = isItemPawnable(handle)
444
+ setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, isActivelyUsed)
445
+ setItemPawnable(handle, canBeSold)
446
+ setItemDroppable(handle, canBeDropped)
447
+ setItemDropOnDeath(handle, dropsOnDeath)
448
+ setItemBooleanField(handle, ITEM_BF_PERISHABLE, perishes)
449
+ setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, powerUp)
436
450
  end
437
451
  },
438
452
  true
@@ -0,0 +1,2 @@
1
+ /** @noSelfInFile */
2
+ export {};
@@ -0,0 +1,21 @@
1
+ local ____exports = {}
2
+ local getLocalClientWidth = BlzGetLocalClientWidth
3
+ local getLocalClientHeight = BlzGetLocalClientHeight
4
+ ---
5
+ -- @internal For use by internal systems only.
6
+ ____exports.getFrameMinXMaxX = function()
7
+ local w = getLocalClientWidth()
8
+ local h = getLocalClientHeight()
9
+ local width4by3 = (w - h / 600 * 800) / 2
10
+ local pxtodpi = 0.6 / h
11
+ local minX = -width4by3 * pxtodpi
12
+ local maxX = minX + w * pxtodpi
13
+ return minX, maxX
14
+ end
15
+ ---
16
+ -- @internal For use by internal systems only.
17
+ ____exports.FRAME_MIN_Y = 0
18
+ ---
19
+ -- @internal For use by internal systems only.
20
+ ____exports.FRAME_MAX_Y = 0.6
21
+ return ____exports
@@ -0,0 +1,2 @@
1
+ /** @noSelfInFile */
2
+ export {};
@@ -0,0 +1,11 @@
1
+ local ____exports = {}
2
+ local getLocationZ = GetLocationZ
3
+ local moveLocation = MoveLocation
4
+ local location = Location(0, 0)
5
+ ---
6
+ -- @internal For use by internal systems only.
7
+ ____exports.getTerrainZ = function(x, y)
8
+ moveLocation(location, x, y)
9
+ return getLocationZ(location)
10
+ end
11
+ 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.PLAYER_LOCAL_HANDLE = GetLocalPlayer()
5
+ return ____exports
@@ -0,0 +1,2 @@
1
+ /** @noSelfInFile */
2
+ export {};
@@ -0,0 +1,16 @@
1
+ local ____exports = {}
2
+ local ____mana_2Dregeneration = require("engine.object-data.entry.ability-type.mana-regeneration")
3
+ local ManaRegenerationAbilityType = ____mana_2Dregeneration.ManaRegenerationAbilityType
4
+ ---
5
+ -- @internal For use by internal systems.
6
+ ____exports.MANA_REGENERATION_RATE_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID = compiletime(function()
7
+ local abilityType = ManaRegenerationAbilityType:create()
8
+ abilityType.isInternal = true
9
+ abilityType.isButtonVisible = false
10
+ abilityType.manaRegenerationRateIncreaseFactor = 100
11
+ return abilityType.id
12
+ end)
13
+ ---
14
+ -- @internal For use by internal systems.
15
+ ____exports.MANA_REGENERATION_RATE_INCREASE_FACTOR_ABILITY_FIELD = ABILITY_RLF_MANA_REGENERATION_BONUS_AS_FRACTION_OF_NORMAL
16
+ return ____exports
@@ -131,11 +131,6 @@ declare module "../unit" {
131
131
  const abilityNoTargetChannelingStartEvent: DispatchingEvent<[Unit, Ability]>;
132
132
  }
133
133
  }
134
- declare module "../unit" {
135
- namespace Unit {
136
- const abilityImpactEvent: DispatchingEvent<[Unit, Ability]>;
137
- }
138
- }
139
134
  declare module "../unit" {
140
135
  namespace Unit {
141
136
  const abilityChannelingFinishEvent: DispatchingEvent<[Unit, Ability]>;
@@ -155,3 +150,38 @@ declare module "../unit" {
155
150
  };
156
151
  }
157
152
  }
153
+ declare module "../unit" {
154
+ namespace Unit {
155
+ const abilityImpactEvent: DispatchingEvent<[Unit, Ability]>;
156
+ }
157
+ }
158
+ declare module "../unit" {
159
+ namespace Unit {
160
+ const abilityWidgetTargetImpactEvent: DispatchingEvent<[Unit, Ability, Widget]>;
161
+ }
162
+ }
163
+ declare module "../unit" {
164
+ namespace Unit {
165
+ const abilityUnitTargetImpactEvent: DispatchingEvent<[Unit, Ability, Unit]>;
166
+ }
167
+ }
168
+ declare module "../unit" {
169
+ namespace Unit {
170
+ const abilityItemTargetImpactEvent: DispatchingEvent<[Unit, Ability, Item]>;
171
+ }
172
+ }
173
+ declare module "../unit" {
174
+ namespace Unit {
175
+ const abilityDestructibleTargetImpactEvent: DispatchingEvent<[Unit, Ability, Destructable]>;
176
+ }
177
+ }
178
+ declare module "../unit" {
179
+ namespace Unit {
180
+ const abilityPointTargetImpactEvent: DispatchingEvent<[Unit, Ability, number, number]>;
181
+ }
182
+ }
183
+ declare module "../unit" {
184
+ namespace Unit {
185
+ const abilityNoTargetImpactEvent: DispatchingEvent<[Unit, Ability]>;
186
+ }
187
+ }
@@ -22,7 +22,12 @@ local checkNotNull = ____preconditions.checkNotNull
22
22
  local ____lazy = require("utility.lazy")
23
23
  local lazyRecord = ____lazy.lazyRecord
24
24
  local ____timer = require("core.types.timer")
25
+ local consumeZeroTimerCallback = ____timer.consumeZeroTimerCallback
25
26
  local Timer = ____timer.Timer
27
+ local ____lua_2Dsets = require("utility.lua-sets")
28
+ local luaSetOf = ____lua_2Dsets.luaSetOf
29
+ local ____attributes = require("attributes")
30
+ local attribute = ____attributes.attribute
26
31
  local eventInvoke = Event.invoke
27
32
  local condition = Condition
28
33
  local createTrigger = CreateTrigger
@@ -347,33 +352,17 @@ rawset(
347
352
  extractAbilityTypeId
348
353
  )
349
354
  )
350
- local internalAbilityImpactEvent = __TS__New(Event)
351
- internalAbilityChannelingStartEvent:addListener(function(...)
352
- Timer:run(eventInvoke, internalAbilityImpactEvent, ...)
353
- end)
354
- rawset(
355
- Unit,
356
- "abilityImpactEvent",
357
- createDispatchingEvent(
358
- createCommonEvent(internalAbilityImpactEvent),
359
- extractAbilityTypeId
360
- )
361
- )
355
+ local internalAbilityChannelingFinishEvent = __TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_FINISH, collectUnitAbilityEventParameters)
362
356
  rawset(
363
357
  Unit,
364
358
  "abilityChannelingFinishEvent",
365
- createDispatchingEvent(
366
- __TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_FINISH, collectUnitAbilityEventParameters),
367
- extractAbilityTypeId
368
- )
359
+ createDispatchingEvent(internalAbilityChannelingFinishEvent, extractAbilityTypeId)
369
360
  )
361
+ local internalAbilityStopEvent = __TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_ENDCAST, collectUnitAbilityEventParameters)
370
362
  rawset(
371
363
  Unit,
372
364
  "abilityStopEvent",
373
- createDispatchingEvent(
374
- __TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_ENDCAST, collectUnitAbilityEventParameters),
375
- extractAbilityTypeId
376
- )
365
+ createDispatchingEvent(internalAbilityStopEvent, extractAbilityTypeId)
377
366
  )
378
367
  rawset(
379
368
  Unit,
@@ -390,7 +379,7 @@ rawset(
390
379
  condition(function()
391
380
  local unit = Unit:of(getTriggerUnit())
392
381
  if unit ~= nil then
393
- local ability = unit:getAbilityById(abilityTypeId)
382
+ local ability = unit:getAbility(abilityTypeId)
394
383
  if ability ~= nil then
395
384
  eventInvoke(event, unit, ability, orderTypeStringId)
396
385
  end
@@ -402,4 +391,90 @@ rawset(
402
391
  end)
403
392
  end)
404
393
  )
394
+ local internalAbilityImpactEvent = __TS__New(Event)
395
+ local impactCallbackIdAttribute = attribute()
396
+ local function invokeImpactEvent(unit, ability, ...)
397
+ ability[impactCallbackIdAttribute] = nil
398
+ eventInvoke(internalAbilityImpactEvent, unit, ability, ...)
399
+ end
400
+ internalAbilityChannelingStartEvent:addListener(
401
+ 999999,
402
+ function(unit, ability, ...)
403
+ ability[impactCallbackIdAttribute] = Timer:run(invokeImpactEvent, unit, ability, ...)
404
+ end
405
+ )
406
+ local function consumeImpactCallback(_, ability)
407
+ local impactCallbackId = ability[impactCallbackIdAttribute]
408
+ if impactCallbackId ~= nil then
409
+ consumeZeroTimerCallback(impactCallbackId)
410
+ end
411
+ end
412
+ internalAbilityChannelingFinishEvent:addListener(999999, consumeImpactCallback)
413
+ internalAbilityStopEvent:addListener(999999, consumeImpactCallback)
414
+ rawset(
415
+ Unit,
416
+ "abilityImpactEvent",
417
+ createDispatchingEvent(
418
+ createCommonEvent(internalAbilityImpactEvent),
419
+ extractAbilityTypeId
420
+ )
421
+ )
422
+ rawset(
423
+ Unit,
424
+ "abilityWidgetTargetImpactEvent",
425
+ createDispatchingEvent(
426
+ createWidgetTargetEvent(internalAbilityImpactEvent),
427
+ extractAbilityTypeId
428
+ )
429
+ )
430
+ rawset(
431
+ Unit,
432
+ "abilityUnitTargetImpactEvent",
433
+ createDispatchingEvent(
434
+ createUnitTargetEvent(internalAbilityImpactEvent),
435
+ extractAbilityTypeId
436
+ )
437
+ )
438
+ rawset(
439
+ Unit,
440
+ "abilityItemTargetImpactEvent",
441
+ createDispatchingEvent(
442
+ createItemTargetEvent(internalAbilityImpactEvent),
443
+ extractAbilityTypeId
444
+ )
445
+ )
446
+ rawset(
447
+ Unit,
448
+ "abilityDestructibleTargetImpactEvent",
449
+ createDispatchingEvent(
450
+ createDestructibleTargetEvent(internalAbilityImpactEvent),
451
+ extractAbilityTypeId
452
+ )
453
+ )
454
+ rawset(
455
+ Unit,
456
+ "abilityPointTargetImpactEvent",
457
+ createDispatchingEvent(
458
+ createPointTargetEvent(internalAbilityImpactEvent),
459
+ extractAbilityTypeId
460
+ )
461
+ )
462
+ rawset(
463
+ Unit,
464
+ "abilityNoTargetImpactEvent",
465
+ createDispatchingEvent(
466
+ createNoTargetEvent(internalAbilityImpactEvent),
467
+ extractAbilityTypeId
468
+ )
469
+ )
470
+ local spellEffectOnlyAbilityTypeIds = luaSetOf(fourCC("AAns"))
471
+ internalAbilityChannelingStartEvent:addListener(
472
+ -999999,
473
+ function(unit, ability)
474
+ if spellEffectOnlyAbilityTypeIds[ability.parentTypeId] ~= nil then
475
+ eventInvoke(internalAbilityChannelingFinishEvent, unit, ability)
476
+ eventInvoke(internalAbilityStopEvent, unit, ability)
477
+ end
478
+ end
479
+ )
405
480
  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;