warscript 0.0.1-dev.724bf08 → 0.0.1-dev.738793
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/config.d.ts +5 -0
- package/config.lua +10 -0
- package/core/types/effect.d.ts +2 -3
- package/core/types/effect.lua +95 -48
- 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.d.ts +1 -1
- package/core/util.lua +12 -1
- package/decl/native.d.ts +840 -786
- package/engine/behaviour/ability/always-enabled.d.ts +7 -0
- package/engine/behaviour/ability/always-enabled.lua +31 -0
- 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 +5 -1
- package/engine/behaviour/ability/damage.lua +2 -2
- package/engine/behaviour/ability/emulate-impact.lua +12 -7
- package/engine/behaviour/ability/on-command-impact.lua +7 -0
- package/engine/behaviour/ability.d.ts +13 -3
- package/engine/behaviour/ability.lua +70 -7
- package/engine/behaviour/unit.d.ts +2 -0
- package/engine/buff.d.ts +56 -41
- package/engine/buff.lua +295 -228
- package/engine/internal/ability.d.ts +11 -1
- package/engine/internal/ability.lua +67 -2
- package/engine/internal/item/ability.lua +106 -0
- package/engine/internal/item.d.ts +4 -3
- package/engine/internal/item.lua +56 -25
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
- package/engine/internal/misc/ability-disable-counter.lua +13 -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-init.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
- package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot.lua +52 -0
- package/engine/internal/unit/bonus.d.ts +2 -0
- package/engine/internal/unit/bonus.lua +17 -0
- package/engine/internal/unit/ignore-events-items.d.ts +2 -0
- package/engine/internal/unit/ignore-events-items.lua +5 -0
- package/engine/internal/unit/item.lua +6 -12
- package/engine/internal/unit+damage.d.ts +1 -10
- package/engine/internal/unit+damage.lua +4 -13
- package/engine/internal/unit+spellSteal.lua +1 -2
- package/engine/internal/unit.d.ts +17 -3
- package/engine/internal/unit.lua +117 -30
- package/engine/internal/utility.lua +12 -0
- package/engine/lightning.d.ts +12 -5
- package/engine/lightning.lua +48 -14
- 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/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 +89 -33
- 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 +3 -1
- package/engine/object-data/entry/item-type.lua +15 -2
- 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-data/utility/object-data-entry-id-generator.lua +7 -0
- package/engine/object-field/ability.d.ts +6 -3
- package/engine/object-field/ability.lua +3 -0
- package/engine/object-field/unit.d.ts +46 -3
- package/engine/object-field/unit.lua +173 -7
- package/engine/object-field.d.ts +11 -3
- package/engine/object-field.lua +162 -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/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -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
|
@@ -7,12 +7,14 @@ local ____item = require("engine.internal.item")
|
|
|
7
7
|
local Item = ____item.Item
|
|
8
8
|
local ____unit = require("engine.internal.unit")
|
|
9
9
|
local Unit = ____unit.Unit
|
|
10
|
+
local ____utility = require("engine.internal.utility")
|
|
11
|
+
local findUnitItemSlot = ____utility.findUnitItemSlot
|
|
12
|
+
local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
|
|
13
|
+
local unitAddItemToSlot = ____add_2Ditem_2Dto_2Dslot.unitAddItemToSlot
|
|
10
14
|
local rawset = _G.rawset
|
|
11
15
|
local ____type = _G.type
|
|
12
16
|
local isItemPowerup = IsItemPowerup
|
|
13
17
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
14
|
-
local unitAddItem = UnitAddItem
|
|
15
|
-
local unitDropItemSlot = UnitDropItemSlot
|
|
16
18
|
local unitInventorySize = UnitInventorySize
|
|
17
19
|
local unitItemInSlot = UnitItemInSlot
|
|
18
20
|
local unitRemoveItemFromSlot = UnitRemoveItemFromSlot
|
|
@@ -31,14 +33,7 @@ function UnitItems.prototype.____constructor(self, handle)
|
|
|
31
33
|
handleByUnitItems[self] = handle
|
|
32
34
|
end
|
|
33
35
|
function UnitItems.prototype.findSlot(self, item)
|
|
34
|
-
|
|
35
|
-
local itemHandle = item.handle
|
|
36
|
-
for slot = 0, unitInventorySize(handle) - 1 do
|
|
37
|
-
if itemHandle == unitItemInSlot(handle, slot) then
|
|
38
|
-
return slot
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
return nil
|
|
36
|
+
return findUnitItemSlot(handleByUnitItems[self], item.handle)
|
|
42
37
|
end
|
|
43
38
|
function UnitItems.prototype.__newindex(self, slot, item)
|
|
44
39
|
local handle = handleByUnitItems[self]
|
|
@@ -52,8 +47,7 @@ function UnitItems.prototype.__newindex(self, slot, item)
|
|
|
52
47
|
if isPowerup then
|
|
53
48
|
setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
|
|
54
49
|
end
|
|
55
|
-
|
|
56
|
-
unitDropItemSlot(handle, itemHandle, slot - 1)
|
|
50
|
+
unitAddItemToSlot(handle, itemHandle, slot - 1)
|
|
57
51
|
if isPowerup then
|
|
58
52
|
setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
59
53
|
end
|
|
@@ -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;
|
|
@@ -7,21 +7,12 @@ 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
|
|
10
12
|
local createUnit = CreateUnit
|
|
11
13
|
local getOwningPlayer = GetOwningPlayer
|
|
12
14
|
local showUnit = ShowUnit
|
|
13
15
|
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
16
|
____exports.DamageType = {}
|
|
26
17
|
local DamageType = ____exports.DamageType
|
|
27
18
|
do
|
|
@@ -96,7 +87,7 @@ Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, att
|
|
|
96
87
|
ranged = false
|
|
97
88
|
end
|
|
98
89
|
if attackType == nil then
|
|
99
|
-
attackType =
|
|
90
|
+
attackType = 0
|
|
100
91
|
end
|
|
101
92
|
if damageType == nil then
|
|
102
93
|
damageType = ____exports.DamageType.MAGIC
|
|
@@ -115,7 +106,7 @@ Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, att
|
|
|
115
106
|
amount,
|
|
116
107
|
attack,
|
|
117
108
|
ranged,
|
|
118
|
-
attackType,
|
|
109
|
+
attackTypeToNative(attackType),
|
|
119
110
|
damageType,
|
|
120
111
|
weaponType
|
|
121
112
|
)
|
|
@@ -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,
|
|
@@ -11,6 +11,9 @@ 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";
|
|
14
17
|
export type UnitClassification = junittype;
|
|
15
18
|
export declare namespace UnitClassification {
|
|
16
19
|
const STRUCTURE: junittype;
|
|
@@ -38,7 +41,7 @@ type AbilityDispatcherTable<T extends any[] = []> = {
|
|
|
38
41
|
type AbilityEventDispatcher<T extends any[] = []> = Event<[Unit, Ability, ...T]> & AbilityDispatcherTable<T>;
|
|
39
42
|
export interface DamagingEvent {
|
|
40
43
|
amount: number;
|
|
41
|
-
attackType:
|
|
44
|
+
attackType: AttackType;
|
|
42
45
|
damageType: jdamagetype;
|
|
43
46
|
weaponType: jweapontype;
|
|
44
47
|
readonly isAttack: boolean;
|
|
@@ -100,7 +103,9 @@ declare const enum UnitPropertyKey {
|
|
|
100
103
|
DELAY_HEALTH_CHECKS_COUNTER = 103,
|
|
101
104
|
DELAY_HEALTH_CHECKS_HEALTH_BONUS = 104,
|
|
102
105
|
PREVENT_DEATH_HEALTH_BONUS = 105,
|
|
103
|
-
IS_TEAM_GLOW_HIDDEN = 106
|
|
106
|
+
IS_TEAM_GLOW_HIDDEN = 106,
|
|
107
|
+
LAST_X = 107,
|
|
108
|
+
LAST_Y = 108
|
|
104
109
|
}
|
|
105
110
|
export type UnitSyncId = number & {
|
|
106
111
|
readonly __unitSyncId: unique symbol;
|
|
@@ -113,6 +118,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
113
118
|
private [UnitPropertyKey.DELAY_HEALTH_CHECKS_HEALTH_BONUS]?;
|
|
114
119
|
private [UnitPropertyKey.PREVENT_DEATH_HEALTH_BONUS]?;
|
|
115
120
|
private [UnitPropertyKey.IS_TEAM_GLOW_HIDDEN]?;
|
|
121
|
+
private [UnitPropertyKey.LAST_X]?;
|
|
122
|
+
private [UnitPropertyKey.LAST_Y]?;
|
|
116
123
|
private _owner?;
|
|
117
124
|
private _timeScale?;
|
|
118
125
|
private events?;
|
|
@@ -133,6 +140,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
133
140
|
get isAlive(): boolean;
|
|
134
141
|
get isDead(): boolean;
|
|
135
142
|
get isIllusion(): boolean;
|
|
143
|
+
get isStunned(): boolean;
|
|
136
144
|
get combatClassifications(): CombatClassifications;
|
|
137
145
|
set combatClassifications(combatClassifications: CombatClassifications);
|
|
138
146
|
hasCombatClassification(combatClassification: CombatClassification): boolean;
|
|
@@ -147,6 +155,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
147
155
|
isEnemyOf(unit: Unit): boolean;
|
|
148
156
|
playAnimation(animation: string, rarity?: jraritycontrol): void;
|
|
149
157
|
playAnimation(animation: number): void;
|
|
158
|
+
resetAnimation(): void;
|
|
150
159
|
queueAnimation(animation: string): void;
|
|
151
160
|
get weapons(): [UnitWeapon, UnitWeapon];
|
|
152
161
|
get firstWeapon(): UnitWeapon;
|
|
@@ -155,6 +164,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
155
164
|
set level(v: number);
|
|
156
165
|
get xp(): number;
|
|
157
166
|
set xp(v: number);
|
|
167
|
+
get primaryAttribute(): UnitAttribute;
|
|
168
|
+
set primaryAttribute(primaryAttribute: UnitAttribute);
|
|
158
169
|
get strengthBase(): number;
|
|
159
170
|
set strengthBase(strengthBase: number);
|
|
160
171
|
get strengthBonus(): number;
|
|
@@ -229,6 +240,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
229
240
|
set timeScale(v: number);
|
|
230
241
|
get collisionSize(): number;
|
|
231
242
|
get pathingCollisionRange(): number;
|
|
243
|
+
get movementType(): MovementType;
|
|
244
|
+
set movementType(movementType: MovementType);
|
|
232
245
|
set pathing(v: boolean);
|
|
233
246
|
isSelected(player: Player): boolean;
|
|
234
247
|
explode(): void;
|
|
@@ -332,7 +345,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
332
345
|
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
333
346
|
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
334
347
|
static itemStackedEvent: UnitTriggerEvent<[Item]>;
|
|
335
|
-
static get
|
|
348
|
+
static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
|
|
349
|
+
static get itemMoveOrderEvent(): Event<[
|
|
336
350
|
unit: Unit,
|
|
337
351
|
item: Item,
|
|
338
352
|
slotFrom: 0 | 1 | 2 | 3 | 4 | 5,
|
package/engine/internal/unit.lua
CHANGED
|
@@ -51,11 +51,17 @@ local ____arrays = require("utility.arrays")
|
|
|
51
51
|
local forEach = ____arrays.forEach
|
|
52
52
|
local ____math = require("math")
|
|
53
53
|
local min = ____math.min
|
|
54
|
+
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
55
|
+
local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
56
|
+
local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
|
|
57
|
+
local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
|
|
58
|
+
local nativeToAttackType = ____attack_2Dtype.nativeToAttackType
|
|
54
59
|
local match = string.match
|
|
55
60
|
local ____tostring = _G.tostring
|
|
56
61
|
local setUnitAnimation = SetUnitAnimation
|
|
57
62
|
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
58
63
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
64
|
+
local resetUnitAnimation = ResetUnitAnimation
|
|
59
65
|
local queueUnitAnimation = QueueUnitAnimation
|
|
60
66
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
61
67
|
local getUnitRealField = BlzGetUnitRealField
|
|
@@ -75,9 +81,9 @@ local setUnitScale = SetUnitScale
|
|
|
75
81
|
local setUnitPosition = SetUnitPosition
|
|
76
82
|
local setUnitTimeScale = SetUnitTimeScale
|
|
77
83
|
local getHandleId = GetHandleId
|
|
84
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
78
85
|
local createUnit = CreateUnit
|
|
79
86
|
local killUnit = KillUnit
|
|
80
|
-
local setUnitExploded = SetUnitExploded
|
|
81
87
|
local removeUnit = RemoveUnit
|
|
82
88
|
local getUnitTypeId = GetUnitTypeId
|
|
83
89
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -93,8 +99,6 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
93
99
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
94
100
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
95
101
|
local isUnitInRange = IsUnitInRange
|
|
96
|
-
local setResourceAmount = SetResourceAmount
|
|
97
|
-
local getResourceAmount = GetResourceAmount
|
|
98
102
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
99
103
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
100
104
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
@@ -125,8 +129,6 @@ local isUnitType = IsUnitType
|
|
|
125
129
|
local isUnitAlly = IsUnitAlly
|
|
126
130
|
local isUnitEnemy = IsUnitEnemy
|
|
127
131
|
local getOwningPlayer = GetOwningPlayer
|
|
128
|
-
local setUnitColor = SetUnitColor
|
|
129
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
130
132
|
____exports.UnitClassification = {}
|
|
131
133
|
local UnitClassification = ____exports.UnitClassification
|
|
132
134
|
do
|
|
@@ -354,7 +356,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
354
356
|
rawset(self, 1 + i, (select(i, ...)))
|
|
355
357
|
end
|
|
356
358
|
end
|
|
357
|
-
local damageSetters = {
|
|
359
|
+
local damageSetters = {
|
|
360
|
+
amount = BlzSetEventDamage,
|
|
361
|
+
attackType = function(attackType)
|
|
362
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
363
|
+
end,
|
|
364
|
+
damageType = BlzSetEventDamageType,
|
|
365
|
+
weaponType = BlzSetEventWeaponType
|
|
366
|
+
}
|
|
358
367
|
local jlimitopByOperator = {
|
|
359
368
|
[0] = LESS_THAN_OR_EQUAL,
|
|
360
369
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -677,6 +686,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
677
686
|
end
|
|
678
687
|
function Unit.prototype.onDestroy(self)
|
|
679
688
|
local handle = self.handle
|
|
689
|
+
self[107] = getUnitX(handle)
|
|
690
|
+
self[108] = getUnitY(handle)
|
|
680
691
|
if not self._owner then
|
|
681
692
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
682
693
|
end
|
|
@@ -792,6 +803,9 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
792
803
|
setUnitAnimation(self.handle, animation)
|
|
793
804
|
end
|
|
794
805
|
end
|
|
806
|
+
function Unit.prototype.resetAnimation(self)
|
|
807
|
+
resetUnitAnimation(self.handle)
|
|
808
|
+
end
|
|
795
809
|
function Unit.prototype.queueAnimation(self, animation)
|
|
796
810
|
queueUnitAnimation(self.handle, animation)
|
|
797
811
|
end
|
|
@@ -806,7 +820,7 @@ function Unit.prototype.isSelected(self, player)
|
|
|
806
820
|
return IsUnitSelected(self.handle, player.handle)
|
|
807
821
|
end
|
|
808
822
|
function Unit.prototype.explode(self)
|
|
809
|
-
|
|
823
|
+
SetUnitExploded(self.handle, true)
|
|
810
824
|
killUnit(self.handle)
|
|
811
825
|
end
|
|
812
826
|
function Unit.prototype.kill(self)
|
|
@@ -929,8 +943,15 @@ function Unit.prototype.interruptAttack(self)
|
|
|
929
943
|
unitInterruptAttack(self.handle)
|
|
930
944
|
end
|
|
931
945
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
932
|
-
|
|
933
|
-
unitDisableAbility(
|
|
946
|
+
local handle = self.handle
|
|
947
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
948
|
+
Timer:run(
|
|
949
|
+
unitDisableAbility,
|
|
950
|
+
handle,
|
|
951
|
+
abilityId,
|
|
952
|
+
false,
|
|
953
|
+
false
|
|
954
|
+
)
|
|
934
955
|
end
|
|
935
956
|
function Unit.prototype.getDistanceTo(self, target)
|
|
936
957
|
local handle = self.handle
|
|
@@ -1195,6 +1216,14 @@ __TS__SetDescriptor(
|
|
|
1195
1216
|
end},
|
|
1196
1217
|
true
|
|
1197
1218
|
)
|
|
1219
|
+
__TS__SetDescriptor(
|
|
1220
|
+
Unit.prototype,
|
|
1221
|
+
"isStunned",
|
|
1222
|
+
{get = function(self)
|
|
1223
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1224
|
+
end},
|
|
1225
|
+
true
|
|
1226
|
+
)
|
|
1198
1227
|
__TS__SetDescriptor(
|
|
1199
1228
|
Unit.prototype,
|
|
1200
1229
|
"combatClassifications",
|
|
@@ -1268,6 +1297,19 @@ __TS__SetDescriptor(
|
|
|
1268
1297
|
},
|
|
1269
1298
|
true
|
|
1270
1299
|
)
|
|
1300
|
+
__TS__SetDescriptor(
|
|
1301
|
+
Unit.prototype,
|
|
1302
|
+
"primaryAttribute",
|
|
1303
|
+
{
|
|
1304
|
+
get = function(self)
|
|
1305
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1306
|
+
end,
|
|
1307
|
+
set = function(self, primaryAttribute)
|
|
1308
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1309
|
+
end
|
|
1310
|
+
},
|
|
1311
|
+
true
|
|
1312
|
+
)
|
|
1271
1313
|
__TS__SetDescriptor(
|
|
1272
1314
|
Unit.prototype,
|
|
1273
1315
|
"strengthBase",
|
|
@@ -1392,7 +1434,7 @@ __TS__SetDescriptor(
|
|
|
1392
1434
|
return not self[106]
|
|
1393
1435
|
end,
|
|
1394
1436
|
set = function(self, isTeamGlowVisible)
|
|
1395
|
-
|
|
1437
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1396
1438
|
local ____temp_6
|
|
1397
1439
|
if not isTeamGlowVisible then
|
|
1398
1440
|
____temp_6 = true
|
|
@@ -1408,9 +1450,9 @@ __TS__SetDescriptor(
|
|
|
1408
1450
|
Unit.prototype,
|
|
1409
1451
|
"color",
|
|
1410
1452
|
{set = function(self, color)
|
|
1411
|
-
|
|
1453
|
+
SetUnitColor(self.handle, color.handle)
|
|
1412
1454
|
if self[106] then
|
|
1413
|
-
|
|
1455
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1414
1456
|
end
|
|
1415
1457
|
end},
|
|
1416
1458
|
true
|
|
@@ -1579,7 +1621,7 @@ __TS__SetDescriptor(
|
|
|
1579
1621
|
"x",
|
|
1580
1622
|
{
|
|
1581
1623
|
get = function(self)
|
|
1582
|
-
return getUnitX(self.handle)
|
|
1624
|
+
return self[107] or getUnitX(self.handle)
|
|
1583
1625
|
end,
|
|
1584
1626
|
set = function(self, v)
|
|
1585
1627
|
SetUnitX(self.handle, v)
|
|
@@ -1592,7 +1634,7 @@ __TS__SetDescriptor(
|
|
|
1592
1634
|
"y",
|
|
1593
1635
|
{
|
|
1594
1636
|
get = function(self)
|
|
1595
|
-
return getUnitY(self.handle)
|
|
1637
|
+
return self[108] or getUnitY(self.handle)
|
|
1596
1638
|
end,
|
|
1597
1639
|
set = function(self, v)
|
|
1598
1640
|
SetUnitY(self.handle, v)
|
|
@@ -1678,10 +1720,10 @@ __TS__SetDescriptor(
|
|
|
1678
1720
|
"gold",
|
|
1679
1721
|
{
|
|
1680
1722
|
get = function(self)
|
|
1681
|
-
return
|
|
1723
|
+
return GetResourceAmount(self.handle)
|
|
1682
1724
|
end,
|
|
1683
1725
|
set = function(self, gold)
|
|
1684
|
-
|
|
1726
|
+
SetResourceAmount(self.handle, gold)
|
|
1685
1727
|
end
|
|
1686
1728
|
},
|
|
1687
1729
|
true
|
|
@@ -1809,6 +1851,19 @@ __TS__SetDescriptor(
|
|
|
1809
1851
|
end},
|
|
1810
1852
|
true
|
|
1811
1853
|
)
|
|
1854
|
+
__TS__SetDescriptor(
|
|
1855
|
+
Unit.prototype,
|
|
1856
|
+
"movementType",
|
|
1857
|
+
{
|
|
1858
|
+
get = function(self)
|
|
1859
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1860
|
+
end,
|
|
1861
|
+
set = function(self, movementType)
|
|
1862
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1863
|
+
end
|
|
1864
|
+
},
|
|
1865
|
+
true
|
|
1866
|
+
)
|
|
1812
1867
|
__TS__SetDescriptor(
|
|
1813
1868
|
Unit.prototype,
|
|
1814
1869
|
"pathing",
|
|
@@ -2315,10 +2370,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2315
2370
|
____exports.UnitTriggerEvent,
|
|
2316
2371
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2317
2372
|
function()
|
|
2318
|
-
local
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2373
|
+
local handle = getOrderedUnit()
|
|
2374
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2375
|
+
local unit = ____exports.Unit:of(handle)
|
|
2376
|
+
if unit.state == 1 then
|
|
2377
|
+
return unit, getIssuedOrderId()
|
|
2378
|
+
end
|
|
2322
2379
|
end
|
|
2323
2380
|
return IgnoreEvent
|
|
2324
2381
|
end
|
|
@@ -2352,7 +2409,7 @@ Unit.onDamaging = (function()
|
|
|
2352
2409
|
local target = BlzGetEventDamageTarget()
|
|
2353
2410
|
local data = {
|
|
2354
2411
|
amount = GetEventDamage(),
|
|
2355
|
-
attackType = BlzGetEventAttackType(),
|
|
2412
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2356
2413
|
damageType = BlzGetEventDamageType(),
|
|
2357
2414
|
weaponType = BlzGetEventWeaponType(),
|
|
2358
2415
|
isAttack = BlzGetEventIsAttack()
|
|
@@ -2420,7 +2477,7 @@ Unit.onDamaging = (function()
|
|
|
2420
2477
|
data.amount,
|
|
2421
2478
|
true,
|
|
2422
2479
|
true,
|
|
2423
|
-
data.attackType,
|
|
2480
|
+
attackTypeToNative(data.attackType),
|
|
2424
2481
|
data.damageType,
|
|
2425
2482
|
data.weaponType
|
|
2426
2483
|
)
|
|
@@ -2449,7 +2506,7 @@ Unit.onDamage = __TS__New(
|
|
|
2449
2506
|
end
|
|
2450
2507
|
local data = {
|
|
2451
2508
|
amount = GetEventDamage(),
|
|
2452
|
-
attackType = BlzGetEventAttackType(),
|
|
2509
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2453
2510
|
damageType = BlzGetEventDamageType(),
|
|
2454
2511
|
weaponType = BlzGetEventWeaponType(),
|
|
2455
2512
|
isAttack = BlzGetEventIsAttack(),
|
|
@@ -2509,8 +2566,9 @@ Unit.itemDroppedEvent = __TS__New(
|
|
|
2509
2566
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2510
2567
|
function()
|
|
2511
2568
|
local unit = getTriggerUnit()
|
|
2512
|
-
|
|
2513
|
-
|
|
2569
|
+
local item = getManipulatedItem()
|
|
2570
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2571
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2514
2572
|
end
|
|
2515
2573
|
return IgnoreEvent
|
|
2516
2574
|
end
|
|
@@ -2520,8 +2578,9 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2520
2578
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2521
2579
|
function()
|
|
2522
2580
|
local unit = getTriggerUnit()
|
|
2523
|
-
|
|
2524
|
-
|
|
2581
|
+
local item = getManipulatedItem()
|
|
2582
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2583
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2525
2584
|
end
|
|
2526
2585
|
return IgnoreEvent
|
|
2527
2586
|
end
|
|
@@ -2529,7 +2588,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2529
2588
|
Unit.itemUsedEvent = __TS__New(
|
|
2530
2589
|
____exports.UnitTriggerEvent,
|
|
2531
2590
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2532
|
-
function()
|
|
2591
|
+
function()
|
|
2592
|
+
local unit = getTriggerUnit()
|
|
2593
|
+
local item = getManipulatedItem()
|
|
2594
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2595
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2596
|
+
end
|
|
2597
|
+
return IgnoreEvent
|
|
2598
|
+
end
|
|
2533
2599
|
)
|
|
2534
2600
|
Unit.itemStackedEvent = __TS__New(
|
|
2535
2601
|
____exports.UnitTriggerEvent,
|
|
@@ -2538,7 +2604,28 @@ Unit.itemStackedEvent = __TS__New(
|
|
|
2538
2604
|
)
|
|
2539
2605
|
__TS__ObjectDefineProperty(
|
|
2540
2606
|
Unit,
|
|
2541
|
-
"
|
|
2607
|
+
"itemUseOrderEvent",
|
|
2608
|
+
{get = function(self)
|
|
2609
|
+
local event = __TS__New(Event)
|
|
2610
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2611
|
+
local slot = order - orderId("useslot0")
|
|
2612
|
+
local function listener(unit)
|
|
2613
|
+
local item = unit.items[slot + 1]
|
|
2614
|
+
if item ~= nil then
|
|
2615
|
+
invoke(event, unit, item)
|
|
2616
|
+
end
|
|
2617
|
+
end
|
|
2618
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2619
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2620
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2621
|
+
end
|
|
2622
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2623
|
+
return event
|
|
2624
|
+
end}
|
|
2625
|
+
)
|
|
2626
|
+
__TS__ObjectDefineProperty(
|
|
2627
|
+
Unit,
|
|
2628
|
+
"itemMoveOrderEvent",
|
|
2542
2629
|
{get = function(self)
|
|
2543
2630
|
local event = __TS__New(Event)
|
|
2544
2631
|
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
@@ -2556,7 +2643,7 @@ __TS__ObjectDefineProperty(
|
|
|
2556
2643
|
end
|
|
2557
2644
|
end)
|
|
2558
2645
|
end
|
|
2559
|
-
rawset(self, "
|
|
2646
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2560
2647
|
return event
|
|
2561
2648
|
end}
|
|
2562
2649
|
)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
2
|
local getUnitAbility = BlzGetUnitAbility
|
|
3
3
|
local unitAddAbility = UnitAddAbility
|
|
4
|
+
local unitInventorySize = UnitInventorySize
|
|
5
|
+
local unitItemInSlot = UnitItemInSlot
|
|
4
6
|
local unitMakeAbilityPermanent = UnitMakeAbilityPermanent
|
|
5
7
|
---
|
|
6
8
|
-- @internal For use by internal systems only.
|
|
@@ -10,4 +12,14 @@ ____exports.addInternalAbility = function(unit, abilityTypeId)
|
|
|
10
12
|
end
|
|
11
13
|
return getUnitAbility(unit, abilityTypeId)
|
|
12
14
|
end
|
|
15
|
+
---
|
|
16
|
+
-- @internal For use by internal systems only.
|
|
17
|
+
____exports.findUnitItemSlot = function(unit, item)
|
|
18
|
+
for slot = 0, unitInventorySize(unit) - 1 do
|
|
19
|
+
if item == unitItemInSlot(unit, slot) then
|
|
20
|
+
return slot
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
return nil
|
|
24
|
+
end
|
|
13
25
|
return ____exports
|
package/engine/lightning.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { LightningTypeId } from "./object-data/entry/lightning-type";
|
|
3
|
-
import { Handle, HandleDestructor } from "../core/types/handle";
|
|
4
3
|
import { Unit } from "../core/types/unit";
|
|
4
|
+
import { AbstractDestroyable, Destructor } from "../destroyable";
|
|
5
5
|
declare const enum LightningPropertyKey {
|
|
6
6
|
CHECK_VISIBILITY = 100,
|
|
7
7
|
SOURCE_UNIT = 101,
|
|
@@ -12,10 +12,12 @@ declare const enum LightningPropertyKey {
|
|
|
12
12
|
TARGET_X = 106,
|
|
13
13
|
TARGET_Y = 107,
|
|
14
14
|
TARGET_Z = 108,
|
|
15
|
-
DURATION = 109
|
|
15
|
+
DURATION = 109,
|
|
16
|
+
FADING = 110
|
|
16
17
|
}
|
|
17
18
|
export type LightningConstructor<T extends Lightning> = typeof Lightning & (new (handle: jlightning, typeId: LightningTypeId) => T);
|
|
18
|
-
export declare class Lightning extends
|
|
19
|
+
export declare class Lightning extends AbstractDestroyable {
|
|
20
|
+
readonly handle: jlightning;
|
|
19
21
|
readonly typeId: LightningTypeId;
|
|
20
22
|
private [LightningPropertyKey.CHECK_VISIBILITY]?;
|
|
21
23
|
private [LightningPropertyKey.SOURCE_UNIT]?;
|
|
@@ -27,8 +29,9 @@ export declare class Lightning extends Handle<jlightning> {
|
|
|
27
29
|
private [LightningPropertyKey.TARGET_Y]?;
|
|
28
30
|
private [LightningPropertyKey.TARGET_Z]?;
|
|
29
31
|
private [LightningPropertyKey.DURATION]?;
|
|
32
|
+
private [LightningPropertyKey.FADING]?;
|
|
30
33
|
constructor(handle: jlightning, typeId: LightningTypeId);
|
|
31
|
-
protected onDestroy():
|
|
34
|
+
protected onDestroy(): Destructor;
|
|
32
35
|
static create<T extends Lightning>(this: LightningConstructor<T>, typeId: LightningTypeId, ...parameters: [
|
|
33
36
|
...checkVisibility: [boolean] | [],
|
|
34
37
|
...sourceAndTarget: [sourceX: number, sourceY: number, targetX: number, targetY: number] | [
|
|
@@ -46,6 +49,10 @@ export declare class Lightning extends Handle<jlightning> {
|
|
|
46
49
|
target: Unit
|
|
47
50
|
]
|
|
48
51
|
]): T;
|
|
49
|
-
static flash(...parameters: [
|
|
52
|
+
static flash(...parameters: [
|
|
53
|
+
...parameters: Parameters<(typeof Lightning)["create"]>,
|
|
54
|
+
duration: number,
|
|
55
|
+
fading?: boolean
|
|
56
|
+
]): void;
|
|
50
57
|
}
|
|
51
58
|
export {};
|