A library of utility functions for modding Warcraft 3 utilizing the W3TS template.
npm install warcraft-3-w3ts-utils
npm install wc3-w3ts-utils
`
yarn
`
yarn add wc3-w3ts-utils
`
Or add the files directly to your W3TS project (recommended for custom Warcraft builds).
Usage
Import only what you need:
`ts
import { delayedTimer, unitsInRange, applyForce, useTempEffect } from "wc3-w3ts-utils";
function Rebuke() {
//Blasts unit's near the archmage away, temporarily slowing them
const t = Trigger.create();
t.registerUnitEvent(this.hero, EVENT_UNIT_SPELL_EFFECT);
triggerAction(t, ({ spellId, refId }) => {
if (spellId !== WTS_Abilities.Rebuke) {
return;
}
delayedTimer(0.5, () => {
unitsInRange(this.hero.x, this.hero.y, 350, (unit) => {
if (unit.isAlive() && unit.isEnemy(this.hero.owner)) {
//apply force
const forceAngle = getRelativeAngleToUnit(this.hero, unit);
applyForce(forceAngle, unit, 1800, { obeyPathing: true });
applyStun(1, { contextId: refId, effectId: "archmage-rebuke", unit: unit });
this.hero.damageTarget(unit.handle, 100, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_ROCK_HEAVY_BASH);
}
});
});
const effect = Effect.createAttachment("Units\\NightElf\\Wisp\\WispExplode.mdl", this.hero, "overhead");
effect?.playWithTimeScale(ANIM_TYPE_BIRTH, 2);
useTempEffect(effect);
});
}
``