warscript 0.0.1-dev.0a43a35 → 0.0.1-dev.0ad346c
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/binaryreader.d.ts +1 -0
- package/binaryreader.lua +3 -0
- 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 +8 -0
- package/core/types/frame.lua +117 -22
- 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 -24
- package/core/types/sound.lua +99 -24
- 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/core/util.d.ts +1 -1
- package/core/util.lua +18 -1
- package/decl/native.d.ts +846 -790
- package/destroyable.d.ts +1 -0
- package/destroyable.lua +9 -0
- package/engine/behavior.d.ts +16 -3
- package/engine/behavior.lua +233 -73
- 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 +8 -5
- package/engine/behaviour/ability/apply-buff.lua +36 -4
- package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
- package/engine/behaviour/ability/damage.d.ts +39 -11
- package/engine/behaviour/ability/damage.lua +83 -37
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +43 -0
- package/engine/behaviour/ability/heal.d.ts +33 -6
- package/engine/behaviour/ability/heal.lua +89 -10
- 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 +25 -0
- package/engine/behaviour/ability/remove-buffs.lua +49 -0
- package/engine/behaviour/ability/restore-mana.d.ts +15 -0
- package/engine/behaviour/ability/restore-mana.lua +29 -0
- package/engine/behaviour/ability.d.ts +26 -5
- package/engine/behaviour/ability.lua +137 -43
- package/engine/behaviour/unit/stun-immunity.d.ts +12 -6
- package/engine/behaviour/unit/stun-immunity.lua +57 -31
- package/engine/behaviour/unit.d.ts +45 -2
- package/engine/behaviour/unit.lua +289 -6
- package/engine/buff.d.ts +127 -48
- package/engine/buff.lua +579 -241
- package/engine/game-map.d.ts +7 -0
- package/engine/game-map.lua +32 -0
- package/engine/internal/ability.d.ts +23 -14
- package/engine/internal/ability.lua +129 -85
- package/engine/internal/item/ability.lua +162 -4
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +20 -19
- package/engine/internal/item.lua +191 -74
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- package/engine/internal/mechanics/cast-ability.lua +6 -3
- 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/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 +45 -1
- package/engine/internal/unit/ability.lua +128 -17
- 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/attributes.d.ts +17 -0
- package/engine/internal/unit/attributes.lua +46 -0
- package/engine/internal/unit/bonus.d.ts +8 -2
- package/engine/internal/unit/bonus.lua +33 -1
- package/engine/internal/unit/fly-height.d.ts +7 -0
- package/engine/internal/unit/fly-height.lua +20 -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/interrupts.d.ts +12 -0
- package/engine/internal/unit/interrupts.lua +28 -0
- package/engine/internal/unit/item.d.ts +24 -0
- package/engine/internal/unit/item.lua +78 -0
- package/engine/internal/unit/main-selected.d.ts +13 -0
- package/engine/internal/unit/main-selected.lua +36 -0
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit/range-event.d.ts +12 -0
- package/engine/internal/unit/range-event.lua +90 -0
- package/engine/internal/unit/scale.d.ts +7 -0
- package/engine/internal/unit/scale.lua +20 -0
- package/engine/internal/unit+ability.lua +12 -3
- 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+transport.lua +4 -10
- package/engine/internal/unit-missile-launch.lua +70 -13
- package/engine/internal/unit.d.ts +64 -30
- package/engine/internal/unit.lua +501 -293
- 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 +9 -2
- package/engine/local-client.lua +112 -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/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/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/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/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/reincarnation.d.ts +8 -0
- package/engine/object-data/entry/ability-type/reincarnation.lua +26 -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 +93 -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 +28 -2
- package/engine/object-data/entry/destructible-type.lua +155 -0
- 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 +25 -5
- package/engine/object-data/entry/unit-type.lua +258 -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 +28 -5
- package/engine/object-field/ability.lua +59 -5
- 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 +359 -116
- package/engine/random.d.ts +10 -0
- package/engine/random.lua +21 -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 +4 -2
- package/engine/standard/fields/ability.lua +4 -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 +9 -0
- package/engine/unit.lua +9 -0
- package/index.d.ts +1 -0
- package/index.lua +1 -0
- package/lualib_bundle.lua +7 -2
- package/net/socket.d.ts +7 -1
- package/net/socket.lua +45 -4
- package/network.d.ts +1 -0
- package/network.lua +3 -2
- package/objutil/buff.lua +12 -11
- package/objutil/unit.lua +8 -0
- package/package.json +2 -2
- package/patch-lua.d.ts +0 -0
- package/patch-lua.lua +25 -0
- package/patch-lualib.lua +1 -1
- package/property.d.ts +55 -0
- package/property.lua +374 -0
- package/utility/arrays.d.ts +10 -1
- package/utility/arrays.lua +45 -3
- 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/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
- package/utility/linked-map.d.ts +34 -0
- package/utility/linked-map.lua +101 -0
- package/utility/linked-set.d.ts +15 -3
- package/utility/linked-set.lua +48 -3
- package/utility/lua-maps.d.ts +15 -2
- package/utility/lua-maps.lua +53 -2
- package/utility/lua-sets.d.ts +2 -0
- package/utility/lua-sets.lua +7 -0
- package/utility/records.lua +20 -1
- package/utility/reflection.lua +11 -7
- package/utility/types.d.ts +4 -0
- package/core/mapbounds.d.ts +0 -8
- package/core/mapbounds.lua +0 -12
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
package/engine/internal/unit.lua
CHANGED
|
@@ -51,33 +51,42 @@ 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
|
|
65
|
+
local ____synchronization = require("engine.synchronization")
|
|
66
|
+
local synchronizer = ____synchronization.synchronizer
|
|
67
|
+
local ____linked_2Dmap = require("utility.linked-map")
|
|
68
|
+
local LinkedMap = ____linked_2Dmap.LinkedMap
|
|
54
69
|
local match = string.match
|
|
55
70
|
local ____tostring = _G.tostring
|
|
56
71
|
local setUnitAnimation = SetUnitAnimation
|
|
57
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
58
72
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
59
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
60
73
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
61
74
|
local getUnitRealField = BlzGetUnitRealField
|
|
62
75
|
local getHeroStr = GetHeroStr
|
|
63
76
|
local getHeroAgi = GetHeroAgi
|
|
64
77
|
local getHeroInt = GetHeroInt
|
|
65
|
-
local setHeroStr = SetHeroStr
|
|
66
|
-
local setHeroAgi = SetHeroAgi
|
|
67
|
-
local setHeroInt = SetHeroInt
|
|
68
78
|
local getUnitBooleanField = BlzGetUnitBooleanField
|
|
69
79
|
local getUnitStringField = BlzGetUnitStringField
|
|
70
80
|
local setUnitIntegerField = BlzSetUnitIntegerField
|
|
71
81
|
local setUnitRealField = BlzSetUnitRealField
|
|
72
82
|
local setUnitBooleanField = BlzSetUnitBooleanField
|
|
73
83
|
local setUnitStringField = BlzSetUnitStringField
|
|
74
|
-
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,15 +102,12 @@ 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
|
|
101
108
|
local setUnitWeaponStringField = BlzSetUnitWeaponStringField
|
|
102
109
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
103
110
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
104
|
-
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
105
111
|
local isUnitInvisible = IsUnitInvisible
|
|
106
112
|
local isUnitVisible = IsUnitVisible
|
|
107
113
|
local getUnitX = GetUnitX
|
|
@@ -118,15 +124,9 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
118
124
|
local getIssuedOrderId = GetIssuedOrderId
|
|
119
125
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
120
126
|
local unitAlive = UnitAlive
|
|
121
|
-
local unitAddType = UnitAddType
|
|
122
|
-
local unitRemoveType = UnitRemoveType
|
|
123
|
-
local isUnitIllusion = IsUnitIllusion
|
|
124
|
-
local isUnitType = IsUnitType
|
|
125
127
|
local isUnitAlly = IsUnitAlly
|
|
126
128
|
local isUnitEnemy = IsUnitEnemy
|
|
127
129
|
local getOwningPlayer = GetOwningPlayer
|
|
128
|
-
local setUnitColor = SetUnitColor
|
|
129
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
130
130
|
____exports.UnitClassification = {}
|
|
131
131
|
local UnitClassification = ____exports.UnitClassification
|
|
132
132
|
do
|
|
@@ -136,6 +136,7 @@ do
|
|
|
136
136
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
137
137
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
138
138
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
139
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
139
140
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
140
141
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
141
142
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -290,7 +291,6 @@ local function dispatch(event, idGetter, argsGetter)
|
|
|
290
291
|
return event[id]
|
|
291
292
|
end
|
|
292
293
|
if not initialized then
|
|
293
|
-
local invoke = Event.invoke
|
|
294
294
|
event:addListener(function(...)
|
|
295
295
|
local id = idGetter(...)
|
|
296
296
|
local dispatched = rawget(self, id)
|
|
@@ -328,7 +328,6 @@ local function dispatchAbility(event)
|
|
|
328
328
|
return event[id]
|
|
329
329
|
end
|
|
330
330
|
if not initialized then
|
|
331
|
-
local invoke = Event.invoke
|
|
332
331
|
event:addListener(function(unit, ability, ...)
|
|
333
332
|
local dispatched = rawget(self, ability.typeId)
|
|
334
333
|
if dispatched ~= nil then
|
|
@@ -345,6 +344,9 @@ local function dispatchAbility(event)
|
|
|
345
344
|
}
|
|
346
345
|
)
|
|
347
346
|
end
|
|
347
|
+
local function damagingEventPreventRetaliation(self)
|
|
348
|
+
self[0] = true
|
|
349
|
+
end
|
|
348
350
|
local function damageEventPreventDeath(self, callback, ...)
|
|
349
351
|
if self[0] ~= nil then
|
|
350
352
|
return
|
|
@@ -356,7 +358,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
356
358
|
rawset(self, 1 + i, (select(i, ...)))
|
|
357
359
|
end
|
|
358
360
|
end
|
|
359
|
-
local damageSetters = {
|
|
361
|
+
local damageSetters = {
|
|
362
|
+
amount = BlzSetEventDamage,
|
|
363
|
+
attackType = function(attackType)
|
|
364
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
365
|
+
end,
|
|
366
|
+
damageType = BlzSetEventDamageType,
|
|
367
|
+
weaponType = BlzSetEventWeaponType
|
|
368
|
+
}
|
|
360
369
|
local jlimitopByOperator = {
|
|
361
370
|
[0] = LESS_THAN_OR_EQUAL,
|
|
362
371
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -374,15 +383,27 @@ local modifiers = {
|
|
|
374
383
|
end,
|
|
375
384
|
armor = function(unit, value)
|
|
376
385
|
if UnitAddAbility(unit, armorBonusAbilityId) then
|
|
377
|
-
assert(
|
|
386
|
+
assert(
|
|
387
|
+
UnitMakeAbilityPermanent(unit, true, armorBonusAbilityId),
|
|
388
|
+
"armor bonus ability must be made permanent",
|
|
389
|
+
unit
|
|
390
|
+
)
|
|
378
391
|
end
|
|
379
|
-
local ability = assert(
|
|
380
|
-
|
|
381
|
-
ability,
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
392
|
+
local ability = assert(
|
|
393
|
+
BlzGetUnitAbility(unit, armorBonusAbilityId),
|
|
394
|
+
"armor bonus ability must be existing",
|
|
395
|
+
unit
|
|
396
|
+
)
|
|
397
|
+
assert(
|
|
398
|
+
BlzSetAbilityRealLevelField(
|
|
399
|
+
ability,
|
|
400
|
+
armorBonusField,
|
|
401
|
+
0,
|
|
402
|
+
BlzGetAbilityRealLevelField(ability, armorBonusField, 0) + value
|
|
403
|
+
),
|
|
404
|
+
"armor bonus ability field must be set",
|
|
405
|
+
unit
|
|
406
|
+
)
|
|
386
407
|
end
|
|
387
408
|
}
|
|
388
409
|
local getters = {
|
|
@@ -400,6 +421,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
|
400
421
|
self.unit = unit
|
|
401
422
|
self.index = index
|
|
402
423
|
end
|
|
424
|
+
__TS__SetDescriptor(
|
|
425
|
+
UnitWeapon.prototype,
|
|
426
|
+
"isEnabled",
|
|
427
|
+
{
|
|
428
|
+
get = function(self)
|
|
429
|
+
return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
|
|
430
|
+
end,
|
|
431
|
+
set = function(self, isEnabled)
|
|
432
|
+
BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
|
|
433
|
+
end
|
|
434
|
+
},
|
|
435
|
+
true
|
|
436
|
+
)
|
|
403
437
|
__TS__SetDescriptor(
|
|
404
438
|
UnitWeapon.prototype,
|
|
405
439
|
"cooldown",
|
|
@@ -434,6 +468,19 @@ __TS__SetDescriptor(
|
|
|
434
468
|
},
|
|
435
469
|
true
|
|
436
470
|
)
|
|
471
|
+
__TS__SetDescriptor(
|
|
472
|
+
UnitWeapon.prototype,
|
|
473
|
+
"allowedTargetCombatClassifications",
|
|
474
|
+
{
|
|
475
|
+
get = function(self)
|
|
476
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
477
|
+
end,
|
|
478
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
479
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
480
|
+
end
|
|
481
|
+
},
|
|
482
|
+
true
|
|
483
|
+
)
|
|
437
484
|
__TS__SetDescriptor(
|
|
438
485
|
UnitWeapon.prototype,
|
|
439
486
|
"damageBase",
|
|
@@ -564,17 +611,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
564
611
|
____exports.Unit:of(unit)
|
|
565
612
|
)
|
|
566
613
|
end
|
|
567
|
-
if not unitAddAbility(unit, abilityId) then
|
|
568
|
-
if getUnitAbility(unit, abilityId) == ability then
|
|
569
|
-
return UnitAbility:of(
|
|
570
|
-
ability,
|
|
571
|
-
abilityId,
|
|
572
|
-
____exports.Unit:of(unit)
|
|
573
|
-
)
|
|
574
|
-
end
|
|
575
|
-
else
|
|
576
|
-
unitRemoveAbility(unit, abilityId)
|
|
577
|
-
end
|
|
578
614
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
579
615
|
local item = unitItemInSlot(unit, i)
|
|
580
616
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -621,26 +657,30 @@ local fieldSetters = {
|
|
|
621
657
|
}
|
|
622
658
|
local dummies = {}
|
|
623
659
|
for ____, player in ipairs(Player.all) do
|
|
624
|
-
local dummy = assert(
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
660
|
+
local dummy = assert(
|
|
661
|
+
createUnit(
|
|
662
|
+
player.handle,
|
|
663
|
+
dummyUnitId,
|
|
664
|
+
0,
|
|
665
|
+
0,
|
|
666
|
+
270
|
|
667
|
+
),
|
|
668
|
+
"dummy must be created",
|
|
669
|
+
player
|
|
670
|
+
)
|
|
631
671
|
ShowUnit(dummy, false)
|
|
632
672
|
dummies[player] = dummy
|
|
633
673
|
end
|
|
634
674
|
local function delayHealthChecksCallback(unit)
|
|
635
|
-
local counter = (unit[
|
|
675
|
+
local counter = (unit[104] or 0) - 1
|
|
636
676
|
if counter ~= 0 then
|
|
637
|
-
unit[
|
|
677
|
+
unit[104] = counter
|
|
638
678
|
return
|
|
639
679
|
end
|
|
640
|
-
unit[
|
|
641
|
-
local healthBonus = unit[
|
|
680
|
+
unit[104] = nil
|
|
681
|
+
local healthBonus = unit[105]
|
|
642
682
|
if healthBonus ~= nil then
|
|
643
|
-
unit[
|
|
683
|
+
unit[105] = nil
|
|
644
684
|
local handle = unit.handle
|
|
645
685
|
BlzSetUnitMaxHP(
|
|
646
686
|
handle,
|
|
@@ -648,45 +688,79 @@ local function delayHealthChecksCallback(unit)
|
|
|
648
688
|
)
|
|
649
689
|
end
|
|
650
690
|
end
|
|
691
|
+
local nextSyncId = 1
|
|
692
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
693
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
694
|
+
local function addAbility(unit, abilityTypeId)
|
|
695
|
+
local ____unitAddAbility_result_0
|
|
696
|
+
if unitAddAbility(unit, abilityTypeId) then
|
|
697
|
+
____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
|
|
698
|
+
else
|
|
699
|
+
____unitAddAbility_result_0 = nil
|
|
700
|
+
end
|
|
701
|
+
return ____unitAddAbility_result_0
|
|
702
|
+
end
|
|
651
703
|
____exports.Unit = __TS__Class()
|
|
652
704
|
local Unit = ____exports.Unit
|
|
653
705
|
Unit.name = "Unit"
|
|
654
706
|
__TS__ClassExtends(Unit, Handle)
|
|
655
707
|
function Unit.prototype.____constructor(self, handle)
|
|
656
708
|
Handle.prototype.____constructor(self, handle)
|
|
709
|
+
local ____nextSyncId_1 = nextSyncId
|
|
710
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
711
|
+
self.syncId = ____nextSyncId_1
|
|
657
712
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
658
|
-
assert(
|
|
659
|
-
|
|
713
|
+
assert(
|
|
714
|
+
unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId),
|
|
715
|
+
"leave detection ability must be added",
|
|
716
|
+
self
|
|
717
|
+
)
|
|
718
|
+
assert(
|
|
719
|
+
unitAddAbility(handle, morphDetectAbilityId),
|
|
720
|
+
"morph detection ability must be added",
|
|
721
|
+
self
|
|
722
|
+
)
|
|
660
723
|
if unitAddAbility(
|
|
661
724
|
handle,
|
|
662
725
|
fourCC("Amrf")
|
|
663
726
|
) then
|
|
664
|
-
assert(
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
727
|
+
assert(
|
|
728
|
+
unitRemoveAbility(
|
|
729
|
+
handle,
|
|
730
|
+
fourCC("Amrf")
|
|
731
|
+
),
|
|
732
|
+
"fly ability must be removed after addition",
|
|
733
|
+
self
|
|
734
|
+
)
|
|
668
735
|
end
|
|
736
|
+
unitBySyncId[self.syncId] = self
|
|
669
737
|
local ____ = self.abilities
|
|
670
738
|
end
|
|
671
|
-
function Unit.prototype.getEvent(self,
|
|
672
|
-
self.events = self.events or (
|
|
673
|
-
local eventId = GetHandleId(
|
|
674
|
-
|
|
675
|
-
|
|
739
|
+
function Unit.prototype.getEvent(self, jevent, collector)
|
|
740
|
+
self.events = self.events or __TS__New(LinkedMap)
|
|
741
|
+
local eventId = GetHandleId(jevent)
|
|
742
|
+
local event = self.events:get(eventId)
|
|
743
|
+
if event == nil then
|
|
744
|
+
event = __TS__New(
|
|
676
745
|
TriggerEvent,
|
|
677
746
|
function(trigger)
|
|
678
|
-
TriggerRegisterUnitEvent(trigger, self.handle,
|
|
747
|
+
TriggerRegisterUnitEvent(trigger, self.handle, jevent)
|
|
679
748
|
end,
|
|
680
749
|
collector or (function() return {} end)
|
|
681
750
|
)
|
|
751
|
+
self.events:put(eventId, event)
|
|
682
752
|
end
|
|
683
|
-
return
|
|
753
|
+
return event
|
|
754
|
+
end
|
|
755
|
+
function Unit.prototype.saveData(self)
|
|
756
|
+
local handle = self.handle
|
|
757
|
+
self[108] = self[108] or getUnitX(handle)
|
|
758
|
+
self[109] = self[109] or getUnitY(handle)
|
|
759
|
+
self._owner = self._owner or Player:of(getOwningPlayer(handle))
|
|
684
760
|
end
|
|
685
761
|
function Unit.prototype.onDestroy(self)
|
|
686
762
|
local handle = self.handle
|
|
687
|
-
|
|
688
|
-
self._owner = Player:of(getOwningPlayer(handle))
|
|
689
|
-
end
|
|
763
|
+
self:saveData()
|
|
690
764
|
local abilities = self.abilities
|
|
691
765
|
for ____, ability in ipairs(abilities) do
|
|
692
766
|
ability:destroy()
|
|
@@ -706,6 +780,10 @@ function Unit.prototype.onDestroy(self)
|
|
|
706
780
|
if eventsToDestroy ~= nil then
|
|
707
781
|
forEach(eventsToDestroy, "destroy")
|
|
708
782
|
end
|
|
783
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) > 0 then
|
|
784
|
+
unitRemoveAbility(handle, leaveDetectAbilityId)
|
|
785
|
+
removeUnit(handle)
|
|
786
|
+
end
|
|
709
787
|
return Handle.prototype.onDestroy(self)
|
|
710
788
|
end
|
|
711
789
|
function Unit.prototype.addAttackHandler(self, condition, action)
|
|
@@ -718,7 +796,11 @@ function Unit.prototype.addAttackHandler(self, condition, action)
|
|
|
718
796
|
self._attackHandlers = handlers
|
|
719
797
|
if #handlers == 1 then
|
|
720
798
|
local handle = self.handle
|
|
721
|
-
assert(
|
|
799
|
+
assert(
|
|
800
|
+
unitAddAbility(handle, attackHandlerAbilityId) and UnitMakeAbilityPermanent(handle, true, attackHandlerAbilityId),
|
|
801
|
+
"attack handler ability must be added",
|
|
802
|
+
self
|
|
803
|
+
)
|
|
722
804
|
end
|
|
723
805
|
return handler
|
|
724
806
|
end
|
|
@@ -747,17 +829,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
747
829
|
end}
|
|
748
830
|
end
|
|
749
831
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
750
|
-
local
|
|
751
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
832
|
+
local ____combatClassification_2 = combatClassification
|
|
833
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
|
|
752
834
|
end
|
|
753
835
|
function Unit.prototype.addClassification(self, classification)
|
|
754
|
-
return
|
|
836
|
+
return UnitAddType(self.handle, classification)
|
|
755
837
|
end
|
|
756
838
|
function Unit.prototype.removeClassification(self, classification)
|
|
757
|
-
return
|
|
839
|
+
return UnitRemoveType(self.handle, classification)
|
|
758
840
|
end
|
|
759
841
|
function Unit.prototype.hasClassification(self, classification)
|
|
760
|
-
return
|
|
842
|
+
return IsUnitType(self.handle, classification)
|
|
761
843
|
end
|
|
762
844
|
function Unit.prototype.isVisibleTo(self, player)
|
|
763
845
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -766,13 +848,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
766
848
|
return isUnitInvisible(self.handle, player.handle)
|
|
767
849
|
end
|
|
768
850
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
769
|
-
local
|
|
851
|
+
local ____temp_3
|
|
770
852
|
if type(x) == "number" then
|
|
771
|
-
|
|
853
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
772
854
|
else
|
|
773
|
-
|
|
855
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
774
856
|
end
|
|
775
|
-
return
|
|
857
|
+
return ____temp_3
|
|
776
858
|
end
|
|
777
859
|
function Unit.prototype.isAllyOf(self, unit)
|
|
778
860
|
return isUnitAlly(
|
|
@@ -790,16 +872,30 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
790
872
|
if type(animation) == "number" then
|
|
791
873
|
setUnitAnimationByIndex(self.handle, animation)
|
|
792
874
|
elseif rarity then
|
|
793
|
-
|
|
875
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
794
876
|
else
|
|
795
877
|
setUnitAnimation(self.handle, animation)
|
|
796
878
|
end
|
|
797
879
|
end
|
|
880
|
+
function Unit.prototype.resetAnimation(self)
|
|
881
|
+
ResetUnitAnimation(self.handle)
|
|
882
|
+
end
|
|
798
883
|
function Unit.prototype.queueAnimation(self, animation)
|
|
799
|
-
|
|
884
|
+
QueueUnitAnimation(self.handle, animation)
|
|
885
|
+
end
|
|
886
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
887
|
+
local firstWeapon = self.firstWeapon
|
|
888
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
889
|
+
return firstWeapon
|
|
890
|
+
end
|
|
891
|
+
local secondWeapon = self.secondWeapon
|
|
892
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
893
|
+
return secondWeapon
|
|
894
|
+
end
|
|
895
|
+
return nil
|
|
800
896
|
end
|
|
801
897
|
function Unit.prototype.delayHealthChecks(self)
|
|
802
|
-
self[
|
|
898
|
+
self[104] = (self[104] or 0) + 1
|
|
803
899
|
Timer:run(delayHealthChecksCallback, self)
|
|
804
900
|
end
|
|
805
901
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -809,21 +905,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
809
905
|
return IsUnitSelected(self.handle, player.handle)
|
|
810
906
|
end
|
|
811
907
|
function Unit.prototype.explode(self)
|
|
812
|
-
|
|
908
|
+
SetUnitExploded(self.handle, true)
|
|
813
909
|
killUnit(self.handle)
|
|
814
910
|
end
|
|
815
911
|
function Unit.prototype.kill(self)
|
|
816
912
|
killUnit(self.handle)
|
|
817
913
|
end
|
|
818
914
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
819
|
-
local
|
|
820
|
-
local
|
|
821
|
-
local
|
|
822
|
-
if
|
|
823
|
-
|
|
915
|
+
local ____ReviveHero_6 = ReviveHero
|
|
916
|
+
local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
|
|
917
|
+
local ____doEffect_4 = doEffect
|
|
918
|
+
if ____doEffect_4 == nil then
|
|
919
|
+
____doEffect_4 = false
|
|
824
920
|
end
|
|
825
|
-
__TS__SparseArrayPush(
|
|
826
|
-
|
|
921
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
922
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
827
923
|
end
|
|
828
924
|
function Unit.prototype.healTarget(self, target, amount)
|
|
829
925
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -863,20 +959,19 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
863
959
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
864
960
|
end
|
|
865
961
|
function Unit.prototype.itemInSlot(self, slot)
|
|
866
|
-
return Item:of(
|
|
962
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
867
963
|
end
|
|
868
964
|
function Unit.prototype.addAbility(self, abilityId)
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
965
|
+
local ability = UnitAbility:of(
|
|
966
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
967
|
+
abilityId,
|
|
968
|
+
self
|
|
969
|
+
)
|
|
970
|
+
if ability ~= nil then
|
|
875
971
|
local abilities = self.abilities
|
|
876
972
|
abilities[#abilities + 1] = ability
|
|
877
|
-
return ability
|
|
878
973
|
end
|
|
879
|
-
return
|
|
974
|
+
return ability
|
|
880
975
|
end
|
|
881
976
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
882
977
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -890,31 +985,21 @@ end
|
|
|
890
985
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
891
986
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
892
987
|
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
|
-
)
|
|
988
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
989
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
990
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
904
991
|
end
|
|
905
|
-
function Unit.prototype.removeAbility(self,
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
end
|
|
992
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
993
|
+
local abilities = self.abilities
|
|
994
|
+
for i = 1, #abilities do
|
|
995
|
+
if abilities[i].typeId == abilityTypeId then
|
|
996
|
+
local ability = abilities[i]
|
|
997
|
+
tremove(abilities, i)
|
|
998
|
+
ability:destroy()
|
|
999
|
+
return true
|
|
914
1000
|
end
|
|
915
|
-
return true
|
|
916
1001
|
end
|
|
917
|
-
return
|
|
1002
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
918
1003
|
end
|
|
919
1004
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
920
1005
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -928,12 +1013,16 @@ end
|
|
|
928
1013
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
929
1014
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
930
1015
|
end
|
|
931
|
-
function Unit.prototype.interruptAttack(self)
|
|
932
|
-
unitInterruptAttack(self.handle)
|
|
933
|
-
end
|
|
934
1016
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
935
|
-
|
|
936
|
-
unitDisableAbility(
|
|
1017
|
+
local handle = self.handle
|
|
1018
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
1019
|
+
Timer:run(
|
|
1020
|
+
unitDisableAbility,
|
|
1021
|
+
handle,
|
|
1022
|
+
abilityId,
|
|
1023
|
+
false,
|
|
1024
|
+
false
|
|
1025
|
+
)
|
|
937
1026
|
end
|
|
938
1027
|
function Unit.prototype.getDistanceTo(self, target)
|
|
939
1028
|
local handle = self.handle
|
|
@@ -993,18 +1082,44 @@ function Unit.prototype.unpauseEx(self)
|
|
|
993
1082
|
self:decrementStunCounter()
|
|
994
1083
|
end
|
|
995
1084
|
function Unit.prototype.incrementStunCounter(self)
|
|
996
|
-
local stunCounter = self[
|
|
997
|
-
if not self[
|
|
1085
|
+
local stunCounter = self[102] or 0
|
|
1086
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
|
|
998
1087
|
BlzPauseUnitEx(self.handle, true)
|
|
999
1088
|
end
|
|
1000
|
-
self[
|
|
1089
|
+
self[102] = stunCounter + 1
|
|
1001
1090
|
end
|
|
1002
1091
|
function Unit.prototype.decrementStunCounter(self)
|
|
1003
|
-
local stunCounter = self[
|
|
1004
|
-
if not self[
|
|
1092
|
+
local stunCounter = self[102] or 0
|
|
1093
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
|
|
1005
1094
|
BlzPauseUnitEx(self.handle, false)
|
|
1006
1095
|
end
|
|
1007
|
-
self[
|
|
1096
|
+
self[102] = stunCounter - 1
|
|
1097
|
+
end
|
|
1098
|
+
function Unit.prototype.incrementForceStunCounter(self)
|
|
1099
|
+
local forceStunCounter = self[103] or 0
|
|
1100
|
+
if forceStunCounter == 0 then
|
|
1101
|
+
local handle = self.handle
|
|
1102
|
+
if not self[101] then
|
|
1103
|
+
for _ = self[102] or 0, -1 do
|
|
1104
|
+
BlzPauseUnitEx(handle, true)
|
|
1105
|
+
end
|
|
1106
|
+
end
|
|
1107
|
+
BlzPauseUnitEx(handle, true)
|
|
1108
|
+
end
|
|
1109
|
+
self[103] = forceStunCounter + 1
|
|
1110
|
+
end
|
|
1111
|
+
function Unit.prototype.decrementForceStunCounter(self)
|
|
1112
|
+
local forceStunCounter = self[103] or 0
|
|
1113
|
+
if forceStunCounter == 1 then
|
|
1114
|
+
local handle = self.handle
|
|
1115
|
+
if not self[101] then
|
|
1116
|
+
for _ = self[102] or 0, -1 do
|
|
1117
|
+
BlzPauseUnitEx(handle, false)
|
|
1118
|
+
end
|
|
1119
|
+
end
|
|
1120
|
+
BlzPauseUnitEx(handle, false)
|
|
1121
|
+
end
|
|
1122
|
+
self[103] = forceStunCounter - 1
|
|
1008
1123
|
end
|
|
1009
1124
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1010
1125
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -1106,8 +1221,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
1106
1221
|
)
|
|
1107
1222
|
return targetCollection
|
|
1108
1223
|
end
|
|
1109
|
-
function Unit.getSelectionOf(self, player)
|
|
1110
|
-
|
|
1224
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1225
|
+
if target == nil then
|
|
1226
|
+
target = {}
|
|
1227
|
+
end
|
|
1228
|
+
targetCollection = target
|
|
1111
1229
|
targetCollectionNextIndex = 1
|
|
1112
1230
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
1113
1231
|
return targetCollection
|
|
@@ -1129,6 +1247,9 @@ end
|
|
|
1129
1247
|
function Unit.prototype.__tostring(self)
|
|
1130
1248
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
1131
1249
|
end
|
|
1250
|
+
function Unit.getBySyncId(self, syncId)
|
|
1251
|
+
return unitBySyncId[syncId]
|
|
1252
|
+
end
|
|
1132
1253
|
__TS__SetDescriptor(
|
|
1133
1254
|
Unit.prototype,
|
|
1134
1255
|
"_deltas",
|
|
@@ -1188,7 +1309,15 @@ __TS__SetDescriptor(
|
|
|
1188
1309
|
Unit.prototype,
|
|
1189
1310
|
"isIllusion",
|
|
1190
1311
|
{get = function(self)
|
|
1191
|
-
return
|
|
1312
|
+
return IsUnitIllusion(self.handle)
|
|
1313
|
+
end},
|
|
1314
|
+
true
|
|
1315
|
+
)
|
|
1316
|
+
__TS__SetDescriptor(
|
|
1317
|
+
Unit.prototype,
|
|
1318
|
+
"isStunned",
|
|
1319
|
+
{get = function(self)
|
|
1320
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1192
1321
|
end},
|
|
1193
1322
|
true
|
|
1194
1323
|
)
|
|
@@ -1267,13 +1396,13 @@ __TS__SetDescriptor(
|
|
|
1267
1396
|
)
|
|
1268
1397
|
__TS__SetDescriptor(
|
|
1269
1398
|
Unit.prototype,
|
|
1270
|
-
"
|
|
1399
|
+
"primaryAttribute",
|
|
1271
1400
|
{
|
|
1272
1401
|
get = function(self)
|
|
1273
|
-
return
|
|
1402
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1274
1403
|
end,
|
|
1275
|
-
set = function(self,
|
|
1276
|
-
|
|
1404
|
+
set = function(self, primaryAttribute)
|
|
1405
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1277
1406
|
end
|
|
1278
1407
|
},
|
|
1279
1408
|
true
|
|
@@ -1295,19 +1424,6 @@ __TS__SetDescriptor(
|
|
|
1295
1424
|
end},
|
|
1296
1425
|
true
|
|
1297
1426
|
)
|
|
1298
|
-
__TS__SetDescriptor(
|
|
1299
|
-
Unit.prototype,
|
|
1300
|
-
"agilityBase",
|
|
1301
|
-
{
|
|
1302
|
-
get = function(self)
|
|
1303
|
-
return getHeroAgi(self.handle, false)
|
|
1304
|
-
end,
|
|
1305
|
-
set = function(self, agilityBase)
|
|
1306
|
-
setHeroAgi(self.handle, agilityBase, true)
|
|
1307
|
-
end
|
|
1308
|
-
},
|
|
1309
|
-
true
|
|
1310
|
-
)
|
|
1311
1427
|
__TS__SetDescriptor(
|
|
1312
1428
|
Unit.prototype,
|
|
1313
1429
|
"agilityBonus",
|
|
@@ -1325,19 +1441,6 @@ __TS__SetDescriptor(
|
|
|
1325
1441
|
end},
|
|
1326
1442
|
true
|
|
1327
1443
|
)
|
|
1328
|
-
__TS__SetDescriptor(
|
|
1329
|
-
Unit.prototype,
|
|
1330
|
-
"intelligenceBase",
|
|
1331
|
-
{
|
|
1332
|
-
get = function(self)
|
|
1333
|
-
return getHeroInt(self.handle, false)
|
|
1334
|
-
end,
|
|
1335
|
-
set = function(self, intelligenceBase)
|
|
1336
|
-
setHeroInt(self.handle, intelligenceBase, true)
|
|
1337
|
-
end
|
|
1338
|
-
},
|
|
1339
|
-
true
|
|
1340
|
-
)
|
|
1341
1444
|
__TS__SetDescriptor(
|
|
1342
1445
|
Unit.prototype,
|
|
1343
1446
|
"intelligenceBonus",
|
|
@@ -1386,17 +1489,17 @@ __TS__SetDescriptor(
|
|
|
1386
1489
|
"isTeamGlowVisible",
|
|
1387
1490
|
{
|
|
1388
1491
|
get = function(self)
|
|
1389
|
-
return not self[
|
|
1492
|
+
return not self[107]
|
|
1390
1493
|
end,
|
|
1391
1494
|
set = function(self, isTeamGlowVisible)
|
|
1392
|
-
|
|
1393
|
-
local
|
|
1495
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1496
|
+
local ____temp_7
|
|
1394
1497
|
if not isTeamGlowVisible then
|
|
1395
|
-
|
|
1498
|
+
____temp_7 = true
|
|
1396
1499
|
else
|
|
1397
|
-
|
|
1500
|
+
____temp_7 = nil
|
|
1398
1501
|
end
|
|
1399
|
-
self[
|
|
1502
|
+
self[107] = ____temp_7
|
|
1400
1503
|
end
|
|
1401
1504
|
},
|
|
1402
1505
|
true
|
|
@@ -1405,9 +1508,9 @@ __TS__SetDescriptor(
|
|
|
1405
1508
|
Unit.prototype,
|
|
1406
1509
|
"color",
|
|
1407
1510
|
{set = function(self, color)
|
|
1408
|
-
|
|
1409
|
-
if self[
|
|
1410
|
-
|
|
1511
|
+
SetUnitColor(self.handle, color.handle)
|
|
1512
|
+
if self[107] then
|
|
1513
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1411
1514
|
end
|
|
1412
1515
|
end},
|
|
1413
1516
|
true
|
|
@@ -1430,14 +1533,14 @@ __TS__SetDescriptor(
|
|
|
1430
1533
|
"maxHealth",
|
|
1431
1534
|
{
|
|
1432
1535
|
get = function(self)
|
|
1433
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1536
|
+
return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
|
|
1434
1537
|
end,
|
|
1435
1538
|
set = function(self, maxHealth)
|
|
1436
|
-
if maxHealth < 1 and self[
|
|
1437
|
-
self[
|
|
1539
|
+
if maxHealth < 1 and self[104] ~= nil then
|
|
1540
|
+
self[105] = (self[105] or 0) + (1 - maxHealth)
|
|
1438
1541
|
maxHealth = 1
|
|
1439
1542
|
end
|
|
1440
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1543
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
|
|
1441
1544
|
end
|
|
1442
1545
|
},
|
|
1443
1546
|
true
|
|
@@ -1479,10 +1582,10 @@ __TS__SetDescriptor(
|
|
|
1479
1582
|
"health",
|
|
1480
1583
|
{
|
|
1481
1584
|
get = function(self)
|
|
1482
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1585
|
+
return GetWidgetLife(self.handle) - (self[106] or 0)
|
|
1483
1586
|
end,
|
|
1484
1587
|
set = function(self, health)
|
|
1485
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1588
|
+
SetWidgetLife(self.handle, health + (self[106] or 0))
|
|
1486
1589
|
end
|
|
1487
1590
|
},
|
|
1488
1591
|
true
|
|
@@ -1558,25 +1661,12 @@ __TS__SetDescriptor(
|
|
|
1558
1661
|
},
|
|
1559
1662
|
true
|
|
1560
1663
|
)
|
|
1561
|
-
__TS__SetDescriptor(
|
|
1562
|
-
Unit.prototype,
|
|
1563
|
-
"flyHeight",
|
|
1564
|
-
{
|
|
1565
|
-
get = function(self)
|
|
1566
|
-
return getUnitFlyHeight(self.handle)
|
|
1567
|
-
end,
|
|
1568
|
-
set = function(self, v)
|
|
1569
|
-
SetUnitFlyHeight(self.handle, v, 100000)
|
|
1570
|
-
end
|
|
1571
|
-
},
|
|
1572
|
-
true
|
|
1573
|
-
)
|
|
1574
1664
|
__TS__SetDescriptor(
|
|
1575
1665
|
Unit.prototype,
|
|
1576
1666
|
"x",
|
|
1577
1667
|
{
|
|
1578
1668
|
get = function(self)
|
|
1579
|
-
return getUnitX(self.handle)
|
|
1669
|
+
return self[108] or getUnitX(self.handle)
|
|
1580
1670
|
end,
|
|
1581
1671
|
set = function(self, v)
|
|
1582
1672
|
SetUnitX(self.handle, v)
|
|
@@ -1589,7 +1679,7 @@ __TS__SetDescriptor(
|
|
|
1589
1679
|
"y",
|
|
1590
1680
|
{
|
|
1591
1681
|
get = function(self)
|
|
1592
|
-
return getUnitY(self.handle)
|
|
1682
|
+
return self[109] or getUnitY(self.handle)
|
|
1593
1683
|
end,
|
|
1594
1684
|
set = function(self, v)
|
|
1595
1685
|
SetUnitY(self.handle, v)
|
|
@@ -1675,10 +1765,10 @@ __TS__SetDescriptor(
|
|
|
1675
1765
|
"gold",
|
|
1676
1766
|
{
|
|
1677
1767
|
get = function(self)
|
|
1678
|
-
return
|
|
1768
|
+
return GetResourceAmount(self.handle)
|
|
1679
1769
|
end,
|
|
1680
1770
|
set = function(self, gold)
|
|
1681
|
-
|
|
1771
|
+
SetResourceAmount(self.handle, gold)
|
|
1682
1772
|
end
|
|
1683
1773
|
},
|
|
1684
1774
|
true
|
|
@@ -1693,17 +1783,21 @@ __TS__SetDescriptor(
|
|
|
1693
1783
|
set = function(self, isPaused)
|
|
1694
1784
|
local handle = self.handle
|
|
1695
1785
|
if isPaused and not IsUnitPaused(handle) then
|
|
1696
|
-
self[
|
|
1697
|
-
|
|
1698
|
-
|
|
1786
|
+
self[101] = true
|
|
1787
|
+
if (self[103] or 0) <= 0 then
|
|
1788
|
+
for _ = self[102] or 0, -1 do
|
|
1789
|
+
BlzPauseUnitEx(handle, true)
|
|
1790
|
+
end
|
|
1699
1791
|
end
|
|
1700
1792
|
PauseUnit(handle, true)
|
|
1701
1793
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1702
1794
|
PauseUnit(handle, false)
|
|
1703
|
-
|
|
1704
|
-
|
|
1795
|
+
if (self[103] or 0) <= 0 then
|
|
1796
|
+
for _ = self[102] or 0, -1 do
|
|
1797
|
+
BlzPauseUnitEx(handle, false)
|
|
1798
|
+
end
|
|
1705
1799
|
end
|
|
1706
|
-
self[
|
|
1800
|
+
self[101] = nil
|
|
1707
1801
|
end
|
|
1708
1802
|
end
|
|
1709
1803
|
},
|
|
@@ -1759,20 +1853,6 @@ __TS__SetDescriptor(
|
|
|
1759
1853
|
},
|
|
1760
1854
|
true
|
|
1761
1855
|
)
|
|
1762
|
-
__TS__SetDescriptor(
|
|
1763
|
-
Unit.prototype,
|
|
1764
|
-
"scale",
|
|
1765
|
-
{
|
|
1766
|
-
get = function(self)
|
|
1767
|
-
return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
|
|
1768
|
-
end,
|
|
1769
|
-
set = function(self, v)
|
|
1770
|
-
setUnitScale(self.handle, v, v, v)
|
|
1771
|
-
setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
|
|
1772
|
-
end
|
|
1773
|
-
},
|
|
1774
|
-
true
|
|
1775
|
-
)
|
|
1776
1856
|
__TS__SetDescriptor(
|
|
1777
1857
|
Unit.prototype,
|
|
1778
1858
|
"timeScale",
|
|
@@ -1806,6 +1886,19 @@ __TS__SetDescriptor(
|
|
|
1806
1886
|
end},
|
|
1807
1887
|
true
|
|
1808
1888
|
)
|
|
1889
|
+
__TS__SetDescriptor(
|
|
1890
|
+
Unit.prototype,
|
|
1891
|
+
"movementType",
|
|
1892
|
+
{
|
|
1893
|
+
get = function(self)
|
|
1894
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1895
|
+
end,
|
|
1896
|
+
set = function(self, movementType)
|
|
1897
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1898
|
+
end
|
|
1899
|
+
},
|
|
1900
|
+
true
|
|
1901
|
+
)
|
|
1809
1902
|
__TS__SetDescriptor(
|
|
1810
1903
|
Unit.prototype,
|
|
1811
1904
|
"pathing",
|
|
@@ -1896,30 +1989,6 @@ __TS__SetDescriptor(
|
|
|
1896
1989
|
end},
|
|
1897
1990
|
true
|
|
1898
1991
|
)
|
|
1899
|
-
__TS__SetDescriptor(
|
|
1900
|
-
Unit.prototype,
|
|
1901
|
-
"onUnitInRange",
|
|
1902
|
-
{get = function(self)
|
|
1903
|
-
local handle = self.handle
|
|
1904
|
-
local onUnitInRange = setmetatable(
|
|
1905
|
-
{},
|
|
1906
|
-
{__index = function(self, value)
|
|
1907
|
-
local event = __TS__New(
|
|
1908
|
-
TriggerEvent,
|
|
1909
|
-
function(trigger)
|
|
1910
|
-
TriggerRegisterUnitInRangeSimple(trigger, value, handle)
|
|
1911
|
-
end,
|
|
1912
|
-
function() return ____exports.Unit:of(handle) end
|
|
1913
|
-
)
|
|
1914
|
-
rawset(self, value, event)
|
|
1915
|
-
return event
|
|
1916
|
-
end}
|
|
1917
|
-
)
|
|
1918
|
-
rawset(self, "onUnitInRange", onUnitInRange)
|
|
1919
|
-
return onUnitInRange
|
|
1920
|
-
end},
|
|
1921
|
-
true
|
|
1922
|
-
)
|
|
1923
1992
|
__TS__SetDescriptor(
|
|
1924
1993
|
Unit.prototype,
|
|
1925
1994
|
"onManaEqual",
|
|
@@ -1987,6 +2056,14 @@ __TS__SetDescriptor(
|
|
|
1987
2056
|
end},
|
|
1988
2057
|
true
|
|
1989
2058
|
)
|
|
2059
|
+
__TS__SetDescriptor(
|
|
2060
|
+
Unit.prototype,
|
|
2061
|
+
"targetAcquiredEvent",
|
|
2062
|
+
{get = function(self)
|
|
2063
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2064
|
+
end},
|
|
2065
|
+
true
|
|
2066
|
+
)
|
|
1990
2067
|
__TS__SetDescriptor(
|
|
1991
2068
|
Unit.prototype,
|
|
1992
2069
|
"onSelect",
|
|
@@ -2047,6 +2124,11 @@ __TS__SetDescriptor(
|
|
|
2047
2124
|
end},
|
|
2048
2125
|
true
|
|
2049
2126
|
)
|
|
2127
|
+
Unit.levelChangedEvent = __TS__New(
|
|
2128
|
+
____exports.UnitTriggerEvent,
|
|
2129
|
+
EVENT_PLAYER_HERO_LEVEL,
|
|
2130
|
+
function() return ____exports.Unit:of(getTriggerUnit()) end
|
|
2131
|
+
)
|
|
2050
2132
|
Unit.deathEvent = __TS__New(
|
|
2051
2133
|
____exports.UnitTriggerEvent,
|
|
2052
2134
|
EVENT_PLAYER_UNIT_DEATH,
|
|
@@ -2060,7 +2142,6 @@ Unit.onDecay = __TS__New(
|
|
|
2060
2142
|
Unit.onResurrect = __TS__New(
|
|
2061
2143
|
InitializingEvent,
|
|
2062
2144
|
function(event)
|
|
2063
|
-
local invoke = Event.invoke
|
|
2064
2145
|
local dead = setmetatable({}, {__mode = "k"})
|
|
2065
2146
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
2066
2147
|
dead[unit] = true
|
|
@@ -2076,10 +2157,15 @@ Unit.onResurrect = __TS__New(
|
|
|
2076
2157
|
Unit.morphEvent = __TS__New(
|
|
2077
2158
|
InitializingEvent,
|
|
2078
2159
|
function(event)
|
|
2160
|
+
local function ifNotLeft(unit)
|
|
2161
|
+
local handle = unit.handle
|
|
2162
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2163
|
+
invoke(event, unit)
|
|
2164
|
+
end
|
|
2165
|
+
end
|
|
2079
2166
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
2080
2167
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
2081
|
-
|
|
2082
|
-
Timer:run(Event.invoke, event, unit)
|
|
2168
|
+
Timer:run(ifNotLeft, unit)
|
|
2083
2169
|
end
|
|
2084
2170
|
end)
|
|
2085
2171
|
end
|
|
@@ -2117,27 +2203,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
2117
2203
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
2118
2204
|
InitializingEvent,
|
|
2119
2205
|
function(event)
|
|
2120
|
-
local invoke = Event.invoke
|
|
2121
2206
|
local function listener(unit, id)
|
|
2122
|
-
local
|
|
2207
|
+
local ____GetSpellTargetUnit_result_10
|
|
2123
2208
|
if GetSpellTargetUnit() then
|
|
2124
|
-
|
|
2209
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2125
2210
|
else
|
|
2126
|
-
local
|
|
2211
|
+
local ____GetSpellTargetItem_result_9
|
|
2127
2212
|
if GetSpellTargetItem() then
|
|
2128
|
-
|
|
2213
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2129
2214
|
else
|
|
2130
|
-
local
|
|
2215
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2131
2216
|
if GetSpellTargetDestructable() then
|
|
2132
|
-
|
|
2217
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2133
2218
|
else
|
|
2134
|
-
|
|
2219
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2135
2220
|
end
|
|
2136
|
-
|
|
2221
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2137
2222
|
end
|
|
2138
|
-
|
|
2223
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2139
2224
|
end
|
|
2140
|
-
local target =
|
|
2225
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2141
2226
|
if target then
|
|
2142
2227
|
invoke(event, unit, id, target)
|
|
2143
2228
|
end
|
|
@@ -2309,10 +2394,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2309
2394
|
____exports.UnitTriggerEvent,
|
|
2310
2395
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2311
2396
|
function()
|
|
2312
|
-
local
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2397
|
+
local handle = getOrderedUnit()
|
|
2398
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2399
|
+
local unit = ____exports.Unit:of(handle)
|
|
2400
|
+
if unit.state == 1 then
|
|
2401
|
+
return unit, getIssuedOrderId()
|
|
2402
|
+
end
|
|
2316
2403
|
end
|
|
2317
2404
|
return IgnoreEvent
|
|
2318
2405
|
end
|
|
@@ -2334,7 +2421,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2334
2421
|
)
|
|
2335
2422
|
Unit.onDamaging = (function()
|
|
2336
2423
|
local event = __TS__New(Event)
|
|
2337
|
-
local invoke = Event.invoke
|
|
2338
2424
|
local trigger = CreateTrigger()
|
|
2339
2425
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2340
2426
|
TriggerAddCondition(
|
|
@@ -2344,38 +2430,57 @@ Unit.onDamaging = (function()
|
|
|
2344
2430
|
if source and source.typeId == dummyUnitId then
|
|
2345
2431
|
source = nil
|
|
2346
2432
|
end
|
|
2347
|
-
local target = BlzGetEventDamageTarget()
|
|
2433
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2434
|
+
local metadata = damageMetadataByTarget[target]
|
|
2435
|
+
damageMetadataByTarget[target] = nil
|
|
2348
2436
|
local data = {
|
|
2349
2437
|
amount = GetEventDamage(),
|
|
2350
|
-
attackType = BlzGetEventAttackType(),
|
|
2438
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2351
2439
|
damageType = BlzGetEventDamageType(),
|
|
2352
2440
|
weaponType = BlzGetEventWeaponType(),
|
|
2353
|
-
|
|
2441
|
+
metadata = metadata,
|
|
2442
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2443
|
+
originalAmount = GetEventDamage(),
|
|
2444
|
+
originalMetadata = metadata,
|
|
2445
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2354
2446
|
}
|
|
2355
2447
|
if data.isAttack and source then
|
|
2356
|
-
|
|
2357
|
-
if weapon == -1 then
|
|
2358
|
-
local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
|
|
2359
|
-
weapon = 0
|
|
2360
|
-
end
|
|
2361
|
-
data.weapon = assert(source.weapons[weapon + 1])
|
|
2448
|
+
data.weapon = source:chooseWeapon(target)
|
|
2362
2449
|
end
|
|
2363
2450
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2364
2451
|
invoke(
|
|
2365
2452
|
event,
|
|
2366
2453
|
source,
|
|
2367
|
-
|
|
2454
|
+
target,
|
|
2368
2455
|
setmetatable(
|
|
2369
2456
|
{},
|
|
2370
2457
|
{
|
|
2371
2458
|
__index = data,
|
|
2372
2459
|
__newindex = function(self, key, value)
|
|
2373
|
-
damageSetters[key]
|
|
2460
|
+
local damageSetter = damageSetters[key]
|
|
2461
|
+
if damageSetter ~= nil then
|
|
2462
|
+
damageSetter(value)
|
|
2463
|
+
end
|
|
2374
2464
|
data[key] = value
|
|
2375
2465
|
end
|
|
2376
2466
|
}
|
|
2377
2467
|
)
|
|
2378
2468
|
)
|
|
2469
|
+
if data[0] and source then
|
|
2470
|
+
local sourceOwner = source.owner.handle
|
|
2471
|
+
data[1] = sourceOwner
|
|
2472
|
+
local targetOwner = target.owner.handle
|
|
2473
|
+
data[2] = targetOwner
|
|
2474
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2475
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2476
|
+
data[3] = true
|
|
2477
|
+
end
|
|
2478
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2479
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2480
|
+
data[4] = true
|
|
2481
|
+
end
|
|
2482
|
+
end
|
|
2483
|
+
damagingEventByTarget[target] = data
|
|
2379
2484
|
return
|
|
2380
2485
|
end
|
|
2381
2486
|
BlzSetEventDamage(0)
|
|
@@ -2383,7 +2488,7 @@ Unit.onDamaging = (function()
|
|
|
2383
2488
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2384
2489
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2385
2490
|
local sourceOwner = source.owner.handle
|
|
2386
|
-
local targetOwner =
|
|
2491
|
+
local targetOwner = target.owner.handle
|
|
2387
2492
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2388
2493
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2389
2494
|
Timer:run(function()
|
|
@@ -2399,23 +2504,19 @@ Unit.onDamaging = (function()
|
|
|
2399
2504
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2400
2505
|
local condition = ____value[1]
|
|
2401
2506
|
local action = ____value[2]
|
|
2402
|
-
if condition(
|
|
2403
|
-
source,
|
|
2404
|
-
____exports.Unit:of(target),
|
|
2405
|
-
data
|
|
2406
|
-
) then
|
|
2507
|
+
if condition(source, target, data) then
|
|
2407
2508
|
action(
|
|
2408
2509
|
source,
|
|
2409
|
-
|
|
2510
|
+
target,
|
|
2410
2511
|
setmetatable(
|
|
2411
2512
|
{fire = function()
|
|
2412
2513
|
UnitDamageTarget(
|
|
2413
2514
|
source.handle,
|
|
2414
|
-
target,
|
|
2515
|
+
target.handle,
|
|
2415
2516
|
data.amount,
|
|
2416
2517
|
true,
|
|
2417
2518
|
true,
|
|
2418
|
-
data.attackType,
|
|
2519
|
+
attackTypeToNative(data.attackType),
|
|
2419
2520
|
data.damageType,
|
|
2420
2521
|
data.weaponType
|
|
2421
2522
|
)
|
|
@@ -2433,7 +2534,6 @@ end)()
|
|
|
2433
2534
|
Unit.onDamage = __TS__New(
|
|
2434
2535
|
InitializingEvent,
|
|
2435
2536
|
function(event)
|
|
2436
|
-
local invoke = Event.invoke
|
|
2437
2537
|
local trigger = CreateTrigger()
|
|
2438
2538
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2439
2539
|
TriggerAddCondition(
|
|
@@ -2443,29 +2543,54 @@ Unit.onDamage = __TS__New(
|
|
|
2443
2543
|
if source and source.typeId == dummyUnitId then
|
|
2444
2544
|
source = nil
|
|
2445
2545
|
end
|
|
2546
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2547
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2548
|
+
damagingEventByTarget[target] = nil
|
|
2446
2549
|
local data = {
|
|
2447
2550
|
amount = GetEventDamage(),
|
|
2448
|
-
attackType = BlzGetEventAttackType(),
|
|
2551
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2449
2552
|
damageType = BlzGetEventDamageType(),
|
|
2450
2553
|
weaponType = BlzGetEventWeaponType(),
|
|
2554
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2451
2555
|
isAttack = BlzGetEventIsAttack(),
|
|
2556
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2557
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2452
2558
|
preventDeath = damageEventPreventDeath
|
|
2453
2559
|
}
|
|
2560
|
+
if damagingEvent then
|
|
2561
|
+
for key, value in pairs(damagingEvent) do
|
|
2562
|
+
if isAttribute(key) then
|
|
2563
|
+
data[key] = value
|
|
2564
|
+
end
|
|
2565
|
+
end
|
|
2566
|
+
local sourceOwner = damagingEvent[1]
|
|
2567
|
+
if sourceOwner then
|
|
2568
|
+
local targetOwner = damagingEvent[2]
|
|
2569
|
+
if damagingEvent[3] then
|
|
2570
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2571
|
+
end
|
|
2572
|
+
if damagingEvent[4] then
|
|
2573
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2574
|
+
end
|
|
2575
|
+
end
|
|
2576
|
+
end
|
|
2454
2577
|
local evData = setmetatable(
|
|
2455
2578
|
{},
|
|
2456
2579
|
{
|
|
2457
2580
|
__index = data,
|
|
2458
2581
|
__newindex = function(self, key, value)
|
|
2459
|
-
damageSetters[key]
|
|
2582
|
+
local damageSetter = damageSetters[key]
|
|
2583
|
+
if damageSetter ~= nil then
|
|
2584
|
+
damageSetter(value)
|
|
2585
|
+
end
|
|
2460
2586
|
data[key] = value
|
|
2461
2587
|
end
|
|
2462
2588
|
}
|
|
2463
2589
|
)
|
|
2464
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2465
2590
|
invoke(event, source, target, evData)
|
|
2466
2591
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2467
2592
|
local bonusHealth = math.ceil(evData.amount)
|
|
2468
|
-
target[
|
|
2593
|
+
target[106] = (target[106] or 0) + bonusHealth
|
|
2469
2594
|
BlzSetUnitMaxHP(
|
|
2470
2595
|
target.handle,
|
|
2471
2596
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2479,7 +2604,7 @@ Unit.onDamage = __TS__New(
|
|
|
2479
2604
|
evData[0],
|
|
2480
2605
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2481
2606
|
)
|
|
2482
|
-
target[
|
|
2607
|
+
target[106] = (target[106] or 0) - bonusHealth
|
|
2483
2608
|
SetWidgetLife(
|
|
2484
2609
|
target.handle,
|
|
2485
2610
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2499,32 +2624,110 @@ Unit.onDamage = __TS__New(
|
|
|
2499
2624
|
DestroyTrigger(trigger)
|
|
2500
2625
|
end
|
|
2501
2626
|
)
|
|
2502
|
-
Unit.
|
|
2627
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2503
2628
|
____exports.UnitTriggerEvent,
|
|
2504
2629
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2505
2630
|
function()
|
|
2506
2631
|
local unit = getTriggerUnit()
|
|
2507
|
-
|
|
2508
|
-
|
|
2632
|
+
local item = getManipulatedItem()
|
|
2633
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2634
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2509
2635
|
end
|
|
2510
2636
|
return IgnoreEvent
|
|
2511
2637
|
end
|
|
2512
2638
|
)
|
|
2513
|
-
Unit.
|
|
2639
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2514
2640
|
____exports.UnitTriggerEvent,
|
|
2515
2641
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2516
2642
|
function()
|
|
2517
|
-
local
|
|
2518
|
-
|
|
2519
|
-
|
|
2643
|
+
local unitHandle = getTriggerUnit()
|
|
2644
|
+
local itemHandle = getManipulatedItem()
|
|
2645
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2646
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2647
|
+
local item = Item:of(itemHandle)
|
|
2648
|
+
if item.owner ~= unit then
|
|
2649
|
+
return unit, item
|
|
2650
|
+
end
|
|
2520
2651
|
end
|
|
2521
2652
|
return IgnoreEvent
|
|
2522
2653
|
end
|
|
2523
2654
|
)
|
|
2524
|
-
Unit.
|
|
2655
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2525
2656
|
____exports.UnitTriggerEvent,
|
|
2526
2657
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2527
|
-
function()
|
|
2658
|
+
function()
|
|
2659
|
+
local unit = getTriggerUnit()
|
|
2660
|
+
local item = getManipulatedItem()
|
|
2661
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2662
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2663
|
+
end
|
|
2664
|
+
return IgnoreEvent
|
|
2665
|
+
end
|
|
2666
|
+
)
|
|
2667
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2668
|
+
____exports.UnitTriggerEvent,
|
|
2669
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2670
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2671
|
+
)
|
|
2672
|
+
__TS__ObjectDefineProperty(
|
|
2673
|
+
Unit,
|
|
2674
|
+
"itemChargesChangedEvent",
|
|
2675
|
+
{get = function(self)
|
|
2676
|
+
local event = __TS__New(Event)
|
|
2677
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2678
|
+
local unit = item.owner
|
|
2679
|
+
if unit ~= nil then
|
|
2680
|
+
invoke(event, unit, item)
|
|
2681
|
+
end
|
|
2682
|
+
end)
|
|
2683
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2684
|
+
return event
|
|
2685
|
+
end}
|
|
2686
|
+
)
|
|
2687
|
+
__TS__ObjectDefineProperty(
|
|
2688
|
+
Unit,
|
|
2689
|
+
"itemUseOrderEvent",
|
|
2690
|
+
{get = function(self)
|
|
2691
|
+
local event = __TS__New(Event)
|
|
2692
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2693
|
+
local slot = order - orderId("useslot0")
|
|
2694
|
+
local function listener(unit)
|
|
2695
|
+
local item = unit.items[slot + 1]
|
|
2696
|
+
if item ~= nil then
|
|
2697
|
+
invoke(event, unit, item)
|
|
2698
|
+
end
|
|
2699
|
+
end
|
|
2700
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2701
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2702
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2703
|
+
end
|
|
2704
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2705
|
+
return event
|
|
2706
|
+
end}
|
|
2707
|
+
)
|
|
2708
|
+
__TS__ObjectDefineProperty(
|
|
2709
|
+
Unit,
|
|
2710
|
+
"itemMoveOrderEvent",
|
|
2711
|
+
{get = function(self)
|
|
2712
|
+
local event = __TS__New(Event)
|
|
2713
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2714
|
+
local slotTo = order - orderId("moveslot0")
|
|
2715
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2716
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2717
|
+
if slotFrom ~= nil then
|
|
2718
|
+
invoke(
|
|
2719
|
+
event,
|
|
2720
|
+
unit,
|
|
2721
|
+
item,
|
|
2722
|
+
slotFrom,
|
|
2723
|
+
slotTo
|
|
2724
|
+
)
|
|
2725
|
+
end
|
|
2726
|
+
end)
|
|
2727
|
+
end
|
|
2728
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2729
|
+
return event
|
|
2730
|
+
end}
|
|
2528
2731
|
)
|
|
2529
2732
|
__TS__ObjectDefineProperty(
|
|
2530
2733
|
Unit,
|
|
@@ -2551,6 +2754,10 @@ __TS__ObjectDefineProperty(
|
|
|
2551
2754
|
rawset(self, "destroyEvent", destroyEvent)
|
|
2552
2755
|
return destroyEvent
|
|
2553
2756
|
end}
|
|
2757
|
+
)
|
|
2758
|
+
Unit.synchronize = synchronizer(
|
|
2759
|
+
function(unit) return unit.syncId end,
|
|
2760
|
+
function(syncId) return unitBySyncId[syncId] end
|
|
2554
2761
|
);
|
|
2555
2762
|
(function(self)
|
|
2556
2763
|
local leaveAbilityIds = postcompile(function()
|
|
@@ -2580,7 +2787,8 @@ __TS__ObjectDefineProperty(
|
|
|
2580
2787
|
return
|
|
2581
2788
|
end
|
|
2582
2789
|
end
|
|
2583
|
-
unit:
|
|
2790
|
+
unit:saveData()
|
|
2791
|
+
Timer:run(unit, "destroy")
|
|
2584
2792
|
end)
|
|
2585
2793
|
end
|
|
2586
2794
|
end)(Unit)
|