Last active
May 30, 2023 13:48
-
-
Save raidan00/87af63e594f5be28a2172141eac32e1e to your computer and use it in GitHub Desktop.
StarBreak-Bots: Auto Loot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name StarBreak-Bots: Auto Loot | |
// @version 1.0 | |
// @match https://*.starbreak.com/* | |
// @grant GM_setValue | |
// @grant GM_getValue | |
// @grant GM_addValueChangeListener | |
// ==/UserScript== | |
let autoLootLeftCode = "Quote"; | |
let autoLootRightCode = "Backslash"; | |
let slotsDecisionIC = { | |
"Main": [ | |
["Knockback Resist", "maxInt"], | |
["Quaestor", "maxInt"], | |
["Adjudicator", "maxInt"], | |
["Armor Piercing", "maxInt"], | |
["Plinks", "maxInt"], | |
["Extra Hit", "maxInt"], | |
["Damage", "maxInt"], | |
["Crit Chance", "maxInt"], | |
["Crit Damage", "maxInt"], | |
["Speed", "minInt"], | |
], | |
"Second": [ | |
["Seeking", "maxInt"], | |
["Missiles", "maxInt"], | |
["Explosion Damage", "maxInt"], | |
["Armor Piercing", "maxInt"], | |
["Max Ammo", "maxInt"], | |
["Trisected", "maxInt"], | |
], | |
"Special": [ | |
["Knockback Resist", "maxInt"], | |
["Acceleration", "maxInt"], | |
["Speed", "maxInt"], | |
["Armor", "maxInt"], | |
["Reflect", "maxInt"], | |
], | |
"Mobility": [ | |
["Overloaded Boosters", "maxInt"], | |
["Boosters", "maxInt"], | |
["Movement Speed", "maxInt"], | |
["Armor", "maxInt"], | |
["Jump Height", "maxInt"], | |
["Damage", "maxInt"], | |
], | |
"Body": [ | |
["Double Bandolier", "maxInt"], | |
["Bandolier", "maxInt"], | |
["Max Ammo", "maxInt"], | |
["Movement Speed", "maxInt"], | |
["Armor", "maxInt"], | |
["Damage", "maxInt"], | |
], | |
"Implant": [ | |
["Salites", "maxInt"], | |
["Calites", "maxInt"], | |
["Ultrites", "maxInt"], | |
["Inferior Salites", "maxInt"], | |
["Inferior Calites", "maxInt"], | |
["Inferior Ultrites", "maxInt"], | |
["Emites", "maxInt"], | |
["Armites", "maxInt"], | |
["Inferior Armites", "maxInt"], | |
["Velites", "maxInt"], | |
["Inferior Velites", "maxInt"], | |
["Bellites", "maxInt"], | |
["Inferior Bellites", "maxInt"], | |
["Delites", "maxInt"], | |
["Inferior Delites ", "maxInt"], | |
["Emites", "maxInt"], | |
["Inferior Emites", "maxInt"], | |
] | |
} | |
let slotsDecisionFab = { | |
"Main": [ | |
["Gavotte", "maxInt"], | |
["Range", "maxInt"], | |
["Seeking", "maxInt"], | |
["Dances", "maxInt"], | |
["Cycle Time", "maxInt"], | |
["Damage", "maxInt"], | |
["Crit Chance", "maxInt"], | |
["Crit Damage", "maxInt"], | |
], | |
"Second": [ | |
["Defiant Antiphon", "doNotUse"], | |
["Invidious Antiphon", "doNotUse"], | |
["Mocking Antiphon", "doNotUse"], | |
["Profane Antiphon", "doNotUse"], | |
["Blasphemous Antionphon", "doNotUse"], | |
["Scorpion", "maxInt"], | |
["Mangonel", "maxInt"], | |
["Whispered Antiphon", "maxInt"], | |
["Silent Antiphon", "maxInt"], | |
["Armored", "maxInt"], | |
["Damage", "maxInt"], | |
["Quick Summon", "maxInt"], | |
["Penetrating", "maxInt"], | |
["Cooldown", "minInt"], | |
], | |
"Special": [ | |
["Mechanized Macron", "doNotUse"], | |
["Skiff", "doNotUse"], | |
["Simultaneous", "maxInt"], | |
["Shielded", "maxInt"], | |
["Duration", "maxInt"], | |
["Shrapnel", "maxInt"], | |
["Armor Piercing", "maxInt"], | |
["Incendiary", "minInt"], | |
], | |
"Mobility": [ | |
["Overloaded Boosters", "maxInt"], | |
["Boosters", "maxInt"], | |
["Movement Speed", "maxInt"], | |
["Armor", "maxInt"], | |
["Base Crit Chance", "maxInt"], | |
["Base Crit Damage", "maxInt"], | |
], | |
"Body": [ | |
["Movement Speed", "maxInt"], | |
["Armor", "maxInt"], | |
["Base Crit Chance", "maxInt"], | |
["Base Crit Damage", "maxInt"], | |
], | |
"Implant": [ | |
["Calites", "maxInt"], | |
["Ultrites", "maxInt"], | |
["Inferior Calites", "maxInt"], | |
["Inferior Ultrites", "maxInt"], | |
["Salites", "maxInt"], | |
["Inferior Salites", "maxInt"], | |
["Emites", "maxInt"], | |
["Armites", "maxInt"], | |
["Inferior Armites", "maxInt"], | |
["Velites", "maxInt"], | |
["Inferior Velites", "maxInt"], | |
["Bellites", "maxInt"], | |
["Inferior Bellites", "maxInt"], | |
["Delites", "maxInt"], | |
["Inferior Delites ", "maxInt"], | |
["Emites", "maxInt"], | |
["Inferior Emites", "maxInt"], | |
] | |
} | |
let slotsDecision = slotsDecisionIC; | |
function sendKey(type, keyCode) { | |
let preventDefault = function dummyPreventDefault() {}; | |
let ev = { type, keyCode, preventDefault }; | |
XDL.onKey(ev); | |
} | |
let direction = 0; | |
GM_addValueChangeListener("startLoot", function(key, oldValue, newValue, remote) { | |
direction = newValue.direction; | |
if(newValue.type == "keydown"){ | |
lootingMode = true; | |
let selected = {}; | |
let equipped = {}; | |
sendKey("keydown", direction); | |
}else{ | |
lootingMode = false; | |
sendKey("keyup", direction); | |
} | |
}); | |
function listener(e){ | |
if (XDL.textInputActive) return; | |
if(e.code == autoLootLeftCode || e.code == autoLootRightCode){ | |
GM_setValue("startLoot", {rnd:Math.random(), type:e.type, direction: e.code == autoLootLeftCode? 37:39}); | |
} | |
} | |
document.addEventListener('keydown', listener, true); | |
document.addEventListener('keyup', listener, true); | |
let selected = {}; | |
let equipped = {}; | |
let lootingMode = false; | |
let firstHalfParse = ""; | |
function getDataFromStringTexture(obj, textStr, font, csscolor){ | |
//console.log(textStr) | |
if(!textStr.includes(":") && !firstHalfParse){ | |
textStr = textStr.replace("Modified ",""); | |
textStr = textStr.replace("Custom ",""); | |
textStr = textStr.replace("Experimantal ",""); | |
textStr = textStr.replace("Prototype ",""); | |
obj[textStr] = 1; | |
return; | |
}; | |
if(firstHalfParse){ | |
obj[firstHalfParse] = textStr.match(/[\+\-\w\d]+/)[0]; | |
firstHalfParse = ""; | |
return; | |
} | |
if(textStr.match(/:\s?$/) ){ | |
firstHalfParse = textStr.match(/[\w\s]+/)[0] | |
}else{ | |
let match = textStr.match(/([\w\s]+):\s([\+\-\w\d]+)/); | |
obj[match[1]] = match[2]; | |
} | |
} | |
function equipIt(){ | |
lootingMode = false; | |
sendKey("keyup", direction); | |
sendKey("keydown", 86); sendKey("keydup", 86); | |
sendKey("keydown", 70); sendKey("keydup", 70); | |
sendKey("keydown", 86); sendKey("keydup", 86); | |
sendKey("keydown", 68); sendKey("keydup", 68); | |
sendKey("keydown", 70); sendKey("keydup", 70); | |
sendKey("keydown", direction); | |
lootingMode = true; | |
} | |
function makeEquipDecision(){ | |
//console.log("makeEquipDecision"); | |
let arr = slotsDecision[selected["Slot"]]; | |
if(!arr)return; | |
for(let i=0; i<arr.length; i++){ | |
let [key, value] = arr[i]; | |
if(!selected[key])selected[key] = 0; | |
if(!equipped[key])equipped[key] = 0; | |
if(selected[key] == "doNotUse") return; | |
let diff = +selected[key] - +equipped[key]; | |
if(value == "minInt") diff* -1; | |
if(diff>0){ | |
equipIt() | |
return; | |
} | |
if(diff<0){ | |
return; | |
} | |
} | |
//console.log(selected, equipped) | |
} | |
function onLoaded(){ | |
(function (orig) { | |
RenderEngineWebGL._Z21XDL_CreateTextTextureiPKcijS0_ij = function (textureId, fontName, size, color, text, outlineSize, outlineColor) { | |
if(!lootingMode) return orig.apply(null, arguments); | |
var textStr = Pointer_stringify(text); | |
var font = size + 'px ' + Pointer_stringify(fontName); | |
var csscolor = TextUtils.loadColorToCSSRGBA(color); | |
//console.log(textStr); | |
if(textStr == "SELECTED" && font == "16px HemiHeadBold" && csscolor == "rgba(255,255,255,1)"){ | |
selected = {collectData: true}; | |
equipped = {}; | |
} | |
if(selected.collectData == true){ | |
getDataFromStringTexture(selected, textStr, font, csscolor) | |
} | |
if(equipped.collectData == true){ | |
getDataFromStringTexture(equipped, textStr, font, csscolor) | |
} | |
if(selected.collectData == true && textStr == "[V]" && font == "13px HemiHeadBold" && csscolor == "rgba(7,216,187,1)"){ | |
selected.vFound = true; | |
} | |
if(selected.vFound == true && textStr == "Equip"){ | |
sendKey("keydown", 86); | |
sendKey("keydup", 86); | |
selected = {}; | |
equipped = {}; | |
} | |
if(selected.vFound == true && textStr == "Pick Up"){ | |
selected.vFound = false; | |
selected.pickUpFound = true; | |
return orig.apply(null, arguments); | |
} | |
if(selected.pickUpFound == true && textStr != "--+[V]"){ | |
selected = {}; | |
equipped = {}; | |
} | |
if(selected.pickUpFound == true && textStr == "--+[V]"){ | |
equipped.collectData = true; | |
selected.collectData = false; | |
selected.pickUpFound = false; | |
} | |
if(equipped.collectData == true && (textStr.includes("Usable by:") || textStr == "Slot: Implant")){ | |
makeEquipDecision(); | |
selected = {}; | |
equipped = {}; | |
} | |
var tid = orig.apply(null, arguments); | |
return tid; | |
}; | |
})(RenderEngineWebGL._Z21XDL_CreateTextTextureiPKcijS0_ij); | |
} | |
function waitUntilLoaded () { | |
if (typeof RenderEngineWebGL == 'undefined' || typeof XDL == 'undefined' || typeof Module === 'undefined') { | |
setTimeout(waitUntilLoaded, 0); | |
return; | |
} | |
onLoaded(); | |
} | |
waitUntilLoaded(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment