warscript 0.0.1-dev.46a1ede → 0.0.1-dev.475a555
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 +5 -0
- package/attributes.lua +8 -1
- package/config.d.ts +5 -0
- package/config.lua +10 -0
- package/core/types/effect.d.ts +1 -3
- package/core/types/effect.lua +26 -29
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/timer.d.ts +6 -7
- package/core/types/timer.lua +18 -21
- package/core/util.lua +6 -1
- package/decl/native.d.ts +840 -786
- package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
- package/engine/behaviour/ability/damage.d.ts +9 -3
- package/engine/behaviour/ability/damage.lua +26 -38
- package/engine/behaviour/ability/emulate-impact.lua +16 -2
- package/engine/behaviour/ability.d.ts +5 -1
- package/engine/behaviour/ability.lua +19 -5
- package/engine/behaviour/unit.d.ts +17 -0
- package/engine/behaviour/unit.lua +114 -4
- package/engine/buff.d.ts +15 -7
- package/engine/buff.lua +145 -104
- package/engine/internal/ability.d.ts +4 -0
- package/engine/internal/ability.lua +17 -0
- package/engine/internal/item/ability.lua +12 -10
- package/engine/internal/item.d.ts +5 -2
- package/engine/internal/item.lua +75 -3
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
- package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
- package/engine/internal/unit/ability.d.ts +5 -0
- package/engine/internal/unit/ability.lua +14 -0
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit+damage.d.ts +2 -11
- package/engine/internal/unit+damage.lua +10 -14
- package/engine/internal/unit+spellSteal.lua +1 -2
- package/engine/internal/unit-missile-launch.lua +1 -1
- package/engine/internal/unit.d.ts +27 -4
- package/engine/internal/unit.lua +184 -37
- package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
- package/engine/object-data/auxiliary/animation-name.lua +16 -0
- package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
- package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
- package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
- package/engine/object-data/auxiliary/attack-type.lua +42 -0
- package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
- package/engine/object-data/auxiliary/movement-type.lua +22 -0
- package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
- package/engine/object-data/auxiliary/sound-eax.lua +2 -0
- package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
- package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
- package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
- package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
- package/engine/object-data/entry/ability-type/berserk.lua +13 -0
- package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
- package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
- package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
- package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
- package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
- package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
- package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
- package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
- package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
- package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
- package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
- package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
- package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
- package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
- package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
- package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
- package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
- package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
- package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
- package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
- package/engine/object-data/entry/ability-type/web.d.ts +12 -0
- package/engine/object-data/entry/ability-type/web.lua +52 -0
- package/engine/object-data/entry/ability-type.d.ts +19 -17
- package/engine/object-data/entry/ability-type.lua +81 -21
- package/engine/object-data/entry/buff-type/applicable.lua +18 -37
- package/engine/object-data/entry/buff-type.d.ts +6 -12
- package/engine/object-data/entry/buff-type.lua +13 -29
- package/engine/object-data/entry/destructible-type.d.ts +1 -1
- package/engine/object-data/entry/item-type.d.ts +1 -1
- package/engine/object-data/entry/item-type.lua +4 -4
- package/engine/object-data/entry/lightning-type.d.ts +1 -1
- package/engine/object-data/entry/sound-preset.d.ts +33 -0
- package/engine/object-data/entry/sound-preset.lua +140 -0
- package/engine/object-data/entry/unit-type.d.ts +10 -3
- package/engine/object-data/entry/unit-type.lua +155 -92
- package/engine/object-data/entry/upgrade.d.ts +1 -1
- package/engine/object-data/entry/upgrade.lua +4 -4
- package/engine/object-data/entry.d.ts +16 -14
- package/engine/object-data/entry.lua +60 -32
- package/engine/object-field/ability.d.ts +1 -1
- package/engine/object-field/unit.d.ts +46 -3
- package/engine/object-field/unit.lua +173 -7
- package/engine/object-field.d.ts +15 -4
- package/engine/object-field.lua +184 -90
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- package/engine/standard/entries/sound-preset.d.ts +10 -0
- package/engine/standard/entries/sound-preset.lua +10 -0
- package/engine/text-tag.d.ts +12 -1
- package/engine/text-tag.lua +44 -10
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/objutil/buff.lua +1 -2
- package/objutil/unit.lua +8 -0
- package/package.json +2 -2
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +3 -0
- package/utility/functions.d.ts +1 -0
- package/utility/functions.lua +1 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +3 -0
- package/utility/lua-maps.d.ts +4 -0
- package/utility/lua-maps.lua +20 -0
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +3 -0
- package/utility/reflection.lua +11 -7
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
package/engine/internal/unit.lua
CHANGED
|
@@ -53,12 +53,17 @@ local ____math = require("math")
|
|
|
53
53
|
local min = ____math.min
|
|
54
54
|
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
55
55
|
local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
56
|
+
local ____attack_2Dtype = require("engine.object-data.auxiliary.attack-type")
|
|
57
|
+
local attackTypeToNative = ____attack_2Dtype.attackTypeToNative
|
|
58
|
+
local nativeToAttackType = ____attack_2Dtype.nativeToAttackType
|
|
59
|
+
local ____damage_2Dmetadata_2Dby_2Dtarget = require("engine.internal.misc.damage-metadata-by-target")
|
|
60
|
+
local damageMetadataByTarget = ____damage_2Dmetadata_2Dby_2Dtarget.damageMetadataByTarget
|
|
61
|
+
local ____attributes = require("attributes")
|
|
62
|
+
local isAttribute = ____attributes.isAttribute
|
|
56
63
|
local match = string.match
|
|
57
64
|
local ____tostring = _G.tostring
|
|
58
65
|
local setUnitAnimation = SetUnitAnimation
|
|
59
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
60
66
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
61
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
62
67
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
63
68
|
local getUnitRealField = BlzGetUnitRealField
|
|
64
69
|
local getHeroStr = GetHeroStr
|
|
@@ -80,7 +85,6 @@ local getHandleId = GetHandleId
|
|
|
80
85
|
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
81
86
|
local createUnit = CreateUnit
|
|
82
87
|
local killUnit = KillUnit
|
|
83
|
-
local setUnitExploded = SetUnitExploded
|
|
84
88
|
local removeUnit = RemoveUnit
|
|
85
89
|
local getUnitTypeId = GetUnitTypeId
|
|
86
90
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -96,8 +100,6 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
96
100
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
97
101
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
98
102
|
local isUnitInRange = IsUnitInRange
|
|
99
|
-
local setResourceAmount = SetResourceAmount
|
|
100
|
-
local getResourceAmount = GetResourceAmount
|
|
101
103
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
102
104
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
103
105
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
@@ -128,8 +130,6 @@ local isUnitType = IsUnitType
|
|
|
128
130
|
local isUnitAlly = IsUnitAlly
|
|
129
131
|
local isUnitEnemy = IsUnitEnemy
|
|
130
132
|
local getOwningPlayer = GetOwningPlayer
|
|
131
|
-
local setUnitColor = SetUnitColor
|
|
132
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
133
133
|
____exports.UnitClassification = {}
|
|
134
134
|
local UnitClassification = ____exports.UnitClassification
|
|
135
135
|
do
|
|
@@ -139,6 +139,7 @@ do
|
|
|
139
139
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
140
140
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
141
141
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
142
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
142
143
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
143
144
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
144
145
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -346,6 +347,9 @@ local function dispatchAbility(event)
|
|
|
346
347
|
}
|
|
347
348
|
)
|
|
348
349
|
end
|
|
350
|
+
local function damagingEventPreventRetaliation(self)
|
|
351
|
+
self[0] = true
|
|
352
|
+
end
|
|
349
353
|
local function damageEventPreventDeath(self, callback, ...)
|
|
350
354
|
if self[0] ~= nil then
|
|
351
355
|
return
|
|
@@ -357,7 +361,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
357
361
|
rawset(self, 1 + i, (select(i, ...)))
|
|
358
362
|
end
|
|
359
363
|
end
|
|
360
|
-
local damageSetters = {
|
|
364
|
+
local damageSetters = {
|
|
365
|
+
amount = BlzSetEventDamage,
|
|
366
|
+
attackType = function(attackType)
|
|
367
|
+
return BlzSetEventAttackType(attackTypeToNative(attackType))
|
|
368
|
+
end,
|
|
369
|
+
damageType = BlzSetEventDamageType,
|
|
370
|
+
weaponType = BlzSetEventWeaponType
|
|
371
|
+
}
|
|
361
372
|
local jlimitopByOperator = {
|
|
362
373
|
[0] = LESS_THAN_OR_EQUAL,
|
|
363
374
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -435,6 +446,19 @@ __TS__SetDescriptor(
|
|
|
435
446
|
},
|
|
436
447
|
true
|
|
437
448
|
)
|
|
449
|
+
__TS__SetDescriptor(
|
|
450
|
+
UnitWeapon.prototype,
|
|
451
|
+
"allowedTargetCombatClassifications",
|
|
452
|
+
{
|
|
453
|
+
get = function(self)
|
|
454
|
+
return BlzGetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index)
|
|
455
|
+
end,
|
|
456
|
+
set = function(self, allowedTargetCombatClassifications)
|
|
457
|
+
BlzSetUnitWeaponIntegerField(self.unit.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, self.index, allowedTargetCombatClassifications)
|
|
458
|
+
end
|
|
459
|
+
},
|
|
460
|
+
true
|
|
461
|
+
)
|
|
438
462
|
__TS__SetDescriptor(
|
|
439
463
|
UnitWeapon.prototype,
|
|
440
464
|
"damageBase",
|
|
@@ -639,7 +663,8 @@ local function delayHealthChecksCallback(unit)
|
|
|
639
663
|
end
|
|
640
664
|
end
|
|
641
665
|
local nextSyncId = 1
|
|
642
|
-
local unitBySyncId = setmetatable({}, {__mode = "
|
|
666
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
667
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
643
668
|
____exports.Unit = __TS__Class()
|
|
644
669
|
local Unit = ____exports.Unit
|
|
645
670
|
Unit.name = "Unit"
|
|
@@ -680,6 +705,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
680
705
|
end
|
|
681
706
|
function Unit.prototype.onDestroy(self)
|
|
682
707
|
local handle = self.handle
|
|
708
|
+
self[107] = getUnitX(handle)
|
|
709
|
+
self[108] = getUnitY(handle)
|
|
683
710
|
if not self._owner then
|
|
684
711
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
685
712
|
end
|
|
@@ -790,13 +817,25 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
790
817
|
if type(animation) == "number" then
|
|
791
818
|
setUnitAnimationByIndex(self.handle, animation)
|
|
792
819
|
elseif rarity then
|
|
793
|
-
|
|
820
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
794
821
|
else
|
|
795
822
|
setUnitAnimation(self.handle, animation)
|
|
796
823
|
end
|
|
797
824
|
end
|
|
825
|
+
function Unit.prototype.resetAnimation(self)
|
|
826
|
+
ResetUnitAnimation(self.handle)
|
|
827
|
+
end
|
|
798
828
|
function Unit.prototype.queueAnimation(self, animation)
|
|
799
|
-
|
|
829
|
+
QueueUnitAnimation(self.handle, animation)
|
|
830
|
+
end
|
|
831
|
+
function Unit.prototype.chooseWeapon(self, target)
|
|
832
|
+
if target:isAllowedTarget(self, self.firstWeapon.allowedTargetCombatClassifications) then
|
|
833
|
+
return self.firstWeapon
|
|
834
|
+
end
|
|
835
|
+
if target:isAllowedTarget(target, self.secondWeapon.allowedTargetCombatClassifications) then
|
|
836
|
+
return self.secondWeapon
|
|
837
|
+
end
|
|
838
|
+
return nil
|
|
800
839
|
end
|
|
801
840
|
function Unit.prototype.delayHealthChecks(self)
|
|
802
841
|
self[103] = (self[103] or 0) + 1
|
|
@@ -809,7 +848,7 @@ function Unit.prototype.isSelected(self, player)
|
|
|
809
848
|
return IsUnitSelected(self.handle, player.handle)
|
|
810
849
|
end
|
|
811
850
|
function Unit.prototype.explode(self)
|
|
812
|
-
|
|
851
|
+
SetUnitExploded(self.handle, true)
|
|
813
852
|
killUnit(self.handle)
|
|
814
853
|
end
|
|
815
854
|
function Unit.prototype.kill(self)
|
|
@@ -928,6 +967,21 @@ end
|
|
|
928
967
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
929
968
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
930
969
|
end
|
|
970
|
+
function Unit.prototype.interruptMovement(self)
|
|
971
|
+
local handle = self.handle
|
|
972
|
+
unitDisableAbility(
|
|
973
|
+
handle,
|
|
974
|
+
fourCC("Amov"),
|
|
975
|
+
true,
|
|
976
|
+
false
|
|
977
|
+
)
|
|
978
|
+
unitDisableAbility(
|
|
979
|
+
handle,
|
|
980
|
+
fourCC("Amov"),
|
|
981
|
+
false,
|
|
982
|
+
false
|
|
983
|
+
)
|
|
984
|
+
end
|
|
931
985
|
function Unit.prototype.interruptAttack(self)
|
|
932
986
|
unitInterruptAttack(self.handle)
|
|
933
987
|
end
|
|
@@ -1286,6 +1340,19 @@ __TS__SetDescriptor(
|
|
|
1286
1340
|
},
|
|
1287
1341
|
true
|
|
1288
1342
|
)
|
|
1343
|
+
__TS__SetDescriptor(
|
|
1344
|
+
Unit.prototype,
|
|
1345
|
+
"primaryAttribute",
|
|
1346
|
+
{
|
|
1347
|
+
get = function(self)
|
|
1348
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1349
|
+
end,
|
|
1350
|
+
set = function(self, primaryAttribute)
|
|
1351
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1352
|
+
end
|
|
1353
|
+
},
|
|
1354
|
+
true
|
|
1355
|
+
)
|
|
1289
1356
|
__TS__SetDescriptor(
|
|
1290
1357
|
Unit.prototype,
|
|
1291
1358
|
"strengthBase",
|
|
@@ -1410,7 +1477,7 @@ __TS__SetDescriptor(
|
|
|
1410
1477
|
return not self[106]
|
|
1411
1478
|
end,
|
|
1412
1479
|
set = function(self, isTeamGlowVisible)
|
|
1413
|
-
|
|
1480
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1414
1481
|
local ____temp_6
|
|
1415
1482
|
if not isTeamGlowVisible then
|
|
1416
1483
|
____temp_6 = true
|
|
@@ -1426,9 +1493,9 @@ __TS__SetDescriptor(
|
|
|
1426
1493
|
Unit.prototype,
|
|
1427
1494
|
"color",
|
|
1428
1495
|
{set = function(self, color)
|
|
1429
|
-
|
|
1496
|
+
SetUnitColor(self.handle, color.handle)
|
|
1430
1497
|
if self[106] then
|
|
1431
|
-
|
|
1498
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1432
1499
|
end
|
|
1433
1500
|
end},
|
|
1434
1501
|
true
|
|
@@ -1597,7 +1664,7 @@ __TS__SetDescriptor(
|
|
|
1597
1664
|
"x",
|
|
1598
1665
|
{
|
|
1599
1666
|
get = function(self)
|
|
1600
|
-
return getUnitX(self.handle)
|
|
1667
|
+
return self[107] or getUnitX(self.handle)
|
|
1601
1668
|
end,
|
|
1602
1669
|
set = function(self, v)
|
|
1603
1670
|
SetUnitX(self.handle, v)
|
|
@@ -1610,7 +1677,7 @@ __TS__SetDescriptor(
|
|
|
1610
1677
|
"y",
|
|
1611
1678
|
{
|
|
1612
1679
|
get = function(self)
|
|
1613
|
-
return getUnitY(self.handle)
|
|
1680
|
+
return self[108] or getUnitY(self.handle)
|
|
1614
1681
|
end,
|
|
1615
1682
|
set = function(self, v)
|
|
1616
1683
|
SetUnitY(self.handle, v)
|
|
@@ -1696,10 +1763,10 @@ __TS__SetDescriptor(
|
|
|
1696
1763
|
"gold",
|
|
1697
1764
|
{
|
|
1698
1765
|
get = function(self)
|
|
1699
|
-
return
|
|
1766
|
+
return GetResourceAmount(self.handle)
|
|
1700
1767
|
end,
|
|
1701
1768
|
set = function(self, gold)
|
|
1702
|
-
|
|
1769
|
+
SetResourceAmount(self.handle, gold)
|
|
1703
1770
|
end
|
|
1704
1771
|
},
|
|
1705
1772
|
true
|
|
@@ -1827,6 +1894,19 @@ __TS__SetDescriptor(
|
|
|
1827
1894
|
end},
|
|
1828
1895
|
true
|
|
1829
1896
|
)
|
|
1897
|
+
__TS__SetDescriptor(
|
|
1898
|
+
Unit.prototype,
|
|
1899
|
+
"movementType",
|
|
1900
|
+
{
|
|
1901
|
+
get = function(self)
|
|
1902
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1903
|
+
end,
|
|
1904
|
+
set = function(self, movementType)
|
|
1905
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1906
|
+
end
|
|
1907
|
+
},
|
|
1908
|
+
true
|
|
1909
|
+
)
|
|
1830
1910
|
__TS__SetDescriptor(
|
|
1831
1911
|
Unit.prototype,
|
|
1832
1912
|
"pathing",
|
|
@@ -2008,6 +2088,14 @@ __TS__SetDescriptor(
|
|
|
2008
2088
|
end},
|
|
2009
2089
|
true
|
|
2010
2090
|
)
|
|
2091
|
+
__TS__SetDescriptor(
|
|
2092
|
+
Unit.prototype,
|
|
2093
|
+
"targetAcquiredEvent",
|
|
2094
|
+
{get = function(self)
|
|
2095
|
+
return self:getEvent(EVENT_UNIT_ACQUIRED_TARGET)
|
|
2096
|
+
end},
|
|
2097
|
+
true
|
|
2098
|
+
)
|
|
2011
2099
|
__TS__SetDescriptor(
|
|
2012
2100
|
Unit.prototype,
|
|
2013
2101
|
"onSelect",
|
|
@@ -2369,13 +2457,19 @@ Unit.onDamaging = (function()
|
|
|
2369
2457
|
if source and source.typeId == dummyUnitId then
|
|
2370
2458
|
source = nil
|
|
2371
2459
|
end
|
|
2372
|
-
local target = BlzGetEventDamageTarget()
|
|
2460
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2461
|
+
local metadata = damageMetadataByTarget[target]
|
|
2462
|
+
damageMetadataByTarget[target] = nil
|
|
2373
2463
|
local data = {
|
|
2374
2464
|
amount = GetEventDamage(),
|
|
2375
|
-
attackType = BlzGetEventAttackType(),
|
|
2465
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2376
2466
|
damageType = BlzGetEventDamageType(),
|
|
2377
2467
|
weaponType = BlzGetEventWeaponType(),
|
|
2378
|
-
|
|
2468
|
+
metadata = metadata,
|
|
2469
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2470
|
+
originalAmount = GetEventDamage(),
|
|
2471
|
+
originalMetadata = metadata,
|
|
2472
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2379
2473
|
}
|
|
2380
2474
|
if data.isAttack and source then
|
|
2381
2475
|
local weapon = BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 1) and (BlzGetUnitWeaponBooleanField(source.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, 0) and -1 or 1) or 0
|
|
@@ -2389,18 +2483,36 @@ Unit.onDamaging = (function()
|
|
|
2389
2483
|
invoke(
|
|
2390
2484
|
event,
|
|
2391
2485
|
source,
|
|
2392
|
-
|
|
2486
|
+
target,
|
|
2393
2487
|
setmetatable(
|
|
2394
2488
|
{},
|
|
2395
2489
|
{
|
|
2396
2490
|
__index = data,
|
|
2397
2491
|
__newindex = function(self, key, value)
|
|
2398
|
-
damageSetters[key]
|
|
2492
|
+
local damageSetter = damageSetters[key]
|
|
2493
|
+
if damageSetter ~= nil then
|
|
2494
|
+
damageSetter(value)
|
|
2495
|
+
end
|
|
2399
2496
|
data[key] = value
|
|
2400
2497
|
end
|
|
2401
2498
|
}
|
|
2402
2499
|
)
|
|
2403
2500
|
)
|
|
2501
|
+
if data[0] and source then
|
|
2502
|
+
local sourceOwner = source.owner.handle
|
|
2503
|
+
data[1] = sourceOwner
|
|
2504
|
+
local targetOwner = target.owner.handle
|
|
2505
|
+
data[2] = targetOwner
|
|
2506
|
+
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2507
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2508
|
+
data[3] = true
|
|
2509
|
+
end
|
|
2510
|
+
if not GetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE) then
|
|
2511
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, true)
|
|
2512
|
+
data[4] = true
|
|
2513
|
+
end
|
|
2514
|
+
end
|
|
2515
|
+
damagingEventByTarget[target] = data
|
|
2404
2516
|
return
|
|
2405
2517
|
end
|
|
2406
2518
|
BlzSetEventDamage(0)
|
|
@@ -2408,7 +2520,7 @@ Unit.onDamaging = (function()
|
|
|
2408
2520
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2409
2521
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2410
2522
|
local sourceOwner = source.owner.handle
|
|
2411
|
-
local targetOwner =
|
|
2523
|
+
local targetOwner = target.owner.handle
|
|
2412
2524
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2413
2525
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2414
2526
|
Timer:run(function()
|
|
@@ -2424,23 +2536,19 @@ Unit.onDamaging = (function()
|
|
|
2424
2536
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2425
2537
|
local condition = ____value[1]
|
|
2426
2538
|
local action = ____value[2]
|
|
2427
|
-
if condition(
|
|
2428
|
-
source,
|
|
2429
|
-
____exports.Unit:of(target),
|
|
2430
|
-
data
|
|
2431
|
-
) then
|
|
2539
|
+
if condition(source, target, data) then
|
|
2432
2540
|
action(
|
|
2433
2541
|
source,
|
|
2434
|
-
|
|
2542
|
+
target,
|
|
2435
2543
|
setmetatable(
|
|
2436
2544
|
{fire = function()
|
|
2437
2545
|
UnitDamageTarget(
|
|
2438
2546
|
source.handle,
|
|
2439
|
-
target,
|
|
2547
|
+
target.handle,
|
|
2440
2548
|
data.amount,
|
|
2441
2549
|
true,
|
|
2442
2550
|
true,
|
|
2443
|
-
data.attackType,
|
|
2551
|
+
attackTypeToNative(data.attackType),
|
|
2444
2552
|
data.damageType,
|
|
2445
2553
|
data.weaponType
|
|
2446
2554
|
)
|
|
@@ -2467,26 +2575,50 @@ Unit.onDamage = __TS__New(
|
|
|
2467
2575
|
if source and source.typeId == dummyUnitId then
|
|
2468
2576
|
source = nil
|
|
2469
2577
|
end
|
|
2578
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2579
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2580
|
+
damagingEventByTarget[target] = nil
|
|
2470
2581
|
local data = {
|
|
2471
2582
|
amount = GetEventDamage(),
|
|
2472
|
-
attackType = BlzGetEventAttackType(),
|
|
2583
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2473
2584
|
damageType = BlzGetEventDamageType(),
|
|
2474
2585
|
weaponType = BlzGetEventWeaponType(),
|
|
2586
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2475
2587
|
isAttack = BlzGetEventIsAttack(),
|
|
2476
|
-
originalAmount = GetEventDamage(),
|
|
2588
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2589
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2477
2590
|
preventDeath = damageEventPreventDeath
|
|
2478
2591
|
}
|
|
2592
|
+
if damagingEvent then
|
|
2593
|
+
for key, value in pairs(damagingEvent) do
|
|
2594
|
+
if isAttribute(key) then
|
|
2595
|
+
data[key] = value
|
|
2596
|
+
end
|
|
2597
|
+
end
|
|
2598
|
+
local sourceOwner = damagingEvent[1]
|
|
2599
|
+
if sourceOwner then
|
|
2600
|
+
local targetOwner = damagingEvent[2]
|
|
2601
|
+
if damagingEvent[3] then
|
|
2602
|
+
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, false)
|
|
2603
|
+
end
|
|
2604
|
+
if damagingEvent[4] then
|
|
2605
|
+
SetPlayerAlliance(targetOwner, sourceOwner, ALLIANCE_PASSIVE, false)
|
|
2606
|
+
end
|
|
2607
|
+
end
|
|
2608
|
+
end
|
|
2479
2609
|
local evData = setmetatable(
|
|
2480
2610
|
{},
|
|
2481
2611
|
{
|
|
2482
2612
|
__index = data,
|
|
2483
2613
|
__newindex = function(self, key, value)
|
|
2484
|
-
damageSetters[key]
|
|
2614
|
+
local damageSetter = damageSetters[key]
|
|
2615
|
+
if damageSetter ~= nil then
|
|
2616
|
+
damageSetter(value)
|
|
2617
|
+
end
|
|
2485
2618
|
data[key] = value
|
|
2486
2619
|
end
|
|
2487
2620
|
}
|
|
2488
2621
|
)
|
|
2489
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2490
2622
|
invoke(event, source, target, evData)
|
|
2491
2623
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2492
2624
|
local bonusHealth = math.ceil(evData.amount)
|
|
@@ -2565,6 +2697,21 @@ Unit.itemStackedEvent = __TS__New(
|
|
|
2565
2697
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2566
2698
|
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2567
2699
|
)
|
|
2700
|
+
__TS__ObjectDefineProperty(
|
|
2701
|
+
Unit,
|
|
2702
|
+
"itemChargesChangedEvent",
|
|
2703
|
+
{get = function(self)
|
|
2704
|
+
local event = __TS__New(Event)
|
|
2705
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2706
|
+
local unit = item.owner
|
|
2707
|
+
if unit ~= nil then
|
|
2708
|
+
invoke(event, unit, item)
|
|
2709
|
+
end
|
|
2710
|
+
end)
|
|
2711
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2712
|
+
return event
|
|
2713
|
+
end}
|
|
2714
|
+
)
|
|
2568
2715
|
__TS__ObjectDefineProperty(
|
|
2569
2716
|
Unit,
|
|
2570
2717
|
"itemUseOrderEvent",
|
|
@@ -1,2 +1,18 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
|
+
local animationNames = {
|
|
3
|
+
attack = true,
|
|
4
|
+
birth = true,
|
|
5
|
+
death = true,
|
|
6
|
+
decay = true,
|
|
7
|
+
dissipate = true,
|
|
8
|
+
morph = true,
|
|
9
|
+
portrait = true,
|
|
10
|
+
sleep = true,
|
|
11
|
+
spell = true,
|
|
12
|
+
stand = true,
|
|
13
|
+
walk = true
|
|
14
|
+
}
|
|
15
|
+
____exports.isAnimationName = function(value)
|
|
16
|
+
return animationNames[value] ~= nil
|
|
17
|
+
end
|
|
2
18
|
return ____exports
|
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
import { ModelNodeName } from "./model-node-name";
|
|
3
3
|
import { ModelNodeQualifier } from "./model-node-qualifier";
|
|
4
4
|
import { Optional } from "../../../utility/types";
|
|
5
|
+
import { EffectParameters } from "../../../core/types/effect";
|
|
5
6
|
export type AttachmentPreset = {
|
|
6
7
|
modelPath: string;
|
|
7
8
|
nodeName: ModelNodeName;
|
|
8
9
|
nodeQualifiers: ModelNodeQualifier[];
|
|
9
10
|
};
|
|
10
|
-
export type
|
|
11
|
-
|
|
11
|
+
export type EffectPresetWithParameters = AttachmentPreset & {
|
|
12
|
+
parameters?: EffectParameters;
|
|
13
|
+
};
|
|
14
|
+
export type AttachmentPresetInput<T extends AttachmentPreset = AttachmentPreset> = Optional<T, "nodeName" | "nodeQualifiers"> | string;
|
|
15
|
+
export type EffectPresetWithParametersInput = AttachmentPresetInput<EffectPresetWithParameters>;
|
|
16
|
+
export declare const toEffectPreset: (effectPresetInput: EffectPresetWithParametersInput) => EffectPresetWithParameters;
|
|
12
17
|
export declare const extractAttachmentPresetInputModelPath: (attachmentPresetInput: AttachmentPresetInput | undefined) => string;
|
|
13
18
|
export declare const extractAttachmentPresetInputNodeFQN: (attachmentPresetInput: AttachmentPresetInput | undefined) => string;
|
|
14
19
|
export declare const splitAttachmentNodeFQN: (attachmentNodeFQN: string) => LuaMultiReturn<[attachmentNodeName: ModelNodeName, attachmentNodeQualifiers: ModelNodeQualifier[]]>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ArrayJoin = ____lualib.__TS__ArrayJoin
|
|
2
3
|
local __TS__StringSplit = ____lualib.__TS__StringSplit
|
|
3
4
|
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
|
|
4
5
|
local ____exports = {}
|
|
5
|
-
____exports.
|
|
6
|
-
return type(
|
|
6
|
+
____exports.toEffectPreset = function(effectPresetInput)
|
|
7
|
+
return type(effectPresetInput) == "string" and ({modelPath = effectPresetInput, nodeName = "origin", nodeQualifiers = {}}) or ({modelPath = effectPresetInput.modelPath, nodeName = effectPresetInput.nodeName or "origin", nodeQualifiers = effectPresetInput.nodeQualifiers or ({}), parameters = effectPresetInput.parameters})
|
|
7
8
|
end
|
|
8
9
|
____exports.extractAttachmentPresetInputModelPath = function(attachmentPresetInput)
|
|
9
10
|
return type(attachmentPresetInput) == "string" and attachmentPresetInput or (attachmentPresetInput and attachmentPresetInput.modelPath or "")
|
|
@@ -12,7 +13,7 @@ ____exports.extractAttachmentPresetInputNodeFQN = function(attachmentPresetInput
|
|
|
12
13
|
if type(attachmentPresetInput) == "string" or attachmentPresetInput == nil then
|
|
13
14
|
return ""
|
|
14
15
|
end
|
|
15
|
-
return
|
|
16
|
+
return __TS__ArrayJoin(
|
|
16
17
|
{
|
|
17
18
|
attachmentPresetInput.nodeName,
|
|
18
19
|
table.unpack(attachmentPresetInput.nodeQualifiers or ({}))
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
export declare const enum AttackType {
|
|
3
|
-
|
|
4
|
-
NORMAL =
|
|
5
|
-
PIERCE =
|
|
6
|
-
SIEGE =
|
|
7
|
-
|
|
8
|
-
CHAOS =
|
|
9
|
-
|
|
10
|
-
HERO = "hero"
|
|
3
|
+
SPELL = 0,
|
|
4
|
+
NORMAL = 1,
|
|
5
|
+
PIERCE = 2,
|
|
6
|
+
SIEGE = 3,
|
|
7
|
+
MAGIC = 4,
|
|
8
|
+
CHAOS = 5,
|
|
9
|
+
HERO = 6
|
|
11
10
|
}
|
|
@@ -1,2 +1,44 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
|
+
local ____records = require("utility.records")
|
|
3
|
+
local invertRecord = ____records.invertRecord
|
|
4
|
+
local stringByAttackType = {
|
|
5
|
+
[1] = "normal",
|
|
6
|
+
[2] = "pierce",
|
|
7
|
+
[3] = "siege",
|
|
8
|
+
[0] = "spells",
|
|
9
|
+
[5] = "chaos",
|
|
10
|
+
[4] = "magic",
|
|
11
|
+
[6] = "hero"
|
|
12
|
+
}
|
|
13
|
+
local attackTypeByString = invertRecord(stringByAttackType)
|
|
14
|
+
local nativeByAttackType = {
|
|
15
|
+
[1] = ATTACK_TYPE_MELEE,
|
|
16
|
+
[2] = ATTACK_TYPE_PIERCE,
|
|
17
|
+
[3] = ATTACK_TYPE_SIEGE,
|
|
18
|
+
[0] = ATTACK_TYPE_NORMAL,
|
|
19
|
+
[5] = ATTACK_TYPE_CHAOS,
|
|
20
|
+
[4] = ATTACK_TYPE_MAGIC,
|
|
21
|
+
[6] = ATTACK_TYPE_HERO
|
|
22
|
+
}
|
|
23
|
+
local attackTypeByNative = invertRecord(nativeByAttackType)
|
|
24
|
+
---
|
|
25
|
+
-- @internal For use by internal systems only.
|
|
26
|
+
____exports.attackTypeToString = function(attackType)
|
|
27
|
+
return attackType ~= nil and stringByAttackType[attackType] or "unknown"
|
|
28
|
+
end
|
|
29
|
+
---
|
|
30
|
+
-- @internal For use by internal systems only.
|
|
31
|
+
____exports.stringToAttackType = function(____string)
|
|
32
|
+
return attackTypeByString[____string]
|
|
33
|
+
end
|
|
34
|
+
---
|
|
35
|
+
-- @internal For use by internal systems only.
|
|
36
|
+
____exports.attackTypeToNative = function(attackType)
|
|
37
|
+
return nativeByAttackType[attackType]
|
|
38
|
+
end
|
|
39
|
+
---
|
|
40
|
+
-- @internal For use by internal systems only.
|
|
41
|
+
____exports.nativeToAttackType = function(attackType)
|
|
42
|
+
return attackTypeByNative[attackType]
|
|
43
|
+
end
|
|
2
44
|
return ____exports
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
export declare const enum MovementType {
|
|
3
|
-
NONE =
|
|
4
|
-
|
|
5
|
-
FLY =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
AMPHIBIOUS =
|
|
3
|
+
NONE = 0,
|
|
4
|
+
FOOT = 1,
|
|
5
|
+
FLY = 2,
|
|
6
|
+
HORSE = 4,
|
|
7
|
+
HOVER = 8,
|
|
8
|
+
FLOAT = 16,
|
|
9
|
+
AMPHIBIOUS = 32
|
|
10
10
|
}
|
|
@@ -1,2 +1,24 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
|
+
local ____records = require("utility.records")
|
|
3
|
+
local invertRecord = ____records.invertRecord
|
|
4
|
+
local stringByMovementType = {
|
|
5
|
+
[0] = "",
|
|
6
|
+
[16] = "float",
|
|
7
|
+
[2] = "fly",
|
|
8
|
+
[1] = "foot",
|
|
9
|
+
[4] = "horse",
|
|
10
|
+
[8] = "hover",
|
|
11
|
+
[32] = "amph"
|
|
12
|
+
}
|
|
13
|
+
local movementTypeByString = invertRecord(stringByMovementType)
|
|
14
|
+
---
|
|
15
|
+
-- @internal For use by internal systems only.
|
|
16
|
+
____exports.movementTypeToString = function(movementType)
|
|
17
|
+
return stringByMovementType[movementType]
|
|
18
|
+
end
|
|
19
|
+
---
|
|
20
|
+
-- @internal For use by internal systems only.
|
|
21
|
+
____exports.stringToMovementType = function(____string)
|
|
22
|
+
return movementTypeByString[____string] or 0
|
|
23
|
+
end
|
|
2
24
|
return ____exports
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
export declare const enum SoundEax {
|
|
3
|
+
DEFAULT = "DefaultEAXON",
|
|
4
|
+
ACKNOWLEDGEMENTS = "HeroAcksEAX",
|
|
5
|
+
ENVIRONMENT = "DoodadsEAX",
|
|
6
|
+
DRUMS = "KotoDrumsEAX",
|
|
7
|
+
ATTACKS = "CombatSoundsEAX",
|
|
8
|
+
ABILITIES = "SpellsEAX",
|
|
9
|
+
MISSILES = "MissilesEAX"
|
|
10
|
+
}
|
|
@@ -12,5 +12,5 @@ export type TechTreeDependency = {
|
|
|
12
12
|
level: number;
|
|
13
13
|
};
|
|
14
14
|
export type TechTreeDependencyInput = TechTreeDependency | UnitTypeId | UpgradeId;
|
|
15
|
-
export declare const extractTechTreeDependencyInputObjectDataEntryId: (techTreeDependencyInput: TechTreeDependencyInput) => ObjectDataEntryId;
|
|
15
|
+
export declare const extractTechTreeDependencyInputObjectDataEntryId: (techTreeDependencyInput: TechTreeDependencyInput) => ObjectDataEntryId & number;
|
|
16
16
|
export declare const extractTechTreeDependencyInputLevel: (techTreeDependencyInput: TechTreeDependencyInput) => number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
____exports.UnitAttribute = UnitAttribute or ({})
|
|
3
|
+
____exports.UnitAttribute.STRENGTH = 1
|
|
4
|
+
____exports.UnitAttribute[____exports.UnitAttribute.STRENGTH] = "STRENGTH"
|
|
5
|
+
____exports.UnitAttribute.INTELLIGENCE = 2
|
|
6
|
+
____exports.UnitAttribute[____exports.UnitAttribute.INTELLIGENCE] = "INTELLIGENCE"
|
|
7
|
+
____exports.UnitAttribute.AGILITY = 3
|
|
8
|
+
____exports.UnitAttribute[____exports.UnitAttribute.AGILITY] = "AGILITY"
|
|
9
|
+
return ____exports
|