warscript 0.0.1-dev.ee2345e → 0.0.1-dev.f9efacb

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 (117) hide show
  1. package/attributes.d.ts +0 -1
  2. package/binaryreader.d.ts +1 -0
  3. package/binaryreader.lua +3 -0
  4. package/core/types/frame.d.ts +8 -1
  5. package/core/types/frame.lua +93 -1
  6. package/core/types/group.d.ts +0 -1
  7. package/core/types/image.d.ts +0 -1
  8. package/core/types/missile.d.ts +2 -2
  9. package/core/types/missile.lua +8 -2
  10. package/core/types/unit.lua +8 -0
  11. package/core/util.d.ts +1 -1
  12. package/core/util.lua +6 -0
  13. package/decl/index.d.ts +1 -0
  14. package/engine/ability.d.ts +1 -1
  15. package/engine/behavior.d.ts +10 -10
  16. package/engine/behavior.lua +6 -6
  17. package/engine/behaviour/ability/apply-buff.d.ts +3 -5
  18. package/engine/behaviour/ability/apply-unit-behavior.d.ts +6 -1
  19. package/engine/behaviour/ability/damage.d.ts +33 -11
  20. package/engine/behaviour/ability/damage.lua +89 -31
  21. package/engine/behaviour/ability/heal.d.ts +33 -6
  22. package/engine/behaviour/ability/heal.lua +89 -10
  23. package/engine/behaviour/ability/instant-impact.lua +4 -0
  24. package/engine/behaviour/ability/restore-mana.d.ts +15 -0
  25. package/engine/behaviour/ability/restore-mana.lua +29 -0
  26. package/engine/behaviour/ability.d.ts +8 -1
  27. package/engine/behaviour/ability.lua +62 -0
  28. package/engine/behaviour/unit/stun-immunity.d.ts +0 -1
  29. package/engine/behaviour/unit.d.ts +8 -2
  30. package/engine/behaviour/unit.lua +27 -0
  31. package/engine/buff.d.ts +62 -20
  32. package/engine/buff.lua +247 -72
  33. package/engine/game-map.d.ts +7 -0
  34. package/engine/game-map.lua +32 -0
  35. package/engine/internal/ability.d.ts +3 -11
  36. package/engine/internal/ability.lua +9 -78
  37. package/engine/internal/item+owner.lua +2 -2
  38. package/engine/internal/unit/bonus.d.ts +9 -8
  39. package/engine/internal/unit/bonus.lua +6 -1
  40. package/engine/internal/unit/item.d.ts +24 -0
  41. package/engine/internal/unit/item.lua +84 -0
  42. package/engine/internal/unit/main-selected.d.ts +7 -0
  43. package/engine/internal/unit/main-selected.lua +40 -0
  44. package/engine/internal/unit+ability.lua +2 -2
  45. package/engine/internal/unit+transport.lua +4 -10
  46. package/engine/internal/unit-missile-launch.lua +25 -6
  47. package/engine/internal/unit.d.ts +57 -16
  48. package/engine/internal/unit.lua +313 -111
  49. package/engine/local-client.d.ts +7 -2
  50. package/engine/local-client.lua +82 -0
  51. package/engine/object-data/auxiliary/attachment-preset.d.ts +0 -1
  52. package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
  53. package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
  54. package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
  55. package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
  56. package/engine/object-data/entry/ability-type/mine.d.ts +10 -0
  57. package/engine/object-data/entry/ability-type/mine.lua +39 -0
  58. package/engine/object-data/entry/ability-type/spirit-touch.d.ts +2 -2
  59. package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
  60. package/engine/object-data/entry/ability-type.d.ts +0 -1
  61. package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
  62. package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
  63. package/engine/object-data/entry/buff-type.d.ts +0 -1
  64. package/engine/object-data/entry/destructible-type.d.ts +0 -1
  65. package/engine/object-data/entry/item-type/blank.d.ts +0 -1
  66. package/engine/object-data/entry/item-type.d.ts +12 -1
  67. package/engine/object-data/entry/item-type.lua +78 -0
  68. package/engine/object-data/entry/lightning-type.d.ts +0 -1
  69. package/engine/object-data/entry/unit-type.d.ts +37 -2
  70. package/engine/object-data/entry/unit-type.lua +333 -49
  71. package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
  72. package/engine/object-data/entry/upgrade.d.ts +0 -1
  73. package/engine/object-data/entry.d.ts +2 -3
  74. package/engine/object-field/ability.d.ts +18 -1
  75. package/engine/object-field/ability.lua +51 -1
  76. package/engine/object-field.d.ts +0 -1
  77. package/engine/random.d.ts +1 -0
  78. package/engine/random.lua +9 -0
  79. package/engine/standard/entries/unit-type.d.ts +39 -1
  80. package/engine/standard/entries/unit-type.lua +39 -1
  81. package/engine/standard/fields/ability.d.ts +1 -1
  82. package/engine/standard/fields/ability.lua +1 -1
  83. package/engine/unit.d.ts +2 -0
  84. package/engine/unit.lua +11 -2
  85. package/event.d.ts +2 -3
  86. package/event.lua +9 -5
  87. package/index.d.ts +1 -0
  88. package/index.lua +1 -0
  89. package/lualib_bundle.lua +146 -42
  90. package/math/vec2.d.ts +2 -9
  91. package/math.d.ts +0 -2
  92. package/net/socket.d.ts +7 -1
  93. package/net/socket.lua +45 -4
  94. package/network.d.ts +1 -0
  95. package/network.lua +3 -2
  96. package/objutil/ability.d.ts +0 -1
  97. package/objutil/buff.d.ts +0 -1
  98. package/objutil/buff.lua +1 -1
  99. package/objutil/object.d.ts +0 -1
  100. package/objutil/unit.d.ts +0 -1
  101. package/package.json +13 -14
  102. package/patch-lua.d.ts +0 -0
  103. package/patch-lua.lua +10 -0
  104. package/property.d.ts +55 -0
  105. package/property.lua +374 -0
  106. package/string.d.ts +30 -0
  107. package/string.lua +14 -0
  108. package/util/stream.d.ts +0 -1
  109. package/utility/arrays.d.ts +3 -4
  110. package/utility/bit-set.d.ts +0 -2
  111. package/utility/linked-set.d.ts +11 -3
  112. package/utility/linked-set.lua +5 -2
  113. package/utility/lua-maps.d.ts +1 -2
  114. package/utility/lua-sets.d.ts +1 -2
  115. package/utility/types.d.ts +1 -0
  116. package/core/mapbounds.d.ts +0 -8
  117. package/core/mapbounds.lua +0 -12
package/engine/buff.d.ts CHANGED
@@ -5,16 +5,19 @@ import { Ability } from "./internal/ability";
5
5
  import { AbilityTypeId } from "./object-data/entry/ability-type";
6
6
  import { BuffPolarity } from "./object-data/auxiliary/buff-polarity";
7
7
  import { BuffResistanceType } from "./object-data/auxiliary/buff-resistance-type";
8
- import { AbilityBooleanField, AbilityBooleanLevelField, AbilityCombatClassificationsLevelField, AbilityDependentValue, AbilityIntegerField, AbilityIntegerLevelField, AbilityNumberField, AbilityNumberLevelField } from "./object-field/ability";
8
+ import { AbilityBooleanField, AbilityBooleanLevelField, AbilityCombatClassificationsLevelField, AbilityDependentValue, AbilityEnumLevelField, AbilityIntegerField, AbilityIntegerLevelField, AbilityNumberField, AbilityNumberLevelField } from "./object-field/ability";
9
9
  import { CombatClassifications } from "./object-data/auxiliary/combat-classification";
10
- import { IsExactlyAny, NonEmptyArray, Prohibit } from "../utility/types";
10
+ import { IsExactlyAny, Prohibit, ReadonlyNonEmptyArray } from "../utility/types";
11
11
  import { UnitBehavior } from "./behaviour/unit";
12
12
  import type { Widget } from "../core/types/widget";
13
13
  import { Destructor } from "../destroyable";
14
14
  export type BuffConstructor<T extends Buff<any> = Buff<any>, Args extends any[] = any> = OmitConstructor<typeof Buff<any>> & (new (...args: Args) => T);
15
+ type EnumParameterValueType<T extends number> = T | AbilityEnumLevelField<T>;
15
16
  type NumberParameterValueType = number | AbilityNumberField | AbilityNumberLevelField;
16
17
  type IntegerParameterValueType = number | AbilityIntegerField | AbilityIntegerLevelField;
17
18
  type BooleanParameterValueType = boolean | AbilityBooleanField | AbilityBooleanLevelField;
19
+ export type BuffPolarityParameterType = EnumParameterValueType<BuffPolarity>;
20
+ export type BuffResistanceTypeParameterType = EnumParameterValueType<BuffResistanceType>;
18
21
  export declare class BuffUniqueGroup {
19
22
  }
20
23
  export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
@@ -51,6 +54,7 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
51
54
  armorIncreaseFactor?: NumberParameterValueType;
52
55
  attackSpeedIncreaseFactor?: NumberParameterValueType;
53
56
  movementSpeedIncreaseFactor?: NumberParameterValueType;
57
+ damageFactor?: NumberParameterValueType;
54
58
  receivedDamageFactor?: NumberParameterValueType;
55
59
  receivedMagicDamageFactor?: NumberParameterValueType;
56
60
  durationIncreaseOnAutoAttack?: NumberParameterValueType;
@@ -64,8 +68,14 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
64
68
  disablesAutoAttack?: BooleanParameterValueType;
65
69
  destroysOnDamage?: BooleanParameterValueType;
66
70
  maximumAutoAttackCount?: IntegerParameterValueType;
71
+ maximumDamageDealtEventCount?: IntegerParameterValueType;
72
+ maximumDamageReceivedEventCount?: IntegerParameterValueType;
73
+ damageOnExpiration?: NumberParameterValueType;
74
+ healingOnExpiration?: NumberParameterValueType;
75
+ killsOnExpiration?: BooleanParameterValueType;
76
+ explodesOnExpiration?: BooleanParameterValueType;
67
77
  uniqueGroup?: BuffUniqueGroup;
68
- } : BuffParameters & (T extends Buff<infer AdditionalParameters> ? AdditionalParameters : {});
78
+ } : BuffParameters & (T extends Buff<infer AdditionalParameters> ? AdditionalParameters : object);
69
79
  declare const enum BuffPropertyKey {
70
80
  UNIT = 100,
71
81
  SOURCE = 101,
@@ -86,19 +96,27 @@ declare const enum BuffPropertyKey {
86
96
  HEALING_INTERVAL = 116,
87
97
  REMAINING_HEALING_OVER_DURATION = 117,
88
98
  HEALING_INTERVAL_TIMER = 118,
89
- DAMAGE_UPON_DEATH_ALLOWED_TARGET_CLASSIFICATIONS = 119,
90
- DAMAGE_UPON_DEATH = 120,
91
- DAMAGE_UPON_DEATH_RANGE = 121,
92
- MEDIUM_DAMAGE_UPON_DEATH = 122,
93
- MEDIUM_DAMAGE_UPON_DEATH_RANGE = 123,
94
- SMALL_DAMAGE_UPON_DEATH = 124,
95
- SMALL_DAMAGE_UPON_DEATH_RANGE = 125,
96
- AUTO_ATTACK_COUNT = 126,
97
- MAXIMUM_AUTO_ATTACK_COUNT = 127,
98
- STUNS = 128,
99
- IGNORES_STUN_IMMUNITY = 129,
100
- DISABLES_AUTO_ATTACK = 130,
101
- PROVIDES_INVULNERABILITY = 131
99
+ DAMAGE_ON_EXPIRATION = 119,
100
+ HEALING_ON_EXPIRATION = 120,
101
+ DAMAGE_UPON_DEATH_ALLOWED_TARGET_CLASSIFICATIONS = 121,
102
+ DAMAGE_UPON_DEATH = 122,
103
+ DAMAGE_UPON_DEATH_RANGE = 123,
104
+ MEDIUM_DAMAGE_UPON_DEATH = 124,
105
+ MEDIUM_DAMAGE_UPON_DEATH_RANGE = 125,
106
+ SMALL_DAMAGE_UPON_DEATH = 126,
107
+ SMALL_DAMAGE_UPON_DEATH_RANGE = 127,
108
+ AUTO_ATTACK_COUNT = 128,
109
+ MAXIMUM_AUTO_ATTACK_COUNT = 129,
110
+ DAMAGE_DEALT_EVENT_COUNT = 130,
111
+ MAXIMUM_DAMAGE_DEALT_EVENT_COUNT = 131,
112
+ DAMAGE_RECEIVED_EVENT_COUNT = 132,
113
+ MAXIMUM_DAMAGE_RECEIVED_EVENT_COUNT = 133,
114
+ STUNS = 134,
115
+ IGNORES_STUN_IMMUNITY = 135,
116
+ DISABLES_AUTO_ATTACK = 136,
117
+ PROVIDES_INVULNERABILITY = 137,
118
+ KILLS_ON_EXPIRATION = 138,
119
+ EXPLODES_ON_EXPIRATION = 139
102
120
  }
103
121
  export declare const enum BuffTypeIdSelectionPolicy {
104
122
  LEAST_DURATION = 0
@@ -106,17 +124,17 @@ export declare const enum BuffTypeIdSelectionPolicy {
106
124
  export type BuffAdditionalParameters = Prohibit<Record<string, any>, keyof BuffParameters>;
107
125
  export type BuffConstructorParameters<AdditionalParameters extends BuffAdditionalParameters> = [
108
126
  ...typeId: [ApplicableBuffTypeId] | [
109
- typeIds: NonEmptyArray<ApplicableBuffTypeId>,
127
+ typeIds: ReadonlyNonEmptyArray<ApplicableBuffTypeId>,
110
128
  typeIdSelectionPolicy: BuffTypeIdSelectionPolicy
111
129
  ],
112
- polarity: BuffPolarity,
113
- resistanceType: BuffResistanceType,
130
+ polarity: BuffPolarityParameterType,
131
+ resistanceType: BuffResistanceTypeParameterType,
114
132
  ...abilityOrParameters: [
115
133
  ability: Ability,
116
134
  parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>
117
135
  ] | [parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>]
118
136
  ];
119
- export declare class Buff<AdditionalParameters extends Prohibit<Record<string, any>, keyof BuffParameters> = {}> extends UnitBehavior {
137
+ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, any>, keyof BuffParameters> = object> extends UnitBehavior {
120
138
  private _unit;
121
139
  protected readonly __additionalParametersBrand?: AdditionalParameters;
122
140
  private [BuffPropertyKey.UNIT];
@@ -138,6 +156,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
138
156
  private [BuffPropertyKey.HEALING_INTERVAL]?;
139
157
  private [BuffPropertyKey.REMAINING_HEALING_OVER_DURATION]?;
140
158
  private [BuffPropertyKey.HEALING_INTERVAL_TIMER]?;
159
+ private [BuffPropertyKey.DAMAGE_ON_EXPIRATION]?;
160
+ private [BuffPropertyKey.HEALING_ON_EXPIRATION]?;
141
161
  private [BuffPropertyKey.DAMAGE_UPON_DEATH_ALLOWED_TARGET_CLASSIFICATIONS]?;
142
162
  private [BuffPropertyKey.DAMAGE_UPON_DEATH]?;
143
163
  private [BuffPropertyKey.DAMAGE_UPON_DEATH_RANGE]?;
@@ -147,10 +167,16 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
147
167
  private [BuffPropertyKey.SMALL_DAMAGE_UPON_DEATH_RANGE]?;
148
168
  private [BuffPropertyKey.MAXIMUM_AUTO_ATTACK_COUNT]?;
149
169
  private [BuffPropertyKey.AUTO_ATTACK_COUNT]?;
170
+ private [BuffPropertyKey.MAXIMUM_DAMAGE_DEALT_EVENT_COUNT]?;
171
+ private [BuffPropertyKey.DAMAGE_DEALT_EVENT_COUNT]?;
172
+ private [BuffPropertyKey.MAXIMUM_DAMAGE_RECEIVED_EVENT_COUNT]?;
173
+ private [BuffPropertyKey.DAMAGE_RECEIVED_EVENT_COUNT]?;
150
174
  private [BuffPropertyKey.STUNS]?;
151
175
  private [BuffPropertyKey.IGNORES_STUN_IMMUNITY]?;
152
176
  private [BuffPropertyKey.DISABLES_AUTO_ATTACK]?;
153
177
  private [BuffPropertyKey.PROVIDES_INVULNERABILITY]?;
178
+ private [BuffPropertyKey.KILLS_ON_EXPIRATION]?;
179
+ private [BuffPropertyKey.EXPLODES_ON_EXPIRATION]?;
154
180
  protected static readonly defaultParameters: BuffParameters;
155
181
  get source(): Unit;
156
182
  readonly typeId: ApplicableBuffTypeId;
@@ -187,6 +213,12 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
187
213
  set healingPerInterval(healingPerInterval: number);
188
214
  get healingInterval(): number;
189
215
  set healingInterval(healingInterval: number);
216
+ get damageOnExpiration(): number;
217
+ set damageOnExpiration(damageOnExpiration: number);
218
+ get healingOnExpiration(): number;
219
+ set healingOnExpiration(healingOnExpiration: number);
220
+ get damageFactor(): number;
221
+ set damageFactor(damageFactor: number);
190
222
  get receivedDamageFactor(): number;
191
223
  set receivedDamageFactor(receivedDamageFactor: number);
192
224
  get armorIncrease(): number;
@@ -199,6 +231,14 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
199
231
  set disablesAutoAttack(disablesAutoAttack: boolean);
200
232
  get providesInvulnerability(): boolean;
201
233
  set providesInvulnerability(providesInvulnerability: boolean);
234
+ get killsOnExpiration(): boolean;
235
+ set killsOnExpiration(killsOnExpiration: boolean);
236
+ get explodesOnExpiration(): boolean;
237
+ set explodesOnExpiration(killsOnExpiration: boolean);
238
+ get maximumDamageDealtEventCount(): number;
239
+ set maximumDamageDealtEventCount(maximumDamageDealtEventCount: number);
240
+ get maximumDamageReceivedEventCount(): number;
241
+ set maximumDamageReceivedEventCount(maximumDamageReceivedEventCount: number);
202
242
  get maximumAutoAttackCount(): number;
203
243
  set maximumAutoAttackCount(maximumAutoAttackCount: number);
204
244
  get durationIncreaseOnAutoAttack(): number;
@@ -215,7 +255,9 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
215
255
  protected onDestroy(): Destructor;
216
256
  static apply<T extends Buff<any>, Args extends any[]>(this: BuffConstructor<T, Args>, ...args: Args): T | undefined;
217
257
  static getByTypeId<T extends Buff<any>, Args extends any[]>(this: BuffConstructor<T, Args>, unit: Unit, typeId: ApplicableBuffTypeId): T | undefined;
258
+ onExpiration(): void;
218
259
  onDeath(source: Unit | undefined): void;
219
260
  onDamageDealt(target: Unit, event: DamageEvent): void;
261
+ onDamageReceived(source: Unit | undefined, event: DamageEvent): void;
220
262
  }
221
263
  export {};
package/engine/buff.lua CHANGED
@@ -94,6 +94,7 @@ local buffParametersKeys = {
94
94
  armorIncreaseFactor = true,
95
95
  attackSpeedIncreaseFactor = true,
96
96
  movementSpeedIncreaseFactor = true,
97
+ damageFactor = true,
97
98
  receivedDamageFactor = true,
98
99
  receivedMagicDamageFactor = true,
99
100
  durationIncreaseOnAutoAttack = true,
@@ -107,8 +108,26 @@ local buffParametersKeys = {
107
108
  disablesAutoAttack = true,
108
109
  destroysOnDamage = true,
109
110
  maximumAutoAttackCount = true,
110
- uniqueGroup = true
111
+ maximumDamageDealtEventCount = true,
112
+ maximumDamageReceivedEventCount = true,
113
+ uniqueGroup = true,
114
+ damageOnExpiration = true,
115
+ healingOnExpiration = true,
116
+ killsOnExpiration = true,
117
+ explodesOnExpiration = true
111
118
  }
119
+ local function resolveEnumValue(ability, level, value)
120
+ if value == nil or type(value) == "number" then
121
+ return value
122
+ end
123
+ if ability == nil then
124
+ error(
125
+ __TS__New(IllegalArgumentException),
126
+ 0
127
+ )
128
+ end
129
+ return value:getValue(ability, level or ability.level)
130
+ end
112
131
  local function resolveNumberValue(ability, level, value)
113
132
  if value == nil or type(value) == "number" then
114
133
  return value
@@ -145,20 +164,32 @@ local function resolveAndSetNumberValue(buff, property, ability, level, value, d
145
164
  buff[property] = resolvedValue
146
165
  end
147
166
  end
148
- local buffBooleanParameters = {"stuns", "ignoresStunImmunity", "disablesAutoAttack", "providesInvulnerability"}
167
+ local buffBooleanParameters = {
168
+ "stuns",
169
+ "ignoresStunImmunity",
170
+ "disablesAutoAttack",
171
+ "providesInvulnerability",
172
+ "killsOnExpiration",
173
+ "explodesOnExpiration"
174
+ }
149
175
  local buffNumberParameters = {
150
176
  "durationIncreaseOnAutoAttack",
151
177
  "attackSpeedIncreaseFactor",
152
178
  "movementSpeedIncreaseFactor",
153
179
  "armorIncrease",
180
+ "damageFactor",
154
181
  "receivedDamageFactor",
155
182
  "maximumAutoAttackCount",
183
+ "maximumDamageDealtEventCount",
184
+ "maximumDamageReceivedEventCount",
156
185
  "damageInterval",
157
186
  "damagePerInterval",
158
187
  "damageOverDuration",
159
188
  "healingInterval",
160
189
  "healingPerInterval",
161
- "healingOverDuration"
190
+ "healingOverDuration",
191
+ "damageOnExpiration",
192
+ "healingOnExpiration"
162
193
  }
163
194
  local unsuccessfulApplicationMarker = {}
164
195
  local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
@@ -207,6 +238,7 @@ local function expireBuff(buff)
207
238
  end
208
239
  end
209
240
  Timer:run(destroyBuff, buff)
241
+ buff:onExpiration()
210
242
  end
211
243
  local function buffDamageIntervalInitialTimerCallback(buff)
212
244
  buffDamageIntervalTimerCallback(buff)
@@ -296,8 +328,6 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
296
328
  end
297
329
  end
298
330
  self.typeId = typeId
299
- self.polarity = polarity
300
- self.resistanceType = resistanceType
301
331
  if not __TS__InstanceOf(ability, Ability) then
302
332
  parameters = ability
303
333
  ability = nil
@@ -324,6 +354,8 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
324
354
  learnLevelMinimum = learnLevelMinimum or ability:getField(ABILITY_IF_REQUIRED_LEVEL)
325
355
  duration = duration or getAbilityDuration(ability, _unit)
326
356
  end
357
+ self.polarity = resolveEnumValue(ability, level, polarity)
358
+ self.resistanceType = resolveEnumValue(ability, level, resistanceType)
327
359
  local buffByTypeId = buffByTypeIdByUnit[_unit]
328
360
  if buffByTypeId == nil then
329
361
  buffByTypeId = {}
@@ -340,8 +372,8 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
340
372
  if not internalApplyBuff(
341
373
  _unit,
342
374
  typeId,
343
- polarity,
344
- resistanceType,
375
+ self.polarity,
376
+ self.resistanceType,
345
377
  level,
346
378
  duration,
347
379
  spellStealPriority,
@@ -530,11 +562,11 @@ function Buff.prototype.onDestroy(self)
530
562
  behavior:destroy()
531
563
  end
532
564
  end
533
- if self[130] then
565
+ if self[136] then
534
566
  unit:decrementDisableAutoAttackCounter()
535
567
  end
536
- if self[128] then
537
- if self[129] then
568
+ if self[134] then
569
+ if self[135] then
538
570
  unit:decrementStunCounter()
539
571
  end
540
572
  unit:decrementStunCounter()
@@ -583,20 +615,34 @@ function Buff.getByTypeId(self, unit, typeId)
583
615
  end
584
616
  return nil
585
617
  end
586
- function Buff.prototype.onDeath(self, source)
618
+ function Buff.prototype.onExpiration(self)
587
619
  local unit = self.unit
588
620
  if self[119] ~= nil then
621
+ (self[101] or unit):damageTarget(unit, self[119] or 0)
622
+ end
623
+ if self[120] ~= nil then
624
+ (self[101] or unit):healTarget(unit, self[119] or 0)
625
+ end
626
+ if self[139] then
627
+ unit:explode()
628
+ elseif self[138] then
629
+ unit:kill()
630
+ end
631
+ end
632
+ function Buff.prototype.onDeath(self, source)
633
+ local unit = self.unit
634
+ if self[121] ~= nil then
589
635
  damageArea(
590
636
  self[101] or unit,
591
- self[119],
637
+ self[121],
592
638
  unit.x,
593
639
  unit.y,
594
- self[121] or 0,
595
- self[120] or 0,
596
640
  self[123] or 0,
597
641
  self[122] or 0,
598
642
  self[125] or 0,
599
- self[124] or 0
643
+ self[124] or 0,
644
+ self[127] or 0,
645
+ self[126] or 0
600
646
  )
601
647
  end
602
648
  end
@@ -618,9 +664,25 @@ function Buff.prototype.onDamageDealt(self, target, event)
618
664
  end
619
665
  self.remainingDuration = remainingDuration
620
666
  end
621
- local autoAttackCount = (self[126] or 0) + 1
622
- self[126] = autoAttackCount
623
- if autoAttackCount == self[127] then
667
+ local autoAttackCount = (self[128] or 0) + 1
668
+ self[128] = autoAttackCount
669
+ if autoAttackCount == self[129] then
670
+ self:destroy()
671
+ end
672
+ end
673
+ if event.originalAmount ~= 0 then
674
+ local damageDealtEventCount = (self[130] or 0) + 1
675
+ self[130] = damageDealtEventCount
676
+ if damageDealtEventCount == self[131] then
677
+ self:destroy()
678
+ end
679
+ end
680
+ end
681
+ function Buff.prototype.onDamageReceived(self, source, event)
682
+ if event.originalAmount ~= 0 then
683
+ local damageReceivedEventCount = (self[132] or 0) + 1
684
+ self[132] = damageReceivedEventCount
685
+ if damageReceivedEventCount == self[133] then
624
686
  self:destroy()
625
687
  end
626
688
  end
@@ -802,6 +864,45 @@ __TS__SetDescriptor(
802
864
  },
803
865
  true
804
866
  )
867
+ __TS__SetDescriptor(
868
+ Buff.prototype,
869
+ "damageOnExpiration",
870
+ {
871
+ get = function(self)
872
+ return self[119] or 0
873
+ end,
874
+ set = function(self, damageOnExpiration)
875
+ self[119] = damageOnExpiration ~= 0 and damageOnExpiration or nil
876
+ end
877
+ },
878
+ true
879
+ )
880
+ __TS__SetDescriptor(
881
+ Buff.prototype,
882
+ "healingOnExpiration",
883
+ {
884
+ get = function(self)
885
+ return self[120] or 0
886
+ end,
887
+ set = function(self, healingOnExpiration)
888
+ self[120] = healingOnExpiration ~= 0 and healingOnExpiration or nil
889
+ end
890
+ },
891
+ true
892
+ )
893
+ __TS__SetDescriptor(
894
+ Buff.prototype,
895
+ "damageFactor",
896
+ {
897
+ get = function(self)
898
+ return self:getUnitBonus(UnitBonusType.DAMAGE_FACTOR)
899
+ end,
900
+ set = function(self, damageFactor)
901
+ self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.DAMAGE_FACTOR, damageFactor)
902
+ end
903
+ },
904
+ true
905
+ )
805
906
  __TS__SetDescriptor(
806
907
  Buff.prototype,
807
908
  "receivedDamageFactor",
@@ -833,25 +934,25 @@ __TS__SetDescriptor(
833
934
  "stuns",
834
935
  {
835
936
  get = function(self)
836
- local ____self__128_52 = self[128]
837
- if ____self__128_52 == nil then
838
- ____self__128_52 = false
937
+ local ____self__134_52 = self[134]
938
+ if ____self__134_52 == nil then
939
+ ____self__134_52 = false
839
940
  end
840
- return ____self__128_52
941
+ return ____self__134_52
841
942
  end,
842
943
  set = function(self, stuns)
843
- if not stuns and self[128] then
844
- if self[129] then
944
+ if not stuns and self[134] then
945
+ if self[135] then
845
946
  self.object:decrementStunCounter()
846
947
  end
847
948
  self.object:decrementStunCounter()
848
- self[128] = nil
849
- elseif stuns and not self[128] then
850
- if self[129] then
949
+ self[134] = nil
950
+ elseif stuns and not self[134] then
951
+ if self[135] then
851
952
  self.object:incrementStunCounter()
852
953
  end
853
954
  self.object:incrementStunCounter()
854
- self[128] = true
955
+ self[134] = true
855
956
  end
856
957
  end
857
958
  },
@@ -862,23 +963,23 @@ __TS__SetDescriptor(
862
963
  "ignoresStunImmunity",
863
964
  {
864
965
  get = function(self)
865
- local ____self__129_53 = self[129]
866
- if ____self__129_53 == nil then
867
- ____self__129_53 = false
966
+ local ____self__135_53 = self[135]
967
+ if ____self__135_53 == nil then
968
+ ____self__135_53 = false
868
969
  end
869
- return ____self__129_53
970
+ return ____self__135_53
870
971
  end,
871
972
  set = function(self, ignoresStunImmunity)
872
- if not ignoresStunImmunity and self[129] then
873
- if self[128] then
973
+ if not ignoresStunImmunity and self[135] then
974
+ if self[134] then
874
975
  self.object:decrementStunCounter()
875
976
  end
876
- self[129] = nil
877
- elseif ignoresStunImmunity and not self[129] then
878
- if self[128] then
977
+ self[135] = nil
978
+ elseif ignoresStunImmunity and not self[135] then
979
+ if self[134] then
879
980
  self.object:incrementStunCounter()
880
981
  end
881
- self[129] = true
982
+ self[135] = true
882
983
  end
883
984
  end
884
985
  },
@@ -889,19 +990,19 @@ __TS__SetDescriptor(
889
990
  "disablesAutoAttack",
890
991
  {
891
992
  get = function(self)
892
- local ____self__130_54 = self[130]
893
- if ____self__130_54 == nil then
894
- ____self__130_54 = false
993
+ local ____self__136_54 = self[136]
994
+ if ____self__136_54 == nil then
995
+ ____self__136_54 = false
895
996
  end
896
- return ____self__130_54
997
+ return ____self__136_54
897
998
  end,
898
999
  set = function(self, disablesAutoAttack)
899
- if not disablesAutoAttack and self[130] then
1000
+ if not disablesAutoAttack and self[136] then
900
1001
  self.object:decrementDisableAutoAttackCounter()
901
- self[130] = nil
902
- elseif disablesAutoAttack and not self[130] then
1002
+ self[136] = nil
1003
+ elseif disablesAutoAttack and not self[136] then
903
1004
  self.object:incrementDisableAutoAttackCounter()
904
- self[130] = true
1005
+ self[136] = true
905
1006
  end
906
1007
  end
907
1008
  },
@@ -912,19 +1013,95 @@ __TS__SetDescriptor(
912
1013
  "providesInvulnerability",
913
1014
  {
914
1015
  get = function(self)
915
- local ____self__131_55 = self[131]
916
- if ____self__131_55 == nil then
917
- ____self__131_55 = false
1016
+ local ____self__137_55 = self[137]
1017
+ if ____self__137_55 == nil then
1018
+ ____self__137_55 = false
918
1019
  end
919
- return ____self__131_55
1020
+ return ____self__137_55
920
1021
  end,
921
1022
  set = function(self, providesInvulnerability)
922
- if not providesInvulnerability and self[131] then
1023
+ if not providesInvulnerability and self[137] then
923
1024
  self.object:decrementInvulnerabilityCounter()
924
- self[131] = nil
925
- elseif providesInvulnerability and not self[131] then
1025
+ self[137] = nil
1026
+ elseif providesInvulnerability and not self[137] then
926
1027
  self.object:incrementInvulnerabilityCounter()
927
- self[131] = true
1028
+ self[137] = true
1029
+ end
1030
+ end
1031
+ },
1032
+ true
1033
+ )
1034
+ __TS__SetDescriptor(
1035
+ Buff.prototype,
1036
+ "killsOnExpiration",
1037
+ {
1038
+ get = function(self)
1039
+ local ____self__138_56 = self[138]
1040
+ if ____self__138_56 == nil then
1041
+ ____self__138_56 = false
1042
+ end
1043
+ return ____self__138_56
1044
+ end,
1045
+ set = function(self, killsOnExpiration)
1046
+ if not killsOnExpiration and self[138] then
1047
+ self[138] = nil
1048
+ elseif killsOnExpiration and not self[138] then
1049
+ self[138] = true
1050
+ end
1051
+ end
1052
+ },
1053
+ true
1054
+ )
1055
+ __TS__SetDescriptor(
1056
+ Buff.prototype,
1057
+ "explodesOnExpiration",
1058
+ {
1059
+ get = function(self)
1060
+ local ____self__139_57 = self[139]
1061
+ if ____self__139_57 == nil then
1062
+ ____self__139_57 = false
1063
+ end
1064
+ return ____self__139_57
1065
+ end,
1066
+ set = function(self, killsOnExpiration)
1067
+ if not killsOnExpiration and self[139] then
1068
+ self[139] = nil
1069
+ elseif killsOnExpiration and not self[139] then
1070
+ self[139] = true
1071
+ end
1072
+ end
1073
+ },
1074
+ true
1075
+ )
1076
+ __TS__SetDescriptor(
1077
+ Buff.prototype,
1078
+ "maximumDamageDealtEventCount",
1079
+ {
1080
+ get = function(self)
1081
+ return self[131] or 0
1082
+ end,
1083
+ set = function(self, maximumDamageDealtEventCount)
1084
+ if maximumDamageDealtEventCount == 0 then
1085
+ self[131] = nil
1086
+ else
1087
+ self[131] = maximumDamageDealtEventCount
1088
+ end
1089
+ end
1090
+ },
1091
+ true
1092
+ )
1093
+ __TS__SetDescriptor(
1094
+ Buff.prototype,
1095
+ "maximumDamageReceivedEventCount",
1096
+ {
1097
+ get = function(self)
1098
+ return self[133] or 0
1099
+ end,
1100
+ set = function(self, maximumDamageReceivedEventCount)
1101
+ if maximumDamageReceivedEventCount == 0 then
1102
+ self[133] = nil
1103
+ else
1104
+ self[133] = maximumDamageReceivedEventCount
928
1105
  end
929
1106
  end
930
1107
  },
@@ -935,13 +1112,13 @@ __TS__SetDescriptor(
935
1112
  "maximumAutoAttackCount",
936
1113
  {
937
1114
  get = function(self)
938
- return self[127] or 0
1115
+ return self[129] or 0
939
1116
  end,
940
1117
  set = function(self, maximumAutoAttackCount)
941
1118
  if maximumAutoAttackCount == 0 then
942
- self[127] = nil
1119
+ self[129] = nil
943
1120
  else
944
- self[127] = maximumAutoAttackCount
1121
+ self[129] = maximumAutoAttackCount
945
1122
  end
946
1123
  end
947
1124
  },
@@ -999,13 +1176,13 @@ __TS__SetDescriptor(
999
1176
  "remainingDuration",
1000
1177
  {
1001
1178
  get = function(self)
1002
- local ____opt_56 = self._timer
1003
- return ____opt_56 and ____opt_56.remaining or 0
1179
+ local ____opt_58 = self._timer
1180
+ return ____opt_58 and ____opt_58.remaining or 0
1004
1181
  end,
1005
1182
  set = function(self, remainingDuration)
1006
- local ____remainingDuration_60 = remainingDuration
1007
- local ____opt_58 = self._timer
1008
- local remainingDurationDelta = ____remainingDuration_60 - (____opt_58 and ____opt_58.remaining or 0)
1183
+ local ____remainingDuration_62 = remainingDuration
1184
+ local ____opt_60 = self._timer
1185
+ local remainingDurationDelta = ____remainingDuration_62 - (____opt_60 and ____opt_60.remaining or 0)
1009
1186
  if remainingDurationDelta ~= 0 then
1010
1187
  self[102] = self[102] + remainingDurationDelta
1011
1188
  if remainingDuration <= 0 then
@@ -1035,24 +1212,22 @@ __TS__SetDescriptor(
1035
1212
  true
1036
1213
  );
1037
1214
  (function(self)
1215
+ local function destroyBuffIfNeeded(buff)
1216
+ if getUnitAbility(buff[100].handle, buff.typeId) ~= buff.handle then
1217
+ buff:destroy()
1218
+ end
1219
+ end
1038
1220
  ____exports.checkBuff = function(unit, buffTypeId)
1039
1221
  local buffByTypeId = buffByTypeIdByUnit[unit]
1040
1222
  if buffByTypeId ~= nil then
1041
1223
  local buff = buffByTypeId[buffTypeId]
1042
- if buff ~= nil and getUnitAbility(unit.handle, buffTypeId) ~= buff.handle then
1043
- buff:destroy()
1224
+ if buff ~= nil then
1225
+ destroyBuffIfNeeded(buff)
1044
1226
  end
1045
1227
  end
1046
1228
  end
1047
1229
  ____exports.checkBuffs = function(unit)
1048
- local buffByTypeId = buffByTypeIdByUnit[unit]
1049
- if buffByTypeId ~= nil then
1050
- for ____, buff in pairs(buffByTypeId) do
1051
- if getUnitAbility(unit.handle, buff.typeId) ~= buff.handle then
1052
- buff:destroy()
1053
- end
1054
- end
1055
- end
1230
+ ____exports.Buff:forAll(unit, destroyBuffIfNeeded)
1056
1231
  end
1057
1232
  Unit.abilityChannelingStartEvent:addListener(
1058
1233
  0,
@@ -0,0 +1,7 @@
1
+ /** @noSelfInFile */
2
+ import { Rect } from "../core/types/rect";
3
+ import { Region } from "../core/types/region";
4
+ export declare class GameMap {
5
+ static get worldBoundsRect(): Rect;
6
+ static get worldBoundsRegion(): Region;
7
+ }