warscript 0.0.1-dev.ccd5725 → 0.0.1-dev.ce2be36
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 -1
- 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 -1
- package/core/types/frame.lua +117 -22
- package/core/types/group.d.ts +0 -1
- package/core/types/image.d.ts +0 -1
- package/core/types/missile.d.ts +2 -2
- package/core/types/missile.lua +8 -2
- package/core/types/player.d.ts +15 -0
- package/core/types/player.lua +56 -14
- 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 +9 -8
- package/core/types/timer.lua +45 -23
- package/core/types/unit.lua +8 -0
- package/core/util.d.ts +1 -1
- package/core/util.lua +18 -1
- package/decl/index.d.ts +1 -0
- package/decl/native.d.ts +846 -790
- package/engine/ability.d.ts +1 -1
- package/engine/behavior.d.ts +15 -10
- package/engine/behavior.lua +112 -33
- package/engine/behaviour/ability/always-enabled.d.ts +7 -0
- package/engine/behaviour/ability/always-enabled.lua +31 -0
- package/engine/behaviour/ability/apply-buff.d.ts +8 -5
- package/engine/behaviour/ability/apply-buff.lua +32 -0
- package/engine/behaviour/ability/apply-unit-behavior.d.ts +6 -1
- 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 -15
- 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 +27 -4
- package/engine/behaviour/ability.lua +152 -26
- package/engine/behaviour/unit/stun-immunity.d.ts +7 -4
- package/engine/behaviour/unit/stun-immunity.lua +52 -27
- package/engine/behaviour/unit.d.ts +42 -2
- package/engine/behaviour/unit.lua +213 -0
- package/engine/buff.d.ts +113 -44
- package/engine/buff.lua +508 -217
- 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/misc/ability-disable-counter.d.ts +2 -0
- package/engine/internal/misc/ability-disable-counter.lua +13 -0
- package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
- package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
- package/engine/internal/misc/frame-coordinates.d.ts +2 -0
- package/engine/internal/misc/frame-coordinates.lua +21 -0
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/misc/player-local-handle.d.ts +2 -0
- package/engine/internal/misc/player-local-handle.lua +5 -0
- package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
- package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
- package/engine/internal/object-data/evasion-probability.d.ts +2 -0
- package/engine/internal/object-data/evasion-probability.lua +16 -0
- package/engine/internal/unit/ability.d.ts +45 -1
- package/engine/internal/unit/ability.lua +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/bonus.d.ts +11 -8
- package/engine/internal/unit/bonus.lua +23 -1
- package/engine/internal/unit/ignore-events-items.d.ts +2 -0
- package/engine/internal/unit/ignore-events-items.lua +5 -0
- package/engine/internal/unit/item.d.ts +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+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 +63 -13
- package/engine/internal/unit.d.ts +96 -24
- package/engine/internal/unit.lua +648 -214
- 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 -3
- 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/combat-classification.d.ts +0 -2
- 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.d.ts +0 -1
- package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
- package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -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/channel.d.ts +0 -1
- 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/mine.d.ts +10 -0
- package/engine/object-data/entry/ability-type/mine.lua +39 -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/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/spirit-touch.d.ts +2 -2
- package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
- 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 -18
- package/engine/object-data/entry/ability-type.lua +93 -36
- package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
- package/engine/object-data/entry/buff-type/applicable.lua +18 -37
- package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
- package/engine/object-data/entry/buff-type.d.ts +6 -13
- package/engine/object-data/entry/buff-type.lua +13 -29
- package/engine/object-data/entry/destructible-type.d.ts +1 -2
- package/engine/object-data/entry/item-type/blank.d.ts +0 -1
- package/engine/object-data/entry/item-type.d.ts +15 -2
- package/engine/object-data/entry/item-type.lua +93 -2
- package/engine/object-data/entry/lightning-type.d.ts +1 -2
- 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 +46 -7
- package/engine/object-data/entry/unit-type.lua +402 -75
- package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
- package/engine/object-data/entry/upgrade.d.ts +1 -2
- package/engine/object-data/entry/upgrade.lua +4 -4
- package/engine/object-data/entry.d.ts +18 -17
- 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 +57 -3
- package/engine/object-field/unit.lua +207 -7
- package/engine/object-field.d.ts +23 -7
- package/engine/object-field.lua +303 -114
- package/engine/random.d.ts +10 -0
- package/engine/random.lua +22 -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/entries/unit-type.d.ts +39 -1
- package/engine/standard/entries/unit-type.lua +39 -1
- package/engine/standard/fields/ability.d.ts +3 -1
- package/engine/standard/fields/ability.lua +3 -1
- package/engine/standard/fields/unit.d.ts +4 -0
- package/engine/standard/fields/unit.lua +7 -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 +4 -0
- package/engine/unit.lua +13 -2
- package/event.d.ts +2 -3
- package/event.lua +9 -5
- package/index.d.ts +1 -0
- package/index.lua +1 -0
- package/lualib_bundle.lua +146 -42
- package/math/vec2.d.ts +2 -9
- package/math.d.ts +0 -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/ability.d.ts +0 -1
- package/objutil/buff.d.ts +0 -1
- package/objutil/buff.lua +3 -4
- package/objutil/object.d.ts +0 -1
- package/objutil/unit.d.ts +0 -1
- package/objutil/unit.lua +8 -0
- package/package.json +13 -14
- package/patch-lua.d.ts +0 -0
- package/patch-lua.lua +10 -0
- package/patch-lualib.lua +1 -1
- package/property.d.ts +55 -0
- package/property.lua +374 -0
- package/string.d.ts +30 -0
- package/string.lua +14 -0
- package/util/stream.d.ts +0 -1
- package/utility/arrays.d.ts +13 -5
- package/utility/arrays.lua +45 -3
- package/utility/bit-set.d.ts +0 -2
- 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-set.d.ts +13 -3
- package/utility/linked-set.lua +27 -3
- package/utility/lua-maps.d.ts +16 -4
- package/utility/lua-maps.lua +53 -2
- package/utility/lua-sets.d.ts +3 -2
- package/utility/lua-sets.lua +7 -0
- 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
|
@@ -5,9 +5,12 @@ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
|
5
5
|
local __TS__New = ____lualib.__TS__New
|
|
6
6
|
local __TS__Class = ____lualib.__TS__Class
|
|
7
7
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
8
|
+
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
8
9
|
local __TS__ArraySetLength = ____lualib.__TS__ArraySetLength
|
|
10
|
+
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
|
|
11
|
+
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
|
|
12
|
+
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
|
|
9
13
|
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
10
|
-
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
11
14
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
12
15
|
local Set = ____lualib.Set
|
|
13
16
|
local __TS__Spread = ____lualib.__TS__Spread
|
|
@@ -48,12 +51,23 @@ local ____arrays = require("utility.arrays")
|
|
|
48
51
|
local forEach = ____arrays.forEach
|
|
49
52
|
local ____math = require("math")
|
|
50
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
|
|
51
67
|
local match = string.match
|
|
52
68
|
local ____tostring = _G.tostring
|
|
53
69
|
local setUnitAnimation = SetUnitAnimation
|
|
54
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
55
70
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
56
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
57
71
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
58
72
|
local getUnitRealField = BlzGetUnitRealField
|
|
59
73
|
local getHeroStr = GetHeroStr
|
|
@@ -72,9 +86,9 @@ local setUnitScale = SetUnitScale
|
|
|
72
86
|
local setUnitPosition = SetUnitPosition
|
|
73
87
|
local setUnitTimeScale = SetUnitTimeScale
|
|
74
88
|
local getHandleId = GetHandleId
|
|
89
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
75
90
|
local createUnit = CreateUnit
|
|
76
91
|
local killUnit = KillUnit
|
|
77
|
-
local setUnitExploded = SetUnitExploded
|
|
78
92
|
local removeUnit = RemoveUnit
|
|
79
93
|
local getUnitTypeId = GetUnitTypeId
|
|
80
94
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -90,8 +104,10 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
90
104
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
91
105
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
92
106
|
local isUnitInRange = IsUnitInRange
|
|
93
|
-
local
|
|
94
|
-
local
|
|
107
|
+
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
108
|
+
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
109
|
+
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
110
|
+
local setUnitWeaponStringField = BlzSetUnitWeaponStringField
|
|
95
111
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
96
112
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
97
113
|
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
@@ -111,15 +127,9 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
111
127
|
local getIssuedOrderId = GetIssuedOrderId
|
|
112
128
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
113
129
|
local unitAlive = UnitAlive
|
|
114
|
-
local unitAddType = UnitAddType
|
|
115
|
-
local unitRemoveType = UnitRemoveType
|
|
116
|
-
local isUnitIllusion = IsUnitIllusion
|
|
117
|
-
local isUnitType = IsUnitType
|
|
118
130
|
local isUnitAlly = IsUnitAlly
|
|
119
131
|
local isUnitEnemy = IsUnitEnemy
|
|
120
132
|
local getOwningPlayer = GetOwningPlayer
|
|
121
|
-
local setUnitColor = SetUnitColor
|
|
122
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
123
133
|
____exports.UnitClassification = {}
|
|
124
134
|
local UnitClassification = ____exports.UnitClassification
|
|
125
135
|
do
|
|
@@ -129,6 +139,7 @@ do
|
|
|
129
139
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
130
140
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
131
141
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
142
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
132
143
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
133
144
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
134
145
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -275,16 +286,14 @@ function UnitTriggerEvent.prototype.____constructor(self, eventType, c)
|
|
|
275
286
|
end
|
|
276
287
|
local function dispatch(event, idGetter, argsGetter)
|
|
277
288
|
local initialized = false
|
|
278
|
-
local x = {}
|
|
279
289
|
return setmetatable(
|
|
280
|
-
|
|
290
|
+
{},
|
|
281
291
|
{
|
|
282
292
|
__index = function(self, id)
|
|
283
293
|
if type(id) ~= "number" then
|
|
284
294
|
return event[id]
|
|
285
295
|
end
|
|
286
296
|
if not initialized then
|
|
287
|
-
local invoke = Event.invoke
|
|
288
297
|
event:addListener(function(...)
|
|
289
298
|
local id = idGetter(...)
|
|
290
299
|
local dispatched = rawget(self, id)
|
|
@@ -322,7 +331,6 @@ local function dispatchAbility(event)
|
|
|
322
331
|
return event[id]
|
|
323
332
|
end
|
|
324
333
|
if not initialized then
|
|
325
|
-
local invoke = Event.invoke
|
|
326
334
|
event:addListener(function(unit, ability, ...)
|
|
327
335
|
local dispatched = rawget(self, ability.typeId)
|
|
328
336
|
if dispatched ~= nil then
|
|
@@ -339,6 +347,9 @@ local function dispatchAbility(event)
|
|
|
339
347
|
}
|
|
340
348
|
)
|
|
341
349
|
end
|
|
350
|
+
local function damagingEventPreventRetaliation(self)
|
|
351
|
+
self[0] = true
|
|
352
|
+
end
|
|
342
353
|
local function damageEventPreventDeath(self, callback, ...)
|
|
343
354
|
if self[0] ~= nil then
|
|
344
355
|
return
|
|
@@ -350,7 +361,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
350
361
|
rawset(self, 1 + i, (select(i, ...)))
|
|
351
362
|
end
|
|
352
363
|
end
|
|
353
|
-
local damageSetters = {
|
|
364
|
+
local damageSetters = {
|
|
365
|
+
amount = BlzSetEventDamage,
|
|
366
|
+
attackType = function(attackType)
|
|
367
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
368
|
+
end,
|
|
369
|
+
damageType = BlzSetEventDamageType,
|
|
370
|
+
weaponType = BlzSetEventWeaponType
|
|
371
|
+
}
|
|
354
372
|
local jlimitopByOperator = {
|
|
355
373
|
[0] = LESS_THAN_OR_EQUAL,
|
|
356
374
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -387,51 +405,184 @@ local getters = {
|
|
|
387
405
|
return BlzGetUnitArmor(unit)
|
|
388
406
|
end
|
|
389
407
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
408
|
+
____exports.UnitWeapon = __TS__Class()
|
|
409
|
+
local UnitWeapon = ____exports.UnitWeapon
|
|
410
|
+
UnitWeapon.name = "UnitWeapon"
|
|
411
|
+
function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
412
|
+
self.unit = unit
|
|
413
|
+
self.index = index
|
|
414
|
+
end
|
|
415
|
+
__TS__SetDescriptor(
|
|
416
|
+
UnitWeapon.prototype,
|
|
417
|
+
"isEnabled",
|
|
418
|
+
{
|
|
419
|
+
get = function(self)
|
|
420
|
+
return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
|
|
421
|
+
end,
|
|
422
|
+
set = function(self, isEnabled)
|
|
423
|
+
BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
|
|
424
|
+
end
|
|
425
|
+
},
|
|
426
|
+
true
|
|
427
|
+
)
|
|
428
|
+
__TS__SetDescriptor(
|
|
429
|
+
UnitWeapon.prototype,
|
|
430
|
+
"cooldown",
|
|
431
|
+
{
|
|
432
|
+
get = function(self)
|
|
433
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index)
|
|
434
|
+
end,
|
|
435
|
+
set = function(self, cooldown)
|
|
436
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index, cooldown)
|
|
437
|
+
end
|
|
438
|
+
},
|
|
439
|
+
true
|
|
440
|
+
)
|
|
441
|
+
__TS__SetDescriptor(
|
|
442
|
+
UnitWeapon.prototype,
|
|
443
|
+
"damage",
|
|
444
|
+
{
|
|
445
|
+
get = function(self)
|
|
446
|
+
local minimumDamage = self.damageBase + self.damageDiceCount
|
|
447
|
+
local maximumDamage = self.damageBase + self.damageDiceCount * self.damageDiceSideCount
|
|
448
|
+
return {minimumDamage, maximumDamage}
|
|
449
|
+
end,
|
|
450
|
+
set = function(self, ____bindingPattern0)
|
|
451
|
+
local maximumDamage
|
|
452
|
+
local minimumDamage
|
|
453
|
+
minimumDamage = ____bindingPattern0[1]
|
|
454
|
+
maximumDamage = ____bindingPattern0[2]
|
|
455
|
+
self.damageBase = minimumDamage - 1
|
|
456
|
+
self.damageDiceCount = 1
|
|
457
|
+
self.damageDiceSideCount = maximumDamage - minimumDamage + 1
|
|
458
|
+
end
|
|
459
|
+
},
|
|
460
|
+
true
|
|
461
|
+
)
|
|
462
|
+
__TS__SetDescriptor(
|
|
463
|
+
UnitWeapon.prototype,
|
|
464
|
+
"allowedTargetCombatClassifications",
|
|
465
|
+
{
|
|
466
|
+
get = function(self)
|
|
467
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
468
|
+
end,
|
|
469
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
470
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
471
|
+
end
|
|
472
|
+
},
|
|
473
|
+
true
|
|
474
|
+
)
|
|
475
|
+
__TS__SetDescriptor(
|
|
476
|
+
UnitWeapon.prototype,
|
|
477
|
+
"damageBase",
|
|
478
|
+
{
|
|
479
|
+
get = function(self)
|
|
480
|
+
return BlzGetUnitBaseDamage(self.unit.handle, self.index)
|
|
481
|
+
end,
|
|
482
|
+
set = function(self, damageBase)
|
|
483
|
+
BlzSetUnitBaseDamage(self.unit.handle, self.index, damageBase)
|
|
484
|
+
end
|
|
485
|
+
},
|
|
486
|
+
true
|
|
487
|
+
)
|
|
488
|
+
__TS__SetDescriptor(
|
|
489
|
+
UnitWeapon.prototype,
|
|
490
|
+
"damageDiceCount",
|
|
491
|
+
{
|
|
492
|
+
get = function(self)
|
|
493
|
+
return BlzGetUnitDiceNumber(self.unit.handle, self.index)
|
|
494
|
+
end,
|
|
495
|
+
set = function(self, damageDiceCount)
|
|
496
|
+
BlzSetUnitDiceNumber(self.unit.handle, self.index, damageDiceCount)
|
|
497
|
+
end
|
|
498
|
+
},
|
|
499
|
+
true
|
|
500
|
+
)
|
|
501
|
+
__TS__SetDescriptor(
|
|
502
|
+
UnitWeapon.prototype,
|
|
503
|
+
"damageDiceSideCount",
|
|
504
|
+
{
|
|
505
|
+
get = function(self)
|
|
506
|
+
return BlzGetUnitDiceSides(self.unit.handle, self.index)
|
|
507
|
+
end,
|
|
508
|
+
set = function(self, damageDiceSideCount)
|
|
509
|
+
BlzSetUnitDiceSides(self.unit.handle, self.index, damageDiceSideCount)
|
|
510
|
+
end
|
|
511
|
+
},
|
|
512
|
+
true
|
|
513
|
+
)
|
|
514
|
+
__TS__SetDescriptor(
|
|
515
|
+
UnitWeapon.prototype,
|
|
516
|
+
"range",
|
|
517
|
+
{
|
|
518
|
+
get = function(self)
|
|
519
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_RANGE, self.index)
|
|
520
|
+
end,
|
|
521
|
+
set = function(self, range)
|
|
522
|
+
local handle = self.unit.handle
|
|
523
|
+
local index = self.index
|
|
524
|
+
setUnitWeaponRealField(
|
|
525
|
+
handle,
|
|
526
|
+
UNIT_WEAPON_RF_ATTACK_RANGE,
|
|
527
|
+
index + 1,
|
|
528
|
+
getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index + 1) + (range - getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index))
|
|
529
|
+
)
|
|
530
|
+
end
|
|
531
|
+
},
|
|
532
|
+
true
|
|
533
|
+
)
|
|
534
|
+
__TS__SetDescriptor(
|
|
535
|
+
UnitWeapon.prototype,
|
|
536
|
+
"impactDelay",
|
|
537
|
+
{
|
|
538
|
+
get = function(self)
|
|
539
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index)
|
|
540
|
+
end,
|
|
541
|
+
set = function(self, impactDelay)
|
|
542
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index, impactDelay)
|
|
543
|
+
end
|
|
544
|
+
},
|
|
545
|
+
true
|
|
546
|
+
)
|
|
547
|
+
__TS__SetDescriptor(
|
|
548
|
+
UnitWeapon.prototype,
|
|
549
|
+
"missileArc",
|
|
550
|
+
{
|
|
551
|
+
get = function(self)
|
|
552
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index)
|
|
553
|
+
end,
|
|
554
|
+
set = function(self, missileArc)
|
|
555
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index, missileArc)
|
|
556
|
+
end
|
|
557
|
+
},
|
|
558
|
+
true
|
|
559
|
+
)
|
|
560
|
+
__TS__SetDescriptor(
|
|
561
|
+
UnitWeapon.prototype,
|
|
562
|
+
"missileModelPath",
|
|
563
|
+
{
|
|
564
|
+
get = function(self)
|
|
565
|
+
return getUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index)
|
|
566
|
+
end,
|
|
567
|
+
set = function(self, missileModelPath)
|
|
568
|
+
setUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index, missileModelPath)
|
|
569
|
+
end
|
|
570
|
+
},
|
|
571
|
+
true
|
|
572
|
+
)
|
|
573
|
+
__TS__SetDescriptor(
|
|
574
|
+
UnitWeapon.prototype,
|
|
575
|
+
"missileSpeed",
|
|
576
|
+
{
|
|
577
|
+
get = function(self)
|
|
578
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index)
|
|
579
|
+
end,
|
|
580
|
+
set = function(self, missileSpeed)
|
|
581
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index, missileSpeed)
|
|
582
|
+
end
|
|
583
|
+
},
|
|
584
|
+
true
|
|
585
|
+
)
|
|
435
586
|
local unitInventorySize = UnitInventorySize
|
|
436
587
|
local unitItemInSlot = UnitItemInSlot
|
|
437
588
|
local getItemAbility = BlzGetItemAbility
|
|
@@ -442,8 +593,6 @@ local getAbilityName = GetAbilityName
|
|
|
442
593
|
local unitAddAbility = UnitAddAbility
|
|
443
594
|
local getUnitGoldCost = GetUnitGoldCost
|
|
444
595
|
local getUnitLumberCost = GetUnitWoodCost
|
|
445
|
-
local unitMakeAbilityPermanent = UnitMakeAbilityPermanent
|
|
446
|
-
local unitAddItem = UnitAddItem
|
|
447
596
|
local unitRemoveAbility = UnitRemoveAbility
|
|
448
597
|
local function retrieveAbility(unit, ability, abilityId)
|
|
449
598
|
if ability == nil then
|
|
@@ -453,17 +602,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
453
602
|
____exports.Unit:of(unit)
|
|
454
603
|
)
|
|
455
604
|
end
|
|
456
|
-
if not unitAddAbility(unit, abilityId) then
|
|
457
|
-
if getUnitAbility(unit, abilityId) == ability then
|
|
458
|
-
return UnitAbility:of(
|
|
459
|
-
ability,
|
|
460
|
-
abilityId,
|
|
461
|
-
____exports.Unit:of(unit)
|
|
462
|
-
)
|
|
463
|
-
end
|
|
464
|
-
else
|
|
465
|
-
unitRemoveAbility(unit, abilityId)
|
|
466
|
-
end
|
|
467
605
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
468
606
|
local item = unitItemInSlot(unit, i)
|
|
469
607
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -520,12 +658,44 @@ for ____, player in ipairs(Player.all) do
|
|
|
520
658
|
ShowUnit(dummy, false)
|
|
521
659
|
dummies[player] = dummy
|
|
522
660
|
end
|
|
661
|
+
local function delayHealthChecksCallback(unit)
|
|
662
|
+
local counter = (unit[104] or 0) - 1
|
|
663
|
+
if counter ~= 0 then
|
|
664
|
+
unit[104] = counter
|
|
665
|
+
return
|
|
666
|
+
end
|
|
667
|
+
unit[104] = nil
|
|
668
|
+
local healthBonus = unit[105]
|
|
669
|
+
if healthBonus ~= nil then
|
|
670
|
+
unit[105] = nil
|
|
671
|
+
local handle = unit.handle
|
|
672
|
+
BlzSetUnitMaxHP(
|
|
673
|
+
handle,
|
|
674
|
+
BlzGetUnitMaxHP(handle) - healthBonus
|
|
675
|
+
)
|
|
676
|
+
end
|
|
677
|
+
end
|
|
678
|
+
local nextSyncId = 1
|
|
679
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
680
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
681
|
+
local function addAbility(unit, abilityTypeId)
|
|
682
|
+
local ____unitAddAbility_result_0
|
|
683
|
+
if unitAddAbility(unit, abilityTypeId) then
|
|
684
|
+
____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
|
|
685
|
+
else
|
|
686
|
+
____unitAddAbility_result_0 = nil
|
|
687
|
+
end
|
|
688
|
+
return ____unitAddAbility_result_0
|
|
689
|
+
end
|
|
523
690
|
____exports.Unit = __TS__Class()
|
|
524
691
|
local Unit = ____exports.Unit
|
|
525
692
|
Unit.name = "Unit"
|
|
526
693
|
__TS__ClassExtends(Unit, Handle)
|
|
527
694
|
function Unit.prototype.____constructor(self, handle)
|
|
528
695
|
Handle.prototype.____constructor(self, handle)
|
|
696
|
+
local ____nextSyncId_1 = nextSyncId
|
|
697
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
698
|
+
self.syncId = ____nextSyncId_1
|
|
529
699
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
530
700
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
531
701
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -538,6 +708,7 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
538
708
|
fourCC("Amrf")
|
|
539
709
|
))
|
|
540
710
|
end
|
|
711
|
+
unitBySyncId[self.syncId] = self
|
|
541
712
|
local ____ = self.abilities
|
|
542
713
|
end
|
|
543
714
|
function Unit.prototype.getEvent(self, event, collector)
|
|
@@ -556,6 +727,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
556
727
|
end
|
|
557
728
|
function Unit.prototype.onDestroy(self)
|
|
558
729
|
local handle = self.handle
|
|
730
|
+
self[108] = getUnitX(handle)
|
|
731
|
+
self[109] = getUnitY(handle)
|
|
559
732
|
if not self._owner then
|
|
560
733
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
561
734
|
end
|
|
@@ -623,17 +796,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
623
796
|
end}
|
|
624
797
|
end
|
|
625
798
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
626
|
-
local
|
|
627
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
799
|
+
local ____combatClassification_2 = combatClassification
|
|
800
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
|
|
628
801
|
end
|
|
629
802
|
function Unit.prototype.addClassification(self, classification)
|
|
630
|
-
return
|
|
803
|
+
return UnitAddType(self.handle, classification)
|
|
631
804
|
end
|
|
632
805
|
function Unit.prototype.removeClassification(self, classification)
|
|
633
|
-
return
|
|
806
|
+
return UnitRemoveType(self.handle, classification)
|
|
634
807
|
end
|
|
635
808
|
function Unit.prototype.hasClassification(self, classification)
|
|
636
|
-
return
|
|
809
|
+
return IsUnitType(self.handle, classification)
|
|
637
810
|
end
|
|
638
811
|
function Unit.prototype.isVisibleTo(self, player)
|
|
639
812
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -642,13 +815,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
642
815
|
return isUnitInvisible(self.handle, player.handle)
|
|
643
816
|
end
|
|
644
817
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
645
|
-
local
|
|
818
|
+
local ____temp_3
|
|
646
819
|
if type(x) == "number" then
|
|
647
|
-
|
|
820
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
648
821
|
else
|
|
649
|
-
|
|
822
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
650
823
|
end
|
|
651
|
-
return
|
|
824
|
+
return ____temp_3
|
|
652
825
|
end
|
|
653
826
|
function Unit.prototype.isAllyOf(self, unit)
|
|
654
827
|
return isUnitAlly(
|
|
@@ -666,13 +839,31 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
666
839
|
if type(animation) == "number" then
|
|
667
840
|
setUnitAnimationByIndex(self.handle, animation)
|
|
668
841
|
elseif rarity then
|
|
669
|
-
|
|
842
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
670
843
|
else
|
|
671
844
|
setUnitAnimation(self.handle, animation)
|
|
672
845
|
end
|
|
673
846
|
end
|
|
847
|
+
function Unit.prototype.resetAnimation(self)
|
|
848
|
+
ResetUnitAnimation(self.handle)
|
|
849
|
+
end
|
|
674
850
|
function Unit.prototype.queueAnimation(self, animation)
|
|
675
|
-
|
|
851
|
+
QueueUnitAnimation(self.handle, animation)
|
|
852
|
+
end
|
|
853
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
854
|
+
local firstWeapon = self.firstWeapon
|
|
855
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
856
|
+
return firstWeapon
|
|
857
|
+
end
|
|
858
|
+
local secondWeapon = self.secondWeapon
|
|
859
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
860
|
+
return secondWeapon
|
|
861
|
+
end
|
|
862
|
+
return nil
|
|
863
|
+
end
|
|
864
|
+
function Unit.prototype.delayHealthChecks(self)
|
|
865
|
+
self[104] = (self[104] or 0) + 1
|
|
866
|
+
Timer:run(delayHealthChecksCallback, self)
|
|
676
867
|
end
|
|
677
868
|
function Unit.prototype.setPosition(self, x, y)
|
|
678
869
|
setUnitPosition(self.handle, x, y)
|
|
@@ -681,14 +872,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
681
872
|
return IsUnitSelected(self.handle, player.handle)
|
|
682
873
|
end
|
|
683
874
|
function Unit.prototype.explode(self)
|
|
684
|
-
|
|
875
|
+
SetUnitExploded(self.handle, true)
|
|
685
876
|
killUnit(self.handle)
|
|
686
877
|
end
|
|
687
878
|
function Unit.prototype.kill(self)
|
|
688
879
|
killUnit(self.handle)
|
|
689
880
|
end
|
|
690
|
-
function Unit.prototype.revive(self,
|
|
691
|
-
|
|
881
|
+
function Unit.prototype.revive(self, x, y, doEffect)
|
|
882
|
+
local ____ReviveHero_6 = ReviveHero
|
|
883
|
+
local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
|
|
884
|
+
local ____doEffect_4 = doEffect
|
|
885
|
+
if ____doEffect_4 == nil then
|
|
886
|
+
____doEffect_4 = false
|
|
887
|
+
end
|
|
888
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
889
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
692
890
|
end
|
|
693
891
|
function Unit.prototype.healTarget(self, target, amount)
|
|
694
892
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -728,20 +926,19 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
728
926
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
729
927
|
end
|
|
730
928
|
function Unit.prototype.itemInSlot(self, slot)
|
|
731
|
-
return Item:of(
|
|
929
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
732
930
|
end
|
|
733
931
|
function Unit.prototype.addAbility(self, abilityId)
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
932
|
+
local ability = UnitAbility:of(
|
|
933
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
934
|
+
abilityId,
|
|
935
|
+
self
|
|
936
|
+
)
|
|
937
|
+
if ability ~= nil then
|
|
740
938
|
local abilities = self.abilities
|
|
741
939
|
abilities[#abilities + 1] = ability
|
|
742
|
-
return ability
|
|
743
940
|
end
|
|
744
|
-
return
|
|
941
|
+
return ability
|
|
745
942
|
end
|
|
746
943
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
747
944
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -755,47 +952,62 @@ end
|
|
|
755
952
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
756
953
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
757
954
|
end
|
|
758
|
-
function Unit.prototype.
|
|
759
|
-
local
|
|
760
|
-
|
|
761
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
762
|
-
return nil
|
|
763
|
-
end
|
|
764
|
-
return UnitAbility:of(
|
|
765
|
-
getUnitAbility(self.handle, abilityId),
|
|
766
|
-
abilityId,
|
|
767
|
-
self
|
|
768
|
-
)
|
|
955
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
956
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
957
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
769
958
|
end
|
|
770
|
-
function Unit.prototype.removeAbility(self,
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
end
|
|
959
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
960
|
+
local abilities = self.abilities
|
|
961
|
+
for i = 1, #abilities do
|
|
962
|
+
if abilities[i].typeId == abilityTypeId then
|
|
963
|
+
local ability = abilities[i]
|
|
964
|
+
tremove(abilities, i)
|
|
965
|
+
ability:destroy()
|
|
966
|
+
return true
|
|
779
967
|
end
|
|
780
|
-
return true
|
|
781
968
|
end
|
|
782
|
-
return
|
|
969
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
783
970
|
end
|
|
784
971
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
785
972
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
786
973
|
end
|
|
974
|
+
function Unit.prototype.getAbilityRemainingCooldown(self, abilityId)
|
|
975
|
+
return BlzGetUnitAbilityCooldownRemaining(self.handle, abilityId)
|
|
976
|
+
end
|
|
787
977
|
function Unit.prototype.startAbilityCooldown(self, abilityId, cooldown)
|
|
788
978
|
BlzStartUnitAbilityCooldown(self.handle, abilityId, cooldown)
|
|
789
979
|
end
|
|
790
980
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
791
981
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
792
982
|
end
|
|
983
|
+
function Unit.prototype.interruptMovement(self)
|
|
984
|
+
local handle = self.handle
|
|
985
|
+
unitDisableAbility(
|
|
986
|
+
handle,
|
|
987
|
+
fourCC("Amov"),
|
|
988
|
+
true,
|
|
989
|
+
false
|
|
990
|
+
)
|
|
991
|
+
unitDisableAbility(
|
|
992
|
+
handle,
|
|
993
|
+
fourCC("Amov"),
|
|
994
|
+
false,
|
|
995
|
+
false
|
|
996
|
+
)
|
|
997
|
+
end
|
|
793
998
|
function Unit.prototype.interruptAttack(self)
|
|
794
999
|
unitInterruptAttack(self.handle)
|
|
795
1000
|
end
|
|
796
1001
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
797
|
-
|
|
798
|
-
unitDisableAbility(
|
|
1002
|
+
local handle = self.handle
|
|
1003
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
1004
|
+
Timer:run(
|
|
1005
|
+
unitDisableAbility,
|
|
1006
|
+
handle,
|
|
1007
|
+
abilityId,
|
|
1008
|
+
false,
|
|
1009
|
+
false
|
|
1010
|
+
)
|
|
799
1011
|
end
|
|
800
1012
|
function Unit.prototype.getDistanceTo(self, target)
|
|
801
1013
|
local handle = self.handle
|
|
@@ -855,18 +1067,44 @@ function Unit.prototype.unpauseEx(self)
|
|
|
855
1067
|
self:decrementStunCounter()
|
|
856
1068
|
end
|
|
857
1069
|
function Unit.prototype.incrementStunCounter(self)
|
|
858
|
-
local stunCounter = self[
|
|
859
|
-
if not self[
|
|
1070
|
+
local stunCounter = self[102] or 0
|
|
1071
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
|
|
860
1072
|
BlzPauseUnitEx(self.handle, true)
|
|
861
1073
|
end
|
|
862
|
-
self[
|
|
1074
|
+
self[102] = stunCounter + 1
|
|
863
1075
|
end
|
|
864
1076
|
function Unit.prototype.decrementStunCounter(self)
|
|
865
|
-
local stunCounter = self[
|
|
866
|
-
if not self[
|
|
1077
|
+
local stunCounter = self[102] or 0
|
|
1078
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
|
|
867
1079
|
BlzPauseUnitEx(self.handle, false)
|
|
868
1080
|
end
|
|
869
|
-
self[
|
|
1081
|
+
self[102] = stunCounter - 1
|
|
1082
|
+
end
|
|
1083
|
+
function Unit.prototype.incrementForceStunCounter(self)
|
|
1084
|
+
local forceStunCounter = self[103] or 0
|
|
1085
|
+
if forceStunCounter == 0 then
|
|
1086
|
+
local handle = self.handle
|
|
1087
|
+
if not self[101] then
|
|
1088
|
+
for _ = self[102] or 0, -1 do
|
|
1089
|
+
BlzPauseUnitEx(handle, true)
|
|
1090
|
+
end
|
|
1091
|
+
end
|
|
1092
|
+
BlzPauseUnitEx(handle, true)
|
|
1093
|
+
end
|
|
1094
|
+
self[103] = forceStunCounter + 1
|
|
1095
|
+
end
|
|
1096
|
+
function Unit.prototype.decrementForceStunCounter(self)
|
|
1097
|
+
local forceStunCounter = self[103] or 0
|
|
1098
|
+
if forceStunCounter == 1 then
|
|
1099
|
+
local handle = self.handle
|
|
1100
|
+
if not self[101] then
|
|
1101
|
+
for _ = self[102] or 0, -1 do
|
|
1102
|
+
BlzPauseUnitEx(handle, false)
|
|
1103
|
+
end
|
|
1104
|
+
end
|
|
1105
|
+
BlzPauseUnitEx(handle, false)
|
|
1106
|
+
end
|
|
1107
|
+
self[103] = forceStunCounter - 1
|
|
870
1108
|
end
|
|
871
1109
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
872
1110
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -968,8 +1206,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
968
1206
|
)
|
|
969
1207
|
return targetCollection
|
|
970
1208
|
end
|
|
971
|
-
function Unit.getSelectionOf(self, player)
|
|
972
|
-
|
|
1209
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1210
|
+
if target == nil then
|
|
1211
|
+
target = {}
|
|
1212
|
+
end
|
|
1213
|
+
targetCollection = target
|
|
973
1214
|
targetCollectionNextIndex = 1
|
|
974
1215
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
975
1216
|
return targetCollection
|
|
@@ -991,6 +1232,9 @@ end
|
|
|
991
1232
|
function Unit.prototype.__tostring(self)
|
|
992
1233
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
993
1234
|
end
|
|
1235
|
+
function Unit.getBySyncId(self, syncId)
|
|
1236
|
+
return unitBySyncId[syncId]
|
|
1237
|
+
end
|
|
994
1238
|
__TS__SetDescriptor(
|
|
995
1239
|
Unit.prototype,
|
|
996
1240
|
"_deltas",
|
|
@@ -1050,7 +1294,15 @@ __TS__SetDescriptor(
|
|
|
1050
1294
|
Unit.prototype,
|
|
1051
1295
|
"isIllusion",
|
|
1052
1296
|
{get = function(self)
|
|
1053
|
-
return
|
|
1297
|
+
return IsUnitIllusion(self.handle)
|
|
1298
|
+
end},
|
|
1299
|
+
true
|
|
1300
|
+
)
|
|
1301
|
+
__TS__SetDescriptor(
|
|
1302
|
+
Unit.prototype,
|
|
1303
|
+
"isStunned",
|
|
1304
|
+
{get = function(self)
|
|
1305
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1054
1306
|
end},
|
|
1055
1307
|
true
|
|
1056
1308
|
)
|
|
@@ -1071,12 +1323,27 @@ __TS__SetDescriptor(
|
|
|
1071
1323
|
Unit.prototype,
|
|
1072
1324
|
"weapons",
|
|
1073
1325
|
{get = function(self)
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1326
|
+
return {self.firstWeapon, self.secondWeapon}
|
|
1327
|
+
end},
|
|
1328
|
+
true
|
|
1329
|
+
)
|
|
1330
|
+
__TS__SetDescriptor(
|
|
1331
|
+
Unit.prototype,
|
|
1332
|
+
"firstWeapon",
|
|
1333
|
+
{get = function(self)
|
|
1334
|
+
local weapon = __TS__New(____exports.UnitWeapon, self, 0)
|
|
1335
|
+
rawset(self, "firstWeapon", weapon)
|
|
1336
|
+
return weapon
|
|
1337
|
+
end},
|
|
1338
|
+
true
|
|
1339
|
+
)
|
|
1340
|
+
__TS__SetDescriptor(
|
|
1341
|
+
Unit.prototype,
|
|
1342
|
+
"secondWeapon",
|
|
1343
|
+
{get = function(self)
|
|
1344
|
+
local weapon = __TS__New(____exports.UnitWeapon, self, 1)
|
|
1345
|
+
rawset(self, "secondWeapon", weapon)
|
|
1346
|
+
return weapon
|
|
1080
1347
|
end},
|
|
1081
1348
|
true
|
|
1082
1349
|
)
|
|
@@ -1112,6 +1379,19 @@ __TS__SetDescriptor(
|
|
|
1112
1379
|
},
|
|
1113
1380
|
true
|
|
1114
1381
|
)
|
|
1382
|
+
__TS__SetDescriptor(
|
|
1383
|
+
Unit.prototype,
|
|
1384
|
+
"primaryAttribute",
|
|
1385
|
+
{
|
|
1386
|
+
get = function(self)
|
|
1387
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1388
|
+
end,
|
|
1389
|
+
set = function(self, primaryAttribute)
|
|
1390
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1391
|
+
end
|
|
1392
|
+
},
|
|
1393
|
+
true
|
|
1394
|
+
)
|
|
1115
1395
|
__TS__SetDescriptor(
|
|
1116
1396
|
Unit.prototype,
|
|
1117
1397
|
"strengthBase",
|
|
@@ -1233,17 +1513,17 @@ __TS__SetDescriptor(
|
|
|
1233
1513
|
"isTeamGlowVisible",
|
|
1234
1514
|
{
|
|
1235
1515
|
get = function(self)
|
|
1236
|
-
return not self[
|
|
1516
|
+
return not self[107]
|
|
1237
1517
|
end,
|
|
1238
1518
|
set = function(self, isTeamGlowVisible)
|
|
1239
|
-
|
|
1240
|
-
local
|
|
1519
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1520
|
+
local ____temp_7
|
|
1241
1521
|
if not isTeamGlowVisible then
|
|
1242
|
-
|
|
1522
|
+
____temp_7 = true
|
|
1243
1523
|
else
|
|
1244
|
-
|
|
1524
|
+
____temp_7 = nil
|
|
1245
1525
|
end
|
|
1246
|
-
self[
|
|
1526
|
+
self[107] = ____temp_7
|
|
1247
1527
|
end
|
|
1248
1528
|
},
|
|
1249
1529
|
true
|
|
@@ -1252,9 +1532,9 @@ __TS__SetDescriptor(
|
|
|
1252
1532
|
Unit.prototype,
|
|
1253
1533
|
"color",
|
|
1254
1534
|
{set = function(self, color)
|
|
1255
|
-
|
|
1256
|
-
if self[
|
|
1257
|
-
|
|
1535
|
+
SetUnitColor(self.handle, color.handle)
|
|
1536
|
+
if self[107] then
|
|
1537
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1258
1538
|
end
|
|
1259
1539
|
end},
|
|
1260
1540
|
true
|
|
@@ -1277,10 +1557,14 @@ __TS__SetDescriptor(
|
|
|
1277
1557
|
"maxHealth",
|
|
1278
1558
|
{
|
|
1279
1559
|
get = function(self)
|
|
1280
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1560
|
+
return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
|
|
1281
1561
|
end,
|
|
1282
1562
|
set = function(self, maxHealth)
|
|
1283
|
-
|
|
1563
|
+
if maxHealth < 1 and self[104] ~= nil then
|
|
1564
|
+
self[105] = (self[105] or 0) + (1 - maxHealth)
|
|
1565
|
+
maxHealth = 1
|
|
1566
|
+
end
|
|
1567
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
|
|
1284
1568
|
end
|
|
1285
1569
|
},
|
|
1286
1570
|
true
|
|
@@ -1322,10 +1606,10 @@ __TS__SetDescriptor(
|
|
|
1322
1606
|
"health",
|
|
1323
1607
|
{
|
|
1324
1608
|
get = function(self)
|
|
1325
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1609
|
+
return GetWidgetLife(self.handle) - (self[106] or 0)
|
|
1326
1610
|
end,
|
|
1327
1611
|
set = function(self, health)
|
|
1328
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1612
|
+
SetWidgetLife(self.handle, health + (self[106] or 0))
|
|
1329
1613
|
end
|
|
1330
1614
|
},
|
|
1331
1615
|
true
|
|
@@ -1419,7 +1703,7 @@ __TS__SetDescriptor(
|
|
|
1419
1703
|
"x",
|
|
1420
1704
|
{
|
|
1421
1705
|
get = function(self)
|
|
1422
|
-
return getUnitX(self.handle)
|
|
1706
|
+
return self[108] or getUnitX(self.handle)
|
|
1423
1707
|
end,
|
|
1424
1708
|
set = function(self, v)
|
|
1425
1709
|
SetUnitX(self.handle, v)
|
|
@@ -1432,7 +1716,7 @@ __TS__SetDescriptor(
|
|
|
1432
1716
|
"y",
|
|
1433
1717
|
{
|
|
1434
1718
|
get = function(self)
|
|
1435
|
-
return getUnitY(self.handle)
|
|
1719
|
+
return self[109] or getUnitY(self.handle)
|
|
1436
1720
|
end,
|
|
1437
1721
|
set = function(self, v)
|
|
1438
1722
|
SetUnitY(self.handle, v)
|
|
@@ -1518,10 +1802,10 @@ __TS__SetDescriptor(
|
|
|
1518
1802
|
"gold",
|
|
1519
1803
|
{
|
|
1520
1804
|
get = function(self)
|
|
1521
|
-
return
|
|
1805
|
+
return GetResourceAmount(self.handle)
|
|
1522
1806
|
end,
|
|
1523
1807
|
set = function(self, gold)
|
|
1524
|
-
|
|
1808
|
+
SetResourceAmount(self.handle, gold)
|
|
1525
1809
|
end
|
|
1526
1810
|
},
|
|
1527
1811
|
true
|
|
@@ -1536,17 +1820,21 @@ __TS__SetDescriptor(
|
|
|
1536
1820
|
set = function(self, isPaused)
|
|
1537
1821
|
local handle = self.handle
|
|
1538
1822
|
if isPaused and not IsUnitPaused(handle) then
|
|
1539
|
-
self[
|
|
1540
|
-
|
|
1541
|
-
|
|
1823
|
+
self[101] = true
|
|
1824
|
+
if (self[103] or 0) <= 0 then
|
|
1825
|
+
for _ = self[102] or 0, -1 do
|
|
1826
|
+
BlzPauseUnitEx(handle, true)
|
|
1827
|
+
end
|
|
1542
1828
|
end
|
|
1543
1829
|
PauseUnit(handle, true)
|
|
1544
1830
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1545
1831
|
PauseUnit(handle, false)
|
|
1546
|
-
|
|
1547
|
-
|
|
1832
|
+
if (self[103] or 0) <= 0 then
|
|
1833
|
+
for _ = self[102] or 0, -1 do
|
|
1834
|
+
BlzPauseUnitEx(handle, false)
|
|
1835
|
+
end
|
|
1548
1836
|
end
|
|
1549
|
-
self[
|
|
1837
|
+
self[101] = nil
|
|
1550
1838
|
end
|
|
1551
1839
|
end
|
|
1552
1840
|
},
|
|
@@ -1649,6 +1937,19 @@ __TS__SetDescriptor(
|
|
|
1649
1937
|
end},
|
|
1650
1938
|
true
|
|
1651
1939
|
)
|
|
1940
|
+
__TS__SetDescriptor(
|
|
1941
|
+
Unit.prototype,
|
|
1942
|
+
"movementType",
|
|
1943
|
+
{
|
|
1944
|
+
get = function(self)
|
|
1945
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1946
|
+
end,
|
|
1947
|
+
set = function(self, movementType)
|
|
1948
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1949
|
+
end
|
|
1950
|
+
},
|
|
1951
|
+
true
|
|
1952
|
+
)
|
|
1652
1953
|
__TS__SetDescriptor(
|
|
1653
1954
|
Unit.prototype,
|
|
1654
1955
|
"pathing",
|
|
@@ -1830,6 +2131,14 @@ __TS__SetDescriptor(
|
|
|
1830
2131
|
end},
|
|
1831
2132
|
true
|
|
1832
2133
|
)
|
|
2134
|
+
__TS__SetDescriptor(
|
|
2135
|
+
Unit.prototype,
|
|
2136
|
+
"targetAcquiredEvent",
|
|
2137
|
+
{get = function(self)
|
|
2138
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2139
|
+
end},
|
|
2140
|
+
true
|
|
2141
|
+
)
|
|
1833
2142
|
__TS__SetDescriptor(
|
|
1834
2143
|
Unit.prototype,
|
|
1835
2144
|
"onSelect",
|
|
@@ -1903,7 +2212,6 @@ Unit.onDecay = __TS__New(
|
|
|
1903
2212
|
Unit.onResurrect = __TS__New(
|
|
1904
2213
|
InitializingEvent,
|
|
1905
2214
|
function(event)
|
|
1906
|
-
local invoke = Event.invoke
|
|
1907
2215
|
local dead = setmetatable({}, {__mode = "k"})
|
|
1908
2216
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
1909
2217
|
dead[unit] = true
|
|
@@ -1919,10 +2227,15 @@ Unit.onResurrect = __TS__New(
|
|
|
1919
2227
|
Unit.morphEvent = __TS__New(
|
|
1920
2228
|
InitializingEvent,
|
|
1921
2229
|
function(event)
|
|
2230
|
+
local function ifNotLeft(unit)
|
|
2231
|
+
local handle = unit.handle
|
|
2232
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2233
|
+
invoke(event, unit)
|
|
2234
|
+
end
|
|
2235
|
+
end
|
|
1922
2236
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
1923
2237
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
1924
|
-
|
|
1925
|
-
Timer:run(Event.invoke, event, unit)
|
|
2238
|
+
Timer:run(ifNotLeft, unit)
|
|
1926
2239
|
end
|
|
1927
2240
|
end)
|
|
1928
2241
|
end
|
|
@@ -1960,27 +2273,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
1960
2273
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
1961
2274
|
InitializingEvent,
|
|
1962
2275
|
function(event)
|
|
1963
|
-
local invoke = Event.invoke
|
|
1964
2276
|
local function listener(unit, id)
|
|
1965
|
-
local
|
|
2277
|
+
local ____GetSpellTargetUnit_result_10
|
|
1966
2278
|
if GetSpellTargetUnit() then
|
|
1967
|
-
|
|
2279
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
1968
2280
|
else
|
|
1969
|
-
local
|
|
2281
|
+
local ____GetSpellTargetItem_result_9
|
|
1970
2282
|
if GetSpellTargetItem() then
|
|
1971
|
-
|
|
2283
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
1972
2284
|
else
|
|
1973
|
-
local
|
|
2285
|
+
local ____GetSpellTargetDestructable_result_8
|
|
1974
2286
|
if GetSpellTargetDestructable() then
|
|
1975
|
-
|
|
2287
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
1976
2288
|
else
|
|
1977
|
-
|
|
2289
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
1978
2290
|
end
|
|
1979
|
-
|
|
2291
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
1980
2292
|
end
|
|
1981
|
-
|
|
2293
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
1982
2294
|
end
|
|
1983
|
-
local target =
|
|
2295
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
1984
2296
|
if target then
|
|
1985
2297
|
invoke(event, unit, id, target)
|
|
1986
2298
|
end
|
|
@@ -2152,10 +2464,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2152
2464
|
____exports.UnitTriggerEvent,
|
|
2153
2465
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2154
2466
|
function()
|
|
2155
|
-
local
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2467
|
+
local handle = getOrderedUnit()
|
|
2468
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2469
|
+
local unit = ____exports.Unit:of(handle)
|
|
2470
|
+
if unit.state == 1 then
|
|
2471
|
+
return unit, getIssuedOrderId()
|
|
2472
|
+
end
|
|
2159
2473
|
end
|
|
2160
2474
|
return IgnoreEvent
|
|
2161
2475
|
end
|
|
@@ -2177,7 +2491,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2177
2491
|
)
|
|
2178
2492
|
Unit.onDamaging = (function()
|
|
2179
2493
|
local event = __TS__New(Event)
|
|
2180
|
-
local invoke = Event.invoke
|
|
2181
2494
|
local trigger = CreateTrigger()
|
|
2182
2495
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2183
2496
|
TriggerAddCondition(
|
|
@@ -2187,38 +2500,57 @@ Unit.onDamaging = (function()
|
|
|
2187
2500
|
if source and source.typeId == dummyUnitId then
|
|
2188
2501
|
source = nil
|
|
2189
2502
|
end
|
|
2190
|
-
local target = BlzGetEventDamageTarget()
|
|
2503
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2504
|
+
local metadata = damageMetadataByTarget[target]
|
|
2505
|
+
damageMetadataByTarget[target] = nil
|
|
2191
2506
|
local data = {
|
|
2192
2507
|
amount = GetEventDamage(),
|
|
2193
|
-
attackType = BlzGetEventAttackType(),
|
|
2508
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2194
2509
|
damageType = BlzGetEventDamageType(),
|
|
2195
2510
|
weaponType = BlzGetEventWeaponType(),
|
|
2196
|
-
|
|
2511
|
+
metadata = metadata,
|
|
2512
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2513
|
+
originalAmount = GetEventDamage(),
|
|
2514
|
+
originalMetadata = metadata,
|
|
2515
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2197
2516
|
}
|
|
2198
2517
|
if data.isAttack and source then
|
|
2199
|
-
|
|
2200
|
-
if weapon == -1 then
|
|
2201
|
-
local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
|
|
2202
|
-
weapon = 0
|
|
2203
|
-
end
|
|
2204
|
-
data.weapon = assert(source.weapons[weapon + 1])
|
|
2518
|
+
data.weapon = source:chooseWeapon(target)
|
|
2205
2519
|
end
|
|
2206
2520
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2207
2521
|
invoke(
|
|
2208
2522
|
event,
|
|
2209
2523
|
source,
|
|
2210
|
-
|
|
2524
|
+
target,
|
|
2211
2525
|
setmetatable(
|
|
2212
2526
|
{},
|
|
2213
2527
|
{
|
|
2214
2528
|
__index = data,
|
|
2215
2529
|
__newindex = function(self, key, value)
|
|
2216
|
-
damageSetters[key]
|
|
2530
|
+
local damageSetter = damageSetters[key]
|
|
2531
|
+
if damageSetter ~= nil then
|
|
2532
|
+
damageSetter(value)
|
|
2533
|
+
end
|
|
2217
2534
|
data[key] = value
|
|
2218
2535
|
end
|
|
2219
2536
|
}
|
|
2220
2537
|
)
|
|
2221
2538
|
)
|
|
2539
|
+
if data[0] and source then
|
|
2540
|
+
local sourceOwner = source.owner.handle
|
|
2541
|
+
data[1] = sourceOwner
|
|
2542
|
+
local targetOwner = target.owner.handle
|
|
2543
|
+
data[2] = targetOwner
|
|
2544
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2545
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2546
|
+
data[3] = true
|
|
2547
|
+
end
|
|
2548
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2549
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2550
|
+
data[4] = true
|
|
2551
|
+
end
|
|
2552
|
+
end
|
|
2553
|
+
damagingEventByTarget[target] = data
|
|
2222
2554
|
return
|
|
2223
2555
|
end
|
|
2224
2556
|
BlzSetEventDamage(0)
|
|
@@ -2226,7 +2558,7 @@ Unit.onDamaging = (function()
|
|
|
2226
2558
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2227
2559
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2228
2560
|
local sourceOwner = source.owner.handle
|
|
2229
|
-
local targetOwner =
|
|
2561
|
+
local targetOwner = target.owner.handle
|
|
2230
2562
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2231
2563
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2232
2564
|
Timer:run(function()
|
|
@@ -2242,23 +2574,19 @@ Unit.onDamaging = (function()
|
|
|
2242
2574
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2243
2575
|
local condition = ____value[1]
|
|
2244
2576
|
local action = ____value[2]
|
|
2245
|
-
if condition(
|
|
2246
|
-
source,
|
|
2247
|
-
____exports.Unit:of(target),
|
|
2248
|
-
data
|
|
2249
|
-
) then
|
|
2577
|
+
if condition(source, target, data) then
|
|
2250
2578
|
action(
|
|
2251
2579
|
source,
|
|
2252
|
-
|
|
2580
|
+
target,
|
|
2253
2581
|
setmetatable(
|
|
2254
2582
|
{fire = function()
|
|
2255
2583
|
UnitDamageTarget(
|
|
2256
2584
|
source.handle,
|
|
2257
|
-
target,
|
|
2585
|
+
target.handle,
|
|
2258
2586
|
data.amount,
|
|
2259
2587
|
true,
|
|
2260
2588
|
true,
|
|
2261
|
-
data.attackType,
|
|
2589
|
+
attackTypeToNative(data.attackType),
|
|
2262
2590
|
data.damageType,
|
|
2263
2591
|
data.weaponType
|
|
2264
2592
|
)
|
|
@@ -2276,7 +2604,6 @@ end)()
|
|
|
2276
2604
|
Unit.onDamage = __TS__New(
|
|
2277
2605
|
InitializingEvent,
|
|
2278
2606
|
function(event)
|
|
2279
|
-
local invoke = Event.invoke
|
|
2280
2607
|
local trigger = CreateTrigger()
|
|
2281
2608
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2282
2609
|
TriggerAddCondition(
|
|
@@ -2286,29 +2613,54 @@ Unit.onDamage = __TS__New(
|
|
|
2286
2613
|
if source and source.typeId == dummyUnitId then
|
|
2287
2614
|
source = nil
|
|
2288
2615
|
end
|
|
2616
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2617
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2618
|
+
damagingEventByTarget[target] = nil
|
|
2289
2619
|
local data = {
|
|
2290
2620
|
amount = GetEventDamage(),
|
|
2291
|
-
attackType = BlzGetEventAttackType(),
|
|
2621
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2292
2622
|
damageType = BlzGetEventDamageType(),
|
|
2293
2623
|
weaponType = BlzGetEventWeaponType(),
|
|
2624
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2294
2625
|
isAttack = BlzGetEventIsAttack(),
|
|
2626
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2627
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2295
2628
|
preventDeath = damageEventPreventDeath
|
|
2296
2629
|
}
|
|
2630
|
+
if damagingEvent then
|
|
2631
|
+
for key, value in pairs(damagingEvent) do
|
|
2632
|
+
if isAttribute(key) then
|
|
2633
|
+
data[key] = value
|
|
2634
|
+
end
|
|
2635
|
+
end
|
|
2636
|
+
local sourceOwner = damagingEvent[1]
|
|
2637
|
+
if sourceOwner then
|
|
2638
|
+
local targetOwner = damagingEvent[2]
|
|
2639
|
+
if damagingEvent[3] then
|
|
2640
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2641
|
+
end
|
|
2642
|
+
if damagingEvent[4] then
|
|
2643
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2644
|
+
end
|
|
2645
|
+
end
|
|
2646
|
+
end
|
|
2297
2647
|
local evData = setmetatable(
|
|
2298
2648
|
{},
|
|
2299
2649
|
{
|
|
2300
2650
|
__index = data,
|
|
2301
2651
|
__newindex = function(self, key, value)
|
|
2302
|
-
damageSetters[key]
|
|
2652
|
+
local damageSetter = damageSetters[key]
|
|
2653
|
+
if damageSetter ~= nil then
|
|
2654
|
+
damageSetter(value)
|
|
2655
|
+
end
|
|
2303
2656
|
data[key] = value
|
|
2304
2657
|
end
|
|
2305
2658
|
}
|
|
2306
2659
|
)
|
|
2307
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2308
2660
|
invoke(event, source, target, evData)
|
|
2309
2661
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2310
2662
|
local bonusHealth = math.ceil(evData.amount)
|
|
2311
|
-
target[
|
|
2663
|
+
target[106] = (target[106] or 0) + bonusHealth
|
|
2312
2664
|
BlzSetUnitMaxHP(
|
|
2313
2665
|
target.handle,
|
|
2314
2666
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2322,7 +2674,7 @@ Unit.onDamage = __TS__New(
|
|
|
2322
2674
|
evData[0],
|
|
2323
2675
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2324
2676
|
)
|
|
2325
|
-
target[
|
|
2677
|
+
target[106] = (target[106] or 0) - bonusHealth
|
|
2326
2678
|
SetWidgetLife(
|
|
2327
2679
|
target.handle,
|
|
2328
2680
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2342,32 +2694,110 @@ Unit.onDamage = __TS__New(
|
|
|
2342
2694
|
DestroyTrigger(trigger)
|
|
2343
2695
|
end
|
|
2344
2696
|
)
|
|
2345
|
-
Unit.
|
|
2697
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2346
2698
|
____exports.UnitTriggerEvent,
|
|
2347
2699
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2348
2700
|
function()
|
|
2349
2701
|
local unit = getTriggerUnit()
|
|
2350
|
-
|
|
2351
|
-
|
|
2702
|
+
local item = getManipulatedItem()
|
|
2703
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2704
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2352
2705
|
end
|
|
2353
2706
|
return IgnoreEvent
|
|
2354
2707
|
end
|
|
2355
2708
|
)
|
|
2356
|
-
Unit.
|
|
2709
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2357
2710
|
____exports.UnitTriggerEvent,
|
|
2358
2711
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2359
2712
|
function()
|
|
2360
|
-
local
|
|
2361
|
-
|
|
2362
|
-
|
|
2713
|
+
local unitHandle = getTriggerUnit()
|
|
2714
|
+
local itemHandle = getManipulatedItem()
|
|
2715
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2716
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2717
|
+
local item = Item:of(itemHandle)
|
|
2718
|
+
if item.owner ~= unit then
|
|
2719
|
+
return unit, item
|
|
2720
|
+
end
|
|
2363
2721
|
end
|
|
2364
2722
|
return IgnoreEvent
|
|
2365
2723
|
end
|
|
2366
2724
|
)
|
|
2367
|
-
Unit.
|
|
2725
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2368
2726
|
____exports.UnitTriggerEvent,
|
|
2369
2727
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2370
|
-
function()
|
|
2728
|
+
function()
|
|
2729
|
+
local unit = getTriggerUnit()
|
|
2730
|
+
local item = getManipulatedItem()
|
|
2731
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2732
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2733
|
+
end
|
|
2734
|
+
return IgnoreEvent
|
|
2735
|
+
end
|
|
2736
|
+
)
|
|
2737
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2738
|
+
____exports.UnitTriggerEvent,
|
|
2739
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2740
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2741
|
+
)
|
|
2742
|
+
__TS__ObjectDefineProperty(
|
|
2743
|
+
Unit,
|
|
2744
|
+
"itemChargesChangedEvent",
|
|
2745
|
+
{get = function(self)
|
|
2746
|
+
local event = __TS__New(Event)
|
|
2747
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2748
|
+
local unit = item.owner
|
|
2749
|
+
if unit ~= nil then
|
|
2750
|
+
invoke(event, unit, item)
|
|
2751
|
+
end
|
|
2752
|
+
end)
|
|
2753
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2754
|
+
return event
|
|
2755
|
+
end}
|
|
2756
|
+
)
|
|
2757
|
+
__TS__ObjectDefineProperty(
|
|
2758
|
+
Unit,
|
|
2759
|
+
"itemUseOrderEvent",
|
|
2760
|
+
{get = function(self)
|
|
2761
|
+
local event = __TS__New(Event)
|
|
2762
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2763
|
+
local slot = order - orderId("useslot0")
|
|
2764
|
+
local function listener(unit)
|
|
2765
|
+
local item = unit.items[slot + 1]
|
|
2766
|
+
if item ~= nil then
|
|
2767
|
+
invoke(event, unit, item)
|
|
2768
|
+
end
|
|
2769
|
+
end
|
|
2770
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2771
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2772
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2773
|
+
end
|
|
2774
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2775
|
+
return event
|
|
2776
|
+
end}
|
|
2777
|
+
)
|
|
2778
|
+
__TS__ObjectDefineProperty(
|
|
2779
|
+
Unit,
|
|
2780
|
+
"itemMoveOrderEvent",
|
|
2781
|
+
{get = function(self)
|
|
2782
|
+
local event = __TS__New(Event)
|
|
2783
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2784
|
+
local slotTo = order - orderId("moveslot0")
|
|
2785
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2786
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2787
|
+
if slotFrom ~= nil then
|
|
2788
|
+
invoke(
|
|
2789
|
+
event,
|
|
2790
|
+
unit,
|
|
2791
|
+
item,
|
|
2792
|
+
slotFrom,
|
|
2793
|
+
slotTo
|
|
2794
|
+
)
|
|
2795
|
+
end
|
|
2796
|
+
end)
|
|
2797
|
+
end
|
|
2798
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2799
|
+
return event
|
|
2800
|
+
end}
|
|
2371
2801
|
)
|
|
2372
2802
|
__TS__ObjectDefineProperty(
|
|
2373
2803
|
Unit,
|
|
@@ -2394,6 +2824,10 @@ __TS__ObjectDefineProperty(
|
|
|
2394
2824
|
rawset(self, "destroyEvent", destroyEvent)
|
|
2395
2825
|
return destroyEvent
|
|
2396
2826
|
end}
|
|
2827
|
+
)
|
|
2828
|
+
Unit.synchronize = synchronizer(
|
|
2829
|
+
function(unit) return unit.syncId end,
|
|
2830
|
+
function(syncId) return unitBySyncId[syncId] end
|
|
2397
2831
|
);
|
|
2398
2832
|
(function(self)
|
|
2399
2833
|
local leaveAbilityIds = postcompile(function()
|