Last active
June 25, 2024 14:41
-
-
Save Riemnand/9165300c0499c8b5f17c6f20baad41d6 to your computer and use it in GitHub Desktop.
Robo's istrolid script that highlights most dungerous cloaked units.
This file contains 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
/* | |
A script that highlights mines, cheeses, bombers and cloak cappers. | |
Ally mines and cheeses are statically highlighted in green. | |
Enemy mines and cheeses dynamically change color from yellow to red, which allows you to see when they move. | |
Made by RoboDrone @riemnand. | |
*/ | |
//cloak highlighter script: | |
(function() { | |
if (window.cloakHighlighterLoaded) { | |
return console.error("Error loading Robo's cloak highlighter script: another one is already loaded.") | |
} else { | |
window.cloakHighlighterLoaded = true | |
} | |
try { | |
types.Unit.prototype.draw = function() { | |
var a, color, j, l, len, len1, part, partNum, r, ref, ref1, s, t, value; | |
if (this.dead) { | |
return; | |
} | |
ref = this.parts; | |
for (j = 0, len = ref.length; j < len; j++) { | |
part = ref[j]; | |
if (typeof part.preDraw === "function") { | |
part.preDraw(); | |
} | |
part.computeWorldPos(); | |
} | |
if (this.maxShield > 0) { | |
s = this.warpIn * 2 - 1; | |
if (s > 0) { | |
color = [this.color[0], this.color[1], this.color[2], 255 * this.shield / this.maxShield * s]; | |
r = (this.radius + 40) / 255; | |
baseAtlas.drawSprite("img/point02.png", this.pos, [r, r], 0, color); | |
} | |
} | |
if (this.warpIn < 1) { | |
this.warpIn += 1 / 60; | |
} | |
ref1 = this.parts; | |
for (partNum = l = 0, len1 = ref1.length; l < len1; partNum = ++l) { | |
part = ref1[partNum]; | |
value = part.pos[1] / 700 - .5 + this.warpIn; | |
if (value > 0) { | |
part.draw(); | |
} else if (value > -0.2) { | |
a = -Math.sin(value / Math.PI * 50); | |
baseAtlas.drawSprite("img/unitBar/fire02.png", part.worldPos, [1, 1], 0, [255, 255, 255, 255 * a]); | |
continue; | |
} | |
} | |
if (this.energy / this.storeEnergy < .05) { | |
t = Math.abs(Math.sin(Date.now() / 300)); | |
baseAtlas.drawSprite("img/unitBar/energy1.png", [this.pos[0], this.pos[1] + 100 + this.radius], [1, 1], 0, [255, 100, 100, t * 200]); | |
} | |
var sizeMultiplier, speedToColor; | |
sizeMultiplier = 0.014 * this.radius | |
if (this.cloakFade > 0 && this.mass < 600 && (this.weaponDPS > 0 || this.genEnergy * 16 < 400) && !(this.weaponDamage <= 400 && this.maxSpeed * 16 < 130 && this.weaponDamage > 100)) { | |
if (this.side != commander.side) { | |
speedToColor = Math.min(v2.mag(this.vel) * 16, 255) | |
baseAtlas.drawSprite("img/unitBar/" + "rallyPoint.png", this.pos, [sizeMultiplier, -sizeMultiplier], 3.1416, [255, 255 - speedToColor, 0, this.cloakFade * 220]); | |
} else if (this.owner == commander.number) { | |
baseAtlas.drawSprite("img/unitBar/" + "rallyPoint.png", this.pos, [sizeMultiplier, -sizeMultiplier], 3.1416, [0, 255, 0, this.cloakFade * 220]); | |
} | |
} | |
if (control.debug && (this._pos2 != null) && this._pos) { | |
a = 16; | |
_offset[0] = this._pos2[0] + (this._pos[0] - this._pos2[0]) * a; | |
_offset[1] = this._pos2[1] + (this._pos[1] - this._pos2[1]) * a; | |
baseAtlas.drawSprite("img/pip1.png", this._pos, [1, 1], 0, [0, 255, 0, 255]); | |
baseAtlas.drawSprite("img/pip1.png", this.pos, [1, 1], 0); | |
return baseAtlas.drawSprite("img/pip1.png", this._pos2, [1, 1], 0, [255, 0, 0, 255]); | |
} | |
}; | |
} catch (err) { | |
console.error("Error in Robo's cloak highlighter script:\n" + err) | |
} | |
}).call(this) | |
//end. |
Author
Riemnand
commented
Jun 25, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment