function _0998_above() {
static var is0998above = false;
once is0998above = l2v(atan2_256(10, 10) >= 90);
return is0998above;
}
function angleBetween_256(x1, y1, x2, y2) {
if (_0998_above()) {
return atan2_256(y2 - y1, x2 - x1);
}
return atan2_256(x2 - x1, y1 - y2);
}
function distanceBetween(x1, y1, x2, y2) {
const x = x2 - x1;
const y = y2 - y1;
return sqrt(x*x + y*y);
}
function polarProjection_256(x0, y0, length, angle) {
var dx, dy;
if (_0998_above()) {
dx, dy = lengthdir_256(length, angle);
return x0 + dx, y0 + dy;
} else {
dx, dy = lengthdir_256(length, 320 - angle);
return x0 + dx, y0 - dy;
}
}
var marine_epd, ghost_epd = 0, 0;
function onPluginStart() {
}
function beforeTriggerExec() {
const cp = getcurpl();
once (ElapsedTime(AtLeast, 0)) {
const cp2 = getcurpl();
setcurpl(EPD(0x628438));
{
const ptr, epd = cunitepdread_cp(0);
CreateUnit(1, "Terran Marine", "Location 1", P1);
if (ptr != 0) {
marine_epd = epd;
}
}
{
const ptr, epd = cunitepdread_cp(0);
CreateUnit(1, "Terran Ghost", "Location 2", P1);
if (ptr != 0) {
ghost_epd = epd;
}
}
setcurpl(cp2);
}
if (marine_epd != 0 && ghost_epd != 0) {
const marine_cu = CUnit(marine_epd);
const ghost_cu = CUnit(ghost_epd);
once {
ghost_cu.set_invincible();
marine_cu.set_invincible();
}
const x0, y0 = marine_cu.getpos("pos");
const x1, y1 = ghost_cu.getpos("pos");
const ang = angleBetween_256(x0, y0, x1, y1);
const dist = distanceBetween(x0, y0, x1, y1);
const x, y = polarProjection_256(x0, y0, dist, ang);
setcurpl(P1);
printAt(0, "The distance from the Machine({},{})(Face:{}) to the Ghost({},{})(Face:{}) is {} , the angle is {}", x0, y0, marine_cu.currentDirection2, x1, y1, ghost_cu.currentDirection2, dist, ang);
printAt(1, "Walking {} distance {} degrees from the Machine position will reach the Ghost's position at ({}, {})", ang, dist, x, y);
}
setcurpl(cp);
}
function afterTriggerExec() {
}