warscript 0.0.1-dev.81b7909 → 0.0.1-dev.820013f

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.
@@ -108,6 +108,7 @@ export declare class Frame extends Handle<jframehandle> {
108
108
  enable(): void;
109
109
  addText(text: string): void;
110
110
  clearAllPoints(): void;
111
+ get children(): Frame[];
111
112
  getChild(index: number): Frame;
112
113
  getChildrenCount(): number;
113
114
  setSize(width: number, height: number): void;
@@ -720,6 +720,18 @@ __TS__SetDescriptor(
720
720
  end},
721
721
  true
722
722
  )
723
+ __TS__SetDescriptor(
724
+ Frame.prototype,
725
+ "children",
726
+ {get = function(self)
727
+ local children = {}
728
+ for i = 0, self:getChildrenCount() - 1 do
729
+ children[i + 1] = self:getChild(i)
730
+ end
731
+ return children
732
+ end},
733
+ true
734
+ )
723
735
  __TS__ObjectDefineProperty(
724
736
  Frame,
725
737
  "onKeyPress",
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,
@@ -17,9 +17,9 @@ export declare abstract class Behavior<T extends AnyNotNil, PeriodicActionParame
17
17
  protected startPeriodicAction(interval: number, ...parameters: PeriodicActionParameters): void;
18
18
  protected stopPeriodicAction(): void;
19
19
  static count<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[]>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, limit?: number): number;
20
- static getFirst<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], Count extends [number] | []>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, ...[count]: Count): Count extends [number] ? T[] : T | undefined;
20
+ static getFirst<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], CountOrPredicate extends [number] | [] | [(behavior: T, ...args: PredicateArgs) => boolean, ...PredicateArgs], PredicateArgs extends any[]>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, ...[countOrPredicate]: CountOrPredicate): CountOrPredicate extends [number] ? T[] : T | undefined;
21
21
  static getLast<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[]>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never): T | undefined;
22
- static getAll<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[]>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never): T[];
22
+ static getAll<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], PredicateArgs extends any[]>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, predicate?: (this: void, behavior: T, ...args: PredicateArgs) => boolean, ...predicateArgs: PredicateArgs): T[];
23
23
  static forFirst<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], ConsumerParameters extends any[]>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, count: number, consumer: (this: void, behavior: T, ...parameters: ConsumerParameters) => any, ...parameters: ConsumerParameters): number;
24
24
  static forFirst<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], K extends KeysOfType<T, (this: T, ...args: any) => any>>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, count: number, key: K, ...parameters: T[K] extends (this: T, ...args: any) => any ? Parameters<T[K]> : never): number;
25
25
  static forAll<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], ConsumerParameters extends any[]>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, consumer: (this: void, behavior: T, ...parameters: ConsumerParameters) => unknown, ...parameters: ConsumerParameters): number;
@@ -83,11 +83,11 @@ function Behavior.count(self, object, limit)
83
83
  end
84
84
  return behaviorsCount
85
85
  end
86
- function Behavior.getFirst(self, object, count)
86
+ function Behavior.getFirst(self, object, countOrPredicate, ...)
87
87
  local behavior = firstBehaviorByObject[object]
88
- if count == nil then
88
+ if type(countOrPredicate) ~= "number" then
89
89
  while behavior ~= nil do
90
- if __TS__InstanceOf(behavior, self) then
90
+ if __TS__InstanceOf(behavior, self) and (countOrPredicate == nil or countOrPredicate(behavior, ...)) then
91
91
  return behavior
92
92
  end
93
93
  behavior = behavior[1]
@@ -96,7 +96,7 @@ function Behavior.getFirst(self, object, count)
96
96
  end
97
97
  local behaviors = {}
98
98
  local behaviorsCount = 0
99
- while behavior ~= nil and behaviorsCount < count do
99
+ while behavior ~= nil and behaviorsCount < countOrPredicate do
100
100
  if __TS__InstanceOf(behavior, self) then
101
101
  behaviorsCount = behaviorsCount + 1
102
102
  behaviors[behaviorsCount] = behavior
@@ -115,12 +115,12 @@ function Behavior.getLast(self, object)
115
115
  end
116
116
  return nil
117
117
  end
118
- function Behavior.getAll(self, object)
118
+ function Behavior.getAll(self, object, predicate, ...)
119
119
  local behaviors = {}
120
120
  local behaviorsCount = 0
121
121
  local behavior = firstBehaviorByObject[object]
122
122
  while behavior ~= nil do
123
- if __TS__InstanceOf(behavior, self) then
123
+ if __TS__InstanceOf(behavior, self) and (predicate == nil or predicate(behavior, ...)) then
124
124
  behaviorsCount = behaviorsCount + 1
125
125
  behaviors[behaviorsCount] = behavior
126
126
  end
@@ -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
  )
@@ -12,8 +12,9 @@ export interface UnitItems extends ReadonlyArray<Item | undefined> {
12
12
  export declare class UnitItems {
13
13
  constructor(handle: junit);
14
14
  protected __newindex(slot: number, item: Item | undefined): void;
15
- protected __index(slot: number): Item | undefined;
15
+ protected __index(key: string | number): unknown;
16
16
  protected __len(): number;
17
+ protected __ipairs(): LuaIterator<LuaMultiReturn<[number, Item | undefined]>, junit>;
17
18
  }
18
19
  declare module "../unit" {
19
20
  interface Unit {
@@ -8,6 +8,7 @@ local Item = ____item.Item
8
8
  local ____unit = require("engine.internal.unit")
9
9
  local Unit = ____unit.Unit
10
10
  local rawset = _G.rawset
11
+ local ____type = _G.type
11
12
  local isItemPowerup = IsItemPowerup
12
13
  local setItemBooleanField = BlzSetItemBooleanField
13
14
  local unitAddItem = UnitAddItem
@@ -16,6 +17,13 @@ local unitInventorySize = UnitInventorySize
16
17
  local unitItemInSlot = UnitItemInSlot
17
18
  local unitRemoveItemFromSlot = UnitRemoveItemFromSlot
18
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
19
27
  ____exports.UnitItems = __TS__Class()
20
28
  local UnitItems = ____exports.UnitItems
21
29
  UnitItems.name = "UnitItems"
@@ -24,10 +32,10 @@ function UnitItems.prototype.____constructor(self, handle)
24
32
  end
25
33
  function UnitItems.prototype.__newindex(self, slot, item)
26
34
  local handle = handleByUnitItems[self]
27
- if slot < 0 or slot >= unitInventorySize(handle) then
35
+ if slot < 1 or slot > unitInventorySize(handle) then
28
36
  return
29
37
  end
30
- unitRemoveItemFromSlot(handle, slot)
38
+ unitRemoveItemFromSlot(handle, slot - 1)
31
39
  if item ~= nil then
32
40
  local itemHandle = item.handle
33
41
  local isPowerup = isItemPowerup(itemHandle)
@@ -35,18 +43,25 @@ function UnitItems.prototype.__newindex(self, slot, item)
35
43
  setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
36
44
  end
37
45
  unitAddItem(handle, itemHandle)
38
- unitDropItemSlot(handle, itemHandle, slot)
46
+ unitDropItemSlot(handle, itemHandle, slot - 1)
39
47
  if isPowerup then
40
48
  setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
41
49
  end
42
50
  end
43
51
  end
44
- function UnitItems.prototype.__index(self, slot)
45
- return Item:of(unitItemInSlot(handleByUnitItems[self], slot))
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)
46
57
  end
47
58
  function UnitItems.prototype.__len(self)
48
59
  return unitInventorySize(handleByUnitItems[self])
49
60
  end
61
+ function UnitItems.prototype.__ipairs(self)
62
+ local handle = handleByUnitItems[self]
63
+ return unitItemsNext, handle, unitInventorySize(handle) << 3
64
+ end
50
65
  __TS__ObjectDefineProperty(
51
66
  Unit.prototype,
52
67
  "items",
@@ -0,0 +1,7 @@
1
+ /** @noSelfInFile */
2
+ import { Player } from "../../../core/types/player";
3
+ declare module "../unit" {
4
+ namespace Unit {
5
+ const getMainSelectedOf: (player: Player) => Unit | undefined;
6
+ }
7
+ }
@@ -0,0 +1,40 @@
1
+ local ____exports = {}
2
+ local ____player = require("core.types.player")
3
+ local Player = ____player.Player
4
+ local ____math = require("math")
5
+ local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
6
+ local MINIMUM_INTEGER = ____math.MINIMUM_INTEGER
7
+ local ____local_2Dclient = require("engine.local-client")
8
+ local LocalClient = ____local_2Dclient.LocalClient
9
+ local ____unit = require("engine.internal.unit")
10
+ local Unit = ____unit.Unit
11
+ local mainSelectedUnitByPlayer = {}
12
+ local syncSlider = BlzCreateFrameByType(
13
+ "SLIDER",
14
+ "UnitSyncId",
15
+ BlzGetOriginFrame(ORIGIN_FRAME_WORLD_FRAME, 0),
16
+ "",
17
+ 0
18
+ )
19
+ BlzFrameSetMinMaxValue(syncSlider, MINIMUM_INTEGER, MAXIMUM_INTEGER)
20
+ LocalClient.mainSelectedUnitChangeEvent:addListener(function()
21
+ local ____opt_0 = LocalClient.mainSelectedUnit
22
+ local syncId = ____opt_0 and ____opt_0.syncId
23
+ BlzFrameSetValue(syncSlider, syncId or 0)
24
+ end)
25
+ local trg = CreateTrigger()
26
+ BlzTriggerRegisterFrameEvent(trg, syncSlider, FRAMEEVENT_SLIDER_VALUE_CHANGED)
27
+ TriggerAddAction(
28
+ trg,
29
+ function()
30
+ mainSelectedUnitByPlayer[Player:of(GetTriggerPlayer())] = Unit:getBySyncId(BlzGetTriggerFrameValue())
31
+ end
32
+ )
33
+ rawset(
34
+ Unit,
35
+ "getMainSelectedOf",
36
+ function(player)
37
+ return mainSelectedUnitByPlayer[player]
38
+ end
39
+ )
40
+ 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)
@@ -94,14 +94,19 @@ export declare class UnitWeapon {
94
94
  set missileSpeed(missileSpeed: number);
95
95
  }
96
96
  declare const enum UnitPropertyKey {
97
- IS_PAUSED = 100,
98
- STUN_COUNTER = 101,
99
- DELAY_HEALTH_CHECKS_COUNTER = 102,
100
- DELAY_HEALTH_CHECKS_HEALTH_BONUS = 103,
101
- PREVENT_DEATH_HEALTH_BONUS = 104,
102
- IS_TEAM_GLOW_HIDDEN = 105
97
+ SYNC_ID = 100,
98
+ IS_PAUSED = 101,
99
+ STUN_COUNTER = 102,
100
+ DELAY_HEALTH_CHECKS_COUNTER = 103,
101
+ DELAY_HEALTH_CHECKS_HEALTH_BONUS = 104,
102
+ PREVENT_DEATH_HEALTH_BONUS = 105,
103
+ IS_TEAM_GLOW_HIDDEN = 106
103
104
  }
105
+ export type UnitSyncId = number & {
106
+ readonly __unitSyncId: unique symbol;
107
+ };
104
108
  export declare class Unit extends Handle<junit> {
109
+ readonly syncId: UnitSyncId;
105
110
  private [UnitPropertyKey.IS_PAUSED]?;
106
111
  private [UnitPropertyKey.STUN_COUNTER]?;
107
112
  private [UnitPropertyKey.DELAY_HEALTH_CHECKS_COUNTER]?;
@@ -288,7 +293,7 @@ export declare class Unit extends Handle<junit> {
288
293
  static getInRange(x: number, y: number, range: number, predicate?: (unit: Unit) => boolean): Unit[];
289
294
  static getInCollisionRange(x: number, y: number, range: number, predicate?: (unit: Unit) => boolean): Unit[];
290
295
  static getInSector(pos: Vec2, range: number, offsetAngle: number, centralAngle: number): Unit[];
291
- static getSelectionOf(player: Player): Unit[];
296
+ static getSelectionOf(player: Player, target?: Unit[]): Unit[];
292
297
  static readonly deathEvent: UnitTriggerEvent<[Unit]>;
293
298
  static readonly onDecay: UnitTriggerEvent<[]>;
294
299
  static readonly onResurrect: InitializingEvent<[Unit], void>;
@@ -337,5 +342,6 @@ export declare class Unit extends Handle<junit> {
337
342
  setField(field: junitbooleanfield, value: boolean): boolean;
338
343
  setField(field: junitstringfield, value: string): boolean;
339
344
  toString(): string;
345
+ static getBySyncId(syncId: UnitSyncId): Unit | undefined;
340
346
  }
341
347
  export {};
@@ -630,15 +630,15 @@ for ____, player in ipairs(Player.all) do
630
630
  dummies[player] = dummy
631
631
  end
632
632
  local function delayHealthChecksCallback(unit)
633
- local counter = (unit[102] or 0) - 1
633
+ local counter = (unit[103] or 0) - 1
634
634
  if counter ~= 0 then
635
- unit[102] = counter
635
+ unit[103] = counter
636
636
  return
637
637
  end
638
- unit[102] = nil
639
- local healthBonus = unit[103]
638
+ unit[103] = nil
639
+ local healthBonus = unit[104]
640
640
  if healthBonus ~= nil then
641
- unit[103] = nil
641
+ unit[104] = nil
642
642
  local handle = unit.handle
643
643
  BlzSetUnitMaxHP(
644
644
  handle,
@@ -646,12 +646,17 @@ local function delayHealthChecksCallback(unit)
646
646
  )
647
647
  end
648
648
  end
649
+ local nextSyncId = 1
650
+ local unitBySyncId = setmetatable({}, {__mode = "k"})
649
651
  ____exports.Unit = __TS__Class()
650
652
  local Unit = ____exports.Unit
651
653
  Unit.name = "Unit"
652
654
  __TS__ClassExtends(Unit, Handle)
653
655
  function Unit.prototype.____constructor(self, handle)
654
656
  Handle.prototype.____constructor(self, handle)
657
+ local ____nextSyncId_0 = nextSyncId
658
+ nextSyncId = ____nextSyncId_0 + 1
659
+ self.syncId = ____nextSyncId_0
655
660
  self._owner = Player:of(getOwningPlayer(handle))
656
661
  assert(unitAddAbility(handle, leaveDetectAbilityId) and UnitMakeAbilityPermanent(handle, true, leaveDetectAbilityId))
657
662
  assert(unitAddAbility(handle, morphDetectAbilityId))
@@ -664,6 +669,7 @@ function Unit.prototype.____constructor(self, handle)
664
669
  fourCC("Amrf")
665
670
  ))
666
671
  end
672
+ unitBySyncId[self.syncId] = self
667
673
  local ____ = self.abilities
668
674
  end
669
675
  function Unit.prototype.getEvent(self, event, collector)
@@ -749,8 +755,8 @@ function Unit.prototype.addModifier(self, property, modifier)
749
755
  end}
750
756
  end
751
757
  function Unit.prototype.hasCombatClassification(self, combatClassification)
752
- local ____combatClassification_0 = combatClassification
753
- return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_0 == ____combatClassification_0
758
+ local ____combatClassification_1 = combatClassification
759
+ return getUnitIntegerField(self.handle, UNIT_IF_TARGETED_AS) & ____combatClassification_1 == ____combatClassification_1
754
760
  end
755
761
  function Unit.prototype.addClassification(self, classification)
756
762
  return unitAddType(self.handle, classification)
@@ -768,13 +774,13 @@ function Unit.prototype.isInvisibleTo(self, player)
768
774
  return isUnitInvisible(self.handle, player.handle)
769
775
  end
770
776
  function Unit.prototype.isInRangeOf(self, x, y, range)
771
- local ____temp_1
777
+ local ____temp_2
772
778
  if type(x) == "number" then
773
- ____temp_1 = isUnitInRangeXY(self.handle, x, y, range)
779
+ ____temp_2 = isUnitInRangeXY(self.handle, x, y, range)
774
780
  else
775
- ____temp_1 = isUnitInRange(self.handle, x.handle, y)
781
+ ____temp_2 = isUnitInRange(self.handle, x.handle, y)
776
782
  end
777
- return ____temp_1
783
+ return ____temp_2
778
784
  end
779
785
  function Unit.prototype.isAllyOf(self, unit)
780
786
  return isUnitAlly(
@@ -801,7 +807,7 @@ function Unit.prototype.queueAnimation(self, animation)
801
807
  queueUnitAnimation(self.handle, animation)
802
808
  end
803
809
  function Unit.prototype.delayHealthChecks(self)
804
- self[102] = (self[102] or 0) + 1
810
+ self[103] = (self[103] or 0) + 1
805
811
  Timer:run(delayHealthChecksCallback, self)
806
812
  end
807
813
  function Unit.prototype.setPosition(self, x, y)
@@ -818,14 +824,14 @@ function Unit.prototype.kill(self)
818
824
  killUnit(self.handle)
819
825
  end
820
826
  function Unit.prototype.revive(self, x, y, doEffect)
821
- local ____ReviveHero_4 = ReviveHero
822
- local ____array_3 = __TS__SparseArrayNew(self.handle, x, y)
823
- local ____doEffect_2 = doEffect
824
- if ____doEffect_2 == nil then
825
- ____doEffect_2 = false
827
+ local ____ReviveHero_5 = ReviveHero
828
+ local ____array_4 = __TS__SparseArrayNew(self.handle, x, y)
829
+ local ____doEffect_3 = doEffect
830
+ if ____doEffect_3 == nil then
831
+ ____doEffect_3 = false
826
832
  end
827
- __TS__SparseArrayPush(____array_3, ____doEffect_2)
828
- ____ReviveHero_4(__TS__SparseArraySpread(____array_3))
833
+ __TS__SparseArrayPush(____array_4, ____doEffect_3)
834
+ ____ReviveHero_5(__TS__SparseArraySpread(____array_4))
829
835
  end
830
836
  function Unit.prototype.healTarget(self, target, amount)
831
837
  if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
@@ -995,18 +1001,18 @@ function Unit.prototype.unpauseEx(self)
995
1001
  self:decrementStunCounter()
996
1002
  end
997
1003
  function Unit.prototype.incrementStunCounter(self)
998
- local stunCounter = self[101] or 0
999
- if not self[100] or stunCounter >= 0 then
1004
+ local stunCounter = self[102] or 0
1005
+ if not self[101] or stunCounter >= 0 then
1000
1006
  BlzPauseUnitEx(self.handle, true)
1001
1007
  end
1002
- self[101] = stunCounter + 1
1008
+ self[102] = stunCounter + 1
1003
1009
  end
1004
1010
  function Unit.prototype.decrementStunCounter(self)
1005
- local stunCounter = self[101] or 0
1006
- if not self[100] or stunCounter >= 1 then
1011
+ local stunCounter = self[102] or 0
1012
+ if not self[101] or stunCounter >= 1 then
1007
1013
  BlzPauseUnitEx(self.handle, false)
1008
1014
  end
1009
- self[101] = stunCounter - 1
1015
+ self[102] = stunCounter - 1
1010
1016
  end
1011
1017
  function Unit.create(self, owner, id, x, y, facing, skinId)
1012
1018
  local handle = skinId and BlzCreateUnitWithSkin(
@@ -1108,8 +1114,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
1108
1114
  )
1109
1115
  return targetCollection
1110
1116
  end
1111
- function Unit.getSelectionOf(self, player)
1112
- targetCollection = {}
1117
+ function Unit.getSelectionOf(self, player, target)
1118
+ if target == nil then
1119
+ target = {}
1120
+ end
1121
+ targetCollection = target
1113
1122
  targetCollectionNextIndex = 1
1114
1123
  GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
1115
1124
  return targetCollection
@@ -1131,6 +1140,9 @@ end
1131
1140
  function Unit.prototype.__tostring(self)
1132
1141
  return (((self.constructor.name .. "$") .. util.id2s(self.typeId)) .. "@") .. tostring(getHandleId(self.handle))
1133
1142
  end
1143
+ function Unit.getBySyncId(self, syncId)
1144
+ return unitBySyncId[syncId]
1145
+ end
1134
1146
  __TS__SetDescriptor(
1135
1147
  Unit.prototype,
1136
1148
  "_deltas",
@@ -1388,17 +1400,17 @@ __TS__SetDescriptor(
1388
1400
  "isTeamGlowVisible",
1389
1401
  {
1390
1402
  get = function(self)
1391
- return not self[105]
1403
+ return not self[106]
1392
1404
  end,
1393
1405
  set = function(self, isTeamGlowVisible)
1394
1406
  showUnitTeamGlow(self.handle, isTeamGlowVisible)
1395
- local ____temp_5
1407
+ local ____temp_6
1396
1408
  if not isTeamGlowVisible then
1397
- ____temp_5 = true
1409
+ ____temp_6 = true
1398
1410
  else
1399
- ____temp_5 = nil
1411
+ ____temp_6 = nil
1400
1412
  end
1401
- self[105] = ____temp_5
1413
+ self[106] = ____temp_6
1402
1414
  end
1403
1415
  },
1404
1416
  true
@@ -1408,7 +1420,7 @@ __TS__SetDescriptor(
1408
1420
  "color",
1409
1421
  {set = function(self, color)
1410
1422
  setUnitColor(self.handle, color.handle)
1411
- if self[105] then
1423
+ if self[106] then
1412
1424
  showUnitTeamGlow(self.handle, false)
1413
1425
  end
1414
1426
  end},
@@ -1432,14 +1444,14 @@ __TS__SetDescriptor(
1432
1444
  "maxHealth",
1433
1445
  {
1434
1446
  get = function(self)
1435
- return BlzGetUnitMaxHP(self.handle) - (self[103] or 0) - (self[104] or 0)
1447
+ return BlzGetUnitMaxHP(self.handle) - (self[104] or 0) - (self[105] or 0)
1436
1448
  end,
1437
1449
  set = function(self, maxHealth)
1438
- if maxHealth < 1 and self[102] ~= nil then
1439
- self[103] = (self[103] or 0) + (1 - maxHealth)
1450
+ if maxHealth < 1 and self[103] ~= nil then
1451
+ self[104] = (self[104] or 0) + (1 - maxHealth)
1440
1452
  maxHealth = 1
1441
1453
  end
1442
- BlzSetUnitMaxHP(self.handle, maxHealth + (self[104] or 0))
1454
+ BlzSetUnitMaxHP(self.handle, maxHealth + (self[105] or 0))
1443
1455
  end
1444
1456
  },
1445
1457
  true
@@ -1481,10 +1493,10 @@ __TS__SetDescriptor(
1481
1493
  "health",
1482
1494
  {
1483
1495
  get = function(self)
1484
- return GetWidgetLife(self.handle) - (self[104] or 0)
1496
+ return GetWidgetLife(self.handle) - (self[105] or 0)
1485
1497
  end,
1486
1498
  set = function(self, health)
1487
- SetWidgetLife(self.handle, health + (self[104] or 0))
1499
+ SetWidgetLife(self.handle, health + (self[105] or 0))
1488
1500
  end
1489
1501
  },
1490
1502
  true
@@ -1695,17 +1707,17 @@ __TS__SetDescriptor(
1695
1707
  set = function(self, isPaused)
1696
1708
  local handle = self.handle
1697
1709
  if isPaused and not IsUnitPaused(handle) then
1698
- self[100] = true
1699
- for _ = self[101] or 0, -1 do
1710
+ self[101] = true
1711
+ for _ = self[102] or 0, -1 do
1700
1712
  BlzPauseUnitEx(handle, true)
1701
1713
  end
1702
1714
  PauseUnit(handle, true)
1703
1715
  elseif not isPaused and IsUnitPaused(handle) then
1704
1716
  PauseUnit(handle, false)
1705
- for _ = self[101] or 0, -1 do
1717
+ for _ = self[102] or 0, -1 do
1706
1718
  BlzPauseUnitEx(handle, false)
1707
1719
  end
1708
- self[100] = nil
1720
+ self[101] = nil
1709
1721
  end
1710
1722
  end
1711
1723
  },
@@ -2124,25 +2136,25 @@ Unit.onTargetCast = dispatchId(__TS__New(
2124
2136
  InitializingEvent,
2125
2137
  function(event)
2126
2138
  local function listener(unit, id)
2127
- local ____GetSpellTargetUnit_result_8
2139
+ local ____GetSpellTargetUnit_result_9
2128
2140
  if GetSpellTargetUnit() then
2129
- ____GetSpellTargetUnit_result_8 = ____exports.Unit:of(GetSpellTargetUnit())
2141
+ ____GetSpellTargetUnit_result_9 = ____exports.Unit:of(GetSpellTargetUnit())
2130
2142
  else
2131
- local ____GetSpellTargetItem_result_7
2143
+ local ____GetSpellTargetItem_result_8
2132
2144
  if GetSpellTargetItem() then
2133
- ____GetSpellTargetItem_result_7 = Item:of(GetSpellTargetItem())
2145
+ ____GetSpellTargetItem_result_8 = Item:of(GetSpellTargetItem())
2134
2146
  else
2135
- local ____GetSpellTargetDestructable_result_6
2147
+ local ____GetSpellTargetDestructable_result_7
2136
2148
  if GetSpellTargetDestructable() then
2137
- ____GetSpellTargetDestructable_result_6 = Destructable:of(GetSpellTargetDestructable())
2149
+ ____GetSpellTargetDestructable_result_7 = Destructable:of(GetSpellTargetDestructable())
2138
2150
  else
2139
- ____GetSpellTargetDestructable_result_6 = nil
2151
+ ____GetSpellTargetDestructable_result_7 = nil
2140
2152
  end
2141
- ____GetSpellTargetItem_result_7 = ____GetSpellTargetDestructable_result_6
2153
+ ____GetSpellTargetItem_result_8 = ____GetSpellTargetDestructable_result_7
2142
2154
  end
2143
- ____GetSpellTargetUnit_result_8 = ____GetSpellTargetItem_result_7
2155
+ ____GetSpellTargetUnit_result_9 = ____GetSpellTargetItem_result_8
2144
2156
  end
2145
- local target = ____GetSpellTargetUnit_result_8
2157
+ local target = ____GetSpellTargetUnit_result_9
2146
2158
  if target then
2147
2159
  invoke(event, unit, id, target)
2148
2160
  end
@@ -2469,7 +2481,7 @@ Unit.onDamage = __TS__New(
2469
2481
  invoke(event, source, target, evData)
2470
2482
  if evData[0] ~= nil and target.health - evData.amount < 0.405 then
2471
2483
  local bonusHealth = math.ceil(evData.amount)
2472
- target[104] = (target[104] or 0) + bonusHealth
2484
+ target[105] = (target[105] or 0) + bonusHealth
2473
2485
  BlzSetUnitMaxHP(
2474
2486
  target.handle,
2475
2487
  BlzGetUnitMaxHP(target.handle) + bonusHealth
@@ -2483,7 +2495,7 @@ Unit.onDamage = __TS__New(
2483
2495
  evData[0],
2484
2496
  table.unpack(evData, 1 + 1, 1 + (evData[1] or 0))
2485
2497
  )
2486
- target[104] = (target[104] or 0) - bonusHealth
2498
+ target[105] = (target[105] or 0) - bonusHealth
2487
2499
  SetWidgetLife(
2488
2500
  target.handle,
2489
2501
  GetWidgetLife(target.handle) - bonusHealth
@@ -1,7 +1,7 @@
1
1
  /** @noSelfInFile */
2
2
  import { Unit } from "../core/types/unit";
3
3
  import { Async } from "../core/types/async";
4
- import { TriggerEvent } from "../event";
4
+ import { Event, TriggerEvent } from "../event";
5
5
  import { GraphicsMode } from "./index";
6
6
  export declare class LocalClient {
7
7
  private constructor();
@@ -11,6 +11,11 @@ export declare class LocalClient {
11
11
  static get isHD(): boolean;
12
12
  static get graphicsMode(): GraphicsMode;
13
13
  static get isActive(): boolean;
14
- static get mouseFocusUnit(): Async<Unit>;
14
+ static get mouseFocusUnit(): Async<Unit> | undefined;
15
+ static get mainSelectedUnit(): Async<Unit> | undefined;
16
+ static get mainSelectedUnitChangeEvent(): Event<[
17
+ previousMainSelectedUnit: Unit | undefined,
18
+ newMainSelectedUnit: Unit | undefined
19
+ ]>;
15
20
  static readonly onDisconnect: TriggerEvent<[]>;
16
21
  }
@@ -1,4 +1,5 @@
1
1
  local ____lualib = require("lualib_bundle")
2
+ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
2
3
  local __TS__Class = ____lualib.__TS__Class
3
4
  local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
4
5
  local __TS__New = ____lualib.__TS__New
@@ -6,13 +7,25 @@ local ____exports = {}
6
7
  local ____unit = require("core.types.unit")
7
8
  local Unit = ____unit.Unit
8
9
  local ____event = require("event")
10
+ local Event = ____event.Event
9
11
  local TriggerEvent = ____event.TriggerEvent
12
+ local ____frame = require("core.types.frame")
13
+ local Frame = ____frame.Frame
14
+ local ____player = require("core.types.player")
15
+ local Player = ____player.Player
16
+ local ____timer = require("core.types.timer")
17
+ local Timer = ____timer.Timer
10
18
  local loadTOCFile = BlzLoadTOCFile
11
19
  local getLocalClientWidth = BlzGetLocalClientWidth
12
20
  local getLocalClientHeight = BlzGetLocalClientHeight
13
21
  local isLocalClientActive = BlzIsLocalClientActive
22
+ local isHeroUnitId = IsHeroUnitId
23
+ local getHandleId = GetHandleId
14
24
  local getMouseFocusUnit = BlzGetMouseFocusUnit
25
+ local getUnitRealField = BlzGetUnitRealField
26
+ local getUnitTypeId = GetUnitTypeId
15
27
  local getLocale = BlzGetLocale
28
+ local tableSort = table.sort
16
29
  local tocPath = "_warscript\\IsHD.toc"
17
30
  compiletime(function()
18
31
  if currentMap then
@@ -21,6 +34,29 @@ compiletime(function()
21
34
  currentMap:addFileString("_HD.w3mod\\" .. tocPath, fdfPath .. "\r\n")
22
35
  end
23
36
  end)
37
+ local selectionButtons
38
+ Timer:run(function()
39
+ selectionButtons = __TS__ArrayMap(
40
+ Frame:byName("SimpleInfoPanelUnitDetail").parent:getChild(5):getChild(0).children,
41
+ function(____, frame) return frame:getChild(1) end
42
+ )
43
+ end)
44
+ local localSelectedUnits = {}
45
+ local indexByLocalSelectedUnit = {}
46
+ local function compareUnitsSelectionPriority(a, b)
47
+ local aHandle = a.handle
48
+ local bHandle = b.handle
49
+ local priorityDelta = getUnitRealField(bHandle, UNIT_RF_PRIORITY) - getUnitRealField(aHandle, UNIT_RF_PRIORITY)
50
+ if priorityDelta ~= 0 then
51
+ return priorityDelta < 0
52
+ end
53
+ local aTypeId = getUnitTypeId(aHandle)
54
+ local bTypeId = getUnitTypeId(bHandle)
55
+ local orderDelta = (isHeroUnitId(aTypeId) and getHandleId(aHandle) or aTypeId) - (isHeroUnitId(bTypeId) and getHandleId(bHandle) or bTypeId)
56
+ return (orderDelta ~= 0 and orderDelta or indexByLocalSelectedUnit[a] - indexByLocalSelectedUnit[b]) < 0
57
+ end
58
+ local mainSelectedUnitChangeEvent
59
+ local previousMainSelectedUnit
24
60
  ____exports.LocalClient = __TS__Class()
25
61
  local LocalClient = ____exports.LocalClient
26
62
  LocalClient.name = "LocalClient"
@@ -69,6 +105,52 @@ __TS__ObjectDefineProperty(
69
105
  return Unit:of(getMouseFocusUnit())
70
106
  end}
71
107
  )
108
+ __TS__ObjectDefineProperty(
109
+ LocalClient,
110
+ "mainSelectedUnit",
111
+ {get = function(self)
112
+ Unit:getSelectionOf(Player["local"], localSelectedUnits)
113
+ for i = 1, #localSelectedUnits do
114
+ indexByLocalSelectedUnit[localSelectedUnits[i]] = i
115
+ end
116
+ tableSort(localSelectedUnits, compareUnitsSelectionPriority)
117
+ local mainSelectedUnitIndex
118
+ if selectionButtons and #localSelectedUnits > 1 then
119
+ local maxButtonWidth = 0
120
+ for i = 0, #selectionButtons - 1 do
121
+ local width = selectionButtons[i + 1].width
122
+ if width > maxButtonWidth then
123
+ maxButtonWidth = width
124
+ mainSelectedUnitIndex = i
125
+ end
126
+ end
127
+ end
128
+ local mainSelectedUnit = localSelectedUnits[(mainSelectedUnitIndex or 0) + 1]
129
+ for i = 1, #localSelectedUnits do
130
+ indexByLocalSelectedUnit[localSelectedUnits[i]] = nil
131
+ localSelectedUnits[i] = nil
132
+ end
133
+ if mainSelectedUnitChangeEvent ~= nil and mainSelectedUnit ~= previousMainSelectedUnit then
134
+ local previousPreviousMainSelectedUnit = previousMainSelectedUnit
135
+ previousMainSelectedUnit = mainSelectedUnit
136
+ Event.invoke(mainSelectedUnitChangeEvent, previousPreviousMainSelectedUnit, previousMainSelectedUnit)
137
+ end
138
+ return mainSelectedUnit
139
+ end}
140
+ )
141
+ __TS__ObjectDefineProperty(
142
+ LocalClient,
143
+ "mainSelectedUnitChangeEvent",
144
+ {get = function(self)
145
+ if mainSelectedUnitChangeEvent == nil then
146
+ mainSelectedUnitChangeEvent = __TS__New(Event)
147
+ Timer.onPeriod[1 / 64]:addListener(function()
148
+ local _ = ____exports.LocalClient.mainSelectedUnit
149
+ end)
150
+ end
151
+ return mainSelectedUnitChangeEvent
152
+ end}
153
+ )
72
154
  LocalClient.onDisconnect = __TS__New(
73
155
  TriggerEvent,
74
156
  function(trigger)
@@ -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
@@ -16,6 +16,7 @@ import "./internal/unit-missile-launch";
16
16
  import "./internal/unit/ghost-counter";
17
17
  import "./internal/unit/invulnerability-counter";
18
18
  import "./internal/unit/detach-missiles";
19
+ import "./internal/unit/main-selected";
19
20
  import "./internal/unit/band-aids/ancestral-spirit-cannibalize";
20
21
  export { Unit, DamagingEvent, DamageEvent } from "./internal/unit";
21
22
  export * from "./internal/unit+damage";
package/engine/unit.lua CHANGED
@@ -16,6 +16,7 @@ require("engine.internal.unit-missile-launch")
16
16
  require("engine.internal.unit.ghost-counter")
17
17
  require("engine.internal.unit.invulnerability-counter")
18
18
  require("engine.internal.unit.detach-missiles")
19
+ require("engine.internal.unit.main-selected")
19
20
  require("engine.internal.unit.band-aids.ancestral-spirit-cannibalize")
20
21
  do
21
22
  local ____unit = require("engine.internal.unit")
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.81b7909",
4
+ "version": "0.0.1-dev.820013f",
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