warscript 0.0.1-dev.240d8a6 → 0.0.1-dev.26f0c5f
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 +14 -6
- package/core/types/effect.lua +131 -35
- 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.d.ts +1 -1
- package/core/util.lua +12 -1
- package/decl/native.d.ts +840 -786
- 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 +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.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +42 -0
- 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 -47
- 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 +63 -42
- package/engine/buff.lua +318 -234
- package/engine/internal/ability.d.ts +17 -2
- package/engine/internal/ability.lua +94 -4
- package/engine/internal/item/ability.lua +161 -4
- 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/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 +45 -1
- package/engine/internal/unit/ability.lua +98 -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/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/bonus.d.ts +2 -0
- package/engine/internal/unit/bonus.lua +17 -0
- 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 +1 -1
- package/engine/internal/unit/item.lua +6 -12
- package/engine/internal/unit/main-selected.d.ts +6 -0
- package/engine/internal/unit/main-selected.lua +12 -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 +33 -8
- package/engine/internal/unit.lua +316 -109
- package/engine/internal/utility.lua +12 -0
- package/engine/lightning.d.ts +12 -5
- package/engine/lightning.lua +48 -14
- 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/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 +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 +3 -1
- package/engine/object-data/entry/item-type.lua +15 -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 +10 -4
- package/engine/object-field/ability.lua +3 -0
- package/engine/object-field/unit.d.ts +50 -3
- package/engine/object-field/unit.lua +186 -7
- package/engine/object-field.d.ts +17 -6
- package/engine/object-field.lua +187 -89
- 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/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 +2 -0
- package/engine/unit.lua +2 -0
- package/objutil/buff.lua +1 -2
- package/objutil/unit.lua +8 -0
- package/package.json +2 -2
- 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 +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
|
@@ -51,12 +51,21 @@ 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
|
|
63
|
+
local ____ability = require("engine.internal.item.ability")
|
|
64
|
+
local doUnitAbilityAction = ____ability.doUnitAbilityAction
|
|
54
65
|
local match = string.match
|
|
55
66
|
local ____tostring = _G.tostring
|
|
56
67
|
local setUnitAnimation = SetUnitAnimation
|
|
57
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
58
68
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
59
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
60
69
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
61
70
|
local getUnitRealField = BlzGetUnitRealField
|
|
62
71
|
local getHeroStr = GetHeroStr
|
|
@@ -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
|
|
@@ -136,6 +141,7 @@ do
|
|
|
136
141
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
137
142
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
138
143
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
144
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
139
145
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
140
146
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
141
147
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -343,6 +349,9 @@ local function dispatchAbility(event)
|
|
|
343
349
|
}
|
|
344
350
|
)
|
|
345
351
|
end
|
|
352
|
+
local function damagingEventPreventRetaliation(self)
|
|
353
|
+
self[0] = true
|
|
354
|
+
end
|
|
346
355
|
local function damageEventPreventDeath(self, callback, ...)
|
|
347
356
|
if self[0] ~= nil then
|
|
348
357
|
return
|
|
@@ -354,7 +363,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
354
363
|
rawset(self, 1 + i, (select(i, ...)))
|
|
355
364
|
end
|
|
356
365
|
end
|
|
357
|
-
local damageSetters = {
|
|
366
|
+
local damageSetters = {
|
|
367
|
+
amount = BlzSetEventDamage,
|
|
368
|
+
attackType = function(attackType)
|
|
369
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
370
|
+
end,
|
|
371
|
+
damageType = BlzSetEventDamageType,
|
|
372
|
+
weaponType = BlzSetEventWeaponType
|
|
373
|
+
}
|
|
358
374
|
local jlimitopByOperator = {
|
|
359
375
|
[0] = LESS_THAN_OR_EQUAL,
|
|
360
376
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -432,6 +448,19 @@ __TS__SetDescriptor(
|
|
|
432
448
|
},
|
|
433
449
|
true
|
|
434
450
|
)
|
|
451
|
+
__TS__SetDescriptor(
|
|
452
|
+
UnitWeapon.prototype,
|
|
453
|
+
"allowedTargetCombatClassifications",
|
|
454
|
+
{
|
|
455
|
+
get = function(self)
|
|
456
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
457
|
+
end,
|
|
458
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
459
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
460
|
+
end
|
|
461
|
+
},
|
|
462
|
+
true
|
|
463
|
+
)
|
|
435
464
|
__TS__SetDescriptor(
|
|
436
465
|
UnitWeapon.prototype,
|
|
437
466
|
"damageBase",
|
|
@@ -562,17 +591,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
562
591
|
____exports.Unit:of(unit)
|
|
563
592
|
)
|
|
564
593
|
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
594
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
577
595
|
local item = unitItemInSlot(unit, i)
|
|
578
596
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -647,7 +665,43 @@ local function delayHealthChecksCallback(unit)
|
|
|
647
665
|
end
|
|
648
666
|
end
|
|
649
667
|
local nextSyncId = 1
|
|
650
|
-
local unitBySyncId = setmetatable({}, {__mode = "
|
|
668
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
669
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
670
|
+
local function addAbility(unit, abilityTypeId)
|
|
671
|
+
local handle = unit.handle
|
|
672
|
+
if unitAddAbility(handle, abilityTypeId) then
|
|
673
|
+
local ability = UnitAbility:of(
|
|
674
|
+
checkNotNull(getUnitAbility(handle, abilityTypeId)),
|
|
675
|
+
abilityTypeId,
|
|
676
|
+
unit
|
|
677
|
+
)
|
|
678
|
+
local abilities = unit.abilities
|
|
679
|
+
abilities[#abilities + 1] = ability
|
|
680
|
+
return ability
|
|
681
|
+
end
|
|
682
|
+
return nil
|
|
683
|
+
end
|
|
684
|
+
local function getAbility(unit, abilityTypeId)
|
|
685
|
+
return UnitAbility:of(
|
|
686
|
+
getUnitAbility(unit.handle, abilityTypeId),
|
|
687
|
+
abilityTypeId,
|
|
688
|
+
unit
|
|
689
|
+
)
|
|
690
|
+
end
|
|
691
|
+
local function removeAbility(unit, abilityTypeId)
|
|
692
|
+
if unitRemoveAbility(unit.handle, abilityTypeId) then
|
|
693
|
+
local abilities = unit.abilities
|
|
694
|
+
for i = 1, #abilities do
|
|
695
|
+
if abilities[i].typeId == abilityTypeId then
|
|
696
|
+
abilities[i]:destroy()
|
|
697
|
+
tremove(abilities, i)
|
|
698
|
+
return true
|
|
699
|
+
end
|
|
700
|
+
end
|
|
701
|
+
return true
|
|
702
|
+
end
|
|
703
|
+
return false
|
|
704
|
+
end
|
|
651
705
|
____exports.Unit = __TS__Class()
|
|
652
706
|
local Unit = ____exports.Unit
|
|
653
707
|
Unit.name = "Unit"
|
|
@@ -688,6 +742,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
688
742
|
end
|
|
689
743
|
function Unit.prototype.onDestroy(self)
|
|
690
744
|
local handle = self.handle
|
|
745
|
+
self[107] = getUnitX(handle)
|
|
746
|
+
self[108] = getUnitY(handle)
|
|
691
747
|
if not self._owner then
|
|
692
748
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
693
749
|
end
|
|
@@ -798,13 +854,25 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
798
854
|
if type(animation) == "number" then
|
|
799
855
|
setUnitAnimationByIndex(self.handle, animation)
|
|
800
856
|
elseif rarity then
|
|
801
|
-
|
|
857
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
802
858
|
else
|
|
803
859
|
setUnitAnimation(self.handle, animation)
|
|
804
860
|
end
|
|
805
861
|
end
|
|
862
|
+
function Unit.prototype.resetAnimation(self)
|
|
863
|
+
ResetUnitAnimation(self.handle)
|
|
864
|
+
end
|
|
806
865
|
function Unit.prototype.queueAnimation(self, animation)
|
|
807
|
-
|
|
866
|
+
QueueUnitAnimation(self.handle, animation)
|
|
867
|
+
end
|
|
868
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
869
|
+
if target:isAllowedTarget(self, self.firstWeapon.allowedTargetCombatClassifications) then
|
|
870
|
+
return self.firstWeapon
|
|
871
|
+
end
|
|
872
|
+
if target:isAllowedTarget(target, self.secondWeapon.allowedTargetCombatClassifications) then
|
|
873
|
+
return self.secondWeapon
|
|
874
|
+
end
|
|
875
|
+
return nil
|
|
808
876
|
end
|
|
809
877
|
function Unit.prototype.delayHealthChecks(self)
|
|
810
878
|
self[103] = (self[103] or 0) + 1
|
|
@@ -817,7 +885,7 @@ function Unit.prototype.isSelected(self, player)
|
|
|
817
885
|
return IsUnitSelected(self.handle, player.handle)
|
|
818
886
|
end
|
|
819
887
|
function Unit.prototype.explode(self)
|
|
820
|
-
|
|
888
|
+
SetUnitExploded(self.handle, true)
|
|
821
889
|
killUnit(self.handle)
|
|
822
890
|
end
|
|
823
891
|
function Unit.prototype.kill(self)
|
|
@@ -874,17 +942,13 @@ function Unit.prototype.itemInSlot(self, slot)
|
|
|
874
942
|
return Item:of(unitItemInSlot(self.handle, slot))
|
|
875
943
|
end
|
|
876
944
|
function Unit.prototype.addAbility(self, abilityId)
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
abilities[#abilities + 1] = ability
|
|
885
|
-
return ability
|
|
886
|
-
end
|
|
887
|
-
return nil
|
|
945
|
+
return doUnitAbilityAction(
|
|
946
|
+
self.handle,
|
|
947
|
+
abilityId,
|
|
948
|
+
addAbility,
|
|
949
|
+
self,
|
|
950
|
+
abilityId
|
|
951
|
+
)
|
|
888
952
|
end
|
|
889
953
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
890
954
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -899,30 +963,22 @@ function Unit.prototype.hasAbility(self, abilityId)
|
|
|
899
963
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
900
964
|
end
|
|
901
965
|
function Unit.prototype.getAbilityById(self, abilityId)
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
905
|
-
return nil
|
|
906
|
-
end
|
|
907
|
-
return UnitAbility:of(
|
|
908
|
-
getUnitAbility(self.handle, abilityId),
|
|
966
|
+
return doUnitAbilityAction(
|
|
967
|
+
self.handle,
|
|
909
968
|
abilityId,
|
|
910
|
-
|
|
969
|
+
getAbility,
|
|
970
|
+
self,
|
|
971
|
+
abilityId
|
|
911
972
|
)
|
|
912
973
|
end
|
|
913
974
|
function Unit.prototype.removeAbility(self, abilityId)
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
end
|
|
922
|
-
end
|
|
923
|
-
return true
|
|
924
|
-
end
|
|
925
|
-
return false
|
|
975
|
+
return doUnitAbilityAction(
|
|
976
|
+
self.handle,
|
|
977
|
+
abilityId,
|
|
978
|
+
removeAbility,
|
|
979
|
+
self,
|
|
980
|
+
abilityId
|
|
981
|
+
)
|
|
926
982
|
end
|
|
927
983
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
928
984
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -936,12 +992,34 @@ end
|
|
|
936
992
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
937
993
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
938
994
|
end
|
|
995
|
+
function Unit.prototype.interruptMovement(self)
|
|
996
|
+
local handle = self.handle
|
|
997
|
+
unitDisableAbility(
|
|
998
|
+
handle,
|
|
999
|
+
fourCC("Amov"),
|
|
1000
|
+
true,
|
|
1001
|
+
false
|
|
1002
|
+
)
|
|
1003
|
+
unitDisableAbility(
|
|
1004
|
+
handle,
|
|
1005
|
+
fourCC("Amov"),
|
|
1006
|
+
false,
|
|
1007
|
+
false
|
|
1008
|
+
)
|
|
1009
|
+
end
|
|
939
1010
|
function Unit.prototype.interruptAttack(self)
|
|
940
1011
|
unitInterruptAttack(self.handle)
|
|
941
1012
|
end
|
|
942
1013
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
943
|
-
|
|
944
|
-
unitDisableAbility(
|
|
1014
|
+
local handle = self.handle
|
|
1015
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
1016
|
+
Timer:run(
|
|
1017
|
+
unitDisableAbility,
|
|
1018
|
+
handle,
|
|
1019
|
+
abilityId,
|
|
1020
|
+
false,
|
|
1021
|
+
false
|
|
1022
|
+
)
|
|
945
1023
|
end
|
|
946
1024
|
function Unit.prototype.getDistanceTo(self, target)
|
|
947
1025
|
local handle = self.handle
|
|
@@ -1206,6 +1284,14 @@ __TS__SetDescriptor(
|
|
|
1206
1284
|
end},
|
|
1207
1285
|
true
|
|
1208
1286
|
)
|
|
1287
|
+
__TS__SetDescriptor(
|
|
1288
|
+
Unit.prototype,
|
|
1289
|
+
"isStunned",
|
|
1290
|
+
{get = function(self)
|
|
1291
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1292
|
+
end},
|
|
1293
|
+
true
|
|
1294
|
+
)
|
|
1209
1295
|
__TS__SetDescriptor(
|
|
1210
1296
|
Unit.prototype,
|
|
1211
1297
|
"combatClassifications",
|
|
@@ -1279,6 +1365,19 @@ __TS__SetDescriptor(
|
|
|
1279
1365
|
},
|
|
1280
1366
|
true
|
|
1281
1367
|
)
|
|
1368
|
+
__TS__SetDescriptor(
|
|
1369
|
+
Unit.prototype,
|
|
1370
|
+
"primaryAttribute",
|
|
1371
|
+
{
|
|
1372
|
+
get = function(self)
|
|
1373
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1374
|
+
end,
|
|
1375
|
+
set = function(self, primaryAttribute)
|
|
1376
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1377
|
+
end
|
|
1378
|
+
},
|
|
1379
|
+
true
|
|
1380
|
+
)
|
|
1282
1381
|
__TS__SetDescriptor(
|
|
1283
1382
|
Unit.prototype,
|
|
1284
1383
|
"strengthBase",
|
|
@@ -1403,7 +1502,7 @@ __TS__SetDescriptor(
|
|
|
1403
1502
|
return not self[106]
|
|
1404
1503
|
end,
|
|
1405
1504
|
set = function(self, isTeamGlowVisible)
|
|
1406
|
-
|
|
1505
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1407
1506
|
local ____temp_6
|
|
1408
1507
|
if not isTeamGlowVisible then
|
|
1409
1508
|
____temp_6 = true
|
|
@@ -1419,9 +1518,9 @@ __TS__SetDescriptor(
|
|
|
1419
1518
|
Unit.prototype,
|
|
1420
1519
|
"color",
|
|
1421
1520
|
{set = function(self, color)
|
|
1422
|
-
|
|
1521
|
+
SetUnitColor(self.handle, color.handle)
|
|
1423
1522
|
if self[106] then
|
|
1424
|
-
|
|
1523
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1425
1524
|
end
|
|
1426
1525
|
end},
|
|
1427
1526
|
true
|
|
@@ -1590,7 +1689,7 @@ __TS__SetDescriptor(
|
|
|
1590
1689
|
"x",
|
|
1591
1690
|
{
|
|
1592
1691
|
get = function(self)
|
|
1593
|
-
return getUnitX(self.handle)
|
|
1692
|
+
return self[107] or getUnitX(self.handle)
|
|
1594
1693
|
end,
|
|
1595
1694
|
set = function(self, v)
|
|
1596
1695
|
SetUnitX(self.handle, v)
|
|
@@ -1603,7 +1702,7 @@ __TS__SetDescriptor(
|
|
|
1603
1702
|
"y",
|
|
1604
1703
|
{
|
|
1605
1704
|
get = function(self)
|
|
1606
|
-
return getUnitY(self.handle)
|
|
1705
|
+
return self[108] or getUnitY(self.handle)
|
|
1607
1706
|
end,
|
|
1608
1707
|
set = function(self, v)
|
|
1609
1708
|
SetUnitY(self.handle, v)
|
|
@@ -1689,10 +1788,10 @@ __TS__SetDescriptor(
|
|
|
1689
1788
|
"gold",
|
|
1690
1789
|
{
|
|
1691
1790
|
get = function(self)
|
|
1692
|
-
return
|
|
1791
|
+
return GetResourceAmount(self.handle)
|
|
1693
1792
|
end,
|
|
1694
1793
|
set = function(self, gold)
|
|
1695
|
-
|
|
1794
|
+
SetResourceAmount(self.handle, gold)
|
|
1696
1795
|
end
|
|
1697
1796
|
},
|
|
1698
1797
|
true
|
|
@@ -1820,6 +1919,19 @@ __TS__SetDescriptor(
|
|
|
1820
1919
|
end},
|
|
1821
1920
|
true
|
|
1822
1921
|
)
|
|
1922
|
+
__TS__SetDescriptor(
|
|
1923
|
+
Unit.prototype,
|
|
1924
|
+
"movementType",
|
|
1925
|
+
{
|
|
1926
|
+
get = function(self)
|
|
1927
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1928
|
+
end,
|
|
1929
|
+
set = function(self, movementType)
|
|
1930
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1931
|
+
end
|
|
1932
|
+
},
|
|
1933
|
+
true
|
|
1934
|
+
)
|
|
1823
1935
|
__TS__SetDescriptor(
|
|
1824
1936
|
Unit.prototype,
|
|
1825
1937
|
"pathing",
|
|
@@ -2001,6 +2113,14 @@ __TS__SetDescriptor(
|
|
|
2001
2113
|
end},
|
|
2002
2114
|
true
|
|
2003
2115
|
)
|
|
2116
|
+
__TS__SetDescriptor(
|
|
2117
|
+
Unit.prototype,
|
|
2118
|
+
"targetAcquiredEvent",
|
|
2119
|
+
{get = function(self)
|
|
2120
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2121
|
+
end},
|
|
2122
|
+
true
|
|
2123
|
+
)
|
|
2004
2124
|
__TS__SetDescriptor(
|
|
2005
2125
|
Unit.prototype,
|
|
2006
2126
|
"onSelect",
|
|
@@ -2326,10 +2446,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2326
2446
|
____exports.UnitTriggerEvent,
|
|
2327
2447
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2328
2448
|
function()
|
|
2329
|
-
local
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2449
|
+
local handle = getOrderedUnit()
|
|
2450
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2451
|
+
local unit = ____exports.Unit:of(handle)
|
|
2452
|
+
if unit.state == 1 then
|
|
2453
|
+
return unit, getIssuedOrderId()
|
|
2454
|
+
end
|
|
2333
2455
|
end
|
|
2334
2456
|
return IgnoreEvent
|
|
2335
2457
|
end
|
|
@@ -2360,13 +2482,19 @@ Unit.onDamaging = (function()
|
|
|
2360
2482
|
if source and source.typeId == dummyUnitId then
|
|
2361
2483
|
source = nil
|
|
2362
2484
|
end
|
|
2363
|
-
local target = BlzGetEventDamageTarget()
|
|
2485
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2486
|
+
local metadata = damageMetadataByTarget[target]
|
|
2487
|
+
damageMetadataByTarget[target] = nil
|
|
2364
2488
|
local data = {
|
|
2365
2489
|
amount = GetEventDamage(),
|
|
2366
|
-
attackType = BlzGetEventAttackType(),
|
|
2490
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2367
2491
|
damageType = BlzGetEventDamageType(),
|
|
2368
2492
|
weaponType = BlzGetEventWeaponType(),
|
|
2369
|
-
|
|
2493
|
+
metadata = metadata,
|
|
2494
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2495
|
+
originalAmount = GetEventDamage(),
|
|
2496
|
+
originalMetadata = metadata,
|
|
2497
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2370
2498
|
}
|
|
2371
2499
|
if data.isAttack and source then
|
|
2372
2500
|
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
|
|
@@ -2380,18 +2508,36 @@ Unit.onDamaging = (function()
|
|
|
2380
2508
|
invoke(
|
|
2381
2509
|
event,
|
|
2382
2510
|
source,
|
|
2383
|
-
|
|
2511
|
+
target,
|
|
2384
2512
|
setmetatable(
|
|
2385
2513
|
{},
|
|
2386
2514
|
{
|
|
2387
2515
|
__index = data,
|
|
2388
2516
|
__newindex = function(self, key, value)
|
|
2389
|
-
damageSetters[key]
|
|
2517
|
+
local damageSetter = damageSetters[key]
|
|
2518
|
+
if damageSetter ~= nil then
|
|
2519
|
+
damageSetter(value)
|
|
2520
|
+
end
|
|
2390
2521
|
data[key] = value
|
|
2391
2522
|
end
|
|
2392
2523
|
}
|
|
2393
2524
|
)
|
|
2394
2525
|
)
|
|
2526
|
+
if data[0] and source then
|
|
2527
|
+
local sourceOwner = source.owner.handle
|
|
2528
|
+
data[1] = sourceOwner
|
|
2529
|
+
local targetOwner = target.owner.handle
|
|
2530
|
+
data[2] = targetOwner
|
|
2531
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2532
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2533
|
+
data[3] = true
|
|
2534
|
+
end
|
|
2535
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2536
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2537
|
+
data[4] = true
|
|
2538
|
+
end
|
|
2539
|
+
end
|
|
2540
|
+
damagingEventByTarget[target] = data
|
|
2395
2541
|
return
|
|
2396
2542
|
end
|
|
2397
2543
|
BlzSetEventDamage(0)
|
|
@@ -2399,7 +2545,7 @@ Unit.onDamaging = (function()
|
|
|
2399
2545
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2400
2546
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2401
2547
|
local sourceOwner = source.owner.handle
|
|
2402
|
-
local targetOwner =
|
|
2548
|
+
local targetOwner = target.owner.handle
|
|
2403
2549
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2404
2550
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2405
2551
|
Timer:run(function()
|
|
@@ -2415,23 +2561,19 @@ Unit.onDamaging = (function()
|
|
|
2415
2561
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2416
2562
|
local condition = ____value[1]
|
|
2417
2563
|
local action = ____value[2]
|
|
2418
|
-
if condition(
|
|
2419
|
-
source,
|
|
2420
|
-
____exports.Unit:of(target),
|
|
2421
|
-
data
|
|
2422
|
-
) then
|
|
2564
|
+
if condition(source, target, data) then
|
|
2423
2565
|
action(
|
|
2424
2566
|
source,
|
|
2425
|
-
|
|
2567
|
+
target,
|
|
2426
2568
|
setmetatable(
|
|
2427
2569
|
{fire = function()
|
|
2428
2570
|
UnitDamageTarget(
|
|
2429
2571
|
source.handle,
|
|
2430
|
-
target,
|
|
2572
|
+
target.handle,
|
|
2431
2573
|
data.amount,
|
|
2432
2574
|
true,
|
|
2433
2575
|
true,
|
|
2434
|
-
data.attackType,
|
|
2576
|
+
attackTypeToNative(data.attackType),
|
|
2435
2577
|
data.damageType,
|
|
2436
2578
|
data.weaponType
|
|
2437
2579
|
)
|
|
@@ -2458,26 +2600,50 @@ Unit.onDamage = __TS__New(
|
|
|
2458
2600
|
if source and source.typeId == dummyUnitId then
|
|
2459
2601
|
source = nil
|
|
2460
2602
|
end
|
|
2603
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2604
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2605
|
+
damagingEventByTarget[target] = nil
|
|
2461
2606
|
local data = {
|
|
2462
2607
|
amount = GetEventDamage(),
|
|
2463
|
-
attackType = BlzGetEventAttackType(),
|
|
2608
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2464
2609
|
damageType = BlzGetEventDamageType(),
|
|
2465
2610
|
weaponType = BlzGetEventWeaponType(),
|
|
2611
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2466
2612
|
isAttack = BlzGetEventIsAttack(),
|
|
2467
|
-
originalAmount = GetEventDamage(),
|
|
2613
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2614
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2468
2615
|
preventDeath = damageEventPreventDeath
|
|
2469
2616
|
}
|
|
2617
|
+
if damagingEvent then
|
|
2618
|
+
for key, value in pairs(damagingEvent) do
|
|
2619
|
+
if isAttribute(key) then
|
|
2620
|
+
data[key] = value
|
|
2621
|
+
end
|
|
2622
|
+
end
|
|
2623
|
+
local sourceOwner = damagingEvent[1]
|
|
2624
|
+
if sourceOwner then
|
|
2625
|
+
local targetOwner = damagingEvent[2]
|
|
2626
|
+
if damagingEvent[3] then
|
|
2627
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2628
|
+
end
|
|
2629
|
+
if damagingEvent[4] then
|
|
2630
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2631
|
+
end
|
|
2632
|
+
end
|
|
2633
|
+
end
|
|
2470
2634
|
local evData = setmetatable(
|
|
2471
2635
|
{},
|
|
2472
2636
|
{
|
|
2473
2637
|
__index = data,
|
|
2474
2638
|
__newindex = function(self, key, value)
|
|
2475
|
-
damageSetters[key]
|
|
2639
|
+
local damageSetter = damageSetters[key]
|
|
2640
|
+
if damageSetter ~= nil then
|
|
2641
|
+
damageSetter(value)
|
|
2642
|
+
end
|
|
2476
2643
|
data[key] = value
|
|
2477
2644
|
end
|
|
2478
2645
|
}
|
|
2479
2646
|
)
|
|
2480
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2481
2647
|
invoke(event, source, target, evData)
|
|
2482
2648
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2483
2649
|
local bonusHealth = math.ceil(evData.amount)
|
|
@@ -2520,8 +2686,9 @@ Unit.itemDroppedEvent = __TS__New(
|
|
|
2520
2686
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2521
2687
|
function()
|
|
2522
2688
|
local unit = getTriggerUnit()
|
|
2523
|
-
|
|
2524
|
-
|
|
2689
|
+
local item = getManipulatedItem()
|
|
2690
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2691
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2525
2692
|
end
|
|
2526
2693
|
return IgnoreEvent
|
|
2527
2694
|
end
|
|
@@ -2531,8 +2698,9 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2531
2698
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2532
2699
|
function()
|
|
2533
2700
|
local unit = getTriggerUnit()
|
|
2534
|
-
|
|
2535
|
-
|
|
2701
|
+
local item = getManipulatedItem()
|
|
2702
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2703
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2536
2704
|
end
|
|
2537
2705
|
return IgnoreEvent
|
|
2538
2706
|
end
|
|
@@ -2540,7 +2708,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2540
2708
|
Unit.itemUsedEvent = __TS__New(
|
|
2541
2709
|
____exports.UnitTriggerEvent,
|
|
2542
2710
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2543
|
-
function()
|
|
2711
|
+
function()
|
|
2712
|
+
local unit = getTriggerUnit()
|
|
2713
|
+
local item = getManipulatedItem()
|
|
2714
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2715
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2716
|
+
end
|
|
2717
|
+
return IgnoreEvent
|
|
2718
|
+
end
|
|
2544
2719
|
)
|
|
2545
2720
|
Unit.itemStackedEvent = __TS__New(
|
|
2546
2721
|
____exports.UnitTriggerEvent,
|
|
@@ -2549,29 +2724,61 @@ Unit.itemStackedEvent = __TS__New(
|
|
|
2549
2724
|
)
|
|
2550
2725
|
__TS__ObjectDefineProperty(
|
|
2551
2726
|
Unit,
|
|
2552
|
-
"
|
|
2727
|
+
"itemChargesChangedEvent",
|
|
2553
2728
|
{get = function(self)
|
|
2554
2729
|
local event = __TS__New(Event)
|
|
2555
|
-
|
|
2556
|
-
local
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2730
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2731
|
+
local unit = item.owner
|
|
2732
|
+
if unit ~= nil then
|
|
2733
|
+
invoke(event, unit, item)
|
|
2734
|
+
end
|
|
2735
|
+
end)
|
|
2736
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2737
|
+
return event
|
|
2738
|
+
end}
|
|
2739
|
+
)
|
|
2740
|
+
__TS__ObjectDefineProperty(
|
|
2741
|
+
Unit,
|
|
2742
|
+
"itemUseOrderEvent",
|
|
2743
|
+
{get = function(self)
|
|
2744
|
+
local event = __TS__New(Event)
|
|
2745
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2746
|
+
local slot = order - orderId("useslot0")
|
|
2747
|
+
local function listener(unit)
|
|
2748
|
+
local item = unit.items[slot + 1]
|
|
2749
|
+
if item ~= nil then
|
|
2750
|
+
invoke(event, unit, item)
|
|
2751
|
+
end
|
|
2572
2752
|
end
|
|
2753
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2754
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2755
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2756
|
+
end
|
|
2757
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2758
|
+
return event
|
|
2759
|
+
end}
|
|
2760
|
+
)
|
|
2761
|
+
__TS__ObjectDefineProperty(
|
|
2762
|
+
Unit,
|
|
2763
|
+
"itemMoveOrderEvent",
|
|
2764
|
+
{get = function(self)
|
|
2765
|
+
local event = __TS__New(Event)
|
|
2766
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2767
|
+
local slotTo = order - orderId("moveslot0")
|
|
2768
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2769
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2770
|
+
if slotFrom ~= nil then
|
|
2771
|
+
invoke(
|
|
2772
|
+
event,
|
|
2773
|
+
unit,
|
|
2774
|
+
item,
|
|
2775
|
+
slotFrom,
|
|
2776
|
+
slotTo
|
|
2777
|
+
)
|
|
2778
|
+
end
|
|
2779
|
+
end)
|
|
2573
2780
|
end
|
|
2574
|
-
rawset(self, "
|
|
2781
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2575
2782
|
return event
|
|
2576
2783
|
end}
|
|
2577
2784
|
)
|