warscript 0.0.1-dev.e4a5fce → 0.0.1-dev.e72b4b0
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 +2 -3
- package/core/types/effect.lua +95 -48
- 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.d.ts +1 -1
- package/core/util.lua +12 -1
- package/decl/native.d.ts +840 -786
- package/engine/behaviour/ability/apply-buff.d.ts +5 -0
- package/engine/behaviour/ability/apply-buff.lua +32 -0
- 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 +20 -8
- package/engine/behaviour/ability/on-command-impact.lua +7 -0
- package/engine/behaviour/ability.d.ts +12 -3
- package/engine/behaviour/ability.lua +67 -8
- package/engine/behaviour/unit.d.ts +24 -0
- package/engine/behaviour/unit.lua +150 -4
- package/engine/buff.d.ts +56 -41
- package/engine/buff.lua +295 -228
- package/engine/internal/ability.d.ts +15 -1
- package/engine/internal/ability.lua +84 -2
- package/engine/internal/item/ability.lua +112 -4
- package/engine/internal/item.d.ts +7 -4
- package/engine/internal/item.lua +131 -28
- 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/object-data/auto-attack-speed-increase.d.ts +1 -1
- package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
- package/engine/internal/object-data/evasion-probability.d.ts +2 -0
- package/engine/internal/object-data/evasion-probability.lua +16 -0
- package/engine/internal/unit/ability.d.ts +35 -0
- package/engine/internal/unit/ability.lua +62 -0
- package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
- package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot.lua +52 -0
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/bonus.d.ts +2 -0
- package/engine/internal/unit/bonus.lua +17 -0
- package/engine/internal/unit/ignore-events-items.d.ts +2 -0
- package/engine/internal/unit/ignore-events-items.lua +5 -0
- package/engine/internal/unit/item.lua +6 -12
- 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 +30 -5
- package/engine/internal/unit.lua +247 -50
- package/engine/internal/utility.lua +12 -0
- package/engine/lightning.d.ts +12 -5
- package/engine/lightning.lua +48 -14
- 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 +89 -33
- 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 +3 -1
- package/engine/object-data/entry/item-type.lua +15 -2
- 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-data/utility/object-data-entry-id-generator.lua +7 -0
- package/engine/object-field/ability.d.ts +6 -3
- package/engine/object-field/ability.lua +3 -0
- package/engine/object-field/unit.d.ts +50 -3
- package/engine/object-field/unit.lua +186 -7
- package/engine/object-field.d.ts +17 -6
- package/engine/object-field.lua +187 -89
- 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/standard/fields/unit.d.ts +3 -0
- package/engine/standard/fields/unit.lua +5 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +175 -10
- package/engine/unit.d.ts +2 -0
- package/engine/unit.lua +2 -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
|
@@ -51,12 +51,19 @@ local ____arrays = require("utility.arrays")
|
|
|
51
51
|
local forEach = ____arrays.forEach
|
|
52
52
|
local ____math = require("math")
|
|
53
53
|
local min = ____math.min
|
|
54
|
+
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
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
|
|
54
63
|
local match = string.match
|
|
55
64
|
local ____tostring = _G.tostring
|
|
56
65
|
local setUnitAnimation = SetUnitAnimation
|
|
57
|
-
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
58
66
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
59
|
-
local queueUnitAnimation = QueueUnitAnimation
|
|
60
67
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
61
68
|
local getUnitRealField = BlzGetUnitRealField
|
|
62
69
|
local getHeroStr = GetHeroStr
|
|
@@ -75,9 +82,9 @@ local setUnitScale = SetUnitScale
|
|
|
75
82
|
local setUnitPosition = SetUnitPosition
|
|
76
83
|
local setUnitTimeScale = SetUnitTimeScale
|
|
77
84
|
local getHandleId = GetHandleId
|
|
85
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
78
86
|
local createUnit = CreateUnit
|
|
79
87
|
local killUnit = KillUnit
|
|
80
|
-
local setUnitExploded = SetUnitExploded
|
|
81
88
|
local removeUnit = RemoveUnit
|
|
82
89
|
local getUnitTypeId = GetUnitTypeId
|
|
83
90
|
local isHeroUnitId = IsHeroUnitId
|
|
@@ -93,8 +100,6 @@ local getSpellTargetItem = GetSpellTargetItem
|
|
|
93
100
|
local getSpellTargetDestructable = GetSpellTargetDestructable
|
|
94
101
|
local isUnitInRangeXY = IsUnitInRangeXY
|
|
95
102
|
local isUnitInRange = IsUnitInRange
|
|
96
|
-
local setResourceAmount = SetResourceAmount
|
|
97
|
-
local getResourceAmount = GetResourceAmount
|
|
98
103
|
local getUnitWeaponRealField = BlzGetUnitWeaponRealField
|
|
99
104
|
local setUnitWeaponRealField = BlzSetUnitWeaponRealField
|
|
100
105
|
local getUnitWeaponStringField = BlzGetUnitWeaponStringField
|
|
@@ -125,8 +130,6 @@ local isUnitType = IsUnitType
|
|
|
125
130
|
local isUnitAlly = IsUnitAlly
|
|
126
131
|
local isUnitEnemy = IsUnitEnemy
|
|
127
132
|
local getOwningPlayer = GetOwningPlayer
|
|
128
|
-
local setUnitColor = SetUnitColor
|
|
129
|
-
local showUnitTeamGlow = BlzShowUnitTeamGlow
|
|
130
133
|
____exports.UnitClassification = {}
|
|
131
134
|
local UnitClassification = ____exports.UnitClassification
|
|
132
135
|
do
|
|
@@ -136,6 +139,7 @@ do
|
|
|
136
139
|
UnitClassification.GROUND = UNIT_TYPE_GROUND
|
|
137
140
|
UnitClassification.SUMMONED = UNIT_TYPE_SUMMONED
|
|
138
141
|
UnitClassification.MECHANICAL = UNIT_TYPE_MECHANICAL
|
|
142
|
+
UnitClassification.WORKER = UNIT_TYPE_PEON
|
|
139
143
|
UnitClassification.ANCIENT = UNIT_TYPE_ANCIENT
|
|
140
144
|
UnitClassification.SUICIDAL = UNIT_TYPE_SAPPER
|
|
141
145
|
UnitClassification.TAUREN = UNIT_TYPE_TAUREN
|
|
@@ -343,6 +347,9 @@ local function dispatchAbility(event)
|
|
|
343
347
|
}
|
|
344
348
|
)
|
|
345
349
|
end
|
|
350
|
+
local function damagingEventPreventRetaliation(self)
|
|
351
|
+
self[0] = true
|
|
352
|
+
end
|
|
346
353
|
local function damageEventPreventDeath(self, callback, ...)
|
|
347
354
|
if self[0] ~= nil then
|
|
348
355
|
return
|
|
@@ -354,7 +361,14 @@ local function damageEventPreventDeath(self, callback, ...)
|
|
|
354
361
|
rawset(self, 1 + i, (select(i, ...)))
|
|
355
362
|
end
|
|
356
363
|
end
|
|
357
|
-
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
|
+
}
|
|
358
372
|
local jlimitopByOperator = {
|
|
359
373
|
[0] = LESS_THAN_OR_EQUAL,
|
|
360
374
|
[1] = LESS_THAN_OR_EQUAL,
|
|
@@ -432,6 +446,19 @@ __TS__SetDescriptor(
|
|
|
432
446
|
},
|
|
433
447
|
true
|
|
434
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
|
+
)
|
|
435
462
|
__TS__SetDescriptor(
|
|
436
463
|
UnitWeapon.prototype,
|
|
437
464
|
"damageBase",
|
|
@@ -636,7 +663,8 @@ local function delayHealthChecksCallback(unit)
|
|
|
636
663
|
end
|
|
637
664
|
end
|
|
638
665
|
local nextSyncId = 1
|
|
639
|
-
local unitBySyncId = setmetatable({}, {__mode = "
|
|
666
|
+
local unitBySyncId = setmetatable({}, {__mode = "v"})
|
|
667
|
+
local damagingEventByTarget = setmetatable({}, {__mode = "k"})
|
|
640
668
|
____exports.Unit = __TS__Class()
|
|
641
669
|
local Unit = ____exports.Unit
|
|
642
670
|
Unit.name = "Unit"
|
|
@@ -677,6 +705,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
677
705
|
end
|
|
678
706
|
function Unit.prototype.onDestroy(self)
|
|
679
707
|
local handle = self.handle
|
|
708
|
+
self[107] = getUnitX(handle)
|
|
709
|
+
self[108] = getUnitY(handle)
|
|
680
710
|
if not self._owner then
|
|
681
711
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
682
712
|
end
|
|
@@ -787,13 +817,25 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
787
817
|
if type(animation) == "number" then
|
|
788
818
|
setUnitAnimationByIndex(self.handle, animation)
|
|
789
819
|
elseif rarity then
|
|
790
|
-
|
|
820
|
+
SetUnitAnimationWithRarity(self.handle, animation, rarity)
|
|
791
821
|
else
|
|
792
822
|
setUnitAnimation(self.handle, animation)
|
|
793
823
|
end
|
|
794
824
|
end
|
|
825
|
+
function Unit.prototype.resetAnimation(self)
|
|
826
|
+
ResetUnitAnimation(self.handle)
|
|
827
|
+
end
|
|
795
828
|
function Unit.prototype.queueAnimation(self, animation)
|
|
796
|
-
|
|
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
|
|
797
839
|
end
|
|
798
840
|
function Unit.prototype.delayHealthChecks(self)
|
|
799
841
|
self[103] = (self[103] or 0) + 1
|
|
@@ -806,7 +848,7 @@ function Unit.prototype.isSelected(self, player)
|
|
|
806
848
|
return IsUnitSelected(self.handle, player.handle)
|
|
807
849
|
end
|
|
808
850
|
function Unit.prototype.explode(self)
|
|
809
|
-
|
|
851
|
+
SetUnitExploded(self.handle, true)
|
|
810
852
|
killUnit(self.handle)
|
|
811
853
|
end
|
|
812
854
|
function Unit.prototype.kill(self)
|
|
@@ -925,12 +967,34 @@ end
|
|
|
925
967
|
function Unit.prototype.endAbilityCooldown(self, abilityId)
|
|
926
968
|
BlzEndUnitAbilityCooldown(self.handle, abilityId)
|
|
927
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
|
|
928
985
|
function Unit.prototype.interruptAttack(self)
|
|
929
986
|
unitInterruptAttack(self.handle)
|
|
930
987
|
end
|
|
931
988
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
932
|
-
|
|
933
|
-
unitDisableAbility(
|
|
989
|
+
local handle = self.handle
|
|
990
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
991
|
+
Timer:run(
|
|
992
|
+
unitDisableAbility,
|
|
993
|
+
handle,
|
|
994
|
+
abilityId,
|
|
995
|
+
false,
|
|
996
|
+
false
|
|
997
|
+
)
|
|
934
998
|
end
|
|
935
999
|
function Unit.prototype.getDistanceTo(self, target)
|
|
936
1000
|
local handle = self.handle
|
|
@@ -1195,6 +1259,14 @@ __TS__SetDescriptor(
|
|
|
1195
1259
|
end},
|
|
1196
1260
|
true
|
|
1197
1261
|
)
|
|
1262
|
+
__TS__SetDescriptor(
|
|
1263
|
+
Unit.prototype,
|
|
1264
|
+
"isStunned",
|
|
1265
|
+
{get = function(self)
|
|
1266
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1267
|
+
end},
|
|
1268
|
+
true
|
|
1269
|
+
)
|
|
1198
1270
|
__TS__SetDescriptor(
|
|
1199
1271
|
Unit.prototype,
|
|
1200
1272
|
"combatClassifications",
|
|
@@ -1268,6 +1340,19 @@ __TS__SetDescriptor(
|
|
|
1268
1340
|
},
|
|
1269
1341
|
true
|
|
1270
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
|
+
)
|
|
1271
1356
|
__TS__SetDescriptor(
|
|
1272
1357
|
Unit.prototype,
|
|
1273
1358
|
"strengthBase",
|
|
@@ -1392,7 +1477,7 @@ __TS__SetDescriptor(
|
|
|
1392
1477
|
return not self[106]
|
|
1393
1478
|
end,
|
|
1394
1479
|
set = function(self, isTeamGlowVisible)
|
|
1395
|
-
|
|
1480
|
+
BlzShowUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1396
1481
|
local ____temp_6
|
|
1397
1482
|
if not isTeamGlowVisible then
|
|
1398
1483
|
____temp_6 = true
|
|
@@ -1408,9 +1493,9 @@ __TS__SetDescriptor(
|
|
|
1408
1493
|
Unit.prototype,
|
|
1409
1494
|
"color",
|
|
1410
1495
|
{set = function(self, color)
|
|
1411
|
-
|
|
1496
|
+
SetUnitColor(self.handle, color.handle)
|
|
1412
1497
|
if self[106] then
|
|
1413
|
-
|
|
1498
|
+
BlzShowUnitTeamGlow(self.handle, false)
|
|
1414
1499
|
end
|
|
1415
1500
|
end},
|
|
1416
1501
|
true
|
|
@@ -1579,7 +1664,7 @@ __TS__SetDescriptor(
|
|
|
1579
1664
|
"x",
|
|
1580
1665
|
{
|
|
1581
1666
|
get = function(self)
|
|
1582
|
-
return getUnitX(self.handle)
|
|
1667
|
+
return self[107] or getUnitX(self.handle)
|
|
1583
1668
|
end,
|
|
1584
1669
|
set = function(self, v)
|
|
1585
1670
|
SetUnitX(self.handle, v)
|
|
@@ -1592,7 +1677,7 @@ __TS__SetDescriptor(
|
|
|
1592
1677
|
"y",
|
|
1593
1678
|
{
|
|
1594
1679
|
get = function(self)
|
|
1595
|
-
return getUnitY(self.handle)
|
|
1680
|
+
return self[108] or getUnitY(self.handle)
|
|
1596
1681
|
end,
|
|
1597
1682
|
set = function(self, v)
|
|
1598
1683
|
SetUnitY(self.handle, v)
|
|
@@ -1678,10 +1763,10 @@ __TS__SetDescriptor(
|
|
|
1678
1763
|
"gold",
|
|
1679
1764
|
{
|
|
1680
1765
|
get = function(self)
|
|
1681
|
-
return
|
|
1766
|
+
return GetResourceAmount(self.handle)
|
|
1682
1767
|
end,
|
|
1683
1768
|
set = function(self, gold)
|
|
1684
|
-
|
|
1769
|
+
SetResourceAmount(self.handle, gold)
|
|
1685
1770
|
end
|
|
1686
1771
|
},
|
|
1687
1772
|
true
|
|
@@ -1809,6 +1894,19 @@ __TS__SetDescriptor(
|
|
|
1809
1894
|
end},
|
|
1810
1895
|
true
|
|
1811
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
|
+
)
|
|
1812
1910
|
__TS__SetDescriptor(
|
|
1813
1911
|
Unit.prototype,
|
|
1814
1912
|
"pathing",
|
|
@@ -1990,6 +2088,14 @@ __TS__SetDescriptor(
|
|
|
1990
2088
|
end},
|
|
1991
2089
|
true
|
|
1992
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
|
+
)
|
|
1993
2099
|
__TS__SetDescriptor(
|
|
1994
2100
|
Unit.prototype,
|
|
1995
2101
|
"onSelect",
|
|
@@ -2315,10 +2421,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2315
2421
|
____exports.UnitTriggerEvent,
|
|
2316
2422
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2317
2423
|
function()
|
|
2318
|
-
local
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2424
|
+
local handle = getOrderedUnit()
|
|
2425
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2426
|
+
local unit = ____exports.Unit:of(handle)
|
|
2427
|
+
if unit.state == 1 then
|
|
2428
|
+
return unit, getIssuedOrderId()
|
|
2429
|
+
end
|
|
2322
2430
|
end
|
|
2323
2431
|
return IgnoreEvent
|
|
2324
2432
|
end
|
|
@@ -2349,13 +2457,19 @@ Unit.onDamaging = (function()
|
|
|
2349
2457
|
if source and source.typeId == dummyUnitId then
|
|
2350
2458
|
source = nil
|
|
2351
2459
|
end
|
|
2352
|
-
local target = BlzGetEventDamageTarget()
|
|
2460
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2461
|
+
local metadata = damageMetadataByTarget[target]
|
|
2462
|
+
damageMetadataByTarget[target] = nil
|
|
2353
2463
|
local data = {
|
|
2354
2464
|
amount = GetEventDamage(),
|
|
2355
|
-
attackType = BlzGetEventAttackType(),
|
|
2465
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2356
2466
|
damageType = BlzGetEventDamageType(),
|
|
2357
2467
|
weaponType = BlzGetEventWeaponType(),
|
|
2358
|
-
|
|
2468
|
+
metadata = metadata,
|
|
2469
|
+
isAttack = BlzGetEventIsAttack(),
|
|
2470
|
+
originalAmount = GetEventDamage(),
|
|
2471
|
+
originalMetadata = metadata,
|
|
2472
|
+
preventRetaliation = damagingEventPreventRetaliation
|
|
2359
2473
|
}
|
|
2360
2474
|
if data.isAttack and source then
|
|
2361
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
|
|
@@ -2369,18 +2483,36 @@ Unit.onDamaging = (function()
|
|
|
2369
2483
|
invoke(
|
|
2370
2484
|
event,
|
|
2371
2485
|
source,
|
|
2372
|
-
|
|
2486
|
+
target,
|
|
2373
2487
|
setmetatable(
|
|
2374
2488
|
{},
|
|
2375
2489
|
{
|
|
2376
2490
|
__index = data,
|
|
2377
2491
|
__newindex = function(self, key, value)
|
|
2378
|
-
damageSetters[key]
|
|
2492
|
+
local damageSetter = damageSetters[key]
|
|
2493
|
+
if damageSetter ~= nil then
|
|
2494
|
+
damageSetter(value)
|
|
2495
|
+
end
|
|
2379
2496
|
data[key] = value
|
|
2380
2497
|
end
|
|
2381
2498
|
}
|
|
2382
2499
|
)
|
|
2383
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
|
|
2384
2516
|
return
|
|
2385
2517
|
end
|
|
2386
2518
|
BlzSetEventDamage(0)
|
|
@@ -2388,7 +2520,7 @@ Unit.onDamaging = (function()
|
|
|
2388
2520
|
BlzSetEventDamageType(DAMAGE_TYPE_UNKNOWN)
|
|
2389
2521
|
BlzSetEventWeaponType(WEAPON_TYPE_WHOKNOWS)
|
|
2390
2522
|
local sourceOwner = source.owner.handle
|
|
2391
|
-
local targetOwner =
|
|
2523
|
+
local targetOwner = target.owner.handle
|
|
2392
2524
|
if not GetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE) then
|
|
2393
2525
|
SetPlayerAlliance(sourceOwner, targetOwner, ALLIANCE_PASSIVE, true)
|
|
2394
2526
|
Timer:run(function()
|
|
@@ -2404,23 +2536,19 @@ Unit.onDamaging = (function()
|
|
|
2404
2536
|
for ____, ____value in ipairs(source._attackHandlers) do
|
|
2405
2537
|
local condition = ____value[1]
|
|
2406
2538
|
local action = ____value[2]
|
|
2407
|
-
if condition(
|
|
2408
|
-
source,
|
|
2409
|
-
____exports.Unit:of(target),
|
|
2410
|
-
data
|
|
2411
|
-
) then
|
|
2539
|
+
if condition(source, target, data) then
|
|
2412
2540
|
action(
|
|
2413
2541
|
source,
|
|
2414
|
-
|
|
2542
|
+
target,
|
|
2415
2543
|
setmetatable(
|
|
2416
2544
|
{fire = function()
|
|
2417
2545
|
UnitDamageTarget(
|
|
2418
2546
|
source.handle,
|
|
2419
|
-
target,
|
|
2547
|
+
target.handle,
|
|
2420
2548
|
data.amount,
|
|
2421
2549
|
true,
|
|
2422
2550
|
true,
|
|
2423
|
-
data.attackType,
|
|
2551
|
+
attackTypeToNative(data.attackType),
|
|
2424
2552
|
data.damageType,
|
|
2425
2553
|
data.weaponType
|
|
2426
2554
|
)
|
|
@@ -2447,26 +2575,50 @@ Unit.onDamage = __TS__New(
|
|
|
2447
2575
|
if source and source.typeId == dummyUnitId then
|
|
2448
2576
|
source = nil
|
|
2449
2577
|
end
|
|
2578
|
+
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2579
|
+
local damagingEvent = damagingEventByTarget[target]
|
|
2580
|
+
damagingEventByTarget[target] = nil
|
|
2450
2581
|
local data = {
|
|
2451
2582
|
amount = GetEventDamage(),
|
|
2452
|
-
attackType = BlzGetEventAttackType(),
|
|
2583
|
+
attackType = nativeToAttackType(BlzGetEventAttackType()),
|
|
2453
2584
|
damageType = BlzGetEventDamageType(),
|
|
2454
2585
|
weaponType = BlzGetEventWeaponType(),
|
|
2586
|
+
metadata = damagingEvent and damagingEvent.metadata,
|
|
2455
2587
|
isAttack = BlzGetEventIsAttack(),
|
|
2456
|
-
originalAmount = GetEventDamage(),
|
|
2588
|
+
originalAmount = damagingEvent and damagingEvent.originalAmount or GetEventDamage(),
|
|
2589
|
+
originalMetadata = damagingEvent and damagingEvent.originalMetadata,
|
|
2457
2590
|
preventDeath = damageEventPreventDeath
|
|
2458
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
|
|
2459
2609
|
local evData = setmetatable(
|
|
2460
2610
|
{},
|
|
2461
2611
|
{
|
|
2462
2612
|
__index = data,
|
|
2463
2613
|
__newindex = function(self, key, value)
|
|
2464
|
-
damageSetters[key]
|
|
2614
|
+
local damageSetter = damageSetters[key]
|
|
2615
|
+
if damageSetter ~= nil then
|
|
2616
|
+
damageSetter(value)
|
|
2617
|
+
end
|
|
2465
2618
|
data[key] = value
|
|
2466
2619
|
end
|
|
2467
2620
|
}
|
|
2468
2621
|
)
|
|
2469
|
-
local target = ____exports.Unit:of(BlzGetEventDamageTarget())
|
|
2470
2622
|
invoke(event, source, target, evData)
|
|
2471
2623
|
if evData[0] ~= nil and target.health - evData.amount < 0.405 then
|
|
2472
2624
|
local bonusHealth = math.ceil(evData.amount)
|
|
@@ -2509,8 +2661,9 @@ Unit.itemDroppedEvent = __TS__New(
|
|
|
2509
2661
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2510
2662
|
function()
|
|
2511
2663
|
local unit = getTriggerUnit()
|
|
2512
|
-
|
|
2513
|
-
|
|
2664
|
+
local item = getManipulatedItem()
|
|
2665
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2666
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2514
2667
|
end
|
|
2515
2668
|
return IgnoreEvent
|
|
2516
2669
|
end
|
|
@@ -2520,8 +2673,9 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2520
2673
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2521
2674
|
function()
|
|
2522
2675
|
local unit = getTriggerUnit()
|
|
2523
|
-
|
|
2524
|
-
|
|
2676
|
+
local item = getManipulatedItem()
|
|
2677
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2678
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2525
2679
|
end
|
|
2526
2680
|
return IgnoreEvent
|
|
2527
2681
|
end
|
|
@@ -2529,7 +2683,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2529
2683
|
Unit.itemUsedEvent = __TS__New(
|
|
2530
2684
|
____exports.UnitTriggerEvent,
|
|
2531
2685
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2532
|
-
function()
|
|
2686
|
+
function()
|
|
2687
|
+
local unit = getTriggerUnit()
|
|
2688
|
+
local item = getManipulatedItem()
|
|
2689
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2690
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2691
|
+
end
|
|
2692
|
+
return IgnoreEvent
|
|
2693
|
+
end
|
|
2533
2694
|
)
|
|
2534
2695
|
Unit.itemStackedEvent = __TS__New(
|
|
2535
2696
|
____exports.UnitTriggerEvent,
|
|
@@ -2538,7 +2699,43 @@ Unit.itemStackedEvent = __TS__New(
|
|
|
2538
2699
|
)
|
|
2539
2700
|
__TS__ObjectDefineProperty(
|
|
2540
2701
|
Unit,
|
|
2541
|
-
"
|
|
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
|
+
)
|
|
2715
|
+
__TS__ObjectDefineProperty(
|
|
2716
|
+
Unit,
|
|
2717
|
+
"itemUseOrderEvent",
|
|
2718
|
+
{get = function(self)
|
|
2719
|
+
local event = __TS__New(Event)
|
|
2720
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2721
|
+
local slot = order - orderId("useslot0")
|
|
2722
|
+
local function listener(unit)
|
|
2723
|
+
local item = unit.items[slot + 1]
|
|
2724
|
+
if item ~= nil then
|
|
2725
|
+
invoke(event, unit, item)
|
|
2726
|
+
end
|
|
2727
|
+
end
|
|
2728
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2729
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2730
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2731
|
+
end
|
|
2732
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2733
|
+
return event
|
|
2734
|
+
end}
|
|
2735
|
+
)
|
|
2736
|
+
__TS__ObjectDefineProperty(
|
|
2737
|
+
Unit,
|
|
2738
|
+
"itemMoveOrderEvent",
|
|
2542
2739
|
{get = function(self)
|
|
2543
2740
|
local event = __TS__New(Event)
|
|
2544
2741
|
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
@@ -2556,7 +2753,7 @@ __TS__ObjectDefineProperty(
|
|
|
2556
2753
|
end
|
|
2557
2754
|
end)
|
|
2558
2755
|
end
|
|
2559
|
-
rawset(self, "
|
|
2756
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2560
2757
|
return event
|
|
2561
2758
|
end}
|
|
2562
2759
|
)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
2
|
local getUnitAbility = BlzGetUnitAbility
|
|
3
3
|
local unitAddAbility = UnitAddAbility
|
|
4
|
+
local unitInventorySize = UnitInventorySize
|
|
5
|
+
local unitItemInSlot = UnitItemInSlot
|
|
4
6
|
local unitMakeAbilityPermanent = UnitMakeAbilityPermanent
|
|
5
7
|
---
|
|
6
8
|
-- @internal For use by internal systems only.
|
|
@@ -10,4 +12,14 @@ ____exports.addInternalAbility = function(unit, abilityTypeId)
|
|
|
10
12
|
end
|
|
11
13
|
return getUnitAbility(unit, abilityTypeId)
|
|
12
14
|
end
|
|
15
|
+
---
|
|
16
|
+
-- @internal For use by internal systems only.
|
|
17
|
+
____exports.findUnitItemSlot = function(unit, item)
|
|
18
|
+
for slot = 0, unitInventorySize(unit) - 1 do
|
|
19
|
+
if item == unitItemInSlot(unit, slot) then
|
|
20
|
+
return slot
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
return nil
|
|
24
|
+
end
|
|
13
25
|
return ____exports
|
package/engine/lightning.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { LightningTypeId } from "./object-data/entry/lightning-type";
|
|
3
|
-
import { Handle, HandleDestructor } from "../core/types/handle";
|
|
4
3
|
import { Unit } from "../core/types/unit";
|
|
4
|
+
import { AbstractDestroyable, Destructor } from "../destroyable";
|
|
5
5
|
declare const enum LightningPropertyKey {
|
|
6
6
|
CHECK_VISIBILITY = 100,
|
|
7
7
|
SOURCE_UNIT = 101,
|
|
@@ -12,10 +12,12 @@ declare const enum LightningPropertyKey {
|
|
|
12
12
|
TARGET_X = 106,
|
|
13
13
|
TARGET_Y = 107,
|
|
14
14
|
TARGET_Z = 108,
|
|
15
|
-
DURATION = 109
|
|
15
|
+
DURATION = 109,
|
|
16
|
+
FADING = 110
|
|
16
17
|
}
|
|
17
18
|
export type LightningConstructor<T extends Lightning> = typeof Lightning & (new (handle: jlightning, typeId: LightningTypeId) => T);
|
|
18
|
-
export declare class Lightning extends
|
|
19
|
+
export declare class Lightning extends AbstractDestroyable {
|
|
20
|
+
readonly handle: jlightning;
|
|
19
21
|
readonly typeId: LightningTypeId;
|
|
20
22
|
private [LightningPropertyKey.CHECK_VISIBILITY]?;
|
|
21
23
|
private [LightningPropertyKey.SOURCE_UNIT]?;
|
|
@@ -27,8 +29,9 @@ export declare class Lightning extends Handle<jlightning> {
|
|
|
27
29
|
private [LightningPropertyKey.TARGET_Y]?;
|
|
28
30
|
private [LightningPropertyKey.TARGET_Z]?;
|
|
29
31
|
private [LightningPropertyKey.DURATION]?;
|
|
32
|
+
private [LightningPropertyKey.FADING]?;
|
|
30
33
|
constructor(handle: jlightning, typeId: LightningTypeId);
|
|
31
|
-
protected onDestroy():
|
|
34
|
+
protected onDestroy(): Destructor;
|
|
32
35
|
static create<T extends Lightning>(this: LightningConstructor<T>, typeId: LightningTypeId, ...parameters: [
|
|
33
36
|
...checkVisibility: [boolean] | [],
|
|
34
37
|
...sourceAndTarget: [sourceX: number, sourceY: number, targetX: number, targetY: number] | [
|
|
@@ -46,6 +49,10 @@ export declare class Lightning extends Handle<jlightning> {
|
|
|
46
49
|
target: Unit
|
|
47
50
|
]
|
|
48
51
|
]): T;
|
|
49
|
-
static flash(...parameters: [
|
|
52
|
+
static flash(...parameters: [
|
|
53
|
+
...parameters: Parameters<(typeof Lightning)["create"]>,
|
|
54
|
+
duration: number,
|
|
55
|
+
fading?: boolean
|
|
56
|
+
]): void;
|
|
50
57
|
}
|
|
51
58
|
export {};
|