Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Copyright 2016 Stan Tatarnykov
- (function() {
- var t = {
- scope: {}
- };
- t.defineProperty = "function" == typeof Object.defineProperties ? Object.defineProperty : function(t, e, a) {
- if (a.get || a.set) throw new TypeError("ES3 does not support getters and setters.");
- t != Array.prototype && t != Object.prototype && (t[e] = a.value)
- };
- t.getGlobal = function(t) {
- return "undefined" != typeof window && window === t ? t : "undefined" != typeof global ? global : t
- };
- t.global = t.getGlobal(this);
- t.polyfill = function(e, a, i, n) {
- if (a) {
- i = t.global;
- e = e.split(".");
- for (n = 0; n < e.length - 1; n++) {
- var r = e[n];
- r in i || (i[r] = {});
- i = i[r]
- }
- e = e[e.length - 1];
- n = i[e];
- a = a(n);
- a != n && null != a && t.defineProperty(i, e, {
- configurable: !0,
- writable: !0,
- value: a
- })
- }
- };
- t.polyfill("Array.prototype.fill", function(t) {
- return t ? t : function(t, e, a) {
- var i = this.length || 0;
- 0 > e && (e = Math.max(0, i + e));
- if (null == a || a > i) a = i;
- a = Number(a);
- 0 > a && (a = Math.max(0, i + a));
- for (e = Number(e || 0); e < a; e++) this[e] = t;
- return this
- }
- }, "es6-impl", "es3");
- t.polyfill("Math.trunc", function(t) {
- return t ? t : function(t) {
- t = Number(t);
- if (isNaN(t) || Infinity === t || -Infinity === t || 0 === t) return t;
- var e = Math.floor(Math.abs(t));
- return 0 > t ? -e : e
- }
- }, "es6-impl", "es3");
- var e = 120,
- a = [];
- a.push({
- name: "USA 1 (New York)",
- ip: "45.79.152.38"
- });
- a.push({
- name: "USA 2 (New York)",
- ip: "173.255.237.64"
- });
- a.push({
- name: "USA 3 (California)",
- ip: "45.33.53.86"
- });
- a.push({
- name: "Brazil/ USA 4 (Texas)",
- ip: "45.33.12.194"
- });
- a.push({
- name: "Europe 1 (Germany)",
- ip: "139.162.173.197"
- });
- a.push({
- name: "Europe 2 (London)",
- ip: "88.80.189.198"
- });
- a.push({
- name: "Asia",
- ip: "103.3.63.181"
- });
- var i = Math.min(a.length - 1, Et(0, 5)),
- n = a[i];
- if ("undefined" !== typeof Storage) {
- console.log("Last used server is " + localStorage.getItem("lastServerIP"));
- for (var r = localStorage.getItem("lastServerIP"), s = 0; s < a.length; s++) a[s].ip == r && (i = s, n = a[i])
- }
- var l = .18,
- h = .1,
- o = "#3FBA54",
- c = "#09992F",
- f = "#09992F",
- m = "#4E66E4",
- g = "#4655A6",
- u = "#F35F53",
- y = "#CF6259",
- p = 1,
- w = 2,
- I = 3,
- P = 4,
- b = 5,
- M = 6,
- x = 7,
- U = 8,
- v = 9,
- A = 10,
- T = 11,
- S = 1,
- k = 2,
- E = 3,
- C = 4,
- D = 5,
- B = 6,
- R = 7,
- O = 8,
- F = 9,
- _ = 10,
- Y = 11,
- L = 12,
- W = 13,
- X = 14,
- N = document.getElementById("gCanvas"),
- z = null,
- H = null,
- G = N.getContext("2d"),
- V = 5,
- q = V,
- j = camy = n_camx = n_camy = o_camx = o_camy = 0,
- Z = 0,
- J = 0,
- K = 0,
- Q = 0,
- $ = 0,
- tt = 0,
- et = !1,
- at = !1,
- it, nt, rt = 0,
- st = 0,
- lt = "",
- ht = 0,
- ot = !1,
- dt = !1,
- ct = !1,
- ft = water = 100,
- mt = xp = xpPer = 0,
- gt = 0,
- ut = +new Date,
- yt = 0,
- pt = 0,
- wt = "",
- It = 100,
- Pt = Array(20).fill(0),
- bt = Array(20).fill(0),
- Mt = Array(20).fill(0),
- xt = [],
- Ut = {},
- vt = [],
- At = +Date.now(),
- Tt;
- St();
- Qt();
- Zt();
- function St() {
- Ut = {};
- xt = [];
- vt = [];
- ft = water = 100;
- water = ft = mt = xpPer = xp = 0;
- wt = "";
- document.getElementById("spawnXpLabel").style.display = wt ? "block" : "none";
- document.getElementById("spawnXpLabel").textContent = wt
- }
- function kt(t, e) {
- return Math.random() * (e - t) + t
- }
- function Et(t, e) {
- return Math.floor(Math.random() * (e - t + 1)) + t
- }
- function Ct(t) {
- t = Math.trunc(t) % 360 + (t - Math.trunc(t));
- return 0 < t ? t : t + 360
- }
- function Dt(t) {
- return 180 / Math.PI * t
- }
- function Bt(t) {
- return Math.PI / 180 * t
- }
- function Rt(t, e, a, i) {
- return Math.atan2(i - e, a - t)
- }
- function Ot(t, e) {
- return 0 != (t >> e) % 2
- }
- function Ft(t, e, a) {
- return a ? t | 1 << e : t & ~(1 << e)
- }
- function _t(t, e) {
- var a = Ct(Dt(e - t));
- 180 < a && (a -= 360);
- return Bt(a)
- }
- function Yt(t, e, a) {
- return Math.min(a, Math.max(e, t))
- }
- function Lt(t) {
- return unescape(encodeURIComponent(t))
- }
- function Wt(t) {
- return decodeURIComponent(escape(t))
- }
- function Xt(t, e, a) {
- var i = 1.2 * G.measureText("M").width;
- t = t.split("\n");
- for (var n = 0; n < t.length; ++n) G.fillText(t[n], e, a), a += i
- }
- function Nt(t) {
- var e = parseInt(t, 10),
- a = Math.floor(e / 3600);
- t = Math.floor((e - 3600 * a) / 60);
- e = e - 3600 * a - 60 * t;
- 10 > e && (e = "0" + e);
- return t + ":" + e
- }
- function zt(t) {
- return 1e3 > t ? t : Math.round(t / 1e3 * 10) / 10 + "k"
- }
- Ht.prototype = {
- id: 0,
- oType: B,
- spawnTime: 0,
- rPer: 0,
- updateTime: 0,
- x: 0,
- y: 0,
- ox: 0,
- oy: 0,
- nx: 0,
- ny: 0,
- rad: 0,
- oRad: 0,
- nRad: 0,
- z: 0,
- name: "",
- dead: !1,
- type: 0
- };
- function Ht(t, e, a, i, n) {
- this.id = t;
- this.oType = e;
- this.ox = this.x = this.nx = a;
- this.oy = this.y = this.ny = i;
- this.nRad = n;
- this.oRad = this.rad = 0;
- if (e == Y || e == X) this.oRad = this.rad = n;
- this.hpPer = this.hpPer_n = this.hpBarA = this.hpBarA_n = this.angle = this.angledelta = 0;
- this.rPer = kt(0, 1);
- this.spawnTime = +Date.now();
- this.updateTime = ae;
- this.flag_hurt = !1;
- this.oType == k && (this.flag_tailBitten = this.flag_lowWat = !1);
- if (this.oType == k || this.oType == F || this.oType == W) this.chatTxt = "", this.chatFadeT = ae - 1, this.chatA = 0;
- this.updateZ = function() {
- switch (this.oType) {
- case X:
- this.z = -111;
- break;
- case Y:
- this.z = -110;
- break;
- case W:
- this.z = -101;
- break;
- case F:
- this.z = -100;
- break;
- case E:
- this.z = 999;
- break;
- case D:
- this.z = 1001;
- break;
- case C:
- this.z = 1002;
- break;
- case L:
- this.z = 9999;
- break;
- case _:
- this.z = 1e4;
- break;
- default:
- this.z = this.type == T ? 1004 : this.type == U ? 1e3 : this.rad
- }
- };
- this.draw = function() {
- var t = this.moveUpdate();
- G.save();
- G.translate(this.x, this.y);
- if (this.oType == B || this.oType == R || this.oType == O || this.oType == F || this.oType == W) {
- var e;
- e = (ae - this.spawnTime) / 1e3;
- var a = this.oType == O ? 2 : 1.3;
- if (this.oType == F || this.oType == W) a = 2.5;
- e = (this.oType == F || this.oType == W ? .04 : .1) * Math.sin(2 * Math.PI / a * e);
- G.scale(1 + e, 1 + e / 2)
- }
- this.dead && (G.globalAlpha *= 1 - t);
- this.oType == E ? this.drawCircle("", c) : this.oType == D ? this.drawCircle("", y) : this.oType == C ? this.drawCircle("", g) : this.oType == B ? 4 != this.type ? this.drawCircle("", u) : this.drawCircle("", "#B8413B") : this.oType == O ? (G.strokeStyle = c, G.lineWidth = 2, G.beginPath(), G.rect(-5, 0, 10, .83 * this.rad), G.fillStyle = "#FFCA49", G.fill(), G.stroke(), G.beginPath(), G.arc(0, 0, this.rad, Math.PI, 2 * Math.PI), G.fillStyle = "#CFAD59", G.fill(), G.stroke()) : this.oType == F ? (G.fillStyle = "#9F8641", G.beginPath(), G.arc(0, 0, this.rad, 0, 2 * Math.PI), G.fill(), G.strokeStyle = c, G.lineWidth = 1.5, G.stroke(), G.fillStyle = "#7E6A35", G.beginPath(), G.arc(0 - this.rPer, 0 - this.rPer, Math.max(0, this.rad - 5), 0, 2 * Math.PI), G.fill(), G.fillStyle = "#5C4E28", G.beginPath(), G.arc(0 + this.rPer, 1, Math.max(0, this.rad - 10), 0, 2 * Math.PI), G.fill()) : this.oType == W ? (G.fillStyle = "#9F8641", G.beginPath(), G.arc(0, 0, this.rad, 0, 2 * Math.PI), G.fill(), G.strokeStyle = c, G.lineWidth = 1.5, G.stroke(), G.fillStyle = "#7E6A35", G.beginPath(), G.arc(0 - this.rPer, 0 - this.rPer, Math.max(0, this.rad - 5), 0, 2 * Math.PI), G.fill(), G.fillStyle = "#5C4E28", G.beginPath(), G.arc(0 + this.rPer, 1, Math.max(0, this.rad - 12), 0, 2 * Math.PI), G.fill(), G.fillStyle = "#40371D", G.beginPath(), G.arc(0 - 2 * this.rPer - 3, 1, Math.max(0, this.rad - 16.5), 0, 2 * Math.PI), G.fill()) : this.oType == _ ? (G.save(), e = (ae - this.spawnTime) / 1e3, e = 1.5 * Math.sin(2 * Math.PI / 2 * e), G.fillStyle = "#45D157", G.globalAlpha = .93, G.beginPath(), G.arc(.5 * -this.rad, .5 * -this.rad + 10 * this.rPer, Math.max(0, .65 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.5 * this.rad, .5 * -this.rad - 10 * this.rPer, Math.max(0, .73 * this.rad - e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.6 * this.rad, .4 * this.rad, Math.max(0, .78 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.5 * -this.rad, .5 * this.rad, Math.max(0, .6 * this.rad + this.rPer - e), 0, 2 * Math.PI), G.fill(), G.restore()) : this.oType == Y ? (G.save(), G.rotate(2 * this.rPer * Math.PI), e = (ae - this.spawnTime) / 1e3, e = 1.5 * Math.sin(2 * Math.PI / 6 * e), G.globalAlpha = 1, t = 4, G.fillStyle = "#8B7833", G.beginPath(), G.arc(0, 0, this.rad, 0, 2 * Math.PI), G.fill(), G.fillStyle = "#98803A", G.globalAlpha = 1, G.beginPath(), G.arc(0, 0, Math.max(0, this.rad - t + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.45 * this.rad, .45 * -this.rad + 15 * this.rPer, Math.max(0, .5 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.5 * this.rad, .5 * this.rad + 15 * this.rPer, Math.max(0, .4 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.55 * -this.rad * .707, .55 * +this.rad * .707 + 15 * this.rPer, Math.max(0, .5 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.75 * -this.rad, .35 * -this.rad + 15 * this.rPer, Math.max(0, .3 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.beginPath(), G.arc(this.rad + 10 * this.rPer, 50 * this.rPer, 8, 0, 2 * Math.PI), G.fill(), G.beginPath(), G.beginPath(), G.arc(this.rad - 20 * this.rPer, 50 * this.rPer, 10, 0, 2 * Math.PI), G.fill(), G.beginPath(), G.restore()) : this.oType == X ? (G.save(), G.rotate(2 * this.rPer * Math.PI), e = (ae - this.spawnTime) / 1e3, e = 5.5 * Math.sin(2 * Math.PI / 4 * e), G.globalAlpha = 1, t = 4, G.fillStyle = m, G.beginPath(), G.arc(0, 0, this.rad, 0, 2 * Math.PI), G.fill(), G.fillStyle = g, G.beginPath(), G.arc(0, 0, Math.max(0, this.rad - t + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.45 * this.rad, .45 * -this.rad + 15 * this.rPer, Math.max(0, .5 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.5 * this.rad, .5 * this.rad + 15 * this.rPer, Math.max(0, .4 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.55 * -this.rad * .707, .55 * +this.rad * .707 + 15 * this.rPer, Math.max(0, .5 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.75 * -this.rad, .35 * -this.rad + 15 * this.rPer, Math.max(0, .3 * this.rad + e), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.beginPath(), G.arc(this.rad + 10 * this.rPer, 50 * this.rPer, 8, 0, 2 * Math.PI), G.fill(), G.beginPath(), G.beginPath(), G.arc(this.rad - 20 * this.rPer, 50 * this.rPer, 10, 0, 2 * Math.PI), G.fill(), G.beginPath(), G.restore()) : this.oType == L ? this.drawCircle("", "#8C9688") : this.oType == R ? this.drawCircle("", m) : this.oType == k ? (this.drawAnimal(), this.drawPlayerText(t)) : this.drawCircle("????", "black");
- this.hpBarA += .1 * (this.hpBarA_n - this.hpBarA);
- .001 < this.hpBarA && (this.hpPer += .1 * (this.hpPer_n - this.hpPer), a = Math.max(1, this.rad / 25), t = 20 * a, e = 5 * a, a = -this.rad - 10 * a, G.globalAlpha *= this.hpBarA, G.fillStyle = "rgba(0,0,0,0.35)", G.fillRect(0 - t / 2, a - e / 2, t, e), G.fillStyle = "#16D729", G.fillRect(0 - t / 2, a - e / 2, this.hpPer / 100 * t, e));
- G.restore()
- };
- this.drawChat = function() {
- if (this.chatTxt) {
- var t = ae > this.chatFadeT ? 0 : 1;
- this.chatA += .1 * (t - this.chatA);
- .001 > this.chatA ? .001 > t && (this.chatTxt = "") : (G.save(), G.font = "10px Arial", G.lineWidth = 1, G.textAlign = "center", G.textBaseline = "middle", G.globalAlpha = .8 * this.chatA, G.fillStyle = c, t = G.measureText(this.chatTxt).width, G.fillRect(this.x - 1 - t / 2, this.y - this.rad - 10 - 5 - 1, t + 2, 12), G.fillStyle = "#F1C34C", G.shadowOffsetX = 1, G.shadowOffsetY = 1, G.shadowColor = "black", G.globalAlpha = this.chatA, G.fillText(this.chatTxt, this.x, this.y - this.rad - 10), G.restore())
- }
- };
- this.gotChat = function(t) {
- this.chatFadeT = ae + 3e3;
- this.chatTxt = t
- };
- this.drawCircle = function(t, e) {
- G.save();
- G.fillStyle = c;
- G.beginPath();
- G.arc(0, 0, this.rad, 0, 2 * Math.PI);
- G.fill();
- G.fillStyle = e;
- G.beginPath();
- G.arc(0, 0, Math.max(0, this.rad - 1.5), 0, 2 * Math.PI);
- G.fill();
- t && (G.globalAlpha = .15, G.fillStyle = "white", G.textBaseline = "middle", G.textAlign = "center", G.fillText(t, 0, 0));
- G.restore()
- };
- this.drawAnimal = function() {
- var t;
- switch (this.type) {
- case p:
- t = "#9BA9B9";
- break;
- case w:
- t = "#AA937E";
- break;
- case I:
- t = "#DD6BD4";
- break;
- case P:
- t = "#FF9D43";
- break;
- case b:
- t = "#C4773E";
- break;
- case M:
- t = "#f8c923";
- break;
- case x:
- t = "#CAC05B";
- break;
- case U:
- t = "#99591C";
- break;
- case v:
- t = "#30F51C";
- break;
- case A:
- t = "#945A99";
- break;
- case T:
- t = "#22FF8A";
- break;
- default:
- t = "#000000"
- }
- G.save();
- G.rotate(this.angle);
- var e = (ae - this.spawnTime) / 1e3,
- a = 2.5 + .7 * Math.sin(2 * Math.PI / 2.5 * e),
- i;
- i = 0 < Pt[this.type - 1] ? "#EF3C31" : 0 < bt[this.type - 1] ? "#4AE05E" : c;
- G.fillStyle = i;
- G.beginPath();
- G.arc(0, 0, this.rad, 0, 2 * Math.PI);
- G.fill();
- G.fillStyle = t;
- G.beginPath();
- G.arc(0, 0, Math.max(0, this.rad - a), 0, 2 * Math.PI);
- G.fill();
- this.flag_hurt && (G.fillStyle = "rgba(255,0,0,0.3)", G.beginPath(), G.arc(0, 0, Math.max(0, this.rad - a), 0, 2 * Math.PI), G.fill());
- if (this.type >= w) {
- var e = (ae - this.spawnTime) / 1e3,
- e = 4 * Math.sin(2 * Math.PI / 5 * e),
- n = 2.5 * a,
- r = .08 * this.rad,
- s = Math.PI / 180;
- G.fillStyle = this.flag_tailBitten ? "#EF3C31" : 0 < Mt[this.type - 1] ? "#4AE05E" : i;
- G.beginPath();
- G.moveTo((this.rad - a + 1) * Math.cos((281 + n) * s), (this.rad - a + 1) * Math.sin(281 * s));
- G.lineTo((this.rad - a + 1) * Math.cos((259 - n) * s), (this.rad - a + 1) * Math.sin(259 * s));
- G.lineTo((this.rad + r + a) * Math.cos((270 + e) * s), (this.rad + r + a) * Math.sin((270 + e) * s));
- G.lineTo((this.rad - a + 1) * Math.cos((281 + n) * s), (this.rad - a + 1) * Math.sin(281 * s));
- G.fill();
- G.fillStyle = this.flag_tailBitten ? "#EF3C31" : t;
- G.beginPath();
- G.moveTo((this.rad - a) * Math.cos(281 * s), (this.rad - a) * Math.sin(281 * s));
- G.lineTo((this.rad - a) * Math.cos(259 * s), (this.rad - a) * Math.sin(259 * s));
- G.lineTo((this.rad + r) * Math.cos((270 + e) * s), (this.rad + r) * Math.sin((270 + e) * s));
- G.lineTo((this.rad - a) * Math.cos(281 * s), (this.rad - a) * Math.sin(281 * s));
- G.fill()
- }
- this.type == A ? (G.beginPath(), G.arc(.2 * this.rad, .7 * this.rad, Math.max(0, .55 * this.rad - a), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.2 * -this.rad, .7 * this.rad, Math.max(0, .55 * this.rad - a), 0, 2 * Math.PI), G.fill(), G.fillStyle = "#8C96A6", G.beginPath(), G.arc(-(.29 * this.rad), .7 * this.rad + 10, Math.max(0, 3 - a / 2), 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.29 * this.rad, .7 * this.rad + 10, Math.max(0, 3 - a / 2), 0, 2 * Math.PI), G.fill()) : this.type == x ? (G.fillStyle = "#B5AE4C", G.beginPath(), G.arc(.1 * this.rad, -.45 * this.rad, .13 * this.rad, 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(-.4 * this.rad, -.2 * this.rad, .12 * this.rad, 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.15 * this.rad, -.25 * this.rad, .16 * this.rad, 0, 2 * Math.PI), G.fill(), G.beginPath(), G.arc(.63 * this.rad, -.4 * this.rad, .1 * this.rad, 0, 2 * Math.PI), G.fill()) : this.type == b ? (G.fillStyle = "#E5C870", G.beginPath(), t = .35 * -this.rad, a = .1 * -this.rad, G.moveTo(t, a), G.lineTo(t + .25 * this.rad, a), G.lineTo(t - .35 * this.rad, a - 15), G.fill(), G.beginPath(), t = .35 * this.rad, a = .1 * -this.rad, G.moveTo(t, a), G.lineTo(t - .25 * this.rad, a), G.lineTo(t + .35 * this.rad, a - 15), G.fill()) : this.type == U && (G.fillStyle = "black", G.beginPath(), G.arc(0, this.rad - 3, Math.max(0, 5 - a / 2), 0, 2 * Math.PI), G.fill());
- G.save();
- t = Math.max(1, this.rad / 25);
- G.scale(t, t);
- this.drawEyeAtPos(6, .32 * this.rad);
- this.drawEyeAtPos(-6, .32 * this.rad);
- G.restore();
- G.restore();
- this.flag_lowWat && (a = .5 * (.8 - .2), a = .2 + a + a * Math.sin(2 * Math.PI / 1.2 * (ae / 1e3)), G.save(), G.globalAlpha = a, G.fillStyle = m, G.beginPath(), G.arc(0, this.rad + 5, 5 * t, 0, 2 * Math.PI), G.fill(), G.restore())
- };
- this.drawPlayerText = function(t) {
- G.save();
- G.lineWidth = 1;
- G.textAlign = "center";
- G.textBaseline = "middle";
- G.shadowOffsetX = 1;
- G.shadowOffsetY = 1;
- G.shadowColor = "black";
- G.fillStyle = "white";
- G.globalAlpha = this.dead ? G.globalAlpha * (1 - t) : 1;
- yOffset = this.rad + 9;
- this.name && (G.font = "10px Arial", G.fillText(this.name, 0, 0 + yOffset), yOffset += 12);
- G.restore()
- };
- this.drawEyeAtPos = function(t, e) {
- G.beginPath();
- G.arc(t, e, 4.5, 0, 2 * Math.PI);
- G.fillStyle = "black";
- G.fill();
- G.beginPath();
- G.fillStyle = "white";
- G.arc(t - 2, e - 1, .99, 0, 2 * Math.PI);
- G.fill()
- };
- this.moveUpdate = function() {
- var t = (ae - this.updateTime) / 1e3 / l,
- t = 0 > t ? 0 : 1 < t ? 1 : t;
- this.dead && 1 <= t && vt.push(this);
- this.x = t * (this.nx - this.ox) + this.ox;
- this.y = t * (this.ny - this.oy) + this.oy;
- this.rad += .1 * (this.nRad - this.rad);
- if (this.oType == k) {
- var e = .1 * this.angleDelta;
- this.angleDelta -= e;
- this.angle += e
- }
- return t
- }
- }
- function Gt(t) {
- this.data = t;
- this.offset = 0;
- this.readUInt8 = function() {
- var t = this.data.getUint8(this.offset);
- this.offset += 1;
- return t
- };
- this.readUInt16 = function() {
- try {
- var t = this.data.getUint16(this.offset, !1);
- this.offset += 2;
- return t
- } catch (t) {
- return 0
- }
- };
- this.readUInt32 = function() {
- var t = this.data.getUint32(this.offset, !1);
- this.offset += 4;
- return t
- };
- this.readString = function() {
- for (var t = this.readUInt16(), e = "", a, i = 0; i < t; i++) a = this.readUInt8(), i != t - 1 && (e += String.fromCharCode(a));
- return Wt(e)
- }
- }
- function Vt(t) {
- this.len = 0;
- this.dataView = new DataView(new ArrayBuffer(t));
- this.writeUInt8 = function(t) {
- this.dataView.setUint8(this.len, t);
- this.len += 1
- };
- this.writeUInt16 = function(t) {
- this.dataView.setUint16(this.len, t, !1);
- this.len += 2
- };
- this.writeInt16 = function(t) {
- this.dataView.setInt16(this.len, t, !1);
- this.len += 2
- };
- this.writeUInt32 = function(t) {
- this.dataView.setUint32(this.len, t, !1);
- this.len += 4
- };
- this.writeString = function(t) {
- t = Lt(t);
- len = t.length;
- this.writeUInt16(t.length);
- for (var e = 0; e < len; e++) this.writeUInt8(t.charCodeAt(e))
- }
- }
- var qt, jt = 0;
- function Zt() {
- !ct && 1 < jt && (i += 1, i > a.length - 1 && (i = 0), n = a[i], Kt());
- document.getElementById("connecting").style.visibility = "visible";
- console.log("Connecting to " + n.name + " (" + n.ip + ")...");
- Tt = new WebSocket("ws://" + n.ip + ":7020");
- Tt.binaryType = "arraybuffer";
- Tt.onopen = function() {
- jt = 0;
- document.getElementById("startMenu").style.visibility = "visible";
- document.getElementById("connecting").style.visibility = "hidden"
- };
- Tt.onmessage = function(t) {
- $t(new DataView(t.data))
- };
- Tt.onclose = function(t) {
- this == Tt && (jt += 1, qt = setTimeout(function() {
- Zt()
- }, 2e3), dt = !1, document.getElementById("connecting").style.visibility = "visible")
- };
- Tt.onerror = function() {
- console.log("socket error!")
- }
- }
- document.getElementById("serverSelect").onchange = Jt;
- function Jt() {
- i = document.getElementById("serverSelect").selectedIndex;
- n = a[i];
- Kt();
- console.log("Server changed...");
- ee() && Tt.close();
- Zt()
- }
- function Kt() {
- "undefined" !== typeof Storage && localStorage.setItem("lastServerIP", n.ip);
- document.getElementById("serverSelect").selectedIndex = i
- }
- function Qt() {
- for (var t = document.getElementById("serverSelect"); t.lastChild;) t.removeChild(t.lastChild);
- for (var e = 0; e < a.length; e++) {
- var i = document.createElement("option");
- i.text = a[e].name;
- t.add(i)
- }
- t.selectedIndex = 0
- }
- function $t(t) {
- msg = new Gt(t);
- msgType = msg.readUInt8();
- switch (msgType) {
- case 1:
- nPlayers = msg.readUInt16();
- lt = nPlayers + " players";
- serverVer = msg.readUInt16();
- serverVer > e ? setTimeout(function() {
- window.location.reload()
- }, 700) : (document.getElementById("startMenuWrapper").style.display = "block", ge(!0));
- break;
- case 2:
- 1 == msg.readUInt8() ? (spectating = 2 == msg.readUInt8(), ot = !spectating, ct = dt = !0, ht = msg.readUInt32(), myRoomID = msg.readUInt16(), rt = msg.readUInt16(), st = msg.readUInt16(), j = o_camx = n_camx = msg.readUInt16() / 4, camy = o_camy = n_camy = msg.readUInt16() / 4, q = msg.readUInt16() / 1e3, V = 2 * q, spectating || se(msg), spectating || (document.getElementById("startMenuWrapper").style.display = "none", window.onbeforeunload = function(t) {
- return "You're alive in a game, close mope.io?"
- }), St()) : alert("Couldn't join a game, server is too full. Try another server, or please try again later.");
- break;
- case 8:
- t = msg.readUInt8();
- var a = msg.readUInt8(),
- i = msg.readUInt8();
- lbData = [];
- for (s = 0; s < i; ++s) lbData.push({
- rank: msg.readUInt8(),
- name: msg.readString(),
- score: msg.readUInt32()
- });
- le(lbData, t, a);
- break;
- case 10:
- nPlayers = msg.readUInt16();
- lt = nPlayers + " players";
- break;
- case 18:
- t = msg.readUInt8();
- It = msg.readUInt32();
- switch (t) {
- case p:
- oe = "A little mouse...\n Drink water, eat berries to grow!";
- break;
- case w:
- oe = "UPGRADED to rabbit:\nEat animals circled in light-green (You can now eat MICE!)";
- break;
- case I:
- oe = "UPGRADED to PIG:\n You can now eat MUSHROOMS\n+ Pigs swim through MUD/Lakes quickly!";
- break;
- case P:
- oe = "UPGRADED to FOX! ,\n (You can hide inside red berry bushes!)";
- break;
- case b:
- oe = "UPGRADED to DEER:\n Eat ONLY MUSHROOMS!";
- break;
- case M:
- oe = "UPGRADED to LION:\n Rawr, let's hunt Foxes and DEER!";
- break;
- case x:
- oe = "UPGRADED to CHEETAH:\n You're super quick!- Let's chase someone...";
- break;
- case U:
- oe = "UPGRADED to BEAR:\n Bears climb through green hills! (And can swim pretty well too)";
- break;
- case v:
- oe = "UPGRADED to CROCODILE (nice!):\n(Now hide in water spots) + Swim well in Mud & Lakes!";
- break;
- case A:
- oe = "UPGRADED to HIPPO! :\nHippos swim in MUD, and especially lakes!";
- break;
- case T:
- oe = "UPGRADED to DRAGON! (WOW, you're amazing!):\nDominate the lands, fly over hills!";
- break;
- default:
- oe = "Upgraded!"
- }
- de = "white";
- ce = +new Date + 5e3;
- Pt = Array(20).fill(0);
- t = msg.readUInt8();
- for (a = 0; a < t; a++) Pt[msg.readUInt8() - 1] = 1;
- bt = Array(20).fill(0);
- t = msg.readUInt8();
- for (a = 0; a < t; a++) bt[msg.readUInt8() - 1] = 1;
- Mt = Array(20).fill(0);
- t = msg.readUInt8();
- for (a = 0; a < t; a++) Mt[msg.readUInt8() - 1] = 1;
- break;
- case 14:
- t = msg.readUInt8();
- var n = msg.readUInt32();
- 0 == t ? (oe = "Watch out! You were eaten!", de = "#F1C34C", ce = +new Date + 2500) : 1 == t ? (oe = "You died of hunger :(", de = "#F1C34C", ce = +new Date + 2500) : 2 == t && (oe = "You died of thirst :( Don't let your water run out!", de = "#F1C34C", ce = +new Date + 3500);
- ot = !1;
- window.setTimeout(function() {
- ot || (document.getElementById("startMenuWrapper").style.display = "block", document.getElementById("nickInput").focus(), wt = 0 < n ? "You'll spawn with +" + zt(n) + " XP!" : "", pt = 0, document.getElementById("spawnXpLabel").style.display = wt ? "block" : "none", document.getElementById("spawnXpLabel").textContent = wt, window.onbeforeunload = null)
- }, 2e3);
- break;
- case 4:
- ie(msg);
- break;
- case 19:
- if (t = msg.readUInt32(), t = Ut[t]) a = msg.readString(), t.gotChat(a)
- }
- }
- function te(t) {
- Tt.send(t.dataView.buffer)
- }
- function ee() {
- return null != Tt && Tt.readyState == Tt.OPEN
- }
- var ae = +new Date,
- At = +new Date;
- function ie(t) {
- At = ae = +new Date;
- o_camx = j;
- o_camy = camy;
- n_camx = t.readUInt16() / 4;
- n_camy = t.readUInt16() / 4;
- q = t.readUInt16() / 1e3;
- var e = t.readUInt8();
- Ot(e, 1) || (ft = t.readUInt8(), xp = t.readUInt32(), mt = t.readUInt8());
- for (var a = t.readUInt16(), i = 0; i < a; i++) {
- var n = t.readUInt8(),
- r = t.readUInt32(),
- s = t.readUInt16() / 4,
- l = t.readUInt16() / 4,
- h = t.readUInt16() / 4,
- e = t.readUInt8(),
- o = null;
- 0 < e && (o = Ut[t.readUInt32()]);
- var d = new Ht(r, n, l, h, s);
- Ut.hasOwnProperty(r) && (e = Ut[r], delete Ut[r], e = xt.indexOf(e), -1 != e && xt.splice(e, 1));
- Ut[r] = d;
- xt.push(d);
- o && (d.updateTime = ae, d.nx = d.x, d.ny = d.y, d.ox = o.x, d.oy = o.y, d.x = o.x, d.y = o.y);
- n == k && (r = t.readUInt8(), e = t.readString(), d.nickName = e, d.type = r, d.name = e ? e : "mope.io");
- n == B && 16 == Math.round(s) && (d.type = 4)
- }
- a = t.readUInt16();
- for (i = 0; i < a; i++) {
- r = t.readUInt32();
- l = t.readUInt16() / 4;
- h = t.readUInt16() / 4;
- s = t.readUInt16() / 10;
- if (d = Ut[r]) d.updateTime = ae, d.ox = d.x, d.oy = d.y, d.nx = l, d.ny = h, d.oRad = d.rad, d.nRad = s;
- d && d.oType == k && (s = t.readUInt8(), n = t.readUInt16(), e = t.readUInt8(), d.type = s, s = Bt(n - 90), d.angleDelta = _t(d.angle, s), d.flag_hurt = Ot(e, 7), d.flag_lowWat = Ot(e, 6), s = Ot(e, 5), d.flag_tailBitten = Ot(e, 4), d.flag_tailBitten && r == ht && (oe = "Ouch! Your tail got bitten!", ce = ae + 2e3), s ? (r = t.readUInt8(), .001 > d.hpBarA && (d.hpPer = r), d.hpPer_n = r, d.hpBarA_n = 1) : d.hpBarA_n = 0);
- d || console.log("PROBLEM, NO OBJ!")
- }
- a = t.readUInt16();
- for (r = 0; r < a; r++) d = t.readUInt32(), e = t.readUInt32(), d = Ut[d], e = Ut[e], d && (e ? (d.dead = !0, d.updateTime = ae, d.ox = d.x, d.oy = d.y, d.oRad = d.rad, d.nx = e.nx, d.ny = e.ny, d.nRad = Math.min(d.rad, e.rad), d.hp_n = 0) : (d.dead = !0, d.updateTime = ae, d.ox = d.x, d.oy = d.y, d.oRad = d.rad, d.nx = d.x, d.ny = d.y, d.nRad = 0))
- }
- function ne(t, e) {
- crossHx = t;
- crossHy = e;
- crossL = 30;
- G.beginPath();
- G.moveTo(crossHx, crossHy - crossL / 2);
- G.lineTo(crossHx, crossHy + crossL / 2);
- G.stroke();
- G.moveTo(crossHx - crossL / 2, crossHy);
- G.lineTo(crossHx + crossL / 2, crossHy);
- G.stroke();
- G.closePath()
- }
- function re() {
- G.fillStyle = o;
- G.fillRect(0, 0, it, nt);
- G.save();
- G.strokeStyle = "black";
- G.globalAlpha = .055;
- G.scale(V, V);
- for (var t = it / V, e = nt / V, a = -.5 + (it - j + t / 2) % 30; a < t; a += 30) G.beginPath(), G.moveTo(a, 0), G.lineTo(a, e), G.stroke();
- for (a = -.5 + (nt - camy + e / 2) % 30; a < e; a += 30) G.beginPath(), G.moveTo(0, a), G.lineTo(t, a), G.stroke();
- G.restore()
- }
- function se(t) {
- H = document.createElement("canvas");
- H.width = 180;
- H.height = 180;
- var e = H.getContext("2d");
- e.globalAlpha = .35;
- e.fillStyle = "#000000";
- e.fillRect(0, 0, H.width, H.height);
- var a = t.readUInt16();
- e.fillStyle = m;
- e.globalAlpha = .5;
- for (var i = 0; i < a; i++) {
- var n = .9 * t.readUInt8(),
- r = .9 * t.readUInt8(),
- s = 4.5 * t.readUInt8();
- e.beginPath();
- e.arc(n, r, Math.max(1, 180 / rt * s * 1.2), 0, 2 * Math.PI);
- e.fill()
- }
- a = t.readUInt16();
- e.fillStyle = "#907A33";
- e.globalAlpha = .7;
- for (i = 0; i < a; i++) n = .9 * t.readUInt8(), r = .9 * t.readUInt8(), e.beginPath(), e.arc(n, r, Math.max(2.5, 180 / rt * 110), 0, 2 * Math.PI), e.fill();
- a = t.readUInt16();
- e.fillStyle = c;
- e.globalAlpha = 1;
- for (i = 0; i < a; i++) n = .9 * t.readUInt8(), r = .9 * t.readUInt8(), e.beginPath(), e.arc(n, r, Math.max(2.5, 180 / rt * 50), 0, 2 * Math.PI), e.fill();
- a = t.readUInt16();
- e.fillStyle = u;
- e.globalAlpha = 1;
- for (i = 0; i < a; i++) n = .9 * t.readUInt8(), r = .9 * t.readUInt8(), e.beginPath(), e.arc(n, r, Math.max(3.5, 180 / rt * 40), 0, 2 * Math.PI), e.fill();
- a = t.readUInt16();
- e.fillStyle = m;
- e.globalAlpha = 1;
- for (i = 0; i < a; i++) n = .9 * t.readUInt8(), r = .9 * t.readUInt8(), e.beginPath(), e.arc(n, r, Math.max(4.5, 180 / rt * 50), 0, 2 * Math.PI), e.fill()
- }
- function le(t, e, a) {
- z = null;
- if (0 != t.length) {
- z = document.createElement("canvas");
- e = z.getContext("2d");
- var i;
- i = 55 + 22 * t.length;
- z.width = 180;
- z.height = 1 * i;
- e.scale(1, 1);
- e.globalAlpha = .35;
- e.fillStyle = "#000000";
- e.fillRect(0, 0, 200, i);
- e.globalAlpha = 1;
- e.fillStyle = "#FFFFFF";
- i = "Top Players";
- e.font = "30px Arial";
- e.shadowOffsetX = 1;
- e.shadowOffsetY = 1;
- e.shadowColor = "black";
- e.fillText(i, 90 - e.measureText(i).width / 2, 40);
- var n;
- e.textAlign = "left";
- e.font = "18px Arial";
- for (n = 0; n < t.length; ++n) i = t[n].name || "mope.io", e.fillStyle = a == t[n].rank ? "#FEED92" : "#FFFFFF", i = t[n].rank + ". " + i + " (" + zt(t[n].score) + ")", e.fillText(i, 15, 65 + 22 * n)
- }
- }
- function he() {
- G.save();
- if (ot) {
- water += .1 * (ft - water);
- xpPer += .03 * (mt - xpPer);
- var t = 1,
- e = 25 >= water;
- e && (t = .7 + .3 * Math.sin(2 * Math.PI / 1.2 * (ae / 1e3)));
- var a = Math.min(450, .9 * N.width),
- i = N.width / 2,
- n = N.height - 60;
- G.globalAlpha = .35 * t;
- G.fillStyle = "#000000";
- G.fillRect(i - a / 2, n - 15, a, 30);
- G.globalAlpha = t;
- G.fillStyle = m;
- G.fillRect(i - a / 2, n - 15, water / 100 * a, 30);
- G.fillStyle = et ? e ? u : "orange" : e ? u : "white";
- G.globalAlpha = 1 * t;
- G.font = "22px Arial";
- G.lineWidth = 1;
- G.textAlign = "center";
- G.textBaseline = "middle";
- G.shadowColor = "black";
- e ? (G.shadowOffsetX = 0, G.shadowOffsetY = 0) : (G.shadowOffsetX = 1, G.shadowOffsetY = 1);
- G.fillText(e ? "LOW Water" : "Water", i, n);
- G.shadowOffsetX = 0;
- G.shadowOffsetY = 0;
- G.globalAlpha = .35;
- G.fillStyle = "#000000";
- n = N.height - 15 - 5;
- a = .9 * N.width;
- G.fillRect(i - a / 2, n - 15, a, 30);
- G.globalAlpha = 1;
- G.fillStyle = "#F3C553";
- G.fillRect(i - a / 2, n - 15, xpPer / 100 * a, 30);
- G.fillStyle = "white";
- G.globalAlpha = 1;
- G.shadowOffsetX = 1;
- G.shadowOffsetY = 1;
- G.shadowColor = "black";
- G.fillText("" + zt(xp) + " xp (" + zt(It) + " xp Next Animal)", i, n);
- G.shadowOffsetX = 0;
- G.shadowOffsetY = 0
- }
- G.restore()
- }
- var oe = "Ready to survive!",
- de = "white",
- ce = +new Date + 0;
- function fe() {
- var t = (ce - ae) / 1e3 / 1,
- t = 0 > t ? 0 : 1 < t ? 1 : t;
- 0 >= t || (G.save(), G.font = "25px Arial", G.lineWidth = 1, G.textAlign = "center", G.textBaseline = "middle", G.shadowOffsetX = 1, G.shadowOffsetY = 1, G.shadowColor = "#000000", G.fillStyle = de, G.globalAlpha = t, Xt(oe, N.width / 2, N.height / 2 - 220), G.restore())
- }
- function me(t) {
- ae = +new Date;
- window.requestAnimationFrame(me);
- G.clearRect(0, 0, N.width, N.height);
- t = (ae - At) / 1e3 / .2;
- t = 0 > t ? 0 : 1 < t ? 1 : t;
- j = t * (n_camx - o_camx) + o_camx;
- camy = t * (n_camy - o_camy) + o_camy;
- V += .05 * (q - V);
- pe();
- re();
- G.save();
- t = it / 2;
- var e = nt / 2;
- G.translate(t * (1 - V) + (t - j) * V, e * (1 - V) + (e - camy) * V);
- G.scale(V, V);
- G.save();
- ct && (t = 10, t = 600, G.globalAlpha = .5, G.fillStyle = f, G.fillRect(0 - t, 0 - t, rt + 2 * t, t), G.fillRect(0 - t, -.5, t, st + 1), G.fillRect(rt, -.5, t, st + 1), G.fillRect(0 - t, st, rt + 2 * t, t));
- G.restore();
- vt = [];
- for (d = 0; d < xt.length; d++) xt[d].updateZ();
- xt.sort(function(t, e) {
- return t.z == e.z ? t.id - e.id : t.z - e.z
- });
- for (d = 0; d < xt.length; d++) xt[d].draw();
- for (d = 0; d < xt.length; d++) xt[d].oType != k && xt[d].oType != F && xt[d].oType != W || xt[d].drawChat();
- for (d = 0; d < vt.length; d++) t = vt[d], Ut.hasOwnProperty(t.id) && delete Ut[t.id], t = xt.indexOf(t), -1 != t && xt.splice(t, 1);
- G.restore();
- fe();
- he();
- ot && (z && z.width && G.drawImage(z, 10, 10), H && H.width && G.drawImage(H, N.width - (10 + H.width), 10), t = Ut[ht]) && (G.fillStyle = "white", G.beginPath(), G.arc(N.width - (10 + H.width) + H.width / rt * t.x, 10 + H.height / st * t.y, 3, 0, 2 * Math.PI), G.fill());
- G.save();
- G.font = "14px Arial";
- G.lineWidth = 1;
- G.textAlign = "right";
- G.textBaseline = "bottom";
- G.shadowOffsetX = 1;
- G.shadowOffsetY = 1;
- G.shadowColor = "#000000";
- G.fillStyle = "white";
- G.fillText(lt, N.width - 5, N.height - 2);
- G.restore()
- }
- window.requestAnimationFrame ? window.requestAnimationFrame(me) : setInterval(draw, 1e3 / 60);
- function ge(t) {
- playerName = nickInput.value.replace(/(<([^>]+)>)/gi, "").substring(0, 25);
- mes = new Vt(9 + Lt(playerName).length);
- mes.writeUInt8(2);
- mes.writeUInt8(0);
- mes.writeString(playerName);
- mes.writeUInt8(t ? 2 : 1);
- mes.writeUInt16(N.width);
- mes.writeUInt16(N.height);
- te(mes);
- t || "undefined" !== typeof Storage && localStorage.setItem("nick", playerName + "")
- }
- document.getElementById("startButton").onclick = function() {
- document.getElementById("spawn_cell").play();
- ee() && ge(!1)
- };
- var ue = !1;
- document.onkeypress = function(t) {
- if (ue || 119 != t.keyCode) {
- if (13 == t.keyCode && ot && !spectating) {
- var e = document.getElementById("chatinput");
- if (!ue) e.style.visibility = "visible", e.focus(), ue = !0;
- else if (13 == t.keyCode) {
- ue = !1;
- e.style.visibility = "hidden";
- e.blur();
- var a = e.value;
- e.value = "";
- 0 < a.length && (newMsg = new Vt(3 + a.length), newMsg.writeUInt8(19), newMsg.writeString(a), te(newMsg))
- }
- }
- 13 != t.keyCode || ot || document.getElementById("startButton").click()
- } else Ie()
- };
- window.onresize = ye;
- function ye() {
- it = window.innerWidth;
- nt = window.innerHeight;
- N.width = it;
- N.height = nt;
- document.getElementById("chatinput").style.marginTop = N.height / 2 - 50 + "px";
- ee() && (mes = new Vt(5), mes.writeUInt8(17), mes.writeUInt16(N.width), mes.writeUInt16(N.height), te(mes))
- }
- ye();
- N.addEventListener("gesturestart", function(t) {
- t.preventDefault()
- });
- N.ontouchstart = function(t) {
- t = t.originalEvent.touches[0];
- console.log("touch statart");
- Z = t.p.pageX;
- J = t.pageY;
- pe()
- };
- N.ontouchmove = function(t) {
- t.preventDefault();
- t = t.touches[0];
- t = new MouseEvent("mousemove", {
- clientX: t.clientX,
- clientY: t.clientY
- });
- N.dispatchEvent(t)
- };
- N.onmousemove = function(t) {
- Z = t.clientX;
- J = t.clientY;
- pe()
- };
- N.onmousedown = function(t) {
- 1 == t.which && (et = !0, ee() && ot && !spectating && (we(), mes = new Vt(2), mes.writeUInt8(21), mes.writeUInt8(1), te(mes)));
- 3 == t.which && Ie()
- };
- N.onmouseup = function(t) {
- 1 == t.which && (et && (mes = new Vt(2), mes.writeUInt8(21), mes.writeUInt8(0), te(mes)), et = !1)
- };
- N.onblur = function(t) {
- et && (mes = new Vt(2), mes.writeUInt8(21), mes.writeUInt8(0), te(mes));
- et = !1
- };
- window.onmouseout = function(t) {
- null == t.toElement && null == t.relatedTarget && (et && (mes = new Vt(2), mes = new Vt(2), mes.writeUInt8(21), mes.writeUInt8(0), wsSeSendMsg(mes)), et = !1)
- };
- window.onmouseout = function(t) {
- null == t.toElement && null == t.relatedTarget && (et && (mes = new Vt(2), mes.writeUInt8(21), mes.writeUInt8(0), te(mes)), mouseLLeftDown = !1)
- };
- document.oncontextmenu = document.body.oncontextmenu = function() {
- return !1
- };
- function pe() {
- var t = it / 2,
- e = nt / 2;
- $ = K;
- tt = Q;
- K = (Z - (t - j * V)) / V;
- Q = (J - (e - camy * V)) / V
- }
- function we() {
- ee() && ot && !spectating && (.1 < Math.abs($ - K) || .1 < Math.abs(tt - Q)) && (mes = new Vt(6), mes.writeUInt8(5), mes.writeInt16(K), mes.writeInt16(Q), te(mes))
- }
- function Ie() {
- ee() && ot && !spectating && (we(), mes = new Vt(1), mes.writeUInt8(20), te(mes))
- }
- setInterval(we, 40);
- window.onload = function() {
- Kt(s);
- if ("undefined" !== typeof Storage) {
- var t = document.getElementById("nickInput");
- t.value = localStorage.getItem("nick");
- t.setSelectionRange(0, t.value.length);
- t.focus()
- }
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement