warscript 0.0.1-dev.d750e38 → 0.0.1-dev.d842bb6

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.
@@ -78,9 +78,9 @@ export declare class Item extends Handle<jitem> {
78
78
  hasAbility(abilityTypeId: AbilityTypeId): boolean;
79
79
  getAbility(abilityTypeId: AbilityTypeId): ItemAbility | undefined;
80
80
  get abilities(): readonly ItemAbility[];
81
- static getInRange(pos: Vec2, range: number): Item[];
81
+ static getInRange(x: number, y: number, range: number): Item[];
82
82
  static getInRect(rect: ReadonlyRect): Item[];
83
83
  static get onCreate(): Event<[Item]>;
84
- static get onDestroy(): Event<[Item]>;
84
+ static get destroyEvent(): Event<[Item]>;
85
85
  }
86
86
  export {};
@@ -15,6 +15,12 @@ local ____ability = require("engine.internal.ability")
15
15
  local ItemAbility = ____ability.ItemAbility
16
16
  local ____ability = require("engine.internal.item.ability")
17
17
  local doAbilityAction = ____ability.doAbilityAction
18
+ local ____dummy_2Ditem = require("engine.internal.object-data.dummy-item")
19
+ local DUMMY_ITEM_ID = ____dummy_2Ditem.DUMMY_ITEM_ID
20
+ local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
21
+ local SLOT_FILLER_ITEM_TYPE_ID = ____add_2Ditem_2Dto_2Dslot.SLOT_FILLER_ITEM_TYPE_ID
22
+ local ____vec2 = require("math.vec2")
23
+ local distance = ____vec2.distance
18
24
  local itemAddAbility = BlzItemAddAbility
19
25
  local itemRemoveAbility = BlzItemRemoveAbility
20
26
  local getItemAbility = BlzGetItemAbility
@@ -24,6 +30,12 @@ local getAbilityId = BlzGetAbilityId
24
30
  local getWidgetLife = GetWidgetLife
25
31
  local removeItem = RemoveItem
26
32
  local getHandleId = GetHandleId
33
+ local setRect = SetRect
34
+ local enumItemsInRect = EnumItemsInRect
35
+ local getEnumItem = GetEnumItem
36
+ local getItemTypeId = GetItemTypeId
37
+ local getItemX = GetItemX
38
+ local getItemY = GetItemY
27
39
  local getItemIntegerField = BlzGetItemIntegerField
28
40
  local setItemBooleanField = BlzSetItemBooleanField
29
41
  local getItemBooleanField = BlzGetItemBooleanField
@@ -53,6 +65,32 @@ local function getItemAbilities(handle, item)
53
65
  end
54
66
  return abilities
55
67
  end
68
+ local targetCollection
69
+ local targetCollectionNextIndex
70
+ local centerX
71
+ local centerY
72
+ local enumRange
73
+ local function collectIntoTarget()
74
+ local item = getEnumItem()
75
+ local typeId = getItemTypeId(item)
76
+ if typeId ~= DUMMY_ITEM_ID and typeId ~= SLOT_FILLER_ITEM_TYPE_ID then
77
+ targetCollection[targetCollectionNextIndex] = ____exports.Item:of(item)
78
+ targetCollectionNextIndex = targetCollectionNextIndex + 1
79
+ end
80
+ end
81
+ local function collectIntoTargetRange()
82
+ local item = getEnumItem()
83
+ local typeId = getItemTypeId(item)
84
+ if distance(
85
+ getItemX(item),
86
+ getItemY(item),
87
+ centerX,
88
+ centerY
89
+ ) <= enumRange and typeId ~= DUMMY_ITEM_ID and typeId ~= SLOT_FILLER_ITEM_TYPE_ID then
90
+ targetCollection[targetCollectionNextIndex] = ____exports.Item:of(item)
91
+ targetCollectionNextIndex = targetCollectionNextIndex + 1
92
+ end
93
+ end
56
94
  ____exports.Item = __TS__Class()
57
95
  local Item = ____exports.Item
58
96
  Item.name = "Item"
@@ -111,34 +149,27 @@ function Item.prototype.getAbility(self, abilityTypeId)
111
149
  local ability = self[101][abilityTypeId] ~= nil and doAbilityAction(self.handle, getItemAbility, abilityTypeId)
112
150
  return ability and ItemAbility:of(ability, abilityTypeId, self) or nil
113
151
  end
114
- function Item.getInRange(self, pos, range)
115
- local collection = {}
116
- SetRect(
152
+ function Item.getInRange(self, x, y, range)
153
+ targetCollection = {}
154
+ targetCollectionNextIndex = 1
155
+ centerX = x
156
+ centerY = y
157
+ enumRange = range
158
+ setRect(
117
159
  enumRect,
118
- pos.x - range,
119
- pos.y - range,
120
- pos.x + range,
121
- pos.y + range
160
+ x - range,
161
+ y - range,
162
+ x + range,
163
+ y + range
122
164
  )
123
- EnumItemsInRect(
124
- enumRect,
125
- nil,
126
- function()
127
- collection[#collection + 1] = self:of(GetEnumItem())
128
- end
129
- )
130
- return collection
165
+ enumItemsInRect(enumRect, nil, collectIntoTargetRange)
166
+ return targetCollection
131
167
  end
132
168
  function Item.getInRect(self, rect)
133
- local collection = {}
134
- EnumItemsInRect(
135
- rect.handle,
136
- nil,
137
- function()
138
- collection[#collection + 1] = self:of(GetEnumItem())
139
- end
140
- )
141
- return collection
169
+ targetCollection = {}
170
+ targetCollectionNextIndex = 1
171
+ enumItemsInRect(rect.handle, nil, collectIntoTarget)
172
+ return targetCollection
142
173
  end
143
174
  __TS__SetDescriptor(
144
175
  Item.prototype,
@@ -551,7 +582,7 @@ __TS__ObjectDefineProperty(
551
582
  )
552
583
  __TS__ObjectDefineProperty(
553
584
  Item,
554
- "onDestroy",
585
+ "destroyEvent",
555
586
  {get = function(self)
556
587
  return self.onDestroyEvent
557
588
  end}
@@ -1,2 +1,2 @@
1
1
  /** @noSelfInFile */
2
- export declare const AUTO_ATTACK_SPEED_INCREASE_FACTOR_ABILITY_FIELD: jabilityreallevelfield;
2
+ export {};
@@ -10,5 +10,7 @@ ____exports.AUTO_ATTACK_SPEED_INCREASE_DUMMY_ABILITY_TYPE_ID = compiletime(funct
10
10
  abilityType.autoAttackSpeedIncreaseFactor = 0
11
11
  return abilityType.id
12
12
  end)
13
+ ---
14
+ -- @internal For use by internal systems.
13
15
  ____exports.AUTO_ATTACK_SPEED_INCREASE_FACTOR_ABILITY_FIELD = ABILITY_RLF_ATTACK_SPEED_INCREASE_ISX1
14
16
  return ____exports
@@ -0,0 +1,2 @@
1
+ /** @noSelfInFile */
2
+ export {};
@@ -0,0 +1,16 @@
1
+ local ____exports = {}
2
+ local ____evasion = require("engine.object-data.entry.ability-type.evasion")
3
+ local EvasionAbilityType = ____evasion.EvasionAbilityType
4
+ ---
5
+ -- @internal For use by internal systems.
6
+ ____exports.EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID = compiletime(function()
7
+ local abilityType = EvasionAbilityType:create()
8
+ abilityType.isInternal = true
9
+ abilityType.isButtonVisible = false
10
+ abilityType.evasionProbability = 0
11
+ return abilityType.id
12
+ end)
13
+ ---
14
+ -- @internal For use by internal systems.
15
+ ____exports.EVASION_PROBABILITY_ABILITY_FIELD = ABILITY_RLF_CHANCE_TO_EVADE_EEV1
16
+ return ____exports
@@ -9,7 +9,9 @@ local setItemVisible = SetItemVisible
9
9
  local unitAddItem = UnitAddItem
10
10
  local unitItemInSlot = UnitItemInSlot
11
11
  local unitRemoveItem = UnitRemoveItem
12
- local FILLER_ITEM_TYPE_ID = compiletime(function()
12
+ ---
13
+ -- @internal For use by internal systems only.
14
+ ____exports.SLOT_FILLER_ITEM_TYPE_ID = compiletime(function()
13
15
  local itemType = BlankItemType:create()
14
16
  itemType.name = "[Warscript/Dummy] Slot Filler"
15
17
  return itemType.id
@@ -19,7 +21,7 @@ end)
19
21
  ____exports.fillerItems = array(
20
22
  6,
21
23
  function()
22
- local item = CreateItem(FILLER_ITEM_TYPE_ID, 0, 0)
24
+ local item = CreateItem(____exports.SLOT_FILLER_ITEM_TYPE_ID, 0, 0)
23
25
  setItemVisible(item, false)
24
26
  ignoreEventsItems[item] = true
25
27
  return item
@@ -11,6 +11,7 @@ export type UnitMovementSpeedFactorBonusId = UnitBonusId<"movementSpeedFactor">;
11
11
  export type UnitAutoAttackDamageBonusId = UnitBonusId<"autoAttackDamage">;
12
12
  export type UnitDamageFactorBonusId = UnitBonusId<"damageFactor">;
13
13
  export type UnitReceivedDamageFactorBonusId = UnitBonusId<"receivedDamageFactor">;
14
+ export type UnitEvasionProbabilityBonusId = UnitBonusId<"evasionProbability">;
14
15
  export type UnitBonusType<Id extends UnitBonusId = UnitBonusId> = ({
15
16
  abilityTypeId: AbilityTypeId;
16
17
  field: jabilityintegerlevelfield;
@@ -34,6 +35,7 @@ export declare namespace UnitBonusType {
34
35
  const AUTO_ATTACK_DAMAGE: UnitBonusType<UnitAutoAttackDamageBonusId>;
35
36
  const DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
36
37
  const RECEIVED_DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
38
+ const EVASION_PROBABILITY: UnitBonusType<UnitEvasionProbabilityBonusId>;
37
39
  }
38
40
  export declare const addUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, value: number) => Id;
39
41
  export declare const removeUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id) => boolean;
@@ -21,8 +21,18 @@ local AUTO_ATTACK_DAMAGE_INCREASE_DUMMY_ABILITY_TYPE_ID = ____auto_2Dattack_2Dda
21
21
  local ____movement_2Dspeed_2Dincrease_2Dfactor = require("engine.internal.object-data.movement-speed-increase-factor")
22
22
  local MOVEMENT_SPEED_INCREASE_FACTOR_ABILITY_FIELD = ____movement_2Dspeed_2Dincrease_2Dfactor.MOVEMENT_SPEED_INCREASE_FACTOR_ABILITY_FIELD
23
23
  local MOVEMENT_SPEED_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID = ____movement_2Dspeed_2Dincrease_2Dfactor.MOVEMENT_SPEED_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID
24
+ local ____evasion_2Dprobability = require("engine.internal.object-data.evasion-probability")
25
+ local EVASION_PROBABILITY_ABILITY_FIELD = ____evasion_2Dprobability.EVASION_PROBABILITY_ABILITY_FIELD
26
+ local EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID = ____evasion_2Dprobability.EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID
24
27
  local damageFactorByUnit = {}
25
28
  local receivedDamageFactorByUnit = {}
29
+ local function atLeastOnceProbability(array)
30
+ local oppositeEventProbability = 1
31
+ for i = 1, #array do
32
+ oppositeEventProbability = oppositeEventProbability * (1 - array[i])
33
+ end
34
+ return 1 - oppositeEventProbability
35
+ end
26
36
  ____exports.UnitBonusType = {}
27
37
  local UnitBonusType = ____exports.UnitBonusType
28
38
  do
@@ -56,6 +66,13 @@ do
56
66
  }
57
67
  UnitBonusType.DAMAGE_FACTOR = {reduce = product, valueByUnit = damageFactorByUnit, initialValue = 1}
58
68
  UnitBonusType.RECEIVED_DAMAGE_FACTOR = {reduce = product, valueByUnit = receivedDamageFactorByUnit, initialValue = 1}
69
+ UnitBonusType.EVASION_PROBABILITY = {
70
+ abilityTypeId = EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID,
71
+ field = EVASION_PROBABILITY_ABILITY_FIELD,
72
+ integer = false,
73
+ reduce = atLeastOnceProbability,
74
+ initialValue = 0
75
+ }
59
76
  end
60
77
  local bonusesByUnitByBonusType = {}
61
78
  local nextId = 1
@@ -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,
@@ -16,7 +16,8 @@ declare const enum LightningPropertyKey {
16
16
  FADING = 110
17
17
  }
18
18
  export type LightningConstructor<T extends Lightning> = typeof Lightning & (new (handle: jlightning, typeId: LightningTypeId) => T);
19
- export declare class Lightning extends Handle<jlightning> {
19
+ export declare class Lightning extends AbstractDestroyable {
20
+ readonly handle: jlightning;
20
21
  readonly typeId: LightningTypeId;
21
22
  private [LightningPropertyKey.CHECK_VISIBILITY]?;
22
23
  private [LightningPropertyKey.SOURCE_UNIT]?;
@@ -30,7 +31,7 @@ export declare class Lightning extends Handle<jlightning> {
30
31
  private [LightningPropertyKey.DURATION]?;
31
32
  private [LightningPropertyKey.FADING]?;
32
33
  constructor(handle: jlightning, typeId: LightningTypeId);
33
- protected onDestroy(): HandleDestructor;
34
+ protected onDestroy(): Destructor;
34
35
  static create<T extends Lightning>(this: LightningConstructor<T>, typeId: LightningTypeId, ...parameters: [
35
36
  ...checkVisibility: [boolean] | [],
36
37
  ...sourceAndTarget: [sourceX: number, sourceY: number, targetX: number, targetY: number] | [
@@ -1,17 +1,16 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
3
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
+ local __TS__New = ____lualib.__TS__New
4
5
  local ____exports = {}
5
- local ____handle = require("core.types.handle")
6
- local Handle = ____handle.Handle
7
6
  local ____timer = require("core.types.timer")
8
7
  local Timer = ____timer.Timer
9
8
  local ____functions = require("utility.functions")
10
9
  local forwardByN = ____functions.forwardByN
11
10
  local ____unit_2Dmissile_2Ddata = require("engine.internal.unit-missile-data")
12
11
  local MISSILE_DATA_BY_UNIT_TYPE_ID = ____unit_2Dmissile_2Ddata.MISSILE_DATA_BY_UNIT_TYPE_ID
13
- local ____math = require("math")
14
- local ceil = ____math.ceil
12
+ local ____destroyable = require("destroyable")
13
+ local AbstractDestroyable = ____destroyable.AbstractDestroyable
15
14
  local ____type = _G.type
16
15
  local select = _G.select
17
16
  local cos = math.cos
@@ -43,9 +42,10 @@ local temporaryLightningsCount = 0
43
42
  ____exports.Lightning = __TS__Class()
44
43
  local Lightning = ____exports.Lightning
45
44
  Lightning.name = "Lightning"
46
- __TS__ClassExtends(Lightning, Handle)
45
+ __TS__ClassExtends(Lightning, AbstractDestroyable)
47
46
  function Lightning.prototype.____constructor(self, handle, typeId)
48
- Handle.prototype.____constructor(self, handle)
47
+ AbstractDestroyable.prototype.____constructor(self)
48
+ self.handle = handle
49
49
  self.typeId = typeId
50
50
  end
51
51
  function Lightning.prototype.onDestroy(self)
@@ -53,7 +53,7 @@ function Lightning.prototype.onDestroy(self)
53
53
  unitToPointLightnings[self] = nil
54
54
  pointToUnitLightnings[self] = nil
55
55
  destroyLightning(self.handle)
56
- return Handle.prototype.onDestroy(self)
56
+ return AbstractDestroyable.prototype.onDestroy(self)
57
57
  end
58
58
  function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, sourceYOrTargetXOrTargetUnit, sourceZOrTargetXOrTargetUnitOrTargetY, targetXOrTargetUnitOrTargetYOrTargetZ, targetY, targetZ)
59
59
  if type(checkVisibility) ~= "boolean" then
@@ -69,7 +69,8 @@ function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, so
69
69
  )
70
70
  end
71
71
  if targetZ ~= nil then
72
- return self:of(
72
+ return __TS__New(
73
+ self,
73
74
  addLightningEx(
74
75
  util.id2s(typeId),
75
76
  checkVisibility,
@@ -86,7 +87,8 @@ function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, so
86
87
  if targetXOrTargetUnitOrTargetYOrTargetZ ~= nil then
87
88
  if ____type(targetXOrTargetUnitOrTargetYOrTargetZ) == "number" then
88
89
  if ____type(sourceXOrSourceUnit) == "number" then
89
- return self:of(
90
+ return __TS__New(
91
+ self,
90
92
  addLightning(
91
93
  util.id2s(typeId),
92
94
  checkVisibility,
@@ -99,7 +101,8 @@ function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, so
99
101
  )
100
102
  end
101
103
  local unit = sourceXOrSourceUnit.handle
102
- local lightning = self:of(
104
+ local lightning = __TS__New(
105
+ self,
103
106
  addLightningEx(
104
107
  util.id2s(typeId),
105
108
  checkVisibility,
@@ -124,7 +127,8 @@ function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, so
124
127
  return lightning
125
128
  end
126
129
  local unit = targetXOrTargetUnitOrTargetYOrTargetZ.handle
127
- local lightning = self:of(
130
+ local lightning = __TS__New(
131
+ self,
128
132
  addLightningEx(
129
133
  util.id2s(typeId),
130
134
  checkVisibility,
@@ -153,7 +157,8 @@ function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, so
153
157
  local unit = sourceXOrSourceUnit.handle
154
158
  moveLocation(location, sourceYOrTargetXOrTargetUnit, sourceZOrTargetXOrTargetUnitOrTargetY)
155
159
  local z = getLocationZ(location)
156
- local lightning = self:of(
160
+ local lightning = __TS__New(
161
+ self,
157
162
  addLightningEx(
158
163
  util.id2s(typeId),
159
164
  checkVisibility,
@@ -180,7 +185,8 @@ function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, so
180
185
  local unit = sourceZOrTargetXOrTargetUnitOrTargetY.handle
181
186
  moveLocation(location, sourceXOrSourceUnit, sourceYOrTargetXOrTargetUnit)
182
187
  local z = getLocationZ(location)
183
- local lightning = self:of(
188
+ local lightning = __TS__New(
189
+ self,
184
190
  addLightningEx(
185
191
  util.id2s(typeId),
186
192
  checkVisibility,
@@ -206,7 +212,8 @@ function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, so
206
212
  end
207
213
  local sourceUnit = sourceXOrSourceUnit.handle
208
214
  local targetUnit = sourceYOrTargetXOrTargetUnit.handle
209
- local lightning = self:of(
215
+ local lightning = __TS__New(
216
+ self,
210
217
  addLightningEx(
211
218
  util.id2s(typeId),
212
219
  checkVisibility,
@@ -319,7 +326,7 @@ Timer.onPeriod[UPDATE_PERIOD]:addListener(function()
319
326
  getLightningColorR(handle),
320
327
  getLightningColorG(handle),
321
328
  getLightningColorB(handle),
322
- ceil(getLightningColorA(handle) * (1 - UPDATE_PERIOD / duration))
329
+ getLightningColorA(handle) * (1 - UPDATE_PERIOD / duration)
323
330
  )
324
331
  end
325
332
  lightning[109] = duration - UPDATE_PERIOD
@@ -12,3 +12,4 @@ export declare const enum AnimationName {
12
12
  STAND = "stand",
13
13
  WALK = "walk"
14
14
  }
15
+ export declare const isAnimationName: (value: string) => value is AnimationName;
@@ -1,2 +1,18 @@
1
1
  local ____exports = {}
2
+ local animationNames = {
3
+ attack = true,
4
+ birth = true,
5
+ death = true,
6
+ decay = true,
7
+ dissipate = true,
8
+ morph = true,
9
+ portrait = true,
10
+ sleep = true,
11
+ spell = true,
12
+ stand = true,
13
+ walk = true
14
+ }
15
+ ____exports.isAnimationName = function(value)
16
+ return animationNames[value] ~= nil
17
+ end
2
18
  return ____exports
@@ -6,6 +6,8 @@ local __TS__New = ____lualib.__TS__New
6
6
  local ____exports = {}
7
7
  local ____channel = require("engine.object-data.entry.ability-type.channel")
8
8
  local ChannelAbilityType = ____channel.ChannelAbilityType
9
+ local ____animation_2Dname = require("engine.object-data.auxiliary.animation-name")
10
+ local isAnimationName = ____animation_2Dname.isAnimationName
9
11
  local ____order_2Dtype_2Dstring_2Did_2Dfactory = require("engine.object-data.utility.order-type-string-id-factory")
10
12
  local orderTypeStringIdFactory = ____order_2Dtype_2Dstring_2Did_2Dfactory.orderTypeStringIdFactory
11
13
  local ____timer = require("core.types.timer")
@@ -21,6 +23,9 @@ local ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD = ____ability.A
21
23
  local AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD = ____ability.AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD
22
24
  local ____linked_2Dset = require("utility.linked-set")
23
25
  local LinkedSet = ____linked_2Dset.LinkedSet
26
+ local ____sound = require("core.types.sound")
27
+ local Sound3D = ____sound.Sound3D
28
+ local SoundPreset = ____sound.SoundPreset
24
29
  local isChannelingAbilityTypeIds = {}
25
30
  local usesAttackAnimationByAbilityTypeId = {}
26
31
  ____exports.BlankConfigurableAbilityType = __TS__Class()
@@ -211,11 +216,26 @@ for abilityTypeId, usesAttackAnimation in pairs(postcompile(function()
211
216
  for abilityTypeId, usesAttackAnimation in pairs(usesAttackAnimationByAbilityTypeId) do
212
217
  if usesAttackAnimation then
213
218
  local abilityType = checkNotNull(____exports.BlankConfigurableAbilityType:of(abilityTypeId))
214
- abilityType.channelingAnimation = {"attack"}
219
+ if isAnimationName(abilityType.channelingAnimation[1]) then
220
+ if abilityType.channelingAnimation[1] ~= "attack" then
221
+ abilityType.channelingAnimation = {"attack"}
222
+ end
223
+ else
224
+ abilityType.channelingAnimation = {
225
+ "attack",
226
+ table.unpack(abilityType.channelingAnimation)
227
+ }
228
+ end
215
229
  end
216
230
  end
217
231
  return usesAttackAnimationByAbilityTypeId
218
232
  end)) do
233
+ Unit.abilityCastingFinishEvent[abilityTypeId]:addListener(function(caster, ability)
234
+ local effectSound = ability:getField(ABILITY_SF_EFFECT_SOUND)
235
+ if effectSound ~= "" then
236
+ Sound3D:playFromLabel(effectSound, SoundPreset.Ability, caster)
237
+ end
238
+ end)
219
239
  if usesAttackAnimation then
220
240
  Unit.abilityCastingStartEvent[abilityTypeId]:addListener(
221
241
  4,
@@ -15,10 +15,10 @@ __TS__SetDescriptor(
15
15
  "missProbability",
16
16
  {
17
17
  get = function(self)
18
- return self:getNumberLevelField("Crs")
18
+ return self:getNumberLevelField("Crs1")
19
19
  end,
20
20
  set = function(self, missProbability)
21
- self:setNumberLevelField("Crs", missProbability)
21
+ self:setNumberLevelField("Crs1", missProbability)
22
22
  end
23
23
  },
24
24
  true
@@ -10,8 +10,8 @@ local ____exports = {}
10
10
  local preparePhysicalPositiveApplicatorAbility
11
11
  local ____ability_2Dtype = require("engine.object-data.entry.ability-type")
12
12
  local AbilityType = ____ability_2Dtype.AbilityType
13
- local ____cripple = require("engine.object-data.entry.ability-type.cripple")
14
- local CrippleAbilityType = ____cripple.CrippleAbilityType
13
+ local ____curse = require("engine.object-data.entry.ability-type.curse")
14
+ local CurseAbilityType = ____curse.CurseAbilityType
15
15
  local ____searing_2Darrows = require("engine.object-data.entry.ability-type.searing-arrows")
16
16
  local SearingArrowsAbilityType = ____searing_2Darrows.SearingArrowsAbilityType
17
17
  local ____slow_2Dpoison = require("engine.object-data.entry.ability-type.slow-poison")
@@ -30,7 +30,6 @@ local ____arrays = require("utility.arrays")
30
30
  local chunked = ____arrays.chunked
31
31
  local map = ____arrays.map
32
32
  local max = ____arrays.max
33
- local toLuaSet = ____arrays.toLuaSet
34
33
  local ____blood_2Dlust = require("engine.object-data.entry.ability-type.blood-lust")
35
34
  local BloodLustAbilityType = ____blood_2Dlust.BloodLustAbilityType
36
35
  local ____berserk = require("engine.object-data.entry.ability-type.berserk")
@@ -43,22 +42,11 @@ local ____permanent_2Dimmolation = require("engine.object-data.entry.ability-typ
43
42
  local PermanentImmolationAbilityType = ____permanent_2Dimmolation.PermanentImmolationAbilityType
44
43
  local ____cast_2Dability = require("engine.internal.mechanics.cast-ability")
45
44
  local castAbility = ____cast_2Dability.castAbility
46
- local createItem = CreateItem
47
- local getAbilityId = BlzGetAbilityId
48
- local getItemAbility = BlzGetItemAbility
49
- local getOwningPlayer = GetOwningPlayer
50
- local getUnitAbilityByIndex = BlzGetUnitAbilityByIndex
51
- local itemAddAbility = BlzItemAddAbility
52
- local removeItem = RemoveItem
53
45
  local setAbilityIntegerField = BlzSetAbilityIntegerField
54
46
  local setAbilityRealLevelField = BlzSetAbilityRealLevelField
55
- local setItemBooleanField = BlzSetItemBooleanField
56
47
  local setPlayerTechResearched = SetPlayerTechResearched
57
48
  local unitAddAbility = UnitAddAbility
58
- local unitAddItem = UnitAddItem
59
49
  local unitDisableAbility = BlzUnitDisableAbility
60
- local unitDropItemSlot = UnitDropItemSlot
61
- local unitInventorySize = UnitInventorySize
62
50
  local unitRemoveAbility = UnitRemoveAbility
63
51
  local compiletimeApplicableBuffTypes = {}
64
52
  ____exports.ApplicableBuffType = __TS__Class()
@@ -113,10 +101,8 @@ local applicatorAbilityTypeIdByApplicatorTypeByApplicableBuffTypeId, applicatorU
113
101
  local applicatorAbilityTypeIdByApplicatorType = {}
114
102
  if applicableBuffType.resistanceType == 1 or applicableBuffType.resistanceType == nil then
115
103
  if applicableBuffType.polarity == 2 or applicableBuffType.polarity == nil then
116
- local applicatorAbilityType = prepareAbilityType(CrippleAbilityType, applicableBuffType)
117
- applicatorAbilityType.movementSpeedDecreaseFactor = 0
118
- applicatorAbilityType.attackSpeedDecreaseFactor = 0
119
- applicatorAbilityType.damageDecreaseFactor = 0
104
+ local applicatorAbilityType = prepareAbilityType(CurseAbilityType, applicableBuffType)
105
+ applicatorAbilityType.missProbability = 0
120
106
  applicatorAbilityType.buffTypeIds = {applicableBuffType.id}
121
107
  applicatorAbilityTypeIdByApplicatorType[852189] = applicatorAbilityType.id
122
108
  end
@@ -204,15 +190,6 @@ local EVASION_ABILITY_TYPE_IDS = postcompile(function()
204
190
  "AIcs"
205
191
  }, fourCC))
206
192
  end)
207
- local INVENTORY_ABILITY_TYPE_IDS = postcompile(function()
208
- return toLuaSet(AbilityType:getAllIdsByBaseIds(map({
209
- "AInv",
210
- "Aihn",
211
- "Aien",
212
- "Aion",
213
- "Aiun"
214
- }, fourCC)))
215
- end)
216
193
  local SEARING_ARROWS_DUMMY_ABILITY_TYPE_ID = compiletime(function()
217
194
  local abilityType = SearingArrowsAbilityType:create()
218
195
  abilityType.isInternal = true
@@ -244,7 +221,7 @@ Unit.abilityCastingStartEvent[SEARING_ARROWS_DUMMY_ABILITY_TYPE_ID]:addListener(
244
221
  )
245
222
  ---
246
223
  -- @internal For use by internal systems only.
247
- ____exports.internalApplyBuff = function(unit, applicableBuffTypeId, polarity, resistanceType, level, duration, spellStealPriority, learnLevelMinimum, movementSpeedIncreaseFactor)
224
+ ____exports.internalApplyBuff = function(unit, applicableBuffTypeId, polarity, resistanceType, level, duration, spellStealPriority, learnLevelMinimum, missProbability)
248
225
  local applicatorType = polarity == 1 and (resistanceType == 1 and 852101 or 852100) or (polarity == 2 and (resistanceType == 1 and 852189 or 852173) or 0)
249
226
  local ____opt_1 = applicatorAbilityTypeIdByApplicatorTypeByApplicableBuffTypeId[applicableBuffTypeId]
250
227
  local applicatorAbilityTypeId = ____opt_1 and ____opt_1[applicatorType]
@@ -267,8 +244,7 @@ ____exports.internalApplyBuff = function(unit, applicableBuffTypeId, polarity, r
267
244
  applicatorAbilityTypeId,
268
245
  preparePhysicalPositiveApplicatorAbility,
269
246
  level,
270
- duration or 0,
271
- movementSpeedIncreaseFactor
247
+ duration or 0
272
248
  )
273
249
  if level ~= nil and level > 0 then
274
250
  local upgradeId = applicatorUpgradeIdByApplicatorAbilityTypeId[applicatorAbilityTypeId]
@@ -298,6 +274,9 @@ ____exports.internalApplyBuff = function(unit, applicableBuffTypeId, polarity, r
298
274
  ability:setField(ABILITY_RLF_DURATION_HERO, level, actualDuration)
299
275
  ability:setField(ABILITY_IF_PRIORITY, spellStealPriority or 0)
300
276
  ability:setField(ABILITY_IF_REQUIRED_LEVEL, learnLevelMinimum or 6)
277
+ if missProbability ~= nil and applicatorType == 852189 then
278
+ ability:setField(ABILITY_RLF_CHANCE_TO_MISS_CRS, missProbability)
279
+ end
301
280
  end,
302
281
  applicatorType,
303
282
  unit
@@ -309,16 +288,13 @@ ____exports.internalApplyBuff = function(unit, applicableBuffTypeId, polarity, r
309
288
  end
310
289
  return success
311
290
  end
312
- preparePhysicalPositiveApplicatorAbility = function(ability, level, duration, movementSpeedIncreaseFactor)
291
+ preparePhysicalPositiveApplicatorAbility = function(ability, level, duration)
313
292
  if level == nil then
314
293
  setAbilityIntegerField(ability, ABILITY_IF_LEVELS, 1)
315
294
  level = 1
316
295
  end
317
296
  setAbilityRealLevelField(ability, ABILITY_RLF_DURATION_NORMAL, level, duration)
318
297
  setAbilityRealLevelField(ability, ABILITY_RLF_DURATION_HERO, level, duration)
319
- if movementSpeedIncreaseFactor ~= nil then
320
- setAbilityRealLevelField(ability, ABILITY_RLF_MOVEMENT_SPEED_INCREASE_BSK1, level, movementSpeedIncreaseFactor)
321
- end
322
298
  end
323
299
  ---
324
300
  -- @internal For use by internal systems only.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "warscript",
4
- "version": "0.0.1-dev.d750e38",
4
+ "version": "0.0.1-dev.d842bb6",
5
5
  "description": "A typescript library for Warcraft III using Warpack.",
6
6
  "keywords": [
7
7
  "warcraft",
@@ -24,7 +24,7 @@
24
24
  "@warscript/language-extensions": "^0.0.1",
25
25
  "@warscript/tstl-plugin": "^0.0.4",
26
26
  "lua-types": "^2.13.1",
27
- "warpack": "0.0.1-dev.1830aad"
27
+ "warpack": "0.0.1-dev.0feff1b"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@typescript-eslint/eslint-plugin": "^8.13.0",