warscript 0.0.1-dev.d63794c → 0.0.1-dev.d750e38

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.
@@ -7,6 +7,9 @@ local AbilityBehavior = ____ability.AbilityBehavior
7
7
  local ____ability = require("engine.standard.fields.ability")
8
8
  local COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD = ____ability.COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD
9
9
  local MANA_COST_ABILITY_INTEGER_LEVEL_FIELD = ____ability.MANA_COST_ABILITY_INTEGER_LEVEL_FIELD
10
+ local ____math = require("math")
11
+ local max = ____math.max
12
+ local MINIMUM_POSITIVE_NORMALIZED_FLOAT = ____math.MINIMUM_POSITIVE_NORMALIZED_FLOAT
10
13
  ____exports.EmulateImpactAbilityBehavior = __TS__Class()
11
14
  local EmulateImpactAbilityBehavior = ____exports.EmulateImpactAbilityBehavior
12
15
  EmulateImpactAbilityBehavior.name = "EmulateImpactAbilityBehavior"
@@ -18,11 +21,7 @@ function EmulateImpactAbilityBehavior.prototype.emulateImpact(self, caster)
18
21
  return
19
22
  end
20
23
  caster.mana = caster.mana - manaCost
21
- if cooldown == 0 then
22
- self.ability:interruptCast()
23
- else
24
- self.ability.cooldownRemaining = cooldown
25
- end
24
+ self.ability.cooldownRemaining = max(cooldown, MINIMUM_POSITIVE_NORMALIZED_FLOAT)
26
25
  self:flashCasterEffect(caster)
27
26
  AbilityBehavior:forAll(self.ability, "onImpact", caster)
28
27
  end
@@ -2,6 +2,8 @@ local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
3
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
4
  local ____exports = {}
5
+ local ____unit = require("engine.internal.unit")
6
+ local Unit = ____unit.Unit
5
7
  local ____emulate_2Dimpact = require("engine.behaviour.ability.emulate-impact")
6
8
  local EmulateImpactAbilityBehavior = ____emulate_2Dimpact.EmulateImpactAbilityBehavior
7
9
  ____exports.OnCommandImpactAbilityBehavior = __TS__Class()
@@ -15,4 +17,9 @@ end
15
17
  function OnCommandImpactAbilityBehavior.prototype.onCommand(self, caster)
16
18
  self:emulateImpact(caster)
17
19
  end
20
+ Unit.itemUseOrderEvent:addListener(function(unit, item)
21
+ for ____, ability in ipairs(item.abilities) do
22
+ ____exports.OnCommandImpactAbilityBehavior:forAll(ability, "onCommand", unit)
23
+ end
24
+ end)
18
25
  return ____exports
@@ -7,7 +7,8 @@ import { Widget } from "../../core/types/widget";
7
7
  import { Item } from "../internal/item";
8
8
  import { Destructable } from "../../core/types/destructable";
9
9
  import { EffectParameters } from "../../core/types/effect";
10
- import { AbilityDependentValue } from "../object-field/ability";
10
+ import { AbilityDependentValue, ReadonlySubscribableAbilityDependentValue, SubscribableAbilityDependentValue } from "../object-field/ability";
11
+ import { Destructor } from "../../destroyable";
11
12
  export type AbilityBehaviorConstructor<Args extends any[]> = new (ability: Ability, ...args: Args) => AbilityBehavior;
12
13
  export type AbilityBehaviorParameters = {
13
14
  isExclusiveOnImpactHandler?: boolean;
@@ -17,6 +18,8 @@ export declare abstract class AbilityBehavior<Parameters extends {
17
18
  missileParameters?: any[];
18
19
  } = {}> extends Behavior<Ability, NonNullable<Parameters["periodicActionParameters"]>> {
19
20
  constructor(ability: Ability, parameters?: AbilityBehaviorParameters);
21
+ protected onDestroy(): Destructor;
22
+ protected subscribe<T extends boolean | number | string>(value: SubscribableAbilityDependentValue<T>): void;
20
23
  protected registerCommandEvent(orderTypeStringId?: string): void;
21
24
  get ability(): Ability;
22
25
  protected resolveCurrentAbilityDependentValue<T extends boolean | number | string>(value: AbilityDependentValue<T>): T;
@@ -28,6 +31,7 @@ export declare abstract class AbilityBehavior<Parameters extends {
28
31
  private static MissileLaunchConfig;
29
32
  private get missileLaunchConfig();
30
33
  protected onCreate(): void;
34
+ onValueChange(_value: ReadonlySubscribableAbilityDependentValue<string | number | boolean>): void;
31
35
  onMissileArrival(...parameters: NonNullable<Parameters["missileParameters"]>): void;
32
36
  onUnitGainAbility(_unit: Unit): void;
33
37
  onUnitLoseAbility(_unit: Unit): void;
@@ -1,6 +1,7 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
3
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
+ local __TS__InstanceOf = ____lualib.__TS__InstanceOf
4
5
  local __TS__New = ____lualib.__TS__New
5
6
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
6
7
  local ____exports = {}
@@ -24,6 +25,8 @@ local MISSILE_SPEED_ABILITY_INTEGER_FIELD = ____ability.MISSILE_SPEED_ABILITY_IN
24
25
  local SPECIAL_EFFECT_ATTACHMENT_POINT_STRING_FIELD = ____ability.SPECIAL_EFFECT_ATTACHMENT_POINT_STRING_FIELD
25
26
  local SPECIAL_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD = ____ability.SPECIAL_EFFECT_MODEL_PATHS_ABILITY_STRING_ARRAY_FIELD
26
27
  local ____ability = require("engine.object-field.ability")
28
+ local AbilityField = ____ability.AbilityField
29
+ local AbilityLevelField = ____ability.AbilityLevelField
27
30
  local resolveCurrentAbilityDependentValue = ____ability.resolveCurrentAbilityDependentValue
28
31
  local ____timer = require("core.types.timer")
29
32
  local Timer = ____timer.Timer
@@ -41,6 +44,7 @@ createUnitEventListener = function(key)
41
44
  end
42
45
  end
43
46
  local registeredCommandEventIds = {}
47
+ local subscribedValuesByAbilityBehavior = {}
44
48
  local ____class_2 = __TS__Class()
45
49
  ____class_2.name = ""
46
50
  function ____class_2.prototype.____constructor(self, abilityBehavior)
@@ -81,6 +85,20 @@ function AbilityBehavior.prototype.____constructor(self, ability, parameters)
81
85
  end
82
86
  self:onCreate()
83
87
  end
88
+ function AbilityBehavior.prototype.onDestroy(self)
89
+ subscribedValuesByAbilityBehavior[self] = nil
90
+ return Behavior.prototype.onDestroy(self)
91
+ end
92
+ function AbilityBehavior.prototype.subscribe(self, value)
93
+ if __TS__InstanceOf(value, AbilityField) or __TS__InstanceOf(value, AbilityLevelField) then
94
+ local subscribedValues = subscribedValuesByAbilityBehavior[self]
95
+ if subscribedValues == nil then
96
+ subscribedValues = {}
97
+ subscribedValuesByAbilityBehavior[self] = subscribedValues
98
+ end
99
+ subscribedValues[value] = true
100
+ end
101
+ end
84
102
  function AbilityBehavior.prototype.registerCommandEvent(self, orderTypeStringId)
85
103
  if orderTypeStringId == nil then
86
104
  orderTypeStringId = self.ability.orderTypeStringId
@@ -137,6 +155,8 @@ function AbilityBehavior.prototype.flashSpecialEffect(self, xOrWidget, yOrDurati
137
155
  end
138
156
  function AbilityBehavior.prototype.onCreate(self)
139
157
  end
158
+ function AbilityBehavior.prototype.onValueChange(self, _value)
159
+ end
140
160
  function AbilityBehavior.prototype.onMissileArrival(self, ...)
141
161
  end
142
162
  function AbilityBehavior.prototype.onUnitGainAbility(self, _unit)
@@ -237,6 +257,18 @@ __TS__SetDescriptor(
237
257
  Unit.abilityChannelingFinishEvent:addListener(createUnitEventListener("onChannelingFinish"))
238
258
  Unit.abilityStopEvent:addListener(createUnitEventListener("onStop"))
239
259
  end)(AbilityBehavior)
260
+ local function checkBehaviorOnValueChange(behavior, field)
261
+ local subscribedValues = subscribedValuesByAbilityBehavior[behavior]
262
+ if subscribedValues ~= nil and subscribedValues[field] ~= nil then
263
+ behavior:onValueChange(field)
264
+ end
265
+ end
266
+ AbilityField.valueChangeEvent:addListener(function(ability, field)
267
+ ____exports.AbilityBehavior:forAll(ability, checkBehaviorOnValueChange, field)
268
+ end)
269
+ AbilityLevelField.valueChangeEvent:addListener(function(ability, field)
270
+ ____exports.AbilityBehavior:forAll(ability, checkBehaviorOnValueChange, field)
271
+ end)
240
272
  Ability.onCreate:addListener(function(ability)
241
273
  local createBehaviorFunctions = createBehaviorFunctionsByAbilityTypeId[ability.typeId]
242
274
  if createBehaviorFunctions ~= nil then
@@ -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 startItemCooldown = ____ability.startItemCooldown
16
17
  local getUnitAbilityLevel = GetUnitAbilityLevel
17
18
  local setUnitAbilityLevel = SetUnitAbilityLevel
18
19
  local setAbilityIntegerField = BlzSetAbilityIntegerField
@@ -34,6 +35,8 @@ local getAbilityStringLevelField = BlzGetAbilityStringLevelField
34
35
  local getUnitAbilityCooldownRemaining = BlzGetUnitAbilityCooldownRemaining
35
36
  local startUnitAbilityCooldown = BlzStartUnitAbilityCooldown
36
37
  local getHandleId = GetHandleId
38
+ local getItemBooleanField = BlzGetItemBooleanField
39
+ local setItemBooleanField = BlzSetItemBooleanField
37
40
  local unitHideAbility = BlzUnitHideAbility
38
41
  local match = string.match
39
42
  local ____type = _G.type
@@ -451,11 +454,6 @@ end
451
454
  local function getAbilityCooldown(_, abilityTypeId)
452
455
  return getUnitAbilityCooldownRemaining(abilityActionDummy, abilityTypeId)
453
456
  end
454
- local function startAbilityCooldown(_, abilityTypeId, cooldown)
455
- startUnitAbilityCooldown(abilityActionDummy, abilityTypeId, cooldown)
456
- end
457
- local function doNothing()
458
- end
459
457
  ____exports.ItemAbility = __TS__Class()
460
458
  local ItemAbility = ____exports.ItemAbility
461
459
  ItemAbility.name = "ItemAbility"
@@ -484,11 +482,12 @@ function ItemAbility.prototype.setField(self, field, levelOrValue, value)
484
482
  )
485
483
  end
486
484
  function ItemAbility.prototype.interruptCast(self)
487
- local item = self.owner
488
- local ____doAbilityActionForceDummy_4 = doAbilityActionForceDummy
489
- local ____item_handle_3 = item.handle
490
- local ____opt_1 = item.owner
491
- ____doAbilityActionForceDummy_4(____item_handle_3, ____opt_1 and ____opt_1.handle, doNothing)
485
+ local handle = self.owner.handle
486
+ local activelyUsed = getItemBooleanField(handle, ITEM_BF_ACTIVELY_USED)
487
+ if activelyUsed then
488
+ setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, false)
489
+ setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, true)
490
+ end
492
491
  end
493
492
  __TS__SetDescriptor(
494
493
  ItemAbility.prototype,
@@ -504,23 +503,17 @@ __TS__SetDescriptor(
504
503
  {
505
504
  get = function(self)
506
505
  local item = self.owner
507
- local ____doAbilityActionForceDummy_8 = doAbilityActionForceDummy
508
- local ____item_handle_7 = item.handle
509
- local ____opt_5 = item.owner
510
- return ____doAbilityActionForceDummy_8(____item_handle_7, ____opt_5 and ____opt_5.handle, getAbilityCooldown, self.typeId)
506
+ local ____doAbilityActionForceDummy_4 = doAbilityActionForceDummy
507
+ local ____item_handle_3 = item.handle
508
+ local ____opt_1 = item.owner
509
+ return ____doAbilityActionForceDummy_4(____item_handle_3, ____opt_1 and ____opt_1.handle, getAbilityCooldown, self.typeId)
511
510
  end,
512
511
  set = function(self, cooldownRemaining)
513
512
  local item = self.owner
514
- local ____doAbilityActionForceDummy_12 = doAbilityActionForceDummy
515
- local ____item_handle_11 = item.handle
516
- local ____opt_9 = item.owner
517
- ____doAbilityActionForceDummy_12(
518
- ____item_handle_11,
519
- ____opt_9 and ____opt_9.handle,
520
- startAbilityCooldown,
521
- self.typeId,
522
- cooldownRemaining
523
- )
513
+ local ____startItemCooldown_8 = startItemCooldown
514
+ local ____item_handle_7 = item.handle
515
+ local ____opt_5 = item.owner
516
+ ____startItemCooldown_8(____item_handle_7, ____opt_5 and ____opt_5.handle, cooldownRemaining)
524
517
  end
525
518
  },
526
519
  true
@@ -1,19 +1,60 @@
1
1
  local ____exports = {}
2
+ local restoreCooldownGroup
2
3
  local ____player = require("core.types.player")
3
4
  local Player = ____player.Player
4
5
  local ____dummy = require("objutil.dummy")
5
6
  local dummyUnitId = ____dummy.dummyUnitId
6
7
  local ____utility = require("engine.internal.utility")
7
8
  local findUnitItemSlot = ____utility.findUnitItemSlot
9
+ local ____blank = require("engine.object-data.entry.item-type.blank")
10
+ local BlankItemType = ____blank.BlankItemType
11
+ local ____object_2Ddata_2Dentry_2Did_2Dgenerator = require("engine.object-data.utility.object-data-entry-id-generator")
12
+ local abilityTypeIdGenerator = ____object_2Ddata_2Dentry_2Did_2Dgenerator.abilityTypeIdGenerator
13
+ local ____math = require("math")
14
+ local MINIMUM_POSITIVE_NORMALIZED_FLOAT = ____math.MINIMUM_POSITIVE_NORMALIZED_FLOAT
15
+ local ____timer = require("core.types.timer")
16
+ local Timer = ____timer.Timer
17
+ local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
18
+ local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
19
+ local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
20
+ local unitAddItemToSlot = ____add_2Ditem_2Dto_2Dslot.unitAddItemToSlot
8
21
  local isItemOwned = IsItemOwned
9
22
  local isItemPowerup = IsItemPowerup
10
23
  local getItemX = GetItemX
11
24
  local getItemY = GetItemY
25
+ local setAbilityRealLevelField = BlzSetAbilityRealLevelField
26
+ local setItemIntegerField = BlzSetItemIntegerField
27
+ local getItemIntegerField = BlzGetItemIntegerField
12
28
  local setItemBooleanField = BlzSetItemBooleanField
13
29
  local setItemPosition = SetItemPosition
14
30
  local unitAddItem = UnitAddItem
15
- local unitDropItemSlot = UnitDropItemSlot
16
31
  local unitRemoveItem = UnitRemoveItem
32
+ local unitUseItem = UnitUseItem
33
+ local unitResetCooldown = UnitResetCooldown
34
+ local COOLDOWN_STARTER_ABILITY_TYPE_ID = compiletime(function()
35
+ if not currentMap then
36
+ return 0
37
+ end
38
+ local abilityType = currentMap.objects.ability:newObject(
39
+ util.id2s(abilityTypeIdGenerator:next()),
40
+ "Absk"
41
+ )
42
+ abilityType["bsk1+0"] = 0
43
+ abilityType["bsk2+0"] = 0
44
+ abilityType["bsk3+0"] = 0
45
+ abilityType["amcs+0"] = 0
46
+ abilityType["adur+0"] = MINIMUM_POSITIVE_NORMALIZED_FLOAT
47
+ abilityType["ahdu+0"] = MINIMUM_POSITIVE_NORMALIZED_FLOAT
48
+ return util.s2id(abilityType.id)
49
+ end)
50
+ local COOLDOWN_STARTER_ITEM_TYPE_ID = compiletime(function()
51
+ local itemType = BlankItemType:create()
52
+ itemType.name = "[Warscript/Dummy] Item Cooldown Starter"
53
+ itemType.abilityTypeIds = {COOLDOWN_STARTER_ABILITY_TYPE_ID}
54
+ itemType.cooldownGroupId = COOLDOWN_STARTER_ABILITY_TYPE_ID
55
+ itemType.activelyUsed = true
56
+ return itemType.id
57
+ end)
17
58
  local dummy = assert(CreateUnit(
18
59
  Player.neutralVictim.handle,
19
60
  dummyUnitId,
@@ -21,13 +62,37 @@ local dummy = assert(CreateUnit(
21
62
  0,
22
63
  270
23
64
  ))
65
+ local cooldownStarterItem = UnitAddItemById(dummy, COOLDOWN_STARTER_ITEM_TYPE_ID)
66
+ local cooldownStarterAbility = BlzGetItemAbility(cooldownStarterItem, COOLDOWN_STARTER_ABILITY_TYPE_ID)
24
67
  ShowUnit(dummy, false)
68
+ local function startItemCooldownInternal(handle, cooldown)
69
+ local cooldownGroup = getItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP)
70
+ setItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP, COOLDOWN_STARTER_ABILITY_TYPE_ID)
71
+ setAbilityRealLevelField(cooldownStarterAbility, ABILITY_RLF_COOLDOWN, 0, cooldown)
72
+ unitResetCooldown(dummy)
73
+ unitUseItem(dummy, cooldownStarterItem)
74
+ Timer:run(restoreCooldownGroup, handle, cooldownGroup)
75
+ end
76
+ restoreCooldownGroup = function(handle, cooldownGroup)
77
+ if getItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP) == COOLDOWN_STARTER_ABILITY_TYPE_ID then
78
+ setItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP, cooldownGroup)
79
+ end
80
+ end
81
+ ---
82
+ -- @internal For use by internal systems only.
83
+ ____exports.startItemCooldown = function(handle, owner, cooldown)
84
+ ____exports.doAbilityActionForceDummy(handle, owner, startItemCooldownInternal, cooldown)
85
+ end
25
86
  ---
26
87
  -- @internal For use by internal systems only.
27
88
  ____exports.abilityActionDummy = dummy
28
89
  ---
29
90
  -- @internal For use by internal systems only.
30
91
  ____exports.doAbilityAction = function(handle, action, ...)
92
+ local isAlreadyIgnoredInEvents = ignoreEventsItems[handle] ~= nil
93
+ if not isAlreadyIgnoredInEvents then
94
+ ignoreEventsItems[handle] = true
95
+ end
31
96
  local isOwned = isItemOwned(handle)
32
97
  local isPowerup
33
98
  local x
@@ -49,6 +114,9 @@ ____exports.doAbilityAction = function(handle, action, ...)
49
114
  setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
50
115
  end
51
116
  end
117
+ if not isAlreadyIgnoredInEvents then
118
+ ignoreEventsItems[handle] = nil
119
+ end
52
120
  return result
53
121
  end
54
122
  ---
@@ -61,6 +129,10 @@ ____exports.doAbilityActionForceDummy = function(handle, owner, action, ...)
61
129
  if slot == nil then
62
130
  return ____exports.doAbilityAction(handle, action, ...)
63
131
  end
132
+ local isAlreadyIgnoredInEvents = ignoreEventsItems[handle] ~= nil
133
+ if not isAlreadyIgnoredInEvents then
134
+ ignoreEventsItems[handle] = true
135
+ end
64
136
  local isPowerup
65
137
  if isItemPowerup(handle) then
66
138
  setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
@@ -70,11 +142,13 @@ ____exports.doAbilityActionForceDummy = function(handle, owner, action, ...)
70
142
  unitAddItem(dummy, handle)
71
143
  local result = action(handle, ...)
72
144
  unitRemoveItem(dummy, handle)
73
- unitAddItem(owner, handle)
74
- unitDropItemSlot(owner, handle, slot)
145
+ unitAddItemToSlot(owner, handle, slot)
75
146
  if isPowerup then
76
147
  setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
77
148
  end
149
+ if not isAlreadyIgnoredInEvents then
150
+ ignoreEventsItems[handle] = nil
151
+ end
78
152
  return result
79
153
  end
80
154
  return ____exports
@@ -0,0 +1,2 @@
1
+ /** @noSelfInFile */
2
+ export {};
@@ -0,0 +1,23 @@
1
+ local ____exports = {}
2
+ local ____unit = require("engine.internal.unit")
3
+ local Unit = ____unit.Unit
4
+ local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
5
+ local fillerItems = ____add_2Ditem_2Dto_2Dslot.fillerItems
6
+ local unitsWithFillerItems = ____add_2Ditem_2Dto_2Dslot.unitsWithFillerItems
7
+ local setItemVisible = SetItemVisible
8
+ local unitRemoveItem = UnitRemoveItem
9
+ Unit.itemPickedUpEvent:addListener(
10
+ 4,
11
+ function(unit)
12
+ local handle = unit.handle
13
+ if unitsWithFillerItems[handle] ~= nil then
14
+ for previousSlot = 1, 6 do
15
+ local fillerItem = fillerItems[previousSlot]
16
+ unitRemoveItem(handle, fillerItem)
17
+ setItemVisible(fillerItem, false)
18
+ end
19
+ unitsWithFillerItems[handle] = nil
20
+ end
21
+ end
22
+ )
23
+ return ____exports
@@ -0,0 +1,2 @@
1
+ /** @noSelfInFile */
2
+ export {};
@@ -0,0 +1,50 @@
1
+ local ____exports = {}
2
+ local ____blank = require("engine.object-data.entry.item-type.blank")
3
+ local BlankItemType = ____blank.BlankItemType
4
+ local ____arrays = require("utility.arrays")
5
+ local array = ____arrays.array
6
+ local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
7
+ local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
8
+ local setItemVisible = SetItemVisible
9
+ local unitAddItem = UnitAddItem
10
+ local unitItemInSlot = UnitItemInSlot
11
+ local unitRemoveItem = UnitRemoveItem
12
+ local FILLER_ITEM_TYPE_ID = compiletime(function()
13
+ local itemType = BlankItemType:create()
14
+ itemType.name = "[Warscript/Dummy] Slot Filler"
15
+ return itemType.id
16
+ end)
17
+ ---
18
+ -- @internal For use by internal systems only.
19
+ ____exports.fillerItems = array(
20
+ 6,
21
+ function()
22
+ local item = CreateItem(FILLER_ITEM_TYPE_ID, 0, 0)
23
+ setItemVisible(item, false)
24
+ ignoreEventsItems[item] = true
25
+ return item
26
+ end
27
+ )
28
+ ---
29
+ -- @internal For use by internal systems only.
30
+ ____exports.unitsWithFillerItems = {}
31
+ ---
32
+ -- @internal For use by internal systems only.
33
+ ____exports.unitAddItemToSlot = function(unit, item, slot)
34
+ for previousSlot = 0, slot - 1 do
35
+ if unitItemInSlot(unit, previousSlot) == nil then
36
+ unitAddItem(unit, ____exports.fillerItems[previousSlot + 1])
37
+ ____exports.unitsWithFillerItems[unit] = true
38
+ end
39
+ end
40
+ unitAddItem(unit, item)
41
+ if ____exports.unitsWithFillerItems[unit] ~= nil then
42
+ for previousSlot = 0, slot - 1 do
43
+ local fillerItem = ____exports.fillerItems[previousSlot + 1]
44
+ unitRemoveItem(unit, fillerItem)
45
+ setItemVisible(fillerItem, false)
46
+ end
47
+ ____exports.unitsWithFillerItems[unit] = nil
48
+ end
49
+ end
50
+ return ____exports
@@ -0,0 +1,2 @@
1
+ /** @noSelfInFile */
2
+ export {};
@@ -0,0 +1,5 @@
1
+ local ____exports = {}
2
+ ---
3
+ -- @internal For use by internal systems only.
4
+ ____exports.ignoreEventsItems = {}
5
+ return ____exports
@@ -9,12 +9,12 @@ local ____unit = require("engine.internal.unit")
9
9
  local Unit = ____unit.Unit
10
10
  local ____utility = require("engine.internal.utility")
11
11
  local findUnitItemSlot = ____utility.findUnitItemSlot
12
+ local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
13
+ local unitAddItemToSlot = ____add_2Ditem_2Dto_2Dslot.unitAddItemToSlot
12
14
  local rawset = _G.rawset
13
15
  local ____type = _G.type
14
16
  local isItemPowerup = IsItemPowerup
15
17
  local setItemBooleanField = BlzSetItemBooleanField
16
- local unitAddItem = UnitAddItem
17
- local unitDropItemSlot = UnitDropItemSlot
18
18
  local unitInventorySize = UnitInventorySize
19
19
  local unitItemInSlot = UnitItemInSlot
20
20
  local unitRemoveItemFromSlot = UnitRemoveItemFromSlot
@@ -47,8 +47,7 @@ function UnitItems.prototype.__newindex(self, slot, item)
47
47
  if isPowerup then
48
48
  setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
49
49
  end
50
- unitAddItem(handle, itemHandle)
51
- unitDropItemSlot(handle, itemHandle, slot - 1)
50
+ unitAddItemToSlot(handle, itemHandle, slot - 1)
52
51
  if isPowerup then
53
52
  setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
54
53
  end
@@ -133,6 +133,7 @@ export declare class Unit extends Handle<junit> {
133
133
  get isAlive(): boolean;
134
134
  get isDead(): boolean;
135
135
  get isIllusion(): boolean;
136
+ get isStunned(): boolean;
136
137
  get combatClassifications(): CombatClassifications;
137
138
  set combatClassifications(combatClassifications: CombatClassifications);
138
139
  hasCombatClassification(combatClassification: CombatClassification): boolean;
@@ -51,6 +51,8 @@ local ____arrays = require("utility.arrays")
51
51
  local forEach = ____arrays.forEach
52
52
  local ____math = require("math")
53
53
  local min = ____math.min
54
+ local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
55
+ local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
54
56
  local match = string.match
55
57
  local ____tostring = _G.tostring
56
58
  local setUnitAnimation = SetUnitAnimation
@@ -75,6 +77,7 @@ local setUnitScale = SetUnitScale
75
77
  local setUnitPosition = SetUnitPosition
76
78
  local setUnitTimeScale = SetUnitTimeScale
77
79
  local getHandleId = GetHandleId
80
+ local getUnitCurrentOrder = GetUnitCurrentOrder
78
81
  local createUnit = CreateUnit
79
82
  local killUnit = KillUnit
80
83
  local setUnitExploded = SetUnitExploded
@@ -929,8 +932,15 @@ function Unit.prototype.interruptAttack(self)
929
932
  unitInterruptAttack(self.handle)
930
933
  end
931
934
  function Unit.prototype.interruptCast(self, abilityId)
932
- unitDisableAbility(self.handle, abilityId, true, false)
933
- unitDisableAbility(self.handle, abilityId, false, false)
935
+ local handle = self.handle
936
+ unitDisableAbility(handle, abilityId, true, false)
937
+ Timer:run(
938
+ unitDisableAbility,
939
+ handle,
940
+ abilityId,
941
+ false,
942
+ false
943
+ )
934
944
  end
935
945
  function Unit.prototype.getDistanceTo(self, target)
936
946
  local handle = self.handle
@@ -1195,6 +1205,14 @@ __TS__SetDescriptor(
1195
1205
  end},
1196
1206
  true
1197
1207
  )
1208
+ __TS__SetDescriptor(
1209
+ Unit.prototype,
1210
+ "isStunned",
1211
+ {get = function(self)
1212
+ return getUnitCurrentOrder(self.handle) == orderId("stunned")
1213
+ end},
1214
+ true
1215
+ )
1198
1216
  __TS__SetDescriptor(
1199
1217
  Unit.prototype,
1200
1218
  "combatClassifications",
@@ -2315,10 +2333,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
2315
2333
  ____exports.UnitTriggerEvent,
2316
2334
  EVENT_PLAYER_UNIT_ISSUED_ORDER,
2317
2335
  function()
2318
- local unit = ____exports.Unit:of(getOrderedUnit())
2319
- local issuedOrderId = getIssuedOrderId()
2320
- if unit ~= nil and unit.state == 1 then
2321
- return unit, issuedOrderId
2336
+ local handle = getOrderedUnit()
2337
+ if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
2338
+ local unit = ____exports.Unit:of(handle)
2339
+ if unit.state == 1 then
2340
+ return unit, getIssuedOrderId()
2341
+ end
2322
2342
  end
2323
2343
  return IgnoreEvent
2324
2344
  end
@@ -2509,8 +2529,9 @@ Unit.itemDroppedEvent = __TS__New(
2509
2529
  EVENT_PLAYER_UNIT_DROP_ITEM,
2510
2530
  function()
2511
2531
  local unit = getTriggerUnit()
2512
- if getUnitTypeId(unit) ~= dummyUnitId then
2513
- return ____exports.Unit:of(unit), Item:of(getManipulatedItem())
2532
+ local item = getManipulatedItem()
2533
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2534
+ return ____exports.Unit:of(unit), Item:of(item)
2514
2535
  end
2515
2536
  return IgnoreEvent
2516
2537
  end
@@ -2520,8 +2541,9 @@ Unit.itemPickedUpEvent = __TS__New(
2520
2541
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2521
2542
  function()
2522
2543
  local unit = getTriggerUnit()
2523
- if getUnitTypeId(unit) ~= dummyUnitId then
2524
- return ____exports.Unit:of(unit), Item:of(getManipulatedItem())
2544
+ local item = getManipulatedItem()
2545
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2546
+ return ____exports.Unit:of(unit), Item:of(item)
2525
2547
  end
2526
2548
  return IgnoreEvent
2527
2549
  end
@@ -2529,7 +2551,14 @@ Unit.itemPickedUpEvent = __TS__New(
2529
2551
  Unit.itemUsedEvent = __TS__New(
2530
2552
  ____exports.UnitTriggerEvent,
2531
2553
  EVENT_PLAYER_UNIT_USE_ITEM,
2532
- function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2554
+ function()
2555
+ local unit = getTriggerUnit()
2556
+ local item = getManipulatedItem()
2557
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2558
+ return ____exports.Unit:of(unit), Item:of(item)
2559
+ end
2560
+ return IgnoreEvent
2561
+ end
2533
2562
  )
2534
2563
  Unit.itemStackedEvent = __TS__New(
2535
2564
  ____exports.UnitTriggerEvent,
@@ -12,7 +12,8 @@ declare const enum LightningPropertyKey {
12
12
  TARGET_X = 106,
13
13
  TARGET_Y = 107,
14
14
  TARGET_Z = 108,
15
- DURATION = 109
15
+ DURATION = 109,
16
+ FADING = 110
16
17
  }
17
18
  export type LightningConstructor<T extends Lightning> = typeof Lightning & (new (handle: jlightning, typeId: LightningTypeId) => T);
18
19
  export declare class Lightning extends Handle<jlightning> {
@@ -27,6 +28,7 @@ export declare class Lightning extends Handle<jlightning> {
27
28
  private [LightningPropertyKey.TARGET_Y]?;
28
29
  private [LightningPropertyKey.TARGET_Z]?;
29
30
  private [LightningPropertyKey.DURATION]?;
31
+ private [LightningPropertyKey.FADING]?;
30
32
  constructor(handle: jlightning, typeId: LightningTypeId);
31
33
  protected onDestroy(): HandleDestructor;
32
34
  static create<T extends Lightning>(this: LightningConstructor<T>, typeId: LightningTypeId, ...parameters: [
@@ -46,6 +48,10 @@ export declare class Lightning extends Handle<jlightning> {
46
48
  target: Unit
47
49
  ]
48
50
  ]): T;
49
- static flash(...parameters: [...parameters: Parameters<(typeof Lightning)["create"]>, duration: number]): void;
51
+ static flash(...parameters: [
52
+ ...parameters: Parameters<(typeof Lightning)["create"]>,
53
+ duration: number,
54
+ fading?: boolean
55
+ ]): void;
50
56
  }
51
57
  export {};
@@ -10,6 +10,8 @@ local ____functions = require("utility.functions")
10
10
  local forwardByN = ____functions.forwardByN
11
11
  local ____unit_2Dmissile_2Ddata = require("engine.internal.unit-missile-data")
12
12
  local MISSILE_DATA_BY_UNIT_TYPE_ID = ____unit_2Dmissile_2Ddata.MISSILE_DATA_BY_UNIT_TYPE_ID
13
+ local ____math = require("math")
14
+ local ceil = ____math.ceil
13
15
  local ____type = _G.type
14
16
  local select = _G.select
15
17
  local cos = math.cos
@@ -27,6 +29,11 @@ local getUnitZ = BlzGetUnitZ
27
29
  local getUnitFlyHeight = GetUnitFlyHeight
28
30
  local getLocationZ = GetLocationZ
29
31
  local moveLocation = MoveLocation
32
+ local getLightningColorA = GetLightningColorA
33
+ local getLightningColorR = GetLightningColorR
34
+ local getLightningColorG = GetLightningColorG
35
+ local getLightningColorB = GetLightningColorB
36
+ local setLightningColor = SetLightningColor
30
37
  local location = Location(0, 0)
31
38
  local unitToUnitLightnings = setmetatable({}, {__mode = "k"})
32
39
  local unitToPointLightnings = setmetatable({}, {__mode = "k"})
@@ -225,9 +232,19 @@ function Lightning.create(self, typeId, checkVisibility, sourceXOrSourceUnit, so
225
232
  return lightning
226
233
  end
227
234
  function Lightning.flash(self, ...)
228
- local parametersToForwardCount = select("#", ...) - 1
235
+ local parameterOrDuration, durationOrFading = select(-2, ...)
236
+ local hasFading = ____type(durationOrFading) ~= "number"
237
+ local parametersToForwardCount = select("#", ...) - (hasFading and 2 or 1)
229
238
  local lightning = forwardByN[parametersToForwardCount](____exports.Lightning.create, self, ...)
230
- local duration = select(-1, ...)
239
+ local duration
240
+ if hasFading then
241
+ duration = parameterOrDuration
242
+ if durationOrFading then
243
+ lightning[110] = true
244
+ end
245
+ else
246
+ duration = durationOrFading
247
+ end
231
248
  lightning[109] = duration
232
249
  temporaryLightningsCount = temporaryLightningsCount + 1
233
250
  temporaryLightnings[temporaryLightningsCount] = lightning
@@ -295,6 +312,16 @@ Timer.onPeriod[UPDATE_PERIOD]:addListener(function()
295
312
  temporaryLightnings[temporaryLightningsCount] = nil
296
313
  temporaryLightningsCount = temporaryLightningsCount - 1
297
314
  else
315
+ if lightning[110] then
316
+ local handle = lightning.handle
317
+ setLightningColor(
318
+ handle,
319
+ getLightningColorR(handle),
320
+ getLightningColorG(handle),
321
+ getLightningColorB(handle),
322
+ ceil(getLightningColorA(handle) * (1 - UPDATE_PERIOD / duration))
323
+ )
324
+ end
298
325
  lightning[109] = duration - UPDATE_PERIOD
299
326
  i = i + 1
300
327
  end
@@ -1,7 +1,6 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
3
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
- local __TS__New = ____lualib.__TS__New
5
4
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
6
5
  local ____exports = {}
7
6
  local ____unit = require("engine.internal.unit")
@@ -31,7 +30,7 @@ local ____entry = require("engine.object-data.entry")
31
30
  local extractObjectDataEntryLevelFieldValue = ____entry.extractObjectDataEntryLevelFieldValue
32
31
  local ObjectDataEntry = ____entry.ObjectDataEntry
33
32
  local ____object_2Ddata_2Dentry_2Did_2Dgenerator = require("engine.object-data.utility.object-data-entry-id-generator")
34
- local ObjectDataEntryIdGenerator = ____object_2Ddata_2Dentry_2Did_2Dgenerator.ObjectDataEntryIdGenerator
33
+ local abilityTypeIdGenerator = ____object_2Ddata_2Dentry_2Did_2Dgenerator.abilityTypeIdGenerator
35
34
  local ____upgrade = require("engine.object-data.entry.upgrade")
36
35
  local Upgrade = ____upgrade.Upgrade
37
36
  local castAnimationFQNByAbilityTypeId = {}
@@ -53,10 +52,7 @@ end
53
52
  function AbilityType.getObjectData(self, map)
54
53
  return map.objects.ability
55
54
  end
56
- AbilityType.idGenerator = __TS__New(
57
- ObjectDataEntryIdGenerator,
58
- fourCC("A000")
59
- )
55
+ AbilityType.idGenerator = abilityTypeIdGenerator
60
56
  __TS__SetDescriptor(
61
57
  AbilityType.prototype,
62
58
  "channelingAnimation",
@@ -999,7 +995,7 @@ local function handleAbilityCastingStartEvent(caster, ability)
999
995
  end
1000
996
  casterCastingEffectsByCaster[caster] = effects
1001
997
  end
1002
- local function handleAbilityStopEvent(caster)
998
+ local function handleAbilityStopCastingEvent(caster)
1003
999
  local effects = casterCastingEffectsByCaster[caster]
1004
1000
  if effects ~= nil then
1005
1001
  for i = 1, #effects do
@@ -1010,8 +1006,8 @@ local function handleAbilityStopEvent(caster)
1010
1006
  end
1011
1007
  for abilityTypeId in pairs(casterCastingEffectModelPathsByAbilityTypeId) do
1012
1008
  Unit.abilityCastingStartEvent[abilityTypeId]:addListener(4, handleAbilityCastingStartEvent)
1013
- Unit.abilityChannelingStartEvent[abilityTypeId]:addListener(4, handleAbilityStopEvent)
1014
- Unit.abilityStopEvent[abilityTypeId]:addListener(4, handleAbilityStopEvent)
1009
+ Unit.abilityChannelingStartEvent[abilityTypeId]:addListener(4, handleAbilityStopCastingEvent)
1010
+ Unit.abilityStopEvent[abilityTypeId]:addListener(4, handleAbilityStopCastingEvent)
1015
1011
  end
1016
1012
  local casterChannelingEffectModelPathsByAbilityTypeId = postcompile(function()
1017
1013
  return mapValues(
@@ -1042,7 +1038,7 @@ local function handleAbilityChannelingStartEvent(caster, ability)
1042
1038
  end
1043
1039
  casterChannelingEffectsByCaster[caster] = effects
1044
1040
  end
1045
- local function handleAbilityStopEventV2(caster)
1041
+ local function handleAbilityStopChannelingEvent(caster)
1046
1042
  local effects = casterChannelingEffectsByCaster[caster]
1047
1043
  if effects ~= nil then
1048
1044
  for i = 1, #effects do
@@ -1053,7 +1049,7 @@ local function handleAbilityStopEventV2(caster)
1053
1049
  end
1054
1050
  for abilityTypeId in pairs(casterChannelingEffectModelPathsByAbilityTypeId) do
1055
1051
  Unit.abilityChannelingStartEvent[abilityTypeId]:addListener(4, handleAbilityChannelingStartEvent)
1056
- Unit.abilityChannelingFinishEvent[abilityTypeId]:addListener(4, handleAbilityStopEventV2)
1057
- Unit.abilityStopEvent[abilityTypeId]:addListener(4, handleAbilityStopEventV2)
1052
+ Unit.abilityChannelingFinishEvent[abilityTypeId]:addListener(4, handleAbilityStopChannelingEvent)
1053
+ Unit.abilityStopEvent[abilityTypeId]:addListener(4, handleAbilityStopChannelingEvent)
1058
1054
  end
1059
1055
  return ____exports
@@ -45,6 +45,8 @@ export declare class ItemType extends ObjectDataEntry<ItemTypeId> {
45
45
  set tooltipText(tooltipText: string);
46
46
  get tooltipExtendedText(): string;
47
47
  set tooltipExtendedText(tooltipText: string);
48
+ get cooldownGroupId(): number;
49
+ set cooldownGroupId(cooldownGroupId: number);
48
50
  get goldCost(): number;
49
51
  set goldCost(goldCost: number);
50
52
  get lumberCost(): number;
@@ -256,6 +256,19 @@ __TS__SetDescriptor(
256
256
  },
257
257
  true
258
258
  )
259
+ __TS__SetDescriptor(
260
+ ItemType.prototype,
261
+ "cooldownGroupId",
262
+ {
263
+ get = function(self)
264
+ return self:getObjectDataEntryIdField("icid")
265
+ end,
266
+ set = function(self, cooldownGroupId)
267
+ self:setObjectDataEntryIdField("icid", cooldownGroupId)
268
+ end
269
+ },
270
+ true
271
+ )
259
272
  __TS__SetDescriptor(
260
273
  ItemType.prototype,
261
274
  "goldCost",
@@ -1,5 +1,6 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__New = ____lualib.__TS__New
3
4
  local ____exports = {}
4
5
  local ____preconditions = require("utility.preconditions")
5
6
  local checkNotNull = ____preconditions.checkNotNull
@@ -60,4 +61,10 @@ function ObjectDataEntryIdGenerator.prototype.next(self)
60
61
  self.id = id
61
62
  return id
62
63
  end
64
+ ---
65
+ -- @internal For use by internal systems only.
66
+ ____exports.abilityTypeIdGenerator = __TS__New(
67
+ ____exports.ObjectDataEntryIdGenerator,
68
+ fourCC("A000")
69
+ )
63
70
  return ____exports
@@ -45,9 +45,10 @@ export declare class AbilityStringField extends AbilityField<string, jabilitystr
45
45
  protected setNativeFieldValue(instance: Ability, value: string): boolean;
46
46
  static get valueChangeEvent(): ObjectFieldValueChangeEvent<AbilityStringField>;
47
47
  }
48
- export declare abstract class AbilityArrayField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType = unknown> extends ObjectArrayField<AbilityType, Ability, ValueType, NativeFieldType> {
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(instance: Ability): boolean;
51
52
  }
52
53
  export declare class AbilityStringArrayField extends AbilityArrayField<string, jabilitystringlevelfield> {
53
54
  protected get defaultValue(): string;
@@ -130,7 +131,9 @@ export declare class AbilityCombatClassificationsLevelField extends AbilityLevel
130
131
  protected getNativeFieldValue(instance: Ability, level: number): CombatClassifications;
131
132
  protected setNativeFieldValue(instance: Ability, level: number, value: CombatClassifications): boolean;
132
133
  }
133
- export type AbilityDependentValue<ValueType extends boolean | number | string> = ValueType | AbilityField<ValueType> | AbilityLevelField<ValueType> | ((ability: Ability) => ValueType);
134
+ export type ReadonlySubscribableAbilityDependentValue<ValueType extends boolean | number | string> = ValueType | ReadonlyObjectFieldType<AbilityField<ValueType>> | ReadonlyObjectLevelFieldType<AbilityLevelField<ValueType>>;
135
+ export type SubscribableAbilityDependentValue<ValueType extends boolean | number | string> = ValueType | AbilityField<ValueType> | AbilityLevelField<ValueType>;
136
+ export type AbilityDependentValue<ValueType extends boolean | number | string> = SubscribableAbilityDependentValue<ValueType> | ((ability: Ability) => ValueType);
134
137
  export declare const resolveCurrentAbilityDependentValue: {
135
138
  <ValueType extends boolean | number | string>(ability: Ability, value: AbilityDependentValue<ValueType>): ValueType;
136
139
  <ValueType extends boolean | number | string>(ability: Ability, value?: AbilityDependentValue<ValueType>): ValueType | undefined;
@@ -197,6 +197,9 @@ __TS__ClassExtends(AbilityArrayField, ObjectArrayField)
197
197
  function AbilityArrayField.prototype.getObjectDataEntryId(self, instance)
198
198
  return instance.typeId
199
199
  end
200
+ function AbilityArrayField.prototype.hasNativeFieldValue(self, instance)
201
+ return instance:hasField(self.nativeField)
202
+ end
200
203
  __TS__SetDescriptor(
201
204
  AbilityArrayField.prototype,
202
205
  "instanceClass",
@@ -16,6 +16,8 @@ declare abstract class ObjectFieldBase<ObjectDataEntryType extends ObjectDataEnt
16
16
  readonly id: ObjectFieldId;
17
17
  protected abstract getNativeFieldById(id: number): NativeFieldType;
18
18
  protected abstract getObjectDataEntryId(instance: InstanceType): ObjectDataEntryIdType<ObjectDataEntryType>;
19
+ protected abstract hasNativeFieldValue(instance: InstanceType): boolean;
20
+ hasValue(instance: InstanceType): boolean;
19
21
  constructor(id: number);
20
22
  static create<T extends ObjectFieldBase<any, any, any, any>>(this: ObjectFieldConstructor<T>, id?: number): T & symbol;
21
23
  static of<T extends ObjectFieldBase<any, any, any, any>>(this: ObjectFieldAbstractConstructor<T>, id: number): T | undefined;
@@ -35,7 +37,6 @@ export type ReadonlyObjectFieldType<T extends ObjectField<any, any, any, any>> =
35
37
  type ReadonlyObjectFieldConstructor<T extends ObjectField> = OmitConstructor<typeof ObjectField> & (abstract new (...args: any[]) => ReadonlyObjectFieldType<T>);
36
38
  export declare abstract class ObjectField<ObjectDataEntryType extends ObjectDataEntry = ObjectDataEntry, InstanceType extends AnyNotNil = AnyNotNil, ValueType extends number | string | boolean = number | string | boolean, NativeFieldType = unknown> extends ObjectFieldBase<ObjectDataEntryType, InstanceType, ValueType, NativeFieldType> {
37
39
  protected abstract readonly defaultValue: ValueType;
38
- protected abstract hasNativeFieldValue(instance: InstanceType): boolean;
39
40
  protected abstract getNativeFieldValue(instance: InstanceType): ValueType;
40
41
  protected abstract setNativeFieldValue(instance: InstanceType, value: ValueType): boolean;
41
42
  getValue(entry: ObjectDataEntryType | InstanceType): ValueType;
@@ -71,7 +72,6 @@ export declare abstract class ObjectArrayField<ObjectDataEntryType extends Objec
71
72
  }
72
73
  export declare abstract class ObjectLevelField<ObjectDataEntryType extends ObjectDataEntry = ObjectDataEntry, InstanceType extends AnyNotNil = AnyNotNil, ValueType extends number | string | boolean = number | string | boolean, InputValueType extends ValueType = never, NativeFieldType = unknown> extends ObjectFieldBase<ObjectDataEntryType, InstanceType, ValueType[], NativeFieldType> {
73
74
  protected abstract readonly defaultValue: ValueType;
74
- protected abstract hasNativeFieldValue(instance: InstanceType): boolean;
75
75
  protected abstract getNativeFieldValue(instance: InstanceType, level: number): ValueType;
76
76
  protected abstract setNativeFieldValue(instance: InstanceType, level: number, value: ValueType): boolean;
77
77
  protected abstract getLevelCount(entry: ObjectDataEntryType | InstanceType): number;
@@ -46,6 +46,10 @@ end
46
46
  function ObjectFieldBase.prototype.supports(self, instance)
47
47
  return __TS__InstanceOf(instance, self.instanceClass)
48
48
  end
49
+ function ObjectFieldBase.prototype.hasValue(self, instance)
50
+ local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
51
+ return defaultValueByObjectDataEntryId ~= nil and defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)] ~= nil or self:hasNativeFieldValue(instance)
52
+ end
49
53
  function ObjectFieldBase.create(self, id)
50
54
  return __TS__New(
51
55
  self,
package/engine/unit.d.ts CHANGED
@@ -17,6 +17,7 @@ import "./internal/unit/ghost-counter";
17
17
  import "./internal/unit/invulnerability-counter";
18
18
  import "./internal/unit/detach-missiles";
19
19
  import "./internal/unit/main-selected";
20
+ import "./internal/unit/add-item-to-slot-init";
20
21
  import "./internal/unit/band-aids/ancestral-spirit-cannibalize";
21
22
  export { Unit, DamagingEvent, DamageEvent } from "./internal/unit";
22
23
  export * from "./internal/unit+damage";
package/engine/unit.lua CHANGED
@@ -17,6 +17,7 @@ require("engine.internal.unit.ghost-counter")
17
17
  require("engine.internal.unit.invulnerability-counter")
18
18
  require("engine.internal.unit.detach-missiles")
19
19
  require("engine.internal.unit.main-selected")
20
+ require("engine.internal.unit.add-item-to-slot-init")
20
21
  require("engine.internal.unit.band-aids.ancestral-spirit-cannibalize")
21
22
  do
22
23
  local ____unit = require("engine.internal.unit")
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "warscript",
4
- "version": "0.0.1-dev.d63794c",
4
+ "version": "0.0.1-dev.d750e38",
5
5
  "description": "A typescript library for Warcraft III using Warpack.",
6
6
  "keywords": [
7
7
  "warcraft",
@@ -24,7 +24,7 @@
24
24
  "@warscript/language-extensions": "^0.0.1",
25
25
  "@warscript/tstl-plugin": "^0.0.4",
26
26
  "lua-types": "^2.13.1",
27
- "warpack": "0.0.1-dev.880fc91"
27
+ "warpack": "0.0.1-dev.1830aad"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@typescript-eslint/eslint-plugin": "^8.13.0",