warscript 0.0.1-dev.3989633 → 0.0.1-dev.39d8e49

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.
@@ -64,7 +64,7 @@ export declare class Sound extends Handle<jsound, [fadeOut?: boolean]> {
64
64
  export declare class Sound3D extends Sound {
65
65
  static playAtPosition(fileName: string, preset: Sound3DPreset, x?: number, y?: number, z?: number): void;
66
66
  static playOnUnit(fileName: string, preset: Sound3DPreset, unit: Unit): void;
67
- static playFromLabel(label: string, preset: Sound3DPreset, unit: Unit): void;
67
+ static playFromLabel(label: string, preset: Sound3DPreset, ...positionOrUnit: [Unit] | [number, number, number?]): void;
68
68
  static createAtPosition(fileName: string, preset: Sound3DPreset, x?: number, y?: number, z?: number): Sound3D;
69
69
  static createOnUnit(fileName: string, preset: Sound3DPreset, unit: Unit): Sound3D;
70
70
  }
@@ -249,9 +249,13 @@ function Sound3D.playOnUnit(self, fileName, preset, unit)
249
249
  startSound(sound)
250
250
  killSoundWhenDone(sound)
251
251
  end
252
- function Sound3D.playFromLabel(self, label, preset, unit)
252
+ function Sound3D.playFromLabel(self, label, preset, unitOrX, y, z)
253
253
  local sound = createPreset3DSoundFromLabel(label, preset)
254
- attachSoundToUnit(sound, unit.handle)
254
+ if type(unitOrX) ~= "number" then
255
+ attachSoundToUnit(sound, unitOrX.handle)
256
+ else
257
+ setSoundPosition(sound, unitOrX, y or 0, z or 0)
258
+ end
255
259
  startSound(sound)
256
260
  killSoundWhenDone(sound)
257
261
  end
@@ -23,9 +23,6 @@ local ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD = ____ability.A
23
23
  local AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD = ____ability.AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD
24
24
  local ____linked_2Dset = require("utility.linked-set")
25
25
  local LinkedSet = ____linked_2Dset.LinkedSet
26
- local ____sound = require("core.types.sound")
27
- local Sound3D = ____sound.Sound3D
28
- local SoundPreset = ____sound.SoundPreset
29
26
  local isChannelingAbilityTypeIds = {}
30
27
  local usesAttackAnimationByAbilityTypeId = {}
31
28
  ____exports.BlankConfigurableAbilityType = __TS__Class()
@@ -230,12 +227,6 @@ for abilityTypeId, usesAttackAnimation in pairs(postcompile(function()
230
227
  end
231
228
  return usesAttackAnimationByAbilityTypeId
232
229
  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)
239
230
  if usesAttackAnimation then
240
231
  Unit.abilityCastingStartEvent[abilityTypeId]:addListener(
241
232
  4,
@@ -15,10 +15,10 @@ __TS__SetDescriptor(
15
15
  "missProbability",
16
16
  {
17
17
  get = function(self)
18
- return self:getNumberLevelField("Crs1")
18
+ return self:getNumberLevelField("Crs\0")
19
19
  end,
20
20
  set = function(self, missProbability)
21
- self:setNumberLevelField("Crs1", missProbability)
21
+ self:setNumberLevelField("Crs\0", missProbability)
22
22
  end
23
23
  },
24
24
  true
@@ -115,6 +115,8 @@ export declare abstract class AbilityType extends ObjectDataEntry<AbilityTypeId>
115
115
  set casterEffectSoundPresetId(casterEffectSoundPresetId: SoundPresetId | undefined);
116
116
  get casterEffectLoopingSoundPresetId(): SoundPresetId;
117
117
  set casterEffectLoopingSoundPresetId(casterEffectLoopingSoundPresetId: SoundPresetId);
118
+ get targetEffectSoundPresetId(): SoundPresetId | undefined;
119
+ set targetEffectSoundPresetId(targetEffectSoundPresetId: SoundPresetId | undefined);
118
120
  get allowedTargetCombatClassifications(): CombatClassifications[];
119
121
  set allowedTargetCombatClassifications(allowedTargetCombatClassifications: ObjectDataEntryLevelFieldValueSupplier<CombatClassifications>);
120
122
  get areaOfEffect(): number[];
@@ -2,6 +2,7 @@ local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
3
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
4
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
5
+ local __TS__InstanceOf = ____lualib.__TS__InstanceOf
5
6
  local ____exports = {}
6
7
  local ____unit = require("engine.internal.unit")
7
8
  local Unit = ____unit.Unit
@@ -33,11 +34,15 @@ local ____object_2Ddata_2Dentry_2Did_2Dgenerator = require("engine.object-data.u
33
34
  local abilityTypeIdGenerator = ____object_2Ddata_2Dentry_2Did_2Dgenerator.abilityTypeIdGenerator
34
35
  local ____upgrade = require("engine.object-data.entry.upgrade")
35
36
  local Upgrade = ____upgrade.Upgrade
37
+ local ____sound = require("core.types.sound")
38
+ local Sound3D = ____sound.Sound3D
39
+ local SoundPreset = ____sound.SoundPreset
36
40
  local castAnimationFQNByAbilityTypeId = {}
37
41
  local isButtonVisibleFalseAbilityTypes = {}
38
42
  local casterCastingEffectPresetsByAbilityTypeId = {}
39
43
  local casterChannelingEffectPresetsByAbilityTypeId = {}
40
44
  local targetCastingEffectPresetsByAbilityTypeId = {}
45
+ local targetEffectSoundPresetByAbilityTypeId = {}
41
46
  ____exports.AbilityType = __TS__Class()
42
47
  local AbilityType = ____exports.AbilityType
43
48
  AbilityType.name = "AbilityType"
@@ -743,6 +748,19 @@ __TS__SetDescriptor(
743
748
  },
744
749
  true
745
750
  )
751
+ __TS__SetDescriptor(
752
+ AbilityType.prototype,
753
+ "targetEffectSoundPresetId",
754
+ {
755
+ get = function(self)
756
+ return targetEffectSoundPresetByAbilityTypeId[self.id]
757
+ end,
758
+ set = function(self, targetEffectSoundPresetId)
759
+ targetEffectSoundPresetByAbilityTypeId[self.id] = targetEffectSoundPresetId
760
+ end
761
+ },
762
+ true
763
+ )
746
764
  __TS__SetDescriptor(
747
765
  AbilityType.prototype,
748
766
  "allowedTargetCombatClassifications",
@@ -967,6 +985,26 @@ for abilityTypeId, animationFQN in pairs(postcompile(function() return castAnima
967
985
  end
968
986
  )
969
987
  end
988
+ for abilityTypeId, soundPresetId in pairs(postcompile(function() return targetEffectSoundPresetByAbilityTypeId end)) do
989
+ if soundPresetId ~= nil then
990
+ Unit.abilityWidgetTargetChannelingStartEvent[abilityTypeId]:addListener(
991
+ 4,
992
+ function(caster, ability, target)
993
+ if __TS__InstanceOf(target, Unit) then
994
+ Sound3D:playFromLabel(soundPresetId, SoundPreset.Ability, target)
995
+ else
996
+ Sound3D:playFromLabel(soundPresetId, SoundPreset.Ability, target.x, target.y)
997
+ end
998
+ end
999
+ )
1000
+ Unit.abilityPointTargetChannelingStartEvent[abilityTypeId]:addListener(
1001
+ 4,
1002
+ function(caster, ability, x, y)
1003
+ Sound3D:playFromLabel(soundPresetId, SoundPreset.Ability, x, y)
1004
+ end
1005
+ )
1006
+ end
1007
+ end
970
1008
  local casterCastingEffectModelPathsByAbilityTypeId = postcompile(function()
971
1009
  return mapValues(
972
1010
  casterCastingEffectPresetsByAbilityTypeId,
@@ -104,7 +104,7 @@ local applicatorAbilityTypeIdByApplicatorTypeByApplicableBuffTypeId, applicatorU
104
104
  local applicatorAbilityType = prepareAbilityType(CurseAbilityType, applicableBuffType)
105
105
  applicatorAbilityType.missProbability = 0
106
106
  applicatorAbilityType.buffTypeIds = {applicableBuffType.id}
107
- applicatorAbilityTypeIdByApplicatorType[852189] = applicatorAbilityType.id
107
+ applicatorAbilityTypeIdByApplicatorType[852190] = applicatorAbilityType.id
108
108
  end
109
109
  if applicableBuffType.polarity == 1 or applicableBuffType.polarity == nil then
110
110
  local applicatorAbilityType = prepareAbilityType(BloodLustAbilityType, applicableBuffType)
@@ -222,7 +222,7 @@ Unit.abilityCastingStartEvent[SEARING_ARROWS_DUMMY_ABILITY_TYPE_ID]:addListener(
222
222
  ---
223
223
  -- @internal For use by internal systems only.
224
224
  ____exports.internalApplyBuff = function(unit, applicableBuffTypeId, polarity, resistanceType, level, duration, spellStealPriority, learnLevelMinimum, missProbability)
225
- local applicatorType = polarity == 1 and (resistanceType == 1 and 852101 or 852100) or (polarity == 2 and (resistanceType == 1 and 852189 or 852173) or 0)
225
+ local applicatorType = polarity == 1 and (resistanceType == 1 and 852101 or 852100) or (polarity == 2 and (resistanceType == 1 and 852190 or 852173) or 0)
226
226
  local ____opt_1 = applicatorAbilityTypeIdByApplicatorTypeByApplicableBuffTypeId[applicableBuffTypeId]
227
227
  local applicatorAbilityTypeId = ____opt_1 and ____opt_1[applicatorType]
228
228
  if applicatorAbilityTypeId == nil then
@@ -274,7 +274,7 @@ ____exports.internalApplyBuff = function(unit, applicableBuffTypeId, polarity, r
274
274
  ability:setField(ABILITY_RLF_DURATION_HERO, level, actualDuration)
275
275
  ability:setField(ABILITY_IF_PRIORITY, spellStealPriority or 0)
276
276
  ability:setField(ABILITY_IF_REQUIRED_LEVEL, learnLevelMinimum or 6)
277
- if missProbability ~= nil and applicatorType == 852189 then
277
+ if missProbability ~= nil and applicatorType == 852190 then
278
278
  ability:setField(ABILITY_RLF_CHANCE_TO_MISS_CRS, missProbability)
279
279
  end
280
280
  end,
@@ -1,5 +1,5 @@
1
1
  /** @noSelfInFile */
2
- import { ObjectDataEntry, ObjectDataEntryConstructor, ObjectDataEntryId } from "../entry";
2
+ import { ObjectDataEntry, ObjectDataEntryId } from "../entry";
3
3
  export type SoundPresetId = ObjectDataEntryId & string & {
4
4
  readonly __soundPresetId: unique symbol;
5
5
  };
@@ -7,7 +7,6 @@ export type StandardSoundPresetId = SoundPresetId & {
7
7
  readonly __standardSoundPresetId: unique symbol;
8
8
  };
9
9
  export declare class SoundPreset extends ObjectDataEntry<SoundPresetId> {
10
- static readonly [id: StandardSoundPresetId]: ObjectDataEntryConstructor<SoundPreset>;
11
10
  static readonly BASE_ID: SoundPresetId;
12
11
  private static nextId;
13
12
  protected static generateId(): string;
@@ -5,8 +5,6 @@ local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
5
5
  local ____exports = {}
6
6
  local ____entry = require("engine.object-data.entry")
7
7
  local ObjectDataEntry = ____entry.ObjectDataEntry
8
- local ____reflection = require("utility.reflection")
9
- local implementReadonlyNumberIndexSupplier = ____reflection.implementReadonlyNumberIndexSupplier
10
8
  ____exports.SoundPreset = __TS__Class()
11
9
  local SoundPreset = ____exports.SoundPreset
12
10
  SoundPreset.name = "SoundPreset"
@@ -19,19 +17,7 @@ function SoundPreset.generateId(self)
19
17
  end
20
18
  function SoundPreset.getObjectData(self, map)
21
19
  return map.objects.sound
22
- end;
23
- (function(self)
24
- implementReadonlyNumberIndexSupplier(
25
- ____exports.SoundPreset,
26
- function(id)
27
- local ____class_3 = __TS__Class()
28
- ____class_3.name = ____class_3.name
29
- __TS__ClassExtends(____class_3, ____exports.SoundPreset)
30
- ____class_3.BASE_ID = id
31
- return ____class_3
32
- end
33
- )
34
- end)(SoundPreset)
20
+ end
35
21
  SoundPreset.BASE_ID = "BlizzardWave"
36
22
  SoundPreset.nextId = 0
37
23
  __TS__SetDescriptor(
@@ -810,7 +810,7 @@ __TS__SetDescriptor(
810
810
  set = function(self, modelPath)
811
811
  self:setStringField("umdl", modelPath)
812
812
  if not self.isPortraitModelPathSet and WarscriptConfig.AUTOMATICALLY_SET_UNIT_TYPE_PORTRAIT_MODEL_PATH then
813
- self:setStringField("upor", modelPath)
813
+ self:setStringField("upor", "")
814
814
  end
815
815
  end
816
816
  },
@@ -826,7 +826,7 @@ __TS__SetDescriptor(
826
826
  set = function(self, modelPathSD)
827
827
  self:setStringField("umdl:sd", modelPathSD)
828
828
  if not self.isPortraitModelPathSet and WarscriptConfig.AUTOMATICALLY_SET_UNIT_TYPE_PORTRAIT_MODEL_PATH then
829
- self:setStringField("upor:sd", modelPathSD)
829
+ self:setStringField("upor:sd", "")
830
830
  end
831
831
  end
832
832
  },
@@ -842,7 +842,7 @@ __TS__SetDescriptor(
842
842
  set = function(self, modelPathHD)
843
843
  self:setStringField("umdl:hd", modelPathHD)
844
844
  if not self.isPortraitModelPathSet and WarscriptConfig.AUTOMATICALLY_SET_UNIT_TYPE_PORTRAIT_MODEL_PATH then
845
- self:setStringField("upor:hd", modelPathHD)
845
+ self:setStringField("upor:hd", "")
846
846
  end
847
847
  end
848
848
  },
@@ -14,17 +14,17 @@ export declare const extractObjectDataEntryLevelArrayFieldValue: <T extends stri
14
14
  export declare abstract class ObjectDataEntry<Id extends ObjectDataEntryId = ObjectDataEntryId> {
15
15
  protected readonly object: WarObject;
16
16
  static readonly BASE_ID: ObjectDataEntryId;
17
- static readonly ID_TYPE: string;
18
17
  protected static readonly IS_SYNTHETIC: boolean;
19
18
  private readonly levelFieldParametersByField;
20
19
  private readonly maxAffectedLevelByField;
21
20
  private _isInternal;
22
21
  private get type();
23
22
  get isInternal(): boolean;
23
+ static get idType(): "number" | "string";
24
24
  protected static generateId(): number | string;
25
25
  protected static getObjectData(map: WarMap): WarObjects;
26
26
  static getAllIdsByBaseIds<T extends ObjectDataEntry>(this: ObjectDataEntryAbstractConstructor<T>, baseIds: number | number[] | string | string[]): ObjectDataEntryIdType<T>[];
27
- static create<T extends ObjectDataEntry>(this: ObjectDataEntryConstructor<T>, ...args: [id?: number, properties?: ObjectDataEntryProperties<T>] | [properties: ObjectDataEntryProperties<T>]): T;
27
+ static create<T extends ObjectDataEntry>(this: ObjectDataEntryConstructor<T>, ...args: [id?: number | string, properties?: ObjectDataEntryProperties<T>] | [properties: ObjectDataEntryProperties<T>]): T;
28
28
  static getAllByBaseIds<T extends ObjectDataEntry>(this: ObjectDataEntryAbstractConstructor<T>, baseIds: number | number[] | string | string[]): T[];
29
29
  static getAll<T extends ObjectDataEntry>(this: ObjectDataEntryAbstractConstructor<T>): T[];
30
30
  static of<T extends ObjectDataEntry>(this: ObjectDataEntryAbstractConstructor<T>, id: number | string): T | undefined;
@@ -7,6 +7,7 @@ local __TS__ClassExtends = ____lualib.__TS__ClassExtends
7
7
  local __TS__InstanceOf = ____lualib.__TS__InstanceOf
8
8
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
9
9
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
10
+ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
10
11
  local __TS__StringSplit = ____lualib.__TS__StringSplit
11
12
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
12
13
  local ____exports = {}
@@ -124,7 +125,7 @@ function ObjectDataEntry.getAllByBaseIds(self, baseIds)
124
125
  local constructor = self
125
126
  for id, object in pairs(constructor:getObjectData(currentMap).all) do
126
127
  if dataBaseIds[object.parentId or id] ~= nil then
127
- local objectDataEntry = self:of(dataToObjectDataEntryId(id, self.ID_TYPE))
128
+ local objectDataEntry = self:of(dataToObjectDataEntryId(id, self.idType))
128
129
  if objectDataEntry ~= nil and not objectDataEntry.isInternal then
129
130
  result[#result + 1] = objectDataEntry
130
131
  end
@@ -139,7 +140,7 @@ function ObjectDataEntry.getAll(self)
139
140
  local constructor = self
140
141
  local result = {}
141
142
  for id in pairs(constructor:getObjectData(currentMap).all) do
142
- local objectDataEntry = self:of(dataToObjectDataEntryId(id, self.ID_TYPE))
143
+ local objectDataEntry = self:of(dataToObjectDataEntryId(id, self.idType))
143
144
  if objectDataEntry ~= nil and not objectDataEntry.isInternal then
144
145
  result[#result + 1] = objectDataEntry
145
146
  end
@@ -156,9 +157,9 @@ function ObjectDataEntry.of(self, id)
156
157
  if object == nil then
157
158
  return nil
158
159
  end
159
- local objectDataEntry = objectDataEntryByObjectDataEntryId[dataToObjectDataEntryId(object.id, self.ID_TYPE)]
160
+ local objectDataEntry = objectDataEntryByObjectDataEntryId[dataToObjectDataEntryId(object.id, self.idType)]
160
161
  if objectDataEntry == nil then
161
- if not constructor.IS_SYNTHETIC and (self.BASE_ID == 0 or dataToObjectDataEntryId(object.parentId, self.ID_TYPE) == self.BASE_ID) then
162
+ if not constructor.IS_SYNTHETIC and (self.BASE_ID == 0 or dataToObjectDataEntryId(object.parentId, self.idType) == self.BASE_ID) then
162
163
  local AbstractObjectDataEntryView = __TS__Class()
163
164
  AbstractObjectDataEntryView.name = "AbstractObjectDataEntryView"
164
165
  __TS__ClassExtends(AbstractObjectDataEntryView, constructor)
@@ -475,7 +476,6 @@ function ObjectDataEntry.prototype.setLevelField(self, field, supplier, extracto
475
476
  end
476
477
  end
477
478
  ObjectDataEntry.BASE_ID = 0
478
- ObjectDataEntry.ID_TYPE = type(self.BASE_ID) == "number" and "number" or "string"
479
479
  ObjectDataEntry.IS_SYNTHETIC = false
480
480
  __TS__SetDescriptor(
481
481
  ObjectDataEntry.prototype,
@@ -503,11 +503,18 @@ __TS__SetDescriptor(
503
503
  },
504
504
  true
505
505
  )
506
+ __TS__ObjectDefineProperty(
507
+ ObjectDataEntry,
508
+ "idType",
509
+ {get = function(self)
510
+ return type(self.BASE_ID) == "number" and "number" or "string"
511
+ end}
512
+ )
506
513
  __TS__SetDescriptor(
507
514
  ObjectDataEntry.prototype,
508
515
  "id",
509
516
  {get = function(self)
510
- return dataToObjectDataEntryId(self.object.id, self.type.ID_TYPE)
517
+ return dataToObjectDataEntryId(self.object.id, self.type.idType)
511
518
  end},
512
519
  true
513
520
  )
@@ -515,7 +522,7 @@ __TS__SetDescriptor(
515
522
  ObjectDataEntry.prototype,
516
523
  "baseId",
517
524
  {get = function(self)
518
- return dataToObjectDataEntryId(self.object.parentId or self.object.id, self.type.ID_TYPE)
525
+ return dataToObjectDataEntryId(self.object.parentId or self.object.id, self.type.idType)
519
526
  end},
520
527
  true
521
528
  )
package/objutil/unit.lua CHANGED
@@ -596,7 +596,7 @@ __TS__SetDescriptor(
596
596
  set = function(self, v)
597
597
  self:setStringField("umdl", v)
598
598
  if WarscriptConfig.AUTOMATICALLY_SET_UNIT_TYPE_PORTRAIT_MODEL_PATH then
599
- self:setStringField("upor", v)
599
+ self:setStringField("upor", "")
600
600
  end
601
601
  end
602
602
  },
@@ -612,7 +612,7 @@ __TS__SetDescriptor(
612
612
  set = function(self, v)
613
613
  self.object:setField("umdl:hd", v)
614
614
  if WarscriptConfig.AUTOMATICALLY_SET_UNIT_TYPE_PORTRAIT_MODEL_PATH then
615
- self.object:setField("upor:hd", v)
615
+ self.object:setField("upor:hd", "")
616
616
  end
617
617
  end
618
618
  },
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.3989633",
4
+ "version": "0.0.1-dev.39d8e49",
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.82ebe44"
27
+ "warpack": "0.0.1-dev.9029fc3"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@typescript-eslint/eslint-plugin": "^8.13.0",
@@ -5,21 +5,25 @@ local checkNotNull = ____preconditions.checkNotNull
5
5
  -- @internal For use by internal systems only.
6
6
  ____exports.implementReadonlyNumberIndexSupplier = function(clazz, supplier)
7
7
  local metatable = checkNotNull(getmetatable(clazz))
8
- local originalIndex = checkNotNull(metatable.__index)
8
+ local originalIndex = checkNotNull(rawget(metatable, "__index"))
9
9
  local memoizedValueByKey = {}
10
- metatable.__index = setmetatable(
11
- memoizedValueByKey,
12
- {__index = function(self, key)
10
+ rawset(
11
+ metatable,
12
+ "__index",
13
+ function(self, key)
13
14
  if type(key) == "number" then
14
- local value = supplier(key)
15
- memoizedValueByKey[key] = value
15
+ local value = memoizedValueByKey[key]
16
+ if value == nil then
17
+ value = supplier(key)
18
+ memoizedValueByKey[key] = value
19
+ end
16
20
  return value
17
21
  end
18
22
  if type(originalIndex) == "function" then
19
23
  return originalIndex(self, key)
20
24
  end
21
25
  return originalIndex[key]
22
- end}
26
+ end
23
27
  )
24
28
  end
25
29
  ____exports.getClass = function(object)