warscript 0.0.1-dev.d1983c6 → 0.0.1-dev.d1b563b
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 +14 -9
- package/core/types/playerCamera.lua +44 -0
- package/core/types/tileCell.d.ts +9 -0
- package/core/types/tileCell.lua +92 -0
- package/core/types/timer.lua +16 -2
- package/decl/native.d.ts +2 -2
- package/engine/behavior.d.ts +3 -0
- package/engine/behavior.lua +53 -0
- 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/unit/ability.lua +1 -1
- package/engine/internal/unit+ability.lua +10 -1
- package/engine/internal/unit.d.ts +3 -3
- package/engine/internal/unit.lua +19 -17
- 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/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/lua-maps.d.ts +6 -1
- package/utility/lua-maps.lua +20 -2
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 = {}
|
|
@@ -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)
|
|
@@ -271,8 +271,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
271
271
|
setAbilityLevel(abilityId: number, level: number): number;
|
|
272
272
|
getAbilityLevel(abilityId: number): number;
|
|
273
273
|
hasAbility(abilityId: number): boolean;
|
|
274
|
-
|
|
275
|
-
removeAbility(
|
|
274
|
+
getAbility(abilityId: number): UnitAbility | undefined;
|
|
275
|
+
removeAbility(abilityTypeId: number): boolean;
|
|
276
276
|
hideAbility(abilityId: number, flag: boolean): void;
|
|
277
277
|
getAbilityRemainingCooldown(abilityId: number): number;
|
|
278
278
|
startAbilityCooldown(abilityId: number, cooldown: number): void;
|
|
@@ -353,7 +353,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
353
353
|
static itemDroppedEvent: UnitTriggerEvent<[Item]>;
|
|
354
354
|
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
355
355
|
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
356
|
-
static itemStackedEvent: UnitTriggerEvent<[Item]>;
|
|
356
|
+
static itemStackedEvent: UnitTriggerEvent<[target: Item, source: Item]>;
|
|
357
357
|
static get itemChargesChangedEvent(): Event<[unit: Unit, item: Item]>;
|
|
358
358
|
static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
|
|
359
359
|
static get itemMoveOrderEvent(): Event<[
|
package/engine/internal/unit.lua
CHANGED
|
@@ -935,23 +935,21 @@ end
|
|
|
935
935
|
function Unit.prototype.hasAbility(self, abilityId)
|
|
936
936
|
return getUnitAbilityLevel(self.handle, abilityId) > 0
|
|
937
937
|
end
|
|
938
|
-
function Unit.prototype.
|
|
938
|
+
function Unit.prototype.getAbility(self, abilityId)
|
|
939
939
|
local ability = doUnitAbilityAction(self.handle, abilityId, getUnitAbility, abilityId)
|
|
940
940
|
return UnitAbility:of(ability, abilityId, self)
|
|
941
941
|
end
|
|
942
|
-
function Unit.prototype.removeAbility(self,
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
end
|
|
942
|
+
function Unit.prototype.removeAbility(self, abilityTypeId)
|
|
943
|
+
local abilities = self.abilities
|
|
944
|
+
for i = 1, #abilities do
|
|
945
|
+
if abilities[i].typeId == abilityTypeId then
|
|
946
|
+
local ability = abilities[i]
|
|
947
|
+
tremove(abilities, i)
|
|
948
|
+
ability:destroy()
|
|
949
|
+
return true
|
|
951
950
|
end
|
|
952
|
-
return true
|
|
953
951
|
end
|
|
954
|
-
return
|
|
952
|
+
return doUnitAbilityAction(self.handle, abilityTypeId, unitRemoveAbility, abilityTypeId)
|
|
955
953
|
end
|
|
956
954
|
function Unit.prototype.hideAbility(self, abilityId, flag)
|
|
957
955
|
BlzUnitHideAbility(self.handle, abilityId, flag)
|
|
@@ -2670,10 +2668,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2670
2668
|
____exports.UnitTriggerEvent,
|
|
2671
2669
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2672
2670
|
function()
|
|
2673
|
-
local
|
|
2674
|
-
local
|
|
2675
|
-
if getUnitTypeId(
|
|
2676
|
-
|
|
2671
|
+
local unitHandle = getTriggerUnit()
|
|
2672
|
+
local itemHandle = getManipulatedItem()
|
|
2673
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2674
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2675
|
+
local item = Item:of(itemHandle)
|
|
2676
|
+
if item.owner ~= unit then
|
|
2677
|
+
return unit, item
|
|
2678
|
+
end
|
|
2677
2679
|
end
|
|
2678
2680
|
return IgnoreEvent
|
|
2679
2681
|
end
|
|
@@ -2693,7 +2695,7 @@ Unit.itemUsedEvent = __TS__New(
|
|
|
2693
2695
|
Unit.itemStackedEvent = __TS__New(
|
|
2694
2696
|
____exports.UnitTriggerEvent,
|
|
2695
2697
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2696
|
-
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(
|
|
2698
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2697
2699
|
)
|
|
2698
2700
|
__TS__ObjectDefineProperty(
|
|
2699
2701
|
Unit,
|
|
@@ -12,7 +12,7 @@ import { ReadonlyNonEmptyLinkedSet } from "../../utility/linked-set";
|
|
|
12
12
|
export declare abstract class AbilityField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType extends jabilityfield = jabilityfield> extends ObjectField<AbilityType, Ability, ValueType, NativeFieldType> {
|
|
13
13
|
protected get instanceClass(): typeof Ability;
|
|
14
14
|
protected getObjectDataEntryId(instance: Ability): AbilityTypeId;
|
|
15
|
-
protected hasNativeFieldValue(
|
|
15
|
+
protected hasNativeFieldValue(abilityTypeId: AbilityTypeId): boolean;
|
|
16
16
|
static get valueChangeEvent(): ObjectFieldValueChangeEvent<ReadonlyObjectFieldType<AbilityField>>;
|
|
17
17
|
}
|
|
18
18
|
export declare class AbilityBooleanField extends AbilityField<boolean, jabilitybooleanfield> {
|
|
@@ -48,7 +48,7 @@ export declare class AbilityStringField extends AbilityField<string, jabilitystr
|
|
|
48
48
|
export declare abstract class AbilityArrayField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType extends jabilityfield = jabilityfield> extends ObjectArrayField<AbilityType, Ability, ValueType, NativeFieldType> {
|
|
49
49
|
protected get instanceClass(): typeof Ability;
|
|
50
50
|
protected getObjectDataEntryId(instance: Ability): AbilityTypeId;
|
|
51
|
-
protected hasNativeFieldValue(
|
|
51
|
+
protected hasNativeFieldValue(abilityTypeId: AbilityTypeId): boolean;
|
|
52
52
|
}
|
|
53
53
|
export declare class AbilityStringArrayField extends AbilityArrayField<string, jabilitystringlevelfield> {
|
|
54
54
|
protected get defaultValue(): string;
|
|
@@ -68,7 +68,7 @@ export declare abstract class AbilityLevelField<ValueType extends number | strin
|
|
|
68
68
|
protected get instanceClass(): typeof Ability;
|
|
69
69
|
protected getLevelCount(entry: AbilityType | Ability): number;
|
|
70
70
|
protected getObjectDataEntryId(instance: Ability): AbilityTypeId;
|
|
71
|
-
protected hasNativeFieldValue(
|
|
71
|
+
protected hasNativeFieldValue(abilityTypeId: AbilityTypeId): boolean;
|
|
72
72
|
static get valueChangeEvent(): ObjectLevelFieldValueChangeEvent<ReadonlyObjectLevelFieldType<AbilityLevelField>>;
|
|
73
73
|
}
|
|
74
74
|
export declare class AbilityBooleanLevelField extends AbilityLevelField<boolean, boolean, jabilityintegerlevelfield> {
|
|
@@ -7,6 +7,7 @@ local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
|
7
7
|
local ____exports = {}
|
|
8
8
|
local ____ability = require("engine.internal.ability")
|
|
9
9
|
local Ability = ____ability.Ability
|
|
10
|
+
local abilityTypeHasField = ____ability.abilityTypeHasField
|
|
10
11
|
local ____object_2Dfield = require("engine.object-field")
|
|
11
12
|
local ObjectArrayField = ____object_2Dfield.ObjectArrayField
|
|
12
13
|
local ObjectField = ____object_2Dfield.ObjectField
|
|
@@ -29,8 +30,8 @@ __TS__ClassExtends(AbilityField, ObjectField)
|
|
|
29
30
|
function AbilityField.prototype.getObjectDataEntryId(self, instance)
|
|
30
31
|
return instance.typeId
|
|
31
32
|
end
|
|
32
|
-
function AbilityField.prototype.hasNativeFieldValue(self,
|
|
33
|
-
return
|
|
33
|
+
function AbilityField.prototype.hasNativeFieldValue(self, abilityTypeId)
|
|
34
|
+
return abilityTypeHasField(abilityTypeId, self.nativeField)
|
|
34
35
|
end
|
|
35
36
|
__TS__SetDescriptor(
|
|
36
37
|
AbilityField.prototype,
|
|
@@ -197,8 +198,8 @@ __TS__ClassExtends(AbilityArrayField, ObjectArrayField)
|
|
|
197
198
|
function AbilityArrayField.prototype.getObjectDataEntryId(self, instance)
|
|
198
199
|
return instance.typeId
|
|
199
200
|
end
|
|
200
|
-
function AbilityArrayField.prototype.hasNativeFieldValue(self,
|
|
201
|
-
return
|
|
201
|
+
function AbilityArrayField.prototype.hasNativeFieldValue(self, abilityTypeId)
|
|
202
|
+
return abilityTypeHasField(abilityTypeId, self.nativeField)
|
|
202
203
|
end
|
|
203
204
|
__TS__SetDescriptor(
|
|
204
205
|
AbilityArrayField.prototype,
|
|
@@ -269,8 +270,8 @@ end
|
|
|
269
270
|
function AbilityLevelField.prototype.getObjectDataEntryId(self, instance)
|
|
270
271
|
return instance.typeId
|
|
271
272
|
end
|
|
272
|
-
function AbilityLevelField.prototype.hasNativeFieldValue(self,
|
|
273
|
-
return
|
|
273
|
+
function AbilityLevelField.prototype.hasNativeFieldValue(self, abilityTypeId)
|
|
274
|
+
return abilityTypeHasField(abilityTypeId, self.nativeField)
|
|
274
275
|
end
|
|
275
276
|
__TS__SetDescriptor(
|
|
276
277
|
AbilityLevelField.prototype,
|