warscript 0.0.1-dev.f48f7bb → 0.0.1-dev.f9166a3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/attributes.d.ts +5 -0
- package/attributes.lua +8 -1
- package/config.d.ts +5 -0
- package/config.lua +10 -0
- package/core/types/effect.d.ts +1 -3
- package/core/types/effect.lua +26 -29
- package/core/types/order.d.ts +1 -0
- package/core/types/order.lua +11 -1
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/timer.d.ts +6 -7
- package/core/types/timer.lua +18 -21
- package/core/util.lua +6 -1
- package/decl/native.d.ts +840 -786
- package/engine/behaviour/ability/apply-buff.d.ts +5 -0
- package/engine/behaviour/ability/apply-buff.lua +32 -0
- package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
- package/engine/behaviour/ability/damage.d.ts +9 -3
- package/engine/behaviour/ability/damage.lua +26 -38
- package/engine/behaviour/ability/emulate-impact.lua +16 -2
- package/engine/behaviour/ability.d.ts +7 -2
- package/engine/behaviour/ability.lua +35 -8
- package/engine/behaviour/unit.d.ts +17 -0
- package/engine/behaviour/unit.lua +114 -4
- package/engine/buff.d.ts +56 -41
- package/engine/buff.lua +295 -228
- package/engine/internal/ability.d.ts +4 -0
- package/engine/internal/ability.lua +17 -2
- package/engine/internal/item/ability.lua +15 -13
- package/engine/internal/item.d.ts +7 -4
- package/engine/internal/item.lua +131 -28
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
- package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
- package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
- package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
- package/engine/internal/object-data/evasion-probability.d.ts +2 -0
- package/engine/internal/object-data/evasion-probability.lua +16 -0
- package/engine/internal/unit/ability.d.ts +5 -0
- package/engine/internal/unit/ability.lua +14 -0
- package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
- package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot.lua +52 -0
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/bonus.d.ts +2 -0
- package/engine/internal/unit/bonus.lua +17 -0
- package/engine/internal/unit/item.lua +3 -48
- package/engine/internal/unit+damage.d.ts +2 -11
- package/engine/internal/unit+damage.lua +10 -14
- package/engine/internal/unit+spellSteal.lua +1 -2
- package/engine/internal/unit-missile-launch.lua +1 -1
- package/engine/internal/unit.d.ts +27 -4
- package/engine/internal/unit.lua +178 -37
- package/engine/lightning.d.ts +12 -5
- package/engine/lightning.lua +48 -14
- package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
- package/engine/object-data/auxiliary/animation-name.lua +16 -0
- package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
- package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
- package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
- package/engine/object-data/auxiliary/attack-type.lua +42 -0
- package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
- package/engine/object-data/auxiliary/movement-type.lua +22 -0
- package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
- package/engine/object-data/auxiliary/sound-eax.lua +2 -0
- package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
- package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
- package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
- package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
- package/engine/object-data/entry/ability-type/berserk.lua +13 -0
- package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
- package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
- package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
- package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
- package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
- package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
- package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
- package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
- package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
- package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
- package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
- package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
- package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
- package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
- package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
- package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
- package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
- package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
- package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
- package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
- package/engine/object-data/entry/ability-type/web.d.ts +12 -0
- package/engine/object-data/entry/ability-type/web.lua +52 -0
- package/engine/object-data/entry/ability-type.d.ts +19 -17
- package/engine/object-data/entry/ability-type.lua +81 -21
- package/engine/object-data/entry/buff-type/applicable.lua +18 -37
- package/engine/object-data/entry/buff-type.d.ts +6 -12
- package/engine/object-data/entry/buff-type.lua +13 -29
- package/engine/object-data/entry/destructible-type.d.ts +1 -1
- package/engine/object-data/entry/item-type.d.ts +1 -1
- package/engine/object-data/entry/item-type.lua +4 -4
- package/engine/object-data/entry/lightning-type.d.ts +1 -1
- package/engine/object-data/entry/sound-preset.d.ts +33 -0
- package/engine/object-data/entry/sound-preset.lua +140 -0
- package/engine/object-data/entry/unit-type.d.ts +10 -3
- package/engine/object-data/entry/unit-type.lua +155 -92
- package/engine/object-data/entry/upgrade.d.ts +1 -1
- package/engine/object-data/entry/upgrade.lua +4 -4
- package/engine/object-data/entry.d.ts +16 -14
- package/engine/object-data/entry.lua +60 -32
- package/engine/object-field/ability.d.ts +1 -1
- package/engine/object-field/unit.d.ts +46 -3
- package/engine/object-field/unit.lua +173 -7
- package/engine/object-field.d.ts +12 -3
- package/engine/object-field.lua +164 -78
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- package/engine/standard/entries/sound-preset.d.ts +10 -0
- package/engine/standard/entries/sound-preset.lua +10 -0
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/objutil/buff.lua +1 -2
- package/objutil/unit.lua +8 -0
- package/package.json +2 -2
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +3 -0
- package/utility/functions.d.ts +1 -0
- package/utility/functions.lua +1 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +3 -0
- package/utility/lua-maps.d.ts +3 -0
- package/utility/lua-maps.lua +16 -0
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +3 -0
- package/utility/reflection.lua +11 -7
package/engine/object-field.lua
CHANGED
|
@@ -20,6 +20,11 @@ local extractObjectDataEntryLevelFieldValue = ____entry.extractObjectDataEntryLe
|
|
|
20
20
|
local ObjectDataEntry = ____entry.ObjectDataEntry
|
|
21
21
|
local ____object_2Ddata_2Dentry_2Did_2Dgenerator = require("engine.object-data.utility.object-data-entry-id-generator")
|
|
22
22
|
local ObjectDataEntryIdGenerator = ____object_2Ddata_2Dentry_2Did_2Dgenerator.ObjectDataEntryIdGenerator
|
|
23
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
24
|
+
local mutableLinkedSet = ____linked_2Dset.mutableLinkedSet
|
|
25
|
+
local ____lua_2Dmaps = require("utility.lua-maps")
|
|
26
|
+
local getOrPut = ____lua_2Dmaps.getOrPut
|
|
27
|
+
local mutableWeakLuaMap = ____lua_2Dmaps.mutableWeakLuaMap
|
|
23
28
|
local compiletimeDefaultValueByObjectDataEntryIdByObjectFieldId = {}
|
|
24
29
|
local defaultValueByObjectDataEntryIdByObjectFieldId = postcompile(function() return compiletimeDefaultValueByObjectDataEntryIdByObjectFieldId end)
|
|
25
30
|
local objectFieldById = {}
|
|
@@ -29,7 +34,11 @@ local idGenerator = __TS__New(
|
|
|
29
34
|
)
|
|
30
35
|
local ObjectFieldBase = __TS__Class()
|
|
31
36
|
ObjectFieldBase.name = "ObjectFieldBase"
|
|
32
|
-
function ObjectFieldBase.prototype.____constructor(self, id)
|
|
37
|
+
function ObjectFieldBase.prototype.____constructor(self, id, isGlobal)
|
|
38
|
+
if isGlobal == nil then
|
|
39
|
+
isGlobal = true
|
|
40
|
+
end
|
|
41
|
+
self.isGlobal = isGlobal
|
|
33
42
|
self.valueByInstance = setmetatable({}, {__mode = "k"})
|
|
34
43
|
if objectFieldById[id] ~= nil then
|
|
35
44
|
error(
|
|
@@ -48,7 +57,7 @@ function ObjectFieldBase.prototype.supports(self, instance)
|
|
|
48
57
|
end
|
|
49
58
|
function ObjectFieldBase.prototype.hasValue(self, instance)
|
|
50
59
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
51
|
-
return defaultValueByObjectDataEntryId ~= nil and defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)] ~= nil or self:hasNativeFieldValue(instance)
|
|
60
|
+
return self.isGlobal or defaultValueByObjectDataEntryId ~= nil and defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)] ~= nil or self:hasNativeFieldValue(instance)
|
|
52
61
|
end
|
|
53
62
|
function ObjectFieldBase.create(self, id)
|
|
54
63
|
return __TS__New(
|
|
@@ -75,7 +84,7 @@ ____exports.ObjectField = __TS__Class()
|
|
|
75
84
|
local ObjectField = ____exports.ObjectField
|
|
76
85
|
ObjectField.name = "ObjectField"
|
|
77
86
|
__TS__ClassExtends(ObjectField, ObjectFieldBase)
|
|
78
|
-
function ObjectField.prototype.getValue(self, entry)
|
|
87
|
+
function ObjectField.prototype.getValue(self, entry, includeModifiers)
|
|
79
88
|
if __TS__InstanceOf(entry, ObjectDataEntry) then
|
|
80
89
|
local defaultValueByObjectDataEntryId = (warpack.compiletime and compiletimeDefaultValueByObjectDataEntryIdByObjectFieldId or defaultValueByObjectDataEntryIdByObjectFieldId)[self.id]
|
|
81
90
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
@@ -86,22 +95,16 @@ function ObjectField.prototype.getValue(self, entry)
|
|
|
86
95
|
end
|
|
87
96
|
return self.defaultValue
|
|
88
97
|
end
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
____self_valueByInstance_entry_0 = defaultValue
|
|
98
|
+
if includeModifiers == false then
|
|
99
|
+
local originalValueByInstance = self.originalValueByInstance
|
|
100
|
+
if originalValueByInstance ~= nil then
|
|
101
|
+
local originalValue = originalValueByInstance[entry]
|
|
102
|
+
if originalValue ~= nil then
|
|
103
|
+
return originalValue
|
|
96
104
|
end
|
|
97
|
-
return ____self_valueByInstance_entry_0
|
|
98
105
|
end
|
|
99
106
|
end
|
|
100
|
-
|
|
101
|
-
if ____temp_1 == nil then
|
|
102
|
-
____temp_1 = self.defaultValue
|
|
103
|
-
end
|
|
104
|
-
return ____temp_1
|
|
107
|
+
return self:getActualValue(entry)
|
|
105
108
|
end
|
|
106
109
|
function ObjectField.prototype.setValue(self, entry, value)
|
|
107
110
|
if __TS__InstanceOf(entry, ObjectDataEntry) then
|
|
@@ -116,37 +119,53 @@ function ObjectField.prototype.setValue(self, entry, value)
|
|
|
116
119
|
defaultValueByObjectDataEntryId[entry.id] = value
|
|
117
120
|
return true
|
|
118
121
|
end
|
|
119
|
-
local
|
|
120
|
-
if
|
|
121
|
-
local
|
|
122
|
-
if
|
|
123
|
-
local
|
|
124
|
-
if
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
local ____self_valueByInstance_entry_2_3 = ____self_valueByInstance_entry_2
|
|
128
|
-
if ____self_valueByInstance_entry_2_3 == nil then
|
|
129
|
-
____self_valueByInstance_entry_2_3 = self.defaultValue
|
|
130
|
-
end
|
|
131
|
-
local previousValue = ____self_valueByInstance_entry_2_3
|
|
132
|
-
if value ~= previousValue then
|
|
133
|
-
self.valueByInstance[entry] = value
|
|
134
|
-
self:invokeValueChangeEvent(entry, self, previousValue, value)
|
|
122
|
+
local modifiersByInstance = self.modifiersByInstance
|
|
123
|
+
if modifiersByInstance ~= nil then
|
|
124
|
+
local modifiers = modifiersByInstance[entry]
|
|
125
|
+
if modifiers ~= nil and modifiers.size ~= 0 then
|
|
126
|
+
local originalValueByInstance = self.originalValueByInstance
|
|
127
|
+
if originalValueByInstance == nil then
|
|
128
|
+
originalValueByInstance = mutableWeakLuaMap()
|
|
129
|
+
self.originalValueByInstance = originalValueByInstance
|
|
135
130
|
end
|
|
136
|
-
|
|
131
|
+
originalValueByInstance[entry] = value
|
|
132
|
+
value = self:calculateActualValue(entry)
|
|
137
133
|
end
|
|
138
134
|
end
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
return self:setActualValue(entry, value)
|
|
136
|
+
end
|
|
137
|
+
function ObjectField.prototype.applyModifier(self, instance, modifier)
|
|
138
|
+
local modifiersByInstance = self.modifiersByInstance
|
|
139
|
+
if modifiersByInstance == nil then
|
|
140
|
+
modifiersByInstance = mutableWeakLuaMap()
|
|
141
|
+
self.modifiersByInstance = modifiersByInstance
|
|
142
|
+
end
|
|
143
|
+
if getOrPut(modifiersByInstance, instance, mutableLinkedSet):add(modifier) then
|
|
144
|
+
local originalValueByInstance = self.originalValueByInstance
|
|
145
|
+
if originalValueByInstance == nil then
|
|
146
|
+
originalValueByInstance = mutableWeakLuaMap()
|
|
147
|
+
self.originalValueByInstance = originalValueByInstance
|
|
148
|
+
end
|
|
149
|
+
originalValueByInstance[instance] = self:getActualValue(instance)
|
|
150
|
+
self:setActualValue(
|
|
151
|
+
instance,
|
|
152
|
+
self:calculateActualValue(instance)
|
|
153
|
+
)
|
|
141
154
|
end
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
155
|
+
end
|
|
156
|
+
function ObjectField.prototype.removeModifier(self, instance, modifier)
|
|
157
|
+
local modifiersByInstance = self.modifiersByInstance
|
|
158
|
+
if modifiersByInstance ~= nil then
|
|
159
|
+
local modifiers = modifiersByInstance[instance]
|
|
160
|
+
if modifiers ~= nil and modifiers:remove(modifier) then
|
|
161
|
+
self:setActualValue(
|
|
162
|
+
instance,
|
|
163
|
+
self:calculateActualValue(instance)
|
|
164
|
+
)
|
|
165
|
+
return true
|
|
146
166
|
end
|
|
147
|
-
self:invokeValueChangeEvent(entry, self, previousValue, value)
|
|
148
167
|
end
|
|
149
|
-
return
|
|
168
|
+
return false
|
|
150
169
|
end
|
|
151
170
|
function ObjectField.prototype.removeValue(self, entry)
|
|
152
171
|
if not warpack.compiletime then
|
|
@@ -168,6 +187,73 @@ function ObjectField.prototype.trySetValue(self, entry, value)
|
|
|
168
187
|
end
|
|
169
188
|
return self:setValue(entry, value)
|
|
170
189
|
end
|
|
190
|
+
function ObjectField.prototype.getActualValue(self, instance)
|
|
191
|
+
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
192
|
+
if defaultValueByObjectDataEntryId ~= nil then
|
|
193
|
+
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)]
|
|
194
|
+
if defaultValue ~= nil then
|
|
195
|
+
local ____self_valueByInstance_instance_0 = self.valueByInstance[instance]
|
|
196
|
+
if ____self_valueByInstance_instance_0 == nil then
|
|
197
|
+
____self_valueByInstance_instance_0 = defaultValue
|
|
198
|
+
end
|
|
199
|
+
return ____self_valueByInstance_instance_0
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
local ____temp_1 = self:getNativeFieldValue(instance)
|
|
203
|
+
if ____temp_1 == nil then
|
|
204
|
+
____temp_1 = self.defaultValue
|
|
205
|
+
end
|
|
206
|
+
return ____temp_1
|
|
207
|
+
end
|
|
208
|
+
function ObjectField.prototype.setActualValue(self, instance, value)
|
|
209
|
+
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
210
|
+
if defaultValueByObjectDataEntryId ~= nil then
|
|
211
|
+
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)]
|
|
212
|
+
if defaultValue ~= nil then
|
|
213
|
+
local ____self_valueByInstance_instance_2 = self.valueByInstance[instance]
|
|
214
|
+
if ____self_valueByInstance_instance_2 == nil then
|
|
215
|
+
____self_valueByInstance_instance_2 = defaultValue
|
|
216
|
+
end
|
|
217
|
+
local ____self_valueByInstance_instance_2_3 = ____self_valueByInstance_instance_2
|
|
218
|
+
if ____self_valueByInstance_instance_2_3 == nil then
|
|
219
|
+
____self_valueByInstance_instance_2_3 = self.defaultValue
|
|
220
|
+
end
|
|
221
|
+
local previousValue = ____self_valueByInstance_instance_2_3
|
|
222
|
+
if value ~= previousValue then
|
|
223
|
+
self.valueByInstance[instance] = value
|
|
224
|
+
self:invokeValueChangeEvent(instance, self, previousValue, value)
|
|
225
|
+
end
|
|
226
|
+
return true
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
if not self:hasNativeFieldValue(instance) then
|
|
230
|
+
return false
|
|
231
|
+
end
|
|
232
|
+
local previousValue = self:getNativeFieldValue(instance)
|
|
233
|
+
if value ~= previousValue then
|
|
234
|
+
if not self:setNativeFieldValue(instance, value) then
|
|
235
|
+
return false
|
|
236
|
+
end
|
|
237
|
+
self:invokeValueChangeEvent(instance, self, previousValue, value)
|
|
238
|
+
end
|
|
239
|
+
return true
|
|
240
|
+
end
|
|
241
|
+
function ObjectField.prototype.calculateActualValue(self, instance)
|
|
242
|
+
local ____opt_4 = self.originalValueByInstance
|
|
243
|
+
local originalValue = ____opt_4 and ____opt_4[instance]
|
|
244
|
+
local ____opt_6 = self.modifiersByInstance
|
|
245
|
+
local modifiers = ____opt_6 and ____opt_6[instance]
|
|
246
|
+
if originalValue ~= nil then
|
|
247
|
+
local value = originalValue
|
|
248
|
+
if modifiers ~= nil then
|
|
249
|
+
for modifier in pairs(modifiers) do
|
|
250
|
+
value = modifier(instance, value, originalValue)
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
return value
|
|
254
|
+
end
|
|
255
|
+
return self.defaultValue
|
|
256
|
+
end
|
|
171
257
|
function ObjectField.prototype.invokeValueChangeEvent(self, ...)
|
|
172
258
|
self:invokeValueChangeEventRecursive(
|
|
173
259
|
getClass(self),
|
|
@@ -221,17 +307,17 @@ function ObjectArrayField.prototype.getValue(self, entry, index)
|
|
|
221
307
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
222
308
|
local value = defaultValueByObjectDataEntryId[entry.id]
|
|
223
309
|
if value ~= nil then
|
|
224
|
-
local
|
|
310
|
+
local ____temp_9
|
|
225
311
|
if index == nil then
|
|
226
|
-
|
|
312
|
+
____temp_9 = value
|
|
227
313
|
else
|
|
228
|
-
local
|
|
229
|
-
if
|
|
230
|
-
|
|
314
|
+
local ____value_index_8 = value[index + 1]
|
|
315
|
+
if ____value_index_8 == nil then
|
|
316
|
+
____value_index_8 = self.defaultValue
|
|
231
317
|
end
|
|
232
|
-
|
|
318
|
+
____temp_9 = ____value_index_8
|
|
233
319
|
end
|
|
234
|
-
return
|
|
320
|
+
return ____temp_9
|
|
235
321
|
end
|
|
236
322
|
end
|
|
237
323
|
return index == nil and ({}) or self.defaultValue
|
|
@@ -241,17 +327,17 @@ function ObjectArrayField.prototype.getValue(self, entry, index)
|
|
|
241
327
|
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(entry)]
|
|
242
328
|
if defaultValue ~= nil then
|
|
243
329
|
local value = self.valueByInstance[entry] or defaultValue
|
|
244
|
-
local
|
|
330
|
+
local ____temp_11
|
|
245
331
|
if index == nil then
|
|
246
|
-
|
|
332
|
+
____temp_11 = value
|
|
247
333
|
else
|
|
248
|
-
local
|
|
249
|
-
if
|
|
250
|
-
|
|
334
|
+
local ____value_index_10 = value[index + 1]
|
|
335
|
+
if ____value_index_10 == nil then
|
|
336
|
+
____value_index_10 = self.defaultValue
|
|
251
337
|
end
|
|
252
|
-
|
|
338
|
+
____temp_11 = ____value_index_10
|
|
253
339
|
end
|
|
254
|
-
return
|
|
340
|
+
return ____temp_11
|
|
255
341
|
end
|
|
256
342
|
end
|
|
257
343
|
if index ~= nil then
|
|
@@ -296,11 +382,11 @@ function ObjectLevelField.prototype.getValue(self, entry, level)
|
|
|
296
382
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
297
383
|
local valueByLevel = defaultValueByObjectDataEntryId[entry.id]
|
|
298
384
|
if valueByLevel ~= nil then
|
|
299
|
-
local
|
|
300
|
-
if
|
|
301
|
-
|
|
385
|
+
local ____valueByLevel_index_12 = valueByLevel[level + 1]
|
|
386
|
+
if ____valueByLevel_index_12 == nil then
|
|
387
|
+
____valueByLevel_index_12 = self.defaultValue
|
|
302
388
|
end
|
|
303
|
-
return
|
|
389
|
+
return ____valueByLevel_index_12
|
|
304
390
|
end
|
|
305
391
|
end
|
|
306
392
|
return self.defaultValue
|
|
@@ -309,23 +395,23 @@ function ObjectLevelField.prototype.getValue(self, entry, level)
|
|
|
309
395
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
310
396
|
local defaultValueByLevel = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(entry)]
|
|
311
397
|
if defaultValueByLevel ~= nil then
|
|
312
|
-
local
|
|
313
|
-
local
|
|
314
|
-
if
|
|
315
|
-
|
|
398
|
+
local ____opt_13 = self.valueByInstance[entry]
|
|
399
|
+
local ____temp_15 = ____opt_13 and ____opt_13[level + 1]
|
|
400
|
+
if ____temp_15 == nil then
|
|
401
|
+
____temp_15 = defaultValueByLevel[level + 1]
|
|
316
402
|
end
|
|
317
|
-
local
|
|
318
|
-
if
|
|
319
|
-
|
|
403
|
+
local ____temp_15_16 = ____temp_15
|
|
404
|
+
if ____temp_15_16 == nil then
|
|
405
|
+
____temp_15_16 = self.defaultValue
|
|
320
406
|
end
|
|
321
|
-
return
|
|
407
|
+
return ____temp_15_16
|
|
322
408
|
end
|
|
323
409
|
end
|
|
324
|
-
local
|
|
325
|
-
if
|
|
326
|
-
|
|
410
|
+
local ____temp_17 = self:getNativeFieldValue(entry, level)
|
|
411
|
+
if ____temp_17 == nil then
|
|
412
|
+
____temp_17 = self.defaultValue
|
|
327
413
|
end
|
|
328
|
-
return
|
|
414
|
+
return ____temp_17
|
|
329
415
|
end
|
|
330
416
|
function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
|
|
331
417
|
if value == nil then
|
|
@@ -374,15 +460,15 @@ function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
|
|
|
374
460
|
valueByLevel = {}
|
|
375
461
|
self.valueByInstance[entry] = valueByLevel
|
|
376
462
|
end
|
|
377
|
-
local
|
|
378
|
-
if
|
|
379
|
-
|
|
463
|
+
local ____valueByLevel_index_18 = valueByLevel[level + 1]
|
|
464
|
+
if ____valueByLevel_index_18 == nil then
|
|
465
|
+
____valueByLevel_index_18 = defaultValueByLevel[level + 1]
|
|
380
466
|
end
|
|
381
|
-
local
|
|
382
|
-
if
|
|
383
|
-
|
|
467
|
+
local ____valueByLevel_index_18_19 = ____valueByLevel_index_18
|
|
468
|
+
if ____valueByLevel_index_18_19 == nil then
|
|
469
|
+
____valueByLevel_index_18_19 = self.defaultValue
|
|
384
470
|
end
|
|
385
|
-
local previousValue =
|
|
471
|
+
local previousValue = ____valueByLevel_index_18_19
|
|
386
472
|
if value ~= previousValue then
|
|
387
473
|
valueByLevel[level + 1] = value
|
|
388
474
|
self:invokeValueChangeEvent(
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { StandardSoundPresetId } from "../../object-data/entry/sound-preset";
|
|
3
|
+
export declare const ABOMINATION_PISSED_SOUND_PRESET_ID: StandardSoundPresetId;
|
|
4
|
+
export declare const ABOMINATION_READY_SOUND_PRESET_ID: StandardSoundPresetId;
|
|
5
|
+
export declare const ABOMINATION_WAR_CRY_SOUND_PRESET_ID: StandardSoundPresetId;
|
|
6
|
+
export declare const AXE_MEDIUM_CHOP_WOOD_SOUND_PRESET_ID: StandardSoundPresetId;
|
|
7
|
+
export declare const IMPALE_SOUND_PRESET_ID: StandardSoundPresetId;
|
|
8
|
+
export declare const IMPALE_HIT_SOUND_PRESET_ID: StandardSoundPresetId;
|
|
9
|
+
export declare const IMPALE_LAND_SOUND_PRESET_ID: StandardSoundPresetId;
|
|
10
|
+
export declare const IMPALE_CAST_SOUND_PRESET_ID: StandardSoundPresetId;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
____exports.ABOMINATION_PISSED_SOUND_PRESET_ID = "AbominationPissed"
|
|
3
|
+
____exports.ABOMINATION_READY_SOUND_PRESET_ID = "AbominationReady"
|
|
4
|
+
____exports.ABOMINATION_WAR_CRY_SOUND_PRESET_ID = "AbominationWarcry"
|
|
5
|
+
____exports.AXE_MEDIUM_CHOP_WOOD_SOUND_PRESET_ID = "AxeMediumChopWood"
|
|
6
|
+
____exports.IMPALE_SOUND_PRESET_ID = "Impale"
|
|
7
|
+
____exports.IMPALE_HIT_SOUND_PRESET_ID = "ImpaleHit"
|
|
8
|
+
____exports.IMPALE_LAND_SOUND_PRESET_ID = "ImpaleLand"
|
|
9
|
+
____exports.IMPALE_CAST_SOUND_PRESET_ID = "ImpaleCast"
|
|
10
|
+
return ____exports
|
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/objutil/buff.lua
CHANGED
|
@@ -20,7 +20,6 @@ local AbilityDefinitionInnerFire = ____ability.AbilityDefinitionInnerFire
|
|
|
20
20
|
local AbilityDefinitionSearingArrows = ____ability.AbilityDefinitionSearingArrows
|
|
21
21
|
local AbilityDefinitionSlowPoison = ____ability.AbilityDefinitionSlowPoison
|
|
22
22
|
local ____unit = require("core.types.unit")
|
|
23
|
-
local AttackType = ____unit.AttackType
|
|
24
23
|
local DamageType = ____unit.DamageType
|
|
25
24
|
local Unit = ____unit.Unit
|
|
26
25
|
local ____dummy = require("core.dummy")
|
|
@@ -756,7 +755,7 @@ for ____, pointDispelAbilityId in ipairs(pointDispelAbilityIds) do
|
|
|
756
755
|
end)
|
|
757
756
|
end
|
|
758
757
|
Unit.onDamaging:addListener(function(source, target, event)
|
|
759
|
-
if event.amount == 0 and event.attackType ==
|
|
758
|
+
if event.amount == 0 and event.attackType == 0 and event.damageType == DamageType.NORMAL and not event.isAttack then
|
|
760
759
|
Timer:run(function()
|
|
761
760
|
checkBuffs(target, true, source)
|
|
762
761
|
end)
|
package/objutil/unit.lua
CHANGED
|
@@ -11,6 +11,8 @@ local ____exports = {}
|
|
|
11
11
|
local ____object = require("objutil.object")
|
|
12
12
|
local ObjectDefinition = ____object.ObjectDefinition
|
|
13
13
|
local idgen = require("objutil.idgen")
|
|
14
|
+
local ____config = require("config")
|
|
15
|
+
local WarscriptConfig = ____config.WarscriptConfig
|
|
14
16
|
local attackTypes = setmetatable(
|
|
15
17
|
{
|
|
16
18
|
normal = "normal",
|
|
@@ -593,6 +595,9 @@ __TS__SetDescriptor(
|
|
|
593
595
|
end,
|
|
594
596
|
set = function(self, v)
|
|
595
597
|
self:setStringField("umdl", v)
|
|
598
|
+
if WarscriptConfig.AUTOMATICALLY_SET_UNIT_TYPE_PORTRAIT_MODEL_PATH then
|
|
599
|
+
self:setStringField("upor", "")
|
|
600
|
+
end
|
|
596
601
|
end
|
|
597
602
|
},
|
|
598
603
|
true
|
|
@@ -606,6 +611,9 @@ __TS__SetDescriptor(
|
|
|
606
611
|
end,
|
|
607
612
|
set = function(self, v)
|
|
608
613
|
self.object:setField("umdl:hd", v)
|
|
614
|
+
if WarscriptConfig.AUTOMATICALLY_SET_UNIT_TYPE_PORTRAIT_MODEL_PATH then
|
|
615
|
+
self.object:setField("upor:hd", "")
|
|
616
|
+
end
|
|
609
617
|
end
|
|
610
618
|
},
|
|
611
619
|
true
|
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.
|
|
4
|
+
"version": "0.0.1-dev.f9166a3",
|
|
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.
|
|
27
|
+
"warpack": "0.0.1-dev.fa5e065"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
package/utility/arrays.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare const mapToLuaSet: {
|
|
|
22
22
|
<T, R extends AnyNotNil>(array: readonly T[], transform: (value: T) => R): LuaSet<R>;
|
|
23
23
|
<T, K extends KeysOfType<T, AnyNotNil>>(array: readonly T[], key: K): LuaSet<T[K] extends AnyNotNil ? T[K] : never>;
|
|
24
24
|
};
|
|
25
|
+
export declare const flatten: <T>(array: readonly (readonly T[])[]) => T[];
|
|
25
26
|
export declare const flatMap: {
|
|
26
27
|
<T, R>(array: readonly T[], transform: (value: T) => readonly R[]): R[];
|
|
27
28
|
<T, K extends KeysOfType<T, readonly any[]>>(array: readonly T[], key: K): (T[K] extends readonly (infer R)[] ? R : never)[];
|
package/utility/arrays.lua
CHANGED
|
@@ -3,6 +3,8 @@ local __TS__New = ____lualib.__TS__New
|
|
|
3
3
|
local ____exports = {}
|
|
4
4
|
local ____exception = require("exception")
|
|
5
5
|
local IllegalArgumentException = ____exception.IllegalArgumentException
|
|
6
|
+
local ____functions = require("utility.functions")
|
|
7
|
+
local identity = ____functions.identity
|
|
6
8
|
local mathMax = math.max
|
|
7
9
|
local mathMin = math.min
|
|
8
10
|
local select = _G.select
|
|
@@ -120,6 +122,7 @@ ____exports.mapToLuaSet = function(array, transform)
|
|
|
120
122
|
end
|
|
121
123
|
return result
|
|
122
124
|
end
|
|
125
|
+
____exports.flatten = function(array) return ____exports.flatMap(array, identity) end
|
|
123
126
|
____exports.flatMap = function(array, transform)
|
|
124
127
|
local result = {}
|
|
125
128
|
local k = 1
|
package/utility/functions.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export declare const apply: {
|
|
|
3
3
|
<T, ConsumerParameters extends any[]>(object: T, consumer: (value: T, ...parameters: ConsumerParameters) => void, ...parameters: ConsumerParameters): T;
|
|
4
4
|
<T, ConsumerParameters extends any[], K extends KeysOfType<T, (...parameters: ConsumerParameters) => void>>(object: T, key: K, ...parameters: ConsumerParameters): T;
|
|
5
5
|
};
|
|
6
|
+
export declare const identity: <T>(value: T) => T;
|
package/utility/functions.lua
CHANGED
package/utility/linked-set.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ export declare class LinkedSet<T extends AnyNotNil> implements ReadonlyLinkedSet
|
|
|
50
50
|
protected __pairs(this: LinkedSet<T>): LuaIterator<T | undefined, IteratorState<T>>;
|
|
51
51
|
}
|
|
52
52
|
export declare const emptyLinkedSet: <T extends AnyNotNil>() => ReadonlyLinkedSet<T>;
|
|
53
|
+
export declare const mutableLinkedSet: <T extends AnyNotNil>() => LinkedSet<T>;
|
|
53
54
|
export declare const mutableLinkedSetOf: <T extends AnyNotNil>(...elements: ReadonlyArray<T>) => LinkedSet<T>;
|
|
54
55
|
export declare const mutableLinkedSetOfNotNull: <T extends AnyNotNil>(...elements: readonly (T | undefined | null)[]) => LinkedSet<T>;
|
|
55
56
|
export declare const linkedSetOf: <T extends AnyNotNil>(...elements: ReadonlyArray<T>) => ReadonlyLinkedSet<T>;
|
package/utility/linked-set.lua
CHANGED
|
@@ -177,6 +177,9 @@ local EMPTY_LINKED_SET = __TS__New(EmptyLinkedSet)
|
|
|
177
177
|
____exports.emptyLinkedSet = function()
|
|
178
178
|
return EMPTY_LINKED_SET
|
|
179
179
|
end
|
|
180
|
+
____exports.mutableLinkedSet = function()
|
|
181
|
+
return __TS__New(____exports.LinkedSet)
|
|
182
|
+
end
|
|
180
183
|
____exports.mutableLinkedSetOf = function(...)
|
|
181
184
|
local linkedSet = __TS__New(____exports.LinkedSet)
|
|
182
185
|
for i = 1, select("#", ...) do
|
package/utility/lua-maps.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { Flatten, TupleOf } from "./types";
|
|
3
|
+
export declare const mutableLuaMap: <K extends AnyNotNil, V>() => LuaMap<K, V>;
|
|
4
|
+
export declare const mutableWeakLuaMap: <K extends AnyNotNil, V>() => LuaMap<K, V>;
|
|
3
5
|
export declare const luaMapOf: <K extends AnyNotNil, V>(...pairs: Flatten<TupleOf<[K, V], 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40>>) => LuaMap<K, V>;
|
|
4
6
|
export declare const luaMapInvert: <K extends AnyNotNil, V extends AnyNotNil>(luaMap: LuaMap<K, V>) => LuaMap<V, K>;
|
|
5
7
|
export declare const mapValues: <K extends AnyNotNil, V1, V2>(luaMap: LuaMap<K, V1>, transform: (value: V1) => V2) => LuaMap<K, V2>;
|
|
8
|
+
export declare const getOrPut: <K extends AnyNotNil, V>(luaMap: LuaMap<K, V>, key: K, defaultValue: () => V) => V;
|
package/utility/lua-maps.lua
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
2
|
local select = _G.select
|
|
3
|
+
local setmetatable = _G.setmetatable
|
|
4
|
+
local weakKeysMetatable = {__mode = "k"}
|
|
5
|
+
____exports.mutableLuaMap = function()
|
|
6
|
+
return {}
|
|
7
|
+
end
|
|
8
|
+
____exports.mutableWeakLuaMap = function()
|
|
9
|
+
return setmetatable({}, weakKeysMetatable)
|
|
10
|
+
end
|
|
3
11
|
____exports.luaMapOf = function(...)
|
|
4
12
|
local luaMap = {}
|
|
5
13
|
for i = 1, select("#", ...), 2 do
|
|
@@ -22,4 +30,12 @@ ____exports.mapValues = function(luaMap, transform)
|
|
|
22
30
|
end
|
|
23
31
|
return result
|
|
24
32
|
end
|
|
33
|
+
____exports.getOrPut = function(luaMap, key, defaultValue)
|
|
34
|
+
local value = luaMap[key]
|
|
35
|
+
if value == nil then
|
|
36
|
+
value = defaultValue()
|
|
37
|
+
luaMap[key] = value
|
|
38
|
+
end
|
|
39
|
+
return value
|
|
40
|
+
end
|
|
25
41
|
return ____exports
|
package/utility/lua-sets.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
+
export declare const mutableLuaSet: <T extends AnyNotNil>() => LuaSet<T>;
|
|
2
3
|
export declare const luaSetOf: <T extends AnyNotNil>(...elements: readonly T[]) => LuaSet<T>;
|
|
3
4
|
export declare const luaSetOfNotNull: <T extends AnyNotNil>(...elements: readonly (T | undefined | null)[]) => LuaSet<T>;
|
|
4
5
|
export declare const luaSetIntersection: <T extends AnyNotNil>(firstLuaSet: ReadonlyLuaSet<T>, secondLuaSet: ReadonlyLuaSet<T>) => LuaSet<T>;
|
package/utility/lua-sets.lua
CHANGED
package/utility/reflection.lua
CHANGED
|
@@ -5,21 +5,25 @@ local checkNotNull = ____preconditions.checkNotNull
|
|
|
5
5
|
-- @internal For use by internal systems only.
|
|
6
6
|
____exports.implementReadonlyNumberIndexSupplier = function(clazz, supplier)
|
|
7
7
|
local metatable = checkNotNull(getmetatable(clazz))
|
|
8
|
-
local originalIndex = checkNotNull(metatable
|
|
8
|
+
local originalIndex = checkNotNull(rawget(metatable, "__index"))
|
|
9
9
|
local memoizedValueByKey = {}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
rawset(
|
|
11
|
+
metatable,
|
|
12
|
+
"__index",
|
|
13
|
+
function(self, key)
|
|
13
14
|
if type(key) == "number" then
|
|
14
|
-
local value =
|
|
15
|
-
|
|
15
|
+
local value = memoizedValueByKey[key]
|
|
16
|
+
if value == nil then
|
|
17
|
+
value = supplier(key)
|
|
18
|
+
memoizedValueByKey[key] = value
|
|
19
|
+
end
|
|
16
20
|
return value
|
|
17
21
|
end
|
|
18
22
|
if type(originalIndex) == "function" then
|
|
19
23
|
return originalIndex(self, key)
|
|
20
24
|
end
|
|
21
25
|
return originalIndex[key]
|
|
22
|
-
end
|
|
26
|
+
end
|
|
23
27
|
)
|
|
24
28
|
end
|
|
25
29
|
____exports.getClass = function(object)
|