warscript 0.0.1-dev.2a0c343 → 0.0.1-dev.2ad49fd
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 +1 -0
- package/attributes.lua +9 -0
- package/core/types/frame.lua +71 -22
- package/core/types/player.d.ts +16 -0
- package/core/types/player.lua +60 -15
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +123 -5
- package/core/types/sound.lua +1 -1
- package/core/types/tileCell.d.ts +11 -1
- package/core/types/tileCell.lua +97 -0
- package/core/types/timer.d.ts +3 -1
- package/core/types/timer.lua +27 -2
- package/decl/native.d.ts +6 -4
- package/destroyable.d.ts +1 -0
- package/destroyable.lua +9 -0
- package/engine/behavior.d.ts +14 -1
- package/engine/behavior.lua +230 -70
- package/engine/behaviour/ability/apply-buff.lua +5 -5
- package/engine/behaviour/ability/damage.d.ts +3 -0
- package/engine/behaviour/ability/damage.lua +8 -2
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +11 -3
- package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
- package/engine/behaviour/ability/remove-buffs.lua +21 -0
- package/engine/behaviour/ability/restore-mana.d.ts +1 -1
- package/engine/behaviour/ability/restore-mana.lua +6 -6
- package/engine/behaviour/ability.d.ts +11 -6
- package/engine/behaviour/ability.lua +38 -17
- package/engine/behaviour/unit/stun-immunity.d.ts +12 -6
- package/engine/behaviour/unit/stun-immunity.lua +57 -31
- package/engine/behaviour/unit.d.ts +39 -3
- package/engine/behaviour/unit.lua +269 -6
- package/engine/buff.d.ts +67 -22
- package/engine/buff.lua +371 -182
- package/engine/internal/ability.d.ts +5 -1
- package/engine/internal/ability.lua +44 -11
- package/engine/internal/item/ability.lua +63 -11
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +16 -16
- package/engine/internal/item.lua +135 -49
- package/engine/internal/mechanics/cast-ability.lua +6 -3
- 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/armor-bonus.d.ts +2 -0
- package/engine/internal/object-data/attribute-bonus.lua +2 -2
- package/engine/internal/object-data/health-bonus.d.ts +2 -0
- package/engine/internal/object-data/health-bonus.lua +16 -0
- package/engine/internal/object-data/mana-bonus.d.ts +2 -0
- package/engine/internal/object-data/mana-bonus.lua +16 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
- package/engine/internal/unit/ability.d.ts +35 -0
- package/engine/internal/unit/ability.lua +98 -9
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/attributes.d.ts +17 -0
- package/engine/internal/unit/attributes.lua +46 -0
- package/engine/internal/unit/bonus.d.ts +6 -0
- package/engine/internal/unit/bonus.lua +33 -3
- package/engine/internal/unit/fly-height.d.ts +7 -0
- package/engine/internal/unit/fly-height.lua +20 -0
- package/engine/internal/unit/interrupts.d.ts +12 -0
- package/engine/internal/unit/interrupts.lua +28 -0
- package/engine/internal/unit/main-selected.lua +12 -27
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit/range-event.d.ts +12 -0
- package/engine/internal/unit/range-event.lua +90 -0
- package/engine/internal/unit/scale.d.ts +7 -0
- package/engine/internal/unit/scale.lua +20 -0
- package/engine/internal/unit+ability.lua +10 -1
- package/engine/internal/unit+bonus.lua +3 -3
- package/engine/internal/unit-missile-launch.lua +52 -14
- package/engine/internal/unit.d.ts +24 -24
- package/engine/internal/unit.lua +266 -237
- package/engine/local-client.d.ts +2 -0
- package/engine/local-client.lua +30 -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/health-regeneration-type.d.ts +8 -0
- package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
- package/engine/object-data/auxiliary/unit-attribute.lua +1 -1
- package/engine/object-data/entry/ability-type/{armor-increase.d.ts → armor-bonus.d.ts} +3 -3
- package/engine/object-data/entry/ability-type/{armor-increase.lua → armor-bonus.lua} +9 -9
- package/engine/object-data/entry/ability-type/health-bonus.d.ts +8 -0
- package/engine/object-data/entry/ability-type/health-bonus.lua +26 -0
- package/engine/object-data/entry/ability-type/mana-bonus.d.ts +8 -0
- package/engine/object-data/entry/ability-type/mana-bonus.lua +26 -0
- package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
- package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
- package/engine/object-data/entry/ability-type/reincarnation.d.ts +8 -0
- package/engine/object-data/entry/ability-type/reincarnation.lua +26 -0
- package/engine/object-data/entry/ability-type.d.ts +2 -0
- package/engine/object-data/entry/ability-type.lua +89 -8
- package/engine/object-data/entry/buff-type/applicable.lua +113 -109
- package/engine/object-data/entry/destructible-type.d.ts +27 -1
- package/engine/object-data/entry/destructible-type.lua +155 -0
- package/engine/object-data/entry/unit-type.d.ts +15 -2
- package/engine/object-data/entry/unit-type.lua +135 -33
- package/engine/object-field/ability.d.ts +3 -3
- package/engine/object-field/ability.lua +9 -8
- package/engine/object-field/unit.d.ts +31 -5
- package/engine/object-field/unit.lua +95 -0
- package/engine/object-field.d.ts +18 -7
- package/engine/object-field.lua +294 -135
- package/engine/random.d.ts +10 -0
- package/engine/random.lua +21 -0
- package/engine/standard/fields/ability.d.ts +2 -2
- package/engine/standard/fields/ability.lua +2 -2
- package/engine/standard/fields/unit.d.ts +12 -0
- package/engine/standard/fields/unit.lua +20 -0
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +250 -10
- package/engine/unit.d.ts +6 -0
- package/engine/unit.lua +6 -0
- package/lualib_bundle.lua +1 -1
- package/net/socket.lua +1 -1
- package/objutil/buff.lua +10 -8
- package/objutil/object.lua +1 -1
- package/operation.lua +1 -4
- package/package.json +5 -5
- package/patch-lua.lua +15 -0
- package/patch-lualib.lua +1 -1
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +8 -0
- package/utility/callback-array.d.ts +17 -0
- package/utility/callback-array.lua +61 -0
- package/utility/functions.d.ts +7 -0
- package/utility/functions.lua +12 -0
- package/utility/linked-map.d.ts +34 -0
- package/utility/linked-map.lua +101 -0
- package/utility/linked-set.d.ts +3 -1
- package/utility/linked-set.lua +40 -1
- package/utility/lua-maps.d.ts +12 -2
- package/utility/lua-maps.lua +37 -2
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +4 -0
- package/utility/records.lua +20 -1
- package/utility/types.d.ts +3 -0
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
- /package/engine/internal/{object-data/armor-increase.d.ts → misc/frame-coordinates.d.ts} +0 -0
- /package/engine/internal/object-data/{armor-increase.lua → armor-bonus.lua} +0 -0
- /package/engine/object-data/entry/ability-type/{attribute-increase.d.ts → attribute-bonus.d.ts} +0 -0
- /package/engine/object-data/entry/ability-type/{attribute-increase.lua → attribute-bonus.lua} +0 -0
package/engine/internal/unit.lua
CHANGED
|
@@ -60,6 +60,12 @@ local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage
|
|
|
60
60
|
local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
|
|
61
61
|
local ____attributes = require("attributes")
|
|
62
62
|
local isAttribute = ____attributes.isAttribute
|
|
63
|
+
local ____ability = require("engine.internal.item.ability")
|
|
64
|
+
local doUnitAbilityAction = ____ability.doUnitAbilityAction
|
|
65
|
+
local ____synchronization = require("engine.synchronization")
|
|
66
|
+
local synchronizer = ____synchronization.synchronizer
|
|
67
|
+
local ____linked_2Dmap = require("utility.linked-map")
|
|
68
|
+
local LinkedMap = ____linked_2Dmap.LinkedMap
|
|
63
69
|
local match = string.match
|
|
64
70
|
local ____tostring = _G.tostring
|
|
65
71
|
local setUnitAnimation = SetUnitAnimation
|
|
@@ -69,16 +75,12 @@ local getUnitRealField = BlzGetUnitRealField
|
|
|
69
75
|
local getHeroStr = GetHeroStr
|
|
70
76
|
local getHeroAgi = GetHeroAgi
|
|
71
77
|
local getHeroInt = GetHeroInt
|
|
72
|
-
local setHeroStr = SetHeroStr
|
|
73
|
-
local setHeroAgi = SetHeroAgi
|
|
74
|
-
local setHeroInt = SetHeroInt
|
|
75
78
|
local getUnitBooleanField = BlzGetUnitBooleanField
|
|
76
79
|
local getUnitStringField = BlzGetUnitStringField
|
|
77
80
|
local setUnitIntegerField = BlzSetUnitIntegerField
|
|
78
81
|
local setUnitRealField = BlzSetUnitRealField
|
|
79
82
|
local setUnitBooleanField = BlzSetUnitBooleanField
|
|
80
83
|
local setUnitStringField = BlzSetUnitStringField
|
|
81
|
-
local setUnitScale = SetUnitScale
|
|
82
84
|
local setUnitPosition = SetUnitPosition
|
|
83
85
|
local setUnitTimeScale = SetUnitTimeScale
|
|
84
86
|
local getHandleId = GetHandleId
|
|
@@ -106,7 +108,6 @@ local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
|
106
108
|
local setUnitWeaponStringField = BlzSetUnitWeaponStringField
|
|
107
109
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
108
110
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
109
|
-
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
110
111
|
local isUnitInvisible = IsUnitInvisible
|
|
111
112
|
local isUnitVisible = IsUnitVisible
|
|
112
113
|
local getUnitX = GetUnitX
|
|
@@ -123,10 +124,6 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
123
124
|
local getIssuedOrderId = GetIssuedOrderId
|
|
124
125
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
125
126
|
local unitAlive = UnitAlive
|
|
126
|
-
local unitAddType = UnitAddType
|
|
127
|
-
local unitRemoveType = UnitRemoveType
|
|
128
|
-
local isUnitIllusion = IsUnitIllusion
|
|
129
|
-
local isUnitType = IsUnitType
|
|
130
127
|
local isUnitAlly = IsUnitAlly
|
|
131
128
|
local isUnitEnemy = IsUnitEnemy
|
|
132
129
|
local getOwningPlayer = GetOwningPlayer
|
|
@@ -348,7 +345,7 @@ local function dispatchAbility(event)
|
|
|
348
345
|
)
|
|
349
346
|
end
|
|
350
347
|
local function damagingEventPreventRetaliation(self)
|
|
351
|
-
|
|
348
|
+
self[0] = true
|
|
352
349
|
end
|
|
353
350
|
local function damageEventPreventDeath(self, callback, ...)
|
|
354
351
|
if self[0] ~= nil then
|
|
@@ -386,15 +383,27 @@ local modifiers = {
|
|
|
386
383
|
end,
|
|
387
384
|
armor = function(unit, value)
|
|
388
385
|
if UnitAddAbility(unit, armorBonusAbilityId) then
|
|
389
|
-
assert(
|
|
386
|
+
assert(
|
|
387
|
+
UnitMakeAbilityPermanent(unit, true, armorBonusAbilityId),
|
|
388
|
+
"armor bonus ability must be made permanent",
|
|
389
|
+
unit
|
|
390
|
+
)
|
|
390
391
|
end
|
|
391
|
-
local ability = assert(
|
|
392
|
-
|
|
393
|
-
ability,
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
392
|
+
local ability = assert(
|
|
393
|
+
BlzGetUnitAbility(unit, armorBonusAbilityId),
|
|
394
|
+
"armor bonus ability must be existing",
|
|
395
|
+
unit
|
|
396
|
+
)
|
|
397
|
+
assert(
|
|
398
|
+
BlzSetAbilityRealLevelField(
|
|
399
|
+
ability,
|
|
400
|
+
armorBonusField,
|
|
401
|
+
0,
|
|
402
|
+
BlzGetAbilityRealLevelField(ability, armorBonusField, 0) + value
|
|
403
|
+
),
|
|
404
|
+
"armor bonus ability field must be set",
|
|
405
|
+
unit
|
|
406
|
+
)
|
|
398
407
|
end
|
|
399
408
|
}
|
|
400
409
|
local getters = {
|
|
@@ -412,6 +421,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
|
412
421
|
self.unit = unit
|
|
413
422
|
self.index = index
|
|
414
423
|
end
|
|
424
|
+
__TS__SetDescriptor(
|
|
425
|
+
UnitWeapon.prototype,
|
|
426
|
+
"isEnabled",
|
|
427
|
+
{
|
|
428
|
+
get = function(self)
|
|
429
|
+
return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
|
|
430
|
+
end,
|
|
431
|
+
set = function(self, isEnabled)
|
|
432
|
+
BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
|
|
433
|
+
end
|
|
434
|
+
},
|
|
435
|
+
true
|
|
436
|
+
)
|
|
415
437
|
__TS__SetDescriptor(
|
|
416
438
|
UnitWeapon.prototype,
|
|
417
439
|
"cooldown",
|
|
@@ -446,6 +468,19 @@ __TS__SetDescriptor(
|
|
|
446
468
|
},
|
|
447
469
|
true
|
|
448
470
|
)
|
|
471
|
+
__TS__SetDescriptor(
|
|
472
|
+
UnitWeapon.prototype,
|
|
473
|
+
"allowedTargetCombatClassifications",
|
|
474
|
+
{
|
|
475
|
+
get = function(self)
|
|
476
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
477
|
+
end,
|
|
478
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
479
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
480
|
+
end
|
|
481
|
+
},
|
|
482
|
+
true
|
|
483
|
+
)
|
|
449
484
|
__TS__SetDescriptor(
|
|
450
485
|
UnitWeapon.prototype,
|
|
451
486
|
"damageBase",
|
|
@@ -622,26 +657,30 @@ local fieldSetters = {
|
|
|
622
657
|
}
|
|
623
658
|
local dummies = {}
|
|
624
659
|
for ____, player in ipairs(Player.all) do
|
|
625
|
-
local dummy = assert(
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
660
|
+
local dummy = assert(
|
|
661
|
+
createUnit(
|
|
662
|
+
player.handle,
|
|
663
|
+
dummyUnitId,
|
|
664
|
+
0,
|
|
665
|
+
0,
|
|
666
|
+
270
|
|
667
|
+
),
|
|
668
|
+
"dummy must be created",
|
|
669
|
+
player
|
|
670
|
+
)
|
|
632
671
|
ShowUnit(dummy, false)
|
|
633
672
|
dummies[player] = dummy
|
|
634
673
|
end
|
|
635
674
|
local function delayHealthChecksCallback(unit)
|
|
636
|
-
local counter = (unit[
|
|
675
|
+
local counter = (unit[104] or 0) - 1
|
|
637
676
|
if counter ~= 0 then
|
|
638
|
-
unit[
|
|
677
|
+
unit[104] = counter
|
|
639
678
|
return
|
|
640
679
|
end
|
|
641
|
-
unit[
|
|
642
|
-
local healthBonus = unit[
|
|
680
|
+
unit[104] = nil
|
|
681
|
+
local healthBonus = unit[105]
|
|
643
682
|
if healthBonus ~= nil then
|
|
644
|
-
unit[
|
|
683
|
+
unit[105] = nil
|
|
645
684
|
local handle = unit.handle
|
|
646
685
|
BlzSetUnitMaxHP(
|
|
647
686
|
handle,
|
|
@@ -652,51 +691,76 @@ end
|
|
|
652
691
|
local nextSyncId = 1
|
|
653
692
|
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
654
693
|
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
694
|
+
local function addAbility(unit, abilityTypeId)
|
|
695
|
+
local ____unitAddAbility_result_0
|
|
696
|
+
if unitAddAbility(unit, abilityTypeId) then
|
|
697
|
+
____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
|
|
698
|
+
else
|
|
699
|
+
____unitAddAbility_result_0 = nil
|
|
700
|
+
end
|
|
701
|
+
return ____unitAddAbility_result_0
|
|
702
|
+
end
|
|
655
703
|
____exports.Unit = __TS__Class()
|
|
656
704
|
local Unit = ____exports.Unit
|
|
657
705
|
Unit.name = "Unit"
|
|
658
706
|
__TS__ClassExtends(Unit, Handle)
|
|
659
707
|
function Unit.prototype.____constructor(self, handle)
|
|
660
708
|
Handle.prototype.____constructor(self, handle)
|
|
661
|
-
local
|
|
662
|
-
nextSyncId =
|
|
663
|
-
self.syncId =
|
|
709
|
+
local ____nextSyncId_1 = nextSyncId
|
|
710
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
711
|
+
self.syncId = ____nextSyncId_1
|
|
664
712
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
665
|
-
assert(
|
|
666
|
-
|
|
713
|
+
assert(
|
|
714
|
+
unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId),
|
|
715
|
+
"leave detection ability must be added",
|
|
716
|
+
self
|
|
717
|
+
)
|
|
718
|
+
assert(
|
|
719
|
+
unitAddAbility(handle, morphDetectAbilityId),
|
|
720
|
+
"morph detection ability must be added",
|
|
721
|
+
self
|
|
722
|
+
)
|
|
667
723
|
if unitAddAbility(
|
|
668
724
|
handle,
|
|
669
725
|
fourCC("Amrf")
|
|
670
726
|
) then
|
|
671
|
-
assert(
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
727
|
+
assert(
|
|
728
|
+
unitRemoveAbility(
|
|
729
|
+
handle,
|
|
730
|
+
fourCC("Amrf")
|
|
731
|
+
),
|
|
732
|
+
"fly ability must be removed after addition",
|
|
733
|
+
self
|
|
734
|
+
)
|
|
675
735
|
end
|
|
676
736
|
unitBySyncId[self.syncId] = self
|
|
677
737
|
local ____ = self.abilities
|
|
678
738
|
end
|
|
679
|
-
function Unit.prototype.getEvent(self,
|
|
680
|
-
self.events = self.events or (
|
|
681
|
-
local eventId = GetHandleId(
|
|
682
|
-
|
|
683
|
-
|
|
739
|
+
function Unit.prototype.getEvent(self, jevent, collector)
|
|
740
|
+
self.events = self.events or __TS__New(LinkedMap)
|
|
741
|
+
local eventId = GetHandleId(jevent)
|
|
742
|
+
local event = self.events:get(eventId)
|
|
743
|
+
if event == nil then
|
|
744
|
+
event = __TS__New(
|
|
684
745
|
TriggerEvent,
|
|
685
746
|
function(trigger)
|
|
686
|
-
TriggerRegisterUnitEvent(trigger, self.handle,
|
|
747
|
+
TriggerRegisterUnitEvent(trigger, self.handle, jevent)
|
|
687
748
|
end,
|
|
688
749
|
collector or (function() return {} end)
|
|
689
750
|
)
|
|
751
|
+
self.events:put(eventId, event)
|
|
690
752
|
end
|
|
691
|
-
return
|
|
753
|
+
return event
|
|
754
|
+
end
|
|
755
|
+
function Unit.prototype.saveData(self)
|
|
756
|
+
local handle = self.handle
|
|
757
|
+
self[108] = self[108] or getUnitX(handle)
|
|
758
|
+
self[109] = self[109] or getUnitY(handle)
|
|
759
|
+
self._owner = self._owner or Player:of(getOwningPlayer(handle))
|
|
692
760
|
end
|
|
693
761
|
function Unit.prototype.onDestroy(self)
|
|
694
762
|
local handle = self.handle
|
|
695
|
-
self
|
|
696
|
-
self[108] = getUnitY(handle)
|
|
697
|
-
if not self._owner then
|
|
698
|
-
self._owner = Player:of(getOwningPlayer(handle))
|
|
699
|
-
end
|
|
763
|
+
self:saveData()
|
|
700
764
|
local abilities = self.abilities
|
|
701
765
|
for ____, ability in ipairs(abilities) do
|
|
702
766
|
ability:destroy()
|
|
@@ -732,7 +796,11 @@ function Unit.prototype.addAttackHandler(self, condition, action)
|
|
|
732
796
|
self._attackHandlers = handlers
|
|
733
797
|
if #handlers == 1 then
|
|
734
798
|
local handle = self.handle
|
|
735
|
-
assert(
|
|
799
|
+
assert(
|
|
800
|
+
unitAddAbility(handle, attackHandlerAbilityId) and UnitMakeAbilityPermanent(handle, true, attackHandlerAbilityId),
|
|
801
|
+
"attack handler ability must be added",
|
|
802
|
+
self
|
|
803
|
+
)
|
|
736
804
|
end
|
|
737
805
|
return handler
|
|
738
806
|
end
|
|
@@ -761,17 +829,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
761
829
|
end}
|
|
762
830
|
end
|
|
763
831
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
764
|
-
local
|
|
765
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
832
|
+
local ____combatClassification_2 = combatClassification
|
|
833
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
|
|
766
834
|
end
|
|
767
835
|
function Unit.prototype.addClassification(self, classification)
|
|
768
|
-
return
|
|
836
|
+
return UnitAddType(self.handle, classification)
|
|
769
837
|
end
|
|
770
838
|
function Unit.prototype.removeClassification(self, classification)
|
|
771
|
-
return
|
|
839
|
+
return UnitRemoveType(self.handle, classification)
|
|
772
840
|
end
|
|
773
841
|
function Unit.prototype.hasClassification(self, classification)
|
|
774
|
-
return
|
|
842
|
+
return IsUnitType(self.handle, classification)
|
|
775
843
|
end
|
|
776
844
|
function Unit.prototype.isVisibleTo(self, player)
|
|
777
845
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -780,13 +848,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
780
848
|
return isUnitInvisible(self.handle, player.handle)
|
|
781
849
|
end
|
|
782
850
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
783
|
-
local
|
|
851
|
+
local ____temp_3
|
|
784
852
|
if type(x) == "number" then
|
|
785
|
-
|
|
853
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
786
854
|
else
|
|
787
|
-
|
|
855
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
788
856
|
end
|
|
789
|
-
return
|
|
857
|
+
return ____temp_3
|
|
790
858
|
end
|
|
791
859
|
function Unit.prototype.isAllyOf(self, unit)
|
|
792
860
|
return isUnitAlly(
|
|
@@ -815,8 +883,19 @@ end
|
|
|
815
883
|
function Unit.prototype.queueAnimation(self, animation)
|
|
816
884
|
QueueUnitAnimation(self.handle, animation)
|
|
817
885
|
end
|
|
886
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
887
|
+
local firstWeapon = self.firstWeapon
|
|
888
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
889
|
+
return firstWeapon
|
|
890
|
+
end
|
|
891
|
+
local secondWeapon = self.secondWeapon
|
|
892
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
893
|
+
return secondWeapon
|
|
894
|
+
end
|
|
895
|
+
return nil
|
|
896
|
+
end
|
|
818
897
|
function Unit.prototype.delayHealthChecks(self)
|
|
819
|
-
self[
|
|
898
|
+
self[104] = (self[104] or 0) + 1
|
|
820
899
|
Timer:run(delayHealthChecksCallback, self)
|
|
821
900
|
end
|
|
822
901
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -833,14 +912,14 @@ function Unit.prototype.kill(self)
|
|
|
833
912
|
killUnit(self.handle)
|
|
834
913
|
end
|
|
835
914
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
836
|
-
local
|
|
837
|
-
local
|
|
838
|
-
local
|
|
839
|
-
if
|
|
840
|
-
|
|
915
|
+
local ____ReviveHero_6 = ReviveHero
|
|
916
|
+
local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
|
|
917
|
+
local ____doEffect_4 = doEffect
|
|
918
|
+
if ____doEffect_4 == nil then
|
|
919
|
+
____doEffect_4 = false
|
|
841
920
|
end
|
|
842
|
-
__TS__SparseArrayPush(
|
|
843
|
-
|
|
921
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
922
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
844
923
|
end
|
|
845
924
|
function Unit.prototype.healTarget(self, target, amount)
|
|
846
925
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -883,17 +962,16 @@ function Unit.prototype.itemInSlot(self, slot)
|
|
|
883
962
|
return Item:of(unitItemInSlot(self.handle, slot))
|
|
884
963
|
end
|
|
885
964
|
function Unit.prototype.addAbility(self, abilityId)
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
965
|
+
local ability = UnitAbility:of(
|
|
966
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
967
|
+
abilityId,
|
|
968
|
+
self
|
|
969
|
+
)
|
|
970
|
+
if ability ~= nil then
|
|
892
971
|
local abilities = self.abilities
|
|
893
972
|
abilities[#abilities + 1] = ability
|
|
894
|
-
return ability
|
|
895
973
|
end
|
|
896
|
-
return
|
|
974
|
+
return ability
|
|
897
975
|
end
|
|
898
976
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
899
977
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -907,31 +985,21 @@ end
|
|
|
907
985
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
908
986
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
909
987
|
end
|
|
910
|
-
function Unit.prototype.
|
|
911
|
-
local
|
|
912
|
-
|
|
913
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
914
|
-
return nil
|
|
915
|
-
end
|
|
916
|
-
return UnitAbility:of(
|
|
917
|
-
getUnitAbility(self.handle, abilityId),
|
|
918
|
-
abilityId,
|
|
919
|
-
self
|
|
920
|
-
)
|
|
988
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
989
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
990
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
921
991
|
end
|
|
922
|
-
function Unit.prototype.removeAbility(self,
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
end
|
|
992
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
993
|
+
local abilities = self.abilities
|
|
994
|
+
for i = 1, #abilities do
|
|
995
|
+
if abilities[i].typeId == abilityTypeId then
|
|
996
|
+
local ability = abilities[i]
|
|
997
|
+
tremove(abilities, i)
|
|
998
|
+
ability:destroy()
|
|
999
|
+
return true
|
|
931
1000
|
end
|
|
932
|
-
return true
|
|
933
1001
|
end
|
|
934
|
-
return
|
|
1002
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
935
1003
|
end
|
|
936
1004
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
937
1005
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -945,9 +1013,6 @@ end
|
|
|
945
1013
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
946
1014
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
947
1015
|
end
|
|
948
|
-
function Unit.prototype.interruptAttack(self)
|
|
949
|
-
unitInterruptAttack(self.handle)
|
|
950
|
-
end
|
|
951
1016
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
952
1017
|
local handle = self.handle
|
|
953
1018
|
unitDisableAbility(handle, abilityId, true, false)
|
|
@@ -1018,18 +1083,44 @@ function Unit.prototype.unpauseEx(self)
|
|
|
1018
1083
|
end
|
|
1019
1084
|
function Unit.prototype.incrementStunCounter(self)
|
|
1020
1085
|
local stunCounter = self[102] or 0
|
|
1021
|
-
if not self[101] or stunCounter >= 0 then
|
|
1086
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
|
|
1022
1087
|
BlzPauseUnitEx(self.handle, true)
|
|
1023
1088
|
end
|
|
1024
1089
|
self[102] = stunCounter + 1
|
|
1025
1090
|
end
|
|
1026
1091
|
function Unit.prototype.decrementStunCounter(self)
|
|
1027
1092
|
local stunCounter = self[102] or 0
|
|
1028
|
-
if not self[101] or stunCounter >= 1 then
|
|
1093
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
|
|
1029
1094
|
BlzPauseUnitEx(self.handle, false)
|
|
1030
1095
|
end
|
|
1031
1096
|
self[102] = stunCounter - 1
|
|
1032
1097
|
end
|
|
1098
|
+
function Unit.prototype.incrementForceStunCounter(self)
|
|
1099
|
+
local forceStunCounter = self[103] or 0
|
|
1100
|
+
if forceStunCounter == 0 then
|
|
1101
|
+
local handle = self.handle
|
|
1102
|
+
if not self[101] then
|
|
1103
|
+
for _ = self[102] or 0, -1 do
|
|
1104
|
+
BlzPauseUnitEx(handle, true)
|
|
1105
|
+
end
|
|
1106
|
+
end
|
|
1107
|
+
BlzPauseUnitEx(handle, true)
|
|
1108
|
+
end
|
|
1109
|
+
self[103] = forceStunCounter + 1
|
|
1110
|
+
end
|
|
1111
|
+
function Unit.prototype.decrementForceStunCounter(self)
|
|
1112
|
+
local forceStunCounter = self[103] or 0
|
|
1113
|
+
if forceStunCounter == 1 then
|
|
1114
|
+
local handle = self.handle
|
|
1115
|
+
if not self[101] then
|
|
1116
|
+
for _ = self[102] or 0, -1 do
|
|
1117
|
+
BlzPauseUnitEx(handle, false)
|
|
1118
|
+
end
|
|
1119
|
+
end
|
|
1120
|
+
BlzPauseUnitEx(handle, false)
|
|
1121
|
+
end
|
|
1122
|
+
self[103] = forceStunCounter - 1
|
|
1123
|
+
end
|
|
1033
1124
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1034
1125
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
1035
1126
|
owner.handle,
|
|
@@ -1218,7 +1309,7 @@ __TS__SetDescriptor(
|
|
|
1218
1309
|
Unit.prototype,
|
|
1219
1310
|
"isIllusion",
|
|
1220
1311
|
{get = function(self)
|
|
1221
|
-
return
|
|
1312
|
+
return IsUnitIllusion(self.handle)
|
|
1222
1313
|
end},
|
|
1223
1314
|
true
|
|
1224
1315
|
)
|
|
@@ -1316,19 +1407,6 @@ __TS__SetDescriptor(
|
|
|
1316
1407
|
},
|
|
1317
1408
|
true
|
|
1318
1409
|
)
|
|
1319
|
-
__TS__SetDescriptor(
|
|
1320
|
-
Unit.prototype,
|
|
1321
|
-
"strengthBase",
|
|
1322
|
-
{
|
|
1323
|
-
get = function(self)
|
|
1324
|
-
return getHeroStr(self.handle, false)
|
|
1325
|
-
end,
|
|
1326
|
-
set = function(self, strengthBase)
|
|
1327
|
-
setHeroStr(self.handle, strengthBase, true)
|
|
1328
|
-
end
|
|
1329
|
-
},
|
|
1330
|
-
true
|
|
1331
|
-
)
|
|
1332
1410
|
__TS__SetDescriptor(
|
|
1333
1411
|
Unit.prototype,
|
|
1334
1412
|
"strengthBonus",
|
|
@@ -1346,19 +1424,6 @@ __TS__SetDescriptor(
|
|
|
1346
1424
|
end},
|
|
1347
1425
|
true
|
|
1348
1426
|
)
|
|
1349
|
-
__TS__SetDescriptor(
|
|
1350
|
-
Unit.prototype,
|
|
1351
|
-
"agilityBase",
|
|
1352
|
-
{
|
|
1353
|
-
get = function(self)
|
|
1354
|
-
return getHeroAgi(self.handle, false)
|
|
1355
|
-
end,
|
|
1356
|
-
set = function(self, agilityBase)
|
|
1357
|
-
setHeroAgi(self.handle, agilityBase, true)
|
|
1358
|
-
end
|
|
1359
|
-
},
|
|
1360
|
-
true
|
|
1361
|
-
)
|
|
1362
1427
|
__TS__SetDescriptor(
|
|
1363
1428
|
Unit.prototype,
|
|
1364
1429
|
"agilityBonus",
|
|
@@ -1376,19 +1441,6 @@ __TS__SetDescriptor(
|
|
|
1376
1441
|
end},
|
|
1377
1442
|
true
|
|
1378
1443
|
)
|
|
1379
|
-
__TS__SetDescriptor(
|
|
1380
|
-
Unit.prototype,
|
|
1381
|
-
"intelligenceBase",
|
|
1382
|
-
{
|
|
1383
|
-
get = function(self)
|
|
1384
|
-
return getHeroInt(self.handle, false)
|
|
1385
|
-
end,
|
|
1386
|
-
set = function(self, intelligenceBase)
|
|
1387
|
-
setHeroInt(self.handle, intelligenceBase, true)
|
|
1388
|
-
end
|
|
1389
|
-
},
|
|
1390
|
-
true
|
|
1391
|
-
)
|
|
1392
1444
|
__TS__SetDescriptor(
|
|
1393
1445
|
Unit.prototype,
|
|
1394
1446
|
"intelligenceBonus",
|
|
@@ -1437,17 +1489,17 @@ __TS__SetDescriptor(
|
|
|
1437
1489
|
"isTeamGlowVisible",
|
|
1438
1490
|
{
|
|
1439
1491
|
get = function(self)
|
|
1440
|
-
return not self[
|
|
1492
|
+
return not self[107]
|
|
1441
1493
|
end,
|
|
1442
1494
|
set = function(self, isTeamGlowVisible)
|
|
1443
1495
|
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1444
|
-
local
|
|
1496
|
+
local ____temp_7
|
|
1445
1497
|
if not isTeamGlowVisible then
|
|
1446
|
-
|
|
1498
|
+
____temp_7 = true
|
|
1447
1499
|
else
|
|
1448
|
-
|
|
1500
|
+
____temp_7 = nil
|
|
1449
1501
|
end
|
|
1450
|
-
self[
|
|
1502
|
+
self[107] = ____temp_7
|
|
1451
1503
|
end
|
|
1452
1504
|
},
|
|
1453
1505
|
true
|
|
@@ -1457,7 +1509,7 @@ __TS__SetDescriptor(
|
|
|
1457
1509
|
"color",
|
|
1458
1510
|
{set = function(self, color)
|
|
1459
1511
|
SetUnitColor(self.handle, color.handle)
|
|
1460
|
-
if self[
|
|
1512
|
+
if self[107] then
|
|
1461
1513
|
BlzShowUnitTeamGlow(self.handle, false)
|
|
1462
1514
|
end
|
|
1463
1515
|
end},
|
|
@@ -1481,14 +1533,14 @@ __TS__SetDescriptor(
|
|
|
1481
1533
|
"maxHealth",
|
|
1482
1534
|
{
|
|
1483
1535
|
get = function(self)
|
|
1484
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1536
|
+
return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
|
|
1485
1537
|
end,
|
|
1486
1538
|
set = function(self, maxHealth)
|
|
1487
|
-
if maxHealth < 1 and self[
|
|
1488
|
-
self[
|
|
1539
|
+
if maxHealth < 1 and self[104] ~= nil then
|
|
1540
|
+
self[105] = (self[105] or 0) + (1 - maxHealth)
|
|
1489
1541
|
maxHealth = 1
|
|
1490
1542
|
end
|
|
1491
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1543
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
|
|
1492
1544
|
end
|
|
1493
1545
|
},
|
|
1494
1546
|
true
|
|
@@ -1530,10 +1582,10 @@ __TS__SetDescriptor(
|
|
|
1530
1582
|
"health",
|
|
1531
1583
|
{
|
|
1532
1584
|
get = function(self)
|
|
1533
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1585
|
+
return GetWidgetLife(self.handle) - (self[106] or 0)
|
|
1534
1586
|
end,
|
|
1535
1587
|
set = function(self, health)
|
|
1536
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1588
|
+
SetWidgetLife(self.handle, health + (self[106] or 0))
|
|
1537
1589
|
end
|
|
1538
1590
|
},
|
|
1539
1591
|
true
|
|
@@ -1609,25 +1661,12 @@ __TS__SetDescriptor(
|
|
|
1609
1661
|
},
|
|
1610
1662
|
true
|
|
1611
1663
|
)
|
|
1612
|
-
__TS__SetDescriptor(
|
|
1613
|
-
Unit.prototype,
|
|
1614
|
-
"flyHeight",
|
|
1615
|
-
{
|
|
1616
|
-
get = function(self)
|
|
1617
|
-
return getUnitFlyHeight(self.handle)
|
|
1618
|
-
end,
|
|
1619
|
-
set = function(self, v)
|
|
1620
|
-
SetUnitFlyHeight(self.handle, v, 100000)
|
|
1621
|
-
end
|
|
1622
|
-
},
|
|
1623
|
-
true
|
|
1624
|
-
)
|
|
1625
1664
|
__TS__SetDescriptor(
|
|
1626
1665
|
Unit.prototype,
|
|
1627
1666
|
"x",
|
|
1628
1667
|
{
|
|
1629
1668
|
get = function(self)
|
|
1630
|
-
return self[
|
|
1669
|
+
return self[108] or getUnitX(self.handle)
|
|
1631
1670
|
end,
|
|
1632
1671
|
set = function(self, v)
|
|
1633
1672
|
SetUnitX(self.handle, v)
|
|
@@ -1640,7 +1679,7 @@ __TS__SetDescriptor(
|
|
|
1640
1679
|
"y",
|
|
1641
1680
|
{
|
|
1642
1681
|
get = function(self)
|
|
1643
|
-
return self[
|
|
1682
|
+
return self[109] or getUnitY(self.handle)
|
|
1644
1683
|
end,
|
|
1645
1684
|
set = function(self, v)
|
|
1646
1685
|
SetUnitY(self.handle, v)
|
|
@@ -1745,14 +1784,18 @@ __TS__SetDescriptor(
|
|
|
1745
1784
|
local handle = self.handle
|
|
1746
1785
|
if isPaused and not IsUnitPaused(handle) then
|
|
1747
1786
|
self[101] = true
|
|
1748
|
-
|
|
1749
|
-
|
|
1787
|
+
if (self[103] or 0) <= 0 then
|
|
1788
|
+
for _ = self[102] or 0, -1 do
|
|
1789
|
+
BlzPauseUnitEx(handle, true)
|
|
1790
|
+
end
|
|
1750
1791
|
end
|
|
1751
1792
|
PauseUnit(handle, true)
|
|
1752
1793
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1753
1794
|
PauseUnit(handle, false)
|
|
1754
|
-
|
|
1755
|
-
|
|
1795
|
+
if (self[103] or 0) <= 0 then
|
|
1796
|
+
for _ = self[102] or 0, -1 do
|
|
1797
|
+
BlzPauseUnitEx(handle, false)
|
|
1798
|
+
end
|
|
1756
1799
|
end
|
|
1757
1800
|
self[101] = nil
|
|
1758
1801
|
end
|
|
@@ -1810,20 +1853,6 @@ __TS__SetDescriptor(
|
|
|
1810
1853
|
},
|
|
1811
1854
|
true
|
|
1812
1855
|
)
|
|
1813
|
-
__TS__SetDescriptor(
|
|
1814
|
-
Unit.prototype,
|
|
1815
|
-
"scale",
|
|
1816
|
-
{
|
|
1817
|
-
get = function(self)
|
|
1818
|
-
return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
|
|
1819
|
-
end,
|
|
1820
|
-
set = function(self, v)
|
|
1821
|
-
setUnitScale(self.handle, v, v, v)
|
|
1822
|
-
setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
|
|
1823
|
-
end
|
|
1824
|
-
},
|
|
1825
|
-
true
|
|
1826
|
-
)
|
|
1827
1856
|
__TS__SetDescriptor(
|
|
1828
1857
|
Unit.prototype,
|
|
1829
1858
|
"timeScale",
|
|
@@ -1960,30 +1989,6 @@ __TS__SetDescriptor(
|
|
|
1960
1989
|
end},
|
|
1961
1990
|
true
|
|
1962
1991
|
)
|
|
1963
|
-
__TS__SetDescriptor(
|
|
1964
|
-
Unit.prototype,
|
|
1965
|
-
"onUnitInRange",
|
|
1966
|
-
{get = function(self)
|
|
1967
|
-
local handle = self.handle
|
|
1968
|
-
local onUnitInRange = setmetatable(
|
|
1969
|
-
{},
|
|
1970
|
-
{__index = function(self, value)
|
|
1971
|
-
local event = __TS__New(
|
|
1972
|
-
TriggerEvent,
|
|
1973
|
-
function(trigger)
|
|
1974
|
-
TriggerRegisterUnitInRangeSimple(trigger, value, handle)
|
|
1975
|
-
end,
|
|
1976
|
-
function() return ____exports.Unit:of(handle) end
|
|
1977
|
-
)
|
|
1978
|
-
rawset(self, value, event)
|
|
1979
|
-
return event
|
|
1980
|
-
end}
|
|
1981
|
-
)
|
|
1982
|
-
rawset(self, "onUnitInRange", onUnitInRange)
|
|
1983
|
-
return onUnitInRange
|
|
1984
|
-
end},
|
|
1985
|
-
true
|
|
1986
|
-
)
|
|
1987
1992
|
__TS__SetDescriptor(
|
|
1988
1993
|
Unit.prototype,
|
|
1989
1994
|
"onManaEqual",
|
|
@@ -2119,6 +2124,11 @@ __TS__SetDescriptor(
|
|
|
2119
2124
|
end},
|
|
2120
2125
|
true
|
|
2121
2126
|
)
|
|
2127
|
+
Unit.levelChangedEvent = __TS__New(
|
|
2128
|
+
____exports.UnitTriggerEvent,
|
|
2129
|
+
EVENT_PLAYER_HERO_LEVEL,
|
|
2130
|
+
function() return ____exports.Unit:of(getTriggerUnit()) end
|
|
2131
|
+
)
|
|
2122
2132
|
Unit.deathEvent = __TS__New(
|
|
2123
2133
|
____exports.UnitTriggerEvent,
|
|
2124
2134
|
EVENT_PLAYER_UNIT_DEATH,
|
|
@@ -2194,25 +2204,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2194
2204
|
InitializingEvent,
|
|
2195
2205
|
function(event)
|
|
2196
2206
|
local function listener(unit, id)
|
|
2197
|
-
local
|
|
2207
|
+
local ____GetSpellTargetUnit_result_10
|
|
2198
2208
|
if GetSpellTargetUnit() then
|
|
2199
|
-
|
|
2209
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2200
2210
|
else
|
|
2201
|
-
local
|
|
2211
|
+
local ____GetSpellTargetItem_result_9
|
|
2202
2212
|
if GetSpellTargetItem() then
|
|
2203
|
-
|
|
2213
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2204
2214
|
else
|
|
2205
|
-
local
|
|
2215
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2206
2216
|
if GetSpellTargetDestructable() then
|
|
2207
|
-
|
|
2217
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2208
2218
|
else
|
|
2209
|
-
|
|
2219
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2210
2220
|
end
|
|
2211
|
-
|
|
2221
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2212
2222
|
end
|
|
2213
|
-
|
|
2223
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2214
2224
|
end
|
|
2215
|
-
local target =
|
|
2225
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2216
2226
|
if target then
|
|
2217
2227
|
invoke(event, unit, id, target)
|
|
2218
2228
|
end
|
|
@@ -2435,12 +2445,7 @@ Unit.onDamaging = (function()
|
|
|
2435
2445
|
preventRetaliation = damagingEventPreventRetaliation
|
|
2436
2446
|
}
|
|
2437
2447
|
if data.isAttack and source then
|
|
2438
|
-
|
|
2439
|
-
if weapon == -1 then
|
|
2440
|
-
local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
|
|
2441
|
-
weapon = 0
|
|
2442
|
-
end
|
|
2443
|
-
data.weapon = assert(source.weapons[weapon + 1])
|
|
2448
|
+
data.weapon = source:chooseWeapon(target)
|
|
2444
2449
|
end
|
|
2445
2450
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2446
2451
|
invoke(
|
|
@@ -2585,7 +2590,7 @@ Unit.onDamage = __TS__New(
|
|
|
2585
2590
|
invoke(event, source, target, evData)
|
|
2586
2591
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2587
2592
|
local bonusHealth = math.ceil(evData.amount)
|
|
2588
|
-
target[
|
|
2593
|
+
target[106] = (target[106] or 0) + bonusHealth
|
|
2589
2594
|
BlzSetUnitMaxHP(
|
|
2590
2595
|
target.handle,
|
|
2591
2596
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2599,7 +2604,7 @@ Unit.onDamage = __TS__New(
|
|
|
2599
2604
|
evData[0],
|
|
2600
2605
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2601
2606
|
)
|
|
2602
|
-
target[
|
|
2607
|
+
target[106] = (target[106] or 0) - bonusHealth
|
|
2603
2608
|
SetWidgetLife(
|
|
2604
2609
|
target.handle,
|
|
2605
2610
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2635,10 +2640,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2635
2640
|
____exports.UnitTriggerEvent,
|
|
2636
2641
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2637
2642
|
function()
|
|
2638
|
-
local
|
|
2639
|
-
local
|
|
2640
|
-
if getUnitTypeId(
|
|
2641
|
-
|
|
2643
|
+
local unitHandle = getTriggerUnit()
|
|
2644
|
+
local itemHandle = getManipulatedItem()
|
|
2645
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2646
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2647
|
+
local item = Item:of(itemHandle)
|
|
2648
|
+
if item.owner ~= unit then
|
|
2649
|
+
return unit, item
|
|
2650
|
+
end
|
|
2642
2651
|
end
|
|
2643
2652
|
return IgnoreEvent
|
|
2644
2653
|
end
|
|
@@ -2658,7 +2667,22 @@ Unit.itemUsedEvent = __TS__New(
|
|
|
2658
2667
|
Unit.itemStackedEvent = __TS__New(
|
|
2659
2668
|
____exports.UnitTriggerEvent,
|
|
2660
2669
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2661
|
-
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(
|
|
2670
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2671
|
+
)
|
|
2672
|
+
__TS__ObjectDefineProperty(
|
|
2673
|
+
Unit,
|
|
2674
|
+
"itemChargesChangedEvent",
|
|
2675
|
+
{get = function(self)
|
|
2676
|
+
local event = __TS__New(Event)
|
|
2677
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2678
|
+
local unit = item.owner
|
|
2679
|
+
if unit ~= nil then
|
|
2680
|
+
invoke(event, unit, item)
|
|
2681
|
+
end
|
|
2682
|
+
end)
|
|
2683
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2684
|
+
return event
|
|
2685
|
+
end}
|
|
2662
2686
|
)
|
|
2663
2687
|
__TS__ObjectDefineProperty(
|
|
2664
2688
|
Unit,
|
|
@@ -2730,6 +2754,10 @@ __TS__ObjectDefineProperty(
|
|
|
2730
2754
|
rawset(self, "destroyEvent", destroyEvent)
|
|
2731
2755
|
return destroyEvent
|
|
2732
2756
|
end}
|
|
2757
|
+
)
|
|
2758
|
+
Unit.synchronize = synchronizer(
|
|
2759
|
+
function(unit) return unit.syncId end,
|
|
2760
|
+
function(syncId) return unitBySyncId[syncId] end
|
|
2733
2761
|
);
|
|
2734
2762
|
(function(self)
|
|
2735
2763
|
local leaveAbilityIds = postcompile(function()
|
|
@@ -2759,7 +2787,8 @@ __TS__ObjectDefineProperty(
|
|
|
2759
2787
|
return
|
|
2760
2788
|
end
|
|
2761
2789
|
end
|
|
2762
|
-
unit:
|
|
2790
|
+
unit:saveData()
|
|
2791
|
+
Timer:run(unit, "destroy")
|
|
2763
2792
|
end)
|
|
2764
2793
|
end
|
|
2765
2794
|
end)(Unit)
|