- Joined
- Mar 31, 2023
- Messages
- 4
Hello, first time posting a question here so forgive me if this isn't the right place. I'm currently learning WC3 modding, and have a TypeScript project setup with
Here's the relevant snippet:
The expected behavior is that whenever a unit owned by player 24 dies, the word "kill" is written to chat. This has not been the case for me, instead what I'm observing is that the first 1-3 kills are correctly noted, and then... The message just stops appearing. Elsewhere in my project I'm spawning enemy units in a more involved function, but the relevant lines can be seen here:
The above code runs on an interval, and it is correctly working. I'm not sure why my trigger suddenly just stops firing. There isn't much else going on in this project, this is the only actual trigger. Any hints or suggestions would be greatly appreciated. I'm wondering if the generated boilerplate of
w3ts
. My project is in its very early stages, so there isn't a whole lot going on. The code is working for the most part, however one of my triggers appears to stop working mid-game.Here's the relevant snippet:
TypeScript:
import { Trigger } from 'w3ts';
// In the Warcraft III Editor I've placed player 24 in a separate force to the players
export const AI_PLAYER = MapPlayer.fromHandle(Player(23));
// This function is imported in a `main.ts` file and executed immediately in global scope
export function createOnKillTrigger() {
const onKillTrigger = new Trigger();
onKillTrigger.registerPlayerUnitEvent(AI_PLAYER, EVENT_PLAYER_UNIT_DEATH, () => true);
onKillTrigger.addAction(() => onKillAction());
}
// Simply echo to all players that a unit owned by player 24 has died
function onKillAction() {
print('kill');
}
The expected behavior is that whenever a unit owned by player 24 dies, the word "kill" is written to chat. This has not been the case for me, instead what I'm observing is that the first 1-3 kills are correctly noted, and then... The message just stops appearing. Elsewhere in my project I'm spawning enemy units in a more involved function, but the relevant lines can be seen here:
TypeScript:
// The `spawnLocation` and `playerUnitLocation` variables are valid locations, since the units spawn successfully
const group = new Group();
for (let i = 0; i < unitCount; i++) {
const enemyUnit = new Unit(AI_PLAYER, FourCC('h000'), GetLocationX(spawnLocation), GetLocationY(spawnLocation), 0);
enemyUnit.setFacingEx(AngleBetweenPoints(spawnLocation, playerUnitLocation));
group.addUnit(enemyUnit);
}
group.orderTarget(OrderId.Attack, playerUnit);
The above code runs on an interval, and it is correctly working. I'm not sure why my trigger suddenly just stops firing. There isn't much else going on in this project, this is the only actual trigger. Any hints or suggestions would be greatly appreciated. I'm wondering if the generated boilerplate of
w3ts
is just too much for WC3? I don't know how anyone is supposed to use the library in that case, but if that is so, then I'll most likely switch to using Lua or JASS directly.