warscript 0.0.1-dev.6be8f21 → 0.0.1-dev.6d8bd54
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/tileCell.d.ts +9 -0
- package/core/types/tileCell.lua +92 -0
- package/core/types/timer.d.ts +1 -0
- package/core/types/timer.lua +21 -2
- package/decl/native.d.ts +6 -4
- package/engine/behavior.d.ts +3 -0
- package/engine/behavior.lua +63 -10
- package/engine/behaviour/ability/restore-mana.d.ts +1 -1
- package/engine/behaviour/ability/restore-mana.lua +6 -6
- package/engine/behaviour/unit.d.ts +6 -2
- package/engine/behaviour/unit.lua +24 -2
- package/engine/buff.d.ts +0 -3
- package/engine/buff.lua +59 -80
- package/engine/internal/ability.d.ts +3 -1
- package/engine/internal/ability.lua +26 -9
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +1 -3
- package/engine/internal/item.lua +22 -23
- 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.lua +1 -1
- package/engine/internal/unit+ability.lua +10 -1
- package/engine/internal/unit-missile-launch.lua +8 -1
- package/engine/internal/unit.d.ts +4 -5
- package/engine/internal/unit.lua +19 -17
- 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.d.ts +2 -2
- package/engine/object-field.lua +8 -6
- package/engine/random.d.ts +9 -0
- package/engine/random.lua +13 -0
- package/engine/text-tag.d.ts +1 -1
- package/engine/text-tag.lua +91 -17
- 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 +2 -0
- package/utility/functions.lua +7 -0
- package/utility/lua-maps.d.ts +11 -2
- package/utility/lua-maps.lua +33 -2
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +4 -0
|
@@ -11,13 +11,17 @@ import { Destructor } from "../../destroyable";
|
|
|
11
11
|
import type { Widget } from "../../core/types/widget";
|
|
12
12
|
import { Destructable } from "../../core/types/destructable";
|
|
13
13
|
import type { Buff } from "../buff";
|
|
14
|
+
import { UnitBonusType } from "../internal/unit/bonus";
|
|
14
15
|
export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
|
|
15
16
|
export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
|
|
17
|
+
readonly sourceAbilityBehavior?: AbilityBehavior;
|
|
18
|
+
private _bonusIdByBonusType?;
|
|
16
19
|
constructor(unit: Unit);
|
|
17
20
|
protected onDestroy(): Destructor;
|
|
18
|
-
readonly sourceAbilityBehavior?: AbilityBehavior;
|
|
19
21
|
get unit(): Unit;
|
|
20
|
-
|
|
22
|
+
protected getUnitBonus(bonusType: UnitBonusType): number;
|
|
23
|
+
protected addOrUpdateOrRemoveUnitBonus(bonusType: UnitBonusType, value: number): void;
|
|
24
|
+
protected registerInRangeUnitEvent<T extends string, Args extends any[]>(this: UnitBehavior<PeriodicActionParameters> & Record<T, (this: this, ...args: Args) => unknown>, event: Event<[...Args]>, extractUnit: (...args: Args) => Unit | undefined, range: number, listener: T): void;
|
|
21
25
|
onImmediateOrder(orderId: number): void;
|
|
22
26
|
onTargetOrder(orderId: number, target: Widget): void;
|
|
23
27
|
onPointOrder(orderId: number, x: number, y: number): void;
|
|
@@ -17,6 +17,11 @@ local getOrPut = ____lua_2Dmaps.getOrPut
|
|
|
17
17
|
local mutableLuaMap = ____lua_2Dmaps.mutableLuaMap
|
|
18
18
|
local ____lua_2Dsets = require("utility.lua-sets")
|
|
19
19
|
local mutableLuaSet = ____lua_2Dsets.mutableLuaSet
|
|
20
|
+
local ____bonus = require("engine.internal.unit.bonus")
|
|
21
|
+
local addOrUpdateOrRemoveUnitBonus = ____bonus.addOrUpdateOrRemoveUnitBonus
|
|
22
|
+
local getUnitBonus = ____bonus.getUnitBonus
|
|
23
|
+
local removeUnitBonus = ____bonus.removeUnitBonus
|
|
24
|
+
local safeCall = warpack.safeCall
|
|
20
25
|
local behaviorsByEvent = {}
|
|
21
26
|
local rangeByBehaviorByEvent = {}
|
|
22
27
|
local listenerByBehaviorByEvent = {}
|
|
@@ -47,8 +52,26 @@ function UnitBehavior.prototype.onDestroy(self)
|
|
|
47
52
|
end
|
|
48
53
|
eventsByBehavior[self] = nil
|
|
49
54
|
end
|
|
55
|
+
if self._bonusIdByBonusType ~= nil then
|
|
56
|
+
for bonusType, bonusId in pairs(self._bonusIdByBonusType) do
|
|
57
|
+
removeUnitBonus(self.object, bonusType, bonusId)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
50
60
|
return Behavior.prototype.onDestroy(self)
|
|
51
61
|
end
|
|
62
|
+
function UnitBehavior.prototype.getUnitBonus(self, bonusType)
|
|
63
|
+
local ____opt_6 = self._bonusIdByBonusType
|
|
64
|
+
local bonusId = ____opt_6 and ____opt_6[bonusType]
|
|
65
|
+
return bonusId == nil and 0 or getUnitBonus(self.object, bonusType, bonusId)
|
|
66
|
+
end
|
|
67
|
+
function UnitBehavior.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
|
|
68
|
+
local bonusIdByBonusType = self._bonusIdByBonusType
|
|
69
|
+
if bonusIdByBonusType == nil then
|
|
70
|
+
bonusIdByBonusType = {}
|
|
71
|
+
self._bonusIdByBonusType = bonusIdByBonusType
|
|
72
|
+
end
|
|
73
|
+
bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self.object, bonusType, bonusIdByBonusType[bonusType], value)
|
|
74
|
+
end
|
|
52
75
|
function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, extractUnit, range, listener)
|
|
53
76
|
local rangeByBehavior = getOrPut(rangeByBehaviorByEvent, event, mutableLuaMap)
|
|
54
77
|
rangeByBehavior[self] = range
|
|
@@ -65,8 +88,7 @@ function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, extractUni
|
|
|
65
88
|
for behavior in pairs(behaviors) do
|
|
66
89
|
local range = rangeByBehavior[behavior]
|
|
67
90
|
if range ~= nil and unit:getCollisionDistanceTo(behavior.unit) <= range then
|
|
68
|
-
|
|
69
|
-
____self_6[listenerByBehavior[behavior]](____self_6, ...)
|
|
91
|
+
safeCall(behavior[listenerByBehavior[behavior]], behavior, ...)
|
|
70
92
|
end
|
|
71
93
|
end
|
|
72
94
|
end
|
package/engine/buff.d.ts
CHANGED
|
@@ -201,11 +201,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
201
201
|
private readonly _spellStealPriority?;
|
|
202
202
|
private readonly _learnLevelMinimum?;
|
|
203
203
|
private readonly [BuffPropertyKey.MISS_PROBABILITY]?;
|
|
204
|
-
private _bonusIdByBonusType?;
|
|
205
204
|
private readonly _abilityTypeIds?;
|
|
206
205
|
private _behaviors?;
|
|
207
|
-
private getUnitBonus;
|
|
208
|
-
private addOrUpdateOrRemoveUnitBonus;
|
|
209
206
|
constructor(target: Unit, ...parameters: BuffConstructorParameters<AdditionalParameters>);
|
|
210
207
|
get level(): number;
|
|
211
208
|
get remainingDamageOverDuration(): number;
|
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
|
|
@@ -509,63 +506,50 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
|
|
|
509
506
|
self[100] = 1
|
|
510
507
|
Event.invoke(buffCreatedEvent, self)
|
|
511
508
|
end
|
|
512
|
-
function Buff.prototype.getUnitBonus(self, bonusType)
|
|
513
|
-
local ____opt_38 = self._bonusIdByBonusType
|
|
514
|
-
local bonusId = ____opt_38 and ____opt_38[bonusType]
|
|
515
|
-
return bonusId == nil and 0 or getUnitBonus(self._unit, bonusType, bonusId)
|
|
516
|
-
end
|
|
517
|
-
function Buff.prototype.addOrUpdateOrRemoveUnitBonus(self, bonusType, value)
|
|
518
|
-
local bonusIdByBonusType = self._bonusIdByBonusType
|
|
519
|
-
if bonusIdByBonusType == nil then
|
|
520
|
-
bonusIdByBonusType = {}
|
|
521
|
-
self._bonusIdByBonusType = bonusIdByBonusType
|
|
522
|
-
end
|
|
523
|
-
bonusIdByBonusType[bonusType] = addOrUpdateOrRemoveUnitBonus(self._unit, bonusType, bonusIdByBonusType[bonusType], value)
|
|
524
|
-
end
|
|
525
509
|
function Buff.prototype.flashEffect(self, widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
|
|
526
510
|
if type(widgetOrXOrParametersOrDuration) == "number" and type(yOrParametersOrDuration) == "number" then
|
|
527
511
|
Effect:flash(self[105], widgetOrXOrParametersOrDuration, yOrParametersOrDuration, parametersOrDuration)
|
|
528
512
|
else
|
|
529
513
|
local isWidgetProvided = __TS__InstanceOf(widgetOrXOrParametersOrDuration, Unit) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Item) or __TS__InstanceOf(widgetOrXOrParametersOrDuration, Destructable)
|
|
530
|
-
local
|
|
531
|
-
local
|
|
532
|
-
local
|
|
514
|
+
local ____Effect_40 = Effect
|
|
515
|
+
local ____Effect_flash_41 = Effect.flash
|
|
516
|
+
local ____array_39 = __TS__SparseArrayNew(
|
|
533
517
|
self[105],
|
|
534
518
|
isWidgetProvided and widgetOrXOrParametersOrDuration or self._unit,
|
|
535
519
|
stringValueByBuffTypeIdByFieldId[fourCC("feft")][self.typeId] or "origin"
|
|
536
520
|
)
|
|
537
|
-
local
|
|
521
|
+
local ____isWidgetProvided_38
|
|
538
522
|
if isWidgetProvided then
|
|
539
|
-
|
|
523
|
+
____isWidgetProvided_38 = yOrParametersOrDuration
|
|
540
524
|
else
|
|
541
|
-
|
|
525
|
+
____isWidgetProvided_38 = widgetOrXOrParametersOrDuration
|
|
542
526
|
end
|
|
543
|
-
__TS__SparseArrayPush(
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
__TS__SparseArraySpread(
|
|
527
|
+
__TS__SparseArrayPush(____array_39, ____isWidgetProvided_38)
|
|
528
|
+
____Effect_flash_41(
|
|
529
|
+
____Effect_40,
|
|
530
|
+
__TS__SparseArraySpread(____array_39)
|
|
547
531
|
)
|
|
548
532
|
end
|
|
549
533
|
end
|
|
550
534
|
function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
|
|
551
535
|
local isWidgetProvided = type(widgetOrDuration) == "table"
|
|
552
|
-
local
|
|
553
|
-
local
|
|
554
|
-
local
|
|
536
|
+
local ____Effect_44 = Effect
|
|
537
|
+
local ____Effect_flash_45 = Effect.flash
|
|
538
|
+
local ____array_43 = __TS__SparseArrayNew(
|
|
555
539
|
self[106],
|
|
556
540
|
isWidgetProvided and widgetOrDuration or self._unit,
|
|
557
541
|
stringValueByBuffTypeIdByFieldId[fourCC("fspt")][self.typeId] or "origin"
|
|
558
542
|
)
|
|
559
|
-
local
|
|
543
|
+
local ____isWidgetProvided_42
|
|
560
544
|
if isWidgetProvided then
|
|
561
|
-
|
|
545
|
+
____isWidgetProvided_42 = duration
|
|
562
546
|
else
|
|
563
|
-
|
|
547
|
+
____isWidgetProvided_42 = widgetOrDuration
|
|
564
548
|
end
|
|
565
|
-
__TS__SparseArrayPush(
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
__TS__SparseArraySpread(
|
|
549
|
+
__TS__SparseArrayPush(____array_43, ____isWidgetProvided_42)
|
|
550
|
+
____Effect_flash_45(
|
|
551
|
+
____Effect_44,
|
|
552
|
+
__TS__SparseArraySpread(____array_43)
|
|
569
553
|
)
|
|
570
554
|
end
|
|
571
555
|
function Buff.prototype.onCreate(self)
|
|
@@ -616,11 +600,6 @@ function Buff.prototype.onDestroy(self)
|
|
|
616
600
|
unit:removeAbility(abilityTypeId)
|
|
617
601
|
end
|
|
618
602
|
end
|
|
619
|
-
if self._bonusIdByBonusType ~= nil then
|
|
620
|
-
for bonusType, bonusId in pairs(self._bonusIdByBonusType) do
|
|
621
|
-
removeUnitBonus(unit, bonusType, bonusId)
|
|
622
|
-
end
|
|
623
|
-
end
|
|
624
603
|
Event.invoke(buffBeingDestroyedEvent, self)
|
|
625
604
|
self[100] = 3
|
|
626
605
|
return UnitBehavior.prototype.onDestroy(self)
|
|
@@ -650,8 +629,8 @@ function Buff.apply(self, ...)
|
|
|
650
629
|
end
|
|
651
630
|
end
|
|
652
631
|
function Buff.getByTypeId(self, unit, typeId)
|
|
653
|
-
local
|
|
654
|
-
local buff =
|
|
632
|
+
local ____opt_46 = buffByTypeIdByUnit[unit]
|
|
633
|
+
local buff = ____opt_46 and ____opt_46[typeId]
|
|
655
634
|
if __TS__InstanceOf(buff, self) then
|
|
656
635
|
return buff
|
|
657
636
|
end
|
|
@@ -809,8 +788,8 @@ __TS__SetDescriptor(
|
|
|
809
788
|
return
|
|
810
789
|
end
|
|
811
790
|
self[112] = damageInterval
|
|
812
|
-
local
|
|
813
|
-
local elapsed =
|
|
791
|
+
local ____opt_48 = self._timer
|
|
792
|
+
local elapsed = ____opt_48 and ____opt_48.elapsed or 0
|
|
814
793
|
local timer = self[114]
|
|
815
794
|
if timer == nil then
|
|
816
795
|
timer = Timer:create()
|
|
@@ -889,8 +868,8 @@ __TS__SetDescriptor(
|
|
|
889
868
|
return
|
|
890
869
|
end
|
|
891
870
|
self[117] = healingInterval
|
|
892
|
-
local
|
|
893
|
-
local elapsed =
|
|
871
|
+
local ____opt_50 = self._timer
|
|
872
|
+
local elapsed = ____opt_50 and ____opt_50.elapsed or 0
|
|
894
873
|
local timer = self[119]
|
|
895
874
|
if timer == nil then
|
|
896
875
|
timer = Timer:create()
|
|
@@ -976,11 +955,11 @@ __TS__SetDescriptor(
|
|
|
976
955
|
"turnsIntoGhost",
|
|
977
956
|
{
|
|
978
957
|
get = function(self)
|
|
979
|
-
local
|
|
980
|
-
if
|
|
981
|
-
|
|
958
|
+
local ____self__135_52 = self[135]
|
|
959
|
+
if ____self__135_52 == nil then
|
|
960
|
+
____self__135_52 = false
|
|
982
961
|
end
|
|
983
|
-
return
|
|
962
|
+
return ____self__135_52
|
|
984
963
|
end,
|
|
985
964
|
set = function(self, turnsIntoGhost)
|
|
986
965
|
if not turnsIntoGhost and self[135] then
|
|
@@ -999,11 +978,11 @@ __TS__SetDescriptor(
|
|
|
999
978
|
"stuns",
|
|
1000
979
|
{
|
|
1001
980
|
get = function(self)
|
|
1002
|
-
local
|
|
1003
|
-
if
|
|
1004
|
-
|
|
981
|
+
local ____self__136_53 = self[136]
|
|
982
|
+
if ____self__136_53 == nil then
|
|
983
|
+
____self__136_53 = false
|
|
1005
984
|
end
|
|
1006
|
-
return
|
|
985
|
+
return ____self__136_53
|
|
1007
986
|
end,
|
|
1008
987
|
set = function(self, stuns)
|
|
1009
988
|
if not stuns and self[136] then
|
|
@@ -1028,11 +1007,11 @@ __TS__SetDescriptor(
|
|
|
1028
1007
|
"ignoresStunImmunity",
|
|
1029
1008
|
{
|
|
1030
1009
|
get = function(self)
|
|
1031
|
-
local
|
|
1032
|
-
if
|
|
1033
|
-
|
|
1010
|
+
local ____self__137_54 = self[137]
|
|
1011
|
+
if ____self__137_54 == nil then
|
|
1012
|
+
____self__137_54 = false
|
|
1034
1013
|
end
|
|
1035
|
-
return
|
|
1014
|
+
return ____self__137_54
|
|
1036
1015
|
end,
|
|
1037
1016
|
set = function(self, ignoresStunImmunity)
|
|
1038
1017
|
if not ignoresStunImmunity and self[137] then
|
|
@@ -1055,11 +1034,11 @@ __TS__SetDescriptor(
|
|
|
1055
1034
|
"disablesAutoAttack",
|
|
1056
1035
|
{
|
|
1057
1036
|
get = function(self)
|
|
1058
|
-
local
|
|
1059
|
-
if
|
|
1060
|
-
|
|
1037
|
+
local ____self__138_55 = self[138]
|
|
1038
|
+
if ____self__138_55 == nil then
|
|
1039
|
+
____self__138_55 = false
|
|
1061
1040
|
end
|
|
1062
|
-
return
|
|
1041
|
+
return ____self__138_55
|
|
1063
1042
|
end,
|
|
1064
1043
|
set = function(self, disablesAutoAttack)
|
|
1065
1044
|
if not disablesAutoAttack and self[138] then
|
|
@@ -1078,11 +1057,11 @@ __TS__SetDescriptor(
|
|
|
1078
1057
|
"providesInvulnerability",
|
|
1079
1058
|
{
|
|
1080
1059
|
get = function(self)
|
|
1081
|
-
local
|
|
1082
|
-
if
|
|
1083
|
-
|
|
1060
|
+
local ____self__139_56 = self[139]
|
|
1061
|
+
if ____self__139_56 == nil then
|
|
1062
|
+
____self__139_56 = false
|
|
1084
1063
|
end
|
|
1085
|
-
return
|
|
1064
|
+
return ____self__139_56
|
|
1086
1065
|
end,
|
|
1087
1066
|
set = function(self, providesInvulnerability)
|
|
1088
1067
|
if not providesInvulnerability and self[139] then
|
|
@@ -1101,11 +1080,11 @@ __TS__SetDescriptor(
|
|
|
1101
1080
|
"killsOnExpiration",
|
|
1102
1081
|
{
|
|
1103
1082
|
get = function(self)
|
|
1104
|
-
local
|
|
1105
|
-
if
|
|
1106
|
-
|
|
1083
|
+
local ____self__140_57 = self[140]
|
|
1084
|
+
if ____self__140_57 == nil then
|
|
1085
|
+
____self__140_57 = false
|
|
1107
1086
|
end
|
|
1108
|
-
return
|
|
1087
|
+
return ____self__140_57
|
|
1109
1088
|
end,
|
|
1110
1089
|
set = function(self, killsOnExpiration)
|
|
1111
1090
|
if not killsOnExpiration and self[140] then
|
|
@@ -1122,11 +1101,11 @@ __TS__SetDescriptor(
|
|
|
1122
1101
|
"explodesOnExpiration",
|
|
1123
1102
|
{
|
|
1124
1103
|
get = function(self)
|
|
1125
|
-
local
|
|
1126
|
-
if
|
|
1127
|
-
|
|
1104
|
+
local ____self__141_58 = self[141]
|
|
1105
|
+
if ____self__141_58 == nil then
|
|
1106
|
+
____self__141_58 = false
|
|
1128
1107
|
end
|
|
1129
|
-
return
|
|
1108
|
+
return ____self__141_58
|
|
1130
1109
|
end,
|
|
1131
1110
|
set = function(self, killsOnExpiration)
|
|
1132
1111
|
if not killsOnExpiration and self[141] then
|
|
@@ -1254,13 +1233,13 @@ __TS__SetDescriptor(
|
|
|
1254
1233
|
"remainingDuration",
|
|
1255
1234
|
{
|
|
1256
1235
|
get = function(self)
|
|
1257
|
-
local
|
|
1258
|
-
return
|
|
1236
|
+
local ____opt_59 = self._timer
|
|
1237
|
+
return ____opt_59 and ____opt_59.remaining or 0
|
|
1259
1238
|
end,
|
|
1260
1239
|
set = function(self, remainingDuration)
|
|
1261
|
-
local
|
|
1262
|
-
local
|
|
1263
|
-
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)
|
|
1264
1243
|
if remainingDurationDelta ~= 0 then
|
|
1265
1244
|
self[103] = self[103] + remainingDurationDelta
|
|
1266
1245
|
if remainingDuration <= 0 then
|
|
@@ -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";
|
|
@@ -67,6 +67,7 @@ export declare class UnitAbility extends Ability {
|
|
|
67
67
|
get cooldownRemaining(): number;
|
|
68
68
|
set cooldownRemaining(cooldownRemaining: number);
|
|
69
69
|
interruptCast(): void;
|
|
70
|
+
protected onDestroy(): HandleDestructor;
|
|
70
71
|
static get onCreate(): Event<[UnitAbility]>;
|
|
71
72
|
static get onDestroy(): Event<[UnitAbility]>;
|
|
72
73
|
}
|
|
@@ -93,6 +94,7 @@ export declare class ItemAbility extends Ability {
|
|
|
93
94
|
get cooldownRemaining(): number;
|
|
94
95
|
set cooldownRemaining(cooldownRemaining: number);
|
|
95
96
|
interruptCast(): void;
|
|
97
|
+
protected onDestroy(): HandleDestructor;
|
|
96
98
|
static get onCreate(): Event<[ItemAbility]>;
|
|
97
99
|
static get onDestroy(): Event<[ItemAbility]>;
|
|
98
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(
|
|
@@ -420,6 +425,12 @@ end
|
|
|
420
425
|
function UnitAbility.prototype.interruptCast(self)
|
|
421
426
|
self.owner:interruptCast(self.typeId)
|
|
422
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
|
|
423
434
|
__TS__SetDescriptor(
|
|
424
435
|
UnitAbility.prototype,
|
|
425
436
|
"isDisabled",
|
|
@@ -512,6 +523,12 @@ function ItemAbility.prototype.interruptCast(self)
|
|
|
512
523
|
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, true)
|
|
513
524
|
end
|
|
514
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
|
|
515
532
|
__TS__SetDescriptor(
|
|
516
533
|
ItemAbility.prototype,
|
|
517
534
|
"level",
|
|
@@ -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",
|
|
@@ -8,12 +8,10 @@ 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
10
|
declare const enum ItemPropertyKey {
|
|
11
|
-
ABILITIES = 100
|
|
12
|
-
LUA_INDEX_BY_ABILITY_TYPE_ID = 101
|
|
11
|
+
ABILITIES = 100
|
|
13
12
|
}
|
|
14
13
|
export declare class Item extends Handle<jitem> {
|
|
15
14
|
private readonly [ItemPropertyKey.ABILITIES];
|
|
16
|
-
private readonly [ItemPropertyKey.LUA_INDEX_BY_ABILITY_TYPE_ID];
|
|
17
15
|
constructor(handle: jitem);
|
|
18
16
|
protected onDestroy(): HandleDestructor;
|
|
19
17
|
static create<T extends Item>(this: typeof Item & (new (handle: jitem) => T), id: number, x: number, y: number, skinId?: number): T;
|
package/engine/internal/item.lua
CHANGED
|
@@ -46,9 +46,11 @@ local getItemY = GetItemY
|
|
|
46
46
|
local getItemCharges = GetItemCharges
|
|
47
47
|
local setItemCharges = SetItemCharges
|
|
48
48
|
local unitRemoveAbility = UnitRemoveAbility
|
|
49
|
+
local unitRemoveItem = UnitRemoveItem
|
|
49
50
|
local unitUseItem = UnitUseItem
|
|
50
51
|
local unitUseItemPoint = UnitUseItemPoint
|
|
51
52
|
local unitUseItemTarget = UnitUseItemTarget
|
|
53
|
+
local tableRemove = table.remove
|
|
52
54
|
_G.SetItemCharges = function(whichItem, charges)
|
|
53
55
|
setItemCharges(whichItem, charges)
|
|
54
56
|
invoke(
|
|
@@ -137,15 +139,13 @@ Item.name = "Item"
|
|
|
137
139
|
__TS__ClassExtends(Item, Handle)
|
|
138
140
|
function Item.prototype.____constructor(self, handle)
|
|
139
141
|
Handle.prototype.____constructor(self, handle)
|
|
140
|
-
|
|
141
|
-
self[100] = abilities
|
|
142
|
-
local luaIndexByAbilityTypeId = {}
|
|
143
|
-
for i = 1, #abilities do
|
|
144
|
-
luaIndexByAbilityTypeId[abilities[i].typeId] = i
|
|
145
|
-
end
|
|
146
|
-
self[101] = luaIndexByAbilityTypeId
|
|
142
|
+
self[100] = doAbilityAction(handle, getItemAbilities, self)
|
|
147
143
|
end
|
|
148
144
|
function Item.prototype.onDestroy(self)
|
|
145
|
+
local owner = self.owner
|
|
146
|
+
if owner ~= nil then
|
|
147
|
+
unitRemoveItem(owner.handle, self.handle)
|
|
148
|
+
end
|
|
149
149
|
local abilities = self[100]
|
|
150
150
|
for i = 1, #abilities do
|
|
151
151
|
abilities[i]:destroy()
|
|
@@ -191,33 +191,32 @@ function Item.prototype.addAbility(self, abilityTypeId)
|
|
|
191
191
|
if nativeAbility ~= nil then
|
|
192
192
|
local ability = ItemAbility:of(nativeAbility, abilityTypeId, self)
|
|
193
193
|
local abilities = self[100]
|
|
194
|
-
|
|
195
|
-
abilities[luaIndex] = ability
|
|
196
|
-
self[101][abilityTypeId] = luaIndex
|
|
194
|
+
abilities[#abilities + 1] = ability
|
|
197
195
|
return ability
|
|
198
196
|
end
|
|
199
197
|
return nil
|
|
200
198
|
end
|
|
201
199
|
function Item.prototype.removeAbility(self, abilityTypeId)
|
|
202
|
-
local
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
for j = luaIndex, abilityTypeIdsLength do
|
|
210
|
-
abilities[j] = abilities[j + 1]
|
|
200
|
+
local abilities = self[100]
|
|
201
|
+
for i = 1, #abilities do
|
|
202
|
+
if abilities[i].typeId == abilityTypeId then
|
|
203
|
+
local ability = abilities[i]
|
|
204
|
+
tableRemove(abilities, i)
|
|
205
|
+
ability:destroy()
|
|
206
|
+
return true
|
|
211
207
|
end
|
|
212
208
|
end
|
|
213
|
-
return
|
|
209
|
+
return doAbilityAction(self.handle, itemRemoveAbility, abilityTypeId)
|
|
214
210
|
end
|
|
215
211
|
function Item.prototype.hasAbility(self, abilityTypeId)
|
|
216
|
-
return self
|
|
212
|
+
return doAbilityAction(self.handle, getItemAbility, abilityTypeId) ~= nil
|
|
217
213
|
end
|
|
218
214
|
function Item.prototype.getAbility(self, abilityTypeId)
|
|
219
|
-
|
|
220
|
-
|
|
215
|
+
return ItemAbility:of(
|
|
216
|
+
doAbilityAction(self.handle, getItemAbility, abilityTypeId),
|
|
217
|
+
abilityTypeId,
|
|
218
|
+
self
|
|
219
|
+
)
|
|
221
220
|
end
|
|
222
221
|
function Item.getInRange(self, x, y, range)
|
|
223
222
|
targetCollection = {}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local getLocalClientWidth = BlzGetLocalClientWidth
|
|
3
|
+
local getLocalClientHeight = BlzGetLocalClientHeight
|
|
4
|
+
---
|
|
5
|
+
-- @internal For use by internal systems only.
|
|
6
|
+
____exports.getFrameMinXMaxX = function()
|
|
7
|
+
local w = getLocalClientWidth()
|
|
8
|
+
local h = getLocalClientHeight()
|
|
9
|
+
local width4by3 = (w - h / 600 * 800) / 2
|
|
10
|
+
local pxtodpi = 0.6 / h
|
|
11
|
+
local minX = -width4by3 * pxtodpi
|
|
12
|
+
local maxX = minX + w * pxtodpi
|
|
13
|
+
return minX, maxX
|
|
14
|
+
end
|
|
15
|
+
---
|
|
16
|
+
-- @internal For use by internal systems only.
|
|
17
|
+
____exports.FRAME_MIN_Y = 0
|
|
18
|
+
---
|
|
19
|
+
-- @internal For use by internal systems only.
|
|
20
|
+
____exports.FRAME_MAX_Y = 0.6
|
|
21
|
+
return ____exports
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local getLocationZ = GetLocationZ
|
|
3
|
+
local moveLocation = MoveLocation
|
|
4
|
+
local location = Location(0, 0)
|
|
5
|
+
---
|
|
6
|
+
-- @internal For use by internal systems only.
|
|
7
|
+
____exports.getTerrainZ = function(x, y)
|
|
8
|
+
moveLocation(location, x, y)
|
|
9
|
+
return getLocationZ(location)
|
|
10
|
+
end
|
|
11
|
+
return ____exports
|
|
@@ -438,7 +438,7 @@ rawset(
|
|
|
438
438
|
condition(function()
|
|
439
439
|
local unit = Unit:of(getTriggerUnit())
|
|
440
440
|
if unit ~= nil then
|
|
441
|
-
local ability = unit:
|
|
441
|
+
local ability = unit:getAbility(abilityTypeId)
|
|
442
442
|
if ability ~= nil then
|
|
443
443
|
eventInvoke(event, unit, ability, orderTypeStringId)
|
|
444
444
|
end
|
|
@@ -7,8 +7,8 @@ local UnitAbility = ____ability.UnitAbility
|
|
|
7
7
|
local ____unit = require("engine.internal.unit")
|
|
8
8
|
local Unit = ____unit.Unit
|
|
9
9
|
local ____event = require("event")
|
|
10
|
-
local Event = ____event.Event
|
|
11
10
|
local createDispatchingEvent = ____event.createDispatchingEvent
|
|
11
|
+
local Event = ____event.Event
|
|
12
12
|
local abilityGainedEvent = createDispatchingEvent(
|
|
13
13
|
__TS__New(Event),
|
|
14
14
|
function(unit, ability) return ability.typeId end
|
|
@@ -40,6 +40,15 @@ ItemAbility.onCreate:addListener(
|
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
)
|
|
43
|
+
ItemAbility.destroyEvent:addListener(
|
|
44
|
+
4,
|
|
45
|
+
function(ability)
|
|
46
|
+
local unit = ability.owner.owner
|
|
47
|
+
if unit ~= nil then
|
|
48
|
+
Event.invoke(abilityLostEvent, unit, ability)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
)
|
|
43
52
|
Unit.itemPickedUpEvent:addListener(
|
|
44
53
|
0,
|
|
45
54
|
function(unit, item)
|