warscript 0.0.1-dev.a4deb44 → 0.0.1-dev.a58cc52
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 +12 -0
- package/attributes.lua +16 -0
- package/binaryreader.d.ts +1 -0
- package/binaryreader.lua +3 -0
- package/config.d.ts +5 -0
- package/config.lua +10 -0
- package/core/types/effect.d.ts +14 -6
- package/core/types/effect.lua +131 -35
- package/core/types/frame.d.ts +8 -1
- package/core/types/frame.lua +93 -1
- package/core/types/group.d.ts +0 -1
- package/core/types/handle.d.ts +2 -1
- package/core/types/handle.lua +5 -0
- package/core/types/image.d.ts +0 -1
- package/core/types/missile.d.ts +2 -2
- package/core/types/missile.lua +8 -2
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/timer.d.ts +6 -7
- package/core/types/timer.lua +18 -21
- package/core/types/unit.lua +8 -0
- package/core/util.d.ts +1 -1
- package/core/util.lua +18 -1
- package/decl/index.d.ts +1 -0
- package/decl/native.d.ts +840 -786
- package/engine/ability.d.ts +1 -1
- package/engine/behavior.d.ts +10 -10
- package/engine/behavior.lua +6 -6
- package/engine/behaviour/ability/always-enabled.d.ts +7 -0
- package/engine/behaviour/ability/always-enabled.lua +31 -0
- package/engine/behaviour/ability/apply-buff.d.ts +8 -5
- package/engine/behaviour/ability/apply-buff.lua +32 -0
- package/engine/behaviour/ability/apply-unit-behavior.d.ts +13 -4
- package/engine/behaviour/ability/apply-unit-behavior.lua +32 -9
- package/engine/behaviour/ability/damage.d.ts +37 -11
- package/engine/behaviour/ability/damage.lua +90 -32
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +35 -0
- package/engine/behaviour/ability/heal.d.ts +33 -6
- package/engine/behaviour/ability/heal.lua +89 -10
- package/engine/behaviour/ability/instant-impact.d.ts +2 -2
- package/engine/behaviour/ability/instant-impact.lua +4 -15
- 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 +27 -4
- package/engine/behaviour/ability.lua +152 -17
- package/engine/behaviour/unit/stun-immunity.d.ts +0 -1
- package/engine/behaviour/unit.d.ts +10 -2
- package/engine/behaviour/unit.lua +27 -0
- package/engine/buff.d.ts +103 -41
- package/engine/buff.lua +465 -212
- package/engine/game-map.d.ts +7 -0
- package/engine/game-map.lua +32 -0
- package/engine/internal/ability.d.ts +16 -13
- package/engine/internal/ability.lua +80 -76
- package/engine/internal/item/ability.lua +106 -0
- package/engine/internal/item+owner.lua +2 -2
- package/engine/internal/item.d.ts +4 -3
- package/engine/internal/item.lua +56 -25
- package/engine/internal/mechanics/ability-duration.d.ts +1 -3
- package/engine/internal/mechanics/ability-duration.lua +3 -1
- package/engine/internal/mechanics/cast-ability.d.ts +2 -0
- package/engine/internal/mechanics/cast-ability.lua +86 -0
- package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
- package/engine/internal/misc/ability-disable-counter.lua +13 -0
- package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
- package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
- package/engine/internal/object-data/evasion-probability.d.ts +2 -0
- package/engine/internal/object-data/evasion-probability.lua +16 -0
- package/engine/internal/unit/ability.d.ts +10 -1
- package/engine/internal/unit/ability.lua +36 -14
- package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
- package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot.lua +52 -0
- package/engine/internal/unit/bonus.d.ts +11 -8
- package/engine/internal/unit/bonus.lua +23 -1
- package/engine/internal/unit/detach-missiles.d.ts +7 -0
- package/engine/internal/unit/detach-missiles.lua +30 -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 +24 -0
- package/engine/internal/unit/item.lua +78 -0
- package/engine/internal/unit/main-selected.d.ts +13 -0
- package/engine/internal/unit/main-selected.lua +51 -0
- package/engine/internal/unit+ability.lua +2 -2
- package/engine/internal/unit+damage.d.ts +1 -10
- package/engine/internal/unit+damage.lua +4 -13
- package/engine/internal/unit+spellSteal.lua +1 -2
- package/engine/internal/unit+transport.lua +4 -10
- package/engine/internal/unit-missile-launch.lua +25 -6
- package/engine/internal/unit.d.ts +72 -17
- package/engine/internal/unit.lua +421 -138
- package/engine/internal/utility.lua +12 -0
- package/engine/lightning.d.ts +12 -5
- package/engine/lightning.lua +48 -14
- package/engine/local-client.d.ts +7 -2
- package/engine/local-client.lua +82 -0
- package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
- package/engine/object-data/auxiliary/animation-name.lua +16 -0
- package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -3
- 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/combat-classification.d.ts +0 -2
- 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.d.ts +0 -1
- package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
- package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
- package/engine/object-data/entry/ability-type/blink.d.ts +10 -0
- package/engine/object-data/entry/ability-type/blink.lua +39 -0
- 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/channel.d.ts +0 -1
- 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/mine.d.ts +10 -0
- package/engine/object-data/entry/ability-type/mine.lua +39 -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/spirit-touch.d.ts +2 -2
- package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
- 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 -18
- package/engine/object-data/entry/ability-type.lua +89 -33
- package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
- package/engine/object-data/entry/buff-type/applicable.lua +39 -102
- package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
- package/engine/object-data/entry/buff-type.d.ts +6 -13
- package/engine/object-data/entry/buff-type.lua +13 -29
- package/engine/object-data/entry/destructible-type.d.ts +1 -2
- package/engine/object-data/entry/item-type/blank.d.ts +0 -1
- package/engine/object-data/entry/item-type.d.ts +15 -2
- package/engine/object-data/entry/item-type.lua +93 -2
- package/engine/object-data/entry/lightning-type.d.ts +1 -2
- 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 +50 -3
- package/engine/object-data/entry/unit-type.lua +452 -61
- package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
- package/engine/object-data/entry/upgrade.d.ts +1 -2
- package/engine/object-data/entry/upgrade.lua +4 -4
- package/engine/object-data/entry.d.ts +18 -17
- package/engine/object-data/entry.lua +60 -32
- package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
- package/engine/object-field/ability.d.ts +26 -3
- package/engine/object-field/ability.lua +54 -1
- package/engine/object-field/unit.d.ts +46 -3
- package/engine/object-field/unit.lua +173 -7
- package/engine/object-field.d.ts +11 -4
- package/engine/object-field.lua +162 -76
- package/engine/random.d.ts +1 -0
- package/engine/random.lua +9 -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/entries/unit-type.d.ts +42 -1
- package/engine/standard/entries/unit-type.lua +42 -1
- package/engine/standard/fields/ability.d.ts +3 -1
- package/engine/standard/fields/ability.lua +3 -1
- package/engine/unit.d.ts +4 -0
- package/engine/unit.lua +13 -2
- package/event.d.ts +2 -3
- package/event.lua +9 -5
- package/global/vec2.lua +1 -0
- package/index.d.ts +1 -0
- package/index.lua +1 -0
- package/lualib_bundle.lua +146 -42
- package/math/vec2.d.ts +2 -9
- package/math.d.ts +0 -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/ability.d.ts +0 -1
- package/objutil/buff.d.ts +0 -1
- package/objutil/buff.lua +2 -3
- package/objutil/object.d.ts +0 -1
- package/objutil/unit.d.ts +0 -1
- package/objutil/unit.lua +8 -0
- package/package.json +13 -14
- package/patch-lua.d.ts +0 -0
- package/patch-lua.lua +10 -0
- package/property.d.ts +55 -0
- package/property.lua +374 -0
- package/string.d.ts +30 -0
- package/string.lua +14 -0
- package/util/stream.d.ts +0 -1
- package/utility/arrays.d.ts +12 -5
- package/utility/arrays.lua +37 -3
- package/utility/bit-set.d.ts +0 -2
- package/utility/functions.d.ts +1 -0
- package/utility/functions.lua +1 -0
- package/utility/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
- package/utility/linked-set.d.ts +12 -3
- package/utility/linked-set.lua +8 -2
- package/utility/lua-maps.d.ts +4 -2
- package/utility/lua-maps.lua +16 -0
- package/utility/lua-sets.d.ts +2 -2
- package/utility/lua-sets.lua +3 -0
- package/utility/reflection.lua +11 -7
- package/utility/types.d.ts +3 -2
- package/core/mapbounds.d.ts +0 -8
- package/core/mapbounds.lua +0 -12
package/engine/internal/unit.lua
CHANGED
|
@@ -5,9 +5,12 @@ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
|
5
5
|
local __TS__New = ____lualib.__TS__New
|
|
6
6
|
local __TS__Class = ____lualib.__TS__Class
|
|
7
7
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
8
|
+
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
8
9
|
local __TS__ArraySetLength = ____lualib.__TS__ArraySetLength
|
|
10
|
+
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
|
|
11
|
+
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
|
|
12
|
+
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
|
|
9
13
|
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
10
|
-
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
11
14
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
12
15
|
local Set = ____lualib.Set
|
|
13
16
|
local __TS__Spread = ____lualib.__TS__Spread
|
|
@@ -48,11 +51,17 @@ local ____arrays = require("utility.arrays")
|
|
|
48
51
|
local forEach = ____arrays.forEach
|
|
49
52
|
local ____math = require("math")
|
|
50
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
|
|
51
59
|
local match = string.match
|
|
52
60
|
local ____tostring = _G.tostring
|
|
53
61
|
local setUnitAnimation = SetUnitAnimation
|
|
54
62
|
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
55
63
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
64
|
+
local resetUnitAnimation = ResetUnitAnimation
|
|
56
65
|
local queueUnitAnimation = QueueUnitAnimation
|
|
57
66
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
58
67
|
local getUnitRealField = BlzGetUnitRealField
|
|
@@ -72,6 +81,7 @@ local setUnitScale = SetUnitScale
|
|
|
72
81
|
local setUnitPosition = SetUnitPosition
|
|
73
82
|
local setUnitTimeScale = SetUnitTimeScale
|
|
74
83
|
local getHandleId = GetHandleId
|
|
84
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
75
85
|
local createUnit = CreateUnit
|
|
76
86
|
local killUnit = KillUnit
|
|
77
87
|
local setUnitExploded = SetUnitExploded
|
|
@@ -92,6 +102,10 @@ local isUnitInRangeXY = IsUnitInRangeXY
|
|
|
92
102
|
local isUnitInRange = IsUnitInRange
|
|
93
103
|
local setResourceAmount = SetResourceAmount
|
|
94
104
|
local getResourceAmount = GetResourceAmount
|
|
105
|
+
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
106
|
+
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
107
|
+
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
108
|
+
local setUnitWeaponStringField = BlzSetUnitWeaponStringField
|
|
95
109
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
96
110
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
97
111
|
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
@@ -275,16 +289,14 @@ function UnitTriggerEvent.prototype.____constructor(self, eventType, c)
|
|
|
275
289
|
end
|
|
276
290
|
local function dispatch(event, idGetter, argsGetter)
|
|
277
291
|
local initialized = false
|
|
278
|
-
local x = {}
|
|
279
292
|
return setmetatable(
|
|
280
|
-
|
|
293
|
+
{},
|
|
281
294
|
{
|
|
282
295
|
__index = function(self, id)
|
|
283
296
|
if type(id) ~= "number" then
|
|
284
297
|
return event[id]
|
|
285
298
|
end
|
|
286
299
|
if not initialized then
|
|
287
|
-
local invoke = Event.invoke
|
|
288
300
|
event:addListener(function(...)
|
|
289
301
|
local id = idGetter(...)
|
|
290
302
|
local dispatched = rawget(self, id)
|
|
@@ -322,7 +334,6 @@ local function dispatchAbility(event)
|
|
|
322
334
|
return event[id]
|
|
323
335
|
end
|
|
324
336
|
if not initialized then
|
|
325
|
-
local invoke = Event.invoke
|
|
326
337
|
event:addListener(function(unit, ability, ...)
|
|
327
338
|
local dispatched = rawget(self, ability.typeId)
|
|
328
339
|
if dispatched ~= nil then
|
|
@@ -350,7 +361,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
350
361
|
rawset(self, 1 + i, (select(i, ...)))
|
|
351
362
|
end
|
|
352
363
|
end
|
|
353
|
-
local damageSetters = {
|
|
364
|
+
local damageSetters = {
|
|
365
|
+
amount = BlzSetEventDamage,
|
|
366
|
+
attackType = function(attackType)
|
|
367
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
368
|
+
end,
|
|
369
|
+
damageType = BlzSetEventDamageType,
|
|
370
|
+
weaponType = BlzSetEventWeaponType
|
|
371
|
+
}
|
|
354
372
|
local jlimitopByOperator = {
|
|
355
373
|
[0] = LESS_THAN_OR_EQUAL,
|
|
356
374
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -387,51 +405,158 @@ local getters = {
|
|
|
387
405
|
return BlzGetUnitArmor(unit)
|
|
388
406
|
end
|
|
389
407
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
408
|
+
____exports.UnitWeapon = __TS__Class()
|
|
409
|
+
local UnitWeapon = ____exports.UnitWeapon
|
|
410
|
+
UnitWeapon.name = "UnitWeapon"
|
|
411
|
+
function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
412
|
+
self.unit = unit
|
|
413
|
+
self.index = index
|
|
414
|
+
end
|
|
415
|
+
__TS__SetDescriptor(
|
|
416
|
+
UnitWeapon.prototype,
|
|
417
|
+
"cooldown",
|
|
418
|
+
{
|
|
419
|
+
get = function(self)
|
|
420
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index)
|
|
421
|
+
end,
|
|
422
|
+
set = function(self, cooldown)
|
|
423
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index, cooldown)
|
|
424
|
+
end
|
|
425
|
+
},
|
|
426
|
+
true
|
|
427
|
+
)
|
|
428
|
+
__TS__SetDescriptor(
|
|
429
|
+
UnitWeapon.prototype,
|
|
430
|
+
"damage",
|
|
431
|
+
{
|
|
432
|
+
get = function(self)
|
|
433
|
+
local minimumDamage = self.damageBase + self.damageDiceCount
|
|
434
|
+
local maximumDamage = self.damageBase + self.damageDiceCount * self.damageDiceSideCount
|
|
435
|
+
return {minimumDamage, maximumDamage}
|
|
436
|
+
end,
|
|
437
|
+
set = function(self, ____bindingPattern0)
|
|
438
|
+
local maximumDamage
|
|
439
|
+
local minimumDamage
|
|
440
|
+
minimumDamage = ____bindingPattern0[1]
|
|
441
|
+
maximumDamage = ____bindingPattern0[2]
|
|
442
|
+
self.damageBase = minimumDamage - 1
|
|
443
|
+
self.damageDiceCount = 1
|
|
444
|
+
self.damageDiceSideCount = maximumDamage - minimumDamage + 1
|
|
445
|
+
end
|
|
446
|
+
},
|
|
447
|
+
true
|
|
448
|
+
)
|
|
449
|
+
__TS__SetDescriptor(
|
|
450
|
+
UnitWeapon.prototype,
|
|
451
|
+
"damageBase",
|
|
452
|
+
{
|
|
453
|
+
get = function(self)
|
|
454
|
+
return BlzGetUnitBaseDamage(self.unit.handle, self.index)
|
|
455
|
+
end,
|
|
456
|
+
set = function(self, damageBase)
|
|
457
|
+
BlzSetUnitBaseDamage(self.unit.handle, self.index, damageBase)
|
|
458
|
+
end
|
|
459
|
+
},
|
|
460
|
+
true
|
|
461
|
+
)
|
|
462
|
+
__TS__SetDescriptor(
|
|
463
|
+
UnitWeapon.prototype,
|
|
464
|
+
"damageDiceCount",
|
|
465
|
+
{
|
|
466
|
+
get = function(self)
|
|
467
|
+
return BlzGetUnitDiceNumber(self.unit.handle, self.index)
|
|
468
|
+
end,
|
|
469
|
+
set = function(self, damageDiceCount)
|
|
470
|
+
BlzSetUnitDiceNumber(self.unit.handle, self.index, damageDiceCount)
|
|
471
|
+
end
|
|
472
|
+
},
|
|
473
|
+
true
|
|
474
|
+
)
|
|
475
|
+
__TS__SetDescriptor(
|
|
476
|
+
UnitWeapon.prototype,
|
|
477
|
+
"damageDiceSideCount",
|
|
478
|
+
{
|
|
479
|
+
get = function(self)
|
|
480
|
+
return BlzGetUnitDiceSides(self.unit.handle, self.index)
|
|
481
|
+
end,
|
|
482
|
+
set = function(self, damageDiceSideCount)
|
|
483
|
+
BlzSetUnitDiceSides(self.unit.handle, self.index, damageDiceSideCount)
|
|
484
|
+
end
|
|
485
|
+
},
|
|
486
|
+
true
|
|
487
|
+
)
|
|
488
|
+
__TS__SetDescriptor(
|
|
489
|
+
UnitWeapon.prototype,
|
|
490
|
+
"range",
|
|
491
|
+
{
|
|
492
|
+
get = function(self)
|
|
493
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_RANGE, self.index)
|
|
494
|
+
end,
|
|
495
|
+
set = function(self, range)
|
|
496
|
+
local handle = self.unit.handle
|
|
497
|
+
local index = self.index
|
|
498
|
+
setUnitWeaponRealField(
|
|
499
|
+
handle,
|
|
500
|
+
UNIT_WEAPON_RF_ATTACK_RANGE,
|
|
501
|
+
index + 1,
|
|
502
|
+
getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index + 1) + (range - getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index))
|
|
503
|
+
)
|
|
504
|
+
end
|
|
505
|
+
},
|
|
506
|
+
true
|
|
507
|
+
)
|
|
508
|
+
__TS__SetDescriptor(
|
|
509
|
+
UnitWeapon.prototype,
|
|
510
|
+
"impactDelay",
|
|
511
|
+
{
|
|
512
|
+
get = function(self)
|
|
513
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index)
|
|
514
|
+
end,
|
|
515
|
+
set = function(self, impactDelay)
|
|
516
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index, impactDelay)
|
|
517
|
+
end
|
|
518
|
+
},
|
|
519
|
+
true
|
|
520
|
+
)
|
|
521
|
+
__TS__SetDescriptor(
|
|
522
|
+
UnitWeapon.prototype,
|
|
523
|
+
"missileArc",
|
|
524
|
+
{
|
|
525
|
+
get = function(self)
|
|
526
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index)
|
|
527
|
+
end,
|
|
528
|
+
set = function(self, missileArc)
|
|
529
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index, missileArc)
|
|
530
|
+
end
|
|
531
|
+
},
|
|
532
|
+
true
|
|
533
|
+
)
|
|
534
|
+
__TS__SetDescriptor(
|
|
535
|
+
UnitWeapon.prototype,
|
|
536
|
+
"missileModelPath",
|
|
537
|
+
{
|
|
538
|
+
get = function(self)
|
|
539
|
+
return getUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index)
|
|
540
|
+
end,
|
|
541
|
+
set = function(self, missileModelPath)
|
|
542
|
+
setUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index, missileModelPath)
|
|
543
|
+
end
|
|
544
|
+
},
|
|
545
|
+
true
|
|
546
|
+
)
|
|
547
|
+
__TS__SetDescriptor(
|
|
548
|
+
UnitWeapon.prototype,
|
|
549
|
+
"missileSpeed",
|
|
550
|
+
{
|
|
551
|
+
get = function(self)
|
|
552
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index)
|
|
553
|
+
end,
|
|
554
|
+
set = function(self, missileSpeed)
|
|
555
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index, missileSpeed)
|
|
556
|
+
end
|
|
557
|
+
},
|
|
558
|
+
true
|
|
559
|
+
)
|
|
435
560
|
local unitInventorySize = UnitInventorySize
|
|
436
561
|
local unitItemInSlot = UnitItemInSlot
|
|
437
562
|
local getItemAbility = BlzGetItemAbility
|
|
@@ -442,8 +567,6 @@ local getAbilityName = GetAbilityName
|
|
|
442
567
|
local unitAddAbility = UnitAddAbility
|
|
443
568
|
local getUnitGoldCost = GetUnitGoldCost
|
|
444
569
|
local getUnitLumberCost = GetUnitWoodCost
|
|
445
|
-
local unitMakeAbilityPermanent = UnitMakeAbilityPermanent
|
|
446
|
-
local unitAddItem = UnitAddItem
|
|
447
570
|
local unitRemoveAbility = UnitRemoveAbility
|
|
448
571
|
local function retrieveAbility(unit, ability, abilityId)
|
|
449
572
|
if ability == nil then
|
|
@@ -453,17 +576,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
453
576
|
____exports.Unit:of(unit)
|
|
454
577
|
)
|
|
455
578
|
end
|
|
456
|
-
if not unitAddAbility(unit, abilityId) then
|
|
457
|
-
if getUnitAbility(unit, abilityId) == ability then
|
|
458
|
-
return UnitAbility:of(
|
|
459
|
-
ability,
|
|
460
|
-
abilityId,
|
|
461
|
-
____exports.Unit:of(unit)
|
|
462
|
-
)
|
|
463
|
-
end
|
|
464
|
-
else
|
|
465
|
-
unitRemoveAbility(unit, abilityId)
|
|
466
|
-
end
|
|
467
579
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
468
580
|
local item = unitItemInSlot(unit, i)
|
|
469
581
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -520,12 +632,34 @@ for ____, player in ipairs(Player.all) do
|
|
|
520
632
|
ShowUnit(dummy, false)
|
|
521
633
|
dummies[player] = dummy
|
|
522
634
|
end
|
|
635
|
+
local function delayHealthChecksCallback(unit)
|
|
636
|
+
local counter = (unit[103] or 0) - 1
|
|
637
|
+
if counter ~= 0 then
|
|
638
|
+
unit[103] = counter
|
|
639
|
+
return
|
|
640
|
+
end
|
|
641
|
+
unit[103] = nil
|
|
642
|
+
local healthBonus = unit[104]
|
|
643
|
+
if healthBonus ~= nil then
|
|
644
|
+
unit[104] = nil
|
|
645
|
+
local handle = unit.handle
|
|
646
|
+
BlzSetUnitMaxHP(
|
|
647
|
+
handle,
|
|
648
|
+
BlzGetUnitMaxHP(handle) - healthBonus
|
|
649
|
+
)
|
|
650
|
+
end
|
|
651
|
+
end
|
|
652
|
+
local nextSyncId = 1
|
|
653
|
+
local unitBySyncId = setmetatable({}, {__mode = "k"})
|
|
523
654
|
____exports.Unit = __TS__Class()
|
|
524
655
|
local Unit = ____exports.Unit
|
|
525
656
|
Unit.name = "Unit"
|
|
526
657
|
__TS__ClassExtends(Unit, Handle)
|
|
527
658
|
function Unit.prototype.____constructor(self, handle)
|
|
528
659
|
Handle.prototype.____constructor(self, handle)
|
|
660
|
+
local ____nextSyncId_0 = nextSyncId
|
|
661
|
+
nextSyncId = ____nextSyncId_0 + 1
|
|
662
|
+
self.syncId = ____nextSyncId_0
|
|
529
663
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
530
664
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
531
665
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -538,6 +672,7 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
538
672
|
fourCC("Amrf")
|
|
539
673
|
))
|
|
540
674
|
end
|
|
675
|
+
unitBySyncId[self.syncId] = self
|
|
541
676
|
local ____ = self.abilities
|
|
542
677
|
end
|
|
543
678
|
function Unit.prototype.getEvent(self, event, collector)
|
|
@@ -556,6 +691,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
556
691
|
end
|
|
557
692
|
function Unit.prototype.onDestroy(self)
|
|
558
693
|
local handle = self.handle
|
|
694
|
+
self[107] = getUnitX(handle)
|
|
695
|
+
self[108] = getUnitY(handle)
|
|
559
696
|
if not self._owner then
|
|
560
697
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
561
698
|
end
|
|
@@ -623,8 +760,8 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
623
760
|
end}
|
|
624
761
|
end
|
|
625
762
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
626
|
-
local
|
|
627
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
763
|
+
local ____combatClassification_1 = combatClassification
|
|
764
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
|
|
628
765
|
end
|
|
629
766
|
function Unit.prototype.addClassification(self, classification)
|
|
630
767
|
return unitAddType(self.handle, classification)
|
|
@@ -642,13 +779,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
642
779
|
return isUnitInvisible(self.handle, player.handle)
|
|
643
780
|
end
|
|
644
781
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
645
|
-
local
|
|
782
|
+
local ____temp_2
|
|
646
783
|
if type(x) == "number" then
|
|
647
|
-
|
|
784
|
+
____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
|
|
648
785
|
else
|
|
649
|
-
|
|
786
|
+
____temp_2 = isUnitInRange(self.handle, x.handle, y)
|
|
650
787
|
end
|
|
651
|
-
return
|
|
788
|
+
return ____temp_2
|
|
652
789
|
end
|
|
653
790
|
function Unit.prototype.isAllyOf(self, unit)
|
|
654
791
|
return isUnitAlly(
|
|
@@ -671,9 +808,16 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
671
808
|
setUnitAnimation(self.handle, animation)
|
|
672
809
|
end
|
|
673
810
|
end
|
|
811
|
+
function Unit.prototype.resetAnimation(self)
|
|
812
|
+
resetUnitAnimation(self.handle)
|
|
813
|
+
end
|
|
674
814
|
function Unit.prototype.queueAnimation(self, animation)
|
|
675
815
|
queueUnitAnimation(self.handle, animation)
|
|
676
816
|
end
|
|
817
|
+
function Unit.prototype.delayHealthChecks(self)
|
|
818
|
+
self[103] = (self[103] or 0) + 1
|
|
819
|
+
Timer:run(delayHealthChecksCallback, self)
|
|
820
|
+
end
|
|
677
821
|
function Unit.prototype.setPosition(self, x, y)
|
|
678
822
|
setUnitPosition(self.handle, x, y)
|
|
679
823
|
end
|
|
@@ -687,8 +831,15 @@ end
|
|
|
687
831
|
function Unit.prototype.kill(self)
|
|
688
832
|
killUnit(self.handle)
|
|
689
833
|
end
|
|
690
|
-
function Unit.prototype.revive(self,
|
|
691
|
-
|
|
834
|
+
function Unit.prototype.revive(self, x, y, doEffect)
|
|
835
|
+
local ____ReviveHero_5 = ReviveHero
|
|
836
|
+
local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
|
|
837
|
+
local ____doEffect_3 = doEffect
|
|
838
|
+
if ____doEffect_3 == nil then
|
|
839
|
+
____doEffect_3 = false
|
|
840
|
+
end
|
|
841
|
+
__TS__SparseArrayPush(____array_4, ____doEffect_3)
|
|
842
|
+
____ReviveHero_5(__TS__SparseArraySpread(____array_4))
|
|
692
843
|
end
|
|
693
844
|
function Unit.prototype.healTarget(self, target, amount)
|
|
694
845
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -728,7 +879,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
728
879
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
729
880
|
end
|
|
730
881
|
function Unit.prototype.itemInSlot(self, slot)
|
|
731
|
-
return Item:of(
|
|
882
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
732
883
|
end
|
|
733
884
|
function Unit.prototype.addAbility(self, abilityId)
|
|
734
885
|
if unitAddAbility(self.handle, abilityId) then
|
|
@@ -784,6 +935,9 @@ end
|
|
|
784
935
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
785
936
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
786
937
|
end
|
|
938
|
+
function Unit.prototype.getAbilityRemainingCooldown(self, abilityId)
|
|
939
|
+
return BlzGetUnitAbilityCooldownRemaining(self.handle, abilityId)
|
|
940
|
+
end
|
|
787
941
|
function Unit.prototype.startAbilityCooldown(self, abilityId, cooldown)
|
|
788
942
|
BlzStartUnitAbilityCooldown(self.handle, abilityId, cooldown)
|
|
789
943
|
end
|
|
@@ -794,8 +948,15 @@ function Unit.prototype.interruptAttack(self)
|
|
|
794
948
|
unitInterruptAttack(self.handle)
|
|
795
949
|
end
|
|
796
950
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
797
|
-
|
|
798
|
-
unitDisableAbility(
|
|
951
|
+
local handle = self.handle
|
|
952
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
953
|
+
Timer:run(
|
|
954
|
+
unitDisableAbility,
|
|
955
|
+
handle,
|
|
956
|
+
abilityId,
|
|
957
|
+
false,
|
|
958
|
+
false
|
|
959
|
+
)
|
|
799
960
|
end
|
|
800
961
|
function Unit.prototype.getDistanceTo(self, target)
|
|
801
962
|
local handle = self.handle
|
|
@@ -855,18 +1016,18 @@ function Unit.prototype.unpauseEx(self)
|
|
|
855
1016
|
self:decrementStunCounter()
|
|
856
1017
|
end
|
|
857
1018
|
function Unit.prototype.incrementStunCounter(self)
|
|
858
|
-
local stunCounter = self[
|
|
859
|
-
if not self[
|
|
1019
|
+
local stunCounter = self[102] or 0
|
|
1020
|
+
if not self[101] or stunCounter >= 0 then
|
|
860
1021
|
BlzPauseUnitEx(self.handle, true)
|
|
861
1022
|
end
|
|
862
|
-
self[
|
|
1023
|
+
self[102] = stunCounter + 1
|
|
863
1024
|
end
|
|
864
1025
|
function Unit.prototype.decrementStunCounter(self)
|
|
865
|
-
local stunCounter = self[
|
|
866
|
-
if not self[
|
|
1026
|
+
local stunCounter = self[102] or 0
|
|
1027
|
+
if not self[101] or stunCounter >= 1 then
|
|
867
1028
|
BlzPauseUnitEx(self.handle, false)
|
|
868
1029
|
end
|
|
869
|
-
self[
|
|
1030
|
+
self[102] = stunCounter - 1
|
|
870
1031
|
end
|
|
871
1032
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
872
1033
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -968,8 +1129,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
968
1129
|
)
|
|
969
1130
|
return targetCollection
|
|
970
1131
|
end
|
|
971
|
-
function Unit.getSelectionOf(self, player)
|
|
972
|
-
|
|
1132
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1133
|
+
if target == nil then
|
|
1134
|
+
target = {}
|
|
1135
|
+
end
|
|
1136
|
+
targetCollection = target
|
|
973
1137
|
targetCollectionNextIndex = 1
|
|
974
1138
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
975
1139
|
return targetCollection
|
|
@@ -991,6 +1155,9 @@ end
|
|
|
991
1155
|
function Unit.prototype.__tostring(self)
|
|
992
1156
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
993
1157
|
end
|
|
1158
|
+
function Unit.getBySyncId(self, syncId)
|
|
1159
|
+
return unitBySyncId[syncId]
|
|
1160
|
+
end
|
|
994
1161
|
__TS__SetDescriptor(
|
|
995
1162
|
Unit.prototype,
|
|
996
1163
|
"_deltas",
|
|
@@ -1054,6 +1221,14 @@ __TS__SetDescriptor(
|
|
|
1054
1221
|
end},
|
|
1055
1222
|
true
|
|
1056
1223
|
)
|
|
1224
|
+
__TS__SetDescriptor(
|
|
1225
|
+
Unit.prototype,
|
|
1226
|
+
"isStunned",
|
|
1227
|
+
{get = function(self)
|
|
1228
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1229
|
+
end},
|
|
1230
|
+
true
|
|
1231
|
+
)
|
|
1057
1232
|
__TS__SetDescriptor(
|
|
1058
1233
|
Unit.prototype,
|
|
1059
1234
|
"combatClassifications",
|
|
@@ -1071,12 +1246,27 @@ __TS__SetDescriptor(
|
|
|
1071
1246
|
Unit.prototype,
|
|
1072
1247
|
"weapons",
|
|
1073
1248
|
{get = function(self)
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1249
|
+
return {self.firstWeapon, self.secondWeapon}
|
|
1250
|
+
end},
|
|
1251
|
+
true
|
|
1252
|
+
)
|
|
1253
|
+
__TS__SetDescriptor(
|
|
1254
|
+
Unit.prototype,
|
|
1255
|
+
"firstWeapon",
|
|
1256
|
+
{get = function(self)
|
|
1257
|
+
local weapon = __TS__New(____exports.UnitWeapon, self, 0)
|
|
1258
|
+
rawset(self, "firstWeapon", weapon)
|
|
1259
|
+
return weapon
|
|
1260
|
+
end},
|
|
1261
|
+
true
|
|
1262
|
+
)
|
|
1263
|
+
__TS__SetDescriptor(
|
|
1264
|
+
Unit.prototype,
|
|
1265
|
+
"secondWeapon",
|
|
1266
|
+
{get = function(self)
|
|
1267
|
+
local weapon = __TS__New(____exports.UnitWeapon, self, 1)
|
|
1268
|
+
rawset(self, "secondWeapon", weapon)
|
|
1269
|
+
return weapon
|
|
1080
1270
|
end},
|
|
1081
1271
|
true
|
|
1082
1272
|
)
|
|
@@ -1112,6 +1302,19 @@ __TS__SetDescriptor(
|
|
|
1112
1302
|
},
|
|
1113
1303
|
true
|
|
1114
1304
|
)
|
|
1305
|
+
__TS__SetDescriptor(
|
|
1306
|
+
Unit.prototype,
|
|
1307
|
+
"primaryAttribute",
|
|
1308
|
+
{
|
|
1309
|
+
get = function(self)
|
|
1310
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1311
|
+
end,
|
|
1312
|
+
set = function(self, primaryAttribute)
|
|
1313
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1314
|
+
end
|
|
1315
|
+
},
|
|
1316
|
+
true
|
|
1317
|
+
)
|
|
1115
1318
|
__TS__SetDescriptor(
|
|
1116
1319
|
Unit.prototype,
|
|
1117
1320
|
"strengthBase",
|
|
@@ -1233,17 +1436,17 @@ __TS__SetDescriptor(
|
|
|
1233
1436
|
"isTeamGlowVisible",
|
|
1234
1437
|
{
|
|
1235
1438
|
get = function(self)
|
|
1236
|
-
return not self[
|
|
1439
|
+
return not self[106]
|
|
1237
1440
|
end,
|
|
1238
1441
|
set = function(self, isTeamGlowVisible)
|
|
1239
1442
|
showUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1240
|
-
local
|
|
1443
|
+
local ____temp_6
|
|
1241
1444
|
if not isTeamGlowVisible then
|
|
1242
|
-
|
|
1445
|
+
____temp_6 = true
|
|
1243
1446
|
else
|
|
1244
|
-
|
|
1447
|
+
____temp_6 = nil
|
|
1245
1448
|
end
|
|
1246
|
-
self[
|
|
1449
|
+
self[106] = ____temp_6
|
|
1247
1450
|
end
|
|
1248
1451
|
},
|
|
1249
1452
|
true
|
|
@@ -1253,7 +1456,7 @@ __TS__SetDescriptor(
|
|
|
1253
1456
|
"color",
|
|
1254
1457
|
{set = function(self, color)
|
|
1255
1458
|
setUnitColor(self.handle, color.handle)
|
|
1256
|
-
if self[
|
|
1459
|
+
if self[106] then
|
|
1257
1460
|
showUnitTeamGlow(self.handle, false)
|
|
1258
1461
|
end
|
|
1259
1462
|
end},
|
|
@@ -1277,10 +1480,14 @@ __TS__SetDescriptor(
|
|
|
1277
1480
|
"maxHealth",
|
|
1278
1481
|
{
|
|
1279
1482
|
get = function(self)
|
|
1280
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1483
|
+
return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
|
|
1281
1484
|
end,
|
|
1282
1485
|
set = function(self, maxHealth)
|
|
1283
|
-
|
|
1486
|
+
if maxHealth < 1 and self[103] ~= nil then
|
|
1487
|
+
self[104] = (self[104] or 0) + (1 - maxHealth)
|
|
1488
|
+
maxHealth = 1
|
|
1489
|
+
end
|
|
1490
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
|
|
1284
1491
|
end
|
|
1285
1492
|
},
|
|
1286
1493
|
true
|
|
@@ -1322,10 +1529,10 @@ __TS__SetDescriptor(
|
|
|
1322
1529
|
"health",
|
|
1323
1530
|
{
|
|
1324
1531
|
get = function(self)
|
|
1325
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1532
|
+
return GetWidgetLife(self.handle) - (self[105] or 0)
|
|
1326
1533
|
end,
|
|
1327
1534
|
set = function(self, health)
|
|
1328
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1535
|
+
SetWidgetLife(self.handle, health + (self[105] or 0))
|
|
1329
1536
|
end
|
|
1330
1537
|
},
|
|
1331
1538
|
true
|
|
@@ -1419,7 +1626,7 @@ __TS__SetDescriptor(
|
|
|
1419
1626
|
"x",
|
|
1420
1627
|
{
|
|
1421
1628
|
get = function(self)
|
|
1422
|
-
return getUnitX(self.handle)
|
|
1629
|
+
return self[107] or getUnitX(self.handle)
|
|
1423
1630
|
end,
|
|
1424
1631
|
set = function(self, v)
|
|
1425
1632
|
SetUnitX(self.handle, v)
|
|
@@ -1432,7 +1639,7 @@ __TS__SetDescriptor(
|
|
|
1432
1639
|
"y",
|
|
1433
1640
|
{
|
|
1434
1641
|
get = function(self)
|
|
1435
|
-
return getUnitY(self.handle)
|
|
1642
|
+
return self[108] or getUnitY(self.handle)
|
|
1436
1643
|
end,
|
|
1437
1644
|
set = function(self, v)
|
|
1438
1645
|
SetUnitY(self.handle, v)
|
|
@@ -1536,17 +1743,17 @@ __TS__SetDescriptor(
|
|
|
1536
1743
|
set = function(self, isPaused)
|
|
1537
1744
|
local handle = self.handle
|
|
1538
1745
|
if isPaused and not IsUnitPaused(handle) then
|
|
1539
|
-
self[
|
|
1540
|
-
for _ = self[
|
|
1746
|
+
self[101] = true
|
|
1747
|
+
for _ = self[102] or 0, -1 do
|
|
1541
1748
|
BlzPauseUnitEx(handle, true)
|
|
1542
1749
|
end
|
|
1543
1750
|
PauseUnit(handle, true)
|
|
1544
1751
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1545
1752
|
PauseUnit(handle, false)
|
|
1546
|
-
for _ = self[
|
|
1753
|
+
for _ = self[102] or 0, -1 do
|
|
1547
1754
|
BlzPauseUnitEx(handle, false)
|
|
1548
1755
|
end
|
|
1549
|
-
self[
|
|
1756
|
+
self[101] = nil
|
|
1550
1757
|
end
|
|
1551
1758
|
end
|
|
1552
1759
|
},
|
|
@@ -1649,6 +1856,19 @@ __TS__SetDescriptor(
|
|
|
1649
1856
|
end},
|
|
1650
1857
|
true
|
|
1651
1858
|
)
|
|
1859
|
+
__TS__SetDescriptor(
|
|
1860
|
+
Unit.prototype,
|
|
1861
|
+
"movementType",
|
|
1862
|
+
{
|
|
1863
|
+
get = function(self)
|
|
1864
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1865
|
+
end,
|
|
1866
|
+
set = function(self, movementType)
|
|
1867
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1868
|
+
end
|
|
1869
|
+
},
|
|
1870
|
+
true
|
|
1871
|
+
)
|
|
1652
1872
|
__TS__SetDescriptor(
|
|
1653
1873
|
Unit.prototype,
|
|
1654
1874
|
"pathing",
|
|
@@ -1903,7 +2123,6 @@ Unit.onDecay = __TS__New(
|
|
|
1903
2123
|
Unit.onResurrect = __TS__New(
|
|
1904
2124
|
InitializingEvent,
|
|
1905
2125
|
function(event)
|
|
1906
|
-
local invoke = Event.invoke
|
|
1907
2126
|
local dead = setmetatable({}, {__mode = "k"})
|
|
1908
2127
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
1909
2128
|
dead[unit] = true
|
|
@@ -1919,10 +2138,15 @@ Unit.onResurrect = __TS__New(
|
|
|
1919
2138
|
Unit.morphEvent = __TS__New(
|
|
1920
2139
|
InitializingEvent,
|
|
1921
2140
|
function(event)
|
|
2141
|
+
local function ifNotLeft(unit)
|
|
2142
|
+
local handle = unit.handle
|
|
2143
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2144
|
+
invoke(event, unit)
|
|
2145
|
+
end
|
|
2146
|
+
end
|
|
1922
2147
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
1923
2148
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
1924
|
-
|
|
1925
|
-
Timer:run(Event.invoke, event, unit)
|
|
2149
|
+
Timer:run(ifNotLeft, unit)
|
|
1926
2150
|
end
|
|
1927
2151
|
end)
|
|
1928
2152
|
end
|
|
@@ -1960,27 +2184,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
1960
2184
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
1961
2185
|
InitializingEvent,
|
|
1962
2186
|
function(event)
|
|
1963
|
-
local invoke = Event.invoke
|
|
1964
2187
|
local function listener(unit, id)
|
|
1965
|
-
local
|
|
2188
|
+
local ____GetSpellTargetUnit_result_9
|
|
1966
2189
|
if GetSpellTargetUnit() then
|
|
1967
|
-
|
|
2190
|
+
____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
1968
2191
|
else
|
|
1969
|
-
local
|
|
2192
|
+
local ____GetSpellTargetItem_result_8
|
|
1970
2193
|
if GetSpellTargetItem() then
|
|
1971
|
-
|
|
2194
|
+
____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
|
|
1972
2195
|
else
|
|
1973
|
-
local
|
|
2196
|
+
local ____GetSpellTargetDestructable_result_7
|
|
1974
2197
|
if GetSpellTargetDestructable() then
|
|
1975
|
-
|
|
2198
|
+
____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
|
|
1976
2199
|
else
|
|
1977
|
-
|
|
2200
|
+
____GetSpellTargetDestructable_result_7 = nil
|
|
1978
2201
|
end
|
|
1979
|
-
|
|
2202
|
+
____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
|
|
1980
2203
|
end
|
|
1981
|
-
|
|
2204
|
+
____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
|
|
1982
2205
|
end
|
|
1983
|
-
local target =
|
|
2206
|
+
local target = ____GetSpellTargetUnit_result_9
|
|
1984
2207
|
if target then
|
|
1985
2208
|
invoke(event, unit, id, target)
|
|
1986
2209
|
end
|
|
@@ -2152,10 +2375,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2152
2375
|
____exports.UnitTriggerEvent,
|
|
2153
2376
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2154
2377
|
function()
|
|
2155
|
-
local
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2378
|
+
local handle = getOrderedUnit()
|
|
2379
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2380
|
+
local unit = ____exports.Unit:of(handle)
|
|
2381
|
+
if unit.state == 1 then
|
|
2382
|
+
return unit, getIssuedOrderId()
|
|
2383
|
+
end
|
|
2159
2384
|
end
|
|
2160
2385
|
return IgnoreEvent
|
|
2161
2386
|
end
|
|
@@ -2177,7 +2402,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2177
2402
|
)
|
|
2178
2403
|
Unit.onDamaging = (function()
|
|
2179
2404
|
local event = __TS__New(Event)
|
|
2180
|
-
local invoke = Event.invoke
|
|
2181
2405
|
local trigger = CreateTrigger()
|
|
2182
2406
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2183
2407
|
TriggerAddCondition(
|
|
@@ -2190,7 +2414,7 @@ Unit.onDamaging = (function()
|
|
|
2190
2414
|
local target = BlzGetEventDamageTarget()
|
|
2191
2415
|
local data = {
|
|
2192
2416
|
amount = GetEventDamage(),
|
|
2193
|
-
attackType = BlzGetEventAttackType(),
|
|
2417
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2194
2418
|
damageType = BlzGetEventDamageType(),
|
|
2195
2419
|
weaponType = BlzGetEventWeaponType(),
|
|
2196
2420
|
isAttack = BlzGetEventIsAttack()
|
|
@@ -2258,7 +2482,7 @@ Unit.onDamaging = (function()
|
|
|
2258
2482
|
data.amount,
|
|
2259
2483
|
true,
|
|
2260
2484
|
true,
|
|
2261
|
-
data.attackType,
|
|
2485
|
+
attackTypeToNative(data.attackType),
|
|
2262
2486
|
data.damageType,
|
|
2263
2487
|
data.weaponType
|
|
2264
2488
|
)
|
|
@@ -2276,7 +2500,6 @@ end)()
|
|
|
2276
2500
|
Unit.onDamage = __TS__New(
|
|
2277
2501
|
InitializingEvent,
|
|
2278
2502
|
function(event)
|
|
2279
|
-
local invoke = Event.invoke
|
|
2280
2503
|
local trigger = CreateTrigger()
|
|
2281
2504
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2282
2505
|
TriggerAddCondition(
|
|
@@ -2288,10 +2511,11 @@ Unit.onDamage = __TS__New(
|
|
|
2288
2511
|
end
|
|
2289
2512
|
local data = {
|
|
2290
2513
|
amount = GetEventDamage(),
|
|
2291
|
-
attackType = BlzGetEventAttackType(),
|
|
2514
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2292
2515
|
damageType = BlzGetEventDamageType(),
|
|
2293
2516
|
weaponType = BlzGetEventWeaponType(),
|
|
2294
2517
|
isAttack = BlzGetEventIsAttack(),
|
|
2518
|
+
originalAmount = GetEventDamage(),
|
|
2295
2519
|
preventDeath = damageEventPreventDeath
|
|
2296
2520
|
}
|
|
2297
2521
|
local evData = setmetatable(
|
|
@@ -2308,7 +2532,7 @@ Unit.onDamage = __TS__New(
|
|
|
2308
2532
|
invoke(event, source, target, evData)
|
|
2309
2533
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2310
2534
|
local bonusHealth = math.ceil(evData.amount)
|
|
2311
|
-
target[
|
|
2535
|
+
target[105] = (target[105] or 0) + bonusHealth
|
|
2312
2536
|
BlzSetUnitMaxHP(
|
|
2313
2537
|
target.handle,
|
|
2314
2538
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2322,7 +2546,7 @@ Unit.onDamage = __TS__New(
|
|
|
2322
2546
|
evData[0],
|
|
2323
2547
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2324
2548
|
)
|
|
2325
|
-
target[
|
|
2549
|
+
target[105] = (target[105] or 0) - bonusHealth
|
|
2326
2550
|
SetWidgetLife(
|
|
2327
2551
|
target.handle,
|
|
2328
2552
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2342,32 +2566,91 @@ Unit.onDamage = __TS__New(
|
|
|
2342
2566
|
DestroyTrigger(trigger)
|
|
2343
2567
|
end
|
|
2344
2568
|
)
|
|
2345
|
-
Unit.
|
|
2569
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2346
2570
|
____exports.UnitTriggerEvent,
|
|
2347
2571
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2348
2572
|
function()
|
|
2349
2573
|
local unit = getTriggerUnit()
|
|
2350
|
-
|
|
2351
|
-
|
|
2574
|
+
local item = getManipulatedItem()
|
|
2575
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2576
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2352
2577
|
end
|
|
2353
2578
|
return IgnoreEvent
|
|
2354
2579
|
end
|
|
2355
2580
|
)
|
|
2356
|
-
Unit.
|
|
2581
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2357
2582
|
____exports.UnitTriggerEvent,
|
|
2358
2583
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2359
2584
|
function()
|
|
2360
2585
|
local unit = getTriggerUnit()
|
|
2361
|
-
|
|
2362
|
-
|
|
2586
|
+
local item = getManipulatedItem()
|
|
2587
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2588
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2363
2589
|
end
|
|
2364
2590
|
return IgnoreEvent
|
|
2365
2591
|
end
|
|
2366
2592
|
)
|
|
2367
|
-
Unit.
|
|
2593
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2368
2594
|
____exports.UnitTriggerEvent,
|
|
2369
2595
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2370
|
-
function()
|
|
2596
|
+
function()
|
|
2597
|
+
local unit = getTriggerUnit()
|
|
2598
|
+
local item = getManipulatedItem()
|
|
2599
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2600
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2601
|
+
end
|
|
2602
|
+
return IgnoreEvent
|
|
2603
|
+
end
|
|
2604
|
+
)
|
|
2605
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2606
|
+
____exports.UnitTriggerEvent,
|
|
2607
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2608
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2609
|
+
)
|
|
2610
|
+
__TS__ObjectDefineProperty(
|
|
2611
|
+
Unit,
|
|
2612
|
+
"itemUseOrderEvent",
|
|
2613
|
+
{get = function(self)
|
|
2614
|
+
local event = __TS__New(Event)
|
|
2615
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2616
|
+
local slot = order - orderId("useslot0")
|
|
2617
|
+
local function listener(unit)
|
|
2618
|
+
local item = unit.items[slot + 1]
|
|
2619
|
+
if item ~= nil then
|
|
2620
|
+
invoke(event, unit, item)
|
|
2621
|
+
end
|
|
2622
|
+
end
|
|
2623
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2624
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2625
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2626
|
+
end
|
|
2627
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2628
|
+
return event
|
|
2629
|
+
end}
|
|
2630
|
+
)
|
|
2631
|
+
__TS__ObjectDefineProperty(
|
|
2632
|
+
Unit,
|
|
2633
|
+
"itemMoveOrderEvent",
|
|
2634
|
+
{get = function(self)
|
|
2635
|
+
local event = __TS__New(Event)
|
|
2636
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2637
|
+
local slotTo = order - orderId("moveslot0")
|
|
2638
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2639
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2640
|
+
if slotFrom ~= nil then
|
|
2641
|
+
invoke(
|
|
2642
|
+
event,
|
|
2643
|
+
unit,
|
|
2644
|
+
item,
|
|
2645
|
+
slotFrom,
|
|
2646
|
+
slotTo
|
|
2647
|
+
)
|
|
2648
|
+
end
|
|
2649
|
+
end)
|
|
2650
|
+
end
|
|
2651
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2652
|
+
return event
|
|
2653
|
+
end}
|
|
2371
2654
|
)
|
|
2372
2655
|
__TS__ObjectDefineProperty(
|
|
2373
2656
|
Unit,
|