warscript 0.0.1-dev.a45bc10 → 0.0.1-dev.a4646d1
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.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/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/destroyable.d.ts +1 -0
- package/destroyable.lua +9 -0
- package/engine/ability.d.ts +1 -1
- package/engine/behavior.d.ts +24 -11
- 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.d.ts +6 -1
- package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
- package/engine/behaviour/ability/damage.d.ts +39 -11
- package/engine/behaviour/ability/damage.lua +83 -37
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +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 +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 +29 -5
- package/engine/behaviour/ability.lua +154 -27
- package/engine/behaviour/unit/stun-immunity.d.ts +12 -7
- package/engine/behaviour/unit/stun-immunity.lua +57 -31
- package/engine/behaviour/unit.d.ts +48 -4
- package/engine/behaviour/unit.lua +292 -2
- package/engine/buff.d.ts +121 -46
- package/engine/buff.lua +567 -248
- package/engine/game-map.d.ts +7 -0
- package/engine/game-map.lua +32 -0
- package/engine/internal/ability.d.ts +23 -14
- package/engine/internal/ability.lua +129 -85
- package/engine/internal/item/ability.lua +162 -4
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +20 -19
- package/engine/internal/item.lua +191 -74
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- package/engine/internal/mechanics/cast-ability.lua +6 -3
- package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
- package/engine/internal/misc/ability-disable-counter.lua +13 -0
- package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
- package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
- package/engine/internal/misc/frame-coordinates.d.ts +2 -0
- package/engine/internal/misc/frame-coordinates.lua +21 -0
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/misc/player-local-handle.d.ts +2 -0
- package/engine/internal/misc/player-local-handle.lua +5 -0
- package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
- package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
- package/engine/internal/object-data/evasion-probability.d.ts +2 -0
- package/engine/internal/object-data/evasion-probability.lua +16 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
- package/engine/internal/unit/ability.d.ts +45 -1
- package/engine/internal/unit/ability.lua +128 -17
- package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
- package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot.lua +52 -0
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/attributes.d.ts +17 -0
- package/engine/internal/unit/attributes.lua +46 -0
- package/engine/internal/unit/bonus.d.ts +13 -8
- package/engine/internal/unit/bonus.lua +33 -1
- package/engine/internal/unit/fly-height.d.ts +7 -0
- package/engine/internal/unit/fly-height.lua +20 -0
- package/engine/internal/unit/ignore-events-items.d.ts +2 -0
- package/engine/internal/unit/ignore-events-items.lua +5 -0
- package/engine/internal/unit/interrupts.d.ts +12 -0
- package/engine/internal/unit/interrupts.lua +28 -0
- package/engine/internal/unit/item.d.ts +24 -0
- package/engine/internal/unit/item.lua +78 -0
- package/engine/internal/unit/main-selected.d.ts +13 -0
- package/engine/internal/unit/main-selected.lua +36 -0
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit/scale.d.ts +7 -0
- package/engine/internal/unit/scale.lua +20 -0
- package/engine/internal/unit+ability.lua +12 -3
- package/engine/internal/unit+damage.d.ts +2 -11
- package/engine/internal/unit+damage.lua +10 -14
- package/engine/internal/unit+spellSteal.lua +1 -2
- package/engine/internal/unit+transport.lua +4 -10
- package/engine/internal/unit-missile-launch.lua +70 -13
- package/engine/internal/unit.d.ts +96 -35
- package/engine/internal/unit.lua +694 -308
- 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 -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/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.d.ts +0 -1
- package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
- package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
- package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
- package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
- package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
- package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
- package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
- package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
- package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
- package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
- package/engine/object-data/entry/ability-type/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/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 +18 -37
- package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
- package/engine/object-data/entry/buff-type.d.ts +6 -13
- package/engine/object-data/entry/buff-type.lua +13 -29
- package/engine/object-data/entry/destructible-type.d.ts +28 -3
- package/engine/object-data/entry/destructible-type.lua +155 -0
- 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 +65 -5
- package/engine/object-data/entry/unit-type.lua +555 -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 +72 -3
- package/engine/object-field/unit.lua +268 -7
- package/engine/object-field.d.ts +25 -7
- package/engine/object-field.lua +359 -116
- 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 +5 -3
- package/engine/standard/fields/ability.lua +5 -3
- package/engine/standard/fields/unit.d.ts +12 -0
- package/engine/standard/fields/unit.lua +20 -0
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +250 -10
- package/engine/unit.d.ts +8 -0
- package/engine/unit.lua +17 -2
- package/event.d.ts +2 -3
- package/event.lua +9 -5
- package/index.d.ts +1 -0
- package/index.lua +1 -0
- package/lualib_bundle.lua +146 -42
- package/math/vec2.d.ts +2 -9
- package/math.d.ts +0 -2
- package/net/socket.d.ts +7 -1
- package/net/socket.lua +45 -4
- package/network.d.ts +1 -0
- package/network.lua +3 -2
- package/objutil/ability.d.ts +0 -1
- package/objutil/buff.d.ts +0 -1
- package/objutil/buff.lua +12 -11
- 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 +19 -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-map.d.ts +26 -0
- package/utility/linked-map.lua +66 -0
- package/utility/linked-set.d.ts +13 -3
- package/utility/linked-set.lua +31 -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/records.lua +20 -1
- package/utility/reflection.lua +11 -7
- package/utility/types.d.ts +4 -0
- package/core/mapbounds.d.ts +0 -8
- package/core/mapbounds.lua +0 -12
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
package/engine/internal/unit.lua
CHANGED
|
@@ -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,33 +51,42 @@ 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 ____linked_2Dmap = require("utility.linked-map")
|
|
68
|
+
local LinkedMap = ____linked_2Dmap.LinkedMap
|
|
51
69
|
local match = string.match
|
|
52
70
|
local ____tostring = _G.tostring
|
|
53
71
|
local setUnitAnimation = SetUnitAnimation
|
|
54
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
55
72
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
56
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
57
73
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
58
74
|
local getUnitRealField = BlzGetUnitRealField
|
|
59
75
|
local getHeroStr = GetHeroStr
|
|
60
76
|
local getHeroAgi = GetHeroAgi
|
|
61
77
|
local getHeroInt = GetHeroInt
|
|
62
|
-
local setHeroStr = SetHeroStr
|
|
63
|
-
local setHeroAgi = SetHeroAgi
|
|
64
|
-
local setHeroInt = SetHeroInt
|
|
65
78
|
local getUnitBooleanField = BlzGetUnitBooleanField
|
|
66
79
|
local getUnitStringField = BlzGetUnitStringField
|
|
67
80
|
local setUnitIntegerField = BlzSetUnitIntegerField
|
|
68
81
|
local setUnitRealField = BlzSetUnitRealField
|
|
69
82
|
local setUnitBooleanField = BlzSetUnitBooleanField
|
|
70
83
|
local setUnitStringField = BlzSetUnitStringField
|
|
71
|
-
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,11 +102,12 @@ 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
|
-
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
98
111
|
local isUnitInvisible = IsUnitInvisible
|
|
99
112
|
local isUnitVisible = IsUnitVisible
|
|
100
113
|
local getUnitX = GetUnitX
|
|
@@ -111,15 +124,9 @@ local getOrderedUnit = GetOrderedUnit
|
|
|
111
124
|
local getIssuedOrderId = GetIssuedOrderId
|
|
112
125
|
local isUnitInvulnerable = BlzIsUnitInvulnerable
|
|
113
126
|
local unitAlive = UnitAlive
|
|
114
|
-
local unitAddType = UnitAddType
|
|
115
|
-
local unitRemoveType = UnitRemoveType
|
|
116
|
-
local isUnitIllusion = IsUnitIllusion
|
|
117
|
-
local isUnitType = IsUnitType
|
|
118
127
|
local isUnitAlly = IsUnitAlly
|
|
119
128
|
local isUnitEnemy = IsUnitEnemy
|
|
120
129
|
local getOwningPlayer = GetOwningPlayer
|
|
121
|
-
local setUnitColor = SetUnitColor
|
|
122
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
123
130
|
____exports.UnitClassification = {}
|
|
124
131
|
local UnitClassification = ____exports.UnitClassification
|
|
125
132
|
do
|
|
@@ -129,6 +136,7 @@ do
|
|
|
129
136
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
130
137
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
131
138
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
139
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
132
140
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
133
141
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
134
142
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -275,16 +283,14 @@ function UnitTriggerEvent.prototype.____constructor(self, eventType, c)
|
|
|
275
283
|
end
|
|
276
284
|
local function dispatch(event, idGetter, argsGetter)
|
|
277
285
|
local initialized = false
|
|
278
|
-
local x = {}
|
|
279
286
|
return setmetatable(
|
|
280
|
-
|
|
287
|
+
{},
|
|
281
288
|
{
|
|
282
289
|
__index = function(self, id)
|
|
283
290
|
if type(id) ~= "number" then
|
|
284
291
|
return event[id]
|
|
285
292
|
end
|
|
286
293
|
if not initialized then
|
|
287
|
-
local invoke = Event.invoke
|
|
288
294
|
event:addListener(function(...)
|
|
289
295
|
local id = idGetter(...)
|
|
290
296
|
local dispatched = rawget(self, id)
|
|
@@ -322,7 +328,6 @@ local function dispatchAbility(event)
|
|
|
322
328
|
return event[id]
|
|
323
329
|
end
|
|
324
330
|
if not initialized then
|
|
325
|
-
local invoke = Event.invoke
|
|
326
331
|
event:addListener(function(unit, ability, ...)
|
|
327
332
|
local dispatched = rawget(self, ability.typeId)
|
|
328
333
|
if dispatched ~= nil then
|
|
@@ -339,6 +344,9 @@ local function dispatchAbility(event)
|
|
|
339
344
|
}
|
|
340
345
|
)
|
|
341
346
|
end
|
|
347
|
+
local function damagingEventPreventRetaliation(self)
|
|
348
|
+
self[0] = true
|
|
349
|
+
end
|
|
342
350
|
local function damageEventPreventDeath(self, callback, ...)
|
|
343
351
|
if self[0] ~= nil then
|
|
344
352
|
return
|
|
@@ -350,7 +358,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
350
358
|
rawset(self, 1 + i, (select(i, ...)))
|
|
351
359
|
end
|
|
352
360
|
end
|
|
353
|
-
local damageSetters = {
|
|
361
|
+
local damageSetters = {
|
|
362
|
+
amount = BlzSetEventDamage,
|
|
363
|
+
attackType = function(attackType)
|
|
364
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
365
|
+
end,
|
|
366
|
+
damageType = BlzSetEventDamageType,
|
|
367
|
+
weaponType = BlzSetEventWeaponType
|
|
368
|
+
}
|
|
354
369
|
local jlimitopByOperator = {
|
|
355
370
|
[0] = LESS_THAN_OR_EQUAL,
|
|
356
371
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -368,15 +383,27 @@ local modifiers = {
|
|
|
368
383
|
end,
|
|
369
384
|
armor = function(unit, value)
|
|
370
385
|
if UnitAddAbility(unit, armorBonusAbilityId) then
|
|
371
|
-
assert(
|
|
386
|
+
assert(
|
|
387
|
+
UnitMakeAbilityPermanent(unit, true, armorBonusAbilityId),
|
|
388
|
+
"armor bonus ability must be made permanent",
|
|
389
|
+
unit
|
|
390
|
+
)
|
|
372
391
|
end
|
|
373
|
-
local ability = assert(
|
|
374
|
-
|
|
375
|
-
ability,
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
392
|
+
local ability = assert(
|
|
393
|
+
BlzGetUnitAbility(unit, armorBonusAbilityId),
|
|
394
|
+
"armor bonus ability must be existing",
|
|
395
|
+
unit
|
|
396
|
+
)
|
|
397
|
+
assert(
|
|
398
|
+
BlzSetAbilityRealLevelField(
|
|
399
|
+
ability,
|
|
400
|
+
armorBonusField,
|
|
401
|
+
0,
|
|
402
|
+
BlzGetAbilityRealLevelField(ability, armorBonusField, 0) + value
|
|
403
|
+
),
|
|
404
|
+
"armor bonus ability field must be set",
|
|
405
|
+
unit
|
|
406
|
+
)
|
|
380
407
|
end
|
|
381
408
|
}
|
|
382
409
|
local getters = {
|
|
@@ -387,51 +414,184 @@ local getters = {
|
|
|
387
414
|
return BlzGetUnitArmor(unit)
|
|
388
415
|
end
|
|
389
416
|
}
|
|
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
|
-
|
|
417
|
+
____exports.UnitWeapon = __TS__Class()
|
|
418
|
+
local UnitWeapon = ____exports.UnitWeapon
|
|
419
|
+
UnitWeapon.name = "UnitWeapon"
|
|
420
|
+
function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
421
|
+
self.unit = unit
|
|
422
|
+
self.index = index
|
|
423
|
+
end
|
|
424
|
+
__TS__SetDescriptor(
|
|
425
|
+
UnitWeapon.prototype,
|
|
426
|
+
"isEnabled",
|
|
427
|
+
{
|
|
428
|
+
get = function(self)
|
|
429
|
+
return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
|
|
430
|
+
end,
|
|
431
|
+
set = function(self, isEnabled)
|
|
432
|
+
BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
|
|
433
|
+
end
|
|
434
|
+
},
|
|
435
|
+
true
|
|
436
|
+
)
|
|
437
|
+
__TS__SetDescriptor(
|
|
438
|
+
UnitWeapon.prototype,
|
|
439
|
+
"cooldown",
|
|
440
|
+
{
|
|
441
|
+
get = function(self)
|
|
442
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index)
|
|
443
|
+
end,
|
|
444
|
+
set = function(self, cooldown)
|
|
445
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index, cooldown)
|
|
446
|
+
end
|
|
447
|
+
},
|
|
448
|
+
true
|
|
449
|
+
)
|
|
450
|
+
__TS__SetDescriptor(
|
|
451
|
+
UnitWeapon.prototype,
|
|
452
|
+
"damage",
|
|
453
|
+
{
|
|
454
|
+
get = function(self)
|
|
455
|
+
local minimumDamage = self.damageBase + self.damageDiceCount
|
|
456
|
+
local maximumDamage = self.damageBase + self.damageDiceCount * self.damageDiceSideCount
|
|
457
|
+
return {minimumDamage, maximumDamage}
|
|
458
|
+
end,
|
|
459
|
+
set = function(self, ____bindingPattern0)
|
|
460
|
+
local maximumDamage
|
|
461
|
+
local minimumDamage
|
|
462
|
+
minimumDamage = ____bindingPattern0[1]
|
|
463
|
+
maximumDamage = ____bindingPattern0[2]
|
|
464
|
+
self.damageBase = minimumDamage - 1
|
|
465
|
+
self.damageDiceCount = 1
|
|
466
|
+
self.damageDiceSideCount = maximumDamage - minimumDamage + 1
|
|
467
|
+
end
|
|
468
|
+
},
|
|
469
|
+
true
|
|
470
|
+
)
|
|
471
|
+
__TS__SetDescriptor(
|
|
472
|
+
UnitWeapon.prototype,
|
|
473
|
+
"allowedTargetCombatClassifications",
|
|
474
|
+
{
|
|
475
|
+
get = function(self)
|
|
476
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
477
|
+
end,
|
|
478
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
479
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
480
|
+
end
|
|
481
|
+
},
|
|
482
|
+
true
|
|
483
|
+
)
|
|
484
|
+
__TS__SetDescriptor(
|
|
485
|
+
UnitWeapon.prototype,
|
|
486
|
+
"damageBase",
|
|
487
|
+
{
|
|
488
|
+
get = function(self)
|
|
489
|
+
return BlzGetUnitBaseDamage(self.unit.handle, self.index)
|
|
490
|
+
end,
|
|
491
|
+
set = function(self, damageBase)
|
|
492
|
+
BlzSetUnitBaseDamage(self.unit.handle, self.index, damageBase)
|
|
493
|
+
end
|
|
494
|
+
},
|
|
495
|
+
true
|
|
496
|
+
)
|
|
497
|
+
__TS__SetDescriptor(
|
|
498
|
+
UnitWeapon.prototype,
|
|
499
|
+
"damageDiceCount",
|
|
500
|
+
{
|
|
501
|
+
get = function(self)
|
|
502
|
+
return BlzGetUnitDiceNumber(self.unit.handle, self.index)
|
|
503
|
+
end,
|
|
504
|
+
set = function(self, damageDiceCount)
|
|
505
|
+
BlzSetUnitDiceNumber(self.unit.handle, self.index, damageDiceCount)
|
|
506
|
+
end
|
|
507
|
+
},
|
|
508
|
+
true
|
|
509
|
+
)
|
|
510
|
+
__TS__SetDescriptor(
|
|
511
|
+
UnitWeapon.prototype,
|
|
512
|
+
"damageDiceSideCount",
|
|
513
|
+
{
|
|
514
|
+
get = function(self)
|
|
515
|
+
return BlzGetUnitDiceSides(self.unit.handle, self.index)
|
|
516
|
+
end,
|
|
517
|
+
set = function(self, damageDiceSideCount)
|
|
518
|
+
BlzSetUnitDiceSides(self.unit.handle, self.index, damageDiceSideCount)
|
|
519
|
+
end
|
|
520
|
+
},
|
|
521
|
+
true
|
|
522
|
+
)
|
|
523
|
+
__TS__SetDescriptor(
|
|
524
|
+
UnitWeapon.prototype,
|
|
525
|
+
"range",
|
|
526
|
+
{
|
|
527
|
+
get = function(self)
|
|
528
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_RANGE, self.index)
|
|
529
|
+
end,
|
|
530
|
+
set = function(self, range)
|
|
531
|
+
local handle = self.unit.handle
|
|
532
|
+
local index = self.index
|
|
533
|
+
setUnitWeaponRealField(
|
|
534
|
+
handle,
|
|
535
|
+
UNIT_WEAPON_RF_ATTACK_RANGE,
|
|
536
|
+
index + 1,
|
|
537
|
+
getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index + 1) + (range - getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index))
|
|
538
|
+
)
|
|
539
|
+
end
|
|
540
|
+
},
|
|
541
|
+
true
|
|
542
|
+
)
|
|
543
|
+
__TS__SetDescriptor(
|
|
544
|
+
UnitWeapon.prototype,
|
|
545
|
+
"impactDelay",
|
|
546
|
+
{
|
|
547
|
+
get = function(self)
|
|
548
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index)
|
|
549
|
+
end,
|
|
550
|
+
set = function(self, impactDelay)
|
|
551
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index, impactDelay)
|
|
552
|
+
end
|
|
553
|
+
},
|
|
554
|
+
true
|
|
555
|
+
)
|
|
556
|
+
__TS__SetDescriptor(
|
|
557
|
+
UnitWeapon.prototype,
|
|
558
|
+
"missileArc",
|
|
559
|
+
{
|
|
560
|
+
get = function(self)
|
|
561
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index)
|
|
562
|
+
end,
|
|
563
|
+
set = function(self, missileArc)
|
|
564
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index, missileArc)
|
|
565
|
+
end
|
|
566
|
+
},
|
|
567
|
+
true
|
|
568
|
+
)
|
|
569
|
+
__TS__SetDescriptor(
|
|
570
|
+
UnitWeapon.prototype,
|
|
571
|
+
"missileModelPath",
|
|
572
|
+
{
|
|
573
|
+
get = function(self)
|
|
574
|
+
return getUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index)
|
|
575
|
+
end,
|
|
576
|
+
set = function(self, missileModelPath)
|
|
577
|
+
setUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index, missileModelPath)
|
|
578
|
+
end
|
|
579
|
+
},
|
|
580
|
+
true
|
|
581
|
+
)
|
|
582
|
+
__TS__SetDescriptor(
|
|
583
|
+
UnitWeapon.prototype,
|
|
584
|
+
"missileSpeed",
|
|
585
|
+
{
|
|
586
|
+
get = function(self)
|
|
587
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index)
|
|
588
|
+
end,
|
|
589
|
+
set = function(self, missileSpeed)
|
|
590
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index, missileSpeed)
|
|
591
|
+
end
|
|
592
|
+
},
|
|
593
|
+
true
|
|
594
|
+
)
|
|
435
595
|
local unitInventorySize = UnitInventorySize
|
|
436
596
|
local unitItemInSlot = UnitItemInSlot
|
|
437
597
|
local getItemAbility = BlzGetItemAbility
|
|
@@ -442,8 +602,6 @@ local getAbilityName = GetAbilityName
|
|
|
442
602
|
local unitAddAbility = UnitAddAbility
|
|
443
603
|
local getUnitGoldCost = GetUnitGoldCost
|
|
444
604
|
local getUnitLumberCost = GetUnitWoodCost
|
|
445
|
-
local unitMakeAbilityPermanent = UnitMakeAbilityPermanent
|
|
446
|
-
local unitAddItem = UnitAddItem
|
|
447
605
|
local unitRemoveAbility = UnitRemoveAbility
|
|
448
606
|
local function retrieveAbility(unit, ability, abilityId)
|
|
449
607
|
if ability == nil then
|
|
@@ -453,17 +611,6 @@ local function retrieveAbility(unit, ability, abilityId)
|
|
|
453
611
|
____exports.Unit:of(unit)
|
|
454
612
|
)
|
|
455
613
|
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
614
|
for i = 0, unitInventorySize(unit) - 1 do
|
|
468
615
|
local item = unitItemInSlot(unit, i)
|
|
469
616
|
if getItemAbility(item, abilityId) == ability then
|
|
@@ -510,52 +657,105 @@ local fieldSetters = {
|
|
|
510
657
|
}
|
|
511
658
|
local dummies = {}
|
|
512
659
|
for ____, player in ipairs(Player.all) do
|
|
513
|
-
local dummy = assert(
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
660
|
+
local dummy = assert(
|
|
661
|
+
createUnit(
|
|
662
|
+
player.handle,
|
|
663
|
+
dummyUnitId,
|
|
664
|
+
0,
|
|
665
|
+
0,
|
|
666
|
+
270
|
|
667
|
+
),
|
|
668
|
+
"dummy must be created",
|
|
669
|
+
player
|
|
670
|
+
)
|
|
520
671
|
ShowUnit(dummy, false)
|
|
521
672
|
dummies[player] = dummy
|
|
522
673
|
end
|
|
674
|
+
local function delayHealthChecksCallback(unit)
|
|
675
|
+
local counter = (unit[104] or 0) - 1
|
|
676
|
+
if counter ~= 0 then
|
|
677
|
+
unit[104] = counter
|
|
678
|
+
return
|
|
679
|
+
end
|
|
680
|
+
unit[104] = nil
|
|
681
|
+
local healthBonus = unit[105]
|
|
682
|
+
if healthBonus ~= nil then
|
|
683
|
+
unit[105] = nil
|
|
684
|
+
local handle = unit.handle
|
|
685
|
+
BlzSetUnitMaxHP(
|
|
686
|
+
handle,
|
|
687
|
+
BlzGetUnitMaxHP(handle) - healthBonus
|
|
688
|
+
)
|
|
689
|
+
end
|
|
690
|
+
end
|
|
691
|
+
local nextSyncId = 1
|
|
692
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
693
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
694
|
+
local function addAbility(unit, abilityTypeId)
|
|
695
|
+
local ____unitAddAbility_result_0
|
|
696
|
+
if unitAddAbility(unit, abilityTypeId) then
|
|
697
|
+
____unitAddAbility_result_0 = getUnitAbility(unit, abilityTypeId)
|
|
698
|
+
else
|
|
699
|
+
____unitAddAbility_result_0 = nil
|
|
700
|
+
end
|
|
701
|
+
return ____unitAddAbility_result_0
|
|
702
|
+
end
|
|
523
703
|
____exports.Unit = __TS__Class()
|
|
524
704
|
local Unit = ____exports.Unit
|
|
525
705
|
Unit.name = "Unit"
|
|
526
706
|
__TS__ClassExtends(Unit, Handle)
|
|
527
707
|
function Unit.prototype.____constructor(self, handle)
|
|
528
708
|
Handle.prototype.____constructor(self, handle)
|
|
709
|
+
local ____nextSyncId_1 = nextSyncId
|
|
710
|
+
nextSyncId = ____nextSyncId_1 + 1
|
|
711
|
+
self.syncId = ____nextSyncId_1
|
|
529
712
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
530
|
-
assert(
|
|
531
|
-
|
|
713
|
+
assert(
|
|
714
|
+
unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId),
|
|
715
|
+
"leave detection ability must be added",
|
|
716
|
+
self
|
|
717
|
+
)
|
|
718
|
+
assert(
|
|
719
|
+
unitAddAbility(handle, morphDetectAbilityId),
|
|
720
|
+
"morph detection ability must be added",
|
|
721
|
+
self
|
|
722
|
+
)
|
|
532
723
|
if unitAddAbility(
|
|
533
724
|
handle,
|
|
534
725
|
fourCC("Amrf")
|
|
535
726
|
) then
|
|
536
|
-
assert(
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
727
|
+
assert(
|
|
728
|
+
unitRemoveAbility(
|
|
729
|
+
handle,
|
|
730
|
+
fourCC("Amrf")
|
|
731
|
+
),
|
|
732
|
+
"fly ability must be removed after addition",
|
|
733
|
+
self
|
|
734
|
+
)
|
|
540
735
|
end
|
|
736
|
+
unitBySyncId[self.syncId] = self
|
|
541
737
|
local ____ = self.abilities
|
|
542
738
|
end
|
|
543
|
-
function Unit.prototype.getEvent(self,
|
|
544
|
-
self.events = self.events or (
|
|
545
|
-
local eventId = GetHandleId(
|
|
546
|
-
|
|
547
|
-
|
|
739
|
+
function Unit.prototype.getEvent(self, jevent, collector)
|
|
740
|
+
self.events = self.events or __TS__New(LinkedMap)
|
|
741
|
+
local eventId = GetHandleId(jevent)
|
|
742
|
+
local event = self.events:get(eventId)
|
|
743
|
+
if event == nil then
|
|
744
|
+
event = __TS__New(
|
|
548
745
|
TriggerEvent,
|
|
549
746
|
function(trigger)
|
|
550
|
-
TriggerRegisterUnitEvent(trigger, self.handle,
|
|
747
|
+
TriggerRegisterUnitEvent(trigger, self.handle, jevent)
|
|
551
748
|
end,
|
|
552
749
|
collector or (function() return {} end)
|
|
553
750
|
)
|
|
751
|
+
self.events:put(eventId, event)
|
|
554
752
|
end
|
|
555
|
-
return
|
|
753
|
+
return event
|
|
556
754
|
end
|
|
557
755
|
function Unit.prototype.onDestroy(self)
|
|
558
756
|
local handle = self.handle
|
|
757
|
+
self[108] = getUnitX(handle)
|
|
758
|
+
self[109] = getUnitY(handle)
|
|
559
759
|
if not self._owner then
|
|
560
760
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
561
761
|
end
|
|
@@ -594,7 +794,11 @@ function Unit.prototype.addAttackHandler(self, condition, action)
|
|
|
594
794
|
self._attackHandlers = handlers
|
|
595
795
|
if #handlers == 1 then
|
|
596
796
|
local handle = self.handle
|
|
597
|
-
assert(
|
|
797
|
+
assert(
|
|
798
|
+
unitAddAbility(handle, attackHandlerAbilityId) and UnitMakeAbilityPermanent(handle, true, attackHandlerAbilityId),
|
|
799
|
+
"attack handler ability must be added",
|
|
800
|
+
self
|
|
801
|
+
)
|
|
598
802
|
end
|
|
599
803
|
return handler
|
|
600
804
|
end
|
|
@@ -623,17 +827,17 @@ function Unit.prototype.addModifier(self, property, modifier)
|
|
|
623
827
|
end}
|
|
624
828
|
end
|
|
625
829
|
function Unit.prototype.hasCombatClassification(self, combatClassification)
|
|
626
|
-
local
|
|
627
|
-
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) &
|
|
830
|
+
local ____combatClassification_2 = combatClassification
|
|
831
|
+
return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_2 == ____combatClassification_2
|
|
628
832
|
end
|
|
629
833
|
function Unit.prototype.addClassification(self, classification)
|
|
630
|
-
return
|
|
834
|
+
return UnitAddType(self.handle, classification)
|
|
631
835
|
end
|
|
632
836
|
function Unit.prototype.removeClassification(self, classification)
|
|
633
|
-
return
|
|
837
|
+
return UnitRemoveType(self.handle, classification)
|
|
634
838
|
end
|
|
635
839
|
function Unit.prototype.hasClassification(self, classification)
|
|
636
|
-
return
|
|
840
|
+
return IsUnitType(self.handle, classification)
|
|
637
841
|
end
|
|
638
842
|
function Unit.prototype.isVisibleTo(self, player)
|
|
639
843
|
return isUnitVisible(self.handle, player.handle)
|
|
@@ -642,13 +846,13 @@ function Unit.prototype.isInvisibleTo(self, player)
|
|
|
642
846
|
return isUnitInvisible(self.handle, player.handle)
|
|
643
847
|
end
|
|
644
848
|
function Unit.prototype.isInRangeOf(self, x, y, range)
|
|
645
|
-
local
|
|
849
|
+
local ____temp_3
|
|
646
850
|
if type(x) == "number" then
|
|
647
|
-
|
|
851
|
+
____temp_3 = isUnitInRangeXY(self.handle, x, y, range)
|
|
648
852
|
else
|
|
649
|
-
|
|
853
|
+
____temp_3 = isUnitInRange(self.handle, x.handle, y)
|
|
650
854
|
end
|
|
651
|
-
return
|
|
855
|
+
return ____temp_3
|
|
652
856
|
end
|
|
653
857
|
function Unit.prototype.isAllyOf(self, unit)
|
|
654
858
|
return isUnitAlly(
|
|
@@ -666,13 +870,31 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
666
870
|
if type(animation) == "number" then
|
|
667
871
|
setUnitAnimationByIndex(self.handle, animation)
|
|
668
872
|
elseif rarity then
|
|
669
|
-
|
|
873
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
670
874
|
else
|
|
671
875
|
setUnitAnimation(self.handle, animation)
|
|
672
876
|
end
|
|
673
877
|
end
|
|
878
|
+
function Unit.prototype.resetAnimation(self)
|
|
879
|
+
ResetUnitAnimation(self.handle)
|
|
880
|
+
end
|
|
674
881
|
function Unit.prototype.queueAnimation(self, animation)
|
|
675
|
-
|
|
882
|
+
QueueUnitAnimation(self.handle, animation)
|
|
883
|
+
end
|
|
884
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
885
|
+
local firstWeapon = self.firstWeapon
|
|
886
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
887
|
+
return firstWeapon
|
|
888
|
+
end
|
|
889
|
+
local secondWeapon = self.secondWeapon
|
|
890
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
891
|
+
return secondWeapon
|
|
892
|
+
end
|
|
893
|
+
return nil
|
|
894
|
+
end
|
|
895
|
+
function Unit.prototype.delayHealthChecks(self)
|
|
896
|
+
self[104] = (self[104] or 0) + 1
|
|
897
|
+
Timer:run(delayHealthChecksCallback, self)
|
|
676
898
|
end
|
|
677
899
|
function Unit.prototype.setPosition(self, x, y)
|
|
678
900
|
setUnitPosition(self.handle, x, y)
|
|
@@ -681,14 +903,21 @@ function Unit.prototype.isSelected(self, player)
|
|
|
681
903
|
return IsUnitSelected(self.handle, player.handle)
|
|
682
904
|
end
|
|
683
905
|
function Unit.prototype.explode(self)
|
|
684
|
-
|
|
906
|
+
SetUnitExploded(self.handle, true)
|
|
685
907
|
killUnit(self.handle)
|
|
686
908
|
end
|
|
687
909
|
function Unit.prototype.kill(self)
|
|
688
910
|
killUnit(self.handle)
|
|
689
911
|
end
|
|
690
|
-
function Unit.prototype.revive(self,
|
|
691
|
-
|
|
912
|
+
function Unit.prototype.revive(self, x, y, doEffect)
|
|
913
|
+
local ____ReviveHero_6 = ReviveHero
|
|
914
|
+
local ____array_5 = __TS__SparseArrayNew(self.handle, x, y)
|
|
915
|
+
local ____doEffect_4 = doEffect
|
|
916
|
+
if ____doEffect_4 == nil then
|
|
917
|
+
____doEffect_4 = false
|
|
918
|
+
end
|
|
919
|
+
__TS__SparseArrayPush(____array_5, ____doEffect_4)
|
|
920
|
+
____ReviveHero_6(__TS__SparseArraySpread(____array_5))
|
|
692
921
|
end
|
|
693
922
|
function Unit.prototype.healTarget(self, target, amount)
|
|
694
923
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -728,20 +957,19 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
728
957
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
729
958
|
end
|
|
730
959
|
function Unit.prototype.itemInSlot(self, slot)
|
|
731
|
-
return Item:of(
|
|
960
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
732
961
|
end
|
|
733
962
|
function Unit.prototype.addAbility(self, abilityId)
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
963
|
+
local ability = UnitAbility:of(
|
|
964
|
+
doUnitAbilityAction(self.handle, abilityId, addAbility, abilityId),
|
|
965
|
+
abilityId,
|
|
966
|
+
self
|
|
967
|
+
)
|
|
968
|
+
if ability ~= nil then
|
|
740
969
|
local abilities = self.abilities
|
|
741
970
|
abilities[#abilities + 1] = ability
|
|
742
|
-
return ability
|
|
743
971
|
end
|
|
744
|
-
return
|
|
972
|
+
return ability
|
|
745
973
|
end
|
|
746
974
|
function Unit.prototype.makeAbilityPermanent(self, abilityId, permanent)
|
|
747
975
|
return UnitMakeAbilityPermanent(self.handle, permanent, abilityId)
|
|
@@ -755,47 +983,44 @@ end
|
|
|
755
983
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
756
984
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
757
985
|
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
|
-
)
|
|
986
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
987
|
+
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
988
|
+
return UnitAbility:of(ability, abilityId, self)
|
|
769
989
|
end
|
|
770
|
-
function Unit.prototype.removeAbility(self,
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
end
|
|
990
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
991
|
+
local abilities = self.abilities
|
|
992
|
+
for i = 1, #abilities do
|
|
993
|
+
if abilities[i].typeId == abilityTypeId then
|
|
994
|
+
local ability = abilities[i]
|
|
995
|
+
tremove(abilities, i)
|
|
996
|
+
ability:destroy()
|
|
997
|
+
return true
|
|
779
998
|
end
|
|
780
|
-
return true
|
|
781
999
|
end
|
|
782
|
-
return
|
|
1000
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
783
1001
|
end
|
|
784
1002
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
785
1003
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
786
1004
|
end
|
|
1005
|
+
function Unit.prototype.getAbilityRemainingCooldown(self, abilityId)
|
|
1006
|
+
return BlzGetUnitAbilityCooldownRemaining(self.handle, abilityId)
|
|
1007
|
+
end
|
|
787
1008
|
function Unit.prototype.startAbilityCooldown(self, abilityId, cooldown)
|
|
788
1009
|
BlzStartUnitAbilityCooldown(self.handle, abilityId, cooldown)
|
|
789
1010
|
end
|
|
790
1011
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
791
1012
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
792
1013
|
end
|
|
793
|
-
function Unit.prototype.interruptAttack(self)
|
|
794
|
-
unitInterruptAttack(self.handle)
|
|
795
|
-
end
|
|
796
1014
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
797
|
-
|
|
798
|
-
unitDisableAbility(
|
|
1015
|
+
local handle = self.handle
|
|
1016
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
1017
|
+
Timer:run(
|
|
1018
|
+
unitDisableAbility,
|
|
1019
|
+
handle,
|
|
1020
|
+
abilityId,
|
|
1021
|
+
false,
|
|
1022
|
+
false
|
|
1023
|
+
)
|
|
799
1024
|
end
|
|
800
1025
|
function Unit.prototype.getDistanceTo(self, target)
|
|
801
1026
|
local handle = self.handle
|
|
@@ -855,18 +1080,44 @@ function Unit.prototype.unpauseEx(self)
|
|
|
855
1080
|
self:decrementStunCounter()
|
|
856
1081
|
end
|
|
857
1082
|
function Unit.prototype.incrementStunCounter(self)
|
|
858
|
-
local stunCounter = self[
|
|
859
|
-
if not self[
|
|
1083
|
+
local stunCounter = self[102] or 0
|
|
1084
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 0 then
|
|
860
1085
|
BlzPauseUnitEx(self.handle, true)
|
|
861
1086
|
end
|
|
862
|
-
self[
|
|
1087
|
+
self[102] = stunCounter + 1
|
|
863
1088
|
end
|
|
864
1089
|
function Unit.prototype.decrementStunCounter(self)
|
|
865
|
-
local stunCounter = self[
|
|
866
|
-
if not self[
|
|
1090
|
+
local stunCounter = self[102] or 0
|
|
1091
|
+
if not self[101] and (self[103] or 0) <= 0 or stunCounter >= 1 then
|
|
867
1092
|
BlzPauseUnitEx(self.handle, false)
|
|
868
1093
|
end
|
|
869
|
-
self[
|
|
1094
|
+
self[102] = stunCounter - 1
|
|
1095
|
+
end
|
|
1096
|
+
function Unit.prototype.incrementForceStunCounter(self)
|
|
1097
|
+
local forceStunCounter = self[103] or 0
|
|
1098
|
+
if forceStunCounter == 0 then
|
|
1099
|
+
local handle = self.handle
|
|
1100
|
+
if not self[101] then
|
|
1101
|
+
for _ = self[102] or 0, -1 do
|
|
1102
|
+
BlzPauseUnitEx(handle, true)
|
|
1103
|
+
end
|
|
1104
|
+
end
|
|
1105
|
+
BlzPauseUnitEx(handle, true)
|
|
1106
|
+
end
|
|
1107
|
+
self[103] = forceStunCounter + 1
|
|
1108
|
+
end
|
|
1109
|
+
function Unit.prototype.decrementForceStunCounter(self)
|
|
1110
|
+
local forceStunCounter = self[103] or 0
|
|
1111
|
+
if forceStunCounter == 1 then
|
|
1112
|
+
local handle = self.handle
|
|
1113
|
+
if not self[101] then
|
|
1114
|
+
for _ = self[102] or 0, -1 do
|
|
1115
|
+
BlzPauseUnitEx(handle, false)
|
|
1116
|
+
end
|
|
1117
|
+
end
|
|
1118
|
+
BlzPauseUnitEx(handle, false)
|
|
1119
|
+
end
|
|
1120
|
+
self[103] = forceStunCounter - 1
|
|
870
1121
|
end
|
|
871
1122
|
function Unit.create(self, owner, id, x, y, facing, skinId)
|
|
872
1123
|
local handle = skinId and BlzCreateUnitWithSkin(
|
|
@@ -968,8 +1219,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
968
1219
|
)
|
|
969
1220
|
return targetCollection
|
|
970
1221
|
end
|
|
971
|
-
function Unit.getSelectionOf(self, player)
|
|
972
|
-
|
|
1222
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1223
|
+
if target == nil then
|
|
1224
|
+
target = {}
|
|
1225
|
+
end
|
|
1226
|
+
targetCollection = target
|
|
973
1227
|
targetCollectionNextIndex = 1
|
|
974
1228
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
975
1229
|
return targetCollection
|
|
@@ -991,6 +1245,9 @@ end
|
|
|
991
1245
|
function Unit.prototype.__tostring(self)
|
|
992
1246
|
return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
|
|
993
1247
|
end
|
|
1248
|
+
function Unit.getBySyncId(self, syncId)
|
|
1249
|
+
return unitBySyncId[syncId]
|
|
1250
|
+
end
|
|
994
1251
|
__TS__SetDescriptor(
|
|
995
1252
|
Unit.prototype,
|
|
996
1253
|
"_deltas",
|
|
@@ -1050,7 +1307,15 @@ __TS__SetDescriptor(
|
|
|
1050
1307
|
Unit.prototype,
|
|
1051
1308
|
"isIllusion",
|
|
1052
1309
|
{get = function(self)
|
|
1053
|
-
return
|
|
1310
|
+
return IsUnitIllusion(self.handle)
|
|
1311
|
+
end},
|
|
1312
|
+
true
|
|
1313
|
+
)
|
|
1314
|
+
__TS__SetDescriptor(
|
|
1315
|
+
Unit.prototype,
|
|
1316
|
+
"isStunned",
|
|
1317
|
+
{get = function(self)
|
|
1318
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1054
1319
|
end},
|
|
1055
1320
|
true
|
|
1056
1321
|
)
|
|
@@ -1071,12 +1336,27 @@ __TS__SetDescriptor(
|
|
|
1071
1336
|
Unit.prototype,
|
|
1072
1337
|
"weapons",
|
|
1073
1338
|
{get = function(self)
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1339
|
+
return {self.firstWeapon, self.secondWeapon}
|
|
1340
|
+
end},
|
|
1341
|
+
true
|
|
1342
|
+
)
|
|
1343
|
+
__TS__SetDescriptor(
|
|
1344
|
+
Unit.prototype,
|
|
1345
|
+
"firstWeapon",
|
|
1346
|
+
{get = function(self)
|
|
1347
|
+
local weapon = __TS__New(____exports.UnitWeapon, self, 0)
|
|
1348
|
+
rawset(self, "firstWeapon", weapon)
|
|
1349
|
+
return weapon
|
|
1350
|
+
end},
|
|
1351
|
+
true
|
|
1352
|
+
)
|
|
1353
|
+
__TS__SetDescriptor(
|
|
1354
|
+
Unit.prototype,
|
|
1355
|
+
"secondWeapon",
|
|
1356
|
+
{get = function(self)
|
|
1357
|
+
local weapon = __TS__New(____exports.UnitWeapon, self, 1)
|
|
1358
|
+
rawset(self, "secondWeapon", weapon)
|
|
1359
|
+
return weapon
|
|
1080
1360
|
end},
|
|
1081
1361
|
true
|
|
1082
1362
|
)
|
|
@@ -1114,13 +1394,13 @@ __TS__SetDescriptor(
|
|
|
1114
1394
|
)
|
|
1115
1395
|
__TS__SetDescriptor(
|
|
1116
1396
|
Unit.prototype,
|
|
1117
|
-
"
|
|
1397
|
+
"primaryAttribute",
|
|
1118
1398
|
{
|
|
1119
1399
|
get = function(self)
|
|
1120
|
-
return
|
|
1400
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1121
1401
|
end,
|
|
1122
|
-
set = function(self,
|
|
1123
|
-
|
|
1402
|
+
set = function(self, primaryAttribute)
|
|
1403
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1124
1404
|
end
|
|
1125
1405
|
},
|
|
1126
1406
|
true
|
|
@@ -1142,19 +1422,6 @@ __TS__SetDescriptor(
|
|
|
1142
1422
|
end},
|
|
1143
1423
|
true
|
|
1144
1424
|
)
|
|
1145
|
-
__TS__SetDescriptor(
|
|
1146
|
-
Unit.prototype,
|
|
1147
|
-
"agilityBase",
|
|
1148
|
-
{
|
|
1149
|
-
get = function(self)
|
|
1150
|
-
return getHeroAgi(self.handle, false)
|
|
1151
|
-
end,
|
|
1152
|
-
set = function(self, agilityBase)
|
|
1153
|
-
setHeroAgi(self.handle, agilityBase, true)
|
|
1154
|
-
end
|
|
1155
|
-
},
|
|
1156
|
-
true
|
|
1157
|
-
)
|
|
1158
1425
|
__TS__SetDescriptor(
|
|
1159
1426
|
Unit.prototype,
|
|
1160
1427
|
"agilityBonus",
|
|
@@ -1172,19 +1439,6 @@ __TS__SetDescriptor(
|
|
|
1172
1439
|
end},
|
|
1173
1440
|
true
|
|
1174
1441
|
)
|
|
1175
|
-
__TS__SetDescriptor(
|
|
1176
|
-
Unit.prototype,
|
|
1177
|
-
"intelligenceBase",
|
|
1178
|
-
{
|
|
1179
|
-
get = function(self)
|
|
1180
|
-
return getHeroInt(self.handle, false)
|
|
1181
|
-
end,
|
|
1182
|
-
set = function(self, intelligenceBase)
|
|
1183
|
-
setHeroInt(self.handle, intelligenceBase, true)
|
|
1184
|
-
end
|
|
1185
|
-
},
|
|
1186
|
-
true
|
|
1187
|
-
)
|
|
1188
1442
|
__TS__SetDescriptor(
|
|
1189
1443
|
Unit.prototype,
|
|
1190
1444
|
"intelligenceBonus",
|
|
@@ -1233,17 +1487,17 @@ __TS__SetDescriptor(
|
|
|
1233
1487
|
"isTeamGlowVisible",
|
|
1234
1488
|
{
|
|
1235
1489
|
get = function(self)
|
|
1236
|
-
return not self[
|
|
1490
|
+
return not self[107]
|
|
1237
1491
|
end,
|
|
1238
1492
|
set = function(self, isTeamGlowVisible)
|
|
1239
|
-
|
|
1240
|
-
local
|
|
1493
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1494
|
+
local ____temp_7
|
|
1241
1495
|
if not isTeamGlowVisible then
|
|
1242
|
-
|
|
1496
|
+
____temp_7 = true
|
|
1243
1497
|
else
|
|
1244
|
-
|
|
1498
|
+
____temp_7 = nil
|
|
1245
1499
|
end
|
|
1246
|
-
self[
|
|
1500
|
+
self[107] = ____temp_7
|
|
1247
1501
|
end
|
|
1248
1502
|
},
|
|
1249
1503
|
true
|
|
@@ -1252,9 +1506,9 @@ __TS__SetDescriptor(
|
|
|
1252
1506
|
Unit.prototype,
|
|
1253
1507
|
"color",
|
|
1254
1508
|
{set = function(self, color)
|
|
1255
|
-
|
|
1256
|
-
if self[
|
|
1257
|
-
|
|
1509
|
+
SetUnitColor(self.handle, color.handle)
|
|
1510
|
+
if self[107] then
|
|
1511
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1258
1512
|
end
|
|
1259
1513
|
end},
|
|
1260
1514
|
true
|
|
@@ -1277,10 +1531,14 @@ __TS__SetDescriptor(
|
|
|
1277
1531
|
"maxHealth",
|
|
1278
1532
|
{
|
|
1279
1533
|
get = function(self)
|
|
1280
|
-
return BlzGetUnitMaxHP(self.handle) - (self[
|
|
1534
|
+
return BlzGetUnitMaxHP(self.handle) - (self[105] or 0) - (self[106] or 0)
|
|
1281
1535
|
end,
|
|
1282
1536
|
set = function(self, maxHealth)
|
|
1283
|
-
|
|
1537
|
+
if maxHealth < 1 and self[104] ~= nil then
|
|
1538
|
+
self[105] = (self[105] or 0) + (1 - maxHealth)
|
|
1539
|
+
maxHealth = 1
|
|
1540
|
+
end
|
|
1541
|
+
BlzSetUnitMaxHP(self.handle, maxHealth + (self[106] or 0))
|
|
1284
1542
|
end
|
|
1285
1543
|
},
|
|
1286
1544
|
true
|
|
@@ -1322,10 +1580,10 @@ __TS__SetDescriptor(
|
|
|
1322
1580
|
"health",
|
|
1323
1581
|
{
|
|
1324
1582
|
get = function(self)
|
|
1325
|
-
return GetWidgetLife(self.handle) - (self[
|
|
1583
|
+
return GetWidgetLife(self.handle) - (self[106] or 0)
|
|
1326
1584
|
end,
|
|
1327
1585
|
set = function(self, health)
|
|
1328
|
-
SetWidgetLife(self.handle, health + (self[
|
|
1586
|
+
SetWidgetLife(self.handle, health + (self[106] or 0))
|
|
1329
1587
|
end
|
|
1330
1588
|
},
|
|
1331
1589
|
true
|
|
@@ -1401,25 +1659,12 @@ __TS__SetDescriptor(
|
|
|
1401
1659
|
},
|
|
1402
1660
|
true
|
|
1403
1661
|
)
|
|
1404
|
-
__TS__SetDescriptor(
|
|
1405
|
-
Unit.prototype,
|
|
1406
|
-
"flyHeight",
|
|
1407
|
-
{
|
|
1408
|
-
get = function(self)
|
|
1409
|
-
return getUnitFlyHeight(self.handle)
|
|
1410
|
-
end,
|
|
1411
|
-
set = function(self, v)
|
|
1412
|
-
SetUnitFlyHeight(self.handle, v, 100000)
|
|
1413
|
-
end
|
|
1414
|
-
},
|
|
1415
|
-
true
|
|
1416
|
-
)
|
|
1417
1662
|
__TS__SetDescriptor(
|
|
1418
1663
|
Unit.prototype,
|
|
1419
1664
|
"x",
|
|
1420
1665
|
{
|
|
1421
1666
|
get = function(self)
|
|
1422
|
-
return getUnitX(self.handle)
|
|
1667
|
+
return self[108] or getUnitX(self.handle)
|
|
1423
1668
|
end,
|
|
1424
1669
|
set = function(self, v)
|
|
1425
1670
|
SetUnitX(self.handle, v)
|
|
@@ -1432,7 +1677,7 @@ __TS__SetDescriptor(
|
|
|
1432
1677
|
"y",
|
|
1433
1678
|
{
|
|
1434
1679
|
get = function(self)
|
|
1435
|
-
return getUnitY(self.handle)
|
|
1680
|
+
return self[109] or getUnitY(self.handle)
|
|
1436
1681
|
end,
|
|
1437
1682
|
set = function(self, v)
|
|
1438
1683
|
SetUnitY(self.handle, v)
|
|
@@ -1518,10 +1763,10 @@ __TS__SetDescriptor(
|
|
|
1518
1763
|
"gold",
|
|
1519
1764
|
{
|
|
1520
1765
|
get = function(self)
|
|
1521
|
-
return
|
|
1766
|
+
return GetResourceAmount(self.handle)
|
|
1522
1767
|
end,
|
|
1523
1768
|
set = function(self, gold)
|
|
1524
|
-
|
|
1769
|
+
SetResourceAmount(self.handle, gold)
|
|
1525
1770
|
end
|
|
1526
1771
|
},
|
|
1527
1772
|
true
|
|
@@ -1536,17 +1781,21 @@ __TS__SetDescriptor(
|
|
|
1536
1781
|
set = function(self, isPaused)
|
|
1537
1782
|
local handle = self.handle
|
|
1538
1783
|
if isPaused and not IsUnitPaused(handle) then
|
|
1539
|
-
self[
|
|
1540
|
-
|
|
1541
|
-
|
|
1784
|
+
self[101] = true
|
|
1785
|
+
if (self[103] or 0) <= 0 then
|
|
1786
|
+
for _ = self[102] or 0, -1 do
|
|
1787
|
+
BlzPauseUnitEx(handle, true)
|
|
1788
|
+
end
|
|
1542
1789
|
end
|
|
1543
1790
|
PauseUnit(handle, true)
|
|
1544
1791
|
elseif not isPaused and IsUnitPaused(handle) then
|
|
1545
1792
|
PauseUnit(handle, false)
|
|
1546
|
-
|
|
1547
|
-
|
|
1793
|
+
if (self[103] or 0) <= 0 then
|
|
1794
|
+
for _ = self[102] or 0, -1 do
|
|
1795
|
+
BlzPauseUnitEx(handle, false)
|
|
1796
|
+
end
|
|
1548
1797
|
end
|
|
1549
|
-
self[
|
|
1798
|
+
self[101] = nil
|
|
1550
1799
|
end
|
|
1551
1800
|
end
|
|
1552
1801
|
},
|
|
@@ -1602,20 +1851,6 @@ __TS__SetDescriptor(
|
|
|
1602
1851
|
},
|
|
1603
1852
|
true
|
|
1604
1853
|
)
|
|
1605
|
-
__TS__SetDescriptor(
|
|
1606
|
-
Unit.prototype,
|
|
1607
|
-
"scale",
|
|
1608
|
-
{
|
|
1609
|
-
get = function(self)
|
|
1610
|
-
return getUnitRealField(self.handle, UNIT_RF_SCALING_VALUE)
|
|
1611
|
-
end,
|
|
1612
|
-
set = function(self, v)
|
|
1613
|
-
setUnitScale(self.handle, v, v, v)
|
|
1614
|
-
setUnitRealField(self.handle, UNIT_RF_SCALING_VALUE, v)
|
|
1615
|
-
end
|
|
1616
|
-
},
|
|
1617
|
-
true
|
|
1618
|
-
)
|
|
1619
1854
|
__TS__SetDescriptor(
|
|
1620
1855
|
Unit.prototype,
|
|
1621
1856
|
"timeScale",
|
|
@@ -1649,6 +1884,19 @@ __TS__SetDescriptor(
|
|
|
1649
1884
|
end},
|
|
1650
1885
|
true
|
|
1651
1886
|
)
|
|
1887
|
+
__TS__SetDescriptor(
|
|
1888
|
+
Unit.prototype,
|
|
1889
|
+
"movementType",
|
|
1890
|
+
{
|
|
1891
|
+
get = function(self)
|
|
1892
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1893
|
+
end,
|
|
1894
|
+
set = function(self, movementType)
|
|
1895
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1896
|
+
end
|
|
1897
|
+
},
|
|
1898
|
+
true
|
|
1899
|
+
)
|
|
1652
1900
|
__TS__SetDescriptor(
|
|
1653
1901
|
Unit.prototype,
|
|
1654
1902
|
"pathing",
|
|
@@ -1830,6 +2078,14 @@ __TS__SetDescriptor(
|
|
|
1830
2078
|
end},
|
|
1831
2079
|
true
|
|
1832
2080
|
)
|
|
2081
|
+
__TS__SetDescriptor(
|
|
2082
|
+
Unit.prototype,
|
|
2083
|
+
"targetAcquiredEvent",
|
|
2084
|
+
{get = function(self)
|
|
2085
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2086
|
+
end},
|
|
2087
|
+
true
|
|
2088
|
+
)
|
|
1833
2089
|
__TS__SetDescriptor(
|
|
1834
2090
|
Unit.prototype,
|
|
1835
2091
|
"onSelect",
|
|
@@ -1890,6 +2146,11 @@ __TS__SetDescriptor(
|
|
|
1890
2146
|
end},
|
|
1891
2147
|
true
|
|
1892
2148
|
)
|
|
2149
|
+
Unit.levelChangedEvent = __TS__New(
|
|
2150
|
+
____exports.UnitTriggerEvent,
|
|
2151
|
+
EVENT_PLAYER_HERO_LEVEL,
|
|
2152
|
+
function() return ____exports.Unit:of(getTriggerUnit()) end
|
|
2153
|
+
)
|
|
1893
2154
|
Unit.deathEvent = __TS__New(
|
|
1894
2155
|
____exports.UnitTriggerEvent,
|
|
1895
2156
|
EVENT_PLAYER_UNIT_DEATH,
|
|
@@ -1903,7 +2164,6 @@ Unit.onDecay = __TS__New(
|
|
|
1903
2164
|
Unit.onResurrect = __TS__New(
|
|
1904
2165
|
InitializingEvent,
|
|
1905
2166
|
function(event)
|
|
1906
|
-
local invoke = Event.invoke
|
|
1907
2167
|
local dead = setmetatable({}, {__mode = "k"})
|
|
1908
2168
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
1909
2169
|
dead[unit] = true
|
|
@@ -1919,10 +2179,15 @@ Unit.onResurrect = __TS__New(
|
|
|
1919
2179
|
Unit.morphEvent = __TS__New(
|
|
1920
2180
|
InitializingEvent,
|
|
1921
2181
|
function(event)
|
|
2182
|
+
local function ifNotLeft(unit)
|
|
2183
|
+
local handle = unit.handle
|
|
2184
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2185
|
+
invoke(event, unit)
|
|
2186
|
+
end
|
|
2187
|
+
end
|
|
1922
2188
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
1923
2189
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
1924
|
-
|
|
1925
|
-
Timer:run(Event.invoke, event, unit)
|
|
2190
|
+
Timer:run(ifNotLeft, unit)
|
|
1926
2191
|
end
|
|
1927
2192
|
end)
|
|
1928
2193
|
end
|
|
@@ -1960,27 +2225,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
1960
2225
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
1961
2226
|
InitializingEvent,
|
|
1962
2227
|
function(event)
|
|
1963
|
-
local invoke = Event.invoke
|
|
1964
2228
|
local function listener(unit, id)
|
|
1965
|
-
local
|
|
2229
|
+
local ____GetSpellTargetUnit_result_10
|
|
1966
2230
|
if GetSpellTargetUnit() then
|
|
1967
|
-
|
|
2231
|
+
____GetSpellTargetUnit_result_10 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
1968
2232
|
else
|
|
1969
|
-
local
|
|
2233
|
+
local ____GetSpellTargetItem_result_9
|
|
1970
2234
|
if GetSpellTargetItem() then
|
|
1971
|
-
|
|
2235
|
+
____GetSpellTargetItem_result_9 = Item:of(GetSpellTargetItem())
|
|
1972
2236
|
else
|
|
1973
|
-
local
|
|
2237
|
+
local ____GetSpellTargetDestructable_result_8
|
|
1974
2238
|
if GetSpellTargetDestructable() then
|
|
1975
|
-
|
|
2239
|
+
____GetSpellTargetDestructable_result_8 = Destructable:of(GetSpellTargetDestructable())
|
|
1976
2240
|
else
|
|
1977
|
-
|
|
2241
|
+
____GetSpellTargetDestructable_result_8 = nil
|
|
1978
2242
|
end
|
|
1979
|
-
|
|
2243
|
+
____GetSpellTargetItem_result_9 = ____GetSpellTargetDestructable_result_8
|
|
1980
2244
|
end
|
|
1981
|
-
|
|
2245
|
+
____GetSpellTargetUnit_result_10 = ____GetSpellTargetItem_result_9
|
|
1982
2246
|
end
|
|
1983
|
-
local target =
|
|
2247
|
+
local target = ____GetSpellTargetUnit_result_10
|
|
1984
2248
|
if target then
|
|
1985
2249
|
invoke(event, unit, id, target)
|
|
1986
2250
|
end
|
|
@@ -2152,10 +2416,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2152
2416
|
____exports.UnitTriggerEvent,
|
|
2153
2417
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2154
2418
|
function()
|
|
2155
|
-
local
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2419
|
+
local handle = getOrderedUnit()
|
|
2420
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2421
|
+
local unit = ____exports.Unit:of(handle)
|
|
2422
|
+
if unit.state == 1 then
|
|
2423
|
+
return unit, getIssuedOrderId()
|
|
2424
|
+
end
|
|
2159
2425
|
end
|
|
2160
2426
|
return IgnoreEvent
|
|
2161
2427
|
end
|
|
@@ -2177,7 +2443,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2177
2443
|
)
|
|
2178
2444
|
Unit.onDamaging = (function()
|
|
2179
2445
|
local event = __TS__New(Event)
|
|
2180
|
-
local invoke = Event.invoke
|
|
2181
2446
|
local trigger = CreateTrigger()
|
|
2182
2447
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2183
2448
|
TriggerAddCondition(
|
|
@@ -2187,38 +2452,57 @@ Unit.onDamaging = (function()
|
|
|
2187
2452
|
if source and source.typeId == dummyUnitId then
|
|
2188
2453
|
source = nil
|
|
2189
2454
|
end
|
|
2190
|
-
local target = BlzGetEventDamageTarget()
|
|
2455
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2456
|
+
local metadata = damageMetadataByTarget[target]
|
|
2457
|
+
damageMetadataByTarget[target] = nil
|
|
2191
2458
|
local data = {
|
|
2192
2459
|
amount = GetEventDamage(),
|
|
2193
|
-
attackType = BlzGetEventAttackType(),
|
|
2460
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2194
2461
|
damageType = BlzGetEventDamageType(),
|
|
2195
2462
|
weaponType = BlzGetEventWeaponType(),
|
|
2196
|
-
|
|
2463
|
+
metadata = metadata,
|
|
2464
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2465
|
+
originalAmount = GetEventDamage(),
|
|
2466
|
+
originalMetadata = metadata,
|
|
2467
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2197
2468
|
}
|
|
2198
2469
|
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])
|
|
2470
|
+
data.weapon = source:chooseWeapon(target)
|
|
2205
2471
|
end
|
|
2206
2472
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2207
2473
|
invoke(
|
|
2208
2474
|
event,
|
|
2209
2475
|
source,
|
|
2210
|
-
|
|
2476
|
+
target,
|
|
2211
2477
|
setmetatable(
|
|
2212
2478
|
{},
|
|
2213
2479
|
{
|
|
2214
2480
|
__index = data,
|
|
2215
2481
|
__newindex = function(self, key, value)
|
|
2216
|
-
damageSetters[key]
|
|
2482
|
+
local damageSetter = damageSetters[key]
|
|
2483
|
+
if damageSetter ~= nil then
|
|
2484
|
+
damageSetter(value)
|
|
2485
|
+
end
|
|
2217
2486
|
data[key] = value
|
|
2218
2487
|
end
|
|
2219
2488
|
}
|
|
2220
2489
|
)
|
|
2221
2490
|
)
|
|
2491
|
+
if data[0] and source then
|
|
2492
|
+
local sourceOwner = source.owner.handle
|
|
2493
|
+
data[1] = sourceOwner
|
|
2494
|
+
local targetOwner = target.owner.handle
|
|
2495
|
+
data[2] = targetOwner
|
|
2496
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2497
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2498
|
+
data[3] = true
|
|
2499
|
+
end
|
|
2500
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2501
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2502
|
+
data[4] = true
|
|
2503
|
+
end
|
|
2504
|
+
end
|
|
2505
|
+
damagingEventByTarget[target] = data
|
|
2222
2506
|
return
|
|
2223
2507
|
end
|
|
2224
2508
|
BlzSetEventDamage(0)
|
|
@@ -2226,7 +2510,7 @@ Unit.onDamaging = (function()
|
|
|
2226
2510
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2227
2511
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2228
2512
|
local sourceOwner = source.owner.handle
|
|
2229
|
-
local targetOwner =
|
|
2513
|
+
local targetOwner = target.owner.handle
|
|
2230
2514
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2231
2515
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2232
2516
|
Timer:run(function()
|
|
@@ -2242,23 +2526,19 @@ Unit.onDamaging = (function()
|
|
|
2242
2526
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2243
2527
|
local condition = ____value[1]
|
|
2244
2528
|
local action = ____value[2]
|
|
2245
|
-
if condition(
|
|
2246
|
-
source,
|
|
2247
|
-
____exports.Unit:of(target),
|
|
2248
|
-
data
|
|
2249
|
-
) then
|
|
2529
|
+
if condition(source, target, data) then
|
|
2250
2530
|
action(
|
|
2251
2531
|
source,
|
|
2252
|
-
|
|
2532
|
+
target,
|
|
2253
2533
|
setmetatable(
|
|
2254
2534
|
{fire = function()
|
|
2255
2535
|
UnitDamageTarget(
|
|
2256
2536
|
source.handle,
|
|
2257
|
-
target,
|
|
2537
|
+
target.handle,
|
|
2258
2538
|
data.amount,
|
|
2259
2539
|
true,
|
|
2260
2540
|
true,
|
|
2261
|
-
data.attackType,
|
|
2541
|
+
attackTypeToNative(data.attackType),
|
|
2262
2542
|
data.damageType,
|
|
2263
2543
|
data.weaponType
|
|
2264
2544
|
)
|
|
@@ -2276,7 +2556,6 @@ end)()
|
|
|
2276
2556
|
Unit.onDamage = __TS__New(
|
|
2277
2557
|
InitializingEvent,
|
|
2278
2558
|
function(event)
|
|
2279
|
-
local invoke = Event.invoke
|
|
2280
2559
|
local trigger = CreateTrigger()
|
|
2281
2560
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2282
2561
|
TriggerAddCondition(
|
|
@@ -2286,29 +2565,54 @@ Unit.onDamage = __TS__New(
|
|
|
2286
2565
|
if source and source.typeId == dummyUnitId then
|
|
2287
2566
|
source = nil
|
|
2288
2567
|
end
|
|
2568
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2569
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2570
|
+
damagingEventByTarget[target] = nil
|
|
2289
2571
|
local data = {
|
|
2290
2572
|
amount = GetEventDamage(),
|
|
2291
|
-
attackType = BlzGetEventAttackType(),
|
|
2573
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2292
2574
|
damageType = BlzGetEventDamageType(),
|
|
2293
2575
|
weaponType = BlzGetEventWeaponType(),
|
|
2576
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2294
2577
|
isAttack = BlzGetEventIsAttack(),
|
|
2578
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2579
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2295
2580
|
preventDeath = damageEventPreventDeath
|
|
2296
2581
|
}
|
|
2582
|
+
if damagingEvent then
|
|
2583
|
+
for key, value in pairs(damagingEvent) do
|
|
2584
|
+
if isAttribute(key) then
|
|
2585
|
+
data[key] = value
|
|
2586
|
+
end
|
|
2587
|
+
end
|
|
2588
|
+
local sourceOwner = damagingEvent[1]
|
|
2589
|
+
if sourceOwner then
|
|
2590
|
+
local targetOwner = damagingEvent[2]
|
|
2591
|
+
if damagingEvent[3] then
|
|
2592
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2593
|
+
end
|
|
2594
|
+
if damagingEvent[4] then
|
|
2595
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2596
|
+
end
|
|
2597
|
+
end
|
|
2598
|
+
end
|
|
2297
2599
|
local evData = setmetatable(
|
|
2298
2600
|
{},
|
|
2299
2601
|
{
|
|
2300
2602
|
__index = data,
|
|
2301
2603
|
__newindex = function(self, key, value)
|
|
2302
|
-
damageSetters[key]
|
|
2604
|
+
local damageSetter = damageSetters[key]
|
|
2605
|
+
if damageSetter ~= nil then
|
|
2606
|
+
damageSetter(value)
|
|
2607
|
+
end
|
|
2303
2608
|
data[key] = value
|
|
2304
2609
|
end
|
|
2305
2610
|
}
|
|
2306
2611
|
)
|
|
2307
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2308
2612
|
invoke(event, source, target, evData)
|
|
2309
2613
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2310
2614
|
local bonusHealth = math.ceil(evData.amount)
|
|
2311
|
-
target[
|
|
2615
|
+
target[106] = (target[106] or 0) + bonusHealth
|
|
2312
2616
|
BlzSetUnitMaxHP(
|
|
2313
2617
|
target.handle,
|
|
2314
2618
|
BlzGetUnitMaxHP(target.handle) + bonusHealth
|
|
@@ -2322,7 +2626,7 @@ Unit.onDamage = __TS__New(
|
|
|
2322
2626
|
evData[0],
|
|
2323
2627
|
table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
|
|
2324
2628
|
)
|
|
2325
|
-
target[
|
|
2629
|
+
target[106] = (target[106] or 0) - bonusHealth
|
|
2326
2630
|
SetWidgetLife(
|
|
2327
2631
|
target.handle,
|
|
2328
2632
|
GetWidgetLife(target.handle) - bonusHealth
|
|
@@ -2342,32 +2646,110 @@ Unit.onDamage = __TS__New(
|
|
|
2342
2646
|
DestroyTrigger(trigger)
|
|
2343
2647
|
end
|
|
2344
2648
|
)
|
|
2345
|
-
Unit.
|
|
2649
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2346
2650
|
____exports.UnitTriggerEvent,
|
|
2347
2651
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2348
2652
|
function()
|
|
2349
2653
|
local unit = getTriggerUnit()
|
|
2350
|
-
|
|
2351
|
-
|
|
2654
|
+
local item = getManipulatedItem()
|
|
2655
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2656
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2352
2657
|
end
|
|
2353
2658
|
return IgnoreEvent
|
|
2354
2659
|
end
|
|
2355
2660
|
)
|
|
2356
|
-
Unit.
|
|
2661
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2357
2662
|
____exports.UnitTriggerEvent,
|
|
2358
2663
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2359
2664
|
function()
|
|
2360
|
-
local
|
|
2361
|
-
|
|
2362
|
-
|
|
2665
|
+
local unitHandle = getTriggerUnit()
|
|
2666
|
+
local itemHandle = getManipulatedItem()
|
|
2667
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2668
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2669
|
+
local item = Item:of(itemHandle)
|
|
2670
|
+
if item.owner ~= unit then
|
|
2671
|
+
return unit, item
|
|
2672
|
+
end
|
|
2363
2673
|
end
|
|
2364
2674
|
return IgnoreEvent
|
|
2365
2675
|
end
|
|
2366
2676
|
)
|
|
2367
|
-
Unit.
|
|
2677
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2368
2678
|
____exports.UnitTriggerEvent,
|
|
2369
2679
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2370
|
-
function()
|
|
2680
|
+
function()
|
|
2681
|
+
local unit = getTriggerUnit()
|
|
2682
|
+
local item = getManipulatedItem()
|
|
2683
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2684
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2685
|
+
end
|
|
2686
|
+
return IgnoreEvent
|
|
2687
|
+
end
|
|
2688
|
+
)
|
|
2689
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2690
|
+
____exports.UnitTriggerEvent,
|
|
2691
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2692
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2693
|
+
)
|
|
2694
|
+
__TS__ObjectDefineProperty(
|
|
2695
|
+
Unit,
|
|
2696
|
+
"itemChargesChangedEvent",
|
|
2697
|
+
{get = function(self)
|
|
2698
|
+
local event = __TS__New(Event)
|
|
2699
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2700
|
+
local unit = item.owner
|
|
2701
|
+
if unit ~= nil then
|
|
2702
|
+
invoke(event, unit, item)
|
|
2703
|
+
end
|
|
2704
|
+
end)
|
|
2705
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2706
|
+
return event
|
|
2707
|
+
end}
|
|
2708
|
+
)
|
|
2709
|
+
__TS__ObjectDefineProperty(
|
|
2710
|
+
Unit,
|
|
2711
|
+
"itemUseOrderEvent",
|
|
2712
|
+
{get = function(self)
|
|
2713
|
+
local event = __TS__New(Event)
|
|
2714
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2715
|
+
local slot = order - orderId("useslot0")
|
|
2716
|
+
local function listener(unit)
|
|
2717
|
+
local item = unit.items[slot + 1]
|
|
2718
|
+
if item ~= nil then
|
|
2719
|
+
invoke(event, unit, item)
|
|
2720
|
+
end
|
|
2721
|
+
end
|
|
2722
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2723
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2724
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2725
|
+
end
|
|
2726
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2727
|
+
return event
|
|
2728
|
+
end}
|
|
2729
|
+
)
|
|
2730
|
+
__TS__ObjectDefineProperty(
|
|
2731
|
+
Unit,
|
|
2732
|
+
"itemMoveOrderEvent",
|
|
2733
|
+
{get = function(self)
|
|
2734
|
+
local event = __TS__New(Event)
|
|
2735
|
+
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
2736
|
+
local slotTo = order - orderId("moveslot0")
|
|
2737
|
+
self.onTargetOrder[order]:addListener(function(unit, item)
|
|
2738
|
+
local slotFrom = unit.items:findSlot(item)
|
|
2739
|
+
if slotFrom ~= nil then
|
|
2740
|
+
invoke(
|
|
2741
|
+
event,
|
|
2742
|
+
unit,
|
|
2743
|
+
item,
|
|
2744
|
+
slotFrom,
|
|
2745
|
+
slotTo
|
|
2746
|
+
)
|
|
2747
|
+
end
|
|
2748
|
+
end)
|
|
2749
|
+
end
|
|
2750
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2751
|
+
return event
|
|
2752
|
+
end}
|
|
2371
2753
|
)
|
|
2372
2754
|
__TS__ObjectDefineProperty(
|
|
2373
2755
|
Unit,
|
|
@@ -2394,6 +2776,10 @@ __TS__ObjectDefineProperty(
|
|
|
2394
2776
|
rawset(self, "destroyEvent", destroyEvent)
|
|
2395
2777
|
return destroyEvent
|
|
2396
2778
|
end}
|
|
2779
|
+
)
|
|
2780
|
+
Unit.synchronize = synchronizer(
|
|
2781
|
+
function(unit) return unit.syncId end,
|
|
2782
|
+
function(syncId) return unitBySyncId[syncId] end
|
|
2397
2783
|
);
|
|
2398
2784
|
(function(self)
|
|
2399
2785
|
local leaveAbilityIds = postcompile(function()
|