warscript 0.0.1-dev.ba37a78 → 0.0.1-dev.bad60be
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 +17 -0
- package/attributes.lua +23 -0
- 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 +93 -1
- package/core/types/group.d.ts +0 -1
- package/core/types/handle.d.ts +2 -1
- package/core/types/handle.lua +5 -0
- 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/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/timer.d.ts +7 -8
- package/core/types/timer.lua +18 -21
- 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 +840 -786
- package/engine/ability.d.ts +1 -1
- package/engine/behavior.d.ts +10 -10
- package/engine/behavior.lua +6 -6
- 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 +5 -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 +42 -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 +16 -0
- package/engine/behaviour/ability/remove-buffs.lua +28 -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 +5 -4
- package/engine/behaviour/unit/stun-immunity.lua +43 -27
- package/engine/behaviour/unit.d.ts +36 -2
- package/engine/behaviour/unit.lua +183 -0
- package/engine/buff.d.ts +104 -41
- package/engine/buff.lua +471 -212
- package/engine/game-map.d.ts +7 -0
- package/engine/game-map.lua +32 -0
- package/engine/internal/ability.d.ts +20 -13
- package/engine/internal/ability.lua +97 -76
- package/engine/internal/item/ability.lua +161 -4
- package/engine/internal/item+owner.lua +2 -2
- package/engine/internal/item.d.ts +7 -4
- package/engine/internal/item.lua +131 -28
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
- package/engine/internal/misc/ability-disable-counter.lua +13 -0
- package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
- package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
- package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
- package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
- package/engine/internal/object-data/evasion-probability.d.ts +2 -0
- package/engine/internal/object-data/evasion-probability.lua +16 -0
- package/engine/internal/unit/ability.d.ts +45 -1
- package/engine/internal/unit/ability.lua +98 -14
- package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
- package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot.lua +52 -0
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/bonus.d.ts +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 +51 -0
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit+ability.lua +2 -2
- 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 +25 -6
- package/engine/internal/unit.d.ts +86 -20
- package/engine/internal/unit.lua +615 -206
- package/engine/internal/utility.lua +12 -0
- package/engine/lightning.d.ts +12 -5
- package/engine/lightning.lua +48 -14
- package/engine/local-client.d.ts +7 -2
- package/engine/local-client.lua +82 -0
- package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
- package/engine/object-data/auxiliary/animation-name.lua +16 -0
- package/engine/object-data/auxiliary/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 +89 -33
- 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 +50 -3
- package/engine/object-data/entry/unit-type.lua +452 -61
- 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 +26 -3
- package/engine/object-field/ability.lua +54 -1
- package/engine/object-field/unit.d.ts +50 -3
- package/engine/object-field/unit.lua +186 -7
- package/engine/object-field.d.ts +17 -7
- package/engine/object-field.lua +187 -89
- package/engine/random.d.ts +1 -0
- package/engine/random.lua +9 -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 +42 -1
- package/engine/standard/entries/unit-type.lua +42 -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 +3 -0
- package/engine/standard/fields/unit.lua +5 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +175 -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 +2 -3
- 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/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 +12 -5
- package/utility/arrays.lua +37 -3
- package/utility/bit-set.d.ts +0 -2
- package/utility/functions.d.ts +1 -0
- package/utility/functions.lua +1 -0
- package/utility/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
- package/utility/linked-set.d.ts +12 -3
- package/utility/linked-set.lua +8 -2
- package/utility/lua-maps.d.ts +5 -2
- package/utility/lua-maps.lua +20 -0
- package/utility/lua-sets.d.ts +2 -2
- package/utility/lua-sets.lua +3 -0
- package/utility/reflection.lua +11 -7
- package/utility/types.d.ts +3 -2
- 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,21 @@ 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
|
|
51
65
|
local match = string.match
|
|
52
66
|
local ____tostring = _G.tostring
|
|
53
67
|
local setUnitAnimation = SetUnitAnimation
|
|
54
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
55
68
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
56
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
57
69
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
58
70
|
local getUnitRealField = BlzGetUnitRealField
|
|
59
71
|
local getHeroStr = GetHeroStr
|
|
@@ -72,9 +84,9 @@ local setUnitScale = SetUnitScale
|
|
|
72
84
|
local setUnitPosition = SetUnitPosition
|
|
73
85
|
local setUnitTimeScale = SetUnitTimeScale
|
|
74
86
|
local getHandleId = GetHandleId
|
|
87
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
75
88
|
local createUnit = CreateUnit
|
|
76
89
|
local killUnit = KillUnit
|
|
77
|
-
local setUnitExploded = SetUnitExploded
|
|
78
90
|
local removeUnit = RemoveUnit
|
|
79
91
|
local getUnitTypeId = GetUnitTypeId
|
|
80
92
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -90,8 +102,10 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
90
102
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
91
103
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
92
104
|
local isUnitInRange = IsUnitInRange
|
|
93
|
-
local
|
|
94
|
-
local
|
|
105
|
+
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
106
|
+
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
107
|
+
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
108
|
+
local setUnitWeaponStringField = BlzSetUnitWeaponStringField
|
|
95
109
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
96
110
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
97
111
|
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
@@ -111,15 +125,9 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
111
125
|
local getIssuedOrderId = GetIssuedOrderId
|
|
112
126
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
113
127
|
local unitAlive = UnitAlive
|
|
114
|
-
local unitAddType = UnitAddType
|
|
115
|
-
local unitRemoveType = UnitRemoveType
|
|
116
|
-
local isUnitIllusion = IsUnitIllusion
|
|
117
|
-
local isUnitType = IsUnitType
|
|
118
128
|
local isUnitAlly = IsUnitAlly
|
|
119
129
|
local isUnitEnemy = IsUnitEnemy
|
|
120
130
|
local getOwningPlayer = GetOwningPlayer
|
|
121
|
-
local setUnitColor = SetUnitColor
|
|
122
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
123
131
|
____exports.UnitClassification = {}
|
|
124
132
|
local UnitClassification = ____exports.UnitClassification
|
|
125
133
|
do
|
|
@@ -129,6 +137,7 @@ do
|
|
|
129
137
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
130
138
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
131
139
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
140
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
132
141
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
133
142
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
134
143
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -275,16 +284,14 @@ function UnitTriggerEvent.prototype.____constructor(self, eventType, c)
|
|
|
275
284
|
end
|
|
276
285
|
local function dispatch(event, idGetter, argsGetter)
|
|
277
286
|
local initialized = false
|
|
278
|
-
local x = {}
|
|
279
287
|
return setmetatable(
|
|
280
|
-
|
|
288
|
+
{},
|
|
281
289
|
{
|
|
282
290
|
__index = function(self, id)
|
|
283
291
|
if type(id) ~= "number" then
|
|
284
292
|
return event[id]
|
|
285
293
|
end
|
|
286
294
|
if not initialized then
|
|
287
|
-
local invoke = Event.invoke
|
|
288
295
|
event:addListener(function(...)
|
|
289
296
|
local id = idGetter(...)
|
|
290
297
|
local dispatched = rawget(self, id)
|
|
@@ -322,7 +329,6 @@ local function dispatchAbility(event)
|
|
|
322
329
|
return event[id]
|
|
323
330
|
end
|
|
324
331
|
if not initialized then
|
|
325
|
-
local invoke = Event.invoke
|
|
326
332
|
event:addListener(function(unit, ability, ...)
|
|
327
333
|
local dispatched = rawget(self, ability.typeId)
|
|
328
334
|
if dispatched ~= nil then
|
|
@@ -339,6 +345,9 @@ local function dispatchAbility(event)
|
|
|
339
345
|
}
|
|
340
346
|
)
|
|
341
347
|
end
|
|
348
|
+
local function damagingEventPreventRetaliation(self)
|
|
349
|
+
self[0] = true
|
|
350
|
+
end
|
|
342
351
|
local function damageEventPreventDeath(self, callback, ...)
|
|
343
352
|
if self[0] ~= nil then
|
|
344
353
|
return
|
|
@@ -350,7 +359,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
350
359
|
rawset(self, 1 + i, (select(i, ...)))
|
|
351
360
|
end
|
|
352
361
|
end
|
|
353
|
-
local damageSetters = {
|
|
362
|
+
local damageSetters = {
|
|
363
|
+
amount = BlzSetEventDamage,
|
|
364
|
+
attackType = function(attackType)
|
|
365
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
366
|
+
end,
|
|
367
|
+
damageType = BlzSetEventDamageType,
|
|
368
|
+
weaponType = BlzSetEventWeaponType
|
|
369
|
+
}
|
|
354
370
|
local jlimitopByOperator = {
|
|
355
371
|
[0] = LESS_THAN_OR_EQUAL,
|
|
356
372
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -387,51 +403,171 @@ local getters = {
|
|
|
387
403
|
return BlzGetUnitArmor(unit)
|
|
388
404
|
end
|
|
389
405
|
}
|
|
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
|
-
|
|
406
|
+
____exports.UnitWeapon = __TS__Class()
|
|
407
|
+
local UnitWeapon = ____exports.UnitWeapon
|
|
408
|
+
UnitWeapon.name = "UnitWeapon"
|
|
409
|
+
function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
410
|
+
self.unit = unit
|
|
411
|
+
self.index = index
|
|
412
|
+
end
|
|
413
|
+
__TS__SetDescriptor(
|
|
414
|
+
UnitWeapon.prototype,
|
|
415
|
+
"cooldown",
|
|
416
|
+
{
|
|
417
|
+
get = function(self)
|
|
418
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index)
|
|
419
|
+
end,
|
|
420
|
+
set = function(self, cooldown)
|
|
421
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index, cooldown)
|
|
422
|
+
end
|
|
423
|
+
},
|
|
424
|
+
true
|
|
425
|
+
)
|
|
426
|
+
__TS__SetDescriptor(
|
|
427
|
+
UnitWeapon.prototype,
|
|
428
|
+
"damage",
|
|
429
|
+
{
|
|
430
|
+
get = function(self)
|
|
431
|
+
local minimumDamage = self.damageBase + self.damageDiceCount
|
|
432
|
+
local maximumDamage = self.damageBase + self.damageDiceCount * self.damageDiceSideCount
|
|
433
|
+
return {minimumDamage, maximumDamage}
|
|
434
|
+
end,
|
|
435
|
+
set = function(self, ____bindingPattern0)
|
|
436
|
+
local maximumDamage
|
|
437
|
+
local minimumDamage
|
|
438
|
+
minimumDamage = ____bindingPattern0[1]
|
|
439
|
+
maximumDamage = ____bindingPattern0[2]
|
|
440
|
+
self.damageBase = minimumDamage - 1
|
|
441
|
+
self.damageDiceCount = 1
|
|
442
|
+
self.damageDiceSideCount = maximumDamage - minimumDamage + 1
|
|
443
|
+
end
|
|
444
|
+
},
|
|
445
|
+
true
|
|
446
|
+
)
|
|
447
|
+
__TS__SetDescriptor(
|
|
448
|
+
UnitWeapon.prototype,
|
|
449
|
+
"allowedTargetCombatClassifications",
|
|
450
|
+
{
|
|
451
|
+
get = function(self)
|
|
452
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
453
|
+
end,
|
|
454
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
455
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
456
|
+
end
|
|
457
|
+
},
|
|
458
|
+
true
|
|
459
|
+
)
|
|
460
|
+
__TS__SetDescriptor(
|
|
461
|
+
UnitWeapon.prototype,
|
|
462
|
+
"damageBase",
|
|
463
|
+
{
|
|
464
|
+
get = function(self)
|
|
465
|
+
return BlzGetUnitBaseDamage(self.unit.handle, self.index)
|
|
466
|
+
end,
|
|
467
|
+
set = function(self, damageBase)
|
|
468
|
+
BlzSetUnitBaseDamage(self.unit.handle, self.index, damageBase)
|
|
469
|
+
end
|
|
470
|
+
},
|
|
471
|
+
true
|
|
472
|
+
)
|
|
473
|
+
__TS__SetDescriptor(
|
|
474
|
+
UnitWeapon.prototype,
|
|
475
|
+
"damageDiceCount",
|
|
476
|
+
{
|
|
477
|
+
get = function(self)
|
|
478
|
+
return BlzGetUnitDiceNumber(self.unit.handle, self.index)
|
|
479
|
+
end,
|
|
480
|
+
set = function(self, damageDiceCount)
|
|
481
|
+
BlzSetUnitDiceNumber(self.unit.handle, self.index, damageDiceCount)
|
|
482
|
+
end
|
|
483
|
+
},
|
|
484
|
+
true
|
|
485
|
+
)
|
|
486
|
+
__TS__SetDescriptor(
|
|
487
|
+
UnitWeapon.prototype,
|
|
488
|
+
"damageDiceSideCount",
|
|
489
|
+
{
|
|
490
|
+
get = function(self)
|
|
491
|
+
return BlzGetUnitDiceSides(self.unit.handle, self.index)
|
|
492
|
+
end,
|
|
493
|
+
set = function(self, damageDiceSideCount)
|
|
494
|
+
BlzSetUnitDiceSides(self.unit.handle, self.index, damageDiceSideCount)
|
|
495
|
+
end
|
|
496
|
+
},
|
|
497
|
+
true
|
|
498
|
+
)
|
|
499
|
+
__TS__SetDescriptor(
|
|
500
|
+
UnitWeapon.prototype,
|
|
501
|
+
"range",
|
|
502
|
+
{
|
|
503
|
+
get = function(self)
|
|
504
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_RANGE, self.index)
|
|
505
|
+
end,
|
|
506
|
+
set = function(self, range)
|
|
507
|
+
local handle = self.unit.handle
|
|
508
|
+
local index = self.index
|
|
509
|
+
setUnitWeaponRealField(
|
|
510
|
+
handle,
|
|
511
|
+
UNIT_WEAPON_RF_ATTACK_RANGE,
|
|
512
|
+
index + 1,
|
|
513
|
+
getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index + 1) + (range - getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index))
|
|
514
|
+
)
|
|
515
|
+
end
|
|
516
|
+
},
|
|
517
|
+
true
|
|
518
|
+
)
|
|
519
|
+
__TS__SetDescriptor(
|
|
520
|
+
UnitWeapon.prototype,
|
|
521
|
+
"impactDelay",
|
|
522
|
+
{
|
|
523
|
+
get = function(self)
|
|
524
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index)
|
|
525
|
+
end,
|
|
526
|
+
set = function(self, impactDelay)
|
|
527
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index, impactDelay)
|
|
528
|
+
end
|
|
529
|
+
},
|
|
530
|
+
true
|
|
531
|
+
)
|
|
532
|
+
__TS__SetDescriptor(
|
|
533
|
+
UnitWeapon.prototype,
|
|
534
|
+
"missileArc",
|
|
535
|
+
{
|
|
536
|
+
get = function(self)
|
|
537
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index)
|
|
538
|
+
end,
|
|
539
|
+
set = function(self, missileArc)
|
|
540
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index, missileArc)
|
|
541
|
+
end
|
|
542
|
+
},
|
|
543
|
+
true
|
|
544
|
+
)
|
|
545
|
+
__TS__SetDescriptor(
|
|
546
|
+
UnitWeapon.prototype,
|
|
547
|
+
"missileModelPath",
|
|
548
|
+
{
|
|
549
|
+
get = function(self)
|
|
550
|
+
return getUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index)
|
|
551
|
+
end,
|
|
552
|
+
set = function(self, missileModelPath)
|
|
553
|
+
setUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index, missileModelPath)
|
|
554
|
+
end
|
|
555
|
+
},
|
|
556
|
+
true
|
|
557
|
+
)
|
|
558
|
+
__TS__SetDescriptor(
|
|
559
|
+
UnitWeapon.prototype,
|
|
560
|
+
"missileSpeed",
|
|
561
|
+
{
|
|
562
|
+
get = function(self)
|
|
563
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index)
|
|
564
|
+
end,
|
|
565
|
+
set = function(self, missileSpeed)
|
|
566
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index, missileSpeed)
|
|
567
|
+
end
|
|
568
|
+
},
|
|
569
|
+
true
|
|
570
|
+
)
|
|
435
571
|
local unitInventorySize = UnitInventorySize
|
|
436
572
|
local unitItemInSlot = UnitItemInSlot
|
|
437
573
|
local getItemAbility = BlzGetItemAbility
|
|
@@ -442,8 +578,6 @@ local getAbilityName = GetAbilityName
|
|
|
442
578
|
local unitAddAbility = UnitAddAbility
|
|
443
579
|
local getUnitGoldCost = GetUnitGoldCost
|
|
444
580
|
local getUnitLumberCost = GetUnitWoodCost
|
|
445
|
-
local unitMakeAbilityPermanent = UnitMakeAbilityPermanent
|
|
446
|
-
local unitAddItem = UnitAddItem
|
|
447
581
|
local unitRemoveAbility = UnitRemoveAbility
|
|
448
582
|
local function retrieveAbility(unit, ability, abilityId)
|
|
449
583
|
if ability == nil then
|
|
@@ -453,17 +587,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
453
587
|
____exports.Unit:of(unit)
|
|
454
588
|
)
|
|
455
589
|
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
590
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
468
591
|
local item = unitItemInSlot(unit, i)
|
|
469
592
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -520,12 +643,70 @@ for ____, player in ipairs(Player.all) do
|
|
|
520
643
|
ShowUnit(dummy, false)
|
|
521
644
|
dummies[player] = dummy
|
|
522
645
|
end
|
|
646
|
+
local function delayHealthChecksCallback(unit)
|
|
647
|
+
local counter = (unit[103] or 0) - 1
|
|
648
|
+
if counter ~= 0 then
|
|
649
|
+
unit[103] = counter
|
|
650
|
+
return
|
|
651
|
+
end
|
|
652
|
+
unit[103] = nil
|
|
653
|
+
local healthBonus = unit[104]
|
|
654
|
+
if healthBonus ~= nil then
|
|
655
|
+
unit[104] = nil
|
|
656
|
+
local handle = unit.handle
|
|
657
|
+
BlzSetUnitMaxHP(
|
|
658
|
+
handle,
|
|
659
|
+
BlzGetUnitMaxHP(handle) - healthBonus
|
|
660
|
+
)
|
|
661
|
+
end
|
|
662
|
+
end
|
|
663
|
+
local nextSyncId = 1
|
|
664
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
665
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
666
|
+
local function addAbility(unit, abilityTypeId)
|
|
667
|
+
local handle = unit.handle
|
|
668
|
+
if unitAddAbility(handle, abilityTypeId) then
|
|
669
|
+
local ability = UnitAbility:of(
|
|
670
|
+
checkNotNull(getUnitAbility(handle, abilityTypeId)),
|
|
671
|
+
abilityTypeId,
|
|
672
|
+
unit
|
|
673
|
+
)
|
|
674
|
+
local abilities = unit.abilities
|
|
675
|
+
abilities[#abilities + 1] = ability
|
|
676
|
+
return ability
|
|
677
|
+
end
|
|
678
|
+
return nil
|
|
679
|
+
end
|
|
680
|
+
local function getAbility(unit, abilityTypeId)
|
|
681
|
+
return UnitAbility:of(
|
|
682
|
+
getUnitAbility(unit.handle, abilityTypeId),
|
|
683
|
+
abilityTypeId,
|
|
684
|
+
unit
|
|
685
|
+
)
|
|
686
|
+
end
|
|
687
|
+
local function removeAbility(unit, abilityTypeId)
|
|
688
|
+
if unitRemoveAbility(unit.handle, abilityTypeId) then
|
|
689
|
+
local abilities = unit.abilities
|
|
690
|
+
for i = 1, #abilities do
|
|
691
|
+
if abilities[i].typeId == abilityTypeId then
|
|
692
|
+
abilities[i]:destroy()
|
|
693
|
+
tremove(abilities, i)
|
|
694
|
+
return true
|
|
695
|
+
end
|
|
696
|
+
end
|
|
697
|
+
return true
|
|
698
|
+
end
|
|
699
|
+
return false
|
|
700
|
+
end
|
|
523
701
|
____exports.Unit = __TS__Class()
|
|
524
702
|
local Unit = ____exports.Unit
|
|
525
703
|
Unit.name = "Unit"
|
|
526
704
|
__TS__ClassExtends(Unit, Handle)
|
|
527
705
|
function Unit.prototype.____constructor(self, handle)
|
|
528
706
|
Handle.prototype.____constructor(self, handle)
|
|
707
|
+
local ____nextSyncId_0 = nextSyncId
|
|
708
|
+
nextSyncId = ____nextSyncId_0 + 1
|
|
709
|
+
self.syncId = ____nextSyncId_0
|
|
529
710
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
530
711
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
531
712
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -538,6 +719,7 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
538
719
|
fourCC("Amrf")
|
|
539
720
|
))
|
|
540
721
|
end
|
|
722
|
+
unitBySyncId[self.syncId] = self
|
|
541
723
|
local ____ = self.abilities
|
|
542
724
|
end
|
|
543
725
|
function Unit.prototype.getEvent(self, event, collector)
|
|
@@ -556,6 +738,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
556
738
|
end
|
|
557
739
|
function Unit.prototype.onDestroy(self)
|
|
558
740
|
local handle = self.handle
|
|
741
|
+
self[107] = getUnitX(handle)
|
|
742
|
+
self[108] = getUnitY(handle)
|
|
559
743
|
if not self._owner then
|
|
560
744
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
561
745
|
end
|
|
@@ -623,17 +807,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
623
807
|
end}
|
|
624
808
|
end
|
|
625
809
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
626
|
-
local
|
|
627
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
810
|
+
local ____combatClassification_1 = combatClassification
|
|
811
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
|
|
628
812
|
end
|
|
629
813
|
function Unit.prototype.addClassification(self, classification)
|
|
630
|
-
return
|
|
814
|
+
return UnitAddType(self.handle, classification)
|
|
631
815
|
end
|
|
632
816
|
function Unit.prototype.removeClassification(self, classification)
|
|
633
|
-
return
|
|
817
|
+
return UnitRemoveType(self.handle, classification)
|
|
634
818
|
end
|
|
635
819
|
function Unit.prototype.hasClassification(self, classification)
|
|
636
|
-
return
|
|
820
|
+
return IsUnitType(self.handle, classification)
|
|
637
821
|
end
|
|
638
822
|
function Unit.prototype.isVisibleTo(self, player)
|
|
639
823
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -642,13 +826,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
642
826
|
return isUnitInvisible(self.handle, player.handle)
|
|
643
827
|
end
|
|
644
828
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
645
|
-
local
|
|
829
|
+
local ____temp_2
|
|
646
830
|
if type(x) == "number" then
|
|
647
|
-
|
|
831
|
+
____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
|
|
648
832
|
else
|
|
649
|
-
|
|
833
|
+
____temp_2 = isUnitInRange(self.handle, x.handle, y)
|
|
650
834
|
end
|
|
651
|
-
return
|
|
835
|
+
return ____temp_2
|
|
652
836
|
end
|
|
653
837
|
function Unit.prototype.isAllyOf(self, unit)
|
|
654
838
|
return isUnitAlly(
|
|
@@ -666,13 +850,29 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
666
850
|
if type(animation) == "number" then
|
|
667
851
|
setUnitAnimationByIndex(self.handle, animation)
|
|
668
852
|
elseif rarity then
|
|
669
|
-
|
|
853
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
670
854
|
else
|
|
671
855
|
setUnitAnimation(self.handle, animation)
|
|
672
856
|
end
|
|
673
857
|
end
|
|
858
|
+
function Unit.prototype.resetAnimation(self)
|
|
859
|
+
ResetUnitAnimation(self.handle)
|
|
860
|
+
end
|
|
674
861
|
function Unit.prototype.queueAnimation(self, animation)
|
|
675
|
-
|
|
862
|
+
QueueUnitAnimation(self.handle, animation)
|
|
863
|
+
end
|
|
864
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
865
|
+
if target:isAllowedTarget(self, self.firstWeapon.allowedTargetCombatClassifications) then
|
|
866
|
+
return self.firstWeapon
|
|
867
|
+
end
|
|
868
|
+
if target:isAllowedTarget(target, self.secondWeapon.allowedTargetCombatClassifications) then
|
|
869
|
+
return self.secondWeapon
|
|
870
|
+
end
|
|
871
|
+
return nil
|
|
872
|
+
end
|
|
873
|
+
function Unit.prototype.delayHealthChecks(self)
|
|
874
|
+
self[103] = (self[103] or 0) + 1
|
|
875
|
+
Timer:run(delayHealthChecksCallback, self)
|
|
676
876
|
end
|
|
677
877
|
function Unit.prototype.setPosition(self, x, y)
|
|
678
878
|
setUnitPosition(self.handle, x, y)
|
|
@@ -681,14 +881,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
681
881
|
return IsUnitSelected(self.handle, player.handle)
|
|
682
882
|
end
|
|
683
883
|
function Unit.prototype.explode(self)
|
|
684
|
-
|
|
884
|
+
SetUnitExploded(self.handle, true)
|
|
685
885
|
killUnit(self.handle)
|
|
686
886
|
end
|
|
687
887
|
function Unit.prototype.kill(self)
|
|
688
888
|
killUnit(self.handle)
|
|
689
889
|
end
|
|
690
|
-
function Unit.prototype.revive(self,
|
|
691
|
-
|
|
890
|
+
function Unit.prototype.revive(self, x, y, doEffect)
|
|
891
|
+
local ____ReviveHero_5 = ReviveHero
|
|
892
|
+
local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
|
|
893
|
+
local ____doEffect_3 = doEffect
|
|
894
|
+
if ____doEffect_3 == nil then
|
|
895
|
+
____doEffect_3 = false
|
|
896
|
+
end
|
|
897
|
+
__TS__SparseArrayPush(____array_4, ____doEffect_3)
|
|
898
|
+
____ReviveHero_5(__TS__SparseArraySpread(____array_4))
|
|
692
899
|
end
|
|
693
900
|
function Unit.prototype.healTarget(self, target, amount)
|
|
694
901
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -728,20 +935,16 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
728
935
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
729
936
|
end
|
|
730
937
|
function Unit.prototype.itemInSlot(self, slot)
|
|
731
|
-
return Item:of(
|
|
938
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
732
939
|
end
|
|
733
940
|
function Unit.prototype.addAbility(self, abilityId)
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
abilities[#abilities + 1] = ability
|
|
742
|
-
return ability
|
|
743
|
-
end
|
|
744
|
-
return nil
|
|
941
|
+
return doUnitAbilityAction(
|
|
942
|
+
self.handle,
|
|
943
|
+
abilityId,
|
|
944
|
+
addAbility,
|
|
945
|
+
self,
|
|
946
|
+
abilityId
|
|
947
|
+
)
|
|
745
948
|
end
|
|
746
949
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
747
950
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -756,46 +959,63 @@ function Unit.prototype.hasAbility(self, abilityId)
|
|
|
756
959
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
757
960
|
end
|
|
758
961
|
function Unit.prototype.getAbilityById(self, abilityId)
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
762
|
-
return nil
|
|
763
|
-
end
|
|
764
|
-
return UnitAbility:of(
|
|
765
|
-
getUnitAbility(self.handle, abilityId),
|
|
962
|
+
return doUnitAbilityAction(
|
|
963
|
+
self.handle,
|
|
766
964
|
abilityId,
|
|
767
|
-
|
|
965
|
+
getAbility,
|
|
966
|
+
self,
|
|
967
|
+
abilityId
|
|
768
968
|
)
|
|
769
969
|
end
|
|
770
970
|
function Unit.prototype.removeAbility(self, abilityId)
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
end
|
|
779
|
-
end
|
|
780
|
-
return true
|
|
781
|
-
end
|
|
782
|
-
return false
|
|
971
|
+
return doUnitAbilityAction(
|
|
972
|
+
self.handle,
|
|
973
|
+
abilityId,
|
|
974
|
+
removeAbility,
|
|
975
|
+
self,
|
|
976
|
+
abilityId
|
|
977
|
+
)
|
|
783
978
|
end
|
|
784
979
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
785
980
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
786
981
|
end
|
|
982
|
+
function Unit.prototype.getAbilityRemainingCooldown(self, abilityId)
|
|
983
|
+
return BlzGetUnitAbilityCooldownRemaining(self.handle, abilityId)
|
|
984
|
+
end
|
|
787
985
|
function Unit.prototype.startAbilityCooldown(self, abilityId, cooldown)
|
|
788
986
|
BlzStartUnitAbilityCooldown(self.handle, abilityId, cooldown)
|
|
789
987
|
end
|
|
790
988
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
791
989
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
792
990
|
end
|
|
991
|
+
function Unit.prototype.interruptMovement(self)
|
|
992
|
+
local handle = self.handle
|
|
993
|
+
unitDisableAbility(
|
|
994
|
+
handle,
|
|
995
|
+
fourCC("Amov"),
|
|
996
|
+
true,
|
|
997
|
+
false
|
|
998
|
+
)
|
|
999
|
+
unitDisableAbility(
|
|
1000
|
+
handle,
|
|
1001
|
+
fourCC("Amov"),
|
|
1002
|
+
false,
|
|
1003
|
+
false
|
|
1004
|
+
)
|
|
1005
|
+
end
|
|
793
1006
|
function Unit.prototype.interruptAttack(self)
|
|
794
1007
|
unitInterruptAttack(self.handle)
|
|
795
1008
|
end
|
|
796
1009
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
797
|
-
|
|
798
|
-
unitDisableAbility(
|
|
1010
|
+
local handle = self.handle
|
|
1011
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
1012
|
+
Timer:run(
|
|
1013
|
+
unitDisableAbility,
|
|
1014
|
+
handle,
|
|
1015
|
+
abilityId,
|
|
1016
|
+
false,
|
|
1017
|
+
false
|
|
1018
|
+
)
|
|
799
1019
|
end
|
|
800
1020
|
function Unit.prototype.getDistanceTo(self, target)
|
|
801
1021
|
local handle = self.handle
|
|
@@ -855,18 +1075,18 @@ function Unit.prototype.unpauseEx(self)
|
|
|
855
1075
|
self:decrementStunCounter()
|
|
856
1076
|
end
|
|
857
1077
|
function Unit.prototype.incrementStunCounter(self)
|
|
858
|
-
local stunCounter = self[
|
|
859
|
-
if not self[
|
|
1078
|
+
local stunCounter = self[102] or 0
|
|
1079
|
+
if not self[101] or stunCounter >= 0 then
|
|
860
1080
|
BlzPauseUnitEx(self.handle, true)
|
|
861
1081
|
end
|
|
862
|
-
self[
|
|
1082
|
+
self[102] = stunCounter + 1
|
|
863
1083
|
end
|
|
864
1084
|
function Unit.prototype.decrementStunCounter(self)
|
|
865
|
-
local stunCounter = self[
|
|
866
|
-
if not self[
|
|
1085
|
+
local stunCounter = self[102] or 0
|
|
1086
|
+
if not self[101] or stunCounter >= 1 then
|
|
867
1087
|
BlzPauseUnitEx(self.handle, false)
|
|
868
1088
|
end
|
|
869
|
-
self[
|
|
1089
|
+
self[102] = stunCounter - 1
|
|
870
1090
|
end
|
|
871
1091
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
872
1092
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -968,8 +1188,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
968
1188
|
)
|
|
969
1189
|
return targetCollection
|
|
970
1190
|
end
|
|
971
|
-
function Unit.getSelectionOf(self, player)
|
|
972
|
-
|
|
1191
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1192
|
+
if target == nil then
|
|
1193
|
+
target = {}
|
|
1194
|
+
end
|
|
1195
|
+
targetCollection = target
|
|
973
1196
|
targetCollectionNextIndex = 1
|
|
974
1197
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
975
1198
|
return targetCollection
|
|
@@ -991,6 +1214,9 @@ end
|
|
|
991
1214
|
function Unit.prototype.__tostring(self)
|
|
992
1215
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
993
1216
|
end
|
|
1217
|
+
function Unit.getBySyncId(self, syncId)
|
|
1218
|
+
return unitBySyncId[syncId]
|
|
1219
|
+
end
|
|
994
1220
|
__TS__SetDescriptor(
|
|
995
1221
|
Unit.prototype,
|
|
996
1222
|
"_deltas",
|
|
@@ -1050,7 +1276,15 @@ __TS__SetDescriptor(
|
|
|
1050
1276
|
Unit.prototype,
|
|
1051
1277
|
"isIllusion",
|
|
1052
1278
|
{get = function(self)
|
|
1053
|
-
return
|
|
1279
|
+
return IsUnitIllusion(self.handle)
|
|
1280
|
+
end},
|
|
1281
|
+
true
|
|
1282
|
+
)
|
|
1283
|
+
__TS__SetDescriptor(
|
|
1284
|
+
Unit.prototype,
|
|
1285
|
+
"isStunned",
|
|
1286
|
+
{get = function(self)
|
|
1287
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1054
1288
|
end},
|
|
1055
1289
|
true
|
|
1056
1290
|
)
|
|
@@ -1071,12 +1305,27 @@ __TS__SetDescriptor(
|
|
|
1071
1305
|
Unit.prototype,
|
|
1072
1306
|
"weapons",
|
|
1073
1307
|
{get = function(self)
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1308
|
+
return {self.firstWeapon, self.secondWeapon}
|
|
1309
|
+
end},
|
|
1310
|
+
true
|
|
1311
|
+
)
|
|
1312
|
+
__TS__SetDescriptor(
|
|
1313
|
+
Unit.prototype,
|
|
1314
|
+
"firstWeapon",
|
|
1315
|
+
{get = function(self)
|
|
1316
|
+
local weapon = __TS__New(____exports.UnitWeapon, self, 0)
|
|
1317
|
+
rawset(self, "firstWeapon", weapon)
|
|
1318
|
+
return weapon
|
|
1319
|
+
end},
|
|
1320
|
+
true
|
|
1321
|
+
)
|
|
1322
|
+
__TS__SetDescriptor(
|
|
1323
|
+
Unit.prototype,
|
|
1324
|
+
"secondWeapon",
|
|
1325
|
+
{get = function(self)
|
|
1326
|
+
local weapon = __TS__New(____exports.UnitWeapon, self, 1)
|
|
1327
|
+
rawset(self, "secondWeapon", weapon)
|
|
1328
|
+
return weapon
|
|
1080
1329
|
end},
|
|
1081
1330
|
true
|
|
1082
1331
|
)
|
|
@@ -1112,6 +1361,19 @@ __TS__SetDescriptor(
|
|
|
1112
1361
|
},
|
|
1113
1362
|
true
|
|
1114
1363
|
)
|
|
1364
|
+
__TS__SetDescriptor(
|
|
1365
|
+
Unit.prototype,
|
|
1366
|
+
"primaryAttribute",
|
|
1367
|
+
{
|
|
1368
|
+
get = function(self)
|
|
1369
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1370
|
+
end,
|
|
1371
|
+
set = function(self, primaryAttribute)
|
|
1372
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1373
|
+
end
|
|
1374
|
+
},
|
|
1375
|
+
true
|
|
1376
|
+
)
|
|
1115
1377
|
__TS__SetDescriptor(
|
|
1116
1378
|
Unit.prototype,
|
|
1117
1379
|
"strengthBase",
|
|
@@ -1233,17 +1495,17 @@ __TS__SetDescriptor(
|
|
|
1233
1495
|
"isTeamGlowVisible",
|
|
1234
1496
|
{
|
|
1235
1497
|
get = function(self)
|
|
1236
|
-
return not self[
|
|
1498
|
+
return not self[106]
|
|
1237
1499
|
end,
|
|
1238
1500
|
set = function(self, isTeamGlowVisible)
|
|
1239
|
-
|
|
1240
|
-
local
|
|
1501
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1502
|
+
local ____temp_6
|
|
1241
1503
|
if not isTeamGlowVisible then
|
|
1242
|
-
|
|
1504
|
+
____temp_6 = true
|
|
1243
1505
|
else
|
|
1244
|
-
|
|
1506
|
+
____temp_6 = nil
|
|
1245
1507
|
end
|
|
1246
|
-
self[
|
|
1508
|
+
self[106] = ____temp_6
|
|
1247
1509
|
end
|
|
1248
1510
|
},
|
|
1249
1511
|
true
|
|
@@ -1252,9 +1514,9 @@ __TS__SetDescriptor(
|
|
|
1252
1514
|
Unit.prototype,
|
|
1253
1515
|
"color",
|
|
1254
1516
|
{set = function(self, color)
|
|
1255
|
-
|
|
1256
|
-
if self[
|
|
1257
|
-
|
|
1517
|
+
SetUnitColor(self.handle, color.handle)
|
|
1518
|
+
if self[106] then
|
|
1519
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1258
1520
|
end
|
|
1259
1521
|
end},
|
|
1260
1522
|
true
|
|
@@ -1277,10 +1539,14 @@ __TS__SetDescriptor(
|
|
|
1277
1539
|
"maxHealth",
|
|
1278
1540
|
{
|
|
1279
1541
|
get = function(self)
|
|
1280
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1542
|
+
return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
|
|
1281
1543
|
end,
|
|
1282
1544
|
set = function(self, maxHealth)
|
|
1283
|
-
|
|
1545
|
+
if maxHealth < 1 and self[103] ~= nil then
|
|
1546
|
+
self[104] = (self[104] or 0) + (1 - maxHealth)
|
|
1547
|
+
maxHealth = 1
|
|
1548
|
+
end
|
|
1549
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
|
|
1284
1550
|
end
|
|
1285
1551
|
},
|
|
1286
1552
|
true
|
|
@@ -1322,10 +1588,10 @@ __TS__SetDescriptor(
|
|
|
1322
1588
|
"health",
|
|
1323
1589
|
{
|
|
1324
1590
|
get = function(self)
|
|
1325
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1591
|
+
return GetWidgetLife(self.handle) - (self[105] or 0)
|
|
1326
1592
|
end,
|
|
1327
1593
|
set = function(self, health)
|
|
1328
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1594
|
+
SetWidgetLife(self.handle, health + (self[105] or 0))
|
|
1329
1595
|
end
|
|
1330
1596
|
},
|
|
1331
1597
|
true
|
|
@@ -1419,7 +1685,7 @@ __TS__SetDescriptor(
|
|
|
1419
1685
|
"x",
|
|
1420
1686
|
{
|
|
1421
1687
|
get = function(self)
|
|
1422
|
-
return getUnitX(self.handle)
|
|
1688
|
+
return self[107] or getUnitX(self.handle)
|
|
1423
1689
|
end,
|
|
1424
1690
|
set = function(self, v)
|
|
1425
1691
|
SetUnitX(self.handle, v)
|
|
@@ -1432,7 +1698,7 @@ __TS__SetDescriptor(
|
|
|
1432
1698
|
"y",
|
|
1433
1699
|
{
|
|
1434
1700
|
get = function(self)
|
|
1435
|
-
return getUnitY(self.handle)
|
|
1701
|
+
return self[108] or getUnitY(self.handle)
|
|
1436
1702
|
end,
|
|
1437
1703
|
set = function(self, v)
|
|
1438
1704
|
SetUnitY(self.handle, v)
|
|
@@ -1518,10 +1784,10 @@ __TS__SetDescriptor(
|
|
|
1518
1784
|
"gold",
|
|
1519
1785
|
{
|
|
1520
1786
|
get = function(self)
|
|
1521
|
-
return
|
|
1787
|
+
return GetResourceAmount(self.handle)
|
|
1522
1788
|
end,
|
|
1523
1789
|
set = function(self, gold)
|
|
1524
|
-
|
|
1790
|
+
SetResourceAmount(self.handle, gold)
|
|
1525
1791
|
end
|
|
1526
1792
|
},
|
|
1527
1793
|
true
|
|
@@ -1536,17 +1802,17 @@ __TS__SetDescriptor(
|
|
|
1536
1802
|
set = function(self, isPaused)
|
|
1537
1803
|
local handle = self.handle
|
|
1538
1804
|
if isPaused and not IsUnitPaused(handle) then
|
|
1539
|
-
self[
|
|
1540
|
-
for _ = self[
|
|
1805
|
+
self[101] = true
|
|
1806
|
+
for _ = self[102] or 0, -1 do
|
|
1541
1807
|
BlzPauseUnitEx(handle, true)
|
|
1542
1808
|
end
|
|
1543
1809
|
PauseUnit(handle, true)
|
|
1544
1810
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1545
1811
|
PauseUnit(handle, false)
|
|
1546
|
-
for _ = self[
|
|
1812
|
+
for _ = self[102] or 0, -1 do
|
|
1547
1813
|
BlzPauseUnitEx(handle, false)
|
|
1548
1814
|
end
|
|
1549
|
-
self[
|
|
1815
|
+
self[101] = nil
|
|
1550
1816
|
end
|
|
1551
1817
|
end
|
|
1552
1818
|
},
|
|
@@ -1649,6 +1915,19 @@ __TS__SetDescriptor(
|
|
|
1649
1915
|
end},
|
|
1650
1916
|
true
|
|
1651
1917
|
)
|
|
1918
|
+
__TS__SetDescriptor(
|
|
1919
|
+
Unit.prototype,
|
|
1920
|
+
"movementType",
|
|
1921
|
+
{
|
|
1922
|
+
get = function(self)
|
|
1923
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1924
|
+
end,
|
|
1925
|
+
set = function(self, movementType)
|
|
1926
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1927
|
+
end
|
|
1928
|
+
},
|
|
1929
|
+
true
|
|
1930
|
+
)
|
|
1652
1931
|
__TS__SetDescriptor(
|
|
1653
1932
|
Unit.prototype,
|
|
1654
1933
|
"pathing",
|
|
@@ -1830,6 +2109,14 @@ __TS__SetDescriptor(
|
|
|
1830
2109
|
end},
|
|
1831
2110
|
true
|
|
1832
2111
|
)
|
|
2112
|
+
__TS__SetDescriptor(
|
|
2113
|
+
Unit.prototype,
|
|
2114
|
+
"targetAcquiredEvent",
|
|
2115
|
+
{get = function(self)
|
|
2116
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2117
|
+
end},
|
|
2118
|
+
true
|
|
2119
|
+
)
|
|
1833
2120
|
__TS__SetDescriptor(
|
|
1834
2121
|
Unit.prototype,
|
|
1835
2122
|
"onSelect",
|
|
@@ -1903,7 +2190,6 @@ Unit.onDecay = __TS__New(
|
|
|
1903
2190
|
Unit.onResurrect = __TS__New(
|
|
1904
2191
|
InitializingEvent,
|
|
1905
2192
|
function(event)
|
|
1906
|
-
local invoke = Event.invoke
|
|
1907
2193
|
local dead = setmetatable({}, {__mode = "k"})
|
|
1908
2194
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
1909
2195
|
dead[unit] = true
|
|
@@ -1919,10 +2205,15 @@ Unit.onResurrect = __TS__New(
|
|
|
1919
2205
|
Unit.morphEvent = __TS__New(
|
|
1920
2206
|
InitializingEvent,
|
|
1921
2207
|
function(event)
|
|
2208
|
+
local function ifNotLeft(unit)
|
|
2209
|
+
local handle = unit.handle
|
|
2210
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2211
|
+
invoke(event, unit)
|
|
2212
|
+
end
|
|
2213
|
+
end
|
|
1922
2214
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
1923
2215
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
1924
|
-
|
|
1925
|
-
Timer:run(Event.invoke, event, unit)
|
|
2216
|
+
Timer:run(ifNotLeft, unit)
|
|
1926
2217
|
end
|
|
1927
2218
|
end)
|
|
1928
2219
|
end
|
|
@@ -1960,27 +2251,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
1960
2251
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
1961
2252
|
InitializingEvent,
|
|
1962
2253
|
function(event)
|
|
1963
|
-
local invoke = Event.invoke
|
|
1964
2254
|
local function listener(unit, id)
|
|
1965
|
-
local
|
|
2255
|
+
local ____GetSpellTargetUnit_result_9
|
|
1966
2256
|
if GetSpellTargetUnit() then
|
|
1967
|
-
|
|
2257
|
+
____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
1968
2258
|
else
|
|
1969
|
-
local
|
|
2259
|
+
local ____GetSpellTargetItem_result_8
|
|
1970
2260
|
if GetSpellTargetItem() then
|
|
1971
|
-
|
|
2261
|
+
____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
|
|
1972
2262
|
else
|
|
1973
|
-
local
|
|
2263
|
+
local ____GetSpellTargetDestructable_result_7
|
|
1974
2264
|
if GetSpellTargetDestructable() then
|
|
1975
|
-
|
|
2265
|
+
____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
|
|
1976
2266
|
else
|
|
1977
|
-
|
|
2267
|
+
____GetSpellTargetDestructable_result_7 = nil
|
|
1978
2268
|
end
|
|
1979
|
-
|
|
2269
|
+
____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
|
|
1980
2270
|
end
|
|
1981
|
-
|
|
2271
|
+
____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
|
|
1982
2272
|
end
|
|
1983
|
-
local target =
|
|
2273
|
+
local target = ____GetSpellTargetUnit_result_9
|
|
1984
2274
|
if target then
|
|
1985
2275
|
invoke(event, unit, id, target)
|
|
1986
2276
|
end
|
|
@@ -2152,10 +2442,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2152
2442
|
____exports.UnitTriggerEvent,
|
|
2153
2443
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2154
2444
|
function()
|
|
2155
|
-
local
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2445
|
+
local handle = getOrderedUnit()
|
|
2446
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2447
|
+
local unit = ____exports.Unit:of(handle)
|
|
2448
|
+
if unit.state == 1 then
|
|
2449
|
+
return unit, getIssuedOrderId()
|
|
2450
|
+
end
|
|
2159
2451
|
end
|
|
2160
2452
|
return IgnoreEvent
|
|
2161
2453
|
end
|
|
@@ -2177,7 +2469,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2177
2469
|
)
|
|
2178
2470
|
Unit.onDamaging = (function()
|
|
2179
2471
|
local event = __TS__New(Event)
|
|
2180
|
-
local invoke = Event.invoke
|
|
2181
2472
|
local trigger = CreateTrigger()
|
|
2182
2473
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2183
2474
|
TriggerAddCondition(
|
|
@@ -2187,13 +2478,19 @@ Unit.onDamaging = (function()
|
|
|
2187
2478
|
if source and source.typeId == dummyUnitId then
|
|
2188
2479
|
source = nil
|
|
2189
2480
|
end
|
|
2190
|
-
local target = BlzGetEventDamageTarget()
|
|
2481
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2482
|
+
local metadata = damageMetadataByTarget[target]
|
|
2483
|
+
damageMetadataByTarget[target] = nil
|
|
2191
2484
|
local data = {
|
|
2192
2485
|
amount = GetEventDamage(),
|
|
2193
|
-
attackType = BlzGetEventAttackType(),
|
|
2486
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2194
2487
|
damageType = BlzGetEventDamageType(),
|
|
2195
2488
|
weaponType = BlzGetEventWeaponType(),
|
|
2196
|
-
|
|
2489
|
+
metadata = metadata,
|
|
2490
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2491
|
+
originalAmount = GetEventDamage(),
|
|
2492
|
+
originalMetadata = metadata,
|
|
2493
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2197
2494
|
}
|
|
2198
2495
|
if data.isAttack and source then
|
|
2199
2496
|
local weapon = BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 1) and (BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 0) and -1 or 1) or 0
|
|
@@ -2207,18 +2504,36 @@ Unit.onDamaging = (function()
|
|
|
2207
2504
|
invoke(
|
|
2208
2505
|
event,
|
|
2209
2506
|
source,
|
|
2210
|
-
|
|
2507
|
+
target,
|
|
2211
2508
|
setmetatable(
|
|
2212
2509
|
{},
|
|
2213
2510
|
{
|
|
2214
2511
|
__index = data,
|
|
2215
2512
|
__newindex = function(self, key, value)
|
|
2216
|
-
damageSetters[key]
|
|
2513
|
+
local damageSetter = damageSetters[key]
|
|
2514
|
+
if damageSetter ~= nil then
|
|
2515
|
+
damageSetter(value)
|
|
2516
|
+
end
|
|
2217
2517
|
data[key] = value
|
|
2218
2518
|
end
|
|
2219
2519
|
}
|
|
2220
2520
|
)
|
|
2221
2521
|
)
|
|
2522
|
+
if data[0] and source then
|
|
2523
|
+
local sourceOwner = source.owner.handle
|
|
2524
|
+
data[1] = sourceOwner
|
|
2525
|
+
local targetOwner = target.owner.handle
|
|
2526
|
+
data[2] = targetOwner
|
|
2527
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2528
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2529
|
+
data[3] = true
|
|
2530
|
+
end
|
|
2531
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2532
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2533
|
+
data[4] = true
|
|
2534
|
+
end
|
|
2535
|
+
end
|
|
2536
|
+
damagingEventByTarget[target] = data
|
|
2222
2537
|
return
|
|
2223
2538
|
end
|
|
2224
2539
|
BlzSetEventDamage(0)
|
|
@@ -2226,7 +2541,7 @@ Unit.onDamaging = (function()
|
|
|
2226
2541
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2227
2542
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2228
2543
|
local sourceOwner = source.owner.handle
|
|
2229
|
-
local targetOwner =
|
|
2544
|
+
local targetOwner = target.owner.handle
|
|
2230
2545
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2231
2546
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2232
2547
|
Timer:run(function()
|
|
@@ -2242,23 +2557,19 @@ Unit.onDamaging = (function()
|
|
|
2242
2557
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2243
2558
|
local condition = ____value[1]
|
|
2244
2559
|
local action = ____value[2]
|
|
2245
|
-
if condition(
|
|
2246
|
-
source,
|
|
2247
|
-
____exports.Unit:of(target),
|
|
2248
|
-
data
|
|
2249
|
-
) then
|
|
2560
|
+
if condition(source, target, data) then
|
|
2250
2561
|
action(
|
|
2251
2562
|
source,
|
|
2252
|
-
|
|
2563
|
+
target,
|
|
2253
2564
|
setmetatable(
|
|
2254
2565
|
{fire = function()
|
|
2255
2566
|
UnitDamageTarget(
|
|
2256
2567
|
source.handle,
|
|
2257
|
-
target,
|
|
2568
|
+
target.handle,
|
|
2258
2569
|
data.amount,
|
|
2259
2570
|
true,
|
|
2260
2571
|
true,
|
|
2261
|
-
data.attackType,
|
|
2572
|
+
attackTypeToNative(data.attackType),
|
|
2262
2573
|
data.damageType,
|
|
2263
2574
|
data.weaponType
|
|
2264
2575
|
)
|
|
@@ -2276,7 +2587,6 @@ end)()
|
|
|
2276
2587
|
Unit.onDamage = __TS__New(
|
|
2277
2588
|
InitializingEvent,
|
|
2278
2589
|
function(event)
|
|
2279
|
-
local invoke = Event.invoke
|
|
2280
2590
|
local trigger = CreateTrigger()
|
|
2281
2591
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2282
2592
|
TriggerAddCondition(
|
|
@@ -2286,29 +2596,54 @@ Unit.onDamage = __TS__New(
|
|
|
2286
2596
|
if source and source.typeId == dummyUnitId then
|
|
2287
2597
|
source = nil
|
|
2288
2598
|
end
|
|
2599
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2600
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2601
|
+
damagingEventByTarget[target] = nil
|
|
2289
2602
|
local data = {
|
|
2290
2603
|
amount = GetEventDamage(),
|
|
2291
|
-
attackType = BlzGetEventAttackType(),
|
|
2604
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2292
2605
|
damageType = BlzGetEventDamageType(),
|
|
2293
2606
|
weaponType = BlzGetEventWeaponType(),
|
|
2607
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2294
2608
|
isAttack = BlzGetEventIsAttack(),
|
|
2609
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2610
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2295
2611
|
preventDeath = damageEventPreventDeath
|
|
2296
2612
|
}
|
|
2613
|
+
if damagingEvent then
|
|
2614
|
+
for key, value in pairs(damagingEvent) do
|
|
2615
|
+
if isAttribute(key) then
|
|
2616
|
+
data[key] = value
|
|
2617
|
+
end
|
|
2618
|
+
end
|
|
2619
|
+
local sourceOwner = damagingEvent[1]
|
|
2620
|
+
if sourceOwner then
|
|
2621
|
+
local targetOwner = damagingEvent[2]
|
|
2622
|
+
if damagingEvent[3] then
|
|
2623
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2624
|
+
end
|
|
2625
|
+
if damagingEvent[4] then
|
|
2626
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2627
|
+
end
|
|
2628
|
+
end
|
|
2629
|
+
end
|
|
2297
2630
|
local evData = setmetatable(
|
|
2298
2631
|
{},
|
|
2299
2632
|
{
|
|
2300
2633
|
__index = data,
|
|
2301
2634
|
__newindex = function(self, key, value)
|
|
2302
|
-
damageSetters[key]
|
|
2635
|
+
local damageSetter = damageSetters[key]
|
|
2636
|
+
if damageSetter ~= nil then
|
|
2637
|
+
damageSetter(value)
|
|
2638
|
+
end
|
|
2303
2639
|
data[key] = value
|
|
2304
2640
|
end
|
|
2305
2641
|
}
|
|
2306
2642
|
)
|
|
2307
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2308
2643
|
invoke(event, source, target, evData)
|
|
2309
2644
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2310
2645
|
local bonusHealth = math.ceil(evData.amount)
|
|
2311
|
-
target[
|
|
2646
|
+
target[105] = (target[105] or 0) + bonusHealth
|
|
2312
2647
|
BlzSetUnitMaxHP(
|
|
2313
2648
|
target.handle,
|
|
2314
2649
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2322,7 +2657,7 @@ Unit.onDamage = __TS__New(
|
|
|
2322
2657
|
evData[0],
|
|
2323
2658
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2324
2659
|
)
|
|
2325
|
-
target[
|
|
2660
|
+
target[105] = (target[105] or 0) - bonusHealth
|
|
2326
2661
|
SetWidgetLife(
|
|
2327
2662
|
target.handle,
|
|
2328
2663
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2342,32 +2677,106 @@ Unit.onDamage = __TS__New(
|
|
|
2342
2677
|
DestroyTrigger(trigger)
|
|
2343
2678
|
end
|
|
2344
2679
|
)
|
|
2345
|
-
Unit.
|
|
2680
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2346
2681
|
____exports.UnitTriggerEvent,
|
|
2347
2682
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2348
2683
|
function()
|
|
2349
2684
|
local unit = getTriggerUnit()
|
|
2350
|
-
|
|
2351
|
-
|
|
2685
|
+
local item = getManipulatedItem()
|
|
2686
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2687
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2352
2688
|
end
|
|
2353
2689
|
return IgnoreEvent
|
|
2354
2690
|
end
|
|
2355
2691
|
)
|
|
2356
|
-
Unit.
|
|
2692
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2357
2693
|
____exports.UnitTriggerEvent,
|
|
2358
2694
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2359
2695
|
function()
|
|
2360
2696
|
local unit = getTriggerUnit()
|
|
2361
|
-
|
|
2362
|
-
|
|
2697
|
+
local item = getManipulatedItem()
|
|
2698
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2699
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2363
2700
|
end
|
|
2364
2701
|
return IgnoreEvent
|
|
2365
2702
|
end
|
|
2366
2703
|
)
|
|
2367
|
-
Unit.
|
|
2704
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2368
2705
|
____exports.UnitTriggerEvent,
|
|
2369
2706
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2370
|
-
function()
|
|
2707
|
+
function()
|
|
2708
|
+
local unit = getTriggerUnit()
|
|
2709
|
+
local item = getManipulatedItem()
|
|
2710
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2711
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2712
|
+
end
|
|
2713
|
+
return IgnoreEvent
|
|
2714
|
+
end
|
|
2715
|
+
)
|
|
2716
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2717
|
+
____exports.UnitTriggerEvent,
|
|
2718
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2719
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2720
|
+
)
|
|
2721
|
+
__TS__ObjectDefineProperty(
|
|
2722
|
+
Unit,
|
|
2723
|
+
"itemChargesChangedEvent",
|
|
2724
|
+
{get = function(self)
|
|
2725
|
+
local event = __TS__New(Event)
|
|
2726
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2727
|
+
local unit = item.owner
|
|
2728
|
+
if unit ~= nil then
|
|
2729
|
+
invoke(event, unit, item)
|
|
2730
|
+
end
|
|
2731
|
+
end)
|
|
2732
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2733
|
+
return event
|
|
2734
|
+
end}
|
|
2735
|
+
)
|
|
2736
|
+
__TS__ObjectDefineProperty(
|
|
2737
|
+
Unit,
|
|
2738
|
+
"itemUseOrderEvent",
|
|
2739
|
+
{get = function(self)
|
|
2740
|
+
local event = __TS__New(Event)
|
|
2741
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2742
|
+
local slot = order - orderId("useslot0")
|
|
2743
|
+
local function listener(unit)
|
|
2744
|
+
local item = unit.items[slot + 1]
|
|
2745
|
+
if item ~= nil then
|
|
2746
|
+
invoke(event, unit, item)
|
|
2747
|
+
end
|
|
2748
|
+
end
|
|
2749
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2750
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2751
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2752
|
+
end
|
|
2753
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2754
|
+
return event
|
|
2755
|
+
end}
|
|
2756
|
+
)
|
|
2757
|
+
__TS__ObjectDefineProperty(
|
|
2758
|
+
Unit,
|
|
2759
|
+
"itemMoveOrderEvent",
|
|
2760
|
+
{get = function(self)
|
|
2761
|
+
local event = __TS__New(Event)
|
|
2762
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2763
|
+
local slotTo = order - orderId("moveslot0")
|
|
2764
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2765
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2766
|
+
if slotFrom ~= nil then
|
|
2767
|
+
invoke(
|
|
2768
|
+
event,
|
|
2769
|
+
unit,
|
|
2770
|
+
item,
|
|
2771
|
+
slotFrom,
|
|
2772
|
+
slotTo
|
|
2773
|
+
)
|
|
2774
|
+
end
|
|
2775
|
+
end)
|
|
2776
|
+
end
|
|
2777
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2778
|
+
return event
|
|
2779
|
+
end}
|
|
2371
2780
|
)
|
|
2372
2781
|
__TS__ObjectDefineProperty(
|
|
2373
2782
|
Unit,
|