warscript 0.0.1-dev.85b1c63 → 0.0.1-dev.870376f
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 +14 -9
- package/core/types/player.d.ts +16 -0
- package/core/types/player.lua +57 -14
- package/core/types/playerCamera.lua +44 -0
- package/core/types/tileCell.d.ts +11 -1
- package/core/types/tileCell.lua +97 -0
- package/core/types/timer.d.ts +3 -2
- package/core/types/timer.lua +8 -2
- package/decl/native.d.ts +2 -2
- package/destroyable.d.ts +1 -0
- package/destroyable.lua +9 -0
- package/engine/behavior.d.ts +11 -2
- package/engine/behavior.lua +174 -71
- package/engine/behaviour/ability/apply-buff.lua +4 -4
- package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
- package/engine/behaviour/ability/remove-buffs.lua +21 -0
- package/engine/behaviour/ability.d.ts +6 -1
- package/engine/behaviour/ability.lua +31 -1
- package/engine/behaviour/unit/stun-immunity.d.ts +9 -5
- package/engine/behaviour/unit/stun-immunity.lua +17 -7
- package/engine/behaviour/unit.d.ts +9 -3
- package/engine/behaviour/unit.lua +108 -26
- package/engine/buff.d.ts +19 -4
- package/engine/buff.lua +122 -41
- package/engine/internal/ability.lua +6 -5
- package/engine/internal/item.d.ts +13 -15
- package/engine/internal/item.lua +59 -48
- package/engine/internal/mechanics/cast-ability.lua +6 -3
- 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 +14 -14
- package/engine/internal/unit/ability.lua +72 -45
- 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/range-event.d.ts +12 -0
- package/engine/internal/unit/range-event.lua +90 -0
- package/engine/internal/unit/scale.d.ts +7 -0
- package/engine/internal/unit/scale.lua +20 -0
- package/engine/internal/unit-missile-launch.lua +51 -20
- package/engine/internal/unit.d.ts +17 -21
- package/engine/internal/unit.lua +166 -188
- package/engine/local-client.d.ts +2 -0
- package/engine/local-client.lua +30 -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/reincarnation.d.ts +8 -0
- package/engine/object-data/entry/ability-type/reincarnation.lua +26 -0
- package/engine/object-data/entry/ability-type.lua +4 -1
- 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 +4 -0
- package/engine/object-data/entry/unit-type.lua +76 -32
- package/engine/object-field/unit.d.ts +20 -5
- package/engine/object-field/unit.lua +61 -0
- package/engine/object-field.d.ts +9 -1
- package/engine/object-field.lua +265 -122
- package/engine/random.d.ts +10 -0
- package/engine/random.lua +21 -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 +11 -3
- package/engine/standard/fields/unit.lua +15 -2
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.lua +3 -2
- 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-lua.lua +15 -0
- 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 +5 -1
- package/utility/callback-array.lua +16 -1
- package/utility/linked-map.d.ts +34 -0
- package/utility/linked-map.lua +101 -0
- package/utility/linked-set.d.ts +3 -1
- package/utility/linked-set.lua +40 -1
- package/utility/lua-maps.d.ts +11 -2
- package/utility/lua-maps.lua +33 -2
- package/utility/records.lua +20 -1
- package/utility/types.d.ts +3 -0
package/engine/internal/unit.lua
CHANGED
|
@@ -62,6 +62,10 @@ local ____attributes = require("attributes")
|
|
|
62
62
|
local isAttribute = ____attributes.isAttribute
|
|
63
63
|
local ____ability = require("engine.internal.item.ability")
|
|
64
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
|
|
65
69
|
local match = string.match
|
|
66
70
|
local ____tostring = _G.tostring
|
|
67
71
|
local setUnitAnimation = SetUnitAnimation
|
|
@@ -71,16 +75,12 @@ local getUnitRealField = BlzGetUnitRealField
|
|
|
71
75
|
local getHeroStr = GetHeroStr
|
|
72
76
|
local getHeroAgi = GetHeroAgi
|
|
73
77
|
local getHeroInt = GetHeroInt
|
|
74
|
-
local setHeroStr = SetHeroStr
|
|
75
|
-
local setHeroAgi = SetHeroAgi
|
|
76
|
-
local setHeroInt = SetHeroInt
|
|
77
78
|
local getUnitBooleanField = BlzGetUnitBooleanField
|
|
78
79
|
local getUnitStringField = BlzGetUnitStringField
|
|
79
80
|
local setUnitIntegerField = BlzSetUnitIntegerField
|
|
80
81
|
local setUnitRealField = BlzSetUnitRealField
|
|
81
82
|
local setUnitBooleanField = BlzSetUnitBooleanField
|
|
82
83
|
local setUnitStringField = BlzSetUnitStringField
|
|
83
|
-
local setUnitScale = SetUnitScale
|
|
84
84
|
local setUnitPosition = SetUnitPosition
|
|
85
85
|
local setUnitTimeScale = SetUnitTimeScale
|
|
86
86
|
local getHandleId = GetHandleId
|
|
@@ -108,7 +108,6 @@ local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
|
108
108
|
local setUnitWeaponStringField = BlzSetUnitWeaponStringField
|
|
109
109
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
110
110
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
111
|
-
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
112
111
|
local isUnitInvisible = IsUnitInvisible
|
|
113
112
|
local isUnitVisible = IsUnitVisible
|
|
114
113
|
local getUnitX = GetUnitX
|
|
@@ -384,15 +383,27 @@ local modifiers = {
|
|
|
384
383
|
end,
|
|
385
384
|
armor = function(unit, value)
|
|
386
385
|
if UnitAddAbility(unit, armorBonusAbilityId) then
|
|
387
|
-
assert(
|
|
386
|
+
assert(
|
|
387
|
+
UnitMakeAbilityPermanent(unit, true, armorBonusAbilityId),
|
|
388
|
+
"armor bonus ability must be made permanent",
|
|
389
|
+
unit
|
|
390
|
+
)
|
|
388
391
|
end
|
|
389
|
-
local ability = assert(
|
|
390
|
-
|
|
391
|
-
ability,
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
392
|
+
local ability = assert(
|
|
393
|
+
BlzGetUnitAbility(unit, armorBonusAbilityId),
|
|
394
|
+
"armor bonus ability must be existing",
|
|
395
|
+
unit
|
|
396
|
+
)
|
|
397
|
+
assert(
|
|
398
|
+
BlzSetAbilityRealLevelField(
|
|
399
|
+
ability,
|
|
400
|
+
armorBonusField,
|
|
401
|
+
0,
|
|
402
|
+
BlzGetAbilityRealLevelField(ability, armorBonusField, 0) + value
|
|
403
|
+
),
|
|
404
|
+
"armor bonus ability field must be set",
|
|
405
|
+
unit
|
|
406
|
+
)
|
|
396
407
|
end
|
|
397
408
|
}
|
|
398
409
|
local getters = {
|
|
@@ -410,6 +421,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
|
410
421
|
self.unit = unit
|
|
411
422
|
self.index = index
|
|
412
423
|
end
|
|
424
|
+
__TS__SetDescriptor(
|
|
425
|
+
UnitWeapon.prototype,
|
|
426
|
+
"isEnabled",
|
|
427
|
+
{
|
|
428
|
+
get = function(self)
|
|
429
|
+
return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
|
|
430
|
+
end,
|
|
431
|
+
set = function(self, isEnabled)
|
|
432
|
+
BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
|
|
433
|
+
end
|
|
434
|
+
},
|
|
435
|
+
true
|
|
436
|
+
)
|
|
413
437
|
__TS__SetDescriptor(
|
|
414
438
|
UnitWeapon.prototype,
|
|
415
439
|
"cooldown",
|
|
@@ -633,26 +657,30 @@ local fieldSetters = {
|
|
|
633
657
|
}
|
|
634
658
|
local dummies = {}
|
|
635
659
|
for ____, player in ipairs(Player.all) do
|
|
636
|
-
local dummy = assert(
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
660
|
+
local dummy = assert(
|
|
661
|
+
createUnit(
|
|
662
|
+
player.handle,
|
|
663
|
+
dummyUnitId,
|
|
664
|
+
0,
|
|
665
|
+
0,
|
|
666
|
+
270
|
|
667
|
+
),
|
|
668
|
+
"dummy must be created",
|
|
669
|
+
player
|
|
670
|
+
)
|
|
643
671
|
ShowUnit(dummy, false)
|
|
644
672
|
dummies[player] = dummy
|
|
645
673
|
end
|
|
646
674
|
local function delayHealthChecksCallback(unit)
|
|
647
|
-
local counter = (unit[
|
|
675
|
+
local counter = (unit[104] or 0) - 1
|
|
648
676
|
if counter ~= 0 then
|
|
649
|
-
unit[
|
|
677
|
+
unit[104] = counter
|
|
650
678
|
return
|
|
651
679
|
end
|
|
652
|
-
unit[
|
|
653
|
-
local healthBonus = unit[
|
|
680
|
+
unit[104] = nil
|
|
681
|
+
local healthBonus = unit[105]
|
|
654
682
|
if healthBonus ~= nil then
|
|
655
|
-
unit[
|
|
683
|
+
unit[105] = nil
|
|
656
684
|
local handle = unit.handle
|
|
657
685
|
BlzSetUnitMaxHP(
|
|
658
686
|
handle,
|
|
@@ -682,41 +710,57 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
682
710
|
nextSyncId = ____nextSyncId_1 + 1
|
|
683
711
|
self.syncId = ____nextSyncId_1
|
|
684
712
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
685
|
-
assert(
|
|
686
|
-
|
|
713
|
+
assert(
|
|
714
|
+
unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId),
|
|
715
|
+
"leave detection ability must be added",
|
|
716
|
+
self
|
|
717
|
+
)
|
|
718
|
+
assert(
|
|
719
|
+
unitAddAbility(handle, morphDetectAbilityId),
|
|
720
|
+
"morph detection ability must be added",
|
|
721
|
+
self
|
|
722
|
+
)
|
|
687
723
|
if unitAddAbility(
|
|
688
724
|
handle,
|
|
689
725
|
fourCC("Amrf")
|
|
690
726
|
) then
|
|
691
|
-
assert(
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
727
|
+
assert(
|
|
728
|
+
unitRemoveAbility(
|
|
729
|
+
handle,
|
|
730
|
+
fourCC("Amrf")
|
|
731
|
+
),
|
|
732
|
+
"fly ability must be removed after addition",
|
|
733
|
+
self
|
|
734
|
+
)
|
|
695
735
|
end
|
|
696
736
|
unitBySyncId[self.syncId] = self
|
|
697
737
|
local ____ = self.abilities
|
|
698
738
|
end
|
|
699
|
-
function Unit.prototype.getEvent(self,
|
|
700
|
-
self.events = self.events or (
|
|
701
|
-
local eventId = GetHandleId(
|
|
702
|
-
|
|
703
|
-
|
|
739
|
+
function Unit.prototype.getEvent(self, jevent, collector)
|
|
740
|
+
self.events = self.events or __TS__New(LinkedMap)
|
|
741
|
+
local eventId = GetHandleId(jevent)
|
|
742
|
+
local event = self.events:get(eventId)
|
|
743
|
+
if event == nil then
|
|
744
|
+
event = __TS__New(
|
|
704
745
|
TriggerEvent,
|
|
705
746
|
function(trigger)
|
|
706
|
-
TriggerRegisterUnitEvent(trigger, self.handle,
|
|
747
|
+
TriggerRegisterUnitEvent(trigger, self.handle, jevent)
|
|
707
748
|
end,
|
|
708
749
|
collector or (function() return {} end)
|
|
709
750
|
)
|
|
751
|
+
self.events:put(eventId, event)
|
|
710
752
|
end
|
|
711
|
-
return
|
|
753
|
+
return event
|
|
754
|
+
end
|
|
755
|
+
function Unit.prototype.saveData(self)
|
|
756
|
+
local handle = self.handle
|
|
757
|
+
self[108] = self[108] or getUnitX(handle)
|
|
758
|
+
self[109] = self[109] or getUnitY(handle)
|
|
759
|
+
self._owner = self._owner or Player:of(getOwningPlayer(handle))
|
|
712
760
|
end
|
|
713
761
|
function Unit.prototype.onDestroy(self)
|
|
714
762
|
local handle = self.handle
|
|
715
|
-
self
|
|
716
|
-
self[108] = getUnitY(handle)
|
|
717
|
-
if not self._owner then
|
|
718
|
-
self._owner = Player:of(getOwningPlayer(handle))
|
|
719
|
-
end
|
|
763
|
+
self:saveData()
|
|
720
764
|
local abilities = self.abilities
|
|
721
765
|
for ____, ability in ipairs(abilities) do
|
|
722
766
|
ability:destroy()
|
|
@@ -752,7 +796,11 @@ function Unit.prototype.addAttackHandler(self, condition, action)
|
|
|
752
796
|
self._attackHandlers = handlers
|
|
753
797
|
if #handlers == 1 then
|
|
754
798
|
local handle = self.handle
|
|
755
|
-
assert(
|
|
799
|
+
assert(
|
|
800
|
+
unitAddAbility(handle, attackHandlerAbilityId) and UnitMakeAbilityPermanent(handle, true, attackHandlerAbilityId),
|
|
801
|
+
"attack handler ability must be added",
|
|
802
|
+
self
|
|
803
|
+
)
|
|
756
804
|
end
|
|
757
805
|
return handler
|
|
758
806
|
end
|
|
@@ -836,16 +884,18 @@ function Unit.prototype.queueAnimation(self, animation)
|
|
|
836
884
|
QueueUnitAnimation(self.handle, animation)
|
|
837
885
|
end
|
|
838
886
|
function Unit.prototype.chooseWeapon(self, target)
|
|
839
|
-
|
|
840
|
-
|
|
887
|
+
local firstWeapon = self.firstWeapon
|
|
888
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
889
|
+
return firstWeapon
|
|
841
890
|
end
|
|
842
|
-
|
|
843
|
-
|
|
891
|
+
local secondWeapon = self.secondWeapon
|
|
892
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
893
|
+
return secondWeapon
|
|
844
894
|
end
|
|
845
895
|
return nil
|
|
846
896
|
end
|
|
847
897
|
function Unit.prototype.delayHealthChecks(self)
|
|
848
|
-
self[
|
|
898
|
+
self[104] = (self[104] or 0) + 1
|
|
849
899
|
Timer:run(delayHealthChecksCallback, self)
|
|
850
900
|
end
|
|
851
901
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -935,20 +985,21 @@ end
|
|
|
935
985
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
936
986
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
937
987
|
end
|
|
938
|
-
function Unit.prototype.
|
|
988
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
939
989
|
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
940
990
|
return UnitAbility:of(ability, abilityId, self)
|
|
941
991
|
end
|
|
942
|
-
function Unit.prototype.removeAbility(self,
|
|
992
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
943
993
|
local abilities = self.abilities
|
|
944
994
|
for i = 1, #abilities do
|
|
945
|
-
if abilities[i].typeId ==
|
|
946
|
-
abilities[i]
|
|
995
|
+
if abilities[i].typeId == abilityTypeId then
|
|
996
|
+
local ability = abilities[i]
|
|
947
997
|
tremove(abilities, i)
|
|
998
|
+
ability:destroy()
|
|
948
999
|
return true
|
|
949
1000
|
end
|
|
950
1001
|
end
|
|
951
|
-
return
|
|
1002
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
952
1003
|
end
|
|
953
1004
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
954
1005
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -962,24 +1013,6 @@ end
|
|
|
962
1013
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
963
1014
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
964
1015
|
end
|
|
965
|
-
function Unit.prototype.interruptMovement(self)
|
|
966
|
-
local handle = self.handle
|
|
967
|
-
unitDisableAbility(
|
|
968
|
-
handle,
|
|
969
|
-
fourCC("Amov"),
|
|
970
|
-
true,
|
|
971
|
-
false
|
|
972
|
-
)
|
|
973
|
-
unitDisableAbility(
|
|
974
|
-
handle,
|
|
975
|
-
fourCC("Amov"),
|
|
976
|
-
false,
|
|
977
|
-
false
|
|
978
|
-
)
|
|
979
|
-
end
|
|
980
|
-
function Unit.prototype.interruptAttack(self)
|
|
981
|
-
unitInterruptAttack(self.handle)
|
|
982
|
-
end
|
|
983
1016
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
984
1017
|
local handle = self.handle
|
|
985
1018
|
unitDisableAbility(handle, abilityId, true, false)
|
|
@@ -1050,18 +1083,44 @@ function Unit.prototype.unpauseEx(self)
|
|
|
1050
1083
|
end
|
|
1051
1084
|
function Unit.prototype.incrementStunCounter(self)
|
|
1052
1085
|
local stunCounter = self[102] or 0
|
|
1053
|
-
if not self[101] or stunCounter >= 0 then
|
|
1086
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
|
|
1054
1087
|
BlzPauseUnitEx(self.handle, true)
|
|
1055
1088
|
end
|
|
1056
1089
|
self[102] = stunCounter + 1
|
|
1057
1090
|
end
|
|
1058
1091
|
function Unit.prototype.decrementStunCounter(self)
|
|
1059
1092
|
local stunCounter = self[102] or 0
|
|
1060
|
-
if not self[101] or stunCounter >= 1 then
|
|
1093
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
|
|
1061
1094
|
BlzPauseUnitEx(self.handle, false)
|
|
1062
1095
|
end
|
|
1063
1096
|
self[102] = stunCounter - 1
|
|
1064
1097
|
end
|
|
1098
|
+
function Unit.prototype.incrementForceStunCounter(self)
|
|
1099
|
+
local forceStunCounter = self[103] or 0
|
|
1100
|
+
if forceStunCounter == 0 then
|
|
1101
|
+
local handle = self.handle
|
|
1102
|
+
if not self[101] then
|
|
1103
|
+
for _ = self[102] or 0, -1 do
|
|
1104
|
+
BlzPauseUnitEx(handle, true)
|
|
1105
|
+
end
|
|
1106
|
+
end
|
|
1107
|
+
BlzPauseUnitEx(handle, true)
|
|
1108
|
+
end
|
|
1109
|
+
self[103] = forceStunCounter + 1
|
|
1110
|
+
end
|
|
1111
|
+
function Unit.prototype.decrementForceStunCounter(self)
|
|
1112
|
+
local forceStunCounter = self[103] or 0
|
|
1113
|
+
if forceStunCounter == 1 then
|
|
1114
|
+
local handle = self.handle
|
|
1115
|
+
if not self[101] then
|
|
1116
|
+
for _ = self[102] or 0, -1 do
|
|
1117
|
+
BlzPauseUnitEx(handle, false)
|
|
1118
|
+
end
|
|
1119
|
+
end
|
|
1120
|
+
BlzPauseUnitEx(handle, false)
|
|
1121
|
+
end
|
|
1122
|
+
self[103] = forceStunCounter - 1
|
|
1123
|
+
end
|
|
1065
1124
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1066
1125
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
1067
1126
|
owner.handle,
|
|
@@ -1348,19 +1407,6 @@ __TS__SetDescriptor(
|
|
|
1348
1407
|
},
|
|
1349
1408
|
true
|
|
1350
1409
|
)
|
|
1351
|
-
__TS__SetDescriptor(
|
|
1352
|
-
Unit.prototype,
|
|
1353
|
-
"strengthBase",
|
|
1354
|
-
{
|
|
1355
|
-
get = function(self)
|
|
1356
|
-
return getHeroStr(self.handle, false)
|
|
1357
|
-
end,
|
|
1358
|
-
set = function(self, strengthBase)
|
|
1359
|
-
setHeroStr(self.handle, strengthBase, true)
|
|
1360
|
-
end
|
|
1361
|
-
},
|
|
1362
|
-
true
|
|
1363
|
-
)
|
|
1364
1410
|
__TS__SetDescriptor(
|
|
1365
1411
|
Unit.prototype,
|
|
1366
1412
|
"strengthBonus",
|
|
@@ -1378,19 +1424,6 @@ __TS__SetDescriptor(
|
|
|
1378
1424
|
end},
|
|
1379
1425
|
true
|
|
1380
1426
|
)
|
|
1381
|
-
__TS__SetDescriptor(
|
|
1382
|
-
Unit.prototype,
|
|
1383
|
-
"agilityBase",
|
|
1384
|
-
{
|
|
1385
|
-
get = function(self)
|
|
1386
|
-
return getHeroAgi(self.handle, false)
|
|
1387
|
-
end,
|
|
1388
|
-
set = function(self, agilityBase)
|
|
1389
|
-
setHeroAgi(self.handle, agilityBase, true)
|
|
1390
|
-
end
|
|
1391
|
-
},
|
|
1392
|
-
true
|
|
1393
|
-
)
|
|
1394
1427
|
__TS__SetDescriptor(
|
|
1395
1428
|
Unit.prototype,
|
|
1396
1429
|
"agilityBonus",
|
|
@@ -1408,19 +1441,6 @@ __TS__SetDescriptor(
|
|
|
1408
1441
|
end},
|
|
1409
1442
|
true
|
|
1410
1443
|
)
|
|
1411
|
-
__TS__SetDescriptor(
|
|
1412
|
-
Unit.prototype,
|
|
1413
|
-
"intelligenceBase",
|
|
1414
|
-
{
|
|
1415
|
-
get = function(self)
|
|
1416
|
-
return getHeroInt(self.handle, false)
|
|
1417
|
-
end,
|
|
1418
|
-
set = function(self, intelligenceBase)
|
|
1419
|
-
setHeroInt(self.handle, intelligenceBase, true)
|
|
1420
|
-
end
|
|
1421
|
-
},
|
|
1422
|
-
true
|
|
1423
|
-
)
|
|
1424
1444
|
__TS__SetDescriptor(
|
|
1425
1445
|
Unit.prototype,
|
|
1426
1446
|
"intelligenceBonus",
|
|
@@ -1469,7 +1489,7 @@ __TS__SetDescriptor(
|
|
|
1469
1489
|
"isTeamGlowVisible",
|
|
1470
1490
|
{
|
|
1471
1491
|
get = function(self)
|
|
1472
|
-
return not self[
|
|
1492
|
+
return not self[107]
|
|
1473
1493
|
end,
|
|
1474
1494
|
set = function(self, isTeamGlowVisible)
|
|
1475
1495
|
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
@@ -1479,7 +1499,7 @@ __TS__SetDescriptor(
|
|
|
1479
1499
|
else
|
|
1480
1500
|
____temp_7 = nil
|
|
1481
1501
|
end
|
|
1482
|
-
self[
|
|
1502
|
+
self[107] = ____temp_7
|
|
1483
1503
|
end
|
|
1484
1504
|
},
|
|
1485
1505
|
true
|
|
@@ -1489,7 +1509,7 @@ __TS__SetDescriptor(
|
|
|
1489
1509
|
"color",
|
|
1490
1510
|
{set = function(self, color)
|
|
1491
1511
|
SetUnitColor(self.handle, color.handle)
|
|
1492
|
-
if self[
|
|
1512
|
+
if self[107] then
|
|
1493
1513
|
BlzShowUnitTeamGlow(self.handle, false)
|
|
1494
1514
|
end
|
|
1495
1515
|
end},
|
|
@@ -1513,14 +1533,14 @@ __TS__SetDescriptor(
|
|
|
1513
1533
|
"maxHealth",
|
|
1514
1534
|
{
|
|
1515
1535
|
get = function(self)
|
|
1516
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1536
|
+
return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
|
|
1517
1537
|
end,
|
|
1518
1538
|
set = function(self, maxHealth)
|
|
1519
|
-
if maxHealth < 1 and self[
|
|
1520
|
-
self[
|
|
1539
|
+
if maxHealth < 1 and self[104] ~= nil then
|
|
1540
|
+
self[105] = (self[105] or 0) + (1 - maxHealth)
|
|
1521
1541
|
maxHealth = 1
|
|
1522
1542
|
end
|
|
1523
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1543
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
|
|
1524
1544
|
end
|
|
1525
1545
|
},
|
|
1526
1546
|
true
|
|
@@ -1562,10 +1582,10 @@ __TS__SetDescriptor(
|
|
|
1562
1582
|
"health",
|
|
1563
1583
|
{
|
|
1564
1584
|
get = function(self)
|
|
1565
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1585
|
+
return GetWidgetLife(self.handle) - (self[106] or 0)
|
|
1566
1586
|
end,
|
|
1567
1587
|
set = function(self, health)
|
|
1568
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1588
|
+
SetWidgetLife(self.handle, health + (self[106] or 0))
|
|
1569
1589
|
end
|
|
1570
1590
|
},
|
|
1571
1591
|
true
|
|
@@ -1641,25 +1661,12 @@ __TS__SetDescriptor(
|
|
|
1641
1661
|
},
|
|
1642
1662
|
true
|
|
1643
1663
|
)
|
|
1644
|
-
__TS__SetDescriptor(
|
|
1645
|
-
Unit.prototype,
|
|
1646
|
-
"flyHeight",
|
|
1647
|
-
{
|
|
1648
|
-
get = function(self)
|
|
1649
|
-
return getUnitFlyHeight(self.handle)
|
|
1650
|
-
end,
|
|
1651
|
-
set = function(self, v)
|
|
1652
|
-
SetUnitFlyHeight(self.handle, v, 100000)
|
|
1653
|
-
end
|
|
1654
|
-
},
|
|
1655
|
-
true
|
|
1656
|
-
)
|
|
1657
1664
|
__TS__SetDescriptor(
|
|
1658
1665
|
Unit.prototype,
|
|
1659
1666
|
"x",
|
|
1660
1667
|
{
|
|
1661
1668
|
get = function(self)
|
|
1662
|
-
return self[
|
|
1669
|
+
return self[108] or getUnitX(self.handle)
|
|
1663
1670
|
end,
|
|
1664
1671
|
set = function(self, v)
|
|
1665
1672
|
SetUnitX(self.handle, v)
|
|
@@ -1672,7 +1679,7 @@ __TS__SetDescriptor(
|
|
|
1672
1679
|
"y",
|
|
1673
1680
|
{
|
|
1674
1681
|
get = function(self)
|
|
1675
|
-
return self[
|
|
1682
|
+
return self[109] or getUnitY(self.handle)
|
|
1676
1683
|
end,
|
|
1677
1684
|
set = function(self, v)
|
|
1678
1685
|
SetUnitY(self.handle, v)
|
|
@@ -1777,14 +1784,18 @@ __TS__SetDescriptor(
|
|
|
1777
1784
|
local handle = self.handle
|
|
1778
1785
|
if isPaused and not IsUnitPaused(handle) then
|
|
1779
1786
|
self[101] = true
|
|
1780
|
-
|
|
1781
|
-
|
|
1787
|
+
if (self[103] or 0) <= 0 then
|
|
1788
|
+
for _ = self[102] or 0, -1 do
|
|
1789
|
+
BlzPauseUnitEx(handle, true)
|
|
1790
|
+
end
|
|
1782
1791
|
end
|
|
1783
1792
|
PauseUnit(handle, true)
|
|
1784
1793
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1785
1794
|
PauseUnit(handle, false)
|
|
1786
|
-
|
|
1787
|
-
|
|
1795
|
+
if (self[103] or 0) <= 0 then
|
|
1796
|
+
for _ = self[102] or 0, -1 do
|
|
1797
|
+
BlzPauseUnitEx(handle, false)
|
|
1798
|
+
end
|
|
1788
1799
|
end
|
|
1789
1800
|
self[101] = nil
|
|
1790
1801
|
end
|
|
@@ -1842,20 +1853,6 @@ __TS__SetDescriptor(
|
|
|
1842
1853
|
},
|
|
1843
1854
|
true
|
|
1844
1855
|
)
|
|
1845
|
-
__TS__SetDescriptor(
|
|
1846
|
-
Unit.prototype,
|
|
1847
|
-
"scale",
|
|
1848
|
-
{
|
|
1849
|
-
get = function(self)
|
|
1850
|
-
return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
|
|
1851
|
-
end,
|
|
1852
|
-
set = function(self, v)
|
|
1853
|
-
setUnitScale(self.handle, v, v, v)
|
|
1854
|
-
setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
|
|
1855
|
-
end
|
|
1856
|
-
},
|
|
1857
|
-
true
|
|
1858
|
-
)
|
|
1859
1856
|
__TS__SetDescriptor(
|
|
1860
1857
|
Unit.prototype,
|
|
1861
1858
|
"timeScale",
|
|
@@ -1992,30 +1989,6 @@ __TS__SetDescriptor(
|
|
|
1992
1989
|
end},
|
|
1993
1990
|
true
|
|
1994
1991
|
)
|
|
1995
|
-
__TS__SetDescriptor(
|
|
1996
|
-
Unit.prototype,
|
|
1997
|
-
"onUnitInRange",
|
|
1998
|
-
{get = function(self)
|
|
1999
|
-
local handle = self.handle
|
|
2000
|
-
local onUnitInRange = setmetatable(
|
|
2001
|
-
{},
|
|
2002
|
-
{__index = function(self, value)
|
|
2003
|
-
local event = __TS__New(
|
|
2004
|
-
TriggerEvent,
|
|
2005
|
-
function(trigger)
|
|
2006
|
-
TriggerRegisterUnitInRangeSimple(trigger, value, handle)
|
|
2007
|
-
end,
|
|
2008
|
-
function() return ____exports.Unit:of(handle) end
|
|
2009
|
-
)
|
|
2010
|
-
rawset(self, value, event)
|
|
2011
|
-
return event
|
|
2012
|
-
end}
|
|
2013
|
-
)
|
|
2014
|
-
rawset(self, "onUnitInRange", onUnitInRange)
|
|
2015
|
-
return onUnitInRange
|
|
2016
|
-
end},
|
|
2017
|
-
true
|
|
2018
|
-
)
|
|
2019
1992
|
__TS__SetDescriptor(
|
|
2020
1993
|
Unit.prototype,
|
|
2021
1994
|
"onManaEqual",
|
|
@@ -2151,6 +2124,11 @@ __TS__SetDescriptor(
|
|
|
2151
2124
|
end},
|
|
2152
2125
|
true
|
|
2153
2126
|
)
|
|
2127
|
+
Unit.levelChangedEvent = __TS__New(
|
|
2128
|
+
____exports.UnitTriggerEvent,
|
|
2129
|
+
EVENT_PLAYER_HERO_LEVEL,
|
|
2130
|
+
function() return ____exports.Unit:of(getTriggerUnit()) end
|
|
2131
|
+
)
|
|
2154
2132
|
Unit.deathEvent = __TS__New(
|
|
2155
2133
|
____exports.UnitTriggerEvent,
|
|
2156
2134
|
EVENT_PLAYER_UNIT_DEATH,
|
|
@@ -2467,12 +2445,7 @@ Unit.onDamaging = (function()
|
|
|
2467
2445
|
preventRetaliation = damagingEventPreventRetaliation
|
|
2468
2446
|
}
|
|
2469
2447
|
if data.isAttack and source then
|
|
2470
|
-
|
|
2471
|
-
if weapon == -1 then
|
|
2472
|
-
local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
|
|
2473
|
-
weapon = 0
|
|
2474
|
-
end
|
|
2475
|
-
data.weapon = assert(source.weapons[weapon + 1])
|
|
2448
|
+
data.weapon = source:chooseWeapon(target)
|
|
2476
2449
|
end
|
|
2477
2450
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2478
2451
|
invoke(
|
|
@@ -2617,7 +2590,7 @@ Unit.onDamage = __TS__New(
|
|
|
2617
2590
|
invoke(event, source, target, evData)
|
|
2618
2591
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2619
2592
|
local bonusHealth = math.ceil(evData.amount)
|
|
2620
|
-
target[
|
|
2593
|
+
target[106] = (target[106] or 0) + bonusHealth
|
|
2621
2594
|
BlzSetUnitMaxHP(
|
|
2622
2595
|
target.handle,
|
|
2623
2596
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2631,7 +2604,7 @@ Unit.onDamage = __TS__New(
|
|
|
2631
2604
|
evData[0],
|
|
2632
2605
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2633
2606
|
)
|
|
2634
|
-
target[
|
|
2607
|
+
target[106] = (target[106] or 0) - bonusHealth
|
|
2635
2608
|
SetWidgetLife(
|
|
2636
2609
|
target.handle,
|
|
2637
2610
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2781,6 +2754,10 @@ __TS__ObjectDefineProperty(
|
|
|
2781
2754
|
rawset(self, "destroyEvent", destroyEvent)
|
|
2782
2755
|
return destroyEvent
|
|
2783
2756
|
end}
|
|
2757
|
+
)
|
|
2758
|
+
Unit.synchronize = synchronizer(
|
|
2759
|
+
function(unit) return unit.syncId end,
|
|
2760
|
+
function(syncId) return unitBySyncId[syncId] end
|
|
2784
2761
|
);
|
|
2785
2762
|
(function(self)
|
|
2786
2763
|
local leaveAbilityIds = postcompile(function()
|
|
@@ -2810,7 +2787,8 @@ __TS__ObjectDefineProperty(
|
|
|
2810
2787
|
return
|
|
2811
2788
|
end
|
|
2812
2789
|
end
|
|
2813
|
-
unit:
|
|
2790
|
+
unit:saveData()
|
|
2791
|
+
Timer:run(unit, "destroy")
|
|
2814
2792
|
end)
|
|
2815
2793
|
end
|
|
2816
2794
|
end)(Unit)
|
package/engine/local-client.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Unit } from "../core/types/unit";
|
|
|
3
3
|
import { Async } from "../core/types/async";
|
|
4
4
|
import { Event, TriggerEvent } from "../event";
|
|
5
5
|
import { GraphicsMode } from "./index";
|
|
6
|
+
import { Color } from "../core/types/color";
|
|
6
7
|
export declare class LocalClient {
|
|
7
8
|
private constructor();
|
|
8
9
|
static readonly locale: string;
|
|
@@ -11,6 +12,7 @@ export declare class LocalClient {
|
|
|
11
12
|
static get isHD(): boolean;
|
|
12
13
|
static get graphicsMode(): GraphicsMode;
|
|
13
14
|
static get isActive(): boolean;
|
|
15
|
+
static pingMinimap(x: number, y: number, duration: number, ...parameters: [] | [red: number, green: number, blue: number, flashy?: boolean] | [color: Color, flashy?: boolean]): void;
|
|
14
16
|
static get mouseFocusUnit(): Async<Unit> | undefined;
|
|
15
17
|
static get mainSelectedUnit(): Async<Unit> | undefined;
|
|
16
18
|
static get mainSelectedUnitChangeEvent(): Event<[
|