warscript 0.0.1-dev.a5f2d10 → 0.0.1-dev.a9a8ba4
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/config.d.ts +5 -0
- package/config.lua +10 -0
- package/core/types/effect.d.ts +1 -3
- package/core/types/effect.lua +26 -29
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/timer.d.ts +7 -8
- package/core/types/timer.lua +18 -21
- package/core/util.lua +6 -1
- package/decl/native.d.ts +840 -786
- package/engine/behaviour/ability/apply-buff.d.ts +5 -0
- package/engine/behaviour/ability/apply-buff.lua +32 -0
- package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
- package/engine/behaviour/ability/damage.d.ts +9 -3
- package/engine/behaviour/ability/damage.lua +26 -38
- package/engine/behaviour/ability/emulate-impact.lua +16 -2
- package/engine/behaviour/ability.d.ts +5 -1
- package/engine/behaviour/ability.lua +26 -21
- 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 +28 -0
- package/engine/behaviour/unit.lua +160 -4
- package/engine/buff.d.ts +54 -41
- package/engine/buff.lua +286 -228
- package/engine/internal/ability.d.ts +4 -0
- package/engine/internal/ability.lua +17 -0
- package/engine/internal/item/ability.lua +62 -11
- package/engine/internal/item.d.ts +7 -4
- package/engine/internal/item.lua +131 -28
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- 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/add-item-to-slot.lua +4 -2
- 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 +1 -1
- package/engine/internal/unit.d.ts +28 -5
- package/engine/internal/unit.lua +243 -74
- package/engine/lightning.d.ts +4 -3
- package/engine/lightning.lua +21 -12
- package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
- package/engine/object-data/auxiliary/animation-name.lua +16 -0
- package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
- package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
- 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/sound-eax.d.ts +10 -0
- package/engine/object-data/auxiliary/sound-eax.lua +2 -0
- package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
- 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/blank-configurable.lua +12 -1
- package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
- package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
- package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
- package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
- package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
- package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
- package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
- 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/phase-shift.d.ts +10 -0
- package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
- package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
- package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
- package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
- package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
- package/engine/object-data/entry/ability-type/shock-wave.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/summon-quilbeast.lua +2 -2
- package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
- package/engine/object-data/entry/ability-type/web.d.ts +12 -0
- package/engine/object-data/entry/ability-type/web.lua +52 -0
- package/engine/object-data/entry/ability-type.d.ts +19 -17
- package/engine/object-data/entry/ability-type.lua +81 -21
- package/engine/object-data/entry/buff-type/applicable.lua +18 -37
- package/engine/object-data/entry/buff-type.d.ts +6 -12
- package/engine/object-data/entry/buff-type.lua +13 -29
- package/engine/object-data/entry/destructible-type.d.ts +1 -1
- package/engine/object-data/entry/item-type.d.ts +1 -1
- package/engine/object-data/entry/item-type.lua +4 -4
- package/engine/object-data/entry/lightning-type.d.ts +1 -1
- package/engine/object-data/entry/sound-preset.d.ts +33 -0
- package/engine/object-data/entry/sound-preset.lua +140 -0
- package/engine/object-data/entry/unit-type.d.ts +10 -3
- package/engine/object-data/entry/unit-type.lua +155 -92
- package/engine/object-data/entry/upgrade.d.ts +1 -1
- package/engine/object-data/entry/upgrade.lua +4 -4
- package/engine/object-data/entry.d.ts +16 -14
- package/engine/object-data/entry.lua +60 -32
- package/engine/object-field/ability.d.ts +1 -1
- package/engine/object-field/unit.d.ts +50 -3
- package/engine/object-field/unit.lua +186 -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/entries/sound-preset.d.ts +10 -0
- package/engine/standard/entries/sound-preset.lua +10 -0
- package/engine/standard/fields/unit.d.ts +3 -0
- package/engine/standard/fields/unit.lua +5 -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/objutil/unit.lua +8 -0
- package/package.json +2 -2
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +3 -0
- package/utility/functions.d.ts +1 -0
- package/utility/functions.lua +1 -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 +1 -0
- package/utility/lua-sets.lua +3 -0
- package/utility/reflection.lua +11 -7
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
package/engine/internal/unit.lua
CHANGED
|
@@ -53,12 +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 queueUnitAnimation = QueueUnitAnimation
|
|
62
69
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
63
70
|
local getUnitRealField = BlzGetUnitRealField
|
|
64
71
|
local getHeroStr = GetHeroStr
|
|
@@ -80,7 +87,6 @@ local getHandleId = GetHandleId
|
|
|
80
87
|
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
81
88
|
local createUnit = CreateUnit
|
|
82
89
|
local killUnit = KillUnit
|
|
83
|
-
local setUnitExploded = SetUnitExploded
|
|
84
90
|
local removeUnit = RemoveUnit
|
|
85
91
|
local getUnitTypeId = GetUnitTypeId
|
|
86
92
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -96,8 +102,6 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
96
102
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
97
103
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
98
104
|
local isUnitInRange = IsUnitInRange
|
|
99
|
-
local setResourceAmount = SetResourceAmount
|
|
100
|
-
local getResourceAmount = GetResourceAmount
|
|
101
105
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
102
106
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
103
107
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
@@ -121,15 +125,10 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
121
125
|
local getIssuedOrderId = GetIssuedOrderId
|
|
122
126
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
123
127
|
local unitAlive = UnitAlive
|
|
124
|
-
local unitAddType = UnitAddType
|
|
125
|
-
local unitRemoveType = UnitRemoveType
|
|
126
|
-
local isUnitIllusion = IsUnitIllusion
|
|
127
128
|
local isUnitType = IsUnitType
|
|
128
129
|
local isUnitAlly = IsUnitAlly
|
|
129
130
|
local isUnitEnemy = IsUnitEnemy
|
|
130
131
|
local getOwningPlayer = GetOwningPlayer
|
|
131
|
-
local setUnitColor = SetUnitColor
|
|
132
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
133
132
|
____exports.UnitClassification = {}
|
|
134
133
|
local UnitClassification = ____exports.UnitClassification
|
|
135
134
|
do
|
|
@@ -139,6 +138,7 @@ do
|
|
|
139
138
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
140
139
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
141
140
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
141
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
142
142
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
143
143
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
144
144
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -346,6 +346,9 @@ local function dispatchAbility(event)
|
|
|
346
346
|
}
|
|
347
347
|
)
|
|
348
348
|
end
|
|
349
|
+
local function damagingEventPreventRetaliation(self)
|
|
350
|
+
self[0] = true
|
|
351
|
+
end
|
|
349
352
|
local function damageEventPreventDeath(self, callback, ...)
|
|
350
353
|
if self[0] ~= nil then
|
|
351
354
|
return
|
|
@@ -357,7 +360,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
357
360
|
rawset(self, 1 + i, (select(i, ...)))
|
|
358
361
|
end
|
|
359
362
|
end
|
|
360
|
-
local damageSetters = {
|
|
363
|
+
local damageSetters = {
|
|
364
|
+
amount = BlzSetEventDamage,
|
|
365
|
+
attackType = function(attackType)
|
|
366
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
367
|
+
end,
|
|
368
|
+
damageType = BlzSetEventDamageType,
|
|
369
|
+
weaponType = BlzSetEventWeaponType
|
|
370
|
+
}
|
|
361
371
|
local jlimitopByOperator = {
|
|
362
372
|
[0] = LESS_THAN_OR_EQUAL,
|
|
363
373
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -435,6 +445,19 @@ __TS__SetDescriptor(
|
|
|
435
445
|
},
|
|
436
446
|
true
|
|
437
447
|
)
|
|
448
|
+
__TS__SetDescriptor(
|
|
449
|
+
UnitWeapon.prototype,
|
|
450
|
+
"allowedTargetCombatClassifications",
|
|
451
|
+
{
|
|
452
|
+
get = function(self)
|
|
453
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
454
|
+
end,
|
|
455
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
456
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
457
|
+
end
|
|
458
|
+
},
|
|
459
|
+
true
|
|
460
|
+
)
|
|
438
461
|
__TS__SetDescriptor(
|
|
439
462
|
UnitWeapon.prototype,
|
|
440
463
|
"damageBase",
|
|
@@ -639,7 +662,43 @@ local function delayHealthChecksCallback(unit)
|
|
|
639
662
|
end
|
|
640
663
|
end
|
|
641
664
|
local nextSyncId = 1
|
|
642
|
-
local unitBySyncId = setmetatable({}, {__mode = "
|
|
665
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
666
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
667
|
+
local function addAbility(unit, abilityTypeId)
|
|
668
|
+
local handle = unit.handle
|
|
669
|
+
if unitAddAbility(handle, abilityTypeId) then
|
|
670
|
+
local ability = UnitAbility:of(
|
|
671
|
+
checkNotNull(getUnitAbility(handle, abilityTypeId)),
|
|
672
|
+
abilityTypeId,
|
|
673
|
+
unit
|
|
674
|
+
)
|
|
675
|
+
local abilities = unit.abilities
|
|
676
|
+
abilities[#abilities + 1] = ability
|
|
677
|
+
return ability
|
|
678
|
+
end
|
|
679
|
+
return nil
|
|
680
|
+
end
|
|
681
|
+
local function getAbility(unit, abilityTypeId)
|
|
682
|
+
return UnitAbility:of(
|
|
683
|
+
getUnitAbility(unit.handle, abilityTypeId),
|
|
684
|
+
abilityTypeId,
|
|
685
|
+
unit
|
|
686
|
+
)
|
|
687
|
+
end
|
|
688
|
+
local function removeAbility(unit, abilityTypeId)
|
|
689
|
+
if unitRemoveAbility(unit.handle, abilityTypeId) then
|
|
690
|
+
local abilities = unit.abilities
|
|
691
|
+
for i = 1, #abilities do
|
|
692
|
+
if abilities[i].typeId == abilityTypeId then
|
|
693
|
+
abilities[i]:destroy()
|
|
694
|
+
tremove(abilities, i)
|
|
695
|
+
return true
|
|
696
|
+
end
|
|
697
|
+
end
|
|
698
|
+
return true
|
|
699
|
+
end
|
|
700
|
+
return false
|
|
701
|
+
end
|
|
643
702
|
____exports.Unit = __TS__Class()
|
|
644
703
|
local Unit = ____exports.Unit
|
|
645
704
|
Unit.name = "Unit"
|
|
@@ -680,6 +739,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
680
739
|
end
|
|
681
740
|
function Unit.prototype.onDestroy(self)
|
|
682
741
|
local handle = self.handle
|
|
742
|
+
self[107] = getUnitX(handle)
|
|
743
|
+
self[108] = getUnitY(handle)
|
|
683
744
|
if not self._owner then
|
|
684
745
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
685
746
|
end
|
|
@@ -751,10 +812,10 @@ function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
|
751
812
|
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
|
|
752
813
|
end
|
|
753
814
|
function Unit.prototype.addClassification(self, classification)
|
|
754
|
-
return
|
|
815
|
+
return UnitAddType(self.handle, classification)
|
|
755
816
|
end
|
|
756
817
|
function Unit.prototype.removeClassification(self, classification)
|
|
757
|
-
return
|
|
818
|
+
return UnitRemoveType(self.handle, classification)
|
|
758
819
|
end
|
|
759
820
|
function Unit.prototype.hasClassification(self, classification)
|
|
760
821
|
return isUnitType(self.handle, classification)
|
|
@@ -790,13 +851,25 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
790
851
|
if type(animation) == "number" then
|
|
791
852
|
setUnitAnimationByIndex(self.handle, animation)
|
|
792
853
|
elseif rarity then
|
|
793
|
-
|
|
854
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
794
855
|
else
|
|
795
856
|
setUnitAnimation(self.handle, animation)
|
|
796
857
|
end
|
|
797
858
|
end
|
|
859
|
+
function Unit.prototype.resetAnimation(self)
|
|
860
|
+
ResetUnitAnimation(self.handle)
|
|
861
|
+
end
|
|
798
862
|
function Unit.prototype.queueAnimation(self, animation)
|
|
799
|
-
|
|
863
|
+
QueueUnitAnimation(self.handle, animation)
|
|
864
|
+
end
|
|
865
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
866
|
+
if target:isAllowedTarget(self, self.firstWeapon.allowedTargetCombatClassifications) then
|
|
867
|
+
return self.firstWeapon
|
|
868
|
+
end
|
|
869
|
+
if target:isAllowedTarget(target, self.secondWeapon.allowedTargetCombatClassifications) then
|
|
870
|
+
return self.secondWeapon
|
|
871
|
+
end
|
|
872
|
+
return nil
|
|
800
873
|
end
|
|
801
874
|
function Unit.prototype.delayHealthChecks(self)
|
|
802
875
|
self[103] = (self[103] or 0) + 1
|
|
@@ -809,7 +882,7 @@ function Unit.prototype.isSelected(self, player)
|
|
|
809
882
|
return IsUnitSelected(self.handle, player.handle)
|
|
810
883
|
end
|
|
811
884
|
function Unit.prototype.explode(self)
|
|
812
|
-
|
|
885
|
+
SetUnitExploded(self.handle, true)
|
|
813
886
|
killUnit(self.handle)
|
|
814
887
|
end
|
|
815
888
|
function Unit.prototype.kill(self)
|
|
@@ -866,17 +939,13 @@ function Unit.prototype.itemInSlot(self, slot)
|
|
|
866
939
|
return Item:of(unitItemInSlot(self.handle, slot))
|
|
867
940
|
end
|
|
868
941
|
function Unit.prototype.addAbility(self, abilityId)
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
abilities[#abilities + 1] = ability
|
|
877
|
-
return ability
|
|
878
|
-
end
|
|
879
|
-
return nil
|
|
942
|
+
return doUnitAbilityAction(
|
|
943
|
+
self.handle,
|
|
944
|
+
abilityId,
|
|
945
|
+
addAbility,
|
|
946
|
+
self,
|
|
947
|
+
abilityId
|
|
948
|
+
)
|
|
880
949
|
end
|
|
881
950
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
882
951
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -891,30 +960,22 @@ function Unit.prototype.hasAbility(self, abilityId)
|
|
|
891
960
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
892
961
|
end
|
|
893
962
|
function Unit.prototype.getAbilityById(self, abilityId)
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
897
|
-
return nil
|
|
898
|
-
end
|
|
899
|
-
return UnitAbility:of(
|
|
900
|
-
getUnitAbility(self.handle, abilityId),
|
|
963
|
+
return doUnitAbilityAction(
|
|
964
|
+
self.handle,
|
|
901
965
|
abilityId,
|
|
902
|
-
|
|
966
|
+
getAbility,
|
|
967
|
+
self,
|
|
968
|
+
abilityId
|
|
903
969
|
)
|
|
904
970
|
end
|
|
905
971
|
function Unit.prototype.removeAbility(self, abilityId)
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
end
|
|
914
|
-
end
|
|
915
|
-
return true
|
|
916
|
-
end
|
|
917
|
-
return false
|
|
972
|
+
return doUnitAbilityAction(
|
|
973
|
+
self.handle,
|
|
974
|
+
abilityId,
|
|
975
|
+
removeAbility,
|
|
976
|
+
self,
|
|
977
|
+
abilityId
|
|
978
|
+
)
|
|
918
979
|
end
|
|
919
980
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
920
981
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -928,6 +989,21 @@ end
|
|
|
928
989
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
929
990
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
930
991
|
end
|
|
992
|
+
function Unit.prototype.interruptMovement(self)
|
|
993
|
+
local handle = self.handle
|
|
994
|
+
unitDisableAbility(
|
|
995
|
+
handle,
|
|
996
|
+
fourCC("Amov"),
|
|
997
|
+
true,
|
|
998
|
+
false
|
|
999
|
+
)
|
|
1000
|
+
unitDisableAbility(
|
|
1001
|
+
handle,
|
|
1002
|
+
fourCC("Amov"),
|
|
1003
|
+
false,
|
|
1004
|
+
false
|
|
1005
|
+
)
|
|
1006
|
+
end
|
|
931
1007
|
function Unit.prototype.interruptAttack(self)
|
|
932
1008
|
unitInterruptAttack(self.handle)
|
|
933
1009
|
end
|
|
@@ -1201,7 +1277,7 @@ __TS__SetDescriptor(
|
|
|
1201
1277
|
Unit.prototype,
|
|
1202
1278
|
"isIllusion",
|
|
1203
1279
|
{get = function(self)
|
|
1204
|
-
return
|
|
1280
|
+
return IsUnitIllusion(self.handle)
|
|
1205
1281
|
end},
|
|
1206
1282
|
true
|
|
1207
1283
|
)
|
|
@@ -1286,6 +1362,19 @@ __TS__SetDescriptor(
|
|
|
1286
1362
|
},
|
|
1287
1363
|
true
|
|
1288
1364
|
)
|
|
1365
|
+
__TS__SetDescriptor(
|
|
1366
|
+
Unit.prototype,
|
|
1367
|
+
"primaryAttribute",
|
|
1368
|
+
{
|
|
1369
|
+
get = function(self)
|
|
1370
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1371
|
+
end,
|
|
1372
|
+
set = function(self, primaryAttribute)
|
|
1373
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1374
|
+
end
|
|
1375
|
+
},
|
|
1376
|
+
true
|
|
1377
|
+
)
|
|
1289
1378
|
__TS__SetDescriptor(
|
|
1290
1379
|
Unit.prototype,
|
|
1291
1380
|
"strengthBase",
|
|
@@ -1410,7 +1499,7 @@ __TS__SetDescriptor(
|
|
|
1410
1499
|
return not self[106]
|
|
1411
1500
|
end,
|
|
1412
1501
|
set = function(self, isTeamGlowVisible)
|
|
1413
|
-
|
|
1502
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1414
1503
|
local ____temp_6
|
|
1415
1504
|
if not isTeamGlowVisible then
|
|
1416
1505
|
____temp_6 = true
|
|
@@ -1426,9 +1515,9 @@ __TS__SetDescriptor(
|
|
|
1426
1515
|
Unit.prototype,
|
|
1427
1516
|
"color",
|
|
1428
1517
|
{set = function(self, color)
|
|
1429
|
-
|
|
1518
|
+
SetUnitColor(self.handle, color.handle)
|
|
1430
1519
|
if self[106] then
|
|
1431
|
-
|
|
1520
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1432
1521
|
end
|
|
1433
1522
|
end},
|
|
1434
1523
|
true
|
|
@@ -1597,7 +1686,7 @@ __TS__SetDescriptor(
|
|
|
1597
1686
|
"x",
|
|
1598
1687
|
{
|
|
1599
1688
|
get = function(self)
|
|
1600
|
-
return getUnitX(self.handle)
|
|
1689
|
+
return self[107] or getUnitX(self.handle)
|
|
1601
1690
|
end,
|
|
1602
1691
|
set = function(self, v)
|
|
1603
1692
|
SetUnitX(self.handle, v)
|
|
@@ -1610,7 +1699,7 @@ __TS__SetDescriptor(
|
|
|
1610
1699
|
"y",
|
|
1611
1700
|
{
|
|
1612
1701
|
get = function(self)
|
|
1613
|
-
return getUnitY(self.handle)
|
|
1702
|
+
return self[108] or getUnitY(self.handle)
|
|
1614
1703
|
end,
|
|
1615
1704
|
set = function(self, v)
|
|
1616
1705
|
SetUnitY(self.handle, v)
|
|
@@ -1696,10 +1785,10 @@ __TS__SetDescriptor(
|
|
|
1696
1785
|
"gold",
|
|
1697
1786
|
{
|
|
1698
1787
|
get = function(self)
|
|
1699
|
-
return
|
|
1788
|
+
return GetResourceAmount(self.handle)
|
|
1700
1789
|
end,
|
|
1701
1790
|
set = function(self, gold)
|
|
1702
|
-
|
|
1791
|
+
SetResourceAmount(self.handle, gold)
|
|
1703
1792
|
end
|
|
1704
1793
|
},
|
|
1705
1794
|
true
|
|
@@ -1827,6 +1916,19 @@ __TS__SetDescriptor(
|
|
|
1827
1916
|
end},
|
|
1828
1917
|
true
|
|
1829
1918
|
)
|
|
1919
|
+
__TS__SetDescriptor(
|
|
1920
|
+
Unit.prototype,
|
|
1921
|
+
"movementType",
|
|
1922
|
+
{
|
|
1923
|
+
get = function(self)
|
|
1924
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1925
|
+
end,
|
|
1926
|
+
set = function(self, movementType)
|
|
1927
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1928
|
+
end
|
|
1929
|
+
},
|
|
1930
|
+
true
|
|
1931
|
+
)
|
|
1830
1932
|
__TS__SetDescriptor(
|
|
1831
1933
|
Unit.prototype,
|
|
1832
1934
|
"pathing",
|
|
@@ -2008,6 +2110,14 @@ __TS__SetDescriptor(
|
|
|
2008
2110
|
end},
|
|
2009
2111
|
true
|
|
2010
2112
|
)
|
|
2113
|
+
__TS__SetDescriptor(
|
|
2114
|
+
Unit.prototype,
|
|
2115
|
+
"targetAcquiredEvent",
|
|
2116
|
+
{get = function(self)
|
|
2117
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2118
|
+
end},
|
|
2119
|
+
true
|
|
2120
|
+
)
|
|
2011
2121
|
__TS__SetDescriptor(
|
|
2012
2122
|
Unit.prototype,
|
|
2013
2123
|
"onSelect",
|
|
@@ -2369,13 +2479,19 @@ Unit.onDamaging = (function()
|
|
|
2369
2479
|
if source and source.typeId == dummyUnitId then
|
|
2370
2480
|
source = nil
|
|
2371
2481
|
end
|
|
2372
|
-
local target = BlzGetEventDamageTarget()
|
|
2482
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2483
|
+
local metadata = damageMetadataByTarget[target]
|
|
2484
|
+
damageMetadataByTarget[target] = nil
|
|
2373
2485
|
local data = {
|
|
2374
2486
|
amount = GetEventDamage(),
|
|
2375
|
-
attackType = BlzGetEventAttackType(),
|
|
2487
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2376
2488
|
damageType = BlzGetEventDamageType(),
|
|
2377
2489
|
weaponType = BlzGetEventWeaponType(),
|
|
2378
|
-
|
|
2490
|
+
metadata = metadata,
|
|
2491
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2492
|
+
originalAmount = GetEventDamage(),
|
|
2493
|
+
originalMetadata = metadata,
|
|
2494
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2379
2495
|
}
|
|
2380
2496
|
if data.isAttack and source then
|
|
2381
2497
|
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
|
|
@@ -2389,18 +2505,36 @@ Unit.onDamaging = (function()
|
|
|
2389
2505
|
invoke(
|
|
2390
2506
|
event,
|
|
2391
2507
|
source,
|
|
2392
|
-
|
|
2508
|
+
target,
|
|
2393
2509
|
setmetatable(
|
|
2394
2510
|
{},
|
|
2395
2511
|
{
|
|
2396
2512
|
__index = data,
|
|
2397
2513
|
__newindex = function(self, key, value)
|
|
2398
|
-
damageSetters[key]
|
|
2514
|
+
local damageSetter = damageSetters[key]
|
|
2515
|
+
if damageSetter ~= nil then
|
|
2516
|
+
damageSetter(value)
|
|
2517
|
+
end
|
|
2399
2518
|
data[key] = value
|
|
2400
2519
|
end
|
|
2401
2520
|
}
|
|
2402
2521
|
)
|
|
2403
2522
|
)
|
|
2523
|
+
if data[0] and source then
|
|
2524
|
+
local sourceOwner = source.owner.handle
|
|
2525
|
+
data[1] = sourceOwner
|
|
2526
|
+
local targetOwner = target.owner.handle
|
|
2527
|
+
data[2] = targetOwner
|
|
2528
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2529
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2530
|
+
data[3] = true
|
|
2531
|
+
end
|
|
2532
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2533
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2534
|
+
data[4] = true
|
|
2535
|
+
end
|
|
2536
|
+
end
|
|
2537
|
+
damagingEventByTarget[target] = data
|
|
2404
2538
|
return
|
|
2405
2539
|
end
|
|
2406
2540
|
BlzSetEventDamage(0)
|
|
@@ -2408,7 +2542,7 @@ Unit.onDamaging = (function()
|
|
|
2408
2542
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2409
2543
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2410
2544
|
local sourceOwner = source.owner.handle
|
|
2411
|
-
local targetOwner =
|
|
2545
|
+
local targetOwner = target.owner.handle
|
|
2412
2546
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2413
2547
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2414
2548
|
Timer:run(function()
|
|
@@ -2424,23 +2558,19 @@ Unit.onDamaging = (function()
|
|
|
2424
2558
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2425
2559
|
local condition = ____value[1]
|
|
2426
2560
|
local action = ____value[2]
|
|
2427
|
-
if condition(
|
|
2428
|
-
source,
|
|
2429
|
-
____exports.Unit:of(target),
|
|
2430
|
-
data
|
|
2431
|
-
) then
|
|
2561
|
+
if condition(source, target, data) then
|
|
2432
2562
|
action(
|
|
2433
2563
|
source,
|
|
2434
|
-
|
|
2564
|
+
target,
|
|
2435
2565
|
setmetatable(
|
|
2436
2566
|
{fire = function()
|
|
2437
2567
|
UnitDamageTarget(
|
|
2438
2568
|
source.handle,
|
|
2439
|
-
target,
|
|
2569
|
+
target.handle,
|
|
2440
2570
|
data.amount,
|
|
2441
2571
|
true,
|
|
2442
2572
|
true,
|
|
2443
|
-
data.attackType,
|
|
2573
|
+
attackTypeToNative(data.attackType),
|
|
2444
2574
|
data.damageType,
|
|
2445
2575
|
data.weaponType
|
|
2446
2576
|
)
|
|
@@ -2467,26 +2597,50 @@ Unit.onDamage = __TS__New(
|
|
|
2467
2597
|
if source and source.typeId == dummyUnitId then
|
|
2468
2598
|
source = nil
|
|
2469
2599
|
end
|
|
2600
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2601
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2602
|
+
damagingEventByTarget[target] = nil
|
|
2470
2603
|
local data = {
|
|
2471
2604
|
amount = GetEventDamage(),
|
|
2472
|
-
attackType = BlzGetEventAttackType(),
|
|
2605
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2473
2606
|
damageType = BlzGetEventDamageType(),
|
|
2474
2607
|
weaponType = BlzGetEventWeaponType(),
|
|
2608
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2475
2609
|
isAttack = BlzGetEventIsAttack(),
|
|
2476
|
-
originalAmount = GetEventDamage(),
|
|
2610
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2611
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2477
2612
|
preventDeath = damageEventPreventDeath
|
|
2478
2613
|
}
|
|
2614
|
+
if damagingEvent then
|
|
2615
|
+
for key, value in pairs(damagingEvent) do
|
|
2616
|
+
if isAttribute(key) then
|
|
2617
|
+
data[key] = value
|
|
2618
|
+
end
|
|
2619
|
+
end
|
|
2620
|
+
local sourceOwner = damagingEvent[1]
|
|
2621
|
+
if sourceOwner then
|
|
2622
|
+
local targetOwner = damagingEvent[2]
|
|
2623
|
+
if damagingEvent[3] then
|
|
2624
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2625
|
+
end
|
|
2626
|
+
if damagingEvent[4] then
|
|
2627
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2628
|
+
end
|
|
2629
|
+
end
|
|
2630
|
+
end
|
|
2479
2631
|
local evData = setmetatable(
|
|
2480
2632
|
{},
|
|
2481
2633
|
{
|
|
2482
2634
|
__index = data,
|
|
2483
2635
|
__newindex = function(self, key, value)
|
|
2484
|
-
damageSetters[key]
|
|
2636
|
+
local damageSetter = damageSetters[key]
|
|
2637
|
+
if damageSetter ~= nil then
|
|
2638
|
+
damageSetter(value)
|
|
2639
|
+
end
|
|
2485
2640
|
data[key] = value
|
|
2486
2641
|
end
|
|
2487
2642
|
}
|
|
2488
2643
|
)
|
|
2489
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2490
2644
|
invoke(event, source, target, evData)
|
|
2491
2645
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2492
2646
|
local bonusHealth = math.ceil(evData.amount)
|
|
@@ -2565,6 +2719,21 @@ Unit.itemStackedEvent = __TS__New(
|
|
|
2565
2719
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2566
2720
|
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2567
2721
|
)
|
|
2722
|
+
__TS__ObjectDefineProperty(
|
|
2723
|
+
Unit,
|
|
2724
|
+
"itemChargesChangedEvent",
|
|
2725
|
+
{get = function(self)
|
|
2726
|
+
local event = __TS__New(Event)
|
|
2727
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2728
|
+
local unit = item.owner
|
|
2729
|
+
if unit ~= nil then
|
|
2730
|
+
invoke(event, unit, item)
|
|
2731
|
+
end
|
|
2732
|
+
end)
|
|
2733
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2734
|
+
return event
|
|
2735
|
+
end}
|
|
2736
|
+
)
|
|
2568
2737
|
__TS__ObjectDefineProperty(
|
|
2569
2738
|
Unit,
|
|
2570
2739
|
"itemUseOrderEvent",
|
package/engine/lightning.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { LightningTypeId } from "./object-data/entry/lightning-type";
|
|
3
|
-
import { Handle, HandleDestructor } from "../core/types/handle";
|
|
4
3
|
import { Unit } from "../core/types/unit";
|
|
4
|
+
import { AbstractDestroyable, Destructor } from "../destroyable";
|
|
5
5
|
declare const enum LightningPropertyKey {
|
|
6
6
|
CHECK_VISIBILITY = 100,
|
|
7
7
|
SOURCE_UNIT = 101,
|
|
@@ -16,7 +16,8 @@ declare const enum LightningPropertyKey {
|
|
|
16
16
|
FADING = 110
|
|
17
17
|
}
|
|
18
18
|
export type LightningConstructor<T extends Lightning> = typeof Lightning & (new (handle: jlightning, typeId: LightningTypeId) => T);
|
|
19
|
-
export declare class Lightning extends
|
|
19
|
+
export declare class Lightning extends AbstractDestroyable {
|
|
20
|
+
readonly handle: jlightning;
|
|
20
21
|
readonly typeId: LightningTypeId;
|
|
21
22
|
private [LightningPropertyKey.CHECK_VISIBILITY]?;
|
|
22
23
|
private [LightningPropertyKey.SOURCE_UNIT]?;
|
|
@@ -30,7 +31,7 @@ export declare class Lightning extends Handle<jlightning> {
|
|
|
30
31
|
private [LightningPropertyKey.DURATION]?;
|
|
31
32
|
private [LightningPropertyKey.FADING]?;
|
|
32
33
|
constructor(handle: jlightning, typeId: LightningTypeId);
|
|
33
|
-
protected onDestroy():
|
|
34
|
+
protected onDestroy(): Destructor;
|
|
34
35
|
static create<T extends Lightning>(this: LightningConstructor<T>, typeId: LightningTypeId, ...parameters: [
|
|
35
36
|
...checkVisibility: [boolean] | [],
|
|
36
37
|
...sourceAndTarget: [sourceX: number, sourceY: number, targetX: number, targetY: number] | [
|