warcraft-3-w3ts-utils 0.1.13 → 0.1.15

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.
Files changed (53) hide show
  1. package/dist/index.lua +0 -2
  2. package/dist/index.lua.map +1 -0
  3. package/dist/package.json +3 -4
  4. package/dist/utils/abilities.lua +0 -2
  5. package/dist/utils/abilities.lua.map +1 -0
  6. package/dist/utils/camera.lua +0 -2
  7. package/dist/utils/camera.lua.map +1 -0
  8. package/dist/utils/chat-command.lua +0 -2
  9. package/dist/utils/chat-command.lua.map +1 -0
  10. package/dist/utils/color.lua +0 -2
  11. package/dist/utils/color.lua.map +1 -0
  12. package/dist/utils/index.lua +0 -2
  13. package/dist/utils/index.lua.map +1 -0
  14. package/dist/utils/item.lua +0 -2
  15. package/dist/utils/item.lua.map +1 -0
  16. package/dist/utils/math.lua +0 -2
  17. package/dist/utils/math.lua.map +1 -0
  18. package/dist/utils/minimapIcons.lua +0 -2
  19. package/dist/utils/minimapIcons.lua.map +1 -0
  20. package/dist/utils/misc.lua +0 -2
  21. package/dist/utils/misc.lua.map +1 -0
  22. package/dist/utils/physics.lua +0 -2
  23. package/dist/utils/physics.lua.map +1 -0
  24. package/dist/utils/players.lua +0 -2
  25. package/dist/utils/players.lua.map +1 -0
  26. package/dist/utils/point.lua +0 -2
  27. package/dist/utils/point.lua.map +1 -0
  28. package/dist/utils/quests.lua +0 -2
  29. package/dist/utils/quests.lua.map +1 -0
  30. package/dist/utils/textTag.lua +0 -2
  31. package/dist/utils/textTag.lua.map +1 -0
  32. package/dist/utils/timer.lua +0 -2
  33. package/dist/utils/timer.lua.map +1 -0
  34. package/dist/utils/units.lua +0 -2
  35. package/dist/utils/units.lua.map +1 -0
  36. package/package.json +3 -4
  37. package/src/index.ts +0 -1
  38. package/src/utils/abilities.ts +0 -158
  39. package/src/utils/camera.ts +0 -63
  40. package/src/utils/chat-command.ts +0 -22
  41. package/src/utils/color.ts +0 -139
  42. package/src/utils/index.ts +0 -15
  43. package/src/utils/item.ts +0 -163
  44. package/src/utils/math.ts +0 -14
  45. package/src/utils/minimapIcons.ts +0 -34
  46. package/src/utils/misc.ts +0 -179
  47. package/src/utils/physics.ts +0 -295
  48. package/src/utils/players.ts +0 -213
  49. package/src/utils/point.ts +0 -81
  50. package/src/utils/quests.ts +0 -38
  51. package/src/utils/textTag.ts +0 -80
  52. package/src/utils/timer.ts +0 -14
  53. package/src/utils/units.ts +0 -84
@@ -1,14 +0,0 @@
1
- import { Timer } from "w3ts";
2
-
3
- /**
4
- * @param duration milliseconds
5
- */
6
- export function delayedTimer(duration: number, cb: (...args: any[]) => any) {
7
- const timer = Timer.create();
8
- timer.start(duration, false, () => {
9
- cb();
10
- timer.destroy();
11
- });
12
-
13
- return timer;
14
- }
@@ -1,84 +0,0 @@
1
- import { Group, MapPlayer, Timer, Unit } from "w3ts";
2
- import { adjustGold, adjustLumber } from "./players";
3
-
4
- export function createUnits(quantity: number, useFood: boolean, ...args: Parameters<typeof Unit.create>) {
5
- const units: Unit[] = [];
6
- for (let x = 0; x < quantity; x++) {
7
- const u = Unit.create(...args);
8
-
9
- if (u) {
10
- u.setUseFood(useFood);
11
- units.push(u);
12
- }
13
- }
14
-
15
- return units;
16
- }
17
-
18
- /**
19
- * Refund unit's gold and wood cost.
20
- * @param u
21
- */
22
- export function refundUnitCost(u: Unit) {
23
- const gold = GetUnitGoldCost(u.typeId);
24
- const wood = GetUnitWoodCost(u.typeId);
25
- adjustGold(u.owner, gold);
26
- adjustLumber(u.owner, wood);
27
- }
28
-
29
- /**
30
- * Returns true if the ALIVE unit has the ability within their first 12 abilities
31
- * @param unit
32
- * @param abilityId
33
- * @returns
34
- */
35
- export function unitHasAbility(unit: Unit, abilityId: number): boolean {
36
- for (let x = 0; x < 12; x++) {
37
- const currentAbility = unit.getAbilityByIndex(x);
38
-
39
- if (currentAbility && currentAbility === unit.getAbility(abilityId) && unit.isAlive()) {
40
- return true;
41
- }
42
- }
43
-
44
- return false;
45
- }
46
-
47
- export function unitsInRange(x: number, y: number, radius: number, cb: (unit: Unit) => void) {
48
- const g = Group.create();
49
- if (g) {
50
- g.enumUnitsInRange(x, y, radius, () => {
51
- const unit = Unit.fromFilter();
52
- if (unit) {
53
- cb(unit);
54
- }
55
- return true;
56
- });
57
-
58
- g.destroy();
59
- }
60
- }
61
-
62
- /**
63
- *
64
- * @param cb
65
- * @param abilityId
66
- * @param owner
67
- */
68
- export function useTempDummyUnit(dummyUnitCode: number, cb: (dummy: Unit) => void, abilityId: number, owner: MapPlayer, x: number, y: number, config?: { facing?: number; abilityLevel?: number; dummyLifeSpan?: number }) {
69
- let dummy: Unit | undefined = undefined;
70
- dummy = Unit.create(owner, dummyUnitCode, x, y, config?.facing ?? 0);
71
-
72
- const t = Timer.create();
73
-
74
- if (dummy) {
75
- dummy.addAbility(abilityId);
76
- dummy.setAbilityManaCost(abilityId, config?.abilityLevel ? config.abilityLevel - 1 : 0, 0);
77
- cb(dummy);
78
-
79
- t.start(config?.dummyLifeSpan ?? 2, false, () => {
80
- dummy?.destroy();
81
- t.destroy();
82
- });
83
- }
84
- }