warscript 0.0.1-dev.240d8a6 → 0.0.1-dev.273b8f3

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 (101) hide show
  1. package/config.d.ts +5 -0
  2. package/config.lua +10 -0
  3. package/core/types/effect.d.ts +13 -3
  4. package/core/types/effect.lua +116 -17
  5. package/core/types/sound.d.ts +1 -0
  6. package/core/types/sound.lua +36 -2
  7. package/core/util.d.ts +1 -1
  8. package/core/util.lua +6 -0
  9. package/engine/behaviour/ability/always-enabled.d.ts +7 -0
  10. package/engine/behaviour/ability/always-enabled.lua +31 -0
  11. package/engine/behaviour/ability/apply-buff.d.ts +5 -0
  12. package/engine/behaviour/ability/apply-buff.lua +32 -0
  13. package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
  14. package/engine/behaviour/ability/emulate-impact.lua +28 -0
  15. package/engine/behaviour/ability/instant-impact.d.ts +2 -2
  16. package/engine/behaviour/ability/instant-impact.lua +4 -19
  17. package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
  18. package/engine/behaviour/ability/on-command-impact.lua +25 -0
  19. package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
  20. package/engine/behaviour/ability/remove-buffs.lua +28 -0
  21. package/engine/behaviour/ability.d.ts +15 -3
  22. package/engine/behaviour/ability.lua +93 -34
  23. package/engine/buff.d.ts +56 -41
  24. package/engine/buff.lua +278 -231
  25. package/engine/internal/ability.d.ts +13 -2
  26. package/engine/internal/ability.lua +77 -4
  27. package/engine/internal/item/ability.lua +106 -0
  28. package/engine/internal/item.d.ts +2 -2
  29. package/engine/internal/item.lua +56 -25
  30. package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
  31. package/engine/internal/misc/ability-disable-counter.lua +13 -0
  32. package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
  33. package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
  34. package/engine/internal/object-data/evasion-probability.d.ts +2 -0
  35. package/engine/internal/object-data/evasion-probability.lua +16 -0
  36. package/engine/internal/unit/ability.d.ts +10 -1
  37. package/engine/internal/unit/ability.lua +36 -14
  38. package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
  39. package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
  40. package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
  41. package/engine/internal/unit/add-item-to-slot.lua +52 -0
  42. package/engine/internal/unit/bonus.d.ts +2 -0
  43. package/engine/internal/unit/bonus.lua +17 -0
  44. package/engine/internal/unit/ignore-events-items.d.ts +2 -0
  45. package/engine/internal/unit/ignore-events-items.lua +5 -0
  46. package/engine/internal/unit/item.d.ts +1 -1
  47. package/engine/internal/unit/item.lua +6 -12
  48. package/engine/internal/unit/main-selected.d.ts +6 -0
  49. package/engine/internal/unit/main-selected.lua +12 -1
  50. package/engine/internal/unit.d.ts +5 -3
  51. package/engine/internal/unit.lua +76 -41
  52. package/engine/internal/utility.lua +12 -0
  53. package/engine/lightning.d.ts +12 -5
  54. package/engine/lightning.lua +48 -14
  55. package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
  56. package/engine/object-data/auxiliary/animation-name.lua +16 -0
  57. package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
  58. package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
  59. package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
  60. package/engine/object-data/entry/ability-type/curse.lua +2 -2
  61. package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
  62. package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
  63. package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
  64. package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
  65. package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
  66. package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
  67. package/engine/object-data/entry/ability-type.d.ts +8 -6
  68. package/engine/object-data/entry/ability-type.lua +62 -27
  69. package/engine/object-data/entry/buff-type/applicable.lua +13 -37
  70. package/engine/object-data/entry/buff-type.d.ts +1 -1
  71. package/engine/object-data/entry/buff-type.lua +2 -2
  72. package/engine/object-data/entry/destructible-type.d.ts +1 -1
  73. package/engine/object-data/entry/item-type.d.ts +3 -1
  74. package/engine/object-data/entry/item-type.lua +15 -2
  75. package/engine/object-data/entry/lightning-type.d.ts +1 -1
  76. package/engine/object-data/entry/sound-preset.d.ts +16 -0
  77. package/engine/object-data/entry/sound-preset.lua +36 -0
  78. package/engine/object-data/entry/unit-type.d.ts +8 -1
  79. package/engine/object-data/entry/unit-type.lua +61 -8
  80. package/engine/object-data/entry/upgrade.d.ts +1 -1
  81. package/engine/object-data/entry/upgrade.lua +4 -4
  82. package/engine/object-data/entry.d.ts +16 -14
  83. package/engine/object-data/entry.lua +60 -32
  84. package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
  85. package/engine/object-field/ability.d.ts +9 -3
  86. package/engine/object-field/ability.lua +3 -0
  87. package/engine/object-field.d.ts +2 -2
  88. package/engine/object-field.lua +4 -0
  89. package/engine/standard/entries/sound-preset.d.ts +10 -0
  90. package/engine/standard/entries/sound-preset.lua +10 -0
  91. package/engine/standard/fields/ability.d.ts +2 -0
  92. package/engine/standard/fields/ability.lua +2 -0
  93. package/engine/unit.d.ts +1 -0
  94. package/engine/unit.lua +1 -0
  95. package/objutil/unit.lua +8 -0
  96. package/package.json +2 -2
  97. package/utility/arrays.d.ts +8 -1
  98. package/utility/arrays.lua +34 -3
  99. package/utility/lazy.d.ts +2 -0
  100. package/utility/lazy.lua +14 -0
  101. package/utility/reflection.lua +11 -7
@@ -46,6 +46,10 @@ end
46
46
  function ObjectFieldBase.prototype.supports(self, instance)
47
47
  return __TS__InstanceOf(instance, self.instanceClass)
48
48
  end
49
+ function ObjectFieldBase.prototype.hasValue(self, instance)
50
+ local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
51
+ return defaultValueByObjectDataEntryId ~= nil and defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)] ~= nil or self:hasNativeFieldValue(instance)
52
+ end
49
53
  function ObjectFieldBase.create(self, id)
50
54
  return __TS__New(
51
55
  self,
@@ -0,0 +1,10 @@
1
+ /** @noSelfInFile */
2
+ import { StandardSoundPresetId } from "../../object-data/entry/sound-preset";
3
+ export declare const ABOMINATION_PISSED_SOUND_PRESET_ID: StandardSoundPresetId;
4
+ export declare const ABOMINATION_READY_SOUND_PRESET_ID: StandardSoundPresetId;
5
+ export declare const ABOMINATION_WAR_CRY_SOUND_PRESET_ID: StandardSoundPresetId;
6
+ export declare const AXE_MEDIUM_CHOP_WOOD_SOUND_PRESET_ID: StandardSoundPresetId;
7
+ export declare const IMPALE_SOUND_PRESET_ID: StandardSoundPresetId;
8
+ export declare const IMPALE_HIT_SOUND_PRESET_ID: StandardSoundPresetId;
9
+ export declare const IMPALE_LAND_SOUND_PRESET_ID: StandardSoundPresetId;
10
+ export declare const IMPALE_CAST_SOUND_PRESET_ID: StandardSoundPresetId;
@@ -0,0 +1,10 @@
1
+ local ____exports = {}
2
+ ____exports.ABOMINATION_PISSED_SOUND_PRESET_ID = "AbominationPissed"
3
+ ____exports.ABOMINATION_READY_SOUND_PRESET_ID = "AbominationReady"
4
+ ____exports.ABOMINATION_WAR_CRY_SOUND_PRESET_ID = "AbominationWarcry"
5
+ ____exports.AXE_MEDIUM_CHOP_WOOD_SOUND_PRESET_ID = "AxeMediumChopWood"
6
+ ____exports.IMPALE_SOUND_PRESET_ID = "Impale"
7
+ ____exports.IMPALE_HIT_SOUND_PRESET_ID = "ImpaleHit"
8
+ ____exports.IMPALE_LAND_SOUND_PRESET_ID = "ImpaleLand"
9
+ ____exports.IMPALE_CAST_SOUND_PRESET_ID = "ImpaleCast"
10
+ return ____exports
@@ -687,6 +687,8 @@ export declare const DISABLE_OTHER_ABILITIES_ABILITY_BOOLEAN_LEVEL_FIELD: Abilit
687
687
  export declare const ALLOW_BOUNTY_ABILITY_BOOLEAN_LEVEL_FIELD: AbilityBooleanLevelField & symbol;
688
688
  export declare const ICON_NORMAL_ABILITY_STRING_LEVEL_FIELD: AbilityStringLevelField & symbol;
689
689
  export declare const CASTER_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD: AbilityStringArrayField & symbol;
690
+ export declare const CASTER_EFFECT_FIRST_ATTACHMENT_POINT_STRING_FIELD: AbilityStringField & symbol;
691
+ export declare const CASTER_EFFECT_SECOND_ATTACHMENT_POINT_STRING_FIELD: AbilityStringField & symbol;
690
692
  export declare const TARGET_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD: AbilityStringArrayField & symbol;
691
693
  export declare const TARGET_EFFECT_FIRST_ATTACHMENT_POINT_STRING_FIELD: AbilityStringField & symbol;
692
694
  export declare const TARGET_EFFECT_SECOND_ATTACHMENT_POINT_STRING_FIELD: AbilityStringField & symbol;
@@ -698,6 +698,8 @@ ____exports.DISABLE_OTHER_ABILITIES_ABILITY_BOOLEAN_LEVEL_FIELD = AbilityBoolean
698
698
  ____exports.ALLOW_BOUNTY_ABILITY_BOOLEAN_LEVEL_FIELD = AbilityBooleanLevelField:create(fourCC("Ntm4"))
699
699
  ____exports.ICON_NORMAL_ABILITY_STRING_LEVEL_FIELD = AbilityStringLevelField:create(fourCC("aart"))
700
700
  ____exports.CASTER_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = AbilityStringArrayField:create(fourCC("acat"))
701
+ ____exports.CASTER_EFFECT_FIRST_ATTACHMENT_POINT_STRING_FIELD = AbilityStringField:create(fourCC("acap"))
702
+ ____exports.CASTER_EFFECT_SECOND_ATTACHMENT_POINT_STRING_FIELD = AbilityStringField:create(fourCC("aca1"))
701
703
  ____exports.TARGET_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = AbilityStringArrayField:create(fourCC("atat"))
702
704
  ____exports.TARGET_EFFECT_FIRST_ATTACHMENT_POINT_STRING_FIELD = AbilityStringField:create(fourCC("ata0"))
703
705
  ____exports.TARGET_EFFECT_SECOND_ATTACHMENT_POINT_STRING_FIELD = AbilityStringField:create(fourCC("ata1"))
package/engine/unit.d.ts CHANGED
@@ -17,6 +17,7 @@ import "./internal/unit/ghost-counter";
17
17
  import "./internal/unit/invulnerability-counter";
18
18
  import "./internal/unit/detach-missiles";
19
19
  import "./internal/unit/main-selected";
20
+ import "./internal/unit/add-item-to-slot-init";
20
21
  import "./internal/unit/band-aids/ancestral-spirit-cannibalize";
21
22
  export { Unit, DamagingEvent, DamageEvent } from "./internal/unit";
22
23
  export * from "./internal/unit+damage";
package/engine/unit.lua CHANGED
@@ -17,6 +17,7 @@ require("engine.internal.unit.ghost-counter")
17
17
  require("engine.internal.unit.invulnerability-counter")
18
18
  require("engine.internal.unit.detach-missiles")
19
19
  require("engine.internal.unit.main-selected")
20
+ require("engine.internal.unit.add-item-to-slot-init")
20
21
  require("engine.internal.unit.band-aids.ancestral-spirit-cannibalize")
21
22
  do
22
23
  local ____unit = require("engine.internal.unit")
package/objutil/unit.lua CHANGED
@@ -11,6 +11,8 @@ local ____exports = {}
11
11
  local ____object = require("objutil.object")
12
12
  local ObjectDefinition = ____object.ObjectDefinition
13
13
  local idgen = require("objutil.idgen")
14
+ local ____config = require("config")
15
+ local WarscriptConfig = ____config.WarscriptConfig
14
16
  local attackTypes = setmetatable(
15
17
  {
16
18
  normal = "normal",
@@ -593,6 +595,9 @@ __TS__SetDescriptor(
593
595
  end,
594
596
  set = function(self, v)
595
597
  self:setStringField("umdl", v)
598
+ if WarscriptConfig.AUTOMATICALLY_SET_UNIT_TYPE_PORTRAIT_MODEL_PATH then
599
+ self:setStringField("upor", "")
600
+ end
596
601
  end
597
602
  },
598
603
  true
@@ -606,6 +611,9 @@ __TS__SetDescriptor(
606
611
  end,
607
612
  set = function(self, v)
608
613
  self.object:setField("umdl:hd", v)
614
+ if WarscriptConfig.AUTOMATICALLY_SET_UNIT_TYPE_PORTRAIT_MODEL_PATH then
615
+ self.object:setField("upor:hd", "")
616
+ end
609
617
  end
610
618
  },
611
619
  true
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.240d8a6",
4
+ "version": "0.0.1-dev.273b8f3",
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.880fc91"
27
+ "warpack": "0.0.1-dev.ba543de"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@typescript-eslint/eslint-plugin": "^8.13.0",
@@ -32,7 +32,10 @@ export declare const flatMapToLuaSet: {
32
32
  };
33
33
  export declare const mapIndexed: <T, R>(array: readonly T[], transform: (index: number, value: T) => R) => R[];
34
34
  export declare const associate: <T, K extends AnyNotNil, V>(array: readonly T[], keySelector: (value: T) => K, valueSelector: (value: T) => V) => LuaMap<K, V>;
35
- export declare const associateBy: <K extends AnyNotNil, V>(array: readonly V[], keySelector: (value: V) => K) => LuaMap<K, V>;
35
+ export declare const associateBy: {
36
+ <K extends AnyNotNil, V>(array: readonly V[], keySelector: (value: V) => K): LuaMap<K, V>;
37
+ <K extends KeysOfType<V, AnyNotNil>, V>(array: readonly V[], keySelector: K): LuaMap<V[K] extends AnyNotNil ? V[K] : never, V>;
38
+ };
36
39
  export declare const associateByIndexed: <K extends AnyNotNil, V>(array: readonly V[], keySelector: (index: number, value: V) => K) => LuaMap<K, V>;
37
40
  export declare const associateWith: <K extends AnyNotNil, V>(array: readonly K[], valueSelector: (value: K) => V) => LuaMap<K, V>;
38
41
  export declare const associateWithIndexed: <K extends AnyNotNil, V>(array: readonly K[], valueSelector: (index: number, value: K) => V) => LuaMap<K, V>;
@@ -41,6 +44,10 @@ export declare const average: (array: readonly number[]) => number;
41
44
  export declare const sum: (array: readonly number[]) => number;
42
45
  export declare const product: (array: readonly number[]) => number;
43
46
  export declare const max: (array: readonly number[]) => number;
47
+ export declare const maxBy: {
48
+ <T, Args extends any[]>(array: readonly T[], selector: (value: T, ...args: Args) => number, ...args: Args): T | undefined;
49
+ <T, K extends KeysOfType<T, number>>(array: readonly T[], key: K): T | undefined;
50
+ };
44
51
  export declare const intersperse: <T>(array: readonly T[], delimiter: T) => T[];
45
52
  export declare const zip: <T, R, V>(array: readonly T[], otherArray: readonly R[], transform: (value: T, otherValue: R) => V) => V[];
46
53
  export declare const chunked: <T>(array: readonly T[], size: number) => T[][];
@@ -178,9 +178,16 @@ ____exports.associate = function(array, keySelector, valueSelector)
178
178
  end
179
179
  ____exports.associateBy = function(array, keySelector)
180
180
  local result = {}
181
- for i = 1, #array do
182
- local value = array[i]
183
- result[keySelector(value)] = value
181
+ if type(keySelector) == "function" then
182
+ for i = 1, #array do
183
+ local value = array[i]
184
+ result[keySelector(value)] = value
185
+ end
186
+ else
187
+ for i = 1, #array do
188
+ local value = array[i]
189
+ result[value[keySelector]] = value
190
+ end
184
191
  end
185
192
  return result
186
193
  end
@@ -251,6 +258,30 @@ ____exports.max = function(array)
251
258
  end
252
259
  return mathMax(table.unpack(array))
253
260
  end
261
+ ____exports.maxBy = function(array, selector, ...)
262
+ local result = nil
263
+ local maxValue = -math.huge
264
+ if type(selector) == "function" then
265
+ for i = 1, #array do
266
+ local element = array[i]
267
+ local value = selector(element, ...)
268
+ if value > maxValue then
269
+ result = element
270
+ maxValue = value
271
+ end
272
+ end
273
+ else
274
+ for i = 1, #array do
275
+ local element = array[i]
276
+ local value = element[selector]
277
+ if value > maxValue then
278
+ result = element
279
+ maxValue = value
280
+ end
281
+ end
282
+ end
283
+ return result
284
+ end
254
285
  ____exports.intersperse = function(array, delimiter)
255
286
  local result = {}
256
287
  local length = #array
@@ -0,0 +1,2 @@
1
+ /** @noSelfInFile */
2
+ export declare const lazyRecord: <K extends keyof any, V>(initializer: (key: K) => V) => Readonly<Record<K, V>>;
@@ -0,0 +1,14 @@
1
+ local ____exports = {}
2
+ local rawset = _G.rawset
3
+ local setmetatable = _G.setmetatable
4
+ ____exports.lazyRecord = function(initializer)
5
+ return setmetatable(
6
+ {},
7
+ {__index = function(self, key)
8
+ local value = initializer(key)
9
+ rawset(self, key, value)
10
+ return value
11
+ end}
12
+ )
13
+ end
14
+ return ____exports
@@ -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)