warscript 0.0.1-dev.d18f377 → 0.0.1-dev.d1b563b
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 +2 -3
- package/core/types/effect.lua +95 -48
- package/core/types/frame.lua +24 -21
- package/core/types/player.lua +3 -1
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +123 -5
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/tileCell.d.ts +9 -0
- package/core/types/tileCell.lua +92 -0
- package/core/types/timer.d.ts +8 -8
- package/core/types/timer.lua +39 -23
- package/core/util.d.ts +1 -1
- package/core/util.lua +12 -1
- package/decl/native.d.ts +846 -790
- package/engine/behavior.d.ts +5 -0
- package/engine/behavior.lua +106 -27
- 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 +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +22 -8
- package/engine/behaviour/ability/on-command-impact.lua +7 -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 +15 -3
- package/engine/behaviour/ability.lua +85 -22
- 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 +32 -0
- package/engine/behaviour/unit.lua +185 -4
- package/engine/buff.d.ts +57 -44
- package/engine/buff.lua +273 -221
- package/engine/internal/ability.d.ts +18 -2
- package/engine/internal/ability.lua +116 -11
- package/engine/internal/item/ability.lua +162 -4
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +8 -7
- package/engine/internal/item.lua +153 -51
- 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 +35 -0
- package/engine/internal/unit/ability.lua +63 -1
- 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.lua +6 -12
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -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 +9 -2
- package/engine/internal/unit.d.ts +35 -11
- package/engine/internal/unit.lua +317 -120
- package/engine/internal/utility.lua +12 -0
- package/engine/lightning.d.ts +12 -5
- package/engine/lightning.lua +48 -14
- 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/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 +3 -1
- package/engine/object-data/entry/item-type.lua +15 -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 +12 -6
- package/engine/object-field/ability.lua +8 -4
- 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 +190 -90
- 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/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 +2 -0
- package/engine/unit.lua +2 -0
- package/objutil/buff.lua +1 -2
- package/objutil/unit.lua +8 -0
- package/package.json +2 -2
- package/patch-lualib.lua +1 -1
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +3 -0
- package/utility/callback-array.d.ts +13 -0
- package/utility/callback-array.lua +46 -0
- package/utility/functions.d.ts +8 -0
- package/utility/functions.lua +13 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +3 -0
- package/utility/lua-maps.d.ts +10 -1
- package/utility/lua-maps.lua +40 -2
- 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",
|
|
@@ -636,16 +661,26 @@ local function delayHealthChecksCallback(unit)
|
|
|
636
661
|
end
|
|
637
662
|
end
|
|
638
663
|
local nextSyncId = 1
|
|
639
|
-
local unitBySyncId = setmetatable({}, {__mode = "
|
|
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
|
|
640
675
|
____exports.Unit = __TS__Class()
|
|
641
676
|
local Unit = ____exports.Unit
|
|
642
677
|
Unit.name = "Unit"
|
|
643
678
|
__TS__ClassExtends(Unit, Handle)
|
|
644
679
|
function Unit.prototype.____constructor(self, handle)
|
|
645
680
|
Handle.prototype.____constructor(self, handle)
|
|
646
|
-
local
|
|
647
|
-
nextSyncId =
|
|
648
|
-
self.syncId =
|
|
681
|
+
local ____nextSyncId_1 = nextSyncId
|
|
682
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
683
|
+
self.syncId = ____nextSyncId_1
|
|
649
684
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
650
685
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
651
686
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -677,6 +712,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
677
712
|
end
|
|
678
713
|
function Unit.prototype.onDestroy(self)
|
|
679
714
|
local handle = self.handle
|
|
715
|
+
self[107] = getUnitX(handle)
|
|
716
|
+
self[108] = getUnitY(handle)
|
|
680
717
|
if not self._owner then
|
|
681
718
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
682
719
|
end
|
|
@@ -744,17 +781,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
744
781
|
end}
|
|
745
782
|
end
|
|
746
783
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
747
|
-
local
|
|
748
|
-
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
|
|
749
786
|
end
|
|
750
787
|
function Unit.prototype.addClassification(self, classification)
|
|
751
|
-
return
|
|
788
|
+
return UnitAddType(self.handle, classification)
|
|
752
789
|
end
|
|
753
790
|
function Unit.prototype.removeClassification(self, classification)
|
|
754
|
-
return
|
|
791
|
+
return UnitRemoveType(self.handle, classification)
|
|
755
792
|
end
|
|
756
793
|
function Unit.prototype.hasClassification(self, classification)
|
|
757
|
-
return
|
|
794
|
+
return IsUnitType(self.handle, classification)
|
|
758
795
|
end
|
|
759
796
|
function Unit.prototype.isVisibleTo(self, player)
|
|
760
797
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -763,13 +800,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
763
800
|
return isUnitInvisible(self.handle, player.handle)
|
|
764
801
|
end
|
|
765
802
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
766
|
-
local
|
|
803
|
+
local ____temp_3
|
|
767
804
|
if type(x) == "number" then
|
|
768
|
-
|
|
805
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
769
806
|
else
|
|
770
|
-
|
|
807
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
771
808
|
end
|
|
772
|
-
return
|
|
809
|
+
return ____temp_3
|
|
773
810
|
end
|
|
774
811
|
function Unit.prototype.isAllyOf(self, unit)
|
|
775
812
|
return isUnitAlly(
|
|
@@ -787,13 +824,25 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
787
824
|
if type(animation) == "number" then
|
|
788
825
|
setUnitAnimationByIndex(self.handle, animation)
|
|
789
826
|
elseif rarity then
|
|
790
|
-
|
|
827
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
791
828
|
else
|
|
792
829
|
setUnitAnimation(self.handle, animation)
|
|
793
830
|
end
|
|
794
831
|
end
|
|
832
|
+
function Unit.prototype.resetAnimation(self)
|
|
833
|
+
ResetUnitAnimation(self.handle)
|
|
834
|
+
end
|
|
795
835
|
function Unit.prototype.queueAnimation(self, animation)
|
|
796
|
-
|
|
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
|
|
797
846
|
end
|
|
798
847
|
function Unit.prototype.delayHealthChecks(self)
|
|
799
848
|
self[103] = (self[103] or 0) + 1
|
|
@@ -806,21 +855,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
806
855
|
return IsUnitSelected(self.handle, player.handle)
|
|
807
856
|
end
|
|
808
857
|
function Unit.prototype.explode(self)
|
|
809
|
-
|
|
858
|
+
SetUnitExploded(self.handle, true)
|
|
810
859
|
killUnit(self.handle)
|
|
811
860
|
end
|
|
812
861
|
function Unit.prototype.kill(self)
|
|
813
862
|
killUnit(self.handle)
|
|
814
863
|
end
|
|
815
864
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
816
|
-
local
|
|
817
|
-
local
|
|
818
|
-
local
|
|
819
|
-
if
|
|
820
|
-
|
|
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
|
|
821
870
|
end
|
|
822
|
-
__TS__SparseArrayPush(
|
|
823
|
-
|
|
871
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
872
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
824
873
|
end
|
|
825
874
|
function Unit.prototype.healTarget(self, target, amount)
|
|
826
875
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -863,17 +912,16 @@ function Unit.prototype.itemInSlot(self, slot)
|
|
|
863
912
|
return Item:of(unitItemInSlot(self.handle, slot))
|
|
864
913
|
end
|
|
865
914
|
function Unit.prototype.addAbility(self, abilityId)
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
915
|
+
local ability = UnitAbility:of(
|
|
916
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
917
|
+
abilityId,
|
|
918
|
+
self
|
|
919
|
+
)
|
|
920
|
+
if ability ~= nil then
|
|
872
921
|
local abilities = self.abilities
|
|
873
922
|
abilities[#abilities + 1] = ability
|
|
874
|
-
return ability
|
|
875
923
|
end
|
|
876
|
-
return
|
|
924
|
+
return ability
|
|
877
925
|
end
|
|
878
926
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
879
927
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -887,31 +935,21 @@ end
|
|
|
887
935
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
888
936
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
889
937
|
end
|
|
890
|
-
function Unit.prototype.
|
|
891
|
-
local
|
|
892
|
-
|
|
893
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
894
|
-
return nil
|
|
895
|
-
end
|
|
896
|
-
return UnitAbility:of(
|
|
897
|
-
getUnitAbility(self.handle, abilityId),
|
|
898
|
-
abilityId,
|
|
899
|
-
self
|
|
900
|
-
)
|
|
938
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
939
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
940
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
901
941
|
end
|
|
902
|
-
function Unit.prototype.removeAbility(self,
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
end
|
|
942
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
943
|
+
local abilities = self.abilities
|
|
944
|
+
for i = 1, #abilities do
|
|
945
|
+
if abilities[i].typeId == abilityTypeId then
|
|
946
|
+
local ability = abilities[i]
|
|
947
|
+
tremove(abilities, i)
|
|
948
|
+
ability:destroy()
|
|
949
|
+
return true
|
|
911
950
|
end
|
|
912
|
-
return true
|
|
913
951
|
end
|
|
914
|
-
return
|
|
952
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
915
953
|
end
|
|
916
954
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
917
955
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -925,12 +963,34 @@ end
|
|
|
925
963
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
926
964
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
927
965
|
end
|
|
966
|
+
function Unit.prototype.interruptMovement(self)
|
|
967
|
+
local handle = self.handle
|
|
968
|
+
unitDisableAbility(
|
|
969
|
+
handle,
|
|
970
|
+
fourCC("Amov"),
|
|
971
|
+
true,
|
|
972
|
+
false
|
|
973
|
+
)
|
|
974
|
+
unitDisableAbility(
|
|
975
|
+
handle,
|
|
976
|
+
fourCC("Amov"),
|
|
977
|
+
false,
|
|
978
|
+
false
|
|
979
|
+
)
|
|
980
|
+
end
|
|
928
981
|
function Unit.prototype.interruptAttack(self)
|
|
929
982
|
unitInterruptAttack(self.handle)
|
|
930
983
|
end
|
|
931
984
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
932
|
-
|
|
933
|
-
unitDisableAbility(
|
|
985
|
+
local handle = self.handle
|
|
986
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
987
|
+
Timer:run(
|
|
988
|
+
unitDisableAbility,
|
|
989
|
+
handle,
|
|
990
|
+
abilityId,
|
|
991
|
+
false,
|
|
992
|
+
false
|
|
993
|
+
)
|
|
934
994
|
end
|
|
935
995
|
function Unit.prototype.getDistanceTo(self, target)
|
|
936
996
|
local handle = self.handle
|
|
@@ -1191,7 +1251,15 @@ __TS__SetDescriptor(
|
|
|
1191
1251
|
Unit.prototype,
|
|
1192
1252
|
"isIllusion",
|
|
1193
1253
|
{get = function(self)
|
|
1194
|
-
return
|
|
1254
|
+
return IsUnitIllusion(self.handle)
|
|
1255
|
+
end},
|
|
1256
|
+
true
|
|
1257
|
+
)
|
|
1258
|
+
__TS__SetDescriptor(
|
|
1259
|
+
Unit.prototype,
|
|
1260
|
+
"isStunned",
|
|
1261
|
+
{get = function(self)
|
|
1262
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1195
1263
|
end},
|
|
1196
1264
|
true
|
|
1197
1265
|
)
|
|
@@ -1268,6 +1336,19 @@ __TS__SetDescriptor(
|
|
|
1268
1336
|
},
|
|
1269
1337
|
true
|
|
1270
1338
|
)
|
|
1339
|
+
__TS__SetDescriptor(
|
|
1340
|
+
Unit.prototype,
|
|
1341
|
+
"primaryAttribute",
|
|
1342
|
+
{
|
|
1343
|
+
get = function(self)
|
|
1344
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1345
|
+
end,
|
|
1346
|
+
set = function(self, primaryAttribute)
|
|
1347
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1348
|
+
end
|
|
1349
|
+
},
|
|
1350
|
+
true
|
|
1351
|
+
)
|
|
1271
1352
|
__TS__SetDescriptor(
|
|
1272
1353
|
Unit.prototype,
|
|
1273
1354
|
"strengthBase",
|
|
@@ -1392,14 +1473,14 @@ __TS__SetDescriptor(
|
|
|
1392
1473
|
return not self[106]
|
|
1393
1474
|
end,
|
|
1394
1475
|
set = function(self, isTeamGlowVisible)
|
|
1395
|
-
|
|
1396
|
-
local
|
|
1476
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1477
|
+
local ____temp_7
|
|
1397
1478
|
if not isTeamGlowVisible then
|
|
1398
|
-
|
|
1479
|
+
____temp_7 = true
|
|
1399
1480
|
else
|
|
1400
|
-
|
|
1481
|
+
____temp_7 = nil
|
|
1401
1482
|
end
|
|
1402
|
-
self[106] =
|
|
1483
|
+
self[106] = ____temp_7
|
|
1403
1484
|
end
|
|
1404
1485
|
},
|
|
1405
1486
|
true
|
|
@@ -1408,9 +1489,9 @@ __TS__SetDescriptor(
|
|
|
1408
1489
|
Unit.prototype,
|
|
1409
1490
|
"color",
|
|
1410
1491
|
{set = function(self, color)
|
|
1411
|
-
|
|
1492
|
+
SetUnitColor(self.handle, color.handle)
|
|
1412
1493
|
if self[106] then
|
|
1413
|
-
|
|
1494
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1414
1495
|
end
|
|
1415
1496
|
end},
|
|
1416
1497
|
true
|
|
@@ -1579,7 +1660,7 @@ __TS__SetDescriptor(
|
|
|
1579
1660
|
"x",
|
|
1580
1661
|
{
|
|
1581
1662
|
get = function(self)
|
|
1582
|
-
return getUnitX(self.handle)
|
|
1663
|
+
return self[107] or getUnitX(self.handle)
|
|
1583
1664
|
end,
|
|
1584
1665
|
set = function(self, v)
|
|
1585
1666
|
SetUnitX(self.handle, v)
|
|
@@ -1592,7 +1673,7 @@ __TS__SetDescriptor(
|
|
|
1592
1673
|
"y",
|
|
1593
1674
|
{
|
|
1594
1675
|
get = function(self)
|
|
1595
|
-
return getUnitY(self.handle)
|
|
1676
|
+
return self[108] or getUnitY(self.handle)
|
|
1596
1677
|
end,
|
|
1597
1678
|
set = function(self, v)
|
|
1598
1679
|
SetUnitY(self.handle, v)
|
|
@@ -1678,10 +1759,10 @@ __TS__SetDescriptor(
|
|
|
1678
1759
|
"gold",
|
|
1679
1760
|
{
|
|
1680
1761
|
get = function(self)
|
|
1681
|
-
return
|
|
1762
|
+
return GetResourceAmount(self.handle)
|
|
1682
1763
|
end,
|
|
1683
1764
|
set = function(self, gold)
|
|
1684
|
-
|
|
1765
|
+
SetResourceAmount(self.handle, gold)
|
|
1685
1766
|
end
|
|
1686
1767
|
},
|
|
1687
1768
|
true
|
|
@@ -1809,6 +1890,19 @@ __TS__SetDescriptor(
|
|
|
1809
1890
|
end},
|
|
1810
1891
|
true
|
|
1811
1892
|
)
|
|
1893
|
+
__TS__SetDescriptor(
|
|
1894
|
+
Unit.prototype,
|
|
1895
|
+
"movementType",
|
|
1896
|
+
{
|
|
1897
|
+
get = function(self)
|
|
1898
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1899
|
+
end,
|
|
1900
|
+
set = function(self, movementType)
|
|
1901
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1902
|
+
end
|
|
1903
|
+
},
|
|
1904
|
+
true
|
|
1905
|
+
)
|
|
1812
1906
|
__TS__SetDescriptor(
|
|
1813
1907
|
Unit.prototype,
|
|
1814
1908
|
"pathing",
|
|
@@ -1990,6 +2084,14 @@ __TS__SetDescriptor(
|
|
|
1990
2084
|
end},
|
|
1991
2085
|
true
|
|
1992
2086
|
)
|
|
2087
|
+
__TS__SetDescriptor(
|
|
2088
|
+
Unit.prototype,
|
|
2089
|
+
"targetAcquiredEvent",
|
|
2090
|
+
{get = function(self)
|
|
2091
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2092
|
+
end},
|
|
2093
|
+
true
|
|
2094
|
+
)
|
|
1993
2095
|
__TS__SetDescriptor(
|
|
1994
2096
|
Unit.prototype,
|
|
1995
2097
|
"onSelect",
|
|
@@ -2125,25 +2227,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2125
2227
|
InitializingEvent,
|
|
2126
2228
|
function(event)
|
|
2127
2229
|
local function listener(unit, id)
|
|
2128
|
-
local
|
|
2230
|
+
local ____GetSpellTargetUnit_result_10
|
|
2129
2231
|
if GetSpellTargetUnit() then
|
|
2130
|
-
|
|
2232
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2131
2233
|
else
|
|
2132
|
-
local
|
|
2234
|
+
local ____GetSpellTargetItem_result_9
|
|
2133
2235
|
if GetSpellTargetItem() then
|
|
2134
|
-
|
|
2236
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2135
2237
|
else
|
|
2136
|
-
local
|
|
2238
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2137
2239
|
if GetSpellTargetDestructable() then
|
|
2138
|
-
|
|
2240
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2139
2241
|
else
|
|
2140
|
-
|
|
2242
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2141
2243
|
end
|
|
2142
|
-
|
|
2244
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2143
2245
|
end
|
|
2144
|
-
|
|
2246
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2145
2247
|
end
|
|
2146
|
-
local target =
|
|
2248
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2147
2249
|
if target then
|
|
2148
2250
|
invoke(event, unit, id, target)
|
|
2149
2251
|
end
|
|
@@ -2315,10 +2417,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2315
2417
|
____exports.UnitTriggerEvent,
|
|
2316
2418
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2317
2419
|
function()
|
|
2318
|
-
local
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2420
|
+
local handle = getOrderedUnit()
|
|
2421
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2422
|
+
local unit = ____exports.Unit:of(handle)
|
|
2423
|
+
if unit.state == 1 then
|
|
2424
|
+
return unit, getIssuedOrderId()
|
|
2425
|
+
end
|
|
2322
2426
|
end
|
|
2323
2427
|
return IgnoreEvent
|
|
2324
2428
|
end
|
|
@@ -2349,13 +2453,19 @@ Unit.onDamaging = (function()
|
|
|
2349
2453
|
if source and source.typeId == dummyUnitId then
|
|
2350
2454
|
source = nil
|
|
2351
2455
|
end
|
|
2352
|
-
local target = BlzGetEventDamageTarget()
|
|
2456
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2457
|
+
local metadata = damageMetadataByTarget[target]
|
|
2458
|
+
damageMetadataByTarget[target] = nil
|
|
2353
2459
|
local data = {
|
|
2354
2460
|
amount = GetEventDamage(),
|
|
2355
|
-
attackType = BlzGetEventAttackType(),
|
|
2461
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2356
2462
|
damageType = BlzGetEventDamageType(),
|
|
2357
2463
|
weaponType = BlzGetEventWeaponType(),
|
|
2358
|
-
|
|
2464
|
+
metadata = metadata,
|
|
2465
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2466
|
+
originalAmount = GetEventDamage(),
|
|
2467
|
+
originalMetadata = metadata,
|
|
2468
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2359
2469
|
}
|
|
2360
2470
|
if data.isAttack and source then
|
|
2361
2471
|
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
|
|
@@ -2369,18 +2479,36 @@ Unit.onDamaging = (function()
|
|
|
2369
2479
|
invoke(
|
|
2370
2480
|
event,
|
|
2371
2481
|
source,
|
|
2372
|
-
|
|
2482
|
+
target,
|
|
2373
2483
|
setmetatable(
|
|
2374
2484
|
{},
|
|
2375
2485
|
{
|
|
2376
2486
|
__index = data,
|
|
2377
2487
|
__newindex = function(self, key, value)
|
|
2378
|
-
damageSetters[key]
|
|
2488
|
+
local damageSetter = damageSetters[key]
|
|
2489
|
+
if damageSetter ~= nil then
|
|
2490
|
+
damageSetter(value)
|
|
2491
|
+
end
|
|
2379
2492
|
data[key] = value
|
|
2380
2493
|
end
|
|
2381
2494
|
}
|
|
2382
2495
|
)
|
|
2383
2496
|
)
|
|
2497
|
+
if data[0] and source then
|
|
2498
|
+
local sourceOwner = source.owner.handle
|
|
2499
|
+
data[1] = sourceOwner
|
|
2500
|
+
local targetOwner = target.owner.handle
|
|
2501
|
+
data[2] = targetOwner
|
|
2502
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2503
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2504
|
+
data[3] = true
|
|
2505
|
+
end
|
|
2506
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2507
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2508
|
+
data[4] = true
|
|
2509
|
+
end
|
|
2510
|
+
end
|
|
2511
|
+
damagingEventByTarget[target] = data
|
|
2384
2512
|
return
|
|
2385
2513
|
end
|
|
2386
2514
|
BlzSetEventDamage(0)
|
|
@@ -2388,7 +2516,7 @@ Unit.onDamaging = (function()
|
|
|
2388
2516
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2389
2517
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2390
2518
|
local sourceOwner = source.owner.handle
|
|
2391
|
-
local targetOwner =
|
|
2519
|
+
local targetOwner = target.owner.handle
|
|
2392
2520
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2393
2521
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2394
2522
|
Timer:run(function()
|
|
@@ -2404,23 +2532,19 @@ Unit.onDamaging = (function()
|
|
|
2404
2532
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2405
2533
|
local condition = ____value[1]
|
|
2406
2534
|
local action = ____value[2]
|
|
2407
|
-
if condition(
|
|
2408
|
-
source,
|
|
2409
|
-
____exports.Unit:of(target),
|
|
2410
|
-
data
|
|
2411
|
-
) then
|
|
2535
|
+
if condition(source, target, data) then
|
|
2412
2536
|
action(
|
|
2413
2537
|
source,
|
|
2414
|
-
|
|
2538
|
+
target,
|
|
2415
2539
|
setmetatable(
|
|
2416
2540
|
{fire = function()
|
|
2417
2541
|
UnitDamageTarget(
|
|
2418
2542
|
source.handle,
|
|
2419
|
-
target,
|
|
2543
|
+
target.handle,
|
|
2420
2544
|
data.amount,
|
|
2421
2545
|
true,
|
|
2422
2546
|
true,
|
|
2423
|
-
data.attackType,
|
|
2547
|
+
attackTypeToNative(data.attackType),
|
|
2424
2548
|
data.damageType,
|
|
2425
2549
|
data.weaponType
|
|
2426
2550
|
)
|
|
@@ -2447,26 +2571,50 @@ Unit.onDamage = __TS__New(
|
|
|
2447
2571
|
if source and source.typeId == dummyUnitId then
|
|
2448
2572
|
source = nil
|
|
2449
2573
|
end
|
|
2574
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2575
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2576
|
+
damagingEventByTarget[target] = nil
|
|
2450
2577
|
local data = {
|
|
2451
2578
|
amount = GetEventDamage(),
|
|
2452
|
-
attackType = BlzGetEventAttackType(),
|
|
2579
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2453
2580
|
damageType = BlzGetEventDamageType(),
|
|
2454
2581
|
weaponType = BlzGetEventWeaponType(),
|
|
2582
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2455
2583
|
isAttack = BlzGetEventIsAttack(),
|
|
2456
|
-
originalAmount = GetEventDamage(),
|
|
2584
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2585
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2457
2586
|
preventDeath = damageEventPreventDeath
|
|
2458
2587
|
}
|
|
2588
|
+
if damagingEvent then
|
|
2589
|
+
for key, value in pairs(damagingEvent) do
|
|
2590
|
+
if isAttribute(key) then
|
|
2591
|
+
data[key] = value
|
|
2592
|
+
end
|
|
2593
|
+
end
|
|
2594
|
+
local sourceOwner = damagingEvent[1]
|
|
2595
|
+
if sourceOwner then
|
|
2596
|
+
local targetOwner = damagingEvent[2]
|
|
2597
|
+
if damagingEvent[3] then
|
|
2598
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2599
|
+
end
|
|
2600
|
+
if damagingEvent[4] then
|
|
2601
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2602
|
+
end
|
|
2603
|
+
end
|
|
2604
|
+
end
|
|
2459
2605
|
local evData = setmetatable(
|
|
2460
2606
|
{},
|
|
2461
2607
|
{
|
|
2462
2608
|
__index = data,
|
|
2463
2609
|
__newindex = function(self, key, value)
|
|
2464
|
-
damageSetters[key]
|
|
2610
|
+
local damageSetter = damageSetters[key]
|
|
2611
|
+
if damageSetter ~= nil then
|
|
2612
|
+
damageSetter(value)
|
|
2613
|
+
end
|
|
2465
2614
|
data[key] = value
|
|
2466
2615
|
end
|
|
2467
2616
|
}
|
|
2468
2617
|
)
|
|
2469
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2470
2618
|
invoke(event, source, target, evData)
|
|
2471
2619
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2472
2620
|
local bonusHealth = math.ceil(evData.amount)
|
|
@@ -2509,8 +2657,9 @@ Unit.itemDroppedEvent = __TS__New(
|
|
|
2509
2657
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2510
2658
|
function()
|
|
2511
2659
|
local unit = getTriggerUnit()
|
|
2512
|
-
|
|
2513
|
-
|
|
2660
|
+
local item = getManipulatedItem()
|
|
2661
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2662
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2514
2663
|
end
|
|
2515
2664
|
return IgnoreEvent
|
|
2516
2665
|
end
|
|
@@ -2519,9 +2668,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2519
2668
|
____exports.UnitTriggerEvent,
|
|
2520
2669
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2521
2670
|
function()
|
|
2522
|
-
local
|
|
2523
|
-
|
|
2524
|
-
|
|
2671
|
+
local unitHandle = getTriggerUnit()
|
|
2672
|
+
local itemHandle = getManipulatedItem()
|
|
2673
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2674
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2675
|
+
local item = Item:of(itemHandle)
|
|
2676
|
+
if item.owner ~= unit then
|
|
2677
|
+
return unit, item
|
|
2678
|
+
end
|
|
2525
2679
|
end
|
|
2526
2680
|
return IgnoreEvent
|
|
2527
2681
|
end
|
|
@@ -2529,16 +2683,59 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2529
2683
|
Unit.itemUsedEvent = __TS__New(
|
|
2530
2684
|
____exports.UnitTriggerEvent,
|
|
2531
2685
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2532
|
-
function()
|
|
2686
|
+
function()
|
|
2687
|
+
local unit = getTriggerUnit()
|
|
2688
|
+
local item = getManipulatedItem()
|
|
2689
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2690
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2691
|
+
end
|
|
2692
|
+
return IgnoreEvent
|
|
2693
|
+
end
|
|
2533
2694
|
)
|
|
2534
2695
|
Unit.itemStackedEvent = __TS__New(
|
|
2535
2696
|
____exports.UnitTriggerEvent,
|
|
2536
2697
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2537
|
-
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(
|
|
2698
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2699
|
+
)
|
|
2700
|
+
__TS__ObjectDefineProperty(
|
|
2701
|
+
Unit,
|
|
2702
|
+
"itemChargesChangedEvent",
|
|
2703
|
+
{get = function(self)
|
|
2704
|
+
local event = __TS__New(Event)
|
|
2705
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2706
|
+
local unit = item.owner
|
|
2707
|
+
if unit ~= nil then
|
|
2708
|
+
invoke(event, unit, item)
|
|
2709
|
+
end
|
|
2710
|
+
end)
|
|
2711
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2712
|
+
return event
|
|
2713
|
+
end}
|
|
2714
|
+
)
|
|
2715
|
+
__TS__ObjectDefineProperty(
|
|
2716
|
+
Unit,
|
|
2717
|
+
"itemUseOrderEvent",
|
|
2718
|
+
{get = function(self)
|
|
2719
|
+
local event = __TS__New(Event)
|
|
2720
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2721
|
+
local slot = order - orderId("useslot0")
|
|
2722
|
+
local function listener(unit)
|
|
2723
|
+
local item = unit.items[slot + 1]
|
|
2724
|
+
if item ~= nil then
|
|
2725
|
+
invoke(event, unit, item)
|
|
2726
|
+
end
|
|
2727
|
+
end
|
|
2728
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2729
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2730
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2731
|
+
end
|
|
2732
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2733
|
+
return event
|
|
2734
|
+
end}
|
|
2538
2735
|
)
|
|
2539
2736
|
__TS__ObjectDefineProperty(
|
|
2540
2737
|
Unit,
|
|
2541
|
-
"
|
|
2738
|
+
"itemMoveOrderEvent",
|
|
2542
2739
|
{get = function(self)
|
|
2543
2740
|
local event = __TS__New(Event)
|
|
2544
2741
|
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
@@ -2556,7 +2753,7 @@ __TS__ObjectDefineProperty(
|
|
|
2556
2753
|
end
|
|
2557
2754
|
end)
|
|
2558
2755
|
end
|
|
2559
|
-
rawset(self, "
|
|
2756
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2560
2757
|
return event
|
|
2561
2758
|
end}
|
|
2562
2759
|
)
|