warscript 0.0.1-dev.effa673 → 0.0.1-dev.f0a9ffe
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/sound.lua +5 -0
- package/core/types/timer.d.ts +8 -8
- package/core/types/timer.lua +25 -23
- package/decl/native.d.ts +844 -788
- 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 +6 -3
- 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 +18 -3
- package/engine/behaviour/ability/restore-mana.d.ts +1 -1
- package/engine/behaviour/ability/restore-mana.lua +6 -6
- 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 +5 -2
- 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 +2 -11
- package/engine/internal/unit+damage.lua +10 -14
- package/engine/internal/unit+spellSteal.lua +1 -2
- package/engine/internal/unit-missile-launch.lua +9 -2
- package/engine/internal/unit.d.ts +23 -6
- package/engine/internal/unit.lua +233 -94
- package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
- package/engine/object-data/auxiliary/armor-type.lua +46 -0
- package/engine/object-data/auxiliary/attachment-preset.d.ts +1 -1
- package/engine/object-data/auxiliary/attachment-preset.lua +3 -2
- package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
- package/engine/object-data/auxiliary/attack-type.lua +42 -0
- package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
- package/engine/object-data/auxiliary/movement-type.lua +22 -0
- package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
- package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
- package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
- package/engine/object-data/entry/ability-type/berserk.lua +13 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
- package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
- package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
- package/engine/object-data/entry/ability-type.lua +8 -3
- package/engine/object-data/entry/buff-type/applicable.lua +5 -0
- package/engine/object-data/entry/buff-type.d.ts +5 -11
- package/engine/object-data/entry/buff-type.lua +11 -27
- package/engine/object-data/entry/unit-type.d.ts +13 -4
- package/engine/object-data/entry/unit-type.lua +153 -85
- package/engine/object-field/ability.d.ts +1 -1
- package/engine/object-field/unit.d.ts +57 -3
- package/engine/object-field/unit.lua +207 -7
- package/engine/object-field.d.ts +15 -4
- package/engine/object-field.lua +184 -90
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- 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/objutil/buff.lua +1 -2
- package/package.json +2 -2
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +3 -0
- package/utility/functions.d.ts +8 -0
- package/utility/functions.lua +13 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +3 -0
- package/utility/lua-maps.d.ts +4 -0
- package/utility/lua-maps.lua +20 -0
- package/utility/lua-sets.d.ts +2 -0
- package/utility/lua-sets.lua +7 -0
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
package/engine/internal/unit.lua
CHANGED
|
@@ -53,13 +53,19 @@ local ____math = require("math")
|
|
|
53
53
|
local min = ____math.min
|
|
54
54
|
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
55
55
|
local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
56
|
+
local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
|
|
57
|
+
local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
|
|
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
|
|
56
65
|
local match = string.match
|
|
57
66
|
local ____tostring = _G.tostring
|
|
58
67
|
local setUnitAnimation = SetUnitAnimation
|
|
59
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
60
68
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
61
|
-
local resetUnitAnimation = ResetUnitAnimation
|
|
62
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
63
69
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
64
70
|
local getUnitRealField = BlzGetUnitRealField
|
|
65
71
|
local getHeroStr = GetHeroStr
|
|
@@ -81,7 +87,6 @@ local getHandleId = GetHandleId
|
|
|
81
87
|
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
82
88
|
local createUnit = CreateUnit
|
|
83
89
|
local killUnit = KillUnit
|
|
84
|
-
local setUnitExploded = SetUnitExploded
|
|
85
90
|
local removeUnit = RemoveUnit
|
|
86
91
|
local getUnitTypeId = GetUnitTypeId
|
|
87
92
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -97,8 +102,6 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
97
102
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
98
103
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
99
104
|
local isUnitInRange = IsUnitInRange
|
|
100
|
-
local setResourceAmount = SetResourceAmount
|
|
101
|
-
local getResourceAmount = GetResourceAmount
|
|
102
105
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
103
106
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
104
107
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
@@ -122,15 +125,9 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
122
125
|
local getIssuedOrderId = GetIssuedOrderId
|
|
123
126
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
124
127
|
local unitAlive = UnitAlive
|
|
125
|
-
local unitAddType = UnitAddType
|
|
126
|
-
local unitRemoveType = UnitRemoveType
|
|
127
|
-
local isUnitIllusion = IsUnitIllusion
|
|
128
|
-
local isUnitType = IsUnitType
|
|
129
128
|
local isUnitAlly = IsUnitAlly
|
|
130
129
|
local isUnitEnemy = IsUnitEnemy
|
|
131
130
|
local getOwningPlayer = GetOwningPlayer
|
|
132
|
-
local setUnitColor = SetUnitColor
|
|
133
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
134
131
|
____exports.UnitClassification = {}
|
|
135
132
|
local UnitClassification = ____exports.UnitClassification
|
|
136
133
|
do
|
|
@@ -140,6 +137,7 @@ do
|
|
|
140
137
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
141
138
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
142
139
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
140
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
143
141
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
144
142
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
145
143
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -347,6 +345,9 @@ local function dispatchAbility(event)
|
|
|
347
345
|
}
|
|
348
346
|
)
|
|
349
347
|
end
|
|
348
|
+
local function damagingEventPreventRetaliation(self)
|
|
349
|
+
self[0] = true
|
|
350
|
+
end
|
|
350
351
|
local function damageEventPreventDeath(self, callback, ...)
|
|
351
352
|
if self[0] ~= nil then
|
|
352
353
|
return
|
|
@@ -358,7 +359,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
358
359
|
rawset(self, 1 + i, (select(i, ...)))
|
|
359
360
|
end
|
|
360
361
|
end
|
|
361
|
-
local damageSetters = {
|
|
362
|
+
local damageSetters = {
|
|
363
|
+
amount = BlzSetEventDamage,
|
|
364
|
+
attackType = function(attackType)
|
|
365
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
366
|
+
end,
|
|
367
|
+
damageType = BlzSetEventDamageType,
|
|
368
|
+
weaponType = BlzSetEventWeaponType
|
|
369
|
+
}
|
|
362
370
|
local jlimitopByOperator = {
|
|
363
371
|
[0] = LESS_THAN_OR_EQUAL,
|
|
364
372
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -436,6 +444,19 @@ __TS__SetDescriptor(
|
|
|
436
444
|
},
|
|
437
445
|
true
|
|
438
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
|
+
)
|
|
439
460
|
__TS__SetDescriptor(
|
|
440
461
|
UnitWeapon.prototype,
|
|
441
462
|
"damageBase",
|
|
@@ -640,16 +661,26 @@ local function delayHealthChecksCallback(unit)
|
|
|
640
661
|
end
|
|
641
662
|
end
|
|
642
663
|
local nextSyncId = 1
|
|
643
|
-
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
|
|
644
675
|
____exports.Unit = __TS__Class()
|
|
645
676
|
local Unit = ____exports.Unit
|
|
646
677
|
Unit.name = "Unit"
|
|
647
678
|
__TS__ClassExtends(Unit, Handle)
|
|
648
679
|
function Unit.prototype.____constructor(self, handle)
|
|
649
680
|
Handle.prototype.____constructor(self, handle)
|
|
650
|
-
local
|
|
651
|
-
nextSyncId =
|
|
652
|
-
self.syncId =
|
|
681
|
+
local ____nextSyncId_1 = nextSyncId
|
|
682
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
683
|
+
self.syncId = ____nextSyncId_1
|
|
653
684
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
654
685
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
655
686
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -750,17 +781,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
750
781
|
end}
|
|
751
782
|
end
|
|
752
783
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
753
|
-
local
|
|
754
|
-
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
|
|
755
786
|
end
|
|
756
787
|
function Unit.prototype.addClassification(self, classification)
|
|
757
|
-
return
|
|
788
|
+
return UnitAddType(self.handle, classification)
|
|
758
789
|
end
|
|
759
790
|
function Unit.prototype.removeClassification(self, classification)
|
|
760
|
-
return
|
|
791
|
+
return UnitRemoveType(self.handle, classification)
|
|
761
792
|
end
|
|
762
793
|
function Unit.prototype.hasClassification(self, classification)
|
|
763
|
-
return
|
|
794
|
+
return IsUnitType(self.handle, classification)
|
|
764
795
|
end
|
|
765
796
|
function Unit.prototype.isVisibleTo(self, player)
|
|
766
797
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -769,13 +800,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
769
800
|
return isUnitInvisible(self.handle, player.handle)
|
|
770
801
|
end
|
|
771
802
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
772
|
-
local
|
|
803
|
+
local ____temp_3
|
|
773
804
|
if type(x) == "number" then
|
|
774
|
-
|
|
805
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
775
806
|
else
|
|
776
|
-
|
|
807
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
777
808
|
end
|
|
778
|
-
return
|
|
809
|
+
return ____temp_3
|
|
779
810
|
end
|
|
780
811
|
function Unit.prototype.isAllyOf(self, unit)
|
|
781
812
|
return isUnitAlly(
|
|
@@ -793,16 +824,25 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
793
824
|
if type(animation) == "number" then
|
|
794
825
|
setUnitAnimationByIndex(self.handle, animation)
|
|
795
826
|
elseif rarity then
|
|
796
|
-
|
|
827
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
797
828
|
else
|
|
798
829
|
setUnitAnimation(self.handle, animation)
|
|
799
830
|
end
|
|
800
831
|
end
|
|
801
832
|
function Unit.prototype.resetAnimation(self)
|
|
802
|
-
|
|
833
|
+
ResetUnitAnimation(self.handle)
|
|
803
834
|
end
|
|
804
835
|
function Unit.prototype.queueAnimation(self, animation)
|
|
805
|
-
|
|
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
|
|
806
846
|
end
|
|
807
847
|
function Unit.prototype.delayHealthChecks(self)
|
|
808
848
|
self[103] = (self[103] or 0) + 1
|
|
@@ -815,21 +855,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
815
855
|
return IsUnitSelected(self.handle, player.handle)
|
|
816
856
|
end
|
|
817
857
|
function Unit.prototype.explode(self)
|
|
818
|
-
|
|
858
|
+
SetUnitExploded(self.handle, true)
|
|
819
859
|
killUnit(self.handle)
|
|
820
860
|
end
|
|
821
861
|
function Unit.prototype.kill(self)
|
|
822
862
|
killUnit(self.handle)
|
|
823
863
|
end
|
|
824
864
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
825
|
-
local
|
|
826
|
-
local
|
|
827
|
-
local
|
|
828
|
-
if
|
|
829
|
-
|
|
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
|
|
830
870
|
end
|
|
831
|
-
__TS__SparseArrayPush(
|
|
832
|
-
|
|
871
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
872
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
833
873
|
end
|
|
834
874
|
function Unit.prototype.healTarget(self, target, amount)
|
|
835
875
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -872,17 +912,16 @@ function Unit.prototype.itemInSlot(self, slot)
|
|
|
872
912
|
return Item:of(unitItemInSlot(self.handle, slot))
|
|
873
913
|
end
|
|
874
914
|
function Unit.prototype.addAbility(self, abilityId)
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
915
|
+
local ability = UnitAbility:of(
|
|
916
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
917
|
+
abilityId,
|
|
918
|
+
self
|
|
919
|
+
)
|
|
920
|
+
if ability ~= nil then
|
|
881
921
|
local abilities = self.abilities
|
|
882
922
|
abilities[#abilities + 1] = ability
|
|
883
|
-
return ability
|
|
884
923
|
end
|
|
885
|
-
return
|
|
924
|
+
return ability
|
|
886
925
|
end
|
|
887
926
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
888
927
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -897,19 +936,11 @@ function Unit.prototype.hasAbility(self, abilityId)
|
|
|
897
936
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
898
937
|
end
|
|
899
938
|
function Unit.prototype.getAbilityById(self, abilityId)
|
|
900
|
-
local
|
|
901
|
-
|
|
902
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
903
|
-
return nil
|
|
904
|
-
end
|
|
905
|
-
return UnitAbility:of(
|
|
906
|
-
getUnitAbility(self.handle, abilityId),
|
|
907
|
-
abilityId,
|
|
908
|
-
self
|
|
909
|
-
)
|
|
939
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
940
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
910
941
|
end
|
|
911
942
|
function Unit.prototype.removeAbility(self, abilityId)
|
|
912
|
-
if
|
|
943
|
+
if doUnitAbilityAction(self.handle, abilityId, unitRemoveAbility, abilityId) then
|
|
913
944
|
local abilities = self.abilities
|
|
914
945
|
for i = 1, #abilities do
|
|
915
946
|
if abilities[i].typeId == abilityId then
|
|
@@ -934,6 +965,21 @@ end
|
|
|
934
965
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
935
966
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
936
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
|
|
937
983
|
function Unit.prototype.interruptAttack(self)
|
|
938
984
|
unitInterruptAttack(self.handle)
|
|
939
985
|
end
|
|
@@ -1207,7 +1253,7 @@ __TS__SetDescriptor(
|
|
|
1207
1253
|
Unit.prototype,
|
|
1208
1254
|
"isIllusion",
|
|
1209
1255
|
{get = function(self)
|
|
1210
|
-
return
|
|
1256
|
+
return IsUnitIllusion(self.handle)
|
|
1211
1257
|
end},
|
|
1212
1258
|
true
|
|
1213
1259
|
)
|
|
@@ -1292,6 +1338,19 @@ __TS__SetDescriptor(
|
|
|
1292
1338
|
},
|
|
1293
1339
|
true
|
|
1294
1340
|
)
|
|
1341
|
+
__TS__SetDescriptor(
|
|
1342
|
+
Unit.prototype,
|
|
1343
|
+
"primaryAttribute",
|
|
1344
|
+
{
|
|
1345
|
+
get = function(self)
|
|
1346
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1347
|
+
end,
|
|
1348
|
+
set = function(self, primaryAttribute)
|
|
1349
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1350
|
+
end
|
|
1351
|
+
},
|
|
1352
|
+
true
|
|
1353
|
+
)
|
|
1295
1354
|
__TS__SetDescriptor(
|
|
1296
1355
|
Unit.prototype,
|
|
1297
1356
|
"strengthBase",
|
|
@@ -1416,14 +1475,14 @@ __TS__SetDescriptor(
|
|
|
1416
1475
|
return not self[106]
|
|
1417
1476
|
end,
|
|
1418
1477
|
set = function(self, isTeamGlowVisible)
|
|
1419
|
-
|
|
1420
|
-
local
|
|
1478
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1479
|
+
local ____temp_7
|
|
1421
1480
|
if not isTeamGlowVisible then
|
|
1422
|
-
|
|
1481
|
+
____temp_7 = true
|
|
1423
1482
|
else
|
|
1424
|
-
|
|
1483
|
+
____temp_7 = nil
|
|
1425
1484
|
end
|
|
1426
|
-
self[106] =
|
|
1485
|
+
self[106] = ____temp_7
|
|
1427
1486
|
end
|
|
1428
1487
|
},
|
|
1429
1488
|
true
|
|
@@ -1432,9 +1491,9 @@ __TS__SetDescriptor(
|
|
|
1432
1491
|
Unit.prototype,
|
|
1433
1492
|
"color",
|
|
1434
1493
|
{set = function(self, color)
|
|
1435
|
-
|
|
1494
|
+
SetUnitColor(self.handle, color.handle)
|
|
1436
1495
|
if self[106] then
|
|
1437
|
-
|
|
1496
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1438
1497
|
end
|
|
1439
1498
|
end},
|
|
1440
1499
|
true
|
|
@@ -1702,10 +1761,10 @@ __TS__SetDescriptor(
|
|
|
1702
1761
|
"gold",
|
|
1703
1762
|
{
|
|
1704
1763
|
get = function(self)
|
|
1705
|
-
return
|
|
1764
|
+
return GetResourceAmount(self.handle)
|
|
1706
1765
|
end,
|
|
1707
1766
|
set = function(self, gold)
|
|
1708
|
-
|
|
1767
|
+
SetResourceAmount(self.handle, gold)
|
|
1709
1768
|
end
|
|
1710
1769
|
},
|
|
1711
1770
|
true
|
|
@@ -1833,6 +1892,19 @@ __TS__SetDescriptor(
|
|
|
1833
1892
|
end},
|
|
1834
1893
|
true
|
|
1835
1894
|
)
|
|
1895
|
+
__TS__SetDescriptor(
|
|
1896
|
+
Unit.prototype,
|
|
1897
|
+
"movementType",
|
|
1898
|
+
{
|
|
1899
|
+
get = function(self)
|
|
1900
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1901
|
+
end,
|
|
1902
|
+
set = function(self, movementType)
|
|
1903
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1904
|
+
end
|
|
1905
|
+
},
|
|
1906
|
+
true
|
|
1907
|
+
)
|
|
1836
1908
|
__TS__SetDescriptor(
|
|
1837
1909
|
Unit.prototype,
|
|
1838
1910
|
"pathing",
|
|
@@ -2014,6 +2086,14 @@ __TS__SetDescriptor(
|
|
|
2014
2086
|
end},
|
|
2015
2087
|
true
|
|
2016
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
|
+
)
|
|
2017
2097
|
__TS__SetDescriptor(
|
|
2018
2098
|
Unit.prototype,
|
|
2019
2099
|
"onSelect",
|
|
@@ -2149,25 +2229,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2149
2229
|
InitializingEvent,
|
|
2150
2230
|
function(event)
|
|
2151
2231
|
local function listener(unit, id)
|
|
2152
|
-
local
|
|
2232
|
+
local ____GetSpellTargetUnit_result_10
|
|
2153
2233
|
if GetSpellTargetUnit() then
|
|
2154
|
-
|
|
2234
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2155
2235
|
else
|
|
2156
|
-
local
|
|
2236
|
+
local ____GetSpellTargetItem_result_9
|
|
2157
2237
|
if GetSpellTargetItem() then
|
|
2158
|
-
|
|
2238
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2159
2239
|
else
|
|
2160
|
-
local
|
|
2240
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2161
2241
|
if GetSpellTargetDestructable() then
|
|
2162
|
-
|
|
2242
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2163
2243
|
else
|
|
2164
|
-
|
|
2244
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2165
2245
|
end
|
|
2166
|
-
|
|
2246
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2167
2247
|
end
|
|
2168
|
-
|
|
2248
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2169
2249
|
end
|
|
2170
|
-
local target =
|
|
2250
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2171
2251
|
if target then
|
|
2172
2252
|
invoke(event, unit, id, target)
|
|
2173
2253
|
end
|
|
@@ -2375,13 +2455,19 @@ Unit.onDamaging = (function()
|
|
|
2375
2455
|
if source and source.typeId == dummyUnitId then
|
|
2376
2456
|
source = nil
|
|
2377
2457
|
end
|
|
2378
|
-
local target = BlzGetEventDamageTarget()
|
|
2458
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2459
|
+
local metadata = damageMetadataByTarget[target]
|
|
2460
|
+
damageMetadataByTarget[target] = nil
|
|
2379
2461
|
local data = {
|
|
2380
2462
|
amount = GetEventDamage(),
|
|
2381
|
-
attackType = BlzGetEventAttackType(),
|
|
2463
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2382
2464
|
damageType = BlzGetEventDamageType(),
|
|
2383
2465
|
weaponType = BlzGetEventWeaponType(),
|
|
2384
|
-
|
|
2466
|
+
metadata = metadata,
|
|
2467
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2468
|
+
originalAmount = GetEventDamage(),
|
|
2469
|
+
originalMetadata = metadata,
|
|
2470
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2385
2471
|
}
|
|
2386
2472
|
if data.isAttack and source then
|
|
2387
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
|
|
@@ -2395,18 +2481,36 @@ Unit.onDamaging = (function()
|
|
|
2395
2481
|
invoke(
|
|
2396
2482
|
event,
|
|
2397
2483
|
source,
|
|
2398
|
-
|
|
2484
|
+
target,
|
|
2399
2485
|
setmetatable(
|
|
2400
2486
|
{},
|
|
2401
2487
|
{
|
|
2402
2488
|
__index = data,
|
|
2403
2489
|
__newindex = function(self, key, value)
|
|
2404
|
-
damageSetters[key]
|
|
2490
|
+
local damageSetter = damageSetters[key]
|
|
2491
|
+
if damageSetter ~= nil then
|
|
2492
|
+
damageSetter(value)
|
|
2493
|
+
end
|
|
2405
2494
|
data[key] = value
|
|
2406
2495
|
end
|
|
2407
2496
|
}
|
|
2408
2497
|
)
|
|
2409
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
|
|
2410
2514
|
return
|
|
2411
2515
|
end
|
|
2412
2516
|
BlzSetEventDamage(0)
|
|
@@ -2414,7 +2518,7 @@ Unit.onDamaging = (function()
|
|
|
2414
2518
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2415
2519
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2416
2520
|
local sourceOwner = source.owner.handle
|
|
2417
|
-
local targetOwner =
|
|
2521
|
+
local targetOwner = target.owner.handle
|
|
2418
2522
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2419
2523
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2420
2524
|
Timer:run(function()
|
|
@@ -2430,23 +2534,19 @@ Unit.onDamaging = (function()
|
|
|
2430
2534
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2431
2535
|
local condition = ____value[1]
|
|
2432
2536
|
local action = ____value[2]
|
|
2433
|
-
if condition(
|
|
2434
|
-
source,
|
|
2435
|
-
____exports.Unit:of(target),
|
|
2436
|
-
data
|
|
2437
|
-
) then
|
|
2537
|
+
if condition(source, target, data) then
|
|
2438
2538
|
action(
|
|
2439
2539
|
source,
|
|
2440
|
-
|
|
2540
|
+
target,
|
|
2441
2541
|
setmetatable(
|
|
2442
2542
|
{fire = function()
|
|
2443
2543
|
UnitDamageTarget(
|
|
2444
2544
|
source.handle,
|
|
2445
|
-
target,
|
|
2545
|
+
target.handle,
|
|
2446
2546
|
data.amount,
|
|
2447
2547
|
true,
|
|
2448
2548
|
true,
|
|
2449
|
-
data.attackType,
|
|
2549
|
+
attackTypeToNative(data.attackType),
|
|
2450
2550
|
data.damageType,
|
|
2451
2551
|
data.weaponType
|
|
2452
2552
|
)
|
|
@@ -2473,26 +2573,50 @@ Unit.onDamage = __TS__New(
|
|
|
2473
2573
|
if source and source.typeId == dummyUnitId then
|
|
2474
2574
|
source = nil
|
|
2475
2575
|
end
|
|
2576
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2577
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2578
|
+
damagingEventByTarget[target] = nil
|
|
2476
2579
|
local data = {
|
|
2477
2580
|
amount = GetEventDamage(),
|
|
2478
|
-
attackType = BlzGetEventAttackType(),
|
|
2581
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2479
2582
|
damageType = BlzGetEventDamageType(),
|
|
2480
2583
|
weaponType = BlzGetEventWeaponType(),
|
|
2584
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2481
2585
|
isAttack = BlzGetEventIsAttack(),
|
|
2482
|
-
originalAmount = GetEventDamage(),
|
|
2586
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2587
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2483
2588
|
preventDeath = damageEventPreventDeath
|
|
2484
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
|
|
2485
2607
|
local evData = setmetatable(
|
|
2486
2608
|
{},
|
|
2487
2609
|
{
|
|
2488
2610
|
__index = data,
|
|
2489
2611
|
__newindex = function(self, key, value)
|
|
2490
|
-
damageSetters[key]
|
|
2612
|
+
local damageSetter = damageSetters[key]
|
|
2613
|
+
if damageSetter ~= nil then
|
|
2614
|
+
damageSetter(value)
|
|
2615
|
+
end
|
|
2491
2616
|
data[key] = value
|
|
2492
2617
|
end
|
|
2493
2618
|
}
|
|
2494
2619
|
)
|
|
2495
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2496
2620
|
invoke(event, source, target, evData)
|
|
2497
2621
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2498
2622
|
local bonusHealth = math.ceil(evData.amount)
|
|
@@ -2571,6 +2695,21 @@ Unit.itemStackedEvent = __TS__New(
|
|
|
2571
2695
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2572
2696
|
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2573
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
|
+
)
|
|
2574
2713
|
__TS__ObjectDefineProperty(
|
|
2575
2714
|
Unit,
|
|
2576
2715
|
"itemUseOrderEvent",
|
|
@@ -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
|