discontinued 2023 july 29th . by ninekorn
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
//NPC SHIP ROTATION AND DIRECTION
var angler = ship.GetRotation(SHIP_ID);
var radToDegrer = angler * (180.0 / Math.PI);
var npcPointX00 = (1 * Math.cos(radToDegrer * Math.PI / 180)) + currentNpcCoord.x;
var npcPointY00 = (1 * Math.sin(radToDegrer * Math.PI / 180)) + currentNpcCoord.y;
var dirX00 = npcPointX00 - currentNpcCoord.x;
var dirY00 = npcPointY00 - currentNpcCoord.y;
var forwardNPC = { x: dirX00, y: dirY00 };
var rightNPC = { x: dirY00, y: -dirX00 };
//--------------------------------
//PLAYER SHIP ROTATION AND DIRECTION
var currentCoordsPlayer = ship.GetCoordinates(player_id);
var anglerOfPlayer = ship.GetRotation(player_id);
var radToDegrerOfPlayer = anglerOfPlayer * (180.0 / Math.PI);
var pointXOfPlayer = (1 * Math.cos(radToDegrerOfPlayer * Math.PI / 180)) + currentCoordsPlayer.x;
var pointYOfPlayer = (1 * Math.sin(radToDegrerOfPlayer * Math.PI / 180)) + currentCoordsPlayer.y;
var dirXOfPlayer = pointXOfPlayer - currentCoordsPlayer.x;
var dirYOfPlayer = pointYOfPlayer - currentCoordsPlayer.y;
var forwardOfPlayer = { x: dirXOfPlayer, y: dirYOfPlayer };
var rightOfPlayer = { x: dirYOfPlayer, y: -dirXOfPlayer };
//--------------------------------
if (npc.CountObjectives(nextCommandToDispatch.id) > 0)
{
var currentObjective = npc.GetCurrentObjective(nextCommandToDispatch.id);
if (currentObjective.id == nextCommandToDispatch.id)
{
var currentFormationWaypoint = goToFormationWaypoint(nextCommandToDispatch);
var distToWaypoint = Math.sqrt(((currentFormationWaypoint.x - currentNpcCoord.x) * (currentFormationWaypoint.x - currentNpcCoord.x)) + ((currentFormationWaypoint.y - currentNpcCoord.y) * (currentFormationWaypoint.y - currentNpcCoord.y)));
var distToPlayer = Math.sqrt(((currentFormationWaypoint.x - currentCoordsPlayer.x) * (currentFormationWaypoint.x - currentCoordsPlayer.x)) + ((currentFormationWaypoint.y - currentCoordsPlayer.y) * (currentFormationWaypoint.y - currentCoordsPlayer.y)));
var distPlayerToDrone = Math.sqrt(((currentNpcCoord.x - currentCoordsPlayer.x) * (currentNpcCoord.x - currentCoordsPlayer.x)) + ((currentNpcCoord.y - currentCoordsPlayer.y) * (currentNpcCoord.y - currentCoordsPlayer.y)));
var dirToWaypointX = (currentFormationWaypoint.x - currentNpcCoord.x) / distToWaypoint;
var dirToWaypointY = (currentFormationWaypoint.y - currentNpcCoord.y) / distToWaypoint;
var dirToWaypoint = { x: dirToWaypointX, y: dirToWaypointY };
var dirPlayerToWaypointX = (currentFormationWaypoint.x - currentCoordsPlayer.x) / distToPlayer;
var dirPlayerToWaypointY = (currentFormationWaypoint.y - currentCoordsPlayer.y) / distToPlayer;
var dirPlayerToWaypoint = { x: dirPlayerToWaypointX, y: dirPlayerToWaypointY };
var dirPlayerToDroneX = (currentNpcCoord.x - currentCoordsPlayer.x) / distPlayerToDrone;
var dirPlayerToDroneY = (currentNpcCoord.y - currentCoordsPlayer.y) / distPlayerToDrone;
var dirPlayerToDrone = { x: dirPlayerToDroneX, y: dirPlayerToDroneY };
var alignedDirectionForwardDOT = Dot(forwardNPC.x, forwardNPC.y, dirToWaypointX, dirToWaypointY);
var alignedDirectionLRDOT = Dot(rightNPC.x, rightNPC.y, dirToWaypointX, dirToWaypointY);
var pointInFrontOfWaypointX = currentFormationWaypoint.x + forwardOfPlayer.x;
var pointInFrontOfWaypointY = currentFormationWaypoint.y + forwardOfPlayer.y;
var pointInFrontOfWaypoint = { x: pointInFrontOfWaypointX, y: pointInFrontOfWaypointY};
var isFrontOrBack = NSEWDIST(currentCoordsPlayer, currentFormationWaypoint, currentNpcCoord);
var isLeftOrRight = NSEWDIST(currentFormationWaypoint, pointInFrontOfWaypoint, currentNpcCoord);
}
}
Page created in 0.076 seconds with 13 queries.