warscript 0.0.1-dev.9048d45 → 0.0.1-dev.90da649
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/apply-unit-behavior.lua +1 -0
- package/engine/behaviour/ability/damage.d.ts +9 -3
- package/engine/behaviour/ability/damage.lua +26 -38
- 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 +7 -2
- package/engine/behaviour/ability.lua +28 -22
- package/engine/behaviour/unit/stun-immunity.d.ts +11 -5
- package/engine/behaviour/unit/stun-immunity.lua +53 -28
- package/engine/behaviour/unit.d.ts +40 -2
- package/engine/behaviour/unit.lua +259 -6
- package/engine/buff.d.ts +28 -12
- package/engine/buff.lua +222 -128
- 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/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/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/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 +45 -14
- package/engine/internal/unit.d.ts +43 -17
- package/engine/internal/unit.lua +343 -172
- 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/curse.lua +2 -2
- package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
- package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
- package/engine/object-data/entry/ability-type/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/raise-dead.d.ts +17 -0
- package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
- package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
- package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
- package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
- package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
- package/engine/object-data/entry/ability-type/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 +3 -0
- package/engine/unit.lua +3 -0
- package/net/socket.lua +1 -1
- package/objutil/buff.lua +2 -3
- package/package.json +2 -2
- 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-set.d.ts +2 -0
- package/utility/linked-set.lua +22 -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/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,34 +53,42 @@ 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 ____unit = require("engine.standard.fields.unit")
|
|
68
|
+
local AGILITY_UNIT_FIELD = ____unit.AGILITY_UNIT_FIELD
|
|
69
|
+
local INTELLIGENCE_UNIT_FIELD = ____unit.INTELLIGENCE_UNIT_FIELD
|
|
70
|
+
local STRENGTH_UNIT_FIELD = ____unit.STRENGTH_UNIT_FIELD
|
|
56
71
|
local match = string.match
|
|
57
72
|
local ____tostring = _G.tostring
|
|
58
73
|
local setUnitAnimation = SetUnitAnimation
|
|
59
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
60
74
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
61
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
62
75
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
63
76
|
local getUnitRealField = BlzGetUnitRealField
|
|
64
77
|
local getHeroStr = GetHeroStr
|
|
65
78
|
local getHeroAgi = GetHeroAgi
|
|
66
79
|
local getHeroInt = GetHeroInt
|
|
67
|
-
local setHeroStr = SetHeroStr
|
|
68
|
-
local setHeroAgi = SetHeroAgi
|
|
69
|
-
local setHeroInt = SetHeroInt
|
|
70
80
|
local getUnitBooleanField = BlzGetUnitBooleanField
|
|
71
81
|
local getUnitStringField = BlzGetUnitStringField
|
|
72
82
|
local setUnitIntegerField = BlzSetUnitIntegerField
|
|
73
83
|
local setUnitRealField = BlzSetUnitRealField
|
|
74
84
|
local setUnitBooleanField = BlzSetUnitBooleanField
|
|
75
85
|
local setUnitStringField = BlzSetUnitStringField
|
|
76
|
-
local setUnitScale = SetUnitScale
|
|
77
86
|
local setUnitPosition = SetUnitPosition
|
|
78
87
|
local setUnitTimeScale = SetUnitTimeScale
|
|
79
88
|
local getHandleId = GetHandleId
|
|
80
89
|
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
81
90
|
local createUnit = CreateUnit
|
|
82
91
|
local killUnit = KillUnit
|
|
83
|
-
local setUnitExploded = SetUnitExploded
|
|
84
92
|
local removeUnit = RemoveUnit
|
|
85
93
|
local getUnitTypeId = GetUnitTypeId
|
|
86
94
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -96,8 +104,6 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
96
104
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
97
105
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
98
106
|
local isUnitInRange = IsUnitInRange
|
|
99
|
-
local setResourceAmount = SetResourceAmount
|
|
100
|
-
local getResourceAmount = GetResourceAmount
|
|
101
107
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
102
108
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
103
109
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
@@ -121,15 +127,9 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
121
127
|
local getIssuedOrderId = GetIssuedOrderId
|
|
122
128
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
123
129
|
local unitAlive = UnitAlive
|
|
124
|
-
local unitAddType = UnitAddType
|
|
125
|
-
local unitRemoveType = UnitRemoveType
|
|
126
|
-
local isUnitIllusion = IsUnitIllusion
|
|
127
|
-
local isUnitType = IsUnitType
|
|
128
130
|
local isUnitAlly = IsUnitAlly
|
|
129
131
|
local isUnitEnemy = IsUnitEnemy
|
|
130
132
|
local getOwningPlayer = GetOwningPlayer
|
|
131
|
-
local setUnitColor = SetUnitColor
|
|
132
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
133
133
|
____exports.UnitClassification = {}
|
|
134
134
|
local UnitClassification = ____exports.UnitClassification
|
|
135
135
|
do
|
|
@@ -139,6 +139,7 @@ do
|
|
|
139
139
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
140
140
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
141
141
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
142
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
142
143
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
143
144
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
144
145
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -346,6 +347,9 @@ local function dispatchAbility(event)
|
|
|
346
347
|
}
|
|
347
348
|
)
|
|
348
349
|
end
|
|
350
|
+
local function damagingEventPreventRetaliation(self)
|
|
351
|
+
self[0] = true
|
|
352
|
+
end
|
|
349
353
|
local function damageEventPreventDeath(self, callback, ...)
|
|
350
354
|
if self[0] ~= nil then
|
|
351
355
|
return
|
|
@@ -357,7 +361,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
357
361
|
rawset(self, 1 + i, (select(i, ...)))
|
|
358
362
|
end
|
|
359
363
|
end
|
|
360
|
-
local damageSetters = {
|
|
364
|
+
local damageSetters = {
|
|
365
|
+
amount = BlzSetEventDamage,
|
|
366
|
+
attackType = function(attackType)
|
|
367
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
368
|
+
end,
|
|
369
|
+
damageType = BlzSetEventDamageType,
|
|
370
|
+
weaponType = BlzSetEventWeaponType
|
|
371
|
+
}
|
|
361
372
|
local jlimitopByOperator = {
|
|
362
373
|
[0] = LESS_THAN_OR_EQUAL,
|
|
363
374
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -401,6 +412,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
|
401
412
|
self.unit = unit
|
|
402
413
|
self.index = index
|
|
403
414
|
end
|
|
415
|
+
__TS__SetDescriptor(
|
|
416
|
+
UnitWeapon.prototype,
|
|
417
|
+
"isEnabled",
|
|
418
|
+
{
|
|
419
|
+
get = function(self)
|
|
420
|
+
return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
|
|
421
|
+
end,
|
|
422
|
+
set = function(self, isEnabled)
|
|
423
|
+
BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
|
|
424
|
+
end
|
|
425
|
+
},
|
|
426
|
+
true
|
|
427
|
+
)
|
|
404
428
|
__TS__SetDescriptor(
|
|
405
429
|
UnitWeapon.prototype,
|
|
406
430
|
"cooldown",
|
|
@@ -435,6 +459,19 @@ __TS__SetDescriptor(
|
|
|
435
459
|
},
|
|
436
460
|
true
|
|
437
461
|
)
|
|
462
|
+
__TS__SetDescriptor(
|
|
463
|
+
UnitWeapon.prototype,
|
|
464
|
+
"allowedTargetCombatClassifications",
|
|
465
|
+
{
|
|
466
|
+
get = function(self)
|
|
467
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
468
|
+
end,
|
|
469
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
470
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
471
|
+
end
|
|
472
|
+
},
|
|
473
|
+
true
|
|
474
|
+
)
|
|
438
475
|
__TS__SetDescriptor(
|
|
439
476
|
UnitWeapon.prototype,
|
|
440
477
|
"damageBase",
|
|
@@ -622,15 +659,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
622
659
|
dummies[player] = dummy
|
|
623
660
|
end
|
|
624
661
|
local function delayHealthChecksCallback(unit)
|
|
625
|
-
local counter = (unit[
|
|
662
|
+
local counter = (unit[104] or 0) - 1
|
|
626
663
|
if counter ~= 0 then
|
|
627
|
-
unit[
|
|
664
|
+
unit[104] = counter
|
|
628
665
|
return
|
|
629
666
|
end
|
|
630
|
-
unit[
|
|
631
|
-
local healthBonus = unit[
|
|
667
|
+
unit[104] = nil
|
|
668
|
+
local healthBonus = unit[105]
|
|
632
669
|
if healthBonus ~= nil then
|
|
633
|
-
unit[
|
|
670
|
+
unit[105] = nil
|
|
634
671
|
local handle = unit.handle
|
|
635
672
|
BlzSetUnitMaxHP(
|
|
636
673
|
handle,
|
|
@@ -639,16 +676,26 @@ local function delayHealthChecksCallback(unit)
|
|
|
639
676
|
end
|
|
640
677
|
end
|
|
641
678
|
local nextSyncId = 1
|
|
642
|
-
local unitBySyncId = setmetatable({}, {__mode = "
|
|
679
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
680
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
681
|
+
local function addAbility(unit, abilityTypeId)
|
|
682
|
+
local ____unitAddAbility_result_0
|
|
683
|
+
if unitAddAbility(unit, abilityTypeId) then
|
|
684
|
+
____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
|
|
685
|
+
else
|
|
686
|
+
____unitAddAbility_result_0 = nil
|
|
687
|
+
end
|
|
688
|
+
return ____unitAddAbility_result_0
|
|
689
|
+
end
|
|
643
690
|
____exports.Unit = __TS__Class()
|
|
644
691
|
local Unit = ____exports.Unit
|
|
645
692
|
Unit.name = "Unit"
|
|
646
693
|
__TS__ClassExtends(Unit, Handle)
|
|
647
694
|
function Unit.prototype.____constructor(self, handle)
|
|
648
695
|
Handle.prototype.____constructor(self, handle)
|
|
649
|
-
local
|
|
650
|
-
nextSyncId =
|
|
651
|
-
self.syncId =
|
|
696
|
+
local ____nextSyncId_1 = nextSyncId
|
|
697
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
698
|
+
self.syncId = ____nextSyncId_1
|
|
652
699
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
653
700
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
654
701
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -680,6 +727,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
680
727
|
end
|
|
681
728
|
function Unit.prototype.onDestroy(self)
|
|
682
729
|
local handle = self.handle
|
|
730
|
+
self[108] = getUnitX(handle)
|
|
731
|
+
self[109] = getUnitY(handle)
|
|
683
732
|
if not self._owner then
|
|
684
733
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
685
734
|
end
|
|
@@ -747,17 +796,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
747
796
|
end}
|
|
748
797
|
end
|
|
749
798
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
750
|
-
local
|
|
751
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
799
|
+
local ____combatClassification_2 = combatClassification
|
|
800
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
|
|
752
801
|
end
|
|
753
802
|
function Unit.prototype.addClassification(self, classification)
|
|
754
|
-
return
|
|
803
|
+
return UnitAddType(self.handle, classification)
|
|
755
804
|
end
|
|
756
805
|
function Unit.prototype.removeClassification(self, classification)
|
|
757
|
-
return
|
|
806
|
+
return UnitRemoveType(self.handle, classification)
|
|
758
807
|
end
|
|
759
808
|
function Unit.prototype.hasClassification(self, classification)
|
|
760
|
-
return
|
|
809
|
+
return IsUnitType(self.handle, classification)
|
|
761
810
|
end
|
|
762
811
|
function Unit.prototype.isVisibleTo(self, player)
|
|
763
812
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -766,13 +815,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
766
815
|
return isUnitInvisible(self.handle, player.handle)
|
|
767
816
|
end
|
|
768
817
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
769
|
-
local
|
|
818
|
+
local ____temp_3
|
|
770
819
|
if type(x) == "number" then
|
|
771
|
-
|
|
820
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
772
821
|
else
|
|
773
|
-
|
|
822
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
774
823
|
end
|
|
775
|
-
return
|
|
824
|
+
return ____temp_3
|
|
776
825
|
end
|
|
777
826
|
function Unit.prototype.isAllyOf(self, unit)
|
|
778
827
|
return isUnitAlly(
|
|
@@ -790,16 +839,30 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
790
839
|
if type(animation) == "number" then
|
|
791
840
|
setUnitAnimationByIndex(self.handle, animation)
|
|
792
841
|
elseif rarity then
|
|
793
|
-
|
|
842
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
794
843
|
else
|
|
795
844
|
setUnitAnimation(self.handle, animation)
|
|
796
845
|
end
|
|
797
846
|
end
|
|
847
|
+
function Unit.prototype.resetAnimation(self)
|
|
848
|
+
ResetUnitAnimation(self.handle)
|
|
849
|
+
end
|
|
798
850
|
function Unit.prototype.queueAnimation(self, animation)
|
|
799
|
-
|
|
851
|
+
QueueUnitAnimation(self.handle, animation)
|
|
852
|
+
end
|
|
853
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
854
|
+
local firstWeapon = self.firstWeapon
|
|
855
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
856
|
+
return firstWeapon
|
|
857
|
+
end
|
|
858
|
+
local secondWeapon = self.secondWeapon
|
|
859
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
860
|
+
return secondWeapon
|
|
861
|
+
end
|
|
862
|
+
return nil
|
|
800
863
|
end
|
|
801
864
|
function Unit.prototype.delayHealthChecks(self)
|
|
802
|
-
self[
|
|
865
|
+
self[104] = (self[104] or 0) + 1
|
|
803
866
|
Timer:run(delayHealthChecksCallback, self)
|
|
804
867
|
end
|
|
805
868
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -809,21 +872,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
809
872
|
return IsUnitSelected(self.handle, player.handle)
|
|
810
873
|
end
|
|
811
874
|
function Unit.prototype.explode(self)
|
|
812
|
-
|
|
875
|
+
SetUnitExploded(self.handle, true)
|
|
813
876
|
killUnit(self.handle)
|
|
814
877
|
end
|
|
815
878
|
function Unit.prototype.kill(self)
|
|
816
879
|
killUnit(self.handle)
|
|
817
880
|
end
|
|
818
881
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
819
|
-
local
|
|
820
|
-
local
|
|
821
|
-
local
|
|
822
|
-
if
|
|
823
|
-
|
|
882
|
+
local ____ReviveHero_6 = ReviveHero
|
|
883
|
+
local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
|
|
884
|
+
local ____doEffect_4 = doEffect
|
|
885
|
+
if ____doEffect_4 == nil then
|
|
886
|
+
____doEffect_4 = false
|
|
824
887
|
end
|
|
825
|
-
__TS__SparseArrayPush(
|
|
826
|
-
|
|
888
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
889
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
827
890
|
end
|
|
828
891
|
function Unit.prototype.healTarget(self, target, amount)
|
|
829
892
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -866,17 +929,16 @@ function Unit.prototype.itemInSlot(self, slot)
|
|
|
866
929
|
return Item:of(unitItemInSlot(self.handle, slot))
|
|
867
930
|
end
|
|
868
931
|
function Unit.prototype.addAbility(self, abilityId)
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
932
|
+
local ability = UnitAbility:of(
|
|
933
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
934
|
+
abilityId,
|
|
935
|
+
self
|
|
936
|
+
)
|
|
937
|
+
if ability ~= nil then
|
|
875
938
|
local abilities = self.abilities
|
|
876
939
|
abilities[#abilities + 1] = ability
|
|
877
|
-
return ability
|
|
878
940
|
end
|
|
879
|
-
return
|
|
941
|
+
return ability
|
|
880
942
|
end
|
|
881
943
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
882
944
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -890,31 +952,21 @@ end
|
|
|
890
952
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
891
953
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
892
954
|
end
|
|
893
|
-
function Unit.prototype.
|
|
894
|
-
local
|
|
895
|
-
|
|
896
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
897
|
-
return nil
|
|
898
|
-
end
|
|
899
|
-
return UnitAbility:of(
|
|
900
|
-
getUnitAbility(self.handle, abilityId),
|
|
901
|
-
abilityId,
|
|
902
|
-
self
|
|
903
|
-
)
|
|
955
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
956
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
957
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
904
958
|
end
|
|
905
|
-
function Unit.prototype.removeAbility(self,
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
end
|
|
959
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
960
|
+
local abilities = self.abilities
|
|
961
|
+
for i = 1, #abilities do
|
|
962
|
+
if abilities[i].typeId == abilityTypeId then
|
|
963
|
+
local ability = abilities[i]
|
|
964
|
+
tremove(abilities, i)
|
|
965
|
+
ability:destroy()
|
|
966
|
+
return true
|
|
914
967
|
end
|
|
915
|
-
return true
|
|
916
968
|
end
|
|
917
|
-
return
|
|
969
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
918
970
|
end
|
|
919
971
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
920
972
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -928,6 +980,21 @@ end
|
|
|
928
980
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
929
981
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
930
982
|
end
|
|
983
|
+
function Unit.prototype.interruptMovement(self)
|
|
984
|
+
local handle = self.handle
|
|
985
|
+
unitDisableAbility(
|
|
986
|
+
handle,
|
|
987
|
+
fourCC("Amov"),
|
|
988
|
+
true,
|
|
989
|
+
false
|
|
990
|
+
)
|
|
991
|
+
unitDisableAbility(
|
|
992
|
+
handle,
|
|
993
|
+
fourCC("Amov"),
|
|
994
|
+
false,
|
|
995
|
+
false
|
|
996
|
+
)
|
|
997
|
+
end
|
|
931
998
|
function Unit.prototype.interruptAttack(self)
|
|
932
999
|
unitInterruptAttack(self.handle)
|
|
933
1000
|
end
|
|
@@ -1001,18 +1068,44 @@ function Unit.prototype.unpauseEx(self)
|
|
|
1001
1068
|
end
|
|
1002
1069
|
function Unit.prototype.incrementStunCounter(self)
|
|
1003
1070
|
local stunCounter = self[102] or 0
|
|
1004
|
-
if not self[101] or stunCounter >= 0 then
|
|
1071
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
|
|
1005
1072
|
BlzPauseUnitEx(self.handle, true)
|
|
1006
1073
|
end
|
|
1007
1074
|
self[102] = stunCounter + 1
|
|
1008
1075
|
end
|
|
1009
1076
|
function Unit.prototype.decrementStunCounter(self)
|
|
1010
1077
|
local stunCounter = self[102] or 0
|
|
1011
|
-
if not self[101] or stunCounter >= 1 then
|
|
1078
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
|
|
1012
1079
|
BlzPauseUnitEx(self.handle, false)
|
|
1013
1080
|
end
|
|
1014
1081
|
self[102] = stunCounter - 1
|
|
1015
1082
|
end
|
|
1083
|
+
function Unit.prototype.incrementForceStunCounter(self)
|
|
1084
|
+
local forceStunCounter = self[103] or 0
|
|
1085
|
+
if forceStunCounter == 0 then
|
|
1086
|
+
local handle = self.handle
|
|
1087
|
+
if not self[101] then
|
|
1088
|
+
for _ = self[102] or 0, -1 do
|
|
1089
|
+
BlzPauseUnitEx(handle, true)
|
|
1090
|
+
end
|
|
1091
|
+
end
|
|
1092
|
+
BlzPauseUnitEx(handle, true)
|
|
1093
|
+
end
|
|
1094
|
+
self[103] = forceStunCounter + 1
|
|
1095
|
+
end
|
|
1096
|
+
function Unit.prototype.decrementForceStunCounter(self)
|
|
1097
|
+
local forceStunCounter = self[103] or 0
|
|
1098
|
+
if forceStunCounter == 1 then
|
|
1099
|
+
local handle = self.handle
|
|
1100
|
+
if not self[101] then
|
|
1101
|
+
for _ = self[102] or 0, -1 do
|
|
1102
|
+
BlzPauseUnitEx(handle, false)
|
|
1103
|
+
end
|
|
1104
|
+
end
|
|
1105
|
+
BlzPauseUnitEx(handle, false)
|
|
1106
|
+
end
|
|
1107
|
+
self[103] = forceStunCounter - 1
|
|
1108
|
+
end
|
|
1016
1109
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1017
1110
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
1018
1111
|
owner.handle,
|
|
@@ -1201,7 +1294,7 @@ __TS__SetDescriptor(
|
|
|
1201
1294
|
Unit.prototype,
|
|
1202
1295
|
"isIllusion",
|
|
1203
1296
|
{get = function(self)
|
|
1204
|
-
return
|
|
1297
|
+
return IsUnitIllusion(self.handle)
|
|
1205
1298
|
end},
|
|
1206
1299
|
true
|
|
1207
1300
|
)
|
|
@@ -1286,6 +1379,19 @@ __TS__SetDescriptor(
|
|
|
1286
1379
|
},
|
|
1287
1380
|
true
|
|
1288
1381
|
)
|
|
1382
|
+
__TS__SetDescriptor(
|
|
1383
|
+
Unit.prototype,
|
|
1384
|
+
"primaryAttribute",
|
|
1385
|
+
{
|
|
1386
|
+
get = function(self)
|
|
1387
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1388
|
+
end,
|
|
1389
|
+
set = function(self, primaryAttribute)
|
|
1390
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1391
|
+
end
|
|
1392
|
+
},
|
|
1393
|
+
true
|
|
1394
|
+
)
|
|
1289
1395
|
__TS__SetDescriptor(
|
|
1290
1396
|
Unit.prototype,
|
|
1291
1397
|
"strengthBase",
|
|
@@ -1294,7 +1400,7 @@ __TS__SetDescriptor(
|
|
|
1294
1400
|
return getHeroStr(self.handle, false)
|
|
1295
1401
|
end,
|
|
1296
1402
|
set = function(self, strengthBase)
|
|
1297
|
-
|
|
1403
|
+
STRENGTH_UNIT_FIELD:setValue(self, strengthBase)
|
|
1298
1404
|
end
|
|
1299
1405
|
},
|
|
1300
1406
|
true
|
|
@@ -1324,7 +1430,7 @@ __TS__SetDescriptor(
|
|
|
1324
1430
|
return getHeroAgi(self.handle, false)
|
|
1325
1431
|
end,
|
|
1326
1432
|
set = function(self, agilityBase)
|
|
1327
|
-
|
|
1433
|
+
AGILITY_UNIT_FIELD:setValue(self, agilityBase)
|
|
1328
1434
|
end
|
|
1329
1435
|
},
|
|
1330
1436
|
true
|
|
@@ -1354,7 +1460,7 @@ __TS__SetDescriptor(
|
|
|
1354
1460
|
return getHeroInt(self.handle, false)
|
|
1355
1461
|
end,
|
|
1356
1462
|
set = function(self, intelligenceBase)
|
|
1357
|
-
|
|
1463
|
+
INTELLIGENCE_UNIT_FIELD:setValue(self, intelligenceBase)
|
|
1358
1464
|
end
|
|
1359
1465
|
},
|
|
1360
1466
|
true
|
|
@@ -1407,17 +1513,17 @@ __TS__SetDescriptor(
|
|
|
1407
1513
|
"isTeamGlowVisible",
|
|
1408
1514
|
{
|
|
1409
1515
|
get = function(self)
|
|
1410
|
-
return not self[
|
|
1516
|
+
return not self[107]
|
|
1411
1517
|
end,
|
|
1412
1518
|
set = function(self, isTeamGlowVisible)
|
|
1413
|
-
|
|
1414
|
-
local
|
|
1519
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1520
|
+
local ____temp_7
|
|
1415
1521
|
if not isTeamGlowVisible then
|
|
1416
|
-
|
|
1522
|
+
____temp_7 = true
|
|
1417
1523
|
else
|
|
1418
|
-
|
|
1524
|
+
____temp_7 = nil
|
|
1419
1525
|
end
|
|
1420
|
-
self[
|
|
1526
|
+
self[107] = ____temp_7
|
|
1421
1527
|
end
|
|
1422
1528
|
},
|
|
1423
1529
|
true
|
|
@@ -1426,9 +1532,9 @@ __TS__SetDescriptor(
|
|
|
1426
1532
|
Unit.prototype,
|
|
1427
1533
|
"color",
|
|
1428
1534
|
{set = function(self, color)
|
|
1429
|
-
|
|
1430
|
-
if self[
|
|
1431
|
-
|
|
1535
|
+
SetUnitColor(self.handle, color.handle)
|
|
1536
|
+
if self[107] then
|
|
1537
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1432
1538
|
end
|
|
1433
1539
|
end},
|
|
1434
1540
|
true
|
|
@@ -1451,14 +1557,14 @@ __TS__SetDescriptor(
|
|
|
1451
1557
|
"maxHealth",
|
|
1452
1558
|
{
|
|
1453
1559
|
get = function(self)
|
|
1454
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1560
|
+
return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
|
|
1455
1561
|
end,
|
|
1456
1562
|
set = function(self, maxHealth)
|
|
1457
|
-
if maxHealth < 1 and self[
|
|
1458
|
-
self[
|
|
1563
|
+
if maxHealth < 1 and self[104] ~= nil then
|
|
1564
|
+
self[105] = (self[105] or 0) + (1 - maxHealth)
|
|
1459
1565
|
maxHealth = 1
|
|
1460
1566
|
end
|
|
1461
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1567
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
|
|
1462
1568
|
end
|
|
1463
1569
|
},
|
|
1464
1570
|
true
|
|
@@ -1500,10 +1606,10 @@ __TS__SetDescriptor(
|
|
|
1500
1606
|
"health",
|
|
1501
1607
|
{
|
|
1502
1608
|
get = function(self)
|
|
1503
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1609
|
+
return GetWidgetLife(self.handle) - (self[106] or 0)
|
|
1504
1610
|
end,
|
|
1505
1611
|
set = function(self, health)
|
|
1506
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1612
|
+
SetWidgetLife(self.handle, health + (self[106] or 0))
|
|
1507
1613
|
end
|
|
1508
1614
|
},
|
|
1509
1615
|
true
|
|
@@ -1579,25 +1685,12 @@ __TS__SetDescriptor(
|
|
|
1579
1685
|
},
|
|
1580
1686
|
true
|
|
1581
1687
|
)
|
|
1582
|
-
__TS__SetDescriptor(
|
|
1583
|
-
Unit.prototype,
|
|
1584
|
-
"flyHeight",
|
|
1585
|
-
{
|
|
1586
|
-
get = function(self)
|
|
1587
|
-
return getUnitFlyHeight(self.handle)
|
|
1588
|
-
end,
|
|
1589
|
-
set = function(self, v)
|
|
1590
|
-
SetUnitFlyHeight(self.handle, v, 100000)
|
|
1591
|
-
end
|
|
1592
|
-
},
|
|
1593
|
-
true
|
|
1594
|
-
)
|
|
1595
1688
|
__TS__SetDescriptor(
|
|
1596
1689
|
Unit.prototype,
|
|
1597
1690
|
"x",
|
|
1598
1691
|
{
|
|
1599
1692
|
get = function(self)
|
|
1600
|
-
return getUnitX(self.handle)
|
|
1693
|
+
return self[108] or getUnitX(self.handle)
|
|
1601
1694
|
end,
|
|
1602
1695
|
set = function(self, v)
|
|
1603
1696
|
SetUnitX(self.handle, v)
|
|
@@ -1610,7 +1703,7 @@ __TS__SetDescriptor(
|
|
|
1610
1703
|
"y",
|
|
1611
1704
|
{
|
|
1612
1705
|
get = function(self)
|
|
1613
|
-
return getUnitY(self.handle)
|
|
1706
|
+
return self[109] or getUnitY(self.handle)
|
|
1614
1707
|
end,
|
|
1615
1708
|
set = function(self, v)
|
|
1616
1709
|
SetUnitY(self.handle, v)
|
|
@@ -1696,10 +1789,10 @@ __TS__SetDescriptor(
|
|
|
1696
1789
|
"gold",
|
|
1697
1790
|
{
|
|
1698
1791
|
get = function(self)
|
|
1699
|
-
return
|
|
1792
|
+
return GetResourceAmount(self.handle)
|
|
1700
1793
|
end,
|
|
1701
1794
|
set = function(self, gold)
|
|
1702
|
-
|
|
1795
|
+
SetResourceAmount(self.handle, gold)
|
|
1703
1796
|
end
|
|
1704
1797
|
},
|
|
1705
1798
|
true
|
|
@@ -1715,14 +1808,18 @@ __TS__SetDescriptor(
|
|
|
1715
1808
|
local handle = self.handle
|
|
1716
1809
|
if isPaused and not IsUnitPaused(handle) then
|
|
1717
1810
|
self[101] = true
|
|
1718
|
-
|
|
1719
|
-
|
|
1811
|
+
if (self[103] or 0) <= 0 then
|
|
1812
|
+
for _ = self[102] or 0, -1 do
|
|
1813
|
+
BlzPauseUnitEx(handle, true)
|
|
1814
|
+
end
|
|
1720
1815
|
end
|
|
1721
1816
|
PauseUnit(handle, true)
|
|
1722
1817
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1723
1818
|
PauseUnit(handle, false)
|
|
1724
|
-
|
|
1725
|
-
|
|
1819
|
+
if (self[103] or 0) <= 0 then
|
|
1820
|
+
for _ = self[102] or 0, -1 do
|
|
1821
|
+
BlzPauseUnitEx(handle, false)
|
|
1822
|
+
end
|
|
1726
1823
|
end
|
|
1727
1824
|
self[101] = nil
|
|
1728
1825
|
end
|
|
@@ -1780,20 +1877,6 @@ __TS__SetDescriptor(
|
|
|
1780
1877
|
},
|
|
1781
1878
|
true
|
|
1782
1879
|
)
|
|
1783
|
-
__TS__SetDescriptor(
|
|
1784
|
-
Unit.prototype,
|
|
1785
|
-
"scale",
|
|
1786
|
-
{
|
|
1787
|
-
get = function(self)
|
|
1788
|
-
return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
|
|
1789
|
-
end,
|
|
1790
|
-
set = function(self, v)
|
|
1791
|
-
setUnitScale(self.handle, v, v, v)
|
|
1792
|
-
setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
|
|
1793
|
-
end
|
|
1794
|
-
},
|
|
1795
|
-
true
|
|
1796
|
-
)
|
|
1797
1880
|
__TS__SetDescriptor(
|
|
1798
1881
|
Unit.prototype,
|
|
1799
1882
|
"timeScale",
|
|
@@ -1827,6 +1910,19 @@ __TS__SetDescriptor(
|
|
|
1827
1910
|
end},
|
|
1828
1911
|
true
|
|
1829
1912
|
)
|
|
1913
|
+
__TS__SetDescriptor(
|
|
1914
|
+
Unit.prototype,
|
|
1915
|
+
"movementType",
|
|
1916
|
+
{
|
|
1917
|
+
get = function(self)
|
|
1918
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1919
|
+
end,
|
|
1920
|
+
set = function(self, movementType)
|
|
1921
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1922
|
+
end
|
|
1923
|
+
},
|
|
1924
|
+
true
|
|
1925
|
+
)
|
|
1830
1926
|
__TS__SetDescriptor(
|
|
1831
1927
|
Unit.prototype,
|
|
1832
1928
|
"pathing",
|
|
@@ -2008,6 +2104,14 @@ __TS__SetDescriptor(
|
|
|
2008
2104
|
end},
|
|
2009
2105
|
true
|
|
2010
2106
|
)
|
|
2107
|
+
__TS__SetDescriptor(
|
|
2108
|
+
Unit.prototype,
|
|
2109
|
+
"targetAcquiredEvent",
|
|
2110
|
+
{get = function(self)
|
|
2111
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2112
|
+
end},
|
|
2113
|
+
true
|
|
2114
|
+
)
|
|
2011
2115
|
__TS__SetDescriptor(
|
|
2012
2116
|
Unit.prototype,
|
|
2013
2117
|
"onSelect",
|
|
@@ -2068,6 +2172,11 @@ __TS__SetDescriptor(
|
|
|
2068
2172
|
end},
|
|
2069
2173
|
true
|
|
2070
2174
|
)
|
|
2175
|
+
Unit.levelChangedEvent = __TS__New(
|
|
2176
|
+
____exports.UnitTriggerEvent,
|
|
2177
|
+
EVENT_PLAYER_HERO_LEVEL,
|
|
2178
|
+
function() return ____exports.Unit:of(getTriggerUnit()) end
|
|
2179
|
+
)
|
|
2071
2180
|
Unit.deathEvent = __TS__New(
|
|
2072
2181
|
____exports.UnitTriggerEvent,
|
|
2073
2182
|
EVENT_PLAYER_UNIT_DEATH,
|
|
@@ -2143,25 +2252,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2143
2252
|
InitializingEvent,
|
|
2144
2253
|
function(event)
|
|
2145
2254
|
local function listener(unit, id)
|
|
2146
|
-
local
|
|
2255
|
+
local ____GetSpellTargetUnit_result_10
|
|
2147
2256
|
if GetSpellTargetUnit() then
|
|
2148
|
-
|
|
2257
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2149
2258
|
else
|
|
2150
|
-
local
|
|
2259
|
+
local ____GetSpellTargetItem_result_9
|
|
2151
2260
|
if GetSpellTargetItem() then
|
|
2152
|
-
|
|
2261
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2153
2262
|
else
|
|
2154
|
-
local
|
|
2263
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2155
2264
|
if GetSpellTargetDestructable() then
|
|
2156
|
-
|
|
2265
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2157
2266
|
else
|
|
2158
|
-
|
|
2267
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2159
2268
|
end
|
|
2160
|
-
|
|
2269
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2161
2270
|
end
|
|
2162
|
-
|
|
2271
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2163
2272
|
end
|
|
2164
|
-
local target =
|
|
2273
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2165
2274
|
if target then
|
|
2166
2275
|
invoke(event, unit, id, target)
|
|
2167
2276
|
end
|
|
@@ -2369,38 +2478,57 @@ Unit.onDamaging = (function()
|
|
|
2369
2478
|
if source and source.typeId == dummyUnitId then
|
|
2370
2479
|
source = nil
|
|
2371
2480
|
end
|
|
2372
|
-
local target = BlzGetEventDamageTarget()
|
|
2481
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2482
|
+
local metadata = damageMetadataByTarget[target]
|
|
2483
|
+
damageMetadataByTarget[target] = nil
|
|
2373
2484
|
local data = {
|
|
2374
2485
|
amount = GetEventDamage(),
|
|
2375
|
-
attackType = BlzGetEventAttackType(),
|
|
2486
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2376
2487
|
damageType = BlzGetEventDamageType(),
|
|
2377
2488
|
weaponType = BlzGetEventWeaponType(),
|
|
2378
|
-
|
|
2489
|
+
metadata = metadata,
|
|
2490
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2491
|
+
originalAmount = GetEventDamage(),
|
|
2492
|
+
originalMetadata = metadata,
|
|
2493
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2379
2494
|
}
|
|
2380
2495
|
if data.isAttack and source then
|
|
2381
|
-
|
|
2382
|
-
if weapon == -1 then
|
|
2383
|
-
local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
|
|
2384
|
-
weapon = 0
|
|
2385
|
-
end
|
|
2386
|
-
data.weapon = assert(source.weapons[weapon + 1])
|
|
2496
|
+
data.weapon = source:chooseWeapon(target)
|
|
2387
2497
|
end
|
|
2388
2498
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2389
2499
|
invoke(
|
|
2390
2500
|
event,
|
|
2391
2501
|
source,
|
|
2392
|
-
|
|
2502
|
+
target,
|
|
2393
2503
|
setmetatable(
|
|
2394
2504
|
{},
|
|
2395
2505
|
{
|
|
2396
2506
|
__index = data,
|
|
2397
2507
|
__newindex = function(self, key, value)
|
|
2398
|
-
damageSetters[key]
|
|
2508
|
+
local damageSetter = damageSetters[key]
|
|
2509
|
+
if damageSetter ~= nil then
|
|
2510
|
+
damageSetter(value)
|
|
2511
|
+
end
|
|
2399
2512
|
data[key] = value
|
|
2400
2513
|
end
|
|
2401
2514
|
}
|
|
2402
2515
|
)
|
|
2403
2516
|
)
|
|
2517
|
+
if data[0] and source then
|
|
2518
|
+
local sourceOwner = source.owner.handle
|
|
2519
|
+
data[1] = sourceOwner
|
|
2520
|
+
local targetOwner = target.owner.handle
|
|
2521
|
+
data[2] = targetOwner
|
|
2522
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2523
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2524
|
+
data[3] = true
|
|
2525
|
+
end
|
|
2526
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2527
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2528
|
+
data[4] = true
|
|
2529
|
+
end
|
|
2530
|
+
end
|
|
2531
|
+
damagingEventByTarget[target] = data
|
|
2404
2532
|
return
|
|
2405
2533
|
end
|
|
2406
2534
|
BlzSetEventDamage(0)
|
|
@@ -2408,7 +2536,7 @@ Unit.onDamaging = (function()
|
|
|
2408
2536
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2409
2537
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2410
2538
|
local sourceOwner = source.owner.handle
|
|
2411
|
-
local targetOwner =
|
|
2539
|
+
local targetOwner = target.owner.handle
|
|
2412
2540
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2413
2541
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2414
2542
|
Timer:run(function()
|
|
@@ -2424,23 +2552,19 @@ Unit.onDamaging = (function()
|
|
|
2424
2552
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2425
2553
|
local condition = ____value[1]
|
|
2426
2554
|
local action = ____value[2]
|
|
2427
|
-
if condition(
|
|
2428
|
-
source,
|
|
2429
|
-
____exports.Unit:of(target),
|
|
2430
|
-
data
|
|
2431
|
-
) then
|
|
2555
|
+
if condition(source, target, data) then
|
|
2432
2556
|
action(
|
|
2433
2557
|
source,
|
|
2434
|
-
|
|
2558
|
+
target,
|
|
2435
2559
|
setmetatable(
|
|
2436
2560
|
{fire = function()
|
|
2437
2561
|
UnitDamageTarget(
|
|
2438
2562
|
source.handle,
|
|
2439
|
-
target,
|
|
2563
|
+
target.handle,
|
|
2440
2564
|
data.amount,
|
|
2441
2565
|
true,
|
|
2442
2566
|
true,
|
|
2443
|
-
data.attackType,
|
|
2567
|
+
attackTypeToNative(data.attackType),
|
|
2444
2568
|
data.damageType,
|
|
2445
2569
|
data.weaponType
|
|
2446
2570
|
)
|
|
@@ -2467,30 +2591,54 @@ Unit.onDamage = __TS__New(
|
|
|
2467
2591
|
if source and source.typeId == dummyUnitId then
|
|
2468
2592
|
source = nil
|
|
2469
2593
|
end
|
|
2594
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2595
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2596
|
+
damagingEventByTarget[target] = nil
|
|
2470
2597
|
local data = {
|
|
2471
2598
|
amount = GetEventDamage(),
|
|
2472
|
-
attackType = BlzGetEventAttackType(),
|
|
2599
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2473
2600
|
damageType = BlzGetEventDamageType(),
|
|
2474
2601
|
weaponType = BlzGetEventWeaponType(),
|
|
2602
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2475
2603
|
isAttack = BlzGetEventIsAttack(),
|
|
2476
|
-
originalAmount = GetEventDamage(),
|
|
2604
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2605
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2477
2606
|
preventDeath = damageEventPreventDeath
|
|
2478
2607
|
}
|
|
2608
|
+
if damagingEvent then
|
|
2609
|
+
for key, value in pairs(damagingEvent) do
|
|
2610
|
+
if isAttribute(key) then
|
|
2611
|
+
data[key] = value
|
|
2612
|
+
end
|
|
2613
|
+
end
|
|
2614
|
+
local sourceOwner = damagingEvent[1]
|
|
2615
|
+
if sourceOwner then
|
|
2616
|
+
local targetOwner = damagingEvent[2]
|
|
2617
|
+
if damagingEvent[3] then
|
|
2618
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2619
|
+
end
|
|
2620
|
+
if damagingEvent[4] then
|
|
2621
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2622
|
+
end
|
|
2623
|
+
end
|
|
2624
|
+
end
|
|
2479
2625
|
local evData = setmetatable(
|
|
2480
2626
|
{},
|
|
2481
2627
|
{
|
|
2482
2628
|
__index = data,
|
|
2483
2629
|
__newindex = function(self, key, value)
|
|
2484
|
-
damageSetters[key]
|
|
2630
|
+
local damageSetter = damageSetters[key]
|
|
2631
|
+
if damageSetter ~= nil then
|
|
2632
|
+
damageSetter(value)
|
|
2633
|
+
end
|
|
2485
2634
|
data[key] = value
|
|
2486
2635
|
end
|
|
2487
2636
|
}
|
|
2488
2637
|
)
|
|
2489
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2490
2638
|
invoke(event, source, target, evData)
|
|
2491
2639
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2492
2640
|
local bonusHealth = math.ceil(evData.amount)
|
|
2493
|
-
target[
|
|
2641
|
+
target[106] = (target[106] or 0) + bonusHealth
|
|
2494
2642
|
BlzSetUnitMaxHP(
|
|
2495
2643
|
target.handle,
|
|
2496
2644
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2504,7 +2652,7 @@ Unit.onDamage = __TS__New(
|
|
|
2504
2652
|
evData[0],
|
|
2505
2653
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2506
2654
|
)
|
|
2507
|
-
target[
|
|
2655
|
+
target[106] = (target[106] or 0) - bonusHealth
|
|
2508
2656
|
SetWidgetLife(
|
|
2509
2657
|
target.handle,
|
|
2510
2658
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2540,10 +2688,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2540
2688
|
____exports.UnitTriggerEvent,
|
|
2541
2689
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2542
2690
|
function()
|
|
2543
|
-
local
|
|
2544
|
-
local
|
|
2545
|
-
if getUnitTypeId(
|
|
2546
|
-
|
|
2691
|
+
local unitHandle = getTriggerUnit()
|
|
2692
|
+
local itemHandle = getManipulatedItem()
|
|
2693
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2694
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2695
|
+
local item = Item:of(itemHandle)
|
|
2696
|
+
if item.owner ~= unit then
|
|
2697
|
+
return unit, item
|
|
2698
|
+
end
|
|
2547
2699
|
end
|
|
2548
2700
|
return IgnoreEvent
|
|
2549
2701
|
end
|
|
@@ -2563,7 +2715,22 @@ Unit.itemUsedEvent = __TS__New(
|
|
|
2563
2715
|
Unit.itemStackedEvent = __TS__New(
|
|
2564
2716
|
____exports.UnitTriggerEvent,
|
|
2565
2717
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2566
|
-
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(
|
|
2718
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2719
|
+
)
|
|
2720
|
+
__TS__ObjectDefineProperty(
|
|
2721
|
+
Unit,
|
|
2722
|
+
"itemChargesChangedEvent",
|
|
2723
|
+
{get = function(self)
|
|
2724
|
+
local event = __TS__New(Event)
|
|
2725
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2726
|
+
local unit = item.owner
|
|
2727
|
+
if unit ~= nil then
|
|
2728
|
+
invoke(event, unit, item)
|
|
2729
|
+
end
|
|
2730
|
+
end)
|
|
2731
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2732
|
+
return event
|
|
2733
|
+
end}
|
|
2567
2734
|
)
|
|
2568
2735
|
__TS__ObjectDefineProperty(
|
|
2569
2736
|
Unit,
|
|
@@ -2635,6 +2802,10 @@ __TS__ObjectDefineProperty(
|
|
|
2635
2802
|
rawset(self, "destroyEvent", destroyEvent)
|
|
2636
2803
|
return destroyEvent
|
|
2637
2804
|
end}
|
|
2805
|
+
)
|
|
2806
|
+
Unit.synchronize = synchronizer(
|
|
2807
|
+
function(unit) return unit.syncId end,
|
|
2808
|
+
function(syncId) return unitBySyncId[syncId] end
|
|
2638
2809
|
);
|
|
2639
2810
|
(function(self)
|
|
2640
2811
|
local leaveAbilityIds = postcompile(function()
|