message (1) (1)
message (1) (1)
} else {
let gotoDist = UTILS.getDist(wdaawdwad[0],
botPlayer, 0, 2);
let gotoAim = UTILS.getDirect(wdaawdwad[0],
botPlayer, 0, 2);
let nearObjs = botObj.filter((e) => e.active &&
(findSID(wdaawdwad, e.sid) ? true : !(e.trap && (player.sid == e.owner.sid ||
player.findAllianceBySid(e.owner.sid)))) && e.isItem && UTILS.getDist(e, botPlayer,
0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale/2)).sort(function(a,
b) {
return UTILS.getDist(a, botPlayer, 0, 2) -
UTILS.getDist(b, botPlayer, 0, 2);
});
if (nearObjs.length > 0) {
let nearObj = nearObjs[0];
let isPassed = UTILS.getDist(wdaawdwad[0],
nearObj, 0, 0);
if ((gotoDist - isPassed) > 0) {
bot.sendWS("a", caf(player, botPlayer) +
Math.PI);
if (findSID(wdaawdwad, nearObj.sid) ?
true : (nearObj.dmg || nearObj.trap)) {
// if (botPlayer.moveDir != undefined)
{
// botPlayer.moveDir = undefined;
// bot.sendWS("a",
botPlayer.moveDir);
bot.sendWS("D", botPlayer.nDir);
// }
} else {
bot.sendWS("D", botPlayer.nDir);
}
if (botPlayer.nDir !=
UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
botPlayer.nDir =
UTILS.getDirect(nearObj, botPlayer, 0, 2);
bot.sendWS("D", botPlayer.nDir);
}
bot.buye(40, 0);
// bot.fastGear();
bot.buye(11, 1);
if (izauto == 0) {
bot.sendWS("K", 1);
izauto = 1;
}
} else {
if (zoon == 'no') {
bot.sendWS("D",
UTILS.getDirect(nearObj, botPlayer, 0, 2));
}
if (cdf(player, botPlayer) <= 220) {
bot.sendWS("a", undefined);
} else {
bot.sendWS("a", caf(player, botPlayer)
+ Math.PI);
}
}
} else {
if (wdaawdwad.length) {
if (zoon == 'no') {
bot.sendWS("D",
UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
// if (izauto == 0) {
// bot.sendWS("K", 1);
// izauto = 1;
// }
}
if (cdf(player, botPlayer) <= 220) {
bot.sendWS("a", undefined);
} else {
bot.sendWS("a", caf(player, botPlayer)
+ Math.PI);
}
} else {
if (zoon == 'no') {
bot.sendWS("D", UTILS.getDirect(player,
botPlayer, 0, 2));
}
if (cdf(player, botPlayer) <= 220) {
bot.sendWS("a", undefined);
} else {
bot.sendWS("a", caf(player, botPlayer)
+ Math.PI);
}
}
}
}
}
}
}
}
}
if (type == "H") {
let tmpData = data[0];
for (let i = 0; i < tmpData.length;) {
botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2],
tmpData[i + 3], tmpData[i + 4],
tmpData[i + 5], items.list[tmpData[i + 6]], true,
(tmpData[i + 7] >= 0 ? {
sid: tmpData[i + 7]
} : null));
i += 8;
}
}
if (type == "N") {
let index = data[0];
let value = data[1];
if (botPlayer) {
botPlayer[index] = value;
}
}
if (type == "O") {
if (data[0] == botPlayer.sid) {
botPlayer.oldHealth = botPlayer.health;
botPlayer.health = data[1];
botPlayer.judgeShame();
if (botPlayer.oldHealth > botPlayer.health) {
if (botPlayer.shameCount < 5) {
for (let i = 0; i < 2; i++) {
bot.place(0, botPlayer.nDir);
}
} else {
setTimeout(() => {
for (let i = 0; i < 2; i++) {
bot.place(0, botPlayer.nDir);
}
}, 95);
}
}
}
}
if (type == "Q") {
let sid = data[0];
botObjManager.disableBySid(sid);
}
if (type == "R") {
let sid = data[0];
if (botPlayer.alive) botObjManager.removeAllItems(sid);
}
if (type == "S") {
let index = data[0];
let value = data[1];
if (botPlayer) {
botPlayer.itemCounts[index] = value;
}
}
if (type == "U") {
if (data[0] > 0) {
if(getEl("setup").value == 'dm') {
if (botPlayer.upgraded == 0) {
bot.sendUpgrade(7);
} else if (botPlayer.upgraded == 1) {
bot.sendUpgrade(17);
} else if (botPlayer.upgraded == 2) {
bot.sendUpgrade(31);
} else if (botPlayer.upgraded == 3) {
bot.sendUpgrade(23);
} else if (botPlayer.upgraded == 4) {
bot.sendUpgrade(9);
} else if (botPlayer.upgraded == 5) {
bot.sendUpgrade(34);
} else if (botPlayer.upgraded == 6) {
bot.sendUpgrade(12);
} else if (botPlayer.upgraded == 7) {
bot.sendUpgrade(15);
}
} else if(getEl("setup").value == 'BM') {
if (botPlayer.upgraded == 0) {
bot.sendUpgrade(6);
} else if (botPlayer.upgraded == 1) {
bot.sendUpgrade(17);
} else if (botPlayer.upgraded == 2) {
bot.sendUpgrade(31);
} else if (botPlayer.upgraded == 3) {
bot.sendUpgrade(23);
} else if (botPlayer.upgraded == 4) {
bot.sendUpgrade(9);
} else if (botPlayer.upgraded == 5) {
bot.sendUpgrade(34);
} else if (botPlayer.upgraded == 6) {
bot.sendUpgrade(12);
} else if (botPlayer.upgraded == 7) {
bot.sendUpgrade(15);
}
} else if(getEl("setup").value == 'pm') {
if (botPlayer.upgraded == 0) {
bot.sendUpgrade(5);
} else if (botPlayer.upgraded == 1) {
bot.sendUpgrade(17);
} else if (botPlayer.upgraded == 2) {
bot.sendUpgrade(31);
} else if (botPlayer.upgraded == 3) {
bot.sendUpgrade(23);
} else if (botPlayer.upgraded == 4) {
bot.sendUpgrade(9);
} else if (botPlayer.upgraded == 5) {
bot.sendUpgrade(34);
} else if (botPlayer.upgraded == 6) {
bot.sendUpgrade(12);
} else if (botPlayer.upgraded == 7) {
bot.sendUpgrade(15);
}
} else if(getEl("setup").value == 'zd') {
if (botPlayer.upgraded == 0) {
bot.sendUpgrade(3);
} else if (botPlayer.upgraded == 1) {
bot.sendUpgrade(17);
} else if (botPlayer.upgraded == 2) {
bot.sendUpgrade(31);
} else if (botPlayer.upgraded == 3) {
bot.sendUpgrade(27);
} else if (botPlayer.upgraded == 4) {
bot.sendUpgrade(9);
} else if (botPlayer.upgraded == 5) {
bot.sendUpgrade(34);
} else if (botPlayer.upgraded == 6) {
bot.sendUpgrade(12);
} else if (botPlayer.upgraded == 7) {
bot.sendUpgrade(15);
}
}
botPlayer.upgraded++;
}
}
if (type == "V") {
let tmpData = data[0];
let wpn = data[1];
if (tmpData) {
if (wpn) botPlayer.weapons = tmpData;
else botPlayer.items = tmpData;
}
}
if (type == "5") {
let type = data[0];
let id = data[1];
let index = data[2];
if (index) {
if (!type)
botPlayer.tails[id] = 1;
else
botPlayer.latestTail = id;
} else {
if (!type)
botPlayer.skins[id] = 1;
else
botPlayer.latestSkin = id;
}
}
if (type == "6") {
let id = data[0];
let mzg = data[1]+'';
if(id == player.sid && mzg.includes(":(")) {
bot.zync(botPlayer.near);
}
}
};
bot.onclose = function() {
botPlayer.inGame = false;
bD.inGame = false;
};
}
// RENDER LEAF:
function renderLeaf(x, y, l, r, ctxt) {
let endX = x + (l * Math.cos(r));
let endY = y + (l * Math.sin(r));
let width = l * 0.4;
ctxt.moveTo(x, y);
ctxt.beginPath();
ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)),
endX, endY);
ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)),
x, y);
ctxt.closePath();
ctxt.fill();
ctxt.stroke();
}
// RENDER CIRCLE:
function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
tmpContext = tmpContext || mainContext;
tmpContext.beginPath();
tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
if (!dontFill) tmpContext.fill();
if (!dontStroke) tmpContext.stroke();
}
function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
tmpContext = tmpContext || mainContext;
tmpContext.beginPath();
tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
if (!dontFill) tmpContext.fill();
if (!dontStroke) tmpContext.stroke();
}
// RENDER STAR SHAPE:
function renderStar(ctxt, spikes, outer, inner) {
let rot = Math.PI / 2 * 3;
let x, y;
let step = Math.PI / spikes;
ctxt.beginPath();
ctxt.moveTo(0, -outer);
for (let i = 0; i < spikes; i++) {
x = Math.cos(rot) * outer;
y = Math.sin(rot) * outer;
ctxt.lineTo(x, y);
rot += step;
x = Math.cos(rot) * inner;
y = Math.sin(rot) * inner;
ctxt.lineTo(x, y);
rot += step;
}
ctxt.lineTo(0, -outer);
ctxt.closePath();
}
function renderHealthStar(ctxt, spikes, outer, inner) {
let rot = Math.PI / 2 * 3;
let x, y;
let step = Math.PI / spikes;
ctxt.beginPath();
ctxt.moveTo(0, -outer);
for (let i = 0; i < spikes; i++) {
x = Math.cos(rot) * outer;
y = Math.sin(rot) * outer;
ctxt.lineTo(x, y);
rot += step;
x = Math.cos(rot) * inner;
y = Math.sin(rot) * inner;
ctxt.lineTo(x, y);
rot += step;
}
ctxt.lineTo(0, -outer);
ctxt.closePath();
}
// RENDER RECTANGLE:
function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
}
function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
}
// RENDER RECTCIRCLE:
function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
ctxt.save();
ctxt.translate(x, y);
seg = Math.ceil(seg / 2);
for (let i = 0; i < seg; i++) {
renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
ctxt.rotate(Math.PI / seg);
}
ctxt.restore();
}
// RENDER BLOB:
function renderBlob(ctxt, spikes, outer, inner) {
let rot = Math.PI / 2 * 3;
let x, y;
let step = Math.PI / spikes;
let tmpOuter;
ctxt.beginPath();
ctxt.moveTo(0, -inner);
for (let i = 0; i < spikes; i++) {
tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step)
* tmpOuter,
Math.cos(rot + (step * 2)) * inner, Math.sin(rot +
(step * 2)) * inner);
rot += step * 2;
}
ctxt.lineTo(0, -inner);
ctxt.closePath();
}
// RENDER TRIANGLE:
function renderTriangle(s, ctx) {
ctx = ctx || mainContext;
let h = s * (Math.sqrt(3) / 2);
ctx.beginPath();
ctx.moveTo(0, -h / 2);
ctx.lineTo(-s / 2, h / 2);
ctx.lineTo(s / 2, h / 2);
ctx.lineTo(0, -h / 2);
ctx.fill();
ctx.closePath();
}
// PREPARE MENU BACKGROUND:
function prepareMenuBackground() {
// let tmpMid = config.mapScale / 2;
// let attempts = 0;
// for (let i = 0; i < items.list.length * 3;) {
// if (attempts >= 1000) break;
// attempts++;
// let type = items.list[UTILS.randInt(0, items.list.length - 1)];
// let data = {
// x: tmpMid + UTILS.randFloat(-1000, 1000),
// y: tmpMid + UTILS.randFloat(-600, 600),
// dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
// };
// if (objectManager.checkItemLocation(data.x, data.y, type.scale, 0.6,
type.id, true)) {
// objectManager.add(i, data.x, data.y, data.dir, type.scale, type.id,
type);
// } else {
// continue;
// }
// i++;
// }
}
const speed = 1;
// RENDER PLAYERS:
function renderDeadPlayers(xOffset, yOffset) {
mainContext.fillStyle = "#91b2db";
const currentTime = Date.now();
deadPlayers.filter(dead => dead.active).forEach((dead) => {
if (!dead.startTime) {
dead.startTime = currentTime;
dead.angle = 0;
dead.radius = 0.1;
}
const timeElapsed = currentTime - dead.startTime;
const maxAlpha = 1;
dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
dead.animate(delta);
mainContext.globalAlpha = dead.alpha;
mainContext.strokeStyle = outlineColor;
mainContext.save();
mainContext.translate(dead.x - xOffset, dead.y - yOffset);
dead.radius -= 0.001;
dead.angle += 0.0174533;
const moveSpeed = 1;
const x = dead.radius * Math.cos(dead.angle);
const y = dead.radius * Math.sin(dead.angle);
dead.x += x * moveSpeed;
dead.y += y * moveSpeed;
mainContext.rotate(dead.angle);
renderDeadPlayer(dead, mainContext);
mainContext.restore();
mainContext.fillStyle = "#91b2db";
if (timeElapsed >= 3000) {
dead.active = false;
dead.startTime = null;
}
});
}
// RENDER PLAYERS:
function renderPlayers(xOffset, yOffset, zIndex) {
mainContext.globalAlpha = 1;
mainContext.fillStyle = "#91b2db";
for (var i = 0; i < players.length; ++i) {
tmpObj = players[i];
if (tmpObj.zIndex == zIndex) {
tmpObj.animate(delta);
if (tmpObj.visible) {
tmpObj.skinRot += (0.002 * delta);
tmpDir = (tmpObj==player?getVisualDir():(tmpObj.dir || 0));
mainContext.save();
mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
// RENDER PLAYER:
mainContext.rotate(tmpDir + tmpObj.dirPlus);
renderPlayer(tmpObj, mainContext);
mainContext.restore();
}
}
}
}
// RENDER DEAD PLAYER:
function renderDeadPlayer(obj, ctxt) {
ctxt = ctxt || mainContext;
ctxt.lineWidth = outlineWidth;
ctxt.lineJoin = "miter";
let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||
1):1;
let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||
1):1;
// TAIL/CAPE:
renderTail2(13, ctxt, obj);
// WEAPON BELLOW HANDS:
if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
renderTool(items.weapons[obj.weaponIndex],
config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
if (items.weapons[obj.weaponIndex].projectile != undefined && !
items.weapons[obj.weaponIndex].hideProjectile) {
renderProjectile(obj.scale, 0,
items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
}
}
// HANDS:
ctxt.fillStyle = "#ececec";
renderCircle(obj.scale * Math.cos(handAngle), (obj.scale *
Math.sin(handAngle)), 14);
renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
(obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
// WEAPON ABOVE HANDS:
if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
renderTool(items.weapons[obj.weaponIndex],
config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
if (items.weapons[obj.weaponIndex].projectile != undefined && !
items.weapons[obj.weaponIndex].hideProjectile) {
renderProjectile(obj.scale, 0,
items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
}
}
// BUILD ITEM:
if (obj.buildIndex >= 0) {
var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
ctxt.drawImage(tmpSprite, obj.scale -
items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
}
// BODY:
renderCircle(0, 0, obj.scale, ctxt);
// SKIN
renderSkin2(48, ctxt, null, obj)
}
// RENDER PLAYER:
function renderPlayer(obj, ctxt) {
ctxt = ctxt || mainContext;
ctxt.lineWidth = outlineWidth;
ctxt.lineJoin = "miter";
let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS ||
1) : 1;
let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD ||
1) : 1;
let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] ==
15);
// TAIL/CAPE:
if (obj.tailIndex > 0) {
renderTailTextureImage(obj.tailIndex, ctxt, obj);
}
// WEAPON BELLOW HANDS:
if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex],
config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
if (items.weapons[obj.weaponIndex].projectile != undefined && !
items.weapons[obj.weaponIndex].hideProjectile) {
renderProjectile(obj.scale, 0,
items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
}
}
// HANDS:
ctxt.fillStyle = config.skinColors[obj.skinColor];
renderCircle(obj.scale * Math.cos(handAngle), (obj.scale *
Math.sin(handAngle)), 14);
renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
(obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
// WEAPON ABOVE HANDS:
if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
renderTool(items.weapons[obj.weaponIndex],
config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
if (items.weapons[obj.weaponIndex].projectile != undefined && !
items.weapons[obj.weaponIndex].hideProjectile) {
renderProjectile(obj.scale, 0,
items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
}
}
// BUILD ITEM:
if (obj.buildIndex >= 0) {
var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
ctxt.drawImage(tmpSprite, obj.scale -
items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
}
// BODY:
renderCircle(0, 0, obj.scale, ctxt);
// SKIN:
if (obj.skinIndex > 0) {
ctxt.rotate(Math.PI / 2);
renderTextureSkin(obj.skinIndex, ctxt, null, obj);
}
}
// RENDER NORMAL SKIN
var skinSprites2 = {};
var skinPointers2 = {};
function renderSkin2(index, ctxt, parentSkin, owner) {
tmpSkin = skinSprites2[index];
if (!tmpSkin) {
var tmpImage = new Image();
tmpImage.onload = function() {
this.isLoaded = true;
this.onload = null;
};
//tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
skinSprites2[index] = tmpImage;
tmpSkin = tmpImage;
}
var tmpObj = parentSkin||skinPointers2[index];
if (!tmpObj) {
for (var i = 0; i < hats.length; ++i) {
if (hats[i].id == index) {
tmpObj = hats[i];
break;
}
}
skinPointers2[index] = tmpObj;
}
if (tmpSkin.isLoaded)
ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale,
tmpObj.scale);
if (!parentSkin && tmpObj.topSprite) {
ctxt.save();
ctxt.rotate(owner.skinRot);
renderSkin2(index + "_top", ctxt, tmpObj, owner);
ctxt.restore();
}
}
// RENDER SKIN:
function renderTextureSkin(index, ctxt, parentSkin, owner) {
if (!(tmpSkin = skinSprites[index + (txt ? "lol" : 0)])) {
var tmpImage = new Image();
tmpImage.onload = function() {
this.isLoaded = true,
this.onload = null
}
,
tmpImage.src = setSkinTextureImage(index, "hat", index),
skinSprites[index + (txt ? "lol" : 0)] = tmpImage,
tmpSkin = tmpImage
}
var tmpObj = parentSkin||skinPointers[index];
if (!tmpObj) {
for (var i = 0; i < hats.length; ++i) {
if (hats[i].id == index) {
tmpObj = hats[i];
break;
}
}
skinPointers[index] = tmpObj;
}
if (tmpSkin.isLoaded)
ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale,
tmpObj.scale);
if (!parentSkin && tmpObj.topSprite) {
ctxt.save();
ctxt.rotate(owner.skinRot);
renderSkin(index + "_top", ctxt, tmpObj, owner);
ctxt.restore();
}
}
var FlareZHat = {
7: "https://i.imgur.com/vAOzlyY.png",
15: "https://i.imgur.com/YRQ8Ybq.png",
40: "https://i.imgur.com/Xzmg27N.png",
26: "https://i.imgur.com/I0xGtyZ.png",
55: "https://i.imgur.com/uYgDtcZ.png",
20: "https://i.imgur.com/f5uhWCk.png",
};
function setSkinTextureImage(id, type, id2) {
if (true) {
if(FlareZHat[id] && type == "hat") {
return FlareZHat[id];
} else {
if(type == "acc") {
return ".././img/accessories/access_" + id + ".png";
} else if(type == "hat") {
return ".././img/hats/hat_" + id + ".png";
} else {
return ".././img/weapons/" + id + ".png";
}
}
} else {
if(type == "acc") {
return ".././img/accessories/access_" + id + ".png";
} else if(type == "hat") {
return ".././img/hats/hat_" + id + ".png";
} else {
return ".././img/weapons/" + id + ".png";
}
}
}
// RENDER SKINS:
let skinSprites = {};
let skinPointers = {};
let tmpSkin;
function renderSkin(index, ctxt, parentSkin, owner) {
tmpSkin = skinSprites[index];
if (!tmpSkin) {
let tmpImage = new Image();
tmpImage.onload = function() {
this.isLoaded = true;
this.onload = null;
};
tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
skinSprites[index] = tmpImage;
tmpSkin = tmpImage;
}
let tmpObj = parentSkin || skinPointers[index];
if (!tmpObj) {
for (let i = 0; i < hats.length; ++i) {
if (hats[i].id == index) {
tmpObj = hats[i];
break;
}
}
skinPointers[index] = tmpObj;
}
if (tmpSkin.isLoaded)
ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale,
tmpObj.scale);
if (!parentSkin && tmpObj.topSprite) {
ctxt.save();
ctxt.rotate(owner.skinRot);
renderSkin(index + "_top", ctxt, tmpObj, owner);
ctxt.restore();
}
}
// RENDER TAIL:
var FlareZAcc = {
21: "https://i.imgur.com/4ddZert.png",
19: "https://i.imgur.com/sULkUZT.png",
};
function setTailTextureImage(id, type, id2) {
if (true) {
if(FlareZAcc[id] && type == "acc") {
return FlareZAcc[id];
} else {
if(type == "acc") {
return ".././img/accessories/access_" + id + ".png";
} else if(type == "hat") {
return ".././img/hats/hat_" + id + ".png";
} else {
return ".././img/weapons/" + id + ".png";
}
}
} else {
if(type == "acc") {
return ".././img/accessories/access_" + id + ".png";
} else if(type == "hat") {
return ".././img/hats/hat_" + id + ".png";
} else {
return ".././img/weapons/" + id + ".png";
}
}
}
function renderTailTextureImage(index, ctxt, owner) {
if (!(tmpSkin = accessSprites[index + (txt ? "lol" : 0)])) {
var tmpImage = new Image();
tmpImage.onload = function() {
this.isLoaded = true,
this.onload = null
}
,
tmpImage.src = setTailTextureImage(index,
"acc"),//".././img/accessories/access_" + index + ".png";
accessSprites[index + (txt ? "lol" : 0)] = tmpImage,
tmpSkin = tmpImage;
}
var tmpObj = accessPointers[index];
if (!tmpObj) {
for (var i = 0; i < accessories.length; ++i) {
if (accessories[i].id == index) {
tmpObj = accessories[i];
break;
}
}
accessPointers[index] = tmpObj;
}
if (tmpSkin.isLoaded) {
ctxt.save();
ctxt.translate(-20 - (tmpObj.xOff||0), 0);
if (tmpObj.spin)
ctxt.rotate(owner.skinRot);
ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale,
tmpObj.scale);
ctxt.restore();
}
}
let accessSprites = {};
let accessPointers = {};
var txt = true;
function renderTail(index, ctxt, owner) {
tmpSkin = accessSprites[index];
if (!tmpSkin) {
let tmpImage = new Image();
tmpImage.onload = function() {
this.isLoaded = true;
this.onload = null;
};
tmpImage.src = "https://moomoo.io/img/accessories/access_" + index +
".png";
accessSprites[index] = tmpImage;
tmpSkin = tmpImage;
}
let tmpObj = accessPointers[index];
if (!tmpObj) {
for (let i = 0; i < accessories.length; ++i) {
if (accessories[i].id == index) {
tmpObj = accessories[i];
break;
}
}
accessPointers[index] = tmpObj;
}
if (tmpSkin.isLoaded) {
ctxt.save();
ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
if (tmpObj.spin)
ctxt.rotate(owner.skinRot);
ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2),
tmpObj.scale, tmpObj.scale);
ctxt.restore();
}
}
var accessSprites2 = {};
var accessPointers2 = {};
function renderTail2(index, ctxt, owner) {
tmpSkin = accessSprites2[index];
if (!tmpSkin) {
var tmpImage = new Image();
tmpImage.onload = function() {
this.isLoaded = true;
this.onload = null;
};
tmpImage.src = "https://moomoo.io/img/accessories/access_" + index +
".png";
accessSprites2[index] = tmpImage;
tmpSkin = tmpImage;
}
var tmpObj = accessPointers2[index];
if (!tmpObj) {
for (var i = 0; i < accessories.length; ++i) {
if (accessories[i].id == index) {
tmpObj = accessories[i];
break;
}
}
accessPointers2[index] = tmpObj;
}
if (tmpSkin.isLoaded) {
ctxt.save();
ctxt.translate(-20 - (tmpObj.xOff||0), 0);
if (tmpObj.spin)
ctxt.rotate(owner.skinRot);
ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale,
tmpObj.scale);
ctxt.restore();
}
}
// RENDER TOOL:
let toolSprites = {};
function renderTool(obj, variant, x, y, ctxt) {
let tmpSrc = obj.src + (variant || "");
let tmpSprite = toolSprites[tmpSrc];
if (!tmpSprite) {
tmpSprite = new Image();
tmpSprite.onload = function() {
this.isLoaded = true;
}
tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
toolSprites[tmpSrc] = tmpSprite;
}
if (tmpSprite.isLoaded)
ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff -
(obj.width / 2), obj.length, obj.width);
}
// RENDER PROJECTILES:
function renderProjectiles(layer, xOffset, yOffset) {
for (let i = 0; i < projectiles.length; i++) {
tmpObj = projectiles[i];
if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
tmpObj.update(delta);
if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset,
tmpObj.scale)) {
mainContext.save();
mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
mainContext.rotate(tmpObj.dir);
renderProjectile(0, 0, tmpObj, mainContext, 1);
mainContext.restore();
}
}
};
}
// RENDER PROJECTILE:
let projectileSprites = {};//fz iz zexy
function renderProjectile(x, y, obj, ctxt, debug) {
if (obj.src) {
let tmpSrc = items.projectiles[obj.indx].src;
let tmpSprite = projectileSprites[tmpSrc];
if (!tmpSprite) {
tmpSprite = new Image();
tmpSprite.onload = function() {
this.isLoaded = true;
}
tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
projectileSprites[tmpSrc] = tmpSprite;
}
if (tmpSprite.isLoaded)
ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2),
obj.scale, obj.scale);
} else if (obj.indx == 1) {
ctxt.fillStyle = "#939393";
renderCircle(x, y, obj.scale, ctxt);
}
}
// RENDER AI:
let aiSprites = {};
function renderAI(obj, ctxt) {
let tmpIndx = obj.index;
let tmpSprite = aiSprites[tmpIndx];
if (!tmpSprite) {
let tmpImg = new Image();
tmpImg.onload = function() {
this.isLoaded = true;
this.onload = null;
};
tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
tmpSprite = tmpImg;
aiSprites[tmpIndx] = tmpSprite;
}
if (tmpSprite.isLoaded) {
let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale *
2);
}
}
// RENDER WATER BODIES:
function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
// MIDDLE RIVER:
let tmpW = config.riverWidth + padding;
let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
}
}
// RENDER GAME OBJECTS:
let gameObjectSprites = {};
function getResSprite(obj) {
let biomeID = (obj.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((obj.y <=
config.snowBiomeTop) ? 1 : 0);
let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
let tmpSprite = gameObjectSprites[tmpIndex];
if (!tmpSprite) {
let blurScale = 6;
let tmpCanvas = document.createElement("canvas");
tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
let tmpContext = tmpCanvas.getContext('2d');
tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
tmpContext.rotate(UTILS.randFloat(0, Math.PI));
tmpContext.strokeStyle = outlineColor;
tmpContext.lineWidth = outlineWidth;
// if (isNight) {
// tmpContext.shadowBlur = blurScale;
// tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
// }
if (obj.type == 0) {
let tmpScale;
let tmpCount = 8;
tmpContext.globalAlpha = (cdf(obj, player) <= 250 ? 0.6 : 1);
for (let i = 0; i < 2; ++i) {
tmpScale = tmpObj.scale * (!i ? 1 : 0.5);
renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
tmpContext.fillStyle = !biomeID ? (!i ? "#9ebf57" : "#b4db62") : (!
i ? "#e3f1f4" : "#fff");
tmpContext.fill();
if (!i) {
tmpContext.stroke();
tmpContext.shadowBlur = null;
tmpContext.shadowColor = null;
tmpContext.globalAlpha = 1;
}
}
} else if (obj.type == 1) {
if (biomeID == 2) {
tmpContext.fillStyle = "#606060";
renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
tmpContext.fill();
tmpContext.stroke();
//tmpContext.shadowBlur = null;
//tmpContext.shadowColor = null;
tmpContext.fillStyle = "#89a54c";
renderCircle(0, 0, obj.scale * 0.55, tmpContext);
tmpContext.fillStyle = "#a5c65b";
renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
} else {
renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
tmpContext.fillStyle = biomeID ? "#e3f1f4" : "#89a54c";
tmpContext.fill();
tmpContext.stroke();
//tmpContext.shadowBlur = null;
//tmpContext.shadowColor = null;
tmpContext.fillStyle = biomeID ? "#6a64af" : "#c15555";
let tmpRange;
let berries = 4;
let rotVal = (Math.PI * 2) / berries;
for (let i = 0; i < berries; ++i) {
tmpRange = UTILS.randInt(tmpObj.scale / 3.5, tmpObj.scale /
2.3);
renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange *
Math.sin(rotVal * i),
UTILS.randInt(10, 12), tmpContext);
}
}
} else if (obj.type == 2 || obj.type == 3) {
tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#938d77" :
"#939393") : "#e0c655";
renderStar(tmpContext, 3, obj.scale, obj.scale);
tmpContext.fill();
tmpContext.stroke();
tmpContext.shadowBlur = null;
tmpContext.shadowColor = null;
tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#b2ab90" :
"#bcbcbc") : "#ebdca3";
renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
tmpContext.fill();
}
tmpSprite = tmpCanvas;
gameObjectSprites[tmpIndex] = tmpSprite;
}
return tmpSprite;
}
// GET ITEM SPRITE:
let itemSprites = [];
function getItemSprite(obj, asIcon) {
let tmpSprite = itemSprites[obj.id];
if (!tmpSprite || asIcon) {
let blurScale = !asIcon ? 20 : 5;
let tmpCanvas = document.createElement("canvas");
let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale :
obj.scale);
tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth +
(items.list[obj.id].spritePadding || 0) + blurScale;
let tmpContext = tmpCanvas.getContext("2d");
tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
tmpContext.strokeStyle = outlineColor;
tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) :
1);
if (!asIcon) {
tmpContext.shadowBlur = 8;
tmpContext.shadowColor = `rgba(0, 0, 0, 0.2)`;
}
if (obj.name == "apple") {
tmpContext.fillStyle = "#c15555";
renderCircle(0, 0, obj.scale, tmpContext);
tmpContext.fillStyle = "#89a54c";
let leafDir = -(Math.PI / 2);
renderLeaf(obj.scale * Math.cos(leafDir), obj.scale *
Math.sin(leafDir),
25, leafDir + Math.PI / 2, tmpContext);
} else if (obj.name == "cookie") {
tmpContext.fillStyle = "#cca861";
renderCircle(0, 0, obj.scale, tmpContext);
tmpContext.fillStyle = "#937c4b";
let chips = 4;
let rotVal = (Math.PI * 2) / chips;
let tmpRange;
for (let i = 0; i < chips; ++i) {
tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange *
Math.sin(rotVal * i),
UTILS.randInt(4, 5), tmpContext, true);
}
} else if (obj.name == "cheese") {
tmpContext.fillStyle = "#f4f3ac";
renderCircle(0, 0, obj.scale, tmpContext);
tmpContext.fillStyle = "#c3c28b";
let chips = 4;
let rotVal = (Math.PI * 2) / chips;
let tmpRange;
for (let i = 0; i < chips; ++i) {
tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange *
Math.sin(rotVal * i),
UTILS.randInt(4, 5), tmpContext, true);
}
} else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name
== "castle wall") {
tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" :
(obj.name == "wood wall") ?
"#a5974c" : "#939393";
let sides = (obj.name == "castle wall") ? 4 : 3;
renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" :
(obj.name == "wood wall") ?
"#c9b758" : "#bcbcbc";
renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
tmpContext.fill();
} else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name
== "poison spikes" ||
obj.name == "spinning spikes") {
tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" :
"#939393";
let tmpScale = (obj.scale * 0.6);
renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale,
tmpScale);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#a5974c";
renderCircle(0, 0, tmpScale, tmpContext);
tmpContext.fillStyle = "#c9b758";
renderCircle(0, 0, tmpScale / 2, tmpContext, true);
} else if (obj.name == "windmill" || obj.name == "faster windmill" ||
obj.name == "power mill") {
tmpContext.fillStyle = "#a5974c";
renderCircle(0, 0, reScale, tmpContext);
tmpContext.fillStyle = "#c9b758";
renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
tmpContext.fillStyle = "#a5974c";
renderCircle(0, 0, reScale * 0.5, tmpContext);
} else if (obj.name == "mine") {
tmpContext.fillStyle = "#939393";
renderStar(tmpContext, 3, obj.scale, obj.scale);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#bcbcbc";
renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
tmpContext.fill();
} else if (obj.name == "sapling") {
for (let i = 0; i < 2; ++i) {
let tmpScale = obj.scale * (!i ? 1 : 0.5);
renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
tmpContext.fill();
if (!i) tmpContext.stroke();
}
} else if (obj.name == "pit trap") {
tmpContext.fillStyle = "#a5974c";
renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = outlineColor;
renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
tmpContext.fill();
} else if (obj.name == "boost pad") {
tmpContext.fillStyle = "#7e7f82";
renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#dbd97d";
renderTriangle(obj.scale * 1, tmpContext);
} else if (obj.name == "turret") {
tmpContext.fillStyle = "#a5974c";
renderCircle(0, 0, obj.scale, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#939393";
let tmpLen = 50;
renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
renderCircle(0, 0, obj.scale * 0.6, tmpContext);
tmpContext.fill();
tmpContext.stroke();
} else if (obj.name == "platform") {
tmpContext.fillStyle = "#cebd5f";
let tmpCount = 4;
let tmpS = obj.scale * 2;
let tmpW = tmpS / tmpCount;
let tmpX = -(obj.scale / 2);
for (let i = 0; i < tmpCount; ++i) {
renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpX += tmpS / tmpCount;
}
} else if (obj.name == "healing pad") {
tmpContext.fillStyle = "#7e7f82";
renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#db6e6e";
renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
} else if (obj.name == "spawn pad") {
tmpContext.fillStyle = "#7e7f82";
renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#71aad6";
renderCircle(0, 0, obj.scale * 0.6, tmpContext);
} else if (obj.name == "blocker") {
tmpContext.fillStyle = "#7e7f82";
renderCircle(0, 0, obj.scale, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpContext.rotate(Math.PI / 4);
tmpContext.fillStyle = "#db6e6e";
renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
} else if (obj.name == "teleporter") {
tmpContext.fillStyle = "#7e7f82";
renderCircle(0, 0, obj.scale, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpContext.rotate(Math.PI / 4);
tmpContext.fillStyle = "#d76edb";
renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
}
tmpSprite = tmpCanvas;
if (!asIcon)
itemSprites[obj.id] = tmpSprite;
}
return tmpSprite;
}
function getItemSprite2(obj, tmpX, tmpY) {
let tmpContext = mainContext;
let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
tmpContext.save();
tmpContext.translate(tmpX, tmpY);
tmpContext.rotate(obj.dir);
tmpContext.strokeStyle = outlineColor;
tmpContext.lineWidth = outlineWidth;
if (obj.name == "apple") {
tmpContext.fillStyle = "#c15555";
renderCircle(0, 0, obj.scale, tmpContext);
tmpContext.fillStyle = "#89a54c";
let leafDir = -(Math.PI / 2);
renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
25, leafDir + Math.PI / 2, tmpContext);
} else if (obj.name == "cookie") {
tmpContext.fillStyle = "#cca861";
renderCircle(0, 0, obj.scale, tmpContext);
tmpContext.fillStyle = "#937c4b";
let chips = 4;
let rotVal = (Math.PI * 2) / chips;
let tmpRange;
for (let i = 0; i < chips; ++i) {
tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange *
Math.sin(rotVal * i),
UTILS.randInt(4, 5), tmpContext, true);
}
} else if (obj.name == "cheese") {
tmpContext.fillStyle = "#f4f3ac";
renderCircle(0, 0, obj.scale, tmpContext);
tmpContext.fillStyle = "#c3c28b";
let chips = 4;
let rotVal = (Math.PI * 2) / chips;
let tmpRange;
for (let i = 0; i < chips; ++i) {
tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange *
Math.sin(rotVal * i),
UTILS.randInt(4, 5), tmpContext, true);
}
} else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name ==
"castle wall") {
tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name
== "wood wall") ?
"#a5974c" : "#939393";
let sides = (obj.name == "castle wall") ? 4 : 3;
renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name
== "wood wall") ?
"#c9b758" : "#bcbcbc";
renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
tmpContext.fill();
} else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name ==
"poison spikes" ||
obj.name == "spinning spikes") {
tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" :
"#939393";
let tmpScale = (obj.scale * 0.6);
renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale,
tmpScale);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#a5974c";
renderCircle(0, 0, tmpScale, tmpContext);
tmpContext.fillStyle = "#c9b758";
renderCircle(0, 0, tmpScale / 2, tmpContext, true);
} else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name
== "power mill") {
tmpContext.fillStyle = "#a5974c";
renderCircle(0, 0, reScale, tmpContext);
tmpContext.fillStyle = "#c9b758";
renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
tmpContext.fillStyle = "#a5974c";
renderCircle(0, 0, reScale * 0.5, tmpContext);
} else if (obj.name == "mine") {
tmpContext.fillStyle = "#939393";
renderStar(tmpContext, 3, obj.scale, obj.scale);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#bcbcbc";
renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
tmpContext.fill();
} else if (obj.name == "sapling") {
for (let i = 0; i < 2; ++i) {
let tmpScale = obj.scale * (!i ? 1 : 0.5);
renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
tmpContext.fill();
if (!i) tmpContext.stroke();
}
} else if (obj.name == "pit trap") {
tmpContext.fillStyle = "#a5974c";
renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = outlineColor;
renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
tmpContext.fill();
} else if (obj.name == "boost pad") {
tmpContext.fillStyle = "#7e7f82";
renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#dbd97d";
renderTriangle(obj.scale * 1, tmpContext);
} else if (obj.name == "turret") {
tmpContext.fillStyle = "#a5974c";
renderCircle(0, 0, obj.scale, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#939393";
let tmpLen = 50;
renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
renderCircle(0, 0, obj.scale * 0.6, tmpContext);
tmpContext.fill();
tmpContext.stroke();
} else if (obj.name == "platform") {
tmpContext.fillStyle = "#cebd5f";
let tmpCount = 4;
let tmpS = obj.scale * 2;
let tmpW = tmpS / tmpCount;
let tmpX = -(obj.scale / 2);
for (let i = 0; i < tmpCount; ++i) {
renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpX += tmpS / tmpCount;
}
} else if (obj.name == "healing pad") {
tmpContext.fillStyle = "#7e7f82";
renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#db6e6e";
renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
} else if (obj.name == "spawn pad") {
tmpContext.fillStyle = "#7e7f82";
renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#71aad6";
renderCircle(0, 0, obj.scale * 0.6, tmpContext);
} else if (obj.name == "blocker") {
tmpContext.fillStyle = "#7e7f82";
renderCircle(0, 0, obj.scale, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpContext.rotate(Math.PI / 4);
tmpContext.fillStyle = "#db6e6e";
renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
} else if (obj.name == "teleporter") {
tmpContext.fillStyle = "#7e7f82";
renderCircle(0, 0, obj.scale, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpContext.rotate(Math.PI / 4);
tmpContext.fillStyle = "#d76edb";
renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
}
tmpContext.restore();
}
let objSprites = [];
function getObjSprite(obj) {
let tmpSprite = objSprites[obj.id];
if (!tmpSprite) {
// let blurScale = isNight ? 20 : 0;
let tmpCanvas = document.createElement("canvas");
tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth +
(items.list[obj.id].spritePadding || 0) + 0;
let tmpContext = tmpCanvas.getContext("2d");
tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
tmpContext.rotate(Math.PI / 2);
tmpContext.strokeStyle = outlineColor;
tmpContext.lineWidth = outlineWidth;
// if (isNight) {
// tmpContext.shadowBlur = 20;
// tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3,
obj.alpha)})`;
// }
if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name ==
"poison spikes" || obj.name == "spinning spikes") {
tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" :
"#939393";
let tmpScale = obj.scale * 0.6;
renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale,
tmpScale);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#a5974c";
renderCircle(0, 0, tmpScale, tmpContext);
tmpContext.fillStyle = "#cc5151";
renderCircle(0, 0, tmpScale / 2, tmpContext, true);
} else if (obj.name == "pit trap") {
tmpContext.fillStyle = "#a5974c";
renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#cc5151";
renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
tmpContext.fill();
}
tmpSprite = tmpCanvas;
objSprites[obj.id] = tmpSprite;
}
return tmpSprite;
}
// GET MARK SPRITE:
function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
let center = {
x: screenWidth / 2,
y: screenHeight / 2,
};
tmpContext.lineWidth = outlineWidth;
mainContext.globalAlpha = 0.2;
tmpContext.strokeStyle = outlineColor;
tmpContext.save();
tmpContext.translate(tmpX, tmpY);
tmpContext.rotate(90**10);
if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison
spikes" || obj.name == "spinning spikes") {
tmpContext.fillStyle = (obj.name == "poison spikes")?"#7b935d":"#939393";
var tmpScale = (obj.scale);
renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#a5974c";
renderCircle(0, 0, tmpScale, tmpContext);
if (player && obj.owner && player.sid != obj.owner.sid && !
tmpObj.findAllianceBySid(obj.owner.sid)) {
tmpContext.fillStyle = "#a34040";
} else {
tmpContext.fillStyle = "#c9b758";
}
renderCircle(0, 0, tmpScale/2, tmpContext, true);
} else if (obj.name == "turret") {
renderCircle(0, 0, obj.scale, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#939393";
let tmpLen = 50;
renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
renderCircle(0, 0, obj.scale * 0.6, tmpContext);
tmpContext.fill();
tmpContext.stroke();
} else if (obj.name == "teleporter") {
tmpContext.fillStyle = "#7e7f82";
renderCircle(0, 0, obj.scale, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpContext.rotate(Math.PI / 4);
tmpContext.fillStyle = "#d76edb";
renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
} else if (obj.name == "platform") {
tmpContext.fillStyle = "#cebd5f";
let tmpCount = 4;
let tmpS = obj.scale * 2;
let tmpW = tmpS / tmpCount;
let tmpX = -(obj.scale / 2);
for (let i = 0; i < tmpCount; ++i) {
renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpX += tmpS / tmpCount;
}
} else if (obj.name == "healing pad") {
tmpContext.fillStyle = "#7e7f82";
renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#db6e6e";
renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
} else if (obj.name == "spawn pad") {
tmpContext.fillStyle = "#7e7f82";
renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpContext.fillStyle = "#71aad6";
renderCircle(0, 0, obj.scale * 0.6, tmpContext);
} else if (obj.name == "blocker") {
tmpContext.fillStyle = "#7e7f82";
renderCircle(0, 0, obj.scale, tmpContext);
tmpContext.fill();
tmpContext.stroke();
tmpContext.rotate(Math.PI / 4);
tmpContext.fillStyle = "#db6e6e";
renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
} else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name
== "power mill") {
tmpContext.fillStyle = "#a5974c";
renderCircle(0, 0, obj.scale, tmpContext);
tmpContext.fillStyle = "#c9b758";
renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
tmpContext.fillStyle = "#a5974c";
renderCircle(0, 0, obj.scale * 0.5, tmpContext);
} else if (obj.name == "pit trap") {
tmpContext.fillStyle = "#a5974c";
renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
tmpContext.fill();
tmpContext.stroke();
if (player && obj.owner && player.sid != obj.owner.sid && !
tmpObj.findAllianceBySid(obj.owner.sid)) {
tmpContext.fillStyle = "#a34040";
} else {
tmpContext.fillStyle = outlineColor;
}
renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
tmpContext.fill();
}
tmpContext.restore();
}
// OBJECT ON SCREEN:
function isOnScreen(x, y, s) {
return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
s,
maxScreenHeight));
}
// RENDER GAME OBJECTS:
function renderGameObjects(layer, xOffset, yOffset) {
let tmpSprite;
let tmpX;
let tmpY;
liztobj.forEach((tmp) => {
tmpObj = tmp;
if (tmpObj.active && liztobj.includes(tmp) && tmpObj.render) {
tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
if (layer == 0) {
tmpObj.update(delta);
}
if (getEl("mode").value == 'fuckemup' && cdf(tmpObj, player) <= 600 &&
tmpObj.isItem) {
mainContext.globalAlpha = tmpObj.alpha/2;
} else {
mainContext.globalAlpha = tmpObj.alpha;
}
if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale +
(tmpObj.blocker || 0))) {
if (tmpObj.isItem) {
if ((tmpObj.dmg || tmpObj.trap) && !
tmpObj.isTeamObject(player)) {
tmpSprite = getObjSprite(tmpObj);
} else {
tmpSprite = getItemSprite(tmpObj);
}
mainContext.save();
mainContext.translate(tmpX, tmpY);
mainContext.rotate(tmpObj.dir);
if (!tmpObj.active) {
mainContext.scale(tmpObj.visScale / tmpObj.scale,
tmpObj.visScale / tmpObj.scale);
}
mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -
(tmpSprite.height / 2));
if (tmpObj.blocker) {
mainContext.strokeStyle = "#db6e6e";
mainContext.globalAlpha = 0.3;
mainContext.lineWidth = 6;
renderCircle(0, 0, tmpObj.blocker, mainContext, false,
true);
}
mainContext.restore();
} else {
tmpSprite = getResSprite(tmpObj);
mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2),
tmpY - (tmpSprite.height / 2));
}
}
if (layer == 3 && !useWasd) {
if (tmpObj.health < tmpObj.maxHealth) {
// HEALTH HOLDER:
mainContext.fillStyle = darkOutlineColor;
mainContext.roundRect(tmpX - config.healthBarWidth / 2 -
config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth +
config.healthBarPad * 2, 17, 8);
mainContext.fill();
// HEALTH BAR:
mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#8ecc51"
: "#cc5151";
mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY,
config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 -
config.healthBarPad * 2, 7);
mainContext.fill();
}
}
}
});
// PLACE VISIBLE:
if (layer == 0) {
if (placeVisible.length) {
placeVisible.forEach((places) => {
tmpX = places.x - xOffset;
tmpY = places.y - yOffset;
markObject(places, tmpX, tmpY);
});
}
}
}
function markObject(tmpObj, tmpX, tmpY) {
getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
}
// RENDER MINIMAP:
class MapPing {
constructor(color, scale) {
this.init = function(x, y) {
this.scale = 0;
this.x = x;
this.y = y;
this.active = true;
};
this.update = function(ctxt, delta) {
if (this.active) {
this.scale += 0.05 * delta;
if (this.scale >= scale) {
this.active = false;
} else {
ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
ctxt.beginPath();
ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y
/ config.mapScale) *
mapDisplay.width, this.scale, 0, 2 * Math.PI);
ctxt.stroke();
}
}
};
this.color = color;
}
}
function pingMap(x, y) {
tmpPing = mapPings.find(pings => !pings.active);
if (!tmpPing) {
tmpPing = new MapPing("#fff", config.mapPingScale);
mapPings.push(tmpPing);
}
tmpPing.init(x, y);
}
function updateMapMarker() {
mapMarker.x = player.x;
mapMarker.y = player.y;
}
function renderMinimap(delta) {
if (player && player.alive) {
mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
// RENDER PINGS:
mapContext.lineWidth = 4;
for (let i = 0; i < mapPings.length; ++i) {
tmpPing = mapPings[i];
mapContext.strokeStyle = tmpPing.color;
tmpPing.update(mapContext, delta);
}
// RENDER BREAK TRACKS:
mapContext.globalAlpha = 1;
mapContext.fillStyle = "#ff0000";
if (breakTrackers.length) {
mapContext.fillStyle = "#abcdef";
mapContext.font = "34px Hammersmith One";
mapContext.textBaseline = "middle";
mapContext.textAlign = "center";
for (let i = 0; i < breakTrackers.length;) {
mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) *
mapDisplay.width,
(breakTrackers[i].y / config.mapScale) *
mapDisplay.height);
i += 2;
}
}
// RENDER PLAYERS:
mapContext.globalAlpha = 1;
mapContext.fillStyle = "#fff";
renderCircle((player.x / config.mapScale) * mapDisplay.width,
(player.y / config.mapScale) * mapDisplay.height, 7,
mapContext, true);
mapContext.fillStyle = "rgba(255,255,255,0.35)";
if (player.team && minimapData) {
for (let i = 0; i < minimapData.length;) {
renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
(minimapData[i + 1] / config.mapScale) *
mapDisplay.height, 7, mapContext, true);
i += 2;
}
}
// RENDER BOTS:
if (bots.length) {
bots.forEach((tmp) => {
if (tmp.inGame) {
mapContext.globalAlpha = 1;
mapContext.strokeStyle = "#cc5151";
renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
(tmp.y2 / config.mapScale) * mapDisplay.height, 7,
mapContext, false, true);
}
});
}
// DEATH LOCATION:
if (lastDeath) {
mapContext.fillStyle = "#fc5553";
mapContext.font = "34px Hammersmith One";
mapContext.textBaseline = "middle";
mapContext.textAlign = "center";
mapContext.fillText("x", (lastDeath.x / config.mapScale) *
mapDisplay.width,
(lastDeath.y / config.mapScale) *
mapDisplay.height);
}
// MAP MARKER:
if (mapMarker) {
mapContext.fillStyle = "#fff";
mapContext.font = "34px Hammersmith One";
mapContext.textBaseline = "middle";
mapContext.textAlign = "center";
mapContext.fillText("x", (mapMarker.x / config.mapScale) *
mapDisplay.width,
(mapMarker.y / config.mapScale) *
mapDisplay.height);
}
}
}
// ICONS:
let crossHairs =
["https://cdn.discordapp.com/attachments/1001384433078779927/1149285738412769300/
newawwddd.png",
"https://cdn.discordapp.com/attachments/1001384433078779927/1149285168780165170/100
px-Crosshairs_Red.png"];
let crossHairSprites = {};
let iconSprites = {};
let icons = ["crown", "skull"];
function loadIcons() {
for (let i = 0; i < icons.length; ++i) {
let tmpSprite = new Image();
tmpSprite.onload = function() {
this.isLoaded = true;
};
tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
iconSprites[icons[i]] = tmpSprite;
}
for (let i = 0; i < crossHairs.length; ++i) {
let tmpSprite = new Image();
tmpSprite.onload = function() {
this.isLoaded = true;
};
tmpSprite.src = crossHairs[i];
crossHairSprites[i] = tmpSprite;
}
}
loadIcons();
function cdf (e, t){
try {
return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
} catch(e){
return Infinity;
}
}
// UPDATE GAME:
function updateGame() {
if(gameObjects.length && inGame) {
gameObjects.forEach((tmp) => {
if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= 1200) {
if(!liztobj.includes(tmp)) {
liztobj.push(tmp);
tmp.render = true;
}
} else {
if(liztobj.includes(tmp)) {
if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200)
{
tmp.render = false;
const index = liztobj.indexOf(tmp);
if (index > -1) { // only splice array when item is found
liztobj.splice(index, 1); // 2nd parameter means remove
one item only
}
}
} else if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >=
1200) {
tmp.render = false;
const index = liztobj.indexOf(tmp);
if (index > -1) { // only splice array when item is found
liztobj.splice(index, 1); // 2nd parameter means remove one
item only
}
} else {
tmp.render = false;
const index = liztobj.indexOf(tmp);
if (index > -1) { // only splice array when item is found
liztobj.splice(index, 1); // 2nd parameter means remove one
item only
}
}
}
})
// gameObjects = gameObjects.filter(e => UTILS.getDistance(e.x, e.y,
player.x, player.y) <= 1000)
}
// if (config.resetRender) {
mainContext.beginPath();
mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
// }
mainContext.globalAlpha = 1;
// MOVE CAMERA:
if (player) {
if (false) {
camX = player.x;
camY = player.y;
} else {
let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
let camSpd = Math.min(tmpDist * 0.0045 * delta, tmpDist);
if (tmpDist > 0.05) {
camX += camSpd * Math.cos(tmpDir);
camY += camSpd * Math.sin(tmpDir);
} else {
camX = player.x;
camY = player.y;
}
}
} else {
camX = config.mapScale / 2 + config.riverWidth;
camY = config.mapScale / 2;
}
// INTERPOLATE PLAYERS AND AI:
let lastTime = now - (1000 / config.serverUpdateRate);
let tmpDiff;
for (let i = 0; i < players.length + ais.length; ++i) {
tmpObj = players[i] || ais[i - players.length];
if (tmpObj && tmpObj.visible) {
if (tmpObj.forcePos) {
tmpObj.x = tmpObj.x2;
tmpObj.y = tmpObj.y2;
tmpObj.dir = tmpObj.d2;
} else {
let total = tmpObj.t2 - tmpObj.t1;
let fraction = lastTime - tmpObj.t1;
let ratio = (fraction / total);
let rate = 170;
tmpObj.dt += delta;
let tmpRate = Math.min(1.7, tmpObj.dt / rate);
tmpDiff = (tmpObj.x2 - tmpObj.x1);
tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
tmpDiff = (tmpObj.y2 - tmpObj.y1);
tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
if (config.anotherVisual) {
tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2,
ratio));
} else {
tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2,
ratio));
}
}
}
}
// RENDER CORDS:
let xOffset = camX - (maxScreenWidth / 2);
let yOffset = camY - (maxScreenHeight / 2);
// RENDER BACKGROUND:
if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop
- yOffset >= maxScreenHeight) {
mainContext.fillStyle = "#b6db66";
mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
} else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
mainContext.fillStyle = "#dbc666";
mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
} else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
mainContext.fillStyle = "#fff";
mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
} else if (config.snowBiomeTop - yOffset >= 0) {
mainContext.fillStyle = "#fff";
mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
mainContext.fillStyle = "#b6db66";
mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
maxScreenHeight - (config.snowBiomeTop - yOffset));
} else {
mainContext.fillStyle = "#b6db66";
mainContext.fillRect(0, 0, maxScreenWidth,
(config.mapScale - config.snowBiomeTop - yOffset));
mainContext.fillStyle = "#dbc666";
mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset),
maxScreenWidth,
maxScreenHeight - (config.mapScale -
config.snowBiomeTop - yOffset));
}
// RENDER WATER AREAS:
if (!firstSetup) {
waterMult += waterPlus * config.waveSpeed * delta;
if (waterMult >= config.waveMax) {
waterMult = config.waveMax;
waterPlus = -1;
} else if (waterMult <= 1) {
waterMult = waterPlus = 1;
}
mainContext.globalAlpha = 1;
mainContext.fillStyle = "#dbc666";
renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
mainContext.fillStyle = "#91b2db";
renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
}
// RENDER DEAD PLAYERS:
mainContext.globalAlpha = 1;
mainContext.strokeStyle = outlineColor;
renderDeadPlayers(xOffset, yOffset);
// RENDER BOTTOM LAYER:
mainContext.globalAlpha = 1;
mainContext.strokeStyle = outlineColor;
renderGameObjects(-1, xOffset, yOffset);
// RENDER PROJECTILES:
mainContext.globalAlpha = 1;
mainContext.lineWidth = outlineWidth;
renderProjectiles(0, xOffset, yOffset);
// RENDER PLAYERS:
renderPlayers(xOffset, yOffset, 0);
// RENDER AI:
mainContext.globalAlpha = 1;
for (let i = 0; i < ais.length; ++i) {
tmpObj = ais[i];
if (tmpObj.active && tmpObj.visible) {
tmpObj.animate(delta);
mainContext.save();
mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
renderAI(tmpObj, mainContext);
mainContext.restore();
}
}
// RENDER GAME OBJECTS (LAYERED):
renderGameObjects(0, xOffset, yOffset);
renderProjectiles(1, xOffset, yOffset);
renderGameObjects(1, xOffset, yOffset);
renderPlayers(xOffset, yOffset, 1);
renderGameObjects(2, xOffset, yOffset);
renderGameObjects(3, xOffset, yOffset);
// MAP BOUNDARIES:
mainContext.fillStyle = "#000";
mainContext.globalAlpha = 0.09;
if (xOffset <= 0) {
mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
}
if (config.mapScale - xOffset <= maxScreenWidth) {
let tmpY = Math.max(0, -yOffset);
mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth -
(config.mapScale - xOffset), maxScreenHeight - tmpY);
}
if (yOffset <= 0) {
mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
}
if (config.mapScale - yOffset <= maxScreenHeight) {
let tmpX = Math.max(0, -xOffset);
let tmpMin = 0;
if (config.mapScale - xOffset <= maxScreenWidth)
tmpMin = maxScreenWidth - (config.mapScale - xOffset);
mainContext.fillRect(tmpX, config.mapScale - yOffset,
(maxScreenWidth - tmpX) - tmpMin, maxScreenHeight -
(config.mapScale - yOffset));
}
// RENDER DAY/NIGHT TIME:
mainContext.globalAlpha = 1;
mainContext.fillStyle = "rgba(0, 5, 80, 0.425)";
mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
// RENDER PLAYER AND AI UI:
mainContext.strokeStyle = darkOutlineColor;
mainContext.globalAlpha = 1;
if (getEl("mode").value == 'fuckemup') {
mainContext.beginPath();
mainContext.strokeStyle = "#000";
mainContext.fillStyle = "#000";
mainContext.globalAlpha = 0.3;
mainContext.lineWidth = 6;
mainContext.arc(player.x - xOffset, player.y - yOffset, 600, 0, 2 *
Math.PI);
mainContext.stroke();
mainContext.globalAlpha = 0.05;
mainContext.fill();
mainContext.closePath();
}
if (playerPrediction) {
mainContext.beginPath();
mainContext.strokeStyle = "#000";
mainContext.fillStyle = "#000";
mainContext.globalAlpha = 0.3;
mainContext.lineWidth = 6;
mainContext.arc(playerPrediction.x - xOffset, playerPrediction.y - yOffset,
player.scale, 0, 2 * Math.PI);
mainContext.stroke();
mainContext.fill();
mainContext.closePath();
}
mainContext.beginPath();
for (let i = 0; i < players.length + ais.length; ++i) {
tmpObj = players[i] || ais[i - players.length];
if (tmpObj.visible && tmpObj.showName === 'NOOO') {
mainContext.strokeStyle = darkOutlineColor;
// NAME AND HEALTH:
// let izbot = false;
// bots.forEach((bot) => {
// if (tmpObj.sid == bot.sid) izbot = true
// else izbot = false;
// });
let tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") +
(tmpObj.name || ""); //+ (tmpObj.isPlayer ? " {" + tmpObj.sid + "}" : "");
if (tmpText != "" && tmpObj.name != "Nitro For Bots") {
// bots.forEach((bot) => {
// if (tmpObj.sid == bot.sid) return;
// });
mainContext.globalAlpha = 1;
mainContext.font = (tmpObj.nameScale || 30) + "px Hammersmith One";
mainContext.fillStyle = "#fff";
mainContext.textBaseline = "middle";
mainContext.textAlign = "center";
mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
mainContext.lineJoin = "round";
mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y -
yOffset - tmpObj.scale) - config.nameY);
mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y -
yOffset - tmpObj.scale) - config.nameY);
if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
let tmpS = config.crownIconScale;
let tmpX = tmpObj.x - xOffset - (tmpS / 2) -
(mainContext.measureText(tmpText).width / 2) - config.crownPad;
mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y -
yOffset - tmpObj.scale) -
config.nameY - (tmpS / 2) - 5, tmpS,
tmpS);
}
if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
let tmpS = config.crownIconScale;
let tmpX = tmpObj.x - xOffset - (tmpS / 2) +
(mainContext.measureText(tmpText).width / 2) + config.crownPad;
mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y -
yOffset - tmpObj.scale) -
config.nameY - (tmpS / 2) - 5, tmpS,
tmpS);
}
if (tmpObj.isPlayer && instaC.wait && near == tmpObj &&
(tmpObj.backupNobull ? crossHairSprites[1].isLoaded : crossHairSprites[0].isLoaded)
&& enemy.length && !useWasd) {
let tmpS = tmpObj.scale * 2.2;
mainContext.drawImage((tmpObj.backupNobull ?
crossHairSprites[1] : crossHairSprites[0]), tmpObj.x - xOffset - tmpS / 2, tmpObj.y
- yOffset - tmpS / 2, tmpS, tmpS);
}
// izbot = false;
}
if (tmpObj.health > 0) {
if(tmpObj.name != "Free Gold") {
// HEALTH HOLDER:
mainContext.fillStyle = darkOutlineColor;
mainContext.roundRect(tmpObj.x - xOffset -
config.healthBarWidth - config.healthBarPad,
(tmpObj.y - yOffset + tmpObj.scale) +
config.nameY, (config.healthBarWidth * 2) +
(config.healthBarPad * 2), 17, 8);
mainContext.fill();
// HEALTH BAR:
mainContext.fillStyle = (tmpObj == player || (tmpObj.team &&
tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
mainContext.roundRect(tmpObj.x - xOffset -
config.healthBarWidth,
(tmpObj.y - yOffset + tmpObj.scale) +
config.nameY + config.healthBarPad,
((config.healthBarWidth * 2) *
(tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
mainContext.fill();
}
if (tmpObj.isPlayer) {
mainContext.globalAlpha = 1;
let targetReloads = {
primary: (tmpObj.primaryIndex == undefined ? 1 :
((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) /
items.weapons[tmpObj.primaryIndex].speed)),
secondary: (tmpObj.secondaryIndex == undefined ? 1 :
((items.weapons[tmpObj.secondaryIndex].speed -
tmpObj.reloads[tmpObj.secondaryIndex]) /
items.weapons[tmpObj.secondaryIndex].speed)),
turret: (2500 - tmpObj.reloads[53]) / 2500
};
if (!tmpObj.currentReloads) {
tmpObj.currentReloads = { // Initialize currentReloads if
not already set
primary: targetReloads.primary,
secondary: targetReloads.secondary,
turret: targetReloads.turret
};
}
const lerpFactor = 0.3;
tmpObj.currentReloads.primary = (1 - lerpFactor) *
tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
tmpObj.currentReloads.secondary = (1 - lerpFactor) *
tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
tmpObj.currentReloads.turret = (1 - lerpFactor) *
tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
let primaryReloadProgress = tmpObj.primaryIndex !== undefined ?
((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) /
items.weapons[tmpObj.primaryIndex].speed) : 1;
let secondaryReloadProgress = tmpObj.secondaryIndex !==
undefined ? ((items.weapons[tmpObj.secondaryIndex].speed -
tmpObj.reloads[tmpObj.secondaryIndex]) /
items.weapons[tmpObj.secondaryIndex].speed) : 1;
const centerX = tmpObj.x - xOffset;
const centerY = tmpObj.y - yOffset;
const barRadius = 35;
const barWidth = 15;
const totalAngle = (Math.PI*2)/3; // Half circle
const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 +
tmpObj.dir - Math.PI/2;
const secondaryEndAngle = secondaryStartAngle + (totalAngle *
tmpObj.currentReloads.secondary);
const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
const primaryEndAngle = primaryStartAngle + (totalAngle *
tmpObj.currentReloads.primary);
const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir -
Math.PI/2;
const turretEndAngle = turretStartAngle + (totalAngle/1.25 *
tmpObj.currentReloads.turret);
function returncoolcolor(RainbowCycle) {
return `hsl(${RainbowCycle-50}, 85%, 50%, 30)`;
}
mainContext.save();
if (tmpObj.currentReloads.primary < 0.999) {
mainContext.beginPath();
mainContext.lineCap = 'round';
mainContext.arc(centerX, centerY, barRadius,
primaryStartAngle, primaryEndAngle);
mainContext.lineWidth = 4;
mainContext.strokeStyle =
returncoolcolor(tmpObj.currentReloads.primary * 240);
mainContext.stroke();
}
if (tmpObj.currentReloads.secondary < 0.999) {
mainContext.beginPath();
mainContext.lineCap = 'round';
mainContext.arc(centerX, centerY, barRadius,
secondaryStartAngle, secondaryEndAngle);
mainContext.lineWidth = 4;
mainContext.strokeStyle =
returncoolcolor(tmpObj.currentReloads.secondary * 240);
mainContext.stroke();
}
if (tmpObj.currentReloads.turret < 0.999) {
mainContext.beginPath();
mainContext.lineCap = 'round';
mainContext.arc(centerX, centerY, barRadius,
turretStartAngle, turretEndAngle);
mainContext.lineWidth = 4;
mainContext.strokeStyle =
returncoolcolor(tmpObj.currentReloads.turret * 240);
mainContext.stroke();
}
mainContext.restore();
if(tmpObj.name != "Nitro For Bots") {
// SHAME COUNT:
mainContext.globalAlpha = 1;
mainContext.font = "24px Hammersmith One";
mainContext.fillStyle = "#fff";
mainContext.strokeStyle = darkOutlineColor;
mainContext.textBaseline = "middle";
mainContext.textAlign = "center";
mainContext.lineWidth = 8;
mainContext.lineJoin = "round";
let tmpS = config.crownIconScale;
let tmpX = tmpObj.x - xOffset - tmpS / 2 + config.crownPad
- 2;
mainContext.strokeText('[' + (tmpObj.skinIndex == 45 &&
tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' +
Math.round(tmpObj.pinge) + '/' + tmpObj.lastshamecount + ']', tmpX, tmpObj.y -
yOffset - tmpObj.scale - config.nameY + 175);
mainContext.fillText('[' + (tmpObj.skinIndex == 45 &&
tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' +
Math.round(tmpObj.pinge) + '/' + tmpObj.lastshamecount + ']', tmpX, tmpObj.y -
yOffset - tmpObj.scale - config.nameY + 175);
}
// PLAYER TRACER:
if (!tmpObj.isTeam(player)) {
let center = {
x: screenWidth / 2,
y: screenHeight / 2,
};
let alpha = Math.min(1, (UTILS.getDistance(0, 0, player.x -
tmpObj.x, (player.y - tmpObj.y) * (16 / 9)) * 100) / (config.maxScreenHeight / 2) /
center.y);
let dist = center.y * alpha / 2;
let tmpX = dist * Math.cos(UTILS.getDirect(tmpObj, player,
0, 0));
let tmpY = dist * Math.sin(UTILS.getDirect(tmpObj, player,
0, 0));
mainContext.save();
mainContext.translate((player.x - xOffset) + tmpX,
(player.y - yOffset) + tmpY);
mainContext.rotate(tmpObj.aim2 + Math.PI / 2);
let by = 255 - (tmpObj.sid * 2);
mainContext.fillStyle = `rgb(${by}, ${by}, ${by})`;
mainContext.globalAlpha = alpha;
let renderTracer = function(s, ctx) {
ctx = ctx || mainContext;
let h = s * (Math.sqrt(3) / 2);
ctx.beginPath();
ctx.moveTo(0, -h / 1.5);
ctx.lineTo(-s / 2, h / 2);
ctx.lineTo(s / 2, h / 2);
ctx.lineTo(0, -h / 1.5);
ctx.fill();
ctx.closePath();
}
renderTracer(25, mainContext);
mainContext.restore();
}
if (getEl("predictType").value == "pre2") {
mainContext.lineWidth = 3;
mainContext.strokeStyle = "#fff";
mainContext.globalAlpha = 1;
mainContext.beginPath();
let render = {
x: tmpObj.x2 - xOffset,
y: tmpObj.y2 - yOffset
};
mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
mainContext.lineTo(render.x, render.y);
mainContext.stroke();
} else if (getEl("predictType").value == "pre3") {
mainContext.lineWidth = 3;
mainContext.strokeStyle = "#cc5151";
mainContext.globalAlpha = 1;
mainContext.beginPath();
let render = {
x: tmpObj.x3 - xOffset,
y: tmpObj.y3 - yOffset
};
mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
mainContext.lineTo(render.x, render.y);
mainContext.stroke();
}
}
}
}
}
if (player) {
// AUTOPUSH LINE:
if (my.autoPush && my.pushData) {
mainContext.lineWidth = 5;
mainContext.globalAlpha = 1;
mainContext.beginPath();
mainContext.strokeStyle = "white";
var x1 = player.x - xOffset;
var y1 = player.y - yOffset;
var x2 = my.pushData.x2 - xOffset;
var y2 = my.pushData.y2 - yOffset;
var x3 = my.pushData.x - xOffset;
var y3 = my.pushData.y - yOffset;
mainContext.moveTo(x1, y1);
mainContext.lineTo(x2, y2);
mainContext.lineTo(x3, y3);
mainContext.stroke();
var deltaX = x3 - x1;
var deltaY = y3 - y1;
var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
var maxDistance = 100;
var percentage = (distance / maxDistance) * 100;
percentage = Math.min(100, Math.max(0, percentage));
let spike;
mainContext.fillStyle = "white";
mainContext.strokeStyle = "black";
mainContext.lineWidth = 5;
mainContext.font = "30px Hammersmith One";
let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active &&
tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 2) <= (near.scale +
tmp.getScale() + 5)).sort(function(a, b) {
return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
})[0];
if(nearTrap)
spike = liztobj.filter(tmp => tmp.dmg && tmp.active &&
tmp.isTeamObject(player) && UTILS.getDist(tmp, nearTrap, 0, 0) <= (near.scale +
nearTrap.scale + tmp.scale)).sort(function(a, b) {
return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0,
2);
})[0];
let xx = (player.x - xOffset + near.x - xOffset) / 2;
let yy = (player.y - yOffset + near.y - yOffset) / 2;
mainContext.moveTo(player.x - xOffset, player.y - yOffset);
mainContext.strokeText(near.aim2, xx, yy);
mainContext.fillText(near.aim2, xx, yy);
}
}
mainContext.globalAlpha = 1;
// RENDER ANIM TEXTS:
textManager.update(delta, mainContext, xOffset, yOffset);
// RENDER CHAT MESSAGES:
for (let i = 0; i < players.length; ++i) {
tmpObj = players[i];
if (tmpObj.visible) {
if (tmpObj.chatCountdown > 0) {
tmpObj.chatCountdown -= delta;
if (tmpObj.chatCountdown <= 0)
tmpObj.chatCountdown = 0;
mainContext.font = "32px Hammersmith One";
let tmpSize = mainContext.measureText(tmpObj.chatMessage);
mainContext.textBaseline = "middle";
mainContext.textAlign = "center";
let tmpX = tmpObj.x - xOffset;
let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
let tmpH = 47;
let tmpW = tmpSize.width + 17;
mainContext.fillStyle = "rgba(0,0,0,0.2)";
mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH,
6);
mainContext.fill();
mainContext.fillStyle = "#fff";
mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
}
if (tmpObj.chat.count > 0) {
if (!useWasd) {
tmpObj.chat.count -= delta;
if (tmpObj.chat.count <= 0)
tmpObj.chat.count = 0;
mainContext.font = "32px Hammersmith One";
let tmpSize = mainContext.measureText(tmpObj.chat.message);
mainContext.textBaseline = "middle";
mainContext.textAlign = "center";
let tmpX = tmpObj.x - xOffset;
let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
let tmpH = 47;
let tmpW = tmpSize.width + 17;
mainContext.fillStyle = "rgba(0,0,0,0.2)";
mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW,
tmpH, 6);
mainContext.fill();
mainContext.fillStyle = "#ffffff99";
mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
} else {
tmpObj.chat.count = 0;
}
}
}
}
if (allChats.length) {
allChats.filter(ch => ch.active).forEach((ch) => {
if (!ch.alive) {
if (ch.alpha <= 1) {
ch.alpha += delta / 250;
if (ch.alpha >= 1) {
ch.alpha = 1;
ch.alive = true;
}
}
} else {
ch.alpha -= delta / 5000;
if (ch.alpha <= 0) {
ch.alpha = 0;
ch.active = false;
}
}
if (ch.active) {
mainContext.font = "20px Ubuntu";
let tmpSize = mainContext.measureText(ch.chat);
mainContext.textBaseline = "middle";
mainContext.textAlign = "center";
let tmpX = ch.x - xOffset;
let tmpY = ch.y - yOffset - 90;
let tmpH = 40;
let tmpW = tmpSize.width + 15;
mainContext.globalAlpha = ch.alpha;
mainContext.fillStyle = ch.owner.isTeam(player) ? "#8ecc51" :
"#cc5151";
mainContext.strokeStyle = "rgb(25, 25, 25)";
mainContext.strokeText(ch.owner.name, tmpX, tmpY - 45);
mainContext.fillText(ch.owner.name, tmpX, tmpY - 45);
mainContext.lineWidth = 5;
mainContext.fillStyle = "#ccc";
mainContext.strokeStyle = "rgb(25, 25, 25)";
mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH,
6);
mainContext.stroke();
mainContext.fill();
mainContext.fillStyle = "#fff";
mainContext.strokeStyle = "#000";
mainContext.strokeText(ch.chat, tmpX, tmpY);
mainContext.fillText(ch.chat, tmpX, tmpY);
ch.y -= delta / 100;
}
});
}
mainContext.globalAlpha = 1;
// RENDER MINIMAP:
renderMinimap(delta);
}
// UPDATE & ANIMATE:
window.requestAnimFrame = function() {
return null;
}
window.rAF = (function() {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
function(callback) {
window.setTimeout(callback, 1000/9);
};
})();
function doUpdate() {
//rape modulus
now = performance.now();
delta = now - lastUpdate;
lastUpdate = now;
let timer = performance.now();
let diff = timer - fpsTimer.last;
if (diff >= 1000) {
fpsTimer.ltime = fpsTimer.time * (1000 / diff);
fpsTimer.last = timer;
fpsTimer.time = 0;
}
fpsTimer.time++;
getEl("pingFps").innerHTML = `${window.pingTime}ms | Fps: $
{Math.round(fpsTimer.ltime)}`;
getEl("packetStatus").innerHTML = secPacket;
updateGame();
rAF(doUpdate);
ms.avg = Math.round((ms.min+ms.max)/2);
}
prepareMenuBackground();
doUpdate();
function toggleUseless(boolean) {
getEl("instaType").disabled = boolean;
getEl("antiBullType").disabled = boolean;
getEl("predictType").disabled = boolean;
}
toggleUseless(useWasd);
let changeDays = {};
window.debug = function() {
my.waitHit = 0;
my.autoAim = false;
instaC.isTrue = false;
traps.inTrap = false;
itemSprites = [];
objSprites = [];
gameObjectSprites = [];
};
window.wasdMode = function() {
useWasd = !useWasd;
toggleUseless(useWasd);
};
window.startGrind = function() {
if (getEl("weaponGrind").checked) {
for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
checkPlace(player.getItemType(22), i);
}
}
};
// REMOVED!!! so they cant abuse :)
let projects = [
"adorable-eight-guppy",
"galvanized-bittersweet-windshield"
];
let botIDS = 0;
window.connectFillBots = function() {
botSkts = [];
botIDS = 0;
for (let i = 0; i < projects.length; i++) {
let test = new WebSocket(`wss://$eggplant-accurate-bottom.glitch.me`);
test.binaryType = "arraybuffer";
test.onopen = function() {
test.ssend = function(type) {
let data = Array.prototype.slice.call(arguments, 1);
let binary = window.msgpack.encode([type, data]);
test.send(binary);
};
for (let i = 0; i < 4; i++) {
window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-
VoPATP", {
action: "homepage"
}).then(function(token) {
let t = WS.url.split("wss://")[1].split("?")[0];
test.ssend("bots", "wss://" + t + "?token=re:" +
encodeURIComponent(token), botIDS);
botSkts.push([test]);
botIDS++;
});
}
};
test.onmessage = function(message) {
let data = new Uint8Array(message.data);
let parsed = window.msgpack.decode(data);
let type = parsed[0];
data = parsed[1];
};
}
};
window.destroyFillBots = function() {
botSkts.forEach((socket) => {
socket[0].close();
});
botSkts = [];
};
window.tryConnectBots = function() {
for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
action: "homepage"
}).then(function(token) {
// CONNECT SOCKET:
botSpawn(token);
});
}
};
window.destroyBots = function() {
bots.forEach((botyyyyy) => {
botyyyyy.closeSocket = true;
});
bots = [];
};
window.resBuild = function() {
if (gameObjects.length) {
gameObjects.forEach((tmp) => {
tmp.breakObj = false;
});
breakObjects = [];
}
};
window.toggleBotsCircle = function() {
player.circle = !player.circle;
};
window.toggleVisual = function() {
config.anotherVisual = !config.anotherVisual;
gameObjects.forEach((tmp) => {
if (tmp.active) {
tmp.dir = tmp.lastDir;
}
});
};
window.prepareUI = function(tmpObj) {
resize();
// CHAT STUFF:
var chatBox = document.getElementById("chatBox");
var chatHolder = document.getElementById("chatHolder");
var suggestBox = document.createElement("div");
suggestBox.id = "suggestBox";
var prevChats = [];
var prevChatsIndex = 0;
function toggleChat() {
if (!usingTouch) {
if (chatHolder.style.display == "block") {
if (chatBox.value) {
sendChat(chatBox.value);
}
closeChat();
} else {
storeMenu.style.display = "none";
allianceMenu.style.display = "none";
chatHolder.style.display = "block";
chatBox.focus();
resetMoveDir();
}
} else {
setTimeout(function () {
var chatMessage = prompt("chat message");
if (chatMessage) {
sendChat(chatMessage);
}
}, 1);
}
chatBox.value = "";
(() => {
prevChatsIndex = 0;
})();
}
function closeChat() {
chatBox.value = "";
chatHolder.style.display = "none";
}
// ACTION BAR:
UTILS.removeAllChildren(actionBar);
for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
(function (i) {
UTILS.generateElement({
id: "actionBarItem" + i,
class: "actionBarItem",
style: "display:none; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5)",
onmouseout: function () {
showItemInfo();
},
parent: actionBar
});
})(i);
}
for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
(function (i) {
let tmpCanvas = document.createElement("canvas");
tmpCanvas.width = tmpCanvas.height = 66;
let tmpContext = tmpCanvas.getContext("2d");
tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
tmpContext.imageSmoothingEnabled = false;
tmpContext.webkitImageSmoothingEnabled = false;
tmpContext.mozImageSmoothingEnabled = false;
if (items.weapons[i]) {
tmpContext.rotate((Math.PI));
let tmpSprite = new Image();
toolSprites[items.weapons[i].src] = tmpSprite;
tmpSprite.onload = function () {
this.isLoaded = true;
let tmpPad = 1 / (this.height / this.width);
let tmpMlt = (items.weapons[i].iPad || 1);
tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt *
config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
tmpCanvas.width * tmpMlt * tmpPad *
config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
tmpContext.fillStyle = "rgba(0, 0, 70, 0.2)";
tmpContext.globalCompositeOperation = "source-atop";
tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height /
2, tmpCanvas.width, tmpCanvas.height);
getEl('actionBarItem' + i).style.backgroundImage = "url(" +
tmpCanvas.toDataURL() + ")";
};
tmpSprite.src = "./../img/weapons/" + items.weapons[i].src +
".png";
let tmpUnit = getEl('actionBarItem' + i);
// tmpUnit.onmouseover = UTILS.checkTrusted(function () {
// showItemInfo(items.weapons[i], true);
// });
tmpUnit.onclick = UTILS.checkTrusted(function () {
selectWeapon(tmpObj.weapons[items.weapons[i].type]);
});
UTILS.hookTouchEvents(tmpUnit);
} else {
let tmpSprite = getItemSprite(items.list[i - items.weapons.length],
true);
let tmpScale = Math.min(tmpCanvas.width - config.iconPadding,
tmpSprite.width);
tmpContext.globalAlpha = 1;
tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2,
tmpScale, tmpScale);
tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
tmpContext.globalCompositeOperation = "source-atop";
tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale,
tmpScale);
getEl('actionBarItem' + i).style.backgroundImage = "url(" +
tmpCanvas.toDataURL() + ")";
let tmpUnit = getEl('actionBarItem' + i);
// tmpUnit.onmouseover = UTILS.checkTrusted(function () {
// showItemInfo(items.list[i - items.weapons.length]);
// });
tmpUnit.onclick = UTILS.checkTrusted(function () {
selectToBuild(tmpObj.items[tmpObj.getItemType(i -
items.weapons.length)]);
});
UTILS.hookTouchEvents(tmpUnit);
}
})(i);
}
};
window.profineTest = function(data) {
if (data) {
// VALIDATE NAME:
let name = data + "";
name = name.slice(0, config.maxNameLength);
return name;
}
};