message (49)
message (49)
// @name uehee
// @author ueheua
// @description nerd
// @version 0.45
// @match *://*.moomoo.io/*
// @icon https://cdn.discordapp.com/emojis/1092169271355912334.gif?
size=48&quality=lossless&name=catKrug
// @run-at document_idle
// @grant none
// ==/UserScript==
let v = `
#upgradeCounter, #storeButton, #leaderboardButton, #allianceButton, #actionBar,
#ageBarContainer, #leaderboard, #killCounter, #gameUI {
transition: all 1s ease-in-out;
}
#mainMenu {
background-image:
url("https://cdn.discordapp.com/attachments/1261384417688031357/1271513777744904202
/oldWorld.jpg?
ex=66b79cfc&is=66b64b7c&hm=d16864586929ad99273894b9d6d6733eaca61b4e22b9181af9da2c4f
023e1703&");
background-size: cover;
}
#menuContainer {
width: 100%;
white-space: nowrap;
text-align: center;
position: absolute;
top: 45%;
transform: translateY(-50%);
-ms-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-webkit-transform: translateY(-50%);
-o-transform: translateY(-50%);
}
#guideCard {
max-height: 235px;
-webkit-overflow-scrolling: touch;
overflow-y: hidden;
}
.menuCard {
background: rgb(0,0,0,0.2);
border-radius: 5px;
box-shadow: 0px 0px 0px 0px rgb(60, 60, 60);
}
.menuCard, .adMenuCard {
vertical-align: top;
text-align: left;
white-space: normal;
word-wrap: break-word;
margin: 5px;
display: inline-block;
width: 300px;
padding: 18px;
-moz-box-shadow: 0px 7px #c4c4c4;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
overflow: hidden;
transition: .5s;
border: none;
}
.menuCard:hover , .adMenuCard:hover {
transform: scale(1.05);
}
#nameInput, #serverBrowser select, div#enterGame.menuButton {
position: relative;
border: none;
outline: none;
border-radius: 6px;
color: #fff;
background-color: rgb(0,0,0,0.5);
}
.animate {
transition: top 0.2s ease-in-out;
}
`;
const styleElement = document.createElement("style");
styleElement.type = "text/css";
styleElement.appendChild(document.createTextNode(v));
document.head.appendChild(styleElement);
// MainMenu:
getEl("desktopInstructions").innerHTML = "";
getEl("promoImgHolder").innerHTML = "";
getEl("promoImgHolder").appendChild(getEl("skinColorHolder"));
$(".menuHeader").hide();
$(".menuText").css({
color: "#4C4C4C",
"font-size": "16px"
});
document.querySelectorAll("#adCard", "div#menuCard.adCard", "#pre-content-
container", ".downloadBadge", "ins.adsbygoogle").forEach(b => b.remove());
getEl('altServer').innerHTML = '<br>';
const menuLink = document.querySelector('.menuLink');
if (menuLink) {
menuLink.href = 'https://discord.com/channels/@me';
menuLink.textContent = 'Aleksa';
}
// Remove MainMenu:
getEl("wideAdCard").remove();
getEl("linksContainer2").remove();
getEl("joinPartyButton").remove();
getEl("partyButton").remove();
getEl("gameName").remove();
getEl("settingsButton").remove();
// Remove Game Guis:
getEl("ageText").remove();
getEl("upgradeCounter").remove();
getEl("resDisplay").remove();
getEl("ageBarContainer").remove();
getEl("storeButton").remove();
getEl("chatButton").remove();
getEl("killCounter").remove();
setInterval(()=>{
var text = document.getElementById("loadingText").innerText;
if (text == "disconnected\nreload") {
window.onbeforeunload = null;
document.body.remove();
window.location.href = window.location.href;
}
}, 0);
setInterval(function() {
//more fps
window.location.native_resolution = true;
}, 1000)
function getEl(id) {
return document.getElementById(id);
}
function r(t) {
if (o[t]) return o[t].exports;
var n = o[t] = {
i: t,
l: !1,
exports: {}
};
return e[t].call(n.exports, n, n.exports, r), n.l = !0, n.exports
}
return r.m = e, r.c = o, r.d = function(t, n, e) {
r.o(t, n) || Object.defineProperty(t, n, {
enumerable: !0,
get: e
})
}, r.r = function(t) {
"undefined" != typeof Symbol && Symbol.toStringTag &&
Object.defineProperty(t, Symbol.toStringTag, {
value: "Module"
}), Object.defineProperty(t, "__esModule", {
value: !0
})
}, r.t = function(n, t) {
if (1 & t && (n = r(n)), 8 & t) return n;
if (4 & t && "object" == typeof n && n && n.__esModule) return n;
var e = Object.create(null);
if (r.r(e), Object.defineProperty(e, "default", {
enumerable: !0,
value: n
}), 2 & t && "string" != typeof n)
for (var o in n) r.d(e, o, function(t) {
return n[t]
}.bind(null, o));
return e
}, r.n = function(t) {
var n = t && t.__esModule ? function() {
return t.default
} : function() {
return t
};
return r.d(n, "9", n), n
}, r.o = function(t, n) {
return Object.prototype.hasOwnProperty.call(t, n)
}, r.p = "/bin/", r(r.s = 0)
}([function(t, n, e) {
var P = {},
M = e(1),
_ = e(2),
A = e(3);
t.exports = P;
var E = 1;
P.js = function() {
var c, i, f, s = 1.4,
p = !1,
u = {},
o = {},
r = {},
l = {},
a = !0,
h = {},
d = [],
y = Number.MAX_VALUE,
v = !1;
this.setAcceptableTiles = function(t) {
t instanceof Array ? f = t : !isNaN(parseFloat(t)) && isFinite(t) && (f
= [t])
}, this.enableSync = function() {
p = !0
}, this.disableSync = function() {
p = !1
}, this.enableDiagonals = function() {
v = !0
}, this.disableDiagonals = function() {
v = !1
}, this.setGrid = function(t) {
c = t;
for (var n = 0; n < c.length; n++)
for (var e = 0; e < c[0].length; e++) o[c[n][e]] || (o[c[n][e]] =
1)
}, this.setTileCost = function(t, n) {
o[t] = n
}, this.setAdditionalPointCost = function(t, n, e) {
void 0 === r[n] && (r[n] = {}), r[n][t] = e
}, this.removeAdditionalPointCost = function(t, n) {
void 0 !== r[n] && delete r[n][t]
}, this.removeAllAdditionalPointCosts = function() {
r = {}
}, this.setDirectionalCondition = function(t, n, e) {
void 0 === l[n] && (l[n] = {}), l[n][t] = e
}, this.removeAllDirectionalConditions = function() {
l = {}
}, this.setIterationsPerCalculation = function(t) {
y = t
}, this.avoidAdditionalPoint = function(t, n) {
void 0 === u[n] && (u[n] = {}), u[n][t] = 1
}, this.stopAvoidingAdditionalPoint = function(t, n) {
void 0 !== u[n] && delete u[n][t]
}, this.enableCornerCutting = function() {
a = !0
}, this.disableCornerCutting = function() {
a = !1
}, this.stopAvoidingAllAdditionalPoints = function() {
u = {}
}, this.findPath = function(t, n, e, o, r) {
function i(t) {
p ? r(t) : setTimeout(function() {
r(t)
})
}
if (void 0 === f) throw new Error("You can't set a path without first
calling setAcceptableTiles() on EasyStar.");
if (void 0 === c) throw new Error("You can't set a path without first
calling setGrid() on EasyStar.");
if (t < 0 || n < 0 || e < 0 || o < 0 || t > c[0].length - 1 || n >
c.length - 1 || e > c[0].length - 1 || o > c.length - 1) throw new Error("Your
start or end point is outside the scope of your grid.");
if (t !== e || n !== o) {
for (var s = c[o][e], u = !1, l = 0; l < f.length; l++)
if (s === f[l]) {
u = !0;
break
} if (!1 !== u) {
var a = new M;
a.openList = new A(function(t, n) {
return t.bestGuessDistance() - n.bestGuessDistance()
}), a.isDoneCalculating = !1, a.nodeHash = {}, a.startX =
t, a.startY = n, a.endX = e, a.endY = o, a.callback = i, a.openList.push(O(a,
a.startX, a.startY, null, 1));
o = E++;
return h[o] = a, d.push(o), o
}
i(null)
} else i([])
}, this.cancelPath = function(t) {
return t in h && (delete h[t], !0)
}, this.calculate = function() {
if (d.length === 0 || c === undefined || f === undefined) return;
for (let i = 0; i < y; i++) {
if (d.length === 0) return;
if (p) i = 0;
const t = d[0];
const n = h[t];
if (n !== undefined) {
if (n.openList.size() !== 0) {
const e = n.openList.pop();
if (v) {
if (e.x > 0 && e.y > 0 && (a || g(c, f, e.x, e.y -
1, e) && g(c, f, e.x - 1, e.y, e))) {
T(n, e, -1, -1, s * b(e.x - 1, e.y - 1));
}
if (e.x < c[0].length - 1 && e.y < c.length - 1 &&
(a || g(c, f, e.x, e.y + 1, e) && g(c, f, e.x + 1, e.y, e))) {
T(n, e, 1, 1, s * b(e.x + 1, e.y + 1));
}
if (e.x < c[0].length - 1 && e.y > 0 && (a || g(c,
f, e.x, e.y - 1, e) && g(c, f, e.x + 1, e.y, e))) {
T(n, e, 1, -1, s * b(e.x + 1, e.y - 1));
}
if (e.x > 0 && e.y < c.length - 1 && (a || g(c, f,
e.x, e.y + 1, e) && g(c, f, e.x - 1, e.y, e))) {
T(n, e, -1, 1, s * b(e.x - 1, e.y + 1));
}
}
} else {
const o = [];
o.push({ x: e.x, y: e.y });
let r = e.parent;
while (r !== null) {
o.push({ x: r.x, y: r.y });
r = r.parent;
}
o.reverse();
n.callback(o);
delete h[t];
d.shift();
}
} else {
n.callback(null);
delete h[t];
d.shift();
}
} else {
d.shift();
}
}
};
var T = function(t, n, e, o, r) {
e = n.x + e, o = n.y + o;
void 0 !== u[o] && void 0 !== u[o][e] || !g(c, f, e, o, n) || (void 0
=== (o = O(t, e, o, n, r)).list ? (o.list = 1, t.openList.push(o)) : n.costSoFar +
r < o.costSoFar && (o.costSoFar = n.costSoFar + r, o.parent = n,
t.openList.updateItem(o)))
},
g = function(t, n, e, o, r) {
var i = l[o] && l[o][e];
if (i) {
var s = x(r.x - e, r.y - o);
if (! function() {
for (var t = 0; t < i.length; t++)
if (i[t] === s) return !0;
return !1
}()) return !1
}
for (var u = 0; u < n.length; u++)
if (t[o][e] === n[u]) return !0;
return !1
},
x = function(t, n) {
if (0 === t && -1 === n) return P.TOP;
if (1 === t && -1 === n) return P.TOP_RIGHT;
if (1 === t && 0 === n) return P.RIGHT;
if (1 === t && 1 === n) return P.BOTTOM_RIGHT;
if (0 === t && 1 === n) return P.BOTTOM;
if (-1 === t && 1 === n) return P.BOTTOM_LEFT;
if (-1 === t && 0 === n) return P.LEFT;
if (-1 === t && -1 === n) return P.TOP_LEFT;
throw new Error("These differences are not valid: " + t + ", " + n)
},
b = function(t, n) {
return r[n] && r[n][t] || o[c[n][t]]
},
O = function(t, n, e, o, r) {
if (void 0 !== t.nodeHash[e]) {
if (void 0 !== t.nodeHash[e][n]) return t.nodeHash[e][n]
} else t.nodeHash[e] = {};
var i = m(n, e, t.endX, t.endY),
r = null !== o ? o.costSoFar + r : 0,
i = new _(o, n, e, r, i);
return t.nodeHash[e][n] = i
},
m = function(t, n, e, o) {
var r, i;
return v ? (r = Math.abs(t - e)) < (i = Math.abs(n - o)) ? s * r +
i : s * i + r : (r = Math.abs(t - e)) + (i = Math.abs(n - o))
}
}, P.TOP = "TOP", P.TOP_RIGHT = "TOP_RIGHT", P.RIGHT = "RIGHT",
P.BOTTOM_RIGHT = "BOTTOM_RIGHT", P.BOTTOM = "BOTTOM", P.BOTTOM_LEFT =
"BOTTOM_LEFT", P.LEFT = "LEFT", P.TOP_LEFT = "TOP_LEFT"
}, function(t, n) {
t.exports = function() {
this.pointsToAvoid = {}, this.startX, this.callback, this.startY,
this.endX, this.endY, this.nodeHash = {}, this.openList
}
}, function(t, n) {
t.exports = function(t, n, e, o, r) {
this.parent = t, this.x = n, this.y = e, this.costSoFar = o,
this.simpleDistanceToTarget = r, this.bestGuessDistance = function() {
return this.costSoFar + this.simpleDistanceToTarget
}
}
}, function(t, n, e) {
t.exports = e(4)
}, function(u, T, t) {
var g, x;
(function() {
var t, p, l, h, d, n, a, e, y, v, o, r, i, c, f;
function s(t) {
this.cmp = null != t ? t : p, this.nodes = []
}
l = Math.floor, v = Math.min, p = function(t, n) {
return t < n ? -1 : n < t ? 1 : 0
}, y = function(t, n, e, o, r) {
var i;
if (null == e && (e = 0), null == r && (r = p), e < 0) throw new
Error("lo must be non-negative");
for (null == o && (o = t.length); e < o;) r(n, t[i = l((e + o) / 2)]) <
0 ? o = i : e = i + 1;
return [].splice.apply(t, [e, e - e].concat(n)), n
}, n = function(t, n, e) {
return null == e && (e = p), t.push(n), c(t, 0, t.length - 1, e)
}, d = function(t, n) {
var e, o;
return null == n && (n = p), e = t.pop(), t.length ? (o = t[0], t[0] =
e, f(t, 0, n)) : o = e, o
}, e = function(t, n, e) {
var o;
return null == e && (e = p), o = t[0], t[0] = n, f(t, 0, e), o
}, a = function(t, n, e) {
var o;
return null == e && (e = p), t.length && e(t[0], n) < 0 && (n = (o =
[t[0], n])[0], t[0] = o[1], f(t, 0, e)), n
}, h = function(e, t) {
var n, o, r, i, s, u;
for (null == t && (t = p), s = [], o = 0, r = (i = function() {
u = [];
for (var t = 0, n = l(e.length / 2); 0 <= n ? t < n : n < t; 0 <= n
? t++ : t--) u.push(t);
return u
}.apply(this).reverse()).length; o < r; o++) n = i[o], s.push(f(e, n,
t));
return s
}, i = function(t, n, e) {
if (null == e && (e = p), -1 !== (n = t.indexOf(n))) return c(t, 0, n,
e), f(t, n, e)
}, o = function(t, n, e) {
var o, r, i, s, u;
if (null == e && (e = p), !(r = t.slice(0, n)).length) return r;
for (h(r, e), i = 0, s = (u = t.slice(n)).length; i < s; i++) o = u[i],
a(r, o, e);
return r.sort(e).reverse()
}, r = function(t, n, e) {
var o, r, i, s, u, l, a, c, f;
if (null == e && (e = p), 10 * n <= t.length) {
if (!(i = t.slice(0, n).sort(e)).length) return i;
for (r = i[i.length - 1], s = 0, l = (a = t.slice(n)).length; s <
l; s++) e(o = a[s], r) < 0 && (y(i, o, 0, null, e), i.pop(), r = i[i.length - 1]);
return i
}
for (h(t, e), f = [], u = 0, c = v(n, t.length); 0 <= c ? u < c : c <
u; 0 <= c ? ++u : --u) f.push(d(t, e));
return f
}, c = function(t, n, e, o) {
var r, i, s;
for (null == o && (o = p), r = t[e]; n < e && o(r, i = t[s = e - 1 >>
1]) < 0;) t[e] = i, e = s;
return t[e] = r
}, f = function(t, n, e) {
var o, r, i, s, u;
for (null == e && (e = p), r = t.length, i = t[u = n], o = 2 * n + 1; o
< r;)(s = o + 1) < r && !(e(t[o], t[s]) < 0) && (o = s), t[n] = t[o], o = 2 * (n =
o) + 1;
return t[n] = i, c(t, u, n, e)
}, s.push = n, s.pop = d, s.replace = e, s.pushpop = a, s.heapify = h,
s.updateItem = i, s.nlargest = o, s.nsmallest = r, s.prototype.push = function(t) {
return n(this.nodes, t, this.cmp)
}, s.prototype.pop = function() {
return d(this.nodes, this.cmp)
}, s.prototype.peek = function() {
return this.nodes[0]
}, s.prototype.contains = function(t) {
return -1 !== this.nodes.indexOf(t)
}, s.prototype.replace = function(t) {
return e(this.nodes, t, this.cmp)
}, s.prototype.pushpop = function(t) {
return a(this.nodes, t, this.cmp)
}, s.prototype.heapify = function() {
return h(this.nodes, this.cmp)
}, s.prototype.updateItem = function(t) {
return i(this.nodes, t, this.cmp)
}, s.prototype.clear = function() {
return this.nodes = []
}, s.prototype.empty = function() {
return 0 === this.nodes.length
}, s.prototype.size = function() {
return this.nodes.length
}, s.prototype.clone = function() {
var t = new s;
return t.nodes = this.nodes.slice(0), t
}, s.prototype.toArray = function() {
return this.nodes.slice(0)
}, s.prototype.insert = s.prototype.push, s.prototype.top =
s.prototype.peek, s.prototype.front = s.prototype.peek, s.prototype.has =
s.prototype.contains, s.prototype.copy = s.prototype.clone, t = s, g = [], void 0
=== (x = "function" == typeof(x = function() {
return t
}) ? x.apply(T, g) : x) || (u.exports = x)
}).call(this)
}]);
let easystar = new EasyStar.js();
!function(run) {
// CLIENT:
config.clientSendRate = 9; // Aim Packet Send Rate
config.serverUpdateRate = 9;
// UI:
config.deathFadeout = 0;
config.playerCapacity = 9999;
// CHECK IN SANDBOX:
config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
// CUSTOMIZATION:
config.skinColors = ["#bf8f54", "#cbb091", "#896c4b", "#fadadc", "#ececec",
"#c37373", "#4c4c4c", "#ecaff7", "#738cc3", "#8bc373", "#91b2db"];
config.weaponVariants = [{
id: 0,
src: "",
xp: 0,
val: 1,
}, {
id: 1,
src: "_g",
xp: 3000,
val: 1.1,
}, {
id: 2,
src: "_d",
xp: 7000,
val: 1.18,
}, {
id: 3,
src: "_r",
poison: true,
xp: 12000,
val: 1.18,
}, {
id: 4,
src: "_e",
poison: true,
heal: true,
xp: 24000,
val: 1.18,
}];
// VISUAL:
config.anotherVisual = true;
config.useWebGl = false;
config.resetRender = true;
config.VolcanoInfo = {
volcanoScale: initialScale,
innerVolcanoScale: baseLayer,
volcanoAnimalStrength: zoomLevel,
volcanoAnimationDuration: hoverLayer,
volcanoAggressionRadius: focalLength,
volcanoAggressionPercentage: velocityLimit,
volcanoDamagePerSecond: unitlessValue,
volcanoLocationX: locationX,
volcanoLocationY: locationY,
}
let Volcano = {
x: config.VolcanoInfo.volcanoLocationX,
y: config.VolcanoInfo.volcanoLocationY,
scale: config.VolcanoInfo.volcanoScale,
Radius: config.VolcanoInfo.volcanoAggressionRadius,
innerScale: config.VolcanoInfo.innerVolcanoScale
}
let VolcanoXY = {
x: config.VolcanoInfo.volcanoLocationX,
y: config.VolcanoInfo.volcanoLocationY,
}
const Me = {
animationTime: 0,
land: null,
lava: null,
x: Volcano.x,
y: Volcano.y
};
function waitTime(timeout) {
return new Promise((done) => {
setTimeout(() => {
done();
}, timeout);
});
}
// STORAGE:
let canStore;
if (typeof(Storage) !== "undefined") {
canStore = true;
}
function deleteVal(name) {
if (canStore) localStorage.removeItem(name);
}
function getSavedVal(name) {
if (canStore) return localStorage.getItem(name);
return null;
}
// CONFIGS:
let gC = function(a, b) {
try {
let res = JSON.parse(getSavedVal(a));
if (typeof res === "object") {
return b;
} else {
return res;
}
} catch (e) {
alert("dieskid");
return b;
}
};
function setCommands() {
return {
"help": {
desc: "Show Commands",
action: function(message) {
for (let cmds in commands) {
addMenuChText("/" + cmds, commands[cmds].desc, "lime", 1);
}
}
},
"clear": {
desc: "Clear Chats",
action: function(message) {
resetMenuChText();
}
},
"debug": {
desc: "Debug Mod For Development",
action: function(message) {
addDeadPlayer(player);
addMenuChText("Debug", "Done", "#99ee99", 1);
}
},
"play": {
desc: "Play Music ( /play [link] )",
action: function(message) {
let link = message.split(" ");
if (link[1]) {
let audio = new Audio(link[1]);
audio.play();
} else {
addMenuChText("Warn", "Enter Link ( /play [link] )",
"#99ee99", 1);
}
}
},
"bye": {
desc: "Leave Game",
action: function(message) {
window.leave();
}
},
};
}
function setConfigs() {
return {
killChat: false,
autoBuy: true,
autoBuyEquip: true,
autoPush: true,
revTick: true,
spikeTick: true,
predictTick: true,
autoPlace: true,
autoReplace: true,
prePlace: true,
antiTrap: true,
slowOT: false,
attackDir: false,
showDir: false,
noDir: false,
autoRespawn: false,
hideDmgText: true,
avoidSpike: true,
fakePing: true,
};
};
let commands = setCommands();
let configs = setConfigs();
window.removeConfigs = function() {
for (let cF in configs) {
deleteVal(cF, configs[cF]);
}
};
// MENU FUNCTIONS:
window.changeMenu = function() {};
window.debug = function() {};
window.wasdMode = function() {};
// PAGE 1:
window.startGrind = function() {};
// PAGE 3:
window.connectFillBots = function() {};
window.destroyFillBots = function() {};
window.tryConnectBots = function() {};
window.destroyBots = function() {};
window.resBuild = function() {};
window.toggleBotsCircle = function() {};
window.toggleVisual = function() {};
// SOME FUNCTIONS:
window.prepareUI = function() {};
window.leave = function() {};
class HtmlAction {
constructor(element) {
this.element = element;
};
add(code) {
if (!this.element) return undefined;
this.element.innerHTML += code;
};
newLine(amount) {
let result = `<br>`;
if (amount > 0) {
result = ``;
for (let i = 0; i < amount; i++) {
result += `<br>`;
}
}
this.add(result);
};
checkBox(setting) {
let newCheck = `<input type = "checkbox"`;
setting.id && (newCheck += ` id = ${setting.id}`);
setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ",
"")}`);
setting.class && (newCheck += ` class = ${setting.class}`);
setting.checked && (newCheck += ` checked`);
setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
newCheck += `>`;
this.add(newCheck);
};
text(setting) {
let newText = `<input type = "text"`;
setting.id && (newText += ` id = ${setting.id}`);
setting.style && (newText += ` style = ${setting.style.replaceAll(" ",
"")}`);
setting.class && (newText += ` class = ${setting.class}`);
setting.size && (newText += ` size = ${setting.size}`);
setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
setting.value && (newText += ` value = ${setting.value}`);
setting.placeHolder && (newText += ` placeHolder = $
{setting.placeHolder.replaceAll(" ", " ")}`);
newText += `>`;
this.add(newText);
};
select(setting) {
let newSelect = `<select`;
setting.id && (newSelect += ` id = ${setting.id}`);
setting.style && (newSelect += ` style = ${setting.style.replaceAll("
", "")}`);
setting.class && (newSelect += ` class = ${setting.class}`);
newSelect += `>`;
for (let options in setting.option) {
newSelect += `<option value = ${setting.option[options].id}`
setting.option[options].selected && (newSelect += ` selected`);
newSelect += `>${options}</option>`;
}
newSelect += `</select>`;
this.add(newSelect);
};
button(setting) {
let newButton = `<button`;
setting.id && (newButton += ` id = ${setting.id}`);
setting.style && (newButton += ` style = ${setting.style.replaceAll("
", "")}`);
setting.class && (newButton += ` class = ${setting.class}`);
setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
newButton += `>`;
setting.innerHTML && (newButton += setting.innerHTML);
newButton += `</button>`;
this.add(newButton);
};
selectMenu(setting) {
let newSelect = `<select`;
if (!setting.id) {
alert("please put id skid");
return;
}
window[setting.id + "Func"] = function() {};
setting.id && (newSelect += ` id = ${setting.id}`);
setting.style && (newSelect += ` style = ${setting.style.replaceAll("
", "")}`);
setting.class && (newSelect += ` class = ${setting.class}`);
newSelect += ` onchange = window.${setting.id + "Func"}()`;
newSelect += `>`;
let last;
let i = 0;
for (let options in setting.menu) {
newSelect += `<option value = ${"option_" + options} id = ${"O_" +
options}`;
setting.menu[options] && (newSelect += ` checked`);
newSelect += ` style = "color: ${setting.menu[options] ? "#000" :
"#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">$
{options}</option>`;
i++;
}
newSelect += `</select>`;
this.add(newSelect);
i = 0;
for (let options in setting.menu) {
window[options + "Func"] = function() {
setting.menu[options] = getEl("check_" + options).checked ?
true : false;
saveVal(options, setting.menu[options]);
//getEl(setting.id).style.color = setting.menu[options] ?
"#8ecc51" : "#cc5151";
};
this.checkBox({id: "check_" + options, style: `display: ${i == 0 ?
"inline-block" : "none"};`, class: "checkB", onclick: `window.${options + "Func"}
()`, checked: setting.menu[options]});
i++;
}
//getEl(setting.id).style.color = setting.menu[last.split("_")
[1]] ? "#8ecc51" : "#fff";
};
};
};
class Html {
constructor() {
this.element = null;
this.action = null;
this.divElement = null;
this.startDiv = function (setting, func) {
};
this.addDiv = function (setting, func) {
};
};
set(id) {
this.element = getEl(id);
this.action = new HtmlAction(this.element);
};
resetHTML(text) {
if (text) {
this.element.innerHTML = ``;
} else {
this.element.innerHTML = ``;
}
};
setStyle(style) {
this.element.style = style;
};
setCSS(style) {
this.action.add(`<style>` + style + `</style>`);
};
};
.leaderboardItem {
float: left;
display: inline-block;
font-size: 16px;
text-align: center;
max-width: max-content;
position: relative;
left: 50%;
transform: translateX(-50%);
text-shadow: -1.1px -1.1px 0 #000, 1.1px -1.1px 0 #000, -1.1px 1.1px 0 #000,
1.1px 1.1px 0 #000;
font-family: Ubuntu, sans-serif;
margin-top: 1.2px;
}
.menuClass{
color: #fff;
font-size: 31px;
text-align: left;
padding: 10px;
padding-top: 7px;
padding-bottom: 5px;
width: 300px;
background: linear-gradient(145deg, #413449, #000000);
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
.menuC {
display: none;
font-family: "Hammersmith One";
font-size: 12px;
max-height: 180px;
overflow-y: scroll;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.menuB {
text-align: center;
background-color: rgb(25, 25, 25);
color: #fff;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
border: 2px solid #000;
outline: none;
}
.menuB:hover {
border: 2px solid #fff;
}
.menuB:active {
color: rgb(25, 25, 25);
background-color: rgb(200, 200, 200);
}
.customText {
color: #000;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
border: 2px solid #000;
outline: none;
}
.customText:focus {
background-color: yellow;
}
.checkB {
position: relative;
top: 2px;
accent-color: #888;
cursor: pointer;
outline: none;
}
.Cselect {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
background-color: rgb(75, 75, 75);
color: #fff;
border: 1px solid #000;
outline: none;
}
#menuChangerLeft, #menuChangerRight {
position: absolute;
right: 10px;
top: 10px;
background-color: rgba(0, 0, 0, 0);
color: #fff;
border: none;
cursor: pointer;
outline: none;
}
#menuChangerLeft:hover, #menuChangerRight:hover {
color: #000;
}
#menuChangerLeft {
right: 52px;
}
::-webkit-scrollbar {
width: 10px;
}
::-webkit-scrollbar-track {
opacity: 0;
}
::-webkit-scrollbar-thumb {
background-color: rgb(25, 25, 25);
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:active {
background-color: rgb(230, 230, 230);
}
`);
HTML.startDiv({id: "menuHeadLine", class: "menuClass"}, (html) => {
html.add(`Mod:`);
//html.button({id: "menuChanger", class: "material-icons", innerHTML:
`sync`, onclick: "window.changeMenu()"});
html.button({id: "menuChangerLeft", class: "material-icons", innerHTML:
`chevron_left`, onclick: "window.changeMenuLeft()"});
html.button({id: "menuChangerRight", class: "material-icons", innerHTML:
`chevron_right`, onclick: "window.changeMenuRight()"});
html.add(`Replace 2:`);
html.checkBox({id: "testReplace2", class: "checkB", checked: true});
html.newLine();
});
HTML.addDiv({id: "menuConfig", class: "menuC", appendID: "menuHeadLine"},
(html) => {
html.add(`AutoPlacer Placement Tick: `);
html.text({id: "autoPlaceTick", class: "customText", value: "2", size:
"2em", maxLength: "1"});
html.newLine();
html.add(`Configs: `);
html.selectMenu({id: "configsChanger", class: "Cselect", menu:
configs});
html.newLine();
html.add(`InstaKill Type: `);
html.select({id: "instaType", class: "Cselect", option: {
OneShot: {
id: "oneShot",
selected: true
},
Spammer: {
id: "spammer"
}
}});
html.newLine();
html.add(`AntiBull Type: `);
html.select({id: "antiBullType", class: "Cselect", option: {
"Disable AntiBull": {
id: "noab",
selected: true
},
"When Reloaded": {
id: "abreload",
},
"Primary Reloaded": {
id: "abalway"
}
}});
html.newLine();
html.add(`Backup Nobull Insta: `);
html.checkBox({id: "backupNobull", class: "checkB", checked: true});
html.newLine();
html.add(`Turret Gear Combat Assistance: `);
html.checkBox({id: "turretCombat", class: "checkB"});
html.newLine();
html.add(`Safe AntiSpikeTick: `);
html.checkBox({id: "safeAntiSpikeTick", class: "checkB", checked:
true});
html.newLine();
});
HTML.addDiv({id: "menuOther", class: "menuC", appendID: "menuHeadLine"},
(html) => {
html.button({class: "menuB", innerHTML: "Connect Bots", onclick:
"window.tryConnectBots()"});
html.button({class: "menuB", innerHTML: "Disconnect Bots", onclick:
"window.destroyBots()"});
html.newLine();
html.button({class: "menuB", innerHTML: "Connect FBots", onclick:
"window.connectFillBots()"});
html.button({class: "menuB", innerHTML: "Disconnect FBots", onclick:
"window.destroyFillBots()"});
html.newLine();
html.button({class: "menuB", innerHTML: "Reset Break Objects", onclick:
"window.resBuild()"});
html.newLine();
html.add(`Break Objects Range: `);
html.text({id: "breakRange", class: "customText", value: "700", size:
"3em", maxLength: "4"});
html.newLine();
html.add(`Predict Movement Type: `);
html.select({id: "predictType", class: "Cselect", option: {
"Disable Render": {
id: "disableRender",
selected: true
},
"X/Y and 2": {
id: "pre2",
},
"X/Y and 3": {
id: "pre3"
}
}});
html.newLine();
html.add(`Render Placers: `);
html.checkBox({id: "placeVis", class: "checkB", checked: true});
html.newLine();
html.add(`Visuals: `);
html.select({id: "visualType", class: "Cselect", option: {
"Old Shit": {
id: "ueh1",
},
"New shit": {
id: "ueh2",
selected: true
},
}});
html.newLine(2);
html.button({class: "menuB", innerHTML: "Toggle Fbots Circle", onclick:
"window.toggleBotsCircle()"});
html.newLine();
html.add(`Circle Rad: `);
html.text({id: "circleRad", class: "customText", value: "200", size:
"3em", maxLength: "4"});
html.newLine();
html.add(`Rad Speed: `);
html.text({id: "radSpeed", class: "customText", value: "0.1", size:
"2em", maxLength: "3"});
html.newLine(2);
html.add(`Cross World: `);
html.checkBox({id: "funni", class: "checkB"});
html.newLine();
html.button({class: "menuB", innerHTML: "Toggle Another Visual",
onclick: "window.toggleVisual()"});
html.newLine();
});
});
function updateInnerHTML() {
infosMenus.innerHTML = `
Ping: <span id="pingFps">0</span>
`;
};
updateInnerHTML();
// GmaeLog / ChatLog:
let style = document.createElement("style");
style.innerHTML = `
#mapDisplay{
left: 15px;
top: 45px;
}
.chMainDiv {
transition: opacity 0.65s ease; /* add this line */
}
.chMainDiv.faded {
opacity: 0;
}
.chDiv{
color: #fff;
padding: 6px;
padding-bottom: 10px;
width: 340px;
height: 280px;
background-color: rgba(0, 0, 0, 0);
transition: background-color 0.65s ease;
border-radius: 4px;
transition: 0.5s;
position: relative;
}
.chMainDiv::-webkit-scrollbar {
display: none;
}
.chMainDiv{
font: 16px Ubuntu;
max-height: 236px;
padding-left: 2px;
overflow-y: scroll;
scroll-behavior: smooth;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
transition: 0.5s;
position: absolute;
bottom: 50px;
left: 5px;
width: 95%;
}
.chMainBox{
position: absolute;
padding: 2px;
padding-left: 5px;
bottom: 10px;
width: 330px;
height: 30px;
background-color: rgb(128, 128, 128, 0.35);
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
color: #fff;
font-family: "Ubuntu";
font-size: 15px;
text-shadow: rgb(0, 0, 0) -1.1px -1.1px 0px, rgb(0, 0, 0) 1.1px -1.1px 0px,
rgb(0, 0, 0) -1.1px 1.1px 0px, rgb(0, 0, 0) 1.1px 1.1px 0px;
border: none;
outline: none;
}
`;
document.head.appendChild(style);
if (!menuCBFocus) {
menuChDisp.classList.add("faded");
setTimeout(() => {
menuChDisp.classList.remove("faded");
}, 5000);
}
}
menuChatBox.value = "";
menuChatBox.addEventListener("focus", () => {
menuCBFocus = true;
mChMain.classList.remove("faded");
});
menuChatBox.addEventListener("blur", () => {
menuCBFocus = false;
mChMain.classList.add("faded");
setTimeout(() => {
mChMain.classList.remove("faded");
}, 5000);
});
function resetMenuChText() {
mChMain.innerHTML = "";
menuChCounts = 0;
lastmes = {};
addMenuChText(null, "Chat '/help' for a list of chat commands.", "white",
1)
}
resetMenuChText();
let menuIndex = 0;
let menus = ["menuMain", "menuConfig", "menuOther"];
window.changeMenu = function() {
getEl(menus[menuIndex % menus.length]).style.display = "none";
menuIndex++;
getEl(menus[menuIndex % menus.length]).style.display = "block";
};
window.changeMenuLeft = function() {
document.getElementById(menus[menuIndex % menus.length]).style.display =
"none";
menuIndex = (menuIndex - 1 + menus.length) % menus.length;
document.getElementById(menus[menuIndex % menus.length]).style.display =
"block";
};
window.changeMenuRight = function() {
document.getElementById(menus[menuIndex % menus.length]).style.display =
"none";
menuIndex = (menuIndex + 1) % menus.length;
document.getElementById(menus[menuIndex % menus.length]).style.display =
"block";
};
let WS = undefined;
let socketID = undefined;
WebSocket.prototype.nsend = WebSocket.prototype.send;
WebSocket.prototype.send = function(message) {
if (!WS) {
WS = this;
WS.addEventListener("message", function(msg) {
getMessage(msg);
});
WS.addEventListener("close", (event) => {
if (event.code == 4001) {
window.location.reload();
}
});
}
if (WS == this) {
dontSend = false;
// SEND MESSAGE:
if (type == "6") {
if (data[0]) {
// ANTI PROFANITY:
let profanity = ["cunt", "whore", "fuck", "shit", "faggot",
"nigger", "nigga", "dick", "vagina", "minge", "cock", "rape", "cum", "sex", "tits",
"penis", "clit", "pussy", "meatcurtain", "jizz", "prune", "douche", "wanker",
"damn", "bitch", "dick", "fag", "bastard", ];
let tmpString;
profanity.forEach((profany) => {
if (data[0].indexOf(profany) > -1) {
tmpString = "";
for (let i = 0; i < profany.length; ++i) {
if (i == 1) {
tmpString += String.fromCharCode(0);
}
tmpString += profany[i];
}
let re = new RegExp(profany, "g");
data[0] = data[0].replace(re, tmpString);
}
});
// FIX CHAT:
data[0] = data[0].slice(0, 30);
}
// START COUNT:
if (!firstSend.sec) {
firstSend.sec = true;
setTimeout(() => {
firstSend.sec = false;
secPacket = 0;
}, secTime);
}
secPacket++;
}
} else {
this.nsend(message);
}
}
function packet(type) {
// EXTRACT DATA ARRAY:
let data = Array.prototype.slice.call(arguments, 1);
// SEND MESSAGE:
let binary = window.msgpack.encode([type, data]);
WS.send(binary);
}
function origPacket(type) {
// EXTRACT DATA ARRAY:
let data = Array.prototype.slice.call(arguments, 1);
// SEND MESSAGE:
let binary = window.msgpack.encode([type, data]);
WS.nsend(binary);
}
window.leave = function() {
origPacket("kys", {
"frvr is so bad": true,
"sidney is too good": true,
"dev are too weak": true,
});
};
//...lol
let io = {
send: packet
};
function getMessage(message) {
let data = new Uint8Array(message.data);
let parsed = window.msgpack.decode(data);
let type = parsed[0];
data = parsed[1];
let events = {
A: setInitData, // id: setInitData,
//B: disconnect,
C: setupGame, // 1: setupGame,
D: addPlayer, // 2: addPlayer,
E: removePlayer, // 4: removePlayer,
a: updatePlayers, // 33: updatePlayers,
G: updateLeaderboard, // 5: updateLeaderboard,here
H: loadGameObject, // 6: loadGameObject,
I: loadAI, // a: loadAI,
J: animateAI, // aa: animateAI,
K: gatherAnimation, // 7: gatherAnimation,
L: wiggleGameObject, // 8: wiggleGameObject,
M: shootTurret, // sp: shootTurret,
N: updatePlayerValue, // 9: updatePlayerValue,
O: updateHealth, // h: updateHealth,//here
P: killPlayer, // 11: killPlayer,
Q: killObject, // 12: killObject,
R: killObjects, // 13: killObjects,
S: updateItemCounts, // 14: updateItemCounts,
T: updateAge, // 15: updateAge,
U: updateUpgrades, // 16: updateUpgrades,
V: updateItems, // 17: updateItems,
X: addProjectile, // 18: addProjectile,
Y: remProjectile, // 19: remProjectile,
//Z: serverShutdownNotice,
//0: addAlliance,
//1: deleteAlliance,
2: allianceNotification, // an: allianceNotification,
3: setPlayerTeam, // st: setPlayerTeam,
4: setAlliancePlayers, // sa: setAlliancePlayers,
5: updateStoreItems, // us: updateStoreItems,
6: receiveChat, // ch: receiveChat,
7: updateMinimap, // mm: updateMinimap,
8: showText, // t: showText,
9: pingMap, // p: pingMap,
0: pingSocketResponse,
};
if (type == "io-init") {
socketID = data[0];
} else {
if (events[type]) {
events[type].apply(undefined, data);
}
}
}
// MATHS:
Math.lerpAngle = function(value1, value2, amount) {
let difference = Math.abs(value2 - value1);
if (difference > Math.PI) {
if (value1 > value2) {
value2 += Math.PI * 2;
} else {
value1 += Math.PI * 2;
}
}
let value = value2 + ((value1 - value2) * amount);
if (value >= 0 && value <= Math.PI * 2) return value;
return value % (Math.PI * 2);
};
// REOUNDED RECTANGLE:
CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
if (w < 2 * r) r = w / 2;
if (h < 2 * r) r = h / 2;
if (r < 0) r = 0;
this.beginPath();
this.moveTo(x + r, y);
this.arcTo(x + w, y, x + w, y + h, r);
this.arcTo(x + w, y + h, x, y + h, r);
this.arcTo(x, y + h, x, y, r);
this.arcTo(x, y, x + w, y, r);
this.closePath();
return this;
};
// GLOBAL VALUES:
function resetMoveDir() {
keys = {};
io.send("e");
}
let ticks = {
tick: 0,
delay: 0,
time: [],
manage: [],
};
let ais = [];
let players = [];
let alliances = [];
let alliancePlayers = [];
let allianceNotifications = [];
let gameObjects = [];
let liztobj = [];
let projectiles = [];
let deadPlayers = [];
let player;
let playerSID;
let _;
let my = {
reloaded: false,
waitHit: 0,
autoAim: false,
revAim: false,
ageInsta: true,
reSync: false,
bullTick: 0,
anti0Tick: 0,
antiSync: false,
safePrimary: function(_) {
return [0, 8].includes(_.primaryIndex);
},
safeSecondary: function(_) {
return [10, 11, 14].includes(_.secondaryIndex);
},
lastDir: 0,
autoPush: false,
pushData: {}
}
function findPlayerByID(id) {
return findID(players, id);
}
function findPlayerBySID(sid) {
return findSID(players, sid);
}
function findAIBySID(sid) {
return findSID(ais, sid);
}
function findObjectBySid(sid) {
return findSID(gameObjects, sid);
}
function findProjectileBySid(sid) {
return findSID(gameObjects, sid);
}
class Utils {
constructor() {
// MATH UTILS:
let mathABS = Math.abs,
mathCOS = Math.cos,
mathSIN = Math.sin,
mathPOW = Math.pow,
mathSQRT = Math.sqrt,
mathATAN2 = Math.atan2,
mathHYPOT = Math.hypot,
mathPI = Math.PI;
function touchStart(e) {
_this.mousifyTouchEvent(e);
window.setUsingTouch(true);
if (preventDefault) {
e.preventDefault();
e.stopPropagation();
}
if (element.onmouseover) element.onmouseover(e);
isHovering = true;
}
function touchMove(e) {
_this.mousifyTouchEvent(e);
window.setUsingTouch(true);
if (preventDefault) {
e.preventDefault();
e.stopPropagation();
}
if (_this.containsPoint(element, e.pageX, e.pageY)) {
if (!isHovering) {
if (element.onmouseover) element.onmouseover(e);
isHovering = true;
}
} else {
if (isHovering) {
if (element.onmouseout) element.onmouseout(e);
isHovering = false;
}
}
}
function touchEnd(e) {
_this.mousifyTouchEvent(e);
window.setUsingTouch(true);
if (preventDefault) {
e.preventDefault();
e.stopPropagation();
}
if (isHovering) {
if (element.onclick) element.onclick(e);
if (element.onmouseout) element.onmouseout(e);
isHovering = false;
}
}
};
this.removeAllChildren = function(element) {
while (element.hasChildNodes()) {
element.removeChild(element.lastChild);
}
};
this.generateElement = function(config) {
let element = document.createElement(config.tag || "div");
function bind(configValue, elementValue) {
if (config[configValue]) element[elementValue] =
config[configValue];
}
bind("text", "textContent");
bind("html", "innerHTML");
bind("class", "className");
for (let key in config) {
switch (key) {
case "tag":
case "text":
case "html":
case "class":
case "style":
case "hookTouch":
case "parent":
case "children":
continue;
default:
break;
}
element[key] = config[key];
}
if (element.onclick) element.onclick =
this.checkTrusted(element.onclick);
if (element.onmouseover) element.onmouseover =
this.checkTrusted(element.onmouseover);
if (element.onmouseout) element.onmouseout =
this.checkTrusted(element.onmouseout);
if (config.style) {
element.style.cssText = config.style;
}
if (config.hookTouch) {
this.hookTouchEvents(element);
}
if (config.parent) {
config.parent.appendChild(element);
}
if (config.children) {
for (let i = 0; i < config.children.length; i++) {
element.appendChild(config.children[i]);
}
}
return element;
};
this.checkTrusted = function(callback) {
return function(ev) {
if (ev && ev instanceof Event && (ev && typeof ev.isTrusted ==
"boolean" ? ev.isTrusted : true)) {
callback(ev);
} else {
//console.error("Event is not trusted.", ev);
}
};
};
this.randomString = function(length) {
let text = "";
let possible =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (let i = 0; i < length; i++) {
text += possible.charAt(Math.floor(Math.random() *
possible.length));
}
return text;
};
this.countInArray = function(array, val) {
let count = 0;
for (let i = 0; i < array.length; i++) {
if (array[i] === val) count++;
}
return count;
};
this.hexToRgb = function(hex) {
return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
};
this.getRgb = function(r, g, b) {
return [r / 255, g / 255, b / 255].join(", ");
};
this.inBetween = function(angle, arra) { // okay the thing i have left
to fix is if the first angle is not in the right quadrant i need to make sure that
the second one is less far(another checking of which quadrant it is depending on
the angle)
//mental health is not looking good rn
let array1q
let array = new Array(2);
let array2q
return true
} else {//is not in between
return false
}
}
}
}
};
class Animtext {
// ANIMATED TEXT:
constructor() {
// INIT:
this.init = function(x, y, scale, speed, life, text, color) {
(this.x = x),
(this.y = y),
(this.color = color),
(this.scale = scale*3.5),
(this.weight = 50);
(this.startScale = this.scale * 1.2),
(this.maxScale = 1.5 * scale),
(this.minScale = 0.5 * scale),
(this.scaleSpeed = 0.7),
(this.speed = speed),
(this.speedMax = speed),
(this.life = life),
(this.maxLife = life),
(this.text = text),
this.movSpeed = speed;
};
// UPDATE:
this.update = function(delta) {
if(this.life){
this.life -= delta;
if(this.scaleSpeed != -0.35){
this.y -= this.speed * delta;
// (this.x += this.speed * delta);
} else {
this.y -= this.speed * delta;
}
this.scale -= .8;
// this.scale > 0.35 && (this.scale = Math.max(this.scale,
this.startScale));
// this.speed < this.speedMax && (this.speed -= this.speedMax *
.0075);
if(this.scale >= this.maxScale){
this.scale = this.maxScale;
this.scaleSpeed *= -.5;
this.speed = this.speed * .75;
};
this.life <= 0 && (this.life = 0)
};
};
// RENDER:
this.render = function(ctxt, xOff, yOff) {
ctxt.lineWidth = 10;
ctxt.strokeStyle = darkOutlineColor; //"black";
ctxt.fillStyle = this.color;
ctxt.globalAlpha = 1;
ctxt.font = this.scale + "px HammerSmith One";
ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
ctxt.globalAlpha = 1;
};
}
};
class Textmanager {
// TEXT MANAGER:
constructor() {
this.texts = [];
this.stack = [];
// UPDATE:
this.update = function(delta, ctxt, xOff, yOff) {
ctxt.textBaseline = "middle";
ctxt.textAlign = "center";
for (let i = 0; i < this.texts.length; ++i) {
if (this.texts[i].life) {
this.texts[i].update(delta);
this.texts[i].render(ctxt, xOff, yOff);
}
}
};
// SHOW TEXT:
this.showText = function(x, y, scale, speed, life, text, color) {
let tmpText;
for (let i = 0; i < this.texts.length; ++i) {
if (!this.texts[i].life) {
tmpText = this.texts[i];
break;
}
}
if (!tmpText) {
tmpText = new Animtext();
this.texts.push(tmpText);
}
tmpText.init(x, y, scale, speed, life, text, color);
};
}
}
class GameObject {
constructor(sid) {
this.sid = sid;
// INIT:
this.init = function(x, y, dir, scale, type, data, owner) {
data = data || {};
this.sentTo = {};
this.gridLocations = [];
this.active = true;
this.render = true;
this.doUpdate = data.doUpdate;
this.x = x;
this.y = y;
this.dir = dir;
this.lastDir = dir;
this.xWiggle = 0;
this.yWiggle = 0;
this.visScale = scale;
this.scale = scale;
this.type = type;
this.id = data.id;
this.owner = owner;
this.name = data.name;
this.isItem = (this.id != undefined);
this.group = data.group;
this.maxHealth = data.health;
this.health = this.maxHealth;
this.layer = 2;
if (this.group != undefined) {
this.layer = this.group.layer;
} else if (this.type == 0) {
this.layer = 3;
} else if (this.type == 2) {
this.layer = 0;
} else if (this.type == 4) {
this.layer = -1;
}
this.colDiv = data.colDiv || 1;
this.blocker = data.blocker;
this.ignoreCollision = data.ignoreCollision;
this.dontGather = data.dontGather;
this.hideFromEnemy = data.hideFromEnemy;
this.friction = data.friction;
this.projDmg = data.projDmg;
this.dmg = data.dmg;
this.pDmg = data.pDmg;
this.pps = data.pps;
this.zIndex = data.zIndex || 0;
this.turnSpeed = data.turnSpeed;
this.req = data.req;
this.trap = data.trap;
this.healCol = data.healCol;
this.teleport = data.teleport;
this.boostSpeed = data.boostSpeed;
this.projectile = data.projectile;
this.shootRange = data.shootRange;
this.shootRate = data.shootRate;
this.shootCount = this.shootRate;
this.spawnPoint = data.spawnPoint;
this.onNear = 0;
this.breakObj = false;
this.alpha = data.alpha || 1;
this.maxAlpha = data.alpha || 1;
this.damaged = 0;
};
// GET HIT:
this.changeHealth = function(amount, doer) {
this.health += amount;
return (this.health <= 0);
};
// GET SCALE:
this.getScale = function(sM, ig) {
sM = sM || 1;
return this.scale * ((this.isItem || this.type == 2 || this.type ==
3 || this.type == 4) ?
1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
};
// VISIBLE TO PLAYER:
this.visibleToPlayer = function(player) {
return !(this.hideFromEnemy) || (this.owner && (this.owner ==
player ||
(this.owner.team &&
player.team == this.owner.team)));
};
// UPDATE:
this.update = function(delta) {
if (this.active) {
if (this.xWiggle) {
this.xWiggle *= Math.pow(0.99, delta);
}
if (this.yWiggle) {
this.yWiggle *= Math.pow(0.99, delta);
}
let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
if (d2 > 0.01) {
this.dir += d2 / 5;
} else {
this.dir = this.lastDir;
}
} else {
if (this.alive) {
this.alpha -= delta / (200 / this.maxAlpha);
this.visScale += delta / (this.scale / 2.5);
if (this.alpha <= 0) {
this.alpha = 0;
this.alive = false;
}
}
}
};
// CHECK TEAM:
this.isTeamObject = function(_) {
return this.owner == null ? true : (this.owner && _.sid ==
this.owner.sid || _.findAllianceBySid(this.owner.sid));
};
}
}
class Items {
constructor() {
// ITEM GROUPS:
this.groups = [{
id: 0,
name: "food",
layer: 0
}, {
id: 1,
name: "walls",
place: true,
limit: 30,
layer: 0
}, {
id: 2,
name: "spikes",
place: true,
limit: 15,
layer: 0
}, {
id: 3,
name: "mill",
place: true,
limit: 7,
layer: 1
}, {
id: 4,
name: "mine",
place: true,
limit: 1,
layer: 0
}, {
id: 5,
name: "trap",
place: true,
limit: 6,
layer: -1
}, {
id: 6,
name: "booster",
place: true,
limit: 12,
layer: -1
}, {
id: 7,
name: "turret",
place: true,
limit: 2,
layer: 1
}, {
id: 8,
name: "watchtower",
place: true,
limit: 12,
layer: 1
}, {
id: 9,
name: "buff",
place: true,
limit: 4,
layer: -1
}, {
id: 10,
name: "spawn",
place: true,
limit: 1,
layer: -1
}, {
id: 11,
name: "sapling",
place: true,
limit: 2,
layer: 0
}, {
id: 12,
name: "blocker",
place: true,
limit: 3,
layer: -1
}, {
id: 13,
name: "teleporter",
place: true,
limit: 2,
layer: -1
}];
// PROJECTILES:
this.projectiles = [{
indx: 0,
layer: 0,
src: "arrow_1",
dmg: 25,
speed: 1.6,
scale: 103,
range: 1000
}, {
indx: 1,
layer: 1,
dmg: 25,
scale: 20
}, {
indx: 0,
layer: 0,
src: "arrow_1",
dmg: 35,
speed: 2.5,
scale: 103,
range: 1200
}, {
indx: 0,
layer: 0,
src: "arrow_1",
dmg: 30,
speed: 2,
scale: 103,
range: 1200
}, {
indx: 1,
layer: 1,
dmg: 16,
scale: 20
}, {
indx: 0,
layer: 0,
src: "bullet_1",
dmg: 50,
speed: 3.6,
scale: 160,
range: 1400
}];
// WEAPONS:
this.weapons = [{
id: 0,
type: 0,
name: "tool hammer",
desc: "tool for gathering all resources",
src: "hammer_1",
length: 140,
width: 140,
xOff: -3,
yOff: 18,
dmg: 25,
range: 65,
gather: 1,
speed: 300
}, {
id: 1,
type: 0,
age: 2,
name: "hand axe",
desc: "gathers resources at a higher rate",
src: "axe_1",
length: 140,
width: 140,
xOff: 3,
yOff: 24,
dmg: 30,
spdMult: 1,
range: 70,
gather: 2,
speed: 400
}, {
id: 2,
type: 0,
age: 8,
pre: 1,
name: "great axe",
desc: "deal more damage and gather more resources",
src: "great_axe_1",
length: 140,
width: 140,
xOff: -8,
yOff: 25,
dmg: 35,
spdMult: 1,
range: 75,
gather: 4,
speed: 400
}, {
id: 3,
type: 0,
age: 2,
name: "short sword",
desc: "increased attack power but slower move speed",
src: "sword_1",
iPad: 1.3,
length: 130,
width: 210,
xOff: -8,
yOff: 46,
dmg: 35,
spdMult: 0.85,
range: 110,
gather: 1,
speed: 300
}, {
id: 4,
type: 0,
age: 8,
pre: 3,
name: "katana",
desc: "greater range and damage",
src: "samurai_1",
iPad: 1.3,
length: 130,
width: 210,
xOff: -8,
yOff: 59,
dmg: 40,
spdMult: 0.8,
range: 118,
gather: 1,
speed: 300
}, {
id: 5,
type: 0,
age: 2,
name: "polearm",
desc: "long range melee weapon",
src: "spear_1",
iPad: 1.3,
length: 130,
width: 210,
xOff: -8,
yOff: 53,
dmg: 45,
knock: 0.2,
spdMult: 0.82,
range: 142,
gather: 1,
speed: 700
}, {
id: 6,
type: 0,
age: 2,
name: "bat",
desc: "fast long range melee weapon",
src: "bat_1",
iPad: 1.3,
length: 110,
width: 180,
xOff: -8,
yOff: 53,
dmg: 20,
knock: 0.7,
range: 110,
gather: 1,
speed: 300
}, {
id: 7,
type: 0,
age: 2,
name: "daggers",
desc: "really fast short range weapon",
src: "dagger_1",
iPad: 0.8,
length: 110,
width: 110,
xOff: 18,
yOff: 0,
dmg: 20,
knock: 0.1,
range: 65,
gather: 1,
hitSlow: 0.1,
spdMult: 1.13,
speed: 100
}, {
id: 8,
type: 0,
age: 2,
name: "stick",
desc: "great for gathering but very weak",
src: "stick_1",
length: 140,
width: 140,
xOff: 3,
yOff: 24,
dmg: 1,
spdMult: 1,
range: 70,
gather: 7,
speed: 400
}, {
id: 9,
type: 1,
age: 6,
name: "hunting bow",
desc: "bow used for ranged combat and hunting",
src: "bow_1",
req: ["wood", 4],
length: 120,
width: 120,
xOff: -6,
yOff: 0,
Pdmg: 25,
projectile: 0,
spdMult: 0.75,
speed: 600
}, {
id: 10,
type: 1,
age: 6,
name: "great hammer",
desc: "hammer used for destroying structures",
src: "great_hammer_1",
length: 140,
width: 140,
xOff: -9,
yOff: 25,
dmg: 10,
Pdmg: 10,
spdMult: 0.88,
range: 75,
sDmg: 7.5,
gather: 1,
speed: 400
}, {
id: 11,
type: 1,
age: 6,
name: "wooden shield",
desc: "blocks projectiles and reduces melee damage",
src: "shield_1",
length: 120,
width: 120,
shield: 0.2,
xOff: 6,
yOff: 0,
Pdmg: 0,
spdMult: 0.7
}, {
id: 12,
type: 1,
age: 8,
pre: 9,
name: "crossbow",
desc: "deals more damage and has greater range",
src: "crossbow_1",
req: ["wood", 5],
aboveHand: true,
armS: 0.75,
length: 120,
width: 120,
xOff: -4,
yOff: 0,
Pdmg: 35,
projectile: 2,
spdMult: 0.7,
speed: 700
}, {
id: 13,
type: 1,
age: 9,
pre: 12,
name: "repeater crossbow",
desc: "high firerate crossbow with reduced damage",
src: "crossbow_2",
req: ["wood", 10],
aboveHand: true,
armS: 0.75,
length: 120,
width: 120,
xOff: -4,
yOff: 0,
Pdmg: 30,
projectile: 3,
spdMult: 0.7,
speed: 230
}, {
id: 14,
type: 1,
age: 6,
name: "mc grabby",
desc: "steals resources from enemies",
src: "grab_1",
length: 130,
width: 210,
xOff: -8,
yOff: 53,
dmg: 0,
Pdmg: 0,
steal: 250,
knock: 0.2,
spdMult: 1.05,
range: 125,
gather: 0,
speed: 700
}, {
id: 15,
type: 1,
age: 9,
pre: 12,
name: "musket",
desc: "slow firerate but high damage and range",
src: "musket_1",
req: ["stone", 10],
aboveHand: true,
rec: 0.35,
armS: 0.6,
hndS: 0.3,
hndD: 1.6,
length: 205,
width: 205,
xOff: 25,
yOff: 0,
Pdmg: 50,
projectile: 5,
hideProjectile: true,
spdMult: 0.6,
speed: 1500
}];
// ITEMS:
this.list = [{
group: this.groups[0],
name: "apple",
desc: "restores 20 health when consumed",
req: ["food", 10],
consume: function(doer) {
return doer.changeHealth(20, doer);
},
scale: 22,
holdOffset: 15,
healing: 20,
itemID: 0,
itemAID: 16,
}, {
age: 3,
group: this.groups[0],
name: "cookie",
desc: "restores 40 health when consumed",
req: ["food", 15],
consume: function(doer) {
return doer.changeHealth(40, doer);
},
scale: 27,
holdOffset: 15,
healing: 40,
itemID: 1,
itemAID: 17,
}, {
age: 7,
group: this.groups[0],
name: "cheese",
desc: "restores 30 health and another 50 over 5 seconds",
req: ["food", 25],
consume: function(doer) {
if (doer.changeHealth(30, doer) || doer.health < 100) {
doer.dmgOverTime.dmg = -10;
doer.dmgOverTime.doer = doer;
doer.dmgOverTime.time = 5;
return true;
}
return false;
},
scale: 27,
holdOffset: 15,
healing: 30,
itemID: 2,
itemAID: 18,
}, {
group: this.groups[1],
name: "wood wall",
desc: "provides protection for your village",
req: ["wood", 10],
projDmg: true,
health: 380,
scale: 50,
holdOffset: 20,
placeOffset: 2,
itemID: 3,
itemAID: 19,
}, {
age: 3,
group: this.groups[1],
name: "stone wall",
desc: "provides improved protection for your village",
req: ["stone", 25],
health: 900,
scale: 50,
holdOffset: 20,
placeOffset: -5,
itemID: 4,
itemAID: 20,
}, {
age: 7,
group: this.groups[1],
name: "castle wall",
desc: "provides powerful protection for your village",
req: ["stone", 35],
health: 1500,
scale: 52,
holdOffset: 20,
placeOffset: -5,
itemID: 5,
itemAID: 21,
}, {
group: this.groups[2],
name: "spikes",
desc: "damages enemies when they touch them",
req: ["wood", 20, "stone", 5],
health: 400,
dmg: 20,
scale: 49,
spritePadding: -23,
holdOffset: 8,
placeOffset: -5,
itemID: 6,
itemAID: 22,
shadow: {
offsetX: 5, // Adjust the shadow's X offset as needed
offsetY: 5, // Adjust the shadow's Y offset as needed
blur: 20, // Adjust the shadow's blur as needed
color: "rgba(0, 0, 0, 0.5)" // Adjust the shadow's color and
transparency as needed
}
}, {
age: 5,
group: this.groups[2],
name: "greater spikes",
desc: "damages enemies when they touch them",
req: ["wood", 30, "stone", 10],
health: 500,
dmg: 35,
scale: 52,
spritePadding: -23,
holdOffset: 8,
placeOffset: -5,
itemID: 7,
itemAID: 23,
}, {
age: 9,
group: this.groups[2],
name: "poison spikes",
desc: "poisons enemies when they touch them",
req: ["wood", 35, "stone", 15],
health: 600,
dmg: 30,
pDmg: 5,
scale: 52,
spritePadding: -23,
holdOffset: 8,
placeOffset: -5,
itemID: 8,
itemAID: 24,
}, {
age: 9,
group: this.groups[2],
name: "spinning spikes",
desc: "damages enemies when they touch them",
req: ["wood", 30, "stone", 20],
health: 500,
dmg: 45,
turnSpeed: 0.003,
scale: 52,
spritePadding: -23,
holdOffset: 8,
placeOffset: -5,
itemID: 9,
itemAID: 25,
}, {
group: this.groups[3],
name: "windmill",
desc: "generates gold over time",
req: ["wood", 50, "stone", 10],
health: 400,
pps: 1,
turnSpeed: 0.0016,
spritePadding: 25,
iconLineMult: 12,
scale: 45,
holdOffset: 20,
placeOffset: 5,
itemID: 10,
itemAID: 26,
}, {
age: 5,
group: this.groups[3],
name: "faster windmill",
desc: "generates more gold over time",
req: ["wood", 60, "stone", 20],
health: 500,
pps: 1.5,
turnSpeed: 0.0025,
spritePadding: 25,
iconLineMult: 12,
scale: 47,
holdOffset: 20,
placeOffset: 5,
itemID: 11,
itemAID: 27,
}, {
age: 8,
group: this.groups[3],
name: "power mill",
desc: "generates more gold over time",
req: ["wood", 100, "stone", 50],
health: 800,
pps: 2,
turnSpeed: 0.005,
spritePadding: 25,
iconLineMult: 12,
scale: 47,
holdOffset: 20,
placeOffset: 5,
itemID: 12,
itemAID: 28,
}, {
age: 5,
group: this.groups[4],
type: 2,
name: "mine",
desc: "allows you to mine stone",
req: ["wood", 20, "stone", 100],
iconLineMult: 12,
scale: 65,
holdOffset: 20,
placeOffset: 0,
itemID: 13,
itemAID: 29,
}, {
age: 5,
group: this.groups[11],
type: 0,
name: "sapling",
desc: "allows you to farm wood",
req: ["wood", 150],
iconLineMult: 12,
colDiv: 0.5,
scale: 110,
holdOffset: 50,
placeOffset: -15,
itemID: 14,
itemAID: 30,
}, {
age: 4,
group: this.groups[5],
name: "pit trap",
desc: "pit that traps enemies if they walk over it",
req: ["wood", 30, "stone", 30],
trap: true,
ignoreCollision: true,
hideFromEnemy: true,
health: 500,
colDiv: 0.2,
scale: 50,
holdOffset: 20,
placeOffset: -5,
alpha: 0.6,
itemID: 15,
itemAID: 31,
}, {
age: 4,
group: this.groups[6],
name: "boost pad",
desc: "provides boost when stepped on",
req: ["stone", 20, "wood", 5],
ignoreCollision: true,
boostSpeed: 1.5,
health: 150,
colDiv: 0.7,
scale: 45,
holdOffset: 20,
placeOffset: -5,
itemID: 16,
itemAID: 32,
}, {
age: 7,
group: this.groups[7],
doUpdate: true,
name: "turret",
desc: "defensive structure that shoots at enemies",
req: ["wood", 200, "stone", 150],
health: 800,
projectile: 1,
shootRange: 700,
shootRate: 2200,
scale: 43,
holdOffset: 20,
placeOffset: -5,
itemID: 17,
itemAID: 33,
}, {
age: 7,
group: this.groups[8],
name: "platform",
desc: "platform to shoot over walls and cross over water",
req: ["wood", 20],
ignoreCollision: true,
zIndex: 1,
health: 300,
scale: 43,
holdOffset: 20,
placeOffset: -5,
itemID: 18,
itemAID: 34,
}, {
age: 7,
group: this.groups[9],
name: "healing pad",
desc: "standing on it will slowly heal you",
req: ["wood", 30, "food", 10],
ignoreCollision: true,
healCol: 15,
health: 400,
colDiv: 0.7,
scale: 45,
holdOffset: 20,
placeOffset: -5,
itemID: 19,
itemAID: 35,
}, {
age: 9,
group: this.groups[10],
name: "spawn pad",
desc: "you will spawn here when you die but it will dissapear",
req: ["wood", 100, "stone", 100],
health: 400,
ignoreCollision: true,
spawnPoint: true,
scale: 45,
holdOffset: 20,
placeOffset: -5,
itemID: 20,
itemAID: 36,
}, {
age: 7,
group: this.groups[12],
name: "blocker",
desc: "blocks building in radius",
req: ["wood", 30, "stone", 25],
ignoreCollision: true,
blocker: 300,
health: 400,
colDiv: 0.7,
scale: 45,
holdOffset: 20,
placeOffset: -5,
itemID: 21,
itemAID: 37,
}, {
age: 7,
group: this.groups[13],
name: "teleporter",
desc: "teleports you to a random point on the map",
req: ["wood", 60, "stone", 60],
ignoreCollision: true,
teleport: true,
health: 200,
colDiv: 0.7,
scale: 45,
holdOffset: 20,
placeOffset: -5,
itemID: 22,
itemAID: 38
}];
// ASSIGN IDS:
for (let i = 0; i < this.list.length; ++i) {
this.list[i].id = i;
if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
}
// TROLOLOLOL:
if (typeof window !== "undefined") {
function shuffle(a) {
for (let i = a.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[a[i], a[j]] = [a[j], a[i]];
}
return a;
}
//shuffle(this.list);
}
}
}
class Objectmanager {
constructor(GameObject, liztobj, UTILS, config, players, server) {
let mathFloor = Math.floor,
mathABS = Math.abs,
mathCOS = Math.cos,
mathSIN = Math.sin,
mathPOW = Math.pow,
mathSQRT = Math.sqrt;
this.ignoreAdd = false;
this.hitObj = [];
// DISABLE OBJ:
this.disableObj = function(obj) {
obj.active = false;
};
// ADD NEW:
let _;
this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
_ = findObjectBySid(sid);
if (!_) {
_ = gameObjects.find((tmp) => !tmp.active);
if (!_) {
_ = new GameObject(sid);
gameObjects.push(_);
}
}
if (setSID) {
_.sid = sid;
}
_.init(x, y, dir, s, type, data, owner);
};
// DISABLE BY SID:
this.disableBySid = function(sid) {
let find = findObjectBySid(sid);
if (find) {
this.disableObj(find);
}
};
// CHECK IF PLACABLE:
this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater,
placer) {
let cantPlace = liztobj.find((tmp) => tmp.active &&
UTILS.getDistance(x, y, tmp.x, tmp.y) < s + (tmp.blocker ? tmp.blocker :
tmp.getScale(sM, tmp.isItem)));
if (cantPlace) return false;
if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 -
config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return
false;
return true;
};
}
}
class Projectile {
constructor(players, ais, objectManager, items, config, UTILS, server) {
// INIT:
this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
this.active = true;
this.tickActive = true;
this.indx = indx;
this.x = x;
this.y = y;
this.x2 = x;
this.y2 = y;
this.dir = dir;
this.skipMov = true;
this.speed = spd;
this.dmg = dmg;
this.scale = scl;
this.range = rng;
this.r2 = rng;
this.owner = owner;
};
// UPDATE:
this.update = function(delta) {
if (this.active) {
let tmpSpeed = this.speed * delta;
if (!this.skipMov) {
this.x += tmpSpeed * Math.cos(this.dir);
this.y += tmpSpeed * Math.sin(this.dir);
this.range -= tmpSpeed;
if (this.range <= 0) {
this.x += this.range * Math.cos(this.dir);
this.y += this.range * Math.sin(this.dir);
tmpSpeed = 1;
this.range = 0;
this.active = false;
}
} else {
this.skipMov = false;
}
}
};
this.tickUpdate = function(delta) {
if (this.tickActive) {
let tmpSpeed = this.speed * delta;
if (!this.skipMov) {
this.x2 += tmpSpeed * Math.cos(this.dir);
this.y2 += tmpSpeed * Math.sin(this.dir);
this.r2 -= tmpSpeed;
if (this.r2 <= 0) {
this.x2 += this.r2 * Math.cos(this.dir);
this.y2 += this.r2 * Math.sin(this.dir);
tmpSpeed = 1;
this.r2 = 0;
this.tickActive = false;
}
} else {
this.skipMov = false;
}
}
};
}
};
class Store {
constructor() {
// STORE HATS:
this.hats = [{
id: 45,
name: "Shame!",
dontSell: true,
price: 0,
scale: 120,
desc: "hacks are for winners"
}, {
id: 51,
name: "Moo Cap",
price: 0,
scale: 120,
desc: "coolest mooer around"
}, {
id: 50,
name: "Apple Cap",
price: 0,
scale: 120,
desc: "apple farms remembers"
}, {
id: 28,
name: "Moo Head",
price: 0,
scale: 120,
desc: "no effect"
}, {
id: 29,
name: "Pig Head",
price: 0,
scale: 120,
desc: "no effect"
}, {
id: 30,
name: "Fluff Head",
price: 0,
scale: 120,
desc: "no effect"
}, {
id: 36,
name: "Pandou Head",
price: 0,
scale: 120,
desc: "no effect"
}, {
id: 37,
name: "Bear Head",
price: 0,
scale: 120,
desc: "no effect"
}, {
id: 38,
name: "Monkey Head",
price: 0,
scale: 120,
desc: "no effect"
}, {
id: 44,
name: "Polar Head",
price: 0,
scale: 120,
desc: "no effect"
}, {
id: 35,
name: "Fez Hat",
price: 0,
scale: 120,
desc: "no effect"
}, {
id: 42,
name: "Enigma Hat",
price: 0,
scale: 120,
desc: "join the enigma army"
}, {
id: 43,
name: "Blitz Hat",
price: 0,
scale: 120,
desc: "hey everybody i'm blitz"
}, {
id: 49,
name: "Bob XIII Hat",
price: 0,
scale: 120,
desc: "like and subscribe"
}, {
id: 57,
name: "Pumpkin",
price: 50,
scale: 120,
desc: "Spooooky"
}, {
id: 8,
name: "Bummle Hat",
price: 100,
scale: 120,
desc: "no effect"
}, {
id: 2,
name: "Straw Hat",
price: 500,
scale: 120,
desc: "no effect"
}, {
id: 15,
name: "Winter Cap",
price: 600,
scale: 120,
desc: "allows you to move at normal speed in snow",
coldM: 1
}, {
id: 5,
name: "Cowboy Hat",
price: 1000,
scale: 120,
desc: "no effect"
}, {
id: 4,
name: "Ranger Hat",
price: 2000,
scale: 120,
desc: "no effect"
}, {
id: 18,
name: "Explorer Hat",
price: 2000,
scale: 120,
desc: "no effect"
}, {
id: 31,
name: "Flipper Hat",
price: 2500,
scale: 120,
desc: "have more control while in water",
watrImm: true
}, {
id: 1,
name: "Marksman Cap",
price: 3000,
scale: 120,
desc: "increases arrow speed and range",
aMlt: 1.3
}, {
id: 10,
name: "Bush Gear",
price: 3000,
scale: 160,
desc: "allows you to disguise yourself as a bush"
}, {
id: 48,
name: "Halo",
price: 3000,
scale: 120,
desc: "no effect"
}, {
id: 6,
name: "Soldier Helmet",
price: 4000,
scale: 120,
desc: "reduces damage taken but slows movement",
spdMult: 0.94,
dmgMult: 0.75
}, {
id: 23,
name: "Anti Venom Gear",
price: 4000,
scale: 120,
desc: "makes you immune to poison",
poisonRes: 1
}, {
id: 13,
name: "Medic Gear",
price: 5000,
scale: 110,
desc: "slowly regenerates health over time",
healthRegen: 3
}, {
id: 9,
name: "Miners Helmet",
price: 5000,
scale: 120,
desc: "earn 1 extra gold per resource",
extraGold: 1
}, {
id: 32,
name: "Musketeer Hat",
price: 5000,
scale: 120,
desc: "reduces cost of projectiles",
projCost: 0.5
}, {
id: 7,
name: "Bull Helmet",
price: 6000,
scale: 120,
desc: "increases damage done but drains health",
healthRegen: -5,
dmgMultO: 1.5,
spdMult: 0.96
}, {
id: 22,
name: "Emp Helmet",
price: 6000,
scale: 120,
desc: "turrets won't attack but you move slower",
antiTurret: 1,
spdMult: 0.7
}, {
id: 12,
name: "Booster Hat",
price: 6000,
scale: 120,
desc: "increases your movement speed",
spdMult: 1.16
}, {
id: 26,
name: "Barbarian Armor",
price: 8000,
scale: 120,
desc: "knocks back enemies that attack you",
dmgK: 0.6
}, {
id: 21,
name: "Plague Mask",
price: 10000,
scale: 120,
desc: "melee attacks deal poison damage",
poisonDmg: 5,
poisonTime: 6
}, {
id: 46,
name: "Bull Mask",
price: 10000,
scale: 120,
desc: "bulls won't target you unless you attack them",
bullRepel: 1
}, {
id: 14,
name: "Windmill Hat",
topSprite: true,
price: 10000,
scale: 120,
desc: "generates points while worn",
pps: 1.5
}, {
id: 11,
name: "Spike Gear",
topSprite: true,
price: 10000,
scale: 120,
desc: "deal damage to players that damage you",
dmg: 0.45
}, {
id: 53,
name: "Turret Gear",
topSprite: true,
price: 10000,
scale: 120,
desc: "you become a walking turret",
turret: {
proj: 1,
range: 700,
rate: 2500
},
spdMult: 0.7
}, {
id: 20,
name: "Samurai Armor",
price: 12000,
scale: 120,
desc: "increased attack speed and fire rate",
atkSpd: 0.78
}, {
id: 58,
name: "Dark Knight",
price: 12000,
scale: 120,
desc: "restores health when you deal damage",
healD: 0.4
}, {
id: 27,
name: "Scavenger Gear",
price: 15000,
scale: 120,
desc: "earn double points for each kill",
kScrM: 2
}, {
id: 40,
name: "Tank Gear",
price: 15000,
scale: 120,
desc: "increased damage to buildings but slower movement",
spdMult: 0.3,
bDmg: 3.3
}, {
id: 52,
name: "Thief Gear",
price: 15000,
scale: 120,
desc: "steal half of a players gold when you kill them",
goldSteal: 0.5
}, {
id: 55,
name: "Bloodthirster",
price: 20000,
scale: 120,
desc: "Restore Health when dealing damage. And increased damage",
healD: 0.25,
dmgMultO: 1.2,
}, {
id: 56,
name: "Assassin Gear",
price: 20000,
scale: 120,
desc: "Go invisible when not moving. Can't eat. Increased speed",
noEat: true,
spdMult: 1.1,
invisTimer: 1000
}];
// STORE ACCESSORIES:
this.accessories = [{
id: 12,
name: "Snowball",
price: 1000,
scale: 105,
xOff: 18,
desc: "no effect"
}, {
id: 9,
name: "Tree Cape",
price: 1000,
scale: 90,
desc: "no effect"
}, {
id: 10,
name: "Stone Cape",
price: 1000,
scale: 90,
desc: "no effect"
}, {
id: 3,
name: "Cookie Cape",
price: 1500,
scale: 90,
desc: "no effect"
}, {
id: 8,
name: "Cow Cape",
price: 2000,
scale: 90,
desc: "no effect"
}, {
id: 11,
name: "Monkey Tail",
price: 2000,
scale: 97,
xOff: 25,
desc: "Super speed but reduced damage",
spdMult: 1.35,
dmgMultO: 0.2
}, {
id: 17,
name: "Apple Basket",
price: 3000,
scale: 80,
xOff: 12,
desc: "slowly regenerates health over time",
healthRegen: 1
}, {
id: 6,
name: "Winter Cape",
price: 3000,
scale: 90,
desc: "no effect"
}, {
id: 4,
name: "Skull Cape",
price: 4000,
scale: 90,
desc: "no effect"
}, {
id: 5,
name: "Dash Cape",
price: 5000,
scale: 90,
desc: "no effect"
}, {
id: 2,
name: "Dragon Cape",
price: 6000,
scale: 90,
desc: "no effect"
}, {
id: 1,
name: "Super Cape",
price: 8000,
scale: 90,
desc: "no effect"
}, {
id: 7,
name: "Troll Cape",
price: 8000,
scale: 90,
desc: "no effect"
}, {
id: 14,
name: "Thorns",
price: 10000,
scale: 115,
xOff: 20,
desc: "no effect"
}, {
id: 15,
name: "Blockades",
price: 10000,
scale: 95,
xOff: 15,
desc: "no effect"
}, {
id: 20,
name: "Devils Tail",
price: 10000,
scale: 95,
xOff: 20,
desc: "no effect"
}, {
id: 16,
name: "Sawblade",
price: 12000,
scale: 90,
spin: true,
xOff: 0,
desc: "deal damage to players that damage you",
dmg: 0.15
}, {
id: 13,
name: "Angel Wings",
price: 15000,
scale: 138,
xOff: 22,
desc: "slowly regenerates health over time",
healthRegen: 3
}, {
id: 19,
name: "Shadow Wings",
price: 15000,
scale: 138,
xOff: 22,
desc: "increased movement speed",
spdMult: 1.1
}, {
id: 18,
name: "Blood Wings",
price: 20000,
scale: 178,
xOff: 26,
desc: "restores health when you deal damage",
healD: 0.2
}, {
id: 21,
name: "Corrupt X Wings",
price: 20000,
scale: 178,
xOff: 26,
desc: "deal damage to players that damage you",
dmg: 0.25
}];
}
};
class ProjectileManager {
constructor(Projectile, projectiles, players, ais, objectManager, items,
config, UTILS, server) {
this.addProjectile = function(x, y, dir, range, speed, indx, owner,
ignoreObj, layer, inWindow) {
let tmpData = items.projectiles[indx];
let tmpProj;
for (let i = 0; i < projectiles.length; ++i) {
if (!projectiles[i].active) {
tmpProj = projectiles[i];
break;
}
}
if (!tmpProj) {
tmpProj = new Projectile(players, ais, objectManager, items,
config, UTILS, server);
tmpProj.sid = projectiles.length;
projectiles.push(tmpProj);
}
tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range,
tmpData.scale, owner);
tmpProj.ignoreObj = ignoreObj;
tmpProj.layer = layer || tmpData.layer;
tmpProj.inWindow = inWindow;
tmpProj.src = tmpData.src;
return tmpProj;
};
}
};
class AiManager {
constructor(ais, AI, players, items, objectManager, config, UTILS,
scoreCallback, server) {
this.aiTypes = [{
id: 0,
src: "cow_1",
killScore: 150,
health: 500,
weightM: 0.8,
speed: 0.00095,
turnSpeed: 0.001,
scale: 72,
drop: ["food", 50]
}, {
id: 1,
src: "pig_1",
killScore: 200,
health: 800,
weightM: 0.6,
speed: 0.00085,
turnSpeed: 0.001,
scale: 72,
drop: ["food", 80]
}, {
id: 2,
name: "Bull",
src: "bull_2",
hostile: true,
dmg: 20,
killScore: 1000,
health: 1800,
weightM: 0.5,
speed: 0.00094,
turnSpeed: 0.00074,
scale: 78,
viewRange: 800,
chargePlayer: true,
drop: ["food", 100]
}, {
id: 3,
name: "Bully",
src: "bull_1",
hostile: true,
dmg: 20,
killScore: 2000,
health: 2800,
weightM: 0.45,
speed: 0.001,
turnSpeed: 0.0008,
scale: 90,
viewRange: 900,
chargePlayer: true,
drop: ["food", 400]
}, {
id: 4,
name: "Wolf",
src: "wolf_1",
hostile: true,
dmg: 8,
killScore: 500,
health: 300,
weightM: 0.45,
speed: 0.001,
turnSpeed: 0.002,
scale: 84,
viewRange: 800,
chargePlayer: true,
drop: ["food", 200]
}, {
id: 5,
name: "Quack",
src: "chicken_1",
dmg: 8,
killScore: 2000,
noTrap: true,
health: 300,
weightM: 0.2,
speed: 0.0018,
turnSpeed: 0.006,
scale: 70,
drop: ["food", 100]
}, {
id: 6,
name: "MOOSTAFA",
nameScale: 50,
src: "enemy",
hostile: true,
dontRun: true,
fixedSpawn: true,
spawnDelay: 60000,
noTrap: true,
colDmg: 100,
dmg: 40,
killScore: 8000,
health: 18000,
weightM: 0.4,
speed: 0.0007,
turnSpeed: 0.01,
scale: 80,
spriteMlt: 1.8,
leapForce: 0.9,
viewRange: 1000,
hitRange: 210,
hitDelay: 1000,
chargePlayer: true,
drop: ["food", 100]
}, {
id: 7,
name: "Treasure",
hostile: true,
nameScale: 35,
src: "crate_1",
fixedSpawn: true,
spawnDelay: 120000,
colDmg: 200,
killScore: 5000,
health: 20000,
weightM: 0.1,
speed: 0.0,
turnSpeed: 0.0,
scale: 70,
spriteMlt: 1.0
}, {
id: 8,
name: "MOOFIE",
src: "wolf_2",
hostile: true,
fixedSpawn: true,
dontRun: true,
hitScare: 4,
spawnDelay: 30000,
noTrap: true,
nameScale: 35,
dmg: 10,
colDmg: 100,
killScore: 3000,
health: 7000,
weightM: 0.45,
speed: 0.0015,
turnSpeed: 0.002,
scale: 90,
viewRange: 800,
chargePlayer: true,
drop: ["food", 1000]
}, {
id: 9,
name: "MOOFIE",
src: "wolf_2",
hostile: !0,
fixedSpawn: !0,
dontRun: !0,
hitScare: 50,
spawnDelay: 6e4,
noTrap: !0,
nameScale: 35,
dmg: 12,
colDmg: 100,
killScore: 3e3,
health: 9e3,
weightM: .45,
speed: .0015,
turnSpeed: .0025,
scale: 94,
viewRange: 1440,
chargePlayer: !0,
drop: ["food", 3e3],
minSpawnRange: .85,
maxSpawnRange: .9
}, {
id: 10,
name: "Wolf",
src: "wolf_1",
hostile: !0,
fixedSpawn: !0,
dontRun: !0,
hitScare: 50,
spawnDelay: 3e4,
dmg: 10,
killScore: 700,
health: 500,
weightM: .45,
speed: .00115,
turnSpeed: .0025,
scale: 88,
viewRange: 1440,
chargePlayer: !0,
drop: ["food", 400],
minSpawnRange: .85,
maxSpawnRange: .9
}, {
id: 11,
name: "Bully",
src: "bull_1",
hostile: !0,
fixedSpawn: !0,
dontRun: !0,
hitScare: 50,
dmg: 20,
killScore: 5e3,
health: 5e3,
spawnDelay: 1e5,
weightM: .45,
speed: .00115,
turnSpeed: .0025,
scale: 94,
viewRange: 1440,
chargePlayer: !0,
drop: ["food", 800],
minSpawnRange: .85,
maxSpawnRange: .9
}];
// INIT:
this.init = function(x, y, dir, index, data) {
this.x = x;
this.y = y;
this.startX = data.fixedSpawn ? x : null;
this.startY = data.fixedSpawn ? y : null;
this.xVel = 0;
this.yVel = 0;
this.zIndex = 0;
this.dir = dir;
this.dirPlus = 0;
this.showName = 'aaa';
this.index = index;
this.src = data.src;
if (data.name) this.name = data.name;
this.weightM = data.weightM;
this.speed = data.speed;
this.killScore = data.killScore;
this.turnSpeed = data.turnSpeed;
this.scale = data.scale;
this.maxHealth = data.health;
this.leapForce = data.leapForce;
this.health = this.maxHealth;
this.chargePlayer = data.chargePlayer;
this.viewRange = data.viewRange;
this.drop = data.drop;
this.dmg = data.dmg;
this.hostile = data.hostile;
this.dontRun = data.dontRun;
this.hitRange = data.hitRange;
this.hitDelay = data.hitDelay;
this.hitScare = data.hitScare;
this.spriteMlt = data.spriteMlt;
this.nameScale = data.nameScale;
this.colDmg = data.colDmg;
this.noTrap = data.noTrap;
this.spawnDelay = data.spawnDelay;
this.hitWait = 0;
this.waitCount = 1000;
this.moveCount = 0;
this.targetDir = 0;
this.active = true;
this.alive = true;
this.runFrom = null;
this.chargeTarget = null;
this.dmgOverTime = {};
};
let tmpRatio = 0;
let animIndex = 0;
this.animate = function(delta) {
if (this.animTime > 0) {
this.animTime -= delta;
if (this.animTime <= 0) {
this.animTime = 0;
this.dirPlus = 0;
tmpRatio = 0;
animIndex = 0;
} else {
if (animIndex == 0) {
tmpRatio += delta / (this.animSpeed *
config.hitReturnRatio);
this.dirPlus = UTILS.lerp(0, this.targetAngle,
Math.min(1, tmpRatio));
if (tmpRatio >= 1) {
tmpRatio = 1;
animIndex = 1;
}
} else {
tmpRatio -= delta / (this.animSpeed * (1 -
config.hitReturnRatio));
this.dirPlus = UTILS.lerp(0, this.targetAngle,
Math.max(0, tmpRatio));
}
}
}
};
// ANIMATION:
this.startAnim = function() {
this.animTime = this.animSpeed = 600;
this.targetAngle = Math.PI * 0.8;
tmpRatio = 0;
animIndex = 0;
};
};
};
class Petal {
constructor(x, y) {
this.x = x;
this.y = y;
this.damage = 10;
this.health = 10;
this.maxHealth = this.health;
this.active = false;
this.alive = false;
this.timer = 1500;
this.time = 0;
this.damaged = 0;
this.alpha = 1;
this.scale = 9;
this.visScale = this.scale;
}
};
class addCh {
constructor(x, y, chat, _) {
this.x = x;
this.y = y;
this.alpha = 0;
this.active = true;
this.alive = false;
this.chat = chat;
this.owner = _;
};
};
class DeadPlayer {
constructor(t, n, i, o, a, r, s, l, c, d) {
this.x = t;
this.y = n;
this.lastDir = i;
this.dir = i + Math.PI;
this.buildIndex = o;
this.weaponIndex = a;
this.weaponVariant = r;
this.skinColor = s;
this.scale = l;
this.visScale = 0;
this.name = c;
this.alpha = 1;
this.active = true;
this.deathDir = d;
this.animate = function (t) {
let n = UTILS.getAngleDist(this.lastDir, this.dir);
if (n > 0.01) {
this.dir += n / 20;
} else {
this.dir = this.lastDir;
}
if (this.visScale < this.scale) {
this.visScale += t / (this.scale / 2);
if (this.visScale >= this.scale) {
this.visScale = this.scale;
}
}
this.alpha -= t / 3e3;
if (this.alpha <= 0) {
this.alpha = 0;
this.active = false;
}
};
}
};
class Player {
constructor(id, sid, config, UTILS, projectileManager, objectManager,
players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
this.id = id;
this.sid = sid;
this.tmpScore = 0;
this.team = null;
this.latestSkin = 0;
this.oldSkinIndex = 0;
this.skinIndex = 0;
this.latestTail = 0;
this.oldTailIndex = 0;
this.tailIndex = 0;
this.hitTime = 0;
this.lastHit = 0;
this.tails = {};
for (let i = 0; i < accessories.length; ++i) {
if (accessories[i].price <= 0) this.tails[accessories[i].id] = 1;
}
this.skins = {};
for (let i = 0; i < hats.length; ++i) {
if (hats[i].price <= 0) this.skins[hats[i].id] = 1;
}
this.points = 0;
this.dt = 0;
this.hidden = false;
this.itemCounts = {};
this.isPlayer = true;
this.pps = 0;
this.moveDir = undefined;
this.skinRot = 0;
this.lastPing = 0;
this.iconIndex = 0;
this.skinColor = 0;
this.dist2 = 0;
this.aim2 = 0;
this.maxSpeed = 1;
this.chat = {
message: null,
count: 0
};
this.circle = false;
this.cAngle = 0;
// SPAWN:
this.spawn = function(moofoll) {
this.attacked = false;
this.timeDamaged = 0;
this.timeHealed = 0;
this.pinge = 0;
this.millPlace = 'NOOO';
this.lastshamecount = 0;
this.death = false;
this.spinDir = 0;
this.sync = false;
this.antiBull = 0;
this.bullTimer = 0;
this.poisonTimer = 0;
this.active = true;
this.alive = true;
this.lockMove = false;
this.lockDir = false;
this.minimapCounter = 0;
this.chatCountdown = 0;
this.shameCount = 0;
this.shameTimer = 0;
this.sentTo = {};
this.gathering = 0;
this.gatherIndex = 0;
this.shooting = {};
this.shootIndex = 9;
this.autoGather = 0;
this.animTime = 0;
this.animSpeed = 0;
this.mouseState = 0;
this.buildIndex = -1;
this.weaponIndex = 0;
this.weaponCode = 0;
this.weaponVariant = 0;
this.primaryIndex = undefined;
this.secondaryIndex = undefined;
this.dmgOverTime = {};
this.noMovTimer = 0;
this.maxXP = 300;
this.XP = 0;
this.age = 1;
this.kills = 0;
this.upgrAge = 2;
this.upgradePoints = 0;
this.x = 0;
this.y = 0;
this.oldXY = {
x: 0,
y: 0
};
this.zIndex = 0;
this.xVel = 0;
this.yVel = 0;
this.slowMult = 1;
this.dir = 0;
this.dirPlus = 0;
this.targetDir = 0;
this.targetAngle = 0;
this.maxHealth = 100;
this.health = this.maxHealth;
this.oldHealth = this.maxHealth;
this.damaged = 0;
this.scale = config.playerScale;
this.speed = config.playerSpeed;
this.resetMoveDir();
this.resetResources(moofoll);
this.items = [0, 3, 6, 10];
this.weapons = [0];
this.shootCount = 0;
this.weaponXP = [];
this.reloads = {
0: 0,
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
6: 0,
7: 0,
8: 0,
9: 0,
10: 0,
11: 0,
12: 0,
13: 0,
14: 0,
15: 0,
53: 0,
};
this.bowThreat = {
9: 0,
12: 0,
13: 0,
15: 0,
};
this.damageThreat = 0;
this.inTrap = false;
this.canEmpAnti = false;
this.empAnti = false;
this.soldierAnti = false;
this.poisonTick = 0;
this.bullTick = 0;
this.setPoisonTick = false;
this.setBullTick = false;
this.antiTimer = 2;
};
// RESET RESOURCES:
this.resetResources = function(moofoll) {
for (let i = 0; i < config.resourceTypes.length; ++i) {
this[config.resourceTypes[i]] = moofoll ? 100 : 0;
}
};
// ADD ITEM:
this.getItemType = function(id) {
let findindx = this.items.findIndex((ids) => ids == id);
if (findindx != -1) {
return findindx;
} else {
return items.checkItem.index(id, this.items);
}
};
// SET DATA:
this.setData = function(data) {
this.id = data[0];
this.sid = data[1];
this.name = data[2];
this.x = data[3];
this.y = data[4];
this.dir = data[5];
this.health = data[6];
this.maxHealth = data[7];
this.scale = data[8];
this.skinColor = data[9];
};
this.bullTimer -= 1;
if (this.bullTimer <= 0) {
this.setBullTick = false;
this.bullTick = game.tick - 1;
this.bullTimer = config.serverUpdateRate;
}
this.poisonTimer -= 1;
if (this.poisonTimer <= 0) {
this.setPoisonTick = false;
this.poisonTick = game.tick - 1;
this.poisonTimer = config.serverUpdateRate;
if (near.dist2 <= 500) {
plaguemask = true;
} else {
plaguemask = false;
}
} else {
plaguemask = false;
}
};
this.update = function(delta) {
if (this.active) {
// MOVE:
let gear = {
skin: findID(hats, this.skinIndex),
tail: findID(accessories, this.tailIndex)
}
let spdMult = ((this.buildIndex >= 0) ? 0.5 : 1) *
(items.weapons[this.weaponIndex].spdMult || 1) * (gear.skin ? (gear.skin.spdMult ||
1) : 1) * (gear.tail ? (gear.tail.spdMult || 1) : 1) * (this.y <=
config.snowBiomeTop ? ((gear.skin && gear.skin.coldM) ? 1 : config.snowSpeed) : 1)
* this.slowMult;
this.maxSpeed = spdMult;
}
};
let tmpRatio = 0;
let animIndex = 0;
this.animate = function(delta) {
if (this.animTime > 0) {
this.animTime -= delta;
if (this.animTime <= 0) {
this.animTime = 0;
this.dirPlus = 0;
tmpRatio = 0;
animIndex = 0;
} else {
if (animIndex == 0) {
tmpRatio += delta / (this.animSpeed *
config.hitReturnRatio);
this.dirPlus = UTILS.lerp(0, this.targetAngle,
Math.min(1, tmpRatio));
if (tmpRatio >= 1) {
tmpRatio = 1;
animIndex = 1;
}
} else {
tmpRatio -= delta / (this.animSpeed * (1 -
config.hitReturnRatio));
this.dirPlus = UTILS.lerp(0, this.targetAngle,
Math.max(0, tmpRatio));
}
}
}
};
// GATHER ANIMATION:
this.startAnim = function(didHit, index) {
this.animTime = this.animSpeed = items.weapons[index].speed;
this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
tmpRatio = 0;
animIndex = 0;
};
// CAN SEE:
this.canSee = function(other) {
if (!other) return false;
let dx = Math.abs(other.x - this.x) - other.scale;
let dy = Math.abs(other.y - this.y) - other.scale;
return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <=
(config.maxScreenHeight / 2) * 1.3;
};
// SHAME SYSTEM:
this.judgeShame = function() {
this.lastshamecount = this.shameCount;
if (this.oldHealth < this.health) {
if (this.hitTime) {
let timeSinceHit = game.tick - this.hitTime;
this.lastHit = game.tick;
this.hitTime = 0;
if (timeSinceHit < 2) {
this.shameCount++;
} else {
this.shameCount = Math.max(0, this.shameCount - 2);
}
}
} else if (this.oldHealth > this.health) {
this.hitTime = game.tick;
}
};
this.addShameTimer = function() {
this.shameCount = 0;
this.shameTimer = 30;
let interval = setInterval(() => {
this.shameTimer--;
if (this.shameTimer <= 0) {
clearInterval(interval);
}
}, 1000);
};
// CHECK TEAM:
this.isTeam = function(_) {
return (this == _ || (this.team && this.team == _.team));
};
// PREPLACER
if (this.reloads[this.weaponIndex] <= 1000/9) {
// place(2, getAttackDir());
let index = this.weaponIndex;
let nearObja = liztobj.filter((e) => (e.active || e.alive) &&
e.health < e.maxHealth && e.group !== undefined && UTILS.getDist(e, player, 0, 2)
<= (items.weapons[player.weaponIndex].range + e.scale));
for(let i = 0; i < nearObja.length; i++) {
let aaa = nearObja[i];
if (this.gathering || this.shooting[1]) {
if (this.gathering) {
this.gathering = 0;
this.reloads[this.gatherIndex] =
(items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
this.attacked = true;
}
if (this.shooting[1]) {
this.shooting[1] = 0;
this.reloads[this.shootIndex] =
(items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
this.attacked = true;
}
} else {
this.attacked = false;
if (this.buildIndex < 0) {
if (this.reloads[this.weaponIndex] > 0) {
// Math.max(0, this.reloads[this.weaponIndex] -
game.tickRate)
this.reloads[this.weaponIndex] = Math.max(0,
this.reloads[this.weaponIndex] - 110);
if (this == player) {
if (getEl("weaponGrind").checked) {
for (let i = 0; i < Math.PI * 2; i += Math.PI /
2) {
checkPlace(player.getItemType(22), i);
}
}
}
if (this.reloads[this.primaryIndex] == 0 &&
this.reloads[this.weaponIndex] == 0) {
this.antiBull++;
game.tickBase(() => {
this.antiBull = 0;
}, 1);
}
}
}
}
};
}
};
class Particle {
constructor() {}
init(x, y, radius, speed, life, color, horizontalSpeed) {
this.x = x;
this.y = y;
this.radius = radius;
this.startRadius = radius;
this.maxRadius = 1.5 * radius;
this.scaleSpeed = 0.7;
this.speed = speed;
this.life = life;
this.totalLife = life;
this.color = color;
this.opacity = 1;
this.horizontalSpeed = horizontalSpeed;
this.initialHorizontalSpeed = horizontalSpeed;
}
update(deltaTime) {
if (this.life > 0) {
this.life -= deltaTime;
this.y -= this.speed * deltaTime;
this.x += this.horizontalSpeed * deltaTime;
this.horizontalSpeed *= 0.95;
this.radius += this.scaleSpeed * deltaTime;
if (this.radius >= this.maxRadius) {
this.radius = this.maxRadius;
this.scaleSpeed *= -1;
} else if (this.radius <= this.startRadius) {
this.radius = this.startRadius;
this.scaleSpeed = 0;
}
this.opacity = Math.max(this.life / this.totalLife, 0);
}
}
render(ctx, offsetX, offsetY) {
ctx.save();
ctx.globalAlpha = this.opacity;
ctx.beginPath();
ctx.arc(this.x - offsetX, this.y - offsetY, this.radius, 0, 2 *
Math.PI);
ctx.fillStyle = this.color;
ctx.shadowColor = this.color;
ctx.shadowBlur = 20;
ctx.fill();
ctx.restore();
}
}
// SOME CODES:
function sendUpgrade(index) {
player.reloads[index] = 0;
packet("H", index);
}
function sendAutoGather() {
packet("K", 1, 1);
}
// PLACER:
function place(id, rad, rmd) {
try {
if (id == undefined) return;
let item = items.list[player.items[id]];
let tmpS = player.scale + item.scale + (item.placeOffset || 0);
let tmpX = player.x2 + tmpS * Math.cos(rad);
let tmpY = player.y2 + tmpS * Math.sin(rad);
if ((player.alive && inGame && player.itemCounts[item.group.id] ==
undefined ? true : player.itemCounts[item.group.id] < (config.isSandbox ? 299 :
item.group.limit ? item.group.limit : 99))) {
selectToBuild(player.items[id]);
sendAtck(1, rad);
selectWeapon(player.weaponCode, 1);
if (rmd && getEl("placeVis").checked) {
placeVisible.push({
x: tmpX,
y: tmpY,
name: item.name,
scale: item.scale,
dir: rad
});
game.tickBase(() => {
placeVisible.shift();
}, 1)
}
}
} catch (e) {}
}
function healthBased() {
if (player.health === 100) {
return 0;
}
function getAttacker(damaged) {
let attackers = enemy.filter(tmp => {
let rule = {
three: tmp.attacked
}
return rule.three;
});
return attackers;
}
function healer() {
for (let i = 0; i < healthBased(); i++) {
place(0, getAttackDir());
}
}
function healer33() {
for (let i = 0; i < healthBased(); i++) {
place(0, getAttackDir());
}
}
function healer1() {
place(0, getAttackDir());
return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
}
function noshameheal() {
place(0, getAttackDir());
if (player.shameCount >= 5) {
place(0, getAttackDir());
healer33();
} else {
if (player.skinIndex != 6 && player.skinIndex != 22) {
healer33();
buyEquip(6, 0);
} else {
const neededHealing = Math.ceil((100 - player.health) /
items.list[player.items[0]].healing);
healer33();
return neededHealing;
}
}
}
function antiSyncHealing() {
if (my.antiSync) return;
my.antiSync = true;
const healAnti = setInterval(() => {
const shameCount = player.shameCount;
const attackDirection = getAttackDir();
if (shameCount < 5) {
place(0, attackDirection);
} else {
clearInterval(healAnti);
my.antiSync = false;
}
}, 75);
setTimeout(() => {
clearInterval(healAnti);
my.antiSync = false;
}, game.tickRate);
}
function applCxC(value) {
if (player.health == 100) return 0;
if (player.skinIndex != 45 && player.skinIndex != 56) {
return Math.ceil(value / items.list[player.items[0]].healing);
}
return 0;
}
function calcDmg(value) {
return value * player.skinIndex == 6 ? 0.75 : 1;
}
function biomeGear(mover, returns) {
if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2
<= config.mapScale / 2 + config.riverWidth / 2) {
if (returns) return 31;
buyEquip(31, 0);
} else {
if (player.y2 <= config.snowBiomeTop) {
if (returns) return mover && player.moveDir == undefined ? 22 : 15;
buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
} else {
if (returns) return mover && player.moveDir == undefined ? 22 : 12;
buyEquip(mover && player.moveDir == undefined ? 22 : 12, 0);
}
}
if (returns) return 0;
}
let info = {};
let aimSpike = 0;
function smartTick(tick) {
doStuffPingSet.push(tick);
}
class Combat {
constructor(UTILS, items) {
this.findSpikeHit = {
x: 0,
y: 0,
spikePosX: 0,
spikePosY: 0,
canHit: false,
spikes: [],
};
this.spikesNearEnemy = [];
this.doSpikeHit = function () {
if (enemy.length) {
let nTrap = gameObjects.find((e) => e.active && 'pit trap' ==
e.name && e.isTeamObject(player) && UTILS.getDistance(e.x, e.y, near.x2, near.y2)
<= 50);
let knocked = 0.3 + (items.weapons[player.weapons[0]].knock ||
0)
let dirs = Math.atan2(
near.y2 - player.y2,
near.x2 - player.x2
)
let iXy = {
x: near.x2 + knocked * Math.cos(dirs) * 224,
y: near.y2 + knocked * Math.sin(dirs) * 224,
}
if (near.dist2 < items.weapons[player.weapons[0]].range + 70 &&
!nTrap && near) {
this.findSpikeHit.x = iXy.x
this.findSpikeHit.y = iXy.y
}
this.findSpikeHit.spikes = gameObjects.filter((e) => e.active
&& e.dmg && e.owner.sid == player.sid && UTILS.getDistance(e.x, e.y, iXy.x, iXy.y)
<= 35 + e.scale)
for (let i = 0; i < this.findSpikeHit.spikes.length; i++) {
let obj = this.findSpikeHit.spikes[i];
if (this.findSpikeHit.canHit) {
instaC.canSpikeTick = true;
instaC.syncHit = true;
if (configs.revTick && player.weapons[1] == 15
&& player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
instaC.revTick = true;
}
}
smartTick(() => {
smartTick(() => {
this.findSpikeHit.spikePosX = 0;
this.findSpikeHit.spikePosY = 0;
this.findSpikeHit.canHit = false;
})
})
}
} else {
this.findSpikeHit.spikePosX = 0;
this.findSpikeHit.spikePosY = 0;
this.findSpikeHit.canHit = false;
}
}
}
}
}
}
function magnitude(vector) {
return Math.hypot(vector.x, vector.y);
}
const predictedPosition = {
x: lastKnownPosition.x + lastKnownPosition.xVel * time,
y: lastKnownPosition.y + lastKnownPosition.yVel * time
};
return predictedPosition;
}
function getEnemyVelocity(near) {
return Math.sqrt(near.xVel * near.xVel + near.yVel * near.yVel);
}
function getEnemyDirection(near) {
return Math.atan2(near.yVel, near.xVel);
}
let packetData = {
place: [],
placeQ: [],
}
class Traps {
constructor(UTILS, items) {
this.dist = 0;
this.aim = 0;
this.inTrap = false;
this.replaced = false;
this.antiTrapped = false;
this.info = {};
this.notFast = function() {
return player.weapons[1] == 10 && ((this.info.health >
items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
}
this.canHit = function() {
const trap1 = gameObjects.filter((e) => e.trap && e.active)
.sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b,
near, 0, 2)).find((trap) => {
const trapDist = Math.sqrt((trap.y - near.y2)**2 + (trap.x -
near.x2)**2);
return (trap !== player && (player.sid === trap.owner.sid ||
player.findAllianceBySid(trap.owner.sid)) && trapDist <= 50);
});
return !trap1;
}
this.cantHit = function() {
const trap1 = gameObjects.filter((e) => e.trap && e.active)
.sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b,
near, 0, 2)).find((trap) => {
const trapDist = Math.sqrt((trap.y - near.y2)**2 + (trap.x -
near.x2)**2);
return (trap !== player && (player.sid === trap.owner.sid ||
player.findAllianceBySid(trap.owner.sid)) && trapDist <= 50);
});
return trap1;
}
gameObjects.forEach((p) => {
tmpObjects.push({
x: p.x,
y: p.y,
active: p.active,
blocker: p.blocker,
scale: p.scale,
isItem: p.isItem,
type: p.type,
colDiv: p.colDiv,
getScale: function(sM, ig) {
sM = sM || 1;
return this.scale * ((this.isItem || this.type == 2
|| this.type == 3 || this.type == 4) ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
}
});
});
// aw
angles.sort((a, b) => {
let distA = UTILS.getDistance(player.x2 + tmpS *
Math.cos(a), player.y2 + tmpS * Math.sin(a), near.x, near.y);
let distB = UTILS.getDistance(player.x2 + tmpS *
Math.cos(b), player.y2 + tmpS * Math.sin(b), near.x, near.y);
return distA - distB;
});
this.checkSpikeTick = function() {
try {
if (![3, 4, 5].includes(near.primaryIndex)) return false;
if ((my.autoPush) ? false : near.primaryIndex == undefined ?
true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
// more range for safe. also testing near.primaryIndex || 5
if (near.dist2 <= items.weapons[near.primaryIndex || 5].range +
(near.scale * 1.8)) {
let item = items.list[9];
let tmpS = near.scale + item.scale + (item.placeOffset ||
0);
let danger = 0;
let counts = {
attempts: 0,
block: `unblocked`
};
for (let i = -1; i <= 1; i += 1 / 10) {
counts.attempts++;
let relAim = UTILS.getDirect(player, near, 2, 2) + i;
let tmpX = near.x2 + tmpS * Math.cos(relAim);
let tmpY = near.y2 + tmpS * Math.sin(relAim);
let cantPlace = liztobj.find((tmp) => tmp.active &&
UTILS.getDistance(tmpX, tmpY, tmp.x, tmp.y) < item.scale + (tmp.blocker ?
tmp.blocker : tmp.getScale(0.6, tmp.isItem)));
if (cantPlace) continue;
if (tmpY >= config.mapScale / 2 - config.riverWidth / 2
&& tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
danger++;
counts.block = `blocked`;
break;
}
if (danger) {
my.anti0Tick = 1;
return true;
}
}
} catch (err) {
return null;
}
return false;
}
function getDist(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;
}
}
this.nearTrap = function () {
return gameObjects.filter(object => object.trap && object.active &&
UTILS.getDist(object, player, 0, 2) <= (player.scale + object.getScale() + 5));
};
this.isEnemyInTrap = function(enemy) {
let nearTraps = this.nearTrap();
return nearTraps.some(trap => UTILS.getDist(trap, enemy, 0, 2) <=
(trap.getScale() + near.scale));
};
this.autoPlace = function () {
let randomDir = Math.random() * Math.PI * 2;
if (enemy.length && configs.autoPlace && !instaC.ticking) {
if (game.tick % (Math.max(1,
parseInt(getEl("autoPlaceTick").value))||1) === 0) {
if (gameObjects.length) {
let near2 = {
inTrap: false,
};
let nearTrap = gameObjects.filter(e => e.trap &&
e.active && e.isTeamObject(player) && UTILS.getDist(e, near, 0, 2) <= (near.scale +
e.getScale() + 5)).sort(function (a, b) {
return UTILS.getDist(a, near, 0, 2) -
UTILS.getDist(b, near, 0, 2);
})[0];
if (nearTrap) {
near2.inTrap = true;
} else {
near2.inTrap = false;
}
if (near.dist2 <= 450) {
if (near.dist2 <= 200) {
this.CanPlace(2, Math.PI / 24, near.aim2, 0,
{inTrap: near2.inTrap});
} else {
this.CanPlace(4, Math.PI / 24, near.aim2);
}
}
} else {
if (near.dist2 <= 450) {
this.CanPlace(4, Math.PI / 24, near.aim2);
}
}
}
}
};
this.replacer2 = function (findObj) {
if (!findObj || !configs.autoReplace) return;
if (!inGame) return;
if (this.antiTrapped) return;
game.tickBase(() => {
this.angles.push(predictedAngle);
if (this.angles.length > 5) {
this.angles.shift();
}
smoothedAngle += preAngleAmount;
isItemSetted[22].innerHTML != 99 &&
this.testCanPlace(2, ifOther, ifOther + Math.PI * 2, Math.PI / 24, objAim, 1);
this.angles.push(predictedAngle);
if (this.angles.length > 5) {
this.angles.shift();
}
smoothedAngle += preAngleAmount;
}
};
function nextIStank() {
return new Promise(resolve => {
game.tickBase(() => {
const skinIndex = near.skinIndex;
const isSkin40 = near.skins[40];
const isReloadsNotOne = near.reloads[near.weapons[1]] !== 1;
const isSkinIndexValid = skinIndex === 6 || skinIndex === 22 ||
(near.oldSkinIndex == 40 && skinIndex == 6);
selectWeapon(player.weapons[[15].includes(player.weapons[1]) ? 1 : 0]);
buyEquip(53, 0);
buyEquip(19, 1);
if ([15].includes(player.weapons[1])) {
sendAutoGather();
}
packet("9", near.aim2, 1);
game.tickBase(() => {
my.revAim = false;
selectWeapon(player.weapons[0]);
buyEquip(7, 0);
buyEquip(19, 1);
if (![15].includes(player.weapons[1])) {
sendAutoGather();
}
packet("9", near.aim2, 1);
game.tickBase(() => {
sendAutoGather();
this.isTrue = false;
my.autoAim = false;
packet("9", undefined, 1);
this.readyTick = false;
}, 3);
}, 1);
}, 1);
};
this.threeOneTickType = function() {
this.isTrue = true;
my.autoAim = true;
selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 :
0]);
biomeGear();
buyEquip(19, 1);
packet("9", near.aim2, 1);
game.tickBase(() => {
selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ?
1 : 0]);
buyEquip(53, 0);
buyEquip(19, 1);
packet("9", near.aim2, 1);
game.tickBase(() => {
selectWeapon(player.weapons[0]);
buyEquip(7, 0);
buyEquip(19, 1);
sendAutoGather();
packet("9", near.aim2, 1);
game.tickBase(() => {
sendAutoGather();
this.isTrue = false;
my.autoAim = false;
packet("9", undefined, 1);
}, 1);
}, 1);
}, 1);
};
this.kmTickType = function() {
this.isTrue = true;
my.autoAim = true;
my.revAim = true;
selectWeapon(player.weapons[1]);
buyEquip(53, 0);
buyEquip(19, 1);
sendAutoGather();
packet("9", near.aim2, 1);
game.tickBase(() => {
my.revAim = false;
selectWeapon(player.weapons[0]);
buyEquip(7, 0);
buyEquip(19, 1);
packet("9", near.aim2, 1);
game.tickBase(() => {
sendAutoGather();
this.isTrue = false;
my.autoAim = false;
packet("9", undefined, 1);
}, 1);
}, 1);
};
this.boostTickType = function() {
this.isTrue = true;
my.autoAim = true;
biomeGear();
buyEquip(11, 1);
packet("9", near.aim2, 1);
game.tickBase(() => {
if (player.weapons[1] == 15) {
my.revAim = true;
}
selectWeapon(player.weapons[[9, 12, 13,
15].includes(player.weapons[1]) ? 1 : 0]);
buyEquip(53, 0);
buyEquip(11, 1);
if ([9, 12, 13, 15].includes(player.weapons[1])) {
sendAutoGather();
}
packet("9", near.aim2, 1);
place(4, near.aim2);
game.tickBase(() => {
my.revAim = false;
selectWeapon(player.weapons[0]);
buyEquip(7, 0);
buyEquip(19, 1);
if (![9, 12, 13, 15].includes(player.weapons[1])) {
sendAutoGather();
}
packet("9", near.aim2, 1);
game.tickBase(() => {
sendAutoGather();
this.isTrue = false;
my.autoAim = false;
packet("9", undefined, 1);
}, 1);
}, 1);
}, 1);
};
this.gotoGoal = function(goto, OT) {
const slowDists = (weeeee) => weeeee * config.playerScale;
const goal = {
a: goto - OT,
b: goto + OT,
c: goto - slowDists(1),
d: goto + slowDists(1),
e: goto - slowDists(2),
f: goto + slowDists(2),
g: goto - slowDists(4),
h: goto + slowDists(4)
};
if (enemy.length) {
const dst = near.dist2;
this.ticking = true;
if (isNear) {
if (isSlow) {
biomeGear();
bQ(19, dst < goal.a ? 0 : 1);
} else {
bQ(6, 0);
bQ(21, dst < goal.a ? 0 : 1);
}
selectWeapon(player.weapons[[10,
14].includes(player.weapons[1]) ? 1 : 0]);
return { dir: near.aim2 + (dst < goal.a ? Math.PI : 0),
action: 0 };
}
class Damages {
constructor(items) {
// 0.75 1 1.125 1.5
this.calcDmg = function(dmg, val) {
return dmg * val;
};
this.getAllDamage = function(dmg) {
return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125),
this.calcDmg(dmg, 1.5)];
};
this.weapons = [];
for (let i = 0; i < items.weapons.length; i++) {
let wp = items.weapons[i];
let name = wp.name.split(" ").length <= 1 ? wp.name :
(wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
this[name] = this.weapons[i];
}
}
}
// LOADING:
let UTILS = new Utils();
let items = new Items();
let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
let store = new Store();
let hats = store.hats;
let accessories = store.accessories;
let projectileManager = new ProjectileManager(Projectile, projectiles, players,
ais, objectManager, items, config, UTILS);
let aiManager = new AiManager(ais, AI, players, items, Volcano, config, UTILS);
let textManager = new Textmanager();
let lastDeath;
let minimapData;
let mapMarker = {};
let mapPings = [];
let tmpPing;
function sendChat(message) {
packet("6", message.slice(0, 30));
}
} else if (isWeapon) {
UTILS.generateElement({
class: "itemInfoReq",
text: !item.type ? "primary" : "secondary",
parent: itemInfoHolder
});
} else {
for (let i = 0; i < item.req.length; i += 2) {
UTILS.generateElement({
class: "itemInfoReq",
html: item.req[i] + "<span class='itemInfoReqVal'> x" +
item.req[i + 1] + "</span>",
parent: itemInfoHolder
});
}
if (item.group.limit) {
UTILS.generateElement({
class: "itemInfoLmt",
text: (player.itemCounts[item.group.id] || 0) + "/" +
(config.isSandbox ? 99 : item.group.limit),
parent: itemInfoHolder
});
}
}
} else {
itemInfoHolder.classList.remove("visible");
}
}
// RESIZE:
window.addEventListener("resize", UTILS.checkTrusted(resize));
function resize() {
screenWidth = window.innerWidth;
screenHeight = window.innerHeight;
let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight /
maxScreenHeight) * pixelDensity;
gameCanvas.width = screenWidth * pixelDensity;
gameCanvas.height = screenHeight * pixelDensity;
gameCanvas.style.width = screenWidth + "px";
gameCanvas.style.height = screenHeight + "px";
be.setTransform(
scaleFillNative, 0,
0, scaleFillNative,
(screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
(screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
);
}
resize();
// MOUSE INPUT:
var usingTouch;
const mals = document.getElementById('touch-controls-fullscreen');
mals.style.display = 'block';
mals.addEventListener("mousemove", gameInput, false);
function gameInput(e) {
mouseX = e.clientX;
mouseY = e.clientY;
}
let clicks = {
left: false,
middle: false,
right: false,
};
mals.addEventListener("mousedown", mouseDown, false);
function mouseDown(e) {
if (attackState != 1) {
attackState = 1;
if (e.button == 0) {
clicks.left = true;
} else if (e.button == 1) {
clicks.middle = true;
} else if (e.button == 2) {
clicks.right = true;
}
}
}
mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
function mouseUp(e) {
if (attackState != 0) {
attackState = 0;
if (e.button == 0) {
clicks.left = false;
} else if (e.button == 1) {
clicks.middle = false;
} else if (e.button == 2) {
clicks.right = false;
}
}
}
mals.addEventListener("wheel", wheel, false);
let wbe = 1;
let mWbe = 1;
let smothAnim = null;
if (smothAnim) clearInterval(smothAnim);
smothAnim = setInterval(() => {
wbe += (mWbe - wbe) * 0.1;
maxScreenWidth = config.maxScreenWidth * wbe;
maxScreenHeight = config.maxScreenHeight * wbe;
resize();
if (Math.abs(mWbe - wbe) < 0.01) {
clearInterval(smothAnim);
}
}, 15);
}
// INPUT UTILS:
function getMoveDir() {
let dx = 0;
let dy = 0;
for (let key in moveKeys) {
let tmpDir = moveKeys[key];
dx += !!keys[key] * tmpDir[0];
dy += !!keys[key] * tmpDir[1];
}
return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
}
// Help Dirs:
let checkDist = 40;
function SpikeDir() {
let spike;
if (traps.inTrap) {
spike = gameObjects.filter(tmp => (tmp.dmg) && tmp.active && !
tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (tmp.scale + 40 +
player.scale)).sort(function(a, b) {
return UTILS.getDist(a, player, 0, 5) - UTILS.getDist(b, player, 0,
5);
})[0];
} else {
spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && !
tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (tmp.scale +
checkDist + player.scale)).sort(function(a, b) {
return UTILS.getDist(a, player, 0, 5) - UTILS.getDist(b, player, 0,
5);
})[0];
}
if (spike) {
let aim = UTILS.getDirect(spike, player, 0, 2);
return aim;
} else {
return (traps.inTrap ? traps.aim : lastDir || 0);
}
}
function getSafeDir() {
if (!player) return 0;
if (!player.lockDir) {
lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth
/ 2));
}
return lastDir || 0;
}
function getAttackDir() {
if (!player) return "0";
return lastDir;
}
function getVisualDir() {
if (!player) return 0;
lastDir = getSafeDir();
return lastDir || 0;
}
// KEYS:
function keysActive() {
return (allianceMenu.style.display != "block" && chatHolder.style.display !
= "block" && !menuCBFocus);
}
function toggleMenuChat() {
if (menuChatDiv.style.display != "none") {
let cmd = function(command) {
return {
found: command.startsWith("/") &&
commands[command.slice(1).split(" ")[0]],
fv: commands[command.slice(1).split(" ")[0]]
}
}
let command = cmd(menuChatBox.value);
if (command.found) {
if (typeof command.fv.action === "function") {
command.fv.action(menuChatBox.value);
}
} else {
sendChat(menuChatBox.value);
}
menuChatBox.value = "";
menuChatBox.blur();
} else {
if (menuCBFocus) {
menuChatBox.blur();
} else {
menuChatBox.focus();
}
}
}
function keyDown(event) {
let keyNum = event.which || event.keyCode || 0;
if (player && player.alive && keysActive()) {
if (!keys[keyNum]) {
keys[keyNum] = 1;
macro[event.key] = 1;
if (keyNum == 27) {
openMenu = !openMenu;
$("#menuDiv").toggle();
$("#menuChatDiv").toggle();
$("#infosMenus").toggle();
$("#mapDisplay").toggle();
} else if (keyNum == 69) {
sendAutoGather();
} else if (keyNum == 66) {
instaC.syncTry();
} else if (keyNum == 67) {
updateMapMarker();
} else if (player.weapons[keyNum - 49] != undefined) {
player.weaponCode = player.weapons[keyNum - 49];
} else if (moveKeys[keyNum]) {
sendMoveDir();
} else if (event.key == "0") {
io.send("6", "snoweiv3.1415926535897")
} else if (event.key == "C") {
syncChat(getEl("songs").value);
} else if (event.key == "/") {
resetMenuChText();
typeof window.debug == "function" && window.debug();
io.send("6", "Success Reset Chat / Debug")
} else if (event.key == "m") {
mills.placeSpawnPads = !mills.placeSpawnPads;
} else if (event.key == "z") {
mills.place = !mills.place;
} else if (event.key == "Z") {
typeof window.debug == "function" && window.debug();
} else if (keyNum == 32) {
packet("F", 1, getSafeDir(), 1);
packet("F", 0, getSafeDir(), 1);
}
}
}
}
// let xx = canvaz.width/2;
// let yy = canvaz.height/2;
// let mouze = {
// x: xx - mouzeX,
// y: yy - mouzeY
// }
// let ingamecoorformodabow = {
// x: player.x + mouze.x,
// y: player.x + mouze.x
// }
addEventListener("keydown", UTILS.checkTrusted(keyDown));
function keyUp(event) {
if (player && player.alive) {
let keyNum = event.which || event.keyCode || 0;
if (keyNum == 13) {
toggleMenuChat();
} else if (keysActive()) {
if (keys[keyNum]) {
keys[keyNum] = 0;
macro[event.key] = 0;
if (moveKeys[keyNum]) {
sendMoveDir();
}
}
}
}
}
window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
function sendMoveDir() {
if(found) {
packet("9", undefined, 1);
} else {
let newMoveDir = getMoveDir();
if (lastMoveDir == undefined || newMoveDir == undefined ||
Math.abs(newMoveDir - lastMoveDir) > 0.3) {
if (!my.autoPush && !found) {
packet("9", newMoveDir, 1);
}
lastMoveDir = newMoveDir;
}
}
}
function chechPathColl(tmp) {
return ((player.scale + tmp.getScale()) / (player.maxSpeed *
items.weapons[player.weaponIndex].spdMult)) + (tmp.dmg && !tmp.isTeamObject(player)
? 35 : 0);
return tmp.colDiv == 0.5 ? (tmp.scale * tmp.colDiv) :
!tmp.isTeamObject(player) && tmp.dmg ? (tmp.scale + player.scale) :
tmp.isTeamObject(player) && tmp.trap ? 0 : tmp.scale;
}
function CanObject(pos, one, two) {
let checkColl = gameObjects.filter(tmp => player.canSee(tmp) &&
tmp.active);
for (let y = 0; y < pathFind.grid; y++) {
grid[y] = [];
for (let x = 0; x < pathFind.grid; x++) {
let tmpXY = {
x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale /
pathFind.grid) * x),
y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale /
pathFind.grid) * y)
}
if (UTILS.getDist(pos, tmpXY, one, two) <= 35) {
pathFind.lastX = x;
pathFind.lastY = y;
grid[y][x] = 0;
continue;
}
let find = checkColl.find(tmp => UTILS.getDist(tmp, tmpXY, 0, 0) <=
chechPathColl(tmp));
if (find) {
if (find.trap) {
grid[y][x] = 0;
continue;
}
grid[y][x] = 1;
} else {
grid[y][x] = 0;
}
}
}
}
function SendPath(pos, one, two) {
grid = [];
CanObject(pos, one, two);
}
let CheckAim = near.aim2, CheckDist = near.dist2;
function Move() {
const trap1 = gameObjects
.filter((e) => e.trap && e.active)
.sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0,
2))
.find((trap) => {
const trapDist = Math.sqrt((trap.y - near.y2)**2 + (trap.x -
near.x2)**2);
return (
trap !== player &&
(player.sid === trap.owner.sid ||
player.findAllianceBySid(trap.owner.sid)) &&
trapDist <= 50
);
});
if (near.dist2 > items.weapons[player.weapons[0]].range + near.scale * 1.8)
{
if (((player.shameCount > 5) || player.skinIndex == 45) && CheckDist <
400) {
packet("9", CheckAim + Math.PI, 1);
} else if (CheckDist <= items.weapons[player.weaponIndex].range +
near.scale && trap1) {
packet("9", undefined, 1);
} else if(!trap1 && CheckDist < items.weapons[player.weaponIndex].range
+ near.scale * 1.8){
packet("9", CheckAim + Math.PI, 1);
} else if(CheckDist >= items.weapons[player.weaponIndex].range +
near.scale * 1.8){
packet("9", CheckAim, 1);
} else {
packet("9", undefined, 1);
}
}
}
function Pathfinder(pos, one, two) {
pathFind.scale = (config.maxScreenWidth / 2) * 1.3;
if (!traps.inTrap) {
if (((CheckDist <= items.weapons[player.weapons[0]].range + near.scale
* 1.8) || player.skinIndex == 45 || player.shameCount > 6)) {
Move();
} else {
SendPath(pos, one, two);
easystar.setGrid(grid);
easystar.setAcceptableTiles([0]);
easystar.enableDiagonals();
easystar.findPath((grid[0].length / 2), (grid.length / 2),
pathFind.lastX, pathFind.lastY, function(path) {
if (path === null) {
pathFind.array = [];
Move();
} else {
pathFind.array = path;
if (pathFind.array.length > 1) {
let tmpXY = {
x: (player.x2 - (pathFind.scale / 2)) +
((pathFind.scale / pathFind.grid) * path[1].x),
y: (player.y2 - (pathFind.scale / 2)) +
((pathFind.scale / pathFind.grid) * path[1].y)
}
io.send("9", UTILS.getDirect(tmpXY, player, 0, 2), 1);
}
}
});
easystar.calculate();
}
}
}
const spiralRadius = 2;
const spiralSpeed = 0.09;
return {
x: combinedX,
y: combinedY,
x2: spike.x + (distanceToSpike + enemy.scale) * Math.cos(angleToSpike),
y2: spike.y + (distanceToSpike + enemy.scale) * Math.sin(angleToSpike),
};
}
// AUTOPUSH:
let CheckCactus = false, PushCactus = false, RealPush = false;
function autoPush() {
let nearTrap = gameObjects.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) {
let isEnemySpikes = gameObjects.some(tmp => tmp.dmg && tmp.active && !
tmp.isTeamObject(player) && UTILS.getDist(tmp, nearTrap, 0, 0) <= (near.scale +
nearTrap.scale + tmp.scale + 5));
if (isEnemySpikes) {
RealPush = false;
pathFind.active = false;
if (my.autoPush) {
my.autoPush = false;
packet("9", lastMoveDir||undefined, 1);
}
return;
}
let spike = gameObjects.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];
if (spike) {
let pos = calculatePushPosition(nearTrap, near);
let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
let tmpScale = tmp.getScale();
if (!tmp.ignoreCollision && UTILS.lineInRect(tmp.x - tmpScale,
tmp.y - tmpScale, tmp.x + tmpScale, tmp.y + tmpScale, player.x2, player.y2, pos.x2,
pos.y2)) {
return true;
}
});
if (finds) {
if (my.autoPush) {
my.autoPush = false;
packet("9", lastMoveDir||undefined, 1);
}
RealPush = false;
pathFind.active = true;
Pathfinder(near, 2, 0);
} else {
RealPush = true;
my.autoPush = true;
my.pushData = {
x: spike.x,
y: spike.y,
x2: pos.x2,
y2: pos.y2
};
function renderCactus(_) {
const biomeID = (_.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((_.y
<= config.snowBiomeTop) ? 1 : 0);
if (player && _.type === 1 && biomeID == 2 && !pathFind.active) {
let CactusDist = UTILS.getDist(_, player, 0, 2), getCactus =
UTILS.getDirect(_, player, 0, 2);
const Ping = window.pingTime >= 90 ? 2 : 1.8, MoveDir = getMoveDir();
if (CactusDist <= 200 && !MoveDir) {
CheckCactus = true;
if (CactusDist < 150) {
packet("9", getCactus + Math.PI, 1);
} else if (CactusDist >= 150) {
packet("9", getCactus, 1);
}
}
} else {
CheckCactus = false;
}
}
function pushCactus(_) {
const biomeID = (_.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((_.y
<= config.snowBiomeTop) ? 1 : 0);
if (player && _.type === 1 && biomeID == 2) {
const FindTrap = gameObjects
.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) &&
UTILS.getDist(tmp, near, 0, 2) <= near.scale + tmp.getScale() + 5)
.sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near,
0, 2))[0];
if (FindTrap) {
if (UTILS.getDist(FindTrap, near, 0, 2) <= near.scale +
FindTrap.scale + _.scale && UTILS.getDist(_, near, 0, 2) <= player.scale + _.scale
+ near.scale) {
PushCactus = true;
const pushDistance = 250;
const pushAngle = UTILS.getDirect(near, _, 2, 0);
const pushDist = UTILS.getDist(near, _, 2, 0);
const pos = {
x: _.x + pushDistance * Math.cos(pushAngle),
y: _.y + pushDistance * Math.sin(pushAngle),
x2: _.x + (pushDist + player.scale * 1.5) *
Math.cos(pushAngle),
y2: _.y + (pushDist + player.scale * 1.5) *
Math.sin(pushAngle),
};
if (UTILS.getDist(_, near, 0, 3) <= (_.scale + near.scale) &&
(near.dist2 <= items.weapons[player.weapons[0]].range + player.scale * 1.8) &&
near.health < 100) {
instaC.canSpikeTick = true;
}
my.autoPush = true;
if (near.dist2 <= items.weapons[player.weapons[0]].range +
player.scale + (near.scale * 1.8)) {
pathFind.active = false;
if (UTILS.getDist(near, _, 2, 0) <= 100 && near.health !=
100 && near.dist2 <= 150) {
my.pushLine = Infinity;
} else {
my.pushLine = {
x: _.x,
y: _.y,
x2: pos.x2,
y2: pos.y2
};
}
if (UTILS.getDist(near, _, 2, 0) <= 100 && near.health !=
100 && near.dist2 <= 150) {
packet("9", undefined, 1);
} else {
packet("9", UTILS.getDirect(pos, player, 2, 2), 1);
}
} else {
pathFind.active = true;
Pathfinder(near, 2, 0);
}
} else {
PushCactus = false;
if (my.autoPush) {
my.autoPush = false;
packet("9", undefined, 1);
}
}
} else {
PushCactus = false;
if (my.autoPush) {
my.autoPush = false;
packet("9", undefined, 1);
}
}
}
}
// SETUP GAME:
function setupGame(yourSID) {
keys = {};
macro = {};
playerSID = yourSID;
attackState = 0;
inGame = true;
packet("F", 0, getAttackDir(), 1);
my.ageInsta = true;
if (firstSetup) {
firstSetup = false;
gameObjects.length = 0;
liztobj.length = 0;
}
}
// REMOVE PLAYER:
function removePlayer(id) {
for (let i = 0; i < players.length; i++) {
if (players[i].id == id) {
addMenuChText("Game", players[i].name + "[" + players[i].sid + "]
left the game", "red");
players.splice(i, 1);
break;
}
}
}
// UPDATE HEALTH:
var judgeAtNextTick = false;
let hittedTime = Date.now();
function updateHealth(sid, value) {
_ = findPlayerBySID(sid);
let secondary = {
weapon: this.secondaryIndex,
variant: this.secondaryVariant
};
let tmpHealth = _.health;
if (_) {
_.oldHealth = _.health;
_.health = value;
_.judgeShame();
if (_.oldHealth > _.health) {
if (_ == near) {
let damage = _.oldHealth - _.health;
if (_.skinIndex == 7 && (damage == 5 || (_.latestTail == 13 &&
damage == 2))) {
_.bullTick = game.tick;
}
}
_.damaged = _.oldHealth - _.health;
let damaged = _.damaged;
_ = findPlayerBySID(sid);
let bullTicked = false;
if (value >= 20) {
hittedTime = Date.now();
judgeAtNextTick = true;
}
if (near.antiBull > 0 && player.shameCount < 5) {
place(0, getAttackDir(), 0, false);
}
if (_.health <= 0) {
if (!_.death) {
_.death = true;
addDeadPlayer(_);
}
}
if (_ == player) {
if (_.skinIndex == 7 && (damaged == 5 || (_.latestTail == 13 &&
damaged == 2))) {
if (my.reSync) {
my.reSync = false;
_.setBullTick = true;
}
bullTicked = true;
}
if (inGame) {
const AKH = player.skinIndex != 6 || near.tailIndex == 21
|| (near.weaponIndex == 5 && near.primaryVariant >= 2) ? near.weaponIndex == 7 ? 35
: 8 : 20;
const AP = near.weaponIndex == 7 ? 35 : near.weaponIndex ==
5 && near.primaryVariant >= 2 ? 15 : 20;
CanPAB = (player.damageThreat > 95) ? true : false;
// Pab
if (damaged > 10 && AntiBull && (traps.canHit() ||
clicks.middle) && (player.tailIndex == 21 || player.skinIndex == 11) && CanPAB) {
instaC.canCounter = true;
} else {
if (_ == player) {
if (damaged <= 30 && near.skinIndex == 11 &&
near.weapons[0] != 8 && near.weapons[0] != 7 && near.weapons[1] != 9 &&
near.skinIndex == 11 && player.reloads[player.weapons[0]] != 0) {
instaC.canAntiCounter = true;
}
}
}
}
} else {
if (!_.setPoisonTick && (_.damaged == 5 || (_.latestTail == 13
&& _.damaged == 2))) {
_.setPoisonTick = true;
}
}
} else {
if (_ != player) {
if (_.maxShameCount < _.shameCount) {
_.maxShameCount = _.shameCount;
}
}
}
}
if (nears.length && _.shameCount <= 5 && nears.some(items => [9, 12, 13,
15].includes(secondary.weapon))) {
if (near.reloads[near.secondaryIndex] == 0) {
my.empAnti = true;
my.soldierAnti = false;
} else {
my.soldierAnti = true
my.empAnti = false;
}
}
}
// KILL PLAYER:
function killPlayer() {
inGame = false;
lastDeath = {
x: player.x,
y: player.y,
};
if (configs.autoRespawn) {
getEl("diedText").style.display = "none";
packet("M", {
name: lastsp[0],
moofoll: lastsp[1],
skin: lastsp[2]
});
}
}
// UPDATE AGE:
function updateAge(xp, mxp, age) {
if (xp != undefined) player.XP = xp;
if (mxp != undefined) player.maxXP = mxp;
if (age != undefined) player.age = age;
}
// UPDATE UPGRADES:
function updateUpgrades(points, age) {
player.upgradePoints = points;
player.upgrAge = age;
if (points > 0) {
tmpList.length = 0;
UTILS.removeAllChildren(upgradeHolder);
for (let i = 0; i < items.weapons.length; ++i) {
if (items.weapons[i].age == age && (items.weapons[i].pre ==
undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
let e = UTILS.generateElement({
id: "upgradeItem" + i,
class: "actionBarItem",
onmouseout: function() {
showItemInfo();
},
parent: upgradeHolder
});
e.style.backgroundImage = getEl("actionBarItem" +
i).style.backgroundImage;
tmpList.push(i);
}
}
for (let i = 0; i < items.list.length; ++i) {
if (items.list[i].age == age && (items.list[i].pre == undefined ||
player.items.indexOf(items.list[i].pre) >= 0)) {
let tmpI = (items.weapons.length + i);
let e = UTILS.generateElement({
id: "upgradeItem" + tmpI,
class: "actionBarItem",
onmouseout: function() {
showItemInfo();
},
parent: upgradeHolder
});
e.style.backgroundImage = getEl("actionBarItem" +
tmpI).style.backgroundImage;
tmpList.push(tmpI);
}
}
for (let i = 0; i < tmpList.length; i++) {
(function(i) {
let tmpItem = getEl('upgradeItem' + i);
tmpItem.onclick = UTILS.checkTrusted(function() {
packet("H", i);
});
UTILS.hookTouchEvents(tmpItem);
})(tmpList[i]);
}
if (tmpList.length) {
upgradeHolder.style.display = "block";
} else {
upgradeHolder.style.display = "none";
showItemInfo();
}
} else {
upgradeHolder.style.display = "none";
showItemInfo();
}
}
// KILL OBJECT:
function killObject(sid) {
let findObj = findObjectBySid(sid);
objectManager.disableBySid(sid);
if (player) {
if (!player.canSee(findObj)) {
breakTrackers.push({
x: findObj.x,
y: findObj.y
});
}
if (breakTrackers.length > 8) {
breakTrackers.shift();
}
if (getEl("testReplace2").checked) {
traps.testReplacer(findObj);
} else {
traps.replacer(findObj);
}
}
let enemy = near;
let A = player;
let dist = cdf(A, enemy);
let dir = caf(A, enemy);
//code of bianos
let objAim = Math.atan2(findObj.y-player.y2, findObj.x-player.x2);
let objDist = Math.hypot(findObj.y-player.y2, findObj.x-player.x2);
//
let ignore = [0, 0];
let place = function(t, f) {
checkPlace(t, f);
}
}
function caf(e, t) {
try {
return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2
|| e.x));
} catch (e) {
return 0;
}
}
let autos = {
insta: {
todo: false,
wait: false,
count: 4,
shame: 5
},
bull: false,
antibull: 0,
reloaded: false,
stopspin: true
}
setInterval(() => {
if (config.isSandbox) {
if (configs.prePlace && !instaC.instaTrue && near.dist2 <= 300 && !
getEl("weaponGrind").checked) {
traps.PrePlace();
}
}
}, 60);
let tracker = {
spin: {
active: false,
noHits: false,
},
draw3: {
active: false,
x: 0,
y: 0,
scale: 0,
},
moveDir: undefined,
lastPos: {
x: 0,
y: 0,
}
}
// Avoid Spike:
function clicksRight() {
selectWeapon(player.weapons[1] == 10 ? player.weapons[1] :
player.weapons[0]);
if (player.reloads[player.weapons[1] == 10 ? player.weapons[1] :
player.weapons[0]] == 0 && !my.waitHit) {
buyEquip(40, 0);
sendAutoGather();
buyEquip(40, 0);
my.waitHit = 1;
game.tickBase(() => {
if (my.anti0Tick > 0) {
buyEquip(6, 0);
}
sendAutoGather();
my.waitHit = 0;
}, 1);
}
buyEquip(21, 1);
};
function AvoidingSpikes() {
if (!configs.avoidSpike) return;
// Avoid Spike:
if (true) {
game.tickBase(() => {
handleMovement();
handleMovement(1);
}, 1);
}
// Break Spikes:
if (true) {
let spike = gameObjects.filter(tmp => (tmp.dmg) && tmp.active && !
tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (tmp.scale + 40 +
player.scale)).sort(function(a, b) {
return UTILS.getDist(a, player, 0, 5) - UTILS.getDist(b, player, 0,
5);
})[0];
if (spike) {
tracker.draw3.x = spike.x
tracker.draw3.y = spike.y
tracker.draw3.scale = spike.scale
if (!clicks.right && !clicks.left && !instaC.canSpikeTick && !
instaC.canCounter) {
my.spikeAim = true;
tracker.draw3.active = true;
clicksRight();
} else {
if (my.spikeAim || tracker.draw3.active) {
my.spikeAim = false;
tracker.draw3.active = false;
}
}
} else {
if (my.spikeAim || tracker.draw3.active) {
my.spikeAim = false;
tracker.draw3.active = false;
}
}
} else {
if (my.spikeAim || tracker.draw3.active) {
my.spikeAim = false;
tracker.draw3.active = false;
}
}
};
// n ti:
// UPDATE PLAYER DATA:
function updatePlayers(data) {
game.tick++;
enemy = [];
nears = [];
near = [];
game.tickSpeed = performance.now() - game.lastTick;
game.lastTick = performance.now();
players.forEach((tmp) => {
tmp.forcePos = !tmp.visible;
tmp.visible = false;
if((tmp.timeHealed - tmp.timeDamaged)>0 &&
tmp.lastshamecount<tmp.shameCount) tmp.pinge = (tmp.timeHealed - tmp.timeDamaged);
});
for (let i = 0; i < data.length;) {
_ = findPlayerBySID(data[i]);
if (_) {
_.t1 = (_.t2 === undefined) ? game.lastTick : _.t2;
_.t2 = game.lastTick;
_.oldPos.x2 = _.x2;
_.oldPos.y2 = _.y2;
_.x1 = _.x;
_.y1 = _.y;
_.x2 = data[i + 1];
_.y2 = data[i + 2];
_.x3 = _.x2 + (_.x2 - _.oldPos.x2);
_.y3 = _.y2 + (_.y2 - _.oldPos.y2);
_.deathDir = caf({
x: player.x3,
y: player.y3
}, {
x: player.oldPos.x2,
y: player.oldPos.y2
}) - Math.PI;
_.d1 = (_.d2 === undefined) ? data[i + 3] : _.d2;
_.d2 = data[i + 3];
_.dt = 0;
_.buildIndex = data[i + 4];
_.weaponIndex = data[i + 5];
_.weaponVariant = data[i + 6];
_.team = data[i + 7];
_.isLeader = data[i + 8];
_.oldSkinIndex = _.skinIndex;
_.oldTailIndex = _.tailIndex;
_.skinIndex = data[i + 9];
_.tailIndex = data[i + 10];
_.iconIndex = data[i + 11];
_.zIndex = data[i + 12];
_.visible = true;
_.update(game.tickSpeed);
_.dist2 = UTILS.getDist(_, player, 2, 2);
_.aim2 = UTILS.getDirect(_, player, 2, 2);
_.dist3 = UTILS.getDist(_, player, 3, 3);
_.aim3 = UTILS.getDirect(_, player, 3, 3);
_.damageThreat = 0;
if (_.skinIndex == 45 && _.shameTimer <= 0) {
_.addShameTimer();
}
if (_.oldSkinIndex == 45 && _.skinIndex != 45) {
_.shameTimer = 0;
_.shameCount = 0;
if (_ == player) {
healer();
}
}
if (_ == player) {
if (liztobj.length) {
let nearTrap = liztobj.filter(e => e.trap && e.active &&
UTILS.getDist(e, _, 0, 2) <= (_.scale + e.getScale() + 25) && !
e.isTeamObject(_)).sort(function(a, b) {
return UTILS.getDist(a, _, 0, 2) - UTILS.getDist(b, _,
0, 2);
})[0];
if (nearTrap) {
let spike = gameObjects.filter(obj => obj.dmg && cdf(_,
obj) <= _.scale + nearTrap.scale/2 && !obj.isTeamObject(_) && obj.active)[0]
traps.dist = UTILS.getDist(nearTrap, _, 0, 2);
traps.aim = UTILS.getDirect(spike ? spike : nearTrap,
_, 0, 2);
if (detect.reverse) {
detect.reverse = false;
}
if (detect.onetick) {
detect.onetick = false;
}
if (detect.barbarian) {
detect.barbarian = false;
}
if (player.empAnti) {
player.empAnti = false;
}
if (player.soldierAnti) {
player.soldierAnti = false;
}
if (my.anti0Tick > 0) {
my.anti0Tick--;
}
if (instaC.ticking) {
instaC.ticking = false;
}
if (instaC.syncHit) {
instaC.syncHit = false;
}
if (traps.replaced) {
traps.replaced = false;
}
if (traps.antiTrapped) {
traps.antiTrapped = false;
}
}
}
}
// UPDATE LEADERBOARD:
const leaderboardElement = document.getElementById('leaderboard');
const textNode = leaderboardElement.firstChild;
if (textNode.nodeType === 3 && textNode.textContent === 'Leaderboard') {
leaderboardElement.removeChild(textNode);
}
function updateLeaderboard(data) {
lastLeaderboardData = data;
UTILS.removeAllChildren(leaderboardData);
let tmpC = 1;
let maxScore = data[2];
for (let i = 0; i < data.length; i += 3) {
(function(i) {
let score = data[i + 2];
let percentage = (score / maxScore) * 100;
// ADD AI:
function loadAI(data) {
for (let i = 0; i < ais.length; ++i) {
ais[i].forcePos = !ais[i].visible;
ais[i].visible = false;
}
if (data) {
let tmpTime = performance.now();
for (let i = 0; i < data.length;) {
_ = findAIBySID(data[i]);
if (_) {
_.index = data[i + 1];
_.t1 = (_.t2 === undefined) ? tmpTime : _.t2;
_.t2 = tmpTime;
_.x1 = _.x;
_.y1 = _.y;
_.x2 = data[i + 2];
_.y2 = data[i + 3];
_.d1 = (_.d2 === undefined) ? data[i + 4] : _.d2;
_.d2 = data[i + 4];
_.health = data[i + 5];
_.dt = 0;
_.visible = true;
} else {
_ = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4],
data[i + 1]);
_.x2 = _.x;
_.y2 = _.y;
_.d2 = _.dir;
_.health = data[i + 5];
if (!aiManager.aiTypes[data[i + 1]].name) _.name =
config.cowNames[data[i + 6]];
_.forcePos = true;
_.sid = data[i];
_.visible = true;
}
i += 7;
}
}
}
// ANIMATE AI:
function animateAI(sid) {
_ = findAIBySID(sid);
if (_) _.startAnim();
}
// GATHER ANIMATION:
let detect = {
insta: false,
reverse: false,
onetick: false,
spiketick: false,
barbarian: false,
antibull: false,
antibullhit: false,
bowInsta: false
}
let doAntiBull = false;
let extremeAntibull = false;
function gatherAnimation(sid, didHit, index) {
_ = findPlayerBySID(sid);
if (_) {
_.startAnim(didHit, index);
_.gatherIndex = index;
_.gathering = 1;
// Anti:
if (_ != player && !_.isTeam(player) && enemy.length) {
if (near.dist2 >= 175 && near.dist2 <= 275 && _.weaponIndex === 5
&& _.primaryVariant >= 1 && _.secondaryIndex !== void 0 && _.skinIndex === 53 &&
player.canEmpAnti === true) {
buyEquip(6, 0);
antiSyncHealing(2,setTimeout(() => 111));
showSettingText(1000, "Anti 0 Tick");
}
if(near.dist2 <= items.weapons[index].range &&
UTILS.getAngleDist(tmpDir, _.dir) <= config.gatherAngle){
if((_.weaponIndex == 12 || _.weaponIndex == 5 || _.weaponIndex
== 13 || _.weaponIndex == 10 || _.weaponIndex == 15) && (_.skinIndex == 53 ||
_.skinIndex == 7)){
buyEquip(6, 0);
buyEquip(13, 1);
if (player.shameCount < 4) {
place(0, getAttackDir());
}
showSettingText(1000, "Anti Reverse");
detect.reverse = true;
} else {
detect.reverse = false;
}
} else {
detect.reverse = false;
}
let tmpDist = UTILS.getDistance(_.x, _.y, player.x, player.y) -
(player.scale * 1.8);
if(tmpDist <= items.weapons[index].range){
tmpDir = UTILS.getDirection(player.x, player.y, _.x, _.y);
if(UTILS.getAngleDist(tmpDir, _.dir) <= config.gatherAngle){
if(_.skinIndex == 11 && player.skinIndex == 7){
detect.antibull = true;
} else {
detect.antibull = false;
}
} else {
detect.antibull = false;
}
} else {
detect.antibull = false;
}
if(near.dist2 <= 400 && near.dist2 >= 170 &&
UTILS.getAngleDist(tmpDir, _.dir) <= config.gatherAngle){
if((_.weaponIndex == 12 || _.weaponIndex == 13) && (_.skinIndex
== 53 || _.skinIndex == 7)){
detect.onetick = true;
} else {
detect.onetick = false;
}
} else {
detect.onetick = false;
}
if(near.dist2 <= 175 && UTILS.getAngleDist(tmpDir, _.dir) <=
config.gatherAngle){
detect.spiketick = true;
} else {
detect.spiketick = false;
}
if(traps.inTrap && !near.reloads[index] && _ != player && tmpDist
<= items.weapons[index].range && UTILS.getAngleDist(tmpDir, _.dir) <=
config.gatherAngle){
detect.barbarian = true;
} else {
detect.barbarian = false;
}
if(near.dist2 <= 190 && UTILS.getAngleDist(tmpDir, _.dir) <=
config.gatherAngle){
if((_.skinIndex == 53 || _.skinIndex == 7)){
detect.antibullhit = true;
} else {
detect.antibullhit = false;
}
} else {
detect.antibullhit = false;
}
// ANTI BULL
if(UTILS.getDistance(_.x, _.y, player.x, player.y) - (player.scale
* 1.8) <= items.weapons[index].range && UTILS.getAngleDist(tmpDir, _.dir) <=
config.gatherAngle){
if(!player.reloads[player.weapons[0]] && !traps.inTrap &&
player.skinIndex == 11){
extremeAntibull = true;
} else {
extremeAntibull = false;
}
} else {
extremeAntibull = false;
}
}
if (didHit) {
let _ects = objectManager.hitObj;
objectManager.hitObj = [];
game.tickBase(() => {
// refind
_ = findPlayerBySID(sid);
let val = items.weapons[index].dmg *
(config.weaponVariants[_[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) *
(items.weapons[index].sDmg || 1) * (_.skinIndex == 40 ? 3.3 : 1);
_ects.forEach((healthy) => {
healthy.health -= val;
});
}, 1);
}
}
}
// SHOOT TURRET:
function shootTurret(sid, dir) {
_ = findObjectBySid(sid);
if (_) {
if (config.anotherVisual) {
_.lastDir = dir;
} else {
_.dir = dir;
}
_.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
_.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
}
}
// ACTION BAR:
function updateItems(data, wpn) {
if (data) {
if (wpn) {
player.weapons = data;
player.primaryIndex = player.weapons[2];
player.secondaryIndex = player.weapons[1];
if (!instaC.isTrue) {
selectWeapon(player.weapons[0]);
}
} else {
player.items = data;
}
}
// ADD PROJECTILE:
function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null,
layer, inWindow).sid = sid;
runAtNextTick.push(Array.prototype.slice.call(arguments));
}
// REMOVE PROJECTILE:
function remProjectile(sid, range) {
for (let i = 0; i < projectiles.length; ++i) {
if (projectiles[i].sid == sid) {
projectiles[i].range = range;
let _ects = objectManager.hitObj;
objectManager.hitObj = [];
game.tickBase(() => {
let val = projectiles[i].dmg;
_ects.forEach((healthy) => {
if (healthy.projDmg) {
healthy.health -= val;
}
});
}, 1);
}
}
}
function setAlliancePlayers(data) {
alliancePlayers = data;
}
// STORE MENU:
function updateStoreItems(type, id, index) {
if (index) {
if (!type) player.tails[id] = 1;
else {
player.latestTail = id;
}
} else {
if (!type) player.skins[id] = 1, id == 7 && (my.reSync = true); //
testing perfect bulltick...
else {
player.latestSkin = id;
}
}
}
function isTeam (_) {
return (this == _ || (this.team && this.team == _.team));
};
// SEND MESSAGE:
function receiveChat(sid, message) {
if (/img/i.test(message)) return;
if (/iframe/i.test(message)) return;
// MINIMAP:
function updateMinimap(data) {
minimapData = data;
}
// RENDER HEXAGON:
// 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 || be;
tmpContext.beginPath();
tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
if (!dontFill) tmpContext.fill();
if (!dontStroke) tmpContext.stroke();
}
// 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);
}
// 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 || be;
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();
}
// RENDER PLAYERS:
function renderDeadPlayers(d, f) {
be.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);
be.globalAlpha = dead.alpha;
be.strokeStyle = outlineColor;
be.save();
be.translate(dead.x - f, dead.y - d);
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;
be.rotate(dead.angle);
renderDeadPlayer(dead, be);
be.restore();
be.fillStyle = "#91b2db";
if (timeElapsed >= 3000) {
dead.active = false;
dead.startTime = null;
}
});
}
// RENDER PLAYERS:
function renderPlayers(f, d, zIndex) {
be.globalAlpha = 1;
be.fillStyle = "#91b2db";
for (var i = 0; i < players.length; ++i) {
_ = players[i];
if (_.zIndex == zIndex) {
_.animate(delta);
if (_.visible) {
_.skinRot += (0.002 * delta);
tmpDir = (!configs.showDir && !useWasd && _ == player) ?
configs.attackDir ? getVisualDir() : getSafeDir() : (_.dir||0);
be.save();
be.translate(_.x - f, _.y - d);
// RENDER PLAYER:
be.rotate(tmpDir + _.dirPlus);
renderPlayer(_, be);
be.restore();
}
}
}
}
// RENDER DEAD PLAYER:
function renderDeadPlayer(obj, ctxt) {
ctxt = ctxt || be;
ctxt.lineWidth = outlineWidth;
ctxt.lineJoin = "miter";
items.projectiles[items.weapons[obj.weaponIndex].projectile], be);
}
}
// 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], be);
}
}
// 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
ctxt.rotate(Math.PI / 2);
renderSkin2(48, ctxt, null, obj)
}
// RENDER PLAYER:
function renderPlayer(obj, ctxt) {
ctxt = ctxt || be;
ctxt.lineWidth = outlineWidth;
ctxt.lineJoin = "miter";
if (_ == player) {
ctxt.globalAlpha = 0.4;
}
// TAIL/CAPE:
if (obj.tailIndex > 0) {
renderTailTextureImage(obj.tailIndex, ctxt, obj);
}
items.projectiles[items.weapons[obj.weaponIndex].projectile], be);
}
}
// 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);
items.projectiles[items.weapons[obj.weaponIndex].projectile], be);
}
}
// 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 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 _ = parentSkin||skinPointers[index];
if (!_) {
for (var i = 0; i < hats.length; ++i) {
if (hats[i].id == index) {
_ = hats[i];
break;
}
}
skinPointers[index] = _;
}
if (tmpSkin.isLoaded)
ctxt.drawImage(tmpSkin, -_.scale/2, -_.scale/2, _.scale, _.scale);
if (!parentSkin && _.topSprite) {
ctxt.save();
ctxt.rotate(owner.skinRot);
renderSkin(index + "_top", ctxt, _, 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",
};
// 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 _ = accessPointers[index];
if (!_) {
for (var i = 0; i < accessories.length; ++i) {
if (accessories[i].id == index) {
_ = accessories[i];
break;
}
}
accessPointers[index] = _;
}
if (tmpSkin.isLoaded) {
ctxt.save();
ctxt.translate(-20 - (_.xOff||0), 0);
if (_.spin)
ctxt.rotate(owner.skinRot);
ctxt.drawImage(tmpSkin, -(_.scale/2), -(_.scale/2), _.scale, _.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, f, d) {
for (let i = 0; i < projectiles.length; i++) {
_ = projectiles[i];
if (_.active && _.layer == layer && _.inWindow) {
_.update(delta);
if (_.active && isOnScreen(_.x - f, _.y - d, _.scale)) {
be.save();
be.translate(_.x - f, _.y - d);
be.rotate(_.dir);
renderProjectile(0, 0, _, be, 1);
be.restore();
}
}
};
}
// RENDER PROJECTILE:
let projectileSprites = {};//fz iz zexy
// RENDER AI:
let aiSprites = {};
// MIDDLE RIVER:
let tmpW = config.riverWidth + padding;
let tmpY = (config.mapScale / 2) - d - (tmpW / 2);
if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
}
}
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 = _.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, _.scale, _.scale * 0.7);
tmpContext.fillStyle = biomeID ? "#e3f1f4" : "#89a54c";
tmpContext.fill();
tmpContext.stroke();
//tmpContext.shadowBlur = null;
//tmpContext.shadowColor = null;
tmpContext.shadowBlur = null;
tmpContext.shadowColor = null;
function Or(e, t, i) {
const s = e.lineWidth || 0;
i /= 2,
e.beginPath();
let n = Math.PI * 2 / t;
for (let r = 0; r < t; r++)
e.lineTo(i + (i - s / 2) * Math.cos(n * r), i + (i - s / 2) *
Math.sin(n * r));
e.closePath()
}
const se = config.maxScreenWidth
, re = config.maxScreenHeight;
function Bo(e, t, i) {
return e + i >= 0 && e - i <= se && t + i >= 0 && t - i <= re
}
function RenderVolcano() {
const t = Volcano.scale * 2
, i = document.createElement("canvas");
i.width = t,
i.height = t;
const s = i.getContext("2d");
s.strokeStyle = "#3e3e3e",
s.lineWidth = outlineWidth * 2,
s.fillStyle = "#7f7f7f",
Or(s, 10, t),
s.fill(),
s.stroke(),
Me.land = i;
const n = document.createElement("canvas")
, r = Volcano.innerScale * 2;
n.width = r,
n.height = r;
const o = n.getContext("2d");
o.strokeStyle = outlineColor,
o.lineWidth = outlineWidth * 1.6,
o.fillStyle = "#f54e16",
o.strokeStyle = "#f56f16",
Or(o, 10, r),
o.fill(),
o.stroke(),
Me.lava = n
}
RenderVolcano();
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 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;
}
// OBJECT ON SCREEN:
function isOnScreen(x, y, s) {
return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y, s,
maxScreenHeight));
}
function renderVolcanoAnim() {
let Re = camX, _e = camY
const T = config.VolcanoInfo;
const e = Re - maxScreenWidth / 2
, t = _e - maxScreenHeight / 2;
Me.animationTime += delta,
Me.animationTime %= T.volcanoAnimationDuration;
const i = T.volcanoAnimationDuration / 2
, s = 1.7 + .3 * (Math.abs(i - Me.animationTime) / i)
, n = T.innerVolcanoScale * s;
be.drawImage(Me.land, Me.x - T.volcanoScale - e, Me.y - T.volcanoScale - t,
T.volcanoScale * 2, T.volcanoScale * 2),
be.drawImage(Me.lava, Me.x - n - e, Me.y - n - t, n * 2, n * 2)
}
be.save();
be.translate(tmpX, tmpY);
be.rotate(_.dir);
if (!_.active) {
be.scale(_.visScale / _.scale, _.visScale / _.scale);
}
be.drawImage(tmpSprite, -(tmpSprite.width / 2), -
(tmpSprite.height / 2));
if (_.blocker) {
be.strokeStyle = "#db6e6e";
be.globalAlpha = 0.3;
be.lineWidth = 6;
renderCircle(0, 0, _.blocker, be, false, true);
}
be.restore();
} else {
if(_.type == 4){
renderVolcanoAnim();
} else {
// Other:
tmpSprite = getResSprite(_);
be.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2),
tmpY - (tmpSprite.height / 2));
}
}
}
}
});
}
// 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 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;
}
}
// 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/1175772907931176991/1226209968051453962/
Pngtreeskull_icon_logo_vector_illuatration_7964583.png?
ex=6623f006&is=66117b06&hm=d34a6c712d3a3185a4ee966a72d839f54206d72f81a42439800706c9
a6069715&","https://cdn.discordapp.com/attachments/
1175772907931176991/1226209968051453962/
Pngtreeskull_icon_logo_vector_illuatration_7964583.png?
ex=6623f006&is=66117b06&hm=d34a6c712d3a3185a4ee966a72d839f54206d72f81a42439800706c9
a6069715&"];
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 getDist(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;
}
}
// GET DIRECTION
function getDir(e, t) {
try {
return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2
|| e.x));
} catch (e) {
return 0;
}
}
// 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) {
be.beginPath();
be.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
// }
be.globalAlpha = 1;
// MOVE CAMERA:
function lerp(a, b, t) {
return a + (b - a) * t;
}
if (player) {
resize();
let target = player;
if (enemy.length) {
if (near.dist2 < 710) {
target = near;
} else {
target = player;
}
} else {
target = player;
}
// RENDER CORDS:
let f = camX - (maxScreenWidth / 2);
let d = camY - (maxScreenHeight / 2);
// RENDER BACKGROUND:
if (config.snowBiomeTop - d <= 0 && config.mapScale - config.snowBiomeTop -
d >= maxScreenHeight) {
be.fillStyle = "#b6db66";
be.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
} else if (config.mapScale - config.snowBiomeTop - d <= 0) {
be.fillStyle = "#dbc666";
be.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
} else if (config.snowBiomeTop - d >= maxScreenHeight) {
be.fillStyle = "#fff";
be.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
} else if (config.snowBiomeTop - d >= 0) {
be.fillStyle = "#fff";
be.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - d);
be.fillStyle = "#b6db66";
be.fillRect(0, config.snowBiomeTop - d, maxScreenWidth, maxScreenHeight
- (config.snowBiomeTop - d));
} else {
be.fillStyle = "#b6db66";
be.fillRect(0, 0, maxScreenWidth, (config.mapScale -
config.snowBiomeTop - d));
be.fillStyle = "#dbc666";
be.fillRect(0, (config.mapScale - config.snowBiomeTop - d),
maxScreenWidth, maxScreenHeight - (config.mapScale - config.snowBiomeTop - d));
}
// RENDER PROJECTILES:
be.globalAlpha = 1;
be.lineWidth = outlineWidth;
renderProjectiles(0, f, d);
// RENDER PLAYERS:
renderPlayers(f, d, 0);
// RENDER AI:
be.globalAlpha = 1;
for (let i = 0; i < ais.length; ++i) {
_ = ais[i];
if (_.active && _.visible) {
_.animate(delta);
be.save();
be.translate(_.x - f, _.y - d);
be.rotate(_.dir + _.dirPlus - (Math.PI / 2));
renderAI(_, be);
be.restore();
}
}
// MAP BOUNDARIES:
be.fillStyle = "#000";
be.globalAlpha = 1;
be.globalCompositeOperation = 'source-over';
if (f <= 0) {
be.fillRect(0, 0, -f, maxScreenHeight);
}
if (config.mapScale - f <= maxScreenWidth) {
let tmpY = Math.max(0, -d);
be.fillRect(config.mapScale - f, tmpY, maxScreenWidth -
(config.mapScale - f), maxScreenHeight - tmpY);
}
if (d <= 0) {
be.fillRect(-f, 0, maxScreenWidth + f, -d);
}
if (config.mapScale - d <= maxScreenHeight) {
let tmpX = Math.max(0, -f);
let tmpMin = 0;
if (config.mapScale - f <= maxScreenWidth) tmpMin = maxScreenWidth -
(config.mapScale - f);
be.fillRect(tmpX, config.mapScale - d, (maxScreenWidth - tmpX) -
tmpMin, maxScreenHeight - (config.mapScale - d));
}
be.globalCompositeOperation = 'source-over';
if (_ == player) {
be.globalAlpha = 0.3;
}
if (_.health > 0) {
try {
SpikeSync(players,gameObjects.filter(t => t.active &&
Math.hypot(t.y - player.y2, t.x - player.x2) < 800),items.weapons,be, {x: f, y:
d});
} catch (t) {
console.error(t);
}
// HEALTH BAR:
if (!_.displayHealth) _.displayHealth = _.health;
const healthLerpSpeed = 0.25;
_.displayHealth += (_.health - _.displayHealth) *
healthLerpSpeed;
be.fillStyle = "#222";
be.roundRect(_.x - f - uWidth - config.healthBarPad, hpOffset +
_.y - d + _.scale + config.nameY, uWidth * 2 + config.healthBarPad * 2, 17, 8);
be.fill();
be.fillStyle = opColor1;
be.roundRect(_.x - f - uWidth, hpOffset + _.y - d + _.scale +
config.nameY + config.healthBarPad, uWidth * 2 * (_.displayHealth / _.maxHealth),
17 - config.healthBarPad * 2, 7);
be.fill();
if (_.isPlayer) {
be.globalAlpha = 1;
// BuildHp:
if (true) {
gameObjects.forEach((tmp) => {
let _ = tmp;
if (player && _.active && _ && _.health) {
let woahMainColors = player.sid != _.owner.sid
&& !player.findAllianceBySid(_.owner.sid) ? "#fcb6b6" : "#e3b5fc";
let woahMainColors2 = player.sid != _.owner.sid
&& !player.findAllianceBySid(_.owner.sid) ? "#4e3838" : "#413449";
}
}
}
}
if (player) {
// PATHFINDER LINE:
if (pathFind.active) {
if (pathFind.array) {
be.lineWidth = 4;
be.globalAlpha = 1;
be.strokeStyle = "#fff";
be.beginPath();
pathFind.array.forEach((path, i) => {
let pathXY = {
x: (pathFind.scale / pathFind.grid) * path.x,
y: (pathFind.scale / pathFind.grid) * path.y
}
let render = {
x: ((player.x2 - (pathFind.scale / 2)) + pathXY.x) - f,
y: ((player.y2 - (pathFind.scale / 2)) + pathXY.y) - d
}
if (i === 0) {
be.moveTo(render.x, render.y);
} else {
be.lineTo(render.x, render.y);
}
});
be.stroke();
}
}
// AUTOPUSH LINE:
if (my.autoPush) {
be.lineWidth = 5;
be.globalAlpha = 1;
be.beginPath();
be.strokeStyle = "blue";
be.moveTo(player.x - f, player.y - d);
be.lineTo(my.pushData.x2 - f, my.pushData.y2 - d);
be.lineTo(my.pushData.x - f, my.pushData.y - d);
be.stroke();
}
let petalsCount = 6;
} else {
petal.time += delta;
if (petal.alive) {
petal.alpha -= delta / 200;
petal.visScale += delta / (petal.scale * 2);
if (petal.alpha <= 0) {
petal.alpha = 0;
petal.alive = false;
}
}
if (petal.alive) {
be.globalAlpha = petal.alpha;
be.lineWidth = 3;
if (breathingPetals.includes(petal)) {
petal.visScale += Math.sin(Date.now() / 1000) * 0.1;
}
}
be.globalAlpha = 1;
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) {
be.font = "20px Ubuntu";
let tmpSize = be.measureText(ch.chat);
be.textBaseline = "middle";
be.textAlign = "center";
let tmpX = ch.x - f;
let tmpY = ch.y - d - 90;
let tmpH = 40;
let tmpW = tmpSize.width + 15;
be.globalAlpha = ch.alpha;
be.lineWidth = 5;
be.fillStyle = "#ccc";
be.strokeStyle = "rgb(25, 25, 25)";
be.fillStyle = "#fff";
be.strokeStyle = "#000";
be.strokeText(ch.chat, tmpX, tmpY);
be.fillText(ch.chat, tmpX, tmpY);
ch.y -= delta / 100;
}
});
}
be.globalAlpha = 1;
// RENDER MINIMAP:
renderMinimap(delta);
}
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.last = timer;
fpsTimer.time = 0;
}
fpsTimer.time++;
updateGame();
rAF(doUpdate);
ms.avg = Math.round((ms.min+ms.max)/2);
}
prepareMenuBackground();
doUpdate();
// ACTION BAR:
UTILS.removeAllChildren(actionBar);
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(_.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(_.items[_.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;
}
}
}(1);