warscript 0.0.1-dev.ffaa090 → 0.0.1-dev.fff719b
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/effect.d.ts +1 -3
- package/core/types/effect.lua +26 -29
- package/core/types/frame.lua +24 -21
- 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.d.ts +17 -25
- package/core/types/sound.lua +85 -44
- package/core/types/tileCell.d.ts +11 -1
- package/core/types/tileCell.lua +97 -0
- package/core/types/timer.d.ts +9 -8
- package/core/types/timer.lua +45 -23
- package/decl/native.d.ts +846 -790
- 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 +6 -3
- package/engine/behaviour/ability/damage.lua +24 -36
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +18 -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 +6 -2
- package/engine/behaviour/ability.lua +16 -22
- 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 +21 -8
- package/engine/buff.lua +193 -121
- package/engine/internal/ability.d.ts +7 -1
- package/engine/internal/ability.lua +49 -9
- package/engine/internal/item/ability.lua +63 -11
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +18 -17
- package/engine/internal/item.lua +135 -49
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- package/engine/internal/mechanics/cast-ability.lua +6 -3
- package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
- package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
- package/engine/internal/misc/frame-coordinates.d.ts +2 -0
- package/engine/internal/misc/frame-coordinates.lua +21 -0
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/misc/player-local-handle.d.ts +2 -0
- package/engine/internal/misc/player-local-handle.lua +5 -0
- package/engine/internal/object-data/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 +2 -0
- package/engine/internal/unit/bonus.lua +10 -0
- 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/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+damage.d.ts +2 -11
- package/engine/internal/unit+damage.lua +10 -14
- package/engine/internal/unit+spellSteal.lua +1 -2
- package/engine/internal/unit-missile-launch.lua +52 -14
- package/engine/internal/unit.d.ts +39 -26
- package/engine/internal/unit.lua +375 -236
- 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/attachment-preset.d.ts +7 -2
- package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
- package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
- package/engine/object-data/auxiliary/attack-type.lua +42 -0
- package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
- package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
- package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
- package/engine/object-data/auxiliary/movement-type.lua +22 -0
- package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
- package/engine/object-data/auxiliary/sound-eax.lua +2 -0
- package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
- package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
- package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
- package/engine/object-data/entry/ability-type/berserk.lua +13 -0
- package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
- package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
- package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
- package/engine/object-data/entry/ability-type/ensnare.lua +52 -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/phase-shift.d.ts +10 -0
- package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
- package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
- package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
- package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
- package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
- package/engine/object-data/entry/ability-type/web.d.ts +12 -0
- package/engine/object-data/entry/ability-type/web.lua +52 -0
- package/engine/object-data/entry/ability-type.d.ts +11 -11
- package/engine/object-data/entry/ability-type.lua +35 -13
- package/engine/object-data/entry/buff-type/applicable.lua +5 -0
- package/engine/object-data/entry/buff-type.d.ts +5 -11
- package/engine/object-data/entry/buff-type.lua +11 -27
- 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/sound-preset.d.ts +17 -0
- package/engine/object-data/entry/sound-preset.lua +104 -0
- package/engine/object-data/entry/unit-type.d.ts +17 -4
- package/engine/object-data/entry/unit-type.lua +197 -85
- package/engine/object-field/ability.d.ts +4 -4
- package/engine/object-field/ability.lua +7 -6
- package/engine/object-field/unit.d.ts +72 -3
- package/engine/object-field/unit.lua +268 -7
- package/engine/object-field.d.ts +25 -6
- package/engine/object-field.lua +357 -118
- package/engine/random.d.ts +9 -0
- package/engine/random.lua +13 -0
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- package/engine/standard/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 +5 -0
- package/engine/unit.lua +5 -0
- package/net/socket.lua +1 -1
- package/objutil/buff.lua +11 -10
- package/package.json +2 -2
- package/patch-lua.lua +9 -0
- package/patch-lualib.lua +1 -1
- package/utility/arrays.d.ts +2 -0
- package/utility/arrays.lua +11 -0
- package/utility/callback-array.d.ts +17 -0
- package/utility/callback-array.lua +61 -0
- package/utility/functions.d.ts +8 -0
- package/utility/functions.lua +13 -0
- package/utility/linked-map.d.ts +26 -0
- package/utility/linked-map.lua +66 -0
- package/utility/linked-set.d.ts +2 -0
- package/utility/linked-set.lua +26 -1
- package/utility/lua-maps.d.ts +15 -2
- package/utility/lua-maps.lua +53 -2
- package/utility/lua-sets.d.ts +2 -0
- package/utility/lua-sets.lua +7 -0
- package/utility/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/unit.lua
CHANGED
|
@@ -53,35 +53,40 @@ local ____math = require("math")
|
|
|
53
53
|
local min = ____math.min
|
|
54
54
|
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
55
55
|
local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
56
|
+
local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
|
|
57
|
+
local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
|
|
58
|
+
local nativeToAttackType = ____attack_2Dtype.nativeToAttackType
|
|
59
|
+
local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
|
|
60
|
+
local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
|
|
61
|
+
local ____attributes = require("attributes")
|
|
62
|
+
local isAttribute = ____attributes.isAttribute
|
|
63
|
+
local ____ability = require("engine.internal.item.ability")
|
|
64
|
+
local doUnitAbilityAction = ____ability.doUnitAbilityAction
|
|
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
|
|
56
69
|
local match = string.match
|
|
57
70
|
local ____tostring = _G.tostring
|
|
58
71
|
local setUnitAnimation = SetUnitAnimation
|
|
59
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
60
72
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
61
|
-
local resetUnitAnimation = ResetUnitAnimation
|
|
62
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
63
73
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
64
74
|
local getUnitRealField = BlzGetUnitRealField
|
|
65
75
|
local getHeroStr = GetHeroStr
|
|
66
76
|
local getHeroAgi = GetHeroAgi
|
|
67
77
|
local getHeroInt = GetHeroInt
|
|
68
|
-
local setHeroStr = SetHeroStr
|
|
69
|
-
local setHeroAgi = SetHeroAgi
|
|
70
|
-
local setHeroInt = SetHeroInt
|
|
71
78
|
local getUnitBooleanField = BlzGetUnitBooleanField
|
|
72
79
|
local getUnitStringField = BlzGetUnitStringField
|
|
73
80
|
local setUnitIntegerField = BlzSetUnitIntegerField
|
|
74
81
|
local setUnitRealField = BlzSetUnitRealField
|
|
75
82
|
local setUnitBooleanField = BlzSetUnitBooleanField
|
|
76
83
|
local setUnitStringField = BlzSetUnitStringField
|
|
77
|
-
local setUnitScale = SetUnitScale
|
|
78
84
|
local setUnitPosition = SetUnitPosition
|
|
79
85
|
local setUnitTimeScale = SetUnitTimeScale
|
|
80
86
|
local getHandleId = GetHandleId
|
|
81
87
|
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
82
88
|
local createUnit = CreateUnit
|
|
83
89
|
local killUnit = KillUnit
|
|
84
|
-
local setUnitExploded = SetUnitExploded
|
|
85
90
|
local removeUnit = RemoveUnit
|
|
86
91
|
local getUnitTypeId = GetUnitTypeId
|
|
87
92
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -97,15 +102,12 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
97
102
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
98
103
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
99
104
|
local isUnitInRange = IsUnitInRange
|
|
100
|
-
local setResourceAmount = SetResourceAmount
|
|
101
|
-
local getResourceAmount = GetResourceAmount
|
|
102
105
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
103
106
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
104
107
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
105
108
|
local setUnitWeaponStringField = BlzSetUnitWeaponStringField
|
|
106
109
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
107
110
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
108
|
-
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
109
111
|
local isUnitInvisible = IsUnitInvisible
|
|
110
112
|
local isUnitVisible = IsUnitVisible
|
|
111
113
|
local getUnitX = GetUnitX
|
|
@@ -122,15 +124,9 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
122
124
|
local getIssuedOrderId = GetIssuedOrderId
|
|
123
125
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
124
126
|
local unitAlive = UnitAlive
|
|
125
|
-
local unitAddType = UnitAddType
|
|
126
|
-
local unitRemoveType = UnitRemoveType
|
|
127
|
-
local isUnitIllusion = IsUnitIllusion
|
|
128
|
-
local isUnitType = IsUnitType
|
|
129
127
|
local isUnitAlly = IsUnitAlly
|
|
130
128
|
local isUnitEnemy = IsUnitEnemy
|
|
131
129
|
local getOwningPlayer = GetOwningPlayer
|
|
132
|
-
local setUnitColor = SetUnitColor
|
|
133
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
134
130
|
____exports.UnitClassification = {}
|
|
135
131
|
local UnitClassification = ____exports.UnitClassification
|
|
136
132
|
do
|
|
@@ -140,6 +136,7 @@ do
|
|
|
140
136
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
141
137
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
142
138
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
139
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
143
140
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
144
141
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
145
142
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -347,6 +344,9 @@ local function dispatchAbility(event)
|
|
|
347
344
|
}
|
|
348
345
|
)
|
|
349
346
|
end
|
|
347
|
+
local function damagingEventPreventRetaliation(self)
|
|
348
|
+
self[0] = true
|
|
349
|
+
end
|
|
350
350
|
local function damageEventPreventDeath(self, callback, ...)
|
|
351
351
|
if self[0] ~= nil then
|
|
352
352
|
return
|
|
@@ -358,7 +358,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
358
358
|
rawset(self, 1 + i, (select(i, ...)))
|
|
359
359
|
end
|
|
360
360
|
end
|
|
361
|
-
local damageSetters = {
|
|
361
|
+
local damageSetters = {
|
|
362
|
+
amount = BlzSetEventDamage,
|
|
363
|
+
attackType = function(attackType)
|
|
364
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
365
|
+
end,
|
|
366
|
+
damageType = BlzSetEventDamageType,
|
|
367
|
+
weaponType = BlzSetEventWeaponType
|
|
368
|
+
}
|
|
362
369
|
local jlimitopByOperator = {
|
|
363
370
|
[0] = LESS_THAN_OR_EQUAL,
|
|
364
371
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -376,15 +383,27 @@ local modifiers = {
|
|
|
376
383
|
end,
|
|
377
384
|
armor = function(unit, value)
|
|
378
385
|
if UnitAddAbility(unit, armorBonusAbilityId) then
|
|
379
|
-
assert(
|
|
386
|
+
assert(
|
|
387
|
+
UnitMakeAbilityPermanent(unit, true, armorBonusAbilityId),
|
|
388
|
+
"armor bonus ability must be made permanent",
|
|
389
|
+
unit
|
|
390
|
+
)
|
|
380
391
|
end
|
|
381
|
-
local ability = assert(
|
|
382
|
-
|
|
383
|
-
ability,
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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
|
+
)
|
|
388
407
|
end
|
|
389
408
|
}
|
|
390
409
|
local getters = {
|
|
@@ -402,6 +421,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
|
402
421
|
self.unit = unit
|
|
403
422
|
self.index = index
|
|
404
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
|
+
)
|
|
405
437
|
__TS__SetDescriptor(
|
|
406
438
|
UnitWeapon.prototype,
|
|
407
439
|
"cooldown",
|
|
@@ -436,6 +468,19 @@ __TS__SetDescriptor(
|
|
|
436
468
|
},
|
|
437
469
|
true
|
|
438
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
|
+
)
|
|
439
484
|
__TS__SetDescriptor(
|
|
440
485
|
UnitWeapon.prototype,
|
|
441
486
|
"damageBase",
|
|
@@ -612,26 +657,30 @@ local fieldSetters = {
|
|
|
612
657
|
}
|
|
613
658
|
local dummies = {}
|
|
614
659
|
for ____, player in ipairs(Player.all) do
|
|
615
|
-
local dummy = assert(
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
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
|
+
)
|
|
622
671
|
ShowUnit(dummy, false)
|
|
623
672
|
dummies[player] = dummy
|
|
624
673
|
end
|
|
625
674
|
local function delayHealthChecksCallback(unit)
|
|
626
|
-
local counter = (unit[
|
|
675
|
+
local counter = (unit[104] or 0) - 1
|
|
627
676
|
if counter ~= 0 then
|
|
628
|
-
unit[
|
|
677
|
+
unit[104] = counter
|
|
629
678
|
return
|
|
630
679
|
end
|
|
631
|
-
unit[
|
|
632
|
-
local healthBonus = unit[
|
|
680
|
+
unit[104] = nil
|
|
681
|
+
local healthBonus = unit[105]
|
|
633
682
|
if healthBonus ~= nil then
|
|
634
|
-
unit[
|
|
683
|
+
unit[105] = nil
|
|
635
684
|
local handle = unit.handle
|
|
636
685
|
BlzSetUnitMaxHP(
|
|
637
686
|
handle,
|
|
@@ -640,49 +689,73 @@ local function delayHealthChecksCallback(unit)
|
|
|
640
689
|
end
|
|
641
690
|
end
|
|
642
691
|
local nextSyncId = 1
|
|
643
|
-
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
|
|
644
703
|
____exports.Unit = __TS__Class()
|
|
645
704
|
local Unit = ____exports.Unit
|
|
646
705
|
Unit.name = "Unit"
|
|
647
706
|
__TS__ClassExtends(Unit, Handle)
|
|
648
707
|
function Unit.prototype.____constructor(self, handle)
|
|
649
708
|
Handle.prototype.____constructor(self, handle)
|
|
650
|
-
local
|
|
651
|
-
nextSyncId =
|
|
652
|
-
self.syncId =
|
|
709
|
+
local ____nextSyncId_1 = nextSyncId
|
|
710
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
711
|
+
self.syncId = ____nextSyncId_1
|
|
653
712
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
654
|
-
assert(
|
|
655
|
-
|
|
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
|
+
)
|
|
656
723
|
if unitAddAbility(
|
|
657
724
|
handle,
|
|
658
725
|
fourCC("Amrf")
|
|
659
726
|
) then
|
|
660
|
-
assert(
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
727
|
+
assert(
|
|
728
|
+
unitRemoveAbility(
|
|
729
|
+
handle,
|
|
730
|
+
fourCC("Amrf")
|
|
731
|
+
),
|
|
732
|
+
"fly ability must be removed after addition",
|
|
733
|
+
self
|
|
734
|
+
)
|
|
664
735
|
end
|
|
665
736
|
unitBySyncId[self.syncId] = self
|
|
666
737
|
local ____ = self.abilities
|
|
667
738
|
end
|
|
668
|
-
function Unit.prototype.getEvent(self,
|
|
669
|
-
self.events = self.events or (
|
|
670
|
-
local eventId = GetHandleId(
|
|
671
|
-
|
|
672
|
-
|
|
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(
|
|
673
745
|
TriggerEvent,
|
|
674
746
|
function(trigger)
|
|
675
|
-
TriggerRegisterUnitEvent(trigger, self.handle,
|
|
747
|
+
TriggerRegisterUnitEvent(trigger, self.handle, jevent)
|
|
676
748
|
end,
|
|
677
749
|
collector or (function() return {} end)
|
|
678
750
|
)
|
|
751
|
+
self.events:put(eventId, event)
|
|
679
752
|
end
|
|
680
|
-
return
|
|
753
|
+
return event
|
|
681
754
|
end
|
|
682
755
|
function Unit.prototype.onDestroy(self)
|
|
683
756
|
local handle = self.handle
|
|
684
|
-
self[
|
|
685
|
-
self[
|
|
757
|
+
self[108] = getUnitX(handle)
|
|
758
|
+
self[109] = getUnitY(handle)
|
|
686
759
|
if not self._owner then
|
|
687
760
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
688
761
|
end
|
|
@@ -721,7 +794,11 @@ function Unit.prototype.addAttackHandler(self, condition, action)
|
|
|
721
794
|
self._attackHandlers = handlers
|
|
722
795
|
if #handlers == 1 then
|
|
723
796
|
local handle = self.handle
|
|
724
|
-
assert(
|
|
797
|
+
assert(
|
|
798
|
+
unitAddAbility(handle, attackHandlerAbilityId) and UnitMakeAbilityPermanent(handle, true, attackHandlerAbilityId),
|
|
799
|
+
"attack handler ability must be added",
|
|
800
|
+
self
|
|
801
|
+
)
|
|
725
802
|
end
|
|
726
803
|
return handler
|
|
727
804
|
end
|
|
@@ -750,17 +827,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
750
827
|
end}
|
|
751
828
|
end
|
|
752
829
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
753
|
-
local
|
|
754
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
830
|
+
local ____combatClassification_2 = combatClassification
|
|
831
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
|
|
755
832
|
end
|
|
756
833
|
function Unit.prototype.addClassification(self, classification)
|
|
757
|
-
return
|
|
834
|
+
return UnitAddType(self.handle, classification)
|
|
758
835
|
end
|
|
759
836
|
function Unit.prototype.removeClassification(self, classification)
|
|
760
|
-
return
|
|
837
|
+
return UnitRemoveType(self.handle, classification)
|
|
761
838
|
end
|
|
762
839
|
function Unit.prototype.hasClassification(self, classification)
|
|
763
|
-
return
|
|
840
|
+
return IsUnitType(self.handle, classification)
|
|
764
841
|
end
|
|
765
842
|
function Unit.prototype.isVisibleTo(self, player)
|
|
766
843
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -769,13 +846,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
769
846
|
return isUnitInvisible(self.handle, player.handle)
|
|
770
847
|
end
|
|
771
848
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
772
|
-
local
|
|
849
|
+
local ____temp_3
|
|
773
850
|
if type(x) == "number" then
|
|
774
|
-
|
|
851
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
775
852
|
else
|
|
776
|
-
|
|
853
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
777
854
|
end
|
|
778
|
-
return
|
|
855
|
+
return ____temp_3
|
|
779
856
|
end
|
|
780
857
|
function Unit.prototype.isAllyOf(self, unit)
|
|
781
858
|
return isUnitAlly(
|
|
@@ -793,19 +870,30 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
793
870
|
if type(animation) == "number" then
|
|
794
871
|
setUnitAnimationByIndex(self.handle, animation)
|
|
795
872
|
elseif rarity then
|
|
796
|
-
|
|
873
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
797
874
|
else
|
|
798
875
|
setUnitAnimation(self.handle, animation)
|
|
799
876
|
end
|
|
800
877
|
end
|
|
801
878
|
function Unit.prototype.resetAnimation(self)
|
|
802
|
-
|
|
879
|
+
ResetUnitAnimation(self.handle)
|
|
803
880
|
end
|
|
804
881
|
function Unit.prototype.queueAnimation(self, animation)
|
|
805
|
-
|
|
882
|
+
QueueUnitAnimation(self.handle, animation)
|
|
883
|
+
end
|
|
884
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
885
|
+
local firstWeapon = self.firstWeapon
|
|
886
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
887
|
+
return firstWeapon
|
|
888
|
+
end
|
|
889
|
+
local secondWeapon = self.secondWeapon
|
|
890
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
891
|
+
return secondWeapon
|
|
892
|
+
end
|
|
893
|
+
return nil
|
|
806
894
|
end
|
|
807
895
|
function Unit.prototype.delayHealthChecks(self)
|
|
808
|
-
self[
|
|
896
|
+
self[104] = (self[104] or 0) + 1
|
|
809
897
|
Timer:run(delayHealthChecksCallback, self)
|
|
810
898
|
end
|
|
811
899
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -815,21 +903,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
815
903
|
return IsUnitSelected(self.handle, player.handle)
|
|
816
904
|
end
|
|
817
905
|
function Unit.prototype.explode(self)
|
|
818
|
-
|
|
906
|
+
SetUnitExploded(self.handle, true)
|
|
819
907
|
killUnit(self.handle)
|
|
820
908
|
end
|
|
821
909
|
function Unit.prototype.kill(self)
|
|
822
910
|
killUnit(self.handle)
|
|
823
911
|
end
|
|
824
912
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
825
|
-
local
|
|
826
|
-
local
|
|
827
|
-
local
|
|
828
|
-
if
|
|
829
|
-
|
|
913
|
+
local ____ReviveHero_6 = ReviveHero
|
|
914
|
+
local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
|
|
915
|
+
local ____doEffect_4 = doEffect
|
|
916
|
+
if ____doEffect_4 == nil then
|
|
917
|
+
____doEffect_4 = false
|
|
830
918
|
end
|
|
831
|
-
__TS__SparseArrayPush(
|
|
832
|
-
|
|
919
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
920
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
833
921
|
end
|
|
834
922
|
function Unit.prototype.healTarget(self, target, amount)
|
|
835
923
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -872,17 +960,16 @@ function Unit.prototype.itemInSlot(self, slot)
|
|
|
872
960
|
return Item:of(unitItemInSlot(self.handle, slot))
|
|
873
961
|
end
|
|
874
962
|
function Unit.prototype.addAbility(self, abilityId)
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
963
|
+
local ability = UnitAbility:of(
|
|
964
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
965
|
+
abilityId,
|
|
966
|
+
self
|
|
967
|
+
)
|
|
968
|
+
if ability ~= nil then
|
|
881
969
|
local abilities = self.abilities
|
|
882
970
|
abilities[#abilities + 1] = ability
|
|
883
|
-
return ability
|
|
884
971
|
end
|
|
885
|
-
return
|
|
972
|
+
return ability
|
|
886
973
|
end
|
|
887
974
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
888
975
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -896,31 +983,21 @@ end
|
|
|
896
983
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
897
984
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
898
985
|
end
|
|
899
|
-
function Unit.prototype.
|
|
900
|
-
local
|
|
901
|
-
|
|
902
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
903
|
-
return nil
|
|
904
|
-
end
|
|
905
|
-
return UnitAbility:of(
|
|
906
|
-
getUnitAbility(self.handle, abilityId),
|
|
907
|
-
abilityId,
|
|
908
|
-
self
|
|
909
|
-
)
|
|
986
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
987
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
988
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
910
989
|
end
|
|
911
|
-
function Unit.prototype.removeAbility(self,
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
end
|
|
990
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
991
|
+
local abilities = self.abilities
|
|
992
|
+
for i = 1, #abilities do
|
|
993
|
+
if abilities[i].typeId == abilityTypeId then
|
|
994
|
+
local ability = abilities[i]
|
|
995
|
+
tremove(abilities, i)
|
|
996
|
+
ability:destroy()
|
|
997
|
+
return true
|
|
920
998
|
end
|
|
921
|
-
return true
|
|
922
999
|
end
|
|
923
|
-
return
|
|
1000
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
924
1001
|
end
|
|
925
1002
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
926
1003
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -934,9 +1011,6 @@ end
|
|
|
934
1011
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
935
1012
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
936
1013
|
end
|
|
937
|
-
function Unit.prototype.interruptAttack(self)
|
|
938
|
-
unitInterruptAttack(self.handle)
|
|
939
|
-
end
|
|
940
1014
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
941
1015
|
local handle = self.handle
|
|
942
1016
|
unitDisableAbility(handle, abilityId, true, false)
|
|
@@ -1007,18 +1081,44 @@ function Unit.prototype.unpauseEx(self)
|
|
|
1007
1081
|
end
|
|
1008
1082
|
function Unit.prototype.incrementStunCounter(self)
|
|
1009
1083
|
local stunCounter = self[102] or 0
|
|
1010
|
-
if not self[101] or stunCounter >= 0 then
|
|
1084
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
|
|
1011
1085
|
BlzPauseUnitEx(self.handle, true)
|
|
1012
1086
|
end
|
|
1013
1087
|
self[102] = stunCounter + 1
|
|
1014
1088
|
end
|
|
1015
1089
|
function Unit.prototype.decrementStunCounter(self)
|
|
1016
1090
|
local stunCounter = self[102] or 0
|
|
1017
|
-
if not self[101] or stunCounter >= 1 then
|
|
1091
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
|
|
1018
1092
|
BlzPauseUnitEx(self.handle, false)
|
|
1019
1093
|
end
|
|
1020
1094
|
self[102] = stunCounter - 1
|
|
1021
1095
|
end
|
|
1096
|
+
function Unit.prototype.incrementForceStunCounter(self)
|
|
1097
|
+
local forceStunCounter = self[103] or 0
|
|
1098
|
+
if forceStunCounter == 0 then
|
|
1099
|
+
local handle = self.handle
|
|
1100
|
+
if not self[101] then
|
|
1101
|
+
for _ = self[102] or 0, -1 do
|
|
1102
|
+
BlzPauseUnitEx(handle, true)
|
|
1103
|
+
end
|
|
1104
|
+
end
|
|
1105
|
+
BlzPauseUnitEx(handle, true)
|
|
1106
|
+
end
|
|
1107
|
+
self[103] = forceStunCounter + 1
|
|
1108
|
+
end
|
|
1109
|
+
function Unit.prototype.decrementForceStunCounter(self)
|
|
1110
|
+
local forceStunCounter = self[103] or 0
|
|
1111
|
+
if forceStunCounter == 1 then
|
|
1112
|
+
local handle = self.handle
|
|
1113
|
+
if not self[101] then
|
|
1114
|
+
for _ = self[102] or 0, -1 do
|
|
1115
|
+
BlzPauseUnitEx(handle, false)
|
|
1116
|
+
end
|
|
1117
|
+
end
|
|
1118
|
+
BlzPauseUnitEx(handle, false)
|
|
1119
|
+
end
|
|
1120
|
+
self[103] = forceStunCounter - 1
|
|
1121
|
+
end
|
|
1022
1122
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1023
1123
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
1024
1124
|
owner.handle,
|
|
@@ -1207,7 +1307,7 @@ __TS__SetDescriptor(
|
|
|
1207
1307
|
Unit.prototype,
|
|
1208
1308
|
"isIllusion",
|
|
1209
1309
|
{get = function(self)
|
|
1210
|
-
return
|
|
1310
|
+
return IsUnitIllusion(self.handle)
|
|
1211
1311
|
end},
|
|
1212
1312
|
true
|
|
1213
1313
|
)
|
|
@@ -1294,13 +1394,13 @@ __TS__SetDescriptor(
|
|
|
1294
1394
|
)
|
|
1295
1395
|
__TS__SetDescriptor(
|
|
1296
1396
|
Unit.prototype,
|
|
1297
|
-
"
|
|
1397
|
+
"primaryAttribute",
|
|
1298
1398
|
{
|
|
1299
1399
|
get = function(self)
|
|
1300
|
-
return
|
|
1400
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1301
1401
|
end,
|
|
1302
|
-
set = function(self,
|
|
1303
|
-
|
|
1402
|
+
set = function(self, primaryAttribute)
|
|
1403
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1304
1404
|
end
|
|
1305
1405
|
},
|
|
1306
1406
|
true
|
|
@@ -1322,19 +1422,6 @@ __TS__SetDescriptor(
|
|
|
1322
1422
|
end},
|
|
1323
1423
|
true
|
|
1324
1424
|
)
|
|
1325
|
-
__TS__SetDescriptor(
|
|
1326
|
-
Unit.prototype,
|
|
1327
|
-
"agilityBase",
|
|
1328
|
-
{
|
|
1329
|
-
get = function(self)
|
|
1330
|
-
return getHeroAgi(self.handle, false)
|
|
1331
|
-
end,
|
|
1332
|
-
set = function(self, agilityBase)
|
|
1333
|
-
setHeroAgi(self.handle, agilityBase, true)
|
|
1334
|
-
end
|
|
1335
|
-
},
|
|
1336
|
-
true
|
|
1337
|
-
)
|
|
1338
1425
|
__TS__SetDescriptor(
|
|
1339
1426
|
Unit.prototype,
|
|
1340
1427
|
"agilityBonus",
|
|
@@ -1352,19 +1439,6 @@ __TS__SetDescriptor(
|
|
|
1352
1439
|
end},
|
|
1353
1440
|
true
|
|
1354
1441
|
)
|
|
1355
|
-
__TS__SetDescriptor(
|
|
1356
|
-
Unit.prototype,
|
|
1357
|
-
"intelligenceBase",
|
|
1358
|
-
{
|
|
1359
|
-
get = function(self)
|
|
1360
|
-
return getHeroInt(self.handle, false)
|
|
1361
|
-
end,
|
|
1362
|
-
set = function(self, intelligenceBase)
|
|
1363
|
-
setHeroInt(self.handle, intelligenceBase, true)
|
|
1364
|
-
end
|
|
1365
|
-
},
|
|
1366
|
-
true
|
|
1367
|
-
)
|
|
1368
1442
|
__TS__SetDescriptor(
|
|
1369
1443
|
Unit.prototype,
|
|
1370
1444
|
"intelligenceBonus",
|
|
@@ -1413,17 +1487,17 @@ __TS__SetDescriptor(
|
|
|
1413
1487
|
"isTeamGlowVisible",
|
|
1414
1488
|
{
|
|
1415
1489
|
get = function(self)
|
|
1416
|
-
return not self[
|
|
1490
|
+
return not self[107]
|
|
1417
1491
|
end,
|
|
1418
1492
|
set = function(self, isTeamGlowVisible)
|
|
1419
|
-
|
|
1420
|
-
local
|
|
1493
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1494
|
+
local ____temp_7
|
|
1421
1495
|
if not isTeamGlowVisible then
|
|
1422
|
-
|
|
1496
|
+
____temp_7 = true
|
|
1423
1497
|
else
|
|
1424
|
-
|
|
1498
|
+
____temp_7 = nil
|
|
1425
1499
|
end
|
|
1426
|
-
self[
|
|
1500
|
+
self[107] = ____temp_7
|
|
1427
1501
|
end
|
|
1428
1502
|
},
|
|
1429
1503
|
true
|
|
@@ -1432,9 +1506,9 @@ __TS__SetDescriptor(
|
|
|
1432
1506
|
Unit.prototype,
|
|
1433
1507
|
"color",
|
|
1434
1508
|
{set = function(self, color)
|
|
1435
|
-
|
|
1436
|
-
if self[
|
|
1437
|
-
|
|
1509
|
+
SetUnitColor(self.handle, color.handle)
|
|
1510
|
+
if self[107] then
|
|
1511
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1438
1512
|
end
|
|
1439
1513
|
end},
|
|
1440
1514
|
true
|
|
@@ -1457,14 +1531,14 @@ __TS__SetDescriptor(
|
|
|
1457
1531
|
"maxHealth",
|
|
1458
1532
|
{
|
|
1459
1533
|
get = function(self)
|
|
1460
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1534
|
+
return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
|
|
1461
1535
|
end,
|
|
1462
1536
|
set = function(self, maxHealth)
|
|
1463
|
-
if maxHealth < 1 and self[
|
|
1464
|
-
self[
|
|
1537
|
+
if maxHealth < 1 and self[104] ~= nil then
|
|
1538
|
+
self[105] = (self[105] or 0) + (1 - maxHealth)
|
|
1465
1539
|
maxHealth = 1
|
|
1466
1540
|
end
|
|
1467
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1541
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
|
|
1468
1542
|
end
|
|
1469
1543
|
},
|
|
1470
1544
|
true
|
|
@@ -1506,10 +1580,10 @@ __TS__SetDescriptor(
|
|
|
1506
1580
|
"health",
|
|
1507
1581
|
{
|
|
1508
1582
|
get = function(self)
|
|
1509
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1583
|
+
return GetWidgetLife(self.handle) - (self[106] or 0)
|
|
1510
1584
|
end,
|
|
1511
1585
|
set = function(self, health)
|
|
1512
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1586
|
+
SetWidgetLife(self.handle, health + (self[106] or 0))
|
|
1513
1587
|
end
|
|
1514
1588
|
},
|
|
1515
1589
|
true
|
|
@@ -1585,25 +1659,12 @@ __TS__SetDescriptor(
|
|
|
1585
1659
|
},
|
|
1586
1660
|
true
|
|
1587
1661
|
)
|
|
1588
|
-
__TS__SetDescriptor(
|
|
1589
|
-
Unit.prototype,
|
|
1590
|
-
"flyHeight",
|
|
1591
|
-
{
|
|
1592
|
-
get = function(self)
|
|
1593
|
-
return getUnitFlyHeight(self.handle)
|
|
1594
|
-
end,
|
|
1595
|
-
set = function(self, v)
|
|
1596
|
-
SetUnitFlyHeight(self.handle, v, 100000)
|
|
1597
|
-
end
|
|
1598
|
-
},
|
|
1599
|
-
true
|
|
1600
|
-
)
|
|
1601
1662
|
__TS__SetDescriptor(
|
|
1602
1663
|
Unit.prototype,
|
|
1603
1664
|
"x",
|
|
1604
1665
|
{
|
|
1605
1666
|
get = function(self)
|
|
1606
|
-
return self[
|
|
1667
|
+
return self[108] or getUnitX(self.handle)
|
|
1607
1668
|
end,
|
|
1608
1669
|
set = function(self, v)
|
|
1609
1670
|
SetUnitX(self.handle, v)
|
|
@@ -1616,7 +1677,7 @@ __TS__SetDescriptor(
|
|
|
1616
1677
|
"y",
|
|
1617
1678
|
{
|
|
1618
1679
|
get = function(self)
|
|
1619
|
-
return self[
|
|
1680
|
+
return self[109] or getUnitY(self.handle)
|
|
1620
1681
|
end,
|
|
1621
1682
|
set = function(self, v)
|
|
1622
1683
|
SetUnitY(self.handle, v)
|
|
@@ -1702,10 +1763,10 @@ __TS__SetDescriptor(
|
|
|
1702
1763
|
"gold",
|
|
1703
1764
|
{
|
|
1704
1765
|
get = function(self)
|
|
1705
|
-
return
|
|
1766
|
+
return GetResourceAmount(self.handle)
|
|
1706
1767
|
end,
|
|
1707
1768
|
set = function(self, gold)
|
|
1708
|
-
|
|
1769
|
+
SetResourceAmount(self.handle, gold)
|
|
1709
1770
|
end
|
|
1710
1771
|
},
|
|
1711
1772
|
true
|
|
@@ -1721,14 +1782,18 @@ __TS__SetDescriptor(
|
|
|
1721
1782
|
local handle = self.handle
|
|
1722
1783
|
if isPaused and not IsUnitPaused(handle) then
|
|
1723
1784
|
self[101] = true
|
|
1724
|
-
|
|
1725
|
-
|
|
1785
|
+
if (self[103] or 0) <= 0 then
|
|
1786
|
+
for _ = self[102] or 0, -1 do
|
|
1787
|
+
BlzPauseUnitEx(handle, true)
|
|
1788
|
+
end
|
|
1726
1789
|
end
|
|
1727
1790
|
PauseUnit(handle, true)
|
|
1728
1791
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1729
1792
|
PauseUnit(handle, false)
|
|
1730
|
-
|
|
1731
|
-
|
|
1793
|
+
if (self[103] or 0) <= 0 then
|
|
1794
|
+
for _ = self[102] or 0, -1 do
|
|
1795
|
+
BlzPauseUnitEx(handle, false)
|
|
1796
|
+
end
|
|
1732
1797
|
end
|
|
1733
1798
|
self[101] = nil
|
|
1734
1799
|
end
|
|
@@ -1786,20 +1851,6 @@ __TS__SetDescriptor(
|
|
|
1786
1851
|
},
|
|
1787
1852
|
true
|
|
1788
1853
|
)
|
|
1789
|
-
__TS__SetDescriptor(
|
|
1790
|
-
Unit.prototype,
|
|
1791
|
-
"scale",
|
|
1792
|
-
{
|
|
1793
|
-
get = function(self)
|
|
1794
|
-
return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
|
|
1795
|
-
end,
|
|
1796
|
-
set = function(self, v)
|
|
1797
|
-
setUnitScale(self.handle, v, v, v)
|
|
1798
|
-
setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
|
|
1799
|
-
end
|
|
1800
|
-
},
|
|
1801
|
-
true
|
|
1802
|
-
)
|
|
1803
1854
|
__TS__SetDescriptor(
|
|
1804
1855
|
Unit.prototype,
|
|
1805
1856
|
"timeScale",
|
|
@@ -1833,6 +1884,19 @@ __TS__SetDescriptor(
|
|
|
1833
1884
|
end},
|
|
1834
1885
|
true
|
|
1835
1886
|
)
|
|
1887
|
+
__TS__SetDescriptor(
|
|
1888
|
+
Unit.prototype,
|
|
1889
|
+
"movementType",
|
|
1890
|
+
{
|
|
1891
|
+
get = function(self)
|
|
1892
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1893
|
+
end,
|
|
1894
|
+
set = function(self, movementType)
|
|
1895
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1896
|
+
end
|
|
1897
|
+
},
|
|
1898
|
+
true
|
|
1899
|
+
)
|
|
1836
1900
|
__TS__SetDescriptor(
|
|
1837
1901
|
Unit.prototype,
|
|
1838
1902
|
"pathing",
|
|
@@ -2014,6 +2078,14 @@ __TS__SetDescriptor(
|
|
|
2014
2078
|
end},
|
|
2015
2079
|
true
|
|
2016
2080
|
)
|
|
2081
|
+
__TS__SetDescriptor(
|
|
2082
|
+
Unit.prototype,
|
|
2083
|
+
"targetAcquiredEvent",
|
|
2084
|
+
{get = function(self)
|
|
2085
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2086
|
+
end},
|
|
2087
|
+
true
|
|
2088
|
+
)
|
|
2017
2089
|
__TS__SetDescriptor(
|
|
2018
2090
|
Unit.prototype,
|
|
2019
2091
|
"onSelect",
|
|
@@ -2074,6 +2146,11 @@ __TS__SetDescriptor(
|
|
|
2074
2146
|
end},
|
|
2075
2147
|
true
|
|
2076
2148
|
)
|
|
2149
|
+
Unit.levelChangedEvent = __TS__New(
|
|
2150
|
+
____exports.UnitTriggerEvent,
|
|
2151
|
+
EVENT_PLAYER_HERO_LEVEL,
|
|
2152
|
+
function() return ____exports.Unit:of(getTriggerUnit()) end
|
|
2153
|
+
)
|
|
2077
2154
|
Unit.deathEvent = __TS__New(
|
|
2078
2155
|
____exports.UnitTriggerEvent,
|
|
2079
2156
|
EVENT_PLAYER_UNIT_DEATH,
|
|
@@ -2149,25 +2226,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2149
2226
|
InitializingEvent,
|
|
2150
2227
|
function(event)
|
|
2151
2228
|
local function listener(unit, id)
|
|
2152
|
-
local
|
|
2229
|
+
local ____GetSpellTargetUnit_result_10
|
|
2153
2230
|
if GetSpellTargetUnit() then
|
|
2154
|
-
|
|
2231
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2155
2232
|
else
|
|
2156
|
-
local
|
|
2233
|
+
local ____GetSpellTargetItem_result_9
|
|
2157
2234
|
if GetSpellTargetItem() then
|
|
2158
|
-
|
|
2235
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2159
2236
|
else
|
|
2160
|
-
local
|
|
2237
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2161
2238
|
if GetSpellTargetDestructable() then
|
|
2162
|
-
|
|
2239
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2163
2240
|
else
|
|
2164
|
-
|
|
2241
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2165
2242
|
end
|
|
2166
|
-
|
|
2243
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2167
2244
|
end
|
|
2168
|
-
|
|
2245
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2169
2246
|
end
|
|
2170
|
-
local target =
|
|
2247
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2171
2248
|
if target then
|
|
2172
2249
|
invoke(event, unit, id, target)
|
|
2173
2250
|
end
|
|
@@ -2375,38 +2452,57 @@ Unit.onDamaging = (function()
|
|
|
2375
2452
|
if source and source.typeId == dummyUnitId then
|
|
2376
2453
|
source = nil
|
|
2377
2454
|
end
|
|
2378
|
-
local target = BlzGetEventDamageTarget()
|
|
2455
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2456
|
+
local metadata = damageMetadataByTarget[target]
|
|
2457
|
+
damageMetadataByTarget[target] = nil
|
|
2379
2458
|
local data = {
|
|
2380
2459
|
amount = GetEventDamage(),
|
|
2381
|
-
attackType = BlzGetEventAttackType(),
|
|
2460
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2382
2461
|
damageType = BlzGetEventDamageType(),
|
|
2383
2462
|
weaponType = BlzGetEventWeaponType(),
|
|
2384
|
-
|
|
2463
|
+
metadata = metadata,
|
|
2464
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2465
|
+
originalAmount = GetEventDamage(),
|
|
2466
|
+
originalMetadata = metadata,
|
|
2467
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2385
2468
|
}
|
|
2386
2469
|
if data.isAttack and source then
|
|
2387
|
-
|
|
2388
|
-
if weapon == -1 then
|
|
2389
|
-
local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
|
|
2390
|
-
weapon = 0
|
|
2391
|
-
end
|
|
2392
|
-
data.weapon = assert(source.weapons[weapon + 1])
|
|
2470
|
+
data.weapon = source:chooseWeapon(target)
|
|
2393
2471
|
end
|
|
2394
2472
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2395
2473
|
invoke(
|
|
2396
2474
|
event,
|
|
2397
2475
|
source,
|
|
2398
|
-
|
|
2476
|
+
target,
|
|
2399
2477
|
setmetatable(
|
|
2400
2478
|
{},
|
|
2401
2479
|
{
|
|
2402
2480
|
__index = data,
|
|
2403
2481
|
__newindex = function(self, key, value)
|
|
2404
|
-
damageSetters[key]
|
|
2482
|
+
local damageSetter = damageSetters[key]
|
|
2483
|
+
if damageSetter ~= nil then
|
|
2484
|
+
damageSetter(value)
|
|
2485
|
+
end
|
|
2405
2486
|
data[key] = value
|
|
2406
2487
|
end
|
|
2407
2488
|
}
|
|
2408
2489
|
)
|
|
2409
2490
|
)
|
|
2491
|
+
if data[0] and source then
|
|
2492
|
+
local sourceOwner = source.owner.handle
|
|
2493
|
+
data[1] = sourceOwner
|
|
2494
|
+
local targetOwner = target.owner.handle
|
|
2495
|
+
data[2] = targetOwner
|
|
2496
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2497
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2498
|
+
data[3] = true
|
|
2499
|
+
end
|
|
2500
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2501
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2502
|
+
data[4] = true
|
|
2503
|
+
end
|
|
2504
|
+
end
|
|
2505
|
+
damagingEventByTarget[target] = data
|
|
2410
2506
|
return
|
|
2411
2507
|
end
|
|
2412
2508
|
BlzSetEventDamage(0)
|
|
@@ -2414,7 +2510,7 @@ Unit.onDamaging = (function()
|
|
|
2414
2510
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2415
2511
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2416
2512
|
local sourceOwner = source.owner.handle
|
|
2417
|
-
local targetOwner =
|
|
2513
|
+
local targetOwner = target.owner.handle
|
|
2418
2514
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2419
2515
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2420
2516
|
Timer:run(function()
|
|
@@ -2430,23 +2526,19 @@ Unit.onDamaging = (function()
|
|
|
2430
2526
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2431
2527
|
local condition = ____value[1]
|
|
2432
2528
|
local action = ____value[2]
|
|
2433
|
-
if condition(
|
|
2434
|
-
source,
|
|
2435
|
-
____exports.Unit:of(target),
|
|
2436
|
-
data
|
|
2437
|
-
) then
|
|
2529
|
+
if condition(source, target, data) then
|
|
2438
2530
|
action(
|
|
2439
2531
|
source,
|
|
2440
|
-
|
|
2532
|
+
target,
|
|
2441
2533
|
setmetatable(
|
|
2442
2534
|
{fire = function()
|
|
2443
2535
|
UnitDamageTarget(
|
|
2444
2536
|
source.handle,
|
|
2445
|
-
target,
|
|
2537
|
+
target.handle,
|
|
2446
2538
|
data.amount,
|
|
2447
2539
|
true,
|
|
2448
2540
|
true,
|
|
2449
|
-
data.attackType,
|
|
2541
|
+
attackTypeToNative(data.attackType),
|
|
2450
2542
|
data.damageType,
|
|
2451
2543
|
data.weaponType
|
|
2452
2544
|
)
|
|
@@ -2473,30 +2565,54 @@ Unit.onDamage = __TS__New(
|
|
|
2473
2565
|
if source and source.typeId == dummyUnitId then
|
|
2474
2566
|
source = nil
|
|
2475
2567
|
end
|
|
2568
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2569
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2570
|
+
damagingEventByTarget[target] = nil
|
|
2476
2571
|
local data = {
|
|
2477
2572
|
amount = GetEventDamage(),
|
|
2478
|
-
attackType = BlzGetEventAttackType(),
|
|
2573
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2479
2574
|
damageType = BlzGetEventDamageType(),
|
|
2480
2575
|
weaponType = BlzGetEventWeaponType(),
|
|
2576
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2481
2577
|
isAttack = BlzGetEventIsAttack(),
|
|
2482
|
-
originalAmount = GetEventDamage(),
|
|
2578
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2579
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2483
2580
|
preventDeath = damageEventPreventDeath
|
|
2484
2581
|
}
|
|
2582
|
+
if damagingEvent then
|
|
2583
|
+
for key, value in pairs(damagingEvent) do
|
|
2584
|
+
if isAttribute(key) then
|
|
2585
|
+
data[key] = value
|
|
2586
|
+
end
|
|
2587
|
+
end
|
|
2588
|
+
local sourceOwner = damagingEvent[1]
|
|
2589
|
+
if sourceOwner then
|
|
2590
|
+
local targetOwner = damagingEvent[2]
|
|
2591
|
+
if damagingEvent[3] then
|
|
2592
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2593
|
+
end
|
|
2594
|
+
if damagingEvent[4] then
|
|
2595
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2596
|
+
end
|
|
2597
|
+
end
|
|
2598
|
+
end
|
|
2485
2599
|
local evData = setmetatable(
|
|
2486
2600
|
{},
|
|
2487
2601
|
{
|
|
2488
2602
|
__index = data,
|
|
2489
2603
|
__newindex = function(self, key, value)
|
|
2490
|
-
damageSetters[key]
|
|
2604
|
+
local damageSetter = damageSetters[key]
|
|
2605
|
+
if damageSetter ~= nil then
|
|
2606
|
+
damageSetter(value)
|
|
2607
|
+
end
|
|
2491
2608
|
data[key] = value
|
|
2492
2609
|
end
|
|
2493
2610
|
}
|
|
2494
2611
|
)
|
|
2495
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2496
2612
|
invoke(event, source, target, evData)
|
|
2497
2613
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2498
2614
|
local bonusHealth = math.ceil(evData.amount)
|
|
2499
|
-
target[
|
|
2615
|
+
target[106] = (target[106] or 0) + bonusHealth
|
|
2500
2616
|
BlzSetUnitMaxHP(
|
|
2501
2617
|
target.handle,
|
|
2502
2618
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2510,7 +2626,7 @@ Unit.onDamage = __TS__New(
|
|
|
2510
2626
|
evData[0],
|
|
2511
2627
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2512
2628
|
)
|
|
2513
|
-
target[
|
|
2629
|
+
target[106] = (target[106] or 0) - bonusHealth
|
|
2514
2630
|
SetWidgetLife(
|
|
2515
2631
|
target.handle,
|
|
2516
2632
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2546,10 +2662,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2546
2662
|
____exports.UnitTriggerEvent,
|
|
2547
2663
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2548
2664
|
function()
|
|
2549
|
-
local
|
|
2550
|
-
local
|
|
2551
|
-
if getUnitTypeId(
|
|
2552
|
-
|
|
2665
|
+
local unitHandle = getTriggerUnit()
|
|
2666
|
+
local itemHandle = getManipulatedItem()
|
|
2667
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2668
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2669
|
+
local item = Item:of(itemHandle)
|
|
2670
|
+
if item.owner ~= unit then
|
|
2671
|
+
return unit, item
|
|
2672
|
+
end
|
|
2553
2673
|
end
|
|
2554
2674
|
return IgnoreEvent
|
|
2555
2675
|
end
|
|
@@ -2569,7 +2689,22 @@ Unit.itemUsedEvent = __TS__New(
|
|
|
2569
2689
|
Unit.itemStackedEvent = __TS__New(
|
|
2570
2690
|
____exports.UnitTriggerEvent,
|
|
2571
2691
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2572
|
-
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(
|
|
2692
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2693
|
+
)
|
|
2694
|
+
__TS__ObjectDefineProperty(
|
|
2695
|
+
Unit,
|
|
2696
|
+
"itemChargesChangedEvent",
|
|
2697
|
+
{get = function(self)
|
|
2698
|
+
local event = __TS__New(Event)
|
|
2699
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2700
|
+
local unit = item.owner
|
|
2701
|
+
if unit ~= nil then
|
|
2702
|
+
invoke(event, unit, item)
|
|
2703
|
+
end
|
|
2704
|
+
end)
|
|
2705
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2706
|
+
return event
|
|
2707
|
+
end}
|
|
2573
2708
|
)
|
|
2574
2709
|
__TS__ObjectDefineProperty(
|
|
2575
2710
|
Unit,
|
|
@@ -2641,6 +2776,10 @@ __TS__ObjectDefineProperty(
|
|
|
2641
2776
|
rawset(self, "destroyEvent", destroyEvent)
|
|
2642
2777
|
return destroyEvent
|
|
2643
2778
|
end}
|
|
2779
|
+
)
|
|
2780
|
+
Unit.synchronize = synchronizer(
|
|
2781
|
+
function(unit) return unit.syncId end,
|
|
2782
|
+
function(syncId) return unitBySyncId[syncId] end
|
|
2644
2783
|
);
|
|
2645
2784
|
(function(self)
|
|
2646
2785
|
local leaveAbilityIds = postcompile(function()
|