warscript 0.0.1-dev.9af2d1a → 0.0.1-dev.9cbb1ff
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/config.d.ts +5 -0
- package/config.lua +10 -0
- package/core/types/effect.d.ts +14 -6
- package/core/types/effect.lua +131 -35
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/timer.d.ts +6 -7
- package/core/types/timer.lua +18 -21
- package/core/util.d.ts +1 -1
- package/core/util.lua +12 -1
- package/engine/behaviour/ability/always-enabled.d.ts +7 -0
- package/engine/behaviour/ability/always-enabled.lua +31 -0
- package/engine/behaviour/ability/apply-buff.d.ts +5 -0
- package/engine/behaviour/ability/apply-buff.lua +32 -0
- package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
- package/engine/behaviour/ability/damage.d.ts +3 -0
- package/engine/behaviour/ability/damage.lua +2 -2
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +35 -0
- package/engine/behaviour/ability/instant-impact.d.ts +2 -2
- package/engine/behaviour/ability/instant-impact.lua +4 -19
- package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
- package/engine/behaviour/ability/on-command-impact.lua +25 -0
- package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
- package/engine/behaviour/ability/remove-buffs.lua +28 -0
- package/engine/behaviour/ability.d.ts +20 -4
- package/engine/behaviour/ability.lua +111 -38
- package/engine/behaviour/unit.d.ts +2 -0
- package/engine/buff.d.ts +62 -42
- package/engine/buff.lua +312 -234
- package/engine/internal/ability.d.ts +13 -2
- package/engine/internal/ability.lua +77 -4
- package/engine/internal/item/ability.lua +106 -0
- package/engine/internal/item.d.ts +2 -2
- package/engine/internal/item.lua +56 -25
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
- package/engine/internal/misc/ability-disable-counter.lua +13 -0
- package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
- package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
- package/engine/internal/object-data/evasion-probability.d.ts +2 -0
- package/engine/internal/object-data/evasion-probability.lua +16 -0
- package/engine/internal/unit/ability.d.ts +10 -1
- package/engine/internal/unit/ability.lua +36 -0
- package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
- package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot.lua +52 -0
- package/engine/internal/unit/bonus.d.ts +2 -0
- package/engine/internal/unit/bonus.lua +17 -0
- package/engine/internal/unit/ignore-events-items.d.ts +2 -0
- package/engine/internal/unit/ignore-events-items.lua +5 -0
- package/engine/internal/unit/item.lua +6 -12
- package/engine/internal/unit/main-selected.d.ts +6 -0
- package/engine/internal/unit/main-selected.lua +12 -1
- package/engine/internal/unit.d.ts +15 -2
- package/engine/internal/unit.lua +97 -15
- package/engine/internal/utility.lua +12 -0
- package/engine/lightning.d.ts +12 -5
- package/engine/lightning.lua +48 -14
- package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
- package/engine/object-data/auxiliary/animation-name.lua +16 -0
- package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
- package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
- 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-eax.d.ts +10 -0
- package/engine/object-data/auxiliary/sound-eax.lua +2 -0
- package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
- package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
- 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/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.lua +12 -1
- package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
- package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
- package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
- package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
- package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
- package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
- package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
- package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
- package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
- package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
- package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
- package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
- package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
- package/engine/object-data/entry/ability-type/shock-wave.lua +26 -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/summon-quilbeast.lua +2 -2
- package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
- package/engine/object-data/entry/ability-type/web.d.ts +12 -0
- package/engine/object-data/entry/ability-type/web.lua +52 -0
- package/engine/object-data/entry/ability-type.d.ts +19 -17
- package/engine/object-data/entry/ability-type.lua +89 -33
- package/engine/object-data/entry/buff-type/applicable.lua +18 -37
- package/engine/object-data/entry/buff-type.d.ts +6 -12
- package/engine/object-data/entry/buff-type.lua +13 -29
- package/engine/object-data/entry/destructible-type.d.ts +1 -1
- package/engine/object-data/entry/item-type.d.ts +3 -1
- package/engine/object-data/entry/item-type.lua +15 -2
- package/engine/object-data/entry/lightning-type.d.ts +1 -1
- package/engine/object-data/entry/sound-preset.d.ts +33 -0
- package/engine/object-data/entry/sound-preset.lua +140 -0
- package/engine/object-data/entry/unit-type.d.ts +8 -1
- package/engine/object-data/entry/unit-type.lua +69 -10
- package/engine/object-data/entry/upgrade.d.ts +1 -1
- package/engine/object-data/entry/upgrade.lua +4 -4
- package/engine/object-data/entry.d.ts +16 -14
- package/engine/object-data/entry.lua +60 -32
- package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
- package/engine/object-field/ability.d.ts +9 -3
- package/engine/object-field/ability.lua +3 -0
- package/engine/object-field.d.ts +11 -3
- package/engine/object-field.lua +162 -76
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- package/engine/standard/entries/sound-preset.d.ts +10 -0
- package/engine/standard/entries/sound-preset.lua +10 -0
- package/engine/standard/fields/ability.d.ts +2 -0
- package/engine/standard/fields/ability.lua +2 -0
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/objutil/unit.lua +8 -0
- package/package.json +2 -2
- package/utility/arrays.d.ts +8 -1
- package/utility/arrays.lua +34 -3
- package/utility/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +3 -0
- package/utility/lua-maps.d.ts +3 -0
- package/utility/lua-maps.lua +16 -0
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +3 -0
- package/utility/reflection.lua +11 -7
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____blank = require("engine.object-data.entry.item-type.blank")
|
|
3
|
+
local BlankItemType = ____blank.BlankItemType
|
|
4
|
+
local ____arrays = require("utility.arrays")
|
|
5
|
+
local array = ____arrays.array
|
|
6
|
+
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
7
|
+
local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
8
|
+
local setItemVisible = SetItemVisible
|
|
9
|
+
local unitAddItem = UnitAddItem
|
|
10
|
+
local unitItemInSlot = UnitItemInSlot
|
|
11
|
+
local unitRemoveItem = UnitRemoveItem
|
|
12
|
+
---
|
|
13
|
+
-- @internal For use by internal systems only.
|
|
14
|
+
____exports.SLOT_FILLER_ITEM_TYPE_ID = compiletime(function()
|
|
15
|
+
local itemType = BlankItemType:create()
|
|
16
|
+
itemType.name = "[Warscript/Dummy] Slot Filler"
|
|
17
|
+
return itemType.id
|
|
18
|
+
end)
|
|
19
|
+
---
|
|
20
|
+
-- @internal For use by internal systems only.
|
|
21
|
+
____exports.fillerItems = array(
|
|
22
|
+
6,
|
|
23
|
+
function()
|
|
24
|
+
local item = CreateItem(____exports.SLOT_FILLER_ITEM_TYPE_ID, 0, 0)
|
|
25
|
+
setItemVisible(item, false)
|
|
26
|
+
ignoreEventsItems[item] = true
|
|
27
|
+
return item
|
|
28
|
+
end
|
|
29
|
+
)
|
|
30
|
+
---
|
|
31
|
+
-- @internal For use by internal systems only.
|
|
32
|
+
____exports.unitsWithFillerItems = {}
|
|
33
|
+
---
|
|
34
|
+
-- @internal For use by internal systems only.
|
|
35
|
+
____exports.unitAddItemToSlot = function(unit, item, slot)
|
|
36
|
+
for previousSlot = 0, slot - 1 do
|
|
37
|
+
if unitItemInSlot(unit, previousSlot) == nil then
|
|
38
|
+
unitAddItem(unit, ____exports.fillerItems[previousSlot + 1])
|
|
39
|
+
____exports.unitsWithFillerItems[unit] = true
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
unitAddItem(unit, item)
|
|
43
|
+
if ____exports.unitsWithFillerItems[unit] ~= nil then
|
|
44
|
+
for previousSlot = 0, slot - 1 do
|
|
45
|
+
local fillerItem = ____exports.fillerItems[previousSlot + 1]
|
|
46
|
+
unitRemoveItem(unit, fillerItem)
|
|
47
|
+
setItemVisible(fillerItem, false)
|
|
48
|
+
end
|
|
49
|
+
____exports.unitsWithFillerItems[unit] = nil
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
return ____exports
|
|
@@ -11,6 +11,7 @@ export type UnitMovementSpeedFactorBonusId = UnitBonusId<"movementSpeedFactor">;
|
|
|
11
11
|
export type UnitAutoAttackDamageBonusId = UnitBonusId<"autoAttackDamage">;
|
|
12
12
|
export type UnitDamageFactorBonusId = UnitBonusId<"damageFactor">;
|
|
13
13
|
export type UnitReceivedDamageFactorBonusId = UnitBonusId<"receivedDamageFactor">;
|
|
14
|
+
export type UnitEvasionProbabilityBonusId = UnitBonusId<"evasionProbability">;
|
|
14
15
|
export type UnitBonusType<Id extends UnitBonusId = UnitBonusId> = ({
|
|
15
16
|
abilityTypeId: AbilityTypeId;
|
|
16
17
|
field: jabilityintegerlevelfield;
|
|
@@ -34,6 +35,7 @@ export declare namespace UnitBonusType {
|
|
|
34
35
|
const AUTO_ATTACK_DAMAGE: UnitBonusType<UnitAutoAttackDamageBonusId>;
|
|
35
36
|
const DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
|
|
36
37
|
const RECEIVED_DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
|
|
38
|
+
const EVASION_PROBABILITY: UnitBonusType<UnitEvasionProbabilityBonusId>;
|
|
37
39
|
}
|
|
38
40
|
export declare const addUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, value: number) => Id;
|
|
39
41
|
export declare const removeUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id) => boolean;
|
|
@@ -21,8 +21,18 @@ 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 ____evasion_2Dprobability = require("engine.internal.object-data.evasion-probability")
|
|
25
|
+
local EVASION_PROBABILITY_ABILITY_FIELD = ____evasion_2Dprobability.EVASION_PROBABILITY_ABILITY_FIELD
|
|
26
|
+
local EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID = ____evasion_2Dprobability.EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID
|
|
24
27
|
local damageFactorByUnit = {}
|
|
25
28
|
local receivedDamageFactorByUnit = {}
|
|
29
|
+
local function atLeastOnceProbability(array)
|
|
30
|
+
local oppositeEventProbability = 1
|
|
31
|
+
for i = 1, #array do
|
|
32
|
+
oppositeEventProbability = oppositeEventProbability * (1 - array[i])
|
|
33
|
+
end
|
|
34
|
+
return 1 - oppositeEventProbability
|
|
35
|
+
end
|
|
26
36
|
____exports.UnitBonusType = {}
|
|
27
37
|
local UnitBonusType = ____exports.UnitBonusType
|
|
28
38
|
do
|
|
@@ -56,6 +66,13 @@ do
|
|
|
56
66
|
}
|
|
57
67
|
UnitBonusType.DAMAGE_FACTOR = {reduce = product, valueByUnit = damageFactorByUnit, initialValue = 1}
|
|
58
68
|
UnitBonusType.RECEIVED_DAMAGE_FACTOR = {reduce = product, valueByUnit = receivedDamageFactorByUnit, initialValue = 1}
|
|
69
|
+
UnitBonusType.EVASION_PROBABILITY = {
|
|
70
|
+
abilityTypeId = EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID,
|
|
71
|
+
field = EVASION_PROBABILITY_ABILITY_FIELD,
|
|
72
|
+
integer = false,
|
|
73
|
+
reduce = atLeastOnceProbability,
|
|
74
|
+
initialValue = 0
|
|
75
|
+
}
|
|
59
76
|
end
|
|
60
77
|
local bonusesByUnitByBonusType = {}
|
|
61
78
|
local nextId = 1
|
|
@@ -7,12 +7,14 @@ local ____item = require("engine.internal.item")
|
|
|
7
7
|
local Item = ____item.Item
|
|
8
8
|
local ____unit = require("engine.internal.unit")
|
|
9
9
|
local Unit = ____unit.Unit
|
|
10
|
+
local ____utility = require("engine.internal.utility")
|
|
11
|
+
local findUnitItemSlot = ____utility.findUnitItemSlot
|
|
12
|
+
local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
|
|
13
|
+
local unitAddItemToSlot = ____add_2Ditem_2Dto_2Dslot.unitAddItemToSlot
|
|
10
14
|
local rawset = _G.rawset
|
|
11
15
|
local ____type = _G.type
|
|
12
16
|
local isItemPowerup = IsItemPowerup
|
|
13
17
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
14
|
-
local unitAddItem = UnitAddItem
|
|
15
|
-
local unitDropItemSlot = UnitDropItemSlot
|
|
16
18
|
local unitInventorySize = UnitInventorySize
|
|
17
19
|
local unitItemInSlot = UnitItemInSlot
|
|
18
20
|
local unitRemoveItemFromSlot = UnitRemoveItemFromSlot
|
|
@@ -31,14 +33,7 @@ function UnitItems.prototype.____constructor(self, handle)
|
|
|
31
33
|
handleByUnitItems[self] = handle
|
|
32
34
|
end
|
|
33
35
|
function UnitItems.prototype.findSlot(self, item)
|
|
34
|
-
|
|
35
|
-
local itemHandle = item.handle
|
|
36
|
-
for slot = 0, unitInventorySize(handle) - 1 do
|
|
37
|
-
if itemHandle == unitItemInSlot(handle, slot) then
|
|
38
|
-
return slot
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
return nil
|
|
36
|
+
return findUnitItemSlot(handleByUnitItems[self], item.handle)
|
|
42
37
|
end
|
|
43
38
|
function UnitItems.prototype.__newindex(self, slot, item)
|
|
44
39
|
local handle = handleByUnitItems[self]
|
|
@@ -52,8 +47,7 @@ function UnitItems.prototype.__newindex(self, slot, item)
|
|
|
52
47
|
if isPowerup then
|
|
53
48
|
setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, false)
|
|
54
49
|
end
|
|
55
|
-
|
|
56
|
-
unitDropItemSlot(handle, itemHandle, slot - 1)
|
|
50
|
+
unitAddItemToSlot(handle, itemHandle, slot - 1)
|
|
57
51
|
if isPowerup then
|
|
58
52
|
setItemBooleanField(itemHandle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
59
53
|
end
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { Player } from "../../../core/types/player";
|
|
3
|
+
import { Event } from "../../../event";
|
|
4
|
+
declare module "../unit" {
|
|
5
|
+
namespace Unit {
|
|
6
|
+
const mainSelectedUnitChangeEvent: Event<[Player]>;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
3
9
|
declare module "../unit" {
|
|
4
10
|
namespace Unit {
|
|
5
11
|
const getMainSelectedOf: (player: Player) => Unit | undefined;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__New = ____lualib.__TS__New
|
|
1
3
|
local ____exports = {}
|
|
2
4
|
local ____player = require("core.types.player")
|
|
3
5
|
local Player = ____player.Player
|
|
@@ -8,6 +10,10 @@ local ____local_2Dclient = require("engine.local-client")
|
|
|
8
10
|
local LocalClient = ____local_2Dclient.LocalClient
|
|
9
11
|
local ____unit = require("engine.internal.unit")
|
|
10
12
|
local Unit = ____unit.Unit
|
|
13
|
+
local ____event = require("event")
|
|
14
|
+
local Event = ____event.Event
|
|
15
|
+
local mainSelectedUnitChangeEvent = __TS__New(Event)
|
|
16
|
+
rawset(Unit, "mainSelectedUnitChangeEvent", mainSelectedUnitChangeEvent)
|
|
11
17
|
local mainSelectedUnitByPlayer = {}
|
|
12
18
|
local syncSlider = BlzCreateFrameByType(
|
|
13
19
|
"SLIDER",
|
|
@@ -27,7 +33,12 @@ BlzTriggerRegisterFrameEvent(trg, syncSlider, FRAMEEVENT_SLIDER_VALUE_CHANGED)
|
|
|
27
33
|
TriggerAddAction(
|
|
28
34
|
trg,
|
|
29
35
|
function()
|
|
30
|
-
|
|
36
|
+
local player = Player:of(GetTriggerPlayer())
|
|
37
|
+
local mainSelectedUnit = Unit:getBySyncId(BlzGetTriggerFrameValue())
|
|
38
|
+
if mainSelectedUnit ~= mainSelectedUnitByPlayer[player] then
|
|
39
|
+
mainSelectedUnitByPlayer[player] = mainSelectedUnit
|
|
40
|
+
Event.invoke(mainSelectedUnitChangeEvent, player)
|
|
41
|
+
end
|
|
31
42
|
end
|
|
32
43
|
)
|
|
33
44
|
rawset(
|
|
@@ -11,6 +11,8 @@ import { Ability, UnitAbility } from "./ability";
|
|
|
11
11
|
import { Widget } from "../../core/types/widget";
|
|
12
12
|
import type { UnitTypeId } from "../object-data/entry/unit-type";
|
|
13
13
|
import { CombatClassification, CombatClassifications } from "../object-data/auxiliary/combat-classification";
|
|
14
|
+
import { MovementType } from "../object-data/auxiliary/movement-type";
|
|
15
|
+
import { UnitAttribute } from "../object-data/auxiliary/unit-attribute";
|
|
14
16
|
export type UnitClassification = junittype;
|
|
15
17
|
export declare namespace UnitClassification {
|
|
16
18
|
const STRUCTURE: junittype;
|
|
@@ -100,7 +102,9 @@ declare const enum UnitPropertyKey {
|
|
|
100
102
|
DELAY_HEALTH_CHECKS_COUNTER = 103,
|
|
101
103
|
DELAY_HEALTH_CHECKS_HEALTH_BONUS = 104,
|
|
102
104
|
PREVENT_DEATH_HEALTH_BONUS = 105,
|
|
103
|
-
IS_TEAM_GLOW_HIDDEN = 106
|
|
105
|
+
IS_TEAM_GLOW_HIDDEN = 106,
|
|
106
|
+
LAST_X = 107,
|
|
107
|
+
LAST_Y = 108
|
|
104
108
|
}
|
|
105
109
|
export type UnitSyncId = number & {
|
|
106
110
|
readonly __unitSyncId: unique symbol;
|
|
@@ -113,6 +117,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
113
117
|
private [UnitPropertyKey.DELAY_HEALTH_CHECKS_HEALTH_BONUS]?;
|
|
114
118
|
private [UnitPropertyKey.PREVENT_DEATH_HEALTH_BONUS]?;
|
|
115
119
|
private [UnitPropertyKey.IS_TEAM_GLOW_HIDDEN]?;
|
|
120
|
+
private [UnitPropertyKey.LAST_X]?;
|
|
121
|
+
private [UnitPropertyKey.LAST_Y]?;
|
|
116
122
|
private _owner?;
|
|
117
123
|
private _timeScale?;
|
|
118
124
|
private events?;
|
|
@@ -133,6 +139,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
133
139
|
get isAlive(): boolean;
|
|
134
140
|
get isDead(): boolean;
|
|
135
141
|
get isIllusion(): boolean;
|
|
142
|
+
get isStunned(): boolean;
|
|
136
143
|
get combatClassifications(): CombatClassifications;
|
|
137
144
|
set combatClassifications(combatClassifications: CombatClassifications);
|
|
138
145
|
hasCombatClassification(combatClassification: CombatClassification): boolean;
|
|
@@ -147,6 +154,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
147
154
|
isEnemyOf(unit: Unit): boolean;
|
|
148
155
|
playAnimation(animation: string, rarity?: jraritycontrol): void;
|
|
149
156
|
playAnimation(animation: number): void;
|
|
157
|
+
resetAnimation(): void;
|
|
150
158
|
queueAnimation(animation: string): void;
|
|
151
159
|
get weapons(): [UnitWeapon, UnitWeapon];
|
|
152
160
|
get firstWeapon(): UnitWeapon;
|
|
@@ -155,6 +163,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
155
163
|
set level(v: number);
|
|
156
164
|
get xp(): number;
|
|
157
165
|
set xp(v: number);
|
|
166
|
+
get primaryAttribute(): UnitAttribute;
|
|
167
|
+
set primaryAttribute(primaryAttribute: UnitAttribute);
|
|
158
168
|
get strengthBase(): number;
|
|
159
169
|
set strengthBase(strengthBase: number);
|
|
160
170
|
get strengthBonus(): number;
|
|
@@ -229,6 +239,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
229
239
|
set timeScale(v: number);
|
|
230
240
|
get collisionSize(): number;
|
|
231
241
|
get pathingCollisionRange(): number;
|
|
242
|
+
get movementType(): MovementType;
|
|
243
|
+
set movementType(movementType: MovementType);
|
|
232
244
|
set pathing(v: boolean);
|
|
233
245
|
isSelected(player: Player): boolean;
|
|
234
246
|
explode(): void;
|
|
@@ -332,7 +344,8 @@ export declare class Unit extends Handle<junit> {
|
|
|
332
344
|
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
333
345
|
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
334
346
|
static itemStackedEvent: UnitTriggerEvent<[Item]>;
|
|
335
|
-
static get
|
|
347
|
+
static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
|
|
348
|
+
static get itemMoveOrderEvent(): Event<[
|
|
336
349
|
unit: Unit,
|
|
337
350
|
item: Item,
|
|
338
351
|
slotFrom: 0 | 1 | 2 | 3 | 4 | 5,
|
package/engine/internal/unit.lua
CHANGED
|
@@ -51,11 +51,14 @@ local ____arrays = require("utility.arrays")
|
|
|
51
51
|
local forEach = ____arrays.forEach
|
|
52
52
|
local ____math = require("math")
|
|
53
53
|
local min = ____math.min
|
|
54
|
+
local ____ignore_2Devents_2Ditems = require("engine.internal.unit.ignore-events-items")
|
|
55
|
+
local ignoreEventsItems = ____ignore_2Devents_2Ditems.ignoreEventsItems
|
|
54
56
|
local match = string.match
|
|
55
57
|
local ____tostring = _G.tostring
|
|
56
58
|
local setUnitAnimation = SetUnitAnimation
|
|
57
59
|
local setUnitAnimationWithRarity = SetUnitAnimationWithRarity
|
|
58
60
|
local setUnitAnimationByIndex = SetUnitAnimationByIndex
|
|
61
|
+
local resetUnitAnimation = ResetUnitAnimation
|
|
59
62
|
local queueUnitAnimation = QueueUnitAnimation
|
|
60
63
|
local getUnitIntegerField = BlzGetUnitIntegerField
|
|
61
64
|
local getUnitRealField = BlzGetUnitRealField
|
|
@@ -75,6 +78,7 @@ local setUnitScale = SetUnitScale
|
|
|
75
78
|
local setUnitPosition = SetUnitPosition
|
|
76
79
|
local setUnitTimeScale = SetUnitTimeScale
|
|
77
80
|
local getHandleId = GetHandleId
|
|
81
|
+
local getUnitCurrentOrder = GetUnitCurrentOrder
|
|
78
82
|
local createUnit = CreateUnit
|
|
79
83
|
local killUnit = KillUnit
|
|
80
84
|
local setUnitExploded = SetUnitExploded
|
|
@@ -677,6 +681,8 @@ function Unit.prototype.getEvent(self, event, collector)
|
|
|
677
681
|
end
|
|
678
682
|
function Unit.prototype.onDestroy(self)
|
|
679
683
|
local handle = self.handle
|
|
684
|
+
self[107] = getUnitX(handle)
|
|
685
|
+
self[108] = getUnitY(handle)
|
|
680
686
|
if not self._owner then
|
|
681
687
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
682
688
|
end
|
|
@@ -792,6 +798,9 @@ function Unit.prototype.playAnimation(self, animation, rarity)
|
|
|
792
798
|
setUnitAnimation(self.handle, animation)
|
|
793
799
|
end
|
|
794
800
|
end
|
|
801
|
+
function Unit.prototype.resetAnimation(self)
|
|
802
|
+
resetUnitAnimation(self.handle)
|
|
803
|
+
end
|
|
795
804
|
function Unit.prototype.queueAnimation(self, animation)
|
|
796
805
|
queueUnitAnimation(self.handle, animation)
|
|
797
806
|
end
|
|
@@ -929,8 +938,15 @@ function Unit.prototype.interruptAttack(self)
|
|
|
929
938
|
unitInterruptAttack(self.handle)
|
|
930
939
|
end
|
|
931
940
|
function Unit.prototype.interruptCast(self, abilityId)
|
|
932
|
-
|
|
933
|
-
unitDisableAbility(
|
|
941
|
+
local handle = self.handle
|
|
942
|
+
unitDisableAbility(handle, abilityId, true, false)
|
|
943
|
+
Timer:run(
|
|
944
|
+
unitDisableAbility,
|
|
945
|
+
handle,
|
|
946
|
+
abilityId,
|
|
947
|
+
false,
|
|
948
|
+
false
|
|
949
|
+
)
|
|
934
950
|
end
|
|
935
951
|
function Unit.prototype.getDistanceTo(self, target)
|
|
936
952
|
local handle = self.handle
|
|
@@ -1195,6 +1211,14 @@ __TS__SetDescriptor(
|
|
|
1195
1211
|
end},
|
|
1196
1212
|
true
|
|
1197
1213
|
)
|
|
1214
|
+
__TS__SetDescriptor(
|
|
1215
|
+
Unit.prototype,
|
|
1216
|
+
"isStunned",
|
|
1217
|
+
{get = function(self)
|
|
1218
|
+
return getUnitCurrentOrder(self.handle) == orderId("stunned")
|
|
1219
|
+
end},
|
|
1220
|
+
true
|
|
1221
|
+
)
|
|
1198
1222
|
__TS__SetDescriptor(
|
|
1199
1223
|
Unit.prototype,
|
|
1200
1224
|
"combatClassifications",
|
|
@@ -1268,6 +1292,19 @@ __TS__SetDescriptor(
|
|
|
1268
1292
|
},
|
|
1269
1293
|
true
|
|
1270
1294
|
)
|
|
1295
|
+
__TS__SetDescriptor(
|
|
1296
|
+
Unit.prototype,
|
|
1297
|
+
"primaryAttribute",
|
|
1298
|
+
{
|
|
1299
|
+
get = function(self)
|
|
1300
|
+
return getUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE)
|
|
1301
|
+
end,
|
|
1302
|
+
set = function(self, primaryAttribute)
|
|
1303
|
+
setUnitIntegerField(self.handle, UNIT_IF_PRIMARY_ATTRIBUTE, primaryAttribute)
|
|
1304
|
+
end
|
|
1305
|
+
},
|
|
1306
|
+
true
|
|
1307
|
+
)
|
|
1271
1308
|
__TS__SetDescriptor(
|
|
1272
1309
|
Unit.prototype,
|
|
1273
1310
|
"strengthBase",
|
|
@@ -1579,7 +1616,7 @@ __TS__SetDescriptor(
|
|
|
1579
1616
|
"x",
|
|
1580
1617
|
{
|
|
1581
1618
|
get = function(self)
|
|
1582
|
-
return getUnitX(self.handle)
|
|
1619
|
+
return self[107] or getUnitX(self.handle)
|
|
1583
1620
|
end,
|
|
1584
1621
|
set = function(self, v)
|
|
1585
1622
|
SetUnitX(self.handle, v)
|
|
@@ -1592,7 +1629,7 @@ __TS__SetDescriptor(
|
|
|
1592
1629
|
"y",
|
|
1593
1630
|
{
|
|
1594
1631
|
get = function(self)
|
|
1595
|
-
return getUnitY(self.handle)
|
|
1632
|
+
return self[108] or getUnitY(self.handle)
|
|
1596
1633
|
end,
|
|
1597
1634
|
set = function(self, v)
|
|
1598
1635
|
SetUnitY(self.handle, v)
|
|
@@ -1809,6 +1846,19 @@ __TS__SetDescriptor(
|
|
|
1809
1846
|
end},
|
|
1810
1847
|
true
|
|
1811
1848
|
)
|
|
1849
|
+
__TS__SetDescriptor(
|
|
1850
|
+
Unit.prototype,
|
|
1851
|
+
"movementType",
|
|
1852
|
+
{
|
|
1853
|
+
get = function(self)
|
|
1854
|
+
return getUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE)
|
|
1855
|
+
end,
|
|
1856
|
+
set = function(self, movementType)
|
|
1857
|
+
setUnitIntegerField(self.handle, UNIT_IF_MOVE_TYPE, movementType)
|
|
1858
|
+
end
|
|
1859
|
+
},
|
|
1860
|
+
true
|
|
1861
|
+
)
|
|
1812
1862
|
__TS__SetDescriptor(
|
|
1813
1863
|
Unit.prototype,
|
|
1814
1864
|
"pathing",
|
|
@@ -2315,10 +2365,12 @@ Unit.onImmediateOrder = dispatchId(__TS__New(
|
|
|
2315
2365
|
____exports.UnitTriggerEvent,
|
|
2316
2366
|
EVENT_PLAYER_UNIT_ISSUED_ORDER,
|
|
2317
2367
|
function()
|
|
2318
|
-
local
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2368
|
+
local handle = getOrderedUnit()
|
|
2369
|
+
if handle ~= nil and getUnitTypeId(handle) ~= dummyUnitId then
|
|
2370
|
+
local unit = ____exports.Unit:of(handle)
|
|
2371
|
+
if unit.state == 1 then
|
|
2372
|
+
return unit, getIssuedOrderId()
|
|
2373
|
+
end
|
|
2322
2374
|
end
|
|
2323
2375
|
return IgnoreEvent
|
|
2324
2376
|
end
|
|
@@ -2509,8 +2561,9 @@ Unit.itemDroppedEvent = __TS__New(
|
|
|
2509
2561
|
EVENT_PLAYER_UNIT_DROP_ITEM,
|
|
2510
2562
|
function()
|
|
2511
2563
|
local unit = getTriggerUnit()
|
|
2512
|
-
|
|
2513
|
-
|
|
2564
|
+
local item = getManipulatedItem()
|
|
2565
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2566
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2514
2567
|
end
|
|
2515
2568
|
return IgnoreEvent
|
|
2516
2569
|
end
|
|
@@ -2520,8 +2573,9 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2520
2573
|
EVENT_PLAYER_UNIT_PICKUP_ITEM,
|
|
2521
2574
|
function()
|
|
2522
2575
|
local unit = getTriggerUnit()
|
|
2523
|
-
|
|
2524
|
-
|
|
2576
|
+
local item = getManipulatedItem()
|
|
2577
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2578
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2525
2579
|
end
|
|
2526
2580
|
return IgnoreEvent
|
|
2527
2581
|
end
|
|
@@ -2529,7 +2583,14 @@ Unit.itemPickedUpEvent = __TS__New(
|
|
|
2529
2583
|
Unit.itemUsedEvent = __TS__New(
|
|
2530
2584
|
____exports.UnitTriggerEvent,
|
|
2531
2585
|
EVENT_PLAYER_UNIT_USE_ITEM,
|
|
2532
|
-
function()
|
|
2586
|
+
function()
|
|
2587
|
+
local unit = getTriggerUnit()
|
|
2588
|
+
local item = getManipulatedItem()
|
|
2589
|
+
if getUnitTypeId(unit) ~= dummyUnitId and not (ignoreEventsItems[item] ~= nil) then
|
|
2590
|
+
return ____exports.Unit:of(unit), Item:of(item)
|
|
2591
|
+
end
|
|
2592
|
+
return IgnoreEvent
|
|
2593
|
+
end
|
|
2533
2594
|
)
|
|
2534
2595
|
Unit.itemStackedEvent = __TS__New(
|
|
2535
2596
|
____exports.UnitTriggerEvent,
|
|
@@ -2538,7 +2599,28 @@ Unit.itemStackedEvent = __TS__New(
|
|
|
2538
2599
|
)
|
|
2539
2600
|
__TS__ObjectDefineProperty(
|
|
2540
2601
|
Unit,
|
|
2541
|
-
"
|
|
2602
|
+
"itemUseOrderEvent",
|
|
2603
|
+
{get = function(self)
|
|
2604
|
+
local event = __TS__New(Event)
|
|
2605
|
+
for order = orderId("useslot0"), orderId("useslot5") do
|
|
2606
|
+
local slot = order - orderId("useslot0")
|
|
2607
|
+
local function listener(unit)
|
|
2608
|
+
local item = unit.items[slot + 1]
|
|
2609
|
+
if item ~= nil then
|
|
2610
|
+
invoke(event, unit, item)
|
|
2611
|
+
end
|
|
2612
|
+
end
|
|
2613
|
+
self.onImmediateOrder[order]:addListener(listener)
|
|
2614
|
+
self.onTargetOrder[order]:addListener(listener)
|
|
2615
|
+
self.onPointOrder[order]:addListener(listener)
|
|
2616
|
+
end
|
|
2617
|
+
rawset(self, "itemUseOrderEvent", event)
|
|
2618
|
+
return event
|
|
2619
|
+
end}
|
|
2620
|
+
)
|
|
2621
|
+
__TS__ObjectDefineProperty(
|
|
2622
|
+
Unit,
|
|
2623
|
+
"itemMoveOrderEvent",
|
|
2542
2624
|
{get = function(self)
|
|
2543
2625
|
local event = __TS__New(Event)
|
|
2544
2626
|
for order = orderId("moveslot0"), orderId("moveslot5") do
|
|
@@ -2556,7 +2638,7 @@ __TS__ObjectDefineProperty(
|
|
|
2556
2638
|
end
|
|
2557
2639
|
end)
|
|
2558
2640
|
end
|
|
2559
|
-
rawset(self, "
|
|
2641
|
+
rawset(self, "itemMoveOrderEvent", event)
|
|
2560
2642
|
return event
|
|
2561
2643
|
end}
|
|
2562
2644
|
)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
2
|
local getUnitAbility = BlzGetUnitAbility
|
|
3
3
|
local unitAddAbility = UnitAddAbility
|
|
4
|
+
local unitInventorySize = UnitInventorySize
|
|
5
|
+
local unitItemInSlot = UnitItemInSlot
|
|
4
6
|
local unitMakeAbilityPermanent = UnitMakeAbilityPermanent
|
|
5
7
|
---
|
|
6
8
|
-- @internal For use by internal systems only.
|
|
@@ -10,4 +12,14 @@ ____exports.addInternalAbility = function(unit, abilityTypeId)
|
|
|
10
12
|
end
|
|
11
13
|
return getUnitAbility(unit, abilityTypeId)
|
|
12
14
|
end
|
|
15
|
+
---
|
|
16
|
+
-- @internal For use by internal systems only.
|
|
17
|
+
____exports.findUnitItemSlot = function(unit, item)
|
|
18
|
+
for slot = 0, unitInventorySize(unit) - 1 do
|
|
19
|
+
if item == unitItemInSlot(unit, slot) then
|
|
20
|
+
return slot
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
return nil
|
|
24
|
+
end
|
|
13
25
|
return ____exports
|
package/engine/lightning.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { LightningTypeId } from "./object-data/entry/lightning-type";
|
|
3
|
-
import { Handle, HandleDestructor } from "../core/types/handle";
|
|
4
3
|
import { Unit } from "../core/types/unit";
|
|
4
|
+
import { AbstractDestroyable, Destructor } from "../destroyable";
|
|
5
5
|
declare const enum LightningPropertyKey {
|
|
6
6
|
CHECK_VISIBILITY = 100,
|
|
7
7
|
SOURCE_UNIT = 101,
|
|
@@ -12,10 +12,12 @@ declare const enum LightningPropertyKey {
|
|
|
12
12
|
TARGET_X = 106,
|
|
13
13
|
TARGET_Y = 107,
|
|
14
14
|
TARGET_Z = 108,
|
|
15
|
-
DURATION = 109
|
|
15
|
+
DURATION = 109,
|
|
16
|
+
FADING = 110
|
|
16
17
|
}
|
|
17
18
|
export type LightningConstructor<T extends Lightning> = typeof Lightning & (new (handle: jlightning, typeId: LightningTypeId) => T);
|
|
18
|
-
export declare class Lightning extends
|
|
19
|
+
export declare class Lightning extends AbstractDestroyable {
|
|
20
|
+
readonly handle: jlightning;
|
|
19
21
|
readonly typeId: LightningTypeId;
|
|
20
22
|
private [LightningPropertyKey.CHECK_VISIBILITY]?;
|
|
21
23
|
private [LightningPropertyKey.SOURCE_UNIT]?;
|
|
@@ -27,8 +29,9 @@ export declare class Lightning extends Handle<jlightning> {
|
|
|
27
29
|
private [LightningPropertyKey.TARGET_Y]?;
|
|
28
30
|
private [LightningPropertyKey.TARGET_Z]?;
|
|
29
31
|
private [LightningPropertyKey.DURATION]?;
|
|
32
|
+
private [LightningPropertyKey.FADING]?;
|
|
30
33
|
constructor(handle: jlightning, typeId: LightningTypeId);
|
|
31
|
-
protected onDestroy():
|
|
34
|
+
protected onDestroy(): Destructor;
|
|
32
35
|
static create<T extends Lightning>(this: LightningConstructor<T>, typeId: LightningTypeId, ...parameters: [
|
|
33
36
|
...checkVisibility: [boolean] | [],
|
|
34
37
|
...sourceAndTarget: [sourceX: number, sourceY: number, targetX: number, targetY: number] | [
|
|
@@ -46,6 +49,10 @@ export declare class Lightning extends Handle<jlightning> {
|
|
|
46
49
|
target: Unit
|
|
47
50
|
]
|
|
48
51
|
]): T;
|
|
49
|
-
static flash(...parameters: [
|
|
52
|
+
static flash(...parameters: [
|
|
53
|
+
...parameters: Parameters<(typeof Lightning)["create"]>,
|
|
54
|
+
duration: number,
|
|
55
|
+
fading?: boolean
|
|
56
|
+
]): void;
|
|
50
57
|
}
|
|
51
58
|
export {};
|