Last active
January 26, 2025 03:49
-
-
Save nabbynz/0b63ad905300057d04bdf6214ceb2585 to your computer and use it in GitHub Desktop.
TagPro Pre-Game Spotlight Modifier
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 TagPro Pre-Game Spotlight Modifier | |
// @description Changes the pre-game spotlight into decreasing circles. Optional highlight own ball during game. | |
// @version 0.0.3 | |
// @match *://*.koalabeast.com/game | |
// @match *://*.koalabeast.com/game?* | |
// @updateURL https://gist.github.com/nabbynz/0b63ad905300057d04bdf6214ceb2585/raw/TagPro_Pre-Game_Spotlight_Modifier.user.js | |
// @downloadURL https://gist.github.com/nabbynz/0b63ad905300057d04bdf6214ceb2585/raw/TagPro_Pre-Game_Spotlight_Modifier.user.js | |
// @grant none | |
// @author nabby | |
// ==/UserScript== | |
console.log('START: ' + GM_info.script.name + ' (v' + GM_info.script.version + ' by ' + GM_info.script.author + ')'); | |
'use strict'; | |
/* eslint-env jquery */ | |
/* globals tagpro, tagproConfig, PIXI */ | |
/* eslint-disable no-multi-spaces */ | |
// --- OPTIONS --- | |
const MODIFY_SPOTLIGHT_CHANGE_ALPHA = true; // slow flashing effect | |
const MODIFY_SPOTLIGHT_CHANGE_SCALE = true; // decreasing scale effect | |
const ADD_BALL_HIGHLIGHT_ON_START = false; // adds a highlight to your ball when the game starts | |
// --- END OPTIONS --- | |
tagpro.ready(() => { | |
let tr = tagpro.renderer; | |
// tr.spotlight = false; // uncomment to disable the spotlight completely | |
// this puts back the spikey "M" on names... | |
tr.veryPrettyText = function (text, color) { | |
return new PIXI.Text(text, { | |
fontFamily: "Arial" , | |
fontSize: "11px", | |
fontWeight: "bold", | |
fill: color || "#FFFFFF", | |
stroke: "#000000", | |
strokeThickness: 2, | |
dropShadow: true, | |
dropShadowColor: "#000000", | |
dropShadowAngle: 0, | |
dropShadowDistance: 0, | |
dropShadowBlur: 3, | |
dropShadowAlpha: 0.8, | |
padding: 10, | |
}); | |
}; | |
function removeSpotlight() { | |
for (let playerId in tagpro.players) { | |
if (!tagpro.players.hasOwnProperty(playerId)) { | |
continue; | |
} | |
const player = tagpro.players[playerId]; | |
if (player.sprites && player.sprites.spotlight) { | |
player.sprites.spotlight.destroy(); | |
delete player.sprites.spotlight; | |
} | |
} | |
} | |
let prevPlayerSpotlight = tagpro.playerId; | |
tr.updateSpotlight = function() { | |
if (tr.spotlight !== false) { | |
if (tagpro.playerId !== prevPlayerSpotlight) { | |
removeSpotlight(); | |
} | |
let player = tagpro.players[tagpro.playerId]; | |
if (!player || !player.sprites) { | |
return; | |
} | |
if (tr.spotlight === null && [tagpro.states.ACTIVE, tagpro.states.OVERTIME, tagpro.states.CLUTCH].includes(tagpro.state)) { | |
tr.spotlight = false; | |
} else if (tagpro.state !== 3 && player.sprites.spotlight) { | |
player.sprites.spotlight.destroy(); | |
delete player.sprites.spotlight; | |
tr.spotlight = false; | |
if (ADD_BALL_HIGHLIGHT_ON_START && !tagproConfig.replay) { | |
player.sprites.highlight = new PIXI.Graphics; | |
player.sprites.highlight.position.set(20, 20); | |
player.sprites.highlight.beginFill((player.team === 1 ? 0xffcc99 : 0x99cccc), 0.5).drawCircle(0, 0, 16); | |
player.sprites.ball.addChild(player.sprites.highlight); | |
} | |
} else { | |
if (!player.sprites.spotlight && tr.spotlight !== false) { // tagpro.viewport.overview && tagpro.viewport.centerLock && | |
if (!player?.sprites?.actualBall?.visible) { | |
return; | |
} | |
player.sprites.spotlight = new PIXI.Graphics; | |
player.sprites.spotlight.alpha = 0.8; | |
player.sprites.spotlight.position.set(20, 20); | |
player.sprites.spotlight.lastSpotlightAlphaChange = performance.now(); | |
player.sprites.spotlight.lastSpotlightScaleChange = performance.now(); | |
player.sprites.spotlight.lineStyle(5, 0xFFFF00, 0.65).drawCircle(0, 0, 35).lineStyle(2, 0xFFFF00, 0.55).drawCircle(0, 0, 40).lineStyle(1, 0xFFFF00, 0.45).drawCircle(0, 0, 45); | |
player.sprites.ball.addChild(player.sprites.spotlight); | |
tr.spotlight = true; | |
} | |
if (player.sprites.spotlight) { | |
if (MODIFY_SPOTLIGHT_CHANGE_ALPHA && (performance.now() - player.sprites.spotlight.lastSpotlightAlphaChange > 200)) { | |
player.sprites.spotlight.alpha = player.sprites.spotlight.alpha === 0.6 ? 0.8 : 0.6; | |
player.sprites.spotlight.lastSpotlightAlphaChange = performance.now(); | |
} | |
if (MODIFY_SPOTLIGHT_CHANGE_SCALE && (performance.now() - player.sprites.spotlight.lastSpotlightScaleChange > 25)) { | |
player.sprites.spotlight.scale.x -= 0.01; | |
player.sprites.spotlight.scale.y -= 0.01; | |
if (player.sprites.spotlight.scale.x < 0.6) { | |
player.sprites.spotlight.scale.x = 1.25; | |
player.sprites.spotlight.scale.y = 1.25; | |
} | |
player.sprites.spotlight.position.set(20, 20); | |
player.sprites.spotlight.lastSpotlightScaleChange = performance.now(); | |
} | |
} | |
} | |
prevPlayerSpotlight = tagpro.playerId; | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment