|
|
@@ -29,73 +29,73 @@ class unitTracker {
|
|
|
// sentinel "shapeId": 730500
|
|
|
|
|
|
Object.assign(this, {
|
|
|
- "collections": new Map(),
|
|
|
- "drop": new Map(),
|
|
|
- "servants": new Map(),
|
|
|
- "users": new Map(),
|
|
|
- "npcs": new Map(),
|
|
|
- "summons": new Map()
|
|
|
+ "spawnedCollections": new Map(),
|
|
|
+ "spawnedDrop": new Map(),
|
|
|
+ "spawnedServants": new Map(),
|
|
|
+ "spawnedPlayers": new Map(),
|
|
|
+ "spawnedNPCS": new Map(),
|
|
|
+ "spawnedSummons": new Map()
|
|
|
});
|
|
|
|
|
|
const dropHandler = (type, event) => {
|
|
|
switch (type) {
|
|
|
- case (ENTITY_HOOK_TYPE.DESPAWN): this.drop.delete(event.gameId); break;
|
|
|
- case (ENTITY_HOOK_TYPE.SPAWN): this.drop.set(event.gameId, event); break;
|
|
|
+ case (ENTITY_HOOK_TYPE.DESPAWN): this.spawnedDrop.delete(event.gameId); break;
|
|
|
+ case (ENTITY_HOOK_TYPE.SPAWN): this.spawnedDrop.set(event.gameId, event); break;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const collectionHandler = (type, event) => {
|
|
|
switch (type) {
|
|
|
- case (ENTITY_HOOK_TYPE.DESPAWN): this.collections.delete(event.gameId); break;
|
|
|
- case (ENTITY_HOOK_TYPE.SPAWN): this.collections.set(event.gameId, event); break;
|
|
|
+ case (ENTITY_HOOK_TYPE.DESPAWN): this.spawnedCollections.delete(event.gameId); break;
|
|
|
+ case (ENTITY_HOOK_TYPE.SPAWN): this.spawnedCollections.set(event.gameId, event); break;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const servantsHandler = (type, event) => {
|
|
|
switch (type) {
|
|
|
- case (ENTITY_HOOK_TYPE.DESPAWN): this.servants.delete(event.gameId); break;
|
|
|
- case (ENTITY_HOOK_TYPE.SPAWN): this.servants.set(event.gameId, event); break;
|
|
|
+ case (ENTITY_HOOK_TYPE.DESPAWN): this.spawnedServants.delete(event.gameId); break;
|
|
|
+ case (ENTITY_HOOK_TYPE.SPAWN): this.spawnedServants.set(event.gameId, event); break;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const userHandler = (type, event) => {
|
|
|
switch (type) {
|
|
|
- case (ENTITY_HOOK_TYPE.DESPAWN): this.users.delete(event.gameId); break;
|
|
|
- case (ENTITY_HOOK_TYPE.SPAWN): this.users.set(event.gameId, event); break;
|
|
|
+ case (ENTITY_HOOK_TYPE.DESPAWN): this.spawnedPlayers.delete(event.gameId); break;
|
|
|
+ case (ENTITY_HOOK_TYPE.SPAWN): this.spawnedPlayers.set(event.gameId, event); break;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const npcHandler = (type, event) => {
|
|
|
switch (type) {
|
|
|
case (ENTITY_HOOK_TYPE.DESPAWN):
|
|
|
- this.npcs.delete(event.gameId);
|
|
|
- this.summons.delete(event.gameId);
|
|
|
+ this.spawnedNPCS.delete(event.gameId);
|
|
|
+ this.spawnedSummons.delete(event.gameId);
|
|
|
break;
|
|
|
case (ENTITY_HOOK_TYPE.SPAWN):
|
|
|
// eslint-disable-next-line no-magic-numbers
|
|
|
- if (event.huntingZoneId === SPECIAL_ZONES.HELPERS && this.users.has(event.owner)) {
|
|
|
- this.summons.set(event.gameId, event);
|
|
|
+ if (event.huntingZoneId === SPECIAL_ZONES.HELPERS && this.spawnedPlayers.has(event.owner)) {
|
|
|
+ this.spawnedSummons.set(event.gameId, event);
|
|
|
}
|
|
|
else {
|
|
|
- this.npcs.set(event.gameId, event);
|
|
|
+ this.spawnedNPCS.set(event.gameId, event);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const userMounted = (type, event) => {
|
|
|
- if (this.users.has(event.gameId)) {
|
|
|
+ if (this.spawnedPlayers.has(event.gameId)) {
|
|
|
let data = undefined;
|
|
|
switch (type) {
|
|
|
case (ENTITY_HOOK_TYPE.DESPAWN):
|
|
|
- data = this.users.get(event.gameId);
|
|
|
+ data = this.spawnedPlayers.get(event.gameId);
|
|
|
data.mount = 0;
|
|
|
- this.users.set(event.gameId, data);
|
|
|
+ this.spawnedPlayers.set(event.gameId, data);
|
|
|
break;
|
|
|
case (ENTITY_HOOK_TYPE.SPAWN):
|
|
|
- data = this.users.get(event.gameId);
|
|
|
+ data = this.spawnedPlayers.get(event.gameId);
|
|
|
data.mount = event.id;
|
|
|
- this.users.set(event.gameId, data);
|
|
|
+ this.spawnedPlayers.set(event.gameId, data);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -107,46 +107,46 @@ class unitTracker {
|
|
|
|
|
|
const updateAngleHandler = (event) => {
|
|
|
let gameId = event.gameId;
|
|
|
- if (this.users.has(gameId)) this.users.set(gameId, updateAngle(this.users.get(gameId), event.w));
|
|
|
- else if (this.npcs.has(gameId)) this.npcs.set(gameId, updateAngle(this.npcs.get(gameId), event.w));
|
|
|
- else if (this.summons.has(gameId)) this.summons.set(gameId, updateAngle(this.summons.get(gameId), event.w));
|
|
|
+ if (this.spawnedPlayers.has(gameId)) this.spawnedPlayers.set(gameId, updateAngle(this.spawnedPlayers.get(gameId), event.w));
|
|
|
+ else if (this.spawnedNPCS.has(gameId)) this.spawnedNPCS.set(gameId, updateAngle(this.spawnedNPCS.get(gameId), event.w));
|
|
|
+ else if (this.spawnedSummons.has(gameId)) this.spawnedSummons.set(gameId, updateAngle(this.spawnedSummons.get(gameId), event.w));
|
|
|
};
|
|
|
|
|
|
|
|
|
const userLocationHandler = (event) => {
|
|
|
- if (this.users.has(event.gameId)) {
|
|
|
- this.users.set(event.gameId, updateLoc(this.users.get(event.gameId), event.loc));
|
|
|
+ if (this.spawnedPlayers.has(event.gameId)) {
|
|
|
+ this.spawnedPlayers.set(event.gameId, updateLoc(this.spawnedPlayers.get(event.gameId), event.loc));
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const npcLocationHandler = (event) => {
|
|
|
- if (this.npcs.has(event.gameId)) {
|
|
|
- this.npcs.set(event.gameId, updateLoc(this.npcs.get(event.gameId), event.loc));
|
|
|
+ if (this.spawnedNPCS.has(event.gameId)) {
|
|
|
+ this.spawnedNPCS.set(event.gameId, updateLoc(this.spawnedNPCS.get(event.gameId), event.loc));
|
|
|
}
|
|
|
- else if (this.summons.has(event.gameId)) {
|
|
|
- this.summons.set(event.gameId, updateLoc(this.summons.get(event.gameId), event.loc));
|
|
|
+ else if (this.spawnedSummons.has(event.gameId)) {
|
|
|
+ this.spawnedSummons.set(event.gameId, updateLoc(this.spawnedSummons.get(event.gameId), event.loc));
|
|
|
}
|
|
|
- else if (this.servants.has(event.gameId)) {
|
|
|
- this.servants.set(event.gameId, updateLoc(this.servants.get(event.gameId), event.loc));
|
|
|
+ else if (this.spawnedServants.has(event.gameId)) {
|
|
|
+ this.spawnedServants.set(event.gameId, updateLoc(this.spawnedServants.get(event.gameId), event.loc));
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const creatureLifeHandler = (event) => {
|
|
|
- if (this.users.has(event.gameId)) {
|
|
|
- let data = this.users.get(event.gameId);
|
|
|
+ if (this.spawnedPlayers.has(event.gameId)) {
|
|
|
+ let data = this.spawnedPlayers.get(event.gameId);
|
|
|
data.alive = event.alive;
|
|
|
- this.users.set(event.gameId, data);
|
|
|
+ this.spawnedPlayers.set(event.gameId, data);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const cleanup = () => {
|
|
|
console.log("DEBUG: unitTracker -> cleanup");
|
|
|
- this.npcs.clear();
|
|
|
- this.summons.clear();
|
|
|
- this.users.clear();
|
|
|
- this.servants.clear();
|
|
|
- this.collections.clear();
|
|
|
- this.drop.clear();
|
|
|
+ this.spawnedNPCS.clear();
|
|
|
+ this.spawnedSummons.clear();
|
|
|
+ this.spawnedPlayers.clear();
|
|
|
+ this.spawnedServants.clear();
|
|
|
+ this.spawnedCollections.clear();
|
|
|
+ this.spawnedDrop.clear();
|
|
|
};
|
|
|
|
|
|
mod.hook(...proto.getData("S_CREATURE_ROTATE"), HOOK_SETTINGS.FIRST, updateAngleHandler);
|