warscript 0.0.1-dev.5abc199 → 0.0.1-dev.5c35450

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.
Files changed (57) hide show
  1. package/core/types/frame.lua +47 -1
  2. package/core/types/item.d.ts +1 -0
  3. package/core/types/item.lua +1 -0
  4. package/core/types/sound.lua +1 -1
  5. package/engine/behaviour/ability/damage.d.ts +3 -0
  6. package/engine/behaviour/ability/damage.lua +8 -2
  7. package/engine/behaviour/ability/emulate-impact.lua +5 -4
  8. package/engine/behaviour/ability.d.ts +5 -5
  9. package/engine/buff.d.ts +41 -13
  10. package/engine/buff.lua +222 -116
  11. package/engine/internal/ability.lua +25 -15
  12. package/engine/internal/item/fields.d.ts +12 -0
  13. package/engine/internal/item/fields.lua +33 -0
  14. package/engine/internal/item.d.ts +0 -4
  15. package/engine/internal/item.lua +0 -37
  16. package/engine/internal/object-data/attribute-bonus.lua +2 -2
  17. package/engine/internal/object-data/health-bonus.d.ts +2 -0
  18. package/engine/internal/object-data/health-bonus.lua +16 -0
  19. package/engine/internal/object-data/mana-bonus.d.ts +2 -0
  20. package/engine/internal/object-data/mana-bonus.lua +16 -0
  21. package/engine/internal/unit/bonus.d.ts +4 -0
  22. package/engine/internal/unit/bonus.lua +23 -3
  23. package/engine/internal/unit+bonus.lua +3 -3
  24. package/engine/local-client.d.ts +5 -0
  25. package/engine/local-client.lua +56 -1
  26. package/engine/object-data/auxiliary/unit-attribute.lua +1 -1
  27. package/engine/object-data/entry/ability-type/{armor-increase.d.ts → armor-bonus.d.ts} +3 -3
  28. package/engine/object-data/entry/ability-type/{armor-increase.lua → armor-bonus.lua} +9 -9
  29. package/engine/object-data/entry/ability-type/health-bonus.d.ts +8 -0
  30. package/engine/object-data/entry/ability-type/health-bonus.lua +26 -0
  31. package/engine/object-data/entry/ability-type/mana-bonus.d.ts +8 -0
  32. package/engine/object-data/entry/ability-type/mana-bonus.lua +26 -0
  33. package/engine/object-data/entry/ability-type.lua +4 -0
  34. package/engine/object-data/entry/buff-type/applicable.lua +113 -109
  35. package/engine/object-field/ability.lua +2 -2
  36. package/engine/object-field/item.d.ts +22 -0
  37. package/engine/object-field/item.lua +118 -0
  38. package/engine/object-field.d.ts +1 -1
  39. package/engine/object-field.lua +9 -7
  40. package/engine/standard/fields/item.d.ts +4 -0
  41. package/engine/standard/fields/item.lua +6 -0
  42. package/lualib_bundle.lua +1 -1
  43. package/math.d.ts +2 -0
  44. package/math.lua +14 -0
  45. package/objutil/object.lua +1 -1
  46. package/operation.lua +1 -4
  47. package/package.json +4 -4
  48. package/utility/linked-map.d.ts +2 -1
  49. package/utility/linked-map.lua +6 -0
  50. package/utility/linked-set.d.ts +1 -0
  51. package/utility/linked-set.lua +6 -0
  52. package/utility/unordered-map.d.ts +27 -0
  53. package/utility/unordered-map.lua +99 -0
  54. /package/engine/internal/object-data/{armor-increase.d.ts → armor-bonus.d.ts} +0 -0
  55. /package/engine/internal/object-data/{armor-increase.lua → armor-bonus.lua} +0 -0
  56. /package/engine/object-data/entry/ability-type/{attribute-increase.d.ts → attribute-bonus.d.ts} +0 -0
  57. /package/engine/object-data/entry/ability-type/{attribute-increase.lua → attribute-bonus.lua} +0 -0
@@ -65,123 +65,127 @@ function ApplicableBuffType.wrap(self, other)
65
65
  return __TS__New(____exports.ApplicableBuffType, other.object)
66
66
  end
67
67
  ApplicableBuffType.BASE_ID = fourCC("BHbz")
68
- local applicatorAbilityTypeIdByApplicatorTypeByApplicableBuffTypeId, applicatorUpgradeIdByApplicatorAbilityTypeId = table.unpack(postcompile(function()
69
- local function prepareAbilityType(abilityTypeConstructor, applicableBuffType)
70
- local abilityType = abilityTypeConstructor:create()
71
- abilityType.isInternal = true
72
- abilityType.levelCount = applicableBuffType.levelCount
73
- abilityType.buttonPositionX = 0
74
- abilityType.buttonPositionY = -11
75
- abilityType.casterAttachmentPresets = {}
76
- abilityType.targetEffectPresets = {}
77
- abilityType.casterEffectSoundPresetId = nil
78
- abilityType.learnLevelMinimum = 6
79
- abilityType.race = "other"
80
- abilityType.shouldCheckTechTreeDependencies = false
81
- abilityType.techTreeDependencies = {}
82
- abilityType.allowedTargetCombatClassifications = combatClassificationsOf(
83
- 4,
84
- 2,
85
- 2097152,
86
- 8,
87
- 1048576,
88
- 16
89
- )
90
- abilityType.areaOfEffect = 0
91
- abilityType.castRange = 999999
92
- abilityType.cooldown = 0
93
- abilityType.manaCost = 0
94
- abilityType.buffDuration = 0
95
- abilityType.heroBuffDuration = 0
96
- return abilityType
97
- end
98
- local multilevelPhysicalPositiveApplicatorAbilityTypes = {}
99
- local applicatorAbilityTypeIdByApplicatorTypeByApplicableBuffTypeId = {}
100
- for applicableBuffType in pairs(compiletimeApplicableBuffTypes) do
101
- local applicatorAbilityTypeIdByApplicatorType = {}
102
- if applicableBuffType.resistanceType == 1 or applicableBuffType.resistanceType == nil then
103
- if applicableBuffType.polarity == 2 or applicableBuffType.polarity == nil then
104
- local applicatorAbilityType = prepareAbilityType(CurseAbilityType, applicableBuffType)
105
- applicatorAbilityType.missProbability = 0
106
- applicatorAbilityType.buffTypeIds = {applicableBuffType.id}
107
- applicatorAbilityTypeIdByApplicatorType[852190] = applicatorAbilityType.id
68
+ local applicatorAbilityTypeIdByApplicatorTypeByApplicableBuffTypeId, applicatorUpgradeIdByApplicatorAbilityTypeId = table.unpack(
69
+ postcompile(function()
70
+ local function prepareAbilityType(abilityTypeConstructor, applicableBuffType)
71
+ local abilityType = abilityTypeConstructor:create()
72
+ abilityType.isInternal = true
73
+ abilityType.levelCount = applicableBuffType.levelCount
74
+ abilityType.buttonPositionX = 0
75
+ abilityType.buttonPositionY = -11
76
+ abilityType.casterAttachmentPresets = {}
77
+ abilityType.targetEffectPresets = {}
78
+ abilityType.casterEffectSoundPresetId = nil
79
+ abilityType.learnLevelMinimum = 6
80
+ abilityType.race = "other"
81
+ abilityType.shouldCheckTechTreeDependencies = false
82
+ abilityType.techTreeDependencies = {}
83
+ abilityType.allowedTargetCombatClassifications = combatClassificationsOf(
84
+ 4,
85
+ 2,
86
+ 2097152,
87
+ 8,
88
+ 1048576,
89
+ 16
90
+ )
91
+ abilityType.areaOfEffect = 0
92
+ abilityType.castRange = 999999
93
+ abilityType.cooldown = 0
94
+ abilityType.manaCost = 0
95
+ abilityType.buffDuration = 0
96
+ abilityType.heroBuffDuration = 0
97
+ return abilityType
98
+ end
99
+ local multilevelPhysicalPositiveApplicatorAbilityTypes = {}
100
+ local applicatorAbilityTypeIdByApplicatorTypeByApplicableBuffTypeId = {}
101
+ for applicableBuffType in pairs(compiletimeApplicableBuffTypes) do
102
+ local applicatorAbilityTypeIdByApplicatorType = {}
103
+ if applicableBuffType.resistanceType == 1 or applicableBuffType.resistanceType == nil then
104
+ if applicableBuffType.polarity == 2 or applicableBuffType.polarity == nil then
105
+ local applicatorAbilityType = prepareAbilityType(CurseAbilityType, applicableBuffType)
106
+ applicatorAbilityType.missProbability = 0
107
+ applicatorAbilityType.buffTypeIds = {applicableBuffType.id}
108
+ applicatorAbilityTypeIdByApplicatorType[852190] = applicatorAbilityType.id
109
+ end
110
+ if applicableBuffType.polarity == 1 or applicableBuffType.polarity == nil then
111
+ local applicatorAbilityType = prepareAbilityType(BloodLustAbilityType, applicableBuffType)
112
+ applicatorAbilityType.attackSpeedIncreaseFactor = 0
113
+ applicatorAbilityType.movementSpeedIncreaseFactor = 0
114
+ applicatorAbilityType.scaleIncrease = 0
115
+ applicatorAbilityType.buffTypeIds = {applicableBuffType.id}
116
+ applicatorAbilityTypeIdByApplicatorType[852101] = applicatorAbilityType.id
117
+ end
108
118
  end
109
- if applicableBuffType.polarity == 1 or applicableBuffType.polarity == nil then
110
- local applicatorAbilityType = prepareAbilityType(BloodLustAbilityType, applicableBuffType)
111
- applicatorAbilityType.attackSpeedIncreaseFactor = 0
112
- applicatorAbilityType.movementSpeedIncreaseFactor = 0
113
- applicatorAbilityType.scaleIncrease = 0
119
+ if applicableBuffType.resistanceType == 2 or applicableBuffType.resistanceType == nil then
120
+ if applicableBuffType.polarity == 2 or applicableBuffType.polarity == nil then
121
+ local applicatorAbilityType = prepareAbilityType(SlowPoisonAbilityType, applicableBuffType)
122
+ applicatorAbilityType.damagePerSecond = 0
123
+ applicatorAbilityType.movementSpeedDecreaseFactor = 0
124
+ applicatorAbilityType.attackSpeedDecreaseFactor = 0
125
+ applicatorAbilityType.isDamageStacking = false
126
+ applicatorAbilityType.isMovementSpeedFactorStacking = false
127
+ applicatorAbilityType.isAttackSpeedFactorStacking = false
128
+ applicatorAbilityType.isAbleToKill = false
129
+ applicatorAbilityType.buffTypeIds = {applicableBuffType.id, applicableBuffType.id}
130
+ applicatorAbilityTypeIdByApplicatorType[852173] = applicatorAbilityType.id
131
+ end
132
+ if applicableBuffType.polarity == 1 or applicableBuffType.polarity == nil then
133
+ local applicatorAbilityType = prepareAbilityType(BerserkAbilityType, applicableBuffType)
134
+ applicatorAbilityType.attackSpeedIncreaseFactor = 0
135
+ applicatorAbilityType.movementSpeedIncreaseFactor = 0
136
+ applicatorAbilityType.receivedDamageIncreaseFactor = 0
137
+ applicatorAbilityType.buffTypeIds = {applicableBuffType.id}
138
+ if applicatorAbilityType.levelCount > 1 then
139
+ multilevelPhysicalPositiveApplicatorAbilityTypes[#multilevelPhysicalPositiveApplicatorAbilityTypes + 1] = applicatorAbilityType
140
+ end
141
+ applicatorAbilityTypeIdByApplicatorType[852100] = applicatorAbilityType.id
142
+ end
143
+ end
144
+ if applicableBuffType.polarity == 0 or applicableBuffType.polarity == nil then
145
+ local applicatorAbilityType = prepareAbilityType(PermanentImmolationAbilityType, applicableBuffType)
146
+ applicatorAbilityType.levelCount = 1
147
+ applicatorAbilityType.damagePerInterval = 0
148
+ applicatorAbilityType.castRange = 0
149
+ applicatorAbilityType.buffDuration = MAXIMUM_INTEGER
150
+ applicatorAbilityType.heroBuffDuration = MAXIMUM_INTEGER
151
+ applicatorAbilityType.allowedTargetCombatClassifications = combatClassificationsOf(1)
114
152
  applicatorAbilityType.buffTypeIds = {applicableBuffType.id}
115
- applicatorAbilityTypeIdByApplicatorType[852101] = applicatorAbilityType.id
153
+ applicatorAbilityTypeIdByApplicatorType[0] = applicatorAbilityType.id
116
154
  end
155
+ applicatorAbilityTypeIdByApplicatorTypeByApplicableBuffTypeId[applicableBuffType.id] = applicatorAbilityTypeIdByApplicatorType
117
156
  end
118
- if applicableBuffType.resistanceType == 2 or applicableBuffType.resistanceType == nil then
119
- if applicableBuffType.polarity == 2 or applicableBuffType.polarity == nil then
120
- local applicatorAbilityType = prepareAbilityType(SlowPoisonAbilityType, applicableBuffType)
121
- applicatorAbilityType.damagePerSecond = 0
122
- applicatorAbilityType.movementSpeedDecreaseFactor = 0
123
- applicatorAbilityType.attackSpeedDecreaseFactor = 0
124
- applicatorAbilityType.isDamageStacking = false
125
- applicatorAbilityType.isMovementSpeedFactorStacking = false
126
- applicatorAbilityType.isAttackSpeedFactorStacking = false
127
- applicatorAbilityType.isAbleToKill = false
128
- applicatorAbilityType.buffTypeIds = {applicableBuffType.id, applicableBuffType.id}
129
- applicatorAbilityTypeIdByApplicatorType[852173] = applicatorAbilityType.id
130
- end
131
- if applicableBuffType.polarity == 1 or applicableBuffType.polarity == nil then
132
- local applicatorAbilityType = prepareAbilityType(BerserkAbilityType, applicableBuffType)
133
- applicatorAbilityType.attackSpeedIncreaseFactor = 0
134
- applicatorAbilityType.movementSpeedIncreaseFactor = 0
135
- applicatorAbilityType.receivedDamageIncreaseFactor = 0
136
- applicatorAbilityType.buffTypeIds = {applicableBuffType.id}
137
- if applicatorAbilityType.levelCount > 1 then
138
- multilevelPhysicalPositiveApplicatorAbilityTypes[#multilevelPhysicalPositiveApplicatorAbilityTypes + 1] = applicatorAbilityType
157
+ local applicatorUpgradeIds = {}
158
+ local applicatorUpgradeIdByApplicatorAbilityTypeId = {}
159
+ for ____, multilevelPhysicalPositiveApplicatorAbilityTypesChunk in ipairs(chunked(multilevelPhysicalPositiveApplicatorAbilityTypes, 4)) do
160
+ local maxLevelCount = max(map(multilevelPhysicalPositiveApplicatorAbilityTypesChunk, "levelCount"))
161
+ local applicatorAbilityTypeIds = map(multilevelPhysicalPositiveApplicatorAbilityTypesChunk, "id")
162
+ local applicatorUpgrade = BlankUpgrade:create()
163
+ applicatorUpgrade.isInternal = true
164
+ applicatorUpgrade.levelCount = maxLevelCount - 1
165
+ applicatorUpgrade.effects = map(
166
+ applicatorAbilityTypeIds,
167
+ function(applicatorAbilityTypeId)
168
+ return {type = "rlev", bonusBase = 1, bonusIncrement = 1, abilityTypeId = applicatorAbilityTypeId}
139
169
  end
140
- applicatorAbilityTypeIdByApplicatorType[852100] = applicatorAbilityType.id
170
+ )
171
+ applicatorUpgradeIds[#applicatorUpgradeIds + 1] = applicatorUpgrade.id
172
+ for ____, applicatorAbilityTypeId in ipairs(applicatorAbilityTypeIds) do
173
+ applicatorUpgradeIdByApplicatorAbilityTypeId[applicatorAbilityTypeId] = applicatorUpgrade.id
141
174
  end
142
175
  end
143
- if applicableBuffType.polarity == 0 or applicableBuffType.polarity == nil then
144
- local applicatorAbilityType = prepareAbilityType(PermanentImmolationAbilityType, applicableBuffType)
145
- applicatorAbilityType.levelCount = 1
146
- applicatorAbilityType.damagePerInterval = 0
147
- applicatorAbilityType.castRange = 0
148
- applicatorAbilityType.buffDuration = MAXIMUM_INTEGER
149
- applicatorAbilityType.heroBuffDuration = MAXIMUM_INTEGER
150
- applicatorAbilityType.allowedTargetCombatClassifications = combatClassificationsOf(1)
151
- applicatorAbilityType.buffTypeIds = {applicableBuffType.id}
152
- applicatorAbilityTypeIdByApplicatorType[0] = applicatorAbilityType.id
153
- end
154
- applicatorAbilityTypeIdByApplicatorTypeByApplicableBuffTypeId[applicableBuffType.id] = applicatorAbilityTypeIdByApplicatorType
155
- end
156
- local applicatorUpgradeIds = {}
157
- local applicatorUpgradeIdByApplicatorAbilityTypeId = {}
158
- for ____, multilevelPhysicalPositiveApplicatorAbilityTypesChunk in ipairs(chunked(multilevelPhysicalPositiveApplicatorAbilityTypes, 4)) do
159
- local maxLevelCount = max(map(multilevelPhysicalPositiveApplicatorAbilityTypesChunk, "levelCount"))
160
- local applicatorAbilityTypeIds = map(multilevelPhysicalPositiveApplicatorAbilityTypesChunk, "id")
161
- local applicatorUpgrade = BlankUpgrade:create()
162
- applicatorUpgrade.isInternal = true
163
- applicatorUpgrade.levelCount = maxLevelCount - 1
164
- applicatorUpgrade.effects = map(
165
- applicatorAbilityTypeIds,
166
- function(applicatorAbilityTypeId)
167
- return {type = "rlev", bonusBase = 1, bonusIncrement = 1, abilityTypeId = applicatorAbilityTypeId}
168
- end
169
- )
170
- applicatorUpgradeIds[#applicatorUpgradeIds + 1] = applicatorUpgrade.id
171
- for ____, applicatorAbilityTypeId in ipairs(applicatorAbilityTypeIds) do
172
- applicatorUpgradeIdByApplicatorAbilityTypeId[applicatorAbilityTypeId] = applicatorUpgrade.id
176
+ for ____, unitType in ipairs(UnitType:getAll()) do
177
+ local ____array_0 = __TS__SparseArrayNew(table.unpack(unitType.affectingUpgradeIds))
178
+ __TS__SparseArrayPush(
179
+ ____array_0,
180
+ table.unpack(applicatorUpgradeIds)
181
+ )
182
+ unitType.affectingUpgradeIds = {__TS__SparseArraySpread(____array_0)}
173
183
  end
174
- end
175
- for ____, unitType in ipairs(UnitType:getAll()) do
176
- local ____array_0 = __TS__SparseArrayNew(table.unpack(unitType.affectingUpgradeIds))
177
- __TS__SparseArrayPush(
178
- ____array_0,
179
- table.unpack(applicatorUpgradeIds)
180
- )
181
- unitType.affectingUpgradeIds = {__TS__SparseArraySpread(____array_0)}
182
- end
183
- return {applicatorAbilityTypeIdByApplicatorTypeByApplicableBuffTypeId, applicatorUpgradeIdByApplicatorAbilityTypeId}
184
- end))
184
+ return {applicatorAbilityTypeIdByApplicatorTypeByApplicableBuffTypeId, applicatorUpgradeIdByApplicatorAbilityTypeId}
185
+ end),
186
+ 1,
187
+ 2
188
+ )
185
189
  local EVASION_ABILITY_TYPE_IDS = postcompile(function()
186
190
  return AbilityType:getAllIdsByBaseIds(map({
187
191
  "AEev",
@@ -519,9 +519,9 @@ __TS__SetDescriptor(
519
519
  )
520
520
  ____exports.resolveCurrentAbilityDependentValue = function(ability, value)
521
521
  if __TS__InstanceOf(value, ____exports.AbilityField) then
522
- return value:getValue(ability)
522
+ return value:getValue(ability, true)
523
523
  elseif __TS__InstanceOf(value, ____exports.AbilityLevelField) then
524
- return value:getValue(ability, ability.level)
524
+ return value:getValue(ability, ability.level, true)
525
525
  elseif type(value) == "function" then
526
526
  return value(ability)
527
527
  else
@@ -0,0 +1,22 @@
1
+ /** @noSelfInFile */
2
+ import { ObjectField } from "../object-field";
3
+ import { Item } from "../internal/item";
4
+ import { ItemType, ItemTypeId } from "../object-data/entry/item-type";
5
+ export declare abstract class ItemField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType = any> extends ObjectField<ItemType, Item, ValueType, NativeFieldType> {
6
+ protected get instanceClass(): typeof Item;
7
+ protected getObjectDataEntryId(instance: Item): ItemTypeId;
8
+ }
9
+ export declare class ItemBooleanField extends ItemField<boolean, jitembooleanfield> {
10
+ protected get defaultValue(): boolean;
11
+ protected getNativeFieldById(id: number): jitembooleanfield;
12
+ protected hasNativeFieldValue(): boolean;
13
+ protected getNativeFieldValue(instance: Item): boolean;
14
+ protected setNativeFieldValue(instance: Item, value: boolean): boolean;
15
+ }
16
+ export declare class ItemIntegerField extends ItemField<number, jitemintegerfield> {
17
+ protected get defaultValue(): number;
18
+ protected getNativeFieldById(id: number): jitemintegerfield;
19
+ protected hasNativeFieldValue(): boolean;
20
+ protected getNativeFieldValue(instance: Item): number;
21
+ protected setNativeFieldValue(instance: Item, value: number): boolean;
22
+ }
@@ -0,0 +1,118 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
+ local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
5
+ local ____exports = {}
6
+ local ____object_2Dfield = require("engine.object-field")
7
+ local ObjectField = ____object_2Dfield.ObjectField
8
+ local ____item = require("engine.internal.item")
9
+ local Item = ____item.Item
10
+ local ____lua_2Dsets = require("utility.lua-sets")
11
+ local luaSetOf = ____lua_2Dsets.luaSetOf
12
+ local convertItemBooleanField = ConvertItemBooleanField
13
+ local convertItemIntegerField = ConvertItemIntegerField
14
+ local getItemBooleanField = BlzGetItemBooleanField
15
+ local getItemIntegerField = BlzGetItemIntegerField
16
+ local isItemPawnable = IsItemPawnable
17
+ local isItemPowerup = IsItemPowerup
18
+ local setItemBooleanField = BlzSetItemBooleanField
19
+ local setItemDropOnDeath = SetItemDropOnDeath
20
+ local setItemDroppable = SetItemDroppable
21
+ local setItemPawnable = SetItemPawnable
22
+ local setItemIntegerField = BlzSetItemIntegerField
23
+ ____exports.ItemField = __TS__Class()
24
+ local ItemField = ____exports.ItemField
25
+ ItemField.name = "ItemField"
26
+ __TS__ClassExtends(ItemField, ObjectField)
27
+ function ItemField.prototype.getObjectDataEntryId(self, instance)
28
+ return instance.typeId
29
+ end
30
+ __TS__SetDescriptor(
31
+ ItemField.prototype,
32
+ "instanceClass",
33
+ {get = function(self)
34
+ return Item
35
+ end},
36
+ true
37
+ )
38
+ local nativeItemBooleanFieldIds = luaSetOf(
39
+ fourCC("ipaw"),
40
+ fourCC("iusa")
41
+ )
42
+ ____exports.ItemBooleanField = __TS__Class()
43
+ local ItemBooleanField = ____exports.ItemBooleanField
44
+ ItemBooleanField.name = "ItemBooleanField"
45
+ __TS__ClassExtends(ItemBooleanField, ____exports.ItemField)
46
+ function ItemBooleanField.prototype.getNativeFieldById(self, id)
47
+ return convertItemBooleanField(id)
48
+ end
49
+ function ItemBooleanField.prototype.hasNativeFieldValue(self)
50
+ return nativeItemBooleanFieldIds[self.id] ~= nil
51
+ end
52
+ function ItemBooleanField.prototype.getNativeFieldValue(self, instance)
53
+ return getItemBooleanField(instance.handle, self.nativeField)
54
+ end
55
+ function ItemBooleanField.prototype.setNativeFieldValue(self, instance, value)
56
+ if self.id == fourCC("iusa") then
57
+ local handle = instance.handle
58
+ local powerUp = isItemPowerup(handle)
59
+ local perishes = getItemBooleanField(handle, ITEM_BF_PERISHABLE)
60
+ local dropsOnDeath = getItemBooleanField(handle, ITEM_BF_DROPPED_WHEN_CARRIER_DIES)
61
+ local canBeDropped = getItemBooleanField(handle, ITEM_BF_CAN_BE_DROPPED)
62
+ local canBeSold = isItemPawnable(handle)
63
+ local result = setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, value)
64
+ setItemPawnable(handle, canBeSold)
65
+ setItemDroppable(handle, canBeDropped)
66
+ setItemDropOnDeath(handle, dropsOnDeath)
67
+ setItemBooleanField(handle, ITEM_BF_PERISHABLE, perishes)
68
+ setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, powerUp)
69
+ return result
70
+ end
71
+ return setItemBooleanField(instance.handle, self.nativeField, value)
72
+ end
73
+ __TS__SetDescriptor(
74
+ ItemBooleanField.prototype,
75
+ "defaultValue",
76
+ {get = function(self)
77
+ return false
78
+ end},
79
+ true
80
+ )
81
+ local nativeItemIntegerFieldIds = luaSetOf(
82
+ fourCC("ilev"),
83
+ fourCC("iuse"),
84
+ fourCC("icid"),
85
+ fourCC("ihtp"),
86
+ fourCC("ihpc"),
87
+ fourCC("ipri"),
88
+ fourCC("iarm"),
89
+ fourCC("iclr"),
90
+ fourCC("iclg"),
91
+ fourCC("iclb"),
92
+ fourCC("ical")
93
+ )
94
+ ____exports.ItemIntegerField = __TS__Class()
95
+ local ItemIntegerField = ____exports.ItemIntegerField
96
+ ItemIntegerField.name = "ItemIntegerField"
97
+ __TS__ClassExtends(ItemIntegerField, ____exports.ItemField)
98
+ function ItemIntegerField.prototype.getNativeFieldById(self, id)
99
+ return convertItemIntegerField(id)
100
+ end
101
+ function ItemIntegerField.prototype.hasNativeFieldValue(self)
102
+ return nativeItemIntegerFieldIds[self.id] ~= nil
103
+ end
104
+ function ItemIntegerField.prototype.getNativeFieldValue(self, instance)
105
+ return getItemIntegerField(instance.handle, self.nativeField)
106
+ end
107
+ function ItemIntegerField.prototype.setNativeFieldValue(self, instance, value)
108
+ return setItemIntegerField(instance.handle, self.nativeField, value)
109
+ end
110
+ __TS__SetDescriptor(
111
+ ItemIntegerField.prototype,
112
+ "defaultValue",
113
+ {get = function(self)
114
+ return 0
115
+ end},
116
+ true
117
+ )
118
+ return ____exports
@@ -88,7 +88,7 @@ export declare abstract class ObjectLevelField<ObjectDataEntryType extends Objec
88
88
  protected abstract getNativeFieldValue(instance: InstanceType, level: number): ValueType;
89
89
  protected abstract setNativeFieldValue(instance: InstanceType, level: number, value: ValueType): boolean;
90
90
  protected abstract getLevelCount(entry: ObjectDataEntryType | InstanceType): number;
91
- getValue<LevelType extends [number] | []>(entry: ObjectDataEntryType | InstanceType, ...[level]: LevelType): LevelType extends [number] ? ValueType : ValueType[];
91
+ getValue<LevelType extends [number, boolean?] | [boolean?]>(entry: ObjectDataEntryType | InstanceType, ...[level, includeModifiers]: LevelType): LevelType extends [number, boolean?] ? ValueType : ValueType[];
92
92
  setValue(entry: ObjectDataEntryType | InstanceType, ...[levelOrValue, value]: [value: ObjectDataEntryLevelFieldValueSupplier<InputValueType, ValueType>] | [level: number, value: InputValueType]): boolean;
93
93
  updateActualValue(instance: InstanceType, level?: number): void;
94
94
  applyModifier(instance: InstanceType, modifier: ObjectLevelFieldModifier<InstanceType, ValueType>): void;
@@ -403,12 +403,12 @@ ____exports.ObjectLevelField = __TS__Class()
403
403
  local ObjectLevelField = ____exports.ObjectLevelField
404
404
  ObjectLevelField.name = "ObjectLevelField"
405
405
  __TS__ClassExtends(ObjectLevelField, ObjectFieldBase)
406
- function ObjectLevelField.prototype.getValue(self, entry, level)
406
+ function ObjectLevelField.prototype.getValue(self, entry, level, includeModifiers)
407
407
  if level == nil then
408
408
  local result = {}
409
409
  local levelCount = self:getLevelCount(entry)
410
410
  for i = 0, levelCount - 1 do
411
- result[i + 1] = self:getValue(entry, i)
411
+ result[i + 1] = self:getValue(entry, i, includeModifiers)
412
412
  end
413
413
  return result
414
414
  end
@@ -426,11 +426,13 @@ function ObjectLevelField.prototype.getValue(self, entry, level)
426
426
  end
427
427
  return self.defaultValue
428
428
  end
429
- local ____opt_22 = self.originalValueByLevelByInstance
430
- local ____opt_20 = ____opt_22 and ____opt_22[entry]
431
- local originalValue = ____opt_20 and ____opt_20[level]
432
- if originalValue ~= nil then
433
- return originalValue
429
+ if not includeModifiers then
430
+ local ____opt_22 = self.originalValueByLevelByInstance
431
+ local ____opt_20 = ____opt_22 and ____opt_22[entry]
432
+ local originalValue = ____opt_20 and ____opt_20[level]
433
+ if originalValue ~= nil then
434
+ return originalValue
435
+ end
434
436
  end
435
437
  return self:getActualValue(entry, level)
436
438
  end
@@ -0,0 +1,4 @@
1
+ /** @noSelfInFile */
2
+ import { ItemBooleanField } from "../../object-field/item";
3
+ export declare const CAN_BE_SOLD_TO_MERCHANTS_ITEM_FIELD: ItemBooleanField & symbol;
4
+ export declare const IS_ACTIVELY_USED_ITEM_FIELD: ItemBooleanField & symbol;
@@ -0,0 +1,6 @@
1
+ local ____exports = {}
2
+ local ____item = require("engine.object-field.item")
3
+ local ItemBooleanField = ____item.ItemBooleanField
4
+ ____exports.CAN_BE_SOLD_TO_MERCHANTS_ITEM_FIELD = ItemBooleanField:create(fourCC("ipaw"))
5
+ ____exports.IS_ACTIVELY_USED_ITEM_FIELD = ItemBooleanField:create(fourCC("iusa"))
6
+ return ____exports
package/lualib_bundle.lua CHANGED
@@ -2241,7 +2241,7 @@ local function __TS__SourceMapTraceBack(fileName, sourceMap)
2241
2241
  end
2242
2242
  local result = string.gsub(
2243
2243
  trace,
2244
- "(%S+)%.lua:(%d+)",
2244
+ "([^%s<]+)%.lua:(%d+)",
2245
2245
  function(file, line) return replacer(nil, file .. ".lua", file .. ".ts", line) end
2246
2246
  )
2247
2247
  local function stringReplacer(____, file, line)
package/math.d.ts CHANGED
@@ -23,6 +23,8 @@ export declare const floor: typeof math.floor;
23
23
  export declare const log: typeof math.log;
24
24
  export declare const max: typeof math.max;
25
25
  export declare const min: typeof math.min;
26
+ export declare const sum: (x: number, ...numbers: number[]) => number;
27
+ export declare const product: (x: number, ...numbers: number[]) => number;
26
28
  /** Returns the signum function of the argument;
27
29
  * zero if the argument is zero,
28
30
  * 1.0 if the argument is greater than zero,
package/math.lua CHANGED
@@ -39,6 +39,20 @@ ____exports.floor = math.floor
39
39
  ____exports.log = math.log
40
40
  ____exports.max = math.max
41
41
  ____exports.min = math.min
42
+ ____exports.sum = function(x, ...)
43
+ for i = 1, select("#", ...) do
44
+ local number = select(i, ...)
45
+ x = x + number
46
+ end
47
+ return x
48
+ end
49
+ ____exports.product = function(x, ...)
50
+ for i = 1, select("#", ...) do
51
+ local number = select(i, ...)
52
+ x = x * number
53
+ end
54
+ return x
55
+ end
42
56
  --- Returns the signum function of the argument;
43
57
  -- zero if the argument is zero,
44
58
  -- 1.0 if the argument is greater than zero,
@@ -153,7 +153,7 @@ end
153
153
  function ObjectDefinition.getLevelArrayFieldValue(self, level, value, values)
154
154
  return type(values) == "function" and values(level, value) or (__TS__ArrayIsArray(values[1]) and values[1] or values)
155
155
  end
156
- ____exports.ObjectType = ObjectType or ({})
156
+ ____exports.ObjectType = ____exports.ObjectType or ({})
157
157
  ____exports.ObjectType.ABILITY = 0
158
158
  ____exports.ObjectType[____exports.ObjectType.ABILITY] = "ABILITY"
159
159
  ____exports.ObjectType.ITEM = 1
package/operation.lua CHANGED
@@ -22,10 +22,7 @@ OperationMonitor.name = "OperationMonitor"
22
22
  __TS__ClassExtends(OperationMonitor, __TS__Promise)
23
23
  function OperationMonitor.prototype.____constructor(self, operation, ...)
24
24
  local args = {...}
25
- __TS__Promise.prototype.____constructor(
26
- self,
27
- table.unpack(args)
28
- )
25
+ __TS__Promise.prototype.____constructor(self, ...)
29
26
  self.o = operation
30
27
  end
31
28
  function OperationMonitor.prototype.cancel(self)
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.5abc199",
4
+ "version": "0.0.1-dev.5c35450",
5
5
  "description": "A typescript library for Warcraft III using Warpack.",
6
6
  "keywords": [
7
7
  "warcraft",
@@ -22,13 +22,13 @@
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@warscript/language-extensions": "^0.0.1",
25
- "@warscript/tstl-plugin": "^0.0.4",
25
+ "@warscript/tstl-plugin": "^0.0.6",
26
26
  "lua-types": "^2.13.1",
27
27
  "warpack": "0.0.1-dev.e490aaf"
28
28
  },
29
29
  "devDependencies": {
30
- "@typescript-eslint/eslint-plugin": "^8.13.0",
31
- "@typescript-eslint/parser": "^8.13.0",
30
+ "@typescript-eslint/eslint-plugin": "^8.61.1",
31
+ "@typescript-eslint/parser": "^8.61.1",
32
32
  "async": "^3.2.6",
33
33
  "copyfiles": "^2.4.1",
34
34
  "eslint": "^9.14.0",
@@ -15,7 +15,7 @@ export interface ReadonlyLinkedMap<K extends AnyNotNil, V> extends LuaPairsItera
15
15
  readonly size: number;
16
16
  }
17
17
  export interface LinkedMap<K extends AnyNotNil, V> extends LuaPairsIterable<K, V> {
18
- readonly __linkedSet: unique symbol;
18
+ readonly __linkedMap: unique symbol;
19
19
  }
20
20
  export declare class LinkedMap<K extends AnyNotNil, V> implements ReadonlyLinkedMap<K, V> {
21
21
  private k;
@@ -27,6 +27,7 @@ export declare class LinkedMap<K extends AnyNotNil, V> implements ReadonlyLinked
27
27
  remove(key: K): boolean;
28
28
  contains(key: AnyNotNil): key is K & OneSidedTypeGuard;
29
29
  get size(): number;
30
+ protected __len(): number;
30
31
  protected __pairs(this: LinkedMap<K, V>): LuaIterator<LuaMultiReturn<[K | undefined, V | undefined]>, IteratorState<K, V>>;
31
32
  }
32
33
  export declare const emptyLinkedMap: <K extends AnyNotNil, V>() => ReadonlyLinkedMap<K, V>;
@@ -47,6 +47,9 @@ end
47
47
  function LinkedMap.prototype.contains(self, key)
48
48
  return self.keys:contains(key)
49
49
  end
50
+ function LinkedMap.prototype.__len(self)
51
+ return self.keys.size
52
+ end
50
53
  function LinkedMap.prototype.__pairs(self)
51
54
  return linkedMapNext, {n = self.k.f, t = self.k.n, v = self.v}, nil
52
55
  end
@@ -88,6 +91,9 @@ function EmptyLinkedMap.prototype.remove(self)
88
91
  0
89
92
  )
90
93
  end
94
+ function EmptyLinkedMap.prototype.__len(self)
95
+ return 0
96
+ end
91
97
  function EmptyLinkedMap.prototype.__pairs(self)
92
98
  return linkedMapNext, emptyIteratorState, nil
93
99
  end
@@ -49,6 +49,7 @@ export declare class LinkedSet<T extends AnyNotNil> implements ReadonlyLinkedSet
49
49
  toArray(): T[];
50
50
  sumOf(selector: ((value: T) => number) | KeysOfType<T, number>): number;
51
51
  sortBy<R>(selector: ((value: T) => R) | KeysOfType<T, R>): void;
52
+ protected __len(): number;
52
53
  protected __pairs(this: LinkedSet<T>): LuaIterator<T | undefined, IteratorState<T>>;
53
54
  }
54
55
  export declare const emptyLinkedSet: <T extends AnyNotNil>() => ReadonlyLinkedSet<T>;
@@ -188,6 +188,9 @@ function LinkedSet.prototype.sortBy(self, selector)
188
188
  self.f = array[1]
189
189
  self.l = array[s]
190
190
  end
191
+ function LinkedSet.prototype.__len(self)
192
+ return self.s
193
+ end
191
194
  function LinkedSet.prototype.__pairs(self)
192
195
  return linkedSetNext, {t = self.n, n = self.f}, nil
193
196
  end
@@ -209,6 +212,9 @@ function EmptyLinkedSet.prototype.add(self)
209
212
  0
210
213
  )
211
214
  end
215
+ function EmptyLinkedSet.prototype.__len(self)
216
+ return 0
217
+ end
212
218
  function EmptyLinkedSet.prototype.__pairs(self)
213
219
  return linkedSetNext, emptyIteratorState, nil
214
220
  end
@@ -0,0 +1,27 @@
1
+ /** @noSelfInFile */
2
+ type OneSidedTypeGuard = {
3
+ readonly __oneSidedTypeGuard: unique symbol;
4
+ };
5
+ export interface ReadonlyUnorderedMap<K extends AnyNotNil, V> extends LuaPairsIterable<K, V> {
6
+ get(key: K): V | undefined;
7
+ contains(key: AnyNotNil): key is K & OneSidedTypeGuard;
8
+ readonly size: number;
9
+ }
10
+ export interface UnorderedMap<K extends AnyNotNil, V> extends LuaPairsIterable<K, V> {
11
+ readonly __unorderedMap: unique symbol;
12
+ }
13
+ export declare class UnorderedMap<K extends AnyNotNil, V> implements ReadonlyUnorderedMap<K, V> {
14
+ private readonly v;
15
+ private s;
16
+ get(key: K): V | undefined;
17
+ getOrPut(key: K, defaultValue: (this: void) => V): V;
18
+ put(key: K, value: V): void;
19
+ remove(key: K): boolean;
20
+ contains(key: AnyNotNil): key is K & OneSidedTypeGuard;
21
+ get size(): number;
22
+ protected __len(): number;
23
+ protected __pairs(this: UnorderedMap<K, V>): ReturnType<typeof pairs>;
24
+ }
25
+ export declare const emptyUnorderedMap: <K extends AnyNotNil, V>() => ReadonlyUnorderedMap<K, V>;
26
+ export declare const mutableUnorderedMap: <K extends AnyNotNil, V>() => UnorderedMap<K, V>;
27
+ export {};