warscript 0.0.1-dev.bcab4e5 → 0.0.1-dev.bed79a4
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/core/types/frame.lua +24 -21
- package/core/types/player.lua +3 -1
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +123 -5
- package/core/types/timer.d.ts +2 -1
- package/core/types/timer.lua +21 -2
- package/decl/native.d.ts +6 -4
- package/engine/behavior.d.ts +5 -0
- package/engine/behavior.lua +106 -27
- package/engine/behaviour/ability/apply-buff.lua +1 -1
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +11 -3
- package/engine/behaviour/ability/restore-mana.d.ts +1 -1
- package/engine/behaviour/ability/restore-mana.lua +6 -6
- package/engine/behaviour/ability.lua +8 -17
- package/engine/behaviour/unit/stun-immunity.d.ts +5 -3
- package/engine/behaviour/unit/stun-immunity.lua +43 -27
- package/engine/behaviour/unit.d.ts +26 -2
- package/engine/behaviour/unit.lua +128 -11
- package/engine/buff.d.ts +2 -4
- package/engine/buff.lua +68 -83
- package/engine/internal/ability.d.ts +5 -1
- package/engine/internal/ability.lua +44 -11
- package/engine/internal/item/ability.lua +63 -11
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +4 -4
- package/engine/internal/item.lua +97 -26
- package/engine/internal/misc/frame-coordinates.d.ts +2 -0
- package/engine/internal/misc/frame-coordinates.lua +21 -0
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/misc/player-local-handle.d.ts +2 -0
- package/engine/internal/misc/player-local-handle.lua +5 -0
- package/engine/internal/unit/ability.d.ts +35 -0
- package/engine/internal/unit/ability.lua +63 -1
- 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+ability.lua +10 -1
- package/engine/internal/unit-missile-launch.lua +8 -1
- package/engine/internal/unit.d.ts +7 -6
- package/engine/internal/unit.lua +103 -73
- package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
- package/engine/object-data/auxiliary/armor-type.lua +46 -0
- package/engine/object-data/entry/ability-type.lua +1 -3
- package/engine/object-data/entry/unit-type.d.ts +11 -2
- package/engine/object-data/entry/unit-type.lua +59 -1
- package/engine/object-field/ability.d.ts +3 -3
- package/engine/object-field/ability.lua +7 -6
- package/engine/object-field/unit.d.ts +11 -0
- package/engine/object-field/unit.lua +34 -0
- package/engine/object-field.d.ts +8 -5
- package/engine/object-field.lua +90 -76
- package/engine/standard/fields/unit.d.ts +4 -0
- package/engine/standard/fields/unit.lua +7 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +249 -10
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/package.json +2 -2
- package/patch-lualib.lua +1 -1
- package/utility/callback-array.d.ts +13 -0
- package/utility/callback-array.lua +46 -0
- package/utility/functions.d.ts +7 -0
- package/utility/functions.lua +12 -0
- package/utility/lua-maps.d.ts +1 -0
- package/utility/lua-maps.lua +4 -0
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +4 -0
- package/core/types/order.d.ts +0 -26
- package/core/types/order.lua +0 -65
package/engine/buff.lua
CHANGED
|
@@ -28,9 +28,6 @@ local ____math = require("math")
|
|
|
28
28
|
local max = ____math.max
|
|
29
29
|
local min = ____math.min
|
|
30
30
|
local ____bonus = require("engine.internal.unit.bonus")
|
|
31
|
-
local addOrUpdateOrRemoveUnitBonus = ____bonus.addOrUpdateOrRemoveUnitBonus
|
|
32
|
-
local getUnitBonus = ____bonus.getUnitBonus
|
|
33
|
-
local removeUnitBonus = ____bonus.removeUnitBonus
|
|
34
31
|
local UnitBonusType = ____bonus.UnitBonusType
|
|
35
32
|
local ____area_2Ddamage = require("engine.internal.mechanics.area-damage")
|
|
36
33
|
local damageArea = ____area_2Ddamage.damageArea
|
|
@@ -304,7 +301,8 @@ buffHealingIntervalTimerCallback = function(buff)
|
|
|
304
301
|
source:healTarget(buff[101], healingPerInterval)
|
|
305
302
|
end
|
|
306
303
|
end
|
|
307
|
-
local
|
|
304
|
+
local buffCreatedEvent = __TS__New(Event)
|
|
305
|
+
local buffBeingDestroyedEvent = __TS__New(Event)
|
|
308
306
|
____exports.Buff = __TS__Class()
|
|
309
307
|
local Buff = ____exports.Buff
|
|
310
308
|
Buff.name = "Buff"
|
|
@@ -506,64 +504,52 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
|
|
|
506
504
|
end
|
|
507
505
|
self:onCreate()
|
|
508
506
|
self[100] = 1
|
|
509
|
-
|
|
510
|
-
function Buff.prototype.getUnitBonus(self, bonusType)
|
|
511
|
-
local ____opt_38 = self._bonusIdByBonusType
|
|
512
|
-
local bonusId = ____opt_38 and ____opt_38[bonusType]
|
|
513
|
-
return bonusId == nil and 0 or getUnitBonus(self._unit, bonusType, bonusId)
|
|
514
|
-
end
|
|
515
|
-
function Buff.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
|
|
516
|
-
local bonusIdByBonusType = self._bonusIdByBonusType
|
|
517
|
-
if bonusIdByBonusType == nil then
|
|
518
|
-
bonusIdByBonusType = {}
|
|
519
|
-
self._bonusIdByBonusType = bonusIdByBonusType
|
|
520
|
-
end
|
|
521
|
-
bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self._unit, bonusType, bonusIdByBonusType[bonusType], value)
|
|
507
|
+
Event.invoke(buffCreatedEvent, self)
|
|
522
508
|
end
|
|
523
509
|
function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
|
|
524
510
|
if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
|
|
525
511
|
Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
|
|
526
512
|
else
|
|
527
513
|
local isWidgetProvided = __TS__InstanceOf(widgetOrXOrParametersOrDuration, Unit) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Item) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Destructable)
|
|
528
|
-
local
|
|
529
|
-
local
|
|
530
|
-
local
|
|
514
|
+
local ____Effect_40 = Effect
|
|
515
|
+
local ____Effect_flash_41 = Effect.flash
|
|
516
|
+
local ____array_39 = __TS__SparseArrayNew(
|
|
531
517
|
self[105],
|
|
532
518
|
isWidgetProvided and widgetOrXOrParametersOrDuration or self._unit,
|
|
533
519
|
stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin"
|
|
534
520
|
)
|
|
535
|
-
local
|
|
521
|
+
local ____isWidgetProvided_38
|
|
536
522
|
if isWidgetProvided then
|
|
537
|
-
|
|
523
|
+
____isWidgetProvided_38 = yOrParametersOrDuration
|
|
538
524
|
else
|
|
539
|
-
|
|
525
|
+
____isWidgetProvided_38 = widgetOrXOrParametersOrDuration
|
|
540
526
|
end
|
|
541
|
-
__TS__SparseArrayPush(
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
__TS__SparseArraySpread(
|
|
527
|
+
__TS__SparseArrayPush(____array_39, ____isWidgetProvided_38)
|
|
528
|
+
____Effect_flash_41(
|
|
529
|
+
____Effect_40,
|
|
530
|
+
__TS__SparseArraySpread(____array_39)
|
|
545
531
|
)
|
|
546
532
|
end
|
|
547
533
|
end
|
|
548
534
|
function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
|
|
549
535
|
local isWidgetProvided = type(widgetOrDuration) == "table"
|
|
550
|
-
local
|
|
551
|
-
local
|
|
552
|
-
local
|
|
536
|
+
local ____Effect_44 = Effect
|
|
537
|
+
local ____Effect_flash_45 = Effect.flash
|
|
538
|
+
local ____array_43 = __TS__SparseArrayNew(
|
|
553
539
|
self[106],
|
|
554
540
|
isWidgetProvided and widgetOrDuration or self._unit,
|
|
555
541
|
stringValueByBuffTypeIdByFieldId[fourCC("fspt")][self.typeId] or "origin"
|
|
556
542
|
)
|
|
557
|
-
local
|
|
543
|
+
local ____isWidgetProvided_42
|
|
558
544
|
if isWidgetProvided then
|
|
559
|
-
|
|
545
|
+
____isWidgetProvided_42 = duration
|
|
560
546
|
else
|
|
561
|
-
|
|
547
|
+
____isWidgetProvided_42 = widgetOrDuration
|
|
562
548
|
end
|
|
563
|
-
__TS__SparseArrayPush(
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
__TS__SparseArraySpread(
|
|
549
|
+
__TS__SparseArrayPush(____array_43, ____isWidgetProvided_42)
|
|
550
|
+
____Effect_flash_45(
|
|
551
|
+
____Effect_44,
|
|
552
|
+
__TS__SparseArraySpread(____array_43)
|
|
567
553
|
)
|
|
568
554
|
end
|
|
569
555
|
function Buff.prototype.onCreate(self)
|
|
@@ -614,12 +600,7 @@ function Buff.prototype.onDestroy(self)
|
|
|
614
600
|
unit:removeAbility(abilityTypeId)
|
|
615
601
|
end
|
|
616
602
|
end
|
|
617
|
-
|
|
618
|
-
for bonusType, bonusId in pairs(self._bonusIdByBonusType) do
|
|
619
|
-
removeUnitBonus(unit, bonusType, bonusId)
|
|
620
|
-
end
|
|
621
|
-
end
|
|
622
|
-
Event.invoke(buffDestroyEvent, self)
|
|
603
|
+
Event.invoke(buffBeingDestroyedEvent, self)
|
|
623
604
|
self[100] = 3
|
|
624
605
|
return UnitBehavior.prototype.onDestroy(self)
|
|
625
606
|
end
|
|
@@ -648,8 +629,8 @@ function Buff.apply(self, ...)
|
|
|
648
629
|
end
|
|
649
630
|
end
|
|
650
631
|
function Buff.getByTypeId(self, unit, typeId)
|
|
651
|
-
local
|
|
652
|
-
local buff =
|
|
632
|
+
local ____opt_46 = buffByTypeIdByUnit[unit]
|
|
633
|
+
local buff = ____opt_46 and ____opt_46[typeId]
|
|
653
634
|
if __TS__InstanceOf(buff, self) then
|
|
654
635
|
return buff
|
|
655
636
|
end
|
|
@@ -807,8 +788,8 @@ __TS__SetDescriptor(
|
|
|
807
788
|
return
|
|
808
789
|
end
|
|
809
790
|
self[112] = damageInterval
|
|
810
|
-
local
|
|
811
|
-
local elapsed =
|
|
791
|
+
local ____opt_48 = self._timer
|
|
792
|
+
local elapsed = ____opt_48 and ____opt_48.elapsed or 0
|
|
812
793
|
local timer = self[114]
|
|
813
794
|
if timer == nil then
|
|
814
795
|
timer = Timer:create()
|
|
@@ -887,8 +868,8 @@ __TS__SetDescriptor(
|
|
|
887
868
|
return
|
|
888
869
|
end
|
|
889
870
|
self[117] = healingInterval
|
|
890
|
-
local
|
|
891
|
-
local elapsed =
|
|
871
|
+
local ____opt_50 = self._timer
|
|
872
|
+
local elapsed = ____opt_50 and ____opt_50.elapsed or 0
|
|
892
873
|
local timer = self[119]
|
|
893
874
|
if timer == nil then
|
|
894
875
|
timer = Timer:create()
|
|
@@ -974,11 +955,11 @@ __TS__SetDescriptor(
|
|
|
974
955
|
"turnsIntoGhost",
|
|
975
956
|
{
|
|
976
957
|
get = function(self)
|
|
977
|
-
local
|
|
978
|
-
if
|
|
979
|
-
|
|
958
|
+
local ____self__135_52 = self[135]
|
|
959
|
+
if ____self__135_52 == nil then
|
|
960
|
+
____self__135_52 = false
|
|
980
961
|
end
|
|
981
|
-
return
|
|
962
|
+
return ____self__135_52
|
|
982
963
|
end,
|
|
983
964
|
set = function(self, turnsIntoGhost)
|
|
984
965
|
if not turnsIntoGhost and self[135] then
|
|
@@ -997,11 +978,11 @@ __TS__SetDescriptor(
|
|
|
997
978
|
"stuns",
|
|
998
979
|
{
|
|
999
980
|
get = function(self)
|
|
1000
|
-
local
|
|
1001
|
-
if
|
|
1002
|
-
|
|
981
|
+
local ____self__136_53 = self[136]
|
|
982
|
+
if ____self__136_53 == nil then
|
|
983
|
+
____self__136_53 = false
|
|
1003
984
|
end
|
|
1004
|
-
return
|
|
985
|
+
return ____self__136_53
|
|
1005
986
|
end,
|
|
1006
987
|
set = function(self, stuns)
|
|
1007
988
|
if not stuns and self[136] then
|
|
@@ -1026,11 +1007,11 @@ __TS__SetDescriptor(
|
|
|
1026
1007
|
"ignoresStunImmunity",
|
|
1027
1008
|
{
|
|
1028
1009
|
get = function(self)
|
|
1029
|
-
local
|
|
1030
|
-
if
|
|
1031
|
-
|
|
1010
|
+
local ____self__137_54 = self[137]
|
|
1011
|
+
if ____self__137_54 == nil then
|
|
1012
|
+
____self__137_54 = false
|
|
1032
1013
|
end
|
|
1033
|
-
return
|
|
1014
|
+
return ____self__137_54
|
|
1034
1015
|
end,
|
|
1035
1016
|
set = function(self, ignoresStunImmunity)
|
|
1036
1017
|
if not ignoresStunImmunity and self[137] then
|
|
@@ -1053,11 +1034,11 @@ __TS__SetDescriptor(
|
|
|
1053
1034
|
"disablesAutoAttack",
|
|
1054
1035
|
{
|
|
1055
1036
|
get = function(self)
|
|
1056
|
-
local
|
|
1057
|
-
if
|
|
1058
|
-
|
|
1037
|
+
local ____self__138_55 = self[138]
|
|
1038
|
+
if ____self__138_55 == nil then
|
|
1039
|
+
____self__138_55 = false
|
|
1059
1040
|
end
|
|
1060
|
-
return
|
|
1041
|
+
return ____self__138_55
|
|
1061
1042
|
end,
|
|
1062
1043
|
set = function(self, disablesAutoAttack)
|
|
1063
1044
|
if not disablesAutoAttack and self[138] then
|
|
@@ -1076,11 +1057,11 @@ __TS__SetDescriptor(
|
|
|
1076
1057
|
"providesInvulnerability",
|
|
1077
1058
|
{
|
|
1078
1059
|
get = function(self)
|
|
1079
|
-
local
|
|
1080
|
-
if
|
|
1081
|
-
|
|
1060
|
+
local ____self__139_56 = self[139]
|
|
1061
|
+
if ____self__139_56 == nil then
|
|
1062
|
+
____self__139_56 = false
|
|
1082
1063
|
end
|
|
1083
|
-
return
|
|
1064
|
+
return ____self__139_56
|
|
1084
1065
|
end,
|
|
1085
1066
|
set = function(self, providesInvulnerability)
|
|
1086
1067
|
if not providesInvulnerability and self[139] then
|
|
@@ -1099,11 +1080,11 @@ __TS__SetDescriptor(
|
|
|
1099
1080
|
"killsOnExpiration",
|
|
1100
1081
|
{
|
|
1101
1082
|
get = function(self)
|
|
1102
|
-
local
|
|
1103
|
-
if
|
|
1104
|
-
|
|
1083
|
+
local ____self__140_57 = self[140]
|
|
1084
|
+
if ____self__140_57 == nil then
|
|
1085
|
+
____self__140_57 = false
|
|
1105
1086
|
end
|
|
1106
|
-
return
|
|
1087
|
+
return ____self__140_57
|
|
1107
1088
|
end,
|
|
1108
1089
|
set = function(self, killsOnExpiration)
|
|
1109
1090
|
if not killsOnExpiration and self[140] then
|
|
@@ -1120,11 +1101,11 @@ __TS__SetDescriptor(
|
|
|
1120
1101
|
"explodesOnExpiration",
|
|
1121
1102
|
{
|
|
1122
1103
|
get = function(self)
|
|
1123
|
-
local
|
|
1124
|
-
if
|
|
1125
|
-
|
|
1104
|
+
local ____self__141_58 = self[141]
|
|
1105
|
+
if ____self__141_58 == nil then
|
|
1106
|
+
____self__141_58 = false
|
|
1126
1107
|
end
|
|
1127
|
-
return
|
|
1108
|
+
return ____self__141_58
|
|
1128
1109
|
end,
|
|
1129
1110
|
set = function(self, killsOnExpiration)
|
|
1130
1111
|
if not killsOnExpiration and self[141] then
|
|
@@ -1252,13 +1233,13 @@ __TS__SetDescriptor(
|
|
|
1252
1233
|
"remainingDuration",
|
|
1253
1234
|
{
|
|
1254
1235
|
get = function(self)
|
|
1255
|
-
local
|
|
1256
|
-
return
|
|
1236
|
+
local ____opt_59 = self._timer
|
|
1237
|
+
return ____opt_59 and ____opt_59.remaining or 0
|
|
1257
1238
|
end,
|
|
1258
1239
|
set = function(self, remainingDuration)
|
|
1259
|
-
local
|
|
1260
|
-
local
|
|
1261
|
-
local remainingDurationDelta =
|
|
1240
|
+
local ____remainingDuration_63 = remainingDuration
|
|
1241
|
+
local ____opt_61 = self._timer
|
|
1242
|
+
local remainingDurationDelta = ____remainingDuration_63 - (____opt_61 and ____opt_61.remaining or 0)
|
|
1262
1243
|
if remainingDurationDelta ~= 0 then
|
|
1263
1244
|
self[103] = self[103] + remainingDurationDelta
|
|
1264
1245
|
if remainingDuration <= 0 then
|
|
@@ -1288,7 +1269,8 @@ __TS__SetDescriptor(
|
|
|
1288
1269
|
},
|
|
1289
1270
|
true
|
|
1290
1271
|
)
|
|
1291
|
-
Buff.
|
|
1272
|
+
Buff.createdEvent = buffCreatedEvent
|
|
1273
|
+
Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
|
|
1292
1274
|
(function(self)
|
|
1293
1275
|
local function destroyBuffIfNeeded(buff)
|
|
1294
1276
|
if getUnitAbility(buff[101].handle, buff.typeId) ~= buff.handle and buff[100] == 1 then
|
|
@@ -1342,5 +1324,8 @@ Buff.destroyEvent = buffDestroyEvent;
|
|
|
1342
1324
|
____exports.checkBuffs(target)
|
|
1343
1325
|
end
|
|
1344
1326
|
)
|
|
1327
|
+
buffCreatedEvent:addListener(function(buff)
|
|
1328
|
+
UnitBehavior:forAll(buff.unit, "onBuffGained", buff)
|
|
1329
|
+
end)
|
|
1345
1330
|
end)(Buff)
|
|
1346
1331
|
return ____exports
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
-
import { Handle } from "../../core/types/handle";
|
|
2
|
+
import { Handle, HandleDestructor } from "../../core/types/handle";
|
|
3
3
|
import { Event } from "../../event";
|
|
4
4
|
import type { Item } from "../../core/types/item";
|
|
5
5
|
import type { Unit } from "./unit";
|
|
@@ -55,16 +55,19 @@ export declare class UnrecognizedAbility extends Ability {
|
|
|
55
55
|
export declare class UnitAbility extends Ability {
|
|
56
56
|
readonly owner: Unit;
|
|
57
57
|
private readonly u;
|
|
58
|
+
private d?;
|
|
58
59
|
constructor(handle: jability, typeId: number, owner: Unit);
|
|
59
60
|
incrementHideCounter(): void;
|
|
60
61
|
decrementHideCounter(): void;
|
|
61
62
|
incrementDisableCounter(): void;
|
|
62
63
|
decrementDisableCounter(): void;
|
|
64
|
+
get isDisabled(): boolean;
|
|
63
65
|
get level(): number;
|
|
64
66
|
set level(v: number);
|
|
65
67
|
get cooldownRemaining(): number;
|
|
66
68
|
set cooldownRemaining(cooldownRemaining: number);
|
|
67
69
|
interruptCast(): void;
|
|
70
|
+
protected onDestroy(): HandleDestructor;
|
|
68
71
|
static get onCreate(): Event<[UnitAbility]>;
|
|
69
72
|
static get onDestroy(): Event<[UnitAbility]>;
|
|
70
73
|
}
|
|
@@ -91,6 +94,7 @@ export declare class ItemAbility extends Ability {
|
|
|
91
94
|
get cooldownRemaining(): number;
|
|
92
95
|
set cooldownRemaining(cooldownRemaining: number);
|
|
93
96
|
interruptCast(): void;
|
|
97
|
+
protected onDestroy(): HandleDestructor;
|
|
94
98
|
static get onCreate(): Event<[ItemAbility]>;
|
|
95
99
|
static get onDestroy(): Event<[ItemAbility]>;
|
|
96
100
|
}
|
|
@@ -232,6 +232,19 @@ ____exports.getOrderIdByAbilityTypeId = function(abilityTypeId)
|
|
|
232
232
|
local parentTypeId = availableFields[abilityTypeId]
|
|
233
233
|
return order2orderId(orders[____type(parentTypeId) == "number" and parentTypeId or abilityTypeId] or "")
|
|
234
234
|
end
|
|
235
|
+
---
|
|
236
|
+
-- @internal For use by internal systems only.
|
|
237
|
+
____exports.abilityTypeHasField = function(abilityTypeId, field)
|
|
238
|
+
field = ____type(field) == "number" and field or getHandleId(field)
|
|
239
|
+
if commonFields[field] then
|
|
240
|
+
return true
|
|
241
|
+
end
|
|
242
|
+
local id = availableFields[abilityTypeId]
|
|
243
|
+
if ____type(id) == "number" then
|
|
244
|
+
id = availableFields[id]
|
|
245
|
+
end
|
|
246
|
+
return not not (id and id[field])
|
|
247
|
+
end
|
|
235
248
|
____exports.Ability = __TS__Class()
|
|
236
249
|
local Ability = ____exports.Ability
|
|
237
250
|
Ability.name = "Ability"
|
|
@@ -247,15 +260,7 @@ function Ability.prototype.getSnapshot(self)
|
|
|
247
260
|
return nil
|
|
248
261
|
end
|
|
249
262
|
function Ability.prototype.hasField(self, field)
|
|
250
|
-
|
|
251
|
-
if commonFields[field] then
|
|
252
|
-
return true
|
|
253
|
-
end
|
|
254
|
-
local id = availableFields[self.typeId]
|
|
255
|
-
if ____type(id) == "number" then
|
|
256
|
-
id = availableFields[id]
|
|
257
|
-
end
|
|
258
|
-
return not not (id and id[field])
|
|
263
|
+
return ____exports.abilityTypeHasField(self.typeId, field)
|
|
259
264
|
end
|
|
260
265
|
function Ability.prototype.getField(self, field, level)
|
|
261
266
|
local fieldType = match(
|
|
@@ -404,14 +409,36 @@ function UnitAbility.prototype.decrementHideCounter(self)
|
|
|
404
409
|
unitHideAbility(self.u, self.typeId, false)
|
|
405
410
|
end
|
|
406
411
|
function UnitAbility.prototype.incrementDisableCounter(self)
|
|
407
|
-
|
|
412
|
+
local unit = self.u
|
|
413
|
+
local typeId = self.typeId
|
|
414
|
+
unitHideAbility(unit, typeId, true)
|
|
415
|
+
unitDisableAbility(unit, typeId, true, false)
|
|
416
|
+
self.d = (self.d or 0) + 1
|
|
408
417
|
end
|
|
409
418
|
function UnitAbility.prototype.decrementDisableCounter(self)
|
|
410
|
-
|
|
419
|
+
local unit = self.u
|
|
420
|
+
local typeId = self.typeId
|
|
421
|
+
unitDisableAbility(unit, typeId, false, false)
|
|
422
|
+
unitHideAbility(unit, typeId, true)
|
|
423
|
+
self.d = (self.d or 0) - 1
|
|
411
424
|
end
|
|
412
425
|
function UnitAbility.prototype.interruptCast(self)
|
|
413
426
|
self.owner:interruptCast(self.typeId)
|
|
414
427
|
end
|
|
428
|
+
function UnitAbility.prototype.onDestroy(self)
|
|
429
|
+
if self.owner.state ~= 2 then
|
|
430
|
+
self.owner:removeAbility(self.typeId)
|
|
431
|
+
end
|
|
432
|
+
return UnitAbility.____super.prototype.onDestroy(self)
|
|
433
|
+
end
|
|
434
|
+
__TS__SetDescriptor(
|
|
435
|
+
UnitAbility.prototype,
|
|
436
|
+
"isDisabled",
|
|
437
|
+
{get = function(self)
|
|
438
|
+
return self.d ~= nil and self.d > 0
|
|
439
|
+
end},
|
|
440
|
+
true
|
|
441
|
+
)
|
|
415
442
|
__TS__SetDescriptor(
|
|
416
443
|
UnitAbility.prototype,
|
|
417
444
|
"level",
|
|
@@ -496,6 +523,12 @@ function ItemAbility.prototype.interruptCast(self)
|
|
|
496
523
|
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, true)
|
|
497
524
|
end
|
|
498
525
|
end
|
|
526
|
+
function ItemAbility.prototype.onDestroy(self)
|
|
527
|
+
if self.owner.state ~= 2 then
|
|
528
|
+
self.owner:removeAbility(self.typeId)
|
|
529
|
+
end
|
|
530
|
+
return ItemAbility.____super.prototype.onDestroy(self)
|
|
531
|
+
end
|
|
499
532
|
__TS__SetDescriptor(
|
|
500
533
|
ItemAbility.prototype,
|
|
501
534
|
"level",
|
|
@@ -20,6 +20,7 @@ local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slo
|
|
|
20
20
|
local unitAddItemToSlot = ____add_2Ditem_2Dto_2Dslot.unitAddItemToSlot
|
|
21
21
|
local isItemOwned = IsItemOwned
|
|
22
22
|
local isItemPowerup = IsItemPowerup
|
|
23
|
+
local getItemAbility = BlzGetItemAbility
|
|
23
24
|
local getItemX = GetItemX
|
|
24
25
|
local getItemY = GetItemY
|
|
25
26
|
local setAbilityRealLevelField = BlzSetAbilityRealLevelField
|
|
@@ -31,6 +32,8 @@ local unitAddItem = UnitAddItem
|
|
|
31
32
|
local unitRemoveItem = UnitRemoveItem
|
|
32
33
|
local unitUseItem = UnitUseItem
|
|
33
34
|
local unitResetCooldown = UnitResetCooldown
|
|
35
|
+
local unitInventorySize = UnitInventorySize
|
|
36
|
+
local unitItemInSlot = UnitItemInSlot
|
|
34
37
|
local COOLDOWN_STARTER_ABILITY_TYPE_ID = compiletime(function()
|
|
35
38
|
if not currentMap then
|
|
36
39
|
return 0
|
|
@@ -55,22 +58,24 @@ local COOLDOWN_STARTER_ITEM_TYPE_ID = compiletime(function()
|
|
|
55
58
|
itemType.activelyUsed = true
|
|
56
59
|
return itemType.id
|
|
57
60
|
end)
|
|
58
|
-
|
|
61
|
+
---
|
|
62
|
+
-- @internal For use by internal systems only.
|
|
63
|
+
____exports.itemAbilityDummy = assert(CreateUnit(
|
|
59
64
|
Player.neutralVictim.handle,
|
|
60
65
|
dummyUnitId,
|
|
61
66
|
0,
|
|
62
67
|
0,
|
|
63
68
|
270
|
|
64
69
|
))
|
|
65
|
-
local cooldownStarterItem = UnitAddItemById(
|
|
66
|
-
local cooldownStarterAbility =
|
|
67
|
-
ShowUnit(
|
|
70
|
+
local cooldownStarterItem = UnitAddItemById(____exports.itemAbilityDummy, COOLDOWN_STARTER_ITEM_TYPE_ID)
|
|
71
|
+
local cooldownStarterAbility = getItemAbility(cooldownStarterItem, COOLDOWN_STARTER_ABILITY_TYPE_ID)
|
|
72
|
+
ShowUnit(____exports.itemAbilityDummy, false)
|
|
68
73
|
local function startItemCooldownInternal(handle, cooldown)
|
|
69
74
|
local cooldownGroup = getItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP)
|
|
70
75
|
setItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP, COOLDOWN_STARTER_ABILITY_TYPE_ID)
|
|
71
76
|
setAbilityRealLevelField(cooldownStarterAbility, ABILITY_RLF_COOLDOWN, 0, cooldown)
|
|
72
|
-
unitResetCooldown(
|
|
73
|
-
unitUseItem(
|
|
77
|
+
unitResetCooldown(____exports.itemAbilityDummy)
|
|
78
|
+
unitUseItem(____exports.itemAbilityDummy, cooldownStarterItem)
|
|
74
79
|
Timer:run(restoreCooldownGroup, handle, cooldownGroup)
|
|
75
80
|
end
|
|
76
81
|
restoreCooldownGroup = function(handle, cooldownGroup)
|
|
@@ -85,7 +90,7 @@ ____exports.startItemCooldown = function(handle, owner, cooldown)
|
|
|
85
90
|
end
|
|
86
91
|
---
|
|
87
92
|
-- @internal For use by internal systems only.
|
|
88
|
-
____exports.abilityActionDummy =
|
|
93
|
+
____exports.abilityActionDummy = ____exports.itemAbilityDummy
|
|
89
94
|
---
|
|
90
95
|
-- @internal For use by internal systems only.
|
|
91
96
|
____exports.doAbilityAction = function(handle, action, ...)
|
|
@@ -104,11 +109,11 @@ ____exports.doAbilityAction = function(handle, action, ...)
|
|
|
104
109
|
end
|
|
105
110
|
x = getItemX(handle)
|
|
106
111
|
y = getItemY(handle)
|
|
107
|
-
unitAddItem(
|
|
112
|
+
unitAddItem(____exports.itemAbilityDummy, handle)
|
|
108
113
|
end
|
|
109
114
|
local result = action(handle, ...)
|
|
110
115
|
if not isOwned then
|
|
111
|
-
unitRemoveItem(
|
|
116
|
+
unitRemoveItem(____exports.itemAbilityDummy, handle)
|
|
112
117
|
setItemPosition(handle, x, y)
|
|
113
118
|
if isPowerup then
|
|
114
119
|
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
@@ -139,9 +144,9 @@ ____exports.doAbilityActionForceDummy = function(handle, owner, action, ...)
|
|
|
139
144
|
isPowerup = true
|
|
140
145
|
end
|
|
141
146
|
unitRemoveItem(owner, handle)
|
|
142
|
-
unitAddItem(
|
|
147
|
+
unitAddItem(____exports.itemAbilityDummy, handle)
|
|
143
148
|
local result = action(handle, ...)
|
|
144
|
-
unitRemoveItem(
|
|
149
|
+
unitRemoveItem(____exports.itemAbilityDummy, handle)
|
|
145
150
|
unitAddItemToSlot(owner, handle, slot)
|
|
146
151
|
if isPowerup then
|
|
147
152
|
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
@@ -151,4 +156,51 @@ ____exports.doAbilityActionForceDummy = function(handle, owner, action, ...)
|
|
|
151
156
|
end
|
|
152
157
|
return result
|
|
153
158
|
end
|
|
159
|
+
local depth = 0
|
|
160
|
+
local itemBySlot = {}
|
|
161
|
+
---
|
|
162
|
+
-- @internal For use by internal systems only.
|
|
163
|
+
____exports.doUnitAbilityAction = function(unit, abilityTypeId, action, ...)
|
|
164
|
+
local ____depth_0 = depth
|
|
165
|
+
depth = ____depth_0 + 1
|
|
166
|
+
local offset = 6 * ____depth_0
|
|
167
|
+
for slot = 0, unitInventorySize(unit) - 1 do
|
|
168
|
+
local item = unitItemInSlot(unit, slot)
|
|
169
|
+
if getItemAbility(item, abilityTypeId) ~= nil then
|
|
170
|
+
local isAlreadyIgnoredInEvents = ignoreEventsItems[item] ~= nil
|
|
171
|
+
if not isAlreadyIgnoredInEvents then
|
|
172
|
+
ignoreEventsItems[item] = true
|
|
173
|
+
end
|
|
174
|
+
unitRemoveItem(unit, item)
|
|
175
|
+
if not isAlreadyIgnoredInEvents then
|
|
176
|
+
ignoreEventsItems[item] = nil
|
|
177
|
+
end
|
|
178
|
+
itemBySlot[offset + slot] = item
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
local result = action(unit, ...)
|
|
182
|
+
for slot = 0, unitInventorySize(unit) - 1 do
|
|
183
|
+
local item = itemBySlot[offset + slot]
|
|
184
|
+
if item ~= nil then
|
|
185
|
+
local isAlreadyIgnoredInEvents = ignoreEventsItems[item] ~= nil
|
|
186
|
+
if not isAlreadyIgnoredInEvents then
|
|
187
|
+
ignoreEventsItems[item] = true
|
|
188
|
+
end
|
|
189
|
+
local isPowerup = isItemPowerup(item)
|
|
190
|
+
if isPowerup then
|
|
191
|
+
setItemBooleanField(item, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
|
|
192
|
+
end
|
|
193
|
+
unitAddItemToSlot(unit, item, slot)
|
|
194
|
+
if isPowerup then
|
|
195
|
+
setItemBooleanField(item, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
196
|
+
end
|
|
197
|
+
if not isAlreadyIgnoredInEvents then
|
|
198
|
+
ignoreEventsItems[item] = nil
|
|
199
|
+
end
|
|
200
|
+
itemBySlot[offset + slot] = nil
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
depth = depth - 1
|
|
204
|
+
return result
|
|
205
|
+
end
|
|
154
206
|
return ____exports
|
|
@@ -6,12 +6,18 @@ local Item = ____item.Item
|
|
|
6
6
|
local ____unit = require("engine.internal.unit")
|
|
7
7
|
local Unit = ____unit.Unit
|
|
8
8
|
local ownerByItem = setmetatable({}, {__mode = "kv"})
|
|
9
|
-
Unit.itemPickedUpEvent:addListener(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
Unit.itemPickedUpEvent:addListener(
|
|
10
|
+
4,
|
|
11
|
+
function(unit, item)
|
|
12
|
+
ownerByItem[item] = unit
|
|
13
|
+
end
|
|
14
|
+
)
|
|
15
|
+
Unit.itemDroppedEvent:addListener(
|
|
16
|
+
4,
|
|
17
|
+
function(unit, item)
|
|
18
|
+
ownerByItem[item] = nil
|
|
19
|
+
end
|
|
20
|
+
)
|
|
15
21
|
__TS__ObjectDefineProperty(
|
|
16
22
|
Item.prototype,
|
|
17
23
|
"owner",
|
|
@@ -7,14 +7,11 @@ import { ItemAbility } from "./ability";
|
|
|
7
7
|
import { AbilityTypeId } from "../object-data/entry/ability-type";
|
|
8
8
|
import type { ItemTypeId } from "../object-data/entry/item-type";
|
|
9
9
|
type DefenseType = 0 | 1 | 2 | 3 | 4 | 5;
|
|
10
|
-
export declare const addAndGetAbility: (handle: jitem, abilityTypeId: AbilityTypeId) => jability | null;
|
|
11
10
|
declare const enum ItemPropertyKey {
|
|
12
|
-
ABILITIES = 100
|
|
13
|
-
LUA_INDEX_BY_ABILITY_TYPE_ID = 101
|
|
11
|
+
ABILITIES = 100
|
|
14
12
|
}
|
|
15
13
|
export declare class Item extends Handle<jitem> {
|
|
16
14
|
private readonly [ItemPropertyKey.ABILITIES];
|
|
17
|
-
private readonly [ItemPropertyKey.LUA_INDEX_BY_ABILITY_TYPE_ID];
|
|
18
15
|
constructor(handle: jitem);
|
|
19
16
|
protected onDestroy(): HandleDestructor;
|
|
20
17
|
static create<T extends Item>(this: typeof Item & (new (handle: jitem) => T), id: number, x: number, y: number, skinId?: number): T;
|
|
@@ -74,6 +71,8 @@ export declare class Item extends Handle<jitem> {
|
|
|
74
71
|
set position(v: Vec2);
|
|
75
72
|
set charges(v: number);
|
|
76
73
|
get charges(): number;
|
|
74
|
+
consumeCharge(): boolean;
|
|
75
|
+
consumeCharges(count: number): boolean;
|
|
77
76
|
addAbility(abilityTypeId: AbilityTypeId): ItemAbility | undefined;
|
|
78
77
|
removeAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
79
78
|
hasAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
@@ -83,5 +82,6 @@ export declare class Item extends Handle<jitem> {
|
|
|
83
82
|
static getInRect(rect: ReadonlyRect): Item[];
|
|
84
83
|
static get onCreate(): Event<[Item]>;
|
|
85
84
|
static get destroyEvent(): Event<[Item]>;
|
|
85
|
+
static readonly chargesChangedEvent: Event<[Item]>;
|
|
86
86
|
}
|
|
87
87
|
export {};
|