warscript 0.0.1-dev.d750e38 → 0.0.1-dev.d7e0522
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/config.d.ts +5 -0
- package/config.lua +10 -0
- package/core/types/effect.d.ts +1 -3
- package/core/types/effect.lua +26 -29
- package/core/types/order.d.ts +1 -0
- package/core/types/order.lua +11 -1
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/timer.d.ts +6 -7
- package/core/types/timer.lua +18 -21
- package/core/util.lua +6 -1
- package/decl/native.d.ts +840 -786
- package/engine/behaviour/ability/apply-buff.d.ts +5 -0
- package/engine/behaviour/ability/apply-buff.lua +32 -0
- package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
- package/engine/behaviour/ability/damage.d.ts +9 -3
- package/engine/behaviour/ability/damage.lua +26 -38
- package/engine/behaviour/ability/emulate-impact.lua +7 -0
- package/engine/behaviour/ability.d.ts +7 -2
- package/engine/behaviour/ability.lua +34 -7
- package/engine/behaviour/unit.d.ts +15 -0
- package/engine/behaviour/unit.lua +104 -4
- package/engine/buff.d.ts +56 -41
- package/engine/buff.lua +295 -228
- package/engine/internal/ability.d.ts +2 -0
- package/engine/internal/ability.lua +7 -0
- package/engine/internal/item/ability.lua +12 -10
- package/engine/internal/item.d.ts +6 -4
- package/engine/internal/item.lua +125 -28
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- 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/object-data/auto-attack-speed-increase.d.ts +1 -1
- package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
- package/engine/internal/object-data/evasion-probability.d.ts +2 -0
- package/engine/internal/object-data/evasion-probability.lua +16 -0
- package/engine/internal/unit/add-item-to-slot.lua +4 -2
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/bonus.d.ts +2 -0
- package/engine/internal/unit/bonus.lua +17 -0
- 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 +26 -4
- package/engine/internal/unit.lua +169 -37
- package/engine/lightning.d.ts +4 -3
- package/engine/lightning.lua +22 -15
- package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
- package/engine/object-data/auxiliary/animation-name.lua +16 -0
- package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
- package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
- package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
- package/engine/object-data/auxiliary/attack-type.lua +42 -0
- package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
- package/engine/object-data/auxiliary/movement-type.lua +22 -0
- package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
- package/engine/object-data/auxiliary/sound-eax.lua +2 -0
- package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
- package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
- package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
- package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
- package/engine/object-data/entry/ability-type/berserk.lua +13 -0
- package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
- package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
- package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
- package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
- package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
- package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
- package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
- package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
- package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
- package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
- package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
- package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
- package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
- package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
- package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
- package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
- package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
- package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
- package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
- package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
- package/engine/object-data/entry/ability-type/web.d.ts +12 -0
- package/engine/object-data/entry/ability-type/web.lua +52 -0
- package/engine/object-data/entry/ability-type.d.ts +19 -17
- package/engine/object-data/entry/ability-type.lua +81 -21
- package/engine/object-data/entry/buff-type/applicable.lua +18 -37
- package/engine/object-data/entry/buff-type.d.ts +6 -12
- package/engine/object-data/entry/buff-type.lua +13 -29
- package/engine/object-data/entry/destructible-type.d.ts +1 -1
- package/engine/object-data/entry/item-type.d.ts +1 -1
- package/engine/object-data/entry/item-type.lua +4 -4
- package/engine/object-data/entry/lightning-type.d.ts +1 -1
- package/engine/object-data/entry/sound-preset.d.ts +33 -0
- package/engine/object-data/entry/sound-preset.lua +140 -0
- package/engine/object-data/entry/unit-type.d.ts +10 -3
- package/engine/object-data/entry/unit-type.lua +155 -92
- package/engine/object-data/entry/upgrade.d.ts +1 -1
- package/engine/object-data/entry/upgrade.lua +4 -4
- package/engine/object-data/entry.d.ts +16 -14
- package/engine/object-data/entry.lua +60 -32
- 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 +9 -1
- package/engine/object-field.lua +158 -76
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- package/engine/standard/entries/sound-preset.d.ts +10 -0
- package/engine/standard/entries/sound-preset.lua +10 -0
- package/objutil/buff.lua +1 -2
- package/objutil/unit.lua +8 -0
- 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/utility/reflection.lua +11 -7
|
@@ -58,6 +58,8 @@ export declare class UnitAbility extends Ability {
|
|
|
58
58
|
constructor(handle: jability, typeId: number, owner: Unit);
|
|
59
59
|
incrementHideCounter(): void;
|
|
60
60
|
decrementHideCounter(): void;
|
|
61
|
+
incrementDisableCounter(): void;
|
|
62
|
+
decrementDisableCounter(): void;
|
|
61
63
|
get level(): number;
|
|
62
64
|
set level(v: number);
|
|
63
65
|
get cooldownRemaining(): number;
|
|
@@ -38,6 +38,7 @@ local getHandleId = GetHandleId
|
|
|
38
38
|
local getItemBooleanField = BlzGetItemBooleanField
|
|
39
39
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
40
40
|
local unitHideAbility = BlzUnitHideAbility
|
|
41
|
+
local unitDisableAbility = BlzUnitDisableAbility
|
|
41
42
|
local match = string.match
|
|
42
43
|
local ____type = _G.type
|
|
43
44
|
local ____tostring = _G.tostring
|
|
@@ -402,6 +403,12 @@ end
|
|
|
402
403
|
function UnitAbility.prototype.decrementHideCounter(self)
|
|
403
404
|
unitHideAbility(self.u, self.typeId, false)
|
|
404
405
|
end
|
|
406
|
+
function UnitAbility.prototype.incrementDisableCounter(self)
|
|
407
|
+
unitDisableAbility(self.u, self.typeId, true, false)
|
|
408
|
+
end
|
|
409
|
+
function UnitAbility.prototype.decrementDisableCounter(self)
|
|
410
|
+
unitDisableAbility(self.u, self.typeId, false, false)
|
|
411
|
+
end
|
|
405
412
|
function UnitAbility.prototype.interruptCast(self)
|
|
406
413
|
self.owner:interruptCast(self.typeId)
|
|
407
414
|
end
|
|
@@ -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)
|
|
@@ -5,8 +5,8 @@ import { Event } from "../../event";
|
|
|
5
5
|
import { ReadonlyRect } from "../../core/types/rect";
|
|
6
6
|
import { ItemAbility } from "./ability";
|
|
7
7
|
import { AbilityTypeId } from "../object-data/entry/ability-type";
|
|
8
|
+
import type { ItemTypeId } from "../object-data/entry/item-type";
|
|
8
9
|
type DefenseType = 0 | 1 | 2 | 3 | 4 | 5;
|
|
9
|
-
export declare const addAndGetAbility: (handle: jitem, abilityTypeId: AbilityTypeId) => jability | null;
|
|
10
10
|
declare const enum ItemPropertyKey {
|
|
11
11
|
ABILITIES = 100,
|
|
12
12
|
LUA_INDEX_BY_ABILITY_TYPE_ID = 101
|
|
@@ -17,7 +17,7 @@ export declare class Item extends Handle<jitem> {
|
|
|
17
17
|
constructor(handle: jitem);
|
|
18
18
|
protected onDestroy(): HandleDestructor;
|
|
19
19
|
static create<T extends Item>(this: typeof Item & (new (handle: jitem) => T), id: number, x: number, y: number, skinId?: number): T;
|
|
20
|
-
get typeId():
|
|
20
|
+
get typeId(): ItemTypeId;
|
|
21
21
|
set skinId(v: number);
|
|
22
22
|
get skinId(): number;
|
|
23
23
|
set name(v: string);
|
|
@@ -73,14 +73,16 @@ export declare class Item extends Handle<jitem> {
|
|
|
73
73
|
set position(v: Vec2);
|
|
74
74
|
set charges(v: number);
|
|
75
75
|
get charges(): number;
|
|
76
|
+
consumeCharge(): boolean;
|
|
76
77
|
addAbility(abilityTypeId: AbilityTypeId): ItemAbility | undefined;
|
|
77
78
|
removeAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
78
79
|
hasAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
79
80
|
getAbility(abilityTypeId: AbilityTypeId): ItemAbility | undefined;
|
|
80
81
|
get abilities(): readonly ItemAbility[];
|
|
81
|
-
static getInRange(
|
|
82
|
+
static getInRange(x: number, y: number, range: number): Item[];
|
|
82
83
|
static getInRect(rect: ReadonlyRect): Item[];
|
|
83
84
|
static get onCreate(): Event<[Item]>;
|
|
84
|
-
static get
|
|
85
|
+
static get destroyEvent(): Event<[Item]>;
|
|
86
|
+
static readonly chargesChangedEvent: Event<[Item]>;
|
|
85
87
|
}
|
|
86
88
|
export {};
|
package/engine/internal/item.lua
CHANGED
|
@@ -1,20 +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
|
|
24
|
+
local ____dummy_2Ditem = require("engine.internal.object-data.dummy-item")
|
|
25
|
+
local DUMMY_ITEM_ID = ____dummy_2Ditem.DUMMY_ITEM_ID
|
|
26
|
+
local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
|
|
27
|
+
local SLOT_FILLER_ITEM_TYPE_ID = ____add_2Ditem_2Dto_2Dslot.SLOT_FILLER_ITEM_TYPE_ID
|
|
28
|
+
local ____vec2 = require("math.vec2")
|
|
29
|
+
local distance = ____vec2.distance
|
|
30
|
+
local itemChargesChangeEvent = __TS__New(Event)
|
|
18
31
|
local itemAddAbility = BlzItemAddAbility
|
|
19
32
|
local itemRemoveAbility = BlzItemRemoveAbility
|
|
20
33
|
local getItemAbility = BlzGetItemAbility
|
|
@@ -24,10 +37,30 @@ local getAbilityId = BlzGetAbilityId
|
|
|
24
37
|
local getWidgetLife = GetWidgetLife
|
|
25
38
|
local removeItem = RemoveItem
|
|
26
39
|
local getHandleId = GetHandleId
|
|
40
|
+
local setRect = SetRect
|
|
41
|
+
local enumItemsInRect = EnumItemsInRect
|
|
42
|
+
local getEnumItem = GetEnumItem
|
|
43
|
+
local getItemTypeId = GetItemTypeId
|
|
44
|
+
local getItemX = GetItemX
|
|
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
|
|
27
57
|
local getItemIntegerField = BlzGetItemIntegerField
|
|
28
58
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
29
59
|
local getItemBooleanField = BlzGetItemBooleanField
|
|
60
|
+
invoke = Event.invoke
|
|
30
61
|
local enumRect = Rect:create(0, 0, 0, 0).handle
|
|
62
|
+
---
|
|
63
|
+
-- @internal For use by internal systems only.
|
|
31
64
|
____exports.addAndGetAbility = function(handle, abilityTypeId)
|
|
32
65
|
if itemAddAbility(handle, abilityTypeId) then
|
|
33
66
|
return getItemAbility(handle, abilityTypeId)
|
|
@@ -53,6 +86,49 @@ local function getItemAbilities(handle, item)
|
|
|
53
86
|
end
|
|
54
87
|
return abilities
|
|
55
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
|
|
106
|
+
local targetCollection
|
|
107
|
+
local targetCollectionNextIndex
|
|
108
|
+
local centerX
|
|
109
|
+
local centerY
|
|
110
|
+
local enumRange
|
|
111
|
+
local function collectIntoTarget()
|
|
112
|
+
local item = getEnumItem()
|
|
113
|
+
local typeId = getItemTypeId(item)
|
|
114
|
+
if typeId ~= DUMMY_ITEM_ID and typeId ~= SLOT_FILLER_ITEM_TYPE_ID then
|
|
115
|
+
targetCollection[targetCollectionNextIndex] = ____exports.Item:of(item)
|
|
116
|
+
targetCollectionNextIndex = targetCollectionNextIndex + 1
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
local function collectIntoTargetRange()
|
|
120
|
+
local item = getEnumItem()
|
|
121
|
+
local typeId = getItemTypeId(item)
|
|
122
|
+
if distance(
|
|
123
|
+
getItemX(item),
|
|
124
|
+
getItemY(item),
|
|
125
|
+
centerX,
|
|
126
|
+
centerY
|
|
127
|
+
) <= enumRange and typeId ~= DUMMY_ITEM_ID and typeId ~= SLOT_FILLER_ITEM_TYPE_ID then
|
|
128
|
+
targetCollection[targetCollectionNextIndex] = ____exports.Item:of(item)
|
|
129
|
+
targetCollectionNextIndex = targetCollectionNextIndex + 1
|
|
130
|
+
end
|
|
131
|
+
end
|
|
56
132
|
____exports.Item = __TS__Class()
|
|
57
133
|
local Item = ____exports.Item
|
|
58
134
|
Item.name = "Item"
|
|
@@ -78,6 +154,32 @@ end
|
|
|
78
154
|
function Item.create(self, id, x, y, skinId)
|
|
79
155
|
return self:of(BlzCreateItemWithSkin(id, x, y, skinId or id))
|
|
80
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
|
|
81
183
|
function Item.prototype.addAbility(self, abilityTypeId)
|
|
82
184
|
local nativeAbility = doAbilityAction(self.handle, ____exports.addAndGetAbility, abilityTypeId)
|
|
83
185
|
if nativeAbility ~= nil then
|
|
@@ -111,34 +213,27 @@ function Item.prototype.getAbility(self, abilityTypeId)
|
|
|
111
213
|
local ability = self[101][abilityTypeId] ~= nil and doAbilityAction(self.handle, getItemAbility, abilityTypeId)
|
|
112
214
|
return ability and ItemAbility:of(ability, abilityTypeId, self) or nil
|
|
113
215
|
end
|
|
114
|
-
function Item.getInRange(self,
|
|
115
|
-
|
|
116
|
-
|
|
216
|
+
function Item.getInRange(self, x, y, range)
|
|
217
|
+
targetCollection = {}
|
|
218
|
+
targetCollectionNextIndex = 1
|
|
219
|
+
centerX = x
|
|
220
|
+
centerY = y
|
|
221
|
+
enumRange = range
|
|
222
|
+
setRect(
|
|
117
223
|
enumRect,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
224
|
+
x - range,
|
|
225
|
+
y - range,
|
|
226
|
+
x + range,
|
|
227
|
+
y + range
|
|
122
228
|
)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
nil,
|
|
126
|
-
function()
|
|
127
|
-
collection[#collection + 1] = self:of(GetEnumItem())
|
|
128
|
-
end
|
|
129
|
-
)
|
|
130
|
-
return collection
|
|
229
|
+
enumItemsInRect(enumRect, nil, collectIntoTargetRange)
|
|
230
|
+
return targetCollection
|
|
131
231
|
end
|
|
132
232
|
function Item.getInRect(self, rect)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
function()
|
|
138
|
-
collection[#collection + 1] = self:of(GetEnumItem())
|
|
139
|
-
end
|
|
140
|
-
)
|
|
141
|
-
return collection
|
|
233
|
+
targetCollection = {}
|
|
234
|
+
targetCollectionNextIndex = 1
|
|
235
|
+
enumItemsInRect(rect.handle, nil, collectIntoTarget)
|
|
236
|
+
return targetCollection
|
|
142
237
|
end
|
|
143
238
|
__TS__SetDescriptor(
|
|
144
239
|
Item.prototype,
|
|
@@ -270,7 +365,7 @@ __TS__SetDescriptor(
|
|
|
270
365
|
"perishable",
|
|
271
366
|
{
|
|
272
367
|
get = function(self)
|
|
273
|
-
return
|
|
368
|
+
return getItemBooleanField(self.handle, ITEM_BF_PERISHABLE)
|
|
274
369
|
end,
|
|
275
370
|
set = function(self, v)
|
|
276
371
|
BlzSetItemBooleanField(self.handle, ITEM_BF_PERISHABLE, v)
|
|
@@ -526,10 +621,11 @@ __TS__SetDescriptor(
|
|
|
526
621
|
"charges",
|
|
527
622
|
{
|
|
528
623
|
get = function(self)
|
|
529
|
-
return
|
|
624
|
+
return getItemCharges(self.handle)
|
|
530
625
|
end,
|
|
531
626
|
set = function(self, v)
|
|
532
|
-
|
|
627
|
+
setItemCharges(self.handle, v)
|
|
628
|
+
invoke(itemChargesChangeEvent, self)
|
|
533
629
|
end
|
|
534
630
|
},
|
|
535
631
|
true
|
|
@@ -551,11 +647,12 @@ __TS__ObjectDefineProperty(
|
|
|
551
647
|
)
|
|
552
648
|
__TS__ObjectDefineProperty(
|
|
553
649
|
Item,
|
|
554
|
-
"
|
|
650
|
+
"destroyEvent",
|
|
555
651
|
{get = function(self)
|
|
556
652
|
return self.onDestroyEvent
|
|
557
653
|
end}
|
|
558
654
|
)
|
|
655
|
+
Item.chargesChangedEvent = itemChargesChangeEvent
|
|
559
656
|
local getManipulatedItem = GetManipulatedItem
|
|
560
657
|
local trigger = CreateTrigger()
|
|
561
658
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_PICKUP_ITEM)
|
|
@@ -8,6 +8,6 @@ local DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD = ____ability.DURATION_NORMAL_AB
|
|
|
8
8
|
-- @internal For use by internal systems only.
|
|
9
9
|
____exports.getAbilityDuration = function(ability, target)
|
|
10
10
|
local level = ability.level
|
|
11
|
-
return target ~= nil and target:hasClassification(UnitClassification.RESISTANT) and DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level) or DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level)
|
|
11
|
+
return target ~= nil and (target.isHero or target:getField(UNIT_IF_LEVEL) >= 6 or target:hasClassification(UnitClassification.RESISTANT)) and DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level) or DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level)
|
|
12
12
|
end
|
|
13
13
|
return ____exports
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
-
export
|
|
2
|
+
export {};
|
|
@@ -10,5 +10,7 @@ ____exports.AUTO_ATTACK_SPEED_INCREASE_DUMMY_ABILITY_TYPE_ID = compiletime(funct
|
|
|
10
10
|
abilityType.autoAttackSpeedIncreaseFactor = 0
|
|
11
11
|
return abilityType.id
|
|
12
12
|
end)
|
|
13
|
+
---
|
|
14
|
+
-- @internal For use by internal systems.
|
|
13
15
|
____exports.AUTO_ATTACK_SPEED_INCREASE_FACTOR_ABILITY_FIELD = ABILITY_RLF_ATTACK_SPEED_INCREASE_ISX1
|
|
14
16
|
return ____exports
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____evasion = require("engine.object-data.entry.ability-type.evasion")
|
|
3
|
+
local EvasionAbilityType = ____evasion.EvasionAbilityType
|
|
4
|
+
---
|
|
5
|
+
-- @internal For use by internal systems.
|
|
6
|
+
____exports.EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID = compiletime(function()
|
|
7
|
+
local abilityType = EvasionAbilityType:create()
|
|
8
|
+
abilityType.isInternal = true
|
|
9
|
+
abilityType.isButtonVisible = false
|
|
10
|
+
abilityType.evasionProbability = 0
|
|
11
|
+
return abilityType.id
|
|
12
|
+
end)
|
|
13
|
+
---
|
|
14
|
+
-- @internal For use by internal systems.
|
|
15
|
+
____exports.EVASION_PROBABILITY_ABILITY_FIELD = ABILITY_RLF_CHANCE_TO_EVADE_EEV1
|
|
16
|
+
return ____exports
|
|
@@ -9,7 +9,9 @@ local setItemVisible = SetItemVisible
|
|
|
9
9
|
local unitAddItem = UnitAddItem
|
|
10
10
|
local unitItemInSlot = UnitItemInSlot
|
|
11
11
|
local unitRemoveItem = UnitRemoveItem
|
|
12
|
-
|
|
12
|
+
---
|
|
13
|
+
-- @internal For use by internal systems only.
|
|
14
|
+
____exports.SLOT_FILLER_ITEM_TYPE_ID = compiletime(function()
|
|
13
15
|
local itemType = BlankItemType:create()
|
|
14
16
|
itemType.name = "[Warscript/Dummy] Slot Filler"
|
|
15
17
|
return itemType.id
|
|
@@ -19,7 +21,7 @@ end)
|
|
|
19
21
|
____exports.fillerItems = array(
|
|
20
22
|
6,
|
|
21
23
|
function()
|
|
22
|
-
local item = CreateItem(
|
|
24
|
+
local item = CreateItem(____exports.SLOT_FILLER_ITEM_TYPE_ID, 0, 0)
|
|
23
25
|
setItemVisible(item, false)
|
|
24
26
|
ignoreEventsItems[item] = true
|
|
25
27
|
return 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)
|
|
@@ -11,6 +11,7 @@ export type UnitMovementSpeedFactorBonusId = UnitBonusId<"movementSpeedFactor">;
|
|
|
11
11
|
export type UnitAutoAttackDamageBonusId = UnitBonusId<"autoAttackDamage">;
|
|
12
12
|
export type UnitDamageFactorBonusId = UnitBonusId<"damageFactor">;
|
|
13
13
|
export type UnitReceivedDamageFactorBonusId = UnitBonusId<"receivedDamageFactor">;
|
|
14
|
+
export type UnitEvasionProbabilityBonusId = UnitBonusId<"evasionProbability">;
|
|
14
15
|
export type UnitBonusType<Id extends UnitBonusId = UnitBonusId> = ({
|
|
15
16
|
abilityTypeId: AbilityTypeId;
|
|
16
17
|
field: jabilityintegerlevelfield;
|
|
@@ -34,6 +35,7 @@ export declare namespace UnitBonusType {
|
|
|
34
35
|
const AUTO_ATTACK_DAMAGE: UnitBonusType<UnitAutoAttackDamageBonusId>;
|
|
35
36
|
const DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
|
|
36
37
|
const RECEIVED_DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
|
|
38
|
+
const EVASION_PROBABILITY: UnitBonusType<UnitEvasionProbabilityBonusId>;
|
|
37
39
|
}
|
|
38
40
|
export declare const addUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, value: number) => Id;
|
|
39
41
|
export declare const removeUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id) => boolean;
|
|
@@ -21,8 +21,18 @@ local AUTO_ATTACK_DAMAGE_INCREASE_DUMMY_ABILITY_TYPE_ID = ____auto_2Dattack_2Dda
|
|
|
21
21
|
local ____movement_2Dspeed_2Dincrease_2Dfactor = require("engine.internal.object-data.movement-speed-increase-factor")
|
|
22
22
|
local MOVEMENT_SPEED_INCREASE_FACTOR_ABILITY_FIELD = ____movement_2Dspeed_2Dincrease_2Dfactor.MOVEMENT_SPEED_INCREASE_FACTOR_ABILITY_FIELD
|
|
23
23
|
local MOVEMENT_SPEED_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID = ____movement_2Dspeed_2Dincrease_2Dfactor.MOVEMENT_SPEED_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID
|
|
24
|
+
local ____evasion_2Dprobability = require("engine.internal.object-data.evasion-probability")
|
|
25
|
+
local EVASION_PROBABILITY_ABILITY_FIELD = ____evasion_2Dprobability.EVASION_PROBABILITY_ABILITY_FIELD
|
|
26
|
+
local EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID = ____evasion_2Dprobability.EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID
|
|
24
27
|
local damageFactorByUnit = {}
|
|
25
28
|
local receivedDamageFactorByUnit = {}
|
|
29
|
+
local function atLeastOnceProbability(array)
|
|
30
|
+
local oppositeEventProbability = 1
|
|
31
|
+
for i = 1, #array do
|
|
32
|
+
oppositeEventProbability = oppositeEventProbability * (1 - array[i])
|
|
33
|
+
end
|
|
34
|
+
return 1 - oppositeEventProbability
|
|
35
|
+
end
|
|
26
36
|
____exports.UnitBonusType = {}
|
|
27
37
|
local UnitBonusType = ____exports.UnitBonusType
|
|
28
38
|
do
|
|
@@ -56,6 +66,13 @@ do
|
|
|
56
66
|
}
|
|
57
67
|
UnitBonusType.DAMAGE_FACTOR = {reduce = product, valueByUnit = damageFactorByUnit, initialValue = 1}
|
|
58
68
|
UnitBonusType.RECEIVED_DAMAGE_FACTOR = {reduce = product, valueByUnit = receivedDamageFactorByUnit, initialValue = 1}
|
|
69
|
+
UnitBonusType.EVASION_PROBABILITY = {
|
|
70
|
+
abilityTypeId = EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID,
|
|
71
|
+
field = EVASION_PROBABILITY_ABILITY_FIELD,
|
|
72
|
+
integer = false,
|
|
73
|
+
reduce = atLeastOnceProbability,
|
|
74
|
+
initialValue = 0
|
|
75
|
+
}
|
|
59
76
|
end
|
|
60
77
|
local bonusesByUnitByBonusType = {}
|
|
61
78
|
local nextId = 1
|
|
@@ -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)
|