warscript 0.0.1-dev.a58cc52 → 0.0.1-dev.a5a2f5e
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 +6 -0
- package/attributes.lua +17 -1
- package/core/types/frame.lua +71 -22
- package/core/types/item.d.ts +1 -0
- package/core/types/item.lua +1 -0
- package/core/types/player.d.ts +17 -1
- package/core/types/player.lua +70 -24
- 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 +7 -2
- package/engine/behaviour/ability/damage.lua +31 -37
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +16 -7
- 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 +7 -1
- package/engine/internal/ability.lua +64 -24
- package/engine/internal/item/ability.lua +63 -11
- package/engine/internal/item/fields.d.ts +12 -0
- package/engine/internal/item/fields.lua +33 -0
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +12 -16
- package/engine/internal/item.lua +118 -69
- package/engine/internal/mechanics/cast-ability.lua +6 -3
- package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
- package/engine/internal/misc/frame-coordinates.d.ts +2 -0
- package/engine/internal/misc/frame-coordinates.lua +21 -0
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/misc/player-local-handle.d.ts +2 -0
- package/engine/internal/misc/player-local-handle.lua +5 -0
- package/engine/internal/object-data/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+damage.d.ts +1 -1
- package/engine/internal/unit+damage.lua +6 -1
- package/engine/internal/unit-missile-launch.lua +52 -14
- package/engine/internal/unit.d.ts +32 -26
- package/engine/internal/unit.lua +351 -269
- package/engine/local-client.d.ts +7 -0
- package/engine/local-client.lua +86 -1
- 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/permanent-invisibility.d.ts +8 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
- package/engine/object-data/entry/ability-type/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/item.d.ts +22 -0
- package/engine/object-field/item.lua +118 -0
- 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/item.d.ts +4 -0
- package/engine/standard/fields/item.lua +6 -0
- 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/math.d.ts +2 -0
- package/math.lua +14 -0
- 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 +35 -0
- package/utility/linked-map.lua +107 -0
- package/utility/linked-set.d.ts +4 -1
- package/utility/linked-set.lua +46 -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/utility/unordered-map.d.ts +27 -0
- package/utility/unordered-map.lua +99 -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/damage-metadata-by-target.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
|
@@ -56,35 +56,37 @@ local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
|
56
56
|
local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
|
|
57
57
|
local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
|
|
58
58
|
local nativeToAttackType = ____attack_2Dtype.nativeToAttackType
|
|
59
|
+
local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
|
|
60
|
+
local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
|
|
61
|
+
local ____attributes = require("attributes")
|
|
62
|
+
local isAttribute = ____attributes.isAttribute
|
|
63
|
+
local ____ability = require("engine.internal.item.ability")
|
|
64
|
+
local doUnitAbilityAction = ____ability.doUnitAbilityAction
|
|
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
|
|
59
69
|
local match = string.match
|
|
60
70
|
local ____tostring = _G.tostring
|
|
61
71
|
local setUnitAnimation = SetUnitAnimation
|
|
62
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
63
72
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
64
|
-
local resetUnitAnimation = ResetUnitAnimation
|
|
65
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
66
73
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
67
74
|
local getUnitRealField = BlzGetUnitRealField
|
|
68
75
|
local getHeroStr = GetHeroStr
|
|
69
76
|
local getHeroAgi = GetHeroAgi
|
|
70
77
|
local getHeroInt = GetHeroInt
|
|
71
|
-
local setHeroStr = SetHeroStr
|
|
72
|
-
local setHeroAgi = SetHeroAgi
|
|
73
|
-
local setHeroInt = SetHeroInt
|
|
74
78
|
local getUnitBooleanField = BlzGetUnitBooleanField
|
|
75
79
|
local getUnitStringField = BlzGetUnitStringField
|
|
76
80
|
local setUnitIntegerField = BlzSetUnitIntegerField
|
|
77
81
|
local setUnitRealField = BlzSetUnitRealField
|
|
78
82
|
local setUnitBooleanField = BlzSetUnitBooleanField
|
|
79
83
|
local setUnitStringField = BlzSetUnitStringField
|
|
80
|
-
local setUnitScale = SetUnitScale
|
|
81
84
|
local setUnitPosition = SetUnitPosition
|
|
82
85
|
local setUnitTimeScale = SetUnitTimeScale
|
|
83
86
|
local getHandleId = GetHandleId
|
|
84
87
|
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
85
88
|
local createUnit = CreateUnit
|
|
86
89
|
local killUnit = KillUnit
|
|
87
|
-
local setUnitExploded = SetUnitExploded
|
|
88
90
|
local removeUnit = RemoveUnit
|
|
89
91
|
local getUnitTypeId = GetUnitTypeId
|
|
90
92
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -100,15 +102,12 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
100
102
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
101
103
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
102
104
|
local isUnitInRange = IsUnitInRange
|
|
103
|
-
local setResourceAmount = SetResourceAmount
|
|
104
|
-
local getResourceAmount = GetResourceAmount
|
|
105
105
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
106
106
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
107
107
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
108
108
|
local setUnitWeaponStringField = BlzSetUnitWeaponStringField
|
|
109
109
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
110
110
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
111
|
-
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
112
111
|
local isUnitInvisible = IsUnitInvisible
|
|
113
112
|
local isUnitVisible = IsUnitVisible
|
|
114
113
|
local getUnitX = GetUnitX
|
|
@@ -125,15 +124,9 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
125
124
|
local getIssuedOrderId = GetIssuedOrderId
|
|
126
125
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
127
126
|
local unitAlive = UnitAlive
|
|
128
|
-
local unitAddType = UnitAddType
|
|
129
|
-
local unitRemoveType = UnitRemoveType
|
|
130
|
-
local isUnitIllusion = IsUnitIllusion
|
|
131
|
-
local isUnitType = IsUnitType
|
|
132
127
|
local isUnitAlly = IsUnitAlly
|
|
133
128
|
local isUnitEnemy = IsUnitEnemy
|
|
134
129
|
local getOwningPlayer = GetOwningPlayer
|
|
135
|
-
local setUnitColor = SetUnitColor
|
|
136
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
137
130
|
____exports.UnitClassification = {}
|
|
138
131
|
local UnitClassification = ____exports.UnitClassification
|
|
139
132
|
do
|
|
@@ -143,6 +136,7 @@ do
|
|
|
143
136
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
144
137
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
145
138
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
139
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
146
140
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
147
141
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
148
142
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -350,6 +344,9 @@ local function dispatchAbility(event)
|
|
|
350
344
|
}
|
|
351
345
|
)
|
|
352
346
|
end
|
|
347
|
+
local function damagingEventPreventRetaliation(self)
|
|
348
|
+
self[0] = true
|
|
349
|
+
end
|
|
353
350
|
local function damageEventPreventDeath(self, callback, ...)
|
|
354
351
|
if self[0] ~= nil then
|
|
355
352
|
return
|
|
@@ -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,
|
|
@@ -650,52 +689,78 @@ local function delayHealthChecksCallback(unit)
|
|
|
650
689
|
end
|
|
651
690
|
end
|
|
652
691
|
local nextSyncId = 1
|
|
653
|
-
local unitBySyncId = setmetatable({}, {__mode = "
|
|
692
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
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
|
|
654
703
|
____exports.Unit = __TS__Class()
|
|
655
704
|
local Unit = ____exports.Unit
|
|
656
705
|
Unit.name = "Unit"
|
|
657
706
|
__TS__ClassExtends(Unit, Handle)
|
|
658
707
|
function Unit.prototype.____constructor(self, handle)
|
|
659
708
|
Handle.prototype.____constructor(self, handle)
|
|
660
|
-
local
|
|
661
|
-
nextSyncId =
|
|
662
|
-
self.syncId =
|
|
709
|
+
local ____nextSyncId_1 = nextSyncId
|
|
710
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
711
|
+
self.syncId = ____nextSyncId_1
|
|
663
712
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
664
|
-
assert(
|
|
665
|
-
|
|
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
|
+
)
|
|
666
723
|
if unitAddAbility(
|
|
667
724
|
handle,
|
|
668
725
|
fourCC("Amrf")
|
|
669
726
|
) then
|
|
670
|
-
assert(
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
727
|
+
assert(
|
|
728
|
+
unitRemoveAbility(
|
|
729
|
+
handle,
|
|
730
|
+
fourCC("Amrf")
|
|
731
|
+
),
|
|
732
|
+
"fly ability must be removed after addition",
|
|
733
|
+
self
|
|
734
|
+
)
|
|
674
735
|
end
|
|
675
736
|
unitBySyncId[self.syncId] = self
|
|
676
737
|
local ____ = self.abilities
|
|
677
738
|
end
|
|
678
|
-
function Unit.prototype.getEvent(self,
|
|
679
|
-
self.events = self.events or (
|
|
680
|
-
local eventId = GetHandleId(
|
|
681
|
-
|
|
682
|
-
|
|
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(
|
|
683
745
|
TriggerEvent,
|
|
684
746
|
function(trigger)
|
|
685
|
-
TriggerRegisterUnitEvent(trigger, self.handle,
|
|
747
|
+
TriggerRegisterUnitEvent(trigger, self.handle, jevent)
|
|
686
748
|
end,
|
|
687
749
|
collector or (function() return {} end)
|
|
688
750
|
)
|
|
751
|
+
self.events:put(eventId, event)
|
|
689
752
|
end
|
|
690
|
-
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))
|
|
691
760
|
end
|
|
692
761
|
function Unit.prototype.onDestroy(self)
|
|
693
762
|
local handle = self.handle
|
|
694
|
-
self
|
|
695
|
-
self[108] = getUnitY(handle)
|
|
696
|
-
if not self._owner then
|
|
697
|
-
self._owner = Player:of(getOwningPlayer(handle))
|
|
698
|
-
end
|
|
763
|
+
self:saveData()
|
|
699
764
|
local abilities = self.abilities
|
|
700
765
|
for ____, ability in ipairs(abilities) do
|
|
701
766
|
ability:destroy()
|
|
@@ -731,7 +796,11 @@ function Unit.prototype.addAttackHandler(self, condition, action)
|
|
|
731
796
|
self._attackHandlers = handlers
|
|
732
797
|
if #handlers == 1 then
|
|
733
798
|
local handle = self.handle
|
|
734
|
-
assert(
|
|
799
|
+
assert(
|
|
800
|
+
unitAddAbility(handle, attackHandlerAbilityId) and UnitMakeAbilityPermanent(handle, true, attackHandlerAbilityId),
|
|
801
|
+
"attack handler ability must be added",
|
|
802
|
+
self
|
|
803
|
+
)
|
|
735
804
|
end
|
|
736
805
|
return handler
|
|
737
806
|
end
|
|
@@ -760,17 +829,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
760
829
|
end}
|
|
761
830
|
end
|
|
762
831
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
763
|
-
local
|
|
764
|
-
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
|
|
765
834
|
end
|
|
766
835
|
function Unit.prototype.addClassification(self, classification)
|
|
767
|
-
return
|
|
836
|
+
return UnitAddType(self.handle, classification)
|
|
768
837
|
end
|
|
769
838
|
function Unit.prototype.removeClassification(self, classification)
|
|
770
|
-
return
|
|
839
|
+
return UnitRemoveType(self.handle, classification)
|
|
771
840
|
end
|
|
772
841
|
function Unit.prototype.hasClassification(self, classification)
|
|
773
|
-
return
|
|
842
|
+
return IsUnitType(self.handle, classification)
|
|
774
843
|
end
|
|
775
844
|
function Unit.prototype.isVisibleTo(self, player)
|
|
776
845
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -779,13 +848,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
779
848
|
return isUnitInvisible(self.handle, player.handle)
|
|
780
849
|
end
|
|
781
850
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
782
|
-
local
|
|
851
|
+
local ____temp_3
|
|
783
852
|
if type(x) == "number" then
|
|
784
|
-
|
|
853
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
785
854
|
else
|
|
786
|
-
|
|
855
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
787
856
|
end
|
|
788
|
-
return
|
|
857
|
+
return ____temp_3
|
|
789
858
|
end
|
|
790
859
|
function Unit.prototype.isAllyOf(self, unit)
|
|
791
860
|
return isUnitAlly(
|
|
@@ -803,19 +872,30 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
803
872
|
if type(animation) == "number" then
|
|
804
873
|
setUnitAnimationByIndex(self.handle, animation)
|
|
805
874
|
elseif rarity then
|
|
806
|
-
|
|
875
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
807
876
|
else
|
|
808
877
|
setUnitAnimation(self.handle, animation)
|
|
809
878
|
end
|
|
810
879
|
end
|
|
811
880
|
function Unit.prototype.resetAnimation(self)
|
|
812
|
-
|
|
881
|
+
ResetUnitAnimation(self.handle)
|
|
813
882
|
end
|
|
814
883
|
function Unit.prototype.queueAnimation(self, animation)
|
|
815
|
-
|
|
884
|
+
QueueUnitAnimation(self.handle, animation)
|
|
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
|
|
816
896
|
end
|
|
817
897
|
function Unit.prototype.delayHealthChecks(self)
|
|
818
|
-
self[
|
|
898
|
+
self[104] = (self[104] or 0) + 1
|
|
819
899
|
Timer:run(delayHealthChecksCallback, self)
|
|
820
900
|
end
|
|
821
901
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -825,21 +905,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
825
905
|
return IsUnitSelected(self.handle, player.handle)
|
|
826
906
|
end
|
|
827
907
|
function Unit.prototype.explode(self)
|
|
828
|
-
|
|
908
|
+
SetUnitExploded(self.handle, true)
|
|
829
909
|
killUnit(self.handle)
|
|
830
910
|
end
|
|
831
911
|
function Unit.prototype.kill(self)
|
|
832
912
|
killUnit(self.handle)
|
|
833
913
|
end
|
|
834
914
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
835
|
-
local
|
|
836
|
-
local
|
|
837
|
-
local
|
|
838
|
-
if
|
|
839
|
-
|
|
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
|
|
840
920
|
end
|
|
841
|
-
__TS__SparseArrayPush(
|
|
842
|
-
|
|
921
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
922
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
843
923
|
end
|
|
844
924
|
function Unit.prototype.healTarget(self, target, amount)
|
|
845
925
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -882,17 +962,16 @@ function Unit.prototype.itemInSlot(self, slot)
|
|
|
882
962
|
return Item:of(unitItemInSlot(self.handle, slot))
|
|
883
963
|
end
|
|
884
964
|
function Unit.prototype.addAbility(self, abilityId)
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
965
|
+
local ability = UnitAbility:of(
|
|
966
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
967
|
+
abilityId,
|
|
968
|
+
self
|
|
969
|
+
)
|
|
970
|
+
if ability ~= nil then
|
|
891
971
|
local abilities = self.abilities
|
|
892
972
|
abilities[#abilities + 1] = ability
|
|
893
|
-
return ability
|
|
894
973
|
end
|
|
895
|
-
return
|
|
974
|
+
return ability
|
|
896
975
|
end
|
|
897
976
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
898
977
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -906,31 +985,21 @@ end
|
|
|
906
985
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
907
986
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
908
987
|
end
|
|
909
|
-
function Unit.prototype.
|
|
910
|
-
local
|
|
911
|
-
|
|
912
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
913
|
-
return nil
|
|
914
|
-
end
|
|
915
|
-
return UnitAbility:of(
|
|
916
|
-
getUnitAbility(self.handle, abilityId),
|
|
917
|
-
abilityId,
|
|
918
|
-
self
|
|
919
|
-
)
|
|
988
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
989
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
990
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
920
991
|
end
|
|
921
|
-
function Unit.prototype.removeAbility(self,
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
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
|
|
930
1000
|
end
|
|
931
|
-
return true
|
|
932
1001
|
end
|
|
933
|
-
return
|
|
1002
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
934
1003
|
end
|
|
935
1004
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
936
1005
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -944,9 +1013,6 @@ end
|
|
|
944
1013
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
945
1014
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
946
1015
|
end
|
|
947
|
-
function Unit.prototype.interruptAttack(self)
|
|
948
|
-
unitInterruptAttack(self.handle)
|
|
949
|
-
end
|
|
950
1016
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
951
1017
|
local handle = self.handle
|
|
952
1018
|
unitDisableAbility(handle, abilityId, true, false)
|
|
@@ -1017,18 +1083,44 @@ function Unit.prototype.unpauseEx(self)
|
|
|
1017
1083
|
end
|
|
1018
1084
|
function Unit.prototype.incrementStunCounter(self)
|
|
1019
1085
|
local stunCounter = self[102] or 0
|
|
1020
|
-
if not self[101] or stunCounter >= 0 then
|
|
1086
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
|
|
1021
1087
|
BlzPauseUnitEx(self.handle, true)
|
|
1022
1088
|
end
|
|
1023
1089
|
self[102] = stunCounter + 1
|
|
1024
1090
|
end
|
|
1025
1091
|
function Unit.prototype.decrementStunCounter(self)
|
|
1026
1092
|
local stunCounter = self[102] or 0
|
|
1027
|
-
if not self[101] or stunCounter >= 1 then
|
|
1093
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
|
|
1028
1094
|
BlzPauseUnitEx(self.handle, false)
|
|
1029
1095
|
end
|
|
1030
1096
|
self[102] = stunCounter - 1
|
|
1031
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
|
|
1032
1124
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1033
1125
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
1034
1126
|
owner.handle,
|
|
@@ -1217,7 +1309,7 @@ __TS__SetDescriptor(
|
|
|
1217
1309
|
Unit.prototype,
|
|
1218
1310
|
"isIllusion",
|
|
1219
1311
|
{get = function(self)
|
|
1220
|
-
return
|
|
1312
|
+
return IsUnitIllusion(self.handle)
|
|
1221
1313
|
end},
|
|
1222
1314
|
true
|
|
1223
1315
|
)
|
|
@@ -1315,19 +1407,6 @@ __TS__SetDescriptor(
|
|
|
1315
1407
|
},
|
|
1316
1408
|
true
|
|
1317
1409
|
)
|
|
1318
|
-
__TS__SetDescriptor(
|
|
1319
|
-
Unit.prototype,
|
|
1320
|
-
"strengthBase",
|
|
1321
|
-
{
|
|
1322
|
-
get = function(self)
|
|
1323
|
-
return getHeroStr(self.handle, false)
|
|
1324
|
-
end,
|
|
1325
|
-
set = function(self, strengthBase)
|
|
1326
|
-
setHeroStr(self.handle, strengthBase, true)
|
|
1327
|
-
end
|
|
1328
|
-
},
|
|
1329
|
-
true
|
|
1330
|
-
)
|
|
1331
1410
|
__TS__SetDescriptor(
|
|
1332
1411
|
Unit.prototype,
|
|
1333
1412
|
"strengthBonus",
|
|
@@ -1345,19 +1424,6 @@ __TS__SetDescriptor(
|
|
|
1345
1424
|
end},
|
|
1346
1425
|
true
|
|
1347
1426
|
)
|
|
1348
|
-
__TS__SetDescriptor(
|
|
1349
|
-
Unit.prototype,
|
|
1350
|
-
"agilityBase",
|
|
1351
|
-
{
|
|
1352
|
-
get = function(self)
|
|
1353
|
-
return getHeroAgi(self.handle, false)
|
|
1354
|
-
end,
|
|
1355
|
-
set = function(self, agilityBase)
|
|
1356
|
-
setHeroAgi(self.handle, agilityBase, true)
|
|
1357
|
-
end
|
|
1358
|
-
},
|
|
1359
|
-
true
|
|
1360
|
-
)
|
|
1361
1427
|
__TS__SetDescriptor(
|
|
1362
1428
|
Unit.prototype,
|
|
1363
1429
|
"agilityBonus",
|
|
@@ -1375,19 +1441,6 @@ __TS__SetDescriptor(
|
|
|
1375
1441
|
end},
|
|
1376
1442
|
true
|
|
1377
1443
|
)
|
|
1378
|
-
__TS__SetDescriptor(
|
|
1379
|
-
Unit.prototype,
|
|
1380
|
-
"intelligenceBase",
|
|
1381
|
-
{
|
|
1382
|
-
get = function(self)
|
|
1383
|
-
return getHeroInt(self.handle, false)
|
|
1384
|
-
end,
|
|
1385
|
-
set = function(self, intelligenceBase)
|
|
1386
|
-
setHeroInt(self.handle, intelligenceBase, true)
|
|
1387
|
-
end
|
|
1388
|
-
},
|
|
1389
|
-
true
|
|
1390
|
-
)
|
|
1391
1444
|
__TS__SetDescriptor(
|
|
1392
1445
|
Unit.prototype,
|
|
1393
1446
|
"intelligenceBonus",
|
|
@@ -1436,17 +1489,17 @@ __TS__SetDescriptor(
|
|
|
1436
1489
|
"isTeamGlowVisible",
|
|
1437
1490
|
{
|
|
1438
1491
|
get = function(self)
|
|
1439
|
-
return not self[
|
|
1492
|
+
return not self[107]
|
|
1440
1493
|
end,
|
|
1441
1494
|
set = function(self, isTeamGlowVisible)
|
|
1442
|
-
|
|
1443
|
-
local
|
|
1495
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1496
|
+
local ____temp_7
|
|
1444
1497
|
if not isTeamGlowVisible then
|
|
1445
|
-
|
|
1498
|
+
____temp_7 = true
|
|
1446
1499
|
else
|
|
1447
|
-
|
|
1500
|
+
____temp_7 = nil
|
|
1448
1501
|
end
|
|
1449
|
-
self[
|
|
1502
|
+
self[107] = ____temp_7
|
|
1450
1503
|
end
|
|
1451
1504
|
},
|
|
1452
1505
|
true
|
|
@@ -1455,9 +1508,9 @@ __TS__SetDescriptor(
|
|
|
1455
1508
|
Unit.prototype,
|
|
1456
1509
|
"color",
|
|
1457
1510
|
{set = function(self, color)
|
|
1458
|
-
|
|
1459
|
-
if self[
|
|
1460
|
-
|
|
1511
|
+
SetUnitColor(self.handle, color.handle)
|
|
1512
|
+
if self[107] then
|
|
1513
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1461
1514
|
end
|
|
1462
1515
|
end},
|
|
1463
1516
|
true
|
|
@@ -1480,14 +1533,14 @@ __TS__SetDescriptor(
|
|
|
1480
1533
|
"maxHealth",
|
|
1481
1534
|
{
|
|
1482
1535
|
get = function(self)
|
|
1483
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1536
|
+
return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
|
|
1484
1537
|
end,
|
|
1485
1538
|
set = function(self, maxHealth)
|
|
1486
|
-
if maxHealth < 1 and self[
|
|
1487
|
-
self[
|
|
1539
|
+
if maxHealth < 1 and self[104] ~= nil then
|
|
1540
|
+
self[105] = (self[105] or 0) + (1 - maxHealth)
|
|
1488
1541
|
maxHealth = 1
|
|
1489
1542
|
end
|
|
1490
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1543
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
|
|
1491
1544
|
end
|
|
1492
1545
|
},
|
|
1493
1546
|
true
|
|
@@ -1529,10 +1582,10 @@ __TS__SetDescriptor(
|
|
|
1529
1582
|
"health",
|
|
1530
1583
|
{
|
|
1531
1584
|
get = function(self)
|
|
1532
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1585
|
+
return GetWidgetLife(self.handle) - (self[106] or 0)
|
|
1533
1586
|
end,
|
|
1534
1587
|
set = function(self, health)
|
|
1535
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1588
|
+
SetWidgetLife(self.handle, health + (self[106] or 0))
|
|
1536
1589
|
end
|
|
1537
1590
|
},
|
|
1538
1591
|
true
|
|
@@ -1608,25 +1661,12 @@ __TS__SetDescriptor(
|
|
|
1608
1661
|
},
|
|
1609
1662
|
true
|
|
1610
1663
|
)
|
|
1611
|
-
__TS__SetDescriptor(
|
|
1612
|
-
Unit.prototype,
|
|
1613
|
-
"flyHeight",
|
|
1614
|
-
{
|
|
1615
|
-
get = function(self)
|
|
1616
|
-
return getUnitFlyHeight(self.handle)
|
|
1617
|
-
end,
|
|
1618
|
-
set = function(self, v)
|
|
1619
|
-
SetUnitFlyHeight(self.handle, v, 100000)
|
|
1620
|
-
end
|
|
1621
|
-
},
|
|
1622
|
-
true
|
|
1623
|
-
)
|
|
1624
1664
|
__TS__SetDescriptor(
|
|
1625
1665
|
Unit.prototype,
|
|
1626
1666
|
"x",
|
|
1627
1667
|
{
|
|
1628
1668
|
get = function(self)
|
|
1629
|
-
return self[
|
|
1669
|
+
return self[108] or getUnitX(self.handle)
|
|
1630
1670
|
end,
|
|
1631
1671
|
set = function(self, v)
|
|
1632
1672
|
SetUnitX(self.handle, v)
|
|
@@ -1639,7 +1679,7 @@ __TS__SetDescriptor(
|
|
|
1639
1679
|
"y",
|
|
1640
1680
|
{
|
|
1641
1681
|
get = function(self)
|
|
1642
|
-
return self[
|
|
1682
|
+
return self[109] or getUnitY(self.handle)
|
|
1643
1683
|
end,
|
|
1644
1684
|
set = function(self, v)
|
|
1645
1685
|
SetUnitY(self.handle, v)
|
|
@@ -1725,10 +1765,10 @@ __TS__SetDescriptor(
|
|
|
1725
1765
|
"gold",
|
|
1726
1766
|
{
|
|
1727
1767
|
get = function(self)
|
|
1728
|
-
return
|
|
1768
|
+
return GetResourceAmount(self.handle)
|
|
1729
1769
|
end,
|
|
1730
1770
|
set = function(self, gold)
|
|
1731
|
-
|
|
1771
|
+
SetResourceAmount(self.handle, gold)
|
|
1732
1772
|
end
|
|
1733
1773
|
},
|
|
1734
1774
|
true
|
|
@@ -1744,14 +1784,18 @@ __TS__SetDescriptor(
|
|
|
1744
1784
|
local handle = self.handle
|
|
1745
1785
|
if isPaused and not IsUnitPaused(handle) then
|
|
1746
1786
|
self[101] = true
|
|
1747
|
-
|
|
1748
|
-
|
|
1787
|
+
if (self[103] or 0) <= 0 then
|
|
1788
|
+
for _ = self[102] or 0, -1 do
|
|
1789
|
+
BlzPauseUnitEx(handle, true)
|
|
1790
|
+
end
|
|
1749
1791
|
end
|
|
1750
1792
|
PauseUnit(handle, true)
|
|
1751
1793
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1752
1794
|
PauseUnit(handle, false)
|
|
1753
|
-
|
|
1754
|
-
|
|
1795
|
+
if (self[103] or 0) <= 0 then
|
|
1796
|
+
for _ = self[102] or 0, -1 do
|
|
1797
|
+
BlzPauseUnitEx(handle, false)
|
|
1798
|
+
end
|
|
1755
1799
|
end
|
|
1756
1800
|
self[101] = nil
|
|
1757
1801
|
end
|
|
@@ -1809,20 +1853,6 @@ __TS__SetDescriptor(
|
|
|
1809
1853
|
},
|
|
1810
1854
|
true
|
|
1811
1855
|
)
|
|
1812
|
-
__TS__SetDescriptor(
|
|
1813
|
-
Unit.prototype,
|
|
1814
|
-
"scale",
|
|
1815
|
-
{
|
|
1816
|
-
get = function(self)
|
|
1817
|
-
return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
|
|
1818
|
-
end,
|
|
1819
|
-
set = function(self, v)
|
|
1820
|
-
setUnitScale(self.handle, v, v, v)
|
|
1821
|
-
setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
|
|
1822
|
-
end
|
|
1823
|
-
},
|
|
1824
|
-
true
|
|
1825
|
-
)
|
|
1826
1856
|
__TS__SetDescriptor(
|
|
1827
1857
|
Unit.prototype,
|
|
1828
1858
|
"timeScale",
|
|
@@ -1959,30 +1989,6 @@ __TS__SetDescriptor(
|
|
|
1959
1989
|
end},
|
|
1960
1990
|
true
|
|
1961
1991
|
)
|
|
1962
|
-
__TS__SetDescriptor(
|
|
1963
|
-
Unit.prototype,
|
|
1964
|
-
"onUnitInRange",
|
|
1965
|
-
{get = function(self)
|
|
1966
|
-
local handle = self.handle
|
|
1967
|
-
local onUnitInRange = setmetatable(
|
|
1968
|
-
{},
|
|
1969
|
-
{__index = function(self, value)
|
|
1970
|
-
local event = __TS__New(
|
|
1971
|
-
TriggerEvent,
|
|
1972
|
-
function(trigger)
|
|
1973
|
-
TriggerRegisterUnitInRangeSimple(trigger, value, handle)
|
|
1974
|
-
end,
|
|
1975
|
-
function() return ____exports.Unit:of(handle) end
|
|
1976
|
-
)
|
|
1977
|
-
rawset(self, value, event)
|
|
1978
|
-
return event
|
|
1979
|
-
end}
|
|
1980
|
-
)
|
|
1981
|
-
rawset(self, "onUnitInRange", onUnitInRange)
|
|
1982
|
-
return onUnitInRange
|
|
1983
|
-
end},
|
|
1984
|
-
true
|
|
1985
|
-
)
|
|
1986
1992
|
__TS__SetDescriptor(
|
|
1987
1993
|
Unit.prototype,
|
|
1988
1994
|
"onManaEqual",
|
|
@@ -2050,6 +2056,14 @@ __TS__SetDescriptor(
|
|
|
2050
2056
|
end},
|
|
2051
2057
|
true
|
|
2052
2058
|
)
|
|
2059
|
+
__TS__SetDescriptor(
|
|
2060
|
+
Unit.prototype,
|
|
2061
|
+
"targetAcquiredEvent",
|
|
2062
|
+
{get = function(self)
|
|
2063
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2064
|
+
end},
|
|
2065
|
+
true
|
|
2066
|
+
)
|
|
2053
2067
|
__TS__SetDescriptor(
|
|
2054
2068
|
Unit.prototype,
|
|
2055
2069
|
"onSelect",
|
|
@@ -2110,6 +2124,11 @@ __TS__SetDescriptor(
|
|
|
2110
2124
|
end},
|
|
2111
2125
|
true
|
|
2112
2126
|
)
|
|
2127
|
+
Unit.levelChangedEvent = __TS__New(
|
|
2128
|
+
____exports.UnitTriggerEvent,
|
|
2129
|
+
EVENT_PLAYER_HERO_LEVEL,
|
|
2130
|
+
function() return ____exports.Unit:of(getTriggerUnit()) end
|
|
2131
|
+
)
|
|
2113
2132
|
Unit.deathEvent = __TS__New(
|
|
2114
2133
|
____exports.UnitTriggerEvent,
|
|
2115
2134
|
EVENT_PLAYER_UNIT_DEATH,
|
|
@@ -2185,25 +2204,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2185
2204
|
InitializingEvent,
|
|
2186
2205
|
function(event)
|
|
2187
2206
|
local function listener(unit, id)
|
|
2188
|
-
local
|
|
2207
|
+
local ____GetSpellTargetUnit_result_10
|
|
2189
2208
|
if GetSpellTargetUnit() then
|
|
2190
|
-
|
|
2209
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2191
2210
|
else
|
|
2192
|
-
local
|
|
2211
|
+
local ____GetSpellTargetItem_result_9
|
|
2193
2212
|
if GetSpellTargetItem() then
|
|
2194
|
-
|
|
2213
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2195
2214
|
else
|
|
2196
|
-
local
|
|
2215
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2197
2216
|
if GetSpellTargetDestructable() then
|
|
2198
|
-
|
|
2217
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2199
2218
|
else
|
|
2200
|
-
|
|
2219
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2201
2220
|
end
|
|
2202
|
-
|
|
2221
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2203
2222
|
end
|
|
2204
|
-
|
|
2223
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2205
2224
|
end
|
|
2206
|
-
local target =
|
|
2225
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2207
2226
|
if target then
|
|
2208
2227
|
invoke(event, unit, id, target)
|
|
2209
2228
|
end
|
|
@@ -2411,38 +2430,57 @@ Unit.onDamaging = (function()
|
|
|
2411
2430
|
if source and source.typeId == dummyUnitId then
|
|
2412
2431
|
source = nil
|
|
2413
2432
|
end
|
|
2414
|
-
local target = BlzGetEventDamageTarget()
|
|
2433
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2434
|
+
local metadata = damageMetadataByTarget[target]
|
|
2435
|
+
damageMetadataByTarget[target] = nil
|
|
2415
2436
|
local data = {
|
|
2416
2437
|
amount = GetEventDamage(),
|
|
2417
2438
|
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2418
2439
|
damageType = BlzGetEventDamageType(),
|
|
2419
2440
|
weaponType = BlzGetEventWeaponType(),
|
|
2420
|
-
|
|
2441
|
+
metadata = metadata,
|
|
2442
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2443
|
+
originalAmount = GetEventDamage(),
|
|
2444
|
+
originalMetadata = metadata,
|
|
2445
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2421
2446
|
}
|
|
2422
2447
|
if data.isAttack and source then
|
|
2423
|
-
|
|
2424
|
-
if weapon == -1 then
|
|
2425
|
-
local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
|
|
2426
|
-
weapon = 0
|
|
2427
|
-
end
|
|
2428
|
-
data.weapon = assert(source.weapons[weapon + 1])
|
|
2448
|
+
data.weapon = source:chooseWeapon(target)
|
|
2429
2449
|
end
|
|
2430
2450
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2431
2451
|
invoke(
|
|
2432
2452
|
event,
|
|
2433
2453
|
source,
|
|
2434
|
-
|
|
2454
|
+
target,
|
|
2435
2455
|
setmetatable(
|
|
2436
2456
|
{},
|
|
2437
2457
|
{
|
|
2438
2458
|
__index = data,
|
|
2439
2459
|
__newindex = function(self, key, value)
|
|
2440
|
-
damageSetters[key]
|
|
2460
|
+
local damageSetter = damageSetters[key]
|
|
2461
|
+
if damageSetter ~= nil then
|
|
2462
|
+
damageSetter(value)
|
|
2463
|
+
end
|
|
2441
2464
|
data[key] = value
|
|
2442
2465
|
end
|
|
2443
2466
|
}
|
|
2444
2467
|
)
|
|
2445
2468
|
)
|
|
2469
|
+
if data[0] and source then
|
|
2470
|
+
local sourceOwner = source.owner.handle
|
|
2471
|
+
data[1] = sourceOwner
|
|
2472
|
+
local targetOwner = target.owner.handle
|
|
2473
|
+
data[2] = targetOwner
|
|
2474
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2475
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2476
|
+
data[3] = true
|
|
2477
|
+
end
|
|
2478
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2479
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2480
|
+
data[4] = true
|
|
2481
|
+
end
|
|
2482
|
+
end
|
|
2483
|
+
damagingEventByTarget[target] = data
|
|
2446
2484
|
return
|
|
2447
2485
|
end
|
|
2448
2486
|
BlzSetEventDamage(0)
|
|
@@ -2450,7 +2488,7 @@ Unit.onDamaging = (function()
|
|
|
2450
2488
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2451
2489
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2452
2490
|
local sourceOwner = source.owner.handle
|
|
2453
|
-
local targetOwner =
|
|
2491
|
+
local targetOwner = target.owner.handle
|
|
2454
2492
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2455
2493
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2456
2494
|
Timer:run(function()
|
|
@@ -2466,19 +2504,15 @@ Unit.onDamaging = (function()
|
|
|
2466
2504
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2467
2505
|
local condition = ____value[1]
|
|
2468
2506
|
local action = ____value[2]
|
|
2469
|
-
if condition(
|
|
2470
|
-
source,
|
|
2471
|
-
____exports.Unit:of(target),
|
|
2472
|
-
data
|
|
2473
|
-
) then
|
|
2507
|
+
if condition(source, target, data) then
|
|
2474
2508
|
action(
|
|
2475
2509
|
source,
|
|
2476
|
-
|
|
2510
|
+
target,
|
|
2477
2511
|
setmetatable(
|
|
2478
2512
|
{fire = function()
|
|
2479
2513
|
UnitDamageTarget(
|
|
2480
2514
|
source.handle,
|
|
2481
|
-
target,
|
|
2515
|
+
target.handle,
|
|
2482
2516
|
data.amount,
|
|
2483
2517
|
true,
|
|
2484
2518
|
true,
|
|
@@ -2509,30 +2543,54 @@ Unit.onDamage = __TS__New(
|
|
|
2509
2543
|
if source and source.typeId == dummyUnitId then
|
|
2510
2544
|
source = nil
|
|
2511
2545
|
end
|
|
2546
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2547
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2548
|
+
damagingEventByTarget[target] = nil
|
|
2512
2549
|
local data = {
|
|
2513
2550
|
amount = GetEventDamage(),
|
|
2514
2551
|
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2515
2552
|
damageType = BlzGetEventDamageType(),
|
|
2516
2553
|
weaponType = BlzGetEventWeaponType(),
|
|
2554
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2517
2555
|
isAttack = BlzGetEventIsAttack(),
|
|
2518
|
-
originalAmount = GetEventDamage(),
|
|
2556
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2557
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2519
2558
|
preventDeath = damageEventPreventDeath
|
|
2520
2559
|
}
|
|
2560
|
+
if damagingEvent then
|
|
2561
|
+
for key, value in pairs(damagingEvent) do
|
|
2562
|
+
if isAttribute(key) then
|
|
2563
|
+
data[key] = value
|
|
2564
|
+
end
|
|
2565
|
+
end
|
|
2566
|
+
local sourceOwner = damagingEvent[1]
|
|
2567
|
+
if sourceOwner then
|
|
2568
|
+
local targetOwner = damagingEvent[2]
|
|
2569
|
+
if damagingEvent[3] then
|
|
2570
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2571
|
+
end
|
|
2572
|
+
if damagingEvent[4] then
|
|
2573
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2574
|
+
end
|
|
2575
|
+
end
|
|
2576
|
+
end
|
|
2521
2577
|
local evData = setmetatable(
|
|
2522
2578
|
{},
|
|
2523
2579
|
{
|
|
2524
2580
|
__index = data,
|
|
2525
2581
|
__newindex = function(self, key, value)
|
|
2526
|
-
damageSetters[key]
|
|
2582
|
+
local damageSetter = damageSetters[key]
|
|
2583
|
+
if damageSetter ~= nil then
|
|
2584
|
+
damageSetter(value)
|
|
2585
|
+
end
|
|
2527
2586
|
data[key] = value
|
|
2528
2587
|
end
|
|
2529
2588
|
}
|
|
2530
2589
|
)
|
|
2531
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2532
2590
|
invoke(event, source, target, evData)
|
|
2533
2591
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2534
2592
|
local bonusHealth = math.ceil(evData.amount)
|
|
2535
|
-
target[
|
|
2593
|
+
target[106] = (target[106] or 0) + bonusHealth
|
|
2536
2594
|
BlzSetUnitMaxHP(
|
|
2537
2595
|
target.handle,
|
|
2538
2596
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2546,7 +2604,7 @@ Unit.onDamage = __TS__New(
|
|
|
2546
2604
|
evData[0],
|
|
2547
2605
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2548
2606
|
)
|
|
2549
|
-
target[
|
|
2607
|
+
target[106] = (target[106] or 0) - bonusHealth
|
|
2550
2608
|
SetWidgetLife(
|
|
2551
2609
|
target.handle,
|
|
2552
2610
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2582,10 +2640,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2582
2640
|
____exports.UnitTriggerEvent,
|
|
2583
2641
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2584
2642
|
function()
|
|
2585
|
-
local
|
|
2586
|
-
local
|
|
2587
|
-
if getUnitTypeId(
|
|
2588
|
-
|
|
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
|
|
2589
2651
|
end
|
|
2590
2652
|
return IgnoreEvent
|
|
2591
2653
|
end
|
|
@@ -2605,7 +2667,22 @@ Unit.itemUsedEvent = __TS__New(
|
|
|
2605
2667
|
Unit.itemStackedEvent = __TS__New(
|
|
2606
2668
|
____exports.UnitTriggerEvent,
|
|
2607
2669
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2608
|
-
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}
|
|
2609
2686
|
)
|
|
2610
2687
|
__TS__ObjectDefineProperty(
|
|
2611
2688
|
Unit,
|
|
@@ -2677,6 +2754,10 @@ __TS__ObjectDefineProperty(
|
|
|
2677
2754
|
rawset(self, "destroyEvent", destroyEvent)
|
|
2678
2755
|
return destroyEvent
|
|
2679
2756
|
end}
|
|
2757
|
+
)
|
|
2758
|
+
Unit.synchronize = synchronizer(
|
|
2759
|
+
function(unit) return unit.syncId end,
|
|
2760
|
+
function(syncId) return unitBySyncId[syncId] end
|
|
2680
2761
|
);
|
|
2681
2762
|
(function(self)
|
|
2682
2763
|
local leaveAbilityIds = postcompile(function()
|
|
@@ -2706,7 +2787,8 @@ __TS__ObjectDefineProperty(
|
|
|
2706
2787
|
return
|
|
2707
2788
|
end
|
|
2708
2789
|
end
|
|
2709
|
-
unit:
|
|
2790
|
+
unit:saveData()
|
|
2791
|
+
Timer:run(unit, "destroy")
|
|
2710
2792
|
end)
|
|
2711
2793
|
end
|
|
2712
2794
|
end)(Unit)
|