warscript 0.0.1-dev.6be8f21 → 0.0.1-dev.6c4635c
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/core/types/frame.lua +24 -21
- 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/tileCell.d.ts +9 -0
- package/core/types/tileCell.lua +92 -0
- package/core/types/timer.d.ts +3 -1
- package/core/types/timer.lua +27 -2
- package/decl/native.d.ts +6 -4
- package/engine/behavior.d.ts +3 -0
- package/engine/behavior.lua +63 -10
- package/engine/behaviour/ability/restore-mana.d.ts +1 -1
- package/engine/behaviour/ability/restore-mana.lua +6 -6
- package/engine/behaviour/unit/stun-immunity.d.ts +2 -0
- package/engine/behaviour/unit/stun-immunity.lua +11 -2
- package/engine/behaviour/unit.d.ts +8 -2
- package/engine/behaviour/unit.lua +29 -2
- package/engine/buff.d.ts +0 -3
- package/engine/buff.lua +59 -80
- package/engine/internal/ability.d.ts +3 -1
- package/engine/internal/ability.lua +26 -9
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +13 -15
- package/engine/internal/item.lua +63 -49
- 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/unit/ability.d.ts +14 -14
- package/engine/internal/unit/ability.lua +72 -45
- package/engine/internal/unit+ability.lua +10 -1
- package/engine/internal/unit-missile-launch.lua +18 -5
- package/engine/internal/unit.d.ts +5 -5
- package/engine/internal/unit.lua +27 -17
- 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/entry/ability-type.lua +5 -4
- package/engine/object-data/entry/unit-type.d.ts +11 -2
- package/engine/object-data/entry/unit-type.lua +59 -1
- package/engine/object-field/ability.d.ts +3 -3
- package/engine/object-field/ability.lua +7 -6
- package/engine/object-field.d.ts +2 -2
- package/engine/object-field.lua +8 -6
- package/engine/random.d.ts +9 -0
- package/engine/random.lua +13 -0
- package/engine/text-tag.d.ts +1 -1
- package/engine/text-tag.lua +91 -17
- package/objutil/buff.lua +1 -1
- package/package.json +2 -2
- package/patch-lualib.lua +1 -1
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +8 -0
- package/utility/callback-array.d.ts +17 -0
- package/utility/callback-array.lua +61 -0
- package/utility/functions.d.ts +2 -0
- package/utility/functions.lua +7 -0
- package/utility/lua-maps.d.ts +11 -2
- package/utility/lua-maps.lua +33 -2
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +4 -0
- package/utility/types.d.ts +3 -0
package/engine/internal/item.lua
CHANGED
|
@@ -46,9 +46,18 @@ local getItemY = GetItemY
|
|
|
46
46
|
local getItemCharges = GetItemCharges
|
|
47
47
|
local setItemCharges = SetItemCharges
|
|
48
48
|
local unitRemoveAbility = UnitRemoveAbility
|
|
49
|
+
local unitRemoveItem = UnitRemoveItem
|
|
49
50
|
local unitUseItem = UnitUseItem
|
|
50
51
|
local unitUseItemPoint = UnitUseItemPoint
|
|
51
52
|
local unitUseItemTarget = UnitUseItemTarget
|
|
53
|
+
local setItemDropOnDeath = SetItemDropOnDeath
|
|
54
|
+
local setItemDroppable = SetItemDroppable
|
|
55
|
+
local setItemPawnable = SetItemPawnable
|
|
56
|
+
local isItemPawnable = IsItemPawnable
|
|
57
|
+
local getItemIntegerField = BlzGetItemIntegerField
|
|
58
|
+
local setItemBooleanField = BlzSetItemBooleanField
|
|
59
|
+
local getItemBooleanField = BlzGetItemBooleanField
|
|
60
|
+
local tableRemove = table.remove
|
|
52
61
|
_G.SetItemCharges = function(whichItem, charges)
|
|
53
62
|
setItemCharges(whichItem, charges)
|
|
54
63
|
invoke(
|
|
@@ -56,9 +65,6 @@ _G.SetItemCharges = function(whichItem, charges)
|
|
|
56
65
|
____exports.Item:of(whichItem)
|
|
57
66
|
)
|
|
58
67
|
end
|
|
59
|
-
local getItemIntegerField = BlzGetItemIntegerField
|
|
60
|
-
local setItemBooleanField = BlzSetItemBooleanField
|
|
61
|
-
local getItemBooleanField = BlzGetItemBooleanField
|
|
62
68
|
invoke = Event.invoke
|
|
63
69
|
local enumRect = Rect:create(0, 0, 0, 0).handle
|
|
64
70
|
---
|
|
@@ -137,15 +143,13 @@ Item.name = "Item"
|
|
|
137
143
|
__TS__ClassExtends(Item, Handle)
|
|
138
144
|
function Item.prototype.____constructor(self, handle)
|
|
139
145
|
Handle.prototype.____constructor(self, handle)
|
|
140
|
-
|
|
141
|
-
self[100] = abilities
|
|
142
|
-
local luaIndexByAbilityTypeId = {}
|
|
143
|
-
for i = 1, #abilities do
|
|
144
|
-
luaIndexByAbilityTypeId[abilities[i].typeId] = i
|
|
145
|
-
end
|
|
146
|
-
self[101] = luaIndexByAbilityTypeId
|
|
146
|
+
self[100] = doAbilityAction(handle, getItemAbilities, self)
|
|
147
147
|
end
|
|
148
148
|
function Item.prototype.onDestroy(self)
|
|
149
|
+
local owner = self.owner
|
|
150
|
+
if owner ~= nil then
|
|
151
|
+
unitRemoveItem(owner.handle, self.handle)
|
|
152
|
+
end
|
|
149
153
|
local abilities = self[100]
|
|
150
154
|
for i = 1, #abilities do
|
|
151
155
|
abilities[i]:destroy()
|
|
@@ -191,33 +195,32 @@ function Item.prototype.addAbility(self, abilityTypeId)
|
|
|
191
195
|
if nativeAbility ~= nil then
|
|
192
196
|
local ability = ItemAbility:of(nativeAbility, abilityTypeId, self)
|
|
193
197
|
local abilities = self[100]
|
|
194
|
-
|
|
195
|
-
abilities[luaIndex] = ability
|
|
196
|
-
self[101][abilityTypeId] = luaIndex
|
|
198
|
+
abilities[#abilities + 1] = ability
|
|
197
199
|
return ability
|
|
198
200
|
end
|
|
199
201
|
return nil
|
|
200
202
|
end
|
|
201
203
|
function Item.prototype.removeAbility(self, abilityTypeId)
|
|
202
|
-
local
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
for j = luaIndex, abilityTypeIdsLength do
|
|
210
|
-
abilities[j] = abilities[j + 1]
|
|
204
|
+
local abilities = self[100]
|
|
205
|
+
for i = 1, #abilities do
|
|
206
|
+
if abilities[i].typeId == abilityTypeId then
|
|
207
|
+
local ability = abilities[i]
|
|
208
|
+
tableRemove(abilities, i)
|
|
209
|
+
ability:destroy()
|
|
210
|
+
return true
|
|
211
211
|
end
|
|
212
212
|
end
|
|
213
|
-
return
|
|
213
|
+
return doAbilityAction(self.handle, itemRemoveAbility, abilityTypeId)
|
|
214
214
|
end
|
|
215
215
|
function Item.prototype.hasAbility(self, abilityTypeId)
|
|
216
|
-
return self
|
|
216
|
+
return doAbilityAction(self.handle, getItemAbility, abilityTypeId) ~= nil
|
|
217
217
|
end
|
|
218
218
|
function Item.prototype.getAbility(self, abilityTypeId)
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
return ItemAbility:of(
|
|
220
|
+
doAbilityAction(self.handle, getItemAbility, abilityTypeId),
|
|
221
|
+
abilityTypeId,
|
|
222
|
+
self
|
|
223
|
+
)
|
|
221
224
|
end
|
|
222
225
|
function Item.getInRange(self, x, y, range)
|
|
223
226
|
targetCollection = {}
|
|
@@ -329,65 +332,68 @@ __TS__SetDescriptor(
|
|
|
329
332
|
)
|
|
330
333
|
__TS__SetDescriptor(
|
|
331
334
|
Item.prototype,
|
|
332
|
-
"
|
|
335
|
+
"dropsOnDeath",
|
|
333
336
|
{
|
|
334
337
|
get = function(self)
|
|
335
|
-
return
|
|
338
|
+
return getItemBooleanField(self.handle, ITEM_BF_DROPPED_WHEN_CARRIER_DIES)
|
|
336
339
|
end,
|
|
337
|
-
set = function(self,
|
|
338
|
-
|
|
340
|
+
set = function(self, dropsOnDeath)
|
|
341
|
+
setItemDropOnDeath(self.handle, dropsOnDeath)
|
|
339
342
|
end
|
|
340
343
|
},
|
|
341
344
|
true
|
|
342
345
|
)
|
|
343
346
|
__TS__SetDescriptor(
|
|
344
347
|
Item.prototype,
|
|
345
|
-
"
|
|
348
|
+
"canBeDropped",
|
|
346
349
|
{
|
|
347
350
|
get = function(self)
|
|
348
|
-
return
|
|
351
|
+
return getItemBooleanField(self.handle, ITEM_BF_CAN_BE_DROPPED)
|
|
349
352
|
end,
|
|
350
|
-
set = function(self,
|
|
351
|
-
|
|
353
|
+
set = function(self, canBeDropped)
|
|
354
|
+
setItemDroppable(self.handle, canBeDropped)
|
|
352
355
|
end
|
|
353
356
|
},
|
|
354
357
|
true
|
|
355
358
|
)
|
|
356
359
|
__TS__SetDescriptor(
|
|
357
360
|
Item.prototype,
|
|
358
|
-
"
|
|
361
|
+
"canBeSold",
|
|
359
362
|
{
|
|
360
363
|
get = function(self)
|
|
361
|
-
return
|
|
364
|
+
return isItemPawnable(self.handle)
|
|
362
365
|
end,
|
|
363
|
-
set = function(self,
|
|
364
|
-
|
|
366
|
+
set = function(self, canBeSold)
|
|
367
|
+
setItemPawnable(self.handle, canBeSold)
|
|
365
368
|
end
|
|
366
369
|
},
|
|
367
370
|
true
|
|
368
371
|
)
|
|
369
372
|
__TS__SetDescriptor(
|
|
370
373
|
Item.prototype,
|
|
371
|
-
"
|
|
374
|
+
"perishes",
|
|
372
375
|
{
|
|
373
376
|
get = function(self)
|
|
374
377
|
return getItemBooleanField(self.handle, ITEM_BF_PERISHABLE)
|
|
375
378
|
end,
|
|
376
|
-
set = function(self,
|
|
377
|
-
|
|
379
|
+
set = function(self, perishes)
|
|
380
|
+
local handle = self.handle
|
|
381
|
+
local powerUp = isItemPowerup(handle)
|
|
382
|
+
setItemBooleanField(handle, ITEM_BF_PERISHABLE, perishes)
|
|
383
|
+
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, powerUp)
|
|
378
384
|
end
|
|
379
385
|
},
|
|
380
386
|
true
|
|
381
387
|
)
|
|
382
388
|
__TS__SetDescriptor(
|
|
383
389
|
Item.prototype,
|
|
384
|
-
"
|
|
390
|
+
"isPowerUp",
|
|
385
391
|
{
|
|
386
392
|
get = function(self)
|
|
387
393
|
return isItemPowerup(self.handle)
|
|
388
394
|
end,
|
|
389
|
-
set = function(self,
|
|
390
|
-
setItemBooleanField(self.handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED,
|
|
395
|
+
set = function(self, isPowerUp)
|
|
396
|
+
setItemBooleanField(self.handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, isPowerUp)
|
|
391
397
|
end
|
|
392
398
|
},
|
|
393
399
|
true
|
|
@@ -423,16 +429,24 @@ __TS__SetDescriptor(
|
|
|
423
429
|
)
|
|
424
430
|
__TS__SetDescriptor(
|
|
425
431
|
Item.prototype,
|
|
426
|
-
"
|
|
432
|
+
"isActivelyUsed",
|
|
427
433
|
{
|
|
428
434
|
get = function(self)
|
|
429
435
|
return getItemBooleanField(self.handle, ITEM_BF_ACTIVELY_USED)
|
|
430
436
|
end,
|
|
431
|
-
set = function(self,
|
|
437
|
+
set = function(self, isActivelyUsed)
|
|
432
438
|
local handle = self.handle
|
|
433
|
-
local
|
|
434
|
-
|
|
435
|
-
|
|
439
|
+
local powerUp = isItemPowerup(handle)
|
|
440
|
+
local perishes = getItemBooleanField(handle, ITEM_BF_PERISHABLE)
|
|
441
|
+
local dropsOnDeath = getItemBooleanField(handle, ITEM_BF_DROPPED_WHEN_CARRIER_DIES)
|
|
442
|
+
local canBeDropped = getItemBooleanField(handle, ITEM_BF_CAN_BE_DROPPED)
|
|
443
|
+
local canBeSold = isItemPawnable(handle)
|
|
444
|
+
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, isActivelyUsed)
|
|
445
|
+
setItemPawnable(handle, canBeSold)
|
|
446
|
+
setItemDroppable(handle, canBeDropped)
|
|
447
|
+
setItemDropOnDeath(handle, dropsOnDeath)
|
|
448
|
+
setItemBooleanField(handle, ITEM_BF_PERISHABLE, perishes)
|
|
449
|
+
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, powerUp)
|
|
436
450
|
end
|
|
437
451
|
},
|
|
438
452
|
true
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local getLocalClientWidth = BlzGetLocalClientWidth
|
|
3
|
+
local getLocalClientHeight = BlzGetLocalClientHeight
|
|
4
|
+
---
|
|
5
|
+
-- @internal For use by internal systems only.
|
|
6
|
+
____exports.getFrameMinXMaxX = function()
|
|
7
|
+
local w = getLocalClientWidth()
|
|
8
|
+
local h = getLocalClientHeight()
|
|
9
|
+
local width4by3 = (w - h / 600 * 800) / 2
|
|
10
|
+
local pxtodpi = 0.6 / h
|
|
11
|
+
local minX = -width4by3 * pxtodpi
|
|
12
|
+
local maxX = minX + w * pxtodpi
|
|
13
|
+
return minX, maxX
|
|
14
|
+
end
|
|
15
|
+
---
|
|
16
|
+
-- @internal For use by internal systems only.
|
|
17
|
+
____exports.FRAME_MIN_Y = 0
|
|
18
|
+
---
|
|
19
|
+
-- @internal For use by internal systems only.
|
|
20
|
+
____exports.FRAME_MAX_Y = 0.6
|
|
21
|
+
return ____exports
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local getLocationZ = GetLocationZ
|
|
3
|
+
local moveLocation = MoveLocation
|
|
4
|
+
local location = Location(0, 0)
|
|
5
|
+
---
|
|
6
|
+
-- @internal For use by internal systems only.
|
|
7
|
+
____exports.getTerrainZ = function(x, y)
|
|
8
|
+
moveLocation(location, x, y)
|
|
9
|
+
return getLocationZ(location)
|
|
10
|
+
end
|
|
11
|
+
return ____exports
|
|
@@ -133,55 +133,55 @@ declare module "../unit" {
|
|
|
133
133
|
}
|
|
134
134
|
declare module "../unit" {
|
|
135
135
|
namespace Unit {
|
|
136
|
-
const
|
|
136
|
+
const abilityChannelingFinishEvent: DispatchingEvent<[Unit, Ability]>;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
declare module "../unit" {
|
|
140
140
|
namespace Unit {
|
|
141
|
-
const
|
|
141
|
+
const abilityStopEvent: DispatchingEvent<[Unit, Ability]>;
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
declare module "../unit" {
|
|
145
145
|
namespace Unit {
|
|
146
|
-
const
|
|
146
|
+
const abilityCommandEvent: {
|
|
147
|
+
readonly [abilityTypeId: number]: {
|
|
148
|
+
readonly [orderTypeStringId: string]: Event<[Unit, Ability, string]>;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
147
151
|
}
|
|
148
152
|
}
|
|
149
153
|
declare module "../unit" {
|
|
150
154
|
namespace Unit {
|
|
151
|
-
const
|
|
155
|
+
const abilityImpactEvent: DispatchingEvent<[Unit, Ability]>;
|
|
152
156
|
}
|
|
153
157
|
}
|
|
154
158
|
declare module "../unit" {
|
|
155
159
|
namespace Unit {
|
|
156
|
-
const
|
|
160
|
+
const abilityWidgetTargetImpactEvent: DispatchingEvent<[Unit, Ability, Widget]>;
|
|
157
161
|
}
|
|
158
162
|
}
|
|
159
163
|
declare module "../unit" {
|
|
160
164
|
namespace Unit {
|
|
161
|
-
const
|
|
165
|
+
const abilityUnitTargetImpactEvent: DispatchingEvent<[Unit, Ability, Unit]>;
|
|
162
166
|
}
|
|
163
167
|
}
|
|
164
168
|
declare module "../unit" {
|
|
165
169
|
namespace Unit {
|
|
166
|
-
const
|
|
170
|
+
const abilityItemTargetImpactEvent: DispatchingEvent<[Unit, Ability, Item]>;
|
|
167
171
|
}
|
|
168
172
|
}
|
|
169
173
|
declare module "../unit" {
|
|
170
174
|
namespace Unit {
|
|
171
|
-
const
|
|
175
|
+
const abilityDestructibleTargetImpactEvent: DispatchingEvent<[Unit, Ability, Destructable]>;
|
|
172
176
|
}
|
|
173
177
|
}
|
|
174
178
|
declare module "../unit" {
|
|
175
179
|
namespace Unit {
|
|
176
|
-
const
|
|
180
|
+
const abilityPointTargetImpactEvent: DispatchingEvent<[Unit, Ability, number, number]>;
|
|
177
181
|
}
|
|
178
182
|
}
|
|
179
183
|
declare module "../unit" {
|
|
180
184
|
namespace Unit {
|
|
181
|
-
const
|
|
182
|
-
readonly [abilityTypeId: number]: {
|
|
183
|
-
readonly [orderTypeStringId: string]: Event<[Unit, Ability, string]>;
|
|
184
|
-
};
|
|
185
|
-
};
|
|
185
|
+
const abilityNoTargetImpactEvent: DispatchingEvent<[Unit, Ability]>;
|
|
186
186
|
}
|
|
187
187
|
}
|
|
@@ -22,7 +22,12 @@ local checkNotNull = ____preconditions.checkNotNull
|
|
|
22
22
|
local ____lazy = require("utility.lazy")
|
|
23
23
|
local lazyRecord = ____lazy.lazyRecord
|
|
24
24
|
local ____timer = require("core.types.timer")
|
|
25
|
+
local consumeZeroTimerCallback = ____timer.consumeZeroTimerCallback
|
|
25
26
|
local Timer = ____timer.Timer
|
|
27
|
+
local ____lua_2Dsets = require("utility.lua-sets")
|
|
28
|
+
local luaSetOf = ____lua_2Dsets.luaSetOf
|
|
29
|
+
local ____attributes = require("attributes")
|
|
30
|
+
local attribute = ____attributes.attribute
|
|
26
31
|
local eventInvoke = Event.invoke
|
|
27
32
|
local condition = Condition
|
|
28
33
|
local createTrigger = CreateTrigger
|
|
@@ -347,10 +352,65 @@ rawset(
|
|
|
347
352
|
extractAbilityTypeId
|
|
348
353
|
)
|
|
349
354
|
)
|
|
355
|
+
local internalAbilityChannelingFinishEvent = __TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_FINISH, collectUnitAbilityEventParameters)
|
|
356
|
+
rawset(
|
|
357
|
+
Unit,
|
|
358
|
+
"abilityChannelingFinishEvent",
|
|
359
|
+
createDispatchingEvent(internalAbilityChannelingFinishEvent, extractAbilityTypeId)
|
|
360
|
+
)
|
|
361
|
+
local internalAbilityStopEvent = __TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_ENDCAST, collectUnitAbilityEventParameters)
|
|
362
|
+
rawset(
|
|
363
|
+
Unit,
|
|
364
|
+
"abilityStopEvent",
|
|
365
|
+
createDispatchingEvent(internalAbilityStopEvent, extractAbilityTypeId)
|
|
366
|
+
)
|
|
367
|
+
rawset(
|
|
368
|
+
Unit,
|
|
369
|
+
"abilityCommandEvent",
|
|
370
|
+
lazyRecord(function(abilityTypeId)
|
|
371
|
+
return lazyRecord(function(orderTypeStringId)
|
|
372
|
+
return __TS__New(
|
|
373
|
+
InitializingEvent,
|
|
374
|
+
function(event)
|
|
375
|
+
local trigger = createTrigger()
|
|
376
|
+
triggerRegisterCommandEvent(trigger, abilityTypeId, orderTypeStringId)
|
|
377
|
+
triggerAddCondition(
|
|
378
|
+
trigger,
|
|
379
|
+
condition(function()
|
|
380
|
+
local unit = Unit:of(getTriggerUnit())
|
|
381
|
+
if unit ~= nil then
|
|
382
|
+
local ability = unit:getAbility(abilityTypeId)
|
|
383
|
+
if ability ~= nil then
|
|
384
|
+
eventInvoke(event, unit, ability, orderTypeStringId)
|
|
385
|
+
end
|
|
386
|
+
end
|
|
387
|
+
end)
|
|
388
|
+
)
|
|
389
|
+
end
|
|
390
|
+
)
|
|
391
|
+
end)
|
|
392
|
+
end)
|
|
393
|
+
)
|
|
350
394
|
local internalAbilityImpactEvent = __TS__New(Event)
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
395
|
+
local impactCallbackIdAttribute = attribute()
|
|
396
|
+
local function invokeImpactEvent(unit, ability, ...)
|
|
397
|
+
ability[impactCallbackIdAttribute] = nil
|
|
398
|
+
eventInvoke(internalAbilityImpactEvent, unit, ability, ...)
|
|
399
|
+
end
|
|
400
|
+
internalAbilityChannelingStartEvent:addListener(
|
|
401
|
+
-999999,
|
|
402
|
+
function(unit, ability, ...)
|
|
403
|
+
ability[impactCallbackIdAttribute] = Timer:run(invokeImpactEvent, unit, ability, ...)
|
|
404
|
+
end
|
|
405
|
+
)
|
|
406
|
+
local function consumeImpactCallback(_, ability)
|
|
407
|
+
local impactCallbackId = ability[impactCallbackIdAttribute]
|
|
408
|
+
if impactCallbackId ~= nil then
|
|
409
|
+
consumeZeroTimerCallback(impactCallbackId)
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
internalAbilityChannelingFinishEvent:addListener(-999999, consumeImpactCallback)
|
|
413
|
+
internalAbilityStopEvent:addListener(-999999, consumeImpactCallback)
|
|
354
414
|
rawset(
|
|
355
415
|
Unit,
|
|
356
416
|
"abilityImpactEvent",
|
|
@@ -407,47 +467,14 @@ rawset(
|
|
|
407
467
|
extractAbilityTypeId
|
|
408
468
|
)
|
|
409
469
|
)
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
Unit,
|
|
420
|
-
"abilityStopEvent",
|
|
421
|
-
createDispatchingEvent(
|
|
422
|
-
__TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_ENDCAST, collectUnitAbilityEventParameters),
|
|
423
|
-
extractAbilityTypeId
|
|
424
|
-
)
|
|
425
|
-
)
|
|
426
|
-
rawset(
|
|
427
|
-
Unit,
|
|
428
|
-
"abilityCommandEvent",
|
|
429
|
-
lazyRecord(function(abilityTypeId)
|
|
430
|
-
return lazyRecord(function(orderTypeStringId)
|
|
431
|
-
return __TS__New(
|
|
432
|
-
InitializingEvent,
|
|
433
|
-
function(event)
|
|
434
|
-
local trigger = createTrigger()
|
|
435
|
-
triggerRegisterCommandEvent(trigger, abilityTypeId, orderTypeStringId)
|
|
436
|
-
triggerAddCondition(
|
|
437
|
-
trigger,
|
|
438
|
-
condition(function()
|
|
439
|
-
local unit = Unit:of(getTriggerUnit())
|
|
440
|
-
if unit ~= nil then
|
|
441
|
-
local ability = unit:getAbilityById(abilityTypeId)
|
|
442
|
-
if ability ~= nil then
|
|
443
|
-
eventInvoke(event, unit, ability, orderTypeStringId)
|
|
444
|
-
end
|
|
445
|
-
end
|
|
446
|
-
end)
|
|
447
|
-
)
|
|
448
|
-
end
|
|
449
|
-
)
|
|
450
|
-
end)
|
|
451
|
-
end)
|
|
470
|
+
local spellEffectOnlyAbilityTypeIds = luaSetOf(fourCC("AAns"))
|
|
471
|
+
internalAbilityChannelingStartEvent:addListener(
|
|
472
|
+
-999999,
|
|
473
|
+
function(unit, ability)
|
|
474
|
+
if spellEffectOnlyAbilityTypeIds[ability.parentTypeId] ~= nil then
|
|
475
|
+
eventInvoke(internalAbilityChannelingFinishEvent, unit, ability)
|
|
476
|
+
eventInvoke(internalAbilityStopEvent, unit, ability)
|
|
477
|
+
end
|
|
478
|
+
end
|
|
452
479
|
)
|
|
453
480
|
return ____exports
|
|
@@ -7,8 +7,8 @@ local UnitAbility = ____ability.UnitAbility
|
|
|
7
7
|
local ____unit = require("engine.internal.unit")
|
|
8
8
|
local Unit = ____unit.Unit
|
|
9
9
|
local ____event = require("event")
|
|
10
|
-
local Event = ____event.Event
|
|
11
10
|
local createDispatchingEvent = ____event.createDispatchingEvent
|
|
11
|
+
local Event = ____event.Event
|
|
12
12
|
local abilityGainedEvent = createDispatchingEvent(
|
|
13
13
|
__TS__New(Event),
|
|
14
14
|
function(unit, ability) return ability.typeId end
|
|
@@ -40,6 +40,15 @@ ItemAbility.onCreate:addListener(
|
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
)
|
|
43
|
+
ItemAbility.destroyEvent:addListener(
|
|
44
|
+
4,
|
|
45
|
+
function(ability)
|
|
46
|
+
local unit = ability.owner.owner
|
|
47
|
+
if unit ~= nil then
|
|
48
|
+
Event.invoke(abilityLostEvent, unit, ability)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
)
|
|
43
52
|
Unit.itemPickedUpEvent:addListener(
|
|
44
53
|
0,
|
|
45
54
|
function(unit, item)
|
|
@@ -9,6 +9,8 @@ local ____timer = require("core.types.timer")
|
|
|
9
9
|
local Timer = ____timer.Timer
|
|
10
10
|
local ____lua_2Dsets = require("utility.lua-sets")
|
|
11
11
|
local luaSetOf = ____lua_2Dsets.luaSetOf
|
|
12
|
+
local ____math = require("math")
|
|
13
|
+
local min = ____math.min
|
|
12
14
|
local autoAttackFinishEvent = __TS__New(Event)
|
|
13
15
|
rawset(Unit, "autoAttackFinishEvent", autoAttackFinishEvent)
|
|
14
16
|
local eventTimerByUnit = {}
|
|
@@ -43,9 +45,20 @@ local function timerCallback(source, target)
|
|
|
43
45
|
eventTimerByUnit[source] = nil
|
|
44
46
|
Event.invoke(autoAttackFinishEvent, source, target)
|
|
45
47
|
end
|
|
46
|
-
Unit.autoAttackStartEvent:addListener(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
Unit.autoAttackStartEvent:addListener(
|
|
49
|
+
4,
|
|
50
|
+
function(source, target)
|
|
51
|
+
local attackPoint = (source:chooseWeapon(target) or source.firstWeapon).impactDelay
|
|
52
|
+
local timer = Timer:simple(
|
|
53
|
+
attackPoint + min(
|
|
54
|
+
compiletime(1 / 64),
|
|
55
|
+
attackPoint / 2
|
|
56
|
+
),
|
|
57
|
+
timerCallback,
|
|
58
|
+
source,
|
|
59
|
+
target
|
|
60
|
+
)
|
|
61
|
+
eventTimerByUnit[source] = timer
|
|
62
|
+
end
|
|
63
|
+
)
|
|
51
64
|
return ____exports
|
|
@@ -146,6 +146,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
146
146
|
get isHero(): boolean;
|
|
147
147
|
get isAlive(): boolean;
|
|
148
148
|
get isDead(): boolean;
|
|
149
|
+
get isRemoved(): boolean;
|
|
149
150
|
get isIllusion(): boolean;
|
|
150
151
|
get isStunned(): boolean;
|
|
151
152
|
get combatClassifications(): CombatClassifications;
|
|
@@ -160,8 +161,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
160
161
|
isInRangeOf(unit: Unit, range: number): boolean;
|
|
161
162
|
isAllyOf(unit: Unit): boolean;
|
|
162
163
|
isEnemyOf(unit: Unit): boolean;
|
|
163
|
-
playAnimation(animation: string, rarity?: jraritycontrol): void;
|
|
164
|
-
playAnimation(animation: number): void;
|
|
164
|
+
playAnimation(...parameters: [animation: number] | [animation: string, rarity?: jraritycontrol]): void;
|
|
165
165
|
resetAnimation(): void;
|
|
166
166
|
queueAnimation(animation: string): void;
|
|
167
167
|
get weapons(): [UnitWeapon, UnitWeapon];
|
|
@@ -272,8 +272,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
272
272
|
setAbilityLevel(abilityId: number, level: number): number;
|
|
273
273
|
getAbilityLevel(abilityId: number): number;
|
|
274
274
|
hasAbility(abilityId: number): boolean;
|
|
275
|
-
|
|
276
|
-
removeAbility(
|
|
275
|
+
getAbility(abilityId: number): UnitAbility | undefined;
|
|
276
|
+
removeAbility(abilityTypeId: number): boolean;
|
|
277
277
|
hideAbility(abilityId: number, flag: boolean): void;
|
|
278
278
|
getAbilityRemainingCooldown(abilityId: number): number;
|
|
279
279
|
startAbilityCooldown(abilityId: number, cooldown: number): void;
|
|
@@ -354,7 +354,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
354
354
|
static itemDroppedEvent: UnitTriggerEvent<[Item]>;
|
|
355
355
|
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
356
356
|
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
357
|
-
static itemStackedEvent: UnitTriggerEvent<[Item]>;
|
|
357
|
+
static itemStackedEvent: UnitTriggerEvent<[target: Item, source: Item]>;
|
|
358
358
|
static get itemChargesChangedEvent(): Event<[unit: Unit, item: Item]>;
|
|
359
359
|
static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
|
|
360
360
|
static get itemMoveOrderEvent(): Event<[
|
package/engine/internal/unit.lua
CHANGED
|
@@ -935,23 +935,21 @@ end
|
|
|
935
935
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
936
936
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
937
937
|
end
|
|
938
|
-
function Unit.prototype.
|
|
938
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
939
939
|
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
940
940
|
return UnitAbility:of(ability, abilityId, self)
|
|
941
941
|
end
|
|
942
|
-
function Unit.prototype.removeAbility(self,
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
end
|
|
942
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
943
|
+
local abilities = self.abilities
|
|
944
|
+
for i = 1, #abilities do
|
|
945
|
+
if abilities[i].typeId == abilityTypeId then
|
|
946
|
+
local ability = abilities[i]
|
|
947
|
+
tremove(abilities, i)
|
|
948
|
+
ability:destroy()
|
|
949
|
+
return true
|
|
951
950
|
end
|
|
952
|
-
return true
|
|
953
951
|
end
|
|
954
|
-
return
|
|
952
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
955
953
|
end
|
|
956
954
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
957
955
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -1249,6 +1247,14 @@ __TS__SetDescriptor(
|
|
|
1249
1247
|
end},
|
|
1250
1248
|
true
|
|
1251
1249
|
)
|
|
1250
|
+
__TS__SetDescriptor(
|
|
1251
|
+
Unit.prototype,
|
|
1252
|
+
"isRemoved",
|
|
1253
|
+
{get = function(self)
|
|
1254
|
+
return getUnitAbilityLevel(self.handle, leaveDetectAbilityId) == 0
|
|
1255
|
+
end},
|
|
1256
|
+
true
|
|
1257
|
+
)
|
|
1252
1258
|
__TS__SetDescriptor(
|
|
1253
1259
|
Unit.prototype,
|
|
1254
1260
|
"isIllusion",
|
|
@@ -2670,10 +2676,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2670
2676
|
____exports.UnitTriggerEvent,
|
|
2671
2677
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2672
2678
|
function()
|
|
2673
|
-
local
|
|
2674
|
-
local
|
|
2675
|
-
if getUnitTypeId(
|
|
2676
|
-
|
|
2679
|
+
local unitHandle = getTriggerUnit()
|
|
2680
|
+
local itemHandle = getManipulatedItem()
|
|
2681
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2682
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2683
|
+
local item = Item:of(itemHandle)
|
|
2684
|
+
if item.owner ~= unit then
|
|
2685
|
+
return unit, item
|
|
2686
|
+
end
|
|
2677
2687
|
end
|
|
2678
2688
|
return IgnoreEvent
|
|
2679
2689
|
end
|
|
@@ -2693,7 +2703,7 @@ Unit.itemUsedEvent = __TS__New(
|
|
|
2693
2703
|
Unit.itemStackedEvent = __TS__New(
|
|
2694
2704
|
____exports.UnitTriggerEvent,
|
|
2695
2705
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2696
|
-
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(
|
|
2706
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2697
2707
|
)
|
|
2698
2708
|
__TS__ObjectDefineProperty(
|
|
2699
2709
|
Unit,
|