warscript 0.0.1-dev.359b41a → 0.0.1-dev.3806ba5

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 (76) hide show
  1. package/config.d.ts +5 -0
  2. package/config.lua +10 -0
  3. package/core/types/effect.d.ts +1 -0
  4. package/core/types/effect.lua +80 -30
  5. package/core/types/sound.d.ts +1 -0
  6. package/core/types/sound.lua +32 -2
  7. package/engine/behaviour/ability/apply-buff.d.ts +5 -0
  8. package/engine/behaviour/ability/apply-buff.lua +32 -0
  9. package/engine/behaviour/ability/emulate-impact.lua +5 -7
  10. package/engine/behaviour/ability/on-command-impact.lua +7 -0
  11. package/engine/behaviour/ability.d.ts +7 -2
  12. package/engine/behaviour/ability.lua +48 -3
  13. package/engine/buff.d.ts +50 -40
  14. package/engine/buff.lua +261 -225
  15. package/engine/internal/ability.d.ts +11 -1
  16. package/engine/internal/ability.lua +67 -2
  17. package/engine/internal/item/ability.lua +106 -0
  18. package/engine/internal/item.d.ts +2 -2
  19. package/engine/internal/item.lua +56 -25
  20. package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
  21. package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
  22. package/engine/internal/object-data/evasion-probability.d.ts +2 -0
  23. package/engine/internal/object-data/evasion-probability.lua +16 -0
  24. package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
  25. package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
  26. package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
  27. package/engine/internal/unit/add-item-to-slot.lua +52 -0
  28. package/engine/internal/unit/bonus.d.ts +2 -0
  29. package/engine/internal/unit/bonus.lua +17 -0
  30. package/engine/internal/unit/ignore-events-items.d.ts +2 -0
  31. package/engine/internal/unit/ignore-events-items.lua +5 -0
  32. package/engine/internal/unit/item.lua +6 -12
  33. package/engine/internal/unit.d.ts +3 -1
  34. package/engine/internal/unit.lua +63 -13
  35. package/engine/internal/utility.lua +12 -0
  36. package/engine/lightning.d.ts +12 -5
  37. package/engine/lightning.lua +48 -14
  38. package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
  39. package/engine/object-data/auxiliary/animation-name.lua +16 -0
  40. package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
  41. package/engine/object-data/entry/ability-type/blank-configurable.lua +21 -1
  42. package/engine/object-data/entry/ability-type/curse.lua +2 -2
  43. package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
  44. package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
  45. package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
  46. package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
  47. package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
  48. package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
  49. package/engine/object-data/entry/ability-type.d.ts +6 -6
  50. package/engine/object-data/entry/ability-type.lua +24 -27
  51. package/engine/object-data/entry/buff-type/applicable.lua +11 -35
  52. package/engine/object-data/entry/buff-type.d.ts +1 -1
  53. package/engine/object-data/entry/buff-type.lua +2 -2
  54. package/engine/object-data/entry/destructible-type.d.ts +1 -1
  55. package/engine/object-data/entry/item-type.d.ts +3 -1
  56. package/engine/object-data/entry/item-type.lua +15 -2
  57. package/engine/object-data/entry/lightning-type.d.ts +1 -1
  58. package/engine/object-data/entry/sound-preset.d.ts +17 -0
  59. package/engine/object-data/entry/sound-preset.lua +50 -0
  60. package/engine/object-data/entry/unit-type.d.ts +8 -1
  61. package/engine/object-data/entry/unit-type.lua +61 -8
  62. package/engine/object-data/entry/upgrade.d.ts +1 -1
  63. package/engine/object-data/entry/upgrade.lua +4 -4
  64. package/engine/object-data/entry.d.ts +15 -13
  65. package/engine/object-data/entry.lua +53 -32
  66. package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
  67. package/engine/object-field/ability.d.ts +5 -2
  68. package/engine/object-field/ability.lua +3 -0
  69. package/engine/object-field.d.ts +2 -2
  70. package/engine/object-field.lua +4 -0
  71. package/engine/standard/entries/sound-preset.d.ts +10 -0
  72. package/engine/standard/entries/sound-preset.lua +10 -0
  73. package/engine/unit.d.ts +1 -0
  74. package/engine/unit.lua +1 -0
  75. package/objutil/unit.lua +8 -0
  76. package/package.json +2 -2
@@ -1,7 +1,7 @@
1
1
  /** @noSelfInFile */
2
2
  import { AttachmentPreset, AttachmentPresetInput } from "./auxiliary/attachment-preset";
3
3
  import { MutableKeys } from "../../utility/types";
4
- export type ObjectDataEntryId = number & {
4
+ export type ObjectDataEntryId = (number | string) & {
5
5
  readonly __objectDataEntryId: unique symbol;
6
6
  };
7
7
  export type ObjectDataEntryIdType<T extends ObjectDataEntry> = T extends ObjectDataEntry<infer Id> ? Id : never;
@@ -14,18 +14,20 @@ 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;
17
18
  protected static readonly IS_SYNTHETIC: boolean;
18
19
  private readonly levelFieldParametersByField;
19
20
  private readonly maxAffectedLevelByField;
20
21
  private _isInternal;
22
+ private get type();
21
23
  get isInternal(): boolean;
22
- protected static generateId(): number;
24
+ protected static generateId(): number | string;
23
25
  protected static getObjectData(map: WarMap): WarObjects;
24
- static getAllIdsByBaseIds<T extends ObjectDataEntry>(this: ObjectDataEntryAbstractConstructor<T>, baseIds: number | number[]): ObjectDataEntryIdType<T>[];
26
+ static getAllIdsByBaseIds<T extends ObjectDataEntry>(this: ObjectDataEntryAbstractConstructor<T>, baseIds: number | number[] | string | string[]): ObjectDataEntryIdType<T>[];
25
27
  static create<T extends ObjectDataEntry>(this: ObjectDataEntryConstructor<T>, ...args: [id?: number, properties?: ObjectDataEntryProperties<T>] | [properties: ObjectDataEntryProperties<T>]): T;
26
- static getAllByBaseIds<T extends ObjectDataEntry>(this: ObjectDataEntryAbstractConstructor<T>, baseIds: number | number[]): T[];
28
+ static getAllByBaseIds<T extends ObjectDataEntry>(this: ObjectDataEntryAbstractConstructor<T>, baseIds: number | number[] | string | string[]): T[];
27
29
  static getAll<T extends ObjectDataEntry>(this: ObjectDataEntryAbstractConstructor<T>): T[];
28
- static of<T extends ObjectDataEntry>(this: ObjectDataEntryAbstractConstructor<T>, id: number): T | undefined;
30
+ static of<T extends ObjectDataEntry>(this: ObjectDataEntryAbstractConstructor<T>, id: number | string): T | undefined;
29
31
  constructor(object: WarObject);
30
32
  get id(): Id;
31
33
  get baseId(): Id;
@@ -42,8 +44,8 @@ export declare abstract class ObjectDataEntry<Id extends ObjectDataEntryId = Obj
42
44
  protected setNumberField(field: string, value: number): void;
43
45
  protected getStringField(field: string): string;
44
46
  protected setStringField(field: string, value: string): void;
45
- protected getObjectDataEntryIdField<Id extends ObjectDataEntryId>(field: string): Id;
46
- protected setObjectDataEntryIdField<Id extends ObjectDataEntryId>(field: string, value: Id): void;
47
+ protected getObjectDataEntryNumericIdField<Id extends ObjectDataEntryId & number>(field: string): Id;
48
+ protected setObjectDataEntryNumericIdField<Id extends ObjectDataEntryId & number>(field: string, value: Id): void;
47
49
  protected getAttachmentPresetField(modelPathField: string, nodeFQNField: string): AttachmentPreset | undefined;
48
50
  protected setAttachmentPresetField(modelPathField: string, nodeFQNField: string, attachmentPreset: AttachmentPresetInput | undefined): void;
49
51
  protected getBooleansField(field: string): boolean[];
@@ -52,8 +54,8 @@ export declare abstract class ObjectDataEntry<Id extends ObjectDataEntryId = Obj
52
54
  protected setNumbersField(field: string, values: number[]): void;
53
55
  protected getStringsField(field: string): string[];
54
56
  protected setStringsField(field: string, values: string[]): void;
55
- protected getObjectDataEntryIdsField<Id extends ObjectDataEntryId>(field: string): Id[];
56
- protected setObjectDataEntryIdsField<Id extends ObjectDataEntryId>(field: string, values: Id[]): void;
57
+ protected getObjectDataEntryNumericIdsField<Id extends ObjectDataEntryId & number>(field: string): Id[];
58
+ protected setObjectDataEntryNumericIdsField<Id extends ObjectDataEntryId & number>(field: string, values: Id[]): void;
57
59
  protected getAttachmentPresetListField(modelPathListField: string, nodeFQNFields: string[]): AttachmentPreset[];
58
60
  protected setAttachmentPresetListField(modelPathListField: string, nodeFQNFields: string[], lengthField: string, attachmentPresets: AttachmentPresetInput[]): void;
59
61
  protected setFlagLevelFieldValue(fieldId: string, flag: 1 | 2 | 4 | 8 | 16, supplier: ObjectDataEntryLevelFieldValueSupplier<boolean>): void;
@@ -64,16 +66,16 @@ export declare abstract class ObjectDataEntry<Id extends ObjectDataEntryId = Obj
64
66
  protected setNumberLevelField(field: string, values: ObjectDataEntryLevelFieldValueSupplier<number>): void;
65
67
  protected getStringLevelField(field: string): string[];
66
68
  protected setStringLevelField(field: string, values: ObjectDataEntryLevelFieldValueSupplier<string>): void;
67
- protected getObjectDataEntryIdLevelField<Id extends ObjectDataEntryId>(field: string): Id[];
68
- protected setObjectDataEntryIdLevelField<Id extends ObjectDataEntryId>(field: string, values: ObjectDataEntryLevelFieldValueSupplier<Id>): void;
69
+ protected getObjectDataEntryNumericIdLevelField<Id extends ObjectDataEntryId & number>(field: string): Id[];
70
+ protected setObjectDataEntryNumericIdLevelField<Id extends ObjectDataEntryId & number>(field: string, values: ObjectDataEntryLevelFieldValueSupplier<Id>): void;
69
71
  protected getBooleansLevelField(field: string): boolean[][];
70
72
  protected setBooleansLevelField(field: string, values: ObjectDataEntryLevelFieldValueSupplier<boolean[]>): void;
71
73
  protected getNumbersLevelField(field: string): number[][];
72
74
  protected setNumbersLevelField(field: string, values: ObjectDataEntryLevelFieldValueSupplier<number[]>): void;
73
75
  protected getStringsLevelField(field: string): string[][];
74
76
  protected setStringsLevelField(field: string, values: ObjectDataEntryLevelFieldValueSupplier<string[]>): void;
75
- protected getObjectDataEntryIdsLevelField<T extends ObjectDataEntryId>(field: string): T[][];
76
- protected setObjectDataEntryIdsLevelField<T extends ObjectDataEntryId>(field: string, values: ObjectDataEntryLevelFieldValueSupplier<T[]>): void;
77
+ protected getObjectDataEntryNumericIdsLevelField<T extends ObjectDataEntryId & number>(field: string): T[][];
78
+ protected setObjectDataEntryNumericIdsLevelField<T extends ObjectDataEntryId & number>(field: string, values: ObjectDataEntryLevelFieldValueSupplier<T[]>): void;
77
79
  private getLevelField;
78
80
  private setLevelField;
79
81
  }
@@ -10,7 +10,7 @@ local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
10
10
  local __TS__StringSplit = ____lualib.__TS__StringSplit
11
11
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
12
12
  local ____exports = {}
13
- local booleanToData, dataToBoolean, numberToData, dataToNumber, stringToData, dataToString, objectDataEntryIdToData, dataToObjectDataEntryId, booleansToData, dataToBooleans, numbersToData, dataToNumbers, stringsToData, dataToStrings, objectDataEntryIdsToData, dataToObjectDataEntryIds, isDataNotBlank
13
+ local booleanToData, dataToBoolean, numberToData, dataToNumber, stringToData, dataToString, objectDataEntryNumericIdToData, dataToObjectDataEntryNumericId, objectDataEntryIdToData, dataToObjectDataEntryId, booleansToData, dataToBooleans, numbersToData, dataToNumbers, stringsToData, dataToStrings, objectDataEntryNumericIdsToData, dataToObjectDataEntryNumericIds, isDataNotBlank
14
14
  local ____attachment_2Dpreset = require("engine.object-data.auxiliary.attachment-preset")
15
15
  local extractAttachmentPresetInputModelPath = ____attachment_2Dpreset.extractAttachmentPresetInputModelPath
16
16
  local extractAttachmentPresetInputNodeFQN = ____attachment_2Dpreset.extractAttachmentPresetInputNodeFQN
@@ -124,7 +124,7 @@ function ObjectDataEntry.getAllByBaseIds(self, baseIds)
124
124
  local constructor = self
125
125
  for id, object in pairs(constructor:getObjectData(currentMap).all) do
126
126
  if dataBaseIds[object.parentId or id] ~= nil then
127
- local objectDataEntry = self:of(dataToObjectDataEntryId(id))
127
+ local objectDataEntry = self:of(dataToObjectDataEntryId(id, self.ID_TYPE))
128
128
  if objectDataEntry ~= nil and not objectDataEntry.isInternal then
129
129
  result[#result + 1] = objectDataEntry
130
130
  end
@@ -139,7 +139,7 @@ function ObjectDataEntry.getAll(self)
139
139
  local constructor = self
140
140
  local result = {}
141
141
  for id in pairs(constructor:getObjectData(currentMap).all) do
142
- local objectDataEntry = self:of(dataToObjectDataEntryId(id))
142
+ local objectDataEntry = self:of(dataToObjectDataEntryId(id, self.ID_TYPE))
143
143
  if objectDataEntry ~= nil and not objectDataEntry.isInternal then
144
144
  result[#result + 1] = objectDataEntry
145
145
  end
@@ -156,9 +156,9 @@ function ObjectDataEntry.of(self, id)
156
156
  if object == nil then
157
157
  return nil
158
158
  end
159
- local objectDataEntry = objectDataEntryByObjectDataEntryId[dataToObjectDataEntryId(object.id)]
159
+ local objectDataEntry = objectDataEntryByObjectDataEntryId[dataToObjectDataEntryId(object.id, self.ID_TYPE)]
160
160
  if objectDataEntry == nil then
161
- if not constructor.IS_SYNTHETIC and (self.BASE_ID == 0 or dataToObjectDataEntryId(object.parentId) == self.BASE_ID) then
161
+ if not constructor.IS_SYNTHETIC and (self.BASE_ID == 0 or dataToObjectDataEntryId(object.parentId, self.ID_TYPE) == self.BASE_ID) then
162
162
  local AbstractObjectDataEntryView = __TS__Class()
163
163
  AbstractObjectDataEntryView.name = "AbstractObjectDataEntryView"
164
164
  __TS__ClassExtends(AbstractObjectDataEntryView, constructor)
@@ -231,13 +231,13 @@ function ObjectDataEntry.prototype.setStringField(self, field, value)
231
231
  stringToData(value)
232
232
  )
233
233
  end
234
- function ObjectDataEntry.prototype.getObjectDataEntryIdField(self, field)
235
- return dataToObjectDataEntryId(self.object:getField(field))
234
+ function ObjectDataEntry.prototype.getObjectDataEntryNumericIdField(self, field)
235
+ return dataToObjectDataEntryNumericId(self.object:getField(field))
236
236
  end
237
- function ObjectDataEntry.prototype.setObjectDataEntryIdField(self, field, value)
237
+ function ObjectDataEntry.prototype.setObjectDataEntryNumericIdField(self, field, value)
238
238
  self.object:setField(
239
239
  field,
240
- objectDataEntryIdToData(value)
240
+ objectDataEntryNumericIdToData(value)
241
241
  )
242
242
  end
243
243
  function ObjectDataEntry.prototype.getAttachmentPresetField(self, modelPathField, nodeFQNField)
@@ -285,13 +285,13 @@ function ObjectDataEntry.prototype.setStringsField(self, field, values)
285
285
  stringsToData(values)
286
286
  )
287
287
  end
288
- function ObjectDataEntry.prototype.getObjectDataEntryIdsField(self, field)
289
- return dataToObjectDataEntryIds(self.object:getField(field))
288
+ function ObjectDataEntry.prototype.getObjectDataEntryNumericIdsField(self, field)
289
+ return dataToObjectDataEntryNumericIds(self.object:getField(field))
290
290
  end
291
- function ObjectDataEntry.prototype.setObjectDataEntryIdsField(self, field, values)
291
+ function ObjectDataEntry.prototype.setObjectDataEntryNumericIdsField(self, field, values)
292
292
  self.object:setField(
293
293
  field,
294
- objectDataEntryIdsToData(values)
294
+ objectDataEntryNumericIdsToData(values)
295
295
  )
296
296
  end
297
297
  function ObjectDataEntry.prototype.getAttachmentPresetListField(self, modelPathListField, nodeFQNFields)
@@ -369,16 +369,16 @@ function ObjectDataEntry.prototype.setStringLevelField(self, field, values)
369
369
  stringToData
370
370
  )
371
371
  end
372
- function ObjectDataEntry.prototype.getObjectDataEntryIdLevelField(self, field)
373
- return self:getLevelField(field, dataToObjectDataEntryId)
372
+ function ObjectDataEntry.prototype.getObjectDataEntryNumericIdLevelField(self, field)
373
+ return self:getLevelField(field, dataToObjectDataEntryNumericId)
374
374
  end
375
- function ObjectDataEntry.prototype.setObjectDataEntryIdLevelField(self, field, values)
375
+ function ObjectDataEntry.prototype.setObjectDataEntryNumericIdLevelField(self, field, values)
376
376
  self:setLevelField(
377
377
  field,
378
378
  values,
379
379
  ____exports.extractObjectDataEntryLevelFieldValue,
380
- dataToObjectDataEntryId,
381
- objectDataEntryIdToData
380
+ dataToObjectDataEntryNumericId,
381
+ objectDataEntryNumericIdToData
382
382
  )
383
383
  end
384
384
  function ObjectDataEntry.prototype.getBooleansLevelField(self, field)
@@ -417,23 +417,26 @@ function ObjectDataEntry.prototype.setStringsLevelField(self, field, values)
417
417
  stringsToData
418
418
  )
419
419
  end
420
- function ObjectDataEntry.prototype.getObjectDataEntryIdsLevelField(self, field)
421
- return self:getLevelField(field, dataToObjectDataEntryIds)
420
+ function ObjectDataEntry.prototype.getObjectDataEntryNumericIdsLevelField(self, field)
421
+ return self:getLevelField(field, dataToObjectDataEntryNumericIds)
422
422
  end
423
- function ObjectDataEntry.prototype.setObjectDataEntryIdsLevelField(self, field, values)
423
+ function ObjectDataEntry.prototype.setObjectDataEntryNumericIdsLevelField(self, field, values)
424
424
  self:setLevelField(
425
425
  field,
426
426
  values,
427
427
  ____exports.extractObjectDataEntryLevelArrayFieldValue,
428
- dataToObjectDataEntryIds,
429
- objectDataEntryIdsToData
428
+ dataToObjectDataEntryNumericIds,
429
+ objectDataEntryNumericIdsToData
430
430
  )
431
431
  end
432
432
  function ObjectDataEntry.prototype.getLevelField(self, field, dataToValue)
433
433
  local values = {}
434
434
  local object = self.object
435
435
  for level = 1, tonumber(object:getField("levels")) or 1 do
436
- values[level] = dataToValue(object:getField((field .. "+") .. tostring(level)))
436
+ values[level] = dataToValue(
437
+ object:getField((field .. "+") .. tostring(level)),
438
+ "number"
439
+ )
437
440
  end
438
441
  return values
439
442
  end
@@ -472,7 +475,16 @@ function ObjectDataEntry.prototype.setLevelField(self, field, supplier, extracto
472
475
  end
473
476
  end
474
477
  ObjectDataEntry.BASE_ID = 0
478
+ ObjectDataEntry.ID_TYPE = type(self.BASE_ID) == "number" and "number" or "string"
475
479
  ObjectDataEntry.IS_SYNTHETIC = false
480
+ __TS__SetDescriptor(
481
+ ObjectDataEntry.prototype,
482
+ "type",
483
+ {get = function(self)
484
+ return self.constructor
485
+ end},
486
+ true
487
+ )
476
488
  __TS__SetDescriptor(
477
489
  ObjectDataEntry.prototype,
478
490
  "isInternal",
@@ -495,7 +507,7 @@ __TS__SetDescriptor(
495
507
  ObjectDataEntry.prototype,
496
508
  "id",
497
509
  {get = function(self)
498
- return dataToObjectDataEntryId(self.object.id)
510
+ return dataToObjectDataEntryId(self.object.id, self.type.ID_TYPE)
499
511
  end},
500
512
  true
501
513
  )
@@ -503,7 +515,7 @@ __TS__SetDescriptor(
503
515
  ObjectDataEntry.prototype,
504
516
  "baseId",
505
517
  {get = function(self)
506
- return dataToObjectDataEntryId(self.object.parentId or self.object.id)
518
+ return dataToObjectDataEntryId(self.object.parentId or self.object.id, self.type.ID_TYPE)
507
519
  end},
508
520
  true
509
521
  )
@@ -533,10 +545,10 @@ end
533
545
  dataToString = function(data)
534
546
  return tostring(data or "")
535
547
  end
536
- objectDataEntryIdToData = function(value)
548
+ objectDataEntryNumericIdToData = function(value)
537
549
  return value == 0 and "" or string.pack(">I4", value)
538
550
  end
539
- dataToObjectDataEntryId = function(data)
551
+ dataToObjectDataEntryNumericId = function(data)
540
552
  local dataString = dataToString(data)
541
553
  if isDataNotBlank(nil, dataString) then
542
554
  return (string.unpack(">I4", dataString))
@@ -544,6 +556,15 @@ dataToObjectDataEntryId = function(data)
544
556
  return 0
545
557
  end
546
558
  end
559
+ objectDataEntryIdToData = function(value)
560
+ return type(value) == "number" and objectDataEntryNumericIdToData(value) or value
561
+ end
562
+ dataToObjectDataEntryId = function(data, ____type)
563
+ if ____type == "number" then
564
+ return dataToObjectDataEntryNumericId(data)
565
+ end
566
+ return dataToString(data)
567
+ end
547
568
  booleansToData = function(value)
548
569
  return table.concat(
549
570
  __TS__ArrayMap(
@@ -607,16 +628,16 @@ dataToStrings = function(data)
607
628
  function(____, data) return dataToString(data) end
608
629
  )
609
630
  end
610
- objectDataEntryIdsToData = function(value)
631
+ objectDataEntryNumericIdsToData = function(value)
611
632
  return table.concat(
612
633
  __TS__ArrayMap(
613
634
  value,
614
- function(____, objectDataEntryId) return objectDataEntryIdToData(objectDataEntryId) end
635
+ function(____, objectDataEntryId) return objectDataEntryNumericIdToData(objectDataEntryId) end
615
636
  ),
616
637
  ","
617
638
  )
618
639
  end
619
- dataToObjectDataEntryIds = function(data)
640
+ dataToObjectDataEntryNumericIds = function(data)
620
641
  return __TS__ArrayMap(
621
642
  __TS__ArrayFilter(
622
643
  __TS__StringSplit(
@@ -625,7 +646,7 @@ dataToObjectDataEntryIds = function(data)
625
646
  ),
626
647
  isDataNotBlank
627
648
  ),
628
- function(____, data) return dataToObjectDataEntryId(data) end
649
+ function(____, data) return dataToObjectDataEntryNumericId(data) end
629
650
  )
630
651
  end
631
652
  isDataNotBlank = function(self, data)
@@ -1,5 +1,6 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__New = ____lualib.__TS__New
3
4
  local ____exports = {}
4
5
  local ____preconditions = require("utility.preconditions")
5
6
  local checkNotNull = ____preconditions.checkNotNull
@@ -60,4 +61,10 @@ function ObjectDataEntryIdGenerator.prototype.next(self)
60
61
  self.id = id
61
62
  return id
62
63
  end
64
+ ---
65
+ -- @internal For use by internal systems only.
66
+ ____exports.abilityTypeIdGenerator = __TS__New(
67
+ ____exports.ObjectDataEntryIdGenerator,
68
+ fourCC("A000")
69
+ )
63
70
  return ____exports
@@ -45,9 +45,10 @@ export declare class AbilityStringField extends AbilityField<string, jabilitystr
45
45
  protected setNativeFieldValue(instance: Ability, value: string): boolean;
46
46
  static get valueChangeEvent(): ObjectFieldValueChangeEvent<AbilityStringField>;
47
47
  }
48
- export declare abstract class AbilityArrayField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType = unknown> extends ObjectArrayField<AbilityType, Ability, ValueType, NativeFieldType> {
48
+ export declare abstract class AbilityArrayField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType extends jabilityfield = jabilityfield> extends ObjectArrayField<AbilityType, Ability, ValueType, NativeFieldType> {
49
49
  protected get instanceClass(): typeof Ability;
50
50
  protected getObjectDataEntryId(instance: Ability): AbilityTypeId;
51
+ protected hasNativeFieldValue(instance: Ability): boolean;
51
52
  }
52
53
  export declare class AbilityStringArrayField extends AbilityArrayField<string, jabilitystringlevelfield> {
53
54
  protected get defaultValue(): string;
@@ -130,7 +131,9 @@ export declare class AbilityCombatClassificationsLevelField extends AbilityLevel
130
131
  protected getNativeFieldValue(instance: Ability, level: number): CombatClassifications;
131
132
  protected setNativeFieldValue(instance: Ability, level: number, value: CombatClassifications): boolean;
132
133
  }
133
- export type AbilityDependentValue<ValueType extends boolean | number | string> = ValueType | AbilityField<ValueType> | AbilityLevelField<ValueType> | ((ability: Ability) => ValueType);
134
+ export type ReadonlySubscribableAbilityDependentValue<ValueType extends boolean | number | string> = ValueType | ReadonlyObjectFieldType<AbilityField<ValueType>> | ReadonlyObjectLevelFieldType<AbilityLevelField<ValueType>>;
135
+ export type SubscribableAbilityDependentValue<ValueType extends boolean | number | string> = ValueType | AbilityField<ValueType> | AbilityLevelField<ValueType>;
136
+ export type AbilityDependentValue<ValueType extends boolean | number | string> = SubscribableAbilityDependentValue<ValueType> | ((ability: Ability) => ValueType);
134
137
  export declare const resolveCurrentAbilityDependentValue: {
135
138
  <ValueType extends boolean | number | string>(ability: Ability, value: AbilityDependentValue<ValueType>): ValueType;
136
139
  <ValueType extends boolean | number | string>(ability: Ability, value?: AbilityDependentValue<ValueType>): ValueType | undefined;
@@ -197,6 +197,9 @@ __TS__ClassExtends(AbilityArrayField, ObjectArrayField)
197
197
  function AbilityArrayField.prototype.getObjectDataEntryId(self, instance)
198
198
  return instance.typeId
199
199
  end
200
+ function AbilityArrayField.prototype.hasNativeFieldValue(self, instance)
201
+ return instance:hasField(self.nativeField)
202
+ end
200
203
  __TS__SetDescriptor(
201
204
  AbilityArrayField.prototype,
202
205
  "instanceClass",
@@ -16,6 +16,8 @@ declare abstract class ObjectFieldBase<ObjectDataEntryType extends ObjectDataEnt
16
16
  readonly id: ObjectFieldId;
17
17
  protected abstract getNativeFieldById(id: number): NativeFieldType;
18
18
  protected abstract getObjectDataEntryId(instance: InstanceType): ObjectDataEntryIdType<ObjectDataEntryType>;
19
+ protected abstract hasNativeFieldValue(instance: InstanceType): boolean;
20
+ hasValue(instance: InstanceType): boolean;
19
21
  constructor(id: number);
20
22
  static create<T extends ObjectFieldBase<any, any, any, any>>(this: ObjectFieldConstructor<T>, id?: number): T & symbol;
21
23
  static of<T extends ObjectFieldBase<any, any, any, any>>(this: ObjectFieldAbstractConstructor<T>, id: number): T | undefined;
@@ -35,7 +37,6 @@ export type ReadonlyObjectFieldType<T extends ObjectField<any, any, any, any>> =
35
37
  type ReadonlyObjectFieldConstructor<T extends ObjectField> = OmitConstructor<typeof ObjectField> & (abstract new (...args: any[]) => ReadonlyObjectFieldType<T>);
36
38
  export declare abstract class ObjectField<ObjectDataEntryType extends ObjectDataEntry = ObjectDataEntry, InstanceType extends AnyNotNil = AnyNotNil, ValueType extends number | string | boolean = number | string | boolean, NativeFieldType = unknown> extends ObjectFieldBase<ObjectDataEntryType, InstanceType, ValueType, NativeFieldType> {
37
39
  protected abstract readonly defaultValue: ValueType;
38
- protected abstract hasNativeFieldValue(instance: InstanceType): boolean;
39
40
  protected abstract getNativeFieldValue(instance: InstanceType): ValueType;
40
41
  protected abstract setNativeFieldValue(instance: InstanceType, value: ValueType): boolean;
41
42
  getValue(entry: ObjectDataEntryType | InstanceType): ValueType;
@@ -71,7 +72,6 @@ export declare abstract class ObjectArrayField<ObjectDataEntryType extends Objec
71
72
  }
72
73
  export declare abstract class ObjectLevelField<ObjectDataEntryType extends ObjectDataEntry = ObjectDataEntry, InstanceType extends AnyNotNil = AnyNotNil, ValueType extends number | string | boolean = number | string | boolean, InputValueType extends ValueType = never, NativeFieldType = unknown> extends ObjectFieldBase<ObjectDataEntryType, InstanceType, ValueType[], NativeFieldType> {
73
74
  protected abstract readonly defaultValue: ValueType;
74
- protected abstract hasNativeFieldValue(instance: InstanceType): boolean;
75
75
  protected abstract getNativeFieldValue(instance: InstanceType, level: number): ValueType;
76
76
  protected abstract setNativeFieldValue(instance: InstanceType, level: number, value: ValueType): boolean;
77
77
  protected abstract getLevelCount(entry: ObjectDataEntryType | InstanceType): number;
@@ -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
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", v)
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", v)
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.359b41a",
4
+ "version": "0.0.1-dev.3806ba5",
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.57dfac2"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@typescript-eslint/eslint-plugin": "^8.13.0",