warscript 0.0.1-dev.a21905e → 0.0.1-dev.a319619
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 +5 -0
- package/attributes.lua +8 -1
- package/config.d.ts +5 -0
- package/config.lua +10 -0
- package/core/types/effect.d.ts +14 -6
- package/core/types/effect.lua +131 -35
- package/core/types/frame.d.ts +4 -0
- package/core/types/frame.lua +81 -12
- package/core/types/player.lua +3 -1
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +79 -5
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/timer.d.ts +8 -8
- package/core/types/timer.lua +25 -23
- package/core/util.d.ts +1 -1
- package/core/util.lua +18 -1
- package/decl/native.d.ts +844 -788
- package/engine/behavior.d.ts +4 -2
- package/engine/behavior.lua +59 -33
- package/engine/behaviour/ability/always-enabled.d.ts +7 -0
- package/engine/behaviour/ability/always-enabled.lua +31 -0
- package/engine/behaviour/ability/apply-buff.d.ts +5 -0
- package/engine/behaviour/ability/apply-buff.lua +32 -0
- 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 +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +43 -0
- package/engine/behaviour/ability/instant-impact.d.ts +2 -2
- package/engine/behaviour/ability/instant-impact.lua +4 -19
- package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
- package/engine/behaviour/ability/on-command-impact.lua +25 -0
- package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
- package/engine/behaviour/ability/remove-buffs.lua +28 -0
- package/engine/behaviour/ability/restore-mana.d.ts +1 -1
- package/engine/behaviour/ability/restore-mana.lua +6 -6
- package/engine/behaviour/ability.d.ts +20 -4
- package/engine/behaviour/ability.lua +111 -47
- package/engine/behaviour/unit/stun-immunity.d.ts +5 -3
- package/engine/behaviour/unit/stun-immunity.lua +43 -27
- package/engine/behaviour/unit.d.ts +28 -0
- package/engine/behaviour/unit.lua +163 -4
- package/engine/buff.d.ts +63 -42
- package/engine/buff.lua +318 -234
- package/engine/internal/ability.d.ts +20 -13
- package/engine/internal/ability.lua +103 -76
- package/engine/internal/item/ability.lua +162 -4
- package/engine/internal/item.d.ts +7 -4
- package/engine/internal/item.lua +131 -28
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
- package/engine/internal/misc/ability-disable-counter.lua +13 -0
- 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/auto-attack-speed-increase.d.ts +1 -1
- package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
- package/engine/internal/object-data/evasion-probability.d.ts +2 -0
- package/engine/internal/object-data/evasion-probability.lua +16 -0
- package/engine/internal/unit/ability.d.ts +45 -1
- package/engine/internal/unit/ability.lua +98 -14
- package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
- package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot.lua +52 -0
- 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 +17 -0
- package/engine/internal/unit/ignore-events-items.d.ts +2 -0
- package/engine/internal/unit/ignore-events-items.lua +5 -0
- package/engine/internal/unit/item.d.ts +2 -0
- package/engine/internal/unit/item.lua +22 -7
- package/engine/internal/unit/main-selected.d.ts +13 -0
- package/engine/internal/unit/main-selected.lua +51 -0
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit+ability.lua +9 -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 +33 -7
- package/engine/internal/unit.d.ts +50 -14
- package/engine/internal/unit.lua +361 -141
- package/engine/internal/utility.lua +12 -0
- package/engine/lightning.d.ts +12 -5
- package/engine/lightning.lua +48 -14
- package/engine/local-client.d.ts +7 -2
- package/engine/local-client.lua +82 -0
- package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
- package/engine/object-data/auxiliary/animation-name.lua +16 -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/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/sound-preset-name.d.ts +5 -1
- package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
- 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/blank-configurable.lua +12 -1
- 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/disease-cloud.lua +2 -2
- package/engine/object-data/entry/ability-type/engineering-upgrade.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/feral-spirit.lua +2 -2
- 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/phoenix-morph.lua +4 -4
- 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/summon-quilbeast.lua +2 -2
- package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
- 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 +19 -17
- package/engine/object-data/entry/ability-type.lua +90 -36
- package/engine/object-data/entry/buff-type/applicable.lua +18 -37
- package/engine/object-data/entry/buff-type.d.ts +6 -12
- package/engine/object-data/entry/buff-type.lua +13 -29
- package/engine/object-data/entry/destructible-type.d.ts +1 -1
- package/engine/object-data/entry/item-type.d.ts +15 -1
- package/engine/object-data/entry/item-type.lua +93 -2
- package/engine/object-data/entry/lightning-type.d.ts +1 -1
- package/engine/object-data/entry/sound-preset.d.ts +33 -0
- package/engine/object-data/entry/sound-preset.lua +140 -0
- package/engine/object-data/entry/unit-type.d.ts +21 -5
- package/engine/object-data/entry/unit-type.lua +214 -93
- package/engine/object-data/entry/upgrade.d.ts +1 -1
- package/engine/object-data/entry/upgrade.lua +4 -4
- package/engine/object-data/entry.d.ts +16 -14
- package/engine/object-data/entry.lua +60 -32
- package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
- package/engine/object-field/ability.d.ts +10 -4
- package/engine/object-field/ability.lua +4 -1
- package/engine/object-field/unit.d.ts +57 -3
- package/engine/object-field/unit.lua +207 -7
- package/engine/object-field.d.ts +17 -6
- package/engine/object-field.lua +187 -89
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- package/engine/standard/entries/sound-preset.d.ts +10 -0
- package/engine/standard/entries/sound-preset.lua +10 -0
- package/engine/standard/fields/ability.d.ts +2 -0
- package/engine/standard/fields/ability.lua +2 -0
- package/engine/standard/fields/unit.d.ts +4 -0
- package/engine/standard/fields/unit.lua +7 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +249 -10
- package/engine/unit.d.ts +3 -0
- package/engine/unit.lua +3 -0
- package/index.d.ts +1 -0
- package/index.lua +1 -0
- package/objutil/buff.lua +1 -2
- package/objutil/unit.lua +8 -0
- package/package.json +2 -2
- package/patch-lua.d.ts +0 -0
- package/patch-lua.lua +10 -0
- package/utility/arrays.d.ts +9 -1
- package/utility/arrays.lua +37 -3
- package/utility/functions.d.ts +8 -0
- package/utility/functions.lua +13 -0
- package/utility/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +3 -0
- package/utility/lua-maps.d.ts +4 -0
- package/utility/lua-maps.lua +20 -0
- package/utility/lua-sets.d.ts +2 -0
- package/utility/lua-sets.lua +7 -0
- package/utility/reflection.lua +11 -7
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
package/engine/internal/unit.lua
CHANGED
|
@@ -51,12 +51,21 @@ local ____arrays = require("utility.arrays")
|
|
|
51
51
|
local forEach = ____arrays.forEach
|
|
52
52
|
local ____math = require("math")
|
|
53
53
|
local min = ____math.min
|
|
54
|
+
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
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
|
|
54
65
|
local match = string.match
|
|
55
66
|
local ____tostring = _G.tostring
|
|
56
67
|
local setUnitAnimation = SetUnitAnimation
|
|
57
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
58
68
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
59
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
60
69
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
61
70
|
local getUnitRealField = BlzGetUnitRealField
|
|
62
71
|
local getHeroStr = GetHeroStr
|
|
@@ -75,9 +84,9 @@ local setUnitScale = SetUnitScale
|
|
|
75
84
|
local setUnitPosition = SetUnitPosition
|
|
76
85
|
local setUnitTimeScale = SetUnitTimeScale
|
|
77
86
|
local getHandleId = GetHandleId
|
|
87
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
78
88
|
local createUnit = CreateUnit
|
|
79
89
|
local killUnit = KillUnit
|
|
80
|
-
local setUnitExploded = SetUnitExploded
|
|
81
90
|
local removeUnit = RemoveUnit
|
|
82
91
|
local getUnitTypeId = GetUnitTypeId
|
|
83
92
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -93,8 +102,6 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
93
102
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
94
103
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
95
104
|
local isUnitInRange = IsUnitInRange
|
|
96
|
-
local setResourceAmount = SetResourceAmount
|
|
97
|
-
local getResourceAmount = GetResourceAmount
|
|
98
105
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
99
106
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
100
107
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
@@ -118,15 +125,9 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
118
125
|
local getIssuedOrderId = GetIssuedOrderId
|
|
119
126
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
120
127
|
local unitAlive = UnitAlive
|
|
121
|
-
local unitAddType = UnitAddType
|
|
122
|
-
local unitRemoveType = UnitRemoveType
|
|
123
|
-
local isUnitIllusion = IsUnitIllusion
|
|
124
|
-
local isUnitType = IsUnitType
|
|
125
128
|
local isUnitAlly = IsUnitAlly
|
|
126
129
|
local isUnitEnemy = IsUnitEnemy
|
|
127
130
|
local getOwningPlayer = GetOwningPlayer
|
|
128
|
-
local setUnitColor = SetUnitColor
|
|
129
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
130
131
|
____exports.UnitClassification = {}
|
|
131
132
|
local UnitClassification = ____exports.UnitClassification
|
|
132
133
|
do
|
|
@@ -136,6 +137,7 @@ do
|
|
|
136
137
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
137
138
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
138
139
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
140
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
139
141
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
140
142
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
141
143
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -343,6 +345,9 @@ local function dispatchAbility(event)
|
|
|
343
345
|
}
|
|
344
346
|
)
|
|
345
347
|
end
|
|
348
|
+
local function damagingEventPreventRetaliation(self)
|
|
349
|
+
self[0] = true
|
|
350
|
+
end
|
|
346
351
|
local function damageEventPreventDeath(self, callback, ...)
|
|
347
352
|
if self[0] ~= nil then
|
|
348
353
|
return
|
|
@@ -354,7 +359,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
354
359
|
rawset(self, 1 + i, (select(i, ...)))
|
|
355
360
|
end
|
|
356
361
|
end
|
|
357
|
-
local damageSetters = {
|
|
362
|
+
local damageSetters = {
|
|
363
|
+
amount = BlzSetEventDamage,
|
|
364
|
+
attackType = function(attackType)
|
|
365
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
366
|
+
end,
|
|
367
|
+
damageType = BlzSetEventDamageType,
|
|
368
|
+
weaponType = BlzSetEventWeaponType
|
|
369
|
+
}
|
|
358
370
|
local jlimitopByOperator = {
|
|
359
371
|
[0] = LESS_THAN_OR_EQUAL,
|
|
360
372
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -432,6 +444,19 @@ __TS__SetDescriptor(
|
|
|
432
444
|
},
|
|
433
445
|
true
|
|
434
446
|
)
|
|
447
|
+
__TS__SetDescriptor(
|
|
448
|
+
UnitWeapon.prototype,
|
|
449
|
+
"allowedTargetCombatClassifications",
|
|
450
|
+
{
|
|
451
|
+
get = function(self)
|
|
452
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
453
|
+
end,
|
|
454
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
455
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
456
|
+
end
|
|
457
|
+
},
|
|
458
|
+
true
|
|
459
|
+
)
|
|
435
460
|
__TS__SetDescriptor(
|
|
436
461
|
UnitWeapon.prototype,
|
|
437
462
|
"damageBase",
|
|
@@ -562,17 +587,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
562
587
|
____exports.Unit:of(unit)
|
|
563
588
|
)
|
|
564
589
|
end
|
|
565
|
-
if not unitAddAbility(unit, abilityId) then
|
|
566
|
-
if getUnitAbility(unit, abilityId) == ability then
|
|
567
|
-
return UnitAbility:of(
|
|
568
|
-
ability,
|
|
569
|
-
abilityId,
|
|
570
|
-
____exports.Unit:of(unit)
|
|
571
|
-
)
|
|
572
|
-
end
|
|
573
|
-
else
|
|
574
|
-
unitRemoveAbility(unit, abilityId)
|
|
575
|
-
end
|
|
576
590
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
577
591
|
local item = unitItemInSlot(unit, i)
|
|
578
592
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -630,15 +644,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
630
644
|
dummies[player] = dummy
|
|
631
645
|
end
|
|
632
646
|
local function delayHealthChecksCallback(unit)
|
|
633
|
-
local counter = (unit[
|
|
647
|
+
local counter = (unit[103] or 0) - 1
|
|
634
648
|
if counter ~= 0 then
|
|
635
|
-
unit[
|
|
649
|
+
unit[103] = counter
|
|
636
650
|
return
|
|
637
651
|
end
|
|
638
|
-
unit[
|
|
639
|
-
local healthBonus = unit[
|
|
652
|
+
unit[103] = nil
|
|
653
|
+
local healthBonus = unit[104]
|
|
640
654
|
if healthBonus ~= nil then
|
|
641
|
-
unit[
|
|
655
|
+
unit[104] = nil
|
|
642
656
|
local handle = unit.handle
|
|
643
657
|
BlzSetUnitMaxHP(
|
|
644
658
|
handle,
|
|
@@ -646,12 +660,27 @@ local function delayHealthChecksCallback(unit)
|
|
|
646
660
|
)
|
|
647
661
|
end
|
|
648
662
|
end
|
|
663
|
+
local nextSyncId = 1
|
|
664
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
665
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
666
|
+
local function addAbility(unit, abilityTypeId)
|
|
667
|
+
local ____unitAddAbility_result_0
|
|
668
|
+
if unitAddAbility(unit, abilityTypeId) then
|
|
669
|
+
____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
|
|
670
|
+
else
|
|
671
|
+
____unitAddAbility_result_0 = nil
|
|
672
|
+
end
|
|
673
|
+
return ____unitAddAbility_result_0
|
|
674
|
+
end
|
|
649
675
|
____exports.Unit = __TS__Class()
|
|
650
676
|
local Unit = ____exports.Unit
|
|
651
677
|
Unit.name = "Unit"
|
|
652
678
|
__TS__ClassExtends(Unit, Handle)
|
|
653
679
|
function Unit.prototype.____constructor(self, handle)
|
|
654
680
|
Handle.prototype.____constructor(self, handle)
|
|
681
|
+
local ____nextSyncId_1 = nextSyncId
|
|
682
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
683
|
+
self.syncId = ____nextSyncId_1
|
|
655
684
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
656
685
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
657
686
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -664,6 +693,7 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
664
693
|
fourCC("Amrf")
|
|
665
694
|
))
|
|
666
695
|
end
|
|
696
|
+
unitBySyncId[self.syncId] = self
|
|
667
697
|
local ____ = self.abilities
|
|
668
698
|
end
|
|
669
699
|
function Unit.prototype.getEvent(self, event, collector)
|
|
@@ -682,6 +712,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
682
712
|
end
|
|
683
713
|
function Unit.prototype.onDestroy(self)
|
|
684
714
|
local handle = self.handle
|
|
715
|
+
self[107] = getUnitX(handle)
|
|
716
|
+
self[108] = getUnitY(handle)
|
|
685
717
|
if not self._owner then
|
|
686
718
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
687
719
|
end
|
|
@@ -749,17 +781,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
749
781
|
end}
|
|
750
782
|
end
|
|
751
783
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
752
|
-
local
|
|
753
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
784
|
+
local ____combatClassification_2 = combatClassification
|
|
785
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
|
|
754
786
|
end
|
|
755
787
|
function Unit.prototype.addClassification(self, classification)
|
|
756
|
-
return
|
|
788
|
+
return UnitAddType(self.handle, classification)
|
|
757
789
|
end
|
|
758
790
|
function Unit.prototype.removeClassification(self, classification)
|
|
759
|
-
return
|
|
791
|
+
return UnitRemoveType(self.handle, classification)
|
|
760
792
|
end
|
|
761
793
|
function Unit.prototype.hasClassification(self, classification)
|
|
762
|
-
return
|
|
794
|
+
return IsUnitType(self.handle, classification)
|
|
763
795
|
end
|
|
764
796
|
function Unit.prototype.isVisibleTo(self, player)
|
|
765
797
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -768,13 +800,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
768
800
|
return isUnitInvisible(self.handle, player.handle)
|
|
769
801
|
end
|
|
770
802
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
771
|
-
local
|
|
803
|
+
local ____temp_3
|
|
772
804
|
if type(x) == "number" then
|
|
773
|
-
|
|
805
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
774
806
|
else
|
|
775
|
-
|
|
807
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
776
808
|
end
|
|
777
|
-
return
|
|
809
|
+
return ____temp_3
|
|
778
810
|
end
|
|
779
811
|
function Unit.prototype.isAllyOf(self, unit)
|
|
780
812
|
return isUnitAlly(
|
|
@@ -792,16 +824,28 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
792
824
|
if type(animation) == "number" then
|
|
793
825
|
setUnitAnimationByIndex(self.handle, animation)
|
|
794
826
|
elseif rarity then
|
|
795
|
-
|
|
827
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
796
828
|
else
|
|
797
829
|
setUnitAnimation(self.handle, animation)
|
|
798
830
|
end
|
|
799
831
|
end
|
|
832
|
+
function Unit.prototype.resetAnimation(self)
|
|
833
|
+
ResetUnitAnimation(self.handle)
|
|
834
|
+
end
|
|
800
835
|
function Unit.prototype.queueAnimation(self, animation)
|
|
801
|
-
|
|
836
|
+
QueueUnitAnimation(self.handle, animation)
|
|
837
|
+
end
|
|
838
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
839
|
+
if target:isAllowedTarget(self, self.firstWeapon.allowedTargetCombatClassifications) then
|
|
840
|
+
return self.firstWeapon
|
|
841
|
+
end
|
|
842
|
+
if target:isAllowedTarget(target, self.secondWeapon.allowedTargetCombatClassifications) then
|
|
843
|
+
return self.secondWeapon
|
|
844
|
+
end
|
|
845
|
+
return nil
|
|
802
846
|
end
|
|
803
847
|
function Unit.prototype.delayHealthChecks(self)
|
|
804
|
-
self[
|
|
848
|
+
self[103] = (self[103] or 0) + 1
|
|
805
849
|
Timer:run(delayHealthChecksCallback, self)
|
|
806
850
|
end
|
|
807
851
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -811,21 +855,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
811
855
|
return IsUnitSelected(self.handle, player.handle)
|
|
812
856
|
end
|
|
813
857
|
function Unit.prototype.explode(self)
|
|
814
|
-
|
|
858
|
+
SetUnitExploded(self.handle, true)
|
|
815
859
|
killUnit(self.handle)
|
|
816
860
|
end
|
|
817
861
|
function Unit.prototype.kill(self)
|
|
818
862
|
killUnit(self.handle)
|
|
819
863
|
end
|
|
820
864
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
821
|
-
local
|
|
822
|
-
local
|
|
823
|
-
local
|
|
824
|
-
if
|
|
825
|
-
|
|
865
|
+
local ____ReviveHero_6 = ReviveHero
|
|
866
|
+
local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
|
|
867
|
+
local ____doEffect_4 = doEffect
|
|
868
|
+
if ____doEffect_4 == nil then
|
|
869
|
+
____doEffect_4 = false
|
|
826
870
|
end
|
|
827
|
-
__TS__SparseArrayPush(
|
|
828
|
-
|
|
871
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
872
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
829
873
|
end
|
|
830
874
|
function Unit.prototype.healTarget(self, target, amount)
|
|
831
875
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -868,17 +912,16 @@ function Unit.prototype.itemInSlot(self, slot)
|
|
|
868
912
|
return Item:of(unitItemInSlot(self.handle, slot))
|
|
869
913
|
end
|
|
870
914
|
function Unit.prototype.addAbility(self, abilityId)
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
915
|
+
local ability = UnitAbility:of(
|
|
916
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
917
|
+
abilityId,
|
|
918
|
+
self
|
|
919
|
+
)
|
|
920
|
+
if ability ~= nil then
|
|
877
921
|
local abilities = self.abilities
|
|
878
922
|
abilities[#abilities + 1] = ability
|
|
879
|
-
return ability
|
|
880
923
|
end
|
|
881
|
-
return
|
|
924
|
+
return ability
|
|
882
925
|
end
|
|
883
926
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
884
927
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -893,19 +936,11 @@ function Unit.prototype.hasAbility(self, abilityId)
|
|
|
893
936
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
894
937
|
end
|
|
895
938
|
function Unit.prototype.getAbilityById(self, abilityId)
|
|
896
|
-
local
|
|
897
|
-
|
|
898
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
899
|
-
return nil
|
|
900
|
-
end
|
|
901
|
-
return UnitAbility:of(
|
|
902
|
-
getUnitAbility(self.handle, abilityId),
|
|
903
|
-
abilityId,
|
|
904
|
-
self
|
|
905
|
-
)
|
|
939
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
940
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
906
941
|
end
|
|
907
942
|
function Unit.prototype.removeAbility(self, abilityId)
|
|
908
|
-
if
|
|
943
|
+
if doUnitAbilityAction(self.handle, abilityId, unitRemoveAbility, abilityId) then
|
|
909
944
|
local abilities = self.abilities
|
|
910
945
|
for i = 1, #abilities do
|
|
911
946
|
if abilities[i].typeId == abilityId then
|
|
@@ -930,12 +965,34 @@ end
|
|
|
930
965
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
931
966
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
932
967
|
end
|
|
968
|
+
function Unit.prototype.interruptMovement(self)
|
|
969
|
+
local handle = self.handle
|
|
970
|
+
unitDisableAbility(
|
|
971
|
+
handle,
|
|
972
|
+
fourCC("Amov"),
|
|
973
|
+
true,
|
|
974
|
+
false
|
|
975
|
+
)
|
|
976
|
+
unitDisableAbility(
|
|
977
|
+
handle,
|
|
978
|
+
fourCC("Amov"),
|
|
979
|
+
false,
|
|
980
|
+
false
|
|
981
|
+
)
|
|
982
|
+
end
|
|
933
983
|
function Unit.prototype.interruptAttack(self)
|
|
934
984
|
unitInterruptAttack(self.handle)
|
|
935
985
|
end
|
|
936
986
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
937
|
-
|
|
938
|
-
unitDisableAbility(
|
|
987
|
+
local handle = self.handle
|
|
988
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
989
|
+
Timer:run(
|
|
990
|
+
unitDisableAbility,
|
|
991
|
+
handle,
|
|
992
|
+
abilityId,
|
|
993
|
+
false,
|
|
994
|
+
false
|
|
995
|
+
)
|
|
939
996
|
end
|
|
940
997
|
function Unit.prototype.getDistanceTo(self, target)
|
|
941
998
|
local handle = self.handle
|
|
@@ -995,18 +1052,18 @@ function Unit.prototype.unpauseEx(self)
|
|
|
995
1052
|
self:decrementStunCounter()
|
|
996
1053
|
end
|
|
997
1054
|
function Unit.prototype.incrementStunCounter(self)
|
|
998
|
-
local stunCounter = self[
|
|
999
|
-
if not self[
|
|
1055
|
+
local stunCounter = self[102] or 0
|
|
1056
|
+
if not self[101] or stunCounter >= 0 then
|
|
1000
1057
|
BlzPauseUnitEx(self.handle, true)
|
|
1001
1058
|
end
|
|
1002
|
-
self[
|
|
1059
|
+
self[102] = stunCounter + 1
|
|
1003
1060
|
end
|
|
1004
1061
|
function Unit.prototype.decrementStunCounter(self)
|
|
1005
|
-
local stunCounter = self[
|
|
1006
|
-
if not self[
|
|
1062
|
+
local stunCounter = self[102] or 0
|
|
1063
|
+
if not self[101] or stunCounter >= 1 then
|
|
1007
1064
|
BlzPauseUnitEx(self.handle, false)
|
|
1008
1065
|
end
|
|
1009
|
-
self[
|
|
1066
|
+
self[102] = stunCounter - 1
|
|
1010
1067
|
end
|
|
1011
1068
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1012
1069
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -1108,8 +1165,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
1108
1165
|
)
|
|
1109
1166
|
return targetCollection
|
|
1110
1167
|
end
|
|
1111
|
-
function Unit.getSelectionOf(self, player)
|
|
1112
|
-
|
|
1168
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1169
|
+
if target == nil then
|
|
1170
|
+
target = {}
|
|
1171
|
+
end
|
|
1172
|
+
targetCollection = target
|
|
1113
1173
|
targetCollectionNextIndex = 1
|
|
1114
1174
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
1115
1175
|
return targetCollection
|
|
@@ -1131,6 +1191,9 @@ end
|
|
|
1131
1191
|
function Unit.prototype.__tostring(self)
|
|
1132
1192
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
1133
1193
|
end
|
|
1194
|
+
function Unit.getBySyncId(self, syncId)
|
|
1195
|
+
return unitBySyncId[syncId]
|
|
1196
|
+
end
|
|
1134
1197
|
__TS__SetDescriptor(
|
|
1135
1198
|
Unit.prototype,
|
|
1136
1199
|
"_deltas",
|
|
@@ -1190,7 +1253,15 @@ __TS__SetDescriptor(
|
|
|
1190
1253
|
Unit.prototype,
|
|
1191
1254
|
"isIllusion",
|
|
1192
1255
|
{get = function(self)
|
|
1193
|
-
return
|
|
1256
|
+
return IsUnitIllusion(self.handle)
|
|
1257
|
+
end},
|
|
1258
|
+
true
|
|
1259
|
+
)
|
|
1260
|
+
__TS__SetDescriptor(
|
|
1261
|
+
Unit.prototype,
|
|
1262
|
+
"isStunned",
|
|
1263
|
+
{get = function(self)
|
|
1264
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1194
1265
|
end},
|
|
1195
1266
|
true
|
|
1196
1267
|
)
|
|
@@ -1267,6 +1338,19 @@ __TS__SetDescriptor(
|
|
|
1267
1338
|
},
|
|
1268
1339
|
true
|
|
1269
1340
|
)
|
|
1341
|
+
__TS__SetDescriptor(
|
|
1342
|
+
Unit.prototype,
|
|
1343
|
+
"primaryAttribute",
|
|
1344
|
+
{
|
|
1345
|
+
get = function(self)
|
|
1346
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1347
|
+
end,
|
|
1348
|
+
set = function(self, primaryAttribute)
|
|
1349
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1350
|
+
end
|
|
1351
|
+
},
|
|
1352
|
+
true
|
|
1353
|
+
)
|
|
1270
1354
|
__TS__SetDescriptor(
|
|
1271
1355
|
Unit.prototype,
|
|
1272
1356
|
"strengthBase",
|
|
@@ -1388,17 +1472,17 @@ __TS__SetDescriptor(
|
|
|
1388
1472
|
"isTeamGlowVisible",
|
|
1389
1473
|
{
|
|
1390
1474
|
get = function(self)
|
|
1391
|
-
return not self[
|
|
1475
|
+
return not self[106]
|
|
1392
1476
|
end,
|
|
1393
1477
|
set = function(self, isTeamGlowVisible)
|
|
1394
|
-
|
|
1395
|
-
local
|
|
1478
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1479
|
+
local ____temp_7
|
|
1396
1480
|
if not isTeamGlowVisible then
|
|
1397
|
-
|
|
1481
|
+
____temp_7 = true
|
|
1398
1482
|
else
|
|
1399
|
-
|
|
1483
|
+
____temp_7 = nil
|
|
1400
1484
|
end
|
|
1401
|
-
self[
|
|
1485
|
+
self[106] = ____temp_7
|
|
1402
1486
|
end
|
|
1403
1487
|
},
|
|
1404
1488
|
true
|
|
@@ -1407,9 +1491,9 @@ __TS__SetDescriptor(
|
|
|
1407
1491
|
Unit.prototype,
|
|
1408
1492
|
"color",
|
|
1409
1493
|
{set = function(self, color)
|
|
1410
|
-
|
|
1411
|
-
if self[
|
|
1412
|
-
|
|
1494
|
+
SetUnitColor(self.handle, color.handle)
|
|
1495
|
+
if self[106] then
|
|
1496
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1413
1497
|
end
|
|
1414
1498
|
end},
|
|
1415
1499
|
true
|
|
@@ -1432,14 +1516,14 @@ __TS__SetDescriptor(
|
|
|
1432
1516
|
"maxHealth",
|
|
1433
1517
|
{
|
|
1434
1518
|
get = function(self)
|
|
1435
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1519
|
+
return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
|
|
1436
1520
|
end,
|
|
1437
1521
|
set = function(self, maxHealth)
|
|
1438
|
-
if maxHealth < 1 and self[
|
|
1439
|
-
self[
|
|
1522
|
+
if maxHealth < 1 and self[103] ~= nil then
|
|
1523
|
+
self[104] = (self[104] or 0) + (1 - maxHealth)
|
|
1440
1524
|
maxHealth = 1
|
|
1441
1525
|
end
|
|
1442
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1526
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
|
|
1443
1527
|
end
|
|
1444
1528
|
},
|
|
1445
1529
|
true
|
|
@@ -1481,10 +1565,10 @@ __TS__SetDescriptor(
|
|
|
1481
1565
|
"health",
|
|
1482
1566
|
{
|
|
1483
1567
|
get = function(self)
|
|
1484
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1568
|
+
return GetWidgetLife(self.handle) - (self[105] or 0)
|
|
1485
1569
|
end,
|
|
1486
1570
|
set = function(self, health)
|
|
1487
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1571
|
+
SetWidgetLife(self.handle, health + (self[105] or 0))
|
|
1488
1572
|
end
|
|
1489
1573
|
},
|
|
1490
1574
|
true
|
|
@@ -1578,7 +1662,7 @@ __TS__SetDescriptor(
|
|
|
1578
1662
|
"x",
|
|
1579
1663
|
{
|
|
1580
1664
|
get = function(self)
|
|
1581
|
-
return getUnitX(self.handle)
|
|
1665
|
+
return self[107] or getUnitX(self.handle)
|
|
1582
1666
|
end,
|
|
1583
1667
|
set = function(self, v)
|
|
1584
1668
|
SetUnitX(self.handle, v)
|
|
@@ -1591,7 +1675,7 @@ __TS__SetDescriptor(
|
|
|
1591
1675
|
"y",
|
|
1592
1676
|
{
|
|
1593
1677
|
get = function(self)
|
|
1594
|
-
return getUnitY(self.handle)
|
|
1678
|
+
return self[108] or getUnitY(self.handle)
|
|
1595
1679
|
end,
|
|
1596
1680
|
set = function(self, v)
|
|
1597
1681
|
SetUnitY(self.handle, v)
|
|
@@ -1677,10 +1761,10 @@ __TS__SetDescriptor(
|
|
|
1677
1761
|
"gold",
|
|
1678
1762
|
{
|
|
1679
1763
|
get = function(self)
|
|
1680
|
-
return
|
|
1764
|
+
return GetResourceAmount(self.handle)
|
|
1681
1765
|
end,
|
|
1682
1766
|
set = function(self, gold)
|
|
1683
|
-
|
|
1767
|
+
SetResourceAmount(self.handle, gold)
|
|
1684
1768
|
end
|
|
1685
1769
|
},
|
|
1686
1770
|
true
|
|
@@ -1695,17 +1779,17 @@ __TS__SetDescriptor(
|
|
|
1695
1779
|
set = function(self, isPaused)
|
|
1696
1780
|
local handle = self.handle
|
|
1697
1781
|
if isPaused and not IsUnitPaused(handle) then
|
|
1698
|
-
self[
|
|
1699
|
-
for _ = self[
|
|
1782
|
+
self[101] = true
|
|
1783
|
+
for _ = self[102] or 0, -1 do
|
|
1700
1784
|
BlzPauseUnitEx(handle, true)
|
|
1701
1785
|
end
|
|
1702
1786
|
PauseUnit(handle, true)
|
|
1703
1787
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1704
1788
|
PauseUnit(handle, false)
|
|
1705
|
-
for _ = self[
|
|
1789
|
+
for _ = self[102] or 0, -1 do
|
|
1706
1790
|
BlzPauseUnitEx(handle, false)
|
|
1707
1791
|
end
|
|
1708
|
-
self[
|
|
1792
|
+
self[101] = nil
|
|
1709
1793
|
end
|
|
1710
1794
|
end
|
|
1711
1795
|
},
|
|
@@ -1808,6 +1892,19 @@ __TS__SetDescriptor(
|
|
|
1808
1892
|
end},
|
|
1809
1893
|
true
|
|
1810
1894
|
)
|
|
1895
|
+
__TS__SetDescriptor(
|
|
1896
|
+
Unit.prototype,
|
|
1897
|
+
"movementType",
|
|
1898
|
+
{
|
|
1899
|
+
get = function(self)
|
|
1900
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1901
|
+
end,
|
|
1902
|
+
set = function(self, movementType)
|
|
1903
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1904
|
+
end
|
|
1905
|
+
},
|
|
1906
|
+
true
|
|
1907
|
+
)
|
|
1811
1908
|
__TS__SetDescriptor(
|
|
1812
1909
|
Unit.prototype,
|
|
1813
1910
|
"pathing",
|
|
@@ -1989,6 +2086,14 @@ __TS__SetDescriptor(
|
|
|
1989
2086
|
end},
|
|
1990
2087
|
true
|
|
1991
2088
|
)
|
|
2089
|
+
__TS__SetDescriptor(
|
|
2090
|
+
Unit.prototype,
|
|
2091
|
+
"targetAcquiredEvent",
|
|
2092
|
+
{get = function(self)
|
|
2093
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2094
|
+
end},
|
|
2095
|
+
true
|
|
2096
|
+
)
|
|
1992
2097
|
__TS__SetDescriptor(
|
|
1993
2098
|
Unit.prototype,
|
|
1994
2099
|
"onSelect",
|
|
@@ -2124,25 +2229,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2124
2229
|
InitializingEvent,
|
|
2125
2230
|
function(event)
|
|
2126
2231
|
local function listener(unit, id)
|
|
2127
|
-
local
|
|
2232
|
+
local ____GetSpellTargetUnit_result_10
|
|
2128
2233
|
if GetSpellTargetUnit() then
|
|
2129
|
-
|
|
2234
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2130
2235
|
else
|
|
2131
|
-
local
|
|
2236
|
+
local ____GetSpellTargetItem_result_9
|
|
2132
2237
|
if GetSpellTargetItem() then
|
|
2133
|
-
|
|
2238
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2134
2239
|
else
|
|
2135
|
-
local
|
|
2240
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2136
2241
|
if GetSpellTargetDestructable() then
|
|
2137
|
-
|
|
2242
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2138
2243
|
else
|
|
2139
|
-
|
|
2244
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2140
2245
|
end
|
|
2141
|
-
|
|
2246
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2142
2247
|
end
|
|
2143
|
-
|
|
2248
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2144
2249
|
end
|
|
2145
|
-
local target =
|
|
2250
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2146
2251
|
if target then
|
|
2147
2252
|
invoke(event, unit, id, target)
|
|
2148
2253
|
end
|
|
@@ -2314,10 +2419,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2314
2419
|
____exports.UnitTriggerEvent,
|
|
2315
2420
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2316
2421
|
function()
|
|
2317
|
-
local
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2422
|
+
local handle = getOrderedUnit()
|
|
2423
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2424
|
+
local unit = ____exports.Unit:of(handle)
|
|
2425
|
+
if unit.state == 1 then
|
|
2426
|
+
return unit, getIssuedOrderId()
|
|
2427
|
+
end
|
|
2321
2428
|
end
|
|
2322
2429
|
return IgnoreEvent
|
|
2323
2430
|
end
|
|
@@ -2348,13 +2455,19 @@ Unit.onDamaging = (function()
|
|
|
2348
2455
|
if source and source.typeId == dummyUnitId then
|
|
2349
2456
|
source = nil
|
|
2350
2457
|
end
|
|
2351
|
-
local target = BlzGetEventDamageTarget()
|
|
2458
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2459
|
+
local metadata = damageMetadataByTarget[target]
|
|
2460
|
+
damageMetadataByTarget[target] = nil
|
|
2352
2461
|
local data = {
|
|
2353
2462
|
amount = GetEventDamage(),
|
|
2354
|
-
attackType = BlzGetEventAttackType(),
|
|
2463
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2355
2464
|
damageType = BlzGetEventDamageType(),
|
|
2356
2465
|
weaponType = BlzGetEventWeaponType(),
|
|
2357
|
-
|
|
2466
|
+
metadata = metadata,
|
|
2467
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2468
|
+
originalAmount = GetEventDamage(),
|
|
2469
|
+
originalMetadata = metadata,
|
|
2470
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2358
2471
|
}
|
|
2359
2472
|
if data.isAttack and source then
|
|
2360
2473
|
local weapon = BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 1) and (BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 0) and -1 or 1) or 0
|
|
@@ -2368,18 +2481,36 @@ Unit.onDamaging = (function()
|
|
|
2368
2481
|
invoke(
|
|
2369
2482
|
event,
|
|
2370
2483
|
source,
|
|
2371
|
-
|
|
2484
|
+
target,
|
|
2372
2485
|
setmetatable(
|
|
2373
2486
|
{},
|
|
2374
2487
|
{
|
|
2375
2488
|
__index = data,
|
|
2376
2489
|
__newindex = function(self, key, value)
|
|
2377
|
-
damageSetters[key]
|
|
2490
|
+
local damageSetter = damageSetters[key]
|
|
2491
|
+
if damageSetter ~= nil then
|
|
2492
|
+
damageSetter(value)
|
|
2493
|
+
end
|
|
2378
2494
|
data[key] = value
|
|
2379
2495
|
end
|
|
2380
2496
|
}
|
|
2381
2497
|
)
|
|
2382
2498
|
)
|
|
2499
|
+
if data[0] and source then
|
|
2500
|
+
local sourceOwner = source.owner.handle
|
|
2501
|
+
data[1] = sourceOwner
|
|
2502
|
+
local targetOwner = target.owner.handle
|
|
2503
|
+
data[2] = targetOwner
|
|
2504
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2505
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2506
|
+
data[3] = true
|
|
2507
|
+
end
|
|
2508
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2509
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2510
|
+
data[4] = true
|
|
2511
|
+
end
|
|
2512
|
+
end
|
|
2513
|
+
damagingEventByTarget[target] = data
|
|
2383
2514
|
return
|
|
2384
2515
|
end
|
|
2385
2516
|
BlzSetEventDamage(0)
|
|
@@ -2387,7 +2518,7 @@ Unit.onDamaging = (function()
|
|
|
2387
2518
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2388
2519
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2389
2520
|
local sourceOwner = source.owner.handle
|
|
2390
|
-
local targetOwner =
|
|
2521
|
+
local targetOwner = target.owner.handle
|
|
2391
2522
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2392
2523
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2393
2524
|
Timer:run(function()
|
|
@@ -2403,23 +2534,19 @@ Unit.onDamaging = (function()
|
|
|
2403
2534
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2404
2535
|
local condition = ____value[1]
|
|
2405
2536
|
local action = ____value[2]
|
|
2406
|
-
if condition(
|
|
2407
|
-
source,
|
|
2408
|
-
____exports.Unit:of(target),
|
|
2409
|
-
data
|
|
2410
|
-
) then
|
|
2537
|
+
if condition(source, target, data) then
|
|
2411
2538
|
action(
|
|
2412
2539
|
source,
|
|
2413
|
-
|
|
2540
|
+
target,
|
|
2414
2541
|
setmetatable(
|
|
2415
2542
|
{fire = function()
|
|
2416
2543
|
UnitDamageTarget(
|
|
2417
2544
|
source.handle,
|
|
2418
|
-
target,
|
|
2545
|
+
target.handle,
|
|
2419
2546
|
data.amount,
|
|
2420
2547
|
true,
|
|
2421
2548
|
true,
|
|
2422
|
-
data.attackType,
|
|
2549
|
+
attackTypeToNative(data.attackType),
|
|
2423
2550
|
data.damageType,
|
|
2424
2551
|
data.weaponType
|
|
2425
2552
|
)
|
|
@@ -2446,30 +2573,54 @@ Unit.onDamage = __TS__New(
|
|
|
2446
2573
|
if source and source.typeId == dummyUnitId then
|
|
2447
2574
|
source = nil
|
|
2448
2575
|
end
|
|
2576
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2577
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2578
|
+
damagingEventByTarget[target] = nil
|
|
2449
2579
|
local data = {
|
|
2450
2580
|
amount = GetEventDamage(),
|
|
2451
|
-
attackType = BlzGetEventAttackType(),
|
|
2581
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2452
2582
|
damageType = BlzGetEventDamageType(),
|
|
2453
2583
|
weaponType = BlzGetEventWeaponType(),
|
|
2584
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2454
2585
|
isAttack = BlzGetEventIsAttack(),
|
|
2455
|
-
originalAmount = GetEventDamage(),
|
|
2586
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2587
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2456
2588
|
preventDeath = damageEventPreventDeath
|
|
2457
2589
|
}
|
|
2590
|
+
if damagingEvent then
|
|
2591
|
+
for key, value in pairs(damagingEvent) do
|
|
2592
|
+
if isAttribute(key) then
|
|
2593
|
+
data[key] = value
|
|
2594
|
+
end
|
|
2595
|
+
end
|
|
2596
|
+
local sourceOwner = damagingEvent[1]
|
|
2597
|
+
if sourceOwner then
|
|
2598
|
+
local targetOwner = damagingEvent[2]
|
|
2599
|
+
if damagingEvent[3] then
|
|
2600
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2601
|
+
end
|
|
2602
|
+
if damagingEvent[4] then
|
|
2603
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2604
|
+
end
|
|
2605
|
+
end
|
|
2606
|
+
end
|
|
2458
2607
|
local evData = setmetatable(
|
|
2459
2608
|
{},
|
|
2460
2609
|
{
|
|
2461
2610
|
__index = data,
|
|
2462
2611
|
__newindex = function(self, key, value)
|
|
2463
|
-
damageSetters[key]
|
|
2612
|
+
local damageSetter = damageSetters[key]
|
|
2613
|
+
if damageSetter ~= nil then
|
|
2614
|
+
damageSetter(value)
|
|
2615
|
+
end
|
|
2464
2616
|
data[key] = value
|
|
2465
2617
|
end
|
|
2466
2618
|
}
|
|
2467
2619
|
)
|
|
2468
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2469
2620
|
invoke(event, source, target, evData)
|
|
2470
2621
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2471
2622
|
local bonusHealth = math.ceil(evData.amount)
|
|
2472
|
-
target[
|
|
2623
|
+
target[105] = (target[105] or 0) + bonusHealth
|
|
2473
2624
|
BlzSetUnitMaxHP(
|
|
2474
2625
|
target.handle,
|
|
2475
2626
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2483,7 +2634,7 @@ Unit.onDamage = __TS__New(
|
|
|
2483
2634
|
evData[0],
|
|
2484
2635
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2485
2636
|
)
|
|
2486
|
-
target[
|
|
2637
|
+
target[105] = (target[105] or 0) - bonusHealth
|
|
2487
2638
|
SetWidgetLife(
|
|
2488
2639
|
target.handle,
|
|
2489
2640
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2508,8 +2659,9 @@ Unit.itemDroppedEvent = __TS__New(
|
|
|
2508
2659
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2509
2660
|
function()
|
|
2510
2661
|
local unit = getTriggerUnit()
|
|
2511
|
-
|
|
2512
|
-
|
|
2662
|
+
local item = getManipulatedItem()
|
|
2663
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2664
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2513
2665
|
end
|
|
2514
2666
|
return IgnoreEvent
|
|
2515
2667
|
end
|
|
@@ -2519,8 +2671,9 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2519
2671
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2520
2672
|
function()
|
|
2521
2673
|
local unit = getTriggerUnit()
|
|
2522
|
-
|
|
2523
|
-
|
|
2674
|
+
local item = getManipulatedItem()
|
|
2675
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2676
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2524
2677
|
end
|
|
2525
2678
|
return IgnoreEvent
|
|
2526
2679
|
end
|
|
@@ -2528,12 +2681,79 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2528
2681
|
Unit.itemUsedEvent = __TS__New(
|
|
2529
2682
|
____exports.UnitTriggerEvent,
|
|
2530
2683
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2531
|
-
function()
|
|
2684
|
+
function()
|
|
2685
|
+
local unit = getTriggerUnit()
|
|
2686
|
+
local item = getManipulatedItem()
|
|
2687
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2688
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2689
|
+
end
|
|
2690
|
+
return IgnoreEvent
|
|
2691
|
+
end
|
|
2532
2692
|
)
|
|
2533
2693
|
Unit.itemStackedEvent = __TS__New(
|
|
2534
2694
|
____exports.UnitTriggerEvent,
|
|
2535
2695
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2536
|
-
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(
|
|
2696
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemSource()), Item:of(BlzGetStackingItemTarget()) end
|
|
2697
|
+
)
|
|
2698
|
+
__TS__ObjectDefineProperty(
|
|
2699
|
+
Unit,
|
|
2700
|
+
"itemChargesChangedEvent",
|
|
2701
|
+
{get = function(self)
|
|
2702
|
+
local event = __TS__New(Event)
|
|
2703
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2704
|
+
local unit = item.owner
|
|
2705
|
+
if unit ~= nil then
|
|
2706
|
+
invoke(event, unit, item)
|
|
2707
|
+
end
|
|
2708
|
+
end)
|
|
2709
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2710
|
+
return event
|
|
2711
|
+
end}
|
|
2712
|
+
)
|
|
2713
|
+
__TS__ObjectDefineProperty(
|
|
2714
|
+
Unit,
|
|
2715
|
+
"itemUseOrderEvent",
|
|
2716
|
+
{get = function(self)
|
|
2717
|
+
local event = __TS__New(Event)
|
|
2718
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2719
|
+
local slot = order - orderId("useslot0")
|
|
2720
|
+
local function listener(unit)
|
|
2721
|
+
local item = unit.items[slot + 1]
|
|
2722
|
+
if item ~= nil then
|
|
2723
|
+
invoke(event, unit, item)
|
|
2724
|
+
end
|
|
2725
|
+
end
|
|
2726
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2727
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2728
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2729
|
+
end
|
|
2730
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2731
|
+
return event
|
|
2732
|
+
end}
|
|
2733
|
+
)
|
|
2734
|
+
__TS__ObjectDefineProperty(
|
|
2735
|
+
Unit,
|
|
2736
|
+
"itemMoveOrderEvent",
|
|
2737
|
+
{get = function(self)
|
|
2738
|
+
local event = __TS__New(Event)
|
|
2739
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2740
|
+
local slotTo = order - orderId("moveslot0")
|
|
2741
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2742
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2743
|
+
if slotFrom ~= nil then
|
|
2744
|
+
invoke(
|
|
2745
|
+
event,
|
|
2746
|
+
unit,
|
|
2747
|
+
item,
|
|
2748
|
+
slotFrom,
|
|
2749
|
+
slotTo
|
|
2750
|
+
)
|
|
2751
|
+
end
|
|
2752
|
+
end)
|
|
2753
|
+
end
|
|
2754
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2755
|
+
return event
|
|
2756
|
+
end}
|
|
2537
2757
|
)
|
|
2538
2758
|
__TS__ObjectDefineProperty(
|
|
2539
2759
|
Unit,
|