warscript 0.0.1-dev.9048d45 → 0.0.1-dev.90f1d49

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 (82) hide show
  1. package/attributes.d.ts +7 -0
  2. package/attributes.lua +8 -1
  3. package/core/types/effect.d.ts +1 -3
  4. package/core/types/effect.lua +26 -29
  5. package/core/types/sound.d.ts +17 -25
  6. package/core/types/sound.lua +85 -44
  7. package/core/types/timer.d.ts +6 -7
  8. package/core/types/timer.lua +18 -21
  9. package/decl/native.d.ts +840 -786
  10. package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
  11. package/engine/behaviour/ability/damage.d.ts +9 -3
  12. package/engine/behaviour/ability/damage.lua +26 -38
  13. package/engine/behaviour/ability/emulate-impact.lua +7 -0
  14. package/engine/behaviour/ability.d.ts +5 -1
  15. package/engine/behaviour/ability.lua +18 -4
  16. package/engine/behaviour/unit.d.ts +2 -0
  17. package/engine/buff.d.ts +13 -8
  18. package/engine/buff.lua +81 -50
  19. package/engine/internal/item.d.ts +2 -1
  20. package/engine/internal/mechanics/ability-duration.lua +1 -1
  21. package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
  22. package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
  23. package/engine/internal/unit+damage.d.ts +2 -11
  24. package/engine/internal/unit+damage.lua +10 -14
  25. package/engine/internal/unit+spellSteal.lua +1 -2
  26. package/engine/internal/unit.d.ts +18 -3
  27. package/engine/internal/unit.lua +94 -33
  28. package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
  29. package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
  30. package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
  31. package/engine/object-data/auxiliary/attack-type.lua +42 -0
  32. package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
  33. package/engine/object-data/auxiliary/movement-type.lua +22 -0
  34. package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
  35. package/engine/object-data/auxiliary/sound-eax.lua +2 -0
  36. package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
  37. package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
  38. package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
  39. package/engine/object-data/entry/ability-type/berserk.lua +13 -0
  40. package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
  41. package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
  42. package/engine/object-data/entry/ability-type/curse.lua +2 -2
  43. package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
  44. package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
  45. package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
  46. package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
  47. package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
  48. package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
  49. package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
  50. package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
  51. package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
  52. package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
  53. package/engine/object-data/entry/ability-type/web.d.ts +12 -0
  54. package/engine/object-data/entry/ability-type/web.lua +52 -0
  55. package/engine/object-data/entry/ability-type.d.ts +11 -11
  56. package/engine/object-data/entry/ability-type.lua +31 -10
  57. package/engine/object-data/entry/buff-type/applicable.lua +5 -0
  58. package/engine/object-data/entry/buff-type.d.ts +5 -11
  59. package/engine/object-data/entry/buff-type.lua +11 -27
  60. package/engine/object-data/entry/sound-preset.d.ts +17 -0
  61. package/engine/object-data/entry/sound-preset.lua +104 -0
  62. package/engine/object-data/entry/unit-type.d.ts +2 -2
  63. package/engine/object-data/entry/unit-type.lua +94 -84
  64. package/engine/object-field/ability.d.ts +1 -1
  65. package/engine/object-field/unit.d.ts +46 -3
  66. package/engine/object-field/unit.lua +173 -7
  67. package/engine/object-field.d.ts +9 -1
  68. package/engine/object-field.lua +158 -76
  69. package/engine/standard/entries/buff-type.d.ts +3 -0
  70. package/engine/standard/entries/buff-type.lua +3 -0
  71. package/objutil/buff.lua +1 -2
  72. package/package.json +2 -2
  73. package/utility/arrays.d.ts +1 -0
  74. package/utility/arrays.lua +3 -0
  75. package/utility/functions.d.ts +1 -0
  76. package/utility/functions.lua +1 -0
  77. package/utility/linked-set.d.ts +1 -0
  78. package/utility/linked-set.lua +3 -0
  79. package/utility/lua-maps.d.ts +3 -0
  80. package/utility/lua-maps.lua +16 -0
  81. package/utility/lua-sets.d.ts +1 -0
  82. package/utility/lua-sets.lua +3 -0
@@ -1,15 +1,6 @@
1
1
  /** @noSelfInFile */
2
2
  import { Widget } from "../../core/types/widget";
3
- export type AttackType = jattacktype;
4
- export declare namespace AttackType {
5
- const SPELL: jattacktype;
6
- const NORMAL: jattacktype;
7
- const PIERCE: jattacktype;
8
- const SIEGE: jattacktype;
9
- const MAGIC: jattacktype;
10
- const CHAOS: jattacktype;
11
- const HERO: jattacktype;
12
- }
3
+ import { AttackType } from "../object-data/auxiliary/attack-type";
13
4
  export type DamageType = jdamagetype;
14
5
  export declare namespace DamageType {
15
6
  const UNKNOWN: jdamagetype;
@@ -64,6 +55,6 @@ export declare namespace WeaponType {
64
55
  }
65
56
  declare module "./unit" {
66
57
  interface Unit {
67
- damageTarget(target: Widget, amount: number, attack?: boolean, ranged?: boolean, attackType?: AttackType, damageType?: DamageType, weaponType?: WeaponType): boolean;
58
+ damageTarget(target: Widget, amount: number, attack?: boolean, ranged?: boolean, attackType?: AttackType, damageType?: DamageType, weaponType?: WeaponType, metadata?: unknown): boolean;
68
59
  }
69
60
  }
@@ -7,21 +7,14 @@ local ____player = require("core.types.player")
7
7
  local Player = ____player.Player
8
8
  local ____dummy = require("objutil.dummy")
9
9
  local dummyUnitId = ____dummy.dummyUnitId
10
+ local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
11
+ local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
12
+ local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
13
+ local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
10
14
  local createUnit = CreateUnit
11
15
  local getOwningPlayer = GetOwningPlayer
12
16
  local showUnit = ShowUnit
13
17
  local unitDamageTarget = UnitDamageTarget
14
- ____exports.AttackType = {}
15
- local AttackType = ____exports.AttackType
16
- do
17
- AttackType.SPELL = ATTACK_TYPE_NORMAL
18
- AttackType.NORMAL = ATTACK_TYPE_MELEE
19
- AttackType.PIERCE = ATTACK_TYPE_PIERCE
20
- AttackType.SIEGE = ATTACK_TYPE_SIEGE
21
- AttackType.MAGIC = ATTACK_TYPE_MAGIC
22
- AttackType.CHAOS = ATTACK_TYPE_CHAOS
23
- AttackType.HERO = ATTACK_TYPE_HERO
24
- end
25
18
  ____exports.DamageType = {}
26
19
  local DamageType = ____exports.DamageType
27
20
  do
@@ -88,7 +81,7 @@ for ____, player in ipairs(Player.all) do
88
81
  showUnit(dummy, false)
89
82
  dummies[player] = dummy
90
83
  end
91
- Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, attackType, damageType, weaponType)
84
+ Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, attackType, damageType, weaponType, metadata)
92
85
  if attack == nil then
93
86
  attack = false
94
87
  end
@@ -96,7 +89,7 @@ Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, att
96
89
  ranged = false
97
90
  end
98
91
  if attackType == nil then
99
- attackType = ____exports.AttackType.SPELL
92
+ attackType = 0
100
93
  end
101
94
  if damageType == nil then
102
95
  damageType = ____exports.DamageType.MAGIC
@@ -109,13 +102,16 @@ Unit.prototype.damageTarget = function(self, target, amount, attack, ranged, att
109
102
  if not getOwningPlayer(handle) then
110
103
  handle = dummies[__TS__InstanceOf(target, Unit) and target.owner or (self._owner or Player.neutralAggressive)]
111
104
  end
105
+ if __TS__InstanceOf(target, Unit) then
106
+ damageMetadataByTarget[target] = metadata
107
+ end
112
108
  return unitDamageTarget(
113
109
  handle,
114
110
  targetHandle,
115
111
  amount,
116
112
  attack,
117
113
  ranged,
118
- attackType,
114
+ attackTypeToNative(attackType),
119
115
  damageType,
120
116
  weaponType
121
117
  )
@@ -6,7 +6,6 @@ local ____exports = {}
6
6
  local ____unit = require("engine.internal.unit")
7
7
  local Unit = ____unit.Unit
8
8
  local ____unit_2Bdamage = require("engine.internal.unit+damage")
9
- local AttackType = ____unit_2Bdamage.AttackType
10
9
  local DamageType = ____unit_2Bdamage.DamageType
11
10
  local ____event = require("event")
12
11
  local Event = ____event.Event
@@ -33,7 +32,7 @@ local spellStealEventStack = {}
33
32
  Unit.onDamaging:addListener(function(source, target, event)
34
33
  if event.amount == 0 and source ~= nil then
35
34
  local count = countByUnit[source] or 0
36
- if count > 0 and event.attackType == AttackType.SPELL then
35
+ if count > 0 and event.attackType == 0 then
37
36
  if event.damageType == DamageType.UNKNOWN then
38
37
  spellStealEventStack[#spellStealEventStack + 1] = {
39
38
  sourceBuffIds = source.buffIds,
@@ -11,6 +11,10 @@ import { Ability, UnitAbility } from "./ability";
11
11
  import { Widget } from "../../core/types/widget";
12
12
  import type { UnitTypeId } from "../object-data/entry/unit-type";
13
13
  import { CombatClassification, CombatClassifications } from "../object-data/auxiliary/combat-classification";
14
+ import { MovementType } from "../object-data/auxiliary/movement-type";
15
+ import { UnitAttribute } from "../object-data/auxiliary/unit-attribute";
16
+ import { AttackType } from "../object-data/auxiliary/attack-type";
17
+ import { AttributesHolder } from "../../attributes";
14
18
  export type UnitClassification = junittype;
15
19
  export declare namespace UnitClassification {
16
20
  const STRUCTURE: junittype;
@@ -36,13 +40,15 @@ type AbilityDispatcherTable<T extends any[] = []> = {
36
40
  readonly [id: number]: Event<[Unit, Ability, ...T]>;
37
41
  };
38
42
  type AbilityEventDispatcher<T extends any[] = []> = Event<[Unit, Ability, ...T]> & AbilityDispatcherTable<T>;
39
- export interface DamagingEvent {
43
+ export interface DamagingEvent extends AttributesHolder {
40
44
  amount: number;
41
- attackType: jattacktype;
45
+ attackType: AttackType;
42
46
  damageType: jdamagetype;
43
47
  weaponType: jweapontype;
48
+ metadata: unknown;
44
49
  readonly isAttack: boolean;
45
50
  readonly originalAmount: number;
51
+ readonly originalMetadata: unknown;
46
52
  }
47
53
  export type DamageEvent = DamagingEvent & {
48
54
  preventDeath<P extends any[]>(this: DamageEvent, callback: (this: void, ...parameters: P) => any, ...parameters: P): void;
@@ -100,7 +106,9 @@ declare const enum UnitPropertyKey {
100
106
  DELAY_HEALTH_CHECKS_COUNTER = 103,
101
107
  DELAY_HEALTH_CHECKS_HEALTH_BONUS = 104,
102
108
  PREVENT_DEATH_HEALTH_BONUS = 105,
103
- IS_TEAM_GLOW_HIDDEN = 106
109
+ IS_TEAM_GLOW_HIDDEN = 106,
110
+ LAST_X = 107,
111
+ LAST_Y = 108
104
112
  }
105
113
  export type UnitSyncId = number & {
106
114
  readonly __unitSyncId: unique symbol;
@@ -113,6 +121,8 @@ export declare class Unit extends Handle<junit> {
113
121
  private [UnitPropertyKey.DELAY_HEALTH_CHECKS_HEALTH_BONUS]?;
114
122
  private [UnitPropertyKey.PREVENT_DEATH_HEALTH_BONUS]?;
115
123
  private [UnitPropertyKey.IS_TEAM_GLOW_HIDDEN]?;
124
+ private [UnitPropertyKey.LAST_X]?;
125
+ private [UnitPropertyKey.LAST_Y]?;
116
126
  private _owner?;
117
127
  private _timeScale?;
118
128
  private events?;
@@ -148,6 +158,7 @@ export declare class Unit extends Handle<junit> {
148
158
  isEnemyOf(unit: Unit): boolean;
149
159
  playAnimation(animation: string, rarity?: jraritycontrol): void;
150
160
  playAnimation(animation: number): void;
161
+ resetAnimation(): void;
151
162
  queueAnimation(animation: string): void;
152
163
  get weapons(): [UnitWeapon, UnitWeapon];
153
164
  get firstWeapon(): UnitWeapon;
@@ -156,6 +167,8 @@ export declare class Unit extends Handle<junit> {
156
167
  set level(v: number);
157
168
  get xp(): number;
158
169
  set xp(v: number);
170
+ get primaryAttribute(): UnitAttribute;
171
+ set primaryAttribute(primaryAttribute: UnitAttribute);
159
172
  get strengthBase(): number;
160
173
  set strengthBase(strengthBase: number);
161
174
  get strengthBonus(): number;
@@ -230,6 +243,8 @@ export declare class Unit extends Handle<junit> {
230
243
  set timeScale(v: number);
231
244
  get collisionSize(): number;
232
245
  get pathingCollisionRange(): number;
246
+ get movementType(): MovementType;
247
+ set movementType(movementType: MovementType);
233
248
  set pathing(v: boolean);
234
249
  isSelected(player: Player): boolean;
235
250
  explode(): void;
@@ -53,11 +53,19 @@ local ____math = require("math")
53
53
  local min = ____math.min
54
54
  local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
55
55
  local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
56
+ local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
57
+ local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
58
+ local nativeToAttackType = ____attack_2Dtype.nativeToAttackType
59
+ local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
60
+ local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
61
+ local ____attributes = require("attributes")
62
+ local isAttribute = ____attributes.isAttribute
56
63
  local match = string.match
57
64
  local ____tostring = _G.tostring
58
65
  local setUnitAnimation = SetUnitAnimation
59
66
  local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
60
67
  local setUnitAnimationByIndex = SetUnitAnimationByIndex
68
+ local resetUnitAnimation = ResetUnitAnimation
61
69
  local queueUnitAnimation = QueueUnitAnimation
62
70
  local getUnitIntegerField = BlzGetUnitIntegerField
63
71
  local getUnitRealField = BlzGetUnitRealField
@@ -80,7 +88,6 @@ local getHandleId = GetHandleId
80
88
  local getUnitCurrentOrder = GetUnitCurrentOrder
81
89
  local createUnit = CreateUnit
82
90
  local killUnit = KillUnit
83
- local setUnitExploded = SetUnitExploded
84
91
  local removeUnit = RemoveUnit
85
92
  local getUnitTypeId = GetUnitTypeId
86
93
  local isHeroUnitId = IsHeroUnitId
@@ -96,8 +103,6 @@ local getSpellTargetItem = GetSpellTargetItem
96
103
  local getSpellTargetDestructable = GetSpellTargetDestructable
97
104
  local isUnitInRangeXY = IsUnitInRangeXY
98
105
  local isUnitInRange = IsUnitInRange
99
- local setResourceAmount = SetResourceAmount
100
- local getResourceAmount = GetResourceAmount
101
106
  local getUnitWeaponRealField = BlzGetUnitWeaponRealField
102
107
  local setUnitWeaponRealField = BlzSetUnitWeaponRealField
103
108
  local getUnitWeaponStringField = BlzGetUnitWeaponStringField
@@ -128,8 +133,6 @@ local isUnitType = IsUnitType
128
133
  local isUnitAlly = IsUnitAlly
129
134
  local isUnitEnemy = IsUnitEnemy
130
135
  local getOwningPlayer = GetOwningPlayer
131
- local setUnitColor = SetUnitColor
132
- local showUnitTeamGlow = BlzShowUnitTeamGlow
133
136
  ____exports.UnitClassification = {}
134
137
  local UnitClassification = ____exports.UnitClassification
135
138
  do
@@ -357,7 +360,14 @@ local function damageEventPreventDeath(self, callback, ...)
357
360
  rawset(self, 1 + i, (select(i, ...)))
358
361
  end
359
362
  end
360
- local damageSetters = {amount = BlzSetEventDamage, attackType = BlzSetEventAttackType, damageType = BlzSetEventDamageType, weaponType = BlzSetEventWeaponType}
363
+ local damageSetters = {
364
+ amount = BlzSetEventDamage,
365
+ attackType = function(attackType)
366
+ return BlzSetEventAttackType(attackTypeToNative(attackType))
367
+ end,
368
+ damageType = BlzSetEventDamageType,
369
+ weaponType = BlzSetEventWeaponType
370
+ }
361
371
  local jlimitopByOperator = {
362
372
  [0] = LESS_THAN_OR_EQUAL,
363
373
  [1] = LESS_THAN_OR_EQUAL,
@@ -639,7 +649,8 @@ local function delayHealthChecksCallback(unit)
639
649
  end
640
650
  end
641
651
  local nextSyncId = 1
642
- local unitBySyncId = setmetatable({}, {__mode = "k"})
652
+ local unitBySyncId = setmetatable({}, {__mode = "v"})
653
+ local damagingEventByTarget = setmetatable({}, {__mode = "k"})
643
654
  ____exports.Unit = __TS__Class()
644
655
  local Unit = ____exports.Unit
645
656
  Unit.name = "Unit"
@@ -680,6 +691,8 @@ function Unit.prototype.getEvent(self, event, collector)
680
691
  end
681
692
  function Unit.prototype.onDestroy(self)
682
693
  local handle = self.handle
694
+ self[107] = getUnitX(handle)
695
+ self[108] = getUnitY(handle)
683
696
  if not self._owner then
684
697
  self._owner = Player:of(getOwningPlayer(handle))
685
698
  end
@@ -795,6 +808,9 @@ function Unit.prototype.playAnimation(self, animation, rarity)
795
808
  setUnitAnimation(self.handle, animation)
796
809
  end
797
810
  end
811
+ function Unit.prototype.resetAnimation(self)
812
+ resetUnitAnimation(self.handle)
813
+ end
798
814
  function Unit.prototype.queueAnimation(self, animation)
799
815
  queueUnitAnimation(self.handle, animation)
800
816
  end
@@ -809,7 +825,7 @@ function Unit.prototype.isSelected(self, player)
809
825
  return IsUnitSelected(self.handle, player.handle)
810
826
  end
811
827
  function Unit.prototype.explode(self)
812
- setUnitExploded(self.handle, true)
828
+ SetUnitExploded(self.handle, true)
813
829
  killUnit(self.handle)
814
830
  end
815
831
  function Unit.prototype.kill(self)
@@ -1286,6 +1302,19 @@ __TS__SetDescriptor(
1286
1302
  },
1287
1303
  true
1288
1304
  )
1305
+ __TS__SetDescriptor(
1306
+ Unit.prototype,
1307
+ "primaryAttribute",
1308
+ {
1309
+ get = function(self)
1310
+ return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
1311
+ end,
1312
+ set = function(self, primaryAttribute)
1313
+ setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
1314
+ end
1315
+ },
1316
+ true
1317
+ )
1289
1318
  __TS__SetDescriptor(
1290
1319
  Unit.prototype,
1291
1320
  "strengthBase",
@@ -1410,7 +1439,7 @@ __TS__SetDescriptor(
1410
1439
  return not self[106]
1411
1440
  end,
1412
1441
  set = function(self, isTeamGlowVisible)
1413
- showUnitTeamGlow(self.handle, isTeamGlowVisible)
1442
+ BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
1414
1443
  local ____temp_6
1415
1444
  if not isTeamGlowVisible then
1416
1445
  ____temp_6 = true
@@ -1426,9 +1455,9 @@ __TS__SetDescriptor(
1426
1455
  Unit.prototype,
1427
1456
  "color",
1428
1457
  {set = function(self, color)
1429
- setUnitColor(self.handle, color.handle)
1458
+ SetUnitColor(self.handle, color.handle)
1430
1459
  if self[106] then
1431
- showUnitTeamGlow(self.handle, false)
1460
+ BlzShowUnitTeamGlow(self.handle, false)
1432
1461
  end
1433
1462
  end},
1434
1463
  true
@@ -1597,7 +1626,7 @@ __TS__SetDescriptor(
1597
1626
  "x",
1598
1627
  {
1599
1628
  get = function(self)
1600
- return getUnitX(self.handle)
1629
+ return self[107] or getUnitX(self.handle)
1601
1630
  end,
1602
1631
  set = function(self, v)
1603
1632
  SetUnitX(self.handle, v)
@@ -1610,7 +1639,7 @@ __TS__SetDescriptor(
1610
1639
  "y",
1611
1640
  {
1612
1641
  get = function(self)
1613
- return getUnitY(self.handle)
1642
+ return self[108] or getUnitY(self.handle)
1614
1643
  end,
1615
1644
  set = function(self, v)
1616
1645
  SetUnitY(self.handle, v)
@@ -1696,10 +1725,10 @@ __TS__SetDescriptor(
1696
1725
  "gold",
1697
1726
  {
1698
1727
  get = function(self)
1699
- return getResourceAmount(self.handle)
1728
+ return GetResourceAmount(self.handle)
1700
1729
  end,
1701
1730
  set = function(self, gold)
1702
- setResourceAmount(self.handle, gold)
1731
+ SetResourceAmount(self.handle, gold)
1703
1732
  end
1704
1733
  },
1705
1734
  true
@@ -1827,6 +1856,19 @@ __TS__SetDescriptor(
1827
1856
  end},
1828
1857
  true
1829
1858
  )
1859
+ __TS__SetDescriptor(
1860
+ Unit.prototype,
1861
+ "movementType",
1862
+ {
1863
+ get = function(self)
1864
+ return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
1865
+ end,
1866
+ set = function(self, movementType)
1867
+ setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
1868
+ end
1869
+ },
1870
+ true
1871
+ )
1830
1872
  __TS__SetDescriptor(
1831
1873
  Unit.prototype,
1832
1874
  "pathing",
@@ -2369,13 +2411,18 @@ Unit.onDamaging = (function()
2369
2411
  if source and source.typeId == dummyUnitId then
2370
2412
  source = nil
2371
2413
  end
2372
- local target = BlzGetEventDamageTarget()
2414
+ local target = ____exports.Unit:of(BlzGetEventDamageTarget())
2415
+ local metadata = damageMetadataByTarget[target]
2416
+ damageMetadataByTarget[target] = nil
2373
2417
  local data = {
2374
2418
  amount = GetEventDamage(),
2375
- attackType = BlzGetEventAttackType(),
2419
+ attackType = nativeToAttackType(BlzGetEventAttackType()),
2376
2420
  damageType = BlzGetEventDamageType(),
2377
2421
  weaponType = BlzGetEventWeaponType(),
2378
- isAttack = BlzGetEventIsAttack()
2422
+ metadata = metadata,
2423
+ isAttack = BlzGetEventIsAttack(),
2424
+ originalAmount = GetEventDamage(),
2425
+ originalMetadata = metadata
2379
2426
  }
2380
2427
  if data.isAttack and source then
2381
2428
  local weapon = BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 1) and (BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 0) and -1 or 1) or 0
@@ -2389,18 +2436,22 @@ Unit.onDamaging = (function()
2389
2436
  invoke(
2390
2437
  event,
2391
2438
  source,
2392
- ____exports.Unit:of(target),
2439
+ target,
2393
2440
  setmetatable(
2394
2441
  {},
2395
2442
  {
2396
2443
  __index = data,
2397
2444
  __newindex = function(self, key, value)
2398
- damageSetters[key](value)
2445
+ local damageSetter = damageSetters[key]
2446
+ if damageSetter ~= nil then
2447
+ damageSetter(value)
2448
+ end
2399
2449
  data[key] = value
2400
2450
  end
2401
2451
  }
2402
2452
  )
2403
2453
  )
2454
+ damagingEventByTarget[target] = data
2404
2455
  return
2405
2456
  end
2406
2457
  BlzSetEventDamage(0)
@@ -2408,7 +2459,7 @@ Unit.onDamaging = (function()
2408
2459
  BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
2409
2460
  BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
2410
2461
  local sourceOwner = source.owner.handle
2411
- local targetOwner = GetOwningPlayer(target)
2462
+ local targetOwner = target.owner.handle
2412
2463
  if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
2413
2464
  SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
2414
2465
  Timer:run(function()
@@ -2424,23 +2475,19 @@ Unit.onDamaging = (function()
2424
2475
  for ____, ____value in ipairs(source._attackHandlers) do
2425
2476
  local condition = ____value[1]
2426
2477
  local action = ____value[2]
2427
- if condition(
2428
- source,
2429
- ____exports.Unit:of(target),
2430
- data
2431
- ) then
2478
+ if condition(source, target, data) then
2432
2479
  action(
2433
2480
  source,
2434
- ____exports.Unit:of(target),
2481
+ target,
2435
2482
  setmetatable(
2436
2483
  {fire = function()
2437
2484
  UnitDamageTarget(
2438
2485
  source.handle,
2439
- target,
2486
+ target.handle,
2440
2487
  data.amount,
2441
2488
  true,
2442
2489
  true,
2443
- data.attackType,
2490
+ attackTypeToNative(data.attackType),
2444
2491
  data.damageType,
2445
2492
  data.weaponType
2446
2493
  )
@@ -2467,26 +2514,40 @@ Unit.onDamage = __TS__New(
2467
2514
  if source and source.typeId == dummyUnitId then
2468
2515
  source = nil
2469
2516
  end
2517
+ local target = ____exports.Unit:of(BlzGetEventDamageTarget())
2518
+ local damagingEvent = damagingEventByTarget[target]
2519
+ damagingEventByTarget[target] = nil
2470
2520
  local data = {
2471
2521
  amount = GetEventDamage(),
2472
- attackType = BlzGetEventAttackType(),
2522
+ attackType = nativeToAttackType(BlzGetEventAttackType()),
2473
2523
  damageType = BlzGetEventDamageType(),
2474
2524
  weaponType = BlzGetEventWeaponType(),
2525
+ metadata = damagingEvent and damagingEvent.metadata,
2475
2526
  isAttack = BlzGetEventIsAttack(),
2476
- originalAmount = GetEventDamage(),
2527
+ originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
2528
+ originalMetadata = damagingEvent and damagingEvent.originalMetadata,
2477
2529
  preventDeath = damageEventPreventDeath
2478
2530
  }
2531
+ if damagingEvent then
2532
+ for key, value in pairs(damagingEvent) do
2533
+ if isAttribute(key) then
2534
+ data[key] = value
2535
+ end
2536
+ end
2537
+ end
2479
2538
  local evData = setmetatable(
2480
2539
  {},
2481
2540
  {
2482
2541
  __index = data,
2483
2542
  __newindex = function(self, key, value)
2484
- damageSetters[key](value)
2543
+ local damageSetter = damageSetters[key]
2544
+ if damageSetter ~= nil then
2545
+ damageSetter(value)
2546
+ end
2485
2547
  data[key] = value
2486
2548
  end
2487
2549
  }
2488
2550
  )
2489
- local target = ____exports.Unit:of(BlzGetEventDamageTarget())
2490
2551
  invoke(event, source, target, evData)
2491
2552
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2492
2553
  local bonusHealth = math.ceil(evData.amount)
@@ -2,13 +2,18 @@
2
2
  import { ModelNodeName } from "./model-node-name";
3
3
  import { ModelNodeQualifier } from "./model-node-qualifier";
4
4
  import { Optional } from "../../../utility/types";
5
+ import { EffectParameters } from "../../../core/types/effect";
5
6
  export type AttachmentPreset = {
6
7
  modelPath: string;
7
8
  nodeName: ModelNodeName;
8
9
  nodeQualifiers: ModelNodeQualifier[];
9
10
  };
10
- export type AttachmentPresetInput = Optional<AttachmentPreset, "nodeQualifiers"> | string;
11
- export declare const toAttachmentPreset: (attachmentPresetInput: AttachmentPresetInput) => AttachmentPreset;
11
+ export type EffectPresetWithParameters = AttachmentPreset & {
12
+ parameters?: EffectParameters;
13
+ };
14
+ export type AttachmentPresetInput<T extends AttachmentPreset = AttachmentPreset> = Optional<T, "nodeName" | "nodeQualifiers"> | string;
15
+ export type EffectPresetWithParametersInput = AttachmentPresetInput<EffectPresetWithParameters>;
16
+ export declare const toEffectPreset: (effectPresetInput: EffectPresetWithParametersInput) => EffectPresetWithParameters;
12
17
  export declare const extractAttachmentPresetInputModelPath: (attachmentPresetInput: AttachmentPresetInput | undefined) => string;
13
18
  export declare const extractAttachmentPresetInputNodeFQN: (attachmentPresetInput: AttachmentPresetInput | undefined) => string;
14
19
  export declare const splitAttachmentNodeFQN: (attachmentNodeFQN: string) => LuaMultiReturn<[attachmentNodeName: ModelNodeName, attachmentNodeQualifiers: ModelNodeQualifier[]]>;
@@ -1,9 +1,10 @@
1
1
  local ____lualib = require("lualib_bundle")
2
+ local __TS__ArrayJoin = ____lualib.__TS__ArrayJoin
2
3
  local __TS__StringSplit = ____lualib.__TS__StringSplit
3
4
  local __TS__ArraySlice = ____lualib.__TS__ArraySlice
4
5
  local ____exports = {}
5
- ____exports.toAttachmentPreset = function(attachmentPresetInput)
6
- return type(attachmentPresetInput) == "string" and ({modelPath = attachmentPresetInput, nodeName = "origin", nodeQualifiers = {}}) or ({modelPath = attachmentPresetInput.modelPath, nodeName = attachmentPresetInput.nodeName, nodeQualifiers = attachmentPresetInput.nodeQualifiers or ({})})
6
+ ____exports.toEffectPreset = function(effectPresetInput)
7
+ return type(effectPresetInput) == "string" and ({modelPath = effectPresetInput, nodeName = "origin", nodeQualifiers = {}}) or ({modelPath = effectPresetInput.modelPath, nodeName = effectPresetInput.nodeName or "origin", nodeQualifiers = effectPresetInput.nodeQualifiers or ({}), parameters = effectPresetInput.parameters})
7
8
  end
8
9
  ____exports.extractAttachmentPresetInputModelPath = function(attachmentPresetInput)
9
10
  return type(attachmentPresetInput) == "string" and attachmentPresetInput or (attachmentPresetInput and attachmentPresetInput.modelPath or "")
@@ -12,7 +13,7 @@ ____exports.extractAttachmentPresetInputNodeFQN = function(attachmentPresetInput
12
13
  if type(attachmentPresetInput) == "string" or attachmentPresetInput == nil then
13
14
  return ""
14
15
  end
15
- return table.concat(
16
+ return __TS__ArrayJoin(
16
17
  {
17
18
  attachmentPresetInput.nodeName,
18
19
  table.unpack(attachmentPresetInput.nodeQualifiers or ({}))
@@ -1,11 +1,10 @@
1
1
  /** @noSelfInFile */
2
2
  export declare const enum AttackType {
3
- NONE = "unknown",
4
- NORMAL = "normal",
5
- PIERCE = "pierce",
6
- SIEGE = "siege",
7
- SPELL = "spells",
8
- CHAOS = "chaos",
9
- MAGIC = "magic",
10
- HERO = "hero"
3
+ SPELL = 0,
4
+ NORMAL = 1,
5
+ PIERCE = 2,
6
+ SIEGE = 3,
7
+ MAGIC = 4,
8
+ CHAOS = 5,
9
+ HERO = 6
11
10
  }
@@ -1,2 +1,44 @@
1
1
  local ____exports = {}
2
+ local ____records = require("utility.records")
3
+ local invertRecord = ____records.invertRecord
4
+ local stringByAttackType = {
5
+ [1] = "normal",
6
+ [2] = "pierce",
7
+ [3] = "siege",
8
+ [0] = "spells",
9
+ [5] = "chaos",
10
+ [4] = "magic",
11
+ [6] = "hero"
12
+ }
13
+ local attackTypeByString = invertRecord(stringByAttackType)
14
+ local nativeByAttackType = {
15
+ [1] = ATTACK_TYPE_MELEE,
16
+ [2] = ATTACK_TYPE_PIERCE,
17
+ [3] = ATTACK_TYPE_SIEGE,
18
+ [0] = ATTACK_TYPE_NORMAL,
19
+ [5] = ATTACK_TYPE_CHAOS,
20
+ [4] = ATTACK_TYPE_MAGIC,
21
+ [6] = ATTACK_TYPE_HERO
22
+ }
23
+ local attackTypeByNative = invertRecord(nativeByAttackType)
24
+ ---
25
+ -- @internal For use by internal systems only.
26
+ ____exports.attackTypeToString = function(attackType)
27
+ return attackType ~= nil and stringByAttackType[attackType] or "unknown"
28
+ end
29
+ ---
30
+ -- @internal For use by internal systems only.
31
+ ____exports.stringToAttackType = function(____string)
32
+ return attackTypeByString[____string]
33
+ end
34
+ ---
35
+ -- @internal For use by internal systems only.
36
+ ____exports.attackTypeToNative = function(attackType)
37
+ return nativeByAttackType[attackType]
38
+ end
39
+ ---
40
+ -- @internal For use by internal systems only.
41
+ ____exports.nativeToAttackType = function(attackType)
42
+ return attackTypeByNative[attackType]
43
+ end
2
44
  return ____exports
@@ -1,10 +1,10 @@
1
1
  /** @noSelfInFile */
2
2
  export declare const enum MovementType {
3
- NONE = "",
4
- FLOAT = "float",
5
- FLY = "fly",
6
- FOOT = "foot",
7
- HORSE = "horse",
8
- HOVER = "hover",
9
- AMPHIBIOUS = "amph"
3
+ NONE = 0,
4
+ FOOT = 1,
5
+ FLY = 2,
6
+ HORSE = 4,
7
+ HOVER = 8,
8
+ FLOAT = 16,
9
+ AMPHIBIOUS = 32
10
10
  }
@@ -1,2 +1,24 @@
1
1
  local ____exports = {}
2
+ local ____records = require("utility.records")
3
+ local invertRecord = ____records.invertRecord
4
+ local stringByMovementType = {
5
+ [0] = "",
6
+ [16] = "float",
7
+ [2] = "fly",
8
+ [1] = "foot",
9
+ [4] = "horse",
10
+ [8] = "hover",
11
+ [32] = "amph"
12
+ }
13
+ local movementTypeByString = invertRecord(stringByMovementType)
14
+ ---
15
+ -- @internal For use by internal systems only.
16
+ ____exports.movementTypeToString = function(movementType)
17
+ return stringByMovementType[movementType]
18
+ end
19
+ ---
20
+ -- @internal For use by internal systems only.
21
+ ____exports.stringToMovementType = function(____string)
22
+ return movementTypeByString[____string] or 0
23
+ end
2
24
  return ____exports
@@ -0,0 +1,10 @@
1
+ /** @noSelfInFile */
2
+ export declare const enum SoundEax {
3
+ DEFAULT = "DefaultEAXON",
4
+ ACKNOWLEDGEMENTS = "HeroAcksEAX",
5
+ ENVIRONMENT = "DoodadsEAX",
6
+ DRUMS = "KotoDrumsEAX",
7
+ ATTACKS = "CombatSoundsEAX",
8
+ ABILITIES = "SpellsEAX",
9
+ MISSILES = "MissilesEAX"
10
+ }
@@ -0,0 +1,2 @@
1
+ local ____exports = {}
2
+ return ____exports
@@ -0,0 +1,6 @@
1
+ /** @noSelfInFile */
2
+ export declare enum UnitAttribute {
3
+ STRENGTH = 1,
4
+ INTELLIGENCE = 2,
5
+ AGILITY = 3
6
+ }