warscript 0.0.1-dev.a58cc52 → 0.0.1-dev.a73c979
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 +5 -0
- package/attributes.lua +8 -1
- package/core/types/timer.d.ts +1 -1
- package/engine/behavior.d.ts +2 -0
- package/engine/behavior.lua +53 -27
- package/engine/behaviour/ability/apply-buff.lua +1 -1
- package/engine/behaviour/ability/damage.d.ts +4 -2
- package/engine/behaviour/ability/damage.lua +24 -36
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +11 -3
- package/engine/behaviour/ability.lua +8 -17
- package/engine/behaviour/unit/stun-immunity.d.ts +5 -3
- package/engine/behaviour/unit/stun-immunity.lua +43 -27
- package/engine/behaviour/unit.d.ts +26 -0
- package/engine/behaviour/unit.lua +163 -4
- package/engine/buff.d.ts +2 -1
- package/engine/buff.lua +9 -3
- package/engine/internal/ability.d.ts +4 -0
- package/engine/internal/ability.lua +23 -0
- package/engine/internal/item/ability.lua +63 -11
- package/engine/internal/item.d.ts +3 -1
- package/engine/internal/item.lua +75 -3
- package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
- package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
- package/engine/internal/unit/ability.d.ts +35 -0
- package/engine/internal/unit/ability.lua +62 -0
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit+damage.d.ts +1 -1
- package/engine/internal/unit+damage.lua +6 -1
- package/engine/internal/unit-missile-launch.lua +1 -1
- package/engine/internal/unit.d.ts +14 -3
- package/engine/internal/unit.lua +193 -90
- package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
- package/engine/object-field/unit.d.ts +11 -0
- package/engine/object-field/unit.lua +34 -0
- package/engine/object-field.d.ts +6 -3
- package/engine/object-field.lua +85 -73
- package/engine/standard/fields/unit.d.ts +4 -0
- package/engine/standard/fields/unit.lua +7 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +175 -10
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/package.json +2 -2
- package/utility/functions.d.ts +5 -0
- package/utility/functions.lua +5 -0
- package/utility/lua-maps.d.ts +1 -0
- package/utility/lua-maps.lua +4 -0
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
package/engine/internal/unit.lua
CHANGED
|
@@ -56,13 +56,16 @@ local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
|
56
56
|
local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
|
|
57
57
|
local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
|
|
58
58
|
local nativeToAttackType = ____attack_2Dtype.nativeToAttackType
|
|
59
|
+
local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
|
|
60
|
+
local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
|
|
61
|
+
local ____attributes = require("attributes")
|
|
62
|
+
local isAttribute = ____attributes.isAttribute
|
|
63
|
+
local ____ability = require("engine.internal.item.ability")
|
|
64
|
+
local doUnitAbilityAction = ____ability.doUnitAbilityAction
|
|
59
65
|
local match = string.match
|
|
60
66
|
local ____tostring = _G.tostring
|
|
61
67
|
local setUnitAnimation = SetUnitAnimation
|
|
62
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
63
68
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
64
|
-
local resetUnitAnimation = ResetUnitAnimation
|
|
65
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
66
69
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
67
70
|
local getUnitRealField = BlzGetUnitRealField
|
|
68
71
|
local getHeroStr = GetHeroStr
|
|
@@ -84,7 +87,6 @@ local getHandleId = GetHandleId
|
|
|
84
87
|
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
85
88
|
local createUnit = CreateUnit
|
|
86
89
|
local killUnit = KillUnit
|
|
87
|
-
local setUnitExploded = SetUnitExploded
|
|
88
90
|
local removeUnit = RemoveUnit
|
|
89
91
|
local getUnitTypeId = GetUnitTypeId
|
|
90
92
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -100,8 +102,6 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
100
102
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
101
103
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
102
104
|
local isUnitInRange = IsUnitInRange
|
|
103
|
-
local setResourceAmount = SetResourceAmount
|
|
104
|
-
local getResourceAmount = GetResourceAmount
|
|
105
105
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
106
106
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
107
107
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
@@ -125,15 +125,9 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
125
125
|
local getIssuedOrderId = GetIssuedOrderId
|
|
126
126
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
127
127
|
local unitAlive = UnitAlive
|
|
128
|
-
local unitAddType = UnitAddType
|
|
129
|
-
local unitRemoveType = UnitRemoveType
|
|
130
|
-
local isUnitIllusion = IsUnitIllusion
|
|
131
|
-
local isUnitType = IsUnitType
|
|
132
128
|
local isUnitAlly = IsUnitAlly
|
|
133
129
|
local isUnitEnemy = IsUnitEnemy
|
|
134
130
|
local getOwningPlayer = GetOwningPlayer
|
|
135
|
-
local setUnitColor = SetUnitColor
|
|
136
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
137
131
|
____exports.UnitClassification = {}
|
|
138
132
|
local UnitClassification = ____exports.UnitClassification
|
|
139
133
|
do
|
|
@@ -143,6 +137,7 @@ do
|
|
|
143
137
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
144
138
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
145
139
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
140
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
146
141
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
147
142
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
148
143
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -350,6 +345,9 @@ local function dispatchAbility(event)
|
|
|
350
345
|
}
|
|
351
346
|
)
|
|
352
347
|
end
|
|
348
|
+
local function damagingEventPreventRetaliation(self)
|
|
349
|
+
self[0] = true
|
|
350
|
+
end
|
|
353
351
|
local function damageEventPreventDeath(self, callback, ...)
|
|
354
352
|
if self[0] ~= nil then
|
|
355
353
|
return
|
|
@@ -446,6 +444,19 @@ __TS__SetDescriptor(
|
|
|
446
444
|
},
|
|
447
445
|
true
|
|
448
446
|
)
|
|
447
|
+
__TS__SetDescriptor(
|
|
448
|
+
UnitWeapon.prototype,
|
|
449
|
+
"allowedTargetCombatClassifications",
|
|
450
|
+
{
|
|
451
|
+
get = function(self)
|
|
452
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
453
|
+
end,
|
|
454
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
455
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
456
|
+
end
|
|
457
|
+
},
|
|
458
|
+
true
|
|
459
|
+
)
|
|
449
460
|
__TS__SetDescriptor(
|
|
450
461
|
UnitWeapon.prototype,
|
|
451
462
|
"damageBase",
|
|
@@ -650,16 +661,26 @@ local function delayHealthChecksCallback(unit)
|
|
|
650
661
|
end
|
|
651
662
|
end
|
|
652
663
|
local nextSyncId = 1
|
|
653
|
-
local unitBySyncId = setmetatable({}, {__mode = "
|
|
664
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
665
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
666
|
+
local function addAbility(unit, abilityTypeId)
|
|
667
|
+
local ____unitAddAbility_result_0
|
|
668
|
+
if unitAddAbility(unit, abilityTypeId) then
|
|
669
|
+
____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
|
|
670
|
+
else
|
|
671
|
+
____unitAddAbility_result_0 = nil
|
|
672
|
+
end
|
|
673
|
+
return ____unitAddAbility_result_0
|
|
674
|
+
end
|
|
654
675
|
____exports.Unit = __TS__Class()
|
|
655
676
|
local Unit = ____exports.Unit
|
|
656
677
|
Unit.name = "Unit"
|
|
657
678
|
__TS__ClassExtends(Unit, Handle)
|
|
658
679
|
function Unit.prototype.____constructor(self, handle)
|
|
659
680
|
Handle.prototype.____constructor(self, handle)
|
|
660
|
-
local
|
|
661
|
-
nextSyncId =
|
|
662
|
-
self.syncId =
|
|
681
|
+
local ____nextSyncId_1 = nextSyncId
|
|
682
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
683
|
+
self.syncId = ____nextSyncId_1
|
|
663
684
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
664
685
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
665
686
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -760,17 +781,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
760
781
|
end}
|
|
761
782
|
end
|
|
762
783
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
763
|
-
local
|
|
764
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
784
|
+
local ____combatClassification_2 = combatClassification
|
|
785
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
|
|
765
786
|
end
|
|
766
787
|
function Unit.prototype.addClassification(self, classification)
|
|
767
|
-
return
|
|
788
|
+
return UnitAddType(self.handle, classification)
|
|
768
789
|
end
|
|
769
790
|
function Unit.prototype.removeClassification(self, classification)
|
|
770
|
-
return
|
|
791
|
+
return UnitRemoveType(self.handle, classification)
|
|
771
792
|
end
|
|
772
793
|
function Unit.prototype.hasClassification(self, classification)
|
|
773
|
-
return
|
|
794
|
+
return IsUnitType(self.handle, classification)
|
|
774
795
|
end
|
|
775
796
|
function Unit.prototype.isVisibleTo(self, player)
|
|
776
797
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -779,13 +800,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
779
800
|
return isUnitInvisible(self.handle, player.handle)
|
|
780
801
|
end
|
|
781
802
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
782
|
-
local
|
|
803
|
+
local ____temp_3
|
|
783
804
|
if type(x) == "number" then
|
|
784
|
-
|
|
805
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
785
806
|
else
|
|
786
|
-
|
|
807
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
787
808
|
end
|
|
788
|
-
return
|
|
809
|
+
return ____temp_3
|
|
789
810
|
end
|
|
790
811
|
function Unit.prototype.isAllyOf(self, unit)
|
|
791
812
|
return isUnitAlly(
|
|
@@ -803,16 +824,25 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
803
824
|
if type(animation) == "number" then
|
|
804
825
|
setUnitAnimationByIndex(self.handle, animation)
|
|
805
826
|
elseif rarity then
|
|
806
|
-
|
|
827
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
807
828
|
else
|
|
808
829
|
setUnitAnimation(self.handle, animation)
|
|
809
830
|
end
|
|
810
831
|
end
|
|
811
832
|
function Unit.prototype.resetAnimation(self)
|
|
812
|
-
|
|
833
|
+
ResetUnitAnimation(self.handle)
|
|
813
834
|
end
|
|
814
835
|
function Unit.prototype.queueAnimation(self, animation)
|
|
815
|
-
|
|
836
|
+
QueueUnitAnimation(self.handle, animation)
|
|
837
|
+
end
|
|
838
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
839
|
+
if target:isAllowedTarget(self, self.firstWeapon.allowedTargetCombatClassifications) then
|
|
840
|
+
return self.firstWeapon
|
|
841
|
+
end
|
|
842
|
+
if target:isAllowedTarget(target, self.secondWeapon.allowedTargetCombatClassifications) then
|
|
843
|
+
return self.secondWeapon
|
|
844
|
+
end
|
|
845
|
+
return nil
|
|
816
846
|
end
|
|
817
847
|
function Unit.prototype.delayHealthChecks(self)
|
|
818
848
|
self[103] = (self[103] or 0) + 1
|
|
@@ -825,21 +855,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
825
855
|
return IsUnitSelected(self.handle, player.handle)
|
|
826
856
|
end
|
|
827
857
|
function Unit.prototype.explode(self)
|
|
828
|
-
|
|
858
|
+
SetUnitExploded(self.handle, true)
|
|
829
859
|
killUnit(self.handle)
|
|
830
860
|
end
|
|
831
861
|
function Unit.prototype.kill(self)
|
|
832
862
|
killUnit(self.handle)
|
|
833
863
|
end
|
|
834
864
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
835
|
-
local
|
|
836
|
-
local
|
|
837
|
-
local
|
|
838
|
-
if
|
|
839
|
-
|
|
865
|
+
local ____ReviveHero_6 = ReviveHero
|
|
866
|
+
local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
|
|
867
|
+
local ____doEffect_4 = doEffect
|
|
868
|
+
if ____doEffect_4 == nil then
|
|
869
|
+
____doEffect_4 = false
|
|
840
870
|
end
|
|
841
|
-
__TS__SparseArrayPush(
|
|
842
|
-
|
|
871
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
872
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
843
873
|
end
|
|
844
874
|
function Unit.prototype.healTarget(self, target, amount)
|
|
845
875
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -882,17 +912,16 @@ function Unit.prototype.itemInSlot(self, slot)
|
|
|
882
912
|
return Item:of(unitItemInSlot(self.handle, slot))
|
|
883
913
|
end
|
|
884
914
|
function Unit.prototype.addAbility(self, abilityId)
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
915
|
+
local ability = UnitAbility:of(
|
|
916
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
917
|
+
abilityId,
|
|
918
|
+
self
|
|
919
|
+
)
|
|
920
|
+
if ability ~= nil then
|
|
891
921
|
local abilities = self.abilities
|
|
892
922
|
abilities[#abilities + 1] = ability
|
|
893
|
-
return ability
|
|
894
923
|
end
|
|
895
|
-
return
|
|
924
|
+
return ability
|
|
896
925
|
end
|
|
897
926
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
898
927
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -907,19 +936,11 @@ function Unit.prototype.hasAbility(self, abilityId)
|
|
|
907
936
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
908
937
|
end
|
|
909
938
|
function Unit.prototype.getAbilityById(self, abilityId)
|
|
910
|
-
local
|
|
911
|
-
|
|
912
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
913
|
-
return nil
|
|
914
|
-
end
|
|
915
|
-
return UnitAbility:of(
|
|
916
|
-
getUnitAbility(self.handle, abilityId),
|
|
917
|
-
abilityId,
|
|
918
|
-
self
|
|
919
|
-
)
|
|
939
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
940
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
920
941
|
end
|
|
921
942
|
function Unit.prototype.removeAbility(self, abilityId)
|
|
922
|
-
if
|
|
943
|
+
if doUnitAbilityAction(self.handle, abilityId, unitRemoveAbility, abilityId) then
|
|
923
944
|
local abilities = self.abilities
|
|
924
945
|
for i = 1, #abilities do
|
|
925
946
|
if abilities[i].typeId == abilityId then
|
|
@@ -944,6 +965,21 @@ end
|
|
|
944
965
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
945
966
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
946
967
|
end
|
|
968
|
+
function Unit.prototype.interruptMovement(self)
|
|
969
|
+
local handle = self.handle
|
|
970
|
+
unitDisableAbility(
|
|
971
|
+
handle,
|
|
972
|
+
fourCC("Amov"),
|
|
973
|
+
true,
|
|
974
|
+
false
|
|
975
|
+
)
|
|
976
|
+
unitDisableAbility(
|
|
977
|
+
handle,
|
|
978
|
+
fourCC("Amov"),
|
|
979
|
+
false,
|
|
980
|
+
false
|
|
981
|
+
)
|
|
982
|
+
end
|
|
947
983
|
function Unit.prototype.interruptAttack(self)
|
|
948
984
|
unitInterruptAttack(self.handle)
|
|
949
985
|
end
|
|
@@ -1217,7 +1253,7 @@ __TS__SetDescriptor(
|
|
|
1217
1253
|
Unit.prototype,
|
|
1218
1254
|
"isIllusion",
|
|
1219
1255
|
{get = function(self)
|
|
1220
|
-
return
|
|
1256
|
+
return IsUnitIllusion(self.handle)
|
|
1221
1257
|
end},
|
|
1222
1258
|
true
|
|
1223
1259
|
)
|
|
@@ -1439,14 +1475,14 @@ __TS__SetDescriptor(
|
|
|
1439
1475
|
return not self[106]
|
|
1440
1476
|
end,
|
|
1441
1477
|
set = function(self, isTeamGlowVisible)
|
|
1442
|
-
|
|
1443
|
-
local
|
|
1478
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1479
|
+
local ____temp_7
|
|
1444
1480
|
if not isTeamGlowVisible then
|
|
1445
|
-
|
|
1481
|
+
____temp_7 = true
|
|
1446
1482
|
else
|
|
1447
|
-
|
|
1483
|
+
____temp_7 = nil
|
|
1448
1484
|
end
|
|
1449
|
-
self[106] =
|
|
1485
|
+
self[106] = ____temp_7
|
|
1450
1486
|
end
|
|
1451
1487
|
},
|
|
1452
1488
|
true
|
|
@@ -1455,9 +1491,9 @@ __TS__SetDescriptor(
|
|
|
1455
1491
|
Unit.prototype,
|
|
1456
1492
|
"color",
|
|
1457
1493
|
{set = function(self, color)
|
|
1458
|
-
|
|
1494
|
+
SetUnitColor(self.handle, color.handle)
|
|
1459
1495
|
if self[106] then
|
|
1460
|
-
|
|
1496
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1461
1497
|
end
|
|
1462
1498
|
end},
|
|
1463
1499
|
true
|
|
@@ -1725,10 +1761,10 @@ __TS__SetDescriptor(
|
|
|
1725
1761
|
"gold",
|
|
1726
1762
|
{
|
|
1727
1763
|
get = function(self)
|
|
1728
|
-
return
|
|
1764
|
+
return GetResourceAmount(self.handle)
|
|
1729
1765
|
end,
|
|
1730
1766
|
set = function(self, gold)
|
|
1731
|
-
|
|
1767
|
+
SetResourceAmount(self.handle, gold)
|
|
1732
1768
|
end
|
|
1733
1769
|
},
|
|
1734
1770
|
true
|
|
@@ -2050,6 +2086,14 @@ __TS__SetDescriptor(
|
|
|
2050
2086
|
end},
|
|
2051
2087
|
true
|
|
2052
2088
|
)
|
|
2089
|
+
__TS__SetDescriptor(
|
|
2090
|
+
Unit.prototype,
|
|
2091
|
+
"targetAcquiredEvent",
|
|
2092
|
+
{get = function(self)
|
|
2093
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2094
|
+
end},
|
|
2095
|
+
true
|
|
2096
|
+
)
|
|
2053
2097
|
__TS__SetDescriptor(
|
|
2054
2098
|
Unit.prototype,
|
|
2055
2099
|
"onSelect",
|
|
@@ -2185,25 +2229,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2185
2229
|
InitializingEvent,
|
|
2186
2230
|
function(event)
|
|
2187
2231
|
local function listener(unit, id)
|
|
2188
|
-
local
|
|
2232
|
+
local ____GetSpellTargetUnit_result_10
|
|
2189
2233
|
if GetSpellTargetUnit() then
|
|
2190
|
-
|
|
2234
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2191
2235
|
else
|
|
2192
|
-
local
|
|
2236
|
+
local ____GetSpellTargetItem_result_9
|
|
2193
2237
|
if GetSpellTargetItem() then
|
|
2194
|
-
|
|
2238
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2195
2239
|
else
|
|
2196
|
-
local
|
|
2240
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2197
2241
|
if GetSpellTargetDestructable() then
|
|
2198
|
-
|
|
2242
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2199
2243
|
else
|
|
2200
|
-
|
|
2244
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2201
2245
|
end
|
|
2202
|
-
|
|
2246
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2203
2247
|
end
|
|
2204
|
-
|
|
2248
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2205
2249
|
end
|
|
2206
|
-
local target =
|
|
2250
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2207
2251
|
if target then
|
|
2208
2252
|
invoke(event, unit, id, target)
|
|
2209
2253
|
end
|
|
@@ -2411,13 +2455,19 @@ Unit.onDamaging = (function()
|
|
|
2411
2455
|
if source and source.typeId == dummyUnitId then
|
|
2412
2456
|
source = nil
|
|
2413
2457
|
end
|
|
2414
|
-
local target = BlzGetEventDamageTarget()
|
|
2458
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2459
|
+
local metadata = damageMetadataByTarget[target]
|
|
2460
|
+
damageMetadataByTarget[target] = nil
|
|
2415
2461
|
local data = {
|
|
2416
2462
|
amount = GetEventDamage(),
|
|
2417
2463
|
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2418
2464
|
damageType = BlzGetEventDamageType(),
|
|
2419
2465
|
weaponType = BlzGetEventWeaponType(),
|
|
2420
|
-
|
|
2466
|
+
metadata = metadata,
|
|
2467
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2468
|
+
originalAmount = GetEventDamage(),
|
|
2469
|
+
originalMetadata = metadata,
|
|
2470
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2421
2471
|
}
|
|
2422
2472
|
if data.isAttack and source then
|
|
2423
2473
|
local weapon = BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 1) and (BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 0) and -1 or 1) or 0
|
|
@@ -2431,18 +2481,36 @@ Unit.onDamaging = (function()
|
|
|
2431
2481
|
invoke(
|
|
2432
2482
|
event,
|
|
2433
2483
|
source,
|
|
2434
|
-
|
|
2484
|
+
target,
|
|
2435
2485
|
setmetatable(
|
|
2436
2486
|
{},
|
|
2437
2487
|
{
|
|
2438
2488
|
__index = data,
|
|
2439
2489
|
__newindex = function(self, key, value)
|
|
2440
|
-
damageSetters[key]
|
|
2490
|
+
local damageSetter = damageSetters[key]
|
|
2491
|
+
if damageSetter ~= nil then
|
|
2492
|
+
damageSetter(value)
|
|
2493
|
+
end
|
|
2441
2494
|
data[key] = value
|
|
2442
2495
|
end
|
|
2443
2496
|
}
|
|
2444
2497
|
)
|
|
2445
2498
|
)
|
|
2499
|
+
if data[0] and source then
|
|
2500
|
+
local sourceOwner = source.owner.handle
|
|
2501
|
+
data[1] = sourceOwner
|
|
2502
|
+
local targetOwner = target.owner.handle
|
|
2503
|
+
data[2] = targetOwner
|
|
2504
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2505
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2506
|
+
data[3] = true
|
|
2507
|
+
end
|
|
2508
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2509
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2510
|
+
data[4] = true
|
|
2511
|
+
end
|
|
2512
|
+
end
|
|
2513
|
+
damagingEventByTarget[target] = data
|
|
2446
2514
|
return
|
|
2447
2515
|
end
|
|
2448
2516
|
BlzSetEventDamage(0)
|
|
@@ -2450,7 +2518,7 @@ Unit.onDamaging = (function()
|
|
|
2450
2518
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2451
2519
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2452
2520
|
local sourceOwner = source.owner.handle
|
|
2453
|
-
local targetOwner =
|
|
2521
|
+
local targetOwner = target.owner.handle
|
|
2454
2522
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2455
2523
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2456
2524
|
Timer:run(function()
|
|
@@ -2466,19 +2534,15 @@ Unit.onDamaging = (function()
|
|
|
2466
2534
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2467
2535
|
local condition = ____value[1]
|
|
2468
2536
|
local action = ____value[2]
|
|
2469
|
-
if condition(
|
|
2470
|
-
source,
|
|
2471
|
-
____exports.Unit:of(target),
|
|
2472
|
-
data
|
|
2473
|
-
) then
|
|
2537
|
+
if condition(source, target, data) then
|
|
2474
2538
|
action(
|
|
2475
2539
|
source,
|
|
2476
|
-
|
|
2540
|
+
target,
|
|
2477
2541
|
setmetatable(
|
|
2478
2542
|
{fire = function()
|
|
2479
2543
|
UnitDamageTarget(
|
|
2480
2544
|
source.handle,
|
|
2481
|
-
target,
|
|
2545
|
+
target.handle,
|
|
2482
2546
|
data.amount,
|
|
2483
2547
|
true,
|
|
2484
2548
|
true,
|
|
@@ -2509,26 +2573,50 @@ Unit.onDamage = __TS__New(
|
|
|
2509
2573
|
if source and source.typeId == dummyUnitId then
|
|
2510
2574
|
source = nil
|
|
2511
2575
|
end
|
|
2576
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2577
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2578
|
+
damagingEventByTarget[target] = nil
|
|
2512
2579
|
local data = {
|
|
2513
2580
|
amount = GetEventDamage(),
|
|
2514
2581
|
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2515
2582
|
damageType = BlzGetEventDamageType(),
|
|
2516
2583
|
weaponType = BlzGetEventWeaponType(),
|
|
2584
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2517
2585
|
isAttack = BlzGetEventIsAttack(),
|
|
2518
|
-
originalAmount = GetEventDamage(),
|
|
2586
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2587
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2519
2588
|
preventDeath = damageEventPreventDeath
|
|
2520
2589
|
}
|
|
2590
|
+
if damagingEvent then
|
|
2591
|
+
for key, value in pairs(damagingEvent) do
|
|
2592
|
+
if isAttribute(key) then
|
|
2593
|
+
data[key] = value
|
|
2594
|
+
end
|
|
2595
|
+
end
|
|
2596
|
+
local sourceOwner = damagingEvent[1]
|
|
2597
|
+
if sourceOwner then
|
|
2598
|
+
local targetOwner = damagingEvent[2]
|
|
2599
|
+
if damagingEvent[3] then
|
|
2600
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2601
|
+
end
|
|
2602
|
+
if damagingEvent[4] then
|
|
2603
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2604
|
+
end
|
|
2605
|
+
end
|
|
2606
|
+
end
|
|
2521
2607
|
local evData = setmetatable(
|
|
2522
2608
|
{},
|
|
2523
2609
|
{
|
|
2524
2610
|
__index = data,
|
|
2525
2611
|
__newindex = function(self, key, value)
|
|
2526
|
-
damageSetters[key]
|
|
2612
|
+
local damageSetter = damageSetters[key]
|
|
2613
|
+
if damageSetter ~= nil then
|
|
2614
|
+
damageSetter(value)
|
|
2615
|
+
end
|
|
2527
2616
|
data[key] = value
|
|
2528
2617
|
end
|
|
2529
2618
|
}
|
|
2530
2619
|
)
|
|
2531
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2532
2620
|
invoke(event, source, target, evData)
|
|
2533
2621
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2534
2622
|
local bonusHealth = math.ceil(evData.amount)
|
|
@@ -2607,6 +2695,21 @@ Unit.itemStackedEvent = __TS__New(
|
|
|
2607
2695
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2608
2696
|
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2609
2697
|
)
|
|
2698
|
+
__TS__ObjectDefineProperty(
|
|
2699
|
+
Unit,
|
|
2700
|
+
"itemChargesChangedEvent",
|
|
2701
|
+
{get = function(self)
|
|
2702
|
+
local event = __TS__New(Event)
|
|
2703
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2704
|
+
local unit = item.owner
|
|
2705
|
+
if unit ~= nil then
|
|
2706
|
+
invoke(event, unit, item)
|
|
2707
|
+
end
|
|
2708
|
+
end)
|
|
2709
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2710
|
+
return event
|
|
2711
|
+
end}
|
|
2712
|
+
)
|
|
2610
2713
|
__TS__ObjectDefineProperty(
|
|
2611
2714
|
Unit,
|
|
2612
2715
|
"itemUseOrderEvent",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { AbilityType, AbilityTypeId } from "../ability-type";
|
|
3
|
+
import { ObjectDataEntryLevelFieldValueSupplier } from "../../entry";
|
|
4
|
+
export declare class PermanentInvisibilityAbilityType extends AbilityType {
|
|
5
|
+
static readonly BASE_ID: AbilityTypeId;
|
|
6
|
+
get shouldAutoAcquireAttackTargets(): boolean[];
|
|
7
|
+
set shouldAutoAcquireAttackTargets(shouldAutoAcquireAttackTargets: ObjectDataEntryLevelFieldValueSupplier<boolean>);
|
|
8
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
|
+
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
5
|
+
local ____exports = {}
|
|
6
|
+
local ____ability_2Dtype = require("engine.object-data.entry.ability-type")
|
|
7
|
+
local AbilityType = ____ability_2Dtype.AbilityType
|
|
8
|
+
____exports.PermanentInvisibilityAbilityType = __TS__Class()
|
|
9
|
+
local PermanentInvisibilityAbilityType = ____exports.PermanentInvisibilityAbilityType
|
|
10
|
+
PermanentInvisibilityAbilityType.name = "PermanentInvisibilityAbilityType"
|
|
11
|
+
__TS__ClassExtends(PermanentInvisibilityAbilityType, AbilityType)
|
|
12
|
+
PermanentInvisibilityAbilityType.BASE_ID = fourCC("Apiv")
|
|
13
|
+
__TS__SetDescriptor(
|
|
14
|
+
PermanentInvisibilityAbilityType.prototype,
|
|
15
|
+
"shouldAutoAcquireAttackTargets",
|
|
16
|
+
{
|
|
17
|
+
get = function(self)
|
|
18
|
+
return self:getBooleanLevelField("Gho1")
|
|
19
|
+
end,
|
|
20
|
+
set = function(self, shouldAutoAcquireAttackTargets)
|
|
21
|
+
self:setBooleanLevelField("Gho1", shouldAutoAcquireAttackTargets)
|
|
22
|
+
end
|
|
23
|
+
},
|
|
24
|
+
true
|
|
25
|
+
)
|
|
26
|
+
return ____exports
|
|
@@ -4,6 +4,7 @@ import { ObjectField, ObjectLevelField, ObjectLevelFieldValueChangeEvent, Readon
|
|
|
4
4
|
import { UnitType, UnitTypeId } from "../object-data/entry/unit-type";
|
|
5
5
|
import { ReadonlyNonEmptyLinkedSet } from "../../utility/linked-set";
|
|
6
6
|
import { AttackType } from "../object-data/auxiliary/attack-type";
|
|
7
|
+
import { UnitClassifications } from "../object-data/auxiliary/unit-classification";
|
|
7
8
|
export declare abstract class UnitField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType = any> extends ObjectField<UnitType, Unit, ValueType, NativeFieldType> {
|
|
8
9
|
protected get instanceClass(): typeof Unit;
|
|
9
10
|
protected getObjectDataEntryId(instance: Unit): UnitTypeId;
|
|
@@ -56,4 +57,14 @@ export declare abstract class UnitEnumWeaponField<T extends number> extends Unit
|
|
|
56
57
|
export declare class UnitAttackTypeWeaponField extends UnitEnumWeaponField<AttackType> {
|
|
57
58
|
protected values: ReadonlyNonEmptyLinkedSet<AttackType>;
|
|
58
59
|
}
|
|
60
|
+
export declare class UnitClassificationsField extends UnitField<UnitClassifications, junitintegerfield> {
|
|
61
|
+
protected get defaultValue(): UnitClassifications;
|
|
62
|
+
protected getNativeFieldById(id: number): junitintegerfield;
|
|
63
|
+
protected getNativeFieldValue(instance: Unit): UnitClassifications;
|
|
64
|
+
protected setNativeFieldValue(instance: Unit, value: UnitClassifications): boolean;
|
|
65
|
+
}
|
|
66
|
+
export declare class UnitPropulsionWindowField extends UnitFloatField {
|
|
67
|
+
protected getNativeFieldValue(instance: Unit): number;
|
|
68
|
+
protected setNativeFieldValue(instance: Unit, value: number): boolean;
|
|
69
|
+
}
|
|
59
70
|
export {};
|
|
@@ -18,6 +18,8 @@ local convertUnitStringField = ConvertUnitStringField
|
|
|
18
18
|
local convertUnitWeaponIntegerField = ConvertUnitWeaponIntegerField
|
|
19
19
|
local getUnitWeaponIntegerField = BlzGetUnitWeaponIntegerField
|
|
20
20
|
local setUnitWeaponIntegerField = BlzSetUnitWeaponIntegerField
|
|
21
|
+
local getUnitPropulsionWindow = GetUnitPropWindow
|
|
22
|
+
local setUnitPropulsionWindow = SetUnitPropWindow
|
|
21
23
|
____exports.UnitField = __TS__Class()
|
|
22
24
|
local UnitField = ____exports.UnitField
|
|
23
25
|
UnitField.name = "UnitField"
|
|
@@ -215,4 +217,36 @@ function UnitAttackTypeWeaponField.prototype.____constructor(self, ...)
|
|
|
215
217
|
6
|
|
216
218
|
)
|
|
217
219
|
end
|
|
220
|
+
____exports.UnitClassificationsField = __TS__Class()
|
|
221
|
+
local UnitClassificationsField = ____exports.UnitClassificationsField
|
|
222
|
+
UnitClassificationsField.name = "UnitClassificationsField"
|
|
223
|
+
__TS__ClassExtends(UnitClassificationsField, ____exports.UnitField)
|
|
224
|
+
function UnitClassificationsField.prototype.getNativeFieldById(self, id)
|
|
225
|
+
return convertUnitIntegerField(id)
|
|
226
|
+
end
|
|
227
|
+
function UnitClassificationsField.prototype.getNativeFieldValue(self, instance)
|
|
228
|
+
return instance:getField(self.nativeField)
|
|
229
|
+
end
|
|
230
|
+
function UnitClassificationsField.prototype.setNativeFieldValue(self, instance, value)
|
|
231
|
+
return instance:setField(self.nativeField, value)
|
|
232
|
+
end
|
|
233
|
+
__TS__SetDescriptor(
|
|
234
|
+
UnitClassificationsField.prototype,
|
|
235
|
+
"defaultValue",
|
|
236
|
+
{get = function(self)
|
|
237
|
+
return 0
|
|
238
|
+
end},
|
|
239
|
+
true
|
|
240
|
+
)
|
|
241
|
+
____exports.UnitPropulsionWindowField = __TS__Class()
|
|
242
|
+
local UnitPropulsionWindowField = ____exports.UnitPropulsionWindowField
|
|
243
|
+
UnitPropulsionWindowField.name = "UnitPropulsionWindowField"
|
|
244
|
+
__TS__ClassExtends(UnitPropulsionWindowField, ____exports.UnitFloatField)
|
|
245
|
+
function UnitPropulsionWindowField.prototype.getNativeFieldValue(self, instance)
|
|
246
|
+
return getUnitPropulsionWindow(instance.handle)
|
|
247
|
+
end
|
|
248
|
+
function UnitPropulsionWindowField.prototype.setNativeFieldValue(self, instance, value)
|
|
249
|
+
setUnitPropulsionWindow(instance.handle, value)
|
|
250
|
+
return true
|
|
251
|
+
end
|
|
218
252
|
return ____exports
|