warscript 0.0.1-dev.c8d6bc0 → 0.0.1-dev.c963f13

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.
@@ -79,12 +79,16 @@ interface UnitWeapon {
79
79
  declare const enum UnitPropertyKey {
80
80
  IS_PAUSED = 100,
81
81
  STUN_COUNTER = 101,
82
- PREVENT_DEATH_HEALTH_BONUS = 102,
83
- IS_TEAM_GLOW_HIDDEN = 103
82
+ DELAY_HEALTH_CHECKS_COUNTER = 102,
83
+ DELAY_HEALTH_CHECKS_HEALTH_BONUS = 103,
84
+ PREVENT_DEATH_HEALTH_BONUS = 104,
85
+ IS_TEAM_GLOW_HIDDEN = 105
84
86
  }
85
87
  export declare class Unit extends Handle<junit> {
86
88
  private [UnitPropertyKey.IS_PAUSED]?;
87
89
  private [UnitPropertyKey.STUN_COUNTER]?;
90
+ private [UnitPropertyKey.DELAY_HEALTH_CHECKS_COUNTER]?;
91
+ private [UnitPropertyKey.DELAY_HEALTH_CHECKS_HEALTH_BONUS]?;
88
92
  private [UnitPropertyKey.PREVENT_DEATH_HEALTH_BONUS]?;
89
93
  private [UnitPropertyKey.IS_TEAM_GLOW_HIDDEN]?;
90
94
  private _owner?;
@@ -148,6 +152,10 @@ export declare class Unit extends Handle<junit> {
148
152
  set color(color: PlayerColor);
149
153
  get acquisitionRange(): number;
150
154
  set acquisitionRange(v: number);
155
+ /**
156
+ * Keeps this unit alive even if its health becomes negative until the current game thread yields.
157
+ */
158
+ delayHealthChecks(): void;
151
159
  get maxHealth(): number;
152
160
  set maxHealth(maxHealth: number);
153
161
  get healthRegenerationRate(): number;
@@ -520,6 +520,23 @@ for ____, player in ipairs(Player.all) do
520
520
  ShowUnit(dummy, false)
521
521
  dummies[player] = dummy
522
522
  end
523
+ local function delayHealthChecksCallback(unit)
524
+ local counter = (unit[102] or 0) - 1
525
+ if counter ~= 0 then
526
+ unit[102] = counter
527
+ return
528
+ end
529
+ unit[102] = nil
530
+ local healthBonus = unit[103]
531
+ if healthBonus ~= nil then
532
+ unit[103] = nil
533
+ local handle = unit.handle
534
+ BlzSetUnitMaxHP(
535
+ handle,
536
+ BlzGetUnitMaxHP(handle) - healthBonus
537
+ )
538
+ end
539
+ end
523
540
  ____exports.Unit = __TS__Class()
524
541
  local Unit = ____exports.Unit
525
542
  Unit.name = "Unit"
@@ -674,6 +691,10 @@ end
674
691
  function Unit.prototype.queueAnimation(self, animation)
675
692
  queueUnitAnimation(self.handle, animation)
676
693
  end
694
+ function Unit.prototype.delayHealthChecks(self)
695
+ self[102] = (self[102] or 0) + 1
696
+ Timer:run(delayHealthChecksCallback, self)
697
+ end
677
698
  function Unit.prototype.setPosition(self, x, y)
678
699
  setUnitPosition(self.handle, x, y)
679
700
  end
@@ -1233,7 +1254,7 @@ __TS__SetDescriptor(
1233
1254
  "isTeamGlowVisible",
1234
1255
  {
1235
1256
  get = function(self)
1236
- return not self[103]
1257
+ return not self[105]
1237
1258
  end,
1238
1259
  set = function(self, isTeamGlowVisible)
1239
1260
  showUnitTeamGlow(self.handle, isTeamGlowVisible)
@@ -1243,7 +1264,7 @@ __TS__SetDescriptor(
1243
1264
  else
1244
1265
  ____temp_2 = nil
1245
1266
  end
1246
- self[103] = ____temp_2
1267
+ self[105] = ____temp_2
1247
1268
  end
1248
1269
  },
1249
1270
  true
@@ -1253,7 +1274,7 @@ __TS__SetDescriptor(
1253
1274
  "color",
1254
1275
  {set = function(self, color)
1255
1276
  setUnitColor(self.handle, color.handle)
1256
- if self[103] then
1277
+ if self[105] then
1257
1278
  showUnitTeamGlow(self.handle, false)
1258
1279
  end
1259
1280
  end},
@@ -1277,10 +1298,14 @@ __TS__SetDescriptor(
1277
1298
  "maxHealth",
1278
1299
  {
1279
1300
  get = function(self)
1280
- return BlzGetUnitMaxHP(self.handle) - (self[102] or 0)
1301
+ return BlzGetUnitMaxHP(self.handle) - (self[103] or 0) - (self[104] or 0)
1281
1302
  end,
1282
1303
  set = function(self, maxHealth)
1283
- BlzSetUnitMaxHP(self.handle, maxHealth + (self[102] or 0))
1304
+ if maxHealth < 1 and self[102] ~= nil then
1305
+ self[103] = (self[103] or 0) + (1 - maxHealth)
1306
+ maxHealth = 1
1307
+ end
1308
+ BlzSetUnitMaxHP(self.handle, maxHealth + (self[104] or 0))
1284
1309
  end
1285
1310
  },
1286
1311
  true
@@ -1322,10 +1347,10 @@ __TS__SetDescriptor(
1322
1347
  "health",
1323
1348
  {
1324
1349
  get = function(self)
1325
- return GetWidgetLife(self.handle) - (self[102] or 0)
1350
+ return GetWidgetLife(self.handle) - (self[104] or 0)
1326
1351
  end,
1327
1352
  set = function(self, health)
1328
- SetWidgetLife(self.handle, health + (self[102] or 0))
1353
+ SetWidgetLife(self.handle, health + (self[104] or 0))
1329
1354
  end
1330
1355
  },
1331
1356
  true
@@ -2308,7 +2333,7 @@ Unit.onDamage = __TS__New(
2308
2333
  invoke(event, source, target, evData)
2309
2334
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2310
2335
  local bonusHealth = math.ceil(evData.amount)
2311
- target[102] = (target[102] or 0) + bonusHealth
2336
+ target[104] = (target[104] or 0) + bonusHealth
2312
2337
  BlzSetUnitMaxHP(
2313
2338
  target.handle,
2314
2339
  BlzGetUnitMaxHP(target.handle) + bonusHealth
@@ -2322,7 +2347,7 @@ Unit.onDamage = __TS__New(
2322
2347
  evData[0],
2323
2348
  table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
2324
2349
  )
2325
- target[102] = (target[102] or 0) - bonusHealth
2350
+ target[104] = (target[104] or 0) - bonusHealth
2326
2351
  SetWidgetLife(
2327
2352
  target.handle,
2328
2353
  GetWidgetLife(target.handle) - bonusHealth
@@ -28,6 +28,16 @@ export declare class UnitTypeWeapon {
28
28
  set attackType(attackType: AttackType);
29
29
  get backSwingDuration(): number;
30
30
  set backSwingDuration(backSwingDuration: number);
31
+ get cooldown(): number;
32
+ set cooldown(cooldown: number);
33
+ get damage(): [minimumDamage: number, maximumDamage: number];
34
+ set damage([minimumDamage, maximumDamage]: [number, number]);
35
+ get damageBase(): number;
36
+ set damageBase(damageBase: number);
37
+ get damageDiceCount(): number;
38
+ set damageDiceCount(damageDiceNumber: number);
39
+ get damageDiceSideCount(): number;
40
+ set damageDiceSideCount(damageDiceSideCount: number);
31
41
  get impactDelay(): number;
32
42
  set impactDelay(impactDelay: number);
33
43
  get missileModelPath(): string;
@@ -176,9 +186,9 @@ export declare abstract class UnitType<Id extends UnitTypeId = UnitTypeId> exten
176
186
  set combatClassifications(combatClassifications: CombatClassifications);
177
187
  get unitClassifications(): UnitClassifications;
178
188
  set unitClassifications(unitClassifications: UnitClassifications);
189
+ get weapons(): TupleOf<UnitTypeWeapon, 2>;
179
190
  get firstWeapon(): UnitTypeWeapon;
180
191
  get secondWeapon(): UnitTypeWeapon;
181
- get weapons(): TupleOf<UnitTypeWeapon, 2>;
182
192
  get flyHeight(): number;
183
193
  set flyHeight(flyHeight: number);
184
194
  get flyHeightMinimum(): number;
@@ -207,6 +217,16 @@ export declare abstract class UnitType<Id extends UnitTypeId = UnitTypeId> exten
207
217
  set formationRank(formationRank: number);
208
218
  get goldCost(): number;
209
219
  set goldCost(goldCost: number);
220
+ get healthRegenerationRate(): number;
221
+ set healthRegenerationRate(healthRegenerationRate: number);
222
+ get manaRegenerationRate(): number;
223
+ set manaRegenerationRate(manaRegenerationRate: number);
224
+ get maximumHealth(): number;
225
+ set maximumHealth(maximumHealth: number);
226
+ get maximumMana(): number;
227
+ set maximumMana(maximumMana: number);
228
+ get initialMana(): number;
229
+ set initialMana(initialMana: number);
210
230
  get isStructure(): boolean;
211
231
  set isStructure(isStructure: boolean);
212
232
  get race(): Race;
@@ -73,21 +73,21 @@ __TS__SetDescriptor(
73
73
  )
74
74
  __TS__SetDescriptor(
75
75
  UnitTypeWeapon.prototype,
76
- "impactDelay",
76
+ "cooldown",
77
77
  {
78
78
  get = function(self)
79
79
  local ____self_4 = self.unitType
80
80
  return ____self_4.getNumberField(
81
81
  ____self_4,
82
- "udp" .. tostring(self.index)
82
+ ("ua" .. tostring(self.index)) .. "c"
83
83
  )
84
84
  end,
85
- set = function(self, impactDelay)
85
+ set = function(self, cooldown)
86
86
  local ____self_5 = self.unitType
87
87
  ____self_5.setNumberField(
88
88
  ____self_5,
89
- "udp" .. tostring(self.index),
90
- impactDelay
89
+ ("ua" .. tostring(self.index)) .. "c",
90
+ cooldown
91
91
  )
92
92
  end
93
93
  },
@@ -95,21 +95,42 @@ __TS__SetDescriptor(
95
95
  )
96
96
  __TS__SetDescriptor(
97
97
  UnitTypeWeapon.prototype,
98
- "missileModelPath",
98
+ "damage",
99
+ {
100
+ get = function(self)
101
+ local minimumDamage = self.damageBase + self.damageDiceCount
102
+ local maximumDamage = self.damageBase + self.damageDiceCount * self.damageDiceSideCount
103
+ return {minimumDamage, maximumDamage}
104
+ end,
105
+ set = function(self, ____bindingPattern0)
106
+ local maximumDamage
107
+ local minimumDamage
108
+ minimumDamage = ____bindingPattern0[1]
109
+ maximumDamage = ____bindingPattern0[2]
110
+ self.damageBase = minimumDamage - 1
111
+ self.damageDiceCount = 1
112
+ self.damageDiceSideCount = maximumDamage - minimumDamage + 1
113
+ end
114
+ },
115
+ true
116
+ )
117
+ __TS__SetDescriptor(
118
+ UnitTypeWeapon.prototype,
119
+ "damageBase",
99
120
  {
100
121
  get = function(self)
101
122
  local ____self_6 = self.unitType
102
- return ____self_6.getStringField(
123
+ return ____self_6.getNumberField(
103
124
  ____self_6,
104
- ("ua" .. tostring(self.index)) .. "m"
125
+ ("ua" .. tostring(self.index)) .. "b"
105
126
  )
106
127
  end,
107
- set = function(self, missileModelPath)
128
+ set = function(self, damageBase)
108
129
  local ____self_7 = self.unitType
109
- ____self_7.setStringField(
130
+ ____self_7.setNumberField(
110
131
  ____self_7,
111
- ("ua" .. tostring(self.index)) .. "m",
112
- missileModelPath
132
+ ("ua" .. tostring(self.index)) .. "b",
133
+ damageBase
113
134
  )
114
135
  end
115
136
  },
@@ -117,19 +138,107 @@ __TS__SetDescriptor(
117
138
  )
118
139
  __TS__SetDescriptor(
119
140
  UnitTypeWeapon.prototype,
120
- "range",
141
+ "damageDiceCount",
121
142
  {
122
143
  get = function(self)
123
144
  local ____self_8 = self.unitType
124
145
  return ____self_8.getNumberField(
125
146
  ____self_8,
126
- ("ua" .. tostring(self.index)) .. "r"
147
+ ("ua" .. tostring(self.index)) .. "d"
127
148
  )
128
149
  end,
129
- set = function(self, range)
150
+ set = function(self, damageDiceNumber)
130
151
  local ____self_9 = self.unitType
131
152
  ____self_9.setNumberField(
132
153
  ____self_9,
154
+ ("ua" .. tostring(self.index)) .. "d",
155
+ damageDiceNumber
156
+ )
157
+ end
158
+ },
159
+ true
160
+ )
161
+ __TS__SetDescriptor(
162
+ UnitTypeWeapon.prototype,
163
+ "damageDiceSideCount",
164
+ {
165
+ get = function(self)
166
+ local ____self_10 = self.unitType
167
+ return ____self_10.getNumberField(
168
+ ____self_10,
169
+ ("ua" .. tostring(self.index)) .. "s"
170
+ )
171
+ end,
172
+ set = function(self, damageDiceSideCount)
173
+ local ____self_11 = self.unitType
174
+ ____self_11.setNumberField(
175
+ ____self_11,
176
+ ("ua" .. tostring(self.index)) .. "s",
177
+ damageDiceSideCount
178
+ )
179
+ end
180
+ },
181
+ true
182
+ )
183
+ __TS__SetDescriptor(
184
+ UnitTypeWeapon.prototype,
185
+ "impactDelay",
186
+ {
187
+ get = function(self)
188
+ local ____self_12 = self.unitType
189
+ return ____self_12.getNumberField(
190
+ ____self_12,
191
+ "udp" .. tostring(self.index)
192
+ )
193
+ end,
194
+ set = function(self, impactDelay)
195
+ local ____self_13 = self.unitType
196
+ ____self_13.setNumberField(
197
+ ____self_13,
198
+ "udp" .. tostring(self.index),
199
+ impactDelay
200
+ )
201
+ end
202
+ },
203
+ true
204
+ )
205
+ __TS__SetDescriptor(
206
+ UnitTypeWeapon.prototype,
207
+ "missileModelPath",
208
+ {
209
+ get = function(self)
210
+ local ____self_14 = self.unitType
211
+ return ____self_14.getStringField(
212
+ ____self_14,
213
+ ("ua" .. tostring(self.index)) .. "m"
214
+ )
215
+ end,
216
+ set = function(self, missileModelPath)
217
+ local ____self_15 = self.unitType
218
+ ____self_15.setStringField(
219
+ ____self_15,
220
+ ("ua" .. tostring(self.index)) .. "m",
221
+ missileModelPath
222
+ )
223
+ end
224
+ },
225
+ true
226
+ )
227
+ __TS__SetDescriptor(
228
+ UnitTypeWeapon.prototype,
229
+ "range",
230
+ {
231
+ get = function(self)
232
+ local ____self_16 = self.unitType
233
+ return ____self_16.getNumberField(
234
+ ____self_16,
235
+ ("ua" .. tostring(self.index)) .. "r"
236
+ )
237
+ end,
238
+ set = function(self, range)
239
+ local ____self_17 = self.unitType
240
+ ____self_17.setNumberField(
241
+ ____self_17,
133
242
  ("ua" .. tostring(self.index)) .. "r",
134
243
  range
135
244
  )
@@ -142,16 +251,16 @@ __TS__SetDescriptor(
142
251
  "soundType",
143
252
  {
144
253
  get = function(self)
145
- local ____self_10 = self.unitType
146
- return ____self_10.getStringField(
147
- ____self_10,
254
+ local ____self_18 = self.unitType
255
+ return ____self_18.getStringField(
256
+ ____self_18,
148
257
  "ucs" .. tostring(self.index)
149
258
  )
150
259
  end,
151
260
  set = function(self, soundType)
152
- local ____self_11 = self.unitType
153
- ____self_11.setStringField(
154
- ____self_11,
261
+ local ____self_19 = self.unitType
262
+ ____self_19.setStringField(
263
+ ____self_19,
155
264
  "ucs" .. tostring(self.index),
156
265
  soundType
157
266
  )
@@ -164,16 +273,16 @@ __TS__SetDescriptor(
164
273
  "soundTypeSD",
165
274
  {
166
275
  get = function(self)
167
- local ____self_12 = self.unitType
168
- return ____self_12.getStringField(
169
- ____self_12,
276
+ local ____self_20 = self.unitType
277
+ return ____self_20.getStringField(
278
+ ____self_20,
170
279
  ("ucs" .. tostring(self.index)) .. ":sd"
171
280
  )
172
281
  end,
173
282
  set = function(self, soundTypeSD)
174
- local ____self_13 = self.unitType
175
- ____self_13.setStringField(
176
- ____self_13,
283
+ local ____self_21 = self.unitType
284
+ ____self_21.setStringField(
285
+ ____self_21,
177
286
  ("ucs" .. tostring(self.index)) .. ":sd",
178
287
  soundTypeSD
179
288
  )
@@ -186,16 +295,16 @@ __TS__SetDescriptor(
186
295
  "soundTypeHD",
187
296
  {
188
297
  get = function(self)
189
- local ____self_14 = self.unitType
190
- return ____self_14.getStringField(
191
- ____self_14,
298
+ local ____self_22 = self.unitType
299
+ return ____self_22.getStringField(
300
+ ____self_22,
192
301
  ("ucs" .. tostring(self.index)) .. ":hd"
193
302
  )
194
303
  end,
195
304
  set = function(self, soundTypeHD)
196
- local ____self_15 = self.unitType
197
- ____self_15.setStringField(
198
- ____self_15,
305
+ local ____self_23 = self.unitType
306
+ ____self_23.setStringField(
307
+ ____self_23,
199
308
  ("ucs" .. tostring(self.index)) .. ":hd",
200
309
  soundTypeHD
201
310
  )
@@ -1087,25 +1196,25 @@ __TS__SetDescriptor(
1087
1196
  )
1088
1197
  __TS__SetDescriptor(
1089
1198
  UnitType.prototype,
1090
- "firstWeapon",
1199
+ "weapons",
1091
1200
  {get = function(self)
1092
- return self.weapons[1]
1201
+ return getOrCreateUnitTypeWeapons(self)
1093
1202
  end},
1094
1203
  true
1095
1204
  )
1096
1205
  __TS__SetDescriptor(
1097
1206
  UnitType.prototype,
1098
- "secondWeapon",
1207
+ "firstWeapon",
1099
1208
  {get = function(self)
1100
- return self.weapons[2]
1209
+ return self.weapons[1]
1101
1210
  end},
1102
1211
  true
1103
1212
  )
1104
1213
  __TS__SetDescriptor(
1105
1214
  UnitType.prototype,
1106
- "weapons",
1215
+ "secondWeapon",
1107
1216
  {get = function(self)
1108
- return getOrCreateUnitTypeWeapons(self)
1217
+ return self.weapons[2]
1109
1218
  end},
1110
1219
  true
1111
1220
  )
@@ -1291,6 +1400,71 @@ __TS__SetDescriptor(
1291
1400
  },
1292
1401
  true
1293
1402
  )
1403
+ __TS__SetDescriptor(
1404
+ UnitType.prototype,
1405
+ "healthRegenerationRate",
1406
+ {
1407
+ get = function(self)
1408
+ return self:getNumberField("uhpr")
1409
+ end,
1410
+ set = function(self, healthRegenerationRate)
1411
+ self:setNumberField("uhpr", healthRegenerationRate)
1412
+ end
1413
+ },
1414
+ true
1415
+ )
1416
+ __TS__SetDescriptor(
1417
+ UnitType.prototype,
1418
+ "manaRegenerationRate",
1419
+ {
1420
+ get = function(self)
1421
+ return self:getNumberField("umpr")
1422
+ end,
1423
+ set = function(self, manaRegenerationRate)
1424
+ self:setNumberField("umpr", manaRegenerationRate)
1425
+ end
1426
+ },
1427
+ true
1428
+ )
1429
+ __TS__SetDescriptor(
1430
+ UnitType.prototype,
1431
+ "maximumHealth",
1432
+ {
1433
+ get = function(self)
1434
+ return self:getNumberField("uhpm")
1435
+ end,
1436
+ set = function(self, maximumHealth)
1437
+ self:setNumberField("uhpm", maximumHealth)
1438
+ end
1439
+ },
1440
+ true
1441
+ )
1442
+ __TS__SetDescriptor(
1443
+ UnitType.prototype,
1444
+ "maximumMana",
1445
+ {
1446
+ get = function(self)
1447
+ return self:getNumberField("umpm")
1448
+ end,
1449
+ set = function(self, maximumMana)
1450
+ self:setNumberField("umpm", maximumMana)
1451
+ end
1452
+ },
1453
+ true
1454
+ )
1455
+ __TS__SetDescriptor(
1456
+ UnitType.prototype,
1457
+ "initialMana",
1458
+ {
1459
+ get = function(self)
1460
+ return self:getNumberField("umpi")
1461
+ end,
1462
+ set = function(self, initialMana)
1463
+ self:setNumberField("umpi", initialMana)
1464
+ end
1465
+ },
1466
+ true
1467
+ )
1294
1468
  __TS__SetDescriptor(
1295
1469
  UnitType.prototype,
1296
1470
  "isStructure",
@@ -1385,11 +1559,11 @@ __TS__SetDescriptor(
1385
1559
  implementReadonlyNumberIndexSupplier(
1386
1560
  ____exports.UnitType,
1387
1561
  function(id)
1388
- local ____class_16 = __TS__Class()
1389
- ____class_16.name = ____class_16.name
1390
- __TS__ClassExtends(____class_16, ____exports.UnitType)
1391
- ____class_16.BASE_ID = id
1392
- return ____class_16
1562
+ local ____class_24 = __TS__Class()
1563
+ ____class_24.name = ____class_24.name
1564
+ __TS__ClassExtends(____class_24, ____exports.UnitType)
1565
+ ____class_24.BASE_ID = id
1566
+ return ____class_24
1393
1567
  end
1394
1568
  )
1395
1569
  ____exports.HeroUnitType = __TS__Class()
@@ -1450,11 +1624,11 @@ __TS__SetDescriptor(
1450
1624
  implementReadonlyNumberIndexSupplier(
1451
1625
  ____exports.HeroUnitType,
1452
1626
  function(id)
1453
- local ____class_17 = __TS__Class()
1454
- ____class_17.name = ____class_17.name
1455
- __TS__ClassExtends(____class_17, ____exports.HeroUnitType)
1456
- ____class_17.BASE_ID = id
1457
- return ____class_17
1627
+ local ____class_25 = __TS__Class()
1628
+ ____class_25.name = ____class_25.name
1629
+ __TS__ClassExtends(____class_25, ____exports.HeroUnitType)
1630
+ ____class_25.BASE_ID = id
1631
+ return ____class_25
1458
1632
  end
1459
1633
  )
1460
1634
  return ____exports
@@ -9,11 +9,31 @@ export declare const RIFLEMAN_UNIT_TYPE_ID: StandardUnitTypeId;
9
9
  export declare const SIEGE_ENGINE_UNIT_TYPE_ID: StandardUnitTypeId;
10
10
  export declare const SORCERESS_UNIT_TYPE_ID: StandardUnitTypeId;
11
11
  export declare const SPELLBREAKER_UNIT_TYPE_ID: StandardUnitTypeId;
12
- export declare const PALADIN_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
13
12
  export declare const ARCHMAGE_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
13
+ export declare const BLOOD_MAGE_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
14
+ export declare const MOUNTAIN_KING_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
15
+ export declare const PALADIN_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
14
16
  export declare const CAPTAIN_UNIT_TYPE_ID: StandardUnitTypeId;
17
+ export declare const ADMIRAL_PROUDMOORE_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
18
+ export declare const ANASTERIAN_SUNSTRIDER_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
19
+ export declare const ANTONIDAS_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
20
+ export declare const ANTONIDAS_GHOST_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
15
21
  export declare const ARTHAS_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
16
22
  export declare const ARTHAS_WITH_FROSTMOURNE_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
23
+ export declare const DAGREN_THE_ORCSLAYER_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
24
+ export declare const HALAHK_THE_LIFEBRINGER_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
25
+ export declare const JAINA_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
26
+ export declare const JENNALLA_DEEMSPRING_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
27
+ export declare const KAEL_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
28
+ export declare const KELEN_THE_SEEKER_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
29
+ export declare const LORD_GARITHOS_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
30
+ export declare const LORD_NICHOLAS_BUZAN_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
31
+ export declare const MAGROTH_THE_DEFENDER_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
32
+ export declare const MURADIN_BRONZEBEARD_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
33
+ export declare const SIR_GREGORY_EDMUNSON_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
34
+ export declare const SYLVANAS_WINDRUNNER_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
35
+ export declare const THALORIEN_DAWNSEEKER_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
36
+ export declare const UTHER_HERO_UNIT_TYPE_ID: StandardHeroUnitTypeId;
17
37
  export declare const BATRIDER_UNIT_TYPE_ID: StandardUnitTypeId;
18
38
  export declare const DEMOLISHER_UNIT_TYPE_ID: StandardUnitTypeId;
19
39
  export declare const GRUNT_UNIT_TYPE_ID: StandardUnitTypeId;
@@ -8,11 +8,31 @@ ____exports.RIFLEMAN_UNIT_TYPE_ID = fourCC("hrif")
8
8
  ____exports.SIEGE_ENGINE_UNIT_TYPE_ID = fourCC("hmtt")
9
9
  ____exports.SORCERESS_UNIT_TYPE_ID = fourCC("hsor")
10
10
  ____exports.SPELLBREAKER_UNIT_TYPE_ID = fourCC("hspt")
11
- ____exports.PALADIN_HERO_UNIT_TYPE_ID = fourCC("Hpal")
12
11
  ____exports.ARCHMAGE_HERO_UNIT_TYPE_ID = fourCC("Hamg")
12
+ ____exports.BLOOD_MAGE_HERO_UNIT_TYPE_ID = fourCC("Hblm")
13
+ ____exports.MOUNTAIN_KING_HERO_UNIT_TYPE_ID = fourCC("Hmkg")
14
+ ____exports.PALADIN_HERO_UNIT_TYPE_ID = fourCC("Hpal")
13
15
  ____exports.CAPTAIN_UNIT_TYPE_ID = fourCC("hcth")
16
+ ____exports.ADMIRAL_PROUDMOORE_HERO_UNIT_TYPE_ID = fourCC("Hapm")
17
+ ____exports.ANASTERIAN_SUNSTRIDER_HERO_UNIT_TYPE_ID = fourCC("Hssa")
18
+ ____exports.ANTONIDAS_HERO_UNIT_TYPE_ID = fourCC("Hant")
19
+ ____exports.ANTONIDAS_GHOST_HERO_UNIT_TYPE_ID = fourCC("Hgam")
14
20
  ____exports.ARTHAS_HERO_UNIT_TYPE_ID = fourCC("Hart")
15
21
  ____exports.ARTHAS_WITH_FROSTMOURNE_HERO_UNIT_TYPE_ID = fourCC("Harf")
22
+ ____exports.DAGREN_THE_ORCSLAYER_HERO_UNIT_TYPE_ID = fourCC("Hdgo")
23
+ ____exports.HALAHK_THE_LIFEBRINGER_HERO_UNIT_TYPE_ID = fourCC("Hhkl")
24
+ ____exports.JAINA_HERO_UNIT_TYPE_ID = fourCC("Hjai")
25
+ ____exports.JENNALLA_DEEMSPRING_HERO_UNIT_TYPE_ID = fourCC("Hjnd")
26
+ ____exports.KAEL_HERO_UNIT_TYPE_ID = fourCC("Hkal")
27
+ ____exports.KELEN_THE_SEEKER_HERO_UNIT_TYPE_ID = fourCC("Haah")
28
+ ____exports.LORD_GARITHOS_HERO_UNIT_TYPE_ID = fourCC("Hlgr")
29
+ ____exports.LORD_NICHOLAS_BUZAN_HERO_UNIT_TYPE_ID = fourCC("Hpb1")
30
+ ____exports.MAGROTH_THE_DEFENDER_HERO_UNIT_TYPE_ID = fourCC("Hmgd")
31
+ ____exports.MURADIN_BRONZEBEARD_HERO_UNIT_TYPE_ID = fourCC("Hmbr")
32
+ ____exports.SIR_GREGORY_EDMUNSON_HERO_UNIT_TYPE_ID = fourCC("Hpb2")
33
+ ____exports.SYLVANAS_WINDRUNNER_HERO_UNIT_TYPE_ID = fourCC("Hvwd")
34
+ ____exports.THALORIEN_DAWNSEEKER_HERO_UNIT_TYPE_ID = fourCC("Hddt")
35
+ ____exports.UTHER_HERO_UNIT_TYPE_ID = fourCC("Huth")
16
36
  ____exports.BATRIDER_UNIT_TYPE_ID = fourCC("otbr")
17
37
  ____exports.DEMOLISHER_UNIT_TYPE_ID = fourCC("ocat")
18
38
  ____exports.GRUNT_UNIT_TYPE_ID = fourCC("ogru")
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.c8d6bc0",
4
+ "version": "0.0.1-dev.c963f13",
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.3",
26
26
  "lua-types": "^2.13.1",
27
- "warpack": "0.0.1-dev.5bdabe5"
27
+ "warpack": "0.0.1-dev.ec41c86"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@typescript-eslint/eslint-plugin": "^5.59.11",
package/string.d.ts CHANGED
@@ -103,4 +103,18 @@ declare global {
103
103
  function isNotBlank(string: string): boolean;
104
104
  }
105
105
  }
106
+ declare global {
107
+ namespace string {
108
+ /**
109
+ * Returns the number of characters matching the given predicate.
110
+ */
111
+ function count(string: string, predicate: (char: string) => boolean): number;
112
+ }
113
+ interface String {
114
+ /**
115
+ * Returns the number of characters matching the given predicate.
116
+ */
117
+ count(predicate: (char: string) => boolean): number;
118
+ }
119
+ }
106
120
  export {};
package/string.lua CHANGED
@@ -31,4 +31,13 @@ end
31
31
  _G.string.isNotBlank = function(____string)
32
32
  return (match(____string, "^%s*$")) == nil
33
33
  end
34
+ _G.string.count = function(____string, predicate)
35
+ local result = 0
36
+ for i = 1, #____string do
37
+ if predicate(sub(____string, i, i)) then
38
+ result = result + 1
39
+ end
40
+ end
41
+ return result
42
+ end
34
43
  return ____exports