Is there a way to turn the vector into a coordinate? For example, I’m doing Cloudrip Siege, and I want to be able to build a decoy toward a specific side. Here’s my code now, but it doesn’t work:
function pos() {
let build = null;
if (sideLength() == "l" && hero.pos.y < 41) build = new Vector(23, 41);
if (sideLength() == "r" && hero.pos.y > 41) build = new Vector(77, 41);
return build;
}
...
if (hero.gold >= hero.costOf("decoy")) hero.buildXY("decoy", pos());
So more or less, I want to build at a point about three meters from my hero, but I don’t want to go all the way to the point.
function sideLength() {
let leftLength = 0;
let rightLength = 0;
for (let enemy of hero.findEnemies()) {
if (enemy.pos.x > 50) {rightLength += 1;}
else {leftLength += 1}
}
if (leftLength > rightLength) {return "l";}
else {return "r";}
}
If you go to the level, you’ll find that there’s a section in the middle of the arena where coins spawn. On either side of the arena, enemies spawn. There are also fences that separate the two areas except for a small portion in the center. I’m trying to build the decoys so that they move toward that opening (on the side with the most enemies).
I don’t think anything is wrong with the code, I can’t use the buildXY() function with a vector, though, so I was wondering if there was a way to find an XY coordinate along that vector, though. I don’t know if it’s even possible, but I uploaded an illustration of what I am thinking.
The buildXY() function requires three inputs: "type", an x coordinate and a y coordinate. I’m trying to get those x and y coordinates from a vector, but I can’t directly input a vector there.