warscript 0.0.1-dev.cc63edd → 0.0.1-dev.ccc2b77
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 +0 -1
- package/binaryreader.d.ts +1 -0
- package/binaryreader.lua +3 -0
- package/core/types/frame.d.ts +5 -1
- package/core/types/frame.lua +34 -1
- package/core/types/group.d.ts +0 -1
- package/core/types/image.d.ts +0 -1
- package/core/types/unit.lua +8 -0
- package/core/util.d.ts +1 -1
- package/core/util.lua +6 -0
- package/decl/index.d.ts +1 -0
- package/engine/ability.d.ts +1 -1
- package/engine/behavior.d.ts +10 -10
- package/engine/behavior.lua +6 -6
- package/engine/behaviour/ability/apply-buff.d.ts +3 -5
- package/engine/behaviour/ability/apply-unit-behavior.d.ts +6 -1
- package/engine/behaviour/ability/damage.d.ts +33 -11
- package/engine/behaviour/ability/damage.lua +89 -31
- package/engine/behaviour/ability/heal.d.ts +33 -6
- package/engine/behaviour/ability/heal.lua +89 -10
- package/engine/behaviour/ability/restore-mana.d.ts +15 -0
- package/engine/behaviour/ability/restore-mana.lua +29 -0
- package/engine/behaviour/unit/stun-immunity.d.ts +0 -1
- package/engine/behaviour/unit.d.ts +8 -2
- package/engine/behaviour/unit.lua +27 -0
- package/engine/buff.d.ts +62 -20
- package/engine/buff.lua +247 -72
- package/engine/game-map.d.ts +7 -0
- package/engine/game-map.lua +32 -0
- package/engine/internal/ability.d.ts +1 -11
- package/engine/internal/ability.lua +2 -78
- package/engine/internal/item+owner.lua +2 -2
- package/engine/internal/unit/bonus.d.ts +9 -8
- package/engine/internal/unit/bonus.lua +6 -1
- package/engine/internal/unit/item.d.ts +23 -0
- package/engine/internal/unit/item.lua +74 -0
- package/engine/internal/unit+ability.lua +2 -2
- package/engine/internal/unit+transport.lua +4 -10
- package/engine/internal/unit-missile-launch.lua +24 -5
- package/engine/internal/unit.d.ts +7 -6
- package/engine/internal/unit.lua +50 -33
- package/engine/local-client.d.ts +7 -2
- package/engine/local-client.lua +81 -0
- package/engine/object-data/auxiliary/attachment-preset.d.ts +0 -1
- package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
- package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
- package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
- package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
- package/engine/object-data/entry/ability-type.d.ts +0 -1
- package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
- package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
- package/engine/object-data/entry/buff-type.d.ts +0 -1
- package/engine/object-data/entry/destructible-type.d.ts +0 -1
- package/engine/object-data/entry/item-type/blank.d.ts +0 -1
- package/engine/object-data/entry/item-type.d.ts +12 -1
- package/engine/object-data/entry/item-type.lua +78 -0
- package/engine/object-data/entry/lightning-type.d.ts +0 -1
- package/engine/object-data/entry/unit-type.d.ts +0 -1
- package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
- package/engine/object-data/entry/upgrade.d.ts +0 -1
- package/engine/object-data/entry.d.ts +2 -3
- package/engine/object-field/ability.d.ts +18 -1
- package/engine/object-field/ability.lua +51 -1
- package/engine/object-field.d.ts +0 -1
- package/engine/random.d.ts +1 -0
- package/engine/random.lua +9 -0
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +10 -2
- package/event.d.ts +2 -3
- package/event.lua +9 -5
- package/index.d.ts +1 -0
- package/index.lua +1 -0
- package/lualib_bundle.lua +146 -42
- package/math/vec2.d.ts +2 -9
- package/math.d.ts +0 -2
- package/net/socket.d.ts +7 -1
- package/net/socket.lua +45 -4
- package/network.d.ts +1 -0
- package/network.lua +3 -2
- package/objutil/ability.d.ts +0 -1
- package/objutil/buff.d.ts +0 -1
- package/objutil/buff.lua +1 -1
- package/objutil/object.d.ts +0 -1
- package/objutil/unit.d.ts +0 -1
- package/package.json +13 -13
- package/patch-lua.d.ts +0 -0
- package/patch-lua.lua +10 -0
- package/property.d.ts +55 -0
- package/property.lua +374 -0
- package/string.d.ts +16 -0
- package/string.lua +5 -0
- package/util/stream.d.ts +0 -1
- package/utility/arrays.d.ts +3 -4
- package/utility/bit-set.d.ts +0 -2
- package/utility/linked-set.d.ts +11 -3
- package/utility/linked-set.lua +5 -2
- package/utility/lua-maps.d.ts +1 -2
- package/utility/lua-sets.d.ts +1 -2
- package/utility/types.d.ts +1 -0
- package/core/mapbounds.d.ts +0 -8
- package/core/mapbounds.lua +0 -12
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="@typescript-to-lua/language-extensions" />
|
|
2
1
|
/** @noSelfInFile */
|
|
3
2
|
import { Unit } from "../unit";
|
|
4
3
|
import { AbilityTypeId } from "../../object-data/entry/ability-type";
|
|
@@ -9,7 +8,8 @@ export type UnitBonusId<Brand extends string = any> = number & {
|
|
|
9
8
|
export type UnitArmorBonusId = UnitBonusId<"armor">;
|
|
10
9
|
export type UnitAttackSpeedFactorBonusId = UnitBonusId<"attackSpeedFactor">;
|
|
11
10
|
export type UnitMovementSpeedFactorBonusId = UnitBonusId<"movementSpeedFactor">;
|
|
12
|
-
export type
|
|
11
|
+
export type UnitAutoAttackDamageBonusId = UnitBonusId<"autoAttackDamage">;
|
|
12
|
+
export type UnitDamageFactorBonusId = UnitBonusId<"damageFactor">;
|
|
13
13
|
export type UnitReceivedDamageFactorBonusId = UnitBonusId<"receivedDamageFactor">;
|
|
14
14
|
export type UnitBonusType<Id extends UnitBonusId = UnitBonusId> = ({
|
|
15
15
|
abilityTypeId: AbilityTypeId;
|
|
@@ -31,11 +31,12 @@ export declare namespace UnitBonusType {
|
|
|
31
31
|
const ARMOR: UnitBonusType<UnitArmorBonusId>;
|
|
32
32
|
const ATTACK_SPEED_FACTOR: UnitBonusType<UnitAttackSpeedFactorBonusId>;
|
|
33
33
|
const MOVEMENT_SPEED_FACTOR: UnitBonusType<UnitAttackSpeedFactorBonusId>;
|
|
34
|
-
const
|
|
34
|
+
const AUTO_ATTACK_DAMAGE: UnitBonusType<UnitAutoAttackDamageBonusId>;
|
|
35
|
+
const DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
|
|
35
36
|
const RECEIVED_DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
|
|
36
37
|
}
|
|
37
|
-
export declare const addUnitBonus: <Id extends UnitBonusId
|
|
38
|
-
export declare const removeUnitBonus: <Id extends UnitBonusId
|
|
39
|
-
export declare const updateUnitBonus: <Id extends UnitBonusId
|
|
40
|
-
export declare const addOrUpdateOrRemoveUnitBonus: <Id extends UnitBonusId
|
|
41
|
-
export declare const getUnitBonus: <Id extends UnitBonusId
|
|
38
|
+
export declare const addUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, value: number) => Id;
|
|
39
|
+
export declare const removeUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id) => boolean;
|
|
40
|
+
export declare const updateUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id, value: number) => boolean;
|
|
41
|
+
export declare const addOrUpdateOrRemoveUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id | undefined, value: number) => Id | undefined;
|
|
42
|
+
export declare const getUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id) => number;
|
|
@@ -21,6 +21,7 @@ local AUTO_ATTACK_DAMAGE_INCREASE_DUMMY_ABILITY_TYPE_ID = ____auto_2Dattack_2Dda
|
|
|
21
21
|
local ____movement_2Dspeed_2Dincrease_2Dfactor = require("engine.internal.object-data.movement-speed-increase-factor")
|
|
22
22
|
local MOVEMENT_SPEED_INCREASE_FACTOR_ABILITY_FIELD = ____movement_2Dspeed_2Dincrease_2Dfactor.MOVEMENT_SPEED_INCREASE_FACTOR_ABILITY_FIELD
|
|
23
23
|
local MOVEMENT_SPEED_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID = ____movement_2Dspeed_2Dincrease_2Dfactor.MOVEMENT_SPEED_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID
|
|
24
|
+
local damageFactorByUnit = {}
|
|
24
25
|
local receivedDamageFactorByUnit = {}
|
|
25
26
|
____exports.UnitBonusType = {}
|
|
26
27
|
local UnitBonusType = ____exports.UnitBonusType
|
|
@@ -46,13 +47,14 @@ do
|
|
|
46
47
|
reduce = sum,
|
|
47
48
|
initialValue = 0
|
|
48
49
|
}
|
|
49
|
-
UnitBonusType.
|
|
50
|
+
UnitBonusType.AUTO_ATTACK_DAMAGE = {
|
|
50
51
|
abilityTypeId = AUTO_ATTACK_DAMAGE_INCREASE_DUMMY_ABILITY_TYPE_ID,
|
|
51
52
|
field = AUTO_ATTACK_DAMAGE_INCREASE_ABILITY_FIELD,
|
|
52
53
|
integer = false,
|
|
53
54
|
reduce = sum,
|
|
54
55
|
initialValue = 0
|
|
55
56
|
}
|
|
57
|
+
UnitBonusType.DAMAGE_FACTOR = {reduce = product, valueByUnit = damageFactorByUnit, initialValue = 1}
|
|
56
58
|
UnitBonusType.RECEIVED_DAMAGE_FACTOR = {reduce = product, valueByUnit = receivedDamageFactorByUnit, initialValue = 1}
|
|
57
59
|
end
|
|
58
60
|
local bonusesByUnitByBonusType = {}
|
|
@@ -180,6 +182,9 @@ end
|
|
|
180
182
|
Unit.onDamage:addListener(
|
|
181
183
|
4,
|
|
182
184
|
function(source, target, event)
|
|
185
|
+
if source ~= nil and damageFactorByUnit[source] ~= nil then
|
|
186
|
+
event.amount = event.amount * damageFactorByUnit[source]
|
|
187
|
+
end
|
|
183
188
|
if receivedDamageFactorByUnit[target] ~= nil then
|
|
184
189
|
event.amount = event.amount * receivedDamageFactorByUnit[target]
|
|
185
190
|
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { Item } from "../item";
|
|
3
|
+
export interface UnitItems extends ReadonlyArray<Item | undefined> {
|
|
4
|
+
readonly length: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
5
|
+
[0]: Item | undefined;
|
|
6
|
+
[1]: Item | undefined;
|
|
7
|
+
[2]: Item | undefined;
|
|
8
|
+
[3]: Item | undefined;
|
|
9
|
+
[4]: Item | undefined;
|
|
10
|
+
[5]: Item | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare class UnitItems {
|
|
13
|
+
constructor(handle: junit);
|
|
14
|
+
protected __newindex(slot: number, item: Item | undefined): void;
|
|
15
|
+
protected __index(key: string | number): unknown;
|
|
16
|
+
protected __len(): number;
|
|
17
|
+
protected __ipairs(): LuaIterator<LuaMultiReturn<[number, Item | undefined]>, junit>;
|
|
18
|
+
}
|
|
19
|
+
declare module "../unit" {
|
|
20
|
+
interface Unit {
|
|
21
|
+
readonly items: UnitItems;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
5
|
+
local ____exports = {}
|
|
6
|
+
local ____item = require("engine.internal.item")
|
|
7
|
+
local Item = ____item.Item
|
|
8
|
+
local ____unit = require("engine.internal.unit")
|
|
9
|
+
local Unit = ____unit.Unit
|
|
10
|
+
local rawset = _G.rawset
|
|
11
|
+
local ____type = _G.type
|
|
12
|
+
local isItemPowerup = IsItemPowerup
|
|
13
|
+
local setItemBooleanField = BlzSetItemBooleanField
|
|
14
|
+
local unitAddItem = UnitAddItem
|
|
15
|
+
local unitDropItemSlot = UnitDropItemSlot
|
|
16
|
+
local unitInventorySize = UnitInventorySize
|
|
17
|
+
local unitItemInSlot = UnitItemInSlot
|
|
18
|
+
local unitRemoveItemFromSlot = UnitRemoveItemFromSlot
|
|
19
|
+
local handleByUnitItems = setmetatable({}, {__mode = "k"})
|
|
20
|
+
local function unitItemsNext(handle, index)
|
|
21
|
+
local slot = index & 7
|
|
22
|
+
if index >> 3 == slot then
|
|
23
|
+
return nil, nil
|
|
24
|
+
end
|
|
25
|
+
return index + 1, Item:of(unitItemInSlot(handle, slot))
|
|
26
|
+
end
|
|
27
|
+
____exports.UnitItems = __TS__Class()
|
|
28
|
+
local UnitItems = ____exports.UnitItems
|
|
29
|
+
UnitItems.name = "UnitItems"
|
|
30
|
+
function UnitItems.prototype.____constructor(self, handle)
|
|
31
|
+
handleByUnitItems[self] = handle
|
|
32
|
+
end
|
|
33
|
+
function UnitItems.prototype.__newindex(self, slot, item)
|
|
34
|
+
local handle = handleByUnitItems[self]
|
|
35
|
+
if slot < 1 or slot > unitInventorySize(handle) then
|
|
36
|
+
return
|
|
37
|
+
end
|
|
38
|
+
unitRemoveItemFromSlot(handle, slot - 1)
|
|
39
|
+
if item ~= nil then
|
|
40
|
+
local itemHandle = item.handle
|
|
41
|
+
local isPowerup = isItemPowerup(itemHandle)
|
|
42
|
+
if isPowerup then
|
|
43
|
+
setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
|
|
44
|
+
end
|
|
45
|
+
unitAddItem(handle, itemHandle)
|
|
46
|
+
unitDropItemSlot(handle, itemHandle, slot - 1)
|
|
47
|
+
if isPowerup then
|
|
48
|
+
setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
function UnitItems.prototype.__index(self, key)
|
|
53
|
+
if ____type(key) == "number" then
|
|
54
|
+
return Item:of(unitItemInSlot(handleByUnitItems[self], key - 1))
|
|
55
|
+
end
|
|
56
|
+
return rawget(____exports.UnitItems.prototype, key)
|
|
57
|
+
end
|
|
58
|
+
function UnitItems.prototype.__len(self)
|
|
59
|
+
return unitInventorySize(handleByUnitItems[self])
|
|
60
|
+
end
|
|
61
|
+
function UnitItems.prototype.__ipairs(self)
|
|
62
|
+
local handle = handleByUnitItems[self]
|
|
63
|
+
return unitItemsNext, handle, unitInventorySize(handle) << 3
|
|
64
|
+
end
|
|
65
|
+
__TS__ObjectDefineProperty(
|
|
66
|
+
Unit.prototype,
|
|
67
|
+
"items",
|
|
68
|
+
{get = function(self)
|
|
69
|
+
local items = __TS__New(____exports.UnitItems, self.handle)
|
|
70
|
+
rawset(self, "items", items)
|
|
71
|
+
return items
|
|
72
|
+
end}
|
|
73
|
+
)
|
|
74
|
+
return ____exports
|
|
@@ -40,7 +40,7 @@ ItemAbility.onCreate:addListener(
|
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
)
|
|
43
|
-
Unit.
|
|
43
|
+
Unit.itemPickedUpEvent:addListener(
|
|
44
44
|
0,
|
|
45
45
|
function(unit, item)
|
|
46
46
|
for ____, ability in ipairs(item.abilities) do
|
|
@@ -48,7 +48,7 @@ Unit.onItemPickup:addListener(
|
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
)
|
|
51
|
-
Unit.
|
|
51
|
+
Unit.itemDroppedEvent:addListener(
|
|
52
52
|
4,
|
|
53
53
|
function(unit, item)
|
|
54
54
|
for ____, ability in ipairs(item.abilities) do
|
|
@@ -6,9 +6,8 @@ local ____unit = require("engine.internal.unit")
|
|
|
6
6
|
local Unit = ____unit.Unit
|
|
7
7
|
local ____event = require("event")
|
|
8
8
|
local Event = ____event.Event
|
|
9
|
-
local
|
|
10
|
-
local
|
|
11
|
-
local boundRegion = ____mapbounds.boundRegion
|
|
9
|
+
local ____game_2Dmap = require("engine.game-map")
|
|
10
|
+
local GameMap = ____game_2Dmap.GameMap
|
|
12
11
|
local eventInvoke = Event.invoke
|
|
13
12
|
local tableRemove = table.remove
|
|
14
13
|
local ____assert = _G.assert
|
|
@@ -58,8 +57,8 @@ triggerAddCondition(
|
|
|
58
57
|
deboard(unit)
|
|
59
58
|
end
|
|
60
59
|
if not unitAlive(handle) then
|
|
61
|
-
unit.x =
|
|
62
|
-
unit.y =
|
|
60
|
+
unit.x = GameMap.worldBoundsRect.maxX
|
|
61
|
+
unit.y = GameMap.worldBoundsRect.maxY
|
|
63
62
|
end
|
|
64
63
|
local transport = Unit:of(getTransportUnit())
|
|
65
64
|
transportByUnit[unit] = transport
|
|
@@ -68,11 +67,6 @@ triggerAddCondition(
|
|
|
68
67
|
eventInvoke(onBoardEvent, unit, transport)
|
|
69
68
|
end)
|
|
70
69
|
)
|
|
71
|
-
boundRegion.onUnitEnter:addListener(function(unit)
|
|
72
|
-
if transportByUnit[unit] ~= nil and not isUnitLoaded(unit.handle) then
|
|
73
|
-
deboard(unit)
|
|
74
|
-
end
|
|
75
|
-
end)
|
|
76
70
|
Unit.deathEvent:addListener(function(unit)
|
|
77
71
|
if transportByUnit[unit] ~= nil then
|
|
78
72
|
deboard(unit)
|
|
@@ -7,14 +7,33 @@ local ____event = require("event")
|
|
|
7
7
|
local Event = ____event.Event
|
|
8
8
|
local ____timer = require("core.types.timer")
|
|
9
9
|
local Timer = ____timer.Timer
|
|
10
|
+
local ____lua_2Dsets = require("utility.lua-sets")
|
|
11
|
+
local luaSetOf = ____lua_2Dsets.luaSetOf
|
|
10
12
|
local autoAttackFinishEvent = __TS__New(Event)
|
|
11
13
|
rawset(Unit, "autoAttackFinishEvent", autoAttackFinishEvent)
|
|
12
14
|
local eventTimerByUnit = {}
|
|
13
|
-
local
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
local instantOrderIds = luaSetOf(
|
|
16
|
+
orderId("avatar"),
|
|
17
|
+
orderId("berserk"),
|
|
18
|
+
orderId("divineshield"),
|
|
19
|
+
orderId("immolation"),
|
|
20
|
+
orderId("moveslot0"),
|
|
21
|
+
orderId("moveslot1"),
|
|
22
|
+
orderId("moveslot2"),
|
|
23
|
+
orderId("moveslot3"),
|
|
24
|
+
orderId("moveslot4"),
|
|
25
|
+
orderId("moveslot5"),
|
|
26
|
+
orderId("unavatar"),
|
|
27
|
+
orderId("undivineshield"),
|
|
28
|
+
orderId("unimmolation")
|
|
29
|
+
)
|
|
30
|
+
local function reset(source, orderId)
|
|
31
|
+
if not (instantOrderIds[orderId] ~= nil) then
|
|
32
|
+
local eventTimer = eventTimerByUnit[source]
|
|
33
|
+
if eventTimer then
|
|
34
|
+
eventTimer:destroy()
|
|
35
|
+
eventTimerByUnit[source] = nil
|
|
36
|
+
end
|
|
18
37
|
end
|
|
19
38
|
end
|
|
20
39
|
Unit.onImmediateOrder:addListener(reset)
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="@typescript-to-lua/language-extensions" />
|
|
2
1
|
/** @noSelfInFile */
|
|
3
2
|
import { Handle, HandleDestructor } from "../../core/types/handle";
|
|
4
3
|
import { Player } from "../../core/types/player";
|
|
@@ -43,6 +42,7 @@ export interface DamagingEvent {
|
|
|
43
42
|
damageType: jdamagetype;
|
|
44
43
|
weaponType: jweapontype;
|
|
45
44
|
readonly isAttack: boolean;
|
|
45
|
+
readonly originalAmount: number;
|
|
46
46
|
}
|
|
47
47
|
export type DamageEvent = DamagingEvent & {
|
|
48
48
|
preventDeath<P extends any[]>(this: DamageEvent, callback: (this: void, ...parameters: P) => any, ...parameters: P): void;
|
|
@@ -228,7 +228,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
228
228
|
isSelected(player: Player): boolean;
|
|
229
229
|
explode(): void;
|
|
230
230
|
kill(): void;
|
|
231
|
-
revive(
|
|
231
|
+
revive(x: number, y: number, doEffect?: boolean): void;
|
|
232
232
|
healTarget(target: Widget, amount: number): void;
|
|
233
233
|
useItem(item: Item): boolean;
|
|
234
234
|
issueImmediateOrder(order: number): boolean;
|
|
@@ -288,7 +288,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
288
288
|
static getInRange(x: number, y: number, range: number, predicate?: (unit: Unit) => boolean): Unit[];
|
|
289
289
|
static getInCollisionRange(x: number, y: number, range: number, predicate?: (unit: Unit) => boolean): Unit[];
|
|
290
290
|
static getInSector(pos: Vec2, range: number, offsetAngle: number, centralAngle: number): Unit[];
|
|
291
|
-
static getSelectionOf(player: Player): Unit[];
|
|
291
|
+
static getSelectionOf(player: Player, target?: Unit[]): Unit[];
|
|
292
292
|
static readonly deathEvent: UnitTriggerEvent<[Unit]>;
|
|
293
293
|
static readonly onDecay: UnitTriggerEvent<[]>;
|
|
294
294
|
static readonly onResurrect: InitializingEvent<[Unit], void>;
|
|
@@ -323,9 +323,10 @@ export declare class Unit extends Handle<junit> {
|
|
|
323
323
|
static readonly autoAttackStartEvent: UnitTriggerEvent<[Unit]>;
|
|
324
324
|
static readonly onDamaging: Event<[source: Unit | undefined, target: Unit, event: DamagingEvent]>;
|
|
325
325
|
static readonly onDamage: InitializingEvent<[source: Unit | undefined, target: Unit, event: DamageEvent], jtrigger>;
|
|
326
|
-
static
|
|
327
|
-
static
|
|
328
|
-
static
|
|
326
|
+
static itemDroppedEvent: UnitTriggerEvent<[Item]>;
|
|
327
|
+
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
328
|
+
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
329
|
+
static itemStackedEvent: UnitTriggerEvent<[Item]>;
|
|
329
330
|
static get onCreate(): EventDispatcher<[Unit], [Unit]>;
|
|
330
331
|
static get destroyEvent(): EventDispatcher<[Unit], [Unit]>;
|
|
331
332
|
getField(field: junitintegerfield | junitrealfield): number;
|
package/engine/internal/unit.lua
CHANGED
|
@@ -7,6 +7,9 @@ local __TS__Class = ____lualib.__TS__Class
|
|
|
7
7
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
8
8
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
9
9
|
local __TS__ArraySetLength = ____lualib.__TS__ArraySetLength
|
|
10
|
+
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
|
|
11
|
+
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
|
|
12
|
+
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
|
|
10
13
|
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
11
14
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
12
15
|
local Set = ____lualib.Set
|
|
@@ -279,16 +282,14 @@ function UnitTriggerEvent.prototype.____constructor(self, eventType, c)
|
|
|
279
282
|
end
|
|
280
283
|
local function dispatch(event, idGetter, argsGetter)
|
|
281
284
|
local initialized = false
|
|
282
|
-
local x = {}
|
|
283
285
|
return setmetatable(
|
|
284
|
-
|
|
286
|
+
{},
|
|
285
287
|
{
|
|
286
288
|
__index = function(self, id)
|
|
287
289
|
if type(id) ~= "number" then
|
|
288
290
|
return event[id]
|
|
289
291
|
end
|
|
290
292
|
if not initialized then
|
|
291
|
-
local invoke = Event.invoke
|
|
292
293
|
event:addListener(function(...)
|
|
293
294
|
local id = idGetter(...)
|
|
294
295
|
local dispatched = rawget(self, id)
|
|
@@ -326,7 +327,6 @@ local function dispatchAbility(event)
|
|
|
326
327
|
return event[id]
|
|
327
328
|
end
|
|
328
329
|
if not initialized then
|
|
329
|
-
local invoke = Event.invoke
|
|
330
330
|
event:addListener(function(unit, ability, ...)
|
|
331
331
|
local dispatched = rawget(self, ability.typeId)
|
|
332
332
|
if dispatched ~= nil then
|
|
@@ -817,8 +817,15 @@ end
|
|
|
817
817
|
function Unit.prototype.kill(self)
|
|
818
818
|
killUnit(self.handle)
|
|
819
819
|
end
|
|
820
|
-
function Unit.prototype.revive(self,
|
|
821
|
-
|
|
820
|
+
function Unit.prototype.revive(self, x, y, doEffect)
|
|
821
|
+
local ____ReviveHero_4 = ReviveHero
|
|
822
|
+
local ____array_3 = __TS__SparseArrayNew(self.handle, x, y)
|
|
823
|
+
local ____doEffect_2 = doEffect
|
|
824
|
+
if ____doEffect_2 == nil then
|
|
825
|
+
____doEffect_2 = false
|
|
826
|
+
end
|
|
827
|
+
__TS__SparseArrayPush(____array_3, ____doEffect_2)
|
|
828
|
+
____ReviveHero_4(__TS__SparseArraySpread(____array_3))
|
|
822
829
|
end
|
|
823
830
|
function Unit.prototype.healTarget(self, target, amount)
|
|
824
831
|
if __TS__InstanceOf(target, ____exports.Unit) and target:hasAbility(fourCC("BIhm")) then
|
|
@@ -858,7 +865,7 @@ function Unit.prototype.dropItemSlot(self, item, slot)
|
|
|
858
865
|
return UnitDropItemSlot(self.handle, item.handle, slot)
|
|
859
866
|
end
|
|
860
867
|
function Unit.prototype.itemInSlot(self, slot)
|
|
861
|
-
return Item:of(
|
|
868
|
+
return Item:of(unitItemInSlot(self.handle, slot))
|
|
862
869
|
end
|
|
863
870
|
function Unit.prototype.addAbility(self, abilityId)
|
|
864
871
|
if unitAddAbility(self.handle, abilityId) then
|
|
@@ -1101,8 +1108,11 @@ function Unit.getInSector(self, pos, range, offsetAngle, centralAngle)
|
|
|
1101
1108
|
)
|
|
1102
1109
|
return targetCollection
|
|
1103
1110
|
end
|
|
1104
|
-
function Unit.getSelectionOf(self, player)
|
|
1105
|
-
|
|
1111
|
+
function Unit.getSelectionOf(self, player, target)
|
|
1112
|
+
if target == nil then
|
|
1113
|
+
target = {}
|
|
1114
|
+
end
|
|
1115
|
+
targetCollection = target
|
|
1106
1116
|
targetCollectionNextIndex = 1
|
|
1107
1117
|
GroupEnumUnitsSelected(dummyGroup, player.handle, collectIntoTarget)
|
|
1108
1118
|
return targetCollection
|
|
@@ -1385,13 +1395,13 @@ __TS__SetDescriptor(
|
|
|
1385
1395
|
end,
|
|
1386
1396
|
set = function(self, isTeamGlowVisible)
|
|
1387
1397
|
showUnitTeamGlow(self.handle, isTeamGlowVisible)
|
|
1388
|
-
local
|
|
1398
|
+
local ____temp_5
|
|
1389
1399
|
if not isTeamGlowVisible then
|
|
1390
|
-
|
|
1400
|
+
____temp_5 = true
|
|
1391
1401
|
else
|
|
1392
|
-
|
|
1402
|
+
____temp_5 = nil
|
|
1393
1403
|
end
|
|
1394
|
-
self[105] =
|
|
1404
|
+
self[105] = ____temp_5
|
|
1395
1405
|
end
|
|
1396
1406
|
},
|
|
1397
1407
|
true
|
|
@@ -2055,7 +2065,6 @@ Unit.onDecay = __TS__New(
|
|
|
2055
2065
|
Unit.onResurrect = __TS__New(
|
|
2056
2066
|
InitializingEvent,
|
|
2057
2067
|
function(event)
|
|
2058
|
-
local invoke = Event.invoke
|
|
2059
2068
|
local dead = setmetatable({}, {__mode = "k"})
|
|
2060
2069
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
2061
2070
|
dead[unit] = true
|
|
@@ -2071,10 +2080,15 @@ Unit.onResurrect = __TS__New(
|
|
|
2071
2080
|
Unit.morphEvent = __TS__New(
|
|
2072
2081
|
InitializingEvent,
|
|
2073
2082
|
function(event)
|
|
2083
|
+
local function ifNotLeft(unit)
|
|
2084
|
+
local handle = unit.handle
|
|
2085
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2086
|
+
invoke(event, unit)
|
|
2087
|
+
end
|
|
2088
|
+
end
|
|
2074
2089
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
2075
2090
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
2076
|
-
|
|
2077
|
-
Timer:run(Event.invoke, event, unit)
|
|
2091
|
+
Timer:run(ifNotLeft, unit)
|
|
2078
2092
|
end
|
|
2079
2093
|
end)
|
|
2080
2094
|
end
|
|
@@ -2112,27 +2126,26 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
2112
2126
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
2113
2127
|
InitializingEvent,
|
|
2114
2128
|
function(event)
|
|
2115
|
-
local invoke = Event.invoke
|
|
2116
2129
|
local function listener(unit, id)
|
|
2117
|
-
local
|
|
2130
|
+
local ____GetSpellTargetUnit_result_8
|
|
2118
2131
|
if GetSpellTargetUnit() then
|
|
2119
|
-
|
|
2132
|
+
____GetSpellTargetUnit_result_8 = ____exports.Unit:of(GetSpellTargetUnit())
|
|
2120
2133
|
else
|
|
2121
|
-
local
|
|
2134
|
+
local ____GetSpellTargetItem_result_7
|
|
2122
2135
|
if GetSpellTargetItem() then
|
|
2123
|
-
|
|
2136
|
+
____GetSpellTargetItem_result_7 = Item:of(GetSpellTargetItem())
|
|
2124
2137
|
else
|
|
2125
|
-
local
|
|
2138
|
+
local ____GetSpellTargetDestructable_result_6
|
|
2126
2139
|
if GetSpellTargetDestructable() then
|
|
2127
|
-
|
|
2140
|
+
____GetSpellTargetDestructable_result_6 = Destructable:of(GetSpellTargetDestructable())
|
|
2128
2141
|
else
|
|
2129
|
-
|
|
2142
|
+
____GetSpellTargetDestructable_result_6 = nil
|
|
2130
2143
|
end
|
|
2131
|
-
|
|
2144
|
+
____GetSpellTargetItem_result_7 = ____GetSpellTargetDestructable_result_6
|
|
2132
2145
|
end
|
|
2133
|
-
|
|
2146
|
+
____GetSpellTargetUnit_result_8 = ____GetSpellTargetItem_result_7
|
|
2134
2147
|
end
|
|
2135
|
-
local target =
|
|
2148
|
+
local target = ____GetSpellTargetUnit_result_8
|
|
2136
2149
|
if target then
|
|
2137
2150
|
invoke(event, unit, id, target)
|
|
2138
2151
|
end
|
|
@@ -2329,7 +2342,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2329
2342
|
)
|
|
2330
2343
|
Unit.onDamaging = (function()
|
|
2331
2344
|
local event = __TS__New(Event)
|
|
2332
|
-
local invoke = Event.invoke
|
|
2333
2345
|
local trigger = CreateTrigger()
|
|
2334
2346
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2335
2347
|
TriggerAddCondition(
|
|
@@ -2428,7 +2440,6 @@ end)()
|
|
|
2428
2440
|
Unit.onDamage = __TS__New(
|
|
2429
2441
|
InitializingEvent,
|
|
2430
2442
|
function(event)
|
|
2431
|
-
local invoke = Event.invoke
|
|
2432
2443
|
local trigger = CreateTrigger()
|
|
2433
2444
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2434
2445
|
TriggerAddCondition(
|
|
@@ -2444,6 +2455,7 @@ Unit.onDamage = __TS__New(
|
|
|
2444
2455
|
damageType = BlzGetEventDamageType(),
|
|
2445
2456
|
weaponType = BlzGetEventWeaponType(),
|
|
2446
2457
|
isAttack = BlzGetEventIsAttack(),
|
|
2458
|
+
originalAmount = GetEventDamage(),
|
|
2447
2459
|
preventDeath = damageEventPreventDeath
|
|
2448
2460
|
}
|
|
2449
2461
|
local evData = setmetatable(
|
|
@@ -2494,7 +2506,7 @@ Unit.onDamage = __TS__New(
|
|
|
2494
2506
|
DestroyTrigger(trigger)
|
|
2495
2507
|
end
|
|
2496
2508
|
)
|
|
2497
|
-
Unit.
|
|
2509
|
+
Unit.itemDroppedEvent = __TS__New(
|
|
2498
2510
|
____exports.UnitTriggerEvent,
|
|
2499
2511
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2500
2512
|
function()
|
|
@@ -2505,7 +2517,7 @@ Unit.onItemDrop = __TS__New(
|
|
|
2505
2517
|
return IgnoreEvent
|
|
2506
2518
|
end
|
|
2507
2519
|
)
|
|
2508
|
-
Unit.
|
|
2520
|
+
Unit.itemPickedUpEvent = __TS__New(
|
|
2509
2521
|
____exports.UnitTriggerEvent,
|
|
2510
2522
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2511
2523
|
function()
|
|
@@ -2516,10 +2528,15 @@ Unit.onItemPickup = __TS__New(
|
|
|
2516
2528
|
return IgnoreEvent
|
|
2517
2529
|
end
|
|
2518
2530
|
)
|
|
2519
|
-
Unit.
|
|
2531
|
+
Unit.itemUsedEvent = __TS__New(
|
|
2520
2532
|
____exports.UnitTriggerEvent,
|
|
2521
2533
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2522
|
-
function() return ____exports.Unit:of(
|
|
2534
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2535
|
+
)
|
|
2536
|
+
Unit.itemStackedEvent = __TS__New(
|
|
2537
|
+
____exports.UnitTriggerEvent,
|
|
2538
|
+
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2539
|
+
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2523
2540
|
)
|
|
2524
2541
|
__TS__ObjectDefineProperty(
|
|
2525
2542
|
Unit,
|
package/engine/local-client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { Unit } from "../core/types/unit";
|
|
3
3
|
import { Async } from "../core/types/async";
|
|
4
|
-
import { TriggerEvent } from "../event";
|
|
4
|
+
import { Event, TriggerEvent } from "../event";
|
|
5
5
|
import { GraphicsMode } from "./index";
|
|
6
6
|
export declare class LocalClient {
|
|
7
7
|
private constructor();
|
|
@@ -11,6 +11,11 @@ export declare class LocalClient {
|
|
|
11
11
|
static get isHD(): boolean;
|
|
12
12
|
static get graphicsMode(): GraphicsMode;
|
|
13
13
|
static get isActive(): boolean;
|
|
14
|
-
static get mouseFocusUnit(): Async<Unit
|
|
14
|
+
static get mouseFocusUnit(): Async<Unit> | undefined;
|
|
15
|
+
static get mainSelectedUnit(): Async<Unit> | undefined;
|
|
16
|
+
static get mainSelectedUnitChangeEvent(): Event<[
|
|
17
|
+
previousMainSelectedUnit: Unit | undefined,
|
|
18
|
+
newMainSelectedUnit: Unit | undefined
|
|
19
|
+
]>;
|
|
15
20
|
static readonly onDisconnect: TriggerEvent<[]>;
|
|
16
21
|
}
|
package/engine/local-client.lua
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
2
3
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
4
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
4
5
|
local __TS__New = ____lualib.__TS__New
|
|
@@ -6,13 +7,25 @@ local ____exports = {}
|
|
|
6
7
|
local ____unit = require("core.types.unit")
|
|
7
8
|
local Unit = ____unit.Unit
|
|
8
9
|
local ____event = require("event")
|
|
10
|
+
local Event = ____event.Event
|
|
9
11
|
local TriggerEvent = ____event.TriggerEvent
|
|
12
|
+
local ____frame = require("core.types.frame")
|
|
13
|
+
local Frame = ____frame.Frame
|
|
14
|
+
local ____player = require("core.types.player")
|
|
15
|
+
local Player = ____player.Player
|
|
16
|
+
local ____timer = require("core.types.timer")
|
|
17
|
+
local Timer = ____timer.Timer
|
|
10
18
|
local loadTOCFile = BlzLoadTOCFile
|
|
11
19
|
local getLocalClientWidth = BlzGetLocalClientWidth
|
|
12
20
|
local getLocalClientHeight = BlzGetLocalClientHeight
|
|
13
21
|
local isLocalClientActive = BlzIsLocalClientActive
|
|
22
|
+
local isHeroUnitId = IsHeroUnitId
|
|
23
|
+
local getHandleId = GetHandleId
|
|
14
24
|
local getMouseFocusUnit = BlzGetMouseFocusUnit
|
|
25
|
+
local getUnitRealField = BlzGetUnitRealField
|
|
26
|
+
local getUnitTypeId = GetUnitTypeId
|
|
15
27
|
local getLocale = BlzGetLocale
|
|
28
|
+
local tableSort = table.sort
|
|
16
29
|
local tocPath = "_warscript\\IsHD.toc"
|
|
17
30
|
compiletime(function()
|
|
18
31
|
if currentMap then
|
|
@@ -21,6 +34,29 @@ compiletime(function()
|
|
|
21
34
|
currentMap:addFileString("_HD.w3mod\\" .. tocPath, fdfPath .. "\r\n")
|
|
22
35
|
end
|
|
23
36
|
end)
|
|
37
|
+
local selectionButtons
|
|
38
|
+
Timer:run(function()
|
|
39
|
+
selectionButtons = __TS__ArrayMap(
|
|
40
|
+
Frame:byName("SimpleInfoPanelUnitDetail").parent:getChild(5):getChild(0).children,
|
|
41
|
+
function(____, frame) return frame:getChild(1) end
|
|
42
|
+
)
|
|
43
|
+
end)
|
|
44
|
+
local localSelectedUnits = {}
|
|
45
|
+
local indexByLocalSelectedUnit = {}
|
|
46
|
+
local function compareUnitsSelectionPriority(a, b)
|
|
47
|
+
local aHandle = a.handle
|
|
48
|
+
local bHandle = b.handle
|
|
49
|
+
local priorityDelta = getUnitRealField(bHandle, UNIT_RF_PRIORITY) - getUnitRealField(aHandle, UNIT_RF_PRIORITY)
|
|
50
|
+
if priorityDelta ~= 0 then
|
|
51
|
+
return priorityDelta < 0
|
|
52
|
+
end
|
|
53
|
+
local aTypeId = getUnitTypeId(aHandle)
|
|
54
|
+
local bTypeId = getUnitTypeId(bHandle)
|
|
55
|
+
local orderDelta = (isHeroUnitId(aTypeId) and getHandleId(aHandle) or aTypeId) - (isHeroUnitId(bTypeId) and getHandleId(bHandle) or bTypeId)
|
|
56
|
+
return (orderDelta ~= 0 and orderDelta or indexByLocalSelectedUnit[a] - indexByLocalSelectedUnit[b]) < 0
|
|
57
|
+
end
|
|
58
|
+
local mainSelectedUnitChangeEvent
|
|
59
|
+
local previousMainSelectedUnit
|
|
24
60
|
____exports.LocalClient = __TS__Class()
|
|
25
61
|
local LocalClient = ____exports.LocalClient
|
|
26
62
|
LocalClient.name = "LocalClient"
|
|
@@ -69,6 +105,51 @@ __TS__ObjectDefineProperty(
|
|
|
69
105
|
return Unit:of(getMouseFocusUnit())
|
|
70
106
|
end}
|
|
71
107
|
)
|
|
108
|
+
__TS__ObjectDefineProperty(
|
|
109
|
+
LocalClient,
|
|
110
|
+
"mainSelectedUnit",
|
|
111
|
+
{get = function(self)
|
|
112
|
+
Unit:getSelectionOf(Player["local"], localSelectedUnits)
|
|
113
|
+
for i = 1, #localSelectedUnits do
|
|
114
|
+
indexByLocalSelectedUnit[localSelectedUnits[i]] = i
|
|
115
|
+
end
|
|
116
|
+
tableSort(localSelectedUnits, compareUnitsSelectionPriority)
|
|
117
|
+
local mainSelectedUnitIndex
|
|
118
|
+
if selectionButtons and #localSelectedUnits > 1 then
|
|
119
|
+
local maxButtonWidth = 0
|
|
120
|
+
for i = 0, #selectionButtons - 1 do
|
|
121
|
+
local width = selectionButtons[i + 1].width
|
|
122
|
+
if width > maxButtonWidth then
|
|
123
|
+
maxButtonWidth = width
|
|
124
|
+
mainSelectedUnitIndex = i
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
local mainSelectedUnit = localSelectedUnits[(mainSelectedUnitIndex or 0) + 1]
|
|
129
|
+
for i = 1, #localSelectedUnits do
|
|
130
|
+
indexByLocalSelectedUnit[localSelectedUnits[i]] = nil
|
|
131
|
+
localSelectedUnits[i] = nil
|
|
132
|
+
end
|
|
133
|
+
if mainSelectedUnitChangeEvent ~= nil and mainSelectedUnit ~= previousMainSelectedUnit then
|
|
134
|
+
Event.invoke(mainSelectedUnitChangeEvent, previousMainSelectedUnit, mainSelectedUnit)
|
|
135
|
+
previousMainSelectedUnit = mainSelectedUnit
|
|
136
|
+
end
|
|
137
|
+
return mainSelectedUnit
|
|
138
|
+
end}
|
|
139
|
+
)
|
|
140
|
+
__TS__ObjectDefineProperty(
|
|
141
|
+
LocalClient,
|
|
142
|
+
"mainSelectedUnitChangeEvent",
|
|
143
|
+
{get = function(self)
|
|
144
|
+
if mainSelectedUnitChangeEvent == nil then
|
|
145
|
+
mainSelectedUnitChangeEvent = __TS__New(Event)
|
|
146
|
+
Timer.onPeriod[1 / 64]:addListener(function()
|
|
147
|
+
local _ = ____exports.LocalClient.mainSelectedUnit
|
|
148
|
+
end)
|
|
149
|
+
end
|
|
150
|
+
return mainSelectedUnitChangeEvent
|
|
151
|
+
end}
|
|
152
|
+
)
|
|
72
153
|
LocalClient.onDisconnect = __TS__New(
|
|
73
154
|
TriggerEvent,
|
|
74
155
|
function(trigger)
|