warscript 0.0.1-dev.0a43a35 → 0.0.1-dev.0eca47c

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.
@@ -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;
@@ -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)
@@ -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
@@ -290,7 +290,6 @@ local function dispatch(event, idGetter, argsGetter)
290
290
  return event[id]
291
291
  end
292
292
  if not initialized then
293
- local invoke = Event.invoke
294
293
  event:addListener(function(...)
295
294
  local id = idGetter(...)
296
295
  local dispatched = rawget(self, id)
@@ -328,7 +327,6 @@ local function dispatchAbility(event)
328
327
  return event[id]
329
328
  end
330
329
  if not initialized then
331
- local invoke = Event.invoke
332
330
  event:addListener(function(unit, ability, ...)
333
331
  local dispatched = rawget(self, ability.typeId)
334
332
  if dispatched ~= nil then
@@ -706,6 +704,10 @@ function Unit.prototype.onDestroy(self)
706
704
  if eventsToDestroy ~= nil then
707
705
  forEach(eventsToDestroy, "destroy")
708
706
  end
707
+ if getUnitAbilityLevel(handle, leaveDetectAbilityId) > 0 then
708
+ unitRemoveAbility(handle, leaveDetectAbilityId)
709
+ removeUnit(handle)
710
+ end
709
711
  return Handle.prototype.onDestroy(self)
710
712
  end
711
713
  function Unit.prototype.addAttackHandler(self, condition, action)
@@ -2060,7 +2062,6 @@ Unit.onDecay = __TS__New(
2060
2062
  Unit.onResurrect = __TS__New(
2061
2063
  InitializingEvent,
2062
2064
  function(event)
2063
- local invoke = Event.invoke
2064
2065
  local dead = setmetatable({}, {__mode = "k"})
2065
2066
  ____exports.Unit.deathEvent:addListener(function(unit)
2066
2067
  dead[unit] = true
@@ -2076,10 +2077,15 @@ Unit.onResurrect = __TS__New(
2076
2077
  Unit.morphEvent = __TS__New(
2077
2078
  InitializingEvent,
2078
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
2079
2086
  ____exports.Unit.onImmediateOrder[orderId("undefend")]:addListener(function(unit)
2080
2087
  if getUnitAbilityLevel(unit.handle, morphDetectAbilityId) == 0 then
2081
- assert(unitAddAbility(unit.handle, morphDetectAbilityId))
2082
- Timer:run(Event.invoke, event, unit)
2088
+ Timer:run(ifNotLeft, unit)
2083
2089
  end
2084
2090
  end)
2085
2091
  end
@@ -2117,7 +2123,6 @@ Unit.onSpellEffect = dispatchId(__TS__New(
2117
2123
  Unit.onTargetCast = dispatchId(__TS__New(
2118
2124
  InitializingEvent,
2119
2125
  function(event)
2120
- local invoke = Event.invoke
2121
2126
  local function listener(unit, id)
2122
2127
  local ____GetSpellTargetUnit_result_8
2123
2128
  if GetSpellTargetUnit() then
@@ -2334,7 +2339,6 @@ Unit.autoAttackStartEvent = __TS__New(
2334
2339
  )
2335
2340
  Unit.onDamaging = (function()
2336
2341
  local event = __TS__New(Event)
2337
- local invoke = Event.invoke
2338
2342
  local trigger = CreateTrigger()
2339
2343
  TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGING)
2340
2344
  TriggerAddCondition(
@@ -2433,7 +2437,6 @@ end)()
2433
2437
  Unit.onDamage = __TS__New(
2434
2438
  InitializingEvent,
2435
2439
  function(event)
2436
- local invoke = Event.invoke
2437
2440
  local trigger = CreateTrigger()
2438
2441
  TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
2439
2442
  TriggerAddCondition(
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") or _VERSION == "Lua 5.1"
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, self.constructor.new)
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.0a43a35",
4
+ "version": "0.0.1-dev.0eca47c",
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.07dd222"
27
+ "warpack": "0.0.1-dev.2c4e71e"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@typescript-eslint/eslint-plugin": "^8.13.0",