warscript 0.0.1-dev.f5421e8 → 0.0.1-dev.f594e71
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 +6 -0
- package/attributes.lua +17 -1
- package/core/types/frame.d.ts +1 -0
- package/core/types/frame.lua +136 -58
- package/core/types/handle.lua +9 -9
- package/core/types/item.d.ts +1 -0
- package/core/types/item.lua +1 -0
- package/core/types/player.d.ts +18 -1
- package/core/types/player.lua +76 -26
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +123 -5
- package/core/types/playerColor.lua +4 -3
- package/core/types/sound.d.ts +1 -1
- package/core/types/sound.lua +19 -9
- package/core/types/tileCell.d.ts +11 -1
- package/core/types/tileCell.lua +97 -0
- package/core/types/timer.d.ts +3 -1
- package/core/types/timer.lua +27 -2
- package/core/types/unit.d.ts +4 -0
- package/core/types/unit.lua +4 -0
- package/decl/native.d.ts +1718 -964
- package/destroyable.d.ts +1 -0
- package/destroyable.lua +9 -0
- package/engine/behavior.d.ts +14 -1
- package/engine/behavior.lua +230 -70
- package/engine/behaviour/ability/apply-buff.lua +5 -5
- package/engine/behaviour/ability/damage.d.ts +9 -3
- package/engine/behaviour/ability/damage.lua +40 -49
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +23 -7
- package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
- package/engine/behaviour/ability/remove-buffs.lua +21 -0
- package/engine/behaviour/ability/restore-mana.d.ts +1 -1
- package/engine/behaviour/ability/restore-mana.lua +6 -6
- package/engine/behaviour/ability.d.ts +12 -6
- package/engine/behaviour/ability.lua +49 -17
- package/engine/behaviour/unit/stun-immunity.d.ts +12 -6
- package/engine/behaviour/unit/stun-immunity.lua +57 -31
- package/engine/behaviour/unit.d.ts +40 -3
- package/engine/behaviour/unit.lua +270 -6
- package/engine/buff.d.ts +75 -28
- package/engine/buff.lua +433 -196
- package/engine/index.d.ts +2 -1
- package/engine/internal/ability.d.ts +11 -1
- package/engine/internal/ability.lua +100 -41
- package/engine/internal/item/ability.lua +63 -11
- package/engine/internal/item/fields.d.ts +12 -0
- package/engine/internal/item/fields.lua +33 -0
- package/engine/internal/item+owner.d.ts +1 -0
- package/engine/internal/item+owner.lua +19 -6
- package/engine/internal/item.d.ts +28 -16
- package/engine/internal/item.lua +241 -82
- package/engine/internal/mechanics/cast-ability.lua +6 -3
- package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
- package/engine/internal/misc/frame-coordinates.d.ts +2 -0
- package/engine/internal/misc/frame-coordinates.lua +21 -0
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/misc/player-local-handle.d.ts +2 -0
- package/engine/internal/misc/player-local-handle.lua +5 -0
- package/engine/internal/object-data/armor-bonus.d.ts +2 -0
- package/engine/internal/object-data/attribute-bonus.lua +2 -2
- package/engine/internal/object-data/health-bonus.d.ts +2 -0
- package/engine/internal/object-data/health-bonus.lua +16 -0
- package/engine/internal/object-data/mana-bonus.d.ts +2 -0
- package/engine/internal/object-data/mana-bonus.lua +16 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
- package/engine/internal/unit/ability.d.ts +35 -0
- package/engine/internal/unit/ability.lua +113 -12
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/appearance.d.ts +15 -0
- package/engine/internal/unit/appearance.lua +85 -0
- package/engine/internal/unit/attributes.d.ts +17 -0
- package/engine/internal/unit/attributes.lua +46 -0
- package/engine/internal/unit/bag.d.ts +18 -0
- package/engine/internal/unit/bag.lua +63 -0
- package/engine/internal/unit/bonus.d.ts +6 -0
- package/engine/internal/unit/bonus.lua +33 -3
- package/engine/internal/unit/buff.d.ts +2 -2
- package/engine/internal/unit/buff.lua +34 -19
- package/engine/internal/unit/equipment.d.ts +36 -0
- package/engine/internal/unit/equipment.lua +169 -0
- package/engine/internal/unit/fly-height.d.ts +7 -0
- package/engine/internal/unit/fly-height.lua +20 -0
- package/engine/internal/unit/interrupts.d.ts +12 -0
- package/engine/internal/unit/interrupts.lua +28 -0
- package/engine/internal/unit/{item.d.ts → inventory.d.ts} +3 -3
- package/engine/internal/unit/{item.lua → inventory.lua} +25 -26
- package/engine/internal/unit/main-selected.lua +12 -27
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit/pseudo-passive-abilities.d.ts +2 -0
- package/engine/internal/unit/pseudo-passive-abilities.lua +11 -0
- package/engine/internal/unit/range-event.d.ts +12 -0
- package/engine/internal/unit/range-event.lua +90 -0
- package/engine/internal/unit/scale.d.ts +7 -0
- package/engine/internal/unit/scale.lua +20 -0
- package/engine/internal/unit+ability.lua +10 -1
- package/engine/internal/unit+bonus.lua +3 -3
- package/engine/internal/unit+damage.d.ts +11 -11
- package/engine/internal/unit+damage.lua +43 -14
- package/engine/internal/unit+spellSteal.lua +1 -2
- package/engine/internal/unit-missile-data.lua +58 -32
- package/engine/internal/unit-missile-launch.lua +52 -14
- package/engine/internal/unit.d.ts +39 -27
- package/engine/internal/unit.lua +382 -269
- package/engine/local-client.d.ts +27 -0
- package/engine/local-client.lua +370 -54
- package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
- package/engine/object-data/auxiliary/armor-type.lua +46 -0
- 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/equipment-slot.d.ts +12 -0
- package/engine/object-data/auxiliary/equipment-slot.lua +2 -0
- package/engine/object-data/auxiliary/equipment-type.d.ts +13 -0
- package/engine/object-data/auxiliary/equipment-type.lua +2 -0
- package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
- package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
- package/engine/object-data/auxiliary/item-tag.d.ts +12 -0
- package/engine/object-data/auxiliary/item-tag.lua +2 -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-set-name.d.ts +14 -3
- 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/apprehend.d.ts +22 -0
- package/engine/object-data/entry/ability-type/apprehend.lua +66 -0
- package/engine/object-data/entry/ability-type/armor-bonus.d.ts +8 -0
- package/engine/object-data/entry/ability-type/{armor-increase.lua → armor-bonus.lua} +9 -9
- package/engine/object-data/entry/ability-type/banshee.d.ts +8 -0
- package/engine/object-data/entry/ability-type/banshee.lua +13 -0
- package/engine/object-data/entry/ability-type/banshees-wail-damage-amp.d.ts +12 -0
- package/engine/object-data/entry/ability-type/banshees-wail-damage-amp.lua +27 -0
- package/engine/object-data/entry/ability-type/banshees-wail.d.ts +31 -0
- package/engine/object-data/entry/ability-type/banshees-wail.lua +117 -0
- package/engine/object-data/entry/ability-type/battering-ram.d.ts +33 -0
- package/engine/object-data/entry/ability-type/battering-ram.lua +130 -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.d.ts +3 -0
- package/engine/object-data/entry/ability-type/blank-configurable.lua +30 -0
- package/engine/object-data/entry/ability-type/cleansing-fire.d.ts +27 -0
- package/engine/object-data/entry/ability-type/cleansing-fire.lua +104 -0
- package/engine/object-data/entry/ability-type/consecration.d.ts +15 -0
- package/engine/object-data/entry/ability-type/consecration.lua +52 -0
- package/engine/object-data/entry/ability-type/cooldown-reduction.d.ts +12 -0
- package/engine/object-data/entry/ability-type/cooldown-reduction.lua +39 -0
- package/engine/object-data/entry/ability-type/critical-strike-system.d.ts +18 -0
- package/engine/object-data/entry/ability-type/critical-strike-system.lua +65 -0
- package/engine/object-data/entry/ability-type/deathseeker-arrows.d.ts +21 -0
- package/engine/object-data/entry/ability-type/deathseeker-arrows.lua +78 -0
- package/engine/object-data/entry/ability-type/equipment-inventory-interface.d.ts +8 -0
- package/engine/object-data/entry/ability-type/equipment-inventory-interface.lua +13 -0
- package/engine/object-data/entry/ability-type/equipment-inventory.d.ts +13 -0
- package/engine/object-data/entry/ability-type/equipment-inventory.lua +27 -0
- package/engine/object-data/entry/ability-type/equipment.d.ts +13 -0
- package/engine/object-data/entry/ability-type/equipment.lua +27 -0
- package/engine/object-data/entry/ability-type/grant-talent-point.d.ts +8 -0
- package/engine/object-data/entry/ability-type/grant-talent-point.lua +13 -0
- package/engine/object-data/entry/ability-type/grim-conviction.d.ts +36 -0
- package/engine/object-data/entry/ability-type/grim-conviction.lua +131 -0
- package/engine/object-data/entry/ability-type/grit.d.ts +18 -0
- package/engine/object-data/entry/ability-type/grit.lua +65 -0
- package/engine/object-data/entry/ability-type/guiding-hand.d.ts +27 -0
- package/engine/object-data/entry/ability-type/guiding-hand.lua +104 -0
- package/engine/object-data/entry/ability-type/headsplitter.d.ts +27 -0
- package/engine/object-data/entry/ability-type/headsplitter.lua +104 -0
- package/engine/object-data/entry/ability-type/{armor-increase.d.ts → healing-modifier.d.ts} +4 -3
- package/engine/object-data/entry/ability-type/healing-modifier.lua +26 -0
- package/engine/object-data/entry/ability-type/health-bonus.d.ts +8 -0
- package/engine/object-data/entry/ability-type/health-bonus.lua +26 -0
- package/engine/object-data/entry/ability-type/heroic-slash.d.ts +18 -0
- package/engine/object-data/entry/ability-type/heroic-slash.lua +65 -0
- package/engine/object-data/entry/ability-type/holy-wrath.d.ts +30 -0
- package/engine/object-data/entry/ability-type/holy-wrath.lua +117 -0
- package/engine/object-data/entry/ability-type/inspire-courage.d.ts +18 -0
- package/engine/object-data/entry/ability-type/inspire-courage.lua +65 -0
- package/engine/object-data/entry/ability-type/lights-mercy.d.ts +27 -0
- package/engine/object-data/entry/ability-type/lights-mercy.lua +104 -0
- package/engine/object-data/entry/ability-type/mana-bonus.d.ts +8 -0
- package/engine/object-data/entry/ability-type/mana-bonus.lua +26 -0
- package/engine/object-data/entry/ability-type/mana-efficiency.d.ts +12 -0
- package/engine/object-data/entry/ability-type/mana-efficiency.lua +39 -0
- package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
- package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
- package/engine/object-data/entry/ability-type/mind-control.d.ts +21 -0
- package/engine/object-data/entry/ability-type/mind-control.lua +78 -0
- package/engine/object-data/entry/ability-type/on-attack-cast-spell.d.ts +21 -0
- package/engine/object-data/entry/ability-type/on-attack-cast-spell.lua +52 -0
- package/engine/object-data/entry/ability-type/on-basic-attack-cast-spell.d.ts +19 -0
- package/engine/object-data/entry/ability-type/on-basic-attack-cast-spell.lua +65 -0
- package/engine/object-data/entry/ability-type/on-hit-cast-spell.d.ts +15 -0
- package/engine/object-data/entry/ability-type/on-hit-cast-spell.lua +26 -0
- package/engine/object-data/entry/ability-type/on-magic-attack-cast-spell.d.ts +6 -0
- package/engine/object-data/entry/ability-type/on-magic-attack-cast-spell.lua +12 -0
- 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/provoke.d.ts +21 -0
- package/engine/object-data/entry/ability-type/provoke.lua +66 -0
- package/engine/object-data/entry/ability-type/raise-the-banner.d.ts +9 -0
- package/engine/object-data/entry/ability-type/raise-the-banner.lua +26 -0
- package/engine/object-data/entry/ability-type/reincarnation.d.ts +8 -0
- package/engine/object-data/entry/ability-type/reincarnation.lua +26 -0
- package/engine/object-data/entry/ability-type/resolve.d.ts +12 -0
- package/engine/object-data/entry/ability-type/resolve.lua +39 -0
- package/engine/object-data/entry/ability-type/righteous-fury.d.ts +33 -0
- package/engine/object-data/entry/ability-type/righteous-fury.lua +130 -0
- package/engine/object-data/entry/ability-type/sacred-aura.d.ts +27 -0
- package/engine/object-data/entry/ability-type/sacred-aura.lua +104 -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/soul-lantern.d.ts +30 -0
- package/engine/object-data/entry/ability-type/soul-lantern.lua +117 -0
- package/engine/object-data/entry/ability-type/spell-amp.d.ts +15 -0
- package/engine/object-data/entry/ability-type/spell-amp.lua +52 -0
- package/engine/object-data/entry/ability-type/spell-critical-strike.d.ts +12 -0
- package/engine/object-data/entry/ability-type/spell-critical-strike.lua +39 -0
- package/engine/object-data/entry/ability-type/spell-vamp.d.ts +12 -0
- package/engine/object-data/entry/ability-type/spell-vamp.lua +39 -0
- package/engine/object-data/entry/ability-type/stackable-evasion.d.ts +9 -0
- package/engine/object-data/entry/ability-type/stackable-evasion.lua +13 -0
- package/engine/object-data/entry/ability-type/stackable-hardened-skin.d.ts +21 -0
- package/engine/object-data/entry/ability-type/stackable-hardened-skin.lua +78 -0
- package/engine/object-data/entry/ability-type/stackable-life-steal.d.ts +9 -0
- package/engine/object-data/entry/ability-type/stackable-life-steal.lua +26 -0
- package/engine/object-data/entry/ability-type/stackable-spell-damage-reduction.d.ts +9 -0
- package/engine/object-data/entry/ability-type/stackable-spell-damage-reduction.lua +13 -0
- package/engine/object-data/entry/ability-type/stackable-thorn-shield.d.ts +9 -0
- package/engine/object-data/entry/ability-type/stackable-thorn-shield.lua +13 -0
- package/engine/object-data/entry/ability-type/stat-details.d.ts +12 -0
- package/engine/object-data/entry/ability-type/stat-details.lua +27 -0
- package/engine/object-data/entry/ability-type/surge-of-light.d.ts +33 -0
- package/engine/object-data/entry/ability-type/surge-of-light.lua +130 -0
- package/engine/object-data/entry/ability-type/sweeping-strike.d.ts +57 -0
- package/engine/object-data/entry/ability-type/sweeping-strike.lua +234 -0
- package/engine/object-data/entry/ability-type/talents.d.ts +12 -0
- package/engine/object-data/entry/ability-type/talents.lua +27 -0
- package/engine/object-data/entry/ability-type/unyielding-guard.d.ts +30 -0
- package/engine/object-data/entry/ability-type/unyielding-guard.lua +117 -0
- package/engine/object-data/entry/ability-type/valiant-charge.d.ts +27 -0
- package/engine/object-data/entry/ability-type/valiant-charge.lua +104 -0
- package/engine/object-data/entry/ability-type/warcry.d.ts +9 -0
- package/engine/object-data/entry/ability-type/warcry.lua +26 -0
- package/engine/object-data/entry/ability-type/withering-fire.d.ts +21 -0
- package/engine/object-data/entry/ability-type/withering-fire.lua +78 -0
- package/engine/object-data/entry/ability-type.d.ts +12 -3
- package/engine/object-data/entry/ability-type.lua +148 -7
- package/engine/object-data/entry/buff-type/applicable.lua +113 -104
- package/engine/object-data/entry/buff-type.d.ts +10 -12
- package/engine/object-data/entry/buff-type.lua +37 -27
- package/engine/object-data/entry/destructible-type.d.ts +32 -2
- package/engine/object-data/entry/destructible-type.lua +181 -0
- package/engine/object-data/entry/item-type.d.ts +12 -3
- package/engine/object-data/entry/item-type.lua +52 -0
- package/engine/object-data/entry/lightning-type.d.ts +2 -2
- package/engine/object-data/entry/sound-preset.d.ts +2 -2
- package/engine/object-data/entry/unit-type.d.ts +64 -6
- package/engine/object-data/entry/unit-type.lua +531 -85
- package/engine/object-data/entry/upgrade.d.ts +2 -2
- package/engine/object-data/entry.d.ts +4 -1
- package/engine/object-field/ability.d.ts +4 -4
- package/engine/object-field/ability.lua +9 -8
- package/engine/object-field/item.d.ts +22 -0
- package/engine/object-field/item.lua +118 -0
- package/engine/object-field/unit.d.ts +72 -3
- package/engine/object-field/unit.lua +268 -7
- package/engine/object-field.d.ts +26 -7
- package/engine/object-field.lua +360 -119
- package/engine/random.d.ts +10 -0
- package/engine/random.lua +21 -0
- package/engine/standard/entries/ability-type.d.ts +3102 -7
- package/engine/standard/entries/ability-type.lua +0 -6
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- package/engine/standard/entries/item-type.d.ts +1299 -0
- package/engine/standard/entries/item-type.lua +2 -0
- package/engine/standard/entries/unit-type.d.ts +5 -0
- package/engine/standard/entries/unit-type.lua +5 -0
- package/engine/standard/fields/ability.d.ts +2 -2
- package/engine/standard/fields/ability.lua +2 -2
- package/engine/standard/fields/item.d.ts +4 -0
- package/engine/standard/fields/item.lua +6 -0
- package/engine/standard/fields/unit.d.ts +12 -0
- package/engine/standard/fields/unit.lua +20 -0
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +250 -10
- package/engine/unit.d.ts +10 -1
- package/engine/unit.lua +10 -1
- package/event.d.ts +1 -1
- package/lualib_bundle.lua +1 -1
- package/math.d.ts +2 -0
- package/math.lua +14 -0
- package/net/socket.lua +1 -1
- package/network.lua +25 -1
- package/objutil/buff.lua +11 -10
- package/objutil/object.lua +1 -1
- package/operation.d.ts +8 -1
- package/operation.lua +38 -18
- package/package.json +3 -23
- package/patch-lua.lua +15 -0
- package/patch-lualib.lua +1 -1
- package/utility/arrays.d.ts +2 -0
- package/utility/arrays.lua +11 -0
- package/utility/callback-array.d.ts +17 -0
- package/utility/callback-array.lua +61 -0
- package/utility/functions.d.ts +8 -0
- package/utility/functions.lua +13 -0
- package/utility/linked-map.d.ts +35 -0
- package/utility/linked-map.lua +107 -0
- package/utility/linked-set.d.ts +5 -1
- package/utility/linked-set.lua +49 -1
- package/utility/lua-maps.d.ts +15 -2
- package/utility/lua-maps.lua +53 -2
- package/utility/lua-sets.d.ts +2 -0
- package/utility/lua-sets.lua +7 -0
- package/utility/random.d.ts +102 -0
- package/utility/random.lua +273 -0
- package/utility/records.lua +20 -1
- package/utility/types.d.ts +3 -0
- package/utility/unordered-map.d.ts +27 -0
- package/utility/unordered-map.lua +99 -0
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
- /package/engine/internal/{object-data/armor-increase.d.ts → misc/damage-metadata-by-target.d.ts} +0 -0
- /package/engine/internal/object-data/{armor-increase.lua → armor-bonus.lua} +0 -0
- /package/engine/object-data/entry/ability-type/{attribute-increase.d.ts → attribute-bonus.d.ts} +0 -0
- /package/engine/object-data/entry/ability-type/{attribute-increase.lua → attribute-bonus.lua} +0 -0
package/engine/local-client.d.ts
CHANGED
|
@@ -3,19 +3,46 @@ import { Unit } from "../core/types/unit";
|
|
|
3
3
|
import { Async } from "../core/types/async";
|
|
4
4
|
import { Event, TriggerEvent } from "../event";
|
|
5
5
|
import { GraphicsMode } from "./index";
|
|
6
|
+
import { Color } from "../core/types/color";
|
|
6
7
|
export declare class LocalClient {
|
|
7
8
|
private constructor();
|
|
8
9
|
static readonly locale: string;
|
|
9
10
|
static get width(): number;
|
|
10
11
|
static get height(): number;
|
|
12
|
+
static get isSD(): boolean;
|
|
11
13
|
static get isHD(): boolean;
|
|
14
|
+
static get isDE(): boolean;
|
|
12
15
|
static get graphicsMode(): GraphicsMode;
|
|
13
16
|
static get isActive(): boolean;
|
|
17
|
+
static get isMinimized(): boolean;
|
|
18
|
+
static pingMinimap(x: number, y: number, duration: number, ...parameters: [] | [red: number, green: number, blue: number, flashy?: boolean] | [color: Color, flashy?: boolean]): void;
|
|
19
|
+
/** Local input state; do not use to branch synchronized game logic. */
|
|
20
|
+
static isKeyPressed(key: joskeytype): boolean;
|
|
21
|
+
/** Local input state. Uses the same modifier mask as Player key events. */
|
|
22
|
+
static isMetaKeyPressed(key: oskeymeta): boolean;
|
|
23
|
+
/** Local input state. */
|
|
24
|
+
static isMouseButtonPressed(button: jmousebuttontype): boolean;
|
|
25
|
+
static get mouseScreenX(): number;
|
|
26
|
+
static get mouseScreenY(): number;
|
|
27
|
+
static screenToFrameX(x: number): number;
|
|
28
|
+
static screenToFrameY(y: number): number;
|
|
29
|
+
static frameToScreenX(x: number): number;
|
|
30
|
+
static frameToScreenY(y: number): number;
|
|
31
|
+
static get mouseFrameX(): number;
|
|
32
|
+
static get mouseFrameY(): number;
|
|
14
33
|
static get mouseFocusUnit(): Async<Unit> | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Local selection sampled every 1/64 second. Undefined before the first tick and while
|
|
36
|
+
* a group selection's buttons are not registered yet (see `selectionLayoutSocket`).
|
|
37
|
+
*/
|
|
15
38
|
static get mainSelectedUnit(): Async<Unit> | undefined;
|
|
16
39
|
static get mainSelectedUnitChangeEvent(): Event<[
|
|
17
40
|
previousMainSelectedUnit: Unit | undefined,
|
|
18
41
|
newMainSelectedUnit: Unit | undefined
|
|
19
42
|
]>;
|
|
43
|
+
static get isInTargetingMode(): boolean;
|
|
44
|
+
static readonly targetingModeEnterEvent: Event<[]>;
|
|
45
|
+
static readonly targetingModeLeaveEvent: Event<[]>;
|
|
46
|
+
static readonly targetingModeStateChangeEvent: Event<[]>;
|
|
20
47
|
static readonly onDisconnect: TriggerEvent<[]>;
|
|
21
48
|
}
|
package/engine/local-client.lua
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
-
local
|
|
2
|
+
local __TS__New = ____lualib.__TS__New
|
|
3
3
|
local __TS__Class = ____lualib.__TS__Class
|
|
4
|
+
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
4
5
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
5
|
-
local __TS__New = ____lualib.__TS__New
|
|
6
6
|
local ____exports = {}
|
|
7
|
+
local actualizeTargetingModeState
|
|
7
8
|
local ____unit = require("core.types.unit")
|
|
8
9
|
local Unit = ____unit.Unit
|
|
9
10
|
local ____event = require("event")
|
|
@@ -15,31 +16,179 @@ local ____player = require("core.types.player")
|
|
|
15
16
|
local Player = ____player.Player
|
|
16
17
|
local ____timer = require("core.types.timer")
|
|
17
18
|
local Timer = ____timer.Timer
|
|
18
|
-
local
|
|
19
|
-
local
|
|
20
|
-
local
|
|
21
|
-
local
|
|
22
|
-
local
|
|
19
|
+
local ____color = require("core.types.color")
|
|
20
|
+
local Color = ____color.Color
|
|
21
|
+
local ____arrays = require("utility.arrays")
|
|
22
|
+
local array = ____arrays.array
|
|
23
|
+
local ____socket = require("net.socket")
|
|
24
|
+
local Socket = ____socket.Socket
|
|
25
|
+
local frameGetChild = BlzFrameGetChild
|
|
26
|
+
local frameGetChildrenCount = BlzFrameGetChildrenCount
|
|
27
|
+
local frameGetParent = BlzFrameGetParent
|
|
28
|
+
local frameGetWidth = BlzFrameGetWidth
|
|
29
|
+
local frameToPixelX = BlzFrameToPixelX
|
|
30
|
+
local frameToPixelY = BlzFrameToPixelY
|
|
31
|
+
local getFrameByName = BlzGetFrameByName
|
|
23
32
|
local getHandleId = GetHandleId
|
|
33
|
+
local getLocalClientHeight = BlzGetLocalClientHeight
|
|
34
|
+
local getLocalClientWidth = BlzGetLocalClientWidth
|
|
35
|
+
local getLocale = BlzGetLocale
|
|
24
36
|
local getMouseFocusUnit = BlzGetMouseFocusUnit
|
|
37
|
+
local getMouseScreenPosX = BlzGetMouseScreenPosX
|
|
38
|
+
local getMouseScreenPosY = BlzGetMouseScreenPosY
|
|
25
39
|
local getUnitRealField = BlzGetUnitRealField
|
|
26
40
|
local getUnitTypeId = GetUnitTypeId
|
|
27
|
-
local
|
|
41
|
+
local isHeroUnitId = IsHeroUnitId
|
|
42
|
+
local isKeyPressed = BlzIsKeyPressed
|
|
43
|
+
local isLocalClientActive = BlzIsLocalClientActive
|
|
44
|
+
local isMetaKeyPressed = BlzIsMetaKeyPressed
|
|
45
|
+
local isMouseButtonPressed = BlzIsMouseButtonPressed
|
|
46
|
+
local loadTOCFile = BlzLoadTOCFile
|
|
47
|
+
local location = Location
|
|
48
|
+
local pingMinimap = PingMinimap
|
|
49
|
+
local pingMinimapEx = PingMinimapEx
|
|
50
|
+
local pixelToFrameX = BlzPixelToFrameX
|
|
51
|
+
local pixelToFrameY = BlzPixelToFrameY
|
|
28
52
|
local tableSort = table.sort
|
|
29
|
-
local
|
|
53
|
+
local hdTocPath = "_warscript\\IsHD.toc"
|
|
54
|
+
local deTocPath = "_warscript\\IsDE.toc"
|
|
30
55
|
compiletime(function()
|
|
31
56
|
if currentMap then
|
|
32
|
-
local
|
|
33
|
-
currentMap:addFileString("_HD.w3mod\\" ..
|
|
34
|
-
currentMap:addFileString("_HD.w3mod\\" ..
|
|
57
|
+
local hdFdfPath = "_warscript\\IsHD.fdf"
|
|
58
|
+
currentMap:addFileString("_HD.w3mod\\" .. hdFdfPath, "\r\n")
|
|
59
|
+
currentMap:addFileString("_HD.w3mod\\" .. hdTocPath, hdFdfPath .. "\r\n")
|
|
60
|
+
local deFdfPath = "_warscript\\IsDE.fdf"
|
|
61
|
+
currentMap:addFileString("_DE.w3mod\\" .. deFdfPath, "\r\n")
|
|
62
|
+
currentMap:addFileString("_DE.w3mod\\" .. deTocPath, deFdfPath .. "\r\n")
|
|
35
63
|
end
|
|
36
64
|
end)
|
|
37
|
-
local
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
65
|
+
local SELECTION_DETAIL_FRAME_NAME = "SimpleInfoPanelUnitDetail"
|
|
66
|
+
local SELECTION_GROUP_PANEL_INDEX = 5
|
|
67
|
+
local SELECTION_BUTTON_ICON_INDEX = 1
|
|
68
|
+
--- The detail panel, its parent, the group panel and the button grid.
|
|
69
|
+
local SELECTION_LAYOUT_ROOT_HANDLE_COUNT = 4
|
|
70
|
+
local SELECTION_LAYOUT_MAX_BUTTON_COUNT = 24
|
|
71
|
+
--- The root frames plus a button and its icon per slot of the largest layout.
|
|
72
|
+
local SELECTION_LAYOUT_MAX_HANDLE_COUNT = SELECTION_LAYOUT_ROOT_HANDLE_COUNT + 2 * SELECTION_LAYOUT_MAX_BUTTON_COUNT
|
|
73
|
+
--- Registration requests for one local selection before giving up on its layout.
|
|
74
|
+
local SELECTION_LAYOUT_MAX_REQUEST_COUNT = 8
|
|
75
|
+
--- Polling ticks between two registration requests for the same selection.
|
|
76
|
+
local SELECTION_LAYOUT_REQUEST_INTERVAL = 16
|
|
77
|
+
local registeredSelectionGrid
|
|
78
|
+
local registeredSelectionButtonCount = 0
|
|
79
|
+
local registeredSelectionButtons = {}
|
|
80
|
+
local registeredSelectionButtonChildCounts = {}
|
|
81
|
+
local registeredSelectionIcons = {}
|
|
82
|
+
--- The index of the widest (highlighted) button among the registered ones. The first value
|
|
83
|
+
-- is false when the layout no longer matches the registration: the grid or a button has a
|
|
84
|
+
-- different number of children, or an icon reads as zero width, which a destroyed frame does.
|
|
85
|
+
local function getRegisteredMainSelectedUnitIndex()
|
|
86
|
+
local grid = registeredSelectionGrid
|
|
87
|
+
if grid == nil or frameGetChildrenCount(grid) ~= registeredSelectionButtonCount then
|
|
88
|
+
return false, 0
|
|
89
|
+
end
|
|
90
|
+
local mainSelectedUnitIndex = 0
|
|
91
|
+
local maxButtonWidth = 0
|
|
92
|
+
for i = 0, registeredSelectionButtonCount - 1 do
|
|
93
|
+
if frameGetChildrenCount(registeredSelectionButtons[i + 1]) ~= registeredSelectionButtonChildCounts[i + 1] then
|
|
94
|
+
return false, 0
|
|
95
|
+
end
|
|
96
|
+
local width = frameGetWidth(registeredSelectionIcons[i + 1])
|
|
97
|
+
if width <= 0 then
|
|
98
|
+
return false, 0
|
|
99
|
+
end
|
|
100
|
+
if width > maxButtonWidth then
|
|
101
|
+
maxButtonWidth = width
|
|
102
|
+
mainSelectedUnitIndex = i
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
return true, mainSelectedUnitIndex
|
|
106
|
+
end
|
|
107
|
+
local function getChildIfPresent(parent, index)
|
|
108
|
+
if parent == nil or index >= frameGetChildrenCount(parent) then
|
|
109
|
+
return nil
|
|
110
|
+
end
|
|
111
|
+
return frameGetChild(parent, index)
|
|
112
|
+
end
|
|
113
|
+
local function padSelectionLayoutFrames(registeredCount)
|
|
114
|
+
do
|
|
115
|
+
local i = registeredCount
|
|
116
|
+
while i < SELECTION_LAYOUT_MAX_HANDLE_COUNT do
|
|
117
|
+
location(0, 0)
|
|
118
|
+
i = i + 1
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
--- Wraps every frame of the group selection layout currently shown on this client, in the
|
|
123
|
+
-- order `actualizeMainSelectedUnit` later walks them. Game-owned frames receive a JASS handle
|
|
124
|
+
-- id the first time a script retrieves them, and the game builds the layout's buttons anew
|
|
125
|
+
-- whenever the selection changes, so this must run in a tick every client shares and register
|
|
126
|
+
-- the same number of handles everywhere: every frame reached for the first time counts, and
|
|
127
|
+
-- the remainder up to SELECTION_LAYOUT_MAX_HANDLE_COUNT is padded with locations, the way
|
|
128
|
+
-- `Frame.byOrigin` balances origin frames that appear asynchronously.
|
|
129
|
+
--
|
|
130
|
+
-- Returns the number of buttons found, or undefined when the layout was not fully reachable.
|
|
131
|
+
local function registerShownSelectionLayoutFrames()
|
|
132
|
+
local registeredCount = 0
|
|
133
|
+
local function register(handle)
|
|
134
|
+
if handle == nil or getHandleId(handle) == 0 then
|
|
135
|
+
return nil
|
|
136
|
+
end
|
|
137
|
+
if not Frame:isWrapped(handle) then
|
|
138
|
+
registeredCount = registeredCount + 1
|
|
139
|
+
end
|
|
140
|
+
Frame:of(handle)
|
|
141
|
+
return handle
|
|
142
|
+
end
|
|
143
|
+
local detail = register(getFrameByName(SELECTION_DETAIL_FRAME_NAME, 0))
|
|
144
|
+
local container = register(detail ~= nil and frameGetParent(detail) or nil)
|
|
145
|
+
local groupPanel = register(getChildIfPresent(container, SELECTION_GROUP_PANEL_INDEX))
|
|
146
|
+
local grid = register(getChildIfPresent(groupPanel, 0))
|
|
147
|
+
registeredSelectionGrid = grid
|
|
148
|
+
local buttonCount
|
|
149
|
+
if grid ~= nil then
|
|
150
|
+
local count = frameGetChildrenCount(grid)
|
|
151
|
+
if count <= SELECTION_LAYOUT_MAX_BUTTON_COUNT then
|
|
152
|
+
buttonCount = count
|
|
153
|
+
for i = 0, count - 1 do
|
|
154
|
+
local button = register(getChildIfPresent(grid, i))
|
|
155
|
+
local icon = register(getChildIfPresent(button, SELECTION_BUTTON_ICON_INDEX))
|
|
156
|
+
if button == nil or icon == nil then
|
|
157
|
+
buttonCount = nil
|
|
158
|
+
else
|
|
159
|
+
registeredSelectionButtons[i + 1] = button
|
|
160
|
+
registeredSelectionButtonChildCounts[i + 1] = frameGetChildrenCount(button)
|
|
161
|
+
registeredSelectionIcons[i + 1] = icon
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
padSelectionLayoutFrames(registeredCount)
|
|
167
|
+
return buttonCount
|
|
168
|
+
end
|
|
169
|
+
local function getExpectedSelectionLayoutButtonCount(selectionCount)
|
|
170
|
+
return selectionCount <= 12 and 12 or SELECTION_LAYOUT_MAX_BUTTON_COUNT
|
|
171
|
+
end
|
|
172
|
+
local selectionLayoutSocket = __TS__New(Socket)
|
|
173
|
+
local localSelectionSignature = 0
|
|
174
|
+
local localSelectionEpoch = 0
|
|
175
|
+
local localSelectionCount = 0
|
|
176
|
+
local registeredSelectionEpoch = 0
|
|
177
|
+
local selectionLayoutRequestCount = 0
|
|
178
|
+
local selectionLayoutRequestPending = false
|
|
179
|
+
local selectionLayoutPollTick = 0
|
|
180
|
+
local selectionLayoutRequestTick = -SELECTION_LAYOUT_REQUEST_INTERVAL
|
|
181
|
+
selectionLayoutSocket.onMessage:addListener(function(player)
|
|
182
|
+
if player ~= Player["local"] then
|
|
183
|
+
padSelectionLayoutFrames(0)
|
|
184
|
+
return
|
|
185
|
+
end
|
|
186
|
+
selectionLayoutRequestPending = false
|
|
187
|
+
local buttonCount = registerShownSelectionLayoutFrames()
|
|
188
|
+
if buttonCount ~= nil and localSelectionCount > 1 and buttonCount == getExpectedSelectionLayoutButtonCount(localSelectionCount) then
|
|
189
|
+
registeredSelectionEpoch = localSelectionEpoch
|
|
190
|
+
registeredSelectionButtonCount = buttonCount
|
|
191
|
+
end
|
|
43
192
|
end)
|
|
44
193
|
local localSelectedUnits = {}
|
|
45
194
|
local indexByLocalSelectedUnit = {}
|
|
@@ -57,11 +206,62 @@ local function compareUnitsSelectionPriority(a, b)
|
|
|
57
206
|
end
|
|
58
207
|
local mainSelectedUnitChangeEvent
|
|
59
208
|
local previousMainSelectedUnit
|
|
209
|
+
local currentMainSelectedUnit
|
|
210
|
+
local lastTargetingModeState = false
|
|
211
|
+
local targetingModeEnterEvent = __TS__New(Event)
|
|
212
|
+
local targetingModeLeaveEvent = __TS__New(Event)
|
|
213
|
+
local targetingModeStateChangeEvent = __TS__New(Event)
|
|
60
214
|
____exports.LocalClient = __TS__Class()
|
|
61
215
|
local LocalClient = ____exports.LocalClient
|
|
62
216
|
LocalClient.name = "LocalClient"
|
|
63
217
|
function LocalClient.prototype.____constructor(self)
|
|
64
218
|
end
|
|
219
|
+
function LocalClient.pingMinimap(self, x, y, duration, redOrColor, greenOrFlashy, blue, flashy)
|
|
220
|
+
if redOrColor == nil then
|
|
221
|
+
pingMinimap(x, y, duration)
|
|
222
|
+
elseif __TS__InstanceOf(redOrColor, Color) then
|
|
223
|
+
pingMinimapEx(
|
|
224
|
+
x,
|
|
225
|
+
y,
|
|
226
|
+
duration,
|
|
227
|
+
redOrColor.r,
|
|
228
|
+
redOrColor.g,
|
|
229
|
+
redOrColor.b,
|
|
230
|
+
greenOrFlashy or false
|
|
231
|
+
)
|
|
232
|
+
else
|
|
233
|
+
pingMinimapEx(
|
|
234
|
+
x,
|
|
235
|
+
y,
|
|
236
|
+
duration,
|
|
237
|
+
redOrColor,
|
|
238
|
+
greenOrFlashy,
|
|
239
|
+
blue,
|
|
240
|
+
flashy or false
|
|
241
|
+
)
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
function LocalClient.isKeyPressed(self, key)
|
|
245
|
+
return isKeyPressed(key)
|
|
246
|
+
end
|
|
247
|
+
function LocalClient.isMetaKeyPressed(self, key)
|
|
248
|
+
return isMetaKeyPressed(key)
|
|
249
|
+
end
|
|
250
|
+
function LocalClient.isMouseButtonPressed(self, button)
|
|
251
|
+
return isMouseButtonPressed(button)
|
|
252
|
+
end
|
|
253
|
+
function LocalClient.screenToFrameX(self, x)
|
|
254
|
+
return pixelToFrameX(x)
|
|
255
|
+
end
|
|
256
|
+
function LocalClient.screenToFrameY(self, y)
|
|
257
|
+
return pixelToFrameY(y)
|
|
258
|
+
end
|
|
259
|
+
function LocalClient.frameToScreenX(self, x)
|
|
260
|
+
return frameToPixelX(x)
|
|
261
|
+
end
|
|
262
|
+
function LocalClient.frameToScreenY(self, y)
|
|
263
|
+
return frameToPixelY(y)
|
|
264
|
+
end
|
|
65
265
|
LocalClient.locale = getLocale()
|
|
66
266
|
__TS__ObjectDefineProperty(
|
|
67
267
|
LocalClient,
|
|
@@ -77,6 +277,13 @@ __TS__ObjectDefineProperty(
|
|
|
77
277
|
return getLocalClientHeight()
|
|
78
278
|
end}
|
|
79
279
|
)
|
|
280
|
+
__TS__ObjectDefineProperty(
|
|
281
|
+
LocalClient,
|
|
282
|
+
"isSD",
|
|
283
|
+
{get = function(self)
|
|
284
|
+
return true
|
|
285
|
+
end}
|
|
286
|
+
)
|
|
80
287
|
__TS__ObjectDefineProperty(
|
|
81
288
|
LocalClient,
|
|
82
289
|
"isHD",
|
|
@@ -84,11 +291,18 @@ __TS__ObjectDefineProperty(
|
|
|
84
291
|
return false
|
|
85
292
|
end}
|
|
86
293
|
)
|
|
294
|
+
__TS__ObjectDefineProperty(
|
|
295
|
+
LocalClient,
|
|
296
|
+
"isDE",
|
|
297
|
+
{get = function(self)
|
|
298
|
+
return false
|
|
299
|
+
end}
|
|
300
|
+
)
|
|
87
301
|
__TS__ObjectDefineProperty(
|
|
88
302
|
LocalClient,
|
|
89
303
|
"graphicsMode",
|
|
90
304
|
{get = function(self)
|
|
91
|
-
return
|
|
305
|
+
return 0
|
|
92
306
|
end}
|
|
93
307
|
)
|
|
94
308
|
__TS__ObjectDefineProperty(
|
|
@@ -98,6 +312,41 @@ __TS__ObjectDefineProperty(
|
|
|
98
312
|
return isLocalClientActive()
|
|
99
313
|
end}
|
|
100
314
|
)
|
|
315
|
+
__TS__ObjectDefineProperty(
|
|
316
|
+
LocalClient,
|
|
317
|
+
"isMinimized",
|
|
318
|
+
{get = function(self)
|
|
319
|
+
return getLocalClientHeight() == 0
|
|
320
|
+
end}
|
|
321
|
+
)
|
|
322
|
+
__TS__ObjectDefineProperty(
|
|
323
|
+
LocalClient,
|
|
324
|
+
"mouseScreenX",
|
|
325
|
+
{get = function(self)
|
|
326
|
+
return getMouseScreenPosX()
|
|
327
|
+
end}
|
|
328
|
+
)
|
|
329
|
+
__TS__ObjectDefineProperty(
|
|
330
|
+
LocalClient,
|
|
331
|
+
"mouseScreenY",
|
|
332
|
+
{get = function(self)
|
|
333
|
+
return getMouseScreenPosY()
|
|
334
|
+
end}
|
|
335
|
+
)
|
|
336
|
+
__TS__ObjectDefineProperty(
|
|
337
|
+
LocalClient,
|
|
338
|
+
"mouseFrameX",
|
|
339
|
+
{get = function(self)
|
|
340
|
+
return pixelToFrameX(getMouseScreenPosX())
|
|
341
|
+
end}
|
|
342
|
+
)
|
|
343
|
+
__TS__ObjectDefineProperty(
|
|
344
|
+
LocalClient,
|
|
345
|
+
"mouseFrameY",
|
|
346
|
+
{get = function(self)
|
|
347
|
+
return pixelToFrameY(getMouseScreenPosY())
|
|
348
|
+
end}
|
|
349
|
+
)
|
|
101
350
|
__TS__ObjectDefineProperty(
|
|
102
351
|
LocalClient,
|
|
103
352
|
"mouseFocusUnit",
|
|
@@ -109,33 +358,7 @@ __TS__ObjectDefineProperty(
|
|
|
109
358
|
LocalClient,
|
|
110
359
|
"mainSelectedUnit",
|
|
111
360
|
{get = function(self)
|
|
112
|
-
|
|
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
|
|
361
|
+
return currentMainSelectedUnit
|
|
139
362
|
end}
|
|
140
363
|
)
|
|
141
364
|
__TS__ObjectDefineProperty(
|
|
@@ -144,13 +367,20 @@ __TS__ObjectDefineProperty(
|
|
|
144
367
|
{get = function(self)
|
|
145
368
|
if mainSelectedUnitChangeEvent == nil then
|
|
146
369
|
mainSelectedUnitChangeEvent = __TS__New(Event)
|
|
147
|
-
Timer.onPeriod[1 / 64]:addListener(function()
|
|
148
|
-
local _ = ____exports.LocalClient.mainSelectedUnit
|
|
149
|
-
end)
|
|
150
370
|
end
|
|
151
371
|
return mainSelectedUnitChangeEvent
|
|
152
372
|
end}
|
|
153
373
|
)
|
|
374
|
+
__TS__ObjectDefineProperty(
|
|
375
|
+
LocalClient,
|
|
376
|
+
"isInTargetingMode",
|
|
377
|
+
{get = function(self)
|
|
378
|
+
return actualizeTargetingModeState()
|
|
379
|
+
end}
|
|
380
|
+
)
|
|
381
|
+
LocalClient.targetingModeEnterEvent = targetingModeEnterEvent
|
|
382
|
+
LocalClient.targetingModeLeaveEvent = targetingModeLeaveEvent
|
|
383
|
+
LocalClient.targetingModeStateChangeEvent = targetingModeStateChangeEvent
|
|
154
384
|
LocalClient.onDisconnect = __TS__New(
|
|
155
385
|
TriggerEvent,
|
|
156
386
|
function(trigger)
|
|
@@ -158,11 +388,97 @@ LocalClient.onDisconnect = __TS__New(
|
|
|
158
388
|
end,
|
|
159
389
|
function() return end
|
|
160
390
|
)
|
|
391
|
+
local function actualizeMainSelectedUnit()
|
|
392
|
+
Unit:getSelectionOf(Player["local"], localSelectedUnits)
|
|
393
|
+
local selectionCount = #localSelectedUnits
|
|
394
|
+
local signature = selectionCount
|
|
395
|
+
for i = 1, selectionCount do
|
|
396
|
+
indexByLocalSelectedUnit[localSelectedUnits[i]] = i
|
|
397
|
+
signature = signature + getHandleId(localSelectedUnits[i].handle)
|
|
398
|
+
end
|
|
399
|
+
selectionLayoutPollTick = selectionLayoutPollTick + 1
|
|
400
|
+
if signature ~= localSelectionSignature then
|
|
401
|
+
localSelectionSignature = signature
|
|
402
|
+
localSelectionEpoch = localSelectionEpoch + 1
|
|
403
|
+
selectionLayoutRequestCount = 0
|
|
404
|
+
selectionLayoutRequestTick = -SELECTION_LAYOUT_REQUEST_INTERVAL
|
|
405
|
+
end
|
|
406
|
+
localSelectionCount = selectionCount
|
|
407
|
+
tableSort(localSelectedUnits, compareUnitsSelectionPriority)
|
|
408
|
+
local mainSelectedUnitIndex
|
|
409
|
+
if selectionCount > 1 then
|
|
410
|
+
local registered = registeredSelectionEpoch == localSelectionEpoch
|
|
411
|
+
if registered then
|
|
412
|
+
local intact, index = getRegisteredMainSelectedUnitIndex()
|
|
413
|
+
if intact then
|
|
414
|
+
mainSelectedUnitIndex = index
|
|
415
|
+
else
|
|
416
|
+
registered = false
|
|
417
|
+
registeredSelectionEpoch = 0
|
|
418
|
+
end
|
|
419
|
+
end
|
|
420
|
+
if not registered and not selectionLayoutRequestPending and selectionLayoutRequestCount < SELECTION_LAYOUT_MAX_REQUEST_COUNT and selectionLayoutPollTick - selectionLayoutRequestTick >= SELECTION_LAYOUT_REQUEST_INTERVAL then
|
|
421
|
+
selectionLayoutRequestPending = true
|
|
422
|
+
selectionLayoutRequestCount = selectionLayoutRequestCount + 1
|
|
423
|
+
selectionLayoutRequestTick = selectionLayoutPollTick
|
|
424
|
+
selectionLayoutSocket:send("")
|
|
425
|
+
end
|
|
426
|
+
end
|
|
427
|
+
local mainSelectedUnit
|
|
428
|
+
if selectionCount <= 1 then
|
|
429
|
+
mainSelectedUnit = localSelectedUnits[1]
|
|
430
|
+
elseif mainSelectedUnitIndex ~= nil then
|
|
431
|
+
mainSelectedUnit = localSelectedUnits[mainSelectedUnitIndex + 1]
|
|
432
|
+
end
|
|
433
|
+
for i = 1, selectionCount do
|
|
434
|
+
indexByLocalSelectedUnit[localSelectedUnits[i]] = nil
|
|
435
|
+
localSelectedUnits[i] = nil
|
|
436
|
+
end
|
|
437
|
+
currentMainSelectedUnit = mainSelectedUnit
|
|
438
|
+
if mainSelectedUnitChangeEvent ~= nil and mainSelectedUnit ~= previousMainSelectedUnit then
|
|
439
|
+
local previousPreviousMainSelectedUnit = previousMainSelectedUnit
|
|
440
|
+
previousMainSelectedUnit = mainSelectedUnit
|
|
441
|
+
Event.invoke(mainSelectedUnitChangeEvent, previousPreviousMainSelectedUnit, previousMainSelectedUnit)
|
|
442
|
+
end
|
|
443
|
+
end
|
|
444
|
+
local commandButtons = array(
|
|
445
|
+
12,
|
|
446
|
+
function(i) return Frame:byOrigin(ORIGIN_FRAME_COMMAND_BUTTON, i) end
|
|
447
|
+
)
|
|
448
|
+
local function getTargetingModeState()
|
|
449
|
+
for i = 0, 10 do
|
|
450
|
+
if commandButtons[i + 1].visible then
|
|
451
|
+
return false
|
|
452
|
+
end
|
|
453
|
+
end
|
|
454
|
+
return commandButtons[12].visible
|
|
455
|
+
end
|
|
456
|
+
actualizeTargetingModeState = function()
|
|
457
|
+
if getTargetingModeState() then
|
|
458
|
+
if not lastTargetingModeState then
|
|
459
|
+
lastTargetingModeState = true
|
|
460
|
+
Event.invoke(targetingModeEnterEvent)
|
|
461
|
+
Event.invoke(targetingModeStateChangeEvent)
|
|
462
|
+
end
|
|
463
|
+
return true
|
|
464
|
+
end
|
|
465
|
+
if lastTargetingModeState then
|
|
466
|
+
lastTargetingModeState = false
|
|
467
|
+
Event.invoke(targetingModeLeaveEvent)
|
|
468
|
+
Event.invoke(targetingModeStateChangeEvent)
|
|
469
|
+
end
|
|
470
|
+
return false
|
|
471
|
+
end
|
|
472
|
+
Timer.onPeriod[1 / 64]:addListener(function()
|
|
473
|
+
actualizeMainSelectedUnit()
|
|
474
|
+
actualizeTargetingModeState()
|
|
475
|
+
end)
|
|
161
476
|
warpack.afterMapInit(function()
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
)
|
|
477
|
+
local isDE = loadTOCFile(deTocPath)
|
|
478
|
+
local isHD = not isDE and loadTOCFile(hdTocPath)
|
|
479
|
+
rawset(____exports.LocalClient, "isDE", isDE)
|
|
480
|
+
rawset(____exports.LocalClient, "isHD", isHD)
|
|
481
|
+
rawset(____exports.LocalClient, "isSD", not isDE and not isHD)
|
|
482
|
+
rawset(____exports.LocalClient, "graphicsMode", isDE and 2 or (isHD and 1 or 0))
|
|
167
483
|
end)
|
|
168
484
|
return ____exports
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____records = require("utility.records")
|
|
3
|
+
local invertRecord = ____records.invertRecord
|
|
4
|
+
local stringByArmorType = {
|
|
5
|
+
[0] = "small",
|
|
6
|
+
[1] = "medium",
|
|
7
|
+
[2] = "large",
|
|
8
|
+
[3] = "fort",
|
|
9
|
+
[4] = "normal",
|
|
10
|
+
[5] = "hero",
|
|
11
|
+
[6] = "divine",
|
|
12
|
+
[7] = "none"
|
|
13
|
+
}
|
|
14
|
+
local armorTypeByString = invertRecord(stringByArmorType)
|
|
15
|
+
local nativeByArmorType = {
|
|
16
|
+
[0] = DEFENSE_TYPE_LIGHT,
|
|
17
|
+
[1] = DEFENSE_TYPE_MEDIUM,
|
|
18
|
+
[2] = DEFENSE_TYPE_LARGE,
|
|
19
|
+
[3] = DEFENSE_TYPE_FORT,
|
|
20
|
+
[4] = DEFENSE_TYPE_NORMAL,
|
|
21
|
+
[5] = DEFENSE_TYPE_HERO,
|
|
22
|
+
[6] = DEFENSE_TYPE_DIVINE,
|
|
23
|
+
[7] = DEFENSE_TYPE_NONE
|
|
24
|
+
}
|
|
25
|
+
local armorTypeByNative = invertRecord(nativeByArmorType)
|
|
26
|
+
---
|
|
27
|
+
-- @internal For use by internal systems only.
|
|
28
|
+
____exports.armorTypeToString = function(armorType)
|
|
29
|
+
return stringByArmorType[armorType]
|
|
30
|
+
end
|
|
31
|
+
---
|
|
32
|
+
-- @internal For use by internal systems only.
|
|
33
|
+
____exports.stringToArmorType = function(____string)
|
|
34
|
+
return armorTypeByString[____string] or 7
|
|
35
|
+
end
|
|
36
|
+
---
|
|
37
|
+
-- @internal For use by internal systems only.
|
|
38
|
+
____exports.armorTypeToNative = function(armorType)
|
|
39
|
+
return nativeByArmorType[armorType]
|
|
40
|
+
end
|
|
41
|
+
---
|
|
42
|
+
-- @internal For use by internal systems only.
|
|
43
|
+
____exports.nativeToArmorType = function(armorType)
|
|
44
|
+
return armorTypeByNative[armorType]
|
|
45
|
+
end
|
|
46
|
+
return ____exports
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
export declare const enum AttackType {
|
|
3
|
-
|
|
4
|
-
NORMAL =
|
|
5
|
-
PIERCE =
|
|
6
|
-
SIEGE =
|
|
7
|
-
|
|
8
|
-
CHAOS =
|
|
9
|
-
|
|
10
|
-
HERO = "hero"
|
|
3
|
+
SPELL = 0,
|
|
4
|
+
NORMAL = 1,
|
|
5
|
+
PIERCE = 2,
|
|
6
|
+
SIEGE = 3,
|
|
7
|
+
MAGIC = 4,
|
|
8
|
+
CHAOS = 5,
|
|
9
|
+
HERO = 6
|
|
11
10
|
}
|
|
@@ -1,2 +1,44 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
|
+
local ____records = require("utility.records")
|
|
3
|
+
local invertRecord = ____records.invertRecord
|
|
4
|
+
local stringByAttackType = {
|
|
5
|
+
[1] = "normal",
|
|
6
|
+
[2] = "pierce",
|
|
7
|
+
[3] = "siege",
|
|
8
|
+
[0] = "spells",
|
|
9
|
+
[5] = "chaos",
|
|
10
|
+
[4] = "magic",
|
|
11
|
+
[6] = "hero"
|
|
12
|
+
}
|
|
13
|
+
local attackTypeByString = invertRecord(stringByAttackType)
|
|
14
|
+
local nativeByAttackType = {
|
|
15
|
+
[1] = ATTACK_TYPE_MELEE,
|
|
16
|
+
[2] = ATTACK_TYPE_PIERCE,
|
|
17
|
+
[3] = ATTACK_TYPE_SIEGE,
|
|
18
|
+
[0] = ATTACK_TYPE_NORMAL,
|
|
19
|
+
[5] = ATTACK_TYPE_CHAOS,
|
|
20
|
+
[4] = ATTACK_TYPE_MAGIC,
|
|
21
|
+
[6] = ATTACK_TYPE_HERO
|
|
22
|
+
}
|
|
23
|
+
local attackTypeByNative = invertRecord(nativeByAttackType)
|
|
24
|
+
---
|
|
25
|
+
-- @internal For use by internal systems only.
|
|
26
|
+
____exports.attackTypeToString = function(attackType)
|
|
27
|
+
return attackType ~= nil and stringByAttackType[attackType] or "unknown"
|
|
28
|
+
end
|
|
29
|
+
---
|
|
30
|
+
-- @internal For use by internal systems only.
|
|
31
|
+
____exports.stringToAttackType = function(____string)
|
|
32
|
+
return attackTypeByString[____string]
|
|
33
|
+
end
|
|
34
|
+
---
|
|
35
|
+
-- @internal For use by internal systems only.
|
|
36
|
+
____exports.attackTypeToNative = function(attackType)
|
|
37
|
+
return nativeByAttackType[attackType]
|
|
38
|
+
end
|
|
39
|
+
---
|
|
40
|
+
-- @internal For use by internal systems only.
|
|
41
|
+
____exports.nativeToAttackType = function(attackType)
|
|
42
|
+
return attackTypeByNative[attackType]
|
|
43
|
+
end
|
|
2
44
|
return ____exports
|