warscript 0.0.1-dev.8fe1307 → 0.0.1-dev.90da649
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 +11 -5
- package/engine/behaviour/unit/stun-immunity.lua +53 -28
- package/engine/behaviour/unit.d.ts +45 -2
- package/engine/behaviour/unit.lua +279 -6
- package/engine/buff.d.ts +115 -42
- package/engine/buff.lua +533 -215
- package/engine/game-map.d.ts +7 -0
- package/engine/game-map.lua +32 -0
- package/engine/internal/ability.d.ts +23 -14
- package/engine/internal/ability.lua +129 -85
- package/engine/internal/item/ability.lua +162 -4
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +20 -19
- package/engine/internal/item.lua +191 -74
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
- package/engine/internal/misc/ability-disable-counter.lua +13 -0
- package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
- package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
- package/engine/internal/misc/frame-coordinates.d.ts +2 -0
- package/engine/internal/misc/frame-coordinates.lua +21 -0
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/misc/player-local-handle.d.ts +2 -0
- package/engine/internal/misc/player-local-handle.lua +5 -0
- package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
- package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
- package/engine/internal/object-data/evasion-probability.d.ts +2 -0
- package/engine/internal/object-data/evasion-probability.lua +16 -0
- package/engine/internal/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/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/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 +63 -13
- package/engine/internal/unit.d.ts +65 -23
- package/engine/internal/unit.lua +462 -202
- 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 +6 -0
- package/engine/unit.lua +6 -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 +3 -4
- 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-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/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
|
@@ -7,6 +7,9 @@ local __TS__Class = ____lualib.__TS__Class
|
|
|
7
7
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
8
8
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
9
9
|
local __TS__ArraySetLength = ____lualib.__TS__ArraySetLength
|
|
10
|
+
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
|
|
11
|
+
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
|
|
12
|
+
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
|
|
10
13
|
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
11
14
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
12
15
|
local Set = ____lualib.Set
|
|
@@ -48,33 +51,44 @@ local ____arrays = require("utility.arrays")
|
|
|
48
51
|
local forEach = ____arrays.forEach
|
|
49
52
|
local ____math = require("math")
|
|
50
53
|
local min = ____math.min
|
|
54
|
+
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
55
|
+
local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
56
|
+
local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
|
|
57
|
+
local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
|
|
58
|
+
local nativeToAttackType = ____attack_2Dtype.nativeToAttackType
|
|
59
|
+
local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
|
|
60
|
+
local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
|
|
61
|
+
local ____attributes = require("attributes")
|
|
62
|
+
local isAttribute = ____attributes.isAttribute
|
|
63
|
+
local ____ability = require("engine.internal.item.ability")
|
|
64
|
+
local doUnitAbilityAction = ____ability.doUnitAbilityAction
|
|
65
|
+
local ____synchronization = require("engine.synchronization")
|
|
66
|
+
local synchronizer = ____synchronization.synchronizer
|
|
67
|
+
local ____unit = require("engine.standard.fields.unit")
|
|
68
|
+
local AGILITY_UNIT_FIELD = ____unit.AGILITY_UNIT_FIELD
|
|
69
|
+
local INTELLIGENCE_UNIT_FIELD = ____unit.INTELLIGENCE_UNIT_FIELD
|
|
70
|
+
local STRENGTH_UNIT_FIELD = ____unit.STRENGTH_UNIT_FIELD
|
|
51
71
|
local match = string.match
|
|
52
72
|
local ____tostring = _G.tostring
|
|
53
73
|
local setUnitAnimation = SetUnitAnimation
|
|
54
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
55
74
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
56
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
57
75
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
58
76
|
local getUnitRealField = BlzGetUnitRealField
|
|
59
77
|
local getHeroStr = GetHeroStr
|
|
60
78
|
local getHeroAgi = GetHeroAgi
|
|
61
79
|
local getHeroInt = GetHeroInt
|
|
62
|
-
local setHeroStr = SetHeroStr
|
|
63
|
-
local setHeroAgi = SetHeroAgi
|
|
64
|
-
local setHeroInt = SetHeroInt
|
|
65
80
|
local getUnitBooleanField = BlzGetUnitBooleanField
|
|
66
81
|
local getUnitStringField = BlzGetUnitStringField
|
|
67
82
|
local setUnitIntegerField = BlzSetUnitIntegerField
|
|
68
83
|
local setUnitRealField = BlzSetUnitRealField
|
|
69
84
|
local setUnitBooleanField = BlzSetUnitBooleanField
|
|
70
85
|
local setUnitStringField = BlzSetUnitStringField
|
|
71
|
-
local setUnitScale = SetUnitScale
|
|
72
86
|
local setUnitPosition = SetUnitPosition
|
|
73
87
|
local setUnitTimeScale = SetUnitTimeScale
|
|
74
88
|
local getHandleId = GetHandleId
|
|
89
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
75
90
|
local createUnit = CreateUnit
|
|
76
91
|
local killUnit = KillUnit
|
|
77
|
-
local setUnitExploded = SetUnitExploded
|
|
78
92
|
local removeUnit = RemoveUnit
|
|
79
93
|
local getUnitTypeId = GetUnitTypeId
|
|
80
94
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -90,8 +104,6 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
90
104
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
91
105
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
92
106
|
local isUnitInRange = IsUnitInRange
|
|
93
|
-
local setResourceAmount = SetResourceAmount
|
|
94
|
-
local getResourceAmount = GetResourceAmount
|
|
95
107
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
96
108
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
97
109
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
@@ -115,15 +127,9 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
115
127
|
local getIssuedOrderId = GetIssuedOrderId
|
|
116
128
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
117
129
|
local unitAlive = UnitAlive
|
|
118
|
-
local unitAddType = UnitAddType
|
|
119
|
-
local unitRemoveType = UnitRemoveType
|
|
120
|
-
local isUnitIllusion = IsUnitIllusion
|
|
121
|
-
local isUnitType = IsUnitType
|
|
122
130
|
local isUnitAlly = IsUnitAlly
|
|
123
131
|
local isUnitEnemy = IsUnitEnemy
|
|
124
132
|
local getOwningPlayer = GetOwningPlayer
|
|
125
|
-
local setUnitColor = SetUnitColor
|
|
126
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
127
133
|
____exports.UnitClassification = {}
|
|
128
134
|
local UnitClassification = ____exports.UnitClassification
|
|
129
135
|
do
|
|
@@ -133,6 +139,7 @@ do
|
|
|
133
139
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
134
140
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
135
141
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
142
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
136
143
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
137
144
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
138
145
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -279,16 +286,14 @@ function UnitTriggerEvent.prototype.____constructor(self, eventType, c)
|
|
|
279
286
|
end
|
|
280
287
|
local function dispatch(event, idGetter, argsGetter)
|
|
281
288
|
local initialized = false
|
|
282
|
-
local x = {}
|
|
283
289
|
return setmetatable(
|
|
284
|
-
|
|
290
|
+
{},
|
|
285
291
|
{
|
|
286
292
|
__index = function(self, id)
|
|
287
293
|
if type(id) ~= "number" then
|
|
288
294
|
return event[id]
|
|
289
295
|
end
|
|
290
296
|
if not initialized then
|
|
291
|
-
local invoke = Event.invoke
|
|
292
297
|
event:addListener(function(...)
|
|
293
298
|
local id = idGetter(...)
|
|
294
299
|
local dispatched = rawget(self, id)
|
|
@@ -326,7 +331,6 @@ local function dispatchAbility(event)
|
|
|
326
331
|
return event[id]
|
|
327
332
|
end
|
|
328
333
|
if not initialized then
|
|
329
|
-
local invoke = Event.invoke
|
|
330
334
|
event:addListener(function(unit, ability, ...)
|
|
331
335
|
local dispatched = rawget(self, ability.typeId)
|
|
332
336
|
if dispatched ~= nil then
|
|
@@ -343,6 +347,9 @@ local function dispatchAbility(event)
|
|
|
343
347
|
}
|
|
344
348
|
)
|
|
345
349
|
end
|
|
350
|
+
local function damagingEventPreventRetaliation(self)
|
|
351
|
+
self[0] = true
|
|
352
|
+
end
|
|
346
353
|
local function damageEventPreventDeath(self, callback, ...)
|
|
347
354
|
if self[0] ~= nil then
|
|
348
355
|
return
|
|
@@ -354,7 +361,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
354
361
|
rawset(self, 1 + i, (select(i, ...)))
|
|
355
362
|
end
|
|
356
363
|
end
|
|
357
|
-
local damageSetters = {
|
|
364
|
+
local damageSetters = {
|
|
365
|
+
amount = BlzSetEventDamage,
|
|
366
|
+
attackType = function(attackType)
|
|
367
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
368
|
+
end,
|
|
369
|
+
damageType = BlzSetEventDamageType,
|
|
370
|
+
weaponType = BlzSetEventWeaponType
|
|
371
|
+
}
|
|
358
372
|
local jlimitopByOperator = {
|
|
359
373
|
[0] = LESS_THAN_OR_EQUAL,
|
|
360
374
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -398,6 +412,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
|
398
412
|
self.unit = unit
|
|
399
413
|
self.index = index
|
|
400
414
|
end
|
|
415
|
+
__TS__SetDescriptor(
|
|
416
|
+
UnitWeapon.prototype,
|
|
417
|
+
"isEnabled",
|
|
418
|
+
{
|
|
419
|
+
get = function(self)
|
|
420
|
+
return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
|
|
421
|
+
end,
|
|
422
|
+
set = function(self, isEnabled)
|
|
423
|
+
BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
|
|
424
|
+
end
|
|
425
|
+
},
|
|
426
|
+
true
|
|
427
|
+
)
|
|
401
428
|
__TS__SetDescriptor(
|
|
402
429
|
UnitWeapon.prototype,
|
|
403
430
|
"cooldown",
|
|
@@ -432,6 +459,19 @@ __TS__SetDescriptor(
|
|
|
432
459
|
},
|
|
433
460
|
true
|
|
434
461
|
)
|
|
462
|
+
__TS__SetDescriptor(
|
|
463
|
+
UnitWeapon.prototype,
|
|
464
|
+
"allowedTargetCombatClassifications",
|
|
465
|
+
{
|
|
466
|
+
get = function(self)
|
|
467
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
468
|
+
end,
|
|
469
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
470
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
471
|
+
end
|
|
472
|
+
},
|
|
473
|
+
true
|
|
474
|
+
)
|
|
435
475
|
__TS__SetDescriptor(
|
|
436
476
|
UnitWeapon.prototype,
|
|
437
477
|
"damageBase",
|
|
@@ -562,17 +602,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
562
602
|
____exports.Unit:of(unit)
|
|
563
603
|
)
|
|
564
604
|
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
605
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
577
606
|
local item = unitItemInSlot(unit, i)
|
|
578
607
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -630,15 +659,15 @@ for ____, player in ipairs(Player.all) do
|
|
|
630
659
|
dummies[player] = dummy
|
|
631
660
|
end
|
|
632
661
|
local function delayHealthChecksCallback(unit)
|
|
633
|
-
local counter = (unit[
|
|
662
|
+
local counter = (unit[104] or 0) - 1
|
|
634
663
|
if counter ~= 0 then
|
|
635
|
-
unit[
|
|
664
|
+
unit[104] = counter
|
|
636
665
|
return
|
|
637
666
|
end
|
|
638
|
-
unit[
|
|
639
|
-
local healthBonus = unit[
|
|
667
|
+
unit[104] = nil
|
|
668
|
+
local healthBonus = unit[105]
|
|
640
669
|
if healthBonus ~= nil then
|
|
641
|
-
unit[
|
|
670
|
+
unit[105] = nil
|
|
642
671
|
local handle = unit.handle
|
|
643
672
|
BlzSetUnitMaxHP(
|
|
644
673
|
handle,
|
|
@@ -646,12 +675,27 @@ local function delayHealthChecksCallback(unit)
|
|
|
646
675
|
)
|
|
647
676
|
end
|
|
648
677
|
end
|
|
678
|
+
local nextSyncId = 1
|
|
679
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
680
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
681
|
+
local function addAbility(unit, abilityTypeId)
|
|
682
|
+
local ____unitAddAbility_result_0
|
|
683
|
+
if unitAddAbility(unit, abilityTypeId) then
|
|
684
|
+
____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
|
|
685
|
+
else
|
|
686
|
+
____unitAddAbility_result_0 = nil
|
|
687
|
+
end
|
|
688
|
+
return ____unitAddAbility_result_0
|
|
689
|
+
end
|
|
649
690
|
____exports.Unit = __TS__Class()
|
|
650
691
|
local Unit = ____exports.Unit
|
|
651
692
|
Unit.name = "Unit"
|
|
652
693
|
__TS__ClassExtends(Unit, Handle)
|
|
653
694
|
function Unit.prototype.____constructor(self, handle)
|
|
654
695
|
Handle.prototype.____constructor(self, handle)
|
|
696
|
+
local ____nextSyncId_1 = nextSyncId
|
|
697
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
698
|
+
self.syncId = ____nextSyncId_1
|
|
655
699
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
656
700
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
657
701
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -664,6 +708,7 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
664
708
|
fourCC("Amrf")
|
|
665
709
|
))
|
|
666
710
|
end
|
|
711
|
+
unitBySyncId[self.syncId] = self
|
|
667
712
|
local ____ = self.abilities
|
|
668
713
|
end
|
|
669
714
|
function Unit.prototype.getEvent(self, event, collector)
|
|
@@ -682,6 +727,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
682
727
|
end
|
|
683
728
|
function Unit.prototype.onDestroy(self)
|
|
684
729
|
local handle = self.handle
|
|
730
|
+
self[108] = getUnitX(handle)
|
|
731
|
+
self[109] = getUnitY(handle)
|
|
685
732
|
if not self._owner then
|
|
686
733
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
687
734
|
end
|
|
@@ -749,17 +796,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
749
796
|
end}
|
|
750
797
|
end
|
|
751
798
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
752
|
-
local
|
|
753
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
799
|
+
local ____combatClassification_2 = combatClassification
|
|
800
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
|
|
754
801
|
end
|
|
755
802
|
function Unit.prototype.addClassification(self, classification)
|
|
756
|
-
return
|
|
803
|
+
return UnitAddType(self.handle, classification)
|
|
757
804
|
end
|
|
758
805
|
function Unit.prototype.removeClassification(self, classification)
|
|
759
|
-
return
|
|
806
|
+
return UnitRemoveType(self.handle, classification)
|
|
760
807
|
end
|
|
761
808
|
function Unit.prototype.hasClassification(self, classification)
|
|
762
|
-
return
|
|
809
|
+
return IsUnitType(self.handle, classification)
|
|
763
810
|
end
|
|
764
811
|
function Unit.prototype.isVisibleTo(self, player)
|
|
765
812
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -768,13 +815,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
768
815
|
return isUnitInvisible(self.handle, player.handle)
|
|
769
816
|
end
|
|
770
817
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
771
|
-
local
|
|
818
|
+
local ____temp_3
|
|
772
819
|
if type(x) == "number" then
|
|
773
|
-
|
|
820
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
774
821
|
else
|
|
775
|
-
|
|
822
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
776
823
|
end
|
|
777
|
-
return
|
|
824
|
+
return ____temp_3
|
|
778
825
|
end
|
|
779
826
|
function Unit.prototype.isAllyOf(self, unit)
|
|
780
827
|
return isUnitAlly(
|
|
@@ -792,16 +839,30 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
792
839
|
if type(animation) == "number" then
|
|
793
840
|
setUnitAnimationByIndex(self.handle, animation)
|
|
794
841
|
elseif rarity then
|
|
795
|
-
|
|
842
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
796
843
|
else
|
|
797
844
|
setUnitAnimation(self.handle, animation)
|
|
798
845
|
end
|
|
799
846
|
end
|
|
847
|
+
function Unit.prototype.resetAnimation(self)
|
|
848
|
+
ResetUnitAnimation(self.handle)
|
|
849
|
+
end
|
|
800
850
|
function Unit.prototype.queueAnimation(self, animation)
|
|
801
|
-
|
|
851
|
+
QueueUnitAnimation(self.handle, animation)
|
|
852
|
+
end
|
|
853
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
854
|
+
local firstWeapon = self.firstWeapon
|
|
855
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
856
|
+
return firstWeapon
|
|
857
|
+
end
|
|
858
|
+
local secondWeapon = self.secondWeapon
|
|
859
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
860
|
+
return secondWeapon
|
|
861
|
+
end
|
|
862
|
+
return nil
|
|
802
863
|
end
|
|
803
864
|
function Unit.prototype.delayHealthChecks(self)
|
|
804
|
-
self[
|
|
865
|
+
self[104] = (self[104] or 0) + 1
|
|
805
866
|
Timer:run(delayHealthChecksCallback, self)
|
|
806
867
|
end
|
|
807
868
|
function Unit.prototype.setPosition(self, x, y)
|
|
@@ -811,14 +872,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
811
872
|
return IsUnitSelected(self.handle, player.handle)
|
|
812
873
|
end
|
|
813
874
|
function Unit.prototype.explode(self)
|
|
814
|
-
|
|
875
|
+
SetUnitExploded(self.handle, true)
|
|
815
876
|
killUnit(self.handle)
|
|
816
877
|
end
|
|
817
878
|
function Unit.prototype.kill(self)
|
|
818
879
|
killUnit(self.handle)
|
|
819
880
|
end
|
|
820
|
-
function Unit.prototype.revive(self,
|
|
821
|
-
|
|
881
|
+
function Unit.prototype.revive(self, x, y, doEffect)
|
|
882
|
+
local ____ReviveHero_6 = ReviveHero
|
|
883
|
+
local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
|
|
884
|
+
local ____doEffect_4 = doEffect
|
|
885
|
+
if ____doEffect_4 == nil then
|
|
886
|
+
____doEffect_4 = false
|
|
887
|
+
end
|
|
888
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
889
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
822
890
|
end
|
|
823
891
|
function Unit.prototype.healTarget(self, target, amount)
|
|
824
892
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -858,20 +926,19 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
858
926
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
859
927
|
end
|
|
860
928
|
function Unit.prototype.itemInSlot(self, slot)
|
|
861
|
-
return Item:of(
|
|
929
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
862
930
|
end
|
|
863
931
|
function Unit.prototype.addAbility(self, abilityId)
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
932
|
+
local ability = UnitAbility:of(
|
|
933
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
934
|
+
abilityId,
|
|
935
|
+
self
|
|
936
|
+
)
|
|
937
|
+
if ability ~= nil then
|
|
870
938
|
local abilities = self.abilities
|
|
871
939
|
abilities[#abilities + 1] = ability
|
|
872
|
-
return ability
|
|
873
940
|
end
|
|
874
|
-
return
|
|
941
|
+
return ability
|
|
875
942
|
end
|
|
876
943
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
877
944
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -885,31 +952,21 @@ end
|
|
|
885
952
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
886
953
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
887
954
|
end
|
|
888
|
-
function Unit.prototype.
|
|
889
|
-
local
|
|
890
|
-
|
|
891
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
892
|
-
return nil
|
|
893
|
-
end
|
|
894
|
-
return UnitAbility:of(
|
|
895
|
-
getUnitAbility(self.handle, abilityId),
|
|
896
|
-
abilityId,
|
|
897
|
-
self
|
|
898
|
-
)
|
|
955
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
956
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
957
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
899
958
|
end
|
|
900
|
-
function Unit.prototype.removeAbility(self,
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
end
|
|
959
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
960
|
+
local abilities = self.abilities
|
|
961
|
+
for i = 1, #abilities do
|
|
962
|
+
if abilities[i].typeId == abilityTypeId then
|
|
963
|
+
local ability = abilities[i]
|
|
964
|
+
tremove(abilities, i)
|
|
965
|
+
ability:destroy()
|
|
966
|
+
return true
|
|
909
967
|
end
|
|
910
|
-
return true
|
|
911
968
|
end
|
|
912
|
-
return
|
|
969
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
913
970
|
end
|
|
914
971
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
915
972
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -923,12 +980,34 @@ end
|
|
|
923
980
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
924
981
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
925
982
|
end
|
|
983
|
+
function Unit.prototype.interruptMovement(self)
|
|
984
|
+
local handle = self.handle
|
|
985
|
+
unitDisableAbility(
|
|
986
|
+
handle,
|
|
987
|
+
fourCC("Amov"),
|
|
988
|
+
true,
|
|
989
|
+
false
|
|
990
|
+
)
|
|
991
|
+
unitDisableAbility(
|
|
992
|
+
handle,
|
|
993
|
+
fourCC("Amov"),
|
|
994
|
+
false,
|
|
995
|
+
false
|
|
996
|
+
)
|
|
997
|
+
end
|
|
926
998
|
function Unit.prototype.interruptAttack(self)
|
|
927
999
|
unitInterruptAttack(self.handle)
|
|
928
1000
|
end
|
|
929
1001
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
930
|
-
|
|
931
|
-
unitDisableAbility(
|
|
1002
|
+
local handle = self.handle
|
|
1003
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
1004
|
+
Timer:run(
|
|
1005
|
+
unitDisableAbility,
|
|
1006
|
+
handle,
|
|
1007
|
+
abilityId,
|
|
1008
|
+
false,
|
|
1009
|
+
false
|
|
1010
|
+
)
|
|
932
1011
|
end
|
|
933
1012
|
function Unit.prototype.getDistanceTo(self, target)
|
|
934
1013
|
local handle = self.handle
|
|
@@ -988,18 +1067,44 @@ function Unit.prototype.unpauseEx(self)
|
|
|
988
1067
|
self:decrementStunCounter()
|
|
989
1068
|
end
|
|
990
1069
|
function Unit.prototype.incrementStunCounter(self)
|
|
991
|
-
local stunCounter = self[
|
|
992
|
-
if not self[
|
|
1070
|
+
local stunCounter = self[102] or 0
|
|
1071
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
|
|
993
1072
|
BlzPauseUnitEx(self.handle, true)
|
|
994
1073
|
end
|
|
995
|
-
self[
|
|
1074
|
+
self[102] = stunCounter + 1
|
|
996
1075
|
end
|
|
997
1076
|
function Unit.prototype.decrementStunCounter(self)
|
|
998
|
-
local stunCounter = self[
|
|
999
|
-
if not self[
|
|
1077
|
+
local stunCounter = self[102] or 0
|
|
1078
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
|
|
1000
1079
|
BlzPauseUnitEx(self.handle, false)
|
|
1001
1080
|
end
|
|
1002
|
-
self[
|
|
1081
|
+
self[102] = stunCounter - 1
|
|
1082
|
+
end
|
|
1083
|
+
function Unit.prototype.incrementForceStunCounter(self)
|
|
1084
|
+
local forceStunCounter = self[103] or 0
|
|
1085
|
+
if forceStunCounter == 0 then
|
|
1086
|
+
local handle = self.handle
|
|
1087
|
+
if not self[101] then
|
|
1088
|
+
for _ = self[102] or 0, -1 do
|
|
1089
|
+
BlzPauseUnitEx(handle, true)
|
|
1090
|
+
end
|
|
1091
|
+
end
|
|
1092
|
+
BlzPauseUnitEx(handle, true)
|
|
1093
|
+
end
|
|
1094
|
+
self[103] = forceStunCounter + 1
|
|
1095
|
+
end
|
|
1096
|
+
function Unit.prototype.decrementForceStunCounter(self)
|
|
1097
|
+
local forceStunCounter = self[103] or 0
|
|
1098
|
+
if forceStunCounter == 1 then
|
|
1099
|
+
local handle = self.handle
|
|
1100
|
+
if not self[101] then
|
|
1101
|
+
for _ = self[102] or 0, -1 do
|
|
1102
|
+
BlzPauseUnitEx(handle, false)
|
|
1103
|
+
end
|
|
1104
|
+
end
|
|
1105
|
+
BlzPauseUnitEx(handle, false)
|
|
1106
|
+
end
|
|
1107
|
+
self[103] = forceStunCounter - 1
|
|
1003
1108
|
end
|
|
1004
1109
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
1005
1110
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -1101,8 +1206,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
1101
1206
|
)
|
|
1102
1207
|
return targetCollection
|
|
1103
1208
|
end
|
|
1104
|
-
function Unit.getSelectionOf(self, player)
|
|
1105
|
-
|
|
1209
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1210
|
+
if target == nil then
|
|
1211
|
+
target = {}
|
|
1212
|
+
end
|
|
1213
|
+
targetCollection = target
|
|
1106
1214
|
targetCollectionNextIndex = 1
|
|
1107
1215
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
1108
1216
|
return targetCollection
|
|
@@ -1124,6 +1232,9 @@ end
|
|
|
1124
1232
|
function Unit.prototype.__tostring(self)
|
|
1125
1233
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
1126
1234
|
end
|
|
1235
|
+
function Unit.getBySyncId(self, syncId)
|
|
1236
|
+
return unitBySyncId[syncId]
|
|
1237
|
+
end
|
|
1127
1238
|
__TS__SetDescriptor(
|
|
1128
1239
|
Unit.prototype,
|
|
1129
1240
|
"_deltas",
|
|
@@ -1183,7 +1294,15 @@ __TS__SetDescriptor(
|
|
|
1183
1294
|
Unit.prototype,
|
|
1184
1295
|
"isIllusion",
|
|
1185
1296
|
{get = function(self)
|
|
1186
|
-
return
|
|
1297
|
+
return IsUnitIllusion(self.handle)
|
|
1298
|
+
end},
|
|
1299
|
+
true
|
|
1300
|
+
)
|
|
1301
|
+
__TS__SetDescriptor(
|
|
1302
|
+
Unit.prototype,
|
|
1303
|
+
"isStunned",
|
|
1304
|
+
{get = function(self)
|
|
1305
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1187
1306
|
end},
|
|
1188
1307
|
true
|
|
1189
1308
|
)
|
|
@@ -1260,6 +1379,19 @@ __TS__SetDescriptor(
|
|
|
1260
1379
|
},
|
|
1261
1380
|
true
|
|
1262
1381
|
)
|
|
1382
|
+
__TS__SetDescriptor(
|
|
1383
|
+
Unit.prototype,
|
|
1384
|
+
"primaryAttribute",
|
|
1385
|
+
{
|
|
1386
|
+
get = function(self)
|
|
1387
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1388
|
+
end,
|
|
1389
|
+
set = function(self, primaryAttribute)
|
|
1390
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1391
|
+
end
|
|
1392
|
+
},
|
|
1393
|
+
true
|
|
1394
|
+
)
|
|
1263
1395
|
__TS__SetDescriptor(
|
|
1264
1396
|
Unit.prototype,
|
|
1265
1397
|
"strengthBase",
|
|
@@ -1268,7 +1400,7 @@ __TS__SetDescriptor(
|
|
|
1268
1400
|
return getHeroStr(self.handle, false)
|
|
1269
1401
|
end,
|
|
1270
1402
|
set = function(self, strengthBase)
|
|
1271
|
-
|
|
1403
|
+
STRENGTH_UNIT_FIELD:setValue(self, strengthBase)
|
|
1272
1404
|
end
|
|
1273
1405
|
},
|
|
1274
1406
|
true
|
|
@@ -1298,7 +1430,7 @@ __TS__SetDescriptor(
|
|
|
1298
1430
|
return getHeroAgi(self.handle, false)
|
|
1299
1431
|
end,
|
|
1300
1432
|
set = function(self, agilityBase)
|
|
1301
|
-
|
|
1433
|
+
AGILITY_UNIT_FIELD:setValue(self, agilityBase)
|
|
1302
1434
|
end
|
|
1303
1435
|
},
|
|
1304
1436
|
true
|
|
@@ -1328,7 +1460,7 @@ __TS__SetDescriptor(
|
|
|
1328
1460
|
return getHeroInt(self.handle, false)
|
|
1329
1461
|
end,
|
|
1330
1462
|
set = function(self, intelligenceBase)
|
|
1331
|
-
|
|
1463
|
+
INTELLIGENCE_UNIT_FIELD:setValue(self, intelligenceBase)
|
|
1332
1464
|
end
|
|
1333
1465
|
},
|
|
1334
1466
|
true
|
|
@@ -1381,17 +1513,17 @@ __TS__SetDescriptor(
|
|
|
1381
1513
|
"isTeamGlowVisible",
|
|
1382
1514
|
{
|
|
1383
1515
|
get = function(self)
|
|
1384
|
-
return not self[
|
|
1516
|
+
return not self[107]
|
|
1385
1517
|
end,
|
|
1386
1518
|
set = function(self, isTeamGlowVisible)
|
|
1387
|
-
|
|
1388
|
-
local
|
|
1519
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1520
|
+
local ____temp_7
|
|
1389
1521
|
if not isTeamGlowVisible then
|
|
1390
|
-
|
|
1522
|
+
____temp_7 = true
|
|
1391
1523
|
else
|
|
1392
|
-
|
|
1524
|
+
____temp_7 = nil
|
|
1393
1525
|
end
|
|
1394
|
-
self[
|
|
1526
|
+
self[107] = ____temp_7
|
|
1395
1527
|
end
|
|
1396
1528
|
},
|
|
1397
1529
|
true
|
|
@@ -1400,9 +1532,9 @@ __TS__SetDescriptor(
|
|
|
1400
1532
|
Unit.prototype,
|
|
1401
1533
|
"color",
|
|
1402
1534
|
{set = function(self, color)
|
|
1403
|
-
|
|
1404
|
-
if self[
|
|
1405
|
-
|
|
1535
|
+
SetUnitColor(self.handle, color.handle)
|
|
1536
|
+
if self[107] then
|
|
1537
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1406
1538
|
end
|
|
1407
1539
|
end},
|
|
1408
1540
|
true
|
|
@@ -1425,14 +1557,14 @@ __TS__SetDescriptor(
|
|
|
1425
1557
|
"maxHealth",
|
|
1426
1558
|
{
|
|
1427
1559
|
get = function(self)
|
|
1428
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1560
|
+
return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
|
|
1429
1561
|
end,
|
|
1430
1562
|
set = function(self, maxHealth)
|
|
1431
|
-
if maxHealth < 1 and self[
|
|
1432
|
-
self[
|
|
1563
|
+
if maxHealth < 1 and self[104] ~= nil then
|
|
1564
|
+
self[105] = (self[105] or 0) + (1 - maxHealth)
|
|
1433
1565
|
maxHealth = 1
|
|
1434
1566
|
end
|
|
1435
|
-
BlzSetUnitMaxHP(self.handle, maxHealth + (self[
|
|
1567
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
|
|
1436
1568
|
end
|
|
1437
1569
|
},
|
|
1438
1570
|
true
|
|
@@ -1474,10 +1606,10 @@ __TS__SetDescriptor(
|
|
|
1474
1606
|
"health",
|
|
1475
1607
|
{
|
|
1476
1608
|
get = function(self)
|
|
1477
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1609
|
+
return GetWidgetLife(self.handle) - (self[106] or 0)
|
|
1478
1610
|
end,
|
|
1479
1611
|
set = function(self, health)
|
|
1480
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1612
|
+
SetWidgetLife(self.handle, health + (self[106] or 0))
|
|
1481
1613
|
end
|
|
1482
1614
|
},
|
|
1483
1615
|
true
|
|
@@ -1553,25 +1685,12 @@ __TS__SetDescriptor(
|
|
|
1553
1685
|
},
|
|
1554
1686
|
true
|
|
1555
1687
|
)
|
|
1556
|
-
__TS__SetDescriptor(
|
|
1557
|
-
Unit.prototype,
|
|
1558
|
-
"flyHeight",
|
|
1559
|
-
{
|
|
1560
|
-
get = function(self)
|
|
1561
|
-
return getUnitFlyHeight(self.handle)
|
|
1562
|
-
end,
|
|
1563
|
-
set = function(self, v)
|
|
1564
|
-
SetUnitFlyHeight(self.handle, v, 100000)
|
|
1565
|
-
end
|
|
1566
|
-
},
|
|
1567
|
-
true
|
|
1568
|
-
)
|
|
1569
1688
|
__TS__SetDescriptor(
|
|
1570
1689
|
Unit.prototype,
|
|
1571
1690
|
"x",
|
|
1572
1691
|
{
|
|
1573
1692
|
get = function(self)
|
|
1574
|
-
return getUnitX(self.handle)
|
|
1693
|
+
return self[108] or getUnitX(self.handle)
|
|
1575
1694
|
end,
|
|
1576
1695
|
set = function(self, v)
|
|
1577
1696
|
SetUnitX(self.handle, v)
|
|
@@ -1584,7 +1703,7 @@ __TS__SetDescriptor(
|
|
|
1584
1703
|
"y",
|
|
1585
1704
|
{
|
|
1586
1705
|
get = function(self)
|
|
1587
|
-
return getUnitY(self.handle)
|
|
1706
|
+
return self[109] or getUnitY(self.handle)
|
|
1588
1707
|
end,
|
|
1589
1708
|
set = function(self, v)
|
|
1590
1709
|
SetUnitY(self.handle, v)
|
|
@@ -1670,10 +1789,10 @@ __TS__SetDescriptor(
|
|
|
1670
1789
|
"gold",
|
|
1671
1790
|
{
|
|
1672
1791
|
get = function(self)
|
|
1673
|
-
return
|
|
1792
|
+
return GetResourceAmount(self.handle)
|
|
1674
1793
|
end,
|
|
1675
1794
|
set = function(self, gold)
|
|
1676
|
-
|
|
1795
|
+
SetResourceAmount(self.handle, gold)
|
|
1677
1796
|
end
|
|
1678
1797
|
},
|
|
1679
1798
|
true
|
|
@@ -1688,17 +1807,21 @@ __TS__SetDescriptor(
|
|
|
1688
1807
|
set = function(self, isPaused)
|
|
1689
1808
|
local handle = self.handle
|
|
1690
1809
|
if isPaused and not IsUnitPaused(handle) then
|
|
1691
|
-
self[
|
|
1692
|
-
|
|
1693
|
-
|
|
1810
|
+
self[101] = true
|
|
1811
|
+
if (self[103] or 0) <= 0 then
|
|
1812
|
+
for _ = self[102] or 0, -1 do
|
|
1813
|
+
BlzPauseUnitEx(handle, true)
|
|
1814
|
+
end
|
|
1694
1815
|
end
|
|
1695
1816
|
PauseUnit(handle, true)
|
|
1696
1817
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1697
1818
|
PauseUnit(handle, false)
|
|
1698
|
-
|
|
1699
|
-
|
|
1819
|
+
if (self[103] or 0) <= 0 then
|
|
1820
|
+
for _ = self[102] or 0, -1 do
|
|
1821
|
+
BlzPauseUnitEx(handle, false)
|
|
1822
|
+
end
|
|
1700
1823
|
end
|
|
1701
|
-
self[
|
|
1824
|
+
self[101] = nil
|
|
1702
1825
|
end
|
|
1703
1826
|
end
|
|
1704
1827
|
},
|
|
@@ -1754,20 +1877,6 @@ __TS__SetDescriptor(
|
|
|
1754
1877
|
},
|
|
1755
1878
|
true
|
|
1756
1879
|
)
|
|
1757
|
-
__TS__SetDescriptor(
|
|
1758
|
-
Unit.prototype,
|
|
1759
|
-
"scale",
|
|
1760
|
-
{
|
|
1761
|
-
get = function(self)
|
|
1762
|
-
return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
|
|
1763
|
-
end,
|
|
1764
|
-
set = function(self, v)
|
|
1765
|
-
setUnitScale(self.handle, v, v, v)
|
|
1766
|
-
setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
|
|
1767
|
-
end
|
|
1768
|
-
},
|
|
1769
|
-
true
|
|
1770
|
-
)
|
|
1771
1880
|
__TS__SetDescriptor(
|
|
1772
1881
|
Unit.prototype,
|
|
1773
1882
|
"timeScale",
|
|
@@ -1801,6 +1910,19 @@ __TS__SetDescriptor(
|
|
|
1801
1910
|
end},
|
|
1802
1911
|
true
|
|
1803
1912
|
)
|
|
1913
|
+
__TS__SetDescriptor(
|
|
1914
|
+
Unit.prototype,
|
|
1915
|
+
"movementType",
|
|
1916
|
+
{
|
|
1917
|
+
get = function(self)
|
|
1918
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1919
|
+
end,
|
|
1920
|
+
set = function(self, movementType)
|
|
1921
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1922
|
+
end
|
|
1923
|
+
},
|
|
1924
|
+
true
|
|
1925
|
+
)
|
|
1804
1926
|
__TS__SetDescriptor(
|
|
1805
1927
|
Unit.prototype,
|
|
1806
1928
|
"pathing",
|
|
@@ -1982,6 +2104,14 @@ __TS__SetDescriptor(
|
|
|
1982
2104
|
end},
|
|
1983
2105
|
true
|
|
1984
2106
|
)
|
|
2107
|
+
__TS__SetDescriptor(
|
|
2108
|
+
Unit.prototype,
|
|
2109
|
+
"targetAcquiredEvent",
|
|
2110
|
+
{get = function(self)
|
|
2111
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2112
|
+
end},
|
|
2113
|
+
true
|
|
2114
|
+
)
|
|
1985
2115
|
__TS__SetDescriptor(
|
|
1986
2116
|
Unit.prototype,
|
|
1987
2117
|
"onSelect",
|
|
@@ -2042,6 +2172,11 @@ __TS__SetDescriptor(
|
|
|
2042
2172
|
end},
|
|
2043
2173
|
true
|
|
2044
2174
|
)
|
|
2175
|
+
Unit.levelChangedEvent = __TS__New(
|
|
2176
|
+
____exports.UnitTriggerEvent,
|
|
2177
|
+
EVENT_PLAYER_HERO_LEVEL,
|
|
2178
|
+
function() return ____exports.Unit:of(getTriggerUnit()) end
|
|
2179
|
+
)
|
|
2045
2180
|
Unit.deathEvent = __TS__New(
|
|
2046
2181
|
____exports.UnitTriggerEvent,
|
|
2047
2182
|
EVENT_PLAYER_UNIT_DEATH,
|
|
@@ -2055,7 +2190,6 @@ Unit.onDecay = __TS__New(
|
|
|
2055
2190
|
Unit.onResurrect = __TS__New(
|
|
2056
2191
|
InitializingEvent,
|
|
2057
2192
|
function(event)
|
|
2058
|
-
local invoke = Event.invoke
|
|
2059
2193
|
local dead = setmetatable({}, {__mode = "k"})
|
|
2060
2194
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
2061
2195
|
dead[unit] = true
|
|
@@ -2071,10 +2205,15 @@ Unit.onResurrect = __TS__New(
|
|
|
2071
2205
|
Unit.morphEvent = __TS__New(
|
|
2072
2206
|
InitializingEvent,
|
|
2073
2207
|
function(event)
|
|
2208
|
+
local function ifNotLeft(unit)
|
|
2209
|
+
local handle = unit.handle
|
|
2210
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2211
|
+
invoke(event, unit)
|
|
2212
|
+
end
|
|
2213
|
+
end
|
|
2074
2214
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
2075
2215
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
2076
|
-
|
|
2077
|
-
Timer:run(Event.invoke, event, unit)
|
|
2216
|
+
Timer:run(ifNotLeft, unit)
|
|
2078
2217
|
end
|
|
2079
2218
|
end)
|
|
2080
2219
|
end
|
|
@@ -2112,27 +2251,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
2112
2251
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
2113
2252
|
InitializingEvent,
|
|
2114
2253
|
function(event)
|
|
2115
|
-
local invoke = Event.invoke
|
|
2116
2254
|
local function listener(unit, id)
|
|
2117
|
-
local
|
|
2255
|
+
local ____GetSpellTargetUnit_result_10
|
|
2118
2256
|
if GetSpellTargetUnit() then
|
|
2119
|
-
|
|
2257
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2120
2258
|
else
|
|
2121
|
-
local
|
|
2259
|
+
local ____GetSpellTargetItem_result_9
|
|
2122
2260
|
if GetSpellTargetItem() then
|
|
2123
|
-
|
|
2261
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
2124
2262
|
else
|
|
2125
|
-
local
|
|
2263
|
+
local ____GetSpellTargetDestructable_result_8
|
|
2126
2264
|
if GetSpellTargetDestructable() then
|
|
2127
|
-
|
|
2265
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
2128
2266
|
else
|
|
2129
|
-
|
|
2267
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
2130
2268
|
end
|
|
2131
|
-
|
|
2269
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
2132
2270
|
end
|
|
2133
|
-
|
|
2271
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
2134
2272
|
end
|
|
2135
|
-
local target =
|
|
2273
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
2136
2274
|
if target then
|
|
2137
2275
|
invoke(event, unit, id, target)
|
|
2138
2276
|
end
|
|
@@ -2304,10 +2442,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2304
2442
|
____exports.UnitTriggerEvent,
|
|
2305
2443
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2306
2444
|
function()
|
|
2307
|
-
local
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2445
|
+
local handle = getOrderedUnit()
|
|
2446
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2447
|
+
local unit = ____exports.Unit:of(handle)
|
|
2448
|
+
if unit.state == 1 then
|
|
2449
|
+
return unit, getIssuedOrderId()
|
|
2450
|
+
end
|
|
2311
2451
|
end
|
|
2312
2452
|
return IgnoreEvent
|
|
2313
2453
|
end
|
|
@@ -2329,7 +2469,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2329
2469
|
)
|
|
2330
2470
|
Unit.onDamaging = (function()
|
|
2331
2471
|
local event = __TS__New(Event)
|
|
2332
|
-
local invoke = Event.invoke
|
|
2333
2472
|
local trigger = CreateTrigger()
|
|
2334
2473
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2335
2474
|
TriggerAddCondition(
|
|
@@ -2339,38 +2478,57 @@ Unit.onDamaging = (function()
|
|
|
2339
2478
|
if source and source.typeId == dummyUnitId then
|
|
2340
2479
|
source = nil
|
|
2341
2480
|
end
|
|
2342
|
-
local target = BlzGetEventDamageTarget()
|
|
2481
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2482
|
+
local metadata = damageMetadataByTarget[target]
|
|
2483
|
+
damageMetadataByTarget[target] = nil
|
|
2343
2484
|
local data = {
|
|
2344
2485
|
amount = GetEventDamage(),
|
|
2345
|
-
attackType = BlzGetEventAttackType(),
|
|
2486
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2346
2487
|
damageType = BlzGetEventDamageType(),
|
|
2347
2488
|
weaponType = BlzGetEventWeaponType(),
|
|
2348
|
-
|
|
2489
|
+
metadata = metadata,
|
|
2490
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2491
|
+
originalAmount = GetEventDamage(),
|
|
2492
|
+
originalMetadata = metadata,
|
|
2493
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2349
2494
|
}
|
|
2350
2495
|
if data.isAttack and source then
|
|
2351
|
-
|
|
2352
|
-
if weapon == -1 then
|
|
2353
|
-
local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
|
|
2354
|
-
weapon = 0
|
|
2355
|
-
end
|
|
2356
|
-
data.weapon = assert(source.weapons[weapon + 1])
|
|
2496
|
+
data.weapon = source:chooseWeapon(target)
|
|
2357
2497
|
end
|
|
2358
2498
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2359
2499
|
invoke(
|
|
2360
2500
|
event,
|
|
2361
2501
|
source,
|
|
2362
|
-
|
|
2502
|
+
target,
|
|
2363
2503
|
setmetatable(
|
|
2364
2504
|
{},
|
|
2365
2505
|
{
|
|
2366
2506
|
__index = data,
|
|
2367
2507
|
__newindex = function(self, key, value)
|
|
2368
|
-
damageSetters[key]
|
|
2508
|
+
local damageSetter = damageSetters[key]
|
|
2509
|
+
if damageSetter ~= nil then
|
|
2510
|
+
damageSetter(value)
|
|
2511
|
+
end
|
|
2369
2512
|
data[key] = value
|
|
2370
2513
|
end
|
|
2371
2514
|
}
|
|
2372
2515
|
)
|
|
2373
2516
|
)
|
|
2517
|
+
if data[0] and source then
|
|
2518
|
+
local sourceOwner = source.owner.handle
|
|
2519
|
+
data[1] = sourceOwner
|
|
2520
|
+
local targetOwner = target.owner.handle
|
|
2521
|
+
data[2] = targetOwner
|
|
2522
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2523
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2524
|
+
data[3] = true
|
|
2525
|
+
end
|
|
2526
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2527
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2528
|
+
data[4] = true
|
|
2529
|
+
end
|
|
2530
|
+
end
|
|
2531
|
+
damagingEventByTarget[target] = data
|
|
2374
2532
|
return
|
|
2375
2533
|
end
|
|
2376
2534
|
BlzSetEventDamage(0)
|
|
@@ -2378,7 +2536,7 @@ Unit.onDamaging = (function()
|
|
|
2378
2536
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2379
2537
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2380
2538
|
local sourceOwner = source.owner.handle
|
|
2381
|
-
local targetOwner =
|
|
2539
|
+
local targetOwner = target.owner.handle
|
|
2382
2540
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2383
2541
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2384
2542
|
Timer:run(function()
|
|
@@ -2394,23 +2552,19 @@ Unit.onDamaging = (function()
|
|
|
2394
2552
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2395
2553
|
local condition = ____value[1]
|
|
2396
2554
|
local action = ____value[2]
|
|
2397
|
-
if condition(
|
|
2398
|
-
source,
|
|
2399
|
-
____exports.Unit:of(target),
|
|
2400
|
-
data
|
|
2401
|
-
) then
|
|
2555
|
+
if condition(source, target, data) then
|
|
2402
2556
|
action(
|
|
2403
2557
|
source,
|
|
2404
|
-
|
|
2558
|
+
target,
|
|
2405
2559
|
setmetatable(
|
|
2406
2560
|
{fire = function()
|
|
2407
2561
|
UnitDamageTarget(
|
|
2408
2562
|
source.handle,
|
|
2409
|
-
target,
|
|
2563
|
+
target.handle,
|
|
2410
2564
|
data.amount,
|
|
2411
2565
|
true,
|
|
2412
2566
|
true,
|
|
2413
|
-
data.attackType,
|
|
2567
|
+
attackTypeToNative(data.attackType),
|
|
2414
2568
|
data.damageType,
|
|
2415
2569
|
data.weaponType
|
|
2416
2570
|
)
|
|
@@ -2428,7 +2582,6 @@ end)()
|
|
|
2428
2582
|
Unit.onDamage = __TS__New(
|
|
2429
2583
|
InitializingEvent,
|
|
2430
2584
|
function(event)
|
|
2431
|
-
local invoke = Event.invoke
|
|
2432
2585
|
local trigger = CreateTrigger()
|
|
2433
2586
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2434
2587
|
TriggerAddCondition(
|
|
@@ -2438,29 +2591,54 @@ Unit.onDamage = __TS__New(
|
|
|
2438
2591
|
if source and source.typeId == dummyUnitId then
|
|
2439
2592
|
source = nil
|
|
2440
2593
|
end
|
|
2594
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2595
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2596
|
+
damagingEventByTarget[target] = nil
|
|
2441
2597
|
local data = {
|
|
2442
2598
|
amount = GetEventDamage(),
|
|
2443
|
-
attackType = BlzGetEventAttackType(),
|
|
2599
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2444
2600
|
damageType = BlzGetEventDamageType(),
|
|
2445
2601
|
weaponType = BlzGetEventWeaponType(),
|
|
2602
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2446
2603
|
isAttack = BlzGetEventIsAttack(),
|
|
2604
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2605
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2447
2606
|
preventDeath = damageEventPreventDeath
|
|
2448
2607
|
}
|
|
2608
|
+
if damagingEvent then
|
|
2609
|
+
for key, value in pairs(damagingEvent) do
|
|
2610
|
+
if isAttribute(key) then
|
|
2611
|
+
data[key] = value
|
|
2612
|
+
end
|
|
2613
|
+
end
|
|
2614
|
+
local sourceOwner = damagingEvent[1]
|
|
2615
|
+
if sourceOwner then
|
|
2616
|
+
local targetOwner = damagingEvent[2]
|
|
2617
|
+
if damagingEvent[3] then
|
|
2618
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2619
|
+
end
|
|
2620
|
+
if damagingEvent[4] then
|
|
2621
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2622
|
+
end
|
|
2623
|
+
end
|
|
2624
|
+
end
|
|
2449
2625
|
local evData = setmetatable(
|
|
2450
2626
|
{},
|
|
2451
2627
|
{
|
|
2452
2628
|
__index = data,
|
|
2453
2629
|
__newindex = function(self, key, value)
|
|
2454
|
-
damageSetters[key]
|
|
2630
|
+
local damageSetter = damageSetters[key]
|
|
2631
|
+
if damageSetter ~= nil then
|
|
2632
|
+
damageSetter(value)
|
|
2633
|
+
end
|
|
2455
2634
|
data[key] = value
|
|
2456
2635
|
end
|
|
2457
2636
|
}
|
|
2458
2637
|
)
|
|
2459
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2460
2638
|
invoke(event, source, target, evData)
|
|
2461
2639
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2462
2640
|
local bonusHealth = math.ceil(evData.amount)
|
|
2463
|
-
target[
|
|
2641
|
+
target[106] = (target[106] or 0) + bonusHealth
|
|
2464
2642
|
BlzSetUnitMaxHP(
|
|
2465
2643
|
target.handle,
|
|
2466
2644
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2474,7 +2652,7 @@ Unit.onDamage = __TS__New(
|
|
|
2474
2652
|
evData[0],
|
|
2475
2653
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2476
2654
|
)
|
|
2477
|
-
target[
|
|
2655
|
+
target[106] = (target[106] or 0) - bonusHealth
|
|
2478
2656
|
SetWidgetLife(
|
|
2479
2657
|
target.handle,
|
|
2480
2658
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2494,32 +2672,110 @@ Unit.onDamage = __TS__New(
|
|
|
2494
2672
|
DestroyTrigger(trigger)
|
|
2495
2673
|
end
|
|
2496
2674
|
)
|
|
2497
|
-
Unit.
|
|
2675
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2498
2676
|
____exports.UnitTriggerEvent,
|
|
2499
2677
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2500
2678
|
function()
|
|
2501
2679
|
local unit = getTriggerUnit()
|
|
2502
|
-
|
|
2503
|
-
|
|
2680
|
+
local item = getManipulatedItem()
|
|
2681
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2682
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2504
2683
|
end
|
|
2505
2684
|
return IgnoreEvent
|
|
2506
2685
|
end
|
|
2507
2686
|
)
|
|
2508
|
-
Unit.
|
|
2687
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2509
2688
|
____exports.UnitTriggerEvent,
|
|
2510
2689
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2511
2690
|
function()
|
|
2512
|
-
local
|
|
2513
|
-
|
|
2514
|
-
|
|
2691
|
+
local unitHandle = getTriggerUnit()
|
|
2692
|
+
local itemHandle = getManipulatedItem()
|
|
2693
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2694
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2695
|
+
local item = Item:of(itemHandle)
|
|
2696
|
+
if item.owner ~= unit then
|
|
2697
|
+
return unit, item
|
|
2698
|
+
end
|
|
2515
2699
|
end
|
|
2516
2700
|
return IgnoreEvent
|
|
2517
2701
|
end
|
|
2518
2702
|
)
|
|
2519
|
-
Unit.
|
|
2703
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2520
2704
|
____exports.UnitTriggerEvent,
|
|
2521
2705
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2522
|
-
function()
|
|
2706
|
+
function()
|
|
2707
|
+
local unit = getTriggerUnit()
|
|
2708
|
+
local item = getManipulatedItem()
|
|
2709
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2710
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2711
|
+
end
|
|
2712
|
+
return IgnoreEvent
|
|
2713
|
+
end
|
|
2714
|
+
)
|
|
2715
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2716
|
+
____exports.UnitTriggerEvent,
|
|
2717
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2718
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2719
|
+
)
|
|
2720
|
+
__TS__ObjectDefineProperty(
|
|
2721
|
+
Unit,
|
|
2722
|
+
"itemChargesChangedEvent",
|
|
2723
|
+
{get = function(self)
|
|
2724
|
+
local event = __TS__New(Event)
|
|
2725
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2726
|
+
local unit = item.owner
|
|
2727
|
+
if unit ~= nil then
|
|
2728
|
+
invoke(event, unit, item)
|
|
2729
|
+
end
|
|
2730
|
+
end)
|
|
2731
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2732
|
+
return event
|
|
2733
|
+
end}
|
|
2734
|
+
)
|
|
2735
|
+
__TS__ObjectDefineProperty(
|
|
2736
|
+
Unit,
|
|
2737
|
+
"itemUseOrderEvent",
|
|
2738
|
+
{get = function(self)
|
|
2739
|
+
local event = __TS__New(Event)
|
|
2740
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2741
|
+
local slot = order - orderId("useslot0")
|
|
2742
|
+
local function listener(unit)
|
|
2743
|
+
local item = unit.items[slot + 1]
|
|
2744
|
+
if item ~= nil then
|
|
2745
|
+
invoke(event, unit, item)
|
|
2746
|
+
end
|
|
2747
|
+
end
|
|
2748
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2749
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2750
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2751
|
+
end
|
|
2752
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2753
|
+
return event
|
|
2754
|
+
end}
|
|
2755
|
+
)
|
|
2756
|
+
__TS__ObjectDefineProperty(
|
|
2757
|
+
Unit,
|
|
2758
|
+
"itemMoveOrderEvent",
|
|
2759
|
+
{get = function(self)
|
|
2760
|
+
local event = __TS__New(Event)
|
|
2761
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2762
|
+
local slotTo = order - orderId("moveslot0")
|
|
2763
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2764
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2765
|
+
if slotFrom ~= nil then
|
|
2766
|
+
invoke(
|
|
2767
|
+
event,
|
|
2768
|
+
unit,
|
|
2769
|
+
item,
|
|
2770
|
+
slotFrom,
|
|
2771
|
+
slotTo
|
|
2772
|
+
)
|
|
2773
|
+
end
|
|
2774
|
+
end)
|
|
2775
|
+
end
|
|
2776
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2777
|
+
return event
|
|
2778
|
+
end}
|
|
2523
2779
|
)
|
|
2524
2780
|
__TS__ObjectDefineProperty(
|
|
2525
2781
|
Unit,
|
|
@@ -2546,6 +2802,10 @@ __TS__ObjectDefineProperty(
|
|
|
2546
2802
|
rawset(self, "destroyEvent", destroyEvent)
|
|
2547
2803
|
return destroyEvent
|
|
2548
2804
|
end}
|
|
2805
|
+
)
|
|
2806
|
+
Unit.synchronize = synchronizer(
|
|
2807
|
+
function(unit) return unit.syncId end,
|
|
2808
|
+
function(syncId) return unitBySyncId[syncId] end
|
|
2549
2809
|
);
|
|
2550
2810
|
(function(self)
|
|
2551
2811
|
local leaveAbilityIds = postcompile(function()
|