// ==UserScript==
// @name Xeraphinite - zombs.io
// @namespace http://tampermonkey.net/
// @version 1.0
// @description ATTENTION! after installing the script, please replace the @resource tag to a @require tag. So that you can use the script with Fontawesome Icons!
// @author rdm, god of simping
// @match http://zombs.io/
// @icon https://cdn.discordapp.com/attachments/854376044522242059/907931471518502922/flowerxeraphinite.png
// @grant none
// @resource https://use.fontawesome.com/2ad2a2ffe2.js
// ==/UserScript==
// v0.1: basic html and css added
// v0.2: html and css done (except party hud)
// v0.3: all html and css done
// v0.4: some functions added
// v0.41: added credits
// v0.5: reworked sell menu
// v0.6: find it out yourself
// v0.61: small adjustments, almost ready for release
// v0.7: added crossbow toolbar icon and afs
// v0.8: autobow added
// v0.9: marker functions, v1.0?
// v1.0: official release, added changelog button
/* remove cringe icons & intro styles */
document.getElementsByClassName('hud-intro-name')[0].setAttribute('maxlength', 29);
document.querySelectorAll('.ad-unit, .hud-intro-left, .hud-intro-youtuber, .hud-intro-footer, .hud-intro-stone, .hud-intro-tree, .hud-intro-social, .hud-intro-more-games').forEach(el => el.remove());
let cssTitle = `
.hud-intro::before {
background-image: url('https://cdn.discordapp.com/attachments/854376044522242059/907880671610040330/background.jpg');
background-size: cover;
}
.btn:hover {
cursor: pointer;
}
.border-theme {
border: 3px solid #2eacbf;
border-radius: 4px;
background: none;
transition: all 0.15s ease-in-out;
}
.border-theme:hover {
cursor: pointer;
border-color: #10c7e3;
}
.btn-theme {
background-color: #1eacbf;
}
.btn-theme:hover {
background-color: #10c7e3;
}
.hud-intro .hud-intro-form .hud-intro-play {
background-color: #1da9bf;
}
.hud-intro .hud-intro-form .hud-intro-play:hover {
background-color: #10c7e3;
}
.hud-intro .hud-intro-corner-bottom-right .hud-name-changelog-full {
display: block;
background: rgba(0, 0, 0, 0.2);
color: rgba(255, 255, 255, 0.4);
text-decoration: none;
font-size: 17px;
padding: 3px 8px;
border-radius: 0 0 4px 4px;
transition: all 0.15s ease-in-out;
}
.hud-intro .hud-intro-corner-bottom-right .hud-name-changelog-full:hover {
color: rgba(255, 255, 255, 0.8);
}
`;
let styles = document.createElement("style");
styles.appendChild(document.createTextNode(cssTitle));
document.head.appendChild(styles);
styles.type = "text/css";
document.getElementsByClassName('hud-intro-corner-bottom-left')[0].insertAdjacentHTML("afterbegin", `
<img src="https://cdn.discordapp.com/attachments/854376044522242059/908331735010377728/xeraedit.png" class="xera" style="opacity: 0.5;">
`);
document.getElementsByClassName('hud-intro-corner-bottom-right')[0].insertAdjacentHTML("afterbegin", `
<a href="/changelog" class="hud-name-changelog-full" target="_blank">View game changelog</a>
`);
document.getElementsByClassName('hud-intro-corner-top-left')[0].insertAdjacentHTML("afterbegin", `
<div class="crdt" style="color: white;opacity: 0.5;">
<h1>Credits</h1>
<p>+ ehScripts</p>
<p>+ Trollers</p>
<p>+ Duck</p>
</div>
`);
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 = `
<center>
<h1 style="text-transform: none;">Name Options</h1>
<hr />
</center>
<br />
<button class="btn hud-intro-invisible" style = 'margin-bottom: 10px;'>Invisible username</button>
<button class="btn hud-intro-random" style = 'margin-bottom: 10px;'>Random-generated username</button>
`;
function invisiblename() {
document.getElementsByClassName('hud-intro-name')[0].value = "ㅤ";
};
function randomname() {
document.getElementsByClassName('hud-intro-name')[0].value = `${text}`;
};
document.querySelector('.hud-intro-invisible').addEventListener('click', invisiblename);
document.querySelector('.hud-intro-random').addEventListener('click', randomname);
/* ui styles */
let blackShadowCSS = `
.hud-menu-icons .hud-menu-icon::before {
filter: drop-shadow(1px 1px 0px #000) drop-shadow(-1px 1px 0px #000) drop-shadow(1px -1px 0px #000) drop-shadow(-1px -1px 0px #000)
}
`;
let blackShadowStyle = document.createElement('style');
blackShadowStyle.innerHTML = blackShadowCSS;
document.body.append(blackShadowStyle);
document.getElementsByClassName('hud-top-right')[0].insertAdjacentHTML("beforeend", `
<div id="zsd">
<button class="btn btn-theme" style="position: absolute;left: -41.5%;z-index: 14;top: 0%;width: 48px;padding: 0 0 0 0px;" onclick="window.zoomOut();">
<i class="fa fa-arrow-up fa-2x" style="margin-top: 5px;"></i>
</button>
<input type='range' style='-webkit-appearance: slider-vertical;position: absolute;left: -15%;width: 5%;z-index: 14;top: -1000%;' id="zoomSlider" min=0.2 max=3 value=1 step=0.02 />
<button class="btn btn-theme" style="position: absolute;z-index: 14;left: -60%;top: 0%;width: 45px;padding: 0 0 0 0px;" onclick="window.zoomIn();">
<i class="fa fa-arrow-down fa-2x" style="margin-top: 5px;"></i>
</button>
</div>`);
document.getElementsByClassName('hud-top-right')[0].insertAdjacentHTML("beforeend", `
<div class="refrsh">
<button class="btn btn white" style="position: absolute;z-index: 14;left: -20%;top: 0%;width: 40px;height: 40px; padding: 0 0 0 0px;" onclick="window.toggleZoS();">
<i class="fa fa-refresh"></i>
</button>
</div>
`);
var xyshow = document.createElement("p");
xyshow.style = 'position: relative;top: 17px;right: 0px;font-weight: 900;font-family: "Hammersmith One";text-shadow: 1px 0 0 #fff, -1px 0 0 #fff, 0 1px 0 #fff, 0 -1px 0 #fff, 0.5px 0.5px #fff, -0.5px -0.5px 0 #fff, 0.5px -0.5px 0 #fff, -0.5px 0.5px 0 #fff;';
xyshow.innerHTML = "loading x/y coordinate";
xyshow.className = "xyshowcoordinate";
document.querySelector(".hud-bottom-left").appendChild(xyshow);
let cssMain = `
.hud-chat .hud-chat-message {
white-space: unset;
word-break: break-word;
}
#hud-menu-party {
top: 51%;
width: 610px;
height: 480px;
background-color: rgba(28, 178, 201, 0.5);
border: 5px solid white;
}
.hud-menu-party .hud-party-tag {
width: 120px;
}
.hud-menu-party .hud-party-share {
width: 280px;
}
.hud-menu-party .hud-party-grid .hud-party-link.is-active {
background: #1cb2c9 !important;
}
.hud-menu-party .hud-party-visibility {
background: #1cb2c9;
}
.hud-menu-party .hud-party-visibility:hover, .hud-menu-party .hud-party-visibility:active {
background: #1cb2c9;
}
.hud-popup-overlay .hud-popup-confirmation .hud-confirmation-actions .btn.btn-green {
background: #1cb2c9;
}
#hud-menu-shop {
top: 54.5%;
left: 50.5%;
width: 690px;
height: 500px;
background-color: rgba(28, 178, 201, 0.5);
border: 5px solid white;
margin: -350px 0 0 -350px;
padding: 20px 20px 20px 20px;
}
.hud-menu-shop .hud-shop-grid .hud-shop-item .hud-shop-item-actions .hud-shop-actions-equip {
background: #12c0db;
}
.hud-menu-shop .hud-shop-grid .hud-shop-item .hud-shop-item-actions .hud-shop-actions-equip:hover, .hud-menu-shop .hud-shop-grid .hud-shop-item .hud-shop-item-actions .hud-shop-actions-equip:active {
background: #1cb2c9;
}
.hud-menu-shop .hud-shop-grid .hud-shop-item .hud-shop-item-actions .hud-shop-actions-equip.is-disabled {
background: none;
}
.hud-menu-shop .hud-shop-grid .hud-shop-item[data-item=HatComingSoon] .hud-shop-item-coming-soon {
background: none;
}
#hud-menu-settings {
height: 550px;
background-color: rgba(28, 178, 201, 0.5);
border: 5px solid white;
}
.hud-menu-settings .hud-xera-grid {
display: block;
height: 460px;
padding: 10px;
margin-top: 18px;
background: rgba(0, 0, 0, 0.2);
overflow: auto;
}
.hud-respawn .hud-respawn-info .hud-respawn-btn {
background: #1abfd9;
}
.hud-respawn .hud-respawn-info .hud-respawn-btn:hover {
background: #1abfd9;
}
#hud-building-overlay {
background-color: rgba(28, 178, 201, 0.5);
border: 1px solid white;
}
.btn.btn-green.hud-building-upgrade {
background-color: #17bed1;
}
.hud-building-overlay .hud-tooltip-health .hud-tooltip-health-bar {
background: #17d1c2;
}
.hud-building-overlay .hud-building-upgrade.is-disabled {
background: #17bed1 !important;
}
::-webkit-scrollbar {
width: 12px;
height: 0px;
background-color: #F5F5F5;
}
::-webkit-scrollbar-thumb {
background-color: #2eacbf;
}
`;
let stylesMain = document.createElement("style");
stylesMain.appendChild(document.createTextNode(cssMain));
document.head.appendChild(stylesMain);
stylesMain.type = "text/css";
/* main code incoming */
//
//
//
/* main css */
let menu = document.querySelector("#hud-menu-settings");
menu.style.overflow = "auto";
menu.innerHTML = `
<p class="hud-Close-icon" style="display:inline-block;margin: 0 0 0 0px;opacity: 0.3;"><strong>✕</strong></p>
<br />
<div class="hud-xera-grid">
<center>
<h2> Sell </h2>
<hr />
<br />
<button class="border-theme 1i" style="margin: 1px;padding: 7px;width: 60px;height: 60px;"><img src="/asset/image/entity/wall/wall-t1-base.svg" style="width: 40px;"></button>
<button class="border-theme 2i" style="margin: 1px;padding: 7px;width: 60px;height: 60px;"><img src="/asset/image/entity/door/door-t1-base.svg" style="width: 40px;"></button>
<button class="border-theme 3i" style="margin: 1px;padding: 7px;width: 60px;height: 60px;"><img src="/asset/image/entity/slow-trap/slow-trap-t1-base.svg" style="width: 40px;"></button>
<br />
<button class="border-theme 4i" style="margin: 1px;padding: 3px;width: 60px;height: 60px;"><img src="/asset/image/entity/arrow-tower/arrow-tower-t1-base.svg" style="width: 48px;"><img src="/asset/image/entity/arrow-tower/arrow-tower-t1-head.svg" style="width: 55px;position: relative;transform: translate(-10%, -100%);"></button>
<button class="border-theme 5i" style="margin: 1px;padding: 3px;width: 60px;height: 60px;"><img src="/asset/image/entity/cannon-tower/cannon-tower-t1-base.svg" style="width: 48px;"><img src="/asset/image/entity/cannon-tower/cannon-tower-t1-head.svg" style="width: 60px;position: relative;transform: translate(-10%, -95%);"></button>
<button class="border-theme 6i" style="margin: 1px;padding: 3px;width: 60px;height: 60px;"><img src="/asset/image/entity/melee-tower/melee-tower-t1-base.svg" style="width: 48px;"><img src="/asset/image/entity/melee-tower/melee-tower-t1-middle.svg" style="width: 40px;position: relative;transform: translate(30%, -130%);"><img src="/asset/image/entity/melee-tower/melee-tower-t1-head.svg" style="width: 35px;position: relative;transform: translate(-5%, -207.5%);"></button>
<br />
<button class="border-theme 7i" style="margin: 1px;padding: 3px;width: 60px;height: 60px;"><img src="/asset/image/entity/bomb-tower/bomb-tower-t1-base.svg" style="width: 48px;"></button>
<button class="border-theme 8i" style="margin: 1px;padding: 3px;width: 60px;height: 60px;"><img src="/asset/image/entity/mage-tower/mage-tower-t1-base.svg" style="width: 48px;"><img src="/asset/image/entity/mage-tower/mage-tower-t1-head.svg" style="width: 25px;position: relative;transform: translate(-0%, -160%);"></button>
<button class="border-theme 9i" style="margin: 1px;padding: 3px;width: 60px;height: 60px;"><img src="/asset/image/entity/gold-mine/gold-mine-t1-base.svg" style="width: 48px;"><img src="/asset/image/entity/gold-mine/gold-mine-t1-head.svg" style="width: 45px;position: relative;transform: translate(-0%, -110%);"></button>
<br />
<button class="border-theme 10i" style="margin: 1px;padding: 3px;width: 60px;height: 60px;"><img src="/asset/image/entity/harvester/harvester-t1-base.svg" style="width: 48px;"><img src="/asset/image/entity/harvester/harvester-t1-head.svg" style="width: 50px;position: relative;transform: translate(-5%, -125%);"></button>
<button class="border-theme 11i" style="margin: 1px;padding: 3px;width: 60px;height: 60px;"><img src="/asset/image/entity/pet-ghost/pet-ghost-t1-base.svg" style="width: 39.5px;"></button>
<button class="border-theme 0i" style="margin: 1px;padding: 3px;width: 60px;height: 60px;"><img src="/asset/image/entity/gold-stash/gold-stash-t1-base.svg" style="width: 48px;"></button>
<br />
<small style="opacity: 0.1">lte's sell numpad sucks lol</small>
<br />
<img src="https://cdn.discordapp.com/attachments/854376044522242059/908538354239434772/clicker.png" style="transform: translate(-180px, -270px);width: 150px;position: relative;margin: -200px;opacity: 0.5;">
<h2> Build </h2>
<hr />
<br />
<button class="btn btn-theme 0i2" style="width: 45%;margin: 1px;" onclick="RecordBase();">Record Base!</button>
<button class="btn btn-theme 1i2" style="width: 45%;margin: 1px;" onclick="buildRecordedBase();">Build Recorded Base!</button>
<button class="btn btn-red 2i2" style="width: 45%;margin: 1px;" onclick="DeleteRecordedbase();">Delete Recorded Base!</button>
<button class="btn btn-green 3i2" style="width: 45%;margin: 1px;" onclick="upgradealltoggle();">Enable Upgrade All!</button>
<br />
<small style="opacity: 0.1">no more useless spaces of code</small>
<br />
<h2> Chat </h2>
<hr />
<br />
<button id="chattoggle" class="btn btn-theme 0i3" style="width: 45%;margin: 1px;" onclick="window.toggleChat();">Toggle Chat!</button>
<br />
<small style="opacity: 0.5">thats all for chat, right now</small>
<br />
<h2> Miscellaneous </h2>
<hr />
<br />
<button class="btn btn-theme 0i4" style="width: 45%;">Activate AHRC!</button>
<button class="btn btn-theme 1i4" style="width: 45%;">Enable Exact RSS Counter!</button>
<br />
<small style="opacity: 0.1">AITO when?</small>
<br />
<h2> Help </h2>
<hr />
</center>
<br />
<h3><i class="fa fa-info-circle"></i> General </h3>
<p>+ 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!".</P>
<p>+ Upgrade All: Automatically upgrades everything in your base to maximum tier possible.</p>
<p>+ AHRC: Stands for "Automatic Harvester Resource Collector", automatically refills your harvester(s) and collects them back to you.</p>
<p>+ Exact RSS Counter: "De-truncate" your resource stats.</p>
<p>+ Join party by PSK function: PSK stands for Party Share Key, use this to join your previous parties!</p>
<br />
<h3><i class="fa fa-keyboard"></i> Keybinds </h3>
<p> - // Enable show other players' RSS.</p>
<p> = // Toggle Exact RSS Counter.</p>
<p> ~ // Add a marker on the minimap.</p>
<br />
<h3><i class="fa fa-exclamation-triangle"></i> Notice </h3>
<p> While this script does auto-heal your player and pet, it however does <strong>not</strong> auto-respawn your pet, or your player.</p>
<p> Toggle showing other players' RSS is a <strong>one-time</strong> choice! Once enabled, cannot be turned off.</p>
<p> AFS is included in the script, please remember that it'll only equip the shield next wave.</p>
<p> Autobow is toggled by holding bow (any tier) and hitting "Space" key.</p>
<p> Markers once placed, cannot be deleted.</p>
<br />
<br />
<h4>Xeraphinite, v1.0</h4>
`;
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;
document.getElementsByClassName("3i2")[0].className = "btn btn-green 3i2";
document.getElementsByClassName("3i2")[0].innerText = "Enable Upgrade All!";
if (upgradeAll) {
document.getElementsByClassName("3i2")[0].className = "btn btn-red 3i2";
document.getElementsByClassName("3i2")[0].innerText = "Disable Upgrade All!";
}
})
document.getElementsByClassName("0i4")[0].addEventListener('click', function() {
AHRC = !AHRC;
document.getElementsByClassName("0i4")[0].className = "btn btn-theme 0i4";
document.getElementsByClassName("0i4")[0].innerText = "Activate AHRC!";
if (AHRC) {
document.getElementsByClassName("0i4")[0].className = "btn btn-red 0i4";
document.getElementsByClassName("0i4")[0].innerText = "Deactivate AHRC!";
}
})
document.getElementsByClassName("1i4")[0].addEventListener('click', function() {
window.frss = !window.frss
document.getElementsByClassName("1i4")[0].className = "btn btn-theme 1i4";
document.getElementsByClassName("1i4")[0].innerText = "Enable Exact RSS Counter!";
if (window.frss) {
document.getElementsByClassName("1i4")[0].className = "btn btn-red 1i4";
document.getElementsByClassName("1i4")[0].innerText = "Disable Exact RSS Counter!";
}
})
document.getElementsByClassName("hud-Close-icon")[0].addEventListener("click", function () {
menu.style.display = "none";
});
window.RecordBase = function(baseName) {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to record base?", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Successfully recorded!");
let buildings = Game.currentGame.ui.buildings;
let base = "";
let stash = GetGoldStash();
if (stash == undefined) {
return
}
let stashPosition = {
x: stash.x,
y: stash.y
}
for (var uid in buildings) {
if (!buildings.hasOwnProperty(uid)) {
continue
}
let obj = buildings[uid]
let x = Game.currentGame.ui.buildings[obj.uid].x - stashPosition.x
let y = Game.currentGame.ui.buildings[obj.uid].y - stashPosition.y
let building = Game.currentGame.ui.buildings[obj.uid].type
let yaw = 180;
base += "PlaceBuilding(stashPosition.x + " + x + ", stashPosition.y + " + y + ", '" + building + "', " + yaw + ");"
}
localStorage.RecordedBase1 = base
})
}
window.buildRecordedBase = function() {
let waitForGoldStash = setInterval(function() {
if (document.querySelectorAll("[data-building]")[10].classList[1] == "is-disabled") {
stash = GetGoldStash();
if (stash == undefined) return
stashPosition = {
x: stash.x,
y: stash.y
}
clearInterval(waitForGoldStash)
game.ui.components.PopupOverlay.showHint("Base is successfully built!");
var basecode = localStorage.RecordedBase1
basecode = new Function(basecode)
return basecode()
}
}, 275)
}
window.DeleteRecordedbase = function() {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to delete recorded base?", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Recorded base has been successfully deleted!");
localStorage.RecordedBase1 = null;
})
}
function GetGoldStash() {
for (let i in game.ui.buildings) {
if (game.ui.buildings[i].type == "GoldStash") {
return game.ui.buildings[i];
}
}
}
window.PlaceBuilding = function(x, y, building, yaw) {
Game.currentGame.network.sendRpc({
name: "MakeBuilding",
x: x,
y: y,
type: building,
yaw: yaw
})
} // from main ultimate
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(`<div class="hud-chat-message"><a href="javascript:void(0);" onclick="window.blockPlayer(\`${msg.displayName}\`)" style="color: red;">Block</a> <strong>${b}</strong>: ${c}</div>`);
a.messagesElem.appendChild(d);
a.messagesElem.scrollTop = a.messagesElem.scrollHeight;
})
Game.currentGame.network.addRpcHandler("ReceiveChatMessage", onMessageReceived); // block chat messages, cutdown from ignition
let chattoggle = document.getElementById("chattoggle");
window.toggleChat = () => {
window.chatDisabled = !window.chatDisabled;
let hcm = document.getElementsByClassName("hud-chat-messages")[0];
if(window.chatDisabled) {
window.oldChatHTML = hcm.innerHTML;
hcm.innerHTML = "<h2>Disabled Chat</h2>";
chattoggle.classList.add("btn-red");
chattoggle.classList.remove("btn-theme");
} else {
hcm.innerHTML = window.oldChatHTML;
chattoggle.classList.add("btn-theme");
chattoggle.classList.remove("btn-red");
};
}; // toggle chat, from ignition
(function() { // modified private parties tab code, except the new tab in the party menu is used differently (not private parties)
let getElement = (Element) => {
return document.getElementsByClassName(Element);
}
let getId = (Element) => {
return document.getElementById(Element);
}
getElement("hud-party-members")[0].style.display = "block";
getElement("hud-party-grid")[0].style.display = "none";
let privateTab2 = document.createElement("a");
privateTab2.className = "hud-party-tabs-link";
privateTab2.id = "privateTab2";
privateTab2.innerHTML = "Share Keys";
let privateHud2 = document.createElement("div");
privateHud2.className = "hud-private hud-party-grid";
privateHud2.id = "privateHud2";
privateHud2.style = "display: none;";
getElement("hud-party-tabs")[0].appendChild(privateTab2);
getElement("hud-menu hud-menu-party")[0].insertBefore(privateHud2, getElement("hud-party-actions")[0]);
getId("privateTab2").onclick = e => {
for (let i = 0; i < getElement("hud-party-tabs-link").length; i++) {
getElement("hud-party-tabs-link")[i].className = "hud-party-tabs-link";
}
getId("privateTab2").className = "hud-party-tabs-link is-active";
getId("privateHud2").setAttribute("style", "display: block;");
if (getElement("hud-party-members")[0].getAttribute("style") == "display: block;") {
getElement("hud-party-members")[0].setAttribute("style", "display: none;");
}
if (getElement("hud-party-grid")[0].getAttribute("style") == "display: block;") {
getElement("hud-party-grid")[0].setAttribute("style", "display: none;");
}
if (getId("privateHud2").getAttribute("style") == "display: none;") {
getId("privateHud2").setAttribute("style", "display: block;");
}
}
getElement("hud-party-tabs-link")[0].onmouseup = e => {
getId("privateHud2").setAttribute("style", "display: none;");
if (getId("privateTab2").className == "hud-party-tabs-link is-active") {
getId("privateTab2").className = "hud-party-tabs-link"
}
}
getElement("hud-party-tabs-link")[1].onmouseup = e => {
getId("privateHud2").setAttribute("style", "display: none;");
if (getId("privateTab2").className == "hud-party-tabs-link is-active") {
getId("privateTab2").className = "hud-party-tabs-link"
}
}
getId("privateHud2").innerHTML = `
<h1>Share Keys</h1>
`;
game.network.addRpcHandler("PartyShareKey", function(e) {
let psk = e.partyShareKey;
let lnk = `http://zombs.io/#/${game.options.serverId}/${psk}/`;
getId("privateHud2").innerHTML += `<div style="display:inline-block;margin-right:10px;"><p>${psk} <a href="${lnk}" target="_blank" color="purple">[Link]</a></p></div>`
});
document.getElementsByClassName("hud-party-actions")[0].insertAdjacentHTML("afterend", `
<button class="btn btn-theme" style="width: 120px;margin: 10px 0 0 0;" onclick="game.network.sendRpc({ name: 'JoinPartyByShareKey', partyShareKey: document.getElementById('psk').value })">Join Party</button>
<input id="psk" style="margin: 10px 15px 0 15px;width: 280px;" placeholder="Party share key... (not link!)" value="" class="btn" />
<button class="btn btn-red" style="width: 120px;margin: 10px 0 0 0;box-shadow: none;" onclick="Game.currentGame.network.sendRpc({name: 'LeaveParty'});">Leave</button>
`);
})(); // modified party tools from ignition
const entirePop = document.getElementsByClassName("hud-intro-wrapper")[0].children[1];
const request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
let data = JSON.parse(request.responseText);
entirePop.innerHTML = `People in game now: ${data.players} - ${(data.players / data.capacity * 100).toFixed(2)}% / ${data.capacity}`;
let servers = ["US East", "US West", "Europe", "Asia", "Australia", "South America"];
for (let i in servers) {
game.ui.components.Intro.serverElem.children[i].setAttribute("label", `${servers[i]}: Population: ${data.regions[servers[i]].players}`);
}
}
};
request.open("GET", "http://zombs.io/capacity", true);
request.send(); // server pop by apex
const fullRSS = () => {
if(!window.frss) { return; };
let resources = ["wood", "stone", "gold"];
let pt = game.ui.playerTick;
let rc = game.ui.components.Resources;
for(let i = 0; i < resources.length; i++) {
let rs = resources[i];
rc[`${rs}Elem`].innerHTML = Math.round(pt[rs]).toLocaleString("en");
};
rc.tokensElem.innerHTML = Math.round(pt.token).toLocaleString("en");
};
let sipt = setInterval(() => {
game.ui.addListener('playerTickUpdate', fullRSS);
}, 50);
setTimeout(() => { clearInterval(sipt); }, 50); // full RSS from ignition, modified to refresh slower
let toolbar = document.createElement("a");
toolbar.classList.add("hud-toolbar-item");
toolbar.classList.add("hud-toolbar-item-crossbow");
toolbar.setAttribute("data-item", "Bow");
toolbar.setAttribute("data-tier", "6");
document.getElementsByClassName("hud-toolbar-inventory")[0].appendChild(toolbar);
document.getElementsByClassName("hud-toolbar-item-crossbow")[0].addEventListener("click", function() {
Game.currentGame.network.sendRpc({ name: "BuyItem", itemName: "Crossbow", tier: 1});
Game.currentGame.network.sendRpc({ name: "EquipItem", itemName: "Crossbow", tier: 1});
}); // crossbow icon buy&equip
let hasBeenInWorld = false;
game.network.addEnterWorldHandler(function () {
setTimeout(() => {
if (!hasBeenInWorld) {
var scoreLogged = 0;
if(!hasBeenInWorld) {
hasBeenInWorld = true
setInterval(() => {
document.querySelector('#scorelog')
.innerText = `Score in Last Wave: ${scoreLogged}`
}, 2000)
}
hasBeenInWorld = true;
var oldScore = Game.currentGame.ui.playerTick.score,
newScore = 0;
Game.currentGame.network.addRpcHandler("DayCycle", () => {
newScore = Game.currentGame.ui.playerTick.score;
scoreLogged = ((newScore - oldScore).toLocaleString("en"));
oldScore = Game.currentGame.ui.playerTick.score;
});
const topCenter = document.querySelector("#hud > div.hud-top-right");
let logElem;
logElem = document.createElement('div');
logElem.innerHTML = `<p id="scorelog" style="color: white;text-align: right;margin: -10px 0 0 0;">Score in Last Wave: 0</p>`;
topCenter.append(logElem);
}
}, 500)
}) // working score logger
function FixShield() {
if (Game.currentGame.ui.playerTick.zombieShieldHealth < 85000) {
Game.currentGame.network.sendRpc({name: "EquipItem", itemName: "ZombieShield", tier: Game.currentGame.ui.inventory.ZombieShield.tier});
}
}
Game.currentGame.network.addRpcHandler("DayCycle", FixShield); // ur avg afs
var map = document.getElementById("hud-map");
let markerId = 1;
window.addMarker = () => {
map.insertAdjacentHTML("beforeend", `<div style="color: red; display: block; left: ${parseInt(game.ui.components.Map.playerElems[game.world.getMyUid()].marker.style.left) - 4}%; top: ${parseInt(game.ui.components.Map.playerElems[game.world.getMyUid()].marker.style.top) - 12}%; position: absolute;" class='map-display'><i class='fa fa-map-marker'>${markerId++}</i></div>`)
};
/* keybinds */
document.addEventListener('keyup', function (e) {
if (e.key === "Enter" && game.ui.playerTick.dead === 1) {
game.ui.components.Chat.startTyping();
};
if (e.key === "`") {
window.addMarker();
game.ui.components.PopupOverlay.showHint(`Added Marker #${markerId-1}`);
};
});
document.addEventListener("keydown", e => {
if(document.activeElement.tagName.toLowerCase() !== "input" && document.activeElement.tagName.toLowerCase() !== "textarea") {
if (e.keyCode == 189) { // key -
showRSS = !showRSS;
};
};
if(document.activeElement.tagName.toLowerCase() !== "input" && document.activeElement.tagName.toLowerCase() !== "textarea") {
if (e.keyCode == 220) {
hardcoreMode = !hardcoreMode;
game.ui.components.PopupOverlay.showHint("Toggled Hardcore Mode.");
};
};
if(document.activeElement.tagName.toLowerCase() !== "input" && document.activeElement.tagName.toLowerCase() !== "textarea") {
if (hardcoreMode) {
if (e.key === "!") {
window.x3builds = !window.x3builds;
game.ui.components.PopupOverlay.showHint("Toggled 3x3 Block.");
};
};
};
if(document.activeElement.tagName.toLowerCase() !== "input" && document.activeElement.tagName.toLowerCase() !== "textarea") {
if(e.key === "=") {
document.getElementsByClassName("1i4")[0].click();
game.ui.components.PopupOverlay.showHint("Toggled Full RSS.");
};
};
if(document.activeElement.tagName.toLowerCase() !== "input" && document.activeElement.tagName.toLowerCase() !== "textarea") {
if(e.key === " " && game.ui.playerTick.weaponName === 'Bow') {
autobow = true;
};
if(game.ui.playerTick.weaponName !== 'Bow') {
autobow = false;
};
};
if(document.activeElement.tagName.toLowerCase() !== "input" && document.activeElement.tagName.toLowerCase() !== "textarea") {
if(e.key === "x") {
modm();
};
};
});