warscript 0.0.1-dev.eb24bc1 → 0.0.1-dev.eb6b18a
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/engine/behaviour/ability/emulate-impact.lua +9 -2
- package/engine/behaviour/ability.lua +8 -17
- package/engine/behaviour/unit/stun-immunity.d.ts +5 -3
- package/engine/behaviour/unit/stun-immunity.lua +43 -27
- package/engine/behaviour/unit.d.ts +24 -0
- package/engine/behaviour/unit.lua +158 -4
- package/engine/internal/ability.d.ts +4 -0
- package/engine/internal/ability.lua +17 -0
- package/engine/internal/item/ability.lua +12 -10
- package/engine/internal/item.d.ts +3 -1
- package/engine/internal/item.lua +75 -3
- package/engine/internal/unit/ability.d.ts +35 -0
- package/engine/internal/unit/ability.lua +62 -0
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit-missile-launch.lua +1 -1
- package/engine/internal/unit.d.ts +9 -1
- package/engine/internal/unit.lua +90 -1
- 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-field/unit.d.ts +4 -0
- package/engine/object-field/unit.lua +13 -0
- package/engine/object-field.d.ts +6 -3
- package/engine/object-field.lua +85 -73
- package/engine/standard/fields/unit.d.ts +3 -0
- package/engine/standard/fields/unit.lua +5 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +175 -10
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/package.json +1 -1
- package/utility/lua-maps.d.ts +1 -0
- package/utility/lua-maps.lua +4 -0
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
package/engine/internal/item.lua
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__New = ____lualib.__TS__New
|
|
2
3
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
4
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
5
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
5
6
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
6
7
|
local __TS__Delete = ____lualib.__TS__Delete
|
|
7
8
|
local ____exports = {}
|
|
9
|
+
local invoke
|
|
8
10
|
local ____handle = require("core.types.handle")
|
|
9
11
|
local Handle = ____handle.Handle
|
|
10
12
|
local ____color = require("core.types.color")
|
|
11
13
|
local Color = ____color.Color
|
|
14
|
+
local ____event = require("event")
|
|
15
|
+
local Event = ____event.Event
|
|
12
16
|
local ____rect = require("core.types.rect")
|
|
13
17
|
local Rect = ____rect.Rect
|
|
14
18
|
local ____ability = require("engine.internal.ability")
|
|
15
19
|
local ItemAbility = ____ability.ItemAbility
|
|
16
20
|
local ____ability = require("engine.internal.item.ability")
|
|
17
21
|
local doAbilityAction = ____ability.doAbilityAction
|
|
22
|
+
local doAbilityActionForceDummy = ____ability.doAbilityActionForceDummy
|
|
23
|
+
local itemAbilityDummy = ____ability.itemAbilityDummy
|
|
18
24
|
local ____dummy_2Ditem = require("engine.internal.object-data.dummy-item")
|
|
19
25
|
local DUMMY_ITEM_ID = ____dummy_2Ditem.DUMMY_ITEM_ID
|
|
20
26
|
local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
|
|
21
27
|
local SLOT_FILLER_ITEM_TYPE_ID = ____add_2Ditem_2Dto_2Dslot.SLOT_FILLER_ITEM_TYPE_ID
|
|
22
28
|
local ____vec2 = require("math.vec2")
|
|
23
29
|
local distance = ____vec2.distance
|
|
30
|
+
local itemChargesChangeEvent = __TS__New(Event)
|
|
24
31
|
local itemAddAbility = BlzItemAddAbility
|
|
25
32
|
local itemRemoveAbility = BlzItemRemoveAbility
|
|
26
33
|
local getItemAbility = BlzGetItemAbility
|
|
@@ -36,10 +43,26 @@ local getEnumItem = GetEnumItem
|
|
|
36
43
|
local getItemTypeId = GetItemTypeId
|
|
37
44
|
local getItemX = GetItemX
|
|
38
45
|
local getItemY = GetItemY
|
|
46
|
+
local getItemCharges = GetItemCharges
|
|
47
|
+
local setItemCharges = SetItemCharges
|
|
48
|
+
local unitRemoveAbility = UnitRemoveAbility
|
|
49
|
+
local unitUseItem = UnitUseItem
|
|
50
|
+
local unitUseItemPoint = UnitUseItemPoint
|
|
51
|
+
local unitUseItemTarget = UnitUseItemTarget
|
|
52
|
+
_G.SetItemCharges = function(whichItem, charges)
|
|
53
|
+
setItemCharges(whichItem, charges)
|
|
54
|
+
invoke(
|
|
55
|
+
itemChargesChangeEvent,
|
|
56
|
+
____exports.Item:of(whichItem)
|
|
57
|
+
)
|
|
58
|
+
end
|
|
39
59
|
local getItemIntegerField = BlzGetItemIntegerField
|
|
40
60
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
41
61
|
local getItemBooleanField = BlzGetItemBooleanField
|
|
62
|
+
invoke = Event.invoke
|
|
42
63
|
local enumRect = Rect:create(0, 0, 0, 0).handle
|
|
64
|
+
---
|
|
65
|
+
-- @internal For use by internal systems only.
|
|
43
66
|
____exports.addAndGetAbility = function(handle, abilityTypeId)
|
|
44
67
|
if itemAddAbility(handle, abilityTypeId) then
|
|
45
68
|
return getItemAbility(handle, abilityTypeId)
|
|
@@ -65,6 +88,23 @@ local function getItemAbilities(handle, item)
|
|
|
65
88
|
end
|
|
66
89
|
return abilities
|
|
67
90
|
end
|
|
91
|
+
local function consumeCharge(handle)
|
|
92
|
+
do
|
|
93
|
+
local i = 0
|
|
94
|
+
local ability = getItemAbilityByIndex(handle, i)
|
|
95
|
+
while ability ~= nil do
|
|
96
|
+
unitRemoveAbility(
|
|
97
|
+
itemAbilityDummy,
|
|
98
|
+
getAbilityId(ability)
|
|
99
|
+
)
|
|
100
|
+
do
|
|
101
|
+
i = i + 1
|
|
102
|
+
ability = getItemAbilityByIndex(handle, i)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
return unitUseItem(itemAbilityDummy, handle) or unitUseItemPoint(itemAbilityDummy, handle, 0, 0) or unitUseItemTarget(itemAbilityDummy, handle, itemAbilityDummy)
|
|
107
|
+
end
|
|
68
108
|
local targetCollection
|
|
69
109
|
local targetCollectionNextIndex
|
|
70
110
|
local centerX
|
|
@@ -116,6 +156,36 @@ end
|
|
|
116
156
|
function Item.create(self, id, x, y, skinId)
|
|
117
157
|
return self:of(BlzCreateItemWithSkin(id, x, y, skinId or id))
|
|
118
158
|
end
|
|
159
|
+
function Item.prototype.consumeCharge(self)
|
|
160
|
+
return self:consumeCharges(1)
|
|
161
|
+
end
|
|
162
|
+
function Item.prototype.consumeCharges(self, count)
|
|
163
|
+
local handle = self.handle
|
|
164
|
+
local charges = getItemCharges(handle)
|
|
165
|
+
if charges > count then
|
|
166
|
+
setItemCharges(handle, charges - count)
|
|
167
|
+
invoke(itemChargesChangeEvent, self)
|
|
168
|
+
return true
|
|
169
|
+
end
|
|
170
|
+
if charges == count then
|
|
171
|
+
if getItemBooleanField(handle, ITEM_BF_PERISHABLE) then
|
|
172
|
+
self:destroy()
|
|
173
|
+
return true
|
|
174
|
+
end
|
|
175
|
+
if not getItemBooleanField(handle, ITEM_BF_ACTIVELY_USED) then
|
|
176
|
+
setItemCharges(handle, 0)
|
|
177
|
+
invoke(itemChargesChangeEvent, self)
|
|
178
|
+
return true
|
|
179
|
+
end
|
|
180
|
+
setItemCharges(handle, 1)
|
|
181
|
+
local ____doAbilityActionForceDummy_2 = doAbilityActionForceDummy
|
|
182
|
+
local ____opt_0 = self.owner
|
|
183
|
+
____doAbilityActionForceDummy_2(handle, ____opt_0 and ____opt_0.handle, consumeCharge)
|
|
184
|
+
invoke(itemChargesChangeEvent, self)
|
|
185
|
+
return true
|
|
186
|
+
end
|
|
187
|
+
return false
|
|
188
|
+
end
|
|
119
189
|
function Item.prototype.addAbility(self, abilityTypeId)
|
|
120
190
|
local nativeAbility = doAbilityAction(self.handle, ____exports.addAndGetAbility, abilityTypeId)
|
|
121
191
|
if nativeAbility ~= nil then
|
|
@@ -301,7 +371,7 @@ __TS__SetDescriptor(
|
|
|
301
371
|
"perishable",
|
|
302
372
|
{
|
|
303
373
|
get = function(self)
|
|
304
|
-
return
|
|
374
|
+
return getItemBooleanField(self.handle, ITEM_BF_PERISHABLE)
|
|
305
375
|
end,
|
|
306
376
|
set = function(self, v)
|
|
307
377
|
BlzSetItemBooleanField(self.handle, ITEM_BF_PERISHABLE, v)
|
|
@@ -557,10 +627,11 @@ __TS__SetDescriptor(
|
|
|
557
627
|
"charges",
|
|
558
628
|
{
|
|
559
629
|
get = function(self)
|
|
560
|
-
return
|
|
630
|
+
return getItemCharges(self.handle)
|
|
561
631
|
end,
|
|
562
632
|
set = function(self, v)
|
|
563
|
-
|
|
633
|
+
setItemCharges(self.handle, v)
|
|
634
|
+
invoke(itemChargesChangeEvent, self)
|
|
564
635
|
end
|
|
565
636
|
},
|
|
566
637
|
true
|
|
@@ -587,6 +658,7 @@ __TS__ObjectDefineProperty(
|
|
|
587
658
|
return self.onDestroyEvent
|
|
588
659
|
end}
|
|
589
660
|
)
|
|
661
|
+
Item.chargesChangedEvent = itemChargesChangeEvent
|
|
590
662
|
local getManipulatedItem = GetManipulatedItem
|
|
591
663
|
local trigger = CreateTrigger()
|
|
592
664
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_PICKUP_ITEM)
|
|
@@ -131,6 +131,41 @@ declare module "../unit" {
|
|
|
131
131
|
const abilityNoTargetChannelingStartEvent: DispatchingEvent<[Unit, Ability]>;
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
+
declare module "../unit" {
|
|
135
|
+
namespace Unit {
|
|
136
|
+
const abilityImpactEvent: DispatchingEvent<[Unit, Ability]>;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
declare module "../unit" {
|
|
140
|
+
namespace Unit {
|
|
141
|
+
const abilityWidgetTargetImpactEvent: DispatchingEvent<[Unit, Ability, Widget]>;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
declare module "../unit" {
|
|
145
|
+
namespace Unit {
|
|
146
|
+
const abilityUnitTargetImpactEvent: DispatchingEvent<[Unit, Ability, Unit]>;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
declare module "../unit" {
|
|
150
|
+
namespace Unit {
|
|
151
|
+
const abilityItemTargetImpactEvent: DispatchingEvent<[Unit, Ability, Item]>;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
declare module "../unit" {
|
|
155
|
+
namespace Unit {
|
|
156
|
+
const abilityDestructibleTargetImpactEvent: DispatchingEvent<[Unit, Ability, Destructable]>;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
declare module "../unit" {
|
|
160
|
+
namespace Unit {
|
|
161
|
+
const abilityPointTargetImpactEvent: DispatchingEvent<[Unit, Ability, number, number]>;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
declare module "../unit" {
|
|
165
|
+
namespace Unit {
|
|
166
|
+
const abilityNoTargetImpactEvent: DispatchingEvent<[Unit, Ability]>;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
134
169
|
declare module "../unit" {
|
|
135
170
|
namespace Unit {
|
|
136
171
|
const abilityChannelingFinishEvent: DispatchingEvent<[Unit, Ability]>;
|
|
@@ -21,6 +21,8 @@ local ____preconditions = require("utility.preconditions")
|
|
|
21
21
|
local checkNotNull = ____preconditions.checkNotNull
|
|
22
22
|
local ____lazy = require("utility.lazy")
|
|
23
23
|
local lazyRecord = ____lazy.lazyRecord
|
|
24
|
+
local ____timer = require("core.types.timer")
|
|
25
|
+
local Timer = ____timer.Timer
|
|
24
26
|
local eventInvoke = Event.invoke
|
|
25
27
|
local condition = Condition
|
|
26
28
|
local createTrigger = CreateTrigger
|
|
@@ -345,6 +347,66 @@ rawset(
|
|
|
345
347
|
extractAbilityTypeId
|
|
346
348
|
)
|
|
347
349
|
)
|
|
350
|
+
local internalAbilityImpactEvent = __TS__New(Event)
|
|
351
|
+
internalAbilityChannelingStartEvent:addListener(function(...)
|
|
352
|
+
Timer:run(eventInvoke, internalAbilityImpactEvent, ...)
|
|
353
|
+
end)
|
|
354
|
+
rawset(
|
|
355
|
+
Unit,
|
|
356
|
+
"abilityImpactEvent",
|
|
357
|
+
createDispatchingEvent(
|
|
358
|
+
createCommonEvent(internalAbilityImpactEvent),
|
|
359
|
+
extractAbilityTypeId
|
|
360
|
+
)
|
|
361
|
+
)
|
|
362
|
+
rawset(
|
|
363
|
+
Unit,
|
|
364
|
+
"abilityWidgetTargetImpactEvent",
|
|
365
|
+
createDispatchingEvent(
|
|
366
|
+
createWidgetTargetEvent(internalAbilityImpactEvent),
|
|
367
|
+
extractAbilityTypeId
|
|
368
|
+
)
|
|
369
|
+
)
|
|
370
|
+
rawset(
|
|
371
|
+
Unit,
|
|
372
|
+
"abilityUnitTargetImpactEvent",
|
|
373
|
+
createDispatchingEvent(
|
|
374
|
+
createUnitTargetEvent(internalAbilityImpactEvent),
|
|
375
|
+
extractAbilityTypeId
|
|
376
|
+
)
|
|
377
|
+
)
|
|
378
|
+
rawset(
|
|
379
|
+
Unit,
|
|
380
|
+
"abilityItemTargetImpactEvent",
|
|
381
|
+
createDispatchingEvent(
|
|
382
|
+
createItemTargetEvent(internalAbilityImpactEvent),
|
|
383
|
+
extractAbilityTypeId
|
|
384
|
+
)
|
|
385
|
+
)
|
|
386
|
+
rawset(
|
|
387
|
+
Unit,
|
|
388
|
+
"abilityDestructibleTargetImpactEvent",
|
|
389
|
+
createDispatchingEvent(
|
|
390
|
+
createDestructibleTargetEvent(internalAbilityImpactEvent),
|
|
391
|
+
extractAbilityTypeId
|
|
392
|
+
)
|
|
393
|
+
)
|
|
394
|
+
rawset(
|
|
395
|
+
Unit,
|
|
396
|
+
"abilityPointTargetImpactEvent",
|
|
397
|
+
createDispatchingEvent(
|
|
398
|
+
createPointTargetEvent(internalAbilityImpactEvent),
|
|
399
|
+
extractAbilityTypeId
|
|
400
|
+
)
|
|
401
|
+
)
|
|
402
|
+
rawset(
|
|
403
|
+
Unit,
|
|
404
|
+
"abilityNoTargetImpactEvent",
|
|
405
|
+
createDispatchingEvent(
|
|
406
|
+
createNoTargetEvent(internalAbilityImpactEvent),
|
|
407
|
+
extractAbilityTypeId
|
|
408
|
+
)
|
|
409
|
+
)
|
|
348
410
|
rawset(
|
|
349
411
|
Unit,
|
|
350
412
|
"abilityChannelingFinishEvent",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { CombatClassifications } from "../../object-data/auxiliary/combat-classification";
|
|
3
3
|
declare module "../unit" {
|
|
4
4
|
interface Unit {
|
|
5
|
-
isAllowedTarget(this: Unit, source: Unit, allowedTargetCombatClassifications
|
|
5
|
+
isAllowedTarget(this: Unit, source: Unit, allowedTargetCombatClassifications?: CombatClassifications): boolean;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
declare module "../unit" {
|
|
@@ -5,7 +5,15 @@ local initializeFilterTargetState = ____combat_2Dclassification.initializeFilter
|
|
|
5
5
|
local ____unit = require("engine.internal.unit")
|
|
6
6
|
local Unit = ____unit.Unit
|
|
7
7
|
Unit.prototype.isAllowedTarget = function(self, source, allowedTargetCombatClassifications)
|
|
8
|
-
|
|
8
|
+
if allowedTargetCombatClassifications ~= nil then
|
|
9
|
+
initializeFilterTargetState(source, allowedTargetCombatClassifications)
|
|
10
|
+
return filterTarget(self)
|
|
11
|
+
end
|
|
12
|
+
initializeFilterTargetState(source, source.firstWeapon.allowedTargetCombatClassifications)
|
|
13
|
+
if filterTarget(self) then
|
|
14
|
+
return true
|
|
15
|
+
end
|
|
16
|
+
initializeFilterTargetState(source, source.secondWeapon.allowedTargetCombatClassifications)
|
|
9
17
|
return filterTarget(self)
|
|
10
18
|
end
|
|
11
19
|
Unit.getAllowedTargetsInRange = function(source, allowedTargetCombatClassifications, x, y, range)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { Widget } from "../../../core/types/widget";
|
|
3
|
+
export declare const enum OrderType {
|
|
4
|
+
IMMEDIATE = 0,
|
|
5
|
+
POINT = 1,
|
|
6
|
+
TARGET = 2
|
|
7
|
+
}
|
|
8
|
+
declare module "../unit" {
|
|
9
|
+
interface Unit {
|
|
10
|
+
readonly currentOrderType: OrderType;
|
|
11
|
+
readonly currentOrderId: number;
|
|
12
|
+
readonly currentOrderStartTime: number;
|
|
13
|
+
readonly currentOrderStartX: number;
|
|
14
|
+
readonly currentOrderStartY: number;
|
|
15
|
+
readonly currentOrderTargetX: number;
|
|
16
|
+
readonly currentOrderTargetY: number;
|
|
17
|
+
readonly currentOrderTarget?: Widget;
|
|
18
|
+
issueOrder(...order: [orderType: OrderType.IMMEDIATE, orderId: number] | [orderType: OrderType.POINT, orderId: number, x: number, y: number] | [orderType: OrderType.TARGET, orderId: number, target: Widget]): boolean;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
3
|
+
local ____exports = {}
|
|
4
|
+
local ____attributes = require("attributes")
|
|
5
|
+
local attribute = ____attributes.attribute
|
|
6
|
+
local ____unit = require("engine.internal.unit")
|
|
7
|
+
local Unit = ____unit.Unit
|
|
8
|
+
local ____game = require("core.game")
|
|
9
|
+
local elapsedTime = ____game.elapsedTime
|
|
10
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
11
|
+
local issueImmediateOrderById = IssueImmediateOrderById
|
|
12
|
+
local issuePointOrderById = IssuePointOrderById
|
|
13
|
+
local issueTargetOrderById = IssueTargetOrderById
|
|
14
|
+
local unitLastOrderTypeAttribute = attribute()
|
|
15
|
+
local unitLastOrderIdAttribute = attribute()
|
|
16
|
+
local unitLastOrderStartTimeAttribute = attribute()
|
|
17
|
+
local unitLastOrderStartXAttribute = attribute()
|
|
18
|
+
local unitLastOrderStartYAttribute = attribute()
|
|
19
|
+
local unitLastOrderTargetXAttribute = attribute()
|
|
20
|
+
local unitLastOrderTargetYAttribute = attribute()
|
|
21
|
+
local unitLastOrderTargetAttribute = attribute()
|
|
22
|
+
Unit.onImmediateOrder:addListener(
|
|
23
|
+
4,
|
|
24
|
+
function(unit, orderId)
|
|
25
|
+
unit[unitLastOrderTypeAttribute] = 0
|
|
26
|
+
unit[unitLastOrderIdAttribute] = orderId
|
|
27
|
+
unit[unitLastOrderStartTimeAttribute] = elapsedTime()
|
|
28
|
+
unit[unitLastOrderStartXAttribute] = unit.x
|
|
29
|
+
unit[unitLastOrderStartYAttribute] = unit.y
|
|
30
|
+
unit[unitLastOrderTargetXAttribute] = nil
|
|
31
|
+
unit[unitLastOrderTargetYAttribute] = nil
|
|
32
|
+
unit[unitLastOrderTargetAttribute] = nil
|
|
33
|
+
end
|
|
34
|
+
)
|
|
35
|
+
Unit.onPointOrder:addListener(
|
|
36
|
+
4,
|
|
37
|
+
function(unit, orderId, x, y)
|
|
38
|
+
unit[unitLastOrderTypeAttribute] = 1
|
|
39
|
+
unit[unitLastOrderIdAttribute] = orderId
|
|
40
|
+
unit[unitLastOrderStartTimeAttribute] = elapsedTime()
|
|
41
|
+
unit[unitLastOrderStartXAttribute] = unit.x
|
|
42
|
+
unit[unitLastOrderStartYAttribute] = unit.y
|
|
43
|
+
unit[unitLastOrderTargetXAttribute] = x
|
|
44
|
+
unit[unitLastOrderTargetYAttribute] = y
|
|
45
|
+
unit[unitLastOrderTargetAttribute] = nil
|
|
46
|
+
end
|
|
47
|
+
)
|
|
48
|
+
Unit.onTargetOrder:addListener(
|
|
49
|
+
4,
|
|
50
|
+
function(unit, orderId, target)
|
|
51
|
+
unit[unitLastOrderTypeAttribute] = 2
|
|
52
|
+
unit[unitLastOrderIdAttribute] = orderId
|
|
53
|
+
unit[unitLastOrderStartTimeAttribute] = elapsedTime()
|
|
54
|
+
unit[unitLastOrderStartXAttribute] = unit.x
|
|
55
|
+
unit[unitLastOrderStartYAttribute] = unit.y
|
|
56
|
+
unit[unitLastOrderTargetXAttribute] = target.x
|
|
57
|
+
unit[unitLastOrderTargetYAttribute] = target.y
|
|
58
|
+
unit[unitLastOrderTargetAttribute] = target
|
|
59
|
+
end
|
|
60
|
+
)
|
|
61
|
+
local function toUndefinedIfCurrentOrderDoesNotMatchLast(unit, value)
|
|
62
|
+
local currentOrderId = getUnitCurrentOrder(unit.handle)
|
|
63
|
+
local lastOrderId = unit[unitLastOrderIdAttribute]
|
|
64
|
+
local ____temp_0
|
|
65
|
+
if currentOrderId == lastOrderId or currentOrderId == orderId("patrolAI") and lastOrderId == orderId("patrol") then
|
|
66
|
+
____temp_0 = value
|
|
67
|
+
else
|
|
68
|
+
____temp_0 = nil
|
|
69
|
+
end
|
|
70
|
+
return ____temp_0
|
|
71
|
+
end
|
|
72
|
+
__TS__ObjectDefineProperty(
|
|
73
|
+
Unit.prototype,
|
|
74
|
+
"currentOrderType",
|
|
75
|
+
{get = function(self)
|
|
76
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTypeAttribute]) or 0
|
|
77
|
+
end}
|
|
78
|
+
)
|
|
79
|
+
__TS__ObjectDefineProperty(
|
|
80
|
+
Unit.prototype,
|
|
81
|
+
"currentOrderId",
|
|
82
|
+
{get = function(self)
|
|
83
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderIdAttribute]) or 0
|
|
84
|
+
end}
|
|
85
|
+
)
|
|
86
|
+
__TS__ObjectDefineProperty(
|
|
87
|
+
Unit.prototype,
|
|
88
|
+
"currentOrderStartTime",
|
|
89
|
+
{get = function(self)
|
|
90
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderStartTimeAttribute]) or 0
|
|
91
|
+
end}
|
|
92
|
+
)
|
|
93
|
+
__TS__ObjectDefineProperty(
|
|
94
|
+
Unit.prototype,
|
|
95
|
+
"currentOrderStartX",
|
|
96
|
+
{get = function(self)
|
|
97
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderStartXAttribute]) or 0
|
|
98
|
+
end}
|
|
99
|
+
)
|
|
100
|
+
__TS__ObjectDefineProperty(
|
|
101
|
+
Unit.prototype,
|
|
102
|
+
"currentOrderStartY",
|
|
103
|
+
{get = function(self)
|
|
104
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderStartYAttribute]) or 0
|
|
105
|
+
end}
|
|
106
|
+
)
|
|
107
|
+
__TS__ObjectDefineProperty(
|
|
108
|
+
Unit.prototype,
|
|
109
|
+
"currentOrderTargetX",
|
|
110
|
+
{get = function(self)
|
|
111
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTargetXAttribute]) or 0
|
|
112
|
+
end}
|
|
113
|
+
)
|
|
114
|
+
__TS__ObjectDefineProperty(
|
|
115
|
+
Unit.prototype,
|
|
116
|
+
"currentOrderTargetY",
|
|
117
|
+
{get = function(self)
|
|
118
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTargetYAttribute]) or 0
|
|
119
|
+
end}
|
|
120
|
+
)
|
|
121
|
+
__TS__ObjectDefineProperty(
|
|
122
|
+
Unit.prototype,
|
|
123
|
+
"currentOrderTarget",
|
|
124
|
+
{get = function(self)
|
|
125
|
+
return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTargetAttribute])
|
|
126
|
+
end}
|
|
127
|
+
)
|
|
128
|
+
local issueOrderByType = {
|
|
129
|
+
[0] = issueImmediateOrderById,
|
|
130
|
+
[1] = issuePointOrderById,
|
|
131
|
+
[2] = function(unitHandle, orderId, widget) return issueTargetOrderById(unitHandle, orderId, widget.handle) end
|
|
132
|
+
}
|
|
133
|
+
Unit.prototype.issueOrder = function(self, orderType, orderId, xOrTarget, y)
|
|
134
|
+
return issueOrderByType[orderType](self.handle, orderId, xOrTarget, y)
|
|
135
|
+
end
|
|
136
|
+
return ____exports
|
|
@@ -44,7 +44,7 @@ local function timerCallback(source, target)
|
|
|
44
44
|
Event.invoke(autoAttackFinishEvent, source, target)
|
|
45
45
|
end
|
|
46
46
|
Unit.autoAttackStartEvent:addListener(function(source, target)
|
|
47
|
-
local attackPoint = source.
|
|
47
|
+
local attackPoint = (source:chooseWeapon(target) or source.firstWeapon).impactDelay
|
|
48
48
|
local timer = Timer:simple(attackPoint, timerCallback, source, target)
|
|
49
49
|
eventTimerByUnit[source] = timer
|
|
50
50
|
end)
|
|
@@ -23,6 +23,7 @@ export declare namespace UnitClassification {
|
|
|
23
23
|
const GROUND: junittype;
|
|
24
24
|
const SUMMONED: junittype;
|
|
25
25
|
const MECHANICAL: junittype;
|
|
26
|
+
const WORKER: junittype;
|
|
26
27
|
const ANCIENT: junittype;
|
|
27
28
|
const SUICIDAL: junittype;
|
|
28
29
|
const TAUREN: junittype;
|
|
@@ -49,8 +50,9 @@ export interface DamagingEvent extends AttributesHolder {
|
|
|
49
50
|
readonly isAttack: boolean;
|
|
50
51
|
readonly originalAmount: number;
|
|
51
52
|
readonly originalMetadata: unknown;
|
|
53
|
+
preventRetaliation(this: DamagingEvent): void;
|
|
52
54
|
}
|
|
53
|
-
export type DamageEvent = DamagingEvent & {
|
|
55
|
+
export type DamageEvent = Omit<DamagingEvent, "preventRetaliation"> & {
|
|
54
56
|
preventDeath<P extends any[]>(this: DamageEvent, callback: (this: void, ...parameters: P) => any, ...parameters: P): void;
|
|
55
57
|
};
|
|
56
58
|
export type AttackDamageEvent = DamagingEvent & {
|
|
@@ -82,6 +84,8 @@ export declare class UnitWeapon {
|
|
|
82
84
|
set cooldown(cooldown: number);
|
|
83
85
|
get damage(): [minimumDamage: number, maximumDamage: number];
|
|
84
86
|
set damage([minimumDamage, maximumDamage]: [number, number]);
|
|
87
|
+
get allowedTargetCombatClassifications(): CombatClassifications;
|
|
88
|
+
set allowedTargetCombatClassifications(allowedTargetCombatClassifications: CombatClassifications);
|
|
85
89
|
get damageBase(): number;
|
|
86
90
|
set damageBase(damageBase: number);
|
|
87
91
|
get damageDiceCount(): number;
|
|
@@ -163,6 +167,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
163
167
|
get weapons(): [UnitWeapon, UnitWeapon];
|
|
164
168
|
get firstWeapon(): UnitWeapon;
|
|
165
169
|
get secondWeapon(): UnitWeapon;
|
|
170
|
+
chooseWeapon(target: Unit): UnitWeapon | undefined;
|
|
166
171
|
get level(): number;
|
|
167
172
|
set level(v: number);
|
|
168
173
|
get xp(): number;
|
|
@@ -273,6 +278,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
273
278
|
getAbilityRemainingCooldown(abilityId: number): number;
|
|
274
279
|
startAbilityCooldown(abilityId: number, cooldown: number): void;
|
|
275
280
|
endAbilityCooldown(abilityId: number): void;
|
|
281
|
+
interruptMovement(): void;
|
|
276
282
|
interruptAttack(): void;
|
|
277
283
|
interruptCast(abilityId: number): void;
|
|
278
284
|
getDistanceTo(target: Unit | Vec2): number;
|
|
@@ -295,6 +301,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
295
301
|
get onUnitInRange(): Record<number, Event<[Unit]>>;
|
|
296
302
|
get onManaEqual(): Record<number, Event<[Unit, number]>>;
|
|
297
303
|
get manaEvent(): Record<Operator, Record<number, Event<[Unit]>>>;
|
|
304
|
+
get targetAcquiredEvent(): Event;
|
|
298
305
|
get onSelect(): Event;
|
|
299
306
|
get onDeselect(): Event;
|
|
300
307
|
get onImmediateOrder(): Event<[number]>;
|
|
@@ -348,6 +355,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
348
355
|
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
349
356
|
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
350
357
|
static itemStackedEvent: UnitTriggerEvent<[Item]>;
|
|
358
|
+
static get itemChargesChangedEvent(): Event<[unit: Unit, item: Item]>;
|
|
351
359
|
static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
|
|
352
360
|
static get itemMoveOrderEvent(): Event<[
|
|
353
361
|
unit: Unit,
|
package/engine/internal/unit.lua
CHANGED
|
@@ -139,6 +139,7 @@ do
|
|
|
139
139
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
140
140
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
141
141
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
142
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
142
143
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
143
144
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
144
145
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -346,6 +347,9 @@ local function dispatchAbility(event)
|
|
|
346
347
|
}
|
|
347
348
|
)
|
|
348
349
|
end
|
|
350
|
+
local function damagingEventPreventRetaliation(self)
|
|
351
|
+
self[0] = true
|
|
352
|
+
end
|
|
349
353
|
local function damageEventPreventDeath(self, callback, ...)
|
|
350
354
|
if self[0] ~= nil then
|
|
351
355
|
return
|
|
@@ -442,6 +446,19 @@ __TS__SetDescriptor(
|
|
|
442
446
|
},
|
|
443
447
|
true
|
|
444
448
|
)
|
|
449
|
+
__TS__SetDescriptor(
|
|
450
|
+
UnitWeapon.prototype,
|
|
451
|
+
"allowedTargetCombatClassifications",
|
|
452
|
+
{
|
|
453
|
+
get = function(self)
|
|
454
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
455
|
+
end,
|
|
456
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
457
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
458
|
+
end
|
|
459
|
+
},
|
|
460
|
+
true
|
|
461
|
+
)
|
|
445
462
|
__TS__SetDescriptor(
|
|
446
463
|
UnitWeapon.prototype,
|
|
447
464
|
"damageBase",
|
|
@@ -811,6 +828,15 @@ end
|
|
|
811
828
|
function Unit.prototype.queueAnimation(self, animation)
|
|
812
829
|
QueueUnitAnimation(self.handle, animation)
|
|
813
830
|
end
|
|
831
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
832
|
+
if target:isAllowedTarget(self, self.firstWeapon.allowedTargetCombatClassifications) then
|
|
833
|
+
return self.firstWeapon
|
|
834
|
+
end
|
|
835
|
+
if target:isAllowedTarget(target, self.secondWeapon.allowedTargetCombatClassifications) then
|
|
836
|
+
return self.secondWeapon
|
|
837
|
+
end
|
|
838
|
+
return nil
|
|
839
|
+
end
|
|
814
840
|
function Unit.prototype.delayHealthChecks(self)
|
|
815
841
|
self[103] = (self[103] or 0) + 1
|
|
816
842
|
Timer:run(delayHealthChecksCallback, self)
|
|
@@ -941,6 +967,21 @@ end
|
|
|
941
967
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
942
968
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
943
969
|
end
|
|
970
|
+
function Unit.prototype.interruptMovement(self)
|
|
971
|
+
local handle = self.handle
|
|
972
|
+
unitDisableAbility(
|
|
973
|
+
handle,
|
|
974
|
+
fourCC("Amov"),
|
|
975
|
+
true,
|
|
976
|
+
false
|
|
977
|
+
)
|
|
978
|
+
unitDisableAbility(
|
|
979
|
+
handle,
|
|
980
|
+
fourCC("Amov"),
|
|
981
|
+
false,
|
|
982
|
+
false
|
|
983
|
+
)
|
|
984
|
+
end
|
|
944
985
|
function Unit.prototype.interruptAttack(self)
|
|
945
986
|
unitInterruptAttack(self.handle)
|
|
946
987
|
end
|
|
@@ -2047,6 +2088,14 @@ __TS__SetDescriptor(
|
|
|
2047
2088
|
end},
|
|
2048
2089
|
true
|
|
2049
2090
|
)
|
|
2091
|
+
__TS__SetDescriptor(
|
|
2092
|
+
Unit.prototype,
|
|
2093
|
+
"targetAcquiredEvent",
|
|
2094
|
+
{get = function(self)
|
|
2095
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2096
|
+
end},
|
|
2097
|
+
true
|
|
2098
|
+
)
|
|
2050
2099
|
__TS__SetDescriptor(
|
|
2051
2100
|
Unit.prototype,
|
|
2052
2101
|
"onSelect",
|
|
@@ -2419,7 +2468,8 @@ Unit.onDamaging = (function()
|
|
|
2419
2468
|
metadata = metadata,
|
|
2420
2469
|
isAttack = BlzGetEventIsAttack(),
|
|
2421
2470
|
originalAmount = GetEventDamage(),
|
|
2422
|
-
originalMetadata = metadata
|
|
2471
|
+
originalMetadata = metadata,
|
|
2472
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2423
2473
|
}
|
|
2424
2474
|
if data.isAttack and source then
|
|
2425
2475
|
local weapon = BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 1) and (BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 0) and -1 or 1) or 0
|
|
@@ -2448,6 +2498,20 @@ Unit.onDamaging = (function()
|
|
|
2448
2498
|
}
|
|
2449
2499
|
)
|
|
2450
2500
|
)
|
|
2501
|
+
if data[0] and source then
|
|
2502
|
+
local sourceOwner = source.owner.handle
|
|
2503
|
+
data[1] = sourceOwner
|
|
2504
|
+
local targetOwner = target.owner.handle
|
|
2505
|
+
data[2] = targetOwner
|
|
2506
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2507
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2508
|
+
data[3] = true
|
|
2509
|
+
end
|
|
2510
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2511
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2512
|
+
data[4] = true
|
|
2513
|
+
end
|
|
2514
|
+
end
|
|
2451
2515
|
damagingEventByTarget[target] = data
|
|
2452
2516
|
return
|
|
2453
2517
|
end
|
|
@@ -2531,6 +2595,16 @@ Unit.onDamage = __TS__New(
|
|
|
2531
2595
|
data[key] = value
|
|
2532
2596
|
end
|
|
2533
2597
|
end
|
|
2598
|
+
local sourceOwner = damagingEvent[1]
|
|
2599
|
+
if sourceOwner then
|
|
2600
|
+
local targetOwner = damagingEvent[2]
|
|
2601
|
+
if damagingEvent[3] then
|
|
2602
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2603
|
+
end
|
|
2604
|
+
if damagingEvent[4] then
|
|
2605
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2606
|
+
end
|
|
2607
|
+
end
|
|
2534
2608
|
end
|
|
2535
2609
|
local evData = setmetatable(
|
|
2536
2610
|
{},
|
|
@@ -2623,6 +2697,21 @@ Unit.itemStackedEvent = __TS__New(
|
|
|
2623
2697
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2624
2698
|
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2625
2699
|
)
|
|
2700
|
+
__TS__ObjectDefineProperty(
|
|
2701
|
+
Unit,
|
|
2702
|
+
"itemChargesChangedEvent",
|
|
2703
|
+
{get = function(self)
|
|
2704
|
+
local event = __TS__New(Event)
|
|
2705
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2706
|
+
local unit = item.owner
|
|
2707
|
+
if unit ~= nil then
|
|
2708
|
+
invoke(event, unit, item)
|
|
2709
|
+
end
|
|
2710
|
+
end)
|
|
2711
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2712
|
+
return event
|
|
2713
|
+
end}
|
|
2714
|
+
)
|
|
2626
2715
|
__TS__ObjectDefineProperty(
|
|
2627
2716
|
Unit,
|
|
2628
2717
|
"itemUseOrderEvent",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { AbilityType, AbilityTypeId } from "../ability-type";
|
|
3
|
+
import { ObjectDataEntryLevelFieldValueSupplier } from "../../entry";
|
|
4
|
+
export declare class PermanentInvisibilityAbilityType extends AbilityType {
|
|
5
|
+
static readonly BASE_ID: AbilityTypeId;
|
|
6
|
+
get shouldAutoAcquireAttackTargets(): boolean[];
|
|
7
|
+
set shouldAutoAcquireAttackTargets(shouldAutoAcquireAttackTargets: ObjectDataEntryLevelFieldValueSupplier<boolean>);
|
|
8
|
+
}
|