warscript 0.0.1-dev.ee2345e → 0.0.1-dev.f955a59
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 +0 -1
- package/binaryreader.d.ts +1 -0
- package/binaryreader.lua +3 -0
- package/core/types/effect.d.ts +13 -3
- package/core/types/effect.lua +116 -17
- 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/image.d.ts +0 -1
- package/core/types/missile.d.ts +2 -2
- package/core/types/missile.lua +8 -2
- package/core/types/unit.lua +8 -0
- package/core/util.d.ts +1 -1
- package/core/util.lua +12 -0
- package/decl/index.d.ts +1 -0
- 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 +3 -5
- package/engine/behaviour/ability/apply-unit-behavior.d.ts +6 -1
- package/engine/behaviour/ability/damage.d.ts +33 -11
- package/engine/behaviour/ability/damage.lua +89 -31
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +28 -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 +21 -3
- package/engine/behaviour/ability.lua +120 -12
- package/engine/behaviour/unit/stun-immunity.d.ts +0 -1
- package/engine/behaviour/unit.d.ts +8 -2
- package/engine/behaviour/unit.lua +27 -0
- package/engine/buff.d.ts +68 -21
- package/engine/buff.lua +276 -90
- 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 +82 -76
- package/engine/internal/item/ability.lua +106 -0
- package/engine/internal/item+owner.lua +2 -2
- package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
- package/engine/internal/misc/ability-disable-counter.lua +13 -0
- package/engine/internal/unit/ability.d.ts +10 -1
- package/engine/internal/unit/ability.lua +36 -14
- package/engine/internal/unit/bonus.d.ts +9 -8
- package/engine/internal/unit/bonus.lua +6 -1
- package/engine/internal/unit/item.d.ts +24 -0
- package/engine/internal/unit/item.lua +79 -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+transport.lua +4 -10
- package/engine/internal/unit-missile-launch.lua +25 -6
- package/engine/internal/unit.d.ts +58 -16
- package/engine/internal/unit.lua +365 -132
- package/engine/internal/utility.lua +12 -0
- package/engine/local-client.d.ts +7 -2
- package/engine/local-client.lua +82 -0
- package/engine/object-data/auxiliary/attachment-preset.d.ts +0 -1
- package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
- package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
- package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
- package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
- package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
- 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/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.d.ts +0 -1
- package/engine/object-data/entry/ability-type.lua +8 -12
- package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
- package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
- package/engine/object-data/entry/buff-type.d.ts +0 -1
- package/engine/object-data/entry/destructible-type.d.ts +0 -1
- package/engine/object-data/entry/item-type/blank.d.ts +0 -1
- package/engine/object-data/entry/item-type.d.ts +14 -1
- package/engine/object-data/entry/item-type.lua +91 -0
- package/engine/object-data/entry/lightning-type.d.ts +0 -1
- package/engine/object-data/entry/unit-type.d.ts +37 -2
- package/engine/object-data/entry/unit-type.lua +333 -49
- package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
- package/engine/object-data/entry/upgrade.d.ts +0 -1
- package/engine/object-data/entry.d.ts +2 -3
- 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.d.ts +2 -3
- package/engine/object-field.lua +4 -0
- package/engine/random.d.ts +1 -0
- package/engine/random.lua +9 -0
- package/engine/standard/entries/unit-type.d.ts +39 -1
- package/engine/standard/entries/unit-type.lua +39 -1
- package/engine/standard/fields/ability.d.ts +3 -1
- package/engine/standard/fields/ability.lua +3 -1
- package/engine/unit.d.ts +2 -0
- package/engine/unit.lua +11 -2
- package/event.d.ts +2 -3
- package/event.lua +9 -5
- 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 +1 -1
- package/objutil/object.d.ts +0 -1
- package/objutil/unit.d.ts +0 -1
- 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 +11 -5
- package/utility/arrays.lua +34 -3
- package/utility/bit-set.d.ts +0 -2
- package/utility/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
- package/utility/linked-set.d.ts +11 -3
- package/utility/linked-set.lua +5 -2
- package/utility/lua-maps.d.ts +1 -2
- package/utility/lua-sets.d.ts +1 -2
- package/utility/types.d.ts +1 -0
- 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
|
|
@@ -92,6 +95,10 @@ local isUnitInRangeXY = IsUnitInRangeXY
|
|
|
92
95
|
local isUnitInRange = IsUnitInRange
|
|
93
96
|
local setResourceAmount = SetResourceAmount
|
|
94
97
|
local getResourceAmount = GetResourceAmount
|
|
98
|
+
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
99
|
+
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
100
|
+
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
101
|
+
local setUnitWeaponStringField = BlzSetUnitWeaponStringField
|
|
95
102
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
96
103
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
97
104
|
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
@@ -275,16 +282,14 @@ function UnitTriggerEvent.prototype.____constructor(self, eventType, c)
|
|
|
275
282
|
end
|
|
276
283
|
local function dispatch(event, idGetter, argsGetter)
|
|
277
284
|
local initialized = false
|
|
278
|
-
local x = {}
|
|
279
285
|
return setmetatable(
|
|
280
|
-
|
|
286
|
+
{},
|
|
281
287
|
{
|
|
282
288
|
__index = function(self, id)
|
|
283
289
|
if type(id) ~= "number" then
|
|
284
290
|
return event[id]
|
|
285
291
|
end
|
|
286
292
|
if not initialized then
|
|
287
|
-
local invoke = Event.invoke
|
|
288
293
|
event:addListener(function(...)
|
|
289
294
|
local id = idGetter(...)
|
|
290
295
|
local dispatched = rawget(self, id)
|
|
@@ -322,7 +327,6 @@ local function dispatchAbility(event)
|
|
|
322
327
|
return event[id]
|
|
323
328
|
end
|
|
324
329
|
if not initialized then
|
|
325
|
-
local invoke = Event.invoke
|
|
326
330
|
event:addListener(function(unit, ability, ...)
|
|
327
331
|
local dispatched = rawget(self, ability.typeId)
|
|
328
332
|
if dispatched ~= nil then
|
|
@@ -387,51 +391,158 @@ local getters = {
|
|
|
387
391
|
return BlzGetUnitArmor(unit)
|
|
388
392
|
end
|
|
389
393
|
}
|
|
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
|
-
|
|
394
|
+
____exports.UnitWeapon = __TS__Class()
|
|
395
|
+
local UnitWeapon = ____exports.UnitWeapon
|
|
396
|
+
UnitWeapon.name = "UnitWeapon"
|
|
397
|
+
function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
398
|
+
self.unit = unit
|
|
399
|
+
self.index = index
|
|
400
|
+
end
|
|
401
|
+
__TS__SetDescriptor(
|
|
402
|
+
UnitWeapon.prototype,
|
|
403
|
+
"cooldown",
|
|
404
|
+
{
|
|
405
|
+
get = function(self)
|
|
406
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index)
|
|
407
|
+
end,
|
|
408
|
+
set = function(self, cooldown)
|
|
409
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index, cooldown)
|
|
410
|
+
end
|
|
411
|
+
},
|
|
412
|
+
true
|
|
413
|
+
)
|
|
414
|
+
__TS__SetDescriptor(
|
|
415
|
+
UnitWeapon.prototype,
|
|
416
|
+
"damage",
|
|
417
|
+
{
|
|
418
|
+
get = function(self)
|
|
419
|
+
local minimumDamage = self.damageBase + self.damageDiceCount
|
|
420
|
+
local maximumDamage = self.damageBase + self.damageDiceCount * self.damageDiceSideCount
|
|
421
|
+
return {minimumDamage, maximumDamage}
|
|
422
|
+
end,
|
|
423
|
+
set = function(self, ____bindingPattern0)
|
|
424
|
+
local maximumDamage
|
|
425
|
+
local minimumDamage
|
|
426
|
+
minimumDamage = ____bindingPattern0[1]
|
|
427
|
+
maximumDamage = ____bindingPattern0[2]
|
|
428
|
+
self.damageBase = minimumDamage - 1
|
|
429
|
+
self.damageDiceCount = 1
|
|
430
|
+
self.damageDiceSideCount = maximumDamage - minimumDamage + 1
|
|
431
|
+
end
|
|
432
|
+
},
|
|
433
|
+
true
|
|
434
|
+
)
|
|
435
|
+
__TS__SetDescriptor(
|
|
436
|
+
UnitWeapon.prototype,
|
|
437
|
+
"damageBase",
|
|
438
|
+
{
|
|
439
|
+
get = function(self)
|
|
440
|
+
return BlzGetUnitBaseDamage(self.unit.handle, self.index)
|
|
441
|
+
end,
|
|
442
|
+
set = function(self, damageBase)
|
|
443
|
+
BlzSetUnitBaseDamage(self.unit.handle, self.index, damageBase)
|
|
444
|
+
end
|
|
445
|
+
},
|
|
446
|
+
true
|
|
447
|
+
)
|
|
448
|
+
__TS__SetDescriptor(
|
|
449
|
+
UnitWeapon.prototype,
|
|
450
|
+
"damageDiceCount",
|
|
451
|
+
{
|
|
452
|
+
get = function(self)
|
|
453
|
+
return BlzGetUnitDiceNumber(self.unit.handle, self.index)
|
|
454
|
+
end,
|
|
455
|
+
set = function(self, damageDiceCount)
|
|
456
|
+
BlzSetUnitDiceNumber(self.unit.handle, self.index, damageDiceCount)
|
|
457
|
+
end
|
|
458
|
+
},
|
|
459
|
+
true
|
|
460
|
+
)
|
|
461
|
+
__TS__SetDescriptor(
|
|
462
|
+
UnitWeapon.prototype,
|
|
463
|
+
"damageDiceSideCount",
|
|
464
|
+
{
|
|
465
|
+
get = function(self)
|
|
466
|
+
return BlzGetUnitDiceSides(self.unit.handle, self.index)
|
|
467
|
+
end,
|
|
468
|
+
set = function(self, damageDiceSideCount)
|
|
469
|
+
BlzSetUnitDiceSides(self.unit.handle, self.index, damageDiceSideCount)
|
|
470
|
+
end
|
|
471
|
+
},
|
|
472
|
+
true
|
|
473
|
+
)
|
|
474
|
+
__TS__SetDescriptor(
|
|
475
|
+
UnitWeapon.prototype,
|
|
476
|
+
"range",
|
|
477
|
+
{
|
|
478
|
+
get = function(self)
|
|
479
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_RANGE, self.index)
|
|
480
|
+
end,
|
|
481
|
+
set = function(self, range)
|
|
482
|
+
local handle = self.unit.handle
|
|
483
|
+
local index = self.index
|
|
484
|
+
setUnitWeaponRealField(
|
|
485
|
+
handle,
|
|
486
|
+
UNIT_WEAPON_RF_ATTACK_RANGE,
|
|
487
|
+
index + 1,
|
|
488
|
+
getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index + 1) + (range - getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index))
|
|
489
|
+
)
|
|
490
|
+
end
|
|
491
|
+
},
|
|
492
|
+
true
|
|
493
|
+
)
|
|
494
|
+
__TS__SetDescriptor(
|
|
495
|
+
UnitWeapon.prototype,
|
|
496
|
+
"impactDelay",
|
|
497
|
+
{
|
|
498
|
+
get = function(self)
|
|
499
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index)
|
|
500
|
+
end,
|
|
501
|
+
set = function(self, impactDelay)
|
|
502
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index, impactDelay)
|
|
503
|
+
end
|
|
504
|
+
},
|
|
505
|
+
true
|
|
506
|
+
)
|
|
507
|
+
__TS__SetDescriptor(
|
|
508
|
+
UnitWeapon.prototype,
|
|
509
|
+
"missileArc",
|
|
510
|
+
{
|
|
511
|
+
get = function(self)
|
|
512
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index)
|
|
513
|
+
end,
|
|
514
|
+
set = function(self, missileArc)
|
|
515
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index, missileArc)
|
|
516
|
+
end
|
|
517
|
+
},
|
|
518
|
+
true
|
|
519
|
+
)
|
|
520
|
+
__TS__SetDescriptor(
|
|
521
|
+
UnitWeapon.prototype,
|
|
522
|
+
"missileModelPath",
|
|
523
|
+
{
|
|
524
|
+
get = function(self)
|
|
525
|
+
return getUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index)
|
|
526
|
+
end,
|
|
527
|
+
set = function(self, missileModelPath)
|
|
528
|
+
setUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index, missileModelPath)
|
|
529
|
+
end
|
|
530
|
+
},
|
|
531
|
+
true
|
|
532
|
+
)
|
|
533
|
+
__TS__SetDescriptor(
|
|
534
|
+
UnitWeapon.prototype,
|
|
535
|
+
"missileSpeed",
|
|
536
|
+
{
|
|
537
|
+
get = function(self)
|
|
538
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index)
|
|
539
|
+
end,
|
|
540
|
+
set = function(self, missileSpeed)
|
|
541
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index, missileSpeed)
|
|
542
|
+
end
|
|
543
|
+
},
|
|
544
|
+
true
|
|
545
|
+
)
|
|
435
546
|
local unitInventorySize = UnitInventorySize
|
|
436
547
|
local unitItemInSlot = UnitItemInSlot
|
|
437
548
|
local getItemAbility = BlzGetItemAbility
|
|
@@ -442,8 +553,6 @@ local getAbilityName = GetAbilityName
|
|
|
442
553
|
local unitAddAbility = UnitAddAbility
|
|
443
554
|
local getUnitGoldCost = GetUnitGoldCost
|
|
444
555
|
local getUnitLumberCost = GetUnitWoodCost
|
|
445
|
-
local unitMakeAbilityPermanent = UnitMakeAbilityPermanent
|
|
446
|
-
local unitAddItem = UnitAddItem
|
|
447
556
|
local unitRemoveAbility = UnitRemoveAbility
|
|
448
557
|
local function retrieveAbility(unit, ability, abilityId)
|
|
449
558
|
if ability == nil then
|
|
@@ -453,17 +562,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
453
562
|
____exports.Unit:of(unit)
|
|
454
563
|
)
|
|
455
564
|
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
565
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
468
566
|
local item = unitItemInSlot(unit, i)
|
|
469
567
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -520,12 +618,37 @@ for ____, player in ipairs(Player.all) do
|
|
|
520
618
|
ShowUnit(dummy, false)
|
|
521
619
|
dummies[player] = dummy
|
|
522
620
|
end
|
|
621
|
+
---
|
|
622
|
+
-- @internal For use by internal systems only.
|
|
623
|
+
____exports.ignoreEventsItems = {}
|
|
624
|
+
local function delayHealthChecksCallback(unit)
|
|
625
|
+
local counter = (unit[103] or 0) - 1
|
|
626
|
+
if counter ~= 0 then
|
|
627
|
+
unit[103] = counter
|
|
628
|
+
return
|
|
629
|
+
end
|
|
630
|
+
unit[103] = nil
|
|
631
|
+
local healthBonus = unit[104]
|
|
632
|
+
if healthBonus ~= nil then
|
|
633
|
+
unit[104] = nil
|
|
634
|
+
local handle = unit.handle
|
|
635
|
+
BlzSetUnitMaxHP(
|
|
636
|
+
handle,
|
|
637
|
+
BlzGetUnitMaxHP(handle) - healthBonus
|
|
638
|
+
)
|
|
639
|
+
end
|
|
640
|
+
end
|
|
641
|
+
local nextSyncId = 1
|
|
642
|
+
local unitBySyncId = setmetatable({}, {__mode = "k"})
|
|
523
643
|
____exports.Unit = __TS__Class()
|
|
524
644
|
local Unit = ____exports.Unit
|
|
525
645
|
Unit.name = "Unit"
|
|
526
646
|
__TS__ClassExtends(Unit, Handle)
|
|
527
647
|
function Unit.prototype.____constructor(self, handle)
|
|
528
648
|
Handle.prototype.____constructor(self, handle)
|
|
649
|
+
local ____nextSyncId_0 = nextSyncId
|
|
650
|
+
nextSyncId = ____nextSyncId_0 + 1
|
|
651
|
+
self.syncId = ____nextSyncId_0
|
|
529
652
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
530
653
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
531
654
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -538,6 +661,7 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
538
661
|
fourCC("Amrf")
|
|
539
662
|
))
|
|
540
663
|
end
|
|
664
|
+
unitBySyncId[self.syncId] = self
|
|
541
665
|
local ____ = self.abilities
|
|
542
666
|
end
|
|
543
667
|
function Unit.prototype.getEvent(self, event, collector)
|
|
@@ -623,8 +747,8 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
623
747
|
end}
|
|
624
748
|
end
|
|
625
749
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
626
|
-
local
|
|
627
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
750
|
+
local ____combatClassification_1 = combatClassification
|
|
751
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
|
|
628
752
|
end
|
|
629
753
|
function Unit.prototype.addClassification(self, classification)
|
|
630
754
|
return unitAddType(self.handle, classification)
|
|
@@ -642,13 +766,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
642
766
|
return isUnitInvisible(self.handle, player.handle)
|
|
643
767
|
end
|
|
644
768
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
645
|
-
local
|
|
769
|
+
local ____temp_2
|
|
646
770
|
if type(x) == "number" then
|
|
647
|
-
|
|
771
|
+
____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
|
|
648
772
|
else
|
|
649
|
-
|
|
773
|
+
____temp_2 = isUnitInRange(self.handle, x.handle, y)
|
|
650
774
|
end
|
|
651
|
-
return
|
|
775
|
+
return ____temp_2
|
|
652
776
|
end
|
|
653
777
|
function Unit.prototype.isAllyOf(self, unit)
|
|
654
778
|
return isUnitAlly(
|
|
@@ -674,6 +798,10 @@ end
|
|
|
674
798
|
function Unit.prototype.queueAnimation(self, animation)
|
|
675
799
|
queueUnitAnimation(self.handle, animation)
|
|
676
800
|
end
|
|
801
|
+
function Unit.prototype.delayHealthChecks(self)
|
|
802
|
+
self[103] = (self[103] or 0) + 1
|
|
803
|
+
Timer:run(delayHealthChecksCallback, self)
|
|
804
|
+
end
|
|
677
805
|
function Unit.prototype.setPosition(self, x, y)
|
|
678
806
|
setUnitPosition(self.handle, x, y)
|
|
679
807
|
end
|
|
@@ -687,8 +815,15 @@ end
|
|
|
687
815
|
function Unit.prototype.kill(self)
|
|
688
816
|
killUnit(self.handle)
|
|
689
817
|
end
|
|
690
|
-
function Unit.prototype.revive(self,
|
|
691
|
-
|
|
818
|
+
function Unit.prototype.revive(self, x, y, doEffect)
|
|
819
|
+
local ____ReviveHero_5 = ReviveHero
|
|
820
|
+
local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
|
|
821
|
+
local ____doEffect_3 = doEffect
|
|
822
|
+
if ____doEffect_3 == nil then
|
|
823
|
+
____doEffect_3 = false
|
|
824
|
+
end
|
|
825
|
+
__TS__SparseArrayPush(____array_4, ____doEffect_3)
|
|
826
|
+
____ReviveHero_5(__TS__SparseArraySpread(____array_4))
|
|
692
827
|
end
|
|
693
828
|
function Unit.prototype.healTarget(self, target, amount)
|
|
694
829
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -728,7 +863,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
728
863
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
729
864
|
end
|
|
730
865
|
function Unit.prototype.itemInSlot(self, slot)
|
|
731
|
-
return Item:of(
|
|
866
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
732
867
|
end
|
|
733
868
|
function Unit.prototype.addAbility(self, abilityId)
|
|
734
869
|
if unitAddAbility(self.handle, abilityId) then
|
|
@@ -784,6 +919,9 @@ end
|
|
|
784
919
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
785
920
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
786
921
|
end
|
|
922
|
+
function Unit.prototype.getAbilityRemainingCooldown(self, abilityId)
|
|
923
|
+
return BlzGetUnitAbilityCooldownRemaining(self.handle, abilityId)
|
|
924
|
+
end
|
|
787
925
|
function Unit.prototype.startAbilityCooldown(self, abilityId, cooldown)
|
|
788
926
|
BlzStartUnitAbilityCooldown(self.handle, abilityId, cooldown)
|
|
789
927
|
end
|
|
@@ -794,8 +932,15 @@ function Unit.prototype.interruptAttack(self)
|
|
|
794
932
|
unitInterruptAttack(self.handle)
|
|
795
933
|
end
|
|
796
934
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
797
|
-
|
|
798
|
-
unitDisableAbility(
|
|
935
|
+
local handle = self.handle
|
|
936
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
937
|
+
Timer:run(
|
|
938
|
+
unitDisableAbility,
|
|
939
|
+
handle,
|
|
940
|
+
abilityId,
|
|
941
|
+
false,
|
|
942
|
+
false
|
|
943
|
+
)
|
|
799
944
|
end
|
|
800
945
|
function Unit.prototype.getDistanceTo(self, target)
|
|
801
946
|
local handle = self.handle
|
|
@@ -855,18 +1000,18 @@ function Unit.prototype.unpauseEx(self)
|
|
|
855
1000
|
self:decrementStunCounter()
|
|
856
1001
|
end
|
|
857
1002
|
function Unit.prototype.incrementStunCounter(self)
|
|
858
|
-
local stunCounter = self[
|
|
859
|
-
if not self[
|
|
1003
|
+
local stunCounter = self[102] or 0
|
|
1004
|
+
if not self[101] or stunCounter >= 0 then
|
|
860
1005
|
BlzPauseUnitEx(self.handle, true)
|
|
861
1006
|
end
|
|
862
|
-
self[
|
|
1007
|
+
self[102] = stunCounter + 1
|
|
863
1008
|
end
|
|
864
1009
|
function Unit.prototype.decrementStunCounter(self)
|
|
865
|
-
local stunCounter = self[
|
|
866
|
-
if not self[
|
|
1010
|
+
local stunCounter = self[102] or 0
|
|
1011
|
+
if not self[101] or stunCounter >= 1 then
|
|
867
1012
|
BlzPauseUnitEx(self.handle, false)
|
|
868
1013
|
end
|
|
869
|
-
self[
|
|
1014
|
+
self[102] = stunCounter - 1
|
|
870
1015
|
end
|
|
871
1016
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
872
1017
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -968,8 +1113,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
968
1113
|
)
|
|
969
1114
|
return targetCollection
|
|
970
1115
|
end
|
|
971
|
-
function Unit.getSelectionOf(self, player)
|
|
972
|
-
|
|
1116
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1117
|
+
if target == nil then
|
|
1118
|
+
target = {}
|
|
1119
|
+
end
|
|
1120
|
+
targetCollection = target
|
|
973
1121
|
targetCollectionNextIndex = 1
|
|
974
1122
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
975
1123
|
return targetCollection
|
|
@@ -991,6 +1139,9 @@ end
|
|
|
991
1139
|
function Unit.prototype.__tostring(self)
|
|
992
1140
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
993
1141
|
end
|
|
1142
|
+
function Unit.getBySyncId(self, syncId)
|
|
1143
|
+
return unitBySyncId[syncId]
|
|
1144
|
+
end
|
|
994
1145
|
__TS__SetDescriptor(
|
|
995
1146
|
Unit.prototype,
|
|
996
1147
|
"_deltas",
|
|
@@ -1071,12 +1222,27 @@ __TS__SetDescriptor(
|
|
|
1071
1222
|
Unit.prototype,
|
|
1072
1223
|
"weapons",
|
|
1073
1224
|
{get = function(self)
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1225
|
+
return {self.firstWeapon, self.secondWeapon}
|
|
1226
|
+
end},
|
|
1227
|
+
true
|
|
1228
|
+
)
|
|
1229
|
+
__TS__SetDescriptor(
|
|
1230
|
+
Unit.prototype,
|
|
1231
|
+
"firstWeapon",
|
|
1232
|
+
{get = function(self)
|
|
1233
|
+
local weapon = __TS__New(____exports.UnitWeapon, self, 0)
|
|
1234
|
+
rawset(self, "firstWeapon", weapon)
|
|
1235
|
+
return weapon
|
|
1236
|
+
end},
|
|
1237
|
+
true
|
|
1238
|
+
)
|
|
1239
|
+
__TS__SetDescriptor(
|
|
1240
|
+
Unit.prototype,
|
|
1241
|
+
"secondWeapon",
|
|
1242
|
+
{get = function(self)
|
|
1243
|
+
local weapon = __TS__New(____exports.UnitWeapon, self, 1)
|
|
1244
|
+
rawset(self, "secondWeapon", weapon)
|
|
1245
|
+
return weapon
|
|
1080
1246
|
end},
|
|
1081
1247
|
true
|
|
1082
1248
|
)
|
|
@@ -1233,17 +1399,17 @@ __TS__SetDescriptor(
|
|
|
1233
1399
|
"isTeamGlowVisible",
|
|
1234
1400
|
{
|
|
1235
1401
|
get = function(self)
|
|
1236
|
-
return not self[
|
|
1402
|
+
return not self[106]
|
|
1237
1403
|
end,
|
|
1238
1404
|
set = function(self, isTeamGlowVisible)
|
|
1239
1405
|
showUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1240
|
-
local
|
|
1406
|
+
local ____temp_6
|
|
1241
1407
|
if not isTeamGlowVisible then
|
|
1242
|
-
|
|
1408
|
+
____temp_6 = true
|
|
1243
1409
|
else
|
|
1244
|
-
|
|
1410
|
+
____temp_6 = nil
|
|
1245
1411
|
end
|
|
1246
|
-
self[
|
|
1412
|
+
self[106] = ____temp_6
|
|
1247
1413
|
end
|
|
1248
1414
|
},
|
|
1249
1415
|
true
|
|
@@ -1253,7 +1419,7 @@ __TS__SetDescriptor(
|
|
|
1253
1419
|
"color",
|
|
1254
1420
|
{set = function(self, color)
|
|
1255
1421
|
setUnitColor(self.handle, color.handle)
|
|
1256
|
-
if self[
|
|
1422
|
+
if self[106] then
|
|
1257
1423
|
showUnitTeamGlow(self.handle, false)
|
|
1258
1424
|
end
|
|
1259
1425
|
end},
|
|
@@ -1277,10 +1443,14 @@ __TS__SetDescriptor(
|
|
|
1277
1443
|
"maxHealth",
|
|
1278
1444
|
{
|
|
1279
1445
|
get = function(self)
|
|
1280
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1446
|
+
return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
|
|
1281
1447
|
end,
|
|
1282
1448
|
set = function(self, maxHealth)
|
|
1283
|
-
|
|
1449
|
+
if maxHealth < 1 and self[103] ~= nil then
|
|
1450
|
+
self[104] = (self[104] or 0) + (1 - maxHealth)
|
|
1451
|
+
maxHealth = 1
|
|
1452
|
+
end
|
|
1453
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
|
|
1284
1454
|
end
|
|
1285
1455
|
},
|
|
1286
1456
|
true
|
|
@@ -1322,10 +1492,10 @@ __TS__SetDescriptor(
|
|
|
1322
1492
|
"health",
|
|
1323
1493
|
{
|
|
1324
1494
|
get = function(self)
|
|
1325
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1495
|
+
return GetWidgetLife(self.handle) - (self[105] or 0)
|
|
1326
1496
|
end,
|
|
1327
1497
|
set = function(self, health)
|
|
1328
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1498
|
+
SetWidgetLife(self.handle, health + (self[105] or 0))
|
|
1329
1499
|
end
|
|
1330
1500
|
},
|
|
1331
1501
|
true
|
|
@@ -1536,17 +1706,17 @@ __TS__SetDescriptor(
|
|
|
1536
1706
|
set = function(self, isPaused)
|
|
1537
1707
|
local handle = self.handle
|
|
1538
1708
|
if isPaused and not IsUnitPaused(handle) then
|
|
1539
|
-
self[
|
|
1540
|
-
for _ = self[
|
|
1709
|
+
self[101] = true
|
|
1710
|
+
for _ = self[102] or 0, -1 do
|
|
1541
1711
|
BlzPauseUnitEx(handle, true)
|
|
1542
1712
|
end
|
|
1543
1713
|
PauseUnit(handle, true)
|
|
1544
1714
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1545
1715
|
PauseUnit(handle, false)
|
|
1546
|
-
for _ = self[
|
|
1716
|
+
for _ = self[102] or 0, -1 do
|
|
1547
1717
|
BlzPauseUnitEx(handle, false)
|
|
1548
1718
|
end
|
|
1549
|
-
self[
|
|
1719
|
+
self[101] = nil
|
|
1550
1720
|
end
|
|
1551
1721
|
end
|
|
1552
1722
|
},
|
|
@@ -1903,7 +2073,6 @@ Unit.onDecay = __TS__New(
|
|
|
1903
2073
|
Unit.onResurrect = __TS__New(
|
|
1904
2074
|
InitializingEvent,
|
|
1905
2075
|
function(event)
|
|
1906
|
-
local invoke = Event.invoke
|
|
1907
2076
|
local dead = setmetatable({}, {__mode = "k"})
|
|
1908
2077
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
1909
2078
|
dead[unit] = true
|
|
@@ -1919,10 +2088,15 @@ Unit.onResurrect = __TS__New(
|
|
|
1919
2088
|
Unit.morphEvent = __TS__New(
|
|
1920
2089
|
InitializingEvent,
|
|
1921
2090
|
function(event)
|
|
2091
|
+
local function ifNotLeft(unit)
|
|
2092
|
+
local handle = unit.handle
|
|
2093
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2094
|
+
invoke(event, unit)
|
|
2095
|
+
end
|
|
2096
|
+
end
|
|
1922
2097
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
1923
2098
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
1924
|
-
|
|
1925
|
-
Timer:run(Event.invoke, event, unit)
|
|
2099
|
+
Timer:run(ifNotLeft, unit)
|
|
1926
2100
|
end
|
|
1927
2101
|
end)
|
|
1928
2102
|
end
|
|
@@ -1960,27 +2134,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
1960
2134
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
1961
2135
|
InitializingEvent,
|
|
1962
2136
|
function(event)
|
|
1963
|
-
local invoke = Event.invoke
|
|
1964
2137
|
local function listener(unit, id)
|
|
1965
|
-
local
|
|
2138
|
+
local ____GetSpellTargetUnit_result_9
|
|
1966
2139
|
if GetSpellTargetUnit() then
|
|
1967
|
-
|
|
2140
|
+
____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
1968
2141
|
else
|
|
1969
|
-
local
|
|
2142
|
+
local ____GetSpellTargetItem_result_8
|
|
1970
2143
|
if GetSpellTargetItem() then
|
|
1971
|
-
|
|
2144
|
+
____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
|
|
1972
2145
|
else
|
|
1973
|
-
local
|
|
2146
|
+
local ____GetSpellTargetDestructable_result_7
|
|
1974
2147
|
if GetSpellTargetDestructable() then
|
|
1975
|
-
|
|
2148
|
+
____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
|
|
1976
2149
|
else
|
|
1977
|
-
|
|
2150
|
+
____GetSpellTargetDestructable_result_7 = nil
|
|
1978
2151
|
end
|
|
1979
|
-
|
|
2152
|
+
____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
|
|
1980
2153
|
end
|
|
1981
|
-
|
|
2154
|
+
____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
|
|
1982
2155
|
end
|
|
1983
|
-
local target =
|
|
2156
|
+
local target = ____GetSpellTargetUnit_result_9
|
|
1984
2157
|
if target then
|
|
1985
2158
|
invoke(event, unit, id, target)
|
|
1986
2159
|
end
|
|
@@ -2152,10 +2325,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2152
2325
|
____exports.UnitTriggerEvent,
|
|
2153
2326
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2154
2327
|
function()
|
|
2155
|
-
local
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2328
|
+
local handle = getOrderedUnit()
|
|
2329
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2330
|
+
local unit = ____exports.Unit:of(handle)
|
|
2331
|
+
if unit.state == 1 then
|
|
2332
|
+
return unit, getIssuedOrderId()
|
|
2333
|
+
end
|
|
2159
2334
|
end
|
|
2160
2335
|
return IgnoreEvent
|
|
2161
2336
|
end
|
|
@@ -2177,7 +2352,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2177
2352
|
)
|
|
2178
2353
|
Unit.onDamaging = (function()
|
|
2179
2354
|
local event = __TS__New(Event)
|
|
2180
|
-
local invoke = Event.invoke
|
|
2181
2355
|
local trigger = CreateTrigger()
|
|
2182
2356
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2183
2357
|
TriggerAddCondition(
|
|
@@ -2276,7 +2450,6 @@ end)()
|
|
|
2276
2450
|
Unit.onDamage = __TS__New(
|
|
2277
2451
|
InitializingEvent,
|
|
2278
2452
|
function(event)
|
|
2279
|
-
local invoke = Event.invoke
|
|
2280
2453
|
local trigger = CreateTrigger()
|
|
2281
2454
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2282
2455
|
TriggerAddCondition(
|
|
@@ -2292,6 +2465,7 @@ Unit.onDamage = __TS__New(
|
|
|
2292
2465
|
damageType = BlzGetEventDamageType(),
|
|
2293
2466
|
weaponType = BlzGetEventWeaponType(),
|
|
2294
2467
|
isAttack = BlzGetEventIsAttack(),
|
|
2468
|
+
originalAmount = GetEventDamage(),
|
|
2295
2469
|
preventDeath = damageEventPreventDeath
|
|
2296
2470
|
}
|
|
2297
2471
|
local evData = setmetatable(
|
|
@@ -2308,7 +2482,7 @@ Unit.onDamage = __TS__New(
|
|
|
2308
2482
|
invoke(event, source, target, evData)
|
|
2309
2483
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2310
2484
|
local bonusHealth = math.ceil(evData.amount)
|
|
2311
|
-
target[
|
|
2485
|
+
target[105] = (target[105] or 0) + bonusHealth
|
|
2312
2486
|
BlzSetUnitMaxHP(
|
|
2313
2487
|
target.handle,
|
|
2314
2488
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2322,7 +2496,7 @@ Unit.onDamage = __TS__New(
|
|
|
2322
2496
|
evData[0],
|
|
2323
2497
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2324
2498
|
)
|
|
2325
|
-
target[
|
|
2499
|
+
target[105] = (target[105] or 0) - bonusHealth
|
|
2326
2500
|
SetWidgetLife(
|
|
2327
2501
|
target.handle,
|
|
2328
2502
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2342,32 +2516,91 @@ Unit.onDamage = __TS__New(
|
|
|
2342
2516
|
DestroyTrigger(trigger)
|
|
2343
2517
|
end
|
|
2344
2518
|
)
|
|
2345
|
-
Unit.
|
|
2519
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2346
2520
|
____exports.UnitTriggerEvent,
|
|
2347
2521
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2348
2522
|
function()
|
|
2349
2523
|
local unit = getTriggerUnit()
|
|
2350
|
-
|
|
2351
|
-
|
|
2524
|
+
local item = getManipulatedItem()
|
|
2525
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (____exports.ignoreEventsItems[item] ~= nil) then
|
|
2526
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2352
2527
|
end
|
|
2353
2528
|
return IgnoreEvent
|
|
2354
2529
|
end
|
|
2355
2530
|
)
|
|
2356
|
-
Unit.
|
|
2531
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2357
2532
|
____exports.UnitTriggerEvent,
|
|
2358
2533
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2359
2534
|
function()
|
|
2360
2535
|
local unit = getTriggerUnit()
|
|
2361
|
-
|
|
2362
|
-
|
|
2536
|
+
local item = getManipulatedItem()
|
|
2537
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (____exports.ignoreEventsItems[item] ~= nil) then
|
|
2538
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2363
2539
|
end
|
|
2364
2540
|
return IgnoreEvent
|
|
2365
2541
|
end
|
|
2366
2542
|
)
|
|
2367
|
-
Unit.
|
|
2543
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2368
2544
|
____exports.UnitTriggerEvent,
|
|
2369
2545
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2370
|
-
function()
|
|
2546
|
+
function()
|
|
2547
|
+
local unit = getTriggerUnit()
|
|
2548
|
+
local item = getManipulatedItem()
|
|
2549
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (____exports.ignoreEventsItems[item] ~= nil) then
|
|
2550
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2551
|
+
end
|
|
2552
|
+
return IgnoreEvent
|
|
2553
|
+
end
|
|
2554
|
+
)
|
|
2555
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2556
|
+
____exports.UnitTriggerEvent,
|
|
2557
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2558
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2559
|
+
)
|
|
2560
|
+
__TS__ObjectDefineProperty(
|
|
2561
|
+
Unit,
|
|
2562
|
+
"itemUseOrderEvent",
|
|
2563
|
+
{get = function(self)
|
|
2564
|
+
local event = __TS__New(Event)
|
|
2565
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2566
|
+
local slot = order - orderId("useslot0")
|
|
2567
|
+
local function listener(unit)
|
|
2568
|
+
local item = unit.items[slot + 1]
|
|
2569
|
+
if item ~= nil then
|
|
2570
|
+
invoke(event, unit, item)
|
|
2571
|
+
end
|
|
2572
|
+
end
|
|
2573
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2574
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2575
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2576
|
+
end
|
|
2577
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2578
|
+
return event
|
|
2579
|
+
end}
|
|
2580
|
+
)
|
|
2581
|
+
__TS__ObjectDefineProperty(
|
|
2582
|
+
Unit,
|
|
2583
|
+
"itemMoveOrderEvent",
|
|
2584
|
+
{get = function(self)
|
|
2585
|
+
local event = __TS__New(Event)
|
|
2586
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2587
|
+
local slotTo = order - orderId("moveslot0")
|
|
2588
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2589
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2590
|
+
if slotFrom ~= nil then
|
|
2591
|
+
invoke(
|
|
2592
|
+
event,
|
|
2593
|
+
unit,
|
|
2594
|
+
item,
|
|
2595
|
+
slotFrom,
|
|
2596
|
+
slotTo
|
|
2597
|
+
)
|
|
2598
|
+
end
|
|
2599
|
+
end)
|
|
2600
|
+
end
|
|
2601
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2602
|
+
return event
|
|
2603
|
+
end}
|
|
2371
2604
|
)
|
|
2372
2605
|
__TS__ObjectDefineProperty(
|
|
2373
2606
|
Unit,
|