warscript 0.0.1-dev.90f1d49 → 0.0.1-dev.91a4dce

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 (93) hide show
  1. package/attributes.d.ts +1 -2
  2. package/attributes.lua +9 -0
  3. package/core/types/frame.lua +24 -21
  4. package/core/types/player.d.ts +15 -0
  5. package/core/types/player.lua +40 -7
  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/emulate-impact.d.ts +1 -1
  17. package/engine/behaviour/ability/emulate-impact.lua +11 -3
  18. package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
  19. package/engine/behaviour/ability/remove-buffs.lua +21 -0
  20. package/engine/behaviour/ability/restore-mana.d.ts +1 -1
  21. package/engine/behaviour/ability/restore-mana.lua +6 -6
  22. package/engine/behaviour/ability.lua +8 -17
  23. package/engine/behaviour/unit/stun-immunity.d.ts +7 -3
  24. package/engine/behaviour/unit/stun-immunity.lua +52 -27
  25. package/engine/behaviour/unit.d.ts +33 -1
  26. package/engine/behaviour/unit.lua +190 -4
  27. package/engine/buff.d.ts +2 -4
  28. package/engine/buff.lua +68 -83
  29. package/engine/internal/ability.d.ts +7 -1
  30. package/engine/internal/ability.lua +49 -9
  31. package/engine/internal/item/ability.lua +63 -11
  32. package/engine/internal/item+owner.lua +12 -6
  33. package/engine/internal/item.d.ts +16 -16
  34. package/engine/internal/item.lua +135 -49
  35. package/engine/internal/misc/frame-coordinates.d.ts +2 -0
  36. package/engine/internal/misc/frame-coordinates.lua +21 -0
  37. package/engine/internal/misc/get-terrain-z.d.ts +2 -0
  38. package/engine/internal/misc/get-terrain-z.lua +11 -0
  39. package/engine/internal/misc/player-local-handle.d.ts +2 -0
  40. package/engine/internal/misc/player-local-handle.lua +5 -0
  41. package/engine/internal/unit/ability.d.ts +35 -0
  42. package/engine/internal/unit/ability.lua +98 -9
  43. package/engine/internal/unit/allowed-targets.d.ts +1 -1
  44. package/engine/internal/unit/allowed-targets.lua +9 -1
  45. package/engine/internal/unit/main-selected.lua +12 -27
  46. package/engine/internal/unit/order.d.ts +20 -0
  47. package/engine/internal/unit/order.lua +136 -0
  48. package/engine/internal/unit+ability.lua +10 -1
  49. package/engine/internal/unit-missile-launch.lua +42 -14
  50. package/engine/internal/unit.d.ts +16 -7
  51. package/engine/internal/unit.lua +182 -86
  52. package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
  53. package/engine/object-data/auxiliary/armor-type.lua +46 -0
  54. package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
  55. package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
  56. package/engine/object-data/entry/ability-type.lua +5 -4
  57. package/engine/object-data/entry/unit-type.d.ts +11 -2
  58. package/engine/object-data/entry/unit-type.lua +59 -1
  59. package/engine/object-field/ability.d.ts +3 -3
  60. package/engine/object-field/ability.lua +7 -6
  61. package/engine/object-field/unit.d.ts +11 -0
  62. package/engine/object-field/unit.lua +34 -0
  63. package/engine/object-field.d.ts +8 -5
  64. package/engine/object-field.lua +90 -76
  65. package/engine/random.d.ts +9 -0
  66. package/engine/random.lua +13 -0
  67. package/engine/standard/fields/unit.d.ts +4 -0
  68. package/engine/standard/fields/unit.lua +7 -0
  69. package/engine/synchronization.d.ts +11 -0
  70. package/engine/synchronization.lua +77 -0
  71. package/engine/text-tag.d.ts +36 -2
  72. package/engine/text-tag.lua +249 -10
  73. package/engine/unit.d.ts +1 -0
  74. package/engine/unit.lua +1 -0
  75. package/net/socket.lua +1 -1
  76. package/objutil/buff.lua +1 -1
  77. package/package.json +2 -2
  78. package/patch-lualib.lua +1 -1
  79. package/utility/arrays.d.ts +1 -0
  80. package/utility/arrays.lua +8 -0
  81. package/utility/callback-array.d.ts +17 -0
  82. package/utility/callback-array.lua +61 -0
  83. package/utility/functions.d.ts +7 -0
  84. package/utility/functions.lua +12 -0
  85. package/utility/linked-set.d.ts +1 -0
  86. package/utility/linked-set.lua +19 -1
  87. package/utility/lua-maps.d.ts +12 -2
  88. package/utility/lua-maps.lua +37 -2
  89. package/utility/lua-sets.d.ts +1 -0
  90. package/utility/lua-sets.lua +4 -0
  91. package/utility/types.d.ts +3 -0
  92. package/core/types/order.d.ts +0 -25
  93. package/core/types/order.lua +0 -55
@@ -60,13 +60,12 @@ local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage
60
60
  local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
61
61
  local ____attributes = require("attributes")
62
62
  local isAttribute = ____attributes.isAttribute
63
+ local ____ability = require("engine.internal.item.ability")
64
+ local doUnitAbilityAction = ____ability.doUnitAbilityAction
63
65
  local match = string.match
64
66
  local ____tostring = _G.tostring
65
67
  local setUnitAnimation = SetUnitAnimation
66
- local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
67
68
  local setUnitAnimationByIndex = SetUnitAnimationByIndex
68
- local resetUnitAnimation = ResetUnitAnimation
69
- local queueUnitAnimation = QueueUnitAnimation
70
69
  local getUnitIntegerField = BlzGetUnitIntegerField
71
70
  local getUnitRealField = BlzGetUnitRealField
72
71
  local getHeroStr = GetHeroStr
@@ -126,10 +125,6 @@ local getOrderedUnit = GetOrderedUnit
126
125
  local getIssuedOrderId = GetIssuedOrderId
127
126
  local isUnitInvulnerable = BlzIsUnitInvulnerable
128
127
  local unitAlive = UnitAlive
129
- local unitAddType = UnitAddType
130
- local unitRemoveType = UnitRemoveType
131
- local isUnitIllusion = IsUnitIllusion
132
- local isUnitType = IsUnitType
133
128
  local isUnitAlly = IsUnitAlly
134
129
  local isUnitEnemy = IsUnitEnemy
135
130
  local getOwningPlayer = GetOwningPlayer
@@ -142,6 +137,7 @@ do
142
137
  UnitClassification.GROUND = UNIT_TYPE_GROUND
143
138
  UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
144
139
  UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
140
+ UnitClassification.WORKER = UNIT_TYPE_PEON
145
141
  UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
146
142
  UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
147
143
  UnitClassification.TAUREN = UNIT_TYPE_TAUREN
@@ -349,6 +345,9 @@ local function dispatchAbility(event)
349
345
  }
350
346
  )
351
347
  end
348
+ local function damagingEventPreventRetaliation(self)
349
+ self[0] = true
350
+ end
352
351
  local function damageEventPreventDeath(self, callback, ...)
353
352
  if self[0] ~= nil then
354
353
  return
@@ -411,6 +410,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
411
410
  self.unit = unit
412
411
  self.index = index
413
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
+ )
414
426
  __TS__SetDescriptor(
415
427
  UnitWeapon.prototype,
416
428
  "cooldown",
@@ -445,6 +457,19 @@ __TS__SetDescriptor(
445
457
  },
446
458
  true
447
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
+ )
448
473
  __TS__SetDescriptor(
449
474
  UnitWeapon.prototype,
450
475
  "damageBase",
@@ -651,15 +676,24 @@ end
651
676
  local nextSyncId = 1
652
677
  local unitBySyncId = setmetatable({}, {__mode = "v"})
653
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
654
688
  ____exports.Unit = __TS__Class()
655
689
  local Unit = ____exports.Unit
656
690
  Unit.name = "Unit"
657
691
  __TS__ClassExtends(Unit, Handle)
658
692
  function Unit.prototype.____constructor(self, handle)
659
693
  Handle.prototype.____constructor(self, handle)
660
- local ____nextSyncId_0 = nextSyncId
661
- nextSyncId = ____nextSyncId_0 + 1
662
- self.syncId = ____nextSyncId_0
694
+ local ____nextSyncId_1 = nextSyncId
695
+ nextSyncId = ____nextSyncId_1 + 1
696
+ self.syncId = ____nextSyncId_1
663
697
  self._owner = Player:of(getOwningPlayer(handle))
664
698
  assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
665
699
  assert(unitAddAbility(handle, morphDetectAbilityId))
@@ -760,17 +794,17 @@ function Unit.prototype.addModifier(self, property, modifier)
760
794
  end}
761
795
  end
762
796
  function Unit.prototype.hasCombatClassification(self, combatClassification)
763
- local ____combatClassification_1 = combatClassification
764
- 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
765
799
  end
766
800
  function Unit.prototype.addClassification(self, classification)
767
- return unitAddType(self.handle, classification)
801
+ return UnitAddType(self.handle, classification)
768
802
  end
769
803
  function Unit.prototype.removeClassification(self, classification)
770
- return unitRemoveType(self.handle, classification)
804
+ return UnitRemoveType(self.handle, classification)
771
805
  end
772
806
  function Unit.prototype.hasClassification(self, classification)
773
- return isUnitType(self.handle, classification)
807
+ return IsUnitType(self.handle, classification)
774
808
  end
775
809
  function Unit.prototype.isVisibleTo(self, player)
776
810
  return isUnitVisible(self.handle, player.handle)
@@ -779,13 +813,13 @@ function Unit.prototype.isInvisibleTo(self, player)
779
813
  return isUnitInvisible(self.handle, player.handle)
780
814
  end
781
815
  function Unit.prototype.isInRangeOf(self, x, y, range)
782
- local ____temp_2
816
+ local ____temp_3
783
817
  if type(x) == "number" then
784
- ____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
818
+ ____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
785
819
  else
786
- ____temp_2 = isUnitInRange(self.handle, x.handle, y)
820
+ ____temp_3 = isUnitInRange(self.handle, x.handle, y)
787
821
  end
788
- return ____temp_2
822
+ return ____temp_3
789
823
  end
790
824
  function Unit.prototype.isAllyOf(self, unit)
791
825
  return isUnitAlly(
@@ -803,16 +837,27 @@ function Unit.prototype.playAnimation(self, animation, rarity)
803
837
  if type(animation) == "number" then
804
838
  setUnitAnimationByIndex(self.handle, animation)
805
839
  elseif rarity then
806
- setUnitAnimationWithRarity(self.handle, animation, rarity)
840
+ SetUnitAnimationWithRarity(self.handle, animation, rarity)
807
841
  else
808
842
  setUnitAnimation(self.handle, animation)
809
843
  end
810
844
  end
811
845
  function Unit.prototype.resetAnimation(self)
812
- resetUnitAnimation(self.handle)
846
+ ResetUnitAnimation(self.handle)
813
847
  end
814
848
  function Unit.prototype.queueAnimation(self, animation)
815
- 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
816
861
  end
817
862
  function Unit.prototype.delayHealthChecks(self)
818
863
  self[103] = (self[103] or 0) + 1
@@ -832,14 +877,14 @@ function Unit.prototype.kill(self)
832
877
  killUnit(self.handle)
833
878
  end
834
879
  function Unit.prototype.revive(self, x, y, doEffect)
835
- local ____ReviveHero_5 = ReviveHero
836
- local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
837
- local ____doEffect_3 = doEffect
838
- if ____doEffect_3 == nil then
839
- ____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
840
885
  end
841
- __TS__SparseArrayPush(____array_4, ____doEffect_3)
842
- ____ReviveHero_5(__TS__SparseArraySpread(____array_4))
886
+ __TS__SparseArrayPush(____array_5, ____doEffect_4)
887
+ ____ReviveHero_6(__TS__SparseArraySpread(____array_5))
843
888
  end
844
889
  function Unit.prototype.healTarget(self, target, amount)
845
890
  if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
@@ -882,17 +927,16 @@ function Unit.prototype.itemInSlot(self, slot)
882
927
  return Item:of(unitItemInSlot(self.handle, slot))
883
928
  end
884
929
  function Unit.prototype.addAbility(self, abilityId)
885
- if unitAddAbility(self.handle, abilityId) then
886
- local ability = UnitAbility:of(
887
- checkNotNull(getUnitAbility(self.handle, abilityId)),
888
- abilityId,
889
- self
890
- )
930
+ local ability = UnitAbility:of(
931
+ doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
932
+ abilityId,
933
+ self
934
+ )
935
+ if ability ~= nil then
891
936
  local abilities = self.abilities
892
937
  abilities[#abilities + 1] = ability
893
- return ability
894
938
  end
895
- return nil
939
+ return ability
896
940
  end
897
941
  function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
898
942
  return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
@@ -906,31 +950,21 @@ end
906
950
  function Unit.prototype.hasAbility(self, abilityId)
907
951
  return getUnitAbilityLevel(self.handle, abilityId) > 0
908
952
  end
909
- function Unit.prototype.getAbilityById(self, abilityId)
910
- local handle = self.handle
911
- if unitAddAbility(handle, abilityId) then
912
- assert(unitRemoveAbility(handle, abilityId))
913
- return nil
914
- end
915
- return UnitAbility:of(
916
- getUnitAbility(self.handle, abilityId),
917
- abilityId,
918
- self
919
- )
953
+ function Unit.prototype.getAbility(self, abilityId)
954
+ local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
955
+ return UnitAbility:of(ability, abilityId, self)
920
956
  end
921
- function Unit.prototype.removeAbility(self, abilityId)
922
- if unitRemoveAbility(self.handle, abilityId) then
923
- local abilities = self.abilities
924
- for i = 1, #abilities do
925
- if abilities[i].typeId == abilityId then
926
- abilities[i]:destroy()
927
- tremove(abilities, i)
928
- return true
929
- 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
930
965
  end
931
- return true
932
966
  end
933
- return false
967
+ return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
934
968
  end
935
969
  function Unit.prototype.hideAbility(self, abilityId, flag)
936
970
  BlzUnitHideAbility(self.handle, abilityId, flag)
@@ -944,6 +978,21 @@ end
944
978
  function Unit.prototype.endAbilityCooldown(self, abilityId)
945
979
  BlzEndUnitAbilityCooldown(self.handle, abilityId)
946
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
947
996
  function Unit.prototype.interruptAttack(self)
948
997
  unitInterruptAttack(self.handle)
949
998
  end
@@ -1217,7 +1266,7 @@ __TS__SetDescriptor(
1217
1266
  Unit.prototype,
1218
1267
  "isIllusion",
1219
1268
  {get = function(self)
1220
- return isUnitIllusion(self.handle)
1269
+ return IsUnitIllusion(self.handle)
1221
1270
  end},
1222
1271
  true
1223
1272
  )
@@ -1440,13 +1489,13 @@ __TS__SetDescriptor(
1440
1489
  end,
1441
1490
  set = function(self, isTeamGlowVisible)
1442
1491
  BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
1443
- local ____temp_6
1492
+ local ____temp_7
1444
1493
  if not isTeamGlowVisible then
1445
- ____temp_6 = true
1494
+ ____temp_7 = true
1446
1495
  else
1447
- ____temp_6 = nil
1496
+ ____temp_7 = nil
1448
1497
  end
1449
- self[106] = ____temp_6
1498
+ self[106] = ____temp_7
1450
1499
  end
1451
1500
  },
1452
1501
  true
@@ -2050,6 +2099,14 @@ __TS__SetDescriptor(
2050
2099
  end},
2051
2100
  true
2052
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
+ )
2053
2110
  __TS__SetDescriptor(
2054
2111
  Unit.prototype,
2055
2112
  "onSelect",
@@ -2185,25 +2242,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
2185
2242
  InitializingEvent,
2186
2243
  function(event)
2187
2244
  local function listener(unit, id)
2188
- local ____GetSpellTargetUnit_result_9
2245
+ local ____GetSpellTargetUnit_result_10
2189
2246
  if GetSpellTargetUnit() then
2190
- ____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
2247
+ ____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
2191
2248
  else
2192
- local ____GetSpellTargetItem_result_8
2249
+ local ____GetSpellTargetItem_result_9
2193
2250
  if GetSpellTargetItem() then
2194
- ____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
2251
+ ____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
2195
2252
  else
2196
- local ____GetSpellTargetDestructable_result_7
2253
+ local ____GetSpellTargetDestructable_result_8
2197
2254
  if GetSpellTargetDestructable() then
2198
- ____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
2255
+ ____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
2199
2256
  else
2200
- ____GetSpellTargetDestructable_result_7 = nil
2257
+ ____GetSpellTargetDestructable_result_8 = nil
2201
2258
  end
2202
- ____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
2259
+ ____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
2203
2260
  end
2204
- ____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
2261
+ ____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
2205
2262
  end
2206
- local target = ____GetSpellTargetUnit_result_9
2263
+ local target = ____GetSpellTargetUnit_result_10
2207
2264
  if target then
2208
2265
  invoke(event, unit, id, target)
2209
2266
  end
@@ -2422,15 +2479,11 @@ Unit.onDamaging = (function()
2422
2479
  metadata = metadata,
2423
2480
  isAttack = BlzGetEventIsAttack(),
2424
2481
  originalAmount = GetEventDamage(),
2425
- originalMetadata = metadata
2482
+ originalMetadata = metadata,
2483
+ preventRetaliation = damagingEventPreventRetaliation
2426
2484
  }
2427
2485
  if data.isAttack and source then
2428
- 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
2429
- if weapon == -1 then
2430
- local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
2431
- weapon = 0
2432
- end
2433
- data.weapon = assert(source.weapons[weapon + 1])
2486
+ data.weapon = source:chooseWeapon(target)
2434
2487
  end
2435
2488
  if not data.isAttack or not source or not source._attackHandlers then
2436
2489
  invoke(
@@ -2451,6 +2504,20 @@ Unit.onDamaging = (function()
2451
2504
  }
2452
2505
  )
2453
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
2454
2521
  damagingEventByTarget[target] = data
2455
2522
  return
2456
2523
  end
@@ -2534,6 +2601,16 @@ Unit.onDamage = __TS__New(
2534
2601
  data[key] = value
2535
2602
  end
2536
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
2537
2614
  end
2538
2615
  local evData = setmetatable(
2539
2616
  {},
@@ -2601,10 +2678,14 @@ Unit.itemPickedUpEvent = __TS__New(
2601
2678
  ____exports.UnitTriggerEvent,
2602
2679
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2603
2680
  function()
2604
- local unit = getTriggerUnit()
2605
- local item = getManipulatedItem()
2606
- if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2607
- 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
2608
2689
  end
2609
2690
  return IgnoreEvent
2610
2691
  end
@@ -2624,7 +2705,22 @@ Unit.itemUsedEvent = __TS__New(
2624
2705
  Unit.itemStackedEvent = __TS__New(
2625
2706
  ____exports.UnitTriggerEvent,
2626
2707
  EVENT_PLAYER_UNIT_STACK_ITEM,
2627
- 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}
2628
2724
  )
2629
2725
  __TS__ObjectDefineProperty(
2630
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;