warscript 0.0.1-dev.4363c65 → 0.0.1-dev.4414935
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/attributes.d.ts +6 -0
- package/attributes.lua +17 -1
- package/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 +4 -0
- package/core/types/frame.lua +95 -21
- package/core/types/player.d.ts +16 -0
- package/core/types/player.lua +60 -15
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +123 -5
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/tileCell.d.ts +11 -1
- package/core/types/tileCell.lua +97 -0
- package/core/types/timer.d.ts +9 -8
- package/core/types/timer.lua +45 -23
- package/core/util.d.ts +1 -1
- package/core/util.lua +18 -1
- package/decl/native.d.ts +846 -790
- package/destroyable.d.ts +1 -0
- package/destroyable.lua +9 -0
- package/engine/behavior.d.ts +16 -3
- package/engine/behavior.lua +233 -73
- package/engine/behaviour/ability/always-enabled.d.ts +7 -0
- package/engine/behaviour/ability/always-enabled.lua +31 -0
- package/engine/behaviour/ability/apply-buff.d.ts +8 -5
- package/engine/behaviour/ability/apply-buff.lua +36 -4
- package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
- package/engine/behaviour/ability/damage.d.ts +9 -3
- package/engine/behaviour/ability/damage.lua +26 -38
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +43 -0
- package/engine/behaviour/ability/instant-impact.d.ts +2 -2
- package/engine/behaviour/ability/instant-impact.lua +4 -19
- package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
- package/engine/behaviour/ability/on-command-impact.lua +25 -0
- package/engine/behaviour/ability/remove-buffs.d.ts +25 -0
- package/engine/behaviour/ability/remove-buffs.lua +49 -0
- package/engine/behaviour/ability/restore-mana.d.ts +1 -1
- package/engine/behaviour/ability/restore-mana.lua +6 -6
- package/engine/behaviour/ability.d.ts +22 -5
- package/engine/behaviour/ability.lua +113 -48
- package/engine/behaviour/unit/stun-immunity.d.ts +12 -6
- package/engine/behaviour/unit/stun-immunity.lua +57 -31
- package/engine/behaviour/unit.d.ts +45 -2
- package/engine/behaviour/unit.lua +289 -6
- package/engine/buff.d.ts +91 -52
- package/engine/buff.lua +433 -274
- package/engine/internal/ability.d.ts +23 -14
- package/engine/internal/ability.lua +129 -85
- package/engine/internal/item/ability.lua +162 -4
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +20 -19
- package/engine/internal/item.lua +191 -74
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- package/engine/internal/mechanics/cast-ability.lua +6 -3
- package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
- package/engine/internal/misc/ability-disable-counter.lua +13 -0
- package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
- package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
- package/engine/internal/misc/frame-coordinates.d.ts +2 -0
- package/engine/internal/misc/frame-coordinates.lua +21 -0
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/misc/player-local-handle.d.ts +2 -0
- package/engine/internal/misc/player-local-handle.lua +5 -0
- package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
- package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
- package/engine/internal/object-data/evasion-probability.d.ts +2 -0
- package/engine/internal/object-data/evasion-probability.lua +16 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
- package/engine/internal/unit/ability.d.ts +45 -1
- package/engine/internal/unit/ability.lua +128 -17
- package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
- package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot.lua +52 -0
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/attributes.d.ts +17 -0
- package/engine/internal/unit/attributes.lua +46 -0
- package/engine/internal/unit/bonus.d.ts +8 -2
- package/engine/internal/unit/bonus.lua +33 -1
- package/engine/internal/unit/fly-height.d.ts +7 -0
- package/engine/internal/unit/fly-height.lua +20 -0
- package/engine/internal/unit/ignore-events-items.d.ts +2 -0
- package/engine/internal/unit/ignore-events-items.lua +5 -0
- package/engine/internal/unit/interrupts.d.ts +12 -0
- package/engine/internal/unit/interrupts.lua +28 -0
- package/engine/internal/unit/item.d.ts +24 -0
- package/engine/internal/unit/item.lua +78 -0
- package/engine/internal/unit/main-selected.d.ts +13 -0
- package/engine/internal/unit/main-selected.lua +36 -0
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit/scale.d.ts +7 -0
- package/engine/internal/unit/scale.lua +20 -0
- package/engine/internal/unit+ability.lua +12 -3
- package/engine/internal/unit+damage.d.ts +2 -11
- package/engine/internal/unit+damage.lua +10 -14
- package/engine/internal/unit+spellSteal.lua +1 -2
- package/engine/internal/unit-missile-launch.lua +70 -13
- package/engine/internal/unit.d.ts +63 -29
- package/engine/internal/unit.lua +475 -257
- package/engine/internal/utility.lua +12 -0
- package/engine/lightning.d.ts +12 -5
- package/engine/lightning.lua +48 -14
- package/engine/local-client.d.ts +9 -2
- package/engine/local-client.lua +112 -0
- package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
- package/engine/object-data/auxiliary/animation-name.lua +16 -0
- package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
- package/engine/object-data/auxiliary/armor-type.lua +46 -0
- package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
- package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
- package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
- package/engine/object-data/auxiliary/attack-type.lua +42 -0
- package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
- package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
- package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
- package/engine/object-data/auxiliary/movement-type.lua +22 -0
- package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
- package/engine/object-data/auxiliary/sound-eax.lua +2 -0
- package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
- package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
- package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
- package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
- package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
- package/engine/object-data/entry/ability-type/berserk.lua +13 -0
- package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
- package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
- package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
- package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
- package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
- package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
- package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
- package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
- package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
- package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
- package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
- package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
- package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
- package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
- package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
- package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
- package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
- package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
- package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
- package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
- package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
- package/engine/object-data/entry/ability-type/web.d.ts +12 -0
- package/engine/object-data/entry/ability-type/web.lua +52 -0
- package/engine/object-data/entry/ability-type.d.ts +19 -17
- package/engine/object-data/entry/ability-type.lua +93 -36
- package/engine/object-data/entry/buff-type/applicable.lua +18 -37
- package/engine/object-data/entry/buff-type.d.ts +6 -12
- package/engine/object-data/entry/buff-type.lua +13 -29
- package/engine/object-data/entry/destructible-type.d.ts +28 -2
- package/engine/object-data/entry/destructible-type.lua +155 -0
- package/engine/object-data/entry/item-type.d.ts +15 -1
- package/engine/object-data/entry/item-type.lua +93 -2
- package/engine/object-data/entry/lightning-type.d.ts +1 -1
- package/engine/object-data/entry/sound-preset.d.ts +33 -0
- package/engine/object-data/entry/sound-preset.lua +140 -0
- package/engine/object-data/entry/unit-type.d.ts +25 -5
- package/engine/object-data/entry/unit-type.lua +258 -93
- package/engine/object-data/entry/upgrade.d.ts +1 -1
- package/engine/object-data/entry/upgrade.lua +4 -4
- package/engine/object-data/entry.d.ts +16 -14
- package/engine/object-data/entry.lua +60 -32
- package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
- package/engine/object-field/ability.d.ts +12 -6
- package/engine/object-field/ability.lua +9 -5
- package/engine/object-field/unit.d.ts +72 -3
- package/engine/object-field/unit.lua +268 -7
- package/engine/object-field.d.ts +25 -6
- package/engine/object-field.lua +359 -116
- package/engine/random.d.ts +9 -0
- package/engine/random.lua +13 -0
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- package/engine/standard/entries/sound-preset.d.ts +10 -0
- package/engine/standard/entries/sound-preset.lua +10 -0
- package/engine/standard/fields/ability.d.ts +4 -2
- package/engine/standard/fields/ability.lua +4 -2
- package/engine/standard/fields/unit.d.ts +12 -0
- package/engine/standard/fields/unit.lua +20 -0
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +250 -10
- package/engine/unit.d.ts +8 -0
- package/engine/unit.lua +8 -0
- package/index.d.ts +1 -0
- package/index.lua +1 -0
- package/net/socket.d.ts +7 -1
- package/net/socket.lua +45 -4
- package/network.d.ts +1 -0
- package/network.lua +3 -2
- package/objutil/buff.lua +12 -11
- package/objutil/unit.lua +8 -0
- package/package.json +2 -2
- package/patch-lua.d.ts +0 -0
- package/patch-lua.lua +10 -0
- package/patch-lualib.lua +1 -1
- package/utility/arrays.d.ts +10 -1
- package/utility/arrays.lua +45 -3
- package/utility/callback-array.d.ts +17 -0
- package/utility/callback-array.lua +61 -0
- package/utility/functions.d.ts +8 -0
- package/utility/functions.lua +13 -0
- package/utility/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
- package/utility/linked-map.d.ts +26 -0
- package/utility/linked-map.lua +66 -0
- package/utility/linked-set.d.ts +2 -0
- package/utility/linked-set.lua +26 -1
- package/utility/lua-maps.d.ts +15 -2
- package/utility/lua-maps.lua +53 -2
- package/utility/lua-sets.d.ts +2 -0
- package/utility/lua-sets.lua +7 -0
- package/utility/records.lua +20 -1
- package/utility/reflection.lua +11 -7
- package/utility/types.d.ts +3 -0
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
package/engine/internal/unit.lua
CHANGED
|
@@ -51,33 +51,42 @@ local ____arrays = require("utility.arrays")
|
|
|
51
51
|
local forEach = ____arrays.forEach
|
|
52
52
|
local ____math = require("math")
|
|
53
53
|
local min = ____math.min
|
|
54
|
+
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
55
|
+
local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
56
|
+
local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
|
|
57
|
+
local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
|
|
58
|
+
local nativeToAttackType = ____attack_2Dtype.nativeToAttackType
|
|
59
|
+
local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
|
|
60
|
+
local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
|
|
61
|
+
local ____attributes = require("attributes")
|
|
62
|
+
local isAttribute = ____attributes.isAttribute
|
|
63
|
+
local ____ability = require("engine.internal.item.ability")
|
|
64
|
+
local doUnitAbilityAction = ____ability.doUnitAbilityAction
|
|
65
|
+
local ____synchronization = require("engine.synchronization")
|
|
66
|
+
local synchronizer = ____synchronization.synchronizer
|
|
67
|
+
local ____linked_2Dmap = require("utility.linked-map")
|
|
68
|
+
local LinkedMap = ____linked_2Dmap.LinkedMap
|
|
54
69
|
local match = string.match
|
|
55
70
|
local ____tostring = _G.tostring
|
|
56
71
|
local setUnitAnimation = SetUnitAnimation
|
|
57
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
58
72
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
59
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
60
73
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
61
74
|
local getUnitRealField = BlzGetUnitRealField
|
|
62
75
|
local getHeroStr = GetHeroStr
|
|
63
76
|
local getHeroAgi = GetHeroAgi
|
|
64
77
|
local getHeroInt = GetHeroInt
|
|
65
|
-
local setHeroStr = SetHeroStr
|
|
66
|
-
local setHeroAgi = SetHeroAgi
|
|
67
|
-
local setHeroInt = SetHeroInt
|
|
68
78
|
local getUnitBooleanField = BlzGetUnitBooleanField
|
|
69
79
|
local getUnitStringField = BlzGetUnitStringField
|
|
70
80
|
local setUnitIntegerField = BlzSetUnitIntegerField
|
|
71
81
|
local setUnitRealField = BlzSetUnitRealField
|
|
72
82
|
local setUnitBooleanField = BlzSetUnitBooleanField
|
|
73
83
|
local setUnitStringField = BlzSetUnitStringField
|
|
74
|
-
local setUnitScale = SetUnitScale
|
|
75
84
|
local setUnitPosition = SetUnitPosition
|
|
76
85
|
local setUnitTimeScale = SetUnitTimeScale
|
|
77
86
|
local getHandleId = GetHandleId
|
|
87
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
78
88
|
local createUnit = CreateUnit
|
|
79
89
|
local killUnit = KillUnit
|
|
80
|
-
local setUnitExploded = SetUnitExploded
|
|
81
90
|
local removeUnit = RemoveUnit
|
|
82
91
|
local getUnitTypeId = GetUnitTypeId
|
|
83
92
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -93,15 +102,12 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
93
102
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
94
103
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
95
104
|
local isUnitInRange = IsUnitInRange
|
|
96
|
-
local setResourceAmount = SetResourceAmount
|
|
97
|
-
local getResourceAmount = GetResourceAmount
|
|
98
105
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
99
106
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
100
107
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
101
108
|
local setUnitWeaponStringField = BlzSetUnitWeaponStringField
|
|
102
109
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
103
110
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
104
|
-
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
105
111
|
local isUnitInvisible = IsUnitInvisible
|
|
106
112
|
local isUnitVisible = IsUnitVisible
|
|
107
113
|
local getUnitX = GetUnitX
|
|
@@ -118,15 +124,9 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
118
124
|
local getIssuedOrderId = GetIssuedOrderId
|
|
119
125
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
120
126
|
local unitAlive = UnitAlive
|
|
121
|
-
local unitAddType = UnitAddType
|
|
122
|
-
local unitRemoveType = UnitRemoveType
|
|
123
|
-
local isUnitIllusion = IsUnitIllusion
|
|
124
|
-
local isUnitType = IsUnitType
|
|
125
127
|
local isUnitAlly = IsUnitAlly
|
|
126
128
|
local isUnitEnemy = IsUnitEnemy
|
|
127
129
|
local getOwningPlayer = GetOwningPlayer
|
|
128
|
-
local setUnitColor = SetUnitColor
|
|
129
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
130
130
|
____exports.UnitClassification = {}
|
|
131
131
|
local UnitClassification = ____exports.UnitClassification
|
|
132
132
|
do
|
|
@@ -136,6 +136,7 @@ do
|
|
|
136
136
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
137
137
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
138
138
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
139
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
139
140
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
140
141
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
141
142
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -343,6 +344,9 @@ local function dispatchAbility(event)
|
|
|
343
344
|
}
|
|
344
345
|
)
|
|
345
346
|
end
|
|
347
|
+
local function damagingEventPreventRetaliation(self)
|
|
348
|
+
self[0] = true
|
|
349
|
+
end
|
|
346
350
|
local function damageEventPreventDeath(self, callback, ...)
|
|
347
351
|
if self[0] ~= nil then
|
|
348
352
|
return
|
|
@@ -354,7 +358,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
354
358
|
rawset(self, 1 + i, (select(i, ...)))
|
|
355
359
|
end
|
|
356
360
|
end
|
|
357
|
-
local damageSetters = {
|
|
361
|
+
local damageSetters = {
|
|
362
|
+
amount = BlzSetEventDamage,
|
|
363
|
+
attackType = function(attackType)
|
|
364
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
365
|
+
end,
|
|
366
|
+
damageType = BlzSetEventDamageType,
|
|
367
|
+
weaponType = BlzSetEventWeaponType
|
|
368
|
+
}
|
|
358
369
|
local jlimitopByOperator = {
|
|
359
370
|
[0] = LESS_THAN_OR_EQUAL,
|
|
360
371
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -372,15 +383,24 @@ local modifiers = {
|
|
|
372
383
|
end,
|
|
373
384
|
armor = function(unit, value)
|
|
374
385
|
if UnitAddAbility(unit, armorBonusAbilityId) then
|
|
375
|
-
assert(
|
|
386
|
+
assert(
|
|
387
|
+
UnitMakeAbilityPermanent(unit, true, armorBonusAbilityId),
|
|
388
|
+
"armor bonus ability must be made permanent"
|
|
389
|
+
)
|
|
376
390
|
end
|
|
377
|
-
local ability = assert(
|
|
378
|
-
|
|
379
|
-
ability
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
391
|
+
local ability = assert(
|
|
392
|
+
BlzGetUnitAbility(unit, armorBonusAbilityId),
|
|
393
|
+
"armor bonus ability must be existing"
|
|
394
|
+
)
|
|
395
|
+
assert(
|
|
396
|
+
BlzSetAbilityRealLevelField(
|
|
397
|
+
ability,
|
|
398
|
+
armorBonusField,
|
|
399
|
+
0,
|
|
400
|
+
BlzGetAbilityRealLevelField(ability, armorBonusField, 0) + value
|
|
401
|
+
),
|
|
402
|
+
"armor bonus ability field must be set"
|
|
403
|
+
)
|
|
384
404
|
end
|
|
385
405
|
}
|
|
386
406
|
local getters = {
|
|
@@ -398,6 +418,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
|
398
418
|
self.unit = unit
|
|
399
419
|
self.index = index
|
|
400
420
|
end
|
|
421
|
+
__TS__SetDescriptor(
|
|
422
|
+
UnitWeapon.prototype,
|
|
423
|
+
"isEnabled",
|
|
424
|
+
{
|
|
425
|
+
get = function(self)
|
|
426
|
+
return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
|
|
427
|
+
end,
|
|
428
|
+
set = function(self, isEnabled)
|
|
429
|
+
BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
|
|
430
|
+
end
|
|
431
|
+
},
|
|
432
|
+
true
|
|
433
|
+
)
|
|
401
434
|
__TS__SetDescriptor(
|
|
402
435
|
UnitWeapon.prototype,
|
|
403
436
|
"cooldown",
|
|
@@ -432,6 +465,19 @@ __TS__SetDescriptor(
|
|
|
432
465
|
},
|
|
433
466
|
true
|
|
434
467
|
)
|
|
468
|
+
__TS__SetDescriptor(
|
|
469
|
+
UnitWeapon.prototype,
|
|
470
|
+
"allowedTargetCombatClassifications",
|
|
471
|
+
{
|
|
472
|
+
get = function(self)
|
|
473
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
474
|
+
end,
|
|
475
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
476
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
477
|
+
end
|
|
478
|
+
},
|
|
479
|
+
true
|
|
480
|
+
)
|
|
435
481
|
__TS__SetDescriptor(
|
|
436
482
|
UnitWeapon.prototype,
|
|
437
483
|
"damageBase",
|
|
@@ -562,17 +608,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
562
608
|
____exports.Unit:of(unit)
|
|
563
609
|
)
|
|
564
610
|
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
611
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
577
612
|
local item = unitItemInSlot(unit, i)
|
|
578
613
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -619,26 +654,29 @@ local fieldSetters = {
|
|
|
619
654
|
}
|
|
620
655
|
local dummies = {}
|
|
621
656
|
for ____, player in ipairs(Player.all) do
|
|
622
|
-
local dummy = assert(
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
657
|
+
local dummy = assert(
|
|
658
|
+
createUnit(
|
|
659
|
+
player.handle,
|
|
660
|
+
dummyUnitId,
|
|
661
|
+
0,
|
|
662
|
+
0,
|
|
663
|
+
270
|
|
664
|
+
),
|
|
665
|
+
"dummy must be created"
|
|
666
|
+
)
|
|
629
667
|
ShowUnit(dummy, false)
|
|
630
668
|
dummies[player] = dummy
|
|
631
669
|
end
|
|
632
670
|
local function delayHealthChecksCallback(unit)
|
|
633
|
-
local counter = (unit[
|
|
671
|
+
local counter = (unit[104] or 0) - 1
|
|
634
672
|
if counter ~= 0 then
|
|
635
|
-
unit[
|
|
673
|
+
unit[104] = counter
|
|
636
674
|
return
|
|
637
675
|
end
|
|
638
|
-
unit[
|
|
639
|
-
local healthBonus = unit[
|
|
676
|
+
unit[104] = nil
|
|
677
|
+
local healthBonus = unit[105]
|
|
640
678
|
if healthBonus ~= nil then
|
|
641
|
-
unit[
|
|
679
|
+
unit[105] = nil
|
|
642
680
|
local handle = unit.handle
|
|
643
681
|
BlzSetUnitMaxHP(
|
|
644
682
|
handle,
|
|
@@ -646,42 +684,71 @@ local function delayHealthChecksCallback(unit)
|
|
|
646
684
|
)
|
|
647
685
|
end
|
|
648
686
|
end
|
|
687
|
+
local nextSyncId = 1
|
|
688
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
689
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
690
|
+
local function addAbility(unit, abilityTypeId)
|
|
691
|
+
local ____unitAddAbility_result_0
|
|
692
|
+
if unitAddAbility(unit, abilityTypeId) then
|
|
693
|
+
____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
|
|
694
|
+
else
|
|
695
|
+
____unitAddAbility_result_0 = nil
|
|
696
|
+
end
|
|
697
|
+
return ____unitAddAbility_result_0
|
|
698
|
+
end
|
|
649
699
|
____exports.Unit = __TS__Class()
|
|
650
700
|
local Unit = ____exports.Unit
|
|
651
701
|
Unit.name = "Unit"
|
|
652
702
|
__TS__ClassExtends(Unit, Handle)
|
|
653
703
|
function Unit.prototype.____constructor(self, handle)
|
|
654
704
|
Handle.prototype.____constructor(self, handle)
|
|
705
|
+
local ____nextSyncId_1 = nextSyncId
|
|
706
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
707
|
+
self.syncId = ____nextSyncId_1
|
|
655
708
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
656
|
-
assert(
|
|
657
|
-
|
|
709
|
+
assert(
|
|
710
|
+
unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId),
|
|
711
|
+
"leave detection ability must be added"
|
|
712
|
+
)
|
|
713
|
+
assert(
|
|
714
|
+
unitAddAbility(handle, morphDetectAbilityId),
|
|
715
|
+
"morph detection ability must be added"
|
|
716
|
+
)
|
|
658
717
|
if unitAddAbility(
|
|
659
718
|
handle,
|
|
660
719
|
fourCC("Amrf")
|
|
661
720
|
) then
|
|
662
|
-
assert(
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
721
|
+
assert(
|
|
722
|
+
unitRemoveAbility(
|
|
723
|
+
handle,
|
|
724
|
+
fourCC("Amrf")
|
|
725
|
+
),
|
|
726
|
+
"fly ability must be removed after addition"
|
|
727
|
+
)
|
|
666
728
|
end
|
|
729
|
+
unitBySyncId[self.syncId] = self
|
|
667
730
|
local ____ = self.abilities
|
|
668
731
|
end
|
|
669
|
-
function Unit.prototype.getEvent(self,
|
|
670
|
-
self.events = self.events or (
|
|
671
|
-
local eventId = GetHandleId(
|
|
672
|
-
|
|
673
|
-
|
|
732
|
+
function Unit.prototype.getEvent(self, jevent, collector)
|
|
733
|
+
self.events = self.events or __TS__New(LinkedMap)
|
|
734
|
+
local eventId = GetHandleId(jevent)
|
|
735
|
+
local event = self.events:get(eventId)
|
|
736
|
+
if event == nil then
|
|
737
|
+
event = __TS__New(
|
|
674
738
|
TriggerEvent,
|
|
675
739
|
function(trigger)
|
|
676
|
-
TriggerRegisterUnitEvent(trigger, self.handle,
|
|
740
|
+
TriggerRegisterUnitEvent(trigger, self.handle, jevent)
|
|
677
741
|
end,
|
|
678
742
|
collector or (function() return {} end)
|
|
679
743
|
)
|
|
744
|
+
self.events:put(eventId, event)
|
|
680
745
|
end
|
|
681
|
-
return
|
|
746
|
+
return event
|
|
682
747
|
end
|
|
683
748
|
function Unit.prototype.onDestroy(self)
|
|
684
749
|
local handle = self.handle
|
|
750
|
+
self[108] = getUnitX(handle)
|
|
751
|
+
self[109] = getUnitY(handle)
|
|
685
752
|
if not self._owner then
|
|
686
753
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
687
754
|
end
|
|
@@ -720,7 +787,10 @@ function Unit.prototype.addAttackHandler(self, condition, action)
|
|
|
720
787
|
self._attackHandlers = handlers
|
|
721
788
|
if #handlers == 1 then
|
|
722
789
|
local handle = self.handle
|
|
723
|
-
assert(
|
|
790
|
+
assert(
|
|
791
|
+
unitAddAbility(handle, attackHandlerAbilityId) and UnitMakeAbilityPermanent(handle, true, attackHandlerAbilityId),
|
|
792
|
+
"attack handler ability must be added"
|
|
793
|
+
)
|
|
724
794
|
end
|
|
725
795
|
return handler
|
|
726
796
|
end
|
|
@@ -749,17 +819,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
749
819
|
end}
|
|
750
820
|
end
|
|
751
821
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
752
|
-
local
|
|
753
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
822
|
+
local ____combatClassification_2 = combatClassification
|
|
823
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
|
|
754
824
|
end
|
|
755
825
|
function Unit.prototype.addClassification(self, classification)
|
|
756
|
-
return
|
|
826
|
+
return UnitAddType(self.handle, classification)
|
|
757
827
|
end
|
|
758
828
|
function Unit.prototype.removeClassification(self, classification)
|
|
759
|
-
return
|
|
829
|
+
return UnitRemoveType(self.handle, classification)
|
|
760
830
|
end
|
|
761
831
|
function Unit.prototype.hasClassification(self, classification)
|
|
762
|
-
return
|
|
832
|
+
return IsUnitType(self.handle, classification)
|
|
763
833
|
end
|
|
764
834
|
function Unit.prototype.isVisibleTo(self, player)
|
|
765
835
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -768,13 +838,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
768
838
|
return isUnitInvisible(self.handle, player.handle)
|
|
769
839
|
end
|
|
770
840
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
771
|
-
local
|
|
841
|
+
local ____temp_3
|
|
772
842
|
if type(x) == "number" then
|
|
773
|
-
|
|
843
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
774
844
|
else
|
|
775
|
-
|
|
845
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
776
846
|
end
|
|
777
|
-
return
|
|
847
|
+
return ____temp_3
|
|
778
848
|
end
|
|
779
849
|
function Unit.prototype.isAllyOf(self, unit)
|
|
780
850
|
return isUnitAlly(
|
|
@@ -792,16 +862,30 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
792
862
|
if type(animation) == "number" then
|
|
793
863
|
setUnitAnimationByIndex(self.handle, animation)
|
|
794
864
|
elseif rarity then
|
|
795
|
-
|
|
865
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
796
866
|
else
|
|
797
867
|
setUnitAnimation(self.handle, animation)
|
|
798
868
|
end
|
|
799
869
|
end
|
|
870
|
+
function Unit.prototype.resetAnimation(self)
|
|
871
|
+
ResetUnitAnimation(self.handle)
|
|
872
|
+
end
|
|
800
873
|
function Unit.prototype.queueAnimation(self, animation)
|
|
801
|
-
|
|
874
|
+
QueueUnitAnimation(self.handle, animation)
|
|
875
|
+
end
|
|
876
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
877
|
+
local firstWeapon = self.firstWeapon
|
|
878
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
879
|
+
return firstWeapon
|
|
880
|
+
end
|
|
881
|
+
local secondWeapon = self.secondWeapon
|
|
882
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
883
|
+
return secondWeapon
|
|
884
|
+
end
|
|
885
|
+
return nil
|
|
802
886
|
end
|
|
803
887
|
function Unit.prototype.delayHealthChecks(self)
|
|
804
|
-
self[
|
|
888
|
+
self[104] = (self[104] or 0) + 1
|
|
805
889
|
Timer:run(delayHealthChecksCallback, self)
|
|
806
890
|
end
|
|
807
891
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -811,21 +895,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
811
895
|
return IsUnitSelected(self.handle, player.handle)
|
|
812
896
|
end
|
|
813
897
|
function Unit.prototype.explode(self)
|
|
814
|
-
|
|
898
|
+
SetUnitExploded(self.handle, true)
|
|
815
899
|
killUnit(self.handle)
|
|
816
900
|
end
|
|
817
901
|
function Unit.prototype.kill(self)
|
|
818
902
|
killUnit(self.handle)
|
|
819
903
|
end
|
|
820
904
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
821
|
-
local
|
|
822
|
-
local
|
|
823
|
-
local
|
|
824
|
-
if
|
|
825
|
-
|
|
905
|
+
local ____ReviveHero_6 = ReviveHero
|
|
906
|
+
local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
|
|
907
|
+
local ____doEffect_4 = doEffect
|
|
908
|
+
if ____doEffect_4 == nil then
|
|
909
|
+
____doEffect_4 = false
|
|
826
910
|
end
|
|
827
|
-
__TS__SparseArrayPush(
|
|
828
|
-
|
|
911
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
912
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
829
913
|
end
|
|
830
914
|
function Unit.prototype.healTarget(self, target, amount)
|
|
831
915
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -865,20 +949,19 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
865
949
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
866
950
|
end
|
|
867
951
|
function Unit.prototype.itemInSlot(self, slot)
|
|
868
|
-
return Item:of(
|
|
952
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
869
953
|
end
|
|
870
954
|
function Unit.prototype.addAbility(self, abilityId)
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
955
|
+
local ability = UnitAbility:of(
|
|
956
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
957
|
+
abilityId,
|
|
958
|
+
self
|
|
959
|
+
)
|
|
960
|
+
if ability ~= nil then
|
|
877
961
|
local abilities = self.abilities
|
|
878
962
|
abilities[#abilities + 1] = ability
|
|
879
|
-
return ability
|
|
880
963
|
end
|
|
881
|
-
return
|
|
964
|
+
return ability
|
|
882
965
|
end
|
|
883
966
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
884
967
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -892,31 +975,21 @@ end
|
|
|
892
975
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
893
976
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
894
977
|
end
|
|
895
|
-
function Unit.prototype.
|
|
896
|
-
local
|
|
897
|
-
|
|
898
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
899
|
-
return nil
|
|
900
|
-
end
|
|
901
|
-
return UnitAbility:of(
|
|
902
|
-
getUnitAbility(self.handle, abilityId),
|
|
903
|
-
abilityId,
|
|
904
|
-
self
|
|
905
|
-
)
|
|
978
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
979
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
980
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
906
981
|
end
|
|
907
|
-
function Unit.prototype.removeAbility(self,
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
end
|
|
982
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
983
|
+
local abilities = self.abilities
|
|
984
|
+
for i = 1, #abilities do
|
|
985
|
+
if abilities[i].typeId == abilityTypeId then
|
|
986
|
+
local ability = abilities[i]
|
|
987
|
+
tremove(abilities, i)
|
|
988
|
+
ability:destroy()
|
|
989
|
+
return true
|
|
916
990
|
end
|
|
917
|
-
return true
|
|
918
991
|
end
|
|
919
|
-
return
|
|
992
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
920
993
|
end
|
|
921
994
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
922
995
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -930,12 +1003,16 @@ end
|
|
|
930
1003
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
931
1004
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
932
1005
|
end
|
|
933
|
-
function Unit.prototype.interruptAttack(self)
|
|
934
|
-
unitInterruptAttack(self.handle)
|
|
935
|
-
end
|
|
936
1006
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
937
|
-
|
|
938
|
-
unitDisableAbility(
|
|
1007
|
+
local handle = self.handle
|
|
1008
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
1009
|
+
Timer:run(
|
|
1010
|
+
unitDisableAbility,
|
|
1011
|
+
handle,
|
|
1012
|
+
abilityId,
|
|
1013
|
+
false,
|
|
1014
|
+
false
|
|
1015
|
+
)
|
|
939
1016
|
end
|
|
940
1017
|
function Unit.prototype.getDistanceTo(self, target)
|
|
941
1018
|
local handle = self.handle
|
|
@@ -995,18 +1072,44 @@ function Unit.prototype.unpauseEx(self)
|
|
|
995
1072
|
self:decrementStunCounter()
|
|
996
1073
|
end
|
|
997
1074
|
function Unit.prototype.incrementStunCounter(self)
|
|
998
|
-
local stunCounter = self[
|
|
999
|
-
if not self[
|
|
1075
|
+
local stunCounter = self[102] or 0
|
|
1076
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
|
|
1000
1077
|
BlzPauseUnitEx(self.handle, true)
|
|
1001
1078
|
end
|
|
1002
|
-
self[
|
|
1079
|
+
self[102] = stunCounter + 1
|
|
1003
1080
|
end
|
|
1004
1081
|
function Unit.prototype.decrementStunCounter(self)
|
|
1005
|
-
local stunCounter = self[
|
|
1006
|
-
if not self[
|
|
1082
|
+
local stunCounter = self[102] or 0
|
|
1083
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
|
|
1007
1084
|
BlzPauseUnitEx(self.handle, false)
|
|
1008
1085
|
end
|
|
1009
|
-
self[
|
|
1086
|
+
self[102] = stunCounter - 1
|
|
1087
|
+
end
|
|
1088
|
+
function Unit.prototype.incrementForceStunCounter(self)
|
|
1089
|
+
local forceStunCounter = self[103] or 0
|
|
1090
|
+
if forceStunCounter == 0 then
|
|
1091
|
+
local handle = self.handle
|
|
1092
|
+
if not self[101] then
|
|
1093
|
+
for _ = self[102] or 0, -1 do
|
|
1094
|
+
BlzPauseUnitEx(handle, true)
|
|
1095
|
+
end
|
|
1096
|
+
end
|
|
1097
|
+
BlzPauseUnitEx(handle, true)
|
|
1098
|
+
end
|
|
1099
|
+
self[103] = forceStunCounter + 1
|
|
1100
|
+
end
|
|
1101
|
+
function Unit.prototype.decrementForceStunCounter(self)
|
|
1102
|
+
local forceStunCounter = self[103] or 0
|
|
1103
|
+
if forceStunCounter == 1 then
|
|
1104
|
+
local handle = self.handle
|
|
1105
|
+
if not self[101] then
|
|
1106
|
+
for _ = self[102] or 0, -1 do
|
|
1107
|
+
BlzPauseUnitEx(handle, false)
|
|
1108
|
+
end
|
|
1109
|
+
end
|
|
1110
|
+
BlzPauseUnitEx(handle, false)
|
|
1111
|
+
end
|
|
1112
|
+
self[103] = forceStunCounter - 1
|
|
1010
1113
|
end
|
|
1011
1114
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1012
1115
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -1108,8 +1211,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
1108
1211
|
)
|
|
1109
1212
|
return targetCollection
|
|
1110
1213
|
end
|
|
1111
|
-
function Unit.getSelectionOf(self, player)
|
|
1112
|
-
|
|
1214
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1215
|
+
if target == nil then
|
|
1216
|
+
target = {}
|
|
1217
|
+
end
|
|
1218
|
+
targetCollection = target
|
|
1113
1219
|
targetCollectionNextIndex = 1
|
|
1114
1220
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
1115
1221
|
return targetCollection
|
|
@@ -1131,6 +1237,9 @@ end
|
|
|
1131
1237
|
function Unit.prototype.__tostring(self)
|
|
1132
1238
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
1133
1239
|
end
|
|
1240
|
+
function Unit.getBySyncId(self, syncId)
|
|
1241
|
+
return unitBySyncId[syncId]
|
|
1242
|
+
end
|
|
1134
1243
|
__TS__SetDescriptor(
|
|
1135
1244
|
Unit.prototype,
|
|
1136
1245
|
"_deltas",
|
|
@@ -1190,7 +1299,15 @@ __TS__SetDescriptor(
|
|
|
1190
1299
|
Unit.prototype,
|
|
1191
1300
|
"isIllusion",
|
|
1192
1301
|
{get = function(self)
|
|
1193
|
-
return
|
|
1302
|
+
return IsUnitIllusion(self.handle)
|
|
1303
|
+
end},
|
|
1304
|
+
true
|
|
1305
|
+
)
|
|
1306
|
+
__TS__SetDescriptor(
|
|
1307
|
+
Unit.prototype,
|
|
1308
|
+
"isStunned",
|
|
1309
|
+
{get = function(self)
|
|
1310
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1194
1311
|
end},
|
|
1195
1312
|
true
|
|
1196
1313
|
)
|
|
@@ -1269,13 +1386,13 @@ __TS__SetDescriptor(
|
|
|
1269
1386
|
)
|
|
1270
1387
|
__TS__SetDescriptor(
|
|
1271
1388
|
Unit.prototype,
|
|
1272
|
-
"
|
|
1389
|
+
"primaryAttribute",
|
|
1273
1390
|
{
|
|
1274
1391
|
get = function(self)
|
|
1275
|
-
return
|
|
1392
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1276
1393
|
end,
|
|
1277
|
-
set = function(self,
|
|
1278
|
-
|
|
1394
|
+
set = function(self, primaryAttribute)
|
|
1395
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1279
1396
|
end
|
|
1280
1397
|
},
|
|
1281
1398
|
true
|
|
@@ -1297,19 +1414,6 @@ __TS__SetDescriptor(
|
|
|
1297
1414
|
end},
|
|
1298
1415
|
true
|
|
1299
1416
|
)
|
|
1300
|
-
__TS__SetDescriptor(
|
|
1301
|
-
Unit.prototype,
|
|
1302
|
-
"agilityBase",
|
|
1303
|
-
{
|
|
1304
|
-
get = function(self)
|
|
1305
|
-
return getHeroAgi(self.handle, false)
|
|
1306
|
-
end,
|
|
1307
|
-
set = function(self, agilityBase)
|
|
1308
|
-
setHeroAgi(self.handle, agilityBase, true)
|
|
1309
|
-
end
|
|
1310
|
-
},
|
|
1311
|
-
true
|
|
1312
|
-
)
|
|
1313
1417
|
__TS__SetDescriptor(
|
|
1314
1418
|
Unit.prototype,
|
|
1315
1419
|
"agilityBonus",
|
|
@@ -1327,19 +1431,6 @@ __TS__SetDescriptor(
|
|
|
1327
1431
|
end},
|
|
1328
1432
|
true
|
|
1329
1433
|
)
|
|
1330
|
-
__TS__SetDescriptor(
|
|
1331
|
-
Unit.prototype,
|
|
1332
|
-
"intelligenceBase",
|
|
1333
|
-
{
|
|
1334
|
-
get = function(self)
|
|
1335
|
-
return getHeroInt(self.handle, false)
|
|
1336
|
-
end,
|
|
1337
|
-
set = function(self, intelligenceBase)
|
|
1338
|
-
setHeroInt(self.handle, intelligenceBase, true)
|
|
1339
|
-
end
|
|
1340
|
-
},
|
|
1341
|
-
true
|
|
1342
|
-
)
|
|
1343
1434
|
__TS__SetDescriptor(
|
|
1344
1435
|
Unit.prototype,
|
|
1345
1436
|
"intelligenceBonus",
|
|
@@ -1388,17 +1479,17 @@ __TS__SetDescriptor(
|
|
|
1388
1479
|
"isTeamGlowVisible",
|
|
1389
1480
|
{
|
|
1390
1481
|
get = function(self)
|
|
1391
|
-
return not self[
|
|
1482
|
+
return not self[107]
|
|
1392
1483
|
end,
|
|
1393
1484
|
set = function(self, isTeamGlowVisible)
|
|
1394
|
-
|
|
1395
|
-
local
|
|
1485
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1486
|
+
local ____temp_7
|
|
1396
1487
|
if not isTeamGlowVisible then
|
|
1397
|
-
|
|
1488
|
+
____temp_7 = true
|
|
1398
1489
|
else
|
|
1399
|
-
|
|
1490
|
+
____temp_7 = nil
|
|
1400
1491
|
end
|
|
1401
|
-
self[
|
|
1492
|
+
self[107] = ____temp_7
|
|
1402
1493
|
end
|
|
1403
1494
|
},
|
|
1404
1495
|
true
|
|
@@ -1407,9 +1498,9 @@ __TS__SetDescriptor(
|
|
|
1407
1498
|
Unit.prototype,
|
|
1408
1499
|
"color",
|
|
1409
1500
|
{set = function(self, color)
|
|
1410
|
-
|
|
1411
|
-
if self[
|
|
1412
|
-
|
|
1501
|
+
SetUnitColor(self.handle, color.handle)
|
|
1502
|
+
if self[107] then
|
|
1503
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1413
1504
|
end
|
|
1414
1505
|
end},
|
|
1415
1506
|
true
|
|
@@ -1432,14 +1523,14 @@ __TS__SetDescriptor(
|
|
|
1432
1523
|
"maxHealth",
|
|
1433
1524
|
{
|
|
1434
1525
|
get = function(self)
|
|
1435
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1526
|
+
return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
|
|
1436
1527
|
end,
|
|
1437
1528
|
set = function(self, maxHealth)
|
|
1438
|
-
if maxHealth < 1 and self[
|
|
1439
|
-
self[
|
|
1529
|
+
if maxHealth < 1 and self[104] ~= nil then
|
|
1530
|
+
self[105] = (self[105] or 0) + (1 - maxHealth)
|
|
1440
1531
|
maxHealth = 1
|
|
1441
1532
|
end
|
|
1442
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1533
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
|
|
1443
1534
|
end
|
|
1444
1535
|
},
|
|
1445
1536
|
true
|
|
@@ -1481,10 +1572,10 @@ __TS__SetDescriptor(
|
|
|
1481
1572
|
"health",
|
|
1482
1573
|
{
|
|
1483
1574
|
get = function(self)
|
|
1484
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1575
|
+
return GetWidgetLife(self.handle) - (self[106] or 0)
|
|
1485
1576
|
end,
|
|
1486
1577
|
set = function(self, health)
|
|
1487
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1578
|
+
SetWidgetLife(self.handle, health + (self[106] or 0))
|
|
1488
1579
|
end
|
|
1489
1580
|
},
|
|
1490
1581
|
true
|
|
@@ -1560,25 +1651,12 @@ __TS__SetDescriptor(
|
|
|
1560
1651
|
},
|
|
1561
1652
|
true
|
|
1562
1653
|
)
|
|
1563
|
-
__TS__SetDescriptor(
|
|
1564
|
-
Unit.prototype,
|
|
1565
|
-
"flyHeight",
|
|
1566
|
-
{
|
|
1567
|
-
get = function(self)
|
|
1568
|
-
return getUnitFlyHeight(self.handle)
|
|
1569
|
-
end,
|
|
1570
|
-
set = function(self, v)
|
|
1571
|
-
SetUnitFlyHeight(self.handle, v, 100000)
|
|
1572
|
-
end
|
|
1573
|
-
},
|
|
1574
|
-
true
|
|
1575
|
-
)
|
|
1576
1654
|
__TS__SetDescriptor(
|
|
1577
1655
|
Unit.prototype,
|
|
1578
1656
|
"x",
|
|
1579
1657
|
{
|
|
1580
1658
|
get = function(self)
|
|
1581
|
-
return getUnitX(self.handle)
|
|
1659
|
+
return self[108] or getUnitX(self.handle)
|
|
1582
1660
|
end,
|
|
1583
1661
|
set = function(self, v)
|
|
1584
1662
|
SetUnitX(self.handle, v)
|
|
@@ -1591,7 +1669,7 @@ __TS__SetDescriptor(
|
|
|
1591
1669
|
"y",
|
|
1592
1670
|
{
|
|
1593
1671
|
get = function(self)
|
|
1594
|
-
return getUnitY(self.handle)
|
|
1672
|
+
return self[109] or getUnitY(self.handle)
|
|
1595
1673
|
end,
|
|
1596
1674
|
set = function(self, v)
|
|
1597
1675
|
SetUnitY(self.handle, v)
|
|
@@ -1677,10 +1755,10 @@ __TS__SetDescriptor(
|
|
|
1677
1755
|
"gold",
|
|
1678
1756
|
{
|
|
1679
1757
|
get = function(self)
|
|
1680
|
-
return
|
|
1758
|
+
return GetResourceAmount(self.handle)
|
|
1681
1759
|
end,
|
|
1682
1760
|
set = function(self, gold)
|
|
1683
|
-
|
|
1761
|
+
SetResourceAmount(self.handle, gold)
|
|
1684
1762
|
end
|
|
1685
1763
|
},
|
|
1686
1764
|
true
|
|
@@ -1695,17 +1773,21 @@ __TS__SetDescriptor(
|
|
|
1695
1773
|
set = function(self, isPaused)
|
|
1696
1774
|
local handle = self.handle
|
|
1697
1775
|
if isPaused and not IsUnitPaused(handle) then
|
|
1698
|
-
self[
|
|
1699
|
-
|
|
1700
|
-
|
|
1776
|
+
self[101] = true
|
|
1777
|
+
if (self[103] or 0) <= 0 then
|
|
1778
|
+
for _ = self[102] or 0, -1 do
|
|
1779
|
+
BlzPauseUnitEx(handle, true)
|
|
1780
|
+
end
|
|
1701
1781
|
end
|
|
1702
1782
|
PauseUnit(handle, true)
|
|
1703
1783
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1704
1784
|
PauseUnit(handle, false)
|
|
1705
|
-
|
|
1706
|
-
|
|
1785
|
+
if (self[103] or 0) <= 0 then
|
|
1786
|
+
for _ = self[102] or 0, -1 do
|
|
1787
|
+
BlzPauseUnitEx(handle, false)
|
|
1788
|
+
end
|
|
1707
1789
|
end
|
|
1708
|
-
self[
|
|
1790
|
+
self[101] = nil
|
|
1709
1791
|
end
|
|
1710
1792
|
end
|
|
1711
1793
|
},
|
|
@@ -1761,20 +1843,6 @@ __TS__SetDescriptor(
|
|
|
1761
1843
|
},
|
|
1762
1844
|
true
|
|
1763
1845
|
)
|
|
1764
|
-
__TS__SetDescriptor(
|
|
1765
|
-
Unit.prototype,
|
|
1766
|
-
"scale",
|
|
1767
|
-
{
|
|
1768
|
-
get = function(self)
|
|
1769
|
-
return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
|
|
1770
|
-
end,
|
|
1771
|
-
set = function(self, v)
|
|
1772
|
-
setUnitScale(self.handle, v, v, v)
|
|
1773
|
-
setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
|
|
1774
|
-
end
|
|
1775
|
-
},
|
|
1776
|
-
true
|
|
1777
|
-
)
|
|
1778
1846
|
__TS__SetDescriptor(
|
|
1779
1847
|
Unit.prototype,
|
|
1780
1848
|
"timeScale",
|
|
@@ -1808,6 +1876,19 @@ __TS__SetDescriptor(
|
|
|
1808
1876
|
end},
|
|
1809
1877
|
true
|
|
1810
1878
|
)
|
|
1879
|
+
__TS__SetDescriptor(
|
|
1880
|
+
Unit.prototype,
|
|
1881
|
+
"movementType",
|
|
1882
|
+
{
|
|
1883
|
+
get = function(self)
|
|
1884
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1885
|
+
end,
|
|
1886
|
+
set = function(self, movementType)
|
|
1887
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1888
|
+
end
|
|
1889
|
+
},
|
|
1890
|
+
true
|
|
1891
|
+
)
|
|
1811
1892
|
__TS__SetDescriptor(
|
|
1812
1893
|
Unit.prototype,
|
|
1813
1894
|
"pathing",
|
|
@@ -1989,6 +2070,14 @@ __TS__SetDescriptor(
|
|
|
1989
2070
|
end},
|
|
1990
2071
|
true
|
|
1991
2072
|
)
|
|
2073
|
+
__TS__SetDescriptor(
|
|
2074
|
+
Unit.prototype,
|
|
2075
|
+
"targetAcquiredEvent",
|
|
2076
|
+
{get = function(self)
|
|
2077
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2078
|
+
end},
|
|
2079
|
+
true
|
|
2080
|
+
)
|
|
1992
2081
|
__TS__SetDescriptor(
|
|
1993
2082
|
Unit.prototype,
|
|
1994
2083
|
"onSelect",
|
|
@@ -2049,6 +2138,11 @@ __TS__SetDescriptor(
|
|
|
2049
2138
|
end},
|
|
2050
2139
|
true
|
|
2051
2140
|
)
|
|
2141
|
+
Unit.levelChangedEvent = __TS__New(
|
|
2142
|
+
____exports.UnitTriggerEvent,
|
|
2143
|
+
EVENT_PLAYER_HERO_LEVEL,
|
|
2144
|
+
function() return ____exports.Unit:of(getTriggerUnit()) end
|
|
2145
|
+
)
|
|
2052
2146
|
Unit.deathEvent = __TS__New(
|
|
2053
2147
|
____exports.UnitTriggerEvent,
|
|
2054
2148
|
EVENT_PLAYER_UNIT_DEATH,
|
|
@@ -2124,25 +2218,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
|
|
|
2124
2218
|
InitializingEvent,
|
|
2125
2219
|
function(event)
|
|
2126
2220
|
local function listener(unit, id)
|
|
2127
|
-
local
|
|
2221
|
+
local ____GetSpellTargetUnit_result_10
|
|
2128
2222
|
if GetSpellTargetUnit() then
|
|
2129
|
-
|
|
2223
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2130
2224
|
else
|
|
2131
|
-
local
|
|
2225
|
+
local ____GetSpellTargetItem_result_9
|
|
2132
2226
|
if GetSpellTargetItem() then
|
|
2133
|
-
|
|
2227
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2134
2228
|
else
|
|
2135
|
-
local
|
|
2229
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2136
2230
|
if GetSpellTargetDestructable() then
|
|
2137
|
-
|
|
2231
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2138
2232
|
else
|
|
2139
|
-
|
|
2233
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2140
2234
|
end
|
|
2141
|
-
|
|
2235
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2142
2236
|
end
|
|
2143
|
-
|
|
2237
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2144
2238
|
end
|
|
2145
|
-
local target =
|
|
2239
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2146
2240
|
if target then
|
|
2147
2241
|
invoke(event, unit, id, target)
|
|
2148
2242
|
end
|
|
@@ -2314,10 +2408,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2314
2408
|
____exports.UnitTriggerEvent,
|
|
2315
2409
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2316
2410
|
function()
|
|
2317
|
-
local
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2411
|
+
local handle = getOrderedUnit()
|
|
2412
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2413
|
+
local unit = ____exports.Unit:of(handle)
|
|
2414
|
+
if unit.state == 1 then
|
|
2415
|
+
return unit, getIssuedOrderId()
|
|
2416
|
+
end
|
|
2321
2417
|
end
|
|
2322
2418
|
return IgnoreEvent
|
|
2323
2419
|
end
|
|
@@ -2348,38 +2444,57 @@ Unit.onDamaging = (function()
|
|
|
2348
2444
|
if source and source.typeId == dummyUnitId then
|
|
2349
2445
|
source = nil
|
|
2350
2446
|
end
|
|
2351
|
-
local target = BlzGetEventDamageTarget()
|
|
2447
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2448
|
+
local metadata = damageMetadataByTarget[target]
|
|
2449
|
+
damageMetadataByTarget[target] = nil
|
|
2352
2450
|
local data = {
|
|
2353
2451
|
amount = GetEventDamage(),
|
|
2354
|
-
attackType = BlzGetEventAttackType(),
|
|
2452
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2355
2453
|
damageType = BlzGetEventDamageType(),
|
|
2356
2454
|
weaponType = BlzGetEventWeaponType(),
|
|
2357
|
-
|
|
2455
|
+
metadata = metadata,
|
|
2456
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2457
|
+
originalAmount = GetEventDamage(),
|
|
2458
|
+
originalMetadata = metadata,
|
|
2459
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2358
2460
|
}
|
|
2359
2461
|
if data.isAttack and source then
|
|
2360
|
-
|
|
2361
|
-
if weapon == -1 then
|
|
2362
|
-
local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
|
|
2363
|
-
weapon = 0
|
|
2364
|
-
end
|
|
2365
|
-
data.weapon = assert(source.weapons[weapon + 1])
|
|
2462
|
+
data.weapon = source:chooseWeapon(target)
|
|
2366
2463
|
end
|
|
2367
2464
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2368
2465
|
invoke(
|
|
2369
2466
|
event,
|
|
2370
2467
|
source,
|
|
2371
|
-
|
|
2468
|
+
target,
|
|
2372
2469
|
setmetatable(
|
|
2373
2470
|
{},
|
|
2374
2471
|
{
|
|
2375
2472
|
__index = data,
|
|
2376
2473
|
__newindex = function(self, key, value)
|
|
2377
|
-
damageSetters[key]
|
|
2474
|
+
local damageSetter = damageSetters[key]
|
|
2475
|
+
if damageSetter ~= nil then
|
|
2476
|
+
damageSetter(value)
|
|
2477
|
+
end
|
|
2378
2478
|
data[key] = value
|
|
2379
2479
|
end
|
|
2380
2480
|
}
|
|
2381
2481
|
)
|
|
2382
2482
|
)
|
|
2483
|
+
if data[0] and source then
|
|
2484
|
+
local sourceOwner = source.owner.handle
|
|
2485
|
+
data[1] = sourceOwner
|
|
2486
|
+
local targetOwner = target.owner.handle
|
|
2487
|
+
data[2] = targetOwner
|
|
2488
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2489
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2490
|
+
data[3] = true
|
|
2491
|
+
end
|
|
2492
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2493
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2494
|
+
data[4] = true
|
|
2495
|
+
end
|
|
2496
|
+
end
|
|
2497
|
+
damagingEventByTarget[target] = data
|
|
2383
2498
|
return
|
|
2384
2499
|
end
|
|
2385
2500
|
BlzSetEventDamage(0)
|
|
@@ -2387,7 +2502,7 @@ Unit.onDamaging = (function()
|
|
|
2387
2502
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2388
2503
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2389
2504
|
local sourceOwner = source.owner.handle
|
|
2390
|
-
local targetOwner =
|
|
2505
|
+
local targetOwner = target.owner.handle
|
|
2391
2506
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2392
2507
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2393
2508
|
Timer:run(function()
|
|
@@ -2403,23 +2518,19 @@ Unit.onDamaging = (function()
|
|
|
2403
2518
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2404
2519
|
local condition = ____value[1]
|
|
2405
2520
|
local action = ____value[2]
|
|
2406
|
-
if condition(
|
|
2407
|
-
source,
|
|
2408
|
-
____exports.Unit:of(target),
|
|
2409
|
-
data
|
|
2410
|
-
) then
|
|
2521
|
+
if condition(source, target, data) then
|
|
2411
2522
|
action(
|
|
2412
2523
|
source,
|
|
2413
|
-
|
|
2524
|
+
target,
|
|
2414
2525
|
setmetatable(
|
|
2415
2526
|
{fire = function()
|
|
2416
2527
|
UnitDamageTarget(
|
|
2417
2528
|
source.handle,
|
|
2418
|
-
target,
|
|
2529
|
+
target.handle,
|
|
2419
2530
|
data.amount,
|
|
2420
2531
|
true,
|
|
2421
2532
|
true,
|
|
2422
|
-
data.attackType,
|
|
2533
|
+
attackTypeToNative(data.attackType),
|
|
2423
2534
|
data.damageType,
|
|
2424
2535
|
data.weaponType
|
|
2425
2536
|
)
|
|
@@ -2446,29 +2557,54 @@ Unit.onDamage = __TS__New(
|
|
|
2446
2557
|
if source and source.typeId == dummyUnitId then
|
|
2447
2558
|
source = nil
|
|
2448
2559
|
end
|
|
2560
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2561
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2562
|
+
damagingEventByTarget[target] = nil
|
|
2449
2563
|
local data = {
|
|
2450
2564
|
amount = GetEventDamage(),
|
|
2451
|
-
attackType = BlzGetEventAttackType(),
|
|
2565
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2452
2566
|
damageType = BlzGetEventDamageType(),
|
|
2453
2567
|
weaponType = BlzGetEventWeaponType(),
|
|
2568
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2454
2569
|
isAttack = BlzGetEventIsAttack(),
|
|
2570
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2571
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2455
2572
|
preventDeath = damageEventPreventDeath
|
|
2456
2573
|
}
|
|
2574
|
+
if damagingEvent then
|
|
2575
|
+
for key, value in pairs(damagingEvent) do
|
|
2576
|
+
if isAttribute(key) then
|
|
2577
|
+
data[key] = value
|
|
2578
|
+
end
|
|
2579
|
+
end
|
|
2580
|
+
local sourceOwner = damagingEvent[1]
|
|
2581
|
+
if sourceOwner then
|
|
2582
|
+
local targetOwner = damagingEvent[2]
|
|
2583
|
+
if damagingEvent[3] then
|
|
2584
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2585
|
+
end
|
|
2586
|
+
if damagingEvent[4] then
|
|
2587
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2588
|
+
end
|
|
2589
|
+
end
|
|
2590
|
+
end
|
|
2457
2591
|
local evData = setmetatable(
|
|
2458
2592
|
{},
|
|
2459
2593
|
{
|
|
2460
2594
|
__index = data,
|
|
2461
2595
|
__newindex = function(self, key, value)
|
|
2462
|
-
damageSetters[key]
|
|
2596
|
+
local damageSetter = damageSetters[key]
|
|
2597
|
+
if damageSetter ~= nil then
|
|
2598
|
+
damageSetter(value)
|
|
2599
|
+
end
|
|
2463
2600
|
data[key] = value
|
|
2464
2601
|
end
|
|
2465
2602
|
}
|
|
2466
2603
|
)
|
|
2467
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2468
2604
|
invoke(event, source, target, evData)
|
|
2469
2605
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2470
2606
|
local bonusHealth = math.ceil(evData.amount)
|
|
2471
|
-
target[
|
|
2607
|
+
target[106] = (target[106] or 0) + bonusHealth
|
|
2472
2608
|
BlzSetUnitMaxHP(
|
|
2473
2609
|
target.handle,
|
|
2474
2610
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2482,7 +2618,7 @@ Unit.onDamage = __TS__New(
|
|
|
2482
2618
|
evData[0],
|
|
2483
2619
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2484
2620
|
)
|
|
2485
|
-
target[
|
|
2621
|
+
target[106] = (target[106] or 0) - bonusHealth
|
|
2486
2622
|
SetWidgetLife(
|
|
2487
2623
|
target.handle,
|
|
2488
2624
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2502,32 +2638,110 @@ Unit.onDamage = __TS__New(
|
|
|
2502
2638
|
DestroyTrigger(trigger)
|
|
2503
2639
|
end
|
|
2504
2640
|
)
|
|
2505
|
-
Unit.
|
|
2641
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2506
2642
|
____exports.UnitTriggerEvent,
|
|
2507
2643
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2508
2644
|
function()
|
|
2509
2645
|
local unit = getTriggerUnit()
|
|
2510
|
-
|
|
2511
|
-
|
|
2646
|
+
local item = getManipulatedItem()
|
|
2647
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2648
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2512
2649
|
end
|
|
2513
2650
|
return IgnoreEvent
|
|
2514
2651
|
end
|
|
2515
2652
|
)
|
|
2516
|
-
Unit.
|
|
2653
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2517
2654
|
____exports.UnitTriggerEvent,
|
|
2518
2655
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2519
2656
|
function()
|
|
2520
|
-
local
|
|
2521
|
-
|
|
2522
|
-
|
|
2657
|
+
local unitHandle = getTriggerUnit()
|
|
2658
|
+
local itemHandle = getManipulatedItem()
|
|
2659
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2660
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2661
|
+
local item = Item:of(itemHandle)
|
|
2662
|
+
if item.owner ~= unit then
|
|
2663
|
+
return unit, item
|
|
2664
|
+
end
|
|
2523
2665
|
end
|
|
2524
2666
|
return IgnoreEvent
|
|
2525
2667
|
end
|
|
2526
2668
|
)
|
|
2527
|
-
Unit.
|
|
2669
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2528
2670
|
____exports.UnitTriggerEvent,
|
|
2529
2671
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2530
|
-
function()
|
|
2672
|
+
function()
|
|
2673
|
+
local unit = getTriggerUnit()
|
|
2674
|
+
local item = getManipulatedItem()
|
|
2675
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2676
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2677
|
+
end
|
|
2678
|
+
return IgnoreEvent
|
|
2679
|
+
end
|
|
2680
|
+
)
|
|
2681
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2682
|
+
____exports.UnitTriggerEvent,
|
|
2683
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2684
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2685
|
+
)
|
|
2686
|
+
__TS__ObjectDefineProperty(
|
|
2687
|
+
Unit,
|
|
2688
|
+
"itemChargesChangedEvent",
|
|
2689
|
+
{get = function(self)
|
|
2690
|
+
local event = __TS__New(Event)
|
|
2691
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2692
|
+
local unit = item.owner
|
|
2693
|
+
if unit ~= nil then
|
|
2694
|
+
invoke(event, unit, item)
|
|
2695
|
+
end
|
|
2696
|
+
end)
|
|
2697
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2698
|
+
return event
|
|
2699
|
+
end}
|
|
2700
|
+
)
|
|
2701
|
+
__TS__ObjectDefineProperty(
|
|
2702
|
+
Unit,
|
|
2703
|
+
"itemUseOrderEvent",
|
|
2704
|
+
{get = function(self)
|
|
2705
|
+
local event = __TS__New(Event)
|
|
2706
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2707
|
+
local slot = order - orderId("useslot0")
|
|
2708
|
+
local function listener(unit)
|
|
2709
|
+
local item = unit.items[slot + 1]
|
|
2710
|
+
if item ~= nil then
|
|
2711
|
+
invoke(event, unit, item)
|
|
2712
|
+
end
|
|
2713
|
+
end
|
|
2714
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2715
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2716
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2717
|
+
end
|
|
2718
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2719
|
+
return event
|
|
2720
|
+
end}
|
|
2721
|
+
)
|
|
2722
|
+
__TS__ObjectDefineProperty(
|
|
2723
|
+
Unit,
|
|
2724
|
+
"itemMoveOrderEvent",
|
|
2725
|
+
{get = function(self)
|
|
2726
|
+
local event = __TS__New(Event)
|
|
2727
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2728
|
+
local slotTo = order - orderId("moveslot0")
|
|
2729
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2730
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2731
|
+
if slotFrom ~= nil then
|
|
2732
|
+
invoke(
|
|
2733
|
+
event,
|
|
2734
|
+
unit,
|
|
2735
|
+
item,
|
|
2736
|
+
slotFrom,
|
|
2737
|
+
slotTo
|
|
2738
|
+
)
|
|
2739
|
+
end
|
|
2740
|
+
end)
|
|
2741
|
+
end
|
|
2742
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2743
|
+
return event
|
|
2744
|
+
end}
|
|
2531
2745
|
)
|
|
2532
2746
|
__TS__ObjectDefineProperty(
|
|
2533
2747
|
Unit,
|
|
@@ -2554,6 +2768,10 @@ __TS__ObjectDefineProperty(
|
|
|
2554
2768
|
rawset(self, "destroyEvent", destroyEvent)
|
|
2555
2769
|
return destroyEvent
|
|
2556
2770
|
end}
|
|
2771
|
+
)
|
|
2772
|
+
Unit.synchronize = synchronizer(
|
|
2773
|
+
function(unit) return unit.syncId end,
|
|
2774
|
+
function(syncId) return unitBySyncId[syncId] end
|
|
2557
2775
|
);
|
|
2558
2776
|
(function(self)
|
|
2559
2777
|
local leaveAbilityIds = postcompile(function()
|