warscript 0.0.1-dev.29630c5 → 0.0.1-dev.2a0c343

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 (116) hide show
  1. package/attributes.d.ts +5 -0
  2. package/attributes.lua +8 -1
  3. package/config.d.ts +5 -0
  4. package/config.lua +10 -0
  5. package/core/types/effect.d.ts +1 -3
  6. package/core/types/effect.lua +26 -29
  7. package/core/types/sound.d.ts +17 -24
  8. package/core/types/sound.lua +99 -24
  9. package/core/types/timer.d.ts +6 -7
  10. package/core/types/timer.lua +18 -21
  11. package/core/util.lua +6 -1
  12. package/decl/native.d.ts +840 -786
  13. package/engine/behaviour/ability/apply-buff.d.ts +5 -0
  14. package/engine/behaviour/ability/apply-buff.lua +32 -0
  15. package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
  16. package/engine/behaviour/ability/damage.d.ts +9 -3
  17. package/engine/behaviour/ability/damage.lua +26 -38
  18. package/engine/behaviour/ability/emulate-impact.lua +7 -0
  19. package/engine/behaviour/ability.d.ts +7 -3
  20. package/engine/behaviour/ability.lua +26 -9
  21. package/engine/behaviour/unit.d.ts +2 -0
  22. package/engine/buff.d.ts +53 -41
  23. package/engine/buff.lua +280 -228
  24. package/engine/internal/ability.d.ts +2 -0
  25. package/engine/internal/ability.lua +7 -0
  26. package/engine/internal/item.d.ts +4 -3
  27. package/engine/internal/item.lua +56 -25
  28. package/engine/internal/mechanics/ability-duration.lua +1 -1
  29. package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
  30. package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
  31. package/engine/internal/unit/add-item-to-slot.lua +4 -2
  32. package/engine/internal/unit+damage.d.ts +2 -11
  33. package/engine/internal/unit+damage.lua +10 -14
  34. package/engine/internal/unit+spellSteal.lua +1 -2
  35. package/engine/internal/unit.d.ts +22 -4
  36. package/engine/internal/unit.lua +132 -37
  37. package/engine/lightning.d.ts +4 -3
  38. package/engine/lightning.lua +21 -12
  39. package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
  40. package/engine/object-data/auxiliary/animation-name.lua +16 -0
  41. package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
  42. package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
  43. package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
  44. package/engine/object-data/auxiliary/attack-type.lua +42 -0
  45. package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
  46. package/engine/object-data/auxiliary/movement-type.lua +22 -0
  47. package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
  48. package/engine/object-data/auxiliary/sound-eax.lua +2 -0
  49. package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
  50. package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
  51. package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
  52. package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
  53. package/engine/object-data/entry/ability-type/berserk.lua +13 -0
  54. package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
  55. package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
  56. package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
  57. package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
  58. package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
  59. package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
  60. package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
  61. package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
  62. package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
  63. package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
  64. package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
  65. package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
  66. package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
  67. package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
  68. package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
  69. package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
  70. package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
  71. package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
  72. package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
  73. package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
  74. package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
  75. package/engine/object-data/entry/ability-type/web.d.ts +12 -0
  76. package/engine/object-data/entry/ability-type/web.lua +52 -0
  77. package/engine/object-data/entry/ability-type.d.ts +19 -17
  78. package/engine/object-data/entry/ability-type.lua +81 -21
  79. package/engine/object-data/entry/buff-type/applicable.lua +18 -37
  80. package/engine/object-data/entry/buff-type.d.ts +6 -12
  81. package/engine/object-data/entry/buff-type.lua +13 -29
  82. package/engine/object-data/entry/destructible-type.d.ts +1 -1
  83. package/engine/object-data/entry/item-type.d.ts +1 -1
  84. package/engine/object-data/entry/item-type.lua +4 -4
  85. package/engine/object-data/entry/lightning-type.d.ts +1 -1
  86. package/engine/object-data/entry/sound-preset.d.ts +33 -0
  87. package/engine/object-data/entry/sound-preset.lua +140 -0
  88. package/engine/object-data/entry/unit-type.d.ts +10 -3
  89. package/engine/object-data/entry/unit-type.lua +155 -92
  90. package/engine/object-data/entry/upgrade.d.ts +1 -1
  91. package/engine/object-data/entry/upgrade.lua +4 -4
  92. package/engine/object-data/entry.d.ts +16 -14
  93. package/engine/object-data/entry.lua +60 -32
  94. package/engine/object-field/ability.d.ts +1 -1
  95. package/engine/object-field/unit.d.ts +46 -3
  96. package/engine/object-field/unit.lua +173 -7
  97. package/engine/object-field.d.ts +9 -1
  98. package/engine/object-field.lua +158 -76
  99. package/engine/standard/entries/buff-type.d.ts +3 -0
  100. package/engine/standard/entries/buff-type.lua +3 -0
  101. package/engine/standard/entries/sound-preset.d.ts +10 -0
  102. package/engine/standard/entries/sound-preset.lua +10 -0
  103. package/objutil/buff.lua +1 -2
  104. package/objutil/unit.lua +8 -0
  105. package/package.json +2 -2
  106. package/utility/arrays.d.ts +1 -0
  107. package/utility/arrays.lua +3 -0
  108. package/utility/functions.d.ts +1 -0
  109. package/utility/functions.lua +1 -0
  110. package/utility/linked-set.d.ts +1 -0
  111. package/utility/linked-set.lua +3 -0
  112. package/utility/lua-maps.d.ts +3 -0
  113. package/utility/lua-maps.lua +16 -0
  114. package/utility/lua-sets.d.ts +1 -0
  115. package/utility/lua-sets.lua +3 -0
  116. package/utility/reflection.lua +11 -7
@@ -53,12 +53,17 @@ local ____math = require("math")
53
53
  local min = ____math.min
54
54
  local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
55
55
  local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
56
+ local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
57
+ local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
58
+ local nativeToAttackType = ____attack_2Dtype.nativeToAttackType
59
+ local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
60
+ local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
61
+ local ____attributes = require("attributes")
62
+ local isAttribute = ____attributes.isAttribute
56
63
  local match = string.match
57
64
  local ____tostring = _G.tostring
58
65
  local setUnitAnimation = SetUnitAnimation
59
- local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
60
66
  local setUnitAnimationByIndex = SetUnitAnimationByIndex
61
- local queueUnitAnimation = QueueUnitAnimation
62
67
  local getUnitIntegerField = BlzGetUnitIntegerField
63
68
  local getUnitRealField = BlzGetUnitRealField
64
69
  local getHeroStr = GetHeroStr
@@ -80,7 +85,6 @@ local getHandleId = GetHandleId
80
85
  local getUnitCurrentOrder = GetUnitCurrentOrder
81
86
  local createUnit = CreateUnit
82
87
  local killUnit = KillUnit
83
- local setUnitExploded = SetUnitExploded
84
88
  local removeUnit = RemoveUnit
85
89
  local getUnitTypeId = GetUnitTypeId
86
90
  local isHeroUnitId = IsHeroUnitId
@@ -96,8 +100,6 @@ local getSpellTargetItem = GetSpellTargetItem
96
100
  local getSpellTargetDestructable = GetSpellTargetDestructable
97
101
  local isUnitInRangeXY = IsUnitInRangeXY
98
102
  local isUnitInRange = IsUnitInRange
99
- local setResourceAmount = SetResourceAmount
100
- local getResourceAmount = GetResourceAmount
101
103
  local getUnitWeaponRealField = BlzGetUnitWeaponRealField
102
104
  local setUnitWeaponRealField = BlzSetUnitWeaponRealField
103
105
  local getUnitWeaponStringField = BlzGetUnitWeaponStringField
@@ -128,8 +130,6 @@ local isUnitType = IsUnitType
128
130
  local isUnitAlly = IsUnitAlly
129
131
  local isUnitEnemy = IsUnitEnemy
130
132
  local getOwningPlayer = GetOwningPlayer
131
- local setUnitColor = SetUnitColor
132
- local showUnitTeamGlow = BlzShowUnitTeamGlow
133
133
  ____exports.UnitClassification = {}
134
134
  local UnitClassification = ____exports.UnitClassification
135
135
  do
@@ -139,6 +139,7 @@ do
139
139
  UnitClassification.GROUND = UNIT_TYPE_GROUND
140
140
  UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
141
141
  UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
142
+ UnitClassification.WORKER = UNIT_TYPE_PEON
142
143
  UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
143
144
  UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
144
145
  UnitClassification.TAUREN = UNIT_TYPE_TAUREN
@@ -346,6 +347,9 @@ local function dispatchAbility(event)
346
347
  }
347
348
  )
348
349
  end
350
+ local function damagingEventPreventRetaliation(self)
351
+ rawset(self, 0, true)
352
+ end
349
353
  local function damageEventPreventDeath(self, callback, ...)
350
354
  if self[0] ~= nil then
351
355
  return
@@ -357,7 +361,14 @@ local function damageEventPreventDeath(self, callback, ...)
357
361
  rawset(self, 1 + i, (select(i, ...)))
358
362
  end
359
363
  end
360
- local damageSetters = {amount = BlzSetEventDamage, attackType = BlzSetEventAttackType, damageType = BlzSetEventDamageType, weaponType = BlzSetEventWeaponType}
364
+ local damageSetters = {
365
+ amount = BlzSetEventDamage,
366
+ attackType = function(attackType)
367
+ return BlzSetEventAttackType(attackTypeToNative(attackType))
368
+ end,
369
+ damageType = BlzSetEventDamageType,
370
+ weaponType = BlzSetEventWeaponType
371
+ }
361
372
  local jlimitopByOperator = {
362
373
  [0] = LESS_THAN_OR_EQUAL,
363
374
  [1] = LESS_THAN_OR_EQUAL,
@@ -639,7 +650,8 @@ local function delayHealthChecksCallback(unit)
639
650
  end
640
651
  end
641
652
  local nextSyncId = 1
642
- local unitBySyncId = setmetatable({}, {__mode = "k"})
653
+ local unitBySyncId = setmetatable({}, {__mode = "v"})
654
+ local damagingEventByTarget = setmetatable({}, {__mode = "k"})
643
655
  ____exports.Unit = __TS__Class()
644
656
  local Unit = ____exports.Unit
645
657
  Unit.name = "Unit"
@@ -680,6 +692,8 @@ function Unit.prototype.getEvent(self, event, collector)
680
692
  end
681
693
  function Unit.prototype.onDestroy(self)
682
694
  local handle = self.handle
695
+ self[107] = getUnitX(handle)
696
+ self[108] = getUnitY(handle)
683
697
  if not self._owner then
684
698
  self._owner = Player:of(getOwningPlayer(handle))
685
699
  end
@@ -790,13 +804,16 @@ function Unit.prototype.playAnimation(self, animation, rarity)
790
804
  if type(animation) == "number" then
791
805
  setUnitAnimationByIndex(self.handle, animation)
792
806
  elseif rarity then
793
- setUnitAnimationWithRarity(self.handle, animation, rarity)
807
+ SetUnitAnimationWithRarity(self.handle, animation, rarity)
794
808
  else
795
809
  setUnitAnimation(self.handle, animation)
796
810
  end
797
811
  end
812
+ function Unit.prototype.resetAnimation(self)
813
+ ResetUnitAnimation(self.handle)
814
+ end
798
815
  function Unit.prototype.queueAnimation(self, animation)
799
- queueUnitAnimation(self.handle, animation)
816
+ QueueUnitAnimation(self.handle, animation)
800
817
  end
801
818
  function Unit.prototype.delayHealthChecks(self)
802
819
  self[103] = (self[103] or 0) + 1
@@ -809,7 +826,7 @@ function Unit.prototype.isSelected(self, player)
809
826
  return IsUnitSelected(self.handle, player.handle)
810
827
  end
811
828
  function Unit.prototype.explode(self)
812
- setUnitExploded(self.handle, true)
829
+ SetUnitExploded(self.handle, true)
813
830
  killUnit(self.handle)
814
831
  end
815
832
  function Unit.prototype.kill(self)
@@ -1286,6 +1303,19 @@ __TS__SetDescriptor(
1286
1303
  },
1287
1304
  true
1288
1305
  )
1306
+ __TS__SetDescriptor(
1307
+ Unit.prototype,
1308
+ "primaryAttribute",
1309
+ {
1310
+ get = function(self)
1311
+ return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
1312
+ end,
1313
+ set = function(self, primaryAttribute)
1314
+ setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
1315
+ end
1316
+ },
1317
+ true
1318
+ )
1289
1319
  __TS__SetDescriptor(
1290
1320
  Unit.prototype,
1291
1321
  "strengthBase",
@@ -1410,7 +1440,7 @@ __TS__SetDescriptor(
1410
1440
  return not self[106]
1411
1441
  end,
1412
1442
  set = function(self, isTeamGlowVisible)
1413
- showUnitTeamGlow(self.handle, isTeamGlowVisible)
1443
+ BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
1414
1444
  local ____temp_6
1415
1445
  if not isTeamGlowVisible then
1416
1446
  ____temp_6 = true
@@ -1426,9 +1456,9 @@ __TS__SetDescriptor(
1426
1456
  Unit.prototype,
1427
1457
  "color",
1428
1458
  {set = function(self, color)
1429
- setUnitColor(self.handle, color.handle)
1459
+ SetUnitColor(self.handle, color.handle)
1430
1460
  if self[106] then
1431
- showUnitTeamGlow(self.handle, false)
1461
+ BlzShowUnitTeamGlow(self.handle, false)
1432
1462
  end
1433
1463
  end},
1434
1464
  true
@@ -1597,7 +1627,7 @@ __TS__SetDescriptor(
1597
1627
  "x",
1598
1628
  {
1599
1629
  get = function(self)
1600
- return getUnitX(self.handle)
1630
+ return self[107] or getUnitX(self.handle)
1601
1631
  end,
1602
1632
  set = function(self, v)
1603
1633
  SetUnitX(self.handle, v)
@@ -1610,7 +1640,7 @@ __TS__SetDescriptor(
1610
1640
  "y",
1611
1641
  {
1612
1642
  get = function(self)
1613
- return getUnitY(self.handle)
1643
+ return self[108] or getUnitY(self.handle)
1614
1644
  end,
1615
1645
  set = function(self, v)
1616
1646
  SetUnitY(self.handle, v)
@@ -1696,10 +1726,10 @@ __TS__SetDescriptor(
1696
1726
  "gold",
1697
1727
  {
1698
1728
  get = function(self)
1699
- return getResourceAmount(self.handle)
1729
+ return GetResourceAmount(self.handle)
1700
1730
  end,
1701
1731
  set = function(self, gold)
1702
- setResourceAmount(self.handle, gold)
1732
+ SetResourceAmount(self.handle, gold)
1703
1733
  end
1704
1734
  },
1705
1735
  true
@@ -1827,6 +1857,19 @@ __TS__SetDescriptor(
1827
1857
  end},
1828
1858
  true
1829
1859
  )
1860
+ __TS__SetDescriptor(
1861
+ Unit.prototype,
1862
+ "movementType",
1863
+ {
1864
+ get = function(self)
1865
+ return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
1866
+ end,
1867
+ set = function(self, movementType)
1868
+ setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
1869
+ end
1870
+ },
1871
+ true
1872
+ )
1830
1873
  __TS__SetDescriptor(
1831
1874
  Unit.prototype,
1832
1875
  "pathing",
@@ -2008,6 +2051,14 @@ __TS__SetDescriptor(
2008
2051
  end},
2009
2052
  true
2010
2053
  )
2054
+ __TS__SetDescriptor(
2055
+ Unit.prototype,
2056
+ "targetAcquiredEvent",
2057
+ {get = function(self)
2058
+ return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
2059
+ end},
2060
+ true
2061
+ )
2011
2062
  __TS__SetDescriptor(
2012
2063
  Unit.prototype,
2013
2064
  "onSelect",
@@ -2369,13 +2420,19 @@ Unit.onDamaging = (function()
2369
2420
  if source and source.typeId == dummyUnitId then
2370
2421
  source = nil
2371
2422
  end
2372
- local target = BlzGetEventDamageTarget()
2423
+ local target = ____exports.Unit:of(BlzGetEventDamageTarget())
2424
+ local metadata = damageMetadataByTarget[target]
2425
+ damageMetadataByTarget[target] = nil
2373
2426
  local data = {
2374
2427
  amount = GetEventDamage(),
2375
- attackType = BlzGetEventAttackType(),
2428
+ attackType = nativeToAttackType(BlzGetEventAttackType()),
2376
2429
  damageType = BlzGetEventDamageType(),
2377
2430
  weaponType = BlzGetEventWeaponType(),
2378
- isAttack = BlzGetEventIsAttack()
2431
+ metadata = metadata,
2432
+ isAttack = BlzGetEventIsAttack(),
2433
+ originalAmount = GetEventDamage(),
2434
+ originalMetadata = metadata,
2435
+ preventRetaliation = damagingEventPreventRetaliation
2379
2436
  }
2380
2437
  if data.isAttack and source then
2381
2438
  local weapon = BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 1) and (BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 0) and -1 or 1) or 0
@@ -2389,18 +2446,36 @@ Unit.onDamaging = (function()
2389
2446
  invoke(
2390
2447
  event,
2391
2448
  source,
2392
- ____exports.Unit:of(target),
2449
+ target,
2393
2450
  setmetatable(
2394
2451
  {},
2395
2452
  {
2396
2453
  __index = data,
2397
2454
  __newindex = function(self, key, value)
2398
- damageSetters[key](value)
2455
+ local damageSetter = damageSetters[key]
2456
+ if damageSetter ~= nil then
2457
+ damageSetter(value)
2458
+ end
2399
2459
  data[key] = value
2400
2460
  end
2401
2461
  }
2402
2462
  )
2403
2463
  )
2464
+ if data[0] and source then
2465
+ local sourceOwner = source.owner.handle
2466
+ data[1] = sourceOwner
2467
+ local targetOwner = target.owner.handle
2468
+ data[2] = targetOwner
2469
+ if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
2470
+ SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
2471
+ data[3] = true
2472
+ end
2473
+ if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
2474
+ SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
2475
+ data[4] = true
2476
+ end
2477
+ end
2478
+ damagingEventByTarget[target] = data
2404
2479
  return
2405
2480
  end
2406
2481
  BlzSetEventDamage(0)
@@ -2408,7 +2483,7 @@ Unit.onDamaging = (function()
2408
2483
  BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
2409
2484
  BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
2410
2485
  local sourceOwner = source.owner.handle
2411
- local targetOwner = GetOwningPlayer(target)
2486
+ local targetOwner = target.owner.handle
2412
2487
  if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
2413
2488
  SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
2414
2489
  Timer:run(function()
@@ -2424,23 +2499,19 @@ Unit.onDamaging = (function()
2424
2499
  for ____, ____value in ipairs(source._attackHandlers) do
2425
2500
  local condition = ____value[1]
2426
2501
  local action = ____value[2]
2427
- if condition(
2428
- source,
2429
- ____exports.Unit:of(target),
2430
- data
2431
- ) then
2502
+ if condition(source, target, data) then
2432
2503
  action(
2433
2504
  source,
2434
- ____exports.Unit:of(target),
2505
+ target,
2435
2506
  setmetatable(
2436
2507
  {fire = function()
2437
2508
  UnitDamageTarget(
2438
2509
  source.handle,
2439
- target,
2510
+ target.handle,
2440
2511
  data.amount,
2441
2512
  true,
2442
2513
  true,
2443
- data.attackType,
2514
+ attackTypeToNative(data.attackType),
2444
2515
  data.damageType,
2445
2516
  data.weaponType
2446
2517
  )
@@ -2467,26 +2538,50 @@ Unit.onDamage = __TS__New(
2467
2538
  if source and source.typeId == dummyUnitId then
2468
2539
  source = nil
2469
2540
  end
2541
+ local target = ____exports.Unit:of(BlzGetEventDamageTarget())
2542
+ local damagingEvent = damagingEventByTarget[target]
2543
+ damagingEventByTarget[target] = nil
2470
2544
  local data = {
2471
2545
  amount = GetEventDamage(),
2472
- attackType = BlzGetEventAttackType(),
2546
+ attackType = nativeToAttackType(BlzGetEventAttackType()),
2473
2547
  damageType = BlzGetEventDamageType(),
2474
2548
  weaponType = BlzGetEventWeaponType(),
2549
+ metadata = damagingEvent and damagingEvent.metadata,
2475
2550
  isAttack = BlzGetEventIsAttack(),
2476
- originalAmount = GetEventDamage(),
2551
+ originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
2552
+ originalMetadata = damagingEvent and damagingEvent.originalMetadata,
2477
2553
  preventDeath = damageEventPreventDeath
2478
2554
  }
2555
+ if damagingEvent then
2556
+ for key, value in pairs(damagingEvent) do
2557
+ if isAttribute(key) then
2558
+ data[key] = value
2559
+ end
2560
+ end
2561
+ local sourceOwner = damagingEvent[1]
2562
+ if sourceOwner then
2563
+ local targetOwner = damagingEvent[2]
2564
+ if damagingEvent[3] then
2565
+ SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
2566
+ end
2567
+ if damagingEvent[4] then
2568
+ SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
2569
+ end
2570
+ end
2571
+ end
2479
2572
  local evData = setmetatable(
2480
2573
  {},
2481
2574
  {
2482
2575
  __index = data,
2483
2576
  __newindex = function(self, key, value)
2484
- damageSetters[key](value)
2577
+ local damageSetter = damageSetters[key]
2578
+ if damageSetter ~= nil then
2579
+ damageSetter(value)
2580
+ end
2485
2581
  data[key] = value
2486
2582
  end
2487
2583
  }
2488
2584
  )
2489
- local target = ____exports.Unit:of(BlzGetEventDamageTarget())
2490
2585
  invoke(event, source, target, evData)
2491
2586
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2492
2587
  local bonusHealth = math.ceil(evData.amount)
@@ -1,7 +1,7 @@
1
1
  /** @noSelfInFile */
2
2
  import { LightningTypeId } from "./object-data/entry/lightning-type";
3
- import { Handle, HandleDestructor } from "../core/types/handle";
4
3
  import { Unit } from "../core/types/unit";
4
+ import { AbstractDestroyable, Destructor } from "../destroyable";
5
5
  declare const enum LightningPropertyKey {
6
6
  CHECK_VISIBILITY = 100,
7
7
  SOURCE_UNIT = 101,
@@ -16,7 +16,8 @@ declare const enum LightningPropertyKey {
16
16
  FADING = 110
17
17
  }
18
18
  export type LightningConstructor<T extends Lightning> = typeof Lightning & (new (handle: jlightning, typeId: LightningTypeId) => T);
19
- export declare class Lightning extends Handle<jlightning> {
19
+ export declare class Lightning extends AbstractDestroyable {
20
+ readonly handle: jlightning;
20
21
  readonly typeId: LightningTypeId;
21
22
  private [LightningPropertyKey.CHECK_VISIBILITY]?;
22
23
  private [LightningPropertyKey.SOURCE_UNIT]?;
@@ -30,7 +31,7 @@ export declare class Lightning extends Handle<jlightning> {
30
31
  private [LightningPropertyKey.DURATION]?;
31
32
  private [LightningPropertyKey.FADING]?;
32
33
  constructor(handle: jlightning, typeId: LightningTypeId);
33
- protected onDestroy(): HandleDestructor;
34
+ protected onDestroy(): Destructor;
34
35
  static create<T extends Lightning>(this: LightningConstructor<T>, typeId: LightningTypeId, ...parameters: [
35
36
  ...checkVisibility: [boolean] | [],
36
37
  ...sourceAndTarget: [sourceX: number, sourceY: number, targetX: number, targetY: number] | [
@@ -1,15 +1,16 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
3
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
+ local __TS__New = ____lualib.__TS__New
4
5
  local ____exports = {}
5
- local ____handle = require("core.types.handle")
6
- local Handle = ____handle.Handle
7
6
  local ____timer = require("core.types.timer")
8
7
  local Timer = ____timer.Timer
9
8
  local ____functions = require("utility.functions")
10
9
  local forwardByN = ____functions.forwardByN
11
10
  local ____unit_2Dmissile_2Ddata = require("engine.internal.unit-missile-data")
12
11
  local MISSILE_DATA_BY_UNIT_TYPE_ID = ____unit_2Dmissile_2Ddata.MISSILE_DATA_BY_UNIT_TYPE_ID
12
+ local ____destroyable = require("destroyable")
13
+ local AbstractDestroyable = ____destroyable.AbstractDestroyable
13
14
  local ____type = _G.type
14
15
  local select = _G.select
15
16
  local cos = math.cos
@@ -41,9 +42,10 @@ local temporaryLightningsCount = 0
41
42
  ____exports.Lightning = __TS__Class()
42
43
  local Lightning = ____exports.Lightning
43
44
  Lightning.name = "Lightning"
44
- __TS__ClassExtends(Lightning, Handle)
45
+ __TS__ClassExtends(Lightning, AbstractDestroyable)
45
46
  function Lightning.prototype.____constructor(self, handle, typeId)
46
- Handle.prototype.____constructor(self, handle)
47
+ AbstractDestroyable.prototype.____constructor(self)
48
+ self.handle = handle
47
49
  self.typeId = typeId
48
50
  end
49
51
  function Lightning.prototype.onDestroy(self)
@@ -51,7 +53,7 @@ function Lightning.prototype.onDestroy(self)
51
53
  unitToPointLightnings[self] = nil
52
54
  pointToUnitLightnings[self] = nil
53
55
  destroyLightning(self.handle)
54
- return Handle.prototype.onDestroy(self)
56
+ return AbstractDestroyable.prototype.onDestroy(self)
55
57
  end
56
58
  function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, sourceYOrTargetXOrTargetUnit, sourceZOrTargetXOrTargetUnitOrTargetY, targetXOrTargetUnitOrTargetYOrTargetZ, targetY, targetZ)
57
59
  if type(checkVisibility) ~= "boolean" then
@@ -67,7 +69,8 @@ function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, so
67
69
  )
68
70
  end
69
71
  if targetZ ~= nil then
70
- return self:of(
72
+ return __TS__New(
73
+ self,
71
74
  addLightningEx(
72
75
  util.id2s(typeId),
73
76
  checkVisibility,
@@ -84,7 +87,8 @@ function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, so
84
87
  if targetXOrTargetUnitOrTargetYOrTargetZ ~= nil then
85
88
  if ____type(targetXOrTargetUnitOrTargetYOrTargetZ) == "number" then
86
89
  if ____type(sourceXOrSourceUnit) == "number" then
87
- return self:of(
90
+ return __TS__New(
91
+ self,
88
92
  addLightning(
89
93
  util.id2s(typeId),
90
94
  checkVisibility,
@@ -97,7 +101,8 @@ function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, so
97
101
  )
98
102
  end
99
103
  local unit = sourceXOrSourceUnit.handle
100
- local lightning = self:of(
104
+ local lightning = __TS__New(
105
+ self,
101
106
  addLightningEx(
102
107
  util.id2s(typeId),
103
108
  checkVisibility,
@@ -122,7 +127,8 @@ function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, so
122
127
  return lightning
123
128
  end
124
129
  local unit = targetXOrTargetUnitOrTargetYOrTargetZ.handle
125
- local lightning = self:of(
130
+ local lightning = __TS__New(
131
+ self,
126
132
  addLightningEx(
127
133
  util.id2s(typeId),
128
134
  checkVisibility,
@@ -151,7 +157,8 @@ function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, so
151
157
  local unit = sourceXOrSourceUnit.handle
152
158
  moveLocation(location, sourceYOrTargetXOrTargetUnit, sourceZOrTargetXOrTargetUnitOrTargetY)
153
159
  local z = getLocationZ(location)
154
- local lightning = self:of(
160
+ local lightning = __TS__New(
161
+ self,
155
162
  addLightningEx(
156
163
  util.id2s(typeId),
157
164
  checkVisibility,
@@ -178,7 +185,8 @@ function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, so
178
185
  local unit = sourceZOrTargetXOrTargetUnitOrTargetY.handle
179
186
  moveLocation(location, sourceXOrSourceUnit, sourceYOrTargetXOrTargetUnit)
180
187
  local z = getLocationZ(location)
181
- local lightning = self:of(
188
+ local lightning = __TS__New(
189
+ self,
182
190
  addLightningEx(
183
191
  util.id2s(typeId),
184
192
  checkVisibility,
@@ -204,7 +212,8 @@ function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, so
204
212
  end
205
213
  local sourceUnit = sourceXOrSourceUnit.handle
206
214
  local targetUnit = sourceYOrTargetXOrTargetUnit.handle
207
- local lightning = self:of(
215
+ local lightning = __TS__New(
216
+ self,
208
217
  addLightningEx(
209
218
  util.id2s(typeId),
210
219
  checkVisibility,
@@ -12,3 +12,4 @@ export declare const enum AnimationName {
12
12
  STAND = "stand",
13
13
  WALK = "walk"
14
14
  }
15
+ export declare const isAnimationName: (value: string) => value is AnimationName;
@@ -1,2 +1,18 @@
1
1
  local ____exports = {}
2
+ local animationNames = {
3
+ attack = true,
4
+ birth = true,
5
+ death = true,
6
+ decay = true,
7
+ dissipate = true,
8
+ morph = true,
9
+ portrait = true,
10
+ sleep = true,
11
+ spell = true,
12
+ stand = true,
13
+ walk = true
14
+ }
15
+ ____exports.isAnimationName = function(value)
16
+ return animationNames[value] ~= nil
17
+ end
2
18
  return ____exports
@@ -2,13 +2,18 @@
2
2
  import { ModelNodeName } from "./model-node-name";
3
3
  import { ModelNodeQualifier } from "./model-node-qualifier";
4
4
  import { Optional } from "../../../utility/types";
5
+ import { EffectParameters } from "../../../core/types/effect";
5
6
  export type AttachmentPreset = {
6
7
  modelPath: string;
7
8
  nodeName: ModelNodeName;
8
9
  nodeQualifiers: ModelNodeQualifier[];
9
10
  };
10
- export type AttachmentPresetInput = Optional<AttachmentPreset, "nodeQualifiers"> | string;
11
- export declare const toAttachmentPreset: (attachmentPresetInput: AttachmentPresetInput) => AttachmentPreset;
11
+ export type EffectPresetWithParameters = AttachmentPreset & {
12
+ parameters?: EffectParameters;
13
+ };
14
+ export type AttachmentPresetInput<T extends AttachmentPreset = AttachmentPreset> = Optional<T, "nodeName" | "nodeQualifiers"> | string;
15
+ export type EffectPresetWithParametersInput = AttachmentPresetInput<EffectPresetWithParameters>;
16
+ export declare const toEffectPreset: (effectPresetInput: EffectPresetWithParametersInput) => EffectPresetWithParameters;
12
17
  export declare const extractAttachmentPresetInputModelPath: (attachmentPresetInput: AttachmentPresetInput | undefined) => string;
13
18
  export declare const extractAttachmentPresetInputNodeFQN: (attachmentPresetInput: AttachmentPresetInput | undefined) => string;
14
19
  export declare const splitAttachmentNodeFQN: (attachmentNodeFQN: string) => LuaMultiReturn<[attachmentNodeName: ModelNodeName, attachmentNodeQualifiers: ModelNodeQualifier[]]>;
@@ -1,9 +1,10 @@
1
1
  local ____lualib = require("lualib_bundle")
2
+ local __TS__ArrayJoin = ____lualib.__TS__ArrayJoin
2
3
  local __TS__StringSplit = ____lualib.__TS__StringSplit
3
4
  local __TS__ArraySlice = ____lualib.__TS__ArraySlice
4
5
  local ____exports = {}
5
- ____exports.toAttachmentPreset = function(attachmentPresetInput)
6
- return type(attachmentPresetInput) == "string" and ({modelPath = attachmentPresetInput, nodeName = "origin", nodeQualifiers = {}}) or ({modelPath = attachmentPresetInput.modelPath, nodeName = attachmentPresetInput.nodeName, nodeQualifiers = attachmentPresetInput.nodeQualifiers or ({})})
6
+ ____exports.toEffectPreset = function(effectPresetInput)
7
+ return type(effectPresetInput) == "string" and ({modelPath = effectPresetInput, nodeName = "origin", nodeQualifiers = {}}) or ({modelPath = effectPresetInput.modelPath, nodeName = effectPresetInput.nodeName or "origin", nodeQualifiers = effectPresetInput.nodeQualifiers or ({}), parameters = effectPresetInput.parameters})
7
8
  end
8
9
  ____exports.extractAttachmentPresetInputModelPath = function(attachmentPresetInput)
9
10
  return type(attachmentPresetInput) == "string" and attachmentPresetInput or (attachmentPresetInput and attachmentPresetInput.modelPath or "")
@@ -12,7 +13,7 @@ ____exports.extractAttachmentPresetInputNodeFQN = function(attachmentPresetInput
12
13
  if type(attachmentPresetInput) == "string" or attachmentPresetInput == nil then
13
14
  return ""
14
15
  end
15
- return table.concat(
16
+ return __TS__ArrayJoin(
16
17
  {
17
18
  attachmentPresetInput.nodeName,
18
19
  table.unpack(attachmentPresetInput.nodeQualifiers or ({}))
@@ -1,11 +1,10 @@
1
1
  /** @noSelfInFile */
2
2
  export declare const enum AttackType {
3
- NONE = "unknown",
4
- NORMAL = "normal",
5
- PIERCE = "pierce",
6
- SIEGE = "siege",
7
- SPELL = "spells",
8
- CHAOS = "chaos",
9
- MAGIC = "magic",
10
- HERO = "hero"
3
+ SPELL = 0,
4
+ NORMAL = 1,
5
+ PIERCE = 2,
6
+ SIEGE = 3,
7
+ MAGIC = 4,
8
+ CHAOS = 5,
9
+ HERO = 6
11
10
  }
@@ -1,2 +1,44 @@
1
1
  local ____exports = {}
2
+ local ____records = require("utility.records")
3
+ local invertRecord = ____records.invertRecord
4
+ local stringByAttackType = {
5
+ [1] = "normal",
6
+ [2] = "pierce",
7
+ [3] = "siege",
8
+ [0] = "spells",
9
+ [5] = "chaos",
10
+ [4] = "magic",
11
+ [6] = "hero"
12
+ }
13
+ local attackTypeByString = invertRecord(stringByAttackType)
14
+ local nativeByAttackType = {
15
+ [1] = ATTACK_TYPE_MELEE,
16
+ [2] = ATTACK_TYPE_PIERCE,
17
+ [3] = ATTACK_TYPE_SIEGE,
18
+ [0] = ATTACK_TYPE_NORMAL,
19
+ [5] = ATTACK_TYPE_CHAOS,
20
+ [4] = ATTACK_TYPE_MAGIC,
21
+ [6] = ATTACK_TYPE_HERO
22
+ }
23
+ local attackTypeByNative = invertRecord(nativeByAttackType)
24
+ ---
25
+ -- @internal For use by internal systems only.
26
+ ____exports.attackTypeToString = function(attackType)
27
+ return attackType ~= nil and stringByAttackType[attackType] or "unknown"
28
+ end
29
+ ---
30
+ -- @internal For use by internal systems only.
31
+ ____exports.stringToAttackType = function(____string)
32
+ return attackTypeByString[____string]
33
+ end
34
+ ---
35
+ -- @internal For use by internal systems only.
36
+ ____exports.attackTypeToNative = function(attackType)
37
+ return nativeByAttackType[attackType]
38
+ end
39
+ ---
40
+ -- @internal For use by internal systems only.
41
+ ____exports.nativeToAttackType = function(attackType)
42
+ return attackTypeByNative[attackType]
43
+ end
2
44
  return ____exports
@@ -1,10 +1,10 @@
1
1
  /** @noSelfInFile */
2
2
  export declare const enum MovementType {
3
- NONE = "",
4
- FLOAT = "float",
5
- FLY = "fly",
6
- FOOT = "foot",
7
- HORSE = "horse",
8
- HOVER = "hover",
9
- AMPHIBIOUS = "amph"
3
+ NONE = 0,
4
+ FOOT = 1,
5
+ FLY = 2,
6
+ HORSE = 4,
7
+ HOVER = 8,
8
+ FLOAT = 16,
9
+ AMPHIBIOUS = 32
10
10
  }