warscript 0.0.1-dev.29b3feb → 0.0.1-dev.3599429

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.
@@ -26,11 +26,8 @@ local getSpellTargetUnit = GetSpellTargetUnit
26
26
  local getSpellTargetX = GetSpellTargetX
27
27
  local getSpellTargetY = GetSpellTargetY
28
28
  local getTriggerUnit = GetTriggerUnit
29
- local getUnitAbility = BlzGetUnitAbility
30
- local unitAddAbility = UnitAddAbility
31
29
  local unitInventorySize = UnitInventorySize
32
30
  local unitItemInSlot = UnitItemInSlot
33
- local unitRemoveAbility = UnitRemoveAbility
34
31
  local function retrieveAbility(unit, ability, abilityId)
35
32
  if ability == nil then
36
33
  return __TS__New(
@@ -39,17 +36,6 @@ local function retrieveAbility(unit, ability, abilityId)
39
36
  Unit:of(unit)
40
37
  )
41
38
  end
42
- if not unitAddAbility(unit, abilityId) then
43
- if getUnitAbility(unit, abilityId) == ability then
44
- return UnitAbility:of(
45
- ability,
46
- abilityId,
47
- Unit:of(unit)
48
- )
49
- end
50
- else
51
- unitRemoveAbility(unit, abilityId)
52
- end
53
39
  for i = 0, unitInventorySize(unit) - 1 do
54
40
  local item = unitItemInSlot(unit, i)
55
41
  if getItemAbility(item, abilityId) == ability then
@@ -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
- mainSelectedUnitByPlayer[Player:of(GetTriggerPlayer())] = Unit:getBySyncId(BlzGetTriggerFrameValue())
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(
@@ -562,17 +562,6 @@ local function retrieveAbility(unit, ability, abilityId)
562
562
  ____exports.Unit:of(unit)
563
563
  )
564
564
  end
565
- if not unitAddAbility(unit, abilityId) then
566
- if getUnitAbility(unit, abilityId) == ability then
567
- return UnitAbility:of(
568
- ability,
569
- abilityId,
570
- ____exports.Unit:of(unit)
571
- )
572
- end
573
- else
574
- unitRemoveAbility(unit, abilityId)
575
- end
576
565
  for i = 0, unitInventorySize(unit) - 1 do
577
566
  local item = unitItemInSlot(unit, i)
578
567
  if getItemAbility(item, abilityId) == ability then
@@ -2552,8 +2541,8 @@ __TS__ObjectDefineProperty(
2552
2541
  "itemMovedEvent",
2553
2542
  {get = function(self)
2554
2543
  local event = __TS__New(Event)
2555
- for order = orderId("moveslot1"), orderId("moveslot5") do
2556
- local slotTo = order - orderId("moveslot1")
2544
+ for order = orderId("moveslot0"), orderId("moveslot5") do
2545
+ local slotTo = order - orderId("moveslot0")
2557
2546
  self.onTargetOrder[order]:addListener(function(unit, item)
2558
2547
  local slotFrom = unit.items:findSlot(item)
2559
2548
  if slotFrom ~= nil then
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.29b3feb",
4
+ "version": "0.0.1-dev.3599429",
5
5
  "description": "A typescript library for Warcraft III using Warpack.",
6
6
  "keywords": [
7
7
  "warcraft",