warscript 0.0.1-dev.24ac045 → 0.0.1-dev.256ff3b
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 +10 -12
- package/core/types/player.lua +3 -1
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +79 -5
- package/core/types/timer.d.ts +1 -0
- package/core/types/timer.lua +21 -2
- package/decl/native.d.ts +4 -2
- package/engine/behavior.d.ts +2 -0
- package/engine/behavior.lua +53 -27
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +2 -1
- 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 +33 -11
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.lua +10 -7
- 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 +10 -1
- package/engine/internal/unit-missile-launch.lua +8 -1
- package/engine/internal/unit.d.ts +2 -3
- package/engine/internal/unit.lua +15 -14
- 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/text-tag.d.ts +1 -1
- package/engine/text-tag.lua +91 -17
- package/package.json +2 -2
- package/utility/callback-array.d.ts +13 -0
- package/utility/callback-array.lua +46 -0
- package/utility/functions.d.ts +4 -0
- package/utility/functions.lua +9 -0
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +4 -0
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
|
}
|
|
@@ -13,6 +13,7 @@ local ____ability = require("engine.internal.item.ability")
|
|
|
13
13
|
local abilityActionDummy = ____ability.abilityActionDummy
|
|
14
14
|
local doAbilityAction = ____ability.doAbilityAction
|
|
15
15
|
local doAbilityActionForceDummy = ____ability.doAbilityActionForceDummy
|
|
16
|
+
local doUnitAbilityAction = ____ability.doUnitAbilityAction
|
|
16
17
|
local startItemCooldown = ____ability.startItemCooldown
|
|
17
18
|
local getUnitAbilityLevel = GetUnitAbilityLevel
|
|
18
19
|
local setUnitAbilityLevel = SetUnitAbilityLevel
|
|
@@ -39,6 +40,8 @@ local getItemBooleanField = BlzGetItemBooleanField
|
|
|
39
40
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
40
41
|
local unitHideAbility = BlzUnitHideAbility
|
|
41
42
|
local unitDisableAbility = BlzUnitDisableAbility
|
|
43
|
+
local unitRemoveAbility = UnitRemoveAbility
|
|
44
|
+
local itemRemoveAbility = BlzItemRemoveAbility
|
|
42
45
|
local match = string.match
|
|
43
46
|
local ____type = _G.type
|
|
44
47
|
local ____tostring = _G.tostring
|
|
@@ -232,6 +235,19 @@ ____exports.getOrderIdByAbilityTypeId = function(abilityTypeId)
|
|
|
232
235
|
local parentTypeId = availableFields[abilityTypeId]
|
|
233
236
|
return order2orderId(orders[____type(parentTypeId) == "number" and parentTypeId or abilityTypeId] or "")
|
|
234
237
|
end
|
|
238
|
+
---
|
|
239
|
+
-- @internal For use by internal systems only.
|
|
240
|
+
____exports.abilityTypeHasField = function(abilityTypeId, field)
|
|
241
|
+
field = ____type(field) == "number" and field or getHandleId(field)
|
|
242
|
+
if commonFields[field] then
|
|
243
|
+
return true
|
|
244
|
+
end
|
|
245
|
+
local id = availableFields[abilityTypeId]
|
|
246
|
+
if ____type(id) == "number" then
|
|
247
|
+
id = availableFields[id]
|
|
248
|
+
end
|
|
249
|
+
return not not (id and id[field])
|
|
250
|
+
end
|
|
235
251
|
____exports.Ability = __TS__Class()
|
|
236
252
|
local Ability = ____exports.Ability
|
|
237
253
|
Ability.name = "Ability"
|
|
@@ -247,15 +263,7 @@ function Ability.prototype.getSnapshot(self)
|
|
|
247
263
|
return nil
|
|
248
264
|
end
|
|
249
265
|
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])
|
|
266
|
+
return ____exports.abilityTypeHasField(self.typeId, field)
|
|
259
267
|
end
|
|
260
268
|
function Ability.prototype.getField(self, field, level)
|
|
261
269
|
local fieldType = match(
|
|
@@ -404,16 +412,26 @@ function UnitAbility.prototype.decrementHideCounter(self)
|
|
|
404
412
|
unitHideAbility(self.u, self.typeId, false)
|
|
405
413
|
end
|
|
406
414
|
function UnitAbility.prototype.incrementDisableCounter(self)
|
|
407
|
-
|
|
415
|
+
local unit = self.u
|
|
416
|
+
local typeId = self.typeId
|
|
417
|
+
unitHideAbility(unit, typeId, true)
|
|
418
|
+
unitDisableAbility(unit, typeId, true, false)
|
|
408
419
|
self.d = (self.d or 0) + 1
|
|
409
420
|
end
|
|
410
421
|
function UnitAbility.prototype.decrementDisableCounter(self)
|
|
411
|
-
|
|
422
|
+
local unit = self.u
|
|
423
|
+
local typeId = self.typeId
|
|
424
|
+
unitDisableAbility(unit, typeId, false, false)
|
|
425
|
+
unitHideAbility(unit, typeId, true)
|
|
412
426
|
self.d = (self.d or 0) - 1
|
|
413
427
|
end
|
|
414
428
|
function UnitAbility.prototype.interruptCast(self)
|
|
415
429
|
self.owner:interruptCast(self.typeId)
|
|
416
430
|
end
|
|
431
|
+
function UnitAbility.prototype.onDestroy(self)
|
|
432
|
+
doUnitAbilityAction(self.owner.handle, self.typeId, unitRemoveAbility, self.typeId)
|
|
433
|
+
return UnitAbility.____super.prototype.onDestroy(self)
|
|
434
|
+
end
|
|
417
435
|
__TS__SetDescriptor(
|
|
418
436
|
UnitAbility.prototype,
|
|
419
437
|
"isDisabled",
|
|
@@ -506,6 +524,10 @@ function ItemAbility.prototype.interruptCast(self)
|
|
|
506
524
|
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, true)
|
|
507
525
|
end
|
|
508
526
|
end
|
|
527
|
+
function ItemAbility.prototype.onDestroy(self)
|
|
528
|
+
doAbilityAction(self.owner.handle, itemRemoveAbility, self.typeId)
|
|
529
|
+
return ItemAbility.____super.prototype.onDestroy(self)
|
|
530
|
+
end
|
|
509
531
|
__TS__SetDescriptor(
|
|
510
532
|
ItemAbility.prototype,
|
|
511
533
|
"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",
|
package/engine/internal/item.lua
CHANGED
|
@@ -29,7 +29,6 @@ local ____vec2 = require("math.vec2")
|
|
|
29
29
|
local distance = ____vec2.distance
|
|
30
30
|
local itemChargesChangeEvent = __TS__New(Event)
|
|
31
31
|
local itemAddAbility = BlzItemAddAbility
|
|
32
|
-
local itemRemoveAbility = BlzItemRemoveAbility
|
|
33
32
|
local getItemAbility = BlzGetItemAbility
|
|
34
33
|
local isItemPowerup = IsItemPowerup
|
|
35
34
|
local getItemAbilityByIndex = BlzGetItemAbilityByIndex
|
|
@@ -46,9 +45,11 @@ local getItemY = GetItemY
|
|
|
46
45
|
local getItemCharges = GetItemCharges
|
|
47
46
|
local setItemCharges = SetItemCharges
|
|
48
47
|
local unitRemoveAbility = UnitRemoveAbility
|
|
48
|
+
local unitRemoveItem = UnitRemoveItem
|
|
49
49
|
local unitUseItem = UnitUseItem
|
|
50
50
|
local unitUseItemPoint = UnitUseItemPoint
|
|
51
51
|
local unitUseItemTarget = UnitUseItemTarget
|
|
52
|
+
local tableRemove = table.remove
|
|
52
53
|
_G.SetItemCharges = function(whichItem, charges)
|
|
53
54
|
setItemCharges(whichItem, charges)
|
|
54
55
|
invoke(
|
|
@@ -146,6 +147,10 @@ function Item.prototype.____constructor(self, handle)
|
|
|
146
147
|
self[101] = luaIndexByAbilityTypeId
|
|
147
148
|
end
|
|
148
149
|
function Item.prototype.onDestroy(self)
|
|
150
|
+
local owner = self.owner
|
|
151
|
+
if owner ~= nil then
|
|
152
|
+
unitRemoveItem(owner.handle, self.handle)
|
|
153
|
+
end
|
|
149
154
|
local abilities = self[100]
|
|
150
155
|
for i = 1, #abilities do
|
|
151
156
|
abilities[i]:destroy()
|
|
@@ -201,14 +206,12 @@ end
|
|
|
201
206
|
function Item.prototype.removeAbility(self, abilityTypeId)
|
|
202
207
|
local luaIndexByAbilityTypeId = self[101]
|
|
203
208
|
local luaIndex = luaIndexByAbilityTypeId[abilityTypeId]
|
|
204
|
-
if luaIndex ~= nil
|
|
205
|
-
luaIndexByAbilityTypeId[abilityTypeId] = nil
|
|
209
|
+
if luaIndex ~= nil then
|
|
206
210
|
local abilities = self[100]
|
|
207
211
|
abilities[luaIndex]:destroy()
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
end
|
|
212
|
+
tableRemove(abilities, luaIndex)
|
|
213
|
+
luaIndexByAbilityTypeId[abilityTypeId] = nil
|
|
214
|
+
return true
|
|
212
215
|
end
|
|
213
216
|
return false
|
|
214
217
|
end
|
|
@@ -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
|
|
@@ -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)
|
|
@@ -9,6 +9,8 @@ local ____timer = require("core.types.timer")
|
|
|
9
9
|
local Timer = ____timer.Timer
|
|
10
10
|
local ____lua_2Dsets = require("utility.lua-sets")
|
|
11
11
|
local luaSetOf = ____lua_2Dsets.luaSetOf
|
|
12
|
+
local ____math = require("math")
|
|
13
|
+
local min = ____math.min
|
|
12
14
|
local autoAttackFinishEvent = __TS__New(Event)
|
|
13
15
|
rawset(Unit, "autoAttackFinishEvent", autoAttackFinishEvent)
|
|
14
16
|
local eventTimerByUnit = {}
|
|
@@ -45,7 +47,12 @@ local function timerCallback(source, target)
|
|
|
45
47
|
end
|
|
46
48
|
Unit.autoAttackStartEvent:addListener(function(source, target)
|
|
47
49
|
local attackPoint = (source:chooseWeapon(target) or source.firstWeapon).impactDelay
|
|
48
|
-
local timer = Timer:simple(
|
|
50
|
+
local timer = Timer:simple(
|
|
51
|
+
attackPoint + min(0.001, attackPoint / 2),
|
|
52
|
+
timerCallback,
|
|
53
|
+
source,
|
|
54
|
+
target
|
|
55
|
+
)
|
|
49
56
|
eventTimerByUnit[source] = timer
|
|
50
57
|
end)
|
|
51
58
|
return ____exports
|
|
@@ -160,8 +160,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
160
160
|
isInRangeOf(unit: Unit, range: number): boolean;
|
|
161
161
|
isAllyOf(unit: Unit): boolean;
|
|
162
162
|
isEnemyOf(unit: Unit): boolean;
|
|
163
|
-
playAnimation(animation: string, rarity?: jraritycontrol): void;
|
|
164
|
-
playAnimation(animation: number): void;
|
|
163
|
+
playAnimation(...parameters: [animation: number] | [animation: string, rarity?: jraritycontrol]): void;
|
|
165
164
|
resetAnimation(): void;
|
|
166
165
|
queueAnimation(animation: string): void;
|
|
167
166
|
get weapons(): [UnitWeapon, UnitWeapon];
|
|
@@ -354,7 +353,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
354
353
|
static itemDroppedEvent: UnitTriggerEvent<[Item]>;
|
|
355
354
|
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
356
355
|
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
357
|
-
static itemStackedEvent: UnitTriggerEvent<[Item]>;
|
|
356
|
+
static itemStackedEvent: UnitTriggerEvent<[target: Item, source: Item]>;
|
|
358
357
|
static get itemChargesChangedEvent(): Event<[unit: Unit, item: Item]>;
|
|
359
358
|
static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
|
|
360
359
|
static get itemMoveOrderEvent(): Event<[
|
package/engine/internal/unit.lua
CHANGED
|
@@ -940,16 +940,13 @@ function Unit.prototype.getAbilityById(self, abilityId)
|
|
|
940
940
|
return UnitAbility:of(ability, abilityId, self)
|
|
941
941
|
end
|
|
942
942
|
function Unit.prototype.removeAbility(self, abilityId)
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
return true
|
|
950
|
-
end
|
|
943
|
+
local abilities = self.abilities
|
|
944
|
+
for i = 1, #abilities do
|
|
945
|
+
if abilities[i].typeId == abilityId then
|
|
946
|
+
abilities[i]:destroy()
|
|
947
|
+
tremove(abilities, i)
|
|
948
|
+
return true
|
|
951
949
|
end
|
|
952
|
-
return true
|
|
953
950
|
end
|
|
954
951
|
return false
|
|
955
952
|
end
|
|
@@ -2670,10 +2667,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2670
2667
|
____exports.UnitTriggerEvent,
|
|
2671
2668
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2672
2669
|
function()
|
|
2673
|
-
local
|
|
2674
|
-
local
|
|
2675
|
-
if getUnitTypeId(
|
|
2676
|
-
|
|
2670
|
+
local unitHandle = getTriggerUnit()
|
|
2671
|
+
local itemHandle = getManipulatedItem()
|
|
2672
|
+
if getUnitTypeId(unitHandle) ~= dummyUnitId and not (ignoreEventsItems[itemHandle] ~= nil) then
|
|
2673
|
+
local unit = ____exports.Unit:of(unitHandle)
|
|
2674
|
+
local item = Item:of(itemHandle)
|
|
2675
|
+
if item.owner ~= unit then
|
|
2676
|
+
return unit, item
|
|
2677
|
+
end
|
|
2677
2678
|
end
|
|
2678
2679
|
return IgnoreEvent
|
|
2679
2680
|
end
|
|
@@ -2693,7 +2694,7 @@ Unit.itemUsedEvent = __TS__New(
|
|
|
2693
2694
|
Unit.itemStackedEvent = __TS__New(
|
|
2694
2695
|
____exports.UnitTriggerEvent,
|
|
2695
2696
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2696
|
-
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(
|
|
2697
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(BlzGetStackingItemTarget()), Item:of(BlzGetStackingItemSource()) end
|
|
2697
2698
|
)
|
|
2698
2699
|
__TS__ObjectDefineProperty(
|
|
2699
2700
|
Unit,
|