update/include destinations in position alerts
This commit is contained in:
6 files changed
+389
-6
No files matched your search
@@ -1,4 +1,6 @@
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const { destinations } = require('../config/locations');
|
||||
const { calculateVector } = require('./vector');
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -49,9 +51,22 @@ module.exports = {
|
||||
|
||||
let unixTime = Math.floor(newDt.getTime() / 1000);
|
||||
|
||||
let tempDest;
|
||||
let lastDist = 1000000;
|
||||
let destination_dir;
|
||||
for (let i = 0; i < destinations.length; i++) {
|
||||
let { distance, theta, dir } = calculateVector(data.pos, destinations[i].coord);
|
||||
if (distance < lastDist) {
|
||||
tempDest = destinations[i].name;
|
||||
lastDist = distance;
|
||||
destination_dir = dir;
|
||||
}
|
||||
}
|
||||
const destination = lastDist > 500 ? `${destination_dir} of ${tempDest}` : tempDest;
|
||||
|
||||
let combatLog = new EmbedBuilder()
|
||||
.setColor(client.config.Colors.Red)
|
||||
.setDescription(`**NOTICE:**\n**${data.player}** has combat logged at <t:${unixTime}> when fighting **${data.lastHitBy}\nLocation [${data.pos[0]}, ${data.pos[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${data.pos[0]};${data.pos[1]})**`);
|
||||
.setDescription(`**NOTICE:**\n**${data.player}** has combat logged at <t:${unixTime}> when fighting **${data.lastHitBy}\nLocation [${data.pos[0]}, ${data.pos[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${data.pos[0]};${data.pos[1]})**\nNear ${destination}`);
|
||||
|
||||
if (client.exists(guild.adminRole)) channel.send({ content: `<@&${guild.adminRole}>` });
|
||||
|
||||
|
||||
+29
-2
@@ -1,5 +1,6 @@
|
||||
const { BanPlayer, UnbanPlayer } = require('./NitradoAPI');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const { calculateVector } = require('./vector');
|
||||
|
||||
// Private functions (only called locally)
|
||||
|
||||
@@ -23,9 +24,22 @@ const HandlePlayerTrackEvent = async (client, guild, e) => {
|
||||
let newDt = await client.getDateEST(player.time);
|
||||
let unixTime = Math.floor(newDt.getTime()/1000);
|
||||
|
||||
let tempDest;
|
||||
let lastDist = 1000000;
|
||||
let destination_dir;
|
||||
for (let i = 0; i < destinations.length; i++) {
|
||||
let { distance, theta, dir } = calculateVector(player.pos, destinations[i].coord);
|
||||
if (distance < lastDist) {
|
||||
tempDest = destinations[i].name;
|
||||
lastDist = distance;
|
||||
destination_dir = dir;
|
||||
}
|
||||
}
|
||||
const destination = lastDist > 500 ? `${destination_dir} of ${tempDest}` : tempDest;
|
||||
|
||||
const trackEvent = new EmbedBuilder()
|
||||
.setColor(client.config.Colors.Default)
|
||||
.setDescription(`**${e.name} Event**\n${e.gamertag} was located at **[${player.pos[0]}, ${player.pos[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${player.pos[0]};${player.pos[1]})** at <t:${unixTime}>`);
|
||||
.setDescription(`**${e.name} Event**\n${e.gamertag} was located at **[${player.pos[0]}, ${player.pos[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${player.pos[0]};${player.pos[1]})** at <t:${unixTime}>\nNear ${destination}`);
|
||||
|
||||
if (!client.exists(e.channel)) return ExpireEvent(client, guild, e); // Expire event since it has invalid channel.
|
||||
const channel = client.GetChannel(e.channel);
|
||||
@@ -97,9 +111,22 @@ module.exports = {
|
||||
let newDt = await client.getDateEST(data.time);
|
||||
let unixTime = Math.floor(newDt.getTime()/1000);
|
||||
|
||||
let tempDest;
|
||||
let lastDist = 1000000;
|
||||
let destination_dir;
|
||||
for (let i = 0; i < destinations.length; i++) {
|
||||
let { distance, theta, dir } = calculateVector(info.victimPOS, destinations[i].coord);
|
||||
if (distance < lastDist) {
|
||||
tempDest = destinations[i].name;
|
||||
lastDist = distance;
|
||||
destination_dir = dir;
|
||||
}
|
||||
}
|
||||
const destination = lastDist > 500 ? `${destination_dir} of ${tempDest}` : tempDest;
|
||||
|
||||
let uavEmbed = new EmbedBuilder()
|
||||
.setColor(client.config.Colors.Default)
|
||||
.setDescription(`**UAV Detection - <t:${unixTime}>**\n**${data.player}** was spotted in the UAV zone at **[${data.pos[0]}, ${data.pos[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${data.pos[0]};${data.pos[1]})**`)
|
||||
.setDescription(`**UAV Detection - <t:${unixTime}>**\n**${data.player}** was spotted in the UAV zone at **[${data.pos[0]}, ${data.pos[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${data.pos[0]};${data.pos[1]})\nNear ${destination}**`)
|
||||
|
||||
client.users.fetch(uav.owner, false).then((user) => {
|
||||
user.send({ embeds: [uavEmbed] });
|
||||
|
||||
+17
-2
@@ -1,6 +1,8 @@
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const { User, addUser } = require('../structures/user');
|
||||
const { KillInAlarm } = require('./AlarmsHandler');
|
||||
const { destinations } = require('../config/locations');
|
||||
const { calculateVector } = require('./vector');
|
||||
|
||||
const Templates = {
|
||||
Killed: 1,
|
||||
@@ -76,10 +78,23 @@ module.exports = {
|
||||
const unixTime = Math.floor(newDt.getTime()/1000);
|
||||
|
||||
const showCoords = client.exists(guild.showKillfeedCoords) ? guild.showKillfeedCoords : false; // default to false if no record of configuration.
|
||||
let tempDest;
|
||||
let lastDist = 1000000;
|
||||
let destination_dir;
|
||||
for (let i = 0; i < destinations.length; i++) {
|
||||
let { distance, theta, dir } = calculateVector(info.victimPOS, destinations[i].coord);
|
||||
if (distance < lastDist) {
|
||||
tempDest = destinations[i].name;
|
||||
lastDist = distance;
|
||||
destination_dir = dir;
|
||||
}
|
||||
}
|
||||
|
||||
const destination = lastDist > 500 ? `${destination_dir} of ${tempDest}` : tempDest;
|
||||
|
||||
if (killedBy == Templates.LandMine || killedBy == Templates.Explosion || killedBy == Templates.Vehicle) {
|
||||
const cod = killedBy == Templates.LandMine ? `Land Mine Trap` : info.causeOfDeath;
|
||||
const coord = showCoords ? `\n**Location [${info.victimPOS[0]}, ${info.victimPOS[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${info.victimPOS[0]};${info.victimPOS[1]})**` : '';
|
||||
const coord = showCoords ? `\n**Location [${info.victimPOS[0]}, ${info.victimPOS[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${info.victimPOS[0]};${info.victimPOS[1]})**\nNear ${destination}` : '';
|
||||
const killMessage = killedBy == Templates.Vehicle ? 'run over by' : 'blew up from';
|
||||
|
||||
const killEvent = new EmbedBuilder()
|
||||
@@ -169,7 +184,7 @@ module.exports = {
|
||||
if (victimStatIndex == -1) stats.push(victimStat);
|
||||
else stats[victimStatIndex] = victimStat;
|
||||
|
||||
const coord = showCoords ? `\n**Location [${info.killerPOS[0]}, ${info.killerPOS[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${info.killerPOS[0]};${info.killerPOS[1]})**` : '';
|
||||
const coord = showCoords ? `\n**Location [${info.victimPOS[0]}, ${info.victimPOS[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${info.victimPOS[0]};${info.victimPOS[1]})*\nNear ${destination}` : '';
|
||||
|
||||
const killEvent = new EmbedBuilder()
|
||||
.setColor(client.config.Colors.Default)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
calculateVector: (pos1, pos2) => {
|
||||
let delta = [Math.round(pos2[0] - pos1[0]), Math.round(pos2[1] - pos1[1])];
|
||||
let distance = parseFloat(Math.sqrt(Math.pow(delta[0], 2) + Math.pow(delta[1], 2)).toFixed(0));
|
||||
let thetat = Math.round(Math.atan2(delta[0], delta[1]) / Math.PI * 180);
|
||||
let theta = (thetat < 0) ? (360 + thetat) : thetat;
|
||||
let compass = ["S", "S.SW", "SW", "W.SW", "W", "W.NW", "NW", "N.NW", "N", "N.NE", "NE", "E.NE", "E", "E.SE", "SE", "S.SE", "S"];
|
||||
let dir = compass[Math.round(theta / 22.5)];
|
||||
|
||||
return {distance, theta, dir}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user