`);
let crdt = document.getElementsByClassName('crdt')[0];
let xera = document.getElementsByClassName('xera')[0];
crdt.style.display = "none";
xera.addEventListener('click', function() {
if(crdt.style.display == "none" || crdt.style.display == "") {
crdt.style.display = "block";
} else {
crdt.style.display = "none";
};
});
/* random character gen */
var availableCharacters = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890~!@#$%^&*()_+`-=[]{};':,./<>?\|";
var textLength = 29;
var text = "";
for (let i = 0; i < textLength; i++) text += availableCharacters[Math.floor(Math.random() * availableCharacters.length)];
/* name stuffs here */
document.getElementsByClassName('hud-intro-name')[0].setAttribute('maxlength', 29);
let guide = document.getElementsByClassName("hud-intro-guide")[0];
guide.innerHTML = `
+ Record base(s): You can save a base with the button, "Record Base!", and build the saved base with "Build Recorded Base!" button. In case you need to delete for another one, just click "Delete Recorded Base!".
+ Upgrade All: Automatically upgrades everything in your base to maximum tier possible.
+ AHRC: Stands for "Automatic Harvester Resource Collector", automatically refills your harvester(s) and collects them back to you.
+ Exact RSS Counter: "De-truncate" your resource stats.
+ Join party by PSK function: PSK stands for Party Share Key, use this to join your previous parties!
Keybinds
- // Enable show other players' RSS.
= // Toggle Exact RSS Counter.
~ // Add a marker on the minimap.
Notice
While this script does auto-heal your player and pet, it however does not auto-respawn your pet, or your player.
Toggle showing other players' RSS is a one-time choice! Once enabled, cannot be turned off.
AFS is included in the script, please remember that it'll only equip the shield next wave.
Autobow is toggled by holding bow (any tier) and hitting "Space" key.
Markers once placed, cannot be deleted.
Xeraphinite, v1.5
`;
function modm() {
if(menu.style.display == "none" || menu.style.display == "") {
menu.style.display = "block";
} else {
menu.style.display = "none";
};
};
/* main code */
var showRSS = false;
var AHRC = false;
var upgradeAll = false;
var petTimeout = false;
var hardcoreMode = false;
var heal = true;
var autobow = false;
var myPosx;
var myPosy;
let myPlayer;
let myPet;
game.network.addEntityUpdateHandler(() => {
if (game.network.connected) {
if(upgradeAll) {
let entities = game.world.entities;
for (var uid in entities) {
if (!entities.hasOwnProperty(uid)) continue;
var obj = entities[uid];
game.network.sendRpc({
name: "UpgradeBuilding",
uid: obj.fromTick.uid
})
}
}
if (AHRC) {
let entities = game.world.entities
for (let uid in entities) {
if (!entities.hasOwnProperty(uid)) continue;
let obj = entities[uid];
game.network.sendRpc({
name: "CollectHarvester",
uid: obj.fromTick.uid
});
if (obj.fromTick.model === "Harvester" && obj.fromTick.tier === 1) {
game.network.sendRpc({
name: "AddDepositToHarvester",
uid: obj.fromTick.uid,
deposit: 0.07
});
}
if (obj.fromTick.model === "Harvester" && obj.fromTick.tier === 2) {
game.network.sendRpc({
name: "AddDepositToHarvester",
uid: obj.fromTick.uid,
deposit: 0.11
});
}
if (obj.fromTick.model === "Harvester" && obj.fromTick.tier === 3) {
game.network.sendRpc({
name: "AddDepositToHarvester",
uid: obj.fromTick.uid,
deposit: 0.17
});
}
if (obj.fromTick.model === "Harvester" && obj.fromTick.tier === 4) {
game.network.sendRpc({
name: "AddDepositToHarvester",
uid: obj.fromTick.uid,
deposit: 0.22
});
}
if (obj.fromTick.model === "Harvester" && obj.fromTick.tier === 5) {
game.network.sendRpc({
name: "AddDepositToHarvester",
uid: obj.fromTick.uid,
deposit: 0.25
});
}
if (obj.fromTick.model === "Harvester" && obj.fromTick.tier === 6) {
game.network.sendRpc({
name: "AddDepositToHarvester",
uid: obj.fromTick.uid,
deposit: 0.28
});
}
if (obj.fromTick.model === "Harvester" && obj.fromTick.tier === 7) {
game.network.sendRpc({
name: "AddDepositToHarvester",
uid: obj.fromTick.uid,
deposit: 0.42
});
}
if (obj.fromTick.model === "Harvester" && obj.fromTick.tier === 8) {
game.network.sendRpc({
name: "AddDepositToHarvester",
uid: obj.fromTick.uid,
deposit: 0.65
});
}
}
}
if (showRSS) {
Object.entries(game.world.entities).forEach((stuff => {
if (stuff[1].targetTick.entityClass === "PlayerEntity") {
var newName = stuff[1].targetTick.name + `\n Wood:` +
game.world.entities[stuff[1].targetTick.uid].targetTick.wood + `\n Stone: ` +
game.world.entities[stuff[1].targetTick.uid].targetTick.stone + `\n Gold: ` +
game.world.entities[stuff[1].targetTick.uid].targetTick.gold + `\n Tokens:` +
game.world.entities[stuff[1].targetTick.uid].targetTick.token + `\n\n\n`;
game.world.entities[stuff[1].targetTick.uid].currentModel.nameEntity.setString(newName);
}
}))
game.world.localPlayer.entity.currentModel.nameEntity.setString(game.ui.playerTick.name)
}
if (heal) {
if (myPlayer) {
let playerHealth = (myPlayer.health/myPlayer.maxHealth) * 100;
if (playerHealth <= 50) {
if (!window.playerTimeout_1) {
window.playerTimeout_1 = true;
setTimeout(() => {
window.playerTimeout_1 = false;
}, 300)
healPlayer();
}
}
}
}
if (heal) {
if (myPet) {
let petHealth = (myPet.health/myPet.maxHealth) * 100;
if (petHealth <= 50) {
if (!petTimeout) {
petTimeout = true;
setTimeout(() => { petTimeout = false; }, 300);
game.network.sendRpc({
"name": "BuyItem",
"itemName": "PetHealthPotion",
"tier": 1
})
game.network.sendRpc({
"name": "EquipItem",
"itemName": "PetHealthPotion",
"tier": 1
})
}
}
}
}
if (autobow) {
game.network.sendInput({space: 0})
game.network.sendInput({space: 1})
}
myPosx = game.ui.playerTick.position.x;
myPosy = game.ui.playerTick.position.y;
if (game.ui.playerTick) {
if (xyshow.innerHTML != `X: ${Math.round(myPosx)-13}, Y: ${Math.round(myPosy)-13}`) {
xyshow.innerHTML = `X: ${Math.round(myPosx - 13)}, Y: ${Math.round(myPosy) - 13}`;
}
}
}
});
function healPlayer() {
Game.currentGame.network.sendRpc({
"name": "EquipItem",
"itemName": "HealthPotion",
"tier": 1
})
Game.currentGame.network.sendRpc({
"name": "BuyItem",
"itemName": "HealthPotion",
"tier": 1
})
}
document.getElementsByClassName("0i")[0].addEventListener('click', function() {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to delete all towers?", 1e4, function() {
for(let uid in game.ui.buildings) {
if(game.ui.buildings[uid].type !== "GoldStash") {
Game.currentGame.network.sendRpc({
name: "DeleteBuilding",
uid: game.ui.buildings[uid].uid
});
}
}
game.ui.components.PopupOverlay.showHint("Sold all.");
})
})
document.getElementsByClassName("1i")[0].addEventListener('click', function() {
for(let uid in game.ui.buildings) {
if(game.ui.buildings[uid].type == "Wall") {
Game.currentGame.network.sendRpc({
name: "DeleteBuilding",
uid: game.ui.buildings[uid].uid
});
}
}
})
document.getElementsByClassName("2i")[0].addEventListener('click', function() {
for(let uid in game.ui.buildings) {
if(game.ui.buildings[uid].type == "Door") {
Game.currentGame.network.sendRpc({
name: "DeleteBuilding",
uid: game.ui.buildings[uid].uid
});
}
}
})
document.getElementsByClassName("3i")[0].addEventListener('click', function() {
for(let uid in game.ui.buildings) {
if(game.ui.buildings[uid].type == "SlowTrap") {
Game.currentGame.network.sendRpc({
name: "DeleteBuilding",
uid: game.ui.buildings[uid].uid
});
}
}
})
document.getElementsByClassName("4i")[0].addEventListener('click', function() {
for(let uid in game.ui.buildings) {
if(game.ui.buildings[uid].type == "ArrowTower") {
Game.currentGame.network.sendRpc({
name: "DeleteBuilding",
uid: game.ui.buildings[uid].uid
});
}
}
})
document.getElementsByClassName("5i")[0].addEventListener('click', function() {
for(let uid in game.ui.buildings) {
if(game.ui.buildings[uid].type == "CannonTower") {
Game.currentGame.network.sendRpc({
name: "DeleteBuilding",
uid: game.ui.buildings[uid].uid
});
}
}
})
document.getElementsByClassName("6i")[0].addEventListener('click', function() {
for(let uid in game.ui.buildings) {
if(game.ui.buildings[uid].type == "MeleeTower") {
Game.currentGame.network.sendRpc({
name: "DeleteBuilding",
uid: game.ui.buildings[uid].uid
});
}
}
})
document.getElementsByClassName("7i")[0].addEventListener('click', function() {
for(let uid in game.ui.buildings) {
if(game.ui.buildings[uid].type == "BombTower") {
Game.currentGame.network.sendRpc({
name: "DeleteBuilding",
uid: game.ui.buildings[uid].uid
});
}
}
})
document.getElementsByClassName("8i")[0].addEventListener('click', function() {
for(let uid in game.ui.buildings) {
if(game.ui.buildings[uid].type == "MagicTower") {
Game.currentGame.network.sendRpc({
name: "DeleteBuilding",
uid: game.ui.buildings[uid].uid
});
}
}
})
document.getElementsByClassName("9i")[0].addEventListener('click', function() {
for(let uid in game.ui.buildings) {
if(game.ui.buildings[uid].type == "GoldMine") {
Game.currentGame.network.sendRpc({
name: "DeleteBuilding",
uid: game.ui.buildings[uid].uid
});
}
}
})
document.getElementsByClassName("10i")[0].addEventListener('click', function() {
for(let uid in game.ui.buildings) {
if(game.ui.buildings[uid].type == "Harvester") {
Game.currentGame.network.sendRpc({
name: "DeleteBuilding",
uid: game.ui.buildings[uid].uid
});
}
}
})
document.getElementsByClassName("11i")[0].addEventListener('click', function() {
for(let uid in game.world.entities) {
if(game.world.entities[uid].fromTick.model == "PetCARL" || game.world.entities[uid].fromTick.model == "PetMiner") {
Game.currentGame.network.sendRpc({
name: "DeleteBuilding",
uid: game.world.entities[uid].fromTick.uid
});
}
}
})
document.getElementsByClassName("3i2")[0].addEventListener('click', function() {
upgradeAll = !upgradeAll;
let upalltoggle = document.getElementById('upalltoggle');
if (upgradeAll) {
upalltoggle.style.color = "green";
upalltoggle.innerText = "ON";
} else {
upalltoggle.style.color = "red";
upalltoggle.innerText = "OFF";
}
})
document.getElementsByClassName("0i4")[0].addEventListener('click', function() {
AHRC = !AHRC;
let ahrctoggle = document.getElementById('ahrctoggle');
if (AHRC) {
ahrctoggle.style.color = "green";
ahrctoggle.innerText = "ON";
} else {
ahrctoggle.style.color = "red";
ahrctoggle.innerText = "OFF";
}
})
document.getElementsByClassName("1i4")[0].addEventListener('click', function() {
window.frss = !window.frss;
let rsstoggle = document.getElementById('exactrsstoggle');
if (window.frss) {
rsstoggle.style.color = "green";
rsstoggle.innerText = "ON";
} else {
rsstoggle.style.color = "red";
rsstoggle.innerText = "OFF";
}
})
document.getElementsByClassName("hud-Close-icon")[0].addEventListener("click", function () {
menu.style.display = "none";
});
var baseStr = "";
var towerCodes = ["Wall", "Door", "SlowTrap", "ArrowTower", "CannonTower", "MeleeTower", "BombTower", "MagicTower", "GoldMine", "Harvester"];
function getGoldStash() {
return Object.values(Game.currentGame.ui.buildings).find(building => building.type == "GoldStash");
}
window.RecordBase = function() {
for (let i in game.ui.buildings) {
const building = game.ui.buildings[i];
if (towerCodes.indexOf(building.type) < 0) continue;
let yaw = 0;
if (["Harvester", "MeleeTower"].includes(building.type)) {
if (game.world.entities[building.uid] !== undefined) yaw = game.world.entities[building.uid].targetTick.yaw;
}
baseStr += `${towerCodes.indexOf(building.type)},${getGoldStash().x - building.x},${getGoldStash().y - building.y},${yaw};`;
}
localStorage.savedBase = baseStr;
console.log(baseStr);
}
window.buildRecordedBase = function() {
function BuildBase(design) {
if (typeof design !== "string") throw new Error("Argument must be given as a string.");
if (getGoldStash() === undefined) throw new Error("You must have a gold stash to be able to use this.");
const towers = design.split(";");
for (let towerStr of towers) {
const tower = towerStr.split(",");
if (tower[0] === "") continue;
if (tower.length < 4) throw new Error(`${JSON.stringify(tower)} contains an issue that must be fixed before this design can be replicated.`);
Game.currentGame.network.sendRpc({
name: "MakeBuilding",
type: towerCodes[parseInt(tower[0])],
x: getGoldStash().x - parseInt(tower[1]),
y: getGoldStash().y - parseInt(tower[2]),
yaw: parseInt(tower[3])
});
}
}
BuildBase(localStorage.savedBase);
}
window.DeleteRecordedbase = function() {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to delete the recorded base?", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Recorded base has been successfully deleted!");
localStorage.savedBase = null;
})
}
game.network.sendRpc2 = game.network.sendRpc;
const placeWall = (x, y) => {
game.network.sendRpc2({
name: 'MakeBuilding',
x: x,
y: y,
type: "Wall",
yaw: 0
});
};
game.network.sendRpc = (data) => {
let gridPos = { x: data.x, y: data.y };
if(data.name === "MakeBuilding" && data.type === "Wall" && window.x3builds) {
placeWall(gridPos.x, gridPos.y);
placeWall(gridPos.x + 48, gridPos.y);
placeWall(gridPos.x, gridPos.y + 48);
placeWall(gridPos.x - 48, gridPos.y);
placeWall(gridPos.x, gridPos.y - 48);
placeWall(gridPos.x - 48, gridPos.y + 48);
placeWall(gridPos.x + 48, gridPos.y - 48);
placeWall(gridPos.x + 48, gridPos.y + 48);
placeWall(gridPos.x - 48, gridPos.y - 48);
};
game.network.sendRpc2(data);
};
let dimension = 1;
let upd = () => {
const renderer = Game.currentGame.renderer;
let canvasWidth = window.innerWidth * window.devicePixelRatio;
let canvasHeight = window.innerHeight * window.devicePixelRatio;
let ratio = canvasHeight / (1080 * dimension);
renderer.scale = ratio;
renderer.entities.setScale(ratio);
renderer.ui.setScale(ratio);
renderer.renderer.resize(canvasWidth, canvasHeight);
renderer.viewport.width = renderer.renderer.width / renderer.scale + 2 * renderer.viewportPadding;
renderer.viewport.height = renderer.renderer.height / renderer.scale + 2 * renderer.viewportPadding;
};
const onWindowResize = () => {
if (window.zoomonscroll) {
upd();
console.log(dimension);
}
} // Zoom by Apex, modified by eh
onWindowResize();
window.onresize = onWindowResize;
window.onwheel = e => {
if (e.deltaY > 0) {
dimension += 0.02;
} else if (e.deltaY < 0) {
dimension -= 0.02;
}
onWindowResize();
}
window.zoom = val => {
dimension = val;
upd();
};
game.network.addEntityUpdateHandler(() => {
if(!window.zoomonscroll) {
window.zoom(document.getElementById("zoomSlider").value);
};
});
window.toggleZoS = () => {
dimension -= 0.02;
window.zoomonscroll = !window.zoomonscroll;
let zs = document.getElementById("zsd");
zs.style.display = zs.style.display == "none" ? "block" : "none";
};
window.zoomOut = () => {
let zs = document.getElementById("zoomSlider");
zs.value = parseInt(zs.value) + 1;
};
window.zoomIn = () => {
let zs = document.getElementById("zoomSlider");
zs.value = parseInt(zs.value) - 1;
}; // cutdown version of ignition's zoom
let blockedNames = [];
window.blockPlayer = name => {
game.ui.components.PopupOverlay.showConfirmation(`Are you sure you want to block ${name}?`, 3500, () => {
blockedNames.push(name);
for(let msg of Array.from(document.getElementsByClassName("hud-chat-message"))) {
if(msg.childNodes[2].innerText === name) {
let bl = msg.childNodes[0];
bl.innerHTML = "Unblock";
bl.style.color = "blue";
bl.onclick = () => {
window.unblockPlayer(name);
};
};
};
}, () => {});
};
window.unblockPlayer = name => {
blockedNames.splice(blockedNames.indexOf(name), 1);
for(let msg of Array.from(document.getElementsByClassName("hud-chat-message"))) {
if(msg.childNodes[2].innerText === name) {
let bl = msg.childNodes[0];
bl.innerHTML = "Block";
bl.style.color = "red";
bl.onclick = () => {
window.blockPlayer(name);
};
};
};
};
Game.currentGame.network.emitter.removeListener("PACKET_RPC", Game.currentGame.network.emitter._events.PACKET_RPC[1]);
let onMessageReceived = (msg => {
if(blockedNames.includes(msg.displayName) || window.chatDisabled) { return; };
let a = Game.currentGame.ui.getComponent("Chat"),
b = msg.displayName.replace(/<(?:.|\n)*?>/gm, ''),
c = msg.message.replace(/<(?:.|\n)*?>/gm, ''),
d = a.ui.createElement(`