warscript 0.0.1-dev.87bdb89 → 0.0.1-dev.8895ff6

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 (118) hide show
  1. package/attributes.d.ts +1 -0
  2. package/attributes.lua +9 -0
  3. package/core/types/frame.lua +24 -21
  4. package/core/types/player.d.ts +16 -0
  5. package/core/types/player.lua +60 -15
  6. package/core/types/playerCamera.d.ts +2 -0
  7. package/core/types/playerCamera.lua +123 -5
  8. package/core/types/tileCell.d.ts +11 -1
  9. package/core/types/tileCell.lua +97 -0
  10. package/core/types/timer.d.ts +3 -1
  11. package/core/types/timer.lua +27 -2
  12. package/decl/native.d.ts +6 -4
  13. package/destroyable.d.ts +1 -0
  14. package/destroyable.lua +9 -0
  15. package/engine/behavior.d.ts +14 -1
  16. package/engine/behavior.lua +230 -70
  17. package/engine/behaviour/ability/apply-buff.lua +5 -5
  18. package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
  19. package/engine/behaviour/ability/emulate-impact.lua +2 -1
  20. package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
  21. package/engine/behaviour/ability/remove-buffs.lua +21 -0
  22. package/engine/behaviour/ability/restore-mana.d.ts +1 -1
  23. package/engine/behaviour/ability/restore-mana.lua +6 -6
  24. package/engine/behaviour/ability.d.ts +2 -1
  25. package/engine/behaviour/ability.lua +9 -17
  26. package/engine/behaviour/unit/stun-immunity.d.ts +12 -6
  27. package/engine/behaviour/unit/stun-immunity.lua +57 -31
  28. package/engine/behaviour/unit.d.ts +26 -5
  29. package/engine/behaviour/unit.lua +180 -27
  30. package/engine/buff.d.ts +21 -8
  31. package/engine/buff.lua +187 -121
  32. package/engine/internal/ability.d.ts +3 -1
  33. package/engine/internal/ability.lua +34 -11
  34. package/engine/internal/item/ability.lua +51 -1
  35. package/engine/internal/item+owner.lua +12 -6
  36. package/engine/internal/item.d.ts +13 -15
  37. package/engine/internal/item.lua +63 -49
  38. package/engine/internal/mechanics/cast-ability.lua +6 -3
  39. package/engine/internal/misc/frame-coordinates.d.ts +2 -0
  40. package/engine/internal/misc/frame-coordinates.lua +21 -0
  41. package/engine/internal/misc/get-terrain-z.d.ts +2 -0
  42. package/engine/internal/misc/get-terrain-z.lua +11 -0
  43. package/engine/internal/misc/player-local-handle.d.ts +2 -0
  44. package/engine/internal/misc/player-local-handle.lua +5 -0
  45. package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
  46. package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
  47. package/engine/internal/unit/ability.d.ts +35 -5
  48. package/engine/internal/unit/ability.lua +96 -21
  49. package/engine/internal/unit/attributes.d.ts +17 -0
  50. package/engine/internal/unit/attributes.lua +46 -0
  51. package/engine/internal/unit/bonus.d.ts +2 -0
  52. package/engine/internal/unit/bonus.lua +10 -0
  53. package/engine/internal/unit/fly-height.d.ts +7 -0
  54. package/engine/internal/unit/fly-height.lua +20 -0
  55. package/engine/internal/unit/interrupts.d.ts +12 -0
  56. package/engine/internal/unit/interrupts.lua +28 -0
  57. package/engine/internal/unit/main-selected.lua +12 -27
  58. package/engine/internal/unit/order.d.ts +20 -0
  59. package/engine/internal/unit/order.lua +136 -0
  60. package/engine/internal/unit/scale.d.ts +7 -0
  61. package/engine/internal/unit/scale.lua +20 -0
  62. package/engine/internal/unit+ability.lua +10 -1
  63. package/engine/internal/unit-missile-launch.lua +52 -14
  64. package/engine/internal/unit.d.ts +19 -23
  65. package/engine/internal/unit.lua +171 -190
  66. package/engine/local-client.d.ts +2 -0
  67. package/engine/local-client.lua +30 -0
  68. package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
  69. package/engine/object-data/auxiliary/armor-type.lua +46 -0
  70. package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
  71. package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
  72. package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
  73. package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
  74. package/engine/object-data/entry/ability-type.lua +5 -4
  75. package/engine/object-data/entry/destructible-type.d.ts +27 -1
  76. package/engine/object-data/entry/destructible-type.lua +155 -0
  77. package/engine/object-data/entry/unit-type.d.ts +15 -2
  78. package/engine/object-data/entry/unit-type.lua +135 -33
  79. package/engine/object-field/ability.d.ts +3 -3
  80. package/engine/object-field/ability.lua +7 -6
  81. package/engine/object-field/unit.d.ts +31 -5
  82. package/engine/object-field/unit.lua +95 -0
  83. package/engine/object-field.d.ts +13 -3
  84. package/engine/object-field.lua +279 -133
  85. package/engine/random.d.ts +9 -0
  86. package/engine/random.lua +13 -0
  87. package/engine/standard/fields/ability.d.ts +2 -2
  88. package/engine/standard/fields/ability.lua +2 -2
  89. package/engine/standard/fields/unit.d.ts +12 -0
  90. package/engine/standard/fields/unit.lua +20 -0
  91. package/engine/synchronization.d.ts +11 -0
  92. package/engine/synchronization.lua +77 -0
  93. package/engine/text-tag.d.ts +26 -3
  94. package/engine/text-tag.lua +217 -11
  95. package/engine/unit.d.ts +5 -0
  96. package/engine/unit.lua +5 -0
  97. package/net/socket.lua +1 -1
  98. package/objutil/buff.lua +10 -8
  99. package/package.json +2 -2
  100. package/patch-lualib.lua +1 -1
  101. package/utility/arrays.d.ts +1 -0
  102. package/utility/arrays.lua +8 -0
  103. package/utility/callback-array.d.ts +17 -0
  104. package/utility/callback-array.lua +61 -0
  105. package/utility/functions.d.ts +7 -0
  106. package/utility/functions.lua +12 -0
  107. package/utility/linked-map.d.ts +26 -0
  108. package/utility/linked-map.lua +66 -0
  109. package/utility/linked-set.d.ts +1 -0
  110. package/utility/linked-set.lua +23 -1
  111. package/utility/lua-maps.d.ts +12 -2
  112. package/utility/lua-maps.lua +37 -2
  113. package/utility/lua-sets.d.ts +1 -0
  114. package/utility/lua-sets.lua +4 -0
  115. package/utility/records.lua +20 -1
  116. package/utility/types.d.ts +3 -0
  117. package/core/types/order.d.ts +0 -26
  118. package/core/types/order.lua +0 -65
@@ -22,7 +22,12 @@ local checkNotNull = ____preconditions.checkNotNull
22
22
  local ____lazy = require("utility.lazy")
23
23
  local lazyRecord = ____lazy.lazyRecord
24
24
  local ____timer = require("core.types.timer")
25
+ local consumeZeroTimerCallback = ____timer.consumeZeroTimerCallback
25
26
  local Timer = ____timer.Timer
27
+ local ____lua_2Dsets = require("utility.lua-sets")
28
+ local luaSetOf = ____lua_2Dsets.luaSetOf
29
+ local ____attributes = require("attributes")
30
+ local attribute = ____attributes.attribute
26
31
  local eventInvoke = Event.invoke
27
32
  local condition = Condition
28
33
  local createTrigger = CreateTrigger
@@ -347,33 +352,17 @@ rawset(
347
352
  extractAbilityTypeId
348
353
  )
349
354
  )
350
- local internalAbilityImpactEvent = __TS__New(Event)
351
- internalAbilityChannelingStartEvent:addListener(function(...)
352
- Timer:run(eventInvoke, internalAbilityImpactEvent, ...)
353
- end)
354
- rawset(
355
- Unit,
356
- "abilityImpactEvent",
357
- createDispatchingEvent(
358
- createCommonEvent(internalAbilityImpactEvent),
359
- extractAbilityTypeId
360
- )
361
- )
355
+ local internalAbilityChannelingFinishEvent = __TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_FINISH, collectUnitAbilityEventParameters)
362
356
  rawset(
363
357
  Unit,
364
358
  "abilityChannelingFinishEvent",
365
- createDispatchingEvent(
366
- __TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_FINISH, collectUnitAbilityEventParameters),
367
- extractAbilityTypeId
368
- )
359
+ createDispatchingEvent(internalAbilityChannelingFinishEvent, extractAbilityTypeId)
369
360
  )
361
+ local internalAbilityStopEvent = __TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_ENDCAST, collectUnitAbilityEventParameters)
370
362
  rawset(
371
363
  Unit,
372
364
  "abilityStopEvent",
373
- createDispatchingEvent(
374
- __TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_ENDCAST, collectUnitAbilityEventParameters),
375
- extractAbilityTypeId
376
- )
365
+ createDispatchingEvent(internalAbilityStopEvent, extractAbilityTypeId)
377
366
  )
378
367
  rawset(
379
368
  Unit,
@@ -390,7 +379,7 @@ rawset(
390
379
  condition(function()
391
380
  local unit = Unit:of(getTriggerUnit())
392
381
  if unit ~= nil then
393
- local ability = unit:getAbilityById(abilityTypeId)
382
+ local ability = unit:getAbility(abilityTypeId)
394
383
  if ability ~= nil then
395
384
  eventInvoke(event, unit, ability, orderTypeStringId)
396
385
  end
@@ -402,4 +391,90 @@ rawset(
402
391
  end)
403
392
  end)
404
393
  )
394
+ local internalAbilityImpactEvent = __TS__New(Event)
395
+ local impactCallbackIdAttribute = attribute()
396
+ local function invokeImpactEvent(unit, ability, ...)
397
+ ability[impactCallbackIdAttribute] = nil
398
+ eventInvoke(internalAbilityImpactEvent, unit, ability, ...)
399
+ end
400
+ internalAbilityChannelingStartEvent:addListener(
401
+ 999999,
402
+ function(unit, ability, ...)
403
+ ability[impactCallbackIdAttribute] = Timer:run(invokeImpactEvent, unit, ability, ...)
404
+ end
405
+ )
406
+ local function consumeImpactCallback(_, ability)
407
+ local impactCallbackId = ability[impactCallbackIdAttribute]
408
+ if impactCallbackId ~= nil then
409
+ consumeZeroTimerCallback(impactCallbackId)
410
+ end
411
+ end
412
+ internalAbilityChannelingFinishEvent:addListener(999999, consumeImpactCallback)
413
+ internalAbilityStopEvent:addListener(999999, consumeImpactCallback)
414
+ rawset(
415
+ Unit,
416
+ "abilityImpactEvent",
417
+ createDispatchingEvent(
418
+ createCommonEvent(internalAbilityImpactEvent),
419
+ extractAbilityTypeId
420
+ )
421
+ )
422
+ rawset(
423
+ Unit,
424
+ "abilityWidgetTargetImpactEvent",
425
+ createDispatchingEvent(
426
+ createWidgetTargetEvent(internalAbilityImpactEvent),
427
+ extractAbilityTypeId
428
+ )
429
+ )
430
+ rawset(
431
+ Unit,
432
+ "abilityUnitTargetImpactEvent",
433
+ createDispatchingEvent(
434
+ createUnitTargetEvent(internalAbilityImpactEvent),
435
+ extractAbilityTypeId
436
+ )
437
+ )
438
+ rawset(
439
+ Unit,
440
+ "abilityItemTargetImpactEvent",
441
+ createDispatchingEvent(
442
+ createItemTargetEvent(internalAbilityImpactEvent),
443
+ extractAbilityTypeId
444
+ )
445
+ )
446
+ rawset(
447
+ Unit,
448
+ "abilityDestructibleTargetImpactEvent",
449
+ createDispatchingEvent(
450
+ createDestructibleTargetEvent(internalAbilityImpactEvent),
451
+ extractAbilityTypeId
452
+ )
453
+ )
454
+ rawset(
455
+ Unit,
456
+ "abilityPointTargetImpactEvent",
457
+ createDispatchingEvent(
458
+ createPointTargetEvent(internalAbilityImpactEvent),
459
+ extractAbilityTypeId
460
+ )
461
+ )
462
+ rawset(
463
+ Unit,
464
+ "abilityNoTargetImpactEvent",
465
+ createDispatchingEvent(
466
+ createNoTargetEvent(internalAbilityImpactEvent),
467
+ extractAbilityTypeId
468
+ )
469
+ )
470
+ local spellEffectOnlyAbilityTypeIds = luaSetOf(fourCC("AAns"))
471
+ internalAbilityChannelingStartEvent:addListener(
472
+ -999999,
473
+ function(unit, ability)
474
+ if spellEffectOnlyAbilityTypeIds[ability.parentTypeId] ~= nil then
475
+ eventInvoke(internalAbilityChannelingFinishEvent, unit, ability)
476
+ eventInvoke(internalAbilityStopEvent, unit, ability)
477
+ end
478
+ end
479
+ )
405
480
  return ____exports
@@ -0,0 +1,17 @@
1
+ /** @noSelfInFile */
2
+ declare module "../unit" {
3
+ interface Unit {
4
+ strengthBase: number;
5
+ }
6
+ }
7
+ declare module "../unit" {
8
+ interface Unit {
9
+ agilityBase: number;
10
+ }
11
+ }
12
+ declare module "../unit" {
13
+ interface Unit {
14
+ intelligenceBase: number;
15
+ }
16
+ }
17
+ export {};
@@ -0,0 +1,46 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
3
+ local ____exports = {}
4
+ local ____unit = require("engine.internal.unit")
5
+ local Unit = ____unit.Unit
6
+ local ____unit = require("engine.standard.fields.unit")
7
+ local AGILITY_UNIT_FIELD = ____unit.AGILITY_UNIT_FIELD
8
+ local INTELLIGENCE_UNIT_FIELD = ____unit.INTELLIGENCE_UNIT_FIELD
9
+ local STRENGTH_UNIT_FIELD = ____unit.STRENGTH_UNIT_FIELD
10
+ __TS__ObjectDefineProperty(
11
+ Unit.prototype,
12
+ "strengthBase",
13
+ {
14
+ get = function(self)
15
+ return STRENGTH_UNIT_FIELD:getValue(self)
16
+ end,
17
+ set = function(self, value)
18
+ STRENGTH_UNIT_FIELD:setValue(self, value)
19
+ end
20
+ }
21
+ )
22
+ __TS__ObjectDefineProperty(
23
+ Unit.prototype,
24
+ "agilityBase",
25
+ {
26
+ get = function(self)
27
+ return AGILITY_UNIT_FIELD:getValue(self)
28
+ end,
29
+ set = function(self, value)
30
+ AGILITY_UNIT_FIELD:setValue(self, value)
31
+ end
32
+ }
33
+ )
34
+ __TS__ObjectDefineProperty(
35
+ Unit.prototype,
36
+ "intelligenceBase",
37
+ {
38
+ get = function(self)
39
+ return INTELLIGENCE_UNIT_FIELD:getValue(self)
40
+ end,
41
+ set = function(self, value)
42
+ INTELLIGENCE_UNIT_FIELD:setValue(self, value)
43
+ end
44
+ }
45
+ )
46
+ return ____exports
@@ -12,6 +12,7 @@ export type UnitAutoAttackDamageBonusId = UnitBonusId<"autoAttackDamage">;
12
12
  export type UnitDamageFactorBonusId = UnitBonusId<"damageFactor">;
13
13
  export type UnitReceivedDamageFactorBonusId = UnitBonusId<"receivedDamageFactor">;
14
14
  export type UnitEvasionProbabilityBonusId = UnitBonusId<"evasionProbability">;
15
+ export type UnitManaRegenerationRateFactorBonusId = UnitBonusId<"manaRegenerationRateFactor">;
15
16
  export type UnitBonusType<Id extends UnitBonusId = UnitBonusId> = ({
16
17
  abilityTypeId: AbilityTypeId;
17
18
  field: jabilityintegerlevelfield;
@@ -36,6 +37,7 @@ export declare namespace UnitBonusType {
36
37
  const DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
37
38
  const RECEIVED_DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
38
39
  const EVASION_PROBABILITY: UnitBonusType<UnitEvasionProbabilityBonusId>;
40
+ const MANA_REGENERATION_RATE_FACTOR: UnitBonusType<UnitManaRegenerationRateFactorBonusId>;
39
41
  }
40
42
  export declare const addUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, value: number) => Id;
41
43
  export declare const removeUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id) => boolean;
@@ -24,6 +24,9 @@ local MOVEMENT_SPEED_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID = ____movement_2Dspee
24
24
  local ____evasion_2Dprobability = require("engine.internal.object-data.evasion-probability")
25
25
  local EVASION_PROBABILITY_ABILITY_FIELD = ____evasion_2Dprobability.EVASION_PROBABILITY_ABILITY_FIELD
26
26
  local EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID = ____evasion_2Dprobability.EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID
27
+ local ____mana_2Dregeneration_2Drate_2Dincrease_2Dfactor = require("engine.internal.object-data.mana-regeneration-rate-increase-factor")
28
+ local MANA_REGENERATION_RATE_INCREASE_FACTOR_ABILITY_FIELD = ____mana_2Dregeneration_2Drate_2Dincrease_2Dfactor.MANA_REGENERATION_RATE_INCREASE_FACTOR_ABILITY_FIELD
29
+ local MANA_REGENERATION_RATE_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID = ____mana_2Dregeneration_2Drate_2Dincrease_2Dfactor.MANA_REGENERATION_RATE_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID
27
30
  local damageFactorByUnit = {}
28
31
  local receivedDamageFactorByUnit = {}
29
32
  local function atLeastOnceProbability(array)
@@ -73,6 +76,13 @@ do
73
76
  reduce = atLeastOnceProbability,
74
77
  initialValue = 0
75
78
  }
79
+ UnitBonusType.MANA_REGENERATION_RATE_FACTOR = {
80
+ abilityTypeId = MANA_REGENERATION_RATE_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID,
81
+ field = MANA_REGENERATION_RATE_INCREASE_FACTOR_ABILITY_FIELD,
82
+ integer = false,
83
+ reduce = sum,
84
+ initialValue = 0
85
+ }
76
86
  end
77
87
  local bonusesByUnitByBonusType = {}
78
88
  local nextId = 1
@@ -0,0 +1,7 @@
1
+ /** @noSelfInFile */
2
+ declare module "../unit" {
3
+ interface Unit {
4
+ flyHeight: number;
5
+ }
6
+ }
7
+ export {};
@@ -0,0 +1,20 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
3
+ local ____exports = {}
4
+ local ____unit = require("engine.internal.unit")
5
+ local Unit = ____unit.Unit
6
+ local ____unit = require("engine.standard.fields.unit")
7
+ local FLY_HEIGHT_UNIT_FIELD = ____unit.FLY_HEIGHT_UNIT_FIELD
8
+ __TS__ObjectDefineProperty(
9
+ Unit.prototype,
10
+ "flyHeight",
11
+ {
12
+ get = function(self)
13
+ return FLY_HEIGHT_UNIT_FIELD:getValue(self)
14
+ end,
15
+ set = function(self, value)
16
+ FLY_HEIGHT_UNIT_FIELD:setValue(self, value)
17
+ end
18
+ }
19
+ )
20
+ return ____exports
@@ -0,0 +1,12 @@
1
+ /** @noSelfInFile */
2
+ declare module "../unit" {
3
+ interface Unit {
4
+ interruptAttack(this: Unit): void;
5
+ }
6
+ }
7
+ declare module "../unit" {
8
+ interface Unit {
9
+ interruptMovement(this: Unit): void;
10
+ }
11
+ }
12
+ export {};
@@ -0,0 +1,28 @@
1
+ local ____exports = {}
2
+ local ____unit = require("engine.internal.unit")
3
+ local Unit = ____unit.Unit
4
+ local ____unit_2Dmissile_2Dlaunch = require("engine.internal.unit-missile-launch")
5
+ local resetAutoAttackTimer = ____unit_2Dmissile_2Dlaunch.resetAutoAttackTimer
6
+ local unitDisableAbility = BlzUnitDisableAbility
7
+ local unitInterruptAttack = BlzUnitInterruptAttack
8
+ Unit.prototype.interruptAttack = function(self)
9
+ unitInterruptAttack(self.handle)
10
+ resetAutoAttackTimer(self)
11
+ end
12
+ Unit.prototype.interruptMovement = function(self)
13
+ local handle = self.handle
14
+ unitDisableAbility(
15
+ handle,
16
+ fourCC("Amov"),
17
+ true,
18
+ false
19
+ )
20
+ unitDisableAbility(
21
+ handle,
22
+ fourCC("Amov"),
23
+ false,
24
+ false
25
+ )
26
+ resetAutoAttackTimer(self)
27
+ end
28
+ return ____exports
@@ -1,46 +1,31 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__New = ____lualib.__TS__New
3
3
  local ____exports = {}
4
- local ____player = require("core.types.player")
5
- local Player = ____player.Player
6
- local ____math = require("math")
7
- local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
8
- local MINIMUM_INTEGER = ____math.MINIMUM_INTEGER
9
4
  local ____local_2Dclient = require("engine.local-client")
10
5
  local LocalClient = ____local_2Dclient.LocalClient
11
6
  local ____unit = require("engine.internal.unit")
12
7
  local Unit = ____unit.Unit
13
8
  local ____event = require("event")
14
9
  local Event = ____event.Event
10
+ local ____synchronization = require("engine.synchronization")
11
+ local ObjectBus = ____synchronization.ObjectBus
15
12
  local mainSelectedUnitChangeEvent = __TS__New(Event)
16
13
  rawset(Unit, "mainSelectedUnitChangeEvent", mainSelectedUnitChangeEvent)
17
14
  local mainSelectedUnitByPlayer = {}
18
- local syncSlider = BlzCreateFrameByType(
19
- "SLIDER",
20
- "UnitSyncId",
21
- BlzGetOriginFrame(ORIGIN_FRAME_WORLD_FRAME, 0),
22
- "",
23
- 0
15
+ local unitBus = __TS__New(
16
+ ObjectBus,
17
+ function(unit) return unit.syncId end,
18
+ function(syncId) return Unit:getBySyncId(syncId) end
24
19
  )
25
- BlzFrameSetMinMaxValue(syncSlider, MINIMUM_INTEGER, MAXIMUM_INTEGER)
26
20
  LocalClient.mainSelectedUnitChangeEvent:addListener(function()
27
- local ____opt_0 = LocalClient.mainSelectedUnit
28
- local syncId = ____opt_0 and ____opt_0.syncId
29
- BlzFrameSetValue(syncSlider, syncId or 0)
21
+ unitBus:send(LocalClient.mainSelectedUnit)
30
22
  end)
31
- local trg = CreateTrigger()
32
- BlzTriggerRegisterFrameEvent(trg, syncSlider, FRAMEEVENT_SLIDER_VALUE_CHANGED)
33
- TriggerAddAction(
34
- trg,
35
- function()
36
- local player = Player:of(GetTriggerPlayer())
37
- local mainSelectedUnit = Unit:getBySyncId(BlzGetTriggerFrameValue())
38
- if mainSelectedUnit ~= mainSelectedUnitByPlayer[player] then
39
- mainSelectedUnitByPlayer[player] = mainSelectedUnit
40
- Event.invoke(mainSelectedUnitChangeEvent, player)
41
- end
23
+ unitBus.event:addListener(function(player, unit)
24
+ if unit ~= mainSelectedUnitByPlayer[player] then
25
+ mainSelectedUnitByPlayer[player] = unit
26
+ Event.invoke(mainSelectedUnitChangeEvent, player)
42
27
  end
43
- )
28
+ end)
44
29
  rawset(
45
30
  Unit,
46
31
  "getMainSelectedOf",
@@ -0,0 +1,20 @@
1
+ /** @noSelfInFile */
2
+ import { Widget } from "../../../core/types/widget";
3
+ export declare const enum OrderType {
4
+ IMMEDIATE = 0,
5
+ POINT = 1,
6
+ TARGET = 2
7
+ }
8
+ declare module "../unit" {
9
+ interface Unit {
10
+ readonly currentOrderType: OrderType;
11
+ readonly currentOrderId: number;
12
+ readonly currentOrderStartTime: number;
13
+ readonly currentOrderStartX: number;
14
+ readonly currentOrderStartY: number;
15
+ readonly currentOrderTargetX: number;
16
+ readonly currentOrderTargetY: number;
17
+ readonly currentOrderTarget?: Widget;
18
+ issueOrder(...order: [orderType: OrderType.IMMEDIATE, orderId: number] | [orderType: OrderType.POINT, orderId: number, x: number, y: number] | [orderType: OrderType.TARGET, orderId: number, target: Widget]): boolean;
19
+ }
20
+ }
@@ -0,0 +1,136 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
3
+ local ____exports = {}
4
+ local ____attributes = require("attributes")
5
+ local attribute = ____attributes.attribute
6
+ local ____unit = require("engine.internal.unit")
7
+ local Unit = ____unit.Unit
8
+ local ____game = require("core.game")
9
+ local elapsedTime = ____game.elapsedTime
10
+ local getUnitCurrentOrder = GetUnitCurrentOrder
11
+ local issueImmediateOrderById = IssueImmediateOrderById
12
+ local issuePointOrderById = IssuePointOrderById
13
+ local issueTargetOrderById = IssueTargetOrderById
14
+ local unitLastOrderTypeAttribute = attribute()
15
+ local unitLastOrderIdAttribute = attribute()
16
+ local unitLastOrderStartTimeAttribute = attribute()
17
+ local unitLastOrderStartXAttribute = attribute()
18
+ local unitLastOrderStartYAttribute = attribute()
19
+ local unitLastOrderTargetXAttribute = attribute()
20
+ local unitLastOrderTargetYAttribute = attribute()
21
+ local unitLastOrderTargetAttribute = attribute()
22
+ Unit.onImmediateOrder:addListener(
23
+ 4,
24
+ function(unit, orderId)
25
+ unit[unitLastOrderTypeAttribute] = 0
26
+ unit[unitLastOrderIdAttribute] = orderId
27
+ unit[unitLastOrderStartTimeAttribute] = elapsedTime()
28
+ unit[unitLastOrderStartXAttribute] = unit.x
29
+ unit[unitLastOrderStartYAttribute] = unit.y
30
+ unit[unitLastOrderTargetXAttribute] = nil
31
+ unit[unitLastOrderTargetYAttribute] = nil
32
+ unit[unitLastOrderTargetAttribute] = nil
33
+ end
34
+ )
35
+ Unit.onPointOrder:addListener(
36
+ 4,
37
+ function(unit, orderId, x, y)
38
+ unit[unitLastOrderTypeAttribute] = 1
39
+ unit[unitLastOrderIdAttribute] = orderId
40
+ unit[unitLastOrderStartTimeAttribute] = elapsedTime()
41
+ unit[unitLastOrderStartXAttribute] = unit.x
42
+ unit[unitLastOrderStartYAttribute] = unit.y
43
+ unit[unitLastOrderTargetXAttribute] = x
44
+ unit[unitLastOrderTargetYAttribute] = y
45
+ unit[unitLastOrderTargetAttribute] = nil
46
+ end
47
+ )
48
+ Unit.onTargetOrder:addListener(
49
+ 4,
50
+ function(unit, orderId, target)
51
+ unit[unitLastOrderTypeAttribute] = 2
52
+ unit[unitLastOrderIdAttribute] = orderId
53
+ unit[unitLastOrderStartTimeAttribute] = elapsedTime()
54
+ unit[unitLastOrderStartXAttribute] = unit.x
55
+ unit[unitLastOrderStartYAttribute] = unit.y
56
+ unit[unitLastOrderTargetXAttribute] = target.x
57
+ unit[unitLastOrderTargetYAttribute] = target.y
58
+ unit[unitLastOrderTargetAttribute] = target
59
+ end
60
+ )
61
+ local function toUndefinedIfCurrentOrderDoesNotMatchLast(unit, value)
62
+ local currentOrderId = getUnitCurrentOrder(unit.handle)
63
+ local lastOrderId = unit[unitLastOrderIdAttribute]
64
+ local ____temp_0
65
+ if currentOrderId == lastOrderId or currentOrderId == orderId("patrolAI") and lastOrderId == orderId("patrol") then
66
+ ____temp_0 = value
67
+ else
68
+ ____temp_0 = nil
69
+ end
70
+ return ____temp_0
71
+ end
72
+ __TS__ObjectDefineProperty(
73
+ Unit.prototype,
74
+ "currentOrderType",
75
+ {get = function(self)
76
+ return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTypeAttribute]) or 0
77
+ end}
78
+ )
79
+ __TS__ObjectDefineProperty(
80
+ Unit.prototype,
81
+ "currentOrderId",
82
+ {get = function(self)
83
+ return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderIdAttribute]) or 0
84
+ end}
85
+ )
86
+ __TS__ObjectDefineProperty(
87
+ Unit.prototype,
88
+ "currentOrderStartTime",
89
+ {get = function(self)
90
+ return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderStartTimeAttribute]) or 0
91
+ end}
92
+ )
93
+ __TS__ObjectDefineProperty(
94
+ Unit.prototype,
95
+ "currentOrderStartX",
96
+ {get = function(self)
97
+ return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderStartXAttribute]) or 0
98
+ end}
99
+ )
100
+ __TS__ObjectDefineProperty(
101
+ Unit.prototype,
102
+ "currentOrderStartY",
103
+ {get = function(self)
104
+ return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderStartYAttribute]) or 0
105
+ end}
106
+ )
107
+ __TS__ObjectDefineProperty(
108
+ Unit.prototype,
109
+ "currentOrderTargetX",
110
+ {get = function(self)
111
+ return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTargetXAttribute]) or 0
112
+ end}
113
+ )
114
+ __TS__ObjectDefineProperty(
115
+ Unit.prototype,
116
+ "currentOrderTargetY",
117
+ {get = function(self)
118
+ return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTargetYAttribute]) or 0
119
+ end}
120
+ )
121
+ __TS__ObjectDefineProperty(
122
+ Unit.prototype,
123
+ "currentOrderTarget",
124
+ {get = function(self)
125
+ return toUndefinedIfCurrentOrderDoesNotMatchLast(self, self[unitLastOrderTargetAttribute])
126
+ end}
127
+ )
128
+ local issueOrderByType = {
129
+ [0] = issueImmediateOrderById,
130
+ [1] = issuePointOrderById,
131
+ [2] = function(unitHandle, orderId, widget) return issueTargetOrderById(unitHandle, orderId, widget.handle) end
132
+ }
133
+ Unit.prototype.issueOrder = function(self, orderType, orderId, xOrTarget, y)
134
+ return issueOrderByType[orderType](self.handle, orderId, xOrTarget, y)
135
+ end
136
+ return ____exports
@@ -0,0 +1,7 @@
1
+ /** @noSelfInFile */
2
+ declare module "../unit" {
3
+ interface Unit {
4
+ scale: number;
5
+ }
6
+ }
7
+ export {};
@@ -0,0 +1,20 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
3
+ local ____exports = {}
4
+ local ____unit = require("engine.internal.unit")
5
+ local Unit = ____unit.Unit
6
+ local ____unit = require("engine.standard.fields.unit")
7
+ local SCALING_VALUE_UNIT_FIELD = ____unit.SCALING_VALUE_UNIT_FIELD
8
+ __TS__ObjectDefineProperty(
9
+ Unit.prototype,
10
+ "scale",
11
+ {
12
+ get = function(self)
13
+ return SCALING_VALUE_UNIT_FIELD:getValue(self)
14
+ end,
15
+ set = function(self, value)
16
+ SCALING_VALUE_UNIT_FIELD:setValue(self, value)
17
+ end
18
+ }
19
+ )
20
+ return ____exports
@@ -7,8 +7,8 @@ local UnitAbility = ____ability.UnitAbility
7
7
  local ____unit = require("engine.internal.unit")
8
8
  local Unit = ____unit.Unit
9
9
  local ____event = require("event")
10
- local Event = ____event.Event
11
10
  local createDispatchingEvent = ____event.createDispatchingEvent
11
+ local Event = ____event.Event
12
12
  local abilityGainedEvent = createDispatchingEvent(
13
13
  __TS__New(Event),
14
14
  function(unit, ability) return ability.typeId end
@@ -40,6 +40,15 @@ ItemAbility.onCreate:addListener(
40
40
  end
41
41
  end
42
42
  )
43
+ ItemAbility.destroyEvent:addListener(
44
+ 4,
45
+ function(ability)
46
+ local unit = ability.owner.owner
47
+ if unit ~= nil then
48
+ Event.invoke(abilityLostEvent, unit, ability)
49
+ end
50
+ end
51
+ )
43
52
  Unit.itemPickedUpEvent:addListener(
44
53
  0,
45
54
  function(unit, item)