warscript 0.0.1-dev.38157d0 → 0.0.1-dev.3e67cca

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/core/util.d.ts CHANGED
@@ -54,7 +54,7 @@ declare global {
54
54
  function fourCC(id: string): number;
55
55
  }
56
56
  declare namespace inner {
57
- const orderId: (id: "blink" | "stop" | "load" | "sleep" | "absorb" | "acidbomb" | "acolyteharvest" | "ambush" | "ancestralspirit" | "ancestralspirittarget" | "animatedead" | "antimagicshell" | "attack" | "attackground" | "attackonce" | "attributemodskill" | "auraunholy" | "auravampiric" | "autodispel" | "autodispeloff" | "autodispelon" | "autoentangle" | "autoentangleinstant" | "autoharvestgold" | "autoharvestlumber" | "avatar" | "avengerform" | "awaken" | "banish" | "barkskin" | "barkskinoff" | "barkskinon" | "battleroar" | "battlestations" | "bearform" | "berserk" | "blackarrow" | "blackarrowoff" | "blackarrowon" | "blight" | "blizzard" | "bloodlust" | "bloodlustoff" | "bloodluston" | "board" | "breathoffire" | "breathoffrost" | "build" | "burrow" | "cannibalize" | "carrionscarabs" | "carrionscarabsinstant" | "carrionscarabsoff" | "carrionscarabson" | "carrionswarm" | "chainlightning" | "channel" | "charm" | "chemicalrage" | "cloudoffog" | "clusterrockets" | "coldarrows" | "coldarrowstarg" | "controlmagic" | "corporealform" | "corrosivebreath" | "coupleinstant" | "coupletarget" | "creepanimatedead" | "creepdevour" | "creepheal" | "creephealoff" | "creephealon" | "creepthunderbolt" | "creepthunderclap" | "cripple" | "curse" | "curseoff" | "curseon" | "cyclone" | "darkconversion" | "darkportal" | "darkritual" | "darksummoning" | "deathanddecay" | "deathcoil" | "deathpact" | "decouple" | "defend" | "detectaoe" | "detonate" | "devour" | "devourmagic" | "disassociate" | "disenchant" | "dismount" | "dispel" | "divineshield" | "doom" | "drain" | "dreadlordinferno" | "dropitem" | "drunkenhaze" | "earthquake" | "eattree" | "elementalfury" | "ensnare" | "ensnareoff" | "ensnareon" | "entangle" | "entangleinstant" | "entanglingroots" | "etherealform" | "evileye" | "faeriefire" | "faeriefireoff" | "faeriefireon" | "fanofknives" | "farsight" | "fingerofdeath" | "firebolt" | "flamestrike" | "flamingarrows" | "flamingarrowstarg" | "flamingattack" | "flamingattacktarg" | "flare" | "forceboard" | "forceofnature" | "forkedlightning" | "freezingbreath" | "frenzy" | "frenzyoff" | "frenzyon" | "frostarmor" | "frostarmoroff" | "frostarmoron" | "frostnova" | "getitem" | "gold2lumber" | "grabtree" | "harvest" | "heal" | "healingspray" | "healingward" | "healingwave" | "healoff" | "healon" | "hex" | "holdposition" | "holybolt" | "howlofterror" | "humanbuild" | "immolation" | "impale" | "incineratearrow" | "incineratearrowoff" | "incineratearrowon" | "inferno" | "innerfire" | "innerfireoff" | "innerfireon" | "instant" | "invisibility" | "lavamonster" | "lightningshield" | "loadarcher" | "loadcorpse" | "loadcorpseinstant" | "locustswarm" | "lumber2gold" | "magicdefense" | "magicleash" | "magicundefense" | "manaburn" | "manaflareoff" | "manaflareon" | "manashieldoff" | "manashieldon" | "massteleport" | "mechanicalcritter" | "metamorphosis" | "militia" | "militiaconvert" | "militiaoff" | "militiaunconvert" | "mindrot" | "mirrorimage" | "monsoon" | "mount" | "mounthippogryph" | "move" | "moveAI" | "nagabuild" | "neutraldetectaoe" | "neutralinteract" | "neutralspell" | "nightelfbuild" | "orcbuild" | "parasite" | "parasiteoff" | "parasiteon" | "patrol" | "patrolAI" | "phaseshift" | "phaseshiftinstant" | "phaseshiftoff" | "phaseshifton" | "phoenixfire" | "phoenixmorph" | "poisonarrows" | "poisonarrowstarg" | "polymorph" | "possession" | "preservation" | "purge" | "rainofchaos" | "rainoffire" | "raisedead" | "raisedeadoff" | "raisedeadon" | "ravenform" | "recharge" | "rechargeoff" | "rechargeon" | "rejuvination" | "renew" | "renewoff" | "renewon" | "repair" | "repairoff" | "repairon" | "replenish" | "replenishlife" | "replenishlifeoff" | "replenishlifeon" | "replenishmana" | "replenishmanaoff" | "replenishmanaon" | "replenishoff" | "replenishon" | "request_hero" | "requestsacrifice" | "restoration" | "restorationoff" | "restorationon" | "resumebuild" | "resumeharvesting" | "resurrection" | "returnresources" | "revenge" | "revive" | "roar" | "robogoblin" | "root" | "sacrifice" | "sanctuary" | "scout" | "selfdestruct" | "selfdestructoff" | "selfdestructon" | "sentinel" | "follow" | "smart" | "setrally" | "shadowsight" | "shadowstrike" | "shockwave" | "silence" | "slow" | "slowoff" | "slowon" | "soulburn" | "soulpreservation" | "spellshield" | "spellshieldaoe" | "spellsteal" | "spellstealoff" | "spellstealon" | "spies" | "spiritlink" | "spiritofvengeance" | "spirittroll" | "spiritwolf" | "stampede" | "standdown" | "starfall" | "stasistrap" | "steal" | "stomp" | "stoneform" | "stunned" | "submerge" | "summonfactory" | "summongrizzly" | "summonphoenix" | "summonquillbeast" | "summonwareagle" | "tankdroppilot" | "tankloadpilot" | "tankpilot" | "taunt" | "thunderbolt" | "thunderclap" | "tornado" | "townbelloff" | "townbellon" | "tranquility" | "transmute" | "unavatar" | "unavengerform" | "unbearform" | "unburrow" | "uncoldarrows" | "uncorporealform" | "undeadbuild" | "undefend" | "undivineshield" | "unetherealform" | "unflamingarrows" | "unflamingattack" | "unholyfrenzy" | "unimmolation" | "unload" | "unloadall" | "unloadallcorpses" | "unloadallinstant" | "unpoisonarrows" | "unravenform" | "unrobogoblin" | "unroot" | "unstableconcoction" | "unstoneform" | "unsubmerge" | "unsummon" | "unwindwalk" | "vengeance" | "vengeanceinstant" | "vengeanceoff" | "vengeanceon" | "volcano" | "voodoo" | "ward" | "waterelemental" | "wateryminion" | "web" | "weboff" | "webon" | "whirlwind" | "windwalk" | "wispharvest") => number;
57
+ const orderId: (id: "blink" | "stop" | "load" | "sleep" | "absorb" | "acidbomb" | "acolyteharvest" | "ambush" | "ancestralspirit" | "ancestralspirittarget" | "animatedead" | "antimagicshell" | "attack" | "attackground" | "attackonce" | "attributemodskill" | "auraunholy" | "auravampiric" | "autodispel" | "autodispeloff" | "autodispelon" | "autoentangle" | "autoentangleinstant" | "autoharvestgold" | "autoharvestlumber" | "avatar" | "avengerform" | "awaken" | "banish" | "barkskin" | "barkskinoff" | "barkskinon" | "battleroar" | "battlestations" | "bearform" | "berserk" | "blackarrow" | "blackarrowoff" | "blackarrowon" | "blight" | "blizzard" | "bloodlust" | "bloodlustoff" | "bloodluston" | "board" | "breathoffire" | "breathoffrost" | "build" | "burrow" | "cannibalize" | "carrionscarabs" | "carrionscarabsinstant" | "carrionscarabsoff" | "carrionscarabson" | "carrionswarm" | "chainlightning" | "channel" | "charm" | "chemicalrage" | "cloudoffog" | "clusterrockets" | "coldarrows" | "coldarrowstarg" | "controlmagic" | "corporealform" | "corrosivebreath" | "coupleinstant" | "coupletarget" | "creepanimatedead" | "creepdevour" | "creepheal" | "creephealoff" | "creephealon" | "creepthunderbolt" | "creepthunderclap" | "cripple" | "curse" | "curseoff" | "curseon" | "cyclone" | "darkconversion" | "darkportal" | "darkritual" | "darksummoning" | "deathanddecay" | "deathcoil" | "deathpact" | "decouple" | "defend" | "detectaoe" | "detonate" | "devour" | "devourmagic" | "disassociate" | "disenchant" | "dismount" | "dispel" | "divineshield" | "doom" | "drain" | "dreadlordinferno" | "dropitem" | "moveslot0" | "moveslot1" | "moveslot2" | "moveslot3" | "moveslot4" | "moveslot5" | "drunkenhaze" | "earthquake" | "eattree" | "elementalfury" | "ensnare" | "ensnareoff" | "ensnareon" | "entangle" | "entangleinstant" | "entanglingroots" | "etherealform" | "evileye" | "faeriefire" | "faeriefireoff" | "faeriefireon" | "fanofknives" | "farsight" | "fingerofdeath" | "firebolt" | "flamestrike" | "flamingarrows" | "flamingarrowstarg" | "flamingattack" | "flamingattacktarg" | "flare" | "forceboard" | "forceofnature" | "forkedlightning" | "freezingbreath" | "frenzy" | "frenzyoff" | "frenzyon" | "frostarmor" | "frostarmoroff" | "frostarmoron" | "frostnova" | "getitem" | "gold2lumber" | "grabtree" | "harvest" | "heal" | "healingspray" | "healingward" | "healingwave" | "healoff" | "healon" | "hex" | "holdposition" | "holybolt" | "howlofterror" | "humanbuild" | "immolation" | "impale" | "incineratearrow" | "incineratearrowoff" | "incineratearrowon" | "inferno" | "innerfire" | "innerfireoff" | "innerfireon" | "instant" | "invisibility" | "lavamonster" | "lightningshield" | "loadarcher" | "loadcorpse" | "loadcorpseinstant" | "locustswarm" | "lumber2gold" | "magicdefense" | "magicleash" | "magicundefense" | "manaburn" | "manaflareoff" | "manaflareon" | "manashieldoff" | "manashieldon" | "massteleport" | "mechanicalcritter" | "metamorphosis" | "militia" | "militiaconvert" | "militiaoff" | "militiaunconvert" | "mindrot" | "mirrorimage" | "monsoon" | "mount" | "mounthippogryph" | "move" | "moveAI" | "nagabuild" | "neutraldetectaoe" | "neutralinteract" | "neutralspell" | "nightelfbuild" | "orcbuild" | "parasite" | "parasiteoff" | "parasiteon" | "patrol" | "patrolAI" | "phaseshift" | "phaseshiftinstant" | "phaseshiftoff" | "phaseshifton" | "phoenixfire" | "phoenixmorph" | "poisonarrows" | "poisonarrowstarg" | "polymorph" | "possession" | "preservation" | "purge" | "rainofchaos" | "rainoffire" | "raisedead" | "raisedeadoff" | "raisedeadon" | "ravenform" | "recharge" | "rechargeoff" | "rechargeon" | "rejuvination" | "renew" | "renewoff" | "renewon" | "repair" | "repairoff" | "repairon" | "replenish" | "replenishlife" | "replenishlifeoff" | "replenishlifeon" | "replenishmana" | "replenishmanaoff" | "replenishmanaon" | "replenishoff" | "replenishon" | "request_hero" | "requestsacrifice" | "restoration" | "restorationoff" | "restorationon" | "resumebuild" | "resumeharvesting" | "resurrection" | "returnresources" | "revenge" | "revive" | "roar" | "robogoblin" | "root" | "sacrifice" | "sanctuary" | "scout" | "selfdestruct" | "selfdestructoff" | "selfdestructon" | "sentinel" | "follow" | "smart" | "setrally" | "shadowsight" | "shadowstrike" | "shockwave" | "silence" | "slow" | "slowoff" | "slowon" | "soulburn" | "soulpreservation" | "spellshield" | "spellshieldaoe" | "spellsteal" | "spellstealoff" | "spellstealon" | "spies" | "spiritlink" | "spiritofvengeance" | "spirittroll" | "spiritwolf" | "stampede" | "standdown" | "starfall" | "stasistrap" | "steal" | "stomp" | "stoneform" | "stunned" | "submerge" | "summonfactory" | "summongrizzly" | "summonphoenix" | "summonquillbeast" | "summonwareagle" | "tankdroppilot" | "tankloadpilot" | "tankpilot" | "taunt" | "thunderbolt" | "thunderclap" | "tornado" | "townbelloff" | "townbellon" | "tranquility" | "transmute" | "unavatar" | "unavengerform" | "unbearform" | "unburrow" | "uncoldarrows" | "uncorporealform" | "undeadbuild" | "undefend" | "undivineshield" | "unetherealform" | "unflamingarrows" | "unflamingattack" | "unholyfrenzy" | "unimmolation" | "unload" | "unloadall" | "unloadallcorpses" | "unloadallinstant" | "unpoisonarrows" | "unravenform" | "unrobogoblin" | "unroot" | "unstableconcoction" | "unstoneform" | "unsubmerge" | "unsummon" | "unwindwalk" | "vengeance" | "vengeanceinstant" | "vengeanceoff" | "vengeanceon" | "volcano" | "voodoo" | "ward" | "waterelemental" | "wateryminion" | "web" | "weboff" | "webon" | "whirlwind" | "windwalk" | "wispharvest") => number;
58
58
  }
59
59
  declare global {
60
60
  function orderId(...args: Parameters<typeof inner.orderId>): ReturnType<typeof inner.orderId>;
package/core/util.lua CHANGED
@@ -196,6 +196,12 @@ do
196
196
  drain = 852487,
197
197
  dreadlordinferno = 852224,
198
198
  dropitem = 852001,
199
+ moveslot0 = 852002,
200
+ moveslot1 = 852003,
201
+ moveslot2 = 852004,
202
+ moveslot3 = 852005,
203
+ moveslot4 = 852006,
204
+ moveslot5 = 852007,
199
205
  drunkenhaze = 852585,
200
206
  earthquake = 852121,
201
207
  eattree = 852146,
@@ -4,14 +4,6 @@ import { Event } from "../../event";
4
4
  import type { Item } from "../../core/types/item";
5
5
  import type { Unit } from "./unit";
6
6
  import type { AbilityTypeId } from "../object-data/entry/ability-type";
7
- interface Fields<K, V> {
8
- set(field: K, value: V): boolean;
9
- get(field: K): V;
10
- has(field: K): boolean;
11
- }
12
- interface AbilityLevel {
13
- realFields: Fields<jabilityreallevelfield, number>;
14
- }
15
7
  export type jabilityfield = jabilityintegerfield | jabilityrealfield | jabilitybooleanfield | jabilitystringfield | jabilityintegerlevelfield | jabilityreallevelfield | jabilitybooleanlevelfield | jabilitystringlevelfield;
16
8
  export declare class AbilitySnapshot {
17
9
  }
@@ -40,8 +32,7 @@ export declare abstract class Ability extends Handle<jability> {
40
32
  setField(field: jabilityintegerlevelfield | jabilityreallevelfield, level: number, value: number): boolean;
41
33
  setField(field: jabilitybooleanlevelfield, level: number, value: boolean): boolean;
42
34
  setField(field: jabilitystringlevelfield, level: number, value: string): boolean;
43
- get realFields(): Fields<jabilityrealfield, number>;
44
- get levels(): readonly AbilityLevel[];
35
+ get levelCount(): number;
45
36
  abstract get level(): number;
46
37
  static get onCreate(): Event<[Ability]>;
47
38
  static get destroyEvent(): Event<[Ability]>;
@@ -88,4 +79,3 @@ export declare class ItemAbility extends Ability {
88
79
  static get onCreate(): Event<[ItemAbility]>;
89
80
  static get onDestroy(): Event<[ItemAbility]>;
90
81
  }
91
- export {};
@@ -2,7 +2,6 @@ local ____lualib = require("lualib_bundle")
2
2
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
3
3
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
4
4
  local __TS__Class = ____lualib.__TS__Class
5
- local __TS__New = ____lualib.__TS__New
6
5
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
7
6
  local __TS__InstanceOf = ____lualib.__TS__InstanceOf
8
7
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
@@ -33,7 +32,6 @@ local getAbilityStringLevelField = BlzGetAbilityStringLevelField
33
32
  local getUnitAbilityCooldownRemaining = BlzGetUnitAbilityCooldownRemaining
34
33
  local startUnitAbilityCooldown = BlzStartUnitAbilityCooldown
35
34
  local getHandleId = GetHandleId
36
- local getItemAbility = BlzGetItemAbility
37
35
  local match = string.match
38
36
  local ____type = _G.type
39
37
  local ____tostring = _G.tostring
@@ -151,55 +149,6 @@ local orders = postcompile(function()
151
149
  end
152
150
  return orders
153
151
  end)
154
- local RealFields = __TS__Class()
155
- RealFields.name = "RealFields"
156
- function RealFields.prototype.____constructor(self, handle)
157
- self.handle = handle
158
- end
159
- function RealFields.prototype.set(self, field, value)
160
- return BlzSetAbilityRealField(self.handle, field, value)
161
- end
162
- function RealFields.prototype.get(self, field)
163
- return BlzGetAbilityRealField(self.handle, field)
164
- end
165
- function RealFields.prototype.has(self, field)
166
- local handle = self.handle
167
- return BlzSetAbilityRealField(
168
- handle,
169
- field,
170
- BlzGetAbilityRealField(handle, field)
171
- )
172
- end
173
- local RealLevelFields = __TS__Class()
174
- RealLevelFields.name = "RealLevelFields"
175
- function RealLevelFields.prototype.____constructor(self, handle, level)
176
- self.handle = handle
177
- self.level = level
178
- end
179
- function RealLevelFields.prototype.set(self, field, value)
180
- return BlzSetAbilityRealLevelField(self.handle, field, self.level, value)
181
- end
182
- function RealLevelFields.prototype.get(self, field)
183
- return BlzGetAbilityRealLevelField(self.handle, field, self.level)
184
- end
185
- function RealLevelFields.prototype.has(self, field)
186
- local handle = self.handle
187
- return BlzSetAbilityRealLevelField(
188
- handle,
189
- field,
190
- 0,
191
- BlzGetAbilityRealLevelField(handle, field, 0)
192
- )
193
- end
194
- local realLevelMetatable = {__index = self}
195
- local levelDescriptors = {realFields = function(self, handle, level)
196
- return __TS__New(RealLevelFields, handle, level)
197
- end}
198
- local levelMetatable = {__index = function(self, key)
199
- local fields = levelDescriptors[key](levelDescriptors, self.handle, self.level)
200
- rawset(self, key, fields)
201
- return fields
202
- end}
203
152
  local fieldGetters = {
204
153
  abilityintegerfield = function(ability, field)
205
154
  return getAbilityIntegerField(ability.handle, field)
@@ -355,34 +304,9 @@ __TS__SetDescriptor(
355
304
  )
356
305
  __TS__SetDescriptor(
357
306
  Ability.prototype,
358
- "realFields",
307
+ "levelCount",
359
308
  {get = function(self)
360
- local realFields = __TS__New(RealFields, self.handle)
361
- rawset(self, "realFields", realFields)
362
- return realFields
363
- end},
364
- true
365
- )
366
- __TS__SetDescriptor(
367
- Ability.prototype,
368
- "levels",
369
- {get = function(self)
370
- local handle = self.handle
371
- local levels = setmetatable(
372
- {},
373
- {
374
- __len = function(self)
375
- return BlzGetAbilityIntegerField(handle, ABILITY_IF_LEVELS)
376
- end,
377
- __index = function(self, i)
378
- local level = setmetatable({handle = handle, level = i - 1}, levelMetatable)
379
- self[i] = level
380
- return level
381
- end
382
- }
383
- )
384
- rawset(self, "levels", levels)
385
- return levels
309
+ return self:getField(ABILITY_IF_LEVELS)
386
310
  end},
387
311
  true
388
312
  )
@@ -0,0 +1,23 @@
1
+ /** @noSelfInFile */
2
+ import { Item } from "../item";
3
+ export interface UnitItems extends ReadonlyArray<Item | undefined> {
4
+ readonly length: 0 | 1 | 2 | 3 | 4 | 5 | 6;
5
+ [0]: Item | undefined;
6
+ [1]: Item | undefined;
7
+ [2]: Item | undefined;
8
+ [3]: Item | undefined;
9
+ [4]: Item | undefined;
10
+ [5]: Item | undefined;
11
+ }
12
+ export declare class UnitItems {
13
+ constructor(handle: junit);
14
+ protected __newindex(slot: number, item: Item | undefined): void;
15
+ protected __index(key: string | number): unknown;
16
+ protected __len(): number;
17
+ protected __ipairs(): LuaIterator<LuaMultiReturn<[number, Item | undefined]>, junit>;
18
+ }
19
+ declare module "../unit" {
20
+ interface Unit {
21
+ readonly items: UnitItems;
22
+ }
23
+ }
@@ -0,0 +1,74 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__New = ____lualib.__TS__New
4
+ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
5
+ local ____exports = {}
6
+ local ____item = require("engine.internal.item")
7
+ local Item = ____item.Item
8
+ local ____unit = require("engine.internal.unit")
9
+ local Unit = ____unit.Unit
10
+ local rawset = _G.rawset
11
+ local ____type = _G.type
12
+ local isItemPowerup = IsItemPowerup
13
+ local setItemBooleanField = BlzSetItemBooleanField
14
+ local unitAddItem = UnitAddItem
15
+ local unitDropItemSlot = UnitDropItemSlot
16
+ local unitInventorySize = UnitInventorySize
17
+ local unitItemInSlot = UnitItemInSlot
18
+ local unitRemoveItemFromSlot = UnitRemoveItemFromSlot
19
+ local handleByUnitItems = setmetatable({}, {__mode = "k"})
20
+ local function unitItemsNext(handle, index)
21
+ local slot = index & 7
22
+ if index >> 3 == slot then
23
+ return nil, nil
24
+ end
25
+ return index + 1, Item:of(unitItemInSlot(handle, slot))
26
+ end
27
+ ____exports.UnitItems = __TS__Class()
28
+ local UnitItems = ____exports.UnitItems
29
+ UnitItems.name = "UnitItems"
30
+ function UnitItems.prototype.____constructor(self, handle)
31
+ handleByUnitItems[self] = handle
32
+ end
33
+ function UnitItems.prototype.__newindex(self, slot, item)
34
+ local handle = handleByUnitItems[self]
35
+ if slot < 1 or slot > unitInventorySize(handle) then
36
+ return
37
+ end
38
+ unitRemoveItemFromSlot(handle, slot - 1)
39
+ if item ~= nil then
40
+ local itemHandle = item.handle
41
+ local isPowerup = isItemPowerup(itemHandle)
42
+ if isPowerup then
43
+ setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
44
+ end
45
+ unitAddItem(handle, itemHandle)
46
+ unitDropItemSlot(handle, itemHandle, slot - 1)
47
+ if isPowerup then
48
+ setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
49
+ end
50
+ end
51
+ end
52
+ function UnitItems.prototype.__index(self, key)
53
+ if ____type(key) == "number" then
54
+ return Item:of(unitItemInSlot(handleByUnitItems[self], key - 1))
55
+ end
56
+ return rawget(____exports.UnitItems.prototype, key)
57
+ end
58
+ function UnitItems.prototype.__len(self)
59
+ return unitInventorySize(handleByUnitItems[self])
60
+ end
61
+ function UnitItems.prototype.__ipairs(self)
62
+ local handle = handleByUnitItems[self]
63
+ return unitItemsNext, handle, unitInventorySize(handle) << 3
64
+ end
65
+ __TS__ObjectDefineProperty(
66
+ Unit.prototype,
67
+ "items",
68
+ {get = function(self)
69
+ local items = __TS__New(____exports.UnitItems, self.handle)
70
+ rawset(self, "items", items)
71
+ return items
72
+ end}
73
+ )
74
+ return ____exports
@@ -7,14 +7,33 @@ local ____event = require("event")
7
7
  local Event = ____event.Event
8
8
  local ____timer = require("core.types.timer")
9
9
  local Timer = ____timer.Timer
10
+ local ____lua_2Dsets = require("utility.lua-sets")
11
+ local luaSetOf = ____lua_2Dsets.luaSetOf
10
12
  local autoAttackFinishEvent = __TS__New(Event)
11
13
  rawset(Unit, "autoAttackFinishEvent", autoAttackFinishEvent)
12
14
  local eventTimerByUnit = {}
13
- local function reset(source)
14
- local eventTimer = eventTimerByUnit[source]
15
- if eventTimer then
16
- eventTimer:destroy()
17
- eventTimerByUnit[source] = nil
15
+ local instantOrderIds = luaSetOf(
16
+ orderId("avatar"),
17
+ orderId("berserk"),
18
+ orderId("divineshield"),
19
+ orderId("immolation"),
20
+ orderId("moveslot0"),
21
+ orderId("moveslot1"),
22
+ orderId("moveslot2"),
23
+ orderId("moveslot3"),
24
+ orderId("moveslot4"),
25
+ orderId("moveslot5"),
26
+ orderId("unavatar"),
27
+ orderId("undivineshield"),
28
+ orderId("unimmolation")
29
+ )
30
+ local function reset(source, orderId)
31
+ if not (instantOrderIds[orderId] ~= nil) then
32
+ local eventTimer = eventTimerByUnit[source]
33
+ if eventTimer then
34
+ eventTimer:destroy()
35
+ eventTimerByUnit[source] = nil
36
+ end
18
37
  end
19
38
  end
20
39
  Unit.onImmediateOrder:addListener(reset)
@@ -68,16 +68,6 @@ declare const modifiers: {
68
68
  speed: (unit: junit, value: number) => void;
69
69
  armor: (unit: junit, value: number) => void;
70
70
  };
71
- export interface UnitItems extends Array<Item | undefined> {
72
- readonly length: 0 | 1 | 2 | 3 | 4 | 5 | 6;
73
- }
74
- export declare class UnitItems {
75
- private readonly handle;
76
- constructor(handle: junit);
77
- protected __newindex(slot: number, item: Item | undefined): void;
78
- protected __index(slot: number): Item | undefined;
79
- protected __len(): number;
80
- }
81
71
  export declare class UnitWeapon {
82
72
  readonly unit: Unit;
83
73
  readonly index: 0 | 1;
@@ -251,7 +241,6 @@ export declare class Unit extends Handle<junit> {
251
241
  dropItemTarget(item: Item, target: Widget): boolean;
252
242
  dropItemSlot(item: Item, slot: number): boolean;
253
243
  itemInSlot(slot: number): Item | null;
254
- get items(): UnitItems;
255
244
  addAbility(abilityId: number): UnitAbility | null;
256
245
  makeAbilityPermanent(abilityId: number, permanent: true): boolean;
257
246
  setAbilityLevel(abilityId: number, level: number): number;
@@ -15,7 +15,6 @@ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
15
15
  local Set = ____lualib.Set
16
16
  local __TS__Spread = ____lualib.__TS__Spread
17
17
  local ____exports = {}
18
- local unitInventorySize, unitItemInSlot, unitDropItemSlot, unitRemoveItemFromSlot, unitAddItem, isItemPowerup, setItemBooleanField
19
18
  local ____handle = require("core.types.handle")
20
19
  local Handle = ____handle.Handle
21
20
  local ____player = require("core.types.player")
@@ -392,37 +391,6 @@ local getters = {
392
391
  return BlzGetUnitArmor(unit)
393
392
  end
394
393
  }
395
- ____exports.UnitItems = __TS__Class()
396
- local UnitItems = ____exports.UnitItems
397
- UnitItems.name = "UnitItems"
398
- function UnitItems.prototype.____constructor(self, handle)
399
- self.handle = handle
400
- end
401
- function UnitItems.prototype.__newindex(self, slot, item)
402
- local handle = self.handle
403
- if slot < 0 or slot >= unitInventorySize(handle) then
404
- return
405
- end
406
- unitRemoveItemFromSlot(handle, slot)
407
- if item ~= nil then
408
- local itemHandle = item.handle
409
- local isPowerup = isItemPowerup(itemHandle)
410
- if isPowerup then
411
- setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
412
- end
413
- unitAddItem(handle, itemHandle)
414
- unitDropItemSlot(handle, itemHandle, slot)
415
- if isPowerup then
416
- setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
417
- end
418
- end
419
- end
420
- function UnitItems.prototype.__index(self, slot)
421
- return Item:of(unitItemInSlot(self.handle, slot))
422
- end
423
- function UnitItems.prototype.__len(self)
424
- return unitInventorySize(self.handle)
425
- end
426
394
  ____exports.UnitWeapon = __TS__Class()
427
395
  local UnitWeapon = ____exports.UnitWeapon
428
396
  UnitWeapon.name = "UnitWeapon"
@@ -575,13 +543,8 @@ __TS__SetDescriptor(
575
543
  },
576
544
  true
577
545
  )
578
- unitInventorySize = UnitInventorySize
579
- unitItemInSlot = UnitItemInSlot
580
- unitDropItemSlot = UnitDropItemSlot
581
- unitRemoveItemFromSlot = UnitRemoveItemFromSlot
582
- unitAddItem = UnitAddItem
583
- isItemPowerup = IsItemPowerup
584
- setItemBooleanField = BlzSetItemBooleanField
546
+ local unitInventorySize = UnitInventorySize
547
+ local unitItemInSlot = UnitItemInSlot
585
548
  local getItemAbility = BlzGetItemAbility
586
549
  local getUnitAbility = BlzGetUnitAbility
587
550
  local getUnitAbilityByIndex = BlzGetUnitAbilityByIndex
@@ -1853,16 +1816,6 @@ __TS__SetDescriptor(
1853
1816
  end},
1854
1817
  true
1855
1818
  )
1856
- __TS__SetDescriptor(
1857
- Unit.prototype,
1858
- "items",
1859
- {get = function(self)
1860
- local items = __TS__New(____exports.UnitItems, self.handle)
1861
- rawset(self, "items", items)
1862
- return items
1863
- end},
1864
- true
1865
- )
1866
1819
  __TS__SetDescriptor(
1867
1820
  Unit.prototype,
1868
1821
  "buffIds",
@@ -45,4 +45,16 @@ export declare class ItemType extends ObjectDataEntry<ItemTypeId> {
45
45
  set tooltipText(tooltipText: string);
46
46
  get tooltipExtendedText(): string;
47
47
  set tooltipExtendedText(tooltipText: string);
48
+ get goldCost(): number;
49
+ set goldCost(goldCost: number);
50
+ get lumberCost(): number;
51
+ set lumberCost(lumberCost: number);
52
+ get activelyUsed(): boolean;
53
+ set activelyUsed(activelyUsed: boolean);
54
+ get perishable(): boolean;
55
+ set perishable(perishable: boolean);
56
+ get initialStackSize(): number;
57
+ set initialStackSize(initialStackSize: number);
58
+ get maximumStackSize(): number;
59
+ set maximumStackSize(maximumStackSize: number);
48
60
  }
@@ -256,4 +256,82 @@ __TS__SetDescriptor(
256
256
  },
257
257
  true
258
258
  )
259
+ __TS__SetDescriptor(
260
+ ItemType.prototype,
261
+ "goldCost",
262
+ {
263
+ get = function(self)
264
+ return self:getNumberField("igol")
265
+ end,
266
+ set = function(self, goldCost)
267
+ self:setNumberField("igol", goldCost)
268
+ end
269
+ },
270
+ true
271
+ )
272
+ __TS__SetDescriptor(
273
+ ItemType.prototype,
274
+ "lumberCost",
275
+ {
276
+ get = function(self)
277
+ return self:getNumberField("ilum")
278
+ end,
279
+ set = function(self, lumberCost)
280
+ self:setNumberField("ilum", lumberCost)
281
+ end
282
+ },
283
+ true
284
+ )
285
+ __TS__SetDescriptor(
286
+ ItemType.prototype,
287
+ "activelyUsed",
288
+ {
289
+ get = function(self)
290
+ return self:getBooleanField("iusa")
291
+ end,
292
+ set = function(self, activelyUsed)
293
+ self:setBooleanField("iusa", activelyUsed)
294
+ end
295
+ },
296
+ true
297
+ )
298
+ __TS__SetDescriptor(
299
+ ItemType.prototype,
300
+ "perishable",
301
+ {
302
+ get = function(self)
303
+ return self:getBooleanField("iper")
304
+ end,
305
+ set = function(self, perishable)
306
+ self:setBooleanField("iper", perishable)
307
+ end
308
+ },
309
+ true
310
+ )
311
+ __TS__SetDescriptor(
312
+ ItemType.prototype,
313
+ "initialStackSize",
314
+ {
315
+ get = function(self)
316
+ return self:getNumberField("iuse")
317
+ end,
318
+ set = function(self, initialStackSize)
319
+ self:setNumberField("iuse", initialStackSize)
320
+ end
321
+ },
322
+ true
323
+ )
324
+ __TS__SetDescriptor(
325
+ ItemType.prototype,
326
+ "maximumStackSize",
327
+ {
328
+ get = function(self)
329
+ return self:getNumberField("ista")
330
+ end,
331
+ set = function(self, maximumStackSize)
332
+ self:setNumberField("ista", maximumStackSize)
333
+ end
334
+ },
335
+ true
336
+ )
259
337
  return ____exports
@@ -261,7 +261,7 @@ local AbilityLevelField = ____exports.AbilityLevelField
261
261
  AbilityLevelField.name = "AbilityLevelField"
262
262
  __TS__ClassExtends(AbilityLevelField, ObjectLevelField)
263
263
  function AbilityLevelField.prototype.getLevelCount(self, entry)
264
- return __TS__InstanceOf(entry, Ability) and #entry.levels or entry.levelCount
264
+ return entry.levelCount
265
265
  end
266
266
  function AbilityLevelField.prototype.getObjectDataEntryId(self, instance)
267
267
  return instance.typeId
package/engine/unit.d.ts CHANGED
@@ -4,6 +4,7 @@ import "./internal/unit/ability";
4
4
  import "./internal/unit/allowed-targets";
5
5
  import "./internal/unit/buff";
6
6
  import "./internal/unit/expiration-timer";
7
+ import "./internal/unit/item";
7
8
  import "./internal/unit+ability";
8
9
  import "./internal/unit+damage";
9
10
  import "./internal/unit+rally";
package/engine/unit.lua CHANGED
@@ -4,6 +4,7 @@ require("engine.internal.unit.ability")
4
4
  require("engine.internal.unit.allowed-targets")
5
5
  require("engine.internal.unit.buff")
6
6
  require("engine.internal.unit.expiration-timer")
7
+ require("engine.internal.unit.item")
7
8
  require("engine.internal.unit+ability")
8
9
  require("engine.internal.unit+damage")
9
10
  require("engine.internal.unit+rally")
package/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /** @noSelfInFile */
2
2
  import "./types";
3
+ import "./patch-lua";
3
4
  import "./patch-lualib";
4
5
  import "./patch-natives";
5
6
  import "./global/math";
package/index.lua CHANGED
@@ -1,5 +1,6 @@
1
1
  local ____exports = {}
2
2
  require("types")
3
+ require("patch-lua")
3
4
  require("patch-lualib")
4
5
  require("patch-natives")
5
6
  require("global.math")
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.38157d0",
4
+ "version": "0.0.1-dev.3e67cca",
5
5
  "description": "A typescript library for Warcraft III using Warpack.",
6
6
  "keywords": [
7
7
  "warcraft",
package/patch-lua.d.ts ADDED
File without changes
package/patch-lua.lua ADDED
@@ -0,0 +1,10 @@
1
+ local getmetatable = _G.getmetatable
2
+ local ipairs = _G.ipairs
3
+
4
+ _G.ipairs = function(t)
5
+ local metatable = getmetatable(t)
6
+ if metatable and metatable.__ipairs then
7
+ return metatable.__ipairs(t)
8
+ end
9
+ return ipairs(t)
10
+ end