Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (async function IncrementalityGame() {
- /* ═══════════════════════════════════════════════
- INCREMENTALLITY v1.4.2
- ═══════════════════════════════════════════════ */
- await new Promise((res, rej) => {
- if (typeof Decimal !== "undefined") return res();
- const s = document.createElement("script");
- s.src = "https://cdn.jsdelivr.net/npm/break_eternity.js";
- s.onload = res;
- s.onerror = () => {
- const s2 = document.createElement("script");
- s2.src = "https://unpkg.com/break_eternity.js";
- s2.onload = res;
- s2.onerror = rej;
- document.head.appendChild(s2);
- };
- document.head.appendChild(s);
- });
- const D = v => new Decimal(v);
- const COOLDOWN = 5;
- const WIN_W = 60;
- const WIN_H = 24;
- const UPG_PER_PAGE = 3;
- let running = false;
- let stopped = false;
- let points = D(0);
- let pointGain = D(1);
- let gx = 0, gy = 0;
- let selfSending = false;
- let currentPage = 1;
- let renderBusy = false;
- let automationOn = false;
- let boosterOn = false;
- let fullAutoOn = false;
- let rbPointBoost = false;
- let rbDoubler = false;
- let rbX2Level = 0;
- let rebirths = 0;
- let increments = D(0);
- let greaterGainMul = D(1);
- const timers = [];
- const rebirthPages = [];
- /* ══════════════════════════════════════
- SOFTCAP SYSTEM
- ══════════════════════════════════════
- Thresholds per upgrade level:
- softcap = base * 50
- softcap^2 = base * 500
- softcap^3 = base * 5000
- hardcap = base * 50000
- At softcap: cost scaling *= 2
- At softcap^2: cost scaling *= 4
- At softcap^3: cost scaling *= 8
- At hardcap: cannot buy more
- For prestige (increment) gains:
- softcap at 1e20 Inc earned
- softcap^2 at 1e40
- softcap^3 at 1e60
- hardcap at 1e80
- */
- const SOFTCAP_THRESHOLDS = {
- 1: { sc:50, sc2:500, sc3:5000, hc:50000 },
- 2: { sc:30, sc2:300, sc3:3000, hc:30000 },
- 3: { sc:40, sc2:400, sc3:4000, hc:40000 },
- 4: { sc:1, sc2:1, sc3:1, hc:1 },
- 5: { sc:20, sc2:200, sc3:2000, hc:20000 },
- 6: { sc:1, sc2:1, sc3:1, hc:1 },
- 7: { sc:25, sc2:250, sc3:2500, hc:25000 }
- };
- const INC_SOFTCAPS = {
- sc: D("1e20"),
- sc2: D("1e40"),
- sc3: D("1e60"),
- hc: D("1e80")
- };
- function getSoftcapLabel(upgId, level) {
- const t = SOFTCAP_THRESHOLDS[upgId];
- if (!t) return "";
- if (level >= t.hc) return " [HARDCAP]";
- if (level >= t.sc3) return " [SC^3]";
- if (level >= t.sc2) return " [SC^2]";
- if (level >= t.sc) return " [SC]";
- return "";
- }
- function getCostMultiplier(upgId, level) {
- const t = SOFTCAP_THRESHOLDS[upgId];
- if (!t) return 1;
- if (level >= t.sc3) return 8;
- if (level >= t.sc2) return 4;
- if (level >= t.sc) return 2;
- return 1;
- }
- function isHardcapped(upgId, level) {
- const t = SOFTCAP_THRESHOLDS[upgId];
- if (!t) return false;
- return level >= t.hc;
- }
- function applyIncSoftcap(raw) {
- raw = D(raw);
- if (raw.gte(INC_SOFTCAPS.hc)) return INC_SOFTCAPS.hc;
- if (raw.gte(INC_SOFTCAPS.sc3)) {
- const over = raw.div(INC_SOFTCAPS.sc3);
- return INC_SOFTCAPS.sc3.mul(over.pow(0.125));
- }
- if (raw.gte(INC_SOFTCAPS.sc2)) {
- const over = raw.div(INC_SOFTCAPS.sc2);
- return INC_SOFTCAPS.sc2.mul(over.pow(0.25));
- }
- if (raw.gte(INC_SOFTCAPS.sc)) {
- const over = raw.div(INC_SOFTCAPS.sc);
- return INC_SOFTCAPS.sc.mul(over.pow(0.5));
- }
- return raw;
- }
- function getIncSoftcapLabel(raw) {
- raw = D(raw);
- if (raw.gte(INC_SOFTCAPS.hc)) return " [HC]";
- if (raw.gte(INC_SOFTCAPS.sc3)) return " [SC^3]";
- if (raw.gte(INC_SOFTCAPS.sc2)) return " [SC^2]";
- if (raw.gte(INC_SOFTCAPS.sc)) return " [SC]";
- return "";
- }
- function defaultUpgrades() {
- return [
- { id:1, name:"Increase point gain", cost:D(10), level:0, scaling:1.5, maxBuy:-1 },
- { id:2, name:"Multiplication (x3)", cost:D(50), level:0, scaling:2.5, maxBuy:-1 },
- { id:3, name:"Cheaper stuff (/1.5)", cost:D(100), level:0, scaling:3, maxBuy:-1 },
- { id:4, name:"Automation [ONE-TIME]", cost:D(1000), level:0, scaling:1, maxBuy:1 },
- { id:5, name:"Exponentiation (^1.1)", cost:D(17500), level:0, scaling:3, maxBuy:-1 },
- { id:6, name:"Booster [ONE-TIME]", cost:D(1e5), level:0, scaling:1, maxBuy:1 },
- { id:7, name:"Greater Gain (+25%)", cost:D(1e7), level:0, scaling:4, maxBuy:-1 }
- ];
- }
- function defaultRebirthUpgrades() {
- return [
- { id:"R1", name:"Point Booster [1x]", cost:D(10), level:0, scaling:1, maxBuy:1,
- desc:"Boost pts by Inc count" },
- { id:"R2", name:"Full Automation [1x]", cost:D(30), level:0, scaling:1, maxBuy:1,
- desc:"Auto 50 lvls every 10s" },
- { id:"R3", name:"Doubler [1x]", cost:D(100), level:0, scaling:1, maxBuy:1,
- desc:"Double rebirth Inc gain" },
- { id:"R4", name:"x2 Rebirth Gain", cost:D(50), level:0, scaling:2.5, maxBuy:-1,
- desc:"x2 Inc gain (stacks)" }
- ];
- }
- let upgrades = defaultUpgrades();
- let rebirthUpgrades = defaultRebirthUpgrades();
- /* ══════════════════════════════════════
- HELPERS
- ══════════════════════════════════════ */
- const sleep = ms => new Promise(r => setTimeout(r, ms));
- function formatNum(n) {
- n = D(n);
- if (n.isNan()) return "NaN";
- if (!n.isFinite()) return "Inf";
- if (n.eq(0)) return "0";
- if (n.lt(0)) return "-" + formatNum(n.neg());
- if (n.lt(1e4)) {
- const v = n.toNumber();
- if (Math.abs(v - Math.round(v)) < 0.005) return String(Math.round(v));
- return v.toFixed(2);
- }
- if (n.layer > 1) return n.toString();
- const exp = n.log10().floor();
- const man = n.div(Decimal.pow(10, exp));
- return man.toNumber().toFixed(2) + "e" + exp.toNumber();
- }
- function roundCost(d) {
- d = D(d);
- if (d.lt(0.01)) return D(0.01);
- if (d.lt(1e13)) return D(Math.round(d.toNumber() * 100) / 100);
- return d.floor();
- }
- function fit(s, ww) { return s.length >= ww ? s.slice(0, ww) : s.padEnd(ww); }
- async function typeAt(str, color, x, y) {
- for (let i = 0; i < str.length; i++) {
- if (stopped) return;
- writeCharAt(str[i], color, x + i, y);
- await sleep(COOLDOWN);
- }
- }
- async function chatSend(msg) {
- selfSending = true;
- try { w.chat.send(msg); } catch (_) {}
- await sleep(150);
- selfSending = false;
- }
- function calcIncrements(pts) {
- pts = D(pts);
- if (pts.lt(1e10)) return D(0);
- const logP = pts.max(1).log10().toNumber();
- let earned = D(Math.floor(Math.pow(logP, 1.5) / 5));
- // R3 doubler
- if (rbDoubler) earned = earned.mul(2);
- // R4 x2 stacking
- if (rbX2Level > 0) earned = earned.mul(D(2).pow(rbX2Level));
- // softcap
- earned = applyIncSoftcap(earned);
- return earned;
- }
- function calcRawIncrements(pts) {
- pts = D(pts);
- if (pts.lt(1e10)) return D(0);
- const logP = pts.max(1).log10().toNumber();
- let earned = D(Math.floor(Math.pow(logP, 1.5) / 5));
- if (rbDoubler) earned = earned.mul(2);
- if (rbX2Level > 0) earned = earned.mul(D(2).pow(rbX2Level));
- return earned;
- }
- /* ══════════════════════════════════════════════════════
- RAW CHAT EXTRACTION — ALL USERS, EXHAUSTIVE
- ══════════════════════════════════════════════════════ */
- const dedupSet = new Map();
- function processRaw(text, source) {
- if (!text || stopped || !running) return;
- text = String(text).trim();
- if (!text || text.length > 600) return;
- // dedup
- const key = text.toLowerCase() + "|" + Math.floor(Date.now() / 900);
- if (dedupSet.has(key)) return;
- dedupSet.set(key, true);
- setTimeout(() => dedupSet.delete(key), 2500);
- // log raw
- console.log(`[RAW ${source || "?"}] ${text}`);
- // check for tilda pattern: anything ~ /command
- const tildaMatch = text.match(/^(.+?)\s*~\s*(.+)$/);
- if (tildaMatch) {
- const afterTilda = tildaMatch[2].trim();
- if (afterTilda.startsWith("/")) {
- console.log(`[CMD from tilda] ${afterTilda}`);
- handleCmd(afterTilda, tildaMatch[1].trim());
- return;
- }
- }
- // extract message from common formats
- let user = "unknown";
- let msg = text;
- for (const pat of [
- /^([^:]{1,30}):\s*(.+)/,
- /^\[([^\]]{1,30})\]\s*(.+)/,
- /^<([^>]{1,30})>\s*(.+)/,
- /^(\S{1,30})\s*[»>]\s*(.+)/
- ]) {
- const m = text.match(pat);
- if (m) { user = m[1].trim(); msg = m[2].trim(); break; }
- }
- if (!msg) return;
- console.log(`${user} ~ ${msg}`);
- if (msg.startsWith("/")) handleCmd(msg, user);
- }
- function extractField(d) {
- if (!d) return "";
- if (typeof d === "string") return d;
- return d.message || d.msg || d.text || d.content || d.body ||
- d.value || d.chat || d.line || d.raw ||
- (typeof d.data === "string" ? d.data : "") || "";
- }
- function tryProcess(d, src) {
- if (!d) return;
- if (typeof d === "string") { processRaw(d, src); return; }
- const m = extractField(d);
- if (typeof m === "string" && m) processRaw(m, src);
- if (Array.isArray(d)) d.forEach(x => tryProcess(x, src));
- }
- (function setupChat() {
- /* 1 w.chat.send intercept */
- try {
- const real = w.chat.send.bind(w.chat);
- w.chat.send = function (m) {
- const r = real(m);
- if (!selfSending) processRaw(m, "send-hook");
- return r;
- };
- } catch (e) { console.warn("[Inc] hook-send:", e); }
- /* 2 w.on multiple events */
- try {
- if (typeof w.on === "function")
- for (const ev of ["chat","message","receive","msg","data","say","talk","text"])
- try { w.on(ev, (...a) => a.forEach(x => tryProcess(x, "w.on-" + ev))); } catch (_) {}
- } catch (_) {}
- /* 3 w.events */
- try {
- if (w.events) {
- const hookEm = em => {
- if (!em) return;
- if (typeof em.on === "function")
- for (const ev of ["chat","message","receive","msg","data"])
- try { em.on(ev, d => tryProcess(d, "events-" + ev)); } catch (_) {}
- if (typeof em.addEventListener === "function")
- for (const ev of ["chat","message"])
- try { em.addEventListener(ev, d => tryProcess(d, "events-ael-" + ev)); } catch (_) {}
- };
- if (typeof w.events === "function") try { hookEm(w.events()); } catch (_) {}
- hookEm(w.events);
- }
- } catch (_) {}
- /* 4 w.chat.on */
- try {
- if (w.chat) {
- if (typeof w.chat.on === "function")
- for (const ev of ["message","receive","msg","data","chat","text"])
- try { w.chat.on(ev, d => tryProcess(d, "chat.on-" + ev)); } catch (_) {}
- if (typeof w.chat.addEventListener === "function")
- for (const ev of ["message","chat","data"])
- try { w.chat.addEventListener(ev, d => tryProcess(d, "chat.ael-" + ev)); } catch (_) {}
- }
- } catch (_) {}
- /* 5 w.on numeric codes */
- try {
- if (typeof w.on === "function")
- for (let code = 0; code <= 30; code++)
- try {
- w.on(code, (...a) => {
- for (const item of a) {
- if (!item) continue;
- const s = typeof item === "string" ? item : extractField(item);
- if (s && typeof s === "string" && s.length > 0 && s.length < 500)
- processRaw(s, `w.on(${code})`);
- }
- });
- } catch (_) {}
- } catch (_) {}
- /* 6 w.emit/trigger intercept */
- try {
- for (const fn of ["emit","trigger","fire","dispatch","publish","broadcast"]) {
- if (w[fn] && typeof w[fn] === "function") {
- const orig = w[fn].bind(w);
- w[fn] = function (evt, ...args) {
- const en = String(evt).toLowerCase();
- if (en.includes("chat") || en.includes("message") || en.includes("msg") || en.includes("say"))
- args.forEach(a => tryProcess(a, `w.${fn}-${evt}`));
- return orig(evt, ...args);
- };
- }
- }
- } catch (_) {}
- /* 7 WebSocket */
- try {
- function hookWS(sock) {
- if (!sock || sock.__inc142) return;
- sock.__inc142 = true;
- sock.addEventListener("message", function (ev) {
- try {
- if (typeof ev.data === "string") {
- // raw first
- if (ev.data.length > 1 && ev.data.length < 500)
- processRaw(ev.data, "ws-raw");
- // also try json walk
- try { walk(JSON.parse(ev.data), "ws-json"); } catch (_) {}
- }
- } catch (_) {}
- });
- }
- function walk(o, src) {
- if (!o) return;
- if (typeof o === "string") { if (o.length < 500) processRaw(o, src); return; }
- if (Array.isArray(o)) { o.forEach(x => walk(x, src)); return; }
- if (typeof o !== "object") return;
- const k = (o.kind || o.type || o.event || o.channel || o.action || o.cmd || o.op || "").toString().toLowerCase();
- if (k.includes("chat") || k.includes("message") || k.includes("msg") || k.includes("say") || k.includes("talk")) {
- const m = o.message || o.msg || o.text || o.content || o.body || o.value || o.line || o.raw || "";
- if (m) {
- const user = o.user || o.username || o.nick || o.nickname || o.sender || o.from || o.author || o.name || o.player || "";
- processRaw(user ? `${user}: ${m}` : String(m), src + "-walk");
- }
- }
- for (const fld of ["data","payload","events","messages","chat","result","results","items","list","entries","lines","logs"])
- if (o[fld]) {
- if (Array.isArray(o[fld])) o[fld].forEach(x => walk(x, src));
- else if (typeof o[fld] === "object") walk(o[fld], src);
- else if (typeof o[fld] === "string" && o[fld].length < 500) processRaw(o[fld], src + "-" + fld);
- }
- }
- const socks = new Set();
- for (const k of ["socket","ws","conn","websocket","_socket","_ws","net","connection","sock","_conn","wss","io"]) {
- try { if (w[k] instanceof WebSocket) socks.add(w[k]); } catch (_) {}
- try { if (w[k] && w[k].socket instanceof WebSocket) socks.add(w[k].socket); } catch (_) {}
- try { if (w[k] && w[k].ws instanceof WebSocket) socks.add(w[k].ws); } catch (_) {}
- try { if (w[k] && w[k]._socket instanceof WebSocket) socks.add(w[k]._socket); } catch (_) {}
- }
- try { Object.keys(w).forEach(k => { try { if (w[k] instanceof WebSocket) socks.add(w[k]); } catch (_) {} }); } catch (_) {}
- try { Object.keys(window).forEach(k => { try { if (window[k] instanceof WebSocket) socks.add(window[k]); } catch (_) {} }); } catch (_) {}
- try {
- for (const gk of Object.keys(window))
- try {
- const obj = window[gk];
- if (obj && typeof obj === "object")
- for (const sk of Object.keys(obj))
- try { if (obj[sk] instanceof WebSocket) socks.add(obj[sk]); } catch (_) {}
- } catch (_) {}
- } catch (_) {}
- socks.forEach(hookWS);
- const OrigWS = window.WebSocket;
- window.WebSocket = function (...a) {
- const s = new OrigWS(...a);
- setTimeout(() => hookWS(s), 50);
- return s;
- };
- window.WebSocket.prototype = OrigWS.prototype;
- for (const c of ["CONNECTING","OPEN","CLOSING","CLOSED"])
- window.WebSocket[c] = OrigWS[c];
- } catch (e) { console.warn("[Inc] hook-ws:", e); }
- /* 8 XHR */
- try {
- const origOpen = XMLHttpRequest.prototype.open;
- const origSend = XMLHttpRequest.prototype.send;
- XMLHttpRequest.prototype.open = function (m, url, ...r) { this.__incUrl = url; return origOpen.call(this, m, url, ...r); };
- XMLHttpRequest.prototype.send = function (body) {
- this.addEventListener("load", function () {
- try {
- const url = (this.__incUrl || "").toLowerCase();
- if (url.includes("chat") || url.includes("message") || url.includes("msg")) {
- const txt = this.responseText;
- if (txt && txt.length < 5000) processRaw(txt, "xhr-raw");
- }
- } catch (_) {}
- });
- return origSend.call(this, body);
- };
- } catch (_) {}
- /* 9 fetch */
- try {
- const origFetch = window.fetch;
- window.fetch = async function (url, ...rest) {
- const resp = await origFetch.call(this, url, ...rest);
- try {
- const urlStr = (typeof url === "string" ? url : url.url || "").toLowerCase();
- if (urlStr.includes("chat") || urlStr.includes("message"))
- resp.clone().text().then(txt => {
- if (txt && txt.length < 5000) processRaw(txt, "fetch-raw");
- }).catch(() => {});
- } catch (_) {}
- return resp;
- };
- } catch (_) {}
- /* 10 DOM MutationObserver */
- try {
- const obs = new Set();
- const sels = [
- "#chat","#chatbox","#chat-messages",".chat-messages",
- "#chatOutput",".chatOutput","#chat_window","#chat_open",
- "#chat_messages",".chat-inner",".chat-log","#chat-log",
- ".messages","#messages",".chat-body","[data-chat]",
- "#chat-content",".chat-content","#chatlog",".chatlog",
- "#msg-container",".msg-container","#chat-area",".chat-area",
- "[class*='chat']","[id*='chat']","[class*='message']","[id*='message']"
- ];
- function observeEl(el) {
- if (obs.has(el)) return; obs.add(el);
- new MutationObserver(muts => {
- for (const m of muts)
- for (const nd of m.addedNodes) {
- const t = (nd.textContent || "").trim();
- if (t && t.length < 500) processRaw(t, "dom-obs");
- }
- }).observe(el, { childList: true, subtree: true });
- }
- sels.forEach(sel => { try { document.querySelectorAll(sel).forEach(observeEl); } catch (_) {} });
- setInterval(() => {
- sels.forEach(sel => { try { document.querySelectorAll(sel).forEach(observeEl); } catch (_) {} });
- }, 3000);
- } catch (_) {}
- /* 11 DOM polling */
- let lastPoll = "";
- setInterval(() => {
- try {
- for (const sel of ["#chat","#chatbox",".chat-messages","#chat-messages","#chatlog",".chatlog"]) {
- const el = document.querySelector(sel);
- if (!el) continue;
- const cur = el.innerText || el.textContent || "";
- if (cur !== lastPoll && cur.length > lastPoll.length) {
- const diff = cur.slice(lastPoll.length).trim();
- lastPoll = cur;
- if (diff) diff.split("\n").forEach(l => { l = l.trim(); if (l) processRaw(l, "dom-poll"); });
- } else lastPoll = cur;
- break;
- }
- } catch (_) {}
- }, 350);
- /* 12 Keyboard Enter */
- try {
- document.addEventListener("keydown", function (e) {
- if (e.key !== "Enter") return;
- const el = document.activeElement;
- if (!el) return;
- const tag = el.tagName.toLowerCase();
- if ((tag === "input" || tag === "textarea") &&
- ((el.id || "").toLowerCase().includes("chat") ||
- (el.className || "").toLowerCase().includes("chat") ||
- (el.placeholder || "").toLowerCase().includes("chat") ||
- (el.name || "").toLowerCase().includes("chat"))) {
- const val = el.value.trim();
- if (val) setTimeout(() => processRaw(val, "input-enter"), 50);
- }
- }, true);
- } catch (_) {}
- /* 13 SSE */
- try {
- const OrigES = window.EventSource;
- if (OrigES) {
- window.EventSource = function (url, ...rest) {
- const es = new OrigES(url, ...rest);
- if ((url || "").toLowerCase().match(/chat|message/))
- es.addEventListener("message", ev => { if (ev.data) processRaw(ev.data, "sse-raw"); });
- return es;
- };
- window.EventSource.prototype = OrigES.prototype;
- }
- } catch (_) {}
- /* 14 BroadcastChannel */
- try {
- const OrigBC = window.BroadcastChannel;
- if (OrigBC) {
- window.BroadcastChannel = function (name) {
- const bc = new OrigBC(name);
- if ((name || "").toLowerCase().match(/chat|message/))
- bc.addEventListener("message", ev => tryProcess(ev.data, "bc"));
- return bc;
- };
- }
- } catch (_) {}
- })();
- /* ── Startup ── */
- console.log("[Incrementallity v1.4.2] Console: quit() info()");
- await chatSend("Incrementallity v1.4.2");
- /* ══════════════════════════════════════
- HUD PANEL
- ══════════════════════════════════════ */
- const shade = document.createElement("div");
- shade.style.cssText = "position:fixed;inset:0;background:rgba(0,0,0,.55);z-index:999998";
- const hud = document.createElement("div");
- hud.style.cssText = `
- position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);
- background:#0f172a;border:2px solid #f43f5e;border-radius:14px;
- padding:28px 34px;z-index:999999;color:#e2e8f0;
- font-family:'Courier New',monospace;
- box-shadow:0 0 50px rgba(244,63,94,.45);min-width:380px`;
- hud.innerHTML = `
- <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:20px">
- <span style="font-size:17px;font-weight:700;color:#f43f5e">⚙ Generate the Game at</span>
- <button id="_ic_close" style="background:#f43f5e;color:#fff;border:none;border-radius:4px;
- padding:6px 18px;font-size:13px;cursor:pointer;font-family:monospace;font-weight:700">✕ Close</button>
- </div>
- <label style="font-size:12px;color:#94a3b8">X Coordinate</label>
- <input id="_ic_x" type="text" value="0" style="display:block;width:100%;padding:8px 10px;margin:4px 0 14px;
- background:#1e293b;border:1px solid #334155;border-radius:8px;color:#e2e8f0;font-family:monospace;font-size:14px;box-sizing:border-box">
- <label style="font-size:12px;color:#94a3b8">Y Coordinate</label>
- <input id="_ic_y" type="text" value="0" style="display:block;width:100%;padding:8px 10px;margin:4px 0 22px;
- background:#1e293b;border:1px solid #334155;border-radius:8px;color:#e2e8f0;font-family:monospace;font-size:14px;box-sizing:border-box">
- <button id="_ic_go" style="width:100%;padding:13px;background:linear-gradient(135deg,#f43f5e,#e11d48);color:#fff;
- border:none;border-radius:10px;font-size:15px;font-weight:700;cursor:pointer;font-family:monospace;letter-spacing:1px">▶ SUBMIT</button>
- <p style="text-align:center;margin:16px 0 0;color:#475569;font-size:11px">Incrementallity v1.4.2</p>`;
- document.body.appendChild(shade);
- document.body.appendChild(hud);
- function closeHUD() { shade.remove(); hud.remove(); }
- document.getElementById("_ic_close").onclick = () => { closeHUD(); stopped = true; timers.forEach(clearInterval); };
- document.getElementById("_ic_go").onclick = async () => {
- if (running) return;
- running = true;
- gx = parseInt(document.getElementById("_ic_x").value) || 0;
- gy = -(parseInt(document.getElementById("_ic_y").value) || 0);
- closeHUD();
- await launch();
- };
- /* ══════════════════════════════════════
- GAME LAUNCHER
- ══════════════════════════════════════ */
- async function launch() {
- await typeAt("Load....", "#f43f5e", gx, gy);
- await sleep(3000);
- for (let i = 0; i < 8; i++) { writeCharAt(" ", "#000000", gx + i, gy); await sleep(COOLDOWN); }
- await drawWindow();
- await render();
- await sleep(100);
- await chatSend("/upg N | /rebirth | /page CMD for all commands");
- startTicks();
- }
- async function drawWindow() {
- const inner = WIN_W - 2;
- await typeAt("╔" + "═".repeat(inner) + "╗", "#f43f5e", gx, gy);
- await typeAt("║" + " Incrementallity v1.4.2 ".padEnd(inner) + "║", "#fbbf24", gx, gy + 1);
- await typeAt("╠" + "═".repeat(inner) + "╣", "#f43f5e", gx, gy + 2);
- for (let r = 3; r < WIN_H - 1; r++)
- await typeAt("║" + " ".repeat(inner) + "║", "#f43f5e", gx, gy + r);
- await typeAt("╚" + "═".repeat(inner) + "╝", "#f43f5e", gx, gy + WIN_H - 1);
- }
- /* ══════════════════════════════════════ */
- function startTicks() {
- timers.push(setInterval(() => {
- if (stopped) return;
- let gain = pointGain.mul(greaterGainMul);
- if (boosterOn) gain = gain.add(points.max(1).pow(0.05));
- if (rbPointBoost) gain = gain.mul(increments.max(1).pow(0.3).add(1));
- points = points.add(gain);
- }, 1000));
- timers.push(setInterval(async () => {
- if (renderBusy || stopped) return;
- renderBusy = true; await render(); renderBusy = false;
- }, 500));
- timers.push(setInterval(() => {
- if (stopped || !automationOn) return;
- for (const u of upgrades)
- if (u.id >= 1 && u.id <= 3 && (u.maxBuy === -1 || u.level < u.maxBuy) && !isHardcapped(u.id, u.level))
- if (points.gte(u.cost)) buyUpgrade(u, true);
- }, 1000));
- timers.push(setInterval(() => {
- if (stopped || !fullAutoOn) return;
- for (let rep = 0; rep < 50; rep++)
- for (const u of upgrades)
- if ((u.maxBuy === -1 || u.level < u.maxBuy) && !isHardcapped(u.id, u.level) && points.gte(u.cost))
- buyUpgrade(u, true);
- }, 10000));
- }
- /* ══════════════════════════════════════
- RENDER
- ══════════════════════════════════════ */
- async function render() {
- const ix = gx + 2, iy = gy + 3, iw = WIN_W - 4;
- let effGain = pointGain.mul(greaterGainMul);
- if (boosterOn) effGain = effGain.add(points.max(1).pow(0.05));
- if (rbPointBoost) effGain = effGain.mul(increments.max(1).pow(0.3).add(1));
- await typeAt(fit(`Pts: ${formatNum(points)} (+${formatNum(effGain)}/s)`, iw), "#34d399", ix, iy);
- let iLine = `Inc: ${formatNum(increments)} | RB: ${rebirths}`;
- if (points.gte(1e10)) {
- const pend = calcIncrements(points);
- const raw = calcRawIncrements(points);
- const scl = getIncSoftcapLabel(raw);
- iLine += ` | Next: +${formatNum(pend)}${scl}`;
- }
- await typeAt(fit(iLine, iw), "#e879f9", ix, iy + 1);
- let flags = "";
- if (automationOn) flags += "[AUTO] ";
- if (fullAutoOn) flags += "[FULL-AUTO] ";
- if (boosterOn) flags += "[BOOST] ";
- if (rbPointBoost) flags += "[RB-BOOST] ";
- if (rbDoubler) flags += "[2x INC] ";
- if (rbX2Level > 0) flags += `[x${D(2).pow(rbX2Level).toString()} RB] `;
- if (greaterGainMul.gt(1)) flags += `[GG x${formatNum(greaterGainMul)}]`;
- await typeAt(fit(flags, iw), "#a78bfa", ix, iy + 2);
- const showRbPage = typeof currentPage === "string" && currentPage.startsWith("B");
- const showRuPage = currentPage === "RU";
- const showCmdPage = currentPage === "CMD";
- if (showCmdPage) {
- /* ── Commands Page ── */
- await typeAt(fit("──── Commands ────", iw), "#fbbf24", ix, iy + 4);
- const cmds = [
- "/upg N - Buy upgrade N",
- "/upg N max - Buy upgrade N to max",
- "/upg all - Buy all upgrades x1",
- "/upg all max - Buy all upgrades to max",
- "/page N - Go to upgrade page N",
- "/page RU - Rebirth upgrades page",
- "/page BN - Rebirth history page N",
- "/page CMD - This commands page",
- "/rupg N - Buy rebirth upgrade N",
- "/rebirth - Perform rebirth (1e100 pts)",
- ];
- for (let i = 0; i < cmds.length && i < 14; i++)
- await typeAt(fit(cmds[i], iw), "#94a3b8", ix, iy + 5 + i);
- for (let r = 5 + cmds.length; r <= 18; r++)
- await typeAt(fit("", iw), "#0f172a", ix, iy + r);
- await typeAt(fit("Page CMD (Commands)", iw), "#fbbf24", ix, iy + 19);
- } else if (showRbPage) {
- await typeAt(fit("──── Rebirth Bonuses ────", iw), "#e879f9", ix, iy + 4);
- const rbIdx = parseInt(String(currentPage).slice(1)) || 1;
- const rbData = rebirthPages[rbIdx - 1];
- if (rbData) {
- await typeAt(fit(`Rebirth #${rbIdx}`, iw), "#fbbf24", ix, iy + 5);
- await typeAt(fit(`Points at RB: ${formatNum(rbData.points)}`, iw), "#94a3b8", ix, iy + 6);
- await typeAt(fit(`Gain at RB: ${formatNum(rbData.gain)}`, iw), "#94a3b8", ix, iy + 7);
- await typeAt(fit(`Inc earned: ${formatNum(rbData.incEarned)}`, iw), "#94a3b8", ix, iy + 8);
- for (let r = 9; r <= 18; r++) await typeAt(fit("", iw), "#0f172a", ix, iy + r);
- } else {
- await typeAt(fit("No data for this rebirth page.", iw), "#94a3b8", ix, iy + 5);
- for (let r = 6; r <= 18; r++) await typeAt(fit("", iw), "#0f172a", ix, iy + r);
- }
- const totalRbP = Math.max(rebirthPages.length, 1);
- await typeAt(fit(`Page B${parseInt(String(currentPage).slice(1)) || 1}/${totalRbP}`, iw), "#fbbf24", ix, iy + 19);
- } else if (showRuPage) {
- await typeAt(fit("──── Rebirth Upgrades ────", iw), "#e879f9", ix, iy + 4);
- for (let i = 0; i < rebirthUpgrades.length; i++) {
- const ru = rebirthUpgrades[i];
- const row = iy + 5 + i * 3;
- const maxed = ru.maxBuy !== -1 && ru.level >= ru.maxBuy;
- const tag = maxed ? " [BOUGHT]" : ru.maxBuy === 1 ? " [1x]" : ` Lv${ru.level}`;
- await typeAt(fit(`[${ru.id}] ${ru.name}${tag}`, iw), "#e879f9", ix, row);
- await typeAt(fit(` Cost: ${formatNum(ru.cost)} Inc | ${ru.desc}`, iw), "#94a3b8", ix, row + 1);
- await typeAt(fit("", iw), "#0f172a", ix, row + 2);
- }
- for (let r = 5 + rebirthUpgrades.length * 3; r <= 18; r++)
- await typeAt(fit("", iw), "#0f172a", ix, iy + r);
- await typeAt(fit("Page RU (Rebirth Upgrades)", iw), "#fbbf24", ix, iy + 19);
- } else {
- const numPage = typeof currentPage === "number" ? currentPage : 1;
- const totalPages = Math.ceil(upgrades.length / UPG_PER_PAGE);
- const cp = Math.max(1, Math.min(numPage, totalPages));
- currentPage = cp;
- const start = (cp - 1) * UPG_PER_PAGE;
- const pageUpg = upgrades.slice(start, start + UPG_PER_PAGE);
- await typeAt(fit("──── Upgrades ────", iw), "#fbbf24", ix, iy + 4);
- const colors = { 1:"#38bdf8", 2:"#c084fc", 3:"#fb923c", 4:"#4ade80", 5:"#f472b6", 6:"#facc15", 7:"#22d3ee" };
- for (let i = 0; i < UPG_PER_PAGE; i++) {
- const row = iy + 5 + i * 4;
- if (i < pageUpg.length) {
- const u = pageUpg[i];
- const oneTime = u.maxBuy === 1;
- const maxed = oneTime && u.level >= 1;
- const hc = isHardcapped(u.id, u.level);
- const scLabel = hc ? " [HARDCAP]" : maxed ? " [BOUGHT]" : oneTime ? " [1x]" : getSoftcapLabel(u.id, u.level);
- await typeAt(fit(`[${u.id}] ${u.name}${scLabel}`, iw), colors[u.id] || "#38bdf8", ix, row);
- await typeAt(fit(` Cost: ${formatNum(u.cost)} pts | Lvl ${u.level}`, iw), "#94a3b8", ix, row + 1);
- const scm = getCostMultiplier(u.id, u.level);
- const scInfo = scm > 1 ? `Cost x${scm}` : "";
- await typeAt(fit(` ${scInfo}`, iw), "#ef4444", ix, row + 2);
- await typeAt(fit("", iw), "#0f172a", ix, row + 3);
- } else {
- for (let j = 0; j < 4; j++) await typeAt(fit("", iw), "#0f172a", ix, row + j);
- }
- }
- // fill remaining
- const usedRows = UPG_PER_PAGE * 4;
- for (let r = 5 + usedRows; r <= 18; r++)
- await typeAt(fit("", iw), "#0f172a", ix, iy + r);
- await typeAt(fit(`Page ${cp}/${totalPages} | /page CMD for help`, iw), "#fbbf24", ix, iy + 19);
- }
- /* rebirth notice */
- const canRebirth = points.gte(D("1e100"));
- if (canRebirth) {
- try { w.changeColor(10); } catch (_) {}
- const pendInc = calcIncrements(points);
- await typeAt(fit(`★ REBIRTH for ${formatNum(pendInc)} Inc! /rebirth ★`, iw), "#ff00ff", ix, iy + 19);
- try { w.changeColor(0); } catch (_) {}
- }
- }
- /* ══════════════════════════════════════
- BUY LOGIC
- ══════════════════════════════════════ */
- function buyUpgrade(u, silent) {
- if (u.maxBuy !== -1 && u.level >= u.maxBuy) return false;
- if (isHardcapped(u.id, u.level)) return false;
- if (!points.gte(u.cost)) return false;
- points = points.sub(u.cost);
- u.level++;
- const scm = getCostMultiplier(u.id, u.level);
- switch (u.id) {
- case 1: pointGain = pointGain.add(1); u.cost = roundCost(D(u.cost).mul(u.scaling * scm)); break;
- case 2: pointGain = pointGain.mul(3); u.cost = roundCost(D(u.cost).mul(u.scaling * scm)); break;
- case 3:
- u.cost = roundCost(D(u.cost).mul(u.scaling * scm));
- for (const upg of upgrades) upg.cost = roundCost(D(upg.cost).div(1.5));
- break;
- case 4: automationOn = true; break;
- case 5: pointGain = pointGain.pow(1.1); u.cost = roundCost(D(u.cost).mul(u.scaling * scm)); break;
- case 6: boosterOn = true; break;
- case 7:
- greaterGainMul = greaterGainMul.mul(1.25);
- pointGain = pointGain.mul(1.25);
- u.cost = roundCost(D(u.cost).mul(u.scaling * scm));
- break;
- }
- return true;
- }
- function buyRebirthUpgrade(ru) {
- if (ru.maxBuy !== -1 && ru.level >= ru.maxBuy) return false;
- if (!increments.gte(ru.cost)) return false;
- increments = increments.sub(ru.cost);
- ru.level++;
- switch (ru.id) {
- case "R1": rbPointBoost = true; break;
- case "R2": fullAutoOn = true; break;
- case "R3": rbDoubler = true; break;
- case "R4":
- rbX2Level++;
- ru.cost = roundCost(D(ru.cost).mul(ru.scaling));
- break;
- }
- return true;
- }
- /* ══════════════════════════════════════ */
- function doRebirth() {
- if (!points.gte(D("1e100"))) return false;
- const earned = calcIncrements(points);
- rebirthPages.push({ points: D(points), gain: D(pointGain), incEarned: D(earned), rb: rebirths + 1 });
- increments = increments.add(earned);
- rebirths++;
- points = D(0); pointGain = D(1);
- automationOn = false; boosterOn = false;
- greaterGainMul = D(1);
- upgrades = defaultUpgrades();
- currentPage = 1;
- // persist rebirth upgrades
- rbPointBoost = false; fullAutoOn = false; rbDoubler = false;
- // rbX2Level persists (it's tracked separately)
- for (const ru of rebirthUpgrades) {
- if (ru.id === "R1" && ru.level >= 1) rbPointBoost = true;
- if (ru.id === "R2" && ru.level >= 1) fullAutoOn = true;
- if (ru.id === "R3" && ru.level >= 1) rbDoubler = true;
- }
- return true;
- }
- /* ══════════════════════════════════════
- COMMAND HANDLER
- ══════════════════════════════════════ */
- async function handleCmd(raw, user) {
- if (!running || stopped) return;
- const cmd = raw.toLowerCase().replace(/\s+/g, " ").trim();
- /* Important commands (always available) */
- if (cmd === "/rebirth") {
- if (doRebirth()) {
- const last = rebirthPages[rebirthPages.length - 1];
- await chatSend(`✓ REBIRTH #${rebirths}! +${formatNum(last.incEarned)} Inc (Total: ${formatNum(increments)})`);
- } else await chatSend(`✗ Need 1e100 pts (have ${formatNum(points)})`);
- return;
- }
- // /upg N (single buy — important, always available)
- const umSingle = cmd.match(/^\/upg\s+(\d+)$/);
- if (umSingle) {
- const id = parseInt(umSingle[1]);
- const u = upgrades.find(x => x.id === id);
- if (!u) { await chatSend("Unknown #" + id); return; }
- if (u.maxBuy !== -1 && u.level >= u.maxBuy) { await chatSend(`✗ [${u.id}] maxed`); return; }
- if (isHardcapped(u.id, u.level)) { await chatSend(`✗ [${u.id}] HARDCAPPED`); return; }
- if (buyUpgrade(u)) {
- await chatSend(`✓ [${u.id}] ${u.name}! +${formatNum(pointGain.mul(greaterGainMul))}/s Next:${formatNum(u.cost)}`);
- } else await chatSend(`✗ Need ${formatNum(u.cost)} (have ${formatNum(points)})`);
- return;
- }
- // /page ... (always available)
- if (cmd === "/page cmd") { currentPage = "CMD"; await chatSend("Commands page"); return; }
- if (cmd === "/page ru") { currentPage = "RU"; await chatSend("Rebirth Upgrades"); return; }
- const rbpm = cmd.match(/^\/page\s+b(\d+)$/i);
- if (rbpm) {
- const idx = parseInt(rbpm[1]);
- if (idx >= 1 && idx <= Math.max(rebirthPages.length, 1)) { currentPage = "B" + idx; await chatSend(`Rebirth Page B${idx}`); }
- else await chatSend(`Invalid. Range: B1-B${Math.max(rebirthPages.length, 1)}`);
- return;
- }
- const pm = cmd.match(/^\/page\s+(\d+)$/);
- if (pm) {
- const p = parseInt(pm[1]);
- const tot = Math.ceil(upgrades.length / UPG_PER_PAGE);
- if (p >= 1 && p <= tot) { currentPage = p; await chatSend(`Page ${p}/${tot}`); }
- else await chatSend(`Invalid. Range: 1-${tot}`);
- return;
- }
- /* Commands moved to /page CMD — still functional */
- const mm = cmd.match(/^\/upg\s+(\d+)\s+max$/);
- if (mm) {
- const id = parseInt(mm[1]);
- const u = upgrades.find(x => x.id === id);
- if (!u) { await chatSend("Unknown #" + id); return; }
- if (u.maxBuy !== -1 && u.level >= u.maxBuy) { await chatSend(`✗ [${u.id}] maxed`); return; }
- let n = 0;
- while (points.gte(u.cost) && (u.maxBuy === -1 || u.level < u.maxBuy) && !isHardcapped(u.id, u.level) && n < 100000) {
- buyUpgrade(u, true); n++;
- }
- await chatSend(n > 0 ? `✓ [${u.id}] x${n}! +${formatNum(pointGain.mul(greaterGainMul))}/s` : `✗ Need ${formatNum(u.cost)} pts`);
- return;
- }
- if (cmd === "/upg all max") {
- let total = 0, go = true;
- while (go && total < 200000) {
- go = false;
- for (const u of upgrades)
- if ((u.maxBuy === -1 || u.level < u.maxBuy) && !isHardcapped(u.id, u.level) && points.gte(u.cost)) {
- buyUpgrade(u, true); total++; go = true;
- }
- }
- await chatSend(total > 0 ? `✓ Bought ${total} total!` : `✗ Can't afford any`);
- return;
- }
- if (cmd === "/upg all") {
- let n = 0;
- for (const u of upgrades)
- if ((u.maxBuy === -1 || u.level < u.maxBuy) && !isHardcapped(u.id, u.level) && points.gte(u.cost)) {
- buyUpgrade(u, true); n++;
- }
- await chatSend(n > 0 ? `✓ Upgraded ${n}!` : `✗ Can't afford any`);
- return;
- }
- const rup = cmd.match(/^\/rupg\s+(\d+)$/);
- if (rup) {
- const rn = parseInt(rup[1]);
- const ru = rebirthUpgrades.find(x => x.id === "R" + rn);
- if (!ru) { await chatSend("Unknown rebirth upgrade R" + rn); return; }
- if (ru.maxBuy !== -1 && ru.level >= ru.maxBuy) { await chatSend(`✗ [${ru.id}] already bought`); return; }
- if (buyRebirthUpgrade(ru)) await chatSend(`✓ [${ru.id}] ${ru.name}! Inc: ${formatNum(increments)}`);
- else await chatSend(`✗ Need ${formatNum(ru.cost)} Inc (have ${formatNum(increments)})`);
- return;
- }
- const rupMax = cmd.match(/^\/rupg\s+(\d+)\s+max$/);
- if (rupMax) {
- const rn = parseInt(rupMax[1]);
- const ru = rebirthUpgrades.find(x => x.id === "R" + rn);
- if (!ru) { await chatSend("Unknown R" + rn); return; }
- let n = 0;
- while ((ru.maxBuy === -1 || ru.level < ru.maxBuy) && increments.gte(ru.cost) && n < 100000) {
- buyRebirthUpgrade(ru); n++;
- }
- await chatSend(n > 0 ? `✓ [${ru.id}] x${n}! Inc: ${formatNum(increments)}` : `✗ Can't afford`);
- return;
- }
- }
- /* ══════════════════════════════════════ */
- window.quit = async function () {
- stopped = true; timers.forEach(clearInterval); timers.length = 0;
- if (running) {
- for (let r = 0; r < WIN_H; r++)
- for (let c = 0; c < WIN_W; c++) {
- writeCharAt(" ", "#000000", gx + c, gy + r); await sleep(COOLDOWN);
- }
- }
- running = false;
- try { shade.remove(); } catch (_) {} try { hud.remove(); } catch (_) {}
- try { w.chat.send("Stopped"); } catch (_) {}
- console.log("[Incrementallity] Game stopped.");
- };
- window.info = function () { console.log("incrementality is a game that i made."); };
- })();
Advertisement
Comments
-
User was banned
-
User was banned
-
User was banned
-
User was banned
Add Comment
Please, Sign In to add comment