warscript 0.0.1-dev.2bde093 → 0.0.1-dev.2fcfd45

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 (95) hide show
  1. package/attributes.d.ts +6 -0
  2. package/attributes.lua +17 -1
  3. package/core/types/frame.lua +24 -21
  4. package/core/types/player.d.ts +15 -0
  5. package/core/types/player.lua +56 -14
  6. package/core/types/playerCamera.d.ts +2 -0
  7. package/core/types/playerCamera.lua +123 -5
  8. package/core/types/tileCell.d.ts +9 -0
  9. package/core/types/tileCell.lua +92 -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/engine/behavior.d.ts +5 -0
  14. package/engine/behavior.lua +106 -27
  15. package/engine/behaviour/ability/apply-buff.lua +1 -1
  16. package/engine/behaviour/ability/damage.d.ts +2 -1
  17. package/engine/behaviour/ability/damage.lua +21 -36
  18. package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
  19. package/engine/behaviour/ability/emulate-impact.lua +11 -3
  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.lua +8 -17
  25. package/engine/behaviour/unit/stun-immunity.d.ts +7 -3
  26. package/engine/behaviour/unit/stun-immunity.lua +52 -27
  27. package/engine/behaviour/unit.d.ts +33 -1
  28. package/engine/behaviour/unit.lua +190 -4
  29. package/engine/buff.d.ts +2 -4
  30. package/engine/buff.lua +68 -83
  31. package/engine/internal/ability.d.ts +7 -1
  32. package/engine/internal/ability.lua +49 -9
  33. package/engine/internal/item/ability.lua +63 -11
  34. package/engine/internal/item+owner.lua +12 -6
  35. package/engine/internal/item.d.ts +16 -16
  36. package/engine/internal/item.lua +135 -49
  37. package/engine/internal/misc/frame-coordinates.d.ts +2 -0
  38. package/engine/internal/misc/frame-coordinates.lua +21 -0
  39. package/engine/internal/misc/get-terrain-z.d.ts +2 -0
  40. package/engine/internal/misc/get-terrain-z.lua +11 -0
  41. package/engine/internal/misc/player-local-handle.d.ts +2 -0
  42. package/engine/internal/misc/player-local-handle.lua +5 -0
  43. package/engine/internal/unit/ability.d.ts +35 -0
  44. package/engine/internal/unit/ability.lua +98 -9
  45. package/engine/internal/unit/allowed-targets.d.ts +1 -1
  46. package/engine/internal/unit/allowed-targets.lua +9 -1
  47. package/engine/internal/unit/main-selected.lua +12 -27
  48. package/engine/internal/unit/order.d.ts +20 -0
  49. package/engine/internal/unit/order.lua +136 -0
  50. package/engine/internal/unit+ability.lua +10 -1
  51. package/engine/internal/unit-missile-launch.lua +42 -14
  52. package/engine/internal/unit.d.ts +18 -8
  53. package/engine/internal/unit.lua +195 -87
  54. package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
  55. package/engine/object-data/auxiliary/armor-type.lua +46 -0
  56. package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
  57. package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
  58. package/engine/object-data/entry/ability-type.lua +5 -4
  59. package/engine/object-data/entry/unit-type.d.ts +11 -2
  60. package/engine/object-data/entry/unit-type.lua +59 -1
  61. package/engine/object-field/ability.d.ts +3 -3
  62. package/engine/object-field/ability.lua +7 -6
  63. package/engine/object-field/unit.d.ts +11 -0
  64. package/engine/object-field/unit.lua +34 -0
  65. package/engine/object-field.d.ts +8 -5
  66. package/engine/object-field.lua +90 -76
  67. package/engine/random.d.ts +9 -0
  68. package/engine/random.lua +13 -0
  69. package/engine/standard/fields/unit.d.ts +4 -0
  70. package/engine/standard/fields/unit.lua +7 -0
  71. package/engine/synchronization.d.ts +11 -0
  72. package/engine/synchronization.lua +77 -0
  73. package/engine/text-tag.d.ts +36 -2
  74. package/engine/text-tag.lua +249 -10
  75. package/engine/unit.d.ts +1 -0
  76. package/engine/unit.lua +1 -0
  77. package/net/socket.lua +1 -1
  78. package/objutil/buff.lua +1 -1
  79. package/package.json +2 -2
  80. package/patch-lualib.lua +1 -1
  81. package/utility/arrays.d.ts +1 -0
  82. package/utility/arrays.lua +8 -0
  83. package/utility/callback-array.d.ts +17 -0
  84. package/utility/callback-array.lua +61 -0
  85. package/utility/functions.d.ts +7 -0
  86. package/utility/functions.lua +12 -0
  87. package/utility/linked-set.d.ts +1 -0
  88. package/utility/linked-set.lua +19 -1
  89. package/utility/lua-maps.d.ts +12 -2
  90. package/utility/lua-maps.lua +37 -2
  91. package/utility/lua-sets.d.ts +1 -0
  92. package/utility/lua-sets.lua +4 -0
  93. package/utility/types.d.ts +3 -0
  94. package/core/types/order.d.ts +0 -25
  95. package/core/types/order.lua +0 -55
@@ -58,13 +58,14 @@ local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
58
58
  local nativeToAttackType = ____attack_2Dtype.nativeToAttackType
59
59
  local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
60
60
  local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
61
+ local ____attributes = require("attributes")
62
+ local isAttribute = ____attributes.isAttribute
63
+ local ____ability = require("engine.internal.item.ability")
64
+ local doUnitAbilityAction = ____ability.doUnitAbilityAction
61
65
  local match = string.match
62
66
  local ____tostring = _G.tostring
63
67
  local setUnitAnimation = SetUnitAnimation
64
- local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
65
68
  local setUnitAnimationByIndex = SetUnitAnimationByIndex
66
- local resetUnitAnimation = ResetUnitAnimation
67
- local queueUnitAnimation = QueueUnitAnimation
68
69
  local getUnitIntegerField = BlzGetUnitIntegerField
69
70
  local getUnitRealField = BlzGetUnitRealField
70
71
  local getHeroStr = GetHeroStr
@@ -124,10 +125,6 @@ local getOrderedUnit = GetOrderedUnit
124
125
  local getIssuedOrderId = GetIssuedOrderId
125
126
  local isUnitInvulnerable = BlzIsUnitInvulnerable
126
127
  local unitAlive = UnitAlive
127
- local unitAddType = UnitAddType
128
- local unitRemoveType = UnitRemoveType
129
- local isUnitIllusion = IsUnitIllusion
130
- local isUnitType = IsUnitType
131
128
  local isUnitAlly = IsUnitAlly
132
129
  local isUnitEnemy = IsUnitEnemy
133
130
  local getOwningPlayer = GetOwningPlayer
@@ -140,6 +137,7 @@ do
140
137
  UnitClassification.GROUND = UNIT_TYPE_GROUND
141
138
  UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
142
139
  UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
140
+ UnitClassification.WORKER = UNIT_TYPE_PEON
143
141
  UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
144
142
  UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
145
143
  UnitClassification.TAUREN = UNIT_TYPE_TAUREN
@@ -347,6 +345,9 @@ local function dispatchAbility(event)
347
345
  }
348
346
  )
349
347
  end
348
+ local function damagingEventPreventRetaliation(self)
349
+ self[0] = true
350
+ end
350
351
  local function damageEventPreventDeath(self, callback, ...)
351
352
  if self[0] ~= nil then
352
353
  return
@@ -409,6 +410,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
409
410
  self.unit = unit
410
411
  self.index = index
411
412
  end
413
+ __TS__SetDescriptor(
414
+ UnitWeapon.prototype,
415
+ "isEnabled",
416
+ {
417
+ get = function(self)
418
+ return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
419
+ end,
420
+ set = function(self, isEnabled)
421
+ BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
422
+ end
423
+ },
424
+ true
425
+ )
412
426
  __TS__SetDescriptor(
413
427
  UnitWeapon.prototype,
414
428
  "cooldown",
@@ -443,6 +457,19 @@ __TS__SetDescriptor(
443
457
  },
444
458
  true
445
459
  )
460
+ __TS__SetDescriptor(
461
+ UnitWeapon.prototype,
462
+ "allowedTargetCombatClassifications",
463
+ {
464
+ get = function(self)
465
+ return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
466
+ end,
467
+ set = function(self, allowedTargetCombatClassifications)
468
+ BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
469
+ end
470
+ },
471
+ true
472
+ )
446
473
  __TS__SetDescriptor(
447
474
  UnitWeapon.prototype,
448
475
  "damageBase",
@@ -649,15 +676,24 @@ end
649
676
  local nextSyncId = 1
650
677
  local unitBySyncId = setmetatable({}, {__mode = "v"})
651
678
  local damagingEventByTarget = setmetatable({}, {__mode = "k"})
679
+ local function addAbility(unit, abilityTypeId)
680
+ local ____unitAddAbility_result_0
681
+ if unitAddAbility(unit, abilityTypeId) then
682
+ ____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
683
+ else
684
+ ____unitAddAbility_result_0 = nil
685
+ end
686
+ return ____unitAddAbility_result_0
687
+ end
652
688
  ____exports.Unit = __TS__Class()
653
689
  local Unit = ____exports.Unit
654
690
  Unit.name = "Unit"
655
691
  __TS__ClassExtends(Unit, Handle)
656
692
  function Unit.prototype.____constructor(self, handle)
657
693
  Handle.prototype.____constructor(self, handle)
658
- local ____nextSyncId_0 = nextSyncId
659
- nextSyncId = ____nextSyncId_0 + 1
660
- self.syncId = ____nextSyncId_0
694
+ local ____nextSyncId_1 = nextSyncId
695
+ nextSyncId = ____nextSyncId_1 + 1
696
+ self.syncId = ____nextSyncId_1
661
697
  self._owner = Player:of(getOwningPlayer(handle))
662
698
  assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
663
699
  assert(unitAddAbility(handle, morphDetectAbilityId))
@@ -758,17 +794,17 @@ function Unit.prototype.addModifier(self, property, modifier)
758
794
  end}
759
795
  end
760
796
  function Unit.prototype.hasCombatClassification(self, combatClassification)
761
- local ____combatClassification_1 = combatClassification
762
- return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
797
+ local ____combatClassification_2 = combatClassification
798
+ return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
763
799
  end
764
800
  function Unit.prototype.addClassification(self, classification)
765
- return unitAddType(self.handle, classification)
801
+ return UnitAddType(self.handle, classification)
766
802
  end
767
803
  function Unit.prototype.removeClassification(self, classification)
768
- return unitRemoveType(self.handle, classification)
804
+ return UnitRemoveType(self.handle, classification)
769
805
  end
770
806
  function Unit.prototype.hasClassification(self, classification)
771
- return isUnitType(self.handle, classification)
807
+ return IsUnitType(self.handle, classification)
772
808
  end
773
809
  function Unit.prototype.isVisibleTo(self, player)
774
810
  return isUnitVisible(self.handle, player.handle)
@@ -777,13 +813,13 @@ function Unit.prototype.isInvisibleTo(self, player)
777
813
  return isUnitInvisible(self.handle, player.handle)
778
814
  end
779
815
  function Unit.prototype.isInRangeOf(self, x, y, range)
780
- local ____temp_2
816
+ local ____temp_3
781
817
  if type(x) == "number" then
782
- ____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
818
+ ____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
783
819
  else
784
- ____temp_2 = isUnitInRange(self.handle, x.handle, y)
820
+ ____temp_3 = isUnitInRange(self.handle, x.handle, y)
785
821
  end
786
- return ____temp_2
822
+ return ____temp_3
787
823
  end
788
824
  function Unit.prototype.isAllyOf(self, unit)
789
825
  return isUnitAlly(
@@ -801,16 +837,27 @@ function Unit.prototype.playAnimation(self, animation, rarity)
801
837
  if type(animation) == "number" then
802
838
  setUnitAnimationByIndex(self.handle, animation)
803
839
  elseif rarity then
804
- setUnitAnimationWithRarity(self.handle, animation, rarity)
840
+ SetUnitAnimationWithRarity(self.handle, animation, rarity)
805
841
  else
806
842
  setUnitAnimation(self.handle, animation)
807
843
  end
808
844
  end
809
845
  function Unit.prototype.resetAnimation(self)
810
- resetUnitAnimation(self.handle)
846
+ ResetUnitAnimation(self.handle)
811
847
  end
812
848
  function Unit.prototype.queueAnimation(self, animation)
813
- queueUnitAnimation(self.handle, animation)
849
+ QueueUnitAnimation(self.handle, animation)
850
+ end
851
+ function Unit.prototype.chooseWeapon(self, target)
852
+ local firstWeapon = self.firstWeapon
853
+ if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
854
+ return firstWeapon
855
+ end
856
+ local secondWeapon = self.secondWeapon
857
+ if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
858
+ return secondWeapon
859
+ end
860
+ return nil
814
861
  end
815
862
  function Unit.prototype.delayHealthChecks(self)
816
863
  self[103] = (self[103] or 0) + 1
@@ -830,14 +877,14 @@ function Unit.prototype.kill(self)
830
877
  killUnit(self.handle)
831
878
  end
832
879
  function Unit.prototype.revive(self, x, y, doEffect)
833
- local ____ReviveHero_5 = ReviveHero
834
- local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
835
- local ____doEffect_3 = doEffect
836
- if ____doEffect_3 == nil then
837
- ____doEffect_3 = false
880
+ local ____ReviveHero_6 = ReviveHero
881
+ local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
882
+ local ____doEffect_4 = doEffect
883
+ if ____doEffect_4 == nil then
884
+ ____doEffect_4 = false
838
885
  end
839
- __TS__SparseArrayPush(____array_4, ____doEffect_3)
840
- ____ReviveHero_5(__TS__SparseArraySpread(____array_4))
886
+ __TS__SparseArrayPush(____array_5, ____doEffect_4)
887
+ ____ReviveHero_6(__TS__SparseArraySpread(____array_5))
841
888
  end
842
889
  function Unit.prototype.healTarget(self, target, amount)
843
890
  if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
@@ -880,17 +927,16 @@ function Unit.prototype.itemInSlot(self, slot)
880
927
  return Item:of(unitItemInSlot(self.handle, slot))
881
928
  end
882
929
  function Unit.prototype.addAbility(self, abilityId)
883
- if unitAddAbility(self.handle, abilityId) then
884
- local ability = UnitAbility:of(
885
- checkNotNull(getUnitAbility(self.handle, abilityId)),
886
- abilityId,
887
- self
888
- )
930
+ local ability = UnitAbility:of(
931
+ doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
932
+ abilityId,
933
+ self
934
+ )
935
+ if ability ~= nil then
889
936
  local abilities = self.abilities
890
937
  abilities[#abilities + 1] = ability
891
- return ability
892
938
  end
893
- return nil
939
+ return ability
894
940
  end
895
941
  function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
896
942
  return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
@@ -904,31 +950,21 @@ end
904
950
  function Unit.prototype.hasAbility(self, abilityId)
905
951
  return getUnitAbilityLevel(self.handle, abilityId) > 0
906
952
  end
907
- function Unit.prototype.getAbilityById(self, abilityId)
908
- local handle = self.handle
909
- if unitAddAbility(handle, abilityId) then
910
- assert(unitRemoveAbility(handle, abilityId))
911
- return nil
912
- end
913
- return UnitAbility:of(
914
- getUnitAbility(self.handle, abilityId),
915
- abilityId,
916
- self
917
- )
953
+ function Unit.prototype.getAbility(self, abilityId)
954
+ local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
955
+ return UnitAbility:of(ability, abilityId, self)
918
956
  end
919
- function Unit.prototype.removeAbility(self, abilityId)
920
- if unitRemoveAbility(self.handle, abilityId) then
921
- local abilities = self.abilities
922
- for i = 1, #abilities do
923
- if abilities[i].typeId == abilityId then
924
- abilities[i]:destroy()
925
- tremove(abilities, i)
926
- return true
927
- end
957
+ function Unit.prototype.removeAbility(self, abilityTypeId)
958
+ local abilities = self.abilities
959
+ for i = 1, #abilities do
960
+ if abilities[i].typeId == abilityTypeId then
961
+ local ability = abilities[i]
962
+ tremove(abilities, i)
963
+ ability:destroy()
964
+ return true
928
965
  end
929
- return true
930
966
  end
931
- return false
967
+ return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
932
968
  end
933
969
  function Unit.prototype.hideAbility(self, abilityId, flag)
934
970
  BlzUnitHideAbility(self.handle, abilityId, flag)
@@ -942,6 +978,21 @@ end
942
978
  function Unit.prototype.endAbilityCooldown(self, abilityId)
943
979
  BlzEndUnitAbilityCooldown(self.handle, abilityId)
944
980
  end
981
+ function Unit.prototype.interruptMovement(self)
982
+ local handle = self.handle
983
+ unitDisableAbility(
984
+ handle,
985
+ fourCC("Amov"),
986
+ true,
987
+ false
988
+ )
989
+ unitDisableAbility(
990
+ handle,
991
+ fourCC("Amov"),
992
+ false,
993
+ false
994
+ )
995
+ end
945
996
  function Unit.prototype.interruptAttack(self)
946
997
  unitInterruptAttack(self.handle)
947
998
  end
@@ -1215,7 +1266,7 @@ __TS__SetDescriptor(
1215
1266
  Unit.prototype,
1216
1267
  "isIllusion",
1217
1268
  {get = function(self)
1218
- return isUnitIllusion(self.handle)
1269
+ return IsUnitIllusion(self.handle)
1219
1270
  end},
1220
1271
  true
1221
1272
  )
@@ -1438,13 +1489,13 @@ __TS__SetDescriptor(
1438
1489
  end,
1439
1490
  set = function(self, isTeamGlowVisible)
1440
1491
  BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
1441
- local ____temp_6
1492
+ local ____temp_7
1442
1493
  if not isTeamGlowVisible then
1443
- ____temp_6 = true
1494
+ ____temp_7 = true
1444
1495
  else
1445
- ____temp_6 = nil
1496
+ ____temp_7 = nil
1446
1497
  end
1447
- self[106] = ____temp_6
1498
+ self[106] = ____temp_7
1448
1499
  end
1449
1500
  },
1450
1501
  true
@@ -2048,6 +2099,14 @@ __TS__SetDescriptor(
2048
2099
  end},
2049
2100
  true
2050
2101
  )
2102
+ __TS__SetDescriptor(
2103
+ Unit.prototype,
2104
+ "targetAcquiredEvent",
2105
+ {get = function(self)
2106
+ return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
2107
+ end},
2108
+ true
2109
+ )
2051
2110
  __TS__SetDescriptor(
2052
2111
  Unit.prototype,
2053
2112
  "onSelect",
@@ -2183,25 +2242,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
2183
2242
  InitializingEvent,
2184
2243
  function(event)
2185
2244
  local function listener(unit, id)
2186
- local ____GetSpellTargetUnit_result_9
2245
+ local ____GetSpellTargetUnit_result_10
2187
2246
  if GetSpellTargetUnit() then
2188
- ____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
2247
+ ____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
2189
2248
  else
2190
- local ____GetSpellTargetItem_result_8
2249
+ local ____GetSpellTargetItem_result_9
2191
2250
  if GetSpellTargetItem() then
2192
- ____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
2251
+ ____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
2193
2252
  else
2194
- local ____GetSpellTargetDestructable_result_7
2253
+ local ____GetSpellTargetDestructable_result_8
2195
2254
  if GetSpellTargetDestructable() then
2196
- ____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
2255
+ ____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
2197
2256
  else
2198
- ____GetSpellTargetDestructable_result_7 = nil
2257
+ ____GetSpellTargetDestructable_result_8 = nil
2199
2258
  end
2200
- ____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
2259
+ ____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
2201
2260
  end
2202
- ____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
2261
+ ____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
2203
2262
  end
2204
- local target = ____GetSpellTargetUnit_result_9
2263
+ local target = ____GetSpellTargetUnit_result_10
2205
2264
  if target then
2206
2265
  invoke(event, unit, id, target)
2207
2266
  end
@@ -2420,15 +2479,11 @@ Unit.onDamaging = (function()
2420
2479
  metadata = metadata,
2421
2480
  isAttack = BlzGetEventIsAttack(),
2422
2481
  originalAmount = GetEventDamage(),
2423
- originalMetadata = metadata
2482
+ originalMetadata = metadata,
2483
+ preventRetaliation = damagingEventPreventRetaliation
2424
2484
  }
2425
2485
  if data.isAttack and source then
2426
- 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
2427
- if weapon == -1 then
2428
- local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
2429
- weapon = 0
2430
- end
2431
- data.weapon = assert(source.weapons[weapon + 1])
2486
+ data.weapon = source:chooseWeapon(target)
2432
2487
  end
2433
2488
  if not data.isAttack or not source or not source._attackHandlers then
2434
2489
  invoke(
@@ -2449,6 +2504,20 @@ Unit.onDamaging = (function()
2449
2504
  }
2450
2505
  )
2451
2506
  )
2507
+ if data[0] and source then
2508
+ local sourceOwner = source.owner.handle
2509
+ data[1] = sourceOwner
2510
+ local targetOwner = target.owner.handle
2511
+ data[2] = targetOwner
2512
+ if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
2513
+ SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
2514
+ data[3] = true
2515
+ end
2516
+ if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
2517
+ SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
2518
+ data[4] = true
2519
+ end
2520
+ end
2452
2521
  damagingEventByTarget[target] = data
2453
2522
  return
2454
2523
  end
@@ -2526,12 +2595,32 @@ Unit.onDamage = __TS__New(
2526
2595
  originalMetadata = damagingEvent and damagingEvent.originalMetadata,
2527
2596
  preventDeath = damageEventPreventDeath
2528
2597
  }
2598
+ if damagingEvent then
2599
+ for key, value in pairs(damagingEvent) do
2600
+ if isAttribute(key) then
2601
+ data[key] = value
2602
+ end
2603
+ end
2604
+ local sourceOwner = damagingEvent[1]
2605
+ if sourceOwner then
2606
+ local targetOwner = damagingEvent[2]
2607
+ if damagingEvent[3] then
2608
+ SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
2609
+ end
2610
+ if damagingEvent[4] then
2611
+ SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
2612
+ end
2613
+ end
2614
+ end
2529
2615
  local evData = setmetatable(
2530
2616
  {},
2531
2617
  {
2532
2618
  __index = data,
2533
2619
  __newindex = function(self, key, value)
2534
- damageSetters[key](value)
2620
+ local damageSetter = damageSetters[key]
2621
+ if damageSetter ~= nil then
2622
+ damageSetter(value)
2623
+ end
2535
2624
  data[key] = value
2536
2625
  end
2537
2626
  }
@@ -2589,10 +2678,14 @@ Unit.itemPickedUpEvent = __TS__New(
2589
2678
  ____exports.UnitTriggerEvent,
2590
2679
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2591
2680
  function()
2592
- local unit = getTriggerUnit()
2593
- local item = getManipulatedItem()
2594
- if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2595
- return ____exports.Unit:of(unit), Item:of(item)
2681
+ local unitHandle = getTriggerUnit()
2682
+ local itemHandle = getManipulatedItem()
2683
+ if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
2684
+ local unit = ____exports.Unit:of(unitHandle)
2685
+ local item = Item:of(itemHandle)
2686
+ if item.owner ~= unit then
2687
+ return unit, item
2688
+ end
2596
2689
  end
2597
2690
  return IgnoreEvent
2598
2691
  end
@@ -2612,7 +2705,22 @@ Unit.itemUsedEvent = __TS__New(
2612
2705
  Unit.itemStackedEvent = __TS__New(
2613
2706
  ____exports.UnitTriggerEvent,
2614
2707
  EVENT_PLAYER_UNIT_STACK_ITEM,
2615
- function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2708
+ function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
2709
+ )
2710
+ __TS__ObjectDefineProperty(
2711
+ Unit,
2712
+ "itemChargesChangedEvent",
2713
+ {get = function(self)
2714
+ local event = __TS__New(Event)
2715
+ Item.chargesChangedEvent:addListener(function(item)
2716
+ local unit = item.owner
2717
+ if unit ~= nil then
2718
+ invoke(event, unit, item)
2719
+ end
2720
+ end)
2721
+ rawset(self, "itemChargesChangedEvent", event)
2722
+ return event
2723
+ end}
2616
2724
  )
2617
2725
  __TS__ObjectDefineProperty(
2618
2726
  Unit,
@@ -0,0 +1,11 @@
1
+ /** @noSelfInFile */
2
+ export declare const enum ArmorType {
3
+ LIGHT = 0,
4
+ MEDIUM = 1,
5
+ HEAVY = 2,
6
+ FORTIFIED = 3,
7
+ NORMAL = 4,
8
+ HERO = 5,
9
+ DIVINE = 6,
10
+ UNARMORED = 7
11
+ }
@@ -0,0 +1,46 @@
1
+ local ____exports = {}
2
+ local ____records = require("utility.records")
3
+ local invertRecord = ____records.invertRecord
4
+ local stringByArmorType = {
5
+ [0] = "small",
6
+ [1] = "medium",
7
+ [2] = "large",
8
+ [3] = "fort",
9
+ [4] = "normal",
10
+ [5] = "hero",
11
+ [6] = "divine",
12
+ [7] = "none"
13
+ }
14
+ local armorTypeByString = invertRecord(stringByArmorType)
15
+ local nativeByArmorType = {
16
+ [0] = DEFENSE_TYPE_LIGHT,
17
+ [1] = DEFENSE_TYPE_MEDIUM,
18
+ [2] = DEFENSE_TYPE_LARGE,
19
+ [3] = DEFENSE_TYPE_FORT,
20
+ [4] = DEFENSE_TYPE_NORMAL,
21
+ [5] = DEFENSE_TYPE_HERO,
22
+ [6] = DEFENSE_TYPE_DIVINE,
23
+ [7] = DEFENSE_TYPE_NONE
24
+ }
25
+ local armorTypeByNative = invertRecord(nativeByArmorType)
26
+ ---
27
+ -- @internal For use by internal systems only.
28
+ ____exports.armorTypeToString = function(armorType)
29
+ return stringByArmorType[armorType]
30
+ end
31
+ ---
32
+ -- @internal For use by internal systems only.
33
+ ____exports.stringToArmorType = function(____string)
34
+ return armorTypeByString[____string] or 7
35
+ end
36
+ ---
37
+ -- @internal For use by internal systems only.
38
+ ____exports.armorTypeToNative = function(armorType)
39
+ return nativeByArmorType[armorType]
40
+ end
41
+ ---
42
+ -- @internal For use by internal systems only.
43
+ ____exports.nativeToArmorType = function(armorType)
44
+ return armorTypeByNative[armorType]
45
+ end
46
+ return ____exports
@@ -0,0 +1,8 @@
1
+ /** @noSelfInFile */
2
+ import { AbilityType, AbilityTypeId } from "../ability-type";
3
+ import { ObjectDataEntryLevelFieldValueSupplier } from "../../entry";
4
+ export declare class PermanentInvisibilityAbilityType extends AbilityType {
5
+ static readonly BASE_ID: AbilityTypeId;
6
+ get shouldAutoAcquireAttackTargets(): boolean[];
7
+ set shouldAutoAcquireAttackTargets(shouldAutoAcquireAttackTargets: ObjectDataEntryLevelFieldValueSupplier<boolean>);
8
+ }
@@ -0,0 +1,26 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
+ local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
5
+ local ____exports = {}
6
+ local ____ability_2Dtype = require("engine.object-data.entry.ability-type")
7
+ local AbilityType = ____ability_2Dtype.AbilityType
8
+ ____exports.PermanentInvisibilityAbilityType = __TS__Class()
9
+ local PermanentInvisibilityAbilityType = ____exports.PermanentInvisibilityAbilityType
10
+ PermanentInvisibilityAbilityType.name = "PermanentInvisibilityAbilityType"
11
+ __TS__ClassExtends(PermanentInvisibilityAbilityType, AbilityType)
12
+ PermanentInvisibilityAbilityType.BASE_ID = fourCC("Apiv")
13
+ __TS__SetDescriptor(
14
+ PermanentInvisibilityAbilityType.prototype,
15
+ "shouldAutoAcquireAttackTargets",
16
+ {
17
+ get = function(self)
18
+ return self:getBooleanLevelField("Gho1")
19
+ end,
20
+ set = function(self, shouldAutoAcquireAttackTargets)
21
+ self:setBooleanLevelField("Gho1", shouldAutoAcquireAttackTargets)
22
+ end
23
+ },
24
+ true
25
+ )
26
+ return ____exports
@@ -38,6 +38,8 @@ local ____sound = require("core.types.sound")
38
38
  local isSoundLabelCustom = ____sound.isSoundLabelCustom
39
39
  local Sound3D = ____sound.Sound3D
40
40
  local SoundSettings = ____sound.SoundSettings
41
+ local ____lua_2Dsets = require("utility.lua-sets")
42
+ local luaSetOf = ____lua_2Dsets.luaSetOf
41
43
  local castAnimationFQNByAbilityTypeId = {}
42
44
  local isButtonVisibleFalseAbilityTypes = {}
43
45
  local casterCastingEffectPresetsByAbilityTypeId = {}
@@ -979,9 +981,7 @@ for abilityTypeId, animationFQN in pairs(postcompile(function() return castAnima
979
981
  4,
980
982
  function(caster, ability)
981
983
  if ability:getField(ABILITY_RLF_CASTING_TIME) ~= 0 then
982
- Timer:run(function()
983
- caster:playAnimation(animationFQN)
984
- end)
984
+ Timer:run(caster, "playAnimation", animationFQN)
985
985
  end
986
986
  end
987
987
  )
@@ -1006,9 +1006,10 @@ for abilityTypeId, soundPresetId in pairs(postcompile(function() return targetEf
1006
1006
  )
1007
1007
  end
1008
1008
  end
1009
+ local unsupportedEffectSoundAbilityTypeIds = luaSetOf(fourCC("AAns"))
1009
1010
  Unit.abilityChannelingStartEvent:addListener(function(caster, ability)
1010
1011
  local soundPresetId = ability:getField(ABILITY_SF_EFFECT_SOUND)
1011
- if isSoundLabelCustom(soundPresetId) then
1012
+ if isSoundLabelCustom(soundPresetId) or soundPresetId ~= "" and unsupportedEffectSoundAbilityTypeIds[ability.parentTypeId] ~= nil then
1012
1013
  Sound3D:playFromLabel(soundPresetId, SoundSettings.Ability, caster)
1013
1014
  end
1014
1015
  end)
@@ -13,6 +13,7 @@ import type { AbilityTypeId } from "./ability-type";
13
13
  import type { UpgradeId } from "./upgrade";
14
14
  import { AnimationQualifier } from "../auxiliary/animation-qualifier";
15
15
  import { AttackType } from "../auxiliary/attack-type";
16
+ import { ArmorType } from "../auxiliary/armor-type";
16
17
  export type UnitTypeId = ObjectDataEntryId & number & {
17
18
  readonly __unitTypeId: unique symbol;
18
19
  };
@@ -144,6 +145,8 @@ export declare abstract class UnitType<Id extends UnitTypeId = UnitTypeId> exten
144
145
  set runSpeedSD(runSpeedSD: number);
145
146
  get runSpeedHD(): number;
146
147
  set runSpeedHD(runSpeedHD: number);
148
+ get selectionCircleHeight(): number;
149
+ set selectionCircleHeight(height: number);
147
150
  get selectionCircleScale(): number;
148
151
  set selectionCircleScale(selectionCircleScale: number);
149
152
  get selectionCircleScaleSD(): number;
@@ -182,16 +185,20 @@ export declare abstract class UnitType<Id extends UnitTypeId = UnitTypeId> exten
182
185
  set walkSpeedSD(walkSpeedSD: number);
183
186
  get walkSpeedHD(): number;
184
187
  set walkSpeedHD(walkSpeedHD: number);
188
+ get armor(): number;
189
+ set armor(armor: number);
185
190
  get armorSoundType(): ArmorSoundType;
186
191
  set armorSoundType(armorSoundType: ArmorSoundType);
187
192
  get armorSoundTypeSD(): ArmorSoundType;
188
193
  set armorSoundTypeSD(armorSoundTypeSD: ArmorSoundType);
189
194
  get armorSoundTypeHD(): ArmorSoundType;
190
195
  set armorSoundTypeHD(armorSoundTypeHD: ArmorSoundType);
196
+ get armorType(): ArmorType;
197
+ set armorType(armorType: ArmorType);
191
198
  get combatClassifications(): CombatClassifications;
192
199
  set combatClassifications(combatClassifications: CombatClassifications);
193
- get unitClassifications(): UnitClassifications;
194
- set unitClassifications(unitClassifications: UnitClassifications);
200
+ get classifications(): UnitClassifications;
201
+ set classifications(unitClassifications: UnitClassifications);
195
202
  get weapons(): TupleOf<UnitTypeWeapon, 2>;
196
203
  get firstWeapon(): UnitTypeWeapon;
197
204
  get secondWeapon(): UnitTypeWeapon;
@@ -225,6 +232,8 @@ export declare abstract class UnitType<Id extends UnitTypeId = UnitTypeId> exten
225
232
  set goldCost(goldCost: number);
226
233
  get healthRegenerationRate(): number;
227
234
  set healthRegenerationRate(healthRegenerationRate: number);
235
+ get level(): number;
236
+ set level(level: number);
228
237
  get manaRegenerationRate(): number;
229
238
  set manaRegenerationRate(manaRegenerationRate: number);
230
239
  get maximumHealth(): number;