warscript 0.0.1-dev.46a1ede → 0.0.1-dev.47f470c

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 (38) hide show
  1. package/config.d.ts +5 -0
  2. package/config.lua +10 -0
  3. package/core/types/sound.d.ts +1 -0
  4. package/core/types/sound.lua +32 -2
  5. package/engine/buff.d.ts +4 -1
  6. package/engine/buff.lua +78 -68
  7. package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
  8. package/engine/object-data/auxiliary/animation-name.lua +16 -0
  9. package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
  10. package/engine/object-data/entry/ability-type/blank-configurable.lua +21 -1
  11. package/engine/object-data/entry/ability-type/curse.lua +2 -2
  12. package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
  13. package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
  14. package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
  15. package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
  16. package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
  17. package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
  18. package/engine/object-data/entry/ability-type.d.ts +1 -1
  19. package/engine/object-data/entry/ability-type.lua +8 -8
  20. package/engine/object-data/entry/buff-type/applicable.lua +10 -34
  21. package/engine/object-data/entry/buff-type.d.ts +1 -1
  22. package/engine/object-data/entry/buff-type.lua +2 -2
  23. package/engine/object-data/entry/destructible-type.d.ts +1 -1
  24. package/engine/object-data/entry/item-type.d.ts +1 -1
  25. package/engine/object-data/entry/item-type.lua +4 -4
  26. package/engine/object-data/entry/lightning-type.d.ts +1 -1
  27. package/engine/object-data/entry/sound-preset.d.ts +17 -0
  28. package/engine/object-data/entry/sound-preset.lua +50 -0
  29. package/engine/object-data/entry/unit-type.d.ts +8 -1
  30. package/engine/object-data/entry/unit-type.lua +61 -8
  31. package/engine/object-data/entry/upgrade.d.ts +1 -1
  32. package/engine/object-data/entry/upgrade.lua +4 -4
  33. package/engine/object-data/entry.d.ts +15 -13
  34. package/engine/object-data/entry.lua +53 -32
  35. package/engine/standard/entries/sound-preset.d.ts +10 -0
  36. package/engine/standard/entries/sound-preset.lua +10 -0
  37. package/objutil/unit.lua +8 -0
  38. package/package.json +2 -2
@@ -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)
@@ -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/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.46a1ede",
4
+ "version": "0.0.1-dev.47f470c",
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.57dfac2"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@typescript-eslint/eslint-plugin": "^8.13.0",