warscript 0.0.1-dev.8c7ee30 → 0.0.1-dev.8efec1a
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/core/types/frame.d.ts +2 -0
- package/core/types/frame.lua +2 -0
- package/core/types/handle.lua +2 -0
- package/engine/behaviour/ability/restore-mana.d.ts +15 -0
- package/engine/behaviour/ability/restore-mana.lua +29 -0
- package/engine/game-map.d.ts +7 -0
- package/engine/game-map.lua +32 -0
- package/engine/internal/unit+transport.lua +4 -10
- package/engine/internal/unit.lua +26 -8
- package/lualib_bundle.lua +7 -2
- package/package.json +2 -2
- package/core/mapbounds.d.ts +0 -8
- package/core/mapbounds.lua +0 -12
package/core/types/frame.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ export declare class Frame extends Handle<jframehandle> {
|
|
|
25
25
|
static readonly GAME_UI: Frame;
|
|
26
26
|
static readonly CONSOLE_UI: Frame;
|
|
27
27
|
static readonly CONSOLE_UI_BACKDROP: Frame;
|
|
28
|
+
static readonly CONSOLE_TOP_BAR: Frame;
|
|
29
|
+
static readonly CONSOLE_BOTTOM_BAR: Frame;
|
|
28
30
|
static readonly WORLD: Frame;
|
|
29
31
|
static readonly CHAT: Frame;
|
|
30
32
|
static readonly TIME_OF_DAY_CLOCK: Frame;
|
package/core/types/frame.lua
CHANGED
|
@@ -293,6 +293,8 @@ end
|
|
|
293
293
|
Frame.GAME_UI = ____exports.Frame:byOrigin(ORIGIN_FRAME_GAME_UI)
|
|
294
294
|
Frame.CONSOLE_UI = ____exports.Frame:byOrigin(ORIGIN_FRAME_SIMPLE_UI_PARENT)
|
|
295
295
|
Frame.CONSOLE_UI_BACKDROP = ____exports.Frame:byName("ConsoleUIBackdrop")
|
|
296
|
+
Frame.CONSOLE_TOP_BAR = ____exports.Frame:byName("ConsoleTopBar")
|
|
297
|
+
Frame.CONSOLE_BOTTOM_BAR = ____exports.Frame:byName("ConsoleBottomBar")
|
|
296
298
|
Frame.WORLD = ____exports.Frame:byOrigin(ORIGIN_FRAME_WORLD_FRAME)
|
|
297
299
|
Frame.CHAT = ____exports.Frame:byOrigin(ORIGIN_FRAME_CHAT_MSG)
|
|
298
300
|
Frame.TIME_OF_DAY_CLOCK = ____exports.Frame.GAME_UI:getChild(5):getChild(0)
|
package/core/types/handle.lua
CHANGED
|
@@ -2,6 +2,7 @@ local ____lualib = require("lualib_bundle")
|
|
|
2
2
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
3
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
4
|
local __TS__New = ____lualib.__TS__New
|
|
5
|
+
local __TS__Delete = ____lualib.__TS__Delete
|
|
5
6
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
6
7
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
7
8
|
local ____exports = {}
|
|
@@ -88,6 +89,7 @@ function Handle.prototype.destroy(self, ...)
|
|
|
88
89
|
0
|
|
89
90
|
)
|
|
90
91
|
end
|
|
92
|
+
__TS__Delete(clazz.memoized, id)
|
|
91
93
|
return nil
|
|
92
94
|
end
|
|
93
95
|
function Handle.invokeOnDestroyEvent(self, clazz, handle)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { Ability } from "../../internal/ability";
|
|
3
|
+
import { Unit } from "../../internal/unit";
|
|
4
|
+
import { AbilityDependentValue } from "../../object-field/ability";
|
|
5
|
+
import { AbilityBehavior } from "../ability";
|
|
6
|
+
export declare class RestoreManaSelfAbilityBehavior extends AbilityBehavior {
|
|
7
|
+
private readonly mana;
|
|
8
|
+
constructor(ability: Ability, mana: AbilityDependentValue<number>);
|
|
9
|
+
onImpact(caster: Unit): void;
|
|
10
|
+
}
|
|
11
|
+
export declare class RestoreManaAbilityBehavior extends AbilityBehavior {
|
|
12
|
+
private readonly mana;
|
|
13
|
+
constructor(ability: Ability, mana: AbilityDependentValue<number>);
|
|
14
|
+
onUnitTargetImpact(caster: Unit, target: Unit): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
|
+
local ____exports = {}
|
|
5
|
+
local ____ability = require("engine.behaviour.ability")
|
|
6
|
+
local AbilityBehavior = ____ability.AbilityBehavior
|
|
7
|
+
____exports.RestoreManaSelfAbilityBehavior = __TS__Class()
|
|
8
|
+
local RestoreManaSelfAbilityBehavior = ____exports.RestoreManaSelfAbilityBehavior
|
|
9
|
+
RestoreManaSelfAbilityBehavior.name = "RestoreManaSelfAbilityBehavior"
|
|
10
|
+
__TS__ClassExtends(RestoreManaSelfAbilityBehavior, AbilityBehavior)
|
|
11
|
+
function RestoreManaSelfAbilityBehavior.prototype.____constructor(self, ability, mana)
|
|
12
|
+
AbilityBehavior.prototype.____constructor(self, ability)
|
|
13
|
+
self.mana = mana
|
|
14
|
+
end
|
|
15
|
+
function RestoreManaSelfAbilityBehavior.prototype.onImpact(self, caster)
|
|
16
|
+
caster.mana = caster.mana + self:resolveCurrentAbilityDependentValue(self.mana)
|
|
17
|
+
end
|
|
18
|
+
____exports.RestoreManaAbilityBehavior = __TS__Class()
|
|
19
|
+
local RestoreManaAbilityBehavior = ____exports.RestoreManaAbilityBehavior
|
|
20
|
+
RestoreManaAbilityBehavior.name = "RestoreManaAbilityBehavior"
|
|
21
|
+
__TS__ClassExtends(RestoreManaAbilityBehavior, AbilityBehavior)
|
|
22
|
+
function RestoreManaAbilityBehavior.prototype.____constructor(self, ability, mana)
|
|
23
|
+
AbilityBehavior.prototype.____constructor(self, ability)
|
|
24
|
+
self.mana = mana
|
|
25
|
+
end
|
|
26
|
+
function RestoreManaAbilityBehavior.prototype.onUnitTargetImpact(self, caster, target)
|
|
27
|
+
target.mana = target.mana + self:resolveCurrentAbilityDependentValue(self.mana)
|
|
28
|
+
end
|
|
29
|
+
return ____exports
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
4
|
+
local ____exports = {}
|
|
5
|
+
local ____rect = require("core.types.rect")
|
|
6
|
+
local Rect = ____rect.Rect
|
|
7
|
+
local ____region = require("core.types.region")
|
|
8
|
+
local Region = ____region.Region
|
|
9
|
+
____exports.GameMap = __TS__Class()
|
|
10
|
+
local GameMap = ____exports.GameMap
|
|
11
|
+
GameMap.name = "GameMap"
|
|
12
|
+
function GameMap.prototype.____constructor(self)
|
|
13
|
+
end
|
|
14
|
+
__TS__ObjectDefineProperty(
|
|
15
|
+
GameMap,
|
|
16
|
+
"worldBoundsRect",
|
|
17
|
+
{get = function(self)
|
|
18
|
+
local rect = Rect:of(GetWorldBounds())
|
|
19
|
+
rawset(self, "worldBoundsRect", rect)
|
|
20
|
+
return rect
|
|
21
|
+
end}
|
|
22
|
+
)
|
|
23
|
+
__TS__ObjectDefineProperty(
|
|
24
|
+
GameMap,
|
|
25
|
+
"worldBoundsRegion",
|
|
26
|
+
{get = function(self)
|
|
27
|
+
local region = Region:create(self.worldBoundsRect)
|
|
28
|
+
rawset(self, "worldBoundsRegion", region)
|
|
29
|
+
return region
|
|
30
|
+
end}
|
|
31
|
+
)
|
|
32
|
+
return ____exports
|
|
@@ -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)
|
package/engine/internal/unit.lua
CHANGED
|
@@ -6,6 +6,7 @@ local __TS__New = ____lualib.__TS__New
|
|
|
6
6
|
local __TS__Class = ____lualib.__TS__Class
|
|
7
7
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
8
8
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
9
|
+
local __TS__ArraySetLength = ____lualib.__TS__ArraySetLength
|
|
9
10
|
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
|
|
10
11
|
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
|
|
11
12
|
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
|
|
@@ -289,7 +290,6 @@ local function dispatch(event, idGetter, argsGetter)
|
|
|
289
290
|
return event[id]
|
|
290
291
|
end
|
|
291
292
|
if not initialized then
|
|
292
|
-
local invoke = Event.invoke
|
|
293
293
|
event:addListener(function(...)
|
|
294
294
|
local id = idGetter(...)
|
|
295
295
|
local dispatched = rawget(self, id)
|
|
@@ -327,7 +327,6 @@ local function dispatchAbility(event)
|
|
|
327
327
|
return event[id]
|
|
328
328
|
end
|
|
329
329
|
if not initialized then
|
|
330
|
-
local invoke = Event.invoke
|
|
331
330
|
event:addListener(function(unit, ability, ...)
|
|
332
331
|
local dispatched = rawget(self, ability.typeId)
|
|
333
332
|
if dispatched ~= nil then
|
|
@@ -686,6 +685,11 @@ function Unit.prototype.onDestroy(self)
|
|
|
686
685
|
if not self._owner then
|
|
687
686
|
self._owner = Player:of(getOwningPlayer(handle))
|
|
688
687
|
end
|
|
688
|
+
local abilities = self.abilities
|
|
689
|
+
for ____, ability in ipairs(abilities) do
|
|
690
|
+
ability:destroy()
|
|
691
|
+
end
|
|
692
|
+
__TS__ArraySetLength(abilities, 0)
|
|
689
693
|
for ____, player in ipairs(Player.all) do
|
|
690
694
|
if self:isSelected(player) then
|
|
691
695
|
Event.invoke(____exports.Unit.onDeselect, self, player)
|
|
@@ -700,6 +704,10 @@ function Unit.prototype.onDestroy(self)
|
|
|
700
704
|
if eventsToDestroy ~= nil then
|
|
701
705
|
forEach(eventsToDestroy, "destroy")
|
|
702
706
|
end
|
|
707
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) > 0 then
|
|
708
|
+
unitRemoveAbility(handle, leaveDetectAbilityId)
|
|
709
|
+
removeUnit(handle)
|
|
710
|
+
end
|
|
703
711
|
return Handle.prototype.onDestroy(self)
|
|
704
712
|
end
|
|
705
713
|
function Unit.prototype.addAttackHandler(self, condition, action)
|
|
@@ -2054,7 +2062,6 @@ Unit.onDecay = __TS__New(
|
|
|
2054
2062
|
Unit.onResurrect = __TS__New(
|
|
2055
2063
|
InitializingEvent,
|
|
2056
2064
|
function(event)
|
|
2057
|
-
local invoke = Event.invoke
|
|
2058
2065
|
local dead = setmetatable({}, {__mode = "k"})
|
|
2059
2066
|
____exports.Unit.deathEvent:addListener(function(unit)
|
|
2060
2067
|
dead[unit] = true
|
|
@@ -2070,10 +2077,15 @@ Unit.onResurrect = __TS__New(
|
|
|
2070
2077
|
Unit.morphEvent = __TS__New(
|
|
2071
2078
|
InitializingEvent,
|
|
2072
2079
|
function(event)
|
|
2080
|
+
local function ifNotLeft(unit)
|
|
2081
|
+
local handle = unit.handle
|
|
2082
|
+
if getUnitAbilityLevel(handle, leaveDetectAbilityId) ~= 0 and unitAddAbility(handle, morphDetectAbilityId) then
|
|
2083
|
+
invoke(event, unit)
|
|
2084
|
+
end
|
|
2085
|
+
end
|
|
2073
2086
|
____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
|
|
2074
2087
|
if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
|
|
2075
|
-
|
|
2076
|
-
Timer:run(Event.invoke, event, unit)
|
|
2088
|
+
Timer:run(ifNotLeft, unit)
|
|
2077
2089
|
end
|
|
2078
2090
|
end)
|
|
2079
2091
|
end
|
|
@@ -2111,7 +2123,6 @@ Unit.onSpellEffect = dispatchId(__TS__New(
|
|
|
2111
2123
|
Unit.onTargetCast = dispatchId(__TS__New(
|
|
2112
2124
|
InitializingEvent,
|
|
2113
2125
|
function(event)
|
|
2114
|
-
local invoke = Event.invoke
|
|
2115
2126
|
local function listener(unit, id)
|
|
2116
2127
|
local ____GetSpellTargetUnit_result_8
|
|
2117
2128
|
if GetSpellTargetUnit() then
|
|
@@ -2328,7 +2339,6 @@ Unit.autoAttackStartEvent = __TS__New(
|
|
|
2328
2339
|
)
|
|
2329
2340
|
Unit.onDamaging = (function()
|
|
2330
2341
|
local event = __TS__New(Event)
|
|
2331
|
-
local invoke = Event.invoke
|
|
2332
2342
|
local trigger = CreateTrigger()
|
|
2333
2343
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
|
|
2334
2344
|
TriggerAddCondition(
|
|
@@ -2427,7 +2437,6 @@ end)()
|
|
|
2427
2437
|
Unit.onDamage = __TS__New(
|
|
2428
2438
|
InitializingEvent,
|
|
2429
2439
|
function(event)
|
|
2430
|
-
local invoke = Event.invoke
|
|
2431
2440
|
local trigger = CreateTrigger()
|
|
2432
2441
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
|
|
2433
2442
|
TriggerAddCondition(
|
|
@@ -2567,6 +2576,15 @@ __TS__ObjectDefineProperty(
|
|
|
2567
2576
|
orderId("magicundefense"),
|
|
2568
2577
|
orderId("unimmolation")
|
|
2569
2578
|
}) do
|
|
2579
|
+
____exports.Unit.onImmediateOrder[leaveOrderId]:addListener(function(unit)
|
|
2580
|
+
local handle = unit.handle
|
|
2581
|
+
for i = 1, #leaveAbilityIds do
|
|
2582
|
+
if getUnitAbilityLevel(handle, leaveAbilityIds[i]) ~= 0 then
|
|
2583
|
+
return
|
|
2584
|
+
end
|
|
2585
|
+
end
|
|
2586
|
+
unit:destroy()
|
|
2587
|
+
end)
|
|
2570
2588
|
end
|
|
2571
2589
|
end)(Unit)
|
|
2572
2590
|
return ____exports
|
package/lualib_bundle.lua
CHANGED
|
@@ -1094,6 +1094,11 @@ do
|
|
|
1094
1094
|
end
|
|
1095
1095
|
if __TS__StringIncludes(_VERSION, "Lua 5.0") then
|
|
1096
1096
|
return debug.traceback(("[Level " .. tostring(level)) .. "]")
|
|
1097
|
+
elseif _VERSION == "Lua 5.1" then
|
|
1098
|
+
return string.sub(
|
|
1099
|
+
debug.traceback("", level),
|
|
1100
|
+
2
|
|
1101
|
+
)
|
|
1097
1102
|
else
|
|
1098
1103
|
return debug.traceback(nil, level)
|
|
1099
1104
|
end
|
|
@@ -1102,7 +1107,7 @@ do
|
|
|
1102
1107
|
return function(self)
|
|
1103
1108
|
local description = getDescription(self)
|
|
1104
1109
|
local caller = debug.getinfo(3, "f")
|
|
1105
|
-
local isClassicLua = __TS__StringIncludes(_VERSION, "Lua 5.0")
|
|
1110
|
+
local isClassicLua = __TS__StringIncludes(_VERSION, "Lua 5.0")
|
|
1106
1111
|
if isClassicLua or caller and caller.func ~= error then
|
|
1107
1112
|
return description
|
|
1108
1113
|
else
|
|
@@ -1126,7 +1131,7 @@ do
|
|
|
1126
1131
|
end
|
|
1127
1132
|
self.message = message
|
|
1128
1133
|
self.name = "Error"
|
|
1129
|
-
self.stack = getErrorStack(nil,
|
|
1134
|
+
self.stack = getErrorStack(nil, __TS__New)
|
|
1130
1135
|
local metatable = getmetatable(self)
|
|
1131
1136
|
if metatable and not metatable.__errorToStringPatched then
|
|
1132
1137
|
metatable.__errorToStringPatched = true
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "warscript",
|
|
4
|
-
"version": "0.0.1-dev.
|
|
4
|
+
"version": "0.0.1-dev.8efec1a",
|
|
5
5
|
"description": "A typescript library for Warcraft III using Warpack.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"warcraft",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@warscript/language-extensions": "^0.0.1",
|
|
25
25
|
"@warscript/tstl-plugin": "^0.0.4",
|
|
26
26
|
"lua-types": "^2.13.1",
|
|
27
|
-
"warpack": "0.0.1-dev.
|
|
27
|
+
"warpack": "0.0.1-dev.2c4e71e"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
package/core/mapbounds.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** @noSelfInFile */
|
|
2
|
-
import { Rect } from "./types/rect";
|
|
3
|
-
import { Region } from "./types/region";
|
|
4
|
-
export declare const boundRect: Rect;
|
|
5
|
-
export declare const boundRegion: Region;
|
|
6
|
-
export declare const boundMin: Readonly<Vec2>;
|
|
7
|
-
export declare const boundMax: Readonly<Vec2>;
|
|
8
|
-
export declare const boundCenter: Readonly<Vec2>;
|
package/core/mapbounds.lua
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
local ____exports = {}
|
|
2
|
-
local ____rect = require("core.types.rect")
|
|
3
|
-
local Rect = ____rect.Rect
|
|
4
|
-
local ____region = require("core.types.region")
|
|
5
|
-
local Region = ____region.Region
|
|
6
|
-
____exports.boundRect = Rect:of(GetWorldBounds())
|
|
7
|
-
____exports.boundRegion = Region:create()
|
|
8
|
-
____exports.boundRegion:addRect(____exports.boundRect)
|
|
9
|
-
____exports.boundMin = vec2(____exports.boundRect.minX, ____exports.boundRect.minY)
|
|
10
|
-
____exports.boundMax = vec2(____exports.boundRect.maxX, ____exports.boundRect.maxY)
|
|
11
|
-
____exports.boundCenter = (____exports.boundMin + ____exports.boundMax) * 0.5
|
|
12
|
-
return ____exports
|