warscript 0.0.1-dev.87bdb89 → 0.0.1-dev.8895ff6
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 +1 -0
- package/attributes.lua +9 -0
- 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 +14 -1
- package/engine/behavior.lua +230 -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 +2 -1
- 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 +9 -17
- package/engine/behaviour/unit/stun-immunity.d.ts +12 -6
- package/engine/behaviour/unit/stun-immunity.lua +57 -31
- package/engine/behaviour/unit.d.ts +26 -5
- package/engine/behaviour/unit.lua +180 -27
- package/engine/buff.d.ts +21 -8
- package/engine/buff.lua +187 -121
- package/engine/internal/ability.d.ts +3 -1
- package/engine/internal/ability.lua +34 -11
- package/engine/internal/item/ability.lua +51 -1
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +13 -15
- package/engine/internal/item.lua +63 -49
- package/engine/internal/mechanics/cast-ability.lua +6 -3
- 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/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
- package/engine/internal/unit/ability.d.ts +35 -5
- package/engine/internal/unit/ability.lua +96 -21
- package/engine/internal/unit/attributes.d.ts +17 -0
- package/engine/internal/unit/attributes.lua +46 -0
- package/engine/internal/unit/bonus.d.ts +2 -0
- package/engine/internal/unit/bonus.lua +10 -0
- package/engine/internal/unit/fly-height.d.ts +7 -0
- package/engine/internal/unit/fly-height.lua +20 -0
- package/engine/internal/unit/interrupts.d.ts +12 -0
- package/engine/internal/unit/interrupts.lua +28 -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 +52 -14
- package/engine/internal/unit.d.ts +19 -23
- package/engine/internal/unit.lua +171 -190
- 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/auxiliary/health-regeneration-type.d.ts +8 -0
- package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
- package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
- package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
- package/engine/object-data/entry/ability-type.lua +5 -4
- package/engine/object-data/entry/destructible-type.d.ts +27 -1
- package/engine/object-data/entry/destructible-type.lua +155 -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 +31 -5
- package/engine/object-field/unit.lua +95 -0
- package/engine/object-field.d.ts +13 -3
- package/engine/object-field.lua +279 -133
- 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 +12 -0
- package/engine/standard/fields/unit.lua +20 -0
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.d.ts +26 -3
- package/engine/text-tag.lua +217 -11
- package/engine/unit.d.ts +5 -0
- package/engine/unit.lua +5 -0
- package/net/socket.lua +1 -1
- package/objutil/buff.lua +10 -8
- 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-map.d.ts +26 -0
- package/utility/linked-map.lua +66 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +23 -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/records.lua +20 -1
- package/utility/types.d.ts +3 -0
- package/core/types/order.d.ts +0 -26
- package/core/types/order.lua +0 -65
package/engine/internal/unit.lua
CHANGED
|
@@ -60,6 +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
|
|
65
|
+
local ____synchronization = require("engine.synchronization")
|
|
66
|
+
local synchronizer = ____synchronization.synchronizer
|
|
67
|
+
local ____linked_2Dmap = require("utility.linked-map")
|
|
68
|
+
local LinkedMap = ____linked_2Dmap.LinkedMap
|
|
63
69
|
local match = string.match
|
|
64
70
|
local ____tostring = _G.tostring
|
|
65
71
|
local setUnitAnimation = SetUnitAnimation
|
|
@@ -69,16 +75,12 @@ local getUnitRealField = BlzGetUnitRealField
|
|
|
69
75
|
local getHeroStr = GetHeroStr
|
|
70
76
|
local getHeroAgi = GetHeroAgi
|
|
71
77
|
local getHeroInt = GetHeroInt
|
|
72
|
-
local setHeroStr = SetHeroStr
|
|
73
|
-
local setHeroAgi = SetHeroAgi
|
|
74
|
-
local setHeroInt = SetHeroInt
|
|
75
78
|
local getUnitBooleanField = BlzGetUnitBooleanField
|
|
76
79
|
local getUnitStringField = BlzGetUnitStringField
|
|
77
80
|
local setUnitIntegerField = BlzSetUnitIntegerField
|
|
78
81
|
local setUnitRealField = BlzSetUnitRealField
|
|
79
82
|
local setUnitBooleanField = BlzSetUnitBooleanField
|
|
80
83
|
local setUnitStringField = BlzSetUnitStringField
|
|
81
|
-
local setUnitScale = SetUnitScale
|
|
82
84
|
local setUnitPosition = SetUnitPosition
|
|
83
85
|
local setUnitTimeScale = SetUnitTimeScale
|
|
84
86
|
local getHandleId = GetHandleId
|
|
@@ -106,7 +108,6 @@ local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
|
106
108
|
local setUnitWeaponStringField = BlzSetUnitWeaponStringField
|
|
107
109
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
108
110
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
109
|
-
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
110
111
|
local isUnitInvisible = IsUnitInvisible
|
|
111
112
|
local isUnitVisible = IsUnitVisible
|
|
112
113
|
local getUnitX = GetUnitX
|
|
@@ -123,10 +124,6 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
123
124
|
local getIssuedOrderId = GetIssuedOrderId
|
|
124
125
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
125
126
|
local unitAlive = UnitAlive
|
|
126
|
-
local unitAddType = UnitAddType
|
|
127
|
-
local unitRemoveType = UnitRemoveType
|
|
128
|
-
local isUnitIllusion = IsUnitIllusion
|
|
129
|
-
local isUnitType = IsUnitType
|
|
130
127
|
local isUnitAlly = IsUnitAlly
|
|
131
128
|
local isUnitEnemy = IsUnitEnemy
|
|
132
129
|
local getOwningPlayer = GetOwningPlayer
|
|
@@ -412,6 +409,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
|
412
409
|
self.unit = unit
|
|
413
410
|
self.index = index
|
|
414
411
|
end
|
|
412
|
+
__TS__SetDescriptor(
|
|
413
|
+
UnitWeapon.prototype,
|
|
414
|
+
"isEnabled",
|
|
415
|
+
{
|
|
416
|
+
get = function(self)
|
|
417
|
+
return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
|
|
418
|
+
end,
|
|
419
|
+
set = function(self, isEnabled)
|
|
420
|
+
BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
|
|
421
|
+
end
|
|
422
|
+
},
|
|
423
|
+
true
|
|
424
|
+
)
|
|
415
425
|
__TS__SetDescriptor(
|
|
416
426
|
UnitWeapon.prototype,
|
|
417
427
|
"cooldown",
|
|
@@ -646,15 +656,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
646
656
|
dummies[player] = dummy
|
|
647
657
|
end
|
|
648
658
|
local function delayHealthChecksCallback(unit)
|
|
649
|
-
local counter = (unit[
|
|
659
|
+
local counter = (unit[104] or 0) - 1
|
|
650
660
|
if counter ~= 0 then
|
|
651
|
-
unit[
|
|
661
|
+
unit[104] = counter
|
|
652
662
|
return
|
|
653
663
|
end
|
|
654
|
-
unit[
|
|
655
|
-
local healthBonus = unit[
|
|
664
|
+
unit[104] = nil
|
|
665
|
+
local healthBonus = unit[105]
|
|
656
666
|
if healthBonus ~= nil then
|
|
657
|
-
unit[
|
|
667
|
+
unit[105] = nil
|
|
658
668
|
local handle = unit.handle
|
|
659
669
|
BlzSetUnitMaxHP(
|
|
660
670
|
handle,
|
|
@@ -665,15 +675,24 @@ end
|
|
|
665
675
|
local nextSyncId = 1
|
|
666
676
|
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
667
677
|
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
678
|
+
local function addAbility(unit, abilityTypeId)
|
|
679
|
+
local ____unitAddAbility_result_0
|
|
680
|
+
if unitAddAbility(unit, abilityTypeId) then
|
|
681
|
+
____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
|
|
682
|
+
else
|
|
683
|
+
____unitAddAbility_result_0 = nil
|
|
684
|
+
end
|
|
685
|
+
return ____unitAddAbility_result_0
|
|
686
|
+
end
|
|
668
687
|
____exports.Unit = __TS__Class()
|
|
669
688
|
local Unit = ____exports.Unit
|
|
670
689
|
Unit.name = "Unit"
|
|
671
690
|
__TS__ClassExtends(Unit, Handle)
|
|
672
691
|
function Unit.prototype.____constructor(self, handle)
|
|
673
692
|
Handle.prototype.____constructor(self, handle)
|
|
674
|
-
local
|
|
675
|
-
nextSyncId =
|
|
676
|
-
self.syncId =
|
|
693
|
+
local ____nextSyncId_1 = nextSyncId
|
|
694
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
695
|
+
self.syncId = ____nextSyncId_1
|
|
677
696
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
678
697
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
679
698
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -689,24 +708,26 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
689
708
|
unitBySyncId[self.syncId] = self
|
|
690
709
|
local ____ = self.abilities
|
|
691
710
|
end
|
|
692
|
-
function Unit.prototype.getEvent(self,
|
|
693
|
-
self.events = self.events or (
|
|
694
|
-
local eventId = GetHandleId(
|
|
695
|
-
|
|
696
|
-
|
|
711
|
+
function Unit.prototype.getEvent(self, jevent, collector)
|
|
712
|
+
self.events = self.events or __TS__New(LinkedMap)
|
|
713
|
+
local eventId = GetHandleId(jevent)
|
|
714
|
+
local event = self.events:get(eventId)
|
|
715
|
+
if event == nil then
|
|
716
|
+
event = __TS__New(
|
|
697
717
|
TriggerEvent,
|
|
698
718
|
function(trigger)
|
|
699
|
-
TriggerRegisterUnitEvent(trigger, self.handle,
|
|
719
|
+
TriggerRegisterUnitEvent(trigger, self.handle, jevent)
|
|
700
720
|
end,
|
|
701
721
|
collector or (function() return {} end)
|
|
702
722
|
)
|
|
723
|
+
self.events:put(eventId, event)
|
|
703
724
|
end
|
|
704
|
-
return
|
|
725
|
+
return event
|
|
705
726
|
end
|
|
706
727
|
function Unit.prototype.onDestroy(self)
|
|
707
728
|
local handle = self.handle
|
|
708
|
-
self[
|
|
709
|
-
self[
|
|
729
|
+
self[108] = getUnitX(handle)
|
|
730
|
+
self[109] = getUnitY(handle)
|
|
710
731
|
if not self._owner then
|
|
711
732
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
712
733
|
end
|
|
@@ -774,17 +795,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
774
795
|
end}
|
|
775
796
|
end
|
|
776
797
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
777
|
-
local
|
|
778
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
798
|
+
local ____combatClassification_2 = combatClassification
|
|
799
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
|
|
779
800
|
end
|
|
780
801
|
function Unit.prototype.addClassification(self, classification)
|
|
781
|
-
return
|
|
802
|
+
return UnitAddType(self.handle, classification)
|
|
782
803
|
end
|
|
783
804
|
function Unit.prototype.removeClassification(self, classification)
|
|
784
|
-
return
|
|
805
|
+
return UnitRemoveType(self.handle, classification)
|
|
785
806
|
end
|
|
786
807
|
function Unit.prototype.hasClassification(self, classification)
|
|
787
|
-
return
|
|
808
|
+
return IsUnitType(self.handle, classification)
|
|
788
809
|
end
|
|
789
810
|
function Unit.prototype.isVisibleTo(self, player)
|
|
790
811
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -793,13 +814,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
793
814
|
return isUnitInvisible(self.handle, player.handle)
|
|
794
815
|
end
|
|
795
816
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
796
|
-
local
|
|
817
|
+
local ____temp_3
|
|
797
818
|
if type(x) == "number" then
|
|
798
|
-
|
|
819
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
799
820
|
else
|
|
800
|
-
|
|
821
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
801
822
|
end
|
|
802
|
-
return
|
|
823
|
+
return ____temp_3
|
|
803
824
|
end
|
|
804
825
|
function Unit.prototype.isAllyOf(self, unit)
|
|
805
826
|
return isUnitAlly(
|
|
@@ -829,16 +850,18 @@ function Unit.prototype.queueAnimation(self, animation)
|
|
|
829
850
|
QueueUnitAnimation(self.handle, animation)
|
|
830
851
|
end
|
|
831
852
|
function Unit.prototype.chooseWeapon(self, target)
|
|
832
|
-
|
|
833
|
-
|
|
853
|
+
local firstWeapon = self.firstWeapon
|
|
854
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
855
|
+
return firstWeapon
|
|
834
856
|
end
|
|
835
|
-
|
|
836
|
-
|
|
857
|
+
local secondWeapon = self.secondWeapon
|
|
858
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
859
|
+
return secondWeapon
|
|
837
860
|
end
|
|
838
861
|
return nil
|
|
839
862
|
end
|
|
840
863
|
function Unit.prototype.delayHealthChecks(self)
|
|
841
|
-
self[
|
|
864
|
+
self[104] = (self[104] or 0) + 1
|
|
842
865
|
Timer:run(delayHealthChecksCallback, self)
|
|
843
866
|
end
|
|
844
867
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -855,14 +878,14 @@ function Unit.prototype.kill(self)
|
|
|
855
878
|
killUnit(self.handle)
|
|
856
879
|
end
|
|
857
880
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
858
|
-
local
|
|
859
|
-
local
|
|
860
|
-
local
|
|
861
|
-
if
|
|
862
|
-
|
|
881
|
+
local ____ReviveHero_6 = ReviveHero
|
|
882
|
+
local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
|
|
883
|
+
local ____doEffect_4 = doEffect
|
|
884
|
+
if ____doEffect_4 == nil then
|
|
885
|
+
____doEffect_4 = false
|
|
863
886
|
end
|
|
864
|
-
__TS__SparseArrayPush(
|
|
865
|
-
|
|
887
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
888
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
866
889
|
end
|
|
867
890
|
function Unit.prototype.healTarget(self, target, amount)
|
|
868
891
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -905,17 +928,16 @@ function Unit.prototype.itemInSlot(self, slot)
|
|
|
905
928
|
return Item:of(unitItemInSlot(self.handle, slot))
|
|
906
929
|
end
|
|
907
930
|
function Unit.prototype.addAbility(self, abilityId)
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
931
|
+
local ability = UnitAbility:of(
|
|
932
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
933
|
+
abilityId,
|
|
934
|
+
self
|
|
935
|
+
)
|
|
936
|
+
if ability ~= nil then
|
|
914
937
|
local abilities = self.abilities
|
|
915
938
|
abilities[#abilities + 1] = ability
|
|
916
|
-
return ability
|
|
917
939
|
end
|
|
918
|
-
return
|
|
940
|
+
return ability
|
|
919
941
|
end
|
|
920
942
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
921
943
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -929,31 +951,21 @@ end
|
|
|
929
951
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
930
952
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
931
953
|
end
|
|
932
|
-
function Unit.prototype.
|
|
933
|
-
local
|
|
934
|
-
|
|
935
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
936
|
-
return nil
|
|
937
|
-
end
|
|
938
|
-
return UnitAbility:of(
|
|
939
|
-
getUnitAbility(self.handle, abilityId),
|
|
940
|
-
abilityId,
|
|
941
|
-
self
|
|
942
|
-
)
|
|
954
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
955
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
956
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
943
957
|
end
|
|
944
|
-
function Unit.prototype.removeAbility(self,
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
end
|
|
958
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
959
|
+
local abilities = self.abilities
|
|
960
|
+
for i = 1, #abilities do
|
|
961
|
+
if abilities[i].typeId == abilityTypeId then
|
|
962
|
+
local ability = abilities[i]
|
|
963
|
+
tremove(abilities, i)
|
|
964
|
+
ability:destroy()
|
|
965
|
+
return true
|
|
953
966
|
end
|
|
954
|
-
return true
|
|
955
967
|
end
|
|
956
|
-
return
|
|
968
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
957
969
|
end
|
|
958
970
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
959
971
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -967,9 +979,6 @@ end
|
|
|
967
979
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
968
980
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
969
981
|
end
|
|
970
|
-
function Unit.prototype.interruptAttack(self)
|
|
971
|
-
unitInterruptAttack(self.handle)
|
|
972
|
-
end
|
|
973
982
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
974
983
|
local handle = self.handle
|
|
975
984
|
unitDisableAbility(handle, abilityId, true, false)
|
|
@@ -1040,18 +1049,44 @@ function Unit.prototype.unpauseEx(self)
|
|
|
1040
1049
|
end
|
|
1041
1050
|
function Unit.prototype.incrementStunCounter(self)
|
|
1042
1051
|
local stunCounter = self[102] or 0
|
|
1043
|
-
if not self[101] or stunCounter >= 0 then
|
|
1052
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
|
|
1044
1053
|
BlzPauseUnitEx(self.handle, true)
|
|
1045
1054
|
end
|
|
1046
1055
|
self[102] = stunCounter + 1
|
|
1047
1056
|
end
|
|
1048
1057
|
function Unit.prototype.decrementStunCounter(self)
|
|
1049
1058
|
local stunCounter = self[102] or 0
|
|
1050
|
-
if not self[101] or stunCounter >= 1 then
|
|
1059
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
|
|
1051
1060
|
BlzPauseUnitEx(self.handle, false)
|
|
1052
1061
|
end
|
|
1053
1062
|
self[102] = stunCounter - 1
|
|
1054
1063
|
end
|
|
1064
|
+
function Unit.prototype.incrementForceStunCounter(self)
|
|
1065
|
+
local forceStunCounter = self[103] or 0
|
|
1066
|
+
if forceStunCounter == 0 then
|
|
1067
|
+
local handle = self.handle
|
|
1068
|
+
if not self[101] then
|
|
1069
|
+
for _ = self[102] or 0, -1 do
|
|
1070
|
+
BlzPauseUnitEx(handle, true)
|
|
1071
|
+
end
|
|
1072
|
+
end
|
|
1073
|
+
BlzPauseUnitEx(handle, true)
|
|
1074
|
+
end
|
|
1075
|
+
self[103] = forceStunCounter + 1
|
|
1076
|
+
end
|
|
1077
|
+
function Unit.prototype.decrementForceStunCounter(self)
|
|
1078
|
+
local forceStunCounter = self[103] or 0
|
|
1079
|
+
if forceStunCounter == 1 then
|
|
1080
|
+
local handle = self.handle
|
|
1081
|
+
if not self[101] then
|
|
1082
|
+
for _ = self[102] or 0, -1 do
|
|
1083
|
+
BlzPauseUnitEx(handle, false)
|
|
1084
|
+
end
|
|
1085
|
+
end
|
|
1086
|
+
BlzPauseUnitEx(handle, false)
|
|
1087
|
+
end
|
|
1088
|
+
self[103] = forceStunCounter - 1
|
|
1089
|
+
end
|
|
1055
1090
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1056
1091
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
1057
1092
|
owner.handle,
|
|
@@ -1240,7 +1275,7 @@ __TS__SetDescriptor(
|
|
|
1240
1275
|
Unit.prototype,
|
|
1241
1276
|
"isIllusion",
|
|
1242
1277
|
{get = function(self)
|
|
1243
|
-
return
|
|
1278
|
+
return IsUnitIllusion(self.handle)
|
|
1244
1279
|
end},
|
|
1245
1280
|
true
|
|
1246
1281
|
)
|
|
@@ -1338,19 +1373,6 @@ __TS__SetDescriptor(
|
|
|
1338
1373
|
},
|
|
1339
1374
|
true
|
|
1340
1375
|
)
|
|
1341
|
-
__TS__SetDescriptor(
|
|
1342
|
-
Unit.prototype,
|
|
1343
|
-
"strengthBase",
|
|
1344
|
-
{
|
|
1345
|
-
get = function(self)
|
|
1346
|
-
return getHeroStr(self.handle, false)
|
|
1347
|
-
end,
|
|
1348
|
-
set = function(self, strengthBase)
|
|
1349
|
-
setHeroStr(self.handle, strengthBase, true)
|
|
1350
|
-
end
|
|
1351
|
-
},
|
|
1352
|
-
true
|
|
1353
|
-
)
|
|
1354
1376
|
__TS__SetDescriptor(
|
|
1355
1377
|
Unit.prototype,
|
|
1356
1378
|
"strengthBonus",
|
|
@@ -1368,19 +1390,6 @@ __TS__SetDescriptor(
|
|
|
1368
1390
|
end},
|
|
1369
1391
|
true
|
|
1370
1392
|
)
|
|
1371
|
-
__TS__SetDescriptor(
|
|
1372
|
-
Unit.prototype,
|
|
1373
|
-
"agilityBase",
|
|
1374
|
-
{
|
|
1375
|
-
get = function(self)
|
|
1376
|
-
return getHeroAgi(self.handle, false)
|
|
1377
|
-
end,
|
|
1378
|
-
set = function(self, agilityBase)
|
|
1379
|
-
setHeroAgi(self.handle, agilityBase, true)
|
|
1380
|
-
end
|
|
1381
|
-
},
|
|
1382
|
-
true
|
|
1383
|
-
)
|
|
1384
1393
|
__TS__SetDescriptor(
|
|
1385
1394
|
Unit.prototype,
|
|
1386
1395
|
"agilityBonus",
|
|
@@ -1398,19 +1407,6 @@ __TS__SetDescriptor(
|
|
|
1398
1407
|
end},
|
|
1399
1408
|
true
|
|
1400
1409
|
)
|
|
1401
|
-
__TS__SetDescriptor(
|
|
1402
|
-
Unit.prototype,
|
|
1403
|
-
"intelligenceBase",
|
|
1404
|
-
{
|
|
1405
|
-
get = function(self)
|
|
1406
|
-
return getHeroInt(self.handle, false)
|
|
1407
|
-
end,
|
|
1408
|
-
set = function(self, intelligenceBase)
|
|
1409
|
-
setHeroInt(self.handle, intelligenceBase, true)
|
|
1410
|
-
end
|
|
1411
|
-
},
|
|
1412
|
-
true
|
|
1413
|
-
)
|
|
1414
1410
|
__TS__SetDescriptor(
|
|
1415
1411
|
Unit.prototype,
|
|
1416
1412
|
"intelligenceBonus",
|
|
@@ -1459,17 +1455,17 @@ __TS__SetDescriptor(
|
|
|
1459
1455
|
"isTeamGlowVisible",
|
|
1460
1456
|
{
|
|
1461
1457
|
get = function(self)
|
|
1462
|
-
return not self[
|
|
1458
|
+
return not self[107]
|
|
1463
1459
|
end,
|
|
1464
1460
|
set = function(self, isTeamGlowVisible)
|
|
1465
1461
|
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1466
|
-
local
|
|
1462
|
+
local ____temp_7
|
|
1467
1463
|
if not isTeamGlowVisible then
|
|
1468
|
-
|
|
1464
|
+
____temp_7 = true
|
|
1469
1465
|
else
|
|
1470
|
-
|
|
1466
|
+
____temp_7 = nil
|
|
1471
1467
|
end
|
|
1472
|
-
self[
|
|
1468
|
+
self[107] = ____temp_7
|
|
1473
1469
|
end
|
|
1474
1470
|
},
|
|
1475
1471
|
true
|
|
@@ -1479,7 +1475,7 @@ __TS__SetDescriptor(
|
|
|
1479
1475
|
"color",
|
|
1480
1476
|
{set = function(self, color)
|
|
1481
1477
|
SetUnitColor(self.handle, color.handle)
|
|
1482
|
-
if self[
|
|
1478
|
+
if self[107] then
|
|
1483
1479
|
BlzShowUnitTeamGlow(self.handle, false)
|
|
1484
1480
|
end
|
|
1485
1481
|
end},
|
|
@@ -1503,14 +1499,14 @@ __TS__SetDescriptor(
|
|
|
1503
1499
|
"maxHealth",
|
|
1504
1500
|
{
|
|
1505
1501
|
get = function(self)
|
|
1506
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1502
|
+
return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
|
|
1507
1503
|
end,
|
|
1508
1504
|
set = function(self, maxHealth)
|
|
1509
|
-
if maxHealth < 1 and self[
|
|
1510
|
-
self[
|
|
1505
|
+
if maxHealth < 1 and self[104] ~= nil then
|
|
1506
|
+
self[105] = (self[105] or 0) + (1 - maxHealth)
|
|
1511
1507
|
maxHealth = 1
|
|
1512
1508
|
end
|
|
1513
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1509
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
|
|
1514
1510
|
end
|
|
1515
1511
|
},
|
|
1516
1512
|
true
|
|
@@ -1552,10 +1548,10 @@ __TS__SetDescriptor(
|
|
|
1552
1548
|
"health",
|
|
1553
1549
|
{
|
|
1554
1550
|
get = function(self)
|
|
1555
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1551
|
+
return GetWidgetLife(self.handle) - (self[106] or 0)
|
|
1556
1552
|
end,
|
|
1557
1553
|
set = function(self, health)
|
|
1558
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1554
|
+
SetWidgetLife(self.handle, health + (self[106] or 0))
|
|
1559
1555
|
end
|
|
1560
1556
|
},
|
|
1561
1557
|
true
|
|
@@ -1631,25 +1627,12 @@ __TS__SetDescriptor(
|
|
|
1631
1627
|
},
|
|
1632
1628
|
true
|
|
1633
1629
|
)
|
|
1634
|
-
__TS__SetDescriptor(
|
|
1635
|
-
Unit.prototype,
|
|
1636
|
-
"flyHeight",
|
|
1637
|
-
{
|
|
1638
|
-
get = function(self)
|
|
1639
|
-
return getUnitFlyHeight(self.handle)
|
|
1640
|
-
end,
|
|
1641
|
-
set = function(self, v)
|
|
1642
|
-
SetUnitFlyHeight(self.handle, v, 100000)
|
|
1643
|
-
end
|
|
1644
|
-
},
|
|
1645
|
-
true
|
|
1646
|
-
)
|
|
1647
1630
|
__TS__SetDescriptor(
|
|
1648
1631
|
Unit.prototype,
|
|
1649
1632
|
"x",
|
|
1650
1633
|
{
|
|
1651
1634
|
get = function(self)
|
|
1652
|
-
return self[
|
|
1635
|
+
return self[108] or getUnitX(self.handle)
|
|
1653
1636
|
end,
|
|
1654
1637
|
set = function(self, v)
|
|
1655
1638
|
SetUnitX(self.handle, v)
|
|
@@ -1662,7 +1645,7 @@ __TS__SetDescriptor(
|
|
|
1662
1645
|
"y",
|
|
1663
1646
|
{
|
|
1664
1647
|
get = function(self)
|
|
1665
|
-
return self[
|
|
1648
|
+
return self[109] or getUnitY(self.handle)
|
|
1666
1649
|
end,
|
|
1667
1650
|
set = function(self, v)
|
|
1668
1651
|
SetUnitY(self.handle, v)
|
|
@@ -1767,14 +1750,18 @@ __TS__SetDescriptor(
|
|
|
1767
1750
|
local handle = self.handle
|
|
1768
1751
|
if isPaused and not IsUnitPaused(handle) then
|
|
1769
1752
|
self[101] = true
|
|
1770
|
-
|
|
1771
|
-
|
|
1753
|
+
if (self[103] or 0) <= 0 then
|
|
1754
|
+
for _ = self[102] or 0, -1 do
|
|
1755
|
+
BlzPauseUnitEx(handle, true)
|
|
1756
|
+
end
|
|
1772
1757
|
end
|
|
1773
1758
|
PauseUnit(handle, true)
|
|
1774
1759
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1775
1760
|
PauseUnit(handle, false)
|
|
1776
|
-
|
|
1777
|
-
|
|
1761
|
+
if (self[103] or 0) <= 0 then
|
|
1762
|
+
for _ = self[102] or 0, -1 do
|
|
1763
|
+
BlzPauseUnitEx(handle, false)
|
|
1764
|
+
end
|
|
1778
1765
|
end
|
|
1779
1766
|
self[101] = nil
|
|
1780
1767
|
end
|
|
@@ -1832,20 +1819,6 @@ __TS__SetDescriptor(
|
|
|
1832
1819
|
},
|
|
1833
1820
|
true
|
|
1834
1821
|
)
|
|
1835
|
-
__TS__SetDescriptor(
|
|
1836
|
-
Unit.prototype,
|
|
1837
|
-
"scale",
|
|
1838
|
-
{
|
|
1839
|
-
get = function(self)
|
|
1840
|
-
return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
|
|
1841
|
-
end,
|
|
1842
|
-
set = function(self, v)
|
|
1843
|
-
setUnitScale(self.handle, v, v, v)
|
|
1844
|
-
setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
|
|
1845
|
-
end
|
|
1846
|
-
},
|
|
1847
|
-
true
|
|
1848
|
-
)
|
|
1849
1822
|
__TS__SetDescriptor(
|
|
1850
1823
|
Unit.prototype,
|
|
1851
1824
|
"timeScale",
|
|
@@ -2141,6 +2114,11 @@ __TS__SetDescriptor(
|
|
|
2141
2114
|
end},
|
|
2142
2115
|
true
|
|
2143
2116
|
)
|
|
2117
|
+
Unit.levelChangedEvent = __TS__New(
|
|
2118
|
+
____exports.UnitTriggerEvent,
|
|
2119
|
+
EVENT_PLAYER_HERO_LEVEL,
|
|
2120
|
+
function() return ____exports.Unit:of(getTriggerUnit()) end
|
|
2121
|
+
)
|
|
2144
2122
|
Unit.deathEvent = __TS__New(
|
|
2145
2123
|
____exports.UnitTriggerEvent,
|
|
2146
2124
|
EVENT_PLAYER_UNIT_DEATH,
|
|
@@ -2216,25 +2194,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2216
2194
|
InitializingEvent,
|
|
2217
2195
|
function(event)
|
|
2218
2196
|
local function listener(unit, id)
|
|
2219
|
-
local
|
|
2197
|
+
local ____GetSpellTargetUnit_result_10
|
|
2220
2198
|
if GetSpellTargetUnit() then
|
|
2221
|
-
|
|
2199
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2222
2200
|
else
|
|
2223
|
-
local
|
|
2201
|
+
local ____GetSpellTargetItem_result_9
|
|
2224
2202
|
if GetSpellTargetItem() then
|
|
2225
|
-
|
|
2203
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2226
2204
|
else
|
|
2227
|
-
local
|
|
2205
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2228
2206
|
if GetSpellTargetDestructable() then
|
|
2229
|
-
|
|
2207
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2230
2208
|
else
|
|
2231
|
-
|
|
2209
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2232
2210
|
end
|
|
2233
|
-
|
|
2211
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2234
2212
|
end
|
|
2235
|
-
|
|
2213
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2236
2214
|
end
|
|
2237
|
-
local target =
|
|
2215
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2238
2216
|
if target then
|
|
2239
2217
|
invoke(event, unit, id, target)
|
|
2240
2218
|
end
|
|
@@ -2457,12 +2435,7 @@ Unit.onDamaging = (function()
|
|
|
2457
2435
|
preventRetaliation = damagingEventPreventRetaliation
|
|
2458
2436
|
}
|
|
2459
2437
|
if data.isAttack and source then
|
|
2460
|
-
|
|
2461
|
-
if weapon == -1 then
|
|
2462
|
-
local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
|
|
2463
|
-
weapon = 0
|
|
2464
|
-
end
|
|
2465
|
-
data.weapon = assert(source.weapons[weapon + 1])
|
|
2438
|
+
data.weapon = source:chooseWeapon(target)
|
|
2466
2439
|
end
|
|
2467
2440
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2468
2441
|
invoke(
|
|
@@ -2607,7 +2580,7 @@ Unit.onDamage = __TS__New(
|
|
|
2607
2580
|
invoke(event, source, target, evData)
|
|
2608
2581
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2609
2582
|
local bonusHealth = math.ceil(evData.amount)
|
|
2610
|
-
target[
|
|
2583
|
+
target[106] = (target[106] or 0) + bonusHealth
|
|
2611
2584
|
BlzSetUnitMaxHP(
|
|
2612
2585
|
target.handle,
|
|
2613
2586
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2621,7 +2594,7 @@ Unit.onDamage = __TS__New(
|
|
|
2621
2594
|
evData[0],
|
|
2622
2595
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2623
2596
|
)
|
|
2624
|
-
target[
|
|
2597
|
+
target[106] = (target[106] or 0) - bonusHealth
|
|
2625
2598
|
SetWidgetLife(
|
|
2626
2599
|
target.handle,
|
|
2627
2600
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2657,10 +2630,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2657
2630
|
____exports.UnitTriggerEvent,
|
|
2658
2631
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2659
2632
|
function()
|
|
2660
|
-
local
|
|
2661
|
-
local
|
|
2662
|
-
if getUnitTypeId(
|
|
2663
|
-
|
|
2633
|
+
local unitHandle = getTriggerUnit()
|
|
2634
|
+
local itemHandle = getManipulatedItem()
|
|
2635
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2636
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2637
|
+
local item = Item:of(itemHandle)
|
|
2638
|
+
if item.owner ~= unit then
|
|
2639
|
+
return unit, item
|
|
2640
|
+
end
|
|
2664
2641
|
end
|
|
2665
2642
|
return IgnoreEvent
|
|
2666
2643
|
end
|
|
@@ -2680,7 +2657,7 @@ Unit.itemUsedEvent = __TS__New(
|
|
|
2680
2657
|
Unit.itemStackedEvent = __TS__New(
|
|
2681
2658
|
____exports.UnitTriggerEvent,
|
|
2682
2659
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2683
|
-
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(
|
|
2660
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2684
2661
|
)
|
|
2685
2662
|
__TS__ObjectDefineProperty(
|
|
2686
2663
|
Unit,
|
|
@@ -2767,6 +2744,10 @@ __TS__ObjectDefineProperty(
|
|
|
2767
2744
|
rawset(self, "destroyEvent", destroyEvent)
|
|
2768
2745
|
return destroyEvent
|
|
2769
2746
|
end}
|
|
2747
|
+
)
|
|
2748
|
+
Unit.synchronize = synchronizer(
|
|
2749
|
+
function(unit) return unit.syncId end,
|
|
2750
|
+
function(syncId) return unitBySyncId[syncId] end
|
|
2770
2751
|
);
|
|
2771
2752
|
(function(self)
|
|
2772
2753
|
local leaveAbilityIds = postcompile(function()
|