warscript 0.0.1-dev.f5421e8 → 0.0.1-dev.f9166a3
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 +5 -0
- package/attributes.lua +8 -1
- package/core/types/order.d.ts +1 -0
- package/core/types/order.lua +11 -1
- package/core/types/sound.lua +5 -0
- package/decl/native.d.ts +840 -786
- package/engine/behaviour/ability/damage.d.ts +6 -3
- package/engine/behaviour/ability/damage.lua +24 -36
- package/engine/behaviour/ability/emulate-impact.lua +16 -2
- package/engine/behaviour/ability.lua +1 -1
- package/engine/behaviour/unit.d.ts +15 -0
- package/engine/behaviour/unit.lua +114 -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 +5 -2
- package/engine/internal/item.lua +75 -3
- 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/unit/ability.d.ts +5 -0
- package/engine/internal/unit/ability.lua +14 -0
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- 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-missile-launch.lua +1 -1
- package/engine/internal/unit.d.ts +20 -3
- package/engine/internal/unit.lua +163 -37
- 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/movement-type.d.ts +7 -7
- package/engine/object-data/auxiliary/movement-type.lua +22 -0
- 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/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/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.lua +7 -0
- package/engine/object-data/entry/buff-type/applicable.lua +5 -0
- package/engine/object-data/entry/buff-type.d.ts +5 -11
- package/engine/object-data/entry/buff-type.lua +11 -27
- package/engine/object-data/entry/unit-type.d.ts +2 -2
- package/engine/object-data/entry/unit-type.lua +94 -84
- package/engine/object-field/ability.d.ts +1 -1
- package/engine/object-field/unit.d.ts +46 -3
- package/engine/object-field/unit.lua +173 -7
- package/engine/object-field.d.ts +12 -3
- package/engine/object-field.lua +164 -78
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- package/objutil/buff.lua +1 -2
- package/package.json +2 -2
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +3 -0
- package/utility/functions.d.ts +1 -0
- package/utility/functions.lua +1 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +3 -0
- package/utility/lua-maps.d.ts +3 -0
- package/utility/lua-maps.lua +16 -0
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +3 -0
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,11 @@ 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
|
+
}
|
|
134
139
|
declare module "../unit" {
|
|
135
140
|
namespace Unit {
|
|
136
141
|
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,18 @@ 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
|
+
)
|
|
348
362
|
rawset(
|
|
349
363
|
Unit,
|
|
350
364
|
"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)
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { Widget } from "../../core/types/widget";
|
|
3
|
-
|
|
4
|
-
export declare namespace AttackType {
|
|
5
|
-
const SPELL: jattacktype;
|
|
6
|
-
const NORMAL: jattacktype;
|
|
7
|
-
const PIERCE: jattacktype;
|
|
8
|
-
const SIEGE: jattacktype;
|
|
9
|
-
const MAGIC: jattacktype;
|
|
10
|
-
const CHAOS: jattacktype;
|
|
11
|
-
const HERO: jattacktype;
|
|
12
|
-
}
|
|
3
|
+
import { AttackType } from "../object-data/auxiliary/attack-type";
|
|
13
4
|
export type DamageType = jdamagetype;
|
|
14
5
|
export declare namespace DamageType {
|
|
15
6
|
const UNKNOWN: jdamagetype;
|
|
@@ -64,6 +55,6 @@ export declare namespace WeaponType {
|
|
|
64
55
|
}
|
|
65
56
|
declare module "./unit" {
|
|
66
57
|
interface Unit {
|
|
67
|
-
damageTarget(target: Widget, amount: number, attack?: boolean, ranged?: boolean, attackType?: AttackType, damageType?: DamageType, weaponType?: WeaponType): boolean;
|
|
58
|
+
damageTarget(target: Widget, amount: number, attack?: boolean, ranged?: boolean, attackType?: AttackType, damageType?: DamageType, weaponType?: WeaponType, metadata?: unknown): boolean;
|
|
68
59
|
}
|
|
69
60
|
}
|
|
@@ -7,21 +7,14 @@ local ____player = require("core.types.player")
|
|
|
7
7
|
local Player = ____player.Player
|
|
8
8
|
local ____dummy = require("objutil.dummy")
|
|
9
9
|
local dummyUnitId = ____dummy.dummyUnitId
|
|
10
|
+
local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
|
|
11
|
+
local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
|
|
12
|
+
local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
|
|
13
|
+
local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
|
|
10
14
|
local createUnit = CreateUnit
|
|
11
15
|
local getOwningPlayer = GetOwningPlayer
|
|
12
16
|
local showUnit = ShowUnit
|
|
13
17
|
local unitDamageTarget = UnitDamageTarget
|
|
14
|
-
____exports.AttackType = {}
|
|
15
|
-
local AttackType = ____exports.AttackType
|
|
16
|
-
do
|
|
17
|
-
AttackType.SPELL = ATTACK_TYPE_NORMAL
|
|
18
|
-
AttackType.NORMAL = ATTACK_TYPE_MELEE
|
|
19
|
-
AttackType.PIERCE = ATTACK_TYPE_PIERCE
|
|
20
|
-
AttackType.SIEGE = ATTACK_TYPE_SIEGE
|
|
21
|
-
AttackType.MAGIC = ATTACK_TYPE_MAGIC
|
|
22
|
-
AttackType.CHAOS = ATTACK_TYPE_CHAOS
|
|
23
|
-
AttackType.HERO = ATTACK_TYPE_HERO
|
|
24
|
-
end
|
|
25
18
|
____exports.DamageType = {}
|
|
26
19
|
local DamageType = ____exports.DamageType
|
|
27
20
|
do
|
|
@@ -88,7 +81,7 @@ for ____, player in ipairs(Player.all) do
|
|
|
88
81
|
showUnit(dummy, false)
|
|
89
82
|
dummies[player] = dummy
|
|
90
83
|
end
|
|
91
|
-
Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, attackType, damageType, weaponType)
|
|
84
|
+
Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, attackType, damageType, weaponType, metadata)
|
|
92
85
|
if attack == nil then
|
|
93
86
|
attack = false
|
|
94
87
|
end
|
|
@@ -96,7 +89,7 @@ Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, att
|
|
|
96
89
|
ranged = false
|
|
97
90
|
end
|
|
98
91
|
if attackType == nil then
|
|
99
|
-
attackType =
|
|
92
|
+
attackType = 0
|
|
100
93
|
end
|
|
101
94
|
if damageType == nil then
|
|
102
95
|
damageType = ____exports.DamageType.MAGIC
|
|
@@ -109,13 +102,16 @@ Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, att
|
|
|
109
102
|
if not getOwningPlayer(handle) then
|
|
110
103
|
handle = dummies[__TS__InstanceOf(target, Unit) and target.owner or (self._owner or Player.neutralAggressive)]
|
|
111
104
|
end
|
|
105
|
+
if __TS__InstanceOf(target, Unit) then
|
|
106
|
+
damageMetadataByTarget[target] = metadata
|
|
107
|
+
end
|
|
112
108
|
return unitDamageTarget(
|
|
113
109
|
handle,
|
|
114
110
|
targetHandle,
|
|
115
111
|
amount,
|
|
116
112
|
attack,
|
|
117
113
|
ranged,
|
|
118
|
-
attackType,
|
|
114
|
+
attackTypeToNative(attackType),
|
|
119
115
|
damageType,
|
|
120
116
|
weaponType
|
|
121
117
|
)
|
|
@@ -6,7 +6,6 @@ local ____exports = {}
|
|
|
6
6
|
local ____unit = require("engine.internal.unit")
|
|
7
7
|
local Unit = ____unit.Unit
|
|
8
8
|
local ____unit_2Bdamage = require("engine.internal.unit+damage")
|
|
9
|
-
local AttackType = ____unit_2Bdamage.AttackType
|
|
10
9
|
local DamageType = ____unit_2Bdamage.DamageType
|
|
11
10
|
local ____event = require("event")
|
|
12
11
|
local Event = ____event.Event
|
|
@@ -33,7 +32,7 @@ local spellStealEventStack = {}
|
|
|
33
32
|
Unit.onDamaging:addListener(function(source, target, event)
|
|
34
33
|
if event.amount == 0 and source ~= nil then
|
|
35
34
|
local count = countByUnit[source] or 0
|
|
36
|
-
if count > 0 and event.attackType ==
|
|
35
|
+
if count > 0 and event.attackType == 0 then
|
|
37
36
|
if event.damageType == DamageType.UNKNOWN then
|
|
38
37
|
spellStealEventStack[#spellStealEventStack + 1] = {
|
|
39
38
|
sourceBuffIds = source.buffIds,
|
|
@@ -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)
|
|
@@ -11,6 +11,10 @@ import { Ability, UnitAbility } from "./ability";
|
|
|
11
11
|
import { Widget } from "../../core/types/widget";
|
|
12
12
|
import type { UnitTypeId } from "../object-data/entry/unit-type";
|
|
13
13
|
import { CombatClassification, CombatClassifications } from "../object-data/auxiliary/combat-classification";
|
|
14
|
+
import { MovementType } from "../object-data/auxiliary/movement-type";
|
|
15
|
+
import { UnitAttribute } from "../object-data/auxiliary/unit-attribute";
|
|
16
|
+
import { AttackType } from "../object-data/auxiliary/attack-type";
|
|
17
|
+
import { AttributesHolder } from "../../attributes";
|
|
14
18
|
export type UnitClassification = junittype;
|
|
15
19
|
export declare namespace UnitClassification {
|
|
16
20
|
const STRUCTURE: junittype;
|
|
@@ -19,6 +23,7 @@ export declare namespace UnitClassification {
|
|
|
19
23
|
const GROUND: junittype;
|
|
20
24
|
const SUMMONED: junittype;
|
|
21
25
|
const MECHANICAL: junittype;
|
|
26
|
+
const WORKER: junittype;
|
|
22
27
|
const ANCIENT: junittype;
|
|
23
28
|
const SUICIDAL: junittype;
|
|
24
29
|
const TAUREN: junittype;
|
|
@@ -36,15 +41,18 @@ type AbilityDispatcherTable<T extends any[] = []> = {
|
|
|
36
41
|
readonly [id: number]: Event<[Unit, Ability, ...T]>;
|
|
37
42
|
};
|
|
38
43
|
type AbilityEventDispatcher<T extends any[] = []> = Event<[Unit, Ability, ...T]> & AbilityDispatcherTable<T>;
|
|
39
|
-
export interface DamagingEvent {
|
|
44
|
+
export interface DamagingEvent extends AttributesHolder {
|
|
40
45
|
amount: number;
|
|
41
|
-
attackType:
|
|
46
|
+
attackType: AttackType;
|
|
42
47
|
damageType: jdamagetype;
|
|
43
48
|
weaponType: jweapontype;
|
|
49
|
+
metadata: unknown;
|
|
44
50
|
readonly isAttack: boolean;
|
|
45
51
|
readonly originalAmount: number;
|
|
52
|
+
readonly originalMetadata: unknown;
|
|
53
|
+
preventRetaliation(this: DamagingEvent): void;
|
|
46
54
|
}
|
|
47
|
-
export type DamageEvent = DamagingEvent & {
|
|
55
|
+
export type DamageEvent = Omit<DamagingEvent, "preventRetaliation"> & {
|
|
48
56
|
preventDeath<P extends any[]>(this: DamageEvent, callback: (this: void, ...parameters: P) => any, ...parameters: P): void;
|
|
49
57
|
};
|
|
50
58
|
export type AttackDamageEvent = DamagingEvent & {
|
|
@@ -76,6 +84,8 @@ export declare class UnitWeapon {
|
|
|
76
84
|
set cooldown(cooldown: number);
|
|
77
85
|
get damage(): [minimumDamage: number, maximumDamage: number];
|
|
78
86
|
set damage([minimumDamage, maximumDamage]: [number, number]);
|
|
87
|
+
get allowedTargetCombatClassifications(): CombatClassifications;
|
|
88
|
+
set allowedTargetCombatClassifications(allowedTargetCombatClassifications: CombatClassifications);
|
|
79
89
|
get damageBase(): number;
|
|
80
90
|
set damageBase(damageBase: number);
|
|
81
91
|
get damageDiceCount(): number;
|
|
@@ -157,10 +167,13 @@ export declare class Unit extends Handle<junit> {
|
|
|
157
167
|
get weapons(): [UnitWeapon, UnitWeapon];
|
|
158
168
|
get firstWeapon(): UnitWeapon;
|
|
159
169
|
get secondWeapon(): UnitWeapon;
|
|
170
|
+
chooseWeapon(target: Unit): UnitWeapon | undefined;
|
|
160
171
|
get level(): number;
|
|
161
172
|
set level(v: number);
|
|
162
173
|
get xp(): number;
|
|
163
174
|
set xp(v: number);
|
|
175
|
+
get primaryAttribute(): UnitAttribute;
|
|
176
|
+
set primaryAttribute(primaryAttribute: UnitAttribute);
|
|
164
177
|
get strengthBase(): number;
|
|
165
178
|
set strengthBase(strengthBase: number);
|
|
166
179
|
get strengthBonus(): number;
|
|
@@ -235,6 +248,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
235
248
|
set timeScale(v: number);
|
|
236
249
|
get collisionSize(): number;
|
|
237
250
|
get pathingCollisionRange(): number;
|
|
251
|
+
get movementType(): MovementType;
|
|
252
|
+
set movementType(movementType: MovementType);
|
|
238
253
|
set pathing(v: boolean);
|
|
239
254
|
isSelected(player: Player): boolean;
|
|
240
255
|
explode(): void;
|
|
@@ -285,6 +300,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
285
300
|
get onUnitInRange(): Record<number, Event<[Unit]>>;
|
|
286
301
|
get onManaEqual(): Record<number, Event<[Unit, number]>>;
|
|
287
302
|
get manaEvent(): Record<Operator, Record<number, Event<[Unit]>>>;
|
|
303
|
+
get targetAcquiredEvent(): Event;
|
|
288
304
|
get onSelect(): Event;
|
|
289
305
|
get onDeselect(): Event;
|
|
290
306
|
get onImmediateOrder(): Event<[number]>;
|
|
@@ -338,6 +354,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
338
354
|
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
339
355
|
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
340
356
|
static itemStackedEvent: UnitTriggerEvent<[Item]>;
|
|
357
|
+
static get itemChargesChangedEvent(): Event<[unit: Unit, item: Item]>;
|
|
341
358
|
static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
|
|
342
359
|
static get itemMoveOrderEvent(): Event<[
|
|
343
360
|
unit: Unit,
|