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