warscript 0.0.1-dev.d690591 → 0.0.1-dev.d6e2c10
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.
- package/attributes.d.ts +6 -0
- package/attributes.lua +17 -1
- package/core/types/frame.lua +24 -21
- package/core/types/player.d.ts +16 -0
- package/core/types/player.lua +60 -15
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +123 -5
- package/core/types/tileCell.d.ts +11 -1
- package/core/types/tileCell.lua +97 -0
- package/core/types/timer.d.ts +3 -1
- package/core/types/timer.lua +27 -2
- package/decl/native.d.ts +6 -4
- package/destroyable.d.ts +1 -0
- package/destroyable.lua +9 -0
- package/engine/behavior.d.ts +12 -1
- package/engine/behavior.lua +172 -70
- package/engine/behaviour/ability/apply-buff.lua +5 -5
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +11 -3
- package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
- package/engine/behaviour/ability/remove-buffs.lua +21 -0
- package/engine/behaviour/ability/restore-mana.d.ts +1 -1
- package/engine/behaviour/ability/restore-mana.lua +6 -6
- package/engine/behaviour/ability.d.ts +2 -1
- package/engine/behaviour/ability.lua +10 -18
- package/engine/behaviour/unit/stun-immunity.d.ts +11 -5
- package/engine/behaviour/unit/stun-immunity.lua +53 -28
- package/engine/behaviour/unit.d.ts +39 -3
- package/engine/behaviour/unit.lua +259 -6
- package/engine/buff.d.ts +14 -6
- package/engine/buff.lua +145 -97
- package/engine/internal/ability.d.ts +7 -1
- package/engine/internal/ability.lua +49 -9
- package/engine/internal/item/ability.lua +63 -11
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +16 -16
- package/engine/internal/item.lua +135 -49
- package/engine/internal/misc/frame-coordinates.d.ts +2 -0
- package/engine/internal/misc/frame-coordinates.lua +21 -0
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/misc/player-local-handle.d.ts +2 -0
- package/engine/internal/misc/player-local-handle.lua +5 -0
- package/engine/internal/unit/ability.d.ts +35 -0
- package/engine/internal/unit/ability.lua +98 -9
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/fly-height.d.ts +7 -0
- package/engine/internal/unit/fly-height.lua +20 -0
- package/engine/internal/unit/main-selected.lua +12 -27
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit/scale.d.ts +7 -0
- package/engine/internal/unit/scale.lua +20 -0
- package/engine/internal/unit+ability.lua +10 -1
- package/engine/internal/unit-missile-launch.lua +45 -14
- package/engine/internal/unit.d.ts +29 -18
- package/engine/internal/unit.lua +257 -140
- package/engine/local-client.d.ts +2 -0
- package/engine/local-client.lua +30 -0
- package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
- package/engine/object-data/auxiliary/armor-type.lua +46 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
- package/engine/object-data/entry/ability-type.lua +5 -4
- package/engine/object-data/entry/destructible-type.d.ts +17 -1
- package/engine/object-data/entry/destructible-type.lua +90 -0
- package/engine/object-data/entry/unit-type.d.ts +15 -2
- package/engine/object-data/entry/unit-type.lua +135 -33
- package/engine/object-field/ability.d.ts +3 -3
- package/engine/object-field/ability.lua +7 -6
- package/engine/object-field/unit.d.ts +24 -1
- package/engine/object-field/unit.lua +91 -0
- package/engine/object-field.d.ts +15 -6
- package/engine/object-field.lua +225 -124
- package/engine/random.d.ts +9 -0
- package/engine/random.lua +13 -0
- package/engine/standard/fields/ability.d.ts +2 -2
- package/engine/standard/fields/ability.lua +2 -2
- package/engine/standard/fields/unit.d.ts +6 -0
- package/engine/standard/fields/unit.lua +11 -0
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +250 -10
- package/engine/unit.d.ts +3 -0
- package/engine/unit.lua +3 -0
- package/net/socket.lua +1 -1
- package/objutil/buff.lua +1 -1
- package/package.json +2 -2
- package/patch-lualib.lua +1 -1
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +8 -0
- package/utility/callback-array.d.ts +17 -0
- package/utility/callback-array.lua +61 -0
- package/utility/functions.d.ts +7 -0
- package/utility/functions.lua +12 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +19 -1
- package/utility/lua-maps.d.ts +12 -2
- package/utility/lua-maps.lua +37 -2
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +4 -0
- package/utility/types.d.ts +3 -0
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
package/engine/internal/unit.lua
CHANGED
|
@@ -58,13 +58,16 @@ 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
|
|
65
|
+
local ____synchronization = require("engine.synchronization")
|
|
66
|
+
local synchronizer = ____synchronization.synchronizer
|
|
61
67
|
local match = string.match
|
|
62
68
|
local ____tostring = _G.tostring
|
|
63
69
|
local setUnitAnimation = SetUnitAnimation
|
|
64
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
65
70
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
66
|
-
local resetUnitAnimation = ResetUnitAnimation
|
|
67
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
68
71
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
69
72
|
local getUnitRealField = BlzGetUnitRealField
|
|
70
73
|
local getHeroStr = GetHeroStr
|
|
@@ -124,10 +127,6 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
124
127
|
local getIssuedOrderId = GetIssuedOrderId
|
|
125
128
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
126
129
|
local unitAlive = UnitAlive
|
|
127
|
-
local unitAddType = UnitAddType
|
|
128
|
-
local unitRemoveType = UnitRemoveType
|
|
129
|
-
local isUnitIllusion = IsUnitIllusion
|
|
130
|
-
local isUnitType = IsUnitType
|
|
131
130
|
local isUnitAlly = IsUnitAlly
|
|
132
131
|
local isUnitEnemy = IsUnitEnemy
|
|
133
132
|
local getOwningPlayer = GetOwningPlayer
|
|
@@ -140,6 +139,7 @@ do
|
|
|
140
139
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
141
140
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
142
141
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
142
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
143
143
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
144
144
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
145
145
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -347,6 +347,9 @@ local function dispatchAbility(event)
|
|
|
347
347
|
}
|
|
348
348
|
)
|
|
349
349
|
end
|
|
350
|
+
local function damagingEventPreventRetaliation(self)
|
|
351
|
+
self[0] = true
|
|
352
|
+
end
|
|
350
353
|
local function damageEventPreventDeath(self, callback, ...)
|
|
351
354
|
if self[0] ~= nil then
|
|
352
355
|
return
|
|
@@ -409,6 +412,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
|
409
412
|
self.unit = unit
|
|
410
413
|
self.index = index
|
|
411
414
|
end
|
|
415
|
+
__TS__SetDescriptor(
|
|
416
|
+
UnitWeapon.prototype,
|
|
417
|
+
"isEnabled",
|
|
418
|
+
{
|
|
419
|
+
get = function(self)
|
|
420
|
+
return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
|
|
421
|
+
end,
|
|
422
|
+
set = function(self, isEnabled)
|
|
423
|
+
BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
|
|
424
|
+
end
|
|
425
|
+
},
|
|
426
|
+
true
|
|
427
|
+
)
|
|
412
428
|
__TS__SetDescriptor(
|
|
413
429
|
UnitWeapon.prototype,
|
|
414
430
|
"cooldown",
|
|
@@ -443,6 +459,19 @@ __TS__SetDescriptor(
|
|
|
443
459
|
},
|
|
444
460
|
true
|
|
445
461
|
)
|
|
462
|
+
__TS__SetDescriptor(
|
|
463
|
+
UnitWeapon.prototype,
|
|
464
|
+
"allowedTargetCombatClassifications",
|
|
465
|
+
{
|
|
466
|
+
get = function(self)
|
|
467
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
468
|
+
end,
|
|
469
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
470
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
471
|
+
end
|
|
472
|
+
},
|
|
473
|
+
true
|
|
474
|
+
)
|
|
446
475
|
__TS__SetDescriptor(
|
|
447
476
|
UnitWeapon.prototype,
|
|
448
477
|
"damageBase",
|
|
@@ -630,15 +659,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
630
659
|
dummies[player] = dummy
|
|
631
660
|
end
|
|
632
661
|
local function delayHealthChecksCallback(unit)
|
|
633
|
-
local counter = (unit[
|
|
662
|
+
local counter = (unit[104] or 0) - 1
|
|
634
663
|
if counter ~= 0 then
|
|
635
|
-
unit[
|
|
664
|
+
unit[104] = counter
|
|
636
665
|
return
|
|
637
666
|
end
|
|
638
|
-
unit[
|
|
639
|
-
local healthBonus = unit[
|
|
667
|
+
unit[104] = nil
|
|
668
|
+
local healthBonus = unit[105]
|
|
640
669
|
if healthBonus ~= nil then
|
|
641
|
-
unit[
|
|
670
|
+
unit[105] = nil
|
|
642
671
|
local handle = unit.handle
|
|
643
672
|
BlzSetUnitMaxHP(
|
|
644
673
|
handle,
|
|
@@ -649,15 +678,24 @@ end
|
|
|
649
678
|
local nextSyncId = 1
|
|
650
679
|
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
651
680
|
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
681
|
+
local function addAbility(unit, abilityTypeId)
|
|
682
|
+
local ____unitAddAbility_result_0
|
|
683
|
+
if unitAddAbility(unit, abilityTypeId) then
|
|
684
|
+
____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
|
|
685
|
+
else
|
|
686
|
+
____unitAddAbility_result_0 = nil
|
|
687
|
+
end
|
|
688
|
+
return ____unitAddAbility_result_0
|
|
689
|
+
end
|
|
652
690
|
____exports.Unit = __TS__Class()
|
|
653
691
|
local Unit = ____exports.Unit
|
|
654
692
|
Unit.name = "Unit"
|
|
655
693
|
__TS__ClassExtends(Unit, Handle)
|
|
656
694
|
function Unit.prototype.____constructor(self, handle)
|
|
657
695
|
Handle.prototype.____constructor(self, handle)
|
|
658
|
-
local
|
|
659
|
-
nextSyncId =
|
|
660
|
-
self.syncId =
|
|
696
|
+
local ____nextSyncId_1 = nextSyncId
|
|
697
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
698
|
+
self.syncId = ____nextSyncId_1
|
|
661
699
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
662
700
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
663
701
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -689,8 +727,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
689
727
|
end
|
|
690
728
|
function Unit.prototype.onDestroy(self)
|
|
691
729
|
local handle = self.handle
|
|
692
|
-
self[
|
|
693
|
-
self[
|
|
730
|
+
self[108] = getUnitX(handle)
|
|
731
|
+
self[109] = getUnitY(handle)
|
|
694
732
|
if not self._owner then
|
|
695
733
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
696
734
|
end
|
|
@@ -758,17 +796,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
758
796
|
end}
|
|
759
797
|
end
|
|
760
798
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
761
|
-
local
|
|
762
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
799
|
+
local ____combatClassification_2 = combatClassification
|
|
800
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
|
|
763
801
|
end
|
|
764
802
|
function Unit.prototype.addClassification(self, classification)
|
|
765
|
-
return
|
|
803
|
+
return UnitAddType(self.handle, classification)
|
|
766
804
|
end
|
|
767
805
|
function Unit.prototype.removeClassification(self, classification)
|
|
768
|
-
return
|
|
806
|
+
return UnitRemoveType(self.handle, classification)
|
|
769
807
|
end
|
|
770
808
|
function Unit.prototype.hasClassification(self, classification)
|
|
771
|
-
return
|
|
809
|
+
return IsUnitType(self.handle, classification)
|
|
772
810
|
end
|
|
773
811
|
function Unit.prototype.isVisibleTo(self, player)
|
|
774
812
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -777,13 +815,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
777
815
|
return isUnitInvisible(self.handle, player.handle)
|
|
778
816
|
end
|
|
779
817
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
780
|
-
local
|
|
818
|
+
local ____temp_3
|
|
781
819
|
if type(x) == "number" then
|
|
782
|
-
|
|
820
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
783
821
|
else
|
|
784
|
-
|
|
822
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
785
823
|
end
|
|
786
|
-
return
|
|
824
|
+
return ____temp_3
|
|
787
825
|
end
|
|
788
826
|
function Unit.prototype.isAllyOf(self, unit)
|
|
789
827
|
return isUnitAlly(
|
|
@@ -801,19 +839,30 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
801
839
|
if type(animation) == "number" then
|
|
802
840
|
setUnitAnimationByIndex(self.handle, animation)
|
|
803
841
|
elseif rarity then
|
|
804
|
-
|
|
842
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
805
843
|
else
|
|
806
844
|
setUnitAnimation(self.handle, animation)
|
|
807
845
|
end
|
|
808
846
|
end
|
|
809
847
|
function Unit.prototype.resetAnimation(self)
|
|
810
|
-
|
|
848
|
+
ResetUnitAnimation(self.handle)
|
|
811
849
|
end
|
|
812
850
|
function Unit.prototype.queueAnimation(self, animation)
|
|
813
|
-
|
|
851
|
+
QueueUnitAnimation(self.handle, animation)
|
|
852
|
+
end
|
|
853
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
854
|
+
local firstWeapon = self.firstWeapon
|
|
855
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
856
|
+
return firstWeapon
|
|
857
|
+
end
|
|
858
|
+
local secondWeapon = self.secondWeapon
|
|
859
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
860
|
+
return secondWeapon
|
|
861
|
+
end
|
|
862
|
+
return nil
|
|
814
863
|
end
|
|
815
864
|
function Unit.prototype.delayHealthChecks(self)
|
|
816
|
-
self[
|
|
865
|
+
self[104] = (self[104] or 0) + 1
|
|
817
866
|
Timer:run(delayHealthChecksCallback, self)
|
|
818
867
|
end
|
|
819
868
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -830,14 +879,14 @@ function Unit.prototype.kill(self)
|
|
|
830
879
|
killUnit(self.handle)
|
|
831
880
|
end
|
|
832
881
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
833
|
-
local
|
|
834
|
-
local
|
|
835
|
-
local
|
|
836
|
-
if
|
|
837
|
-
|
|
882
|
+
local ____ReviveHero_6 = ReviveHero
|
|
883
|
+
local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
|
|
884
|
+
local ____doEffect_4 = doEffect
|
|
885
|
+
if ____doEffect_4 == nil then
|
|
886
|
+
____doEffect_4 = false
|
|
838
887
|
end
|
|
839
|
-
__TS__SparseArrayPush(
|
|
840
|
-
|
|
888
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
889
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
841
890
|
end
|
|
842
891
|
function Unit.prototype.healTarget(self, target, amount)
|
|
843
892
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -880,17 +929,16 @@ function Unit.prototype.itemInSlot(self, slot)
|
|
|
880
929
|
return Item:of(unitItemInSlot(self.handle, slot))
|
|
881
930
|
end
|
|
882
931
|
function Unit.prototype.addAbility(self, abilityId)
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
932
|
+
local ability = UnitAbility:of(
|
|
933
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
934
|
+
abilityId,
|
|
935
|
+
self
|
|
936
|
+
)
|
|
937
|
+
if ability ~= nil then
|
|
889
938
|
local abilities = self.abilities
|
|
890
939
|
abilities[#abilities + 1] = ability
|
|
891
|
-
return ability
|
|
892
940
|
end
|
|
893
|
-
return
|
|
941
|
+
return ability
|
|
894
942
|
end
|
|
895
943
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
896
944
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -904,31 +952,21 @@ end
|
|
|
904
952
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
905
953
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
906
954
|
end
|
|
907
|
-
function Unit.prototype.
|
|
908
|
-
local
|
|
909
|
-
|
|
910
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
911
|
-
return nil
|
|
912
|
-
end
|
|
913
|
-
return UnitAbility:of(
|
|
914
|
-
getUnitAbility(self.handle, abilityId),
|
|
915
|
-
abilityId,
|
|
916
|
-
self
|
|
917
|
-
)
|
|
955
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
956
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
957
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
918
958
|
end
|
|
919
|
-
function Unit.prototype.removeAbility(self,
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
end
|
|
959
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
960
|
+
local abilities = self.abilities
|
|
961
|
+
for i = 1, #abilities do
|
|
962
|
+
if abilities[i].typeId == abilityTypeId then
|
|
963
|
+
local ability = abilities[i]
|
|
964
|
+
tremove(abilities, i)
|
|
965
|
+
ability:destroy()
|
|
966
|
+
return true
|
|
928
967
|
end
|
|
929
|
-
return true
|
|
930
968
|
end
|
|
931
|
-
return
|
|
969
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
932
970
|
end
|
|
933
971
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
934
972
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -942,6 +980,21 @@ end
|
|
|
942
980
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
943
981
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
944
982
|
end
|
|
983
|
+
function Unit.prototype.interruptMovement(self)
|
|
984
|
+
local handle = self.handle
|
|
985
|
+
unitDisableAbility(
|
|
986
|
+
handle,
|
|
987
|
+
fourCC("Amov"),
|
|
988
|
+
true,
|
|
989
|
+
false
|
|
990
|
+
)
|
|
991
|
+
unitDisableAbility(
|
|
992
|
+
handle,
|
|
993
|
+
fourCC("Amov"),
|
|
994
|
+
false,
|
|
995
|
+
false
|
|
996
|
+
)
|
|
997
|
+
end
|
|
945
998
|
function Unit.prototype.interruptAttack(self)
|
|
946
999
|
unitInterruptAttack(self.handle)
|
|
947
1000
|
end
|
|
@@ -1015,18 +1068,44 @@ function Unit.prototype.unpauseEx(self)
|
|
|
1015
1068
|
end
|
|
1016
1069
|
function Unit.prototype.incrementStunCounter(self)
|
|
1017
1070
|
local stunCounter = self[102] or 0
|
|
1018
|
-
if not self[101] or stunCounter >= 0 then
|
|
1071
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
|
|
1019
1072
|
BlzPauseUnitEx(self.handle, true)
|
|
1020
1073
|
end
|
|
1021
1074
|
self[102] = stunCounter + 1
|
|
1022
1075
|
end
|
|
1023
1076
|
function Unit.prototype.decrementStunCounter(self)
|
|
1024
1077
|
local stunCounter = self[102] or 0
|
|
1025
|
-
if not self[101] or stunCounter >= 1 then
|
|
1078
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
|
|
1026
1079
|
BlzPauseUnitEx(self.handle, false)
|
|
1027
1080
|
end
|
|
1028
1081
|
self[102] = stunCounter - 1
|
|
1029
1082
|
end
|
|
1083
|
+
function Unit.prototype.incrementForceStunCounter(self)
|
|
1084
|
+
local forceStunCounter = self[103] or 0
|
|
1085
|
+
if forceStunCounter == 0 then
|
|
1086
|
+
local handle = self.handle
|
|
1087
|
+
if not self[101] then
|
|
1088
|
+
for _ = self[102] or 0, -1 do
|
|
1089
|
+
BlzPauseUnitEx(handle, true)
|
|
1090
|
+
end
|
|
1091
|
+
end
|
|
1092
|
+
BlzPauseUnitEx(handle, true)
|
|
1093
|
+
end
|
|
1094
|
+
self[103] = forceStunCounter + 1
|
|
1095
|
+
end
|
|
1096
|
+
function Unit.prototype.decrementForceStunCounter(self)
|
|
1097
|
+
local forceStunCounter = self[103] or 0
|
|
1098
|
+
if forceStunCounter == 1 then
|
|
1099
|
+
local handle = self.handle
|
|
1100
|
+
if not self[101] then
|
|
1101
|
+
for _ = self[102] or 0, -1 do
|
|
1102
|
+
BlzPauseUnitEx(handle, false)
|
|
1103
|
+
end
|
|
1104
|
+
end
|
|
1105
|
+
BlzPauseUnitEx(handle, false)
|
|
1106
|
+
end
|
|
1107
|
+
self[103] = forceStunCounter - 1
|
|
1108
|
+
end
|
|
1030
1109
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1031
1110
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
1032
1111
|
owner.handle,
|
|
@@ -1215,7 +1294,7 @@ __TS__SetDescriptor(
|
|
|
1215
1294
|
Unit.prototype,
|
|
1216
1295
|
"isIllusion",
|
|
1217
1296
|
{get = function(self)
|
|
1218
|
-
return
|
|
1297
|
+
return IsUnitIllusion(self.handle)
|
|
1219
1298
|
end},
|
|
1220
1299
|
true
|
|
1221
1300
|
)
|
|
@@ -1434,17 +1513,17 @@ __TS__SetDescriptor(
|
|
|
1434
1513
|
"isTeamGlowVisible",
|
|
1435
1514
|
{
|
|
1436
1515
|
get = function(self)
|
|
1437
|
-
return not self[
|
|
1516
|
+
return not self[107]
|
|
1438
1517
|
end,
|
|
1439
1518
|
set = function(self, isTeamGlowVisible)
|
|
1440
1519
|
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1441
|
-
local
|
|
1520
|
+
local ____temp_7
|
|
1442
1521
|
if not isTeamGlowVisible then
|
|
1443
|
-
|
|
1522
|
+
____temp_7 = true
|
|
1444
1523
|
else
|
|
1445
|
-
|
|
1524
|
+
____temp_7 = nil
|
|
1446
1525
|
end
|
|
1447
|
-
self[
|
|
1526
|
+
self[107] = ____temp_7
|
|
1448
1527
|
end
|
|
1449
1528
|
},
|
|
1450
1529
|
true
|
|
@@ -1454,7 +1533,7 @@ __TS__SetDescriptor(
|
|
|
1454
1533
|
"color",
|
|
1455
1534
|
{set = function(self, color)
|
|
1456
1535
|
SetUnitColor(self.handle, color.handle)
|
|
1457
|
-
if self[
|
|
1536
|
+
if self[107] then
|
|
1458
1537
|
BlzShowUnitTeamGlow(self.handle, false)
|
|
1459
1538
|
end
|
|
1460
1539
|
end},
|
|
@@ -1478,14 +1557,14 @@ __TS__SetDescriptor(
|
|
|
1478
1557
|
"maxHealth",
|
|
1479
1558
|
{
|
|
1480
1559
|
get = function(self)
|
|
1481
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1560
|
+
return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
|
|
1482
1561
|
end,
|
|
1483
1562
|
set = function(self, maxHealth)
|
|
1484
|
-
if maxHealth < 1 and self[
|
|
1485
|
-
self[
|
|
1563
|
+
if maxHealth < 1 and self[104] ~= nil then
|
|
1564
|
+
self[105] = (self[105] or 0) + (1 - maxHealth)
|
|
1486
1565
|
maxHealth = 1
|
|
1487
1566
|
end
|
|
1488
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1567
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
|
|
1489
1568
|
end
|
|
1490
1569
|
},
|
|
1491
1570
|
true
|
|
@@ -1527,10 +1606,10 @@ __TS__SetDescriptor(
|
|
|
1527
1606
|
"health",
|
|
1528
1607
|
{
|
|
1529
1608
|
get = function(self)
|
|
1530
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1609
|
+
return GetWidgetLife(self.handle) - (self[106] or 0)
|
|
1531
1610
|
end,
|
|
1532
1611
|
set = function(self, health)
|
|
1533
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1612
|
+
SetWidgetLife(self.handle, health + (self[106] or 0))
|
|
1534
1613
|
end
|
|
1535
1614
|
},
|
|
1536
1615
|
true
|
|
@@ -1606,25 +1685,12 @@ __TS__SetDescriptor(
|
|
|
1606
1685
|
},
|
|
1607
1686
|
true
|
|
1608
1687
|
)
|
|
1609
|
-
__TS__SetDescriptor(
|
|
1610
|
-
Unit.prototype,
|
|
1611
|
-
"flyHeight",
|
|
1612
|
-
{
|
|
1613
|
-
get = function(self)
|
|
1614
|
-
return getUnitFlyHeight(self.handle)
|
|
1615
|
-
end,
|
|
1616
|
-
set = function(self, v)
|
|
1617
|
-
SetUnitFlyHeight(self.handle, v, 100000)
|
|
1618
|
-
end
|
|
1619
|
-
},
|
|
1620
|
-
true
|
|
1621
|
-
)
|
|
1622
1688
|
__TS__SetDescriptor(
|
|
1623
1689
|
Unit.prototype,
|
|
1624
1690
|
"x",
|
|
1625
1691
|
{
|
|
1626
1692
|
get = function(self)
|
|
1627
|
-
return self[
|
|
1693
|
+
return self[108] or getUnitX(self.handle)
|
|
1628
1694
|
end,
|
|
1629
1695
|
set = function(self, v)
|
|
1630
1696
|
SetUnitX(self.handle, v)
|
|
@@ -1637,7 +1703,7 @@ __TS__SetDescriptor(
|
|
|
1637
1703
|
"y",
|
|
1638
1704
|
{
|
|
1639
1705
|
get = function(self)
|
|
1640
|
-
return self[
|
|
1706
|
+
return self[109] or getUnitY(self.handle)
|
|
1641
1707
|
end,
|
|
1642
1708
|
set = function(self, v)
|
|
1643
1709
|
SetUnitY(self.handle, v)
|
|
@@ -1742,14 +1808,18 @@ __TS__SetDescriptor(
|
|
|
1742
1808
|
local handle = self.handle
|
|
1743
1809
|
if isPaused and not IsUnitPaused(handle) then
|
|
1744
1810
|
self[101] = true
|
|
1745
|
-
|
|
1746
|
-
|
|
1811
|
+
if (self[103] or 0) <= 0 then
|
|
1812
|
+
for _ = self[102] or 0, -1 do
|
|
1813
|
+
BlzPauseUnitEx(handle, true)
|
|
1814
|
+
end
|
|
1747
1815
|
end
|
|
1748
1816
|
PauseUnit(handle, true)
|
|
1749
1817
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1750
1818
|
PauseUnit(handle, false)
|
|
1751
|
-
|
|
1752
|
-
|
|
1819
|
+
if (self[103] or 0) <= 0 then
|
|
1820
|
+
for _ = self[102] or 0, -1 do
|
|
1821
|
+
BlzPauseUnitEx(handle, false)
|
|
1822
|
+
end
|
|
1753
1823
|
end
|
|
1754
1824
|
self[101] = nil
|
|
1755
1825
|
end
|
|
@@ -1807,20 +1877,6 @@ __TS__SetDescriptor(
|
|
|
1807
1877
|
},
|
|
1808
1878
|
true
|
|
1809
1879
|
)
|
|
1810
|
-
__TS__SetDescriptor(
|
|
1811
|
-
Unit.prototype,
|
|
1812
|
-
"scale",
|
|
1813
|
-
{
|
|
1814
|
-
get = function(self)
|
|
1815
|
-
return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
|
|
1816
|
-
end,
|
|
1817
|
-
set = function(self, v)
|
|
1818
|
-
setUnitScale(self.handle, v, v, v)
|
|
1819
|
-
setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
|
|
1820
|
-
end
|
|
1821
|
-
},
|
|
1822
|
-
true
|
|
1823
|
-
)
|
|
1824
1880
|
__TS__SetDescriptor(
|
|
1825
1881
|
Unit.prototype,
|
|
1826
1882
|
"timeScale",
|
|
@@ -2048,6 +2104,14 @@ __TS__SetDescriptor(
|
|
|
2048
2104
|
end},
|
|
2049
2105
|
true
|
|
2050
2106
|
)
|
|
2107
|
+
__TS__SetDescriptor(
|
|
2108
|
+
Unit.prototype,
|
|
2109
|
+
"targetAcquiredEvent",
|
|
2110
|
+
{get = function(self)
|
|
2111
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2112
|
+
end},
|
|
2113
|
+
true
|
|
2114
|
+
)
|
|
2051
2115
|
__TS__SetDescriptor(
|
|
2052
2116
|
Unit.prototype,
|
|
2053
2117
|
"onSelect",
|
|
@@ -2183,25 +2247,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2183
2247
|
InitializingEvent,
|
|
2184
2248
|
function(event)
|
|
2185
2249
|
local function listener(unit, id)
|
|
2186
|
-
local
|
|
2250
|
+
local ____GetSpellTargetUnit_result_10
|
|
2187
2251
|
if GetSpellTargetUnit() then
|
|
2188
|
-
|
|
2252
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2189
2253
|
else
|
|
2190
|
-
local
|
|
2254
|
+
local ____GetSpellTargetItem_result_9
|
|
2191
2255
|
if GetSpellTargetItem() then
|
|
2192
|
-
|
|
2256
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2193
2257
|
else
|
|
2194
|
-
local
|
|
2258
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2195
2259
|
if GetSpellTargetDestructable() then
|
|
2196
|
-
|
|
2260
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2197
2261
|
else
|
|
2198
|
-
|
|
2262
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2199
2263
|
end
|
|
2200
|
-
|
|
2264
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2201
2265
|
end
|
|
2202
|
-
|
|
2266
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2203
2267
|
end
|
|
2204
|
-
local target =
|
|
2268
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2205
2269
|
if target then
|
|
2206
2270
|
invoke(event, unit, id, target)
|
|
2207
2271
|
end
|
|
@@ -2420,15 +2484,11 @@ Unit.onDamaging = (function()
|
|
|
2420
2484
|
metadata = metadata,
|
|
2421
2485
|
isAttack = BlzGetEventIsAttack(),
|
|
2422
2486
|
originalAmount = GetEventDamage(),
|
|
2423
|
-
originalMetadata = metadata
|
|
2487
|
+
originalMetadata = metadata,
|
|
2488
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2424
2489
|
}
|
|
2425
2490
|
if data.isAttack and source then
|
|
2426
|
-
|
|
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])
|
|
2491
|
+
data.weapon = source:chooseWeapon(target)
|
|
2432
2492
|
end
|
|
2433
2493
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2434
2494
|
invoke(
|
|
@@ -2449,6 +2509,20 @@ Unit.onDamaging = (function()
|
|
|
2449
2509
|
}
|
|
2450
2510
|
)
|
|
2451
2511
|
)
|
|
2512
|
+
if data[0] and source then
|
|
2513
|
+
local sourceOwner = source.owner.handle
|
|
2514
|
+
data[1] = sourceOwner
|
|
2515
|
+
local targetOwner = target.owner.handle
|
|
2516
|
+
data[2] = targetOwner
|
|
2517
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2518
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2519
|
+
data[3] = true
|
|
2520
|
+
end
|
|
2521
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2522
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2523
|
+
data[4] = true
|
|
2524
|
+
end
|
|
2525
|
+
end
|
|
2452
2526
|
damagingEventByTarget[target] = data
|
|
2453
2527
|
return
|
|
2454
2528
|
end
|
|
@@ -2526,12 +2600,32 @@ Unit.onDamage = __TS__New(
|
|
|
2526
2600
|
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2527
2601
|
preventDeath = damageEventPreventDeath
|
|
2528
2602
|
}
|
|
2603
|
+
if damagingEvent then
|
|
2604
|
+
for key, value in pairs(damagingEvent) do
|
|
2605
|
+
if isAttribute(key) then
|
|
2606
|
+
data[key] = value
|
|
2607
|
+
end
|
|
2608
|
+
end
|
|
2609
|
+
local sourceOwner = damagingEvent[1]
|
|
2610
|
+
if sourceOwner then
|
|
2611
|
+
local targetOwner = damagingEvent[2]
|
|
2612
|
+
if damagingEvent[3] then
|
|
2613
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2614
|
+
end
|
|
2615
|
+
if damagingEvent[4] then
|
|
2616
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2617
|
+
end
|
|
2618
|
+
end
|
|
2619
|
+
end
|
|
2529
2620
|
local evData = setmetatable(
|
|
2530
2621
|
{},
|
|
2531
2622
|
{
|
|
2532
2623
|
__index = data,
|
|
2533
2624
|
__newindex = function(self, key, value)
|
|
2534
|
-
damageSetters[key]
|
|
2625
|
+
local damageSetter = damageSetters[key]
|
|
2626
|
+
if damageSetter ~= nil then
|
|
2627
|
+
damageSetter(value)
|
|
2628
|
+
end
|
|
2535
2629
|
data[key] = value
|
|
2536
2630
|
end
|
|
2537
2631
|
}
|
|
@@ -2539,7 +2633,7 @@ Unit.onDamage = __TS__New(
|
|
|
2539
2633
|
invoke(event, source, target, evData)
|
|
2540
2634
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2541
2635
|
local bonusHealth = math.ceil(evData.amount)
|
|
2542
|
-
target[
|
|
2636
|
+
target[106] = (target[106] or 0) + bonusHealth
|
|
2543
2637
|
BlzSetUnitMaxHP(
|
|
2544
2638
|
target.handle,
|
|
2545
2639
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2553,7 +2647,7 @@ Unit.onDamage = __TS__New(
|
|
|
2553
2647
|
evData[0],
|
|
2554
2648
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2555
2649
|
)
|
|
2556
|
-
target[
|
|
2650
|
+
target[106] = (target[106] or 0) - bonusHealth
|
|
2557
2651
|
SetWidgetLife(
|
|
2558
2652
|
target.handle,
|
|
2559
2653
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2589,10 +2683,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2589
2683
|
____exports.UnitTriggerEvent,
|
|
2590
2684
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2591
2685
|
function()
|
|
2592
|
-
local
|
|
2593
|
-
local
|
|
2594
|
-
if getUnitTypeId(
|
|
2595
|
-
|
|
2686
|
+
local unitHandle = getTriggerUnit()
|
|
2687
|
+
local itemHandle = getManipulatedItem()
|
|
2688
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2689
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2690
|
+
local item = Item:of(itemHandle)
|
|
2691
|
+
if item.owner ~= unit then
|
|
2692
|
+
return unit, item
|
|
2693
|
+
end
|
|
2596
2694
|
end
|
|
2597
2695
|
return IgnoreEvent
|
|
2598
2696
|
end
|
|
@@ -2612,7 +2710,22 @@ Unit.itemUsedEvent = __TS__New(
|
|
|
2612
2710
|
Unit.itemStackedEvent = __TS__New(
|
|
2613
2711
|
____exports.UnitTriggerEvent,
|
|
2614
2712
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2615
|
-
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(
|
|
2713
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2714
|
+
)
|
|
2715
|
+
__TS__ObjectDefineProperty(
|
|
2716
|
+
Unit,
|
|
2717
|
+
"itemChargesChangedEvent",
|
|
2718
|
+
{get = function(self)
|
|
2719
|
+
local event = __TS__New(Event)
|
|
2720
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2721
|
+
local unit = item.owner
|
|
2722
|
+
if unit ~= nil then
|
|
2723
|
+
invoke(event, unit, item)
|
|
2724
|
+
end
|
|
2725
|
+
end)
|
|
2726
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2727
|
+
return event
|
|
2728
|
+
end}
|
|
2616
2729
|
)
|
|
2617
2730
|
__TS__ObjectDefineProperty(
|
|
2618
2731
|
Unit,
|
|
@@ -2684,6 +2797,10 @@ __TS__ObjectDefineProperty(
|
|
|
2684
2797
|
rawset(self, "destroyEvent", destroyEvent)
|
|
2685
2798
|
return destroyEvent
|
|
2686
2799
|
end}
|
|
2800
|
+
)
|
|
2801
|
+
Unit.synchronize = synchronizer(
|
|
2802
|
+
function(unit) return unit.syncId end,
|
|
2803
|
+
function(syncId) return unitBySyncId[syncId] end
|
|
2687
2804
|
);
|
|
2688
2805
|
(function(self)
|
|
2689
2806
|
local leaveAbilityIds = postcompile(function()
|