warscript 0.0.1-dev.d63794c → 0.0.1-dev.d690591
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 +1 -3
- package/core/types/effect.lua +26 -29
- 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 +11 -5
- package/engine/behaviour/ability/on-command-impact.lua +7 -0
- package/engine/behaviour/ability.d.ts +12 -3
- package/engine/behaviour/ability.lua +66 -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.lua +17 -24
- package/engine/internal/item/ability.lua +77 -3
- 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/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-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 +3 -4
- 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.d.ts +17 -2
- package/engine/internal/unit.lua +121 -43
- 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,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,
|
|
@@ -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,11 +41,13 @@ 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;
|
|
47
|
+
metadata: unknown;
|
|
44
48
|
readonly isAttack: boolean;
|
|
45
49
|
readonly originalAmount: number;
|
|
50
|
+
readonly originalMetadata: unknown;
|
|
46
51
|
}
|
|
47
52
|
export type DamageEvent = DamagingEvent & {
|
|
48
53
|
preventDeath<P extends any[]>(this: DamageEvent, callback: (this: void, ...parameters: P) => any, ...parameters: P): void;
|
|
@@ -100,7 +105,9 @@ declare const enum UnitPropertyKey {
|
|
|
100
105
|
DELAY_HEALTH_CHECKS_COUNTER = 103,
|
|
101
106
|
DELAY_HEALTH_CHECKS_HEALTH_BONUS = 104,
|
|
102
107
|
PREVENT_DEATH_HEALTH_BONUS = 105,
|
|
103
|
-
IS_TEAM_GLOW_HIDDEN = 106
|
|
108
|
+
IS_TEAM_GLOW_HIDDEN = 106,
|
|
109
|
+
LAST_X = 107,
|
|
110
|
+
LAST_Y = 108
|
|
104
111
|
}
|
|
105
112
|
export type UnitSyncId = number & {
|
|
106
113
|
readonly __unitSyncId: unique symbol;
|
|
@@ -113,6 +120,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
113
120
|
private [UnitPropertyKey.DELAY_HEALTH_CHECKS_HEALTH_BONUS]?;
|
|
114
121
|
private [UnitPropertyKey.PREVENT_DEATH_HEALTH_BONUS]?;
|
|
115
122
|
private [UnitPropertyKey.IS_TEAM_GLOW_HIDDEN]?;
|
|
123
|
+
private [UnitPropertyKey.LAST_X]?;
|
|
124
|
+
private [UnitPropertyKey.LAST_Y]?;
|
|
116
125
|
private _owner?;
|
|
117
126
|
private _timeScale?;
|
|
118
127
|
private events?;
|
|
@@ -133,6 +142,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
133
142
|
get isAlive(): boolean;
|
|
134
143
|
get isDead(): boolean;
|
|
135
144
|
get isIllusion(): boolean;
|
|
145
|
+
get isStunned(): boolean;
|
|
136
146
|
get combatClassifications(): CombatClassifications;
|
|
137
147
|
set combatClassifications(combatClassifications: CombatClassifications);
|
|
138
148
|
hasCombatClassification(combatClassification: CombatClassification): boolean;
|
|
@@ -147,6 +157,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
147
157
|
isEnemyOf(unit: Unit): boolean;
|
|
148
158
|
playAnimation(animation: string, rarity?: jraritycontrol): void;
|
|
149
159
|
playAnimation(animation: number): void;
|
|
160
|
+
resetAnimation(): void;
|
|
150
161
|
queueAnimation(animation: string): void;
|
|
151
162
|
get weapons(): [UnitWeapon, UnitWeapon];
|
|
152
163
|
get firstWeapon(): UnitWeapon;
|
|
@@ -155,6 +166,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
155
166
|
set level(v: number);
|
|
156
167
|
get xp(): number;
|
|
157
168
|
set xp(v: number);
|
|
169
|
+
get primaryAttribute(): UnitAttribute;
|
|
170
|
+
set primaryAttribute(primaryAttribute: UnitAttribute);
|
|
158
171
|
get strengthBase(): number;
|
|
159
172
|
set strengthBase(strengthBase: number);
|
|
160
173
|
get strengthBonus(): number;
|
|
@@ -229,6 +242,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
229
242
|
set timeScale(v: number);
|
|
230
243
|
get collisionSize(): number;
|
|
231
244
|
get pathingCollisionRange(): number;
|
|
245
|
+
get movementType(): MovementType;
|
|
246
|
+
set movementType(movementType: MovementType);
|
|
232
247
|
set pathing(v: boolean);
|
|
233
248
|
isSelected(player: Player): boolean;
|
|
234
249
|
explode(): void;
|
package/engine/internal/unit.lua
CHANGED
|
@@ -51,11 +51,19 @@ 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
|
|
59
|
+
local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
|
|
60
|
+
local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
|
|
54
61
|
local match = string.match
|
|
55
62
|
local ____tostring = _G.tostring
|
|
56
63
|
local setUnitAnimation = SetUnitAnimation
|
|
57
64
|
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
58
65
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
66
|
+
local resetUnitAnimation = ResetUnitAnimation
|
|
59
67
|
local queueUnitAnimation = QueueUnitAnimation
|
|
60
68
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
61
69
|
local getUnitRealField = BlzGetUnitRealField
|
|
@@ -75,9 +83,9 @@ local setUnitScale = SetUnitScale
|
|
|
75
83
|
local setUnitPosition = SetUnitPosition
|
|
76
84
|
local setUnitTimeScale = SetUnitTimeScale
|
|
77
85
|
local getHandleId = GetHandleId
|
|
86
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
78
87
|
local createUnit = CreateUnit
|
|
79
88
|
local killUnit = KillUnit
|
|
80
|
-
local setUnitExploded = SetUnitExploded
|
|
81
89
|
local removeUnit = RemoveUnit
|
|
82
90
|
local getUnitTypeId = GetUnitTypeId
|
|
83
91
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -93,8 +101,6 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
93
101
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
94
102
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
95
103
|
local isUnitInRange = IsUnitInRange
|
|
96
|
-
local setResourceAmount = SetResourceAmount
|
|
97
|
-
local getResourceAmount = GetResourceAmount
|
|
98
104
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
99
105
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
100
106
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
@@ -125,8 +131,6 @@ local isUnitType = IsUnitType
|
|
|
125
131
|
local isUnitAlly = IsUnitAlly
|
|
126
132
|
local isUnitEnemy = IsUnitEnemy
|
|
127
133
|
local getOwningPlayer = GetOwningPlayer
|
|
128
|
-
local setUnitColor = SetUnitColor
|
|
129
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
130
134
|
____exports.UnitClassification = {}
|
|
131
135
|
local UnitClassification = ____exports.UnitClassification
|
|
132
136
|
do
|
|
@@ -354,7 +358,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
354
358
|
rawset(self, 1 + i, (select(i, ...)))
|
|
355
359
|
end
|
|
356
360
|
end
|
|
357
|
-
local damageSetters = {
|
|
361
|
+
local damageSetters = {
|
|
362
|
+
amount = BlzSetEventDamage,
|
|
363
|
+
attackType = function(attackType)
|
|
364
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
365
|
+
end,
|
|
366
|
+
damageType = BlzSetEventDamageType,
|
|
367
|
+
weaponType = BlzSetEventWeaponType
|
|
368
|
+
}
|
|
358
369
|
local jlimitopByOperator = {
|
|
359
370
|
[0] = LESS_THAN_OR_EQUAL,
|
|
360
371
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -636,7 +647,8 @@ local function delayHealthChecksCallback(unit)
|
|
|
636
647
|
end
|
|
637
648
|
end
|
|
638
649
|
local nextSyncId = 1
|
|
639
|
-
local unitBySyncId = setmetatable({}, {__mode = "
|
|
650
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
651
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
640
652
|
____exports.Unit = __TS__Class()
|
|
641
653
|
local Unit = ____exports.Unit
|
|
642
654
|
Unit.name = "Unit"
|
|
@@ -677,6 +689,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
677
689
|
end
|
|
678
690
|
function Unit.prototype.onDestroy(self)
|
|
679
691
|
local handle = self.handle
|
|
692
|
+
self[107] = getUnitX(handle)
|
|
693
|
+
self[108] = getUnitY(handle)
|
|
680
694
|
if not self._owner then
|
|
681
695
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
682
696
|
end
|
|
@@ -792,6 +806,9 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
792
806
|
setUnitAnimation(self.handle, animation)
|
|
793
807
|
end
|
|
794
808
|
end
|
|
809
|
+
function Unit.prototype.resetAnimation(self)
|
|
810
|
+
resetUnitAnimation(self.handle)
|
|
811
|
+
end
|
|
795
812
|
function Unit.prototype.queueAnimation(self, animation)
|
|
796
813
|
queueUnitAnimation(self.handle, animation)
|
|
797
814
|
end
|
|
@@ -806,7 +823,7 @@ function Unit.prototype.isSelected(self, player)
|
|
|
806
823
|
return IsUnitSelected(self.handle, player.handle)
|
|
807
824
|
end
|
|
808
825
|
function Unit.prototype.explode(self)
|
|
809
|
-
|
|
826
|
+
SetUnitExploded(self.handle, true)
|
|
810
827
|
killUnit(self.handle)
|
|
811
828
|
end
|
|
812
829
|
function Unit.prototype.kill(self)
|
|
@@ -929,8 +946,15 @@ function Unit.prototype.interruptAttack(self)
|
|
|
929
946
|
unitInterruptAttack(self.handle)
|
|
930
947
|
end
|
|
931
948
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
932
|
-
|
|
933
|
-
unitDisableAbility(
|
|
949
|
+
local handle = self.handle
|
|
950
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
951
|
+
Timer:run(
|
|
952
|
+
unitDisableAbility,
|
|
953
|
+
handle,
|
|
954
|
+
abilityId,
|
|
955
|
+
false,
|
|
956
|
+
false
|
|
957
|
+
)
|
|
934
958
|
end
|
|
935
959
|
function Unit.prototype.getDistanceTo(self, target)
|
|
936
960
|
local handle = self.handle
|
|
@@ -1195,6 +1219,14 @@ __TS__SetDescriptor(
|
|
|
1195
1219
|
end},
|
|
1196
1220
|
true
|
|
1197
1221
|
)
|
|
1222
|
+
__TS__SetDescriptor(
|
|
1223
|
+
Unit.prototype,
|
|
1224
|
+
"isStunned",
|
|
1225
|
+
{get = function(self)
|
|
1226
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1227
|
+
end},
|
|
1228
|
+
true
|
|
1229
|
+
)
|
|
1198
1230
|
__TS__SetDescriptor(
|
|
1199
1231
|
Unit.prototype,
|
|
1200
1232
|
"combatClassifications",
|
|
@@ -1268,6 +1300,19 @@ __TS__SetDescriptor(
|
|
|
1268
1300
|
},
|
|
1269
1301
|
true
|
|
1270
1302
|
)
|
|
1303
|
+
__TS__SetDescriptor(
|
|
1304
|
+
Unit.prototype,
|
|
1305
|
+
"primaryAttribute",
|
|
1306
|
+
{
|
|
1307
|
+
get = function(self)
|
|
1308
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1309
|
+
end,
|
|
1310
|
+
set = function(self, primaryAttribute)
|
|
1311
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1312
|
+
end
|
|
1313
|
+
},
|
|
1314
|
+
true
|
|
1315
|
+
)
|
|
1271
1316
|
__TS__SetDescriptor(
|
|
1272
1317
|
Unit.prototype,
|
|
1273
1318
|
"strengthBase",
|
|
@@ -1392,7 +1437,7 @@ __TS__SetDescriptor(
|
|
|
1392
1437
|
return not self[106]
|
|
1393
1438
|
end,
|
|
1394
1439
|
set = function(self, isTeamGlowVisible)
|
|
1395
|
-
|
|
1440
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1396
1441
|
local ____temp_6
|
|
1397
1442
|
if not isTeamGlowVisible then
|
|
1398
1443
|
____temp_6 = true
|
|
@@ -1408,9 +1453,9 @@ __TS__SetDescriptor(
|
|
|
1408
1453
|
Unit.prototype,
|
|
1409
1454
|
"color",
|
|
1410
1455
|
{set = function(self, color)
|
|
1411
|
-
|
|
1456
|
+
SetUnitColor(self.handle, color.handle)
|
|
1412
1457
|
if self[106] then
|
|
1413
|
-
|
|
1458
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1414
1459
|
end
|
|
1415
1460
|
end},
|
|
1416
1461
|
true
|
|
@@ -1579,7 +1624,7 @@ __TS__SetDescriptor(
|
|
|
1579
1624
|
"x",
|
|
1580
1625
|
{
|
|
1581
1626
|
get = function(self)
|
|
1582
|
-
return getUnitX(self.handle)
|
|
1627
|
+
return self[107] or getUnitX(self.handle)
|
|
1583
1628
|
end,
|
|
1584
1629
|
set = function(self, v)
|
|
1585
1630
|
SetUnitX(self.handle, v)
|
|
@@ -1592,7 +1637,7 @@ __TS__SetDescriptor(
|
|
|
1592
1637
|
"y",
|
|
1593
1638
|
{
|
|
1594
1639
|
get = function(self)
|
|
1595
|
-
return getUnitY(self.handle)
|
|
1640
|
+
return self[108] or getUnitY(self.handle)
|
|
1596
1641
|
end,
|
|
1597
1642
|
set = function(self, v)
|
|
1598
1643
|
SetUnitY(self.handle, v)
|
|
@@ -1678,10 +1723,10 @@ __TS__SetDescriptor(
|
|
|
1678
1723
|
"gold",
|
|
1679
1724
|
{
|
|
1680
1725
|
get = function(self)
|
|
1681
|
-
return
|
|
1726
|
+
return GetResourceAmount(self.handle)
|
|
1682
1727
|
end,
|
|
1683
1728
|
set = function(self, gold)
|
|
1684
|
-
|
|
1729
|
+
SetResourceAmount(self.handle, gold)
|
|
1685
1730
|
end
|
|
1686
1731
|
},
|
|
1687
1732
|
true
|
|
@@ -1809,6 +1854,19 @@ __TS__SetDescriptor(
|
|
|
1809
1854
|
end},
|
|
1810
1855
|
true
|
|
1811
1856
|
)
|
|
1857
|
+
__TS__SetDescriptor(
|
|
1858
|
+
Unit.prototype,
|
|
1859
|
+
"movementType",
|
|
1860
|
+
{
|
|
1861
|
+
get = function(self)
|
|
1862
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1863
|
+
end,
|
|
1864
|
+
set = function(self, movementType)
|
|
1865
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1866
|
+
end
|
|
1867
|
+
},
|
|
1868
|
+
true
|
|
1869
|
+
)
|
|
1812
1870
|
__TS__SetDescriptor(
|
|
1813
1871
|
Unit.prototype,
|
|
1814
1872
|
"pathing",
|
|
@@ -2315,10 +2373,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2315
2373
|
____exports.UnitTriggerEvent,
|
|
2316
2374
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2317
2375
|
function()
|
|
2318
|
-
local
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2376
|
+
local handle = getOrderedUnit()
|
|
2377
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2378
|
+
local unit = ____exports.Unit:of(handle)
|
|
2379
|
+
if unit.state == 1 then
|
|
2380
|
+
return unit, getIssuedOrderId()
|
|
2381
|
+
end
|
|
2322
2382
|
end
|
|
2323
2383
|
return IgnoreEvent
|
|
2324
2384
|
end
|
|
@@ -2349,13 +2409,18 @@ Unit.onDamaging = (function()
|
|
|
2349
2409
|
if source and source.typeId == dummyUnitId then
|
|
2350
2410
|
source = nil
|
|
2351
2411
|
end
|
|
2352
|
-
local target = BlzGetEventDamageTarget()
|
|
2412
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2413
|
+
local metadata = damageMetadataByTarget[target]
|
|
2414
|
+
damageMetadataByTarget[target] = nil
|
|
2353
2415
|
local data = {
|
|
2354
2416
|
amount = GetEventDamage(),
|
|
2355
|
-
attackType = BlzGetEventAttackType(),
|
|
2417
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2356
2418
|
damageType = BlzGetEventDamageType(),
|
|
2357
2419
|
weaponType = BlzGetEventWeaponType(),
|
|
2358
|
-
|
|
2420
|
+
metadata = metadata,
|
|
2421
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2422
|
+
originalAmount = GetEventDamage(),
|
|
2423
|
+
originalMetadata = metadata
|
|
2359
2424
|
}
|
|
2360
2425
|
if data.isAttack and source then
|
|
2361
2426
|
local weapon = BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 1) and (BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 0) and -1 or 1) or 0
|
|
@@ -2369,18 +2434,22 @@ Unit.onDamaging = (function()
|
|
|
2369
2434
|
invoke(
|
|
2370
2435
|
event,
|
|
2371
2436
|
source,
|
|
2372
|
-
|
|
2437
|
+
target,
|
|
2373
2438
|
setmetatable(
|
|
2374
2439
|
{},
|
|
2375
2440
|
{
|
|
2376
2441
|
__index = data,
|
|
2377
2442
|
__newindex = function(self, key, value)
|
|
2378
|
-
damageSetters[key]
|
|
2443
|
+
local damageSetter = damageSetters[key]
|
|
2444
|
+
if damageSetter ~= nil then
|
|
2445
|
+
damageSetter(value)
|
|
2446
|
+
end
|
|
2379
2447
|
data[key] = value
|
|
2380
2448
|
end
|
|
2381
2449
|
}
|
|
2382
2450
|
)
|
|
2383
2451
|
)
|
|
2452
|
+
damagingEventByTarget[target] = data
|
|
2384
2453
|
return
|
|
2385
2454
|
end
|
|
2386
2455
|
BlzSetEventDamage(0)
|
|
@@ -2388,7 +2457,7 @@ Unit.onDamaging = (function()
|
|
|
2388
2457
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2389
2458
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2390
2459
|
local sourceOwner = source.owner.handle
|
|
2391
|
-
local targetOwner =
|
|
2460
|
+
local targetOwner = target.owner.handle
|
|
2392
2461
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2393
2462
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2394
2463
|
Timer:run(function()
|
|
@@ -2404,23 +2473,19 @@ Unit.onDamaging = (function()
|
|
|
2404
2473
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2405
2474
|
local condition = ____value[1]
|
|
2406
2475
|
local action = ____value[2]
|
|
2407
|
-
if condition(
|
|
2408
|
-
source,
|
|
2409
|
-
____exports.Unit:of(target),
|
|
2410
|
-
data
|
|
2411
|
-
) then
|
|
2476
|
+
if condition(source, target, data) then
|
|
2412
2477
|
action(
|
|
2413
2478
|
source,
|
|
2414
|
-
|
|
2479
|
+
target,
|
|
2415
2480
|
setmetatable(
|
|
2416
2481
|
{fire = function()
|
|
2417
2482
|
UnitDamageTarget(
|
|
2418
2483
|
source.handle,
|
|
2419
|
-
target,
|
|
2484
|
+
target.handle,
|
|
2420
2485
|
data.amount,
|
|
2421
2486
|
true,
|
|
2422
2487
|
true,
|
|
2423
|
-
data.attackType,
|
|
2488
|
+
attackTypeToNative(data.attackType),
|
|
2424
2489
|
data.damageType,
|
|
2425
2490
|
data.weaponType
|
|
2426
2491
|
)
|
|
@@ -2447,13 +2512,18 @@ Unit.onDamage = __TS__New(
|
|
|
2447
2512
|
if source and source.typeId == dummyUnitId then
|
|
2448
2513
|
source = nil
|
|
2449
2514
|
end
|
|
2515
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2516
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2517
|
+
damagingEventByTarget[target] = nil
|
|
2450
2518
|
local data = {
|
|
2451
2519
|
amount = GetEventDamage(),
|
|
2452
|
-
attackType = BlzGetEventAttackType(),
|
|
2520
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2453
2521
|
damageType = BlzGetEventDamageType(),
|
|
2454
2522
|
weaponType = BlzGetEventWeaponType(),
|
|
2523
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2455
2524
|
isAttack = BlzGetEventIsAttack(),
|
|
2456
|
-
originalAmount = GetEventDamage(),
|
|
2525
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2526
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2457
2527
|
preventDeath = damageEventPreventDeath
|
|
2458
2528
|
}
|
|
2459
2529
|
local evData = setmetatable(
|
|
@@ -2466,7 +2536,6 @@ Unit.onDamage = __TS__New(
|
|
|
2466
2536
|
end
|
|
2467
2537
|
}
|
|
2468
2538
|
)
|
|
2469
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2470
2539
|
invoke(event, source, target, evData)
|
|
2471
2540
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2472
2541
|
local bonusHealth = math.ceil(evData.amount)
|
|
@@ -2509,8 +2578,9 @@ Unit.itemDroppedEvent = __TS__New(
|
|
|
2509
2578
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2510
2579
|
function()
|
|
2511
2580
|
local unit = getTriggerUnit()
|
|
2512
|
-
|
|
2513
|
-
|
|
2581
|
+
local item = getManipulatedItem()
|
|
2582
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2583
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2514
2584
|
end
|
|
2515
2585
|
return IgnoreEvent
|
|
2516
2586
|
end
|
|
@@ -2520,8 +2590,9 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2520
2590
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2521
2591
|
function()
|
|
2522
2592
|
local unit = getTriggerUnit()
|
|
2523
|
-
|
|
2524
|
-
|
|
2593
|
+
local item = getManipulatedItem()
|
|
2594
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2595
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2525
2596
|
end
|
|
2526
2597
|
return IgnoreEvent
|
|
2527
2598
|
end
|
|
@@ -2529,7 +2600,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2529
2600
|
Unit.itemUsedEvent = __TS__New(
|
|
2530
2601
|
____exports.UnitTriggerEvent,
|
|
2531
2602
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2532
|
-
function()
|
|
2603
|
+
function()
|
|
2604
|
+
local unit = getTriggerUnit()
|
|
2605
|
+
local item = getManipulatedItem()
|
|
2606
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2607
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2608
|
+
end
|
|
2609
|
+
return IgnoreEvent
|
|
2610
|
+
end
|
|
2533
2611
|
)
|
|
2534
2612
|
Unit.itemStackedEvent = __TS__New(
|
|
2535
2613
|
____exports.UnitTriggerEvent,
|
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 {};
|