warscript 0.0.1-dev.6f480d0 → 0.0.1-dev.6fe4470
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/attributes.d.ts +12 -0
- package/attributes.lua +16 -0
- package/binaryreader.d.ts +1 -0
- package/binaryreader.lua +3 -0
- package/core/types/frame.d.ts +4 -1
- package/core/types/frame.lua +22 -1
- package/core/types/group.d.ts +0 -1
- package/core/types/handle.d.ts +2 -1
- package/core/types/handle.lua +5 -0
- package/core/types/image.d.ts +0 -1
- package/core/types/missile.d.ts +2 -2
- package/core/types/missile.lua +8 -2
- package/core/types/unit.lua +8 -0
- package/decl/index.d.ts +1 -0
- package/engine/ability.d.ts +1 -1
- package/engine/behavior.d.ts +10 -10
- package/engine/behaviour/ability/apply-buff.d.ts +3 -5
- package/engine/behaviour/ability/apply-unit-behavior.d.ts +5 -1
- package/engine/behaviour/ability/damage.d.ts +33 -11
- package/engine/behaviour/ability/damage.lua +89 -31
- package/engine/behaviour/ability/heal.d.ts +33 -6
- package/engine/behaviour/ability/heal.lua +89 -10
- package/engine/behaviour/ability/instant-impact.lua +4 -0
- package/engine/behaviour/ability/restore-mana.d.ts +15 -0
- package/engine/behaviour/ability/restore-mana.lua +29 -0
- package/engine/behaviour/ability.d.ts +8 -1
- package/engine/behaviour/ability.lua +62 -0
- package/engine/behaviour/unit/stun-immunity.d.ts +0 -1
- package/engine/behaviour/unit.d.ts +3 -2
- package/engine/behaviour/unit.lua +7 -0
- package/engine/buff.d.ts +59 -20
- package/engine/buff.lua +232 -72
- package/engine/game-map.d.ts +7 -0
- package/engine/game-map.lua +32 -0
- package/engine/internal/mechanics/ability-duration.d.ts +1 -3
- package/engine/internal/mechanics/ability-duration.lua +2 -0
- package/engine/internal/mechanics/cast-ability.d.ts +2 -0
- package/engine/internal/mechanics/cast-ability.lua +86 -0
- package/engine/internal/unit/bonus.d.ts +5 -6
- package/engine/internal/unit/detach-missiles.d.ts +7 -0
- package/engine/internal/unit/detach-missiles.lua +30 -0
- package/engine/internal/unit+transport.lua +4 -10
- package/engine/internal/unit-missile-launch.lua +1 -1
- package/engine/internal/unit.d.ts +38 -10
- package/engine/internal/unit.lua +249 -88
- package/engine/object-data/auxiliary/attachment-preset.d.ts +0 -1
- package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
- package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
- package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
- package/engine/object-data/entry/ability-type/blink.d.ts +10 -0
- package/engine/object-data/entry/ability-type/blink.lua +39 -0
- package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
- package/engine/object-data/entry/ability-type/mine.d.ts +10 -0
- package/engine/object-data/entry/ability-type/mine.lua +39 -0
- package/engine/object-data/entry/ability-type/spirit-touch.d.ts +2 -2
- package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
- package/engine/object-data/entry/ability-type.d.ts +0 -1
- package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
- package/engine/object-data/entry/buff-type/applicable.lua +27 -71
- package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
- package/engine/object-data/entry/buff-type.d.ts +0 -1
- package/engine/object-data/entry/destructible-type.d.ts +0 -1
- package/engine/object-data/entry/item-type/blank.d.ts +0 -1
- package/engine/object-data/entry/item-type.d.ts +0 -1
- package/engine/object-data/entry/lightning-type.d.ts +0 -1
- package/engine/object-data/entry/unit-type.d.ts +42 -2
- package/engine/object-data/entry/unit-type.lua +378 -50
- package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
- package/engine/object-data/entry/upgrade.d.ts +0 -1
- package/engine/object-data/entry.d.ts +2 -3
- package/engine/object-field/ability.d.ts +18 -1
- package/engine/object-field/ability.lua +50 -0
- package/engine/object-field.d.ts +0 -1
- package/engine/random.d.ts +1 -0
- package/engine/random.lua +9 -0
- package/engine/standard/entries/unit-type.d.ts +42 -1
- package/engine/standard/entries/unit-type.lua +42 -1
- package/engine/standard/fields/ability.d.ts +1 -1
- package/engine/standard/fields/ability.lua +1 -1
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +10 -2
- package/event.d.ts +2 -3
- package/event.lua +9 -5
- package/global/vec2.lua +1 -0
- package/lualib_bundle.lua +146 -42
- package/math/vec2.d.ts +2 -9
- package/math.d.ts +0 -2
- package/objutil/ability.d.ts +0 -1
- package/objutil/buff.d.ts +0 -1
- package/objutil/object.d.ts +0 -1
- package/objutil/unit.d.ts +0 -1
- package/package.json +13 -14
- package/property.d.ts +55 -0
- package/property.lua +374 -0
- package/string.d.ts +30 -0
- package/string.lua +14 -0
- package/util/stream.d.ts +0 -1
- package/utility/arrays.d.ts +3 -4
- package/utility/bit-set.d.ts +0 -2
- package/utility/linked-set.d.ts +11 -3
- package/utility/linked-set.lua +5 -2
- package/utility/lua-maps.d.ts +1 -2
- package/utility/lua-sets.d.ts +1 -2
- package/utility/types.d.ts +3 -2
- package/core/mapbounds.d.ts +0 -8
- package/core/mapbounds.lua +0 -12
package/engine/buff.lua
CHANGED
|
@@ -107,8 +107,26 @@ local buffParametersKeys = {
|
|
|
107
107
|
disablesAutoAttack = true,
|
|
108
108
|
destroysOnDamage = true,
|
|
109
109
|
maximumAutoAttackCount = true,
|
|
110
|
-
|
|
110
|
+
maximumDamageDealtEventCount = true,
|
|
111
|
+
maximumDamageReceivedEventCount = true,
|
|
112
|
+
uniqueGroup = true,
|
|
113
|
+
damageOnExpiration = true,
|
|
114
|
+
healingOnExpiration = true,
|
|
115
|
+
killsOnExpiration = true,
|
|
116
|
+
explodesOnExpiration = true
|
|
111
117
|
}
|
|
118
|
+
local function resolveEnumValue(ability, level, value)
|
|
119
|
+
if value == nil or type(value) == "number" then
|
|
120
|
+
return value
|
|
121
|
+
end
|
|
122
|
+
if ability == nil then
|
|
123
|
+
error(
|
|
124
|
+
__TS__New(IllegalArgumentException),
|
|
125
|
+
0
|
|
126
|
+
)
|
|
127
|
+
end
|
|
128
|
+
return value:getValue(ability, level or ability.level)
|
|
129
|
+
end
|
|
112
130
|
local function resolveNumberValue(ability, level, value)
|
|
113
131
|
if value == nil or type(value) == "number" then
|
|
114
132
|
return value
|
|
@@ -145,7 +163,14 @@ local function resolveAndSetNumberValue(buff, property, ability, level, value, d
|
|
|
145
163
|
buff[property] = resolvedValue
|
|
146
164
|
end
|
|
147
165
|
end
|
|
148
|
-
local buffBooleanParameters = {
|
|
166
|
+
local buffBooleanParameters = {
|
|
167
|
+
"stuns",
|
|
168
|
+
"ignoresStunImmunity",
|
|
169
|
+
"disablesAutoAttack",
|
|
170
|
+
"providesInvulnerability",
|
|
171
|
+
"killsOnExpiration",
|
|
172
|
+
"explodesOnExpiration"
|
|
173
|
+
}
|
|
149
174
|
local buffNumberParameters = {
|
|
150
175
|
"durationIncreaseOnAutoAttack",
|
|
151
176
|
"attackSpeedIncreaseFactor",
|
|
@@ -153,12 +178,16 @@ local buffNumberParameters = {
|
|
|
153
178
|
"armorIncrease",
|
|
154
179
|
"receivedDamageFactor",
|
|
155
180
|
"maximumAutoAttackCount",
|
|
181
|
+
"maximumDamageDealtEventCount",
|
|
182
|
+
"maximumDamageReceivedEventCount",
|
|
156
183
|
"damageInterval",
|
|
157
184
|
"damagePerInterval",
|
|
158
185
|
"damageOverDuration",
|
|
159
186
|
"healingInterval",
|
|
160
187
|
"healingPerInterval",
|
|
161
|
-
"healingOverDuration"
|
|
188
|
+
"healingOverDuration",
|
|
189
|
+
"damageOnExpiration",
|
|
190
|
+
"healingOnExpiration"
|
|
162
191
|
}
|
|
163
192
|
local unsuccessfulApplicationMarker = {}
|
|
164
193
|
local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
|
|
@@ -207,6 +236,7 @@ local function expireBuff(buff)
|
|
|
207
236
|
end
|
|
208
237
|
end
|
|
209
238
|
Timer:run(destroyBuff, buff)
|
|
239
|
+
buff:onExpiration()
|
|
210
240
|
end
|
|
211
241
|
local function buffDamageIntervalInitialTimerCallback(buff)
|
|
212
242
|
buffDamageIntervalTimerCallback(buff)
|
|
@@ -296,8 +326,6 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
|
|
|
296
326
|
end
|
|
297
327
|
end
|
|
298
328
|
self.typeId = typeId
|
|
299
|
-
self.polarity = polarity
|
|
300
|
-
self.resistanceType = resistanceType
|
|
301
329
|
if not __TS__InstanceOf(ability, Ability) then
|
|
302
330
|
parameters = ability
|
|
303
331
|
ability = nil
|
|
@@ -324,6 +352,8 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
|
|
|
324
352
|
learnLevelMinimum = learnLevelMinimum or ability:getField(ABILITY_IF_REQUIRED_LEVEL)
|
|
325
353
|
duration = duration or getAbilityDuration(ability, _unit)
|
|
326
354
|
end
|
|
355
|
+
self.polarity = resolveEnumValue(ability, level, polarity)
|
|
356
|
+
self.resistanceType = resolveEnumValue(ability, level, resistanceType)
|
|
327
357
|
local buffByTypeId = buffByTypeIdByUnit[_unit]
|
|
328
358
|
if buffByTypeId == nil then
|
|
329
359
|
buffByTypeId = {}
|
|
@@ -340,8 +370,8 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
|
|
|
340
370
|
if not internalApplyBuff(
|
|
341
371
|
_unit,
|
|
342
372
|
typeId,
|
|
343
|
-
polarity,
|
|
344
|
-
resistanceType,
|
|
373
|
+
self.polarity,
|
|
374
|
+
self.resistanceType,
|
|
345
375
|
level,
|
|
346
376
|
duration,
|
|
347
377
|
spellStealPriority,
|
|
@@ -530,11 +560,11 @@ function Buff.prototype.onDestroy(self)
|
|
|
530
560
|
behavior:destroy()
|
|
531
561
|
end
|
|
532
562
|
end
|
|
533
|
-
if self[
|
|
563
|
+
if self[136] then
|
|
534
564
|
unit:decrementDisableAutoAttackCounter()
|
|
535
565
|
end
|
|
536
|
-
if self[
|
|
537
|
-
if self[
|
|
566
|
+
if self[134] then
|
|
567
|
+
if self[135] then
|
|
538
568
|
unit:decrementStunCounter()
|
|
539
569
|
end
|
|
540
570
|
unit:decrementStunCounter()
|
|
@@ -583,20 +613,34 @@ function Buff.getByTypeId(self, unit, typeId)
|
|
|
583
613
|
end
|
|
584
614
|
return nil
|
|
585
615
|
end
|
|
586
|
-
function Buff.prototype.
|
|
616
|
+
function Buff.prototype.onExpiration(self)
|
|
587
617
|
local unit = self.unit
|
|
588
618
|
if self[119] ~= nil then
|
|
619
|
+
(self[101] or unit):damageTarget(unit, self[119] or 0)
|
|
620
|
+
end
|
|
621
|
+
if self[120] ~= nil then
|
|
622
|
+
(self[101] or unit):healTarget(unit, self[119] or 0)
|
|
623
|
+
end
|
|
624
|
+
if self[139] then
|
|
625
|
+
unit:explode()
|
|
626
|
+
elseif self[138] then
|
|
627
|
+
unit:kill()
|
|
628
|
+
end
|
|
629
|
+
end
|
|
630
|
+
function Buff.prototype.onDeath(self, source)
|
|
631
|
+
local unit = self.unit
|
|
632
|
+
if self[121] ~= nil then
|
|
589
633
|
damageArea(
|
|
590
634
|
self[101] or unit,
|
|
591
|
-
self[
|
|
635
|
+
self[121],
|
|
592
636
|
unit.x,
|
|
593
637
|
unit.y,
|
|
594
|
-
self[121] or 0,
|
|
595
|
-
self[120] or 0,
|
|
596
638
|
self[123] or 0,
|
|
597
639
|
self[122] or 0,
|
|
598
640
|
self[125] or 0,
|
|
599
|
-
self[124] or 0
|
|
641
|
+
self[124] or 0,
|
|
642
|
+
self[127] or 0,
|
|
643
|
+
self[126] or 0
|
|
600
644
|
)
|
|
601
645
|
end
|
|
602
646
|
end
|
|
@@ -618,9 +662,25 @@ function Buff.prototype.onDamageDealt(self, target, event)
|
|
|
618
662
|
end
|
|
619
663
|
self.remainingDuration = remainingDuration
|
|
620
664
|
end
|
|
621
|
-
local autoAttackCount = (self[
|
|
622
|
-
self[
|
|
623
|
-
if autoAttackCount == self[
|
|
665
|
+
local autoAttackCount = (self[128] or 0) + 1
|
|
666
|
+
self[128] = autoAttackCount
|
|
667
|
+
if autoAttackCount == self[129] then
|
|
668
|
+
self:destroy()
|
|
669
|
+
end
|
|
670
|
+
end
|
|
671
|
+
if event.originalAmount ~= 0 then
|
|
672
|
+
local damageDealtEventCount = (self[130] or 0) + 1
|
|
673
|
+
self[130] = damageDealtEventCount
|
|
674
|
+
if damageDealtEventCount == self[131] then
|
|
675
|
+
self:destroy()
|
|
676
|
+
end
|
|
677
|
+
end
|
|
678
|
+
end
|
|
679
|
+
function Buff.prototype.onDamageReceived(self, source, event)
|
|
680
|
+
if event.originalAmount ~= 0 then
|
|
681
|
+
local damageReceivedEventCount = (self[132] or 0) + 1
|
|
682
|
+
self[132] = damageReceivedEventCount
|
|
683
|
+
if damageReceivedEventCount == self[133] then
|
|
624
684
|
self:destroy()
|
|
625
685
|
end
|
|
626
686
|
end
|
|
@@ -802,6 +862,32 @@ __TS__SetDescriptor(
|
|
|
802
862
|
},
|
|
803
863
|
true
|
|
804
864
|
)
|
|
865
|
+
__TS__SetDescriptor(
|
|
866
|
+
Buff.prototype,
|
|
867
|
+
"damageOnExpiration",
|
|
868
|
+
{
|
|
869
|
+
get = function(self)
|
|
870
|
+
return self[119] or 0
|
|
871
|
+
end,
|
|
872
|
+
set = function(self, damageOnExpiration)
|
|
873
|
+
self[119] = damageOnExpiration ~= 0 and damageOnExpiration or nil
|
|
874
|
+
end
|
|
875
|
+
},
|
|
876
|
+
true
|
|
877
|
+
)
|
|
878
|
+
__TS__SetDescriptor(
|
|
879
|
+
Buff.prototype,
|
|
880
|
+
"healingOnExpiration",
|
|
881
|
+
{
|
|
882
|
+
get = function(self)
|
|
883
|
+
return self[120] or 0
|
|
884
|
+
end,
|
|
885
|
+
set = function(self, healingOnExpiration)
|
|
886
|
+
self[120] = healingOnExpiration ~= 0 and healingOnExpiration or nil
|
|
887
|
+
end
|
|
888
|
+
},
|
|
889
|
+
true
|
|
890
|
+
)
|
|
805
891
|
__TS__SetDescriptor(
|
|
806
892
|
Buff.prototype,
|
|
807
893
|
"receivedDamageFactor",
|
|
@@ -833,25 +919,25 @@ __TS__SetDescriptor(
|
|
|
833
919
|
"stuns",
|
|
834
920
|
{
|
|
835
921
|
get = function(self)
|
|
836
|
-
local
|
|
837
|
-
if
|
|
838
|
-
|
|
922
|
+
local ____self__134_52 = self[134]
|
|
923
|
+
if ____self__134_52 == nil then
|
|
924
|
+
____self__134_52 = false
|
|
839
925
|
end
|
|
840
|
-
return
|
|
926
|
+
return ____self__134_52
|
|
841
927
|
end,
|
|
842
928
|
set = function(self, stuns)
|
|
843
|
-
if not stuns and self[
|
|
844
|
-
if self[
|
|
929
|
+
if not stuns and self[134] then
|
|
930
|
+
if self[135] then
|
|
845
931
|
self.object:decrementStunCounter()
|
|
846
932
|
end
|
|
847
933
|
self.object:decrementStunCounter()
|
|
848
|
-
self[
|
|
849
|
-
elseif stuns and not self[
|
|
850
|
-
if self[
|
|
934
|
+
self[134] = nil
|
|
935
|
+
elseif stuns and not self[134] then
|
|
936
|
+
if self[135] then
|
|
851
937
|
self.object:incrementStunCounter()
|
|
852
938
|
end
|
|
853
939
|
self.object:incrementStunCounter()
|
|
854
|
-
self[
|
|
940
|
+
self[134] = true
|
|
855
941
|
end
|
|
856
942
|
end
|
|
857
943
|
},
|
|
@@ -862,23 +948,23 @@ __TS__SetDescriptor(
|
|
|
862
948
|
"ignoresStunImmunity",
|
|
863
949
|
{
|
|
864
950
|
get = function(self)
|
|
865
|
-
local
|
|
866
|
-
if
|
|
867
|
-
|
|
951
|
+
local ____self__135_53 = self[135]
|
|
952
|
+
if ____self__135_53 == nil then
|
|
953
|
+
____self__135_53 = false
|
|
868
954
|
end
|
|
869
|
-
return
|
|
955
|
+
return ____self__135_53
|
|
870
956
|
end,
|
|
871
957
|
set = function(self, ignoresStunImmunity)
|
|
872
|
-
if not ignoresStunImmunity and self[
|
|
873
|
-
if self[
|
|
958
|
+
if not ignoresStunImmunity and self[135] then
|
|
959
|
+
if self[134] then
|
|
874
960
|
self.object:decrementStunCounter()
|
|
875
961
|
end
|
|
876
|
-
self[
|
|
877
|
-
elseif ignoresStunImmunity and not self[
|
|
878
|
-
if self[
|
|
962
|
+
self[135] = nil
|
|
963
|
+
elseif ignoresStunImmunity and not self[135] then
|
|
964
|
+
if self[134] then
|
|
879
965
|
self.object:incrementStunCounter()
|
|
880
966
|
end
|
|
881
|
-
self[
|
|
967
|
+
self[135] = true
|
|
882
968
|
end
|
|
883
969
|
end
|
|
884
970
|
},
|
|
@@ -889,19 +975,19 @@ __TS__SetDescriptor(
|
|
|
889
975
|
"disablesAutoAttack",
|
|
890
976
|
{
|
|
891
977
|
get = function(self)
|
|
892
|
-
local
|
|
893
|
-
if
|
|
894
|
-
|
|
978
|
+
local ____self__136_54 = self[136]
|
|
979
|
+
if ____self__136_54 == nil then
|
|
980
|
+
____self__136_54 = false
|
|
895
981
|
end
|
|
896
|
-
return
|
|
982
|
+
return ____self__136_54
|
|
897
983
|
end,
|
|
898
984
|
set = function(self, disablesAutoAttack)
|
|
899
|
-
if not disablesAutoAttack and self[
|
|
985
|
+
if not disablesAutoAttack and self[136] then
|
|
900
986
|
self.object:decrementDisableAutoAttackCounter()
|
|
901
|
-
self[
|
|
902
|
-
elseif disablesAutoAttack and not self[
|
|
987
|
+
self[136] = nil
|
|
988
|
+
elseif disablesAutoAttack and not self[136] then
|
|
903
989
|
self.object:incrementDisableAutoAttackCounter()
|
|
904
|
-
self[
|
|
990
|
+
self[136] = true
|
|
905
991
|
end
|
|
906
992
|
end
|
|
907
993
|
},
|
|
@@ -912,19 +998,95 @@ __TS__SetDescriptor(
|
|
|
912
998
|
"providesInvulnerability",
|
|
913
999
|
{
|
|
914
1000
|
get = function(self)
|
|
915
|
-
local
|
|
916
|
-
if
|
|
917
|
-
|
|
1001
|
+
local ____self__137_55 = self[137]
|
|
1002
|
+
if ____self__137_55 == nil then
|
|
1003
|
+
____self__137_55 = false
|
|
918
1004
|
end
|
|
919
|
-
return
|
|
1005
|
+
return ____self__137_55
|
|
920
1006
|
end,
|
|
921
1007
|
set = function(self, providesInvulnerability)
|
|
922
|
-
if not providesInvulnerability and self[
|
|
1008
|
+
if not providesInvulnerability and self[137] then
|
|
923
1009
|
self.object:decrementInvulnerabilityCounter()
|
|
924
|
-
self[
|
|
925
|
-
elseif providesInvulnerability and not self[
|
|
1010
|
+
self[137] = nil
|
|
1011
|
+
elseif providesInvulnerability and not self[137] then
|
|
926
1012
|
self.object:incrementInvulnerabilityCounter()
|
|
927
|
-
self[
|
|
1013
|
+
self[137] = true
|
|
1014
|
+
end
|
|
1015
|
+
end
|
|
1016
|
+
},
|
|
1017
|
+
true
|
|
1018
|
+
)
|
|
1019
|
+
__TS__SetDescriptor(
|
|
1020
|
+
Buff.prototype,
|
|
1021
|
+
"killsOnExpiration",
|
|
1022
|
+
{
|
|
1023
|
+
get = function(self)
|
|
1024
|
+
local ____self__138_56 = self[138]
|
|
1025
|
+
if ____self__138_56 == nil then
|
|
1026
|
+
____self__138_56 = false
|
|
1027
|
+
end
|
|
1028
|
+
return ____self__138_56
|
|
1029
|
+
end,
|
|
1030
|
+
set = function(self, killsOnExpiration)
|
|
1031
|
+
if not killsOnExpiration and self[138] then
|
|
1032
|
+
self[138] = nil
|
|
1033
|
+
elseif killsOnExpiration and not self[138] then
|
|
1034
|
+
self[138] = true
|
|
1035
|
+
end
|
|
1036
|
+
end
|
|
1037
|
+
},
|
|
1038
|
+
true
|
|
1039
|
+
)
|
|
1040
|
+
__TS__SetDescriptor(
|
|
1041
|
+
Buff.prototype,
|
|
1042
|
+
"explodesOnExpiration",
|
|
1043
|
+
{
|
|
1044
|
+
get = function(self)
|
|
1045
|
+
local ____self__139_57 = self[139]
|
|
1046
|
+
if ____self__139_57 == nil then
|
|
1047
|
+
____self__139_57 = false
|
|
1048
|
+
end
|
|
1049
|
+
return ____self__139_57
|
|
1050
|
+
end,
|
|
1051
|
+
set = function(self, killsOnExpiration)
|
|
1052
|
+
if not killsOnExpiration and self[139] then
|
|
1053
|
+
self[139] = nil
|
|
1054
|
+
elseif killsOnExpiration and not self[139] then
|
|
1055
|
+
self[139] = true
|
|
1056
|
+
end
|
|
1057
|
+
end
|
|
1058
|
+
},
|
|
1059
|
+
true
|
|
1060
|
+
)
|
|
1061
|
+
__TS__SetDescriptor(
|
|
1062
|
+
Buff.prototype,
|
|
1063
|
+
"maximumDamageDealtEventCount",
|
|
1064
|
+
{
|
|
1065
|
+
get = function(self)
|
|
1066
|
+
return self[131] or 0
|
|
1067
|
+
end,
|
|
1068
|
+
set = function(self, maximumDamageDealtEventCount)
|
|
1069
|
+
if maximumDamageDealtEventCount == 0 then
|
|
1070
|
+
self[131] = nil
|
|
1071
|
+
else
|
|
1072
|
+
self[131] = maximumDamageDealtEventCount
|
|
1073
|
+
end
|
|
1074
|
+
end
|
|
1075
|
+
},
|
|
1076
|
+
true
|
|
1077
|
+
)
|
|
1078
|
+
__TS__SetDescriptor(
|
|
1079
|
+
Buff.prototype,
|
|
1080
|
+
"maximumDamageReceivedEventCount",
|
|
1081
|
+
{
|
|
1082
|
+
get = function(self)
|
|
1083
|
+
return self[133] or 0
|
|
1084
|
+
end,
|
|
1085
|
+
set = function(self, maximumDamageReceivedEventCount)
|
|
1086
|
+
if maximumDamageReceivedEventCount == 0 then
|
|
1087
|
+
self[133] = nil
|
|
1088
|
+
else
|
|
1089
|
+
self[133] = maximumDamageReceivedEventCount
|
|
928
1090
|
end
|
|
929
1091
|
end
|
|
930
1092
|
},
|
|
@@ -935,13 +1097,13 @@ __TS__SetDescriptor(
|
|
|
935
1097
|
"maximumAutoAttackCount",
|
|
936
1098
|
{
|
|
937
1099
|
get = function(self)
|
|
938
|
-
return self[
|
|
1100
|
+
return self[129] or 0
|
|
939
1101
|
end,
|
|
940
1102
|
set = function(self, maximumAutoAttackCount)
|
|
941
1103
|
if maximumAutoAttackCount == 0 then
|
|
942
|
-
self[
|
|
1104
|
+
self[129] = nil
|
|
943
1105
|
else
|
|
944
|
-
self[
|
|
1106
|
+
self[129] = maximumAutoAttackCount
|
|
945
1107
|
end
|
|
946
1108
|
end
|
|
947
1109
|
},
|
|
@@ -999,13 +1161,13 @@ __TS__SetDescriptor(
|
|
|
999
1161
|
"remainingDuration",
|
|
1000
1162
|
{
|
|
1001
1163
|
get = function(self)
|
|
1002
|
-
local
|
|
1003
|
-
return
|
|
1164
|
+
local ____opt_58 = self._timer
|
|
1165
|
+
return ____opt_58 and ____opt_58.remaining or 0
|
|
1004
1166
|
end,
|
|
1005
1167
|
set = function(self, remainingDuration)
|
|
1006
|
-
local
|
|
1007
|
-
local
|
|
1008
|
-
local remainingDurationDelta =
|
|
1168
|
+
local ____remainingDuration_62 = remainingDuration
|
|
1169
|
+
local ____opt_60 = self._timer
|
|
1170
|
+
local remainingDurationDelta = ____remainingDuration_62 - (____opt_60 and ____opt_60.remaining or 0)
|
|
1009
1171
|
if remainingDurationDelta ~= 0 then
|
|
1010
1172
|
self[102] = self[102] + remainingDurationDelta
|
|
1011
1173
|
if remainingDuration <= 0 then
|
|
@@ -1035,24 +1197,22 @@ __TS__SetDescriptor(
|
|
|
1035
1197
|
true
|
|
1036
1198
|
);
|
|
1037
1199
|
(function(self)
|
|
1200
|
+
local function destroyBuffIfNeeded(buff)
|
|
1201
|
+
if getUnitAbility(buff[100].handle, buff.typeId) ~= buff.handle then
|
|
1202
|
+
buff:destroy()
|
|
1203
|
+
end
|
|
1204
|
+
end
|
|
1038
1205
|
____exports.checkBuff = function(unit, buffTypeId)
|
|
1039
1206
|
local buffByTypeId = buffByTypeIdByUnit[unit]
|
|
1040
1207
|
if buffByTypeId ~= nil then
|
|
1041
1208
|
local buff = buffByTypeId[buffTypeId]
|
|
1042
|
-
if buff ~= nil
|
|
1043
|
-
buff
|
|
1209
|
+
if buff ~= nil then
|
|
1210
|
+
destroyBuffIfNeeded(buff)
|
|
1044
1211
|
end
|
|
1045
1212
|
end
|
|
1046
1213
|
end
|
|
1047
1214
|
____exports.checkBuffs = function(unit)
|
|
1048
|
-
|
|
1049
|
-
if buffByTypeId ~= nil then
|
|
1050
|
-
for ____, buff in pairs(buffByTypeId) do
|
|
1051
|
-
if getUnitAbility(unit.handle, buff.typeId) ~= buff.handle then
|
|
1052
|
-
buff:destroy()
|
|
1053
|
-
end
|
|
1054
|
-
end
|
|
1055
|
-
end
|
|
1215
|
+
____exports.Buff:forAll(unit, destroyBuffIfNeeded)
|
|
1056
1216
|
end
|
|
1057
1217
|
Unit.abilityChannelingStartEvent:addListener(
|
|
1058
1218
|
0,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
4
|
+
local ____exports = {}
|
|
5
|
+
local ____rect = require("core.types.rect")
|
|
6
|
+
local Rect = ____rect.Rect
|
|
7
|
+
local ____region = require("core.types.region")
|
|
8
|
+
local Region = ____region.Region
|
|
9
|
+
____exports.GameMap = __TS__Class()
|
|
10
|
+
local GameMap = ____exports.GameMap
|
|
11
|
+
GameMap.name = "GameMap"
|
|
12
|
+
function GameMap.prototype.____constructor(self)
|
|
13
|
+
end
|
|
14
|
+
__TS__ObjectDefineProperty(
|
|
15
|
+
GameMap,
|
|
16
|
+
"worldBoundsRect",
|
|
17
|
+
{get = function(self)
|
|
18
|
+
local rect = Rect:of(GetWorldBounds())
|
|
19
|
+
rawset(self, "worldBoundsRect", rect)
|
|
20
|
+
return rect
|
|
21
|
+
end}
|
|
22
|
+
)
|
|
23
|
+
__TS__ObjectDefineProperty(
|
|
24
|
+
GameMap,
|
|
25
|
+
"worldBoundsRegion",
|
|
26
|
+
{get = function(self)
|
|
27
|
+
local region = Region:create(self.worldBoundsRect)
|
|
28
|
+
rawset(self, "worldBoundsRegion", region)
|
|
29
|
+
return region
|
|
30
|
+
end}
|
|
31
|
+
)
|
|
32
|
+
return ____exports
|
|
@@ -4,6 +4,8 @@ local UnitClassification = ____unit.UnitClassification
|
|
|
4
4
|
local ____ability = require("engine.standard.fields.ability")
|
|
5
5
|
local DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD = ____ability.DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD
|
|
6
6
|
local DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD = ____ability.DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD
|
|
7
|
+
---
|
|
8
|
+
-- @internal For use by internal systems only.
|
|
7
9
|
____exports.getAbilityDuration = function(ability, target)
|
|
8
10
|
local level = ability.level
|
|
9
11
|
return target ~= nil and target:hasClassification(UnitClassification.RESISTANT) and DURATION_HERO_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level) or DURATION_NORMAL_ABILITY_FLOAT_LEVEL_FIELD:getValue(ability, level)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____ability_2Dtype = require("engine.object-data.entry.ability-type")
|
|
3
|
+
local AbilityType = ____ability_2Dtype.AbilityType
|
|
4
|
+
local ____dummy_2Ditem = require("engine.internal.object-data.dummy-item")
|
|
5
|
+
local DUMMY_ITEM_ID = ____dummy_2Ditem.DUMMY_ITEM_ID
|
|
6
|
+
local ____dummy_2Dunits = require("engine.internal.misc.dummy-units")
|
|
7
|
+
local INVENTORY_DUMMY_NATIVE_UNIT = ____dummy_2Dunits.INVENTORY_DUMMY_NATIVE_UNIT
|
|
8
|
+
local ____preconditions = require("utility.preconditions")
|
|
9
|
+
local checkNotNull = ____preconditions.checkNotNull
|
|
10
|
+
local ____dummy_2Dinventory = require("engine.internal.object-data.dummy-inventory")
|
|
11
|
+
local INVENTORY_ABILITY_TYPE_ID = ____dummy_2Dinventory.INVENTORY_ABILITY_TYPE_ID
|
|
12
|
+
local ____arrays = require("utility.arrays")
|
|
13
|
+
local map = ____arrays.map
|
|
14
|
+
local toLuaSet = ____arrays.toLuaSet
|
|
15
|
+
local createItem = CreateItem
|
|
16
|
+
local getAbilityId = BlzGetAbilityId
|
|
17
|
+
local getItemAbility = BlzGetItemAbility
|
|
18
|
+
local getUnitAbilityByIndex = BlzGetUnitAbilityByIndex
|
|
19
|
+
local itemAddAbility = BlzItemAddAbility
|
|
20
|
+
local setItemBooleanField = BlzSetItemBooleanField
|
|
21
|
+
local removeItem = RemoveItem
|
|
22
|
+
local unitAddAbility = UnitAddAbility
|
|
23
|
+
local unitAddItem = UnitAddItem
|
|
24
|
+
local unitDropItemSlot = UnitDropItemSlot
|
|
25
|
+
local unitInventorySize = UnitInventorySize
|
|
26
|
+
local unitRemoveAbility = UnitRemoveAbility
|
|
27
|
+
local unitRemoveItemFromSlot = UnitRemoveItemFromSlot
|
|
28
|
+
local INVENTORY_ABILITY_TYPE_IDS = postcompile(function()
|
|
29
|
+
return toLuaSet(AbilityType:getAllIdsByBaseIds(map({
|
|
30
|
+
"AInv",
|
|
31
|
+
"Aihn",
|
|
32
|
+
"Aien",
|
|
33
|
+
"Aion",
|
|
34
|
+
"Aiun"
|
|
35
|
+
}, fourCC)))
|
|
36
|
+
end)
|
|
37
|
+
---
|
|
38
|
+
-- @internal For use by internal systems only.
|
|
39
|
+
____exports.castAbility = function(nativeUnit, abilityTypeId, prepareAbility, ...)
|
|
40
|
+
local nativeItem = createItem(DUMMY_ITEM_ID, 0, 0)
|
|
41
|
+
unitAddItem(INVENTORY_DUMMY_NATIVE_UNIT, nativeItem)
|
|
42
|
+
itemAddAbility(nativeItem, abilityTypeId)
|
|
43
|
+
local nativeAbility = checkNotNull(getItemAbility(nativeItem, abilityTypeId))
|
|
44
|
+
if prepareAbility ~= nil then
|
|
45
|
+
prepareAbility(nativeAbility, ...)
|
|
46
|
+
end
|
|
47
|
+
setItemBooleanField(nativeItem, ITEM_BF_ACTIVELY_USED, true)
|
|
48
|
+
setItemBooleanField(nativeItem, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
49
|
+
local success
|
|
50
|
+
if unitAddItem(nativeUnit, nativeItem) then
|
|
51
|
+
success = true
|
|
52
|
+
else
|
|
53
|
+
local latestInventoryAbilityTypeId = 0
|
|
54
|
+
local nativeItemBySlot = {}
|
|
55
|
+
local inventorySize = unitInventorySize(nativeUnit)
|
|
56
|
+
if inventorySize ~= 0 then
|
|
57
|
+
for slot = 0, inventorySize - 1 do
|
|
58
|
+
nativeItemBySlot[slot] = unitRemoveItemFromSlot(nativeUnit, slot)
|
|
59
|
+
end
|
|
60
|
+
local unitNativeAbility = getUnitAbilityByIndex(nativeUnit, 0)
|
|
61
|
+
local i = 1
|
|
62
|
+
while unitNativeAbility ~= nil do
|
|
63
|
+
local abilityTypeId = getAbilityId(unitNativeAbility)
|
|
64
|
+
if INVENTORY_ABILITY_TYPE_IDS[abilityTypeId] ~= nil then
|
|
65
|
+
latestInventoryAbilityTypeId = abilityTypeId
|
|
66
|
+
end
|
|
67
|
+
unitNativeAbility = getUnitAbilityByIndex(nativeUnit, i)
|
|
68
|
+
i = i + 1
|
|
69
|
+
end
|
|
70
|
+
unitRemoveAbility(nativeUnit, latestInventoryAbilityTypeId)
|
|
71
|
+
end
|
|
72
|
+
unitAddAbility(nativeUnit, INVENTORY_ABILITY_TYPE_ID)
|
|
73
|
+
success = unitAddItem(nativeUnit, nativeItem)
|
|
74
|
+
unitRemoveAbility(nativeUnit, INVENTORY_ABILITY_TYPE_ID)
|
|
75
|
+
if latestInventoryAbilityTypeId ~= 0 then
|
|
76
|
+
unitAddAbility(nativeUnit, latestInventoryAbilityTypeId)
|
|
77
|
+
for slot, nativeItem in pairs(nativeItemBySlot) do
|
|
78
|
+
unitAddItem(nativeUnit, nativeItem)
|
|
79
|
+
unitDropItemSlot(nativeUnit, nativeItem, slot)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
removeItem(nativeItem)
|
|
84
|
+
return success
|
|
85
|
+
end
|
|
86
|
+
return ____exports
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="@typescript-to-lua/language-extensions" />
|
|
2
1
|
/** @noSelfInFile */
|
|
3
2
|
import { Unit } from "../unit";
|
|
4
3
|
import { AbilityTypeId } from "../../object-data/entry/ability-type";
|
|
@@ -34,8 +33,8 @@ export declare namespace UnitBonusType {
|
|
|
34
33
|
const DAMAGE: UnitBonusType<UnitDamageBonusId>;
|
|
35
34
|
const RECEIVED_DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
|
|
36
35
|
}
|
|
37
|
-
export declare const addUnitBonus: <Id extends UnitBonusId
|
|
38
|
-
export declare const removeUnitBonus: <Id extends UnitBonusId
|
|
39
|
-
export declare const updateUnitBonus: <Id extends UnitBonusId
|
|
40
|
-
export declare const addOrUpdateOrRemoveUnitBonus: <Id extends UnitBonusId
|
|
41
|
-
export declare const getUnitBonus: <Id extends UnitBonusId
|
|
36
|
+
export declare const addUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, value: number) => Id;
|
|
37
|
+
export declare const removeUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id) => boolean;
|
|
38
|
+
export declare const updateUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id, value: number) => boolean;
|
|
39
|
+
export declare const addOrUpdateOrRemoveUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id | undefined, value: number) => Id | undefined;
|
|
40
|
+
export declare const getUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id) => number;
|