warscript 0.0.1-dev.2cd2e68 → 0.0.1-dev.3030dbc
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 +15 -0
- package/core/types/player.lua +56 -14
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +123 -5
- package/core/types/tileCell.d.ts +9 -0
- package/core/types/tileCell.lua +92 -0
- package/core/types/timer.d.ts +3 -1
- package/core/types/timer.lua +27 -2
- package/decl/native.d.ts +6 -4
- package/engine/behavior.d.ts +5 -0
- package/engine/behavior.lua +106 -27
- package/engine/behaviour/ability/apply-buff.lua +1 -1
- 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.lua +7 -16
- package/engine/behaviour/unit/stun-immunity.d.ts +7 -3
- package/engine/behaviour/unit/stun-immunity.lua +52 -27
- package/engine/behaviour/unit.d.ts +19 -2
- package/engine/behaviour/unit.lua +83 -7
- package/engine/buff.d.ts +12 -5
- package/engine/buff.lua +123 -86
- 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/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 -5
- package/engine/internal/unit/ability.lua +96 -21
- 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+ability.lua +10 -1
- package/engine/internal/unit-missile-launch.lua +45 -14
- package/engine/internal/unit.d.ts +19 -12
- package/engine/internal/unit.lua +170 -109
- 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.lua +5 -4
- package/engine/object-data/entry/unit-type.d.ts +11 -2
- package/engine/object-data/entry/unit-type.lua +59 -1
- package/engine/object-field/ability.d.ts +3 -3
- package/engine/object-field/ability.lua +7 -6
- package/engine/object-field/unit.d.ts +11 -0
- package/engine/object-field/unit.lua +34 -0
- package/engine/object-field.d.ts +11 -3
- package/engine/object-field.lua +194 -102
- package/engine/random.d.ts +9 -0
- package/engine/random.lua +13 -0
- package/engine/standard/fields/unit.d.ts +4 -0
- package/engine/standard/fields/unit.lua +7 -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 +1 -0
- package/engine/unit.lua +1 -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 -26
- package/core/types/order.lua +0 -65
package/engine/internal/unit.lua
CHANGED
|
@@ -60,6 +60,10 @@ 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
|
|
63
67
|
local match = string.match
|
|
64
68
|
local ____tostring = _G.tostring
|
|
65
69
|
local setUnitAnimation = SetUnitAnimation
|
|
@@ -123,10 +127,6 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
123
127
|
local getIssuedOrderId = GetIssuedOrderId
|
|
124
128
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
125
129
|
local unitAlive = UnitAlive
|
|
126
|
-
local unitAddType = UnitAddType
|
|
127
|
-
local unitRemoveType = UnitRemoveType
|
|
128
|
-
local isUnitIllusion = IsUnitIllusion
|
|
129
|
-
local isUnitType = IsUnitType
|
|
130
130
|
local isUnitAlly = IsUnitAlly
|
|
131
131
|
local isUnitEnemy = IsUnitEnemy
|
|
132
132
|
local getOwningPlayer = GetOwningPlayer
|
|
@@ -412,6 +412,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
|
412
412
|
self.unit = unit
|
|
413
413
|
self.index = index
|
|
414
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
|
+
)
|
|
415
428
|
__TS__SetDescriptor(
|
|
416
429
|
UnitWeapon.prototype,
|
|
417
430
|
"cooldown",
|
|
@@ -646,15 +659,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
646
659
|
dummies[player] = dummy
|
|
647
660
|
end
|
|
648
661
|
local function delayHealthChecksCallback(unit)
|
|
649
|
-
local counter = (unit[
|
|
662
|
+
local counter = (unit[104] or 0) - 1
|
|
650
663
|
if counter ~= 0 then
|
|
651
|
-
unit[
|
|
664
|
+
unit[104] = counter
|
|
652
665
|
return
|
|
653
666
|
end
|
|
654
|
-
unit[
|
|
655
|
-
local healthBonus = unit[
|
|
667
|
+
unit[104] = nil
|
|
668
|
+
local healthBonus = unit[105]
|
|
656
669
|
if healthBonus ~= nil then
|
|
657
|
-
unit[
|
|
670
|
+
unit[105] = nil
|
|
658
671
|
local handle = unit.handle
|
|
659
672
|
BlzSetUnitMaxHP(
|
|
660
673
|
handle,
|
|
@@ -665,15 +678,24 @@ end
|
|
|
665
678
|
local nextSyncId = 1
|
|
666
679
|
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
667
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
|
|
668
690
|
____exports.Unit = __TS__Class()
|
|
669
691
|
local Unit = ____exports.Unit
|
|
670
692
|
Unit.name = "Unit"
|
|
671
693
|
__TS__ClassExtends(Unit, Handle)
|
|
672
694
|
function Unit.prototype.____constructor(self, handle)
|
|
673
695
|
Handle.prototype.____constructor(self, handle)
|
|
674
|
-
local
|
|
675
|
-
nextSyncId =
|
|
676
|
-
self.syncId =
|
|
696
|
+
local ____nextSyncId_1 = nextSyncId
|
|
697
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
698
|
+
self.syncId = ____nextSyncId_1
|
|
677
699
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
678
700
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
679
701
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -705,8 +727,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
705
727
|
end
|
|
706
728
|
function Unit.prototype.onDestroy(self)
|
|
707
729
|
local handle = self.handle
|
|
708
|
-
self[
|
|
709
|
-
self[
|
|
730
|
+
self[108] = getUnitX(handle)
|
|
731
|
+
self[109] = getUnitY(handle)
|
|
710
732
|
if not self._owner then
|
|
711
733
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
712
734
|
end
|
|
@@ -774,17 +796,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
774
796
|
end}
|
|
775
797
|
end
|
|
776
798
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
777
|
-
local
|
|
778
|
-
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
|
|
779
801
|
end
|
|
780
802
|
function Unit.prototype.addClassification(self, classification)
|
|
781
|
-
return
|
|
803
|
+
return UnitAddType(self.handle, classification)
|
|
782
804
|
end
|
|
783
805
|
function Unit.prototype.removeClassification(self, classification)
|
|
784
|
-
return
|
|
806
|
+
return UnitRemoveType(self.handle, classification)
|
|
785
807
|
end
|
|
786
808
|
function Unit.prototype.hasClassification(self, classification)
|
|
787
|
-
return
|
|
809
|
+
return IsUnitType(self.handle, classification)
|
|
788
810
|
end
|
|
789
811
|
function Unit.prototype.isVisibleTo(self, player)
|
|
790
812
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -793,13 +815,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
793
815
|
return isUnitInvisible(self.handle, player.handle)
|
|
794
816
|
end
|
|
795
817
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
796
|
-
local
|
|
818
|
+
local ____temp_3
|
|
797
819
|
if type(x) == "number" then
|
|
798
|
-
|
|
820
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
799
821
|
else
|
|
800
|
-
|
|
822
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
801
823
|
end
|
|
802
|
-
return
|
|
824
|
+
return ____temp_3
|
|
803
825
|
end
|
|
804
826
|
function Unit.prototype.isAllyOf(self, unit)
|
|
805
827
|
return isUnitAlly(
|
|
@@ -829,16 +851,18 @@ function Unit.prototype.queueAnimation(self, animation)
|
|
|
829
851
|
QueueUnitAnimation(self.handle, animation)
|
|
830
852
|
end
|
|
831
853
|
function Unit.prototype.chooseWeapon(self, target)
|
|
832
|
-
|
|
833
|
-
|
|
854
|
+
local firstWeapon = self.firstWeapon
|
|
855
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
856
|
+
return firstWeapon
|
|
834
857
|
end
|
|
835
|
-
|
|
836
|
-
|
|
858
|
+
local secondWeapon = self.secondWeapon
|
|
859
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
860
|
+
return secondWeapon
|
|
837
861
|
end
|
|
838
862
|
return nil
|
|
839
863
|
end
|
|
840
864
|
function Unit.prototype.delayHealthChecks(self)
|
|
841
|
-
self[
|
|
865
|
+
self[104] = (self[104] or 0) + 1
|
|
842
866
|
Timer:run(delayHealthChecksCallback, self)
|
|
843
867
|
end
|
|
844
868
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -855,14 +879,14 @@ function Unit.prototype.kill(self)
|
|
|
855
879
|
killUnit(self.handle)
|
|
856
880
|
end
|
|
857
881
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
858
|
-
local
|
|
859
|
-
local
|
|
860
|
-
local
|
|
861
|
-
if
|
|
862
|
-
|
|
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
|
|
863
887
|
end
|
|
864
|
-
__TS__SparseArrayPush(
|
|
865
|
-
|
|
888
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
889
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
866
890
|
end
|
|
867
891
|
function Unit.prototype.healTarget(self, target, amount)
|
|
868
892
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -905,17 +929,16 @@ function Unit.prototype.itemInSlot(self, slot)
|
|
|
905
929
|
return Item:of(unitItemInSlot(self.handle, slot))
|
|
906
930
|
end
|
|
907
931
|
function Unit.prototype.addAbility(self, abilityId)
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
932
|
+
local ability = UnitAbility:of(
|
|
933
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
934
|
+
abilityId,
|
|
935
|
+
self
|
|
936
|
+
)
|
|
937
|
+
if ability ~= nil then
|
|
914
938
|
local abilities = self.abilities
|
|
915
939
|
abilities[#abilities + 1] = ability
|
|
916
|
-
return ability
|
|
917
940
|
end
|
|
918
|
-
return
|
|
941
|
+
return ability
|
|
919
942
|
end
|
|
920
943
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
921
944
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -929,31 +952,21 @@ end
|
|
|
929
952
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
930
953
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
931
954
|
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
|
-
)
|
|
955
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
956
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
957
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
943
958
|
end
|
|
944
|
-
function Unit.prototype.removeAbility(self,
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
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
|
|
953
967
|
end
|
|
954
|
-
return true
|
|
955
968
|
end
|
|
956
|
-
return
|
|
969
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
957
970
|
end
|
|
958
971
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
959
972
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -967,6 +980,21 @@ end
|
|
|
967
980
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
968
981
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
969
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
|
|
970
998
|
function Unit.prototype.interruptAttack(self)
|
|
971
999
|
unitInterruptAttack(self.handle)
|
|
972
1000
|
end
|
|
@@ -1040,18 +1068,44 @@ function Unit.prototype.unpauseEx(self)
|
|
|
1040
1068
|
end
|
|
1041
1069
|
function Unit.prototype.incrementStunCounter(self)
|
|
1042
1070
|
local stunCounter = self[102] or 0
|
|
1043
|
-
if not self[101] or stunCounter >= 0 then
|
|
1071
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
|
|
1044
1072
|
BlzPauseUnitEx(self.handle, true)
|
|
1045
1073
|
end
|
|
1046
1074
|
self[102] = stunCounter + 1
|
|
1047
1075
|
end
|
|
1048
1076
|
function Unit.prototype.decrementStunCounter(self)
|
|
1049
1077
|
local stunCounter = self[102] or 0
|
|
1050
|
-
if not self[101] or stunCounter >= 1 then
|
|
1078
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
|
|
1051
1079
|
BlzPauseUnitEx(self.handle, false)
|
|
1052
1080
|
end
|
|
1053
1081
|
self[102] = stunCounter - 1
|
|
1054
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
|
|
1055
1109
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1056
1110
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
1057
1111
|
owner.handle,
|
|
@@ -1240,7 +1294,7 @@ __TS__SetDescriptor(
|
|
|
1240
1294
|
Unit.prototype,
|
|
1241
1295
|
"isIllusion",
|
|
1242
1296
|
{get = function(self)
|
|
1243
|
-
return
|
|
1297
|
+
return IsUnitIllusion(self.handle)
|
|
1244
1298
|
end},
|
|
1245
1299
|
true
|
|
1246
1300
|
)
|
|
@@ -1459,17 +1513,17 @@ __TS__SetDescriptor(
|
|
|
1459
1513
|
"isTeamGlowVisible",
|
|
1460
1514
|
{
|
|
1461
1515
|
get = function(self)
|
|
1462
|
-
return not self[
|
|
1516
|
+
return not self[107]
|
|
1463
1517
|
end,
|
|
1464
1518
|
set = function(self, isTeamGlowVisible)
|
|
1465
1519
|
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1466
|
-
local
|
|
1520
|
+
local ____temp_7
|
|
1467
1521
|
if not isTeamGlowVisible then
|
|
1468
|
-
|
|
1522
|
+
____temp_7 = true
|
|
1469
1523
|
else
|
|
1470
|
-
|
|
1524
|
+
____temp_7 = nil
|
|
1471
1525
|
end
|
|
1472
|
-
self[
|
|
1526
|
+
self[107] = ____temp_7
|
|
1473
1527
|
end
|
|
1474
1528
|
},
|
|
1475
1529
|
true
|
|
@@ -1479,7 +1533,7 @@ __TS__SetDescriptor(
|
|
|
1479
1533
|
"color",
|
|
1480
1534
|
{set = function(self, color)
|
|
1481
1535
|
SetUnitColor(self.handle, color.handle)
|
|
1482
|
-
if self[
|
|
1536
|
+
if self[107] then
|
|
1483
1537
|
BlzShowUnitTeamGlow(self.handle, false)
|
|
1484
1538
|
end
|
|
1485
1539
|
end},
|
|
@@ -1503,14 +1557,14 @@ __TS__SetDescriptor(
|
|
|
1503
1557
|
"maxHealth",
|
|
1504
1558
|
{
|
|
1505
1559
|
get = function(self)
|
|
1506
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1560
|
+
return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
|
|
1507
1561
|
end,
|
|
1508
1562
|
set = function(self, maxHealth)
|
|
1509
|
-
if maxHealth < 1 and self[
|
|
1510
|
-
self[
|
|
1563
|
+
if maxHealth < 1 and self[104] ~= nil then
|
|
1564
|
+
self[105] = (self[105] or 0) + (1 - maxHealth)
|
|
1511
1565
|
maxHealth = 1
|
|
1512
1566
|
end
|
|
1513
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1567
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
|
|
1514
1568
|
end
|
|
1515
1569
|
},
|
|
1516
1570
|
true
|
|
@@ -1552,10 +1606,10 @@ __TS__SetDescriptor(
|
|
|
1552
1606
|
"health",
|
|
1553
1607
|
{
|
|
1554
1608
|
get = function(self)
|
|
1555
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1609
|
+
return GetWidgetLife(self.handle) - (self[106] or 0)
|
|
1556
1610
|
end,
|
|
1557
1611
|
set = function(self, health)
|
|
1558
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1612
|
+
SetWidgetLife(self.handle, health + (self[106] or 0))
|
|
1559
1613
|
end
|
|
1560
1614
|
},
|
|
1561
1615
|
true
|
|
@@ -1649,7 +1703,7 @@ __TS__SetDescriptor(
|
|
|
1649
1703
|
"x",
|
|
1650
1704
|
{
|
|
1651
1705
|
get = function(self)
|
|
1652
|
-
return self[
|
|
1706
|
+
return self[108] or getUnitX(self.handle)
|
|
1653
1707
|
end,
|
|
1654
1708
|
set = function(self, v)
|
|
1655
1709
|
SetUnitX(self.handle, v)
|
|
@@ -1662,7 +1716,7 @@ __TS__SetDescriptor(
|
|
|
1662
1716
|
"y",
|
|
1663
1717
|
{
|
|
1664
1718
|
get = function(self)
|
|
1665
|
-
return self[
|
|
1719
|
+
return self[109] or getUnitY(self.handle)
|
|
1666
1720
|
end,
|
|
1667
1721
|
set = function(self, v)
|
|
1668
1722
|
SetUnitY(self.handle, v)
|
|
@@ -1767,14 +1821,18 @@ __TS__SetDescriptor(
|
|
|
1767
1821
|
local handle = self.handle
|
|
1768
1822
|
if isPaused and not IsUnitPaused(handle) then
|
|
1769
1823
|
self[101] = true
|
|
1770
|
-
|
|
1771
|
-
|
|
1824
|
+
if (self[103] or 0) <= 0 then
|
|
1825
|
+
for _ = self[102] or 0, -1 do
|
|
1826
|
+
BlzPauseUnitEx(handle, true)
|
|
1827
|
+
end
|
|
1772
1828
|
end
|
|
1773
1829
|
PauseUnit(handle, true)
|
|
1774
1830
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1775
1831
|
PauseUnit(handle, false)
|
|
1776
|
-
|
|
1777
|
-
|
|
1832
|
+
if (self[103] or 0) <= 0 then
|
|
1833
|
+
for _ = self[102] or 0, -1 do
|
|
1834
|
+
BlzPauseUnitEx(handle, false)
|
|
1835
|
+
end
|
|
1778
1836
|
end
|
|
1779
1837
|
self[101] = nil
|
|
1780
1838
|
end
|
|
@@ -2216,25 +2274,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2216
2274
|
InitializingEvent,
|
|
2217
2275
|
function(event)
|
|
2218
2276
|
local function listener(unit, id)
|
|
2219
|
-
local
|
|
2277
|
+
local ____GetSpellTargetUnit_result_10
|
|
2220
2278
|
if GetSpellTargetUnit() then
|
|
2221
|
-
|
|
2279
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2222
2280
|
else
|
|
2223
|
-
local
|
|
2281
|
+
local ____GetSpellTargetItem_result_9
|
|
2224
2282
|
if GetSpellTargetItem() then
|
|
2225
|
-
|
|
2283
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2226
2284
|
else
|
|
2227
|
-
local
|
|
2285
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2228
2286
|
if GetSpellTargetDestructable() then
|
|
2229
|
-
|
|
2287
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2230
2288
|
else
|
|
2231
|
-
|
|
2289
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2232
2290
|
end
|
|
2233
|
-
|
|
2291
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2234
2292
|
end
|
|
2235
|
-
|
|
2293
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2236
2294
|
end
|
|
2237
|
-
local target =
|
|
2295
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2238
2296
|
if target then
|
|
2239
2297
|
invoke(event, unit, id, target)
|
|
2240
2298
|
end
|
|
@@ -2457,12 +2515,7 @@ Unit.onDamaging = (function()
|
|
|
2457
2515
|
preventRetaliation = damagingEventPreventRetaliation
|
|
2458
2516
|
}
|
|
2459
2517
|
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])
|
|
2518
|
+
data.weapon = source:chooseWeapon(target)
|
|
2466
2519
|
end
|
|
2467
2520
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2468
2521
|
invoke(
|
|
@@ -2607,7 +2660,7 @@ Unit.onDamage = __TS__New(
|
|
|
2607
2660
|
invoke(event, source, target, evData)
|
|
2608
2661
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2609
2662
|
local bonusHealth = math.ceil(evData.amount)
|
|
2610
|
-
target[
|
|
2663
|
+
target[106] = (target[106] or 0) + bonusHealth
|
|
2611
2664
|
BlzSetUnitMaxHP(
|
|
2612
2665
|
target.handle,
|
|
2613
2666
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2621,7 +2674,7 @@ Unit.onDamage = __TS__New(
|
|
|
2621
2674
|
evData[0],
|
|
2622
2675
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2623
2676
|
)
|
|
2624
|
-
target[
|
|
2677
|
+
target[106] = (target[106] or 0) - bonusHealth
|
|
2625
2678
|
SetWidgetLife(
|
|
2626
2679
|
target.handle,
|
|
2627
2680
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2657,10 +2710,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2657
2710
|
____exports.UnitTriggerEvent,
|
|
2658
2711
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2659
2712
|
function()
|
|
2660
|
-
local
|
|
2661
|
-
local
|
|
2662
|
-
if getUnitTypeId(
|
|
2663
|
-
|
|
2713
|
+
local unitHandle = getTriggerUnit()
|
|
2714
|
+
local itemHandle = getManipulatedItem()
|
|
2715
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2716
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2717
|
+
local item = Item:of(itemHandle)
|
|
2718
|
+
if item.owner ~= unit then
|
|
2719
|
+
return unit, item
|
|
2720
|
+
end
|
|
2664
2721
|
end
|
|
2665
2722
|
return IgnoreEvent
|
|
2666
2723
|
end
|
|
@@ -2680,7 +2737,7 @@ Unit.itemUsedEvent = __TS__New(
|
|
|
2680
2737
|
Unit.itemStackedEvent = __TS__New(
|
|
2681
2738
|
____exports.UnitTriggerEvent,
|
|
2682
2739
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2683
|
-
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(
|
|
2740
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2684
2741
|
)
|
|
2685
2742
|
__TS__ObjectDefineProperty(
|
|
2686
2743
|
Unit,
|
|
@@ -2767,6 +2824,10 @@ __TS__ObjectDefineProperty(
|
|
|
2767
2824
|
rawset(self, "destroyEvent", destroyEvent)
|
|
2768
2825
|
return destroyEvent
|
|
2769
2826
|
end}
|
|
2827
|
+
)
|
|
2828
|
+
Unit.synchronize = synchronizer(
|
|
2829
|
+
function(unit) return unit.syncId end,
|
|
2830
|
+
function(syncId) return unitBySyncId[syncId] end
|
|
2770
2831
|
);
|
|
2771
2832
|
(function(self)
|
|
2772
2833
|
local leaveAbilityIds = postcompile(function()
|
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, extraEffects?: boolean] | [color: Color, extraEffects?: boolean]): void;
|
|
14
16
|
static get mouseFocusUnit(): Async<Unit> | undefined;
|
|
15
17
|
static get mainSelectedUnit(): Async<Unit> | undefined;
|
|
16
18
|
static get mainSelectedUnitChangeEvent(): Event<[
|
package/engine/local-client.lua
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
3
3
|
local __TS__Class = ____lualib.__TS__Class
|
|
4
|
+
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
4
5
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
5
6
|
local __TS__New = ____lualib.__TS__New
|
|
6
7
|
local ____exports = {}
|
|
@@ -15,6 +16,8 @@ local ____player = require("core.types.player")
|
|
|
15
16
|
local Player = ____player.Player
|
|
16
17
|
local ____timer = require("core.types.timer")
|
|
17
18
|
local Timer = ____timer.Timer
|
|
19
|
+
local ____color = require("core.types.color")
|
|
20
|
+
local Color = ____color.Color
|
|
18
21
|
local loadTOCFile = BlzLoadTOCFile
|
|
19
22
|
local getLocalClientWidth = BlzGetLocalClientWidth
|
|
20
23
|
local getLocalClientHeight = BlzGetLocalClientHeight
|
|
@@ -25,6 +28,8 @@ local getMouseFocusUnit = BlzGetMouseFocusUnit
|
|
|
25
28
|
local getUnitRealField = BlzGetUnitRealField
|
|
26
29
|
local getUnitTypeId = GetUnitTypeId
|
|
27
30
|
local getLocale = BlzGetLocale
|
|
31
|
+
local pingMinimap = PingMinimap
|
|
32
|
+
local pingMinimapEx = PingMinimapEx
|
|
28
33
|
local tableSort = table.sort
|
|
29
34
|
local tocPath = "_warscript\\IsHD.toc"
|
|
30
35
|
compiletime(function()
|
|
@@ -62,6 +67,31 @@ local LocalClient = ____exports.LocalClient
|
|
|
62
67
|
LocalClient.name = "LocalClient"
|
|
63
68
|
function LocalClient.prototype.____constructor(self)
|
|
64
69
|
end
|
|
70
|
+
function LocalClient.pingMinimap(self, x, y, duration, redOrColor, greenOrExtraEffects, blue, extraEffects)
|
|
71
|
+
if redOrColor == nil then
|
|
72
|
+
pingMinimap(x, y, duration)
|
|
73
|
+
elseif __TS__InstanceOf(redOrColor, Color) then
|
|
74
|
+
pingMinimapEx(
|
|
75
|
+
x,
|
|
76
|
+
y,
|
|
77
|
+
duration,
|
|
78
|
+
redOrColor.r,
|
|
79
|
+
redOrColor.g,
|
|
80
|
+
redOrColor.b,
|
|
81
|
+
greenOrExtraEffects or false
|
|
82
|
+
)
|
|
83
|
+
else
|
|
84
|
+
pingMinimapEx(
|
|
85
|
+
x,
|
|
86
|
+
y,
|
|
87
|
+
duration,
|
|
88
|
+
redOrColor,
|
|
89
|
+
greenOrExtraEffects,
|
|
90
|
+
blue,
|
|
91
|
+
extraEffects or false
|
|
92
|
+
)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
65
95
|
LocalClient.locale = getLocale()
|
|
66
96
|
__TS__ObjectDefineProperty(
|
|
67
97
|
LocalClient,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____records = require("utility.records")
|
|
3
|
+
local invertRecord = ____records.invertRecord
|
|
4
|
+
local stringByArmorType = {
|
|
5
|
+
[0] = "small",
|
|
6
|
+
[1] = "medium",
|
|
7
|
+
[2] = "large",
|
|
8
|
+
[3] = "fort",
|
|
9
|
+
[4] = "normal",
|
|
10
|
+
[5] = "hero",
|
|
11
|
+
[6] = "divine",
|
|
12
|
+
[7] = "none"
|
|
13
|
+
}
|
|
14
|
+
local armorTypeByString = invertRecord(stringByArmorType)
|
|
15
|
+
local nativeByArmorType = {
|
|
16
|
+
[0] = DEFENSE_TYPE_LIGHT,
|
|
17
|
+
[1] = DEFENSE_TYPE_MEDIUM,
|
|
18
|
+
[2] = DEFENSE_TYPE_LARGE,
|
|
19
|
+
[3] = DEFENSE_TYPE_FORT,
|
|
20
|
+
[4] = DEFENSE_TYPE_NORMAL,
|
|
21
|
+
[5] = DEFENSE_TYPE_HERO,
|
|
22
|
+
[6] = DEFENSE_TYPE_DIVINE,
|
|
23
|
+
[7] = DEFENSE_TYPE_NONE
|
|
24
|
+
}
|
|
25
|
+
local armorTypeByNative = invertRecord(nativeByArmorType)
|
|
26
|
+
---
|
|
27
|
+
-- @internal For use by internal systems only.
|
|
28
|
+
____exports.armorTypeToString = function(armorType)
|
|
29
|
+
return stringByArmorType[armorType]
|
|
30
|
+
end
|
|
31
|
+
---
|
|
32
|
+
-- @internal For use by internal systems only.
|
|
33
|
+
____exports.stringToArmorType = function(____string)
|
|
34
|
+
return armorTypeByString[____string] or 7
|
|
35
|
+
end
|
|
36
|
+
---
|
|
37
|
+
-- @internal For use by internal systems only.
|
|
38
|
+
____exports.armorTypeToNative = function(armorType)
|
|
39
|
+
return nativeByArmorType[armorType]
|
|
40
|
+
end
|
|
41
|
+
---
|
|
42
|
+
-- @internal For use by internal systems only.
|
|
43
|
+
____exports.nativeToArmorType = function(armorType)
|
|
44
|
+
return armorTypeByNative[armorType]
|
|
45
|
+
end
|
|
46
|
+
return ____exports
|