warscript 0.0.1-dev.c946175 → 0.0.1-dev.cc49a34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/attributes.d.ts +6 -0
- package/attributes.lua +17 -1
- package/binaryreader.d.ts +1 -0
- package/binaryreader.lua +3 -0
- package/config.d.ts +5 -0
- package/config.lua +10 -0
- package/core/types/effect.d.ts +14 -6
- package/core/types/effect.lua +131 -35
- package/core/types/frame.d.ts +8 -0
- package/core/types/frame.lua +117 -22
- package/core/types/player.d.ts +16 -0
- package/core/types/player.lua +60 -15
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +123 -5
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/tileCell.d.ts +11 -1
- package/core/types/tileCell.lua +97 -0
- package/core/types/timer.d.ts +9 -8
- package/core/types/timer.lua +45 -23
- package/core/util.d.ts +1 -1
- package/core/util.lua +18 -1
- package/decl/native.d.ts +846 -790
- package/destroyable.d.ts +1 -0
- package/destroyable.lua +9 -0
- package/engine/behavior.d.ts +16 -3
- package/engine/behavior.lua +233 -73
- package/engine/behaviour/ability/always-enabled.d.ts +7 -0
- package/engine/behaviour/ability/always-enabled.lua +31 -0
- package/engine/behaviour/ability/apply-buff.d.ts +8 -5
- package/engine/behaviour/ability/apply-buff.lua +36 -4
- package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
- package/engine/behaviour/ability/damage.d.ts +39 -11
- package/engine/behaviour/ability/damage.lua +83 -37
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +43 -0
- package/engine/behaviour/ability/heal.d.ts +33 -6
- package/engine/behaviour/ability/heal.lua +89 -10
- package/engine/behaviour/ability/instant-impact.d.ts +2 -2
- package/engine/behaviour/ability/instant-impact.lua +4 -19
- package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
- package/engine/behaviour/ability/on-command-impact.lua +25 -0
- package/engine/behaviour/ability/remove-buffs.d.ts +25 -0
- package/engine/behaviour/ability/remove-buffs.lua +49 -0
- package/engine/behaviour/ability/restore-mana.d.ts +15 -0
- package/engine/behaviour/ability/restore-mana.lua +29 -0
- package/engine/behaviour/ability.d.ts +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 +119 -44
- package/engine/buff.lua +560 -239
- package/engine/game-map.d.ts +7 -0
- package/engine/game-map.lua +32 -0
- package/engine/internal/ability.d.ts +23 -14
- package/engine/internal/ability.lua +129 -85
- package/engine/internal/item/ability.lua +162 -4
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +20 -19
- package/engine/internal/item.lua +191 -74
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- package/engine/internal/mechanics/cast-ability.lua +6 -3
- package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
- package/engine/internal/misc/ability-disable-counter.lua +13 -0
- package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
- package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
- package/engine/internal/misc/frame-coordinates.d.ts +2 -0
- package/engine/internal/misc/frame-coordinates.lua +21 -0
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/misc/player-local-handle.d.ts +2 -0
- package/engine/internal/misc/player-local-handle.lua +5 -0
- package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
- package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
- package/engine/internal/object-data/evasion-probability.d.ts +2 -0
- package/engine/internal/object-data/evasion-probability.lua +16 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
- package/engine/internal/unit/ability.d.ts +45 -1
- package/engine/internal/unit/ability.lua +128 -17
- package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
- package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot.lua +52 -0
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/attributes.d.ts +17 -0
- package/engine/internal/unit/attributes.lua +46 -0
- package/engine/internal/unit/bonus.d.ts +8 -2
- package/engine/internal/unit/bonus.lua +33 -1
- package/engine/internal/unit/fly-height.d.ts +7 -0
- package/engine/internal/unit/fly-height.lua +20 -0
- package/engine/internal/unit/ignore-events-items.d.ts +2 -0
- package/engine/internal/unit/ignore-events-items.lua +5 -0
- package/engine/internal/unit/interrupts.d.ts +12 -0
- package/engine/internal/unit/interrupts.lua +28 -0
- package/engine/internal/unit/item.d.ts +24 -0
- package/engine/internal/unit/item.lua +78 -0
- package/engine/internal/unit/main-selected.d.ts +13 -0
- package/engine/internal/unit/main-selected.lua +36 -0
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit/scale.d.ts +7 -0
- package/engine/internal/unit/scale.lua +20 -0
- package/engine/internal/unit+ability.lua +12 -3
- package/engine/internal/unit+damage.d.ts +2 -11
- package/engine/internal/unit+damage.lua +10 -14
- package/engine/internal/unit+spellSteal.lua +1 -2
- package/engine/internal/unit+transport.lua +4 -10
- package/engine/internal/unit-missile-launch.lua +70 -13
- package/engine/internal/unit.d.ts +63 -29
- package/engine/internal/unit.lua +437 -245
- 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 +28 -5
- package/engine/object-field/ability.lua +59 -5
- package/engine/object-field/unit.d.ts +72 -3
- package/engine/object-field/unit.lua +268 -7
- package/engine/object-field.d.ts +25 -6
- package/engine/object-field.lua +359 -116
- package/engine/random.d.ts +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/lualib_bundle.lua +7 -2
- package/net/socket.d.ts +7 -1
- package/net/socket.lua +45 -4
- package/network.d.ts +1 -0
- package/network.lua +3 -2
- package/objutil/buff.lua +12 -11
- package/objutil/unit.lua +8 -0
- package/package.json +2 -2
- package/patch-lua.d.ts +0 -0
- package/patch-lua.lua +10 -0
- package/patch-lualib.lua +1 -1
- package/property.d.ts +55 -0
- package/property.lua +374 -0
- package/utility/arrays.d.ts +10 -1
- package/utility/arrays.lua +45 -3
- package/utility/callback-array.d.ts +17 -0
- package/utility/callback-array.lua +61 -0
- package/utility/functions.d.ts +8 -0
- package/utility/functions.lua +13 -0
- package/utility/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
- package/utility/linked-map.d.ts +26 -0
- package/utility/linked-map.lua +66 -0
- package/utility/linked-set.d.ts +13 -2
- package/utility/linked-set.lua +27 -3
- package/utility/lua-maps.d.ts +15 -2
- package/utility/lua-maps.lua +53 -2
- package/utility/lua-sets.d.ts +2 -0
- package/utility/lua-sets.lua +7 -0
- package/utility/records.lua +20 -1
- package/utility/reflection.lua +11 -7
- package/utility/types.d.ts +4 -0
- package/core/mapbounds.d.ts +0 -8
- package/core/mapbounds.lua +0 -12
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
package/engine/internal/unit.lua
CHANGED
|
@@ -51,33 +51,42 @@ local ____arrays = require("utility.arrays")
|
|
|
51
51
|
local forEach = ____arrays.forEach
|
|
52
52
|
local ____math = require("math")
|
|
53
53
|
local min = ____math.min
|
|
54
|
+
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
55
|
+
local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
56
|
+
local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
|
|
57
|
+
local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
|
|
58
|
+
local nativeToAttackType = ____attack_2Dtype.nativeToAttackType
|
|
59
|
+
local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
|
|
60
|
+
local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
|
|
61
|
+
local ____attributes = require("attributes")
|
|
62
|
+
local isAttribute = ____attributes.isAttribute
|
|
63
|
+
local ____ability = require("engine.internal.item.ability")
|
|
64
|
+
local doUnitAbilityAction = ____ability.doUnitAbilityAction
|
|
65
|
+
local ____synchronization = require("engine.synchronization")
|
|
66
|
+
local synchronizer = ____synchronization.synchronizer
|
|
67
|
+
local ____linked_2Dmap = require("utility.linked-map")
|
|
68
|
+
local LinkedMap = ____linked_2Dmap.LinkedMap
|
|
54
69
|
local match = string.match
|
|
55
70
|
local ____tostring = _G.tostring
|
|
56
71
|
local setUnitAnimation = SetUnitAnimation
|
|
57
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
58
72
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
59
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
60
73
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
61
74
|
local getUnitRealField = BlzGetUnitRealField
|
|
62
75
|
local getHeroStr = GetHeroStr
|
|
63
76
|
local getHeroAgi = GetHeroAgi
|
|
64
77
|
local getHeroInt = GetHeroInt
|
|
65
|
-
local setHeroStr = SetHeroStr
|
|
66
|
-
local setHeroAgi = SetHeroAgi
|
|
67
|
-
local setHeroInt = SetHeroInt
|
|
68
78
|
local getUnitBooleanField = BlzGetUnitBooleanField
|
|
69
79
|
local getUnitStringField = BlzGetUnitStringField
|
|
70
80
|
local setUnitIntegerField = BlzSetUnitIntegerField
|
|
71
81
|
local setUnitRealField = BlzSetUnitRealField
|
|
72
82
|
local setUnitBooleanField = BlzSetUnitBooleanField
|
|
73
83
|
local setUnitStringField = BlzSetUnitStringField
|
|
74
|
-
local setUnitScale = SetUnitScale
|
|
75
84
|
local setUnitPosition = SetUnitPosition
|
|
76
85
|
local setUnitTimeScale = SetUnitTimeScale
|
|
77
86
|
local getHandleId = GetHandleId
|
|
87
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
78
88
|
local createUnit = CreateUnit
|
|
79
89
|
local killUnit = KillUnit
|
|
80
|
-
local setUnitExploded = SetUnitExploded
|
|
81
90
|
local removeUnit = RemoveUnit
|
|
82
91
|
local getUnitTypeId = GetUnitTypeId
|
|
83
92
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -93,15 +102,12 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
93
102
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
94
103
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
95
104
|
local isUnitInRange = IsUnitInRange
|
|
96
|
-
local setResourceAmount = SetResourceAmount
|
|
97
|
-
local getResourceAmount = GetResourceAmount
|
|
98
105
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
99
106
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
100
107
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
101
108
|
local setUnitWeaponStringField = BlzSetUnitWeaponStringField
|
|
102
109
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
103
110
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
104
|
-
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
105
111
|
local isUnitInvisible = IsUnitInvisible
|
|
106
112
|
local isUnitVisible = IsUnitVisible
|
|
107
113
|
local getUnitX = GetUnitX
|
|
@@ -118,15 +124,9 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
118
124
|
local getIssuedOrderId = GetIssuedOrderId
|
|
119
125
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
120
126
|
local unitAlive = UnitAlive
|
|
121
|
-
local unitAddType = UnitAddType
|
|
122
|
-
local unitRemoveType = UnitRemoveType
|
|
123
|
-
local isUnitIllusion = IsUnitIllusion
|
|
124
|
-
local isUnitType = IsUnitType
|
|
125
127
|
local isUnitAlly = IsUnitAlly
|
|
126
128
|
local isUnitEnemy = IsUnitEnemy
|
|
127
129
|
local getOwningPlayer = GetOwningPlayer
|
|
128
|
-
local setUnitColor = SetUnitColor
|
|
129
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
130
130
|
____exports.UnitClassification = {}
|
|
131
131
|
local UnitClassification = ____exports.UnitClassification
|
|
132
132
|
do
|
|
@@ -136,6 +136,7 @@ do
|
|
|
136
136
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
137
137
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
138
138
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
139
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
139
140
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
140
141
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
141
142
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -290,7 +291,6 @@ local function dispatch(event, idGetter, argsGetter)
|
|
|
290
291
|
return event[id]
|
|
291
292
|
end
|
|
292
293
|
if not initialized then
|
|
293
|
-
local invoke = Event.invoke
|
|
294
294
|
event:addListener(function(...)
|
|
295
295
|
local id = idGetter(...)
|
|
296
296
|
local dispatched = rawget(self, id)
|
|
@@ -328,7 +328,6 @@ local function dispatchAbility(event)
|
|
|
328
328
|
return event[id]
|
|
329
329
|
end
|
|
330
330
|
if not initialized then
|
|
331
|
-
local invoke = Event.invoke
|
|
332
331
|
event:addListener(function(unit, ability, ...)
|
|
333
332
|
local dispatched = rawget(self, ability.typeId)
|
|
334
333
|
if dispatched ~= nil then
|
|
@@ -345,6 +344,9 @@ local function dispatchAbility(event)
|
|
|
345
344
|
}
|
|
346
345
|
)
|
|
347
346
|
end
|
|
347
|
+
local function damagingEventPreventRetaliation(self)
|
|
348
|
+
self[0] = true
|
|
349
|
+
end
|
|
348
350
|
local function damageEventPreventDeath(self, callback, ...)
|
|
349
351
|
if self[0] ~= nil then
|
|
350
352
|
return
|
|
@@ -356,7 +358,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
356
358
|
rawset(self, 1 + i, (select(i, ...)))
|
|
357
359
|
end
|
|
358
360
|
end
|
|
359
|
-
local damageSetters = {
|
|
361
|
+
local damageSetters = {
|
|
362
|
+
amount = BlzSetEventDamage,
|
|
363
|
+
attackType = function(attackType)
|
|
364
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
365
|
+
end,
|
|
366
|
+
damageType = BlzSetEventDamageType,
|
|
367
|
+
weaponType = BlzSetEventWeaponType
|
|
368
|
+
}
|
|
360
369
|
local jlimitopByOperator = {
|
|
361
370
|
[0] = LESS_THAN_OR_EQUAL,
|
|
362
371
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -400,6 +409,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
|
400
409
|
self.unit = unit
|
|
401
410
|
self.index = index
|
|
402
411
|
end
|
|
412
|
+
__TS__SetDescriptor(
|
|
413
|
+
UnitWeapon.prototype,
|
|
414
|
+
"isEnabled",
|
|
415
|
+
{
|
|
416
|
+
get = function(self)
|
|
417
|
+
return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
|
|
418
|
+
end,
|
|
419
|
+
set = function(self, isEnabled)
|
|
420
|
+
BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
|
|
421
|
+
end
|
|
422
|
+
},
|
|
423
|
+
true
|
|
424
|
+
)
|
|
403
425
|
__TS__SetDescriptor(
|
|
404
426
|
UnitWeapon.prototype,
|
|
405
427
|
"cooldown",
|
|
@@ -434,6 +456,19 @@ __TS__SetDescriptor(
|
|
|
434
456
|
},
|
|
435
457
|
true
|
|
436
458
|
)
|
|
459
|
+
__TS__SetDescriptor(
|
|
460
|
+
UnitWeapon.prototype,
|
|
461
|
+
"allowedTargetCombatClassifications",
|
|
462
|
+
{
|
|
463
|
+
get = function(self)
|
|
464
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
465
|
+
end,
|
|
466
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
467
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
468
|
+
end
|
|
469
|
+
},
|
|
470
|
+
true
|
|
471
|
+
)
|
|
437
472
|
__TS__SetDescriptor(
|
|
438
473
|
UnitWeapon.prototype,
|
|
439
474
|
"damageBase",
|
|
@@ -564,17 +599,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
564
599
|
____exports.Unit:of(unit)
|
|
565
600
|
)
|
|
566
601
|
end
|
|
567
|
-
if not unitAddAbility(unit, abilityId) then
|
|
568
|
-
if getUnitAbility(unit, abilityId) == ability then
|
|
569
|
-
return UnitAbility:of(
|
|
570
|
-
ability,
|
|
571
|
-
abilityId,
|
|
572
|
-
____exports.Unit:of(unit)
|
|
573
|
-
)
|
|
574
|
-
end
|
|
575
|
-
else
|
|
576
|
-
unitRemoveAbility(unit, abilityId)
|
|
577
|
-
end
|
|
578
602
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
579
603
|
local item = unitItemInSlot(unit, i)
|
|
580
604
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -632,15 +656,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
632
656
|
dummies[player] = dummy
|
|
633
657
|
end
|
|
634
658
|
local function delayHealthChecksCallback(unit)
|
|
635
|
-
local counter = (unit[
|
|
659
|
+
local counter = (unit[104] or 0) - 1
|
|
636
660
|
if counter ~= 0 then
|
|
637
|
-
unit[
|
|
661
|
+
unit[104] = counter
|
|
638
662
|
return
|
|
639
663
|
end
|
|
640
|
-
unit[
|
|
641
|
-
local healthBonus = unit[
|
|
664
|
+
unit[104] = nil
|
|
665
|
+
local healthBonus = unit[105]
|
|
642
666
|
if healthBonus ~= nil then
|
|
643
|
-
unit[
|
|
667
|
+
unit[105] = nil
|
|
644
668
|
local handle = unit.handle
|
|
645
669
|
BlzSetUnitMaxHP(
|
|
646
670
|
handle,
|
|
@@ -648,12 +672,27 @@ local function delayHealthChecksCallback(unit)
|
|
|
648
672
|
)
|
|
649
673
|
end
|
|
650
674
|
end
|
|
675
|
+
local nextSyncId = 1
|
|
676
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
677
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
678
|
+
local function addAbility(unit, abilityTypeId)
|
|
679
|
+
local ____unitAddAbility_result_0
|
|
680
|
+
if unitAddAbility(unit, abilityTypeId) then
|
|
681
|
+
____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
|
|
682
|
+
else
|
|
683
|
+
____unitAddAbility_result_0 = nil
|
|
684
|
+
end
|
|
685
|
+
return ____unitAddAbility_result_0
|
|
686
|
+
end
|
|
651
687
|
____exports.Unit = __TS__Class()
|
|
652
688
|
local Unit = ____exports.Unit
|
|
653
689
|
Unit.name = "Unit"
|
|
654
690
|
__TS__ClassExtends(Unit, Handle)
|
|
655
691
|
function Unit.prototype.____constructor(self, handle)
|
|
656
692
|
Handle.prototype.____constructor(self, handle)
|
|
693
|
+
local ____nextSyncId_1 = nextSyncId
|
|
694
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
695
|
+
self.syncId = ____nextSyncId_1
|
|
657
696
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
658
697
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
659
698
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -666,24 +705,29 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
666
705
|
fourCC("Amrf")
|
|
667
706
|
))
|
|
668
707
|
end
|
|
708
|
+
unitBySyncId[self.syncId] = self
|
|
669
709
|
local ____ = self.abilities
|
|
670
710
|
end
|
|
671
|
-
function Unit.prototype.getEvent(self,
|
|
672
|
-
self.events = self.events or (
|
|
673
|
-
local eventId = GetHandleId(
|
|
674
|
-
|
|
675
|
-
|
|
711
|
+
function Unit.prototype.getEvent(self, jevent, collector)
|
|
712
|
+
self.events = self.events or __TS__New(LinkedMap)
|
|
713
|
+
local eventId = GetHandleId(jevent)
|
|
714
|
+
local event = self.events:get(eventId)
|
|
715
|
+
if event == nil then
|
|
716
|
+
event = __TS__New(
|
|
676
717
|
TriggerEvent,
|
|
677
718
|
function(trigger)
|
|
678
|
-
TriggerRegisterUnitEvent(trigger, self.handle,
|
|
719
|
+
TriggerRegisterUnitEvent(trigger, self.handle, jevent)
|
|
679
720
|
end,
|
|
680
721
|
collector or (function() return {} end)
|
|
681
722
|
)
|
|
723
|
+
self.events:put(eventId, event)
|
|
682
724
|
end
|
|
683
|
-
return
|
|
725
|
+
return event
|
|
684
726
|
end
|
|
685
727
|
function Unit.prototype.onDestroy(self)
|
|
686
728
|
local handle = self.handle
|
|
729
|
+
self[108] = getUnitX(handle)
|
|
730
|
+
self[109] = getUnitY(handle)
|
|
687
731
|
if not self._owner then
|
|
688
732
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
689
733
|
end
|
|
@@ -751,17 +795,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
751
795
|
end}
|
|
752
796
|
end
|
|
753
797
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
754
|
-
local
|
|
755
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
798
|
+
local ____combatClassification_2 = combatClassification
|
|
799
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
|
|
756
800
|
end
|
|
757
801
|
function Unit.prototype.addClassification(self, classification)
|
|
758
|
-
return
|
|
802
|
+
return UnitAddType(self.handle, classification)
|
|
759
803
|
end
|
|
760
804
|
function Unit.prototype.removeClassification(self, classification)
|
|
761
|
-
return
|
|
805
|
+
return UnitRemoveType(self.handle, classification)
|
|
762
806
|
end
|
|
763
807
|
function Unit.prototype.hasClassification(self, classification)
|
|
764
|
-
return
|
|
808
|
+
return IsUnitType(self.handle, classification)
|
|
765
809
|
end
|
|
766
810
|
function Unit.prototype.isVisibleTo(self, player)
|
|
767
811
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -770,13 +814,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
770
814
|
return isUnitInvisible(self.handle, player.handle)
|
|
771
815
|
end
|
|
772
816
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
773
|
-
local
|
|
817
|
+
local ____temp_3
|
|
774
818
|
if type(x) == "number" then
|
|
775
|
-
|
|
819
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
776
820
|
else
|
|
777
|
-
|
|
821
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
778
822
|
end
|
|
779
|
-
return
|
|
823
|
+
return ____temp_3
|
|
780
824
|
end
|
|
781
825
|
function Unit.prototype.isAllyOf(self, unit)
|
|
782
826
|
return isUnitAlly(
|
|
@@ -794,16 +838,30 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
794
838
|
if type(animation) == "number" then
|
|
795
839
|
setUnitAnimationByIndex(self.handle, animation)
|
|
796
840
|
elseif rarity then
|
|
797
|
-
|
|
841
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
798
842
|
else
|
|
799
843
|
setUnitAnimation(self.handle, animation)
|
|
800
844
|
end
|
|
801
845
|
end
|
|
846
|
+
function Unit.prototype.resetAnimation(self)
|
|
847
|
+
ResetUnitAnimation(self.handle)
|
|
848
|
+
end
|
|
802
849
|
function Unit.prototype.queueAnimation(self, animation)
|
|
803
|
-
|
|
850
|
+
QueueUnitAnimation(self.handle, animation)
|
|
851
|
+
end
|
|
852
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
853
|
+
local firstWeapon = self.firstWeapon
|
|
854
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
855
|
+
return firstWeapon
|
|
856
|
+
end
|
|
857
|
+
local secondWeapon = self.secondWeapon
|
|
858
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
859
|
+
return secondWeapon
|
|
860
|
+
end
|
|
861
|
+
return nil
|
|
804
862
|
end
|
|
805
863
|
function Unit.prototype.delayHealthChecks(self)
|
|
806
|
-
self[
|
|
864
|
+
self[104] = (self[104] or 0) + 1
|
|
807
865
|
Timer:run(delayHealthChecksCallback, self)
|
|
808
866
|
end
|
|
809
867
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -813,21 +871,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
813
871
|
return IsUnitSelected(self.handle, player.handle)
|
|
814
872
|
end
|
|
815
873
|
function Unit.prototype.explode(self)
|
|
816
|
-
|
|
874
|
+
SetUnitExploded(self.handle, true)
|
|
817
875
|
killUnit(self.handle)
|
|
818
876
|
end
|
|
819
877
|
function Unit.prototype.kill(self)
|
|
820
878
|
killUnit(self.handle)
|
|
821
879
|
end
|
|
822
880
|
function Unit.prototype.revive(self, x, y, doEffect)
|
|
823
|
-
local
|
|
824
|
-
local
|
|
825
|
-
local
|
|
826
|
-
if
|
|
827
|
-
|
|
881
|
+
local ____ReviveHero_6 = ReviveHero
|
|
882
|
+
local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
|
|
883
|
+
local ____doEffect_4 = doEffect
|
|
884
|
+
if ____doEffect_4 == nil then
|
|
885
|
+
____doEffect_4 = false
|
|
828
886
|
end
|
|
829
|
-
__TS__SparseArrayPush(
|
|
830
|
-
|
|
887
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
888
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
831
889
|
end
|
|
832
890
|
function Unit.prototype.healTarget(self, target, amount)
|
|
833
891
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -867,20 +925,19 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
867
925
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
868
926
|
end
|
|
869
927
|
function Unit.prototype.itemInSlot(self, slot)
|
|
870
|
-
return Item:of(
|
|
928
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
871
929
|
end
|
|
872
930
|
function Unit.prototype.addAbility(self, abilityId)
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
931
|
+
local ability = UnitAbility:of(
|
|
932
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
933
|
+
abilityId,
|
|
934
|
+
self
|
|
935
|
+
)
|
|
936
|
+
if ability ~= nil then
|
|
879
937
|
local abilities = self.abilities
|
|
880
938
|
abilities[#abilities + 1] = ability
|
|
881
|
-
return ability
|
|
882
939
|
end
|
|
883
|
-
return
|
|
940
|
+
return ability
|
|
884
941
|
end
|
|
885
942
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
886
943
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -894,31 +951,21 @@ end
|
|
|
894
951
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
895
952
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
896
953
|
end
|
|
897
|
-
function Unit.prototype.
|
|
898
|
-
local
|
|
899
|
-
|
|
900
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
901
|
-
return nil
|
|
902
|
-
end
|
|
903
|
-
return UnitAbility:of(
|
|
904
|
-
getUnitAbility(self.handle, abilityId),
|
|
905
|
-
abilityId,
|
|
906
|
-
self
|
|
907
|
-
)
|
|
954
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
955
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
956
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
908
957
|
end
|
|
909
|
-
function Unit.prototype.removeAbility(self,
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
end
|
|
958
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
959
|
+
local abilities = self.abilities
|
|
960
|
+
for i = 1, #abilities do
|
|
961
|
+
if abilities[i].typeId == abilityTypeId then
|
|
962
|
+
local ability = abilities[i]
|
|
963
|
+
tremove(abilities, i)
|
|
964
|
+
ability:destroy()
|
|
965
|
+
return true
|
|
918
966
|
end
|
|
919
|
-
return true
|
|
920
967
|
end
|
|
921
|
-
return
|
|
968
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
922
969
|
end
|
|
923
970
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
924
971
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -932,12 +979,16 @@ end
|
|
|
932
979
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
933
980
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
934
981
|
end
|
|
935
|
-
function Unit.prototype.interruptAttack(self)
|
|
936
|
-
unitInterruptAttack(self.handle)
|
|
937
|
-
end
|
|
938
982
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
939
|
-
|
|
940
|
-
unitDisableAbility(
|
|
983
|
+
local handle = self.handle
|
|
984
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
985
|
+
Timer:run(
|
|
986
|
+
unitDisableAbility,
|
|
987
|
+
handle,
|
|
988
|
+
abilityId,
|
|
989
|
+
false,
|
|
990
|
+
false
|
|
991
|
+
)
|
|
941
992
|
end
|
|
942
993
|
function Unit.prototype.getDistanceTo(self, target)
|
|
943
994
|
local handle = self.handle
|
|
@@ -997,18 +1048,44 @@ function Unit.prototype.unpauseEx(self)
|
|
|
997
1048
|
self:decrementStunCounter()
|
|
998
1049
|
end
|
|
999
1050
|
function Unit.prototype.incrementStunCounter(self)
|
|
1000
|
-
local stunCounter = self[
|
|
1001
|
-
if not self[
|
|
1051
|
+
local stunCounter = self[102] or 0
|
|
1052
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
|
|
1002
1053
|
BlzPauseUnitEx(self.handle, true)
|
|
1003
1054
|
end
|
|
1004
|
-
self[
|
|
1055
|
+
self[102] = stunCounter + 1
|
|
1005
1056
|
end
|
|
1006
1057
|
function Unit.prototype.decrementStunCounter(self)
|
|
1007
|
-
local stunCounter = self[
|
|
1008
|
-
if not self[
|
|
1058
|
+
local stunCounter = self[102] or 0
|
|
1059
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
|
|
1009
1060
|
BlzPauseUnitEx(self.handle, false)
|
|
1010
1061
|
end
|
|
1011
|
-
self[
|
|
1062
|
+
self[102] = stunCounter - 1
|
|
1063
|
+
end
|
|
1064
|
+
function Unit.prototype.incrementForceStunCounter(self)
|
|
1065
|
+
local forceStunCounter = self[103] or 0
|
|
1066
|
+
if forceStunCounter == 0 then
|
|
1067
|
+
local handle = self.handle
|
|
1068
|
+
if not self[101] then
|
|
1069
|
+
for _ = self[102] or 0, -1 do
|
|
1070
|
+
BlzPauseUnitEx(handle, true)
|
|
1071
|
+
end
|
|
1072
|
+
end
|
|
1073
|
+
BlzPauseUnitEx(handle, true)
|
|
1074
|
+
end
|
|
1075
|
+
self[103] = forceStunCounter + 1
|
|
1076
|
+
end
|
|
1077
|
+
function Unit.prototype.decrementForceStunCounter(self)
|
|
1078
|
+
local forceStunCounter = self[103] or 0
|
|
1079
|
+
if forceStunCounter == 1 then
|
|
1080
|
+
local handle = self.handle
|
|
1081
|
+
if not self[101] then
|
|
1082
|
+
for _ = self[102] or 0, -1 do
|
|
1083
|
+
BlzPauseUnitEx(handle, false)
|
|
1084
|
+
end
|
|
1085
|
+
end
|
|
1086
|
+
BlzPauseUnitEx(handle, false)
|
|
1087
|
+
end
|
|
1088
|
+
self[103] = forceStunCounter - 1
|
|
1012
1089
|
end
|
|
1013
1090
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1014
1091
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -1110,8 +1187,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
1110
1187
|
)
|
|
1111
1188
|
return targetCollection
|
|
1112
1189
|
end
|
|
1113
|
-
function Unit.getSelectionOf(self, player)
|
|
1114
|
-
|
|
1190
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1191
|
+
if target == nil then
|
|
1192
|
+
target = {}
|
|
1193
|
+
end
|
|
1194
|
+
targetCollection = target
|
|
1115
1195
|
targetCollectionNextIndex = 1
|
|
1116
1196
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
1117
1197
|
return targetCollection
|
|
@@ -1133,6 +1213,9 @@ end
|
|
|
1133
1213
|
function Unit.prototype.__tostring(self)
|
|
1134
1214
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
1135
1215
|
end
|
|
1216
|
+
function Unit.getBySyncId(self, syncId)
|
|
1217
|
+
return unitBySyncId[syncId]
|
|
1218
|
+
end
|
|
1136
1219
|
__TS__SetDescriptor(
|
|
1137
1220
|
Unit.prototype,
|
|
1138
1221
|
"_deltas",
|
|
@@ -1192,7 +1275,15 @@ __TS__SetDescriptor(
|
|
|
1192
1275
|
Unit.prototype,
|
|
1193
1276
|
"isIllusion",
|
|
1194
1277
|
{get = function(self)
|
|
1195
|
-
return
|
|
1278
|
+
return IsUnitIllusion(self.handle)
|
|
1279
|
+
end},
|
|
1280
|
+
true
|
|
1281
|
+
)
|
|
1282
|
+
__TS__SetDescriptor(
|
|
1283
|
+
Unit.prototype,
|
|
1284
|
+
"isStunned",
|
|
1285
|
+
{get = function(self)
|
|
1286
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1196
1287
|
end},
|
|
1197
1288
|
true
|
|
1198
1289
|
)
|
|
@@ -1271,13 +1362,13 @@ __TS__SetDescriptor(
|
|
|
1271
1362
|
)
|
|
1272
1363
|
__TS__SetDescriptor(
|
|
1273
1364
|
Unit.prototype,
|
|
1274
|
-
"
|
|
1365
|
+
"primaryAttribute",
|
|
1275
1366
|
{
|
|
1276
1367
|
get = function(self)
|
|
1277
|
-
return
|
|
1368
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1278
1369
|
end,
|
|
1279
|
-
set = function(self,
|
|
1280
|
-
|
|
1370
|
+
set = function(self, primaryAttribute)
|
|
1371
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1281
1372
|
end
|
|
1282
1373
|
},
|
|
1283
1374
|
true
|
|
@@ -1299,19 +1390,6 @@ __TS__SetDescriptor(
|
|
|
1299
1390
|
end},
|
|
1300
1391
|
true
|
|
1301
1392
|
)
|
|
1302
|
-
__TS__SetDescriptor(
|
|
1303
|
-
Unit.prototype,
|
|
1304
|
-
"agilityBase",
|
|
1305
|
-
{
|
|
1306
|
-
get = function(self)
|
|
1307
|
-
return getHeroAgi(self.handle, false)
|
|
1308
|
-
end,
|
|
1309
|
-
set = function(self, agilityBase)
|
|
1310
|
-
setHeroAgi(self.handle, agilityBase, true)
|
|
1311
|
-
end
|
|
1312
|
-
},
|
|
1313
|
-
true
|
|
1314
|
-
)
|
|
1315
1393
|
__TS__SetDescriptor(
|
|
1316
1394
|
Unit.prototype,
|
|
1317
1395
|
"agilityBonus",
|
|
@@ -1329,19 +1407,6 @@ __TS__SetDescriptor(
|
|
|
1329
1407
|
end},
|
|
1330
1408
|
true
|
|
1331
1409
|
)
|
|
1332
|
-
__TS__SetDescriptor(
|
|
1333
|
-
Unit.prototype,
|
|
1334
|
-
"intelligenceBase",
|
|
1335
|
-
{
|
|
1336
|
-
get = function(self)
|
|
1337
|
-
return getHeroInt(self.handle, false)
|
|
1338
|
-
end,
|
|
1339
|
-
set = function(self, intelligenceBase)
|
|
1340
|
-
setHeroInt(self.handle, intelligenceBase, true)
|
|
1341
|
-
end
|
|
1342
|
-
},
|
|
1343
|
-
true
|
|
1344
|
-
)
|
|
1345
1410
|
__TS__SetDescriptor(
|
|
1346
1411
|
Unit.prototype,
|
|
1347
1412
|
"intelligenceBonus",
|
|
@@ -1390,17 +1455,17 @@ __TS__SetDescriptor(
|
|
|
1390
1455
|
"isTeamGlowVisible",
|
|
1391
1456
|
{
|
|
1392
1457
|
get = function(self)
|
|
1393
|
-
return not self[
|
|
1458
|
+
return not self[107]
|
|
1394
1459
|
end,
|
|
1395
1460
|
set = function(self, isTeamGlowVisible)
|
|
1396
|
-
|
|
1397
|
-
local
|
|
1461
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1462
|
+
local ____temp_7
|
|
1398
1463
|
if not isTeamGlowVisible then
|
|
1399
|
-
|
|
1464
|
+
____temp_7 = true
|
|
1400
1465
|
else
|
|
1401
|
-
|
|
1466
|
+
____temp_7 = nil
|
|
1402
1467
|
end
|
|
1403
|
-
self[
|
|
1468
|
+
self[107] = ____temp_7
|
|
1404
1469
|
end
|
|
1405
1470
|
},
|
|
1406
1471
|
true
|
|
@@ -1409,9 +1474,9 @@ __TS__SetDescriptor(
|
|
|
1409
1474
|
Unit.prototype,
|
|
1410
1475
|
"color",
|
|
1411
1476
|
{set = function(self, color)
|
|
1412
|
-
|
|
1413
|
-
if self[
|
|
1414
|
-
|
|
1477
|
+
SetUnitColor(self.handle, color.handle)
|
|
1478
|
+
if self[107] then
|
|
1479
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1415
1480
|
end
|
|
1416
1481
|
end},
|
|
1417
1482
|
true
|
|
@@ -1434,14 +1499,14 @@ __TS__SetDescriptor(
|
|
|
1434
1499
|
"maxHealth",
|
|
1435
1500
|
{
|
|
1436
1501
|
get = function(self)
|
|
1437
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1502
|
+
return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
|
|
1438
1503
|
end,
|
|
1439
1504
|
set = function(self, maxHealth)
|
|
1440
|
-
if maxHealth < 1 and self[
|
|
1441
|
-
self[
|
|
1505
|
+
if maxHealth < 1 and self[104] ~= nil then
|
|
1506
|
+
self[105] = (self[105] or 0) + (1 - maxHealth)
|
|
1442
1507
|
maxHealth = 1
|
|
1443
1508
|
end
|
|
1444
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1509
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
|
|
1445
1510
|
end
|
|
1446
1511
|
},
|
|
1447
1512
|
true
|
|
@@ -1483,10 +1548,10 @@ __TS__SetDescriptor(
|
|
|
1483
1548
|
"health",
|
|
1484
1549
|
{
|
|
1485
1550
|
get = function(self)
|
|
1486
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1551
|
+
return GetWidgetLife(self.handle) - (self[106] or 0)
|
|
1487
1552
|
end,
|
|
1488
1553
|
set = function(self, health)
|
|
1489
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1554
|
+
SetWidgetLife(self.handle, health + (self[106] or 0))
|
|
1490
1555
|
end
|
|
1491
1556
|
},
|
|
1492
1557
|
true
|
|
@@ -1562,25 +1627,12 @@ __TS__SetDescriptor(
|
|
|
1562
1627
|
},
|
|
1563
1628
|
true
|
|
1564
1629
|
)
|
|
1565
|
-
__TS__SetDescriptor(
|
|
1566
|
-
Unit.prototype,
|
|
1567
|
-
"flyHeight",
|
|
1568
|
-
{
|
|
1569
|
-
get = function(self)
|
|
1570
|
-
return getUnitFlyHeight(self.handle)
|
|
1571
|
-
end,
|
|
1572
|
-
set = function(self, v)
|
|
1573
|
-
SetUnitFlyHeight(self.handle, v, 100000)
|
|
1574
|
-
end
|
|
1575
|
-
},
|
|
1576
|
-
true
|
|
1577
|
-
)
|
|
1578
1630
|
__TS__SetDescriptor(
|
|
1579
1631
|
Unit.prototype,
|
|
1580
1632
|
"x",
|
|
1581
1633
|
{
|
|
1582
1634
|
get = function(self)
|
|
1583
|
-
return getUnitX(self.handle)
|
|
1635
|
+
return self[108] or getUnitX(self.handle)
|
|
1584
1636
|
end,
|
|
1585
1637
|
set = function(self, v)
|
|
1586
1638
|
SetUnitX(self.handle, v)
|
|
@@ -1593,7 +1645,7 @@ __TS__SetDescriptor(
|
|
|
1593
1645
|
"y",
|
|
1594
1646
|
{
|
|
1595
1647
|
get = function(self)
|
|
1596
|
-
return getUnitY(self.handle)
|
|
1648
|
+
return self[109] or getUnitY(self.handle)
|
|
1597
1649
|
end,
|
|
1598
1650
|
set = function(self, v)
|
|
1599
1651
|
SetUnitY(self.handle, v)
|
|
@@ -1679,10 +1731,10 @@ __TS__SetDescriptor(
|
|
|
1679
1731
|
"gold",
|
|
1680
1732
|
{
|
|
1681
1733
|
get = function(self)
|
|
1682
|
-
return
|
|
1734
|
+
return GetResourceAmount(self.handle)
|
|
1683
1735
|
end,
|
|
1684
1736
|
set = function(self, gold)
|
|
1685
|
-
|
|
1737
|
+
SetResourceAmount(self.handle, gold)
|
|
1686
1738
|
end
|
|
1687
1739
|
},
|
|
1688
1740
|
true
|
|
@@ -1697,17 +1749,21 @@ __TS__SetDescriptor(
|
|
|
1697
1749
|
set = function(self, isPaused)
|
|
1698
1750
|
local handle = self.handle
|
|
1699
1751
|
if isPaused and not IsUnitPaused(handle) then
|
|
1700
|
-
self[
|
|
1701
|
-
|
|
1702
|
-
|
|
1752
|
+
self[101] = true
|
|
1753
|
+
if (self[103] or 0) <= 0 then
|
|
1754
|
+
for _ = self[102] or 0, -1 do
|
|
1755
|
+
BlzPauseUnitEx(handle, true)
|
|
1756
|
+
end
|
|
1703
1757
|
end
|
|
1704
1758
|
PauseUnit(handle, true)
|
|
1705
1759
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1706
1760
|
PauseUnit(handle, false)
|
|
1707
|
-
|
|
1708
|
-
|
|
1761
|
+
if (self[103] or 0) <= 0 then
|
|
1762
|
+
for _ = self[102] or 0, -1 do
|
|
1763
|
+
BlzPauseUnitEx(handle, false)
|
|
1764
|
+
end
|
|
1709
1765
|
end
|
|
1710
|
-
self[
|
|
1766
|
+
self[101] = nil
|
|
1711
1767
|
end
|
|
1712
1768
|
end
|
|
1713
1769
|
},
|
|
@@ -1763,20 +1819,6 @@ __TS__SetDescriptor(
|
|
|
1763
1819
|
},
|
|
1764
1820
|
true
|
|
1765
1821
|
)
|
|
1766
|
-
__TS__SetDescriptor(
|
|
1767
|
-
Unit.prototype,
|
|
1768
|
-
"scale",
|
|
1769
|
-
{
|
|
1770
|
-
get = function(self)
|
|
1771
|
-
return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
|
|
1772
|
-
end,
|
|
1773
|
-
set = function(self, v)
|
|
1774
|
-
setUnitScale(self.handle, v, v, v)
|
|
1775
|
-
setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
|
|
1776
|
-
end
|
|
1777
|
-
},
|
|
1778
|
-
true
|
|
1779
|
-
)
|
|
1780
1822
|
__TS__SetDescriptor(
|
|
1781
1823
|
Unit.prototype,
|
|
1782
1824
|
"timeScale",
|
|
@@ -1810,6 +1852,19 @@ __TS__SetDescriptor(
|
|
|
1810
1852
|
end},
|
|
1811
1853
|
true
|
|
1812
1854
|
)
|
|
1855
|
+
__TS__SetDescriptor(
|
|
1856
|
+
Unit.prototype,
|
|
1857
|
+
"movementType",
|
|
1858
|
+
{
|
|
1859
|
+
get = function(self)
|
|
1860
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1861
|
+
end,
|
|
1862
|
+
set = function(self, movementType)
|
|
1863
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1864
|
+
end
|
|
1865
|
+
},
|
|
1866
|
+
true
|
|
1867
|
+
)
|
|
1813
1868
|
__TS__SetDescriptor(
|
|
1814
1869
|
Unit.prototype,
|
|
1815
1870
|
"pathing",
|
|
@@ -1991,6 +2046,14 @@ __TS__SetDescriptor(
|
|
|
1991
2046
|
end},
|
|
1992
2047
|
true
|
|
1993
2048
|
)
|
|
2049
|
+
__TS__SetDescriptor(
|
|
2050
|
+
Unit.prototype,
|
|
2051
|
+
"targetAcquiredEvent",
|
|
2052
|
+
{get = function(self)
|
|
2053
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2054
|
+
end},
|
|
2055
|
+
true
|
|
2056
|
+
)
|
|
1994
2057
|
__TS__SetDescriptor(
|
|
1995
2058
|
Unit.prototype,
|
|
1996
2059
|
"onSelect",
|
|
@@ -2051,6 +2114,11 @@ __TS__SetDescriptor(
|
|
|
2051
2114
|
end},
|
|
2052
2115
|
true
|
|
2053
2116
|
)
|
|
2117
|
+
Unit.levelChangedEvent = __TS__New(
|
|
2118
|
+
____exports.UnitTriggerEvent,
|
|
2119
|
+
EVENT_PLAYER_HERO_LEVEL,
|
|
2120
|
+
function() return ____exports.Unit:of(getTriggerUnit()) end
|
|
2121
|
+
)
|
|
2054
2122
|
Unit.deathEvent = __TS__New(
|
|
2055
2123
|
____exports.UnitTriggerEvent,
|
|
2056
2124
|
EVENT_PLAYER_UNIT_DEATH,
|
|
@@ -2064,7 +2132,6 @@ Unit.onDecay = __TS__New(
|
|
|
2064
2132
|
Unit.onResurrect = __TS__New(
|
|
2065
2133
|
InitializingEvent,
|
|
2066
2134
|
function(event)
|
|
2067
|
-
local invoke = Event.invoke
|
|
2068
2135
|
local dead = setmetatable({}, {__mode = "k"})
|
|
2069
2136
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
2070
2137
|
dead[unit] = true
|
|
@@ -2080,11 +2147,15 @@ Unit.onResurrect = __TS__New(
|
|
|
2080
2147
|
Unit.morphEvent = __TS__New(
|
|
2081
2148
|
InitializingEvent,
|
|
2082
2149
|
function(event)
|
|
2083
|
-
|
|
2150
|
+
local function ifNotLeft(unit)
|
|
2084
2151
|
local handle = unit.handle
|
|
2085
|
-
if getUnitAbilityLevel(handle,
|
|
2086
|
-
|
|
2087
|
-
|
|
2152
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2153
|
+
invoke(event, unit)
|
|
2154
|
+
end
|
|
2155
|
+
end
|
|
2156
|
+
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
2157
|
+
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
2158
|
+
Timer:run(ifNotLeft, unit)
|
|
2088
2159
|
end
|
|
2089
2160
|
end)
|
|
2090
2161
|
end
|
|
@@ -2122,27 +2193,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
2122
2193
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
2123
2194
|
InitializingEvent,
|
|
2124
2195
|
function(event)
|
|
2125
|
-
local invoke = Event.invoke
|
|
2126
2196
|
local function listener(unit, id)
|
|
2127
|
-
local
|
|
2197
|
+
local ____GetSpellTargetUnit_result_10
|
|
2128
2198
|
if GetSpellTargetUnit() then
|
|
2129
|
-
|
|
2199
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2130
2200
|
else
|
|
2131
|
-
local
|
|
2201
|
+
local ____GetSpellTargetItem_result_9
|
|
2132
2202
|
if GetSpellTargetItem() then
|
|
2133
|
-
|
|
2203
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2134
2204
|
else
|
|
2135
|
-
local
|
|
2205
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2136
2206
|
if GetSpellTargetDestructable() then
|
|
2137
|
-
|
|
2207
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2138
2208
|
else
|
|
2139
|
-
|
|
2209
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2140
2210
|
end
|
|
2141
|
-
|
|
2211
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2142
2212
|
end
|
|
2143
|
-
|
|
2213
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2144
2214
|
end
|
|
2145
|
-
local target =
|
|
2215
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2146
2216
|
if target then
|
|
2147
2217
|
invoke(event, unit, id, target)
|
|
2148
2218
|
end
|
|
@@ -2314,10 +2384,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2314
2384
|
____exports.UnitTriggerEvent,
|
|
2315
2385
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2316
2386
|
function()
|
|
2317
|
-
local
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2387
|
+
local handle = getOrderedUnit()
|
|
2388
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2389
|
+
local unit = ____exports.Unit:of(handle)
|
|
2390
|
+
if unit.state == 1 then
|
|
2391
|
+
return unit, getIssuedOrderId()
|
|
2392
|
+
end
|
|
2321
2393
|
end
|
|
2322
2394
|
return IgnoreEvent
|
|
2323
2395
|
end
|
|
@@ -2339,7 +2411,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2339
2411
|
)
|
|
2340
2412
|
Unit.onDamaging = (function()
|
|
2341
2413
|
local event = __TS__New(Event)
|
|
2342
|
-
local invoke = Event.invoke
|
|
2343
2414
|
local trigger = CreateTrigger()
|
|
2344
2415
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2345
2416
|
TriggerAddCondition(
|
|
@@ -2349,38 +2420,57 @@ Unit.onDamaging = (function()
|
|
|
2349
2420
|
if source and source.typeId == dummyUnitId then
|
|
2350
2421
|
source = nil
|
|
2351
2422
|
end
|
|
2352
|
-
local target = BlzGetEventDamageTarget()
|
|
2423
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2424
|
+
local metadata = damageMetadataByTarget[target]
|
|
2425
|
+
damageMetadataByTarget[target] = nil
|
|
2353
2426
|
local data = {
|
|
2354
2427
|
amount = GetEventDamage(),
|
|
2355
|
-
attackType = BlzGetEventAttackType(),
|
|
2428
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2356
2429
|
damageType = BlzGetEventDamageType(),
|
|
2357
2430
|
weaponType = BlzGetEventWeaponType(),
|
|
2358
|
-
|
|
2431
|
+
metadata = metadata,
|
|
2432
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2433
|
+
originalAmount = GetEventDamage(),
|
|
2434
|
+
originalMetadata = metadata,
|
|
2435
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2359
2436
|
}
|
|
2360
2437
|
if data.isAttack and source then
|
|
2361
|
-
|
|
2362
|
-
if weapon == -1 then
|
|
2363
|
-
local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
|
|
2364
|
-
weapon = 0
|
|
2365
|
-
end
|
|
2366
|
-
data.weapon = assert(source.weapons[weapon + 1])
|
|
2438
|
+
data.weapon = source:chooseWeapon(target)
|
|
2367
2439
|
end
|
|
2368
2440
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2369
2441
|
invoke(
|
|
2370
2442
|
event,
|
|
2371
2443
|
source,
|
|
2372
|
-
|
|
2444
|
+
target,
|
|
2373
2445
|
setmetatable(
|
|
2374
2446
|
{},
|
|
2375
2447
|
{
|
|
2376
2448
|
__index = data,
|
|
2377
2449
|
__newindex = function(self, key, value)
|
|
2378
|
-
damageSetters[key]
|
|
2450
|
+
local damageSetter = damageSetters[key]
|
|
2451
|
+
if damageSetter ~= nil then
|
|
2452
|
+
damageSetter(value)
|
|
2453
|
+
end
|
|
2379
2454
|
data[key] = value
|
|
2380
2455
|
end
|
|
2381
2456
|
}
|
|
2382
2457
|
)
|
|
2383
2458
|
)
|
|
2459
|
+
if data[0] and source then
|
|
2460
|
+
local sourceOwner = source.owner.handle
|
|
2461
|
+
data[1] = sourceOwner
|
|
2462
|
+
local targetOwner = target.owner.handle
|
|
2463
|
+
data[2] = targetOwner
|
|
2464
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2465
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2466
|
+
data[3] = true
|
|
2467
|
+
end
|
|
2468
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2469
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2470
|
+
data[4] = true
|
|
2471
|
+
end
|
|
2472
|
+
end
|
|
2473
|
+
damagingEventByTarget[target] = data
|
|
2384
2474
|
return
|
|
2385
2475
|
end
|
|
2386
2476
|
BlzSetEventDamage(0)
|
|
@@ -2388,7 +2478,7 @@ Unit.onDamaging = (function()
|
|
|
2388
2478
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2389
2479
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2390
2480
|
local sourceOwner = source.owner.handle
|
|
2391
|
-
local targetOwner =
|
|
2481
|
+
local targetOwner = target.owner.handle
|
|
2392
2482
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2393
2483
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2394
2484
|
Timer:run(function()
|
|
@@ -2404,23 +2494,19 @@ Unit.onDamaging = (function()
|
|
|
2404
2494
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2405
2495
|
local condition = ____value[1]
|
|
2406
2496
|
local action = ____value[2]
|
|
2407
|
-
if condition(
|
|
2408
|
-
source,
|
|
2409
|
-
____exports.Unit:of(target),
|
|
2410
|
-
data
|
|
2411
|
-
) then
|
|
2497
|
+
if condition(source, target, data) then
|
|
2412
2498
|
action(
|
|
2413
2499
|
source,
|
|
2414
|
-
|
|
2500
|
+
target,
|
|
2415
2501
|
setmetatable(
|
|
2416
2502
|
{fire = function()
|
|
2417
2503
|
UnitDamageTarget(
|
|
2418
2504
|
source.handle,
|
|
2419
|
-
target,
|
|
2505
|
+
target.handle,
|
|
2420
2506
|
data.amount,
|
|
2421
2507
|
true,
|
|
2422
2508
|
true,
|
|
2423
|
-
data.attackType,
|
|
2509
|
+
attackTypeToNative(data.attackType),
|
|
2424
2510
|
data.damageType,
|
|
2425
2511
|
data.weaponType
|
|
2426
2512
|
)
|
|
@@ -2438,7 +2524,6 @@ end)()
|
|
|
2438
2524
|
Unit.onDamage = __TS__New(
|
|
2439
2525
|
InitializingEvent,
|
|
2440
2526
|
function(event)
|
|
2441
|
-
local invoke = Event.invoke
|
|
2442
2527
|
local trigger = CreateTrigger()
|
|
2443
2528
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2444
2529
|
TriggerAddCondition(
|
|
@@ -2448,29 +2533,54 @@ Unit.onDamage = __TS__New(
|
|
|
2448
2533
|
if source and source.typeId == dummyUnitId then
|
|
2449
2534
|
source = nil
|
|
2450
2535
|
end
|
|
2536
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2537
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2538
|
+
damagingEventByTarget[target] = nil
|
|
2451
2539
|
local data = {
|
|
2452
2540
|
amount = GetEventDamage(),
|
|
2453
|
-
attackType = BlzGetEventAttackType(),
|
|
2541
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2454
2542
|
damageType = BlzGetEventDamageType(),
|
|
2455
2543
|
weaponType = BlzGetEventWeaponType(),
|
|
2544
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2456
2545
|
isAttack = BlzGetEventIsAttack(),
|
|
2546
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2547
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2457
2548
|
preventDeath = damageEventPreventDeath
|
|
2458
2549
|
}
|
|
2550
|
+
if damagingEvent then
|
|
2551
|
+
for key, value in pairs(damagingEvent) do
|
|
2552
|
+
if isAttribute(key) then
|
|
2553
|
+
data[key] = value
|
|
2554
|
+
end
|
|
2555
|
+
end
|
|
2556
|
+
local sourceOwner = damagingEvent[1]
|
|
2557
|
+
if sourceOwner then
|
|
2558
|
+
local targetOwner = damagingEvent[2]
|
|
2559
|
+
if damagingEvent[3] then
|
|
2560
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2561
|
+
end
|
|
2562
|
+
if damagingEvent[4] then
|
|
2563
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2564
|
+
end
|
|
2565
|
+
end
|
|
2566
|
+
end
|
|
2459
2567
|
local evData = setmetatable(
|
|
2460
2568
|
{},
|
|
2461
2569
|
{
|
|
2462
2570
|
__index = data,
|
|
2463
2571
|
__newindex = function(self, key, value)
|
|
2464
|
-
damageSetters[key]
|
|
2572
|
+
local damageSetter = damageSetters[key]
|
|
2573
|
+
if damageSetter ~= nil then
|
|
2574
|
+
damageSetter(value)
|
|
2575
|
+
end
|
|
2465
2576
|
data[key] = value
|
|
2466
2577
|
end
|
|
2467
2578
|
}
|
|
2468
2579
|
)
|
|
2469
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2470
2580
|
invoke(event, source, target, evData)
|
|
2471
2581
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2472
2582
|
local bonusHealth = math.ceil(evData.amount)
|
|
2473
|
-
target[
|
|
2583
|
+
target[106] = (target[106] or 0) + bonusHealth
|
|
2474
2584
|
BlzSetUnitMaxHP(
|
|
2475
2585
|
target.handle,
|
|
2476
2586
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2484,7 +2594,7 @@ Unit.onDamage = __TS__New(
|
|
|
2484
2594
|
evData[0],
|
|
2485
2595
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2486
2596
|
)
|
|
2487
|
-
target[
|
|
2597
|
+
target[106] = (target[106] or 0) - bonusHealth
|
|
2488
2598
|
SetWidgetLife(
|
|
2489
2599
|
target.handle,
|
|
2490
2600
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2504,32 +2614,110 @@ Unit.onDamage = __TS__New(
|
|
|
2504
2614
|
DestroyTrigger(trigger)
|
|
2505
2615
|
end
|
|
2506
2616
|
)
|
|
2507
|
-
Unit.
|
|
2617
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2508
2618
|
____exports.UnitTriggerEvent,
|
|
2509
2619
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2510
2620
|
function()
|
|
2511
2621
|
local unit = getTriggerUnit()
|
|
2512
|
-
|
|
2513
|
-
|
|
2622
|
+
local item = getManipulatedItem()
|
|
2623
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2624
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2514
2625
|
end
|
|
2515
2626
|
return IgnoreEvent
|
|
2516
2627
|
end
|
|
2517
2628
|
)
|
|
2518
|
-
Unit.
|
|
2629
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2519
2630
|
____exports.UnitTriggerEvent,
|
|
2520
2631
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2521
2632
|
function()
|
|
2522
|
-
local
|
|
2523
|
-
|
|
2524
|
-
|
|
2633
|
+
local unitHandle = getTriggerUnit()
|
|
2634
|
+
local itemHandle = getManipulatedItem()
|
|
2635
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2636
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2637
|
+
local item = Item:of(itemHandle)
|
|
2638
|
+
if item.owner ~= unit then
|
|
2639
|
+
return unit, item
|
|
2640
|
+
end
|
|
2525
2641
|
end
|
|
2526
2642
|
return IgnoreEvent
|
|
2527
2643
|
end
|
|
2528
2644
|
)
|
|
2529
|
-
Unit.
|
|
2645
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2530
2646
|
____exports.UnitTriggerEvent,
|
|
2531
2647
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2532
|
-
function()
|
|
2648
|
+
function()
|
|
2649
|
+
local unit = getTriggerUnit()
|
|
2650
|
+
local item = getManipulatedItem()
|
|
2651
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2652
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2653
|
+
end
|
|
2654
|
+
return IgnoreEvent
|
|
2655
|
+
end
|
|
2656
|
+
)
|
|
2657
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2658
|
+
____exports.UnitTriggerEvent,
|
|
2659
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2660
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2661
|
+
)
|
|
2662
|
+
__TS__ObjectDefineProperty(
|
|
2663
|
+
Unit,
|
|
2664
|
+
"itemChargesChangedEvent",
|
|
2665
|
+
{get = function(self)
|
|
2666
|
+
local event = __TS__New(Event)
|
|
2667
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2668
|
+
local unit = item.owner
|
|
2669
|
+
if unit ~= nil then
|
|
2670
|
+
invoke(event, unit, item)
|
|
2671
|
+
end
|
|
2672
|
+
end)
|
|
2673
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2674
|
+
return event
|
|
2675
|
+
end}
|
|
2676
|
+
)
|
|
2677
|
+
__TS__ObjectDefineProperty(
|
|
2678
|
+
Unit,
|
|
2679
|
+
"itemUseOrderEvent",
|
|
2680
|
+
{get = function(self)
|
|
2681
|
+
local event = __TS__New(Event)
|
|
2682
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2683
|
+
local slot = order - orderId("useslot0")
|
|
2684
|
+
local function listener(unit)
|
|
2685
|
+
local item = unit.items[slot + 1]
|
|
2686
|
+
if item ~= nil then
|
|
2687
|
+
invoke(event, unit, item)
|
|
2688
|
+
end
|
|
2689
|
+
end
|
|
2690
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2691
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2692
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2693
|
+
end
|
|
2694
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2695
|
+
return event
|
|
2696
|
+
end}
|
|
2697
|
+
)
|
|
2698
|
+
__TS__ObjectDefineProperty(
|
|
2699
|
+
Unit,
|
|
2700
|
+
"itemMoveOrderEvent",
|
|
2701
|
+
{get = function(self)
|
|
2702
|
+
local event = __TS__New(Event)
|
|
2703
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2704
|
+
local slotTo = order - orderId("moveslot0")
|
|
2705
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2706
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2707
|
+
if slotFrom ~= nil then
|
|
2708
|
+
invoke(
|
|
2709
|
+
event,
|
|
2710
|
+
unit,
|
|
2711
|
+
item,
|
|
2712
|
+
slotFrom,
|
|
2713
|
+
slotTo
|
|
2714
|
+
)
|
|
2715
|
+
end
|
|
2716
|
+
end)
|
|
2717
|
+
end
|
|
2718
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2719
|
+
return event
|
|
2720
|
+
end}
|
|
2533
2721
|
)
|
|
2534
2722
|
__TS__ObjectDefineProperty(
|
|
2535
2723
|
Unit,
|
|
@@ -2556,6 +2744,10 @@ __TS__ObjectDefineProperty(
|
|
|
2556
2744
|
rawset(self, "destroyEvent", destroyEvent)
|
|
2557
2745
|
return destroyEvent
|
|
2558
2746
|
end}
|
|
2747
|
+
)
|
|
2748
|
+
Unit.synchronize = synchronizer(
|
|
2749
|
+
function(unit) return unit.syncId end,
|
|
2750
|
+
function(syncId) return unitBySyncId[syncId] end
|
|
2559
2751
|
);
|
|
2560
2752
|
(function(self)
|
|
2561
2753
|
local leaveAbilityIds = postcompile(function()
|