warscript 0.0.1-dev.a3723da → 0.0.1-dev.a44a461
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 +7 -0
- package/attributes.lua +8 -1
- package/binaryreader.d.ts +1 -0
- package/binaryreader.lua +3 -0
- package/config.d.ts +5 -0
- package/config.lua +10 -0
- package/core/types/effect.d.ts +14 -6
- package/core/types/effect.lua +131 -35
- package/core/types/frame.d.ts +6 -0
- package/core/types/frame.lua +91 -1
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/timer.d.ts +6 -7
- package/core/types/timer.lua +18 -21
- package/core/util.d.ts +1 -1
- package/core/util.lua +18 -1
- package/decl/native.d.ts +840 -786
- package/engine/behavior.d.ts +2 -2
- package/engine/behavior.lua +6 -6
- package/engine/behaviour/ability/always-enabled.d.ts +7 -0
- package/engine/behaviour/ability/always-enabled.lua +31 -0
- package/engine/behaviour/ability/apply-buff.d.ts +8 -5
- 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 +12 -6
- package/engine/behaviour/ability/damage.lua +37 -51
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +35 -0
- package/engine/behaviour/ability/heal.d.ts +33 -6
- package/engine/behaviour/ability/heal.lua +89 -10
- package/engine/behaviour/ability/instant-impact.d.ts +2 -2
- package/engine/behaviour/ability/instant-impact.lua +4 -19
- package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
- package/engine/behaviour/ability/on-command-impact.lua +25 -0
- package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
- package/engine/behaviour/ability/remove-buffs.lua +28 -0
- package/engine/behaviour/ability.d.ts +20 -4
- package/engine/behaviour/ability.lua +111 -38
- package/engine/behaviour/unit.d.ts +7 -0
- package/engine/behaviour/unit.lua +20 -0
- package/engine/buff.d.ts +101 -39
- package/engine/buff.lua +458 -203
- package/engine/internal/ability.d.ts +16 -13
- package/engine/internal/ability.lua +80 -76
- package/engine/internal/item/ability.lua +106 -0
- package/engine/internal/item+owner.lua +2 -2
- package/engine/internal/item.d.ts +4 -3
- package/engine/internal/item.lua +56 -25
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
- package/engine/internal/misc/ability-disable-counter.lua +13 -0
- 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/object-data/auto-attack-speed-increase.d.ts +1 -1
- package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
- package/engine/internal/object-data/evasion-probability.d.ts +2 -0
- package/engine/internal/object-data/evasion-probability.lua +16 -0
- package/engine/internal/unit/ability.d.ts +10 -1
- package/engine/internal/unit/ability.lua +36 -14
- package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
- package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot.lua +52 -0
- package/engine/internal/unit/bonus.d.ts +6 -2
- package/engine/internal/unit/bonus.lua +23 -1
- package/engine/internal/unit/ignore-events-items.d.ts +2 -0
- package/engine/internal/unit/ignore-events-items.lua +5 -0
- package/engine/internal/unit/item.d.ts +24 -0
- package/engine/internal/unit/item.lua +78 -0
- package/engine/internal/unit/main-selected.d.ts +13 -0
- package/engine/internal/unit/main-selected.lua +51 -0
- package/engine/internal/unit+ability.lua +2 -2
- 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 +24 -5
- package/engine/internal/unit.d.ts +43 -12
- package/engine/internal/unit.lua +255 -114
- package/engine/internal/utility.lua +12 -0
- package/engine/lightning.d.ts +12 -5
- package/engine/lightning.lua +48 -14
- package/engine/local-client.d.ts +7 -2
- package/engine/local-client.lua +82 -0
- 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/sound-preset-name.d.ts +5 -1
- 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/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 +89 -33
- 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 +15 -1
- package/engine/object-data/entry/item-type.lua +93 -2
- 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-data/utility/object-data-entry-id-generator.lua +7 -0
- package/engine/object-field/ability.d.ts +26 -3
- package/engine/object-field/ability.lua +54 -1
- package/engine/object-field/unit.d.ts +46 -3
- package/engine/object-field/unit.lua +173 -7
- package/engine/object-field.d.ts +11 -3
- package/engine/object-field.lua +162 -76
- 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/ability.d.ts +2 -0
- package/engine/standard/fields/ability.lua +2 -0
- package/engine/unit.d.ts +3 -0
- package/engine/unit.lua +3 -0
- package/index.d.ts +1 -0
- package/index.lua +1 -0
- package/net/socket.d.ts +7 -1
- package/net/socket.lua +45 -4
- package/network.d.ts +1 -0
- package/network.lua +3 -2
- package/objutil/buff.lua +2 -3
- package/objutil/unit.lua +8 -0
- package/package.json +2 -2
- package/patch-lua.d.ts +0 -0
- package/patch-lua.lua +10 -0
- package/property.d.ts +55 -0
- package/property.lua +374 -0
- package/utility/arrays.d.ts +9 -1
- package/utility/arrays.lua +37 -3
- package/utility/functions.d.ts +1 -0
- package/utility/functions.lua +1 -0
- package/utility/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
- package/utility/linked-set.d.ts +12 -2
- package/utility/linked-set.lua +8 -2
- package/utility/lua-maps.d.ts +3 -0
- package/utility/lua-maps.lua +16 -0
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +3 -0
- package/utility/reflection.lua +11 -7
- package/utility/types.d.ts +1 -0
package/engine/internal/unit.lua
CHANGED
|
@@ -51,11 +51,20 @@ local ____arrays = require("utility.arrays")
|
|
|
51
51
|
local forEach = ____arrays.forEach
|
|
52
52
|
local ____math = require("math")
|
|
53
53
|
local min = ____math.min
|
|
54
|
+
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
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
|
|
54
63
|
local match = string.match
|
|
55
64
|
local ____tostring = _G.tostring
|
|
56
65
|
local setUnitAnimation = SetUnitAnimation
|
|
57
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
58
66
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
67
|
+
local resetUnitAnimation = ResetUnitAnimation
|
|
59
68
|
local queueUnitAnimation = QueueUnitAnimation
|
|
60
69
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
61
70
|
local getUnitRealField = BlzGetUnitRealField
|
|
@@ -75,9 +84,9 @@ local setUnitScale = SetUnitScale
|
|
|
75
84
|
local setUnitPosition = SetUnitPosition
|
|
76
85
|
local setUnitTimeScale = SetUnitTimeScale
|
|
77
86
|
local getHandleId = GetHandleId
|
|
87
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
78
88
|
local createUnit = CreateUnit
|
|
79
89
|
local killUnit = KillUnit
|
|
80
|
-
local setUnitExploded = SetUnitExploded
|
|
81
90
|
local removeUnit = RemoveUnit
|
|
82
91
|
local getUnitTypeId = GetUnitTypeId
|
|
83
92
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -93,8 +102,6 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
93
102
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
94
103
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
95
104
|
local isUnitInRange = IsUnitInRange
|
|
96
|
-
local setResourceAmount = SetResourceAmount
|
|
97
|
-
local getResourceAmount = GetResourceAmount
|
|
98
105
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
99
106
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
100
107
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
@@ -125,8 +132,6 @@ local isUnitType = IsUnitType
|
|
|
125
132
|
local isUnitAlly = IsUnitAlly
|
|
126
133
|
local isUnitEnemy = IsUnitEnemy
|
|
127
134
|
local getOwningPlayer = GetOwningPlayer
|
|
128
|
-
local setUnitColor = SetUnitColor
|
|
129
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
130
135
|
____exports.UnitClassification = {}
|
|
131
136
|
local UnitClassification = ____exports.UnitClassification
|
|
132
137
|
do
|
|
@@ -354,7 +359,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
354
359
|
rawset(self, 1 + i, (select(i, ...)))
|
|
355
360
|
end
|
|
356
361
|
end
|
|
357
|
-
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
|
+
}
|
|
358
370
|
local jlimitopByOperator = {
|
|
359
371
|
[0] = LESS_THAN_OR_EQUAL,
|
|
360
372
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -562,17 +574,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
562
574
|
____exports.Unit:of(unit)
|
|
563
575
|
)
|
|
564
576
|
end
|
|
565
|
-
if not unitAddAbility(unit, abilityId) then
|
|
566
|
-
if getUnitAbility(unit, abilityId) == ability then
|
|
567
|
-
return UnitAbility:of(
|
|
568
|
-
ability,
|
|
569
|
-
abilityId,
|
|
570
|
-
____exports.Unit:of(unit)
|
|
571
|
-
)
|
|
572
|
-
end
|
|
573
|
-
else
|
|
574
|
-
unitRemoveAbility(unit, abilityId)
|
|
575
|
-
end
|
|
576
577
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
577
578
|
local item = unitItemInSlot(unit, i)
|
|
578
579
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -630,15 +631,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
630
631
|
dummies[player] = dummy
|
|
631
632
|
end
|
|
632
633
|
local function delayHealthChecksCallback(unit)
|
|
633
|
-
local counter = (unit[
|
|
634
|
+
local counter = (unit[103] or 0) - 1
|
|
634
635
|
if counter ~= 0 then
|
|
635
|
-
unit[
|
|
636
|
+
unit[103] = counter
|
|
636
637
|
return
|
|
637
638
|
end
|
|
638
|
-
unit[
|
|
639
|
-
local healthBonus = unit[
|
|
639
|
+
unit[103] = nil
|
|
640
|
+
local healthBonus = unit[104]
|
|
640
641
|
if healthBonus ~= nil then
|
|
641
|
-
unit[
|
|
642
|
+
unit[104] = nil
|
|
642
643
|
local handle = unit.handle
|
|
643
644
|
BlzSetUnitMaxHP(
|
|
644
645
|
handle,
|
|
@@ -646,12 +647,18 @@ local function delayHealthChecksCallback(unit)
|
|
|
646
647
|
)
|
|
647
648
|
end
|
|
648
649
|
end
|
|
650
|
+
local nextSyncId = 1
|
|
651
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
652
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
649
653
|
____exports.Unit = __TS__Class()
|
|
650
654
|
local Unit = ____exports.Unit
|
|
651
655
|
Unit.name = "Unit"
|
|
652
656
|
__TS__ClassExtends(Unit, Handle)
|
|
653
657
|
function Unit.prototype.____constructor(self, handle)
|
|
654
658
|
Handle.prototype.____constructor(self, handle)
|
|
659
|
+
local ____nextSyncId_0 = nextSyncId
|
|
660
|
+
nextSyncId = ____nextSyncId_0 + 1
|
|
661
|
+
self.syncId = ____nextSyncId_0
|
|
655
662
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
656
663
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
657
664
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -664,6 +671,7 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
664
671
|
fourCC("Amrf")
|
|
665
672
|
))
|
|
666
673
|
end
|
|
674
|
+
unitBySyncId[self.syncId] = self
|
|
667
675
|
local ____ = self.abilities
|
|
668
676
|
end
|
|
669
677
|
function Unit.prototype.getEvent(self, event, collector)
|
|
@@ -682,6 +690,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
682
690
|
end
|
|
683
691
|
function Unit.prototype.onDestroy(self)
|
|
684
692
|
local handle = self.handle
|
|
693
|
+
self[107] = getUnitX(handle)
|
|
694
|
+
self[108] = getUnitY(handle)
|
|
685
695
|
if not self._owner then
|
|
686
696
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
687
697
|
end
|
|
@@ -749,8 +759,8 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
749
759
|
end}
|
|
750
760
|
end
|
|
751
761
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
752
|
-
local
|
|
753
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
762
|
+
local ____combatClassification_1 = combatClassification
|
|
763
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
|
|
754
764
|
end
|
|
755
765
|
function Unit.prototype.addClassification(self, classification)
|
|
756
766
|
return unitAddType(self.handle, classification)
|
|
@@ -768,13 +778,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
768
778
|
return isUnitInvisible(self.handle, player.handle)
|
|
769
779
|
end
|
|
770
780
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
771
|
-
local
|
|
781
|
+
local ____temp_2
|
|
772
782
|
if type(x) == "number" then
|
|
773
|
-
|
|
783
|
+
____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
|
|
774
784
|
else
|
|
775
|
-
|
|
785
|
+
____temp_2 = isUnitInRange(self.handle, x.handle, y)
|
|
776
786
|
end
|
|
777
|
-
return
|
|
787
|
+
return ____temp_2
|
|
778
788
|
end
|
|
779
789
|
function Unit.prototype.isAllyOf(self, unit)
|
|
780
790
|
return isUnitAlly(
|
|
@@ -792,16 +802,19 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
792
802
|
if type(animation) == "number" then
|
|
793
803
|
setUnitAnimationByIndex(self.handle, animation)
|
|
794
804
|
elseif rarity then
|
|
795
|
-
|
|
805
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
796
806
|
else
|
|
797
807
|
setUnitAnimation(self.handle, animation)
|
|
798
808
|
end
|
|
799
809
|
end
|
|
810
|
+
function Unit.prototype.resetAnimation(self)
|
|
811
|
+
resetUnitAnimation(self.handle)
|
|
812
|
+
end
|
|
800
813
|
function Unit.prototype.queueAnimation(self, animation)
|
|
801
814
|
queueUnitAnimation(self.handle, animation)
|
|
802
815
|
end
|
|
803
816
|
function Unit.prototype.delayHealthChecks(self)
|
|
804
|
-
self[
|
|
817
|
+
self[103] = (self[103] or 0) + 1
|
|
805
818
|
Timer:run(delayHealthChecksCallback, self)
|
|
806
819
|
end
|
|
807
820
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -811,21 +824,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
811
824
|
return IsUnitSelected(self.handle, player.handle)
|
|
812
825
|
end
|
|
813
826
|
function Unit.prototype.explode(self)
|
|
814
|
-
|
|
827
|
+
SetUnitExploded(self.handle, true)
|
|
815
828
|
killUnit(self.handle)
|
|
816
829
|
end
|
|
817
830
|
function Unit.prototype.kill(self)
|
|
818
831
|
killUnit(self.handle)
|
|
819
832
|
end
|
|
820
833
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
821
|
-
local
|
|
822
|
-
local
|
|
823
|
-
local
|
|
824
|
-
if
|
|
825
|
-
|
|
834
|
+
local ____ReviveHero_5 = ReviveHero
|
|
835
|
+
local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
|
|
836
|
+
local ____doEffect_3 = doEffect
|
|
837
|
+
if ____doEffect_3 == nil then
|
|
838
|
+
____doEffect_3 = false
|
|
826
839
|
end
|
|
827
|
-
__TS__SparseArrayPush(
|
|
828
|
-
|
|
840
|
+
__TS__SparseArrayPush(____array_4, ____doEffect_3)
|
|
841
|
+
____ReviveHero_5(__TS__SparseArraySpread(____array_4))
|
|
829
842
|
end
|
|
830
843
|
function Unit.prototype.healTarget(self, target, amount)
|
|
831
844
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -865,7 +878,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
865
878
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
866
879
|
end
|
|
867
880
|
function Unit.prototype.itemInSlot(self, slot)
|
|
868
|
-
return Item:of(
|
|
881
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
869
882
|
end
|
|
870
883
|
function Unit.prototype.addAbility(self, abilityId)
|
|
871
884
|
if unitAddAbility(self.handle, abilityId) then
|
|
@@ -934,8 +947,15 @@ function Unit.prototype.interruptAttack(self)
|
|
|
934
947
|
unitInterruptAttack(self.handle)
|
|
935
948
|
end
|
|
936
949
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
937
|
-
|
|
938
|
-
unitDisableAbility(
|
|
950
|
+
local handle = self.handle
|
|
951
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
952
|
+
Timer:run(
|
|
953
|
+
unitDisableAbility,
|
|
954
|
+
handle,
|
|
955
|
+
abilityId,
|
|
956
|
+
false,
|
|
957
|
+
false
|
|
958
|
+
)
|
|
939
959
|
end
|
|
940
960
|
function Unit.prototype.getDistanceTo(self, target)
|
|
941
961
|
local handle = self.handle
|
|
@@ -995,18 +1015,18 @@ function Unit.prototype.unpauseEx(self)
|
|
|
995
1015
|
self:decrementStunCounter()
|
|
996
1016
|
end
|
|
997
1017
|
function Unit.prototype.incrementStunCounter(self)
|
|
998
|
-
local stunCounter = self[
|
|
999
|
-
if not self[
|
|
1018
|
+
local stunCounter = self[102] or 0
|
|
1019
|
+
if not self[101] or stunCounter >= 0 then
|
|
1000
1020
|
BlzPauseUnitEx(self.handle, true)
|
|
1001
1021
|
end
|
|
1002
|
-
self[
|
|
1022
|
+
self[102] = stunCounter + 1
|
|
1003
1023
|
end
|
|
1004
1024
|
function Unit.prototype.decrementStunCounter(self)
|
|
1005
|
-
local stunCounter = self[
|
|
1006
|
-
if not self[
|
|
1025
|
+
local stunCounter = self[102] or 0
|
|
1026
|
+
if not self[101] or stunCounter >= 1 then
|
|
1007
1027
|
BlzPauseUnitEx(self.handle, false)
|
|
1008
1028
|
end
|
|
1009
|
-
self[
|
|
1029
|
+
self[102] = stunCounter - 1
|
|
1010
1030
|
end
|
|
1011
1031
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1012
1032
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -1108,8 +1128,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
1108
1128
|
)
|
|
1109
1129
|
return targetCollection
|
|
1110
1130
|
end
|
|
1111
|
-
function Unit.getSelectionOf(self, player)
|
|
1112
|
-
|
|
1131
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1132
|
+
if target == nil then
|
|
1133
|
+
target = {}
|
|
1134
|
+
end
|
|
1135
|
+
targetCollection = target
|
|
1113
1136
|
targetCollectionNextIndex = 1
|
|
1114
1137
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
1115
1138
|
return targetCollection
|
|
@@ -1131,6 +1154,9 @@ end
|
|
|
1131
1154
|
function Unit.prototype.__tostring(self)
|
|
1132
1155
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
1133
1156
|
end
|
|
1157
|
+
function Unit.getBySyncId(self, syncId)
|
|
1158
|
+
return unitBySyncId[syncId]
|
|
1159
|
+
end
|
|
1134
1160
|
__TS__SetDescriptor(
|
|
1135
1161
|
Unit.prototype,
|
|
1136
1162
|
"_deltas",
|
|
@@ -1194,6 +1220,14 @@ __TS__SetDescriptor(
|
|
|
1194
1220
|
end},
|
|
1195
1221
|
true
|
|
1196
1222
|
)
|
|
1223
|
+
__TS__SetDescriptor(
|
|
1224
|
+
Unit.prototype,
|
|
1225
|
+
"isStunned",
|
|
1226
|
+
{get = function(self)
|
|
1227
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1228
|
+
end},
|
|
1229
|
+
true
|
|
1230
|
+
)
|
|
1197
1231
|
__TS__SetDescriptor(
|
|
1198
1232
|
Unit.prototype,
|
|
1199
1233
|
"combatClassifications",
|
|
@@ -1267,6 +1301,19 @@ __TS__SetDescriptor(
|
|
|
1267
1301
|
},
|
|
1268
1302
|
true
|
|
1269
1303
|
)
|
|
1304
|
+
__TS__SetDescriptor(
|
|
1305
|
+
Unit.prototype,
|
|
1306
|
+
"primaryAttribute",
|
|
1307
|
+
{
|
|
1308
|
+
get = function(self)
|
|
1309
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1310
|
+
end,
|
|
1311
|
+
set = function(self, primaryAttribute)
|
|
1312
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1313
|
+
end
|
|
1314
|
+
},
|
|
1315
|
+
true
|
|
1316
|
+
)
|
|
1270
1317
|
__TS__SetDescriptor(
|
|
1271
1318
|
Unit.prototype,
|
|
1272
1319
|
"strengthBase",
|
|
@@ -1388,17 +1435,17 @@ __TS__SetDescriptor(
|
|
|
1388
1435
|
"isTeamGlowVisible",
|
|
1389
1436
|
{
|
|
1390
1437
|
get = function(self)
|
|
1391
|
-
return not self[
|
|
1438
|
+
return not self[106]
|
|
1392
1439
|
end,
|
|
1393
1440
|
set = function(self, isTeamGlowVisible)
|
|
1394
|
-
|
|
1395
|
-
local
|
|
1441
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1442
|
+
local ____temp_6
|
|
1396
1443
|
if not isTeamGlowVisible then
|
|
1397
|
-
|
|
1444
|
+
____temp_6 = true
|
|
1398
1445
|
else
|
|
1399
|
-
|
|
1446
|
+
____temp_6 = nil
|
|
1400
1447
|
end
|
|
1401
|
-
self[
|
|
1448
|
+
self[106] = ____temp_6
|
|
1402
1449
|
end
|
|
1403
1450
|
},
|
|
1404
1451
|
true
|
|
@@ -1407,9 +1454,9 @@ __TS__SetDescriptor(
|
|
|
1407
1454
|
Unit.prototype,
|
|
1408
1455
|
"color",
|
|
1409
1456
|
{set = function(self, color)
|
|
1410
|
-
|
|
1411
|
-
if self[
|
|
1412
|
-
|
|
1457
|
+
SetUnitColor(self.handle, color.handle)
|
|
1458
|
+
if self[106] then
|
|
1459
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1413
1460
|
end
|
|
1414
1461
|
end},
|
|
1415
1462
|
true
|
|
@@ -1432,14 +1479,14 @@ __TS__SetDescriptor(
|
|
|
1432
1479
|
"maxHealth",
|
|
1433
1480
|
{
|
|
1434
1481
|
get = function(self)
|
|
1435
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1482
|
+
return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
|
|
1436
1483
|
end,
|
|
1437
1484
|
set = function(self, maxHealth)
|
|
1438
|
-
if maxHealth < 1 and self[
|
|
1439
|
-
self[
|
|
1485
|
+
if maxHealth < 1 and self[103] ~= nil then
|
|
1486
|
+
self[104] = (self[104] or 0) + (1 - maxHealth)
|
|
1440
1487
|
maxHealth = 1
|
|
1441
1488
|
end
|
|
1442
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1489
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
|
|
1443
1490
|
end
|
|
1444
1491
|
},
|
|
1445
1492
|
true
|
|
@@ -1481,10 +1528,10 @@ __TS__SetDescriptor(
|
|
|
1481
1528
|
"health",
|
|
1482
1529
|
{
|
|
1483
1530
|
get = function(self)
|
|
1484
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1531
|
+
return GetWidgetLife(self.handle) - (self[105] or 0)
|
|
1485
1532
|
end,
|
|
1486
1533
|
set = function(self, health)
|
|
1487
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1534
|
+
SetWidgetLife(self.handle, health + (self[105] or 0))
|
|
1488
1535
|
end
|
|
1489
1536
|
},
|
|
1490
1537
|
true
|
|
@@ -1578,7 +1625,7 @@ __TS__SetDescriptor(
|
|
|
1578
1625
|
"x",
|
|
1579
1626
|
{
|
|
1580
1627
|
get = function(self)
|
|
1581
|
-
return getUnitX(self.handle)
|
|
1628
|
+
return self[107] or getUnitX(self.handle)
|
|
1582
1629
|
end,
|
|
1583
1630
|
set = function(self, v)
|
|
1584
1631
|
SetUnitX(self.handle, v)
|
|
@@ -1591,7 +1638,7 @@ __TS__SetDescriptor(
|
|
|
1591
1638
|
"y",
|
|
1592
1639
|
{
|
|
1593
1640
|
get = function(self)
|
|
1594
|
-
return getUnitY(self.handle)
|
|
1641
|
+
return self[108] or getUnitY(self.handle)
|
|
1595
1642
|
end,
|
|
1596
1643
|
set = function(self, v)
|
|
1597
1644
|
SetUnitY(self.handle, v)
|
|
@@ -1677,10 +1724,10 @@ __TS__SetDescriptor(
|
|
|
1677
1724
|
"gold",
|
|
1678
1725
|
{
|
|
1679
1726
|
get = function(self)
|
|
1680
|
-
return
|
|
1727
|
+
return GetResourceAmount(self.handle)
|
|
1681
1728
|
end,
|
|
1682
1729
|
set = function(self, gold)
|
|
1683
|
-
|
|
1730
|
+
SetResourceAmount(self.handle, gold)
|
|
1684
1731
|
end
|
|
1685
1732
|
},
|
|
1686
1733
|
true
|
|
@@ -1695,17 +1742,17 @@ __TS__SetDescriptor(
|
|
|
1695
1742
|
set = function(self, isPaused)
|
|
1696
1743
|
local handle = self.handle
|
|
1697
1744
|
if isPaused and not IsUnitPaused(handle) then
|
|
1698
|
-
self[
|
|
1699
|
-
for _ = self[
|
|
1745
|
+
self[101] = true
|
|
1746
|
+
for _ = self[102] or 0, -1 do
|
|
1700
1747
|
BlzPauseUnitEx(handle, true)
|
|
1701
1748
|
end
|
|
1702
1749
|
PauseUnit(handle, true)
|
|
1703
1750
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1704
1751
|
PauseUnit(handle, false)
|
|
1705
|
-
for _ = self[
|
|
1752
|
+
for _ = self[102] or 0, -1 do
|
|
1706
1753
|
BlzPauseUnitEx(handle, false)
|
|
1707
1754
|
end
|
|
1708
|
-
self[
|
|
1755
|
+
self[101] = nil
|
|
1709
1756
|
end
|
|
1710
1757
|
end
|
|
1711
1758
|
},
|
|
@@ -1808,6 +1855,19 @@ __TS__SetDescriptor(
|
|
|
1808
1855
|
end},
|
|
1809
1856
|
true
|
|
1810
1857
|
)
|
|
1858
|
+
__TS__SetDescriptor(
|
|
1859
|
+
Unit.prototype,
|
|
1860
|
+
"movementType",
|
|
1861
|
+
{
|
|
1862
|
+
get = function(self)
|
|
1863
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1864
|
+
end,
|
|
1865
|
+
set = function(self, movementType)
|
|
1866
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1867
|
+
end
|
|
1868
|
+
},
|
|
1869
|
+
true
|
|
1870
|
+
)
|
|
1811
1871
|
__TS__SetDescriptor(
|
|
1812
1872
|
Unit.prototype,
|
|
1813
1873
|
"pathing",
|
|
@@ -2124,25 +2184,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2124
2184
|
InitializingEvent,
|
|
2125
2185
|
function(event)
|
|
2126
2186
|
local function listener(unit, id)
|
|
2127
|
-
local
|
|
2187
|
+
local ____GetSpellTargetUnit_result_9
|
|
2128
2188
|
if GetSpellTargetUnit() then
|
|
2129
|
-
|
|
2189
|
+
____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2130
2190
|
else
|
|
2131
|
-
local
|
|
2191
|
+
local ____GetSpellTargetItem_result_8
|
|
2132
2192
|
if GetSpellTargetItem() then
|
|
2133
|
-
|
|
2193
|
+
____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
|
|
2134
2194
|
else
|
|
2135
|
-
local
|
|
2195
|
+
local ____GetSpellTargetDestructable_result_7
|
|
2136
2196
|
if GetSpellTargetDestructable() then
|
|
2137
|
-
|
|
2197
|
+
____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
|
|
2138
2198
|
else
|
|
2139
|
-
|
|
2199
|
+
____GetSpellTargetDestructable_result_7 = nil
|
|
2140
2200
|
end
|
|
2141
|
-
|
|
2201
|
+
____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
|
|
2142
2202
|
end
|
|
2143
|
-
|
|
2203
|
+
____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
|
|
2144
2204
|
end
|
|
2145
|
-
local target =
|
|
2205
|
+
local target = ____GetSpellTargetUnit_result_9
|
|
2146
2206
|
if target then
|
|
2147
2207
|
invoke(event, unit, id, target)
|
|
2148
2208
|
end
|
|
@@ -2314,10 +2374,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2314
2374
|
____exports.UnitTriggerEvent,
|
|
2315
2375
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2316
2376
|
function()
|
|
2317
|
-
local
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2377
|
+
local handle = getOrderedUnit()
|
|
2378
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2379
|
+
local unit = ____exports.Unit:of(handle)
|
|
2380
|
+
if unit.state == 1 then
|
|
2381
|
+
return unit, getIssuedOrderId()
|
|
2382
|
+
end
|
|
2321
2383
|
end
|
|
2322
2384
|
return IgnoreEvent
|
|
2323
2385
|
end
|
|
@@ -2348,13 +2410,18 @@ Unit.onDamaging = (function()
|
|
|
2348
2410
|
if source and source.typeId == dummyUnitId then
|
|
2349
2411
|
source = nil
|
|
2350
2412
|
end
|
|
2351
|
-
local target = BlzGetEventDamageTarget()
|
|
2413
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2414
|
+
local metadata = damageMetadataByTarget[target]
|
|
2415
|
+
damageMetadataByTarget[target] = nil
|
|
2352
2416
|
local data = {
|
|
2353
2417
|
amount = GetEventDamage(),
|
|
2354
|
-
attackType = BlzGetEventAttackType(),
|
|
2418
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2355
2419
|
damageType = BlzGetEventDamageType(),
|
|
2356
2420
|
weaponType = BlzGetEventWeaponType(),
|
|
2357
|
-
|
|
2421
|
+
metadata = metadata,
|
|
2422
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2423
|
+
originalAmount = GetEventDamage(),
|
|
2424
|
+
originalMetadata = metadata
|
|
2358
2425
|
}
|
|
2359
2426
|
if data.isAttack and source then
|
|
2360
2427
|
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
|
|
@@ -2368,18 +2435,22 @@ Unit.onDamaging = (function()
|
|
|
2368
2435
|
invoke(
|
|
2369
2436
|
event,
|
|
2370
2437
|
source,
|
|
2371
|
-
|
|
2438
|
+
target,
|
|
2372
2439
|
setmetatable(
|
|
2373
2440
|
{},
|
|
2374
2441
|
{
|
|
2375
2442
|
__index = data,
|
|
2376
2443
|
__newindex = function(self, key, value)
|
|
2377
|
-
damageSetters[key]
|
|
2444
|
+
local damageSetter = damageSetters[key]
|
|
2445
|
+
if damageSetter ~= nil then
|
|
2446
|
+
damageSetter(value)
|
|
2447
|
+
end
|
|
2378
2448
|
data[key] = value
|
|
2379
2449
|
end
|
|
2380
2450
|
}
|
|
2381
2451
|
)
|
|
2382
2452
|
)
|
|
2453
|
+
damagingEventByTarget[target] = data
|
|
2383
2454
|
return
|
|
2384
2455
|
end
|
|
2385
2456
|
BlzSetEventDamage(0)
|
|
@@ -2387,7 +2458,7 @@ Unit.onDamaging = (function()
|
|
|
2387
2458
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2388
2459
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2389
2460
|
local sourceOwner = source.owner.handle
|
|
2390
|
-
local targetOwner =
|
|
2461
|
+
local targetOwner = target.owner.handle
|
|
2391
2462
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2392
2463
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2393
2464
|
Timer:run(function()
|
|
@@ -2403,23 +2474,19 @@ Unit.onDamaging = (function()
|
|
|
2403
2474
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2404
2475
|
local condition = ____value[1]
|
|
2405
2476
|
local action = ____value[2]
|
|
2406
|
-
if condition(
|
|
2407
|
-
source,
|
|
2408
|
-
____exports.Unit:of(target),
|
|
2409
|
-
data
|
|
2410
|
-
) then
|
|
2477
|
+
if condition(source, target, data) then
|
|
2411
2478
|
action(
|
|
2412
2479
|
source,
|
|
2413
|
-
|
|
2480
|
+
target,
|
|
2414
2481
|
setmetatable(
|
|
2415
2482
|
{fire = function()
|
|
2416
2483
|
UnitDamageTarget(
|
|
2417
2484
|
source.handle,
|
|
2418
|
-
target,
|
|
2485
|
+
target.handle,
|
|
2419
2486
|
data.amount,
|
|
2420
2487
|
true,
|
|
2421
2488
|
true,
|
|
2422
|
-
data.attackType,
|
|
2489
|
+
attackTypeToNative(data.attackType),
|
|
2423
2490
|
data.damageType,
|
|
2424
2491
|
data.weaponType
|
|
2425
2492
|
)
|
|
@@ -2446,29 +2513,44 @@ Unit.onDamage = __TS__New(
|
|
|
2446
2513
|
if source and source.typeId == dummyUnitId then
|
|
2447
2514
|
source = nil
|
|
2448
2515
|
end
|
|
2516
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2517
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2518
|
+
damagingEventByTarget[target] = nil
|
|
2449
2519
|
local data = {
|
|
2450
2520
|
amount = GetEventDamage(),
|
|
2451
|
-
attackType = BlzGetEventAttackType(),
|
|
2521
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2452
2522
|
damageType = BlzGetEventDamageType(),
|
|
2453
2523
|
weaponType = BlzGetEventWeaponType(),
|
|
2524
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2454
2525
|
isAttack = BlzGetEventIsAttack(),
|
|
2526
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2527
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2455
2528
|
preventDeath = damageEventPreventDeath
|
|
2456
2529
|
}
|
|
2530
|
+
if damagingEvent then
|
|
2531
|
+
for key, value in pairs(damagingEvent) do
|
|
2532
|
+
if isAttribute(key) then
|
|
2533
|
+
data[key] = value
|
|
2534
|
+
end
|
|
2535
|
+
end
|
|
2536
|
+
end
|
|
2457
2537
|
local evData = setmetatable(
|
|
2458
2538
|
{},
|
|
2459
2539
|
{
|
|
2460
2540
|
__index = data,
|
|
2461
2541
|
__newindex = function(self, key, value)
|
|
2462
|
-
damageSetters[key]
|
|
2542
|
+
local damageSetter = damageSetters[key]
|
|
2543
|
+
if damageSetter ~= nil then
|
|
2544
|
+
damageSetter(value)
|
|
2545
|
+
end
|
|
2463
2546
|
data[key] = value
|
|
2464
2547
|
end
|
|
2465
2548
|
}
|
|
2466
2549
|
)
|
|
2467
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2468
2550
|
invoke(event, source, target, evData)
|
|
2469
2551
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2470
2552
|
local bonusHealth = math.ceil(evData.amount)
|
|
2471
|
-
target[
|
|
2553
|
+
target[105] = (target[105] or 0) + bonusHealth
|
|
2472
2554
|
BlzSetUnitMaxHP(
|
|
2473
2555
|
target.handle,
|
|
2474
2556
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2482,7 +2564,7 @@ Unit.onDamage = __TS__New(
|
|
|
2482
2564
|
evData[0],
|
|
2483
2565
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2484
2566
|
)
|
|
2485
|
-
target[
|
|
2567
|
+
target[105] = (target[105] or 0) - bonusHealth
|
|
2486
2568
|
SetWidgetLife(
|
|
2487
2569
|
target.handle,
|
|
2488
2570
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2502,32 +2584,91 @@ Unit.onDamage = __TS__New(
|
|
|
2502
2584
|
DestroyTrigger(trigger)
|
|
2503
2585
|
end
|
|
2504
2586
|
)
|
|
2505
|
-
Unit.
|
|
2587
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2506
2588
|
____exports.UnitTriggerEvent,
|
|
2507
2589
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2508
2590
|
function()
|
|
2509
2591
|
local unit = getTriggerUnit()
|
|
2510
|
-
|
|
2511
|
-
|
|
2592
|
+
local item = getManipulatedItem()
|
|
2593
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2594
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2512
2595
|
end
|
|
2513
2596
|
return IgnoreEvent
|
|
2514
2597
|
end
|
|
2515
2598
|
)
|
|
2516
|
-
Unit.
|
|
2599
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2517
2600
|
____exports.UnitTriggerEvent,
|
|
2518
2601
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2519
2602
|
function()
|
|
2520
2603
|
local unit = getTriggerUnit()
|
|
2521
|
-
|
|
2522
|
-
|
|
2604
|
+
local item = getManipulatedItem()
|
|
2605
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2606
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2523
2607
|
end
|
|
2524
2608
|
return IgnoreEvent
|
|
2525
2609
|
end
|
|
2526
2610
|
)
|
|
2527
|
-
Unit.
|
|
2611
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2528
2612
|
____exports.UnitTriggerEvent,
|
|
2529
2613
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2530
|
-
function()
|
|
2614
|
+
function()
|
|
2615
|
+
local unit = getTriggerUnit()
|
|
2616
|
+
local item = getManipulatedItem()
|
|
2617
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2618
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2619
|
+
end
|
|
2620
|
+
return IgnoreEvent
|
|
2621
|
+
end
|
|
2622
|
+
)
|
|
2623
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2624
|
+
____exports.UnitTriggerEvent,
|
|
2625
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2626
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2627
|
+
)
|
|
2628
|
+
__TS__ObjectDefineProperty(
|
|
2629
|
+
Unit,
|
|
2630
|
+
"itemUseOrderEvent",
|
|
2631
|
+
{get = function(self)
|
|
2632
|
+
local event = __TS__New(Event)
|
|
2633
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2634
|
+
local slot = order - orderId("useslot0")
|
|
2635
|
+
local function listener(unit)
|
|
2636
|
+
local item = unit.items[slot + 1]
|
|
2637
|
+
if item ~= nil then
|
|
2638
|
+
invoke(event, unit, item)
|
|
2639
|
+
end
|
|
2640
|
+
end
|
|
2641
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2642
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2643
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2644
|
+
end
|
|
2645
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2646
|
+
return event
|
|
2647
|
+
end}
|
|
2648
|
+
)
|
|
2649
|
+
__TS__ObjectDefineProperty(
|
|
2650
|
+
Unit,
|
|
2651
|
+
"itemMoveOrderEvent",
|
|
2652
|
+
{get = function(self)
|
|
2653
|
+
local event = __TS__New(Event)
|
|
2654
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2655
|
+
local slotTo = order - orderId("moveslot0")
|
|
2656
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2657
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2658
|
+
if slotFrom ~= nil then
|
|
2659
|
+
invoke(
|
|
2660
|
+
event,
|
|
2661
|
+
unit,
|
|
2662
|
+
item,
|
|
2663
|
+
slotFrom,
|
|
2664
|
+
slotTo
|
|
2665
|
+
)
|
|
2666
|
+
end
|
|
2667
|
+
end)
|
|
2668
|
+
end
|
|
2669
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2670
|
+
return event
|
|
2671
|
+
end}
|
|
2531
2672
|
)
|
|
2532
2673
|
__TS__ObjectDefineProperty(
|
|
2533
2674
|
Unit,
|