warscript 0.0.1-dev.7278154 → 0.0.1-dev.73fbafc

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.
Files changed (45) hide show
  1. package/attributes.d.ts +1 -0
  2. package/attributes.lua +9 -0
  3. package/core/types/frame.lua +14 -9
  4. package/core/types/playerCamera.lua +44 -0
  5. package/core/types/tileCell.d.ts +9 -0
  6. package/core/types/tileCell.lua +92 -0
  7. package/core/types/timer.d.ts +3 -2
  8. package/core/types/timer.lua +8 -2
  9. package/decl/native.d.ts +2 -2
  10. package/engine/behavior.d.ts +1 -0
  11. package/engine/behavior.lua +9 -0
  12. package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
  13. package/engine/behaviour/ability/remove-buffs.lua +21 -0
  14. package/engine/behaviour/unit/stun-immunity.d.ts +2 -0
  15. package/engine/behaviour/unit/stun-immunity.lua +11 -2
  16. package/engine/behaviour/unit.d.ts +2 -0
  17. package/engine/behaviour/unit.lua +5 -0
  18. package/engine/internal/ability.lua +6 -5
  19. package/engine/internal/item.d.ts +13 -15
  20. package/engine/internal/item.lua +59 -48
  21. package/engine/internal/unit/ability.d.ts +14 -14
  22. package/engine/internal/unit/ability.lua +72 -45
  23. package/engine/internal/unit/main-selected.lua +12 -27
  24. package/engine/internal/unit-missile-launch.lua +42 -21
  25. package/engine/internal/unit.d.ts +4 -2
  26. package/engine/internal/unit.lua +26 -15
  27. package/engine/object-data/entry/ability-type.lua +4 -1
  28. package/engine/random.d.ts +9 -0
  29. package/engine/random.lua +13 -0
  30. package/engine/synchronization.d.ts +11 -0
  31. package/engine/synchronization.lua +77 -0
  32. package/engine/text-tag.lua +1 -1
  33. package/net/socket.lua +1 -1
  34. package/objutil/buff.lua +1 -1
  35. package/package.json +2 -2
  36. package/patch-lualib.lua +1 -1
  37. package/utility/arrays.d.ts +1 -0
  38. package/utility/arrays.lua +8 -0
  39. package/utility/callback-array.d.ts +5 -1
  40. package/utility/callback-array.lua +16 -1
  41. package/utility/linked-set.d.ts +1 -0
  42. package/utility/linked-set.lua +19 -1
  43. package/utility/lua-maps.d.ts +11 -2
  44. package/utility/lua-maps.lua +33 -2
  45. package/utility/types.d.ts +3 -0
package/attributes.d.ts CHANGED
@@ -13,5 +13,6 @@ export declare namespace Attribute {
13
13
  export declare class AttributesHolder {
14
14
  readonly get: (<T>(attribute: Attribute<T>) => T | undefined) & LuaExtension<"TableGetMethod">;
15
15
  readonly set: (<T>(attribute: Attribute<T>, value: T | undefined) => void) & LuaExtension<"TableSetMethod">;
16
+ getOrPut<T>(attribute: Attribute<T>, defaultValue: () => T): T;
16
17
  }
17
18
  export {};
package/attributes.lua CHANGED
@@ -20,4 +20,13 @@ local AttributesHolder = ____exports.AttributesHolder
20
20
  AttributesHolder.name = "AttributesHolder"
21
21
  function AttributesHolder.prototype.____constructor(self)
22
22
  end
23
+ function AttributesHolder.prototype.getOrPut(self, attribute, defaultValue)
24
+ local value = self[attribute]
25
+ if value ~= nil then
26
+ return value
27
+ end
28
+ value = defaultValue()
29
+ self[attribute] = value
30
+ return value
31
+ end
23
32
  return ____exports
@@ -19,13 +19,16 @@ local ____frame_2Dcoordinates = require("engine.internal.misc.frame-coordinates"
19
19
  local FRAME_MAX_Y = ____frame_2Dcoordinates.FRAME_MAX_Y
20
20
  local FRAME_MIN_Y = ____frame_2Dcoordinates.FRAME_MIN_Y
21
21
  local getFrameMinXMaxX = ____frame_2Dcoordinates.getFrameMinXMaxX
22
+ local ____playerCamera = require("core.types.playerCamera")
23
+ local frameCoordinatesToWorld = ____playerCamera.frameCoordinatesToWorld
24
+ local worldCoordinatesToFrame = ____playerCamera.worldCoordinatesToFrame
25
+ local ____get_2Dterrain_2Dz = require("engine.internal.misc.get-terrain-z")
26
+ local getTerrainZ = ____get_2Dterrain_2Dz.getTerrainZ
22
27
  local frameClick = BlzFrameClick
23
28
  local frameGetEnable = BlzFrameGetEnable
24
29
  local frameIsVisible = BlzFrameIsVisible
25
30
  local frameSetEnable = BlzFrameSetEnable
26
31
  local frameSetScale = BlzFrameSetScale
27
- local getCameraTargetPositionX = GetCameraTargetPositionX
28
- local getCameraTargetPositionY = GetCameraTargetPositionY
29
32
  local ____rawget = _G.rawget
30
33
  local rawset = _G.rawset
31
34
  local invoke = Event.invoke
@@ -936,16 +939,19 @@ __TS__ObjectDefineProperty(
936
939
  local event = __TS__New(Event)
937
940
  local syncX = 0
938
941
  local syncY = 0
939
- local syncCamX = getCameraTargetPositionX()
940
- local syncCamY = getCameraTargetPositionY()
942
+ local syncFrameX = 0
943
+ local syncFrameY = 0
941
944
  local lastX = syncX
942
945
  local lastY = syncY
943
946
  self.onMouseMove:addListener(function(player, x, y)
944
947
  if player.isLocal then
945
948
  syncX = x
946
949
  syncY = y
947
- syncCamX = getCameraTargetPositionX()
948
- syncCamY = getCameraTargetPositionY()
950
+ syncFrameX, syncFrameY = worldCoordinatesToFrame(
951
+ x,
952
+ y,
953
+ getTerrainZ(x, y)
954
+ )
949
955
  lastX = x
950
956
  lastY = y
951
957
  invoke(event, x, y)
@@ -955,9 +961,8 @@ __TS__ObjectDefineProperty(
955
961
  if syncX == 0 and syncY == 0 then
956
962
  return
957
963
  end
958
- local x = syncX + (getCameraTargetPositionX() - syncCamX)
959
- local y = syncY + (getCameraTargetPositionY() - syncCamY)
960
- if x ~= lastX or y ~= lastY then
964
+ local x, y, ____, isDefinite = frameCoordinatesToWorld(syncFrameX, syncFrameY)
965
+ if isDefinite and (x ~= lastX or y ~= lastY) then
961
966
  lastX = x
962
967
  lastY = y
963
968
  invoke(event, x, y)
@@ -13,6 +13,8 @@ local ____frame_2Dcoordinates = require("engine.internal.misc.frame-coordinates"
13
13
  local FRAME_MAX_Y = ____frame_2Dcoordinates.FRAME_MAX_Y
14
14
  local FRAME_MIN_Y = ____frame_2Dcoordinates.FRAME_MIN_Y
15
15
  local getFrameMinXMaxX = ____frame_2Dcoordinates.getFrameMinXMaxX
16
+ local ____get_2Dterrain_2Dz = require("engine.internal.misc.get-terrain-z")
17
+ local getTerrainZ = ____get_2Dterrain_2Dz.getTerrainZ
16
18
  local getHandleId = GetHandleId
17
19
  local setCameraField = SetCameraField
18
20
  local getCameraField = GetCameraField
@@ -26,6 +28,7 @@ local resetToGameCamera = ResetToGameCamera
26
28
  local cos = math.cos
27
29
  local deg = math.deg
28
30
  local sin = math.sin
31
+ local sqrt = math.sqrt
29
32
  local memoized = {}
30
33
  ____exports.PlayerCamera = __TS__Class()
31
34
  local PlayerCamera = ____exports.PlayerCamera
@@ -233,4 +236,45 @@ ____exports.worldCoordinatesToFrame = function(x, y, z)
233
236
  local frameY = 0.42625 - yCenterScreenShift + (cameraAngleOfAttackSinRotationCos * dx + cameraAngleOfAttackSinRotationSin * dy - cameraAngleOfAttackCos * dz) / xPrime
234
237
  return frameX, frameY, xPrime < 0 and frameX >= frameMinX and frameX <= frameMaxX and frameY >= FRAME_MIN_Y and frameY <= FRAME_MAX_Y
235
238
  end
239
+ ---
240
+ -- @internal For use by internal systems only.
241
+ ____exports.frameCoordinatesToWorld = function(x, y)
242
+ if not isCameraViewPrecalculated then
243
+ precalculateCameraView()
244
+ end
245
+ local a = (x - 0.4) * scaleFactor
246
+ local b = (0.42625 - yCenterScreenShift - y) * scaleFactor
247
+ local nx = 1 / sqrt(1 + a * a + b * b)
248
+ local ny = sqrt(1 - (1 + b * b) * nx * nx)
249
+ local nz = sqrt(1 - nx * nx - ny * ny)
250
+ if a > 0 then
251
+ ny = -ny
252
+ end
253
+ if b < 0 then
254
+ nz = -nz
255
+ end
256
+ local nxPrime = cameraAngleOfAttackCosRotationCos * nx - cameraRotationSin * ny + cameraAngleOfAttackSinRotationCos * nz
257
+ local nyPrime = cameraAngleOfAttackCosRotationSin * nx + cameraRotationCos * ny + cameraAngleOfAttackSinRotationSin * nz
258
+ local nzPrime = -cameraAngleOfAttackSin * nx + cameraAngleOfAttackCos * nz
259
+ local zGuess = getTerrainZ(cameraEyeX, cameraEyeY)
260
+ local xGuess = cameraEyeX + nxPrime * (cameraEyeZ - zGuess) / nzPrime
261
+ local yGuess = cameraEyeY + nyPrime * (cameraEyeZ - zGuess) / nzPrime
262
+ local zWorld = getTerrainZ(xGuess, yGuess)
263
+ local deltaZ = zWorld - zGuess
264
+ zGuess = zWorld
265
+ local zWorldOld = zWorld
266
+ local deltaZOld = deltaZ
267
+ local i = 0
268
+ while (deltaZ > 1 or deltaZ < -1) and i < 50 do
269
+ xGuess = cameraEyeX + nxPrime * (cameraEyeZ - zGuess) / nzPrime
270
+ yGuess = cameraEyeY + nyPrime * (cameraEyeZ - zGuess) / nzPrime
271
+ zWorld = getTerrainZ(xGuess, yGuess)
272
+ deltaZ = zWorld - zGuess
273
+ zGuess = (deltaZOld * zWorld - deltaZ * zWorldOld) / (deltaZOld - deltaZ)
274
+ zWorldOld = zWorld
275
+ deltaZOld = deltaZ
276
+ i = i + 1
277
+ end
278
+ return xGuess, yGuess, zWorld, i < 50
279
+ end
236
280
  return ____exports
@@ -5,6 +5,15 @@ export declare class TileCell implements Readonly<Vec2> {
5
5
  readonly y: number;
6
6
  readonly z: undefined;
7
7
  protected constructor(id: number, x: number, y: number, z: undefined);
8
+ get up(): TileCell;
9
+ get down(): TileCell;
10
+ get left(): TileCell;
11
+ get right(): TileCell;
12
+ get terrainTypeId(): number;
13
+ set terrainTypeId(terrainTypeId: number);
14
+ get terrainVariance(): number;
15
+ set terrainVariance(terrainVariance: number);
16
+ randomizeTerrainVariance(): void;
8
17
  isInRangeOf(x: number, y: number, range: number): boolean;
9
18
  isInRangeOf(tileCell: TileCell, range: number): boolean;
10
19
  static getInRect(minX: number, minY: number, maxX: number, maxY: number): TileCell[];
@@ -1,7 +1,11 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
3
  local __TS__New = ____lualib.__TS__New
4
+ local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
4
5
  local ____exports = {}
6
+ local getTerrainType = GetTerrainType
7
+ local setTerrainType = SetTerrainType
8
+ local getTerrainVariance = GetTerrainVariance
5
9
  local abs = math.abs
6
10
  local ____type = math.type
7
11
  local ult = math.ult
@@ -16,6 +20,18 @@ function TileCell.prototype.____constructor(self, id, x, y, z)
16
20
  self.z = z
17
21
  tileCellById[id] = self
18
22
  end
23
+ function TileCell.prototype.randomizeTerrainVariance(self)
24
+ local x = self.x
25
+ local y = self.y
26
+ setTerrainType(
27
+ x,
28
+ y,
29
+ getTerrainType(x, y),
30
+ -1,
31
+ 1,
32
+ 1
33
+ )
34
+ end
19
35
  function TileCell.prototype.isInRangeOf(self, x, y, range)
20
36
  if range == nil then
21
37
  range = y
@@ -97,4 +113,80 @@ function TileCell.of(x, y)
97
113
  nil
98
114
  )
99
115
  end
116
+ __TS__SetDescriptor(
117
+ TileCell.prototype,
118
+ "up",
119
+ {get = function(self)
120
+ return ____exports.TileCell.of(self.x, self.y + 128)
121
+ end},
122
+ true
123
+ )
124
+ __TS__SetDescriptor(
125
+ TileCell.prototype,
126
+ "down",
127
+ {get = function(self)
128
+ return ____exports.TileCell.of(self.x, self.y - 128)
129
+ end},
130
+ true
131
+ )
132
+ __TS__SetDescriptor(
133
+ TileCell.prototype,
134
+ "left",
135
+ {get = function(self)
136
+ return ____exports.TileCell.of(self.x - 128, self.y)
137
+ end},
138
+ true
139
+ )
140
+ __TS__SetDescriptor(
141
+ TileCell.prototype,
142
+ "right",
143
+ {get = function(self)
144
+ return ____exports.TileCell.of(self.x + 128, self.y)
145
+ end},
146
+ true
147
+ )
148
+ __TS__SetDescriptor(
149
+ TileCell.prototype,
150
+ "terrainTypeId",
151
+ {
152
+ get = function(self)
153
+ return getTerrainType(self.x, self.y)
154
+ end,
155
+ set = function(self, terrainTypeId)
156
+ local x = self.x
157
+ local y = self.y
158
+ setTerrainType(
159
+ x,
160
+ y,
161
+ terrainTypeId,
162
+ getTerrainVariance(x, y),
163
+ 1,
164
+ 1
165
+ )
166
+ end
167
+ },
168
+ true
169
+ )
170
+ __TS__SetDescriptor(
171
+ TileCell.prototype,
172
+ "terrainVariance",
173
+ {
174
+ get = function(self)
175
+ return getTerrainVariance(self.x, self.y)
176
+ end,
177
+ set = function(self, terrainVariance)
178
+ local x = self.x
179
+ local y = self.y
180
+ setTerrainType(
181
+ x,
182
+ y,
183
+ getTerrainType(x, y),
184
+ terrainVariance,
185
+ 1,
186
+ 1
187
+ )
188
+ end
189
+ },
190
+ true
191
+ )
100
192
  return ____exports
@@ -1,6 +1,7 @@
1
1
  /** @noSelfInFile */
2
2
  import { Event } from "../../event";
3
3
  import { AbstractDestroyable, Destructor } from "../../destroyable";
4
+ import { CallbackId } from "../../utility/callback-array";
4
5
  declare const enum TimerPropertyKey {
5
6
  HANDLE = 0,
6
7
  DESTROY_ON_EXPIRATION = 1,
@@ -22,8 +23,8 @@ export declare class Timer extends AbstractDestroyable {
22
23
  pause(): void;
23
24
  resume(): void;
24
25
  static create(): Timer;
25
- static run<T, K extends KeysOfType<T, (this: T, ...args: any) => any>>(object: T, key: K, ...parameters: T[K] extends (this: T, ...args: any) => any ? Parameters<T[K]> : never): void;
26
- static run<Args extends any[]>(callback: (this: void, ...args: Args) => void, ...args: Args): void;
26
+ static run<T, K extends KeysOfType<T, (this: T, ...args: any) => any>>(object: T, key: K, ...parameters: T[K] extends (this: T, ...args: any) => any ? Parameters<T[K]> : never): CallbackId;
27
+ static run<Args extends any[]>(callback: (this: void, ...args: Args) => void, ...args: Args): CallbackId;
27
28
  static simple<Args extends any[]>(timeout: number, callback: (...args: Args) => void, ...args: Args): Timer;
28
29
  static periodic<Args extends any[]>(period: number, callback: (this: void, timer: Timer, ...args: Args) => void, ...args: Args): Timer;
29
30
  static counted(period: number, count: number, callback: (this: void, timer: Timer) => void): Timer;
@@ -15,6 +15,7 @@ local AbstractDestroyable = ____destroyable.AbstractDestroyable
15
15
  local ____callback_2Darray = require("utility.callback-array")
16
16
  local addCallback = ____callback_2Darray.addCallback
17
17
  local callbackArray = ____callback_2Darray.callbackArray
18
+ local consumeCallback = ____callback_2Darray.consumeCallback
18
19
  local consumeCallbacks = ____callback_2Darray.consumeCallbacks
19
20
  local createTimer = CreateTimer
20
21
  local timerStart = TimerStart
@@ -55,6 +56,11 @@ local function timerSafeCall()
55
56
  end
56
57
  local zeroTimerScheduled = false
57
58
  local zeroTimerCallbacks = callbackArray()
59
+ ---
60
+ -- @internal For use by internal systems only.
61
+ ____exports.consumeZeroTimerCallback = function(id)
62
+ consumeCallback(zeroTimerCallbacks, id)
63
+ end
58
64
  local function invokeZeroTimerCallbacks()
59
65
  zeroTimerScheduled = false
60
66
  consumeCallbacks(zeroTimerCallbacks)
@@ -98,9 +104,9 @@ function Timer.run(self, objectOrCallback, keyOrFirstArg, ...)
98
104
  ____exports.Timer:simple(0, invokeZeroTimerCallbacks)
99
105
  end
100
106
  if ____type(objectOrCallback) == "function" then
101
- addCallback(zeroTimerCallbacks, objectOrCallback, keyOrFirstArg, ...)
107
+ return addCallback(zeroTimerCallbacks, objectOrCallback, keyOrFirstArg, ...)
102
108
  else
103
- addCallback(zeroTimerCallbacks, objectOrCallback[keyOrFirstArg], objectOrCallback, ...)
109
+ return addCallback(zeroTimerCallbacks, objectOrCallback[keyOrFirstArg], objectOrCallback, ...)
104
110
  end
105
111
  end
106
112
  function Timer.simple(self, timeout, callback, ...)
package/decl/native.d.ts CHANGED
@@ -5259,8 +5259,8 @@ declare function BlzRemoveAbilityStringLevelArrayField(
5259
5259
  level: number,
5260
5260
  value: string,
5261
5261
  ): boolean
5262
- declare function BlzGetItemAbilityByIndex(whichItem: jitem, index: number): jability | null
5263
- declare function BlzGetItemAbility(whichItem: jitem, abilCode: number): jability | null
5262
+ declare function BlzGetItemAbilityByIndex(whichItem: jitem, index: number): jability | undefined
5263
+ declare function BlzGetItemAbility(whichItem: jitem, abilCode: number): jability | undefined
5264
5264
  declare function BlzItemAddAbility(whichItem: jitem, abilCode: number): boolean
5265
5265
  declare function BlzGetItemBooleanField(whichItem: jitem, whichField: jitembooleanfield): boolean
5266
5266
  declare function BlzGetItemIntegerField(whichItem: jitem, whichField: jitemintegerfield): number
@@ -15,6 +15,7 @@ export declare abstract class Behavior<T extends AnyNotNil, PeriodicActionParame
15
15
  protected constructor(object: T);
16
16
  protected onDestroy(): Destructor;
17
17
  protected registerEvent<K extends string, Args extends any[]>(this: Behavior<any, PeriodicActionParameters> & Record<K, (this: this, ...args: Args) => unknown>, event: Event<[...Args]>, listener: K): void;
18
+ protected deregisterEvent(event: Event<any>): boolean;
18
19
  protected onPeriod(...parameters: PeriodicActionParameters): void;
19
20
  protected startPeriodicAction(interval: number, ...parameters: PeriodicActionParameters): void;
20
21
  protected stopPeriodicAction(): void;
@@ -127,6 +127,15 @@ function Behavior.prototype.registerEvent(self, event, listener)
127
127
  end
128
128
  behaviors:add(self)
129
129
  end
130
+ function Behavior.prototype.deregisterEvent(self, event)
131
+ local behaviors = behaviorsByEvent[event]
132
+ if behaviors ~= nil and behaviors:remove(self) then
133
+ eventsByBehavior[self][event] = nil
134
+ listenerByBehaviorByEvent[event][self] = nil
135
+ return true
136
+ end
137
+ return false
138
+ end
130
139
  function Behavior.prototype.onPeriod(self, ...)
131
140
  end
132
141
  function Behavior.prototype.startPeriodicAction(self, interval, ...)
@@ -14,3 +14,12 @@ export declare class RemoveBuffsSelfAbilityBehavior extends AbilityBehavior {
14
14
  constructor(ability: Ability, polarity?: AbilityDependentValue<BuffPolarity> | undefined, resistanceType?: AbilityDependentValue<BuffResistanceType> | undefined, includeExpirationTimers?: AbilityDependentValue<boolean> | undefined, includeAuras?: AbilityDependentValue<boolean> | undefined, autoDispel?: AbilityDependentValue<boolean> | undefined);
15
15
  onImpact(caster: Unit): void;
16
16
  }
17
+ export declare class RemoveBuffsTargetAbilityBehavior extends AbilityBehavior {
18
+ private readonly polarity?;
19
+ private readonly resistanceType?;
20
+ private readonly includeExpirationTimers?;
21
+ private readonly includeAuras?;
22
+ private readonly autoDispel?;
23
+ constructor(ability: Ability, polarity?: AbilityDependentValue<BuffPolarity> | undefined, resistanceType?: AbilityDependentValue<BuffResistanceType> | undefined, includeExpirationTimers?: AbilityDependentValue<boolean> | undefined, includeAuras?: AbilityDependentValue<boolean> | undefined, autoDispel?: AbilityDependentValue<boolean> | undefined);
24
+ onUnitTargetImpact(_: Unit, target: Unit): void;
25
+ }
@@ -25,4 +25,25 @@ function RemoveBuffsSelfAbilityBehavior.prototype.onImpact(self, caster)
25
25
  self:resolveCurrentAbilityDependentValue(self.autoDispel)
26
26
  )
27
27
  end
28
+ ____exports.RemoveBuffsTargetAbilityBehavior = __TS__Class()
29
+ local RemoveBuffsTargetAbilityBehavior = ____exports.RemoveBuffsTargetAbilityBehavior
30
+ RemoveBuffsTargetAbilityBehavior.name = "RemoveBuffsTargetAbilityBehavior"
31
+ __TS__ClassExtends(RemoveBuffsTargetAbilityBehavior, AbilityBehavior)
32
+ function RemoveBuffsTargetAbilityBehavior.prototype.____constructor(self, ability, polarity, resistanceType, includeExpirationTimers, includeAuras, autoDispel)
33
+ AbilityBehavior.prototype.____constructor(self, ability)
34
+ self.polarity = polarity
35
+ self.resistanceType = resistanceType
36
+ self.includeExpirationTimers = includeExpirationTimers
37
+ self.includeAuras = includeAuras
38
+ self.autoDispel = autoDispel
39
+ end
40
+ function RemoveBuffsTargetAbilityBehavior.prototype.onUnitTargetImpact(self, _, target)
41
+ target:removeBuffs(
42
+ self:resolveCurrentAbilityDependentValue(self.polarity),
43
+ self:resolveCurrentAbilityDependentValue(self.resistanceType),
44
+ self:resolveCurrentAbilityDependentValue(self.includeExpirationTimers),
45
+ self:resolveCurrentAbilityDependentValue(self.includeAuras),
46
+ self:resolveCurrentAbilityDependentValue(self.autoDispel)
47
+ )
48
+ end
28
49
  return ____exports
@@ -8,6 +8,7 @@ export type StunImmunityUnitBehaviourParameters = {
8
8
  buffTypeIds?: LuaSet<BuffTypeId>;
9
9
  textTagPreset?: TextTagPreset;
10
10
  textTagText?: string;
11
+ additionalAction?: (this: void, unit: Unit) => void;
11
12
  };
12
13
  export declare class StunImmunityUnitBehavior extends UnitBehavior {
13
14
  readonly parameters: Readonly<StunImmunityUnitBehaviourParameters>;
@@ -17,4 +18,5 @@ export declare class StunImmunityUnitBehavior extends UnitBehavior {
17
18
  onDamageReceived(): void;
18
19
  onTargetingAbilityChannelingStart(): void;
19
20
  onTargetingAbilityImpact(): void;
21
+ protected onEffect(): void;
20
22
  }
@@ -48,8 +48,15 @@ local function process(behavior)
48
48
  for buffTypeId in pairs(behavior.parameters.buffTypeIds or DEFAULT_BUFF_TYPE_IDS) do
49
49
  hasRemovedBuffs = hasRemovedBuffs or behavior.unit:removeBuff(buffTypeId)
50
50
  end
51
- if hasRemovedBuffs and behavior.parameters.textTagText ~= nil then
52
- TextTag:flash(TextTag.MISS, behavior.parameters.textTagText, behavior.unit.x, behavior.unit.y)
51
+ if hasRemovedBuffs then
52
+ behavior.onEffect(behavior)
53
+ if behavior.parameters.textTagText ~= nil then
54
+ TextTag:flash(TextTag.MISS, behavior.parameters.textTagText, behavior.unit.x, behavior.unit.y)
55
+ end
56
+ local ____opt_0 = behavior.parameters.additionalAction
57
+ if ____opt_0 ~= nil then
58
+ ____opt_0(behavior.unit)
59
+ end
53
60
  end
54
61
  end
55
62
  ____exports.StunImmunityUnitBehavior = __TS__Class()
@@ -79,5 +86,7 @@ end
79
86
  function StunImmunityUnitBehavior.prototype.onTargetingAbilityImpact(self)
80
87
  process(self)
81
88
  end
89
+ function StunImmunityUnitBehavior.prototype.onEffect(self)
90
+ end
82
91
  StunImmunityUnitBehavior.defaultParameters = {buffTypeIds = DEFAULT_BUFF_TYPE_IDS, textTagPreset = TextTag.MISS, textTagText = nil}
83
92
  return ____exports
@@ -12,6 +12,7 @@ import type { Widget } from "../../core/types/widget";
12
12
  import { Destructable } from "../../core/types/destructable";
13
13
  import type { Buff } from "../buff";
14
14
  import { UnitBonusType } from "../internal/unit/bonus";
15
+ import { Player } from "../../core/types/player";
15
16
  export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
16
17
  export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
17
18
  readonly sourceAbilityBehavior?: AbilityBehavior;
@@ -55,4 +56,5 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
55
56
  onItemChargesChanged(item: Item): void;
56
57
  onKill(target: Unit): void;
57
58
  onDeath(source: Unit | undefined): void;
59
+ onOwnerChange(previousOwner: Player): void;
58
60
  }
@@ -165,6 +165,8 @@ function UnitBehavior.prototype.onKill(self, target)
165
165
  end
166
166
  function UnitBehavior.prototype.onDeath(self, source)
167
167
  end
168
+ function UnitBehavior.prototype.onOwnerChange(self, previousOwner)
169
+ end
168
170
  __TS__SetDescriptor(
169
171
  UnitBehavior.prototype,
170
172
  "unit",
@@ -276,6 +278,9 @@ __TS__SetDescriptor(
276
278
  Unit.itemChargesChangedEvent:addListener(function(unit, item)
277
279
  ____exports.UnitBehavior:forAll(unit, "onItemChargesChanged", item)
278
280
  end)
281
+ Unit.onOwnerChange:addListener(function(unit, previousOwner)
282
+ ____exports.UnitBehavior:forAll(unit, "onOwnerChange", previousOwner)
283
+ end)
279
284
  end)(UnitBehavior)
280
285
  Unit.destroyEvent:addListener(function(unit)
281
286
  ____exports.UnitBehavior:forAll(unit, "destroy")
@@ -13,7 +13,6 @@ local ____ability = require("engine.internal.item.ability")
13
13
  local abilityActionDummy = ____ability.abilityActionDummy
14
14
  local doAbilityAction = ____ability.doAbilityAction
15
15
  local doAbilityActionForceDummy = ____ability.doAbilityActionForceDummy
16
- local doUnitAbilityAction = ____ability.doUnitAbilityAction
17
16
  local startItemCooldown = ____ability.startItemCooldown
18
17
  local getUnitAbilityLevel = GetUnitAbilityLevel
19
18
  local setUnitAbilityLevel = SetUnitAbilityLevel
@@ -40,8 +39,6 @@ local getItemBooleanField = BlzGetItemBooleanField
40
39
  local setItemBooleanField = BlzSetItemBooleanField
41
40
  local unitHideAbility = BlzUnitHideAbility
42
41
  local unitDisableAbility = BlzUnitDisableAbility
43
- local unitRemoveAbility = UnitRemoveAbility
44
- local itemRemoveAbility = BlzItemRemoveAbility
45
42
  local match = string.match
46
43
  local ____type = _G.type
47
44
  local ____tostring = _G.tostring
@@ -429,7 +426,9 @@ function UnitAbility.prototype.interruptCast(self)
429
426
  self.owner:interruptCast(self.typeId)
430
427
  end
431
428
  function UnitAbility.prototype.onDestroy(self)
432
- doUnitAbilityAction(self.owner.handle, self.typeId, unitRemoveAbility, self.typeId)
429
+ if self.owner.state ~= 2 then
430
+ self.owner:removeAbility(self.typeId)
431
+ end
433
432
  return UnitAbility.____super.prototype.onDestroy(self)
434
433
  end
435
434
  __TS__SetDescriptor(
@@ -525,7 +524,9 @@ function ItemAbility.prototype.interruptCast(self)
525
524
  end
526
525
  end
527
526
  function ItemAbility.prototype.onDestroy(self)
528
- doAbilityAction(self.owner.handle, itemRemoveAbility, self.typeId)
527
+ if self.owner.state ~= 2 then
528
+ self.owner:removeAbility(self.typeId)
529
+ end
529
530
  return ItemAbility.____super.prototype.onDestroy(self)
530
531
  end
531
532
  __TS__SetDescriptor(
@@ -8,12 +8,10 @@ import { AbilityTypeId } from "../object-data/entry/ability-type";
8
8
  import type { ItemTypeId } from "../object-data/entry/item-type";
9
9
  type DefenseType = 0 | 1 | 2 | 3 | 4 | 5;
10
10
  declare const enum ItemPropertyKey {
11
- ABILITIES = 100,
12
- LUA_INDEX_BY_ABILITY_TYPE_ID = 101
11
+ ABILITIES = 100
13
12
  }
14
13
  export declare class Item extends Handle<jitem> {
15
14
  private readonly [ItemPropertyKey.ABILITIES];
16
- private readonly [ItemPropertyKey.LUA_INDEX_BY_ABILITY_TYPE_ID];
17
15
  constructor(handle: jitem);
18
16
  protected onDestroy(): HandleDestructor;
19
17
  static create<T extends Item>(this: typeof Item & (new (handle: jitem) => T), id: number, x: number, y: number, skinId?: number): T;
@@ -30,22 +28,22 @@ export declare class Item extends Handle<jitem> {
30
28
  get extendedTooltip(): string;
31
29
  set iconPath(v: string);
32
30
  get iconPath(): string;
33
- set dropOnDeath(v: boolean);
34
- get dropOnDeath(): boolean;
35
- set droppable(v: boolean);
36
- get droppable(): boolean;
37
- set pawnable(v: boolean);
38
- get pawnable(): boolean;
39
- set perishable(v: boolean);
40
- get perishable(): boolean;
41
- set powerup(v: boolean);
42
- get powerup(): boolean;
31
+ set dropsOnDeath(dropsOnDeath: boolean);
32
+ get dropsOnDeath(): boolean;
33
+ set canBeDropped(canBeDropped: boolean);
34
+ get canBeDropped(): boolean;
35
+ set canBeSold(canBeSold: boolean);
36
+ get canBeSold(): boolean;
37
+ set perishes(perishes: boolean);
38
+ get perishes(): boolean;
39
+ set isPowerUp(isPowerUp: boolean);
40
+ get isPowerUp(): boolean;
43
41
  get isAlive(): boolean;
44
42
  get isDead(): boolean;
45
43
  set isInvulnerable(isInvulnerable: boolean);
46
44
  get isInvulnerable(): boolean;
47
- set usable(v: boolean);
48
- get usable(): boolean;
45
+ set isActivelyUsed(isActivelyUsed: boolean);
46
+ get isActivelyUsed(): boolean;
49
47
  set visible(v: boolean);
50
48
  get visible(): boolean;
51
49
  set level(v: number);