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.
- package/dist/index.lua +0 -2
- package/dist/index.lua.map +1 -0
- package/dist/package.json +3 -4
- package/dist/utils/abilities.lua +0 -2
- package/dist/utils/abilities.lua.map +1 -0
- package/dist/utils/camera.lua +0 -2
- package/dist/utils/camera.lua.map +1 -0
- package/dist/utils/chat-command.lua +0 -2
- package/dist/utils/chat-command.lua.map +1 -0
- package/dist/utils/color.lua +0 -2
- package/dist/utils/color.lua.map +1 -0
- package/dist/utils/index.lua +0 -2
- package/dist/utils/index.lua.map +1 -0
- package/dist/utils/item.lua +0 -2
- package/dist/utils/item.lua.map +1 -0
- package/dist/utils/math.lua +0 -2
- package/dist/utils/math.lua.map +1 -0
- package/dist/utils/minimapIcons.lua +0 -2
- package/dist/utils/minimapIcons.lua.map +1 -0
- package/dist/utils/misc.lua +0 -2
- package/dist/utils/misc.lua.map +1 -0
- package/dist/utils/physics.lua +0 -2
- package/dist/utils/physics.lua.map +1 -0
- package/dist/utils/players.lua +0 -2
- package/dist/utils/players.lua.map +1 -0
- package/dist/utils/point.lua +0 -2
- package/dist/utils/point.lua.map +1 -0
- package/dist/utils/quests.lua +0 -2
- package/dist/utils/quests.lua.map +1 -0
- package/dist/utils/textTag.lua +0 -2
- package/dist/utils/textTag.lua.map +1 -0
- package/dist/utils/timer.lua +0 -2
- package/dist/utils/timer.lua.map +1 -0
- package/dist/utils/units.lua +0 -2
- package/dist/utils/units.lua.map +1 -0
- package/package.json +3 -4
- package/src/index.ts +0 -1
- package/src/utils/abilities.ts +0 -158
- package/src/utils/camera.ts +0 -63
- package/src/utils/chat-command.ts +0 -22
- package/src/utils/color.ts +0 -139
- package/src/utils/index.ts +0 -15
- package/src/utils/item.ts +0 -163
- package/src/utils/math.ts +0 -14
- package/src/utils/minimapIcons.ts +0 -34
- package/src/utils/misc.ts +0 -179
- package/src/utils/physics.ts +0 -295
- package/src/utils/players.ts +0 -213
- package/src/utils/point.ts +0 -81
- package/src/utils/quests.ts +0 -38
- package/src/utils/textTag.ts +0 -80
- package/src/utils/timer.ts +0 -14
- package/src/utils/units.ts +0 -84
package/src/utils/timer.ts
DELETED
|
@@ -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
|
-
}
|
package/src/utils/units.ts
DELETED
|
@@ -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
|
-
}
|