warscript 0.0.1-dev.dd8349d → 0.0.1-dev.e147c49
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 +1 -0
- package/attributes.lua +9 -0
- 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 +14 -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 +711 -11
- 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 +3 -0
- package/engine/behaviour/ability/damage.lua +18 -15
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +16 -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 +28 -5
- package/engine/behaviour/unit.lua +186 -27
- 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 +9 -1
- package/engine/internal/ability.lua +96 -44
- package/engine/internal/item/ability.lua +51 -1
- 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 +24 -14
- package/engine/internal/item.lua +176 -85
- package/engine/internal/mechanics/cast-ability.lua +6 -3
- 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/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 +9 -0
- package/engine/internal/unit+damage.lua +33 -0
- package/engine/internal/unit-missile-data.lua +58 -32
- package/engine/internal/unit-missile-launch.lua +52 -14
- package/engine/internal/unit.d.ts +19 -24
- package/engine/internal/unit.lua +233 -246
- package/engine/local-client.d.ts +27 -0
- package/engine/local-client.lua +518 -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/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/sound-set-name.d.ts +14 -3
- package/engine/object-data/auxiliary/unit-attribute.lua +1 -1
- 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/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/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/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 +142 -8
- package/engine/object-data/entry/buff-type/applicable.lua +113 -109
- package/engine/object-data/entry/buff-type.d.ts +6 -2
- package/engine/object-data/entry/buff-type.lua +26 -0
- 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 +62 -4
- package/engine/object-data/entry/unit-type.lua +474 -38
- 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 +3 -3
- 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 +31 -5
- package/engine/object-field/unit.lua +95 -0
- package/engine/object-field.d.ts +18 -7
- package/engine/object-field.lua +294 -135
- 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/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 +10 -8
- 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 +1 -0
- package/utility/arrays.lua +8 -0
- package/utility/callback-array.d.ts +17 -0
- package/utility/callback-array.lua +61 -0
- package/utility/functions.d.ts +7 -0
- package/utility/functions.lua +12 -0
- package/utility/linked-map.d.ts +35 -0
- package/utility/linked-map.lua +107 -0
- package/utility/linked-set.d.ts +4 -1
- package/utility/linked-set.lua +46 -1
- package/utility/lua-maps.d.ts +12 -2
- package/utility/lua-maps.lua +37 -2
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +4 -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 -26
- package/core/types/order.lua +0 -65
- /package/engine/internal/{object-data/armor-increase.d.ts → misc/frame-coordinates.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
|
|
36
|
+
* or until startup selection-frame initialization has finished.
|
|
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,11 @@
|
|
|
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
|
|
6
|
+
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
6
7
|
local ____exports = {}
|
|
8
|
+
local actualizeTargetingModeState
|
|
7
9
|
local ____unit = require("core.types.unit")
|
|
8
10
|
local Unit = ____unit.Unit
|
|
9
11
|
local ____event = require("event")
|
|
@@ -15,32 +17,140 @@ local ____player = require("core.types.player")
|
|
|
15
17
|
local Player = ____player.Player
|
|
16
18
|
local ____timer = require("core.types.timer")
|
|
17
19
|
local Timer = ____timer.Timer
|
|
18
|
-
local
|
|
19
|
-
local
|
|
20
|
-
local
|
|
21
|
-
local
|
|
22
|
-
local
|
|
20
|
+
local ____color = require("core.types.color")
|
|
21
|
+
local Color = ____color.Color
|
|
22
|
+
local ____arrays = require("utility.arrays")
|
|
23
|
+
local array = ____arrays.array
|
|
24
|
+
local ____unit = require("objutil.unit")
|
|
25
|
+
local UnitDefinition = ____unit.UnitDefinition
|
|
26
|
+
local ____socket = require("net.socket")
|
|
27
|
+
local Socket = ____socket.Socket
|
|
28
|
+
local frameGetChild = BlzFrameGetChild
|
|
29
|
+
local frameGetChildrenCount = BlzFrameGetChildrenCount
|
|
30
|
+
local frameGetParent = BlzFrameGetParent
|
|
31
|
+
local frameToPixelX = BlzFrameToPixelX
|
|
32
|
+
local frameToPixelY = BlzFrameToPixelY
|
|
33
|
+
local getFrameByName = BlzGetFrameByName
|
|
23
34
|
local getHandleId = GetHandleId
|
|
35
|
+
local getLocalClientHeight = BlzGetLocalClientHeight
|
|
36
|
+
local getLocalClientWidth = BlzGetLocalClientWidth
|
|
37
|
+
local getLocale = BlzGetLocale
|
|
24
38
|
local getMouseFocusUnit = BlzGetMouseFocusUnit
|
|
39
|
+
local getMouseScreenPosX = BlzGetMouseScreenPosX
|
|
40
|
+
local getMouseScreenPosY = BlzGetMouseScreenPosY
|
|
25
41
|
local getUnitRealField = BlzGetUnitRealField
|
|
26
42
|
local getUnitTypeId = GetUnitTypeId
|
|
27
|
-
local
|
|
43
|
+
local isHeroUnitId = IsHeroUnitId
|
|
44
|
+
local isKeyPressed = BlzIsKeyPressed
|
|
45
|
+
local isLocalClientActive = BlzIsLocalClientActive
|
|
46
|
+
local isMetaKeyPressed = BlzIsMetaKeyPressed
|
|
47
|
+
local isMouseButtonPressed = BlzIsMouseButtonPressed
|
|
48
|
+
local loadTOCFile = BlzLoadTOCFile
|
|
49
|
+
local location = Location
|
|
50
|
+
local pingMinimap = PingMinimap
|
|
51
|
+
local pingMinimapEx = PingMinimapEx
|
|
52
|
+
local pixelToFrameX = BlzPixelToFrameX
|
|
53
|
+
local pixelToFrameY = BlzPixelToFrameY
|
|
28
54
|
local tableSort = table.sort
|
|
29
|
-
local
|
|
55
|
+
local hdTocPath = "_warscript\\IsHD.toc"
|
|
56
|
+
local deTocPath = "_warscript\\IsDE.toc"
|
|
30
57
|
compiletime(function()
|
|
31
58
|
if currentMap then
|
|
32
|
-
local
|
|
33
|
-
currentMap:addFileString("_HD.w3mod\\" ..
|
|
34
|
-
currentMap:addFileString("_HD.w3mod\\" ..
|
|
59
|
+
local hdFdfPath = "_warscript\\IsHD.fdf"
|
|
60
|
+
currentMap:addFileString("_HD.w3mod\\" .. hdFdfPath, "\r\n")
|
|
61
|
+
currentMap:addFileString("_HD.w3mod\\" .. hdTocPath, hdFdfPath .. "\r\n")
|
|
62
|
+
local deFdfPath = "_warscript\\IsDE.fdf"
|
|
63
|
+
currentMap:addFileString("_DE.w3mod\\" .. deFdfPath, "\r\n")
|
|
64
|
+
currentMap:addFileString("_DE.w3mod\\" .. deTocPath, deFdfPath .. "\r\n")
|
|
35
65
|
end
|
|
36
66
|
end)
|
|
37
|
-
local
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
67
|
+
local selectionWarmupUnitTypeId = compiletime(function()
|
|
68
|
+
local dummy = __TS__New(UnitDefinition, "hfoo", nil, {
|
|
69
|
+
name = "[Warscript/Selection Warmup] Unit",
|
|
70
|
+
model = "",
|
|
71
|
+
modelHD = "",
|
|
72
|
+
foodCost = 0,
|
|
73
|
+
movementType = "none",
|
|
74
|
+
collisionSize = 0,
|
|
75
|
+
selectionScale = 0,
|
|
76
|
+
sightRadiusDay = 0,
|
|
77
|
+
sightRadiusNight = 0,
|
|
78
|
+
abilitiesNormal = {"Avul"}
|
|
79
|
+
})
|
|
80
|
+
dummy.weapons[1].enabled = false
|
|
81
|
+
dummy.weapons[2].enabled = false
|
|
82
|
+
return fourCC(dummy.id)
|
|
43
83
|
end)
|
|
84
|
+
local SELECTION_DETAIL_FRAME_NAME = "SimpleInfoPanelUnitDetail"
|
|
85
|
+
local SELECTION_GROUP_PANEL_INDEX = 5
|
|
86
|
+
local SELECTION_BUTTON_ICON_INDEX = 1
|
|
87
|
+
--- The detail panel, its parent, the group panel and the button grid.
|
|
88
|
+
local SELECTION_LAYOUT_ROOT_HANDLE_COUNT = 4
|
|
89
|
+
--- The group selection layouts by button count, in the order the startup warmup goes through them.
|
|
90
|
+
local SELECTION_LAYOUT_BUTTON_COUNTS = {24, 12}
|
|
91
|
+
local function getSelectionButtons()
|
|
92
|
+
return Frame:byName(SELECTION_DETAIL_FRAME_NAME).parent:getChild(SELECTION_GROUP_PANEL_INDEX):getChild(0)
|
|
93
|
+
end
|
|
94
|
+
local function getMainSelectedUnitIndex(selectionButtons, buttonCount)
|
|
95
|
+
local mainSelectedUnitIndex
|
|
96
|
+
local maxButtonWidth = 0
|
|
97
|
+
for i = 0, buttonCount - 1 do
|
|
98
|
+
local width = selectionButtons:getChild(i):getChild(SELECTION_BUTTON_ICON_INDEX).width
|
|
99
|
+
if width > maxButtonWidth then
|
|
100
|
+
maxButtonWidth = width
|
|
101
|
+
mainSelectedUnitIndex = i
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
return mainSelectedUnitIndex
|
|
105
|
+
end
|
|
106
|
+
local function getChildIfPresent(parent, index)
|
|
107
|
+
if parent == nil or index >= frameGetChildrenCount(parent) then
|
|
108
|
+
return nil
|
|
109
|
+
end
|
|
110
|
+
return frameGetChild(parent, index)
|
|
111
|
+
end
|
|
112
|
+
--- Wraps every frame of the group selection layout currently shown on this client, in the
|
|
113
|
+
-- order `actualizeMainSelectedUnit` later walks them. Game-owned frames receive a JASS handle
|
|
114
|
+
-- id the first time a script retrieves them, so this must run on every client in the same
|
|
115
|
+
-- tick and register the same number of handles everywhere: every frame reached for the first
|
|
116
|
+
-- time counts, and the remainder up to the layout's total is padded with locations, the way
|
|
117
|
+
-- `Frame.byOrigin` balances origin frames that appear asynchronously.
|
|
118
|
+
--
|
|
119
|
+
-- Returns whether the local layout has `buttonCount` buttons and every frame was reached.
|
|
120
|
+
local function registerSelectionLayoutFrames(buttonCount)
|
|
121
|
+
local registeredCount = 0
|
|
122
|
+
local function register(handle)
|
|
123
|
+
if handle == nil or getHandleId(handle) == 0 then
|
|
124
|
+
return nil
|
|
125
|
+
end
|
|
126
|
+
if not Frame:isWrapped(handle) then
|
|
127
|
+
registeredCount = registeredCount + 1
|
|
128
|
+
end
|
|
129
|
+
Frame:of(handle)
|
|
130
|
+
return handle
|
|
131
|
+
end
|
|
132
|
+
local detail = register(getFrameByName(SELECTION_DETAIL_FRAME_NAME, 0))
|
|
133
|
+
local container = register(detail ~= nil and frameGetParent(detail) or nil)
|
|
134
|
+
local groupPanel = register(getChildIfPresent(container, SELECTION_GROUP_PANEL_INDEX))
|
|
135
|
+
local grid = register(getChildIfPresent(groupPanel, 0))
|
|
136
|
+
local complete = grid ~= nil and frameGetChildrenCount(grid) == buttonCount
|
|
137
|
+
for i = 0, buttonCount - 1 do
|
|
138
|
+
local button = register(getChildIfPresent(grid, i))
|
|
139
|
+
local icon = register(getChildIfPresent(button, SELECTION_BUTTON_ICON_INDEX))
|
|
140
|
+
if icon == nil then
|
|
141
|
+
complete = false
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
local totalHandleCount = SELECTION_LAYOUT_ROOT_HANDLE_COUNT + 2 * buttonCount
|
|
145
|
+
do
|
|
146
|
+
local i = registeredCount
|
|
147
|
+
while i < totalHandleCount do
|
|
148
|
+
location(0, 0)
|
|
149
|
+
i = i + 1
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
return complete
|
|
153
|
+
end
|
|
44
154
|
local localSelectedUnits = {}
|
|
45
155
|
local indexByLocalSelectedUnit = {}
|
|
46
156
|
local function compareUnitsSelectionPriority(a, b)
|
|
@@ -57,11 +167,62 @@ local function compareUnitsSelectionPriority(a, b)
|
|
|
57
167
|
end
|
|
58
168
|
local mainSelectedUnitChangeEvent
|
|
59
169
|
local previousMainSelectedUnit
|
|
170
|
+
local currentMainSelectedUnit
|
|
171
|
+
local lastTargetingModeState = false
|
|
172
|
+
local targetingModeEnterEvent = __TS__New(Event)
|
|
173
|
+
local targetingModeLeaveEvent = __TS__New(Event)
|
|
174
|
+
local targetingModeStateChangeEvent = __TS__New(Event)
|
|
60
175
|
____exports.LocalClient = __TS__Class()
|
|
61
176
|
local LocalClient = ____exports.LocalClient
|
|
62
177
|
LocalClient.name = "LocalClient"
|
|
63
178
|
function LocalClient.prototype.____constructor(self)
|
|
64
179
|
end
|
|
180
|
+
function LocalClient.pingMinimap(self, x, y, duration, redOrColor, greenOrFlashy, blue, flashy)
|
|
181
|
+
if redOrColor == nil then
|
|
182
|
+
pingMinimap(x, y, duration)
|
|
183
|
+
elseif __TS__InstanceOf(redOrColor, Color) then
|
|
184
|
+
pingMinimapEx(
|
|
185
|
+
x,
|
|
186
|
+
y,
|
|
187
|
+
duration,
|
|
188
|
+
redOrColor.r,
|
|
189
|
+
redOrColor.g,
|
|
190
|
+
redOrColor.b,
|
|
191
|
+
greenOrFlashy or false
|
|
192
|
+
)
|
|
193
|
+
else
|
|
194
|
+
pingMinimapEx(
|
|
195
|
+
x,
|
|
196
|
+
y,
|
|
197
|
+
duration,
|
|
198
|
+
redOrColor,
|
|
199
|
+
greenOrFlashy,
|
|
200
|
+
blue,
|
|
201
|
+
flashy or false
|
|
202
|
+
)
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
function LocalClient.isKeyPressed(self, key)
|
|
206
|
+
return isKeyPressed(key)
|
|
207
|
+
end
|
|
208
|
+
function LocalClient.isMetaKeyPressed(self, key)
|
|
209
|
+
return isMetaKeyPressed(key)
|
|
210
|
+
end
|
|
211
|
+
function LocalClient.isMouseButtonPressed(self, button)
|
|
212
|
+
return isMouseButtonPressed(button)
|
|
213
|
+
end
|
|
214
|
+
function LocalClient.screenToFrameX(self, x)
|
|
215
|
+
return pixelToFrameX(x)
|
|
216
|
+
end
|
|
217
|
+
function LocalClient.screenToFrameY(self, y)
|
|
218
|
+
return pixelToFrameY(y)
|
|
219
|
+
end
|
|
220
|
+
function LocalClient.frameToScreenX(self, x)
|
|
221
|
+
return frameToPixelX(x)
|
|
222
|
+
end
|
|
223
|
+
function LocalClient.frameToScreenY(self, y)
|
|
224
|
+
return frameToPixelY(y)
|
|
225
|
+
end
|
|
65
226
|
LocalClient.locale = getLocale()
|
|
66
227
|
__TS__ObjectDefineProperty(
|
|
67
228
|
LocalClient,
|
|
@@ -77,6 +238,13 @@ __TS__ObjectDefineProperty(
|
|
|
77
238
|
return getLocalClientHeight()
|
|
78
239
|
end}
|
|
79
240
|
)
|
|
241
|
+
__TS__ObjectDefineProperty(
|
|
242
|
+
LocalClient,
|
|
243
|
+
"isSD",
|
|
244
|
+
{get = function(self)
|
|
245
|
+
return true
|
|
246
|
+
end}
|
|
247
|
+
)
|
|
80
248
|
__TS__ObjectDefineProperty(
|
|
81
249
|
LocalClient,
|
|
82
250
|
"isHD",
|
|
@@ -84,11 +252,18 @@ __TS__ObjectDefineProperty(
|
|
|
84
252
|
return false
|
|
85
253
|
end}
|
|
86
254
|
)
|
|
255
|
+
__TS__ObjectDefineProperty(
|
|
256
|
+
LocalClient,
|
|
257
|
+
"isDE",
|
|
258
|
+
{get = function(self)
|
|
259
|
+
return false
|
|
260
|
+
end}
|
|
261
|
+
)
|
|
87
262
|
__TS__ObjectDefineProperty(
|
|
88
263
|
LocalClient,
|
|
89
264
|
"graphicsMode",
|
|
90
265
|
{get = function(self)
|
|
91
|
-
return
|
|
266
|
+
return 0
|
|
92
267
|
end}
|
|
93
268
|
)
|
|
94
269
|
__TS__ObjectDefineProperty(
|
|
@@ -98,6 +273,41 @@ __TS__ObjectDefineProperty(
|
|
|
98
273
|
return isLocalClientActive()
|
|
99
274
|
end}
|
|
100
275
|
)
|
|
276
|
+
__TS__ObjectDefineProperty(
|
|
277
|
+
LocalClient,
|
|
278
|
+
"isMinimized",
|
|
279
|
+
{get = function(self)
|
|
280
|
+
return getLocalClientHeight() == 0
|
|
281
|
+
end}
|
|
282
|
+
)
|
|
283
|
+
__TS__ObjectDefineProperty(
|
|
284
|
+
LocalClient,
|
|
285
|
+
"mouseScreenX",
|
|
286
|
+
{get = function(self)
|
|
287
|
+
return getMouseScreenPosX()
|
|
288
|
+
end}
|
|
289
|
+
)
|
|
290
|
+
__TS__ObjectDefineProperty(
|
|
291
|
+
LocalClient,
|
|
292
|
+
"mouseScreenY",
|
|
293
|
+
{get = function(self)
|
|
294
|
+
return getMouseScreenPosY()
|
|
295
|
+
end}
|
|
296
|
+
)
|
|
297
|
+
__TS__ObjectDefineProperty(
|
|
298
|
+
LocalClient,
|
|
299
|
+
"mouseFrameX",
|
|
300
|
+
{get = function(self)
|
|
301
|
+
return pixelToFrameX(getMouseScreenPosX())
|
|
302
|
+
end}
|
|
303
|
+
)
|
|
304
|
+
__TS__ObjectDefineProperty(
|
|
305
|
+
LocalClient,
|
|
306
|
+
"mouseFrameY",
|
|
307
|
+
{get = function(self)
|
|
308
|
+
return pixelToFrameY(getMouseScreenPosY())
|
|
309
|
+
end}
|
|
310
|
+
)
|
|
101
311
|
__TS__ObjectDefineProperty(
|
|
102
312
|
LocalClient,
|
|
103
313
|
"mouseFocusUnit",
|
|
@@ -109,33 +319,7 @@ __TS__ObjectDefineProperty(
|
|
|
109
319
|
LocalClient,
|
|
110
320
|
"mainSelectedUnit",
|
|
111
321
|
{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
|
|
322
|
+
return currentMainSelectedUnit
|
|
139
323
|
end}
|
|
140
324
|
)
|
|
141
325
|
__TS__ObjectDefineProperty(
|
|
@@ -144,13 +328,20 @@ __TS__ObjectDefineProperty(
|
|
|
144
328
|
{get = function(self)
|
|
145
329
|
if mainSelectedUnitChangeEvent == nil then
|
|
146
330
|
mainSelectedUnitChangeEvent = __TS__New(Event)
|
|
147
|
-
Timer.onPeriod[1 / 64]:addListener(function()
|
|
148
|
-
local _ = ____exports.LocalClient.mainSelectedUnit
|
|
149
|
-
end)
|
|
150
331
|
end
|
|
151
332
|
return mainSelectedUnitChangeEvent
|
|
152
333
|
end}
|
|
153
334
|
)
|
|
335
|
+
__TS__ObjectDefineProperty(
|
|
336
|
+
LocalClient,
|
|
337
|
+
"isInTargetingMode",
|
|
338
|
+
{get = function(self)
|
|
339
|
+
return actualizeTargetingModeState()
|
|
340
|
+
end}
|
|
341
|
+
)
|
|
342
|
+
LocalClient.targetingModeEnterEvent = targetingModeEnterEvent
|
|
343
|
+
LocalClient.targetingModeLeaveEvent = targetingModeLeaveEvent
|
|
344
|
+
LocalClient.targetingModeStateChangeEvent = targetingModeStateChangeEvent
|
|
154
345
|
LocalClient.onDisconnect = __TS__New(
|
|
155
346
|
TriggerEvent,
|
|
156
347
|
function(trigger)
|
|
@@ -158,11 +349,284 @@ LocalClient.onDisconnect = __TS__New(
|
|
|
158
349
|
end,
|
|
159
350
|
function() return end
|
|
160
351
|
)
|
|
352
|
+
local function actualizeMainSelectedUnit()
|
|
353
|
+
Unit:getSelectionOf(Player["local"], localSelectedUnits)
|
|
354
|
+
for i = 1, #localSelectedUnits do
|
|
355
|
+
indexByLocalSelectedUnit[localSelectedUnits[i]] = i
|
|
356
|
+
end
|
|
357
|
+
tableSort(localSelectedUnits, compareUnitsSelectionPriority)
|
|
358
|
+
local mainSelectedUnitIndex
|
|
359
|
+
if #localSelectedUnits > 1 then
|
|
360
|
+
local selectionButtons = getSelectionButtons()
|
|
361
|
+
mainSelectedUnitIndex = getMainSelectedUnitIndex(
|
|
362
|
+
selectionButtons,
|
|
363
|
+
selectionButtons:getChildrenCount()
|
|
364
|
+
)
|
|
365
|
+
end
|
|
366
|
+
local mainSelectedUnit = localSelectedUnits[(#localSelectedUnits > 1 and (mainSelectedUnitIndex or 0) or 0) + 1]
|
|
367
|
+
for i = 1, #localSelectedUnits do
|
|
368
|
+
indexByLocalSelectedUnit[localSelectedUnits[i]] = nil
|
|
369
|
+
localSelectedUnits[i] = nil
|
|
370
|
+
end
|
|
371
|
+
currentMainSelectedUnit = mainSelectedUnit
|
|
372
|
+
if mainSelectedUnitChangeEvent ~= nil and mainSelectedUnit ~= previousMainSelectedUnit then
|
|
373
|
+
local previousPreviousMainSelectedUnit = previousMainSelectedUnit
|
|
374
|
+
previousMainSelectedUnit = mainSelectedUnit
|
|
375
|
+
Event.invoke(mainSelectedUnitChangeEvent, previousPreviousMainSelectedUnit, previousMainSelectedUnit)
|
|
376
|
+
end
|
|
377
|
+
end
|
|
378
|
+
local commandButtons = array(
|
|
379
|
+
12,
|
|
380
|
+
function(i) return Frame:byOrigin(ORIGIN_FRAME_COMMAND_BUTTON, i) end
|
|
381
|
+
)
|
|
382
|
+
local function getTargetingModeState()
|
|
383
|
+
for i = 0, 10 do
|
|
384
|
+
if commandButtons[i + 1].visible then
|
|
385
|
+
return false
|
|
386
|
+
end
|
|
387
|
+
end
|
|
388
|
+
return commandButtons[12].visible
|
|
389
|
+
end
|
|
390
|
+
actualizeTargetingModeState = function()
|
|
391
|
+
if getTargetingModeState() then
|
|
392
|
+
if not lastTargetingModeState then
|
|
393
|
+
lastTargetingModeState = true
|
|
394
|
+
Event.invoke(targetingModeEnterEvent)
|
|
395
|
+
Event.invoke(targetingModeStateChangeEvent)
|
|
396
|
+
end
|
|
397
|
+
return true
|
|
398
|
+
end
|
|
399
|
+
if lastTargetingModeState then
|
|
400
|
+
lastTargetingModeState = false
|
|
401
|
+
Event.invoke(targetingModeLeaveEvent)
|
|
402
|
+
Event.invoke(targetingModeStateChangeEvent)
|
|
403
|
+
end
|
|
404
|
+
return false
|
|
405
|
+
end
|
|
406
|
+
Timer.onPeriod[1 / 64]:addListener(function()
|
|
407
|
+
actualizeTargetingModeState()
|
|
408
|
+
end)
|
|
409
|
+
local function initializeSelectionFrames()
|
|
410
|
+
local checkProgress, registerStage, checkRegistration, onMessage, onPlayerLeave, observeSelection, retryTimer
|
|
411
|
+
local warmups = {}
|
|
412
|
+
local warmupByPlayer = {}
|
|
413
|
+
local dummyUnits = {}
|
|
414
|
+
local socket = __TS__New(Socket)
|
|
415
|
+
local stageIndex = 0
|
|
416
|
+
local round = 0
|
|
417
|
+
local registering = false
|
|
418
|
+
--- The round whose frames this client has registered.
|
|
419
|
+
local registeredRound = 0
|
|
420
|
+
local finished = false
|
|
421
|
+
local sentSeenRound = 0
|
|
422
|
+
local seenMessage = ""
|
|
423
|
+
local registeredMessage = ""
|
|
424
|
+
local failedMessage = ""
|
|
425
|
+
local function getStageButtonCount()
|
|
426
|
+
return SELECTION_LAYOUT_BUTTON_COUNTS[stageIndex + 1]
|
|
427
|
+
end
|
|
428
|
+
local function retrySelection()
|
|
429
|
+
local count = getStageButtonCount()
|
|
430
|
+
for ____, warmup in ipairs(warmups) do
|
|
431
|
+
do
|
|
432
|
+
if not warmup.player.isPlaying then
|
|
433
|
+
goto __continue69
|
|
434
|
+
end
|
|
435
|
+
if warmup.player == Player["local"] then
|
|
436
|
+
local selection = Unit:getSelectionOf(Player["local"])
|
|
437
|
+
local normalSelection = __TS__ArrayFilter(
|
|
438
|
+
selection,
|
|
439
|
+
function(____, unit) return not (dummyUnits[unit] ~= nil) end
|
|
440
|
+
)
|
|
441
|
+
if #normalSelection > 0 or #selection == 0 then
|
|
442
|
+
warmup.previousSelection = normalSelection
|
|
443
|
+
end
|
|
444
|
+
end
|
|
445
|
+
warmup.player:clearSelection()
|
|
446
|
+
for i = 0, count - 1 do
|
|
447
|
+
warmup.player:select(warmup.units[i + 1])
|
|
448
|
+
end
|
|
449
|
+
end
|
|
450
|
+
::__continue69::
|
|
451
|
+
end
|
|
452
|
+
end
|
|
453
|
+
local function startRound()
|
|
454
|
+
round = round + 1
|
|
455
|
+
registering = false
|
|
456
|
+
local count = getStageButtonCount()
|
|
457
|
+
seenMessage = "seen" .. tostring(count)
|
|
458
|
+
registeredMessage = "registered" .. tostring(count)
|
|
459
|
+
failedMessage = "failed" .. tostring(count)
|
|
460
|
+
retrySelection()
|
|
461
|
+
checkProgress()
|
|
462
|
+
end
|
|
463
|
+
local function finish()
|
|
464
|
+
finished = true
|
|
465
|
+
retryTimer:destroy()
|
|
466
|
+
Timer.onPeriod[1 / 64]:removeListener(observeSelection)
|
|
467
|
+
socket.onMessage:removeListener(onMessage)
|
|
468
|
+
Player.onLeave:removeListener(onPlayerLeave)
|
|
469
|
+
local restoreSelection
|
|
470
|
+
local selection = Unit:getSelectionOf(Player["local"])
|
|
471
|
+
for ____, unit in ipairs(selection) do
|
|
472
|
+
if dummyUnits[unit] ~= nil then
|
|
473
|
+
restoreSelection = __TS__ArrayFilter(
|
|
474
|
+
selection,
|
|
475
|
+
function(____, selected) return not (dummyUnits[selected] ~= nil) end
|
|
476
|
+
)
|
|
477
|
+
if #restoreSelection == 0 then
|
|
478
|
+
local ____opt_0 = warmupByPlayer[Player["local"]]
|
|
479
|
+
restoreSelection = ____opt_0 and ____opt_0.previousSelection
|
|
480
|
+
end
|
|
481
|
+
Player["local"]:clearSelection()
|
|
482
|
+
break
|
|
483
|
+
end
|
|
484
|
+
end
|
|
485
|
+
for ____, warmup in ipairs(warmups) do
|
|
486
|
+
for ____, unit in ipairs(warmup.units) do
|
|
487
|
+
unit:destroy()
|
|
488
|
+
end
|
|
489
|
+
warmup.units = {}
|
|
490
|
+
end
|
|
491
|
+
if restoreSelection ~= nil then
|
|
492
|
+
for ____, unit in ipairs(restoreSelection) do
|
|
493
|
+
if getUnitTypeId(unit.handle) ~= 0 then
|
|
494
|
+
Player["local"]:select(unit)
|
|
495
|
+
end
|
|
496
|
+
end
|
|
497
|
+
end
|
|
498
|
+
Timer.onPeriod[1 / 64]:addListener(actualizeMainSelectedUnit)
|
|
499
|
+
end
|
|
500
|
+
checkProgress = function()
|
|
501
|
+
if finished or registering then
|
|
502
|
+
return
|
|
503
|
+
end
|
|
504
|
+
for ____, warmup in ipairs(warmups) do
|
|
505
|
+
if warmup.player.isPlaying and warmup.seenRound ~= round then
|
|
506
|
+
return
|
|
507
|
+
end
|
|
508
|
+
end
|
|
509
|
+
registering = true
|
|
510
|
+
Timer:simple(1 / 64, registerStage)
|
|
511
|
+
end
|
|
512
|
+
registerStage = function()
|
|
513
|
+
if finished then
|
|
514
|
+
return
|
|
515
|
+
end
|
|
516
|
+
registeredRound = round
|
|
517
|
+
local succeeded = registerSelectionLayoutFrames(getStageButtonCount())
|
|
518
|
+
if warmupByPlayer[Player["local"]] ~= nil and Player["local"].isPlaying then
|
|
519
|
+
socket:send(succeeded and registeredMessage or failedMessage)
|
|
520
|
+
end
|
|
521
|
+
checkRegistration()
|
|
522
|
+
end
|
|
523
|
+
checkRegistration = function()
|
|
524
|
+
if finished or not registering then
|
|
525
|
+
return
|
|
526
|
+
end
|
|
527
|
+
local succeeded = true
|
|
528
|
+
for ____, warmup in ipairs(warmups) do
|
|
529
|
+
do
|
|
530
|
+
if not warmup.player.isPlaying then
|
|
531
|
+
goto __continue101
|
|
532
|
+
end
|
|
533
|
+
if warmup.registrationRound ~= round then
|
|
534
|
+
return
|
|
535
|
+
end
|
|
536
|
+
if not warmup.registrationSucceeded then
|
|
537
|
+
succeeded = false
|
|
538
|
+
end
|
|
539
|
+
end
|
|
540
|
+
::__continue101::
|
|
541
|
+
end
|
|
542
|
+
if not succeeded then
|
|
543
|
+
startRound()
|
|
544
|
+
return
|
|
545
|
+
end
|
|
546
|
+
if stageIndex + 1 >= #SELECTION_LAYOUT_BUTTON_COUNTS then
|
|
547
|
+
finish()
|
|
548
|
+
return
|
|
549
|
+
end
|
|
550
|
+
stageIndex = stageIndex + 1
|
|
551
|
+
local count = getStageButtonCount()
|
|
552
|
+
for ____, warmup in ipairs(warmups) do
|
|
553
|
+
for i = #warmup.units - 1, count, -1 do
|
|
554
|
+
warmup.units[i + 1]:destroy()
|
|
555
|
+
warmup.units[i + 1] = nil
|
|
556
|
+
end
|
|
557
|
+
end
|
|
558
|
+
startRound()
|
|
559
|
+
end
|
|
560
|
+
onMessage = function(player, message)
|
|
561
|
+
local warmup = warmupByPlayer[player]
|
|
562
|
+
if warmup == nil or not player.isPlaying then
|
|
563
|
+
return
|
|
564
|
+
end
|
|
565
|
+
if message == seenMessage then
|
|
566
|
+
warmup.seenRound = round
|
|
567
|
+
checkProgress()
|
|
568
|
+
elseif (message == registeredMessage or message == failedMessage) and registeredRound == round then
|
|
569
|
+
warmup.registrationRound = round
|
|
570
|
+
warmup.registrationSucceeded = message == registeredMessage
|
|
571
|
+
checkRegistration()
|
|
572
|
+
end
|
|
573
|
+
end
|
|
574
|
+
onPlayerLeave = function()
|
|
575
|
+
checkProgress()
|
|
576
|
+
checkRegistration()
|
|
577
|
+
end
|
|
578
|
+
observeSelection = function()
|
|
579
|
+
if sentSeenRound == round or not (warmupByPlayer[Player["local"]] ~= nil) or not Player["local"].isPlaying then
|
|
580
|
+
return
|
|
581
|
+
end
|
|
582
|
+
local localSelectionCount = #Unit:getSelectionOf(Player["local"])
|
|
583
|
+
local maximumCount = getStageButtonCount()
|
|
584
|
+
local minimumCount = maximumCount == 12 and 2 or 13
|
|
585
|
+
if localSelectionCount >= minimumCount and localSelectionCount <= maximumCount then
|
|
586
|
+
socket:send(seenMessage)
|
|
587
|
+
sentSeenRound = round
|
|
588
|
+
end
|
|
589
|
+
end
|
|
590
|
+
for ____, player in ipairs(Player.all) do
|
|
591
|
+
if player.isUser and player.isPlaying then
|
|
592
|
+
local warmup = {
|
|
593
|
+
player = player,
|
|
594
|
+
units = {},
|
|
595
|
+
previousSelection = player == Player["local"] and Unit:getSelectionOf(player) or ({}),
|
|
596
|
+
seenRound = 0,
|
|
597
|
+
registrationRound = 0,
|
|
598
|
+
registrationSucceeded = false
|
|
599
|
+
}
|
|
600
|
+
warmups[#warmups + 1] = warmup
|
|
601
|
+
warmupByPlayer[player] = warmup
|
|
602
|
+
for i = 0, SELECTION_LAYOUT_BUTTON_COUNTS[1] - 1 do
|
|
603
|
+
local unit = assert(Unit:create(
|
|
604
|
+
player,
|
|
605
|
+
selectionWarmupUnitTypeId,
|
|
606
|
+
0,
|
|
607
|
+
0,
|
|
608
|
+
0
|
|
609
|
+
))
|
|
610
|
+
unit.isPaused = true
|
|
611
|
+
warmup.units[i + 1] = unit
|
|
612
|
+
dummyUnits[unit] = true
|
|
613
|
+
end
|
|
614
|
+
end
|
|
615
|
+
end
|
|
616
|
+
socket.onMessage:addListener(onMessage)
|
|
617
|
+
Player.onLeave:addListener(onPlayerLeave)
|
|
618
|
+
Timer.onPeriod[1 / 64]:addListener(observeSelection)
|
|
619
|
+
retryTimer = Timer:periodic(1, retrySelection)
|
|
620
|
+
startRound()
|
|
621
|
+
observeSelection()
|
|
622
|
+
end
|
|
161
623
|
warpack.afterMapInit(function()
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
)
|
|
624
|
+
local isDE = loadTOCFile(deTocPath)
|
|
625
|
+
local isHD = not isDE and loadTOCFile(hdTocPath)
|
|
626
|
+
rawset(____exports.LocalClient, "isDE", isDE)
|
|
627
|
+
rawset(____exports.LocalClient, "isHD", isHD)
|
|
628
|
+
rawset(____exports.LocalClient, "isSD", not isDE and not isHD)
|
|
629
|
+
rawset(____exports.LocalClient, "graphicsMode", isDE and 2 or (isHD and 1 or 0))
|
|
167
630
|
end)
|
|
631
|
+
Timer:run(initializeSelectionFrames)
|
|
168
632
|
return ____exports
|