warscript 0.0.1-dev.65ee461 → 0.0.1-dev.66ce6c9

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 (36) hide show
  1. package/core/types/effect.d.ts +3 -1
  2. package/core/types/effect.lua +29 -26
  3. package/core/types/sound.d.ts +25 -17
  4. package/core/types/sound.lua +44 -80
  5. package/core/types/timer.d.ts +7 -6
  6. package/core/types/timer.lua +21 -18
  7. package/engine/behaviour/ability/apply-unit-behavior.lua +0 -1
  8. package/engine/behaviour/ability/damage.d.ts +0 -3
  9. package/engine/behaviour/ability/damage.lua +2 -2
  10. package/engine/behaviour/ability.d.ts +1 -4
  11. package/engine/behaviour/ability.lua +4 -6
  12. package/engine/behaviour/unit.d.ts +0 -2
  13. package/engine/buff.d.ts +8 -13
  14. package/engine/buff.lua +50 -81
  15. package/engine/internal/mechanics/ability-duration.lua +1 -1
  16. package/engine/internal/unit.d.ts +1 -6
  17. package/engine/internal/unit.lua +2 -8
  18. package/engine/object-data/auxiliary/attachment-preset.d.ts +2 -7
  19. package/engine/object-data/auxiliary/attachment-preset.lua +3 -4
  20. package/engine/object-data/entry/ability-type/shock-wave.d.ts +0 -4
  21. package/engine/object-data/entry/ability-type/shock-wave.lua +0 -26
  22. package/engine/object-data/entry/ability-type.d.ts +11 -11
  23. package/engine/object-data/entry/ability-type.lua +10 -24
  24. package/engine/object-data/entry/sound-preset.d.ts +0 -17
  25. package/engine/object-data/entry/sound-preset.lua +0 -104
  26. package/package.json +2 -2
  27. package/engine/object-data/auxiliary/sound-eax.d.ts +0 -10
  28. package/engine/object-data/auxiliary/sound-eax.lua +0 -2
  29. package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +0 -14
  30. package/engine/object-data/entry/ability-type/carrion-swarm.lua +0 -65
  31. package/engine/object-data/entry/ability-type/ensnare.d.ts +0 -12
  32. package/engine/object-data/entry/ability-type/ensnare.lua +0 -52
  33. package/engine/object-data/entry/ability-type/phase-shift.d.ts +0 -10
  34. package/engine/object-data/entry/ability-type/phase-shift.lua +0 -39
  35. package/engine/object-data/entry/ability-type/web.d.ts +0 -12
  36. package/engine/object-data/entry/ability-type/web.lua +0 -52
@@ -30,10 +30,12 @@ export declare class Effect extends Handle<jeffect> {
30
30
  set pitch(pitch: number);
31
31
  get roll(): number;
32
32
  set roll(roll: number);
33
- static create<T extends Effect>(this: typeof Effect & (new (handle: jeffect) => T), modelPath: string, xOrWidget: number | Widget, yOrAttachmentPoint?: number | string, parameters?: EffectParameters): T;
33
+ static create<T extends Effect>(this: typeof Effect & (new (handle: jeffect) => T), model: string, pos: Vec2): T;
34
+ static createTarget<T extends Effect>(this: typeof Effect & (new (handle: jeffect) => T), model: string, target: Widget, attachPoint: string): T;
34
35
  static flash(modelPath: string, ...args: [
35
36
  ...pointOrWidget: [x: number, y: number] | [widget: Widget, attachmentPoint?: string],
36
37
  ...parametersOrDuration: [parametersOrDuration?: EffectParameters | number] | [duration?: number, parameters?: EffectParameters]
37
38
  ]): void;
39
+ static flashTarget(model: string, target: Widget, attachPoint: string, duration?: number): void;
38
40
  }
39
41
  export {};
@@ -4,7 +4,7 @@ local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
4
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
5
5
  local __TS__InstanceOf = ____lualib.__TS__InstanceOf
6
6
  local ____exports = {}
7
- local dummyPlayer, addSpecialEffectInternal, flash
7
+ local dummyPlayer, flash
8
8
  local ____handle = require("core.types.handle")
9
9
  local Handle = ____handle.Handle
10
10
  local ____playerColor = require("core.types.playerColor")
@@ -119,7 +119,6 @@ local function setSpecialEffectColor(effect, color)
119
119
  dummyPlayer.color = dummyColor
120
120
  end
121
121
  local setters = {scale = setSpecialEffectScale, color = setSpecialEffectColor, pitch = setSpecialEffectPitchDegrees, roll = setSpecialEffectRollDegrees}
122
- local setterProperties = {"scale", "color", "pitch", "roll"}
123
122
  dummyPlayer = Player.neutralExtra
124
123
  local temporaryEffects = {}
125
124
  local temporaryEffectsDurations = {}
@@ -178,14 +177,11 @@ function Effect.prototype.onDestroy(self)
178
177
  destroyEffect(self.handle)
179
178
  return Handle.prototype.onDestroy(self)
180
179
  end
181
- function Effect.create(self, modelPath, xOrWidget, yOrAttachmentPoint, parameters)
182
- local effect = self:of(addSpecialEffectInternal(modelPath, xOrWidget, yOrAttachmentPoint, parameters))
183
- if parameters ~= nil then
184
- effect[100] = parameters.color
185
- effect[101] = parameters.pitch
186
- effect[102] = parameters.roll
187
- end
188
- return effect
180
+ function Effect.create(self, model, pos)
181
+ return self:of(addSpecialEffect(model, pos.x, pos.y))
182
+ end
183
+ function Effect.createTarget(self, model, target, attachPoint)
184
+ return self:of(addSpecialEffectTarget(model, target.handle, attachPoint))
189
185
  end
190
186
  function Effect.flash(self, modelPath, xOrWidget, yOrOrAttachmentPoint, parametersOrDuration, parameters)
191
187
  if type(parametersOrDuration) ~= "number" then
@@ -210,12 +206,24 @@ function Effect.flash(self, modelPath, xOrWidget, yOrOrAttachmentPoint, paramete
210
206
  parameters
211
207
  )
212
208
  end
209
+ function Effect.flashTarget(self, model, target, attachPoint, duration)
210
+ local effect = addSpecialEffectTarget(model, target.handle, attachPoint)
211
+ if effect ~= nil then
212
+ if duration and duration > 0 then
213
+ temporaryEffectsCount = temporaryEffectsCount + 1
214
+ temporaryEffects[temporaryEffectsCount] = effect
215
+ temporaryEffectsDurations[temporaryEffectsCount] = duration
216
+ else
217
+ destroyEffect(effect)
218
+ end
219
+ end
220
+ end
213
221
  __TS__SetDescriptor(
214
222
  Effect.prototype,
215
223
  "color",
216
224
  {
217
225
  get = function(self)
218
- return self[100] or PlayerColor.red
226
+ return self[100] or PlayerColor.black
219
227
  end,
220
228
  set = function(self, color)
221
229
  setSpecialEffectColor(self.handle, color)
@@ -265,35 +273,30 @@ __TS__SetDescriptor(
265
273
  },
266
274
  true
267
275
  )
268
- addSpecialEffectInternal = function(modelPath, xOrWidget, yOrAttachmentPoint, parameters)
276
+ flash = function(modelPath, xOrWidget, yOrOrAttachmentPoint, duration, parameters)
269
277
  local coordinatesProvided = type(xOrWidget) == "number"
270
278
  local isPositional = coordinatesProvided or (parameters and parameters.detached) == true
271
279
  local x = not isPositional and 0 or (coordinatesProvided and xOrWidget or xOrWidget.x)
272
- local y = not isPositional and 0 or (coordinatesProvided and yOrAttachmentPoint or xOrWidget.y)
273
- local effect = isPositional and addSpecialEffect(modelPath, x, y) or addSpecialEffectTarget(modelPath, xOrWidget.handle, yOrAttachmentPoint or "origin")
280
+ local y = not isPositional and 0 or (coordinatesProvided and yOrOrAttachmentPoint or xOrWidget.y)
281
+ local effect = isPositional and addSpecialEffect(modelPath, x, y) or addSpecialEffectTarget(modelPath, xOrWidget.handle, yOrOrAttachmentPoint or "origin")
282
+ if isPositional and not coordinatesProvided and (parameters and parameters.scale) == nil and __TS__InstanceOf(xOrWidget, Unit) then
283
+ setSpecialEffectScale(effect, xOrWidget.scale)
284
+ end
274
285
  if parameters ~= nil then
275
- if isPositional and parameters.scale == nil and __TS__InstanceOf(xOrWidget, Unit) then
276
- setSpecialEffectScale(effect, xOrWidget.scale)
277
- end
278
- for ____, property in ipairs(setterProperties) do
279
- local value = parameters[property]
280
- if value ~= nil then
281
- setters[property](effect, value)
286
+ for key, value in ____pairs(parameters) do
287
+ if key ~= "zOffset" and key ~= "detached" and key ~= "scaleZOffset" and key ~= "delay" then
288
+ setters[key](effect, value)
282
289
  end
283
290
  end
284
291
  if isPositional and parameters.zOffset ~= nil then
285
292
  moveLocation(location, x, y)
286
293
  local z = __TS__InstanceOf(xOrWidget, Unit) and getLocationZ(location) + xOrWidget.flyHeight or getLocationZ(location)
287
- setSpecialEffectZ(
294
+ BlzSetSpecialEffectZ(
288
295
  effect,
289
296
  z + parameters.zOffset * (parameters.scaleZOffset and getSpecialEffectScale(effect) or 1)
290
297
  )
291
298
  end
292
299
  end
293
- return effect
294
- end
295
- flash = function(modelPath, xOrWidget, yOrAttachmentPoint, duration, parameters)
296
- local effect = addSpecialEffectInternal(modelPath, xOrWidget, yOrAttachmentPoint, parameters)
297
300
  if duration ~= nil and duration > 0 then
298
301
  temporaryEffectsCount = temporaryEffectsCount + 1
299
302
  temporaryEffects[temporaryEffectsCount] = effect
@@ -1,7 +1,6 @@
1
1
  /** @noSelfInFile */
2
2
  import { Handle, HandleDestructor } from "./handle";
3
3
  import { Unit } from "./unit";
4
- import { SoundEax } from "../../engine/object-data/auxiliary/sound-eax";
5
4
  export declare enum SoundChannel {
6
5
  General = 0,
7
6
  UnitSelection = 1,
@@ -19,7 +18,16 @@ export declare enum SoundChannel {
19
18
  Birth = 13,
20
19
  Fire = 14
21
20
  }
22
- export type SoundSettings = Readonly<{
21
+ export declare enum SoundEax {
22
+ Default = "DefaultEAXON",
23
+ Acknowledgements = "HeroAcksEAX",
24
+ Environment = "DoodadsEAX",
25
+ Drums = "KotoDrumsEAX",
26
+ Attacks = "CombatSoundsEAX",
27
+ Abilities = "SpellsEAX",
28
+ Missiles = "MissilesEAX"
29
+ }
30
+ export type SoundPreset = Readonly<{
23
31
  channel?: SoundChannel;
24
32
  eax?: SoundEax;
25
33
  fadeInRate?: number;
@@ -28,19 +36,19 @@ export type SoundSettings = Readonly<{
28
36
  volume?: number;
29
37
  pitch?: number;
30
38
  }>;
31
- export type Sound3DSettings = SoundSettings & Readonly<{
39
+ export type Sound3DPreset = SoundPreset & Readonly<{
32
40
  stopWhenOutOfRange?: boolean;
33
41
  minDistance?: number;
34
42
  maxDistance?: number;
35
43
  distanceCutoff?: number;
36
44
  }>;
37
- export declare namespace SoundSettings {
38
- const UI: SoundSettings;
39
- const Music: SoundSettings;
40
- const Attack: Sound3DSettings;
41
- const Ability: Sound3DSettings;
42
- const AbilityLooping: Sound3DSettings;
43
- const Missile: Sound3DSettings;
45
+ export declare namespace SoundPreset {
46
+ const UI: SoundPreset;
47
+ const Music: SoundPreset;
48
+ const Attack: Sound3DPreset;
49
+ const Ability: Sound3DPreset;
50
+ const AbilityLooping: Sound3DPreset;
51
+ const Missile: Sound3DPreset;
44
52
  }
45
53
  export declare class Sound extends Handle<jsound, [fadeOut?: boolean]> {
46
54
  private _volume?;
@@ -50,13 +58,13 @@ export declare class Sound extends Handle<jsound, [fadeOut?: boolean]> {
50
58
  start(milliseconds?: number): void;
51
59
  stop(fadeOut?: boolean): void;
52
60
  restart(milliseconds?: number): void;
53
- static play(fileName: string, preset: SoundSettings): void;
54
- static create(fileName: string, preset: SoundSettings): Sound;
61
+ static play(fileName: string, preset: SoundPreset): void;
62
+ static create(fileName: string, preset: SoundPreset): Sound;
55
63
  }
56
64
  export declare class Sound3D extends Sound {
57
- static playAtPosition(fileName: string, preset: Sound3DSettings, x?: number, y?: number, z?: number): void;
58
- static playOnUnit(fileName: string, preset: Sound3DSettings, unit: Unit): void;
59
- static playFromLabel(label: string, preset: Sound3DSettings, ...positionOrUnit: [Unit] | [number, number, number?]): void;
60
- static createAtPosition(fileName: string, preset: Sound3DSettings, x?: number, y?: number, z?: number): Sound3D;
61
- static createOnUnit(fileName: string, preset: Sound3DSettings, unit: Unit): Sound3D;
65
+ static playAtPosition(fileName: string, preset: Sound3DPreset, x?: number, y?: number, z?: number): void;
66
+ static playOnUnit(fileName: string, preset: Sound3DPreset, unit: Unit): void;
67
+ static playFromLabel(label: string, preset: Sound3DPreset, ...positionOrUnit: [Unit] | [number, number, number?]): void;
68
+ static createAtPosition(fileName: string, preset: Sound3DPreset, x?: number, y?: number, z?: number): Sound3D;
69
+ static createOnUnit(fileName: string, preset: Sound3DPreset, unit: Unit): Sound3D;
62
70
  }
@@ -5,10 +5,6 @@ local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
5
5
  local ____exports = {}
6
6
  local ____handle = require("core.types.handle")
7
7
  local Handle = ____handle.Handle
8
- local ____sound_2Dpreset = require("engine.object-data.entry.sound-preset")
9
- local SoundPreset = ____sound_2Dpreset.SoundPreset
10
- local ____random = require("engine.random")
11
- local randomInteger = ____random.randomInteger
12
8
  local createSound = CreateSound
13
9
  local createSoundFromLabel = CreateSoundFromLabel
14
10
  local setSoundPitch = SetSoundPitch
@@ -53,21 +49,29 @@ ____exports.SoundChannel.Birth = 13
53
49
  ____exports.SoundChannel[____exports.SoundChannel.Birth] = "Birth"
54
50
  ____exports.SoundChannel.Fire = 14
55
51
  ____exports.SoundChannel[____exports.SoundChannel.Fire] = "Fire"
56
- ____exports.SoundSettings = {}
57
- local SoundSettings = ____exports.SoundSettings
52
+ ____exports.SoundEax = SoundEax or ({})
53
+ ____exports.SoundEax.Default = "DefaultEAXON"
54
+ ____exports.SoundEax.Acknowledgements = "HeroAcksEAX"
55
+ ____exports.SoundEax.Environment = "DoodadsEAX"
56
+ ____exports.SoundEax.Drums = "KotoDrumsEAX"
57
+ ____exports.SoundEax.Attacks = "CombatSoundsEAX"
58
+ ____exports.SoundEax.Abilities = "SpellsEAX"
59
+ ____exports.SoundEax.Missiles = "MissilesEAX"
60
+ ____exports.SoundPreset = {}
61
+ local SoundPreset = ____exports.SoundPreset
58
62
  do
59
- SoundSettings.UI = {channel = ____exports.SoundChannel.UI, eax = "DefaultEAXON", fadeInRate = 12700, fadeOutRate = 12700}
60
- SoundSettings.Music = {
63
+ SoundPreset.UI = {channel = ____exports.SoundChannel.UI, eax = ____exports.SoundEax.Default, fadeInRate = 12700, fadeOutRate = 12700}
64
+ SoundPreset.Music = {
61
65
  channel = ____exports.SoundChannel.Music,
62
- eax = "DefaultEAXON",
66
+ eax = ____exports.SoundEax.Default,
63
67
  fadeInRate = 12700,
64
68
  fadeOutRate = 12700,
65
69
  looping = true
66
70
  }
67
- SoundSettings.Attack = {channel = ____exports.SoundChannel.Combat, eax = "CombatSoundsEAX", fadeInRate = 10, fadeOutRate = 10}
68
- SoundSettings.Ability = {
71
+ SoundPreset.Attack = {channel = ____exports.SoundChannel.Combat, eax = ____exports.SoundEax.Attacks, fadeInRate = 10, fadeOutRate = 10}
72
+ SoundPreset.Ability = {
69
73
  channel = ____exports.SoundChannel.Animations,
70
- eax = "SpellsEAX",
74
+ eax = ____exports.SoundEax.Abilities,
71
75
  stopWhenOutOfRange = true,
72
76
  volume = 127,
73
77
  fadeInRate = 1,
@@ -77,9 +81,9 @@ do
77
81
  maxDistance = 3500,
78
82
  distanceCutoff = 3000
79
83
  }
80
- SoundSettings.AbilityLooping = {
84
+ SoundPreset.AbilityLooping = {
81
85
  channel = ____exports.SoundChannel.Birth,
82
- eax = "SpellsEAX",
86
+ eax = ____exports.SoundEax.Abilities,
83
87
  looping = true,
84
88
  stopWhenOutOfRange = true,
85
89
  volume = 127,
@@ -90,9 +94,9 @@ do
90
94
  maxDistance = 3000,
91
95
  distanceCutoff = 3000
92
96
  }
93
- SoundSettings.Missile = {
97
+ SoundPreset.Missile = {
94
98
  channel = ____exports.SoundChannel.Animations,
95
- eax = "MissilesEAX",
99
+ eax = ____exports.SoundEax.Missiles,
96
100
  stopWhenOutOfRange = true,
97
101
  volume = 127,
98
102
  fadeInRate = 1,
@@ -103,24 +107,6 @@ do
103
107
  distanceCutoff = 3000
104
108
  }
105
109
  end
106
- local customSoundPresetDataByLabel = postcompile(function()
107
- local customSoundPresetDataByLabel = {}
108
- for ____, soundPreset in ipairs(SoundPreset:getAll()) do
109
- if soundPreset.isCustom then
110
- customSoundPresetDataByLabel[soundPreset.id] = {
111
- filePaths = soundPreset.filePaths,
112
- volume = soundPreset.volume,
113
- pitch = soundPreset.pitch,
114
- channel = soundPreset.channel,
115
- minimumDistance = soundPreset.minimumDistance,
116
- maximumDistance = soundPreset.maximumDistance,
117
- distanceCutoff = soundPreset.distanceCutoff,
118
- eax = soundPreset.eax
119
- }
120
- end
121
- end
122
- return customSoundPresetDataByLabel
123
- end)
124
110
  local function createPresetSound(fileName, preset)
125
111
  local ____fileName_1 = fileName
126
112
  local ____preset_looping_0 = preset.looping
@@ -134,7 +120,7 @@ local function createPresetSound(fileName, preset)
134
120
  true,
135
121
  preset.fadeInRate or 12700,
136
122
  preset.fadeOutRate or 12700,
137
- preset.eax or "DefaultEAXON"
123
+ preset.eax or ____exports.SoundEax.Default
138
124
  )
139
125
  setSoundChannel(sound, preset.channel or ____exports.SoundChannel.General)
140
126
  setSoundVolume(sound, preset.volume or 127)
@@ -157,7 +143,7 @@ local function createPreset3DSound(fileName, preset)
157
143
  ____preset_stopWhenOutOfRange_3,
158
144
  preset.fadeInRate or 12700,
159
145
  preset.fadeOutRate or 12700,
160
- preset.eax or "DefaultEAXON"
146
+ preset.eax or ____exports.SoundEax.Default
161
147
  )
162
148
  setSoundChannel(sound, preset.channel or ____exports.SoundChannel.General)
163
149
  setSoundVolume(sound, preset.volume or 127)
@@ -167,51 +153,29 @@ local function createPreset3DSound(fileName, preset)
167
153
  return sound
168
154
  end
169
155
  local function createPreset3DSoundFromLabel(label, preset)
170
- local customSoundPresetData = customSoundPresetDataByLabel[label]
171
- if customSoundPresetData == nil then
172
- local ____label_7 = label
173
- local ____preset_looping_5 = preset.looping
174
- if ____preset_looping_5 == nil then
175
- ____preset_looping_5 = false
176
- end
177
- local ____preset_stopWhenOutOfRange_6 = preset.stopWhenOutOfRange
178
- if ____preset_stopWhenOutOfRange_6 == nil then
179
- ____preset_stopWhenOutOfRange_6 = true
180
- end
181
- return createSoundFromLabel(
182
- ____label_7,
183
- ____preset_looping_5,
184
- true,
185
- ____preset_stopWhenOutOfRange_6,
186
- preset.fadeInRate or 12700,
187
- preset.fadeOutRate or 12700
188
- )
189
- else
190
- local ____customSoundPresetData_filePaths_index_10 = customSoundPresetData.filePaths[randomInteger(#customSoundPresetData.filePaths - 1) + 1]
191
- local ____preset_looping_8 = preset.looping
192
- if ____preset_looping_8 == nil then
193
- ____preset_looping_8 = false
194
- end
195
- local ____preset_stopWhenOutOfRange_9 = preset.stopWhenOutOfRange
196
- if ____preset_stopWhenOutOfRange_9 == nil then
197
- ____preset_stopWhenOutOfRange_9 = true
198
- end
199
- local sound = createSound(
200
- ____customSoundPresetData_filePaths_index_10,
201
- ____preset_looping_8,
202
- true,
203
- ____preset_stopWhenOutOfRange_9,
204
- preset.fadeInRate or 12700,
205
- preset.fadeOutRate or 12700,
206
- customSoundPresetData.eax
207
- )
208
- setSoundChannel(sound, customSoundPresetData.channel)
209
- setSoundVolume(sound, customSoundPresetData.volume)
210
- setSoundPitch(sound, customSoundPresetData.pitch)
211
- setSoundDistances(sound, customSoundPresetData.minimumDistance, customSoundPresetData.maximumDistance)
212
- setSoundDistanceCutoff(sound, customSoundPresetData.distanceCutoff)
213
- return sound
156
+ local ____label_7 = label
157
+ local ____preset_looping_5 = preset.looping
158
+ if ____preset_looping_5 == nil then
159
+ ____preset_looping_5 = false
214
160
  end
161
+ local ____preset_stopWhenOutOfRange_6 = preset.stopWhenOutOfRange
162
+ if ____preset_stopWhenOutOfRange_6 == nil then
163
+ ____preset_stopWhenOutOfRange_6 = true
164
+ end
165
+ local sound = createSoundFromLabel(
166
+ ____label_7,
167
+ ____preset_looping_5,
168
+ true,
169
+ ____preset_stopWhenOutOfRange_6,
170
+ preset.fadeInRate or 12700,
171
+ preset.fadeOutRate or 12700
172
+ )
173
+ setSoundChannel(sound, preset.channel or ____exports.SoundChannel.General)
174
+ setSoundVolume(sound, preset.volume or 127)
175
+ setSoundPitch(sound, preset.pitch or 1)
176
+ setSoundDistances(sound, preset.minDistance or 600, preset.maxDistance or 8000)
177
+ setSoundDistanceCutoff(sound, preset.distanceCutoff or 1500)
178
+ return sound
215
179
  end
216
180
  ____exports.Sound = __TS__Class()
217
181
  local Sound = ____exports.Sound
@@ -1,26 +1,27 @@
1
1
  /** @noSelfInFile */
2
2
  import { Event } from "../../event";
3
- import { AbstractDestroyable, Destructor } from "../../destroyable";
4
3
  declare const enum TimerPropertyKey {
5
4
  HANDLE = 0,
6
- DESTROY_ON_EXPIRATION = 1,
7
- CALLBACK = 2,
8
- ARGS_LENGTH = 3
5
+ DESTROYED = 1,
6
+ DESTROY_ON_EXPIRATION = 2,
7
+ CALLBACK = 3,
8
+ ARGS_LENGTH = 4
9
9
  }
10
- export declare class Timer extends AbstractDestroyable {
10
+ export declare class Timer implements Destroyable {
11
11
  private readonly [TimerPropertyKey.HANDLE];
12
+ private [TimerPropertyKey.DESTROYED]?;
12
13
  private [TimerPropertyKey.DESTROY_ON_EXPIRATION]?;
13
14
  private [TimerPropertyKey.CALLBACK]?;
14
15
  private [TimerPropertyKey.ARGS_LENGTH]?;
15
16
  private constructor();
16
17
  get handle(): jtimer;
17
18
  start<Args extends any[]>(timeout: number, periodic: boolean, callback: (...args: Args) => void, ...args: Args): void;
18
- onDestroy(): Destructor;
19
19
  get elapsed(): number;
20
20
  get remaining(): number;
21
21
  get timeout(): number;
22
22
  pause(): void;
23
23
  resume(): void;
24
+ destroy(): void;
24
25
  static create(): Timer;
25
26
  static run<Args extends any[]>(callback: (...args: Args) => void, ...args: Args): void;
26
27
  static simple<Args extends any[]>(timeout: number, callback: (...args: Args) => void, ...args: Args): Timer;
@@ -1,7 +1,6 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__New = ____lualib.__TS__New
3
3
  local __TS__Class = ____lualib.__TS__Class
4
- local __TS__ClassExtends = ____lualib.__TS__ClassExtends
5
4
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
6
5
  local __TS__Promise = ____lualib.__TS__Promise
7
6
  local ____exports = {}
@@ -10,8 +9,8 @@ local Event = ____event.Event
10
9
  local InitializingEvent = ____event.InitializingEvent
11
10
  local ____objectPool = require("util.objectPool")
12
11
  local ObjectPool = ____objectPool.ObjectPool
13
- local ____destroyable = require("destroyable")
14
- local AbstractDestroyable = ____destroyable.AbstractDestroyable
12
+ local ____exception = require("exception")
13
+ local IllegalStateException = ____exception.IllegalStateException
15
14
  local createTimer = CreateTimer
16
15
  local timerStart = TimerStart
17
16
  local pauseTimer = PauseTimer
@@ -36,14 +35,14 @@ local timerByHandleId = {}
36
35
  local function timerSafeCall()
37
36
  local timer = timerByHandleId[getHandleId(getExpiredTimer())]
38
37
  if timer ~= nil then
39
- if timer[1] then
38
+ if timer[2] then
40
39
  timer:destroy()
41
40
  end
42
- local callback = timer[2]
41
+ local callback = timer[3]
43
42
  if callback ~= nil then
44
43
  safeCall(
45
44
  callback,
46
- ____unpack(timer, 3 + 1, 3 + (timer[3] or 0))
45
+ ____unpack(timer, 4 + 1, 4 + (timer[4] or 0))
47
46
  )
48
47
  end
49
48
  end
@@ -51,33 +50,37 @@ end
51
50
  ____exports.Timer = __TS__Class()
52
51
  local Timer = ____exports.Timer
53
52
  Timer.name = "Timer"
54
- __TS__ClassExtends(Timer, AbstractDestroyable)
55
53
  function Timer.prototype.____constructor(self)
56
- AbstractDestroyable.prototype.____constructor(self)
57
54
  self[0] = get()
58
55
  timerByHandleId[getHandleId(self[0])] = self
59
56
  end
60
57
  function Timer.prototype.start(self, timeout, periodic, callback, ...)
61
- self[2] = callback
58
+ self[3] = callback
62
59
  local argsLength = select("#", ...)
63
- self[3] = argsLength
60
+ self[4] = argsLength
64
61
  for i = 1, argsLength do
65
- self[3 + i] = (select(i, ...))
62
+ self[4 + i] = (select(i, ...))
66
63
  end
67
64
  timerStart(self.handle, timeout, periodic, timerSafeCall)
68
65
  end
69
- function Timer.prototype.onDestroy(self)
70
- local handle = self[0]
71
- timerByHandleId[getHandleId(handle)] = nil
72
- release(handle)
73
- return AbstractDestroyable.prototype.onDestroy(self)
74
- end
75
66
  function Timer.prototype.pause(self)
76
67
  pauseTimer(self[0])
77
68
  end
78
69
  function Timer.prototype.resume(self)
79
70
  resumeTimer(self[0])
80
71
  end
72
+ function Timer.prototype.destroy(self)
73
+ if self[1] then
74
+ error(
75
+ __TS__New(IllegalStateException, "Double-destroy run for timer"),
76
+ 0
77
+ )
78
+ end
79
+ local handle = self[0]
80
+ timerByHandleId[getHandleId(handle)] = nil
81
+ release(handle)
82
+ self[1] = true
83
+ end
81
84
  function Timer.create(self)
82
85
  return __TS__New(____exports.Timer)
83
86
  end
@@ -86,7 +89,7 @@ function Timer.run(self, callback, ...)
86
89
  end
87
90
  function Timer.simple(self, timeout, callback, ...)
88
91
  local timer = __TS__New(____exports.Timer)
89
- timer[1] = true
92
+ timer[2] = true
90
93
  timer:start(timeout, false, callback, ...)
91
94
  return timer
92
95
  end
@@ -41,7 +41,6 @@ function ApplyUnitBehaviorAbilityBehavior.prototype.onUnitGainAbility(self, unit
41
41
  ____opt_0:destroy()
42
42
  end
43
43
  self.unitBehavior = __TS__New(self.unitBehaviorConstructor, unit)
44
- self.unitBehavior.sourceAbilityBehavior = self
45
44
  self:update()
46
45
  end
47
46
  function ApplyUnitBehaviorAbilityBehavior.prototype.onUnitLoseAbility(self)
@@ -5,7 +5,6 @@ import { Unit } from "../../internal/unit";
5
5
  import { AbilityDependentValue } from "../../object-field/ability";
6
6
  import { Widget } from "../../../core/types/widget";
7
7
  import { AttackType, DamageType, WeaponType } from "../../internal/unit+damage";
8
- import { CombatClassifications } from "../../object-data/auxiliary/combat-classification";
9
8
  export type DamageAbilityBehaviorParameters = {
10
9
  damagePerStrength?: AbilityDependentValue<number>;
11
10
  damagePerAgility?: AbilityDependentValue<number>;
@@ -16,8 +15,6 @@ export type DamageAbilityBehaviorParameters = {
16
15
  };
17
16
  export type DamageAreaAbilityBehaviorParameters = DamageAbilityBehaviorParameters & {
18
17
  maximumDamage?: AbilityDependentValue<number>;
19
- areaOfEffect?: AbilityDependentValue<number>;
20
- allowedTargetCombatClassifications?: AbilityDependentValue<CombatClassifications>;
21
18
  };
22
19
  declare abstract class DamageAbilityBehavior<T extends DamageAbilityBehaviorParameters = DamageAbilityBehaviorParameters> extends AbilityBehavior {
23
20
  protected readonly damage: AbilityDependentValue<number>;
@@ -82,10 +82,10 @@ function DamageAreaAbilityBehavior.prototype.damageArea(self, caster, x, y)
82
82
  local parameters = self.parameters
83
83
  local targets = Unit.getAllowedTargetsInCollisionRange(
84
84
  caster,
85
- self:resolveCurrentAbilityDependentValue(parameters and parameters.allowedTargetCombatClassifications or ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD),
85
+ self:resolveCurrentAbilityDependentValue(ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD),
86
86
  x,
87
87
  y,
88
- self:resolveCurrentAbilityDependentValue(parameters and parameters.areaOfEffect or AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD)
88
+ self:resolveCurrentAbilityDependentValue(AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD)
89
89
  )
90
90
  local damage = self:calculateDamage(caster)
91
91
  local maximumDamage = self:resolveCurrentAbilityDependentValue(parameters and parameters.maximumDamage or 0)
@@ -29,10 +29,7 @@ export declare abstract class AbilityBehavior<Parameters extends {
29
29
  protected flashTargetEffect(widget: Widget, ...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]): void;
30
30
  protected flashAreaEffect(x: number, y: number, ...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]): void;
31
31
  protected flashEffect(x: number, y: number, ...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]): void;
32
- protected flashSpecialEffect(...args: [
33
- ...pointOrWidget: [x: number, y: number] | [widget: Widget],
34
- ...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]
35
- ]): void;
32
+ protected flashSpecialEffect(...args: [...pointOrWidget: [x: number, y: number] | [widget: Widget], duration?: number]): void;
36
33
  private static MissileLaunchConfig;
37
34
  private get missileLaunchConfig();
38
35
  protected onCreate(): void;
@@ -148,14 +148,13 @@ function AbilityBehavior.prototype.flashEffect(self, x, y, ...)
148
148
  ...
149
149
  )
150
150
  end
151
- function AbilityBehavior.prototype.flashSpecialEffect(self, xOrWidget, yOrParametersOrDuration, durationOrParameters, parameters)
151
+ function AbilityBehavior.prototype.flashSpecialEffect(self, xOrWidget, yOrDuration, duration)
152
152
  if type(xOrWidget) == "number" then
153
153
  Effect:flash(
154
154
  SPECIAL_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD:getValue(self.ability, 0),
155
155
  xOrWidget,
156
- yOrParametersOrDuration,
157
- durationOrParameters,
158
- parameters
156
+ yOrDuration,
157
+ duration
159
158
  )
160
159
  else
161
160
  local attachmentPoint = SPECIAL_EFFECT_ATTACHMENT_POINT_STRING_FIELD:getValue(self.ability)
@@ -163,8 +162,7 @@ function AbilityBehavior.prototype.flashSpecialEffect(self, xOrWidget, yOrParame
163
162
  SPECIAL_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD:getValue(self.ability, 0),
164
163
  xOrWidget,
165
164
  attachmentPoint ~= "" and attachmentPoint or "origin",
166
- yOrParametersOrDuration,
167
- durationOrParameters
165
+ yOrDuration
168
166
  )
169
167
  end
170
168
  end
@@ -5,11 +5,9 @@ import { DamageEvent, DamagingEvent, Unit } from "../internal/unit";
5
5
  import "../internal/unit+ability";
6
6
  import "../internal/unit-missile-launch";
7
7
  import { Item } from "../internal/item";
8
- import type { AbilityBehavior } from "./ability";
9
8
  export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
10
9
  export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
11
10
  constructor(unit: Unit);
12
- readonly sourceAbilityBehavior?: AbilityBehavior;
13
11
  get unit(): Unit;
14
12
  onAutoAttackStart(target: Unit): void;
15
13
  onAutoAttackFinish(target: Unit): void;
package/engine/buff.d.ts CHANGED
@@ -64,7 +64,6 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
64
64
  durationIncreaseOnAutoAttack?: NumberParameterValueType;
65
65
  maximumRemainingDuration?: NumberParameterValueType;
66
66
  maximumDuration?: NumberParameterValueType;
67
- turnsIntoGhost?: BooleanParameterValueType;
68
67
  stuns?: BooleanParameterValueType;
69
68
  ignoresStunImmunity?: BooleanParameterValueType;
70
69
  providesStunImmunity?: BooleanParameterValueType;
@@ -117,14 +116,13 @@ declare const enum BuffPropertyKey {
117
116
  MAXIMUM_DAMAGE_DEALT_EVENT_COUNT = 132,
118
117
  DAMAGE_RECEIVED_EVENT_COUNT = 133,
119
118
  MAXIMUM_DAMAGE_RECEIVED_EVENT_COUNT = 134,
120
- TURNS_INTO_GHOST = 135,
121
- STUNS = 136,
122
- IGNORES_STUN_IMMUNITY = 137,
123
- DISABLES_AUTO_ATTACK = 138,
124
- PROVIDES_INVULNERABILITY = 139,
125
- KILLS_ON_EXPIRATION = 140,
126
- EXPLODES_ON_EXPIRATION = 141,
127
- MISS_PROBABILITY = 142
119
+ STUNS = 135,
120
+ IGNORES_STUN_IMMUNITY = 136,
121
+ DISABLES_AUTO_ATTACK = 137,
122
+ PROVIDES_INVULNERABILITY = 138,
123
+ KILLS_ON_EXPIRATION = 139,
124
+ EXPLODES_ON_EXPIRATION = 140,
125
+ MISS_PROBABILITY = 141
128
126
  }
129
127
  export declare const enum BuffTypeIdSelectionPolicy {
130
128
  LEAST_DURATION = 0
@@ -138,7 +136,7 @@ export type BuffConstructorParameters<AdditionalParameters extends BuffAdditiona
138
136
  polarity: BuffPolarityParameterType,
139
137
  resistanceType: BuffResistanceTypeParameterType,
140
138
  ...abilityOrParameters: [
141
- ability?: Ability,
139
+ ability: Ability,
142
140
  parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>
143
141
  ] | [parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>]
144
142
  ];
@@ -180,7 +178,6 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
180
178
  private [BuffPropertyKey.DAMAGE_DEALT_EVENT_COUNT]?;
181
179
  private [BuffPropertyKey.MAXIMUM_DAMAGE_RECEIVED_EVENT_COUNT]?;
182
180
  private [BuffPropertyKey.DAMAGE_RECEIVED_EVENT_COUNT]?;
183
- private [BuffPropertyKey.TURNS_INTO_GHOST]?;
184
181
  private [BuffPropertyKey.STUNS]?;
185
182
  private [BuffPropertyKey.IGNORES_STUN_IMMUNITY]?;
186
183
  private [BuffPropertyKey.DISABLES_AUTO_ATTACK]?;
@@ -234,8 +231,6 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
234
231
  set receivedDamageFactor(receivedDamageFactor: number);
235
232
  get armorIncrease(): number;
236
233
  set armorIncrease(armorIncrease: number);
237
- get turnsIntoGhost(): boolean;
238
- set turnsIntoGhost(turnsIntoGhost: boolean);
239
234
  get stuns(): boolean;
240
235
  set stuns(stuns: boolean);
241
236
  get ignoresStunImmunity(): boolean;