warscript 0.0.1-dev.2af030d → 0.0.1-dev.2cd2e68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/attributes.d.ts +5 -1
- package/attributes.lua +8 -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 +93 -1
- 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/order.d.ts +1 -0
- package/core/types/order.lua +11 -1
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/timer.d.ts +6 -7
- 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 +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 +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 +153 -18
- package/engine/behaviour/unit/stun-immunity.d.ts +0 -1
- package/engine/behaviour/unit.d.ts +25 -2
- package/engine/behaviour/unit.lua +137 -0
- package/engine/buff.d.ts +103 -41
- package/engine/buff.lua +465 -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 +112 -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 +15 -1
- package/engine/internal/unit/ability.lua +50 -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+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 +53 -15
- package/engine/internal/unit.lua +345 -121
- 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 +10 -4
- package/engine/object-data/entry/unit-type.lua +155 -92
- 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 +46 -3
- package/engine/object-field/unit.lua +173 -7
- package/engine/object-field.d.ts +15 -7
- package/engine/object-field.lua +178 -81
- 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 +18 -0
- package/engine/standard/entries/unit-type.lua +18 -0
- package/engine/standard/fields/ability.d.ts +3 -1
- package/engine/standard/fields/ability.lua +3 -1
- package/engine/unit.d.ts +3 -0
- package/engine/unit.lua +12 -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 -13
- 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 +16 -0
- package/string.lua +5 -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 +4 -2
- package/utility/lua-maps.lua +16 -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 +1 -0
- package/core/mapbounds.d.ts +0 -8
- package/core/mapbounds.lua +0 -12
package/engine/internal/unit.lua
CHANGED
|
@@ -7,6 +7,9 @@ local __TS__Class = ____lualib.__TS__Class
|
|
|
7
7
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
8
8
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
9
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
|
|
10
13
|
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
11
14
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
12
15
|
local Set = ____lualib.Set
|
|
@@ -48,12 +51,19 @@ 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
|
|
51
63
|
local match = string.match
|
|
52
64
|
local ____tostring = _G.tostring
|
|
53
65
|
local setUnitAnimation = SetUnitAnimation
|
|
54
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
55
66
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
56
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
57
67
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
58
68
|
local getUnitRealField = BlzGetUnitRealField
|
|
59
69
|
local getHeroStr = GetHeroStr
|
|
@@ -72,9 +82,9 @@ local setUnitScale = SetUnitScale
|
|
|
72
82
|
local setUnitPosition = SetUnitPosition
|
|
73
83
|
local setUnitTimeScale = SetUnitTimeScale
|
|
74
84
|
local getHandleId = GetHandleId
|
|
85
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
75
86
|
local createUnit = CreateUnit
|
|
76
87
|
local killUnit = KillUnit
|
|
77
|
-
local setUnitExploded = SetUnitExploded
|
|
78
88
|
local removeUnit = RemoveUnit
|
|
79
89
|
local getUnitTypeId = GetUnitTypeId
|
|
80
90
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -90,8 +100,6 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
90
100
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
91
101
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
92
102
|
local isUnitInRange = IsUnitInRange
|
|
93
|
-
local setResourceAmount = SetResourceAmount
|
|
94
|
-
local getResourceAmount = GetResourceAmount
|
|
95
103
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
96
104
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
97
105
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
@@ -122,8 +130,6 @@ local isUnitType = IsUnitType
|
|
|
122
130
|
local isUnitAlly = IsUnitAlly
|
|
123
131
|
local isUnitEnemy = IsUnitEnemy
|
|
124
132
|
local getOwningPlayer = GetOwningPlayer
|
|
125
|
-
local setUnitColor = SetUnitColor
|
|
126
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
127
133
|
____exports.UnitClassification = {}
|
|
128
134
|
local UnitClassification = ____exports.UnitClassification
|
|
129
135
|
do
|
|
@@ -133,6 +139,7 @@ do
|
|
|
133
139
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
134
140
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
135
141
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
142
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
136
143
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
137
144
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
138
145
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -279,16 +286,14 @@ function UnitTriggerEvent.prototype.____constructor(self, eventType, c)
|
|
|
279
286
|
end
|
|
280
287
|
local function dispatch(event, idGetter, argsGetter)
|
|
281
288
|
local initialized = false
|
|
282
|
-
local x = {}
|
|
283
289
|
return setmetatable(
|
|
284
|
-
|
|
290
|
+
{},
|
|
285
291
|
{
|
|
286
292
|
__index = function(self, id)
|
|
287
293
|
if type(id) ~= "number" then
|
|
288
294
|
return event[id]
|
|
289
295
|
end
|
|
290
296
|
if not initialized then
|
|
291
|
-
local invoke = Event.invoke
|
|
292
297
|
event:addListener(function(...)
|
|
293
298
|
local id = idGetter(...)
|
|
294
299
|
local dispatched = rawget(self, id)
|
|
@@ -326,7 +331,6 @@ local function dispatchAbility(event)
|
|
|
326
331
|
return event[id]
|
|
327
332
|
end
|
|
328
333
|
if not initialized then
|
|
329
|
-
local invoke = Event.invoke
|
|
330
334
|
event:addListener(function(unit, ability, ...)
|
|
331
335
|
local dispatched = rawget(self, ability.typeId)
|
|
332
336
|
if dispatched ~= nil then
|
|
@@ -343,6 +347,9 @@ local function dispatchAbility(event)
|
|
|
343
347
|
}
|
|
344
348
|
)
|
|
345
349
|
end
|
|
350
|
+
local function damagingEventPreventRetaliation(self)
|
|
351
|
+
self[0] = true
|
|
352
|
+
end
|
|
346
353
|
local function damageEventPreventDeath(self, callback, ...)
|
|
347
354
|
if self[0] ~= nil then
|
|
348
355
|
return
|
|
@@ -354,7 +361,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
354
361
|
rawset(self, 1 + i, (select(i, ...)))
|
|
355
362
|
end
|
|
356
363
|
end
|
|
357
|
-
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
|
+
}
|
|
358
372
|
local jlimitopByOperator = {
|
|
359
373
|
[0] = LESS_THAN_OR_EQUAL,
|
|
360
374
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -432,6 +446,19 @@ __TS__SetDescriptor(
|
|
|
432
446
|
},
|
|
433
447
|
true
|
|
434
448
|
)
|
|
449
|
+
__TS__SetDescriptor(
|
|
450
|
+
UnitWeapon.prototype,
|
|
451
|
+
"allowedTargetCombatClassifications",
|
|
452
|
+
{
|
|
453
|
+
get = function(self)
|
|
454
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
455
|
+
end,
|
|
456
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
457
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
458
|
+
end
|
|
459
|
+
},
|
|
460
|
+
true
|
|
461
|
+
)
|
|
435
462
|
__TS__SetDescriptor(
|
|
436
463
|
UnitWeapon.prototype,
|
|
437
464
|
"damageBase",
|
|
@@ -562,17 +589,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
562
589
|
____exports.Unit:of(unit)
|
|
563
590
|
)
|
|
564
591
|
end
|
|
565
|
-
if not unitAddAbility(unit, abilityId) then
|
|
566
|
-
if getUnitAbility(unit, abilityId) == ability then
|
|
567
|
-
return UnitAbility:of(
|
|
568
|
-
ability,
|
|
569
|
-
abilityId,
|
|
570
|
-
____exports.Unit:of(unit)
|
|
571
|
-
)
|
|
572
|
-
end
|
|
573
|
-
else
|
|
574
|
-
unitRemoveAbility(unit, abilityId)
|
|
575
|
-
end
|
|
576
592
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
577
593
|
local item = unitItemInSlot(unit, i)
|
|
578
594
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -630,15 +646,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
630
646
|
dummies[player] = dummy
|
|
631
647
|
end
|
|
632
648
|
local function delayHealthChecksCallback(unit)
|
|
633
|
-
local counter = (unit[
|
|
649
|
+
local counter = (unit[103] or 0) - 1
|
|
634
650
|
if counter ~= 0 then
|
|
635
|
-
unit[
|
|
651
|
+
unit[103] = counter
|
|
636
652
|
return
|
|
637
653
|
end
|
|
638
|
-
unit[
|
|
639
|
-
local healthBonus = unit[
|
|
654
|
+
unit[103] = nil
|
|
655
|
+
local healthBonus = unit[104]
|
|
640
656
|
if healthBonus ~= nil then
|
|
641
|
-
unit[
|
|
657
|
+
unit[104] = nil
|
|
642
658
|
local handle = unit.handle
|
|
643
659
|
BlzSetUnitMaxHP(
|
|
644
660
|
handle,
|
|
@@ -646,12 +662,18 @@ local function delayHealthChecksCallback(unit)
|
|
|
646
662
|
)
|
|
647
663
|
end
|
|
648
664
|
end
|
|
665
|
+
local nextSyncId = 1
|
|
666
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
667
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
649
668
|
____exports.Unit = __TS__Class()
|
|
650
669
|
local Unit = ____exports.Unit
|
|
651
670
|
Unit.name = "Unit"
|
|
652
671
|
__TS__ClassExtends(Unit, Handle)
|
|
653
672
|
function Unit.prototype.____constructor(self, handle)
|
|
654
673
|
Handle.prototype.____constructor(self, handle)
|
|
674
|
+
local ____nextSyncId_0 = nextSyncId
|
|
675
|
+
nextSyncId = ____nextSyncId_0 + 1
|
|
676
|
+
self.syncId = ____nextSyncId_0
|
|
655
677
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
656
678
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
657
679
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -664,6 +686,7 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
664
686
|
fourCC("Amrf")
|
|
665
687
|
))
|
|
666
688
|
end
|
|
689
|
+
unitBySyncId[self.syncId] = self
|
|
667
690
|
local ____ = self.abilities
|
|
668
691
|
end
|
|
669
692
|
function Unit.prototype.getEvent(self, event, collector)
|
|
@@ -682,6 +705,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
682
705
|
end
|
|
683
706
|
function Unit.prototype.onDestroy(self)
|
|
684
707
|
local handle = self.handle
|
|
708
|
+
self[107] = getUnitX(handle)
|
|
709
|
+
self[108] = getUnitY(handle)
|
|
685
710
|
if not self._owner then
|
|
686
711
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
687
712
|
end
|
|
@@ -749,8 +774,8 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
749
774
|
end}
|
|
750
775
|
end
|
|
751
776
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
752
|
-
local
|
|
753
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
777
|
+
local ____combatClassification_1 = combatClassification
|
|
778
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
|
|
754
779
|
end
|
|
755
780
|
function Unit.prototype.addClassification(self, classification)
|
|
756
781
|
return unitAddType(self.handle, classification)
|
|
@@ -768,13 +793,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
768
793
|
return isUnitInvisible(self.handle, player.handle)
|
|
769
794
|
end
|
|
770
795
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
771
|
-
local
|
|
796
|
+
local ____temp_2
|
|
772
797
|
if type(x) == "number" then
|
|
773
|
-
|
|
798
|
+
____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
|
|
774
799
|
else
|
|
775
|
-
|
|
800
|
+
____temp_2 = isUnitInRange(self.handle, x.handle, y)
|
|
776
801
|
end
|
|
777
|
-
return
|
|
802
|
+
return ____temp_2
|
|
778
803
|
end
|
|
779
804
|
function Unit.prototype.isAllyOf(self, unit)
|
|
780
805
|
return isUnitAlly(
|
|
@@ -792,16 +817,28 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
792
817
|
if type(animation) == "number" then
|
|
793
818
|
setUnitAnimationByIndex(self.handle, animation)
|
|
794
819
|
elseif rarity then
|
|
795
|
-
|
|
820
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
796
821
|
else
|
|
797
822
|
setUnitAnimation(self.handle, animation)
|
|
798
823
|
end
|
|
799
824
|
end
|
|
825
|
+
function Unit.prototype.resetAnimation(self)
|
|
826
|
+
ResetUnitAnimation(self.handle)
|
|
827
|
+
end
|
|
800
828
|
function Unit.prototype.queueAnimation(self, animation)
|
|
801
|
-
|
|
829
|
+
QueueUnitAnimation(self.handle, animation)
|
|
830
|
+
end
|
|
831
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
832
|
+
if target:isAllowedTarget(self, self.firstWeapon.allowedTargetCombatClassifications) then
|
|
833
|
+
return self.firstWeapon
|
|
834
|
+
end
|
|
835
|
+
if target:isAllowedTarget(target, self.secondWeapon.allowedTargetCombatClassifications) then
|
|
836
|
+
return self.secondWeapon
|
|
837
|
+
end
|
|
838
|
+
return nil
|
|
802
839
|
end
|
|
803
840
|
function Unit.prototype.delayHealthChecks(self)
|
|
804
|
-
self[
|
|
841
|
+
self[103] = (self[103] or 0) + 1
|
|
805
842
|
Timer:run(delayHealthChecksCallback, self)
|
|
806
843
|
end
|
|
807
844
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -811,14 +848,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
811
848
|
return IsUnitSelected(self.handle, player.handle)
|
|
812
849
|
end
|
|
813
850
|
function Unit.prototype.explode(self)
|
|
814
|
-
|
|
851
|
+
SetUnitExploded(self.handle, true)
|
|
815
852
|
killUnit(self.handle)
|
|
816
853
|
end
|
|
817
854
|
function Unit.prototype.kill(self)
|
|
818
855
|
killUnit(self.handle)
|
|
819
856
|
end
|
|
820
|
-
function Unit.prototype.revive(self,
|
|
821
|
-
|
|
857
|
+
function Unit.prototype.revive(self, x, y, doEffect)
|
|
858
|
+
local ____ReviveHero_5 = ReviveHero
|
|
859
|
+
local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
|
|
860
|
+
local ____doEffect_3 = doEffect
|
|
861
|
+
if ____doEffect_3 == nil then
|
|
862
|
+
____doEffect_3 = false
|
|
863
|
+
end
|
|
864
|
+
__TS__SparseArrayPush(____array_4, ____doEffect_3)
|
|
865
|
+
____ReviveHero_5(__TS__SparseArraySpread(____array_4))
|
|
822
866
|
end
|
|
823
867
|
function Unit.prototype.healTarget(self, target, amount)
|
|
824
868
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -858,7 +902,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
858
902
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
859
903
|
end
|
|
860
904
|
function Unit.prototype.itemInSlot(self, slot)
|
|
861
|
-
return Item:of(
|
|
905
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
862
906
|
end
|
|
863
907
|
function Unit.prototype.addAbility(self, abilityId)
|
|
864
908
|
if unitAddAbility(self.handle, abilityId) then
|
|
@@ -914,6 +958,9 @@ end
|
|
|
914
958
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
915
959
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
916
960
|
end
|
|
961
|
+
function Unit.prototype.getAbilityRemainingCooldown(self, abilityId)
|
|
962
|
+
return BlzGetUnitAbilityCooldownRemaining(self.handle, abilityId)
|
|
963
|
+
end
|
|
917
964
|
function Unit.prototype.startAbilityCooldown(self, abilityId, cooldown)
|
|
918
965
|
BlzStartUnitAbilityCooldown(self.handle, abilityId, cooldown)
|
|
919
966
|
end
|
|
@@ -924,8 +971,15 @@ function Unit.prototype.interruptAttack(self)
|
|
|
924
971
|
unitInterruptAttack(self.handle)
|
|
925
972
|
end
|
|
926
973
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
927
|
-
|
|
928
|
-
unitDisableAbility(
|
|
974
|
+
local handle = self.handle
|
|
975
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
976
|
+
Timer:run(
|
|
977
|
+
unitDisableAbility,
|
|
978
|
+
handle,
|
|
979
|
+
abilityId,
|
|
980
|
+
false,
|
|
981
|
+
false
|
|
982
|
+
)
|
|
929
983
|
end
|
|
930
984
|
function Unit.prototype.getDistanceTo(self, target)
|
|
931
985
|
local handle = self.handle
|
|
@@ -985,18 +1039,18 @@ function Unit.prototype.unpauseEx(self)
|
|
|
985
1039
|
self:decrementStunCounter()
|
|
986
1040
|
end
|
|
987
1041
|
function Unit.prototype.incrementStunCounter(self)
|
|
988
|
-
local stunCounter = self[
|
|
989
|
-
if not self[
|
|
1042
|
+
local stunCounter = self[102] or 0
|
|
1043
|
+
if not self[101] or stunCounter >= 0 then
|
|
990
1044
|
BlzPauseUnitEx(self.handle, true)
|
|
991
1045
|
end
|
|
992
|
-
self[
|
|
1046
|
+
self[102] = stunCounter + 1
|
|
993
1047
|
end
|
|
994
1048
|
function Unit.prototype.decrementStunCounter(self)
|
|
995
|
-
local stunCounter = self[
|
|
996
|
-
if not self[
|
|
1049
|
+
local stunCounter = self[102] or 0
|
|
1050
|
+
if not self[101] or stunCounter >= 1 then
|
|
997
1051
|
BlzPauseUnitEx(self.handle, false)
|
|
998
1052
|
end
|
|
999
|
-
self[
|
|
1053
|
+
self[102] = stunCounter - 1
|
|
1000
1054
|
end
|
|
1001
1055
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1002
1056
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -1098,8 +1152,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
1098
1152
|
)
|
|
1099
1153
|
return targetCollection
|
|
1100
1154
|
end
|
|
1101
|
-
function Unit.getSelectionOf(self, player)
|
|
1102
|
-
|
|
1155
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1156
|
+
if target == nil then
|
|
1157
|
+
target = {}
|
|
1158
|
+
end
|
|
1159
|
+
targetCollection = target
|
|
1103
1160
|
targetCollectionNextIndex = 1
|
|
1104
1161
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
1105
1162
|
return targetCollection
|
|
@@ -1121,6 +1178,9 @@ end
|
|
|
1121
1178
|
function Unit.prototype.__tostring(self)
|
|
1122
1179
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
1123
1180
|
end
|
|
1181
|
+
function Unit.getBySyncId(self, syncId)
|
|
1182
|
+
return unitBySyncId[syncId]
|
|
1183
|
+
end
|
|
1124
1184
|
__TS__SetDescriptor(
|
|
1125
1185
|
Unit.prototype,
|
|
1126
1186
|
"_deltas",
|
|
@@ -1184,6 +1244,14 @@ __TS__SetDescriptor(
|
|
|
1184
1244
|
end},
|
|
1185
1245
|
true
|
|
1186
1246
|
)
|
|
1247
|
+
__TS__SetDescriptor(
|
|
1248
|
+
Unit.prototype,
|
|
1249
|
+
"isStunned",
|
|
1250
|
+
{get = function(self)
|
|
1251
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1252
|
+
end},
|
|
1253
|
+
true
|
|
1254
|
+
)
|
|
1187
1255
|
__TS__SetDescriptor(
|
|
1188
1256
|
Unit.prototype,
|
|
1189
1257
|
"combatClassifications",
|
|
@@ -1257,6 +1325,19 @@ __TS__SetDescriptor(
|
|
|
1257
1325
|
},
|
|
1258
1326
|
true
|
|
1259
1327
|
)
|
|
1328
|
+
__TS__SetDescriptor(
|
|
1329
|
+
Unit.prototype,
|
|
1330
|
+
"primaryAttribute",
|
|
1331
|
+
{
|
|
1332
|
+
get = function(self)
|
|
1333
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1334
|
+
end,
|
|
1335
|
+
set = function(self, primaryAttribute)
|
|
1336
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1337
|
+
end
|
|
1338
|
+
},
|
|
1339
|
+
true
|
|
1340
|
+
)
|
|
1260
1341
|
__TS__SetDescriptor(
|
|
1261
1342
|
Unit.prototype,
|
|
1262
1343
|
"strengthBase",
|
|
@@ -1378,17 +1459,17 @@ __TS__SetDescriptor(
|
|
|
1378
1459
|
"isTeamGlowVisible",
|
|
1379
1460
|
{
|
|
1380
1461
|
get = function(self)
|
|
1381
|
-
return not self[
|
|
1462
|
+
return not self[106]
|
|
1382
1463
|
end,
|
|
1383
1464
|
set = function(self, isTeamGlowVisible)
|
|
1384
|
-
|
|
1385
|
-
local
|
|
1465
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1466
|
+
local ____temp_6
|
|
1386
1467
|
if not isTeamGlowVisible then
|
|
1387
|
-
|
|
1468
|
+
____temp_6 = true
|
|
1388
1469
|
else
|
|
1389
|
-
|
|
1470
|
+
____temp_6 = nil
|
|
1390
1471
|
end
|
|
1391
|
-
self[
|
|
1472
|
+
self[106] = ____temp_6
|
|
1392
1473
|
end
|
|
1393
1474
|
},
|
|
1394
1475
|
true
|
|
@@ -1397,9 +1478,9 @@ __TS__SetDescriptor(
|
|
|
1397
1478
|
Unit.prototype,
|
|
1398
1479
|
"color",
|
|
1399
1480
|
{set = function(self, color)
|
|
1400
|
-
|
|
1401
|
-
if self[
|
|
1402
|
-
|
|
1481
|
+
SetUnitColor(self.handle, color.handle)
|
|
1482
|
+
if self[106] then
|
|
1483
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1403
1484
|
end
|
|
1404
1485
|
end},
|
|
1405
1486
|
true
|
|
@@ -1422,14 +1503,14 @@ __TS__SetDescriptor(
|
|
|
1422
1503
|
"maxHealth",
|
|
1423
1504
|
{
|
|
1424
1505
|
get = function(self)
|
|
1425
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1506
|
+
return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
|
|
1426
1507
|
end,
|
|
1427
1508
|
set = function(self, maxHealth)
|
|
1428
|
-
if maxHealth < 1 and self[
|
|
1429
|
-
self[
|
|
1509
|
+
if maxHealth < 1 and self[103] ~= nil then
|
|
1510
|
+
self[104] = (self[104] or 0) + (1 - maxHealth)
|
|
1430
1511
|
maxHealth = 1
|
|
1431
1512
|
end
|
|
1432
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1513
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
|
|
1433
1514
|
end
|
|
1434
1515
|
},
|
|
1435
1516
|
true
|
|
@@ -1471,10 +1552,10 @@ __TS__SetDescriptor(
|
|
|
1471
1552
|
"health",
|
|
1472
1553
|
{
|
|
1473
1554
|
get = function(self)
|
|
1474
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1555
|
+
return GetWidgetLife(self.handle) - (self[105] or 0)
|
|
1475
1556
|
end,
|
|
1476
1557
|
set = function(self, health)
|
|
1477
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1558
|
+
SetWidgetLife(self.handle, health + (self[105] or 0))
|
|
1478
1559
|
end
|
|
1479
1560
|
},
|
|
1480
1561
|
true
|
|
@@ -1568,7 +1649,7 @@ __TS__SetDescriptor(
|
|
|
1568
1649
|
"x",
|
|
1569
1650
|
{
|
|
1570
1651
|
get = function(self)
|
|
1571
|
-
return getUnitX(self.handle)
|
|
1652
|
+
return self[107] or getUnitX(self.handle)
|
|
1572
1653
|
end,
|
|
1573
1654
|
set = function(self, v)
|
|
1574
1655
|
SetUnitX(self.handle, v)
|
|
@@ -1581,7 +1662,7 @@ __TS__SetDescriptor(
|
|
|
1581
1662
|
"y",
|
|
1582
1663
|
{
|
|
1583
1664
|
get = function(self)
|
|
1584
|
-
return getUnitY(self.handle)
|
|
1665
|
+
return self[108] or getUnitY(self.handle)
|
|
1585
1666
|
end,
|
|
1586
1667
|
set = function(self, v)
|
|
1587
1668
|
SetUnitY(self.handle, v)
|
|
@@ -1667,10 +1748,10 @@ __TS__SetDescriptor(
|
|
|
1667
1748
|
"gold",
|
|
1668
1749
|
{
|
|
1669
1750
|
get = function(self)
|
|
1670
|
-
return
|
|
1751
|
+
return GetResourceAmount(self.handle)
|
|
1671
1752
|
end,
|
|
1672
1753
|
set = function(self, gold)
|
|
1673
|
-
|
|
1754
|
+
SetResourceAmount(self.handle, gold)
|
|
1674
1755
|
end
|
|
1675
1756
|
},
|
|
1676
1757
|
true
|
|
@@ -1685,17 +1766,17 @@ __TS__SetDescriptor(
|
|
|
1685
1766
|
set = function(self, isPaused)
|
|
1686
1767
|
local handle = self.handle
|
|
1687
1768
|
if isPaused and not IsUnitPaused(handle) then
|
|
1688
|
-
self[
|
|
1689
|
-
for _ = self[
|
|
1769
|
+
self[101] = true
|
|
1770
|
+
for _ = self[102] or 0, -1 do
|
|
1690
1771
|
BlzPauseUnitEx(handle, true)
|
|
1691
1772
|
end
|
|
1692
1773
|
PauseUnit(handle, true)
|
|
1693
1774
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1694
1775
|
PauseUnit(handle, false)
|
|
1695
|
-
for _ = self[
|
|
1776
|
+
for _ = self[102] or 0, -1 do
|
|
1696
1777
|
BlzPauseUnitEx(handle, false)
|
|
1697
1778
|
end
|
|
1698
|
-
self[
|
|
1779
|
+
self[101] = nil
|
|
1699
1780
|
end
|
|
1700
1781
|
end
|
|
1701
1782
|
},
|
|
@@ -1798,6 +1879,19 @@ __TS__SetDescriptor(
|
|
|
1798
1879
|
end},
|
|
1799
1880
|
true
|
|
1800
1881
|
)
|
|
1882
|
+
__TS__SetDescriptor(
|
|
1883
|
+
Unit.prototype,
|
|
1884
|
+
"movementType",
|
|
1885
|
+
{
|
|
1886
|
+
get = function(self)
|
|
1887
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1888
|
+
end,
|
|
1889
|
+
set = function(self, movementType)
|
|
1890
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1891
|
+
end
|
|
1892
|
+
},
|
|
1893
|
+
true
|
|
1894
|
+
)
|
|
1801
1895
|
__TS__SetDescriptor(
|
|
1802
1896
|
Unit.prototype,
|
|
1803
1897
|
"pathing",
|
|
@@ -1979,6 +2073,14 @@ __TS__SetDescriptor(
|
|
|
1979
2073
|
end},
|
|
1980
2074
|
true
|
|
1981
2075
|
)
|
|
2076
|
+
__TS__SetDescriptor(
|
|
2077
|
+
Unit.prototype,
|
|
2078
|
+
"targetAcquiredEvent",
|
|
2079
|
+
{get = function(self)
|
|
2080
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2081
|
+
end},
|
|
2082
|
+
true
|
|
2083
|
+
)
|
|
1982
2084
|
__TS__SetDescriptor(
|
|
1983
2085
|
Unit.prototype,
|
|
1984
2086
|
"onSelect",
|
|
@@ -2052,7 +2154,6 @@ Unit.onDecay = __TS__New(
|
|
|
2052
2154
|
Unit.onResurrect = __TS__New(
|
|
2053
2155
|
InitializingEvent,
|
|
2054
2156
|
function(event)
|
|
2055
|
-
local invoke = Event.invoke
|
|
2056
2157
|
local dead = setmetatable({}, {__mode = "k"})
|
|
2057
2158
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
2058
2159
|
dead[unit] = true
|
|
@@ -2068,10 +2169,15 @@ Unit.onResurrect = __TS__New(
|
|
|
2068
2169
|
Unit.morphEvent = __TS__New(
|
|
2069
2170
|
InitializingEvent,
|
|
2070
2171
|
function(event)
|
|
2172
|
+
local function ifNotLeft(unit)
|
|
2173
|
+
local handle = unit.handle
|
|
2174
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2175
|
+
invoke(event, unit)
|
|
2176
|
+
end
|
|
2177
|
+
end
|
|
2071
2178
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
2072
2179
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
2073
|
-
|
|
2074
|
-
Timer:run(Event.invoke, event, unit)
|
|
2180
|
+
Timer:run(ifNotLeft, unit)
|
|
2075
2181
|
end
|
|
2076
2182
|
end)
|
|
2077
2183
|
end
|
|
@@ -2109,27 +2215,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
2109
2215
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
2110
2216
|
InitializingEvent,
|
|
2111
2217
|
function(event)
|
|
2112
|
-
local invoke = Event.invoke
|
|
2113
2218
|
local function listener(unit, id)
|
|
2114
|
-
local
|
|
2219
|
+
local ____GetSpellTargetUnit_result_9
|
|
2115
2220
|
if GetSpellTargetUnit() then
|
|
2116
|
-
|
|
2221
|
+
____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2117
2222
|
else
|
|
2118
|
-
local
|
|
2223
|
+
local ____GetSpellTargetItem_result_8
|
|
2119
2224
|
if GetSpellTargetItem() then
|
|
2120
|
-
|
|
2225
|
+
____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
|
|
2121
2226
|
else
|
|
2122
|
-
local
|
|
2227
|
+
local ____GetSpellTargetDestructable_result_7
|
|
2123
2228
|
if GetSpellTargetDestructable() then
|
|
2124
|
-
|
|
2229
|
+
____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
|
|
2125
2230
|
else
|
|
2126
|
-
|
|
2231
|
+
____GetSpellTargetDestructable_result_7 = nil
|
|
2127
2232
|
end
|
|
2128
|
-
|
|
2233
|
+
____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
|
|
2129
2234
|
end
|
|
2130
|
-
|
|
2235
|
+
____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
|
|
2131
2236
|
end
|
|
2132
|
-
local target =
|
|
2237
|
+
local target = ____GetSpellTargetUnit_result_9
|
|
2133
2238
|
if target then
|
|
2134
2239
|
invoke(event, unit, id, target)
|
|
2135
2240
|
end
|
|
@@ -2301,10 +2406,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2301
2406
|
____exports.UnitTriggerEvent,
|
|
2302
2407
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2303
2408
|
function()
|
|
2304
|
-
local
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2409
|
+
local handle = getOrderedUnit()
|
|
2410
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2411
|
+
local unit = ____exports.Unit:of(handle)
|
|
2412
|
+
if unit.state == 1 then
|
|
2413
|
+
return unit, getIssuedOrderId()
|
|
2414
|
+
end
|
|
2308
2415
|
end
|
|
2309
2416
|
return IgnoreEvent
|
|
2310
2417
|
end
|
|
@@ -2326,7 +2433,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2326
2433
|
)
|
|
2327
2434
|
Unit.onDamaging = (function()
|
|
2328
2435
|
local event = __TS__New(Event)
|
|
2329
|
-
local invoke = Event.invoke
|
|
2330
2436
|
local trigger = CreateTrigger()
|
|
2331
2437
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2332
2438
|
TriggerAddCondition(
|
|
@@ -2336,13 +2442,19 @@ Unit.onDamaging = (function()
|
|
|
2336
2442
|
if source and source.typeId == dummyUnitId then
|
|
2337
2443
|
source = nil
|
|
2338
2444
|
end
|
|
2339
|
-
local target = BlzGetEventDamageTarget()
|
|
2445
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2446
|
+
local metadata = damageMetadataByTarget[target]
|
|
2447
|
+
damageMetadataByTarget[target] = nil
|
|
2340
2448
|
local data = {
|
|
2341
2449
|
amount = GetEventDamage(),
|
|
2342
|
-
attackType = BlzGetEventAttackType(),
|
|
2450
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2343
2451
|
damageType = BlzGetEventDamageType(),
|
|
2344
2452
|
weaponType = BlzGetEventWeaponType(),
|
|
2345
|
-
|
|
2453
|
+
metadata = metadata,
|
|
2454
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2455
|
+
originalAmount = GetEventDamage(),
|
|
2456
|
+
originalMetadata = metadata,
|
|
2457
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2346
2458
|
}
|
|
2347
2459
|
if data.isAttack and source then
|
|
2348
2460
|
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
|
|
@@ -2356,18 +2468,36 @@ Unit.onDamaging = (function()
|
|
|
2356
2468
|
invoke(
|
|
2357
2469
|
event,
|
|
2358
2470
|
source,
|
|
2359
|
-
|
|
2471
|
+
target,
|
|
2360
2472
|
setmetatable(
|
|
2361
2473
|
{},
|
|
2362
2474
|
{
|
|
2363
2475
|
__index = data,
|
|
2364
2476
|
__newindex = function(self, key, value)
|
|
2365
|
-
damageSetters[key]
|
|
2477
|
+
local damageSetter = damageSetters[key]
|
|
2478
|
+
if damageSetter ~= nil then
|
|
2479
|
+
damageSetter(value)
|
|
2480
|
+
end
|
|
2366
2481
|
data[key] = value
|
|
2367
2482
|
end
|
|
2368
2483
|
}
|
|
2369
2484
|
)
|
|
2370
2485
|
)
|
|
2486
|
+
if data[0] and source then
|
|
2487
|
+
local sourceOwner = source.owner.handle
|
|
2488
|
+
data[1] = sourceOwner
|
|
2489
|
+
local targetOwner = target.owner.handle
|
|
2490
|
+
data[2] = targetOwner
|
|
2491
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2492
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2493
|
+
data[3] = true
|
|
2494
|
+
end
|
|
2495
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2496
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2497
|
+
data[4] = true
|
|
2498
|
+
end
|
|
2499
|
+
end
|
|
2500
|
+
damagingEventByTarget[target] = data
|
|
2371
2501
|
return
|
|
2372
2502
|
end
|
|
2373
2503
|
BlzSetEventDamage(0)
|
|
@@ -2375,7 +2505,7 @@ Unit.onDamaging = (function()
|
|
|
2375
2505
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2376
2506
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2377
2507
|
local sourceOwner = source.owner.handle
|
|
2378
|
-
local targetOwner =
|
|
2508
|
+
local targetOwner = target.owner.handle
|
|
2379
2509
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2380
2510
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2381
2511
|
Timer:run(function()
|
|
@@ -2391,23 +2521,19 @@ Unit.onDamaging = (function()
|
|
|
2391
2521
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2392
2522
|
local condition = ____value[1]
|
|
2393
2523
|
local action = ____value[2]
|
|
2394
|
-
if condition(
|
|
2395
|
-
source,
|
|
2396
|
-
____exports.Unit:of(target),
|
|
2397
|
-
data
|
|
2398
|
-
) then
|
|
2524
|
+
if condition(source, target, data) then
|
|
2399
2525
|
action(
|
|
2400
2526
|
source,
|
|
2401
|
-
|
|
2527
|
+
target,
|
|
2402
2528
|
setmetatable(
|
|
2403
2529
|
{fire = function()
|
|
2404
2530
|
UnitDamageTarget(
|
|
2405
2531
|
source.handle,
|
|
2406
|
-
target,
|
|
2532
|
+
target.handle,
|
|
2407
2533
|
data.amount,
|
|
2408
2534
|
true,
|
|
2409
2535
|
true,
|
|
2410
|
-
data.attackType,
|
|
2536
|
+
attackTypeToNative(data.attackType),
|
|
2411
2537
|
data.damageType,
|
|
2412
2538
|
data.weaponType
|
|
2413
2539
|
)
|
|
@@ -2425,7 +2551,6 @@ end)()
|
|
|
2425
2551
|
Unit.onDamage = __TS__New(
|
|
2426
2552
|
InitializingEvent,
|
|
2427
2553
|
function(event)
|
|
2428
|
-
local invoke = Event.invoke
|
|
2429
2554
|
local trigger = CreateTrigger()
|
|
2430
2555
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2431
2556
|
TriggerAddCondition(
|
|
@@ -2435,29 +2560,54 @@ Unit.onDamage = __TS__New(
|
|
|
2435
2560
|
if source and source.typeId == dummyUnitId then
|
|
2436
2561
|
source = nil
|
|
2437
2562
|
end
|
|
2563
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2564
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2565
|
+
damagingEventByTarget[target] = nil
|
|
2438
2566
|
local data = {
|
|
2439
2567
|
amount = GetEventDamage(),
|
|
2440
|
-
attackType = BlzGetEventAttackType(),
|
|
2568
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2441
2569
|
damageType = BlzGetEventDamageType(),
|
|
2442
2570
|
weaponType = BlzGetEventWeaponType(),
|
|
2571
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2443
2572
|
isAttack = BlzGetEventIsAttack(),
|
|
2573
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2574
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2444
2575
|
preventDeath = damageEventPreventDeath
|
|
2445
2576
|
}
|
|
2577
|
+
if damagingEvent then
|
|
2578
|
+
for key, value in pairs(damagingEvent) do
|
|
2579
|
+
if isAttribute(key) then
|
|
2580
|
+
data[key] = value
|
|
2581
|
+
end
|
|
2582
|
+
end
|
|
2583
|
+
local sourceOwner = damagingEvent[1]
|
|
2584
|
+
if sourceOwner then
|
|
2585
|
+
local targetOwner = damagingEvent[2]
|
|
2586
|
+
if damagingEvent[3] then
|
|
2587
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2588
|
+
end
|
|
2589
|
+
if damagingEvent[4] then
|
|
2590
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2591
|
+
end
|
|
2592
|
+
end
|
|
2593
|
+
end
|
|
2446
2594
|
local evData = setmetatable(
|
|
2447
2595
|
{},
|
|
2448
2596
|
{
|
|
2449
2597
|
__index = data,
|
|
2450
2598
|
__newindex = function(self, key, value)
|
|
2451
|
-
damageSetters[key]
|
|
2599
|
+
local damageSetter = damageSetters[key]
|
|
2600
|
+
if damageSetter ~= nil then
|
|
2601
|
+
damageSetter(value)
|
|
2602
|
+
end
|
|
2452
2603
|
data[key] = value
|
|
2453
2604
|
end
|
|
2454
2605
|
}
|
|
2455
2606
|
)
|
|
2456
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2457
2607
|
invoke(event, source, target, evData)
|
|
2458
2608
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2459
2609
|
local bonusHealth = math.ceil(evData.amount)
|
|
2460
|
-
target[
|
|
2610
|
+
target[105] = (target[105] or 0) + bonusHealth
|
|
2461
2611
|
BlzSetUnitMaxHP(
|
|
2462
2612
|
target.handle,
|
|
2463
2613
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2471,7 +2621,7 @@ Unit.onDamage = __TS__New(
|
|
|
2471
2621
|
evData[0],
|
|
2472
2622
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2473
2623
|
)
|
|
2474
|
-
target[
|
|
2624
|
+
target[105] = (target[105] or 0) - bonusHealth
|
|
2475
2625
|
SetWidgetLife(
|
|
2476
2626
|
target.handle,
|
|
2477
2627
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2491,32 +2641,106 @@ Unit.onDamage = __TS__New(
|
|
|
2491
2641
|
DestroyTrigger(trigger)
|
|
2492
2642
|
end
|
|
2493
2643
|
)
|
|
2494
|
-
Unit.
|
|
2644
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2495
2645
|
____exports.UnitTriggerEvent,
|
|
2496
2646
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2497
2647
|
function()
|
|
2498
2648
|
local unit = getTriggerUnit()
|
|
2499
|
-
|
|
2500
|
-
|
|
2649
|
+
local item = getManipulatedItem()
|
|
2650
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2651
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2501
2652
|
end
|
|
2502
2653
|
return IgnoreEvent
|
|
2503
2654
|
end
|
|
2504
2655
|
)
|
|
2505
|
-
Unit.
|
|
2656
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2506
2657
|
____exports.UnitTriggerEvent,
|
|
2507
2658
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2508
2659
|
function()
|
|
2509
2660
|
local unit = getTriggerUnit()
|
|
2510
|
-
|
|
2511
|
-
|
|
2661
|
+
local item = getManipulatedItem()
|
|
2662
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2663
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2512
2664
|
end
|
|
2513
2665
|
return IgnoreEvent
|
|
2514
2666
|
end
|
|
2515
2667
|
)
|
|
2516
|
-
Unit.
|
|
2668
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2517
2669
|
____exports.UnitTriggerEvent,
|
|
2518
2670
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2519
|
-
function()
|
|
2671
|
+
function()
|
|
2672
|
+
local unit = getTriggerUnit()
|
|
2673
|
+
local item = getManipulatedItem()
|
|
2674
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2675
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2676
|
+
end
|
|
2677
|
+
return IgnoreEvent
|
|
2678
|
+
end
|
|
2679
|
+
)
|
|
2680
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2681
|
+
____exports.UnitTriggerEvent,
|
|
2682
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2683
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2684
|
+
)
|
|
2685
|
+
__TS__ObjectDefineProperty(
|
|
2686
|
+
Unit,
|
|
2687
|
+
"itemChargesChangedEvent",
|
|
2688
|
+
{get = function(self)
|
|
2689
|
+
local event = __TS__New(Event)
|
|
2690
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2691
|
+
local unit = item.owner
|
|
2692
|
+
if unit ~= nil then
|
|
2693
|
+
invoke(event, unit, item)
|
|
2694
|
+
end
|
|
2695
|
+
end)
|
|
2696
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2697
|
+
return event
|
|
2698
|
+
end}
|
|
2699
|
+
)
|
|
2700
|
+
__TS__ObjectDefineProperty(
|
|
2701
|
+
Unit,
|
|
2702
|
+
"itemUseOrderEvent",
|
|
2703
|
+
{get = function(self)
|
|
2704
|
+
local event = __TS__New(Event)
|
|
2705
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2706
|
+
local slot = order - orderId("useslot0")
|
|
2707
|
+
local function listener(unit)
|
|
2708
|
+
local item = unit.items[slot + 1]
|
|
2709
|
+
if item ~= nil then
|
|
2710
|
+
invoke(event, unit, item)
|
|
2711
|
+
end
|
|
2712
|
+
end
|
|
2713
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2714
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2715
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2716
|
+
end
|
|
2717
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2718
|
+
return event
|
|
2719
|
+
end}
|
|
2720
|
+
)
|
|
2721
|
+
__TS__ObjectDefineProperty(
|
|
2722
|
+
Unit,
|
|
2723
|
+
"itemMoveOrderEvent",
|
|
2724
|
+
{get = function(self)
|
|
2725
|
+
local event = __TS__New(Event)
|
|
2726
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2727
|
+
local slotTo = order - orderId("moveslot0")
|
|
2728
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2729
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2730
|
+
if slotFrom ~= nil then
|
|
2731
|
+
invoke(
|
|
2732
|
+
event,
|
|
2733
|
+
unit,
|
|
2734
|
+
item,
|
|
2735
|
+
slotFrom,
|
|
2736
|
+
slotTo
|
|
2737
|
+
)
|
|
2738
|
+
end
|
|
2739
|
+
end)
|
|
2740
|
+
end
|
|
2741
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2742
|
+
return event
|
|
2743
|
+
end}
|
|
2520
2744
|
)
|
|
2521
2745
|
__TS__ObjectDefineProperty(
|
|
2522
2746
|
Unit,
|