warscript 0.0.1-dev.6f480d0 → 0.0.1-dev.6f7008d
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 +18 -0
- package/attributes.lua +32 -0
- package/binaryreader.d.ts +1 -0
- package/binaryreader.lua +3 -0
- package/config.d.ts +5 -0
- package/config.lua +10 -0
- package/core/types/effect.d.ts +14 -6
- package/core/types/effect.lua +131 -35
- package/core/types/frame.d.ts +8 -1
- package/core/types/frame.lua +117 -22
- package/core/types/group.d.ts +0 -1
- package/core/types/handle.d.ts +2 -1
- package/core/types/handle.lua +5 -0
- package/core/types/image.d.ts +0 -1
- package/core/types/missile.d.ts +2 -2
- package/core/types/missile.lua +8 -2
- package/core/types/player.lua +3 -1
- 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 +9 -0
- package/core/types/tileCell.lua +92 -0
- package/core/types/timer.d.ts +9 -8
- package/core/types/timer.lua +45 -23
- package/core/types/unit.lua +8 -0
- package/core/util.d.ts +1 -1
- package/core/util.lua +18 -1
- package/decl/index.d.ts +1 -0
- package/decl/native.d.ts +846 -790
- package/engine/ability.d.ts +1 -1
- package/engine/behavior.d.ts +15 -10
- package/engine/behavior.lua +112 -33
- package/engine/behaviour/ability/always-enabled.d.ts +7 -0
- package/engine/behaviour/ability/always-enabled.lua +31 -0
- package/engine/behaviour/ability/apply-buff.d.ts +8 -5
- package/engine/behaviour/ability/apply-buff.lua +32 -0
- package/engine/behaviour/ability/apply-unit-behavior.d.ts +5 -1
- package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
- package/engine/behaviour/ability/damage.d.ts +39 -11
- package/engine/behaviour/ability/damage.lua +83 -37
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +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 -15
- package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
- package/engine/behaviour/ability/on-command-impact.lua +25 -0
- package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
- package/engine/behaviour/ability/remove-buffs.lua +28 -0
- package/engine/behaviour/ability/restore-mana.d.ts +15 -0
- package/engine/behaviour/ability/restore-mana.lua +29 -0
- package/engine/behaviour/ability.d.ts +27 -4
- package/engine/behaviour/ability.lua +152 -26
- package/engine/behaviour/unit/stun-immunity.d.ts +7 -4
- package/engine/behaviour/unit/stun-immunity.lua +52 -27
- package/engine/behaviour/unit.d.ts +42 -2
- package/engine/behaviour/unit.lua +213 -0
- package/engine/buff.d.ts +104 -44
- package/engine/buff.lua +453 -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.d.ts +1 -3
- package/engine/internal/mechanics/ability-duration.lua +3 -1
- package/engine/internal/mechanics/cast-ability.d.ts +2 -0
- package/engine/internal/mechanics/cast-ability.lua +86 -0
- 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/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 +11 -8
- package/engine/internal/unit/bonus.lua +23 -1
- package/engine/internal/unit/detach-missiles.d.ts +7 -0
- package/engine/internal/unit/detach-missiles.lua +30 -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+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 +60 -13
- package/engine/internal/unit.d.ts +91 -24
- package/engine/internal/unit.lua +610 -212
- package/engine/internal/utility.lua +12 -0
- package/engine/lightning.d.ts +12 -5
- package/engine/lightning.lua +48 -14
- package/engine/local-client.d.ts +7 -2
- package/engine/local-client.lua +82 -0
- package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
- package/engine/object-data/auxiliary/animation-name.lua +16 -0
- package/engine/object-data/auxiliary/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 -3
- package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
- package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
- package/engine/object-data/auxiliary/attack-type.lua +42 -0
- package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
- package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
- package/engine/object-data/auxiliary/movement-type.lua +22 -0
- package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
- package/engine/object-data/auxiliary/sound-eax.lua +2 -0
- package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
- package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
- package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
- package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
- package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
- package/engine/object-data/entry/ability-type/berserk.lua +13 -0
- package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
- package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
- package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
- package/engine/object-data/entry/ability-type/blink.d.ts +10 -0
- package/engine/object-data/entry/ability-type/blink.lua +39 -0
- package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
- package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
- package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
- package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
- package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
- package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
- package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
- package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
- package/engine/object-data/entry/ability-type/mine.d.ts +10 -0
- package/engine/object-data/entry/ability-type/mine.lua +39 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
- package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
- package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
- package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
- package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
- package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
- package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
- package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
- package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
- package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
- package/engine/object-data/entry/ability-type/spirit-touch.d.ts +2 -2
- package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
- package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
- package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
- package/engine/object-data/entry/ability-type/web.d.ts +12 -0
- package/engine/object-data/entry/ability-type/web.lua +52 -0
- package/engine/object-data/entry/ability-type.d.ts +19 -18
- package/engine/object-data/entry/ability-type.lua +93 -36
- package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
- package/engine/object-data/entry/buff-type/applicable.lua +39 -102
- package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
- package/engine/object-data/entry/buff-type.d.ts +6 -13
- package/engine/object-data/entry/buff-type.lua +13 -29
- package/engine/object-data/entry/destructible-type.d.ts +1 -2
- package/engine/object-data/entry/item-type/blank.d.ts +0 -1
- package/engine/object-data/entry/item-type.d.ts +15 -2
- package/engine/object-data/entry/item-type.lua +93 -2
- package/engine/object-data/entry/lightning-type.d.ts +1 -2
- package/engine/object-data/entry/sound-preset.d.ts +33 -0
- package/engine/object-data/entry/sound-preset.lua +140 -0
- package/engine/object-data/entry/unit-type.d.ts +61 -5
- package/engine/object-data/entry/unit-type.lua +511 -62
- package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
- package/engine/object-data/entry/upgrade.d.ts +1 -2
- package/engine/object-data/entry/upgrade.lua +4 -4
- package/engine/object-data/entry.d.ts +18 -17
- package/engine/object-data/entry.lua +60 -32
- package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
- package/engine/object-field/ability.d.ts +28 -5
- package/engine/object-field/ability.lua +59 -5
- package/engine/object-field/unit.d.ts +57 -3
- package/engine/object-field/unit.lua +207 -7
- package/engine/object-field.d.ts +17 -7
- package/engine/object-field.lua +190 -90
- package/engine/random.d.ts +10 -0
- package/engine/random.lua +22 -0
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- package/engine/standard/entries/sound-preset.d.ts +10 -0
- package/engine/standard/entries/sound-preset.lua +10 -0
- package/engine/standard/entries/unit-type.d.ts +42 -1
- package/engine/standard/entries/unit-type.lua +42 -1
- package/engine/standard/fields/ability.d.ts +3 -1
- package/engine/standard/fields/ability.lua +3 -1
- package/engine/standard/fields/unit.d.ts +4 -0
- package/engine/standard/fields/unit.lua +7 -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 +249 -10
- package/engine/unit.d.ts +5 -0
- package/engine/unit.lua +14 -2
- package/event.d.ts +2 -3
- package/event.lua +9 -5
- package/global/vec2.lua +1 -0
- package/index.d.ts +1 -0
- package/index.lua +1 -0
- package/lualib_bundle.lua +146 -42
- package/math/vec2.d.ts +2 -9
- package/math.d.ts +0 -2
- package/net/socket.d.ts +7 -1
- package/net/socket.lua +45 -4
- package/network.d.ts +1 -0
- package/network.lua +3 -2
- package/objutil/ability.d.ts +0 -1
- package/objutil/buff.d.ts +0 -1
- package/objutil/buff.lua +3 -4
- package/objutil/object.d.ts +0 -1
- package/objutil/unit.d.ts +0 -1
- package/objutil/unit.lua +8 -0
- package/package.json +13 -14
- package/patch-lua.d.ts +0 -0
- package/patch-lua.lua +10 -0
- package/patch-lualib.lua +1 -1
- package/property.d.ts +55 -0
- package/property.lua +374 -0
- package/string.d.ts +30 -0
- package/string.lua +14 -0
- package/util/stream.d.ts +0 -1
- package/utility/arrays.d.ts +13 -5
- package/utility/arrays.lua +45 -3
- package/utility/bit-set.d.ts +0 -2
- 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 -3
- package/utility/linked-set.lua +27 -3
- package/utility/lua-maps.d.ts +16 -4
- package/utility/lua-maps.lua +53 -2
- package/utility/lua-sets.d.ts +3 -2
- package/utility/lua-sets.lua +7 -0
- package/utility/reflection.lua +11 -7
- package/utility/types.d.ts +6 -2
- package/core/mapbounds.d.ts +0 -8
- package/core/mapbounds.lua +0 -12
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
package/engine/internal/unit.lua
CHANGED
|
@@ -5,9 +5,12 @@ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
|
5
5
|
local __TS__New = ____lualib.__TS__New
|
|
6
6
|
local __TS__Class = ____lualib.__TS__Class
|
|
7
7
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
8
|
+
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
8
9
|
local __TS__ArraySetLength = ____lualib.__TS__ArraySetLength
|
|
10
|
+
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
|
|
11
|
+
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
|
|
12
|
+
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
|
|
9
13
|
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
10
|
-
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
11
14
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
12
15
|
local Set = ____lualib.Set
|
|
13
16
|
local __TS__Spread = ____lualib.__TS__Spread
|
|
@@ -48,12 +51,21 @@ local ____arrays = require("utility.arrays")
|
|
|
48
51
|
local forEach = ____arrays.forEach
|
|
49
52
|
local ____math = require("math")
|
|
50
53
|
local min = ____math.min
|
|
54
|
+
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
55
|
+
local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
56
|
+
local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
|
|
57
|
+
local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
|
|
58
|
+
local nativeToAttackType = ____attack_2Dtype.nativeToAttackType
|
|
59
|
+
local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
|
|
60
|
+
local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
|
|
61
|
+
local ____attributes = require("attributes")
|
|
62
|
+
local isAttribute = ____attributes.isAttribute
|
|
63
|
+
local ____ability = require("engine.internal.item.ability")
|
|
64
|
+
local doUnitAbilityAction = ____ability.doUnitAbilityAction
|
|
51
65
|
local match = string.match
|
|
52
66
|
local ____tostring = _G.tostring
|
|
53
67
|
local setUnitAnimation = SetUnitAnimation
|
|
54
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
55
68
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
56
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
57
69
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
58
70
|
local getUnitRealField = BlzGetUnitRealField
|
|
59
71
|
local getHeroStr = GetHeroStr
|
|
@@ -72,9 +84,9 @@ local setUnitScale = SetUnitScale
|
|
|
72
84
|
local setUnitPosition = SetUnitPosition
|
|
73
85
|
local setUnitTimeScale = SetUnitTimeScale
|
|
74
86
|
local getHandleId = GetHandleId
|
|
87
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
75
88
|
local createUnit = CreateUnit
|
|
76
89
|
local killUnit = KillUnit
|
|
77
|
-
local setUnitExploded = SetUnitExploded
|
|
78
90
|
local removeUnit = RemoveUnit
|
|
79
91
|
local getUnitTypeId = GetUnitTypeId
|
|
80
92
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -90,8 +102,10 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
90
102
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
91
103
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
92
104
|
local isUnitInRange = IsUnitInRange
|
|
93
|
-
local
|
|
94
|
-
local
|
|
105
|
+
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
106
|
+
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
107
|
+
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
108
|
+
local setUnitWeaponStringField = BlzSetUnitWeaponStringField
|
|
95
109
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
96
110
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
97
111
|
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
@@ -111,15 +125,9 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
111
125
|
local getIssuedOrderId = GetIssuedOrderId
|
|
112
126
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
113
127
|
local unitAlive = UnitAlive
|
|
114
|
-
local unitAddType = UnitAddType
|
|
115
|
-
local unitRemoveType = UnitRemoveType
|
|
116
|
-
local isUnitIllusion = IsUnitIllusion
|
|
117
|
-
local isUnitType = IsUnitType
|
|
118
128
|
local isUnitAlly = IsUnitAlly
|
|
119
129
|
local isUnitEnemy = IsUnitEnemy
|
|
120
130
|
local getOwningPlayer = GetOwningPlayer
|
|
121
|
-
local setUnitColor = SetUnitColor
|
|
122
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
123
131
|
____exports.UnitClassification = {}
|
|
124
132
|
local UnitClassification = ____exports.UnitClassification
|
|
125
133
|
do
|
|
@@ -129,6 +137,7 @@ do
|
|
|
129
137
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
130
138
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
131
139
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
140
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
132
141
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
133
142
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
134
143
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -275,16 +284,14 @@ function UnitTriggerEvent.prototype.____constructor(self, eventType, c)
|
|
|
275
284
|
end
|
|
276
285
|
local function dispatch(event, idGetter, argsGetter)
|
|
277
286
|
local initialized = false
|
|
278
|
-
local x = {}
|
|
279
287
|
return setmetatable(
|
|
280
|
-
|
|
288
|
+
{},
|
|
281
289
|
{
|
|
282
290
|
__index = function(self, id)
|
|
283
291
|
if type(id) ~= "number" then
|
|
284
292
|
return event[id]
|
|
285
293
|
end
|
|
286
294
|
if not initialized then
|
|
287
|
-
local invoke = Event.invoke
|
|
288
295
|
event:addListener(function(...)
|
|
289
296
|
local id = idGetter(...)
|
|
290
297
|
local dispatched = rawget(self, id)
|
|
@@ -322,7 +329,6 @@ local function dispatchAbility(event)
|
|
|
322
329
|
return event[id]
|
|
323
330
|
end
|
|
324
331
|
if not initialized then
|
|
325
|
-
local invoke = Event.invoke
|
|
326
332
|
event:addListener(function(unit, ability, ...)
|
|
327
333
|
local dispatched = rawget(self, ability.typeId)
|
|
328
334
|
if dispatched ~= nil then
|
|
@@ -339,6 +345,9 @@ local function dispatchAbility(event)
|
|
|
339
345
|
}
|
|
340
346
|
)
|
|
341
347
|
end
|
|
348
|
+
local function damagingEventPreventRetaliation(self)
|
|
349
|
+
self[0] = true
|
|
350
|
+
end
|
|
342
351
|
local function damageEventPreventDeath(self, callback, ...)
|
|
343
352
|
if self[0] ~= nil then
|
|
344
353
|
return
|
|
@@ -350,7 +359,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
350
359
|
rawset(self, 1 + i, (select(i, ...)))
|
|
351
360
|
end
|
|
352
361
|
end
|
|
353
|
-
local damageSetters = {
|
|
362
|
+
local damageSetters = {
|
|
363
|
+
amount = BlzSetEventDamage,
|
|
364
|
+
attackType = function(attackType)
|
|
365
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
366
|
+
end,
|
|
367
|
+
damageType = BlzSetEventDamageType,
|
|
368
|
+
weaponType = BlzSetEventWeaponType
|
|
369
|
+
}
|
|
354
370
|
local jlimitopByOperator = {
|
|
355
371
|
[0] = LESS_THAN_OR_EQUAL,
|
|
356
372
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -387,51 +403,184 @@ local getters = {
|
|
|
387
403
|
return BlzGetUnitArmor(unit)
|
|
388
404
|
end
|
|
389
405
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
406
|
+
____exports.UnitWeapon = __TS__Class()
|
|
407
|
+
local UnitWeapon = ____exports.UnitWeapon
|
|
408
|
+
UnitWeapon.name = "UnitWeapon"
|
|
409
|
+
function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
410
|
+
self.unit = unit
|
|
411
|
+
self.index = index
|
|
412
|
+
end
|
|
413
|
+
__TS__SetDescriptor(
|
|
414
|
+
UnitWeapon.prototype,
|
|
415
|
+
"isEnabled",
|
|
416
|
+
{
|
|
417
|
+
get = function(self)
|
|
418
|
+
return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
|
|
419
|
+
end,
|
|
420
|
+
set = function(self, isEnabled)
|
|
421
|
+
BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
|
|
422
|
+
end
|
|
423
|
+
},
|
|
424
|
+
true
|
|
425
|
+
)
|
|
426
|
+
__TS__SetDescriptor(
|
|
427
|
+
UnitWeapon.prototype,
|
|
428
|
+
"cooldown",
|
|
429
|
+
{
|
|
430
|
+
get = function(self)
|
|
431
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index)
|
|
432
|
+
end,
|
|
433
|
+
set = function(self, cooldown)
|
|
434
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index, cooldown)
|
|
435
|
+
end
|
|
436
|
+
},
|
|
437
|
+
true
|
|
438
|
+
)
|
|
439
|
+
__TS__SetDescriptor(
|
|
440
|
+
UnitWeapon.prototype,
|
|
441
|
+
"damage",
|
|
442
|
+
{
|
|
443
|
+
get = function(self)
|
|
444
|
+
local minimumDamage = self.damageBase + self.damageDiceCount
|
|
445
|
+
local maximumDamage = self.damageBase + self.damageDiceCount * self.damageDiceSideCount
|
|
446
|
+
return {minimumDamage, maximumDamage}
|
|
447
|
+
end,
|
|
448
|
+
set = function(self, ____bindingPattern0)
|
|
449
|
+
local maximumDamage
|
|
450
|
+
local minimumDamage
|
|
451
|
+
minimumDamage = ____bindingPattern0[1]
|
|
452
|
+
maximumDamage = ____bindingPattern0[2]
|
|
453
|
+
self.damageBase = minimumDamage - 1
|
|
454
|
+
self.damageDiceCount = 1
|
|
455
|
+
self.damageDiceSideCount = maximumDamage - minimumDamage + 1
|
|
456
|
+
end
|
|
457
|
+
},
|
|
458
|
+
true
|
|
459
|
+
)
|
|
460
|
+
__TS__SetDescriptor(
|
|
461
|
+
UnitWeapon.prototype,
|
|
462
|
+
"allowedTargetCombatClassifications",
|
|
463
|
+
{
|
|
464
|
+
get = function(self)
|
|
465
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
466
|
+
end,
|
|
467
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
468
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
469
|
+
end
|
|
470
|
+
},
|
|
471
|
+
true
|
|
472
|
+
)
|
|
473
|
+
__TS__SetDescriptor(
|
|
474
|
+
UnitWeapon.prototype,
|
|
475
|
+
"damageBase",
|
|
476
|
+
{
|
|
477
|
+
get = function(self)
|
|
478
|
+
return BlzGetUnitBaseDamage(self.unit.handle, self.index)
|
|
479
|
+
end,
|
|
480
|
+
set = function(self, damageBase)
|
|
481
|
+
BlzSetUnitBaseDamage(self.unit.handle, self.index, damageBase)
|
|
482
|
+
end
|
|
483
|
+
},
|
|
484
|
+
true
|
|
485
|
+
)
|
|
486
|
+
__TS__SetDescriptor(
|
|
487
|
+
UnitWeapon.prototype,
|
|
488
|
+
"damageDiceCount",
|
|
489
|
+
{
|
|
490
|
+
get = function(self)
|
|
491
|
+
return BlzGetUnitDiceNumber(self.unit.handle, self.index)
|
|
492
|
+
end,
|
|
493
|
+
set = function(self, damageDiceCount)
|
|
494
|
+
BlzSetUnitDiceNumber(self.unit.handle, self.index, damageDiceCount)
|
|
495
|
+
end
|
|
496
|
+
},
|
|
497
|
+
true
|
|
498
|
+
)
|
|
499
|
+
__TS__SetDescriptor(
|
|
500
|
+
UnitWeapon.prototype,
|
|
501
|
+
"damageDiceSideCount",
|
|
502
|
+
{
|
|
503
|
+
get = function(self)
|
|
504
|
+
return BlzGetUnitDiceSides(self.unit.handle, self.index)
|
|
505
|
+
end,
|
|
506
|
+
set = function(self, damageDiceSideCount)
|
|
507
|
+
BlzSetUnitDiceSides(self.unit.handle, self.index, damageDiceSideCount)
|
|
508
|
+
end
|
|
509
|
+
},
|
|
510
|
+
true
|
|
511
|
+
)
|
|
512
|
+
__TS__SetDescriptor(
|
|
513
|
+
UnitWeapon.prototype,
|
|
514
|
+
"range",
|
|
515
|
+
{
|
|
516
|
+
get = function(self)
|
|
517
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_RANGE, self.index)
|
|
518
|
+
end,
|
|
519
|
+
set = function(self, range)
|
|
520
|
+
local handle = self.unit.handle
|
|
521
|
+
local index = self.index
|
|
522
|
+
setUnitWeaponRealField(
|
|
523
|
+
handle,
|
|
524
|
+
UNIT_WEAPON_RF_ATTACK_RANGE,
|
|
525
|
+
index + 1,
|
|
526
|
+
getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index + 1) + (range - getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index))
|
|
527
|
+
)
|
|
528
|
+
end
|
|
529
|
+
},
|
|
530
|
+
true
|
|
531
|
+
)
|
|
532
|
+
__TS__SetDescriptor(
|
|
533
|
+
UnitWeapon.prototype,
|
|
534
|
+
"impactDelay",
|
|
535
|
+
{
|
|
536
|
+
get = function(self)
|
|
537
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index)
|
|
538
|
+
end,
|
|
539
|
+
set = function(self, impactDelay)
|
|
540
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index, impactDelay)
|
|
541
|
+
end
|
|
542
|
+
},
|
|
543
|
+
true
|
|
544
|
+
)
|
|
545
|
+
__TS__SetDescriptor(
|
|
546
|
+
UnitWeapon.prototype,
|
|
547
|
+
"missileArc",
|
|
548
|
+
{
|
|
549
|
+
get = function(self)
|
|
550
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index)
|
|
551
|
+
end,
|
|
552
|
+
set = function(self, missileArc)
|
|
553
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index, missileArc)
|
|
554
|
+
end
|
|
555
|
+
},
|
|
556
|
+
true
|
|
557
|
+
)
|
|
558
|
+
__TS__SetDescriptor(
|
|
559
|
+
UnitWeapon.prototype,
|
|
560
|
+
"missileModelPath",
|
|
561
|
+
{
|
|
562
|
+
get = function(self)
|
|
563
|
+
return getUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index)
|
|
564
|
+
end,
|
|
565
|
+
set = function(self, missileModelPath)
|
|
566
|
+
setUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index, missileModelPath)
|
|
567
|
+
end
|
|
568
|
+
},
|
|
569
|
+
true
|
|
570
|
+
)
|
|
571
|
+
__TS__SetDescriptor(
|
|
572
|
+
UnitWeapon.prototype,
|
|
573
|
+
"missileSpeed",
|
|
574
|
+
{
|
|
575
|
+
get = function(self)
|
|
576
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index)
|
|
577
|
+
end,
|
|
578
|
+
set = function(self, missileSpeed)
|
|
579
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index, missileSpeed)
|
|
580
|
+
end
|
|
581
|
+
},
|
|
582
|
+
true
|
|
583
|
+
)
|
|
435
584
|
local unitInventorySize = UnitInventorySize
|
|
436
585
|
local unitItemInSlot = UnitItemInSlot
|
|
437
586
|
local getItemAbility = BlzGetItemAbility
|
|
@@ -442,8 +591,6 @@ local getAbilityName = GetAbilityName
|
|
|
442
591
|
local unitAddAbility = UnitAddAbility
|
|
443
592
|
local getUnitGoldCost = GetUnitGoldCost
|
|
444
593
|
local getUnitLumberCost = GetUnitWoodCost
|
|
445
|
-
local unitMakeAbilityPermanent = UnitMakeAbilityPermanent
|
|
446
|
-
local unitAddItem = UnitAddItem
|
|
447
594
|
local unitRemoveAbility = UnitRemoveAbility
|
|
448
595
|
local function retrieveAbility(unit, ability, abilityId)
|
|
449
596
|
if ability == nil then
|
|
@@ -453,17 +600,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
453
600
|
____exports.Unit:of(unit)
|
|
454
601
|
)
|
|
455
602
|
end
|
|
456
|
-
if not unitAddAbility(unit, abilityId) then
|
|
457
|
-
if getUnitAbility(unit, abilityId) == ability then
|
|
458
|
-
return UnitAbility:of(
|
|
459
|
-
ability,
|
|
460
|
-
abilityId,
|
|
461
|
-
____exports.Unit:of(unit)
|
|
462
|
-
)
|
|
463
|
-
end
|
|
464
|
-
else
|
|
465
|
-
unitRemoveAbility(unit, abilityId)
|
|
466
|
-
end
|
|
467
603
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
468
604
|
local item = unitItemInSlot(unit, i)
|
|
469
605
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -520,12 +656,44 @@ for ____, player in ipairs(Player.all) do
|
|
|
520
656
|
ShowUnit(dummy, false)
|
|
521
657
|
dummies[player] = dummy
|
|
522
658
|
end
|
|
659
|
+
local function delayHealthChecksCallback(unit)
|
|
660
|
+
local counter = (unit[103] or 0) - 1
|
|
661
|
+
if counter ~= 0 then
|
|
662
|
+
unit[103] = counter
|
|
663
|
+
return
|
|
664
|
+
end
|
|
665
|
+
unit[103] = nil
|
|
666
|
+
local healthBonus = unit[104]
|
|
667
|
+
if healthBonus ~= nil then
|
|
668
|
+
unit[104] = nil
|
|
669
|
+
local handle = unit.handle
|
|
670
|
+
BlzSetUnitMaxHP(
|
|
671
|
+
handle,
|
|
672
|
+
BlzGetUnitMaxHP(handle) - healthBonus
|
|
673
|
+
)
|
|
674
|
+
end
|
|
675
|
+
end
|
|
676
|
+
local nextSyncId = 1
|
|
677
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
678
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
679
|
+
local function addAbility(unit, abilityTypeId)
|
|
680
|
+
local ____unitAddAbility_result_0
|
|
681
|
+
if unitAddAbility(unit, abilityTypeId) then
|
|
682
|
+
____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
|
|
683
|
+
else
|
|
684
|
+
____unitAddAbility_result_0 = nil
|
|
685
|
+
end
|
|
686
|
+
return ____unitAddAbility_result_0
|
|
687
|
+
end
|
|
523
688
|
____exports.Unit = __TS__Class()
|
|
524
689
|
local Unit = ____exports.Unit
|
|
525
690
|
Unit.name = "Unit"
|
|
526
691
|
__TS__ClassExtends(Unit, Handle)
|
|
527
692
|
function Unit.prototype.____constructor(self, handle)
|
|
528
693
|
Handle.prototype.____constructor(self, handle)
|
|
694
|
+
local ____nextSyncId_1 = nextSyncId
|
|
695
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
696
|
+
self.syncId = ____nextSyncId_1
|
|
529
697
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
530
698
|
assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
|
|
531
699
|
assert(unitAddAbility(handle, morphDetectAbilityId))
|
|
@@ -538,6 +706,7 @@ function Unit.prototype.____constructor(self, handle)
|
|
|
538
706
|
fourCC("Amrf")
|
|
539
707
|
))
|
|
540
708
|
end
|
|
709
|
+
unitBySyncId[self.syncId] = self
|
|
541
710
|
local ____ = self.abilities
|
|
542
711
|
end
|
|
543
712
|
function Unit.prototype.getEvent(self, event, collector)
|
|
@@ -556,6 +725,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
556
725
|
end
|
|
557
726
|
function Unit.prototype.onDestroy(self)
|
|
558
727
|
local handle = self.handle
|
|
728
|
+
self[107] = getUnitX(handle)
|
|
729
|
+
self[108] = getUnitY(handle)
|
|
559
730
|
if not self._owner then
|
|
560
731
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
561
732
|
end
|
|
@@ -623,17 +794,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
623
794
|
end}
|
|
624
795
|
end
|
|
625
796
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
626
|
-
local
|
|
627
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
797
|
+
local ____combatClassification_2 = combatClassification
|
|
798
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
|
|
628
799
|
end
|
|
629
800
|
function Unit.prototype.addClassification(self, classification)
|
|
630
|
-
return
|
|
801
|
+
return UnitAddType(self.handle, classification)
|
|
631
802
|
end
|
|
632
803
|
function Unit.prototype.removeClassification(self, classification)
|
|
633
|
-
return
|
|
804
|
+
return UnitRemoveType(self.handle, classification)
|
|
634
805
|
end
|
|
635
806
|
function Unit.prototype.hasClassification(self, classification)
|
|
636
|
-
return
|
|
807
|
+
return IsUnitType(self.handle, classification)
|
|
637
808
|
end
|
|
638
809
|
function Unit.prototype.isVisibleTo(self, player)
|
|
639
810
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -642,13 +813,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
642
813
|
return isUnitInvisible(self.handle, player.handle)
|
|
643
814
|
end
|
|
644
815
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
645
|
-
local
|
|
816
|
+
local ____temp_3
|
|
646
817
|
if type(x) == "number" then
|
|
647
|
-
|
|
818
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
648
819
|
else
|
|
649
|
-
|
|
820
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
650
821
|
end
|
|
651
|
-
return
|
|
822
|
+
return ____temp_3
|
|
652
823
|
end
|
|
653
824
|
function Unit.prototype.isAllyOf(self, unit)
|
|
654
825
|
return isUnitAlly(
|
|
@@ -666,13 +837,31 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
666
837
|
if type(animation) == "number" then
|
|
667
838
|
setUnitAnimationByIndex(self.handle, animation)
|
|
668
839
|
elseif rarity then
|
|
669
|
-
|
|
840
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
670
841
|
else
|
|
671
842
|
setUnitAnimation(self.handle, animation)
|
|
672
843
|
end
|
|
673
844
|
end
|
|
845
|
+
function Unit.prototype.resetAnimation(self)
|
|
846
|
+
ResetUnitAnimation(self.handle)
|
|
847
|
+
end
|
|
674
848
|
function Unit.prototype.queueAnimation(self, animation)
|
|
675
|
-
|
|
849
|
+
QueueUnitAnimation(self.handle, animation)
|
|
850
|
+
end
|
|
851
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
852
|
+
local firstWeapon = self.firstWeapon
|
|
853
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
854
|
+
return firstWeapon
|
|
855
|
+
end
|
|
856
|
+
local secondWeapon = self.secondWeapon
|
|
857
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
858
|
+
return secondWeapon
|
|
859
|
+
end
|
|
860
|
+
return nil
|
|
861
|
+
end
|
|
862
|
+
function Unit.prototype.delayHealthChecks(self)
|
|
863
|
+
self[103] = (self[103] or 0) + 1
|
|
864
|
+
Timer:run(delayHealthChecksCallback, self)
|
|
676
865
|
end
|
|
677
866
|
function Unit.prototype.setPosition(self, x, y)
|
|
678
867
|
setUnitPosition(self.handle, x, y)
|
|
@@ -681,14 +870,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
681
870
|
return IsUnitSelected(self.handle, player.handle)
|
|
682
871
|
end
|
|
683
872
|
function Unit.prototype.explode(self)
|
|
684
|
-
|
|
873
|
+
SetUnitExploded(self.handle, true)
|
|
685
874
|
killUnit(self.handle)
|
|
686
875
|
end
|
|
687
876
|
function Unit.prototype.kill(self)
|
|
688
877
|
killUnit(self.handle)
|
|
689
878
|
end
|
|
690
|
-
function Unit.prototype.revive(self,
|
|
691
|
-
|
|
879
|
+
function Unit.prototype.revive(self, x, y, doEffect)
|
|
880
|
+
local ____ReviveHero_6 = ReviveHero
|
|
881
|
+
local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
|
|
882
|
+
local ____doEffect_4 = doEffect
|
|
883
|
+
if ____doEffect_4 == nil then
|
|
884
|
+
____doEffect_4 = false
|
|
885
|
+
end
|
|
886
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
887
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
692
888
|
end
|
|
693
889
|
function Unit.prototype.healTarget(self, target, amount)
|
|
694
890
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -728,20 +924,19 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
728
924
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
729
925
|
end
|
|
730
926
|
function Unit.prototype.itemInSlot(self, slot)
|
|
731
|
-
return Item:of(
|
|
927
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
732
928
|
end
|
|
733
929
|
function Unit.prototype.addAbility(self, abilityId)
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
930
|
+
local ability = UnitAbility:of(
|
|
931
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
932
|
+
abilityId,
|
|
933
|
+
self
|
|
934
|
+
)
|
|
935
|
+
if ability ~= nil then
|
|
740
936
|
local abilities = self.abilities
|
|
741
937
|
abilities[#abilities + 1] = ability
|
|
742
|
-
return ability
|
|
743
938
|
end
|
|
744
|
-
return
|
|
939
|
+
return ability
|
|
745
940
|
end
|
|
746
941
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
747
942
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -755,47 +950,62 @@ end
|
|
|
755
950
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
756
951
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
757
952
|
end
|
|
758
|
-
function Unit.prototype.
|
|
759
|
-
local
|
|
760
|
-
|
|
761
|
-
assert(unitRemoveAbility(handle, abilityId))
|
|
762
|
-
return nil
|
|
763
|
-
end
|
|
764
|
-
return UnitAbility:of(
|
|
765
|
-
getUnitAbility(self.handle, abilityId),
|
|
766
|
-
abilityId,
|
|
767
|
-
self
|
|
768
|
-
)
|
|
953
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
954
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
955
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
769
956
|
end
|
|
770
|
-
function Unit.prototype.removeAbility(self,
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
end
|
|
957
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
958
|
+
local abilities = self.abilities
|
|
959
|
+
for i = 1, #abilities do
|
|
960
|
+
if abilities[i].typeId == abilityTypeId then
|
|
961
|
+
local ability = abilities[i]
|
|
962
|
+
tremove(abilities, i)
|
|
963
|
+
ability:destroy()
|
|
964
|
+
return true
|
|
779
965
|
end
|
|
780
|
-
return true
|
|
781
966
|
end
|
|
782
|
-
return
|
|
967
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
783
968
|
end
|
|
784
969
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
785
970
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
786
971
|
end
|
|
972
|
+
function Unit.prototype.getAbilityRemainingCooldown(self, abilityId)
|
|
973
|
+
return BlzGetUnitAbilityCooldownRemaining(self.handle, abilityId)
|
|
974
|
+
end
|
|
787
975
|
function Unit.prototype.startAbilityCooldown(self, abilityId, cooldown)
|
|
788
976
|
BlzStartUnitAbilityCooldown(self.handle, abilityId, cooldown)
|
|
789
977
|
end
|
|
790
978
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
791
979
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
792
980
|
end
|
|
981
|
+
function Unit.prototype.interruptMovement(self)
|
|
982
|
+
local handle = self.handle
|
|
983
|
+
unitDisableAbility(
|
|
984
|
+
handle,
|
|
985
|
+
fourCC("Amov"),
|
|
986
|
+
true,
|
|
987
|
+
false
|
|
988
|
+
)
|
|
989
|
+
unitDisableAbility(
|
|
990
|
+
handle,
|
|
991
|
+
fourCC("Amov"),
|
|
992
|
+
false,
|
|
993
|
+
false
|
|
994
|
+
)
|
|
995
|
+
end
|
|
793
996
|
function Unit.prototype.interruptAttack(self)
|
|
794
997
|
unitInterruptAttack(self.handle)
|
|
795
998
|
end
|
|
796
999
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
797
|
-
|
|
798
|
-
unitDisableAbility(
|
|
1000
|
+
local handle = self.handle
|
|
1001
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
1002
|
+
Timer:run(
|
|
1003
|
+
unitDisableAbility,
|
|
1004
|
+
handle,
|
|
1005
|
+
abilityId,
|
|
1006
|
+
false,
|
|
1007
|
+
false
|
|
1008
|
+
)
|
|
799
1009
|
end
|
|
800
1010
|
function Unit.prototype.getDistanceTo(self, target)
|
|
801
1011
|
local handle = self.handle
|
|
@@ -855,18 +1065,18 @@ function Unit.prototype.unpauseEx(self)
|
|
|
855
1065
|
self:decrementStunCounter()
|
|
856
1066
|
end
|
|
857
1067
|
function Unit.prototype.incrementStunCounter(self)
|
|
858
|
-
local stunCounter = self[
|
|
859
|
-
if not self[
|
|
1068
|
+
local stunCounter = self[102] or 0
|
|
1069
|
+
if not self[101] or stunCounter >= 0 then
|
|
860
1070
|
BlzPauseUnitEx(self.handle, true)
|
|
861
1071
|
end
|
|
862
|
-
self[
|
|
1072
|
+
self[102] = stunCounter + 1
|
|
863
1073
|
end
|
|
864
1074
|
function Unit.prototype.decrementStunCounter(self)
|
|
865
|
-
local stunCounter = self[
|
|
866
|
-
if not self[
|
|
1075
|
+
local stunCounter = self[102] or 0
|
|
1076
|
+
if not self[101] or stunCounter >= 1 then
|
|
867
1077
|
BlzPauseUnitEx(self.handle, false)
|
|
868
1078
|
end
|
|
869
|
-
self[
|
|
1079
|
+
self[102] = stunCounter - 1
|
|
870
1080
|
end
|
|
871
1081
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
872
1082
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -968,8 +1178,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
968
1178
|
)
|
|
969
1179
|
return targetCollection
|
|
970
1180
|
end
|
|
971
|
-
function Unit.getSelectionOf(self, player)
|
|
972
|
-
|
|
1181
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1182
|
+
if target == nil then
|
|
1183
|
+
target = {}
|
|
1184
|
+
end
|
|
1185
|
+
targetCollection = target
|
|
973
1186
|
targetCollectionNextIndex = 1
|
|
974
1187
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
975
1188
|
return targetCollection
|
|
@@ -991,6 +1204,9 @@ end
|
|
|
991
1204
|
function Unit.prototype.__tostring(self)
|
|
992
1205
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
993
1206
|
end
|
|
1207
|
+
function Unit.getBySyncId(self, syncId)
|
|
1208
|
+
return unitBySyncId[syncId]
|
|
1209
|
+
end
|
|
994
1210
|
__TS__SetDescriptor(
|
|
995
1211
|
Unit.prototype,
|
|
996
1212
|
"_deltas",
|
|
@@ -1050,7 +1266,15 @@ __TS__SetDescriptor(
|
|
|
1050
1266
|
Unit.prototype,
|
|
1051
1267
|
"isIllusion",
|
|
1052
1268
|
{get = function(self)
|
|
1053
|
-
return
|
|
1269
|
+
return IsUnitIllusion(self.handle)
|
|
1270
|
+
end},
|
|
1271
|
+
true
|
|
1272
|
+
)
|
|
1273
|
+
__TS__SetDescriptor(
|
|
1274
|
+
Unit.prototype,
|
|
1275
|
+
"isStunned",
|
|
1276
|
+
{get = function(self)
|
|
1277
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1054
1278
|
end},
|
|
1055
1279
|
true
|
|
1056
1280
|
)
|
|
@@ -1071,12 +1295,27 @@ __TS__SetDescriptor(
|
|
|
1071
1295
|
Unit.prototype,
|
|
1072
1296
|
"weapons",
|
|
1073
1297
|
{get = function(self)
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1298
|
+
return {self.firstWeapon, self.secondWeapon}
|
|
1299
|
+
end},
|
|
1300
|
+
true
|
|
1301
|
+
)
|
|
1302
|
+
__TS__SetDescriptor(
|
|
1303
|
+
Unit.prototype,
|
|
1304
|
+
"firstWeapon",
|
|
1305
|
+
{get = function(self)
|
|
1306
|
+
local weapon = __TS__New(____exports.UnitWeapon, self, 0)
|
|
1307
|
+
rawset(self, "firstWeapon", weapon)
|
|
1308
|
+
return weapon
|
|
1309
|
+
end},
|
|
1310
|
+
true
|
|
1311
|
+
)
|
|
1312
|
+
__TS__SetDescriptor(
|
|
1313
|
+
Unit.prototype,
|
|
1314
|
+
"secondWeapon",
|
|
1315
|
+
{get = function(self)
|
|
1316
|
+
local weapon = __TS__New(____exports.UnitWeapon, self, 1)
|
|
1317
|
+
rawset(self, "secondWeapon", weapon)
|
|
1318
|
+
return weapon
|
|
1080
1319
|
end},
|
|
1081
1320
|
true
|
|
1082
1321
|
)
|
|
@@ -1112,6 +1351,19 @@ __TS__SetDescriptor(
|
|
|
1112
1351
|
},
|
|
1113
1352
|
true
|
|
1114
1353
|
)
|
|
1354
|
+
__TS__SetDescriptor(
|
|
1355
|
+
Unit.prototype,
|
|
1356
|
+
"primaryAttribute",
|
|
1357
|
+
{
|
|
1358
|
+
get = function(self)
|
|
1359
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1360
|
+
end,
|
|
1361
|
+
set = function(self, primaryAttribute)
|
|
1362
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1363
|
+
end
|
|
1364
|
+
},
|
|
1365
|
+
true
|
|
1366
|
+
)
|
|
1115
1367
|
__TS__SetDescriptor(
|
|
1116
1368
|
Unit.prototype,
|
|
1117
1369
|
"strengthBase",
|
|
@@ -1233,17 +1485,17 @@ __TS__SetDescriptor(
|
|
|
1233
1485
|
"isTeamGlowVisible",
|
|
1234
1486
|
{
|
|
1235
1487
|
get = function(self)
|
|
1236
|
-
return not self[
|
|
1488
|
+
return not self[106]
|
|
1237
1489
|
end,
|
|
1238
1490
|
set = function(self, isTeamGlowVisible)
|
|
1239
|
-
|
|
1240
|
-
local
|
|
1491
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1492
|
+
local ____temp_7
|
|
1241
1493
|
if not isTeamGlowVisible then
|
|
1242
|
-
|
|
1494
|
+
____temp_7 = true
|
|
1243
1495
|
else
|
|
1244
|
-
|
|
1496
|
+
____temp_7 = nil
|
|
1245
1497
|
end
|
|
1246
|
-
self[
|
|
1498
|
+
self[106] = ____temp_7
|
|
1247
1499
|
end
|
|
1248
1500
|
},
|
|
1249
1501
|
true
|
|
@@ -1252,9 +1504,9 @@ __TS__SetDescriptor(
|
|
|
1252
1504
|
Unit.prototype,
|
|
1253
1505
|
"color",
|
|
1254
1506
|
{set = function(self, color)
|
|
1255
|
-
|
|
1256
|
-
if self[
|
|
1257
|
-
|
|
1507
|
+
SetUnitColor(self.handle, color.handle)
|
|
1508
|
+
if self[106] then
|
|
1509
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1258
1510
|
end
|
|
1259
1511
|
end},
|
|
1260
1512
|
true
|
|
@@ -1277,10 +1529,14 @@ __TS__SetDescriptor(
|
|
|
1277
1529
|
"maxHealth",
|
|
1278
1530
|
{
|
|
1279
1531
|
get = function(self)
|
|
1280
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1532
|
+
return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
|
|
1281
1533
|
end,
|
|
1282
1534
|
set = function(self, maxHealth)
|
|
1283
|
-
|
|
1535
|
+
if maxHealth < 1 and self[103] ~= nil then
|
|
1536
|
+
self[104] = (self[104] or 0) + (1 - maxHealth)
|
|
1537
|
+
maxHealth = 1
|
|
1538
|
+
end
|
|
1539
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
|
|
1284
1540
|
end
|
|
1285
1541
|
},
|
|
1286
1542
|
true
|
|
@@ -1322,10 +1578,10 @@ __TS__SetDescriptor(
|
|
|
1322
1578
|
"health",
|
|
1323
1579
|
{
|
|
1324
1580
|
get = function(self)
|
|
1325
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1581
|
+
return GetWidgetLife(self.handle) - (self[105] or 0)
|
|
1326
1582
|
end,
|
|
1327
1583
|
set = function(self, health)
|
|
1328
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1584
|
+
SetWidgetLife(self.handle, health + (self[105] or 0))
|
|
1329
1585
|
end
|
|
1330
1586
|
},
|
|
1331
1587
|
true
|
|
@@ -1419,7 +1675,7 @@ __TS__SetDescriptor(
|
|
|
1419
1675
|
"x",
|
|
1420
1676
|
{
|
|
1421
1677
|
get = function(self)
|
|
1422
|
-
return getUnitX(self.handle)
|
|
1678
|
+
return self[107] or getUnitX(self.handle)
|
|
1423
1679
|
end,
|
|
1424
1680
|
set = function(self, v)
|
|
1425
1681
|
SetUnitX(self.handle, v)
|
|
@@ -1432,7 +1688,7 @@ __TS__SetDescriptor(
|
|
|
1432
1688
|
"y",
|
|
1433
1689
|
{
|
|
1434
1690
|
get = function(self)
|
|
1435
|
-
return getUnitY(self.handle)
|
|
1691
|
+
return self[108] or getUnitY(self.handle)
|
|
1436
1692
|
end,
|
|
1437
1693
|
set = function(self, v)
|
|
1438
1694
|
SetUnitY(self.handle, v)
|
|
@@ -1518,10 +1774,10 @@ __TS__SetDescriptor(
|
|
|
1518
1774
|
"gold",
|
|
1519
1775
|
{
|
|
1520
1776
|
get = function(self)
|
|
1521
|
-
return
|
|
1777
|
+
return GetResourceAmount(self.handle)
|
|
1522
1778
|
end,
|
|
1523
1779
|
set = function(self, gold)
|
|
1524
|
-
|
|
1780
|
+
SetResourceAmount(self.handle, gold)
|
|
1525
1781
|
end
|
|
1526
1782
|
},
|
|
1527
1783
|
true
|
|
@@ -1536,17 +1792,17 @@ __TS__SetDescriptor(
|
|
|
1536
1792
|
set = function(self, isPaused)
|
|
1537
1793
|
local handle = self.handle
|
|
1538
1794
|
if isPaused and not IsUnitPaused(handle) then
|
|
1539
|
-
self[
|
|
1540
|
-
for _ = self[
|
|
1795
|
+
self[101] = true
|
|
1796
|
+
for _ = self[102] or 0, -1 do
|
|
1541
1797
|
BlzPauseUnitEx(handle, true)
|
|
1542
1798
|
end
|
|
1543
1799
|
PauseUnit(handle, true)
|
|
1544
1800
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1545
1801
|
PauseUnit(handle, false)
|
|
1546
|
-
for _ = self[
|
|
1802
|
+
for _ = self[102] or 0, -1 do
|
|
1547
1803
|
BlzPauseUnitEx(handle, false)
|
|
1548
1804
|
end
|
|
1549
|
-
self[
|
|
1805
|
+
self[101] = nil
|
|
1550
1806
|
end
|
|
1551
1807
|
end
|
|
1552
1808
|
},
|
|
@@ -1649,6 +1905,19 @@ __TS__SetDescriptor(
|
|
|
1649
1905
|
end},
|
|
1650
1906
|
true
|
|
1651
1907
|
)
|
|
1908
|
+
__TS__SetDescriptor(
|
|
1909
|
+
Unit.prototype,
|
|
1910
|
+
"movementType",
|
|
1911
|
+
{
|
|
1912
|
+
get = function(self)
|
|
1913
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1914
|
+
end,
|
|
1915
|
+
set = function(self, movementType)
|
|
1916
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1917
|
+
end
|
|
1918
|
+
},
|
|
1919
|
+
true
|
|
1920
|
+
)
|
|
1652
1921
|
__TS__SetDescriptor(
|
|
1653
1922
|
Unit.prototype,
|
|
1654
1923
|
"pathing",
|
|
@@ -1830,6 +2099,14 @@ __TS__SetDescriptor(
|
|
|
1830
2099
|
end},
|
|
1831
2100
|
true
|
|
1832
2101
|
)
|
|
2102
|
+
__TS__SetDescriptor(
|
|
2103
|
+
Unit.prototype,
|
|
2104
|
+
"targetAcquiredEvent",
|
|
2105
|
+
{get = function(self)
|
|
2106
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2107
|
+
end},
|
|
2108
|
+
true
|
|
2109
|
+
)
|
|
1833
2110
|
__TS__SetDescriptor(
|
|
1834
2111
|
Unit.prototype,
|
|
1835
2112
|
"onSelect",
|
|
@@ -1903,7 +2180,6 @@ Unit.onDecay = __TS__New(
|
|
|
1903
2180
|
Unit.onResurrect = __TS__New(
|
|
1904
2181
|
InitializingEvent,
|
|
1905
2182
|
function(event)
|
|
1906
|
-
local invoke = Event.invoke
|
|
1907
2183
|
local dead = setmetatable({}, {__mode = "k"})
|
|
1908
2184
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
1909
2185
|
dead[unit] = true
|
|
@@ -1919,10 +2195,15 @@ Unit.onResurrect = __TS__New(
|
|
|
1919
2195
|
Unit.morphEvent = __TS__New(
|
|
1920
2196
|
InitializingEvent,
|
|
1921
2197
|
function(event)
|
|
2198
|
+
local function ifNotLeft(unit)
|
|
2199
|
+
local handle = unit.handle
|
|
2200
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2201
|
+
invoke(event, unit)
|
|
2202
|
+
end
|
|
2203
|
+
end
|
|
1922
2204
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
1923
2205
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
1924
|
-
|
|
1925
|
-
Timer:run(Event.invoke, event, unit)
|
|
2206
|
+
Timer:run(ifNotLeft, unit)
|
|
1926
2207
|
end
|
|
1927
2208
|
end)
|
|
1928
2209
|
end
|
|
@@ -1960,27 +2241,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
1960
2241
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
1961
2242
|
InitializingEvent,
|
|
1962
2243
|
function(event)
|
|
1963
|
-
local invoke = Event.invoke
|
|
1964
2244
|
local function listener(unit, id)
|
|
1965
|
-
local
|
|
2245
|
+
local ____GetSpellTargetUnit_result_10
|
|
1966
2246
|
if GetSpellTargetUnit() then
|
|
1967
|
-
|
|
2247
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
1968
2248
|
else
|
|
1969
|
-
local
|
|
2249
|
+
local ____GetSpellTargetItem_result_9
|
|
1970
2250
|
if GetSpellTargetItem() then
|
|
1971
|
-
|
|
2251
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
1972
2252
|
else
|
|
1973
|
-
local
|
|
2253
|
+
local ____GetSpellTargetDestructable_result_8
|
|
1974
2254
|
if GetSpellTargetDestructable() then
|
|
1975
|
-
|
|
2255
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
1976
2256
|
else
|
|
1977
|
-
|
|
2257
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
1978
2258
|
end
|
|
1979
|
-
|
|
2259
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
1980
2260
|
end
|
|
1981
|
-
|
|
2261
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
1982
2262
|
end
|
|
1983
|
-
local target =
|
|
2263
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
1984
2264
|
if target then
|
|
1985
2265
|
invoke(event, unit, id, target)
|
|
1986
2266
|
end
|
|
@@ -2152,10 +2432,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2152
2432
|
____exports.UnitTriggerEvent,
|
|
2153
2433
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2154
2434
|
function()
|
|
2155
|
-
local
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2435
|
+
local handle = getOrderedUnit()
|
|
2436
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2437
|
+
local unit = ____exports.Unit:of(handle)
|
|
2438
|
+
if unit.state == 1 then
|
|
2439
|
+
return unit, getIssuedOrderId()
|
|
2440
|
+
end
|
|
2159
2441
|
end
|
|
2160
2442
|
return IgnoreEvent
|
|
2161
2443
|
end
|
|
@@ -2177,7 +2459,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2177
2459
|
)
|
|
2178
2460
|
Unit.onDamaging = (function()
|
|
2179
2461
|
local event = __TS__New(Event)
|
|
2180
|
-
local invoke = Event.invoke
|
|
2181
2462
|
local trigger = CreateTrigger()
|
|
2182
2463
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2183
2464
|
TriggerAddCondition(
|
|
@@ -2187,38 +2468,57 @@ Unit.onDamaging = (function()
|
|
|
2187
2468
|
if source and source.typeId == dummyUnitId then
|
|
2188
2469
|
source = nil
|
|
2189
2470
|
end
|
|
2190
|
-
local target = BlzGetEventDamageTarget()
|
|
2471
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2472
|
+
local metadata = damageMetadataByTarget[target]
|
|
2473
|
+
damageMetadataByTarget[target] = nil
|
|
2191
2474
|
local data = {
|
|
2192
2475
|
amount = GetEventDamage(),
|
|
2193
|
-
attackType = BlzGetEventAttackType(),
|
|
2476
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2194
2477
|
damageType = BlzGetEventDamageType(),
|
|
2195
2478
|
weaponType = BlzGetEventWeaponType(),
|
|
2196
|
-
|
|
2479
|
+
metadata = metadata,
|
|
2480
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2481
|
+
originalAmount = GetEventDamage(),
|
|
2482
|
+
originalMetadata = metadata,
|
|
2483
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2197
2484
|
}
|
|
2198
2485
|
if data.isAttack and source then
|
|
2199
|
-
|
|
2200
|
-
if weapon == -1 then
|
|
2201
|
-
local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
|
|
2202
|
-
weapon = 0
|
|
2203
|
-
end
|
|
2204
|
-
data.weapon = assert(source.weapons[weapon + 1])
|
|
2486
|
+
data.weapon = source:chooseWeapon(target)
|
|
2205
2487
|
end
|
|
2206
2488
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2207
2489
|
invoke(
|
|
2208
2490
|
event,
|
|
2209
2491
|
source,
|
|
2210
|
-
|
|
2492
|
+
target,
|
|
2211
2493
|
setmetatable(
|
|
2212
2494
|
{},
|
|
2213
2495
|
{
|
|
2214
2496
|
__index = data,
|
|
2215
2497
|
__newindex = function(self, key, value)
|
|
2216
|
-
damageSetters[key]
|
|
2498
|
+
local damageSetter = damageSetters[key]
|
|
2499
|
+
if damageSetter ~= nil then
|
|
2500
|
+
damageSetter(value)
|
|
2501
|
+
end
|
|
2217
2502
|
data[key] = value
|
|
2218
2503
|
end
|
|
2219
2504
|
}
|
|
2220
2505
|
)
|
|
2221
2506
|
)
|
|
2507
|
+
if data[0] and source then
|
|
2508
|
+
local sourceOwner = source.owner.handle
|
|
2509
|
+
data[1] = sourceOwner
|
|
2510
|
+
local targetOwner = target.owner.handle
|
|
2511
|
+
data[2] = targetOwner
|
|
2512
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2513
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2514
|
+
data[3] = true
|
|
2515
|
+
end
|
|
2516
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2517
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2518
|
+
data[4] = true
|
|
2519
|
+
end
|
|
2520
|
+
end
|
|
2521
|
+
damagingEventByTarget[target] = data
|
|
2222
2522
|
return
|
|
2223
2523
|
end
|
|
2224
2524
|
BlzSetEventDamage(0)
|
|
@@ -2226,7 +2526,7 @@ Unit.onDamaging = (function()
|
|
|
2226
2526
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2227
2527
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2228
2528
|
local sourceOwner = source.owner.handle
|
|
2229
|
-
local targetOwner =
|
|
2529
|
+
local targetOwner = target.owner.handle
|
|
2230
2530
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2231
2531
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2232
2532
|
Timer:run(function()
|
|
@@ -2242,23 +2542,19 @@ Unit.onDamaging = (function()
|
|
|
2242
2542
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2243
2543
|
local condition = ____value[1]
|
|
2244
2544
|
local action = ____value[2]
|
|
2245
|
-
if condition(
|
|
2246
|
-
source,
|
|
2247
|
-
____exports.Unit:of(target),
|
|
2248
|
-
data
|
|
2249
|
-
) then
|
|
2545
|
+
if condition(source, target, data) then
|
|
2250
2546
|
action(
|
|
2251
2547
|
source,
|
|
2252
|
-
|
|
2548
|
+
target,
|
|
2253
2549
|
setmetatable(
|
|
2254
2550
|
{fire = function()
|
|
2255
2551
|
UnitDamageTarget(
|
|
2256
2552
|
source.handle,
|
|
2257
|
-
target,
|
|
2553
|
+
target.handle,
|
|
2258
2554
|
data.amount,
|
|
2259
2555
|
true,
|
|
2260
2556
|
true,
|
|
2261
|
-
data.attackType,
|
|
2557
|
+
attackTypeToNative(data.attackType),
|
|
2262
2558
|
data.damageType,
|
|
2263
2559
|
data.weaponType
|
|
2264
2560
|
)
|
|
@@ -2276,7 +2572,6 @@ end)()
|
|
|
2276
2572
|
Unit.onDamage = __TS__New(
|
|
2277
2573
|
InitializingEvent,
|
|
2278
2574
|
function(event)
|
|
2279
|
-
local invoke = Event.invoke
|
|
2280
2575
|
local trigger = CreateTrigger()
|
|
2281
2576
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2282
2577
|
TriggerAddCondition(
|
|
@@ -2286,29 +2581,54 @@ Unit.onDamage = __TS__New(
|
|
|
2286
2581
|
if source and source.typeId == dummyUnitId then
|
|
2287
2582
|
source = nil
|
|
2288
2583
|
end
|
|
2584
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2585
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2586
|
+
damagingEventByTarget[target] = nil
|
|
2289
2587
|
local data = {
|
|
2290
2588
|
amount = GetEventDamage(),
|
|
2291
|
-
attackType = BlzGetEventAttackType(),
|
|
2589
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2292
2590
|
damageType = BlzGetEventDamageType(),
|
|
2293
2591
|
weaponType = BlzGetEventWeaponType(),
|
|
2592
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2294
2593
|
isAttack = BlzGetEventIsAttack(),
|
|
2594
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2595
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2295
2596
|
preventDeath = damageEventPreventDeath
|
|
2296
2597
|
}
|
|
2598
|
+
if damagingEvent then
|
|
2599
|
+
for key, value in pairs(damagingEvent) do
|
|
2600
|
+
if isAttribute(key) then
|
|
2601
|
+
data[key] = value
|
|
2602
|
+
end
|
|
2603
|
+
end
|
|
2604
|
+
local sourceOwner = damagingEvent[1]
|
|
2605
|
+
if sourceOwner then
|
|
2606
|
+
local targetOwner = damagingEvent[2]
|
|
2607
|
+
if damagingEvent[3] then
|
|
2608
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2609
|
+
end
|
|
2610
|
+
if damagingEvent[4] then
|
|
2611
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2612
|
+
end
|
|
2613
|
+
end
|
|
2614
|
+
end
|
|
2297
2615
|
local evData = setmetatable(
|
|
2298
2616
|
{},
|
|
2299
2617
|
{
|
|
2300
2618
|
__index = data,
|
|
2301
2619
|
__newindex = function(self, key, value)
|
|
2302
|
-
damageSetters[key]
|
|
2620
|
+
local damageSetter = damageSetters[key]
|
|
2621
|
+
if damageSetter ~= nil then
|
|
2622
|
+
damageSetter(value)
|
|
2623
|
+
end
|
|
2303
2624
|
data[key] = value
|
|
2304
2625
|
end
|
|
2305
2626
|
}
|
|
2306
2627
|
)
|
|
2307
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2308
2628
|
invoke(event, source, target, evData)
|
|
2309
2629
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2310
2630
|
local bonusHealth = math.ceil(evData.amount)
|
|
2311
|
-
target[
|
|
2631
|
+
target[105] = (target[105] or 0) + bonusHealth
|
|
2312
2632
|
BlzSetUnitMaxHP(
|
|
2313
2633
|
target.handle,
|
|
2314
2634
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2322,7 +2642,7 @@ Unit.onDamage = __TS__New(
|
|
|
2322
2642
|
evData[0],
|
|
2323
2643
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2324
2644
|
)
|
|
2325
|
-
target[
|
|
2645
|
+
target[105] = (target[105] or 0) - bonusHealth
|
|
2326
2646
|
SetWidgetLife(
|
|
2327
2647
|
target.handle,
|
|
2328
2648
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2342,32 +2662,110 @@ Unit.onDamage = __TS__New(
|
|
|
2342
2662
|
DestroyTrigger(trigger)
|
|
2343
2663
|
end
|
|
2344
2664
|
)
|
|
2345
|
-
Unit.
|
|
2665
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2346
2666
|
____exports.UnitTriggerEvent,
|
|
2347
2667
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2348
2668
|
function()
|
|
2349
2669
|
local unit = getTriggerUnit()
|
|
2350
|
-
|
|
2351
|
-
|
|
2670
|
+
local item = getManipulatedItem()
|
|
2671
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2672
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2352
2673
|
end
|
|
2353
2674
|
return IgnoreEvent
|
|
2354
2675
|
end
|
|
2355
2676
|
)
|
|
2356
|
-
Unit.
|
|
2677
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2357
2678
|
____exports.UnitTriggerEvent,
|
|
2358
2679
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2359
2680
|
function()
|
|
2360
|
-
local
|
|
2361
|
-
|
|
2362
|
-
|
|
2681
|
+
local unitHandle = getTriggerUnit()
|
|
2682
|
+
local itemHandle = getManipulatedItem()
|
|
2683
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2684
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2685
|
+
local item = Item:of(itemHandle)
|
|
2686
|
+
if item.owner ~= unit then
|
|
2687
|
+
return unit, item
|
|
2688
|
+
end
|
|
2363
2689
|
end
|
|
2364
2690
|
return IgnoreEvent
|
|
2365
2691
|
end
|
|
2366
2692
|
)
|
|
2367
|
-
Unit.
|
|
2693
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2368
2694
|
____exports.UnitTriggerEvent,
|
|
2369
2695
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2370
|
-
function()
|
|
2696
|
+
function()
|
|
2697
|
+
local unit = getTriggerUnit()
|
|
2698
|
+
local item = getManipulatedItem()
|
|
2699
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2700
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2701
|
+
end
|
|
2702
|
+
return IgnoreEvent
|
|
2703
|
+
end
|
|
2704
|
+
)
|
|
2705
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2706
|
+
____exports.UnitTriggerEvent,
|
|
2707
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2708
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2709
|
+
)
|
|
2710
|
+
__TS__ObjectDefineProperty(
|
|
2711
|
+
Unit,
|
|
2712
|
+
"itemChargesChangedEvent",
|
|
2713
|
+
{get = function(self)
|
|
2714
|
+
local event = __TS__New(Event)
|
|
2715
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2716
|
+
local unit = item.owner
|
|
2717
|
+
if unit ~= nil then
|
|
2718
|
+
invoke(event, unit, item)
|
|
2719
|
+
end
|
|
2720
|
+
end)
|
|
2721
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2722
|
+
return event
|
|
2723
|
+
end}
|
|
2724
|
+
)
|
|
2725
|
+
__TS__ObjectDefineProperty(
|
|
2726
|
+
Unit,
|
|
2727
|
+
"itemUseOrderEvent",
|
|
2728
|
+
{get = function(self)
|
|
2729
|
+
local event = __TS__New(Event)
|
|
2730
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2731
|
+
local slot = order - orderId("useslot0")
|
|
2732
|
+
local function listener(unit)
|
|
2733
|
+
local item = unit.items[slot + 1]
|
|
2734
|
+
if item ~= nil then
|
|
2735
|
+
invoke(event, unit, item)
|
|
2736
|
+
end
|
|
2737
|
+
end
|
|
2738
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2739
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2740
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2741
|
+
end
|
|
2742
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2743
|
+
return event
|
|
2744
|
+
end}
|
|
2745
|
+
)
|
|
2746
|
+
__TS__ObjectDefineProperty(
|
|
2747
|
+
Unit,
|
|
2748
|
+
"itemMoveOrderEvent",
|
|
2749
|
+
{get = function(self)
|
|
2750
|
+
local event = __TS__New(Event)
|
|
2751
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2752
|
+
local slotTo = order - orderId("moveslot0")
|
|
2753
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2754
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2755
|
+
if slotFrom ~= nil then
|
|
2756
|
+
invoke(
|
|
2757
|
+
event,
|
|
2758
|
+
unit,
|
|
2759
|
+
item,
|
|
2760
|
+
slotFrom,
|
|
2761
|
+
slotTo
|
|
2762
|
+
)
|
|
2763
|
+
end
|
|
2764
|
+
end)
|
|
2765
|
+
end
|
|
2766
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2767
|
+
return event
|
|
2768
|
+
end}
|
|
2371
2769
|
)
|
|
2372
2770
|
__TS__ObjectDefineProperty(
|
|
2373
2771
|
Unit,
|