warscript 0.0.1-dev.8c7ee30 → 0.0.1-dev.8f3f3ea
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/binaryreader.d.ts +1 -0
- package/binaryreader.lua +3 -0
- package/binarywriter.lua +12 -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 +8 -0
- package/core/types/frame.lua +117 -22
- package/core/types/handle.lua +2 -0
- package/core/types/player.lua +3 -1
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +123 -5
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/tileCell.d.ts +9 -0
- package/core/types/tileCell.lua +92 -0
- package/core/types/timer.d.ts +8 -8
- package/core/types/timer.lua +39 -23
- package/core/util.d.ts +1 -1
- package/core/util.lua +18 -1
- package/decl/native.d.ts +846 -790
- package/engine/behavior.d.ts +7 -2
- package/engine/behavior.lua +112 -33
- 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 +39 -11
- package/engine/behaviour/ability/damage.lua +83 -37
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +43 -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/restore-mana.d.ts +15 -0
- package/engine/behaviour/ability/restore-mana.lua +29 -0
- package/engine/behaviour/ability.d.ts +20 -4
- package/engine/behaviour/ability.lua +111 -47
- package/engine/behaviour/unit/stun-immunity.d.ts +7 -3
- package/engine/behaviour/unit/stun-immunity.lua +52 -27
- package/engine/behaviour/unit.d.ts +37 -0
- package/engine/behaviour/unit.lua +205 -4
- package/engine/buff.d.ts +102 -42
- package/engine/buff.lua +446 -206
- package/engine/game-map.d.ts +7 -0
- package/engine/game-map.lua +32 -0
- package/engine/internal/ability.d.ts +23 -14
- package/engine/internal/ability.lua +129 -85
- package/engine/internal/item/ability.lua +162 -4
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +8 -7
- package/engine/internal/item.lua +153 -51
- 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/misc/frame-coordinates.d.ts +2 -0
- package/engine/internal/misc/frame-coordinates.lua +21 -0
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/misc/player-local-handle.d.ts +2 -0
- package/engine/internal/misc/player-local-handle.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 +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/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit+ability.lua +12 -3
- 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+transport.lua +4 -10
- package/engine/internal/unit-missile-launch.lua +42 -10
- package/engine/internal/unit.d.ts +56 -18
- package/engine/internal/unit.lua +409 -163
- 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/armor-type.d.ts +11 -0
- package/engine/object-data/auxiliary/armor-type.lua +46 -0
- package/engine/object-data/auxiliary/attachment-preset.d.ts +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 +93 -36
- 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 +21 -5
- package/engine/object-data/entry/unit-type.lua +214 -93
- 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 +28 -5
- package/engine/object-field/ability.lua +59 -5
- package/engine/object-field/unit.d.ts +57 -3
- package/engine/object-field/unit.lua +207 -7
- package/engine/object-field.d.ts +17 -6
- package/engine/object-field.lua +190 -90
- package/engine/random.d.ts +9 -0
- package/engine/random.lua +13 -0
- 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 +4 -0
- package/engine/standard/fields/unit.lua +7 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +249 -10
- package/engine/unit.d.ts +4 -0
- package/engine/unit.lua +4 -0
- package/index.d.ts +1 -0
- package/index.lua +1 -0
- package/lualib_bundle.lua +7 -2
- 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/patch-lualib.lua +1 -1
- package/property.d.ts +55 -0
- package/property.lua +374 -0
- package/utility/arrays.d.ts +10 -1
- package/utility/arrays.lua +45 -3
- package/utility/callback-array.d.ts +13 -0
- package/utility/callback-array.lua +46 -0
- package/utility/functions.d.ts +8 -0
- package/utility/functions.lua +13 -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 +15 -2
- package/utility/lua-maps.lua +53 -2
- package/utility/lua-sets.d.ts +2 -0
- package/utility/lua-sets.lua +7 -0
- package/utility/reflection.lua +11 -7
- package/utility/types.d.ts +1 -0
- package/core/mapbounds.d.ts +0 -8
- package/core/mapbounds.lua +0 -12
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
package/engine/internal/unit.lua
CHANGED
|
@@ -6,6 +6,7 @@ local __TS__New = ____lualib.__TS__New
|
|
|
6
6
|
local __TS__Class = ____lualib.__TS__Class
|
|
7
7
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
8
8
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
9
|
+
local __TS__ArraySetLength = ____lualib.__TS__ArraySetLength
|
|
9
10
|
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
|
|
10
11
|
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
|
|
11
12
|
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
|
|
@@ -50,12 +51,21 @@ local ____arrays = require("utility.arrays")
|
|
|
50
51
|
local forEach = ____arrays.forEach
|
|
51
52
|
local ____math = require("math")
|
|
52
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
|
|
53
65
|
local match = string.match
|
|
54
66
|
local ____tostring = _G.tostring
|
|
55
67
|
local setUnitAnimation = SetUnitAnimation
|
|
56
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
57
68
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
58
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
59
69
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
60
70
|
local getUnitRealField = BlzGetUnitRealField
|
|
61
71
|
local getHeroStr = GetHeroStr
|
|
@@ -74,9 +84,9 @@ local setUnitScale = SetUnitScale
|
|
|
74
84
|
local setUnitPosition = SetUnitPosition
|
|
75
85
|
local setUnitTimeScale = SetUnitTimeScale
|
|
76
86
|
local getHandleId = GetHandleId
|
|
87
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
77
88
|
local createUnit = CreateUnit
|
|
78
89
|
local killUnit = KillUnit
|
|
79
|
-
local setUnitExploded = SetUnitExploded
|
|
80
90
|
local removeUnit = RemoveUnit
|
|
81
91
|
local getUnitTypeId = GetUnitTypeId
|
|
82
92
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -92,8 +102,6 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
92
102
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
93
103
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
94
104
|
local isUnitInRange = IsUnitInRange
|
|
95
|
-
local setResourceAmount = SetResourceAmount
|
|
96
|
-
local getResourceAmount = GetResourceAmount
|
|
97
105
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
98
106
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
99
107
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
@@ -117,15 +125,9 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
117
125
|
local getIssuedOrderId = GetIssuedOrderId
|
|
118
126
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
119
127
|
local unitAlive = UnitAlive
|
|
120
|
-
local unitAddType = UnitAddType
|
|
121
|
-
local unitRemoveType = UnitRemoveType
|
|
122
|
-
local isUnitIllusion = IsUnitIllusion
|
|
123
|
-
local isUnitType = IsUnitType
|
|
124
128
|
local isUnitAlly = IsUnitAlly
|
|
125
129
|
local isUnitEnemy = IsUnitEnemy
|
|
126
130
|
local getOwningPlayer = GetOwningPlayer
|
|
127
|
-
local setUnitColor = SetUnitColor
|
|
128
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
129
131
|
____exports.UnitClassification = {}
|
|
130
132
|
local UnitClassification = ____exports.UnitClassification
|
|
131
133
|
do
|
|
@@ -135,6 +137,7 @@ do
|
|
|
135
137
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
136
138
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
137
139
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
140
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
138
141
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
139
142
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
140
143
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -289,7 +292,6 @@ local function dispatch(event, idGetter, argsGetter)
|
|
|
289
292
|
return event[id]
|
|
290
293
|
end
|
|
291
294
|
if not initialized then
|
|
292
|
-
local invoke = Event.invoke
|
|
293
295
|
event:addListener(function(...)
|
|
294
296
|
local id = idGetter(...)
|
|
295
297
|
local dispatched = rawget(self, id)
|
|
@@ -327,7 +329,6 @@ local function dispatchAbility(event)
|
|
|
327
329
|
return event[id]
|
|
328
330
|
end
|
|
329
331
|
if not initialized then
|
|
330
|
-
local invoke = Event.invoke
|
|
331
332
|
event:addListener(function(unit, ability, ...)
|
|
332
333
|
local dispatched = rawget(self, ability.typeId)
|
|
333
334
|
if dispatched ~= nil then
|
|
@@ -344,6 +345,9 @@ local function dispatchAbility(event)
|
|
|
344
345
|
}
|
|
345
346
|
)
|
|
346
347
|
end
|
|
348
|
+
local function damagingEventPreventRetaliation(self)
|
|
349
|
+
self[0] = true
|
|
350
|
+
end
|
|
347
351
|
local function damageEventPreventDeath(self, callback, ...)
|
|
348
352
|
if self[0] ~= nil then
|
|
349
353
|
return
|
|
@@ -355,7 +359,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
355
359
|
rawset(self, 1 + i, (select(i, ...)))
|
|
356
360
|
end
|
|
357
361
|
end
|
|
358
|
-
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
|
+
}
|
|
359
370
|
local jlimitopByOperator = {
|
|
360
371
|
[0] = LESS_THAN_OR_EQUAL,
|
|
361
372
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -433,6 +444,19 @@ __TS__SetDescriptor(
|
|
|
433
444
|
},
|
|
434
445
|
true
|
|
435
446
|
)
|
|
447
|
+
__TS__SetDescriptor(
|
|
448
|
+
UnitWeapon.prototype,
|
|
449
|
+
"allowedTargetCombatClassifications",
|
|
450
|
+
{
|
|
451
|
+
get = function(self)
|
|
452
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
453
|
+
end,
|
|
454
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
455
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
456
|
+
end
|
|
457
|
+
},
|
|
458
|
+
true
|
|
459
|
+
)
|
|
436
460
|
__TS__SetDescriptor(
|
|
437
461
|
UnitWeapon.prototype,
|
|
438
462
|
"damageBase",
|
|
@@ -563,17 +587,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
563
587
|
____exports.Unit:of(unit)
|
|
564
588
|
)
|
|
565
589
|
end
|
|
566
|
-
if not unitAddAbility(unit, abilityId) then
|
|
567
|
-
if getUnitAbility(unit, abilityId) == ability then
|
|
568
|
-
return UnitAbility:of(
|
|
569
|
-
ability,
|
|
570
|
-
abilityId,
|
|
571
|
-
____exports.Unit:of(unit)
|
|
572
|
-
)
|
|
573
|
-
end
|
|
574
|
-
else
|
|
575
|
-
unitRemoveAbility(unit, abilityId)
|
|
576
|
-
end
|
|
577
590
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
578
591
|
local item = unitItemInSlot(unit, i)
|
|
579
592
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -631,15 +644,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
631
644
|
dummies[player] = dummy
|
|
632
645
|
end
|
|
633
646
|
local function delayHealthChecksCallback(unit)
|
|
634
|
-
local counter = (unit[
|
|
647
|
+
local counter = (unit[103] or 0) - 1
|
|
635
648
|
if counter ~= 0 then
|
|
636
|
-
unit[
|
|
649
|
+
unit[103] = counter
|
|
637
650
|
return
|
|
638
651
|
end
|
|
639
|
-
unit[
|
|
640
|
-
local healthBonus = unit[
|
|
652
|
+
unit[103] = nil
|
|
653
|
+
local healthBonus = unit[104]
|
|
641
654
|
if healthBonus ~= nil then
|
|
642
|
-
unit[
|
|
655
|
+
unit[104] = nil
|
|
643
656
|
local handle = unit.handle
|
|
644
657
|
BlzSetUnitMaxHP(
|
|
645
658
|
handle,
|
|
@@ -647,12 +660,27 @@ local function delayHealthChecksCallback(unit)
|
|
|
647
660
|
)
|
|
648
661
|
end
|
|
649
662
|
end
|
|
663
|
+
local nextSyncId = 1
|
|
664
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
665
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
666
|
+
local function addAbility(unit, abilityTypeId)
|
|
667
|
+
local ____unitAddAbility_result_0
|
|
668
|
+
if unitAddAbility(unit, abilityTypeId) then
|
|
669
|
+
____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
|
|
670
|
+
else
|
|
671
|
+
____unitAddAbility_result_0 = nil
|
|
672
|
+
end
|
|
673
|
+
return ____unitAddAbility_result_0
|
|
674
|
+
end
|
|
650
675
|
____exports.Unit = __TS__Class()
|
|
651
676
|
local Unit = ____exports.Unit
|
|
652
677
|
Unit.name = "Unit"
|
|
653
678
|
__TS__ClassExtends(Unit, Handle)
|
|
654
679
|
function Unit.prototype.____constructor(self, handle)
|
|
655
680
|
Handle.prototype.____constructor(self, handle)
|
|
681
|
+
local ____nextSyncId_1 = nextSyncId
|
|
682
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
683
|
+
self.syncId = ____nextSyncId_1
|
|
656
684
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
657
685
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
658
686
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -665,6 +693,7 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
665
693
|
fourCC("Amrf")
|
|
666
694
|
))
|
|
667
695
|
end
|
|
696
|
+
unitBySyncId[self.syncId] = self
|
|
668
697
|
local ____ = self.abilities
|
|
669
698
|
end
|
|
670
699
|
function Unit.prototype.getEvent(self, event, collector)
|
|
@@ -683,9 +712,16 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
683
712
|
end
|
|
684
713
|
function Unit.prototype.onDestroy(self)
|
|
685
714
|
local handle = self.handle
|
|
715
|
+
self[107] = getUnitX(handle)
|
|
716
|
+
self[108] = getUnitY(handle)
|
|
686
717
|
if not self._owner then
|
|
687
718
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
688
719
|
end
|
|
720
|
+
local abilities = self.abilities
|
|
721
|
+
for ____, ability in ipairs(abilities) do
|
|
722
|
+
ability:destroy()
|
|
723
|
+
end
|
|
724
|
+
__TS__ArraySetLength(abilities, 0)
|
|
689
725
|
for ____, player in ipairs(Player.all) do
|
|
690
726
|
if self:isSelected(player) then
|
|
691
727
|
Event.invoke(____exports.Unit.onDeselect, self, player)
|
|
@@ -700,6 +736,10 @@ function Unit.prototype.onDestroy(self)
|
|
|
700
736
|
if eventsToDestroy ~= nil then
|
|
701
737
|
forEach(eventsToDestroy, "destroy")
|
|
702
738
|
end
|
|
739
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) > 0 then
|
|
740
|
+
unitRemoveAbility(handle, leaveDetectAbilityId)
|
|
741
|
+
removeUnit(handle)
|
|
742
|
+
end
|
|
703
743
|
return Handle.prototype.onDestroy(self)
|
|
704
744
|
end
|
|
705
745
|
function Unit.prototype.addAttackHandler(self, condition, action)
|
|
@@ -741,17 +781,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
741
781
|
end}
|
|
742
782
|
end
|
|
743
783
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
744
|
-
local
|
|
745
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
784
|
+
local ____combatClassification_2 = combatClassification
|
|
785
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
|
|
746
786
|
end
|
|
747
787
|
function Unit.prototype.addClassification(self, classification)
|
|
748
|
-
return
|
|
788
|
+
return UnitAddType(self.handle, classification)
|
|
749
789
|
end
|
|
750
790
|
function Unit.prototype.removeClassification(self, classification)
|
|
751
|
-
return
|
|
791
|
+
return UnitRemoveType(self.handle, classification)
|
|
752
792
|
end
|
|
753
793
|
function Unit.prototype.hasClassification(self, classification)
|
|
754
|
-
return
|
|
794
|
+
return IsUnitType(self.handle, classification)
|
|
755
795
|
end
|
|
756
796
|
function Unit.prototype.isVisibleTo(self, player)
|
|
757
797
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -760,13 +800,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
760
800
|
return isUnitInvisible(self.handle, player.handle)
|
|
761
801
|
end
|
|
762
802
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
763
|
-
local
|
|
803
|
+
local ____temp_3
|
|
764
804
|
if type(x) == "number" then
|
|
765
|
-
|
|
805
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
766
806
|
else
|
|
767
|
-
|
|
807
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
768
808
|
end
|
|
769
|
-
return
|
|
809
|
+
return ____temp_3
|
|
770
810
|
end
|
|
771
811
|
function Unit.prototype.isAllyOf(self, unit)
|
|
772
812
|
return isUnitAlly(
|
|
@@ -784,16 +824,28 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
784
824
|
if type(animation) == "number" then
|
|
785
825
|
setUnitAnimationByIndex(self.handle, animation)
|
|
786
826
|
elseif rarity then
|
|
787
|
-
|
|
827
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
788
828
|
else
|
|
789
829
|
setUnitAnimation(self.handle, animation)
|
|
790
830
|
end
|
|
791
831
|
end
|
|
832
|
+
function Unit.prototype.resetAnimation(self)
|
|
833
|
+
ResetUnitAnimation(self.handle)
|
|
834
|
+
end
|
|
792
835
|
function Unit.prototype.queueAnimation(self, animation)
|
|
793
|
-
|
|
836
|
+
QueueUnitAnimation(self.handle, animation)
|
|
837
|
+
end
|
|
838
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
839
|
+
if target:isAllowedTarget(self, self.firstWeapon.allowedTargetCombatClassifications) then
|
|
840
|
+
return self.firstWeapon
|
|
841
|
+
end
|
|
842
|
+
if target:isAllowedTarget(target, self.secondWeapon.allowedTargetCombatClassifications) then
|
|
843
|
+
return self.secondWeapon
|
|
844
|
+
end
|
|
845
|
+
return nil
|
|
794
846
|
end
|
|
795
847
|
function Unit.prototype.delayHealthChecks(self)
|
|
796
|
-
self[
|
|
848
|
+
self[103] = (self[103] or 0) + 1
|
|
797
849
|
Timer:run(delayHealthChecksCallback, self)
|
|
798
850
|
end
|
|
799
851
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -803,21 +855,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
803
855
|
return IsUnitSelected(self.handle, player.handle)
|
|
804
856
|
end
|
|
805
857
|
function Unit.prototype.explode(self)
|
|
806
|
-
|
|
858
|
+
SetUnitExploded(self.handle, true)
|
|
807
859
|
killUnit(self.handle)
|
|
808
860
|
end
|
|
809
861
|
function Unit.prototype.kill(self)
|
|
810
862
|
killUnit(self.handle)
|
|
811
863
|
end
|
|
812
864
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
813
|
-
local
|
|
814
|
-
local
|
|
815
|
-
local
|
|
816
|
-
if
|
|
817
|
-
|
|
865
|
+
local ____ReviveHero_6 = ReviveHero
|
|
866
|
+
local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
|
|
867
|
+
local ____doEffect_4 = doEffect
|
|
868
|
+
if ____doEffect_4 == nil then
|
|
869
|
+
____doEffect_4 = false
|
|
818
870
|
end
|
|
819
|
-
__TS__SparseArrayPush(
|
|
820
|
-
|
|
871
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
872
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
821
873
|
end
|
|
822
874
|
function Unit.prototype.healTarget(self, target, amount)
|
|
823
875
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -857,20 +909,19 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
857
909
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
858
910
|
end
|
|
859
911
|
function Unit.prototype.itemInSlot(self, slot)
|
|
860
|
-
return Item:of(
|
|
912
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
861
913
|
end
|
|
862
914
|
function Unit.prototype.addAbility(self, abilityId)
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
915
|
+
local ability = UnitAbility:of(
|
|
916
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
917
|
+
abilityId,
|
|
918
|
+
self
|
|
919
|
+
)
|
|
920
|
+
if ability ~= nil then
|
|
869
921
|
local abilities = self.abilities
|
|
870
922
|
abilities[#abilities + 1] = ability
|
|
871
|
-
return ability
|
|
872
923
|
end
|
|
873
|
-
return
|
|
924
|
+
return ability
|
|
874
925
|
end
|
|
875
926
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
876
927
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -884,31 +935,21 @@ end
|
|
|
884
935
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
885
936
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
886
937
|
end
|
|
887
|
-
function Unit.prototype.
|
|
888
|
-
local
|
|
889
|
-
|
|
890
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
891
|
-
return nil
|
|
892
|
-
end
|
|
893
|
-
return UnitAbility:of(
|
|
894
|
-
getUnitAbility(self.handle, abilityId),
|
|
895
|
-
abilityId,
|
|
896
|
-
self
|
|
897
|
-
)
|
|
938
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
939
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
940
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
898
941
|
end
|
|
899
|
-
function Unit.prototype.removeAbility(self,
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
end
|
|
942
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
943
|
+
local abilities = self.abilities
|
|
944
|
+
for i = 1, #abilities do
|
|
945
|
+
if abilities[i].typeId == abilityTypeId then
|
|
946
|
+
local ability = abilities[i]
|
|
947
|
+
tremove(abilities, i)
|
|
948
|
+
ability:destroy()
|
|
949
|
+
return true
|
|
908
950
|
end
|
|
909
|
-
return true
|
|
910
951
|
end
|
|
911
|
-
return
|
|
952
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
912
953
|
end
|
|
913
954
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
914
955
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -922,12 +963,34 @@ end
|
|
|
922
963
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
923
964
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
924
965
|
end
|
|
966
|
+
function Unit.prototype.interruptMovement(self)
|
|
967
|
+
local handle = self.handle
|
|
968
|
+
unitDisableAbility(
|
|
969
|
+
handle,
|
|
970
|
+
fourCC("Amov"),
|
|
971
|
+
true,
|
|
972
|
+
false
|
|
973
|
+
)
|
|
974
|
+
unitDisableAbility(
|
|
975
|
+
handle,
|
|
976
|
+
fourCC("Amov"),
|
|
977
|
+
false,
|
|
978
|
+
false
|
|
979
|
+
)
|
|
980
|
+
end
|
|
925
981
|
function Unit.prototype.interruptAttack(self)
|
|
926
982
|
unitInterruptAttack(self.handle)
|
|
927
983
|
end
|
|
928
984
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
929
|
-
|
|
930
|
-
unitDisableAbility(
|
|
985
|
+
local handle = self.handle
|
|
986
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
987
|
+
Timer:run(
|
|
988
|
+
unitDisableAbility,
|
|
989
|
+
handle,
|
|
990
|
+
abilityId,
|
|
991
|
+
false,
|
|
992
|
+
false
|
|
993
|
+
)
|
|
931
994
|
end
|
|
932
995
|
function Unit.prototype.getDistanceTo(self, target)
|
|
933
996
|
local handle = self.handle
|
|
@@ -987,18 +1050,18 @@ function Unit.prototype.unpauseEx(self)
|
|
|
987
1050
|
self:decrementStunCounter()
|
|
988
1051
|
end
|
|
989
1052
|
function Unit.prototype.incrementStunCounter(self)
|
|
990
|
-
local stunCounter = self[
|
|
991
|
-
if not self[
|
|
1053
|
+
local stunCounter = self[102] or 0
|
|
1054
|
+
if not self[101] or stunCounter >= 0 then
|
|
992
1055
|
BlzPauseUnitEx(self.handle, true)
|
|
993
1056
|
end
|
|
994
|
-
self[
|
|
1057
|
+
self[102] = stunCounter + 1
|
|
995
1058
|
end
|
|
996
1059
|
function Unit.prototype.decrementStunCounter(self)
|
|
997
|
-
local stunCounter = self[
|
|
998
|
-
if not self[
|
|
1060
|
+
local stunCounter = self[102] or 0
|
|
1061
|
+
if not self[101] or stunCounter >= 1 then
|
|
999
1062
|
BlzPauseUnitEx(self.handle, false)
|
|
1000
1063
|
end
|
|
1001
|
-
self[
|
|
1064
|
+
self[102] = stunCounter - 1
|
|
1002
1065
|
end
|
|
1003
1066
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1004
1067
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -1100,8 +1163,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
1100
1163
|
)
|
|
1101
1164
|
return targetCollection
|
|
1102
1165
|
end
|
|
1103
|
-
function Unit.getSelectionOf(self, player)
|
|
1104
|
-
|
|
1166
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1167
|
+
if target == nil then
|
|
1168
|
+
target = {}
|
|
1169
|
+
end
|
|
1170
|
+
targetCollection = target
|
|
1105
1171
|
targetCollectionNextIndex = 1
|
|
1106
1172
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
1107
1173
|
return targetCollection
|
|
@@ -1123,6 +1189,9 @@ end
|
|
|
1123
1189
|
function Unit.prototype.__tostring(self)
|
|
1124
1190
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
1125
1191
|
end
|
|
1192
|
+
function Unit.getBySyncId(self, syncId)
|
|
1193
|
+
return unitBySyncId[syncId]
|
|
1194
|
+
end
|
|
1126
1195
|
__TS__SetDescriptor(
|
|
1127
1196
|
Unit.prototype,
|
|
1128
1197
|
"_deltas",
|
|
@@ -1182,7 +1251,15 @@ __TS__SetDescriptor(
|
|
|
1182
1251
|
Unit.prototype,
|
|
1183
1252
|
"isIllusion",
|
|
1184
1253
|
{get = function(self)
|
|
1185
|
-
return
|
|
1254
|
+
return IsUnitIllusion(self.handle)
|
|
1255
|
+
end},
|
|
1256
|
+
true
|
|
1257
|
+
)
|
|
1258
|
+
__TS__SetDescriptor(
|
|
1259
|
+
Unit.prototype,
|
|
1260
|
+
"isStunned",
|
|
1261
|
+
{get = function(self)
|
|
1262
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1186
1263
|
end},
|
|
1187
1264
|
true
|
|
1188
1265
|
)
|
|
@@ -1259,6 +1336,19 @@ __TS__SetDescriptor(
|
|
|
1259
1336
|
},
|
|
1260
1337
|
true
|
|
1261
1338
|
)
|
|
1339
|
+
__TS__SetDescriptor(
|
|
1340
|
+
Unit.prototype,
|
|
1341
|
+
"primaryAttribute",
|
|
1342
|
+
{
|
|
1343
|
+
get = function(self)
|
|
1344
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1345
|
+
end,
|
|
1346
|
+
set = function(self, primaryAttribute)
|
|
1347
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1348
|
+
end
|
|
1349
|
+
},
|
|
1350
|
+
true
|
|
1351
|
+
)
|
|
1262
1352
|
__TS__SetDescriptor(
|
|
1263
1353
|
Unit.prototype,
|
|
1264
1354
|
"strengthBase",
|
|
@@ -1380,17 +1470,17 @@ __TS__SetDescriptor(
|
|
|
1380
1470
|
"isTeamGlowVisible",
|
|
1381
1471
|
{
|
|
1382
1472
|
get = function(self)
|
|
1383
|
-
return not self[
|
|
1473
|
+
return not self[106]
|
|
1384
1474
|
end,
|
|
1385
1475
|
set = function(self, isTeamGlowVisible)
|
|
1386
|
-
|
|
1387
|
-
local
|
|
1476
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1477
|
+
local ____temp_7
|
|
1388
1478
|
if not isTeamGlowVisible then
|
|
1389
|
-
|
|
1479
|
+
____temp_7 = true
|
|
1390
1480
|
else
|
|
1391
|
-
|
|
1481
|
+
____temp_7 = nil
|
|
1392
1482
|
end
|
|
1393
|
-
self[
|
|
1483
|
+
self[106] = ____temp_7
|
|
1394
1484
|
end
|
|
1395
1485
|
},
|
|
1396
1486
|
true
|
|
@@ -1399,9 +1489,9 @@ __TS__SetDescriptor(
|
|
|
1399
1489
|
Unit.prototype,
|
|
1400
1490
|
"color",
|
|
1401
1491
|
{set = function(self, color)
|
|
1402
|
-
|
|
1403
|
-
if self[
|
|
1404
|
-
|
|
1492
|
+
SetUnitColor(self.handle, color.handle)
|
|
1493
|
+
if self[106] then
|
|
1494
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1405
1495
|
end
|
|
1406
1496
|
end},
|
|
1407
1497
|
true
|
|
@@ -1424,14 +1514,14 @@ __TS__SetDescriptor(
|
|
|
1424
1514
|
"maxHealth",
|
|
1425
1515
|
{
|
|
1426
1516
|
get = function(self)
|
|
1427
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1517
|
+
return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
|
|
1428
1518
|
end,
|
|
1429
1519
|
set = function(self, maxHealth)
|
|
1430
|
-
if maxHealth < 1 and self[
|
|
1431
|
-
self[
|
|
1520
|
+
if maxHealth < 1 and self[103] ~= nil then
|
|
1521
|
+
self[104] = (self[104] or 0) + (1 - maxHealth)
|
|
1432
1522
|
maxHealth = 1
|
|
1433
1523
|
end
|
|
1434
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1524
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
|
|
1435
1525
|
end
|
|
1436
1526
|
},
|
|
1437
1527
|
true
|
|
@@ -1473,10 +1563,10 @@ __TS__SetDescriptor(
|
|
|
1473
1563
|
"health",
|
|
1474
1564
|
{
|
|
1475
1565
|
get = function(self)
|
|
1476
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1566
|
+
return GetWidgetLife(self.handle) - (self[105] or 0)
|
|
1477
1567
|
end,
|
|
1478
1568
|
set = function(self, health)
|
|
1479
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1569
|
+
SetWidgetLife(self.handle, health + (self[105] or 0))
|
|
1480
1570
|
end
|
|
1481
1571
|
},
|
|
1482
1572
|
true
|
|
@@ -1570,7 +1660,7 @@ __TS__SetDescriptor(
|
|
|
1570
1660
|
"x",
|
|
1571
1661
|
{
|
|
1572
1662
|
get = function(self)
|
|
1573
|
-
return getUnitX(self.handle)
|
|
1663
|
+
return self[107] or getUnitX(self.handle)
|
|
1574
1664
|
end,
|
|
1575
1665
|
set = function(self, v)
|
|
1576
1666
|
SetUnitX(self.handle, v)
|
|
@@ -1583,7 +1673,7 @@ __TS__SetDescriptor(
|
|
|
1583
1673
|
"y",
|
|
1584
1674
|
{
|
|
1585
1675
|
get = function(self)
|
|
1586
|
-
return getUnitY(self.handle)
|
|
1676
|
+
return self[108] or getUnitY(self.handle)
|
|
1587
1677
|
end,
|
|
1588
1678
|
set = function(self, v)
|
|
1589
1679
|
SetUnitY(self.handle, v)
|
|
@@ -1669,10 +1759,10 @@ __TS__SetDescriptor(
|
|
|
1669
1759
|
"gold",
|
|
1670
1760
|
{
|
|
1671
1761
|
get = function(self)
|
|
1672
|
-
return
|
|
1762
|
+
return GetResourceAmount(self.handle)
|
|
1673
1763
|
end,
|
|
1674
1764
|
set = function(self, gold)
|
|
1675
|
-
|
|
1765
|
+
SetResourceAmount(self.handle, gold)
|
|
1676
1766
|
end
|
|
1677
1767
|
},
|
|
1678
1768
|
true
|
|
@@ -1687,17 +1777,17 @@ __TS__SetDescriptor(
|
|
|
1687
1777
|
set = function(self, isPaused)
|
|
1688
1778
|
local handle = self.handle
|
|
1689
1779
|
if isPaused and not IsUnitPaused(handle) then
|
|
1690
|
-
self[
|
|
1691
|
-
for _ = self[
|
|
1780
|
+
self[101] = true
|
|
1781
|
+
for _ = self[102] or 0, -1 do
|
|
1692
1782
|
BlzPauseUnitEx(handle, true)
|
|
1693
1783
|
end
|
|
1694
1784
|
PauseUnit(handle, true)
|
|
1695
1785
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1696
1786
|
PauseUnit(handle, false)
|
|
1697
|
-
for _ = self[
|
|
1787
|
+
for _ = self[102] or 0, -1 do
|
|
1698
1788
|
BlzPauseUnitEx(handle, false)
|
|
1699
1789
|
end
|
|
1700
|
-
self[
|
|
1790
|
+
self[101] = nil
|
|
1701
1791
|
end
|
|
1702
1792
|
end
|
|
1703
1793
|
},
|
|
@@ -1800,6 +1890,19 @@ __TS__SetDescriptor(
|
|
|
1800
1890
|
end},
|
|
1801
1891
|
true
|
|
1802
1892
|
)
|
|
1893
|
+
__TS__SetDescriptor(
|
|
1894
|
+
Unit.prototype,
|
|
1895
|
+
"movementType",
|
|
1896
|
+
{
|
|
1897
|
+
get = function(self)
|
|
1898
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1899
|
+
end,
|
|
1900
|
+
set = function(self, movementType)
|
|
1901
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1902
|
+
end
|
|
1903
|
+
},
|
|
1904
|
+
true
|
|
1905
|
+
)
|
|
1803
1906
|
__TS__SetDescriptor(
|
|
1804
1907
|
Unit.prototype,
|
|
1805
1908
|
"pathing",
|
|
@@ -1981,6 +2084,14 @@ __TS__SetDescriptor(
|
|
|
1981
2084
|
end},
|
|
1982
2085
|
true
|
|
1983
2086
|
)
|
|
2087
|
+
__TS__SetDescriptor(
|
|
2088
|
+
Unit.prototype,
|
|
2089
|
+
"targetAcquiredEvent",
|
|
2090
|
+
{get = function(self)
|
|
2091
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2092
|
+
end},
|
|
2093
|
+
true
|
|
2094
|
+
)
|
|
1984
2095
|
__TS__SetDescriptor(
|
|
1985
2096
|
Unit.prototype,
|
|
1986
2097
|
"onSelect",
|
|
@@ -2054,7 +2165,6 @@ Unit.onDecay = __TS__New(
|
|
|
2054
2165
|
Unit.onResurrect = __TS__New(
|
|
2055
2166
|
InitializingEvent,
|
|
2056
2167
|
function(event)
|
|
2057
|
-
local invoke = Event.invoke
|
|
2058
2168
|
local dead = setmetatable({}, {__mode = "k"})
|
|
2059
2169
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
2060
2170
|
dead[unit] = true
|
|
@@ -2070,10 +2180,15 @@ Unit.onResurrect = __TS__New(
|
|
|
2070
2180
|
Unit.morphEvent = __TS__New(
|
|
2071
2181
|
InitializingEvent,
|
|
2072
2182
|
function(event)
|
|
2183
|
+
local function ifNotLeft(unit)
|
|
2184
|
+
local handle = unit.handle
|
|
2185
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2186
|
+
invoke(event, unit)
|
|
2187
|
+
end
|
|
2188
|
+
end
|
|
2073
2189
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
2074
2190
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
2075
|
-
|
|
2076
|
-
Timer:run(Event.invoke, event, unit)
|
|
2191
|
+
Timer:run(ifNotLeft, unit)
|
|
2077
2192
|
end
|
|
2078
2193
|
end)
|
|
2079
2194
|
end
|
|
@@ -2111,27 +2226,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
2111
2226
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
2112
2227
|
InitializingEvent,
|
|
2113
2228
|
function(event)
|
|
2114
|
-
local invoke = Event.invoke
|
|
2115
2229
|
local function listener(unit, id)
|
|
2116
|
-
local
|
|
2230
|
+
local ____GetSpellTargetUnit_result_10
|
|
2117
2231
|
if GetSpellTargetUnit() then
|
|
2118
|
-
|
|
2232
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2119
2233
|
else
|
|
2120
|
-
local
|
|
2234
|
+
local ____GetSpellTargetItem_result_9
|
|
2121
2235
|
if GetSpellTargetItem() then
|
|
2122
|
-
|
|
2236
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2123
2237
|
else
|
|
2124
|
-
local
|
|
2238
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2125
2239
|
if GetSpellTargetDestructable() then
|
|
2126
|
-
|
|
2240
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2127
2241
|
else
|
|
2128
|
-
|
|
2242
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2129
2243
|
end
|
|
2130
|
-
|
|
2244
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2131
2245
|
end
|
|
2132
|
-
|
|
2246
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2133
2247
|
end
|
|
2134
|
-
local target =
|
|
2248
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2135
2249
|
if target then
|
|
2136
2250
|
invoke(event, unit, id, target)
|
|
2137
2251
|
end
|
|
@@ -2303,10 +2417,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2303
2417
|
____exports.UnitTriggerEvent,
|
|
2304
2418
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2305
2419
|
function()
|
|
2306
|
-
local
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2420
|
+
local handle = getOrderedUnit()
|
|
2421
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2422
|
+
local unit = ____exports.Unit:of(handle)
|
|
2423
|
+
if unit.state == 1 then
|
|
2424
|
+
return unit, getIssuedOrderId()
|
|
2425
|
+
end
|
|
2310
2426
|
end
|
|
2311
2427
|
return IgnoreEvent
|
|
2312
2428
|
end
|
|
@@ -2328,7 +2444,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2328
2444
|
)
|
|
2329
2445
|
Unit.onDamaging = (function()
|
|
2330
2446
|
local event = __TS__New(Event)
|
|
2331
|
-
local invoke = Event.invoke
|
|
2332
2447
|
local trigger = CreateTrigger()
|
|
2333
2448
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2334
2449
|
TriggerAddCondition(
|
|
@@ -2338,13 +2453,19 @@ Unit.onDamaging = (function()
|
|
|
2338
2453
|
if source and source.typeId == dummyUnitId then
|
|
2339
2454
|
source = nil
|
|
2340
2455
|
end
|
|
2341
|
-
local target = BlzGetEventDamageTarget()
|
|
2456
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2457
|
+
local metadata = damageMetadataByTarget[target]
|
|
2458
|
+
damageMetadataByTarget[target] = nil
|
|
2342
2459
|
local data = {
|
|
2343
2460
|
amount = GetEventDamage(),
|
|
2344
|
-
attackType = BlzGetEventAttackType(),
|
|
2461
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2345
2462
|
damageType = BlzGetEventDamageType(),
|
|
2346
2463
|
weaponType = BlzGetEventWeaponType(),
|
|
2347
|
-
|
|
2464
|
+
metadata = metadata,
|
|
2465
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2466
|
+
originalAmount = GetEventDamage(),
|
|
2467
|
+
originalMetadata = metadata,
|
|
2468
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2348
2469
|
}
|
|
2349
2470
|
if data.isAttack and source then
|
|
2350
2471
|
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
|
|
@@ -2358,18 +2479,36 @@ Unit.onDamaging = (function()
|
|
|
2358
2479
|
invoke(
|
|
2359
2480
|
event,
|
|
2360
2481
|
source,
|
|
2361
|
-
|
|
2482
|
+
target,
|
|
2362
2483
|
setmetatable(
|
|
2363
2484
|
{},
|
|
2364
2485
|
{
|
|
2365
2486
|
__index = data,
|
|
2366
2487
|
__newindex = function(self, key, value)
|
|
2367
|
-
damageSetters[key]
|
|
2488
|
+
local damageSetter = damageSetters[key]
|
|
2489
|
+
if damageSetter ~= nil then
|
|
2490
|
+
damageSetter(value)
|
|
2491
|
+
end
|
|
2368
2492
|
data[key] = value
|
|
2369
2493
|
end
|
|
2370
2494
|
}
|
|
2371
2495
|
)
|
|
2372
2496
|
)
|
|
2497
|
+
if data[0] and source then
|
|
2498
|
+
local sourceOwner = source.owner.handle
|
|
2499
|
+
data[1] = sourceOwner
|
|
2500
|
+
local targetOwner = target.owner.handle
|
|
2501
|
+
data[2] = targetOwner
|
|
2502
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2503
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2504
|
+
data[3] = true
|
|
2505
|
+
end
|
|
2506
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2507
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2508
|
+
data[4] = true
|
|
2509
|
+
end
|
|
2510
|
+
end
|
|
2511
|
+
damagingEventByTarget[target] = data
|
|
2373
2512
|
return
|
|
2374
2513
|
end
|
|
2375
2514
|
BlzSetEventDamage(0)
|
|
@@ -2377,7 +2516,7 @@ Unit.onDamaging = (function()
|
|
|
2377
2516
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2378
2517
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2379
2518
|
local sourceOwner = source.owner.handle
|
|
2380
|
-
local targetOwner =
|
|
2519
|
+
local targetOwner = target.owner.handle
|
|
2381
2520
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2382
2521
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2383
2522
|
Timer:run(function()
|
|
@@ -2393,23 +2532,19 @@ Unit.onDamaging = (function()
|
|
|
2393
2532
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2394
2533
|
local condition = ____value[1]
|
|
2395
2534
|
local action = ____value[2]
|
|
2396
|
-
if condition(
|
|
2397
|
-
source,
|
|
2398
|
-
____exports.Unit:of(target),
|
|
2399
|
-
data
|
|
2400
|
-
) then
|
|
2535
|
+
if condition(source, target, data) then
|
|
2401
2536
|
action(
|
|
2402
2537
|
source,
|
|
2403
|
-
|
|
2538
|
+
target,
|
|
2404
2539
|
setmetatable(
|
|
2405
2540
|
{fire = function()
|
|
2406
2541
|
UnitDamageTarget(
|
|
2407
2542
|
source.handle,
|
|
2408
|
-
target,
|
|
2543
|
+
target.handle,
|
|
2409
2544
|
data.amount,
|
|
2410
2545
|
true,
|
|
2411
2546
|
true,
|
|
2412
|
-
data.attackType,
|
|
2547
|
+
attackTypeToNative(data.attackType),
|
|
2413
2548
|
data.damageType,
|
|
2414
2549
|
data.weaponType
|
|
2415
2550
|
)
|
|
@@ -2427,7 +2562,6 @@ end)()
|
|
|
2427
2562
|
Unit.onDamage = __TS__New(
|
|
2428
2563
|
InitializingEvent,
|
|
2429
2564
|
function(event)
|
|
2430
|
-
local invoke = Event.invoke
|
|
2431
2565
|
local trigger = CreateTrigger()
|
|
2432
2566
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2433
2567
|
TriggerAddCondition(
|
|
@@ -2437,29 +2571,54 @@ Unit.onDamage = __TS__New(
|
|
|
2437
2571
|
if source and source.typeId == dummyUnitId then
|
|
2438
2572
|
source = nil
|
|
2439
2573
|
end
|
|
2574
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2575
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2576
|
+
damagingEventByTarget[target] = nil
|
|
2440
2577
|
local data = {
|
|
2441
2578
|
amount = GetEventDamage(),
|
|
2442
|
-
attackType = BlzGetEventAttackType(),
|
|
2579
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2443
2580
|
damageType = BlzGetEventDamageType(),
|
|
2444
2581
|
weaponType = BlzGetEventWeaponType(),
|
|
2582
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2445
2583
|
isAttack = BlzGetEventIsAttack(),
|
|
2584
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2585
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2446
2586
|
preventDeath = damageEventPreventDeath
|
|
2447
2587
|
}
|
|
2588
|
+
if damagingEvent then
|
|
2589
|
+
for key, value in pairs(damagingEvent) do
|
|
2590
|
+
if isAttribute(key) then
|
|
2591
|
+
data[key] = value
|
|
2592
|
+
end
|
|
2593
|
+
end
|
|
2594
|
+
local sourceOwner = damagingEvent[1]
|
|
2595
|
+
if sourceOwner then
|
|
2596
|
+
local targetOwner = damagingEvent[2]
|
|
2597
|
+
if damagingEvent[3] then
|
|
2598
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2599
|
+
end
|
|
2600
|
+
if damagingEvent[4] then
|
|
2601
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2602
|
+
end
|
|
2603
|
+
end
|
|
2604
|
+
end
|
|
2448
2605
|
local evData = setmetatable(
|
|
2449
2606
|
{},
|
|
2450
2607
|
{
|
|
2451
2608
|
__index = data,
|
|
2452
2609
|
__newindex = function(self, key, value)
|
|
2453
|
-
damageSetters[key]
|
|
2610
|
+
local damageSetter = damageSetters[key]
|
|
2611
|
+
if damageSetter ~= nil then
|
|
2612
|
+
damageSetter(value)
|
|
2613
|
+
end
|
|
2454
2614
|
data[key] = value
|
|
2455
2615
|
end
|
|
2456
2616
|
}
|
|
2457
2617
|
)
|
|
2458
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2459
2618
|
invoke(event, source, target, evData)
|
|
2460
2619
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2461
2620
|
local bonusHealth = math.ceil(evData.amount)
|
|
2462
|
-
target[
|
|
2621
|
+
target[105] = (target[105] or 0) + bonusHealth
|
|
2463
2622
|
BlzSetUnitMaxHP(
|
|
2464
2623
|
target.handle,
|
|
2465
2624
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2473,7 +2632,7 @@ Unit.onDamage = __TS__New(
|
|
|
2473
2632
|
evData[0],
|
|
2474
2633
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2475
2634
|
)
|
|
2476
|
-
target[
|
|
2635
|
+
target[105] = (target[105] or 0) - bonusHealth
|
|
2477
2636
|
SetWidgetLife(
|
|
2478
2637
|
target.handle,
|
|
2479
2638
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2493,32 +2652,110 @@ Unit.onDamage = __TS__New(
|
|
|
2493
2652
|
DestroyTrigger(trigger)
|
|
2494
2653
|
end
|
|
2495
2654
|
)
|
|
2496
|
-
Unit.
|
|
2655
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2497
2656
|
____exports.UnitTriggerEvent,
|
|
2498
2657
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2499
2658
|
function()
|
|
2500
2659
|
local unit = getTriggerUnit()
|
|
2501
|
-
|
|
2502
|
-
|
|
2660
|
+
local item = getManipulatedItem()
|
|
2661
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2662
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2503
2663
|
end
|
|
2504
2664
|
return IgnoreEvent
|
|
2505
2665
|
end
|
|
2506
2666
|
)
|
|
2507
|
-
Unit.
|
|
2667
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2508
2668
|
____exports.UnitTriggerEvent,
|
|
2509
2669
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2510
2670
|
function()
|
|
2511
|
-
local
|
|
2512
|
-
|
|
2513
|
-
|
|
2671
|
+
local unitHandle = getTriggerUnit()
|
|
2672
|
+
local itemHandle = getManipulatedItem()
|
|
2673
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2674
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2675
|
+
local item = Item:of(itemHandle)
|
|
2676
|
+
if item.owner ~= unit then
|
|
2677
|
+
return unit, item
|
|
2678
|
+
end
|
|
2514
2679
|
end
|
|
2515
2680
|
return IgnoreEvent
|
|
2516
2681
|
end
|
|
2517
2682
|
)
|
|
2518
|
-
Unit.
|
|
2683
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2519
2684
|
____exports.UnitTriggerEvent,
|
|
2520
2685
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2521
|
-
function()
|
|
2686
|
+
function()
|
|
2687
|
+
local unit = getTriggerUnit()
|
|
2688
|
+
local item = getManipulatedItem()
|
|
2689
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2690
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2691
|
+
end
|
|
2692
|
+
return IgnoreEvent
|
|
2693
|
+
end
|
|
2694
|
+
)
|
|
2695
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2696
|
+
____exports.UnitTriggerEvent,
|
|
2697
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2698
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2699
|
+
)
|
|
2700
|
+
__TS__ObjectDefineProperty(
|
|
2701
|
+
Unit,
|
|
2702
|
+
"itemChargesChangedEvent",
|
|
2703
|
+
{get = function(self)
|
|
2704
|
+
local event = __TS__New(Event)
|
|
2705
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2706
|
+
local unit = item.owner
|
|
2707
|
+
if unit ~= nil then
|
|
2708
|
+
invoke(event, unit, item)
|
|
2709
|
+
end
|
|
2710
|
+
end)
|
|
2711
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2712
|
+
return event
|
|
2713
|
+
end}
|
|
2714
|
+
)
|
|
2715
|
+
__TS__ObjectDefineProperty(
|
|
2716
|
+
Unit,
|
|
2717
|
+
"itemUseOrderEvent",
|
|
2718
|
+
{get = function(self)
|
|
2719
|
+
local event = __TS__New(Event)
|
|
2720
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2721
|
+
local slot = order - orderId("useslot0")
|
|
2722
|
+
local function listener(unit)
|
|
2723
|
+
local item = unit.items[slot + 1]
|
|
2724
|
+
if item ~= nil then
|
|
2725
|
+
invoke(event, unit, item)
|
|
2726
|
+
end
|
|
2727
|
+
end
|
|
2728
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2729
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2730
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2731
|
+
end
|
|
2732
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2733
|
+
return event
|
|
2734
|
+
end}
|
|
2735
|
+
)
|
|
2736
|
+
__TS__ObjectDefineProperty(
|
|
2737
|
+
Unit,
|
|
2738
|
+
"itemMoveOrderEvent",
|
|
2739
|
+
{get = function(self)
|
|
2740
|
+
local event = __TS__New(Event)
|
|
2741
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2742
|
+
local slotTo = order - orderId("moveslot0")
|
|
2743
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2744
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2745
|
+
if slotFrom ~= nil then
|
|
2746
|
+
invoke(
|
|
2747
|
+
event,
|
|
2748
|
+
unit,
|
|
2749
|
+
item,
|
|
2750
|
+
slotFrom,
|
|
2751
|
+
slotTo
|
|
2752
|
+
)
|
|
2753
|
+
end
|
|
2754
|
+
end)
|
|
2755
|
+
end
|
|
2756
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2757
|
+
return event
|
|
2758
|
+
end}
|
|
2522
2759
|
)
|
|
2523
2760
|
__TS__ObjectDefineProperty(
|
|
2524
2761
|
Unit,
|
|
@@ -2567,6 +2804,15 @@ __TS__ObjectDefineProperty(
|
|
|
2567
2804
|
orderId("magicundefense"),
|
|
2568
2805
|
orderId("unimmolation")
|
|
2569
2806
|
}) do
|
|
2807
|
+
____exports.Unit.onImmediateOrder[leaveOrderId]:addListener(function(unit)
|
|
2808
|
+
local handle = unit.handle
|
|
2809
|
+
for i = 1, #leaveAbilityIds do
|
|
2810
|
+
if getUnitAbilityLevel(handle, leaveAbilityIds[i]) ~= 0 then
|
|
2811
|
+
return
|
|
2812
|
+
end
|
|
2813
|
+
end
|
|
2814
|
+
unit:destroy()
|
|
2815
|
+
end)
|
|
2570
2816
|
end
|
|
2571
2817
|
end)(Unit)
|
|
2572
2818
|
return ____exports
|