warscript 0.0.1-dev.c963f13 → 0.0.1-dev.ccc2b77
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.
- package/attributes.d.ts +0 -1
- package/binaryreader.d.ts +1 -0
- package/binaryreader.lua +3 -0
- package/core/types/frame.d.ts +5 -1
- package/core/types/frame.lua +34 -1
- package/core/types/group.d.ts +0 -1
- package/core/types/image.d.ts +0 -1
- package/core/types/missile.d.ts +2 -2
- package/core/types/missile.lua +8 -2
- package/core/types/unit.lua +8 -0
- package/core/util.d.ts +1 -1
- package/core/util.lua +6 -0
- package/decl/index.d.ts +1 -0
- package/engine/ability.d.ts +1 -1
- package/engine/behavior.d.ts +10 -10
- package/engine/behavior.lua +6 -6
- package/engine/behaviour/ability/apply-buff.d.ts +3 -5
- package/engine/behaviour/ability/apply-unit-behavior.d.ts +6 -1
- package/engine/behaviour/ability/damage.d.ts +33 -11
- package/engine/behaviour/ability/damage.lua +89 -31
- package/engine/behaviour/ability/heal.d.ts +33 -6
- package/engine/behaviour/ability/heal.lua +89 -10
- package/engine/behaviour/ability/instant-impact.lua +4 -0
- package/engine/behaviour/ability/restore-mana.d.ts +15 -0
- package/engine/behaviour/ability/restore-mana.lua +29 -0
- package/engine/behaviour/ability.d.ts +8 -1
- package/engine/behaviour/ability.lua +62 -0
- package/engine/behaviour/unit/stun-immunity.d.ts +0 -1
- package/engine/behaviour/unit.d.ts +8 -2
- package/engine/behaviour/unit.lua +27 -0
- package/engine/buff.d.ts +62 -20
- package/engine/buff.lua +247 -72
- package/engine/game-map.d.ts +7 -0
- package/engine/game-map.lua +32 -0
- package/engine/internal/ability.d.ts +1 -11
- package/engine/internal/ability.lua +2 -78
- package/engine/internal/item+owner.lua +2 -2
- package/engine/internal/unit/bonus.d.ts +9 -8
- package/engine/internal/unit/bonus.lua +6 -1
- package/engine/internal/unit/item.d.ts +23 -0
- package/engine/internal/unit/item.lua +74 -0
- package/engine/internal/unit+ability.lua +2 -2
- package/engine/internal/unit+transport.lua +4 -10
- package/engine/internal/unit-missile-launch.lua +25 -6
- package/engine/internal/unit.d.ts +33 -12
- package/engine/internal/unit.lua +231 -87
- package/engine/local-client.d.ts +7 -2
- package/engine/local-client.lua +81 -0
- package/engine/object-data/auxiliary/attachment-preset.d.ts +0 -1
- package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
- package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
- package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
- package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
- package/engine/object-data/entry/ability-type/mine.d.ts +10 -0
- package/engine/object-data/entry/ability-type/mine.lua +39 -0
- package/engine/object-data/entry/ability-type/spirit-touch.d.ts +2 -2
- package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
- package/engine/object-data/entry/ability-type.d.ts +0 -1
- package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
- package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
- package/engine/object-data/entry/buff-type.d.ts +0 -1
- package/engine/object-data/entry/destructible-type.d.ts +0 -1
- package/engine/object-data/entry/item-type/blank.d.ts +0 -1
- package/engine/object-data/entry/item-type.d.ts +12 -1
- package/engine/object-data/entry/item-type.lua +78 -0
- package/engine/object-data/entry/lightning-type.d.ts +0 -1
- package/engine/object-data/entry/unit-type.d.ts +0 -1
- package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
- package/engine/object-data/entry/upgrade.d.ts +0 -1
- package/engine/object-data/entry.d.ts +2 -3
- package/engine/object-field/ability.d.ts +18 -1
- package/engine/object-field/ability.lua +51 -1
- package/engine/object-field.d.ts +0 -1
- package/engine/random.d.ts +1 -0
- package/engine/random.lua +9 -0
- package/engine/standard/entries/unit-type.d.ts +18 -0
- package/engine/standard/entries/unit-type.lua +18 -0
- package/engine/standard/fields/ability.d.ts +1 -1
- package/engine/standard/fields/ability.lua +1 -1
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +10 -2
- package/event.d.ts +2 -3
- package/event.lua +9 -5
- package/index.d.ts +1 -0
- package/index.lua +1 -0
- package/lualib_bundle.lua +146 -42
- package/math/vec2.d.ts +2 -9
- package/math.d.ts +0 -2
- package/net/socket.d.ts +7 -1
- package/net/socket.lua +45 -4
- package/network.d.ts +1 -0
- package/network.lua +3 -2
- package/objutil/ability.d.ts +0 -1
- package/objutil/buff.d.ts +0 -1
- package/objutil/buff.lua +1 -1
- package/objutil/object.d.ts +0 -1
- package/objutil/unit.d.ts +0 -1
- package/package.json +13 -13
- package/patch-lua.d.ts +0 -0
- package/patch-lua.lua +10 -0
- package/property.d.ts +55 -0
- package/property.lua +374 -0
- package/string.d.ts +16 -0
- package/string.lua +5 -0
- package/util/stream.d.ts +0 -1
- package/utility/arrays.d.ts +3 -4
- package/utility/bit-set.d.ts +0 -2
- package/utility/linked-set.d.ts +11 -3
- package/utility/linked-set.lua +5 -2
- package/utility/lua-maps.d.ts +1 -2
- package/utility/lua-sets.d.ts +1 -2
- package/utility/types.d.ts +1 -0
- package/core/mapbounds.d.ts +0 -8
- package/core/mapbounds.lua +0 -12
package/engine/internal/unit.lua
CHANGED
|
@@ -5,9 +5,12 @@ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
|
5
5
|
local __TS__New = ____lualib.__TS__New
|
|
6
6
|
local __TS__Class = ____lualib.__TS__Class
|
|
7
7
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
8
|
+
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
8
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
|
|
9
13
|
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
10
|
-
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
11
14
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
12
15
|
local Set = ____lualib.Set
|
|
13
16
|
local __TS__Spread = ____lualib.__TS__Spread
|
|
@@ -92,6 +95,10 @@ local isUnitInRangeXY = IsUnitInRangeXY
|
|
|
92
95
|
local isUnitInRange = IsUnitInRange
|
|
93
96
|
local setResourceAmount = SetResourceAmount
|
|
94
97
|
local getResourceAmount = GetResourceAmount
|
|
98
|
+
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
99
|
+
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
100
|
+
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
101
|
+
local setUnitWeaponStringField = BlzSetUnitWeaponStringField
|
|
95
102
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
96
103
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
97
104
|
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
@@ -275,16 +282,14 @@ function UnitTriggerEvent.prototype.____constructor(self, eventType, c)
|
|
|
275
282
|
end
|
|
276
283
|
local function dispatch(event, idGetter, argsGetter)
|
|
277
284
|
local initialized = false
|
|
278
|
-
local x = {}
|
|
279
285
|
return setmetatable(
|
|
280
|
-
|
|
286
|
+
{},
|
|
281
287
|
{
|
|
282
288
|
__index = function(self, id)
|
|
283
289
|
if type(id) ~= "number" then
|
|
284
290
|
return event[id]
|
|
285
291
|
end
|
|
286
292
|
if not initialized then
|
|
287
|
-
local invoke = Event.invoke
|
|
288
293
|
event:addListener(function(...)
|
|
289
294
|
local id = idGetter(...)
|
|
290
295
|
local dispatched = rawget(self, id)
|
|
@@ -322,7 +327,6 @@ local function dispatchAbility(event)
|
|
|
322
327
|
return event[id]
|
|
323
328
|
end
|
|
324
329
|
if not initialized then
|
|
325
|
-
local invoke = Event.invoke
|
|
326
330
|
event:addListener(function(unit, ability, ...)
|
|
327
331
|
local dispatched = rawget(self, ability.typeId)
|
|
328
332
|
if dispatched ~= nil then
|
|
@@ -387,51 +391,158 @@ local getters = {
|
|
|
387
391
|
return BlzGetUnitArmor(unit)
|
|
388
392
|
end
|
|
389
393
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
394
|
+
____exports.UnitWeapon = __TS__Class()
|
|
395
|
+
local UnitWeapon = ____exports.UnitWeapon
|
|
396
|
+
UnitWeapon.name = "UnitWeapon"
|
|
397
|
+
function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
398
|
+
self.unit = unit
|
|
399
|
+
self.index = index
|
|
400
|
+
end
|
|
401
|
+
__TS__SetDescriptor(
|
|
402
|
+
UnitWeapon.prototype,
|
|
403
|
+
"cooldown",
|
|
404
|
+
{
|
|
405
|
+
get = function(self)
|
|
406
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index)
|
|
407
|
+
end,
|
|
408
|
+
set = function(self, cooldown)
|
|
409
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, self.index, cooldown)
|
|
410
|
+
end
|
|
411
|
+
},
|
|
412
|
+
true
|
|
413
|
+
)
|
|
414
|
+
__TS__SetDescriptor(
|
|
415
|
+
UnitWeapon.prototype,
|
|
416
|
+
"damage",
|
|
417
|
+
{
|
|
418
|
+
get = function(self)
|
|
419
|
+
local minimumDamage = self.damageBase + self.damageDiceCount
|
|
420
|
+
local maximumDamage = self.damageBase + self.damageDiceCount * self.damageDiceSideCount
|
|
421
|
+
return {minimumDamage, maximumDamage}
|
|
422
|
+
end,
|
|
423
|
+
set = function(self, ____bindingPattern0)
|
|
424
|
+
local maximumDamage
|
|
425
|
+
local minimumDamage
|
|
426
|
+
minimumDamage = ____bindingPattern0[1]
|
|
427
|
+
maximumDamage = ____bindingPattern0[2]
|
|
428
|
+
self.damageBase = minimumDamage - 1
|
|
429
|
+
self.damageDiceCount = 1
|
|
430
|
+
self.damageDiceSideCount = maximumDamage - minimumDamage + 1
|
|
431
|
+
end
|
|
432
|
+
},
|
|
433
|
+
true
|
|
434
|
+
)
|
|
435
|
+
__TS__SetDescriptor(
|
|
436
|
+
UnitWeapon.prototype,
|
|
437
|
+
"damageBase",
|
|
438
|
+
{
|
|
439
|
+
get = function(self)
|
|
440
|
+
return BlzGetUnitBaseDamage(self.unit.handle, self.index)
|
|
441
|
+
end,
|
|
442
|
+
set = function(self, damageBase)
|
|
443
|
+
BlzSetUnitBaseDamage(self.unit.handle, self.index, damageBase)
|
|
444
|
+
end
|
|
445
|
+
},
|
|
446
|
+
true
|
|
447
|
+
)
|
|
448
|
+
__TS__SetDescriptor(
|
|
449
|
+
UnitWeapon.prototype,
|
|
450
|
+
"damageDiceCount",
|
|
451
|
+
{
|
|
452
|
+
get = function(self)
|
|
453
|
+
return BlzGetUnitDiceNumber(self.unit.handle, self.index)
|
|
454
|
+
end,
|
|
455
|
+
set = function(self, damageDiceCount)
|
|
456
|
+
BlzSetUnitDiceNumber(self.unit.handle, self.index, damageDiceCount)
|
|
457
|
+
end
|
|
458
|
+
},
|
|
459
|
+
true
|
|
460
|
+
)
|
|
461
|
+
__TS__SetDescriptor(
|
|
462
|
+
UnitWeapon.prototype,
|
|
463
|
+
"damageDiceSideCount",
|
|
464
|
+
{
|
|
465
|
+
get = function(self)
|
|
466
|
+
return BlzGetUnitDiceSides(self.unit.handle, self.index)
|
|
467
|
+
end,
|
|
468
|
+
set = function(self, damageDiceSideCount)
|
|
469
|
+
BlzSetUnitDiceSides(self.unit.handle, self.index, damageDiceSideCount)
|
|
470
|
+
end
|
|
471
|
+
},
|
|
472
|
+
true
|
|
473
|
+
)
|
|
474
|
+
__TS__SetDescriptor(
|
|
475
|
+
UnitWeapon.prototype,
|
|
476
|
+
"range",
|
|
477
|
+
{
|
|
478
|
+
get = function(self)
|
|
479
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_RANGE, self.index)
|
|
480
|
+
end,
|
|
481
|
+
set = function(self, range)
|
|
482
|
+
local handle = self.unit.handle
|
|
483
|
+
local index = self.index
|
|
484
|
+
setUnitWeaponRealField(
|
|
485
|
+
handle,
|
|
486
|
+
UNIT_WEAPON_RF_ATTACK_RANGE,
|
|
487
|
+
index + 1,
|
|
488
|
+
getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index + 1) + (range - getUnitWeaponRealField(handle, UNIT_WEAPON_RF_ATTACK_RANGE, index))
|
|
489
|
+
)
|
|
490
|
+
end
|
|
491
|
+
},
|
|
492
|
+
true
|
|
493
|
+
)
|
|
494
|
+
__TS__SetDescriptor(
|
|
495
|
+
UnitWeapon.prototype,
|
|
496
|
+
"impactDelay",
|
|
497
|
+
{
|
|
498
|
+
get = function(self)
|
|
499
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index)
|
|
500
|
+
end,
|
|
501
|
+
set = function(self, impactDelay)
|
|
502
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, self.index, impactDelay)
|
|
503
|
+
end
|
|
504
|
+
},
|
|
505
|
+
true
|
|
506
|
+
)
|
|
507
|
+
__TS__SetDescriptor(
|
|
508
|
+
UnitWeapon.prototype,
|
|
509
|
+
"missileArc",
|
|
510
|
+
{
|
|
511
|
+
get = function(self)
|
|
512
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index)
|
|
513
|
+
end,
|
|
514
|
+
set = function(self, missileArc)
|
|
515
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC, self.index, missileArc)
|
|
516
|
+
end
|
|
517
|
+
},
|
|
518
|
+
true
|
|
519
|
+
)
|
|
520
|
+
__TS__SetDescriptor(
|
|
521
|
+
UnitWeapon.prototype,
|
|
522
|
+
"missileModelPath",
|
|
523
|
+
{
|
|
524
|
+
get = function(self)
|
|
525
|
+
return getUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index)
|
|
526
|
+
end,
|
|
527
|
+
set = function(self, missileModelPath)
|
|
528
|
+
setUnitWeaponStringField(self.unit.handle, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, self.index, missileModelPath)
|
|
529
|
+
end
|
|
530
|
+
},
|
|
531
|
+
true
|
|
532
|
+
)
|
|
533
|
+
__TS__SetDescriptor(
|
|
534
|
+
UnitWeapon.prototype,
|
|
535
|
+
"missileSpeed",
|
|
536
|
+
{
|
|
537
|
+
get = function(self)
|
|
538
|
+
return getUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index)
|
|
539
|
+
end,
|
|
540
|
+
set = function(self, missileSpeed)
|
|
541
|
+
setUnitWeaponRealField(self.unit.handle, UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED, self.index, missileSpeed)
|
|
542
|
+
end
|
|
543
|
+
},
|
|
544
|
+
true
|
|
545
|
+
)
|
|
435
546
|
local unitInventorySize = UnitInventorySize
|
|
436
547
|
local unitItemInSlot = UnitItemInSlot
|
|
437
548
|
local getItemAbility = BlzGetItemAbility
|
|
@@ -442,8 +553,6 @@ local getAbilityName = GetAbilityName
|
|
|
442
553
|
local unitAddAbility = UnitAddAbility
|
|
443
554
|
local getUnitGoldCost = GetUnitGoldCost
|
|
444
555
|
local getUnitLumberCost = GetUnitWoodCost
|
|
445
|
-
local unitMakeAbilityPermanent = UnitMakeAbilityPermanent
|
|
446
|
-
local unitAddItem = UnitAddItem
|
|
447
556
|
local unitRemoveAbility = UnitRemoveAbility
|
|
448
557
|
local function retrieveAbility(unit, ability, abilityId)
|
|
449
558
|
if ability == nil then
|
|
@@ -708,8 +817,15 @@ end
|
|
|
708
817
|
function Unit.prototype.kill(self)
|
|
709
818
|
killUnit(self.handle)
|
|
710
819
|
end
|
|
711
|
-
function Unit.prototype.revive(self,
|
|
712
|
-
|
|
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))
|
|
713
829
|
end
|
|
714
830
|
function Unit.prototype.healTarget(self, target, amount)
|
|
715
831
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -749,7 +865,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
749
865
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
750
866
|
end
|
|
751
867
|
function Unit.prototype.itemInSlot(self, slot)
|
|
752
|
-
return Item:of(
|
|
868
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
753
869
|
end
|
|
754
870
|
function Unit.prototype.addAbility(self, abilityId)
|
|
755
871
|
if unitAddAbility(self.handle, abilityId) then
|
|
@@ -805,6 +921,9 @@ end
|
|
|
805
921
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
806
922
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
807
923
|
end
|
|
924
|
+
function Unit.prototype.getAbilityRemainingCooldown(self, abilityId)
|
|
925
|
+
return BlzGetUnitAbilityCooldownRemaining(self.handle, abilityId)
|
|
926
|
+
end
|
|
808
927
|
function Unit.prototype.startAbilityCooldown(self, abilityId, cooldown)
|
|
809
928
|
BlzStartUnitAbilityCooldown(self.handle, abilityId, cooldown)
|
|
810
929
|
end
|
|
@@ -989,8 +1108,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
989
1108
|
)
|
|
990
1109
|
return targetCollection
|
|
991
1110
|
end
|
|
992
|
-
function Unit.getSelectionOf(self, player)
|
|
993
|
-
|
|
1111
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1112
|
+
if target == nil then
|
|
1113
|
+
target = {}
|
|
1114
|
+
end
|
|
1115
|
+
targetCollection = target
|
|
994
1116
|
targetCollectionNextIndex = 1
|
|
995
1117
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
996
1118
|
return targetCollection
|
|
@@ -1092,12 +1214,27 @@ __TS__SetDescriptor(
|
|
|
1092
1214
|
Unit.prototype,
|
|
1093
1215
|
"weapons",
|
|
1094
1216
|
{get = function(self)
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1217
|
+
return {self.firstWeapon, self.secondWeapon}
|
|
1218
|
+
end},
|
|
1219
|
+
true
|
|
1220
|
+
)
|
|
1221
|
+
__TS__SetDescriptor(
|
|
1222
|
+
Unit.prototype,
|
|
1223
|
+
"firstWeapon",
|
|
1224
|
+
{get = function(self)
|
|
1225
|
+
local weapon = __TS__New(____exports.UnitWeapon, self, 0)
|
|
1226
|
+
rawset(self, "firstWeapon", weapon)
|
|
1227
|
+
return weapon
|
|
1228
|
+
end},
|
|
1229
|
+
true
|
|
1230
|
+
)
|
|
1231
|
+
__TS__SetDescriptor(
|
|
1232
|
+
Unit.prototype,
|
|
1233
|
+
"secondWeapon",
|
|
1234
|
+
{get = function(self)
|
|
1235
|
+
local weapon = __TS__New(____exports.UnitWeapon, self, 1)
|
|
1236
|
+
rawset(self, "secondWeapon", weapon)
|
|
1237
|
+
return weapon
|
|
1101
1238
|
end},
|
|
1102
1239
|
true
|
|
1103
1240
|
)
|
|
@@ -1258,13 +1395,13 @@ __TS__SetDescriptor(
|
|
|
1258
1395
|
end,
|
|
1259
1396
|
set = function(self, isTeamGlowVisible)
|
|
1260
1397
|
showUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1261
|
-
local
|
|
1398
|
+
local ____temp_5
|
|
1262
1399
|
if not isTeamGlowVisible then
|
|
1263
|
-
|
|
1400
|
+
____temp_5 = true
|
|
1264
1401
|
else
|
|
1265
|
-
|
|
1402
|
+
____temp_5 = nil
|
|
1266
1403
|
end
|
|
1267
|
-
self[105] =
|
|
1404
|
+
self[105] = ____temp_5
|
|
1268
1405
|
end
|
|
1269
1406
|
},
|
|
1270
1407
|
true
|
|
@@ -1928,7 +2065,6 @@ Unit.onDecay = __TS__New(
|
|
|
1928
2065
|
Unit.onResurrect = __TS__New(
|
|
1929
2066
|
InitializingEvent,
|
|
1930
2067
|
function(event)
|
|
1931
|
-
local invoke = Event.invoke
|
|
1932
2068
|
local dead = setmetatable({}, {__mode = "k"})
|
|
1933
2069
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
1934
2070
|
dead[unit] = true
|
|
@@ -1944,10 +2080,15 @@ Unit.onResurrect = __TS__New(
|
|
|
1944
2080
|
Unit.morphEvent = __TS__New(
|
|
1945
2081
|
InitializingEvent,
|
|
1946
2082
|
function(event)
|
|
2083
|
+
local function ifNotLeft(unit)
|
|
2084
|
+
local handle = unit.handle
|
|
2085
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2086
|
+
invoke(event, unit)
|
|
2087
|
+
end
|
|
2088
|
+
end
|
|
1947
2089
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
1948
2090
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
1949
|
-
|
|
1950
|
-
Timer:run(Event.invoke, event, unit)
|
|
2091
|
+
Timer:run(ifNotLeft, unit)
|
|
1951
2092
|
end
|
|
1952
2093
|
end)
|
|
1953
2094
|
end
|
|
@@ -1985,27 +2126,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
1985
2126
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
1986
2127
|
InitializingEvent,
|
|
1987
2128
|
function(event)
|
|
1988
|
-
local invoke = Event.invoke
|
|
1989
2129
|
local function listener(unit, id)
|
|
1990
|
-
local
|
|
2130
|
+
local ____GetSpellTargetUnit_result_8
|
|
1991
2131
|
if GetSpellTargetUnit() then
|
|
1992
|
-
|
|
2132
|
+
____GetSpellTargetUnit_result_8 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
1993
2133
|
else
|
|
1994
|
-
local
|
|
2134
|
+
local ____GetSpellTargetItem_result_7
|
|
1995
2135
|
if GetSpellTargetItem() then
|
|
1996
|
-
|
|
2136
|
+
____GetSpellTargetItem_result_7 = Item:of(GetSpellTargetItem())
|
|
1997
2137
|
else
|
|
1998
|
-
local
|
|
2138
|
+
local ____GetSpellTargetDestructable_result_6
|
|
1999
2139
|
if GetSpellTargetDestructable() then
|
|
2000
|
-
|
|
2140
|
+
____GetSpellTargetDestructable_result_6 = Destructable:of(GetSpellTargetDestructable())
|
|
2001
2141
|
else
|
|
2002
|
-
|
|
2142
|
+
____GetSpellTargetDestructable_result_6 = nil
|
|
2003
2143
|
end
|
|
2004
|
-
|
|
2144
|
+
____GetSpellTargetItem_result_7 = ____GetSpellTargetDestructable_result_6
|
|
2005
2145
|
end
|
|
2006
|
-
|
|
2146
|
+
____GetSpellTargetUnit_result_8 = ____GetSpellTargetItem_result_7
|
|
2007
2147
|
end
|
|
2008
|
-
local target =
|
|
2148
|
+
local target = ____GetSpellTargetUnit_result_8
|
|
2009
2149
|
if target then
|
|
2010
2150
|
invoke(event, unit, id, target)
|
|
2011
2151
|
end
|
|
@@ -2202,7 +2342,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2202
2342
|
)
|
|
2203
2343
|
Unit.onDamaging = (function()
|
|
2204
2344
|
local event = __TS__New(Event)
|
|
2205
|
-
local invoke = Event.invoke
|
|
2206
2345
|
local trigger = CreateTrigger()
|
|
2207
2346
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2208
2347
|
TriggerAddCondition(
|
|
@@ -2301,7 +2440,6 @@ end)()
|
|
|
2301
2440
|
Unit.onDamage = __TS__New(
|
|
2302
2441
|
InitializingEvent,
|
|
2303
2442
|
function(event)
|
|
2304
|
-
local invoke = Event.invoke
|
|
2305
2443
|
local trigger = CreateTrigger()
|
|
2306
2444
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2307
2445
|
TriggerAddCondition(
|
|
@@ -2317,6 +2455,7 @@ Unit.onDamage = __TS__New(
|
|
|
2317
2455
|
damageType = BlzGetEventDamageType(),
|
|
2318
2456
|
weaponType = BlzGetEventWeaponType(),
|
|
2319
2457
|
isAttack = BlzGetEventIsAttack(),
|
|
2458
|
+
originalAmount = GetEventDamage(),
|
|
2320
2459
|
preventDeath = damageEventPreventDeath
|
|
2321
2460
|
}
|
|
2322
2461
|
local evData = setmetatable(
|
|
@@ -2367,7 +2506,7 @@ Unit.onDamage = __TS__New(
|
|
|
2367
2506
|
DestroyTrigger(trigger)
|
|
2368
2507
|
end
|
|
2369
2508
|
)
|
|
2370
|
-
Unit.
|
|
2509
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2371
2510
|
____exports.UnitTriggerEvent,
|
|
2372
2511
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2373
2512
|
function()
|
|
@@ -2378,7 +2517,7 @@ Unit.onItemDrop = __TS__New(
|
|
|
2378
2517
|
return IgnoreEvent
|
|
2379
2518
|
end
|
|
2380
2519
|
)
|
|
2381
|
-
Unit.
|
|
2520
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2382
2521
|
____exports.UnitTriggerEvent,
|
|
2383
2522
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2384
2523
|
function()
|
|
@@ -2389,10 +2528,15 @@ Unit.onItemPickup = __TS__New(
|
|
|
2389
2528
|
return IgnoreEvent
|
|
2390
2529
|
end
|
|
2391
2530
|
)
|
|
2392
|
-
Unit.
|
|
2531
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2393
2532
|
____exports.UnitTriggerEvent,
|
|
2394
2533
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2395
|
-
function() return ____exports.Unit:of(
|
|
2534
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2535
|
+
)
|
|
2536
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2537
|
+
____exports.UnitTriggerEvent,
|
|
2538
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2539
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2396
2540
|
)
|
|
2397
2541
|
__TS__ObjectDefineProperty(
|
|
2398
2542
|
Unit,
|
package/engine/local-client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { Unit } from "../core/types/unit";
|
|
3
3
|
import { Async } from "../core/types/async";
|
|
4
|
-
import { TriggerEvent } from "../event";
|
|
4
|
+
import { Event, TriggerEvent } from "../event";
|
|
5
5
|
import { GraphicsMode } from "./index";
|
|
6
6
|
export declare class LocalClient {
|
|
7
7
|
private constructor();
|
|
@@ -11,6 +11,11 @@ export declare class LocalClient {
|
|
|
11
11
|
static get isHD(): boolean;
|
|
12
12
|
static get graphicsMode(): GraphicsMode;
|
|
13
13
|
static get isActive(): boolean;
|
|
14
|
-
static get mouseFocusUnit(): Async<Unit
|
|
14
|
+
static get mouseFocusUnit(): Async<Unit> | undefined;
|
|
15
|
+
static get mainSelectedUnit(): Async<Unit> | undefined;
|
|
16
|
+
static get mainSelectedUnitChangeEvent(): Event<[
|
|
17
|
+
previousMainSelectedUnit: Unit | undefined,
|
|
18
|
+
newMainSelectedUnit: Unit | undefined
|
|
19
|
+
]>;
|
|
15
20
|
static readonly onDisconnect: TriggerEvent<[]>;
|
|
16
21
|
}
|
package/engine/local-client.lua
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
2
3
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
4
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
4
5
|
local __TS__New = ____lualib.__TS__New
|
|
@@ -6,13 +7,25 @@ local ____exports = {}
|
|
|
6
7
|
local ____unit = require("core.types.unit")
|
|
7
8
|
local Unit = ____unit.Unit
|
|
8
9
|
local ____event = require("event")
|
|
10
|
+
local Event = ____event.Event
|
|
9
11
|
local TriggerEvent = ____event.TriggerEvent
|
|
12
|
+
local ____frame = require("core.types.frame")
|
|
13
|
+
local Frame = ____frame.Frame
|
|
14
|
+
local ____player = require("core.types.player")
|
|
15
|
+
local Player = ____player.Player
|
|
16
|
+
local ____timer = require("core.types.timer")
|
|
17
|
+
local Timer = ____timer.Timer
|
|
10
18
|
local loadTOCFile = BlzLoadTOCFile
|
|
11
19
|
local getLocalClientWidth = BlzGetLocalClientWidth
|
|
12
20
|
local getLocalClientHeight = BlzGetLocalClientHeight
|
|
13
21
|
local isLocalClientActive = BlzIsLocalClientActive
|
|
22
|
+
local isHeroUnitId = IsHeroUnitId
|
|
23
|
+
local getHandleId = GetHandleId
|
|
14
24
|
local getMouseFocusUnit = BlzGetMouseFocusUnit
|
|
25
|
+
local getUnitRealField = BlzGetUnitRealField
|
|
26
|
+
local getUnitTypeId = GetUnitTypeId
|
|
15
27
|
local getLocale = BlzGetLocale
|
|
28
|
+
local tableSort = table.sort
|
|
16
29
|
local tocPath = "_warscript\\IsHD.toc"
|
|
17
30
|
compiletime(function()
|
|
18
31
|
if currentMap then
|
|
@@ -21,6 +34,29 @@ compiletime(function()
|
|
|
21
34
|
currentMap:addFileString("_HD.w3mod\\" .. tocPath, fdfPath .. "\r\n")
|
|
22
35
|
end
|
|
23
36
|
end)
|
|
37
|
+
local selectionButtons
|
|
38
|
+
Timer:run(function()
|
|
39
|
+
selectionButtons = __TS__ArrayMap(
|
|
40
|
+
Frame:byName("SimpleInfoPanelUnitDetail").parent:getChild(5):getChild(0).children,
|
|
41
|
+
function(____, frame) return frame:getChild(1) end
|
|
42
|
+
)
|
|
43
|
+
end)
|
|
44
|
+
local localSelectedUnits = {}
|
|
45
|
+
local indexByLocalSelectedUnit = {}
|
|
46
|
+
local function compareUnitsSelectionPriority(a, b)
|
|
47
|
+
local aHandle = a.handle
|
|
48
|
+
local bHandle = b.handle
|
|
49
|
+
local priorityDelta = getUnitRealField(bHandle, UNIT_RF_PRIORITY) - getUnitRealField(aHandle, UNIT_RF_PRIORITY)
|
|
50
|
+
if priorityDelta ~= 0 then
|
|
51
|
+
return priorityDelta < 0
|
|
52
|
+
end
|
|
53
|
+
local aTypeId = getUnitTypeId(aHandle)
|
|
54
|
+
local bTypeId = getUnitTypeId(bHandle)
|
|
55
|
+
local orderDelta = (isHeroUnitId(aTypeId) and getHandleId(aHandle) or aTypeId) - (isHeroUnitId(bTypeId) and getHandleId(bHandle) or bTypeId)
|
|
56
|
+
return (orderDelta ~= 0 and orderDelta or indexByLocalSelectedUnit[a] - indexByLocalSelectedUnit[b]) < 0
|
|
57
|
+
end
|
|
58
|
+
local mainSelectedUnitChangeEvent
|
|
59
|
+
local previousMainSelectedUnit
|
|
24
60
|
____exports.LocalClient = __TS__Class()
|
|
25
61
|
local LocalClient = ____exports.LocalClient
|
|
26
62
|
LocalClient.name = "LocalClient"
|
|
@@ -69,6 +105,51 @@ __TS__ObjectDefineProperty(
|
|
|
69
105
|
return Unit:of(getMouseFocusUnit())
|
|
70
106
|
end}
|
|
71
107
|
)
|
|
108
|
+
__TS__ObjectDefineProperty(
|
|
109
|
+
LocalClient,
|
|
110
|
+
"mainSelectedUnit",
|
|
111
|
+
{get = function(self)
|
|
112
|
+
Unit:getSelectionOf(Player["local"], localSelectedUnits)
|
|
113
|
+
for i = 1, #localSelectedUnits do
|
|
114
|
+
indexByLocalSelectedUnit[localSelectedUnits[i]] = i
|
|
115
|
+
end
|
|
116
|
+
tableSort(localSelectedUnits, compareUnitsSelectionPriority)
|
|
117
|
+
local mainSelectedUnitIndex
|
|
118
|
+
if selectionButtons and #localSelectedUnits > 1 then
|
|
119
|
+
local maxButtonWidth = 0
|
|
120
|
+
for i = 0, #selectionButtons - 1 do
|
|
121
|
+
local width = selectionButtons[i + 1].width
|
|
122
|
+
if width > maxButtonWidth then
|
|
123
|
+
maxButtonWidth = width
|
|
124
|
+
mainSelectedUnitIndex = i
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
local mainSelectedUnit = localSelectedUnits[(mainSelectedUnitIndex or 0) + 1]
|
|
129
|
+
for i = 1, #localSelectedUnits do
|
|
130
|
+
indexByLocalSelectedUnit[localSelectedUnits[i]] = nil
|
|
131
|
+
localSelectedUnits[i] = nil
|
|
132
|
+
end
|
|
133
|
+
if mainSelectedUnitChangeEvent ~= nil and mainSelectedUnit ~= previousMainSelectedUnit then
|
|
134
|
+
Event.invoke(mainSelectedUnitChangeEvent, previousMainSelectedUnit, mainSelectedUnit)
|
|
135
|
+
previousMainSelectedUnit = mainSelectedUnit
|
|
136
|
+
end
|
|
137
|
+
return mainSelectedUnit
|
|
138
|
+
end}
|
|
139
|
+
)
|
|
140
|
+
__TS__ObjectDefineProperty(
|
|
141
|
+
LocalClient,
|
|
142
|
+
"mainSelectedUnitChangeEvent",
|
|
143
|
+
{get = function(self)
|
|
144
|
+
if mainSelectedUnitChangeEvent == nil then
|
|
145
|
+
mainSelectedUnitChangeEvent = __TS__New(Event)
|
|
146
|
+
Timer.onPeriod[1 / 64]:addListener(function()
|
|
147
|
+
local _ = ____exports.LocalClient.mainSelectedUnit
|
|
148
|
+
end)
|
|
149
|
+
end
|
|
150
|
+
return mainSelectedUnitChangeEvent
|
|
151
|
+
end}
|
|
152
|
+
)
|
|
72
153
|
LocalClient.onDisconnect = __TS__New(
|
|
73
154
|
TriggerEvent,
|
|
74
155
|
function(trigger)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { AbilityType, AbilityTypeId } from "../ability-type";
|
|
3
|
+
import { ObjectDataEntryLevelFieldValueSupplier } from "../../entry";
|
|
4
|
+
export declare class MineAbilityType extends AbilityType {
|
|
5
|
+
static readonly BASE_ID: AbilityTypeId;
|
|
6
|
+
get activationDelay(): number[];
|
|
7
|
+
set activationDelay(activationDelay: ObjectDataEntryLevelFieldValueSupplier<number>);
|
|
8
|
+
get invisibilityDelay(): number[];
|
|
9
|
+
set invisibilityDelay(invisibilityDelay: ObjectDataEntryLevelFieldValueSupplier<number>);
|
|
10
|
+
}
|