warscript 0.0.1-dev.bcab4e5 → 0.0.1-dev.bf99da4
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/unit.d.ts +8 -0
- package/engine/behaviour/unit.lua +45 -4
- package/engine/internal/item/ability.lua +12 -10
- package/engine/internal/item.d.ts +2 -1
- package/engine/internal/item.lua +69 -3
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit.d.ts +1 -0
- package/engine/internal/unit.lua +15 -0
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ import { Item } from "../internal/item";
|
|
|
8
8
|
import type { AbilityBehavior } from "./ability";
|
|
9
9
|
import { Event } from "../../event";
|
|
10
10
|
import { Destructor } from "../../destroyable";
|
|
11
|
+
import type { Widget } from "../../core/types/widget";
|
|
11
12
|
export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
|
|
12
13
|
export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
|
|
13
14
|
constructor(unit: Unit);
|
|
@@ -15,6 +16,9 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
|
|
|
15
16
|
readonly sourceAbilityBehavior?: AbilityBehavior;
|
|
16
17
|
get unit(): Unit;
|
|
17
18
|
registerInRangeUnitEvent<T extends string, Args extends any[]>(this: UnitBehavior<PeriodicActionParameters> & Record<T, (this: this, unit: Unit, ...args: Args) => unknown>, event: Event<[Unit, ...Args]>, range: number, listener: T): void;
|
|
19
|
+
onImmediateOrder(orderId: number): void;
|
|
20
|
+
onTargetOrder(orderId: number, target: Widget): void;
|
|
21
|
+
onPointOrder(orderId: number, x: number, y: number): void;
|
|
18
22
|
onAutoAttackStart(target: Unit): void;
|
|
19
23
|
onAutoAttackFinish(target: Unit): void;
|
|
20
24
|
onTargetingAutoAttackStart(source: Unit): void;
|
|
@@ -25,10 +29,14 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
|
|
|
25
29
|
onDamageReceived(source: Unit | undefined, event: DamageEvent): void;
|
|
26
30
|
onAbilityGained(ability: Ability): void;
|
|
27
31
|
onAbilityLost(ability: Ability): void;
|
|
32
|
+
onAbilityChannelingStart(ability: Ability): void;
|
|
33
|
+
onAbilityChannelingFinish(ability: Ability): void;
|
|
34
|
+
onAbilityStop(ability: Ability): void;
|
|
28
35
|
onItemDropped(item: Item): void;
|
|
29
36
|
onItemPickedUp(item: Item): void;
|
|
30
37
|
onItemUsed(item: Item): void;
|
|
31
38
|
onItemStacked(item: Item): void;
|
|
39
|
+
onItemChargesChanged(item: Item): void;
|
|
32
40
|
onKill(target: Unit): void;
|
|
33
41
|
onDeath(source: Unit | undefined): void;
|
|
34
42
|
}
|
|
@@ -74,6 +74,12 @@ function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, range, lis
|
|
|
74
74
|
end
|
|
75
75
|
behaviors:add(self)
|
|
76
76
|
end
|
|
77
|
+
function UnitBehavior.prototype.onImmediateOrder(self, orderId)
|
|
78
|
+
end
|
|
79
|
+
function UnitBehavior.prototype.onTargetOrder(self, orderId, target)
|
|
80
|
+
end
|
|
81
|
+
function UnitBehavior.prototype.onPointOrder(self, orderId, x, y)
|
|
82
|
+
end
|
|
77
83
|
function UnitBehavior.prototype.onAutoAttackStart(self, target)
|
|
78
84
|
end
|
|
79
85
|
function UnitBehavior.prototype.onAutoAttackFinish(self, target)
|
|
@@ -94,6 +100,12 @@ function UnitBehavior.prototype.onAbilityGained(self, ability)
|
|
|
94
100
|
end
|
|
95
101
|
function UnitBehavior.prototype.onAbilityLost(self, ability)
|
|
96
102
|
end
|
|
103
|
+
function UnitBehavior.prototype.onAbilityChannelingStart(self, ability)
|
|
104
|
+
end
|
|
105
|
+
function UnitBehavior.prototype.onAbilityChannelingFinish(self, ability)
|
|
106
|
+
end
|
|
107
|
+
function UnitBehavior.prototype.onAbilityStop(self, ability)
|
|
108
|
+
end
|
|
97
109
|
function UnitBehavior.prototype.onItemDropped(self, item)
|
|
98
110
|
end
|
|
99
111
|
function UnitBehavior.prototype.onItemPickedUp(self, item)
|
|
@@ -102,6 +114,8 @@ function UnitBehavior.prototype.onItemUsed(self, item)
|
|
|
102
114
|
end
|
|
103
115
|
function UnitBehavior.prototype.onItemStacked(self, item)
|
|
104
116
|
end
|
|
117
|
+
function UnitBehavior.prototype.onItemChargesChanged(self, item)
|
|
118
|
+
end
|
|
105
119
|
function UnitBehavior.prototype.onKill(self, target)
|
|
106
120
|
end
|
|
107
121
|
function UnitBehavior.prototype.onDeath(self, source)
|
|
@@ -115,6 +129,21 @@ __TS__SetDescriptor(
|
|
|
115
129
|
true
|
|
116
130
|
);
|
|
117
131
|
(function(self)
|
|
132
|
+
Unit.onImmediateOrder:addListener(function(source, orderId)
|
|
133
|
+
____exports.UnitBehavior:forAll(source, "onImmediateOrder", orderId)
|
|
134
|
+
end)
|
|
135
|
+
Unit.onTargetOrder:addListener(function(source, orderId, target)
|
|
136
|
+
____exports.UnitBehavior:forAll(source, "onTargetOrder", orderId, target)
|
|
137
|
+
end)
|
|
138
|
+
Unit.onPointOrder:addListener(function(source, orderId, x, y)
|
|
139
|
+
____exports.UnitBehavior:forAll(
|
|
140
|
+
source,
|
|
141
|
+
"onPointOrder",
|
|
142
|
+
orderId,
|
|
143
|
+
x,
|
|
144
|
+
y
|
|
145
|
+
)
|
|
146
|
+
end)
|
|
118
147
|
Unit.autoAttackStartEvent:addListener(function(source, target)
|
|
119
148
|
____exports.UnitBehavior:forAll(source, "onAutoAttackStart", target)
|
|
120
149
|
____exports.UnitBehavior:forAll(target, "onTargetingAutoAttackStart", source)
|
|
@@ -135,11 +164,20 @@ __TS__SetDescriptor(
|
|
|
135
164
|
end
|
|
136
165
|
____exports.UnitBehavior:forAll(target, "onDamageReceived", source, event)
|
|
137
166
|
end)
|
|
138
|
-
Unit.abilityGainedEvent:addListener(function(source,
|
|
139
|
-
____exports.UnitBehavior:forAll(source, "onAbilityGained",
|
|
167
|
+
Unit.abilityGainedEvent:addListener(function(source, ability)
|
|
168
|
+
____exports.UnitBehavior:forAll(source, "onAbilityGained", ability)
|
|
169
|
+
end)
|
|
170
|
+
Unit.abilityLostEvent:addListener(function(source, ability)
|
|
171
|
+
____exports.UnitBehavior:forAll(source, "onAbilityLost", ability)
|
|
140
172
|
end)
|
|
141
|
-
Unit.
|
|
142
|
-
____exports.UnitBehavior:forAll(source, "
|
|
173
|
+
Unit.abilityChannelingStartEvent:addListener(function(source, ability)
|
|
174
|
+
____exports.UnitBehavior:forAll(source, "onAbilityChannelingStart", ability)
|
|
175
|
+
end)
|
|
176
|
+
Unit.abilityChannelingFinishEvent:addListener(function(source, ability)
|
|
177
|
+
____exports.UnitBehavior:forAll(source, "onAbilityChannelingFinish", ability)
|
|
178
|
+
end)
|
|
179
|
+
Unit.abilityStopEvent:addListener(function(source, ability)
|
|
180
|
+
____exports.UnitBehavior:forAll(source, "onAbilityStop", ability)
|
|
143
181
|
end)
|
|
144
182
|
Unit.deathEvent:addListener(function(target, source)
|
|
145
183
|
if source ~= nil then
|
|
@@ -159,6 +197,9 @@ __TS__SetDescriptor(
|
|
|
159
197
|
Unit.itemStackedEvent:addListener(function(unit, item)
|
|
160
198
|
____exports.UnitBehavior:forAll(unit, "onItemStacked", item)
|
|
161
199
|
end)
|
|
200
|
+
Unit.itemChargesChangedEvent:addListener(function(unit, item)
|
|
201
|
+
____exports.UnitBehavior:forAll(unit, "onItemChargesChanged", item)
|
|
202
|
+
end)
|
|
162
203
|
end)(UnitBehavior)
|
|
163
204
|
Unit.destroyEvent:addListener(function(unit)
|
|
164
205
|
____exports.UnitBehavior:forAll(unit, "destroy")
|
|
@@ -55,22 +55,24 @@ local COOLDOWN_STARTER_ITEM_TYPE_ID = compiletime(function()
|
|
|
55
55
|
itemType.activelyUsed = true
|
|
56
56
|
return itemType.id
|
|
57
57
|
end)
|
|
58
|
-
|
|
58
|
+
---
|
|
59
|
+
-- @internal For use by internal systems only.
|
|
60
|
+
____exports.itemAbilityDummy = assert(CreateUnit(
|
|
59
61
|
Player.neutralVictim.handle,
|
|
60
62
|
dummyUnitId,
|
|
61
63
|
0,
|
|
62
64
|
0,
|
|
63
65
|
270
|
|
64
66
|
))
|
|
65
|
-
local cooldownStarterItem = UnitAddItemById(
|
|
67
|
+
local cooldownStarterItem = UnitAddItemById(____exports.itemAbilityDummy, COOLDOWN_STARTER_ITEM_TYPE_ID)
|
|
66
68
|
local cooldownStarterAbility = BlzGetItemAbility(cooldownStarterItem, COOLDOWN_STARTER_ABILITY_TYPE_ID)
|
|
67
|
-
ShowUnit(
|
|
69
|
+
ShowUnit(____exports.itemAbilityDummy, false)
|
|
68
70
|
local function startItemCooldownInternal(handle, cooldown)
|
|
69
71
|
local cooldownGroup = getItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP)
|
|
70
72
|
setItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP, COOLDOWN_STARTER_ABILITY_TYPE_ID)
|
|
71
73
|
setAbilityRealLevelField(cooldownStarterAbility, ABILITY_RLF_COOLDOWN, 0, cooldown)
|
|
72
|
-
unitResetCooldown(
|
|
73
|
-
unitUseItem(
|
|
74
|
+
unitResetCooldown(____exports.itemAbilityDummy)
|
|
75
|
+
unitUseItem(____exports.itemAbilityDummy, cooldownStarterItem)
|
|
74
76
|
Timer:run(restoreCooldownGroup, handle, cooldownGroup)
|
|
75
77
|
end
|
|
76
78
|
restoreCooldownGroup = function(handle, cooldownGroup)
|
|
@@ -85,7 +87,7 @@ ____exports.startItemCooldown = function(handle, owner, cooldown)
|
|
|
85
87
|
end
|
|
86
88
|
---
|
|
87
89
|
-- @internal For use by internal systems only.
|
|
88
|
-
____exports.abilityActionDummy =
|
|
90
|
+
____exports.abilityActionDummy = ____exports.itemAbilityDummy
|
|
89
91
|
---
|
|
90
92
|
-- @internal For use by internal systems only.
|
|
91
93
|
____exports.doAbilityAction = function(handle, action, ...)
|
|
@@ -104,11 +106,11 @@ ____exports.doAbilityAction = function(handle, action, ...)
|
|
|
104
106
|
end
|
|
105
107
|
x = getItemX(handle)
|
|
106
108
|
y = getItemY(handle)
|
|
107
|
-
unitAddItem(
|
|
109
|
+
unitAddItem(____exports.itemAbilityDummy, handle)
|
|
108
110
|
end
|
|
109
111
|
local result = action(handle, ...)
|
|
110
112
|
if not isOwned then
|
|
111
|
-
unitRemoveItem(
|
|
113
|
+
unitRemoveItem(____exports.itemAbilityDummy, handle)
|
|
112
114
|
setItemPosition(handle, x, y)
|
|
113
115
|
if isPowerup then
|
|
114
116
|
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
@@ -139,9 +141,9 @@ ____exports.doAbilityActionForceDummy = function(handle, owner, action, ...)
|
|
|
139
141
|
isPowerup = true
|
|
140
142
|
end
|
|
141
143
|
unitRemoveItem(owner, handle)
|
|
142
|
-
unitAddItem(
|
|
144
|
+
unitAddItem(____exports.itemAbilityDummy, handle)
|
|
143
145
|
local result = action(handle, ...)
|
|
144
|
-
unitRemoveItem(
|
|
146
|
+
unitRemoveItem(____exports.itemAbilityDummy, handle)
|
|
145
147
|
unitAddItemToSlot(owner, handle, slot)
|
|
146
148
|
if isPowerup then
|
|
147
149
|
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
@@ -7,7 +7,6 @@ import { ItemAbility } from "./ability";
|
|
|
7
7
|
import { AbilityTypeId } from "../object-data/entry/ability-type";
|
|
8
8
|
import type { ItemTypeId } from "../object-data/entry/item-type";
|
|
9
9
|
type DefenseType = 0 | 1 | 2 | 3 | 4 | 5;
|
|
10
|
-
export declare const addAndGetAbility: (handle: jitem, abilityTypeId: AbilityTypeId) => jability | null;
|
|
11
10
|
declare const enum ItemPropertyKey {
|
|
12
11
|
ABILITIES = 100,
|
|
13
12
|
LUA_INDEX_BY_ABILITY_TYPE_ID = 101
|
|
@@ -74,6 +73,7 @@ export declare class Item extends Handle<jitem> {
|
|
|
74
73
|
set position(v: Vec2);
|
|
75
74
|
set charges(v: number);
|
|
76
75
|
get charges(): number;
|
|
76
|
+
consumeCharge(): boolean;
|
|
77
77
|
addAbility(abilityTypeId: AbilityTypeId): ItemAbility | undefined;
|
|
78
78
|
removeAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
79
79
|
hasAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
@@ -83,5 +83,6 @@ export declare class Item extends Handle<jitem> {
|
|
|
83
83
|
static getInRect(rect: ReadonlyRect): Item[];
|
|
84
84
|
static get onCreate(): Event<[Item]>;
|
|
85
85
|
static get destroyEvent(): Event<[Item]>;
|
|
86
|
+
static readonly chargesChangedEvent: Event<[Item]>;
|
|
86
87
|
}
|
|
87
88
|
export {};
|
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,24 @@ 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
|
+
_G.SetItemCharges = function(whichItem, charges)
|
|
51
|
+
setItemCharges(whichItem, charges)
|
|
52
|
+
invoke(
|
|
53
|
+
itemChargesChangeEvent,
|
|
54
|
+
____exports.Item:of(whichItem)
|
|
55
|
+
)
|
|
56
|
+
end
|
|
39
57
|
local getItemIntegerField = BlzGetItemIntegerField
|
|
40
58
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
41
59
|
local getItemBooleanField = BlzGetItemBooleanField
|
|
60
|
+
invoke = Event.invoke
|
|
42
61
|
local enumRect = Rect:create(0, 0, 0, 0).handle
|
|
62
|
+
---
|
|
63
|
+
-- @internal For use by internal systems only.
|
|
43
64
|
____exports.addAndGetAbility = function(handle, abilityTypeId)
|
|
44
65
|
if itemAddAbility(handle, abilityTypeId) then
|
|
45
66
|
return getItemAbility(handle, abilityTypeId)
|
|
@@ -65,6 +86,23 @@ local function getItemAbilities(handle, item)
|
|
|
65
86
|
end
|
|
66
87
|
return abilities
|
|
67
88
|
end
|
|
89
|
+
local function consumeCharge(handle)
|
|
90
|
+
do
|
|
91
|
+
local i = 0
|
|
92
|
+
local ability = getItemAbilityByIndex(handle, i)
|
|
93
|
+
while ability ~= nil do
|
|
94
|
+
unitRemoveAbility(
|
|
95
|
+
itemAbilityDummy,
|
|
96
|
+
getAbilityId(ability)
|
|
97
|
+
)
|
|
98
|
+
do
|
|
99
|
+
i = i + 1
|
|
100
|
+
ability = getItemAbilityByIndex(handle, i)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
unitUseItem(itemAbilityDummy, handle)
|
|
105
|
+
end
|
|
68
106
|
local targetCollection
|
|
69
107
|
local targetCollectionNextIndex
|
|
70
108
|
local centerX
|
|
@@ -116,6 +154,32 @@ end
|
|
|
116
154
|
function Item.create(self, id, x, y, skinId)
|
|
117
155
|
return self:of(BlzCreateItemWithSkin(id, x, y, skinId or id))
|
|
118
156
|
end
|
|
157
|
+
function Item.prototype.consumeCharge(self)
|
|
158
|
+
local handle = self.handle
|
|
159
|
+
local charges = getItemCharges(handle)
|
|
160
|
+
if charges >= 2 then
|
|
161
|
+
setItemCharges(handle, charges - 1)
|
|
162
|
+
invoke(itemChargesChangeEvent, self)
|
|
163
|
+
return true
|
|
164
|
+
end
|
|
165
|
+
if charges == 1 then
|
|
166
|
+
if getItemBooleanField(handle, ITEM_BF_PERISHABLE) then
|
|
167
|
+
self:destroy()
|
|
168
|
+
return true
|
|
169
|
+
end
|
|
170
|
+
if not getItemBooleanField(handle, ITEM_BF_ACTIVELY_USED) then
|
|
171
|
+
setItemCharges(handle, 0)
|
|
172
|
+
invoke(itemChargesChangeEvent, self)
|
|
173
|
+
return true
|
|
174
|
+
end
|
|
175
|
+
local ____doAbilityActionForceDummy_2 = doAbilityActionForceDummy
|
|
176
|
+
local ____opt_0 = self.owner
|
|
177
|
+
____doAbilityActionForceDummy_2(handle, ____opt_0 and ____opt_0.handle, consumeCharge)
|
|
178
|
+
invoke(itemChargesChangeEvent, self)
|
|
179
|
+
return true
|
|
180
|
+
end
|
|
181
|
+
return false
|
|
182
|
+
end
|
|
119
183
|
function Item.prototype.addAbility(self, abilityTypeId)
|
|
120
184
|
local nativeAbility = doAbilityAction(self.handle, ____exports.addAndGetAbility, abilityTypeId)
|
|
121
185
|
if nativeAbility ~= nil then
|
|
@@ -301,7 +365,7 @@ __TS__SetDescriptor(
|
|
|
301
365
|
"perishable",
|
|
302
366
|
{
|
|
303
367
|
get = function(self)
|
|
304
|
-
return
|
|
368
|
+
return getItemBooleanField(self.handle, ITEM_BF_PERISHABLE)
|
|
305
369
|
end,
|
|
306
370
|
set = function(self, v)
|
|
307
371
|
BlzSetItemBooleanField(self.handle, ITEM_BF_PERISHABLE, v)
|
|
@@ -557,10 +621,11 @@ __TS__SetDescriptor(
|
|
|
557
621
|
"charges",
|
|
558
622
|
{
|
|
559
623
|
get = function(self)
|
|
560
|
-
return
|
|
624
|
+
return getItemCharges(self.handle)
|
|
561
625
|
end,
|
|
562
626
|
set = function(self, v)
|
|
563
|
-
|
|
627
|
+
setItemCharges(self.handle, v)
|
|
628
|
+
invoke(itemChargesChangeEvent, self)
|
|
564
629
|
end
|
|
565
630
|
},
|
|
566
631
|
true
|
|
@@ -587,6 +652,7 @@ __TS__ObjectDefineProperty(
|
|
|
587
652
|
return self.onDestroyEvent
|
|
588
653
|
end}
|
|
589
654
|
)
|
|
655
|
+
Item.chargesChangedEvent = itemChargesChangeEvent
|
|
590
656
|
local getManipulatedItem = GetManipulatedItem
|
|
591
657
|
local trigger = CreateTrigger()
|
|
592
658
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_PICKUP_ITEM)
|
|
@@ -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)
|
|
@@ -354,6 +354,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
354
354
|
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
355
355
|
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
356
356
|
static itemStackedEvent: UnitTriggerEvent<[Item]>;
|
|
357
|
+
static get itemChargesChangedEvent(): Event<[unit: Unit, item: Item]>;
|
|
357
358
|
static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
|
|
358
359
|
static get itemMoveOrderEvent(): Event<[
|
|
359
360
|
unit: Unit,
|
package/engine/internal/unit.lua
CHANGED
|
@@ -2682,6 +2682,21 @@ Unit.itemStackedEvent = __TS__New(
|
|
|
2682
2682
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2683
2683
|
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2684
2684
|
)
|
|
2685
|
+
__TS__ObjectDefineProperty(
|
|
2686
|
+
Unit,
|
|
2687
|
+
"itemChargesChangedEvent",
|
|
2688
|
+
{get = function(self)
|
|
2689
|
+
local event = __TS__New(Event)
|
|
2690
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2691
|
+
local unit = item.owner
|
|
2692
|
+
if unit ~= nil then
|
|
2693
|
+
invoke(event, unit, item)
|
|
2694
|
+
end
|
|
2695
|
+
end)
|
|
2696
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2697
|
+
return event
|
|
2698
|
+
end}
|
|
2699
|
+
)
|
|
2685
2700
|
__TS__ObjectDefineProperty(
|
|
2686
2701
|
Unit,
|
|
2687
2702
|
"itemUseOrderEvent",
|
package/package.json
CHANGED