warscript 0.0.1-dev.4117d1e → 0.0.1-dev.42d21a8

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
@@ -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
@@ -35,6 +35,8 @@ local getAbilityStringLevelField = BlzGetAbilityStringLevelField
35
35
  local getUnitAbilityCooldownRemaining = BlzGetUnitAbilityCooldownRemaining
36
36
  local startUnitAbilityCooldown = BlzStartUnitAbilityCooldown
37
37
  local getHandleId = GetHandleId
38
+ local getItemBooleanField = BlzGetItemBooleanField
39
+ local setItemBooleanField = BlzSetItemBooleanField
38
40
  local unitHideAbility = BlzUnitHideAbility
39
41
  local match = string.match
40
42
  local ____type = _G.type
@@ -452,8 +454,6 @@ end
452
454
  local function getAbilityCooldown(_, abilityTypeId)
453
455
  return getUnitAbilityCooldownRemaining(abilityActionDummy, abilityTypeId)
454
456
  end
455
- local function doNothing()
456
- end
457
457
  ____exports.ItemAbility = __TS__Class()
458
458
  local ItemAbility = ____exports.ItemAbility
459
459
  ItemAbility.name = "ItemAbility"
@@ -482,11 +482,12 @@ function ItemAbility.prototype.setField(self, field, levelOrValue, value)
482
482
  )
483
483
  end
484
484
  function ItemAbility.prototype.interruptCast(self)
485
- local item = self.owner
486
- local ____doAbilityActionForceDummy_4 = doAbilityActionForceDummy
487
- local ____item_handle_3 = item.handle
488
- local ____opt_1 = item.owner
489
- ____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
490
491
  end
491
492
  __TS__SetDescriptor(
492
493
  ItemAbility.prototype,
@@ -502,17 +503,17 @@ __TS__SetDescriptor(
502
503
  {
503
504
  get = function(self)
504
505
  local item = self.owner
505
- local ____doAbilityActionForceDummy_8 = doAbilityActionForceDummy
506
- local ____item_handle_7 = item.handle
507
- local ____opt_5 = item.owner
508
- 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)
509
510
  end,
510
511
  set = function(self, cooldownRemaining)
511
512
  local item = self.owner
512
- local ____startItemCooldown_12 = startItemCooldown
513
- local ____item_handle_11 = item.handle
514
- local ____opt_9 = item.owner
515
- ____startItemCooldown_12(____item_handle_11, ____opt_9 and ____opt_9.handle, cooldownRemaining)
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)
516
517
  end
517
518
  },
518
519
  true
@@ -1,4 +1,5 @@
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")
@@ -11,6 +12,12 @@ local ____object_2Ddata_2Dentry_2Did_2Dgenerator = require("engine.object-data.u
11
12
  local abilityTypeIdGenerator = ____object_2Ddata_2Dentry_2Did_2Dgenerator.abilityTypeIdGenerator
12
13
  local ____math = require("math")
13
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
14
21
  local isItemOwned = IsItemOwned
15
22
  local isItemPowerup = IsItemPowerup
16
23
  local getItemX = GetItemX
@@ -21,7 +28,6 @@ local getItemIntegerField = BlzGetItemIntegerField
21
28
  local setItemBooleanField = BlzSetItemBooleanField
22
29
  local setItemPosition = SetItemPosition
23
30
  local unitAddItem = UnitAddItem
24
- local unitDropItemSlot = UnitDropItemSlot
25
31
  local unitRemoveItem = UnitRemoveItem
26
32
  local unitUseItem = UnitUseItem
27
33
  local unitResetCooldown = UnitResetCooldown
@@ -65,6 +71,12 @@ local function startItemCooldownInternal(handle, cooldown)
65
71
  setAbilityRealLevelField(cooldownStarterAbility, ABILITY_RLF_COOLDOWN, 0, cooldown)
66
72
  unitResetCooldown(dummy)
67
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
68
80
  end
69
81
  ---
70
82
  -- @internal For use by internal systems only.
@@ -77,6 +89,10 @@ ____exports.abilityActionDummy = dummy
77
89
  ---
78
90
  -- @internal For use by internal systems only.
79
91
  ____exports.doAbilityAction = function(handle, action, ...)
92
+ local isAlreadyIgnoredInEvents = ignoreEventsItems[handle] ~= nil
93
+ if not isAlreadyIgnoredInEvents then
94
+ ignoreEventsItems[handle] = true
95
+ end
80
96
  local isOwned = isItemOwned(handle)
81
97
  local isPowerup
82
98
  local x
@@ -98,6 +114,9 @@ ____exports.doAbilityAction = function(handle, action, ...)
98
114
  setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
99
115
  end
100
116
  end
117
+ if not isAlreadyIgnoredInEvents then
118
+ ignoreEventsItems[handle] = nil
119
+ end
101
120
  return result
102
121
  end
103
122
  ---
@@ -110,6 +129,10 @@ ____exports.doAbilityActionForceDummy = function(handle, owner, action, ...)
110
129
  if slot == nil then
111
130
  return ____exports.doAbilityAction(handle, action, ...)
112
131
  end
132
+ local isAlreadyIgnoredInEvents = ignoreEventsItems[handle] ~= nil
133
+ if not isAlreadyIgnoredInEvents then
134
+ ignoreEventsItems[handle] = true
135
+ end
113
136
  local isPowerup
114
137
  if isItemPowerup(handle) then
115
138
  setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
@@ -119,11 +142,13 @@ ____exports.doAbilityActionForceDummy = function(handle, owner, action, ...)
119
142
  unitAddItem(dummy, handle)
120
143
  local result = action(handle, ...)
121
144
  unitRemoveItem(dummy, handle)
122
- unitAddItem(owner, handle)
123
- unitDropItemSlot(owner, handle, slot)
145
+ unitAddItemToSlot(owner, handle, slot)
124
146
  if isPowerup then
125
147
  setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
126
148
  end
149
+ if not isAlreadyIgnoredInEvents then
150
+ ignoreEventsItems[handle] = nil
151
+ end
127
152
  return result
128
153
  end
129
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 - 2 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 - 2 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)
52
51
  if isPowerup then
53
52
  setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
54
53
  end
@@ -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
@@ -929,8 +931,15 @@ function Unit.prototype.interruptAttack(self)
929
931
  unitInterruptAttack(self.handle)
930
932
  end
931
933
  function Unit.prototype.interruptCast(self, abilityId)
932
- unitDisableAbility(self.handle, abilityId, true, false)
933
- unitDisableAbility(self.handle, abilityId, false, false)
934
+ local handle = self.handle
935
+ unitDisableAbility(handle, abilityId, true, false)
936
+ Timer:run(
937
+ unitDisableAbility,
938
+ handle,
939
+ abilityId,
940
+ false,
941
+ false
942
+ )
934
943
  end
935
944
  function Unit.prototype.getDistanceTo(self, target)
936
945
  local handle = self.handle
@@ -2315,10 +2324,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
2315
2324
  ____exports.UnitTriggerEvent,
2316
2325
  EVENT_PLAYER_UNIT_ISSUED_ORDER,
2317
2326
  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
2327
+ local handle = getOrderedUnit()
2328
+ if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
2329
+ local unit = ____exports.Unit:of(handle)
2330
+ if unit.state == 1 then
2331
+ return unit, getIssuedOrderId()
2332
+ end
2322
2333
  end
2323
2334
  return IgnoreEvent
2324
2335
  end
@@ -2509,8 +2520,9 @@ Unit.itemDroppedEvent = __TS__New(
2509
2520
  EVENT_PLAYER_UNIT_DROP_ITEM,
2510
2521
  function()
2511
2522
  local unit = getTriggerUnit()
2512
- if getUnitTypeId(unit) ~= dummyUnitId then
2513
- return ____exports.Unit:of(unit), Item:of(getManipulatedItem())
2523
+ local item = getManipulatedItem()
2524
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2525
+ return ____exports.Unit:of(unit), Item:of(item)
2514
2526
  end
2515
2527
  return IgnoreEvent
2516
2528
  end
@@ -2520,8 +2532,9 @@ Unit.itemPickedUpEvent = __TS__New(
2520
2532
  EVENT_PLAYER_UNIT_PICKUP_ITEM,
2521
2533
  function()
2522
2534
  local unit = getTriggerUnit()
2523
- if getUnitTypeId(unit) ~= dummyUnitId then
2524
- return ____exports.Unit:of(unit), Item:of(getManipulatedItem())
2535
+ local item = getManipulatedItem()
2536
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2537
+ return ____exports.Unit:of(unit), Item:of(item)
2525
2538
  end
2526
2539
  return IgnoreEvent
2527
2540
  end
@@ -2529,7 +2542,14 @@ Unit.itemPickedUpEvent = __TS__New(
2529
2542
  Unit.itemUsedEvent = __TS__New(
2530
2543
  ____exports.UnitTriggerEvent,
2531
2544
  EVENT_PLAYER_UNIT_USE_ITEM,
2532
- function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
2545
+ function()
2546
+ local unit = getTriggerUnit()
2547
+ local item = getManipulatedItem()
2548
+ if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
2549
+ return ____exports.Unit:of(unit), Item:of(item)
2550
+ end
2551
+ return IgnoreEvent
2552
+ end
2533
2553
  )
2534
2554
  Unit.itemStackedEvent = __TS__New(
2535
2555
  ____exports.UnitTriggerEvent,
@@ -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.4117d1e",
4
+ "version": "0.0.1-dev.42d21a8",
5
5
  "description": "A typescript library for Warcraft III using Warpack.",
6
6
  "keywords": [
7
7
  "warcraft",