warscript 0.0.1-dev.c59dd14 → 0.0.1-dev.c79b20b

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 (87) 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 +4 -1
  5. package/core/types/frame.lua +22 -1
  6. package/core/types/group.d.ts +0 -1
  7. package/core/types/image.d.ts +0 -1
  8. package/core/types/unit.lua +8 -0
  9. package/decl/index.d.ts +1 -0
  10. package/engine/ability.d.ts +1 -1
  11. package/engine/behavior.d.ts +10 -10
  12. package/engine/behaviour/ability/apply-buff.d.ts +3 -5
  13. package/engine/behaviour/ability/apply-unit-behavior.d.ts +6 -1
  14. package/engine/behaviour/ability/damage.d.ts +33 -11
  15. package/engine/behaviour/ability/damage.lua +89 -31
  16. package/engine/behaviour/ability/heal.d.ts +33 -6
  17. package/engine/behaviour/ability/heal.lua +89 -10
  18. package/engine/behaviour/ability/restore-mana.d.ts +15 -0
  19. package/engine/behaviour/ability/restore-mana.lua +29 -0
  20. package/engine/behaviour/unit/stun-immunity.d.ts +0 -1
  21. package/engine/behaviour/unit.d.ts +8 -2
  22. package/engine/behaviour/unit.lua +27 -0
  23. package/engine/buff.d.ts +62 -20
  24. package/engine/buff.lua +247 -72
  25. package/engine/game-map.d.ts +7 -0
  26. package/engine/game-map.lua +32 -0
  27. package/engine/internal/item+owner.lua +2 -2
  28. package/engine/internal/unit/bonus.d.ts +9 -8
  29. package/engine/internal/unit/bonus.lua +6 -1
  30. package/engine/internal/unit+ability.lua +2 -2
  31. package/engine/internal/unit+item.d.ts +23 -0
  32. package/engine/internal/unit+item.lua +57 -0
  33. package/engine/internal/unit+transport.lua +4 -10
  34. package/engine/internal/unit.d.ts +6 -5
  35. package/engine/internal/unit.lua +45 -31
  36. package/engine/object-data/auxiliary/attachment-preset.d.ts +0 -1
  37. package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
  38. package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
  39. package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
  40. package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
  41. package/engine/object-data/entry/ability-type.d.ts +0 -1
  42. package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
  43. package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
  44. package/engine/object-data/entry/buff-type.d.ts +0 -1
  45. package/engine/object-data/entry/destructible-type.d.ts +0 -1
  46. package/engine/object-data/entry/item-type/blank.d.ts +0 -1
  47. package/engine/object-data/entry/item-type.d.ts +0 -1
  48. package/engine/object-data/entry/lightning-type.d.ts +0 -1
  49. package/engine/object-data/entry/unit-type.d.ts +0 -1
  50. package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
  51. package/engine/object-data/entry/upgrade.d.ts +0 -1
  52. package/engine/object-data/entry.d.ts +2 -3
  53. package/engine/object-field/ability.d.ts +18 -1
  54. package/engine/object-field/ability.lua +50 -0
  55. package/engine/object-field.d.ts +0 -1
  56. package/engine/random.d.ts +1 -5
  57. package/engine/unit.d.ts +1 -0
  58. package/engine/unit.lua +10 -2
  59. package/event.d.ts +2 -3
  60. package/event.lua +9 -5
  61. package/lualib_bundle.lua +146 -42
  62. package/math/vec2.d.ts +2 -9
  63. package/math.d.ts +0 -2
  64. package/net/socket.d.ts +7 -1
  65. package/net/socket.lua +45 -4
  66. package/network.d.ts +1 -0
  67. package/network.lua +3 -2
  68. package/objutil/ability.d.ts +0 -1
  69. package/objutil/buff.d.ts +0 -1
  70. package/objutil/buff.lua +1 -1
  71. package/objutil/object.d.ts +0 -1
  72. package/objutil/unit.d.ts +0 -1
  73. package/package.json +13 -13
  74. package/property.d.ts +55 -0
  75. package/property.lua +374 -0
  76. package/string.d.ts +16 -0
  77. package/string.lua +5 -0
  78. package/util/stream.d.ts +0 -1
  79. package/utility/arrays.d.ts +3 -4
  80. package/utility/bit-set.d.ts +0 -2
  81. package/utility/linked-set.d.ts +11 -3
  82. package/utility/linked-set.lua +5 -2
  83. package/utility/lua-maps.d.ts +1 -2
  84. package/utility/lua-sets.d.ts +1 -2
  85. package/utility/types.d.ts +1 -0
  86. package/core/mapbounds.d.ts +0 -8
  87. package/core/mapbounds.lua +0 -12
@@ -0,0 +1,57 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__New = ____lualib.__TS__New
4
+ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
5
+ local ____exports = {}
6
+ local ____item = require("engine.internal.item")
7
+ local Item = ____item.Item
8
+ local ____unit = require("engine.internal.unit")
9
+ local Unit = ____unit.Unit
10
+ local isItemPowerup = IsItemPowerup
11
+ local setItemBooleanField = BlzSetItemBooleanField
12
+ local unitAddItem = UnitAddItem
13
+ local unitDropItemSlot = UnitDropItemSlot
14
+ local unitInventorySize = UnitInventorySize
15
+ local unitItemInSlot = UnitItemInSlot
16
+ local unitRemoveItemFromSlot = UnitRemoveItemFromSlot
17
+ ____exports.UnitItems = __TS__Class()
18
+ local UnitItems = ____exports.UnitItems
19
+ UnitItems.name = "UnitItems"
20
+ function UnitItems.prototype.____constructor(self, handle)
21
+ self.handle = handle
22
+ end
23
+ function UnitItems.prototype.__newindex(self, slot, item)
24
+ local handle = self.handle
25
+ if slot < 0 or slot >= unitInventorySize(handle) then
26
+ return
27
+ end
28
+ unitRemoveItemFromSlot(handle, slot)
29
+ if item ~= nil then
30
+ local itemHandle = item.handle
31
+ local isPowerup = isItemPowerup(itemHandle)
32
+ if isPowerup then
33
+ setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
34
+ end
35
+ unitAddItem(handle, itemHandle)
36
+ unitDropItemSlot(handle, itemHandle, slot)
37
+ if isPowerup then
38
+ setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
39
+ end
40
+ end
41
+ end
42
+ function UnitItems.prototype.__index(self, slot)
43
+ return Item:of(unitItemInSlot(self.handle, slot))
44
+ end
45
+ function UnitItems.prototype.__len(self)
46
+ return unitInventorySize(self.handle)
47
+ end
48
+ __TS__ObjectDefineProperty(
49
+ Unit.prototype,
50
+ "items",
51
+ {get = function(self)
52
+ local items = __TS__New(____exports.UnitItems, self.handle)
53
+ rawset(self, "items", items)
54
+ return items
55
+ end}
56
+ )
57
+ return ____exports
@@ -6,9 +6,8 @@ local ____unit = require("engine.internal.unit")
6
6
  local Unit = ____unit.Unit
7
7
  local ____event = require("event")
8
8
  local Event = ____event.Event
9
- local ____mapbounds = require("core.mapbounds")
10
- local boundMax = ____mapbounds.boundMax
11
- local boundRegion = ____mapbounds.boundRegion
9
+ local ____game_2Dmap = require("engine.game-map")
10
+ local GameMap = ____game_2Dmap.GameMap
12
11
  local eventInvoke = Event.invoke
13
12
  local tableRemove = table.remove
14
13
  local ____assert = _G.assert
@@ -58,8 +57,8 @@ triggerAddCondition(
58
57
  deboard(unit)
59
58
  end
60
59
  if not unitAlive(handle) then
61
- unit.x = boundMax.x
62
- unit.y = boundMax.y
60
+ unit.x = GameMap.worldBoundsRect.maxX
61
+ unit.y = GameMap.worldBoundsRect.maxY
63
62
  end
64
63
  local transport = Unit:of(getTransportUnit())
65
64
  transportByUnit[unit] = transport
@@ -68,11 +67,6 @@ triggerAddCondition(
68
67
  eventInvoke(onBoardEvent, unit, transport)
69
68
  end)
70
69
  )
71
- boundRegion.onUnitEnter:addListener(function(unit)
72
- if transportByUnit[unit] ~= nil and not isUnitLoaded(unit.handle) then
73
- deboard(unit)
74
- end
75
- end)
76
70
  Unit.deathEvent:addListener(function(unit)
77
71
  if transportByUnit[unit] ~= nil then
78
72
  deboard(unit)
@@ -1,4 +1,3 @@
1
- /// <reference types="@typescript-to-lua/language-extensions" />
2
1
  /** @noSelfInFile */
3
2
  import { Handle, HandleDestructor } from "../../core/types/handle";
4
3
  import { Player } from "../../core/types/player";
@@ -43,6 +42,7 @@ export interface DamagingEvent {
43
42
  damageType: jdamagetype;
44
43
  weaponType: jweapontype;
45
44
  readonly isAttack: boolean;
45
+ readonly originalAmount: number;
46
46
  }
47
47
  export type DamageEvent = DamagingEvent & {
48
48
  preventDeath<P extends any[]>(this: DamageEvent, callback: (this: void, ...parameters: P) => any, ...parameters: P): void;
@@ -228,7 +228,7 @@ export declare class Unit extends Handle<junit> {
228
228
  isSelected(player: Player): boolean;
229
229
  explode(): void;
230
230
  kill(): void;
231
- revive(pos: Vec2, doEffect: boolean): void;
231
+ revive(x: number, y: number, doEffect?: boolean): void;
232
232
  healTarget(target: Widget, amount: number): void;
233
233
  useItem(item: Item): boolean;
234
234
  issueImmediateOrder(order: number): boolean;
@@ -323,9 +323,10 @@ export declare class Unit extends Handle<junit> {
323
323
  static readonly autoAttackStartEvent: UnitTriggerEvent<[Unit]>;
324
324
  static readonly onDamaging: Event<[source: Unit | undefined, target: Unit, event: DamagingEvent]>;
325
325
  static readonly onDamage: InitializingEvent<[source: Unit | undefined, target: Unit, event: DamageEvent], jtrigger>;
326
- static onItemDrop: UnitTriggerEvent<[Item]>;
327
- static onItemPickup: UnitTriggerEvent<[Item]>;
328
- static onItemUse: UnitTriggerEvent<[Item]>;
326
+ static itemDroppedEvent: UnitTriggerEvent<[Item]>;
327
+ static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
328
+ static itemUsedEvent: UnitTriggerEvent<[Item]>;
329
+ static itemStackedEvent: UnitTriggerEvent<[Item]>;
329
330
  static get onCreate(): EventDispatcher<[Unit], [Unit]>;
330
331
  static get destroyEvent(): EventDispatcher<[Unit], [Unit]>;
331
332
  getField(field: junitintegerfield | junitrealfield): number;
@@ -7,6 +7,9 @@ local __TS__Class = ____lualib.__TS__Class
7
7
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
8
8
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
9
9
  local __TS__ArraySetLength = ____lualib.__TS__ArraySetLength
10
+ local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
11
+ local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
12
+ local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
10
13
  local __TS__InstanceOf = ____lualib.__TS__InstanceOf
11
14
  local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
12
15
  local Set = ____lualib.Set
@@ -279,16 +282,14 @@ function UnitTriggerEvent.prototype.____constructor(self, eventType, c)
279
282
  end
280
283
  local function dispatch(event, idGetter, argsGetter)
281
284
  local initialized = false
282
- local x = {}
283
285
  return setmetatable(
284
- x,
286
+ {},
285
287
  {
286
288
  __index = function(self, id)
287
289
  if type(id) ~= "number" then
288
290
  return event[id]
289
291
  end
290
292
  if not initialized then
291
- local invoke = Event.invoke
292
293
  event:addListener(function(...)
293
294
  local id = idGetter(...)
294
295
  local dispatched = rawget(self, id)
@@ -326,7 +327,6 @@ local function dispatchAbility(event)
326
327
  return event[id]
327
328
  end
328
329
  if not initialized then
329
- local invoke = Event.invoke
330
330
  event:addListener(function(unit, ability, ...)
331
331
  local dispatched = rawget(self, ability.typeId)
332
332
  if dispatched ~= nil then
@@ -817,8 +817,15 @@ end
817
817
  function Unit.prototype.kill(self)
818
818
  killUnit(self.handle)
819
819
  end
820
- function Unit.prototype.revive(self, pos, doEffect)
821
- ReviveHero(self.handle, pos.x, pos.y, doEffect)
820
+ function Unit.prototype.revive(self, x, y, doEffect)
821
+ local ____ReviveHero_4 = ReviveHero
822
+ local ____array_3 = __TS__SparseArrayNew(self.handle, x, y)
823
+ local ____doEffect_2 = doEffect
824
+ if ____doEffect_2 == nil then
825
+ ____doEffect_2 = false
826
+ end
827
+ __TS__SparseArrayPush(____array_3, ____doEffect_2)
828
+ ____ReviveHero_4(__TS__SparseArraySpread(____array_3))
822
829
  end
823
830
  function Unit.prototype.healTarget(self, target, amount)
824
831
  if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
@@ -858,7 +865,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
858
865
  return UnitDropItemSlot(self.handle, item.handle, slot)
859
866
  end
860
867
  function Unit.prototype.itemInSlot(self, slot)
861
- return Item:of(UnitItemInSlot(self.handle, slot))
868
+ return Item:of(unitItemInSlot(self.handle, slot))
862
869
  end
863
870
  function Unit.prototype.addAbility(self, abilityId)
864
871
  if unitAddAbility(self.handle, abilityId) then
@@ -1385,13 +1392,13 @@ __TS__SetDescriptor(
1385
1392
  end,
1386
1393
  set = function(self, isTeamGlowVisible)
1387
1394
  showUnitTeamGlow(self.handle, isTeamGlowVisible)
1388
- local ____temp_2
1395
+ local ____temp_5
1389
1396
  if not isTeamGlowVisible then
1390
- ____temp_2 = true
1397
+ ____temp_5 = true
1391
1398
  else
1392
- ____temp_2 = nil
1399
+ ____temp_5 = nil
1393
1400
  end
1394
- self[105] = ____temp_2
1401
+ self[105] = ____temp_5
1395
1402
  end
1396
1403
  },
1397
1404
  true
@@ -2055,7 +2062,6 @@ Unit.onDecay = __TS__New(
2055
2062
  Unit.onResurrect = __TS__New(
2056
2063
  InitializingEvent,
2057
2064
  function(event)
2058
- local invoke = Event.invoke
2059
2065
  local dead = setmetatable({}, {__mode = "k"})
2060
2066
  ____exports.Unit.deathEvent:addListener(function(unit)
2061
2067
  dead[unit] = true
@@ -2071,10 +2077,15 @@ Unit.onResurrect = __TS__New(
2071
2077
  Unit.morphEvent = __TS__New(
2072
2078
  InitializingEvent,
2073
2079
  function(event)
2080
+ local function ifNotLeft(unit)
2081
+ local handle = unit.handle
2082
+ if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
2083
+ invoke(event, unit)
2084
+ end
2085
+ end
2074
2086
  ____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
2075
2087
  if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
2076
- assert(unitAddAbility(unit.handle, morphDetectAbilityId))
2077
- Timer:run(Event.invoke, event, unit)
2088
+ Timer:run(ifNotLeft, unit)
2078
2089
  end
2079
2090
  end)
2080
2091
  end
@@ -2112,27 +2123,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
2112
2123
  Unit.onTargetCast = dispatchId(__TS__New(
2113
2124
  InitializingEvent,
2114
2125
  function(event)
2115
- local invoke = Event.invoke
2116
2126
  local function listener(unit, id)
2117
- local ____GetSpellTargetUnit_result_5
2127
+ local ____GetSpellTargetUnit_result_8
2118
2128
  if GetSpellTargetUnit() then
2119
- ____GetSpellTargetUnit_result_5 = ____exports.Unit:of(GetSpellTargetUnit())
2129
+ ____GetSpellTargetUnit_result_8 = ____exports.Unit:of(GetSpellTargetUnit())
2120
2130
  else
2121
- local ____GetSpellTargetItem_result_4
2131
+ local ____GetSpellTargetItem_result_7
2122
2132
  if GetSpellTargetItem() then
2123
- ____GetSpellTargetItem_result_4 = Item:of(GetSpellTargetItem())
2133
+ ____GetSpellTargetItem_result_7 = Item:of(GetSpellTargetItem())
2124
2134
  else
2125
- local ____GetSpellTargetDestructable_result_3
2135
+ local ____GetSpellTargetDestructable_result_6
2126
2136
  if GetSpellTargetDestructable() then
2127
- ____GetSpellTargetDestructable_result_3 = Destructable:of(GetSpellTargetDestructable())
2137
+ ____GetSpellTargetDestructable_result_6 = Destructable:of(GetSpellTargetDestructable())
2128
2138
  else
2129
- ____GetSpellTargetDestructable_result_3 = nil
2139
+ ____GetSpellTargetDestructable_result_6 = nil
2130
2140
  end
2131
- ____GetSpellTargetItem_result_4 = ____GetSpellTargetDestructable_result_3
2141
+ ____GetSpellTargetItem_result_7 = ____GetSpellTargetDestructable_result_6
2132
2142
  end
2133
- ____GetSpellTargetUnit_result_5 = ____GetSpellTargetItem_result_4
2143
+ ____GetSpellTargetUnit_result_8 = ____GetSpellTargetItem_result_7
2134
2144
  end
2135
- local target = ____GetSpellTargetUnit_result_5
2145
+ local target = ____GetSpellTargetUnit_result_8
2136
2146
  if target then
2137
2147
  invoke(event, unit, id, target)
2138
2148
  end
@@ -2329,7 +2339,6 @@ Unit.autoAttackStartEvent = __TS__New(
2329
2339
  )
2330
2340
  Unit.onDamaging = (function()
2331
2341
  local event = __TS__New(Event)
2332
- local invoke = Event.invoke
2333
2342
  local trigger = CreateTrigger()
2334
2343
  TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
2335
2344
  TriggerAddCondition(
@@ -2428,7 +2437,6 @@ end)()
2428
2437
  Unit.onDamage = __TS__New(
2429
2438
  InitializingEvent,
2430
2439
  function(event)
2431
- local invoke = Event.invoke
2432
2440
  local trigger = CreateTrigger()
2433
2441
  TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
2434
2442
  TriggerAddCondition(
@@ -2444,6 +2452,7 @@ Unit.onDamage = __TS__New(
2444
2452
  damageType = BlzGetEventDamageType(),
2445
2453
  weaponType = BlzGetEventWeaponType(),
2446
2454
  isAttack = BlzGetEventIsAttack(),
2455
+ originalAmount = GetEventDamage(),
2447
2456
  preventDeath = damageEventPreventDeath
2448
2457
  }
2449
2458
  local evData = setmetatable(
@@ -2494,7 +2503,7 @@ Unit.onDamage = __TS__New(
2494
2503
  DestroyTrigger(trigger)
2495
2504
  end
2496
2505
  )
2497
- Unit.onItemDrop = __TS__New(
2506
+ Unit.itemDroppedEvent = __TS__New(
2498
2507
  ____exports.UnitTriggerEvent,
2499
2508
  EVENT_PLAYER_UNIT_DROP_ITEM,
2500
2509
  function()
@@ -2505,7 +2514,7 @@ Unit.onItemDrop = __TS__New(
2505
2514
  return IgnoreEvent
2506
2515
  end
2507
2516
  )
2508
- Unit.onItemPickup = __TS__New(
2517
+ Unit.itemPickedUpEvent = __TS__New(
2509
2518
  ____exports.UnitTriggerEvent,
2510
2519
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2511
2520
  function()
@@ -2516,10 +2525,15 @@ Unit.onItemPickup = __TS__New(
2516
2525
  return IgnoreEvent
2517
2526
  end
2518
2527
  )
2519
- Unit.onItemUse = __TS__New(
2528
+ Unit.itemUsedEvent = __TS__New(
2520
2529
  ____exports.UnitTriggerEvent,
2521
2530
  EVENT_PLAYER_UNIT_USE_ITEM,
2522
- function() return ____exports.Unit:of(GetTriggerUnit()), Item:of(GetManipulatedItem()) end
2531
+ function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2532
+ )
2533
+ Unit.itemStackedEvent = __TS__New(
2534
+ ____exports.UnitTriggerEvent,
2535
+ EVENT_PLAYER_UNIT_STACK_ITEM,
2536
+ function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2523
2537
  )
2524
2538
  __TS__ObjectDefineProperty(
2525
2539
  Unit,
@@ -1,4 +1,3 @@
1
- /// <reference types="@typescript-to-lua/language-extensions" />
2
1
  /** @noSelfInFile */
3
2
  import { ModelNodeName } from "./model-node-name";
4
3
  import { ModelNodeQualifier } from "./model-node-qualifier";
@@ -1,5 +1,3 @@
1
- /// <reference types="@warscript/language-extensions" />
2
- /// <reference types="@typescript-to-lua/language-extensions" />
3
1
  /** @noSelfInFile */
4
2
  export declare const enum CombatClassification {
5
3
  NONE = 1,// 2^0
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { ChannelAbilityType, ChannelAbilityTypeTargetingType } from "./channel";
4
3
  import { ObjectDataEntryLevelFieldValueSupplier } from "../../entry";
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { DiseaseCloudAbilityType } from "./disease-cloud";
4
3
  export declare class BlankPassiveAbilityType extends DiseaseCloudAbilityType {
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { AbilityType, AbilityTypeId } from "../ability-type";
4
3
  import { ObjectDataEntryLevelFieldValueSupplier } from "../../entry";
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import "../../internal/unit/ability";
4
3
  import { TupleOf } from "../../../utility/types";
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { BuffPolarity } from "../../auxiliary/buff-polarity";
4
3
  import { BuffResistanceType } from "../../auxiliary/buff-resistance-type";
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { BuffType, BuffTypeId } from "../buff-type";
4
3
  export declare class BlankBuffType extends BuffType {
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { TupleOf } from "../../../utility/types";
4
3
  import { AttachmentPreset, AttachmentPresetInput } from "../auxiliary/attachment-preset";
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { ArmorSoundType } from "../auxiliary/armor-sound-type";
4
3
  import { CombatClassifications } from "../auxiliary/combat-classification";
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { ItemType, ItemTypeId } from "../item-type";
4
3
  export declare class BlankItemType extends ItemType {
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { ArmorSoundType } from "../auxiliary/armor-sound-type";
4
3
  import { ObjectDataEntry, ObjectDataEntryId } from "../entry";
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { ObjectDataEntry, ObjectDataEntryConstructor, ObjectDataEntryId } from "../entry";
4
3
  import { Color } from "../../../core/types/color";
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { TupleOf } from "../../../utility/types";
4
3
  import { ArmorSoundType } from "../auxiliary/armor-sound-type";
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { Upgrade, UpgradeId } from "../upgrade";
4
3
  export declare class BlankUpgrade extends Upgrade {
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { TupleOf } from "../../../utility/types";
4
3
  import { TechTreeDependency, TechTreeDependencyInput } from "../auxiliary/tech-tree-dependency";
@@ -1,4 +1,3 @@
1
- /// <reference types="warpack-types/warpack" />
2
1
  /** @noSelfInFile */
3
2
  import { AttachmentPreset, AttachmentPresetInput } from "./auxiliary/attachment-preset";
4
3
  import { MutableKeys } from "../../utility/types";
@@ -10,8 +9,8 @@ export type ObjectDataEntryConstructor<T extends ObjectDataEntry> = OmitConstruc
10
9
  export type ObjectDataEntryAbstractConstructor<T extends ObjectDataEntry> = OmitConstructor<typeof ObjectDataEntry> & (abstract new (object: WarObject) => T);
11
10
  export type ObjectDataEntryProperties<T extends ObjectDataEntry> = Partial<T[MutableKeys<T>]>;
12
11
  export type ObjectDataEntryLevelFieldValueSupplier<ValueType extends string | number | boolean | undefined | Record<string, any>, InputValueType = ValueType> = ValueType | readonly ValueType[] | ((level: number, currentValue: InputValueType) => ValueType);
13
- export declare const extractObjectDataEntryLevelFieldValue: <ValueType extends string | number | boolean | Record<string, any> | undefined, InputValueType = ValueType>(supplier: ObjectDataEntryLevelFieldValueSupplier<ValueType, InputValueType>, level: number, currentValue: InputValueType) => ValueType;
14
- export declare const extractObjectDataEntryLevelArrayFieldValue: <T extends string | number | boolean | Record<string, any> | undefined, S extends T[]>(supplier: ObjectDataEntryLevelFieldValueSupplier<S, S>, level: number, currentValue: S) => S;
12
+ export declare const extractObjectDataEntryLevelFieldValue: <ValueType extends string | number | boolean | undefined | Record<string, any>, InputValueType = ValueType>(supplier: ObjectDataEntryLevelFieldValueSupplier<ValueType, InputValueType>, level: number, currentValue: InputValueType) => ValueType;
13
+ export declare const extractObjectDataEntryLevelArrayFieldValue: <T extends string | number | boolean | undefined | Record<string, any>, S extends T[]>(supplier: ObjectDataEntryLevelFieldValueSupplier<S>, level: number, currentValue: S) => S;
15
14
  export declare abstract class ObjectDataEntry<Id extends ObjectDataEntryId = ObjectDataEntryId> {
16
15
  protected readonly object: WarObject;
17
16
  static readonly BASE_ID: ObjectDataEntryId;
@@ -6,6 +6,9 @@ import { ObjectDataEntryId } from "../object-data/entry";
6
6
  import { LightningTypeId } from "../object-data/entry/lightning-type";
7
7
  import { CombatClassifications } from "../object-data/auxiliary/combat-classification";
8
8
  import { UnitTypeId } from "../object-data/entry/unit-type";
9
+ import { BuffResistanceType } from "../object-data/auxiliary/buff-resistance-type";
10
+ import { BuffPolarity } from "../object-data/auxiliary/buff-polarity";
11
+ import { ReadonlyNonEmptyLinkedSet } from "../../utility/linked-set";
9
12
  export declare abstract class AbilityField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType extends jabilityfield = jabilityfield> extends ObjectField<AbilityType, Ability, ValueType, NativeFieldType> {
10
13
  protected get instanceClass(): typeof Ability;
11
14
  protected getObjectDataEntryId(instance: Ability): AbilityTypeId;
@@ -107,6 +110,20 @@ export declare class AbilityAbilityTypeIdLevelField extends AbilityObjectDataEnt
107
110
  }
108
111
  export declare class AbilityUnitTypeIdLevelField extends AbilityObjectDataEntryIdLevelField<UnitTypeId> {
109
112
  }
113
+ export declare abstract class AbilityEnumLevelField<T extends number> extends AbilityLevelField<T, T, jabilityintegerlevelfield> {
114
+ protected abstract values: ReadonlyNonEmptyLinkedSet<T>;
115
+ protected get defaultValue(): T;
116
+ protected getNativeFieldById(id: number): jabilityintegerlevelfield;
117
+ protected getNativeFieldValue(instance: Ability, level: number): T;
118
+ protected setNativeFieldValue(instance: Ability, level: number, value: T): boolean;
119
+ static get valueChangeEvent(): ObjectLevelFieldValueChangeEvent<AbilityBooleanLevelField>;
120
+ }
121
+ export declare class AbilityBuffPolarityLevelField extends AbilityEnumLevelField<BuffPolarity> {
122
+ protected values: ReadonlyNonEmptyLinkedSet<BuffPolarity>;
123
+ }
124
+ export declare class AbilityBuffResistanceTypeLevelField extends AbilityEnumLevelField<BuffResistanceType> {
125
+ protected values: ReadonlyNonEmptyLinkedSet<BuffResistanceType>;
126
+ }
110
127
  export declare class AbilityCombatClassificationsLevelField extends AbilityLevelField<CombatClassifications, CombatClassifications, jabilityintegerlevelfield> {
111
128
  protected get defaultValue(): CombatClassifications;
112
129
  protected getNativeFieldById(id: number): jabilityintegerlevelfield;
@@ -114,4 +131,4 @@ export declare class AbilityCombatClassificationsLevelField extends AbilityLevel
114
131
  protected setNativeFieldValue(instance: Ability, level: number, value: CombatClassifications): boolean;
115
132
  }
116
133
  export type AbilityDependentValue<ValueType extends boolean | number | string> = ValueType | AbilityField<ValueType> | AbilityLevelField<ValueType> | ((ability: Ability) => ValueType);
117
- export declare const resolveCurrentAbilityDependentValue: <ValueType extends string | number | boolean>(ability: Ability, value: AbilityDependentValue<ValueType>) => ValueType;
134
+ export declare const resolveCurrentAbilityDependentValue: <ValueType extends boolean | number | string>(ability: Ability, value: AbilityDependentValue<ValueType>) => ValueType;
@@ -13,6 +13,8 @@ local ObjectField = ____object_2Dfield.ObjectField
13
13
  local ObjectLevelField = ____object_2Dfield.ObjectLevelField
14
14
  local ____ability_2Dtype = require("engine.object-data.entry.ability-type")
15
15
  local AbilityType = ____ability_2Dtype.AbilityType
16
+ local ____linked_2Dset = require("utility.linked-set")
17
+ local nonEmptyLinkedSetOf = ____linked_2Dset.nonEmptyLinkedSetOf
16
18
  local convertAbilityBooleanField = _G.ConvertAbilityBooleanField
17
19
  local convertAbilityIntegerField = _G.ConvertAbilityIntegerField
18
20
  local convertAbilityRealField = _G.ConvertAbilityRealField
@@ -431,6 +433,54 @@ ____exports.AbilityUnitTypeIdLevelField = __TS__Class()
431
433
  local AbilityUnitTypeIdLevelField = ____exports.AbilityUnitTypeIdLevelField
432
434
  AbilityUnitTypeIdLevelField.name = "AbilityUnitTypeIdLevelField"
433
435
  __TS__ClassExtends(AbilityUnitTypeIdLevelField, ____exports.AbilityObjectDataEntryIdLevelField)
436
+ ____exports.AbilityEnumLevelField = __TS__Class()
437
+ local AbilityEnumLevelField = ____exports.AbilityEnumLevelField
438
+ AbilityEnumLevelField.name = "AbilityEnumLevelField"
439
+ __TS__ClassExtends(AbilityEnumLevelField, ____exports.AbilityLevelField)
440
+ function AbilityEnumLevelField.prototype.getNativeFieldById(self, id)
441
+ return convertAbilityIntegerLevelField(id)
442
+ end
443
+ function AbilityEnumLevelField.prototype.getNativeFieldValue(self, instance, level)
444
+ local value = instance:getField(self.nativeField, level)
445
+ if self.values:contains(value) then
446
+ return value
447
+ end
448
+ return self.values:first()
449
+ end
450
+ function AbilityEnumLevelField.prototype.setNativeFieldValue(self, instance, level, value)
451
+ return instance:setField(self.nativeField, level, value)
452
+ end
453
+ __TS__SetDescriptor(
454
+ AbilityEnumLevelField.prototype,
455
+ "defaultValue",
456
+ {get = function(self)
457
+ return self.values:first()
458
+ end},
459
+ true
460
+ )
461
+ __TS__ObjectDefineProperty(
462
+ AbilityEnumLevelField,
463
+ "valueChangeEvent",
464
+ {get = function(self)
465
+ return self:getOrCreateValueChangeEvent()
466
+ end}
467
+ )
468
+ ____exports.AbilityBuffPolarityLevelField = __TS__Class()
469
+ local AbilityBuffPolarityLevelField = ____exports.AbilityBuffPolarityLevelField
470
+ AbilityBuffPolarityLevelField.name = "AbilityBuffPolarityLevelField"
471
+ __TS__ClassExtends(AbilityBuffPolarityLevelField, ____exports.AbilityEnumLevelField)
472
+ function AbilityBuffPolarityLevelField.prototype.____constructor(self, ...)
473
+ AbilityBuffPolarityLevelField.____super.prototype.____constructor(self, ...)
474
+ self.values = nonEmptyLinkedSetOf(0, 1, 2)
475
+ end
476
+ ____exports.AbilityBuffResistanceTypeLevelField = __TS__Class()
477
+ local AbilityBuffResistanceTypeLevelField = ____exports.AbilityBuffResistanceTypeLevelField
478
+ AbilityBuffResistanceTypeLevelField.name = "AbilityBuffResistanceTypeLevelField"
479
+ __TS__ClassExtends(AbilityBuffResistanceTypeLevelField, ____exports.AbilityEnumLevelField)
480
+ function AbilityBuffResistanceTypeLevelField.prototype.____constructor(self, ...)
481
+ AbilityBuffResistanceTypeLevelField.____super.prototype.____constructor(self, ...)
482
+ self.values = nonEmptyLinkedSetOf(1, 2, 3)
483
+ end
434
484
  local allowedTargetCombatClassificationsByLevelByAbilityTypeId = postcompile(function()
435
485
  local allowedTargetCombatClassificationsByLevelByAbilityTypeId = {}
436
486
  for ____, abilityType in ipairs(AbilityType:getAll()) do
@@ -1,4 +1,3 @@
1
- /// <reference types="@typescript-to-lua/language-extensions" />
2
1
  /** @noSelfInFile */
3
2
  import { DispatchingEvent } from "../event";
4
3
  import { AbstractConstructor } from "../utility/types";
@@ -1,4 +1,3 @@
1
- /// <reference types="@typescript-to-lua/language-extensions" />
2
1
  /** @noSelfInFile */
3
2
  export declare const randomAngle: () => number;
4
3
  export declare const randomInteger: {
@@ -9,7 +8,4 @@ export declare const randomFloat: {
9
8
  (upperBound?: number): number;
10
9
  (lowerBound: number, upperBound: number): number;
11
10
  };
12
- export declare const randomXY: (centerX: number, centerY: number, range: number) => LuaMultiReturn<[
13
- x: number,
14
- y: number
15
- ]>;
11
+ export declare const randomXY: (centerX: number, centerY: number, range: number) => LuaMultiReturn<[x: number, y: number]>;
package/engine/unit.d.ts CHANGED
@@ -4,6 +4,7 @@ import "./internal/unit/ability";
4
4
  import "./internal/unit/allowed-targets";
5
5
  import "./internal/unit/buff";
6
6
  import "./internal/unit/expiration-timer";
7
+ import "./internal/unit+item";
7
8
  import "./internal/unit+ability";
8
9
  import "./internal/unit+damage";
9
10
  import "./internal/unit+rally";
package/engine/unit.lua CHANGED
@@ -4,6 +4,7 @@ require("engine.internal.unit.ability")
4
4
  require("engine.internal.unit.allowed-targets")
5
5
  require("engine.internal.unit.buff")
6
6
  require("engine.internal.unit.expiration-timer")
7
+ require("engine.internal.unit+item")
7
8
  require("engine.internal.unit+ability")
8
9
  require("engine.internal.unit+damage")
9
10
  require("engine.internal.unit+rally")
@@ -18,8 +19,7 @@ require("engine.internal.unit.detach-missiles")
18
19
  require("engine.internal.unit.band-aids.ancestral-spirit-cannibalize")
19
20
  do
20
21
  local ____unit = require("engine.internal.unit")
21
- local Unit = ____unit.Unit
22
- ____exports.Unit = Unit
22
+ ____exports.Unit = ____unit.Unit
23
23
  end
24
24
  do
25
25
  local ____export = require("engine.internal.unit+damage")
@@ -29,4 +29,12 @@ do
29
29
  end
30
30
  end
31
31
  end
32
+ do
33
+ local ____export = require("engine.internal.unit+rally")
34
+ for ____exportKey, ____exportValue in pairs(____export) do
35
+ if ____exportKey ~= "default" then
36
+ ____exports[____exportKey] = ____exportValue
37
+ end
38
+ end
39
+ end
32
40
  return ____exports
package/event.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- /// <reference types="@typescript-to-lua/language-extensions" />
2
1
  /** @noSelfInFile */
3
- export type EventListener<T extends any[]> = (...args: T) => void;
2
+ export type EventListener<T extends any[]> = (this: void, ...args: T) => void;
4
3
  export declare const enum EventListenerPriority {
5
4
  LOWEST = 0,
6
5
  LOW = 1,
@@ -38,7 +37,7 @@ export type EventDispatchTable<EventType extends Event<any>, KeyType extends num
38
37
  };
39
38
  export type DispatchingEvent<P extends any[], T extends Event<P> = Event<P>, S extends Event<P> = Event<P>> = T & EventDispatchTable<S>;
40
39
  export declare const createDispatchingEvent: {
41
- <T extends Event<any>, S extends Event<EventParameters<T>>>(underlyingEvent: T, extractKey: (...args: EventParameters<T>) => number, ...createEvent: [...(Event<any> extends S ? [(() => S)?] : [() => S])]): DispatchingEvent<EventParameters<T>, T>;
40
+ <T extends Event<any>, S extends Event<EventParameters<T>>>(underlyingEvent: T, extractKey: (this: void, ...args: EventParameters<T>) => number, invokeEvent?: (this: void, event: S, ...args: EventParameters<T>) => unknown, ...createEvent: [...(Event<any> extends S ? [((this: void) => S)?] : [(this: void) => S])]): DispatchingEvent<EventParameters<T>, T, S>;
42
41
  };
43
42
  export declare class DependentInitializingEvent<T extends any[], R extends any[]> extends InitializingEvent<R, EventListener<T>> {
44
43
  constructor(underlyingEvent: Event<T>, priority: EventListenerPriority, collector: (...args: T) => LuaMultiReturn<[false] | [true, ...R]>);